nutballs

For some reason using the webrequest class in the manner of my framework is not working. It does work on another site, on the same server, without my framework. Obviously its something with my framework but again, just not seeing it. It runs the execution, but nothing gets returned from the remote server. If i hit the same server using just this:
$xml = new SimpleXMLElement(file_get_contents($url));
it can grab the content.

application->scrapesomething gets called from my presentation page, but no need to show that.

debug output

simpleGet: Starts with [http://www.asu.edu]
Outbound Header:
GET  HTTP/1.1
Host: www.asu.edu
User-Agent:
Accept:
Accept-Language:
Accept-Encoding:
Accept-Charset:
Connection: close

Content-Type: text/html
Content-Length: 0

Default beforeExecute()
Execute: Starts
Execute: HostStr=[www.asu.edu] Port:80
Execute:

PHP

 5 or greater, setting timeout of
Execute: Sending request
Execute: Request Sent
GetChunk: Starts
getChunk: Remote Timeout
handleProxyRetry()
Execute: Failed - Did not receive anything from remote host
handleFailure()
Default afterExecute()
simpleGet Failed
Array
(
)


My application class - stripped down

class application
{  
private function scrapesomething()
{
//Get the URLs to scrape
$url= "http://www.asu.edu";
$req = &$GLOBALS['webrequest']; //this is the global reference to the webrequest object instance in the presentation page.
                $req->debugMode = WRD_ECHO;
$req->method = 'GET'; //for some reason if i dont put this, it wont default to get, and it fails. clue?
$result = $req->simpleGet($url);
print_r($req->getHeaders());
      }
}


only thing that was added to perks webrequest class was this constructor to enable global access to a single object. (per my framework)

function __construct() {
if ($GLOBALS['webrequest'])
{
$GLOBALS['messages']->adderr('webrequest.class.

php

  is being constructed more than once.');
}
else
{
$GLOBALS['webrequest'] = &$this;
}
  }

nutballs

I ran some more tests, such as instantiating the webrequest object from within the application->function.
still no worky. but the result from debug is different.


simpleGet: Starts with [http://www.mit.edu]
Outbound Header:
GET  HTTP/1.1
Host: www.mit.edu
User-Agent: Mozilla/5.0 (

Mac

 intosh; U; PPC

Mac

  OS X; en)

Apple

 WebKit/417.9 (KHTML, like Gecko) Safari/417.8
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding:
Accept-Charset: ISO-8859-1,utf-8:q=0.7,*;q=0.7
Connection: close

Content-Type: text/html
Content-Length: 0

Default beforeExecute()
Execute: Starts
Execute: HostStr=[www.mit.edu] Port:80
Execute:

PHP

 5 or greater, setting timeout of 30
Execute: Sending request
Execute: Request Sent
GetChunk: Starts
GetChunk: Received 2988
processHeaders: Starts
processHeaders: Result Code is
processHeaders: Array Follows
Array
(
)
Execute: Successful Retrieve
postProcess: Content length is 0
handleSuccess()
Default afterExecute()
Execute: Completes
simpleGet Failed
Array
(
)

perkiset

NB - how you're using it is unfamiliar to me so I'll try to ring you up later and get more symptoms and example source

/p

nutballs

i dunno. my framework seems to be having issues. particularly the database class. My methodology of assigning each object to a global variable is not working. Weird behavior is afoot.

like doing a "select * from table where something=somethingelse limit 2" and then looping, actually processes 7 rows... LOL

conceptually I like my framework, but I have a feeling it just is too open to weirdness. Unless its just that Im not understanding

php

  and its intricacies.

perkiset

I've been wanting to talk to you re. "frameworks" in any case.

I've noticed something extremely similar about your's and my trajectories, moving from large compiled language IDEs into this new realm. The most important thing I can say is that I had a gorgeous, full featured capital-F Framework written in Kylix and Delphi that was the basis for all of my sites. It was the most efficient and best way to do things.

I wrote my first couple passes at a

PHP

 -based framework the same way. It was lush and full, chock full of all kinds of mechanisms that I thought would really make my future

PHP

  life better.

Now my framework (lowercase f) is more a loose confederation of includes than a large single code body. I notice as I get better and better with

PHP

  (I'm in about 2.5 years now) that my code gets lighter, smaller, tighter and faster as I move away from my older notions of Framework into littler classes that I combine and retask more easily. Today, my backoffice framework, for example, LOOKS like it is a big managed app, but actually it's a bunch of pages that happen to work together. It is true that everything flows through a single script and my essentially page construction methodology is the same, but the code that does it is pretty light. My stock retail site script is only a couple hundred lines long now - my basic structure is pretty simple:


  • Create just a couple global objects like a db connection - but my db connection does not actually connect until it's required, so it's still pretty light

  • Check to make sure <whatever cached items [this] site needs> are loaded

  • Translate URL to taste

  • require() <the page file> defined by the URL. This page file will include the theme file if it requires it. A normal page will, a report page, for example, will not.

  • Some times the main script will do some output modification with the content[] array that is created by that whole mess. For example, retail sites may need prices changed to reflect the country of surfer origin - that's done in the main script because I don't want to have every page, the theme etc have to know what country the surfer is from.

  • echo implode(chr(10), $content);



I know you'll need to follow a trajectory and explorations at your own pace... just wanted to offer this a gear turner because you seem a bit frustrated by the complexity of it. I get it.

Applause
/p

nutballs

I fully agree.
The main problem i am trying to tackle though is codebase-consistency. If i deploy custom apps to 5 different clients, all of which are built using the same framework, I can easily update security handling for example, by just dropping the new class class file into each site. In an ideal world, all my stuff would operate via RPC, but that is unrealistic with latency and such.

My framework is not complicated, and is only to provide the bare minimum of consistent functionalities that every single site i make has. Such as
database connectivity and SQL injection defense
access security both page level and inpage level
template management and display security (XSS defense)
messaging
general configuration class with site specific constants like database logins for example
helpers like a dateadd function.

thats really it. everything else is just piled into one giant ass application class.
The only reason is consistency.

nutballs

thats really weird. my constructor to globalize the object actually prevents it from functioning. Im sure if i actually took some time to read though all your code I would realize why, but alas, I am a lazy bastard and just barreling through stuff for now. So pffft. moving onward and just using the class locally when needed.

perkiset

Alas.
Applause

nutballs

You are just jealous of my mastery of archaic english.  Applause

perkiset

It's a fair cop.


Perkiset's Place Home   Politics @ Perkiset's