function checkCookie() { if($this->_valid === true) { return true; } $cookieName = $this->libs->Config->get('Session', 'cookieName'); if(isset($_COOKIE[$cookieName])) { //D::log($_COOKIE[$cookieName], 'Cookie Set'); $cookie = explode('_', $_COOKIE[$cookieName]); $row = f_first($this->libs->Query->select('*')->from($this->libs->Config->get('Session', 'tableName'))->where(array('id' => f_first($cookie)))->results()); if(!empty($row) && $this->encryptCheckString($row->uid) === f_last($cookie)) { if($this->encryptCheckString($this->getCheckString($row->uid)) === $row->checkString) { $this->_valid = true; $this->_id = $row->id; $this->loadData($this->libs->Query->select('*')->from($this->libs->Config->get('Session', 'dataTableName'))->where(array('session' => $this->_id))->results()); D::log($this->_data, 'cookie is good. heres some data:'); return true; } } } $uid = $this->getUid(); if(!$this->saveCookie($this->generateCookie($this->getCheckString($uid), $uid)) ) { D::warn('Cookie Failed'); return false; } else { return true; } }
public function newDb($name) { $database = $this->libs->Config->get('databases', $name); //Sweetframework::getClass('lib', 'databases/drivers/' . $database['driver'], ); //App::includeLibrary('Databases/Drivers/' . $database['driver'] . '.php'); $this->setCurrentDb($name); $this->databases[$name] = Sweetframework::loadClass('lib', 'databases/drivers/' . $database['driver'], $database); //new $database['driver']($database); if(!$this->databases[$name]->connect()) { D::warn('failed to connect to the db'); } }
function connect($settings=null) { //print_r($settings); if(isset($settings)) { $this->settings = $settings; } // D::show($this->settings, 'newDB'); //connects using our settings /* @todo make the @ be able to be turned on and off by debug mode */ $this->connection = @mysql_connect($this->settings['host'], $this->settings['username'], $this->settings['password']); if (!$this->connection) { D::warn("Couldn't to the db dude, check the settings man.\nHost: " . $this->settings['host'] . "\nUser: "******"\nDatabase: " . $this->settings['host']); return false; } else { if(!mysql_select_db($this->settings['databaseName'])) { D::warn('Could not select the database: ' . $this->settings['databaseName']); return false; } D::log('DB Connected'); $this->connected = true; return true; } }
function __set($var, $value) { $this->__update[$var] = $value; if(is_scalar($value)) { $this->__data = array_map( function($row) use($var, $value) { $row[$var] = $value; return $row; }, $this->__data ); return $value; } else { D::warn('SweetRows do not currently support non scalar values… yet.'); } }
public function go($query=null) { if(!isset($query)) { self::$last = $this->_build(); } else { self::$last = $query; } $this->reset(); if(!self::$_driver->query(self::$last)) { D::warn('Query Failed: ' . self::$last); return false; } return $this; }
public static function loadFileType($type, $name) { /* @todo - need to use a FileName function here */ //$loc = self::fileLoc($name); foreach(self::$paths[$type] as $path) { if(self::loadFile($path, $name. '.php')) { return true; } } D::warn('Could not load file with type ' . $type . ' and name ' . $name); return false; }