Quantcast
Channel: WampServer - WampServer English
Viewing all articles
Browse latest Browse all 3177

Cannot access website folder (no replies)

$
0
0
Dear Experts,

I had setup a WAMP server in my PC with Win 8 and Virtual Host was setup as below -

# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/angliadesign/clients2/jhm/site/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride None
# Require local
Require all granted
</Directory>
</VirtualHost>

Our required website is under a sub-folder "Web_Application" as below -

C:\wamp64\www\angliadesign\clients2\jhm\site\Web_Application

When accessing the website by accessing the above sub-folder in Google Chrome, i.e.

[test.jkbrothers.net]

I could NOT access the website and found msg as below -

Not Found
The requested URL /angliadesign/clients2/jhm/site/Web_Application/en/ was not found on this server.

Apache/2.4.39 (Win64) PHP/7.2.18 Server at test.jkbrothers.net Port 80

Don't know why the above msg was found as there is no the above path (....../en/) setup in my PC.

Could you advise how to solve the above problem so that I can access the above website / sub-folder "Web_ Application" ?

Below is the content of "index.php" under the above sub-folder "Web_Application" -

C:\wamp64\www\angliadesign\clients2\jhm\site\Web_Application

<?php
include('core/framework.php');
$framework = new framework();
$framework->call('common', 'func');
$framework->init();
?>

Below is also the content of "framework.php" under the following sub-folder -

C:\wamp64\www\angliadesign\clients2\jhm\site\Web_Application\core

<?php

/**
* Framework
* This php included all core functions to be used
*
* 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.");
}
else
{
header('HTTP/1.1 301 Moved Permanently');
set_session('_redirect', $_redirect + 1);
redirect($url);
}
}

}
?>


Pls also let me know if you need more info. on this.


Many Thanks,
KH Fong

Viewing all articles
Browse latest Browse all 3177

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>