function bBlog(&$aSmartyObj) { if (is_object($aSmartyObj)) { $this->smartyObj =& $aSmartyObj; } else { $this->smartyObj = new Smarty(); } //set cache directory $this->smartyObj->cache_dir = BBLOGROOT . 'cache'; // set cache lifetime to 1 hour $this->smartyObj->cache_lifetime = 3600; // connect to database $this->db = new db(DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_HOST); $this->num_rows =& $this->db->num_rows; $this->insert_id =& $this->db->insert_id; $this->rows_affected =& $this->db->rows_affected; // auth image $this->authimage = new authimage(); //Load configuration variables bBlogConfig::loadConfiguration($this->db); $this->smartyObj->assign('blogname', C_BLOGNAME); $this->smartyObj->assign('blogdescription', C_BLOG_DESCRIPTION); $this->smartyObj->assign('blogurl', BLOGURL); $this->smartyObj->assign('bblogurl', BBLOGURL); $this->smartyObj->assign('metakeywords', C_META_KEYWORDS); $this->smartyObj->assign('metadescription', C_META_DESCRIPTION); // initial time from config table, based on last updated stuff. // this is just the initial value. $this->lastmodified = C_LAST_MODIFIED; $this->smartyObj->register_postfilter("update_when_compiled"); // load up the sections $this->get_sections(); //register the dynamic block handler for dynamic template sections //can't be loaded from a normal function. file because there's no way to //specify non-cacheable functions currently $this->smartyObj->register_block('dynamic', 'smarty_block_dynamic', false); //start the session that we need so much ;) if (!session_id()) { session_start(); } }
/** * Retrieve configuration from database in form suitable for display in the admin form * * Returned data format: * index : pair * left = Label displayed on form * right = HTML Input tag already prepared for display * @param object $db Instance of ezSQL, passed by reference * @return array Indexed array of pairs */ function showConfigForm(&$db) { $rows = array(); $rs = $db->get_results('SELECT name, value, label, type, possible FROM `' . T_CONFIG . '` ORDER BY id ASC'); if (!is_null($rs)) { foreach ($rs as $c) { if ($c->type !== '') { $label = htmlspecialchars($c->label); $func = 'input' . ucfirst($c->type); if ($c->type === 'text') { $field = bBlogConfig::inputText($c->name, $c->value); } else { if ($c->type === 'select') { $values = bBlogConfig::getPossibleValues($c->possible, &$db); $field = bBlogConfig::inputSelect($c->name, $values, $c->value); } } $rows[] = array("left" => $label, "right" => $field); } } } return $rows; }
<?php /** * builtin.options.php - the option panel, allows you to change options * * @package bBlog * @author Eaden McKee - <*****@*****.**> - last modified by $LastChangedBy: $ * @version $Id: $ * @copyright The bBlog Project, http://www.bblog.com/ * @license http://www.gnu.org/licenses/gpl.html GNU General Public License */ function identify_admin_options() { return array('name' => 'options', 'type' => 'builtin', 'nicename' => 'Options', 'description' => 'Allows you to change options', 'authors' => 'Eaden McKee', 'licence' => 'GPL', 'help' => ''); } if (isset($_POST['submit']) && $_POST['submit'] == 'Save Options') { // saving options.. bBlogConfig::saveConfiguration($bBlog->db); $bBlog->smartyObj->assign("showmessage", TRUE); $bBlog->smartyObj->assign("showoptions", 'no'); $bBlog->smartyObj->assign("message_title", "Options Updated"); $bBlog->smartyObj->assign("message_content", "Your changes have been saved.<br><a href='index.php?b=options&r=" . rand(20, 214142124) . "'>Click here to continue</a>"); } else { $optionrows = bBlogConfig::showConfigForm($bBlog->db); $bBlog->smartyObj->assign("optionrows", $optionrows); } // end of else $bBlog->display("options.html"); ?>