Pages: Previous12
Current Page: 2 of 2
Re: Cannot access website folder
Posted by: RiggsFolly (Moderator)
Date: February 03, 2020 10:29AM

If your site lives in C:\wampJHMJKB\Web_Application then that is where the Virtual Host should point to

Like this

<VirtualHost *:80>
ServerName wampjhmjkb
DocumentRoot "c:/wampjhmjkb/Web_Application "
    <Directory "c:/wampjhmjkb/Web_Application /">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.2.0 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.19>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 05, 2020 03:35AM

Dear Otomatic (Moderator) / RiggsFolly (Moderator) / Experts,

Could you still advise solution for our above problem ?

Below is an Installation Guide of handover info. provided by our previous hosting vendor for your ref. -

1. Upload all files from directory "Web Application" to your web server root directory

2. Change the permission of folder "upload" & "cache" in "Web Application" to 777

3. Import the database file "jhmjkbrothers_****.sql" in directory "Database" to your web database

4. Adjust the config file setting in directory "Web Application" > "config" > db.conf.php

****** Select One Option From Below ******

4.1 Standard Setting (Less Security)
4.1.1 Create a database user and fill in the information to the config file accordingly
4.1.2 Since we have created one single user only, please fill the username and password for 'user' & 'cms_user', '********' & '***_********'

4.2 Advance Setting (Higher Security)
4.2.1 Create 2 database users, first user with SELECT & UPDATE permission only, the second user with FULL permission which is used in backend system for admin to manage the website content
4.2.2 Fill the 2 database user login information to the config file accordingly
4.2.2.1 'user', '********' = The first user with SELECT & UPDATE permission only
4.2.2.2 'cms_user', '***_********' = The second user with FULL permission

***********************************

5. Advance setting in directory "Web Application" > "config" > sys.conf.php

I had completed all of the above steps before, except the step 2 which should be irrelevant to WAMP server. However, the above problem still cannot be solved. Could you also advise ?


Many Thanks,
KH Fong

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 05, 2020 05:02AM

RiggsFolly (Moderator),

Even if changing the new Vitual Host as your above suggested -

<VirtualHost *:80>
ServerName wampjhmjkb
DocumentRoot "c:/wampjhmjkb/Web_Application "
<Directory "c:/wampjhmjkb/Web_Application /">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

or

<VirtualHost *:80>
ServerName wampjhmjkb
DocumentRoot "c:/wampjhmjkb/Web_Application"
<Directory "c:/wampjhmjkb/Web_Application/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

Link -
[wampjhmjkb]

Problem still cannot be solved with error as below -

Not Found
The requested URL /web_application/ was not found on this server.

Apache/2.4.39 (Win64) PHP/7.2.18 Server at wampjhmjkb Port 80

Could you also advise ?


Many Thanks,
KH Fong

Options: ReplyQuote
Re: Cannot access website folder
Posted by: RiggsFolly (Moderator)
Date: February 05, 2020 11:51AM

1. Upload all files from directory "Web Application" to your web server root directory


This says place the files FROM the "Web Application" folder into the DocumentRoot folder, so

a) Create a directory, for example

>C:                   <-- could be any drive 
>CD \               <-- cd to the root of the drive
>MD websrc      <-- make a new folder to contain all your site
>CD websrc
>MD jhmjkb
>CD jhmjkb
>MD www

You should now have a folder to hold your site c:\websrc\jhmjkb\www

Copy the contents of "Web Application" and all its SubFolders into c:\websrc\jhmjkb\www

<VirtualHost *:80>
    ServerName jhmjkb
    DocumentRoot "c:/websrc/jhmjkb/www"
    <Directory "c:/websrc/jhmjkb/www/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>


2. Change the permission of folder "upload" & "cache" in "Web Application" to 777
Not possible on a Windows PC, ignore this instruction


Go to the HOSTS file C:\windows\system32\drivers\etc\hosts

Edit it and add

127.0.0.1 jhmjkb
::1 jhmjkb

REBOOT, or refresh windows DNS Cache using

To reset the DNS resolver cache, perform the following steps:

- Select the “Start” button, then type “cmd“.
- Right-click “Command Prompt“, then choose “Run as Administrator“.
- Type ipconfig /flushdns
- - then press “Enter“. (be sure there is a space before the slash)

