From: <wis...@us...> - 2013-07-16 15:36:28
|
Revision: 11827 http://sourceforge.net/p/xoops/svn/11827 Author: wishcraft Date: 2013-07-16 15:36:22 +0000 (Tue, 16 Jul 2013) Log Message: ----------- PHP Standalone for incorperating into other frameworks and systems without existing condoms like Xortity and Protector Added Paths: ----------- XoopsModules/xortify/standalone/ XoopsModules/xortify/standalone/4.11/ XoopsModules/xortify/standalone/4.11/banned.php XoopsModules/xortify/standalone/4.11/class/ XoopsModules/xortify/standalone/4.11/class/auth/ XoopsModules/xortify/standalone/4.11/class/auth/auth.php XoopsModules/xortify/standalone/4.11/class/auth/auth_curl.php XoopsModules/xortify/standalone/4.11/class/auth/auth_curl_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_curlserialised.php XoopsModules/xortify/standalone/4.11/class/auth/auth_curlserialised_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_curlxml.php XoopsModules/xortify/standalone/4.11/class/auth/auth_curlxml_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_json.php XoopsModules/xortify/standalone/4.11/class/auth/auth_json_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_curl.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_curl_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_curlserialised.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_curlserialised_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_curlxml.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_curlxml_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_json.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_json_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_wgetserialised.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_wgetserialised_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_wgetxml.php XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_wgetxml_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_soap.php XoopsModules/xortify/standalone/4.11/class/auth/auth_soap_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_wgetserialised.php XoopsModules/xortify/standalone/4.11/class/auth/auth_wgetserialised_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/auth_wgetxml.php XoopsModules/xortify/standalone/4.11/class/auth/auth_wgetxml_provisionning.php XoopsModules/xortify/standalone/4.11/class/auth/authfactory.php XoopsModules/xortify/standalone/4.11/class/auth/index.html XoopsModules/xortify/standalone/4.11/class/cache/ XoopsModules/xortify/standalone/4.11/class/cache/apc.php XoopsModules/xortify/standalone/4.11/class/cache/cache.php XoopsModules/xortify/standalone/4.11/class/cache/file.php XoopsModules/xortify/standalone/4.11/class/cache/index.html XoopsModules/xortify/standalone/4.11/class/cache/memcache.php XoopsModules/xortify/standalone/4.11/class/cache/model.php XoopsModules/xortify/standalone/4.11/class/cache/xcache.php XoopsModules/xortify/standalone/4.11/class/curl.php XoopsModules/xortify/standalone/4.11/class/curlserialised.php XoopsModules/xortify/standalone/4.11/class/curlxml.php XoopsModules/xortify/standalone/4.11/class/index.html XoopsModules/xortify/standalone/4.11/class/json.php XoopsModules/xortify/standalone/4.11/class/lists.php XoopsModules/xortify/standalone/4.11/class/rest_curl.php XoopsModules/xortify/standalone/4.11/class/rest_curlserialised.php XoopsModules/xortify/standalone/4.11/class/rest_curlxml.php XoopsModules/xortify/standalone/4.11/class/rest_json.php XoopsModules/xortify/standalone/4.11/class/rest_wgetserialised.php XoopsModules/xortify/standalone/4.11/class/rest_wgetxml.php XoopsModules/xortify/standalone/4.11/class/soap.php XoopsModules/xortify/standalone/4.11/class/wgetserialised.php XoopsModules/xortify/standalone/4.11/class/wgetxml.php XoopsModules/xortify/standalone/4.11/config.php XoopsModules/xortify/standalone/4.11/data/ XoopsModules/xortify/standalone/4.11/images/ XoopsModules/xortify/standalone/4.11/images/accessdenied.png XoopsModules/xortify/standalone/4.11/images/index.html XoopsModules/xortify/standalone/4.11/include/ XoopsModules/xortify/standalone/4.11/include/JSON.php XoopsModules/xortify/standalone/4.11/include/common.php XoopsModules/xortify/standalone/4.11/include/constants.php XoopsModules/xortify/standalone/4.11/include/functions.php XoopsModules/xortify/standalone/4.11/include/index.html XoopsModules/xortify/standalone/4.11/include/post.footer.end.php XoopsModules/xortify/standalone/4.11/include/post.header.addmeta.php XoopsModules/xortify/standalone/4.11/include/post.header.endcache.php XoopsModules/xortify/standalone/4.11/include/post.loader.mainfile.php XoopsModules/xortify/standalone/4.11/include/pre.loader.mainfile.php XoopsModules/xortify/standalone/4.11/poll/ XoopsModules/xortify/standalone/4.11/poll/index.php XoopsModules/xortify/standalone/4.11/providers/ XoopsModules/xortify/standalone/4.11/providers/index.html XoopsModules/xortify/standalone/4.11/providers/projecthoneypot.org/ XoopsModules/xortify/standalone/4.11/providers/projecthoneypot.org/index.html XoopsModules/xortify/standalone/4.11/providers/projecthoneypot.org/post.loader.php XoopsModules/xortify/standalone/4.11/providers/providers.php XoopsModules/xortify/standalone/4.11/providers/stopforumspam.com/ XoopsModules/xortify/standalone/4.11/providers/stopforumspam.com/index.html XoopsModules/xortify/standalone/4.11/providers/stopforumspam.com/post.loader.php XoopsModules/xortify/standalone/4.11/providers/xortify/ XoopsModules/xortify/standalone/4.11/providers/xortify/footer.post.loader.php XoopsModules/xortify/standalone/4.11/providers/xortify/header.post.loader.php XoopsModules/xortify/standalone/4.11/providers/xortify/index.html XoopsModules/xortify/standalone/4.11/providers/xortify/post.loader.php XoopsModules/xortify/standalone/4.11/providers/xortify/pre.loader.php XoopsModules/xortify/standalone/4.11/spam.php Added: XoopsModules/xortify/standalone/4.11/banned.php =================================================================== --- XoopsModules/xortify/standalone/4.11/banned.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/banned.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,9 @@ +<?php + include dirname(__FILE__).'/include/common.php'; + ?> + <h1><?php echo (isset($_SESSION['xortify']['xoops_pagetitle'])?$_SESSION['xortify']['xoops_pagetitle']:'You are banned!'); ?></h1> + <p align="center" style='font-size:1.24em'}><?php echo (isset($_SESSION['xortify']['description'])?$_SESSION['xortify']['description']:'You have been banned by one of our affilate honeypots!'); ?></p> + <p align="center" style='font-size:1.34em; border:dashed; margin:10 10 10 10; background-color:#feedcd;'}><u>Ban Provider:</u> <?php echo (isset($_SESSION['xortify']['provider'])?$_SESSION['xortify']['provider']:'Unknown Provider!'); ?></p> + <p align="center" style='font-size:1.14em; border:dashed; margin:10 10 10 10; background-color:#feedad;'}><u>Xortify Version:</u> <?php echo (isset($_SESSION['xortify']['version'])?$_SESSION['xortify']['version']:'Unknown Provider!'); ?><br/><u>Agent:</u> <?php echo (isset($_SESSION['xortify']['agent'])?$_SESSION['xortify']['agent']:'Unknown User Agent!'); ?><br/><u>PHP Version:</u> <?php echo (PHP_VERSION); ?></p> + <?php +?> Added: XoopsModules/xortify/standalone/4.11/class/auth/auth.php =================================================================== --- XoopsModules/xortify/standalone/4.11/class/auth/auth.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/class/auth/auth.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,140 @@ +<?php +/* + * Prevents Spam, Harvesting, Human Rights Abuse, Captcha Abuse etc. + * basic statistic of them in XOOPS Copyright (C) 2012 Simon Roberts + * Contact: wishcraft - si...@ch... + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * See /docs/license.pdf for full license. + * + * Shouts:- Mamba (www.xoops.org), flipse (www.nlxoops.nl) + * Many thanks for your additional work with version 1.01 + * + * Version: 3.10 Final (Stable) + * Published: Chronolabs + * Download: http://code.google.com/p/chronolabs + * This File: auth.php + * Description: Xortify Authentication Library modeled from Auth. + * Date: 09/09/2012 19:34 AEST + * License: GNU3 + * + */ + +class XortifyAuth { + + var $_dao; + + var $_errors; + /** + * Authentication Service constructor + */ + function XortifyAuth (&$dao){ + $this->_dao = $dao; + } + + /** + * @abstract need to be write in the dervied class + */ + function authenticate() { + $authenticated = false; + + return $authenticated; + } + + /** + * add an error + * + * @param string $value error to add + * @access public + */ + function setErrors($err_no, $err_str) + { + $this->_errors[$err_no] = trim($err_str); + } + + /** + * return the errors for this object as an array + * + * @return array an array of errors + * @access public + */ + function getErrors() + { + return $this->_errors; + } + + /** + * return the errors for this object as html + * + * @return string html listing the errors + * @access public + */ + function getHtmlErrors() + { + global $xoopsConfig; + $ret = '<br>'; + if ( $xoopsConfig['debug_mode'] == 1 || $xoopsConfig['debug_mode'] == 2 ) + { + if (!empty($this->_errors)) { + foreach ($this->_errors as $errno => $errstr) { + $ret .= $errstr . '<br/>'; + } + } else { + $ret .= _NONE.'<br />'; + } + $ret .= sprintf(_AUTH_MSG_AUTH_METHOD, $this->auth_method); + } + else { + $ret .= _US_INCORRECTLOGIN; + } + return $ret; + } + + /** + * checks for variables require in siteinfo package in the auth library + * + * @param array $siteinfo + * + * @return array $siteinfo + * @access public + */ + function check_siteinfo($siteinfo){ + + global $xoopsConfig; + if (!isset($siteinfo)||empty($siteinfo)||!is_array($siteinfo)){ + $siteinfo = array(); + $siteinfo['sitename'] = $xoopsConfig['sitename']; + $siteinfo['adminmail'] = $xoopsConfig['adminmail']; + $siteinfo['systemkey'] = XOOPS_LICENSE_KEY; + $siteinfo['xoops_url'] = XOOPS_URL; + } + + if (!isset($siteinfo['sitename'])||empty($siteinfo['sitename'])) + $siteinfo['sitename'] = $xoopsConfig['sitename']; + + if (!isset($siteinfo['adminmail'])||empty($siteinfo['adminmail'])) + $siteinfo['adminmail'] = $xoopsConfig['adminmail']; + + if (!isset($siteinfo['xoops_url'])||empty($siteinfo['xoops_url'])) + $siteinfo['xoops_url'] = XOOPS_URL; + + if (!isset($siteinfo['systemkey'])||empty($siteinfo['systemkey'])) + $siteinfo['systemkey'] = $xoopsConfig['systemkey']; + + return $siteinfo; + } +} + + +?> Added: XoopsModules/xortify/standalone/4.11/class/auth/auth_curl.php =================================================================== --- XoopsModules/xortify/standalone/4.11/class/auth/auth_curl.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/class/auth/auth_curl.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,212 @@ +<?php +/* + * Prevents Spam, Harvesting, Human Rights Abuse, Captcha Abuse etc. + * basic statistic of them in XOOPS Copyright (C) 2012 Simon Roberts + * Contact: wishcraft - si...@ch... + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * See /docs/license.pdf for full license. + * + * Shouts:- Mamba (www.xoops.org), flipse (www.nlxoops.nl) + * Many thanks for your additional work with version 1.01 + * + * Version: 3.10 Final (Stable) + * Published: Chronolabs + * Download: http://code.google.com/p/chronolabs + * This File: auth_curl.php + * Description: Auth Library with CURL JSON routines for signup and API + * Date: 09/09/2012 19:34 AEST + * License: GNU3 + * + */ + +if (!function_exists('json_encode')){ + function json_encode($data) { + static $json = NULL; + if (!class_exists('Services_JSON') ) { include_once (_RUN_XORTIFY_ROOT_PATH . '/include/JSON.php'); } + $json = new Services_JSON(); + return $json->encode($data); + } +} + +if (!function_exists('json_decode')){ + function json_decode($data) { + static $json = NULL; + if (!class_exists('Services_JSON') ) { include_once (_RUN_XORTIFY_ROOT_PATH . '/include/JSON.php'); } + $json = new Services_JSON(); + return $json->decode($data); + } +} + +if (!defined('XORTIFY_CURL_API')) + define('XORTIFY_CURL_API', _RUN_XORTIFY_API_CURL); + +if (!defined('XORTIFY_USER_AGENT')) + define('XORTIFY_USER_AGENT', sprintf(_MI_XOR_USER_AGENT, _MI_XOR_NAME, _MI_XOR_VERSION, _MI_XOR_RUNTIME, _MI_XOR_MODE)); + +include_once _RUN_XORTIFY_ROOT_PATH . '/class/auth/auth_curl_provisionning.php'; + +class XortifyAuthCurl extends XortifyAuth { + + var $curl_client; + var $curl_xoops_username = ''; + var $curl_xoops_password = ''; + var $_dao; + var $_json = ''; + /** + * Authentication Service constructor + */ + function XortifyAuthCurl (&$dao) { + if (!$ch = curl_init(XORTIFY_CURL_API)) { + trigger_error('Could not intialise CURL file: '.XORTIFY_CURL_API); + return false; + } + $cookies = _RUN_XORTIFY_VAR_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR .' authcurl_'.md5(XORTIFY_CURL_API).'.cookie'; + + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, _RUN_XORTIFY_CURL_CONNECTIONTIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, _RUN_XORTIFY_CURL_TIMEOUT); + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_USERAGENT, XORTIFY_USER_AGENT); + $this->curl_client =& $ch; + } + + + /** + * Authenticate user again curl directory (Bind) + * + * @param string $uname Username + * @param string $pwd Password + * + * @return bool + */ + function authenticate($uname, $pwd = null) { + $authenticated = false; + $this->XortifyAuthCurl($_SESSION['xortify']['db']); + + if (!$this->curl_client) { + $this->setErrors(0, _AUTH_CURL_EXTENSION_NOT_LOAD); + return $authenticated; + } + + + $rnd = rand(-100000, 100000000); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, array('xoops_authentication' => json_encode(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "auth" => array('username' => $uname, "password" => $pwd, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pwd), "rand"=>$rnd))))); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = $this->obj2array(json_decode($data)); + return $result["RESULT"]; + } + + + /** + * validate a user via curl + * + * @param string $uname + * @param string $email + * @param string $pass + * @param string $vpass + * + * @return string + */ + function validate($uname, $email, $pass, $vpass){ + $this->XortifyAuthCurl($_SESSION['xortify']['db']); + $rnd = rand(-100000, 100000000); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, array('xoops_user_validate' => json_encode(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "validate" => array('uname' => $uname, "pass" => $pass, "vpass" => $vpass, "email" => $email, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pass), "rand"=>$rnd))))); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = $this->obj2array(json_decode($data)); + if ($result['ERRNUM']==1){ + return $result["RESULT"]; + } else { + return false; + } + + } + + + /** + * get the xoops site disclaimer via curl + * + * @return string + */ + function network_disclaimer(){ + $this->XortifyAuthCurl($_SESSION['xortify']['db']); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, array('xoops_network_disclaimer' => json_encode(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password)))); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + + $result = $this->obj2array(json_decode($data)); + if ($result['ERRNUM']==1){ + return $result["RESULT"]; + } else { + return false; + } + + } + + /** + * create a user + * + * @param bool $user_viewemail + * @param string $uname + * @param string $email + * @param string $url + * @param string $actkey + * @param string $pass + * @param integer $timezone_offset + * @param bool $user_mailok + * @param array $siteinfo + * + * @return array + */ + function create_user($user_viewemail, $uname, $email, $url, $actkey, + $pass, $timezone_offset, $user_mailok, $siteinfo){ + + $siteinfo = $this->check_siteinfo($siteinfo); + + $rnd = rand(-100000, 100000000); + $this->XortifyAuthCurl($_SESSION['xortify']['db']); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, 'server_create_user='.json_encode(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "user" => array('user_viewemail' =>$user_viewemail, 'uname' => $uname, 'email' => $email, 'url' => $url, 'actkey' => $actkey, 'pass' => $pass, 'timezone_offset' => $timezone_offset, 'user_mailok' => $user_mailok, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pass), "rand"=>$rnd), "siteinfo" => $siteinfo))); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = $this->obj2array(json_decode($data)); + if ($result['ERRNUM']==1){ + return $result["RESULT"]; + } else { + return false; + } + } + + function obj2array($objects) { + $ret = array(); + foreach($objects as $key => $value) { + if (is_a($value, 'stdClass')) { + $ret[$key] = (array)$value; + } elseif (is_array($value)) { + $ret[$key] = $this->obj2array($value); + } else { + $ret[$key] = $value; + } + } + return $ret; + } + +} +// end class + + +?> Added: XoopsModules/xortify/standalone/4.11/class/auth/auth_curl_provisionning.php =================================================================== --- XoopsModules/xortify/standalone/4.11/class/auth/auth_curl_provisionning.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/class/auth/auth_curl_provisionning.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,144 @@ +<?php +/* + * Prevents Spam, Harvesting, Human Rights Abuse, Captcha Abuse etc. + * basic statistic of them in XOOPS Copyright (C) 2012 Simon Roberts + * Contact: wishcraft - si...@ch... + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * See /docs/license.pdf for full license. + * + * Shouts:- Mamba (www.xoops.org), flipse (www.nlxoops.nl) + * Many thanks for your additional work with version 1.01 + * + * Version: 3.10 Final (Stable) + * Published: Chronolabs + * Download: http://code.google.com/p/chronolabs + * This File: auth_curl_provisionning.php + * Description: Provisionning for CURL Auth Library + * Date: 09/09/2012 19:34 AEST + * License: GNU3 + * + */ + +class XortifyAuthCurlProvisionning { + var $_auth_instance; + + function &getInstance(&$auth_instance) + { + static $provis_instance; + if (!isset($provis_instance)) { + $provis_instance = new XortifyAuthWgetserialisedProvisionning($auth_instance); + } + return $provis_instance; + } + + /** + * Authentication Service constructor + */ + function __construct (&$auth_instance) { + $this->_auth_instance = &$auth_instance; + /** + * Syronise User to Database/Storage Mechanism + */ + } + + /** + * Return a Xortify User Object + * + * @return XortifyUser or false + */ + function getXortifyUser($uname) { + /** + * Get a USer Object based on $uname + */ + } + + /** + * Launch the synchronisation process + * + * @return bool + */ + function sync($datas, $uname, $pwd = null) { + /** + * Syronise User to Database/Storage Mechanism + */ + } + + /** + * Add a new user to the system + * + * @return bool + */ + function add($datas, $uname, $pwd = null) { + /** + * Add User to Database/Storage Mechanism + */ + return $newuser; + } + + /** + * Modify user information + * + * @return bool + */ + function change(&$xoopsUser, $datas, $uname, $pwd = null) { + /** + * Update & Change User to Database/Storage Mechanism + */ + } + + function change_json(&$xoopsUser, $datas, $uname, $pwd = null) { + /** + * Update & Change User to Database/Storage Mechanism + */ + } + + /** + * Modify a user + * + * @return bool + */ + function delete() { + } + + /** + * Suspend a user + * + * @return bool + */ + function suspend() { + } + + /** + * Restore a user + * + * @return bool + */ + function restore() { + } + + /** + * Add a new user to the system + * + * @return bool + */ + function resetpwd() { + } + + + +} +// end class + +?> Added: XoopsModules/xortify/standalone/4.11/class/auth/auth_curlserialised.php =================================================================== --- XoopsModules/xortify/standalone/4.11/class/auth/auth_curlserialised.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/class/auth/auth_curlserialised.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,193 @@ +<?php +/* + * Prevents Spam, Harvesting, Human Rights Abuse, Captcha Abuse etc. + * basic statistic of them in XOOPS Copyright (C) 2012 Simon Roberts + * Contact: wishcraft - si...@ch... + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * See /docs/license.pdf for full license. + * + * Shouts:- Mamba (www.xoops.org), flipse (www.nlxoops.nl) + * Many thanks for your additional work with version 1.01 + * + * Version: 3.10 Final (Stable) + * Published: Chronolabs + * Download: http://code.google.com/p/chronolabs + * This File: auth_curlserialised.php + * Description: Auth Library for CURL Serialised Packages and Xortify + * Date: 09/09/2012 19:34 AEST + * License: GNU3 + * + */ + +if (!defined('XORTIFY_CURLSERIAL_API')) + define('XORTIFY_CURLSERIAL_API', _RUN_XORTIFY_API_SERIAL); + +if (!defined('XORTIFY_USER_AGENT')) + define('XORTIFY_USER_AGENT', sprintf(_MI_XOR_USER_AGENT, _MI_XOR_NAME, _MI_XOR_VERSION, _MI_XOR_RUNTIME, _MI_XOR_MODE)); + +include_once _RUN_XORTIFY_ROOT_PATH . '/class/auth/auth_curlserialised_provisionning.php'; + +class XortifyAuthCurlserialised extends XortifyAuth { + + var $curl_client; + var $curl_xoops_username = ''; + var $curl_xoops_password = ''; + var $_dao; + /** + * Authentication Service constructor + */ + function XortifyAuthCurlserialised (&$dao) { + + if (!$ch = curl_init(XORTIFY_CURLSERIAL_API)) { + trigger_error('Could not intialise CURL file: '.$url); + return false; + } + $cookies = _RUN_XORTIFY_VAR_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR .' authcurl_'.md5(XORTIFY_CURLSERIAL_API).'.cookie'; + + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, _RUN_XORTIFY_CURL_CONNECTIONTIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, _RUN_XORTIFY_CURL_TIMEOUT); + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_USERAGENT, XORTIFY_USER_AGENT); + $this->curl_client =& $ch; + } + + + /** + * Authenticate user again curl directory (Bind) + * + * @param string $uname Username + * @param string $pwd Password + * + * @return bool + */ + function authenticate($uname, $pwd = null) { + $authenticated = false; + $this->XortifyAuthCurlserialised($_SESSION['xortify']['db']); + + if (!$this->curl_client) { + $this->setErrors(0, _AUTH_CURL_EXTENSION_NOT_LOAD); + return $authenticated; + } + + + $rnd = rand(-100000, 100000000); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, array('xoops_authentication' => serialize(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "auth" => array('username' => $uname, "password" => $pwd, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pwd), "rand"=>$rnd))))); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = unserialize($data); + return $result["RESULT"]; + } + + + /** + * validate a user via curl + * + * @param string $uname + * @param string $email + * @param string $pass + * @param string $vpass + * + * @return string + */ + function validate($uname, $email, $pass, $vpass){ + $this->XortifyAuthCurlserialised($_SESSION['xortify']['db']); + $rnd = rand(-100000, 100000000); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, array('xoops_user_validate' => serialize(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "validate" => array('uname' => $uname, "pass" => $pass, "vpass" => $vpass, "email" => $email, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pass), "rand"=>$rnd))))); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = unserialize($data); + if ($result['ERRNUM']==1){ + return $result["RESULT"]; + } else { + return false; + } + + } + + + /** + * get the xoops site disclaimer via curl + * + * @return string + */ + function network_disclaimer(){ + $this->XortifyAuthCurlserialised($_SESSION['xortify']['db']); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, array('xoops_network_disclaimer' => serialize(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password)))); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = unserialize($data); + if ($result['ERRNUM']==1){ + return $result["RESULT"]; + } else { + return false; + } + + } + + /** + * create a user + * + * @param bool $user_viewemail + * @param string $uname + * @param string $email + * @param string $url + * @param string $actkey + * @param string $pass + * @param integer $timezone_offset + * @param bool $user_mailok + * @param array $siteinfo + * + * @return array + */ + function create_user($user_viewemail, $uname, $email, $url, $actkey, + $pass, $timezone_offset, $user_mailok, $siteinfo){ + + $siteinfo = $this->check_siteinfo($siteinfo); + + $rnd = rand(-100000, 100000000); + $this->XortifyAuthCurlserialised($_SESSION['xortify']['db']); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, 'server_create_user='.serialize(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "user" => array('user_viewemail' =>$user_viewemail, 'uname' => $uname, 'email' => $email, 'url' => $url, 'actkey' => $actkey, 'pass' => $pass, 'timezone_offset' => $timezone_offset, 'user_mailok' => $user_mailok, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pass), "rand"=>$rnd), "siteinfo" => $siteinfo))); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = unserialize($data); + if ($result['ERRNUM']==1){ + return $result["RESULT"]; + } else { + return false; + } + } + + function obj2array($objects) { + $ret = array(); + foreach($objects as $key => $value) { + if (is_a($value, 'stdClass')) { + $ret[$key] = (array)$value; + } elseif (is_array($value)) { + $ret[$key] = $this->obj2array($value); + } else { + $ret[$key] = $value; + } + } + return $ret; + } + +} +// end class + + +?> Added: XoopsModules/xortify/standalone/4.11/class/auth/auth_curlserialised_provisionning.php =================================================================== --- XoopsModules/xortify/standalone/4.11/class/auth/auth_curlserialised_provisionning.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/class/auth/auth_curlserialised_provisionning.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,145 @@ +<?php +/* + * Prevents Spam, Harvesting, Human Rights Abuse, Captcha Abuse etc. + * basic statistic of them in XOOPS Copyright (C) 2012 Simon Roberts + * Contact: wishcraft - si...@ch... + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * See /docs/license.pdf for full license. + * + * Shouts:- Mamba (www.xoops.org), flipse (www.nlxoops.nl) + * Many thanks for your additional work with version 1.01 + * + * Version: 3.10 Final (Stable) + * Published: Chronolabs + * Download: http://code.google.com/p/chronolabs + * This File: auth_curlserialised_provisionning.php + * Description: Auth Provisionning Library for CURL Serialised Package + * Date: 09/09/2012 19:34 AEST + * License: GNU3 + * + */ + +class XortifyAuthCurlserialisedProvisionning { + + var $_auth_instance; + + function &getInstance(&$auth_instance) + { + static $provis_instance; + if (!isset($provis_instance)) { + $provis_instance = new XortifyAuthWgetserialisedProvisionning($auth_instance); + } + return $provis_instance; + } + + /** + * Authentication Service constructor + */ + function __construct (&$auth_instance) { + $this->_auth_instance = &$auth_instance; + /** + * Syronise User to Database/Storage Mechanism + */ + } + + /** + * Return a Xortify User Object + * + * @return XortifyUser or false + */ + function getXortifyUser($uname) { + /** + * Get a USer Object based on $uname + */ + } + + /** + * Launch the synchronisation process + * + * @return bool + */ + function sync($datas, $uname, $pwd = null) { + /** + * Syronise User to Database/Storage Mechanism + */ + } + + /** + * Add a new user to the system + * + * @return bool + */ + function add($datas, $uname, $pwd = null) { + /** + * Add User to Database/Storage Mechanism + */ + return $newuser; + } + + /** + * Modify user information + * + * @return bool + */ + function change(&$xoopsUser, $datas, $uname, $pwd = null) { + /** + * Update & Change User to Database/Storage Mechanism + */ + } + + function change_json(&$xoopsUser, $datas, $uname, $pwd = null) { + /** + * Update & Change User to Database/Storage Mechanism + */ + } + + /** + * Modify a user + * + * @return bool + */ + function delete() { + } + + /** + * Suspend a user + * + * @return bool + */ + function suspend() { + } + + /** + * Restore a user + * + * @return bool + */ + function restore() { + } + + /** + * Add a new user to the system + * + * @return bool + */ + function resetpwd() { + } + + + +} +// end class + +?> Added: XoopsModules/xortify/standalone/4.11/class/auth/auth_curlxml.php =================================================================== --- XoopsModules/xortify/standalone/4.11/class/auth/auth_curlxml.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/class/auth/auth_curlxml.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,180 @@ +<?php +/* + * Prevents Spam, Harvesting, Human Rights Abuse, Captcha Abuse etc. + * basic statistic of them in XOOPS Copyright (C) 2012 Simon Roberts + * Contact: wishcraft - si...@ch... + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * See /docs/license.pdf for full license. + * + * Shouts:- Mamba (www.xoops.org), flipse (www.nlxoops.nl) + * Many thanks for your additional work with version 1.01 + * + * Version: 3.10 Final (Stable) + * Published: Chronolabs + * Download: http://code.google.com/p/chronolabs + * This File: auth_curl.php + * Description: Auth Library with CURL XML routines for signup and API + * Date: 09/09/2012 19:34 AEST + * License: GNU3 + * + */ + +if (!defined('XORTIFY_CURLXML_API')) + define('XORTIFY_CURLXML_API', _RUN_XORTIFY_API_XML); + +if (!defined('XORTIFY_USER_AGENT')) + define('XORTIFY_USER_AGENT', sprintf(_MI_XOR_USER_AGENT, _MI_XOR_NAME, _MI_XOR_VERSION, _MI_XOR_RUNTIME, _MI_XOR_MODE)); + +include_once _RUN_XORTIFY_ROOT_PATH . '/class/auth/auth_curlxml_provisionning.php'; + +class XortifyAuthCurlxml extends XortifyAuth { + + var $curl_client; + var $curl_xoops_username = ''; + var $curl_xoops_password = ''; + var $_dao; + var $_json = ''; + /** + * Authentication Service constructor + */ + function XortifyAuthCurlxml (&$dao) { + if (!$ch = curl_init(XORTIFY_CURLXML_API)) { + trigger_error('Could not intialise CURL file: '.$url); + return false; + } + $cookies = _RUN_XORTIFY_VAR_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR .' authcurl_'.md5(XORTIFY_CURLXML_API).'.cookie'; + + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, _RUN_XORTIFY_CURL_CONNECTIONTIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, _RUN_XORTIFY_CURL_TIMEOUT); + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_USERAGENT, XORTIFY_USER_AGENT); + $this->curl_client =& $ch; + } + + + /** + * Authenticate user again curl directory (Bind) + * + * @param string $uname Username + * @param string $pwd Password + * + * @return bool + */ + function authenticate($uname, $pwd = null) { + $authenticated = false; + $this->XortifyAuthCurlxml($_SESSION['xortify']['db']); + + if (!$this->curl_client) { + $this->setErrors(0, _AUTH_CURL_EXTENSION_NOT_LOAD); + return $authenticated; + } + + + $rnd = rand(-100000, 100000000); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, 'xoops_authentication='. xortify_toXml(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "auth" => array('username' => $uname, "password" => $pwd, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pwd), "rand"=>$rnd)), 'xoops_authentication')); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = xortify_elekey2numeric(xortify_xml2array($data), 'xoops_authentication'); + return $result['xoops_authentication']["RESULT"]; + } + + + /** + * validate a user via curl + * + * @param string $uname + * @param string $email + * @param string $pass + * @param string $vpass + * + * @return string + */ + function validate($uname, $email, $pass, $vpass){ + $this->XortifyAuthCurlxml($_SESSION['xortify']['db']); + $rnd = rand(-100000, 100000000); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, 'xoops_user_validate=' . xortify_toXml(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "validate" => array('uname' => $uname, "pass" => $pass, "vpass" => $vpass, "email" => $email, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pass), "rand"=>$rnd)), 'xoops_user_validate')); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = xortify_elekey2numeric(xortify_xml2array($data), 'xoops_user_validate'); + if ($result['xoops_user_validate']['ERRNUM']==1){ + return $result['xoops_user_validate']["RESULT"]; + } else { + return false; + } + + } + + + /** + * get the xoops site disclaimer via curl + * + * @return string + */ + function network_disclaimer(){ + $this->XortifyAuthCurlxml($_SESSION['xortify']['db']); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, 'xoops_network_disclaimer=' . xortify_toXml(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password), 'xoops_network_disclaimer')); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = xortify_elekey2numeric(xortify_xml2array($data), 'xoops_network_disclaimer'); + if ($result['xoops_network_disclaimer']['ERRNUM']==1){ + return $result['xoops_network_disclaimer']["RESULT"]; + } else { + return false; + } + + } + + /** + * create a user + * + * @param bool $user_viewemail + * @param string $uname + * @param string $email + * @param string $url + * @param string $actkey + * @param string $pass + * @param integer $timezone_offset + * @param bool $user_mailok + * @param array $siteinfo + * + * @return array + */ + function create_user($user_viewemail, $uname, $email, $url, $actkey, + $pass, $timezone_offset, $user_mailok, $siteinfo){ + + $siteinfo = $this->check_siteinfo($siteinfo); + + $rnd = rand(-100000, 100000000); + $this->XortifyAuthCurlxml($_SESSION['xortify']['db']); + curl_setopt($this->curl_client, CURLOPT_POSTFIELDS, 'server_create_user='.xortify_toXml(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "user" => array('user_viewemail' =>$user_viewemail, 'uname' => $uname, 'email' => $email, 'url' => $url, 'actkey' => $actkey, 'pass' => $pass, 'timezone_offset' => $timezone_offset, 'user_mailok' => $user_mailok, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pass), "rand"=>$rnd), "siteinfo" => $siteinfo), 'server_create_user')); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = xortify_elekey2numeric(xortify_xml2array($data), 'server_create_user'); + if ($result['server_create_user']['ERRNUM']==1){ + return $result['server_create_user']["RESULT"]; + } else { + return false; + } + } + + +} +// end class + + +?> Added: XoopsModules/xortify/standalone/4.11/class/auth/auth_curlxml_provisionning.php =================================================================== --- XoopsModules/xortify/standalone/4.11/class/auth/auth_curlxml_provisionning.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/class/auth/auth_curlxml_provisionning.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,146 @@ +<?php +/* + * Prevents Spam, Harvesting, Human Rights Abuse, Captcha Abuse etc. + * basic statistic of them in XOOPS Copyright (C) 2012 Simon Roberts + * Contact: wishcraft - si...@ch... + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * See /docs/license.pdf for full license. + * + * Shouts:- Mamba (www.xoops.org), flipse (www.nlxoops.nl) + * Many thanks for your additional work with version 1.01 + * + * Version: 3.10 Final (Stable) + * Published: Chronolabs + * Download: http://code.google.com/p/chronolabs + * This File: auth_curlxml_provisionning.php + * Description: Auth Provisionning Library for CURL XML Package + * Date: 09/09/2012 19:34 AEST + * License: GNU3 + * + */ + + +class XortifyAuthCurlxmlProvisionning { + var $_auth_instance; + + function &getInstance(&$auth_instance) + { + static $provis_instance; + if (!isset($provis_instance)) { + $provis_instance = new XortifyAuthWgetserialisedProvisionning($auth_instance); + } + return $provis_instance; + } + + /** + * Authentication Service constructor + */ + function __construct (&$auth_instance) { + $this->_auth_instance = &$auth_instance; + /** + * Syronise User to Database/Storage Mechanism + */ + } + + /** + * Return a Xortify User Object + * + * @return XortifyUser or false + */ + function getXortifyUser($uname) { + /** + * Get a USer Object based on $uname + */ + } + + /** + * Launch the synchronisation process + * + * @return bool + */ + function sync($datas, $uname, $pwd = null) { + /** + * Syronise User to Database/Storage Mechanism + */ + } + + /** + * Add a new user to the system + * + * @return bool + */ + function add($datas, $uname, $pwd = null) { + /** + * Add User to Database/Storage Mechanism + */ + return $newuser; + } + + /** + * Modify user information + * + * @return bool + */ + function change(&$xoopsUser, $datas, $uname, $pwd = null) { + /** + * Update & Change User to Database/Storage Mechanism + */ + } + + function change_json(&$xoopsUser, $datas, $uname, $pwd = null) { + /** + * Update & Change User to Database/Storage Mechanism + */ + } + + /** + * Modify a user + * + * @return bool + */ + function delete() { + } + + /** + * Suspend a user + * + * @return bool + */ + function suspend() { + } + + /** + * Restore a user + * + * @return bool + */ + function restore() { + } + + /** + * Add a new user to the system + * + * @return bool + */ + function resetpwd() { + } + + + + +} +// end class + +?> Added: XoopsModules/xortify/standalone/4.11/class/auth/auth_json.php =================================================================== --- XoopsModules/xortify/standalone/4.11/class/auth/auth_json.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/class/auth/auth_json.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,197 @@ +<?php +/* + * Prevents Spam, Harvesting, Human Rights Abuse, Captcha Abuse etc. + * basic statistic of them in XOOPS Copyright (C) 2012 Simon Roberts + * Contact: wishcraft - si...@ch... + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * See /docs/license.pdf for full license. + * + * Shouts:- Mamba (www.xoops.org), flipse (www.nlxoops.nl) + * Many thanks for your additional work with version 1.01 + * + * Version: 3.10 Final (Stable) + * Published: Chronolabs + * Download: http://code.google.com/p/chronolabs + * This File: auth_json.php + * Description: Auth Library with wGET JSON routines for signup and API + * Date: 09/09/2012 19:34 AEST + * License: GNU3 + * + */ + +if (!function_exists('json_encode')){ + function json_encode($data) { + static $json = NULL; + if (!class_exists('Services_JSON') ) { include_once (_RUN_XORTIFY_ROOT_PATH . '/include/JSON.php'); } + $json = new Services_JSON(); + return $json->encode($data); + } +} + +if (!function_exists('json_decode')){ + function json_decode($data) { + static $json = NULL; + if (!class_exists('Services_JSON') ) { include_once (_RUN_XORTIFY_ROOT_PATH . '/include/JSON.php'); } + $json = new Services_JSON(); + return $json->decode($data); + } +} + +if (!defined('XORTIFY_JSON_API')) + define('XORTIFY_JSON_API', _RUN_XORTIFY_API_JSON); +include_once _RUN_XORTIFY_ROOT_PATH . '/class/auth/auth_json_provisionning.php'; + +class XortifyAuthJson extends XortifyAuth { + + var $json_client; + var $json_xoops_username = ''; + var $json_xoops_password = ''; + var $_dao; + var $_json = ''; + /** + * Authentication Service constructor + */ + function XortifyAuthJson (&$dao) { + + } + + + /** + * Authenticate user again json directory (Bind) + * + * @param string $uname Username + * @param string $pwd Password + * + * @return bool + */ + function authenticate($uname, $pwd = null) { + $authenticated = false; + $rnd = rand(-100000, 100000000); + $data = file_get_contents(XORTIFY_JSON_API.'?xoops_authentication='.urlencode(json_encode(array("username"=> $this->json_xoops_username, "password"=> $this->json_xoops_password, "auth" => array('username' => $uname, "password" => $pwd, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pwd), "rand"=>$rnd))))); + $result = $this->obj2array(json_decode($data)); + return $result["RESULT"]; + } + + + /** + * validate a user via json + * + * @param string $uname + * @param string $email + * @param string $pass + * @param string $vpass + * + * @return string + */ + function validate($uname, $email, $pass, $vpass){ + $rnd = rand(-100000, 100000000); + $data = file_get_contents(XORTIFY_JSON_API.'?xoops_user_validate='.urlencode(json_encode(array("username"=> $this->json_xoops_username, "password"=> $this->json_xoops_password, "validate" => array('uname' => $uname, "pass" => $pass, "vpass" => $vpass, "email" => $email, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pass), "rand"=>$rnd))))); + $result = $this->obj2array(json_decode($data)); + if ($result['ERRNUM']==1){ + return $result["RESULT"]; + } else { + return false; + } + + } + + function reduce_string($str) + { + $str = preg_replace(array( + + // eliminate single line comments in '// ...' form + '#^\s*//(.+)$#m', + + // eliminate multi-line comments in '/* ... */' form, at start of string + '#^\s*/\*(.+)\*/#Us', + + // eliminate multi-line comments in '/* ... */' form, at end of string + '#/\*(.+)\*/\s*$#Us' + + ), '', $str); + + // eliminate extraneous space + return trim($str); + } + + /** + * get the xoops site disclaimer via json + * + * @return string + */ + function network_disclaimer(){ + + $data = file_get_contents(XORTIFY_JSON_API.'?xoops_network_disclaimer='.urlencode(json_encode(array("username"=> $this->json_xoops_username, "password"=> $this->json_xoops_password)))); + $result = $this->obj2array(json_decode($data)); + + if ($result['ERRNUM']==1){ + return $result["RESULT"]; + } else { + return false; + } + + } + + /** + * create a user + * + * @param bool $user_viewemail + * @param string $uname + * @param string $email + * @param string $url + * @param string $actkey + * @param string $pass + * @param integer $timezone_offset + * @param bool $user_mailok + * @param array $siteinfo + * + * @return array + */ + function create_user($user_viewemail, $uname, $email, $url, $actkey, + $pass, $timezone_offset, $user_mailok, $siteinfo){ + + $siteinfo = $this->check_siteinfo($siteinfo); + + $rnd = rand(-100000, 100000000); + $data = file_get_contents(XORTIFY_JSON_API.'?server_create_user='.urlencode(json_encode(array("username"=> $this->json_xoops_username, "password"=> $this->json_xoops_password, "user" => array('user_viewemail' =>$user_viewemail, 'uname' => $uname, 'email' => $email, 'url' => $url, 'actkey' => $actkey, 'pass' => $pass, 'timezone_offset' => $timezone_offset, 'user_mailok' => $user_mailok, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pass), "rand"=>$rnd), "siteinfo" => $siteinfo)))); + $result = $this->obj2array(json_decode($data)); + + if ($result['ERRNUM']==1){ + + return $result["RESULT"]; + + } else { + return false; + } + } + + function obj2array($objects) { + $ret = array(); + foreach($objects as $key => $value) { + if (is_a($value, 'stdClass')) { + $ret[$key] = (array)$value; + } elseif (is_array($value)) { + $ret[$key] = $this->obj2array($value); + } else { + $ret[$key] = $value; + } + } + return $ret; + } +} +// end class + + +?> Added: XoopsModules/xortify/standalone/4.11/class/auth/auth_json_provisionning.php =================================================================== --- XoopsModules/xortify/standalone/4.11/class/auth/auth_json_provisionning.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/class/auth/auth_json_provisionning.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,145 @@ +<?php +/* + * Prevents Spam, Harvesting, Human Rights Abuse, Captcha Abuse etc. + * basic statistic of them in XOOPS Copyright (C) 2012 Simon Roberts + * Contact: wishcraft - si...@ch... + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * See /docs/license.pdf for full license. + * + * Shouts:- Mamba (www.xoops.org), flipse (www.nlxoops.nl) + * Many thanks for your additional work with version 1.01 + * + * Version: 3.10 Final (Stable) + * Published: Chronolabs + * Download: http://code.google.com/p/chronolabs + * This File: auth_json_provisionning.php + * Description: Auth Provisionning Library for wGET JSON Package + * Date: 09/09/2012 19:34 AEST + * License: GNU3 + * + */ + +class XortifyAuthJsonProvisionning { + var $_auth_instance; + + function &getInstance(&$auth_instance) + { + static $provis_instance; + if (!isset($provis_instance)) { + $provis_instance = new XortifyAuthWgetserialisedProvisionning($auth_instance); + } + return $provis_instance; + } + + /** + * Authentication Service constructor + */ + function __construct (&$auth_instance) { + $this->_auth_instance = &$auth_instance; + /** + * Syronise User to Database/Storage Mechanism + */ + } + + /** + * Return a Xortify User Object + * + * @return XortifyUser or false + */ + function getXortifyUser($uname) { + /** + * Get a USer Object based on $uname + */ + } + + /** + * Launch the synchronisation process + * + * @return bool + */ + function sync($datas, $uname, $pwd = null) { + /** + * Syronise User to Database/Storage Mechanism + */ + } + + /** + * Add a new user to the system + * + * @return bool + */ + function add($datas, $uname, $pwd = null) { + /** + * Add User to Database/Storage Mechanism + */ + return $newuser; + } + + /** + * Modify user information + * + * @return bool + */ + function change(&$xoopsUser, $datas, $uname, $pwd = null) { + /** + * Update & Change User to Database/Storage Mechanism + */ + } + + function change_json(&$xoopsUser, $datas, $uname, $pwd = null) { + /** + * Update & Change User to Database/Storage Mechanism + */ + } + + /** + * Modify a user + * + * @return bool + */ + function delete() { + } + + /** + * Suspend a user + * + * @return bool + */ + function suspend() { + } + + /** + * Restore a user + * + * @return bool + */ + function restore() { + } + + /** + * Add a new user to the system + * + * @return bool + */ + function resetpwd() { + } + + + + +} +// end class + +?> Added: XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_curl.php =================================================================== --- XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_curl.php (rev 0) +++ XoopsModules/xortify/standalone/4.11/class/auth/auth_rest_curl.php 2013-07-16 15:36:22 UTC (rev 11827) @@ -0,0 +1,211 @@ +<?php +/* + * Prevents Spam, Harvesting, Human Rights Abuse, Captcha Abuse etc. + * basic statistic of them in XOOPS Copyright (C) 2012 Simon Roberts + * Contact: wishcraft - si...@ch... + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * See /docs/license.pdf for full license. + * + * Shouts:- Mamba (www.xoops.org), flipse (www.nlxoops.nl) + * Many thanks for your additional work with version 1.01 + * + * Version: 3.10 Final (Stable) + * Published: Chronolabs + * Download: http://code.google.com/p/chronolabs + * This File: auth_curl.php + * Description: Auth Library with CURL JSON routines for signup and API + * Date: 09/09/2012 19:34 AEST + * License: GNU3 + * + */ + +if (!function_exists('json_encode')){ + function json_encode($data) { + static $json = NULL; + if (!class_exists('Services_JSON') ) { include_once (_RUN_XORTIFY_ROOT_PATH . '/include/JSON.php'); } + $json = new Services_JSON(); + return $json->encode($data); + } +} + +if (!function_exists('json_decode')){ + function json_decode($data) { + static $json = NULL; + if (!class_exists('Services_JSON') ) { include_once (_RUN_XORTIFY_ROOT_PATH . '/include/JSON.php'); } + $json = new Services_JSON(); + return $json->decode($data); + } +} + + +if (!defined('XORTIFY_REST_API')) + define('XORTIFY_REST_API', _RUN_XORTIFY_API_REST.'%s/json/?%s'); + +if (!defined('XORTIFY_USER_AGENT')) + define('XORTIFY_USER_AGENT', sprintf(_MI_XOR_USER_AGENT, _MI_XOR_NAME, _MI_XOR_VERSION, _MI_XOR_RUNTIME, _MI_XOR_MODE)); + +include_once _RUN_XORTIFY_ROOT_PATH . '/class/auth/auth_rest_curl_provisionning.php'; + +class XortifyAuthRest_Curl extends XortifyAuth { + + var $curl_client; + var $curl_xoops_username = ''; + var $curl_xoops_password = ''; + var $_dao; + var $_json = ''; + /** + * Authentication Service constructor + */ + function XortifyAuthRest_Curl (&$dao) { + if (!$ch = curl_init()) { + trigger_error('Could not intialise CURL file: '.XORTIFY_REST_API); + return false; + } + $cookies = _RUN_XORTIFY_VAR_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR .' authcurl_'.md5(XORTIFY_REST_API).'.cookie'; + + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, _RUN_XORTIFY_CURL_CONNECTIONTIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, _RUN_XORTIFY_CURL_TIMEOUT); + curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_USERAGENT, XORTIFY_USER_AGENT); + $this->curl_client =& $ch; + } + + + /** + * Authenticate user again curl directory (Bind) + * + * @param string $uname Username + * @param string $pwd Password + * + * @return bool + */ + function authenticate($uname, $pwd = null) { + $authenticated = false; + $this->XortifyAuthRest_Curl($_SESSION['xortify']['db']); + + if (!$this->curl_client) { + $this->setErrors(0, _AUTH_CURL_EXTENSION_NOT_LOAD); + return $authenticated; + } + + + $rnd = rand(-100000, 100000000); + curl_setopt($this->curl_client, CURLOPT_URL, sprintf(XORTIFY_REST_API, 'xoops_authentication', http_build_query(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "auth" => array('username' => $uname, "password" => $pwd, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pwd), "rand"=>$rnd))))); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = $this->obj2array(json_decode($data)); + return $result["RESULT"]; + } + + + /** + * validate a user via curl + * + * @param string $uname + * @param string $email + * @param string $pass + * @param string $vpass + * + * @return string + */ + function validate($uname, $email, $pass, $vpass){ + $this->XortifyAuthRest_Curl($_SESSION['xortify']['db']); + $rnd = rand(-100000, 100000000); + curl_setopt($this->curl_client, CURLOPT_URL, sprintf(XORTIFY_REST_API, 'xoops_user_validate', http_build_query(array("username"=> $this->curl_xoops_username, "password"=> $this->curl_xoops_password, "validate" => array('uname' => $uname, "pass" => $pass, "vpass" => $vpass, "email" => $email, "time" => time(), "passhash" => sha1((time()-$rnd).$uname.$pass), "rand"=>$rnd))))); + $data = curl_exec($this->curl_client); + curl_close($this->curl_client); + $result = $this->obj2array(json_decode($data)); + if ($result['ERRNUM']==1){ + return $result["RESULT"]; + } else { + return false; + } + + } + + + /** + * get the xoops site disclaimer via curl + * + * @return string + */ + function network_disclaimer(){ + $this->XortifyAuthRest_Curl($_SESSION['xortify']['db']); + curl_setopt($this->curl_client, CURLOPT_URL, sprintf(XORTIFY_REST_API, 'xoops_network_disclaimer', http_build_query(array("username"=> $this->curl_xoo... [truncated message content] |