Exemplo n.º 1
0
 /**
  * 根据公司名称获取公司ID
  * @param string $companyName
  * @return array
  */
 function getCompanyIdByName($companyName)
 {
     if (!$companyName) {
         return array();
     }
     return $this->_db->get_value("SELECT companyid FROM  {$this->_tableName} WHERE companyname = " . S::sqlEscape($companyName) . "");
 }
Exemplo n.º 2
0
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;
    }
}
Exemplo n.º 3
0
 /**
  * 获得最新公告
  * @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);
 }
Exemplo n.º 4
0
 function _getSearchSQL($array)
 {
     if ($array['username']) {
         return ' AND username='******'username']);
     }
     return ' ';
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
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;
 }
Exemplo n.º 8
0
function isFriend($uid, $friend)
{
    global $db;
    if ($db->get_value("SELECT uid FROM pw_friends WHERE uid=" . S::sqlEscape($uid) . ' AND friendid=' . S::sqlEscape($friend) . " AND status='0'")) {
        return true;
    }
    return false;
}
Exemplo n.º 9
0
 function update($uploaddb)
 {
     $attaches = array();
     foreach ($uploaddb as $v) {
         $attaches['attach' . $v['id']] = $v['fileuploadurl'];
     }
     $attaches && $this->db->pw_update("SELECT * FROM pw_auth_certificate WHERE uid=" . S::sqlEscape($this->uid), "UPDATE pw_auth_certificate SET " . S::sqlSingle($attaches) . ' WHERE uid=' . $this->uid, "INSERT INTO pw_auth_certificate SET " . S::sqlSingle($attaches) . ',state=0,uid=' . $this->uid);
 }
Exemplo n.º 10
0
 function getUserGroups($type)
 {
     if (!$type) {
         return false;
     }
     $query = $this->_db->query("SELECT gid FROM {$this->_tableName} WHERE gptype=" . S::sqlEscape($type));
     return array_keys($this->_getAllResultFromQuery($query, 'gid'));
 }
Exemplo n.º 11
0
 function updataById($tplid, $array)
 {
     $array = $this->_checkData($array);
     if (!$array) {
         return null;
     }
     $this->_db->update("UPDATE " . $this->_tableName . " SET " . S::sqlSingle($array, false) . " WHERE tplid=" . S::sqlEscape($tplid));
 }
Exemplo n.º 12
0
 function getByIdentify($identify)
 {
     $temp = $this->_db->get_one("SELECT * FROM " . $this->_tableName . " WHERE identify=" . S::sqlEscape($identify));
     if (!$temp) {
         return array();
     }
     return $this->_unserializeData($temp);
 }
Exemplo n.º 13
0
 /**
  * 根据公司ID获取用户id
  * @param int companyId
  * @return array
  */
 function getUserIdsByCompanyId($companyId)
 {
     if (!$companyId) {
         return array();
     }
     $query = $this->_db->query("SELECT uid FROM  {$this->_tableName} WHERE companyid = " . S::sqlEscape($companyId) . "");
     return $this->_getAllResultFromQuery($query, 'uid');
 }
Exemplo n.º 14
0
 /**
  * 根据分类stid查name
  * 
  * @param stid 分类id
  * @return array 查询结果数组
  */
 function getTypesByStid($stid)
 {
     $stid = intval($stid);
     if (!$stid) {
         return null;
     }
     return $this->_db->get_one('SELECT name FROM ' . $this->_tableName . ' WHERE ifable <> 0 AND stid= ' . S::sqlEscape($stid));
 }
Exemplo n.º 15
0
 function getGroupcateCreditset($type)
 {
     $creditset = $this->db->get_value("SELECT creditset FROM pw_cnclass WHERE fid=" . S::sqlEscape($this->classid));
     $creditset = unserialize($creditset);
     $creditset = array_filter($creditset[$type], "group_filter");
     $creditset = is_array($creditset) ? $creditset : array();
     return $creditset;
 }
Exemplo n.º 16
0
 function _getCacheDataByNameNoCache($name)
 {
     global $db;
     if (!$name) {
         return false;
     }
     return $db->get_one("SELECT * FROM pw_cache WHERE name=" . S::sqlEscape($name));
 }
Exemplo n.º 17
0
 /**
  * 
  * 根据资料首次填写区域获取字段列表
  * @param int $complement
  * @return array
  */
 function getFieldsByComplement($complement)
 {
     $complement = (int) $complement;
     if (!S::inArray($complement, array(0, 1, 2))) {
         return array();
     }
     $query = $this->_db->query('SELECT * FROM ' . $this->_tableName . ' WHERE complement = ' . S::sqlEscape($complement) . ' AND state = 1 ORDER BY vieworder ASC');
     return $this->_getAllResultFromQuery($query, $this->_primaryKey);
 }
Exemplo n.º 18
0
 function getDatasByInvokePiece($invokePieceId)
 {
     $temp = array();
     $query = $this->_db->query("SELECT * FROM " . $this->_tableName . " WHERE invokepieceid=" . S::sqlEscape($invokePieceId));
     while ($rt = $this->_db->fetch_array($query)) {
         $temp[] = $rt;
     }
     return $temp;
 }
Exemplo n.º 19
0
 function getCommentsByCommentid($commentid)
 {
     $commentid = intval($commentid);
     if (!$commentid) {
         return array();
     }
     $query = $this->_db->query('SELECT * FROM ' . $this->_tableName . ' WHERE commentid = ' . S::sqlEscape($commentid) . '  ORDER BY postdate DESC LIMIT 30');
     return $this->_getAllResultFromQuery($query);
 }
 function countCertificateInfo($state)
 {
     if ($state) {
         $where = 'WHERE state=' . S::sqlEscape($state);
     } else {
         $where = 'WHERE state>0';
     }
     return $this->_db->get_value("SELECT COUNT(*) FROM {$this->_tableName} {$where}");
 }
Exemplo n.º 21
0
 function checkTableField($table, $field)
 {
     list($table, $field) = array(trim($table), trim($field));
     if (!$table || !$field) {
         return $this->buildResponse(SITE_INVALID_PARAMS);
     }
     $result = $GLOBALS['db']->get_one(sprintf('SHOW COLUMNS FROM %s LIKE %s', S::sqlMetadata($table), S::sqlEscape($field)));
     return $this->buildResponse(S::isArray($result) ? 0 : 1);
 }
Exemplo n.º 22
0
 function countAllByUserId($userId)
 {
     $userId = intval($userId);
     if ($userId < 1) {
         return array();
     }
     $query = $this->_db->query("SELECT COUNT(*) as total,categoryid FROM " . $this->_tableName . " WHERE uid = " . S::sqlEscape($userId) . " AND status = 1 GROUP BY categoryid");
     return $this->_getAllResultFromQuery($query, 'categoryid');
 }
Exemplo n.º 23
0
 /**
  * 按分类ID查所有sid
  * 
  * @param int $stid 分类ID
  * @return array 数组链接ID
  */
 function findSidByStid($stid)
 {
     $stid = intval($stid);
     if ($stid < 1) {
         return array();
     }
     $query = $this->_db->query('SELECT sid FROM ' . $this->_tableName . ' WHERE stid = ' . S::sqlEscape($stid));
     return $this->_getAllResultFromQuery($query);
 }
Exemplo n.º 24
0
 function getPtable($tid)
 {
     if ($GLOBALS['db_plist'] && is_array($plistdb = $GLOBALS['db_plist'])) {
         $postTableId = $GLOBALS['db']->get_value('SELECT ptable FROM pw_threads WHERE tid=' . S::sqlEscape($tid, false));
         if ((int) $postTableId > 0 && array_key_exists($postTableId, $plistdb)) {
             return 'pw_posts' . $postTableId;
         }
     }
     return 'pw_posts';
 }
Exemplo n.º 25
0
 function _getFirstPostNoCache($postTable, $tid, $limit, $offset)
 {
     $readdb = array();
     $limit = S::sqlLimit($limit, $offset);
     $query = $GLOBALS['db']->query("SELECT t.* FROM {$postTable} t WHERE t.tid=" . S::sqlEscape($tid) . " AND t.ifcheck='1' ORDER BY t.postdate ASC {$limit}");
     while ($read = $GLOBALS['db']->fetch_array($query)) {
         $readdb[] = $read;
     }
     return $readdb;
 }
