<?php require_once('Connections/dalilack.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	$_SESSION = array();
$params = session_get_cookie_params();
setcookie(session_name(), '', time() -42000,
  $params["path"], $params["domain"],
  $params["secure"], $params["httponly"]);
session_destroy();
  $logoutGoTo = "index.html";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "login/login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO packages (idd, packageTitle, packageDescription, packageGraphic) VALUES (%s, %s, %s, %s)",
				       GetSQLValueString($_SESSION['MM_adminId'], "text"),
					   GetSQLValueString($_POST['packageTitle'], "text"),
                       GetSQLValueString($_POST['packageDescription'], "text"),
                       GetSQLValueString($_FILES['packageGraphic']['name'], "text"));

 

  mysql_select_db($database_dalilack, $dalilack);
  $Result1 = mysql_query($insertSQL, $dalilack) or die(mysql_error());

if (isset($_FILES['files'])){
	foreach ($_FILES['files']['tmp_name'] as $key => $tmp_name){
		move_uploaded_file($tmp_name, "uploaded_files/{$_FILES['files']['name'][$key]}");
	}
}

  $insertGoTo = "marketList.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_dalilack, $dalilack);
$query_product = "SELECT packageId, packageTitle, packageDescription, packageGraphic FROM packages ";
$product = mysql_query($query_product, $dalilack) or die(mysql_error());
$row_product = mysql_fetch_assoc($product);
$totalRows_product = mysql_num_rows($product);
$colname_account = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_account = $_SESSION['MM_Username'];
}
mysql_select_db($database_dalilack, $dalilack);
$query_account = sprintf("SELECT * FROM `admin` WHERE userName=%s",
	GetSQLValueString($colname_account, "text"));
$account = mysql_query($query_account, $dalilack) or die(mysql_error());
$row_account = mysql_fetch_assoc($account);
$totalRows_account = mysql_num_rows($account);
  // assign the recordset result to the session variables
  foreach ($row_account as $col => $val) {
    $_SESSION[$col] = $val;
  }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Portfolio</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="stylesheets/screen.css" type="text/css" rel="stylesheet" media="screen,projection" />
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/framework.js"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>

<!--[if lt IE 7]>
<link href="stylesheets/screen-ie6.css" type="text/css" rel="stylesheet" media="screen,projection" />
<![endif]-->
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="main">
  <div class="header_full">
    <div class="header">
      <div class="twitter"><a href="index.html"><img src="images/twitter.gif" width="38" height="35" border="0" alt="logo" /></a><span>Follow us on Twitter</span></div>
      <div class="top_menu"><a href="#">Email</a> | <a href="#">Client Login</a></div>
      <div class="clr"></div>
      <div class="logo"><a href="index.html"><img src="images/logo2.png" width="249" height="71" border="0" alt="logo" /></a></div>
      <div class="menu">
        <ul>
          <li><a href="index.html"><span>home</span></a></li>
          <li><a href="market.html" class="active"><span>portfolio</span></a></li>
          <li><a href="about.html"><span>about me</span></a></li>
          <li><a href="contact.html"><span>contact me</span></a></li>
        </ul>
      </div>
      <div class="clr"></div>
    </div>
  </div>

  <div class="body">
    <div class="block_box">
      <div class="block_box_t">
        <div class="block_box_b">
          <h1 class="about">E-Market : Click then Post !!</h1>

<div class="marketProductcss" id="marketProductcss">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>

  <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"  enctype="multipart/form-data">
      <table align="left">
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Package Title:<br /></td>
          <td><input type="text" name="packageTitle" value="" size="32" /></td>
          </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Package Description:</td>
          <td><textarea name="packageDescription" cols="32" rows="10"></textarea></td>
          </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">Package Graphic:</td>
          <td><input type="file" name="files[]" id="upload" multiple="multiple"  value="" size="32"  min="1" max="9999"/></td>
          </tr>
        <tr valign="baseline">
          <td nowrap="nowrap" align="right">&nbsp;</td>
          <td><input type="submit" value="Insert record" /></td>
          </tr>
        </table>
      <input type="hidden" name="MM_insert" value="form1" />
      </form>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
     <p>&nbsp;</p>
    <p>&nbsp;</p>

</div>

          <div class="clr"></div>
        </div>
      </div>
    </div>
  </div>
  <div class="footer">
    <div class="footer_resize">
      <p class="leftt"><a href="index.html"><img src="images/logo_f.png" alt="picture" width="249" height="71" border="0" /></a></p>
      <p class="rightt">© Copyright Dalilack.com. <a href="http://dalilack.com/" class="no_border">dalilack.com</a>. All Rights Reserved</p>
      <div class="clr"></div>
    </div>
  </div>
  <div class="clr"></div>
</div>
<p>&nbsp;</p>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprypackageTitle", "none", {validateOn:["blur"]});
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprypackageDescription", {validateOn:["blur"], hint:"Write Down the full details about your product then click on browse to view your ADs with Image"});
</script>
</body>
</html>
<?php
mysql_free_result($product);
?> 