[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnuheter-dev] jcexport: !is_numeric() m m
From: |
Ulf Harnhammar |
Subject: |
[Gnuheter-dev] jcexport: !is_numeric() m m |
Date: |
Thu, 15 Aug 2002 20:22:21 +0200 (CEST) |
Hej,
jag har nu commitat en del ändringar till jcexport.
1) Som tidigare diskuterats på listan är det av säkerhetsskäl bättre att
använda !is_numeric($x) än $x < 1, när $x används i SQL-satser. Detta är
nu ändrat.
2) På något ställe refererade koden direkt till webbplatsen
gnuheter.com/org. Jag gjorde den mer generell, genom att använda
$nuke_url.
3) Jag lade in en del apostrofer runt variabler i SQL-satser.
4) Några till småändringar.
// Ulf
--- jcexport.php.old 2002-08-15 18:06:25.000000000 +0200
+++ jcexport.php 2002-08-15 19:35:02.000000000 +0200
@@ -22,6 +22,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.
#
+# $Id: jcexport.php,v 1.1 2002/08/15 16:26:56 metaur Exp $
function gethighest($table, $id) {
@@ -53,7 +54,7 @@
function showarticle($endsid, $count, $index) {
global $nuke_url;
- if (@$count < 1)
+ if ((@$count < 1) or (!is_numeric($count)))
$count = 1;
if ($count > 50) {
@@ -61,7 +62,8 @@
exit;
}
- if (@$endsid > 0)
+ $endsql = "";
+ if (is_numeric($endsid))
$endsql = "WHERE sid <= \"$endsid\"";
$sql = "SELECT sid,title,time,topic,aid,informant,hometext,notes,bodytext"
@@ -84,7 +86,7 @@
. " Avdelning: $topictext\n"
. " Författare: $aid\n"
. " URL: $nuke_url"."article.php?sid=$sid\n";
- if ("$aid" != "$informant")
+ if ($aid != $informant)
echo " Insänt av: $informant\n";
echo "\n"
. "$hometext\n"
@@ -100,8 +102,7 @@
function showcomment($tid) {
global $nuke_url;
- # Not strictly necessary, but it feels better.
- if (@$tid < 1) {
+ if (!is_numeric($tid)) {
echo "\"$tid\" är inte en giltig tid.";
exit;
}
@@ -118,12 +119,12 @@
list($pid, $sid, $date, $name, $email, $url, $subject, $comment) = $resarray;
- $sql = "SELECT title FROM stories WHERE sid=$sid";
+ $sql = "SELECT title FROM stories WHERE sid='$sid'";
$result = mysql_query($sql);
if (!$result) { echo mysql_errno(). ": ".mysql_error(); exit(); }
$resarray = mysql_fetch_row($result);
if (!$resarray) {
- echo "Very strange. Article $sid does not exist.\n";
+ echo "Konstigt. Artikel $sid finns inte.\n";
exit;
}
list($title) = $resarray;
@@ -144,8 +145,7 @@
function showpoll($pollID) {
global $nuke_url;
- # Not strictly necessary, but it feels better.
- if (@$pollID < 1) {
+ if (!is_numeric($pollID)) {
echo "\"$pollID\" är inte en giltig pollID.";
exit;
}
@@ -165,13 +165,13 @@
. "Undersökning: $pollTitle\n"
. "\n"
. " Avdelning: Undersökning\n"
- . " Röstningsbås: http://www.gnuheter.com/pollBooth.php?pollID=$pollID\n"
- . " Resultat:
http://www.gnuheter.org/pollBooth.php?op=results&pollID=$pollID\n"
+ . " Röstningsbås: ${nuke_url}pollBooth.php?pollID=$pollID\n"
+ . " Resultat: ${nuke_url}pollBooth.php?op=results&pollID=$pollID\n"
. "\n"
. " $pollTitle\n"
. "\n";
- $sql = "SELECT optionText FROM poll_data WHERE pollID=$pollID";
+ $sql = "SELECT optionText FROM poll_data WHERE pollID='$pollID'";
$result = mysql_query($sql);
if (!$result) { echo mysql_errno(). ": ".mysql_error(); exit(); }
while ($resarray = mysql_fetch_row($result)) {
@@ -186,7 +186,7 @@
function showpollcomment($tid) {
global $nuke_url;
- if (@$tid < 1) {
+ if (!is_numeric($tid)) {
echo "\"$tid\" är inte en giltig tid.";
exit;
}
@@ -203,7 +203,7 @@
list($pid, $pollID, $date, $name, $email, $url, $subject, $comment) =
$resarray;
- $sql = "SELECT pollTitle FROM poll_desc WHERE pollID=$pollID";
+ $sql = "SELECT pollTitle FROM poll_desc WHERE pollID='$pollID'";
$result = mysql_query($sql);
if (!$result) { echo mysql_errno(). ": ".mysql_error(); exit(); }
$resarray = mysql_fetch_row($result);
@@ -229,7 +229,7 @@
function showdiary($did) {
global $nuke_url;
- if (@$did < 1) {
+ if (!is_numeric($did)) {
echo "\"$did\" är inte en giltig did.";
exit;
}
@@ -261,12 +261,12 @@
function help() {
global $nuke_url;
- $url = "$nuke_url"."jcexport.php?op=";
+ $url = $nuke_url."jcexport.php?op=";
echo "Användning:\n"
. $url."help Den här hjälptexten.\n"
. $url."index Visa högsta kommentar/artikelnummer.\n"
- . $url."diary&did=DID Visa daboksinlägg nummer DID.\n"
+ . $url."diary&did=DID Visa dagboksinlägg nummer DID.\n"
. $url."pollcomment&tid=TID Visa undersökningskommentar nummer TID\n"
. $url."poll&pollID=ID Visa undersökning nummer ID\n"
. $url."comment&tid=TID Visa kommentar nummer TID\n"
@@ -285,7 +285,7 @@
header("Content-Type: text/plain");
-if ("$index" == "yes")
+if ($index == "yes")
index();
switch ($op) {
@@ -317,5 +317,6 @@
default:
help();
}
+
include('counter.php');
?>
- [Gnuheter-dev] jcexport: !is_numeric() m m,
Ulf Harnhammar <=