Thread: PHP login script stopped working
Results 1 to 2 of 2
Related
-
Auto Login Script Forum: Javascript Forum
Replies: 0 -
'Login' Script Forum: HTML Forum
Replies: 14 -
EMERGENCY allowedRecipients for Formmail.pl stopped working Forum: CGI Perl Forum
Replies: 6 -
Info for login script Forum: Website Scripts Forum
Replies: 4
-
05-26-2006, 05:37 AM #1
PHP login script stopped working
I have a login script which displays who's viewing my website.
It's now not working can anyone take a look at it see whats wrong.
I have reproduced it here :-
It stores the names of each visitor up to a max of 200 in a txt file called 'ppl_visited' and was used to display which pages they visited but I have removed that part as I don't really need to know that any more it just stores the names now (or did).
It also stores the names of each visitor in a txt file
called 'ppl_online' which I use to display who is online at any given time much the same as this forum does.
(It is a password controled private website and I for now have removed the password.)
This is the error message I get..
----------------------------
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
----------------------------
Any help would be appreciated..
---------------------------
<?php
$page_directory = "/public_html/"; //Make sure it includes the trailing slash
$index_page = "wjcag.php";
$password = " ***********";
$ppl_online_file = "./ppl_online.txt";
$timeout = 15; //minutes inactivity to be set as "offline"
$separator = ", ";
$login_page = "login.htm";
$log_limit = 200;
$log_file = "ppl_visited.txt";
$ip = $HTTP_ENV_VARS['REMOTE_ADDR'];
if(!is_readable($ppl_online_file)){
$handle = fopen($ppl_online_file, 'w');
fclose($handle);
}
$ppl_online = file($ppl_online_file);
$ppl_online_now = array();
$ppl_not_online = array();
foreach($ppl_online as $key => $value){
$value = trim($value);
$temp = explode(' ', $value, 4);
if(($_POST['password'] == $password) && (strtolower($temp[3]) == strtolower($_POST['name']))){
$current_user = $temp[3];
$current_user_type = $temp[0];
$temp[1] = time();
}else if(($temp[0] == 3) && ($temp[3] == $_COOKIE['name'])){
}else if($temp[2] == $ip){
$current_user = $temp[3];
$current_user_type = $temp[0];
$temp[1] = time();
}else if($temp[0] == 1){
if($temp[1] + (60 * $timeout) >= time()){
array_push($ppl_online_now, explode(' ', $value, 4));
}else{
array_push($ppl_not_online, explode(' ', $value, 4));
}
}else if($temp[1] + (60 * $timeout) >= time()){
array_push($ppl_online_now, explode(' ', $value, 4));
}
}
header("Cache-Control: no-cache, must-revalidate");
if($_POST['go']){
if($_POST['password'] == $password){
$current_user_type = $_POST['Rem'];
if($_POST['Rem'] == 0){
setcookie('password', $_POST['password'], time() + 157680000, '/', '.wjcag.co.uk');
setcookie('name', $_POST['name'], time() + 157680000, '/', '.wjcag.co.uk');
}
$current_user = $_POST['name'];
if((isset($_GET['page'])) && (is_readable($page_directory . $_GET['page']))){
$html = displayfile($page_directory . $_GET['page']);
}else{
if(is_readable($page_directory . $index_page)){
$html = displayfile($page_directory . $index_page);
}else{
echo "Please click back; the index page either does not exist, or is unreadable<br /> sorry, for the inconvenience";
}
}
}else{
echo displayfile($page_directory . $login_page);
}
}else if((isset($_COOKIE['name'])) && ($_COOKIE['password'] == $password)){
$current_user_type = 3;
$current_user = $_COOKIE['name'];
if((isset($_GET['page'])) && (is_readable($page_directory . $_GET['page']))){
$html = displayfile($page_directory . $_GET['page']);
}else{
if(is_readable($page_directory . $index_page)){
$html = displayfile($page_directory . $index_page);
}else{
echo "Please click back; the index page either does not exist, or is unreadable<br /> sorry, for the inconvenience";
}
}
}else if($current_user != ''){
if((isset($_GET['page'])) && (is_readable($page_directory . $_GET['page']))){
$html = displayfile($page_directory . $_GET['page']);
}else{
if(is_readable($page_directory . $index_page)){
$html = displayfile($page_directory . $index_page);
}else{
echo "Please click back; the index page either does not exist, or is unreadable<br /> sorry, for the inconvenience";
}
}
}else{
echo displayfile($page_directory . $login_page);
}
if(is_array($ppl_online_now[0])){
foreach($ppl_online_now as $key => $firstdim){
if($ppl_online_now[$key] != ''){
$txt_output .= implode(" ", $ppl_online_now[$key]);
if(is_array($ppl_online_now[$key+1]) || isset($current_user_type)){
$txt_output .= "\n";
}
}
}
}
if(isset($current_user_type)){
$txt_output .= $current_user_type . " " . time() . " " . $ip . " " . $current_user;
}
if(is_array($ppl_not_online[0])){
if(isset($current_user_type) || is_array($ppl_online_now[0])){
$txt_output .= "\n";
}
foreach($ppl_not_online as $key => $firstdim){
$txt_output .= implode(" ", $ppl_not_online[$key]);
if(is_array($ppl_not_online[$key+1])){
$txt_output .= "\n";
}
}
}
$handle = fopen($ppl_online_file, 'w+');
fwrite($handle, $txt_output);
fclose($handle);
$html = str_replace("<name_of_person>", $current_user, $html);
$ppl_output .= $current_user;
if(is_array($ppl_online_now[0])){
if(isset($current_user)){
$ppl_output .= $separator;
}
foreach($ppl_online_now as $key => $value){
$ppl_output .= $ppl_online_now[$key][3];
if(is_array($ppl_online_now[$key+1])){
$ppl_output .= $separator;
}
}
}
$html = str_replace("<people_online>", $ppl_output, $html);
//THIS IS WHERE THE LOG IS STARTED
$logdata = array();
if(is_readable($page_directory . $log_file)){
$logdata = file($page_directory . $log_file);
}
$logdata = str_replace("\n", "", $logdata);
if((trim($HTTP_ENV_VARS['REQUEST_URI']) != '/')
{
array_unshift($logdata, date("F j,") . " " . $current_user);
}
if(count($logdata) >= 100){
$exclude = array_pop($logdata);
}
if(count($logdata) >= 100){
$exclude = array_pop($logdata);
}
unset($exclude);
$handle = fopen($page_directory . $log_file, 'w+');
fwrite($handle, implode("\n", $logdata));
fclose($handle);
//END OF LOG
$html = str_replace("<ppl_visited>", implode("<br />\n", $logdata), $html);
echo $html;
function displayfile($filename){
$handle = fopen($filename, 'r');
$filecontents = fread($handle, filesize($filename));
fclose($handle);
return $filecontents;
}
?>
-----------------------------------
Thanx...Last edited by Glenvern; 05-26-2006 at 05:47 AM.
Glenvern
-
05-26-2006, 08:32 AM #2
Re: PHP login script stopped working
Zend picked up an extra ( on line 139 (or thereabouts)
It's part of the following if statement.
Code:$logdata = str_replace("\n", "", $logdata); if((trim($HTTP_ENV_VARS['REQUEST_URI']) != '/'){ array_unshift($logdata, date("F j,") . " " . $current_user); }
Just as an advert - even though I'm not on commission- Zend was the best $200 I ever talked work into spending for me
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum