Ejemplo n.º 1
0
 function SB_SanityCheck()
 {
     $this->um =& SB_UserManager::staticInstance();
     $this->tree =& SB_Tree::staticInstance();
     $this->db =& SB_Database::staticInstance();
     if (!$this->um->isLogged() || !$this->um->isAdmin()) {
         die("Access denied!");
     }
 }
Ejemplo n.º 2
0
 function SB_Validator()
 {
     $this->um =& SB_UserManager::staticInstance();
     $this->tree =& SB_Tree::staticInstance();
     $this->db =& SB_Database::staticInstance();
     $this->fc =& SB_FaviconCache::staticInstance();
     if (!$this->um->setupDone || !$this->um->isLogged()) {
         echo 'Access denied!';
         die;
     }
 }
Ejemplo n.º 3
0
 function SB_Writer_xbel_mozilla()
 {
     parent::__construct();
     $this->metaAttr = array('owner' => 'Mozilla');
     $db =& SB_Database::staticInstance();
     $special = array('is_toolbar' => 'BookmarksToolbarFolder', 'is_unfiled' => 'UnfiledBookmarksFolder');
     foreach ($special as $attr => $label) {
         $id = $db->getUserData('special', $this->um->uid, $attr);
         if ($id) {
             $this->metaAttr[$label] = 'n' . $id;
         }
     }
 }
Ejemplo n.º 4
0
 function _buildMessengerCommon(&$fields, $to)
 {
     $fields['--hidden1-'] = array('name' => 'uid', 'value' => SB_reqVal('uid'));
     $fields['--hidden2-'] = array('name' => 'command_gid', 'value' => SB_reqVal('command_gid'));
     $isModerator = SB_reqChk('command_gid') && $this->um->isModerator(SB_reqVal('command_gid'));
     if ($isModerator || $this->um->isAdmin()) {
         $fields['From'] = array('name' => 'from', 'type' => 'select', '_options' => '_buildMessengerFrom');
         $fields['To (Just Label)'] = array('name' => 'to', 'value' => $to);
     } else {
         $fields['To'] = array('disabled' => 1, 'name' => 'to', 'value' => $to);
     }
     $fields['Subject'] = array('name' => 'subject');
     if (SB_reqChk('inre')) {
         $where = array('mid' => intval(SB_reqVal('inre')));
         $db =& SB_Database::staticInstance();
         $res = $db->select('subject', 'sitebar_message', $where);
         if ($res) {
             $rec = $db->fetchRecord($res);
             $subject = $rec['subject'];
             if (strpos($subject, SB_T('Re:')) != 0) {
                 $subject = SB_T('Re:') . ' ' . $subject;
             }
             $where['^1'] = 'AND';
             $where['uid'] = $this->um->uid;
             if ($db->select(null, 'sitebar_message_folder', $where)) {
                 $fields['Subject']['value'] = $subject;
             }
         }
     }
     $fields['Message'] = array('name' => 'message', 'type' => 'textarea', 'rows' => 5);
     if ($this->um->isAdmin()) {
         $fields['--raw1-'] = '<p><a target="_blank" href="http://www.fckeditor.net/demo/default.html">FCKeditor - WYSIWYG</a></p>';
         $fields['Formatting'] = array('name' => 'format', 'type' => 'select', '_options' => '_buildMessengerFormatting');
         $fields['Respect Allow Info Mail'] = array('name' => 'respect', 'type' => 'checkbox', 'checked' => 0, 'title' => SB_P('command::tooltip_respect'));
         $fields['Expiration'] = array('name' => 'expires', 'value' => date('Y-m-d', mktime(0, 0, 0, date('m') + 1, date('d'), date('Y'))));
     }
 }
Ejemplo n.º 5
0
 function SB_Tree()
 {
     $this->db =& SB_Database::staticInstance();
     $this->um =& SB_UserManager::staticInstance();
     $this->userSortMode = $this->um->getParam('user', 'link_sort_mode');
     $this->sortModeLabel = array('user' => 'User Default', 'custom' => 'Custom Order', 'abc' => 'Alphabetically', 'added' => 'Recently Added', 'changed' => 'Recently Modified', 'visited' => 'Recently Visited', 'hits' => 'Most Popular', 'waiting' => 'Waiting for Visit');
 }
