Jump to content

Maverickb7

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Posts 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. 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.

  5. 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.

  6. 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?

  7. 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 />";
            }
        }
    }
    
    ?>
    

  8. 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.

  9. 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?

  10. 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?

  11. 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!

  12. 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);
    ?>
    

×
×
  • 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.