function convertToName($chatId)
{
    if ($chatId < 0) {
        //is Group
        switch ($chatId) {
            case 'groupID1':
                return "group1";
                break;
            case 'groupID2':
                return "group2";
                break;
            default:
                sendMessage("me", $chatId . "群組使用了我");
                return $chatId;
                break;
        }
    } else {
        if ($chatId > 0) {
            //is Personal
            switch ($chatId) {
                case 'me':
                    return "me";
                    break;
                case '1':
                    return "1";
                    break;
                default:
                    sendMessage("me", $chatId . "是" . $senderName);
                    return $chatId;
                    break;
            }
        }
    }
}
Пример #2
0
function optimalpayments_3dsecure($params)
{
    $cardtype = optimalpayments_cardtype($params['cardtype']);
    $xml = "<ccEnrollmentLookupRequestV1\nxmlns=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\"\nxmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\nxsi:schemaLocation=\"http://www.optimalpayments.com/creditcard/xmlschema/v1\">\n<merchantAccount>\n<accountNum>" . $params['accountnumber'] . "</accountNum>\n<storeID>" . $params['merchantid'] . "</storeID>\n<storePwd>" . $params['merchantpw'] . "</storePwd>\n</merchantAccount>\n<merchantRefNum>" . $params['invoiceid'] . "</merchantRefNum>\n<amount>" . $params['amount'] . "</amount>\n<card>\n<cardNum>" . $params['cardnum'] . "</cardNum>\n<cardExpiry>\n<month>" . substr($params['cardexp'], 0, 2) . "</month>\n<year>20" . substr($params['cardexp'], 2, 2) . "</year>\n</cardExpiry>\n<cardType>" . $cardtype . "</cardType>\n</card>\n</ccEnrollmentLookupRequestV1>";
    $url = "https://webservices.optimalpayments.com/creditcardWS/CreditCardServlet/v1";
    if ($params['testmode']) {
        $url = "https://webservices.test.optimalpayments.com/creditcardWS/CreditCardServlet/v1";
    }
    $query_str = "txnMode=ccTDSLookup&txnRequest=" . urlencode($xml);
    $data = curlCall($url, $query_str);
    $xmldata = XMLtoArray($data);
    $xmldata = $xmldata['CCTXNRESPONSEV1'];
    if ($xmldata['CODE'] == "0") {
        logTransaction("Optimal Payments 3D Auth", $data, "Lookup Successful");
        $_SESSION['optimalpaymentsconfirmationnumber'] = $xmldata['CONFIRMATIONNUMBER'];
        if ($xmldata['TDSRESPONSE']['ENROLLMENTSTATUS'] == "Y") {
            $code = "<form method=\"post\" action=\"" . $xmldata['TDSRESPONSE']['ACSURL'] . "\">\n<input type=hidden name=\"PaReq\" value=\"" . $xmldata['TDSRESPONSE']['PAYMENTREQUEST'] . "\">\n<input type=hidden name=\"TermUrl\" value=\"" . $params['systemurl'] . "/modules/gateways/callback/optimalpayments.php\">\n<input type=hidden name=\"MD\" value=\"" . $params['invoiceid'] . "\">\n<noscript>\n<div class=\"errorbox\"><b>JavaScript is currently disabled or is not supported by your browser.</b><br />Please click the continue button to proceed with the processing of your transaction.</div>\n<p align=\"center\"><input type=\"submit\" value=\"Continue >>\" /></p>\n</noscript>\n</form>";
            return $code;
        }
        $captureresult = optimalpayments_capture($params);
        if ($captureresult['status'] == "success") {
            addInvoicePayment($params['invoiceid'], $captureresult['transid'], "", "", "optimalpayments", "on");
            sendMessage("Credit Card Payment Confirmation", $invoiceid);
        }
        logTransaction("Optimal Payments Non 3d Processed", $captureresult['rawdata'], ucfirst($captureresult['status']));
        return $captureresult['status'];
    }
    logTransaction("Optimal Payments 3D Auth", $data, "Failed");
}
Пример #3
0
 function onMessage($from, $channel, $msg)
 {
     //Only trigger on !botlog
     if (stringStartsWith($msg, "{$this->config['trigger']}botlog")) {
         //Get hold of number of rows to show and possible password
         $tmp = explode(" ", $msg);
         $pass = '';
         if (count($tmp) == 3) {
             $pass = $tmp[1];
             $limit = $tmp[2];
         } else {
             if (count($tmp) == 2) {
                 $limit = $tmp[1];
             }
         }
         if (!is_numeric($limit)) {
             $limit = 10;
         }
         if (strlen($this->config['adminPass']) > 0 && $pass != $this->config['adminPass']) {
             sendMessage($this->socket, $channel, "{$from}: Wrong password");
         } else {
             //Password auth ok, display log data
             sendMessage($this->socket, $channel, "{$from}: Last {$limit} entries from bot log:");
             $logdata = file('logs/vikingbot.log');
             $rows = count($logdata);
             for ($i = $rows - $limit; $i < $rows; $i++) {
                 sendMessage($this->socket, $channel, "{$logdata[$i]}");
                 //Avoid Excess flood kick from server
                 usleep(500000);
             }
             sendMessage($this->socket, $channel, "------------");
         }
     }
 }
Пример #4
0
 public static function runBountyExchange($username, $defender)
 {
     //  *** BOUNTY EQUATION ***
     $user = Player::findByName($username);
     $defender = Player::findByName($defender);
     if ($defender->bounty > 0) {
         $user->set_gold($user->gold + $defender->bounty);
         $user->save();
         $defender->set_bounty(0);
         $defender->save();
         // *** Reward bounty whenever available. ***
         return "You have received the {$defender->bounty} gold bounty on {$defender}'s head for your deeds!";
         $bounty_msg = "You have valiantly slain the wanted criminal, {$defender}! For your efforts, you have been awarded {$defender->bounty} gold!";
         sendMessage("Village Doshin", $username, $bounty_msg);
     } else {
         // *** Bounty Increase equation: (attacker's level - defender's level) / an increment, rounded down ***
         $levelRatio = floor(($user->level - $defender->level) / 10);
         $bountyIncrease = min(25, max($levelRatio * 25, 0));
         //Avoids negative increases, max of 30 gold, min of 0
         if ($bountyIncrease > 0) {
             // *** If Defender has no bounty and there was a level difference. ***
             $user->set_bounty($user->bounty + $bountyIncrease);
             $user->save();
             return "Your victim was much weaker than you. The townsfolk are angered. A bounty of {$bountyIncrease} gold has been placed on your head!";
         } else {
             return null;
         }
     }
 }
Пример #5
0
/**
 *
 * @ WHMCS FULL DECODED & NULLED
 *
 * @ Version  : 5.2.15
 * @ Author   : MTIMER
 * @ Release on : 2013-12-24
 * @ Website  : http://www.mtimer.cn
 *
 **/
