Location: PHPKode > projects > Roller CMS > home/fedec/www/rollercms/admin/users/index.php
<?php
/*************************************************************************/
/* ROLLER CMS - ADVANCED PORTAL MANAGEMENT SYSTEM                        */
/* ============================================                          */
/*                                                                       */
/* Copyright (c) 2005 by Federico Campoli (hide@address.com)              */
/*                                                                       */
/* This program is free software. You can redistribute it and/or modify  */
/* it under the terms of the GNU General Public License as published by  */
/* the Free Software Foundation; either version 2 of the License.        */
/*************************************************************************/
include($_SERVER["DOCUMENT_ROOT"].'/common_files/template/main_app_header_admin.inc.php');
?>
<body bgcolor="White">
		
			<?php 
			
			switch($HTTP_GET_VARS["action"])
                        {
			//blocco inserimento nuovo utente
			case "insert":
				//$str_sql=" SELECT ".$table_prefix."_users_insert_1('".$HTTP_POST_VARS["usrname"]."')";
				$str_sql=" SELECT ".$table_prefix."_users_insert_2('".$HTTP_POST_VARS["usrname"]."','".$HTTP_POST_VARS["passwd"]."')";
				$query_results=pg_query($data_conn,$str_sql);
				echo pg_last_error();
				echo "<script language=\"javascript\">self.parent.show_hide(\"frm_new\", \"hide\");";
				echo "self.parent.location.reload();";
				echo "</script>";
			break;

			
			//blocco creazione nuovo utente
			case "new":
			echo "<form method=\"post\" action=\"".$_SERVER["SCRIPT_NAME"]."?action=insert\" onsubmit=\"return valida_new_user(this);\" name=\"form_insert\">";
				echo "<table bgcolor=\"White\" border=\"1\">";
				echo "<tr>";
				echo "<td>Username</td>";
				echo "<td><input type=\"text\" name=\"usrname\" value=\"\" /></td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>Password</td>";
				echo "<td><input type=\"password\" name=\"passwd\" value=\"\" /></td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>Conferma Password</td>";
				echo "<td><input type=\"password\" name=\"conf_passwd\" value=\"\" /></td>";
				echo "</tr>";
				echo "</table>";	
				echo "<input type=\"submit\" value=\"aggiungi utente\" />";	
				echo "</form>";
			break;
			
			
			//blocco delete utenti
			case "delete":
				$str_sql=" SELECT ".$table_prefix."_users_delete_1('".$HTTP_GET_VARS["id_user"]."')";
				$query_results=pg_query($data_conn,$str_sql);
				echo pg_last_error();
				header("Location: ".$_SERVER["SCRIPT_NAME"]);
			
			break;
			//blocco edit elementi degli utenti
			case "edit_item":
				//$str_sql="select ".$table_prefix."_select_item('".$HTTP_GET_VARS["table_name"]."','".$HTTP_GET_VARS["field_name"]."','id_user','".$HTTP_GET_VARS["id_user"]."') as item";
				$str_sql="select ".$table_prefix."_users_select_4('".$HTTP_GET_VARS["table_id"]."','".$HTTP_GET_VARS["field_name"]."','id_user','".$HTTP_GET_VARS["id_user"]."') as item";
				$query_results=pg_query($data_conn,$str_sql);
				$row=pg_fetch_array($query_results);
				echo pg_last_error();
				echo "<form method=\"post\" action=\"".$_SERVER["SCRIPT_NAME"]."?action=update\" >";
				echo "<table bgcolor=\"White\" border=\"1\">";
				echo "<tr>";
				
				echo "<td><input type=\"text\" name=\"item\" value=\"".stripslashes($row["item"])."\" /></td>";
				echo "</tr>";
				echo "</table>";	
				echo "<input type=\"hidden\" name=\"table_id\" value='".$HTTP_GET_VARS["table_id"]."'/>";
				echo "<input type=\"hidden\" name=\"table_name\" value='".$HTTP_GET_VARS["table_name"]."'/>";
				echo "<input type=\"hidden\" name=\"field_name\" value='".$HTTP_GET_VARS["field_name"]."'/>";
				echo "<input type=\"hidden\" name=\"id_user\" value='".$HTTP_GET_VARS["id_user"]."'/>";
				echo "<input type=\"submit\" / value=\"Modifica\">";	
				echo "</form>";
			break;
			
			// Blocco update utenti
			case "update":
				$str_sql=" SELECT ".$table_prefix."_users_update_5(".$HTTP_POST_VARS["table_id"].",'".$HTTP_POST_VARS["field_name"]."','".$HTTP_POST_VARS["item"]."','id_user','".$HTTP_POST_VARS["id_user"]."')";
				$query_results=pg_query($data_conn,$str_sql);
				echo pg_last_error();
				echo "<script language=\"javascript\">self.parent.show_hide(\"frm_edit\", \"hide\");";
				echo "self.parent.location.reload();";
				echo "</script>";
				//header("Location: ".$_SERVER["SCRIPT_NAME"]."?action=layer\"");
				
			break;
			
			// Blocco edit utenti
			case "edit":
				$str_sql="
					SELECT ".$table_prefix."_users.usrname,
						".$table_prefix."_users_info.*
					FROM   ".$table_prefix."_users_info,
						".$table_prefix."_users
					WHERE  ".$table_prefix."_users_info.id_user=".$table_prefix."_users.id_user AND
						".$table_prefix."_users.id_user='".$HTTP_GET_VARS["id_user"]."'
						";
				$query_results=pg_query($data_conn,$str_sql);
				$row=pg_fetch_array($query_results);
				echo "<iframe width=\"400\" height=\"104\" name=\"test\" id=\"frm_edit\" src=\"".$_SERVER["SCRIPT_NAME"]."?action=layer\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" style=\" visibility:hidden; position: absolute; border:solid; border-width : 1px;\"></iframe>";
				echo "<form method=\"post\" action=\"".$_SERVER["SCRIPT_NAME"]."?id_user=".$row["id_user"]."&amp;action=update\" >";
				echo "<table bgcolor=\"White\" border=\"1\">";
				
				//username
				echo "<tr>";
				echo "<td>Username</td>";
				echo "<td><input type=\"hidden\" name=\"usrname\" value='".stripslashes($row["usrname"])."'/>".stripslashes($row["usrname"])."<img src='images/admin/edit.gif' alt='edit' id=\"img_edit_usrname\"width='16' height='16' border='0' onclick=\"dlg_edit_prop('frm_edit','img_edit_usrname','".$_SERVER["SCRIPT_NAME"]."?id_user=".$HTTP_GET_VARS["id_user"]."&amp;action=edit_item&amp;table_id=0&amp;field_name=usrname')\" /></td>";
				echo "</tr>";
				
				//Nome
				echo "<tr>";
				echo "<td>Nome</td>";
				echo "<td><input type=\"hidden\" name=\"name\" value='".stripslashes($row["name"])."'/>".stripslashes($row["name"])."<img src='images/admin/edit.gif' alt='edit' id=\"img_edit_name\"width='16' height='16' border='0' onclick=\"dlg_edit_prop('frm_edit','img_edit_name','".$_SERVER["SCRIPT_NAME"]."?id_user=".$HTTP_GET_VARS["id_user"]."&amp;action=edit_item&amp;table_id=1&amp;field_name=name')\" /></td>";
				echo "</tr>";
				
				//Cognome
				echo "<tr>";
				echo "<td>Cognome</td>";
				echo "<td><input type=\"hidden\" name=\"surname\" value='".stripslashes($row["surname"])."'/>".stripslashes($row["surname"])."<img src='images/admin/edit.gif' alt='edit' id=\"img_edit_surn\"width='16' height='16' border='0' onclick=\"dlg_edit_prop('frm_edit','img_edit_surn','".$_SERVER["SCRIPT_NAME"]."?id_user=".$HTTP_GET_VARS["id_user"]."&amp;action=edit_item&amp;table_id=1&amp;field_name=surname')\" /></td>";
				echo "</tr>";
				
				//Cognome
				echo "<tr>";
				echo "<td>Indirizzo</td>";
				echo "<td><input type=\"hidden\" name=\"address\" value='".stripslashes($row["address"])."'/>".stripslashes($row["address"])."<img src='images/admin/edit.gif' alt='edit' id=\"img_edit_addr\"width='16' height='16' border='0' onclick=\"dlg_edit_prop('frm_edit','img_edit_addr','".$_SERVER["SCRIPT_NAME"]."?id_user=".$HTTP_GET_VARS["id_user"]."&amp;action=edit_item&amp;table_id=1&amp;field_name=address')\" /></td>";
				echo "</tr>";
				
				//Citta'
				echo "<tr>";
				echo "<td>Citta'</td>";
				echo "<td><input type=\"hidden\" name=\"city\" value='".stripslashes($row["city"])."'/>".stripslashes($row["city"])."<img src='images/admin/edit.gif' alt='edit' id=\"img_edit_city\"width='16' height='16' border='0' onclick=\"dlg_edit_prop('frm_edit','img_edit_city','".$_SERVER["SCRIPT_NAME"]."?id_user=".$HTTP_GET_VARS["id_user"]."&amp;action=edit_item&amp;table_id=1&amp;field_name=city')\" /></td>";
				echo "</tr>";
				
				echo "</table>";	
				echo "</form>";
				echo "<a href=".$_SERVER["SCRIPT_NAME"]." >Torna indietro</a>";
			
			break;
			
			case "layer":
			echo "&nbsp;";
			break;
			
			
			// Blocco default di visualizzazione utenti
			default:
				$str_sql="SELECT    ".$table_prefix."_users.usrname,
						    ".$table_prefix."_users_info.*
					  FROM      ".$table_prefix."_users_info,
						    ".$table_prefix."_users
					  WHERE     ".$table_prefix."_users_info.id_user=".$table_prefix."_users.id_user	 
					  ORDER BY  ".$table_prefix."_users.id_user
						 ";
				$query_results=pg_query($data_conn,$str_sql);
				$num_rows=pg_num_rows($query_results);
				echo "<iframe width=\"400\" height=\"200\" name=\"test\" id=\"frm_new\" src=\"".$_SERVER["SCRIPT_NAME"]."?action=layer\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" style=\" visibility:hidden; position: absolute; border:solid; border-width : 1px;\"></iframe>";
				echo "<table bgcolor=\"White\" border=\"1\">";
				echo "<tr>";
				echo "<td>Username</td>";
				echo "<td>Nome</td>";
				echo "<td>Cognome</td>";
				echo "<td>Actions</td>";
				echo "</tr>";
				for ($i=1;$i<=$num_rows;$i++)
				{
					$row=pg_fetch_array($query_results);
					
	
					echo "<tr>";
					echo "<td>".$row["usrname"]."</td>";
					echo "<td>".$row["name"]."</td>";
					echo "<td>".$row["surname"]."</td>";
					echo "<td>";
					echo "<a href='".$_SERVER["SCRIPT_NAME"]."?id_user=".$row["id_user"]."&amp;action=edit'><img src='images/admin/edit.gif' alt='edit' width='16' height='16' border='0' /></a>&nbsp;";
					echo "<a href='".$_SERVER["SCRIPT_NAME"]."?id_user=".$row["id_user"]."&amp;action=delete' onclick=\"return confirm_delete(this)\"><img src='images/admin/delete.gif' width='16' height='16' alt='delete' border='0' /></a></td>";
					echo "</tr>";
				}
				echo "</table>";	
				echo "<br/>";
				
				echo "<img src='images/admin/scrivi.gif' alt='nuovo utente' id=\"img_new_user\"width='20' height='16' border='0' onclick=\"dlg_edit_prop('frm_new','img_new_user','".$_SERVER["SCRIPT_NAME"]."?action=new')\" />";
			break;
			}
			?>
	<br/>
	<br/>
	<A href="<?php echo $folder_admin;?>main/index.php">Main Admin</A>

</body>
</html>
<?php 
include($_SERVER["DOCUMENT_ROOT"].'/common_files/template/main_app_footer.inc.php');

?>
Return current item: Roller CMS