Manual web wap 7.10

806
.
Gabriel
CyberGhostNet Group
Manual wap web for johncms 7.1.0
By Gabriel

open system/johncms/Environment.php

Find:
public function __invoke(ContainerInterface $container)
    {
        $this->container = $container;
        $this->ipLog($this->getIp());
        return $this;
    }


Add this line:
$this->AgentWeb();
        //access web


And put this code:
/*
      * web view johncms 7.1.0
      * By Gabriel
      * http://nircable.esy.es
    */
    public function AgentWeb()
	{
       if (isset($_GET['w']))
			$_SESSION['agent_web'] = 'web';
		if (isset($_GET['m']))
			$_SESSION['agent_web'] = 'wap';
		if (isset($_POST['web']))
			$_SESSION['agent_web'] = 'web';
		if (isset($_POST['wap']))
			$_SESSION['agent_web'] = 'wap';
		if ($_SESSION['agent_web'] == 'web')
			$agent_web = 'web';
		elseif ($_SESSION['agent_web'] == 'wap')
			$agent_web = 'wap';
		else
			$agent_web = 'wap';
		return $agent_web;
	}

close and save Environment.php
Go to system/johncms/Tools.php
open and put this code:
public function getSkins()
    {
        return $this->user->isValid() && !empty($this->userConfig->skins)
            ? $this->userConfig->skins
            : $this->config->skinweb;
    }

Close and save.

Go to system/johncms/UserConfig.php
Find:
'kmess'       => 20, // Число сообщений на страницу
            'skin'        => '', // Тема оформления

Add this line:
'skins'      => '', // Theme web

Close and save.


Now open admin/includes/settings.php
Find:
$config['skindef'] = isset($_POST['skindef']) ? trim($_POST['skindef']) : 'default';

Add this line:
$config['skinweb'] = isset($_POST['skinweb']) ? trim($_POST['skinweb']) : 'default'; //default skin is default


And add the selected style:
echo '<p><h3>' . _t('Themes') . ' Web</h3>&#160;<select name="skinweb">';
$dirs = opendir('../themes');

while ($skinweb = readdir($dirs)) {
    if (($skinweb != '.') && ($skinweb != '..') && ($skinweb != '.svn')) {
        $skinweb = str_replace('.css', '', $skinweb);
        echo '<option' . ($config['skinweb'] == $skinweb ? ' selected="selected">' : '>') . $skinweb . '</option>';
    }
}

closedir($dirs);

echo '</select>' .
    '</p>';

Close and save
Now open profile/includes/settings.php
Find:
// Устанавливаем скин
            foreach (glob('../theme/*/*.css') as $val) {
                $theme_list[] = array_pop(explode('/', dirname($val)));
            }

            $set_user['skin'] = isset($_POST['skin']) && in_array($_POST['skin'], $theme_list) ? htmlspecialchars(trim($_POST['skin'])) : $config['skindef'];

Add this line:
// Устанавливаем скин web
            foreach (glob('../themes/*/*.css') as $vals) {
                $themes_list[] = array_pop(explode('/', dirname($vals)));
            }

            $set_user['skins'] = isset($_POST['skins']) && in_array($_POST['skins'], $themes_list) ? htmlspecialchars(trim($_POST['skins'])) : $config['skinweb'];


Add the selected theme for user
echo '<p><h3>' . _t('Appearance') . ' Web</h3>';
        // Выбор темы оформления
        echo '<select name="skins">';

        foreach (glob('../themes/*/*.css') as $vals) {
            $dirs = explode('/', dirname($vals));
            $themes = array_pop($dirs);
            echo '<option' . ($userConfig->skins == $themes ? ' selected="selected">' : '>') . $themes . '</option>';
        }

        echo '</select> ' . _t('Theme') . '</p>';

Close and save!

Go to system/bootstrap.php
add this line:
require __DIR__ . '/Mobile_Detect/Mobile_Detect.php';
# @var Mobile_Detect
$Mobile_Detect = new Mobile_Detect;

# @var Mobile_Detect with Version
$OpMin = $Mobile_Detect->version('Opera Mini');
$Android = $Mobile_Detect->version('Android');

# @var Mobile_Detect with is
$Mobile = $Mobile_Detect->isMobile();
$Tablet = $Mobile_Detect->isTablet();
if (empty($_SESSION['agent_web'])){
       if (!$Mobile) {
		    $_SESSION['agent_web'] = 'web';
       } else {
			 $_SESSION['agent_web'] = 'wap';
       }
}	

if ($_SESSION['agent_web'] == 'web') {
	$agent_web = 'web';
} elseif ($_SESSION['agent_web'] == 'wap') {
	$agent_web = 'wap';
} else {
	$agent_web = 'wap';
}


Go to system/head.php
This For menu mobile and web
if ($agent_web == 'web') {
   echo 'Head Web';
   //require(ROOT_PATH . 'themes/' . $tools->getSkins() . '/head.php');
  // themes head for web im use and put on dir /themes/
} else {
   echo 'Head Mobile';
   //head mobile
}


for end.php
if ($agent_web == 'web') {
   echo 'End Web';
   //require(ROOT_PATH . 'themes/' . $tools->getSkins() . '/end.php');
  // themes end for web im use and put on dir /themes/
} else {
   echo 'End Mobile';
   // end mobile
}


To access web you can use domain/?w
To access wap you can use domain/?m

Or you can use form like this
echo '<form action="" method="post">
			<input type="submit" name="web" value="Dekstop Views">
		</form>';
Прикрепленные файлы:
Всего: 1