function verifyPayment(&$pPaymentParameters, &$pOrder) { global $gCommerceSystem; unset($_SESSION[$this->code . '_error']); if (!empty($pPaymentParameters['cc_ref_id'])) { // reference transation $this->cc_ref_id = $pPaymentParameters['cc_ref_id']; } elseif (empty($pPaymentParameters['cc_number'])) { $this->mErrors['number'] = tra('Please enter a credit card number.'); } elseif ($this->verifyCreditCard($pPaymentParameters['cc_number'], $pPaymentParameters['cc_expires_month'], $pPaymentParameters['cc_expires_year'], $pPaymentParameters['cc_cvv'])) { if (empty($pPaymentParameters['cc_owner'])) { $this->mErrors['owner'] = tra('Please enter the name card holders name as it is written on the card.'); } else { $this->cc_owner = $pPaymentParameters['cc_owner']; } if (preg_match('/^37/', $pPaymentParameters['cc_number']) && BitBase::getParameter($pOrder->info, 'currency', $gCommerceSystem->getConfig('DEFAULT_CURRENCY')) != 'USD') { $this->mErrors['number'] = tra('American Express cannot process transactions in currencies other than USD. Change the currency in your cart, or use a different card.'); } } $this->saveSessionDetails(); if ($this->mErrors) { $_SESSION[$this->code . '_error'] = $this->mErrors; } return count($this->mErrors) === 0; }
/** * Load the data from the database * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash **/ function load() { if ($this->verifyId($this->mBitForumTopicId) || $this->verifyId($this->mContentId)) { // LibertyContent::load()assumes you have joined already, and will not execute any sql! // This is a significant performance optimization $lookupColumn = $this->verifyId($this->mBitForumTopicId) ? 'bitforum_topic_id' : 'content_id'; $bindVars = array(); $selectSql = $joinSql = $whereSql = ''; array_push($bindVars, $lookupId = @BitBase::verifyId($this->mBitForumTopicId) ? $this->mBitForumTopicId : $this->mContentId); $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); $query = "SELECT bft.*, lc.*, uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name, uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name {$selectSql} \n\t\t\tFROM `" . BIT_DB_PREFIX . "bitforums_topics` bft \n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = bft.`content_id` ) {$joinSql}\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON( uuc.`user_id` = lc.`user_id` )\n\t\t\tWHERE bft.`{$lookupColumn}`=? {$whereSql}"; $result = $this->mDb->query($query, $bindVars); if ($result && $result->numRows()) { $this->mInfo = $result->fields; $this->mContentId = $result->fields['content_id']; $this->mBitForumTopicId = $result->fields['bitforum_topic_id']; $this->mInfo['creator'] = isset($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user']; $this->mInfo['editor'] = isset($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user']; $this->mInfo['display_url'] = $this->getDisplayUrl(); $this->mInfo['parsed_data'] = $this->parseData(); LibertyAttachable::load(); } } return count($this->mInfo); }
/** * expunge * * @param numeric $pContentId * @access public * @return ADO result set on success, FALSE on failure */ function expunge($pContentId) { if (@BitBase::verifyId($pContentId)) { $query = "DELETE FROM `" . BIT_DB_PREFIX . "semaphore` WHERE `content_id` = ?"; $this->mDb->query($query, array($pContentId)); } }
function load($pGmapId = NULL) { global $gBitSystem; if (!empty($this->mOverlaySetId) || !empty($this->mContentId)) { $lookupColumn = !empty($this->mOverlaySetId) ? 'set_id' : 'content_id'; $bindVars = array(); $selectSql = ''; $joinSql = ''; $whereSql = ''; array_push($bindVars, $lookupId = @BitBase::verifyId($this->mOverlaySetId) ? $this->mOverlaySetId : $this->mContentId); if (!empty($pGmapId) && is_numeric($pGmapId) && $this->mOverlaySetType != NULL) { $selectSql = ", osk.*"; $joinSql = "LEFT JOIN `" . BIT_DB_PREFIX . "gmaps_sets_keychain` osk ON ( osk.`set_id` = os.`set_id` )"; $whereSql = "AND osk.`gmap_id` = ? AND osk.`set_type` = ?"; $bindVars = array_merge($bindVars, array($pGmapId, $this->mOverlaySetType)); } $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); $query = "select os.*, lc.*,\n\t\t\t\t\t uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\t\t uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name {$selectSql}\n\t\t\t\t\t FROM `" . BIT_DB_PREFIX . $this->mOverlaySetTable . "` os\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_id` = os.`content_id`) {$joinSql}\n\t\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON (uue.`user_id` = lc.`modifier_user_id`)\n\t\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON (uuc.`user_id` = lc.`user_id`)\n\t\t\t\t\t WHERE os.`{$lookupColumn}`=? {$whereSql}"; $result = $this->mDb->query($query, $bindVars); if ($result && $result->numRows()) { $this->mInfo = $result->fields; $this->mInfo['gmap_id'] = $pGmapId; $this->mOverlaySetId = $result->fields['set_id']; $this->mContentId = $result->fields['content_id']; } } return count($this->mInfo); }
/** * Load Function */ function data_toc($pData, $pParams) { include_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; global $gStructure, $gContent, $gBitSmarty; if (is_object($gStructure) && $gStructure->isValid()) { $struct =& $gStructure; } elseif (@BitBase::verifyId($pParams['structure_id'])) { $struct = new LibertyStructure($pParams['structure_id']); $struct->load(); } elseif (is_object($gContent)) { $structures = $gContent->getStructures(); // We take the first structure. not good, but works for now - spiderr if (!empty($structures[0])) { require_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; $struct = new LibertyStructure($structures[0]['structure_id']); $struct->load(); } } $repl = ' '; if (!empty($struct) && is_object($struct) && $struct->isValid()) { if (@BitBase::verifyId($structure_id)) { $get_structure = $structure_id; } else { $get_structure = $struct->mStructureId; } $tree = $struct->getSubTree($get_structure, !empty($pParams['display']) && $pParams['display'] == 'full_toc'); $gBitSmarty->assign("subtree", $tree); $repl = $gBitSmarty->fetch("bitpackage:liberty/plugins/data_toc.tpl"); } return $repl; }
/** * smarty_function_captcha */ function smarty_function_captcha($pParams, &$gBitSmarty) { global $gBitSystem, $gBitUser; if (!empty($pParams['force']) || empty($_SESSION['captcha_verified']) && !$gBitUser->hasPermission('p_users_bypass_captcha')) { $pParams['size'] = !empty($pParams['size']) ? $pParams['size'] : '5'; $pParams['variant'] = !empty($pParams['variant']) ? $pParams['variant'] : 'condensed'; if (!empty($pParams['errors'])) { $gBitSmarty->assign('errors', $pParams['errors']); } if ($gBitSystem->isFeatureActive('liberty_use_captcha_freecap')) { $pParams['source'] = UTIL_PKG_URL . "freecap/freecap.php"; } else { $getString = 'size=' . $pParams['size']; if (@BitBase::verifyId($pParams['width'])) { $getString .= '&width=' . $pParams['width']; } if (@BitBase::verifyId($pParams['height'])) { $getString .= '&height=' . $pParams['height']; } $pParams['source'] = USERS_PKG_URL . "captcha_image.php?{$getString}"; } $gBitSmarty->assign('params', $pParams); print $gBitSmarty->fetch("bitpackage:kernel/captcha.tpl"); } }
/** * Load an IRList content Item * * (Describe IRList object here ) */ function load($pContentId = NULL) { if ($pContentId) { $this->mContentId = (int) $pContentId; } if (@$this->verifyId($this->mIRId) || @$this->verifyId($this->mContentId)) { $lookupColumn = @$this->verifyId($this->mIRId) ? 'ir_id' : 'content_id'; $bindVars = array(); $selectSql = ''; $joinSql = ''; $whereSql = ''; array_push($bindVars, $lookupId = @BitBase::verifyId($this->mIRId) ? $this->mIRId : $this->mContentId); $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); $query = "select ir.*, lc.*,\r\n\t\t\t\tuue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\r\n\t\t\t\tuuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name,\r\n\t\t\t\tuux.`login` AS closed_user, uuc.`real_name` AS closed_real_name\r\n\t\t\t\t{$selectSql}\r\n\t\t\t\tFROM `" . BIT_DB_PREFIX . "irlist_secondary` ir\r\n\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON ( lc.`content_id` = ir.`content_id` ) {$joinSql}\r\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON (uue.`user_id` = lc.`modifier_user_id`)\r\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON (uuc.`user_id` = lc.`user_id`)\r\n\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uux ON (uux.`user_id` = ir.`closed_user_id`)\r\n\t\t\t\tWHERE ir.`{$lookupColumn}`=? {$whereSql}"; $result = $this->mDb->query($query, $bindVars); if ($result && $result->numRows()) { $this->mInfo = $result->fields; $this->mContentId = (int) $result->fields['content_id']; $this->mIRId = (int) $result->fields['ir_id']; $this->mIRName = $result->fields['title']; $this->mInfo['creator'] = isset($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user']; $this->mInfo['editor'] = isset($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user']; $this->mInfo['display_url'] = $this->getDisplayUrl(); } } LibertyContent::load(); return; }
function __construct($pUprn) { parent::__construct(); if (is_numeric($pUprn)) { $this->mUprn = $pUprn; } }
/** * attachment_filter_expunge * * @param string $pString * @param array $pFilterHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function attachment_filter_expunge($pString, &$pFilterHash) { global $gBitSystem; if (@BitBase::verifyId($pFilterHash['content_id'])) { $gBitSystem->mDb->query("DELETE FROM `" . BIT_DB_PREFIX . "liberty_attachment_usage` WHERE `content_id` = ?", array($pFilterHash['content_id'])); } }
function storePayment(&$pParamHash) { $this->StartTrans(); if ($this->verifyPayment($pParamHash)) { if (@BitBase::verifyId($pParamHash['commissions_payments_id'])) { $this->mDb->associateUpdate(TABLE_COMMISSIONS_PAYMENTS, $pParamHash['payment_store'], array('commissions_payments_id' => $pParamHash['commissions_payments_id'])); } else { $pParamHash['commissions_payments_id'] = $this->mDb->GenID('com_commissions_payments_id_seq'); $pParamHash['payment_store']['commissions_payments_id'] = $pParamHash['commissions_payments_id']; $this->mDb->associateInsert(TABLE_COMMISSIONS_PAYMENTS, $pParamHash['payment_store']); } switch ($pParamHash['payment_store']['payment_method']) { case 'storecredit': if ($this->mDb->getAssoc("SELECT * FROM " . TABLE_COUPON_GV_CUSTOMER . " WHERE `customer_id`=?", array($pParamHash['payment_store']['payee_user_id']))) { $this->mDb->query("UPDATE " . TABLE_COUPON_GV_CUSTOMER . " SET `amount`=`amount`+? WHERE `customer_id`=?", array($pParamHash['payment_store']['payment_amount'], $pParamHash['payment_store']['payee_user_id'])); } else { $this->mDb->query("INSERT INTO " . TABLE_COUPON_GV_CUSTOMER . " (`amount`,`customer_id`) VALUES (?,?)", array($pParamHash['payment_store']['payment_amount'], $pParamHash['payment_store']['payee_user_id'])); } break; default: break; } $this->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } return count($this->mErrors) == 0; }
public static function prepGetList(&$pListHash) { if (!empty($pListHash['period'])) { $pListHash['period_format'] = BitDb::getPeriodFormat($pListHash['period']); } parent::prepGetList($pListHash); }
/** * Delete entry(ies) from liberty_content_role_map table with content_id. * * @param object $pContent */ function expunge($ContentId = NULL) { $ret = FALSE; if (@BitBase::verifyId($ContentId)) { $this->mDb->query("DELETE FROM `" . BIT_DB_PREFIX . "liberty_content_role_map` WHERE `content_id`=?", array($ContentId)); } return $ret; }
function __construct() { global $gBitDb; parent::__construct(); $this->currencies = array(); $currencies_query = "SELECT `code` AS `hash_key`, * FROM " . TABLE_CURRENCIES; $this->currencies = $this->mDb->getAssoc($currencies_query); }
function __construct($pCategoryId = NULL, $pContentId = NULL) { parent::__construct(); if (is_numeric($pCategoryId)) { $this->mCategoryId = $pCategoryId; $this->load(); } }
/** * Initiate class * * @return void */ function __construct() { global $gBitSystem; parent::__construct(); // table order is important due to constraints $this->mTables = array('packager_packages', 'packager_versions', 'packager_licenses', 'packager_types', 'packager_changelogs', 'packager_dependencies'); $this->mHost = $gBitSystem->getConfig('packager_rem_host', 'www.bitweaver.org'); }
function currency_yahoo_quote($code, $base = DEFAULT_CURRENCY) { global $gYahooCurrencies; $ret = FALSE; if (empty($gYahooCurrencies)) { currency_yahoo_load($base); } return BitBase::getParameter($gYahooCurrencies, strtoupper($base . $code)); }
function feed_get_status($pListHash) { global $gBitDb; $whereSql = ''; $bindVars = array(); $statuses = array(); BitBase::prepGetList($pListHash); if (!empty($pListHash['user_id'])) { $whereSql = " WHERE lal.user_id = ? "; $bindVars[] = $pListHash['user_id']; } else { $whereSql = "WHERE 1=1 "; } $query = "SELECT lal.content_id, lal.user_id, lal.log_message, MAX(lal.last_modified) AS last_modified, lc.data, uu.login, uu.real_name, uu.email\n\t\t\t FROM liberty_action_log lal\n\t\t\t INNER JOIN liberty_content lc ON (lc.content_id=lal.content_id)\n\t\t\t INNER JOIN liberty_comments lcs ON (lcs.content_id = lc.content_id)\n\t\t\t INNER JOIN users_users uu ON (uu.user_id=lal.user_id)\n\t\t\t {$whereSql} AND lc.content_type_guid = 'feedstatus'\n\t\t\t GROUP BY lal.content_id, lal.user_id, uu.login, uu.real_name, uu.email, lal.log_message,lc.data\n\t\t\t ORDER BY MAX(lal.last_modified) DESC"; $res = $gBitDb->query($query, $bindVars, $pListHash['max_records']); $user = new BitUser($pListHash['user_id']); $user->load(); while ($status = $res->fetchRow()) { $avatarUrl = $user->getThumbnailUrl(); if (empty($avatarUrl)) { $avatarUrl = USERS_PKG_URI . "icons/silhouette.png"; } $status['feed_icon_url'] = $avatarUrl; $comment = new LibertyComment(NULL, $status['content_id']); $replies = $comment->getComments($status['content_id'], null, null, 'commentDate_asc'); $status['replies'] = $replies; foreach ($status['replies'] as &$reply) { $replyUser = new BitUser($reply['user_id']); $replyUser->load(); $replyAvatarUrl = $replyUser->getThumbnailUrl(); if (empty($replyAvatarUrl)) { $replyAvatarUrl = USERS_PKG_URI . "icons/silhouette.png"; } $reply['feed_icon_url'] = $replyAvatarUrl; } //after loading up the thumbnails in the prior array layout for ease, we break up the array to split long comment threads $MAX_SHOWN_REPLIES = 3; if (count($status['replies']) > $MAX_SHOWN_REPLIES) { $maxIteration = count($status['replies']) - $MAX_SHOWN_REPLIES; $i = 0; foreach ($status['replies'] as $excess) { if ($i < $maxIteration) { $status['replies_excess'][$excess['content_id']] = $excess; //use content_id to index for consistency with normal replies array unset($status['replies'][$excess['content_id']]); //remove from the normal replies array } else { break; } $i++; } } $statuses[] = $status; } return $statuses; }
function existing_files_store(&$pStoreRow) { global $gBitSystem, $gContent; if (@BitBase::verifyId($gContent->mContentId)) { // Update the attachments content_id $query = "UPDATE `" . BIT_DB_PREFIX . "liberty_attachments` SET " . "content_id = ? WHERE attachment_id = ?"; $result = $gContent->mDb->query($query, array($gContent->mContentId, $pStoreRow['attachment_id'])); } return TRUE; }
/** * BitGameSystem During initialisation, be sure to call our base constructors * * @param string $pGame * @access public * @return void */ function __construct($pGameType = NULL) { parent::__construct(); if (!empty($pGameType) && ($gameType = $this->isActiveGameType($pGameType))) { global $gBitSystem; $game = $this->mGameTypes[$pGameType]; require_once '../' . $gBitSystem->mPackages[$game['package']]['dir'] . "/" . $game['handler_file']; $gameClass = $game['class']; $this->mGame = new $gameClass(); } }
function getProductObject($pProductsMixed) { $productsId = zen_get_prid($pProductsMixed); if (BitBase::verifyId($productsId)) { if (!isset($this->mProductObjects[$productsId])) { if ($this->mProductObjects[$productsId] = bc_get_commerce_product($productsId)) { $ret =& $this->mProductObjects[$productsId]; } } } return $this->mProductObjects[$productsId]; }
/** * Store the data in the database * * @param array $pStoreRow File data needed to store details in the database - sanitised and generated in the verify function * @access public * @return TRUE on success, FALSE on failure - $pStoreRow[errors] will contain reason */ function mime_pbase_store(&$pStoreRow) { global $gBitSystem; $ret = FALSE; if (@BitBase::verifyId($pStoreRow['pbase_id'])) { // add the data into liberty_attachments to make this file available as attachment $storeHash = array("attachment_id" => $pStoreRow['attachment_id'], "content_id" => $pStoreRow['content_id'], "attachment_plugin_guid" => PLUGIN_MIME_GUID_PBASE, "foreign_id" => $pStoreRow['pbase_id'], "user_id" => $pStoreRow['user_id']); $gBitSystem->mDb->associateInsert(BIT_DB_PREFIX . "liberty_attachments", $storeHash); $ret = TRUE; } else { $pStoreRow['errors']['pbase_id'] = "No valid PBase ID given."; } return $ret; }
public function __construct($pPidId = NULL, $pConfig = array()) { if (!empty($pPidId)) { // set id $this->mPid = $pPidId; // log file path $this->mLogFile = PHPASYNC_TEMP_DIR . '/' . $this->mPid; } // set default config values $this->mConfig = array('append_log' => FALSE, 'max_execution_time' => "1200", 'memory_limit' => '128M', 'no-gzip' => 1, 'zlib.output_compression' => 0, 'ignore_user_abort' => FALSE); // override default config if (!empty($pConfig)) { extract_to($pConfig, $this->mConfig, EXTR_IF_EXISTS); } parent::__construct(); }
function __construct() { $this->code = 'demo'; parent::__construct(); if (!empty($_GET['main_page'])) { $this->title = ''; // Payment Module title in Catalog } else { $this->title = tra('Demo'); // Payment Module title in Admin } $this->description = tra('Demo Fulfillment<br/><a href="' . PRODUCTS_PKG_URL . 'admin/accounting/index.php?fulfillment_code=demo">Accounting</a>'); $this->sort_order = 5; $this->enabled = defined('MODULE_FULFILLMENT_DEMO_STATUS') && MODULE_FULFILLMENT_DEMO_STATUS == 'True' ? true : false; $this->mPartsList = array('123' => 'Acme 123 Widget'); }
/** * mime_flash_store_preferences * * @param array $pFileHash Flash information * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function mime_flash_store_preferences(&$pFileHash) { $ret = FALSE; if (@BitBase::verifyId($pFileHash['attachment_id'])) { list($pFileHash['preferences']['width'], $pFileHash['preferences']['height'], $type, $attr) = getimagesize(STORAGE_PKG_PATH . $pFileHash['upload']['dest_branch'] . $pFileHash['upload']['name']); // store width of video if (!empty($pFileHash['preferences']['width'])) { LibertyMime::storeAttachmentPreference($pFileHash['attachment_id'], 'width', $pFileHash['preferences']['width']); } // store height of video if (!empty($pFileHash['preferences']['height'])) { LibertyMime::storeAttachmentPreference($pFileHash['attachment_id'], 'height', $pFileHash['preferences']['height']); } $ret = TRUE; } return $ret; }
/** * Given a content_id, this will return and object of the proper type * * @param integer content_id of the object to be returned * @param string optional content_type_guid of pConId. This will save a select if you happen to have this info. If not, this method will look it up for you. * @param call load on the content. Defaults to true. * @returns object of the appropriate content type class */ public static function getLibertyObject($pContentId, $pContentGuid = NULL, $pLoadContent = TRUE) { $ret = NULL; global $gLibertySystem, $gBitUser, $gBitSystem; if (BitBase::verifyId($pContentId)) { // remove non integer bits from structure_id and content_id requests // can happen with period's at the end of url's that are email'ed around $pContentId = preg_replace('/[\\D]/', '', $pContentId); if (empty($pContentGuid)) { $pContentGuid = $gLibertySystem->mDb->getOne("SELECT `content_type_guid` FROM `" . BIT_DB_PREFIX . "liberty_content` WHERE `content_id`=?", array($pContentId)); } if (!empty($pContentGuid) && isset($gLibertySystem->mContentTypes[$pContentGuid]) && ($typeClass = $gLibertySystem->getContentClassName($pContentGuid))) { $creator = new $typeClass(); $ret = $creator->getNewObject($typeClass, $pContentId, $pLoadContent); } } return $ret; }
function getProductHistory($pListHash) { $whereSql = ''; $bindVars = array(); if (@BitBase::verifyId($pListHash['products_id'])) { $whereSql = 'cop.`products_id`=?'; $bindVars[] = $pListHash['products_id']; } if (@BitBase::verifyId($pListHash['user_id'])) { $whereSql = 'lc.`user_id`=?'; $bindVars[] = $pListHash['user_id']; } if ($whereSql) { $sql = "SELECT cop.`orders_products_id` AS `hash_key`, co.*, cop.*," . $this->mDb->SQLDate('Y-m-d H:i', 'co.`date_purchased`') . " AS `purchase_time` \n\t\t\t\t\tFROM " . TABLE_ORDERS . " co \n\t\t\t\t\t\tINNER JOIN " . TABLE_ORDERS_PRODUCTS . " cop ON(co.`orders_id`=cop.`orders_id`)\n\t\t\t\t\t\tLEFT OUTER JOIN " . TABLE_PRODUCTS . " cp ON(cp.`products_id`=cop.`products_id`)\n\t\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON(lc.`content_id`=cp.`content_id`)\n\t\t\t\t\tWHERE {$whereSql}\n\t\t\t\t\tORDER BY co.`orders_id` DESC"; $ret = $this->mDb->getAssoc($sql, $bindVars); } return $ret; }
function smarty_function_displayname($pParams, &$gBitSmarty) { global $gBitUser; if (!empty($pParams['hash'])) { if (is_array($pParams['hash'])) { $hash = array_merge($pParams, $pParams['hash']); unset($hash['hash']); // if the hash only has a user_id, we need to look up the user if (@BitBase::verifyId($hash['user_id']) && empty($hash['user']) && empty($hash['email']) && empty($hash['login'])) { $lookupHash['user_id'] = $hash['user_id']; } } else { // We were probably just passed the 'login' due to legacy code which has yet to be converted if (strpos('@', $pParams['hash'])) { $lookupHash['email'] = $hash; } elseif (is_numeric($pParams['hash'])) { $lookupHash['user_id'] = $hash; } else { $lookupHash['login'] = $hash; } } } elseif (!empty($pParams['user_id'])) { $lookupHash['user_id'] = $pParams['user_id']; } elseif (!empty($pParams['email'])) { $lookupHash['email'] = $pParams['email']; } elseif (!empty($pParams['login'])) { $lookupHash['login'] = $pParams['login']; } elseif (!empty($pParams['user'])) { $lookupHash['login'] = $pParams['user']; } elseif (empty($pParams)) { global $gBitUser; $hash = $gBitUser->mInfo; } if (!empty($lookupHash)) { $hash = $gBitUser->getUserInfo($lookupHash); } if (!empty($hash)) { $displayName = BitUser::getDisplayNameFromHash(empty($pParams['nolink']), $hash); } else { // Now we're really in trouble. We don't even have a user_id to work with $displayName = "Unknown"; } return $displayName; }
function bit_files_store(&$pStoreRow) { global $gBitSystem, $gBitUser; $ret = NULL; // we have been given an attachment_id but no foreign_id. we will make a last attempt to see if this is an update or an insert if (@BitBase::verifyId($pStoreRow['attachment_id']) && !@BitBase::verifyId($pStoreRow['foreign_id'])) { $pStoreRow['foreign_id'] = $gBitSystem->mDb->getOne("SELECT `foreign_id` FROM `" . BIT_DB_PREFIX . "liberty_attachments` WHERE `attachment_id` = ?", array($pStoreRow['attachment_id'])); } if (@BitBase::verifyId($pStoreRow['foreign_id'])) { $sql = "UPDATE `" . BIT_DB_PREFIX . "liberty_files` SET `file_name`=?, `mime_type`=?, `file_size`=? WHERE `file_id` = ?"; $gBitSystem->mDb->query($sql, array($pStoreRow['upload']['name'], $pStoreRow['upload']['type'], $pStoreRow['upload']['size'], $pStoreRow['foreign_id'])); } else { $pStoreRow['foreign_id'] = $gBitSystem->mDb->GenID('liberty_files_id_seq'); $sql = "INSERT INTO `" . BIT_DB_PREFIX . "liberty_files` ( `file_name`, `file_id`, `mime_type`, `file_size`, `user_id` ) VALUES ( ?, ?, ?, ?, ? )"; $userId = !empty($pStoreRow['upload']['user_id']) ? $pStoreRow['upload']['user_id'] : $gBitUser->mUserId; $gBitSystem->mDb->query($sql, array($pStoreRow['upload']['name'], $pStoreRow['foreign_id'], $pStoreRow['upload']['type'], $pStoreRow['upload']['size'], $userId)); } return $ret; }
function load() { if (!empty($this->mOverlayId) || !empty($this->mContentId)) { // LibertyContent::load()assumes you have joined already, and will not execute any sql! // This is a significant performance optimization $overlayKey = $this->mOverlayType . '_id'; $lookupColumn = !empty($this->mOverlayId) ? $overlayKey : 'content_id'; $bindVars = array(); $selectSql = ''; $joinSql = ''; $whereSql = ''; array_push($bindVars, $lookupId = @BitBase::verifyId($this->mOverlayId) ? $this->mOverlayId : $this->mContentId); $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); $query = "select ot.*, lc.*,\n\t\t\t\t\t uue.`login` AS modifier_user, uue.`real_name` AS modifier_real_name,\n\t\t\t\t\t uuc.`login` AS creator_user, uuc.`real_name` AS creator_real_name {$selectSql}\n\t\t\t\t\t FROM `" . BIT_DB_PREFIX . $this->mOverlayTable . "` ot\n\t\t\t\t\t\tINNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_id` = ot.`content_id`) {$joinSql}\n\t\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON (uue.`user_id` = lc.`modifier_user_id`)\n\t\t\t\t\t\tLEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON (uuc.`user_id` = lc.`user_id`)\n\t\t\t\t\t WHERE ot.`{$lookupColumn}`=? {$whereSql}"; $result = $this->mDb->query($query, $bindVars); if ($result && $result->numRows()) { $this->mInfo = $result->fields; $this->mOverlayId = $result->fields[$overlayKey]; $this->mContentId = $result->fields['content_id']; $this->mInfo['creator'] = isset($result->fields['creator_real_name']) ? $result->fields['creator_real_name'] : $result->fields['creator_user']; $this->mInfo['editor'] = isset($result->fields['modifier_real_name']) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user']; $this->mInfo['display_url'] = $this->getDisplayUrl(); // $this->mInfo['parsed_data'] = $this->parseData(); $this->mInfo['raw'] = $this->mInfo['data']; $parseHash['data'] = $this->mInfo['data']; $this->prepParseFilters($parseHash); // @TODO this has gone through many changes and this looks a bit chaotic - might be able to simplify this $this->mInfo['xml_parsed_data'] = $this->parseData($parseHash, $this->mInfo['format_guid']); $this->mInfo['parsed_data'] = $this->parseData($parseHash, $this->mInfo['format_guid']); $this->mInfo['clean_data'] = $this->mInfo['parsed_data']; $this->mInfo['parsed_data'] = addslashes($this->mInfo['parsed_data']); $this->mInfo['xml_data'] = str_replace("\n", " ", $this->mInfo['data']); $this->mInfo['data'] = addslashes($this->mInfo['data']); $this->mInfo['data'] = str_replace("\n", "\\n", $this->mInfo['data']); LibertyMime::load(); } } return count($this->mInfo); }
/** * getList * * @param array $pListHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function getList(&$pListHash) { if (empty($pListHash['sort_mode'])) { $pListHash['sort_mode'] = 'word_desc'; } BitBase::prepGetList($pListHash); $whereSql = ''; $bindVars = $ret = array(); if (!empty($pListHash['find'])) { $whereSql .= empty($whereSql) ? ' WHERE ' : ' AND '; $whereSql .= " UPPER( hw.`word` ) LIKE ? "; $bindVars[] = '%' . strtoupper($pListHash['find']) . '%'; } $query = "\n\t\t\tSELECT hw.`word`, hw.`url`\n\t\t\tFROM `" . BIT_DB_PREFIX . "hotwords` hw\n\t\t\t{$whereSql}\n\t\t\tORDER BY " . $this->mDb->convertSortmode($pListHash['sort_mode']); $result = $this->mDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']); while ($aux = $result->fetchRow()) { $ret[] = $aux; } $query = "\n\t\t\tSELECT COUNT( hw.`word` )\n\t\t\tFROM `" . BIT_DB_PREFIX . "hotwords` hw\n\t\t\t{$whereSql}"; $pListHash['cant'] = $this->mDb->getOne($query, $bindVars); BitBase::postGetList($pListHash); return $ret; }