|
From: Javier S. <ja...@us...> - 2001-08-22 16:34:23
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv4704
Modified Files:
include.php
Log Message:
splitting configuration stuff to config.php
Index: include.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/include.php,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- include.php 2001/08/21 16:50:27 1.36
+++ include.php 2001/08/22 16:34:20 1.37
@@ -10,68 +10,37 @@
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
-//
+//
// phpBugTracker is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with phpBugTracker; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// ------------------------------------------------------------------------
-define ('INSTALLPATH','/home/bcurtis/public_html/phpbt');
-define ('INSTALLURL','http://localhost/~bcurtis/phpbt');
-// Location of phplib -- only necessary if you can't define your include path
-define ('PHPLIBPATH','');
-define ('ONEDAY',86400);
-define ('DATEFORMAT','m-d-Y');
-define ('TIMEFORMAT','g:i A');
-define ('ADMINEMAIL','ph...@be...');
-define ('ENCRYPTPASS',0); // Whether to store passwords encrypted
-define ('THEME','default/'); // Which set of templates to use
-define ('USE_JPGRAPH',0); // Whether to show images or not
-define ('JPGRAPH_PATH', '/home/bcurtis/public_html/jp/'); // If it's not in the include path
-define ('MASK_EMAIL', 1); // Should email addresses be plainly visible?
-define ('HIDE_EMAIL', 1); // Should email addresses be hidden for those not logged in?
-// Should the query list use the severity colors as the row background color (like SourceForge)
-define ('USE_SEVERITY_COLOR', 1);
-// Sub-dir of the INSTALLPATH - Needs to be writeable by the web process
-define ('ATTACHMENT_PATH', 'attachments');
-// Maximum size (in bytes) of an attachment
-// This will not override the settings in php.ini if php.ini has a lower limit
-define ('ATTACHMENT_MAX_SIZE', 2097152);
-
-require PHPLIBPATH.'db_mysql.inc';
-require PHPLIBPATH.'ct_sql.inc';
-require PHPLIBPATH.'session.inc';
-require PHPLIBPATH.'auth.inc';
-require PHPLIBPATH.'perm.inc';
-require PHPLIBPATH.'page.inc';
-require PHPLIBPATH.'template.inc';
+require "config.php";
-// Localization - include the file with the desired language
-include INSTALLPATH.'/languages/en.php';
-
// Edit this class with your database information
class dbclass extends DB_Sql {
- var $classname = 'dbclass';
- var $Host = 'localhost';
- var $Database = 'BugTracker';
- var $User = 'root';
- var $Password = '';
-
- function grab($q_string = '') {
- if ($q_string) $this->query($q_string);
- $this->next_record();
- return $this->Record;
- }
-
- function grab_field($q_string = '') {
- list($retval) = $this->grab($q_string);
- return $retval;
- }
+ var $classname = 'dbclass';
+ var $Host = DB_HOST;
+ var $Database = DB_DATABASE;
+ var $User = DB_USER;
+ var $Password = DB_PASSWORD;
+
+ function grab($q_string = '') {
+ if ($q_string) $this->query($q_string);
+ $this->next_record();
+ return $this->Record;
+ }
+
+ function grab_field($q_string = '') {
+ list($retval) = $this->grab($q_string);
+ return $retval;
+ }
}
$q = new dbclass;
@@ -84,394 +53,394 @@
$_pv = $HTTP_POST_VARS;
$select['authlevels'] = array(
- 0 => 'Inactive',
- 1 => 'User',
- 3 => 'Developer',
- 7 => 'Manager',
- 15 => 'Administrator'
- );
+ 0 => 'Inactive',
+ 1 => 'User',
+ 3 => 'Developer',
+ 7 => 'Manager',
+ 15 => 'Administrator'
+ );
$all_db_fields = array(
- 'bug_id' => 'ID',
- 'title' => 'Title',
- 'description' => 'Description',
- 'url' => 'URL',
- 'severity_name' => 'Severity',
- 'priority' => 'Priority',
- 'status_name' => 'Status',
- 'resolution_name' => 'Resolution',
- 'reporter' => 'Reporter',
- 'owner' => 'Owner',
- 'created_date' => 'Created Date',
- 'lastmodifier' => 'Last Modified By',
- 'last_modified_date' => 'Last Modified Date',
- 'project_name' => 'Project',
- 'version_name' => 'Version',
- 'component_name' => 'Component',
- 'os_name' => 'OS',
- 'browser_string' => 'Browser',
- 'close_date' => 'Closed Date'
- );
-
-$default_db_fields = array('bug_id', 'title', 'reporter', 'owner',
- 'severity_name', 'priority', 'status_name', 'resolution_name');
-
+ 'bug_id' => 'ID',
+ 'title' => 'Title',
+ 'description' => 'Description',
+ 'url' => 'URL',
+ 'severity_name' => 'Severity',
+ 'priority' => 'Priority',
+ 'status_name' => 'Status',
+ 'resolution_name' => 'Resolution',
+ 'reporter' => 'Reporter',
+ 'owner' => 'Owner',
+ 'created_date' => 'Created Date',
+ 'lastmodifier' => 'Last Modified By',
+ 'last_modified_date' => 'Last Modified Date',
+ 'project_name' => 'Project',
+ 'version_name' => 'Version',
+ 'component_name' => 'Component',
+ 'os_name' => 'OS',
+ 'browser_string' => 'Browser',
+ 'close_date' => 'Closed Date'
+ );
+
+$default_db_fields = array('bug_id', 'title', 'reporter', 'owner',
+ 'severity_name', 'priority', 'status_name', 'resolution_name');
+
class sqlclass extends CT_Sql {
- var $database_class = 'dbclass';
- var $database_table = 'active_sessions';
+ var $database_class = 'dbclass';
+ var $database_table = 'active_sessions';
}
class usess extends Session {
- var $classname = 'usess';
- var $magic = 'gerdisbad';
- var $mode = 'cookie';
- #var $fallback_mode = 'get';
- var $lifetime = 0;
- var $that_class = 'sqlclass';
- var $allowcache = 'jl';
+ var $classname = 'usess';
+ var $magic = 'gerdisbad';
+ var $mode = 'cookie';
+ #var $fallback_mode = 'get';
+ var $lifetime = 0;
+ var $that_class = 'sqlclass';
+ var $allowcache = 'jl';
}
class uauth extends Auth {
- var $classname = 'uauth';
- var $lifetime = 0;
- var $magic = 'looneyville';
- var $nobody = true;
-
- function auth_loginform() {
- global $sess;
-
- include 'templates/'.THEME.'login.html';
-
- }
-
- function auth_validatelogin() {
- global $username, $password, $q, $select, $emailpass, $emailsuccess, $STRING;
-
- if (!$username) return 'nobody';
- $this->auth['uname'] = $username;
- if (ENCRYPTPASS) {
- $password = md5($password);
- }
- $u = $q->grab("select * from user where email = '$username' and password = '$password' and user_level > 0");
- if (!$q->num_rows()) {
- return 'nobody';
- } else {
- $this->auth['fname'] = $u['first_name'];
- $this->auth['lname'] = $u['last_name'];
- $this->auth['email'] = $u['email'];
- $this->auth['perm'] = $select['authlevels'][$u['user_level']];
- $this->auth['db_fields'] = unserialize($u['bug_list_fields']);
- return $u['user_id'];
- }
- }
-
- function unauth($nobody = false) {
- Auth::unauth($nobody);
- $this->auth['db_fields'] = '';
- }
+ var $classname = 'uauth';
+ var $lifetime = 0;
+ var $magic = 'looneyville';
+ var $nobody = true;
+
+ function auth_loginform() {
+ global $sess;
+
+ include 'templates/'.THEME.'login.html';
+
+ }
+
+ function auth_validatelogin() {
+ global $username, $password, $q, $select, $emailpass, $emailsuccess, $STRING;
+
+ if (!$username) return 'nobody';
+ $this->auth['uname'] = $username;
+ if (ENCRYPTPASS) {
+ $password = md5($password);
+ }
+ $u = $q->grab("select * from user where email = '$username' and password = '$password' and user_level > 0");
+ if (!$q->num_rows()) {
+ return 'nobody';
+ } else {
+ $this->auth['fname'] = $u['first_name'];
+ $this->auth['lname'] = $u['last_name'];
+ $this->auth['email'] = $u['email'];
+ $this->auth['perm'] = $select['authlevels'][$u['user_level']];
+ $this->auth['db_fields'] = unserialize($u['bug_list_fields']);
+ return $u['user_id'];
+ }
+ }
+
+ function unauth($nobody = false) {
+ Auth::unauth($nobody);
+ $this->auth['db_fields'] = '';
+ }
}
class uperm extends Perm {
- var $classname = 'uperm';
- var $permissions = array(
- 'Inactive' => 0,
- 'User' => 1,
- 'Developer' => 3,
- 'Manager' => 7,
- 'Administrator' => 15,
- );
-
- function perm_invalid() {
- global $t, $auth;
- $t->set_file('content','badperm.html');
- $t->pparse('main',array('content','wrap','main'));
- }
+ var $classname = 'uperm';
+ var $permissions = array(
+ 'Inactive' => 0,
+ 'User' => 1,
+ 'Developer' => 3,
+ 'Manager' => 7,
+ 'Administrator' => 15,
+ );
+
+ function perm_invalid() {
+ global $t, $auth;
+ $t->set_file('content','badperm.html');
+ $t->pparse('main',array('content','wrap','main'));
+ }
}
class templateclass extends Template {
- function pparse($target, $handle, $append = false) {
- global $auth, $perm, $q;
-
- $u = $auth->auth['uid'];
- $this->set_block('wrap', 'logoutblock', 'loblock');
- $this->set_block('wrap', 'loginblock', 'liblock');
- $this->set_block('wrap', 'adminnavblock', 'anblock');
- if ($u && $u != 'nobody') {
- list($owner_open, $owner_closed) =
- $q->grab("select sum(if(status_name in ('Unconfirmed','New','Assigned','Reopened'),1,0)), sum(if(status_name not in ('Unconfirmed','New','Assigned','Reopened'),1,0)) from bug b left join status s using(status_id) where assigned_to = $u");
- list($reporter_open, $reporter_closed) =
- $q->grab("select sum(if(status_name in ('Unconfirmed','New','Assigned','Reopened'),1,0)), sum(if(status_name not in ('Unconfirmed','New','Assigned','Reopened'),1,0)) from bug b left join status s using(status_id) where created_by = $u");
- $this->set_var(array(
- 'loggedinas' => $auth->auth['email'],
- 'liblock' => '',
- 'owner_open' => $owner_open,
- 'owner_closed' => $owner_closed,
- 'reporter_open' => $reporter_open,
- 'reporter_closed' => $reporter_closed
- ));
- $this->parse('loblock', 'logoutblock', true);
- } else {
- $this->set_var(array(
- 'loggedinas' => '',
- 'loblock' => ''
- ));
- $this->parse('liblock', 'loginblock', true);
- }
- if (isset($perm) && $perm->have_perm('Administrator')) {
- $this->parse('anblock', 'adminnavblock', true);
- } else {
- $this->set_var('anblock', '');
- }
- print $this->finish($this->parse($target, $handle, $append));
- return false;
- }
+ function pparse($target, $handle, $append = false) {
+ global $auth, $perm, $q;
+
+ $u = $auth->auth['uid'];
+ $this->set_block('wrap', 'logoutblock', 'loblock');
+ $this->set_block('wrap', 'loginblock', 'liblock');
+ $this->set_block('wrap', 'adminnavblock', 'anblock');
+ if ($u && $u != 'nobody') {
+ list($owner_open, $owner_closed) =
+ $q->grab("select sum(if(status_name in ('Unconfirmed','New','Assigned','Reopened'),1,0)), sum(if(status_name not in ('Unconfirmed','New','Assigned','Reopened'),1,0)) from bug b left join status s using(status_id) where assigned_to = $u");
+ list($reporter_open, $reporter_closed) =
+ $q->grab("select sum(if(status_name in ('Unconfirmed','New','Assigned','Reopened'),1,0)), sum(if(status_name not in ('Unconfirmed','New','Assigned','Reopened'),1,0)) from bug b left join status s using(status_id) where created_by = $u");
+ $this->set_var(array(
+ 'loggedinas' => $auth->auth['email'],
+ 'liblock' => '',
+ 'owner_open' => $owner_open,
+ 'owner_closed' => $owner_closed,
+ 'reporter_open' => $reporter_open,
+ 'reporter_closed' => $reporter_closed
+ ));
+ $this->parse('loblock', 'logoutblock', true);
+ } else {
+ $this->set_var(array(
+ 'loggedinas' => '',
+ 'loblock' => ''
+ ));
+ $this->parse('liblock', 'loginblock', true);
+ }
+ if (isset($perm) && $perm->have_perm('Administrator')) {
+ $this->parse('anblock', 'adminnavblock', true);
+ } else {
+ $this->set_var('anblock', '');
+ }
+ print $this->finish($this->parse($target, $handle, $append));
+ return false;
+ }
}
$t = new templateclass('templates/'.THEME,'keep');
$t->set_var(array(
- 'TITLE' => '',
- 'me' => $me,
- 'me2' => $me2,
- 'error' => '',
- 'cssfile' => $cssfile,
- 'loginerror' => ''));
-
-// End classes -- Begin helper functions
-
+ 'TITLE' => '',
+ 'me' => $me,
+ 'me2' => $me2,
+ 'error' => '',
+ 'cssfile' => $cssfile,
+ 'loginerror' => ''));
+
+// End classes -- Begin helper functions
+
///
/// Show text to the browser - escape hatch
function show_text($text, $iserror = false) {
- global $t;
-
- $t->set_file('content','error.html');
- if (!$iserror) $t->set_var('text',$text);
- else $t->set_var('text',"<font color=red>$text</font>");
+ global $t;
+
+ $t->set_file('content','error.html');
+ if (!$iserror) $t->set_var('text',$text);
+ else $t->set_var('text',"<font color=red>$text</font>");
}
$select['priority'] = array(
- 1 => '1 - Low',
- 2 => '2',
- 3 => '3 - Medium',
- 4 => '4',
- 5 => '5 - High'
- );
+ 1 => '1 - Low',
+ 2 => '2',
+ 3 => '3 - Medium',
+ 4 => '4',
+ 5 => '5 - High'
+ );
///
/// Build a select box with the item matching $value selected
function build_select($box, $value = '', $project = 0) {
- global $q, $select;
-
- $text = '';
- $queries = array(
- 'severity' => "select {$box}_id, {$box}_name from $box where sort_order > 0 order by sort_order",
- 'status' => "select {$box}_id, {$box}_name from $box where sort_order > 0 order by sort_order",
- 'resolution' => "select {$box}_id, {$box}_name from $box where sort_order > 0 order by sort_order",
- 'project' => "select {$box}_id, {$box}_name from $box where active = 1 order by {$box}_name",
- 'component' => "select {$box}_id, {$box}_name from $box where project_id = $project order by {$box}_name",
- 'version' => "select {$box}_id, {$box}_name from $box where project_id = $project order by {$box}_name"
- );
-
- switch($box) {
- case 'severity' :
- case 'status' :
- case 'resolution' :
- case 'project' :
- case 'component' :
- case 'version' :
- $q->query($queries[$box]);
- while ($row = $q->grab()) {
- if ($value == $row[$box.'_id'] and $value != '') $sel = ' selected';
- else $sel = '';
- $text .= '<option value="'.
- $row[$box.'_id']."\"$sel>".$row[$box.'_name']."</option>";
- }
- break;
- case 'os' :
- $q->query("select {$box}_id, {$box}_name, regex from $box order by sort_order");
- while ($row = $q->grab()) {
- if ($value == '' and $row['Regex'] and
- preg_match($row['Regex'],$GLOBALS['HTTP_USER_AGENT'])) $sel = ' selected';
- elseif ($value == $row[$box.'ID']) $sel = ' selected';
- else $sel = '';
- $text .= '<option value="'.
- $row[$box.'_id']."\"$sel>".$row[$box.'_name']."</option>";
- }
- break;
- case 'owner' :
- $q->query("Select user_id, email from user where user_level > 1 order by email");
- while ($row = $q->grab()) {
- if ($value == $row['user_id']) $sel = ' selected';
- else $sel = '';
- $text .= "<option value=\"{$row['user_id']}\"$sel>{$row['email']}</option>";
- }
- break;
- default :
- $deadarray = $select[$box];
- while(list($val,$item) = each($deadarray)) {
- if ($value == $val and $value != '') $sel = ' selected';
- else $sel = '';
- $text .= "<option value=\"$val\"$sel>$item</option>";
- }
- break;
- }
- return $text;
+ global $q, $select;
+
+ $text = '';
+ $queries = array(
+ 'severity' => "select {$box}_id, {$box}_name from $box where sort_order > 0 order by sort_order",
+ 'status' => "select {$box}_id, {$box}_name from $box where sort_order > 0 order by sort_order",
+ 'resolution' => "select {$box}_id, {$box}_name from $box where sort_order > 0 order by sort_order",
+ 'project' => "select {$box}_id, {$box}_name from $box where active = 1 order by {$box}_name",
+ 'component' => "select {$box}_id, {$box}_name from $box where project_id = $project order by {$box}_name",
+ 'version' => "select {$box}_id, {$box}_name from $box where project_id = $project order by {$box}_name"
+ );
+
+ switch($box) {
+ case 'severity' :
+ case 'status' :
+ case 'resolution' :
+ case 'project' :
+ case 'component' :
+ case 'version' :
+ $q->query($queries[$box]);
+ while ($row = $q->grab()) {
+ if ($value == $row[$box.'_id'] and $value != '') $sel = ' selected';
+ else $sel = '';
+ $text .= '<option value="'.
+ $row[$box.'_id']."\"$sel>".$row[$box.'_name']."</option>";
+ }
+ break;
+ case 'os' :
+ $q->query("select {$box}_id, {$box}_name, regex from $box order by sort_order");
+ while ($row = $q->grab()) {
+ if ($value == '' and $row['Regex'] and
+ preg_match($row['Regex'],$GLOBALS['HTTP_USER_AGENT'])) $sel = ' selected';
+ elseif ($value == $row[$box.'ID']) $sel = ' selected';
+ else $sel = '';
+ $text .= '<option value="'.
+ $row[$box.'_id']."\"$sel>".$row[$box.'_name']."</option>";
+ }
+ break;
+ case 'owner' :
+ $q->query("Select user_id, email from user where user_level > 1 order by email");
+ while ($row = $q->grab()) {
+ if ($value == $row['user_id']) $sel = ' selected';
+ else $sel = '';
+ $text .= "<option value=\"{$row['user_id']}\"$sel>{$row['email']}</option>";
+ }
+ break;
+ default :
+ $deadarray = $select[$box];
+ while(list($val,$item) = each($deadarray)) {
+ if ($value == $val and $value != '') $sel = ' selected';
+ else $sel = '';
+ $text .= "<option value=\"$val\"$sel>$item</option>";
+ }
+ break;
+ }
+ return $text;
}
///
/// Divide the results of a database query into multiple pages
function multipages($nr, $page, $urlstr) {
- global $me, $selrange;
-
- if (!$page) $page = 1;
- if ($page == 'all') {
- $selrange = $nr;
- $llimit = 0;
- $page = 0;
- } else {
- #$selrange = 60;
- $llimit = ($page-1)*$selrange;
- }
- if ($nr) $npages = ceil($nr/$selrange);
- else $npages = 0;
- if ($npages == 1) $pages = 1;
- else {
- for ($i=1; $i<=$npages; $i++) {
- $pages .= $i != $page ? " <a href='$me?page=$i&$urlstr'>$i</a> " : " $i ";
- $pages .= $i != $npages ? '|' : '';
- }
- }
- return array($selrange, $llimit, $npages, $pages);
+ global $me, $selrange;
+
+ if (!$page) $page = 1;
+ if ($page == 'all') {
+ $selrange = $nr;
+ $llimit = 0;
+ $page = 0;
+ } else {
+ #$selrange = 60;
+ $llimit = ($page-1)*$selrange;
+ }
+ if ($nr) $npages = ceil($nr/$selrange);
+ else $npages = 0;
+ if ($npages == 1) $pages = 1;
+ else {
+ for ($i=1; $i<=$npages; $i++) {
+ $pages .= $i != $page ? " <a href='$me?page=$i&$urlstr'>$i</a> " : " $i ";
+ $pages .= $i != $npages ? '|' : '';
+ }
+ }
+ return array($selrange, $llimit, $npages, $pages);
}
-///
+///
/// Sets variables in the templates for the column headers to sort database results
function sorting_headers($url, $headers, $order, $sort, $urlstr = '') {
- global $t;
-
- while(list($k, $v) = each($headers)) {
- $t->set_var($k.'url', "$url?order=$v&sort=".
- ($order == $v ? ($sort == 'asc' ? 'desc' : 'asc') : 'asc').
- ($urlstr ? '&'.$urlstr : ''));
- $t->set_var($k.'color', $order == $v ? '#bbbbbb' : '#eeeeee');
- }
+ global $t;
+
+ while(list($k, $v) = each($headers)) {
+ $t->set_var($k.'url', "$url?order=$v&sort=".
+ ($order == $v ? ($sort == 'asc' ? 'desc' : 'asc') : 'asc').
+ ($urlstr ? '&'.$urlstr : ''));
+ $t->set_var($k.'color', $order == $v ? '#bbbbbb' : '#eeeeee');
+ }
}
///
/// Generates a somewhat random pronounceable password $length letters long
/// (From zend.com user Rival7)
-function genpassword($length){
+function genpassword($length){
- srand((double)microtime()*1000000);
+ srand((double)microtime()*1000000);
- $vowels = array("a", "e", "i", "o", "u");
- $cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr",
+ $vowels = array("a", "e", "i", "o", "u");
+ $cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr",
- "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl");
+ "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl");
- $num_vowels = count($vowels);
- $num_cons = count($cons);
+ $num_vowels = count($vowels);
+ $num_cons = count($cons);
- for($i = 0; $i < $length; $i++){
- $password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)];
- }
+ for($i = 0; $i < $length; $i++){
+ $password .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)];
+ }
- return substr($password, 0, $length);
-}
+ return substr($password, 0, $length);
+}
///
/// Wrap text - Picked up somewhere on the net - probably zend.com
function textwrap($text, $wrap=72, $break="\n"){
- $len = strlen($text);
- if ($len > $wrap) {
- $h = '';
- $lastWhite = 0;
- $lastChar = 0;
- $lastBreak = 0;
- while ($lastChar < $len) {
- $char = substr($text, $lastChar, 1);
- if (($lastChar - $lastBreak > $wrap) && ($lastWhite > $lastBreak)) {
- $h .= substr($text, $lastBreak, ($lastWhite - $lastBreak)) . $break;
- $lastChar = $lastWhite + 1;
- $lastBreak = $lastChar;
- }
- /* You may wish to include other characters as valid whitespace... */
- if ($char == ' ' || $char == chr(13) || $char == chr(10))
- $lastWhite = $lastChar;
- $lastChar = $lastChar + 1;
- }
- $h .= substr($text, $lastBreak);
- }
- else $h = $text;
- return $h;
+ $len = strlen($text);
+ if ($len > $wrap) {
+ $h = '';
+ $lastWhite = 0;
+ $lastChar = 0;
+ $lastBreak = 0;
+ while ($lastChar < $len) {
+ $char = substr($text, $lastChar, 1);
+ if (($lastChar - $lastBreak > $wrap) && ($lastWhite > $lastBreak)) {
+ $h .= substr($text, $lastBreak, ($lastWhite - $lastBreak)) . $break;
+ $lastChar = $lastWhite + 1;
+ $lastBreak = $lastChar;
+ }
+ /* You may wish to include other characters as valid whitespace... */
+ if ($char == ' ' || $char == chr(13) || $char == chr(10))
+ $lastWhite = $lastChar;
+ $lastChar = $lastChar + 1;
+ }
+ $h .= substr($text, $lastBreak);
+ }
+ else $h = $text;
+ return $h;
}
///
/// Return a delimited list if there is more than one element in $ary, otherwise
/// return the lone element as the list
function delimit_list($delimiter, $ary) {
- if ($ary[1]) return join($delimiter, $ary);
- elseif ($ary[0]) return ($ary[0]);
- else return '';
+ if ($ary[1]) return join($delimiter, $ary);
+ elseif ($ary[0]) return ($ary[0]);
+ else return '';
}
///
/// Check the validity of an email address
/// (From zend.com user russIndr)
-function valid_email($email) {
- return eregi('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$', $email);
+function valid_email($email) {
+ return eregi('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$', $email);
}
///
/// If the constant is set do a little email masking to make harvesting a little harder
function maskemail($email) {
- global $auth;
-
- if (HIDE_EMAIL && $auth->auth['uid'] == 'nobody') {
- return '******';
- } elseif (MASK_EMAIL) {
- return str_replace('@', ' at ', str_replace('.', ' dot ', $email));
- } else {
- return $email;
- }
+ global $auth;
+
+ if (HIDE_EMAIL && $auth->auth['uid'] == 'nobody') {
+ return '******';
+ } elseif (MASK_EMAIL) {
+ return str_replace('@', ' at ', str_replace('.', ' dot ', $email));
+ } else {
+ return $email;
+ }
}
// Begin every page with a page_open
if (!defined('NO_AUTH')) {
- page_open(array('sess' => 'usess', 'auth' => 'uauth', 'perm' => 'uperm'));
- $u = $auth->auth['uid'];
+ page_open(array('sess' => 'usess', 'auth' => 'uauth', 'perm' => 'uperm'));
+ $u = $auth->auth['uid'];
}
// Check to see if the user is trying to login
if (isset($HTTP_POST_VARS['login'])) {
- if (isset($HTTP_POST_VARS['sendpass'])) {
- list($email, $password) = $q->grab("select email, password from user where email = '$username' and user_level > 0");
- if (!$q->num_rows()) {
- $t->set_var(array(
- 'loginerrorcolor' => '#ff0000',
- 'loginerror' => 'Invalid login<br>'
- ));
- } else {
- if (ENCRYPTPASS) {
- $password = genpassword(10);
- $mpassword = md5($password);
- $q->query("update user set password = '$mpassword' where email = '$username'");
- }
- mail($email, $STRING['newacctsubject'], sprintf($STRING['newacctmessage'],
- $password), 'From: '.ADMINEMAIL);
- $t->set_var(array(
- 'loginerrorcolor' => '#0000ff',
- 'loginerror' => 'Your password has been emailed to you<br>'
- ));
- }
- } else {
- $auth->auth['uid'] = $auth->auth_validatelogin();
- if ($auth->auth['uid'] == 'nobody') {
- $t->set_var(array(
- 'loginerrorcolor' => '#ff0000',
- 'loginerror' => 'Invalid login<br>'
- ));
- }
- }
+ if (isset($HTTP_POST_VARS['sendpass'])) {
+ list($email, $password) = $q->grab("select email, password from user where email = '$username' and user_level > 0");
+ if (!$q->num_rows()) {
+ $t->set_var(array(
+ 'loginerrorcolor' => '#ff0000',
+ 'loginerror' => 'Invalid login<br>'
+ ));
+ } else {
+ if (ENCRYPTPASS) {
+ $password = genpassword(10);
+ $mpassword = md5($password);
+ $q->query("update user set password = '$mpassword' where email = '$username'");
+ }
+ mail($email, $STRING['newacctsubject'], sprintf($STRING['newacctmessage'],
+ $password), 'From: '.ADMINEMAIL);
+ $t->set_var(array(
+ 'loginerrorcolor' => '#0000ff',
+ 'loginerror' => 'Your password has been emailed to you<br>'
+ ));
+ }
+ } else {
+ $auth->auth['uid'] = $auth->auth_validatelogin();
+ if ($auth->auth['uid'] == 'nobody') {
+ $t->set_var(array(
+ 'loginerrorcolor' => '#ff0000',
+ 'loginerror' => 'Invalid login<br>'
+ ));
+ }
+ }
}
-?>
+?>
\ No newline at end of file
|