public function addUser()
 {
     $username = I('post.username', 0);
     $password = I('post.password', 0);
     ($username === 0 || $password === 0) && $this->error("大哥别瞎搞!");
     $username = checkUsername($username);
     if (!$username) {
         $this->ajaxReturn("大哥别瞎注册!");
         exit;
     }
     $user = M('user');
     $queryResult = $user->where("username = '******'", $username)->find();
     if ($queryResult) {
         $this->ajaxReturn("user_exist");
         exit;
     }
     $data = array('id' => "", 'username' => $username, 'password' => pwEncrypt($username, $password), 'lasttime' => time(), 'lastip' => get_client_ip());
     $result = $user->add($data);
     if ($result) {
         $this->ajaxReturn("ok");
         exit;
     } else {
         $this->ajaxReturn("注册失败!");
         exit;
     }
 }
Esempio n. 2
0
function createUser($data)
{
    if ($obs = json_decode($data, true)) {
        $user = htmlentities(preg_replace("/[^a-zA-Z]*/", "", $obs['u']), ENT_QUOTES, "utf-8");
        $pw = htmlentities(preg_replace("/[^a-zA-Z]*/", "", $obs['p']), ENT_QUOTES, "utf-8");
        $cp = htmlentities(preg_replace("/[^a-zA-Z]*/", "", $obs['cp']), ENT_QUOTES, "utf-8");
        if (strlen($user) < 6 || strlen($pw) < 6 || strlen($user) > 20 || strlen($pw) > 20) {
            return -1;
        }
        if ($pw != $cp) {
            return -1;
        } elseif (checkUsername($user) > 0) {
            return -1;
        } else {
            $cPass = hashPass($pw);
            if (!storeNewUser($user, $cPass)) {
                return -1;
            } else {
                //account successfully created, so we will automatically log them in
                if (login(json_encode(array("n" => $user, "p" => $pw)), $_SERVER['REMOTE_ADDR']) == 1) {
                    return 1;
                } else {
                    return -1;
                }
            }
        }
    } else {
        return -1;
    }
}
Esempio n. 3
0
function verifyUserPass($username, $password, $redirect)
{
    $config = getConfig();
    if (checkUsername($username, $config->username) && checkPassword($password, $config->password)) {
        if (loadConfig($config)) {
            $_SESSION["loggedIn"] = true;
        }
        header("Location: " . $redirect);
    } else {
        return false;
    }
}
Esempio n. 4
0
function check()
{
    global $error;
    global $CONST;
    if (isset($_POST["usernamesignup"]) && isset($_POST["anweshasignup"]) && isset($_POST["passwordsignup"]) && isset($_POST['6_letters_code'])) {
    } else {
        $error["msg"] = 'Incomplete request';
        $error['component'] = 'username';
        return;
    }
    $user = $_POST["usernamesignup"];
    $anw = $_POST["anweshasignup"];
    $pass = $_POST["passwordsignup"];
    /**
     * validating captcha
     */
    if (empty($_SESSION['6_letters_code']) || $_SESSION['6_letters_code'] != $_POST['6_letters_code']) {
        $error["msg"] = "The captcha code does not match!";
        $error["component"] = "captcha";
        return;
    }
    /**
     * getting the status of login in anwesha website
     */
    $url = 'http://2016.anwesha.info/login/';
    $data = array('username' => $anw, 'password' => $pass);
    $data = http_build_query($data);
    $reply = do_post_request($url, $data);
    $res = (array) json_decode($reply);
    /**
     * getting the login status
     */
    if (!$res['status']) {
        $error["msg"] = "Authentication failed. You entered an incorrect Anwesha ID or password.";
        $error["component"] = "anwesha";
        return;
    }
    $hash = sha1($pass);
    if (!checkUsername($user)) {
        $error["msg"] = "Username already taken.";
        $error["component"] = "username";
        return;
    }
    if (!filter_var($user, FILTER_VALIDATE_REGEXP, array("options" => array('regexp' => '/^[\\w]{5,15}$/')))) {
        $error["msg"] = "Inappropriate username (5 to 15 alphanumeric characters needed)";
        $error["component"] = "username";
        return;
    }
    // var_dump($CONT);
}
Esempio n. 5
0
/**
 * procDeleteUser - If the submitted username is correct,
 * the user is deleted from the database.
 */