Test this by doing, from the command prompt
>ping -n 1 jhmjkb

Example success
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss)
If that successfully pings your domain name move on


RESTART WAMPServer, or Start it if it is not already running

in your browser enter the correct domain name to get to your site which will be what is in the Virtual Hosts ServerName, so jhmjkb


http: //jhmjkb
without the space between http: and //


I have not touched onto the correct setting up of the config file or the restore of the database, I assume you can cope with that yourself

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.2.0 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.19>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 06, 2020 05:16AM

Dear RiggsFolly (Moderator),

Thanks for your info. Had followed your above info. to setup the Server Name & Document Root with Directory as below -

<VirtualHost *:80>
ServerName jhmjkb
DocumentRoot "c:/wampHosts/jhmjkb/www"
<Directory "c:/wampHosts/jhmjkb/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

However, still cannot access the domain website -
[jhmjkb]

Similar error as below -
Not Found
The requested URL /en/ was not found on this server.

Apache/2.4.39 (Win64) PHP/7.2.18 Server at jhmjkb Port 80

The "/en/" was still automatically defaulted while there is no such sub-folder under the Root Directory.

Could you also advise ?

BTW, why the domain link is [jhmjkb] instead of [jhmjkb] ?


Many Thanks,
KH Fong

Options: ReplyQuote
Re: Cannot access website folder
Posted by: RiggsFolly (Moderator)
Date: February 06, 2020 10:20AM

That sounds like a website issue, have you checked what is in the .htaccess file

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.2.0 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.19>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 06, 2020 11:28AM

Dear RiggsFolly (Moderator),


There is no the *.htaccess or *htaccess* file under our above Root Directory. Could you advise how to solve it ?


Many Thanks,
KH Fong

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 07, 2020 03:59AM

Dear RiggsFolly (Moderator),

The Virtual Host had been changed by removing the "www", as below -

<VirtualHost *:80>
ServerName jhmjkb
DocumentRoot "c:/wampHosts/jhmjkb"
<Directory "c:/wampHosts/jhmjkb/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

Link is the same -
[jhmjkb]

However, problem still could not be solved with same error as below -
Not Found
The requested URL /en/ was not found on this server.

Apache/2.4.39 (Win64) PHP/7.2.18 Server at jhmjkb Port 80

The "/en/" was still automatically defaulted while there is no such sub-folder under the above Root Directory - "jhmjkb".

When inputting the "[jhmjkb]; in browser, it is automatically changed to "[jhmjkb];.

Same as the original hosted website (which hosting will be ended by vendor shortly) -
[www.jhm-jkbrothers.com]

When inputting the above website in browser, it is also automatically changed to "[www.jhm-jkbrothers.com];.

Does it mean that some sub-folder(s) like "/en/" with files are missing in the above Root Directory - "jhmjkb", or else ?


Many Thanks,
KH Fong

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 10, 2020 03:36AM

Dear RiggsFolly (Moderator) / Experts,

Could you help to advise for our above problem ?

Below is the content of "index.php" under the above Root Directory - "jhmjkb" -
 <?php 
 include('core/framework.php');
 $framework = new framework();
 $framework->call('common', 'func');
 $framework->init();
 ?>
Below is the content of "framework.php" under the above Directory - "jhmjkb/core" (originally posted on January 21, 2020 04:54AM but removed by Otomatic (Moderator)) –
<?php

/**
 * 	Framework
 * 	This php included all core functions to be used
 *
 * 	Copyright Annoucement
 * 	@
 * 	@
 * 	@
 * 	@
 * 	@
 *
 * 	Function List
 * 	==========================================================================================
 * 	-	System Function
 * 	@function		lib($class, $object)							Function to load library
 * 	@function		func($function)									Function to load function
 * 	@function		call($name, $type)								Function to load apps's php ('func' or 'class' or 'other')
 * 	@function		load($page, $func)								Function to load page (default load '$page->main()')
 * 	@function		init($defaultPage, $defaultFunc)				Function to initial the core (default load 'index->main()')
 * 	@function		url($fullPath)									Function to get current url path (default 'false')
 * 	@function		path()											Function to get core path
 * 	@function		now($format)									Function to get current time (default 'Y-m-d H:i:s')
 * 	@function		isCMS()											Function to check current path whether is cms or not
 * 	@function		render($bag, $view, $template_bag, $template)	Function to render view (default 'html')
 * 	@function		cacheLog($cache_path)							Function to add log and clear expired cache file
 */

