Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- check_login('3');
- $id=$_REQUEST['id'];
- ?>
- <h2><a href="index.php">Dashboard</a> » <a href="#" class="active">Reinstall</a></h2>
- <div id="main">
- <table cellpadding="0" cellspacing="0">
- <tr>
- <?php
- $array = mysql_query("SELECT * FROM cpanel WHERE id = $id AND username = '".$_SESSION['username']."'") or die(mysql_error());
- $rows = mysql_fetch_array($array);
- $people = array($rows['username']);
- if (in_array($_SESSION['username'],$people, TRUE))
- {
- $select = "SELECT * FROM cpanel WHERE id = $id";
- $results = mysql_query($select);
- $num_rows = mysql_num_rows($results);
- while ($row = mysql_fetch_array($results)){
- // Info required for cPanel access
- $cpuser = $row['cpuser']; // Username used to login to CPanel
- $cppass = $row['cppass']; // Password used to login to CPanel
- $domain = $row['domain']; // Domain name where CPanel is run
- $skin = $row['skin']; // Set to cPanel skin you use (script won't work if it doesn't match). Most people run the default x theme
- // Info required for FTP host
- $ftpuser = $row['ftpuser']; // Username for FTP account
- $ftppass = $row['ftppass']; // Password for FTP account
- $ftphost = $row['ftphost']; // Full hostname or IP address for FTP host
- $ftpmode = $row['ftpmode']; // FTP mode ("ftp" for active, "passiveftp" for passive)
- $ftpport = $row['ftpport']; // FTP port
- $ftpdir = $row['ftpdir']; // FTP directory
- // Notification information
- $notifyemail = $row['email']; // Email address to send results
- // Secure or non-secure mode
- $secure = $row['secure']; // Set to 1 for SSL (requires SSL support), otherwise will use standard HTTP
- // Set to 1 to have web page result appear in your cron log
- $debug = 1;
- // *********** NO CONFIGURATION ITEMS BELOW THIS LINE *********
- if ($secure) {
- $url = "ssl://".$domain;
- $port = 2083;
- } else {
- $url = $domain;
- $port = 2082;
- }
- $socket = fsockopen($url,$port);
- if (!$socket) {
- echo "Failed to open socket connection... Bailing out!\n";
- $to = $notifyemail;
- $subject = "Backup Failed!";
- $message = "Hello! This is a email reminder to let you know that the backup for your cPanel account failed to connect for ".$domain."... Please double check all of your connection settings!";
- $from = "failed@freeautobackup.com";
- $headers = "From:" . $from;
- mail($to,$subject,$message,$headers);
- echo "Notifying user!";
- exit;
- }
- // Encode authentication string
- $authstr = $cpuser.":".$cppass;
- $pass = base64_encode($authstr);
- //local with mail
- $m = "email=$notifyemail&submit=Generate Backup";
- //remote with mail
- $fm = "dest=$ftpmode&email=$notifyemail&server=$ftphost&user=$ftpuser&pass=$ftppass&port=$ftpport&rdir=$ftpdir&submit=Generate Backup";
- //remote with no mail
- $fnm = "dest=$ftpmode&server=$ftphost&user=$ftpuser&pass=$ftppass&port=$ftpport&rdir=$ftpdir&submit=Generate Backup";
- $result = $nm;
- if ($result == $nm) {
- $params = $nm;
- }
- elseif ($result == $m) {
- $params = $m;
- }
- elseif ($result == $fm) {
- $params = $fm;
- }
- elseif ($result == $fnm) {
- $params = $fnm;
- }
- // Make POST to cPanel
- fputs($socket,"POST /frontend/".$skin."/backup/dofullbackup.html?".$params." HTTP/1.0\r\n");
- fputs($socket,"Host: $domain\r\n");
- fputs($socket,"Authorization: Basic $pass\r\n");
- fputs($socket,"Connection: Close\r\n");
- fputs($socket,"\r\n");
- // Grab response even if we don't do anything with it.
- while (!feof($socket)) {
- $response = fgets($socket,4096);
- if ($debug) echo $response;
- }
- if(preg_match("/401 access denied/i", $socket)){ echo "hi"; }
- fclose($socket);
- echo "Starting backup for user ".$cpuser." at ".$domain."";
- echo "<br>";
- }
- }
- else
- {
- echo "This isn't yours...<br />";
- }
- ?>
- </tr>
- </table>
- <br>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement