star7th 9 жил өмнө
parent
commit
473433552a

+ 0 - 68
Application/Home/Controller/PageController.class.php

@@ -88,74 +88,6 @@ class PageController extends BaseController {
         $this->display();        
     }
 
-    //跳转到HTTP接口测试页面
-	public function http_api(){
-		
-		$this->display(); 
-	}
-
-	//处理HTTP测试请求,返回请求接口后的数据
-	public function ajaxHttpApi(){
-		$url=I('url');
-		$method=I('method');
-		$params=I('params');
-		if($method=='get'){
-			$url=$url."?".$params;
-			$return=$this->http_get($url);
-		}else{
-			$return=$this->http_post($url, $params);
-		}
-		echo $return;
-	}
-	/**
-	 * GET 请求
-	 *
-	 * @param string $url        	
-	 */
-	private function http_get($url) {
-		$oCurl = curl_init ();
-		if (stripos ( $url, "https://" ) !== FALSE) {
-			curl_setopt ( $oCurl, CURLOPT_SSL_VERIFYPEER, FALSE );
-			curl_setopt ( $oCurl, CURLOPT_SSL_VERIFYHOST, FALSE );
-		}
-		curl_setopt ( $oCurl, CURLOPT_URL, $url );
-		curl_setopt ( $oCurl, CURLOPT_RETURNTRANSFER, 1 );
-		$sContent = curl_exec ( $oCurl );
-		curl_close ( $oCurl );
-		return $sContent;
-	}
-	
-	/**
-	 * POST 请求
-	 *
-	 * @param string $url        	
-	 * @param array $param        	
-	 * @return string content
-	 */
-	private function http_post($url, $param) {
-		$oCurl = curl_init ();
-		if (stripos ( $url, "https://" ) !== FALSE) {
-			curl_setopt ( $oCurl, CURLOPT_SSL_VERIFYPEER, FALSE );
-			curl_setopt ( $oCurl, CURLOPT_SSL_VERIFYHOST, false );
-		}
-		if (is_string ( $param )) {
-			$strPOST = $param;
-		} else {
-			$aPOST = array ();
-			foreach ( $param as $key => $val ) {
-				$aPOST [] = $key . "=" . urlencode ( $val );
-			}
-			$strPOST = join ( "&", $aPOST );
-		}
-		curl_setopt ( $oCurl, CURLOPT_URL, $url );
-		curl_setopt ( $oCurl, CURLOPT_RETURNTRANSFER, 1 );
-		curl_setopt ( $oCurl, CURLOPT_POST, true );
-		curl_setopt ( $oCurl, CURLOPT_POSTFIELDS, $strPOST );
-		$sContent = curl_exec ( $oCurl );
-		curl_close ( $oCurl );
-		return $sContent;
-	}
-
     //保存
     public function save(){
         $login_user = $this->checkLogin();

+ 0 - 94
Application/Home/View/Page/http_api.html

@@ -1,94 +0,0 @@
-<include file="Common/header" />
-<style type="text/css">
-	input{
-		width: 100%;
-	}
-</style>
-<div id="layout" style="width: 70%;margin: auto;">
-	<form class="form-horizontal">
-		<h2 style="text-align: center;">{$Think.Lang.api_test_title}</h2>
-        <div class="control-group">
-          <div class="controls">
-            <select style="width: 100px;" id="method" >
-            	<option value="post">POST</option>
-            	<option value="get">GET</option>
-            </select>
-          </div>
-        </div>
-        <div class="control-group">
-          <div class="controls">
-          	<label >{$Think.Lang.api_address_description}</label>
-            <input type="text" id="url"  placeholder="{$Think.Lang.api_address}" >
-          </div>
-        </div>
-        <div class="control-group">
-          <div class="controls">
-          	<label >{$Think.Lang.params_description})</label>
-            <input type="text" id="params" placeholder="{$Think.Lang.params}" >
-          </div>
-        </div>
-        <div class="control-group">
-          <div class="controls">
-            <button type="button" class="btn btn-primary" id="http-submit">{$Think.Lang.submit}</button>
-            <button type="reset"  class="btn btn-link" >{$Think.Lang.clear}</button>
-          </div>
-        </div>
-        <div class="control-group">
-          <div class="controls">
-          	<label >{$Think.Lang.result}</label>
-			<textarea style="width: 100%;height: 300px;" id="http-response"></textarea>
-          </div>
-        </div>
-      </form>
-</div>
-<include file="Common/footer" />
-<script type="text/javascript">
-	$(function () {
-		//格式化json数据
-		function dump(arr,level) { 
-			 var dumped_text = ""; 
-			 if(!level) level = 0; 
-			 
-			 //The padding given at the beginning of the line. 
-			 var level_padding = ""; 
-			 for(var j=0;j<level+1;j++) level_padding += "     "; 
-			 if(typeof(arr) == 'object') { //Array/Hashes/Objects 
-			 	 var i=0;
-				 for(var item in arr) { 
-					 var value = arr[item]; 
-					 if(typeof(value) == 'object') { //If it is an array, 
-						 dumped_text += level_padding + "\"" + item + "\" : \{ \n"; 
-						 dumped_text += dump(value,level+1); 
-					 	 dumped_text +=level_padding +"\}";
-					 } else { 
-					 	dumped_text += level_padding + "\"" + item + "\" : \"" + value + "\""; 
-					 } 
-					 if(i<Object.getOwnPropertyNames(arr).length-1){
-					 	dumped_text+=", \n";
-					 }else{
-					 	dumped_text+=" \n";
-					 }
-					 i++;
-				 } 
-			 } else { //Stings/Chars/Numbers etc. 
-			 	dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; 
-			 } 
-			 return dumped_text; 
-		} 
-		$("#http-submit").on('click',function () {
-			$.post("?s=home/page/ajaxHttpApi",{
-				url:$("#url").val(),
-				method:$("#method").val(),
-				params:$("#params").val()
-			},function (data) {
-				try{
-					var text="\{ \n"+dump(JSON.parse(data))+" \}";//整体加个大括号
-					$("#http-response").val(text);
-				}catch(e){
-					//非json数据直接显示
-					$("#http-response").val(data);
-				}
-			});
-		});
-	});
-</script>

