Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 32

Thread: [Various] HTTP Wrappers

  1. #11

    Joined
    Dec 2011
    Posts
    488
    Thanks
    303
    Thanked
    559/263
    DL/UL
    13/4
    Mentioned
    34 times
    Time Online
    1h 58m
    Avg. Time Online
    N/A
    Anytime in the next like week, haha

  2. #12
    Saiyan Race
    j03's Avatar
    Joined
    Dec 2011
    Posts
    13,722
    Userbars
    166
    Thanks
    5,906
    Thanked
    33,077/6,608
    DL/UL
    23/36
    Mentioned
    3,867 times
    Time Online
    563d 5h 25m
    Avg. Time Online
    3h 13m
    Wow totally forgot about cxWrapper!
    (you need an account to see links)
    (you need an account to see links)(you need an account to see links)

    ------------------------
    [02/24/2013] Stealth CORE is made into the first standalone Neopets auto-player.
    ------------------------


  3. #13
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    Can we get this thread stickied please?

  4. #14

    Joined
    Jul 2012
    Posts
    20
    Userbars
    0
    Thanks
    11
    Thanked
    1/1
    DL/UL
    7/0
    Mentioned
    Never
    Time Online
    7m
    Avg. Time Online
    N/A
    Do we have a breakdown of the features, pros/cons and so on of the different wrappers?
    Thank you for the post as well

  5. #15
    james087's Avatar
    Joined
    Sep 2012
    Posts
    64
    Userbars
    1
    Thanks
    20
    Thanked
    7/5
    DL/UL
    10/0
    Mentioned
    1 time
    Time Online
    N/A
    Avg. Time Online
    N/A
    mmm what about the php wrapper inside of @(you need an account to see links) 's Dailies Script zWrapper?
    PHP Code:
    class zWrapper
    {

        private 
    $cookies$LastPage$useProxy;

        public 
    $proxyHost$proxyPort;

        public function 
    Request($method$url$referer ''$showHeaders false)
        {
            
    $showHeaders = (bool)$showHeaders;
            
    $file '';
            
    $host '';
            
    $data '';
            if (
    strcasecmp($method'GETPOST') == 0) {
                if ((
    $x strpos($url'~~')) !== false) {
                    
    $data substr($url$x 2);
                    
    $url substr($url0$x);
                }
            } else
                if (
    strcasecmp($method'POST') == 0) {
                    if ((
    $x strpos($url'?')) !== false) {
                        
    $data substr($url$x 1);
                        
    $url substr($url0$x);
                    }
                }
            if (
    strcasecmp(substr($url07), 'http://') == 0) {
                
    $host substr($url7);
            }
            if ((
    $x strpos($host'/')) !== false) {
                
    $file substr($host$x);
                
    $host substr($host0$x);
            } else {
                
    $file '/';
            }
            if (isset(
    $referer)) {
                
    $referer 'Referer: ' $referer;
            } else
                if (isset(
    $this->LastPage)) {
                    
    $referer 'Referer: ' $this->LastPage;
                }
            
    $this->LastPage $url;
            
    $fp null;
            if (
    $this->useProxy)
                
    $fp fsockopen($this->proxyHost$this->proxyPort) or die($errstr ' (' $errno .
                    
    ')');
            else
                
    $fp fsockopen($host80) or die($errstr ' (' $errno ')');
            if (
    $fp) {
                
    fwrite($fp$this->headers($method$file$host$referer$data));
                
    $r '';
                
    $s microtime(true);
                while (!
    feof($fp) && (microtime(true) - $s 10000))
                    
    $r .= fgets($fp256);
                
    fclose($fp);
                
    $temp explode("\r\n\r\n"$r2);
                
    $this->process_headers($temp[0]);
                if (
    strpos($temp[0], 'Content-Encoding: gzip') !== false) {
                    
    $temp[1] = $this->el_zip_gzDecode($temp[1]);
                    return 
    $showHeaders implode("\r\n\r\n"$temp) : empty($temp[1]) ? implode("\r\n\r\n",
                        
    $temp) : $temp[1];
                } else {
                    return 
    $showHeaders $r : empty($temp[1]) ? implode("\r\n\r\n"$temp) : $temp[1];
                }
            }
        }

        public function 
    clearCookies()
        {
            
    $this->cookies = array();
        }

        public function 
    getCookies()
        {
            return 
    $this->cookies;
        }

        public function 
    setProxy($host$port)
        {
            
    $this->proxyHost $host;
            
    $this->proxyPort $port;
            
    $this->useProxy true;
        }

        public function 
    offProxy()
        {
            
    $this->useProxy false;
        }

        public function 
    setCookies($cookies)
        {
            
    $this->cookies $cookies;
        }

        public function 
    __construct()
        {
            
    date_default_timezone_set('America/Los_Angeles');
            
    $this->cookies = array();
            if (!
    function_exists('stripos')) {
                function 
    stripos($haystack$needle)
                {
                    return 
    strpos($haystackstristr($haystack$needle));
                }
            }
        }

        private function 
    el_zip_gzDecode($data)
        {
            
    $gzMagic sprintf("%X%X"ord(substr($data11)), ord(substr($data01)));
            if (
    $gzMagic != "8B1F") {
                
    $unpacked = @gzinflate($data);
                return 
    $unpacked;
            }
            
    $flags ord(substr($data31));
            
    $headerlen 10;
            if (
    $flags 4) {
                
    $extralen unpack('v'substr($data102));
                
    $extralen $extralen[1];
                
    $headerlen += $extralen;
            }
            if (
    $flags 2// CRC at end of header

                
    $headerlen += 2;
            return 
    gzinflate(substr($data$headerlenstrlen($data) - $headerlen 8));
        }

        private function 
    cookieString()
        {
            if (
    count($this->cookies) > 0) {
                
    $string 'Cookie:';
                foreach (
    $this->cookies as $k => $v)
                    
    $string .= $k=$v;";
                return 
    $string "\r\n";
            }
        }

        private function 
    process_headers($headers)
        {
            
    $size count($lines explode("\n"$headers));
            
    $x = -1;
            while (++
    $x $size) {
                if (
    preg_match('/^Set-Cookie: ([^;]+);/'$lines[$x], $s)) {
                    list(
    $key$val) = explode("="$s[1], 2);
                    
    $this->cookies[$key] = $val;
                }
            }
        }

        private function 
    headers($method$file$host$referer ""$data "")
        {
            
    $isPost stripos($method'POST') !== false;
            
    $h = ($isPost 'POST ' 'GET ') . (@substr($file01) == '/' $file '/' .
                
    $file) . " HTTP/1.1\r\n";
            
    $h .= 'Host: ' $host "\r\n";
            
    $h .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
            
    $h .= "Accept-Language: en-us,en;q=0.5\r\n";
            
    $h .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
            
    $h .= "Accept-Encoding: gzip,deflate\r\n";
            if (!empty(
    $referer))
                
    $h .= $referer "\r\n";
            
    $h .= $this->cookieString();
            
    $h .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13\r\n";
            if (
    $isPost) {
                
    $h .= "Content-Type: application/x-www-form-urlencoded\r\n";
                
    $h .= 'Content-Length: ' strlen($data) . "\r\n";
            }
            
    $h .= "Keep-Alive: 115\r\n";
            
    $h .= "Connection: keep-alive\r\n\r\n";
            
    #$h .= "Connection: close\r\n\r\n";
            
    if ($isPost)
                
    $h .= $data;
            return 
    $h;
        }


    Lol check out what I made

    all my shyt's going to be in php now
    well unless you guys strongly prefer either vb.net or (preferably)C# so that you can more easily step through my code.
    Last edited by james087; 09-08-2012 at 09:15 PM.

  6. The Following User Says Thank You to james087 For This Useful Post:

    Zachafer (09-09-2012)

  7. #16
    Zachafer's Avatar
    Joined
    Dec 2011
    Posts
    1,235
    Userbars
    11
    Thanks
    769
    Thanked
    1,466/678
    DL/UL
    98/0
    Mentioned
    512 times
    Time Online
    24d 13h 9m
    Avg. Time Online
    8m
    I strongly prefer php

  8. #17
    james087's Avatar
    Joined
    Sep 2012
    Posts
    64
    Userbars
    1
    Thanks
    20
    Thanked
    7/5
    DL/UL
    10/0
    Mentioned
    1 time
    Time Online
    N/A
    Avg. Time Online
    N/A
    Quote Originally Posted by Miguel View Post
    I'm not sure what you're doing there with PHP as a desktop application, but looks nice! Though in my experience running it as a program instead of a web script was somewhat slow, what's the speed like there?
    All I made was a hello world app the rest of those files are Zachafer's. This is my first experience running php as a desktop app so not sure on benchmarks. Even more unsure now that I've learned I can compile php.

    What programs have you run that seemed somewhat slow that were in PHP?

  9. #18
    james087's Avatar
    Joined
    Sep 2012
    Posts
    64
    Userbars
    1
    Thanks
    20
    Thanked
    7/5
    DL/UL
    10/0
    Mentioned
    1 time
    Time Online
    N/A
    Avg. Time Online
    N/A
    Quote Originally Posted by Miguel View Post
    Just some stuff I've written, might be better in a newer PHP release though
    Oh cool I didn't think anyone else here would have any experience with php as a desktop application. Did you use GTK+ / glade to make the gui? Seems GTK is much more popular with python, but I have zero experience with python.. figured I'd learn GTK+ /glade first and then maybe switch to python since there is so much more active development going on with it compared to php.. if php isn't good enough for what I need it to do.

    Are you concerned about speed for things like auto buying?
    Last edited by james087; 09-10-2012 at 12:25 PM.

  10. #19
    james087's Avatar
    Joined
    Sep 2012
    Posts
    64
    Userbars
    1
    Thanks
    20
    Thanked
    7/5
    DL/UL
    10/0
    Mentioned
    1 time
    Time Online
    N/A
    Avg. Time Online
    N/A
    Quote Originally Posted by Miguel View Post
    PHP is designed for web development
    Yeah, the vast majority of my background is in web development php, which is why the idea of using PHP as a desktop application appeals to me. My first language was C# / asp.net (also for web), but moved to PHP just because it was the first job I could find.

    I'm probably underestimating the importance of speed for these small little applications. I'm sure I'll have tons of fun trying to optimize when that time comes

    I'll switch to python if it becomes unrealistic to use php. Joe likes python right?
    Quote Originally Posted by Infamous Joe View Post
    ./m Y U NO POST PYTHON WRAPPER?
    Last edited by james087; 09-10-2012 at 01:19 PM.

  11. #20
    Saiyan Race
    j03's Avatar
    Joined
    Dec 2011
    Posts
    13,722
    Userbars
    166
    Thanks
    5,906
    Thanked
    33,077/6,608
    DL/UL
    23/36
    Mentioned
    3,867 times
    Time Online
    563d 5h 25m
    Avg. Time Online
    3h 13m
    Quote Originally Posted by james087 View Post
    Yeah, the vast majority of my background is in web development php, which is why the idea of using PHP as a desktop application appeals to me. My first language was C# / asp.net (also for web), but moved to PHP just because it was the first job I could find.

    I'm probably underestimating the importance of speed for these small little applications. I'm sure I'll have tons of fun trying to optimize when that time comes

    I'll switch to python if it becomes unrealistic to use php. Joe likes python right?
    I like C# a lot right now.
    (you need an account to see links)
    (you need an account to see links)(you need an account to see links)

    ------------------------
    [02/24/2013] Stealth CORE is made into the first standalone Neopets auto-player.
    ------------------------


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •