Jump to content

eevan79

Members
  • Posts

    240
  • Joined

  • Last visited

    Never

Everything posted by eevan79

  1. When I post text like: rep(/<a\s[^<>]*?href=\"?([^<>]*?)\"?(\s[^<>]*)?>([^<>]*?)<\/a>/gi,"[url=http://$1]$3[/url]"); I get following: rep(/<a\s[^]*?href=\"?([^]*?)\"?(\s[^]*)?>([^]*?)/gi,"[url=http://some_url_link.com]$3[/url]"); <> is removed This code I use to convert text: function convEnt2($text){ return strip_tags(str_replace( array("'", '"', "<", ">",'$','\\'), array(''', '"','<', '>','$','& #92;'), $text)); } Note & #92; is without space. I cant write it here, cause smf convert to \ But <> is removed from text. Also BBCode [ url=$1] is replaced with link instead of text. This BB code I use for link: '@\[(?i)url=(.*?)\](.*?)\[/(?i)url\]@si', '/\[url\]([^\"]*?)\[\/url\]/si', and replace with: '<a href="\\1" target="_blank">\\2</a>', '<a href="\\1" target="_blank">\\1</a>', How to fix to get text as written (<> and [ url=$1)? EDIT: Now I see...even in SMF [ url=$1 not working between wrapped bbcode [ php ]. I get [ url = http://$1 etc... SMF added "http://"
  2. Oh...you didnt understand . This is SELECT with different conditions (WHERE and LIMIT). In first I need to select all to get all users online. Second query check if user session exists (if not its INSERT another 'session' +1 user online). And third query checks last registered user from different table ('users' not 'user_online'). But this can be separated query. I want at least to "wrap" first 2 queries in one. --- Sorry I wrote wrong title of this topic - "Join same table".
  3. I tried to join same table (with aliases) but cant make to work. Here is code (separate): SELECT * FROM ".$table_prefix."online_users ORDER BY user ASC and SELECT session FROM ".$table_prefix."online_users WHERE session='".$session."' and SELECT user_name,user_id FROM ".$table_prefix."users ORDER BY user_date DESC LIMIT 1 How to do this in one single query? (is it possible?)
  4. Solved. Delete this post...or whatever
  5. Solved. Cookies didnt setup properly. setcookie('username', $_POST['user_name'], time()+60*60*24*365); setcookie('password', sha1($_POST['user_pass']), time()+60*60*24*365);
  6. I am not sure if following code working. First I set cookie when user login: //SET cookie if (isset($_POST['rememberme'])) { /* Set cookie to last 1 year */ setcookie('username', $_POST['user_name'], time()+60*60*24*365, '/account', ''); setcookie('password', sha1($_POST['user_pass']), time()+60*60*24*365, '/account', ''); } else { /* Cookie expires when browser closes */ setcookie('username', $_POST['user_name'], false, '/account', ''); setcookie('password', sha1($_POST['user_pass']), false, '/account', ''); } //END cookie In always included header.php I check if this cookie exist: if(isset($_COOKIE['username']) AND isset($_COOKIE['password']) AND $_SESSION['signed_in']==false) { $result=mysql_query("SELECT * FROM ".$table_prefix."users WHERE user_name = '".$_COOKIE['username']."'"); if (mysql_num_rows($result) >=1) { $row = mysql_fetch_assoc ($result); if (sha1($row['user_pass']) == sha1($_COOKIE['password'])) { echo "signed in"; $_SESSION['signed_in'] = true; $_SESSION['user_id'] = $row['user_id']; $_SESSION['user_name'] = $row['user_name']; $_SESSION['user_level'] = $row['user_level']; $_SESSION['user_ip'] = $_SERVER["REMOTE_ADDR"]; } } } and when user signout: setcookie('username', '', false, '/account', ''); setcookie('password', '', false, '/account', ''); I am not sure if this code working. How to check it (when session end?) ?
  7. I am using syntax highlighter to highlight code between tags. Here is bbcode: [b]search:[/b] [code=php:0]'/\[code\]([\s\S]*?)\[\/code\]/si' replace: '<pre><code>$1</code></pre> ' And its working fine. Now I want to reverse code (for example. when user edit post). So I use: '/<pre\s[^<>]*?code\"?[^<>]*?>([^<>]*?)<\/pre>/si' to: '[code ]$1[/code ]' But its not working. 1. How to properly reverse this regex? Also when I put code between [ code]and[/code ] tags I get lots of empty spaces. For example here is source from phpmyadmin: <pre><code>require_once 'Zend/Uri/Exception.php'; <br>require_once 'Zend/Uri/Http.php'; <br>require_once 'Zend/Uri/Mailto.php'; <br> <br>abstract class Zend_Uri <br>{ <br> <br> /** <br> * Return a string representation of this URI. <br> * <br> * @see getUri() <br> * @return string <br> */ <br> public function __toString() <br> { <br> return $this->getUri(); <br> } <br> <br> static public function factory($uri = 'http') <br> { <br> $uri = explode(':', $uri, 2); <br> $scheme = strtolower($uri[0]); <br> $schemeSpecific = isset($uri[1]) ? $uri[1] : ''; <br> <br> // Security check: $scheme is used to load a class file, <br> // so only alphanumerics are allowed. <br> if (!ctype_alnum($scheme)) { <br> throw new Zend_Uri_Exception('Illegal scheme'); <br> } <br> } <br>} <br>array("\r\n", "'", '"', '&', '$', '<', '>'), $text)); <br>?></code></pre> There are lots of <br>. 2. Can I remove double <br> when text is between [color=red] tags?[/color]
  8. Script moved at new location: http://novibb.iz.rs
  9. function write_value_of($var,$oldval,$newval) { $contents = file_get_contents('myfile.php'); $regex = '~\\'.$var.'\s+=\s+\''.$oldval.'\';~is'; $contents = preg_replace($regex, "$var = '$newval';", $contents); file_put_contents('myfile.php', $contents); } usage: write_value_of('$site',"This is a example",'Text to replace');
  10. Not bad idea, but it also need to check if there is image in post and then thumbnail that image. Anyway, I think Its better to replace image with link. I dont want to create thumbs if there is small images. Also, I have tested getimagesize and its very slow if there is more than one image.
  11. I found function that check file size (remote) function remote_filesize($url, $user = "", $pw = "") { ob_start(); $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); if(!empty($user) && !empty($pw)) { $headers = array('Authorization: Basic ' . base64_encode("$user:$pw")); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } $ok = curl_exec($ch); curl_close($ch); $head = ob_get_contents(); ob_end_clean(); $regex = '/Content-Length:\s([0-9].+?)\s/'; $count = preg_match($regex, $head, $matches); return isset($matches[1]) ? $matches[1] : "unknown"; } echo remote_filesize($text,'',''); How to use this function to check images in posts? First I need to find url between [ img] [/ img] tags and than use this function to check. If file size is >= 200 replace this [ img] tags with
  12. How to check size of image in post (text) and replace it with url? Example: I need to check if img tags exists in post and check size in kb of that image. If size >=200kb (example) than replace tags with: [url ]http://link_to_image.jpg[/url ]. This is code that I use to replace all [ img] tags with [ url] $text = str_replace ("[img ]","[url ]",$text ); $text = str_replace ("[/img ]","[/url ]",$text ); This code doesnt check image size, but replace all images with urls.
  13. You are right. Thanks for note. Large images must be reduced or replaced with links. Soon I'll add option that all large images convert into links (if image is larger than 1024x768 or 200kb - optional). Some other features implemented: Email settings: local or smtp, avatars, today dates converted into "Today" , forum permissions, bans...
  14. Here how I temporary solve this: and the popup dont shows up. Is there any better way?
  15. When I use two password field I get the popup window to select users. Here is screenshot but when I insert another input field that is different type (email) this popup dont shows up. I tried to set this input field hidden but still getting popup window. <tr> <td width="220" height="36"><div align="right">Password: </div></td><td> <div align="left"> <input size="30" type="password" name="user_password" /> </td> <tr> <td height="36"><div align="right">Confirm password:</div></td><td> <div align="left"><input size="30" type="password" name="user_pass_check" /></div></td></tr> How to prevent this popup to not show up???
  16. Now I see...that is not users from mysql database. That popup shows up users that is login on website (from local browser). When I insert another <input field that is not password type, popup dont show up. Strange.
  17. There is not code for the popup. Thats strange. Maybe it's happening cause I SELECT cofirm code (that is sended to user mail to confirm change pw). Confirm code is generated with this code: $confirm_code=md5(uniqid(rand())); and when user click on link that contains confirmation code I must verify that code exists in database: $result = mysql_query("SELECT confirm_code FROM ".$table_prefix."users WHERE confirm_code = '" . mysql_real_escape_string($_GET['passkey']) . "'") or die(mysql_error()); And this popup only shows when I type different password and confirm password! EDIT: I remove code that check password and confirm password and the popup still shows up! EDIT2: You are right. I tried it on different browsers and the popup didnt show up. Only on firefox...It seems that problem is related to passwords stored in browser cache or something...
  18. I almost finished code that allows users to change their password. But when type different password and confim password I get popup window to select all users from mysql database which I want to change password. Here is screenshot: And code: I almost finished code that allows users to change their password. But when type different password and confim password I get popup window to select all users from mysql database which I want to change password. Here is screenshot: And code: [code=php:0]<?php include ('header.php'); if (mysql_real_escape_string($_GET['changepass']) == 1) { if ($_SERVER['REQUEST_METHOD'] != 'POST') { //FORM CHANGE PW $passkey = mysql_real_escape_string($_GET['passkey']); $result = mysql_query("SELECT user_name, user_pass, confirm_code FROM " . $table_prefix . "users WHERE confirm_code = '" . mysql_real_escape_string($_GET['passkey']) . "'") or die(mysql_error()); if (mysql_num_rows($result) == 0) { echo '<br><b>Information</b><hr/><br/><div align="center"><font color="red">Wrong confirmation code or you have already changed your password.</font><br /><a class="loginlink" href="index.php"><br />Back to forum index</a>.</div><br />'; } else { echo ' <h3>Change your password</h3><br /> <div align="center"><span id="msg"></span></div> <form method="post" action=""> <table class="registration" border=1><tr> <th><b> Change password</b></th> <th><b></b></th></tr> <tr> <td width="220" height="36"><div align="right">Password: </div></td><td> <div align="left"> <input size="30" type="password" name="user_password" /> </td> <tr> <td height="36"><div align="right">Confirm password:</div></td><td> <div align="left"><input size="30" type="password" name="user_pass_check" /></div></td></tr> </div></table> <br /> <table class="registration" border=1> <tr> <td height="36"><input type="submit" class="inputButton" value="Submit" /> </td></tr></table></form> '; } } else { $errors = array(); if (isset($_POST['user_password'])) { if (strlen($_POST['user_password']) < 3) { $errors[] = 'The password field contain too few charachters.'; } if ($_POST['user_password'] != $_POST['user_pass_check']) { $errors[] = 'The two passwords did not match.'; } } else { $errors[] = 'The password field cannot be empty.'; } if (!empty($errors)) { echo '<b>Information</b><hr><br/><div align="center">Following fields are not filled in correctly.<br /><br /><tr>'; foreach($errors as $key => $value) /* walk through the array so all the errors get displayed */ { echo '<td><font color="red">' . $value . '<br /></td></tr></font>'; } echo '<br /><a href="javascript: history.go(-1) ">Try again</a></div><br /><br />'; } else { //CHANGE PASSWORD CODE HERE die; } } } Why I get popup window??
  19. Currently I cant send you source code, but it'll be available after few modification and then this code will be open source and available for download. Regards, Ivan
  20. This require restart server or not? Anyway, I use following script to compare time difference in minutes: date("Y-m-d H:i:s",$time); $mytime = date("Y-m-d H:i:s",$time); $time2 = mysql_query("SELECT NOW()"); $datetime = mysql_fetch_assoc($time2); $servertime = $datetime['NOW()']; echo "<br >Time difference: ".(strtotime($mytime) - strtotime($servertime))/ 60 ." minutes"; //and set variable $s_timediff = (strtotime($mytime) - strtotime($servertime))/ 60; When INSERT into table I just use NOW() + INTERVAL $s_timediff MINUTE and its working fine without setting up server timezone.
  21. How to get same dates from mysql and with php? On localhost I have current date for both. But when upload script I have time difference - with php I need +6 hours and in mysql +2 hours. $time = strtotime("+6 hours"); date("d.m.Y, H:i",$time); and I got: 14.07.2010, 03:30 When I insert something in mysql table with NOW() I have: 14.07.2010, 01:30 How to synchronize both dates to work on all servers?
  22. wildteen8, thanks. It's working. @Ken, I know. Your script are very usefull anyway, specially if I change code for including variables as Crayon Violent suggest. Thanks all for for help.
  23. Unfortunately, I noticed some failure in function When I call function it add "=" at first 3 lines and at last 3 lines. So it look like this: <?php = session_start(); = = $server = 'localhost'; $username = 'root'; $password = ''; instead of: <?php session_start(); $server = 'localhost'; $username = 'root'; $password = ''; ... $topics_per_page = '10';
  24. Finally . Awsome ken. I'm working on this all day. Finally works perfectly. Thank you from me!
  25. All images are autoresized. Example here - http://avs-demo.iz.rs/testforum/topic.php?t=1 (...if you think about that. )
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.