/**
  *	delete all user's records from user_attrs
  */
 function delete_user_attrs($uid)
 {
     global $config;
     $errors = array();
     if (!$this->connect_to_db($errors)) {
         ErrorHandler::add_error($errors);
         return false;
     }
     /* table's name */
     $t_name =& $config->data_sql->user_attrs->table_name;
     /* col names */
     $c =& $config->data_sql->user_attrs->cols;
     /* flags */
     $f =& $config->data_sql->user_attrs->flag_values;
     $q = "delete from " . $t_name . " \n\t\t      where " . $c->uid . "  = '" . $uid . "'";
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         if ($res->getCode() == DB_ERROR_NOSUCHTABLE) {
             return true;
         } else {
             ErrorHandler::log_errors($res);
             return false;
         }
     }
     return true;
 }
Example #2
0
  function is_conference_owner($conference_id, $username) {
    global $log; 
    $log->log("is_conference_owner $conference_id, $username "); 

    if ($conference_id && $username){ 
      change_to_conference_db($this->db);

      $q=" select owner_flag FROM invitees WHERE conference_id=$conference_id AND invitee_username='******'";
      $res=$this->db->query($q);

      if (DB::isError($res)) {
        $log->log("QUERY FAILED $q " . $res->getMessage());
      }
      $owner_flag = FALSE;

      $row = $res->fetchRow() ; 
      if ($row[0]) { 
        $owner_flag = TRUE;
      }

      $res->free();
      change_to_default_db($this->db);
      return $owner_flag; 
    }
  }  
/**
 * Execute a MySQL query
 *
 * @param	array		$dsn
 * @param	string	$query
 * @return	void	FALSE / array
 */
function myQuery($dsn, $query)
{
    require_once 'DB.php';
    $db =& DB::connect($dsn['DB_dsn'], $dsn['DB_options']);
    //	if (PEAR::isError($db)) {
    if (DB::isError($db)) {
        myLog($db->getMessage() . $db->getUserInfo());
        return false;
    }
    $db->setFetchMode(DB_FETCHMODE_ASSOC);
    // always set utf8
    $result = $db->query('SET NAMES utf8;');
    if (DB::isError($result)) {
        myLog('Query error:' . $result->getMessage());
        return false;
    }
    //	$result = $db->query($query);
    $result = $db->getAll($query);
    if (DB::isError($result)) {
        myLog('Query error: "' . $query . '" -> ' . $result->getMessage());
        return false;
    }
    $db->disconnect();
    return $result;
}
Example #4
0
File: go.php Project: joestump/jax
 function go()
 {
     $this->JxAuthNo();
     if ((int) $_GET['linkID'] > 0) {
         $sql = "SELECT *\n                FROM menu_links\n                WHERE contentID='" . $_GET['linkID'] . "'";
         $result = $this->db->query($sql);
         if (!DB::isError($result) && $result->numRows()) {
             $row = $result->fetchRow();
             $sql = "UPDATE menu_links\n                  SET hits=(hits + 1)\n                  WHERE contentID='" . $_GET['linkID'] . "'";
             $result = $this->db->query($sql);
             $go = $row['url'];
         }
     } elseif ((int) $_GET['categoryID'] > 0) {
         $sql = "SELECT *\n                FROM menu_categories\n                WHERE contentID='" . $_GET['linkID'] . "'";
         $result = $this->db->query($sql);
         if (!DB::isError($result) && $result->numRows()) {
             $row = $result->fetchRow();
             $sql = "UPDATE menu_categories\n                  SET hits=(hits + 1)\n                  WHERE contentID='" . $_GET['linkID'] . "'";
             $result = $this->db->query($sql);
             $go = $row['url'];
         }
     }
     if (!eregi('^http', $go)) {
         $go = $_SERVER['SCRIPT_NAME'] . $go;
     }
     header("Location: {$go}");
     exit;
 }
 /**
  * Returns true if the result set has more records
  * @return  bool  true if more records available
  */
 function hasMore() {
   if($this->pos <= $this->getLastRowNumber() + 1) { 
     return !is_null($this->current) && !DB::isError($this->current);
   } else {
     return false;
   }
 }
function log_err($file, $line, $message)
{
    global $error_level;
    // debug
    //print "<p>Error in: $file At line: $line</p>";
    //print "<p>Message: $message</p>";
    if ($error_level == 1) {
        $category = 0;
        $message = "{$message} ({$file}, {$line})";
        $dsn = array('phptype' => 'mysql', 'username' => 'cityg_8', 'password' => 'gBhpj4Xj', 'hostspec' => 'db72c.pair.com', 'database' => 'cityg_dev');
        $db =& DB::connect($dsn, $options);
        //$this->db = DB::connect($dsn);
        if (DB::isError($db)) {
            die($db->getMessage());
        }
        /**
         * /remark
         * Unix time has greater resolution than MySQL
         * datetime as far as I can tell.
         */
        $sql = "INSERT INTO event_log SET";
        $sql .= " timetamp=" . time();
        $sql .= " category=" . $db->quote($category);
        $sql .= ", message=" . $db->quote($message);
        $db->query($sql);
        if (DB::isError($db)) {
            die($db->getMessage());
        }
        //	print "<p>Error in: $file At line: $line</p>";
        //	print "<p>Message: $message</p>";
    }
}
 public function getTransactionsByUserID($user_id)
 {
     $this->db_manager->openConnection();
     $sql = "select * from Transaction where Customer_ID = {$user_id} ";
     $result = $this->db_manager->query($sql);
     if (DB::isError($result)) {
         die($result->getMessage());
     }
     while ($result->fetchInto($row)) {
         /**
          * row[0]; Transaction ID
          *
          * row[1]: Movie ID
          *
          * row[2]: Customer ID
          *
          * row[3]: Rental Date
          *
          * row[4]: Return Date
          *
          * row[5]: Cost
          */
         $this->transactions[] = new Transaction($row[0], $row[1], $row[2], $row[3], $row[4], $row[5]);
     }
     $this->db_manager->closeConnection();
     return $this->transactions;
 }
Example #8
0
 /**
  * Add new category
  *
  *    $data = array(
  *        'name'   => 'category name',
  *        'desc'   => 'category description',
  *        'parent' => 'category parent id'
  *        );
  *
  * @param array
  * @return mixed ID of the category or PEAR error object
  */
 static function add($data)
 {
     global $dbh;
     if (empty($data['name'])) {
         throw new InvalidArgumentException('no name given');
     }
     $name = $data['name'];
     $desc = empty($data['desc']) ? 'none' : $data['desc'];
     $parent = empty($data['parent']) ? null : $data['parent'];
     $sql = 'INSERT INTO categories (id, name, description, parent) VALUES (?, ?, ?, ?)';
     $id = $dbh->nextId('categories');
     $err = $dbh->query($sql, array($id, $name, $desc, $parent));
     if (DB::isError($err)) {
         return $err;
     }
     $err = renumber_visitations($id, $parent);
     if (PEAR::isError($err)) {
         return $err;
     }
     include_once 'pear-rest.php';
     $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
     $pear_rest->saveCategoryREST($name);
     $pear_rest->saveAllCategoriesREST();
     $pear_rest->savePackagesCategoryREST($name);
     return $id;
 }
 /**
  *  Delete credentials from DB
  *
  *	On error this method returning FALSE.
  *
  *  Possible options:
  *	 - none
  *	
  *
  *	@return bool
  */
 function del_credentials($uid, $did, $uname, $realm, $opt)
 {
     global $config;
     $errors = array();
     if (!$this->connect_to_db($errors)) {
         ErrorHandler::add_error($errors);
         return false;
     }
     /* table name */
     $t_name =& $config->data_sql->credentials->table_name;
     /* col names */
     $c =& $config->data_sql->credentials->cols;
     /* flags */
     $f =& $config->data_sql->credentials->flag_values;
     $q = "delete from " . $t_name . "\n\t\t      where " . $c->uid . "   = " . $this->sql_format($uid, "s") . " and\n\t\t            " . $c->uname . " = " . $this->sql_format($uname, "s") . " and\n\t\t            " . $c->realm . " = " . $this->sql_format($realm, "s");
     if ($config->auth['use_did']) {
         $q .= " and " . $c->did . " = " . $this->sql_format($did, "s");
     }
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         ErrorHandler::log_errors($res);
         return false;
     }
     return true;
 }
