[xoops-cvslog 92] CVS update: xoops2jp/html/modules/mydownloads

Zurück zum Archiv-Index

onokazu onoka****@users*****
2005年 6月 8日 (水) 13:36:25 JST


Index: xoops2jp/html/modules/mydownloads/ratefile.php
diff -u xoops2jp/html/modules/mydownloads/ratefile.php:1.2 xoops2jp/html/modules/mydownloads/ratefile.php:1.2.6.1
--- xoops2jp/html/modules/mydownloads/ratefile.php:1.2	Fri Mar 18 21:52:14 2005
+++ xoops2jp/html/modules/mydownloads/ratefile.php	Wed Jun  8 13:36:25 2005
@@ -1,5 +1,5 @@
 <?php
-// $Id: ratefile.php,v 1.2 2005/03/18 12:52:14 onokazu Exp $
+// $Id: ratefile.php,v 1.2.6.1 2005/06/08 04:36:25 onokazu Exp $
 //  ------------------------------------------------------------------------ //
 //                XOOPS - PHP Content Management System                      //
 //                    Copyright (c) 2000 XOOPS.org                           //
@@ -30,72 +30,72 @@
 $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object
 
 if(!empty($HTTP_POST_VARS['submit'])) {
-	$eh = new ErrorHandler; //ErrorHandler object
-	if(empty($xoopsUser)){
-		$ratinguser = 0;
-	}else{
-		$ratinguser = $xoopsUser->getVar('uid');
-	}
-
-	//Make sure only 1 anonymous from an IP in a single day.
-	$anonwaitdays = 1;
-	$ip = getenv("REMOTE_ADDR");
-	$lid = intval($HTTP_POST_VARS['lid']);
-	$cid = intval($HTTP_POST_VARS['cid']);
-	$rating = intval($HTTP_POST_VARS['rating']);
-
-	// Check if Rating is Null
-	if ($rating=="--") {
-		redirect_header("ratefile.php?cid=".$cid."&amp;lid=".$lid."",4,_MD_NORATING);
-		exit();
-	}
-
-	// Check if Download POSTER is voting (UNLESS Anonymous users allowed to post)
-	if ($ratinguser != 0) {
-		$result=$xoopsDB->query("SELECT submitter FROM ".$xoopsDB->prefix("mydownloads_downloads")." WHERE lid=$lid");
-		while(list($ratinguserDB)=$xoopsDB->fetchRow($result)) {
-			if ($ratinguserDB==$ratinguser) {
-				redirect_header("index.php",4,_MD_CANTVOTEOWN);
-				exit();
-			}
-		}
-
-		// Check if REG user is trying to vote twice.
-		$result=$xoopsDB->query("SELECT ratinguser FROM ".$xoopsDB->prefix("mydownloads_votedata")." WHERE lid=$lid");
-		while(list($ratinguserDB)=$xoopsDB->fetchRow($result)) {
-			if ($ratinguserDB==$ratinguser) {
-				redirect_header("index.php",4,_MD_VOTEONCE);
-				exit();
-			}
-		}
-
-	} else {
-
-		// Check if ANONYMOUS user is trying to vote more than once per day.
-		$yesterday = (time()-(86400 * $anonwaitdays));
-		$result=$xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_votedata")." WHERE lid=$lid AND ratinguser=0 AND ratinghostname = '$ip'  AND ratingtimestamp > $yesterday");
-		list($anonvotecount) = $xoopsDB->fetchRow($result);
-		if ($anonvotecount >= 1) {
-			redirect_header("index.php",4,_MD_VOTEONCE);
-			exit();
-		}
-	}
-
-	//All is well.  Add to Line Item Rate to DB.
-	$newid = $xoopsDB->genId($xoopsDB->prefix("mydownloads_votedata")."_ratingid_seq");
-	$datetime = time();
-	$sql = sprintf("INSERT INTO %s (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES (%u, %u, %u, %u, '%s', %u)", $xoopsDB->prefix("mydownloads_votedata"), $newid, $lid, $ratinguser, $rating, $ip, $datetime);
-	$xoopsDB->query($sql) or $eh("0013");
-
-	//All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB.
-	updaterating($lid);
-	$ratemessage = _MD_VOTEAPPRE."<br />".sprintf(_MD_THANKYOU,$xoopsConfig[sitename]);
-	redirect_header("index.php",4,$ratemessage);
-	exit();
+    $eh = new ErrorHandler; //ErrorHandler object
+    if(empty($xoopsUser)){
+        $ratinguser = 0;
+    }else{
+        $ratinguser = $xoopsUser->getVar('uid');
+    }
+
+    //Make sure only 1 anonymous from an IP in a single day.
+    $anonwaitdays = 1;
+    $ip = getenv("REMOTE_ADDR");
+    $lid = intval($HTTP_POST_VARS['lid']);
+    $cid = intval($HTTP_POST_VARS['cid']);
+    $rating = intval($HTTP_POST_VARS['rating']);
+
+    // Check if Rating is Null
+    if ($rating=="--") {
+        redirect_header("ratefile.php?cid=".$cid."&amp;lid=".$lid."",4,_MD_NORATING);
+        exit();
+    }
+
+    // Check if Download POSTER is voting (UNLESS Anonymous users allowed to post)
+    if ($ratinguser != 0) {
+        $result=$xoopsDB->query("SELECT submitter FROM ".$xoopsDB->prefix("mydownloads_downloads")." WHERE lid=$lid");
+        while(list($ratinguserDB)=$xoopsDB->fetchRow($result)) {
+            if ($ratinguserDB==$ratinguser) {
+                redirect_header("index.php",4,_MD_CANTVOTEOWN);
+                exit();
+            }
+        }
+
+        // Check if REG user is trying to vote twice.
+        $result=$xoopsDB->query("SELECT ratinguser FROM ".$xoopsDB->prefix("mydownloads_votedata")." WHERE lid=$lid");
+        while(list($ratinguserDB)=$xoopsDB->fetchRow($result)) {
+            if ($ratinguserDB==$ratinguser) {
+                redirect_header("index.php",4,_MD_VOTEONCE);
+                exit();
+            }
+        }
+
+    } else {
+
+        // Check if ANONYMOUS user is trying to vote more than once per day.
+        $yesterday = (time()-(86400 * $anonwaitdays));
+        $result=$xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_votedata")." WHERE lid=$lid AND ratinguser=0 AND ratinghostname = '$ip'  AND ratingtimestamp > $yesterday");
+        list($anonvotecount) = $xoopsDB->fetchRow($result);
+        if ($anonvotecount >= 1) {
+            redirect_header("index.php",4,_MD_VOTEONCE);
+            exit();
+        }
+    }
+
+    //All is well.  Add to Line Item Rate to DB.
+    $newid = $xoopsDB->genId($xoopsDB->prefix("mydownloads_votedata")."_ratingid_seq");
+    $datetime = time();
+    $sql = sprintf("INSERT INTO %s (ratingid, lid, ratinguser, rating, ratinghostname, ratingtimestamp) VALUES (%u, %u, %u, %u, '%s', %u)", $xoopsDB->prefix("mydownloads_votedata"), $newid, $lid, $ratinguser, $rating, $ip, $datetime);
+    $xoopsDB->query($sql) or $eh("0013");
+
+    //All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB.
+    updaterating($lid);
+    $ratemessage = _MD_VOTEAPPRE."<br />".sprintf(_MD_THANKYOU, htmlspecialchars($xoopsConfig['sitename']));
+    redirect_header("index.php",4,$ratemessage);
+    exit();
 
 } else {
 
-	$xoopsOption['template_main'] = 'mydownloads_ratefile.html';
+    $xoopsOption['template_main'] = 'mydownloads_ratefile.html';
     include XOOPS_ROOT_PATH."/header.php";
     $lid = intval($HTTP_GET_VARS['lid']);
     $result=$xoopsDB->query("SELECT title FROM ".$xoopsDB->prefix("mydownloads_downloads")." WHERE lid=$lid");


xoops-cvslog メーリングリストの案内
Zurück zum Archiv-Index