Location: PHPKode > projects > eBlog > admin/todo.php
<?php

/**************************************************************************
 *                                                                        *
 *                                                                        *
 *         Solution: eBlog                                                *
 *          Release: 1.7                                                  *
 *             File: admin/todo.php                                       *
 *               By: Emuci inc.                                           *
 *          Website: http://www.emuci.com                                 *
 *        Copyright: (C) 2010 Emcui inc.                                  *
 *                                                                        *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *                                                                        *
 *   This script is NOT freeware and is subjected to Emuci terms of use   *
 *   located in the docs folder.                                          *
 *                                                                        *
 *                                                                        *
 *************************************************************************/


include 'global.php';
	
$action = $_GET['action'];
$id     = $_GET['id'];
$refresh  = $_GET['refresh'];

if($_SESSION['permission'] == 1){
	
	if(empty($action))
	{
		$action = "showForm";
	}
	
	
	// 1: Force window to refresh
	if ($action=="refresh")
	{
		echo " 
		<script type=\"text/javascript\">
		top.parent.location = \"index.php\";
		</script>
		";
	}
	
	
	
	// 2: Add New Task
	if($action == "add")
	{
		$name = htmlspecialchars($_POST['title']);
		$type = $_POST['type'];
		
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
		$query  = "SELECT id FROM eblog_todo ORDER BY id ASC";
		$result = mysql_query($query);
		while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			$newID = $row['id'];
		}
		$newID++;
		
		mysql_query("INSERT INTO eblog_todo  VALUES ('$newID', '$type', '$name')");
		mysql_close($conn);
		
		echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; url=todo.php?action=refresh\">";
		
	}
	
	
	
	// 3: Remove a task
	if($action == "remove")
	{
		$conn = mysql_connect($dbhost, $dbuser, $dbpass);
		mysql_select_db($dbname);
		
		mysql_query("DELETE FROM eblog_todo WHERE id=$id");
		mysql_close($conn);
		
		echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php\">";
	}
	
			


	// 4: Show Form
	if($action == "showForm")
	{
		echo "<html dir=\"$blog_dir\">
			  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=$blog_windows_encoding\">
				<script language=\"javascript\">
				  function checkForm(form){
				  
				  if(form.title.value == \"\"){
				  alert( \"$lang_erorr_code137\" );
				  form.title.focus();
				  return false;
				  }

				  return true;
				  }
			</script>
			
			  <body text=\"#000000\" link=\"#7d7d7c\" alink=\"7d7d7c\" vlink=\"7d7d7c\" topmargin=\"10\">
			  <div align=\"center\">
			   <form method=\"post\" action=\"todo.php?action=add\" onSubmit=\"return checkForm(this);\">
			  <table bordercolor=\"#727272\" style=\"border-collapse: collapse\" cellSpacing=\"0\" cellPadding=\"4\"  border=\"1\" height=\"20\">
			  <tr bgcolor=\"#f2f2f2\">

			  
			  <td width=\"80\">
			  <font face=\"tahoma\" size=\"2\">$lang_admin_taskName:</font>
			  </td>
			  
			  <td>
			  <input type=\"text\" name=\"title\" size=\"58\" style=\"font-family: Tahoma; font-size: 12px; color: #000000; border: 1px solid #000000;\">
			  </td>
			  
			  </tr><tr bgcolor=\"#dadada\">
			  
			  <td width=\"80\">
			  <font face=\"tahoma\" size=\"2\">$lang_admin_taskType:</font>
			  </td>
			  
			  <td width=\"120\">
			  <select name=\"type\" style=\"width: 110;  height:21\">
			  <option value=\"caution\">$lang_admin_todo_caution</option>
			  <option value=\"add\">$lang_admin_todo_add</option>
			  <option value=\"fix\">$lang_admin_todo_fix</option>
			  <option value=\"info\">$lang_admin_todo_info</option>
			  <option value=\"erorr\">$lang_admin_todo_erorr</option>
			  </select>
			  </td>
			  
			  </tr><tr bgcolor=\"#f2f2f2\">
			  
			  

			  </tr>
			  </table><br><center><input type=\"submit\" value=\"$lang_admin_add\"></center></form></div>
		";
		
		echo "</body></html>";
	}

 }
			
?>
Return current item: eBlog