コード例 #1
0
 public function __construct($request)
 {
     global $lang;
     $this->lang = $lang;
     if (isset($_GET['sort']) && $_GET['sort'] != "*") {
         //if($request['sort'] == "*") {
         //$order ="[a-zA-Z].*$";
         //$like = 'REGEXP';
         //} else {
         $order = strtolower($_GET['sort']) . '%';
         $like = 'LIKE';
         //}
     } else {
         $order = "%";
         $like = 'LIKE';
     }
     $limit = isset($_GET['limit']) ? intval($_GET['limit']) : NULL;
     $start = isset($_GET['start']) ? intval($_GET['start']) : NULL;
     global $settings;
     $db_type = get_setting(get_setting('application', 'dba_name'), 'type');
     $proper_limit = $db_type == 'pgsql' ? "LIMIT {$limit} OFFSET {$start}" : "LIMIT {$start}, {$limit}";
     $extra = !is_null($limit) && !is_null($start) ? $proper_limit : "LIMIT " . $settings['memberlistperpage'];
     $query = "SELECT * FROM " . USERS . " WHERE name {$like} '{$order}' {$extra}";
     $this->users = DBA::Open()->Query($query)->GetIterator();
 }
コード例 #2
0
 public function Execute(Template $template, Session $session, $request)
 {
     $this->dba = DBA::Open();
     $template = CreateAncestors($template, $template['L_ADMINPANEL']);
     if ($session['user'] instanceof Member && $session['user']['perms'] & ADMIN) {
         $template->content = array('file' => 'admin/admin.html');
         $template->admin_panel = array('file' => 'admin/mod_permissions.html');
         if (isset($request['forum']) && intval($request['forum']) != 0) {
             $forum = $this->dba->GetRow("SELECT * FROM " . FORUMS . " WHERE id = " . intval($request['forum']));
             /* Set the template variables */
             $template['forum_id'] = $forum['id'];
             $template['can_view'] = $forum['can_view'];
             $template['can_read'] = $forum['can_read'];
             $template['can_post'] = $forum['can_post'];
             $template['can_reply'] = $forum['can_reply'];
             $template['can_edit'] = $forum['can_edit'];
             $template['can_sticky'] = $forum['can_sticky'];
             $template['can_announce'] = $forum['can_announce'];
             $template['can_vote'] = $forum['can_vote'];
             $template['can_pollcreate'] = $forum['can_pollcreate'];
             $template['can_attach'] = $forum['can_attach'];
         } else {
             return new Error($template['L_FORUMDOESNTEXIST'], $template);
         }
     }
     return TRUE;
 }
コード例 #3
0
 public function Execute(Template $template, Session $session, $request)
 {
     $this->dba = DBA::Open();
     /* Create the ancestors bar (if we run into any trouble */
     $template = CreateAncestors($template, $template['L_INFORMATION']);
     if ($session['user'] instanceof Guest) {
         $email = htmlspecialchars($request['email']);
         if ($email == check_mail($email)) {
             if ($this->dba->Query("SELECT * FROM " . USERS . " WHERE email = '{$email}'")->NumRows() > 0) {
                 $new_pw = $this->GetRandom();
                 $forum = $this->dba->GetValue("SELECT name FROM " . FORUMS . " WHERE row_left = 1");
                 $username = $this->dba->GetValue("SELECT name FROM " . USERS . " WHERE email = '{$email}'");
                 if (mail($email, sprintf($template['L_PWSENTSUBJECT'], $forum), sprintf($template['L_PWSENTMESSAGE'], $forum, $username, $new_pw, $forum), "From: \"Password Reset - k4 Bulletin Board Mailer\" <noreply@" . $_SERVER['HTTP_HOST'] . ">")) {
                     $this->dba->Query("UPDATE " . USERS . " SET pass = '******' WHERE email = '{$email}'");
                     return new Error($template['L_PASSWORDSENT'] . '<meta http-equiv="refresh" content="2; url=index.php">', $template);
                 } else {
                     return new Error($template['L_ERRORRESETPW'], $template);
                 }
             } else {
                 return new Error($template['L_INVALIDEMAIL'], $template);
             }
         } else {
             return new Error($template['L_INVALIDEMAIL'], $template);
         }
     } else {
         return new Error($template['L_CANTBELOGGEDIN'], $template);
     }
 }
コード例 #4
0
ファイル: prune.class.php プロジェクト: BackupTheBerlios/k4bb
 public function Execute(Template $template, Session $session, $request)
 {
     $this->dba = DBA::Open();
     $template = CreateAncestors($template, $template['L_ADMINPANEL']);
     if ($session['user'] instanceof Member && $session['user']['perms'] & ADMIN) {
         if (isset($request['forum']) && isset($request['days'])) {
             /* Turn the board off for safety reasons */
             $this->dba->Execute("UPDATE " . SETTING . " SET value = '0' WHERE varname = 'bbactive'");
             $days = intval($request['days']);
             $forum = intval($request['forum']);
             $created = $days == 0 ? time() : time() - $days * 24 * 3600;
             $prune = new Prune();
             if ($forum == -1) {
                 foreach ($this->dba->Query("SELECT * FROM " . POSTS . " WHERE row_status != 2 AND row_status != 3 AND row_type = 2 AND row_right-row_left-1 = 0 AND created <= " . $created) as $post) {
                     $prune->KillNode($post);
                 }
             } else {
                 foreach ($this->dba->Query("SELECT * FROM " . POSTS . " WHERE parent_id = " . $forum . " AND row_status != 2 AND row_status != 3 AND row_type = 2 AND row_right-row_left-1 = 0 AND created <= " . $created) as $post) {
                     $prune->KillNode($post);
                 }
             }
             /* Turn the board back on */
             $this->dba->Execute("UPDATE " . SETTING . " SET value = '1' WHERE varname = 'bbactive'");
             return new Error($template['L_PRUNESUCCESS'] . '<meta http-equiv="refresh" content="2; url=admin.php?act=prune">', $template);
         } else {
             return new Error($template['L_FORUMDOESNTEXIST'], $template);
         }
     }
     return TRUE;
 }
コード例 #5
0
 public function __construct()
 {
     $expired = time() - Lib::GetSetting('sess.gc_maxlifetime');
     $users = DBA::Open()->Query("SELECT * FROM " . USERS . " WHERE birthday != 0");
     $this->count = $users->NumRows();
     $this->users = $users->GetIterator();
     $this->i = 1;
 }
コード例 #6
0
 public function __construct()
 {
     $url = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
     $this->config = new Config();
     $this->last_year = new Url($url);
     $this->last_month = new Url($url);
     $this->next_year = new Url($url);
     $this->next_month = new Url($url);
     $this->dba = DBA::Open();
 }
コード例 #7
0
 public function Execute(Template $template, Session $session, $request)
 {
     if ($session['user'] instanceof Member && $session['user']['perms'] & ADMIN) {
         $id = intval($request['bwid']);
         if (DBA::Open()->Query("DELETE FROM " . BADWORDS . " WHERE id = {$id}")) {
             header("Location: admin.php?act=censoring");
         }
     }
     return TRUE;
 }
コード例 #8
0
ファイル: forum.class.php プロジェクト: BackupTheBerlios/k4bb
 public function setForumPermissions($forum_id, $request)
 {
     $dba = DBA::Open();
     foreach ($request as $key => $val) {
         $request['key'] = $dba->Quote(intval($val));
     }
     if ($dba->Query("UPDATE " . FORUMS . " SET can_attach = " . $request['can_attach'] . ", can_view = " . $request['can_view'] . ", can_read = " . $request['can_read'] . ", can_post = " . $request['can_post'] . ", can_reply = " . $request['can_reply'] . ", can_edit = " . $request['can_edit'] . ", can_sticky = " . $request['can_sticky'] . ", can_announce = " . $request['can_announce'] . ", can_vote = " . $request['can_vote'] . ", can_pollcreate = " . $request['can_pollcreate'] . " WHERE id = {$forum_id}")) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
コード例 #9
0
ファイル: index.php プロジェクト: BackupTheBerlios/k4bb
 public function Execute(Template $template, Session $session, $request)
 {
     $forum = new Forum();
     //foreach(DBA::Open()->Query("SELECT * FROM ". SESSIONS) as $s) { print_r($s); }
     //$rows = $forum->getForums((@$session['user']['perms'] & ADMIN));
     /* Set the templates */
     $template->content = array('file' => 'forums.html');
     if ($template['WOLenable'] == 1) {
         $template->users_online = array('file' => 'online_users.html');
     }
     if ($template['showbirthdays'] == 1) {
         $template->todays_bdays = array('file' => 'birthdays.html');
     }
     $suspend = $session['user']['perms'] & ADMIN ? 1 : 0;
     /* Set the forums and categoris */
     $template->categories = new ForumList(FALSE, $suspend);
     /* Set the title of the page */
     $template['title'] = $template['L_HOME'];
     $expired = time() - Lib::GetSetting('sess.gc_maxlifetime');
     /* Display message for unlogged users */
     if ($session['user'] instanceof Guest) {
         $template['welcome_title'] = sprintf($template['L_WELCOMETITLE'], $template['forum_description']);
         // you can use forum_name here instead
         $template['welcome_msg'] = $template['L_WELCOMEMESSAGE'];
     } else {
         $template->welcome_msg = array('hide' => TRUE);
     }
     /* Set the online users list */
     if ($template['displayloggedin'] == 1) {
         $template->online_users = new Online_Users();
     }
     if ($template['showbirthdays'] == 1) {
         $template->birthdays = new Birthdays();
     }
     //DBA::Open()->Execute("delete from k4_pmsgs");
     //echo DBA::Open()->GetValue("select count(*) from k4_pmsgs");
     //print_r(DBA::Open()->GetRow("SELECT * FROM ". FORUMS ." WHERE row_left = 1"));
     //foreach(DBA::Open()->Query("SELECT * FROM ". POSTS ." WHERE row_left < 0 OR row_right < 0") as $t) { print_r($t); }
     $stats = DBA::Open()->GetRow("SELECT (SELECT COUNT(*) FROM " . USERS . " WHERE invisible = 0) AS num_members, (SELECT COUNT(s.uid) FROM " . USERS . " u, " . SESSIONS . " s WHERE u.invisible = 1 AND u.id = s.uid) AS num_invisible, (SELECT MAX(id) FROM " . USERS . ") AS newest_uid, (SELECT name FROM " . USERS . " ORDER BY created DESC LIMIT 1) AS newest_user, (SELECT COUNT(*) FROM " . USERS . " WHERE seen >= {$expired}) AS num_online, (SELECT COUNT(*) FROM " . POSTS . ") AS num_articles, (SELECT COUNT(*) FROM " . SESSIONS . ") AS num_total FROM " . USERS);
     /* Set the board statistics */
     $template['newest_member'] = sprintf($template['L_NEWESTMEMBER'], $stats['newest_uid'], $stats['newest_user']);
     $template['total_posts'] = sprintf($template['L_TOTALPOSTS'], $stats['num_articles']);
     $template['total_users'] = sprintf($template['L_TOTALUSERS'], $stats['num_members']);
     $guests = $stats['num_total'] - $stats['num_online'] < 0 ? 0 : $stats['num_total'] - $stats['num_online'];
     $guests = $template['WOLguests'] == 1 ? $guests : '--';
     $template['online_stats'] = sprintf($template['L_ONLINEUSERSTATS'], $stats['num_total'], $stats['num_online'], $guests, $stats['num_invisible']);
     /* Set the number of queries */
     $template['num_queries'] = $session->dba->num_queries;
     return TRUE;
 }
コード例 #10
0
ファイル: login.class.php プロジェクト: BackupTheBerlios/k4bb
 public function Execute(Template $template, Session $session, $request)
 {
     /* Create the ancestors bar (if we run into any trouble */
     $template = CreateAncestors($template, $template['L_LOGOUT']);
     if ($session['user'] instanceof Member) {
         setcookie('k4_lastactive', time(), time() + 3600 * 24 * 60);
         // expire in 30 days
         DBA::Open()->Query("UPDATE " . USERS . " SET last_seen = seen, seen = 0 WHERE id = " . $session['user']['id']);
         $session['user'] = new Guest();
         $session['rememberme'] = 'off';
         header("Location: {$_SERVER['HTTP_REFERER']}");
         exit;
     } else {
         return new Error($template['L_NEEDLOGGEDIN'], $template);
     }
     return FALSE;
 }
コード例 #11
0
 public function Execute(Template $template, Session $session, $request)
 {
     if ($session['user'] instanceof Member && $session['user']['perms'] & ADMIN) {
         $dba = DBA::Open();
         if (!$request['name']) {
             return new Error(sprintf($template['L_REQUIREDFIELDS'], $template['L_NAME']), $template);
         }
         if (!$request['description']) {
             return new Error(sprintf($template['L_REQUIREDFIELDS'], $template['L_DESCRIPTION']), $template);
         }
         if (!$request['mod_name']) {
             return new Error(sprintf($template['L_REQUIREDFIELDS'], $template['L_MODERATOR']), $template);
         }
         if (!$request['perms']) {
             return new Error(sprintf($template['L_REQUIREDFIELDS'], $template['L_PERMISSIONS']), $template);
         }
         $name = $dba->Quote($request['name']);
         $id = intval($request['id']);
         $description = $dba->Quote($request['description']);
         $mod_name = $dba->Quote($request['mod_name']);
         try {
             $mod = $dba->GetRow("SELECT * FROM " . USERS . " WHERE name = '{$mod_name}'");
             $permissions = intval($request['perms']);
             $users = $dba->Query("SELECT * FROM " . USER_IN_GROUP . " WHERE group_id = {$id}");
             foreach ($users as $user) {
                 $temp_user = $dba->GetRow("SELECT * FROM " . USERS . " WHERE id = " . $user['id']);
                 if ($permissions > $temp_user['perms']) {
                     @$dba->Query("UPDATE " . USERS . " SET perms = {$permissions} WHERE id = " . $user['id']);
                 }
             }
             if (@$dba->Query("UPDATE " . GROUPS . " SET name = '{$name}', description = '{$description}', mod_name = '" . $mod['name'] . "', mod_id = " . $mod['id'] . ", permissions = {$permissions} WHERE id = {$id}")) {
                 header("Location: admin.php?act=groups");
             }
         } catch (DBA_Exception $e) {
             return new TplException($e, $template);
         }
     }
     return TRUE;
 }
コード例 #12
0
ファイル: dba_driver.php プロジェクト: HaakonME/hubzilla
 /**
  * @brief Returns the database driver object.
  *
  * If available it will use PHP's mysqli otherwise mysql driver.
  *
  * @param string $server DB server name
  * @param string $port DB port
  * @param string $user DB username
  * @param string $pass DB password
  * @param string $db database name
  * @param string $dbtype 0 for mysql, 1 for postgres
  * @param bool $install Defaults to false
  * @return null|dba_driver A database driver object (dba_mysql|dba_mysqli) or null if no driver found.
  */
 public static function dba_factory($server, $port, $user, $pass, $db, $dbtype, $install = false)
 {
     self::$dba = null;
     self::$dbtype = intval($dbtype);
     $set_port = $port;
     if (self::$dbtype == DBTYPE_POSTGRES) {
         require_once 'include/dba/dba_postgres.php';
         if (is_null($port)) {
             $set_port = 5432;
         }
         self::$dba = new dba_postgres($server, $set_port, $user, $pass, $db, $install);
     } else {
         //			Highly experimental at the present time.
         //			require_once('include/dba/dba_pdo.php');
         //			self::$dba = new dba_pdo($server, $set_port,$user,$pass,$db,$install);
         //		}
         if (class_exists('mysqli')) {
             if (is_null($port)) {
                 $set_port = ini_get("mysqli.default_port");
             }
             require_once 'include/dba/dba_mysqli.php';
             self::$dba = new dba_mysqli($server, $set_port, $user, $pass, $db, $install);
         }
     }
     // Until we have a proper PDO driver, store the DB connection parameters for
     // plugins/addons which use PDO natively (such as cdav). This is wasteful as
     // it opens a separate connection to the DB, but saves a lot of effort re-writing
     // third-party interfaces that are working and well tested.
     if (is_object(self::$dba) && self::$dba->connected) {
         if ($server === '127.6.95.1') {
             $port = $set_port;
         }
         $dns = (self::$dbtype == DBTYPE_POSTGRES ? 'postgres' : 'mysql') . ':host=' . $server . (is_null($port) ? '' : ';port=' . $port) . ';dbname=' . $db;
         self::$dba->pdo_set(array($dns, $user, $pass));
     }
     define('NULL_DATE', self::$dba->get_null_date());
     define('ACTIVE_DBTYPE', self::$dbtype);
     return self::$dba;
 }
コード例 #13
0
 public function __construct()
 {
     $this->session = $_SESSION;
     $this->dba = DBA::Open();
     $this->friends = $this->dba->Query("SELECT * FROM " . PMSG_LIST . " WHERE member_list_id = " . $this->session['user']['id'] . " AND user_liked = 0")->GetIterator();
 }
コード例 #14
0
ファイル: users.class.php プロジェクト: BackupTheBerlios/k4bb
 public function Execute(Template $template, Session $session, $request)
 {
     $this->dba = DBA::Open();
     $template = CreateAncestors($template, $template['L_ADMINPANEL']);
     if ($session['user'] instanceof Member && $session['user']['perms'] & ADMIN) {
         $user = $this->dba->Quote($request['name']);
         if ($this->dba->Query("SELECT * FROM " . USERS . " WHERE name = '{$user}'")->NumRows() == 1) {
             $id = $this->dba->GetValue("SELECT id FROM " . USERS . " WHERE name = '{$user}'");
             if (isset($request['edit'])) {
                 header("Location: member.php?id=" . $id);
             } else {
                 if (isset($request['delete'])) {
                     if ($id != 1) {
                         $this->dba->Execute("DELETE FROM " . SESSIONS . " WHERE uid = " . $id);
                         $this->dba->Execute("DELETE FROM " . USERS . " WHERE id = " . $id);
                         $this->dba->Execute("UPDATE " . POSTS . " SET poster_id = 0 WHERE poster_id = " . $id);
                         $this->dba->Execute("UPDATE " . FORUMS . " SET thread_uid = 0 WHERE thread_uid = " . $id);
                         return new Error($template['L_DELETEDUSER'], $template);
                     } else {
                         return new Error($template['L_CANNOTDELETEADMIN'], $template);
                     }
                 }
             }
         } else {
             return new Error($template['L_USERDOESNTEXIST'], $template);
         }
     }
 }
コード例 #15
0
ファイル: boot.php プロジェクト: einervonvielen/hubzilla
function sys_boot()
{
    // our central App object
    App::init();
    /*
     * Load the configuration file which contains our DB credentials.
     * Ignore errors. If the file doesn't exist or is empty, we are running in
     * installation mode.
     */
    // miniApp is a conversion object from old style .htconfig.php files
    $a = new miniApp();
    App::$install = file_exists('.htconfig.php') && filesize('.htconfig.php') ? false : true;
    @(include '.htconfig.php');
    if (!defined('UNO')) {
        define('UNO', 0);
    }
    if (array_key_exists('default_timezone', get_defined_vars())) {
        App::$config['system']['timezone'] = $default_timezone;
    }
    $a->convert();
    App::$timezone = App::$config['system']['timezone'] ? App::$config['system']['timezone'] : 'UTC';
    date_default_timezone_set(App::$timezone);
    /*
     * Try to open the database;
     */
    require_once 'include/dba/dba_driver.php';
    if (!App::$install) {
        DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install);
        if (!DBA::$dba->connected) {
            system_unavailable();
        }
        unset($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type);
        /**
         * Load configs from db. Overwrite configs from .htconfig.php
         */
        load_config('config');
        load_config('system');
        load_config('feature');
        App::$session = new Zotlabs\Web\Session();
        App::$session->init();
        load_hooks();
        call_hooks('init_1');
    }
}
コード例 #16
0
<?php

/**********************************************************************************
 *     k4 Bulletin Board
 *     lang.php (English language pack)
 *     Copyright (c) 2004, Peter Goodman
 *     Permission is hereby granted, free of charge, to any person obtaining 
 *     a copy of this software and associated documentation files (the 
 *     "Software"), to deal in the Software without restriction, including 
 *     without limitation the rights to use, copy, modify, merge, publish, 
 *     distribute, sublicense, and/or sell copies of the Software, and to 
 *     permit persons to whom the Software is furnished to do so, subject to 
 *     the following conditions:
 *     The above copyright notice and this permission notice shall be 
 *     included in all copies or substantial portions of the Software.
 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 *     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
 *     BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
 *     ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
 *     CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
 *     SOFTWARE.
 *********************************************************************************/
error_reporting(E_STRICT | E_ALL);
/*------------------------------- SETTINGS -------------------------------- */
$settings = array();
foreach (DBA::Open()->Query("SELECT * FROM " . SETTING) as $setting) {
    $settings[$setting['varname']] = $setting['value'];
}
/*------------------------------------------------------------------------- */
コード例 #17
0
ファイル: Setup.php プロジェクト: einervonvielen/hubzilla
 /**
  * @brief Handle the actions of the different setup steps.
  *
  */
 function post()
 {
     switch ($this->install_wizard_pass) {
         case 1:
         case 2:
             return;
             // implied break;
         // implied break;
         case 3:
             $urlpath = \App::get_path();
             $dbhost = trim($_POST['dbhost']);
             $dbport = intval(trim($_POST['dbport']));
             $dbuser = trim($_POST['dbuser']);
             $dbpass = trim($_POST['dbpass']);
             $dbdata = trim($_POST['dbdata']);
             $dbtype = intval(trim($_POST['dbtype']));
             $phpath = trim($_POST['phpath']);
             $adminmail = trim($_POST['adminmail']);
             $siteurl = trim($_POST['siteurl']);
             $advanced = intval($_POST['advanced']) ? 1 : 0;
             // $siteurl should not have a trailing slash
             $siteurl = rtrim($siteurl, '/');
             require_once 'include/dba/dba_driver.php';
             $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
             if (!\DBA::$dba->connected) {
                 echo 'Database Connect failed: ' . DBA::$dba->error;
                 killme();
             }
             return;
             // implied break;
         // implied break;
         case 4:
             $urlpath = \App::get_path();
             $dbhost = notags(trim($_POST['dbhost']));
             $dbport = intval(notags(trim($_POST['dbport'])));
             $dbuser = notags(trim($_POST['dbuser']));
             $dbpass = notags(trim($_POST['dbpass']));
             $dbdata = notags(trim($_POST['dbdata']));
             $dbtype = intval(notags(trim($_POST['dbtype'])));
             $phpath = notags(trim($_POST['phpath']));
             $timezone = notags(trim($_POST['timezone']));
             $adminmail = notags(trim($_POST['adminmail']));
             $siteurl = notags(trim($_POST['siteurl']));
             $advanced = intval($_POST['advanced']) ? 1 : 0;
             if ($siteurl != z_root()) {
                 $test = z_fetch_url($siteurl . "/setup/testrewrite");
                 if (!$test['success'] || $test['body'] != 'ok') {
                     \App::$data['url_fail'] = true;
                     \App::$data['url_error'] = $test['error'];
                     return;
                 }
             }
             if (!\DBA::$dba->connected) {
                 // connect to db
                 $db = \DBA::dba_factory($dbhost, $dbport, $dbuser, $dbpass, $dbdata, $dbtype, true);
             }
             if (!\DBA::$dba->connected) {
                 echo 'CRITICAL: DB not connected.';
                 killme();
             }
             $tpl = get_intltext_template('htconfig.tpl');
             $txt = replace_macros($tpl, array('$dbhost' => $dbhost, '$dbport' => $dbport, '$dbuser' => $dbuser, '$dbpass' => $dbpass, '$dbdata' => $dbdata, '$dbtype' => $dbtype, '$uno' => 1 - $advanced, '$timezone' => $timezone, '$siteurl' => $siteurl, '$site_id' => random_string(), '$phpath' => $phpath, '$adminmail' => $adminmail));
             $result = file_put_contents('.htconfig.php', $txt);
             if (!$result) {
                 \App::$data['txt'] = $txt;
             }
             $errors = $this->load_database($db);
             if ($errors) {
                 \App::$data['db_failed'] = $errors;
             } else {
                 \App::$data['db_installed'] = true;
             }
             return;
             // implied break;
         // implied break;
         default:
             break;
     }
 }
