Ejemplo n.º 1
0
 function checkuser($a, $p, $ajax = false)
 {
     //验证用户 账号/密码
     self::$Rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__members` WHERE `username`='{$a}' AND `password`='{$p}'");
     if (empty(self::$Rs)) {
         //记录
         $a && runlog('user.login', 'username='******'&password='******'password']);
         if ($ajax) {
             return false;
         }
         self::LoginPage();
     } else {
         self::$uId = self::$Rs->uid;
         self::$Rs->info && (self::$Rs->info = unserialize(self::$Rs->info));
         self::$group = iCMS_DB::getRow("SELECT * FROM `#iCMS@__group` WHERE `gid`='{self::{$Rs->groupid}}'");
         //用户组
         self::$power = explode(',', self::merge(self::$group->power, self::$Rs->power));
         $cpower = self::merge(self::$group->cpower, self::$Rs->cpower);
         self::$cpower = empty($cpower) ? array(0) : explode(',', $cpower);
         self::$nickname = empty(self::$Rs->nickname) ? self::$Rs->username : self::$Rs->nickname;
         if ($ajax) {
             return true;
         }
     }
 }
Ejemplo n.º 2
0
function runcron($cronid = 0)
{
    global $_SGLOBAL, $_SCONFIG, $_SBLOCK, $_TPL, $_SCOOKIE, $_SN, $space;
    $where = $cronid ? "cronid='{$cronid}'" : "available>'0' AND nextrun<='{$_SGLOBAL['timestamp']}'";
    $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('cron') . " WHERE {$where} ORDER BY nextrun LIMIT 1");
    //只运行一个
    if ($cron = $_SGLOBAL['db']->fetch_array($query)) {
        $lockfile = S_ROOT . './data/runcron_' . $cron['cronid'] . '.lock';
        $cronfile = S_ROOT . './source/cron/' . $cron['filename'];
        if (is_writable($lockfile)) {
            $locktime = filemtime($lockfile);
            if ($locktime > $_SGLOBAL['timestamp'] - 600) {
                //10分钟
                return NULL;
            }
        } else {
            @touch($lockfile);
        }
        @set_time_limit(1000);
        @ignore_user_abort(TRUE);
        cronnextrun($cron);
        if (!@(include $cronfile)) {
            runlog('CRON', $cron['name'] . ' : Cron script(' . $cron['filename'] . ') not found or syntax error', 0);
        }
        @unlink($lockfile);
    }
    //更新config
    cron_config();
}
Ejemplo n.º 3
0
function getforeignpicpath($filename, $name1, $name2, $mkdir = false)
{
    global $_SGLOBAL, $_SC;
    $filepath = "foreign" . $filename;
    //$name1 = gmdate('Ym');
    //$name2 = gmdate('j');
    chdir(dirname(dirname(dirname(__FILE__))));
    //change the current dir to ihome dir.
    if ($mkdir) {
        $newfilename = $_SC['attachdir'] . './' . $name1;
        if (!is_dir($newfilename)) {
            if (!@mkdir($newfilename)) {
                runlog('error', "DIR: {$newfilename} can not make");
                return $filepath;
            }
        }
        $newfilename .= '/' . $name2;
        if (!is_dir($newfilename)) {
            if (!@mkdir($newfilename)) {
                runlog('error', "DIR: {$newfilename} can not make");
                return $name1 . '/' . $filepath;
            }
        }
    }
    return $name1 . '/' . $name2 . '/' . $filepath;
}
Ejemplo n.º 4
0
 public function wx_sendMsg($data)
 {
     if (!getglobal('setting/CorpID') || !getglobal('setting/CorpSecret')) {
         return false;
     }
     $user = C::t('user')->fetch($data['uid']);
     if (!$user['wechat_userid'] || $user['wechat_status'] != 1) {
         C::t('notification')->update($data['id'], array('wx_new' => $data['wx_new'] + 1));
         return false;
     }
     $agentid = 0;
     if ($data['from_idtype'] == 'app' && $data['from_id'] && ($wxapp = C::t('wx_app')->fetch($data['from_id']))) {
         if ($wxapp['agentid'] && $wxapp['status'] < 1) {
             $agentid = $wxapp['agentid'];
         }
     }
     $wx = new qyWechat(array('appid' => getglobal('setting/CorpID'), 'appsecret' => getglobal('setting/CorpSecret')));
     $msg = array("touser" => "dzz-" . $data['uid'], "safe" => 0, "agentid" => $agentid, "msgtype" => "news", "news" => array("articles" => array(array("title" => $data['title'], "description" => getstr($data['wx_note'], 0, 0, 0, 0, -1), "url" => $wx->getOauthRedirect(getglobal('siteurl') . 'index.php?mod=system&op=wxredirect&url=' . dzzencode($data['redirecturl']))))));
     if ($ret = $wx->sendMessage($msg)) {
         C::t('notification')->update($data['id'], array('wx_new' => 0));
         return true;
     } else {
         C::t('notification')->update($data['id'], array('wx_new' => $data['wx_new'] + 1));
         $message = 'wx_notification:errCode:' . $wx->errCode . ';errMsg:' . $wx->errMsg;
         runlog('wxlog', $message);
         return false;
     }
 }
Ejemplo n.º 5
0
function capi_jpush($uidarr, $message, $title = null, $extras = null)
{
    $client = new JPush(JPUSH_APP_KEY, JPUSH_MASTER_SECRET);
    try {
        $result = $client->push()->setPlatform(array('ios', 'android'))->addAlias($uidarr)->setNotificationAlert($message)->addAndroidNotification($message, $title, 1, $extras)->addIosNotification($message, JPUSH_IOS_SOUND, '+1', true, null, $extras)->send();
        if (D_BUG) {
            runlog('jpush', 'Push Success:' . json_encode($result));
        }
    } catch (APIRequestException $e) {
        /*
        echo 'Push Fail.' . $br;
        echo 'Http Code : ' . $e->httpCode . $br;
        echo 'code : ' . $e->code . $br;
        echo 'Error Message : ' . $e->message . $br;
        echo 'Response JSON : ' . $e->json . $br;
        echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br;
        echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br;
        echo 'rateLimitReset : ' . $e->rateLimitReset . $br;
        */
        if (D_BUG) {
            runlog('jpush', 'Push Fail:' . json_encode(array('error' => $e)));
        }
    } catch (APIConnectionException $e) {
        /*
        echo 'Push Fail: ' . $br;
        echo 'Error Message: ' . $e->getMessage() . $br;
        //response timeout means your request has probably be received by JPUsh Server,please check that whether need to be pushed again.
        echo 'IsResponseTimeout: ' . $e->isResponseTimeout . $br;
        */
        if (D_BUG) {
            runlog('jpush', 'Push Fail:' . json_encode(array('ErrorMessage' => $e->getMessage(), 'IsResponseTimeout' => $e->isResponseTimeout)));
        }
    }
    //echo $br . '-------------' . $br;
}
Ejemplo n.º 6
0
function sftp_connect()
{
    global $_SGLOBAL;
    @set_time_limit(0);
    $func = $_SGLOBAL['setting']['ftpssl'] && function_exists('ftp_ssl_connect') ? 'ftp_ssl_connect' : 'ftp_connect';
    if ($func == 'ftp_connect' && !function_exists('ftp_connect')) {
        runlog('FTP', "FTP NOT SUPPORTED.", 0);
    }
    if ($ftpconnid = @$func($_SGLOBAL['setting']['ftphost'], intval($_SGLOBAL['setting']['ftpport']), 20)) {
        if ($_SGLOBAL['setting']['ftptimeout'] && function_exists('ftp_set_option')) {
            @ftp_set_option($ftpconnid, FTP_TIMEOUT_SEC, $_SGLOBAL['setting']['ftptimeout']);
        }
        if (sftp_login($ftpconnid, $_SGLOBAL['setting']['ftpuser'], $_SGLOBAL['setting']['ftppassword'])) {
            if ($_SGLOBAL['setting']['ftppasv']) {
                sftp_pasv($ftpconnid, TRUE);
            }
            if (sftp_chdir($ftpconnid, $_SGLOBAL['setting']['ftpdir'])) {
                return $ftpconnid;
            } else {
                runlog('FTP', "CHDIR '{$_SGLOBAL[setting][ftpdir]}' ERROR.", 0);
            }
        } else {
            runlog('FTP', '530 NOT LOGGED IN.', 0);
        }
    } else {
        runlog('FTP', "COULDN'T CONNECT TO {$_SGLOBAL[setting][ftphost]}:{$_SGLOBAL[setting][ftpport]}.", 0);
    }
    sftp_close($ftpconnid);
    return -1;
}
Ejemplo n.º 7
0
 function checkuser($a, $p)
 {
     //验证用户 账号/密码
     $this->user = $this->db->getRow("SELECT * FROM `#iCMS@__members` WHERE `username`='{$a}' AND `password`='{$p}'");
     if (empty($this->user)) {
         //记录
         $a && runlog('user.login', 'username='******'&password='******'password']);
         $this->LoginPage();
     } else {
         $this->uId = $this->user->uid;
         $this->user->info && ($this->user->info = unserialize($this->user->info));
         $this->group = $this->db->getRow("SELECT * FROM `#iCMS@__group` WHERE `gid`='{$this->user->groupid}'");
         //用户组
         $this->power = explode(',', $this->merge($this->group->power, $this->user->power));
         $cpower = $this->merge($this->group->cpower, $this->user->cpower);
         $this->cpower = empty($cpower) ? array(0) : explode(',', $cpower);
     }
 }
Ejemplo n.º 8
0
 function checkadmin($a, $p, $Ret = false)
 {
     //验证用户 账号/密码
     self::$Rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__admin` WHERE `username`='{$a}' AND `password`='{$p}'");
     if (empty(self::$Rs)) {
         //记录
         $a && runlog('login', 'username='******'&password='******'password']);
         return $Ret ? 'Bad' : self::LoginPage();
     } else {
         self::$uId = self::$Rs->uid;
         self::$Rs->info && (self::$Rs->info = unserialize(self::$Rs->info));
         self::$group = iCMS_DB::getRow("SELECT * FROM `#iCMS@__group` WHERE `gid`='" . self::$Rs->groupid . "'");
         //用户组
         self::$power = explode(',', self::merge(self::$group->power, self::$Rs->power));
         $cpower = self::merge(self::$group->cpower, self::$Rs->cpower);
         self::$cpower = empty($cpower) ? array(0) : explode(',', $cpower);
         self::$Rs->groupid == "1" && (self::$cpower = NULL);
     }
 }
Ejemplo n.º 9
0
 public static function sendMessage($uid, $title, $content, $msgType, $extra = null, $mask = 3, $jpushAk = null, $jpushSk = null)
 {
     global $_G;
     $tmp = Utils::readLocalAkSk2();
     if (!isset($tmp['app_key']) || !isset($tmp['app_secret'])) {
         return false;
     }
     $ak = $tmp['app_key'];
     $sk = $tmp['app_secret'];
     $appInfo = self::getAppInfo($ak, $sk);
     if (!isset($appInfo['app_id'])) {
         return false;
     }
     $appId = $appInfo['app_id'];
     $alias = sprintf('%020lu%020lu', $appId, $uid);
     $params = array('alias' => $alias, 'mask' => $mask, 'message_type' => $msgType, 'title' => $title, 'content' => $content);
     if (is_array($extra)) {
         $params['extra'] = BIGAPPJSON::encode($extra);
     }
     if (!is_null($jpushAk) && !is_null($jpushSk)) {
         $params['jpush_app_key'] = $jpushAk;
         $params['jpush_master_secret'] = $jpushSk;
     }
     $url = BigAppConf::$pushUrl;
     $obj = new BkSvr($ak, $sk, 30);
     $ret = $obj->getInfo($url, $params, false, false);
     if (!is_array($ret)) {
         runlog('bigapp', 'send message failed, invalid return [ ret: ' . $ret . ' ]');
         return false;
     }
     if (0 != $ret['error_code']) {
         runlog('bigapp', 'send message failed, error code is not 0 [ ret: ' . BIGAPPJSON::encode($ret) . ' ]');
         return $ret;
     }
     return true;
 }
Ejemplo n.º 10
0
            if ($_GET['sendemail']) {
                if (!function_exists('sendmail')) {
                    include libfile('function/mail');
                }
                foreach (array('delete', 'validate', 'invalidate') as $o) {
                    foreach ($moderation[$o] as $uid) {
                        if (isset($members[$uid])) {
                            $member = $members[$uid];
                            $member['regdate'] = dgmdate($member['regdate']);
                            $member['submitdate'] = dgmdate($member['submitdate']);
                            $member['moddate'] = dgmdate(TIMESTAMP);
                            $member['operation'] = $o;
                            $member['remark'] = $_GET['remark'][$uid] ? dhtmlspecialchars($_GET['remark'][$uid]) : $lang['none'];
                            $moderate_member_message = lang('email', 'moderate_member_message', array('username' => $member['username'], 'bbname' => $_G['setting']['bbname'], 'regdate' => $member['regdate'], 'submitdate' => $member['submitdate'], 'submittimes' => $member['submittimes'], 'message' => $member['message'], 'modresult' => lang('email', 'moderate_member_' . $member['operation']), 'moddate' => $member['moddate'], 'adminusername' => $_G['member']['username'], 'remark' => $member['remark'], 'siteurl' => $_G['siteurl']));
                            if (!sendmail("{$member['username']} <{$member['email']}>", lang('email', 'moderate_member_subject'), $moderate_member_message)) {
                                runlog('sendmail', "{$member['email']} sendmail failed.");
                            }
                        }
                    }
                }
            }
        }
        cpmsg('moderate_members_op_succeed', "action=moderate&operation=members&page={$page}", 'succeed', array('numvalidated' => $numvalidated, 'numinvalidated' => $numinvalidated, 'numdeleted' => $numdeleted));
    }
} elseif ($do == 'del') {
    if (!submitcheck('prunesubmit', 1)) {
        shownav('user', 'nav_modmembers');
        showsubmenu('nav_moderate_users', array(array('nav_moderate_users_mod', 'moderate&operation=members&do=mod', 0), array('clean', 'moderate&operation=members&do=del', 1)));
        showtips('moderate_members_tips');
        showformheader('moderate&operation=members&do=del');
        showtableheader('moderate_members_prune');
Ejemplo n.º 11
0
    $html = "<tr class='myportal'>\n\t\t\t\t\t  <td valign='top'><input class='myportal_enable' type='checkbox' name='new_check' checked disabled/></td>\n\t\t\t\t\t  <td><input type='text' class='txt myportal_sort' style='width:20px' value='1' disabled/></td>\n\t\t\t\t\t  <input type='hidden' class='myportal_id'  value='0'/>\n\t\t\t\t\t  <td>" . $lang['portal_home'] . "</td>\n\t\t\t\t\t  <td><input type='text'  class='txt myportal_title' style='width:100px' value='" . $lang['portal_home_title'] . "'/></td>\n\t\t\t\t\t</tr>";
    if (!empty($portalcategory)) {
        foreach ($portalcategory as $cat) {
            if ($cat['closed'] != 1) {
                $enable = $sort = 0;
                $title = $cat['catname'];
                if (isset($setting['portal']) && !empty($setting['portal'])) {
                    foreach ($setting['portal'] as $category) {
                        if ($category['id'] == $cat['catid']) {
                            $sort = isset($category['sort']) ? $category['sort'] : 10;
                            $enable = isset($category['enable']) ? $category['enable'] : 0;
                            if (isset($category['title'])) {
                                $title = Utils::converGbkString($category['title']);
                            }
                            break;
                        }
                    }
                }
                $html .= "<tr class='myportal'>\n\t\t\t\t\t\t\t\t\t\t  <td valign='top'><input class='myportal_enable' type='checkbox' " . ($enable == 1 ? "checked" : "") . "/></td>\n\t\t\t\t\t\t\t\t\t\t  <td><input type='text' class='txt myportal_sort' style='width:20px' value='" . $sort . "'/></td>\n\t\t\t\t\t\t\t\t\t\t  <input type='hidden' class='myportal_id'  value='" . $cat['catid'] . "'/>\n\t\t\t\t\t\t\t\t\t\t  <td>" . $cat['catname'] . "</td>\n\t\t\t\t\t\t\t\t\t\t  <td><input type='text' class='txt myportal_title' style='width:100px' value='" . $title . "'/></td>\n\t\t\t\t\t\t\t\t\t  </tr>";
            }
        }
    }
    $tplVars['html'] = $html;
}
if (isset($_GET['debug']) && $_GET['debug'] == '1') {
    echo json_encode($params);
    exit;
}
Utils::loadTemplate(dirname(__FILE__) . '/view/' . $tpl, $params, $tplVars);
runlog('bigapp', "show {$tpl} page succ");
Ejemplo n.º 12
0
function notifymembers($operation, $variable)
{
    global $_G, $lang, $urladd, $conditions, $search_condition;
    if (!empty($_GET['current'])) {
        $subject = $message = '';
        if ($settings = C::t('common_setting')->fetch($variable, true)) {
            $subject = $settings['subject'];
            $message = $settings['message'];
        }
        $setarr = array();
        foreach ($_G['setting']['extcredits'] as $id => $value) {
            if (isset($_GET['extcredits' . $id])) {
                if ($_GET['updatecredittype'] == 0) {
                    $setarr['extcredits' . $id] = $_GET['extcredits' . $id];
                } else {
                    $setarr[] = 'extcredits' . $id;
                }
            }
        }
    } else {
        $current = 0;
        $subject = $_GET['subject'];
        $message = $_GET['message'];
        $subject = trim($subject);
        $message = trim(str_replace("\t", ' ', $message));
        $addmsg = '';
        if ($_GET['notifymembers'] && $_GET['notifymember'] && !($subject && $message)) {
            cpmsg('members_newsletter_sm_invalid', '', 'error');
        }
        if ($operation == 'reward') {
            $serarr = array();
            if ($_GET['updatecredittype'] == 0) {
                if (is_array($_GET['addextcredits']) && !empty($_GET['addextcredits'])) {
                    foreach ($_GET['addextcredits'] as $key => $value) {
                        $value = intval($value);
                        if (isset($_G['setting']['extcredits'][$key]) && !empty($value)) {
                            $setarr['extcredits' . $key] = $value;
                            $addmsg .= $_G['setting']['extcredits'][$key]['title'] . ": " . ($value > 0 ? '<em class="xi1">+' : '<em class="xg1">') . "{$value}</em> " . $_G['setting']['extcredits'][$key]['unit'] . ' &nbsp; ';
                        }
                    }
                }
            } else {
                if (is_array($_GET['resetextcredits']) && !empty($_GET['resetextcredits'])) {
                    foreach ($_GET['resetextcredits'] as $key => $value) {
                        $value = intval($value);
                        if (isset($_G['setting']['extcredits'][$key]) && !empty($value)) {
                            $setarr[] = 'extcredits' . $key;
                            $addmsg .= $_G['setting']['extcredits'][$key]['title'] . ': <em class="xg1">' . cplang('members_reward_clean') . '</em> &nbsp; ';
                        }
                    }
                }
            }
            if ($addmsg) {
                $addmsg = ' &nbsp; <br /><br /><b>' . cplang('members_reward_affect') . ':</b><br \\>' . $addmsg;
            }
            if (!empty($setarr)) {
                $limit = 2000;
                set_time_limit(0);
                $i = 0;
                while (true) {
                    $uids = searchmembers($search_condition, $limit, $i * $limit);
                    $allcount = C::t('common_member_count')->fetch_all($uids);
                    $insertmember = array_diff($uids, array_keys($allcount));
                    foreach ($insertmember as $uid) {
                        C::t('common_member_count')->insert(array('uid' => $uid));
                    }
                    if ($_GET['updatecredittype'] == 0) {
                        C::t('common_member_count')->increase($uids, $setarr);
                    } else {
                        C::t('common_member_count')->clear_extcredits($uids, $setarr);
                    }
                    if (count($uids) < $limit) {
                        break;
                    }
                    $i++;
                }
            } else {
                cpmsg('members_reward_invalid', '', 'error');
            }
            if (!$_GET['notifymembers']) {
                cpmsg('members_reward_succeed', '', 'succeed');
            }
        } elseif ($operation == 'confermedal') {
            $medals = $_GET['medals'];
            if (!empty($medals)) {
                $medalids = array();
                foreach ($medals as $key => $medalid) {
                    $medalids[] = $key;
                }
                $medalsnew = $comma = '';
                $medalsnewarray = $medalidarray = array();
                foreach (C::t('forum_medal')->fetch_all_by_id($medalids) as $medal) {
                    $medal['status'] = empty($medal['expiration']) ? 0 : 1;
                    $medal['expiration'] = empty($medal['expiration']) ? 0 : TIMESTAMP + $medal['expiration'] * 86400;
                    $medal['medal'] = $medal['medalid'] . (empty($medal['expiration']) ? '' : '|' . $medal['expiration']);
                    $medalsnew .= $comma . $medal['medal'];
                    $medalsnewarray[] = $medal;
                    $medalidarray[] = $medal['medalid'];
                    $comma = "\t";
                }
                $uids = searchmembers($search_condition);
                if ($uids) {
                    foreach (C::t('common_member_field_forum')->fetch_all($uids) as $uid => $medalnew) {
                        $usermedal = array();
                        $addmedalnew = '';
                        if (empty($medalnew['medals'])) {
                            $addmedalnew = $medalsnew;
                        } else {
                            foreach ($medalidarray as $medalid) {
                                $usermedal_arr = explode("\t", $medalnew['medals']);
                                foreach ($usermedal_arr as $key => $medalval) {
                                    list($usermedalid, ) = explode("|", $medalval);
                                    $usermedal[] = $usermedalid;
                                }
                                if (!in_array($medalid, $usermedal)) {
                                    $addmedalnew .= $medalid . "\t";
                                }
                            }
                            $addmedalnew .= $medalnew['medals'];
                        }
                        C::t('common_member_field_forum')->update($medalnew['uid'], array('medals' => $addmedalnew), true);
                        foreach ($medalsnewarray as $medalnewarray) {
                            $data = array('uid' => $medalnew['uid'], 'medalid' => $medalnewarray['medalid'], 'type' => 0, 'dateline' => $_G['timestamp'], 'expiration' => $medalnewarray['expiration'], 'status' => $medalnewarray['status']);
                            C::t('forum_medallog')->insert($data);
                            C::t('common_member_medal')->insert(array('uid' => $medalnew['uid'], 'medalid' => $medalnewarray['medalid']), 0, 1);
                        }
                    }
                }
            }
            if (!$_GET['notifymember']) {
                cpmsg('members_confermedal_succeed', '', 'succeed');
            }
        } elseif ($operation == 'confermagic') {
            $magics = $_GET['magic'];
            $magicnum = $_GET['magicnum'];
            if ($magics) {
                require_once libfile('function/magic');
                $limit = 200;
                set_time_limit(0);
                for ($i = 0; $i > -1; $i++) {
                    $uids = searchmembers($search_condition, $limit, $i * $limit);
                    foreach ($magics as $magicid) {
                        $uparray = $insarray = array();
                        if (empty($magicnum[$magicid])) {
                            continue;
                        }
                        $query = C::t('common_member_magic')->fetch_all($uids ? $uids : -1, $magicid);
                        foreach ($query as $row) {
                            $uparray[] = $row['uid'];
                        }
                        if ($uparray) {
                            C::t('common_member_magic')->increase($uparray, $magicid, array('num' => $magicnum[$magicid]));
                        }
                        $insarray = array_diff($uids, $uparray);
                        if ($insarray) {
                            $sqls = array();
                            foreach ($insarray as $uid) {
                                C::t('common_member_magic')->insert(array('uid' => $uid, 'magicid' => $magicid, 'num' => $magicnum[$magicid]));
                            }
                        }
                        foreach ($uids as $uid) {
                            updatemagiclog($magicid, '3', $magicnum[$magicid], '', $uid);
                        }
                    }
                    if (count($uids) < $limit) {
                        break;
                    }
                }
            }
        }
        C::t('common_setting')->update($variable, array('subject' => $subject, 'message' => $message));
    }
    $pertask = intval($_GET['pertask']);
    $current = $_GET['current'] ? intval($_GET['current']) : 0;
    $continue = FALSE;
    if (!function_exists('sendmail')) {
        include libfile('function/mail');
    }
    if ($_GET['notifymember'] && in_array($_GET['notifymembers'], array('pm', 'notice', 'email', 'mobile'))) {
        $uids = searchmembers($search_condition, $pertask, $current);
        require_once libfile('function/discuzcode');
        $message = in_array($_GET['notifymembers'], array('email', 'notice')) && $_GET['posttype'] ? discuzcode($message, 1, 0, 1, '', '', '', 1) : discuzcode($message, 1, 0);
        $pmuids = array();
        if ($_GET['notifymembers'] == 'pm') {
            $membernum = countmembers($search_condition, $urladd);
            $gpmid = $_GET['gpmid'];
            if (!$gpmid) {
                $pmdata = array('authorid' => $_G['uid'], 'author' => !$_GET['system'] ? $_G['member']['username'] : '', 'dateline' => TIMESTAMP, 'message' => ($subject ? '<b>' . $subject . '</b><br /> &nbsp; ' : '') . $message . $addmsg, 'numbers' => $membernum);
                $gpmid = C::t('common_grouppm')->insert($pmdata, true);
            }
            $urladd .= '&gpmid=' . $gpmid;
        }
        $members = C::t('common_member')->fetch_all($uids);
        if ($_GET['notifymembers'] == 'mobile') {
            $toUids = array_keys($members);
            if ($_G['setting']['cloud_status'] && !empty($toUids)) {
                try {
                    $noticeService = Cloud::loadClass('Service_Client_Notification');
                    $fromType = $_GET['system'] ? 1 : 2;
                    $noticeService->addSiteMasterUserNotify($toUids, $subject, $message, $_G['uid'], $_G['username'], $fromType, TIMESTAMP);
                } catch (Cloud_Service_Client_RestfulException $e) {
                    cpmsg('[' . $e->getCode() . ']' . $e->getMessage(), '', 'error');
                }
            }
        } else {
            foreach ($members as $member) {
                if ($_GET['notifymembers'] == 'pm') {
                    C::t('common_member_grouppm')->insert(array('uid' => $member['uid'], 'gpmid' => $gpmid, 'status' => 0), false, true);
                    $newpm = setstatus(2, 1, $member['newpm']);
                    C::t('common_member')->update($member['uid'], array('newpm' => $newpm));
                } elseif ($_GET['notifymembers'] == 'notice') {
                    notification_add($member['uid'], 'system', 'system_notice', array('subject' => $subject, 'message' => $message . $addmsg, 'from_id' => 0, 'from_idtype' => 'sendnotice'), 1);
                } elseif ($_GET['notifymembers'] == 'email') {
                    if (!sendmail("{$member['username']} <{$member['email']}>", $subject, $message . $addmsg)) {
                        runlog('sendmail', "{$member['email']} sendmail failed.");
                    }
                }
                $log = array();
                if ($_GET['updatecredittype'] == 0) {
                    foreach ($setarr as $key => $val) {
                        if (empty($val)) {
                            continue;
                        }
                        $val = intval($val);
                        $id = intval($key);
                        $id = !$id && substr($key, 0, -1) == 'extcredits' ? intval(substr($key, -1, 1)) : $id;
                        if (0 < $id && $id < 9) {
                            $log['extcredits' . $id] = $val;
                        }
                    }
                    $logtype = 'RPR';
                } else {
                    foreach ($setarr as $val) {
                        if (empty($val)) {
                            continue;
                        }
                        $id = intval($val);
                        $id = !$id && substr($val, 0, -1) == 'extcredits' ? intval(substr($val, -1, 1)) : $id;
                        if (0 < $id && $id < 9) {
                            $log['extcredits' . $id] = '-1';
                        }
                    }
                    $logtype = 'RPZ';
                }
                include_once libfile('function/credit');
                credit_log($member['uid'], $logtype, $member['uid'], $log);
                $continue = TRUE;
            }
        }
    }
    $newsletter_detail = array();
    if ($continue) {
        $next = $current + $pertask;
        $newsletter_detail = array('uid' => $_G['uid'], 'current' => $current, 'next' => $next, 'search_condition' => serialize($search_condition), 'action' => "action=members&operation={$operation}&{$operation}submit=yes&current={$next}&pertask={$pertask}&system={$_GET['system']}&posttype={$_GET['posttype']}&notifymember={$_GET['notifymember']}&notifymembers=" . rawurlencode($_GET['notifymembers']) . $urladd);
        save_newsletter('newsletter_detail', $newsletter_detail);
        $logaddurl = '';
        foreach ($setarr as $k => $v) {
            if ($_GET['updatecredittype'] == 0) {
                $logaddurl .= '&' . $k . '=' . $v;
            } else {
                $logaddurl .= '&' . $v . '=-1';
            }
        }
        $logaddurl .= '&updatecredittype=' . $_GET['updatecredittype'];
        cpmsg("{$lang['members_newsletter_send']}: " . cplang('members_newsletter_processing', array('current' => $current, 'next' => $next, 'search_condition' => serialize($search_condition))), "action=members&operation={$operation}&{$operation}submit=yes&current={$next}&pertask={$pertask}&system={$_GET['system']}&posttype={$_GET['posttype']}&notifymember={$_GET['notifymember']}&notifymembers=" . rawurlencode($_GET['notifymembers']) . $urladd . $logaddurl, 'loadingform');
    } else {
        del_newsletter('newsletter_detail');
        if ($operation == 'reward' && $_GET['notifymembers'] == 'pm') {
            $message = '';
        } else {
            $message = '_notify';
        }
        cpmsg('members' . ($operation ? '_' . $operation : '') . $message . '_succeed', '', 'succeed');
    }
}
Ejemplo n.º 13
0
function sendmail($toemail, $subject, $message, $from = '')
{
    global $_G;
    if (!is_array($_G['setting']['mail'])) {
        $_G['setting']['mail'] = dunserialize($_G['setting']['mail']);
    }
    $_G['setting']['mail']['server'] = $_G['setting']['mail']['port'] = $_G['setting']['mail']['auth'] = $_G['setting']['mail']['from'] = $_G['setting']['mail']['auth_username'] = $_G['setting']['mail']['auth_password'] = '';
    if ($_G['setting']['mail']['mailsend'] != 1) {
        $smtpnum = count($_G['setting']['mail']['smtp']);
        if ($smtpnum) {
            $rid = rand(0, $smtpnum - 1);
            $smtp = $_G['setting']['mail']['smtp'][$rid];
            $_G['setting']['mail']['server'] = $smtp['server'];
            $_G['setting']['mail']['port'] = $smtp['port'];
            $_G['setting']['mail']['auth'] = $smtp['auth'] ? 1 : 0;
            $_G['setting']['mail']['from'] = $smtp['from'];
            $_G['setting']['mail']['auth_username'] = $smtp['auth_username'];
            $_G['setting']['mail']['auth_password'] = $smtp['auth_password'];
        }
    }
    $message = preg_replace("/href\\=\"(?!(http|https)\\:\\/\\/)(.+?)\"/i", 'href="' . $_G['siteurl'] . '\\2"', $message);
    $message = <<<EOT
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset={$_G['charset']}">
<title>{$subject}</title>
</head>
<body>
{$subject}<br />
{$message}
</body>
</html>
EOT;
    $maildelimiter = $_G['setting']['mail']['maildelimiter'] == 1 ? "\r\n" : ($_G['setting']['mail']['maildelimiter'] == 2 ? "\r" : "\n");
    $mailusername = isset($_G['setting']['mail']['mailusername']) ? $_G['setting']['mail']['mailusername'] : 1;
    $_G['setting']['mail']['port'] = $_G['setting']['mail']['port'] ? $_G['setting']['mail']['port'] : 25;
    $_G['setting']['mail']['mailsend'] = $_G['setting']['mail']['mailsend'] ? $_G['setting']['mail']['mailsend'] : 1;
    if ($_G['setting']['mail']['mailsend'] == 3) {
        $email_from = empty($from) ? $_G['setting']['adminemail'] : $from;
    } else {
        $email_from = $from == '' ? '=?' . CHARSET . '?B?' . base64_encode($_G['setting']['sitename']) . "?= <" . $_G['setting']['adminemail'] . ">" : (preg_match('/^(.+?) \\<(.+?)\\>$/', $from, $mats) ? '=?' . CHARSET . '?B?' . base64_encode($mats[1]) . "?= <{$mats['2']}>" : $from);
    }
    $email_to = preg_match('/^(.+?) \\<(.+?)\\>$/', $toemail, $mats) ? $mailusername ? '=?' . CHARSET . '?B?' . base64_encode($mats[1]) . "?= <{$mats['2']}>" : $mats[2] : $toemail;
    $email_subject = '=?' . CHARSET . '?B?' . base64_encode(preg_replace("/[\r|\n]/", '', '[' . $_G['setting']['sitename'] . '] ' . $subject)) . '?=';
    $email_message = chunk_split(base64_encode(str_replace("\n", "\r\n", str_replace("\r", "\n", str_replace("\r\n", "\n", str_replace("\n\r", "\r", $message))))));
    $host = $_SERVER['HTTP_HOST'];
    $version = $_G['setting']['version'];
    $headers = "From: {$email_from}{$maildelimiter}X-Priority: 3{$maildelimiter}X-Mailer: {$host} {$version} {$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/html; charset=" . CHARSET . "{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
    if ($_G['setting']['mail']['mailsend'] == 1) {
        if (function_exists('mail') && @mail($email_to, $email_subject, $email_message, $headers)) {
            return true;
        }
        return false;
    } elseif ($_G['setting']['mail']['mailsend'] == 2) {
        if (!($fp = fsocketopen($_G['setting']['mail']['server'], $_G['setting']['mail']['port'], $errno, $errstr, 30))) {
            runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) CONNECT - Unable to connect to the SMTP server", 0);
            return false;
        }
        stream_set_blocking($fp, true);
        $lastmessage = fgets($fp, 512);
        if (substr($lastmessage, 0, 3) != '220') {
            runlog('SMTP', "{$_G[setting][mail][server]}:{$_G[setting][mail][port]} CONNECT - {$lastmessage}", 0);
            return false;
        }
        fputs($fp, ($_G['setting']['mail']['auth'] ? 'EHLO' : 'HELO') . " uchome\r\n");
        $lastmessage = fgets($fp, 512);
        if (substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) {
            runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) HELO/EHLO - {$lastmessage}", 0);
            return false;
        }
        while (1) {
            if (substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) {
                break;
            }
            $lastmessage = fgets($fp, 512);
        }
        if ($_G['setting']['mail']['auth']) {
            fputs($fp, "AUTH LOGIN\r\n");
            $lastmessage = fgets($fp, 512);
            if (substr($lastmessage, 0, 3) != 334) {
                runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) AUTH LOGIN - {$lastmessage}", 0);
                return false;
            }
            fputs($fp, base64_encode($_G['setting']['mail']['auth_username']) . "\r\n");
            $lastmessage = fgets($fp, 512);
            if (substr($lastmessage, 0, 3) != 334) {
                runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) USERNAME - {$lastmessage}", 0);
                return false;
            }
            fputs($fp, base64_encode($_G['setting']['mail']['auth_password']) . "\r\n");
            $lastmessage = fgets($fp, 512);
            if (substr($lastmessage, 0, 3) != 235) {
                runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) PASSWORD - {$lastmessage}", 0);
                return false;
            }
            $email_from = $_G['setting']['mail']['from'];
        }
        fputs($fp, "MAIL FROM: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $email_from) . ">\r\n");
        $lastmessage = fgets($fp, 512);
        if (substr($lastmessage, 0, 3) != 250) {
            fputs($fp, "MAIL FROM: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $email_from) . ">\r\n");
            $lastmessage = fgets($fp, 512);
            if (substr($lastmessage, 0, 3) != 250) {
                runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) MAIL FROM - {$lastmessage}", 0);
                return false;
            }
        }
        fputs($fp, "RCPT TO: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $toemail) . ">\r\n");
        $lastmessage = fgets($fp, 512);
        if (substr($lastmessage, 0, 3) != 250) {
            fputs($fp, "RCPT TO: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $toemail) . ">\r\n");
            $lastmessage = fgets($fp, 512);
            runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) RCPT TO - {$lastmessage}", 0);
            return false;
        }
        fputs($fp, "DATA\r\n");
        $lastmessage = fgets($fp, 512);
        if (substr($lastmessage, 0, 3) != 354) {
            runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) DATA - {$lastmessage}", 0);
            return false;
        }
        $timeoffset = $_G['setting']['timeoffset'];
        if (function_exists('date_default_timezone_set')) {
            @date_default_timezone_set('Etc/GMT' . ($timeoffset > 0 ? '-' : '+') . abs($timeoffset));
        }
        $headers .= 'Message-ID: <' . date('YmdHs') . '.' . substr(md5($email_message . microtime()), 0, 6) . rand(100000, 999999) . '@' . $_SERVER['HTTP_HOST'] . ">{$maildelimiter}";
        fputs($fp, "Date: " . date('r') . "\r\n");
        fputs($fp, "To: " . $email_to . "\r\n");
        fputs($fp, "Subject: " . $email_subject . "\r\n");
        fputs($fp, $headers . "\r\n");
        fputs($fp, "\r\n\r\n");
        fputs($fp, "{$email_message}\r\n.\r\n");
        $lastmessage = fgets($fp, 512);
        if (substr($lastmessage, 0, 3) != 250) {
            runlog('SMTP', "({$_G[setting][mail][server]}:{$_G[setting][mail][port]}) END - {$lastmessage}", 0);
        }
        fputs($fp, "QUIT\r\n");
        return true;
    } elseif ($_G['setting']['mail']['mailsend'] == 3) {
        ini_set('SMTP', $_G['setting']['mail']['server']);
        ini_set('smtp_port', $_G['setting']['mail']['port']);
        ini_set('sendmail_from', $email_from);
        if (function_exists('mail') && @mail($email_to, $email_subject, $email_message, $headers)) {
            return true;
        }
        return false;
    }
}
Ejemplo n.º 14
0
foreach ($params as &$item) {
    $item = str_replace("#u", "\\u", $item);
}
if (!$params["iosurl"]) {
    $params["iosurl"] = "";
}
if (!$params["appdesc"]) {
    $params["appdesc"] = "";
}
$params["ajaxurl"] = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:mobileapi';
$params["mobileurl"] = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:mobile';
$imgUrl = rtrim($_G['siteurl'], '/') . '/' . BigAppConf::$upfileUrl . '&key=' . urlencode('mobile_app_image_s');
$tplVars = array("plugin_path" => rtrim($_G['siteurl'], '/') . '/source/plugin/bigapp', "imgUrl" => $imgUrl);
///////////////////////////////////
updatecache('setting');
if (isset($_G['setting']['bigapp_pcset'])) {
    $_G['setting']['bigapp_pcset'] = unserialize($_G['setting']['bigapp_pcset']);
}
$params["ajaxurl2"] = rtrim($_G['siteurl'], '/') . '/plugin.php?id=bigapp:pcset&inajax=1';
$params["moburl_switch"] = 0;
$params["moburl"] = "";
if (isset($_G['setting']['bigapp_pcset']['moburl_switch'])) {
    $params["moburl_switch"] = $_G['setting']['bigapp_pcset']['moburl_switch'];
}
if (isset($_G['setting']['bigapp_pcset']['moburl'])) {
    $params["moburl"] = $_G['setting']['bigapp_pcset']['moburl'];
}
///////////////////////////////////
Utils::loadTemplate(FILE_PATH . '/view/mobileset.tpl', $params, $tplVars);
runlog('bigapp', 'show release page succ');
// vim600: sw=4 ts=4 fdm=marker syn=php
Ejemplo n.º 15
0
function swritefile($filename, $writetext, $openmod = 'w')
{
    if (@($fp = fopen($filename, $openmod))) {
        flock($fp, 2);
        fwrite($fp, $writetext);
        fclose($fp);
        return true;
    } else {
        runlog('error', "File: {$filename} write error.");
        return false;
    }
}
Ejemplo n.º 16
0
 function output()
 {
     global $_G;
     $variable = array('pmid' => $GLOBALS['return'], 'message' => $_POST['show_message']);
     if (isset($_G['setting']['bigapp_push_config']) && is_string($_G['setting']['bigapp_push_config'])) {
         $_G['setting']['bigapp_push_config'] = unserialize($_G['setting']['bigapp_push_config']);
     }
     if (!isset($_G['setting']['bigapp_push_config']['push_enabled'])) {
         $_G['setting']['bigapp_push_config']['push_enabled'] = 1;
     }
     if ($_G['setting']['bigapp_push_config']['push_enabled']) {
         if ($GLOBALS['return'] > 0) {
             $sql = 'SELECT uid, username FROM ' . DB::table('common_member') . ' WHERE uid IN (' . $_G['uid'] . ', ' . $_REQUEST['touid'] . ')';
             $query = DB::query($sql);
             $uid = null;
             $touid = null;
             $user = null;
             $touser = null;
             while ($tmp = DB::fetch($query)) {
                 if ($tmp['uid'] === $_G['uid']) {
                     $uid = $_G['uid'];
                     $user = $tmp['username'];
                     continue;
                 }
                 $touid = $tmp['uid'];
                 $touser = $tmp['username'];
             }
             if (!is_null($uid) && !is_null($touid) && !is_null($user) && !is_null($touser) && $uid != $touid) {
                 if (function_exists('iconv')) {
                     $user = iconv(CHARSET, 'UTF-8//ignore', $user);
                     $touser = iconv(CHARSET, 'UTF-8//ignore', $touser);
                 } else {
                     $user = mb_convert_encoding($user, 'UTF-8', CHARSET);
                     $touser = mb_convert_encoding($touser, 'UTF-8', CHARSET);
                 }
                 $title = '您有新的消息,请注意查收';
                 $content = "用户 {$user} 向您发来新消息,详情点击查看";
                 $extra = array('user' => '__DONT_DICONV_TO_UTF8___' . $user, 'touser' => '__DONT_DICONV_TO_UTF8___' . $touser, 'uid' => $uid, 'touid' => $touid, 'pmid' => $GLOBALS['return'], 'message' => '__DONT_DICONV_TO_UTF8___' . $_REQUEST['message']);
                 require_once dirname(dirname(dirname(__FILE__))) . '/libs/pushmsg.inc.php';
                 $ret = PushMsg::sendMessage($touid, $title, $content, 1, $extra, 1);
                 //仅仅推送消息
                 $result = 'fail';
                 if (true === $ret) {
                     $result = 'succ';
                 }
                 runlog('bigapp', "[mobile]try to send message notice [ uid: {$uid}, touid: {$touid}, user: {$user}, touser: {$touser}, result: {$result} ].");
             }
         }
     }
     bigapp_core::result(bigapp_core::variable($variable));
 }
Ejemplo n.º 17
0
 function delete($group_name, $filename)
 {
     $file_arr = parse_url($filename);
     $filename = substr($file_arr['path'], 1);
     try {
         $tracker_server = tracker_get_connectionByGroupName($group_name);
         if ($tracker_server == false) {
             runlog('api_fastDFS_log', "tracker_get_connection fail!");
             return -1;
         }
         $storage_server = null;
         $result = storage_delete_file($tracker_server, $storage_server, $group_name, $filename);
         if ($result == 0) {
             return 0;
             //删除成功
         } else {
             runlog('api_fastDFS_log', "storage_delete_file fail, result={$result}");
         }
     } catch (Exception $e) {
         return -1;
         //删除失败
     }
     return -1;
     //删除失败
 }
Ejemplo n.º 18
0
function getfilepath($fileext, $mkdir=false) {
	global $_SGLOBAL, $_SC;

	$filepath = "{$_SGLOBAL['supe_uid']}_{$_SGLOBAL['timestamp']}".random(4).".$fileext";
	$name1 = gmdate('Ym');
	$name2 = gmdate('j');

	if($mkdir) {
		$newfilename = $_SC['attachdir'].'./'.$name1;
		if(!is_dir($newfilename)) {
			if(!@mkdir($newfilename)) {
				runlog('error', "DIR: $newfilename can not make");
				return $filepath;
			}
		}
		$newfilename .= '/'.$name2;
		if(!is_dir($newfilename)) {
			if(!@mkdir($newfilename)) {
				runlog('error', "DIR: $newfilename can not make");
				return $name1.'/'.$filepath;
			}
		}
	}
	return $name1.'/'.$name2.'/'.$filepath;
}
Ejemplo n.º 19
0
if (isset($_REQUEST["ajax"]) && $_REQUEST['ajax'] == 1) {
    require_once dirname(__FILE__) . "/models/push/JpushClient.php";
    $paramRet = BIGAPPJSON::encode(array('request_id' => rand(1000000, 10000000000), 'error_code' => 100802, 'error_msg' => 'invalid param'));
    $authRet = BIGAPPJSON::encode(array('request_id' => rand(1000000, 10000000000), 'error_code' => 100803, 'error_msg' => 'auth failed'));
    $svrRet = BIGAPPJSON::encode(array('request_id' => rand(1000000, 10000000000), 'error_code' => 100800, 'error_msg' => 'internal server error'));
    if (!isset($_G['groupid']) || 1 != $_G['groupid']) {
        echo $authRet;
        die(0);
    }
    //1. 发送消息
    if ($_REQUEST["action"] == 'submit') {
        $params = array("alias" => "all", "title" => $_REQUEST["title"], "content" => $_REQUEST["msg"], "istest" => 0);
        $ret = Bigapp_JpushClient::sendMessage($params);
        echo $ret;
    } else {
        if ($_REQUEST["action"] == 'query') {
            $resData = C::t("#bigapp#bigapp_push_message")->query();
            echo BIGAPPJSON::encode(array("data" => $resData));
        } else {
            echo $paramRet;
        }
    }
    die(0);
}
require_once dirname(__FILE__) . '/libs/menu.inc.php';
require_once dirname(__FILE__) . '/libs/verify.inc.php';
$params = array("groupid" => isset($_G['groupid']) ? intval($_G['groupid']) : 7, "appid" => $appid, "api" => BigappEnv::getSiteUrl() . "/plugin.php?id=bigapp:pushmsg&ajax=1");
$tplVars = array("plugin_path" => BigappEnv::getPluginPath());
Utils::loadTemplate(dirname(__FILE__) . '/view/pushmsg.tpl', $params, $tplVars);
runlog('bigapp', 'show pushmsg page succ');
// vim600: sw=4 ts=4 fdm=marker syn=php
Ejemplo n.º 20
0
function showTaskResult($appInfo, $taskInfo)
{
    global $ak, $pluginid, $_G;
    $appIcon = $taskInfo['task_info']['icon_image'];
    $appName = $taskInfo['task_info']['app_name'];
    $url = Utils::addUrlQueryString(BigAppConf::$taskScheduleUrl, array('task_id' => $taskInfo['task_id'], 'app_key' => $ak));
    $tpl = file_get_contents(dirname(__FILE__) . '/view/appLoad.tpl');
    if (is_string($tpl) && strtolower(CHARSET) != 'utf-8' && strtolower(CHARSET) != 'utf8') {
        if (function_exists('iconv')) {
            $tpl = @iconv('UTF-8', 'GBK//ignore', $tpl);
        } else {
            if (function_exists('mb_convert_encoding')) {
                $tpl = @mb_convert_encoding($tpl, 'GBK', 'UTF-8');
            }
        }
    }
    $tpl = str_replace('<% app_charset %>', CHARSET, $tpl);
    $tpl = str_replace('<% app_icon %>', $appIcon, $tpl);
    if (function_exists('iconv')) {
        $appName = iconv('UTF-8', CHARSET . '//ignore', $appName);
    } else {
        $appName = mb_convert_encoding($appName, CHARSET, 'UTF-8');
    }
    $tpl = str_replace('<% app_name %>', $appName, $tpl);
    $tpl = str_replace('<% schedule_url %>', $url, $tpl);
    $tpl = str_replace('<% error_url %>', rtrim($_G['siteurl'], '/') . '/admin.php?action=plugins&operation=config&do=' . $pluginid . '&identifier=bigapp&pmod=buildapp&force=1', $tpl);
    echo $tpl;
    runlog('bigapp', 'show my app page succ');
}
Ejemplo n.º 21
0
//更新用户最后发送时间
if($touids) {
	$_SGLOBAL['db']->query("UPDATE ".tname('space')." SET lastsend='$_SGLOBAL[timestamp]' WHERE uid IN (".simplode($touids).")");
}

