Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: [1] 2 3

Author Topic: [MOD] User login using mysql mod. sNews 1.3  (Read 34259 times)

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
[MOD] User login using mysql mod. sNews 1.3
« on: December 13, 2005, 02:41:59 PM »

This is the begining of a user managment mod using mysql...
I needed something like this so here goes...

Using phpMyAdmin or whatever add this table into you mysql
Code: [Select]
CREATE TABLE `users` (
  `id` int(3) unsigned NOT NULL auto_increment,
  `username` varchar(150) NOT NULL default '',
  `password` varchar(150) NOT NULL default '',
  `email` varchar(250) NOT NULL default '',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM;

Find this:
Code: [Select]
function title() {and BEFORE it add:
Code: [Select]
function do_login() {
$login_username = $_POST['Username'];
$login_password = $_POST['Password'];
  $query = "SELECT * FROM " .s('prefix'). "users WHERE username = '$login_username'";
$result = mysql_query($query);
  while ($r = mysql_fetch_array($result)) {
if ($r['password'] == $login_password) {
$_SESSION['Logged_In'] = "True";
    $_SESSION['Username'] = s('username');
return true;
} else {
return false;
}
}
}

Find this:
Code: [Select]
if (md5($_POST['Username']) == s('username') && md5($_POST['Password']) == s('password')) {
$_SESSION['Logged_In'] = "True";
$_SESSION['Username'] = s('username');
}
and replace the whole thing with:
Code: [Select]
do_login();
This is it for now... Now insert some users and passwords into the mysql... :)

WARNING:
This is a very fist beta mod... Should work correctly...
The passwords are not yet md5d so they are free to anyone who has access to your mysql...
There is still no inteface to allow creationg/changes in users...

TODO:
Hashing password.
Allow users to get new password/change their passwords
Have two user levels... admin / poster... admin can create posters, but posters can't... everyone can post! :P
Maybe mod so each news post has an author?
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4957
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] User login using mysql mod. sNews 1.3
« Reply #1 on: December 13, 2005, 02:48:41 PM »

Ok, I do not get a thing...but the function is neat. Might want to try this out once you have gone from beta to stable version. Is it possible for you to post when this is done and provide a download link with some "explanation for idiots.txt" ??

Patric.
Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
[MOD] User login using mysql mod. sNews 1.3
« Reply #2 on: December 13, 2005, 02:54:19 PM »

I've rewritten quick a few lines of code due to the fact that I had to make unicode work... :/

Before posting the whole file I need to ask the author of this script to allow me to make the mods I need...
The original scripts calls one too many times the mysql connect thingie... Something that in the copy or sNews I'm working on doesn't happen...
If s/he has any objections on changing this I won't be able to post the script cause of the many differences with the original...

:) I'll do my best in any case! ;)

Ps. What thing don't you get?
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4957
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] User login using mysql mod. sNews 1.3
« Reply #3 on: December 13, 2005, 03:00:16 PM »

I think HE, Luka, will say... -"Nah, thats ok"...But I agree with you. He has to say this, as it is his script.

As to what things I do not understand...Hehe, the whole codebit you posted. I'm no hardcore coder in PHP. I can barely make minor changes to it in order to make it look the way I want it to, but functionwise...I'm not to count with ;).

I get what you're doing and what use that could be to ie me, but how you do it is beyond me, as is what Luka and Albert and the others on this here site...I'm just an poor ol' designer...
Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
[MOD] User login using mysql mod. sNews 1.3
« Reply #4 on: December 13, 2005, 03:04:05 PM »

I've been flamed quite a few times for naming he female coders so... :P hehhh~ ;)

I've just PMd luka with a whole bunch hoping he's aint gonna get pissed off~ ^_^
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4957
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] User login using mysql mod. sNews 1.3
« Reply #5 on: December 13, 2005, 03:07:55 PM »

Hehe...well we do not flame eachother here... I can actually ask the most stupid q's ever and just get plain answers, so if I haven't gotten flamed here, you  won't.

Luka, won't be pissed off. He's kind of busy right now with the 1.4 version and it's upcoming release, so possibly you'll have to wait for an answer, but not pissed off...And I think you'll get the answer aswell rather swiftly...

P
Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
[MOD] User login using mysql mod. sNews 1.3
« Reply #6 on: December 13, 2005, 03:13:40 PM »

There are just some stuff I'd REAAAAALLLLYYYY love to get to the 1.4 version so I don't have to mod every version to get unicode working! :(

After this I think we could get down and make a mod that will allow modules...
so every mod would be just one file in a directory or something like this...

Shouldn't be very difficult considering the code is so clean... :)
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4957
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] User login using mysql mod. sNews 1.3
« Reply #7 on: December 13, 2005, 03:19:32 PM »

That kind of thinking is darn good...

