コード例 #1
0
 function sendResponse()
 {
     if ($this->currentView) {
         $form = XOS::create('xoops_pyro_Form', array('instances' => array('preferences' => &$this->preferencesBag), 'submissions' => array('save-prefs' => array($_SERVER['REQUEST_URI'], 'urlencoded-post')), 'renderAsHtml' => true));
         $this->viewVars['form'] = $form;
         $this->viewVars['prefs'] = $this->preferencesBag;
     }
     return parent::sendResponse();
 }
コード例 #2
0
 function xoInit($options = array())
 {
     if (!$this->db) {
         $this->db =& XOS::create('xoops_db_Database');
     }
     $table = $this->db->prefix('sys_preference');
     $selectPred = "(`bundleId`='' OR `bundleId`=?) AND (`hostName`='' OR `hostName`=?) AND (`language`='' OR `language`=?)";
     $this->queries = array('getPrefs' => "SELECT * FROM `{$table}` WHERE `userId`=? AND {$selectPred} ORDER BY `weight`,`language`", 'delPrefs' => "DELETE FROM `{$table}` WHERE `bundleId`=:bundle AND `userId`=:user AND `hostName`=:host", 'insertScalar' => "INSERT INTO `{$table}` (`weight`,`bundleId`,`userId`,`hostName`,`language`,`propertyName`,`scalarValue`,`complexValue`) " . "VALUES ", 'insertComplex' => "INSERT INTO `{$table}` (`weight`,`bundleId`,`userId`,`hostName`,`language`,`propertyName`,`scalarValue`,`complexValue`) " . "VALUES ");
     return true;
 }
コード例 #3
0
 /**
  * Initializes the accessor instance
  */
 function xoInit($options = array())
 {
     // If no db specified, automatically connect to the system db
     if (!$this->db) {
         $this->db =& XOS::create('xoops_db_Database');
     }
     if (isset($this->tables[0])) {
         $this->tables = array_combine($this->tables, array_map(array(&$this->db, 'prefix'), $this->tables));
     }
     return true;
 }
コード例 #4
0
 /**
  * Initialize the specified object as a save handler
  *
  * @param mixed $handler Object to attach (or bundleIdentifier of the handler to instanciate)
  * @return boolean true on success, false otherwise
  */
 function attachHandler($handler)
 {
     if (!is_object($handler)) {
         if (!($handler = XOS::create($handler))) {
             trigger_error("Failed to initialize the session save handler.", E_USER_WARNING);
             return false;
         }
     }
     session_set_save_handler(array(&$handler, 'open'), array(&$handler, 'close'), array(&$handler, 'read'), array(&$handler, 'write'), array(&$handler, 'destroy'), array(&$handler, 'gc'));
     $this->saveHandler =& $handler;
     return true;
 }
コード例 #5
0
 function checkCredentials($login, $password, $hash = '')
 {
     if (empty($hash)) {
         $password = md5($password);
     }
     $db =& XOS::create('xoops_db_Database');
     $table = $db->prefix('users');
     $stmt = $db->prepare("SELECT COUNT(*) FROM `{$table}` WHERE `uname`=:login AND `pass`=:password");
     $stmt->bindValue(':login', $login, PDO_PARAM_STR);
     $stmt->bindValue(':password', $password, PDO_PARAM_STR);
     if ($stmt->execute()) {
         list($count) = $stmt->fetch(PDO_FETCH_NUM);
         $stmt->closeCursor();
     }
     return @$count ? true : false;
 }
コード例 #6
0
ファイル: auth.php プロジェクト: BackupTheBerlios/xoops4-svn
 /**
  * Check the validity of the specified user credentials
  * 
  * <p>
  * The authentication service asks every driver configured in the
  * xoops_auth_AuthenticationService::authDrivers property to check the specified
  * credentials, until one positively recognizes the user.
  * </p><p>
  * It returns the XOOPS login of the authenticated user if one is identified, or false otherwise
  * </p>
  *
  * @param string $login User name to provide to auth drivers
  * @param string $password Password to provide to auth drivers
  * @param string $hash Hash function used to encrypt the provided password (if any)
  * @return string XOOPS login of the identified user (false if all drivers failed to authenticate the user)
  */
 function checkCredentials($login, $password, $hash = '')
 {
     // Check each auth
     foreach ($this->authDrivers as $k => $driver) {
         if (!is_object($driver)) {
             if (!($instance = XOS::create($driver))) {
                 trigger_error("Cannot instanciate authentication driver {$driver}", E_USER_WARNING);
                 unset($this->authDrivers[$k]);
                 continue;
             }
             $driver = $this->authDrivers[$k] = $instance;
         }
         if ($xoopsLogin = $driver->checkCredentials($login, $password, $hash)) {
             return $xoopsLogin !== true ? $xoopsLogin : $login;
         }
     }
     return false;
 }
コード例 #7
0
 /**
  * Creates an instance to represent a connection to the requested database
  * 
  * mysql:host=localhost;dbname=mydb
  * to explicitely specify a xoops driver:
  * xoops.legacy:host=localhost;dbname=mydb
  */
 function &createInstance($options = array(), $initArgs = array())
 {
     if (!isset($options['dsn'])) {
         $options['dsn'] = 'system';
     }
     if (isset($this->instances[$options['dsn']])) {
         return $this->instances[$options['dsn']];
     }
     $inst = false;
     $parsed = explode(':', $dsn = $options['dsn'], 2);
     if (count($parsed) == 1) {
         // An alias name was specified
         if (!isset($this->availableStores[$parsed[0]])) {
             trigger_error("The database alias {$parsed[0]} is invalid.", E_USER_WARNING);
             return $inst;
         }
         $options = array_merge($this->availableStores[$parsed[0]], $options);
     } else {
         // A real DSN was specified
         if (substr($parsed[0], 0, 5) == 'xoops') {
             // Convert the rest of the dsn string to properties
             $parsed = explode(';', $parsed[1]);
             foreach ($parsed as $prop) {
                 list($name, $value) = explode('=', $prop, 2);
                 $options[$name] = $value;
             }
             $options['driverName'] = $parsed[0];
         }
     }
     if (substr($options['driverName'], 0, 5) != 'xoops') {
         trigger_error("Direct PDO drivers access is not implemented yet.", E_USER_WARNING);
         return $inst;
     } else {
         $options['driverName'] = substr($options['driverName'], 6);
         $inst =& XOS::create("xoops_db_Database_{$options['driverName']}", $options);
         $this->instances[$dsn] =& $inst;
     }
     return $inst;
 }
コード例 #8
0
ファイル: exxos.php プロジェクト: BackupTheBerlios/xoops4-svn
 /**
  * Create an object instance
  * 
  * This function will delegate object instanciation to a local factory if one has been
  * specified. It is also able to handle singletons: when a singleton is requested
  * it will check if it has not been already created and return a reference to the already
  * existing instance if it has.
  */
 function &create($id, $options = null, $args = null)
 {
     $me =& $GLOBALS[EXXOS];
     $inst = false;
     if (is_array($id)) {
         @(list($id, $options, $initArgs) = $id);
     }
     if (isset($me->services[$id])) {
         return $me->services[$id];
     }
     XOS::import($id);
     if (isset($me->registry[$id])) {
         if (!isset($me->factories[$id]) && isset($me->registry[$id]['xoFactory'])) {
             $me->factories[$id] =& XOS::create($me->registry[$id]['xoFactory']);
             unset($me->registry[$id]['xoFactory']);
         }
         if (@is_object($me->factories[$id])) {
             if (method_exists($me->factories[$id], 'createInstanceOf')) {
                 $inst =& $me->factories[$id]->createInstanceOf($id, $options);
             } else {
                 $inst =& $me->factories[$id]->createInstance($options);
             }
         } else {
             $inst =& XOS::createInstanceOf($id, $options, $args);
         }
         if (is_object($inst)) {
             if (@$inst->xoSingleton) {
                 $me->services[$id] =& $inst;
                 if (!@empty($options['xoServiceName'])) {
                     $me->services[$options['xoServiceName']] =& $inst;
                 }
             }
         }
     }
     return $inst;
 }
コード例 #9
0
ファイル: theme.php プロジェクト: BackupTheBerlios/xoops4-svn
 function resourcePath($path, $fromDocRoot = true)
 {
     global $xoops;
     if ($path[0] == '/') {
         $path = substr($path, 1);
         $fromDocRoot = false;
     }
     if (file_exists("{$this->path}/{$path}")) {
         return "themes/{$this->folderName}/{$path}";
     }
     if (!empty($this->parentTheme)) {
         if (!is_object($this->parentTheme)) {
             $this->parentTheme =& XOS::create('xoops_pyro_Theme', array('folderName' => $this->parentTheme));
         }
         if (is_object($this->parentTheme)) {
             return $this->parentTheme->resourcePath($path, $fromDocRoot);
         }
     }
     return $fromDocRoot ? "www/{$path}" : "themes/{$this->folderName}/{$path}";
 }