function doUnsubscribe($email, $key)
{
    global $whmcs;
    global $_LANG;
    $whmcs->get_hash();
    if (!$email) {
        return $_LANG['pwresetemailrequired'];
    }
    $result = select_query("tblclients", "id,email,emailoptout", array("email" => $email));
    $data = mysql_fetch_array($result);
    $userid = $data['id'];
    $email = $data['email'];
    $emailoptout = $data['emailoptout'];
    $newkey = sha1($email . $userid . $cc_encryption_hash);
    if ($newkey == $key) {
        if (!$userid) {
            return $_LANG['unsubscribehashinvalid'];
        }
        if ($emailoptout == 1) {
            return $_LANG['alreadyunsubscribed'];
        }
        update_query("tblclients", array("emailoptout" => "1"), array("id" => $userid));
        sendMessage("Unsubscribe Confirmation", $userid);
        logActivity("Unsubscribed From Marketing Emails - User ID:" . $userid, $userid);
        return null;
    }
    return $_LANG['unsubscribehashinvalid'];
}
Пример #6
0
function send_kill_mails($username, $target, $attacker_id, $article, $item, $today, $loot)
{
    $target_email_msg = "You have been killed by {$attacker_id} with {$article} {$item} at {$today} and lost {$loot} gold.";
    sendMessage($attacker_id, $target, $target_email_msg);
    $user_email_msg = "You have killed {$target} with {$article} {$item} at {$today} and received {$loot} gold.";
    sendMessage($target, $username, $user_email_msg);
}
Пример #7
0
 /**
  * 
  * update check value 
  * @param type $id  curr id
  * @param type $status   status: 0 or 1 
  */
 public function updateCheck()
 {
     if (!v_islogin()) {
         $this->error('请登录', U("Admin/User/Login"));
     } else {
         $status = I('param.status');
         $id = I('param.cork-id');
         $canid = I('param.canid');
         $content = I('param.content');
         $cork = M('cork')->where(array("id" => $id))->select();
         if ($cork) {
             $cork[0]['check'] = $status;
             $cork[0]['content'] = $content;
             $cork[0]['canid'] = $canid;
             M('cork')->data($cork[0])->save();
             if ($status == 1) {
                 self::delete($id);
                 sendMessage($cork[0]['openid'], "您的作品未通过审核,请按规则重新上传,如有疑问请联系客服。\n原因:" . $content . "\n点击链接重新上传:http://wx.mynow.net/?s=/Home/Oauth2/index/type/index");
             } else {
                 if ($status == 2) {
                     sendMessage($cork[0]['openid'], "您的作品已通过审核,详情请点击:http://wx.mynow.net/?s=/Home/Oauth2/index/type/index");
                 }
             }
             $this->success('审核成功', U("Admin/Activity/cork"), 3);
         } else {
             //no change
             $this->error('参数错误,ID未找到', U("Admin/Activity/cork"), 5);
         }
     }
 }
Пример #8
0
function sendFormatedMessage($msgInfo)
{
    $msgInfo['reqTime'] = number_format(1000 * time(), 0, '', '');
    $content = $msgInfo['memberCode'] . $msgInfo['customerName'] . $msgInfo['customerPhone'] . $msgInfo['customerAddress'] . $msgInfo['customerMemo'] . $msgInfo['msgDetail'] . $msgInfo['deviceNo'] . $msgInfo['msgNo'] . $msgInfo['reqTime'] . FEYIN_KEY;
    $msgInfo['securityCode'] = md5($content);
    $msgInfo['mode'] = 1;
    return sendMessage($msgInfo);
}
Пример #9
0
 public static function newFiles()
 {
     $this->setDefaults();
     foreach ($this->plugin->storage->newFiles as $fileName) {
         MessageM . sendMessage(null, "%TAG%WCouldn't find '%A%fileName%.yml%W' creating new one.", "fileName-" . $fileName);
     }
     $this->plugin->storage->newFiles = [];
 }
Пример #10
0
 public function onMessage($from, $channel, $msg)
 {
     if (stringEndsWith($msg, "{$this->config['trigger']}memory")) {
         $usedMem = round(memory_get_usage() / 1024 / 1024, 2);
         $freeMem = round($this->config['memoryLimit'] - $usedMem, 2);
         sendMessage($this->socket, $channel, $from . ": Memory status: {$usedMem} MB used, {$freeMem} MB free.");
         $usedMem = null;
         $freeMem = null;
     }
 }
 public function onMessage($from, $channel, $msg)
 {
     global $config;
     if ($from != '' || $channel != '') {
         global $irc;
         $data = $irc->processIncomingMessage(array('message' => iconv($config['encoding'], 'UTF-8', $msg), 'from' => iconv($config['encoding'], 'UTF-8', $from), 'channel' => iconv($config['encoding'], 'UTF-8', $channel)));
         if ($data && $data != 1) {
             sendMessage($this->socket, $channel, $from . ': ' . iconv('UTF-8', $config['encoding'], $data));
         }
     }
 }
Пример #12
0
function loginMail()
{
    $errMsg = '';
    if (!isset($_GET['email'])) {
        $errMsg .= 'email';
    }
    if (!isset($_GET['password'])) {
        if (strlen($errMsg) > 0) {
            $errMsg .= ', ';
        }
        $errMsg .= 'password';
    }
    if (strlen($errMsg) > 0) {
        // At least one of the fields is not set, so return an error
        sendMessage(ERR, 'The following required parameters are not set: [' . $errMsg . ']');
        return;
    }
    $email = $_GET['email'];
    $password = $_GET['password'];
    // Check if user exists
    $db = acquireDatabase();
    $loader = new User($db);
    try {
        $res = $loader->loadWhere('email=?', [$email]);
        if (sizeof($res) > 0) {
            $user = $res[0];
            // Check if password is correct
            $validPassword = $user->getPassword();
            $password = User::encryptPassword($password);
            if ($validPassword == $password) {
                // Login successful -> return session id
                session_start();
                $_SESSION['uid'] = $user->getId();
                $_SESSION['email'] = $user->getEmail();
                if ($user->getState() == 'FILL_DATA') {
                    sendMessage(WARN, 'Login successful. Please complete your registration.');
                } else {
                    $_SESSION['name'] = $user->getName();
                    sendMessage(OK, 'Login successful.');
                }
            } else {
                sendMessage(ERR, 'Password invalid.');
            }
        } else {
            // User doesn't exist
            sendMessage(ERR, 'User invalid.');
        }
    } catch (DbException $e) {
        sendMessage(ERR, $e->getMessage());
    }
    $db->close();
}
Пример #13
0
 public function register($username = '', $nickname = '', $password = '', $repassword = '', $email = '', $verify = '', $type = 'start')
 {
     $type = op_t($type);
     if (!C('USER_ALLOW_REGISTER')) {
         $this->error('注册已关闭');
     }
     $verifyarr = explode(',', C('VERIFY_OPEN'));
     if (in_array('1', $verifyarr)) {
         $this->assign('isverify', 1);
     } else {
         $this->assign('isverify', 0);
     }
     if (IS_POST) {
         //注册用户
         /* 检测验证码 TODO: */
         if (in_array('1', $verifyarr)) {
             if (!$this->check_verify($verify)) {
                 $this->error('验证码输入错误!');
             }
         }
         if ($password != $repassword) {
             $this->error('两次密码输入不一致');
         }
         /* 调用注册接口注册用户 */
         $User = new UserApi();
         $uid = $User->register($username, $nickname, $password, $email);
         if (0 < $uid) {
             //注册成功
             sendMessage($uid, 0, '注册成功', '恭喜您!您已经注册成功,请尽快<a href="' . U('Ucenter/yzmail') . '">验证邮箱地址</a>,第一时间获取网站动态!', 0);
             $uid = $User->login($username, $password);
             //通过账号密码取到uid
             D('Member')->login($uid, false);
             //登陆
             asyn_sendmail($email, 2);
             setuserscore($uid, C('REGSCORE'));
             $this->success('注册成功并登陆!', cookie('referurl'));
         } else {
             //注册失败,显示错误信息
             $this->error($this->showRegError($uid));
         }
     } else {
         //显示注册表单
         if (is_login()) {
             redirect(cookie('referurl'));
         }
         if (cookie('referurl') == '') {
             cookie('referurl', $_SERVER['HTTP_REFERER']);
         }
         $this->display();
     }
 }
Пример #14
0
 public function telCode()
 {
     //手机号码
     $tel = I('post.phone');
     //发送验证码
     $telcode = rand(100000, 999999);
     $res = sendMessage($tel, $telcode);
     //存入session中
     if ($res) {
         session('telcode', $telcode);
         //将telcode返回到js
         $this->ajaxReturn($telcode);
     }
 }
Пример #15
0
/**
 * 群聊
 * 
 * @param  swoole_server $server  
 * @param  array|mixed   $content 消息内容
 * @param  int           $from_fd 发送人
 * @param  string        $channel 频道,如果没有指定,默认为公共频道
 */