The intention with this script is to keep it simple, neat, nice and a "one filer"...as it should, I'd might add. We do not want another MamboJambo ;). But I can imagen more addons/mod's or what ever you might call it. Certain site's crave certain slutations, hehe...solutions, I mean. Which in plain english would be something like: A mod to allow modules would be awsome !!

I have some thought's on what to do, but have no clue what so ever on how to achieve it...

Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1746
    • http://www.snewscms.com
[MOD] User login using mysql mod. sNews 1.3
« Reply #8 on: December 13, 2005, 03:24:19 PM »

I've seen the message you sent me analyzerx.

Version 1.4 that you see on Solucija.com is using a perm connection to the database, and I'm testing it to see if it'll be good enough or we'll connect to the database every time.

I'll be happy to hear to all suggestions you might have considering mods, addons and the rest of the family.

I'm just kinda busy right now with the new version and some small problems came out to the light  ;D
Since SEF url's arrived every link has to have a full path... Even the style.css in your template... I can see error reports now  ;D

The thing you're working on, the database stored users, hm.. It's a thing we could do in like an hour, but there are some things that need to be discussed. Believe me that I've given this a lot of thought and still decided to keep the username and password in the snews.php.. However, a mod would be great  ;D
Logged

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
[MOD] User login using mysql mod. sNews 1.3
« Reply #9 on: December 13, 2005, 03:29:42 PM »

Thoughts are perfect too~ ;)

I like that the script is only one file, (very much to be exact ;) but for example now anyone who wants to adding something,
(authors, geolocations, xml, links in the menu etc) has to mod the file...

Wouldn't be easier both for devs and users that s/he could just upload one file and be done with? :)

Luka:
Thanks for the quick reply~ ^_^

I supose that the discussions are on the "bulletproof" part you are talking about on the site? :P

If I can help beta testing and working on bugs just tell me~ ^_^ I'd be more than happy to~ :)
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

Luka

  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 36
  • Posts: 1746
    • http://www.snewscms.com
[MOD] User login using mysql mod. sNews 1.3
« Reply #10 on: December 13, 2005, 03:33:54 PM »

Quote from: analyzerx
I supose that the discussions are on the "bulletproof" part you are talking about on the site? :P

Exactly. Engine vurnerabilities are being reported as much intense as Britney's boobslip, and
there are some really bad people that will make me stop working on sNews eventually.

Quote from: analyzerx
If I can help beta testing and working on bugs just tell me~ ^_^ I'd be more than happy to~ :)

Well if you have the time I could email some copies of the new engine tonight to anyone who wants
to take a test ride  ;D
Logged

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
[MOD] User login using mysql mod. sNews 1.3
« Reply #11 on: December 13, 2005, 03:39:50 PM »

I'll try to see how I can make this as secure as I can...
XSS and MySQL injection won't be a problem on the mod side and I'll try to see what happens with url injections and stuff and get back to you~ ^_^

Quote from: Luka
Well if you have the time I could email some copies of the new engine tonight to anyone who wants
to take a test ride  ;D

'd love to~ ^_^
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4957
  • I'm a self-made man and worships my creator.
    • p-ahlqvist.com
[MOD] User login using mysql mod. sNews 1.3
« Reply #12 on: December 13, 2005, 03:43:36 PM »

Quote
to anyone who wants
to take a test ride

Well, now we just have to make a female kinda logo to use... As in "I would like to take her for a ride"...

Pardon my sexist approach ;)...
Logged
My sNews site
"It's only dead fish that goes with the flow... "
Updated, online again - Free designs

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
[MOD] User login using mysql mod. sNews 1.3
« Reply #13 on: December 13, 2005, 05:01:34 PM »

Ok, it took me a bit more than one hour but it's done now... :)
The basic at least... :P

Add edit delete users... but everyone can... It's just a couple more lines to put admin/user modes but I need to be somewhere now... :/

If anyone has any ideas on what else should be done please feel free~ ;)

(users will be able to change ONLY their password, admins can change everyone's ;)
(Passwords will be md5d so user CANOT retrieve his password... ^_^ this is for many reasons... ;)
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.

George Antoniadis

  • Sr. Member
  • ****
  • Karma: 0
  • Posts: 479
[MOD] User login using mysql mod. sNews 1.3
« Reply #14 on: December 13, 2005, 07:12:00 PM »

http://noodles.gr/sNews/sNews_1.3_pconnect-mod+user-db/

That's a working draft... login with admin/admin :)
I'm working on the admin/user modes now...

You can find the modded version in:
http://noodles.gr/sNews/sNews_1.3_pconnect-mod+user-db/snews_php.txt
I'll update it every time it's stable ;)
Logged
How I feel like I'm starless, I'm ready to fade now.
And how I feel like I'm starless, I'm hopeless and greyed out.
Pages: [1] 2 3