Exemplo n.º 1
0
 /**
  * Forum_Controller constructor
  * @param string template	The base template to use for
  *							the specific page.
  */
 function Forum_Controller($template)
 {
     /* Globalize the settings and config arrays */
     global $_SETTINGS, $_USERGROUPS, $_ALLFORUMS;
     /* Make sure the default event class exists */
     if (!class_exists('DefaultEvent')) {
         exit('Yahtzee!');
     }
     /* Call the Controller Constructor */
     parent::Controller(new DefaultEvent());
     /* Create a new instance of Template */
     error::reset();
     $this->template =& new Template($template);
     if (error::grab()) {
         critical_error();
     }
     /* Set all of the setting values to the template */
     $this->template->setVarArray($_SETTINGS);
     /* Set the Jump To Box */
     $jump_to =& new AllForumsIterator($_ALLFORUMS);
     $this->template->setList('all_forums', $jump_to);
     /* Add the usergroups to the template */
     $usergroups =& new FAArrayIterator($_USERGROUPS);
     $this->template->setList('usergroups', $usergroups);
 }
Exemplo n.º 2
0
 */
function error_handler($errorno, $string, $file, $line)
{
    if ($errorno != 2048 && $errorno != 8) {
        //  E_STRICT & E_NOTICE  && $errorno != 8
        return compile_error($string, $file, $line);
    }
}
set_error_handler("error_handler");
/**
 * Get all of the settings into one big array
 */
/* Get the configuration options */
global $_CONFIG;
/* Get the database Object and set it to a global */
error::reset();
$_DBA =& Database::open($_CONFIG['dba']);
if (error::grab()) {
    return critical_error();
}
$GLOBALS['_DBA'] =& $_DBA;
/*
$query = "";

foreach(explode("\r\n", $query) as $q)
	if($q != '')
		$_DBA->executeUpdate($q);
exit;
*/
/**
 * Create some cache files to reduce queries, but only if it needs to be re/created
Exemplo n.º 3
0
 /**
  * The function which calls everything from the controller
  * and render the template(s).
  * @param mixed template	The template variable, holds all current
  *							template information
  * @param mixed session		The session variable, holds all current
  *							session information
  * @return					method template render
  * @see Template
  * @see Session
  */
 function Execute(&$template)
 {
     global $_DBA, $_URL, $_SETTINGS;
     /**
      * General Variable Setting
      */
     /* Start the timer */
     $this->timer =& new Timer();
     /* Merge the post and get arrays */
     $request = array_merge($this->get, $this->post, $this->cookie);
     /* Strip annoying slashes on everything */
     foreach ($request as $key => $val) {
         if (!is_array($val)) {
             $request[$key] = stripslashes($val);
         }
     }
     $result = FALSE;
     /* Get the act var */
     $act_var = get_setting('application', 'action_var') or $act_var = 'act';
     /* get the session and user variables */
     $session =& $_SESSION;
     $user =& $_SESSION['user']->info;
     /**
      * Member/Guest Settings
      */
     /* Figure out which styleset, imageset and templateset to use */
     $styleset = is_a($session['user'], 'Member') && $user['styleset'] != '' || is_a($session['user'], 'Guest') && $user['styleset'] != '' ? $user['styleset'] : $template->getVar('styleset');
     $imageset = is_a($session['user'], 'Member') && $user['imgset'] != '' ? $user['imgset'] : $template->getVar('imageset');
     $templateset = is_a($session['user'], 'Member') && $user['tplset'] != '' ? $user['tplset'] : $template->getVar('templateset');
     /* Set the style, template and image sets */
     $this->template->setVar('css_styles', get_cached_styleset($styleset, $template->getVar('styleset')));
     $template_dir = FORUM_BASE_DIR . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
     $imgs_dir = FORUM_BASE_DIR . DIRECTORY_SEPARATOR . 'Images' . DIRECTORY_SEPARATOR;
     /* Should we get the template set that goes with this styleset? */
     $templateset = is_dir($template_dir . $styleset) ? $template_dir . $styleset : $template_dir . $templateset;
     /* Should we get the image set that goes with this styleset? */
     $imageset = is_dir($imgs_dir . $styleset) ? $styleset : $imageset;
     /* Check to see if our templates directory exists */
     if (!is_dir($templateset)) {
         exit('Invalid template set for: ' . $templateset);
     }
     /* Check to see if our images directory exists */
     if (!is_dir($imgs_dir . $imageset)) {
         exit('Invalid image set for: ' . $imageset);
     }
     /* Set the template an image sets */
     $this->template->setDirname($templateset);
     $this->template->setVar('IMG_DIR', $imageset);
     /* Determine which language to get, and then include the appropriate file */
     $language = is_a($session['user'], 'Member') ? strtolower($user['language']) : strtolower(get_setting('application', 'lang'));
     /* Check to see if this is an invalid language file */
     if (!file_exists(FORUM_BASE_DIR . '/includes/lang/' . $language . '/lang.php')) {
         exit('Invalid Language file.');
     }
     /* Require the language file */
     include FORUM_BASE_DIR . '/includes/lang/' . $language . '/lang.php';
     /* Set the language variable to the template */
     $template->setVar('LANG', $language);
     global $lang;
     /* Check if the language function exists */
     if (!isset($lang) || !is_array($lang) || empty($lang)) {
         exit('Invalid Language file.');
     }
     /* Set the locale to which language we are using */
     setlocale(LC_ALL, $lang['locale']);
     /* Set the language array */
     $template->setVarArray($lang);
     /* Memory Saving */
     unset($lang);
     /**
      * Event Execution
      */
     if (get_map($user, 'can_see_board', 'can_view', array()) > $user['perms']) {
         /* This user doesn't have permission to see the bb */
         $template = BreadCrumbs($template, $template->getVar('L_INFORMATION'));
         $template->setInfo('content', $template->getVar('L_YOUNEEDPERMS'));
     } else {
         if (intval($_SETTINGS['bbactive']) == 0 && $user['perms'] < SUPERMOD) {
             /* The board is closed */
             $template = BreadCrumbs($template, $template->getVar('L_INFORMATION'));
             $template->setInfo('content', $_SETTINGS['bbclosedreason']);
         } else {
             /* get the result of our event call */
             if (isset($request[$act_var]) && isset($this->events[$request[$act_var]])) {
                 $result = $this->events[$request[$act_var]]->Execute(&$template, $request, &$_DBA, &$session, &$user);
             }
             /* If the result is false, execute our defaultevent class */
             if ($result == FALSE) {
                 $this->default->Execute(&$template, $request, &$_DBA, &$session, &$user);
             }
         }
     }
     /**
      * User Information
      */
     /* Clear the session and user variables */
     $session =& $_SESSION;
     $user =& $_SESSION['user']->info;
     /**
      * Filters
      */
     /* Apply each Filter to the request */
     for ($i = 0; $i < count($this->filters); $i++) {
         $this->filters[$i]->Execute(&$template, &$session, $this->cookie, $this->post, $this->get);
     }
     /* If the user is logged in, set all of his user info to the template */
     if (is_a($session['user'], 'Member')) {
         foreach ($user as $key => $val) {
             $this->template->setVar('user_' . $key, $val);
         }
     }
     /* Set the number of queries */
     $template->setVar('num_queries', $_DBA->num_queries);
     /* Set the Load time */
     $template->setVar('load_time', $this->timer->__toString());
     if (DEBUG_SQL) {
         $debug_url =& new Url($_URL->__toString());
         $debug_url->args['debug'] = 1;
         $template->setVar('debug_url', $debug_url->__toString());
         $template->show('sql_debug');
         if (isset($request['debug']) && $request['debug'] == 1) {
             /* Output our debugged SQL */
             debug_sql();
         }
     }
     /* Do the mail queue */
     execute_mail_queue();
     /* Do the topic queue */
     execute_topic_queue();
     /**
      * Render the template 
      */
     error::reset();
     $template->Render();
     if (error::grab()) {
         critical_error();
     }
 }