Exemplo n.º 26
0
 function getIdsFromTable($startId, $endId)
 {
     list($tableName, $primaryKey) = $this->getPrimaryKeyAndTable();
     $result = array();
     $query = $GLOBALS['db']->query(sprintf("SELECT %s FROM %s WHERE %s >= %s AND %s <= %s", S::sqlMetaData($primaryKey), S::sqlMetaData($tableName), S::sqlMetaData($primaryKey), S::sqlEscape($startId), S::sqlMetaData($primaryKey), S::sqlEscape($endId)));
     while ($rt = $GLOBALS['db']->fetch_array($query)) {
         $result[] = $rt[$primaryKey];
     }
     return $result;
 }
Exemplo n.º 27
0
 function getThreadsByLastPost($startTime, $endTime, $page, $perpage)
 {
     list($startTime, $endTime, $page, $perpage) = array(intval($startTime), intval($endTime), intval($page), intval($perpage));
     if ($startTime < 1 || $endTime < 1 || $startTime > $endTime || $page < 1 || $perpage < 1) {
         return array();
     }
     $offset = ($page - 1) * $perpage;
     $query = $GLOBALS['db']->query("SELECT t.*,f.name as forumname FROM pw_threads t LEFT JOIN pw_forums f USING(fid) WHERE t.fid != 0 AND t.ifcheck = 1 AND t.lastpost >= " . S::sqlEscape($startTime) . " AND lastpost <= " . S::sqlEscape($endTime) . S::sqlLimit($offset, $perpage));
     return $this->getThreadDataWithTmsgs($query);
 }
 function getUserByUid($uid, $rights)
 {
     $sqladd = $sqltab = '';
     if ($rights) {
         $sqladd = ',sr.' . implode(',sr.', $rights);
         $sqltab = "LEFT JOIN pw_singleright sr ON m.uid=sr.uid";
     }
     $detail = $this->_db->get_one("SELECT m.uid,m.username,m.password,m.safecv,m.email,m.bday,m.oicq,m.groupid,m.memberid,m.groups,m.icon,m.regdate,m.honor,m.timedf, m.style,m.datefm,m.t_num,m.p_num,m.yz,m.newpm,m.userstatus,m.shortcut,m.medals,md.lastmsg,md.postnum,md.rvrc,md.money,md.credit,md.currency,md.lastvisit,md.thisvisit,md.onlinetime,md.lastpost,md.todaypost,md.monthpost,md.onlineip,md.uploadtime,md.uploadnum,md.starttime,md.pwdctime,md.monoltime,md.digests,md.f_num,md.creditpop,md.jobnum,md.lastgrab,md.follows,md.fans,md.newfans,md.newreferto,md.newcomment,md.postcheck {$sqladd} FROM pw_members m LEFT JOIN pw_memberdata md ON m.uid=md.uid {$sqltab} WHERE m.uid=" . S::sqlEscape($uid) . " AND m.groupid<>'0' AND md.uid IS NOT NULL");
     return $detail;
 }
Exemplo n.º 29
0
 function getAttentions($uid)
 {
     $_array = array();
     $_sql = "SELECT m.uid,m.username,a.touid FROM " . " pw_attention a" . " LEFT JOIN pw_members m" . " ON a.touid=m.uid" . " WHERE a.uid= " . S::sqlEscape($uid) . "ORDER BY a.date";
     $_query = $this->_db->query($_sql);
     while ($rt = $this->_db->fetch_array($_query)) {
         $_array[$rt['uid']] = $rt;
     }
     return $_array;
 }
Exemplo n.º 30
0
 function _getSpaceDataByUidNoCache($uid)
 {
     global $db;
     $uid = intval($uid);
     if ($uid < 1) {
         return false;
     }
     $space = $db->get_one("SELECT * FROM pw_space WHERE uid=" . S::sqlEscape($uid));
     return $space;
 }