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; }
/** * 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 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 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; }
/** * 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 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)); } }
/** * 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 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; }
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; }
/** * 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; }
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; }
/** * 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 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); }
/** * 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($pContentId = NULL, $pPluginParams = NULL) { global $gBitSystem; if ($this->verifyId($this->mNlpgId) || $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->mNlpgId) ? 'nlpg_id' : 'content_id'; $bindVars = array(); $selectSql = ''; $joinSql = ''; $whereSql = ''; array_push($bindVars, $lookupId = @BitBase::verifyId($this->mNlpgId) ? $this->mNlpgId : $this->mContentId); $this->getServicesSql('content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars); $query = "SELECT n.*, 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} " . "FROM `" . BIT_DB_PREFIX . "nlpg_metadata` n " . "INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( lc.`content_id` = n.`content_id` ) {$joinSql}" . "LEFT JOIN `" . BIT_DB_PREFIX . "users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )" . "LEFT JOIN `" . BIT_DB_PREFIX . "users_users` uuc ON( uuc.`user_id` = lc.`user_id` )" . "WHERE e.`{$lookupColumn}`=? {$whereSql}"; $result = false; // $this->mDb->query( $query, $bindVars ); if ($result && $result->numRows()) { $this->mInfo = $result->fields; $this->mContentId = $result->fields['content_id']; $this->mNlpgId = $result->fields['nlpg_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['data'], $this->mInfo['format_guid']); $prefChecks = array('show_start_time', 'show_end_time'); foreach ($prefChecks as $key => $var) { if ($this->getPreference($var) == 'on') { $this->mInfo[$var] = 1; } else { $this->mInfo[$var] = 0; } } LibertyAttachable::load(); } } return count($this->mInfo); }
public function verify(&$iParamHash) { $isNewType = FALSE; // Validate the (optional) topic_id parameter if (@BitBase::verifyId($iParamHash['article_type_id'])) { $cleanHash['article_type_id'] = (int) $iParamHash['article_type_id']; } else { $isNewType = TRUE; $cleanHash['article_type_id'] = NULL; } if (!$isNewType) { $cleanHash['use_ratings'] = !empty($iParamHash['use_ratings']) ? $iParamHash['use_ratings'] : 'n'; $cleanHash['show_pre_publ'] = !empty($iParamHash['show_pre_publ']) ? $iParamHash['show_pre_publ'] : 'n'; $cleanHash['show_post_expire'] = !empty($iParamHash['show_post_expire']) ? $iParamHash['show_post_expire'] : 'n'; $cleanHash['heading_only'] = !empty($iParamHash['heading_only']) ? $iParamHash['heading_only'] : 'n'; $cleanHash['allow_comments'] = !empty($iParamHash['allow_comments']) ? $iParamHash['allow_comments'] : 'n'; $cleanHash['comment_can_rate_article'] = !empty($iParamHash['comment_can_rate_article']) ? $iParamHash['comment_can_rate_article'] : 'n'; $cleanHash['show_image'] = !empty($iParamHash['show_image']) ? $iParamHash['show_image'] : 'n'; $cleanHash['show_avatar'] = !empty($iParamHash['show_avatar']) ? $iParamHash['show_avatar'] : 'n'; $cleanHash['show_author'] = !empty($iParamHash['show_author']) ? $iParamHash['show_author'] : 'n'; $cleanHash['show_pubdate'] = !empty($iParamHash['show_pubdate']) ? $iParamHash['show_pubdate'] : 'n'; $cleanHash['show_expdate'] = !empty($iParamHash['show_expdate']) ? $iParamHash['show_expdate'] : 'n'; $cleanHash['show_reads'] = !empty($iParamHash['show_reads']) ? $iParamHash['show_reads'] : 'n'; $cleanHash['show_size'] = !empty($iParamHash['show_size']) ? $iParamHash['show_size'] : 'n'; $cleanHash['creator_edit'] = !empty($iParamHash['creator_edit']) ? $iParamHash['creator_edit'] : 'n'; $cleanHash['type_name'] = !empty($iParamHash['type_name']) ? $iParamHash['type_name'] : NULL; } else { // Was an acceptable name given? if (empty($iParamHash['type_name']) || $iParamHash['type_name'] == '') { $this->mErrors['type_name'] = tra("Invalid or blank article type name supplied"); } else { $cleanHash['type_name'] = $iParamHash['type_name']; } } $iParamHash = $cleanHash; return count($this->mErrors) == 0; }
function load() { if (!empty($this->mOverlayId) || !empty($this->mContentId)) { $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.*, ufm.`favorite_content_id`, ufm.`map_position`,\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,\n\t\t\t\t\t lf.storage_path AS `image_attachment_path` {$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\tLEFT JOIN `" . BIT_DB_PREFIX . "users_favorites_map` ufm ON ( lc.`content_id`=ufm.`favorite_content_id` )\n\t\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_attachments` la ON( la.`content_id` = lc.`content_id` AND la.`is_primary` = 'y' )\n\t\t\t\t\t\tLEFT OUTER JOIN `" . BIT_DB_PREFIX . "liberty_files` lf ON( lf.`file_id` = la.`foreign_id` )\n\t\t\t\t\t WHERE ot.`{$lookupColumn}`=? {$whereSql}"; if ($this->mInfo = $this->mDb->getRow($query, $bindVars)) { $this->mInfo['thumbnail_url'] = liberty_fetch_thumbnails(array("storage_path" => $this->mInfo['image_attachment_path'])); $this->mOverlayId = $this->mInfo[$overlayKey]; $this->mContentId = $this->mInfo['content_id']; $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']); // to support html in labels $this->mInfo['parsed_label_data'] = $this->parseData($this->mInfo['label_data'], $this->mInfo['format_guid']); $comment = new LibertyComment(); $this->mInfo['num_comments'] = $comment->getNumComments($this->mInfo['content_id']); LibertyMime::load(); } } return count($this->mInfo); }
/** * mime_image_store_exif_data Process a JPEG and store its EXIF data as meta data. * * @param array $pFileHash file details. * @param array $pFileHash[upload] should contain a complete hash from $_FILES * @access public * @return TRUE on success, FALSE on failure */ function mime_image_store_exif_data($pFileHash) { global $gBitSystem; if (!empty($pFileHash['upload'])) { $upload =& $pFileHash['upload']; } if (@BitBase::verifyId($pFileHash['attachment_id']) && ($exifHash = mime_image_get_exif_data($upload))) { // only makes sense to store the GPS data if we at least have latitude and longitude if (!empty($exifHash['GPS'])) { LibertyMime::storeMetaData($pFileHash['attachment_id'], 'GPS', $exifHash['GPS']); } if (!empty($exifHash['EXIF'])) { // LibertyMime::storeMetaData( $pFileHash['attachment_id'], 'EXIF', $exifHash['EXIF'] ); } } return TRUE; }
/** * isValid Make sure sample is loaded and valid * * @access public * @return boolean TRUE on success, FALSE on failure */ function isValid() { return @BitBase::verifyId($this->mSampleId) && @BitBase::verifyId($this->mContentId); }
<?php require_once '../../kernel/setup_inc.php'; $listHash = $_REQUEST; if (@BitBase::verifyId($_REQUEST['user_id'])) { $listHash['user_id'] = $_REQUEST['user_id']; } if (!empty($_REQUEST['user_agent'])) { $listHash['user_agent'] = $_REQUEST['user_agent']; } if (!empty($_REQUEST['ip'])) { $listHash['ip'] = $_REQUEST['ip']; } if (@BitBase::verifyId($_REQUEST['user_id'])) { $listHash['user_id'] = $_REQUEST['user_id']; } $gBitSmarty->assign('userActivity', $gBitUser->getUserActivity($listHash)); $gBitSmarty->assignByRef('listInfo', $listHash['listInfo']); $gBitSystem->display('bitpackage:users/user_activity.tpl', 'User Activity', array('display_mode' => 'admin'));
/** * verify - standard API method, with a twist. It will gobble up anything in $_FILES if available, unless an array of arrays is passed in to $pParamHash['_files_override'] * * @access private * @author Christian Fowler<*****@*****.**> * @param $pParamHash * @return FALSE if errors were present, TRUE meaning object is ready to store * @deprecated deprecated since version 2.1.0-beta */ function verify(&$pParamHash) { //deprecated( "This method has been replaced by a method in LibertyMime. Please try to migrate your code." ); global $gBitSystem, $gBitUser; // check to see if we have any files to upload if (isset($pParamHash['_files_override'])) { // we have been passed in a manually stuffed files attachment, such as a custom uploader would have done. // process this, and skip over $_FILES $uploads = $pParamHash['_files_override']; } elseif (!empty($_FILES)) { // we have some _FILES hanging around we will gobble up. This is inherently dagnerous chewing up a _FILES like this as // it can cause premature storing of a _FILE if you are trying to store multiple pieces of content at once. foreach ($_FILES as $key => $file) { if (!empty($file['name'])) { $uploads[$key] = $file; } } } // don't check for p_liberty_attach_attachments permission on bitpermuser class so registration with avatar upload works if (strtolower(get_class($this)) == 'bitpermuser') { $pParamHash['no_perm_check'] = TRUE; } // check for the required permissions to upload a file to the liberty attachments area if (!empty($uploads) && empty($pParamHash['no_perm_check'])) { if (!$gBitUser->hasPermission('p_liberty_attach_attachments')) { $this->mErrors['permission'] = tra('You do not have permission to upload attachments.'); } } if (!empty($pParamHash['attachment_id']) && !$this->verifyId($pParamHash['attachment_id'])) { $this->mErrors['file'] = tra('System Error: Non-numeric storage_id.'); } if (empty($pParamHash['user_id'])) { // storage is always owned by the user that uploaded it! // er... or at least admin if somehow we have a NULL mUserId - anon uploads maybe? $pParamHash['user_id'] = @$this->verifyId($gBitUser->mUserId) ? $gBitUser->mUserId : ROOT_USER_ID; } if (empty($pParamHash['process_storage'])) { $pParamHash['process_storage'] = NULL; } if (empty($pParamHash['subdir'])) { $pParamHash['subdir'] = 'files'; } if (!empty($uploads)) { foreach (array_keys($uploads) as $f) { $this->verifyAttachment($pParamHash, $uploads[$f], $f); } } // primary attachment. Allow 'none' to clear the primary. if (!@BitBase::verifyId($pParamHash['liberty_attachments']['primary']) && (empty($pParamHash['liberty_attachments']['primary']) || $pParamHash['liberty_attachments']['primary'] != 'none')) { $pParamHash['liberty_attachments']['primary'] = NULL; } // if we have an error we get them all by checking parent classes for additional errors if (count($this->mErrors) > 0) { parent::verify($pParamHash); } return count($this->mErrors) == 0; }
/** * getContentIdFromAttachmentId * * @param array $pAttachmentId Attachment id of which you want the content Id * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function getContentIdFromAttachmentId($pAttachmentId) { if (@BitBase::verifyId($pAttachmentId)) { return $this->mDb->getOne("SELECT `content_id` FROM `" . BIT_DB_PREFIX . "liberty_attachments` WHERE `attachment_id` = ?", array($pAttachmentId)); } }
function mime_default_branch($pAttachmentId) { $ret = FALSE; if (@BitBase::verifyId($pAttachmentId)) { $ret = FLAT_STORAGE_NAME . '/' . $pAttachmentId % 1000 . '/' . $pAttachmentId . '/'; } return $ret; }
$listHash = array(); $newsletters = $gContent->getList($listHash); $gBitSmarty->assignByRef('subs', BitNewsletter::getUserSubscriptions($gBitUser->getField('user_id'), $gBitUser->getField('email'))); $gBitSmarty->assignByRef('newsletters', $newsletters); $foo = parse_url($_SERVER["REQUEST_URI"]); $gBitSmarty->assign('url_subscribe', httpPrefix() . $foo["path"]); $subinfo = array(); $unsubs = array(); // We have a url_code from a clicked link in an email if (isset($_REQUEST['c']) && strlen($_REQUEST['c']) == 32 && ($subInfo = BitNewsletterMailer::lookupSubscription(array('url_code' => $_REQUEST['c'])))) { } elseif ($gBitUser->isRegistered()) { if (!($subInfo = BitNewsletterMailer::lookupSubscription(array('user_id' => $gBitUser->mUserId)))) { $subInfo = $gBitUser->mInfo; } } if (!empty($subInfo['user_id']) && BitBase::verifyId($subInfo['user_id'])) { $lookup['user_id'] = $subInfo['user_id']; } else { $lookup['email'] = $subInfo['email']; } $unsubs = BitNewsletterMailer::getUnsubscriptions($lookup); // Update subscriptions if (isset($_REQUEST["update"])) { $subHash['response_content_id'] = $_REQUEST['response_content_id']; $subHash['sub_lookup'] = !empty($subInfo['user_id']) ? array('user_id' => $subInfo['user_id']) : array('email' => $subInfo['email']); if (!empty($_REQUEST['unsubscribe_all'])) { $subHash['unsubscribe_all'] = 'y'; $subHash['unsub_content'] = array_keys($newsletters); } else { $subHash['unsubscribe_all'] = NULL; foreach (array_keys($newsletters) as $nlContentId) {
require_once DIASALSA_PKG_PATH . 'SalsaAction.php'; require_once LIBERTY_PKG_PATH . 'lookup_content_inc.php'; if (empty($gContent) || !is_object($gContent) || !$gContent->isValid()) { // if someone gives us a action_key we try to find it if (!empty($_REQUEST['action_key']) && is_numeric($_REQUEST['action_key'])) { global $gBitDb; $_REQUEST['action_id'] = $gBitDb->getOne("SELECT action_id FROM `" . BIT_DB_PREFIX . "diasalsa_actions` a WHERE a.`key_id`=?", array($_REQUEST['action_key'])); if (empty($_REQUEST['action_id'])) { $gBitSystem->fatalError(tra('No action found with key id: ') . $_REQUEST['action_key']); } } // if someone gives us a action_name we try to find it if (!empty($_REQUEST['action_name'])) { global $gBitDb; $_REQUEST['action_id'] = $gBitDb->getOne("SELECT action_id FROM `" . BIT_DB_PREFIX . "diasalsa_actions` a LEFT JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (a.`content_id` = lc.`content_id`) WHERE lc.`title` = ?", array($_REQUEST['action_name'])); if (empty($_REQUEST['action_id'])) { $gBitSystem->fatalError(tra('No action found with the name: ') . $_REQUEST['action_name']); } } // if action_id supplied, use that if (@BitBase::verifyId($_REQUEST['action_id'])) { $gContent = new SalsaAction($_REQUEST['action_id']); $gContent->load(); } elseif (@BitBase::verifyId($_REQUEST['content_id'])) { $gContent = new SalsaAction(NULL, $_REQUEST['content_id']); $gContent->load(); } else { $gContent = new SalsaAction(); } $gBitSmarty->assign_by_ref('gContent', $gContent); }
require_once "../kernel/setup_inc.php"; global $gBitSmarty, $gContent, $gBitUser, $gBitSystem, $gLibertySystem; // we just want information about a single attachment if (isset($_REQUEST['attachment_id']) && is_numeric($_REQUEST['attachment_id'])) { if (!$gContent) { $gContent = new LibertyMime(); } // this is a hack to make it compatible with existing tpls for now $attachment = $gContent->getAttachment($_REQUEST['attachment_id']); $ret = array(); $ret[$attachment['attachment_id']] = $attachment; $userAttachments = $ret; $gContent->mStorage = $userAttachments; $gBitSmarty->assign('gContent', $gContent); } else { // we want a list of user attachments $listHash = $_REQUEST; $listHash = array('page' => @BitBase::verifyId($_REQUEST['pgnPage']) ? $_REQUEST['pgnPage'] : NULL, 'load_attached_to' => true); $userAttachments = $gBitUser->getUserAttachments($listHash); // Fake the storage assignment for edit_storage_list.tpl $gContent->mStorage = $userAttachments; $gBitSmarty->assign('gContent', $gContent); // pagination $offset = @BitBase::verifyId($_REQUEST['offset']) ? $_REQUEST['offset'] : 0; $gBitSmarty->assign('curPage', $pgnPage = @BitBase::verifyId($_REQUEST['pgnPage']) ? $_REQUEST['pgnPage'] : 1); $offset = ($pgnPage - 1) * $gBitSystem->getConfig('max_records'); // calculate page number $numPages = ceil($listHash['cant'] / $gBitSystem->getConfig('max_records')); $gBitSmarty->assign('cant', $listHash['cant']); $gBitSmarty->assign('numPages', $numPages); }