function delete_privilege($id, $priv_id) { $this->_model()->delete_privilege($id, $priv_id); $this->cache->context_delete($this->_model()->CACHE_KEY_PRIVILEGE); add_info(l('Privilege deleted.')); redirect($_SERVER['HTTP_REFERER']); }
function _save($id = null) { $this->_view = $this->_name . '/show'; $model = $this->_model(); if ($_POST) { if ($this->_validate()) { $_POST['id'] = $id; try { $tags = $_POST['tags']; unset($_POST['tags']); $id = $model->save($_POST, $id); $model->update_tag($tags, $id); if (!$this->input->is_ajax_request()) { redirect($this->_get_uri('listing')); } add_info($id ? l('Record updated') : l('Record added')); } catch (Exception $e) { add_error(l($e->getMessage())); } } } else { if ($id !== null) { $this->_data['id'] = $id; $_POST = $model->get($id); $_POST['tags'] = $model->get_tag($id); } } }
function ReceiveSettings($formname = '') { $this->dataset = manage_receive_dataset_from_selector($formname); if ($this->dataset == null) { return false; } if ($this->dataset->GetID() < 0) { add_info('Не указан набор данных'); return false; } $this->dataset->Ref(); $fields = array('uid' => 'INT', 'order' => 'INT'); $arr = $this->dataset->GenCreateFields(); foreach ($arr as $k => $v) { $fields[$k] = $v; } $this->settings['dataset'] = array('id' => $this->dataset->GetID(), 'settings' => $this->dataset->GetSettings()); $this->settings['content'] = content_create_support_table($this->content_id, $this->dataset->GetID(), $fields); $this->settings['script'] = -1; $this->settings['itemScript'] = -1; $this->settings['fullScript'] = -1; $this->settings['detailed'] = $_POST[$formname . '_detailed'] ? 1 : 0; $this->UpdateScripts(); $s = 'content_' . $this->content_id . '_count'; manage_settings_create('Количество элементов на странице для раздела ' . '«' . htmlspecialchars($this->GetName()) . '»', 'Разделы', $s, 'CSCSignedNumber'); opt_set($s, '10'); return true; }
function send() { global $keystring, $login, $email; $hash = md5('#RANDOM_PREFIX#' . mtime() . '#RANDOM_SEPARATOR#' . $login . '#WITH#' . $email . '#RANDOM_SUFFIX#'); if ($_SESSION['CAPTCHA_Keystring'] == '' || strtolower($keystring) != $_SESSION['CAPTCHA_Keystring']) { add_info('Вы не прошли тест Тьюринга на подтверждение того, что вы не бот.'); return false; } $r = db_row_value('user', "(`login` =\"{$login}\") AND (`email`=\"{$email}\") AND (`authorized`=1)"); if ($r['id'] == '') { add_info('Неверное сочетание login <-> email'); return false; } $s = unserialize($r['settings']); if ($s['restore_timestamp'] && time() - $s['restore_timestamp'] < config_get('restore-timeout')) { add_info('Вы не можете просить восстановку пароля так часто'); return false; } $s['restore_hash'] = $hash; $s['restore_timestamp'] = time(); db_update('user', array('settings' => db_string(serialize($s))), '`id`=' . $r['id']); $link = config_get('http-document-root') . '/login/restore/confirm/?id=' . $r['id'] . '&hash=' . $hash; sendmail_tpl(stripslashes($email), 'Восстановление пароля в системе ' . config_get('site-name'), 'restore', array('login' => stripslashes($login), 'email' => stripslashes($email), 'link' => $link)); return true; }
function CanCreate() { if (db_count('service', '`sclass` = "CSCLog"') == 0) { return true; } add_info('Может существовать лишь один серфис журналирования.'); return false; }
function CanCreate() { if (db_count('service', '`sclass`="CSCRSS"') == 0) { return true; } add_info('Может существовать лишь один RSS серфис.'); return false; }
function Update() { $name = htmlspecialchars(addslashes($this->name)); if (db_count('service', '`name`="' . $name . '" AND `id`<>' . $this->id) > 0) { add_info('Сервис с таким именем уже существует.'); return false; } db_update('service', array('name' => "\"{$name}\""), '`id`=' . $this->id); return true; }
function group_update($id) { $name = htmlspecialchars(trim($_POST['name'])); if ($name == '') { return; } if (db_count('group', '(`name`="' . $name . '") AND (`id`<>' . $id . ')') > 0) { add_info('Группа с таким именем уже существует.'); } else { db_update('group', array('name' => '"' . $name . '"', 'default' => manage_setting_get_received('default_group') ? 1 : 0), "`id`={$id}"); } }
function ReceiveSettings() { $this->dataset = manage_receive_dataset_from_selector($this->GetClassName()); if ($this->dataset == null) { return false; } if ($this->dataset->GetID() < 0) { add_info('Не указан набор данных'); return false; } $this->dataset->Ref(); $this->settings['dataset'] = array('id' => $this->dataset->GetID(), 'settings' => $this->dataset->GetSettings()); $this->settings['content'] = content_create_support_table($this->content_id, $this->dataset->GetID(), $this->dataset->GenCreateFields()); $this->settings['script'] = -1; return true; }
function user_delete($id) { if (user_is_system($id)) { add_info('Невозможно удалить этого пользователя, ' . 'так как он является системным.'); return false; } user_delete_from_groups($id); hook_call('CORE.Security.OnUserDelete', $id); return db_delete('user', 'id=' . $id); }
function UpdateCat($id, $name) { if (trim($name) == '') { add_info('Название подкаталога не может быть пустым.'); return false; } db_update($this->settings['content'], array('name' => db_html_string($name)), "`id`={$id}"); return true; }
function _save($id = null) { $this->_view = $this->_name . '/show'; if ($_POST) { if ($this->_validate()) { $_POST['id'] = $id; try { $this->_model()->save($_POST, $id); $referrer = $this->session->userdata('referrer'); if (empty($referrer)) { $referrer = $this->_get_uri('listing'); } add_info($id ? l('Record updated') : l('Record added')); if (!$this->input->is_ajax_request()) { redirect($referrer); } } catch (Exception $e) { add_error(l($e->getMessage())); } } } else { if ($id !== null) { $this->_data['id'] = $id; $_POST = $this->_model()->get($id); if (empty($_POST)) { show_404($this->uri->uri_string); } } $this->load->library('user_agent'); $this->session->set_userdata('referrer', $this->agent->referrer()); } $this->_data['fields'] = $this->_model()->list_fields(true); }
/** Redirects to the given request and Adds an information message to the global array of information $__info. @param arg_arr_request the array that contains the request parameteres (Controller, action ...). @param arg_str_info_msg [Optional] the message that is shown to the user. @param arg_arr_info_params [Optional] any extra parameters added to the info message if the message text has placeholders (Like %s or %d). @param arg_type [Optional] The type of the message that can be ("info" or "warning") which decides the style of the information shown. @return the output of the new request. */ public static function redirect($arg_arr_request, $arg_str_info_msg = "", array $arg_arr_info_params = array(), $arg_type = "info") { global $__in; if (!is_array($arg_arr_request)) { $arr_req = split("/", $arg_arr_request); $arg_arr_request = array(); if (count($arr_req) == 1) { $arg_arr_request['action'] = $arr_req[0]; } else { if (count($arr_req) == 2) { $arg_arr_request['controller'] = $arr_req[0]; $arg_arr_request['action'] = $arr_req[1]; } } } if ($arg_str_info_msg) { add_info($arg_str_info_msg, $arg_arr_info_params, $arg_type); } if (!$arg_arr_request['controller']) { $arg_arr_request['controller'] = $__in['controller']; } $_SESSION['__GET_REPITITION_STOPPER_OLD'] = $__in; $_SESSION['__GET_REPITITION_STOPPER_NEW'] = $arg_arr_request; $__in = $arg_arr_request; return dispatcher::request(); }
function Categories_Add($contest_id = -1) { global $name; if (!$this->GetAllowed('CONTEST.MANAGE')) { return; } if ($contest_id < 0) { $contest_id = $_SESSION['WT_contest_id']; } $name = stripslashes($name); if (trim($name) == '') { add_info('Имя категории не может быть пустым.'); return false; } if (db_count('tester_categories', '`name`=' . db_string($name))) { add_info('Категория с таким именем уже существует.'); return false; } $order = db_max('tester_categories', 'order', '`contest_id`=' . $_SESSION['WT_contest_id']) + 1; db_insert('tester_categories', array('name' => db_string(htmlspecialchars($name)), 'contest_id' => $contest_id, 'order' => $order)); return true; }
function Create() { global $_POST; $name = addslashes(htmlspecialchars(trim($this->name))); $path = addslashes($this->path); if ($name == '' || $path == '') { return false; } if (!check_dir($path)) { return false; } if (db_count('storage', '`name`="' . $name . '"')) { add_info('Хранилище данных с таким именем уже существует.'); return false; } else { if (db_count('storage', '`path`="' . $path . '"')) { add_info('Хранилище данных с таким путем уже существует.'); return false; } else { if (dir_exists($this->GetFullPath())) { add_info('Данный путь уже используется в системе. Пожалуйста, укажите другой.'); return false; } else { $sdir = config_get('site-root') . config_get('document-root') . config_get('storage-root'); @mkdir($sdir); @chmod($sdir, 0775); @mkdir($this->GetFullPath()); @chmod($this->GetFullPath(), 0775); db_insert('storage', array('name' => "\"{$name}\"", 'path' => "\"{$path}\"")); $this->id = db_last_insert(); db_create_table('storage_volume_' . $this->id, array('id' => 'INT NOT NULL PRIMARY KEY AUTO_INCREMENT', 'file' => 'TEXT', 'user_id' => 'INT', 'timestamp' => 'INT', 'accepted' => 'BOOL DEFAULT 0', 'params' => 'TEXT DEFAULT ""')); return true; } } } }
function delete_organization($id, $priv_id) { $this->_model()->delete_organization($id, $priv_id); add_info(l('Group data deleted.')); redirect($_SERVER['HTTP_REFERER']); }
function _save($id = null) { $this->_view = $this->_name . '/show'; $user_model = $this->_model('user'); $user = $this->auth->get_user(); if ($_POST) { if ($id && !$_POST['password'] && !$_POST['password2']) { unset($this->_validation['edit']['password']); unset($this->_validation['edit']['password2']); } if ($this->_validate()) { try { $id = $user_model->save($_POST, $id); add_info($id ? l('Record updated') : l('Record added')); if (!$this->input->is_ajax_request()) { redirect($this->_get_uri('listing')); } } catch (Exception $e) { add_error(l($e->getMessage())); } } } else { if ($id !== null) { $this->_data['id'] = $id; $_POST = $user_model->get($id); $param = array($_POST['id']); $roles = $user_model->_db()->query('SELECT role_id FROM ' . $user_model->_db()->dbprefix . 'user_role WHERE user_id = ?', $param)->result_array(); $_POST['roles'] = array(); if (!empty($roles)) { foreach ($roles as $role) { $_POST['roles'][] = $role['role_id']; } } $org = $user_model->_db()->query('SELECT org_id FROM ' . $user_model->_db()->dbprefix . 'user_organization WHERE user_id = ?', $param)->row_array(); if (!empty($org)) { $_POST['org_id'] = $org['org_id']; } $this->hooks->call_hook('user:fetch', $_POST); } } $_POST['password'] = ''; if (!$user['is_top_member']) { $this->db->where('id !=', '1'); } $roles = $this->db->order_by('name')->get('role')->result_array(); $this->_data['role_items'] = array('' => l('(Please select)')); foreach ($roles as $role) { $this->_data['role_items'][$role['id']] = $role['name']; } $orgs = $this->_model('organization')->find(null, array('name' => 'asc')); $this->_data['org_items'] = array('' => l('(Please select)')); foreach ($orgs as $org) { $this->_data['org_items'][$org['id']] = $org['name']; } }
function Create($name, $lid) { $gw = WT_spawn_new_gateway(); if (!$gw->GetAllowed('CONTEST.CREATE')) { return; } if (trim($name) == '') { add_info('Имя создаваемого контеста не может быть пустым'); } if (db_count('tester_contests', '`name`=' . db_html_string($name) . ' AND `lid`=' . $lid) > 0) { add_info('Контест с таким именем уже существует в списке ' . 'контестов указанной библиотеки.'); return; } $_POST = array(); $lib = WT_spawn_new_library($lid); $params = array(); $lib->PerformCreation(&$params); db_insert('tester_contests', array('name' => db_html_string($name), 'lid' => $lid, 'status' => 0, 'settings' => db_string(serialize($params)))); $this->FillData(); }
function ReceiveValue($field, $formname = '') { $this->SpawnStorage(); $data = $_FILES[$formname . '_' . $field]; $r = $this->Comporator($data['size'], $this->settings['size'], 'Размер', 1, 'байт'); if ($r != '') { add_info($r); return false; } $fn = $this->storage->Put($data, user_id()); $this->storage->Accept($fn); $this->val = $fn; return true; }
*/ if ($PHP_SELF != '') { print 'HACKERS?'; die; } ?> <div id="navigator"><a href="<?php echo config_get('document-root'); ?> /login">Вход в систему</a><a href="<?php echo config_get('document-root'); ?> /login/registration">Регистрация</a>Активация пользователя</div> ${information} <?php global $id, $hash; if (!isset($id) || !isnumber($id) || !isset($hash)) { add_info('Пропущен обязательный параметр.'); } else { $r = db_row_value('user', '`id`=' . $id); if ($r['authorized']) { add_info('Ошибка активации пользователя.'); } else { if (md5($r['login'] . '##VERY_RANDOM_SEED##' . $r['email'] . '##' . $r['id']) != $hash) { add_info('Ошибка активации пользователя.'); } else { add_info('Пользователь успешно активирован. Вход в систему с логином ' . $r['login'] . ' разрешен.'); db_update('user', array('authorized' => 1)); } } }
function ReceiveContentSettings($title, $field) { $st = $_POST['cntset_' . $field . '_storage']; if (!manage_stroage_exists($st)) { add_info('Не указано хранилище данных для поля «' . $title . '»'); return false; } $res = array(); $res['storage'] = $st; if (!$this->UpdateLimitSetting(&$res, $title, $field, 'hlimit')) { return false; } if (!$this->UpdateLimitSetting(&$res, $title, $field, 'vlimit')) { return false; } if (!$this->UpdateLimitSetting(&$res, $title, $field, 'size')) { return false; } $this->settings['data'] = $res; $this->settings = combine_arrays($this->settings, $res); return true; }
function Problem_AccessibleForSubmit($problem_id, $user_id, $silent = true, $contest_id = -1) { if ($contest_id < 0) { $contest_id = $_SESSION['WT_contest_id']; } $manage = $this->IsContestJudge(); $contest = WT_contest_by_id($contest_id); $add = ''; if ($contest['settings']['ignore_ce']) { $add = ' AND (`errors`<>"CE") '; } if ($contest['settings']['trycount'] > 0 && !$manage) { // TODO: // Optimize this stupid checking for correct working with ignored solutions if (db_count('tester_solutions', "(`ignored`=0) " . "AND (`errors`<>\"CR\") {$add} " . "AND (`user_id`={$user_id}) " . "AND (`contest_id`={$contest_id}) " . "AND (`problem_id`={$problem_id})") >= $contest['settings']['trycount']) { add_info('Невозможно послать решение задачи, так как превышен предел попыток.'); return false; } } if (db_count('tester_disabled_problems', '(`contest_id`=' . $contest_id . ') AND (`problem_id`=' . $problem_id . ')') > 0) { return false; } if (!WT_contest_running($contest_id) && !$manage) { add_info('Невозможно послать решение задачи, ' . 'так как контест завершен.'); return false; } if (!$this->Problem_IsAtContest($problem_id, $contest_id)) { if (!$silent) { add_info('Извините, но выбранная задача уже отсутсвует на контесте.'); } return false; } return true; }
function content_unavaliable() { add_info('Этот раздел в данное время Вам недоступен.'); }
function register() { global $agree, $email, $keystring; if ($_SESSION['CAPTCHA_Keystring'] == '' || strtolower($keystring) != $_SESSION['CAPTCHA_Keystring']) { add_info('Вы не прошли тест Тьюринга на подтверждение того, что вы не бот.'); return false; } if ($email == config_get('null-email')) { add_info('Недопустимый адрес электронной почты.'); return false; } if (!$agree) { add_info('Вы не согласны с правилами этого ресурса, так как же мы Вас здесь зарегестрируем?'); return false; } return user_create_received(false); }
$email = stripslashes($email); $arr = array(); $u = user_get_by_id(user_id()); if ($u['email'] != '' && !check_email($email)) { add_info('Указанный E-Mail не выглядит корректным'); } else { if (user_registered_with_email($email, user_id())) { add_info('Такой E-Mail уже используется.'); } else { $arr['email'] = db_string($email); } } if ($chpasswd_val) { global $passwd, $passwd_confirm; if ($passwd != $passwd_confirm) { add_info('Ошибка подтверждеия пароля. Пароль не был обновлен.'); } else { $arr['password'] = '******' . addslashes(user_password_hash(user_login(), stripslashes($passwd))) . '")'; } } if (count($arr) > 0) { db_update('user', $arr, '`id`=' . user_id()); if (isset($arr['password'])) { user_authorize(user_login(), stripslashes($passwd)); } } } $u = user_get_by_id(user_id()); $f = new CVCForm(); $f->Init('', 'action=.?action\\=save' . ($redirect != '' ? '&redirect=' . prepare_arg($redirect) . ';backlink=' . prepare_arg($redirect) : '') . ';method=POST;add_check_func=check;'); $f->AppendLabelField('Имя пользователя', '', $u['name']);
function Update($title) { global $_POST; $t = $title; $title = htmlspecialchars(trim($_POST['title'])); if ($title == '') { return; } $dataset = db_field_value('dataset_assoc', 'dataset', '`id`=' . $this->id); if (db_count('dataset_assoc', '`dataset`="' . $dataset . '" and `title`="' . $title . '" AND `id`<>' . $this->id) > 0) { add_info('Поле с таким именем уже существует в этом наборе данных.'); return false; } db_update('dataset_assoc', array('title' => "\"{$title}\""), '`id`=' . $this->id); $this->title = $t; return true; }
<div id="edit_container"> <?php session_start(); //Checking session name for security. include "LoginSecurity.php"; include "db.php"; echo "<h2>Add an item</h2>"; echo "<form action='Food_inventory.php?page=1' method='post'>\n\t\t\t\t\t\t<input type='submit' value='Home' />\n\t\t\t\t\t</form>\n\t\t\t\t"; echo "<hr />"; $action = NULL; if (isset($_GET['action'])) { $action = $_GET['action']; } //If they've pressed the Add button. if (isset($_POST['add'])) { add_info(); } //Displaying the form. display_food(); //Validate input. validate(); function display_food() { $categorysql = "SELECT DISTINCT category_description, category_id FROM category ORDER BY category_description"; $categoryresult = mysql_query($categorysql); echo "<form action='?action=submit' method='post' id='add_food_form'>\n\t\t\t\t\t\t<table border=1 class='full_input'>\n\t\t\t\t\t\t\t <th>Name</th>\n\t\t\t\t\t\t\t <th>Description</th>\n\t\t\t\t\t\t\t <th>Price</th>\n\t\t\t\t\t\t\t <th>Cyclone Card Item</th>\n\t\t\t\t\t\t\t <th colspan=2>Cyclone Card Price</th>\n\t\t\t\t\t\t<tr>"; echo "<td><input type='text' name='food_name'</td>"; echo "<td><textarea name='food_description'></textarea></td>"; echo "<td><input type='text' name='regular_price'</td>"; echo "<td><input type='text' placeholder='Yes/No' name='cyclone_card'/></td>\n\t\t\t\t\t\t\t\t<td colspan=2><input type='text' name='cyclone_price' placeholder='Amount or N/A'/></td>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<th>Sale Price</th>\n\t\t\t\t\t\t\t<th colspan=2>Sale Start Date</th>\n\t\t\t\t\t\t\t<th colspan=2>Sale End Date</th>\n\t\t\t\t\t\t\t<th>Category</th>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td><input type='text' name='sale_price' id='sale_price' /></td>\n\t\t\t\t\t\t\t<td colspan=2><input type='text' id='sale_start_date' name='sale_start_date' placeholder='Click to set date..' /></td>\n\t\t\t\t\t\t\t<td colspan=2><input type='text' id='sale_end_date' name='sale_end_date' placeholder='Click to set date..' /></td>\n\t\t\t\t\t\t\t<td><select name='category_id'>\n\t\t\t\t\t\t\t\t\t<option value='' selected disabled>--</option>;\n\t\t\t\t\t\t\t"; //This is the section to display all food categories (distinct) and default the selection to what the current category is for the food.
<?php require_once dirname(__FILE__) . "/../../../config.php"; require_once PHP_ROOT . "lib/inc.php"; require_once PHP_ROOT . "model/page.php"; $page = new page($_GET['id']); if ($_GET['lang'] == "en") { require_once PHP_ROOT . "uploads/translation/en.php"; } else { require_once PHP_ROOT . "uploads/translation/ar.php"; } $prefix = $_GET['prefix']; $arr_controls = array(); if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($page->add_picture($_FILES['pic'])) { add_info("file_uploaded"); } } if ($_GET['action'] == "del") { $page->delete_picture($_GET['image']); } elseif ($_GET['action'] == "setdefault") { $page->set_default_picture($_GET['image']); } elseif ($_GET['action'] == "unsetdefault") { $page->unset_default_picture(); } $arr_pix = $page->get_all_pictures(); ?> <html> <head> <link href="/view/en/default/style.css" rel="stylesheet"/> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1256"/>
* * This program can be distributed under the terms of the GNU GPL. * See the file COPYING. */ if ($PHP_SELF != '') { print 'HACKERS?'; die; } global $self, $wiki, $action, $id; $content = content_lookup(dirname($self)); if ($content != null) { if (!$content->GetAllowed('EDIT')) { header('Location: .'); } else { ?> <div id="navigator">Редактирование статьи</div> <div class="contentSub">Статья: «<a href="."><?php echo $content->GetName(); ?> </a>»</div> ${information} <?php if (user_id() < 0) { add_info('Вы не представились системе. Выйдите из этого раздела, если вы не нуждаетесь во внесении изменений в эту статью. ' . 'Так или иначае, Ваш IP-адрес протрассирован и сохранен, все Ваши действия журналируются. Если Вы совершите противозаконные действия, оговорённые УК РФ, то мы оставляем за собой право сообщить об этих действиях в правоохранительные органы.'); } $content->Editor_EditForm(); } } else { print '${information}'; add_info('Невозмонжно отобразить страницу, так как запрашиваемый раздел поврежден или не существует. Извините.'); }
function UpdateReceived() { global $_POST; $n = trim($_POST['className']); $name = htmlspecialchars(trim($_POST['className'])); if ($name == '') { return; } if (db_count('dataset', '`name`="' . $name . '" AND `id`<>' . $this->id) > 0) { add_info('Набор данных с таким именем уже существует.'); } else { db_update('dataset', array('name' => "\"{$name}\""), '`id`=' . $this->id); $this->name = stripslashes(trim($_POST['className'])); } }