'__s-backslash__', '/' => '__s-slash__', ':' => '__s-colon__', '*' => '__s-star__', '?' => '__s-quest__', '"' => '__s-quotes__', '<' => '__s-leftarrow__', '>' => '__s-rightarrow__', '|' => '__s-direct__'); public static function debug($var) { echo '
'; print_r($var); echo '
'; } public static function create($config, $query = null, $get = null, $clear_url = null) { $obj = new sc; $obj->config = $config; $obj->get = $get; $obj->clear_url = $clear_url; $obj->config['murl'] = str_replace(array('http://', 'https://'), '', $obj->config['url']); if(substr($obj->config['murl'], -1) == '/') $obj->config['murl'] = substr($obj->config['murl'], 0, -1); $obj->config['url_domain_count'] = count(explode('.', $obj->config['murl'])); if($query !== null) $obj->query = $query; return $obj; } public function getPage() { $call_url = $this->clear_url; if(preg_match('#schandler_#', $call_url)) { preg_match('#<\?!!php(.*)!!\?>#Uis', file_get_contents('cache/'.$call_url), $matches); eval($matches[1]); return $this; } $tmp = explode('/', $call_url); $end = array_pop($tmp); if(empty($end)) $end = array_pop($tmp); $_tmp = explode('.', $end); if(count($_tmp) == 1) { if(substr($call_url, -1) == '/') $call_url = $call_url.'index.html'; else $call_url = $call_url.'/index.html'; } else switch($_tmp[1]) { case 'jpg': case 'png': case'jpeg': $call_url = str_replace(array('(', ')'), '', $call_url); break; } if(file_exists('cache/'.$call_url)) { $this->page = file_get_contents('cache/'.$call_url); $this->SetHeaders(); return $this; } elseif(strpos( $this->query, '?')) { $url_end = substr($this->query, strpos($this->query, '?')); $url_end = str_replace(array_keys($this->__specsymbols), array_values($this->__specsymbols),$url_end); $call_url = $this->clear_url.$url_end; if(file_exists('cache/'.$call_url)) { $this->page = file_get_contents('cache/'.$call_url); $this->SetHeaders(); return $this; } } if($this->query !== null) { if(isset($url_end)) unset($url_end); if(strpos($this->query, '?')) $url_end = substr($this->query, strpos($this->query, '?')); $query = explode('/', $this->clear_url); $end = end($query); $file = strpos($end, '.') ? array_pop($query) : ''; if(isset($url_end)) $file = str_replace(array_keys($this->__specsymbols), array_values($this->__specsymbols), $file.$url_end); reset($query); $dir = 'cache'; foreach($query as $key => $value) { $dir = $dir.'/'.$value; @mkdir($dir); } } $http = new http; if($this->config['charset'] !== null) $http->encoding = $this->config['charset']; if(is_file('proxy.txt')) $http->proxy = $this->getProxy(); $url = $this->config['url']; if($this->query !== null) if(substr($this->query, 0, 3) == 's__') $url = 'http://'.substr($this->query, 3, strpos($this->query, '/')-3).'.'. $this->config['murl'].substr($this->query, strpos($this->query, '/')); else $url = $this->config['url'].$this->query; $this->page = $http->get($url); if($this->page == '') // в случае проблем с прокси. if(is_file('proxy.txt')) { $proxy_list = explode("\n", file_get_contents('proxy.txt')); foreach($proxy_list as $key => $value) $proxy_list[$key] = trim($value); $proxy_list = array_flip($proxy_list); unset($proxy_list[$http->proxy]); $proxy_list = array_flip($proxy_list); $proxy_list = implode("\r\n", $proxy_list); if(!empty($proxy_list)) file_put_contents('proxy.txt', $proxy_list); else @unlink('proxy.txt'); if(!is_file('proxy.txt')) { $this->proxy = ''; $this->page = $http->get($url); } else { $http->proxy = $this->getProxy(); $this->page = $http->get($url); } } if(isset($this->config['handlers'])) { $this->page = str_replace('', '', $this->page); } if(isset($this->query)) { $tmp = explode('.', $this->query); $ext = strtolower(array_pop($tmp)); switch($ext) { case 'css': $this->cssOperation(); $this->setHeaders(); break; case 'jpg': case 'jpeg': case 'png': $this->imageOperation(); $this->setHeaders(); return $this; break; default: $this->sinonim(); // Синонимайзер $this->cutCounters(); // Вырезаем счетчики $this->urlReplaces()->replaceHrefs(); // Замена ссылок $this->textReplaces(); // Замены (текст и регулярки) $this->formHandlers(); // Обработчики форм $this->SetHeaders(); // Установка заголовков } } else { $this->sinonim(); // Синонимайзер $this->cutCounters(); // Вырезаем счетчики $this->urlReplaces()->replaceHrefs(); // Замена ссылок $this->textReplaces(); // Замены (текст и регулярки) $this->formHandlers(); // Обработчики форм $this->SetHeaders(); // Установка заголовков } if($this->query !== null) { if(isset($file) and !empty($file)) file_put_contents($dir.'/'.$file, $this->page); else file_put_contents($dir.'/index.html', $this->page); } else file_put_contents('cache/index.html', $this->page); return $this; } public function sinonim() { if(isset($this->config['sinonim'])) { $db_name = 's.db'; if($this->config['charset'] == 'windows-1251') $db_name = 's1251.db'; $db = file_get_contents($db_name); $db = unserialize($db); $this->page = str_replace(array_keys($db), array_values($db), $this->page); } return $this; } public function cutCounters() { if(isset($this->config['cutcounters'])) { $counters = array( '@.*@s', '@@s', '@.*@s', '@.*@s', '@.*@s', '@.*@s', '@'. ''. ''. ''. ''. '', $html); echo $html; } else sc::ajaxPrint('Не удалось найти тег head в коде страницы'); } } elseif(isset($_POST['go'])) // Установка { $files = array(); $config = $_POST; $config['url'] = str_replace(array('http://', 'https://'), '', $config['url']); $config['url'] = 'http://'.$config['url']; $config['url'] = str_replace('www.', '', $config['url']); if(substr($config['url'], -1) != '/') $config['url'] = $config['url'].'/'; if(!isset($config['use_proxy'])) unset($config['proxy_list']); if(!isset($config['multiinstall'])) { unset($config['multiinstall_server']); unset($config['multiinstall_login']); unset($config['multiinstall_password']); unset($config['multiinstall_site_folders']); unset($config['multiinstall_site_urls']); } if(!isset($config['replacements_standart_checkbox'])) { unset($config['replacements_standart']); unset($config['replacements_standart_separator']); } if(!isset($config['replacements_regular_checkbox'])) { unset($config['replacements_regular']); unset($config['replacements_regular_separator']); } unset($config['go']); if(isset($config['script_password']) and !empty($config['script_password'])) $files['password.cfg'] = md5($config['script_password']); if(isset($config['proxy_list'])) { $files['proxy.txt'] = $config['proxy_list']; unset($config['proxy_list']); unset($config['use_proxy']); } if(is_file('password.cfg')) unlink('password.cfg'); if(is_file('replacements_regular.txt')) unlink('replacements_regular.txt'); if(is_file('replacements_standart.txt')) unlink('replacements_standart.txt'); $charset = strtolower($config['charset']); $config['charset'] = $charset; if(isset($config['replacements_standart'])) $files['replacements_standart.txt'] = iconv('utf-8', $charset, $config['replacements_standart']); if(isset($config['replacements_regular'])) $files['replacements_regular.txt'] = iconv('utf-8', $charset, $config['replacements_regular']); if(isset($config['replacements_standart'])) unset($config['replacements_standart']); if(isset($config['replacements_regular'])) unset($config['replacements_regular']); if(!isset($config['adminpanel'])) if(is_file('css_colors.txt')) unlink('css_colors.txt'); if(isset($config['adminpanel'])) unset($config['adminpanel']); if(isset($config['formhandler'])) { $info = json_decode($config['formhandler']); $info = (array)$info; $handlers = (array)$info['handlers'][0]; unset($info['handlers']); $handler = array(); if($handlers['type'] == 'email') { $handler['data']['email'] = $handlers['emailsend_email']; $handler['data']['title'] = $handlers['emailsend_title']; $handler['data']['text'] = $handlers['emailsend_text']; $handler['data']['text'] = str_replace("'", '"', $handler['data']['text']); $handler['data']['text'] = "'" . preg_replace('#\{\{name_([^}]+)}}#', '\'.@$_POST[\'$1\'].\'', $handler['data']['text']) . "'"; $handler['data']['text'] = str_replace('{{datetime}}', '\'.date("Y-m-d H:i:s").\'', $handler['data']['text']); file_put_contents('cache/schandler_'.$info['handler'].'.php', 'Успешно!
подождите.."; else echo "

Что-то пошло не так, попробуйте еще раз

"; !!?>'); } elseif($handlers['type'] == 'getpostsend') { if($handlers['getpostsend_type'] == 1) $handler['data']['type'] = 'get'; elseif($handlers['getpostsend_type'] == 0) $handler['data']['type'] = 'post'; $config['handlers']['getpost_url'] = $handlers['getpostsend_url']; $config['handlers']['getpost_type'] = $handler['data']['type']; } $config['handlers']['point'] = $info['point']; $config['handlers']['name'] = $info['handler']; $config['handlers']['type'] = $handlers['type']; unset($config['formhandler']); } $json_config = json_encode($config); $files['config.cfg'] = $json_config; $files['.htaccess'] = 'AddDefaultCharset UTF-8 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*) index.php [QSA] '; if(isset($config['multiinstall']) and $config['multiinstall'] == 'on') { $server = $config['multiinstall_server']; $login = $config['multiinstall_login']; $password = $config['multiinstall_password']; $folders = array_map('trim', explode("\n", $config['multiinstall_site_folders'])); $urls = array_map('trim', explode("\n", $config['multiinstall_site_urls'])); $ftp = ftp_connect($server); ftp_login($ftp, $login, $password); $list = ftp_nlist($ftp, '.'); $path = ''; if(array_search('public_html', $list)) $path = 'public_html/'; @mkdir('multi_temp'); file_put_contents('multi_temp/.htaccess', $files['.htaccess']); file_put_contents('multi_temp/password.cfg', $files['password.cfg']); file_put_contents('multi_temp/index.php', file_get_contents('index.php')); file_put_contents('multi_temp/s.db', file_get_contents('s.db')); foreach($folders as $key => $value) { $tmp_config = $config; if(isset($tmp_config['multiinstall'])) { unset($tmp_config['multiinstall']); unset($tmp_config['multiinstall_server']); unset($tmp_config['multiinstall_login']); unset($tmp_config['multiinstall_password']); unset($tmp_config['multiinstall_site_folders']); unset($tmp_config['multiinstall_site_urls']); } $tmp_config['url'] = isset($urls[$key]) ? $urls[$key] : $urls[0]; $tmp_config['url'] = str_replace('www.', '', $tmp_config['url']); $tmp_config['charset'] = sc::getCharset($tmp_config['url']); $tmp_config = json_encode($tmp_config); $files['config.cfg'] = $tmp_config; $files['index.php'] = $files['s.db'] = ''; file_put_contents("multi_temp/config.cfg", $files['config.cfg']); @ftp_mkdir($ftp, $path.$value.'/system'); @ftp_mkdir($ftp, $path.$value.'/cache'); foreach(array_keys($files) as $file_name) ftp_put($ftp, $path.$value.'/'.$file_name, 'multi_temp/'.$file_name, FTP_BINARY); foreach(array('adminpanel.html', 'main.html', 'install_success.html', 'http.php', 'class.upload.php', 'main.js', 'main.css') as $system_file_name) ftp_put($ftp, $path.$value.'/system/'.$system_file_name, 'system/'.$system_file_name, FTP_BINARY); } unlink('multi_temp/.htaccess'); sc::removeDir('multi_temp'); die('Готово'); } else { foreach($files as $key => $value) file_put_contents($key, $value); if(is_dir('cache')) sc::removeDir($_SERVER['DOCUMENT_ROOT'].'/cache'); if(is_dir('temp')) sc::removeDir($_SERVER['DOCUMENT_ROOT'].'/temp'); @mkdir('cache'); } header('Content-Type: text/html; charset=utf-8'); echo file_get_contents('system/install_success.html'); } else { // Скрипт не установлен header('Content-Type: text/html; charset=utf-8'); $html = file_get_contents('system/main.html'); echo $html; } } else { // Скрипт установлен - вывод сайта if(isset($_GET['sitecopy']) and $_GET['sitecopy'] == 'adminpanel') { if($password = sc::getPassword()) { if(!isset($_GET['password'])) { header('Location: /index.php'); die(); } else if(md5($_GET['password']) != $password) { header('Location: /index.php'); die(); } } if(isset($_GET['action'])) { switch($_GET['action']) { case 'clearcsssettings': if(file_exists('css_colors.txt')) { unlink('css_colors.txt'); echo 'Цвета перегенерированны.'; } else echo 'Нечего сбрасывать :) Чтобы сбросить настройки цветов, нужно сначала выбрать опцию "Рандомное изменение цветов в CSS"'; break; case 'clearcache': sc::removeDir('cache', false); mkdir('cache', 0777); echo 'Очистили папку cache.'; break; case 'reinstall': unlink('config.cfg'); header('Location: /'); break; case 'ajax': if(isset($_GET['function']) and $_GET['function'] == 'get_charset_from_url') sc::ajaxPrint(sc::getCharset($_GET['url'])); break; } die(); } else { if($password = sc::getPassword()) { if(!isset($_GET['password'])) { header('Location: /'); die(); } else if(md5($_GET['password']) != $password) { header('Location: /'); die(); } } $config = (array)json_decode(file_get_contents('config.cfg')); if(file_exists('replacements_standart.txt')) $config['replacements_standart_checkbox'] = 'on'; if(file_exists('replacements_regular.txt')) $config['replacements_regular_checkbox'] = 'on'; if(file_exists('proxy.txt')) { $config['use_proxy'] = 'on'; $config['proxy_list'] = file_get_contents('proxy.txt'); } $config = json_encode($config); $html = file_get_contents('system/adminpanel.html'); $html = str_replace('{{config}}', $config, $html); header('Content-Type: text/html; charset=utf-8'); echo $html; } } else { $config = json_decode(file_get_contents('config.cfg')); $query = $clear_url = $_SERVER['REQUEST_URI']; if($strpos = strpos($clear_url, '?')) $clear_url = substr($clear_url, 0, $strpos); $query = ($query == '/') ? null : substr($query, 1); if(substr($clear_url, 0, 1) == '/') $clear_url = substr($clear_url, 1); $sc = sc::create((array) $config, $query, $_GET, $clear_url)-> getPage()-> printPage(); } }