public function getInstalled($uId)
 {
     $db_prefix = getDbPrefix();
     $result = doQuery("SELECT `appid` FROM {$db_prefix}userapp WHERE `uid` = {$uId}");
     $result = getSubByKey($result, 'appid');
     return new APIResponse($result);
 }
Example #2
0
 public function areFriends($uId1, $uId2)
 {
     $db_prefix = getDbPrefix();
     $sql = "SELECT * FROM {$db_prefix}friend WHERE `uid` = '{$uId1}' AND `friend_uid` = '{$uId2}' AND `status` = '1' LIMIT 1";
     $result = doQuery($sql) ? true : false;
     return new APIResponse($result);
 }
 function remove($appIds)
 {
     $db_prefix = getDbPrefix();
     $appIds = "'" . implode("','", $appIds) . "'";
     $result = doQuery("DELETE FROM {$db_prefix}myop_userapp WHERE `appid` IN ( {$appIds} )");
     $result = doQuery("DELETE FROM {$db_prefix}myop_userappfield WHERE `appid` IN ( {$appIds} )") || $result;
     $result = doQuery("DELETE FROM {$db_prefix}myop_myapp WHERE `appid` IN ( {$appIds} )") || $result;
     //TODO: update cache
     return new APIResponse($result);
 }
Example #4
0
 function getFriendInfo($uId, $num = MY_FRIEND_NUM_LIMIT, $isExtra = false)
 {
     $users = $this->getUsers(array($uId), false, true, $isExtra, true, $num, false, true);
     $db_prefix = getDbPrefix();
     $totalNum = doQuery("SELECT COUNT(*) AS count FROM {$db_prefix}weibo_follow WHERE `uid` = {$uId}");
     $totalNum = $totalNum[0]['count'];
     $friends = $users[0]['friends'];
     unset($users[0]['friends']);
     $result = array('totalNum' => $totalNum, 'friends' => $friends, 'me' => $users[0]);
     return new APIResponse($result);
 }
Example #5
0
 public function getUpdatedFriends($num)
 {
     $db_prefix = getDbPrefix();
     $totalNum = doQuery("SELECT COUNT(*) AS count FROM {$db_prefix}myop_friendlog");
     $totalNum = $totalNum[0]['count'];
     $friends = array();
     if ($totalNum) {
         $res = doQuery("SELECT * FROM {$db_prefix}myop_friendlog ORDER BY dateline DESC LIMIT {$num}");
         foreach ($res as $friend) {
             $friends[] = array('uId' => $friend['uid'], 'uId2' => $friend['fuid'], 'action' => $friend['action']);
             //删除记录
             doQuery("DELETE FROM {$db_prefix}myop_friendlog WHERE `uid` = {$friend['uid']} AND `fuid` = {$friend['fuid']}");
         }
     }
     $result = array('totalNum' => $totalNum, 'friends' => $friends);
     return new APIResponse($result);
 }
Example #6
0
 function send($uId, $recipientIds, $appId, $requestName, $myml, $type)
 {
     $db_prefix = getDbPrefix();
     $now = time();
     $result = array();
     $type = $type == 'request' ? '1' : '0';
     $fields = array('typename' => $requestName, 'appid' => $appId, 'type' => $type, 'fromuid' => $uId, 'dateline' => $now);
     foreach ($recipientIds as $key => $val) {
         $myml = str_replace('space.php?', U('home/Space/index') . '&', $myml);
         $myml = str_replace('userapp.php', MYOP_URL . '/userapp.php', $myml);
         $hash = crc32($appId . $val . $now . rand(0, 1000));
         $hash = sprintf('%u', $hash);
         $fields['touid'] = intval($val);
         $fields['hash'] = $hash;
         $fields['myml'] = str_replace('{{MyReqHash}}', $hash, $myml);
         $result[] = inserttable('myop_myinvite', $fields, 1);
         //TODO: 更新统计
         //doQuery("UPDATE ".tname('space')." SET myinvitenum=myinvitenum+1 WHERE `uid`='{$fields['touid']}'");
     }
     return new APIResponse($result);
 }
