function change_pass($username) { global $LDAPHOST, $LDAPPORT, $ldap, $LDAPADMIN, $LDAPADMINPASS, $LDAPDATAFIELD, $LDAPLOCALDOMAIN, $LDAPDOMAIN; if ($ldap) { $bind = @ldap_bind($ldap, $LDAPADMIN . "@" . $LDAPLOCALDOMAIN, $LDAPADMINPASS); if (!$bind) { @ldap_close($ldap); die('<p class="message">Your password is incorrect, please try again <a href=javascript:history.back()>click here</a><br>'); } $filter = "(sAMAccountName={$username})"; $results = ldap_search($ldap, $LDAPDOMAIN, $filter); ldap_sort($ldap, $results, "sn"); $info = ldap_get_entries($ldap, $results); if ($info['count'] < 1) { @ldap_close($ldap); die('<p class="message">Error occurred, please verify your user , <a href="javascript:history.back()">Go Back</a>'); } $dn = $info[0]["dn"]; $stored_mail = $info[0][$LDAPDATAFIELD][0] or die('<p class="message">We could not get your info, please contact Support!'); $newPassw = genPassword("xxx0yY0yY"); $mailPass = $newPassw; $newPassword = "******"{$newPassw}\""; $len = strlen($newPassword); $newPass = ""; for ($i = 0; $i < $len; $i++) { $newPass .= "{$newPassword[$i]}"; } $newPassword = $newPass; $data_new["unicodePwd"][] = $newPassword; if (ldap_mod_replace($ldap, $dn, $data_new)) { return array(true, $stored_mail, $mailPass); } else { return array(false, 100, 100); } return array(true, $stored_mail, $mailPass); } else { return array(false, 0, 0); } // function }
switch (getVar('action')) { case 'signup': if (getVar('email')) { $addUser = $dbh->prepare("INSERT INTO users (username, password, email, firstname, lastname, address, postalcode, city, phone) VALUES (:username, :password, :email, :firstname, :lastname, :address, :postalcode, :city, :phone)"); $addUser->execute(array(':username' => getVar('username'), ':password' => passwordHash(getVar('password')), ':email' => getVar('email'), ':firstname' => getVar('firstname'), ':lastname' => getVar('lastname'), ':address' => getVar('address'), ':postalcode' => getVar('postalcode'), ':city' => getVar('city'), ':phone' => getVar('phone'))); renderHome('accountCreated', true); } else { render('user-signup'); } break; case 'reset': if (getVar('email')) { $userQuery = $dbh->prepare("SELECT id FROM users WHERE email = :email"); $userQuery->execute(array(':email' => getVar('email'))); if ($userQuery->rowCount()) { $newPass = genPassword(); mail(getVar('email'), 'Your new password on ' . getConfigKey('title'), 'Your new password is ' . $newPass); $resetQuery = $dbh->prepare("UPDATE users SET password = :password WHERE email = :email LIMIT 1"); $resetQuery->execute(array(':password' => passwordHash($newPass), ':email' => getVar('email'))); render('user-reset', array()); } else { render('error', array('error' => 'No account was found.')); } } else { render('user-reset'); } break; case 'login': $loginQuery = $dbh->prepare("SELECT id, firstname, lastname, username, email, address, city, postalcode, phone FROM users WHERE username = :username AND password = :password"); $loginQuery->execute(array(':username' => getVar('username'), ':password' => passwordHash(getVar('password')))); $user = $loginQuery->fetchAll()[0];
/** * Generate a random string, and create a CAPTCHA image out of it */ function create_image() { // generate pronouncable pass $pass = genPassword(5, 6); $font = './captcha.ttf'; $maxsize = 50; $sizeVar = 25; $rotate = 20; $bgcol = 50; // + 50 $bgtextcol = 80; // + 50 $textcol = 205; // + 50 // remember the pass $_SESSION["captcha"] = $pass; // calculate dimentions required for pass $box = @imageTTFBbox($maxsize, 0, $font, $pass); $minwidth = abs($box[4] - $box[0]); $minheight = abs($box[5] - $box[1]); // allow spacing for rotating letters $width = $minwidth + 100; $height = $minheight + rand(5, 15); // give some air for the letters to breathe // create initial image $image = ImageCreatetruecolor($width, $height); if (function_exists('imageantialias')) { imageantialias($image, true); } // define background color - never the same, close to black $clr_black = ImageColorAllocate($image, rand($bgcol, $bgcol + 30), rand($bgcol, $bgcol + 30), rand($bgcol, $bgcol + 30)); imagefill($image, 0, 0, $clr_black); // calculate starting positions for letters $x = rand(10, 25); //($width / 2) - ($minwidth / 2); $xinit = $x; $y = $minheight - abs($box[1]) + ($height - $minheight) / 2; // fill the background with big letters, colored a bit lightly, to vary the bg. $bgx = $x / 2; $size = rand($maxsize - 10, $maxsize); for ($i = 0; $i < strlen($pass); $i++) { // modify color a bit $clr_white = ImageColorAllocate($image, rand($bgtextcol, $bgtextcol + 50), rand($bgtextcol, $bgtextcol + 50), rand($bgtextcol, $bgtextcol + 50)); $angle = rand(0 - $rotate, $rotate); $letter = substr($pass, $i, 1); imagettftext($image, $size * 2, $angle, $bgx, $y, $clr_white, $font, $letter); list($x1, $a, $a, $a, $x2) = @imageTTFBbox($size, $angle, $font, $letter); $bgx += abs($x2 - $x1); } // for each letter, decide a color, decide a rotation, put it on the image, // and figure out width to place next letter correctly for ($i = 0; $i < strlen($pass); $i++) { // modify color a bit $clr_white = ImageColorAllocate($image, rand($textcol, $textcol + 50), rand($textcol, $textcol + 50), rand($textcol, $textcol + 50)); $angle = rand(0 - $rotate, $rotate); $letter = substr($pass, $i, 1); $size = rand($maxsize - $sizeVar, $maxsize); $tempbox = @imageTTFBbox($size, $angle, $font, $letter); $y = abs($tempbox[5] - $tempbox[1]) + ($height - abs($tempbox[5] - $tempbox[1])) / 2; imagettftext($image, $size, $angle, $x, $y, $clr_white, $font, $letter); $x += abs($tempbox[4] - $tempbox[0]); } // figure out final width (same space at the end as there was at the beginning) $width = $xinit + $x; // throw in some lines $clr_white = ImageColorAllocate($image, rand(160, 200), rand(160, 200), rand(160, 200)); imagelinethick($image, rand(0, 10), rand(0, $height / 2), rand($width - 10, $width), rand($height / 2, $height), $clr_white, rand(1, 2)); $clr_white = ImageColorAllocate($image, rand(160, 200), rand(160, 200), rand(160, 200)); imagelinethick($image, rand($width / 2 - 10, $width / 2), rand($height / 2, $height), rand($width / 2 + 10, $width), rand(0, $height / 2), $clr_white, rand(1, 2)); // generate final image by cropping initial image to the proper width, // which we didn't know till now. $finalimage = ImageCreatetruecolor($width, $height); if (function_exists('imageantialias')) { imageantialias($finalimage, true); } imagecopy($finalimage, $image, 0, 0, 0, 0, $width, $height); // clear some memory imagedestroy($image); // dump image imagepng($finalimage); // clear some more memory imagedestroy($finalimage); }
mail(getVar('email'), 'Votre compte sur plopbox.zlock.eu', "Votre compte a ete cree sur plopbox.zlock.eu\nLogin: "******"\nPassword: "******"UPDATE users SET level = 2 WHERE id = :id LIMIT 1"); $sth->execute(array(':id' => getVar('id'))); break; case 'removeAdmin': $sth = $dbh->prepare("UPDATE users SET level = 1 WHERE id = :id LIMIT 1"); $sth->execute(array(':id' => getVar('id'))); break; case 'ban': $sth = $dbh->prepare("UPDATE users SET level = 0 WHERE id = :id LIMIT 1"); $sth->execute(array(':id' => getVar('id'))); break; case 'genPassword': $password = genPassword(); $sth = $dbh->prepare("UPDATE users SET password = :password WHERE id = :id LIMIT 1"); $sth->execute(array(':id' => getVar('id'), ':password' => passwordHash($password))); mail(getVar('email'), 'Votre nouveau mot de passe sur plopbox.zlock.eu', "Votre nouveau mot de passe sur plopbox.zlock.eu est: " . $password, 'From: noreply@zlock.eu'); break; } } if (!$_SESSION['id'] && $_SESSION['id'] != 1) { render('forbidden'); } $userssQuery = $dbh->prepare("SELECT id, login, email, level FROM users"); $userssQuery->execute(); $users = $userssQuery->fetchAll(); // 0 = banned // 1 = user // 2 = admin // 3 = superadmin $levels = array('<span class="label label-important">Banni</span>', '<span class="label">Normal</span>', '<span class="label label-success">Admin serveur</span>', '<span class="label label-inverse">Root</span>'); render('users', array('users' => $users, 'levels' => $levels));
$userData['email'] = $_GET['mail']; $userData['SSID'] = $_GET['SSID']; //var_dump($userData); $cmd = $_GET['cmd']; $chkUsr = checkUser($userData, $dbdriver, $server, $user, $password, 'simple3d', 'users'); if ($cmd == 'login') { if ($chkUsr['login'] == 'login') { $data = getUserData($userData, $dbdriver, $server, $user, $password); $echo = "{status:'exists',data:{$data}}"; } else { $echo = "{'status':'invalid' , 'error': '" . $chkUsr['login'] . "' }"; } } if ($cmd == 'makeuser') { if ($chkUsr['signup'] == 'signup') { $userData['password'] = genPassword(); createUser($userData, $dbdriver, $server, $user, $password); $SSID = genSSID($userData, $dbdriver, $server, $user, $password, 'simple3d', 'users'); $echo = "{status:'created','SSID':'{$SSID}'}"; $confaddress = 'http://*****:*****@gmail.com', 'Simple3D Account Creation', "<html><body>{$usrStr}</body></html>"); } else { $echo = "{'status':'invalid' , 'error': '" . $chkUsr['signup'] . "' }"; } } if ($cmd == 'logout') {
<div class='break4'></div> <?php try { echo "<div class='sitename'>VM LiveView Lite Setup</div>\n"; echo "<div class='break6'></div>\n"; if ($illegalRemoteAddr === true) { echo "<div class='red'>Sorry, but this page can only be requested by the localhost.</div>\n"; } else { $mysqlHost = "localhost"; $mysqlPort = "3306"; $mysqlAdminUser = "******"; $mysqlAdminPass = ""; $databaseName = "vmliveview01"; $databaseWriter = "vmliveview01dbw"; $databaseWriterHost = "localhost"; $databaseWriterPass = genPassword(20); if (isset($_POST["MysqlHost"])) { $mysqlHost = $_POST["MysqlHost"]; } if (isset($_POST["MysqlPort"])) { $mysqlPort = $_POST["MysqlPort"]; } if (isset($_POST["MysqlAdminUser"])) { $mysqlAdminUser = $_POST["MysqlAdminUser"]; } if (isset($_POST["MysqlAdminPass"])) { $mysqlAdminPass = $_POST["MysqlAdminPass"]; } if (isset($_POST["DatabaseName"])) { $databaseName = $_POST["DatabaseName"]; }
/** * 生成表单域对应的html * @param array $input * @param array $field 字段信息 * @return string */ public function genHtml(&$input, $field) { $width = $input['width']; $height = $input['height']; $value = $input['value']; $type = $input['type']; $remark = $input['remark']; $class = 'input'; if ('file' == $type) { $fn = "{$field['name']}"; } else { $fn = "{$field['model']}[{$field['name']}]"; } $html = ''; if ('text' == $type) { $html = genText($fn, $width, $value, $class); } else { if ('password' == $type) { $html = genPassword($fn, $width, $value, $class); } else { if ('select' == $type) { $list = $this->optValueToArray($input['opt_value']); $html = genSelect($fn, $list['opt_value'], $list['selected']); } else { if ('radio' == $type) { $list = $this->optValueToArray($input['opt_value']); $html = genRadios($fn, $list['opt_value'], $list['selected']); } else { if ('checkbox' == $type) { $list = $this->optValueToArray($input['opt_value'], true); $html = genCheckboxs($fn, $list['opt_value'], $list['selected']); } else { if ('file' == $type) { $html = genFile($fn); } else { if ('textarea' == $type) { $html = genTextarea($fn, $value, $width, $height, $remark); } else { if ('date' == $type) { $html = genDate($fn, $value, $class); } else { if ('relation_select' == $type) { $relaOpts = $this->getRelationOpts($field); $input['opt_value'] = $this->optArrayToString($relaOpts); $html = genSelect($fn, $relaOpts['opt_value']); } else { if ('editor' == $type) { $html = genEditor($fn, empty($value) ? $remark : $value, $width, $height, $input['editor']); } } } } } } } } } } $input['html'] = $html; }