Donations

Help support Pro_News and become a member of our Sponsors Group
The tip jar is at PayPal, but does not require a PayPal account
User Info
Välkommen Anonym
Medlemskap:
Senaste: Witewolf
Nya idag: 0
Nya igår: 0
Genomsnittligt: 151
Besökare on-line:
Medlemmar: 0
Besökare: 39
Bots: 3
Totalt: 42
Vem är här inne:
Besökare:Pro News Articles
Support Forums
Support Forums
Pro News Articles
Support Forums
Téléchargement
Pro News Articles
Pro News Articles
Pro News Articles
Support Forums
Support Forums
Mon Compte
Support Forums
Pro News Articles
الصفحة الأولى
Support Forums
Support Forums
Nedlastninger
My Account
Pro News Articles
Support Forums
Support Forums
Support Forums
Pro News Articles
Support Forums
Downloads
Support Forums
Support Forums
Pro News Articles
Nedlastninger
Support Forums
Downloads
Nedlastninger
Support Forums
Pro News Articles
Support Forums
Pro News Articles
Support Forums
Pro News Articles
Bots:Google > Hjem
Baidu > Pro News Articles
YANDEX > Pro News Articles
Ansvariga inloggade:
Inga ansvariga inloggade!
Error when your username is not equal to your admin name
Error when your username is not equal to your admin name
Skrivet: Tis Maj 18, 2010 10:15 pm
I had an error tryin the Discuss This! feature.
When i'm clicking That Link is shows me an database error on
News_Pro/functions.php line 2297
$Revision: 3.25 $
$Date: 2010-03-29 15:01:47 $
Author: layingback
$sql = "INSERT INTO ".$forumspro_prefix."topics (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote, icon_id) VALUES ('$subject', $userid, $current_time, $forum_id, ".TOPIC_UNLOCKED.", 0, 0, 0)";
The SQL query is right but when you have diffrent admin name and username the problem comes:
sinces the $user_id definition on line 2283:
list($userid) = $db->sql_fetchrow($db->sql_query("SELECT user_id FROM ".$user_prefix."_users WHERE username='$username'"));
uses the $username, but in the query teh username used is the admin name, wich returns and empty value for the query on line 2283.
This issue is solved using the is_user() function wich returns a 'valid' user_id in this case.
This should be applied on line 2363 on the same file.
Notes:
1. Tested with a Custom Forums_Pro install.
2. DF version 921
3. The Discuss this function worked fine only logged as user.
greenday2k please enter your server specs in your user profile!

greenday2k- Poster

- Inlägg: 21
- Blev medlem: Maj 18, 2009
- Från: Bogotá
Re: Error when your username is not equal to your admin name
Skrivet: Ons Maj 19, 2010 4:29 pm
I'm sorry, I don't follow what your fix actually consists of, and so I can't be sure that I actually understand the problem.
The $username is being taken from the original story, so who is doing the discussThis, and whether or not they have an admin name = user name shouldn't matter ...
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Inlägg: 1229
- Blev medlem: Mar 18, 2006
Re: Error when your username is not equal to your admin name
Skrivet: Ons Maj 19, 2010 9:02 pm
OK, i'll try to explain this better.
To reproduce this you have to have a different administrator and username. Logged as Admin & regular user.
For this case: my admin nickname is: anticitizen1
my regular user name is: aker
Go to admin and Publish a new Article with Comments enabled.
Now go to the homepage click on start the disscusion, or discuss this!
You get this database error:
On /News_Pro/discuss=880.html
While executing query "INSERT INTO nuke_foro_topics (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote, icon_id) VALUES ('PostName', , 1274313251, 95, 0, 0, 0, 0)"
See the empty value for the second field in the query, is empty.
That's supossed to be a user_id.
The debug info showed the query to get that user_id is:
list($userid) = $db->sql_fetchrow($db->sql_query("SELECT user_id FROM ".$user_prefix."_users WHERE username='$username'"));
LINE 2286: SELECT user_id FROM nuke_users WHERE username='anticitizen1'
anticitizen1 is my Administrator Name, not my regular user name.
And if there are no records for a user_id wich has username of "anticitizen1", the query will return an empty value and cause the MySql error.
Now i understand that the solution of $user_id = is_user(); is not valid.
and the cuase of the bug comes from: /pro_news/admin/admin_functions.php line 1141
$postby = (can_admin($module_name) ? is_admin($module_name) : $userinfo['username']);
this returns my admin username not my regular username.
greenday2k please enter your server specs in your user profile!

greenday2k- Poster

- Inlägg: 21
- Blev medlem: Maj 18, 2009
- Från: Bogotá
Re: Error when your username is not equal to your admin name
Skrivet: Ons Maj 19, 2010 9:40 pm
Thanks, got it - both the problem and the solution!
Wow, I just checked, this bug has been there since the original 0.9 beta release that I started from! I guess not too many people use different admin/usernames ![]()
I think that line in admin_functions.php should just be:
$postby = $userinfo['username']);
Please let me know if this works in your set up. Thanks again.
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Inlägg: 1229
- Blev medlem: Mar 18, 2006
Re: Error when your username is not equal to your admin name
Skrivet: Ons Maj 19, 2010 11:22 pm
$postby = $userinfo['username'];
Works fine.
greenday2k please enter your server specs in your user profile!

greenday2k- Poster

- Inlägg: 21
- Blev medlem: Maj 18, 2009
- Från: Bogotá
Re: Error when your username is not equal to your admin name
Skrivet: Tor Maj 20, 2010 7:22 am
Good.
Minor, but can I just ask if you would test the following please?
Create the article logged in as Admin, but NOT logged in as any user. It will post as Anonymous user, which is to be expected. But could you just check that it doesn't cause a similar SQL error inside discussThis when commented on by a properly logged in user or admin? TIA!
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Inlägg: 1229
- Blev medlem: Mar 18, 2006
Re: Error when your username is not equal to your admin name
Skrivet: Tor Maj 20, 2010 4:06 pm
Crated a new article loggged only as Admin.
Then clicked the DiscussThis the post is "correctly" created but using anonymous as user ( visitor, And looks terrible in the forum -thats another issue not directly related with PN ).
Not logged (Nor Admin, nor regular user)
Same history, but this time Not logged at all, click on the discussthis.
Message of "user only area" -wich seems to be fine!
logged as user.
Went and then clicked the DiscussThis as regular user. A Neew post was created correctly but using anomously.
Options:
create a "deafult" author (if none is selected) wich points to a valid account on the users database.
Select the database the user_id checking that is not anonymous using user level >1 AND if that returns an emtpy (no existent) use the info for the default user. Redundant check if option 1 is implemented, but useful if the "original" poster has changed his username (it happens on my site, the new fashion! ;D )
Or just check the user level and if returns an empty string the userinfo['username'] ?
greenday2k please enter your server specs in your user profile!

greenday2k- Poster

- Inlägg: 21
- Blev medlem: Maj 18, 2009
- Från: Bogotá
Re: Error when your username is not equal to your admin name
Skrivet: Fre Maj 21, 2010 7:32 am
No I don't think I want to add that type of contingency code. Pro_News is big enough and complex enough as it is, without adding special case code.
My real concern is/was that it didn't trigger an error. Thanks for testing that.
Anyone who posts without being logged in as user as well as admin is asking for trouble, anywhere in DF. And it is a DF error of omission, not a Pro_News one.
I have a warning in the install notes (which is more than DF does). But I guess I could look at adding some sort of alert to Admin > Pro_News > Submit article...
I avoid this problem with my admins by never giving them the admin login URL! (I'll PM you the details.)
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Inlägg: 1229
- Blev medlem: Mar 18, 2006
Re: Error when your username is not equal to your admin name
Skrivet: Fre Maj 21, 2010 3:28 pm
I understand, But is it possible to add a warning if the admin is not logged as user? to avoid problems on the every day runtime.
greenday2k please enter your server specs in your user profile!

greenday2k- Poster

- Inlägg: 21
- Blev medlem: Maj 18, 2009
- Från: Bogotá
Re: Error when your username is not equal to your admin name
Skrivet: Fre Maj 21, 2010 4:30 pm
- greenday2kBut is it possible to add a warning if the admin is not logged as user?
That's what I meant by:
- layingbackBut I guess I could look at adding some sort of alert to Admin > Pro_News > Submit article...
Just above the basic submit instructions.
But I'm currently trying to display the comments, or at least the first X comments, something like Amazon reviews (but without all the options!) Sorry I'll probably only do for Forums, but if I manage to do in Blocks like I'm want, then it will easy for you to recode to ForumsPro...
layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6.32 / 1.3.39 - 2.2.12 / 4.4.7 - 5.1.37 / 5.3.0 / 9.2.1

layingback- Site Admin

- Inlägg: 1229
- Blev medlem: Mar 18, 2006
Du kan inte svara på inlägg i det här forumet
Du kan inte ändra dina inlägg i det här forumet
Du kan inte ta bort dina inlägg i det här forumet
Du kan inte rösta i det här forumet
Du kan inte bifoga filer i det här fourmet
Du kan inte ladda ner filer i detta forum
Alla tider är GMT











