HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/api/class.base.php
<?php
/**
 * This file contains the iwp_base class, the one from which all other classes are extended from.
 *
 * @version $Id$
 * 
 *
 * @package IWP
 * @subpackage IWP_API
 */

/**
 * IWP Base Class
 * This is the base class that has the __get() overloading function to have the same functionality available in all classes.
 * This is used so any class can use: $this->db, $this->template, $this->xml etc. and they will automatically grab the current instance (or create) of the class
 *
 * @package IWP
 * @subpackage IWP_API
 * @property iwp_mysql $db
 * @property iwp_urls $urls
 * @property iwp_xmlwriter $xml
 * @property iwp_template $template
 * @property iwp_controller $controller
 * @property iwp_modules $modules
 * @property iwp_session $session
 * @property iwp_validation $valid
 * @property iwp_output $output
 * @property iwp_language $lang
 * @property iwp_cache $cache
 * @property iwp_admin_auth $auth
 */
class iwp_base {
	/**
	 * Instance
	 * This static variable holds the current instance of this object being loaded.
	 * So using the getInstance function anywhere will return the very same instance.
	 *
	 * @var object Instance
	 */
	public static $Instance;

	/**
	 * getInstance
	 * This is a static function that sets up the class instance and stores it to the static variable. It will then return that instantiation in the future.
	 *
	 * @return object Returns the instantiated object
	 **/
	public static function getInstance(){
		if(!isset(self::$Instance)){
			self::$Instance = new self();
		}
		return self::$Instance;
	}

	/**
	 * __get
	 * This is the universal getting that captures and requests for class variables that don't exist.
	 * It is used to instantiate various objects on request, such as the database class and the validation class.
	 *
	 * @param $var string The name of the variable that is trying to be
	 *
	 * @return void
	 **/
	public function __get($var){
		// database class
		if($var == 'db'){
			$this->db = new iwp_mysql();
			$this->db->Connect(iwp_config::Get("dbServer"), iwp_config::Get("dbUser"), iwp_config::Get("dbPass"), iwp_config::Get("dbDatabase"));
			if(IWP::$DebugMySQLMode){
				$this->db->QueryLogByDateDir = IWP_BASE_PATH.'/tmp';
			}

			iwp_mysql::$Instance = &$this->db;

			return $this->db;
		}

		// urls class
		if($var == 'urls'){
			$this->urls = iwp_urls::getInstance();
			return $this->urls;
		}

		// xml class
		if($var == 'xml'){
			$this->xml = new iwp_xmlwriter();
			return $this->xml;
		}

		// template class
		if($var == 'template'){
			$this->template = iwp_template::getInstance();
			$this->template->SetIncludePath(IWP_BASE_PATH);
			$this->template->SetCachePath(IWP_CACHE_TEMPLATE_PATH);

			if(defined('IN_CONTROL_PANEL') && IN_CONTROL_PANEL){
				$this->template->SetTemplatePathForBackEnd();
			}else{
				$this->template->SetTemplatePathForFrontEnd();
			}

			$this->template->Assign('now', time());
			return $this->template;
		}

		// controller class
		if($var == 'controller'){
			$this->controller = iwp_controller::getInstance();
			return $this->controller;
		}

		// modules class
		if($var == 'modules'){
			$this->modules = iwp_modules::getInstance();
			return $this->modules;
		}

		// session class
		if($var == 'session'){
			$this->session = iwp_session::getInstance();
			return $this->session;
		}

		// validation class
		if($var == 'valid'){
			$this->valid = new iwp_validation();
			return $this->valid;
		}

		// output class
		if($var == 'output'){
			$this->output =  iwp_output::getInstance();
			return $this->output;
		}

		// lang class
		if($var == 'lang'){
			$this->lang = iwp_language::getInstance();
			return $this->lang;
		}

		// cache class
		if($var == 'cache'){
			$this->cache = iwp_cache::getInstance();
			return $this->cache;
		}

		// auth class
		if($var == 'auth'){
			if(defined('IN_CONTROL_PANEL') && IN_CONTROL_PANEL){
				$this->auth = iwp_admin_auth::getInstance();
				return $this->auth;
			}else{
				$this->auth = iwp_auth::getInstance();
				return $this->auth;
			}
		}

		return false;
	}

	/**
	 * A function for error messages, making the process a bit easier. Its almost an alias function
	 *
	 * @param string $msg The error message to be displayed on the page
	 *
	 * @return void
	 *
	 * @see Message()
	 */
	public function ErrorMessage($msg) {
		$this->Message($msg, 'error');
	}

	/**
	 * This function sets up the template variables for displaying an error or success message on a page.
	 *
	 * @param string $msg The message to be displayed
	 * @param string $type The message type, success or error
	 *
	 * @return void
	 */
	public function Message($msg, $type=null) {
		if($type === null){
			$type = 'success';
		}
		$this->template->Assign('MessageText', $msg);
		$this->template->Assign('MessageType', $type);
	}

	public function GetActivityLogSubjectURL ($subjectId, $subjectText) {
		return '';
	}

	public function GetActivityLogUserURL ($userId, $userText) {
		if (is_numeric($userId) && $userText) {
			return 'index.php?section=user&action=edit&userid='. $userId;
		}

		return '';
	}
}