Jump to content

Maverickb7

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Everything posted by Maverickb7

  1. With the popularity of Bittorrent I was surprised to see that I could find many resources on how to display a torrents information via PHP. I've searched google, websites, and forums for a while now and I've come up empty handed. I've found some other scripts that do it, buts the code is to complex as the scripts are rich with features that make it hard to tell whats really needed. Does anyone know of any php examples, scripts, or tutorials that would help me extract information about torrents. Gathering information like seeders, leechers, file size, file content, ect.. would be very useful. I'm hoping that alot of you have resources to share because I'm really lost. =(
  2. Alright. I'm trying to create a file that will display a image galley. The file would scan a specified folder for images and would then create a thumbnail of each image with a link to the full sized image. I've been able to scan a directory, create a thumbnail, and display the images but I've hit a wall. What I want to do now is have x number of images to be displayed on each page. So in other words it would show 15 images on one page and would have a 1, 2, 3, 4, 5, 6, 7, 8, ect... if more images exsist. Also, I want to know how I would go about doing this without reloading the page.. this is not an importent feature but it looked nice on other sites. Does anyone know any tutorials or something that would help me out?
  3. I'm trying to use: str_replace("&", "?", $data) but I think the ; with & is cutting the code short. How can I escape that ; so it includes within the string and doesn't think its ending the line?
  4. wow.... I finally figured out what it was. Turns out some of the feeds had already broke the string down like html_entity would, so i used html_entity_decode to decode all those first, then removed all html tags. Thanks for all your help!
  5. Like I said before. I replaced split() with strip_tags() using $fp and echoed the results and it was clean text, all HTML code was removed and everything looked great. But doing that killed the code. I think it removed the xml blocks to, not sure. But it doesn't wanna work like that. =( I've been working on this for hours and hours and can't seem to figure it out. ANY help is appreciated.
  6. Yeah I know, I was originally using the CURL code to read file that has its data devided by comma's. I haven't found a way to remove the split() without killing the code. It's reading a rss feed so I dont see why the split() would be needed? I'm new to PHP and still learning so perhaps I'm missing something.
  7. but why would I need to use that comma? It's a rss/xml feed. Should I still use that?
  8. I've tried that previously and it didn't help any. It still displays partial pieces of the html within the string. I was playing a little bit with the CURL area of the code and noticed that when I replace split() with strip_tags() the code is completely clean. The only problem is the script does not function if I change that. One strange thing I wanted to ask about was the split() function. I use to use this code to open csv files that had data seperated by commas. I tried to remove it within this code, but the foreach right after doesn't work then. =s How can I get around using split without killing my code?
  9. Why does html still get through strip_tags and how can I increase the accuracy of removing all html? I really need help guys. =(
  10. Here is the code I've come up with so far. Basically what I'm trying to do is take a RSS feed, grab the items, check if there in the database, and if not add them. But during that process I want to strip out all html including links, images, text styles.. ect... <?php $connection = mysql_connect("localhost", "DBuser", "$DBpass"); mysql_select_db("$DB", $connection); $counter = 0; $type = 0; $tag = ""; $itemInfo = array(); $channelInfo = array(); function opening_element($xmlParser, $name, $attribute){ global $tag, $type; $tag = $name; if($name == "CHANNEL"){ $type = 1; } else if($name == "ITEM"){ $type = 2; } }//end opening element function closing_element($xmlParser, $name){ global $tag, $type, $counter; $tag = ""; if($name == "ITEM"){ $type = 0; $counter++; } else if($name == "CHANNEL"){ $type = 0; } }//end closing_element function c_data($xmlParser, $data){ global $tag, $type, $channelInfo, $itemInfo, $counter; $data = strip_tags($data); $data = addslashes($data); if($tag == "TITLE" || $tag == "DESCRIPTION" || $tag == "LINK"){ if($type == 1){ $channelInfo[strtolower($tag)] = $data; }//end checking channel else if($type == 2){ $itemInfo[$counter][strtolower($tag)] .= $data; }//end checking for item }//end checking tag }//end cdata funct $xmlParser = xml_parser_create(); xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, TRUE); xml_parser_set_option($xmlParser, XML_OPTION_SKIP_WHITE, TRUE); xml_set_element_handler($xmlParser, "opening_element", "closing_element"); xml_set_character_data_handler($xmlParser, "c_data"); $ch = curl_init(); $timeout = 5; // set to zero for no timeout curl_setopt ($ch, CURLOPT_URL, $_GET['rss']); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $fp = curl_exec($ch); curl_close($ch); $fp = split(",", $fp); foreach($fp as $line){ if(!xml_parse($xmlParser, $line)){ die("Could not parse file."); } } foreach($itemInfo as $items){ $query = mysql_query("SELECT * FROM articlefeed WHERE title = '".htmlentities($items['title'], ENT_QUOTES)."'") or die(mysql_error()); $num = mysql_num_rows($query); if($num > 0){ echo $items['title']." already exists!<br />"; } else { if (mysql_query("INSERT INTO articlefeed VALUES('', '".$items['title']."', '".htmlentities($items['description'], ENT_QUOTES)."', '".htmlentities($items['link'],ENT_QUOTES)."')") or die(mysql_error())){ echo $items['title']." was added!<br />"; } } } ?>
  11. isn't that what addslashes() does? It adds slashs in front of all the single and double quotes? And to answer you question yes the content is going to be dynamic and none of the input within the string is going to be under my control. So I have to clean it up myself after its been sent to me.
  12. Alright, this should be pretty easy right? Well... i'm trying it so of course something has to go wrong. I have a string that contains various types of html like imgs and links. I want to remove all html from this string. Now I've tried using strip_tags() but it give something like... the string holds... <b>Ubisoft reveals it's long-speculated Clancy franchise under construction at the Shanghai studio.</b><br /> Ubisoft has revealed the long-speculated latest entry in the Tom Clancy series, EndWar, a strategy game set on the backdrop of World War III.<br /><br /><a href="http://www.computerandvideogames.com/article.php?id=162648?cid=OTC-RSS&attr=CVG-News-RSS"><img src="http://medialib.computerandvideogames.com/screens/screenshot_177640_thumb93.jpg"></a> <br /><br /><a href="http://www.computerandvideogames.com/article.php?id=162648?cid=OTC-RSS&attr=CVG-News-RSS">Click here to read the full article</a> and when I use strip_tags(addslashes($mystring)) it gives me: Riots earthquakes and pollution strike in new screens. We've got a shed-load of new screens from EA's DS outing in its classic sim series Sim City. alib.computerandvideogames.com/screens/screenshot_177546_thumb93.jpg"> m/screens/screenshot_177551_thumb93.jpg"> humb93.jpg"> p://www.computerandvideogames.com/article.php?id=162585?cid=OTC-RSS&attr=CVG-News-RSS"> Click here to read the full article what am I doing wrong?
  13. Yeah, makes sense. I already know how to add items in a database, I'm just not to familiar with RSS feeds. I'll look into parsing rss feeds and see what I can come up with.
  14. links... scripts... anything that could help would be appreciated...
  15. I've tried very hard to find something to help me do this on my own but I've come up empty handed. I've searched google and countless other sites for the answer and now I turn to phpfreaks. I'm trying to learn how to do the following: I want to have a list of RSS feeds. I want to go through the list when a certain page is visited and then add each item from each feed to the database. I haven't been able to find any tutorials or scripts that do this and i've been trying to learn. Can anyone point me in the right direction?
  16. It would probably help everyone alot more if you showed the actually code being used. Then maybe someone could pin point whats going wrong for you.
  17. Sadly I haven't taken any PHP classes. I'm just reading tutorials and getting help on phpfreaks. This place sure has been a great help to me. Seems like everytime I come here I'm learning something new because of someone elses problem. =P
  18. I think your using the code wrong. Create a file called thumbnail.php and place this code in. Now simply use thumbnail.php like it was an image and call it like: <img src="http://www.yoursite.com/thumbnail.php"> this should work for you as long as you have an image called yourfile.jpg in the same directory. You could use $_GET to specific which image you wanna thumbnail as well, rather then naming a file within thumbnail.php. Hope that helps!
  19. oh alright. I see what your saying now. Your just sayin it's not good to use $_GET['q'] directly because of what it might hold. Basically all your saying is its better to filter out bad characters before using it within a query string?
  20. so instead of: $query = mysql_query("SELECT * FROM table") or die(mysql_error()); would be: $query = mysqli_query("SELECT * FROM table") or die(mysql_error());
  21. I use something simular so that's why I'm asking.
  22. Sorry to break in on your topic. but genericnumber1.. why is it vulnerable to sql injection and what can you do to secure it?
  23. This should resize your image fairly easy. I'm sure you could come up with something better if you modified it a bit. You could set it up as a function so it'll be easy to use. <?php // The file you are resizing $file = 'yourfile.jpg'; //This will set our output to 45% of the original size $size = 0.45; // This sets it to a .jpg, but you can change this to png or gif header('Content-type: image/jpeg'); // Setting the resize parameters list($width, $height) = getimagesize($file); $modwidth = $width * $size; $modheight = $height * $size; // Resizing the Image $tn = imagecreatetruecolor($modwidth, $modheight); $image = imagecreatefromjpeg($file); imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height); // Outputting a .jpg, you can make this gif or png if you want //notice we set the quality (third value) to 100 imagejpeg($tn, null, 100); ?>
  24. Sounds good and works great. Thanks for all your advice and help.
×
×
  • 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.