SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Undefined index: css and Undefined variable: error on the script

    Hi To All
    Can you please help with this script. I just download a script on the Net and when I try to run it gave this error:

    Code:
    [client 192.168.2.24] PHP Notice:  Undefined index:  css in /var/www/web9/web/install/install.php on line 209, referer: http://ofb9.ofb.com/install/install.php
    [client 192.168.2.24] PHP Notice:  Undefined variable:  error in /var/www/web9/web/install/install.php on line 260, referer: http://ofb9.ofb.com/install/install.php
    I already tried to put on the script this line
    Code:
    extract($_REQUEST);
     as well as this line  
    error_reporting = E_ALL & ~E_NOTICE;
    I also tried to put on my php.ini the
    error_reporting = E_ALL & ~E_NOTICE;
    and still the script doesn't run

    How could the problem be

    By the way I am using PHP version 4.3.9 and Apache 2.0.52
    and the line that cause the error is
    Code:
    <link rel="stylesheet" href="<? if (!$_POST["css"]) echo "../templates/webfilesystem/style.css"; else echo $_POST["css"]; ?>" type="text/css">
    and also this one
    Code:
    if ($error) {

    PHP Code:
    <? 


    if (!$_POST["dbname"] || !$_POST["dbhost"]) {


    ?>
    <html>
    <head>
    <title>
    <? 
    if (!isset($title)) $title="File Manager"; echo "$title"?>
    </title>
    <meta http-equiv="Content-Type" content="text/html;">
    <link rel="stylesheet" href="../templates/webfilesystem/style.css" type="text/css">
    </head>

    <body align=center  topmargin="0" bottommargin="0">
    <table cellpadding=0 cellspacing=0 border=0 width=780 align=center bgcolor="#CDCDCD">
        <tr>
            <td colspan=2 align=center>
                <br/>Installing FileManager<br/><br/>
            </td>
        </tr> 
        <tr>
            <td></br></br>
            </td>
        </tr>
    <!-------------------------------------------------------------->
    <!-------------------------------------------------------------->    

        
        <tr align=center>
           <td colspan=2 class="tableheader" >
                Database
            </td>
        </tr>
        <form name="installform" action="<? echo $_SERVER['PHP_SELF']; ?>" method=post>
        <tr class="tablecontent">
            <td align=right width=40%>
                Database Hostname/IP:
            </td>
            <td>
                <input type="text" class="introduceri" size=30 name="dbhost">
            </td>
        </tr>
         <tr class="tablecontent">
            <td align=right>
                Database User:
            </td>
            <td>
                <input type="text" class="introduceri" size=30 name="dbuser">
            </td>
        </tr>
         <tr class="tablecontent">
            <td align=right>
                Database Password:
            </td>
            <td>
                <input type="password" class="introduceri" size=30 name="dbpass">
            </td>
        </tr>
         <tr class="tablecontent">
            <td align=right>
                Database Name:
            </td>
            <td>
                <input type="text" class="introduceri" size=30 name="dbname">
            </td>
        </tr>
        <tr>
            <td colspan=2>Please make sure there is no other database with the same name</br></br>
            </td>
        </tr>
    <!-------------------------------------------------------------->
    <!-------------------------------------------------------------->
         <tr align=center>
            <td colspan=2 class="tableheader">
             Files
            </td>
        </tr>
        
        <tr class="tablecontent">
            <td align=right>
                FileRoot Directory:
            </td>
            <td>
                <input type="text" class="introduceri" size=30 name="fileroot_dir">
            </td>
        </tr>
        <tr class="tablecontent">
            <td align=right>
                Maximum Upload Size:
            </td>
            <td>
                <input type="text" class="introduceri" size=30 name="max_upload_size" STYLE="text-align:right" value=20>Mb
            </td>
        </tr>
        <tr>
            <td colspan=2>The maximum upload size is limited by the one in the server config (httpd.conf) file </br><br/>
            YOUR WEBSERVER must have permisions to make the FILEROOT directory, if it is already created, the server must have rights to access it and create subdirectories<br/>
            ex : c:/fileroot/ (win) or /fileroot/ (linux)</br>
            DON'T FORGET TO PUT A TRALING SLASH AFTER THE DIRECTORY NAME ! ( ex : c:/fileroot/ not c:/fileroot )
            It is NOT recommended to keep the fileroot as a sub-directory  of your web-site's html documents root (c:/apache/htdocs/ or /var/www/html/ )
            </td>
        </tr>
    <!-------------------------------------------------------------->
    <!-------------------------------------------------------------->    
        
        
        
       
      
       
        
        <tr>
            <td colspan=2></br></br>
            </td>
        </tr>
    <!-------------------------------------------------------------->
    <!-------------------------------------------------------------->
         <tr align=center>
            <td colspan=2 class="tableheader">
             Administrator
            </td>
        </tr>
        
        <tr class="tablecontent">
            <td align=right>
                Email:
            </td>
            <td>
                <input type="text" class="introduceri" size=30 name="admin_email">
            </td>
        </tr>
        <tr class="tablecontent">
            <td align=right>
                Password:
            </td>
            <td>
                <input type="password" class="introduceri" size=30 name="admin_pwd1">
            </td>
        </tr>
        <tr class="tablecontent">
            <td align=right>
                Confirm:
            </td>
            <td>
                <input type="password" class="introduceri" size=30 name="admin_pwd2">
            </td>
        </tr>
        <tr class="tablecontent">
            <td align=right>
                Name:
            </td>
            <td>
                <input type="text" class="introduceri" size=30 name="admin_name">
            </td>
        </tr>
        
        <tr>
            <td></br></br>
            </td>
        </tr>
    <!-------------------------------------------------------------->
    <!-------------------------------------------------------------->    
        
        
         <tr class="tablecontent">
            <td colspan=2 align=center>
             <input type=submit class=submit value="Install">
            </td>
        </tr>
         
        
        </form>
        
    <!-------------------------------------------------------------->
    <!-------------------------------------------------------------->    
        
        
         <tr class="tablecontent">
            <td colspan=2>
             <br/>
            </td>
        </tr>
        
        
    </table>
    </body>
    </html>


    <?

    }

     else {
     
     
    ?>
    <html>
    <head>
    <title>
    <? 
    if (!isset($title)) $title="File Manager Install"; echo "$title"?>
    </title>
    <meta http-equiv="Content-Type" content="text/html;">
    <link rel="stylesheet" href="<? if (!$_POST["css"]) echo "../templates/webfilesystem/style.css"; else echo $_POST["css"]; ?>" type="text/css">
    </head>

    <body align=center  topmargin="0" bottommargin="0">
    <table cellpadding=0 cellspacing=0 border=0 width=780 align=center bgcolor="#CDCDCD">
        <tr>
            <td colspan=2 align=center>
                <br/>Installing FileManager<br/><br/>
            </td>
        </tr> 
        <tr>
            <td></br></br>
            </td>
        </tr>
        <tr class="tablecontent">
            <td colspan=2>
    <!-------------------------------------------------------------->
    <!-------------------------------------------------------------->    
    <?
    $dbhost 
    $_POST["dbhost"];
    $dbuser $_POST["dbuser"];
    $dbpass $_POST["dbpass"];
    $dbname $_POST["dbname"];

    if (
    $dbhost ==""$error.= "You must supply a host name<br/>";
    if (
    $dbuser ==""$error.= "You must supply a database user name<br/>";
    if (
    $dbpass ==""$error.= "You must supply a database user password<br/>";
    if (
    $dbname ==""$error.= "You must supply a database name<br/>";
    $dbcnx mysql_connect($dbhost$dbuser$dbpass);
    if ( !
    $dbcnx ){
    $error.= "Could not connect to database ! Please check the details, and check that the mysql service is running. <br/>";
    }
    $admin_email $_POST["admin_email"];
    $admin_pwd1 $_POST["admin_pwd1"];
    $admin_pwd2 $_POST["admin_pwd2"];
    $admin_name $_POST["admin_name"];

    if (
    $admin_email==""$error.= "You must supply an administrator email<br/>";
    if (
    $admin_pwd1==""$error.= "You must supply an administrator password<br/>";
    if (
    $admin_pwd2==""$error.= "You must supply an administrator password<br/>";
    if (
    $admin_pwd2 != $admin_pwd1$error.= "The passwords don't match<br/>";
    if (
    $admin_name==""$error.= "You must supply an administrator name<br/>";

    $max_upload_size $_POST["max_upload_size"];
    if (
    $max_upload_size==""$error.= "You must supply a value for Maximum Upload Size<br/>";

    $fileroot_dir $_POST["fileroot_dir"];



    if (
    $error) {

    echo 
    $error"<br/>";
    echo 
    "<a href=\"javascript:window.history.go(-1);\">Back<br/></a>"
    exit;
    }
    else {

    echo 
    "   database variables set......<br/>";
    // begin



    $user strtok($admin_email,"@");
    $domain_name strtok("\n");

    //create fileroot
    if(!@file_exists($fileroot_dir)){
                       
    $ok=@mkdir($fileroot_dir,0777);
                       }
                       
    //create workspaces for administrator                   
    if(!@file_exists($fileroot_dir."/".$domain_name)){
                       
    $ok=@mkdir($fileroot_dir."/".$domain_name,0777);
                       }
    //company workspace                   
    if(!@file_exists($fileroot_dir."/".$domain_name."/$".$domain_name)){
                       
    $ok2=@mkdir($fileroot_dir."/".$domain_name."/$".$domain_name,0777);
                       }
    //user workspace                   
    if(!@file_exists($fileroot_dir."/".$domain_name."/".$user)){
                       
    $ok3=@mkdir($fileroot_dir."/".$domain_name."/".$user,0777);
                       }


    //create database + tables
     
    if (!mysql_query"CREATE DATABASE ".$_POST["dbname"]." " ,$dbcnx)) {  echo "error creating database"; exit; }
    else echo 
    "mysql database created .... <br/>";
    $dump_file "filemanager.sql";

    mysql_select_db($dbname,$dbcnx);


    $FP fopen $dump_file'r' );
    $READ fread $FPfilesize $dump_file) );
    $READ explode ";"$READ );
    foreach ( 
    $READ AS $RED ) {
    mysql_query ($RED$dbcnx );
    }

    echo 
    "mysql script executed .... <br/>";
    //insert the administrator user account details
    $sql_admin "INSERT INTO users VALUES ('','$admin_email','$admin_pwd1','$admin_name','','','','admin','','','yes','','','','','','','') ";
    mysql_query ($sql_admin,$dbcnx); 
    echo 
    "administrator account created .... <br/>";

    //creating output for the config file
     
    $out"<?
    //Database
    §dbhost = \""
    .$_POST["dbhost"]."\";// HOST name/IP  - leave blank for localhost
    §dbuser = \""
    .$_POST["dbuser"]."\"; // SQL username
    §dbpass = \""
    .$_POST["dbpass"]."\"; // SQL Password
    §dbname = \""
    .$_POST["dbname"]."\"; // SQL Database
    //Style Sheet

    §GLOBALS[\"template\"] = \"webfilesystem\";

    if (file_exists (\"templates/\".§GLOBALS[\"template\"].\"/template.php\") ) {  include \"templates/\".§GLOBALS[\"template\"].\"/template.php\"; } 
    else  include \"../templates/\".§GLOBALS[\"template\"].\"/template.php\";


    §GLOBALS[\"max_upload_size\"] = "
    .$_POST["max_upload_size"]."*1024*1024; // in bytes   - limited by php.ini variable 50 Mb


    §GLOBALS[\"fileroot_dir\"] = \""
    .$_POST["fileroot_dir"]."\";  //fileroot path

    // put 99999 for one page :)
    §GLOBALS[\"users_per_page\"] = 15;
    §GLOBALS[\"rules_per_page\"] = 15;

    //these go for            admin, poweruser, user


    //domains menu
    §GLOBALS[\"domains_menu\"] =  array(1,1,0);
    §GLOBALS[\"company_workspace_access\"] =  array(1,0,0);

    §GLOBALS[\"domains_list\"] =  array(1,1,0); // ex: only admin powerusers will see the domain list, and the link in the left-side tree to domain_list
    §GLOBALS[\"synonyms_list\"] = array(1,1,0);
    §GLOBALS[\"add_synonym\"] =   array(1,0,0);

    //users menu
    §GLOBALS[\"users_menu\"] =    array(1,1,0);

    §GLOBALS[\"users_list\"] =    array(1,1,0);
    §GLOBALS[\"add_user\"] =      array(1,1,0);
    §GLOBALS[\"user_rules\"] =    array(1,0,0);
    §GLOBALS[\"insert_rule\"] =   array(1,0,0);

    //fileroot access
    §GLOBALS[\"fileroot_access\"] = array(1,0,0);

    //quotas for admin, poweruser, user
    §GLOBALS[\"quota\"] =  array(104857600,15728640,5242880);
    //default company workspace quota
    §GLOBALS[\"company_workspace_quota\"] =  1024*1024*20;

    //specific company workspace quota - this is not the sum of this domain's users workspaces - it's just the shared company workspace quota
    §GLOBALS[\"quota\"][\"yahoo.com\"] = 1024*1024*30; //example - 30 Mb
    //allow powerusers to edit/delete user details
    §GLOBALS[\"pu_allow_useredit\"] = 1;

    //allow powerusers to edit/delete synonyms
    §GLOBALS[\"pu_allow_synonymedit\"] = 0;

    §GLOBALS[\"webmaster\"]=\"webmaster@domain.com\";//mail messages reply to address

    //rewrite url  - replaces url_repl1 with url_repl2

    §GLOBALS[\"url_repl1\"] =  array(\"\'\",\"&\",\"+\");
    §GLOBALS[\"url_repl2\"] =  array(\"^^^\",\"§§§\",\"@@@\");


    §PHP_SELF = §_SERVER[\'PHP_SELF\'];
    ?>"
    ;

    //writing + saving the config file

     
    $filename "../conf/conf.php";

     if (!@
    touch($filename)) { echo "The config file could not be created, Please change the priviledges , so that the web-server can create the conf.php file";echo "<br/><a href=\"javascript:window.history.go(-1);\">Back<br/></a>"; exit; }// Create blank file 
     
    if (!@chmod($filename,0666)) { echo "The config file could not be edited, Please change the priviledges , so that the web-server can change the conf.php file";echo "<br/><a href=\"javascript:window.history.go(-1);\">Back<br/></a>";  exit; }

     
    $conf_file fopen($filename,"w");
     
     
    $out str_replace("§","$",$out);
     
     
    $out stripslashes($out);
     
     
    fwrite($conf_file,$out);
     
    fclose($conf_file);
     echo 
    "config file \"conf/conf.php\" written.....<br/>";
    ?> 
     
      
          
             
            </td>
        </tr>
        
        
        <tr align=center>
           <td colspan=2 class="tableheader" >
                Installation Complete
            </td>
        </tr>
        <tr class="tablecontent">
            <td colspan=2>
             Please delete the 'install.php' file, and then launch the filemanager index.php file<br/>
             There are many other options that can be changed in the conf/conf.php file, feel free to modify any of them.<br/>
             Click 'finish' to be redirected to the main page<br/>
             
             Have Fun !<br/><br/><br/>
            </td>
        </tr>
        <tr align=center>
           <td colspan=2 class="tableheader" >
                <input type=submit class=submit value="Finish" onClick="javascript:window.location.href='../'">
            </td>
        </tr>
        
        
        
        
    </table>
    </body>
    </html>
     
     
     
     
     
     
     
    <? 

     
    }//end else
     
     
    }

    ?>

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    CSS problem - I would create it as a variable $css ...

    $css = ( isset ($_POST['css']) ) ? $_POST['css'] : '../templates/webfilesystem/style.css';

    <link rel="stylesheet" href="<?php echo $css ?>" type="text/css">


    $error problem - I would first put a line of

    $error = '';

    near the top, then at the check I would do ...

    if ( strlen ($error) > 0 ) {
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Setting your error reporting to
    PHP Code:
    error_reporting(E_ALL E_NOTICE); 
    should get rid of those pesky notice errors, but siteguru's advice is better coding practice...

  4. #4
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you siteguru for your suggestion, right now there's no more error on the script but the problem is when I run again the script it says

    Code:
        error creating database
    Below is the portion of the script that gives the error and you can see it on the bottom of the script

    PHP Code:

    $user 
    strtok($admin_email,"@");
    $domain_name strtok("\n");

    //create fileroot
    if(!@file_exists($fileroot_dir)){
                       
    $ok=@mkdir($fileroot_dir,0777);
                       }

    //create workspaces for administrator
    if(!@file_exists($fileroot_dir."/".$domain_name)){
                       
    $ok=@mkdir($fileroot_dir."/".$domain_name,0777);
                       }
    //company workspace
    if(!@file_exists($fileroot_dir."/".$domain_name."/$".$domain_name)){
                       
    $ok2=@mkdir($fileroot_dir."/".$domain_name."/$".$domain_name,0777);
                       }
    //user workspace
    if(!@file_exists($fileroot_dir."/".$domain_name."/".$user)){
                       
    $ok3=@mkdir($fileroot_dir."/".$domain_name."/".$user,0777);
                       }


    //create database + tables

    if (!mysql_query"CREATE DATABASE ".$_POST["dbname"]." " ,$dbcnx)) {  echo "error creating database"; exit; }
    else echo 
    "mysql database created .... <br/>"
    What seems could be the problem?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •