Checking user string"; flush(); if(empty($user) || empty($password)){ echo "FAILED\n"; return false; } echo "OK\n"; echo "
Adding ". $user; flush(); $creation = !is_file($usersFile); $fd = @ fopen($usersFile, "a+"); if($fd == false){ echo "FAILED
\n"; return false; } if($creation) fwrite($fd, "\n"); if($encrypt) $password = hash("sha512", $password); fwrite($fd, $user ."|". $password ."\n"); fclose($fd); echo "OK\n"; return true; } // show login screen, if needed if((!empty($_POST['username'])) && (!empty($_POST['password']))){ // load user if(!file_exists($usersFile)){ // create the first new user addUser($_POST['username'], $_POST['password']); } $users = @ file($usersFile, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES); if(is_array($users)){ array_shift($users); foreach($users as $user){ $tmp = explode("|", $user); if(count($tmp) == 2){ if(($_POST['username'] == $tmp[0]) && (hash("sha512", $_POST['password']) == $tmp[1])){ $_SESSION['Username'] = $_POST['username']; $_SESSION['loggedIn'] = 1; } } } } } $loggedIn = 0; $user = ""; if(array_key_exists("loggedIn", $_SESSION) && array_key_exists("Username", $_SESSION)){ $loggedIn = $_SESSION['loggedIn']; $user = $_SESSION['Username']; } $title = "ManuServer - Administration"; include("header.php"); echo "
\n"; if(($loggedIn != 1) || (empty($user))){ # if $usersFile contains no users, let the user create one if(!file_exists($usersFile)) echo "

Enter a username and a password to create the first user!

"; ?>
Username:
Password:
\n"; addUser($_POST['newUsername'], $_POST['newPassword']); echo "
\n"; } elseif($_POST['action'] == "storeGeneral"){ Settings::setValue("SUBMITUSER", $_POST["submitUser"]); Settings::setValue("SUBMITPASSWORD", $_POST["submitPassword"]); Settings::setValue("ADMINUSER", $_POST["adminUser"]); Settings::setValue("ADMINPASSWORD", $_POST["adminPassword"]); Settings::setValue("DBNAME", $_POST["dbName"]); $piwikId = intval($_POST['piwikId']); Settings::setValue("PIWIKID", $piwikId); $piwikURL = $_POST['piwikURL']; $piwikURL = preg_replace("/^(https?:\/\/)/", "", $piwikURL); $piwikURL = preg_replace("/(\/$)/", "", $piwikURL); Settings::setValue("PIWIKURL", $piwikURL); } elseif($_POST['action'] == "deleteUser"){ $delUsers = $_POST["delUsers"]; echo "
\n"; echo "
Checking selected users"; flush(); if(count($delUsers) == 0 || !is_array($delUsers)){ echo "FAILED
\n"; } else{ echo "OK
\n"; // first cleanup all echo "
Reading users list"; flush(); $users = @ file($usersFile, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES); array_shift($users); if(count($users) == 0){ echo "FAILED
\n"; } else{ // clean up old user list file echo "OK\n"; echo "
Cleanup old user list"; flush(); $fd = @ fopen($usersFile, "w+"); if($fd == false){ echo "FAILED
\n"; } else{ fwrite($fd, "\n"); echo "OK\n"; // add not deleted users to the emptied user list foreach($users as $user){ $tmp = explode("|", $user); if(count($tmp) != 2){ echo "FAILED\n"; } else{ $name = trim($tmp[0]); $password = trim($tmp[1]); if(empty($name) || empty($password)){ echo "FAILED\n"; } else{ if(!in_array($name, $delUsers)){ addUser($name, $password, false); } } } } } } } $userList = @ file($usersFile, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES); array_shift($userList); echo "\n"; } } # if any queued manufacturer are present, display the link $count = 0; $connId = @ mysql_connect("localhost", Settings::value("SUBMITUSER"), Settings::value("SUBMITPASSWORD")); if(!$connId){ echo "
\n"; echo "
Please specify the database submit user
\n"; echo "
\n"; } else{ if(!mysql_select_db(Settings::value("DBNAME"))){ echo "
\n"; echo "
Please specify the database
\n"; echo "
\n"; mysql_close($connId); } else{ $res = mysql_query("SELECT id FROM manufacturerhasmins_queue"); $count = mysql_num_rows($res); if($count < 1){ $res = mysql_query("SELECT id FROM mintypes_queue"); $count = mysql_num_rows($res); if($count < 1){ $res = mysql_query("SELECT id FROM manufacturers_queue"); $count = mysql_num_rows($res); } } mysql_close($connId); } } if($count > 0){ echo "
\n"; echo " Process ". $count ." queued items\n"; echo "
\n"; } ?>

Users

Username:
Password:
\n"; $i++; } } ?>
". $user ."

General Settings

Database
General
Database name: ">
Submit Database User:
(Should be able to SELECT all tables and to write only on _queue tables)
Username: ">
Password: ">
Admin Database User:
Username: ">
Password: ">
Piwik
Piwik URL: ">
Piwik Id: ">
\n"; include("footer.php"); ?>