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