Exemplo n.º 1
0
/**
 * Get the uid of a user from the username
 *
 * @access public
 * @author Michael Halbrook
 * @since 1.9 - 19/04/2004
 * @param uname $ the username
 * @return mixed userid if found, false if not, void upon error
 */
function pnUserGetIDFromName($uname)
{
    $uname = isset($uname) ? $uname : '';
    if (!pnVarValidate($uname, 'uname')) {
        return false;
    }
    static $uid = array();
    if (isset($uid[$uname])) {
        return $uid[$uname];
    }
    $dbconn =& pnDBGetConn(true);
    $pntable =& pnDBGetTables();
    $userstable = $pntable['users'];
    $userscolumn =& $pntable['users_column'];
    $query = "SELECT {$userscolumn['uid']}\n              FROM {$userstable}\n              WHERE {$userscolumn['uname']} = '" . pnVarPrepForStore($uname) . "'";
    $result =& $dbconn->Execute($query);
    if ($dbconn->ErrorNo() != 0) {
        return;
    }
    if ($result->EOF) {
        $uid[$uname] = false;
        return false;
    }
    list($uid[$uname]) = $result->fields;
    $result->Close();
    return $uid[$uname];
}
Exemplo n.º 2
0
/**
 * pnThemeInfo()
 * <br />
 * This function returns information about a certain theme. 
 * For this purpose, it includes the xaninfo.php file (for 
 * Xanthia themes) or the themeinfo.php (for other themes).
 * <br />
 * If the name passed isn't a valid theme, false is returned. 
 * <br />
 * For a valid theme, at least these values are returned:
 * xanthia (boolean, true if this is a Xanthia theme)
 * hidden  (boolean, true if this is a hidden theme)
 * active  (boolean, true if the theme is active)
 * 
 * @author Joerg Napp
 * @since PostNuke .760
 * @param string $theme the name of the theme
 * @return array the theme information
 **/
