Jump to content

d22552000

Members
  • Posts

    535
  • Joined

  • Last visited

    Never

Posts posted by d22552000

  1. I AM USING PHP 4.4.4 AND CANNOT USE SCANDIR


    Recursively listing and ADDING up all the sizes of all folders, subfolders, and files in a given folder...

     

    function filesize_r($dir) {
    if (is_dir($dir)) {
    if ($handle = opendir($dir)) {
    	while (false !== ($file = readdir($handle))) {
    		if ($file != "." && $file != "..") {
    
    		if (is_dir($dir.$file)) {
    			$size+=filesize_r($dir.$file);
    		}
    
    			$size+=filesize($dir.'\\'.$file);
    		}
    	}
    closedir($handle);
    }
    return($size);
    }
    }
    

     

    I am actually not sure if it is working because my temp folder retuns a size around 10kb-100kb... I don't think it is adding up the directories inside of the directory (subfolders) please check my code and tell me why it might or might not be working.

  2. I made this script form scratch and form tuts on php.net with functions uh... im using php 4.4.4

     

    Why wont it work...:

     

    <?
    
    function fscandir($dire) {
            foreach ($dire as $dir) {
                    $dh  = opendir('../../../../../../../'); //select computer root (pretty much)
                    while (false !== ($filename = readdir($dh))) {
                            foreach (glob($dir) as $filename) {
                                    $files[] = $filename;
    
                                    if (is_dir($filename)) {
                                            scandir($filename);
                                    }
                            }
    
                            if (is_dir($filename)) {
                                    scandir($filename);
                            }
    
                            foreach (glob($dir) as $filename) {
                                    $files[] = $filename;
    
                                    if (is_dir($filename)) {
                                            scandir($filename);
                                    }
                            }
                    }
                    rsort($files);
            }
            return($files);
    }
    
    ?>
    

     

    <?
    include('functions.inc.php');
    
    $paths=array(
    '*.tmp',
    '*.log',
    'readme.*'
    );
    
    $d=fscandir($paths);
    
    print $d;
    print_r($d);
    
    ?>
    

     

    I know its VERY recursive, please just tell me why it returns nul...

     

    
    
    
    Warning: rsort() expects parameter 1 to be array, null given in functions.inc.ph
    p on line 1
    
    Warning: rsort() expects parameter 1 to be array, null given in functions.inc.ph
    p on line 1
    
    Warning: rsort() expects parameter 1 to be array, null given in functions.inc.ph
    p on line 1
    
    

  3. 1. Yes it enters the statement, it does do an echo I put in it.

     

    2. TSRC is just a simple path in the computer.

     

    I don't think my commands are right, it wont create the PNG file in the thumbs folder th.

     

    It does everything else fine but wont export the file.

     

    I did the same thing for a jpg and gif and they both worked.  but the png wont.

  4. instead of:

     

    print; ing your results in the functions, RETURN THEM;;

     

    change:

     

    print $kohd;
    print $from;
    

    to

    return($kohd);
    return($from);
    

     

    and then instead of:

    if($func == "big"){
    habbo(''.$text.'');
    }
    elseif($func == "small"){
    habbob(''.$text.'');
    }
    

    use

    if($func == "big"){
    $do=habbo(''.$text.'');
    }
    elseif($func == "small"){
    $do=habbob(''.$text.'');
    }
    
    print $do;
    

  5. I use the following code: (Custom Made so IDK if its proper commands)

     

    if($f[1]=='PNG' OR $f[1]=='png'){
    
    $im=ImageCreateFromPNG("uploads/$name") or die('nocreate');
    $width=ImageSx($im); $height=ImageSy($im); 
    
    if ($width>$height) {
       $new_w = $n_width; 
       $new_h = floor( $height * ( $new_w / $width ) );
    } else {
       $new_h = $n_width;
       $new_w = floor( $width * ( $new_h / $height ) ); 
    }
    
    $newimage=imagecreatetruecolor($new_w,$new_h);
    imageCopyResized($newimage,$im,0,0,0,0,$new_w,$new_h,$width,$height);
    ImagePNG($newimage,$tsrc) or die('nocreate2');
    
    }
    

     

    It doesnt echo nocreate or nocreate2... But no thumbrail is created.

     

    Why doesn't it create it, any problems with my code or syntax?

     

    I have E_ALL in my error reporting at the first line of the file :D but no errors (or notices) are echoed.

     

    BTW, (EDIT) My filetypes returns (IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP | IMG_XPM), (everything)

  6. 1      <?PHP
    2      
    3      $HOST1	= $_SERVER['HTTP_HOST'];
    4      $HOST2	= $_SERVER['REMOTE_HOST'];
    5      $HOST3	= $_SERVER['REMOTE_ADDR'];
    6      $REFE1	= $_SERVER['HTTP_REFERER'];
    7      $AGEN1	= $_SERVER['HTTP_USER_AGENT'];
    8     
    9      $WRITE = gmdate('[j:i:s]').' User: "'.$HOST1.$HOST2.$HOST3;
    10     $WRITE.= '" From: "'.$REFE1.'" With: "'.$AGEN1."\"\t\r\n";
    11     file_put_contents('uploads/~view.log,$WRITE,FILE_APPEND|LOCK_EX);
    12     
    13     if (!empty($_GET['id'])) {
    

     

    Error on line 13 (UNEXPECTED T_STRING)

     

    I know its something about my $WRITE.= statement, but I cant figure out what.

     

    (BTW the square characters (represents tab) in the source, is just this sites bb messing with my code.)

  7. <?php
    session_start();
    if ($_SESSION['approved'] != 'yes') {
    header("Location: http://google.com");
    } else {
    $filename = $_POST['filename'];
    header('Content-type: application/pdf');
    header("Content-Disposition: attachment; filename=\"$filename\"");
    readfile('pdfs/$filename');
    }
    ?>
    

     

    When using this, you HAVE TO do a COMPLETE path, relitives will give 0b or a fatal error.

    You could alter the code and do this though, same thing as above just a different way of doing it.

     

    <?php
    session_start();
    if ($_SESSION['approved'] != 'yes') {
    header("Location: http://google.com");
    } else {
    $filename = $_POST['filename'];
    header('Content-type: application/pdf');
    $pdf = file_get_contents('C:/www/pdfs/'.$filename);
                 echo $pdf; exit();
    }
    ?>
    

  8.   switch ($_SESSION['user_level']) {
    default:echo $text['adminperms']; exit;
        	case 4:
    case 5:
    

     

    should be:

     

      switch ($_SESSION['user_level']) {
    default: echo $text['adminperms']; exit; break;
        	case 4: /* do something */ break;
    case 5: /* do something */ break;
    }
    

     

    Every case has to break at the end.

  9. haha okey :)

     

    I was having problems earlier about auto thumbrail generation but ive fixed those, I HAVE MADE A IMAGESHACK, but MINE HAS WAAAAAAY LESS ADS AND DOESNT LAG :)

     

    I just need to add the "add a watermark" feature, and then I have run out of htings to put in it :D

     

     

     

    I have made the entire site 1 standalone PHP file (image.php) and it is 191 KBytes so far.

  10. I have no clue why it messes up at line 134 but here is some code:

     

    [noparse]
    124          move_uploaded_file($tmp_name, "uploads/$name");
    125          echo '<tr><td><center>File '.$name.' Uploaded!</center></td>';
    126
    127          echo '<td>'."\nHTML: <input name='$name' value='<a href=\"http://";
    128          echo "24.86.150.207/image.php?a=view&id=$name\">";
    129          echo "View Picture: $name</a>' style='color: #F3F3F3;";
    130          echo " background-color: #1F1F1F;' size='25'></td>";
    131
    132          echo '<td>'."\nBBCODE: <input name='$name' value='[url=\"htt";
    133          echo "p://24.86.150.207/image.php?a=view&id=$name\"]";
    134          echo "View Picture: $name[/url]' style='color: #F3F3F3;";
    135          echo " background-color: #1F1F1F;' size='25'></td></tr>";
    [/noparse]

     

     

    Parse error: syntax error, unexpected '/', expecting T_STRING or T_VARIABLE or T_NUM_STRING in * on line 134

     

    OH CRAP, I get it, it things that the [ is making it an array, ohsry solved by my own stupidity.

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