Esempio n. 1
0
	public function respond() {
		global $_W, $engine;
		$level = array();
		if (!empty($_W['account']['modules'])) {
			foreach ($_W['account']['modules'] as $row) {
				if (!empty($row['displayorder']) && $row['displayorder'] < 127) {
					$level[$row['displayorder']] = $row;
				}
			}
		}
		if (!empty($level)) {
			$response = '';
			for ($i = 1; $i <= 5; $i++) {
				if (!empty($response)) {
					$engine->response['module'] = $_W['module'];
					return $response;
					break;
				}
				if (empty($level[$i])) {
					continue;
				}
				$_W['module'] = $level[$i]['name'];
				$processor = WeUtility::createModuleProcessor($_W['module']);
				$processor->message = $this->message;
				$processor->inContext = false;
				$processor->rule = $this->rule;
				$engine->response['rule'] = $default['id'];
				$response = $processor->respond();
			}
		}
		if (!empty($_W['account']['default_period']) && empty($_W['cache']['default_period'])) {
			return;
		}
		$response['FromUserName'] = $this->message['to'];
		$response['ToUserName'] = $this->message['from'];
		$response['MsgType'] = 'text';
		$default = pdo_fetchcolumn("SELECT `default` FROM " . tablename('wechats') . " WHERE `weid`=:weid", array(':weid' => $_W['weid']));
		if (is_array(iunserializer($default))) {
			$default = iunserializer($default);
			$_W['module'] = $default['module'];
			$processor = WeUtility::createModuleProcessor($default['module']);
			$processor->message = $this->message;
			$processor->inContext = $this->inContext;
			$processor->rule = $default['id'];
			return $processor->respond();
		}
		$response['Content'] = stripslashes($default);
		return $response;
	}
Esempio n. 2
0
 public function respond()
 {
     global $_W, $engine;
     $sql = "SELECT `welcome` FROM " . tablename('wechats') . " WHERE `weid`=:weid";
     $default = pdo_fetchcolumn($sql, array(':weid' => $_W['weid']));
     if (is_array(iunserializer($default))) {
         $default = iunserializer($default);
         $_W['module'] = $default['module'];
         $processor = WeUtility::createModuleProcessor($default['module']);
         $processor->message = $this->message;
         $processor->inContext = $this->inContext;
         $processor->rule = $default['id'];
         $processor->module = $_W['account']['modules'][$default['module']];
         $engine->response['rule'] = $default['id'];
         return $processor->respond();
     }
     return $this->respText($default);
 }
Esempio n. 3
0
	public function respond() {
		global $_W, $engine;
		$r['FromUserName'] = $this->message['to'];
		$r['ToUserName'] = $this->message['from'];
		$r['MsgType'] = 'text';
		$sql = "SELECT `welcome` FROM " . tablename('wechats') . " WHERE `weid`=:weid";
		$default = pdo_fetchcolumn($sql, array(':weid' => $_W['weid']));
		if (is_array(iunserializer($default))) {
			$default = iunserializer($default);
			$_W['module'] = $default['module'];
			$processor = WeUtility::createModuleProcessor($default['module']);
			$processor->message = $this->message;
			$processor->inContext = $this->inContext;
			$processor->rule = $default['id'];
			$engine->response['rule'] = $default['id'];
			return $processor->respond();
		}
		$r['Content'] = $default;
		return $r;
	}
Esempio n. 4
0
 private function process($param)
 {
     global $_W;
     if (empty($param['module']) || !in_array($param['module'], $this->modules)) {
         return false;
     }
     $processor = WeUtility::createModuleProcessor($param['module']);
     $processor->message = $param['message'];
     $processor->rule = $param['rule'];
     $processor->priority = intval($param['priority']);
     $processor->inContext = $param['context'] === true;
     $response = $processor->respond();
     if (empty($response)) {
         return false;
     }
     return $response;
 }