class framework {

	private $_time = false;

	public function __construct($runtime = false) {
		if(!session_id()){
			session_start();
		}
		require_once(self::path().'/core/function/common.func.php');
		if(self::lib('config', 'sys')->get('debug') == true) {
			error_reporting(E_ERROR | E_WARNING | E_PARSE);
		}else{
			error_reporting(0);
		}
		$protocol = toLower(self::lib('config', 'sys')->get('forceProtocol'));
		if($protocol && getip()) {
			$is_https = isset($_SERVER['HTTPS']) && toLower($_SERVER['HTTPS']) != 'off';
			if(($is_https && $protocol == 'http') ||
			   (! $is_https && $protocol == 'https'))
			{
				redirect($protocol . '://' . $_SERVER['HTTP_HOST'] . geturl(true, true, true));
			}
		}
		$tmp = get_global('_page');
		set_global('_page', $tmp ? $tmp : 'index');
		$customize_link = self::lib('config', 'sys')->get('customizeLink');
		if(! self::isCMS() && 
		   ($customize_link === true || (is_array($customize_link) && in_array(get_global('_page'), $customize_link))))
		{
			set_global('_func', 'main');
		}
		else
		{		
			$tmp = get_global('_func');
			set_global('_func', $tmp ? $tmp : 'main');
		}
		if($runtime){
			self::runtime();
		}
	}
	
	public function __destruct() {
		if($this->_time){
			$time = microtime();
			$time = explode(' ', $time);
			$time = $time[1] + $time[0];
			$endtime = $time;
			$totaltime = ($endtime - $this->_time);
			echo '<br />This page loaded in '.$totaltime.' seconds.';
		}
	}
		
	/**
     * 	Function to load library
	 * 	@param	string	$class		Class name to load.
	 * 	@param	array	$arr		Extra param pass to the library.
     * 	@return	object				Class object
     */
	public static function lib($class, $arr = array()) {
		$class = toLower($class);
		if(!class_exists($class)) {
			$path = self::path() . "/core/class/{$class}.class.php";
			if(file_exists($path)){
				require_once($path);
			}
		}
		if(class_exists($class)) {
			if(!is_array($arr)){
				$arr = array($arr);
			}
			$class = new ReflectionClass($class);
			return $class->newInstanceArgs($arr);
		}else{
			return false;
		}
	}

	/**
     * 	Function to load core function
	 * 	@param	string	$func		Function name to load.
	 * 	@return	object				self
     */
	public static function func($function) {
		$function = toLower($function);
		$path = self::path() . "/core/function/{$function}.func.php";
		if(file_exists($path)){
			require_once($path);
		}
		return new framework();	
	}
	
	/**
     * 	Function to load apps's php
	 * 	@param	string $name, array $name	PHP name to load.
	 * 	@param	string	$type				PHP type to load.
	 * 	@return	object						self
     */
	public static function call($name, $type = '') {
		if(is_array($name)){
			foreach($name as $value){
				self::call($value, $type);
			}
		}else{
			switch($type){
				case 'func':
					$folders = array('function');
					break;
				case 'class':
					$folders = array('class');
					break;
				case 'other':
					$folders = array('3rdparty');
					break;
				default:
					$folders = array('function', 'class', '3rdparty');
			}
			$base_path = self::path() . (self::isCMS() ? '/cms' : '');
			foreach($folders as $folder){
				$path = "{$base_path}/apps/{$folder}/{$name}.php";
				if(file_exists($path)){
					require_once($path);
					break;
				}
			}
		}
		return new framework();	
	}
	
