public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     ef19aa17b0bbdb31ebfc4a2b8744cda8075bd9ff
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 29 21:08:25 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Mon Jan 29 21:08:25 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=ef19aa17

Remove the unused php/lib/list.php

 php/lib/list.php | 391 -------------------------------------------------------
 1 file changed, 391 deletions(-)

diff --git a/php/lib/list.php b/php/lib/list.php
deleted file mode 100644
index 5deb5e9..0000000
--- a/php/lib/list.php
+++ /dev/null
@@ -1,391 +0,0 @@
-<?php
-/**
- *	List functions for lists of values.
- *	@package mirror 
- *	@subpackage lib
- *	@author Mike Morgan <mike.morgan@oregonstate.edu> 
- *	
- *	Usage example:
- *	<code>
- *	$orderby=get_order();
- *	$query="SELECT * FROM fic_courses $orderby";
- *	$courses=db_get($query,MYSQL_ASSOC);
- *	$headers=array(
- *		'course_id'=>'',
- *		'title'=>'Course Title',
- *		'date_start_course'=>'Start',
- *		'date_end_course'=>'End',
- *		'date_start_reg'=>'Reg Starts',
- *		'date_end_reg'=>'Reg Ends',
- *		'active'=>'Active?',
- *		'entry_date'=>'Created'
- *	);
- *	show_list($courses,$headers);
- *	</code>
- *
- *	Accompanying CSS for table output:
- *	<code>
- *	.list
- *	{
- *		border:1px solid #999;
- *	}
- *	.list th
- *	{
- *		background:#eee;
- *		border:1px solid #000;
- *		font-weight:bold;
- *	}
- *	.list th a
- *	{
- *		display:block;
- *		padding:0 14px;
- *	}
- *	.list th a:hover
- *	{
- *		background-color:#fff;
- *	}
- *	.row1
- *	{
- *		background:#ddd;
- *	}
- *	.row2
- *	{
- *		background:#ccc;
- *	}
- *	.row1:hover, .row2:hover
- *	{
- *		background-color:#fec;
- *	}
- *	.current-sort
- *	{
- *		background:#fda;
- *	}
- *	.sort-desc
- *	{
- *		background:#fec url(../img/up.gif) no-repeat right;
- *	}
- *	.sort-asc
- *	{
- *		background:#fec url(../img/down.gif) no-repeat right;
- *	}
- *	</code>
-
- *	Accompanying JavaScript for select all / inverse:
- *	<code>
- *	<script type="text/javascript">
- *	//<!--
- *	function selectAll(formObj,invert)
- *	{
- *		for (var i=0;i < formObj.elements.length;i++)
- *		{
- *			fldObj = formObj.elements[i];
- *			if (fldObj.type == 'checkbox')
- *			{
- *				if (invert==1)
- *				{
- *					fldObj.checked = (fldObj.checked) ? false : true;
- *				}
- *				else
- *				{
- *					fldObj.checked = true;
- *				}
- *			}
- *		}
- *	}
- *	//-->
- *	</script>
- *	</code>
- */
-
-/**
- *	Show a list of values, for forms.
- *	@param array $list associative array
- *	@param array $headers column name => column title (for table heads)
- *	@param string $type checkbox, radio, simple
- *	@param array $array actions to display in actions select list 
- *	@param string $form_id id of form holding list
- *	@param bool $sortable whether or not to show sortable column headers (links in th's)
- *	@param array|string $selected if type is checkbox, array otherwise string with one val
- */
-function show_list($list,$headers,$type='checkbox',$actions=null,$form_id=null,$sortable=true,$selected=null)
-{
-	if ( is_array($list) && count($list)>0 && is_array($headers) )
-	{
-		if ( $type!='simple' && !empty($_GET['sort']) && !empty($_GET['order']) )
-		{
-			form_hidden('sort',$_GET['sort']);
-			form_hidden('order',$_GET['order']);
-		}
-		echo "\n".'<table class="list">';
-		show_headers($headers,$type,$sortable);
-		echo "\n".'<tbody>';
-		foreach ($list as $row)
-		{
-			show_row($headers,$row,$type,$count++,$selected);
-		}
-		echo "\n".'</tbody>';
-		echo "\n".'</table>';
-		if ($type=='checkbox')
-		{
-echo <<<js
-<script type="text/javascript">
-//<!--
-function list_select(formObj,invert)
-{
-	for (var i=0;i < formObj.elements.length;i++)
-	{
-		fldObj = formObj.elements[i];
-		if (fldObj.type == 'checkbox')
-		{
-			if (invert==1)
-			{
-				fldObj.checked = (fldObj.checked) ? false : true;
-			}
-			else
-			{
-				fldObj.checked = true;
-			}
-		}
-	}
-}
-//-->
-</script>
-js;
-			echo "\n".'<p><input type="button" name="selectall" onclick="list_select(this.form,0);" class="button2" value="Select All"/> <input type="button" name="selectall" onclick="list_select(this.form,1);" class="button2" value="Invert"/></p>';
-		}
-		if ($type=='radio'||$type='checkbox-small')
-		{
-			echo '<br />';	
-		}
-		if (is_array($actions)&&$type!='simple')
-		{
-			if (count($actions) == 1) {
-				$actions = array_values($actions);
-				echo '<p>';
-				form_submit('submit','submit','button1',$actions[0].' &raquo;');
-				echo '</p>';
-			} else {
-				echo '<p>';
-				echo '<label for="action">With selected: </label>';
-				form_select('action','action','text2',$actions,'');
-				form_submit('submit','submit','button1','Go &raquo;');
-				echo '</p>';
-			}
-		}
-	}
-	elseif ( !is_array($headers) )
-	{
-		echo "\n".'<h1>FIX HEADERS ARRAY</h1>';
-	}
-	else
-	{
-		echo "\n".'<p>No records found.</p>';
-	}
-}
-
-/**
- *	Show table headers.
- *	@param array $headers column name => column title (for table heads)
- *	@param string $type type of list that is being shown
- *	@param bool $sortable whether or not to show sortable column headers (links in th's)
- */
-function show_headers($headers,$type,$sortable=true)
-{
-	echo "\n".'<thead><tr>';
-	$sort=$_GET['sort'];
-	$order=get_order();
-	$count=0;
-	foreach ($headers as $col=>$title)
-	{
-		if ( !empty($sort) && !empty($order) )
-		{
-			if ($col==$sort && $order=='ASC')
-			{
-				$a_class=' class="sort-asc current-sort" ';
-			}
-			elseif ($col==$sort && $order=='DESC')
-			{
-				$a_class=' class="sort-desc current-sort" ';
-			}
-			else
-			{
-				$a_class=null;
-			}
-		}
-		if ($type!='simple'&&$count==0)	
-		{
-			echo "\n".'<th> </th>';
-			next;
-		}
-		elseif($sortable)
-		{
-			$qs = array();
-			foreach ($_GET as $qn=>$qv) { $qs[$qn] = $qv; } // existing query string variables
-			$qs['sort'] = $col; // add/replace sort to query string
-			$qs['order'] = $order; // add/replace order by to query string
-			foreach ($qs as $qn=>$qv) { $querystring[] = $qn.'='.$qv; } // existing query string variables
-			echo "\n".'<th><a '.$a_class.'href="'.$_SERVER['PHP_SELF'].'?'.implode('&amp;',$querystring).'">'.$title.'</a></th>';
-			unset($qs);
-			unset($querystring);
-		}
-		else
-		{
-			echo "\n".'<th>'.$title.'</th>';
-		}
-		$count++;
-	}
-	echo "\n".'</tr></thead>';
-}
-
-/**
- *	Show table data.
- *	@param array $headers column name => column title (for knowing which ones to display)
- *	@param array $row table row, assoc
- *	@param string $type type of table, determines first column, which could be an input
- *	@param array|string $selected selected items; if type is checkbox, array otherwise string with one val
- */
-function show_row($headers,$row,$type,$num=null,$selected=null)
-{
-	$indexes=array_keys($headers);
-	$idname = $indexes[0];
-	$count=0;
-	$tr_class=($num%2)?' class="row1" ':' class="row2" ';
-	echo "\n".'<tr'.$tr_class.'>';
-	foreach ($indexes as $index)
-	{
-		$row[$index]=clean_out($row[$index]);
-		if ($type!='simple'&&$count==0)
-		{
-			$id=preg_replace('/[^[:alnum:]]/', '', $index).$row[$index];
-			if ($type=='checkbox'||$type=='checkbox-small')
-			{
-				echo "\n".'<td>';
-				form_checkbox($idname.'[]',$id,null,$row[$index],(is_array($selected) && in_array($row[$index], $selected)));
-				echo "\n".'</td>';
-			}
-			elseif ($type=='radio')
-			{
-				echo "\n".'<td>';
-				form_radio($idname,$id,null,$row[$index], ($row[$index] == $selected));
-				echo "\n".'</td>';
-			}
-		}
-		else
-		{
-			echo ($type=='simple')?"\n".'<td>'.$row[$index].'</td>':"\n".'<td><label for="'.$id.'">'.$row[$index].'</label></td>';
-		}
-		$count++;
-	}
-	echo "\n".'</tr>';
-}
-
-/**
- *	Determine current sort order.
- */
-function get_order()
-{
-	return ($_GET['order']=='ASC')?'DESC':'ASC';
-}
-
-/**
- *	Determine whether or not list is currently sorted.
- *	@param string $method which http method to check for sort information
- *	@return mixed cleaned orderby clause based on saved sort information or null if no orderby is set in the defined method
- */
-function get_orderby($method='get')
-{
-	if ( $method=='get' && !empty($_GET['sort']) && !empty($_GET['order']) )
-	{
-		$sort=clean_in($_GET['sort']);
-		$order=clean_in($_GET['order']);
-		return " ORDER BY $sort $order ";
-	}
-	elseif ( $method=='post' && !empty($_POST['sort']) && !empty($_POST['order']) )
-	{
-		$sort=clean_in($_POST['sort']);
-		$order=clean_in($_POST['order']);
-		return " ORDER BY $sort $order ";
-	}
-	elseif ( $method=='session' && !empty($_SESSION['sort']) && !empty($_SESSION['order']) )
-	{
-		$sort=clean_in($_SESSION['sort']);
-		$order=clean_in($_SESSION['order']);
-		return " ORDER BY $sort $order ";
-	}
-	else return null;
-}
-
-/**
- *	Parses $_POST for ids, shows edit forms for each id with populated data.
- *	<ul>
- *	<li>name will be used to retrieve an _array_ from $_POST of the same name</li>
- *		<li>the form will be an include, with $posts[col_name] as the default for all values</li>
- *		<li>try to keep your query simple (no crazy sorting, etc.) -- we're talking one record at a time here anyway</li>
- *	</ul>
- *	Example:
- *	<code>
- *	list_edit_ids('course_id','../forms/course.php','SELECT * FROM fic_courses','1');
- *	</code>
- *	@param string $name name of id field
- *	@param string $form path to form to be used to items
- *	@param string $q_front front half of query
- *	@param string $q_where where statement
- *	@param array $dates array of date field names, so they can be fixed for forms
- *	@param array $datetimes array of datetime field names, so they can be fixed for forms
- */
-function list_edit_ids($name,$form,$q_front,$q_where='1',$dates=null,$datetimes=null)
-{
-	if ( !empty($_SESSION[$name]) && is_array($_SESSION[$name]) )
-	{
-		$ids=implode(',',$_SESSION[$name]);
-		$orderby=get_orderby('session');
-		$query=$q_front.' WHERE '.$q_where." AND $name IN($ids) ".$orderby;
-		$records=db_get($query);
-		form_start($name);
-		foreach ($records as $record)
-		{
-			echo "\n".'<div class="record">';
-			$record=form_array_fix_dates($dates,$datetimes,2,$record);
-			foreach ($record as $key=>$val)
-			{
-				$posts[$key]=clean_out($val);
-			}
-			include($form);
-			echo "\n".'<div class="record-submit">';
-			form_submit('submit', '', 'button1');
-			echo "\n".'</div>';
-			echo "\n".'</div>';
-		}
-		form_end();
-	}
-	else
-	{
-		echo '<p>You must select a record.  <a href="javascript:history.back();">Go back</a>.</p>';
-	}
-}
-
-/**
- *	Process a submitted list_edit_ids form.
- *	@param array $name array of primary ids posted from the form, these are vital to the WHERE clause of the UPDATE statements.
- *	@param string $table name of table being affected
- */
-function list_update_ids($name,$table)
-{
-	$keys=array_keys($_POST[$name]);
-	foreach ($keys as $index)
-	{
-		foreach ($_POST as $key=>$val)
-		{
-			if ($key!='submit')
-			{
-				$posts[$index][$key]=$val[$index];
-			}
-		}
-	}
-	foreach ($posts as $dataset)
-	{
-		$query=db_makeupdate($dataset,$table," WHERE $name='".$dataset[$name]."' ");
-		db_query($query);
-	}
-}
-?>


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     d180173111518d7c87538dafdeac6727d6c6e47a
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 29 21:59:05 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Mon Jan 29 21:59:05 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=d1801731