function mass($server, $content, $from_fd, $channel = 'public')
{
    global $app;
    foreach ($app->users->online() as $user) {
        $to_fd = $user['fd'];
        if ($from_fd === $to_fd) {
            continue;
        }
        if (is_null($channel) || $user['channel'] !== $channel) {
            continue;
        }
        sendMessage($server, 'chat', $content, $from_fd, $to_fd);
    }
}
Пример #16
0
function globalsignssl_resend($params)
{
    $result = select_query("tblsslorders", "id", array("serviceid" => $params['serviceid']));
    $data = mysql_fetch_array($result);
    $id = $data['id'];
    if (!$id) {
        return "No SSL Order exists for this product";
    }
    global $CONFIG;
    $sslconfigurationlink = $CONFIG['SystemURL'] . "/configuressl.php?cert=" . md5($id);
    $sslconfigurationlink = "<a href=\"" . $sslconfigurationlink . "\">" . $sslconfigurationlink . "</a>";
    sendMessage("SSL Certificate Configuration Required", $params['serviceid'], array("ssl_configuration_link" => $sslconfigurationlink));
    return "success";
}
Пример #17
0
function sendMessageAdmins($user_id, $subject, $body)
{
    $user_id = escape($user_id);
    //confirm that user is an administrator
    $result = mysql_query("SELECT COUNT(*) FROM user_groups WHERE user_id = '{$user_id}'");
    $row = mysql_fetch_array($result);
    if ($row[0] == 0) {
        return 3;
    }
    //get all targets
    $result = mysql_query("SELECT DISTINCT user_id FROM user_groups");
    while ($row = mysql_fetch_array($result)) {
        sendMessage($user_id, $row[0], $subject, $body);
    }
}
Пример #18
0
 function tick()
 {
     if ($this->lastCheck < time()) {
         clearstatcache();
         if (filemtime($this->db) >= $this->lastCheck) {
             $data = file($this->db);
             foreach ($data as $row) {
                 sendMessage($this->socket, $this->channel, $row);
                 usleep(300000);
             }
             $h = fopen($this->db, 'w+');
             fclose($h);
             $data = null;
             $h = null;
         }
         $this->lastCheck = time();
     }
 }
Пример #19
0
 public function insert()
 {
     $data['sendtype'] = I('sendtype', 0);
     $data['at'] = I('at', '');
     $data['title'] = I('title', '');
     $data['content'] = I('content', '');
     if ($data['content'] == '') {
         $this->mtReturn(300, '内容为空!');
     }
     if ($data['sendtype'] == 0 && $data['at'] == '') {
         $this->mtReturn(300, '没有@任何人!');
     }
     if ($data['sendtype'] == 0) {
         //通知被@到的人
         $uids = get_at_uids($data['at']);
         $uids = array_unique($uids);
         $count = 0;
         foreach ($uids as $uid) {
             $title = $data['title'];
             $message = $data['content'];
             if ($uid > 0) {
                 sendMessage($uid, 1, $title, $message, 0);
                 $count = $count + 1;
             }
             //
         }
         if ($count == 0) {
             $this->mtReturn(300, '@的人不存在!');
         } elseif ($count < count($uids)) {
             $this->mtReturn(200, '发送消息成功,但@的用户中有' . (count($uids) - $count) . '个不存在!');
         } else {
             $this->mtReturn(200, '发送消息成功!');
         }
     } else {
         $uids = D('member')->where(array('status' => 1))->getField('uid', true);
         $uids = array_subtract($uids, array(1));
         foreach ($uids as $uid) {
             $title = $data['title'];
             $message = $data['content'];
             sendMessage($uid, 1, $title, $message, 0);
         }
     }
     $this->mtReturn(200, '发送消息成功!');
 }
 function tick()
 {
     if ($this->lastCleanTime + 3600 < time()) {
         $this->cleanDB();
         $this->lastCleanTime = time();
     }
     //Start pollings feeds that should be updated after 20 seconds to get the bot in to any channels etc
     if ($this->started + 30 < time()) {
         $this->twitterRequest();
     }
     //If we got todo, output one row from it
     if (count($this->todo) > 0) {
         if (time() > $this->lastMsgSent + 5) {
             $row = array_pop($this->todo);
             sendMessage($this->socket, $row[0], $row[1]);
             $this->lastMsgSent = time();
         }
     }
 }