Example #7
0
 function publishTemplatizedAction($uId, $appId, $titleTemplate, $titleData, $bodyTemplate, $bodyData, $bodyGeneral = '', $image1 = '', $image1Link = '', $image2 = '', $image2Link = '', $image3 = '', $image3Link = '', $image4 = '', $image4Link = '', $targetIds = '', $privacy = '', $hashTemplate = '', $hashData = '', $specialAppid = 0)
 {
     global $_SITE_CONFIG;
     $db_prefix = getDbPrefix();
     $site_userapp_url = SITE_URL . '/apps/myop/userapp.php';
     $site_cp_url = SITE_URL . '/apps/myop/cp.php';
     if (strpos($titleTemplate, MYOP_URL) === false) {
         $titleTemplate = str_replace('userapp.php', $site_userapp_url, $titleTemplate);
         $titleTemplate = str_replace('cp.php', $site_cp_url, $titleTemplate);
     }
     foreach ($titleData as $k => $v) {
         if (strpos($titleTemplate, MYOP_URL) === false) {
             $v = str_replace('userapp.php', $site_userapp_url, $v);
             $v = str_replace('cp.php', $site_cp_url, $v);
         }
         $titleTemplate = str_replace('{' . $k . '}', $v, $titleTemplate);
     }
     if (strpos($bodyTemplate, MYOP_URL) === false) {
         $bodyTemplate = str_replace('userapp.php', $site_userapp_url, $bodyTemplate);
         $bodyTemplate = str_replace('cp.php', $site_cp_url, $bodyTemplate);
     }
     foreach ($bodyData as $k => $v) {
         if (strpos($bodyTemplate, MYOP_URL) === false) {
             $v = str_replace('userapp.php', $site_userapp_url, $v);
             $v = str_replace('cp.php', $site_cp_url, $v);
         }
         $bodyTemplate = str_replace('{' . $k . '}', $v, $bodyTemplate);
     }
     $titleTemplate = str_replace('{actor}', '', $titleTemplate);
     $bodyTemplate = str_replace('{actor}', '<a href="' . U('home/Space/index', array('uid' => $uId)) . '">' . getUserName($uId) . '</a>', $bodyTemplate);
     $content = array('title' => stripslashes($titleTemplate), 'content' => stripslashes($bodyTemplate), 'image1' => $image1, 'image1Link' => $image1Link, 'image2' => $image2, 'image2Link' => $image2Link, 'image3' => $image3, 'image3Link' => $image3Link, 'image4' => $image4, 'image4Link' => $image4Link);
     doLog($content, 'ContetArray');
     $content = serialize($content);
     $ctime = time();
     $sql = "INSERT INTO {$db_prefix}feed (`uid`,`data`,`type`,`ctime`) VALUES \r\n\t\t\t\t\t   ({$_SITE_CONFIG['uid']}, '{$content}', 'myop_feed','{$ctime}')";
     $result = doQuery($sql);
     return new APIResponse($result);
 }
Example #8
0
<?php

require_once './common.php';
//检查漫游是否开启
if (!$_SITE_CONFIG['my_status']) {
    redirect(SITE_URL, 5, '抱歉:漫游已关闭。系统将在5秒后自动跳转至首页');
}
if (empty($_GET['id'])) {
    exit('请先选择应用');
}
$_GET['id'] = intval($_GET['id']);
$db_prefix = getDbPrefix();
$app = doQuery("SELECT * FROM {$db_prefix}myop_myapp WHERE `appid` = {$_GET['id']} LIMIT 1");
$app = $app[0];
setTitle($app['appname']);
//漫游
$my_appId = $_GET['id'];
$my_suffix = base64_decode(urldecode($_GET['my_suffix']));
$my_prefix = MYOP_URL . '/';
if (!$my_suffix) {
    header('Location: userapp.php?id=' . $my_appId . '&my_suffix=' . urlencode(base64_encode('/')));
    exit;
}
if (preg_match('/^\\//', $my_suffix)) {
    $url = 'http://apps.manyou.com/' . $my_appId . $my_suffix;
} else {
    if ($my_suffix) {
        $url = 'http://apps.manyou.com/' . $my_appId . '/' . $my_suffix;
    } else {
        $url = 'http://apps.manyou.com/' . $my_appId;
    }
Example #9
0
function getUserCredit($uid)
{
    if (empty($uid)) {
        return false;
    }
    $db_preifx = getDbPrefix();
    $credit_type = doQuery("SELECT * FROM {$db_preifx}credit_type ORDER BY id ASC");
    $user_credit_info = doQuery("SELECT * FROM {$db_preifx}credit_user WHERE `uid` = {$uid}");
    $user_credit_info = $user_credit_info[0];
    foreach ($credit_type as $v) {
        $user_credit[$v['name']] = array('credit' => intval($user_credit_info[$v['name']]), 'alias' => $v['alias']);
    }
    return $user_credit;
}
Example #10
0
 function validate()
 {
     $this->db = connectDb();
     $this->dbPrefix = getDbPrefix();
     $this->t = new TextFilter();
     return true;
 }
Example #11
0
 public function refreshApplication($appId, $appName, $version, $displayMethod, $narrow, $flag, $displayOrder)
 {
     global $_SGLOBAL;
     $fields = array();
     if ($appName !== null && strlen($appName) > 1) {
         $fields['appname'] = $appName;
     }
     if ($version !== null) {
         $fields['version'] = $version;
     }
     if ($displayMethod !== null) {
         // todo: remove
         $fields['displaymethod'] = $displayMethod;
     }
     if ($narrow !== null) {
         $fields['narrow'] = $narrow;
     }
     if ($flag !== null) {
         $fields['flag'] = $flag;
     }
     if ($displayOrder !== null) {
         $fields['displayorder'] = $displayOrder;
     }
     $db_prefix = getDbPrefix();
     $is_installed = doQuery("SELECT * FROM {$db_prefix}myop_myapp WHERE `appid` = {$appId}");
     if ($is_installed) {
         $where = sprintf('appid = %d', $appId);
         updatetable('myop_myapp', $fields, $where);
     } else {
         $fields['appid'] = $appId;
         $result = inserttable('myop_myapp', $fields, 1);
     }
     //TODO: update cache
 }