Re: Could you look at this code

From: Date: Wed, 27 Sep 2000 10:20:07 +0000
Subject: Re: Could you look at this code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-17668@lists.php.net to get a copy of this message
Now just 114 lines! Needs checking. I found a couple of mistakes: namely $usr instead of $user etc.. Enjoy! David. ----- Original Message ----- From: Richard Kurth <rkurth@pacifier.com> To: Php <php-general@lists.php.net> Sent: Friday, September 22, 2000 5:04 AM Subject: [PHP] Could you look at this code > > Would it be to much to ask if people could look at this code and > tell me how I could make it more friendly and maybe more > compressed. Would functions work better to do all of this. > > This script is to run at root on the command line called by cron > > > > #!/usr/local/bin/php > <?php > > > file://defalt ip address > $ip = "207.204.234.45"; > > $hostname = "localhost"; > $username = ""; > $password = ""; > $dbName = ""; > $db = MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to > database"); > mysql_select_db($dbName ,$db); > > file://Search database for new subscripers > $query = "SELECT * FROM pcustomers "; > $result = mysql_query ($query) or > die("Error in query"); > while($myrow = mysql_fetch_array($result)) > > file://Select a new ip address for subscriber > $query1 = "SELECT ip FROM ipaddress LIMIT 1"; > $result1 = mysql_query ($query1) or > die("Error in query"); > while($myrow1 = mysql_fetch_array($result1)) > > $ipaddress = $myrow1["ip"]; > } > > file://set varabals for eash subscriber > $domainname = $myrow["domaname"]; > $account = $myrow["account"]; > $sdomaname = $myrow["sdomaname"]; > $name = $myrow["name"]; > $company = $myrow["company"]; > $street = $myrow["street"]; > $city = $myrow["city"]; > $state = $myrow["state"]; > $zip = $myrow["zip"]; > $country = $myrow["country"]; > $hphone = $myrow["hphone"]; > $wphone = $myrow["wphone"]; > $fax = $myrow["fax"]; > $email = $myrow["email"]; > $username = $myrow["username"]; > $password = $myrow["password"]; > $frontpage = $myrow["frontpage"]; > $terms = $myrow["terms"]; > $id = $myrow["id"]; > $plan = $myrow["plan"]; > $wantdatabase = $myrow["wantdatabase"]; > $databasename = $myrow["databasename"]; > $signdate = $myrow["signdate"]; > > if ($account =="NewDomain") { > > file://If new account is Economy do this > if ($plan=="Economy"){ > $ipn = "-i $ip"; > $host = " -n www"; > $dom = " -d $domainname"; > $mb = " -q 25"; > $user = " -u 2"; > $cgi =" -c"; > $ssl =" -l"; > $ftp = " -f:"; > $ee = " -e"; > $webd =" -w"; > $fullyqualified ="-d www.$domainname"; > $username = " -u $name"; > $userspasswd = " -p $password"; > $quotainMB = " -q 10"; > $siteadmi = " -a "; > $string = "$ipn $host $dom $mb $usr $cgi $ssl $ftp $ee $webd"; > $string2 = "$fullyqualified $username $userpasswd > $quotainMB $siteadmi"; > if ($frontpage=="YES") > $fp = " -x"; > $string = $string . $fp; > $string2 = $string2 . $fp; > } > file://If new account is Basic do this > file://Basic Account > if ($plan== "Basic"){ > $ipn = "-i $ip"; > $host = " -n www"; > $dom = " -d $domainname"; > $mb = " -q 50"; > $user = " -u 4"; > $cgi =" -c"; > $ssl =" -l"; > $ftp = " -f:"; > $ee = " -e"; > $webd =" -w"; > $fullyqualified ="-d www.$domainname"; > $username = " -u $name"; > $userspasswd = " -p $password"; > $quotainMB = " -q 10"; > $siteadmi = " -a "; > $string = "$ipn $host $dom $mb $usr $cgi $ssl $ftp $ee $webd"; > $string2 = "$fullyqualified $username $userpasswd > $quotainMB $siteadmi"; > if ($frontpage=="YES") > $fp = " -x"; > $string = $string . $fp; > $string2 = $string2 . $fp; > } > > file://If new account is Delux do this > // Deluxe Account > if ($plan== "Deluxe"){ > $ipn = "-i $ip"; > $host = " -n www"; > $dom = " -d $domainname"; > $mb = " -q 75"; > $user = " -u 8"; > $cgi =" -c"; > $ssl =" -l"; > $ftp = " -f:"; > $ee = " -e"; > $webd =" -w"; > $fullyqualified ="-d www.$domainname"; > $username = " -u $name"; > $userspasswd = " -p $password"; > $quotainMB = " -q 10"; > $siteadmi = " -a "; > $string = "$ipn $host $dom $mb $usr $cgi $ssl $ftp $ee $webd"; > $string2 = "$fullyqualified $username $userpasswd > $quotainMB $siteadmi"; > if ($frontpage=="YES") > $fp = " -x"; > $string = $string . $fp; > $string2 = $string2 . $fp; > } > > file://If new account is Commerce do this > // Commerce Account > if ($plan== "Commerce"){ > file://If database is out of ip address set this defalt > for now > If ($ipaddress == ""){ > $ipaddress = "207.204.234.67"; > } > $ipn = "-i $ipaddress"; > $host = " -n www"; > $dom = " -d $domainname"; > $mb = " -q 100"; > $user = " -u 10"; > $cgi =" -c"; > $ssl =" -l"; > $ftp = " -f:"; > $ee = " -e"; > $webd =" -w"; > $ssi = " -s"; > $shell=" -t"; > $fullyqualified ="-d www.$domainname"; > $username = " -u $name"; > $userspasswd = " -p $password"; > $quotainMB = " -q 10"; > $siteadmi = " -a "; > $string = "$ipn $host $dom $mb $usr $cgi $ssl $ftp $ee $webd > $ssi $shell"; > $string2 = "$fullyqualified $username $userpasswd > $quotainMB $siteadmi"; > > // Store used ip address in usedipaddress along with > domain name and date > $query2="INSERT INTO usedipaddress VALUES > ('NULL','$ipaddress', '$domainname','NULL')"; > $result2 = mysql_query ($query2) or die("Error in > query"); > if ($frontpage=="YES") > $fp = " -x"; > $string = $string . $fp; > $string2 = $string2 . $fp; > } > file://If new account is Professional do this > // Professional Account > if ($plan== "Professional"){ > file://If database is out of ip address set this > defalt for now > If ($ipaddress == ""){ > $ipaddress = "207.204.234.67"; > } > $ipn = "-i $ipaddress"; > $host = " -n www"; > $dom = " -d $domainname"; > $mb = " -q 150"; > $user = " -u 20"; > $cgi =" -c"; > $ssl =" -l"; > $ftp = " -f:"; > $ee = " -e"; > $webd =" -w"; > $ssi = " -s"; > $shell=" -t"; > $fullyqualified ="-d www.$domainname"; > $username = " -u $name"; > $userspasswd = " -p $password"; > $quotainMB = " -q 10"; > $siteadmi = " -a "; > $string = "$ipn $host $dom $mb $usr $cgi $ssl $ftp $ee $webd > $ssi $shell"; > $string2 = "$fullyqualified $username $userpasswd > $quotainMB $siteadmi"; > > // Store used ip address in usedipaddress along with > domain name and date > $query2="INSERT INTO usedipaddress VALUES > ('NULL','$ipaddress', '$domainname','NULL')"; > $result2 = mysql_query ($query2) or die("Error in > query"); > if ($frontpage=="YES") > $fp = " -x"; > $string = $string . $fp; > $string2 = $string2 . $fp; > } > file://If new account is Exclusive do this > // Exclusive Account > if ($plan== "Exclusive"){ > > file://If database is out of ip address set this defalt > for now > If ($ipaddress == ""){ > $ipaddress = "207.204.234.67"; > } > $ipn = "-i $ipaddress"; > $host = " -n www"; > $dom = " -d $domainname"; > $mb = " -q 200"; > $user = " -u 30"; > $cgi =" -c"; > $ssl =" -l"; > $ftp = " -f:"; > $ee = " -e"; > $webd =" -w"; > $ssi = " -s"; > $shell=" -t"; > $fullyqualified ="-d www.$domainname"; > $username = " -u $name"; > $userspasswd = " -p $password"; > $quotainMB = " -q 10"; > $siteadmi = " -a "; > $string = "$ipn $host $dom $mb $usr $cgi $ssl $ftp $ee $webd > $ssi $shell"; > $string2 = "$fullyqualified $username $userpasswd > $quotainMB $siteadmi"; > > // Store used ip address in usedipaddress along with > domain name and date > $query2="INSERT INTO usedipaddress VALUES > ('NULL','$ipaddress', '$domainname','NULL')"; > $result2 = mysql_query ($query2) or die("Error in > query"); > if ($frontpage=="YES") > $fp = " -x"; > $string = $string . $fp; > $string2 = $string2 . $fp; > } > file://Delete any used ip address from the database > $query3="DELETE FROM ipaddress WHERE (ip = '$ipaddress')"; > $result3 = mysql_query ($query3) or die("Error in query"); > > > > // Run the script to update the server > > echo "<br>"; > echo ("system /usr/sbin/cobalt/addvsite $string"); > echo "<br>"; > echo ("system /usr/sbin/cobalt/adduser $string2"); > echo "<br>"; > echo "<br>"; > } > } > > ?> > > > > > > > > > > > > > > > > NorthWestHost > Your web host provider > www.northwesthost.com > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#17668) next »