コード例 #18
0
ファイル: ranks.class.php プロジェクト: BackupTheBerlios/k4bb
 public function __construct()
 {
     $this->dba = DBA::Open();
     $this->ranks = $this->dba->Query("SELECT * FROM " . RANKS)->GetIterator();
 }
コード例 #19
0
ファイル: icons.class.php プロジェクト: BackupTheBerlios/k4bb
 public function Execute(Template $template, Session $session, $request)
 {
     if ($session['user'] instanceof Member && $session['user']['perms'] & ADMIN) {
         $table = $request['act'] == 'deletepi' ? POSTICONS : EMOTICONS;
         if (is_int(@$request['id']) && @$request['id'] != 0 && isset($request['id']) && $request['id'] != '') {
             $id = intval($request['id']);
             if (DBA::Open()->Query("DELETE FROM " . $table . " WHERE id = {$id}")) {
                 header("Location: admin.php?act=icons");
             }
         } else {
             return new Error($template['L_INVALIDICONID'], $template);
         }
     }
 }
コード例 #20
0
 public function __construct($row, $revert)
 {
     $this->revert = $revert;
     $this->item = DBA::Open()->Query("SELECT * FROM " . FAQ . " WHERE parent_id = " . $row['id'])->GetIterator();
 }
コード例 #21
0
ファイル: DBATest.php プロジェクト: KIZI/sewebar-cms
 public function testToArray3RefsLevel2()
 {
     $DBA = new DBA('ant_001', $this->connectiveConj, array(), 2);
     $BBAMock = $this->getMock("BBA", array('toArray'), array('ant_001', 'Sex', array('F')));
     $BBAMock->expects($this->once())->method("toArray")->will($this->returnValue(array(array('name' => 'Sex', 'type' => 'attr', 'category' => 'One category', 'fields' => array(array('name' => 'category', 'value' => 'F'))))));
     $DBA->addRef($BBAMock);
     $BBAMock2 = $this->getMock("BBA", array('toArray'), array('ant_002', 'District', array('Praha')));
     $BBAMock2->expects($this->once())->method("toArray")->will($this->returnValue(array(array('name' => 'District', 'type' => 'attr', 'category' => 'One category', 'fields' => array(array('name' => 'category', 'value' => 'Praha'))))));
     $DBA->addRef($BBAMock2);
     $BBAMock3 = $this->getMock("BBA", array('toArray'), array('ant_003', 'Age', array('31')));
     $BBAMock3->expects($this->once())->method("toArray")->will($this->returnValue(array(array('name' => 'Age', 'type' => 'attr', 'category' => 'One category', 'fields' => array(array('name' => 'category', 'value' => '31'))))));
     $DBA->addRef($BBAMock3);
     $array = array(array('name' => '(', 'type' => 'lbrac', 'category' => '', 'fields' => array()), array('name' => 'Sex', 'type' => 'attr', 'category' => 'One category', 'fields' => array(array('name' => 'category', 'value' => 'F'))), array('name' => 'AND', 'type' => 'and', 'category' => '', 'fields' => array()), array('name' => 'District', 'type' => 'attr', 'category' => 'One category', 'fields' => array(array('name' => 'category', 'value' => 'Praha'))), array('name' => 'AND', 'type' => 'and', 'category' => '', 'fields' => array()), array('name' => 'Age', 'type' => 'attr', 'category' => 'One category', 'fields' => array(array('name' => 'category', 'value' => '31'))), array('name' => ')', 'type' => 'rbrac', 'category' => '', 'fields' => array()));
     $this->assertEquals($array, $DBA->toArray());
 }
コード例 #22
0
ファイル: faq.class.php プロジェクト: BackupTheBerlios/k4bb
 public function Execute(Template $template, Session $session, $request)
 {
     if ($session['user'] instanceof Member && $session['user']['perms'] & ADMIN) {
         if (!isset($request['parent_id']) || !@$request['parent_id']) {
             return new Error(sprintf($template['L_REQUIREDFIELDSSF'], $template['L_CATEGORY']), $template);
         }
         if (!isset($request['question']) || !@$request['question']) {
             return new Error(sprintf($template['L_REQUIREDFIELDSSF'], $template['L_QUESTION']), $template);
         }
         if (!isset($request['question']) || !@$request['message']) {
             return new Error(sprintf($template['L_REQUIREDFIELDSSF'], $template['L_ANSWER']), $template);
         }
         $dba = DBA::Open();
         $parent_id = intval($request['parent_id']);
         $question = $dba->Quote($request['question']);
         $parser = new BBParser($request['message']);
         $answer = $dba->Quote($parser->Execute());
         if (intval($request['add']) == 1) {
             if ($dba->Query("INSERT INTO " . FAQ . " (parent_id, question, answer) VALUES ({$parent_id}, '{$question}', '{$answer}')")) {
                 header("Location: admin.php?act=faq");
             }
         } else {
             $id = intval($request['id']);
             if ($dba->Query("UPDATE " . FAQ . " SET parent_id = {$parent_id}, question = '{$question}', answer = '{$answer}' WHERE id = {$id}")) {
                 header("Location: admin.php?act=faq");
             }
         }
     }
 }
