Jump to content

[SOLVED] really slow script


thewooleymammoth

Recommended Posts

ive got a page going that reads a file, if it exists and outputs it in a table, im trying to create a sort by catogory type link.

 

<?php
$pagename='Links';
include('tophalf.php');
?>
<?php 
if(isset($_COOKIE['auth'])) {  
echo "<table width='100%'>
      <tr align='center'>
        <td align='center'>
        Sort By
        </td>
      </tr>
      <tr align='center'>
        <td align='center'>
        <a href='links test.php?type=Comedy'>comedy</a>
        </td>
      </tr>
      <table>";
      $lastlink = 50;
  $type=strip_tags($_GET['type']);
  while($lastlink != 0){
    $filename = "links/".$lastlink.'.txt';
      
      if (is_readable($filename)){
        $openfile = fopen($filename, "r") or die('error1');;
        $content = fread($openfile, filesize($filename)) or die ('error2');
        $conexp = explode('|',$content);
        $date = date('F d Y H:i:s.', filemtime($filename));
        $user= $_COOKIE['auth'];
        $filenamecom="links/".$lastlink."com.txt";
        $color1='#4F4F4F';
        $color3='999999';
        $color2='#E5E5E5';
         if ($type == All || $type == $conexp[0]){
            echo "
            <table border='0' width='50%' bgcolor='$color1' cellpadding='5' cellspacing='2' align='center'>
                    <tr>                	
                      <td>insert advertisement<br></td>
                    </tr>
                    <tr>
                    <td align='left' width='100%'><h1 STYLE='font-family: Arial; font-size : 16pt; font-weight :bold;text-align : left; color :999999 ;margin:0;margin-left:2px;padding:0'>";
                  
                      if ($conexp[1] == 'safe'){echo "<img src='img/childsafe.gif' width='50' height='50'> ";}
                      else{}
                  
                  
                  
                      echo $conexp[0]."</span></td>
                    </tr>
                    <tr bgcolor=$color3> 
                      <td align='right' width='100%'>Added by <a href='member.php?user=".$conexp[2]."'>".$conexp[2]."</a><br>".$conexp[3]."</td>
                    </tr>
                    <tr bgcolor=$color3>
                      <td bgcolor=$color2><a href='".$conexp[4]."' target='_blank'>".$conexp[4]."</a>
                      <br>".$conexp[5]."</td>
                    </tr>
                    <tr align='center'>
                    <td><a href='linkcomments.php?lastlink=".$lastlink."'>View Comments</a></td>
                    </tr>
                    </table>
                    <br><br>
                    ";
                    fclose($filename);
                      $num=4;
                      $num2=$num+1;
                  $lastlink--;
         }else{}
      }else{
      $lastlink--;
      }
    }
}else{
echo 'Please Login to view Links';
}
?>
  <?php
  include('bottumhalf.php');
  ?>

 

the problem is that when get is set to all, it seems to have no problem but when its set to Comedy, it times out everytime, could someone please enlighten me on why its so slow and possibly how to fix it, thanks. an example of the file being displayed is as follows

 

Comedy|safe| thewooleymammoth| Friday 21st of September 2007 11:05:08 AM| http://youtube.com/watch?v=ea7oIraV2Q0| DR TRAN|

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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