Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560
[2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85
[3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50
[4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13
[5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
403WebShell
403Webshell
Server IP : 94.177.8.99  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/theyoungdesigners_com/modules/cmsSinglePage/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/theyoungdesigners_com/modules/cmsSinglePage/main.php
<?php

namespace modules\cmsSinglePage;

// http://imakewebthings.com/waypoints/
// https://github.com/imakewebthings/waypoints/issues/157
// https://github.com/imakewebthings/waypoints/issues/126

// however, if we have a bot/crawler, the singlepage feature is ignored
/*
bug in waypoint fixed with addition of following (when scrolling up to the top of the page)

		tp = waypoint.triggerPoint;
		if (!isForward) {
			var ht = waypoint.element.clientHeight;
			tp += ht;
		}
        var wasBeforeTriggerPoint = axis.oldScroll < tp;
        var nowAfterTriggerPoint = axis.newScroll >= tp;

*/

class main extends \moduleMain {

	use \modules\input\traits {
			\modules\input\traits::__construct as __ConstructInput;
		}
	use \modules\output\traits {
			\modules\output\traits::__construct as __ConstructOutput;
		}
	use \modules\database\traits {
			\modules\database\traits::__construct as __ConstructDatabase;
		}

	protected $base;
	protected $isBot;
	protected $in_body;
	protected $old_list;
	protected $new_list;
	protected $x_info;
	protected $model_cms;
	
	public function __construct() {
		parent::__construct(__DIR__);
		$this->__ConstructInput();
		$this->__ConstructOutput();
		$this->__ConstructDatabase();
		$this->base = $this->StaticUriModule(__DIR__);
		$this->isBot = NULL;
		$this->in_body = FALSE;
	}

	// each page still keeps it's own url, 
	// single page will be displayed when visited by a bot
	
	public function Activate() {
		hook_add('cms.fields', [$this, '__addCmsTabs_singlepage'], 80);	// singlepage
		hook_add('cms.save', [$this, '__save_content']); 
		hook_add('cms.saved', [$this, '__saved']); 	// update links
		hook_add('cms.body', [$this, '__body'], 1);	// display extra pages
	}
	
	public function __addCmsTabs_singlepage($model_cms) {

		// these pages will be added to the end of the current page.
		// url will change as one scrolls down the page
		$model_cms->AddTab('Single Page',
			$model_cms->AddField_Comment('Select the pages to be included with this content on a Single Page. Drag to re-order'),
			$model_cms->AddField_Sortable('pagelist', 'Page List')
			// to do: link to add new page - current page will be missing from list, as will any already present in the list
		);
	}

	// https://test.patientappsinc.com/plugins/cms_singlepage/rebuild
	// rebuild pagelist_parent and pagelist entries
	public function Rebuild() {
		$this->_loadCMS();
		$pagelists = [];
		$parent = [];
	// get all pagelists
		$list = $this->model_cms->LoadDynamicPages(TRUE);
		foreach($list as $list_item) {
			if (isset($list_item['__extra']['pagelist']) && $list_item['__extra']['pagelist'] != '') {
				$uri = $list_item['pg_uri'];
				$pagelists[$uri] = $list_item['__extra']['pagelist'];
				$parent = $this->_pagelist($list_item['__extra']['pagelist'], $uri);
			}
		}
	// update childrens
		foreach($list as $list_item) {
			$uri = $list_item['pg_uri'];
			if (isset($parent[$uri])) {
				$list_item['__extra']['pagelist_parent'] = $parent[$uri];
			} else {
				unset($list_item['__extra']['pagelist_parent']);
			}
			$x = serialize($list_item['__extra']);
			$sql = 'update pages set pg_extra=%s where pg_uri=%s';
			$this->Execute($sql, [$x, $uri]);
		}
		return "<p>Pagelist entries rebuilt</p>";
	}
	
	public function __save_content($post, $sender) {
		$pagelist = isset($post['pagelist']) ? trim($post['pagelist']) : '';
		$this->old_list = isset($sender->INFO->__extra['pagelist']) ? $sender->INFO->__extra['pagelist'] : '';
		$this->new_list = $pagelist;
		$extra = $sender->Extra();
		$extra['pagelist'] = $pagelist;
		$sender->Extra($extra);
	}

	public function __saved($sender) {
		if ($this->old_list == $this->new_list) return;		// nothing changed, so links on other pages do not need changing
		
		$this->_loadCMS();
		$old_info = $sender->INFO;
		$old = $this->_pagelist($this->old_list);
		$new = $this->_pagelist($this->new_list);
		foreach($old as $old_item => $filler) {
			if (isset($new[$old_item])) {
				unset($old[$old_item], $new[$old_item]);		// remove unchanged
			}
		}
		// whatever remains is to be deleted or inserted.
		foreach($old as $item => $filler) {
			$this->singlePageLink_Remove($item);
		}
		foreach($new as $item => $filler) {
			$this->singlePageLink_Add($item, $old_info->pg_uri);
		}
		$sender->INFO = $old_info;
	}
	
	private function _pagelist($list, $uri = 1) {
		$result = [];
		if ($list != '') {
			$list = explode(';', $list);
			foreach($list as $list_item) {
				list($k, $v) = explode('=', $list_item, 2);
				$result[$k] = $uri;
			}
		}
		return $result;
	}
	
	private function _loadCMS(){
		$this->model_cms = $this->LoadModel('cms_model', 'cms');
	}

	public function __body(&$body, $sender) {
		if (is_null($this->isBot)) {
			$this->isBot = hook_execute('input.isbot', FALSE);
		}

		$p = [
			'in_body' 	=> $this->in_body,
			'is_bot'	=> $this->isBot,
			'editpage'	=> $_GET['editpage'] ?? '',
		];

		if (!empty($this->in_body) || $this->isBot) return;
		if (!empty($_GET['editpage'])) return;		// in page editor. edit only single page
		
		$this->in_body = 1;
		$this->x_info = $sender->INFO->__extra;
		$old_info = $sender->INFO;
		$desired_entrypoint = '';
		$pagelist_parent = isset($this->x_info['pagelist_parent']) ? trim($this->x_info['pagelist_parent']) : '';
		if ($pagelist_parent != '') {	// load the parent page, if a direct link to a subpage has been specified
			$this->_loadCMS();
			if ($this->model_cms->TemplateGet($pagelist_parent)) {
				$desired_entrypoint = $old_info->pg_uri;
				$this->x_info = $sender->INFO->__extra;
				$old_info = $sender->INFO;		// the main page is not the specified one, but the parent
			} else {
				$pagelist_parent = '';
			}
		}
		$pagelist = isset($this->x_info['pagelist']) ? trim($this->x_info['pagelist']) : '';
		if ($pagelist != '') {

//			$ext = JS;
			$ext = '.js';
			$id = $this->IncludeFile("{$this->base}/jquery.waypoints{$ext}", 'waypoints')
						->depends('jquery');
			
			$this->_loadCMS();
			$this->CreateSinglePage($body, $pagelist, $pagelist_parent, $desired_entrypoint);

			$name = \Misc::asSlug($desired_entrypoint);
			if ($name == '' && $desired_entrypoint != '') $name = 'index';
			
			$ext = '.js';
			$id = $this->IncludeFile("{$this->base}/jquery.waypoints{$ext}", 'waypoints')
						->depends('jquery');
		// http://imakewebthings.com/waypoints/api/offset-option/
			$id = $this->IncludeFile("{$this->base}/singlepage.js")
						->depends('waypoints')
						->Attr('data-waypoint', $name);

		}
		$sender->INFO = $old_info;
		$this->in_body = 0;
	}
	
    // At the moment, this only supports joining CMS pages
	private function CreateSinglePage(&$body, $pagelist, $pagelist_parent) {
		$list = explode(';', $pagelist);
		if ($pagelist_parent != '') {
			$body = $this->model_cms->GetBody();	// overwrite specified page with parent
			$uri = $pagelist_parent;
		}
        // Generate the main page
		$uri = $this->model_cms->INFO->pg_uri;
		$auth = isset($this->model_cms->edit_auth) ? ' data-auth="' . $this->model_cms->edit_auth . '"' : '';
		$name = \Misc::asSlug($uri);
		if ($name == '') $name = 'index';
		$body = <<<BLOCK
<div class="cms-waypoint" id="$name" data-href="{$uri}"{$auth}>
$body
</div>
BLOCK;
		
		$pages = [];
		foreach($list as &$list_item) {
			list($k, $v) = explode('=', $list_item, 2);
			$list_item = $k;
			$pages[] = $k;
		}
		$cmspages = $this->model_cms->GetPages($pages);
		$original = $this->model_cms->INFO;
		$original_auth = isset($this->model_cms->edit_auth) ? $this->model_cms->edit_auth : '';
		unset($list_item);
        
        // add to the main page eached linked page
		foreach($list as $uri) {
			if (isset($cmspages[$uri])) {
				$this->model_cms->INFO = $cmspages[$uri];
				$item_body = $this->model_cms->GetBody();
				$auth = isset($this->model_cms->edit_auth) ? ' data-auth="' . $this->model_cms->edit_auth . '"' : '';
				$name = \Misc::asSlug($uri);
				if ($name == '') $name = 'index';
				$body .= <<<BLOCK
<div class="cms-waypoint" id="$name" data-href="{$uri}"{$auth}>
$item_body
</div>

BLOCK;

			}
		}
		$this->model_cms->INFO = $original;
		$this->model_cms->edit_auth = $original_auth;
	}
	
	private function singlePageLink_Remove($item) {
		if ($this->model_cms->TemplateGet($item)) {
			$extra = $this->model_cms->Extra();
			if (isset($extra['pagelist_parent'])) {
				unset($extra['pagelist_parent']);
				$this->_updateEntry($item, $extra);
			}
		}
	}

	private function singlePageLink_Add($item, $parent) {
		if ($this->model_cms->TemplateGet($item)) {
			$extra = $this->model_cms->Extra();
			$extra['pagelist_parent'] = $parent;
			$this->_updateEntry($item, $extra);
		}
	}
	
	private function _updateEntry($uri, $extra) {
		$this->TableName('pages')
			->InsertOrUpdate([
				'pg_uri' => $uri,
			],[
				'pg_extra' => serialize($extra),
			]);
	}

	/*
	// with a given singlepage, update all child links
	public function update_links($uri = '/') {
		$this->_loadCMS();
		if ($this->model_cms->TemplateGet($uri)) {
			$extra = $this->model_cms->Extra();
			$parent = $this->_pagelist($extra['pagelist'], $uri);

			// get all old links to this page
			$rows = $this->Query('select pg_uri from pages')
						->Where('pg_extra like %s', "%pagelist_parent=\"{$uri}\"%")
						->Get();
			$existing = [];
			foreach($rows as $row) {
				$u = $row->pg_uri;
				if (isset($parent[$u])) {
					unset($parent[$u]);		// unset
				} else {
					$existing[] = $u;
				}
			}
			
			// new items
			$engine = $this->DatabaseEngine();
			foreach($parent as $new_uri => $filler) {
				if ($this->model_cms->TemplateGet($new_uri)) {
					$extra = $this->model_cms->Extra();
					$extra['pagelist_parent'] = $uri;
					$x = serialize($extra);
					$this->Query('update pages set pg_extra=%s', $x)
							->Where('pg_uri=%s', $new_uri)
							->Get();
//					echo "Added: $new_url - {$engine->lastsql}\n";
				}
			}
			
			// remove now-unused items
			foreach($existing as $old_uri) {
				if ($this->model_cms->TemplateGet($old_uri)) {
					$extra = $this->model_cms->Extra();
					unset($extra['pagelist_parent']);
					$x = serialize($extra);
					$this->Query('update pages set pg_extra=%s', $x)
							->Where('pg_uri=%s', $old_uri)
							->Get();
//					echo "Removed: $new_url - {$engine->lastsql}\n";
				}
			}
		}
	} */

}

Youez - 2016 - github.com/yon3zu
LinuXploit