Esempio n. 5
0
    echo $exit;
    exit;
}
if ($do == 'end') {
    $fanid = intval($_GPC['fanid']);
    $fans = pdo_fetch('SELECT fanid,acid,openid FROM ' . tablename('mc_mapping_fans') . ' WHERE uniacid = :uniacid AND fanid = :id', array(':uniacid' => $_W['uniacid'], ':id' => $fanid));
    $account = account_fetch($fans['acid']);
    $message['from'] = $_W['openid'] = $fans['openid'];
    $message['to'] = $account['original'];
    if (!empty($message['to'])) {
        $sessionid = md5($message['from'] . $message['to'] . $_W['uniacid']);
        load()->classs('wesession');
        load()->classs('account');
        session_id($sessionid);
        WeSession::start($_W['uniacid'], $_W['openid'], 300);
        $processor = WeUtility::createModuleProcessor('chats');
        $processor->end();
    }
    if (!empty($_GPC['from'])) {
        $url = base64_decode($_GPC['from']);
    } else {
        $url = url('mc/fans/', array('acid' => $fans['acid']));
    }
    header('Location:' . $url);
    exit;
}
function iurldecode($str)
{
    if (!is_array($str)) {
        return urldecode($str);
    }
Esempio n. 6
0
/**
 * 运行模块勾子
 * @param string $hookname
 */
function runhook($hookname) {
	global $_W;
	$hooks = $_W['cache']['hooks'][$_W['weid']];
	if (empty($hooks)) {
		cache_build_hook($_W['uid']);
		$hooks = cache_load("hooks:{$_W['weid']}");
	}
	if (!empty($hooks[$hookname])) {
		foreach ($hooks[$hookname] as $hook) {
			$hookobj = WeUtility::createModuleProcessor($hook[0]);
			if (method_exists($hookobj, $hook[1])) {
				call_user_func(array($hookobj, $hook[1]));
			}
		}
	}
}
Esempio n. 7
0
 public function doWebPreview()
 {
     //'from_user' => base64_encode(authcode("fromuser", 'ENCODE'))
     $url = create_url('mobile/module', array('name' => 'shopping3', 'do' => 'wlhome', 'weid' => $GLOBALS['_W']['weid']));
     $processor = WeUtility::createModuleProcessor($this->module['name']);
     $url = $processor->index();
     header('Location: ' . $url);
 }
Esempio n. 8
0
 public function respond()
 {
     global $_W, $engine;
     $level = array();
     if (!empty($_W['account']['modules'])) {
         foreach ($_W['account']['modules'] as $row) {
             if (!empty($row['displayorder']) && $row['displayorder'] < 127) {
                 $level[$row['displayorder']] = $row;
             }
         }
     }
     if (!empty($level)) {
         $response = '';
         for ($i = 1; $i <= 5; $i++) {
             if (!empty($response)) {
                 $engine->response['module'] = $_W['module'];
                 return $response;
                 break;
             }
             if (empty($level[$i])) {
                 continue;
             }
             $_W['module'] = $level[$i]['name'];
             $processor = WeUtility::createModuleProcessor($_W['module']);
             $processor->message = $this->message;
             $processor->inContext = false;
             $processor->rule = $this->rule;
             $engine->response['rule'] = $default['id'];
             $processor->module = $_W['account']['modules'][$_W['module']];
             $response = $processor->respond();
         }
     }
     if (!empty($_W['account']['default_period'])) {
         $_W['cache']['default_period'] = TRUE;
         $row = pdo_fetch("SELECT id, lastupdate FROM " . tablename('default_reply_log') . " WHERE from_user = '******'from']}' AND weid = '{$_W['weid']}'");
         if (!empty($row)) {
             if (TIMESTAMP - intval($row['lastupdate']) > intval($_W['account']['default_period'])) {
                 $_W['cache']['default_period'] = TRUE;
             } else {
                 $_W['cache']['default_period'] = FALSE;
             }
         }
         if (!empty($row)) {
             pdo_update('default_reply_log', array('lastupdate' => TIMESTAMP), array('id' => $row['id']));
         } else {
             pdo_insert('default_reply_log', array('from_user' => $this->message['from'], 'lastupdate' => TIMESTAMP, 'weid' => $_W['weid']));
         }
     }
     if (!empty($_W['account']['default_period']) && empty($_W['cache']['default_period'])) {
         return;
     }
     $default = pdo_fetchcolumn("SELECT `default` FROM " . tablename('wechats') . " WHERE `weid`=:weid", array(':weid' => $_W['weid']));
     if (is_array(iunserializer($default))) {
         $default = iunserializer($default);
         $_W['module'] = $default['module'];
         $processor = WeUtility::createModuleProcessor($default['module']);
         $processor->message = $this->message;
         $processor->inContext = $this->inContext;
         $processor->rule = $default['id'];
         $processor->module = $_W['account']['modules'][$default['module']];
         return $processor->respond();
     }
     return $this->respText($default);
 }
Esempio n. 9
0
	private function process() {
		$response = false;
		if (empty($this->response['module']) || !in_array($this->response['module'], $this->modules)) {
			return false;
		}
		$processor = WeUtility::createModuleProcessor($this->response['module']);
		$processor->message = $this->message;
		$processor->rule = $this->response['rule'];
		$response = $processor->respond();
		if(empty($response)) {
			return false;
		}
		return $response;
	}