com web/doc: Auth stuff removed: include/cvs-auth.inc include/lib_auth.inc.php include/lib_general.inc. php templates/all/www/login.tpl.php www/admin.php w ww/login.php
| Newsgroups | php.doc.web |
|---|---|
| Message-ID | <[email protected]> |
Commit: f85b309b6bb9ede2610758e28baadb54d211c012 Author: Sobak <[email protected]> Mon, 17 Mar 2014 21:00:40 +0100 Parents: 43784b3fa9da34a9858ee07c8120de884402033d Branches: master Link: http://git.php.net/?p=web/doc.git;a=commitdiff;h=f85b309b6bb9ede2610758e28baadb54d211c012 Log: Auth stuff removed Changed paths: D include/cvs-auth.inc D include/lib_auth.inc.php M include/lib_general.inc.php D templates/all/www/login.tpl.php D www/admin.php D www/login.php
diff_f85b309b6bb9ede2610758e28baadb54d211c012.txt
(text/plain, 15.2 KB)
diff --git a/include/cvs-auth.inc b/include/cvs-auth.inc deleted file mode 100755 index 685ecfb..0000000 --- a/include/cvs-auth.inc +++ /dev/null @@ -1,107 +0,0 @@ -<?php -/** - * +----------------------------------------------------------------------+ - * | PHP Documentation Site Source Code | - * +----------------------------------------------------------------------+ - * | Copyright (c) 1997-2011 The PHP Group | - * +----------------------------------------------------------------------+ - * | This source file is subject to version 3.0 of the PHP license, | - * | that is bundled with this package in the file LICENSE, and is | - * | available at through the world-wide-web at | - * | http://www.php.net/license/3_0.txt. | - * | If you did not receive a copy of the PHP license and are unable to | - * | obtain it through the world-wide-web, please send a note to | - * | [email protected] so we can mail you a copy immediately. | - * +----------------------------------------------------------------------+ - * | Authors: Sara Golemon <[email protected]> | - * | Wez Furlong <[email protected]> | - * | Jacques Marneweck <[email protected]> | - * +----------------------------------------------------------------------+ - * - * $Id$ - */ - -require_once(dirname(__FILE__) . '/../build-ops.php'); - -function auth_vs_svn($user, $pass, &$errors = null) -{ - $errors = array(); - - $post = http_build_query( - array( - 'token' => getenv('AUTH_TOKEN'), - 'username' => $user, - 'password' => $pass, - ) - ); - - $opts = array( - 'method' => 'POST', - 'header' => 'Content-type: application/x-www-form-urlencoded', - 'content' => $post, - ); - - $ctx = stream_context_create(array('http' => $opts)); - - $s = file_get_contents('https://master.php.net/fetch/cvsauth.php', false, $ctx); - - $a = @unserialize($s); - if (!is_array($a)) { - $errors[] = "Failed to get authentication information.\nMaybe master is down?\n"; - return false; - } - if (isset($a['errno'])) { - $errors[] = "Authentication failed: {$a['errstr']}\n"; - return false; - } - - return true; -} - - -/** - * Check local credential cache before sending extra queries - * to master.php.net - */ -function auth_vs_local ($idx, $user, $pass) { - - $res = sqlite_query ($idx, "SELECT * FROM auth WHERE username='" . sqlite_escape_string($user) . "'"); - - if (!$res) { - return false; - } - - if (!$data = sqlite_fetch_array($res, SQLITE_ASSOC)) { - return false; - } - - if ($data['time'] + 60*60*24 < time()) { - return false; - } - - if (sha1($pass) == $data['password']) { - return true; - } - - return false; -} - -function verify_password($user, $pass) { - global $idx; - - if (!$user || !$pass) { - return false; - } - - if (auth_vs_local($idx, $user, $pass)) { - return true; - } - - if (auth_vs_svn($user, $pass)) { - return true; - } - - return false; -} - -/* vim: set noet ts=4 sw=4 ft=php: : */ diff --git a/include/lib_auth.inc.php b/include/lib_auth.inc.php deleted file mode 100644 index d948fc4..0000000 --- a/include/lib_auth.inc.php +++ /dev/null @@ -1,108 +0,0 @@ -<?php -/** - * +----------------------------------------------------------------------+ - * | PHP Documentation Site Source Code | - * +----------------------------------------------------------------------+ - * | Copyright (c) 1997-2011 The PHP Group | - * +----------------------------------------------------------------------+ - * | This source file is subject to version 3.0 of the PHP license, | - * | that is bundled with this package in the file LICENSE, and is | - * | available at through the world-wide-web at | - * | http://www.php.net/license/3_0.txt. | - * | If you did not receive a copy of the PHP license and are unable to | - * | obtain it through the world-wide-web, please send a note to | - * | [email protected] so we can mail you a copy immediately. | - * +----------------------------------------------------------------------+ - * | Authors: Jacques Marneweck <[email protected]> | - * | Nuno Lopes <[email protected]> | - * +----------------------------------------------------------------------+ - * - */ - -require_once 'cvs-auth.inc'; - -$user = null; // Register globals... - -//list of docweb admins that have 'special' rights -$admins = array( - 'didou', - 'goba', - 'jacques', - 'nlopess', - 'philip', - 'sean', - 'vincent', - 'mazzanet', - 'colder', - 'bjori', -); - -/** - * Credential checking of the $_COOKIE['MAGIC_COOKIE'] - */ -function auth() -{ - $return = urlencode($_SERVER['REQUEST_URI']); - - if (isset($_POST['username']) && isset($_POST['passwd'])) { - if (!verify_password($_POST['username'], $_POST['passwd'])) { - header ('Location: https://doc.php.net/login.php?return='.$return); - exit; - } - } else { - header ('Location: https://doc.php.net/login.php?return='.$return); - exit; - } -} - - -/** - * Checks if a user has admin rights - */ -function is_admin() -{ - return in_array($GLOBALS['user'], $GLOBALS['admins']); -} - -/** - * returns the user's real name - */ -function user_name($user = false) -{ - $user = $user ? $user : $GLOBALS['user']; - return master_user_name($user); -} - - -/** - * Fetch the user's real name from the master server - */ -function master_user_name($nick) -{ - // LOGINFIXME: Do this query through the proper API - return "unknown"; - $magic_cookie = (!empty($_COOKIE['MAGIC_COOKIE'])) ? - $_COOKIE['MAGIC_COOKIE'] : - '' ; // need a generic key here!! - - if (!$fp = @fsockopen('master.php.net', 80)) - return $nick; - - fputs($fp, "GET /manage/users.php?username=$nick HTTP/1.0\r\n". - "Host: master.php.net\r\n". - "Cookie: MAGIC_COOKIE=$magic_cookie\r\n". - "\r\n"); - - $txt = @fread($fp, 50000); - fclose($fp); - - // if we found a name, cache it in the DB - if (preg_match('@<th[^>]+>Name:</th>\s+<td><input[^>]+value="([^"]+)"@', $txt, $match)) { - sqlite_query($GLOBALS['idx'], "INSERT INTO users (username, name) VALUES ('$nick', '$match[1]')"); //the server has no sqlite_exec support yet (still php4) - return $match[1]; - } - - return $nick; -} - -?> diff --git a/include/lib_general.inc.php b/include/lib_general.inc.php index 299ef2b..e8ba5a5 100644 --- a/include/lib_general.inc.php +++ b/include/lib_general.inc.php @@ -21,8 +21,6 @@ $Id$ */ -require_once dirname(__FILE__) . '/lib_auth.inc.php'; - function is_translation($project, $language) { return is_dir(SVN_DIR . $GLOBALS['PROJECTS'][$project] . '/' . $language); @@ -207,9 +205,6 @@ function site_nav_provider() $links['phpt-generator'] = BASE_URL . '/phpt_generator.php'; } - if (is_admin()) - $links['admin'] = BASE_URL . '/admin.php'; - return DocWeb_Template::get( 'shared/nav_links.tpl.php', array('links' => $links, 'Language' => &$GLOBALS['Language']) diff --git a/templates/all/www/login.tpl.php b/templates/all/www/login.tpl.php deleted file mode 100644 index fa185ab..0000000 --- a/templates/all/www/login.tpl.php +++ /dev/null @@ -1,33 +0,0 @@ -<p> - &docweb.login.subhead; -</p> - -<p> -<form method="post" name="login" action="/login.php"> -<input type="hidden" name="return" value="<?php - - if (isset($_REQUEST['return'])) { - echo htmlspecialchars($_REQUEST['return']); - } - -?>" /> -<table border="0" cellspacing="2" cellpadding="2"> - <tr> - <th>Username</th> - <td><input type="text" name="username" value="" /></td> - </tr> - <tr> - <th>Password</th> - <td><input type="password" name="passwd" value="" /></td> - </tr> - <tr> - <td> - <td><input type="submit" value="Login »" /></td> - </tr> -</table> -</form> -</p> - -<p> - &docweb.login.text; -</p> diff --git a/www/admin.php b/www/admin.php deleted file mode 100644 index c4437b2..0000000 --- a/www/admin.php +++ /dev/null @@ -1,219 +0,0 @@ -<?php -/* -+----------------------------------------------------------------------+ -| PHP Documentation Site Source Code | -+----------------------------------------------------------------------+ -| Copyright (c) 1997-2011 The PHP Group | -+----------------------------------------------------------------------+ -| This source file is subject to version 3.0 of the PHP license, | -| that is bundled with this package in the file LICENSE, and is | -| available at through the world-wide-web at | -| http://www.php.net/license/3_0.txt. | -| If you did not receive a copy of the PHP license and are unable to | -| obtain it through the world-wide-web, please send a note to | -| [email protected] so we can mail you a copy immediately. | -+----------------------------------------------------------------------+ -| Authors: Nuno Lopes <[email protected]> | -+----------------------------------------------------------------------+ -$Id$ -*/ - -include '../include/init.inc.php'; - -auth(); -if (!is_admin()) { - die('you are not an admin!'); -} - -ob_start(); // hack for phpinfo() -echo site_header('Admin Zone'); - - -// helper functions - -function info() { - ob_end_clean(); //get ride of the headers - phpinfo(); - exit; -} - -function pearinfo() { - ob_end_clean(); - require_once 'PEAR/Info.php'; - $info = new PEAR_Info('/usr/local/share/pear'); - $info->show(); - exit; -} - -function print_file_list($base) -{ - if (!empty($_GET['file']) && !is_dir(dirname(__FILE__) . "/../$_GET[file]")) - return; - - $files = glob(dirname(__FILE__) . '/../' . @$_GET['file'] . $base); - $uri = preg_replace('/&file=[^&]*/', '', $_SERVER['REQUEST_URI']); - if ($files) { - echo '<p>Available files:</p><ul>'; - foreach ($files as $file) { - $file = basename($file); - if ($file == '.svn') continue; - echo "<li><a href='$uri&file=". urlencode(@$_GET['file'] . "/$file") . "'>$file</a></li>"; - } - echo '</ul>'; - } else { - echo '<p>There are no files currently available</p>'; - } - -} - -function sql() -{ - if (empty($_POST['command'])) { - sql_print_textarea('', @$_REQUEST['file']); - - // execute the sql - } else { - $file = dirname(__FILE__) . '/../sqlite/' . $_POST['file']; - $idx = sqlite_open($file, 0666, $error); - if (!$idx) { - echo "<p>$error</p>"; - sql_print_textarea($_POST['command'], $_POST['file']); - return; - } - - $result = sqlite_query($idx, $_POST['command']); - - if (!$result) { - echo '<p><strong>There was an error in the query:</strong> ' . sqlite_error_string(sqlite_last_error($idx)) . '</p><p> </p>'; - sql_print_textarea($_POST['command'], $_POST['file']); - return; - } - - echo '<p>File size: ' . filesize($file) / 1024 . ' KB</p>'; - echo '<p>Affected rows: ' . sqlite_changes($idx) , '</p>'; - echo '<pre>' . htmlspecialchars(print_r(sqlite_fetch_all($result), true)) . '</pre>'; - sqlite_close($idx); - sql_print_textarea($_POST['command'], $_POST['file']); - } -} - - -function sql_print_textarea($txt, $file) -{ - print_file_list('sqlite/*.sqlite'); - - echo <<< HTML -<p> </p> -<form method="POST" action="$_SERVER[REQUEST_URI]"> - <p>SQL: <textarea name="command" rows="5" cols="70">$txt</textarea></p> - <p>DB: <input type="text" name="file" value="$file" /></p> - <p><input type="submit" value="Execute" /></p> -</form> -HTML; - -} - - -function chmodf() -{ - if (empty($_POST['mod']) || empty($_REQUEST['file'])) { - rmch_print_html(@$_REQUEST['file'], @$_POST['mod'], true); - - // change the permissions - } else { - $path = realpath(dirname(__FILE__) . "/../$_POST[file]"); - $allowed = dirname(dirname(__FILE__)); - - if (strncmp($path, $allowed, strlen($allowed))) { - echo "<p>The file isn't within an allowed directory!</p>"; - return; - } - - if (chmod($path, octdec($_POST['mod']))) - echo '<p>chmod() ok!</p>'; - else - echo '<p>chmod() failed!</p>'; - } -} - - -function rm() -{ - if (empty($_REQUEST['file'])) { - rmch_print_html(@$_REQUEST['file'], '', false); - - // change the permissions - } else { - $path = realpath(dirname(__FILE__) . "/../$_REQUEST[file]"); - $allowed = dirname(dirname(__FILE__)); - - if (strncmp($path, $allowed, strlen($allowed))) { - echo "<p>The file isn't within an allowed directory!</p>"; - return; - } - - if (unlink($path)) - echo '<p>unlink() ok!</p>'; - else - echo '<p>unlink() failed!</p>'; - } -} - - -function rmch_print_html($file, $val, $mod) -{ - print_file_list('/*'); - - echo <<< HTML -<p> </p> -<form method="POST" action="$_SERVER[REQUEST_URI]"> - <p>File: <input type="text" name="file" value="$file" /></p> -HTML; - - if ($mod) - echo '<p>Permissions: <input type="text" name="mod" value="' . $val . '" /></p>'; - - echo <<< HTML - <p><input type="submit" value="Execute" /></p> -</form> -HTML; - -} - - -// control flow -if (empty($_GET['z'])) { -$lastSVNUpdate = date ('r', filemtime('./.svn/entries')); - - echo <<< HTML -<p>Menu:</p> -<ul> - <li><a href="?z=sql">SQL Injector</a></li> - <li><a href="?z=chmodf">chmod</a></li> - <li><a href="?z=rm">remove files</a></li> - <li><a href="?z=info">PHP info</a></li> - <!--<li><a href="?z=pearinfo">PEAR info</a></li> - pearinfo is broken for everyone--> -</ul> -<br /> -<p>Last SVN Update: $lastSVNUpdate</p> -HTML; - -} else { - switch ($_GET['z']) { - case 'sql': - case 'chmodf': - case 'rm': - case 'info': - case 'pearinfo': - $_GET['z'](); - break; - - default: - echo '<p>wrong zone!</p>'; - } -} - - -echo site_footer(); -?> diff --git a/www/login.php b/www/login.php deleted file mode 100644 index 72d16e9..0000000 --- a/www/login.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/* $Id$ */ - -include '../include/init.inc.php'; - -// FIXME: MAGIC_COKIE disabled -if (!empty($_POST)) { - auth(); - - if (isset($_REQUEST['return']) && !empty($_REQUEST['return']) - && ctype_print($_REQUEST['return'])) { - - header('Location: http://'.$_SERVER['HTTP_HOST'].$_REQUEST['return']); - } - echo 'You are logged in'; - echo is_admin() ? ' <strong>with admin rights</strong>.' : '.'; -} else { - echo site_header('docweb.common.header.login'); - echo DocWeb_Template::get('login.tpl.php'); - echo site_footer(); -} -?>