Ejemplo n.º 6
0
    function checkStructure()
    {
        $this->db = SB_Database::staticInstance();
        if ($this->db->connection) {
            $release = $this->getDBRelease();
            if ($this->db->currentRelease() != $release) {
                if (isset($_REQUEST['command'])) {
                    $this->command = $_REQUEST['command'];
                }
                switch ($this->command) {
                    case 'Upgrade':
                        $this->conversion($release, true);
                        exit;
                    case 'Downgrade':
                        $this->conversion($release, false);
                        exit;
                    case 'Install':
                        $this->install();
                        exit;
                }
                if ($release) {
                    $dbrel = $this->db->currentRelease();
                    $this->message = <<<MSG
Your software version {$dbrel} differs from the database version {$release}.
MSG;
                    $this->writePage();
                    ?>
<p>
<form action="<?php 
                    echo SB_FORM_ACTION_EXECUTOR;
                    ?>
" method="POST">
<?php 
                    if (file_exists($this->getScriptName($release, true))) {
                        ?>
<input type="submit" name="command" value="Upgrade">
<?php 
                    }
                    if (file_exists($this->getScriptName($release, false))) {
                        ?>
<input type="submit" name="command" value="Downgrade">
<?php 
                    }
                    ?>
<input type="submit" name="command" value="Reload">
</form>
<?php 
                } else {
                    $this->message = 'Your database does not contain SiteBar tables.';
                    $this->writePage();
                    ?>
<p>
<form action="<?php 
                    echo SB_FORM_ACTION_EXECUTOR;
                    ?>
" method="POST">
<input type="submit" name="command" value="Install">
<input type="submit" name="command" value="Reload">
</form>
<?php 
                }
            } else {
                header('Location: index.php');
            }
        } else {
            $this->error('Cannot connect to database!');
            $this->writePage();
            ?>
<p>
<form action="<?php 
            echo SB_FORM_ACTION_EXECUTOR;
            ?>
" method="POST">
<input type="submit" name="command" value="Check Settings">
</form>
<?php 
        }
    }
Ejemplo n.º 7
0
 function privateMessage($params)
 {
     $gid = isset($params['gid']) && $params['gid'] ? $params['gid'] : null;
     $isModerator = $gid && $this->isModerator($gid);
     $isAdmin = $this->isAdmin();
     $role = ($isModerator || $isAdmin) && isset($params['from_role']) ? $params['from_role'] : 'user';
     $db =& SB_Database::staticInstance();
     $insert = array('uid' => $this->uid, 'gid' => $gid, 'sent' => array('now' => null), 'role' => $role, 'format' => $isAdmin && $params['format'] ? $params['format'] : 'plain', 'to_label' => $params['to_label'], 'subject' => $params['subject'], 'message' => $params['message']);
     $db->insert('sitebar_message', $insert);
     $mid = $db->getLastId();
     if ($isAdmin && $params['expires']) {
         $insert['expires'] = $params['expires'];
     }
     $counter = 0;
     $safe_mode = in_array(strtolower(ini_get('safe_mode')), array("1", "on", "yes", "true"));
     if (!$safe_mode) {
         // We need more time if our database is slow
         set_time_limit(intval(count($params['to_list']) / 20) + 10);
     }
     $insert = array('mid' => $mid);
     // Insert recipients
     foreach ($params['to_list'] as $uid => $user) {
         if ($uid == SB_ANONYM) {
             continue;
         }
         $userparams = $user['params'];
         $this->explodeParams($userparams, 'tmp');
         if (($isModerator || $isAdmin) && isset($params['respect']) && !$this->getParam('tmp', 'allow_info_mails')) {
             continue;
         }
         SB_SetLanguage($this->getParam('tmp', 'lang'));
         $counter++;
         $insert['uid'] = $uid;
         $db->insert('sitebar_message_folder', $insert);
         if ($params['pm_notification'] && $user['verified'] && $this->getParam('config', 'use_mail_features') && $this->getParam('tmp', 'pm_notification')) {
             $subject = SB_T('SiteBar: Private Message Notification');
             $msg = SB_P('command::pm_notification', array($params['subject'], SB_Page::absBaseUrl()));
             $this->sendMail(array('email' => $user['email']), $subject, $msg);
         }
     }
     SB_SetLanguage($this->getParam('user', 'lang'));
     $insert['folder'] = 'outbox';
     // Insert senders
     if (($isModerator || $isAdmin) && $role != 'user') {
         $gid = $role == 'admins' ? SB_ADMIN_GROUP : $gid;
         foreach ($this->getMembers($gid) as $uid => $user) {
             $userparams = $user['params'];
             $this->explodeParams($userparams, 'tmp');
             SB_SetLanguage($this->getParam('tmp', 'lang'));
             $counter++;
             $insert['uid'] = $uid;
             $db->insert('sitebar_message_folder', $insert);
         }
     } else {
         $insert['uid'] = $this->uid;
         $db->insert('sitebar_message_folder', $insert);
     }
     SB_SetLanguage($this->getParam('user', 'lang'));
 }
Ejemplo n.º 8
0
 function SB_DatabaseMySQL($ignoreError = false)
 {
     parent::SB_Database();
     if (!extension_loaded('mysql') || !function_exists('mysql_connect')) {
         die('SiteBar: No support for MySQL detected!');
     }
     if (!is_file('./adm/config.inc.php')) {
         return;
     }
     include './adm/config.inc.php';
     $config = $SITEBAR['db'];
     $this->name = $config['name'];
     $this->connection = $this->connect($config['host'], $config['username'], $config['password']);
     if (!$this->connection) {
         return;
     }
     if (!$this->hasDB($config['name'])) {
         if (!$ignoreError) {
             die('SiteBar: Database <b>' . $this->name . '</b> does not exist! ' . 'Delete your <b>adm/config.inc.php</b>!');
         }
         $this->connection = null;
         return;
     }
 }
Ejemplo n.º 9
0
 function SB_Token()
 {
     $this->db =& SB_Database::staticInstance();
     $this->um =& SB_UserManager::staticInstance();
 }
Ejemplo n.º 10
0
 function SB_FaviconCache()
 {
     $this->db =& SB_Database::staticInstance();
     $this->um =& SB_UserManager::staticInstance();
 }