Customizing SMF > Portals, Bridges, and Integrations
SMF 2.0 API and cronjob script
Sunchaser:
I have a cronjob script that checks for died players of my game and disable their account from the forum.
This is the code in the controller framework:
--- Code: ---function delete_account( $char )
{
require_once( '../../application/libraries/vendors/smf/smf_2_api.php');
$salt = substr(md5(mt_rand()), 0, 4);
kohana::log('debug', '=> Attempting to delete account: ' . $char -> user -> username . ' from forum...');
$res = smfapi_updateMemberData($this -> char -> user -> username,
array(
'member_Name' => $this -> user -> username . '_' . $salt,
'emailAddress' => 'deleted_" . $this -> user -> username . "@x.it',
'realName' => concat('(RIP) ' , realName) ));
kohana::log('debug', 'res: ' . $res );
}
--- End code ---
And i call the URL from the following php script:
--- Code: ---c:\wamp\bin\php\php5.3.5\php.exe ..\..\index.php character/complete_action
--- End code ---
That does some other things and then calls the function delete_account.
However i'm getting this error:
--- Code: ---<p>Errore in <strong>C:/wamp/www/me20_fix/application/libraries/vendors/smf/smf_2_api.php</strong> linea: <strong>563</s
trong>.</p>
<p><code class="block">Undefined index: HTTP_USER_AGENT</code></p>
<h3>Tracciato</h3>
<ul class="backtrace"><li>Errore in <strong>application\models\forumbridge.php</strong> linea: <strong>137</strong>.<pre
>require_once( application\libraries\vendors\smf\smf_2_api.php )</pre></li>
--- End code ---
Probably is because i am calling the function from a command-line php script.
Any help?
Thanks
Arantor:
Make sure first that $_SERVER['HTTP_USER_AGENT'] is defined (SMF is never really aimed at running as a CLI script)
Secondly, I thought updateMemberData worked on a user id not the user name, but if it works for you, fine.
I'm also curious, why disable the account? That seems like a strange way to do things, personally.
Sunchaser:
Thanks,
Players have one account and may have n characters. The forum is a Role Play forum, so when a characters dies and the player creates another one, I want the Character name and his posts to remain, as an history. So i disable their old account and rename the older username by appending a random number.
Sunchaser:
Hm, i got another error, the function that does not work is smfapi_loadUserSettings().
Looked a bit the function and it doesn't seem it can work from a php stand-alone script
Arantor:
Um, no, loadUserSettings() and its ilk looks at the current user through the cookie supplied to it. Doesn't make a lot of sense when calling as a CLI script because the current user is not going to be a forum user.
What exactly are you trying to achieve then?
Navigation
[0] Message Index
[#] Next page
Go to full version