PHP - Running Cpanel's Php5.5 From Ssh (which Wants To Use A Different Php Version)
I'm working on a website (for free) and the website owner has shared hosting w/ cPanel. When logged in to cPanel, the PHP version can be set to PHP5.5. So I did that. When logged in via SSH, scripts are still running on PHP5.3.
I found that /opt/alt/php55/usr/bin/php is a location of php5.5, but when I run my script, it gives an error that mysqli is not found.
As far as I know, this is probably just a typical cPanel install. If anyone can point me to the right way to run PHP5.5 from the command line, I'd appreciate it.
Similar TutorialsThis topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=318815.0 I have a small php upload/download script, it always worked on older php4 -5 but not on php5.3 ,gobal varitables must be on , I dont know to much about php and was hoping someone will look at at and let me know what to change to make it work on php5.3 or higher..............................THANKS! for any help in fixing this issue
<body link="#FFFF00" vlink="#FF0000" alink="#FFFF00"><? $extlimit = "yes"; //Do you want to limit the extensions of files uploaded $limitedext = array(".zip",".sim",".car",".jpg",".gif"); //Extensions you want files uploaded limited to. $sizelimit = "no"; //Do you want a size limit, yes or no? $sizebytes = "30033000"; //size limit in bytes $dl = "xxxxxxxxxxx"; //url where files are uploaded $absolute_path = "xxxxxxxxxxx"; //Absolute path to where files are uploaded $websiteurl = "xxxxxxxx"; //Url to you website $websitename = "Car File Manger"; if (!isset($action)) { $action = ""; } switch($action) { default: echo" <html> <head> <title>Upload Or Download</title> </head> <body> <a href=$PHP_SELF?action=upload>Upload</a> | <a href=$PHP_SELF?action=download>Download</a> | <a href=$websiteurl>Return to $websitename</a> <br><br> </body> </html>"; break; case "download": echo " <html> <head> <title>File Download</title> </head> <body><a href=$PHP_SELF?action=upload>Upload File</a> | <a href=$websiteurl>Return to $websitename</a>"; $list = "<table width=500 border=0 bordercolor=#000000 style=\"border-collapse: collapse\">"; $list .= "<tr><td width=500><center><b>Click To Download</b></center></td></tr>"; $dir = opendir($absolute_path); while($file = readdir($dir)) { if (($file != "..") and ($file != ".")) { //Download files with spaces fix by Kokesh $list .= "<tr><td width=700><a href='$dl/$file'>$file</a></center></td></tr>"; } } $list .= "</table>"; echo $list; echo" <br><br> </body> </html>"; break; case "upload": echo" <html> <head> <title>File Upload</title> </head> <body> <form method=POST action=$PHP_SELF?action=doupload enctype=multipart/form-data> <p>File to upload:<br> <input type=file name=file size=30> <p><button name=submit type=submit> Upload </button> </form> <br><br> </body> </html>"; break; //File Upload case "doupload": $dir = "dir"; if ($file != "") { if (file_exists("$absolute_path/$file_name")) { die("File already exists"); } if (($sizelimit == "yes") && ($file_size > $sizebytes)) { die("File is to big. It must be $sizebytes bytes or less."); } $ext = strrchr($file_name,'.'); if (($extlimit == "yes") && (!in_array($ext,$limitedext))) { die("The file you are uploading doesn't have the correct extension."); } @copy($file, "$absolute_path/$file_name") or die("The file you are trying to upload couldn't be copied to the server"); } else { die("Must select file to upload"); } echo " <html> <head> <title>File Uploaded</title> </head> <body>"; echo $file_name." was uploaded"; echo "<br> <a href=$PHP_SELF?action=upload>Upload </a> | <a href=$PHP_SELF?action=download> Download </a> | <a href=$websiteurl> Return to $websitename</a><br><br> </body> </html>"; break; } ?> Edited by Ch0cu3r, 01 September 2014 - 06:05 AM. Hi all, But of a PHP newbie so treat me nice but this one is driving me nuts I have the exact same login.php file running on two different servers and they have slightly different versions of PHP installed as follows: 1. PHP Version 5.0.4 - version http://www.trafficpaymaster.com/tpm/phpversion.php 2. PHP Version 5.2.15 - version http://www.dentistsinflorida.org/tpm/phpversion.php The login works fine on the first server from he http://www.trafficpaymaster.com/tpm/login.php Email: test@test.com Pwd: test But try it on the second server he http://www.dentistsinflorida.org/tpm/login.php Using the same email and password (which is correct) it just loops round not letting the user into the main script at index.php Question: Why? What have I got wrong for that later version of PHP? Many thanks guys. Hello, I created a PHP script that creates a database, user, and then adds the user to the database. it had been working perfectly for the past year, and then out of no where last night, it stopped working simultaneously on 20 different servers.. cPanel has not changed or anything, unless it was auto-updated without my knowledge... the first 2 lines work, however the last line does not $b = file_get_contents("https://".$username.":".$password."@localhost:2083/frontend/x3/sql/addb.html?db=database"); $b = file_get_contents("https://".$username.":".$password."@localhost:2083/frontend/x3/sql/adduser.html?user=username&pass=password"); $b = file_get_contents("https://".$username.":".$password."@localhost:2083/frontend/x3/sql/addusertodb.html?user=username&db=database&ALL=ALL"); any thoughts? Hi, There is a feature in cpanel called optimize website and when you go in it there is a field to fill Compress the specified MIME types. My question is this the correct way to optimize PHP CSS JS did i enter the mime types correctly? text/html text/plain text/xml/css/application/x-httpd-php/application/x-javascript I found this class online that looks like it should work. I have googled quite a bit on how to get this to work, but I can't find anything. All the discussions on google are a couple years old. Code: [Select] <?php class cPanel { var $cPanelUser = ""; var $cPanelPass = ""; var $cPanelDomain = ""; var $cPanelPort = 0; var $cPanelRel = ""; var $cPanelRoot = ""; function cPanel($cPanelDomain, $cPanelPort, $authUser, $authPass) { $this->cPanelDomain = $cPanelDomain; $this->cPanelPort = $cPanelPort; $this->cPanelUser = $authUser; $this->cPanelPass = $authPass; //Root path of cPanel to load pages begining with / $this->cPanelRoot = "http".($this->cPanelPort==2083 ? "s" : "")."://".$this->cPanelDomain.":".$this->cPanelPort."/"; //Relative path of cPanel to load pages not begining with / $this->cPanelRel = $this->cPanelRoot.""; } function fetchPage($cPanelPage, $sPostVars = "") { $ch = curl_init(); $loginf = sprintf("%s:%s", $this->cPanelUser, $this->cPanelPass); //Build the path. If it begins with / we go and paste at root if ($cPanelPage[0] == '/') { $url = $this->cPanelRoot.substr($cPanelPage, 1); } else { //Build the path - if begins with / we go and paste relative $url = $this->cPanelRel.$cPanelPage; } curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $sPostVars); // curl_setopt ($curl, CURLOPT_TIMEOUT, 30); // curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5))); // curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); // curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0); // curl_setopt ($curl, CURLOPT_FAILONERROR, 0); echo $loginf; echo $url."?".$sPostVars; curl_setopt ($ch, CURLOPT_USERPWD, $loginf); curl_setopt ($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); $result = curl_exec ($ch); echo 'Errors: ' . curl_errno($ch) . ' ' . curl_error($ch) . '<br><br>'; curl_close ($ch); return $result; } } hi, I wrote code that allow me to create email account outside of cpanel and works greats with one domain name. However I'm trying to change code for two domains to select domain name using menu. The forms that i wrote is come with one text fields for input user name and one drop menu for select domain which is: Code: [Select] <input name="username" size="20" /> <select name="domain_select" id="domain_select"> <option value="realdeafworld.com">domain1.com</option> <option value="realdeafway.com">domain2.com</option> </select>and then is sending data to other page which is config.php and Code: [Select] $username = 'username'; // This variable is the cPanel username $password = 'password'; // Please enter your cPanel password $domain_name = 'domain1.com, domain2.com'; // Please enter the domain name associated with the account $domain_select = $domain_name; $skin = 'x3'; and then it will process to other page which is "http://$username:$password@$domain_name:2082/frontend/$skin/mail/doaddpop.html?email=$_POST[username]&domain=$domain_name&password=$_POST[password]"a=25"); For some reason is not working right, event i put Code: [Select] $domain_name = 'realdeafworld.com, realdeafway.com'; between two domain im getting result of domain1.com. i also changed the variable name to Code: [Select] $domain_name = '$domain_select '; and still not working. Can anyone help me how can i solve this by select one domain name from menu before create email account! please help thanks. AM Hi... I could really do with some help, I have some form code I have been using for a very long time. how every my server company will not install php4 anymore Can someone have a look at this code and let me know why its not php5 compatible. Thanks <?php /* $sendto is the email where form results are sent to */ $sendto = "........"; /* $ccto is the email where form results can be carbon copied to */ $ccto = "..........."; /* O P T I O N A L V A R I A B L E S */ /* TO POST PHP ERRORS TO PAGE FOR DEBUGING SET: $report_errors = "ALL"; TO REMOVE PHP ERRORS FROM POSTING TO THE PAGE FOR USE SET: $report_errors = "NONE"; */ $report_errors = "NONE"; $setokurl = "1"; $okurls = "http://www.dwcontractors.com"; if ($report_errors == "NONE") { error_reporting(0); }else{ error_reporting(E_ALL); } /* --- I F S E T O K U R L = 1 ----- */ if ($setokurl == "1"){ $found_url = "0"; $referer =$_SERVER["HTTP_REFERER"]; $referer = str_replace("://", "[CS]", $referer); $referer_sp = explode("/", $referer); $referer = "$referer_sp[0]"; $referer .= "/"; $referer = str_replace("[CS]", "://", $referer); $referer = strtolower($referer); $okurls = split(",", $okurls); foreach ($okurls as $myokurls) { $myokurls = strtolower($myokurls); if ($referer == strtolower($myokurls)) { $found_url = "1"; } } if ($found_url == "0") { $ERROR_action = "bad_okurl"; include("$PATH_error$PAGE_error"); } } /* --- E N D I F S E T O K U R L = 1 --- */ /* check to see if posted */ if ($HTTP_GET_VARS || ! $HTTP_POST_VARS || $_GET || ! $_POST) { include("nverror.php4"); no_pst(); }else{ /* IF OLDER VERSION OF PHP CONVERT TO NEWER VARIABLES */ if (! $_POST) { $_POST = "$HTTP_POST_VARS"; } if (! $_SERVER) { $_SERVER = "$HTTP_SERVER_VARS"; } $year = date("Y"); $month = date("m"); $day = date("d"); $hour = date("h"); $min = date("i"); $tod = date("a"); $ip=$_SERVER["REMOTE_ADDR"]; $SEND_prnt = "The form below was submited by " . $_POST{"email"} . " from Ip address: $ip on $monthnameactual $month/$day/$year at $hour:$min $tod \n"; $SEND_prnt .= "--- DW Contractors ---\n\n"; /* CHECK TO SEE IF $_POST{"required"} IS SET */ if ($_POST{"required"}){ $post_required = $_POST{"required"}; $required = split(",", $post_required); $reqnum = count($required); for ($req=0; $req < $reqnum; $req++) { $REQ_name = $required[$req]; $REQ_value = $POST{"$REQ_name"}; if ($REQ_name == "email") { $goodem = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $_POST{"email"}, $trashed); if (! $goodem) { include("nverror.php4"); msng_email(); } /* end ! $goodem */ } elseif (! $_POST{"$REQ_name"}) { $isreqe = "1"; $REQ_error .= "<li> $REQ_name "; } /* end ! req val */ } /* end REQ for loop */ /* IF THERE ARE ANY REQUIRED FIELDS NOT FILLED IN */ if ($isreqe == "1") { include("nverror.php4"); msng_required(); } } /* END CHECK TO SEE IF $_POST{"required"} IS SET */ /* END IF THERE ARE ANY REQUIRED FIELDS NOT FILLED IN */ /* GET POSTED VARIABLES */ foreach ($_POST as $NVPOST_name => $NVPOST_value) { $NVPOST_value = str_replace("\n", "", $NVPOST_value); $NVPOST_value = str_replace("\r", "", $NVPOST_value); $NVPOST_value = preg_replace("'\cc:'si", "Cc ", $NVPOST_value); $NVPOST_value = preg_replace("'\bcc:'si", "bcc ", $NVPOST_value); $NVPOST_value = preg_replace("'\to:'si", "to ", $NVPOST_value); $NVPOST_value = preg_replace("'\bc:'si", "bc ", $NVPOST_value); if (strtolower($NVPOST_name) == "subject") { $NVPOST_value = str_replace(":", ";", $NVPOST_value); } /* G E T E M A I L */ if (strtolower($NVPOST_name) == "email") { $SEND_email = "$NVPOST_value"; $SEND_email = str_replace(":", "", $SEND_email); $SEND_email = str_replace(" ", "", $SEND_email); } /* END GET LEADS EMAIL */ if (! $_POST{"sort"}) { /* CHECK TO SEE IF CONFIG FIELD */ if ($NVPOST_name == "subject" || $NVPOST_name == "sort" || $NVPOST_name == "required" || $NVPOST_name == "success_page"){}else{ $SEND_prnt .= "$NVPOST_name: $NVPOST_value \n\n"; } } /* end ! sort */ } /* end foreach */ /* END GET POSTED VARIABLES */ if ($_POST{"sort"}) { /* SORT VARIABLES */ $sortvars = split(",", $_POST{"sort"}); $sortnum = count($sortvars); for ($num=0; $num < $sortnum; $num++) { $SEND_prnt .= "$sortvars[$num]: " . $_POST{"$sortvars[$num]"} . " \n\n"; } } /* END SORT VARIABLES */ /* send mail */ if (! $ccto) { $header = "From: $SEND_email\r\nReply-to: $SEND_email"; }else{ $header = "From: $SEND_email\r\nReply-to: $SEND_email\r\nCc: $ccto"; } mail($sendto, $_POST{"subject"}, $SEND_prnt, $header); /* END sendmail */ /* CHECK TO SEE IF FORM SPECIFYS A SUCCESS PAGE */ if (! $_POST{"success_page"}) { include("nverror.php4"); default_success(); }else{ $successpage=$_POST{"success_page"}; header("Location: $successpage"); /* redirect */ exit; } } /* END IF POSTED */ ?> I think this is the absolute best are to post this question. I hope it's not moved. Can you guys recommend any books that would give a very solid crash course in PHP5 OOP? Anything you've read and feel is worth it. I don't want to just go and pickup any first book i see. Thanks! Helo, I need big help how to adjust this code to new PHP 5.3 that dont support egeri any more public static function blacklist(&$query) { return eregi(self::$_blacklist, $query) ? true : false; } HELP ! ! ! I am setting up php5 on ubuntu 10.10 I can visit pages but they come up with errors Code: [Select] Notice: Undefined index: id in /var/www/alphawebpro.com/htdocs/index.php on line 5 Notice: Undefined index: action in /var/www/alphawebpro.com/htdocs/index.php on line 9 Warning: include(/var/www/alphawebpro.com/htdocs/home.php): failed to open stream: Permission denied in /var/www/alphawebpro.com/htdocs/index.php on line 105 Warning: include(): Failed opening 'home.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/alphawebpro.com/htdocs/index.php on line 105 Any idea as to how I fix this? I need to produce 4 byte CRC32 checksums for UDP packets sent to an rcon tool for an online game. The (brief) specification for formatting these UDP packets is he http://www.battleye.com/downloads/BERConProtocol.txt I have been converting the results of the CRC32() to hex and inserting it successfully in the correct part of the packet. The checksum result however is different from one that I packet captured from a working rcon tool. I have tried various methods of converting the int that CRC32 produces but have been unsuccessful in producing the correct checksum. For reference below is the captured correct packet from the working tool. All data is the same as the packets my tool produces except for the checksum. The checksum is bytes 3,4,5 & 6. and is formed (to my understanding) by performing a CRC32 check on the subsequent bytes. (From Smartsniff) 00000000 42 45 D5 C3 FB ED FF 00 61 62 63 64 65 31 32 BE...... abcde12 If anyone has a working CRC32 class that could reproduce the successful hash above or has any pointers in the correct direction I would be very thankful. I had a website running a XML script which worked perfectly but I have updated it by using XMLReader and PHP 5. However, there is a security update on PHP 5 which prevents me from accessing files on my server. Someone has suggested I add a php.ini file with the following: allow_url_fopen = on allow_url_include = on However I have also read that the whole purpose of the security update is to prevent this. Can someone advise me how I can get around this issue so that my server can read files and still operate by the PHP5 security update. Any help would be greatly appreciated. I have not been here for a long time, but just recently my php5.ini and .htaccess file got deleted while trying to install a new script. I have shared linux hosting at godaddy, but I cannot seem to get the code required inside these two files that would be standard or basic.
Does anyone have a sample code I can use on these two files?
Thanks in advance!
I just finished (or so I thought) a project. But my client's server runs PHP4, so I need to adapt my code. Here's what stopped working: Code: [Select] $localClasses = new DOMDocument; $localClasses -> load("file.xml"); $localClasses -> get_elements_by_tagname('Title') -> item(0) -> firstChild -> nodeValue Here's my petty attempt at trying to adapt this code to run in PHP4: Code: [Select] $file = file_get_contents("localClasses.xml"); $localClasses = new DOMDocument($file); $test = $localClasses -> get_elements_by_tagname('Title'); $testText = $test -> item[0] -> firstChild -> nodeValue; print $testText; This doesn't give me any errors, but nothing shows up. Any help would be appreciated. Thanks for reading! I'm sure this issue has been addressed before, but as I can't find anything on google OR bing, I've resorted to asking it he Since, ereg and eregi are deprecated in PHP5, how do you test strings using regular expressions? Is there a new function for this? EDIT: I also looked on php.net, but all it says is its deprecated in PHP5. I didn't see any links to the new function(s) that have replaced the former. I am trying to convert a php4 app to php5 and am getting this error (Fatal error: Cannot re-assign $this in ) when I call this class. $this = $this->createUnique($new); is the line that generates the error. I try to rename $this to $_this but it does not help. I think I lose the reference to the object later on in the code. Then I will get an error like (Fatal error: Call to a member function createUnique() on a non-object in) Is there another way to reference the current instance of an object in php5? Any help appreciated... Code Example: Code: [Select] class imageobject{ var $handle; var $height=0; var $width=0; var $directory; var $filename; //constructor function imageobject($directory,$filename,$width=0,$height=0,$color="FFFFFF") { $this->directory = $directory; $this->filename = $filename; if ($filename=="" && $width>0 && $height>0){ $new = $this->createImage($width,$height); $this = $this->createUnique($new); }elseif (file_exists($directory.$filename)){ $size = GetImageSize($directory.$filename); if ($size) $this->handle = $this->getHandle($directory.$filename,$size[2]); $this->width = $size[0]; $this->height = $size[1]; } function createUnique($imgnew) { $this->type = substr($this->output,0,3); $unique_str = $this->uniqueName(); switch ($this->type){ case "png": imagepng($imgnew,RES_DIR.$unique_str); break; default: imagejpeg($imgnew,RES_DIR.$unique_str,$this->quality); break; } $this->handle && imagedestroy($this->handle); $newobject = new imageobject(RES_DIR,$unique_str,$this->type); return $newobject; } )//end class Hello everyone. I have a problem with the local server (localhost connection). Until yesterday I used an old version of XAMPP's (version 1.6.4 with PHP 5.2.4) and last night I finally found the time to install XAMPP 1.7.3 with PHP 5.3.1. But some things that I worked under the old XAMPP-om, which are working perfectly now no longer work, and I do not know why. Please find enclosed pics that were under php4 and that now works. So I wonder where is the error and where possible errors. Also under my new PHP-om non-stop is done refresh the page and print portions of the code (as you can see from the picture). I am enable short tags support in php.ini. Thank you. PHP 5.3.1 PHP 5.2.4 Been using these includes in php4 for a long time, but they don't work in php5. Page loads, but included code is blank. Code: [Select] <?php include("http://www.xxxxxxxx.org/header.php"); ?> |