Jump to content

adrianTNT

Members
  • Posts

    146
  • Joined

  • Last visited

Everything posted by adrianTNT

  1. [blmg911 Member Posts: 150] Quick, let's find his other posts
  2. Hello, I have a function that is supposed to loop over a given directory and remove all its sub files AND folders. The problem is... in some situations it crashes the server, I think it does an infinite loop. I know that it does this when I have MAC files in that folder, whenever this happens I always have a sub folder named "__MACOSX" and inside that folder there are files starting with "._", like ._photo.jpg Can someone please tell me how to fix ths function? It probably has something to do with area $child[0] == '.' Or maybe cause is that directory is never closed back, I dont know where to close it (not my code) // remove all contents of the directory function rmdir_r($path) { if (!is_dir($path)) {return false;} $stack = Array($path); while ($dir = array_pop($stack)) { if (@rmdir($dir)) {continue;} $stack[] = $dir; $dh = opendir($dir); while (($child = readdir($dh)) !== false) { if ($child[0] == '.') {continue;} $child = $dir . DIRECTORY_SEPARATOR . $child; if (is_dir($child)) {$stack[] = $child;} else {unlink($child);} } } return true; } rmdir_r('temp2'); Thank you.
  3. Hello, I have a function that is supposed to loop over a given directory and remove all its sub files AND folders. The problem is... in some situations it crashes the server, I think it does an infinite loop. I know that it does this when I have MAC files in that folder, whenever this happens I always have a sub folder named "__MACOSX" and inside that folder there are files starting with "._", like ._photo.jpg Can someone please tell me how to fix ths function? It probably has something to do with area $child[0] == '.' // remove all contents of the directory function rmdir_r($path) { if (!is_dir($path)) {return false;} $stack = Array($path); while ($dir = array_pop($stack)) { if (@rmdir($dir)) {continue;} $stack[] = $dir; $dh = opendir($dir); while (($child = readdir($dh)) !== false) { if ($child[0] == '.') {continue;} $child = $dir . DIRECTORY_SEPARATOR . $child; if (is_dir($child)) {$stack[] = $child;} else {unlink($child);} } } return true; } rmdir_r('temp2'); Thank you.
  4. I already have many "user comments" in database and Is best to find a good way to display those instead of using something like BB code. Maybe somone can tell me how to apply a htmlentities on text outside of the <a> tags for this function? How can I do a htmlentities($1) and htmlentities($2) for this code? <?php // converts links inside plain text to clickable <a> tags if (!function_exists("text_to_clickable_link")) { function text_to_clickable_link($text){ # this functions deserves credit to the fine folks at phpbb.com $text = preg_replace('#(script|about|applet|activex|chrome):#is', "$1:", $text); // pad it with a space so we can match things at the start of the 1st line. $ret = ' ' . $text; // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing // Must contain at least 2 dots. xxxx contains either alphanum, or "-" // zzzz is optional.. will contain everything up to the first space, newline, // comma, double quote or <. $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "$1<a href=\"http://$2\" rel=\"nofollow\" target=\"_blank\">$2</a>", $ret); // Remove our padding.. $ret = substr($ret, 1); return $ret; } } ?>
  5. Hello, I did a search, I didn't find something similar... I need a function, maybe someone can help. I need to display a user comment (just like a forum post) and - convert the plain text into a clickable html link - do wordwrap on the visible text but not inside the link tag - do a htmlentities or htmlspecialchars on the text outside of the link This is exactly how Vbulletin posts are processed, liks are clickable and text is wrapped properly to avoid long texts that break site layout. Anyone can help? I am sure some people used this in websites. Thanks.
  6. I think with XMLWriter I would have to code the whole page differently. I tried some more things and it appears to work ok like this: $listing_title = $row_Recordset_listings_rss['listing_title']; $listing_title = strip_tags($listing_title); $listing_title = str_replace("\r\n"," ",$listing_title); $listing_title = htmlspecialchars($listing_title); $listing_title = utf8_encode($listing_title); Using htmlspecialchars to get rid of the errors generated by characters like "&". So apparently it works ok now. Thank you for your time. - Adrian.
  7. I guess it's "manually" without XML functions ... I have: <?php header("content-type: application/rss+xml charset:utf-8",true);?> <?php echo html_entity_decode('<?xml version="1.0" encoding="utf-8" ?>');?> ... <?php echo "<title>".$listing_title."</title>\n";?> ...
  8. Hello, the tables show latin1_swedish_ci as "collation" and the same in an upper level; I don't know if is correct or not. (These should be the default values that php my admin shown me when setting the database). I later saw that I had an html_entities() done on the image_title and that was what caused the error I mentioned above in first post. I removed the html_entities() and did this: $image_title = strip_tags($image_title); $image_title = str_replace("\r\n"," ",$image_title); $image_title = utf8_encode($image_title); But when it reaches an '&' it says: Whitespace is not allowed at this location. Error processing resource 'feed.xml'. Line 1353, Positio... <description>Mother & daughter Golden Retriver's Molly & Elsie Do you know what I should do about this? Should I just str_replace the '&' with something like 'and' or there is a more professional fix to avoid this? Thanks.
  9. Hello. I have some issues understanding special characters and how they should be printed on screen. For example... php takes from database an image title and it is: "Brasão" with that special "a". In the web page it is printed correctly but inside an rss (feed file that I made) it says: The XML page cannot be displayed Reference to undefined entity 'Atilde'. Error processing resource 'http://www.jpgbox.com/feed.xml'. Line 76, Position 16 <title>Brasão Rio Grande do Sul</title> ---------------^ Is there a function that I can use to convert the string to be safely printed in the RSS file? In my rss header I have application/rss+xml charset:utf-8. I hope I explained correctly. Thank you. - Adrian.
  10. By truncating \\2 I mean that the anchor text of an < a > tag will get shorter, so that the link will not be too large in the page and damaging the layout. Can someone post a sample for the str_replace ? Because as I know that one will only replace an exact string and I cannot see a way to create the link html code with that.
  11. I dont think str_replace can do that in order to find patterns like http:// and www, can it? I am completely lost when I try to understand those things like: ("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*) Any other ideas?
  12. Hello, I have a code that creates <a> tags (clickable links) from plain text urls. This code searches for http:// and www and creates the <a> tags. $ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" rel=\"nofollow\" target=\"_blank\">\\2</a>", $ret); How can I truncate the \\2 before the </ a>? So that it doesn't break my layout. I have a truncate_text() function but I don't know how to insert it there. Thank you.
  13. That worked. Thank you very much Rajiv.
  14. I managed to do it by count(DISTINCT user_id) FROM table_name, it returns correct results but it looks buggy to me, is this correct? // total unique users subscribed to at least one category mysql_select_db($database_cms, $cms); $query_Recordset_stats_unique_subscribers = "SELECT count(DISTINCT cat_subscription_user_id) FROM cat_subscriptions"; $Recordset_stats_unique_subscribers = mysql_query($query_Recordset_stats_unique_subscribers, $cms) or die(mysql_error()); $row_Recordset_stats_unique_subscribers = mysql_fetch_assoc($Recordset_stats_unique_subscribers); $totalRows_Recordset_stats_unique_subscribers = mysql_num_rows($Recordset_stats_unique_subscribers); I have "count" there in 2nd line but in order to return the total is this line correct? Do I use count distinct again? <?php echo $row_Recordset_stats_unique_subscribers['count(DISTINCT cat_subscription_user_id)']; ?> It is the second code that looks buggy, I am not sure the thing inside the [] is correct, it does return the correct results but I was expecting it to return the total by: $totalRows_Recordset_stats_unique_subscribers Is it correct?
  15. Hello, can someone tell if there is a commend for this? I have a table that has fields like: ID CATEGORY ID USER ID -----+----------------+------------- 0 10 25 1 12 24 2 9 24 3 20 25 (The table represents users subscribed to categories). User id can be more than once in the table, I want to find the total number of users subscribed to categories, in the above sample this total would be 2 (user 24 and user 25). I think the command (if exists) should be something like: "count total unique values of USER ID from TABLE_NAME" ? Any ideas? Thanks.
  16. I thought there are some simple predefined image functions for this, after some searching I found a script that gets a bit complicated, it is done by getting the average color of each pixel between the two images (image vs watermark) and then merge them in order to create a smooth combination between them. It works OK: http://www.devshed.com/c/a/PHP/Dynamic-Watermarking-with-PHP/
  17. Hello. I am trying to put watermarks on images on-the-fly by a php script, in general this is done by merging two images , the source and a watermark (usually PNG with transparency). The problem is ... I cannot get the right combination (jpg/png, 8/16 bits, indexed color/RGB color) in order for the watermark to appear with smooth edges over the source image, the watermark always appears eider with white opaque background or when it is transparent it has rough edges. Any advices? Thank you.
  18. It works now. No spaces when I tested but today it works fine, it was a cache issue. Yes, something like that, but the problem now was the header info to tell browsers to treat it like an XML file, I will now see if it works to dinamically generate the tags, this part should not be a problem. Thank you both for your time.
  19. Hello, I want to generate a feed file dynamically inside a .php file, but in my browser it looks like a plain file even if the source file contains the right tags, I simplified it to this code (attached), is the header info incorrect or why does the browser read it like a plain file? <?php header ("content-type: text/xml");?> <?php echo html_entity_decode('<?xml version="1.0" encoding="UTF-8" ?>');?> <rss VERSION="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <item> <title>Pong</title> <link>http://www.site.com/flash/games/pong_1327.html</link> <description>Flash Ping-Pong game.Just my version of one of the first games.</description> </item> <item> <title>RSS reader</title> <link>http://www.site.com/flash/web_applications_and_data/rss_reader_1326.html</link> <description>RSS reader in AS2, uses shared object to save the address if u want</description> </item> </channel> </rss> I can make it physically save an XML file but I prefer to show the xml contents in the php file. Any ideas? Thanks.
  20. Thanks for the replies guys, yes, I needed === (three of them), !== actually did exactly what I wanted. I receive fast accurate replies here (like always). Great community.
  21. I have this code, the strpos in the function should return false when string is not found, correct? But instead it seems to return false for found string? What am I soing wrong? I can use the code like this too but it looks worong. <?php function check_referer($the_referer_to_check){ // list of urls to remove from referers list when reading the list of referers $bad_referers = array('yahoo','google','.mail.live.com','search.msn','abv','google.de','google.se'); for($i=0;$i<count($bad_referers);$i++){ // if string not found then value is FALSE, correct? // so why does it return values for *found values? if(strpos($the_referer_to_check, $bad_referers[$i]) == 'FALSE'){ echo $bad_referers[$i].' NOT found in ' .$the_referer_to_check.'<br>'; } } } check_referer('google.com'); check_referer('site.com'); // this one is not in the bad_referers check_referer('abv.bg'); ?> Returns:
  22. Thank you Wuhtzu I adjusted row names a bit and the code worked nicely. Have a great day.
  23. What are you trying to do? I use a simple PHP script to communicate with PayPal by PayPal IPN service.
  24. I think this could help you extract some data from the html tags (links, titles, etc): Class: Get tag value http://www.phpclasses.org/browse/package/4033.html I didn't tested it but looks like what you need.
  25. I smell click fraud
×
×
  • 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.