function restoreDBFromBackup() { makeRed("Restore Database? WARNING: This will drop all tables and restore data to last backup!"); echo "(Y/N): "; $data = FOPEN("php://stdin", "rb"); $input = ''; while (1 == 1) { $chunk = FREAD($data, 1); if ($chunk == "\n" || $chunk == "\r") { break; } $input .= $chunk; } FCLOSE($data); if (strtolower(@$input) == 'y') { echo "Getting Credentials from application.ini...\n"; $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $bootstrap = $application->getBootstrap(); $options = $bootstrap->getOptions(); $db = $options['resources']['db']['params']; echo "Database Restoring. Please be patient, this could take a while..."; sleep(1); echo "."; sleep(1); echo "."; sleep(1); echo "."; echo "\n"; exec("mysql -u " . $db['username'] . " -p" . $db['password'] . " " . $db['dbname'] . " < " . APPLICATION_PATH . "/../data/dbbackup.sql", $output); makeGreen("DONE!"); echo "\n\n"; } else { echo "Operation Cancelled.\n"; } }
function send_file($name) { OB_END_CLEAN(); $path = $name; //"../temp/".$name; if (!IS_FILE($path) or CONNECTION_STATUS() != 0) { return FALSE; } HEADER("Cache-Control: no-store, no-cache, must-revalidate"); HEADER("Cache-Control: post-check=0, pre-check=0", FALSE); HEADER("Pragma: no-cache"); HEADER("Expires: " . GMDATE("D, d M Y H:i:s", MKTIME(DATE("H") + 2, DATE("i"), DATE("s"), DATE("m"), DATE("d"), DATE("Y"))) . " GMT"); HEADER("Last-Modified: " . GMDATE("D, d M Y H:i:s") . " GMT"); HEADER("Content-Type: application/octet-stream"); HEADER("Content-Length: " . (string) FILESIZE($path)); HEADER("Content-Disposition: inline; filename={$name}"); HEADER("Content-Transfer-Encoding: binary\n"); if ($file = FOPEN($path, 'rb')) { while (!FEOF($file) and CONNECTION_STATUS() == 0) { print FREAD($file, 1024 * 8); FLUSH(); } FCLOSE($file); } return CONNECTION_STATUS() == 0 and !CONNECTION_ABORTED(); }
function xmlFeedImporter($feed_id) { $this->feed_id = $feed_id; $this->line = 0; $this->depth = 0; $this->feed_row = JB_XMLIMP_load_feed_row($feed_id); JBPLUG_do_callback('xml_import_parser_construct', $this); //require_once (dirname(__FILE__).'/xml_import_custom_functions.php'); // open the file depending on pickup method. // If FTP or URL then pre-fetch it and open the local file switch ($this->feed_row['pickup_method']) { case 'POST': // Read the raw input from stdin // http://www.php.net/wrappers.php // php://input is not available with enctype="multipart/form-data if (!($this->fp = fopen('php://input', 'rb'))) { $this->set_import_error("Couldn't open input stream"); return false; } // check the key if (trim($this->feed_row['feed_key']) != '') { $key = $_GET['key']; if ($key != $this->feed_row['feed_key']) { $this->set_import_error('Invalid key / key not received. Please make sure key is passed in the query string. eg. http://www.example.com/jb-xml-pickup.php?feed_id=1&key=something'); return false; } } break; case 'FILE': if (file_exists($this->feed_row['feed_filename'])) { $this->fp = fopen($this->feed_row['feed_filename'], 'rb'); } else { $this->set_import_error("File not found " . $this->feed_row['feed_filename']); return false; } break; case 'URL': $url = $this->feed_row['feed_url']; /*$url_arr = parse_url($url); $header .= "GET ".$url_arr['path']."?".$url_arr['query']." HTTP/1.1\r\n"; $header .= "Host: ".$url_arr['host']."\r\n\r\n"; if ($url_arr['scheme']=='http') { $port = 80; } elseif ($url_arr['scheme']=='https') { $port = 443; $url_arr['host'] = 'ssl://'.$url_arr['host']; // works only if openssl is compiled } else { $port = $url_arr['port']; } //if (!$this->fp = fsockopen ($url_arr['host'], $port, $errno, $errstr, 30)) { */ if (!($this->fp = fopen($url, 'rb'))) { $this->set_import_error('Cannot open URL ' . $this->feed_row['feed_url']); return false; } break; case 'FTP': $ftp_server = trim($this->feed_row['ftp_host']); $ftp_user = trim($this->feed_row['ftp_user']); $ftp_pass = trim($this->feed_row['ftp_pass']); $remote_file = trim($this->feed_row['ftp_filename']); // set up a connection or error if (!($conn_id = ftp_connect($ftp_server))) { $this->set_import_error("FTP: Couldn't connect to {$ftp_server}"); return false; } // try to login if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { // turn passive mode on ftp_pasv($conn_id, true); $s = md5(JB_SITE_NAME . time()); if (function_exists('JB_get_cache_dir')) { $cache_dir = JB_get_cache_dir(); } else { $cache_dir = JB_basedirpath() . 'cache/'; } $temp_filename = $cache_dir . 'import_temp_' . $s . '.xml'; if ($fp_temp = fopen($temp_filename, 'wb')) { if (ftp_fget($conn_id, $fp_temp, $remote_file, FTP_BINARY, 0)) { FCLOSE($fp_temp); $this->fp = fopen($temp_filename, 'rb'); } else { $this->set_import_error("FTP: Couldn't download {$remote_file}\n"); return false; } } ftp_close($conn_id); } else { $this->set_import_error("FTP: Couldn't login as {$ftp_user}\n"); return false; } // close the connection ftp_close($conn_id); break; } $this->FMD =& $this->feed_row['FMD']; }
<br/>LargeAvatar: <img src='$player->avatarfull'/>"; echo "<br/>SmallAvatar: <img src='$player->avatar'/>"; */ $steam64 = $player->steamid; $steamID = GetSteamNorm($steam64); //Get players ingame name $_SESSION['id'] = $steam64; $_SESSION['sid'] = $steamID; $_SESSION['name'] = $player->personaname; $_SESSION['mAvatar'] = $player->avatarmedium; $_SESSION['steamAPI'] = $_STEAMAPI; if (empty($admin)) { $str = "<?php \$admin = '{$steam64}';?>"; $fp = FOPEN("admin.php", "w"); FWRITE($fp, $str); FCLOSE($fp); echo "<p> Successfully made {$friendlyName} an admin!</p>"; header("Location: {$curdirectory}/logout.php"); } if ($steam64 == $admin) { $_SESSION['admin'] = True; } else { $_SESSION['admin'] = False; } } header("Location: {$curdirectory}/install.php"); } } } catch (ErrorException $e) { echo $e->getMessage(); }