	/**
     * 	Function to load page
	 * 	@param	string	$page		Page name to load.
	 * 	@param	string	$func		Function to call.
	 * 	@param	array	$para		Parameter to pass to the function.
     * 	@return	object				self
     */
	public static function load($page, $func, $para = array()) {
		if($page != 'html')
		{
			$cache_folder = false;
			if(! self::isCMS() && ! do_post() && ! do_file())
			{				
				$cache = self::lib('config', 'cache')->get();	
				if($cache['view']['enable'] && ! in_array($page, $cache['view']['no_cache']))
				{
					$cache_folder = self::path() . '/' . $cache['path'];
					if(! is_dir($cache_folder))
					{
		                mkdir($cache_folder, 0777);
		            }
					$cache_folder .= '/view';
		            if(! is_dir($cache_folder))
					{
		                mkdir($cache_folder, 0777);
		            }
		            self::cacheLog($cache_folder);
		            $cache_name = geturl(true, true, true);
		            if($cache['view']['session'])
		            {
		            	$cache_name .= json_encode($_SESSION);
		            }
		            $cache_folder .= '/' . md5($cache_name);
		            if(file_exists($cache_folder) && (! $cache['view']['lifetime'] || (time() - filemtime($cache_folder)) < $cache['view']['lifetime']))
		            {
		            	read_file($cache_folder);
		            	return new framework();	
		            }
				}
			}
			$path = self::path() . (self::isCMS() ? '/cms' : '') . "/apps/controller/{$page}.php";
			if(file_exists($path)) {
				require_once($path);
			}
			if(class_exists('_' . $page))
			{
				$page = '_' . $page;
				$pageClass = new $page();
			}
			elseif(class_exists($page))
			{
				$pageClass = new $page();
			}
			if($pageClass)
			{
				$hv_func = true;
				if(method_exists($pageClass, '_' . $func))
				{
					$func = '_' . $func;
				}
				elseif(! method_exists($pageClass, $func))
				{
					$hv_func = false;
				}
				if($hv_func)
				{
					$tmp = new ReflectionMethod($pageClass, $func);
					if($tmp->isPublic())
					{
						$para = xssfilter($para);
						ob_start();
						call_user_func_array(array($pageClass, $func), $para);
						$html = ob_get_clean();
						echo $html;
						del_session('_redirect');
						if($cache_folder)
						{
							file_put_contents($cache_folder, $html);
						}
						return new framework();	
					}		
				}
			}	
		}
		self::redirect(geturl());
	}
	
