<?php
session_start();

$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if *1 && ($_SERVER['QUERY_STRING'] != "")){
 $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if *2 &&($_GET['doLogout']=="true")){
 //to fully log out a visitor we need to clear the session varialbles
 session_unregister('MM_Username');
 session_unregister('MM_UserGroup');

 $logoutGoTo = "view.php";
 if ($logoutGoTo) {
   header("Location: $logoutGoTo");
   exit;
 }
}
?>
<?php require_once('Connections/connAmazon2.php'); ?>
<?php
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

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 (!*3 && (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
$currentPage = $_SERVER["PHP_SELF"];

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
 $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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 *4 && ($_POST["MM_insert"] == "form2")) {
 $insertSQL = sprintf("INSERT INTO amazonz_data (id, title, category, topic, uptime, uset_id) VALUES (%s, %s, %s, %s, %s, %s)",
                      GetSQLValueString($_POST['id'], "int"),
                      GetSQLValueString($_POST['title'], "text"),
                      GetSQLValueString($_POST['category'], "text"),
                      GetSQLValueString($_POST['topic'], "text"),
                      GetSQLValueString($_POST['uptime'], "date"),
                      GetSQLValueString($_POST['uset_id'], "text"));

 mysql_select_db($database_connAmazon2, $connAmazon2);
 $Result1 = mysql_query($insertSQL, $connAmazon2) or die(mysql_error());

 $insertGoTo = "admin.php";
 if (isset($_SERVER['QUERY_STRING'])) {
   $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
   $insertGoTo .= $_SERVER['QUERY_STRING'];
 }
 header(sprintf("Location: %s", $insertGoTo));
}

$maxRows_rsAmazonz2 = 10;
$pageNum_rsAmazonz2 = 0;
if (isset($_GET['pageNum_rsAmazonz2'])) {
 $pageNum_rsAmazonz2 = $_GET['pageNum_rsAmazonz2'];
}
$startRow_rsAmazonz2 = $pageNum_rsAmazonz2 * $maxRows_rsAmazonz2;

$colname_rsAmazonz2 = "%";
if (isset($_GET['key'])) {
 $colname_rsAmazonz2 = (get_magic_quotes_gpc()) ? $_GET['key'] : addslashes($_GET['key']);
}
mysql_select_db($database_connAmazon2, $connAmazon2);
$sessionname=$_SESSION['MM_Username'];
$query_rsAmazonz2 = sprintf("SELECT * FROM amazonz_data WHERE topic LIKE '%s' && uset_id = '$sessionname' ORDER BY uptime DESC" , $colname_rsAmazonz2);
$query_limit_rsAmazonz2 = sprintf("%s LIMIT %d, %d", $query_rsAmazonz2, $startRow_rsAmazonz2, $maxRows_rsAmazonz2);
$rsAmazonz2 = mysql_query($query_limit_rsAmazonz2, $connAmazon2) or die(mysql_error());
$row_rsAmazonz2 = mysql_fetch_assoc($rsAmazonz2);

if (isset($_GET['totalRows_rsAmazonz2'])) {
 $totalRows_rsAmazonz2 = $_GET['totalRows_rsAmazonz2'];
} else {
 $all_rsAmazonz2 = mysql_query($query_rsAmazonz2);
 $totalRows_rsAmazonz2 = mysql_num_rows($all_rsAmazonz2);
}
$totalPages_rsAmazonz2 = ceil($totalRows_rsAmazonz2/$maxRows_rsAmazonz2)-1;

$queryString_rsAmazonz2 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
 $params = explode("&", $_SERVER['QUERY_STRING']);
 $newParams = array();
 foreach ($params as $param) {
   if (stristr($param, "pageNum_rsAmazonz2") == false && 
       stristr($param, "totalRows_rsAmazonz2") == false) {
     array_push($newParams, $param);
   }
 }
 if (count($newParams) != 0) {
   $queryString_rsAmazonz2 = "&" . htmlentities(implode("&", $newParams));
 }
}
$queryString_rsAmazonz2 = sprintf("&totalRows_rsAmazonz2=%d%s", $totalRows_rsAmazonz2, $queryString_rsAmazonz2);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
<title>ログ管理</title>
<style type="text/css">
<!--
.style6 {font-size: 10px}
    • >
</style>
</head>