Пример #21
0
function getYoungsters($people)
{
    if (!doValidation($people)) {
        sendMessage(doValidation($people));
        return false;
    }
    $i = 0;
    // Get year from date
    foreach ($people as $person) {
        preg_match("/[0-9]+/", $person['dob'], $matches);
        $age = abs(date('Y') - $matches[0]);
        if ($age < 21) {
            $folks[$i]['age'] = $age;
            $folks[$i]['name'] = $person['name'];
            $i++;
        }
    }
    return !empty($folks) ? $folks : null;
}
Пример #22
0
 function onMessage($from, $channel, $msg)
 {
     if (stringStartsWith($msg, "{$this->config['trigger']}op")) {
         $bits = explode(" ", $msg);
         $pass = @$bits[3];
         $who = @$bits[1];
         $where = @$bits[2];
         if (strlen($this->config['adminPass']) > 0 && $pass != $this->config['adminPass']) {
             sendMessage($this->socket, $channel, "{$from}: Wrong password");
         } else {
             if (strlen($who) == 0 || strlen($where) == 0) {
                 sendMessage($this->socket, $channel, "{$from}: Syntax: {$this->config['trigger']}op nick #channel [adminPassword]");
             } else {
                 sendData($this->socket, "MODE {$where} +o {$who}");
                 sendMessage($this->socket, $channel, "{$from}: OP has been attempted given, note that i must be OP myself to do it.");
             }
         }
     }
 }
Пример #23
0
 public function onMessage($from, $channel, $msg)
 {
     if (stringStartsWith($msg, "{$this->config['trigger']}upgrade")) {
         $bits = explode(" ", $msg);
         $pass = $bits[1];
         if (strlen($this->config['adminPass']) > 0 && $pass != $this->config['adminPass']) {
             sendMessage($this->socket, $channel, "{$from}: Wrong password");
         } else {
             $restartRequired = false;
             sendMessage($this->socket, $channel, "{$from}: Starting upgrade of bot and its plugins...");
             $response = trim(shell_exec("git pull"));
             if (empty($response)) {
                 sendMessage($this->socket, $channel, "{$from}: Error upgrading core. Check permissions!");
             } elseif ($response != 'Already up-to-date.') {
                 $restartRequired = true;
                 sendMessage($this->socket, $channel, "{$from}: Upgrading core: {$response}");
             }
             $coreDir = getcwd();
             $pluginsRecDirIterator = new RecursiveDirectoryIterator('./');
             foreach (new RecursiveIteratorIterator($pluginsRecDirIterator) as $gitDir) {
                 if (stringEndsWith($gitDir, ".git/..")) {
                     chdir($gitDir);
                     $response = trim(shell_exec("git pull"));
                     if (empty($response)) {
                         sendMessage($this->socket, $channel, "{$from}: Error upgrading sub git. Check permissions!");
                     } elseif ($response != 'Already up-to-date.') {
                         $restartRequired = true;
                         sendMessage($this->socket, $channel, "{$from}: Upgrading sub git: {$response}");
                     }
                     chdir($coreDir);
                 }
             }
             if ($restartRequired) {
                 sendMessage($this->socket, $channel, "{$from}: Restarting...");
                 sendData($this->socket, 'QUIT :Restarting due to upgrade');
                 die(exec('sh start.sh > /dev/null &'));
             } else {
                 sendMessage($this->socket, $channel, "{$from}: Everything up to date, not restarting.");
             }
         }
     }
 }
Пример #24
0
 public function tick()
 {
     //Clean up the RSS database each hour
     if ($this->lastCleanTime + 3600 < time()) {
         logMsg("rssPlugin: Cleaning RSS DB");
         $this->cleanFeedDB();
         $this->lastCleanTime = time();
     }
     //Start pollings feeds that should be updated after 20 seconds to get the bot in to any channels etc
     if ($this->started + $this->config['waitTime'] < time()) {
         $this->parseFeeds();
     }
     //If we got todo, output one row from it
     if (count($this->todo) > 0) {
         if (time() > $this->lastMsgSent + 5) {
             $row = array_pop($this->todo);
             sendMessage($this->socket, $row[0], $row[1]);
             $this->lastMsgSent = time();
         }
     }
 }
 public function onPlayerDeath(PlayerDeathEvent $event)
 {
     $entity = $event->getEntity();
     $cause = $entity->getLastDamageCause();
     if ($cause instanceof EntityDamageByEntityEvent) {
         $killer = $cause->getDamager()->getPlayer();
         # CustomMessage
         $Kmessage = str_replace("{Name}", $entity->getPlayer()->getName(), $this->config->get("message-Drop"));
         $Kmessage = str_replace("{Money}", $this->config->get("money-Drop"), $this->config->get("message-Drop"));
         $killer->sendMessage("{$Kmessage}");
         $Dmessage = str_replace("{Name}", $killer->getPlayer()->getName(), $this->config->get("message-Lost"));
         $Dmessage = str_replace("{Money}", $this->config->get("money-Lost"), $this->config->get("message-Lost"));
         $entity > sendMessage("{$Dmessage}");
         # Conclusion
         $this->reduceMoney($entity->getName(), $this->config->get("money-Lost"));
         $this->grantMoney($killer->getName(), $this->config->get("money-Drop"));
         return true;
     } else {
         return true;
     }
 }
Пример #26
0
 function onMessage($from, $channel, $msg)
 {
     if (stringStartsWith($msg, "{$this->config['trigger']}upgrade")) {
         $bits = explode(" ", $msg);
         $pass = $bits[1];
         if (strlen($this->config['adminPass']) > 0 && $pass != $this->config['adminPass']) {
             sendMessage($this->socket, $channel, "{$from}: Wrong password");
         } else {
             sendMessage($this->socket, $channel, "{$from}: Starting upgrade...");
             $response = trim(shell_exec("git pull"));
             if ($response == 'Already up-to-date.') {
                 sendMessage($this->socket, $channel, "{$from}: The bot is already up to date, not restarting.");
             } else {
                 sendMessage($this->socket, $channel, "{$from}: {$response}");
                 sendMessage($this->socket, $channel, "{$from}: Restarting...");
                 sendData($this->socket, 'QUIT :Restarting due to upgrade');
                 die(exec('sh start.sh > /dev/null &'));
             }
         }
     }
 }
Пример #27
0
function receiveMessage()
{
    global $users;
    $from = $_REQUEST['From'];
    $to = $_REQUEST['To'];
    $text = $_REQUEST['Body'];
    if (($text[0] == "c" || $text[0] == "C") && in_array($from, $users)) {
        //Remove 'c' from message to get contact name
        $contact = substr($text, 2);
        //Dial by Number
        if (is_numeric($contact)) {
            $message = "Callback Requested: " . $contact;
            $fromNum = $_REQUEST['FromCountry'] == "US" ? $twilio_usa : $twilio_france;
            sendMessage($from, $message, $fromNum);
            callback($from, $contact, $from);
            //Dial by Name
        } else {
            if (array_key_exists($contact, $recipients)) {
                $num = substr($recipients[$contact], 1);
                $message = "Callback Requested: " . $num;
                $fromNum = $_REQUEST['FromCountry'] == "US" ? $twilio_usa : $twilio_france;
                sendMessage($from, $message, $fromNum);
                callback($from, $num, $from);
                //Something's wrong
            } else {
                $fromNum = $_REQUEST['FromCountry'] == "US" ? $twilio_usa : $twilio_france;
                $message = "Unknown Contact: " . $contact;
                sendMessage($from, $message, $fromNum);
            }
        }
    } else {
        //Shame on them.
        $message = "You are not authorized. Contact Ross for access.";
        $fromNum = $_REQUEST['FromCountry'] == "US" ? $twilio_usa : $twilio_france;
        sendMessage($from, $message, $fromNum);
        //Let me know of the intrusion
        $message = "Unauthorized Access: " . $from . " Message: " . $text;
        sendMessage($admins['ross'], $message);
    }
}
Пример #28
0
function tex($chatID, $params)
{
    // Generate tex expression merging params
    $texExpr = "";
    for ($i = 0; $i < count($params); $i++) {
        $texExpr = $texExpr . $params[$i] . " ";
    }
    // Compile tex expression to webp image
    $result = tex2webp($texExpr, "doc.webp");
    // Send the sticker
    if ($result == 2) {
        sendMessage("TeX timeout error.", $chatID);
    } else {
        if ($result == 1) {
            sendMessage("TeX error.", $chatID);
        } else {
            sendSticker("doc.webp", $chatID);
        }
    }
    // Remove the file (just to keep the server clean)
    unlink("doc.webp");
}
Пример #29
0
 public function edit()
 {
     if ($this->isPost()) {
         $module = $_POST['module'];
         $module_id = intval($_POST['module_id']);
         $m_comment = M('Comment');
         $m_comment->create();
         $m_comment->update_time = time();
         if ($m_comment->save()) {
             $m_id = $module . '_id';
             if (intval($_POST['message_alert']) == 1) {
                 sendMessage($_POST['to_role_id'], L('THE MAIN CONTENTS ARE AS FOLLOWS', array(createCommentAlertInfo($module, $module_id), chr(10), $_POST['content'])), 1);
             }
             if (intval($_POST['email_alert']) == 1) {
                 $email_result = sysSendEmail($_POST['to_role_id'], createCommentAlertInfo($module, $module_id), L('THE MAIN CONTENT', array($_POST['content'])));
                 if (!$email_result) {
                     alert('error', L('EMAIL NOTIFICATION OF FAILURE THE OTHER PARTY IS NOT SET EFFECTIVE EMAIL'), $_SERVER['HTTP_REFERER']);
                 }
             }
             if (intval($_POST['sms_alert']) == 1) {
                 $sms_result = sysSendSms($_POST['to_role_id'], createCommentAlertInfo($module, $module_id));
                 if (100 == $sms_result) {
                     alert('error', L('SMS NOTIFICATION OF FAILURE THE OTHER PARTY IS NOT SET EFFECTIVE PHONE'), $_SERVER['HTTP_REFERER']);
                 } elseif ($sms_result < 0) {
                     alert(L('SMS SEND FAILS AN ERROR CODE PLEASE CONTACT THE ADMINISTRATOR CONFIRMATION MESSAGE INTERFACE CONFIGURATION'), array(error, $sms_result), $_SERVER['HTTP_REFERER']);
                 }
             }
             alert('success', L('MODIFY COMMENTS SUCCESS'), $_SERVER['HTTP_REFERER']);
         } else {
             alert('error', L('MODIFY COMMENTS FAILED'), $_SERVER['HTTP_REFERER']);
         }
     } elseif ($_GET['id']) {
         $this->comment = M('Comment')->where('comment_id =%d', $_GET['id'])->find();
         $this->display();
     } else {
         alert('error', L('PARAMETER ERROR'), $_SERVER['HTTP_REFERER']);
     }
 }