コード例 #23
0
ファイル: test_drivers.php プロジェクト: laiello/coopcrucial
        echo $result->getMessage() . "\n";
        exit;
    }
    $key = $testDB->firstkey();
    while ($key !== FALSE) {
        echo "{$key} = " . $testDB->fetch($key) . "\n";
        $key = $testDB->nextkey($key);
    }
    if (PEAR::isError($result = $testDB->close())) {
        echo $result->getMessage();
        exit;
    }
    if (PEAR::isError($result = $testDB->drop())) {
        echo $result->getMessage();
        exit;
    }
}
echo "Testing static drop functionality\n";
// test static drop
foreach ($testDrivers as $driver) {
    echo "Testing {$driver} driver\n\n";
    $testDB =& DBA::create($driver);
    if (PEAR::isError($result = $testDB->open('test_db', 'c'))) {
        echo $result->getMessage() . "\n";
        exit;
    }
    if (PEAR::isError($result = DBA::db_drop('test_db', $driver))) {
        echo $result->getMessage();
        exit;
    }
}
コード例 #24
0
ファイル: DBA.php プロジェクト: GeekyNinja/LifesavingCAD
 /**
  * DBA_Error constructor.
  *
  * @param mixed   $code      DBA error code, or string with error message.
  * @param integer $mode      what "error mode" to operate in
  * @param integer $level     what error level to use for
  *                           $mode & PEAR_ERROR_TRIGGER
  * @param smixed  $debuginfo additional debug info, such as the last query
  */
 function DBA_Error($code = DBA_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = NULL)
 {
     if (is_int($code)) {
         $this->PEAR_Error('DBA Error: ' . DBA::errorMessage($code), $code, $mode, $level, $debuginfo);
     } else {
         $this->PEAR_Error('DBA Error: ' . $code, DBA_ERROR, $mode, $level, $debuginfo);
     }
 }
コード例 #25
0
ファイル: posting.php プロジェクト: BackupTheBerlios/k4bb
 public function Execute(Template $template, Session $session, $request)
 {
     $dba = DBA::Open();
     /* Create the ancestors bar (if we run into any trouble */
     $template = CreateAncestors($template, $template['L_EDITPOST']);
     /* Set the user's permissions */
     $user_perms = isset($session['user']['perms']) ? $session['user']['perms'] : ALL;
     if ($session['user'] instanceof Member) {
         $id = intval(@$request['id']);
         if (isset($request['id']) && $id != 0) {
             try {
                 @($post = $dba->GetRow("SELECT * FROM " . POSTS . " WHERE id = {$id}"));
             } catch (DBA_Exception $e) {
                 return new TplException($e, $template);
             }
             if (is_array($post) && !empty($post)) {
                 /* Try and get the forum */
                 try {
                     @($f = new Forum());
                     @($forum = $f->getForum($post['forum_id']));
                 } catch (DBA_Exception $e) {
                     return new TplException($e, $template);
                 }
                 if ($user_perms >= $forum['can_edit'] && ($session['user']['id'] == $post['poster_id'] || $user_perms & ADMIN)) {
                     /* Set the post icons and the emoticons */
                     $template->posticons = DBA::Open()->Query("SELECT * FROM " . POSTICONS);
                     $template->emoticons = DBA::Open()->Query("SELECT * FROM " . EMOTICONS);
                     /* Hide the part of this template that has to do with replying */
                     $template->post_thread = array('hide' => TRUE);
                     /* Set the template */
                     $template->content = array('file' => 'newthread.html');
                     $parser = new BBParser($post['body_text']);
                     $template['message'] = $parser->Revert($post['body_text']);
                     $template['posttitle'] = $post['name'];
                     /* Remove all of the extra features */
                     $template->poll_options = array('hide' => TRUE);
                     $template->post_options = array('hide' => TRUE);
                     $template->can_attach = array('hide' => TRUE);
                     /* Set the thread action */
                     $template['a_add_thread'] = new Action('posting.php', 'update_post');
                     /* Set the post id */
                     $template['post_id'] = $post['id'];
                 } else {
                     return new Error($template['L_PERMSEDITPOST'], $template);
                 }
             } else {
                 return new Error($template['L_INVALIDPOSTID'], $template);
             }
         } else {
             return new Error($template['L_INVALIDPOSTID'], $template);
         }
     } else {
         return new Error($template['L_NEEDLOGGEDIN'], $template);
     }
     /* Set the number of queries */
     $template['num_queries'] = $session->dba->num_queries;
     return TRUE;
 }