コード例 #10
0
 /**
  * Create an instance of the specified service by name
  * 
  * @param string $name		Name under which the service will be available
  * @param string $bundleId	ID of the class to instanciate
  * @param array  $options	Parameters to send to the service during instanciation
  */
 function &loadService($name, $bundleId = '', $options = array())
 {
     if (isset($this->captures[$name])) {
         $bundleId = $this->captures[$name];
     } elseif (empty($bundleId)) {
         $bundleId = $name;
     }
     if (!isset($this->services[$name])) {
         $this->services[$name] =& XOS::create($bundleId, $options);
     }
     return $this->services[$name];
 }
コード例 #11
0
    $xoopsTpl->assign(array('xoops_isuser' => true, 'xoops_userid' => $xoopsUser->getVar('uid'), 'xoops_uname' => $xoopsUser->getVar('uname'), 'xoops_isadmin' => $xoopsUserIsAdmin));
    $groups = $xoopsUser->getGroups();
} else {
    $xoopsTpl->assign(array('xoops_isuser' => false, 'xoops_isadmin' => false));
    $groups = XOOPS_GROUP_ANONYMOUS;
}
if (isset($xoopsModule) && is_object($xoopsModule)) {
    // set page title
    $xoopsTpl->assign('xoops_pagetitle', $xoopsModule->getVar('name'));
    $xoopsTpl->assign('xoops_dirname', $xoopsModule->getVar('dirname'));
} else {
    $xoopsTpl->assign('xoops_pagetitle', htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES));
    $xoopsTpl->assign('xoops_dirname', "system");
}
/////////
$builder =& XOS::create('xoops_logos_PageBuilder');
$builder->retrieveBlocks();
$builder->assignVars($xoops->services['theme']->template);
if (xoops_getenv('REQUEST_METHOD') != 'POST' && !empty($xoopsModule) && !empty($xoopsConfig['module_cache'][$xoopsModule->getVar('mid')])) {
    $xoopsTpl->xoops_setCaching(2);
    $xoopsTpl->xoops_setCacheTime($xoopsConfig['module_cache'][$xoopsModule->getVar('mid')]);
    if (!isset($xoopsOption['template_main'])) {
        $xoopsCachedTemplate = 'db:system_dummy.html';
    } else {
        $xoopsCachedTemplate = 'db:' . $xoopsOption['template_main'];
    }
    // generate safe cache Id
    $xoopsCachedTemplateId = 'mod_' . $xoopsModule->getVar('dirname') . '|' . md5(str_replace(XOOPS_URL, '', $GLOBALS['xoopsRequestUri']));
    if ($xoopsTpl->is_cached($xoopsCachedTemplate, $xoopsCachedTemplateId)) {
        $xoopsLogger->addExtra($xoopsCachedTemplate, sprintf('Cached (regenerates every %d seconds)', $xoopsConfig['module_cache'][$xoopsModule->getVar('mid')]));
        $xoopsTpl->assign('xoops_contents', $xoopsTpl->fetch($xoopsCachedTemplate, $xoopsCachedTemplateId));
コード例 #12
0
 /**
  * Accept the specified user as the currently logged in user
  *
  * @param string $login Login of the user to accept
  * @param boolean $permanent Whether to accept this user permanently or for the current request only
  * @return boolean
  */
 function acceptUser($login = '', $permanent = false)
 {
     if (!$login) {
         return false;
     }
     // @TODO-2.3: Clean this up later...
     $GLOBALS['xoopsDB'] = $this->loadService('legacydb');
     require_once XOOPS_ROOT_PATH . '/include/functions.php';
     require_once XOOPS_ROOT_PATH . '/kernel/object.php';
     require_once XOOPS_ROOT_PATH . '/class/criteria.php';
     $handler =& xoops_gethandler('member');
     list($user) = $handler->getUsers(new Criteria('uname', $login));
     if (is_object($user)) {
         $GLOBALS['xoopsUser'] = $user;
         XOS::import('xoops_kernel_User');
         $lvl_lookup = array(0 => XO_LEVEL_INACTIVE, 1 => XO_LEVEL_REGISTERED, 5 => XO_LEVEL_ADMIN);
         $this->currentUser = XOS::create('xoops_kernel_User', array('userId' => $user->getVar('uid', 'n'), 'login' => $user->getVar('uname', 'n'), 'email' => $user->getVar('email', 'n'), 'groups' => $user->getGroups(), 'fullName' => $user->getVar('name', 'n'), 'level' => $lvl_lookup[$user->getVar('level', 'n')]));
         if (isset($this->services['http'])) {
             $this->services['http']->addVariation('xo-user', $this->currentUser->userId);
         }
         if ($permanent && $this->services['session']) {
             $this->services['session']->start();
             $_SESSION[$this->xoBundleIdentifier]['currentUser'] = $login;
         }
         return true;
     } else {
         $GLOBALS['xoopsUser'] = '';
         $this->currentUser = XOS::create('xoops_kernel_User');
     }
     return false;
 }
コード例 #13
0
ファイル: theme.php プロジェクト: BackupTheBerlios/xoops4-svn
 function resourcePath($path, $fromDocRoot = true)
 {
     global $xoops;
     $parts = explode('#', $path, 2);
     if (count($parts) > 1) {
         list($bundleId, $resPath) = $parts;
         // This is component resource: modules are in 'modules', and components in 'components'
         $themedRoot = substr($parts[0], 0, 4) == 'mod_' ? 'modules' : 'components';
         if (file_exists("{$this->path}/{$themedRoot}/{$bundleId}/{$resPath}")) {
             return "themes/{$this->folderName}/{$themedRoot}/{$bundleId}/{$resPath}";
         } else {
             return XOS::classVar($bundleId, 'xoBundleRoot') . '/' . $resPath;
         }
     }
     if (substr($path, 0, 1) == '/') {
         $path = substr($path, 1);
         $fromDocRoot = false;
     }
     if (file_exists("{$this->path}/{$path}")) {
         return "themes/{$this->folderName}/{$path}";
     }
     if (!empty($this->parentTheme)) {
         if (!is_object($this->parentTheme)) {
             $this->parentTheme =& XOS::create('xoops_opal_Theme', array('folderName' => $this->parentTheme));
         }
         if (is_object($this->parentTheme)) {
             return $this->parentTheme->resourcePath($path, $fromDocRoot);
         }
     }
     return $fromDocRoot ? "www/{$path}" : "themes/{$this->folderName}/{$path}";
 }
コード例 #14
0
ファイル: mysql.php プロジェクト: BackupTheBerlios/xoops4-svn
 function fetch($mode = null, $orientation = null, $offset = null)
 {
     if (!$this->result) {
         return false;
     }
     if (!$mode) {
         $mode = $this->fetchMode;
     }
     switch ($mode) {
         case PDO_FETCH_ASSOC:
             return mysql_fetch_array($this->result, MYSQL_ASSOC);
         case PDO_FETCH_BOTH:
             return mysql_fetch_array($this->result, MYSQL_BOTH);
         case PDO_FETCH_NUM:
             return mysql_fetch_array($this->result, MYSQL_NUM);
         case PDO_FETCH_LAZY:
         case PDO_FETCH_OBJ:
             if ($props = mysql_fetch_array($this->result, MYSQL_ASSOC)) {
                 $target = new stdClass();
                 XOS::apply($target, $props);
                 return $target;
             }
             return false;
         case PDO_FETCH_INTO:
             if ($props = mysql_fetch_array($this->result, MYSQL_ASSOC)) {
                 XOS::apply($this->fetchTarget, $props);
                 return $this->fetchTarget;
             }
             return false;
         case PDO_FETCH_CLASS:
             if ($props = mysql_fetch_array($this->result, MYSQL_ASSOC)) {
                 return XOS::create($this->fetchTarget, $props);
             }
             return false;
         case PDO_FETCH_CLASS | PDO_FETCH_CLASSTYPE:
             if ($props = mysql_fetch_array($this->result, MYSQL_ASSOC)) {
                 $classType = array_shift($props);
                 return XOS::create($classType, $props);
             }
             return false;
         case PDO_FETCH_BOUND:
             if ($row = mysql_fetch_array($this->result, MYSQL_BOTH)) {
                 foreach ($this->columnBindings as $k => $col) {
                     $col[0] = $this->castValue(is_int($k) ? $row[$k - 1] : $row[$k], $col[1]);
                 }
                 return true;
             }
             return false;
     }
 }