$UserName, "Password" => $Password ); $token = self::execute($user); self::setLoginToken($token); return $token; } static public function execute($request, $session = null) { $Url = 'http://' . str_replace(array('http://', 'https://'), '', self::$Url); $res = utils::http_post_xml($Url, $request); return $res; } /** * 组装请求艺龙接口的XML * @param $data * @param string $encoding * @param string $root * @return string */ static public function xml_encode($data, $LoginToken, $root = "") { $encoding=self::$encoding; $GUID = self::$GUID; $Version = self::$Version; $xml = "\n"; $xml .= "<$root xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" >"; $xml .= "$LoginToken$GUID$Version"; $xml .= parent::data_to_xml($data); $xml .= ""; return $xml; } /* * 验证post传递的参数是否合法 * 默认提交的全是POST请求 */ static function validatePost() { $post = array(); if (isset($_POST) && !empty($_POST)) { $post = array_merge($post, $_POST); } if (isset($_REQUEST) && !empty($_REQUEST)) { $post = array_merge($post, $_REQUEST); } if (isset($_GET) && !empty($_GET)) { $post = array_merge($post, $_GET); } if (!empty($post)) { if (isset($_POST['error'])) unset($_POST['error']); foreach (array_keys($post) as $array_key) { if (!self::validateString($post[$array_key])) { return false; } } } return true; } /* * 验证参数是否合法 * @return 合法:true 非法:false */ static function validateString($str) { $check = 0; if (is_string($str)) $check = preg_match('/select |insert |update |delete |union|into|load_file|outfile/', $str); return $check == 0 ? true : false; } }