Completed
Branch master (6c262f)
by Pierre-Henry
111:59 queued 51:18
created

_install/library/Controller.class.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * @title            Controller Core Class
4
 *
5
 * @author           Pierre-Henry Soria <[email protected]>
6
 * @copyright        (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved.
7
 * @license          GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.
8
 * @link             http://ph7cms.com
9
 * @package          PH7 / Install / Library
10
 */
11
12
namespace PH7;
13
14
defined('PH7') or die('Restricted access');
15
16
use Smarty;
17
18
abstract class Controller implements Controllable
19
{
20
    const SOFTWARE_NAME = 'pH7CMS';
21
    const DEFAULT_SITE_NAME = 'Social Dating App';
22
    const SOFTWARE_PREFIX_COOKIE_NAME = 'pH7';
23
    const SOFTWARE_WEBSITE = 'http://ph7cms.com';
24
    const SOFTWARE_LICENSE_URL = 'http://ph7cms.com/legal/license';
25
    const SOFTWARE_HELP_URL = 'http://clients.hizup.com/support'; // Help Desk URL
26
    const SOFTWARE_LICENSE_KEY_URL = 'http://ph7cms.com/web/buysinglelicense';
27
    const SOFTWARE_DOWNLOAD_URL = 'http://download.hizup.com/';
28
    const SOFTWARE_REQUIREMENTS_URL = 'http://ph7cms.com/doc/en/requirements';
29
    const SOFTWARE_HOSTING_LIST_URL = 'http://ph7cms.com/hosting';
30
    const SOFTWARE_HOSTING_LIST_FR_URL = 'http://ph7cms.com/doc/fr/h%C3%A9bergement-web';
31
    const SOFTWARE_EMAIL = '[email protected]';
32
    const SOFTWARE_AUTHOR = 'Pierre-Henry Soria';
33
    const SOFTWARE_LICENSE = 'GNU General Public License; See PH7.LICENSE.txt and PH7.COPYRIGHT.txt in the root directory.';
34
    const SOFTWARE_COPYRIGHT = '© (c) 2012-2017, Pierre-Henry Soria. All Rights Reserved.';
35
36
    // 1.0, 1.1 branches were "pOH", 1.2 was "pOW", 1.3, 1.4 were "p[H]", 2.* was "H2O", 3.* was "H3O", 4.* was "HCO", 5.* was "pCO" and 6.* is "WoW"
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
    const SOFTWARE_VERSION_NAME = 'WoW';
38
    const SOFTWARE_VERSION = '6.0.13';
39
    const SOFTWARE_BUILD = '1';
40
41
    const DEFAULT_LANG = 'en';
42
    const DEFAULT_THEME = 'base';
43
44
    /** @var Smarty */
45
    protected $oView;
46
47
    /** @var string */
48
    protected $sCurrentLang;
49
50
    public function __construct()
51
    {
52
        global $LANG;
53
54
        // Initialize PHP session
55
        $this->initializePHPSession();
56
57
        // Verify and correct the time zone if necessary
58
        $this->checkTimezone();
59
60
        // Language initialization
61
        $this->sCurrentLang = (new Language)->get();
62
        include_once PH7_ROOT_INSTALL . 'langs/' . $this->sCurrentLang . '/install.lang.php';
63
64
        /* Smarty initialization */
65
        $this->oView = new Smarty;
66
        $this->oView->use_sub_dirs = true;
67
        $this->oView->setTemplateDir(PH7_ROOT_INSTALL . 'views/' . self::DEFAULT_THEME);
68
        $this->oView->setCompileDir(PH7_ROOT_INSTALL . 'data/caches/smarty_compile');
69
        $this->oView->setCacheDir(PH7_ROOT_INSTALL  . 'data/caches/smarty_cache');
70
        $this->oView->setPluginsDir(PH7_ROOT_INSTALL . 'library/Smarty/plugins');
71
        // Smarty Cache
72
        $this->oView->caching = 0; // 0 = Cache disabled |  1 = Cache never expires | 2 = Set the cache duration at "cache_lifetime" attribute
73
        $this->oView->cache_lifetime = 86400; // 86400 seconds = 24h
74
75
        $this->oView->assign('LANG', $LANG);
76
        $this->oView->assign('software_name', self::SOFTWARE_NAME);
77
        $this->oView->assign('software_version', self::SOFTWARE_VERSION . ' Build ' . self::SOFTWARE_BUILD . ' - ' . self::SOFTWARE_VERSION_NAME);
78
        $this->oView->assign('software_website', self::SOFTWARE_WEBSITE);
79
        $this->oView->assign('software_license_url', self::SOFTWARE_LICENSE_URL);
80
        $this->oView->assign('software_help_url', self::SOFTWARE_HELP_URL);
81
        $this->oView->assign('software_license_key_url', self::SOFTWARE_LICENSE_KEY_URL);
82
        $this->oView->assign('software_author', self::SOFTWARE_AUTHOR);
83
        $this->oView->assign('software_copyright', self::SOFTWARE_COPYRIGHT);
84
        $this->oView->assign('software_email', self::SOFTWARE_EMAIL);
85
        $this->oView->assign('tpl_name', self::DEFAULT_THEME);
86
        $this->oView->assign('current_lang', $this->sCurrentLang);
87
    }
88
89
    /**
90
     * Check if the session is already initialized (thanks "session_status()" PHP >= 5.4)
91
     * And initialize it if it isn't the case.
92
     *
93
     * @return void
94
     */
95
    protected function initializePHPSession()
96
    {
97
        if (session_status() !== PHP_SESSION_ACTIVE)
98
            @session_start();
99
    }
100
101
    /**
102
     * Set a default timezone if it is not already configured.
103
     *
104
     * @return void
105
     */
106
    protected function checkTimezone()
107
    {
108
        if (!ini_get('date.timezone'))
109
            date_default_timezone_set(PH7_DEFAULT_TIMEZONE);
110
    }
111
}
112