Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Try $_SESSION['products'] = serialize($products); Remember to unserialize() it when you need to get it again.
  2. It's just an install of phpBB with no content and using the default skin... What is there to comment on?
  3. Seeing as you have a list of functions you might want to link to the relevant manual entry.
  4. It's a library function: http://php.net/number_format
  5. What do you mean with "right side"?
  6. It won't be published before it's approved. I.e. yes, you can preview it.
  7. SELECT * FROM table ORDER BY RAND() LIMIT 1; or some of the methods here.
  8. I edited my post just before you replied
  9. You can use $_SERVER['REQUEST_URI'] for that. Edit: That won't get the entire URL though. You'll need to combine some different variables like this: <?php switch($_SERVER['SERVER_PORT']) { default: case 80: $url = 'http'; break; case 443: $url = 'https'; break; } $url .= '://'.$_SERVER['SERVER_NAME'].(!in_array($_SERVER['SERVER_PORT'], array(80, 443)) ? ':'.$_SERVER['SERVER_PORT'] : null).$_SERVER['REQUEST_URI']; echo $url; ?>
  10. Don't waste money on buying anti-virus programs (McAffee, Norton, etc.), don't even waste bandwidth on pirating them. The free ones (like AVG which neylitalo linked to) are much better IMO. Those commercial ones seem bloated and hogs all the system resources - that's at least my experience.
  11. Is that the only code on that page/in that file?
  12. handle_img_bbcode() still needs to return something as that is what the tag will be replaced with. If you add in the return from my original function at the end if handle_img_bbcode() then it should work again.
  13. No, handle_img_bbcode() is what is a callback function. Basically preg_replace_callback() will pass an array of matches to that function. Take a look at http://php.net/preg_replace_callback for more info. You just need to pass it to the bbCode() function.
  14. You could do it like this: <?php function handle_img_bbcode($matches) { $url = $matches[1]; list($width, $height) = getimagesize($url); // check if it's too large here... return "<img src='{$url}' width='{$width}' height='{$height}' />"; } function bbCode($input) { $input = strip_tags($input); $bbcodes = array('[b]','[/b]','[i]','[/i]','[u]','[/u]'); $htmlbbcodes = array('<b>','</b>','<i>','</i>','<u>','</u>'); $input = preg_replace_callback("`\[img\]([\w]*[:\/\/]*[\w\.\?\/&=\;, \-@%\?]+)\[/img\]`isU", 'handle_img_bbcode', $input); $input = str_replace($bbcodes, $htmlbbcodes, $input); return $input; } ?>
  15. Yeah, it's really handy. I have similar ones for Google (google - http://www.google.com/search?q=%s), Wikipedia (wp - http://en.wikipedia.org/wiki/Special:Search?search=%s) and Dictionary.com (d - http://dictionary.reference.com/search?q=%s). It makes looking things up a little faster.
  16. Yeah, the above code I posted will do that (get the image url+width+height). If there is anything in the code you don't understand feel free to ask Just modify handle_img_bbcode() to throw an error if it's too big.
  17. I just tested my own email on your function. It works fine for me. Are you testing with some non-standard email or something?
  18. This is what I do: I setup a bookmark like this: http://php.net/%s Then I go edit the bookmark and make the keyword "p" (without quotes). Then I just have to type p function_name in the address bar to jump to it's manual page. E.g. p substr will go to http://php.net/substr
  19. Hmm... yeah, you're right... didn't notice that. There are a number of different regular expressions for emails you can use here though: http://www.regular-expressions.info/email.html
  20. The str_repeat() was just to get a string long enough to be truncated. I just didn't bother to to type a lot of characters so I had PHP do it for me. You'd just use it like this: truncate('long text here')
  21. Is this sort of what you want? <?php function handle_img_bbcode($matches) { $url = $matches[1]; list($width, $height) = getimagesize($url); return "<img src='{$url}' width='{$width}' height='{$height}' />"; } $string = "[img=http://www.phpfreaks.com/images/logo_main.jpg]"; $string = preg_replace_callback("`\[img\]([\w]*[:\/\/]*[\w\.\?\/&=\;, \-@%\?]+)\[/img\]`isU", 'handle_img_bbcode', $string); echo $string; ?> Output: <img src='http://www.phpfreaks.com/images/logo_main.jpg' width='510' height='94' /> I don't see why you'd want to get the height and width for bbcode images. If there are more than a few then it might increase the load time as the server first would have to download the image (and wait until it's done) and then the user would have to download the image as well.
  22. Something like this? <?php function truncate($string, $max_chars = 30) { if(strlen($string) > $max_chars) { $string = substr($string, 0, $max_chars).'...'; } return $string; } echo truncate(str_repeat('abc', 20)); ?>
  23. Q1: Use {6,} instead of {6,40} Q2: A-Z will only accept uppercase characters (that's actually a "bug" in all the regular expressions in your code (unless of course you only want your users' passwords and usernames to have uppercase characters, underscore and numbers)). You need to specify both the uppercase characters and lowercase characters (i.e. a-zA-Z).
  24. Well, I don't know if it's horrible, it's just not how I would have done it. It was more like the usage of HTML and CSS I was thinking about. Try to google "tableless layout" to see what I mean - plenty of resources, no need to post it here since this is a topic meant for review of the looks.
  25. At the software page: The headers (security, productivity etc.) could use some padding and some margin-bottom. You might want to add links to the buttons/images for the software as well. On the chatroom you might want to change the timestamps so they are based on the client and not the server time. It said 10:31 am when I tested it, but it was 6:31 pm. The bars/headers saying stuff like "Top News Story" (front page) could use some padding as well. I don't understand the about page. There are just a lot of icons...
×
×
  • 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.