Classes and problems with links...
Posted: Sun Aug 17, 2003 4:43 pm
ok, I'll just start off by admitting I am gonna be a bastard and post a lot of code, cause I don't really know where my problem is coming from. Hell, if what you suggests actually even works, I would be willin to paypal you a few bucks! So here's the problem. I am using Oxynews inside of an OOP ticket tracking system called DCL. I have to put the news program into classes so that I can get it to use the same security system as the DCL. When I put it into the class and integrate the security system, the edit news postings' self generated links do not work, and just pop the same page up again. So here's the code.
If you need any more info, I will be watching the post for the remainder of the day. Thanks, I really really appreciate ANY help!!!
Code: Select all
<?php
class oxynews_N_edit_process;
{
function dpn()
{
include("oxynews_config.php");
//This puts it inside the other program//
commonHeader();
// function DPN ($num_rows, $this_page, $table_name, $slq_more = "", $extra_url = "") {
/*
Parameter 1: The number of rows that it will change for every time you press a next or prev button.
have been made it will output 0, just as it should.
Parameter 2: The path to the page where the script is used.
Parameter 3: The name of the table where the scripts counts rows in.
Parameter 4: If you need to add something like, "where id=something" to the query then do it there.
Parameter 5: If you need to add more to the links write it here. Remember the & at the start.
Remember that you must open a connection to the sever and also open a database before you use this function.
*/
global $DPN_row_num, $DPN_Button;
/* Design */
$super_prev = "Start";
$prev = "Prev";
$number_r = "[";
$number_l = "]";
$next = "Next";
$super_next = "End";
$non = "--";
$mysql_query = "SELECT COUNT(*) FROM $table_name";
if ($slq_more) {
$mysql_query .= " ".$slq_more;
}
$mysql_result = @mysql_query($mysql_query);
$mysql_row = @mysql_fetch_row($mysql_result);
$total_rows = $mysql_row[0];
settype($DPN_row_num, "integer");
if (empty($DPN_row_num) OR $DPN_row_num < 0) {
$DPN_row_num = 0;
} elseif ($DPN_row_num > $total_rows) {
$DPN_row_num = floor($total_rows/$num_rows)*$num_rows;
} elseif (!is_int($DPN_row_num/$num_rows)) {
$DPN_row_num = floor($DPN_row_num/$num_rows)*$num_rows;
}
$button .= "<b>";
if ($total_rows > $num_rows) { // If the total amount of rows in the database is bigger then $num_rows
/* Looks for Prev Button */
if ($DPN_row_num >= $num_rows) {
$button .= "<a href='main.php?menuAction=oxynews_N_edit.dpn&DPN_row_num=0".$extra_url."'>$super_prev</a>";
$button .= " <a href='main.php?menuAction=oxynews_N_edit.dpn&DPN_row_num=".($DPN_row_num-$num_rows).$extra_url."'>$prev</a>";
} else {
$button .= "$super_prev";
$button .= " $prev";
}
/* Numbers in between next and prev button */
for ($i = 0; ($i*$num_rows) < $total_rows; $i++) {
$button .= " ".$number_r;
if (($i*$num_rows) != $DPN_row_num) {
$button .= "<a href='main.php?menuAction=oxynews_N_edit.dpn&DPN_row_num=".($i*$num_rows).$extra_url."'>";
}
$button .= $i+1;
if (($i*$num_rows) != $DPN_row_num) {
$button .= "</a>";
}
$button .= $number_l;
}
/* Looks for Next Button */
if (($DPN_row_num+$num_rows) < $total_rows) {
$button .= " <a href='main.php?menuAction=oxynews_N_edit.dpn&DPN_row_num=".($DPN_row_num+$num_rows).$extra_url."'>$next</a>";
$button .= " <a href='main.php?menuAction=oxynews_N_edit.dpn&DPN_row_num=".(floor($total_rows/$num_rows)*$num_rows).$extra_url."'>$super_next</a>";
} else {
$button .= " $next";
$button .= " $super_next";
}
$button .= "</b>";
} else {
$button .= $non;
}
$button .= "</b>";
$DPN_Button = $button;
// Security system that was integrated into the news program
if (!$GLOBALS['g_oSec']->HasSecLvl($GLOBALS['dcl_info']['DCL_DEL_WO']))
return PrintPermissionDenied();
echo"<font face='Verdana, Arial, Helvetica, sans-serif' size='2'>
<center>\n";
if ($id) {
$sql = "SELECT * FROM $oxynews_mysql_table_name WHERE id=$id";
if ($oxynews_usermade) {
$sql .= " and author='".$phpUserLogin_userinfo["short"]."'";
}
$result = mysql_query($sql);
if (@mysql_num_rows($result) > 0) { // If there is news in the table.
$myrow = mysql_fetch_assoc($result);
?>Code: Select all
<a href='main.php?menuAction=oxynews_N_edit.dpn'>Back</a><p>
Edit the fields, and press Update!<br>
Note: Titles can only be 40 characters long.</p>
<form name="form" method="post" action="oxynews_N_edit_process.php">
<input type=hidden name="id" value="<?=$myrowї"id"]?>">
<input type=hidden name="DPN_row_num" value="<?=$DPN_row_num?>">
<table>
<tr>
<td colspan="2" align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Title:</font><br><input type ="text" name = "title" MaxLength=50 value="<?php echo $myrowї"title"] ?>"></td>
</tr>
<tr>
<td align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">News:<br><textarea name ="desc" rows = "10" cols = "50" wrap="VIRTUAL"><?php echo $myrowї"description"] ?></textarea><br></font>
</td>
</tr>
</table>
<p>
<input type="Submit" name="update" value="Update">
</form>Code: Select all
<?php
} else {
echo "Something went wrong. Press back and try again too.\n";
}
} else {
DPN(10, "class.oxynews_N_edit.inc.php", "oxynews_news");
//DPN(10,"class.oxynews_N_edit.inc.php",$oxynews_mysql_table_name,$oxynews_usermade);
// Some changes were made to these queries, but none have made them link generation work so far.
//order by id DESC LIMIT $DPN_row_num, 10
$sql = "SELECT * FROM oxynews_news ";
if ($oxynews_usermade) {
$sql .= "WHERE author='".$phpUserLogin_userinfo["short"]."' ";
}
$sql .= "order by id DESC LIMIT ".$DPN_row_num.",10";
$result = mysql_query($sql);
$oxynews_num_rows = @mysql_num_rows($result);
$oxynews_i = 0;
if ($oxynews_num_rows > 0) { // If there is news in the table.
echo"Select the title of the news item you wish to edit:<p>";
echo $DPN_Button."<p>";
echo"<table border = '0' width = '65%' align='center'>\n";
while ($rows = mysql_fetch_assoc($result)) {
if (empty($rows[title])) {
$rows[title] = "ERROR - TITLE IS EMPTY";
}
echo" <tr>
<td bgcolor='#CCCCCC'><font face='Verdana, Arial, Helvetica, sans-serif' size='2'><a href="?menuAction=oxynews_N_edit.dpn&id=$rows[id]&DPN_row_num=$DPN_row_num"><b>$rows[title]</b></a> - Posted by: <b>".$rows[date]." ".$rows[time]." GMT</b> <b><A HREF='mailto:".$rows[email]."'>".$rows[author]."</A></b></font></td>
</tr>
<tr>
<td bgcolor='#FFFFFF'><font face='Verdana, Arial, Helvetica, sans-serif' size='2'>".oxynews_bbcode($rows[description])."</td>
</tr>\n";
$oxynews_i++;
if ($oxynews_i < $oxynews_num_rows) {
echo" <tr>
<td> </td>
</tr>\n";
}
}
echo"</table><p>";
echo $DPN_Button;
} else {
echo "<font face='Verdana, Arial, Helvetica, sans-serif' size='2'>";
if ($oxynews_usermade) {
echo"No news made by you in the database";
} else {
echo"No news in database";
}
echo"</font>\n";
}
}
echo"</center>
</font>";
}
}
?>