zhenjiang.dou il y a 8 ans
Parent
commit
a8e5cc44a2
6 fichiers modifiés avec 62 ajouts et 3 suppressions
  1. 19 1
      core.php
  2. 27 0
      post.php
  3. 11 0
      remote_reg.php
  4. BIN
      resources/background.png
  5. 2 2
      signup.php
  6. 3 0
      test.php

+ 19 - 1
core.php

@@ -6,4 +6,22 @@
     $rooturl = $_SERVER['HTTP_HOST'];
     $domain = preg_replace('/^www\./', '', $rooturl);
     $static_release = "2016122717430333";
-?>
+    function curlrequest($url, $data, $method="post") {
+        $ch = curl_init(); // 初始化CURL句柄
+        curl_setopt($ch, CURLOPT_URL, $url); // 设置请求的URL
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // 设为TRUE把curl_exec()结果转化为字串,而不是直接输出
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); // 设置请求方式
+        curl_setopt($ch, CURLOPT_REFERER,$url); // 构造来路
+        curl_setopt($ch, CURLOPT_HTTPHEADER,array("X-HTTP-Method-Override: $method")); // 设置HTTP头信息
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // 设置提交的字符串
+        $document = curl_exec($ch); // 执行预定义的CURL
+        if(!curl_errno($ch)) {
+            $info = curl_getinfo($ch);
+            echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];
+        } else {
+            echo 'Curl error: ' . curl_error($ch);
+        }
+        curl_close($ch);
+        // $document=preg_replace("/[\t\n\r]+/","",$document);
+        return $document;
+    }

+ 27 - 0
post.php

@@ -0,0 +1,27 @@
+<?php
+ 
+function curlrequest($url,$data,$method="post"){
+    $ch = curl_init(); // 初始化CURL句柄 
+    curl_setopt($ch, CURLOPT_URL, $url); // 设置请求的URL
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // 设为TRUE把curl_exec()结果转化为字串,而不是直接输出 
+    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); // 设置请求方式
+    curl_setopt($ch, CURLOPT_REFERER,$url); // 构造来路
+    curl_setopt($ch, CURLOPT_HTTPHEADER,array("X-HTTP-Method-Override: $method"));//设置HTTP头信息
+    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // 设置提交的字符串
+    $document = curl_exec($ch); // 执行预定义的CURL
+    if(!curl_errno($ch)) {
+      $info = curl_getinfo($ch);
+      echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url']; 
+    } else {
+      echo 'Curl error: ' . curl_error($ch); 
+    }
+    curl_close($ch);
+    return $document;
+}
+ 
+$url = 'http://order.uiisc.com/register.php';
+$data = "request from put method";
+$return = curlrequest($url, $data, "post");
+ 
+var_dump($return);exit;
+?>

+ 11 - 0
remote_reg.php

@@ -0,0 +1,11 @@
+<?php
+    require_once ("core.php");
+    // $domain = "uiisc.com";
+    $post_data = $_POST;
+    print_r($post_data);
+    $data = file_get_contents("php://input");
+    $url = "http://order.".$domain."/register.php";
+    // $data = $post_data;
+    $return = curlrequest("http://".$domain."/test.php", $data, "post");
+
+    var_dump($return);exit;

BIN
resources/background.png


+ 2 - 2
signup.php

@@ -36,7 +36,7 @@
             </p></h3>
         </div>-->
         <div class="panel-body">
-            <form class="form-horizontal" role="form" method=post action="https://order.<?=$domain?>/register.php">
+            <form class="form-horizontal" role="form" method=post action="//order.<?=$domain?>/register.php"><!--remote_reg.php-->
                 <input type="hidden" name="plan_name" value="free webhosting">
                 <div class="form-group">
                     <label for="inputUsername" class="col-sm-4 control-label" data-i18n="username">Username</label>
@@ -84,7 +84,7 @@
                 <div class="form-group">
                     <label for="inputID" class="col-sm-4 control-label" data-i18n="security_code">Security Code</label>
                     <div class="col-sm-5">
-                    <img width="90px" height="25px" src="https://order.<?=$domain?>/image.php?id=<?=$security_id?>">
+                    <img width="90px" height="25px" src="//order.<?=$domain?>/image.php?id=<?=$security_id?>">
                     <input type="hidden" name="id" class="form-control" id="inputID" placeholder="ID" value="<?=$security_id?>">
                     </div>
                 </div>

+ 3 - 0
test.php

@@ -0,0 +1,3 @@
+<?php
+    print_r($_POST);
+?>