function admin_header($title, $parent_file = false) { $self = preg_replace('|^.*/admin/|i', '', $_SERVER['PHP_SELF']); $self = preg_replace('|^.*/plugins/|i', '', $self); header('Content-Type: text/html; charset=utf-8'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title; ?> — <?php echo get_option('sitename'); ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="<?php echo get_option('baseurl'); ?> admin/resources/jquery-ui.css" media="screen"/> <link rel="stylesheet" type="text/css" href="<?php echo get_option('baseurl'); ?> admin/resources/core.css" media="screen"/> <link rel="stylesheet" type="text/css" href="<?php echo get_option('baseurl'); ?> admin/resources/full.css" media="screen"/> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/jquery.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/json2.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/jquery.ui.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/jquery.scrollTo.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/humanmsg.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> admin/admin.js"></script> </head> <body id="admin-<?php echo $self; ?> " class="admin-page"> <div id="header"> <p id="sitetitle"><a href="<?php echo get_option('baseurl'); ?> "><?php echo get_option('sitename'); ?> </a></p> <ul id="navigation"> <?php $navigation = array(array(_r('Dashboard'), 'index.php', ''), array(_r('Feeds'), 'feeds.php', 'feeds'), array(_r('Settings'), 'settings.php', 'settings')); $navigation = apply_filters('navigation', $navigation); $subnavigation = apply_filters('subnavigation', array('index.php' => array(array(_r('Home'), 'index.php', 'home')), 'feeds.php' => array(array(_r('Add/Manage'), 'feeds.php', 'feeds'), array(_r('Import'), 'feed-import.php', 'feeds')), 'settings.php' => array(array(_r('General'), 'settings.php', 'settings'))), $navigation, $self); foreach ($navigation as $nav_item) { $class = 'item'; if (strcmp($self, $nav_item[1]) == 0 || $parent_file && $nav_item[1] == $parent_file) { $class .= ' current'; } if (isset($subnavigation[$nav_item[1]]) && count($subnavigation[$nav_item[1]]) > 1) { $class .= ' has-submenu'; } echo "<li class='{$class}'><a href='{$nav_item[1]}'>{$nav_item[0]}</a>"; if (!isset($subnavigation[$nav_item[1]]) || count($subnavigation[$nav_item[1]]) < 2) { echo "</li>"; continue; } echo '<ul class="submenu">'; foreach ($subnavigation[$nav_item[1]] as $subnav_item) { echo '<li' . (strcmp($self, $subnav_item[1]) == 0 ? ' class="current"' : '') . "><a href='{$subnav_item[1]}'>{$subnav_item[0]}</a></li>"; } echo '</ul></li>'; } ?> <li id="page_item_logout" class="seperator"><a href="admin.php?logout=logout" title="<?php _e('Log out of your current session'); ?> "><?php _e('Log out'); ?> </a></li> </ul> </div> <div id="main"> <?php if ($result = implode('</p><p>', MessageHandler::get())) { echo '<div id="alert" class="fade"><p>' . $result . '</p></div>'; } do_action('admin_header'); do_action("admin_header-{$self}"); do_action('send_headers'); }
/** * Common administration helpers * * @author Ryan McCue <*****@*****.**> * @package Lilina * @version 1.0 * @license http://opensource.org/licenses/gpl-license.php GNU Public License */ function admin_header($title, $parent_file = false) { $self = preg_replace('|^.*/admin/|i', '', $_SERVER['PHP_SELF']); $self = preg_replace('|^.*/plugins/|i', '', $self); header('Content-Type: text/html; charset=utf-8'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title; ?> — <?php echo get_option('sitename'); ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="<?php echo get_option('baseurl'); ?> admin/resources/jquery-ui.css" media="screen"/> <link rel="stylesheet" type="text/css" href="<?php echo get_option('baseurl'); ?> admin/resources/core.css" media="screen"/> <link rel="stylesheet" type="text/css" href="<?php echo get_option('baseurl'); ?> admin/resources/full.css" media="screen"/> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/jquery.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/json2.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/jquery.ui.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> inc/js/jquery.scrollTo.js"></script> <script type="text/javascript" src="<?php echo get_option('baseurl'); ?> admin/admin.js"></script> <script type="text/javascript"> admin.localisations = { "No feed URL supplied": "<?php _e('No feed URL supplied'); ?> ", "No feed ID supplied": "<?php _e('No feed ID supplied'); ?> ", "Failed to parse response: ": "<?php _e('Failed to parse response: '); ?> ", "Are You Sure?": "<?php _e('Are You Sure?'); ?> ", "Whoops!": "<?php _e('Whoops!'); ?> ", "OK": "<?php _e('OK'); ?> ", "Cancel": "<?php _e('Cancel'); ?> ", "Something Went Wrong!": "<?php _e('Something Went Wrong!'); ?> ", "Error message:": "<?php _e('Error message:'); ?> ", 'If you think you shouldn\'t have received this error then <a href="http://code.google.com/p/lilina/issues">report a bug</a> quoting that message and how it happened.': '<?php echo str_replace("'", '\\\'', _r('If you think you shouldn\'t have received this error then <a href="http://code.google.com/p/lilina/issues">report a bug</a> quoting that message and how it happened.')); ?> ', "Double-click to edit": "<?php _e('Double-click to edit'); ?> ", "Delete": "<?php _e('Delete'); ?> ", "Show advanced options": "<?php _e('Show advanced options'); ?> " }; </script> </head> <body id="admin-<?php echo basename($self, '.php'); ?> " class="admin-page"> <div id="header"> <p id="sitetitle"><a href="<?php echo get_option('baseurl'); ?> "><?php echo get_option('sitename'); ?> </a></p> <ul id="navigation"> <?php $navigation = array(array(_r('Dashboard'), 'index.php', ''), array(_r('Feeds'), 'feeds.php', 'feeds'), array(_r('Settings'), 'settings.php', 'settings')); $navigation = apply_filters('navigation', $navigation); $subnavigation = apply_filters('subnavigation', array('index.php' => array(array(_r('Home'), 'index.php', 'home')), 'feeds.php' => array(array(_r('Add/Manage'), 'feeds.php', 'feeds'), array(_r('Import'), 'feed-import.php', 'feeds')), 'settings.php' => array(array(_r('General'), 'settings.php', 'settings'))), $navigation, $self); foreach ($navigation as $nav_item) { $class = 'item'; if (strcmp($self, $nav_item[1]) == 0 || $parent_file && $nav_item[1] == $parent_file) { $class .= ' current'; } if (isset($subnavigation[$nav_item[1]]) && count($subnavigation[$nav_item[1]]) > 1) { $class .= ' has-submenu'; } echo "<li class='{$class}'><a href='{$nav_item[1]}'>{$nav_item[0]}</a>"; if (!isset($subnavigation[$nav_item[1]]) || count($subnavigation[$nav_item[1]]) < 2) { echo "</li>"; continue; } echo '<ul class="submenu">'; foreach ($subnavigation[$nav_item[1]] as $subnav_item) { echo '<li' . (strcmp($self, $subnav_item[1]) == 0 ? ' class="current"' : '') . "><a href='{$subnav_item[1]}'>{$subnav_item[0]}</a></li>"; } echo '</ul></li>'; } ?> </ul> <ul id="utilities"> <li><a href="page_item_logout"><a href="login.php?logout" title="<?php _e('Log out of your current session'); ?> "><?php _e('Sign out'); ?> </a></a></li> <?php do_action('admin_utilities_items'); ?> </ul> </div> <div id="main"> <?php if ($result = implode('</p><p>', MessageHandler::get())) { echo '<div id="alert" class="fade"><p>' . $result . '</p></div>'; } do_action('admin_header'); do_action("admin_header-{$self}"); do_action('send_headers'); }
/** * 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'); }