function initiate_session() { system_init(); memberReset(); transReset(); printReset(); getsubtotals(); loadglobalvalues(); loaddata(); }
<br />имя: ' . $edit . '<br /> <i>размер: ' . $info_img[0] . 'x' . $info_img[1] . '</i><br /><hr>'; $contentcenter .= 'Описание:<br /> <form action=?cat=' . $cat . '&edit=' . $edit . '&ok=1 name="uploadForm" method="post"> <textarea name="Opisanie" cols="40" row="6">' . $opisanie . '</textarea><br /> <input type="submit" value="Сохранить" /><br /> </form></table>'; if ($save) { $opisanie = $_POST['Opisanie']; $opisanie = str_replace("\n", ' ', $opisanie); $opisanie = str_replace("\r", '', $opisanie); $data = array('fname' => $cat . '/' . $edit, 'opisanie' => $opisanie); $present = 0; $arr = array(); if (file_exists($myFile)) { $arr = loaddata($myFile); } $present = false; if (is_array($arr)) { foreach ($arr as $key => $ta) { if ($cat . '/' . $edit == $ta['fname']) { $arr[$key]['opisanie'] = $opisanie; $present = true; break; } } } if (!$present) { $arr[] = $data; } savedataarray($myFile, $arr, 'w');
header('Content-Type: application/json'); } else { // set content type header to script header('Content-Type: text/javascript'); // wrap data in callback function $data = $callback . '(' . $data . ');'; } setResponseCode($code); exit($data); } // initialize data file with $schema data if (!file_exists($datafile)) { savedata($schema, $datafile); } // load data $data = loaddata($datafile); if (!$data) { $data = array(); } $range = !isset($_GET['range']) ? count($data) : $_GET['range']; $offset = !isset($_GET['offset']) ? 1 : $_GET['offset']; $callback = empty($_GET['callback']) ? '' : $_GET['callback']; // read request data from standard input into a variable // ref: http://www.lornajane.net/posts/2008/accessing-incoming-put-data-from-php parse_str(file_get_contents("php://input"), $REQUEST); // parse request URI into array of path segments $pattern = '/' . preg_quote(API_BASE_PATH, '/') . '/'; //$request = preg_replace($pattern, '', $_SERVER['REQUEST_URI']); $request = preg_replace($pattern, '', $_SERVER['REDIRECT_URL']); // separate request into path segments array $ps = explode('/', $request);
<?php $path = substr(str_replace('\\', '/', dirname(__FILE__)), 0, -6); include $path . '/admin/adminses.php'; include CONF . 'gbconf.php'; $sitetitle = "Управление гостевой книгой"; $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; $del = isset($_GET['del']) ? (int) $_GET['del'] : 0; $edit = isset($_GET['edit']) ? (int) $_GET['edit'] : 0; $moder = isset($_GET['moder']) ? (int) $_GET['moder'] : -1; $id = isset($_GET['id']) ? (int) $_GET['id'] : 0; $myFile = ENGINE . 'guestbookdb.php'; //Запись if (isset($_REQUEST['mess'])) { if ($edit > 0) { $gbs = loaddata($myFile); $data = $gbs[$edit - 1]; $msg = $_REQUEST['mess']; $msg = nl2br($msg); $msg = filterquotes($msg); $data['mess'] = $msg; $answer = trim($_REQUEST['answer']); if (strip_tags($answer) == '') { unset($data['answer']); } else { $data['answer'] = filterquotes(nl2br($answer)); } $gbs[$edit - 1] = $data; savedataarray($myFile, $gbs, 'w'); } header('Location: /admin/guestbook.php');
fclose($fp); } function loaddata($datafile) { // read from serialized file return @unserialize(@file_get_contents($datafile)); } $datafile = 'users.dat'; // Note: Do NOT use 'id' as a field name as id is used and passed as the array index $fieldlist = array('firstname', 'lastname', 'login'); // initialize data file if (!file_exists($datafile)) { savedata(array(array("firstname" => "John", "lastname" => "Doe", "login" => "jdoe"), array("firstname" => "Alex", "lastname" => "Jones", "login" => "ajones"), array("firstname" => "Mary", "lastname" => "Allen", "login" => "coachu"), array("firstname" => "Peter", "lastname" => "Geraci", "login" => "attyatlaw"), array("firstname" => "Liz", "lastname" => "Cleaver", "login" => "lcleaver"), array("firstname" => "Harry", "lastname" => "Jacobs", "login" => "hjacobs"), array("firstname" => "Alice", "lastname" => "Hartmann", "login" => "alice1"), array("firstname" => "Maria", "lastname" => "Alvarez", "login" => "ma229"), array("firstname" => "June", "lastname" => "Wendell", "login" => "june.wendell"), array("firstname" => "Bob", "lastname" => "Tackle", "login" => "thebob1"), array("firstname" => "Jane", "lastname" => "Smith", "login" => "jmsmith")), $datafile); } // load data $users = loaddata($datafile); if (!$users) { $users = array(); } $action = empty($_GET['action']) ? '' : strtoupper($_GET['action']); $type = empty($_GET['type']) ? 'JSON' : strtoupper($_GET['type']); $id = !isset($_GET['id']) ? -1 : $_GET['id']; $range = !isset($_GET['range']) ? count($users) : $_GET['range']; $offset = !isset($_GET['offset']) ? 0 : $_GET['offset']; $callback = empty($_GET['callback']) ? '' : $_GET['callback']; if (!empty($callback)) { $type = 'JSON'; } // force type to JSON if callback present //echo "action: $action id: $id type: $type"; switch ($action) {
function inc_newsread_count($news_id) { global $newslogfilename; $news = loaddata($newslogfilename); $notread = true; $newsout = array(); foreach ($news as $data) { if ($data['id'] == $news_id) { $data['count']++; $notread = false; } $newsout[] = $data; } if ($notread) { $newsout[] = array('id' => $news_id, 'count' => 1); } savedataarray($newslogfilename, $newsout, 'w'); }
<?php header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); header('Content-type: application/json; charset=utf-8'); if (isset($_GET['call'])) { if ($_GET['call'] == 'loaddata') { echo loaddata(); } } else { if ($_POST['action'] == 'savedata') { echo json_encode(savedata($_POST['colors'], $_POST['shapes'])); } } function savedata($colors, $shapes) { $directory = "../data"; $valid = true; $result = '{"status":"fail","error":"Data file not found"}'; if (is_dir($directory)) { $fname = "{$directory}/data.txt"; $fh = fopen($fname, 'w'); $data = '"colors":' . $colors . ',"shapes":' . $shapes; fwrite($fh, $data); fclose($fh); } else { $result = '{"status":"fail"'; $result .= ',"error":"Directory not found"}'; $valid = false; } if ($valid) { $result = '{"status":"success"}';
} elseif (isset($_GET['editbook'])) { echo "<div align=\"center\"><h2>Update Page</h2></div>"; include 'editbook.php'; list($bookid, $nam, $cat, $aut, $pub, $inf, $cod, $pic, $usermail, $price, $hidden, $cata) = loaddata($user, "", "edit", 1); echo "<div align=\"center\"><form enctype=multipart/form-data method=post action=index.php?postbook=1&del={$bookid} class=\"signin\" onSubmit=\"return con();\"><button type=submit class=\"btn btn-danger\">Delete The Book</button></form></div>"; include 'postbook.php'; } elseif (isset($_GET['editprofile'])) { echo "<div align=\"center\"><h2>User Information</h2></div>"; include 'editprofile.php'; } elseif (isset($_GET['order'])) { $datetime = date('Y-m-d H:i:s', time()); $bookid = $_POST['orderbook']; $postsql = "INSERT INTO `order` VALUES ('0', '{$bookid}', '1', '{$user}', '{$datetime}');"; include 'uploadinformation.php'; postthing($postsql); loaddata($user, "", "myorder", 1); } elseif (isset($_GET['delorder'])) { $orderdel = $_POST['orderdel']; $postsql = "DELETE FROM `order` WHERE `orderid` = '{$orderdel}';"; include 'uploadinformation.php'; postthing($postsql); loaddata($user, "", "myorder", 1); } elseif (isset($_GET['myorder'])) { loaddata($user, "", "myorder", 1); } elseif (isset($_GET['search'])) { loaddata($user, "", "search", 1); } elseif (isset($_GET['cat'])) { loaddata($user, "", "cat", 1); } else { loaddata("", "", "recent", 1); }
case "ShowOneMember": $RestrictToIdMember = IdMember(GetParam("cid", 0)); break; case "HideAction": $Message = "Toggle hide for general public"; toggleAction('DisplayInPublic', 0); break; case "UnhideAction": $Message = "Toggle hide for general public"; toggleAction('DisplayInPublic', 1); break; case "DefaultEditAction": $Message = "Toggle whether creator may edit post"; toggleAction('AllowEdit', 0); break; case "AllowEditAction": $Message = "Toggle whether creator may edit post"; toggleAction('AllowEdit', 1); break; } function toggleAction($act, $newValue) { $str = "UPDATE comments SET {$act} = {$newValue} WHERE id=" . Getparam("IdComment"); sql_query($str); LogStr(" Toggling <b>hide</b> for IdComment #" . Getparam("IdComment"), "AdminComment"); } $Message = "Negative Comments"; $count = getcount("AdminCommentMustCheck", $RestrictToIdMember); // call the layout DisplayAdminComments(loaddata("AdminCommentMustCheck", $RestrictToIdMember, $page, $comments_per_page), $Message, $page, $comments_per_page, $count, "AdminCommentMustCheckList");
} $search_bad_words = array("'хуй'si", "'пизд'si", "'ёб'si", "'сука'si", "'суки'si", "'дроч'si", "'хуя'si", "'ссуч'si"); $replace = array("*", "*", "*", "*", "*", "*", "*", "*"); $msg = preg_replace($search_bad_words, $replace, $msg); $name = preg_replace($search_bad_words, $replace, $name); $city = preg_replace($search_bad_words, $replace, $city); if (empty($error)) { $msg = nl2br($msg); $msg = str_replace("\n", " ", $msg); $msg = str_replace("\r", " ", $msg); require_once CODE . 'bbParser.php'; $bbcode = new bbParser($disableURL); $msg = $bbcode->getHtml($msg); $data = array('time' => time(), 'name' => $name, 'city' => $city, 'email' => $email, 'url' => $url, 'mess' => $msg, 'ip' => $_SERVER[REMOTE_ADDR]); if (file_exists($myFile)) { $datas = loaddata($myFile); // Если $catmessage = true органичиваем число // сообщений в гостевой книге $nummessage if ($catmessage && count($datas) >= $nummessage) { array_splice($datas, 0, count($datas) - $nummessage + 1); } } $datas[] = $data; savedataarray($myFile, $datas, 'w'); @setcookie('flood_gb', $gbflood, time() + $gbflood); // Если $sendmail = true отправляем уведомление if ($sendmail) { $thm = 'guestbook - a new post'; $msg = "post: {$msg}\nname: {$name}"; mail($valmail, $thm, $msg); }