function tablesforupdate($var)
{
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    global $xoopsDB;
    $sql = "SELECT * FROM " . $xoopsDB->prefix('curl_tables') . " WHERE allowupdate = 1 and visible = 1";
    $ret = $xoopsDB->query($sql);
    $rtn = array();
    while ($row = $xoopsDB->fetchArray($ret)) {
        $t++;
        $rtn[$t] = array('id' => $row['tbl_id'], 'table' => $row['tablename']);
    }
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if (!validateuser($var['username'], $var['password'])) {
            return false;
        }
    }
    return $rtn;
}
Esempio n. 2
0
function seolinks($username, $password, $records)
{
    global $xoopsModuleConfig, $xoopsDB;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    $records = $records != 0 ? intval($records) : 12;
    $sql = "SELECT DISTINCT `uri`, `sitename` FROM " . $xoopsDB->prefix('spiders_statistics') . ' order by `when` DESC limit ' . intval($records);
    $result = $xoopsDB->query($sql);
    $ret = array();
    while ($robot = $xoopsDB->fetchArray($result)) {
        $id++;
        foreach (array('uri', 'sitename') as $field) {
            $ret[$id][$field] = urldecode($robot[$field]);
        }
        $url = parse_url(urldecode($robot['uri']));
        $ret[$id]['host'] = $url['host'];
    }
    return array("links" => count($ret), "made" => time(), "seolinks" => $ret);
}
function xoops_authentication($username, $password, $auth)
{
    global $xoopsModuleConfig, $xoopsConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    if ($auth['passhash'] != '') {
        if ($auth['passhash'] != sha1($auth['time'] - $auth['rand'] . $auth['username'] . $auth['password'])) {
            return array("ERRNUM" => 4, "ERRTXT" => 'No Passhash');
        }
    } else {
        return array("ERRNUM" => 4, "ERRTXT" => 'No Passhash');
    }
    require_once XOOPS_ROOT_PATH . '/class/auth/authfactory.php';
    require_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/auth.php';
    $xoopsAuth =& XoopsAuthFactory::getAuthConnection(addslashes($auth['username']));
    $user = $xoopsAuth->authenticate(addslashes($auth['username']), addslashes($auth['password']));
    if (is_object($user)) {
        $row = array("uid" => $user->getVar('uid'), "uname" => $user->getVar('uname'), "email" => $user->getVar('email'), "user_from" => $user->getVar('user_from'), "name" => $user->getVar('name'), "url" => $user->getVar('url'), "user_icq" => $user->getVar('user_icq'), "user_sig" => $user->getVar('user_sig'), "user_viewemail" => $user->getVar('user_viewemail'), "user_aim" => $user->getVar('user_aim'), "user_yim" => $user->getVar('user_yim'), "user_msnm" => $user->getVar('user_msnm'), "attachsig" => $user->getVar('attachsig'), "timezone_offset" => $user->getVar('timezone_offset'), "notify_method" => $user->getVar('notify_method'), "user_occ" => $user->getVar('user_occ'), "bio" => $user->getVar('bio'), "user_intrest" => $user->getVar('user_intrest'), "user_mailok" => $user->getVar('user_mailok'));
    }
    if (!empty($row)) {
        return array("ERRNUM" => 1, "RESULT" => $row);
    } else {
        return array("ERRNUM" => 3, "ERRTXT" => _ERR_FUNCTION_FAIL);
    }
}
Esempio n. 4
0
function retrieve($var)
{
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    global $xoopsDB;
    if (strlen($var['tablename']) > 0) {
        $tbl_id = get_tableid($var['tablename']);
    } elseif ($var['id'] > 0) {
        $tbl_id = $var['id'];
    } else {
        return array('ErrNum' => 2, "ErrDesc" => 'Table Name or Table ID not specified');
    }
    if (!validate($tbl_id, $var['data'], "allowretrieve")) {
        return array('ErrNum' => 4, "ErrDesc" => 'Not all fields are allowed retrieve');
    } else {
        $sql = "SELECT ";
        foreach ($var['data'] as $data) {
            if ($data['field'] == '*') {
                return array('ErrNum' => 7, "ErrDesc" => 'Wildcard not accepted');
            }
            $sql_b .= "`" . $data['field'] . "`,";
        }
        if (strlen($var['clause']) > 0) {
            if (strpos(' ' . strtolower($var['clause']), 'union') > 0) {
                return array('ErrNum' => 8, "ErrDesc" => 'Union not accepted');
            }
            $sql_c .= 'WHERE ' . $var['clause'] . "";
        }
        global $xoopsModuleConfig;
        if ($xoopsModuleConfig['site_user_auth'] == 1) {
            if (!validateuser($var['username'], $var['password'])) {
                return false;
            }
        }
        //echo $sql." ".substr($sql_b,0,strlen($str_b)-1)." FROM ".$xoopsDB->prefix(get_tablename($tbl_id))." ".$sql_c;
        $rt = $xoopsDB->queryf($sql . " " . substr($sql_b, 0, strlen($str_b) - 1) . " FROM " . $xoopsDB->prefix(get_tablename($tbl_id)) . " " . $sql_c);
        if (!$xoopsDB->getRowsNum($rt)) {
            return array('ErrNum' => 3, "ErrDesc" => 'No Records Returned from Query');
        } else {
            $rtn = array();
            while ($row = $xoopsDB->fetchArray($rt)) {
                $rdata = array();
                foreach ($var['data'] as $data) {
                    $rdata[] = array("fieldname" => $data['field'], "value" => $row[$data['field']]);
                }
                $rtn[] = $rdata;
            }
        }
        return array("total_records" => $xoopsDB->getRowsNum($rt), "items" => $rtn);
    }
}
Esempio n. 5
0
function spiderstat($username, $password, $statistic)
{
    global $xoopsModuleConfig, $xoopsDB;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    $spider_handler =& xoops_getmodulehandler('spiders', 'spiders');
    $member_handler =& xoops_gethandler('member');
    $modulehandler =& xoops_gethandler('module');
    $confighandler =& xoops_gethandler('config');
    $xoModule = $modulehandler->getByDirname('spiders');
    $xoConfig = $confighandler->getConfigList($xoModule->getVar('mid'), false);
    $statistics_handler =& xoops_getmodulehandler('statistics', 'spiders');
    $ban = $spider_handler->banDetails($statistic['netaddy']);
    if ($ban != false) {
        return array("ban_made" => $ban, "made" => time());
    }
    $spiders = $spider_handler->getObjects(NULL);
    foreach ($spiders as $spider) {
        if (strtolower($spider->getVar('robot-id')) == strtolower($statistic['robot-id'])) {
            $id = $spider->getVar('id');
            $thespider = $spider;
        }
    }
    $stat = $statistics_handler->create();
    $stat->setVar('id', $id);
    $stat->setVar('useragent', $statistic['useragent']);
    $stat->setVar('uri', $statistic['uri']);
    $stat->setVar('netaddy', $statistic['netaddy']);
    $stat->setVar('ip', $statistic['ip']);
    $stat->setVar('server-ip', $statistic['server-ip']);
    $stat->setVar('when', $statistic['when']);
    $stat->setVar('sitename', $statistic['sitename']);
    $sql = "DELETE FROM " . $GLOBALS['xoopsDB']->prefix('spiders_statistics') . " WHERE `when` < '" . (time() - 24 * 60 * 60 * 7 * 2) . "'";
    @$GLOBALS['xoopsDB']->queryF($sql);
    $status = $statistics_handler->insert($stat) ? true : false;
    if (strpos(strtolower($_SERVER['HTTP_HOST']), 'xortify.com')) {
        define('XORTIFY_API_LOCAL', 'http://xortify.chronolabs.coop/soap/');
        define('XORTIFY_API_URI', 'http://xortify.chronolabs.coop/soap/');
    } else {
        define('XORTIFY_API_LOCAL', 'http://xortify.com/soap/');
        define('XORTIFY_API_URI', 'http://xortify.com/soap/');
    }
    @($soap_client = @new soapclient(NULL, array('location' => XORTIFY_API_LOCAL, 'uri' => XORTIFY_API_URI)));
    @$soap_client->__soapCall('spiderstat', array("username" => $username, "password" => $password, "statistic" => $statistic));
    return array("stat_made" => $status, "made" => time());
}
Esempio n. 6
0
function update($var)
{
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    global $xoopsDB;
    if (strlen($var['tablename']) > 0) {
        $tbl_id = get_tableid($var['tablename']);
    } elseif ($var['id'] > 0) {
        $tbl_id = $var['id'];
    } else {
        return array('ErrNum' => 2, "ErrDesc" => 'Table Name or Table ID not specified');
    }
    if (!validate($tbl_id, $var['data'], "allowupdate")) {
        return array('ErrNum' => 5, "ErrDesc" => 'Not all fields are allowed update');
    } else {
        $sql = "UPDATE " . $xoopsDB->prefix(get_tablename($tbl_id)) . ' SET ';
        foreach ($var['data'] as $data) {
            if (!is_fieldkey($data['field'], $tbl_id)) {
                $sql_b .= "`" . $data['field'] . "` = '" . addslashes($data['value']) . "',";
            } else {
                if (strpos(' ' . $data['value'], '%') > 0 || strpos(' ' . $data['value'], '_') > 0) {
                    return array('ErrNum' => 7, "ErrDesc" => 'Wildcard not accepted');
                }
                if (strpos(' ' . strtolower($data['value']), 'union') > 0) {
                    return array('ErrNum' => 8, "ErrDesc" => 'Union not accepted');
                }
                $sql_c .= " WHERE `" . $data['field'] . "` = '" . addslashes($data['value']) . "'";
            }
        }
        if (strlen($sql_c) == 0) {
            return array('ErrNum' => 6, "ErrDesc" => 'No primary key set');
        }
        global $xoopsModuleConfig;
        if ($xoopsModuleConfig['site_user_auth'] == 1) {
            if (!validateuser($var['username'], $var['password'])) {
                return false;
            }
        }
        return $xoopsDB->queryF($sql . substr($sql_b, 0, strlen($sql_b) - 1) . $sql_c);
    }
}
 function arpmacaddress($username, $password, $remoteaddress)
 {
     global $xoopsModuleConfig, $xoopsConfig;
     if ($xoopsModuleConfig['site_user_auth'] == 1) {
         if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
             return $ret;
         }
         if (!checkright(basename(__FILE__), $username, $password)) {
             mark_for_lock(basename(__FILE__), $username, $password);
             return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
         }
     }
     error_reporting(0);
     exec('arping -c 1 ' . $remoteaddress, $user_mac);
     $macaddress = substr($user_mac[1], strpos($user_mac[1], ':') - 2, '17');
     return array('MACADDRESS' => $macaddress);
 }
function tableschemer($var)
{
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    global $xoopsDB;
    $sql = "SELECT * FROM " . $xoopsDB->prefix('curl_fields') . " WHERE visible = 1 ";
    if ($var['post'] = 1) {
        $sql .= "and allowpost = 1 ";
    } elseif ($var['retrieve'] = 1) {
        $sql .= "and allowretrieve = 1 ";
    } elseif ($var['update'] = 1) {
        $sql .= "and allowupdate = 1 ";
    }
    if (strlen($var['tablename']) > 0) {
        $sql .= "and tbl_id = " . get_tableid($var['tablename']);
    } elseif ($var['id'] > 0) {
        $sql .= "and tbl_id = " . $var['id'];
    } else {
        return array('ErrNum' => 2, "ErrDesc" => 'Table Name or Table ID not specified');
    }
    $ret = $xoopsDB->query($sql);
    $rtn = array();
    while ($row = $xoopsDB->fetchArray($ret)) {
        $rtn[] = array('table_id' => $row['tbl_id'], 'field' => $row['fieldname'], 'allowpost' => $row['allowpost'], 'allowretrieve' => $row['allowretrieve'], 'allowupdate' => $row['allowupdate'], 'string' => $row['string'], 'int' => $row['int'], 'float' => $row['float'], 'text' => $row['text'], 'key' => $row['key'], 'other' => $row['other']);
    }
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if (!validateuser($var['username'], $var['password'])) {
            return false;
        }
    }
    return $rtn;
}
 function xoops_user_validate($username, $password, $validate)
 {
     global $xoopsModuleConfig, $xoopsConfig;
     if ($xoopsModuleConfig['site_user_auth'] == 1) {
         if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
             return $ret;
         }
         if (!checkright(basename(__FILE__), $username, $password)) {
             mark_for_lock(basename(__FILE__), $username, $password);
             return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
         }
     }
     if ($validate['passhash'] != '') {
         if ($validate['passhash'] != sha1($validate['time'] - $validate['rand'] . $validate['uname'] . $validate['pass'])) {
             return array("ERRNUM" => 4, "ERRTXT" => 'No Passhash');
         }
     } else {
         return array("ERRNUM" => 4, "ERRTXT" => 'No Passhash');
     }
     return array('ERRNUM' => 1, 'RESULT' => userCheck($validate['uname'], $validate['email'], $validate['pass'], $validate['vpass']));
 }
