Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
Trubador
Regular
Regular



Joined: Dec 28, 2004
Posts: 94

PostPosted: Fri Jun 30, 2006 6:09 pm Reply with quote

I've been trying for a while now to change the way adminid acts in displaying the "Editorial by 0" in weblink module. It shows the admin ID instead of the admin username.

I've searched the web for a fix but found none and tried to myself, without success.

Im currently using RP-weblinks but the code is the same for the basic module.

Can any Guru shed any light on this?

Cheers

Trub
 
View user's profile Send private message
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Fri Jun 30, 2006 7:05 pm Reply with quote

This "guru" is puzzled. How do you get to see the "editorial by 0" thing? Can you take me thru the steps to get that far and I'll look in the code to see where it's generated once I can duplicate it on my test site. It may take a day or two or three as I'll be in and out (unless someone else gets to it first).

I don't use weblinks much, never found much use for it. I'd love to find a site that has it set up well and where it serves a useful purpose. Any leads appreciated.
 
View user's profile Send private message Visit poster's website
jaded
Theme Guru



Joined: Nov 01, 2003
Posts: 1006

PostPosted: Fri Jun 30, 2006 9:00 pm Reply with quote

nsn supporters is much more useful in my opinion. That is what I would choose to use in place of weblinks.

_________________
Themes BB Skins [ Only registered users can see links on this board! Get registered or login! ]
Graphic Tees [ Only registered users can see links on this board! Get registered or login! ]
Paranormal Tees [ Only registered users can see links on this board! Get registered or login! ]
Ghost Stories & More [ Only registered users can see links on this board! Get registered or login! ] 
View user's profile Send private message Visit poster's website
Trubador







PostPosted: Sat Jul 01, 2006 8:04 am Reply with quote

I've installed Ravens 7.6 2.02.02 Distro. You do not need to login as the weblinks module is accessable to all.
[ Only registered users can see links on this board! Get registered or login! ]

You will notice that "Alateen" is the first link in there and has now got an editorial link.

Editorials for links can be added to any weblink via ACP - "Modify a Link". this is the only way an editorial can be added. You can not add an editorial through ACP - "Add a New Link". It has to be done when you Modify one.

My other site uses RP Web_Links but has the same problem and the same code to produce and view the Editorial, so if the Basic module can be fixed I'll also be able to fix the other Smile

I've found two functions in modules/weblinks/index.php

The first for displaying the current editorial

Quote:

function viewlinkeditorial($lid, $ttitle) {
global $prefix, $db, $admin, $module_name;
include("header.php");
include("modules/$module_name/l_config.php");
menu(1);
$lid = intval(trim($lid));
$result = $db->sql_query("SELECT adminid, editorialtimestamp, editorialtext, editorialtitle FROM ".$prefix."_links_editorials WHERE linkid = '$lid'");
$recordexist = $db->sql_numrows($result);
$ttitle = htmlentities($ttitle);
$transfertitle = ereg_replace ("_", " ", $ttitle);
$displaytitle = $transfertitle;
echo "<br>";
OpenTable();
echo "<center><font class=\"option\"><b>"._LINKPROFILE.": ".htmlentities($displaytitle)."</b></font><br>";
linkinfomenu($lid, $ttitle);
if ($recordexist != 0) {
while($row = $db->sql_fetchrow($result)) {
$adminid = intval($row['adminid']);
$editorialtimestamp = $row['editorialtimestamp'];
$editorialtext = stripslashes($row['editorialtext']);
$editorialtitle = stripslashes(check_html($row['editorialtitle'], "nohtml"));
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2})Sad[0-9]{1,2})Sad[0-9]{1,2})", $editorialtimestamp, $editorialtime);
$editorialtime = strftime("%F",mktime($editorialtime[4],$editorialtime[5],$editorialtime[6],$editorialtime[2],$editorialtime[3],$editorialtime[1]));
$date_array = explode("-", $editorialtime);
$timestamp = mktime(0, 0, 0, $date_array['1'], $date_array['2'], $date_array['0']);
$formatted_date = date("F j, Y", $timestamp);
echo "<br><br>";
OpenTable2();
echo "<center><font class=\"option\"><b>'$editorialtitle'</b></font></center>"
."<center><font class=\"tiny\">"._EDITORIALBY." $adminid - $formatted_date</font></center><br><br>"
."$editorialtext";
CloseTable2();
}
} else {
echo "<br><br><center><font class=\"option\"><b>"._NOEDITORIAL."</b></font></center>";
}
echo "<br><br><center>";
linkfooter($lid,$ttitle);
echo "</center>";
CloseTable();
include("footer.php");
}


Which is fine as it is displaying the data given in ACP as $adminid from _links_editorials

The weblinks/admin/index.php has this code to enter the admin id.

Quote:
function LinksModLink($lid) {
global $prefix, $db, $admin_file, $bgcolor1, $bgcolor2;
include("header.php");
GraphicAdmin();
global $anonymous;
$lid = intval($lid);
$result = $db->sql_query("SELECT cid, title, url, description, name, email, hits from " . $prefix . "_links_links where lid='$lid'");
OpenTable();
echo "<center><font class=\"title\"><b>" . _WEBLINKSADMIN . "</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center><font class=\"option\"><b>" . _MODLINK . "</b></font></center><br><br>";
while($row = $db->sql_fetchrow($result)) {
$cid = intval($row['cid']);
$title = stripslashes($row['title']);
$url = $row['url'];
$description = stripslashes($row['description']);
$name = $row['name'];
$email = $row['email'];
$hits = intval($row['hits']);
echo "<form action=".$admin_file.".php method=post>"
."" . _LINKID . ": <b>$lid</b><br>"
."" . _PAGETITLE . ": <input type=\"text\" name=\"title\" value=\"$title\" size=\"50\" maxlength=\"100\"><br>"
."" . _PAGEURL . ": <input type=\"text\" name=\"url\" value=\"$url\" size=\"50\" maxlength=\"100\">&nbsp;[ <a href=\"$url\">Visit</a> ]<br>"
."" . _DESCRIPTION . ":<br><textarea name=\"description\" cols=\"60\" rows=\"10\">$description</textarea><br>"
."" . _NAME . ": <input type=\"text\" name=\"name\" size=\"50\" maxlength=\"100\" value=\"$name\"><br>"
."" . _EMAIL . ": <input type=\"text\" name=\"email\" size=\"50\" maxlength=\"100\" value=\"$email\"><br>"
."" . _HITS . ": <input type=\"text\" name=\"hits\" value=\"$hits\" size=\"12\" maxlength=\"11\"><br>";
echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">"
."" . _CATEGORY . ": <select name=\"cat\">";
$result2 = $db->sql_query("SELECT cid, title, parentid from " . $prefix . "_links_categories order by title");
while($row2 = $db->sql_fetchrow($result2)) {
$cid2 = intval($row2['cid']);
$ctitle2 = stripslashes($row2['title']);
$parentid2 = $row2['parentid'];
if ($cid2==$cid) {
$sel = "selected";
} else {
$sel = "";
}
if ($parentid2!=0) $ctitle2=getparent($parentid2,$ctitle2);
echo "<option value=\"$cid2\" $sel>$ctitle2</option>";
}

echo "</select>"
."<input type=\"hidden\" name=\"op\" value=\"LinksModLinkS\">"
."<input type=\"submit\" value=\"" . _MODIFY . "\"> [ <a href=\"".$admin_file.".php?op=LinksDelLink&amp;lid=$lid\">" . _DELETE . "</a> ]</form><br>";
CloseTable();
echo "<br>";
/* Modify or Add Editorial */
$resulted2 = $db->sql_query("SELECT adminid, editorialtimestamp, editorialtext, editorialtitle from " . $prefix . "_links_editorials where linkid='$lid'");
$recordexist = $db->sql_numrows($resulted2);
OpenTable();
/* if returns 'bad query' status 0 (add editorial) */
if ($recordexist == 0) {
echo "<center><font class=\"option\"><b>" . _ADDEDITORIAL . "</b></font></center><br><br>"
."<form action=\"".$admin_file.".php\" method=\"post\">"
."<input type=\"hidden\" name=\"linkid\" value=\"$lid\">"
."" . _EDITORIALTITLE . ":<br><input type=\"text\" name=\"editorialtitle\" value=\"$editorialtitle\" size=\"50\" maxlength=\"100\"><br>"
."" . _EDITORIALTEXT . ":<br><textarea name=\"editorialtext\" cols=\"60\" rows=\"10\">$editorialtext</textarea><br>"
."</select><input type=\"hidden\" name=\"op\" value=\"LinksAddEditorial\"><input type=\"submit\" value=\"Add\">";
} else {
/* if returns 'cool' then status 1 (modify editorial) */
while($row3 = $db->sql_fetchrow($resulted2)) {
$editorialtimestamp = $row3['editorialtimestamp'];
$editorialtext = stripslashes($row3['editorialtext']);
$editorialtitle = stripslashes($row3['editorialtitle']);
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2})Sad[0-9]{1,2})Sad[0-9]{1,2})", $editorialtimestamp, $editorialtime);
$editorialtime = strftime("%F",mktime($editorialtime[4],$editorialtime[5],$editorialtime[6],$editorialtime[2],$editorialtime[3],$editorialtime[1]));
$date_array = explode("-", $editorialtime);
$timestamp = mktime(0, 0, 0, $date_array['1'], $date_array['2'], $date_array['0']);
$formatted_date = date("F j, Y", $timestamp);
echo "<center><font class=\"option\"><b>Modify Editorial</b></font></center><br><br>"
."<form action=\"".$admin_file.".php\" method=\"post\">"
."" . _AUTHOR . ": $adminid<br>"
."" . _DATEWRITTEN . ": $formatted_date<br><br>"
."<input type=\"hidden\" name=\"linkid\" value=\"$lid\">"
."" . _EDITORIALTITLE . ":<br><input type=\"text\" name=\"editorialtitle\" value=\"$editorialtitle\" size=\"50\" maxlength=\"100\"><br>"
."" . _EDITORIALTEXT . ":<br><textarea name=\"editorialtext\" cols=\"60\" rows=\"10\">$editorialtext</textarea><br>"
."</select><input type=\"hidden\" name=\"op\" value=\"LinksModEditorial\"><input type=\"submit\" value=\"" . _MODIFY . "\"> [ <a href=\"".$admin_file.".php?op=LinksDelEditorial&amp;linkid=$lid\">" . _DELETE . "</a> ]";
}
}
CloseTable();