//删除邮件
$_SGLOBAL['db']->query("DELETE FROM ".tname('mailcron')." WHERE cid IN (".simplode($cids).")");
$_SGLOBAL['db']->query("DELETE FROM ".tname('mailqueue')." WHERE cid IN (".simplode($cids).")");

//开始发送
include_once(S_ROOT.'./source/function_sendmail.php');
foreach ($list as $cid => $value) {
	$mlist = $sublist[$cid];
	if($value['email'] && $mlist) {
		$subject = getstr($mlist[0]['subject'], 80, 0, 0, 0, 0, -1);
		$message = '';
		foreach ($mlist as $subvalue) {
			if($subvalue['message']) {
				$message .= "<br><strong>$subvalue[subject]</strong><br>$subvalue[message]<br>";
			} else {
				$message .= $subvalue['subject'].'<br>';
			}
		}
		if(!sendmail($value['email'], $subject, $message)) {
			runlog('sendmail', "$value[email] sendmail failed.");
		}
	}
}

?>
Ejemplo n.º 22
0
        if ($weixinid != $member['weixinid'] && C::t('user')->fetch_by_weixinid($weixinid)) {
            showmessage('该微信号已经被注册');
        }
        $setarr['weixinid'] = $weixinid;
    } else {
        $setarr['weixinid'] = '';
    }
    if ($setarr) {
        if (C::t('user')->update($_G['uid'], $setarr)) {
            wx_updateUser($_G['uid']);
        }
    }
    showmessage('do_success', dreferer());
} elseif ($_GET['sendmail']) {
    $user = C::t('user')->fetch($_G['uid']);
    $idstring = random(6);
    $authstr = $_G['setting']['regverify'] == 1 ? "{$_G['timestamp']}\t2\t{$idstring}" : '';
    C::t('user')->update($_G['uid'], array('authstr' => $authstr));
    $verifyurl = "{$_G[siteurl]}user.php?mod=activate&amp;uid={$_G[uid]}&amp;id={$idstring}";
    $email_verify_message = lang('email', 'email_verify_message', array('username' => $_G['member']['username'], 'sitename' => $_G['setting']['sitename'], 'siteurl' => $_G['siteurl'], 'url' => $verifyurl));
    if (!sendmail("{$user['username']} <{$user['email']}>", lang('email', 'email_verify_subject'), $email_verify_message)) {
        runlog('sendmail', "{$user['email']} sendmail failed.");
        showmessage('邮件发送失败!请检查您的登录邮箱是否正确,或者更换登录邮箱', 'user.php?mod=password');
    } else {
        showmessage('邮件已发送,可能需要等几分钟才能收到邮件', 'user.php?mod=password');
    }
} else {
    $user = C::t('user')->fetch($_G['uid']);
    include template('password');
}
exit;
Ejemplo n.º 23
0
$akskRet = BIGAPPJSON::encode(array('request_id' => rand(1000000, 10000000000), 'error_code' => 100803, 'error_msg' => 'auth failed', 'show_tips' => '__DONT_DICONV_TO_UTF8___您尚未在应用设置中填写jpush的appkey或master_secret,无法发送测试消息'));
$svrRet = BIGAPPJSON::encode(array('request_id' => rand(1000000, 10000000000), 'error_code' => 100804, 'error_msg' => 'internal server error', 'show_tips' => '__DONT_DICONV_TO_UTF8___服务器内部错误'));
$aliasRet = array('request_id' => rand(1000000, 10000000000), 'error_code' => 100805, 'error_msg' => 'invalid alias', 'show_tips' => '__DONT_DICONV_TO_UTF8___请在网络良好的环境下开启客户端');
header('Content-Type: text/html; charset=utf-8');
if (!isset($_G['groupid']) || 1 != $_G['groupid']) {
    echo $authRet;
    die(0);
}
$aksk = BigappEnv::getAkSk();
$ak = $aksk["ak"];
$sk = $aksk["sk"];
$obj = new BkSvr($ak, $sk, 30);
$ret = $obj->getInfo(BigAppConf::$pushUrl, $_GET, false, false);
if (false === $ret || 0 != $ret['error_code']) {
    if (100020 == $ret['error_code']) {
        $aliasRet['show_tips'] .= '并以' . $_G['username'] . '帐号登录,然后重试';
        $aliasRet = BIGAPPJSON::encode($aliasRet);
        echo $aliasRet;
        die(0);
    }
    if (100021 == $ret['error_code']) {
        echo $akskRet;
        die(0);
    }
    echo $svrRet;
    die(0);
}
$ret['show_tips'] = '__DONT_DICONV_TO_UTF8___测试消息发送成功,稍后您手机应该能收到消息';
echo BIGAPPJSON::encode($ret);
runlog('bigapp', 'send test message succ');
die(0);
function sendmail($toemail, $subject, $message, $from='') {
	global $_SC, $_SCONFIG, $_SGLOBAL, $space, $_SN;
	
	$_SCONFIG['linkguide'] = 0;
	
	include template('sendmail');
	$message = ob_get_contents();
	obclean();
	
	include_once(S_ROOT.'./data/data_mail.php');
	$mail = $_SGLOBAL['mail'];
	
	//邮件头的分隔符
	$maildelimiter = $mail['maildelimiter'] == 1 ? "\r\n" : ($mail['maildelimiter'] == 2 ? "\r" : "\n");
	//收件人地址中包含用户名
	$mailusername = isset($mail['mailusername']) ? $mail['mailusername'] : 1;
	//端口
	$mail['port'] = $mail['port'] ? $mail['port'] : 25;
	$mail['mailsend'] = $mail['mailsend'] ? $mail['mailsend'] : 1;
	
	//发信者
	if($mail['mailsend'] == 3) {
		$email_from = empty($from) ? $_SCONFIG['adminemail'] : $from;
	} else {
		$email_from = $from == '' ? '=?'.$_SC['charset'].'?B?'.base64_encode($_SCONFIG['sitename'])."?= <".$_SCONFIG['adminemail'].">" : (preg_match('/^(.+?) \<(.+?)\>$/',$from, $mats) ? '=?'.$_SC['charset'].'?B?'.base64_encode($mats[1])."?= <$mats[2]>" : $from);
	}
	
	$email_to = preg_match('/^(.+?) \<(.+?)\>$/',$toemail, $mats) ? ($mailusername ? '=?'.$_SC['charset'].'?B?'.base64_encode($mats[1])."?= <$mats[2]>" : $mats[2]) : $toemail;;
	
	$email_subject = '=?'.$_SC['charset'].'?B?'.base64_encode(preg_replace("/[\r|\n]/", '', '['.$_SCONFIG['sitename'].'] '.$subject)).'?=';
	$email_message = chunk_split(base64_encode(str_replace("\n", "\r\n", str_replace("\r", "\n", str_replace("\r\n", "\n", str_replace("\n\r", "\r", $message))))));
	
	$headers = "From: $email_from{$maildelimiter}X-Priority: 3{$maildelimiter}X-Mailer: UCENTER_HOME ".X_VER."{$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/html; charset=$_SC[charset]{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
		
	if($mail['mailsend'] == 1) {
		if(function_exists('mail') && @mail($email_to, $email_subject, $email_message, $headers)) {
			return true;
		}
		return false;
		
	} elseif($mail['mailsend'] == 2) {

		if(!$fp = fsockopen($mail['server'], $mail['port'], $errno, $errstr, 30)) {
			runlog('SMTP', "($mail[server]:$mail[port]) CONNECT - Unable to connect to the SMTP server", 0);
			return false;
		}
	 	stream_set_blocking($fp, true);
	
		$lastmessage = fgets($fp, 512);
		if(substr($lastmessage, 0, 3) != '220') {
			runlog('SMTP', "$mail[server]:$mail[port] CONNECT - $lastmessage", 0);
			return false;
		}
	
		fputs($fp, ($mail['auth'] ? 'EHLO' : 'HELO')." uchome\r\n");
		$lastmessage = fgets($fp, 512);
		if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) {
			runlog('SMTP', "($mail[server]:$mail[port]) HELO/EHLO - $lastmessage", 0);
			return false;
		}
	
		while(1) {
			if(substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) {
	 			break;
	 		}
	 		$lastmessage = fgets($fp, 512);
		}
	
		if($mail['auth']) {
			fputs($fp, "AUTH LOGIN\r\n");
			$lastmessage = fgets($fp, 512);
			if(substr($lastmessage, 0, 3) != 334) {
				runlog('SMTP', "($mail[server]:$mail[port]) AUTH LOGIN - $lastmessage", 0);
				return false;
			}
	
			fputs($fp, base64_encode($mail['auth_username'])."\r\n");
			$lastmessage = fgets($fp, 512);
			if(substr($lastmessage, 0, 3) != 334) {
				runlog('SMTP', "($mail[server]:$mail[port]) USERNAME - $lastmessage", 0);
				return false;
			}
	
			fputs($fp, base64_encode($mail['auth_password'])."\r\n");
			$lastmessage = fgets($fp, 512);
			if(substr($lastmessage, 0, 3) != 235) {
				runlog('SMTP', "($mail[server]:$mail[port]) PASSWORD - $lastmessage", 0);
				return false;
			}
	
			$email_from = $mail['from'];
		}
	
		fputs($fp, "MAIL FROM: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $email_from).">\r\n");
		$lastmessage = fgets($fp, 512);
		if(substr($lastmessage, 0, 3) != 250) {
			fputs($fp, "MAIL FROM: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $email_from).">\r\n");
			$lastmessage = fgets($fp, 512);
			if(substr($lastmessage, 0, 3) != 250) {
				runlog('SMTP', "($mail[server]:$mail[port]) MAIL FROM - $lastmessage", 0);
				return false;
			}
		}
	
		fputs($fp, "RCPT TO: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $toemail).">\r\n");
		$lastmessage = fgets($fp, 512);
		if(substr($lastmessage, 0, 3) != 250) {
			fputs($fp, "RCPT TO: <".preg_replace("/.*\<(.+?)\>.*/", "\\1", $toemail).">\r\n");
			$lastmessage = fgets($fp, 512);
			runlog('SMTP', "($mail[server]:$mail[port]) RCPT TO - $lastmessage", 0);
			return false;
		}
	
		fputs($fp, "DATA\r\n");
		$lastmessage = fgets($fp, 512);
		if(substr($lastmessage, 0, 3) != 354) {
			runlog('SMTP', "($mail[server]:$mail[port]) DATA - $lastmessage", 0);
			return false;
		}
	
		$headers .= 'Message-ID: <'.gmdate('YmdHs').'.'.substr(md5($email_message.microtime()), 0, 6).rand(100000, 999999).'@'.$_SERVER['HTTP_HOST'].">{$maildelimiter}";
	
		fputs($fp, "Date: ".gmdate('r')."\r\n");
		fputs($fp, "To: ".$email_to."\r\n");
		fputs($fp, "Subject: ".$email_subject."\r\n");
		fputs($fp, $headers."\r\n");
		fputs($fp, "\r\n\r\n");
		fputs($fp, "$email_message\r\n.\r\n");
		$lastmessage = fgets($fp, 512);
		if(substr($lastmessage, 0, 3) != 250) {
			runlog('SMTP', "($mail[server]:$mail[port]) END - $lastmessage", 0);
		}
		fputs($fp, "QUIT\r\n");
		
		return true;

	} elseif($mail['mailsend'] == 3) {

		ini_set('SMTP', $mail['server']);
		ini_set('smtp_port', $mail['port']);
		ini_set('sendmail_from', $email_from);
	
		if(function_exists('mail') && @mail($email_to, $email_subject, $email_message, $headers)) {
			return true;
		}
		return false;
	}
}
Ejemplo n.º 25
0
function deletepicfiles($pics)
{
    global $_SGLOBAL, $_SC;
    $remotes = array();
    foreach ($pics as $pic) {
        if ($pic['remote']) {
            $remotes[] = $pic;
        } else {
            $file = $_SC['attachdir'] . './' . $pic['filepath'];
            if (!@unlink($file)) {
                runlog('PIC', "Delete pic file '{$file}' error.", 0);
            }
            if ($pic['thumb']) {
                if (!@unlink($file . '.thumb.jpg')) {
                    runlog('PIC', "Delete pic file '{$file}.thumb.jpg' error.", 0);
                }
            }
        }
    }
    //删除远程附件
    if ($remotes) {
        include_once S_ROOT . './data/data_setting.php';
        include_once S_ROOT . './source/function_ftp.php';
        $ftpconnid = sftp_connect();
        foreach ($remotes as $pic) {
            $file = $pic['filepath'];
            if ($ftpconnid) {
                if (!sftp_delete($ftpconnid, $file)) {
                    runlog('FTP', "Delete pic file '{$file}' error.", 0);
                }
                if ($pic['thumb'] && !sftp_delete($ftpconnid, $file . '.thumb.jpg')) {
                    runlog('FTP', "Delete pic file '{$file}.thumb.jpg' error.", 0);
                }
            } else {
                runlog('FTP', "Delete pic file '{$file}' error.", 0);
                if ($pic['thumb']) {
                    runlog('FTP', "Delete pic file '{$file}.thumb.jpg' error.", 0);
                }
            }
        }
    }
}
Ejemplo n.º 26
0
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: member_emailverify.php 25756 2011-11-22 02:47:45Z zhangguosheng $
 */
if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
define('NOROBOT', TRUE);
$member = getuserbyuid($_G['uid']);
if (!$member || $member['groupid'] != 8) {
    showmessage('member_not_found');
} else {
    $member = array_merge(C::t('common_member_field_forum')->fetch($member['uid']), $member);
}
if ($_G['setting']['regverify'] == 2) {
    showmessage('register_verify_invalid');
}
list($dateline, $type, $idstring) = explode("\t", $member['authstr']);
if ($type == 2 && TIMESTAMP - $dateline < 86400) {
    showmessage('email_verify_invalid');
}
$idstring = $type == 2 && $idstring ? $idstring : random(6);
C::t('common_member_field_forum')->update($_G['uid'], array('authstr' => "{$_G['timestamp']}\t2\t{$idstring}"));
$verifyurl = "{$_G[siteurl]}member.php?mod=activate&amp;uid={$_G[uid]}&amp;id={$idstring}";
$email_verify_message = lang('email', 'email_verify_message', array('username' => $_G['member']['username'], 'bbname' => $_G['setting']['bbname'], 'siteurl' => $_G['siteurl'], 'url' => $verifyurl));
include_once libfile('function/mail');
if (!sendmail("{$_G[member][username]} <{$_GET['email']}>", lang('email', 'email_verify_subject'), $email_verify_message)) {
    runlog('sendmail', "{$_GET['email']} sendmail failed.");
}
showmessage('email_verify_succeed');
Ejemplo n.º 27
0
function getfilepath($fileext, $mkdir = false)
{
    global $_G;
    $filepath = "{$_G['uid']}_{$_G['timestamp']}" . random(4) . ".{$fileext}";
    $name1 = gmdate('Ym');
    $name2 = gmdate('j');
    if ($mkdir) {
        $newfilename = $_G['setting']['attachdir'] . './album/' . $name1;
        if (!is_dir($newfilename)) {
            if (!@mkdir($newfilename)) {
                runlog('error', "DIR: {$newfilename} can not make");
                return $filepath;
            }
        }
        $newfilename .= '/' . $name2;
        if (!is_dir($newfilename)) {
            if (!@mkdir($newfilename)) {
                runlog('error', "DIR: {$newfilename} can not make");
                return $name1 . '/' . $filepath;
            }
        }
    }
    return $name1 . '/' . $name2 . '/' . $filepath;
}
Ejemplo n.º 28
0
/**
 * 发送邮件
 * @param $toemail 收件人email
 * @param $subject 邮件主题
 * @param $message 正文
 * @param $from 发件人
 * @param $cfg 邮件配置信息
 * @param $sitename 邮件站点名称
 */
function sendmail($toemail, $subject, $message, $from = '', $cfg = array(), $sitename = '')
{
    if ($sitename == '') {
        $siteid = get_siteid();
        $siteinfo = siteinfo($siteid);
        $sitename = $siteinfo['site_title'];
    }
    $adminemail = '*****@*****.**';
    if ($cfg && is_array($cfg)) {
        $adminemail = $cfg['from'];
        $mail = $cfg;
        $mail_type = $cfg['mail_type'];
        //邮件发送模式
    } else {
        $cfg = getcache('common', 'commons');
        $adminemail = $cfg['mail_from'];
        $mail_type = $cfg['mail_type'];
        //邮件发送模式
        $mail = array('mailsend' => 2, 'maildelimiter' => 1, 'mailusername' => 1, 'server' => $cfg['mail_server'], 'port' => $cfg['mail_port'], 'auth' => $cfg['mail_auth'], 'from' => $cfg['mail_from'], 'auth_username' => $cfg['mail_user'], 'auth_password' => $cfg['mail_password']);
    }
    //mail 发送模式
    if ($mail_type == 0) {
        $headers = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=' . CHARSET . '' . "\r\n";
        $headers .= 'From: ' . $sitename . ' <' . $from . '>' . "\r\n";
        mail($toemail, $subject, $message, $headers);
        return true;
    }
    //邮件头的分隔符
    $maildelimiter = $mail['maildelimiter'] == 1 ? "\r\n" : ($mail['maildelimiter'] == 2 ? "\r" : "\n");
    //收件人地址中包含用户名
    $mailusername = isset($mail['mailusername']) ? $mail['mailusername'] : 1;
    //端口
    $mail['port'] = $mail['port'] ? $mail['port'] : 25;
    $mail['mailsend'] = $mail['mailsend'] ? $mail['mailsend'] : 1;
    //发信者
    $email_from = $from == '' ? '=?' . CHARSET . '?B?' . base64_encode($sitename) . "?= <" . $adminemail . ">" : (preg_match('/^(.+?) \\<(.+?)\\>$/', $from, $mats) ? '=?' . CHARSET . '?B?' . base64_encode($mats[1]) . "?= <{$mats['2']}>" : $from);
    $email_to = preg_match('/^(.+?) \\<(.+?)\\>$/', $toemail, $mats) ? $mailusername ? '=?' . CHARSET . '?B?' . base64_encode($mats[1]) . "?= <{$mats['2']}>" : $mats[2] : $toemail;
    $email_subject = '=?' . CHARSET . '?B?' . base64_encode(preg_replace("/[\r|\n]/", '', '[PHPCMS] ' . $subject)) . '?=';
    $email_message = chunk_split(base64_encode(str_replace("\n", "\r\n", str_replace("\r", "\n", str_replace("\r\n", "\n", str_replace("\n\r", "\r", $message))))));
    $headers = "From: {$email_from}{$maildelimiter}X-Priority: 3{$maildelimiter}X-Mailer: PHPCMS-V9 {$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/html; charset=" . CHARSET . "{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}";
    if (!($fp = fsockopen($mail['server'], $mail['port'], $errno, $errstr, 30))) {
        runlog('SMTP', "({$mail['server']}:{$mail['port']}) CONNECT - Unable to connect to the SMTP server", 0);
        return false;
    }
    stream_set_blocking($fp, true);
    $lastmessage = fgets($fp, 512);
    if (substr($lastmessage, 0, 3) != '220') {
        runlog('SMTP', "{$mail['server']}:{$mail['port']} CONNECT - {$lastmessage}", 0);
        return false;
    }
    fputs($fp, ($mail['auth'] ? 'EHLO' : 'HELO') . " uchome\r\n");
    $lastmessage = fgets($fp, 512);
    if (substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) {
        runlog('SMTP', "({$mail['server']}:{$mail['port']}) HELO/EHLO - {$lastmessage}", 0);
        return false;
    }
    while (1) {
        if (substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) {
            break;
        }
        $lastmessage = fgets($fp, 512);
    }
    if ($mail['auth']) {
        fputs($fp, "AUTH LOGIN\r\n");
        $lastmessage = fgets($fp, 512);
        if (substr($lastmessage, 0, 3) != 334) {
            runlog('SMTP', "({$mail['server']}:{$mail['port']}) AUTH LOGIN - {$lastmessage}", 0);
            return false;
        }
        fputs($fp, base64_encode($mail['auth_username']) . "\r\n");
        $lastmessage = fgets($fp, 512);
        if (substr($lastmessage, 0, 3) != 334) {
            runlog('SMTP', "({$mail['server']}:{$mail['port']}) USERNAME - {$lastmessage}", 0);
            return false;
        }
        fputs($fp, base64_encode($mail['auth_password']) . "\r\n");
        $lastmessage = fgets($fp, 512);
        if (substr($lastmessage, 0, 3) != 235) {
            runlog('SMTP', "({$mail['server']}:{$mail['port']}) PASSWORD - {$lastmessage}", 0);
            return false;
        }
        $email_from = $mail['from'];
    }
    fputs($fp, "MAIL FROM: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $email_from) . ">\r\n");
    $lastmessage = fgets($fp, 512);
    if (substr($lastmessage, 0, 3) != 250) {
        fputs($fp, "MAIL FROM: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $email_from) . ">\r\n");
        $lastmessage = fgets($fp, 512);
        if (substr($lastmessage, 0, 3) != 250) {
            runlog('SMTP', "({$mail['server']}:{$mail['port']}) MAIL FROM - {$lastmessage}", 0);
            return false;
        }
    }
    fputs($fp, "RCPT TO: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $toemail) . ">\r\n");
    $lastmessage = fgets($fp, 512);
    if (substr($lastmessage, 0, 3) != 250) {
        fputs($fp, "RCPT TO: <" . preg_replace("/.*\\<(.+?)\\>.*/", "\\1", $toemail) . ">\r\n");
        $lastmessage = fgets($fp, 512);
        runlog('SMTP', "({$mail['server']}:{$mail['port']}) RCPT TO - {$lastmessage}", 0);
        return false;
    }
    fputs($fp, "DATA\r\n");
    $lastmessage = fgets($fp, 512);
    if (substr($lastmessage, 0, 3) != 354) {
        runlog('SMTP', "({$mail['server']}:{$mail['port']}) DATA - {$lastmessage}", 0);
        return false;
    }
    $headers .= 'Message-ID: <' . gmdate('YmdHs') . '.' . substr(md5($email_message . microtime()), 0, 6) . rand(100000, 999999) . '@' . $_SERVER['HTTP_HOST'] . ">{$maildelimiter}";
    fputs($fp, "Date: " . gmdate('r') . "\r\n");
    fputs($fp, "To: " . $email_to . "\r\n");
    fputs($fp, "Subject: " . $email_subject . "\r\n");
    fputs($fp, $headers . "\r\n");
    fputs($fp, "\r\n\r\n");
    fputs($fp, "{$email_message}\r\n.\r\n");
    $lastmessage = fgets($fp, 512);
    if (substr($lastmessage, 0, 3) != 250) {
        runlog('SMTP', "({$mail['server']}:{$mail['port']}) END - {$lastmessage}", 0);
    }
    fputs($fp, "QUIT\r\n");
    return true;
}
Ejemplo n.º 29
0
    } else {
        $emailcount = C::t('common_member')->count_by_email($_GET['email'], 1);
        if (!$emailcount) {
            showmessage('lostpasswd_email_not_exist');
        }
        if ($emailcount > 1) {
            showmessage('lostpasswd_many_users_use_email');
        }
        $member = C::t('common_member')->fetch_by_email($_GET['email'], 1);
        list($tmp['uid'], , $tmp['email']) = uc_get_user(addslashes($member['username']));
        $tmp['email'] = strtolower(trim($tmp['email']));
    }
    if (!$member) {
        showmessage('getpasswd_account_notmatch');
    } elseif ($member['adminid'] == 1 || $member['adminid'] == 2) {
        showmessage('getpasswd_account_invalid');
    }
    $table_ext = $member['_inarchive'] ? '_archive' : '';
    if ($member['email'] != $tmp['email']) {
        C::t('common_member' . $table_ext)->update($tmp['uid'], array('email' => $tmp['email']));
    }
    $idstring = random(6);
    C::t('common_member_field_forum' . $table_ext)->update($member['uid'], array('authstr' => "{$_G['timestamp']}\t1\t{$idstring}"));
    require_once libfile('function/mail');
    $get_passwd_subject = lang('email', 'get_passwd_subject');
    $get_passwd_message = lang('email', 'get_passwd_message', array('username' => $member['username'], 'bbname' => $_G['setting']['bbname'], 'siteurl' => $_G['siteurl'], 'uid' => $member['uid'], 'idstring' => $idstring, 'clientip' => $_G['clientip']));
    if (!sendmail("{$_GET['username']} <{$tmp['email']}>", $get_passwd_subject, $get_passwd_message)) {
        runlog('sendmail', "{$tmp['email']} sendmail failed.");
    }
    showmessage('getpasswd_send_succeed', $_G['siteurl'], array(), array('showdialog' => 1, 'locationtime' => true));
}
Ejemplo n.º 30
0
function admincp_log()
{
    global $_GET, $_POST, $_iGLOBAL;
    if ($_GET['mo'] == "html") {
        return;
    }
    $log_message = '';
    if ($_GET) {
        $log_message .= 'GET{';
        foreach ($_GET as $g_k => $g_v) {
            $g_v = is_array($g_v) ? serialize($g_v) : $g_v;
            $log_message .= "{$g_k}={$g_v};";
        }
        $log_message .= '}';
    }
    if ($_POST) {
        $log_message .= 'POST{';
        foreach ($_POST as $g_k => $g_v) {
            $g_v = is_array($g_v) ? serialize($g_v) : $g_v;
            $log_message .= "{$g_k}={$g_v};";
        }
        $log_message .= '}';
    }
    runlog('admincp', $log_message);
}