function UpdateSql($data, $table, $where, $strict = false) { $f = ''; $field = array(); if ($strict) { $fieldrows = $GLOBALS['db']->fetch_first("select * from " . tname($table)); $field = array_keys($fieldrows); } foreach ($data as $key => $val) { if ($strict) { if (in_array($key, $field)) { $d = $i > 0 ? ',' : ''; $f .= $d . "`" . $key . "`=" . "'" . global_addslashes(trim($val)) . "'"; $i++; } } else { $d = $i > 0 ? ',' : ''; $f .= $d . "`" . $key . "`=" . "'" . global_addslashes(trim($val)) . "'"; $i++; } } $sql = "update " . tname($table) . " set "; $sql .= $f . " where 1 " . $where; return $sql; }
function setFlag($applications, $flag) { global $_SGLOBAL; $flag = ($flag == 'disabled') ? -1 : ($flag == 'default' ? 1 : 0); $appIds = array(); if ($applications && is_array($applications)) { foreach($applications as $application) { $this->refreshApplication($application['appId'], $application['appName'], null, null, null, $flag, null); $appIds[] = $application['appId']; } } if ($flag == -1) { $sql = sprintf('DELETE FROM %s WHERE icon IN (%s)', tname('feed'), simplode($appIds)); $_SGLOBAL['db']->query($sql); $sql = sprintf('DELETE FROM %s WHERE appid IN (%s)', tname('userapp'), simplode($appIds)); $_SGLOBAL['db']->query($sql); $sql = sprintf('DELETE FROM %s WHERE appid IN (%s)', tname('userappfield'), simplode($appIds)); $_SGLOBAL['db']->query($sql); $sql = sprintf('DELETE FROM %s WHERE appid IN (%s)', tname('myinvite'), simplode($appIds)); $_SGLOBAL['db']->query($sql); $sql = sprintf('DELETE FROM %s WHERE type IN (%s)', tname('notification'), simplode($appIds)); $_SGLOBAL['db']->query($sql); } $result = true; return new APIResponse($result); }
function get_ad($adid) { global $_SGLOBAL; $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('ad4dev') . " WHERE id={$adid}"); $ad = $_SGLOBAL['db']->fetch_array($query); return $ad; }
/** * 商舖的自定義導航 * * @param int $shopid 商舖 ID */ function get_shop_nav($shopid) { global $_G, $_SGLOBAL, $_BCACHE, $_SBLOCK; $nav_default = $this->get_shop_nav_default($shopid); $_SGLOBAL['shop_nav'] = array(); $_BCACHE->cachesql('shopnav', 'SELECT * FROM ' . tname('nav') . " WHERE (type=\\'sys\\' OR type=\\'shop\\') AND shopid='{$shopid}' AND displayorder>-1 ORDER BY displayorder ASC", 0, 0, 10, 0, 'detail', 'nav', $shopid); foreach ($_SBLOCK['shopnav'] as $value) { if ($value['available'] == 1) { $value['target'] = $value['target'] ? ' target=\'_blank\'' : ''; $value['style'] = ' style=\'' . pktitlestyle($value['highlight']) . '\''; $value['url'] = $nav_default[$value['flag']]['url']; $_SGLOBAL['shop_nav'][$value['flag']] = $value; unset($nav_default[$value['flag']]); } else { unset($nav_default[$value['flag']]); } } foreach ($nav_default as $key => $value) { if (!isset($rowitems[$key])) { $_SGLOBAL['shop_nav'][$key] = $value; } $_SGLOBAL['shop_nav'][$key]['url'] = $value['url']; } return $_SGLOBAL['shop_nav']; }
function getrss($catid) { global $_SGLOBAL, $_SCONFIG; $rssarr = array(); $attacharr = array(); if (empty($_SCONFIG['rssnum'])) { $_SCONFIG['rssnum'] = 10; } $sql = "SELECT si.itemid, si.uid, si.username, si.subject, sn.*, si.dateline, c.name FROM " . tname('spaceitems') . " si INNER JOIN " . tname('categories') . " c ON si.catid = c.catid LEFT JOIN " . tname('spacenews') . " sn ON si.itemid = sn.itemid WHERE si.type='news' "; if (!empty($catid)) { $sql .= " AND si.catid='{$catid}' "; } $sql .= " ORDER BY si.dateline DESC LIMIT 100"; $query = $_SGLOBAL['db']->query($sql); while ($items = $_SGLOBAL['db']->fetch_array($query)) { $othermsgarr = array(); $items['message'] = cutstr($items['message'], 255, 1); if (!empty($othermsgarr)) { $items['message'] = implode('<br>', $othermsgarr) . '<br>' . $items['message']; } if (!empty($items['hash'])) { $attacharr[] = trim($items['hash']); } $rssarr[$items['itemid']] = $items; } return $rssarr; }
function get($uId, $num) { global $_SGLOBAL; $result = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('feed')." WHERE uid='$uId' ORDER BY dateline DESC LIMIT 0,$num"); while($value = $_SGLOBAL['db']->fetch_array($query)) { $result[] = array( 'appId' => $value['appid'], 'created' => $value['dateline'], 'type' => $value['icon'], 'titleTemplate' => $value['title_template'], 'titleData' => $value['title_data'], 'bodyTemplate' => $value['body_template'], 'bodyData' => $value['body_data'], 'bodyGeneral' => $value['body_general'], 'image1' => $value['image_1'], 'image1Link' => $value['image_1_link'], 'image2' => $value['image_2'], 'image2Link' => $value['image_2_link'], 'image3' => $value['image_3'], 'image3Link' => $value['image_3_link'], 'image4' => $value['image_4'], 'image4Link' => $value['image_4_link'], 'targetIds' => $value['target_ids'], 'privacy' => $value['friend']==0?'public':($value['friend']==1?'friends':'someFriends') ); } return new APIResponse($result); }
function get_uid($type, $msg) { global $_SGLOBAL; if ($type == 1) { $str = explode(",", $msg); //print_r($str); $collegeid = $str[0]; $startyear = $str[1]; $wheresql = "collegeid = '{$collegeid}' and startyear = {$startyear}"; //print($wheresql); } else { if ($type == 2) { $str = explode(",", $msg); $name = $str[0]; $bir = $str[1]; $wheresql = "realname = '{$name}' and birthday = {$bir}"; } } $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('baseprofile') . " where " . $wheresql); if ($value = $_SGLOBAL['db']->fetch_array($query)) { $uid = $value[uid]; if ($value[uid] == null) { $uid = 'no uid'; } } else { $uid = 'no person'; } return $uid; }
function getAstrosData() { $mysql = new SaeMysql(); $sql0 = "SELECT * FROM `" . tname("astro") . "` LIMIT 12"; $astros = $mysql->getData($sql0); return $astros; }
function gettask() { global $space, $_SGLOBAL; $task = array(); if (!@(include_once S_ROOT . './data/data_task.php')) { include_once S_ROOT . './source/function_cache.php'; task_cache(); } if ($_SGLOBAL['task']) { $usertasks = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('usertask') . " WHERE uid='{$_SGLOBAL['supe_uid']}'"); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $usertasks[$value['taskid']] = $value; } //需要执行的任务 foreach ($_SGLOBAL['task'] as $value) { if ($value['starttime'] <= $_SGLOBAL['timestamp'] && (empty($usertasks[$value['taskid']]) || $value['nexttime'] && $_SGLOBAL['timestamp'] - $usertasks[$value['taskid']]['dateline'] >= $value['nexttime'])) { $value['image'] = empty($value['image']) ? 'image/task.gif' : $value['image']; $task = $value; break; } } } return $task; }
function get_service($serid) { global $_SGLOBAL; $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('apps') . " WHERE id={$serid}"); $service = $_SGLOBAL['db']->fetch_array($query); return $service; }
function send($uId, $recipientIds, $appId, $notification) { global $_SGLOBAL; //过滤黑名单中的用户 $blacklist = $result = array(); // 允许匿名发送 if ($uId) { $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('blacklist')." WHERE uid IN ('".implode("','", $recipientIds)."') AND buid='$uId'"); while($value = $_SGLOBAL['db']->fetch_array($query)) { $blacklist[$value['uid']] = $value['uid']; } } include_once(S_ROOT.'./source/function_cp.php'); foreach($recipientIds as $recipientId) { $val = intval($recipientId); if($val && empty($blacklist[$val])) { $result[$val] = notification_add($val, $appId, $notification, 1); } else { $result[$recipientId] = null; } } return new APIResponse($result); }
function main_action() { global $db, $session; $uid = $session->get('adminid'); //得到个人信息 $userinfo = $db->fetch_first('select * from ' . tname('admin') . ' where uid=' . $uid); include ROOT_PATH . '/views/admin/adminframe.php'; }
/** * 更新用户的积分 * * @param integer $uId 用户Id * @param integer $credits 积分值 * @return integer 更新后的用户积分 */ function update($uId, $credits) { global $_SGLOBAL; $sql = sprintf('UPDATE %s SET credit = credit + %d WHERE uid=%d', tname('space'), $credits, $uId); $result = $_SGLOBAL['db']->query($sql); $query = $_SGLOBAL['db']->query('SELECT credit FROM ' . tname('space') . ' WHERE uid =' . $uId); $row = $_SGLOBAL['db']->fetch_array($query); return new APIResponse($row['credit']); }
function areFriends($uId1, $uId2) { global $_SGLOBAL; $query = $_SGLOBAL['db']->query("SELECT uid FROM ".tname('friend')." WHERE uid='$uId1' AND fuid='$uId2' AND status='1'"); $result = false; if($friend = $_SGLOBAL['db']->fetch_array($query)) { $result = true; } return new APIResponse($result); }
function deletedoings($ids) { global $_SGLOBAL; $_SGLOBAL['db']->query("DELETE FROM " . tname('doing') . " WHERE doid IN (" . simplode($ids) . ")"); //删除评论 $_SGLOBAL['db']->query("DELETE FROM " . tname('docomment') . " WHERE doid IN (" . simplode($ids) . ")"); //删除feed $_SGLOBAL['db']->query("DELETE FROM " . tname('feed') . " WHERE id IN (" . simplode($ids) . ") AND idtype='doid'"); return true; }
function get($uIds) { global $_SGLOBAL; $result = array(); $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('friend') . " WHERE uid IN ('" . implode("','", $uIds) . "') AND status='1'"); while ($friend = $_SGLOBAL['db']->fetch_array($query)) { $result[$friend['uid']][] = $friend['fuid']; } return new APIResponse($result); }
function saveProject_action() { global $db; $projectName = $_POST['projectName']; $projectType = $_POST['projectType']; $projectUser = $_POST['projectUser']; $mobile = $_POST['mobile']; $weichart = $_POST['weichart']; $email = $_POST['email']; $company = $_POST['company']; $industry = $_POST['industry']; $rzjd = $_POST['rzjd']; $rzje = $_POST['rzje']; $tdgm = $_POST['tdgm']; // 高管职位 $ggzws = $_POST['ggzws']; // 高管名称 $ggmcs = $_POST['ggmcs']; // 营业执照图片 $fjImageArr = $_POST['fjImageArr']; // 产品图片 $cptpImageArr = $_POST['cptpImageArr']; // 二维码 $cpewmImageArr = $_POST['cpewmImageArr']; // 商业计划书、战略规划 $syjhImageArr = $_POST['syjhImageArr']; if ($projectType == 0) { $projectTypeName = "社会项目"; } else { $projectTypeName = "高校项目"; } $db->query("insert into " . tname('project') . "(project_name,project_type,project_type_id,project_user,project_user_phone,project_user_email,project_user_weixin,project_company,project_company_type,project_company_financ_p,project_company_financ,project_company_team,created_time) values ('" . $projectName . "','" . $projectTypeName . "','" . $projectType . "','" . $projectUser . "','" . $mobile . "','" . $email . "','" . $weichart . "','" . $company . "','" . $industry . "','" . $rzjd . "','" . $rzje . "','" . $tdgm . "','" . time() . "')"); $project_id = $db->insert_id(); // 插入营业执照图片 foreach ($fjImageArr as $fjImage) { $db->query("insert into " . tname('project_bl') . "(project_id,file_id,created_time) values ('" . $project_id . "','" . $fjImage . "','" . time() . "')"); } // 插入产品图片 foreach ($cptpImageArr as $cptpImage) { $db->query("insert into " . tname('project_product') . "(project_id,file_id,created_time) values ('" . $project_id . "','" . $cptpImage . "','" . time() . "')"); } // 插入二维码 foreach ($cpewmImageArr as $cpewmImage) { $db->query("insert into " . tname('project_qr') . "(project_id,file_id,created_time) values ('" . $project_id . "','" . $cpewmImage . "','" . time() . "')"); } // 插入商业计划书、战略规划 foreach ($syjhImageArr as $syjhImage) { $db->query("insert into " . tname('project_plan') . "(project_id,file_id,created_time) values ('" . $project_id . "','" . $syjhImage . "','" . time() . "')"); } for ($i = 0; $i < count($ggzws); $i++) { $db->query("insert into " . tname('project_gg') . "(project_id,gg_mc,gg_zw,created_time) values ('" . $project_id . "','" . $ggmcs[$i] . "','" . $ggzws[$i] . "','" . time() . "')"); } $pro['ret'] = 0; echo json_encode($pro); }
function updateviewnum($itemid) { global $_SGLOBAL; $logfile = S_ROOT . './log/viewcount.log'; if (@($fp = fopen($logfile, 'a+'))) { fwrite($fp, $itemid . "\n"); fclose($fp); @chmod($logfile, 0777); } else { $_SGLOBAL['db']->query('UPDATE ' . tname('spaceitems') . ' SET viewnum=viewnum+1 WHERE itemid=\'' . $itemid . '\''); } }
function get($uId, $num) { global $_SGLOBAL; $sql = 'SELECT * FROM %s WHERE uid = %d LIMIT %d'; $sql = sprintf($sql, tname('doing'), $uId, $num); $query = $_SGLOBAL['db']->query($sql); $result = array(); while ($doing = $_SGLOBAL['db']->fetch_array($query)) { $result[] = array('created' => $doing['dateline'], 'message' => $doing['message'], 'ip' => $doing['ip'], 'clientIdentify' => $doing['from']); } return new APIResponse($result); }
function config_cache($updatedata = true) { global $_SGLOBAL; $_SCONFIG = array(); $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('config')); while ($value = $_SGLOBAL['db']->fetch_array($query)) { if ($value['var'] == 'privacy') { $value['datavalue'] = empty($value['datavalue']) ? array() : unserialize($value['datavalue']); } $_SCONFIG[$value['var']] = $value['datavalue']; } cache_write('config', '_SCONFIG', $_SCONFIG); }
function cron_config() { global $_SGLOBAL; //下次执行cron时间 $query = $_SGLOBAL['db']->query("SELECT nextrun FROM " . tname('cron') . " WHERE available>'0' ORDER BY nextrun LIMIT 1"); $nextrun = $_SGLOBAL['db']->result($query, 0); if (empty($nextrun)) { $nextrun = 0; } //更新config inserttable('config', array('var' => 'cronnextrun', 'datavalue' => $nextrun), 0, true); include_once S_ROOT . './source/function_cache.php'; config_cache(false); }
function deletethreads($tagid, $tids) { global $_SGLOBAL; //删除 $_SGLOBAL['db']->query("DELETE FROM " . tname('thread') . " WHERE tid ={$tids}"); $_SGLOBAL['db']->query("DELETE FROM " . tname('post') . " WHERE tid ={$tids}"); //删除feed $_SGLOBAL['db']->query("DELETE FROM " . tname('feed') . " WHERE id ={$tids} AND idtype='tid'"); //删除举报 $_SGLOBAL['db']->query("DELETE FROM " . tname('report') . " WHERE id ={$tids} AND idtype='tid'"); //删除脚印 $_SGLOBAL['db']->query("DELETE FROM " . tname('clickuser') . " WHERE id ={$tids} AND idtype='tid'"); return true; }
function email_reg($email, $backurl = '') { global $_SGLOBAL, $_SC; $email_reg['email'] = $email; $email_reg['ip'] = getonlineip(1); $email_reg['salt'] = random(6); $email_reg['hash'] = substr(md5(md5($email) . $email_reg['salt']), 8, 7); $email_reg['addtime'] = $_SGLOBAL['timestamp']; $email_reg['used'] = 0; $email_reg['backurl'] = $backurl; $id = inserttable(tname("open_email_reg"), $email_reg, 1, 1); $h = $email_reg['hash']; return $_SC['site_host'] . "/?r=" . $h; }
function getAstroMonthSql($params) { $sql = 'replace ' . tname("astro_month") . '('; foreach ($params as $attribute => $value) { $sql .= "`" . $attribute . "`,"; } $sql .= ') values ('; foreach ($params as $attribute => $value) { $value = trim($value); $sql .= "'" . $value . "',"; } $sql .= ');'; $sql = str_replace(",)", ")", $sql); return $sql; }
function initParent() { global $_SGLOBAL; global $_PARENT; $query = $_SGLOBAL['db']->query("select * from " . tname('parent') . " where suid = " . $_SGLOBAL['supe_uid'] . " and isactive = 1"); $rows = $_SGLOBAL['db']->fetch_array($query); if ($rows) { $_PARENT['uid'] = $rows['uid']; $_PARENT['username'] = $rows['username']; $_PARENT['realname'] = $rows['realname']; $_PARENT['email'] = $rows['email']; $_PARENT['password'] = '******'; $_PARENT['emailupdated'] = 0; } }
function favorite_action() { global $session, $db; $cateindex = isset($_GET['cid']) ? $_GET['cid'] : 'home'; $category = array(); if (!empty($cateindex)) { $query = $db->query("select * from " . tname('board') . " where category_id='" . $cateindex . "'"); while ($rows = $db->fetch_array($query)) { $category[$rows['category_id']][] = $rows['title']; } } $favcate = bidcms_encode($category); //前20个推荐的采集 $pins = bidcms_encode(getallpins()); include template('index_favorite'); }
protected function focus_autoback() { global $_SGLOBAL, $_SC, $wx; $op_wxid = $wx->weixin['op_wxid']; $rand_pic = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28'); $query = $_SGLOBAL['db']->query('select * from ' . tname('open_member_weixin_autoreply') . ' where type="focus" and op_wxid="' . $op_wxid . '" and state=1 order by priority desc'); if ($msg = $_SGLOBAL['db']->fetch_array($query)) { switch ($msg['reply_type']) { case "text": $content = db_to_content(htmlspecialchars_decode($msg['content'])); $resultStr = $this->resp_text($content); return $resultStr; break; case "single_news": $data = $_SGLOBAL['db']->getall('select * from ' . tname('open_member_weixin_autoreply_info') . ' where autoreply_id="' . $msg['id'] . '" and state=1'); if ($data) { if ($data[0]['url'] == '') { $data[0]['url'] = $_SC['site_host'] . "/appmsg/?id=" . $data[0]['id'] . "&tp=1"; } $data[0]['picurl'] = $data[0]['pic']; if ($data[0]['picurl'] == '') { $data[0]['picurl'] = $_SC['img_url'] . '/mpres/wallpaper/' . $rand_pic[array_rand($rand_pic, 1)] . '.jpg'; } $data[0]['description'] = htmlspecialchars_decode($data[0]['summary']); $resultStr = $this->resp_news($data); return $resultStr; } break; case "multi_news": $data = $_SGLOBAL['db']->getall('select * from ' . tname('open_member_weixin_autoreply_info') . ' where autoreply_id="' . $msg['id'] . '" and state=1 order by sort_order limit 0,8'); foreach ($data as $k => $v) { if ($data[$k]['url'] == '') { $data[$k]['url'] = $_SC['site_host'] . "/appmsg/?id=" . $data[$k]['id'] . "&tp=1"; } $data[$k]['picurl'] = $data[$k]['pic']; $data[$k]['description'] = htmlspecialchars_decode($data[$k]['summary']); } if ($data[0]['picurl'] == '') { $data[0]['picurl'] = $_SC['img_url'] . '/mpres/wallpaper/' . $rand_pic[array_rand($rand_pic, 1)] . '.jpg'; } $resultStr = $this->resp_news($data); return $resultStr; break; } } return false; }
function get_uid($id) { global $_SGLOBAL; $collegeid = $id; $wheresql = "collegeid = {$collegeid}"; //echo "SELECT * FROM ".tname('baseprofile')." where ".$wheresql; $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('baseprofile') . " where " . $wheresql); if ($value = $_SGLOBAL['db']->fetch_array($query)) { $uid = $value[uid]; if ($value[uid] == null) { $uid = 'no uid'; } } else { $uid = 'no person'; } return $uid; }
function getBirthDaySql($params) { $sql = 'replace ' . tname("astro_birthday") . '('; foreach ($params as $attribute => $value) { $sql .= "`" . $attribute . "`,"; } $sql .= ') values ('; foreach ($params as $attribute => $value) { $value = trim($value); $value = str_replace("<br>", "", $value); $value = str_replace("'", '"', $value); #$value = mb_convert_encoding($value,"UTF-8","gb2312"); $sql .= "'" . $value . "',"; } $sql .= ');'; $sql = str_replace(",)", ")", $sql); return $sql; }
function posttag($tagnamestr) { global $_SGLOBAL, $lang; $tagarr = array('existsname' => array(), 'nonename' => array(), 'closename' => array(), 'existsid' => array()); if (empty($tagnamestr)) { return $tagarr; } $tagnamearr = array(); $valuearr = explode(' ', str_replace(',', ' ', shtmlspecialchars($tagnamestr))); foreach ($valuearr as $value) { if (count($tagnamearr) > 10) { break; } $value = posttagcheck($value); if ($value) { $tagnamearr[md5($value)] = $value; } } if (empty($tagnamearr)) { return $tagarr; } $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('tags') . ' WHERE tagname IN (' . simplode($tagnamearr) . ')'); while ($value = $_SGLOBAL['db']->fetch_array($query)) { $tagarr['existsid'][] = $value['tagid']; $tagarr['existsname'][] = $value['tagname']; if ($value['close']) { $tagarr['closename'][] = $value['tagname']; } } if (!empty($tagarr['existsname'])) { foreach ($tagnamearr as $value) { if (!in_array($value, $tagarr['existsname'])) { $tagarr['nonename'][] = $value; } } } else { $tagarr['nonename'] = $tagnamearr; } if (!empty($tagarr['closename'])) { showmessage($lang['not_allowed_to_belong_to_the_following_tag'] . ':<p>' . implode(',', $tagarr['closename']) . '</p>'); } return $tagarr; }