Created
          February 12, 2013 22:36 
        
      - 
      
- 
        Save kevinharley/4774136 to your computer and use it in GitHub Desktop. 
    CORS Proxy server solution for ajax posts
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| // URL from registration form | |
| $ret = PostAdminUser('Data2Gold.com', 'cc3/PRSave.wow?fx=00461&WEB', $_POST); | |
| function PostAdminUser($empfaenger, $file, $data) | |
| { | |
| $dataparts = array(); | |
| foreach($data as $key => $value) | |
| { | |
| $dataparts[] = urlencode($key).'='.urlencode($value); | |
| } | |
| $data = implode('&', $dataparts); | |
| $fp = fsockopen('Data2Gold.com', 80, $errno, $errstr, 30); | |
| if (!$fp) { | |
| $ret = "$errstr ($errno)<br />\n"; | |
| } else { | |
| $out = "POST /".$file." HTTP/1.1\r\n"; | |
| $out .= "Host: Data2Gold.com\r\n"; | |
| $out .= "Accept: */*\r\n"; | |
| $out .= "Content-type: application/x-www-form-urlencoded\r\n"; | |
| $out .= "Content-length: ".strlen($data)."\r\n"; | |
| $out .= "Connection: close\r\n"; | |
| $out .= "\r\n"; | |
| $out .= "$data"; | |
| $ret = ''; | |
| fwrite($fp, $out); | |
| while (!feof($fp)) { | |
| $ret .= fgets($fp); | |
| } | |
| fclose($fp); | |
| } | |
| return "Replyheader:\n".$ret."\n\nPost-Header:\n".$out ; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment