Announcement

Collapse
No announcement yet.

Help with codelet please...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with codelet please...

    I keep getting some parse errors on this line of code:

    if (param("head"=0))
    {
    $header = ""; $footer = "";}
    }


    got any ideas? Would be excellent if you could correct this! Thanks, kyle.

  • #2
    What are the errors you are getting?

    Also

    Code:
    { 
    $header = ""; $footer = "";} 
    }
    Should the one in bold be there ?
    Email: [email protected]
    Site: Under Construction

    Comment


    • #3
      I am going to trash this line of code:


      if (param("head"=0))
      {
      $header = ""; $footer = "";}
      }


      I discovered that I don't even need it because I am not using a header or footer!


      But now I have run into a new problem! This script has sub routines to run! So I don't know how to rewrite the routines from cgi to php. Here was the sub-routine codelet from a cgi script:
      [B]
      &Get_Types();
      &Admin if (param('action') eq 'admin'); # Admin
      &Download if (param('action') eq 'download'); # Filedownload
      &Modify if (param('action') eq 'modify'); # Modifys files
      &Modify2 if (param('action2') eq 'modify2');
      &Modify3 if (param('action2') eq 'modify3');
      &Makedirs if (param('action') eq 'makedir'); # Makes upload-directories
      &Makedirs2 if (param('action2') eq 'makedir2');
      &Remove if (param('action') eq 'remove'); # Removes files
      &Remove2 if (param('action2') eq 'remove2');
      &Password if (param('action') eq 'password'); # Changes password
      &Password2 if (param('action2') eq 'password2');
      &Upload if (param('action') eq 'upload');
      &Upload2 if (param('action2') eq 'upload2');
      &Search if (param('action') eq 'search'); # Search files
      &Search2 if (param('action2') eq 'search2');
      &Top if (param('action') eq 'toplist');
      &Rate if (param('action') eq 'rate');
      &Rate2 if (param('action2') eq 'rate2');
      &Stats if (param('action') eq 'stats');

      &Upview; # Views files (DEFAULT)
      exit;
      [B]

      That one was in cgi, and I don't know how to do it in php. If you can help me. PLEASE do.
      I also have a bit of another problem, when I am actually writing the sub routines, I can't do them in php. Here is the sub routine itself in cgi for the routine "stats":

      sub Stats {
      open(FILE,"<$datafile") || &Error("Error opening file $datafile");
      @database = <FILE>;
      close(FILE);

      $counter=0;$downloads=0;$total_size=0;
      foreach(@database) {
      chomp();
      my ($foo,$id,$date,$name,$type,$filename,$size,$author,$email,$description,$count,$info,$pic, $sup) = split('\|\|');
      $counter++;
      $downloads += $count;
      if($size =~ "K") {
      $size =~ s/K//g;
      $total_size += ($size * 1024);
      } elsif($size =~ "M") {
      $size =~ s/M//g;
      $total_size += ($size * 1048576);
      } elsif($size =~ "G") {
      $size =~ s/G//g;
      $total_size += ($size * 1073741824);
      } elsif($size =~ "T") {
      $size =~ s/T//g;
      $total_size += ($size * 1099511627776);
      }
      }

      while ($total_size > 1024 and $length_descriptor ne 'T')
      {
      $total_size /= 1024;
      $length_descriptor = ($length_descriptor ? ($length_descriptor eq 'K'
      ? 'M' : $length_descriptor eq 'M' ? 'G' : 'T' ) : 'K');
      }

      $total_size = sprintf("%.2f",$total_size);

      print "Content-type: text/html\n\n";
      print "<html><body>\n";
      print "<br><b>Total files:</b> $counter\n";
      print "<br><b>Total filesize:</b> $total_size$length_descriptor\n";
      print "<br><b>Total downloads:</b> $downloads\n";
      print "</body></html>";
      exit
      }


      I can convert most of that codelet there, I just can't do the first line of it!: sub Stats {

      How does this look in php? Thanks man.

      -Kyle. (This is an upload script.)

      Comment


      • #4
        a PERL sub would be a PHP function

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X