Author |
Message |
neralex
Site Admin

Joined: Aug 22, 2007
Posts: 1775
|
Posted:
Mon Dec 13, 2010 7:47 am |
|
hi guys!
i have a question about a part of modules/Search/index.php:
Code:printf('<tr><td><img src="images/folders.gif" border="0" alt="" /> <font class="option"><a href="%s"><b>%s</b></a></font><br /><font class="content">'._CONTRIBUTEDBY.' '.$informant.'<br />'._POSTEDBY.' <a href="%s">%s</a>',$furl,$title,$url,$aid,$informant);
|
in this line are two hyperlinks. the first is the story-link and the 2nd display the name of the author.
story-link:
Code:<font class="option"><a href="%s"><b>%s</b></a></font>
|
author's name:
Code:'._POSTEDBY.' <a href="%s">%s</a>'
|
i want edit the link to the author's name. but if i take a look with the browser in the the sourcecode, then i found this link without a target:
Code:<a href="">author's name</a>'
|
if i click on this "empty" link, then i come to a empty search result. my article was posted with the god-admin, is this the problem or how can i fix this? where is the %s determined?
if i remove the %s from this hyperlink, then its turn off the display of the complete link.
greetz |
Last edited by neralex on Mon Dec 13, 2010 3:32 pm; edited 3 times in total |
|
|
 |
fkelly
Former Moderator in Good Standing

Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY
|
Posted:
Mon Dec 13, 2010 10:04 am |
|
It looks to me like you may have found a bug. If you look at the code:
Code: printf('<tr><td><img src="images/folders.gif" border="0" alt="" /> <font class="option"><a href="%s"><b>%s</b></a></font><br /><font class="content">'._CONTRIBUTEDBY.' '.$informant.'<br/>'._POSTEDBY.' <a href="%s">%s</a>',$furl,$title,$url,$aid,$informant); echo ' '._ON.' '.$datetime.'<br />'.$match
|
which by the way is seriously misformatted according to our "standards", you will see that there are four %s's. The variable substitutions that should take place are:
$furl into first %s
$title into second %s
$url into third %s
$aid into the fourth %s
poor $informant has no where to go -- although it is echoed out after the _CONTRIBUTEDBY constant earlier.
I don't have time to experiment but I'd guess that the second instance of the variable $informant could be removed ... the one after the ",$furl ..."
That may not explain your problem however. It does look to me like $aid, which is the administrator who posted the article should be put into the line you quoted:
'._POSTEDBY.' <a href="">author's name</a>'
The value of $aid is retrieved from the stories table with:
Code:while($row5 = $db->sql_fetchrow($result5) and $x < $offset) {
$sid = intval($row5['sid']);
$aid = stripslashes($row5['aid']);
|
up around line 200 of the current code. Of course there's an extraneous stripslashes in there too ... filtering is totally screwed up in this program ... but I suspect that if you look at the table in phpmyadmin you'll find a missing aid field. Or else throw some diagnostics in and echo it out after you retrieve it and see what's going on.
Sorry, I don't have the time to dig any deeper. If you don't understand the way %s are substituted into a printf statement take a look at the PHP manual. |
|
|
|
 |
Palbin
Site Admin

Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Mon Dec 13, 2010 11:27 am |
|
I'll post a revised index.php tonight if I get time. |
_________________ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. |
|
|
 |
neralex

|
Posted:
Mon Dec 13, 2010 3:31 pm |
|
fkelly wrote: | '._POSTEDBY.' <a href="">author's name</a>' |
it was a copy&paste failure of me:
the correct output on my browser is (author's name = expample for username):
Code:<a href="">author's name</a>
|
and thanks for your answers!! palbin thx for your time and your great work.
btw: i can't answer directly to this post of you. i found no buttouns to "submit" or "preview" |
|
|
|
 |
fkelly

|
Posted:
Mon Dec 13, 2010 3:53 pm |
|
It still looks to me like the value for $aid should be within the double quotes after <a href=
Just checking my stories table in phpmyadmin. The field aid, which goes into the variable $aid ... while it may syntantically be interpreted as "author's id" is really the id of the administrator who posted the article. It can be the same as the "informant" who is the true author of the article but it isn't where a normal user (non-admin) submitted the article.
So you should not have a null value between those quotes ... unless I am misinterpreting what you are saying. You really might want to take a look at your stories table and make sure that the aid field is getting filled. And maybe Palbin will be able to shed more light when he gets a chance to look at this. |
|
|
|
 |
neralex

|
Posted:
Mon Dec 13, 2010 3:59 pm |
|
|
|
 |
fkelly

|
Posted:
Mon Dec 13, 2010 4:24 pm |
|
I don't know what the quote button in forums is supposed to do. I've clicked around on it as you suggested and get flaky looking results. But honestly, I don't care: I don't use it anyway and I stay out of the Forums code wherever possible. If you have an issue with it, it would be best to start a separate thread. Mixing technical issues in the same thread is a sure way to confusion and I admit to being confused by this. Let's deal with the search issues here and get them resolved. |
|
|
|
 |
neralex

|
Posted:
Mon Dec 13, 2010 4:36 pm |
|
okay. the search thing is my goal! |
|
|
|
 |
Palbin

|
Posted:
Mon Dec 13, 2010 4:48 pm |
|
neralex, we are aware of the quote problem. |
|
|
|
 |
Palbin

|
Posted:
Sat Dec 18, 2010 11:04 am |
|
|
|
 |
neralex

|
Posted:
Sat Dec 18, 2010 2:42 pm |
|
Palbin, thanx! it works perfekt for me!
you have one little freespace in a generated url:
search:
Code:echo '<br /><br /><div style="text-align: center;"><a href="modules.php?name=' . $module_name . '&author=' . $author . '&topic=' . $row['topic'] . '&min=' . $max . '&query=' . urlencode($query) .' &type=' . $type . '&category=' . $category . '">';
|
you found in this line:
Code:' &type=' . $type . '
|
remove the freespace before the &:
Code:'&type=' . $type . '
|
...and my validator counts to 0 warnings! great work!
 |
|
|
|
 |
Palbin

|
Posted:
Sat Dec 18, 2010 4:44 pm |
|
|
|
 |
|