if ($action === "add") { $name = $_POST['name']; for ($i = 0; $i < strlen($name); $i++) { if (Ord($name[$i]) >= 65 && Ord($name[$i]) <= 90 || $name[$i] === '_') { } else { exit("Bad macros name."); } } $type = $_POST['type']; $t_body = $_POST['t_body']; if (strlen($t_body) > 5) { $fp = fopen("../macro/{$name}.txt", "w") or die("Cant create file '{$name}'."); fwrite($fp, $t_body); fclose($fp); } $linec = line_count($name . ".txt"); @mysql_query("INSERT INTO macro (name,type,file,count) VALUES ('{$name}','{$type}','{$name}.txt','{$linec}');"); Header("Location: http://{$server}/spm/admin/macros.php"); } elseif ($action === "delete") { $macid = $_GET['macid']; $res = @mysql_query("SELECT * FROM macro WHERE `id` = {$macid};"); @mysql_query("DELETE FROM macro WHERE `id` = {$macid};"); /* if ($res) { $file = "../macro/".mysql_result($res,0,'file'); if (file_exists($file)) unlink($file); Header("Location: http://$server/spm/admin/macros.php"); } else echo "Netu takogo macrosa."; */ } echo "<hr>\r\n";
if (!$f) { return 0; } $linecount = 0; while (!feof($f)) { $str1 = fgets($f, 1024); $linecount++; } fclose($f); //$linecount--; return $linecount; } $action = $_GET['action']; if ($action === "add") { $file = $_POST['file']; $linec = line_count("../lists/" . $file); mysql_query("INSERT INTO lists (file,count) VALUES ('{$file}','{$linec}');"); Header("Location: http://{$server}/spm/admin/lists.php"); } elseif ($action === "delete") { $listid = $_GET['listid']; @mysql_query("DELETE FROM lists WHERE `id` = {$listid};"); } echo "<hr>\r\n"; echo "<div align='center'><h2>Lists</h2></div>\r\n"; include "menu.inc"; echo "<hr>\r\n"; $list = @mysql_query("SELECT * FROM lists;"); $list_count = @mysql_num_rows($list); if ($list_count > 0) { echo "<table border='1' align='center'>"; echo "<tr><td>File</td><td>Count</td><td>Delete</td></tr>\r\n";