Example #1
0
 private function _CheckSchemaVersion()
 {
     $Config = $this->GetSys('Config');
     // Get the schema version required
     $Version = $Config->GetConfiguration('schema_version');
     $Model = new cModel('SchemaVersions');
     // SchemaVersions doesn't exist, we must be upgrading from 0.7.8 and have not updated.
     if (!$Model->Get('Exists')) {
         echo __('Table Does Not Exist', array('tablename' => 'SchemaVersions'));
         exit;
     }
     // Retrieve the latest schema version information.
     $Model->Retrieve(null, 'Schema_PK DESC', array('start' => 0, 'step' => 1));
     // No schema version info was found, so we must be upgrading from 0.7.8.
     if ($Model->Get('Total') == 0) {
         echo __('Schema Version Information Unavailable', array('version' => $Version));
         exit;
     }
     $Model->Fetch();
     $Current = $Model->Get('Version');
     $Script = $Model->Get('Script');
     // If the current and the expected schema version don't match, give a suggested update scripts to run.
     if ($Current != $Version) {
         echo __('Incorrect Schema Version', array('version' => $Version, 'current' => $Current, 'script' => $Script));
         exit;
     }
     return true;
 }
Example #2
0
 public function Active($pAddress, $pUserId)
 {
     $UserAccounts = new cModel('UserAccounts');
     $UserAccounts->Structure();
     $UserAccounts->Retrieve(array('Email' => $pAddress));
     if ($UserAccounts->Get('Total') == 0) {
         return false;
     }
     return true;
 }
Example #3
0
 public function IdentifierExists($pData = null)
 {
     if ($this->_Source != 'Component') {
         return false;
     }
     $Identifier = $pData['Identifier'];
     $Model = new cModel('PageReferences');
     $Model->Retrieve(array('Identifier' => $Identifier));
     if ($Model->Get('Total') > 0) {
         return true;
     }
     return false;
 }
Example #4
0
 public function EndFooterDisplay($pData = null)
 {
     $Model = new cModel('Janitor');
     $Model->Retrieve(array('Task' => 'Janitorial'));
     $Model->Fetch();
     $lastUpdated = strtotime($Model->Get('Updated'));
     $now = strtotime(NOW());
     $diff = $now - $lastUpdated;
     $diffMinutes = $diff / 60;
     // If we've recently updated, don't ping the Janitor.
     if ($diffMinutes < 1) {
         return true;
     }
     $this->_Janitorial();
     return true;
 }
Example #5
0
 public function Load($pUser)
 {
     $UserAccounts = new cModel("UserAccounts");
     $UserAccounts->Structure();
     if (is_int($pUser)) {
         $UserAccounts->Retrieve(array('Account_PK' => $pUser));
     } else {
         $UserAccounts->Retrieve(array('Username' => $pUser));
     }
     $UserAccounts->Fetch();
     if (!$UserAccounts->Get("Username")) {
         return false;
     }
     $this->Username = $UserAccounts->Get("Username");
     $this->Id = $UserAccounts->Get("Account_PK");
     // Load the user profile information.
     $UserProfile = new cModel("UserProfile");
     $UserProfile->Retrieve(array("Account_FK" => $UserAccounts->Get("Account_PK")));
     $UserProfile->Fetch();
     $this->Account_PK = $UserProfile->Get("Account_FK");
     if ($UserProfile->Get("Alias")) {
         $this->Fullname = $UserProfile->Get("Alias");
     } else {
         $this->Fullname = $UserProfile->Get("Fullname");
     }
     $this->Description = $UserProfile->Get("Description");
     $this->Domain = $_SERVER['HTTP_HOST'];
     $this->Account = $this->Username . '@' . $this->Domain;
     $this->Email = $UserAccounts->Get('Email');
     $this->Remote = false;
     return true;
 }
