Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: BrianE on February 17, 2019, 09:34:37 AM

Title: API 1.1 not available?
Post by: BrianE on February 17, 2019, 09:34:37 AM
We are running SMF 1.1.21 and I cannot change or upgrade it at present. I have written my own membership program (C++) for the society of which I am MemSec. I would like to interface to SMF to create users instead of having to log in to SMF, go to registration and enter data manually. It seems I need API 1.1 but I cannot find it on this site despite being informed that it is here in 'tools'. So, two questions:
1: If I need API 1.1 where can I get it from?
2: If I don't then how do I create users programatically?

Thanks for reading and hopefully helping.
Title: Re: API 1.1 not available?
Post by: Arantor on February 17, 2019, 09:46:58 AM
There isn't an API for 1.1 though I doubt it would take that much to change.

However I'd be more concerned at doing any substantial development on a platform that is 13 years old, receives no support from its authors for security issues and also forces you onto older, known insecure versions of PHP as a result.
Title: Re: API 1.1 not available?
Post by: vbgamer45 on February 17, 2019, 10:58:58 AM
2. I would check out
sources\Subs-Members.php
function registerMember(&$regOptions)

If you want to do via php.
There is also an smf_api.php    out there for 1.1.x

Or you can also just insert the entry into the smf_members database table
I did something like this a long time ago

$salt = substr(md5(rand()), 0, 4);

// Format the username properly.
$username = preg_replace('~[\t\n\r\x0B\0\xA0]+~', ' ', $username);
$ip = isset($_SERVER['REMOTE_ADDR']) ? addslashes(substr(stripslashes($_SERVER['REMOTE_ADDR']), 0, 255)) : '';

$request = mysql_query("
INSERT INTO {$prefix}members
(memberName, realName, passwd, emailAddress, ID_GROUP, posts, dateRegistered, hideEmail, passwordSalt, lngfile, personalText, avatar, memberIP, memberIP2, buddy_list, pm_ignore_list, messageLabels, websiteTitle, websiteUrl, location, ICQ, MSN, signature, usertitle, secretQuestion, additionalGroups)
VALUES (SUBSTRING('$username', 1, 25), SUBSTRING('$username', 1, 25), '" . sha1(strtolower($username) . $password) . "', '$email1', 1, '0', '" . time() . "', '1', '$salt', '', '', '', '$ip', '$ip', '', '', '', '', '', '', '', '', '', '', '', '')");