More database typo fixes

 php/lib/db.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/php/lib/db.php b/php/lib/db.php
index 34e49e3..ae20f9e 100644
--- a/php/lib/db.php
+++ b/php/lib/db.php
@@ -43,7 +43,7 @@ public static function query($qry=null, $parameters=[])
         else return false;
     }
     if(!empty($parameters)) {
-	static::$result = static::$dbh->prepare($query);
+	static::$result = static::$dbh->prepare($qry);
 	static::$result->execute($parameters);
     }
     else {
@@ -149,7 +149,7 @@ public static function close($dbh=null)
  *  @param int $type result type
  */
 public static function get_one($query,$type=PDO::FETCH_ASSOC,$parameters=[]) {
-    $buf = static::get($query.' LIMIT 1',$type,$parameters);
+    $buf = static::get($query.' LIMIT 1',$type,null,$parameters);
     return $buf[0];
 }
 
@@ -162,7 +162,7 @@ public static function get_one($query,$type=PDO::FETCH_ASSOC,$parameters=[]) {
  */
 public static function name_to_id($table,$id_col,$name_col,$name)
 {
-    $buf = static::get_one("SELECT {$id_col} FROM {$table} WHERE {$name_col} = :name", PDO::FETCH_NUM, [':name' => $name]);
+    $buf = static::get_one("SELECT {$id_col} FROM {$table} WHERE {$name_col} = ?", PDO::FETCH_NUM, [$name]);
     return $buf[0];
 }
 


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     2d323e26c63a2f1d11f347a6bb725c095965bda2
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 15:37:19 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 15:37:19 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=2d323e26

fix library comments and convert util query

 php/lib/db.php   | 4 ++--
 php/lib/util.php | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/php/lib/db.php b/php/lib/db.php
index ae20f9e..003be70 100644
--- a/php/lib/db.php
+++ b/php/lib/db.php
@@ -1,6 +1,6 @@
 <?php
 /**
- *  Minimal wrappers for core PHP mysql_* functions.
+ *  Minimal wrappers for core PHP PDO functions.
  *  @package mirror
  *  @subpackage lib
  */
@@ -109,7 +109,7 @@ public static function get($query,$type=PDO::FETCH_BOTH,$col_id=NULL,$parameters
 }
 
 /**
- *  Since PHP's mysql_insert_id() sometimes throws an error, this is the replacement
+ *  Wrapper for PDOStatement::lastInsertId()
  *  @param PDO $dbh optional dbh to get the last inserted id from
  *  @return int the return value of MySQL's last_insert_id()
  */

diff --git a/php/lib/util.php b/php/lib/util.php
index af64fbb..8f8e1e4 100644
--- a/php/lib/util.php
+++ b/php/lib/util.php
@@ -13,7 +13,7 @@ function microtime_float()
 {
     list($usec, $sec) = explode(" ", microtime());
     return ((float)$usec + (float)$sec);
-} 
+}
 
 /**
  *	Add a message to SESSION['messages'] array.
@@ -157,8 +157,8 @@ function emptify_in_array($array, $needle)
  */
 function record_exists($table,$column,$val,$extra=NULL)
 {
-	$result = db_query("SELECT * FROM {$table} WHERE {$column}='{$val}' {$extra}");
-	if ($result&&mysql_num_rows($result)>0)
+	$result = DB::query("SELECT * FROM {$table} WHERE {$column}='{$val}' {$extra}");
+	if ($result&&$result->rowCount()>0)
 	{
 		return true;
 	}


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     0c00dcb46e650589a387bd042735669402842468
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 29 21:46:39 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Mon Jan 29 21:46:39 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=0c00dcb4

Bug fixes for some typos

 php/lib/db.php     | 6 +++---
 php/lib/mirror.php | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/php/lib/db.php b/php/lib/db.php
index 6882064..34e49e3 100644
--- a/php/lib/db.php
+++ b/php/lib/db.php
@@ -7,8 +7,8 @@
 
 class DB {
 
-	private $dsn;
-	private $result;
+	private static $dbh;
+	private static $result;
 /**
  *  Connect to a MySQL database server.
  *  @param string $host db server, defaults to localhost
@@ -20,7 +20,7 @@ public static function connect($host='localhost',$user=null,$password=null,$data
 {
     if (!empty($host) && isset($user) && isset($password)) {
 	$dsn = "mysql:host={$host}";
-	if(!empty($database)) $dsn .= ";database={$database}";
+	if(!empty($database)) $dsn .= ";dbname={$database}";
 	$options = [PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
         static::$dbh = new PDO($dsn, $user, $password, $options);
     }

diff --git a/php/lib/mirror.php b/php/lib/mirror.php
index ac3e904..564e33f 100644
--- a/php/lib/mirror.php
+++ b/php/lib/mirror.php
@@ -530,3 +530,5 @@ public static function get_product_stats()
             mirror_locations.product_id
     ");
 }
+
+}


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     200852fe6592cf0e4aa026acf29499542c173806
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 15:18:07 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 15:18:07 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=200852fe

Revert "Remove the unused php/lib/list.php"

This reverts commit 011b963d1f61307fa0dbcef713224a0353e5801e.

 php/lib/list.php | 391 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 391 insertions(+)

diff --git a/php/lib/list.php b/php/lib/list.php
new file mode 100644
index 0000000..5deb5e9
--- /dev/null
+++ b/php/lib/list.php
@@ -0,0 +1,391 @@
+<?php
+/**
+ *	List functions for lists of values.
+ *	@package mirror 
+ *	@subpackage lib
+ *	@author Mike Morgan <mike.morgan@oregonstate.edu> 
+ *	
+ *	Usage example:
+ *	<code>
+ *	$orderby=get_order();
+ *	$query="SELECT * FROM fic_courses $orderby";
+ *	$courses=db_get($query,MYSQL_ASSOC);
+ *	$headers=array(
+ *		'course_id'=>'',
+ *		'title'=>'Course Title',
+ *		'date_start_course'=>'Start',
+ *		'date_end_course'=>'End',
+ *		'date_start_reg'=>'Reg Starts',
+ *		'date_end_reg'=>'Reg Ends',
+ *		'active'=>'Active?',
+ *		'entry_date'=>'Created'
+ *	);
+ *	show_list($courses,$headers);
+ *	</code>
+ *
+ *	Accompanying CSS for table output:
+ *	<code>
+ *	.list
+ *	{
+ *		border:1px solid #999;
+ *	}
+ *	.list th
+ *	{
+ *		background:#eee;
+ *		border:1px solid #000;
+ *		font-weight:bold;
+ *	}
+ *	.list th a
+ *	{
+ *		display:block;
+ *		padding:0 14px;
+ *	}
+ *	.list th a:hover
+ *	{
+ *		background-color:#fff;
+ *	}
+ *	.row1
+ *	{
+ *		background:#ddd;
+ *	}
+ *	.row2
+ *	{
+ *		background:#ccc;
+ *	}
+ *	.row1:hover, .row2:hover
+ *	{
+ *		background-color:#fec;
+ *	}
+ *	.current-sort
+ *	{
+ *		background:#fda;
+ *	}
+ *	.sort-desc
+ *	{
+ *		background:#fec url(../img/up.gif) no-repeat right;
+ *	}
+ *	.sort-asc
+ *	{
+ *		background:#fec url(../img/down.gif) no-repeat right;
+ *	}
+ *	</code>
+
+ *	Accompanying JavaScript for select all / inverse:
+ *	<code>
+ *	<script type="text/javascript">
+ *	//<!--
+ *	function selectAll(formObj,invert)
+ *	{
+ *		for (var i=0;i < formObj.elements.length;i++)
+ *		{
+ *			fldObj = formObj.elements[i];
+ *			if (fldObj.type == 'checkbox')
+ *			{
+ *				if (invert==1)
+ *				{
+ *					fldObj.checked = (fldObj.checked) ? false : true;
+ *				}
+ *				else
+ *				{
+ *					fldObj.checked = true;
+ *				}
+ *			}
+ *		}
+ *	}
+ *	//-->
+ *	</script>
+ *	</code>
+ */
+
+/**
+ *	Show a list of values, for forms.
+ *	@param array $list associative array
+ *	@param array $headers column name => column title (for table heads)
+ *	@param string $type checkbox, radio, simple
+ *	@param array $array actions to display in actions select list 
+ *	@param string $form_id id of form holding list
+ *	@param bool $sortable whether or not to show sortable column headers (links in th's)
+ *	@param array|string $selected if type is checkbox, array otherwise string with one val
+ */
+function show_list($list,$headers,$type='checkbox',$actions=null,$form_id=null,$sortable=true,$selected=null)
+{
+	if ( is_array($list) && count($list)>0 && is_array($headers) )
+	{
+		if ( $type!='simple' && !empty($_GET['sort']) && !empty($_GET['order']) )
+		{
+			form_hidden('sort',$_GET['sort']);
+			form_hidden('order',$_GET['order']);
+		}
+		echo "\n".'<table class="list">';
+		show_headers($headers,$type,$sortable);
+		echo "\n".'<tbody>';
+		foreach ($list as $row)
+		{
+			show_row($headers,$row,$type,$count++,$selected);
+		}
+		echo "\n".'</tbody>';
+		echo "\n".'</table>';
+		if ($type=='checkbox')
+		{
+echo <<<js
+<script type="text/javascript">
+//<!--
+function list_select(formObj,invert)
+{
+	for (var i=0;i < formObj.elements.length;i++)
+	{
+		fldObj = formObj.elements[i];
+		if (fldObj.type == 'checkbox')
+		{
+			if (invert==1)
+			{
+				fldObj.checked = (fldObj.checked) ? false : true;
+			}
+			else
+			{
+				fldObj.checked = true;
+			}
+		}
+	}
+}
+//-->
+</script>
+js;
+			echo "\n".'<p><input type="button" name="selectall" onclick="list_select(this.form,0);" class="button2" value="Select All"/> <input type="button" name="selectall" onclick="list_select(this.form,1);" class="button2" value="Invert"/></p>';
+		}
+		if ($type=='radio'||$type='checkbox-small')
+		{
+			echo '<br />';	
+		}
+		if (is_array($actions)&&$type!='simple')
+		{
+			if (count($actions) == 1) {
+				$actions = array_values($actions);
+				echo '<p>';
+				form_submit('submit','submit','button1',$actions[0].' &raquo;');
+				echo '</p>';
+			} else {
+				echo '<p>';
+				echo '<label for="action">With selected: </label>';
+				form_select('action','action','text2',$actions,'');
+				form_submit('submit','submit','button1','Go &raquo;');
+				echo '</p>';
+			}
+		}
+	}
+	elseif ( !is_array($headers) )
+	{
+		echo "\n".'<h1>FIX HEADERS ARRAY</h1>';
+	}
+	else
+	{
+		echo "\n".'<p>No records found.</p>';
+	}
+}
+
+/**
+ *	Show table headers.
+ *	@param array $headers column name => column title (for table heads)
+ *	@param string $type type of list that is being shown
+ *	@param bool $sortable whether or not to show sortable column headers (links in th's)
+ */
+function show_headers($headers,$type,$sortable=true)
+{
+	echo "\n".'<thead><tr>';
+	$sort=$_GET['sort'];
+	$order=get_order();
+	$count=0;
+	foreach ($headers as $col=>$title)
+	{
+		if ( !empty($sort) && !empty($order) )
+		{
+			if ($col==$sort && $order=='ASC')
+			{
+				$a_class=' class="sort-asc current-sort" ';
+			}
+			elseif ($col==$sort && $order=='DESC')
+			{
+				$a_class=' class="sort-desc current-sort" ';
+			}
+			else
+			{
+				$a_class=null;
+			}
+		}
+		if ($type!='simple'&&$count==0)	
+		{
+			echo "\n".'<th> </th>';
+			next;
+		}
+		elseif($sortable)
+		{
+			$qs = array();
+			foreach ($_GET as $qn=>$qv) { $qs[$qn] = $qv; } // existing query string variables
+			$qs['sort'] = $col; // add/replace sort to query string
+			$qs['order'] = $order; // add/replace order by to query string
+			foreach ($qs as $qn=>$qv) { $querystring[] = $qn.'='.$qv; } // existing query string variables
+			echo "\n".'<th><a '.$a_class.'href="'.$_SERVER['PHP_SELF'].'?'.implode('&amp;',$querystring).'">'.$title.'</a></th>';
+			unset($qs);
+			unset($querystring);
+		}
+		else
+		{
+			echo "\n".'<th>'.$title.'</th>';
+		}
+		$count++;
+	}
+	echo "\n".'</tr></thead>';
+}
+
+/**
+ *	Show table data.
+ *	@param array $headers column name => column title (for knowing which ones to display)
+ *	@param array $row table row, assoc
+ *	@param string $type type of table, determines first column, which could be an input
+ *	@param array|string $selected selected items; if type is checkbox, array otherwise string with one val
+ */
+function show_row($headers,$row,$type,$num=null,$selected=null)
+{
+	$indexes=array_keys($headers);
+	$idname = $indexes[0];
+	$count=0;
+	$tr_class=($num%2)?' class="row1" ':' class="row2" ';
+	echo "\n".'<tr'.$tr_class.'>';
+	foreach ($indexes as $index)
+	{
+		$row[$index]=clean_out($row[$index]);
+		if ($type!='simple'&&$count==0)
+		{
+			$id=preg_replace('/[^[:alnum:]]/', '', $index).$row[$index];
+			if ($type=='checkbox'||$type=='checkbox-small')
+			{
+				echo "\n".'<td>';
+				form_checkbox($idname.'[]',$id,null,$row[$index],(is_array($selected) && in_array($row[$index], $selected)));
+				echo "\n".'</td>';
+			}
+			elseif ($type=='radio')
+			{
+				echo "\n".'<td>';
+				form_radio($idname,$id,null,$row[$index], ($row[$index] == $selected));
+				echo "\n".'</td>';
+			}
+		}
+		else
+		{
+			echo ($type=='simple')?"\n".'<td>'.$row[$index].'</td>':"\n".'<td><label for="'.$id.'">'.$row[$index].'</label></td>';
+		}
+		$count++;
+	}
+	echo "\n".'</tr>';
+}
+
+/**
+ *	Determine current sort order.
+ */
+function get_order()
+{
+	return ($_GET['order']=='ASC')?'DESC':'ASC';
+}
+
+/**
+ *	Determine whether or not list is currently sorted.
+ *	@param string $method which http method to check for sort information
+ *	@return mixed cleaned orderby clause based on saved sort information or null if no orderby is set in the defined method
+ */
+function get_orderby($method='get')
+{
+	if ( $method=='get' && !empty($_GET['sort']) && !empty($_GET['order']) )
+	{
+		$sort=clean_in($_GET['sort']);
+		$order=clean_in($_GET['order']);
+		return " ORDER BY $sort $order ";
+	}
+	elseif ( $method=='post' && !empty($_POST['sort']) && !empty($_POST['order']) )
+	{
+		$sort=clean_in($_POST['sort']);
+		$order=clean_in($_POST['order']);
+		return " ORDER BY $sort $order ";
+	}
+	elseif ( $method=='session' && !empty($_SESSION['sort']) && !empty($_SESSION['order']) )
+	{
+		$sort=clean_in($_SESSION['sort']);
+		$order=clean_in($_SESSION['order']);
+		return " ORDER BY $sort $order ";
+	}
+	else return null;
+}
+
+/**
+ *	Parses $_POST for ids, shows edit forms for each id with populated data.
+ *	<ul>
+ *	<li>name will be used to retrieve an _array_ from $_POST of the same name</li>
+ *		<li>the form will be an include, with $posts[col_name] as the default for all values</li>
+ *		<li>try to keep your query simple (no crazy sorting, etc.) -- we're talking one record at a time here anyway</li>
+ *	</ul>
+ *	Example:
+ *	<code>
+ *	list_edit_ids('course_id','../forms/course.php','SELECT * FROM fic_courses','1');
+ *	</code>
+ *	@param string $name name of id field
+ *	@param string $form path to form to be used to items
+ *	@param string $q_front front half of query
+ *	@param string $q_where where statement
+ *	@param array $dates array of date field names, so they can be fixed for forms
+ *	@param array $datetimes array of datetime field names, so they can be fixed for forms
+ */
+function list_edit_ids($name,$form,$q_front,$q_where='1',$dates=null,$datetimes=null)
+{
+	if ( !empty($_SESSION[$name]) && is_array($_SESSION[$name]) )
+	{
+		$ids=implode(',',$_SESSION[$name]);
+		$orderby=get_orderby('session');
+		$query=$q_front.' WHERE '.$q_where." AND $name IN($ids) ".$orderby;
+		$records=db_get($query);
+		form_start($name);
+		foreach ($records as $record)
+		{
+			echo "\n".'<div class="record">';
+			$record=form_array_fix_dates($dates,$datetimes,2,$record);
+			foreach ($record as $key=>$val)
+			{
+				$posts[$key]=clean_out($val);
+			}
+			include($form);
+			echo "\n".'<div class="record-submit">';
+			form_submit('submit', '', 'button1');
+			echo "\n".'</div>';
+			echo "\n".'</div>';
+		}
+		form_end();
+	}
+	else
+	{
+		echo '<p>You must select a record.  <a href="javascript:history.back();">Go back</a>.</p>';
+	}
+}
+
+/**
+ *	Process a submitted list_edit_ids form.
+ *	@param array $name array of primary ids posted from the form, these are vital to the WHERE clause of the UPDATE statements.
+ *	@param string $table name of table being affected
+ */
+function list_update_ids($name,$table)
+{
+	$keys=array_keys($_POST[$name]);
+	foreach ($keys as $index)
+	{
+		foreach ($_POST as $key=>$val)
+		{
+			if ($key!='submit')
+			{
+				$posts[$index][$key]=$val[$index];
+			}
+		}
+	}
+	foreach ($posts as $dataset)
+	{
+		$query=db_makeupdate($dataset,$table," WHERE $name='".$dataset[$name]."' ");
+		db_query($query);
+	}
+}
+?>


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     1ce3c9c90a14683c6900e9812202c6fa355e53df
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 15:38:23 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 15:38:23 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=1ce3c9c9

Remove old db lib backup

 php/lib/db.php.orig | 306 ----------------------------------------------------
 1 file changed, 306 deletions(-)

diff --git a/php/lib/db.php.orig b/php/lib/db.php.orig
deleted file mode 100644
index 23dd1ea..0000000
--- a/php/lib/db.php.orig
+++ /dev/null
@@ -1,306 +0,0 @@
-<?php
-/**
- *  Minimal wrappers for core PHP mysql_* functions.
- *  @package mirror
- *  @subpackage lib
- */
-
-/**
- *  Connect to a MySQL database server.
- *  @param string $host db server, defaults to localhost
- *  @param string $user db username
- *  @param string $password db password 
- *  @return resource dbh
- */
-function db_connect($host='localhost',$user=null,$password=null)
-{
-    static $dbh = null;
-    if (!empty($host) && isset($user) && isset($password)) {
-        $dbh = @mysql_connect($host,$user,$password);
-    }
-    if (is_resource($dbh)) { 
-        return $dbh; 
-    }
-    else die("Unable to create database connection in db_connect()");
-}
-
-/**
- *  Select database.
- *  @param string $database name of the database to select
- *  @param resource $dbh valid dbh, null if not defined 
- *  @return bool success of command
- */
-function db_select($database,$dbh=null)
-{
-    if(is_resource($dbh)){
-        return @mysql_select_db($database);
-    }else{
-        return @mysql_select_db($database, db_connect());
-    }
-    
-}
-
-/**
- *  Execute a MySQL query.
- *  @param string $qry MySQL query
- *  @param resource $dbh valid dbh
- */
-function db_query($qry=null,$dbh=null)
-{
-    static $result = null;
-    if(!is_resource($dbh)) $dbh = db_connect();
-    printf("q:%s dbh=%s\n",$qry,$dbh);
-    if(is_null($qry))
-    {
-        if(is_resource($result)) return $result;
-        else return false;
-    }
-    else
-    {
-        $result = mysql_query($qry,$dbh);
-        return $result;
-    }
-}
-
-/**
- *  Fetch a row as an array from a result.
- *  @param string $result (default to null)
- *  @return array
- */
-function db_fetch($result=null,$type=MYSQL_BOTH)
-{
-    if(!is_resource($result)) {
-        print 'Rerun query"'.$result.'"';
-        return @mysql_fetch_array(db_query());
-    } else { 
-        return @mysql_fetch_array($result,$type);
-    }
-}
-
-/**
- *  Fetch an array based on a query. 
- *  @param string $query database query
- *  @param int $type result type
- *  @param string $col_id if passed it, the values of this column in the result set will be used as the array keys in the returned array
- *  @return array $list array of database rows
- *  Example of returned array:
- *  <code>
- *  db_get("SELECT * FROM table",MYSQL_ASSOC);
- *  returns...
- *  Array
- *  (
- *      [0] => Array
- *          (
- *              [id] => 1
- *              [field1] => data1 
- *              [field2] => data2
- *          )
- *
- *  )
- *  </code>
- */
-function db_get($query,$type=MYSQL_BOTH,$col_id=NULL)
-{
-    $res = db_query($query);
-    $list = array();
-    if (is_resource($res) && !is_null($col_id) && ($type == MYSQL_BOTH || $type == MYSQL_ASSOC) && @mysql_num_rows($res) !== 0) {
-        $col_test = db_fetch($res,$type);
-        @mysql_data_seek($res, 0);
-        if (array_key_exists($col_id,$col_test)) {
-            while ( $buf = db_fetch($res,$type) ) {
-                $list[$buf[$col_id]] = $buf;
-            }
-            return $list;
-        }
-    }
-    while ( $buf = db_fetch($res,$type) ) {
-        $list[] = $buf;
-    }
-    return $list;
-}
-
-/**
- *	Get all of the fieldnames for the specified table.
- *	@param string $table name of table to describe
- *	@return array array of column names, must be an array 
- */
-function db_fieldnames($table)
-{
-    $dbh = db_connect();
-    $results = db_query("DESCRIBE $table");
-    if (is_resource($results))
-	{
-        while ($buf=db_fetch($results))
-		{
-            $field_names[] = $buf[0];
-		}
-    }
-	else 
-	{
-		$field_names[] = 0;
-	}
-	return $field_names;
-}
-
-/**
- *	Create a MySQL INSERT statement based on $_POST array generated by form submission.
- *	<ul>
- *		<li>does not work with mysql functions (PASSWORD, etc.) because there are forced double quotes</li>
- *		<li>do not use clean_in() before this, or you'll have double the slashes</li>
- *		<li>use the function only when it saves you time, not _always_</li>
- *		<li>form items not set will not be processed (unchecked radios, checkboxes) - handle these manually, or don't use the func</li>
- *	</ul>
- *	@param array $vars array of posts
- *	@param string $table name of the table that fields will be inserted into
- *	@return string $query resulting MySQL insert string
- */
-function db_makeinsert($vars,$table)
-{
-    $dbh = db_connect();
-    $fields = db_fieldnames($table);
-    foreach ($fields as $field)
-	{
-        if (get_magic_quotes_gpc) $vars[$field] = stripslashes($vars[$field]);
-        $vars[$field] = addslashes($vars[$field]);
-        if (isset($vars[$field]))
-		{
-            isset($q1)?$q1 .= ','.$field:$q1='INSERT INTO '.$table.'('.$field;
-            isset($q2)?$q2 .= ",'$vars[$field]'":$q2=" VALUES('$vars[$field]'";
-        }
-    }
-    $q1 .= ')';
-    $q2 .= ')';
-    $query = $q1.$q2;
-    return $query;
-}
-
-/**
- *	Create a MySQL REPLACE statement based on $_POST array generated by form submission.
- *	<ul>
- *		<li>does not work with mysql functions (PASSWORD, etc.) because there are forced double quotes</li>
- *		<li>do not use clean_in() before this, or you'll have double the slashes</li>
- *		<li>use the function only when it saves you time, not _always_</li>
- *		<li>form items not set will not be processed (unchecked radios, checkboxes) - handle these manually, or don't use the func</li>
- *	</ul>
- *	@param array $vars array of posts
- *	@param string $table name of the table that fields will be inserted into
- *	@return string $query resulting MySQL insert string
- */
-function db_makereplace($vars,$table)
-{
-    $dbh = db_connect();
-    $fields = db_fieldnames($table);
-    foreach ($fields as $field)
-	{
-        if (get_magic_quotes_gpc) $vars[$field] = stripslashes($vars[$field]);
-        $vars[$field] = addslashes($vars[$field]);
-        if (isset($vars[$field]))
-		{
-            isset($q1)?$q1 .= ','.$field:$q1='REPLACE INTO '.$table.'('.$field;
-            isset($q2)?$q2 .= ",'$vars[$field]'":$q2=" VALUES('$vars[$field]'";
-        }
-    }
-    $q1 .= ')';
-    $q2 .= ')';
-    $query = $q1.$q2;
-    return $query;
-}
-
-/**
- *	Create a MySQL UPDATE statement based on $_POST array generated by form submission.
- *	<ul>
- *		<li>does not work with mysql functions (PASSWORD, etc.) because there are forced double quotes</li>
- *		<li>do not use clean_in() before this, or you'll have double the slashes</li>
- *		<li>use the function only when it saves you time, not _always_</li>
- *		<li>form items not set will not be processed (unchecked radios, checkboxes) - handle these manually, or don't use the func</li>
- *	</ul>
- *	@param array $vars array of posts
- *	@param string $table name of the table that fields will be inserted into
- *	@param string $where where clause, describing which records are to be updated
- */
-function db_makeupdate($vars,$table,$where)
-{
-    $dbh = db_connect();
-    $fields = db_fieldnames($table);
-    foreach ($fields as $field)
-	{
-		if (isset($vars[$field]))
-		{
-			if (get_magic_quotes_gpc()) $vars[$field] = stripslashes($vars[$field]);
-			$vars[$field]=addslashes($vars[$field]);
-			$q1 = isset($q1)?$q1 .= ' ,'.$field."='$vars[$field]'":'UPDATE '.$table.' set '.$field."='$vars[$field]'";
-        }
-    }
-    $query = $q1.' '.$where;
-    return $query;
-}
-
-/**
- *  Since PHP's mysql_insert_id() sometimes throws an error, this is the replacement
- *  @param resource $dbh optional dbh to get the last inserted id from
- *  @return int the return value of MySQL's last_insert_id()
- */
-function db_insert_id($dbh=null)
-{
-    if(!is_resource($dbh)) $dbh = db_connect();
-    $buf = db_fetch(db_query("SELECT LAST_INSERT_ID()", $dbh));
-    return empty($buf[0]) ? false : $buf[0];
-}
-
-/**
- *  Determine number of rows in result.
- *  @param resource $result mysql result
- *  @return int number of rows in query result
- */
-function db_numrows($result=null)
-{
-    return (!is_resource($result))? @mysql_num_rows(db_query()) : @mysql_num_rows($result);
-}
-
-/**
- *  Close the db connection.  If a dbh is not specified, assume the last opened link.
- *  @param resource $dbh optional dbh to close
- */
-function db_close($dbh=null)
-{
-    return is_resource($dbh)?@mysql_close($dbh):@mysql_close(); 
-}
-
-/**
- *  Get one record.
- *  @param string $query query
- *  @param int $type result type
- */
-function db_get_one($query,$type=MYSQL_ASSOC) {
-    $buf = db_get($query.' LIMIT 1',$type);
-    return $buf[0];
-}
-
-/**
- *  Get an ID based on name.
- *  @param string $table
- *  @param string $id_col
- *  @param string $name_col
- *  @param string $name
- */
-function db_name_to_id($table,$id_col,$name_col,$name)
-{
-    $q = "SELECT {$id_col} FROM {$table} WHERE {$name_col} = '{$name}'";
-    print 'Query: '.$q."<br />\n";
-    $buf = db_get_one($q, MYSQL_NUM);
-    return $buf[0];
-}
-
-/**
- *  Sets enum booleans to their opposite
- *  @param string $table
- *  @param string $pri
- *  @param string $col
- *  @param array $id
- *  @return int
- */
-function db_toggle_bool($table, $pri, $col, $id)
-{
-    return db_query("UPDATE {$table} SET {$col} = IF({$col} = '1', '0', '1') WHERE {$pri} = {$id}");
-}
-?>


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     584d92e682b2fb5f373953ed28e5b802079d4ccc
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 15:18:05 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 15:18:05 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=584d92e6

Fix authentication

 php/lib/auth.php | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/php/lib/auth.php b/php/lib/auth.php
index 68bf91a..610b3c2 100644
--- a/php/lib/auth.php
+++ b/php/lib/auth.php
@@ -14,17 +14,17 @@ class Auth {
  */
 public static function is_valid_session()
 {
-    $cookieAdmin = filter_input(INPUT_COOKIE, 'mozilla-mirror-admin');
-    if (!empty($cookieAdmin)) {  // check cookie
-        $res = DB::query("SELECT * FROM mirror_sessions WHERE session_id = ?", [$cookieAdmin]);  // check db for id
+    if (session_status() !== PHP_SESSION_ACTIVE) {
+	session_name('mozilla-mirror-admin');
+	session_start();
+    }
+    if (!empty($_SESSION['user'])) {  // check cookie
+        $res = DB::query("SELECT * FROM mirror_sessions WHERE session_id = ?", [session_id()]);  // check db for id
         if ($res && DB::numrows($res)>0) {
             $buf = DB::fetch($res,PDO::FETCH_ASSOC);
             // comment line below to disable gc and allow multiple sessions per username
-            DB::query("DELETE FROM mirror_sessions WHERE username=? AND session_id != ?", [$buf['username'], $cookieAdmin]);  // garbage collection
+            DB::query("DELETE FROM mirror_sessions WHERE username=? AND session_id != ?", [$buf['username'], session_id()]);  // garbage collection
             $user = DB::fetch(DB::query("SELECT * FROM mirror_users WHERE username=?", [$buf['username']]),PDO::FETCH_ASSOC);
-            if (empty($_SESSION)) {
-                static::create_session($user);  // if session isn't started, create it and push user data
-            }
             return true;
         }
     }
@@ -74,7 +74,7 @@ public static function create_session($user,$secure=0)
     session_name('mozilla-mirror-admin');
     session_set_cookie_params(0,'/',$_SERVER['HTTP_HOST'],$secure);
     session_start();
-    DB::query("INSERT INTO mirror_sessions(session_id,username) VALUES(?,?)", [session_id(), $user['username']]);
+    DB::query("INSERT IGNORE INTO mirror_sessions(session_id,username) VALUES(?,?)", [session_id(), $user['username']]);
     $_SESSION['user']=$user;
 }
 
@@ -84,8 +84,11 @@ public static function create_session($user,$secure=0)
 public static function logout()
 {
     // comment line below to keep gc from deleting other sessions for this user
-    $cookieAdmin = filter_input(INPUT_COOKIE, 'mozilla-mirror-admin');
-    DB::query("DELETE FROM mirror_sessions WHERE session_id=? OR username=?", [$cookieAdmin, $_SESSION['user']['username']]);
+    if (session_status() !== PHP_SESSION_ACTIVE) {
+	session_name('mozilla-mirror-admin');
+	session_start();
+    }
+    DB::query("DELETE FROM mirror_sessions WHERE session_id=? OR username=?", [session_id(), $_SESSION['user']['username']]);
     $_COOKIE = array();
     $_SESSION = array();
 }


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     8a8cccee7bc2ff11600bf83b684e627feefeb3d6
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 15:42:46 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 15:42:46 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=8a8cccee

Remove unused function from the list lib

 php/lib/list.php | 51 +--------------------------------------------------
 1 file changed, 1 insertion(+), 50 deletions(-)

diff --git a/php/lib/list.php b/php/lib/list.php
index c7e872b..9f480bc 100644
--- a/php/lib/list.php
+++ b/php/lib/list.php
@@ -9,7 +9,7 @@
  *	<code>
  *	$orderby=get_order();
  *	$query="SELECT * FROM fic_courses $orderby";
- *	$courses=db_get($query,MYSQL_ASSOC);
+ *	$courses=DB::get($query,PDO::FETCH_ASSOC);
  *	$headers=array(
  *		'course_id'=>'',
  *		'title'=>'Course Title',
@@ -314,52 +314,3 @@ function get_orderby($method='get')
 	}
 	else return null;
 }
-
-/**
- *	Parses $_POST for ids, shows edit forms for each id with populated data.
- *	<ul>
- *	<li>name will be used to retrieve an _array_ from $_POST of the same name</li>
- *		<li>the form will be an include, with $posts[col_name] as the default for all values</li>
- *		<li>try to keep your query simple (no crazy sorting, etc.) -- we're talking one record at a time here anyway</li>
- *	</ul>
- *	Example:
- *	<code>
- *	list_edit_ids('course_id','../forms/course.php','SELECT * FROM fic_courses','1');
- *	</code>
- *	@param string $name name of id field
- *	@param string $form path to form to be used to items
- *	@param string $q_front front half of query
- *	@param string $q_where where statement
- *	@param array $dates array of date field names, so they can be fixed for forms
- *	@param array $datetimes array of datetime field names, so they can be fixed for forms
- */
-function list_edit_ids($name,$form,$q_front,$q_where='1',$dates=null,$datetimes=null)
-{
-	if ( !empty($_SESSION[$name]) && is_array($_SESSION[$name]) )
-	{
-		$ids=implode(',',$_SESSION[$name]);
-		$orderby=get_orderby('session');
-		$query=$q_front.' WHERE '.$q_where." AND $name IN($ids) ".$orderby;
-		$records=db_get($query);
-		form_start($name);
-		foreach ($records as $record)
-		{
-			echo "\n".'<div class="record">';
-			$record=form_array_fix_dates($dates,$datetimes,2,$record);
-			foreach ($record as $key=>$val)
-			{
-				$posts[$key]=clean_out($val);
-			}
-			include($form);
-			echo "\n".'<div class="record-submit">';
-			form_submit('submit', '', 'button1');
-			echo "\n".'</div>';
-			echo "\n".'</div>';
-		}
-		form_end();
-	}
-	else
-	{
-		echo '<p>You must select a record.  <a href="javascript:history.back();">Go back</a>.</p>';
-	}
-}


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     c3fb882b2b5a8789cb255ec18f22bc2237fec23d
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 17:32:03 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 17:32:03 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=c3fb882b

Restore headers after they were broken fixing warnings

 php/lib/list.php | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/php/lib/list.php b/php/lib/list.php
index 8424ae3..86334c0 100644
--- a/php/lib/list.php
+++ b/php/lib/list.php
@@ -213,10 +213,9 @@ function show_headers($headers,$type,$sortable=true)
 				$a_class=null;
 			}
 		}
-		if ($type!='simple'&&$count==0)	
+		if ($type!='simple'&&$count==0)
 		{
 			echo "\n".'<th> </th>';
-			continue;
 		}
 		elseif($sortable)
 		{


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     cbb2b1f5e4b53a08bece7af5426468694a4b0922
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 16:36:02 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 16:36:02 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=cbb2b1f5

Remove old references

 php/lib/csv.php  | 18 +++++++++---------
 php/lib/util.php |  4 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/php/lib/csv.php b/php/lib/csv.php
index 12dff67..832866f 100644
--- a/php/lib/csv.php
+++ b/php/lib/csv.php
@@ -166,7 +166,7 @@ function csv_csv_to_array($string)
 {
 	$return = array();
 	$length = strlen($string);
-	
+
 	// create a temp file and write the string to it
 	$tmpfname = tempnam('/tmp', 'csvlib');
 	$fh = fopen($tmpfname, 'w');
@@ -194,23 +194,23 @@ function csv_csv_to_array($string)
  * @param string $enclosure enclosure character, default to '"'
  * @return &array the two dimensional array with the csv file content, or an empty if an error occured
  */
-function &csv_csv_file_to_array($filepath, $delimiter=',', $enclosure='"')
+function csv_csv_file_to_array($filepath, $delimiter=',', $enclosure='"')
 {
 	$return = array();
-	
+
 	if (!file_exists($filepath) || !is_readable($filepath))
 		return $return;
-	
-	$fh =& fopen($filepath, 'r');
+
+	$fh = fopen($filepath, 'r');
 	$size = filesize($filepath)+1;
 
-	while ($data =& fgetcsv($fh, $size, $delimiter, $enclosure))
+	while ($data = fgetcsv($fh, $size, $delimiter, $enclosure))
 	{
 		$return[] = $data;
 	}
-	
+
 	fclose($fh);
-	
+
 	return $return;
 }
-?>
+

diff --git a/php/lib/util.php b/php/lib/util.php
index fa95114..c058e2d 100644
--- a/php/lib/util.php
+++ b/php/lib/util.php
@@ -311,9 +311,9 @@ function array_order_by(&$array, $key=null, $order=null, $retain_keys=TRUE, $cas
 	foreach($x as $row_key => $uselessvalue)
 	{
 		if ($retain_keys)
-			$return_arr[$row_key] =& $array[$row_key];
+			$return_arr[$row_key] = $array[$row_key];
 		else
-			$return_arr[] =& $array[$row_key];
+			$return_arr[] = $array[$row_key];
 	}
 
 	return $return_arr;


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2018-01-30 18:16 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2018-01-30 18:16 UTC (permalink / raw
  To: gentoo-commits

commit:     a7817026c2caa0dbf0f8961eb8f69f27a9c17f8e
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 30 15:43:47 2018 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Tue Jan 30 15:43:47 2018 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=a7817026

Update comment in forms lib

 php/lib/forms.php | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/php/lib/forms.php b/php/lib/forms.php
index 0317949..e435181 100644
--- a/php/lib/forms.php
+++ b/php/lib/forms.php
@@ -641,8 +641,8 @@ function url_out($url)
 }
 
 /**
- *	Take a db_get result and return an array of options.
- *	@param array $data db_get result
+ *	Take a DB::get result and return an array of options.
+ *	@param array $data DB::get result
  *	@param string $val_col column containing the value for each option
  *	@param string $name_col column containing the text
  *	@return array $options array of options ($val=>$text)
@@ -656,4 +656,3 @@ function db_get_to_options($data,$val_col,$name_col)
 	}
 	return $options;
 }
-?>


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [gentoo-commits] proj/bouncer:master commit in: php/lib/
@ 2019-08-19 14:02 Brian Evans
  0 siblings, 0 replies; 12+ messages in thread
From: Brian Evans @ 2019-08-19 14:02 UTC (permalink / raw
  To: gentoo-commits

commit:     a7066d7bd83e18729d0b0a9efc3449decfa27a69
Author:     Brian Evans <grknight <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 19 14:02:09 2019 +0000
Commit:     Brian Evans <grknight <AT> gentoo <DOT> org>
CommitDate: Mon Aug 19 14:02:09 2019 +0000
URL:        https://gitweb.gentoo.org/proj/bouncer.git/commit/?id=a7066d7b

php/lib/auth.php: Drop md5 upgrade check

Signed-off-by: Brian Evans <grknight <AT> gentoo.org>

 php/lib/auth.php | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/php/lib/auth.php b/php/lib/auth.php
index 610b3c2..7101886 100644
--- a/php/lib/auth.php
+++ b/php/lib/auth.php
@@ -48,9 +48,7 @@ public static function query($username,$password)
     if ($res && DB::numrows($res)>0) {
         $userrow = DB::fetch($res,PDO::FETCH_ASSOC);
 	if (!password_verify($password, $userrow['password'])) {
-		if ($userrow['password'] !== md5($password))
-			return false;
-		static::password_upgrade($userrow, $username, $password);
+		return false;
 	}
 	if (password_needs_rehash($userrow['password'], PASSWORD_DEFAULT))
 		static::password_upgrade($userrow, $username, $password);


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-08-19 14:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-30 18:16 [gentoo-commits] proj/bouncer:master commit in: php/lib/ Brian Evans
  -- strict thread matches above, loose matches on Subject: below --
2019-08-19 14:02 Brian Evans
2018-01-30 18:16 Brian Evans
2018-01-30 18:16 Brian Evans
2018-01-30 18:16 Brian Evans
2018-01-30 18:16 Brian Evans
2018-01-30 18:16 Brian Evans
2018-01-30 18:16 Brian Evans
2018-01-30 18:16 Brian Evans
2018-01-30 18:16 Brian Evans
2018-01-30 18:16 Brian Evans
2018-01-30 18:16 Brian Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox