public function run() { global $platal, $globals; $nom = S::v('prenom') . ' ' . S::v('nom'); $mail = $this->user->bestEmail(); $sig = $nom . ' (' . S::v('promo') . ')'; Banana::$msgedit_headers['X-Org-Mail'] = $this->user->forlifeEmail(); // Tree color $req = XDB::query('SELECT tree_unread, tree_read FROM forum_profiles WHERE uid= {?}', $this->user->id()); if (!(list($unread, $read) = $req->fetchOneRow())) { $unread = 'o'; $read = 'dg'; } Banana::$tree_unread = $unread; Banana::$tree_read = $read; // Build user profile Banana::$profile['headers']['From'] = "{$nom} <{$mail}>"; Banana::$profile['headers']['Organization'] = make_Organization(); Banana::$profile['signature'] = $sig; // Page design Banana::$page->killPage('forums'); Banana::$page->killPage('subscribe'); // Run Banana return parent::run(); }
/** * 组装小名片数据 * * @param int $uid 用户ID * @param int $winduid 当前用户id * @param bool $username 用户名 * @return array */ function getCardData($uid, $winduid, $username) { extract(pwCache::getData(R_P . "data/bbscache/level.php", false)); if ($uid < 1 && !trim($username) || $username == '游客' || $username == '匿名') { return array('username' => '游客', 'memtitle' => $ltitle[2]); } $userService = L::loadClass('UserService', 'user'); if ($uid) { $userInfo = $userService->get($uid, true, true); } elseif ($username) { $userInfo = $userService->getByUserName($username, true, true); } if (!S::isArray($userInfo)) { return array(); } require_once R_P . 'require/showimg.php'; list($faceimage) = showfacedesign($userInfo['icon'], 1, 's'); $userInfo['groupid'] == '-1' && ($userInfo['groupid'] = $userInfo['memberid']); !array_key_exists($userInfo['groupid'], (array) $lpic) && ($userInfo['groupid'] = 8); $online = checkOnline($userInfo['thisvisit']); $onlineRead = $online ? getOnlineViewing($userInfo['uid'], $userInfo['username']) : array(); $user = array('mine' => $userInfo['uid'] == $winduid || !$winduid ? 0 : 1, 'uid' => $userInfo['uid'], 'username' => $userInfo['username'], 'icon' => $faceimage, 'memtitle' => $ltitle[$userInfo['groupid']], 'genderClass' => $userInfo['gender'], 'viewTid' => isset($onlineRead['tid']) && $onlineRead['tid'] ? $onlineRead['tid'] : '', 'viewFid' => isset($onlineRead['fid']) && $onlineRead['fid'] ? $onlineRead['fid'] : '', 'online' => $online ? 1 : 0); $user['medals'] = getMedalsByUid($userInfo['uid']); // 勋章 $memberTagsService = L::loadClass('memberTagsService', 'user'); $user['memberTags'] = $memberTagsService->makeClassTags($memberTagsService->getMemberTagsByUid($userInfo['uid'])); //标签 $attentionSerivce = L::loadClass('Attention', 'friend'); /* @var $attentionSerivce PW_Attention */ $user['attention'] = $attentionSerivce->isFollow($winduid, $userInfo['uid']) ? 1 : 0; //关注 return $user; }
function _getSearchSQL($array) { if ($array['username']) { return ' AND username='******'username']); } return ' '; }
/** * 获取帖子基本信息和详细信息 * * @param int $threadId 帖子id * @return array */ function getThreadAndTmsgByThreadId($threadId) { $threadId = S::int($threadId); if ($threadId < 1) { return false; } if (!$this->checkMemcache()) { return $this->_getThreadAndTmsgByThreadIdNoCache($threadId); } $threadKey = $this->_getKeyForThread($threadId); $tmsgKey = $this->_getKeyForTmsg($threadId); //* $result = $this->_cacheService->get(array($threadKey, $tmsgKey)); //* $thread = isset($result[$threadKey]) ? $result[$threadKey] : false; //* $tmsg = isset($result[$tmsgKey]) ? $result[$tmsgKey] : false; $thread = $this->_cacheService->get($threadKey); $tmsg = $this->_cacheService->get($tmsgKey); if ($thread === false) { $thread = $this->_getThreadNoCache($threadId); $this->_cacheService->set($threadKey, $thread); } if ($tmsg === false) { $tmsg = $this->_getTmsgNoCache($threadId); $this->_cacheService->set($tmsgKey, $tmsg); } return $thread && $tmsg ? array_merge($thread, $tmsg) : array(); }
public static function getInstance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
function initCurrUpload($key, $value) { list($t, $i) = explode('_', $key); $arr = array('id' => intval($i), 'attname' => $t, 'name' => S::escapeChar($value['name']), 'size' => intval($value['size']), 'type' => 'zip', 'ifthumb' => 0, 'fileuploadurl' => ''); $arr['ext'] = strtolower(substr(strrchr($arr['name'], '.'), 1)); return $arr; }
/** * 获得最新公告 * @param int $num */ function getNewData($num) { global $timestamp; $num = (int) $num; $query = $this->_db->query("SELECT * FROM {$this->_tableName} WHERE ifopen = '1' AND \n\t\t\tstartdate <= " . S::sqlEscape($timestamp) . " AND enddate=0 OR enddate>" . S::sqlEscape($timestamp) . " ORDER BY aid DESC LIMIT 0,{$num}"); return $this->_getAllResultFromQuery($query); }
/** * * 数据处理 * @param int $fid * @return */ function _cookData($data) { if (!S::isArray($data)) { return array(); } require_once R_P . 'require/showimg.php'; foreach ($data as $k => $v) { $tem = array(); $tem['url'] = USER_URL . $v['uid']; $tem['title'] = $v['username']; $tem['value'] = $v['uid']; if (array_key_exists('icon', $v)) { $pic = showfacedesign($v['icon'], true, 's'); if (is_array($pic)) { $tem['image'] = $pic[0]; } else { $tem['image'] = ''; } } else { $tem['image'] = ''; } $tem['addition'] = $v; $userInfo[] = $tem; } return $userInfo; }
function vote($readvote) { global $db, $votetype, $ifview, $votedb, $votesum, $action, $viewvoter, $tid, $admincheck, $vote_close; $votearray = unserialize($readvote['voteopts']); $votetype = $readvote['mostvotes'] > 1 ? 'checkbox' : 'radio'; $votesum = 0; $votedb = $voter = array(); $ifview = $viewvoter == 'yes' ? 'no' : 'yes'; foreach ($votearray as $option) { $votesum += $option[1]; } if ($viewvoter == 'yes') { $query = $db->query("SELECT username,vote FROM pw_voter WHERE tid=" . S::sqlEscape($tid) . " LIMIT 500"); while ($rt = $db->fetch_array($query)) { $voter[$rt['vote']][] = $rt[username]; } } foreach ($votearray as $key => $value) { $vote = array(); $vote['percent'] = $votesum ? round(100 * $value[1] / $votesum, 2) : 0; if ($readvote['previewable'] == 0 || $readvote['havevote'] || $vote_close) { $vote['width'] = floor(500 * $value[1] / ($votesum + 1)); $vote['num'] = $value[1]; } else { $vote['width'] = 0; $vote['num'] = '*'; } $vote['name'] = $value[0]; $vote['voter'] = $voter[$key]; $votedb[$key] = $vote; } }
public static function IsCandidate(User $user, $candidate) { if (!$user->checkPerms(User::PERM_MAIL)) { return false; } return S::v('no_redirect'); }
function update($uploaddb) { $fieldService = L::loadClass('ActivityField', 'activity'); if ($this->tid) { $defaultAttach = $userAttach = array(); foreach ($uploaddb as $key => $value) { if ($value['id']) { $attach = array(); $attach = $fieldService->getField($value['id']); $this->attachs[$attach['fieldname']] = $value['fileuploadurl']; if ($attach['fieldname'] && $attach['ifdel'] == 1) { $userAttach[$attach['fieldname']] = $value['fileuploadurl']; } elseif ($attach['fieldname'] && !$attach['ifdel']) { $defaultAttach[$attach['fieldname']] = $value['fileuploadurl']; } } } $defaultValueTableName = getActivityValueTableNameByActmid(); $userDefinedValueTableName = getActivityValueTableNameByActmid($this->actmid, 1, 1); if ($defaultAttach) { $this->db->update("UPDATE {$defaultValueTableName} SET " . S::sqlSingle($defaultAttach) . " WHERE tid=" . S::sqlEscape($this->tid)); } if ($userAttach) { $this->db->update("UPDATE {$userDefinedValueTableName} SET " . S::sqlSingle($userAttach) . " WHERE tid=" . S::sqlEscape($this->tid)); } } else { foreach ($uploaddb as $key => $value) { $this->attachs['fileuploadurl'] = $value['fileuploadurl']; } } return true; }
function smarty_function_grpvisibility($params, &$smarty) { $user = $params['user']; $group = $params['group']; $grpcoll = $user->groupVisibility($group); $visigroup = $grpcoll->count() == 1 ? $grpcoll->first() : null; // if $user is session user, see which visibility option is enabled $flagselect = ''; if (S::user()->isMe($user)) { $possib = $user->getAvailVisibilities($group); $flagoptions = array(); foreach ($possib as $gid => $title) { $flagoption = '<option value="' . $gid . '"'; if ($visigroup != null && $visigroup->id() == $gid) { $flagoption .= ' selected'; } $flagoption .= '>visible par ' . $title . '</option>'; $flagoptions[] = $flagoption; } $flagselect = '<select class="visiselect" name="visibility-' . $user->id() . '-' . $group->id() . '">' . implode($flagoptions) . '</select>'; } // Get color & title list($color, $title) = User::visibilitiesColInfo($grpcoll); return '<form class="visicontainer" id="visiflag-' . $user->id() . '-' . $group->id() . '">' . '<div class="visiflag ' . $color . ' click" title="' . $title . '"></div>' . $flagselect . '</form>'; }
function display() { header("Content-Type: application/x-shockwave-flash"); $this->beginMovie(); $num = strlen($this->codes); if ($num > 0) { $this->imageWidth = floor($this->frameWidth / $num); $this->imageHeight = $this->frameHeight; $X1 = $Y1 = 0; $X2 = $this->imageWidth * 20; $Y2 = $this->imageHeight * 20; $imgpath = $GLOBALS['imgdir'] . '/ck/flash/'; for ($i = 0; $i < strlen($this->codes); $i++) { $file = $imgpath . strtolower($this->codes[$i]) . '.jpg'; $image = $this->defineBitmapJPEG($file); $CharacterInfo = $this->defineRectangleBitmap($X1, $Y1, $X2, $Y2, $this->imageWidth, false, false, 0, 0, 0, 0, 'c', $image, true, null); $characterdepth = $this->easyPlaceObject($CharacterInfo['charid']); $X1 += $this->imageWidth * 20; $X2 += $this->imageWidth * 20; } $this->endFrame(); S::filter(); } $this->endMovie(); print $this->getMovie(); exit; }
function smarty_block_canEdit($params, $content, &$smarty, &$repeat) { $group = $params['target']->group(); if (S::user()->hasRights($group, Rights::admin()) || S::user()->isWeb()) { return $content; } }
function syncredit($arr) { if (is_array($arr)) { foreach ($arr as $uid => $setv) { $updateMemberData = array(); foreach ($setv as $cid => $value) { if (is_numeric($cid)) { $value = intval($value); /** $this->db->pw_update( "SELECT uid FROM pw_membercredit WHERE uid=" . S::sqlEscape($uid) . ' AND cid=' . S::sqlEscape($cid), "UPDATE pw_membercredit SET value=" . S::sqlEscape($value) . ' WHERE uid=' . S::sqlEscape($uid) . ' AND cid=' . S::sqlEscape($cid), "INSERT INTO pw_membercredit SET " . S::sqlSingle(array('uid' => $uid, 'cid' => $cid, 'value' => $value)) ); **/ $this->db->pw_update("SELECT uid FROM pw_membercredit WHERE uid=" . S::sqlEscape($uid) . ' AND cid=' . S::sqlEscape($cid), pwQuery::updateClause('pw_membercredit', 'uid=:uid AND cid=:cid', array($uid, $cid), array('value' => $value)), pwQuery::insertClause('pw_membercredit', array('uid' => $uid, 'cid' => $cid, 'value' => $value))); } elseif (in_array($cid, array('money', 'rvrc', 'credit', 'currency'))) { $cid == 'rvrc' && ($value *= 10); $updateMemberData[$cid] = intval($value); } } if ($updateMemberData) { $userService = L::loadClass('UserService', 'user'); /* @var $userService PW_UserService */ $userService->update($uid, array(), $updateMemberData); } } } return new ApiResponse(1); }
/** * »ñÈ¡¿ªÆôͼ¿áµÄ°æ¿é * @return array */ function getTucoolForums() { $tucoolForums = array(); $fids = $this->getAllForumIds(); $forumsDao = $this->getForumsDao(); $forumSets = $forumsDao->getForumSetsByFids($fids); if ($forumSets) { foreach ($forumSets as $k => $v) { $forumset = array(); $v = @unserialize($v['forumset']); if (!$v['iftucool']) { continue; } $forumset['tucoolpic'] = intval($v['tucoolpic']); S::isArray($forumset) && ($tucoolForums[$k] = $forumset); } } if ($tucoolForums) { $forums = $forumsDao->getFormusByFids(array_keys($tucoolForums), 'fid,name'); foreach ($forums as $k => $v) { $tucoolForums[$k] = array_merge($tucoolForums[$k], $v); } } return $tucoolForums; }
/** * 添加 * * @param array $fieldsData * @return int */ function insert($fieldsData) { if (!S::isArray($fieldsData)) { return false; } return $this->_insert($fieldsData); }
/** * 根据tids批量删除数据 * * @param int $tid * @return array */ function deleteByTids($tids) { if (!S::isArray($tids)) { return false; } return $this->_db->update("DELETE FROM " . $this->_tableName . " WHERE tid IN (" . S::sqlImplode($tids) . ")"); }
function deleteByTids($tids) { if (!S::isArray($tids)) { return false; } return pwQuery::delete($this->_tableName, "{$this->_primaryKey} IN (:{$this->_primaryKey})", array($tids)); }
/** * 添加 * * @param array $fieldsData 数据数组,以数据库字段为key * @return int 新增id */ function insert($fieldsData) { if (S::isArray($fieldsData)) { $typeDb = $this->_getTypeDB(); return $typeDb->insert($fieldsData); } }
function aliasStatic($alias) { $file = S::escapePath(AREA_PATH . $alias . '/index.html'); $output = cookTemplate(); pwCache::writeover($file, $output); ob_clean(); }
public static function IsCandidate(User $user, $candidate) { if (!$user->checkPerms(User::PERM_MAIL)) { return false; } return count(S::v('mx_failures', array())) > 0; }
function update($uploaddb) { global $windid, $winduid, $timestamp, $pintro; foreach ($uploaddb as $key => $value) { $this->attachs[] = array('aid' => $this->aid, 'pintro' => $pintro[$value['id']] ? $pintro[$value['id']] : substr($value['name'], 0, strrpos($value['name'], '.')), 'path' => $value['fileuploadurl'], 'uploader' => $windid, 'uptime' => $timestamp, 'ifthumb' => $value['ifthumb']); } if ($this->attachs) { $this->db->update("INSERT INTO pw_cnphoto (aid,pintro,path,uploader,uptime,ifthumb) VALUES " . S::sqlMulti($this->attachs)); $this->pid = $this->db->insert_id(); $cnalbum = $this->db->get_one("SELECT * FROM pw_cnalbum WHERE aid=" . S::sqlEscape($this->aid)); if ($this->atype) { if (!$cnalbum['private']) { updateDatanalyse($this->pid, 'groupPicNew', $timestamp); } } else { $statistics = L::loadClass('Statistics', 'datanalyse'); $statistics->photouser($winduid, count($this->attachs)); } if (isset($cnalbum['lastphoto']) && !$cnalbum['lastphoto']) { $lastphoto = $this->getLastPhotoThumb(); $lastphotosqlAdd = ",lastphoto= " . S::sqlEscape($lastphoto); } $this->db->update("UPDATE pw_cnalbum SET photonum=photonum+" . S::sqlEscape(count($this->attachs)) . ",lasttime=" . S::sqlEscape($timestamp) . $lastphotosqlAdd . " WHERE aid=" . S::sqlEscape($this->aid)); } return true; }
function saveModesData($uid, $data, $conf) { $array = array(); foreach ($data as $key => $value) { $this->_cacheService->set($this->_getKeyForUserMode($uid, $key), array('num' => S::isArray($conf[$key]) ? S::int($conf[$key]['num']) : $conf[$key], 'value' => $value), S::isArray($conf[$key]) && isset($conf[$key]['expire']) ? S::int($conf[$key]['expire']) : 608400); } }
function getAtFeedByUserNames($usernames) { $data = array(); if (!S::isArray($usernames)) { return $data; } $userService = L::loadClass('userservice', 'user'); $users = $userService->getByUserNames($usernames); if (S::isArray($users)) { $userIds = array(); foreach ($users as $k => $v) { $userIds[$v['uid']] = $v['username']; } $ouserdataDb = $this->_getOuserdataDB(); $atFeeds = (array) $ouserdataDb->findUserAtPrivacy(array_keys($userIds)); if (S::isArray($atFeeds)) { foreach ($atFeeds as $v) { $data[$v['uid']] = array('at_isfeed' => $v['at_isfeed'], 'username' => $userIds[$v['uid']]); } } foreach ($userIds as $uid => $username) { $data[$uid] or $data[$uid] = array('at_isfeed' => 0, 'username' => $username); } } return $data; }
function _updateDb() { global $db; $fileContent = $this->_getFileContent(); $temparray = explode("\t", $fileContent); $data = s::isArray($temparray) ? array_count_values($temparray) : array(); $nowtime = PwStrtoTime(get_date($this->_timestamp, 'Y-m-d')); $sql = array(); foreach ($data as $key => $val) { $key = trim($this->_filterCheckKeyword($key)); if (!$key) { continue; } $sql[] = array($key, $val, $nowtime); if (++$count > 1000) { break; } } if (!$sql) { return false; } $db->query("INSERT INTO pw_searchstatistic(keyword,num,created_time) VALUES " . S::sqlMulti($sql)); $deleteTime = $this->_timestamp - 86400 * 90; $db->query("DELETE FROM pw_searchstatistic WHERE created_time < {$deleteTime}"); return true; }
static function put($product, $qty = 1) { if (!$product instanceof Product) { $product = Product::find(static::idFrom($product)); } if (!$product) { $product = func_get_arg(0); Log::warn_Cart("Unknown product [{$product}] to place in cart."); } elseif (!$product->available) { Log::warn_Cart("Attempting to place unavailable product [{$product->title}]."); } else { $oldQty = static::qty($product) ?: null; $qty = max(0, round(S::toFloat($qty), 2)); $key = 'cart_goods.' . $product->id; if ($qty == 0) { if ($oldQty) { Session::forget($key); Event::fire('cart.removed', array($product, &$oldQty)); } } else { $qty = max($product->min, $qty); $product->fractable or $qty = ceil($qty); if ($qty != $oldQty) { Session::put($key, $qty); Event::fire('cart.added', array($product, &$oldQty)); } } return $product; } }
/** * ÅжϸÃÌû×ÓÊÇ·ñÒѱ»É¾³ý * @param unknown_type $thread */ function _checkIfDelete($thread) { if (!S::isArray($thread)) { return true; } return $thread['fid'] == 0 && $thread['ifcheck'] == 1; }
function getguestIndexpath() { global $db_guestdir; $mode = S::getGP('m'); $mode = $mode && in_array($mode, array('bbs', 'area', 'o')) ? $mode : ''; return D_P . "{$db_guestdir}/index" . $mode . ".html"; }
function smarty_function_test_email($params, $smarty) { $label = isset($params['title']) ? $params['title'] : 'Envoyer un email de test'; $token = "'" . S::v('xsrf_token') . (isset($params['hruid']) ? "', " : "'"); $hruid = isset($params['hruid']) ? "'" . $params['hruid'] . "'" : ''; return '<div class="center">' . ' <div id="mail_sent" style="position: absolute;"></div><br />' . ' <div><input type="submit" name="send" value="' . $label . '" onclick="sendTestEmail(' . $token . $hruid . ')" /></div>' . '</div>'; }