mirror of https://git.code.sf.net/p/quake/website
Whee, adding/editing seems to work.
This commit is contained in:
parent
e7130ddc6b
commit
a0a47c2b2c
23
lib/sql.php
23
lib/sql.php
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
SQL function library
|
SQL function library
|
||||||
|
|
||||||
Copyright (C) 2001 Jeff Teunissen <deek@quakeforge.net>
|
Copyright (C) 2001-2007 Jeff Teunissen <deek@quakeforge.net>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
@ -29,10 +29,9 @@ have ('sql');
|
||||||
|
|
||||||
function sqlReadQuery ($query)
|
function sqlReadQuery ($query)
|
||||||
{
|
{
|
||||||
$ret = null;
|
|
||||||
|
|
||||||
global $sqlError;
|
global $sqlError;
|
||||||
|
|
||||||
|
$ret = null;
|
||||||
$sqlError = null; // always set SQL error condition
|
$sqlError = null; // always set SQL error condition
|
||||||
|
|
||||||
if (sqlAvail && $conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass)) {
|
if (sqlAvail && $conn = @mysql_pconnect (sqlHost, sqlUser, sqlPass)) {
|
||||||
|
@ -44,6 +43,7 @@ function sqlReadQuery ($query)
|
||||||
} else { // Successful query, no rows returned.
|
} else { // Successful query, no rows returned.
|
||||||
$ret = true;
|
$ret = true;
|
||||||
}
|
}
|
||||||
|
@mysql_free_result ($result);
|
||||||
} else { // Query failed.
|
} else { // Query failed.
|
||||||
$sqlError = mysql_error ();
|
$sqlError = mysql_error ();
|
||||||
$ret = false;
|
$ret = false;
|
||||||
|
@ -65,23 +65,22 @@ function sqlWriteQuery ($query)
|
||||||
|
|
||||||
$sqlError = null; // always set SQL error condition
|
$sqlError = null; // always set SQL error condition
|
||||||
|
|
||||||
if (sqlAvail
|
if (sqlAvail && defined ('sqlRWUser') && defined ('sqlRWPass')
|
||||||
&& defined (sqlRWUser)
|
|
||||||
&& defined (sqlRWPass)
|
|
||||||
&& $conn = @mysql_pconnect (sqlHost, sqlRWUser, sqlRWPass)) {
|
&& $conn = @mysql_pconnect (sqlHost, sqlRWUser, sqlRWPass)) {
|
||||||
if ($result = @mysql_db_query (sqlDB, $query, $conn)) {
|
if ($result = @mysql_db_query (sqlDB, $query, $conn)) { // Success
|
||||||
if ($numRows = @mysql_affected_rows ($result)) { // Success
|
$ret = @mysql_affected_rows ($conn);
|
||||||
$ret = $numRows;
|
@mysql_free_result ($result);
|
||||||
}
|
|
||||||
} else { // Query failed.
|
} else { // Query failed.
|
||||||
$sqlError = @mysql_error ();
|
$sqlError = @mysql_error ();
|
||||||
$ret = false;
|
$ret = false;
|
||||||
}
|
}
|
||||||
@mysql_close ($conn);
|
|
||||||
} else { // Couldn't even connect.
|
} else { // Couldn't even connect.
|
||||||
if (sqlAvail && defined (sqlRWUser) && defined (sqlRWPass))
|
if (sqlAvail && defined ('sqlRWUser') && defined ('sqlRWPass'))
|
||||||
$sqlError = @mysql_error ();
|
$sqlError = @mysql_error ();
|
||||||
|
else
|
||||||
|
$sqlError = "Cannot write to database.";
|
||||||
}
|
}
|
||||||
|
@mysql_close ($conn);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -12,12 +12,13 @@
|
||||||
$user = $userInfo['u_displayname'];
|
$user = $userInfo['u_displayname'];
|
||||||
|
|
||||||
if ($planText && $planSubj && $mode == "Post") {
|
if ($planText && $planSubj && $mode == "Post") {
|
||||||
|
$planSubj = addSlashes ($planSubj);
|
||||||
$planText = addSlashes ($planText);
|
$planText = addSlashes ($planText);
|
||||||
$query = 'INSERT INTO plans (p_date, p_user, p_subject, p_plan) VALUES ('
|
$query = 'INSERT INTO plans (p_date, p_user, p_title, p_plan) VALUES ('
|
||||||
."NOW(), '$user', '$planSubj', '$planText')";
|
."NOW(), '$user', '$planSubj', '$planText')";
|
||||||
|
|
||||||
$rows = sqlWriteQuery ($query);
|
$rows = sqlWriteQuery ($query);
|
||||||
if ($rows && $rows !== true) {
|
if ($rows) {
|
||||||
echo '<P>Your plan entry has been posted successfully.</P>';
|
echo '<P>Your plan entry has been posted successfully.</P>';
|
||||||
} else {
|
} else {
|
||||||
echo "<P>Somebody screwed up, MySQL said '$sqlError'. Bug a project admin or somethin', eh?</P>";
|
echo "<P>Somebody screwed up, MySQL said '$sqlError'. Bug a project admin or somethin', eh?</P>";
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
$id = $array['p_id'];
|
$id = $array['p_id'];
|
||||||
$usr = $array['p_user'];
|
$usr = $array['p_user'];
|
||||||
$date = dateFromSQLDateTime ($array['p_date']);
|
$date = dateFromSQLDateTime ($array['p_date']);
|
||||||
$subj = convertFromHTML (stripSlashes ($array['p_subject']));
|
$subj = convertFromHTML (stripSlashes ($array['p_title']));
|
||||||
$txt = convertFromHTML (stripSlashes ($array['p_plan']));
|
$txt = convertFromHTML (stripSlashes ($array['p_plan']));
|
||||||
|
|
||||||
newsBoxOpen ("Edit Plan Entry #$id");
|
newsBoxOpen ("Edit Plan Entry #$id");
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
if ($planSubj && $planText && $planUser) {
|
if ($planSubj && $planText && $planUser) {
|
||||||
$planText = addSlashes ($planText);
|
$planText = addSlashes ($planText);
|
||||||
$query = 'UPDATE plans SET'
|
$query = 'UPDATE plans SET'
|
||||||
." p_user='$planUser', p_subject='$planSubj' p_plan='$planText'"
|
." p_user='$planUser', p_title='$planSubj', p_plan='$planText'"
|
||||||
." WHERE p_id='$planID'";
|
." WHERE p_id='$planID'";
|
||||||
|
|
||||||
$rows = sqlWriteQuery ($query);
|
$rows = sqlWriteQuery ($query);
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
echo '<P>Your edit was processed successfully. Congratulations on your revision of history.<STRONG>:)</STRONG></P>';
|
echo '<P>Your edit was processed successfully. Congratulations on your revision of history.<STRONG>:)</STRONG></P>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$query = 'SELECT p_id, p_date, p_user, p_plan FROM plans'
|
$query = 'SELECT p_id, p_date, p_user, p_title, p_plan FROM plans'
|
||||||
." WHERE p_id=$planID";
|
." WHERE p_id=$planID";
|
||||||
|
|
||||||
$entries = sqlReadQuery ($query);
|
$entries = sqlReadQuery ($query);
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
} else {
|
} else {
|
||||||
newsBoxOpen ("All Plan Entries");
|
newsBoxOpen ("All Plan Entries");
|
||||||
|
|
||||||
$query = 'SELECT p_id, p_date, p_user, p_plan FROM plans'
|
$query = 'SELECT p_id, p_date, p_user, p_title, p_plan FROM plans'
|
||||||
.' ORDER BY p_date DESC';
|
.' ORDER BY p_date DESC';
|
||||||
|
|
||||||
$entries = sqlReadQuery ($query);
|
$entries = sqlReadQuery ($query);
|
||||||
|
|
Loading…
Reference in New Issue