PageRenderTime 38ms CodeModel.GetById 3ms app.highlight 27ms RepoModel.GetById 1ms app.codeStats 1ms

/ xvweb/core/XVWeb.class.php

http://xvweb.googlecode.com/
PHP | 934 lines | 795 code | 34 blank | 105 comment | 104 complexity | 8fe2506d69b0f779aeccd4922d1e99ec MD5 | raw file
  1<?php
  2/***************************************************************************
  3****************   Bordeux.NET Project             *************************
  4****************   File name :   XVWeb.class.php   *************************
  5****************   Start     :   22.05.2007 r.     *************************
  6****************   License   :   LGPL              *************************
  7****************   Version   :  1.0                *************************
  8****************   Authors   :  XVweb team         *************************
  9*************************XVweb Team*****************************************
 10				Krzyszof Bednarczyk, meybe you
 11/////////////////////////////////////////////////////////////////////////////
 12Klasa XVweb jest na licencji LGPL v3.0 ( GNU LESSER GENERAL PUBLIC LICENSE)
 13****************http://www.gnu.org/licenses/lgpl-3.0.txt********************
 14		Pe?na dokumentacja znajduje si? na stronie domowej projektu: 
 15*********************http://www.bordeux.NET/Xvweb***************************
 16***************************************************************************/
 17define('DownloadLink', "http://www.bordeux.net/xvweb/getlast/?version=1.0",  true);
 18if(!defined('Cache_dir'))
 19define('Cache_dir', dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR);
 20include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'Session.XVWeb.class.php');
 21include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'operation.XVWeb.class.php');
 22include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'db.XVWeb.class.php');
 23include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'phpQuery'.DIRECTORY_SEPARATOR.'phpQuery.php');
 24
 25$LocationXVWeb = dirname(__FILE__);
 26class XVWeb extends OperationXVWeb
 27{	
 28	const Version = "1.0";
 29	//**********Baza**********//
 30	var $DataBase='';
 31	//**********/Baza**********//
 32	//**********XVWeb**********//
 33	var $IP='';
 34	var $Cookie = array();
 35	var $Server = array();
 36	//**********/XVWeb**********//
 37	//**********Sesje**********//
 38	var $Session='';
 39	//**********/Sesje**********//
 40	//**********Sesje**********//
 41	var $ParserMyBBcode;
 42	//**********/Sesje**********//
 43	//**********Sesje**********//
 44	var $HTMLtoDoc;
 45	//**********/Sesje**********//
 46	//*****Ustawienia Tabel********//
 47	var $DataBasePrefix = '';
 48
 49	//*****/Ustawienia Tabel*******//
 50	//**********Serwis**********//
 51	var $SrvName='XVweb CMS';
 52	var $SrvLocation='';
 53	var $SrvDomain= 'xvweb.bordeux.net';
 54	//**********/Serwis**********//
 55	//**********Register********//
 56	var $Register = '';
 57	var $RegisterID = '';
 58	var $RegisterError = '';
 59	//*********/Register********//
 60	var $Date = array();
 61	//**********ReadArticle********//
 62	var $ReadArticleOut = null; //array
 63	var $ReadArticleIndexOut = null; //array
 64	var $ReadArticleError = '';
 65	var $ArticleFooLocation = '';
 66	var $ArticleFooVersion = '';
 67	var $ArticleFooIDinArticleIndex = '';
 68	//*********/ReadArticle*******//
 69	//**********SystemSQL********//
 70	var $SystemRegisterMail = 'RegisterMail';
 71	var $SystemRegisterResult = 'RegisterResult';
 72	//**********/SystemSQL*******//
 73	//**********Users********//
 74	var $ReadUser= "";
 75	//*********/Users********//
 76	//**********SaveArticle*******//
 77	var $SaveArticle = array();
 78	var $SaveArticleError;
 79	//*********/SaveArticle*******//
 80	//**********SaveModificationArticle*******//
 81	var $SaveModificationArticle = array();
 82	var $SaveModificationArticleError;
 83	//*********/SaveModificationArticle*******//
 84	var $XVwebError;
 85	var $Cache;
 86	/*************************************************************************************************************/
 87	//**********Admin**********//
 88	public $AdminCheck;
 89	//**********/Admin*********//
 90	public $Admin;
 91	function __construct($ConfigDir = null) {
 92		if(!is_null($ConfigDir) ){
 93			$this->Date['ConfigDir'] = $ConfigDir;
 94		}
 95		$this->Cookie =&$GLOBALS['_COOKIE'];
 96		$this->IP = $_SERVER['REMOTE_ADDR'];
 97	}
 98	/************************************************************************************************/
 99	public function &PreWork(){
100		$this->Cache = new Cache($this);
101		$this->Session = new SessionClass($this);
102		if(is_null($this->Session->Session('user_permissions'))){
103			$this->Session->Session('Logged_ID', 2);
104			$this->Session->Session('Logged_User', "Anonymous");
105			$this->Session->Session('user_group', "anonymous");
106			$this->Session->Session('user_permissions', $this->get_group_permissions("anonymous"));
107		}
108		return $this;
109	}
110	/************************************************************************************************/
111	public function ConnectPDO($host, $dbname, $user, $password) {
112		try {
113			$this->DataBase = new xvDB('mysql:host='.($host).';dbname='.($dbname), $user, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
114			$this->DataBase->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
115			$this->DataBase->setAttribute(PDO::ATTR_PERSISTENT, true);
116			$this->DataBase->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1);
117			$this->DataBase->setAttribute( PDO::ATTR_STATEMENT_CLASS, array( 'xvDB_statement', array(&$this->DataBase, &$this)) );
118			$this->DataBase->exec("SET NAMES 'utf8' COLLATE 'utf8_bin'");
119			$this->DataBase->setXV($this);
120		} catch (PDOException $e) {
121			$this->ErrorClass($e);
122			return false;
123		}
124		return true;
125	}
126	/************************************************************************************************/
127	public function __clone() {
128		echo "Warning! XVweb is cloning !";
129	}
130	
131	/************************************************************************************************/
132	function LoadException() {
133		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'Exception.XVWeb.class.php');
134	}
135	/************************************************************************************************/
136	function IncludeParseHTML(){
137		if(empty($this->ParserMyBBcode)){
138			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'parser.MyHTML.XVweb.class.php');
139			$this->ParserMyBBcode =new ParserMyHTML($this);
140		}
141	}
142	/************************************************************************************************/
143	function &TextParser($reload=false){
144		if(empty($this->Date['Classes']['TextParser']) or $reload){
145			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'parser.MyHTML.XVweb.class.php');
146			$this->Date['Classes']['TextParser'] =new ParserMyHTML($this);
147		}
148		return $this->Date['Classes']['TextParser'];
149	}
150	/************************************************************************************************/
151	function &AntyFlood() {
152		if(empty($this->Date['Classes']['AntyFlood'])){
153			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'AntyFlood.XVWeb.class.php');
154			$this->Date['Classes']['AntyFlood'] = new AntyFlood($this);
155		}
156		return $this->Date['Classes']['AntyFlood'];
157	}
158
159	/************************************************************************************************/
160	public function ActivateUser($User, $temppass){
161		return $this->Users()->ActivateUser($User, $temppass);
162	}
163	/************************************************************************************************/
164	public function GetDivisions($URLArticle = null){
165			if(is_null($URLArticle)){
166				$URLArticle = $this->ReadArticleIndexOut['URL'];
167			}
168			if($this->Cache->exist("GetDivisions",$URLArticle))
169			return  $this->Cache->get();	
170			$GetDivisions = $this->DataBase->prepare('SELECT {ListArticles:*} FROM {ListArticles} WHERE {ListArticles:Category} = :ExCategory AND {ListArticles:Accepted} = "yes" ORDER BY {ListArticles:Topic} ASC');
171			$GetDivisions->execute(array(':ExCategory' => ($URLArticle)));
172			return $this->Cache->put("GetDivisions", $URLArticle, $GetDivisions->fetchAll(PDO::FETCH_ASSOC));
173	}
174	/************************************************************************************************/
175	function ReadArticle($address=null, $VersionArticle = "", $Theread = null) {
176                        if(!empty($VersionArticle) or $VersionArticle != 0 && is_numeric($VersionArticle)){
177                                $this->ArticleFooVersion = $VersionArticle;
178                        }
179                        if(!is_null($address)){
180                                $this->ArticleFooLocation = $this->AddSlashesStartAndEnd($address); //tu
181                                $this->ArticleFooLocation = str_replace("_", " ", $this->ArticleFooLocation);
182                        }
183                        if(!empty($this->ArticleFooIDinArticleIndex) && !is_numeric($this->ArticleFooIDinArticleIndex)){
184                                $this->ReadArticleError  = 1; // b?ad przy doborze ID
185                                return false;
186                        }
187                        if(!is_null($Theread)){
188                                $IAS = $this->ReadArticleIndexOut;
189                                $AAS = $this->ReadArticleOut;
190                                //$this->ReadArticleIndexOut = &$this->Date[$Theread]['ReadArticleIndexOut'];
191                                //$this->ReadArticleOut = &$this->Date[$Theread]['ReadArticleOut'];
192                        }
193
194                        $ExecArgs = array();
195                        $ExecArgs[':TypeVote'] = 'article';
196
197                        $Select .= '{ListArticles:*:prepend:IA.} , ((SELECT CONCAT(COALESCE( SUM({Votes:Vote}), 0),"|", COUNT(*)) FROM {Votes} WHERE {Votes:Type} = :TypeVote AND  {Votes:SID} =  IA.{ListArticles:ID} )) AS `Votes` ';
198
199                        if($this->Session->Session('Logged_Logged') == true){
200                                $Select .= ', ((SELECT CONCAT(COALESCE({Bookmarks:Observed} , 0),"|", COALESCE({Bookmarks:Bookmark}, 0)) FROM {Bookmarks} WHERE {Bookmarks:Type} = :TypeVote AND  {Bookmarks:IDS} =  IA.{ListArticles:ID}  AND {Bookmarks:User} = :UserExec)) AS `Bookmarks` ';
201                                $ExecArgs[':UserExec'] = $this->Session->Session('Logged_User');
202                        }
203
204                        if(!empty($this->ArticleFooIDinArticleIndex)){
205                                $ReadIndexArticleSQL = $this->DataBase->prepare('SELECT SQL_CACHE '.$Select.' FROM {ListArticles} AS `IA` WHERE {ListArticles:ID} = :IDExec LIMIT 1');
206                                $ExecArgs[':IDExec'] = ($this->ArticleFooIDinArticleIndex);
207                                $ReadIndexArticleSQL->execute($ExecArgs);
208                        }else{
209                                $ReadIndexArticleSQL = $this->DataBase->prepare('SELECT '.$Select.' FROM {ListArticles} AS `IA`  WHERE IA.{ListArticles:URL} = :AdresExec LIMIT 1');
210                                $ExecArgs[':AdresExec'] = ($this->ArticleFooLocation);
211                                $ReadIndexArticleSQL->execute($ExecArgs);
212                        }
213                        if(!($ReadIndexArticleSQL->rowCount())){
214                                $this->ReadArticleOut = null;
215                                $this->ReadArticleError  = 2; // art nie istnieje
216                                return false;
217                        }
218                        $this->ReadArticleIndexOut = $ReadIndexArticleSQL->fetch(PDO::FETCH_ASSOC);
219                        $this->ReadArticleIndexOut['LocationInSQL'] = $this->ReadArticleIndexOut['AdressInSQL'];
220                        $this->ReadArticleIndexOut['Options'] = unserialize($this->ReadArticleIndexOut['Options']);
221                        list($this->ReadArticleIndexOut['Votes'], $this->ReadArticleIndexOut['AllVotes']) = explode("|", $this->ReadArticleIndexOut['Votes']);
222                        if($this->ReadArticleIndexOut['Accepted'] == "no")
223                                $this->ReadArticleIndexOut['AcceptedMsg'] = $this->GetOnlyContextArticle('/System/NotAccepted/');
224                        if(!empty($this->ReadArticleIndexOut['Bookmarks']))
225                                list($this->ReadArticleIndexOut['Observed'], $this->ReadArticleIndexOut['Bookmark']) = explode('|',$this->ReadArticleIndexOut['Bookmarks']);
226
227                        unset($Select);
228                        unset($ReadIndexArticleRow);
229
230                        $this->DataBase->pquery('UPDATE {ListArticles} SET {ListArticles:Views} = {ListArticles:Views} +1 WHERE {ListArticles:ID} = '.$this->ReadArticleIndexOut['ID']); // Counter
231
232                        if(ifsetor($this->ReadArticleIndexOut['Options']["DisableCache"], false) == true)
233                        $this->Cache->disable(); //disable cache - options article
234
235
236                        if( $this->Cache->exist("Article", ($this->ReadArticleIndexOut['LocationInSQL'].(empty($this->ArticleFooVersion) ? "" : ($this->ArticleFooVersion))))){
237                                $this->ReadArticleOut = $this->Cache->get();
238                        }else{
239   
240                                if(!empty($this->ArticleFooVersion) && is_numeric($this->ArticleFooVersion)){
241                                        $ReadArticleSQL = $this->DataBase->prepare('SELECT SQL_CACHE {Articles:*} FROM {Articles} WHERE {Articles:AdressInSQL} = :AddressInSQL  AND {Articles:Version} <= :ArticleVersion ORDER BY {Articles:Version} DESC LIMIT 1');
242                                        $ReadArticleSQL->execute(array(
243                                                ':AddressInSQL' => ($this->ReadArticleIndexOut['LocationInSQL']),
244                                                ':ArticleVersion' => ($this->ArticleFooVersion)
245                                        ));
246                                }else{
247                                        $ReadArticleSQL = $this->DataBase->prepare('SELECT SQL_CACHE {Articles:*} FROM {Articles} WHERE {Articles:AdressInSQL} = :AddressInSQL AND  {Articles:Version}  = :ActualVersion LIMIT 1');
248                                        $ReadArticleSQL->execute(array(
249                                                ':AddressInSQL' => ($this->ReadArticleIndexOut['LocationInSQL']),
250                                                ':ActualVersion' => ($this->ReadArticleIndexOut['ActualVersion']),
251                                        ));
252                                }
253                                unset($Select);
254
255                                if(!($ReadArticleSQL->rowCount())){
256                                        $this->ReadArticleOut = null;
257                                        $this->ReadArticleError  = 2; // art nie istnieje, ale pozostal tylko wpis w ArticleIndex, ktory zostal usuniety
258                                        return false;
259                                }
260                                $this->ReadArticleOut = $ReadArticleSQL->fetch(PDO::FETCH_ASSOC);
261                                $this->ReadArticleOut['LocationInSQL'] =  $this->ReadArticleOut['AdressInSQL'];
262                                $this->Cache->put("Article", ($this->ReadArticleIndexOut['LocationInSQL'].(empty($this->ArticleFooVersion) ? "" : $this->ArticleFooVersion)), $this->ReadArticleOut);
263                        }
264
265                        if(!is_null($Theread)){
266                                $this->Date[$Theread]['ReadArticleIndexOut'] = $this->ReadArticleIndexOut;
267                                $this->Date[$Theread]['ReadArticleOut'] = $this->ReadArticleOut;
268                                $this->ReadArticleIndexOut = $IAS;
269                                $this->ReadArticleOut = $AAS;
270                        }
271
272                        $this->ReadArticleError  = 0; // ok
273                        return true;
274        }
275	/************************************************************************************************/
276	var $IssetArticleID;
277	function isset_article($Location=null){
278	if(is_numeric($this->IssetArticleID)){
279				$IssetArticleSQL = $this->DataBase->prepare('SELECT SQL_CACHE {ListArticles:ID} FROM{ListArticles} WHERE {ListArticles:ID} = :IDArticle LIMIT 1');
280				$IssetArticleSQL->execute(array(':IDArticle' => ($this->IssetArticleID))); //tu
281				if(!($IssetArticleSQL->rowCount())){
282					return false;
283				}
284				return true;
285			}
286			$IssetArticleSQL = $this->DataBase->prepare('SELECT SQL_CACHE {ListArticles:ID}  FROM {ListArticles} WHERE {ListArticles:URL} = :UrlIdexArticle LIMIT 1');
287			$IssetArticleSQL->execute(array(':UrlIdexArticle' => ($this->AddSlashesStartAndEnd($Location)))); //tu
288			if(!($IssetArticleSQL->rowCount())){
289				return false;
290			}
291			return true;
292	}
293
294	/************************************************************************************************/
295	function isset_user($User){
296			$IssetUserSQL = $this->DataBase->prepare('SELECT SQL_CACHE * FROM {Users} WHERE {Users:User} = :IssetUser LIMIT 1');
297			$IssetUserSQL->execute(array(':IssetUser' => ($User)));
298			if(!($IssetUserSQL->rowCount())){
299				return false;
300			}
301			return true;
302	}
303	/************************************************************************************************/
304	function user_config($User, $Data = null, $extend = true){
305			$IssetUserSQL = $this->DataBase->prepare('SELECT {Users:Config} AS `uconfig` FROM {Users} WHERE {Users:User} = :IssetUser LIMIT 1');
306			$IssetUserSQL->execute(array(':IssetUser' => ($User)));
307			$Result = $IssetUserSQL->fetch();
308			$Result = unserialize($Result['uconfig']);
309			
310					if(!is_null($Data) && is_array($Data)){
311						if($extend)
312						$Result = $this->array_merge_recursive_distinct($Result, $Data);
313							else 
314							$Result = $Data;
315							
316						$IssetUserSQL = $this->DataBase->prepare('UPDATE {Users} SET {Users:Config} = :Data WHERE {Users:User} = :IssetUser LIMIT 1');
317						$IssetUserSQL->execute(array(':IssetUser' => ($User), ":Data"=>serialize($Result)));
318					}
319			return ($Result);
320	}
321	/************************************************************************************************/
322	function CheckAdmin($User= null, $Bit= 1){
323			if(!is_numeric($Bit) or !($Bit)){
324				return false;
325			}
326			$WildCard = str_repeat("_", ($Bit - 1));
327			$WildCard .= "1%";
328			$CheckAdminSql = $this->DataBase->prepare('SELECT * FROM {Users} WHERE {Users:User} = :UserExecute AND {Users:Admin} LIKE "'.$WildCard.'" LIMIT 1');
329			$CheckAdminSql->execute(array(':UserExecute' => ($User)));
330			if(($CheckAdminSql->rowCount())){
331				return true;
332			}else{
333				return false;
334			}
335	}
336	/************************************************************************************************/
337	function ReadUser($User = null){
338			if(!is_null($User)){
339				$this->ReadUser['User'] = $User;
340			}
341			$ReadSQLUser = $this->DataBase->prepare('SELECT {Users:*} FROM {Users} WHERE  {Users:User} = :UserExecute LIMIT 1');
342			$ReadSQLUser->execute(array(':UserExecute' => $this->ReadUser['User']));
343			if(!($ReadSQLUser->rowCount())){
344				return false;
345			}
346			$this->ReadUser = $ReadSQLUser->fetch();
347			$this->ReadUser['Nick'] = $this->ReadUser['User'];
348			$this->ReadUser['GG'] = $this->ReadUser['GaduGadu'];
349			
350			$this->EditUserInit();
351				$this->Date['EditUser']->Date['Log'] = false;
352				$this->Date['EditUser']->Date['OffSecure']=true;
353				$this->Date['EditUser']->Init($this->ReadUser['User']);
354				$this->Date['EditUser']->set("Views", $this->ReadUser['Views']+1);
355			$this->Date['EditUser']->execute();
356			unset($this->Date['EditUser']);
357			
358			return true;
359	}
360	/************************************************************************************************/
361	function SaveComment($Comment=null, $Author = null, $LocationCommentID = null){
362		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'CommentSave.XVWeb.class.php');
363		$CommentSave =  new CommentSave($this);
364		return $CommentSave->SaveComment($Comment, $Author, $LocationCommentID);
365	}
366	/************************************************************************************************/
367	var $CommentRead;
368	function CommentRead($ID=null){
369		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'ReadComment.XVWeb.class.php');
370		$ReadComment =  new ReadComment($this);
371		return $ReadComment->CommentRead($ID);
372	}
373	
374	var $SaveModification = array(
375	"IDComment"=>"",
376	"Comment"=>"",
377	"Error"=>""
378	);
379	/************************************************************************************************/
380	function SaveModificationComment($ID = null, $Comment=null){
381		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'ModComment.XVWeb.class.php');
382		$SaveModComment =  new SaveModComment($this);
383		return $SaveModComment->SaveModificationComment($ID, $Comment);
384	}
385	/************************************************************************************************/
386	public function ReadArticleToDOC($URL= null){
387		if(!is_null($URLS['Site'])){
388			if(!($this->ReadArticle($URL)))
389			return false;
390			
391		}
392		$this->IncludeParseHTML();
393		if(empty($this->HTMLtoDoc)){
394			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'html_to_doc.inc.php');
395			$this->HTMLtoDoc = new HTML_TO_DOC();
396		}
397		if(is_null($this->ReadArticleOut) or is_null($this->ReadArticleIndexOut))
398		return false; else
399		$this->HTMLtoDoc->createDoc($this->ParseArticleContents(), $this->ReadArticleIndexOut['Topic'], true);
400	}
401	/************************************************************************************************/
402	var $Loggin = null;
403	public function Loggin($User= null, $Password= null, $MD5Pass=false , $ValidPass = true){
404			if(!is_null($User)){
405				$this->Loggin['User'] = $User;
406			}
407			if(!is_null($Password)){
408				$this->Loggin['Password'] = $Password;
409			}
410			if(!$this->ReadUser($this->Loggin['User'])){
411				$this->Loggin['Error'] = 1 ; //brak usera
412				return false;
413			}
414			if(!empty($this->ReadUser['OpenID'])) {
415				$this->Loggin['Error'] = 3 ; //open id check it is
416				return false;
417			}
418
419			if($ValidPass){
420				if($MD5Pass==true){
421					if($this->Loggin['Password'] != md5(MD5Key.$this->ReadUser['Password'])){
422						$this->Loggin['Error'] = 2; //zle haslo
423						return false;
424					}
425				}else{
426					if(md5(MD5Key.$this->Loggin['Password']) != $this->ReadUser['Password']){ //tu
427						$this->Loggin['Error'] = 2; //zle haslo
428						return false;
429					}
430				}
431			}
432
433			$this->EditUserInit();
434			$this->Date['EditUser']->Date['Log'] = false;
435			$this->Date['EditUser']->Date['OffSecure']=true;
436			$this->Date['EditUser']->Init($this->ReadUser['User']);
437			$this->Date['EditUser']->set("IP", $_SERVER['REMOTE_ADDR'].", ".gethostbyaddr($_SERVER['REMOTE_ADDR']).", ".$_SERVER['HTTP_USER_AGENT']);
438			$this->Date['EditUser']->set("LastLogin",  date('Y-m-d H:i:s'));
439			$this->Date['EditUser']->set("LoginCount", $this->ReadUser['LoginCount']+1);
440			$this->Date['EditUser']->execute();
441			
442			$this->Session->Session('Logged_Logged', true);
443			$this->Session->Session('Logged_ID', $this->ReadUser['ID']);
444			$this->Session->Session('Logged_User', $this->ReadUser['Nick']);
445			$this->Session->Session('Logged_Password', $this->ReadUser['Password']);
446			$this->Session->Session('Logged_Theme', $this->ReadUser['Theme']);
447			$this->Session->Session('Logged_Avant', $this->ReadUser['Avant']);
448			$this->Session->Session('user_group', $this->ReadUser['Group']);
449			$this->Session->Session('user_permissions', $this->get_group_permissions($this->ReadUser['Group']));
450			$this->Log("LoggedUser", array("User"=>$this->ReadUser['Nick']));
451			return true;
452	}
453	/************************************************************************************************/
454	var $LogginWithOpenIDVar;
455	public function LogginWithOpenID(&$OpenIDGet){
456		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'LoginOpenID.XVWeb.class.php');
457		$OpenIDLogin =  new OpenIDLogin($this);
458		return $OpenIDLogin->LogginWithOpenID($OpenIDGet);
459	}
460	/************************************************************************************************/
461	var $OpenID;
462	public function LoadOpenIDClass(){
463			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'class.openid.php');
464			if(empty($this->OpenID))
465			$this->OpenID   = new SimpleOpenID;
466	}
467	/************************************************************************************************/
468	public function LoadGOpenID(){
469			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'GOpenID.class.php');
470			if(empty($this->Date['GOpenID']))
471			$this->Date['GOpenID']   = new GOpenID;
472	}
473	/************************************************************************************************/
474	public function LogOut(){
475		$this->Session->Clear();
476	}
477	/************************************************************************************************/
478	function ParseArticlecontents($text = null){
479			$MD5Hash = md5(MD5Key.(is_null($text)?$this->ReadArticleOut['ID']:$text)); // zmien na url i id versji
480			if($this->Cache->exist("ArticleParse",$MD5Hash))
481			return (ifsetor($this->ReadArticleIndexOut['Options']['EnablePHP'], 0) ? $this->EvalHTML($this->Cache->get()): $this->Cache->get());
482			$this->IncludeParseHTML();
483			$Result = $this->Cache->put("ArticleParse",$MD5Hash, (is_null($text) ? $this->ParserMyBBcode->set("Options", $this->ReadArticleIndexOut['Options'])->set("Blocked", ($this->ReadArticleIndexOut['Blocked'] == "yes" ? 1 : 0))->SetText($this->ReadArticleOut['Contents'])->Parse()->ToHTML() : $this->ParserMyBBcode->set("Blocked", ($this->ReadArticleIndexOut['Blocked'] == "yes" ? 1 : 0))->SetText($text)->Parse()->ToHTML()));
484
485			return (ifsetor($this->ReadArticleIndexOut['Options']['EnablePHP'], 0) ? $this->EvalHTML($Result) : $Result);
486	}
487	/************************************************************************************************/
488	function CommentArticle($IDArticle = null, $Parse = true){
489			$localID = $this->ReadArticleIndexOut['AdressInSQL'];
490			if(!is_null($IDArticle)){
491				$localID = $IDArticle; //tu
492			}
493			if(empty($localID))
494			return array();
495			
496			if($this->Cache->exist("Comment",$localID)){
497				return $this->Cache->get();
498			}
499			if($Parse){
500				$this->IncludeParseHTML();
501			}
502			
503			$SQLComment = $this->DataBase->prepare('SELECT 
504			{Comments:*:prepend:CT.} ,
505			UT.{Users:Avant} AS `Avant` ,
506			(SELECT COALESCE( SUM({Votes:Vote}), 0) FROM {Votes} WHERE {Votes:Type} = :TypeVote AND {Votes:SID} =  CT.{Comments:ID} ) AS `Votes`
507			FROM 
508				{Comments} AS `CT`,
509				{Users} AS `UT`
510		WHERE   
511			CT.{Comments:IDArticleInSQL} = :URLExecute AND UT.{Users:User} =   CT.{Comments:Author}  ORDER BY {Comments:ID} DESC');
512			$SQLComment->execute(array(':URLExecute' => $localID, ":TypeVote"=>"comment"));
513			$ArrayComment = $SQLComment->fetchAll();
514			return $this->Cache->put("Comment",$localID, $ArrayComment);
515	}
516
517	/************************************************************************************************/
518	function EditTagArticle($ArticleID, $Tags){
519		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'EditTag.XVWeb.class.php');
520		$EditArticle =  new EditArticle($this);
521		return $EditArticle->EditTagArticle($ArticleID, $Tags);
522	}
523	/************************************************************************************************/
524	public function ConfigSystem($id, $Mod = null){
525			if(is_null($Mod)){
526				$ConfigCache = $this->Cache("Config", $id);
527				if(!is_null($ConfigCache))
528				return $ConfigCache;
529				$ConfigSQL = $this->DataBase->prepare('SELECT * FROM `'.($this->DataBasePrefix).($this->DataBaseSystem['DataBaseSystem']).'` WHERE  `'.($this->DataBaseSystem['Name']).'` = :NameExecute LIMIT 1');
530				$ConfigSQL->execute(array(':NameExecute' => $id));
531				while ($SQlRowConfig = $ConfigSQL->fetch()) {
532					$return = $SQlRowConfig;
533				}
534				$TMPRetrun = (isset($return) ? $return[($this->DataBaseSystem['Value'])] : null);
535				$this->Cache("Config",$id, $TMPRetrun, 900);
536				return $TMPRetrun;
537			}else{
538				if(is_null($this->ConfigSystem($id))){
539					$SystemInfoSQL = $this->DataBase->prepare('INSERT INTO `'.($this->DataBasePrefix).($this->DataBaseSystem['DataBaseSystem']).'`  (`'.($this->DataBaseSystem['Name']).'`, `'.($this->DataBaseSystem['Value']).'`) VALUES ( :IDExecute , :ModExecute )');
540					$SystemInfoSQL->execute(
541					array(':IDExecute' => $id ,
542					':ModExecute' => $Mod
543					)
544					);
545					if($SystemInfoSQL){
546						return $Mod;
547					}else{
548						return false;
549					}
550				}else{
551					$SystemInfoSQL = $this->DataBase->prepare('UPDATE `'.($this->DataBasePrefix).($this->DataBaseSystem['DataBaseSystem']).'` SET `'.($this->DataBaseSystem['Value']).'` = :ModExecute WHERE `'.($this->DataBaseSystem['Name']).'` = :IDExecute');
552					$SystemInfoSQL = $SystemInfoSQL->execute(
553					array(':IDExecute' => $id ,
554					':ModExecute' => $Mod
555					)
556					);
557					if($SystemInfoSQL){
558						return $Mod;
559					}else{
560						return false;
561					}
562				}
563			}
564	}
565	/************************************************************************************************/
566	public function DeleteComment($ID){
567			if(!is_numeric($ID)){
568				return false;
569			}
570			$this->CommentRead($ID);
571			if(($this->Admin['DeleteComment'] && $this->CommentRead['Author']==$this->Session->Session('Logged_User')) or $this->Admin['DeleteCommentOther']){
572				$DeleteCommentSQL = $this->DataBase->prepare('DELETE FROM {Comments} WHERE {Comments:ID} = :IDComment LIMIT 1');
573				$DeleteCommentSQL->execute(array(':IDComment' => ($ID)));
574				$this->Cache->clear("Comment", $this->CommentRead['IDArticleInSQL']);
575				$this->Log("DeleteComment", array("CommentID"=> $ID));
576				return true;
577			}else{
578				return false;
579			}
580	}
581	/************************************************************************************************/
582	public function IDtoURL($id){
583			if(is_numeric($id)){
584				if($this->Cache->exist("IDtoURL",($id)))
585				return $this->Cache->get();
586				
587				$IDtoURLSQL = $this->DataBase->prepare('SELECT {ListArticles:URL} AS `URL` FROM {ListArticles} WHERE {ListArticles:ID} = :IDinArticleIndexExecute LIMIT 1');
588				$IDtoURLSQL->execute(array(':IDinArticleIndexExecute' => ($id)));
589				$IDtoURLSQL = $IDtoURLSQL->fetch();
590				return $this->Cache->put("IDtoURL",($id), $IDtoURLSQL['URL']);
591			}
592			return false;
593	}
594	/************************************************************************************************/
595	public function URLtoID($UrlArticle){
596			if(!empty($UrlArticle)){
597				$UrlArticle = $this->AddSlashesStartAndEnd($UrlArticle);
598				if($this->Cache->exist("URLtoID",($UrlArticle))){
599					return $this->Cache->get();
600				}
601				$URLtoIDSQL = $this->DataBase->prepare('SELECT {ListArticles:ID} AS `ID` FROM {ListArticles} WHERE {ListArticles:URL} = :URLinArticleIndexExecute LIMIT 1');
602				$URLtoIDSQL->execute(array(':URLinArticleIndexExecute' => ($UrlArticle)));
603				$URLtoIDSQL = $URLtoIDSQL->fetch();
604				return $this->Cache->put("URLtoID",($UrlArticle), $URLtoIDSQL['ID']);
605			}
606			return false;
607	}
608	/************************************************************************************************/
609	public function DeleteArticle($ID){
610		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'DeleteArticle.XVWeb.class.php');
611		$DeleteArticle =  new DeleteArticleClass($this);
612		return $DeleteArticle->DeleteArticle($ID);
613	}
614	/************************************************************************************************/
615	var $Search;
616	var $SearchResultCount;
617	var $SearchInVersion=false;
618	public function Search($String, $ActualPage = 0, $EveryPage =30){
619		if(empty($this->Date['Search'])){
620			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'SearchClass.XVWeb.class.php');
621			$this->Date['Search'] =  new SearchClass($this);
622		}
623		return $this->Date['Search']->Search($String, $ActualPage, $EveryPage);
624	}
625	/************************************************************************************************/
626	public function Log($type, $data,  $who=null, $ip =null){
627		if(is_null($who)){
628		if (is_object($this->Session)) 
629			$who = $this->Session->Session('Logged_User');
630		}else{
631			$who = "Error";
632		}
633		if(empty($who))
634		$who = null;
635		if(is_null($ip))
636		$ip = $this->IP;
637		try {
638		
639			if(get_class($this->DataBase) == "xvDB"){
640			$LogSQL = $this->DataBase->prepare('INSERT INTO {Logs}  ( {Logs:Date} , {Logs:Type} , {Logs:User} , {Logs:Text} , {Logs:IP} ) VALUES ( NOW() , :TypeExecute , :UserExecute , :TextExecute , :IPExecute ) ;');
641			$LogSQL->PDOException();
642			$LogSQL->execute(
643			array(
644			':TypeExecute' => $type,
645			':UserExecute' => $who,
646			':TextExecute' => serialize($data),
647			':IPExecute'   => $ip
648			)
649			);
650			}
651		} catch (Exception $e) {
652			$this->ErrorClass($e);
653			$this->XVwebError[] = $e->getMessage();
654			return false;
655		}
656		return true;
657	}
658	/************************************************************************************************/
659	public function ErrorClass($Exception){
660		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'PDOError.XVWeb.class.php');
661		$PDOError = new PDOError($Exception);
662		$this->Log("Exception", $Exception);
663		ob_start();
664		($PDOError->show($this));
665	}
666	/************************************************************************************************/
667	function GetOnlyContextArticle($URL){
668		$URL = $this->AddSlashesStartAndEnd($URL);
669		$GetOnlyContex = $this->DataBase->prepare('SELECT {Articles:Contents} AS `Contents`  FROM  {ListArticles} ArticleIndex RIGHT JOIN {Articles} Article ON ArticleIndex.{ListArticles:AdressInSQL}=Article.{Articles:AdressInSQL} WHERE ArticleIndex.{ListArticles:URL} = :URLExecute ORDER BY Article.{Articles:Version} DESC LIMIT 1;');
670		$GetOnlyContex->execute(
671		array(
672		':URLExecute' => $URL 
673		)
674		);
675		$ContextFinall = $GetOnlyContex->fetch();
676		if(empty($ContextFinall))
677		$ContextFinall = ""; else
678		$ContextFinall = $ContextFinall['Contents'];
679		
680		return $ContextFinall;
681	}
682	/************************************************************************************************/
683	function GetHisotryAricle($ID){
684		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'HistoryArticle.XVWeb.class.php');
685		$HistoryArticle =  new HistoryArticle($this);
686		return $HistoryArticle->GetHisotryAricle($ID);
687	}
688	/************************************************************************************************/
689	public function UserList($Date = array()){
690		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'UserList.XVWeb.class.php');
691		$UserList =  new UserListClass($this);
692		return $UserList->UserList($Date);
693	}
694	/************************************************************************************************/
695	public function OnlineList(){
696		include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'OnlineList.XVWeb.class.php');
697		return  new OnlineListClass($this);
698	}
699	/************************************************************************************************/
700	public function PluginInt($Date = array(), $PHPLocation, $ClassName){
701		include_once($PHPLocation);
702		return  new $ClassName($this);
703	}
704	/************************************************************************************************/
705	public function &Users(){
706		if(empty($this->Date['UserClass'])){
707			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'User.XVWeb.class.php');
708			$this->Date['UserClass'] = new UsersClass($this);
709		}
710		return $this->Date['UserClass'];
711	}
712	/************************************************************************************************/
713	public function &MailClass(){
714		if(empty($this->Date['MailClass'])){
715			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'mail.XVWeb.class.php');
716			$this->Date['MailClass'] = new MailClass();
717		}
718		return $this->Date['MailClass'];
719	}
720	/************************************************************************************************/
721	public function &DeleteUser(){
722		if(empty($this->Date['DeleteUser'])){
723			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'DeleteUser.XVWeb.class.php');
724			$this->Date['DeleteUser'] = new DeletUserClass($this);
725		}
726		return$this->Date['DeleteUser'];
727	}
728	/************************************************************************************************/
729	public function OnlineInit($UrlLocation){
730		if(empty($this->Date['Online'])){
731			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'Online.XVWeb.class.php');
732			$this->Date['Online'] = new OnlineClass($this, $UrlLocation);
733		}
734	}
735	/************************************************************************************************/
736	public function &EditUserInit(){
737		if(empty($this->Date['EditUser'])){
738			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'EditUser.XVWeb.class.php');
739			$this->Date['EditUser'] = new EditUserClass($this);
740		}
741		return $this->Date['EditUser'];
742	}
743	/************************************************************************************************/
744	public function &DelArtVer(){
745		if(empty($this->Date['DeleteArtVer'])){
746			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'DeleteVersionArticle.XVWeb.class.php');
747			$this->Date['DeleteArtVer'] = new DeleteVersionArticleClass($this);
748		}
749		return $this->Date['DeleteArtVer'];
750	}
751	/************************************************************************************************/
752	public function &FilesClass(){
753		if(empty($this->Date['FilesClass'])){
754			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'Files.XVWeb.class.php');
755			$this->Date['FilesClass'] = new FilesClass($this);
756		}
757		return $this->Date['FilesClass'];
758	}
759	/************************************************************************************************/
760	public function &DiffClass(){
761		if(empty($this->Date['DiffClass'])){
762			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'DiffArticle.XVWeb.class.php');
763			$this->Date['DiffClass'] = new DiffArticleClass($this);
764		}
765		return $this->Date['DiffClass'];
766	}
767	/************************************************************************************************/
768	public function &Votes(){
769		if(empty($this->Date['VotesClass'])){
770			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'Votes.XVWeb.class.php');
771			$this->Date['Votes'] = new VotesClass($this);
772		}
773		return $this->Date['Votes'];
774	}
775	/************************************************************************************************/
776	public function &XMLParser(){
777		if(empty($this->Date['XMLParser'])){
778			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'XmlParser.XVWeb.class.php');
779			$this->Date['XMLParser'] = new XMLParser($this);
780		}
781		return $this->Date['XMLParser'];
782	}
783	/************************************************************************************************/
784	public function &Config($var){
785		if(empty($this->Date['Config'][$var])){
786		$File = $this->Date['ConfigDir'].$var.'.xml';
787			if (!file_exists($File)){
788					$BackTrack = debug_backtrace();
789					$BackTrack = ($BackTrack[0]);
790					$ErrorInfo[] = array("Message"=>"ErrorMessage", "value"=> "Warning: XVweb::Config(".$var.") [function.Config]: failed to open stream: No such file or directory in ".realpath($File)." on line ".$BackTrack['line']. " in file ".$BackTrack['file']);
791					$ErrorInfo[] = array("Message"=>"ErrorCode", "value"=> "404");
792					$ErrorInfo[] = array("Message"=>"ErrorFile", "value"=> $BackTrack['file']);
793					$ErrorInfo[] = array("Message"=>"ErrorLine", "value"=> $BackTrack['line']);
794					$ErrorInfo[] = array("Message"=>"ErrorTime", "value"=> date("y.m.Y H:i:s:u"));
795					$ErrorInfo[] = array("Message"=>"ClientIP", "value"=> $_SERVER['REMOTE_ADDR']);
796					$ErrorInfo[] = array("Message"=>"ErrorFile", "value"=> $BackTrack['file']);
797					$this->ErrorClass($ErrorInfo);
798				return false;
799				}
800			$this->Date['Config'][$var] = phpQuery::newDocumentFile($File);
801		}
802		return $this->Date['Config'][$var];
803	}
804	/************************************************************************************************/
805	public function &XML($File){
806		if(empty($this->Date['XML'][$File])){
807			$this->Date['XML'][$File] = new DOMDocument('1.0', 'UTF-8');
808			//$this->Date['XML'][$File]->encoding= "utf-8";
809			$this->Date['XML'][$File]->load($File);
810		}
811		return $this->Date['XML'][$File];
812	}
813	/************************************************************************************************/
814	public function &Plugins(){
815		if(empty($this->Date['PluginsClass'])){
816			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'Plugins.XVWeb.class.php');
817			$this->Date['PluginsClass'] = new Plugins($this);
818		}
819		return $this->Date['PluginsClass'];
820	}
821	/************************************************************************************************/
822	public function &LostPassword(){
823		if(empty($this->Date['LostPassword'])){
824			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'LostPassword.XVWeb.class.php');
825			$this->Date['LostPassword'] = new LostPassword($this);
826		}
827		return $this->Date['LostPassword'];
828	}
829	/************************************************************************************************/
830	public function &InitClass($ClassName){
831		if(empty($this->Date['Classes'][$ClassName])){
832			$this->Date['Classes'][$ClassName] = new $ClassName($this);
833		}
834		return $this->Date['Classes'][$ClassName];
835	}
836	/************************************************************************************************/
837	public function &EditArticle(){
838		if(empty($this->Date['EditArticle'])){
839			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'Article.XVWeb.class.php');
840			$this->Date['EditArticle'] =  new XVArticle($this);
841		}
842		return $this->Date['EditArticle'];
843	}
844	/************************************************************************************************/
845	public function &Messages(){
846		if(empty($this->Date['Messages'])){
847			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'Messages.XVWeb.class.php');
848			$this->Date['Messages'] =  new Messages($this);
849		}
850		return $this->Date['Messages'];
851	}
852	/************************************************************************************************/
853	public function SendMail($mail, $url, $vars){
854		if(!($this->ReadArticle($url))){
855			$BackTrack = debug_backtrace();
856			$BackTrack = ($BackTrack[0]);
857					$ErrorInfo[] = array("Message"=>"ErrorMessage", "value"=> "The system article doesn't exist : ".$url);
858					$ErrorInfo[] = array("Message"=>"ErrorCode", "value"=> "5");
859					$ErrorInfo[] = array("Message"=>"ErrorFile", "value"=> $BackTrack['file']);
860					$ErrorInfo[] = array("Message"=>"ErrorLine", "value"=> $BackTrack['line']);
861					$ErrorInfo[] = array("Message"=>"ErrorTime", "value"=> date("y.m.Y H:i:s:u"));
862					$ErrorInfo[] = array("Message"=>"ClientIP", "value"=> $_SERVER['REMOTE_ADDR']);
863					$ErrorInfo[] = array("Message"=>"ErrorFile", "value"=> $BackTrack['file']);
864			$this->ErrorClass($ErrorInfo);
865				return false;
866		}
867		
868					$vars["{{sitename}}"] = $this->SrvName;
869					$vars["{{domain}}"] = $this->SrvDomain;
870		foreach($this->Date['URLS'] as $key=>$val)
871			$vars["{{urls.".$key."}}"] = $val;
872			
873		foreach($vars as $key=>$val){
874			$vars[str_replace(array("{", "}"), array("%7B", "%7D"), $key)] = $val;
875		}
876		//var_dump($vars);
877		$MailContent = $this->ParseArticleContents();
878		$MailContent = $this->stritr($MailContent, $vars);
879		$MailTopic = $this->stritr($this->ReadArticleOut['Topic'], $vars);
880		return $this->MailClass()->mail($mail, $MailTopic, $MailContent);
881		
882	}
883	/************************************************************************************************/
884	public function &module($class, $file){
885		if(empty($this->Date['Classes'][$class])){
886			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.$file.'.XVWeb.class.php');
887			$this->Date['Classes'][$class] = new $class($this);
888		}
889		return $this->Date['Classes'][$class];
890	}
891	/************************************************************************************************/
892	public function message($ErrorPage){
893			ob_clean();
894			extract($GLOBALS);
895			$ErrorPage['URLS'] = $this->Date['URLS'];
896			include_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'libraries'.DIRECTORY_SEPARATOR.'errorpage'.DIRECTORY_SEPARATOR.'index.php');
897			exit;
898	}
899	/************************************************************************************************/
900	public function get_group_permissions($group){
901			$permissions = array();
902			$permissions_sql = $this->DataBase->prepare('SELECT {Groups:Permission} AS `Permission`  FROM  {Groups} WHERE {Groups:Name} = :name ;');
903			$permissions_sql->execute(array(
904				":name" => $group
905			));
906			$permissions_sql = $permissions_sql->fetchAll(PDO::FETCH_ASSOC);
907			
908			foreach($permissions_sql as $permission)
909				$permissions[] = $permission['Permission'];
910				
911		return $permissions;
912	}
913	/************************************************************************************************/
914	public function permissions(){
915		 $perms = &$this->Session->Session('user_permissions');
916		 if(!is_array($perms))
917			return false;
918			
919		 foreach(func_get_args() as $a){
920			if(!in_array($a, $perms))
921				return false;
922		 }
923	return true;
924	}
925	/************************************************************************************************/
926	
927	
928	
929	function __destruct() {
930	}
931	/************************************************************************************************/
932	
933}
934?>