
superkingkong
Members-
Posts
46 -
Joined
-
Last visited
Everything posted by superkingkong
-
thanks for the grear help it works apparently, we need to start the session on the main page we learnt something new today
-
i put the include on the top before the echo, i didn't get any error, but it still keeps logging. i've tried uploading the same scripts to a different host to test... it still doing the same thing. http://picsworld.biz/tt/i.php - the main script to call the log.php http://picsworld.biz/tt/log.php - the log script http://picsworld.biz/tt/logv.php - the viewer
-
yes... this is the entire script. here is the code on the pages additional info: my web hosting company is using suphp 5. does that matter? it doesn't support virtual(), that's why i'm converting my perl to php this is the i.php <?php echo "<br />test log script<br />"; // phpinfo (); include ('log.php'); ?> this is the log.php <?php session_start(); // Getting the information $ipaddress = $_SERVER['REMOTE_ADDR']; $page = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; // $page .= iif(!empty($_SERVER['QUERY_STRING']), "?{$_SERVER['QUERY_STRING']}", ""); $referrer = $_SERVER['HTTP_REFERER']; $datetime = date('D, M j, Y (T) \a\t h:i:s A'); $useragent = $_SERVER['HTTP_USER_AGENT']; $remotehost = @getHostByAddr($ipaddress); // Create log line $logline = $ipaddress . '|' . $referrer . '|' . $datetime . '|' . $useragent . '|' . $remotehost . '|' . $page . "\n"; // Write to log file: $logfile = 'log.db'; $_SESSION['stats'] = (isset($_SESSION['stats'])) ? $_SESSION['stats']+1 : 1; if($_SESSION['stats'] > 1) { //they refreshed the page or came back here } else { //it's their first time here; your code here if (!$handle = fopen($logfile, 'r+')) { die("Failed to open log file"); } file_put_contents($logfile, $logline . file_get_contents($logfile)); fclose($handle); } ?>
-
hi, i've created a blank file with the code include ("log.php") http://premium.sfdns.net/~superkin/i.php everytime when i refresh that page, i get new log http://premium.sfdns.net/~superkin/logv.php this script is to view the log i've tried using IE7 and ff3.. still the same can you please try the url above and look at the log and see whether it increments.... thanks
-
did you try the browser reload? on my side, it still logs when i refresh... -- sorry.. double posting. i can't delete this post...
-
hi, i've tried the code above, the script still logs when i refresh the browser. i'm using firefox. appreciate if you can please help, thanks. about the db, that will be my next step. last time my perl writes to a plain text file, since i've just converted to php, i want to make this script works first, then i'll move on to database
-
hi, thanks a lot for the info. i've managed to come out with this code: what's your opinion? <?php session_start(); // Getting the information $ipaddress = $_SERVER['REMOTE_ADDR']; $page = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $page .= if(!empty($_SERVER['QUERY_STRING']), "?{$_SERVER['QUERY_STRING']}", ""); $referrer = $_SERVER['HTTP_REFERER']; $datetime = date('D, M j, Y (T) \a\t h:i:s A'); $useragent = $_SERVER['HTTP_USER_AGENT']; $remotehost = @getHostByAddr($ipaddress); // Create log line $logline = $ipaddress . '|' . $referrer . '|' . $datetime . '|' . $useragent . '|' . $remotehost . '|' . $page . "\n"; // Write to log file: $logfile = 'log.db'; $_SESSION['stats'] = (isset($_SESSION['stats'])) ? $_SESSION['stats']+1 : 1; if($_SESSION['stats'] > 1) { //they refreshed the page or came back here } else { //it's their first time here; your code here if (!$handle = fopen($logfile, 'r+')) { die("Failed to open log file"); } file_put_contents($logfile, $logline . file_get_contents($logfile)); fclose($handle); } ?> and i call it from other pages <?php include ("log.php"); ?> appreciate your feedback
-
thanks for the idea i have one question, how long will the session last before the script starts logging again? thanks
-
hi, previously i'm using this perl script, but recently, i'm converting my old html website to php, so, my perl is not working with php anymore. this script is to log visitors info, browser, ip and hostname. i'm stuck with these steps, preventing the script from logging the info when user is refresing the browser. appreciate if anyone can help me out with porting this perl code to php.. if (-e "$hostfile") { open(HOST,"$hostfile"); $hostline = <HOST>; chop($hostline) if $hostline =~ /\n$/; close(HOST); ($old_time,$old_number,$old_page,$old_browser) = split(/\¦/,$hostline); } # save host and time info and check if this is a page reload open(HOST,">$hostfile"); $seconds = time; print HOST "$seconds\¦$ENV{REMOTE_ADDR}\¦$ENV{'DOCUMENT_URI'}\¦$ENV{'HTTP_USER_AGENT'}"; close(HOST); if ($time - $old_time < $interval && $ENV{REMOTE_ADDR} eq $old_number && $ENV{'DOCUMENT_URI'} eq $old_page && $ENV{'HTTP_USER_AGENT'} eq $old_browser) { don't do anything } else { process it } appreciate if anyone could help me out with this, thanks.
-
displaying even/odd items of an array
superkingkong replied to superkingkong's topic in PHP Coding Help
oh, i'm not sure whether it reads the .htaccess. all i know is, when my directory has no files (excluding) .htaccess, the count shows 1 if i have abc.gif and .htaccess, the count shows 1 if i have abc.gif and def.jpg and .htaccess, the count shows 2 so, i'm not sure what is wrong.. -
PHP FTP multiple files upload help
superkingkong replied to superkingkong's topic in PHP Coding Help
yes, i've seen quite a few of them, but they can only upload 1 file at a time. if my user needs to upload 100 files, they will have to click and wait for 100 times... i've read somewhere, the timeout directive can't be changed in .htaccess... well, maybe someone here might have a more accurate information. as for zipping up... it's also an options, but to zip 100 files is a pita -
displaying even/odd items of an array
superkingkong replied to superkingkong's topic in PHP Coding Help
hi, i'm sorry to bother again i've noticed that... although the directory is "empty", the count is showing 1. well, actually, my upload directory has a .htaccess file. is glob reading it as well although it is not declared in glob? thanks. -
hi guys, i'm trying to look for a php ftp script that can upload multiple files to my site. currently, i'm using the php / perl to upload, but when trying to upload large files, i get http error page that most ppl are having... it's something to do with the httpd.conf timeout error, which i can't change, because my site is hosted on a shared server. i'm trying to upload multiple image files, eg, 5mb each file...about 10of them each time.. so, it should be 50mb total each time. sometimes it's successful, probably the connection is fast, but most of the time, i get an http error page, due to connection slow. would appreciate if someone could give me some pointer on this php ftp upload. btw, i'm new to php thank you very much
-
displaying even/odd items of an array
superkingkong replied to superkingkong's topic in PHP Coding Help
hey, thanks my bad, too excited to try out the new code, missed the 2 dots thanks again -
displaying even/odd items of an array
superkingkong replied to superkingkong's topic in PHP Coding Help
thanks for the suggestion i tried to put the code in the particular directory, it only shows the top and bottom row. total files uploaded is only 1. all the files are not showing. do you know the reason? by the way, the directory is not empty. thanks. -
displaying even/odd items of an array
superkingkong replied to superkingkong's topic in PHP Coding Help
ooh... here is my code.... wonder whether if you can help me to "streamline" it <?php $viewExt = '.jpg|.jpeg|.tif|.tiff|.gif|.png|.pdf|.txt'; // only filenames with these extensions will be displayed $dirHandle = opendir('../upload'); $fcount = 0; while ($file = readdir($dirHandle)) { if ($file != '.' && $file != '..' && eregi("($viewExt)$",$file) && !eregi("^index.",$file)) { $stack[] = $file; // append filename to an array $fcount ++; } } closedir($dirHandle); sort($stack); echo "<table border=1><tr><td colspan='2' align='center'><b>Your Uploaded Files</b></td></tr><tr><td>"; $type = 0; //Even; for($i = $type; $i < count($stack); $i += 2){ echo "<br><font color='#ff0000'><b>•</b></font> " . $stack[$i]; } echo "</td><td>"; $type = 1; //Odd; for($i = $type; $i < count($stack); $i += 2){ echo "<br><font color='#ff0000'><b>•</b></font> " . $stack[$i]; } echo "</tr><tr><td colspan='2' align='center'><b>Total Uploaded Files:" . $fcount . "</b></td></tr></table>"; ?> thank you very much :) -
displaying even/odd items of an array
superkingkong replied to superkingkong's topic in PHP Coding Help
Hi, thank you so much :) -
hi guys, for eg, i have a listing of files in a directory, assigned to an array eg, abc.txt def.txt ghi.txt jkl.txt mno.txt pqr.txt stu.txt vwx.txt yz.txt how can i display the even count or odd count of them? eg, abc.txt ghi.txt mno.txt stu.txt yz.txt or def.txt jkl.txt pqr.txt vwx.txt your help is very much appreciated, thanks
-
Problem with session.. error http 500. please help.
superkingkong replied to superkingkong's topic in PHP Coding Help
yes, my account came with a cpanel, assigned to me by the hosting company. but i can't access it now, my office blocked the port i will check it when i reach home. so, where can i find the error log? can i check it with ftp? i have ftp access to my account now. -
Problem with session.. error http 500. please help.
superkingkong replied to superkingkong's topic in PHP Coding Help
well, i'm not sure how my php.ini is. ok, my whole objective is to create a sub-folder within my upload folder, based on their first name and last name. so that they can upload files onto "their own" folder, easy for me to manage. probably my logic wrong.. since i'm not a programmer anyway, my first page is to get users' first and last name. form.php form.php is working to my expectation. second, form output to fl_name.php fl_name.php is working, since it manages to create directory and display the session variable - fpath third, is the upload.php upload.php is working as well, i mean, it still prints out the correct session variable -
hi guys, I'm just a newbie in php, trying to create an upload script. it was working initially, until i start using session, so that i can pass values between pages. i have few question, but let me start with this first. here is my code: <?php // this starts the session session_start(); $success = 0; $fail = 0; $uploaddir = 'chenup/'; $max_size = "10000000"; // 50000 is the same as 50kb $totalfiles = "5"; session_start(); require('includes/application_top.php'); echo '<html ' . HTML_PARAMS . '><head><meta http-equiv="Content-Type" content="text/html; charset=' . CHARSET . '">'; echo '<title>' . TITLE . ' - Upload Photos</title>'; echo '<base href="' . (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG . '">'; echo '<link rel="stylesheet" type="text/css" href="stylesheet.css"></head>'; echo '<body><center><table class="infoBoxContents" border="0" width="100%" cellspacing="0" cellpadding="0"><tr class="infoBoxContents"><td class="infoBoxContents" align="center"><table class="infoBoxContents" border="0" width="90%" cellspacing="8" cellpadding="8">'; for ($i=0;$i<$totalfiles;$i++) { if($_FILES['userfile']['name'][$i]) { $uploadfile = $uploaddir . basename($_FILES['userfile']['name'][$i]); $ext = strtolower(substr($uploadfile,strlen($uploadfile)-3,3)); if (preg_match("/(jpg|gif|png|tif|pdf)/",$ext)) { // Check File Size if(($_FILES['userfile']['size'][$i] < $_POST['MAX_FILE_SIZE']) || ($_FILES['userfile']['size'][$i] < $max_size)) { if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $uploadfile)) { $success++; $success_total++; echo '<tr><td class="UploadPage" align="center"><b><font color="#00CC00">Upload Success !</font></b><br>' . ' <b>' . $_FILES['userfile']['name'][$i] . '</b> (' . $_FILES['userfile']['size'][$i]/1024 . ' kb)'; echo '</td></tr>'; } else { $fail++; echo '<tr><td class="UploadPage" align="center"><b><font color="#ff0000">Upload Failed.! Please retry</font></b><br>' . ' <b>' . $_FILES['userfile']['name'][$i] . '</b> (' . $_FILES['userfile']['size'][$i]/1024 . ' kb)'; echo '</td></tr>'; } } else { $fail++; echo '<tr><td class="UploadPage" align="center"><b><font color="#ff0000">Upload Failed ! File size exceed 10MB</font></b><br>' . ' <b>' . $_FILES['userfile']['name'][$i] . '</b> (' . $_FILES['userfile']['size'][$i]/1024 . ' kb)'; echo '</td></tr>'; } } else { $fail++; echo '<tr><td class="UploadPage" align="center"><b><font color="#ff0000">Upload Failed ! Invalid File Extension</font></b><br>' . ' <b>' . $_FILES['userfile']['name'][$i] . '</b> (' . $_FILES['userfile']['size'][$i]/1024 . ' kb)'; echo '</td></tr>'; } } } echo '</table></td></tr><tr><td class="main" align="center"> <br><table class="infoBoxContents" border="2" width="40%" cellspacing="3" cellpadding="3"><tr><td class="main" align=left>'; echo '<b>Total number of files uploaded:</b></td><td class="main" align=left> '.$success; echo '</td></tr><tr><td class="main" align=left><b>Total number of files not uploaded:</b></td><td class="main" align=left> '.$fail . '</td></tr></table></td></tr>'; echo '<tr><td class="main" align="center"> <br><form method="post"><input type="button" value="Close Window" onclick="window.close()"></form> <FORM METHOD="LINK" ACTION="upload.php"><INPUT TYPE="submit" VALUE="Continue"></FORM></td></tr>'; echo '<tr class="infoBoxContents"><td class="main" align="center"> <p><img src="images/store_logo.png" alt="PicsWorld"> <br><font size=-2>Copyright © 2008 <a href="http://picsworld.biz/">PicsWorld</a></font></td></tr></table>'; ?> The php script will be working if i remark // the session start (). when i unremark it, the page will show http 500 error. i would appreciate if someone could help me out here. really need your help, thanks. btw, i have few files before this final scripts. i will show it here if you need me to. thanks a lot.