+ 3 - 9
Application/Home/View/Page/index.html

@@ -1,15 +1,7 @@
 <include file="Common/header" />
 <link href="__PUBLIC__/highlight/default.min.css" rel="stylesheet"> 
-<script src="__PUBLIC__/highlight/highlight.min.js"></script> 
+<link href="__PUBLIC__/css/page/index.css" rel="stylesheet"> 
 
-<style type="text/css">
-body{
-	overflow-x:hidden;overflow-y:hidden;
-	font-size: 1rem;
-	line-height: 1.7em;
-}
-
-</style>
 <h3 style="text-align: center;">{$page.page_title}</h3>
 <!-- 这里开始是内容 -->
 <div class="" style="padding-top:10px;">
@@ -22,4 +14,6 @@ body{
 
 
  <include file="Common/footer" />
+ <script src="__PUBLIC__/highlight/highlight.min.js"></script> 
 <script src="__PUBLIC__/js/page/index.js"></script>
+s

+ 22 - 0
Public/css/page/index.css

@@ -0,0 +1,22 @@
+
+h3{
+	font-size: 1.5em;
+}
+
+body{
+	overflow-x:hidden;overflow-y:hidden;
+	font-size: 1rem;
+	line-height: 1.7em;
+}
+
+p{
+	margin: 0 0 20px;
+	text-align: justify;
+	text-justify: inter-ideograph;
+	word-break: initial;
+	word-break: break-word;
+}
+
+li{
+	line-height: 30px;
+}