Page 4 of 6

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 9:44 am
by JAB Creations
WOOT! I was going to get stuck on imploding an array with Onion's suggestion though I remembered .= and I was like...nice...

I'm going to email this to the person I interviewed with in a moment to see if this is what he is looking for. I'd appreciate your opinions on this bit, just throw it on your localhost and hit the submit button if you'd so kindly would. :)

Code: Select all

<div style="height: 200px;">
<?php
function url_remote($url)
{
 $separator = '&';
 //$separator = '&';//Uncomment this instead separator if you plan to use as part of client XHTML output.
 if (isset($url))
 {$wookie_feet .= $url.'?';
  foreach ($_POST as $key => $value)
  {
   $wookie_feet .= urlencode($key).'='.urlencode($value);
   $wookie_feet .=  $separator;
  }
  return $wookie_feet;
 }
 else
 {
  return false;
 }
}
$url = $_POST['url'];
echo url_remote($url);
?>
</div>
<form action="" method="post">
<fieldset>
<legend>Add Game</legend>
<div><label for="name_first">First Name</label><input id="name_first" name="name_first" type="text" value="John" /></div>
<div><label for="name_last">Last Name</label><input id="name_last" name="name_last" type="text" value="Smith" /></div>
<div><label for="url">URL</label><input id="url" name="url" type="text" value="http://localhost/" /></div>
</fieldset>
 
<fieldset>
<legend>Game Tags</legend>
<div><label for="cat_1"><input checked="checked" class="checkbox" id="cat_1" name="cat_1" type="checkbox" value="1" />Action</label></div>
<div><label for="cat_2"><input checked="checked" class="checkbox" id="cat_2" name="cat_2" type="checkbox" value="2" />Adventure</label></div>
<div><label for="cat_3"><input checked="checked" class="checkbox" id="cat_3" name="cat_3" type="checkbox" value="3" />Arcade</label></div>
<div><label for="cat_4"><input checked="checked" class="checkbox" id="cat_4" name="cat_4" type="checkbox" value="4" />Family</label></div>
<div><label for="cat_5"><input checked="checked" class="checkbox" id="cat_5" name="cat_5" type="checkbox" value="5" />Puzzle</label></div>
<div><label for="cat_6"><input checked="checked" class="checkbox" id="cat_6" name="cat_6" type="checkbox" value="6" />Role Player</label></div>
<div><label for="cat_7"><input checked="checked" class="checkbox" id="cat_7" name="cat_7" type="checkbox" value="7" />Sports</label></div>
</fieldset>
 
<fieldset>
<legend>Options</legend>
<div><input class="button" type="submit" value="Add this game now!" /></div>
</fieldset>
</form>
An example of the output minus the http...
localhost/?name_first=John&name_last=Smith&url=http%3A%2F%2Flocalhost%2F&cat_1=1&cat_2=2&cat_3=3&cat_4=4&cat_5=5&cat_6=6&cat_7=7&

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 9:47 am
by JAB Creations
Oh wait it has to be remote! DOH! I changed the echo to an include at the bottom and I got this error...
URL file-access is disabled in the server configuration
...this has to call a remote server with the URL so it dumps the $_GET's in to a database. That's all I have to do before I submit this...suggestions to reduce the time between now and the submission? Time is a factor here.

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 10:09 am
by JAB Creations

Code: Select all

$fp = fsockopen(url_remote($url), 80, $errno, $errstr, 8);
I just left him a quick message/question about his server's PHP configuration in regards to socket transport "http". He mentioned something about time outs as well so this seems to fit exactly what he's looking for. I also want to see how he wants the function "styled" as in if it's static just for this sort of request of if he wants it to be a bit more open ended for other tasks.

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 10:37 am
by onion2k
At a minimum I think I'd do...

Code: Select all

function pass_to_domain($domain="www.domain.com/remote.php", $array=$_POST) {
  $get_values = array();
  foreach ($array as $key => $value) {
    $get_values[] = urlencode($key)."=".urlencode($value);
  }
  file_get_contents("http://".$domain."?".implode("&", $get_values));
}
 
Obviously there should be checks to see if the domain already has a protocol assigned, and if there are already any get vars, and to see if $array actually contains any values... but if you're looking to make something short rather than robust...

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 10:38 am
by onion2k
Word of advice... $wookie_feet is a bit of a strange variable name. You should use something that describes the value it holds.

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 10:53 am
by JAB Creations
XAMPP doesn't have socket transport "http" enabled and I just changed...

allow_url_include = Off

to...

allow_url_include = On

in php.ini.

I'll change the wookie feet variable in a moment though I'm stuck on this problem right now. They're obviously running a custom configured Apache server so I'm looking for http anything right now. Nothing mentioned here either...
http://us3.php.net/fsockopen

Suggestions to enable HTTP for fsockopen please?

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 10:57 am
by jaoudestudios
Sorry, have not been keeping up-to-date with the thread. JAB you seem to be doing well though!

I do agree with Onion2k, change $wookie_feet as is it meaningless especially if another developer needs to work on your code.

When I get home I will have a read and catch up.

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 11:03 am
by JAB Creations
Thanks jaoudes, I've been burning some extra Red Bull to bust through this as much as I can. I said I'd email him in a couple minutes...

So XAMPP keeps refusing to execute the HTTP request! So I rebooted (and XP decided as usual that it should take three minutes to power off my system) after I manually restarted Apache any way. I used Advanced Find & Replace to make sure I corrected all of the bloody php.ini files in the XAMPP directory (because you know it SHOULD be necessary to have half a dozen of the dang blasted things!)...so none of that worked!

Then I just uploaded the file to my live server and it's still giving me the same error! Is laughing at my own misfortune natural or should I be spazzing out right now like a noob? :|

...on the upside I plan on writing my own blog for the next major version of my site in very 2009!

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 11:14 am
by JAB Creations
basically, you cant feed a full uri as the target parameter.
...trying this now then...

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 11:22 am
by onion2k
JAB Creations wrote:So XAMPP keeps refusing to execute the HTTP request! So I rebooted (and XP decided as usual that it should take three minutes to power off my system) after I manually restarted Apache any way. I used Advanced Find & Replace to make sure I corrected all of the bloody php.ini files in the XAMPP directory (because you know it SHOULD be necessary to have half a dozen of the dang blasted things!)...so none of that worked!
Have a look at phpinfo()... there should be a page with it at http://localhost/xampp/phpinfo.php ... it'll tell you the path for the php.ini file Apache is using under "Loaded Configuration File".

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 11:28 am
by onion2k
Also, the option in php.ini you need to set to On is "allow_url_fopen" rather than "allow_url_include" I think.

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 11:51 am
by JAB Creations
Thanks though I'm using file_get_contents which works perfectly however I'll still look up what you mentioned Onion.

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Fri Oct 17, 2008 2:22 pm
by JAB Creations
UPDATE

Ok I'm at that critical point where everything I could have done is done. It's all up to the folks at the company to discuss the matter. Here are the questions I asked in no particular order...

1.) What if anything would you like me to concentrate on?

The answer I got was pretty much the database stuff. He said MySQL is great for basic stuff and then companies like Google use it. So I am going to look to flex my brain as much as I can to prove I'm up to the task. Learning tertiary relational databases (or whatever the correct terminology is) impressed him in the time I did it. So MySQL is my weak spot and so I'm going to try to concentrate on that as much as I acn (which essentially has been my major point of work since the summer began here (northern hemisphere of course).

2.) If I start what should I expect as far as showing up?

The decision will be made over the weekend/early in the week. Essentially if I get the job I'll jump in and start working an 8:30-5:30 shift. Absolutely frigin gorgeous because these are the type of people (like you guys I suppose though I know them more face to face then through a forum though I imagine everyone's personalities to be on many of the same frequencies) I want to be around and work with. The main point is for me to plan ahead because they know I don't have a car and I wanted to show that so long as they give me a reasonable amount of time with a heads up that I'll be there when they want me to be. Sarasota's bus system blows but I'll make it work out one way or another.

3.) What could I improve on the work that I submitted?

He did have some constructive criticism (nicely worded and greatly appreciated!) and I explained that I usually don't put $_POST in to a MySQL query (they were of course escaped!) just that I was concentrating on learning the relational database stuff. He said none of what I sent counts against me, it merely gives him an idea of where I stand.

In general my chances at least appear to seem reasonably high even though they are saying they want me just for working on the back end. I also mentioned I was going to try to use fsockopen instead of file_get_contents though my local (and live servers) absolutely refused to allow me to use the HTTP method. I also added that I'd be more then happy to bring my box in and learn how to optimize and configure my system similar to their setup.

In general he said he likes me and that I am under the serious consideration list (not the exact words). So they'll give me a call early next week regardless of what the decision is. Again as I mentioned earlier if I don't get the job they'll give me advice on what I should concentrate on.

...as for this moment in time I have a client coming over with Burger King (I'm frigin starved!) and a LAN party a little later on hopefully. I really appreciate everyone's advice and support and I'll keep you guys up to date on everything.

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Mon Oct 20, 2008 2:04 pm
by JAB Creations
Monday's UPDATE

I just got a call in regards to a second interview scheduled for tomorrow. If what I've been told remains accurate if I fit then I could start as early as Wednesday morning.

It's oddly a win-win situation for me. If I don't get the job I get to stay up until 4am everyday working on code. If you lived in Florida you would too, trust me!

If I do get the job family said they'd get me a cheap laptop (I'd like to get an Acer Aspire, ASUS is permanently on my s-list.) which would give me something to do while I wait for them to open.

...for the President's interview I have my current project live and while still in Alpha 2 it's pretty late and stable. They use Firefox (thankfully) and I'm sure they won't mind letting me sign on to Yahoo to demonstrate my SJAX single page load/registration/email verification power feature.

I've created an indirect though easy method to share my current project without posting a direct link. To view my project simply type the password "alpha2" (without the quotes all lower case) and the page will redirect you.

I'll demo to the president how the SJAX registration works keeping in mind that it's still an alpha though the important stuff is there. Since it's a developer position they're more interested in functionality which is what I've mostly concentrated on thus far. Currently the members and profiles pages in the top menu work. The registration link will open a layer and the process should be ready for public usage only of course the rest of the project it still in Alpha (albeit relatively late and mostly stable). The passwords are stored as salt and peppered hashes.

Things you can do after registration include updating your profile and uploading an avatar. You'll be able to view your profile listed on the members page. Keep in mind it's mostly a basis for things to come.

That's about it I guess for now. I'll have some time tomorrow morning to work on any rough edges though I'm not looking to destabilize the current build since everything that I've worked on currently works. I'll post how the second interview went sometime late tomorrow afternoon. Also once I hit my initial beta stage I'll post the code for this project in the critique forum. Feel free to post your comments here for now about it and thanks to any one who checks it out.

Re: PHP Lead Developer Interview: Your suggestions please!

Posted: Mon Oct 20, 2008 2:35 pm
by onion2k
Good luck mate.