Example #6
0
 function Forgot($pView = null, $pData = null)
 {
     $username = ltrim(rtrim($this->GetSys("Request")->Get("Username")));
     if (!$username) {
         $this->GetSys("Session")->Context("login.login.(\\d+).login");
         $this->GetSys("Session")->Set("Message", "Invalid Username");
         $this->GetSys("Session")->Set("Error", 1);
         return $this->Display($pView, $pData);
     }
     $this->Mailer = $this->GetSys("Mailer");
     $newpassword = $this->_GeneratePassword('##XX##XX#XX!');
     $UserAccounts = new cModel('UserAccounts');
     $UserAccounts->Retrieve(array("Username" => $username));
     if (!$UserAccounts->Fetch()) {
         $this->GetSys("Session")->Context("login.login.(\\d+).login");
         $this->GetSys("Session")->Set("Message", __("Username Not Found", array("username" => $username)));
         $this->GetSys("Session")->Set("Error", 1);
         return $this->Display($pView, $pData);
     }
     $UserProfile = new cModel('UserProfile');
     $UserProfile->Retrieve($UserAccounts->Get("Account_PK"));
     $UserProfile->Fetch();
     $newpass = $this->GetSys("Crypt")->Encrypt($newpassword);
     $to = $UserAccounts->Get("Email");
     $toName = $UserProfile->Get("Fullname");
     if (!$this->ForgotEmail($to, $username, $newpassword)) {
         // Couldn't send out the message, so error without resetting the pw.
         $this->GetSys("Session")->Context("login.login.(\\d+).login");
         $this->GetSys("Session")->Set("Message", "Error Sending Message");
         $this->GetSys("Session")->Set("Error", 1);
     } else {
         // Reset the pw.
         $UserAccounts->Set("Pass", $newpass);
         $UserAccounts->Save();
         $this->GetSys("Session")->Context("login.login.(\\d+).login");
         $this->GetSys("Session")->Set("Message", __("Password Has Been Reset", array("username" => $username)));
         $this->GetSys("Session")->Set("Error", 0);
     }
     return $this->Display($pView, $pData);
 }
Example #7
0
 public function UpdateNetworkNode($pDomain, $pEntryPoint, $pVersion, $pProtocols = 'http')
 {
     $Model = new cModel('NetworkNodes');
     $Model->Retrieve(array('Domain' => $pDomain));
     if ($Model->Get('Total') == 0) {
         // New record.
         $Model->Set('Trust', 'discovered');
         $Model->Set('Access', 'public');
         $Model->Set('Inherit', '0');
         $Model->Set('Source', ASD_DOMAIN);
         $Model->Set('Created', NOW());
     } else {
         $Model->Fetch();
     }
     $Model->Set('Domain', $pDomain);
     $Model->Set('Entry', $pEntryPoint);
     $Model->Set('Version', $pVersion);
     $Model->Set('Protocols', $pProtocols);
     $Model->Set('Updated', NOW());
     $Model->Set('Contacted', NOW());
     $Model->Save();
     return true;
 }
Example #8
0
 public function Access($pData = null)
 {
     // Only allow internal components to get access information.
     $Source = $this->Get('Source');
     if ($Source != 'Component') {
         return false;
     }
     $account = isset($pData['account']) ? $pData['account'] : null;
     $context = isset($pData['context']) ? $pData['context'] : null;
     $access = new cSecurityAccess();
     if (!$account) {
         $user = $this->GetSys("Components")->Talk("User", "Current");
         // No user is logged in, so send back the defaults.
         if (!$user) {
             $access->Set("Read", isset($pData['Read']) ? $pData['Read'] : false);
             $access->Set("Write", isset($pData['Write']) ? $pData['Write'] : false);
             $access->Set("Admin", isset($pData['Admin']) ? $pData['Admin'] : false);
             return $access;
         }
         $account = $user->Username . '@' . $user->Domain;
     }
     if (!$context) {
         $context = $_SERVER['REQUEST_URI'];
     }
     $account = strtolower($account);
     // Return cached value to avoid duplicate effort.
     if (isset($this->_Cache[$account][$context])) {
         return $this->_Cache[$account][$context];
     }
     $accessModel = new cModel("AccessControl");
     $domain = ASD_DOMAIN;
     $pattern = '/(.*)@' . $domain . '/';
     if (preg_match($pattern, $account)) {
         list($username, $domain) = explode('@', $account);
     }
     // Load security settings from AccessControl.
     $criteria = array(array("account" => $account, "||account" => $username), "Location" => $context);
     $accessModel->Retrieve($criteria);
     $accessModel->Fetch();
     // If no entries were found, go backwards for inheritance.
     if ($accessModel->Get("Total") == 0 and $context != '/') {
         // Remove top directory off of Location.
         $currentLocation = strrchr(rtrim($context, "/"), "/");
         $currentLocationpos = strpos($context, $currentLocation);
         $parentLocation = substr($context, 0, $currentLocationpos + 1);
         // Use recursive call of this function.
         $parameters['account'] = $account;
         $parameters['context'] = $parentLocation;
         $parentAccess = $this->Access($parameters);
         if ($parentAccess->Get("Inheritance")) {
             // Inherit parent values.
             $access->Set("Inheritance", $parentAccess->Get("Inheritance"));
             $access->Set("Read", $parentAccess->Get("Read"));
             $access->Set("Write", $parentAccess->Get("Write"));
             $access->Set("Admin", $parentAccess->Get("Admin"));
         } else {
             // Use default values;
             $this->AccessControl->Location = $context;
             $access->Set("Read", isset($pData['Read']) ? $pData['Read'] : false);
             $access->Set("Write", isset($pData['Write']) ? $pData['Write'] : false);
             $access->Set("Admin", isset($pData['Admin']) ? $pData['Admin'] : false);
         }
         // if
         unset($parentAccess);
     } else {
         $access->Set("Read", $accessModel->Get("Read"));
         $access->Set("Write", $accessModel->Get("Write"));
         $access->Set("Admin", $accessModel->Get("Admin"));
         $access->Set("Inheritance", $accessModel->Get("Inheritance"));
     }
     // if
     // Store result in internal cache.
     $this->_Cache[$account][$context] = $access;
     return $access;
 }
Example #9
0
 public function CreateRelationship($pFirst, $pSecond)
 {
     $UserAccounts = new cModel('UserAccounts');
     $UserAccounts->Retrieve(array('Account_PK' => $pFirst));
     $UserAccounts->Fetch();
     $firstUsername = $UserAccounts->Get('Username');
     $UserAccounts->Retrieve(array('Account_PK' => $pSecond));
     $UserAccounts->Fetch();
     $secondUsername = $UserAccounts->Get('Username');
     // Create first record
     $this->Set('Owner_FK', $pFirst);
     $this->Set('Username', $secondUsername);
     $this->Set('Domain', ASD_DOMAIN);
     $this->Set('Verification', 1);
     $this->Set("Created", NOW());
     $this->Save();
     // Create second record
     $this->Set('Friend_PK', NULL);
     $this->Set('Owner_FK', $pSecond);
     $this->Set('Username', $firstUsername);
     $this->Set('Domain', ASD_DOMAIN);
     $this->Set('Verification', 1);
     $this->Set("Created", NOW());
     $this->Save();
     return true;
 }
Example #10
0
 public function _LoadNodeNetwork()
 {
     // Cache the values so we don't keep loading this.
     if (isset($this->_CachedNodeNetwork)) {
         return $this->_CachedNodeNetwork;
     }
     // Load a list of known nodes.
     $nodes = new cModel('NetworkNodes');
     $nodes->Retrieve();
     if ($nodes->Get('Total') == 0) {
         return false;
     }
     $trusted = array();
     $discovered = array();
     $blocked = array();
     // Separate into a list of trusted, blocked or discovered
     while ($nodes->Fetch()) {
         if ($nodes->Get('Trust') == 'trusted') {
             $trusted[] = $nodes->Get('Domain');
         } else {
             if ($nodes->Get('Trust') == 'discovered') {
                 $discovered[] = $nodes->Get('Domain');
             } else {
                 $blocked[] = $nodes->Get('Domain');
             }
         }
         $nodeList[] = $nodes->Get('Data');
     }
     $this->_CachedNodeNetwork = array($trusted, $discovered, $blocked);
     $this->_CachedNodeInformation = $nodeList;
     return array($trusted, $discovered, $blocked);
 }