/** * Dispatches the current URL and executes an assigned callback */ public static function dispatch() { $method = 'default'; if (isset($_REQUEST['method'])) { $method = preg_replace('/[^-_.0-9a-zA-Z]/', '', $_REQUEST['method']); } $method = apply_filters('controller-method', $method); define('LILINA_PAGE', $method); try { if (!$method || empty(Controller::$methods[$method])) { // Dynamically load method if possible if (file_exists(LILINA_INCPATH . '/core/method-' . $method . '.php')) { require_once LILINA_INCPATH . '/core/method-' . $method . '.php'; } } // Check again, in case we loaded it last time if (!$method || empty(Controller::$methods[$method])) { // No or invalid method throw new Exception(sprintf(_r('Unknown method: %s'), $method)); } $callback = Controller::$methods[$method]; call_user_func($callback); } catch (Exception $e) { lilina_nice_die('<p>' . sprintf(_r('An error occured dispatching a method: %s'), $e->getMessage()) . '</p>'); } }
/** * Dispatches the current URL and executes an assigned callback */ public function dispatch() { $method = 'default'; if (isset($_GET['method'])) { $method = preg_replace('/[^-_.0-9a-zA-Z]/', '', $_GET['method']); } try { if (!$method || empty($this->methods[$method])) { // No or invalid method throw new Exception('Unknown method: ' . $method); } $callback = $this->methods[$method]; $output = call_user_func($callback); } catch (Exception $e) { lilina_nice_die('<p>An error occured dispatching a method: ' . $e->getMessage() . '</p>'); } }
if (!validate_plugin($plugin_file)) { return false; } unset($current_plugins[md5($plugin_file)]); $data = new DataHandler(); $data->save('plugins.data', serialize($current_plugins)); return true; } if (isset($_REQUEST['activate_plugin'])) { activate_plugin($_REQUEST['activate_plugin']); } elseif (isset($_REQUEST['deactivate_plugin'])) { deactivate_plugin($_REQUEST['deactivate_plugin']); } if (!empty($_POST['action']) && $_POST['action'] == 'settings' && !empty($_POST['_nonce'])) { if (!check_nonce($_POST['_nonce'])) { lilina_nice_die('Nonces do not match.'); } clear_html_cache(); /** Needs better validation */ if (!empty($_POST['sitename'])) { update_option('sitename', $_REQUEST['sitename']); } if (!empty($_POST['template'])) { update_option('template', $_REQUEST['template']); } if (!empty($_POST['locale'])) { update_option('locale', $_REQUEST['locale']); } if (!empty($_POST['timezone'])) { update_option('timezone', $_REQUEST['timezone']); }
/** * Check that the system can run Lilina * * Checks Lilina's requirements against what the server actually has and * complains if something goes wrong. * * @author SimplePie * @return bool True if Lilina can run on this system without warnings, otherwise it does not return */ public function compatibility_test() { $errors = array(); $warnings = array(); $output = "<p>The following errors were found with your installation:</p>"; $xml_ok = extension_loaded('xml'); $pcre_ok = extension_loaded('pcre'); $zlib_ok = extension_loaded('zlib'); $mbstring_ok = extension_loaded('mbstring'); $iconv_ok = extension_loaded('iconv'); if ($xml_ok && $pcre_ok && $mbstring_ok && $iconv_ok && $zlib_ok) { return; } if (!$xml_ok) { $errors[] = "<strong>XML:</strong> Your PHP installation doesn't support XML parsing."; } if (!$pcre_ok) { $errors[] = "<strong>PCRE:</strong> Your PHP installation doesn't support Perl-Compatible Regular Expressions."; } if (!$iconv_ok && !$mbstring_ok) { $errors[] = "<strong>mbstring and iconv</strong>: You do not have either of these extensions installed. Lilina requires at least one of these in order to function properly."; } elseif (!$iconv_ok) { $warnings[] = "<strong>iconv:</strong> <code>mbstring</code> is installed, but <code>iconv</code> is not. This means that not all character encodings or translations will be supported."; } elseif (!$mbstring_ok) { $warnings[] = "<strong>mbstring:</strong> <code>iconv</code> is installed, but <code>mbstring</code> is not. This means that not all character encodings or translations will be supported."; } if (!$zlib_ok) { $warnings[] = "<strong>Zlib:</strong> The <code>Zlib</code> extension is not available. You will not be able to use feeds with GZIP compression."; } if (!empty($errors)) { $output .= "\n<h2>Errors</h2>\n<ul>\n<li>"; $output .= implode(" <em>Looks like Lilina won't run.</em></li>\n<li>", $errors); $output .= "</li>\n</ul>\n"; } if (!empty($warnings)) { $output .= "\n<h2>Warnings</h2>\n<ul>\n<li>"; $output .= implode(" <em>This might cause some problems with some feeds.</em></li>\n<li>", $warnings); $output .= "</li>\n</ul>\n"; } if (empty($errors)) { $output .= "<p>These warnings might cause some feeds not to be read properly, however <em>you will be able to run Lilina.</em></p>\n"; $output .= '<form action="install.php" method="post">'; $output .= '<input type="hidden" name="page" value="1" /><input type="hidden" name="skip" value="1" />'; $output .= '<input class="submit" type="submit" value="Continue" /></form>'; $output .= "<p id='footnote-quote'>Danger, Will Robinson! — <em>Lost in Space</em></p>"; lilina_nice_die($output, 'Whoops!'); } else { $output .= '<p>These errors mean that <em>you will not be able to run Lilina.</em></p>'; $output .= "<p id='footnote-quote'>Kosa moja haliachi mke — <em>Swahili proverb ('One mistake isn't reason enough to leave your wife')</em></p>"; lilina_nice_die($output, 'Uh oh!'); } }
/** * upgrade() - Run upgrade processes on supplied data * * {{@internal Missing Long Description}}} */ function upgrade() { global $lilina; //require_once(LILINA_INCPATH . '/core/plugin-functions.php'); require_once LILINA_INCPATH . '/core/feed-functions.php'; require_once LILINA_INCPATH . '/core/version.php'; require_once LILINA_INCPATH . '/core/misc-functions.php'; /** Rename possible old files */ if (@file_exists(LILINA_PATH . '/.myfeeds.data')) { rename(LILINA_PATH . '/.myfeeds.data', LILINA_PATH . '/content/system/config/feeds.data'); } elseif (@file_exists(LILINA_PATH . '/conf/.myfeeds.data')) { rename(LILINA_PATH . '/conf/.myfeeds.data', LILINA_PATH . '/content/system/config/feeds.data'); } elseif (@file_exists(LILINA_PATH . '/conf/.feeds.data')) { rename(LILINA_PATH . '/conf/.feeds.data', LILINA_PATH . '/content/system/config/feeds.data'); } elseif (@file_exists(LILINA_PATH . '/conf/feeds.data')) { rename(LILINA_PATH . '/conf/feeds.data', LILINA_PATH . '/content/system/config/feeds.data'); } if (@file_exists(LILINA_PATH . '/conf/settings.php')) { rename(LILINA_PATH . '/conf/settings.php', LILINA_PATH . '/content/system/config/settings.php'); } require_once LILINA_PATH . '/inc/core/conf.php'; /* if(@file_exists(LILINA_PATH . '/content/system/config/feeds.data')) { $feeds = file_get_contents(LILINA_PATH . '/content/system/config/feeds.data'); $feeds = unserialize( base64_decode($feeds) ); /** Are we pre-versioned? * / if(!isset($feeds['version'])){ /** Is this 0.7? * / if(!is_array($feeds['feeds'][0])) { /** 1 dimensional array, each value is a feed URL string * / foreach($feeds['feeds'] as $new_feed) { Feeds::get_instance()->add($new_feed); } } /** We must be in between 0.7 and r147, when we started versioning * / elseif(!isset($feeds['feeds'][0]['url'])) { foreach($feeds['feeds'] as $new_feed) { Feeds::get_instance()->add($new_feed['feed'], $new_feed['name']); } } /** The feeds are up to date, but we don't have a version * / else { } } elseif($feeds['version'] != $lilina['feed-storage']['version']) { /** Note the lack of breaks here, this means the cases cascade * / switch(true) { case $feeds['version'] < 147: /** We had a b0rked upgrader, so we need to make sure everything is okay * / foreach($feeds['feeds'] as $this_feed) { } case $feeds['version'] < 237: /** We moved stuff around this version, but we've handled that above. * / } } else { } global $data; $data = $feeds; $data['version'] = $lilina['feed-storage']['version']; save_feeds(); } //end file_exists() */ /** Just in case... */ unset($BASEURL); require LILINA_PATH . '/content/system/config/settings.php'; if (isset($BASEURL) && !empty($BASEURL)) { // 0.7 or below $raw_php = "<?php\n// What you want to call your Lilina installation\n\$settings['sitename'] = '{$SITETITLE}';\n\n// The URL to your server\n\$settings['baseurl'] = '{$BASEURL}';\n\n// Username and password to log into the administration panel\n// 'pass' is MD5ed\n\$settings['auth'] = array(\n\t\t\t\t\t\t\t'user' => '{$USERNAME}',\n\t\t\t\t\t\t\t'pass' => '" . md5($PASSWORD) . "'\n\t\t\t\t\t\t\t);\n\n// All the enabled plugins, stored in a serialized string\n\$settings['enabled_plugins'] = '';\n\n// Version of these settings; don't change this\n\$settings['settings_version'] = " . $lilina['settings-storage']['version'] . ";\n?>"; if (!($settings_file = @fopen(LILINA_PATH . '/content/system/config/settings.php', 'w+')) || !is_resource($settings_file)) { lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/settings.php failed</p>', 'Upgrade failed'); } fputs($settings_file, $raw_php); fclose($settings_file); } elseif (!isset($settings['settings_version'])) { // Between 0.7 and r147 // Fine to just use existing settings $raw_php = file_get_contents(LILINA_PATH . '/content/system/config/settings.php'); $raw_php = str_replace('?>', "// Version of these settings; don't change this\n" . "\$settings['settings_version'] = " . $lilina['settings-storage']['version'] . ";\n?>", $raw_php); if (!($settings_file = @fopen(LILINA_PATH . '/conf/settings.php', 'w+')) || !is_resource($settings_file)) { lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/settings.php failed</p>', 'Upgrade failed'); } fputs($settings_file, $raw_php); fclose($settings_file); } elseif ($settings['settings_version'] != $lilina['settings-storage']['version']) { /** Note the lack of breaks here, this means the cases cascade */ switch (true) { case $settings['settings_version'] < 237: /** We moved stuff around this version, but we've handled that above. */ /** We moved stuff around this version, but we've handled that above. */ case $settings['settings_version'] < 297: new_options_297(); case $settings['settings_version'] < 302: new_options_302(); case $settings['settings_version'] < 339: new_options_339(); case $settings['settings_version'] < 368: new_options_368(); case $settings['settings_version'] < 480: new_options_368(); } $raw_php = file_get_contents(LILINA_PATH . '/content/system/config/settings.php'); $raw_php = str_replace("\$settings['settings_version'] = " . $settings['settings_version'] . ";", "\$settings['settings_version'] = " . $lilina['settings-storage']['version'] . ";", $raw_php); if (!($settings_file = @fopen(LILINA_PATH . '/content/system/config/settings.php', 'w+')) || !is_resource($settings_file)) { lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/settings.php failed</p>', 'Upgrade failed'); } fputs($settings_file, $raw_php); fclose($settings_file); require_once LILINA_INCPATH . '/core/class-datahandler.php'; if (!save_options()) { lilina_nice_die('<p>Failed to upgrade settings: Saving content/system/config/options.data failed</p>', 'Upgrade failed'); } } $string = ''; if (count(MessageHandler::get()) === 0) { lilina_nice_die('<p>Your installation has been upgraded successfully. Now, <a href="index.php">get back to reading!</a></p>', 'Upgrade Successful'); return; } else { $string .= '<p>Your installation has <strong>not</strong> been upgraded successfully. Here\'s the error:</p><ul><li>'; } lilina_nice_die($string . implode('</li><li>', MessageHandler::get()) . '</li></ul>', 'Upgrade failed'); }
global $page; $body = ''; if (defined('LILINA_AUTH_ERROR') && LILINA_AUTH_ERROR === -1) { $body = '<p class="alert">' . _r('Your password or username is incorrect. Please make sure you have spelt it correctly.') . '</p>'; } $body .= ' <form action="login.php" method="post"> <fieldset id="login"> <div class="row"> <label for="user">' . _r('Username') . ':</label> <input type="text" name="user" id="user" class="input" /> </div> <div class="row"> <label for="pass">' . _r('Password') . ':</label> <input type="password" name="pass" id="pass" class="input" /> </div> </fieldset> <input type="hidden" name="page" value="' . (isset($page) ? $page : '') . '" /> <input type="submit" value="' . _r('Login') . '" class="submit" /> </form> <script type="text/javascript" src="' . get_option('baseurl') . 'inc/js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function() { setTimeout("hideAlert()", 700); }); function hideAlert() { $(".alert").fadeOut(2000); } </script>'; lilina_nice_die($body, _r('Login'), 'login');