    /**
     * 	Function to initial the core
	 * 	@param	string $defaultPage					Default home page to load
	 * 	@param	string $defaultFunc					Default home page function to call
     */
    public function init($defaultPage = '', $defaultFunc = '') {
		if($defaultPage){
			set_global('_page', $defaultPage);
		}
		if($defaultFunc){
			set_global('_func', $defaultFunc);
		}
		$url = self::url(true);
		if(! xssfilter($url))
		{
			self::redirect(geturl());
		}
		$para = explode('/', $url);
		if($path = get_global('_path'))
		{
			if($path == 'img/')
			{
				include(self::path() . '/img.php');
				exit;
			}
			else
			{
				if(strpos($path, 'upload/') === false)
				{
					$ext = toLower(pathinfo($path, PATHINFO_EXTENSION));
					$dangerous_ext = array('htaccess', 'php', 'asp', 'aspx');
					if(! in_array($ext, $dangerous_ext))
					{
						if(is_file($path) && file_exists($path))
						{							
							$name = basename($path);
							if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0'))
							{
								$name = mb_convert_encoding($name, 'big5', 'auto');
							}
							header('Content-Description: File Transfer');
							header('Content-Type: ' . file_type($path));
							header('Content-Disposition: inline; filename="' . $name . '"');
							header('Content-Transfer-Encoding: binary');
							header('Cache-Control: private, max-age=604800');
							header('Pragma: public');
							header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT');
							header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT');
							flush();
							read_file($path);
							exit;
						}
						elseif(strpos($path, 'css/') !== false)
						{
							$path = preg_replace('/^css\/([a-zA-Z0-9\/]+)(\.css)?$/i', '$1', $path);
							include(self::path() . '/css.php');
							exit;
						}
						elseif($path == 'js/lang.js')
						{
							header('content-type: text/javascript');
							header('Cache-Control: private, max-age=604800');
							header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT');
							include('lang.php');
							exit;
						}
					}
					header('HTTP/1.0 404 Not Found');
				}
				else
				{
					$file = $path;
					include(self::path() . '/file.php');
				}
				exit;
			}
		}
		$customize_link = self::lib('config', 'sys')->get('customizeLink');
		if(! self::isCMS() && $customize_link)
		{
			$full_customize_link = self::lib('config', 'sys')->get('fullCustomizeLink');
			if($full_customize_link)
			{
				$pageName = get_global('_page');
			}
			else
			{
				$pageName = array_shift($para);
			}
			if($full_customize_link || ! is_array($customize_link) || (is_array($customize_link) && 
																	   in_array($pageName, $customize_link)))
			{
				$funcName = 'main';
			}
			else
			{
				$funcName = array_shift($para);
			}
		}
		else
		{
			$pageName = array_shift($para);
			$funcName = array_shift($para);
		}
		$_config = self::lib('config', 'sys');
		header('Content-Type: text/html; charset=utf-8');
		header('X-XSS-Protection: 1; mode=block');
		if($_config->get('iframe'))
		{
			header('P3P: CP="CAO PSA OUR"');
		}
		else
		{
			header('X-Content-Type-Options: nosniff');
			header('X-Frame-Options: SAMEORIGIN');
		}
		if(! $_config->get('jsAccessCookie'))
		{
			@ini_set('session.cookie_httponly', true);
			@ini_set('session.cookie_secure', true);
		}
		$title = $_config->get('title');
		$meta = $_config->get('meta');
		$database = $_config->get('database');
		if($_config->get('lang')){
			$lang = self::lib('language')->get();
			if(is_array($title)){
				$title = $title[$lang];
			}
			if(isset($meta[$lang])){
				$meta = $meta[$lang];
			}	
		}	
		if($database && ! self::isCMS())
		{
			$_setting = self::lib('setting');
			$language = self::lib('language')->getLang();
			foreach($language as $key => $value)
			{
				if($value['code'] == $lang)
				{
					$lang = $key;
					break;
				}
			}
			$meta['keywords'] = $_setting->get('keywords_' . $lang);
			$meta['description'] = $_setting->get('description_' . $lang);
		}
		if($meta){
			foreach($meta as $key => $value){
				if(!self::lib('meta')->get($key)){
					self::lib('meta')->set($key, $value);
				}
			}
		}
		self::lib('title')->set($title);
		self::load($pageName, $funcName, $para);
		return $this;
    }
	
	/**
     * 	Function to get current url path
	 * 	@param	boolean $fullPath					Whether to get full url path or not
	 * 	@return	string								url path
     */
	public static function url($fullPath = false) {
		if(! $para = get_global('_para'))
		{			
			$is_cms = self::isCMS();
			$cms_lang = self::lib('config')->get('cmsLang', 'sys');
			$cms_def_lang = self::lib('config')->get('cmsDefLang', 'sys');
			$customize_link = self::lib('config', 'sys')->get('customizeLink');
			$script_name = $_SERVER['SCRIPT_NAME'];
			if(self::lib('config')->get('htaccess', 'sys'))
			{
				$script_name = dirname($_SERVER['SCRIPT_NAME']);		
			}
			$path = str_replace($script_name . '/', '', $_SERVER['REQUEST_URI']);
			$path = preg_replace('/^\//', '', $path);
			$path = preg_replace('/\?.*$/', '', $path);
			$para = array_filter(explode('/', $path), function($value) { 
				return $value !== ''; 
			});
			if((! preg_match('/^(.*\/)?(?P<path>(css|js|img|upload)\/.*)$/', $path, $match) || preg_match('/(css\/[^\.]*|lang\.js)$/', $path)) && ($is_cms || self::lib('config')->get('lang', 'sys'))){
				$lang = array_shift($para);
				$_lang = self::lib('language', $lang);
				$url = '/' . (sizeof($para) ? implode('/', $para) . '/' : '') . (do_get() ? '?' . http_build_query(do_get()) : '');
				if(! $is_cms && $lang != $_lang->get())
				{
					self::redirect(geturl() . $_lang->get() . $url);
				}
				else if($is_cms && $lang != $cms_def_lang && ! in_array($lang, array_keys($cms_lang)))
				{
					self::redirect(geturl() . $cms_def_lang . $url);
				}
			}
			if(array_key_exists('path', $match))
			{
				set_global('_path', $match['path']);
			}
			$para[0] = $para[0] ? $para[0] : get_global('_page');
			$para[1] = $para[1] ? $para[1] : get_global('_func');
			set_global('_para', $para);
		}
		if($fullPath)
		{
			return implode('/', $para);
		}
		else
		{
			return $para[0] . '/' . $para[1];
		}
	}
	