and the second for updating the database with the new/modified editorial.

Quote:
function LinksAddEditorial($linkid, $editorialtitle, $editorialtext) {
global $aid, $prefix, $db, $admin_file;
$editorialtext = stripslashes(FixQuotes($editorialtext));
$db->sql_query("insert into " . $prefix . "_links_editorials values ('$linkid', '$aid', now(), '$editorialtext', '$editorialtitle')");
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><br>"
."<font class=option>"
."" . _EDITORIALADDED . "<br><br>"
."[ <a href=\"".$admin_file.".php?op=Links\">" . _WEBLINKSADMIN . "</a> ]<br><br>";
echo "$linkid $adminid, $editorialtitle, $editorialtext";
CloseTable();
include("footer.php");
}

function LinksModEditorial($linkid, $editorialtitle, $editorialtext) {
global $prefix, $db, $admin_file;
$linkid = intval($linkid);
$editorialtext = stripslashes(FixQuotes($editorialtext));
$db->sql_query("update " . $prefix . "_links_editorials set editorialtext='$editorialtext', editorialtitle='$editorialtitle' where linkid='$linkid'");
include("header.php");
GraphicAdmin();
OpenTable();
echo "<br><center>"
."<font class=\"option\">"
."" . _EDITORIALMODIFIED . "<br><br>"
."[ <a href=\"".$admin_file.".php?op=Links\">" . _WEBLINKSADMIN . "</a> ]<br><br>";
CloseTable();
include("footer.php");
}

function LinksDelEditorial($linkid) {
global $prefix, $db, $admin_file;
$linkid = intval($linkid);
$db->sql_query("delete from " . $prefix . "_links_editorials where linkid='$linkid'");
include("header.php");
GraphicAdmin();
OpenTable();
echo "<br><center>"
."<font class=\"option\">"
."" . _EDITORIALREMOVED . "<br><br>"
."[ <a href=\"".$admin_file.".php?op=Links\">" . _WEBLINKSADMIN . "</a> ]<br><br>";
CloseTable();
include("footer.php");
}


Im just really unsure on where to edit the second function to update $adminid and whether this will show ID number or Admin Username.

Your help much apprieciated as my sql knowledge is poor.

Trub

P.s. This also applies to Nuke 7.4 as well. Looks like a common error that none have noticed Smile
 
Trubador







PostPosted: Sun Jul 02, 2006 3:49 am Reply with quote

Well...... I totally went off on the wrong track. After looking in the db the correct info was being inserted.

There were two errors however, one in modules/Web_Links/index.php

Quote:
***** FIND *****
$adminid = intval($row['adminid']);

***** REPLACE WITH *****
$adminid = $row['adminid'];


the other in modules/Web_Links/admin/index.php

Quote:
***** FIND *****
while($row3 = $db->sql_fetchrow($resulted2)) {

***** AFTER ADD *****
$adminid = $row3['adminid'];



I think I was looking well too deep and didnt see the forest for the trees Smile

The Editorials now display the Editorial Author Name instead of "0"

Cheers for the replies all.

Trub
 
Trubador







PostPosted: Sun Jul 02, 2006 4:07 am Reply with quote

For RP Web_Links Module change these.

Open root/admin/modules/links.php

Quote:
***** FIND *****
/* if returns 'cool' then status 1 (modify editorial) */
while($row3 = $db->sql_fetchrow($resulted2)) {

***** AFTER ADD *****
$adminid = $row3['adminid'];


Open root/modules/Web_Links/index.php

Quote:
***** FIND *****
$adminid = intval($row['adminid']);

***** CHANGE TO *****
$adminid = $row['adminid'];


Smile

Trub
 
fkelly







PostPosted: Sun Jul 02, 2006 7:28 am Reply with quote

Good job! I managed to replicate this, and though it is in a really obscure corner of Nuke, it is a bug. The links_editorial table correctly stores the adminid as the name of the admin but the application of intval causes the bug you see. Probably way back when the programmer thought that adminid was the numeric value of the administrator's id and not his name and was trying to be "safe" by making sure that whatever value was used was an integer.

I will put this thread into our bug tracking system for the next release of Ravennuke and it will get taken care of. Thanks for reporting it and good detective work.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©