Jump to content

Common problem in common.php


eaglelegend

Recommended Posts

Hello guys, sorry I havent been online for a while!, I could really appreciate your help, since my database had messed up, and I want to create a filebased notifing system if you dont understand, allow me to explain, admin, or such, can log in to there filebased accounts, to notify the users that the site is down, in the way, you could say they can access this page to close the site, and put a reason why and date and time when the site will be back, as you will soon see in my code!.

 

The problem I am having is an old one, in terms, you probably get this ALOT!...

 

Parse error: syntax error, unexpected $end in common.php on line 119

 

This is in the common.php file, basically where everything processes, you all probably, and should know that anyway.

 

Thanks again, I could really appreciate your help.

 

<?php

session_start();

function registerUser($user,$pass1,$pass2){
$errorText = '';

// Check passwords
if ($pass1 != $pass2) $errorText = "Passwords are not identical!";
elseif (strlen($pass1) < 6) $errorText = "Password is to short!";

// Check user existance	
$pfile = fopen("userpwd.txt","a+");
    rewind($pfile);

    while (!feof($pfile)) {
        $line = fgets($pfile);
        $tmp = explode(':', $line);
        if ($tmp[0] == $user) {
            $errorText = "The selected user name is taken!";
            break;
        }
    }

    // If everything is OK -> store user data
    if ($errorText == ''){
	// Secure password string
	$userpass = md5($pass1);
    	
	fwrite($pfile, "\r\n$user:$userpass");
    }
    
    fclose($pfile);


return $errorText;
}

function loginUser($user,$pass){
$errorText = '';
$validUser = false;

// Check user existance	
$pfile = fopen("userpwd.txt","r");
    rewind($pfile);

    while (!feof($pfile)) {
        $line = fgets($pfile);
        $tmp = explode(':', $line);
        if ($tmp[0] == $user) {
            // User exists, check password
            if (trim($tmp[1]) == trim(md5($pass))){
            	$validUser= true;
            	$_SESSION['userName'] = $user;
            }
            break;
        }
    }
    fclose($pfile);

    if ($validUser != true) $errorText = "Invalid username or password!";
    
    if ($validUser == true) $_SESSION['validUser'] = true;
    else $_SESSION['validUser'] = false;

return $errorText;	
}

function logoutUser(){
unset($_SESSION['validUser']);
unset($_SESSION['userName']);
}

function checkUser(){
if ((!isset($_SESSION['validUser'])) || ($_SESSION['validUser'] != true)){
	header('Location: login.php');
}
}

function Maintain($reason,$month,$day,$year,$hour,$min,$sec){
$errorText = '';

// Check info existance	
$pfile = fopen("maintain.txt","a+");
    rewind($pfile);

    while (!feof($pfile)) {
        $line = fgets($pfile);
        $tmp = explode(':', $line);
        if ($tmp[0] == $reason) {
            $errorText = "There is an error with the reason!";
        if ($tmp[0] == $month) {
            $errorText = "There is an error with the month!";
        if ($tmp[0] == $day) {
            $errorText = "There is an error with the day!";
        if ($tmp[0] == $year) {
            $errorText = "There is an error with the year!";
        if ($tmp[0] == $hour) {
            $errorText = "There is an error with the hour!";
        if ($tmp[0] == $min) {
            $errorText = "There is an error with the minute!";
        if ($tmp[0] == $sec) {
            $errorText = "There is an error with the second!";    
            break;
        }
    }

    // If everything is OK -> store user data
    if ($errorText == ''){
    	
	fwrite($pfile, "\r\n$reason:$month:$day:$year:$hour:$min:$sec");
    }
    
    fclose($pfile);


return $errorText;

?>

Link to comment
https://forums.phpfreaks.com/topic/116868-common-problem-in-commonphp/
Share on other sites

You also didn't close 90% of the if statements in the last function starting with:

 

        if ($tmp[0] == $reason) {
           $errorText = "There is an error with the reason!";
       if ($tmp[0] == $month) {
           $errorText = "There is an error with the month!";
       if ($tmp[0] == $day) {
           $errorText = "There is an error with the day!";
       if ($tmp[0] == $year) {
           $errorText = "There is an error with the year!";
       if ($tmp[0] == $hour) {
           $errorText = "There is an error with the hour!";
       if ($tmp[0] == $min) {
           $errorText = "There is an error with the minute!";
       if ($tmp[0] == $sec) {
           $errorText = "There is an error with the second!";    
           break;
       }

 

You probably meant to do else if but didnt.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.