Esempio n. 10
0
function post($var)
{
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    global $xoopsDB;
    if (strlen($var['tablename']) > 0) {
        $tbl_id = get_tableid($var['tablename']);
    } elseif ($var['id'] > 0) {
        $tbl_id = $var['id'];
    } else {
        return array('ErrNum' => 2, "ErrDesc" => 'Table Name or Table ID not specified');
    }
    if (!validate($tbl_id, $var['data'], "allowpost")) {
        return array('ErrNum' => 1, "ErrDesc" => 'Not all fields are allowed posting');
    } else {
        $sql = "INSERT INTO " . $xoopsDB->prefix(get_tablename($tbl_id));
        foreach ($var['data'] as $data) {
            $sql_b .= "`" . $data['field'] . "`,";
            $sql_c .= "'" . addslashes($data['value']) . "',";
        }
        global $xoopsModuleConfig;
        if ($xoopsModuleConfig['site_user_auth'] == 1) {
            if (!validateuser($var['username'], $var['password'])) {
                return false;
            }
        }
        //		echo $sql." (".substr($sql_b,0,strlen($str_b)-1).") VALUES (".substr($sql_c,0,strlen($str_c)-1).")";
        $rt = $xoopsDB->queryF($sql . " (" . substr($sql_b, 0, strlen($str_b) - 1) . ") VALUES (" . substr($sql_c, 0, strlen($str_c) - 1) . ")");
        return array("insert_id" => $xoopsDB->getInsertId($rt));
    }
}
Esempio n. 11
0
function spiders($username, $password, $records)
{
    global $xoopsModuleConfig, $xoopsDB;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    $records = $records != 0 ? intval($records) : 600;
    $sql = "SELECT * FROM " . $xoopsDB->prefix('spiders') . ' limit ' . intval($records);
    $result = $xoopsDB->query($sql);
    $ret = array();
    while ($robot = $xoopsDB->fetchArray($result)) {
        $id++;
        foreach (array('robot-id', 'robot-name', 'robot-cover-url', 'robot-details-url', 'robot-owner-name', 'robot-owner-url', 'robot-owner-email', 'robot-status', 'robot-purpose', 'robot-type', 'robot-platform', 'robot-availability', 'robot-exclusion', 'robot-exclusion-useragent', 'robot-noindex', 'robot-host', 'robot-from', 'robot-useragent', 'robot-language', 'robot-description', 'robot-history', 'robot-environment', 'modified-date', 'modified-by', 'robot-safeuseragent', 'robot-handlesession') as $field) {
            $ret[$id][$field] = $robot[$field];
        }
    }
    return array("spiders" => count($ret), "made" => time(), "robots" => $ret);
}
Esempio n. 12
0
function bans($username, $password, $records)
{
    global $xoopsModuleConfig, $xoopsDB;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    $records = $records != 0 ? intval($records) : 60 * 60 * 0.65;
    $sql = "SELECT * FROM " . $xoopsDB->prefix('ban_member') . ' order by `made` DESC limit ' . intval($records);
    $result = $xoopsDB->query($sql);
    $ret = array();
    while ($ban = $xoopsDB->fetchArray($result)) {
        $id++;
        foreach (array('ip4', 'ip6', 'proxy-ip4', 'proxy-ip6', 'network-addy', 'mac-addy', 'long') as $field) {
            $ret[$id][$field] = $ban[$field];
        }
    }
    return array("bans" => count($ret), "made" => time(), "data" => $ret);
}
function xoops_network_disclaimer($username, $password)
{
    global $xoopsModuleConfig, $xoopsConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    include_once XOOPS_ROOT_PATH . '/class/auth/authfactory.php';
    include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/auth.php';
    $xoopsAuth =& XoopsAuthFactory::getAuthConnection();
    if (check_auth_class($xoopsAuth) == true) {
        $result = $xoopsAuth->network_disclaimer();
        return $result;
    } else {
        $config_handler =& xoops_gethandler('config');
        $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
        return array("ERRNUM" => 1, "RESULT" => $xoopsConfigUser['reg_disclaimer']);
    }
}
function xoops_create_user($username, $password, $user, $siteinfo)
{
    xoops_load("userUtility");
    global $xoopsModuleConfig, $xoopsConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    return array("Username" => $username, "password" => $password, 'user' => $user, 'siteinfo' => $siteinfo);
    if ($user['passhash'] != '') {
        if ($user['passhash'] != sha1($user['time'] - $user['rand'] . $user['uname'] . $user['pass'])) {
            return array("ERRNUM" => 4, "ERRTXT" => 'No Passhash');
        }
    } else {
        return array("ERRNUM" => 4, "ERRTXT" => 'No Passhash');
    }
    foreach ($user as $k => $l) {
        ${$k} = $l;
    }
    include_once XOOPS_ROOT_PATH . '/class/auth/authfactory.php';
    include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/auth.php';
    $xoopsAuth =& XoopsAuthFactory::getAuthConnection($uname);
    if (check_auth_class($xoopsAuth) == true) {
        $result = $xoopsAuth->create_user($user_viewemail, $uname, $email, $url, $actkey, $pass, $timezone_offset, $user_mailok, $siteinfo);
        return $result;
    } else {
        if (strlen(userCheck($uname, $email, $pass, $pass)) == 0) {
            global $xoopsConfig;
            $config_handler =& xoops_gethandler('config');
            $xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
            $member_handler =& xoops_gethandler('member');
            $newuser =& $member_handler->createUser();
            $newuser->setVar('user_viewemail', $user_viewemail, true);
            $newuser->setVar('uname', $uname, true);
            $newuser->setVar('email', $email, true);
            if ($url != '') {
                $newuser->setVar('url', formatURL($url), true);
            }
            $newuser->setVar('user_avatar', 'blank.gif', true);
            if (empty($actkey)) {
                $actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8);
            }
            $newuser->setVar('actkey', $actkey, true);
            $newuser->setVar('pass', md5($pass), true);
            $newuser->setVar('timezone_offset', $timezone_offset, true);
            $newuser->setVar('user_regdate', time(), true);
            $newuser->setVar('uorder', $xoopsConfig['com_order'], true);
            $newuser->setVar('umode', $xoopsConfig['com_mode'], true);
            $newuser->setVar('user_mailok', $user_mailok, true);
            $newuser->setVar('user_intrest', _US_USERREG . ' @ ' . $xoops_url, true);
            if ($xoopsConfigUser['activation_type'] == 1) {
                $newuser->setVar('level', 1, true);
            }
            if (!$member_handler->insertUser($newuser, true)) {
                $return = array('state' => 1, "text" => _US_REGISTERNG);
            } else {
                $newid = $newuser->getVar('uid');
                if (!$member_handler->addUserToGroup(XOOPS_GROUP_USERS, $newid)) {
                    $return = array('state' => 1, "text" => _US_REGISTERNG);
                }
                if ($xoopsConfigUser['activation_type'] == 1) {
                    $return = array('state' => 2, "user" => $uname);
                }
                // Sending notification email to user for self activation
                if ($xoopsConfigUser['activation_type'] == 0) {
                    $xoopsMailer =& xoops_getMailer();
                    $xoopsMailer->useMail();
                    $xoopsMailer->setTemplate('register.tpl');
                    $xoopsMailer->assign('SITENAME', $siteinfo['sitename']);
                    $xoopsMailer->assign('ADMINMAIL', $siteinfo['adminmail']);
                    $xoopsMailer->assign('SITEURL', XOOPS_URL . "/");
                    $xoopsMailer->setToUsers(new XoopsUser($newid));
                    $xoopsMailer->setFromEmail($siteinfo['adminmail']);
                    $xoopsMailer->setFromName($siteinfo['sitename']);
                    $xoopsMailer->setSubject(sprintf(_US_USERKEYFOR, $uname));
                    if (!$xoopsMailer->send()) {
                        $return = array('state' => 1, "text" => _US_YOURREGMAILNG);
                    } else {
                        $return = array('state' => 1, "text" => _US_YOURREGISTERED);
                    }
                    // Sending notification email to administrator for activation
                } elseif ($xoopsConfigUser['activation_type'] == 2) {
                    $xoopsMailer =& xoops_getMailer();
                    $xoopsMailer->useMail();
                    $xoopsMailer->setTemplate('adminactivate.tpl');
                    $xoopsMailer->assign('USERNAME', $uname);
                    $xoopsMailer->assign('USEREMAIL', $email);
                    if ($siteinfo['xoops_url'] == XOOPS_URL) {
                        $xoopsMailer->assign('USERACTLINK', $siteinfo['xoops_url'] . '/register.php?op=actv&id=' . $newid . '&actkey=' . $actkey);
                    }
                } else {
                    $xoopsMailer->assign('USERACTLINK', $siteinfo['xoops_url'] . '/register.php?op=actv&uname=' . $uname . '&actkey=' . $actkey);
                }
                $xoopsMailer->assign('SITENAME', $siteinfo['sitename']);
                $xoopsMailer->assign('ADMINMAIL', $siteinfo['adminmail']);
                $xoopsMailer->assign('SITEURL', $siteinfo['xoops_url'] . "/");
                $member_handler =& xoops_gethandler('member');
                $xoopsMailer->setToGroups($member_handler->getGroup($xoopsConfigUser['activation_group']));
                $xoopsMailer->setFromEmail($siteinfo['adminmail']);
                $xoopsMailer->setFromName($siteinfo['sitename']);
                $xoopsMailer->setSubject(sprintf(_US_USERKEYFOR, $uname));
                if (!$xoopsMailer->send()) {
                    $return = array('state' => 1, "text" => _US_YOURREGMAILNG);
                } else {
                    $return = array('state' => 1, "text" => _US_YOURREGISTERED2);
                }
            }
            if ($xoopsConfigUser['new_user_notify'] == 1 && !empty($xoopsConfigUser['new_user_notify_group'])) {
                $xoopsMailer =& xoops_getMailer();
                $xoopsMailer->useMail();
                $member_handler =& xoops_gethandler('member');
                $xoopsMailer->setToGroups($member_handler->getGroup($xoopsConfigUser['new_user_notify_group']));
                $xoopsMailer->setFromEmail($siteinfo['adminmail']);
                $xoopsMailer->setFromName($siteinfo['sitename']);
                $xoopsMailer->setSubject(sprintf(_US_NEWUSERREGAT, $xoopsConfig['sitename']));
                $xoopsMailer->setBody(sprintf(_US_HASJUSTREG, $uname));
                $xoopsMailer->send();
            }
            if (strpos(strtolower($_SERVER['HTTP_HOST']), 'xortify.com')) {
                define('XORTIFY_API_LOCAL', 'http://xortify.chronolabs.coop/soap/');
                define('XORTIFY_API_URI', 'http://xortify.chronolabs.coop/soap/');
            } else {
                define('XORTIFY_API_LOCAL', 'http://xortify.com/soap/');
                define('XORTIFY_API_URI', 'http://xortify.com/soap/');
            }
            $soap_client = @new soapclient(NULL, array('location' => XORTIFY_API_LOCAL, 'uri' => XORTIFY_API_URI));
            $result = @$soap_client->__soapCall('xoops_create_user', array("username" => $username, "password" => $password, "user" => $user, "siteinfo" => $siteinfo));
            return array("ERRNUM" => 1, "RESULT" => $return);
        } else {
            return array("ERRNUM" => 1, "RESULT" => array('state' => 1, 'text' => userCheck($uname, $email, $pass, $pass)));
        }
    }
}
Esempio n. 15
0
function retrievekeys($var)
{
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    global $xoopsDB;
    $sql = "SELECT * FROM " . $xoopsDB->prefix('curl_fields') . " WHERE `key` = 1 and visible = 1 ";
    if (strlen($var['tablename']) > 0) {
        $sql .= "and tbl_id = " . get_tableid($var['tablename']);
        $tbl_id = get_tableid($var['tablename']);
    } elseif ($var['id'] > 0) {
        $sql .= "and tbl_id = " . $var['id'];
        $tbl_id = $var['id'];
    } else {
        return array('ErrNum' => 2, "ErrDesc" => 'Table Name or Table ID not specified');
    }
    $ret = $xoopsDB->query($sql);
    $sql = "SELECT ";
    $tmp = array();
    while ($row = $xoopsDB->fetchArray($ret)) {
        $sql .= '`' . $row['fieldname'] . '`';
        $tmp[] = $row['fieldname'];
        $t++;
        if ($t < $xoopsDB->getRowsNum($ret)) {
            $sql .= ', ';
        }
    }
    if (strlen($var['tablename']) > 0) {
        $sql .= ' FROM ' . $xoopsDB->prefix($var['tablename']);
    } elseif ($var['id'] > 0) {
        $sql .= ' FROM ' . $xoopsDB->prefix(get_tablename($var['id']));
    }
    if ($var['clause'] == 1) {
        if (strpos(' ' . strtolower($var['clause']), 'union') > 0) {
            return array('ErrNum' => 8, "ErrDesc" => 'Union not accepted');
        }
        $sql .= ' WHERE `' . get_fieldname($var['fieldid'], $tbl_id) . '` ' . $var['clause'];
    }
    $ret = $xoopsDB->query($sql);
    $rtn = array();
    while ($row = $xoopsDB->fetchArray($ret)) {
        $id++;
        $tmp_b = array();
        foreach ($tmp as $result) {
            $tmp_b[] = array("field" => $result, "value" => $row[$result]);
        }
        $rtn[] = array('id' => $id, 'data' => $tmp_b);
    }
    global $xoopsModuleConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if (!validateuser($var['username'], $var['password'])) {
            return false;
        }
    }
    return $rtn;
}
Esempio n. 16
0
function spider($username, $password, $apispider)
{
    global $xoopsModuleConfig, $xoopsDB;
    $id = 0;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    $spider_handler =& xoops_getmodulehandler('spiders', 'spiders');
    $spidermods_handler =& xoops_getmodulehandler('modifications', 'spiders');
    $suser_handler =& xoops_getmodulehandler('spiders_user', 'spiders');
    $member_handler =& xoops_gethandler('member');
    $modulehandler =& xoops_gethandler('module');
    $confighandler =& xoops_gethandler('config');
    $xoModule = $modulehandler->getByDirname('spiders');
    $xoConfig = $confighandler->getConfigList($xoModule->getVar('mid'), false);
    $spiders = $spider_handler->getObjects(NULL);
    foreach ($spiders as $spider) {
        if (strtolower($spider->getVar('robot-id')) == strtolower($apispider['robot-id'])) {
            $id = $spider->getVar('id');
            $thespider = $spider;
        }
    }
    if ($id == 0) {
        $part = $spider_handler->safeAgent($apispider['robot-useragent']);
        foreach (array(';', '/', ',', '/', '(', ')', ' ') as $split) {
            $ret = array();
            foreach (explode($split, $part) as $value) {
                $ret[] = $value;
            }
            $part = implode(' ', $ret);
        }
        $criteria = new CriteriaCompo();
        foreach ($ret as $value) {
            if (!is_numeric(substr($value, 0, 1)) && substr($value, 0, 1) != 'x') {
                if (!empty($value)) {
                    $criteria->add(new Criteria('`robot-safeuseragent`', '%' . $value . '%', 'LIKE'), 'OR');
                    $uagereg[] = strtolower($value);
                    $uageregb[] = $value;
                }
            }
        }
        $id = 0;
        $spiders = $spider_handler->getObjects($criteria, true);
        foreach ($spiders as $spider) {
            $suser = $suser_handler->get($spider->getVar('id'));
            $robot = $member_handler->getUser($suser->getVar('uid'));
            $part = $spider_handler->safeAgent($spider->getVar('robot-useragent'));
            foreach (array(';', '/', ',', '\\', '(', ')', ' ') as $split) {
                $usersafeagent = array();
                foreach (explode($split, $part) as $value) {
                    $usersafeagent[] = $value;
                }
                $part = implode(' ', $usersafeagent);
            }
            $usersafeagent = explode(' ', $part);
            $match = 0;
            $dos_crsafe = array();
            foreach ($uagereg as $uaid => $ireg) {
                if ((in_array($ireg, $usersafeagent) || strpos(strtolower(' ' . $part), strtolower($ireg))) && !is_object($GLOBALS['xoopsUser'])) {
                    $match++;
                    $dos_crsafe[] = $uageregb[$uaid];
                }
            }
            if (intval($match / count($uagereg) * 100) > intval($xoConfig['match_percentile'])) {
                $id = $spider->getVar('id');
                $thespider = $spider;
            }
        }
    }
    $newmod = $spidermods_handler->create();
    foreach ($apispider as $key => $value) {
        if ($id != 0) {
            if (md5($value) != md5($thespider->getVar($key)) && strlen($value) != strlen($thespider->getVar($key))) {
                $change++;
                $newmod->setVar($key, $value);
            } else {
                $newmod->setVar($key, $thespider->getVar($key));
            }
        } else {
            $change++;
            $newmod->setVar($key, $value);
        }
    }
    $newmod->setVar('id', $id);
    if (strpos(strtolower($_SERVER['HTTP_HOST']), 'xortify.com')) {
        define('XORTIFY_API_LOCAL', 'http://xortify.chronolabs.coop/soap/');
        define('XORTIFY_API_URI', 'http://xortify.chronolabs.coop/soap/');
    } else {
        define('XORTIFY_API_LOCAL', 'http://xortify.com/soap/');
        define('XORTIFY_API_URI', 'http://xortify.com/soap/');
    }
    @($soap_client = @new soapclient(NULL, array('location' => XORTIFY_API_LOCAL, 'uri' => XORTIFY_API_URI)));
    $soap_client->__soapCall('spider', array("username" => $username, "password" => $password, "spider" => $apispider));
    return array("mod_made" => $spidermods_handler->insert($newmod, true), "made" => time());
}
function xoops_check_activation($username, $password, $user)
{
    global $xoopsModuleConfig, $xoopsConfig;
    if ($xoopsModuleConfig['site_user_auth'] == 1) {
        if ($ret = check_for_lock(basename(__FILE__), $username, $password)) {
            return $ret;
        }
        if (!checkright(basename(__FILE__), $username, $password)) {
            mark_for_lock(basename(__FILE__), $username, $password);
            return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in');
        }
    }
    if ($user['passhash'] != '') {
        if ($user['passhash'] != sha1($user['time'] - $user['rand'] . $user['uname'] . $user['actkey'])) {
            return array("ERRNUM" => 4, "ERRTXT" => 'No Passhash');
        }
    } else {
        return array("ERRNUM" => 4, "ERRTXT" => 'No Passhash');
    }
    foreach ($user as $k => $l) {
        ${$k} = $l;
    }
    $siteinfo = check_siteinfo($siteinfo);
    include_once XOOPS_ROOT_PATH . '/class/auth/authfactory.php';
    include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/auth.php';
    $xoopsAuth =& XoopsAuthFactory::getAuthConnection(addslashes($uname));
    if (check_auth_class($xoopsAuth) == true) {
        $result = $xoopsAuth->check_activation($uname, $actkey, $siteinfo);
        return $result;
    } else {
        global $xoopsConfig, $xoopsConfigUser;
        global $xoopsDB;
        $sql = "SELECT uid FROM " . $xoopsDB->prefix('users') . " WHERE uname = '{$uname}'";
        $ret = $xoopsDB->query($sql);
        $row = $xoopsDB->fetchArray($ret);
        $member_handler =& xoops_gethandler('member');
        $thisuser =& $member_handler->getUser($row['uid']);
        if (!is_object($thisuser)) {
            exit;
        }
        if ($thisuser->getVar('actkey') != $actkey) {
            $return = array("state" => _US_STATE_ONE, "action" => "redirect_header", "url" => 'index.php', "opt" => 5, "text" => _US_ACTKEYNOT);
        } else {
            if ($thisuser->getVar('level') > 0) {
                $return = array("state" => _US_STATE_ONE, "action" => "redirect_header", "url" => 'user.php', "opt" => 5, "text" => _US_ACONTACT, "set" => false);
            } else {
                if (false != $member_handler->activateUser($thisuser)) {
                    $config_handler =& xoops_gethandler('config');
                    $xoopsConfigUser = $config_handler->getConfigsByCat(XOOPS_CONF_USER);
                    if ($xoopsConfigUser['activation_type'] == 2) {
                        $myts =& MyTextSanitizer::getInstance();
                        $xoopsMailer =& xoops_getMailer();
                        $xoopsMailer->useMail();
                        $xoopsMailer->setTemplate('activated.tpl');
                        $xoopsMailer->assign('SITENAME', $siteinfo['sitename']);
                        $xoopsMailer->assign('ADMINMAIL', $siteinfo['adminmail']);
                        $xoopsMailer->assign('SITEURL', $siteinfo['xoops_url'] . "/");
                        $xoopsMailer->setToUsers($thisuser);
                        $xoopsMailer->setFromEmail($siteinfo['adminmail']);
                        $xoopsMailer->setFromName($siteinfo['sitename']);
                        $xoopsMailer->setSubject(sprintf(_US_YOURACCOUNT, $siteinfo['sitename']));
                        if (!$xoopsMailer->send()) {
                            $return = array("state" => _US_STATE_TWO, "text" => sprintf(_US_ACTVMAILNG, $thisuser->getVar('uname')));
                        } else {
                            $return = array("state" => _US_STATE_TWO, "text" => sprintf(_US_ACTVMAILOK, $thisuser->getVar('uname')));
                        }
                    } else {
                        $local = explode(' @ ', $thisuser->getVar('user_intrest'));
                        if ($local[0] == _US_USERREG) {
                            $return = array("state" => _US_STATE_ONE, "action" => "redirect_header", "url" => $local[1] . '/user.php', "opt" => 5, "text" => _US_ACTLOGIN, "set" => false);
                        } else {
                            $return = array("state" => _US_STATE_ONE, "action" => "redirect_header", "url" => 'user.php', "opt" => 5, "text" => _US_ACTLOGIN, "set" => false);
                        }
                    }
                } else {
                    $return = array("state" => _US_STATE_ONE, "action" => "redirect_header", "url" => 'index.php', "opt" => 5, "text" => 'Activation failed!');
                }
            }
        }
        return $return;
    }
}