/** * load help content from db */ public function loadContent() { $help_content = HelpContent::getContentByRoute(); foreach ($help_content as $row) { $this->addPlainText($row['label'] ?: '', $this->interpolate($row['content'], $this->variables), $row['icon'] ? Icon::create($row['icon'], 'info_alt') : null, URLHelper::getURL('dispatch.php/help_content/edit/' . $row['content_id']), URLHelper::getURL('dispatch.php/help_content/delete/' . $row['content_id'])); } if (!count($help_content) && $this->help_admin) { $this->addPlainText('', '', null, null, null, URLHelper::getURL('dispatch.php/help_content/edit/new' . '?help_content_route=' . get_route())); } }
/** * sends tour object as json data * * @param string $tour_id id of tour object * @param String $step_nr number of step to start with */ function get_data_action($tour_id, $step_nr = 1) { $this->route = get_route(Request::get('route')); $this->tour = new HelpTour($tour_id); if (!$this->tour->isVisible() or !$this->route) { return $this->render_nothing(); } $this->user_visit = new HelpTourUser(array($tour_id, $GLOBALS['user']->user_id)); if ($this->user_visit->step_nr > 1 and !$_SESSION['active_tour']['step_nr'] and $this->tour->type == 'tour') { $data['last_run'] = sprintf(_('Wollen Sie die Tour "%s" an der letzten Position fortsetzen?'), $this->tour->name); $data['last_run_step'] = $this->user_visit->step_nr; $data['last_run_href'] = URLHelper::getURL($this->tour->steps[$this->user_visit->step_nr - 1]->route, NULL, true); } else { $_SESSION['active_tour'] = array('tour_id' => $tour_id, 'step_nr' => $step_nr, 'last_route' => $this->tour->steps[$step_nr - 1]->route, 'previous_route' => '', 'next_route' => ''); $this->user_visit->step_nr = $step_nr; $this->user_visit->store(); } $first_step = $step_nr; while ($first_step > 1 and $this->route == $this->tour->steps[$first_step - 2]->route) { $first_step--; } if ($first_step > 1 and $this->tour->type == 'tour') { $data['back_link'] = URLHelper::getURL($this->tour->steps[$first_step - 2]->route, NULL, true); $_SESSION['active_tour']['previous_route'] = $this->tour->steps[$first_step - 2]->route; } $data['route_step_nr'] = $first_step; $next_first_step = $first_step; while ($this->route == $this->tour->steps[$next_first_step - 1]->route) { $data['data'][] = array('step_nr' => $this->tour->steps[$next_first_step - 1]->step, 'element' => $this->tour->steps[$next_first_step - 1]->css_selector, 'title' => htmlReady($this->tour->steps[$next_first_step - 1]->title), 'tip' => formatReady($this->tour->steps[$next_first_step - 1]->tip), 'route' => $this->tour->steps[$next_first_step - 1]->route, 'action_next' => $this->tour->steps[$next_first_step - 1]->action_next, 'action_prev' => $this->tour->steps[$next_first_step - 1]->action_prev, 'interactive' => $this->tour->steps[$next_first_step - 1]->interactive ? '1' : '', 'orientation' => $this->tour->steps[$next_first_step - 1]->orientation); $next_first_step++; } if ($this->tour->steps[$step_nr - 1]->route != $this->route) { $data['redirect'] = URLHelper::getURL($this->tour->steps[$step_nr - 1]->route, NULL, true); } elseif (!count($data['data'])) { return $this->render_nothing(); } if ($next_first_step <= count($this->tour->steps)) { if ($this->tour->type == 'tour') { $data['proceed_link'] = URLHelper::getURL($this->tour->steps[$next_first_step - 1]->route, NULL, true); } $_SESSION['active_tour']['next_route'] = $this->tour->steps[$next_first_step - 1]->route; } $data['edit_mode'] = $this->help_admin; $data['step_count'] = count($this->tour->steps); $data['controls_position'] = 'BR'; $data['tour_type'] = $this->tour->type; $data['tour_title'] = htmlReady($this->tour->name); $template = $GLOBALS['template_factory']->open('tour/tour.php'); $template->set_layout(null); $data['tour_html'] = $template->render(); $this->set_content_type('application/json; charset=UTF-8'); return $this->render_text(json_encode(studip_utf8encode($data))); }
/** * fetches set of content from database for given route * * @param string $route route for help content * @param string $language language * @return array set of help content */ public static function GetContentByRoute($route = '', $language = '') { $language = $language ?: substr($GLOBALS['user']->preferred_language, 0, 2); if (!$language) { $language = 'de'; } $version = Config::get()->getValue('HELP_CONTENT_CURRENT_VERSION'); if (!$version) { return array(); } $route = get_route($route); $query = "SELECT *\n FROM help_content\n WHERE route LIKE CONCAT(?, '%') AND language = ? AND visible = 1"; $statement = DBManager::get()->prepare($query); $statement->execute(array($route, $language)); $ret = $statement->fetchGrouped(PDO::FETCH_ASSOC); foreach ($ret as $index => $data) { if (!match_route($data['route'], $route)) { unset($ret[$index]); } } return $ret; }
echo '<input type="hidden" name="del_trip" value=' . $id_trip . '>'; echo '<td><input type="submit" value="Удалить"></td>'; echo "</form>"; echo "</tr>"; } ?> </tbody> </table> </section> <section class="12u"></section> <center> <section class="6u 12u(narrower)"> <form method="post" action="trip.php" name="add"> <select name="route_id"> <? get_route($link); ?> </select> <select name="bus_id"> <? get_bus($link); ?> </select> <input type="text" name="date" placeholder="Дата" id="datepicker"> <input type="submit" name="add" value="Добавить"/> <input type="submit" name="add_month" value="Добавить на месяц"/> </form> <p>Для того, чтобы добавить поездки на месяц вперед, необходимо выбрать любой день в нужном месяце.</p> </section> </center> </div>
/** * startup * * @since 1.2.1 * @deprecated 2.0.0 * * @package Redaxscript * @category Startup * @author Henry Ruhs */ function startup() { /* ini set */ if (function_exists('ini_set')) { if (error_reporting() == 0) { ini_set('display_startup_errors', 0); ini_set('display_errors', 0); } ini_set('session.use_trans_sid', 0); ini_set('url_rewriter.tags', 0); } /* session start */ session_start(); /* define general */ define('FILE', get_file()); define('ROOT', get_root()); define('TOKEN', get_token()); /* prefix and salt */ define('PREFIX', Redaxscript\Config::get('prefix')); define('SALT', Redaxscript\Config::get('salt')); /* database connect */ database_connect(Redaxscript\Config::get('host'), Redaxscript\Config::get('name'), Redaxscript\Config::get('user'), Redaxscript\Config::get('password')); /* define session */ define('DB_CONNECTED', $_SESSION[ROOT . '/db_connected']); define('DB_ERROR', $_SESSION[ROOT . '/db_error']); define('LOGGED_IN', $_SESSION[ROOT . '/logged_in']); define('ATTACK_BLOCKED', $_SESSION[ROOT . '/attack_blocked']); /* setup charset */ if (function_exists('ini_set')) { ini_set('default_charset', s('charset')); } /* define parameter */ define('FIRST_PARAMETER', get_parameter('first')); define('FIRST_SUB_PARAMETER', get_parameter('first_sub')); define('SECOND_PARAMETER', get_parameter('second')); define('SECOND_SUB_PARAMETER', get_parameter('second_sub')); define('THIRD_PARAMETER', get_parameter('third')); define('THIRD_SUB_PARAMETER', get_parameter('third_sub')); if (LOGGED_IN == TOKEN && FIRST_PARAMETER == 'admin') { define('ADMIN_PARAMETER', get_parameter('admin')); define('TABLE_PARAMETER', get_parameter('table')); define('ID_PARAMETER', get_parameter('id')); define('ALIAS_PARAMETER', get_parameter('alias')); } else { undefine(array('ADMIN_PARAMETER', 'TABLE_PARAMETER', 'ID_PARAMETER', 'ALIAS_PARAMETER')); } define('LAST_PARAMETER', get_parameter('last')); define('LAST_SUB_PARAMETER', get_parameter('last_sub')); define('TOKEN_PARAMETER', get_parameter('token')); /* define routes */ define('FULL_ROUTE', get_route(0)); define('FULL_TOP_ROUTE', get_route(1)); if (function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) == '' || file_exists('.htaccess') == '' || FILE == 'install.php') { define('REWRITE_ROUTE', '?p='); define('LANGUAGE_ROUTE', '&l='); define('TEMPLATE_ROUTE', '&t='); } else { define('REWRITE_ROUTE', ''); define('LANGUAGE_ROUTE', '.'); define('TEMPLATE_ROUTE', '.'); } /* redirect to install */ if (DB_CONNECTED == 0 && file_exists('install.php')) { define('REFRESH_ROUTE', ROOT . '/install.php'); } /* define tables */ if (FULL_ROUTE == '' || FIRST_PARAMETER == 'admin' && SECOND_PARAMETER == '') { /* check for homepage */ if (s('homepage') > 0) { $table = 'articles'; $id = s('homepage'); } else { $table = 'categories'; $id = 0; /* check order */ if (s('order') == 'asc') { $function = 'min'; } else { if (s('order') == 'desc') { $function = 'max'; } } $rank = query_plumb('rank', $table, $function); /* if category is published */ if ($rank) { $status = retrieve('status', $table, 'rank', $rank); if ($status == 1) { $id = retrieve('id', $table, 'rank', $rank); } } } define('FIRST_TABLE', $table); define('SECOND_TABLE', ''); define('THIRD_TABLE', ''); define('LAST_TABLE', $table); } else { if (FIRST_PARAMETER) { define('FIRST_TABLE', query_table(FIRST_PARAMETER)); } else { define('FIRST_TABLE', ''); } if (FIRST_TABLE) { define('SECOND_TABLE', query_table(SECOND_PARAMETER)); } else { define('SECOND_TABLE', ''); } if (SECOND_TABLE) { define('THIRD_TABLE', query_table(THIRD_PARAMETER)); } else { define('THIRD_TABLE', ''); } if (LAST_PARAMETER) { define('LAST_TABLE', query_table(LAST_PARAMETER)); } else { define('LAST_TABLE', ''); } if (LAST_TABLE) { $id = retrieve('id', LAST_TABLE, 'alias', LAST_PARAMETER); } } /* define ids */ if (LAST_TABLE == 'categories') { define('CATEGORY', $id); define('ARTICLE', ''); define('LAST_ID', $id); } else { if (LAST_TABLE == 'articles') { define('CATEGORY', ''); define('ARTICLE', $id); define('LAST_ID', $id); } else { undefine(array('CATEGORY', 'ARTICLE', 'LAST_ID')); } } /* define content error */ $aliasValidator = new Redaxscript\Validator\Alias(); if (LAST_ID == '' && $aliasValidator->validate(FIRST_PARAMETER, Redaxscript\Validator\Alias::MODE_DEFAULT) == Redaxscript\Validator\Validator::FAILED) { define('CONTENT_ERROR', 1); } else { define('CONTENT_ERROR', 0); } /* define user */ define('MY_IP', get_user_ip()); define('MY_BROWSER', get_user_agent(0)); define('MY_BROWSER_VERSION', get_user_agent(1)); define('MY_ENGINE', get_user_agent(2)); define('MY_MOBILE', get_user_agent(4)); define('MY_TABLET', get_user_agent(5)); /* if mobile or tablet */ if (MY_MOBILE || MY_TABLET) { define('MY_DESKTOP', ''); } else { define('MY_DESKTOP', get_user_agent(3)); } /* if logged in */ if (LOGGED_IN == TOKEN) { define('MY_ID', $_SESSION[ROOT . '/my_id']); define('MY_NAME', $_SESSION[ROOT . '/my_name']); define('MY_USER', $_SESSION[ROOT . '/my_user']); define('MY_EMAIL', $_SESSION[ROOT . '/my_email']); define('MY_GROUPS', $_SESSION[ROOT . '/my_groups']); /* define access */ $access_array = array('categories', 'articles', 'extras', 'comments', 'groups', 'users'); foreach ($access_array as $value) { define(strtoupper($value) . '_NEW', $_SESSION[ROOT . '/' . $value . '_new']); define(strtoupper($value) . '_EDIT', $_SESSION[ROOT . '/' . $value . '_edit']); define(strtoupper($value) . '_DELETE', $_SESSION[ROOT . '/' . $value . '_delete']); if (TABLE_PARAMETER == 'users' && ID_PARAMETER == MY_ID && $value == 'users') { define('USERS_EXCEPTION', 1); } else { if ($value == 'users') { define('USERS_EXCEPTION', 0); } } } define('MODULES_INSTALL', $_SESSION[ROOT . '/modules_install']); define('MODULES_EDIT', $_SESSION[ROOT . '/modules_edit']); define('MODULES_UNINSTALL', $_SESSION[ROOT . '/modules_uninstall']); define('SETTINGS_EDIT', $_SESSION[ROOT . '/settings_edit']); define('FILTER', $_SESSION[ROOT . '/filter']); } else { define('FILTER', 1); } /* define table access */ define('TABLE_NEW', constant(strtoupper(TABLE_PARAMETER) . '_NEW')); define('TABLE_INSTALL', constant(strtoupper(TABLE_PARAMETER) . '_INSTALL')); define('TABLE_EDIT', constant(strtoupper(TABLE_PARAMETER) . '_EDIT')); define('TABLE_DELETE', constant(strtoupper(TABLE_PARAMETER) . '_DELETE')); define('TABLE_UNINSTALL', constant(strtoupper(TABLE_PARAMETER) . '_UNINSTALL')); /* define time */ define('GMDATE', gmdate('D, d M Y H:i:s') . ' GMT'); define('GMDATE_PLUS_WEEK', gmdate('D, d M Y H:i:s', strtotime('+1 week')) . ' GMT'); define('GMDATE_PLUS_YEAR', gmdate('D, d M Y H:i:s', strtotime('+1 year')) . ' GMT'); define('NOW', date('Y-m-d H:i:s')); define('DELAY', date('Y-m-d H:i:s', strtotime('+1 minute'))); define('TODAY', date('Y-m-d')); /* future update */ define('UPDATE', $_SESSION[ROOT . '/update']); if (UPDATE == '') { future_update('articles'); future_update('extras'); $_SESSION[ROOT . '/update'] = DELAY; } else { if (UPDATE < NOW) { $_SESSION[ROOT . '/update'] = ''; } } }
public function destroy($id) { $this->model->findOrFail($id)->delete(); return redirect(route(get_route($this->model, 'index')))->with('success', 'Item deleted'); }
/** * compares actual route to requested route * * @param string $requested_route requested route (for help content or tour) * @param string $current_route current route (optional) * * @return boolean result */ function match_route($requested_route, $current_route = '') { if (!$current_route) { $current_route = get_route(); } $route_parts = explode('?', $requested_route); // if base routes don't match, return false without further checks if ($route_parts[0] != $current_route) { return false; } // if no parameters given and base routes do match, return true if (!$route_parts[1]) { return true; } // extract vars and check if they are set accordingly $vars = array(); parse_str($route_parts[1], $vars); if (!count($vars)) { return false; } foreach ($vars as $name => $value) { if (@$_REQUEST[$name] != $value) { return false; } } return true; }
<?php define('SQL_INC', 1); define('CURR_MENU', 'users_accounts'); define('CURR_SUBMENU', 'users'); require 'inc/common.inc.php'; check_permissions(CURR_SUBMENU, 1); $accounts = get_users_accounts(); $tariffs = get_tariffs(); $route = get_route(); $id_user = intval($_POST['id_user']) ? intval($_POST['id_user']) : intval($_GET['id_user']); if ($_POST['search']) { $search_text = preg_match('/^[a-zA-Z0-9а-яА-Я_\\*\\?]+$/u', $_POST['search_text']) ? $_POST['search_text'] : ''; $search_text = str_replace(array("*", "?"), array("%", "_"), $search_text); } if ($_POST['modify'] || $_GET['id_user']) { check_permissions(CURR_MENU, 2); if (!$_POST['confirm'] && $id_user) { $db->sql_query("select login, pass, id_account, id_tariff, inet_ntoa(addr) as \"addr\", p_in, p_out, inet_ntoa(eth_ip) as \"eth_ip\", eth_mac, nat, route as \"id_route\" from users where users.id='{$id_user}'"); $result = $db->sql_fetchrow(); } $user_login = $_POST['confirm'] ? $_POST['user_login'] : $result['login']; $id_account = $_POST['id_account'] ? intval($_POST['id_account']) : $result['id_account']; $id_tariff = $_POST['id_tariff'] ? intval($_POST['id_tariff']) : $result['id_tariff']; $p_in = $_POST['confirm'] ? intval($_POST['p_in']) * 1024 * 1024 : $result['p_in']; $p_out = $_POST['confirm'] ? $_POST['p_out'] * 1024 * 1024 : $result['p_out']; $password1 = $_POST['confirm'] ? $_POST['password1'] : $result['pass']; $password2 = $_POST['confirm'] ? $_POST['password2'] : $result['pass']; $addr = $_POST['confirm'] ? $_POST['addr'] : $result['addr']; $eth_ip = $_POST['confirm'] ? addslashes($_POST['eth_ip']) : $result['eth_ip']; $eth_mac = $_POST['confirm'] ? addslashes($_POST['eth_mac']) : $result['eth_mac'];
/ /* *************************************************/ require_once "includes.php"; $database = init_database(); $param = null; if (isset($_GET['type'])) { $type = $_GET['type']; } // Check for the path elements $path = $_SERVER[PATH_INFO]; if ($path != null) { $path_params = spliti("/", $path); } if ($_SERVER['REQUEST_METHOD'] == 'GET') { // GET Request set_headers($type); if ($path_params[1] != null) { render_result(get_route($path_params[1]), "route", $type); // Ressourcendarstellung } else { render_result(get_routen(), "routen", $type); // Listenressource } } /* not used if ($_SERVER['REQUEST_METHOD'] == 'POST') { // POST Request $input = file_get_contents("php://input"); render_result(create_route($input),null,$type); // create track entry and copy file } */ mysql_close($database);
/** * fetches set of tours from database for given route * * @param string $route route for tours to begin * @param boolean $as_objects include HelpTour objects in result array * @return array set of tours */ public static function GetToursByRoute($route = '') { if (!$route) { $route = get_route(); } $query = "SELECT tour_id AS idx, help_tours.*\n FROM help_tour_steps\n INNER JOIN help_tours USING (tour_id)\n WHERE route = ? AND step = 1\n ORDER BY name ASC"; $statement = DBManager::get()->prepare($query); $statement->execute(array($route)); $ret = $statement->fetchGrouped(PDO::FETCH_ASSOC); return HelpTour::GetTourObjects($ret); }