Exemplo n.º 4
0
 function Execute(&$template, $request, &$dba, &$session, &$user)
 {
     if (is_a($session['user'], 'Member') && $user['perms'] >= ADMIN) {
         if (!isset($request['field']) || $request['field'] == '') {
             $template->setInfo('content', $template->getVar('L_INVALIDUSERFIELD'), TRUE);
             return TRUE;
         }
         $field = $dba->getRow("SELECT * FROM " . PROFILEFIELDS . " WHERE name = '" . $dba->quote($request['field']) . "'");
         if (!$field || !is_array($field) || empty($field)) {
             $template->setInfo('content', $template->getVar('L_INVALIDUSERFIELD'), TRUE);
             return TRUE;
         }
         if (!$dba->query("SELECT " . $field['name'] . " FROM " . USERINFO . " LIMIT 1")) {
             /* Delete the profile field version of this because obviously it shouldn't exist */
             $dba->executeUpdate("DELETE FROM " . PROFILEFIELDS . " WHERE name = '" . $dba->quote($field['name']) . "'");
             $template->setInfo('content', $template->getVar('L_INVALIDUSERFIELD'), TRUE);
             return TRUE;
         }
         /* Remove the field */
         error::reset();
         $dba->alterTable(USERINFO, "DROP " . $dba->quote($field['name']));
         $error = error::grab();
         if ($error) {
             $template->setInfo('content', sprintf($template->getVar('L_ERRORDELPROFILEFIELD'), $request['title'], $error->message . ' Line: ' . $error->line . ', File: ' . basename($error->filename)), FALSE);
             return TRUE;
         }
         /* Remove the last of the profile field info if we've made it this far */
         $dba->executeUpdate("DELETE FROM " . PROFILEFIELDS . " WHERE name = '" . $dba->quote($field['name']) . "'");
         /* Remove the cache file so it may be remade */
         if (!@touch(CACHE_FILE, time() - 86460)) {
             @unlink(CACHE_FILE);
         }
         $template->setInfo('content', sprintf($template->getVar('L_REMOVEDPROFILEFIELD'), $field['title']), FALSE);
         $template->setRedirect('admin.php?act=userfields', 3);
     } else {
         $template->setError('content', $template->getVar('L_YOUNEEDPERMS'));
     }
     return TRUE;
 }
Exemplo n.º 5
0
function compile_error($message, $file, $line)
{
    error::reset();
    error::pitch(new FAError($message, $file, $line));
    critical_error();
}