function pnThemeInfo($theme)
{
    $theme = isset($theme) ? $theme : '';
    if (!pnVarValidate($theme, 'theme')) {
        return false;
    }
    $themepath = pnVarPrepForOS($theme);
    // determine if this is a valid theme
    if (!file_exists(WHERE_IS_PERSO . "themes/{$themepath}/theme.php") && !file_exists("themes/{$themepath}/theme.php")) {
        return false;
    }
    $themeinfo = array();
    // Setting the defaults
    $themeinfo['name'] = $theme;
    // might be useful
    $themeinfo['hidden'] = false;
    // A theme isn't hidden unless explicitly marked as hidden
    $themeinfo['xanthia'] = false;
    // assume the theme not to be a Xanthia theme unless xaninfo.php is present.
    $themeinfo['active'] = true;
    // assume the theme to be active unless it isn't
    if (file_exists($file = WHERE_IS_PERSO . "themes/{$themepath}/themeinfo.php")) {
        include $file;
    } elseif (file_exists($file = "themes/{$themepath}/themeinfo.php")) {
        include $file;
    } elseif (file_exists($file = WHERE_IS_PERSO . "themes/{$themepath}/xaninfo.php")) {
        $themeinfo['xanthia'] = true;
        include $file;
    } elseif (file_exists($file = "themes/{$themepath}/xaninfo.php")) {
        $themeinfo['xanthia'] = true;
        include $file;
    }
    if ($themeinfo['xanthia']) {
        if (pnModAPILoad('Xanthia', 'user')) {
            // see if the skin is in the database (=active)
            $skinid = pnModAPIFunc('Xanthia', 'user', 'getSkinID', array('skin' => $theme));
            $themeinfo['active'] = (bool) $skinid;
        } else {
            // don't use Xanthia themes without Xanthia.
            // Maybe the function should return false (= not a valid theme) in this case?
            $themeinfo['active'] = false;
        }
    }
    return $themeinfo;
}
Exemplo n.º 3
0
function userCheck($var)
{
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();
    $uname = $var['add_uname'];
    $email = $var['add_email'];
    $stop = "";
    $res = pnVarValidate($email, 'email');
    if ($res == false) {
        $stop = "<center><font class=\"pn-title\">" . _ERRORINVEMAIL . "</center></font><br>";
    }
    // Here we test the uname. Any value is possible but space.
    // On special character sets you might configure the server.
    // (was bug #455288)
    if (!$uname || !(ereg("^[[:print:]]+", $uname) && !ereg("[[:space:]]", $uname))) {
        /**
         * if ((!$uname) || ($uname=="") || (ereg("[^a-zA-Z0-9_-]",$uname))) {
         */
        $stop = "<center><font class=\"pn-title\">" . _ERRORINVNICK . "</center></font><br>";
    }
    if (strlen($uname) > 25) {
        $stop = "<center><font class=\"pn-title\">" . _NICK2LONG . "</center></font>";
    }
    // Illegal Usernames [class007]
    $reg_illegalusername = pnConfigGetVar('reg_Illegalusername');
    if (!empty($reg_illegalusername)) {
        $usernames = explode(" ", $reg_illegalusername);
        $count = count($usernames);
        $pregcondition = "/((";
        for ($i = 0; $i < $count; $i++) {
            if ($i != $count - 1) {
                $pregcondition .= $usernames[$i] . ")|(";
            } else {
                $pregcondition .= $usernames[$i] . "))/iAD";
            }
        }
        // die ($pregcondition);
        if (preg_match($pregcondition, $uname)) {
            $stop = "<center><font class=\"pn-title\">" . _NAMERESERVED . "</center></font>";
        }
    }
    if (strrpos($uname, ' ') > 0) {
        $stop = "<center><font class=\"pn-title\">" . _NICKNOSPACES . "</center></font>";
    }
    $column =& $pntable['users_column'];
    $existinguser = $dbconn->Execute("SELECT {$column['uname']} FROM {$pntable['users']} WHERE {$column['uname']}='" . pnVarPrepForStore($uname) . "\n'");
    if (!$existinguser->EOF) {
        $stop = "<center><font class=\"pn-title\">" . _NICKTAKEN . "</center></font><br>";
    }
    $existinguser->Close();
    // new by class007
    if (pnConfigGetVar('reg_uniemail')) {
        if (!$existinguser->EOF) {
            $existinguser = $dbconn->Execute("SELECT {$column['email']} FROM {$pntable['users']} WHERE {$column['email']}='" . pnVarPrepForStore($email) . "'");
            $stop = "<center><font class=\"pn-title\">" . _EMAILREGISTERED . "</center></font><br>";
            $existinguser->Close();
        }
    }
    return $stop;
}
Exemplo n.º 4
0
/**
 * pnModLangLoad
 * loads the language files for a module
 *
 * @author Mark West
 * @link http://www.markwest.me.uk
 * @param modname - name of the module
 * @param type - type of the language file to load e.g. user, admin
 * @param api - load api lang file or gui lang file
 */
function pnModLangLoad($modname, $type = 'user', $api = false)
{
    // define input, all numbers and booleans to strings
    $modname = isset($modname) ? (string) $modname : '';
    // validate
    if (!pnVarValidate($modname, 'mod')) {
        return false;
    }
    // get the module info
    $modinfo = isset($modname) ? pnModGetInfo(pnModGetIDFromName($modname)) : false;
    if (!$modinfo) {
        return false;
    }
    // create variables for the OS preped version of the directory
    list($osdirectory, $ostype) = pnVarPrepForOS($modinfo['directory'], $type);
    $defaultlang = pnConfigGetVar('language');
    if (empty($defaultlang)) {
        $defaultlang = 'eng';
    }
    $osapi = '';
    if ($api) {
        $osapi = 'api';
    }
    $currentlang = pnUserGetLang();
    if (file_exists("modules/{$osdirectory}/pnlang/{$currentlang}/{$ostype}{$osapi}.php")) {
        include_once "modules/{$osdirectory}/pnlang/" . pnVarPrepForOS($currentlang) . "/{$ostype}{$osapi}.php";
    } elseif (file_exists("modules/{$osdirectory}/pnlang/{$defaultlang}/{$ostype}{$osapi}.php")) {
        include_once "modules/{$osdirectory}/pnlang/" . pnVarPrepForOS($defaultlang) . "/{$ostype}{$osapi}.php";
    }
    return;
}