function procDeleteUser()
{
    global $session, $database, $form;
    /* Username error checking */
    $subuser = checkUsername("deluser");
    $database->REGISTRAR("USUARIO_ELIMINAR", "Se eliminó un usuario.", "Usuario afectado: {$subuser}");
    /* Errors exist, have user correct them */
    if ($form->num_errors > 0) {
        $_SESSION['value_array'] = $_POST;
        $_SESSION['error_array'] = $form->getErrorArray();
        header("Location: ../?accion=gestionar+clientes");
    } else {
        $q = "DELETE FROM " . TBL_USERS . " WHERE codigo = '{$subuser}'";
        $database->query($q);
        header("Location: ../?accion=gestionar+clientes");
    }
}
Esempio n. 6
0
if (!$passwordError && isset($_POST['newPass']) && !empty($_POST['newPass'])) {
    try {
        $stmt = $db->prepare("update `users` set password=:password where id=:id");
        $stmt->bindParam(":password", hash("sha512", $_POST['newPass']));
        $stmt->bindParam(":id", $_SESSION['user_id']);
        $stmt->execute();
        $passwordChanged = 1;
    } catch (PDOException $e) {
        $passwordError = -1;
    }
}
// Basic data check
$phoneError = $addressError = $emailError = $dateError = $usernameError = 0;
$phoneChanged = $addressChanged = $emailChanged = $dateChanged = $usernameChanged = 0;
if (isset($_POST['username']) && !empty($_POST['username']) && addslashes($_POST['username']) != $_SESSION['username']) {
    $usernameError = checkUsername($_POST['username']);
    if ($usernameError == 0) {
        try {
            $stmt = $db->prepare("select * from `users` where username=:username");
            $stmt->bindParam(":username", addslashes($_POST['username']));
            $stmt->execute();
            if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                $usernameError = 3;
            }
        } catch (PDOException $e) {
            echo "Database error";
        }
    }
    $basicChanged = 1;
    $usernameChanged = 1;
}
Esempio n. 7
0
    if (password_verify($password, $password_hashed)) {
        echo "You logged in with user: "******" that has the ID: " . $row['userID'];
    } else {
        echo 'Invalid password.';
    }
} else {
    if ($form_page == 'register') {
        //die("Function isn't added yet");
        $username = $_POST['username'];
        $password = $_POST['password'];
        $password2 = $_POST['password2'];
        $email = $_POST['email'];
        register($username, $password, $email);
    } else {
        if ($form_page == 'usernameCheck') {
            //die("Function isn't added yet");
            $username = $_POST['username'];
            $array = checkUsername($username);
            echo json_encode($array);
        } else {
            if ($form_page == 'emailCheck') {
                //die("Function isn't added yet");
                $email = $_POST['email'];
                $array = checkEmail($email);
                echo json_encode($array);
            } else {
                die('Something went wrong');
            }
        }
    }
}
Esempio n. 8
0
         if (!$fileError && !$nameError) {
             if (!file_exists($filepath)) {
                 if (!is_uploaded_file($_FILES['fileChoose']['tmp_name']) || !copy($_FILES['fileChoose']['tmp_name'], $filepath)) {
                     $fileError = 2;
                 } else {
                     chmod($filepath, 776);
                 }
             } else {
                 $fileError = 4;
             }
         }
     }
 } else {
     if (isset($_POST['name']) && !empty($_POST['name'])) {
         $name = trim($_POST['name']);
         $nameError = checkUsername($name);
         if (!$nameError) {
             if (isset($_SESSION['location']) && !empty($_SESSION['location'])) {
                 $filepath = $_SESSION['location'] . '/' . $name . '.txt';
             } else {
                 $filepath = "data/" . $_SESSION['user_id'] . "/home/" . $name . ".txt";
             }
             if (!file_exists($filepath)) {
                 $file = fopen($filepath, "w");
                 if ($file) {
                     fclose($file);
                 } else {
                     $fileError = 2;
                 }
             } else {
                 $fileError = 4;
Esempio n. 9
0
        header('Location: registration.php?error=5');
    }
    // verify password meets complexity -- complexity = min. 12 characters, etc
    if (strlen($password1) < 12) {
        header('Location: registration.php?error=4');
    }
    $hasUpperCase = preg_match("/[A-Z]/", $password1);
    $hasLowerCase = preg_match("/[a-z]/", $password1);
    $hasNumbers = preg_match("/[0-9]/", $password1);
    $hasNonalphas = preg_match("/[!#\$%&\\?_ ]/", $password1);
    if ($hasUpperCase + $hasLowerCase + $hasNumbers + $hasNonalphas < 3) {
        $_SESSION['error'] = true;
        header('Location: registration.php?error=4');
    }
    return 1;
}
// end functions
// Validation:
$validationResult = checkToken($sToken, $_SESSION['token']) + checkUsername($username, $conn) + checkEmail($email, $vemail, $conn) + checkPasswd($password1, $password2);
// This is being called when it should not be called when the email validation fails
// Behavior:
//		When email fails to validate, the INSERT SQL statement is still running and creating a new entry in the user table
if ($validationResult == 4) {
    $salt = createSalt();
    $password = hash('sha256', $salt . $hash);
    $username = mysqli_real_escape_string($conn, $username);
    $query = "INSERT INTO member ( username, password, email, salt)\n\t        VALUES ( '{$username}', '{$password}', '{$email}', '{$salt}');";
    $result = mysqli_query($conn, $query);
    // echo  "query sucess <br>";
    // Redirect to page thanking the user for registering
}
 *
 * You should have received a copy of the GNU General Public License
 * along with Loquacity; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
include_once "../config.php";
include_once 'charsets.php';
include_once 'taglines.php';
require_once "validation/passwordManager.class.php";
$myPasswdMgr =& new passwordManager($loq->_adb);
$loq->template_dir = LOQ_APP_ROOT . 'includes/admin_templates';
$loq->assign('sidemsg', 'Loquacity Password Recovery');
$_SESSION['username'] = $_POST['username'];
$_SESSION['answer'] = $_POST['answer'];
// if a username in the post is entered, and that username exists in the database,
if (isset($_SESSION['username']) && $_SESSION['username'] == checkUsername($_SESSION['username'])) {
    // get the secret question for the user
    $secQuestion = $myPasswdMgr->getQuestion($_SESSION['username']);
    $loq->assign('question', $secQuestion);
    $_SESSION['answer'] = $_POST['answer'];
    $template = 'askquestion.html';
    // Now check if we have an answer or not, and compare them.
    // psudo: if (checkAnswers(pw1,pw2)  where pw1 = getAnswer(username)
    if ($myPasswdMgr->checkAnswers($myPasswdMgr->getAnswer($_SESSION['username']), $_SESSION['answer'])) {
        // success! reset password and send the email.
        setPassword($_SESSION['username'], $_SESSION['answer']);
        sendEmail($user, $email, $passwd);
        $template = 'status.html';
    } else {
        $loq->assign('title', 'Please answer your question');
        $template = 'askquestion.html';
Esempio n. 11
0
        error("Fields must not be empty!");
    }
}
function checkUsername($username)
{
    $len = strlen($username);
    for ($i = 0; $i < $len; $i++) {
        if ($username[$i] < 'a' || $username[$i] > 'z') {
            error("Only english letters allowed");
        }
    }
}
assertPost("tid");
assertPost("password");
$id = strtolower($_POST["tid"]);
checkUsername($id);
$password = $_POST["password"];
$cid = $contest["cid"];
$sql = "SELECT * FROM team WHERE cid='{$cid}' AND id='{$id}'";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) {
    error("User name already exists");
}
$sql = "INSERT team (id, password, cid, date) VALUES ('{$id}', '{$password}', '{$cid}', Now())";
$result = mysql_query($sql);
$tid = mysql_insert_id();
$_SESSION["tid"] = $tid;
print "team id is {$tid} <br />";
$sql = "INSERT contestant (tid) VALUES ('{$tid}')";
for ($i = 0; $i < 3; $i++) {
    mysql_query($sql);
Esempio n. 12
0
require_once 'php/recaptchalib.php';
require_once 'php/email.php';
if ($loggedin) {
    header('Location: summary.php');
    exit;
}
$errors = array();
$name = $email = "";
if (isset($_POST['name']) || isset($_POST['email']) || isset($_POST['p']) || isset($_POST['pLength'])) {
    if (!isset($_POST['name']) || !sanityCheck($_POST['name'], 'string', 3, 25)) {
        $errors[] = $tr["ERR_USERNAME_LENGTH"];
    } else {
        if (SQL("SELECT 1 FROM accounts WHERE username = ?;", $_POST['name']) != null) {
            $errors[] = $tr["ERR_USERNAME_EXITS"];
        } else {
            if (!checkUsername($_POST['name'])) {
                $errors[] = $tr["ERR_USERNAME_FORMAT"];
            } else {
                $name = xssafe($_POST['name']);
            }
        }
    }
    if (!isset($_POST['email']) || !sanityCheck($_POST['email'], 'string', 7, 50) || !checkEmail($_POST['email'])) {
        $errors[] = $tr["ERR_EMAIL"];
    } else {
        $email = $_POST['email'];
    }
    if (!isset($_POST['pLength']) || !sanityCheck($_POST['pLength'], 'numeric', 0, 3)) {
        $errors[] = $tr["ERR_PASSWORD_LENGTH"];
    } else {
        $pLength = intval($_POST['pLength']);
Esempio n. 13
0
<?php

include 'db.php';
include 'functions.php';
?>

<?php 
if (trim($_POST['username']) != "" && trim($_POST['email']) != "" && trim($_POST['password']) != "") {
    if (checkUsername($_POST['username'])) {
        ?>
		<?php 
        include 'webTop.php';
        ?>
		<?php 
        echo "Error: el nombre de usuario ya est&aacute; en uso.";
        ?>
		<?php 
        include 'webBottom.php';
        ?>
		<?php 
    } else {
        if (checkEmail($_POST['email'])) {
            ?>
			<?php 
            include 'webTop.php';
            ?>
			<?php 
            echo "Error: el email ya est&aacute; en uso.";
            ?>
			<?php 
            include 'webBottom.php';
Esempio n. 14
0
<?php

require_once '../../config.php';
//Verify if admin is logged in
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : "";
switch ($action) {
    case 'checkUsername':
        checkUsername($_REQUEST['strUsername'], $con);
        break;
    default:
        break;
}
function checkUsername($strUsername, $con)
{
    //Query to check if username already exist
    $strSql = "select vchr_username from tbl_student where vchr_username='******'";
    $rstResult = mysqli_query($con, $strSql);
    if (mysqli_num_rows($rstResult) == 1) {
        //Set error messege to give a javascript alert as username already exist
        $strResult = "Username already exist! Please change the username";
    } else {
        $strResult = "";
    }
    echo $strResult;
}
<?php

include "ShopAnytimeMVC.php";
if (isset($_GET['username'])) {
    $user = checkUsername($_GET['username']);
    if (count($user) < 1) {
        print "valid";
    } else {
        print "invalid";
    }
}
if ($_POST) {
    $fname = $_POST['firstnameRegister'];
    $lname = $_POST['lastnameRegister'];
    $add = $_POST['addressRegister'];
    $uname = $_POST['usernameRegister'];
    $pwd = $_POST['passwordRegister'];
    createAccount($fname, $lname, $add, $uname, $pwd);
    header("Location: /eio/Assignment6/ShopAnytimeHome.php?Register='success'");
    exit;
}
?>

Esempio n. 16
0
#
#####################################################################
include 'includes/backend/mysqli_connect.php';
include 'includes/functions.php';
include '/includes/PHPMailer/send_mail.php';
if (isset($_POST)) {
    $firstname = mysqli_real_escape_string($dbc, $_POST['firstname']);
    $lastname = mysqli_real_escape_string($dbc, $_POST['lastname']);
    $username = mysqli_real_escape_string($dbc, $_POST['username']);
    $email = mysqli_real_escape_string($dbc, $_POST['email']);
    $password = mysqli_real_escape_string($dbc, $_POST['password']);
    $gender = $_POST['gender'];
    $datepost = $_POST['dateofbirth'];
    $date = DateTime::createFromFormat('d-m-Y', $datepost);
    $dateofbirth = $date->format('Y-m-d H:i:s');
    $checkuser = checkUsername($username);
    $checkemail = checkEmail($email);
    if (mysqli_num_rows($checkuser) > 0) {
        echo json_encode(['status' => 'USER']);
    } else {
        if (mysqli_num_rows($checkemail) > 0) {
            echo json_encode(['status' => 'EMAIL']);
        } else {
            $rs = register($username, $password, $email, $firstname, $lastname, $dateofbirth, $gender);
            if (mysqli_affected_rows($dbc) == 1) {
                $expired_date = date("Y-m-d H:i:s", time() + 259200);
                $token = sha1(uniqid(rand(), true));
                // get user_id
                $result = checkUsernameAndEmail($username, $email);
                $user = mysqli_fetch_array($result, MYSQLI_ASSOC);
                $user_id = $user['user_id'];
<?php

include '../included-files/connect-database.php';
$post_username = '******';
$post_email = 'email';
$required_message = 'Required';
if (isset($_POST[$post_username])) {
    $username = mysqli_real_escape_string($connection, $_POST[$post_username]);
    checkUsername($connection, $username);
}
if (isset($_POST[$post_email])) {
    $email = mysqli_real_escape_string($connection, $_POST[$post_email]);
    checkEmail($connection, $email);
}
function checkUsername($connection, $username)
{
    $student_table = STUDENT_TABLE_NAME;
    $student_username = STUDENT_USERNAME;
    $query = " SELECT {$student_username} ";
    $query .= " FROM {$student_table} ";
    $query .= " WHERE {$student_username} = '{$username}';";
    $result = mysqli_query($connection, $query);
    $num_rows = mysqli_num_rows($result);
    if ($num_rows < 1) {
        echo 'Available';
    } else {
        echo 'Taken';
    }
}
function checkEmail($connection, $email)
{
Esempio n. 18
0
<?php

session_start();
echo "Username: "******"<br>";
echo "Password: "******"<br>";
echo "Gebruiker ingelogd: " . returnIngelogd($_COOKIE['gebruikerIngelogd']) . "<br>";
echo "Administrator: " . checkAdministrator($_SESSION['admin']) . "<br>";
echo "<h4>" . hasRights($_COOKIE['gebruikerIngelogd'], $_SESSION['admin']) . "</h4>";
function checkUsername($gebruikerIngelogd, $username)
{
    if (returnIngelogd($gebruikerIngelogd) == "Ja") {
        return $username;
    } else {
        return "gast";
    }
}
function checkPassword($gebruikerIngelogd, $password)
{
    if (returnIngelogd($gebruikerIngelogd) == "Ja") {
        return $password;
    } else {
        return "geen wachtwoord";
    }
}
function returnIngelogd($gebruikerIngelogd)
{
    if ($gebruikerIngelogd != "") {
        return "Ja";
    } else {
        return "Nee";
    }
Esempio n. 19
0
<?php

include ("phpFunctions.php");
//session_start();
$thename = $_POST['newusername'];
$thepass = $_POST['newpassword'];
$confpass = $_POST['confpassword'];
$userPasswordExist = checkUsernameAndPassword($thename, $thepass);
$usernameUsed = checkUsername($thename);

if($userPasswordExist != 0)
{
	//$errorMessage = "1";
	//$errorMessage = 'Existing user? . Please go to the login page';
	header('Location:/~mohit/Blog_App/index.php');
}
else if($usernameUsed != 0)
{
	//$errorMessage = "2";
	//$erorMessage = 'Please choose another user id. This userid is already used.';
	redirect('signup.php');
}
else if($thepass !== $confpass)
{
	redirect('signup.php');
}
else 
{
	createNewUser($_POST['newusername'], $_POST['newpassword']);
	$userRegistered = checkUsernameAndPassword($thename, $thepass);
	if($userRegistered == 0)
Esempio n. 20
0
     die("Password must be 72 characters or less.");
 }
 $password = $hasher->HashPassword($password);
 //Minimum hash length is 20 characters. If less, something's broken.
 if (strlen($password) >= 20) {
     //Hashing has worked.
     //Add the entry and go to the login page.
     $sql = "INSERT INTO Users (name, password, email) VALUES ('{$username}', '{$password}', '{$email}')";
     $query = mysqli_query($conn, $sql);
     if (!$query) {
         echo $conn->error;
     } else {
         header("location: {$host}");
     }
 } else {
     if (checkUsername($username)) {
         //Username exists
         $output .= "<p>That username is already in use.</p>";
         echo $output;
     } else {
         if (checkEmail($email)) {
             //User has account
             $output .= "<p>That email is already in use.</p>";
             echo $output;
         } else {
             if (strlen($password) < 20) {
                 //Password too short
                 $output .= "<p>Something went wrong.</p>";
                 echo $output;
             }
         }
Esempio n. 21
0
 To read the license please visit http://www.gnu.org/copyleft/gpl.html

*******************************************************************************/
// prevent direct invocation
if (!isset($cfg['user']) || isset($_REQUEST['cfg'])) {
    @ob_end_clean();
    @header("location: ../../../index.php");
    exit;
}
/******************************************************************************/
$newUser = tfb_getRequestVar('newUser');
$pass1 = tfb_getRequestVar('pass1');
$pass2 = tfb_getRequestVar('pass2');
$userType = tfb_getRequestVar('userType');
// check username
$usernameCheck = checkUsername($newUser);
// check password
$passwordCheck = checkPassword($pass1, $pass2);
// new user ?
$newUser = strtolower($newUser);
if ($usernameCheck === true && $passwordCheck === true) {
    addNewUser($newUser, $pass1, $userType);
    AuditAction($cfg["constants"]["admin"], $cfg['_NEWUSER'] . ": " . $newUser);
    @header("location: admin.php?op=showUsers");
    exit;
}
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.admin.addUser.tmpl");
// set vars
$tmpl->setvar('newUser', $newUser);
// error
        }
        $nameIdArr = explode(",", $nameIds);
        $dbConnect->setProfileInstallation($userId, $nameIdArr);
        die("Saved!");
        break;
    case 26:
        //set profile activation
        if (!isset($_POST['names']) || !isset($_GET['uname']) || !isset($_GET['pw']) || !isset($_GET['modId'])) {
            die("Missing parameter!");
            break;
        }
        $username = $_GET['uname'];
        $pw = $_GET['pw'];
        $names = $_POST['names'];
        $modId = $_GET['modId'];
        $userId = checkUsername($username, $pw);
        if ($userId < 0) {
            die("Rejected!");
        }
        $namesArr = explode(",", $names);
        $dbConnect->setProfileActivation($userId, $modId, $namesArr);
        die("Saved!");
        break;
    default:
        die("Unknown mode!");
        break;
}
$xml = $xmlDoc->getXml();
echo $xml;
/*
function my_dir($dir){
Esempio n. 23
0
 $username = $conn->real_escape_string($username);
 $password = $conn->real_escape_string($password);
 if (strlen($password) > 72) {
     die("Password must be 72 characters or less.");
 }
 $password = $hasher->HashPassword($password);
 //Minimum hash length is 20 characters. If less, something's broken.
 if (strlen($password) >= 20 && !checkUsername($username, $conn)) {
     //TODO - Also check the email address isn't used.
     //Hashing has worked and there's no existing user by that name.
     //Add the entry and go to the login page.
     $sql = "INSERT INTO Users (username, password, email) VALUES ('{$username}', '{$password}', {$email})";
     $conn->query($sql);
     header("location:form.php");
 } else {
     if (checkUsername($username, $conn)) {
         //Username exists
         echo "That username is already in use.";
     } else {
         if (checkEmail($email, $conn)) {
             //Username exists
             echo "That email is already in use.";
         } else {
             if (strlen($password) < 20) {
                 //Password too short
                 echo "Something went wrong.";
             }
         }
     }
 }
 $conn->close();
    echo "Welcome " . $_SESSION['firstName'] . " " . $_SESSION['lastName'] . "<br/>";
} else {
    include "login.php";
}
if (isset($_SESSION['userName'])) {
    include "navigationLoggedIn.html";
} else {
    include "navigation.html";
}
?>
		</nav>

		<section>
		<?php 
$con = connectToDB();
checkUsername($con, "register", $_POST['firstName'], $_POST['lastName'], $_POST['userName'], $_POST['password'], $_POST['usertype']);
?>
		</section>
	</BODY>
	
	<footer>
		<?php 
if (isset($_SESSION['userName'])) {
    include "navigationLoggedIn.html";
} else {
    include "navigation.html";
}
?>
	</footer>
</HTML>
Esempio n. 25
0
		<title>Caller Records</title>
<link rel="stylesheet" href="css/sort.css" />
<link rel="stylesheet" href="css/mediaboxAdvBlack.css" type="text/css" media="screen"/> 
<script type="text/javascript" src="js/mootools.1.2.4.js"></script>
<script type="text/javascript" src="js/mediaboxAdv-1.2.0.js"></script>
<script type="text/javascript" src="js/instantEdit.js"></script>
</head>
		<body>
		<script>
			var cookieUsername = Cookie.read("VoxeoSBCusername");
			var cookiePassword = Cookie.read("VoxeoSBCpassword");
		</script>	
		<?

			if (isset($_COOKIE['VoxeoSBCusername']) && isset($_COOKIE['VoxeoSBCpassword'])) {			
				if(!(checkUsername($_COOKIE['VoxeoSBCusername'])) || !(checkPasswordSha1($_COOKIE['VoxeoSBCpassword']))){
					//echo('<script>redirectHome("Invalid Password");</script>');		
					redirectHome("Invalid Password");
			    } else {
				}
				?>
			<table cellpadding="1" cellspacing="10" border="0" id="header">
				<tr>
				<td>	
					<img src="images/logo.png" height="35px"/>
					</td>
					<td>
					<font size="3">Application Firewall</font>
					</td>
				</tr>
			</table>
Esempio n. 26
0
 function presave($key, $val)
 {
     if (!isset($this->presaved)) {
         $this->presaved = array();
     }
     //TODO: check duplicate for: logn + email
     //TODO: van, amit ne engedjen, csak, amikor még tök új a cuccos.
     //TODO: törölhető oszlop: ismerosok, baratok, regip, lastip, log, adminmegj,atvett
     //TODO: a nickname - becenev / name - nev esetén ez nem segít, bár nem sok dupla munka azért
     //TODO: elrontja ...
     //if($this->$key == $val) return true;
     //TODO: szóljon vissza a kötelező
     if ($val == '' and in_array($key, array('username', 'login', 'email'))) {
         return false;
     }
     if ($key == 'uid') {
         if ($this->uid != $val) {
             return false;
         }
     } elseif (in_array($key, array('username', 'login'))) {
         if ($this->uid == 0) {
             if (!checkUsername($val)) {
                 return false;
             }
             $this->presaved['login'] = sanitize($val);
         } elseif ($this->username != $val) {
             return false;
         }
     } elseif (in_array($key, array('jelszo', 'password'))) {
         $this->presaved['jelszo'] = password_hash($val, PASSWORD_BCRYPT);
     } elseif ($key == 'roles' or $key == 'jogok') {
         if (!is_array($val)) {
             $val = array($val);
         }
         foreach ($val as $k => $i) {
             $val['jogok'] = trim(sanitize($i), "-");
         }
         $val = array_unique($val);
         $this->presaved['jogok'] = implode('-', $val);
     } elseif ($key == 'nickname' or $key == 'becenev') {
         $this->presaved['becenev'] = sanitize($val);
     } elseif ($key == 'name' or $key == 'nev') {
         $this->presaved['nev'] = sanitize($val);
     } elseif ($key == 'ok') {
         $con = array(1 => 'i', 0 => 'n');
         if ($val == '') {
             $this->presaved[$key] = 'n';
         } elseif (in_array($val, array('i', 'n'))) {
             $this->presaved[$key] = $val;
         } elseif (in_array($val, array(1, 0))) {
             $this->presaved[$key] = $con[$val];
         } else {
             return false;
         }
     } elseif ($key == 'volunteer') {
         if ($val == '') {
             $this->presaved[$key] = 0;
         } elseif (in_array($val, array(0, 1))) {
             $this->presaved[$key] = $val;
         } else {
             return false;
         }
     } elseif (in_array($key, array('letrehozta'))) {
         //TODO: túlzás lenne megnézni, hogy valódi name-e? (bár ha törölt... user...)
         $this->presaved[$key] = sanitize($val);
     } elseif (in_array($key, array('regdatum', 'lastlogin', 'lastactive'))) {
         if (is_numeric($val)) {
             $this->presaved[$key] = date('Y-m-d H:i:s', $val);
         } elseif (strtotime($val)) {
             $this->presaved[$key] = date('Y-m-d H:i:s', strtotime($val));
         } else {
             return false;
         }
     } elseif ($key == 'email') {
         if (!filter_var($val, FILTER_VALIDATE_EMAIL)) {
             return false;
         }
         if ($this->isEmailInUse($val)) {
             return false;
         }
         $this->presaved[$key] = $val;
     } else {
         return false;
     }
     return true;
 }
<?php

require_once '../../connectDB.php';
if (isset($_POST['username'])) {
    echo json_encode(checkUsername($_POST['username']));
}
function checkUsername($username)
{
    $search = "SELECT * FROM user WHERE username LIKE '{$username}'";
    $hasilquery = mysql_query($search);
    $result = mysql_fetch_assoc($hasilquery);
    if ($result != null) {
        //kalau ada yang sama
        $code = 400;
    } else {
        // kalau ga ada yang sama
        $code = 200;
    }
    return array("code" => $code);
}
if (isset($_SESSION['userName'])) {
    echo "Welcome " . $_SESSION['firstName'] . " " . $_SESSION['lastName'] . "<br/>";
} else {
}
if (isset($_SESSION['userName'])) {
    include "navigationLoggedIn.html";
} else {
    include "navigation.html";
}
?>
		</nav>

		<section>
		<?php 
$con = connectToDB();
checkUsername($con, "login");
?>
		</section>
	</BODY>
	
	<footer>
		<?php 
if (isset($_SESSION['userName'])) {
    include "navigationLoggedIn.html";
} else {
    include "navigation.html";
}
?>
	</footer>
</HTML>
Esempio n. 29
0
     exec($cmd, $o, $rc);
     $cmd = 'brctl show | grep vnet | sed \'s/^\\(vnet[0-9]\\+_[0-9]\\+\\).*/\\1/g\' | while read line; do ifconfig $line down; brctl delbr $line; done';
     exec($cmd, $o, $rc);
     $cmd = 'ovs-vsctl list-br | while read line; do ovs-vsctl del-br $line; done';
     exec($cmd, $o, $rc);
     $cmd = 'ifconfig | grep vunl | cut -d\' \' -f1 | while read line; do tunctl -d $line; done';
     exec($cmd, $o, $rc);
     break;
 case 'platform':
     $cmd = '/usr/sbin/dmidecode -s system-product-name';
     exec($cmd, $o, $rc);
     print implode('', $o) . "\n";
     break;
 case 'start':
     // Starting node(s)
     if (!checkUsername($lab->getTenant())) {
         // Cannot create username
         error_log(date('M d H:i:s ') . date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][14]);
         exit(14);
     }
     if (isset($node_id)) {
         // Node ID is set, create attached networks, prepare node and start it
         foreach ($lab->getNodes()[$node_id]->getEthernets() as $interface) {
             if ($interface->getNetworkId() !== 0 && !isset($lab->getNetworks()[$interface->getNetworkId()])) {
                 // Interface is set but network does not exist
                 error_log(date('M d H:i:s ') . date('M d H:i:s ') . 'ERROR: ' . $GLOBALS['messages'][10]);
                 exit(10);
             } else {
                 if ($interface->getNetworkId() !== 0) {
                     // Create attached networks only
                     $p = array('name' => 'vnet' . $lab->getTenant() . '_' . $interface->getNetworkId(), 'type' => $lab->getNetworks()[$interface->getNetworkId()]->getNType());
Esempio n. 30
0
function register()
{
    $username = isset($_POST['catcracker_regusername']) ? $_POST['catcracker_regusername'] : "";
    $password = isset($_POST['catcracker_regpassword']) ? $_POST['catcracker_regpassword'] : "";
    $passwordrep = isset($_POST['catcracker_regpasswordrep']) ? $_POST['catcracker_regpasswordrep'] : "";
    if ($username == "") {
        addError("username_missing", "register.username.missing");
    }
    if ($password == "") {
        addError("password_missing", "register.password.missing");
    }
    if ($passwordrep == "") {
        addError("rep_password_missing", "register.repeatpassword.missing");
    }
    if (strcmp($password, $passwordrep) != 0) {
        addError("password_match_error", "register.password.matcherror");
    }
    if (getErrorCount() == 1) {
        if (checkUsername(array($username))) {
            addError("reg_username_exists", "register.username.exists");
        }
    }
    if (getErrorCount() > 1) {
        outputJSON("error");
    } else {
        $valid = false;
        $userid = 0;
        try {
            $userid = addUser(array($username, md5($password)));
            $valid = true;
        } catch (Exception $e) {
            addError("registration_invalid", $e->getMessage(), false);
        }
        if ($valid) {
            $_SESSION['username'] = $username;
            addMessage("message", "registration.sucessful");
            addMessage("username", $username, false);
            addMessage("userid", $userid, false);
            outputJSON("success");
        } else {
            outputJSON("error");
        }
    }
}