Example #1
0
 function add($p, $delete_if_exists = 0)
 {
     $rets = array();
     $buddyid = (int) ($p['buddyid'] ? $p['buddyid'] : $p['touid']);
     $uid = $p['uid'] > 0 ? $p['uid'] : MEMBER_ID;
     if ($uid < 1 || $buddyid < 1 || $uid == $buddyid) {
         $rets['error'] = '您不能关注自己';
         return $rets;
     }
     $query = DB::query("SELECT * FROM `" . TABLE_PREFIX . "members` WHERE `uid` IN ('{$uid}','{$buddyid}')");
     $members = array();
     while (false != ($row = DB::fetch($query))) {
         $members[$row['uid']] = $row;
     }
     $info = $this->info($buddyid, $uid);
     if (!$info) {
         $sys_config = jconf::get();
         if (count($members) < 2) {
             $rets['error'] = '关注失败,TA已经消失不见了';
             return $rets;
         }
         if ($sys_config['follow_limit'] > 0 && $members[$uid]['follow_count'] >= $sys_config['follow_limit']) {
             $rets['error'] = '本站限制关注数量为<b>' . $sys_config['follow_limit'] . '</b>人,您不能再关注更多的好友了';
             return $rets;
         }
         if ($members[$buddyid]['disallow_beiguanzhu']) {
             $rets['error'] = '关注失败,TA设置了禁止被关注';
             return $rets;
         }
         if (is_blacklist($uid, $buddyid)) {
             $rets['error'] = '关注失败,对方已将您拉入了黑名单';
             return $rets;
         }
         $_tmps = jsg_role_check_allow('follow', $buddyid, $uid);
         if ($_tmps && $_tmps['error']) {
             return $_tmps;
         }
         jtable('buddy_follow')->add($uid, $buddyid);
         jtable('buddy_fans')->add($buddyid, $uid);
         ios_push_msg($buddyid, '你有新消息:1个粉丝');
         $this->count($uid);
         $this->count($buddyid);
         if ($sys_config['sendmailday'] > 0) {
             jtable('mailqueue')->add($members[$buddyid], 'notice_fans');
         }
         if ($sys_config['extcredits_enable'] && $uid > 0) {
             $update_credits = false;
             if ($members[$buddyid]['nickname']) {
                 $update_credits = update_credits_by_action("_U" . crc32($members[$buddyid]['nickname']), $uid);
             }
             if (!$update_credits) {
                 update_credits_by_action('buddy', $uid);
             }
         }
         if ($sys_config['imjiqiren_enable'] && imjiqiren_init($sys_config)) {
             imjiqiren_send_message($members[$buddyid], 'f');
         }
         if ($sys_config['sms_enable'] && sms_init($sys_config)) {
             sms_send_message($members[$buddyid], 'f');
         }
     } else {
         if ($delete_if_exists) {
             $this->del_info($buddyid, $uid);
         }
     }
     return $info;
 }
