⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin.php

📁 希望这个对大家有用
💻 PHP
字号:
<?php require_once('Connections/vote.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']);
	
  $logoutGoTo = "index.php";
  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.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($QUERY_STRING) && strlen($QUERY_STRING) > 0) 
  $MM_referrer .= "?" . $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 = "") 
{
  $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;
}
}

if ((isset($_GET['vid'])) && ($_GET['vid'] != "")) {
  $deleteSQL = sprintf("DELETE FROM votemain WHERE vote_id=%s",
                       GetSQLValueString($_GET['vid'], "int"));

  mysql_select_db($database_vote, $vote);
  $Result1 = mysql_query($deleteSQL, $vote) or die(mysql_error());
}

mysql_select_db($database_vote, $vote);
$query_rsVote = "SELECT vote_id, vote_title, vote_time FROM votemain ORDER BY vote_time DESC";
$rsVote = mysql_query($query_rsVote, $vote) or die(mysql_error());
$row_rsVote = mysql_fetch_assoc($rsVote);
$totalRows_rsVote = mysql_num_rows($rsVote);
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>在线投票系统后台管理</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
function deleteVote ( vid ) {
  ans = confirm ( "确实要删除这个投票主题及其所有选项吗?" );
  if ( ans ) {
    location.href = "admin.php?vid=" + vid;
  }
}
</script>
</head>

<body>
<table width="98%" border="1" frame="below" rules="none">
  <tr>
    <td scope="col"><img src="images/logo.gif" width="160" height="33" /></td>
    <td valign="bottom" scope="col"><a href="index.php">系统首页</a></td>
    <td valign="bottom" scope="col"><a href="addnew.php">发起新投票</a></td>
    <td valign="bottom" scope="col"><a href="<?php echo $logoutAction ?>">注销</a></td>
    <td align="right" valign="bottom" scope="col"><?php echo date("Y年n月j日"); ?>&nbsp;&nbsp;</td>
  </tr>
</table>
<br />
当前位置:后台管理<br /><br />
<?php if ($totalRows_rsVote > 0) { // Show if recordset not empty ?>
  <table width="98%" border="1" cellpadding="5" bordercolor="#cccccc">
    <tr bgcolor="#666666">
      <th class="title">编号</th>
      <th class="title">投票主题</th>
      <th class="title">发起时间</th>
      <th class="title">操作</th>
    </tr>
    <?php do { ?>
      <tr>
        <td align="center"><?php echo $row_rsVote['vote_id']; ?></td>
        <td><?php echo $row_rsVote['vote_title']; ?></td>
        <td align="center"><?php echo $row_rsVote['vote_time']; ?></td>
        <td align="center"><a href="additem.php?vid=<?php echo $row_rsVote['vote_id']; ?>">添加选项</a>&nbsp;<a href="update.php?vid=<?php echo $row_rsVote['vote_id']; ?>">编辑选项</a>&nbsp;<a href="#" onclick="deleteVote(<?php echo $row_rsVote['vote_id']; ?>);">删除主题</a></td>
      </tr>
      <?php } while ($row_rsVote = mysql_fetch_assoc($rsVote)); ?>
  </table>
  <?php } // Show if recordset not empty ?>
<?php if ($totalRows_rsVote == 0) { // Show if recordset empty ?>
  <table width="256" border="1" align="center">
    <tr>
      <th align="center" bgcolor="#666666" class="title">提示信息</th>
    </tr>
    <tr>
      <td height="56" align="center">目前暂无投票活动。</td>
    </tr>
  </table>
  <?php } // Show if recordset empty ?>
</body>
</html>
<?php
mysql_free_result($rsVote);
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -