protected function get_params(Query $query) { if (Session::getInstance()->is_moderator()) { Database::replace('help', array('key' => 'add', 'text' => (string) $query->get('text')), array('key')); } $this->set_success(true); }
public function recieve_art($data) { $parent = $data['data']['id_parent']; $this->set_param('variation_link', 'parent=' . $parent . '&sort=parent_order&order=asc&per_page=all'); $this->set_param('id_parent', $parent); if (!isset($data['data']['artist'][0]['id'])) { $this->set_param('is_author', false); $this->set_param('have_author', false); return; } $user = Session::getInstance()->get_data(); $this->set_param('is_author', $data['data']['artist'][0]['id'] == $user['user']['gallery']); $this->set_param('have_author', true); }
protected function get_params(Query $query) { $url = $query->get('url'); $name = $query->get('name'); if (empty($url) || empty($name)) { $this->set_error(420); return; } $session = Session::getInstance(); $cookie = $session->get_hash(); $order = Database::get_field('head_menu_user', 'max(`order`)', 'cookie = ?', $cookie); Database::insert('head_menu_user', ['cookie' => $cookie, 'name' => $name, 'url' => $url, 'order' => (int) $order + 1]); $this->set_success(true); $this->set_params(['id' => Database::last_id(), 'name' => $name, 'url' => $url]); }
public function __construct($api = false, $object = false, $data = array(), $method = 'recieve_data') { if ($api) { $this->api = (string) $api; } $this->data = (array) $data; $this->data['cookie'] = Session::getInstance()->get_hash(); $this->data['ip'] = Session::getInstance()->get_ip(); if ($object && is_callable(array($object, $method))) { $this->hash = md5($this->api . serialize($this->data)); $this->bind(array($object, $method)); } }
protected function get_modules(Query $query) { if (!Session::getInstance()->is_moderator()) { return []; } $return = [new HtmlAdminMenu($query)]; if ($query->url(1) == 'tag') { $return[] = new HtmlAdminTag($query); } if ($query->url(1) == 'help') { $return[] = new HtmlAdminHelp($query); } if ($query->url(1) == 'similar') { $return[] = new HtmlAdminSimilar($query); } return $return; }
protected function get_params(Query $query) { $section = $query->get('section'); $key = $query->get('key'); $value = $query->get('value'); $values = (array) $query->get('values'); if (empty($values)) { $values = [$key => $value]; } foreach ($values as $key => $value) { if (preg_match('/[^a-z_\\d]/ui', $section)) { $this->set_error(430); return; } $session = Session::getInstance(); $session->set($section, $key, $value); } $this->set_success(true); }
protected function get_params(Query $query) { $id = $query->get('id'); if (empty($id)) { return; } $session = Session::getInstance(); $cookie = $session->get_hash(); $item = Database::get_full_row('head_menu_user', 'cookie = ? and id = ?', [$cookie, $id]); foreach ($item as $key => $value) { $this->set_param($key, $value); } $order = Database::order('order', 'asc')->get_vector('head_menu_user', ['id', 'order'], 'cookie = ?', $cookie); $set_order = []; $i = 0; foreach ($order as $order_id => $value) { $set_order[] = ['selected' => $order_id == $id, 'order' => ++$i]; } $this->set_param('order', $set_order); }
protected function get_params(Query $query) { $id = $query->get('id'); $url = $query->get('url'); $name = $query->get('name'); $order = $query->get('order'); if (empty($url) || empty($name) || empty($id) || empty($order)) { $this->set_error(420); return; } Database::update('head_menu_user', ['url' => $url, 'name' => $name], $id); $session = Session::getInstance(); $cookie = $session->get_hash(); $items = Database::order('order', 'asc')->get_table('head_menu_user', array('id', 'order'), 'cookie = ?', $cookie); foreach ($items as &$item) { if ($item['id'] == $id) { $item['new_order'] = $order; } } unset($item); $new_order = 1; foreach ($items as &$item) { if (!empty($item['new_order'])) { continue; } if ($new_order == $order) { $new_order++; } $item['new_order'] = $new_order; $new_order++; } unset($item); foreach ($items as $item) { if ($item['new_order'] != $item['order']) { Database::update('head_menu_user', ['order' => $item['new_order']], $item['id']); } } $this->set_success(true); $this->set_params(['name' => $name, 'url' => $url, 'order' => $items]); }
use Otaku\Framework\Http; use Otaku\Framework\Session; use Otaku\Framework\Query; use Otaku\Art\Module\Main as Module; include_once 'framework/init.php'; define('API', ROOT_DIR . SL . 'api' . SL); define('API_LIBS', API . 'libs' . SL); define('API_IMAGES', API . 'images' . SL); new Autoload(array('Art' => LIBS, 'Api' => API_LIBS, 'Framework' => FRAMEWORK_LIBS), FRAMEWORK_EXTERNAL); mb_internal_encoding('UTF-8'); $config = Config::getInstance(); $config->parse(CONFIG . SL . 'define.ini', true); $config->parse(CONFIG . SL . 'settings.ini'); $config->add(['safe' => ['mode' => $safeMode]], true); $domain = $config->get('site', 'domain'); if ($domain && $domain != $_SERVER['SERVER_NAME']) { $url = 'http://' . $domain . $_SERVER['REQUEST_URI']; Http::redirect($url, true); } $session = Session::getInstance(); $session->init(); $config->add($session->get_data()); $query = new Query($_SERVER['REQUEST_URI'], array_replace($_POST, $_GET)); unset($_GET, $_POST); \RainTPL::configure('tpl_dir', TPL . SL); \RainTPL::configure('cache_dir', CACHE . SL . 'tpl' . SL); \RainTPL::configure('path_replace', false); $module = new Module($query); $request = $module->gather_request(); $request->perform(); $module->dispatch();