Example #2
0
 function pmSendAgain($post)
 {
     $message = trim($post['message']);
     $time = time();
     if ($message == '') {
         return 1;
     }
     $pmid = $post['pmid'];
     $pm = $this->DatabaseHandler->Query("select * from " . TABLE_PREFIX . "pms where pmid = '{$pmid}'");
     $pm_list = $pm->GetRow();
     $pm_list['message'] = $message;
     $touid = $pm_list['msgtoid'];
     $uids = '';
     if ($pm_list['msgtoid'] > $pm_list['msgfromid']) {
         $uids = $pm_list['msgfromid'] . "," . $pm_list['msgtoid'];
     } else {
         $uids = $pm_list['msgtoid'] . "," . $pm_list['msgfromid'];
     }
     if ($touid < 1) {
         return 5;
     }
     $to_user_list = array();
     $sql = "\r\n\t\tSELECT\r\n\t\t\tuid,username,nickname,notice_pm,email,newpm\r\n\t\tFROM\r\n\t\t\t" . TABLE_PREFIX . 'members' . "\r\n\t\tWHERE\r\n\t\t\tuid = '{$touid}'";
     $query = $this->DatabaseHandler->Query($sql);
     while ($row = $query->GetRow()) {
         $to_user_list[$row['uid']] = $row;
     }
     if ($to_user_list == false) {
         return 3;
     }
     $plid = DB::result_first("select plid from " . TABLE_PREFIX . "pms_index where uids = '{$uids}'");
     if ($plid == 0) {
         DB::query("insert into " . TABLE_PREFIX . "pms_index (uids) values('{$uids}')");
         $plid = mysql_insert_id();
         $pm_list['plid'] = $plid;
         $lastmessage = addslashes(serialize($pm_list));
         DB::query("insert into " . TABLE_PREFIX . "pms_list (plid,uid,pmnum,dateline,lastmessage) values('{$plid}'," . MEMBER_ID . ",1,'{$time}','{$lastmessage}')");
         if ($pm_list['msgtoid'] != $pm_list['msgfromid']) {
             DB::query("insert into " . TABLE_PREFIX . "pms_list (plid,uid,pmnum,dateline,lastmessage) values('{$plid}','{$touid}',1,'{$time}','{$lastmessage}')");
         }
     } else {
         $lastmessage = addslashes(serialize($pm_list));
         DB::query("update " . TABLE_PREFIX . "pms_list set pmnum = pmnum + 1,dateline = '{$time}',lastmessage = '{$lastmessage}' where plid = '{$plid}'");
     }
     DB::query("update " . TABLE_PREFIX . "pms set folder = 'inbox' ,message = '{$message}' ,dateline = '{$time}',plid = '{$plid}' where pmid = '{$pmid}'");
     $num = 1;
     $_tmps = array_keys($to_user_list);
     $to_user_id_list = array();
     foreach ($_tmps as $_tmp) {
         $_tmp = (int) $_tmp;
         if ($_tmp > 0) {
             $to_user_id_list[$_tmp] = $_tmp;
         }
     }
     $this->UpdateNewMsgCount($num, $to_user_id_list);
     foreach ($to_user_list as $user_notice) {
         if ($GLOBALS['_J']['config']['sendmailday'] > 0) {
             jtable('mailqueue')->add($user_notice, 'notice_pm');
         }
         if ($GLOBALS['_J']['config']['imjiqiren_enable'] && imjiqiren_init()) {
             imjiqiren_send_message($user_notice, 'm', $GLOBALS['_J']['config']);
         }
         if ($GLOBALS['_J']['config']['sms_enable'] && sms_init()) {
             sms_send_message($user_notice, 'm', $GLOBALS['_J']['config']);
         }
     }
     if ($GLOBALS['_J']['config']['extcredits_enable'] && MEMBER_ID > 0) {
         update_credits_by_action('pm', MEMBER_ID, count($to_user_list));
     }
     return 0;
 }
Example #3
0
 private function _process_reply($data)
 {
     $totid = jfilter($data['totid'], 'int');
     if ($totid > 0 && $data['touid'] > 0 && $data['uid'] != $data['touid'] && !jtable('topic_mention')->is_at($data['tid'], $data['touid'])) {
         if ($data['type'] == 'both' || $data['type'] == 'reply') {
             jtable('members')->update_count($data['touid'], 'comment_new', '+1');
         }
         if ($GLOBALS['_J']['config']['imjiqiren_enable'] || $GLOBALS['_J']['config']['sms_enable'] || $GLOBALS['_J']['config']['sendmailday'] > 0) {
             $sql = "select `uid`,`username`,`nickname`,`email`,`lastactivity`,\r\n\t\t\t\t\t`newpm`,`at_new`,`event_new`,`fans_new`,`vote_new`,`dig_new`,`channel_new`,`company_new`,`qun_new`,`comment_new`,\r\n\t\t\t\t\t`email_checked`,`notice_reply`,`user_notice_time`\r\n\t\t\t\tfrom `" . TABLE_PREFIX . "members`\r\n\t\t\t\twhere `uid` = '{$data['touid']}'";
             $reply_notice = DB::fetch_first($sql);
             if ($reply_notice) {
                 if ($GLOBALS['_J']['config']['imjiqiren_enable'] && imjiqiren_init()) {
                     imjiqiren_send_message($reply_notice, 'p', $GLOBALS['_J']['config']);
                 }
                 if ($GLOBALS['_J']['config']['sms_enable'] && sms_init()) {
                     sms_send_message($reply_notice, 'p', $GLOBALS['_J']['config']);
                 }
                 if ($GLOBALS['_J']['config']['sendmailday'] > 0) {
                     jtable('mailqueue')->add($reply_notice, 'notice_reply');
                 }
             }
         }
     }
 }