$_GET['db'] = moadminModel::$dbName; } else { if (strpos($_GET['db'], '.') !== false) { $_GET['db'] = $_GET['newdb']; } } try { moadminComponent::$model = new moadminModel($_GET['db']); } catch (Exception $e) { echo $e; exit(0); } $html = get::helper('html'); $ver = explode('.', phpversion()); get::$isPhp523orNewer = $ver[0] >= 5 && ($ver[1] > 2 || $ver[1] == 2 && $ver[2] >= 3); $form = new formHelper(); $mo = new moadminComponent(); if (isset($_GET['export']) && isset($mo->mongo['listRows'])) { $rows = array(); foreach ($mo->mongo['listRows'] as $row) { $rows[] = serialize($row); } $filename = get::htmlentities($_GET['db']); if (isset($_GET['collection'])) { $filename .= '~' . get::htmlentities($_GET['collection']); } $filename .= '.json'; get::helper('json')->echoJson($rows, $filename); exit(0); } /**
/** * Starts the application. * * @return void */ public static function run() { self::$starttime = microtime(true); error_reporting(config::ERROR_LEVEL); if (isset(config::$session_cookie_domain)) { ini_set('session.cookie_domain', config::$session_cookie_domain); } if (class_exists('formHelper')) { formHelper::fixArrays(); } if (class_exists('csrfHelper')) { injector::register(array('csrfHelper', 'injector')); } if (is::ssl() && isset(config::$https_domain) && !isset(config::$http_domain)) { if (is::existset($_GET, 'r_domain')) { config::$http_domain = get::fulldomain($_GET['r_domain']); } else { config::$http_domain = get::fulldomain('www'); } } session_start(); if (config::$isolated_subdomains) { // find the domain $domain = isset(config::$http_domain) ? config::$http_domain : get::fulldomain(); // kill any subdomain sessions that have been transfered to another subdomain $existing = array_keys($_SESSION); foreach ($existing as $d) { if (!is_array($_SESSION[$d])) { continue; } if (array_key_exists('kill_munla_session', $_SESSION[$d]) && $_SESSION[$d]['kill_munla_session']) { unset($_SESSION[$d]); } } // initialize and setup the session for this subdomain if (!array_key_exists($domain, $_SESSION)) { $_SESSION[$domain] = array(); } munla::$session =& $_SESSION[$domain]; } else { munla::$session =& $_SESSION; } if (class_exists('singleUseArray')) { if (!is::existset(munla::$session, 'MUNLA_SINGLE_USE')) { munla::$singleUse = new singleUseArray(); } else { munla::$singleUse = unserialize(munla::$session['MUNLA_SINGLE_USE']); } } $route = get::route(); if (is_array($route) && $route['controller'] == 'csrf' && $route['action'] == 'keepalive' && class_exists('csrfHelper') && is::existset($route, 'params') && count($route['params']) > 0) { if (isset($_POST['token'])) { echo csrfHelper::keepAlive($route['params'][0], $_POST['token']); } exit; } if (class_exists('user') && is_subclass_of('user', 'userBase')) { if (!is::existset(munla::$session, 'MUNLA_USER')) { munla::$session['MUNLA_USER'] = new userWrapper(new user()); } } injector::start(); if (class_exists('app') && is_callable(array('app', 'setup'))) { app::setup(); } if (!isset(munla::$user) && is::existset(munla::$session, 'MUNLA_USER')) { munla::$user =& munla::$session['MUNLA_USER']; } if (!is::ajax()) { $submittedForm = formHelper::process(); if (isset($submittedForm)) { formHelper::process($submittedForm); } } if (class_exists('app') && is_callable(array('app', 'start'))) { $route = app::start($route); } if ($route === null) { $route = array('controller' => 'index', 'action' => 'index', 'params' => null); } $controller = get::controller($route['controller']); if (!isset($controller) && $route['controller'] != 'index') { //push action to params, controller to action, and set controller to index and try again. if ($route['action'] != 'index') { if (!isset($route['params'])) { $route['params'] = array(); } array_unshift($route['params'], $route['action']); } $route['action'] = $route['controller']; $route['controller'] = 'index'; $controller = get::controller('index'); } $view = null; if (isset($controller)) { $action = $controller->getAction(array($route['action'], $route['params'])); if (isset($action)) { try { $viewParams = call_user_func_array(array($controller, $action['action']), $action['params']); //various things could happen here... if (!isset($viewParams)) { $viewParams = array(); } elseif (!is_array($viewParams)) { $viewParams = array($viewParams); } $view = get::view($route, $controller, $viewParams); } catch (SSLException $e) { go::ssl(!is::ssl()); } catch (PermissionException $e) { munla::$nohistory = true; if (isset(munla::$user) && !munla::$user->is_logged_in() && munla::$user->getLoginView()) { $view = munla::$user->getLoginView(); } else { $view = get::view('errors/generic', 'default', array('error_msg' => $e->getMessage())); } } catch (Exception $e) { munla::$nohistory = true; $view = get::view('errors/generic', 'default', array('error_msg' => $e->getMessage())); } } else { $view = get::view($route, $controller); } } else { $view = get::view($route); } if ($view != null) { $view->render(); } else { throw new Exception('View not found!'); } if (class_exists('app', false)) { munla::$nohistory = app::finish(munla::$nohistory); } if (munla::$nohistory === false) { munla::$session['lastpage'] = get::url(); } if (isset(munla::$singleUse)) { munla::$session['MUNLA_SINGLE_USE'] = serialize(munla::$singleUse); } }
} if (!isset($_GET['db'])) { $_GET['db'] = 'admin'; } else { if (strpos($_GET['db'], '.') !== false) { $_GET['db'] = $_GET['newdb']; } } try { moadminComponent::$model = new moadminModel($_GET['db']); } catch (Exception $e) { echo $e; exit(0); } $html = get::helper('html'); $form = new formHelper(); $mo = new moadminComponent(); /** * phpMoAdmin front-end view-element */ $headerArgs['title'] = isset($_GET['action']) ? 'phpMoAdmin - ' . get::htmlentities($_GET['action']) : 'phpMoAdmin'; if (THEME != 'classic') { $headerArgs['jqueryTheme'] = in_array(THEME, array('swanky-purse', 'trontastic')) ? THEME : 'trontastic'; } $headerArgs['cssInline'] = ' /* reset */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent;} input, textarea {margin: 0; padding: 0;}
/** * Safely fixes automatic character escaping in the given array ONCE. * * @return void */ public static function fixArrays() { if (self::$postGetFixed) { return; } if (count($_POST) > 0) { self::doFixArray($_POST); } if (count($_GET) > 0) { self::doFixArray($_GET); } self::$postGetFixed = true; }