Location: PHPKode > scripts > php ireport > phpireport v1.0 alpha revision 25/phpireport/admin.php
 <?
 //echo is_admin_loggedin($admin_username, $admin_password);
 if(is_admin_loggedin($admin_username, $admin_password)=="false")
 {
  $page_content = "
  <form method='post' action='index.php'>
  <label>username: <input type='text' name='admin__username' id='name' /></label>
  <label>password: <input type='password' name='admin__password' id='name' /></label>
  <input type='submit' value='submit' class='button' />
  <input type='hidden' name='page' value='admin'/>
  <input type='hidden' name='action' value='admin_login'/>
  </form>
  ";
 }
 

 if(is_admin_loggedin($admin_username, $admin_password)=="true")
 {
 
 ////////////////////////////
  if($save_options=='yes')
 {
	write_option('site_name', $sitename);
	if($regenerate!=''){write_option('site_key', generate_random_string('250'));}
 }
 
  if($add_new_network=='yes')
 {
	if($read=='yes'){$read='1';}else{$read='0';}
	if($write=='yes'){$write='1';}else{$write='0';}
	if($enable_network=='yes'){$enable_network='1';}else{$enable_network='0';}
	add_network($network_name,$network_url,$key,$read,$write,$enable_network);
 }
 
 
   if($action=='edit_network')
 {
	$network_info = get_network_info($network_id);
	//print_r($network_info);
	
	$edit_network_name = $network_info['name'];
	$edit_network_url = $network_info['url'];
	$edit_key = $network_info['secret_key'];
	if($network_info['read']=='1'){$edit_read="checked";}else{$edit_read="";}
	if($network_info['write']=='1'){$edit_write="checked";}else{$edit_write="";}
	if($network_info['enable']=='1'){$edit_enable_network="checked";}else{$edit_enable_network="";}
	$check_add_new_network = "no";
	$check_edit_exist_network = "yes";
	$edit_id = $network_id;
 }
 else
 {
	$check_add_new_network = "yes";
	$check_edit_exist_network = "no";
 }
 
 
   if($action=='delete_network')
 {
	delete_network($network_id);
 }
 
 if($edit_exist_network=='yes')
 {
 	if($read=='yes'){$read='1';}else{$read='0';}
	if($write=='yes'){$write='1';}else{$write='0';}
	if($enable_network=='yes'){$enable_network='1';}else{$enable_network='0';}
	edit_network_info($edit_id,$network_name,$network_url,$key,$read,$write,$enable_network);
	redirect_to_page("admin");
 }
 
 if($action=="generate_network_write_key")
 {
 generate_network_key($network_id);
 }
 ///////////////////////////
 
 
 
   $page_content = "
  <p class='no-border'><b>GENERAL OPTIONS</b></p>
  <form method='post' target='index.php'>
  <label>site name: <input type='text' name='sitename' value='".read_option('site_name')."' id='name' /></label>
  <label>site key: <input type='text' name='site_key' value='".read_option('site_key')."' id='name' /></label>
  <input type='submit' name='regenerate' value='regenrate site key' class='button' />
  <input type='submit' value='save options' class='button' />
  <input type='hidden' name='page' value='admin'/>
  <input type='hidden' name='save_options' value='yes'/>
  </form>

  <br>
  <p class='no-border'><b>ADD/EDIT NETWORK</b></p>
  <form method='post' target='index.php'>
  <label>network name: <input type='text' name='network_name' id='name' value='".$edit_network_name."' /></label>
  <label>network url: <input type='text' name='network_url' id='name' value='".$edit_network_url."' /></label>
  <label>network secret key: <input type='text' name='key' id='name' value='".$edit_key."' /></label>
  <br>
  <label><input type='checkbox' name='read' value='yes' ".$edit_read."/> grab reports </label>
  <br>
  <label><input type='checkbox' name='write' value='yes' ".$edit_write."/> send reoprts </label>
  <br>
  <label><input type='checkbox' name='enable_network' value='yes' ".$edit_enable_network."/> enable network </label>
  <br><br>
  <label><input type='submit' value='add/edit network' class='button' /></label>
  <input type='hidden' name='page' value='admin'/>
  <input type='hidden' name='add_new_network' value='".$check_add_new_network."'/>
  <input type='hidden' name='edit_exist_network' value='".$check_edit_exist_network."'/>
  <input type='hidden' name='edit' value='yes'/>
  <input type='hidden' name='edit_id' value='".$edit_id."'/>
  </form>


<br>
	<p class='no-border'><b>MY NETWORKS</b></p>
				<table>
					<tr>
						<th>network</th>
						<th>read</th>
						<th>write</th>
						<th>state</th>
						<th></th>
						<th></th>
						<th></th>
					</tr>";
$all_networks = get_all_networks();

//print_r($all_networks);

for ($i = 0; $i <= count($all_networks)-1; $i++) {
if($all_networks[$i]['read']=='1'){$read='<font color="green">YES</font>';}else{$read='<font color="red">NO</font>';}
if($all_networks[$i]['write']=='1'){$write='<font color="green">YES</font>';}else{$write='<font color="red">NO</font>';}
if($all_networks[$i]['enable']=='1'){$enabled='<font color="green">ENABLED</font>';}else{$enabled='<font color="red">DISABLED</font>';}
if($all_networks[$i]['state']=='online'){$state='<font color="green">ONLINE</font>';}else{$state='<font color="red">OFFLINE</font>';}

    $page_content = $page_content ."
					<tr>
						<td><a href='#' title='url: ".$all_networks[$i]['url']."'>".strtoupper($all_networks[$i]['name'])."</a></td>
						<td>".$read."</td>
						<td>".$write."</td>
						<td>".$state."</td>
						<td>".$enabled."</td>
						<td>
						<a href='index.php?page=admin&action=edit_network&network_id=".$all_networks[$i]['id']."'>
						<img src='template/default/images/edit.png' title='edit'/></td>
						<td>
						<a href='index.php?page=admin&action=delete_network&network_id=".$all_networks[$i]['id']."'>
						<img src='template/default/images/del.png' title='delete'/>
						</a>
						</td>
					</tr>";
}					

	
$page_content = $page_content ."
				</table> 

				
	<br>
	<p class='no-border'><b>NETWORKS WRITE PERMISSION</b></p>
			<table>
					<tr>
						<th>network</th>
						<th>write key</th>
						<th></th>
						<th>last change</th>
					</tr>";		
					
$all_networks = get_all_networks();

//print_r($all_networks);

for ($i = 0; $i <= count($all_networks)-1; $i++) {

    $page_content = $page_content ."
					<tr>
						<td>".strtoupper($all_networks[$i]['name'])."</td>
						<td>".$all_networks[$i]['secret_key']."</td>
						<td><center>
						<a href='index.php?page=admin&action=generate_network_write_key&network_id=".$all_networks[$i]['id']."'>
						<img src='template/default/images/regenerate.png' title='regenerate write key'>
						</a>
						</center></td>
						<td><center>".microtime_to_string($all_networks[$i]['last_key_change'])."</center></td>
					</tr>";
}		
					
$page_content = $page_content . "					
			</table>

	<br>
	<p class='no-border'><b>MY WRITE KEYS</b></p>
			<table>
			<tr>
			<th>network</th>
			<th>my write key</th>
			</tr>";
			
for ($i = 0; $i <= count($all_networks)-1; $i++) {

    $page_content = $page_content ."
					<tr>
						<td>".strtoupper($all_networks[$i]['name'])."</td>
						<td>".$all_networks[$i]['my_write_key']."</td>
					</tr>";
}
			
$page_content = $page_content . "			
			</table>
			
<a href='index.php?page=admin&action=admin_logout'>logout</a>				
	";
   }
 ?>
Return current item: php ireport