
php-n00b
Members-
Posts
20 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
-
Location
xxxx rm /home/zack/Desktop/js.js zzzz
php-n00b's Achievements

Member (2/5)
0
Reputation
-
Ahoy Sailor! So I've just started making a Server Client based application in PHP, First time I've dabble in PHP for about a year so forgive me if I'm slightly rusty. But I get the "Could not accept incoming connection" error when my client try's to connect to my server. How cometh? <?php $host = "127.0.0.1"; $port = 405; set_time_limit(0); // create socket $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); $result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n"); $result = socket_listen($socket, 3) or die("Could not set up socket listener\n"); // Networking area, Creating, Binding & finally listing $spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); $out = "0;text\n"; socket_write($spawn, $out, strlen ($out)) or die("Could not write output\n"); ?> ^ Client <?php $addr="127.0.0.1"; $port=405; $timeout=0; $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n"); $res = socket_connect($socket, $addr, $port); $spawn = socket_accept($socket) or die("Could not accept incoming connection\n"); $dat= socket_read($spawn, 1024) or die("Could not read input\n"); echo $dat; ?> Server^ _____________________ Anyone know? See Ya!
-
What's Up? OK, So I'm using the IF and ELSE function to echo some html code, But I need to be able to echo the contents of a variable inside of some html code. if ($var1=="text") echo '<body><text>$text</text></body>' else echo 'Failed' But of course instead of echoing the contents of the $text variable, It just echo $text. I'ved tried putting. if ($var1=="text") echo '<body><text>'; echo $text; echo '</text></body>' else echo 'Failed' But I got another error, Someone in IRC mentioned the word backslash, However that was the only advice I got. Thanks Bye!
-
What's Up? OK, so I've been trying to copy a file to the root of my webserver from a folder, But when you use this code. <?php chdir('saved/'); $file = 'Archive.tar.gz'; $newfile = (New.tar.gz); if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } ?> It copies it to the same dir, I've tried $newfile = (/public_html/New.tar.gz); But that doesn't work, If the folder was in the same folder as where you where currently chdir'd to, then it would be $newfile = (folder/New.tar.gz); But how would you copy it to the root of your server? Anyone Know? Thanks Bye.
-
Thanks everyone for helping, I used $glob = new RegexIterator(new DirectoryIterator("Folder/"), '#\.html$#D'); foreach ($glob as $file) { echo $file->getFilename() . "\n"; $lines = $file->openFile(); foreach ($lines as $line) { echo $line; } echo "\n--\n"; } using that glob thing i got some sort of error, Now i see the contents of the files all in one place, Thanks alot :-)
-
Oops I meant to echo the contents of all the files, Why am I such an idiot?
-
What's Up? OK, So I'm finally nearing the end of my first big php endeavour, The last thing I need to do it to make viewing all the files I have easier, Is it possible to echo all the files (they all end in .html) in a php file? So something like. $var = "Folder/*.html"; echo $var But not that of course. Any ideas? Thanks Bye!
-
What's Up? OK, So since the need for php has been cropping up in my latest project a lot lately, I decided to get down and get learning! Somehow, I even amazed myself, I got this far. Basically when you use a basic IP php logger, It logs your IP and date to separate lines, So if your getting lots of visits then your gonna have a bulky list, Lets see if we can change that? <?php $ip = $_SERVER['REMOTE_ADDR']; $datum = date("d-m-y / h:a"); $invoegen = "$datum - $ip \n"; $fopen = fopen("Database.html", "a"); $echo = file_get_contents('Database.html'); $old = "$ip"; $new = "\n"; $make = str_replace($old, $new, $echo); fwrite($fopen, $make); fwrite($fopen, $invoegen); fclose($fopen); # ip logging completed! ?> As you can see it gets your IP, And then attempts to replace it in the log, And it works 100% fine, But now its time for the harder part, The date, How could we remove the date that the IP came with, str_replace doesn't use wildcards does it? (*)? Thanks Bye.
-
What's Up? OK, So New to PHP, And have a quick and hopefully easy question. Basically when the same user comes to me PHP ip logger script their IP gets logged, But if they come twice it makes a whole new line, So i set about figuring out how to clean up multiple entry's. Heres my source. <?php $logfile= 'make1.html'; $IP = $_SERVER['REMOTE_ADDR']; $logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>'; $fp = fopen($logfile, "a"); fwrite($fp, $logdetails); fwrite($fp, "<br>"); fclose($fp); $data1 = file("make1.html"); $data2 = file("make2.html"); file_put_contents('Database.html', implode('', array_unique(array_merge($data1,$data2)))); unlink('make1.html'); unlink('make2.html'); $ourFileName = "make1.html"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); $ourFileName = "make2.html"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); ?> Now that works fine, When a the same person comes it just updates the time, But, When a new IP comes it clears the last IP and puta the new one their. Example. So the IP 127.0.0.1 gets logged first. December 12, 2009, 2:55 pm: 127.0.0.1 And when it comes again December 12, 2009, 3:00 pm: 127.0.0.1 So everythings fine, When the new IP comes though this happens. December 12, 2009, 3:02 pm: 74.63.89.20 What happened the the last IP's entry? Anyone Know? Thanks Bye.
-
What's Up? OK, Now I have the typical IP logging script. <?php $logfile= 'Database.html'; $IP = $_SERVER['REMOTE_ADDR']; $logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>'; $fp = fopen($logfile, "a"); fwrite($fp, $logdetails); fwrite($fp, "<br>"); fclose($fp); ?> But I'm expecting lots of visits from the same IP, So instead of adding a new line to the log file for the same IP, Is it possible to over write the last recorded visit, So only the time of that visit is updated? Thanks Bye.
-
What's Up? OK, So I followed a tutorial using practice Off-line html's, And it worked, But when i try edit the value of a field using an online frame, It doesn't work. Example: Lets try and edit google.co.uk's text field. <body onload="parent.right_frame.document.f.q.value='Yo!'"> 'right_frame' shows google.co.uk. But It doesn't work. Anyone see the scripting hole? Thanks Bye.
-
What's Up? OK, So I'm creating a auto submission script, And i have it working, Well some whatley, You see when I myself click the submit button everything works, But my goal is to make it automatic. On another forum in the javascript section we used onload="document.post.submit();" But to put it in short that didn't work. So i thought how about our good old friend vbscript. So it it possible via <script type="vbscript">?
-
What's Up? OK, So im new to PHP and wondered is it possible to insert text into a html form field using PHP? Thanks Bye.
-
Ouch! Nah, How hard is it to do in mysql?
-
Is it still possible in PHP?
-
What's Up? OK, So i currently use this script off the internet. <?php $logfile= 'logged.html'; $IP = $_SERVER['REMOTE_ADDR']; $logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>'; $fp = fopen($logfile, "a"); fwrite($fp, $logdetails); fwrite($fp, "<br>"); fclose($fp); ?> But i'll be getting loats of visits from the same IP, So instead of trolling thorough some sort of text dungeon i wondered if there was a way to update the prevoius entry of that iP, So if a new IP visited then it would be logged to a new line but if the same one visited it would just update the time and date.