.
*
* @package 2Moons Webinstaller
* @author Slaver
* @copyright 2011 Slaver (Fork/2Moons)
* @license http://www.gnu.org/licenses/gpl.html GNU GPLv3 License
* @version 1.1 (2011-02-23)
* @link http://code.google.com/p/2moons/
*/
// Get RootPath
$ROOT = str_replace('\\', '/', dirname(__FILE__)).'/';
// Set Revision
$REV = !isset($_GET['revision']) ? 1 : (int) $_GET['revision'];
// Set SVN Paths
$SVN = 'http://2moons.googlecode.com/';
$SVNHIS = $SVN.'svn-history/r'.$REV.'/trunk/';
$SVNPATH = $SVN.'svn/trunk/';
$CAPTCHASVN = 'http://recaptcha.googlecode.com/svn/trunk/recaptcha-plugins/php/';
// Set Functions for ErrorHandling
function ErrorHandler($errno, $errstr, $errfile, $errline) {
switch ($errno) {
case E_WARNING:
case E_USER_WARNING:
$error = 'Warning: '.$errstr;
break;
case E_ERROR:
case E_USER_ERROR:
$error = 'Fatal Error: '.$errstr;
break;
default:
$error = 'Unknown: '.$errstr;
break;
}
ob_clean();
header('HTTP/1.1 502 Bad Gateway');
echo json_encode(array('status' => $error));
ob_end_flush();
exit;
}
function FatalErrorHandler()
{
if ($error = error_get_last())
ErrorHandler($error['type'], $error['message'], $error['file'], $error['line']);
}
set_error_handler('ErrorHandler');
register_shutdown_function('FatalErrorHandler');
// Start AJAX Actions
if(isset($_GET['action'])) {
ob_start();
@set_time_limit(0);
ini_set('display_errors', 0);
switch($_GET['action']) {
case 'filelist': // Get Filelist from SVN
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CRLF, true);
curl_setopt($ch, CURLOPT_USERAGENT, "2Moons WebInstaller");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$List = array();
function getPath($Path)
{
global $ch, $SVNHIS, $List;
curl_setopt($ch, CURLOPT_URL, $SVNHIS.$Path);
$RAW = curl_exec($ch);
preg_match_all('//', $RAW, $MATCHES);
foreach($MATCHES[1] as $MATCH) {
if($MATCH === '../')
continue;
$List[] = $Path.$MATCH;
if(substr($MATCH, -1) === '/')
getPath($Path.$MATCH);
}
}
getPath('');
curl_close($ch);
echo json_encode($List);
rename(__FILE__, $ROOT.'webinstall.php');
break;
case 'require': // Get Requriments for 2Moons
echo json_encode(array(
'php' => version_compare(PHP_VERSION, "5.2.5", ">=") ? 'yes' : 'no',
'mysqli' => class_exists('mysqli') ? 'yes' : 'no',
'iniset' => function_exists('ini_set') ? 'yes' : 'no',
'curl' => function_exists('curl_init') ? 'yes' : 'no',
'root' => is_writable($ROOT) ? 'yes' : 'no',
));
break;
case 'revision': // Get last Revisions Number
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $SVNPATH);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CRLF, true);
curl_setopt($ch, CURLOPT_USERAGENT, "2Moons WebInstaller");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo (int)preg_replace('/.*Revision (\d{1,4}).*/im', '$1', curl_exec($ch));
break;
case 'unlink': // Delete Installfiles
unlink($ROOT.'webinstall.php');
file_put_contents($ROOT.'install/.htaccess', 'deny from all');
break;
case 'download': // Download a File
if(strpos($_GET['file'], '.') === false) {
if(!file_exists(dirname($ROOT.$_GET['file'])))
mkdir(dirname($ROOT.$_GET['file']));
if(!file_exists($ROOT.$_GET['file']))
mkdir($ROOT.$_GET['file']);
chmod($ROOT.$_GET['file'], 0777);
echo json_encode(array('status' => 'OK'));
exit;
}
if(strpos($_GET['file'], 'libs/reCAPTCHA/') !== false) {
$SVNHIS = $CAPTCHASVN;
$Path = str_replace('includes/libs/reCAPTCHA/', '', $_GET['file']);
} elseif($_GET['file'] == '.htaccess' && file_exists($ROOT.'.htaccess')) {
$Path = $_GET['file'];
$_GET['file'] = '_htaccess';
} else {
$Path = $_GET['file'];
}
$fp = fopen($ROOT.$_GET['file'], 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_URL, $SVNHIS.$Path);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "2Moons WebInstaller");
curl_setopt($ch, CURLOPT_CRLF, true);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
if(curl_errno($ch))
echo json_encode(array('status' => curl_error($ch)));
else
echo json_encode(array('status' => 'OK'));
curl_close($ch);
fclose($fp);
chmod($ROOT.$_GET['file'], 0666);
break;
}
ob_end_flush();
exit;
}
?>
Partneroldalak:
Domain regisztrci tr s szerverszolgltatsok: domain domainnv trhely e-mail, imap, pop3
www.webtar.hu
www.micropay.hu
www.ingyenweb.hu
www.videok.hu
www.antikvrium.hu
www.ftpdir.hu
www.fotk.hu
www.randi.hu
www.licit.hu
www.napivicc.hu
www.gyertyalang.hu
www.helyesrs.hu
Domain regisztrci