	/**
     * 	Function to get core path
	 * 	@return	string								core path
     */
	public static function path() {
		return dirname(dirname(__FILE__));
	}
	
	/**
     * 	Function to get current time	 
	 * 	@param	string $format						Datetime format
	 * 	@return	string								datetime (Y-m-d H:i:s)
     */
	public static function now($format = 'Y-m-d H:i:s') {
		return to_date($format, ((int) self::lib('setting')->get('time')).' hour');
	}
	
	/**
     * 	Function to check current path whether is cms or not
	 * 	@return	boolean								true or false
     */	
	public static function isCMS() {
		if(self::lib('config')->get('htaccess', 'sys'))
		{
			return preg_match('/\/cms\/$/', geturl());
		}
		else
		{
			return preg_match('/\/cms\/' . basename($_SERVER['SCRIPT_NAME']) . '\/$/', geturl());	
		}
	}
	
	/**
     * 	Function to render view
	 * 	@param	array $bag							Variable to be used in the view
	 * 	@param	string $view						View name
	 * 	@param	array $template_bag					Variable to be used in the template view (html)
	 * 	@param	string $template					Template view name (html)
     */	
	public static function render($bag = array(), $view = '', $template_bag = array(), $template = 'html') {
		if($template)
		{
			$path = self::path() . (self::isCMS() ? '/cms' : '') . "/apps/controller/html.php";
			if(file_exists($path))
			{
				require_once($path);
				$template_func = $template == 'html' ? 'main' : $template;
				if(method_exists('html', $template_func))
				{
					$tmp = new ReflectionMethod('html', $template_func);
					if($tmp->isPublic())
					{
						$template_bag = extend(call_user_func(array('html', $template_func)), $template_bag);
					}
				}
			}
		}
		if(is_array($bag))
		{			
			ob_start();
			include_view($bag, $view);
			$body = ob_get_clean();
		}
		else
		{
			$body = $bag;
		}
		if($template)
		{
			if($protocol = toLower(self::lib('config', 'sys')->get('forceProtocol')))
			{
				$body = '<script type="text/javascript">
							if(window.location.protocol.toLowerCase().indexOf(\'' . $protocol . ':\') == -1)
							{
								window.location.href = \'' . $protocol . '://\'+ window.location.host + window.location.pathname;
							}
					     </script>' . $body;
			}
			if(! self::lib('config', 'sys')->get('allowHighlight', 'sys'))
			{
				$body = '<script type="text/javascript">
					    	document.addEventListener(\'dragstart\', function(e) {
					    		e.preventDefault();
					    	}, false);
					    	document.addEventListener(\'selectstart\', function(e) {
					    		e.preventDefault();
					    	}, false);
					    	function noHightlight(node) {
					    		if (node.nodeType == 1) {
					    			node.setAttribute(\'unselectable\', \'on\');
					    		}
					    		var child = node.firstChild;
					    		while (child) {
					    			noHightlight(child);
					    			child = child.nextSibling;
					    		}
					    	}
					    	noHightlight(document.body);
					     </script>' . $body;
			}
			if(! self::lib('config', 'sys')->get('allowRightClick', 'sys'))
			{
				$body = '<script type="text/javascript">
					     	document.addEventListener(\'contextmenu\', function(e) {
					     		e.preventDefault();
					     	}, false);
					     </script>' . $body;
			}
			ob_start();
			include_view(extend($template_bag, array(
				'body'	=>	$body
			)), $template);
			$body = ob_get_clean();
		}
		if(! self::isCMS())
		{		
			$url = geturl();
			if(! self::lib('config')->get('htaccess', 'sys'))
			{
				$url = dirname($url) . '/';
			}
			$body = preg_replace('/(\<(link|script|img|a|source)[^>]*\s+(src|href)\=(\"|\'))((?!((https?|tel|sms|mailto|whatsapp|callto|facetime|skype|wtai|dc)\:|\.{0,2}\/|\#))[^>]*(\"|\'))/i', '$1' . $url . '$5', $body);
		}
		echo $body;
	}

	/**
     * 	Function to add log and clear expired cache file
	 * 	@param	string $cache_path					Cache path
     */	
	public static function cacheLog($cache_path)
	{
		$log_path = $cache_path . '/log';
		$now = time();
		if(! file_exists($log_path))
		{
			file_put_contents($log_path, $now);
		}
		else
		{
			$last_clean = file_get_contents($log_path);
			$diff = $now - $last_clean;
			if($diff > 86400)
			{
				file_put_contents($log_path, $now);
				$files = filelist($cache_path);
				if($files)
				{
					foreach($files as $value)
					{
						if(file_exists($value) && ($now - filemtime($value)) > 86400)
						{
							@unlink($value);
						}
					}
				}
			}
		}
	}
	
	private function runtime(){
		$time = microtime();
		$time = explode(' ', $time);
		$time = $time[1] + $time[0];
		$this->_time = $time;
	}
	
	private function redirect($url)
	{
		$_redirect = (int) get_session('_redirect');
		if($_redirect >= 3)
		{
			del_session('_redirect');
			die("'" . self::url(true) . "' not exists."winking smiley;
		}
		else
		{
			header('HTTP/1.1 301 Moved Permanently');
			set_session('_redirect', $_redirect + 1);
			redirect($url);
		}
	}

}
?>

Many Thanks,
KH Fong



Edited 2 time(s). Last edit at 02/10/2020 04:13PM by RiggsFolly.

Options: ReplyQuote
Re: Cannot access website folder
Posted by: RiggsFolly (Moderator)
Date: February 10, 2020 04:17PM

We do not debug PHP code on this site.

We assist in getting WAMPServer running but do not provide a complete APACHE / PHP / MYSQL training courses.

There comes a time when you just have to look at the manuals yourself

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.2.0 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.19>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 1 time(s). Last edit at 02/11/2020 10:27AM by RiggsFolly.

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 11, 2020 03:29AM

Dear RiggsFolly (Moderator),

Problem (1) -
As you replied on 06 Feb, "That sounds like a website issue........". Could you advise whether the problem should be due to missing the sub-folder - "/en/" with files under the Root Directory, e.g. "jhmjkb", or else ?

Problem (2) -
Another problem is that the following newly created Virtual Host with Server can only be connected by my PC but CANNOT be connected by another PC / Device -

<VirtualHost *:80>
ServerName jhmjkb
DocumentRoot "c:/wampHosts/jhmjkb"
<Directory "c:/wampHosts/jhmjkb/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride None
#Require local
Require all granted
</Directory>
</VirtualHost>

Link -
[jhmjkb]

In my PC, found the following error which should still be connected -
Not Found
The requested URL /en/ was not found on this server.
Apache/2.4.39 (Win64) PHP/7.2.18 Server at jhmjkb Port 80

In another PC / Device, found the following error which is in traditional Chinese, like below -
Cannot connect the website
Cannot find jhmjkb 's server IP address
DNS_PROBE_FINISHED_NXDOMAIN

Could you also advise how to solve the above Problem (2) ?


Many Thanks,
KH Fong



Edited 1 time(s). Last edit at 02/11/2020 03:31AM by khofong3.

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 12, 2020 06:31AM

Dear RiggsFolly (Moderator),

For the above Problem (2), to let people access the website from outside, does it mean that the DocumentRoot with Directory must be same as our original and under the following ?

DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/....../"

Must be under the following PC folder to store the Root Directory with files, e.g. "jhmjkb" ?
C:\wamp64\www\

Must be under the ServerName localhost ?

Must be with a domain name registered beforehand ?


Many Thanks,
KH Fong

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 13, 2020 11:26AM

Dear RiggsFolly (Moderator) / Experts,

Could you advise for the above Problem (2) 1st ? Very confused on this.


Tks,
KH Fong

Options: ReplyQuote
Re: Cannot access website folder
Posted by: RiggsFolly (Moderator)
Date: February 13, 2020 12:16PM

To get to this VH you need to enter its domain name in the browser.

The other PC does not know how to locate this domain because it is not in the global DNS system

So you have to add your domain to the PC that is trying to access the server by adding the domain to the HOSTS file C:\windows\system32\drivers\etc\hosts

129.168.1.xxx   jhmjkb

Where 129.168.1.xxx is the ip address of the WAMPServer PC (configured with a static IP Addres sof course)

Then reboot the clisnt PC.

If you had a local company DNS Server you could add your domian in there, but that is definitely not a question for us

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.2.0 32bit & 64bit)
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.19>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 14, 2020 11:04AM

Dear RiggsFolly (Moderator),

Thanks for your advice.

As you replied "To get to this VH you need to enter its domain name in the browser.", do you mean the domain should be as below ?

[jhmjkb]

One more Question - If another PC was also setup the WAMP with the same Server Name & domain as above but in different web contents, which web content will be displayed in browser after inputting the above domain in browser ?


From your above reply on February 05, 2020 11:51AM, the "hosts" file was already setup as below -

#
127.0.0.1 localhost
::1 localhost

127.0.0.1 jhmjkb
::1 jhmjkb

How should this file be corrected ? What should be added / changed / removed, could you explain in details ?


Many Thanks,
KH Fong

Options: ReplyQuote
Re: Cannot access website folder
Posted by: Otomatic (Moderator)
Date: February 14, 2020 12:33PM

As RiggsFolly once wrote, "but that is definitely not a question for us."

In no way is your problem due to a Wampserver defect.

I repeat - once again - that this forum is not intended to debug PHP scripts or SQL queries from users, nor to explain how to transfer sites from hosting providers, nor to provide installation procedures for hundreds of CMS and thousands of web applications.

This is the last answer of this thread and I reserve the right to close this discussion.

Options: ReplyQuote
Re: Cannot access website folder
Posted by: khofong3 (---.static.hk.net)
Date: February 17, 2020 07:04AM

Hi,

As RiggsFolly once wrote, "but that is definitely not a question for us." is for "If you had a local company DNS Server you could add your domian in there". From your post on January 21, 2020 03:43PM, you had mentioned "Wampserver is intended for local web development and has absolutely no need for a registered domain name.".

Actually don't want to bother you, but your above suggestions were really not worked !

From Otomatic (Moderator) –
January 21, 2020 10:59AM
January 21, 2020 03:43PM
My response –
January 22, 2020 08:33AM

From Otomatic (Moderator) –
January 23, 2020 11:37AM
January 23, 2020 12:42PM
January 24, 2020 10:12AM
February 14, 2020 12:33PM

From RiggsFolly (Moderator) –
January 29, 2020 10:55PM
February 03, 2020 10:29AM
February 05, 2020 11:51AM
My response –
February 06, 2020 05:16AM

From RiggsFolly (Moderator) –
February 06, 2020 10:20AM
My response –
February 06, 2020 11:28AM
February 07, 2020 03:59AM
February 11, 2020 03:29AM
February 12, 2020 06:31AM

From RiggsFolly (Moderator) –
February 13, 2020 12:16PM
My response –
February 14, 2020 11:04AM

Already don't need you to advise for the above problem (1) (refer post on February 11, 2020 03:29AM), just want you to advise some simpler question(s) for the above problem (2) posted on February 14, 2020 11:04AM.

If you don't want to provide support / share knowledge, why do you act as the Support / Moderator in this forum !?


Tks,

Options: ReplyQuote
Re: Cannot access website folder
Posted by: Otomatic (Moderator)
Date: February 17, 2020 09:16AM

This is only your problem and in no way a Wampserver problem.
Discussion closed.

------------------------------------------------------------------------------------------------------------
Wampserver 3.2.3 32 bit - Apache 2.4.46 - PHP 7.4.9…5.6.40 - MySQL 5.7.31 - MariaDB 10.5.5
Wampserver 3.2.3 64 bit - Apache 2.4.46 - PHP 7.4.9…5.6.40 - MySQL 5.7.31/8.0.21 - MariaDB 10.5.5
PhPMyadmin 5.0.2 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Pages: Previous12
Current Page: 2 of 2


Sorry, you can't reply to this topic. It has been closed.