<body>
<form name="form1" method="get" action="">
 <div align="center"> <?php echo ($_SESSION['MM_Username']. "さん こんにちわ!"); ?>
   <input name="key" type="text" id="key">    
   <input name="Submit" type="submit" value="検索">
 <a href="add.php">投稿</a>   <a href="<?php echo $logoutAction ?>">ログアウト</a> <a href="view.php">投稿閲覧</a></div></form><br>

   <form method="post" name="form2" action="<?php echo $editFormAction; ?>">
     <table width="250" height="100" align="center">
       <tr valign="baseline">
         <td align="left" nowrap class="style6">タイトル:
           <input type="text" name="title" value="" size="32">          </td>
       </tr>
       <tr valign="baseline">
         <td align="left" nowrap><span class="style6">カテゴリ:
             <select name="category">
               <option value="BOOK" <?php if (!(strcmp("BOOK", ""))) {echo "SELECTED";} ?>>BOOK</option>
               <option value="DVD" <?php if (!(strcmp("DVD", ""))) {echo "SELECTED";} ?>>DVD</option>
               <option value="CD" <?php if (!(strcmp("CD", ""))) {echo "SELECTED";} ?>>CD</option>
         </select>
         </span></td>
       </tr>
       <tr valign="baseline">
         <td align="left" valign="top" nowrap><p class="style6">トピック:<br>
           <textarea name="topic" cols="40" rows="5"></textarea>
</p>
         </td>
       </tr>
       <tr valign="baseline">
         <td align="left" nowrap><input type="submit" value="投稿"></td>
       </tr>
     </table>
     <input type="hidden" name="id" value="">
     <input type="hidden" name="uptime" value="<?php echo date('Y/m/d H:i:s'); ?>">
     <input type="hidden" name="uset_id" value="<?php echo($_SESSION['MM_Username']); ?>">
     <input type="hidden" name="MM_insert" value="form2">
   </form>
   <p>&nbsp;</p>
   <table width="400" border="0" align="center" cellpadding="3">
 <?php do { ?>
 <tr>
   <td><span class="style6"><?php echo $row_rsAmazonz2['uptime']; ?></span></td>
 </tr>
 <tr>
   <td><span class="style6"><?php echo $row_rsAmazonz2['title']; ?></span></td>
 </tr>
 <tr>
   <td><span class="style6"><?php echo $row_rsAmazonz2['category']; ?></span></td>
 </tr>
 <tr>
   <td><span class="style6"><?php echo $row_rsAmazonz2['topic']; ?></span></td>
 </tr>
 <tr>
   <td><span class="style6"><?php echo $row_rsAmazonz2['uset_id']; ?></span></td>
 </tr>
 <tr>
   <td><span class="style6"><a href="update.php?id=<?php echo $row_rsAmazonz2['id']; ?>">修正</a> <a href="del.php?id=<?php echo $row_rsAmazonz2['id']; ?>">削除</a> </span>      <hr></td>
 </tr>
 <?php } while ($row_rsAmazonz2 = mysql_fetch_assoc($rsAmazonz2)); ?>
</table>

<table border="0" width="50%" align="center">
 <tr>
   <td width="23%" align="center"><?php if ($pageNum_rsAmazonz2 > 0) { // Show if not first page ?>
     <a href="<?php printf("%s?pageNum_rsAmazonz2=%d%s", $currentPage, 0, $queryString_rsAmazonz2); ?>">先頭</a>
     <?php } // Show if not first page ?>
   </td>
   <td width="31%" align="center"><?php if ($pageNum_rsAmazonz2 > 0) { // Show if not first page ?>
     <a href="<?php printf("%s?pageNum_rsAmazonz2=%d%s", $currentPage, max(0, $pageNum_rsAmazonz2 - 1), $queryString_rsAmazonz2); ?>">戻る</a>
     <?php } // Show if not first page ?>
   </td>
   <td width="23%" align="center"><?php if ($pageNum_rsAmazonz2 < $totalPages_rsAmazonz2) { // Show if not last page ?>
     <a href="<?php printf("%s?pageNum_rsAmazonz2=%d%s", $currentPage, min($totalPages_rsAmazonz2, $pageNum_rsAmazonz2 + 1), $queryString_rsAmazonz2); ?>">次へ</a>
     <?php } // Show if not last page ?>
   </td>
   <td width="23%" align="center"><?php if ($pageNum_rsAmazonz2 < $totalPages_rsAmazonz2) { // Show if not last page ?>
     <a href="<?php printf("%s?pageNum_rsAmazonz2=%d%s", $currentPage, $totalPages_rsAmazonz2, $queryString_rsAmazonz2); ?>">最終</a>
     <?php } // Show if not last page ?>
   </td>
 </tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsAmazonz2);
?>

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2006年11月02日 10:10
添付ファイル

*1 isset($_SERVER['QUERY_STRING']

*2 isset($_GET['doLogout']

*3 isset($_SESSION['MM_Username']

*4 isset($_POST["MM_insert"]