/**
* Function: makePagination() - creates page links
*
* @access public
* @var integer $albumID - the album to paginate
*/
function makePagination($start)
{
    global $db, $config;
    /* Get the total number of images in this album */
    $result =& $db->query('SELECT * FROM ' . TP . 'images');
    if (DB::isError($result)) {
        die($result->getMessage());
    }
    $numImages = $result->numRows();
    $out = 'Page: ';
    /* Figure out number of pages we should have */
    $totalPages = ceil($numImages / $config['imagesPP']);
    /* Figure out what page we are on */
    $current = $start / $config['imagesPP'] + 1;
    for ($i = 1; $i <= $totalPages; $i++) {
        /* If this is the current page, echo a non-link */
        if ($i == $current) {
            $out .= '<span style="font-weight: bold;">[ ' . $i . ' ]</span>&nbsp;';
            /* otherwise, echo a link to the next page */
        } else {
            /* If $i is not 1 (i.e. the first page), the link is echoed with a start variable */
            if ($i != 1) {
                $out .= '<a href="' . $_SERVER['PHP_SELF'] . '?s=images&amp;start=' . $config['imagesPP'] * ($i - 1) . '">' . $i . '</a>&nbsp;';
                /* otherwise, the link is echoed as the first page (i.e. no start) */
            } else {
                $out .= '<a href="' . $_SERVER['PHP_SELF'] . '?s=images">' . $i . '</a>&nbsp;';
            }
        }
    }
    return $out;
}
  function get_conference_name($domain) { 
    global $config,$log ; 

    if ($domain)  { 
       change_to_conference_db($this->db); 
       $q="SELECT count(*),com.company_name FROM companies com,conferences con " 
         . " WHERE com.domain='$domain' " 
         . " AND com.company_id = con.company_id GROUP BY com.company_name"; 

       $res=$this->db->query($q);
       if (DB::isError($res)) {
         $log->log("QUERY FAILED $q " . $res->getMessage());
       } 

       $row  = $res->fetchRow() ; 
       $count = $row[0] ; 
       $company_name = $row[1]; 
       $res->free(); 

       if (!$count) {
          $q = "SELECT company_name FROM companies WHERE domain='$domain' "  ; 
          $res=$this->db->query($q);
          $row = $res->fetchRow() ;
          $company_name = $row[0];
          $count  =0; 
       } 
       $count++;
       $conf_name = "$company_name Conference #$count" ; 
       $log->log("count = $count $conf_name "); 
  
       change_to_default_db($this->db);
       return $conf_name ; 
    } 
  }
Example #12
0
function autologin()
{
    if (isset($_COOKIE['user']) && isset($_COOKIE['passwd']) && isset($_COOKIE['userid'])) {
        global $db;
        $pass = $_COOKIE['passwd'];
        $user = $_COOKIE['user'];
        $userid = $_COOKIE['userid'];
        $res =& $db->query("SELECT * FROM " . db_tablename('users') . " WHERE id=" . $db->quote((int) $userid) . " AND user=" . $db->quote($user));
        if (DB::isError($res)) {
            return;
        }
        $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
        if (!isset($row['password'])) {
            return;
        }
        $passchk = md5($row['password'] . $row['salt']);
        if ($pass == $passchk) {
            $_SESSION['user'] = $row['user'];
            $_SESSION['level'] = $row['level'];
            $_SESSION['userid'] = $row['id'];
            $_SESSION['logged_in'] = 1;
            mk_cookie('user', $row['user']);
            mk_cookie('userid', $row['id']);
            mk_cookie('passwd', $passchk);
        }
    }
}
Example #13
0
 function saveLink()
 {
     print "Creating";
     $link_id = $_REQUEST['id'];
     if ($link_id == null) {
         // print "Inserting";
         // FIXME: param values must come from context
         $sql = "INSERT INTO links SET link=" . $this->db->quote($this->c->request->params['link']) . ", title=" . $this->db->quote($this->c->request->params['title']) . ", description=" . $this->db->quote($this->c->request->params['description']);
     } else {
         print "Updating";
         /*
              $sql = "UPDATE links SET link=". $this->db->quote($_POST['link']) .
                                    ", title=".$this->db->quote($_POST['title']).
                                     ", description=".$this->db->quote($_POST['description']) .
                                     " WHERE id=".$this->db->quote($_POST['id']);
         */
         // Debugging
         // print "<pre>Model Params:";
         // print_r( $_REQUEST );
         // print "</pre>";
         // print "<pre>Model Params:";
         // print_r( $this->c->request->params );
         // print "</pre>";
         $sql = "UPDATE links SET link=" . $this->db->quote($this->c->request->params['link']) . ", title=" . $this->db->quote($this->c->request->params['title']) . ", description=" . $this->db->quote($this->c->request->params['description']) . " WHERE id=" . $this->db->quote($this->c->request->params['id']);
         print $sql;
     }
     $this->db->query($sql);
     if (DB::isError($this->db)) {
         die($this->db->getMessage());
     }
 }
Example #14
0
 /**
  * Query the database.
  *
  * @param string $query the SQL query
  * @param string $type the type of query
  * @param string $format the query format
  */
 function query($query, $type = SQL_NONE, $format = SQL_INDEX)
 {
     $this->record = array();
     $_data = array();
     // Determine fetch mode (index or associative).
     $_fetchmode = $format == SQL_ASSOC ? DB_FETCHMODE_ASSOC : null;
     $this->result = $this->db->query($query);
     if (DB::isError($this->result)) {
         $this->error = $this->result->getMessage();
         return false;
     }
     switch ($type) {
         case SQL_ALL:
             // Get all the records.
             while ($_row = $this->result->fetchRow($_fetchmode)) {
                 $_data[] = $_row;
             }
             $this->result->free();
             $this->record = $_data;
             break;
         case SQL_INIT:
             // Get the first record.
             $this->record = $this->result->fetchRow($_fetchmode);
             break;
         case SQL_NONE:
         default:
             // Records will be looped over with next().
             break;
     }
     return true;
 }
Example #15
0
 public function ic2_errlog_lotate()
 {
     $ini = ic2_loadconfig();
     $error_log_num = $ini['General']['error_log_num'];
     if ($error_log_num > 0) {
         $q_table = $this->_db->quoteIdentifier($this->__table);
         $sql1 = 'SELECT COUNT(*) FROM ' . $q_table;
         $sql2 = 'SELECT MIN(occured) FROM ' . $q_table;
         $sql3 = 'DELETE FROM ' . $q_table . ' WHERE occured = ';
         while (($r1 = $this->_db->getOne($sql1)) > $error_log_num) {
             if (DB::isError($r1)) {
                 return $r1;
             }
             $r2 = $this->_db->getOne($sql2);
             if (DB::isError($r2)) {
                 return $r2;
             }
             $r3 = $this->_db->query($sql3 . $r2);
             if (DB::isError($r3)) {
                 return $r3;
             }
             if ($this->_db->affectedRows() == 0) {
                 break;
             }
         }
     }
     return DB_OK;
 }
 /**
  * Assign array with message data
  *
  * @param array $data
  */
 function perform(&$data)
 {
     if (empty($data['mid']) || empty($data['var'])) {
         trigger_error("'mid' or 'var' is empty!\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     // get var name to store the result
     $this->B->{$data}['var'] = array();
     $result =& $this->B->{$data}['var'];
     $_fields = implode(',', $data['fields']);
     if (!isset($data['fields']['enc_type'])) {
         $_fields .= ',enc_type';
     }
     $sql = "\n            SELECT\n                {$_fields}\n            FROM\n                {$this->B->sys['db']['table_prefix']}earchive_messages\n            WHERE\n                mid={$data['mid']}";
     $result = $this->B->db->getRow($sql, array(), DB_FETCHMODE_ASSOC);
     if (DB::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     // transform text to html
     if ($result['enc_type'] == 'text/plain') {
         $result['body'] = nl2br($this->_text2html($result['body']));
     }
     return TRUE;
 }
 /**
  * Assign array with message attachments data
  *
  * @param array $data
  */
 function perform(&$data)
 {
     if (empty($data['mid']) || empty($data['var'])) {
         trigger_error("'mid' or 'var' is empty!\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     // get var name to store the result
     $this->B->{$data}['var'] = array();
     $_result =& $this->B->{$data}['var'];
     $comma = '';
     foreach ($data['fields'] as $f) {
         $_fields .= $comma . $f;
         $comma = ',';
     }
     $sql = "\n            SELECT\n                {$_fields}\n            FROM\n                {$this->B->sys['db']['table_prefix']}earchive_attach\n            WHERE\n                mid={$data['mid']}            \n            ORDER BY\n                file ASC";
     $result = $this->B->db->query($sql);
     if (DB::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
     }
     $_result = array();
     if (is_object($result)) {
         while ($row = $result->FetchRow(DB_FETCHMODE_ASSOC)) {
             $tmp = array();
             foreach ($data['fields'] as $f) {
                 $tmp[$f] = stripslashes($row[$f]);
             }
             $_result[] = $tmp;
         }
     }
     return TRUE;
 }
 /**
  *	delete alias of user
  *
  *	@param string	$uid		owner of the contact 
  *	@param string	$username	username part from URI
  *	@param string	$did		domain part from URI
  *	@param string	$flags		flags of the URI
  *	@param array	$opt		various options
  *	@return bool				TRUE on success, FALSE on failure
  */
 function delete_uri($uid, $scheme, $username, $did, $flags, $opt)
 {
     global $config;
     $errors = array();
     if (!$this->connect_to_db($errors)) {
         ErrorHandler::add_error($errors);
         return false;
     }
     /* table name */
     $t_name =& $config->data_sql->uri->table_name;
     /* col names */
     $c =& $config->data_sql->uri->cols;
     /* flags */
     $f =& $config->data_sql->uri->flag_values;
     $q = "delete from " . $t_name . "\n\t\t      where " . $c->uid . "      = " . $this->sql_format($uid, "s") . " and \n\t\t            " . $c->scheme . "   = " . $this->sql_format($scheme, "s") . " and \n\t\t            " . $c->username . " = " . $this->sql_format($username, "s") . " and \n\t\t            " . $c->did . "      = " . $this->sql_format($did, "s") . " and \n\t\t            " . $c->flags . "    = " . $this->sql_format($flags, "n");
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         ErrorHandler::log_errors($res);
         return false;
     }
     if (isModuleLoaded('xxl')) {
         // get domain: $alias_d = domainname of $did
         $alias_uri = "sip:" . $username . "@" . $alias_d;
         if (false === $this->clear_proxy_xxl($alias_uri, null, $errors)) {
             ErrorHandler::add_error($errors);
             return false;
         }
     }
     return true;
 }
 /**
  * Delete email list message data and attachement folder
  *
  * @param array $data
  */
 function perform($data)
 {
     if (empty($data['mid'])) {
         return FALSE;
     }
     // get message folder and lid
     M(MOD_EARCHIVE, 'get_message', array('mid' => $data['mid'], 'var' => 'm_data', 'fields' => array('lid', 'folder')));
     // get list folder
     M(MOD_EARCHIVE, 'get_list', array('lid' => $this->B->m_data['lid'], 'var' => 'l_data', 'fields' => array('lid', 'folder')));
     // build whole path to message folder
     $path = SF_BASE_DIR . '/data/earchive/' . $this->B->l_data['folder'] . '/' . $this->B->m_data['folder'];
     if (!empty($this->B->m_data['folder']) && @is_dir($path)) {
         // delete attachements folder for this message
         commonUtil::delete_dir_tree($path);
     }
     // delete list messages
     $sql = "\n            DELETE FROM \n                {$this->B->sys['db']['table_prefix']}earchive_messages\n            WHERE\n                mid={$data['mid']}";
     $result = $this->B->db->query($sql);
     if (DB::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
     }
     // delete list messages
     $sql = "\n            DELETE FROM \n                {$this->B->sys['db']['table_prefix']}earchive_attach\n            WHERE\n                mid={$data['mid']}";
     $result = $this->B->db->query($sql);
     if (DB::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
     }
     // Delete message words from the search index
     M(MOD_EARCHIVE, 'word_indexer', array('delete_words' => TRUE, 'mid' => (int) $data['mid']));
     // Delete cache data
     M(MOD_COMMON, 'cache_delete', array('group' => 'earchive'));
     return TRUE;
 }
 function get_missed_calls_of_yesterday($uid, $opt)
 {
     global $config;
     $errors = array();
     if (!$this->connect_to_db($errors)) {
         ErrorHandler::add_error($errors);
         return false;
     }
     if ($this->db_host['parsed']['phptype'] == 'mysql') {
         $q_date = " date_format(request_timestamp, '%Y-%m-%d')=date_format(DATE_SUB(CURDATE(), INTERVAL 1 DAY), '%Y-%m-%d') ";
     } else {
         $q_date = " date_trunc('day', request_timestamp)=date_trunc('day', (CURRENT_DATE - INTERVAL '1 DAY')) ";
     }
     $q = "SELECT from_uri, sip_from, request_timestamp, sip_status  " . "FROM " . $config->data_sql->table_missed_calls . " " . "WHERE to_uid='" . $uid . "' and " . $q_date . "ORDER BY request_timestamp DESC ";
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         ErrorHandler::log_errors($res);
         return false;
     }
     $out = array();
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $out[] = $row;
     }
     $res->free();
     return $out;
 }
 /**
  *	set password for user
  */
 function set_password_to_user($user, $passwd, &$errors)
 {
     global $config;
     if (!$this->connect_to_db($errors)) {
         return false;
     }
     /* table name */
     $t_name =& $config->data_sql->credentials->table_name;
     /* col names */
     $c =& $config->data_sql->credentials->cols;
     /* flags */
     $f =& $config->data_sql->credentials->flag_values;
     $ha1 = md5($user->get_username() . ":" . $user->get_realm() . ":" . $passwd);
     $ha1b = md5($user->get_username() . "@" . $user->get_realm() . ":" . $user->get_realm() . ":" . $passwd);
     if (!$config->clear_text_pw) {
         $passwd = "";
     }
     $q = "update " . $t_name . " \n\t\t    set " . $c->password . " = " . $this->sql_format($passwd, "s") . ", \n\t\t\t    " . $c->ha1 . "      = " . $this->sql_format($ha1, "s") . ", \n\t\t\t\t" . $c->ha1b . "     = " . $this->sql_format($ha1b, "s") . "\n\t\t\twhere " . $c->uid . "   = " . $this->sql_format($user->get_uid(), "s") . " and\n\t\t\t      " . $c->uname . " = " . $this->sql_format($user->get_username(), "s") . " and\n\t\t\t\t  " . $c->realm . " = " . $this->sql_format($user->get_realm(), "s");
     if ($config->auth['use_did']) {
         $q .= " and " . $c->did . " = " . $this->sql_format($user->get_did(), "s");
     }
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         log_errors($res, $errors);
         return false;
     }
     return true;
 }
Example #22
0
  function mailbox_exists ($mailbox) {
    global $log; 
    if (!$mailbox) { 
      return false; 
    } 
    $voicemail_db = get_voicemail_db($this->db, $this->udomain);
    change_db($this->db, $voicemail_db);
    $q = "SELECT count(extension) " . 
         " FROM VM_Users  WHERE extension = " . $mailbox;
                                                                                                                                               
     $res = $this->db->query($q);
                                                                                                                                               
     if (DB::isError($res)) {
          $log->log("FAILED QUERY : $q",LOG_ERR);
          change_to_default_db($this->db);
           
          return false;
     }
     $row =  $res->fetchRow(DB_FETCHMODE_ORDERED) ;
     $res->free();
     change_to_default_db($this->db);

     $count = $row[0]; 
     if ($count == 1)  {
       return true; 
     } else {
       return false; 
     } 
  } 
Example #23
0
function dberror($result)
{
    if (DB::isError($result)) {
        $errorMessage = $result->getMessage();
        die($errorMessage);
    }
}
Example #24
0
 function render()
 {
     $user =& JxSingleton::factory('user');
     $template =& new JxTemplate(JX_BASE_PATH . '/modules/content/tpl');
     $templateFile = 'JxAdminStatus.tpl';
     if ((int) $_GET['contentID'] > 0) {
         $sql = "SELECT *\n                FROM content \n                WHERE contentID='" . $_GET['contentID'] . "'";
         $record = $this->db->getRow($sql);
         if (DB::isError($record)) {
             $this->templateFile = 'noperms.tpl';
             return false;
         }
         if ($record['w'] || $user->userID == $record['userID']) {
             $sql = "UPDATE content\n                  SET available='" . $_GET['available'] . "'\n                  WHERE contentID='" . $_GET['contentID'] . "'";
             $result = $this->db->query($sql);
             if (!DB::isError($result)) {
                 $template->assign('msg', 'Status has been updated!');
             } else {
                 $template->assign('msg', 'ERROR: status has not been updated!');
             }
         } else {
             $template->assign('msg', 'ERROR: you have no perms!');
         }
     }
     return $template->fetch($templateFile);
 }
 /**
  *  Enable or disable domain
  *
  *  Possible options:
  *
  *    did		(int)   	default: null
  *      id of domain which will be en/disabled
  *      this option is REQUIRED
  *      
  *    disable	(bool)  	default: false
  *      if true domain will be disabled, otherwise wil be enabled
  *      
  *	@param array $opt		associative array of options
  *	@return bool			TRUE on success, FALSE on failure
  */
 function enable_domain($opt)
 {
     global $config;
     $errors = array();
     if (!$this->connect_to_db($errors)) {
         ErrorHandler::add_error($errors);
         return false;
     }
     /* table's name */
     $td_name =& $config->data_sql->domain->table_name;
     /* col names */
     $cd =& $config->data_sql->domain->cols;
     /* flags */
     $fd =& $config->data_sql->domain->flag_values;
     $o_did = isset($opt['did']) ? $opt['did'] : null;
     $o_disable = isset($opt['disable']) ? $opt['disable'] : false;
     if (is_null($o_did)) {
         ErrorHandler::log_errors(PEAR::raiseError('domain for en/disable is not specified'));
         return false;
     }
     $q = "update " . $td_name . " set ";
     if ($o_disable) {
         $q .= $cd->flags . " = " . $cd->flags . " | " . $fd['DB_DISABLED'];
     } else {
         $q .= $cd->flags . " = " . $cd->flags . " & ~" . $fd['DB_DISABLED'];
     }
     $q .= " where " . $cd->did . " = " . $this->sql_format($o_did, "s");
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         ErrorHandler::log_errors($res);
         return false;
     }
     return true;
 }
 /**
  *  return array of domain ids which can administer given user
  *
  *
  *  Possible options:
  *	 - none
  *      
  *	@param string $uid		
  *	@param array $opt		associative array of options
  *	@return array			array of domain ids or FALSE on error
  */
 function get_domains_of_admin($uid, $opt)
 {
     global $config;
     $errors = array();
     if (!$this->connect_to_db($errors)) {
         ErrorHandler::add_error($errors);
         return false;
     }
     /* table's name */
     $t_name =& $config->data_sql->domain_attrs->table_name;
     /* col names */
     $c =& $config->data_sql->domain_attrs->cols;
     /* flags */
     $f =& $config->data_sql->domain_attrs->flag_values;
     $an =& $config->attr_names;
     $q = "select " . $c->did . " \n\t\t    from " . $t_name . "\n\t\t\twhere  " . $c->name . "  = '" . $an['admin'] . "' and \n\t\t\t       " . $c->value . " = " . $this->sql_format($uid, "s") . " and \n\t\t\t      (" . $c->flags . " & " . $f['DB_DELETED'] . ") = 0 and\n\t\t\t\t  (" . $c->flags . " & " . $f['DB_FOR_SERWEB'] . ") = " . $f['DB_FOR_SERWEB'];
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         ErrorHandler::log_errors($res);
         return false;
     }
     $out = array();
     for ($i = 0; $row = $res->fetchRow(DB_FETCHMODE_ASSOC); $i++) {
         $out[$i] = $row[$c->did];
     }
     $res->free();
     return $out;
 }
Example #27
0
 /**
  * Constructor.
  */
 function WikiDB_backend_PearDB_mysql($dbparams)
 {
     $this->WikiDB_backend_PearDB($dbparams);
     //$this->_serverinfo = $this->_dbh->ServerInfo();
     $row = $this->_dbh->GetOne("SELECT version()");
     if (!DB::isError($row) and !empty($row)) {
         $arr = explode('.', $row);
         $this->_serverinfo['version'] = (string) ($arr[0] * 100 + $arr[1]) . "." . (int) $arr[2];
         if ($this->_serverinfo['version'] < 323.0) {
             // Older MySQL's don't have CASE WHEN ... END
             $this->_expressions['maxmajor'] = "MAX(IF(minor_edit=0,version,0))";
             $this->_expressions['maxminor'] = "MAX(IF(minor_edit<>0,version,0))";
         }
         // esp. needed for utf databases
         if ($this->_serverinfo['version'] > 401.0) {
             global $charset;
             $aliases = array('iso-8859-1' => 'latin1', 'utf-8' => 'utf8');
             //http://dev.mysql.com/doc/mysql/en/charset-connection.html
             if (isset($aliases[strtolower($charset)])) {
                 // mysql needs special unusual names and doesn't resolve aliases
                 mysql_query("SET NAMES '" . $aliases[$charset] . "'");
             } else {
                 mysql_query("SET NAMES '{$charset}'");
             }
         }
     }
 }
Example #28
0
 function get_VM($user, $mid, &$errors)
 {
     global $config, $lang_str;
     if (!$this->connect_to_db($errors)) {
         return false;
     }
     $q = "select subject, file from " . $config->data_sql->table_voice_silo . " where mid=" . $mid . " and " . $this->get_indexing_sql_where_phrase_uri($user);
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         log_errors($res, $errors);
         return false;
     }
     if (!$res->numRows()) {
         $errors[] = $lang_str['err_voice_msg_not_found'];
         return false;
     }
     $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
     $res->free();
     @($fp = fopen($config->voice_silo_dir . $row->file, 'r'));
     if (!$fp) {
         $errors[] = $lang_str['err_can_not_open_message'];
         return false;
     }
     Header("Content-Disposition: attachment;filename=" . RawURLEncode(($row->subject ? $row->subject : "received message") . ".wav"));
     Header("Content-type: audio/wav");
     @fpassthru($fp);
     @fclose($fp);
     return true;
 }
 /**
  *	get all versions of file specific for domain
  *
  *  Possible options parameters:
  *		none
  *
  *	@param string $did		domain id
  *	@param string $file		filename (with path)
  *	@param array $opt		associative array of options
  *	@return array			array of versions of file or FALSE on failure
  */
 function get_file_versions($did, $file, $opt)
 {
     global $config;
     $errors = array();
     if (!$this->connect_to_db($errors)) {
         ErrorHandler::add_error($errors);
         return false;
     }
     /* table's name */
     $td_name =& $config->data_sql->domain_settings->table_name;
     /* col names */
     $cd =& $config->data_sql->domain_settings->cols;
     /* flags */
     $fd =& $config->data_sql->domain_settings->flag_values;
     $q = "select " . $cd->version . ", " . $cd->timestamp . ", " . $cd->flags . " \n\t\t      from " . $td_name . " \n\t\t\t  where " . $cd->did . " = " . $this->sql_format($did, "s") . " and\n\t\t\t        " . $cd->filename . " = " . $this->sql_format($file, "s");
     $res = $this->db->query($q);
     if (DB::isError($res)) {
         ErrorHandler::log_errors($res);
         return false;
     }
     $out = array();
     while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
         $out[$row[$cd->version]]['timestamp'] = $row[$cd->timestamp];
         $out[$row[$cd->version]]['deleted'] = (bool) ($row[$cd->flags] & $fd["DB_DELETED"]);
         $out[$row[$cd->version]]['dir'] = (bool) ($row[$cd->flags] & $fd["DB_DIR"]);
     }
     $res->free();
     return $out;
 }
Example #30
0
 function __destruct()
 {
     if (DB::isError($this->db)) {
         die('Could not connect to database!');
     }
     $this->db->disconnect();
 }