コード例 #26
0
ファイル: admin.php プロジェクト: BackupTheBerlios/k4bb
 public function Execute(Template $template, Session $session, $request)
 {
     $this->dba = DBA::Open();
     /* Ancestors Bar */
     $template = CreateAncestors($template, $template['L_LOCKTHREAD']);
     /* Check permissions */
     if ($session['user'] instanceof Member && $session['user']['perms'] >= MOD) {
         /* Set the templates */
         $template->content = array('file' => 'admin/admin.html');
         $row = $this->dba->GetRow("SELECT * FROM " . POSTS . " WHERE id = " . intval($request['id']));
         if (!empty($row) && isset($row['id'])) {
             /* Lock the thread */
             $this->dba->Execute("UPDATE " . POSTS . " SET row_locked = 1 WHERE id = " . $row['id']);
             return new Error($template['L_LOCKEDTHREAD'] . '<meta http-equiv="refresh" content="2; url=viewforum.php?id=' . $row['forum_id'] . '">', $template);
         } else {
             return new Error($template['L_INVALIDTHREADID'], $template);
         }
     }
     /* Set the number of queries */
     $template['num_queries'] = $session->dba->num_queries;
     return TRUE;
 }
コード例 #27
0
ファイル: forum.inc.php プロジェクト: BackupTheBerlios/k4bb
 public function ExecutePage()
 {
     //$timer		= new Timer;
     $session = new Session();
     $dba = DBA::Open();
     global $settings;
     foreach ($settings as $key => $val) {
         $this->template[$key] = $val;
     }
     $this->template['date'] = strftime("%a, %B %d");
     $this->template['num_queries'] = $dba->NumQueries();
     $this->template['IMG_DIR'] = !$session['user'] instanceof Member ? $this->template['imageset'] : $session['user']['imgset'];
     $this->template['VERSION'] = VERSION;
     if ($session['user'] instanceof Member) {
         if ($this->template['checknewpm'] == 1) {
             if ($dba->GetValue("SELECT COUNT(*) FROM " . PMSGS . " WHERE (poster_id = " . $session['user']['id'] . " AND saved = 1 AND new_reply = 1) OR ((member_id = " . $session['user']['id'] . " OR member_id = 0) AND member_has_read = 0)") == 0) {
                 $this->template->new_pms = array('hide' => TRUE);
             }
         }
     } else {
         $this->template->new_pms = array('hide' => TRUE);
     }
     /* Navigation */
     if ($this->template['enablememberlist'] == 0) {
         $this->template->memberlist_link = array('hide' => TRUE);
     }
     if ($this->template['calendarenabled'] == 0) {
         $this->template->calendar_link = array('hide' => TRUE);
     }
     $default_theme = $this->template['styleset'];
     $styleset = !$session['user'] instanceof Member ? $default_theme : $dba->GetValue("SELECT name FROM " . STYLES . " WHERE id = " . $session['user']['styleset']);
     $this->template['imageset'] = !$session['user'] instanceof Member ? $this->template['imageset'] : $session['user']['imgset'];
     $this->template->css_styles = $dba->Query("SELECT * FROM " . CSS . " WHERE style_id = (SELECT id FROM " . STYLES . " WHERE name = '" . $styleset . "') ORDER BY name ASC");
     $this->template['load_time'] = $this->timer->__toString();
     parent::Execute($this->template, $session);
 }
コード例 #28
0
 public function __construct($id)
 {
     $this->id = $id;
     $this->dba = DBA::Open();
     $this->options = $this->dba->Query("SELECT * FROM " . POLLOPTIONS . " WHERE poll_id = {$this->id}")->GetIterator();
 }
コード例 #29
0
ファイル: Table.php プロジェクト: GeekyNinja/LifesavingCAD
 /**
  * Check whether table exists
  *
  * @access  public
  * @param   string $tableName
  * @return  boolean true if the table exists, false otherwise
  */
 function tableExists($tableName)
 {
     return DBA::db_exists($tableName, $this->_driver);
 }
コード例 #30
0
ファイル: css.class.php プロジェクト: BackupTheBerlios/k4bb
 public function Execute(Template $template, Session $session, $request)
 {
     if ($session['user'] instanceof Member && $session['user']['perms'] & ADMIN) {
         $css = new CSS();
         $dba = DBA::Open();
         if (isset($_FILES["imported_file"]["tmp_name"])) {
             $filename = 'Uploads/' . $_FILES["imported_file"]["name"];
             if (move_uploaded_file($_FILES["imported_file"]["tmp_name"], $filename)) {
                 //if(is_uploaded_file($filename)) {
                 include $filename;
                 header("Location: admin.php?act=css");
                 //}
             }
         }
     }
     return TRUE;
 }