cvs: bugtracker /htdocs .htaccess config.php /htdocs/elements screen.css /htdocs/index index.php /includes database_mysql.php database_mysqli.php
functions.php user.php /includes/cache status.php user.php /template/generic header.html /template/generic/bug index.php /template/generic/user
convert.php login.php

From: Date: Wed, 16 Jul 2008 04:19:21 +0000
Subject: cvs: bugtracker /htdocs .htaccess config.php /htdocs/elements screen.css /htdocs/index index.php /includes database_mysql.php database_mysqli.php
functions.php user.php /includes/cache status.php user.php /template/generic header.html /template/generic/bug index.php /template/generic/user
convert.php login.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-2113@lists.php.net to get a copy of this message
bcarlyon Wed Jul 16 04:19:21 2008 UTC Added files: /bugtracker/template/generic/user convert.php login.php Modified files: /bugtracker/htdocs .htaccess config.php /bugtracker/htdocs/elements screen.css /bugtracker/htdocs/index index.php /bugtracker/includes database_mysql.php database_mysqli.php functions.php user.php /bugtracker/includes/cache status.php user.php /bugtracker/template/generic header.html /bugtracker/template/generic/bug index.php Log: Adding broken temp -> real user convert But adding with Backtrace with sensible output Added catch error which usually results in a white page Also borrowed the pearweb error display box Added catch if bug_uid does not exist, give a nice error Bug fixed the database files a little, added functions for data protect, (todo proper protect for mysql) Added the user files, changed location of the login page Convert as is (broken) Login working to push to convert and check auth against the database Convert is to be working later today if not early tomorrow UK time

http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/.htaccess?r1=1.1&r2=1.2&diff_format=u Index: bugtracker/htdocs/.htaccess diff -u bugtracker/htdocs/.htaccess:1.1 bugtracker/htdocs/.htaccess:1.2 --- bugtracker/htdocs/.htaccess:1.1 Wed Jul 9 13:07:21 2008 +++ bugtracker/htdocs/.htaccess Wed Jul 16 04:19:20 2008 @@ -7,10 +7,15 @@ #smaller rewrites, higher priority you know RewriteRule bug/(.*)$ index/index.php?page=bug&bug_id=$1&%{QUERY_STRING} [L,PT] -#the big rewrite -RewriteRule (.*)$ index/index.php?page=$1&%{QUERY_STRING} [L,PT] #Some shuntage RedirectPermanent /gifs http://bugs.php.net/gifs RedirectPermanent /style.css http://bugs.php.net/style.css RedirectPermanent /source.php http://bugs.php.net/source.php + +#Other shuntage +RewriteRule ^login/$ /user/login/ [L,PT] + +#the big rewrite +RewriteRule (.*)$ index/index.php?page=$1&%{QUERY_STRING} [L,PT] + http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/config.php?r1=1.2&r2=1.3&diff_format=u Index: bugtracker/htdocs/config.php diff -u bugtracker/htdocs/config.php:1.2 bugtracker/htdocs/config.php:1.3 --- bugtracker/htdocs/config.php:1.2 Thu Jul 10 20:56:41 2008 +++ bugtracker/htdocs/config.php Wed Jul 16 04:19:20 2008 @@ -10,11 +10,18 @@ ); define('CONFIG_ARRAY','configuration'); -define('USER_TABLE','bug_user'); +define('USER_TABLE','user'); +define('TEMP_USER_TABLE','temp_account'); $recaptcha_key = '6LdlXwAAAAAAAA_SQn5B7hqK8bd3mrBERvmbvsZO'; $recaptcha_prv = '6LdlXwAAAAAAAD5Tvwhyk0I2GKVgJE5UonW3oYDY'; +$cookie = array(); +$cookie['name'] = 'phpbugz'; +$cookie['host'] = str_replace('www.','',$_SERVER['HTTP_HOST']); +$cookie['script_path'] = '/'; +$cookie['secure'] = 0; + if ($database['type'] == 'mysqli') { include($_SERVER['DOCUMENT_ROOT'] . '../includes/database_mysqli.php'); http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/elements/screen.css?r1=1.3&r2=1.4&diff_format=u Index: bugtracker/htdocs/elements/screen.css diff -u bugtracker/htdocs/elements/screen.css:1.3 bugtracker/htdocs/elements/screen.css:1.4 --- bugtracker/htdocs/elements/screen.css:1.3 Fri Jul 11 13:14:18 2008 +++ bugtracker/htdocs/elements/screen.css Wed Jul 16 04:19:20 2008 @@ -101,6 +101,7 @@ .form label { float: left; font-weight: 700; + cursor: pointer; } .slim, #bug { width: 550px; @@ -173,3 +174,14 @@ float: right; } +#error { + clear: both; + font-size: 108%; + font-weight: bold; + padding: 1.0em !important; + border: 1px solid #660000; + margin: 1.0em !important; + background: #fee; + color: #660000; +} + http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/index/index.php?r1=1.5&r2=1.6&diff_format=u Index: bugtracker/htdocs/index/index.php diff -u bugtracker/htdocs/index/index.php:1.5 bugtracker/htdocs/index/index.php:1.6 --- bugtracker/htdocs/index/index.php:1.5 Fri Jul 11 13:47:16 2008 +++ bugtracker/htdocs/index/index.php Wed Jul 16 04:19:20 2008 @@ -7,10 +7,14 @@ License: ***********************************************************/ +//backtrace has something to talk too +$template_data = array('backtrace' => ''); //before we start lets see if the database engine is online include($_SERVER['DOCUMENT_ROOT'] . '/config.php'); include($_SERVER['DOCUMENT_ROOT'] . '../includes/functions.php'); +$errorhandler = set_error_handler("itsanerrorhandler",E_ALL&~E_NOTICE); + //database time $db = new db(); $dbtest = $db->test_connect(); @@ -63,7 +67,7 @@ closedir($handle); } $form_data = array();//array for holding the data in forms -$template_data = array( +$template_data = array_merge($template_data, array( 'page_title' => 'PHP Bugs', 'year' => date('Y',time()), 'url' => ($_REQUEST['page']) ? $_REQUEST['page'] : 'home', @@ -71,6 +75,8 @@ 'login' => '<li><a href="/account-request.php">Register</a></li>' . "\n" . '<li><a href="/login.php?redirect=">Login</a></li>', 'login' => "\n" . '<li><a href="/login/">Login</a></li>', 'favicon' => '', + 'form_error' => '', + ) ); $template_data['cvs_version'] = substr( $php_version[sizeof($php_version)] ,0,4); if ($template != 'php') @@ -81,6 +87,8 @@ } //now then is the user logged in? +$user->check_auth(); + $user_data = array(); //default is the user is not, will auth in a moment $template_data['if logged_in'] = '<!--'; @@ -154,7 +162,7 @@ $template_data['queries'] = $db->query_count; -$content = tpl_process('generic/header.html', TRUE, $jsscripts, $meta_refresh) . $content . tpl_process('generic/footer.html'); +$content = tpl_process('generic/header.html', TRUE, $jsscripts, $meta_refresh) . $content . '<br />' . tpl_process('generic/footer.html'); $content = str_replace('<table','<table cellspacing="0" cellpadding="0"',$content); @@ -179,6 +187,20 @@ $db->close(); unset($db); +echo '<textarea style="width: 95%; height: 200px; border: 1px solid #000;" rows="10" cols="50">debug: ' . "\n"; + +echo ' +cookie +'; +print_r($_COOKIE); + +echo ' +tpl +'; +print_r($template_data); + +echo '</textarea>'; + echo ' </body> </html> http://cvs.php.net/viewvc.cgi/bugtracker/includes/database_mysql.php?r1=1.2&r2=1.3&diff_format=u Index: bugtracker/includes/database_mysql.php diff -u bugtracker/includes/database_mysql.php:1.2 bugtracker/includes/database_mysql.php:1.3 --- bugtracker/includes/database_mysql.php:1.2 Thu Jul 10 20:56:41 2008 +++ bugtracker/includes/database_mysql.php Wed Jul 16 04:19:20 2008 @@ -3,6 +3,7 @@ //class class db { public $query_count = 0; + public $query = ''; function test_connect() { global $database; @@ -29,6 +30,12 @@ return $data; } function get_data($query) { + if (!$query) + { + global $content; + $content .= '<div id="error">No Query</div>'; + return; + } $query = str_replace(array('"NOW()"',"'NOW()'"),'NOW()',$query); $this->query = $query; http://cvs.php.net/viewvc.cgi/bugtracker/includes/database_mysqli.php?r1=1.2&r2=1.3&diff_format=u Index: bugtracker/includes/database_mysqli.php diff -u bugtracker/includes/database_mysqli.php:1.2 bugtracker/includes/database_mysqli.php:1.3 --- bugtracker/includes/database_mysqli.php:1.2 Thu Jul 10 20:56:41 2008 +++ bugtracker/includes/database_mysqli.php Wed Jul 16 04:19:20 2008 @@ -3,6 +3,7 @@ //class class db { public $query_count = 0; + public $query = ''; function test_connect() { global $database; @@ -31,6 +32,12 @@ return $data; } function get_data($query) { + if (!$query) + { + global $content; + $content .= '<div id="error">No Query</div>'; + return; + } $query = str_replace(array('"NOW()"',"'NOW()'"),'NOW()',$query); // $query = mysqli_real_escape_string($this->connect_id,$query); $this->query = $query; @@ -71,7 +78,7 @@ } function handle_error($error = '') { global $content; - $content .= "<br /><br /><b>Error " . mysqli_errno($this->connect_id) . " : ". mysqli_error($this->connect_id) . ' - ' . $this->query . '</b><br /><br />'; + $content .= '<div id="error">Error ' . mysqli_errno($this->connect_id) . " : ". mysqli_error($this->connect_id) . ' - ' . $this->query . '</div>'; return; } function close() { http://cvs.php.net/viewvc.cgi/bugtracker/includes/functions.php?r1=1.6&r2=1.7&diff_format=u Index: bugtracker/includes/functions.php diff -u bugtracker/includes/functions.php:1.6 bugtracker/includes/functions.php:1.7 --- bugtracker/includes/functions.php:1.6 Fri Jul 11 13:47:16 2008 +++ bugtracker/includes/functions.php Wed Jul 16 04:19:20 2008 @@ -22,6 +22,13 @@ } foreach ($template_data as $ref => $replace) { + if ($ref == 'form_error' && $replace) + { + if (!strpos('class="error"',$replace)) + { + $replace = '<div id="error">' . $replace . '</div>'; + } + } $html = str_replace('{' . strtoupper($ref) . '}',$replace,$html); } foreach ($form_data as $ref => $replace) @@ -36,6 +43,14 @@ } else { + if ($ref == 'form_error') + { + //check for div + if (!strpos('class="error"',$replace)) + { + $replace = '<div id="error">' . $replace . '</div>'; + } + } $html = str_replace('{' . strtoupper($ref) . '}',$replace,$html); } } @@ -96,3 +111,64 @@ return false; } +//error control + +function itsanerrorhandler($errno, $errstr, $errfile, $errline) +{ +global $template_data; +$fail = ''; + switch ($errno) { + case E_USER_ERROR: + echo "<b>My ERROR</b> [$errno] $errstr<br />\n"; + echo " Fatal error on line $errline in file $errfile"; + echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n"; + echo "Aborting...<br />\n"; + exit(1); + break; + + case E_USER_WARNING: + $fail = "<b>My WARNING</b> [$errno] $errstr<br />\n"; + break; + + case E_USER_NOTICE: + $fail = "<b>My NOTICE</b> [$errno] $errstr<br />\n"; + break; + + default: + $fail = "Unknown error type: [$errno] $errstr<br />\n"; + break; + } + + $template_data['backtrace'] .= '<strong>' . $fail . '</strong>'; + errorarray(debug_backtrace()); + $template_data['backtrace'] = '<div id="error">' . $template_data['backtrace'] . '</div>'; + + return; +} + +function errorarray($array) +{ + global $template_data; + foreach ($array as $ref => $data) + { + $template_data['backtrace'] .= '<br />'; + if (!is_numeric($ref)) + { + $template_data['backtrace'] .= $ref. ': '; + } + if (get_class($data)) + { + $template_data['backtrace'] .= get_class($data); + } + else if (is_array($data)) + { + errorarray($data); + } + else + { + $template_data['backtrace'] .= $data; + } + } + + return; +} http://cvs.php.net/viewvc.cgi/bugtracker/includes/user.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/user.php diff -u bugtracker/includes/user.php:1.4 bugtracker/includes/user.php:1.5 --- bugtracker/includes/user.php:1.4 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/user.php Wed Jul 16 04:19:20 2008 @@ -3,13 +3,29 @@ //users class class user { public $logged_in = FALSE; + public $logged_in_temp = FALSE; + public $handle = ''; function check_auth() { - global $system_data; + global $cookie; //read cookie - //check - //logged in logged out - $this->logged_in = FALSE; + if (isset($_COOKIE[$cookie['name']])) + { + $data = $_COOKIE[$cookie['name']]; + $data = explode('=',$data); + if ($data[0] == 'handle') + { + $this->logged_in_temp = TRUE; + $this->handle = $data[1]; + //no further auth required + } +/* +$template_data['login'] = ' +<li><a href="/profile/">' . $this->handle . '</a></li> +<li><a href="/logout/">Logout</a></li> +'; +*/ + } return; } @@ -123,42 +139,134 @@ } return; } - function register() { - global $profile_data; - //check to see if the user exists first - //using the user cache - if (is_array($users)) + function register($user_data) { + global $db,$email; + + //this will create a user, BUT WILL NOT CHECK IT EXISTS FIRST + //assumes done prior to calling this function + + $user_data['temp_handle'] = ''; + unset($user_data['temp_handle']); + $query = 'INSERT INTO ' . USER_TABLE . ' (' . implode(', ', array_keys($user_data)) . ', registered) VALUES ("'; + foreach (array_values($user_data) as $data) + { + $query .= $db->protect_data($data); + $query .= '","'; + } +// $query = substr($query,0,-2); + $query = substr($query,0,-1); + $query .= 'NOW())'; + + $db->get_data($query); + + if ($this->fetch_handle($user_data['handle'])) { - //cache exists - if (in_array($profile_data['username'],$users)) - { - //username is in cache and thus exists - } + //email time + $dest = $user_data['email']; + $subject = 'PHP Bugz Account Conversion'; + $message = 'You or someone else has converted your http://bugs.php.net/ Account to a full account'; + $message .= "\n\r" . 'In order to continue you will need to verfiy your email address'; + $message .= "\n\r" . 'Click the following link, or copy and paste it into your browser'; + $message .= "\n\r\n\r"; + + $message .= "\n\r\n\r"; + + $email->send_to_user($dest,$subject,$message); } + return TRUE; } function login($user,$password) { - global $system_data,$template_data; + global $template_data,$db; //lets authenticate the user - $query = 'SELECT * FROM ' . USER_TABLE . " WHERE username = '{$user}'"; - $result = getdata($query); - if (mysql_num_rows($result)) - { - //user authenticated - //write cookie - //update $system - //go for redirect - header('Location: http://' . $_SERVER['HTTP_HOST'] . '/' . $template_data['return']); - return TRUE; + $query = 'SELECT * FROM ' . USER_TABLE . ' WHERE handle = \'' . $db->protect_data($user) . '\' AND password = \'' . $password . '\''; + $db->get_data($query); + $valid = $db->total_rows; + + //try email + $query = 'SELECT * FROM ' . USER_TABLE . ' WHERE email = \'' . $db->protect_data($user) . '\' AND password = \'' . $password . '\''; + $db->get_data($query); + $valid = ($valid) ? $valid : $db->total_rows; + + if ($valid) + { + //so lets make sure we have this right + $user = $db->fetch_row(); + $this->handle = $user['handle']; + if ($this->write_cookie('',$template_data['return'])) + { + return TRUE; + } + $template_data['form_error'] = '<div id="error">The Cookie could not be set</div>'; } - else + + //try temp + $query = 'SELECT * FROM ' . TEMP_USER_TABLE . ' WHERE handle = \'' . $db->protect_data($user) . '\' AND password = \'' . $password . '\''; + $db->get_data($query); + $valid = $db->total_rows; + $query = 'SELECT * FROM ' . TEMP_USER_TABLE . ' WHERE email = \'' . $db->protect_data($user) . '\' AND password = \'' . $password . '\''; + $db->get_data($query); + $valid = ($valid) ? $valid : $db->total_rows; + if ($valid) { - //not authed - $template_data['form_error'] = '<strong>Your User Credentials could not be Validated</strong><br /><br />'; + $user = $db->fetch_row(); + $this->handle = $user['handle']; + //temp account login! + //set a cookie + if ($this->write_cookie(array('handle' => $this->handle),TEMP_ACCOUNT)) + { + //convert? + header('Location: /user/convert/'); + //not sure if this generates an error ^^ but it worked fine... + return TRUE; + } + else + { + $template_data['form_error'] = '<div id="error">The Cookie could not be set</div>'; + return FALSE; + } } + + unset($password); + //not authed + $template_data['form_error'] = '<div id="error">Your User Credentials could not be Validated</div>'; return FALSE; } - function fetch_handle($search) { - + function write_cookie($user_data, $type = 'user', $redirect = FALSE) + { + global $cookie; + if ($type == TEMP_ACCOUNT) + { + if (setcookie($cookie['name'], 'handle=' . $this->handle, time() + 120, $cookie['script_path'], $cookie['host'], $cookie['secure'])) + { + return TRUE; + } + } + else if (setcookie('php_bugz','temp',time() + (15*60), '/', str_replace('www.','',$_SERVER['HTTP_HOST']), 0)) + { + $this->logged_in = TRUE; + if ($redirect) + { + header('Location: ' . $redirect); + } + return TRUE; + } + return FALSE; + } + function fetch_handle($search,$mode = 'exist') { + global $db; + //its a search function + if ($mode == 'exist') + { + //first lets see if the search is a handle + //in order to do this we will go straight to the database + $query = 'SELECT * FROM ' . USER_TABLE . ' WHERE handle = \'' . $db->protect_data($search) . '\''; + $db->get_data($query); + if ($db->total_rows) + { + return TRUE; + } + } + return FALSE; } function update_password($password,$email,$handle = '',$mode = '') { global $db; http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/status.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/status.php diff -u bugtracker/includes/cache/status.php:1.4 bugtracker/includes/cache/status.php:1.5 --- bugtracker/includes/cache/status.php:1.4 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/cache/status.php Wed Jul 16 04:19:20 2008 @@ -2,7 +2,7 @@ $status[0] = "Pending"; $status[1] = "Bogus"; - $status[3] = "Is Bug"; + $status[2] = "Is Bug"; foreach($status as $ref => $data) { http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/user.php?r1=1.3&r2=1.4&diff_format=u Index: bugtracker/includes/cache/user.php diff -u bugtracker/includes/cache/user.php:1.3 bugtracker/includes/cache/user.php:1.4 --- bugtracker/includes/cache/user.php:1.3 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/cache/user.php Wed Jul 16 04:19:20 2008 @@ -1,2 +1,5 @@ <?php + $users["Tbarry_barrycarlyon"]["handle"] = "Tbarry_barrycarlyon"; + $users["Tbarry_barrycarlyon"]["email"] = "barry@barrycarlyon.co.uk"; + http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/header.html?r1=1.1&r2=1.2&diff_format=u Index: bugtracker/template/generic/header.html diff -u bugtracker/template/generic/header.html:1.1 bugtracker/template/generic/header.html:1.2 --- bugtracker/template/generic/header.html:1.1 Wed Jul 9 13:07:22 2008 +++ bugtracker/template/generic/header.html Wed Jul 16 04:19:20 2008 @@ -59,3 +59,5 @@ <input type="image" src="/gifs/small_submit_white.gif" onclick="window.location = '/bug/' + document.getElementById('searchfor').value;"/> </div> +{BACKTRACE} + http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/bug/index.php?r1=1.7&r2=1.8&diff_format=u Index: bugtracker/template/generic/bug/index.php diff -u bugtracker/template/generic/bug/index.php:1.7 bugtracker/template/generic/bug/index.php:1.8 --- bugtracker/template/generic/bug/index.php:1.7 Fri Jul 11 13:14:18 2008 +++ bugtracker/template/generic/bug/index.php Wed Jul 16 04:19:20 2008 @@ -2,12 +2,6 @@ $bug_id = $_REQUEST['bug_id']; $bug_id = str_replace('/','',$bug_id); -/* -if (substr($bug_id,-1) == '/') -{ - $bug_id = -} -*/ if (substr($bug_id,0,8) == 'download') { @@ -34,92 +28,101 @@ if (is_numeric($bug_id)) { - -$query = "SELECT *,UNIX_TIMESTAMP(reported_on),UNIX_TIMESTAMP(assigned_on),UNIX_TIMESTAMP(updated) FROM bug WHERE bug_id = '{$bug_id}'"; -$db->get_data($query); -$row = $db->fetch_row(); -$bug = $row; - -//get comments -$query = "SELECT * FROM bug_comment WHERE bug_id = '{$bug_id}' AND ( comment_type = " . DESCRIPTION . ' OR comment_type = ' . REPRODUCE . ' OR comment_type = ' . EXPECTED . ' OR comment_type = ' . ACTUAL . ')'; -$db->get_data($query); -$comments = array(); -while ($entry = $db->fetch_row()) -{ - $comments[$comment_type[$entry['comment_type']]] = $entry['comment']; -} -$bug = array_merge($bug, $comments); - -$row['password'] = ''; - -$template_data['page_title'] .= ' - #' . $bug['bug_id'] . ' ' . $bug['summary']; - -$content .= '<h2>Bug Display</h2>'; -$content .= '<table id="bug">'; - -$content .= '<tr><td style="width: 100px;">Bug: #' . $bug['bug_id'] . '</td><td style="width: 200px;">' . $bug['summary'] . '</td><td>Reported By: <strong>' . $bug['reported_by'] . '</strong></td></tr>'; -$content .= '<tr><td>'; - -// $content .= '<img src="/images/bug_status/' . $status[$bug['status']] . '.png" alt="' . $status[$bug['status']] . '" />'; - $content .= '<h4>' . $status[$bug['status']] . '</h4>'; -$content .= '</td><td colspan="2">Opened: ' . date('d/m/Y h:i O',$bug['UNIX_TIMESTAMP(reported_on)']) . '<br />'; - if ($bug['UNIX_TIMESTAMP(updated)'] != $bug['UNIX_TIMESTAMP(reported_on)']) - { - $content .= 'Last Updated: ' . date('d/m/Y h:i O',$bug['UNIX_TIMESTAMP(updated)']) . '<br />';; + $query = "SELECT *,UNIX_TIMESTAMP(reported_on),UNIX_TIMESTAMP(assigned_on),UNIX_TIMESTAMP(updated) FROM bug WHERE bug_id = '{$bug_id}'"; + $db->get_data($query); + $row = $db->fetch_row(); + + if (!$db->total_rows) + { + $content .= '<h2>Bug Display</h2>'; + $template_data['form_error'] = 'The ID you supplied is invalid, the bug does not exist.'; + $content .= '{FORM_ERROR}'; + $content = tpl_process($content,FALSE); } - if ($bug['status'] != 0) + else { - $content .= 'Assigned to: <strong>' . $bug['assigned_to'] . '</strong><br />'; - $content .= 'Assigned on: ' . date('d/m/Y h:i O',$bug['UNIX_TIMESTAMP(assigned_on)']); - } -$content .= '</td></tr>'; - -$content .= '<tr><td></td><td style="text-align: right;">Version:</td><td>' . $php_version[$bug['php_version']] . '</td></tr>'; -$content .= '<tr><td></td><td style="text-align: right;">Type:</td><td>' . $bug_type[$bug['bug_type']] . '</td></tr>'; -$content .= '<tr><td></td><td style="text-align: right;">OS:</td><td>' . $os_version[$bug['os_version']] . '</td></tr>'; - -$content .= '<tr><td></td><td colspan="2">'; -$content .= $bug['description']; -$content .= '<br />&nbsp;'; - -$content .= '</td></tr>'; -if (isset($bug['reproduce'])) -{ - $content .= "\n"; - //render a fancy line number box - $jsscripts[] = '/elements/js/lineno.js'; - $content .= '<tr><td></td><td colspan="2" style="display: none;" id="reproduce_link"><a href="javascript:handleClick(\'reproduce_code\');handleClick(\'reproduce_link\');">Show Reproduce Code and Results</a></td></tr>'; -// $content .= '<tr><td></td><td colspan="2" style="display: block;" id="reproduce_code">'; - $content .= '<tr><td></td><td colspan="2" id="reproduce_code">'; - $content .= '<h5>Reproduce Code</h5>'; - $content .= '<a href="javascript:handleClick(\'reproduce_code\');handleClick(\'reproduce_link\');" class="lineno">Hide Code and Results</a>'; - $content .= '<a href="javascript:selectText(\'reproduce\');" title="Select Code" class="textselect">Select Code</a>'; - $content .= '<a href="/bug/download/' . $bug['bug_id'] . '/" title="Download Code" class="textselect">Download</a>'; - $content .= '<textarea id="reproduce" rows="7" cols="55">' . $bug['reproduce'] . '</textarea>'; - //given reporduce assume other, expected and actual - //need a swtich in the db for line numbers or dyn generate? - $content .= '<hr />'; - $content .= '<h5>Expected Result</h5>'; - $content .= '<textarea id="expected" rows="7" cols="55">' . $bug['expected'] . '</textarea>'; - $content .= '<hr />'; - $content .= '<a href="javascript:createTextAreaWithLines(\'expected\');" class="lineno">Add Line Numbers</a>'; - $content .= '<hr />'; - $content .= '<h5>Actual Result</h5>'; - $content .= '<textarea id="actual" rows="7" cols="55">' . $bug['actual'] . '</textarea>'; - $content .= '<hr />'; - $content .= '<a href="javascript:createTextAreaWithLines(\'actual\');" class="lineno">Add Line Numbers</a>'; - $content .= '</td></tr>'; - $content .= "\n"; -} - -//here be the comment controller -$comment->spawn_form(); - -$content .= '</table><br /><hr /><hr />'; - -if (isset($bug['reproduce'])) -{ - $content .= ' + $bug = $row; + + //get comments + $query = "SELECT * FROM bug_comment WHERE bug_id = '{$bug_id}' AND ( comment_type = " . DESCRIPTION . ' OR comment_type = ' . REPRODUCE . ' OR comment_type = ' . EXPECTED . ' OR comment_type = ' . ACTUAL . ')'; + $db->get_data($query); + $comments = array(); + while ($entry = $db->fetch_row()) + { + $comments[$comment_type[$entry['comment_type']]] = $entry['comment']; + } + $bug = array_merge($bug, $comments); + + $row['password'] = ''; + + $template_data['page_title'] .= ' - #' . $bug['bug_id'] . ' ' . $bug['summary']; + + $content .= '<h2>Bug Display</h2>'; + $content .= '<table id="bug">'; + + $content .= '<tr><td style="width: 100px;">Bug: #' . $bug['bug_id'] . '</td><td style="width: 200px;">' . $bug['summary'] . '</td><td>Reported By: <strong>' . $bug['reported_by'] . '</strong></td></tr>'; + $content .= '<tr><td>'; + + // $content .= '<img src="/images/bug_status/' . $status[$bug['status']] . '.png" alt="' . $status[$bug['status']] . '" />'; + $content .= '<h4>' . $status[$bug['status']] . '</h4>'; + $content .= '</td><td colspan="2">Opened: ' . date('d/m/Y h:i O',$bug['UNIX_TIMESTAMP(reported_on)']) . '<br />'; + if ($bug['UNIX_TIMESTAMP(updated)'] != $bug['UNIX_TIMESTAMP(reported_on)']) + { + $content .= 'Last Updated: ' . date('d/m/Y h:i O',$bug['UNIX_TIMESTAMP(updated)']) . '<br />';; + } + if ($bug['status'] != 0) + { + $content .= 'Assigned to: <strong>' . $bug['assigned_to'] . '</strong><br />'; + $content .= 'Assigned on: ' . date('d/m/Y h:i O',$bug['UNIX_TIMESTAMP(assigned_on)']); + } + $content .= '</td></tr>'; + + $content .= '<tr><td></td><td style="text-align: right;">Version:</td><td>' . $php_version[$bug['php_version']] . '</td></tr>'; + $content .= '<tr><td></td><td style="text-align: right;">Type:</td><td>' . $bug_type[$bug['bug_type']] . '</td></tr>'; + $content .= '<tr><td></td><td style="text-align: right;">OS:</td><td>' . $os_version[$bug['os_version']] . '</td></tr>'; + + $content .= '<tr><td></td><td colspan="2">'; + $content .= $bug['description']; + $content .= '<br />&nbsp;'; + + $content .= '</td></tr>'; + if (isset($bug['reproduce'])) + { + $content .= "\n"; + //render a fancy line number box + $jsscripts[] = '/elements/js/lineno.js'; + $content .= '<tr><td></td><td colspan="2" style="display: none;" id="reproduce_link"><a href="javascript:handleClick(\'reproduce_code\');handleClick(\'reproduce_link\');">Show Reproduce Code and Results</a></td></tr>'; + // $content .= '<tr><td></td><td colspan="2" style="display: block;" id="reproduce_code">'; + $content .= '<tr><td></td><td colspan="2" id="reproduce_code">'; + $content .= '<h5>Reproduce Code</h5>'; + $content .= '<a href="javascript:handleClick(\'reproduce_code\');handleClick(\'reproduce_link\');" class="lineno">Hide Code and Results</a>'; + $content .= '<a href="javascript:selectText(\'reproduce\');" title="Select Code" class="textselect">Select Code</a>'; + $content .= '<a href="/bug/download/' . $bug['bug_id'] . '/" title="Download Code" class="textselect">Download</a>'; + $content .= '<textarea id="reproduce" rows="7" cols="55">' . $bug['reproduce'] . '</textarea>'; + //given reporduce assume other, expected and actual + //need a swtich in the db for line numbers or dyn generate? + $content .= '<hr />'; + $content .= '<h5>Expected Result</h5>'; + $content .= '<textarea id="expected" rows="7" cols="55">' . $bug['expected'] . '</textarea>'; + $content .= '<hr />'; + $content .= '<a href="javascript:createTextAreaWithLines(\'expected\');" class="lineno">Add Line Numbers</a>'; + $content .= '<hr />'; + $content .= '<h5>Actual Result</h5>'; + $content .= '<textarea id="actual" rows="7" cols="55">' . $bug['actual'] . '</textarea>'; + $content .= '<hr />'; + $content .= '<a href="javascript:createTextAreaWithLines(\'actual\');" class="lineno">Add Line Numbers</a>'; + $content .= '</td></tr>'; + $content .= "\n"; + } + + //here be the comment controller + $comment->spawn_form(); + + $content .= '</table><br /><hr /><hr />'; + + if (isset($bug['reproduce'])) + { + $content .= ' <script type="text/javascript"> createTextAreaWithLines(\'reproduce\'); </script>'; @@ -129,31 +132,31 @@ </script> '; */ -} - -$content .= 'tempory hack'; -$content .= '<table>'; -foreach ($row as $col => $data) -{ - if (is_numeric($col)) - { - } - else if (isset($$col)) - { - if (is_array($$col)) + } + + $content .= 'tempory hack'; + $content .= '<table>'; + foreach ($row as $col => $data) { - //shunt into box - $temp = $$col; - $content .= '<tr><td>' . $col . '</td><td>' . $temp[$data] . ' - ' . $data . '</td></tr>'; + if (is_numeric($col)) + { + } + else if (isset($$col)) + { + if (is_array($$col)) + { + //shunt into box + $temp = $$col; + $content .= '<tr><td>' . $col . '</td><td>' . $temp[$data] . ' - ' . $data . '</td></tr>'; + } + } + else + { + $content .= '<tr><td>' . $col . '</td><td>' . $data . '</td></tr>'; + } } + $content .= '</table>'; } - else - { - $content .= '<tr><td>' . $col . '</td><td>' . $data . '</td></tr>'; - } -} -$content .= '</table>'; - } else if ($bug_id) { http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/user/convert.php?view=markup&rev=1.1 Index: bugtracker/template/generic/user/convert.php +++ bugtracker/template/generic/user/convert.php <?php //convert a user from a temp account to a real account //check for logged in $temp_handle = loadvar('temp_handle',''); $redirect_convert = TRUE; if ($temp_handle) { $user_data = array(); $user_data['temp_handle'] = loadvar('temp_handle',$user->handle); //there is hope that the handle might still be there, assuming the cookie is not invalid now, and no user on the address line $user_data['handle'] = loadvar('handle',''); $user_data['password'] = loadvar('password',''); //check valid $query = 'SELECT * FROM ' . TEMP_USER_TABLE . ' WHERE handle = \'' . $db->protect_data($temp_handle) . '\''; $db->get_data($query); // $valid = $db->total_rows ? TRUE : FALSE; //if the new handle is already in the user table.... if ($user->fetch_handle($handle)) { $template_data['form_error'] = 'The handle you have selected is already in use, please select another'; $user->logged_in_temp = TRUE; $redirect_convert = FALSE; } else if ($db->total_rows) { $query = 'DESCRIBE ' . USER_TABLE; $db->get_data($query); $past_updated = FALSE; while ($data = $db->fetch_row()) { if ($past_updated) { $type = explode('(',$data['Type']); $dims = str_replace(')','',$type[1]); $type = $type[0]; if ($type == 'varchar') { //here one would do some far out preg matchage } $user_data[$data[0]] = loadvar($data[0],''); } else { if ($data[0] == 'updated') { $past_updated = TRUE; } } } unset($past_updated); //grab that email $query = 'SELECT email FROM ' . TEMP_USER_TABLE . ' WHERE handle = \'' . $db->protect_data($user_data['temp_handle']) . '\''; $db->get_data($query); $user_email = $db->fetch_row(); $user_data['email'] = $user_email[0]; unset($user_email); if (!$user_data['password']) { //user would like to use the old password $query = 'SELECT password FROM ' . TEMP_USER_TABLE . ' WHERE handle = \'' . $db->protect_data($user_data['temp_handle']) . '\''; $db->get_data($query); if ($db->total_rows) { $temp_pass = $db->fetch_row(); //pre md5'ed $user_data['password'] = $temp_pass['password']; unset($temp_pass); } } else { $user_data['password'] = md5($user_data['password']); } //lets check we have the key components if ($user_data['handle'] && ($user_data['password'] != md5('')) && $user_data['email']) { if ($user->fetch_handle($user_data['handle'])) { //already reigstered $template_data['form_error'] = '<div id="error">The handle you have selected is already in use, please pick another</div>'; $user->logged_in_temp = TRUE; $user->handle = $user_data['temp_handle']; } //if all good pass it to the register function //$user->register($user_data); if ($user->register($user_data)) { //the user has been registered in the main database //what now? $content .= '<h2>Account Status</h2>'; $content .= '<p>Your account has begun the conversion process.</p>'; $content .= '<p>An email has been sent to you, in order for you to confirm your address.</p>'; $content .= '<p>In order to continue please visit the link in the email.</p>'; $user->logged_in_temp = FALSE; $redirect_convert = FALSE; } } else { if (!$user_data['email']) { $template_data['form_error'] = '<div id="error">For some reason you email address is missing</div>'; } else { $template_data['form_error'] = '<div id="error">You must supply a handle, password</div>'; } $user->logged_in_temp = TRUE; $user->handle = $user_data['temp_handle']; } } } //use this switch for drop through return to form, //same for the redirect switch //we dont always want to redirect, if no temp user logged in if ($user->logged_in_temp) { $content .= '<h2>Creating a User</h2>'; $content .= '<p>You have attempted to login as a temporary user, in order to continue your account needs to be upgraded to a full account</p>'; $temp_handle = $user->handle; $query = 'SELECT * FROM ' . TEMP_USER_TABLE . ' WHERE handle = \'' . $db->protect_data($temp_handle) . '\''; $db->get_data($query); if ($db->total_rows) { $content .= '<p>Please confirm your details, then we can confirm you email address</p>'; $content .= '<form action="/user/convert/" method="post" class="form">'; $content .= '<input type="hidden" name="temp_handle" value="' . $temp_handle . '" />'; $content .= '<div class="slim">'; $temp_user = $db->fetch_row(); $content .= ' {FORM_ERROR} <label for="handle">Handle:</label><input type="text" name="handle" id="handle" value="' . $temp_handle . '" /> <br /><br /> <label for="password">Password:</label><input type="text" name="password" id="password" /> <br />Leave blank to use current <br /><br /> '; $query = 'DESCRIBE ' . USER_TABLE; $db->get_data($query); $past_updated = FALSE; while ($data = $db->fetch_row()) { if ($past_updated) { $type = explode('(',$data['Type']); $dims = str_replace(')','',$type[1]); $type = $type[0]; if ($type == 'varchar') { $content .= '<label for="' . $data[0] . '">' . titleit($data[0]) . ':</label><input type="text" name="' . $data[0] . '" id="' . $data[0] . '" value="' . $data['Default'] . '" maxlenth="' . $dims . '" />'; } $content .= "\n" . '<br /><br />' . "\n"; } else { if ($data[0] == 'updated') { $past_updated = TRUE; } } } unset($past_updated); $content .= '<input type="submit" name="submit" value="Submit" />'; $content .= '</div>'; $content .= '</form><br />'; } else { $content .= '<p>However, you have specified an Invalide Handle</p>'; } $content = tpl_process($content,FALSE); } else if ($redirect_convert) { header('Location: /login/'); } http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/user/login.php?view=markup&rev=1.1 Index: bugtracker/template/generic/user/login.php +++ bugtracker/template/generic/user/login.php <?php //login contoller and generator echo '<!--'; $method = loadvar('method'); echo '-->'; $template_data['form_error'] = ''; $template_data['username'] = ''; $template_data['remember'] = ''; $template_data['return'] = (isset($_SERVER['HTTP_REFERER'])) ? str_replace('http://' . $_SERVER['HTTP_HOST'],'',$_SERVER['HTTP_REFERER']) : '/'; $content .= '<h2>Logging In</h2>'; switch($method) { case('login'): { $username = loadvar('username'); $password = md5(loadvar('password')); $remember = loadvar('remember'); $return = loadvar('return',$template_data['return']); $template_data['username'] = $username; $template_data['remember'] = ($remember) ? ' checked="checked" ' : ''; $template_data['return'] = $return; // $system_data['login_username'] = $username; // $system_data['login_password'] = $password; //call login $user->login($username,$password); $content .= ''; } default: { $content .= ' {FORM_ERROR} <form action="/login/" method="post" class="form"> <input type="hidden" name="method" value="login" /> <div class="slim"> <label for="username" >Handle/Email:</label> <input type="text" name="username" id="username" value="{USERNAME}" /> <br /><br /> <label for="password" >Password:</label> <input type="password" name="password" id="password" /> <br /><br /> <label for="remember" >Remember:</label> <input type="checkbox" name="remember" id="remember" {REMEMBER} /> <br /><br /> <input type="submit" name="submit" id="submit" value="Submit" /> </div> <input type="hidden" name="return" value="{RETURN}" /> </form> '; } } $content = tpl_process($content,FALSE);
« previous php.webmaster (#2113) next »