function add_rule($arr) { if (isset($arr['code']) || $arr) { $value = array('code' => '', 'desc' => ''); if (!is_array($arr)) { $value['code'] = $arr; } else { $value = set_merge($value, $arr); } $rules = get_option('rules_all', true); $rules_search = get_rules(); $rules_search = array_merge($rules_search[0], $rules_search[1]); if (!is_array($rules)) { $rules = array(); } $value['code'] = canone_code($value['code']); $t = true; foreach ($rules_search as $item) { if ($value['code'] == $item['code']) { $t = false; } } if ($t) { $rules[] = $value; return update_option('rules_all', json_val_encode($rules)); } else { return false; } } else { return false; } }
function add_action($arr) { global $ACTIONS, $APAGES; $custom = array('code' => '', 'function' => '', 'rule' => 'admin', 'category' => 'public', 'priority' => 30, 'zone' => '', 'auto' => ''); $custom = set_merge($custom, $arr); $key = $custom['code'] = canone_code($custom['code']); if (validate_code($key) && !isset($ACTIONS[$key]) && (isset($APAGES['index']) && $custom['category'] == $APAGES['index']->category || $custom['category'] == 'all')) { $ACTIONS[$key] = new actions_collector($custom); } }
function add_script($arr) { global $SCRIPTS, $APAGES; $custom = array('code' => '', 'type' => 'script', 'link' => '', 'function' => '', 'priority' => '30', 'auto' => '', 'category' => 'public', 'zone' => ''); $custom = set_merge($custom, $arr); $key = $custom['code'] = canone_code($custom['code']); if (validate_code($key) && !isset($SCRIPTS[$key]) && (isset($APAGES['index']) && $custom['category'] == $APAGES['index']->category || $custom['category'] == 'all')) { $SCRIPTS[$key] = new scripts_collector($custom); } }
function add_option($params) { global $DETDB; if (is_array($params)) { $custom = (array) new option($params, true); $custom['code'] = canone_code($custom['code']); if (validate_code($custom['code'])) { if (!check_code('options', $custom['code'], 'code')) { return $DETDB->insert('options', $custom); } else { push_output_message(array('text' => 'Данный код уже занят.', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'error')); } } else { push_output_message(array('text' => 'Отправлен неправильный (невалидный) код.', 'title' => 'Ошибка!', 'class' => 'alert alert-warning', 'type' => 'error')); } } return false; }
function update_detblock($ID, $par) { global $DETDB; if (is_merged($par) && is_numeric($ID) && ($obj = $DETDB->isset_cell('detblocks_types', $ID))) { $par = (array) $par; $custom = array(); if (isset($par['code']) && $par['code']) { $par['code'] = canone_code($par['code']); if (!validate_code($par['code'])) { return false; } else { $custom['code'] = $par['code']; } } if (isset($par['name'])) { $custom['name'] = $par['name']; } if (isset($par['description'])) { $custom['description'] = $par['description']; } return $DETDB->update('detblocks_types', $custom, "WHERE ID={$ID}"); } return false; }
function update_users_groups($par, $cond) { global $DETDB; if (is_merged($par)) { $par = (array) $par; if (isset($par['code'])) { $par['code'] = canone_code($par['code']); if (!validate_code($par['code'])) { return false; } } return $DETDB->update('users_groups', $par, $cond); } return false; }
define('INCLUDES', '/includes'); define('ABSPATH', realpath(dirname(__FILE__))); $CONNECT = (object) array('action' => $_POST['action'], 'params' => isset($_POST['params']) ? $_POST['params'] : null, 'category' => isset($_POST['category']) && $_POST['category'] ? $_POST['category'] : 'public', 'key' => isset($_POST['key']) && $_POST['key'] ? $_POST['key'] : null, 'host' => $_SERVER['HTTP_REFERER'] ? parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) : null, 'type' => null); if ($CONNECT->key) { $CONNECT->type = 'remote'; } elseif ($CONNECT->host == $_SERVER['HTTP_HOST']) { $CONNECT->type = 'ajax'; } if ($CONNECT->type) { require_once ABSPATH . INCLUDES . '/basic-load.php'; global $BLOCK; if (!$BLOCK) { if ($CONNECT->type == 'remote' && (!check_remote_key($CONNECT->key) || $_SERVER['HTTP_USER_AGENT'] != 'DETWorker')) { echo 'Wrong key'; } else { $CONNECT->action = canone_code($CONNECT->action); if (!preg_match('/^(' . $CONNECT->type . '_)/i', $CONNECT->action)) { $CONNECT->action = $CONNECT->type . '_' . $CONNECT->action; } if ($CONNECT->params && check_json($CONNECT->params)) { $CONNECT->params = json_decode($CONNECT->params, true); } if ($CONNECT->category == 'admin') { require_once ABSPATH . '/' . ADMIN . INCLUDES . '/admin-load.php'; } else { require_once ABSPATH . INCLUDES . '/public/public-load.php'; } require_once ABSPATH . INCLUDES . '/basic-doit.php'; actions_zone($CONNECT->type . '_before_action', $CONNECT->params); make_action($CONNECT->action, $CONNECT->params); actions_zone($CONNECT->type . '_after_action', $CONNECT->params);
function get_real_key() { global $APAGES; $key = isset($_GET['page']) ? $_GET['page'] : 'index'; return canone_code($key); }