Пример #30
0
         while ($resultats_cups = $query_cups->fetch()) {
             // On stock les noms des cups
             if ($resultats_cups['idcup'] == $idcup_client) {
                 $nom_cup_client = $resultats_cups['nom'];
             }
             if ($resultats_cups['idcup'] == $idcup_vendeur) {
                 $nom_cup_vendeur = $resultats_cups['nom'];
             }
         }
         // On ferme la connexion
         $query_cups->closeCursor();
         $sujet = 'Offre acceptée';
         $contenu = 'Ceci est un message automatique.' . "\n" . $login_client . ' a accepté votre offre : ' . $qte_vendeur . ' ' . $nom_cup_vendeur . ' (' . $login_vendeur . ') contre ' . $qte_client . ' ' . $nom_cup_client . ' (' . $login_client . ')' . "\n" . "\n" . 'Organisez-vous pour conclure la transaction ! Vous pouvez toujours mettre à jour votre collection si l\'échange n\'a finalement pas lieu.';
         // On envoie un message à l'auteur de l'offre pour lui dire que l'user à accepter son offre
         include '../messages/send_msg_function.php';
         sendMessage($login_client, $login_vendeur, $sujet, $contenu);
         // Il faut traiter les cas "n'importe laquelle de mes cups" (option désactivée pour le moment)
         header('Location: ' . $_SERVER['HTTP_REFERER']);
         exit;
     } else {
         // S'il n'a pas l'ecocups nécessaire, on le redirige
         header('Location: ' . $_SERVER['HTTP_REFERER']);
         exit;
     }
 } else {
     // On ferme la connexion
     $query_auto_accept->closeCursor();
     // S'il tente une douille, on le redirige
     header('Location: ' . $_SERVER['HTTP_REFERER']);
     exit;
 }