Example #1
0
 /**
  * Initialization, creating cache engine instance
  */
 protected function construct()
 {
     $this->cache = !DEBUG;
     if (!$this->init && $this->cache) {
         $engine_class = '\\cs\\Cache\\' . ($this->engine = Core::instance()->cache_engine);
         $this->engine_instance = new $engine_class();
     }
 }
Example #2
0
 /**
  * Detection of encryption support
  */
 protected function construct()
 {
     if ($this->encrypt_support = check_mcrypt()) {
         $Core = Core::instance();
         $this->key = $Core->key;
         $this->iv = $Core->iv;
     }
 }
Example #3
0
 function __construct()
 {
     if (!memcached()) {
         return;
     }
     $this->memcached = new \Memcached(DOMAIN);
     $Core = Core::instance();
     $this->memcached->addServer($Core->memcached_host ?: '127.0.0.1', $Core->memcached_port ?: 11211);
 }
Example #4
0
 * @author		Nazar Mokrynskyi <*****@*****.**>
 * @copyright	Copyright (c) 2011-2014, Nazar Mokrynskyi
 * @license		MIT License, see license.txt
 */
namespace cs\modules\System;

use h, cs\Config, cs\Core, cs\Index, cs\Language;
$Config = Config::instance();
$L = Language::instance();
$Config->reload_languages();
$translate_engines = _mb_substr(get_files_list(ENGINES . '/Text', '/^[^_].*?\\.php$/i', 'f'), 0, -4);
$translate_engines_settings = [];
$current_engine_settings = '';
foreach ($translate_engines as $engine) {
    $parameters = file_get_json(ENGINES . '/Text/' . $engine . '.json');
    if (is_array($parameters) && !empty($parameters)) {
        $table = '';
        foreach ($parameters as $paremeter => $description) {
            $table .= h::{'tr td'}([$description, h::input(['name' => 'core[auto_translation_engine][' . $paremeter . ']', 'value' => isset($Config->core['auto_translation_engine'][$paremeter]) ? $Config->core['auto_translation_engine'][$paremeter] : ''])]);
        }
        $translate_engines_settings[] = base64_encode(h::table($table));
    } else {
        $translate_engines_settings[] = base64_encode($parameters ?: $L->no_settings_found);
    }
    if ($engine == $Config->core['auto_translation_engine']['name']) {
        $current_engine_settings = base64_decode(array_slice($translate_engines_settings, -1)[0]);
    }
}
unset($engine, $parameters, $paremeter, $description, $table);
Index::instance()->content(h::{'p.lead.cs-center'}(FIXED_LANGUAGE ? $L->language_fixed_as . ' ' . Core::instance()->language : false) . h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr| td'}(core_select($Config->core['active_languages'], 'language', 'change_language', 'current_language'), core_select($Config->core['languages'], 'active_languages', 'change_active_languages', null, true), [h::info('multilingual'), h::{'input[type=radio]'}(['name' => 'core[multilingual]', 'checked' => $Config->core['multilingual'], 'value' => [0, 1], 'in' => [$L->off, $L->on], 'OnClick' => ["\$('.cs-multilingual').hide(); \$('.cs-auto-translation').hide();", "\$('.cs-multilingual').show(); if (\$('#auto_translation [value=1]').prop('checked')) \$('.cs-auto-translation').show();"]])], [[h::info('auto_translation'), h::{'input[type=radio]'}(['name' => 'core[auto_translation]', 'checked' => $Config->core['auto_translation'], 'value' => [0, 1], 'in' => [$L->off, $L->on], 'OnClick' => ["\$('.cs-auto-translation').hide();", "\$('.cs-auto-translation').show();"]])], ['style' => !$Config->core['multilingual'] ? 'display: none; ' : '', 'id' => 'auto_translation', 'class' => 'cs-multilingual']], [[h::info('auto_translation_engine'), h::select($translate_engines, ['name' => 'core[auto_translation_engine][name]', 'selected' => $Config->core['auto_translation_engine']['name'], 'data-settings' => $translate_engines_settings, 'size' => 5])], ['style' => !$Config->core['multilingual'] || !$Config->core['auto_translation'] ? 'display: none; ' : '', 'id' => 'auto_translation_engine', 'class' => 'cs-auto-translation']], [[$L->auto_translation_engine_settings, ['style' => !$Config->core['multilingual'] || !$Config->core['auto_translation'] ? 'display: none; ' : '', 'class' => 'cs-auto-translation cs-multilingual']], [$current_engine_settings, ['style' => !$Config->core['multilingual'] || !$Config->core['auto_translation'] ? 'display: none; ' : '', 'id' => 'auto_translation_engine_settings', 'class' => 'cs-auto-translation']]]));
Example #5
0
     break;
 case 'db':
     $show_modules = false;
     if (count($Config->db) > 1) {
         $Page->warning($L->changing_settings_warning);
         $Page->title($L->db_settings_for_module($rc[3]));
         $a->content(h::{'p.lead.cs-center'}($L->db_settings_for_module($rc[3])));
         if (!Trigger::instance()->run('admin/System/components/modules/db/prepare', ['name' => $rc[3]])) {
             break;
         }
         $a->buttons = true;
         $a->apply_button = false;
         $a->cancel_button_back = true;
         module_db_settings:
         if (file_exists(MODULES . "/{$rc['3']}/meta/db.json")) {
             $Core = Core::instance();
             $dbs = [0 => "{$L->core_db} ({$Core->db_type})"];
             foreach ($Config->db as $i => &$db_data) {
                 if ($i) {
                     $dbs[$i] = "{$db_data['name']} ({$db_data['host']} / {$db_data['type']})";
                 }
             }
             unset($i, $db_data);
             $db_list = [];
             $db_json = file_get_json(MODULES . "/{$rc['3']}/meta/db.json");
             foreach ($db_json as $database) {
                 $db_list[] = [$L->{"{$rc['3']}_db_{$database}"}, h::select(['in' => array_values($dbs), 'value' => array_keys($dbs)], ['name' => "db[{$database}]", 'selected' => isset($Config->components['modules'][$rc[3]]['db'][$database]) ? $Config->components['modules'][$rc[3]]['db'][$database] : 0, 'size' => 5])];
             }
             unset($db_json, $dbs, $database);
             $a->content(h::{'table.cs-table'}(h::{'thead tr th'}([h::info('appointment_of_db'), h::info('system_db')]) . h::{'tbody tr| td'}($db_list)));
             unset($db_list);
Example #6
0
 * @copyright	Copyright (c) 2013-2014, Nazar Mokrynskyi
 * @license		MIT License, see license.txt
 */
namespace cs;

use h;
/**
 * Multilingual functionality: redirects and necessary meta-tags
 */
Trigger::instance()->register('System/User/construct/after', function () {
    $Config = Config::instance();
    if (!$Config->core['multilingual']) {
        return;
    }
    $relative_address = $Config->server['relative_address'];
    $Cache = Cache::instance();
    if (!FIXED_LANGUAGE && $_SERVER['REQUEST_METHOD'] == 'GET' && $Cache->cache_state() && Core::instance()->cache_engine != 'BlackHole') {
        $clang = Language::instance()->clang;
        if (!HOME) {
            header("Location: /{$clang}/{$relative_address}", true, 301);
        } else {
            header("Location: /{$clang}", true, 301);
        }
    }
    $base_url = substr($Config->base_url(), 0, -3);
    Page::instance()->Head .= h::{'link[rel=alternate]'}(['hreflang' => 'x-default', 'href' => !HOME ? "{$base_url}/{$relative_address}" : "{$base_url}"]) . h::{'link[rel=alternate]|'}(array_map(function ($lang) use($base_url, $relative_address) {
        return ['hreflang' => $lang, 'href' => "{$base_url}/{$lang}/{$relative_address}"];
    }, array_values($Cache->get('languages/clangs', function () use($Config) {
        return $Config->update_clangs();
    })) ?: []));
});
Example #7
0
 * @package        Elections
 * @category       modules
 * @author         Nazar Mokrynskyi <*****@*****.**>
 * @copyright      Copyright (c) 2014, Nazar Mokrynskyi
 * @license        MIT License, see license.txt
 */
namespace cs\modules\Precincts;

use h, cs\Core, cs\Index, cs\Language, cs\Page, cs\User;
$Index = Index::instance();
$Index->title_auto = false;
$L = Language::instance();
$Page = Page::instance();
if (isset($Index->route_path[0], $Index->route_ids[1]) && $Index->route_path[0] == 'violation') {
    $violation = Violations::instance()->get($Index->route_ids[1]);
    if ($violation['images']) {
        $Page->replace('/<meta content="[^"]*share.png" property="og:image">/Uims', '');
        $Page->replace('/<link href="[^"]*share.png" rel="image_src">/Uims', '');
        $Page->link(['rel' => 'image_src', 'href' => $violation['images'][0]]);
        foreach ($violation['images'] as $image) {
            $Page->og('image', $image);
            $Page->og('image:secure_url', $image);
        }
    }
    if ($violation['text']) {
        $Page->Description = description($violation['text']);
    }
}
$Page->Header .= h::{'button.cs-elections-add-violation'}(h::{'i.uk-icon-plus'}() . " {$L->add_violation}") . h::{'button.cs-elections-last-violations'}();
$Page->js("window.disqus_shortname = '" . Core::instance()->disqus_shortname . "';", 'code');
$Page->content(h::{'div.cs-elections-last-violations-panel'}(h::h2($L->last_violations) . h::{'section'}()) . h::{'aside.cs-elections-precinct-sidebar'}() . h::{'aside.cs-elections-add-violation-sidebar'}() . h::{'aside.cs-elections-violation-read-more-sidebar'}() . h::{'aside.cs-elections-main-sidebar'}(h::{'div.cs-elections-opirzagin a[href=become_eyes]'}($L->become_eyes) . h::{'div.cs-elections-opirzagin a[href=opirzagin]'}($L->opircrew) . h::{'div.cs-elections-opirzagin a[href=instruktsia]'}($L->instruktsia) . h::{'div.cs-elections-socials'}('<div class="yashare-auto-init" data-yashareL10n="uk" data-yashareQuickServices="facebook" data-yashareLink="https://www.facebook.com/opir.org" data-yashareTheme="counter" data-yashareImage="https://opir.org/components/modules/Common/includes/img/share.png"></div>' . '<div class="yashare-auto-init" data-yashareL10n="uk" data-yashareQuickServices="vkontakte,twitter" data-yashareLink="https://opir.org/" data-yashareTheme="counter" data-yashareImage="https://opir.org/components/modules/Common/includes/img/share.png"></div>') . h::h2($L->precincts_search) . h::{'input.cs-elections-precincts-search[type=search]'}(['placeholder' => $L->number_or_address]) . h::{'section.cs-elections-precincts-search-results[level=0]'}() . h::h2($L->mobile_apps) . h::{'div.cs-elections-mobile-apps'}(h::{'a[target=_blank'}($L->download_in('App Store'), ['href' => 'https://itunes.apple.com/ua/app/opir.org/id896488790']) . h::{'a[target=_blank]'}($L->download_in('Google Play'), ['href' => 'https://play.google.com/store/apps/details?id=example.yariksoffice']) . h::{'a[target=_blank]'}($L->download_in('Market Place'), ['onclick' => "\$.cs.simple_modal('{$L->soon}')"])) . h::h2($L->contacts) . h::{'div.cs-elections-contacts'}(h::a(h::icon('phone') . '+38 093 012 22 11') . h::a(h::icon('phone') . '+38 067 708 42 90') . h::{'a[href=mailto:info@opir.org]'}(h::icon('envelope') . '*****@*****.**')) . h::h2($L->map_legend) . h::{'div.cs-elections-map-legend'}(h::div($L->precincts_with_violations) . h::div($L->precincts_without_violations) . h::div($L->district_precincts))));
Example #8
0
 /**
  * Processing of template, substituting of content, preparing for the output
  *
  * @return Page
  */
 protected function prepare()
 {
     $Config = Config::instance(true);
     /**
      * Loading of template
      * Loading of CSS and JavaScript
      * Getting user information
      */
     $this->get_template()->add_includes_on_page()->get_header_info();
     /**
      * Forming page title
      */
     foreach ($this->Title as $i => $v) {
         if (!trim($v)) {
             unset($this->Title[$i]);
         } else {
             $this->Title[$i] = trim($v);
         }
     }
     if ($Config) {
         $this->Title = $Config->core['title_reverse'] ? array_reverse($this->Title) : $this->Title;
         $this->Title = implode($Config->core['title_delimiter'], $this->Title);
     } else {
         $this->Title = $this->Title[0];
     }
     /**
      * Core JS
      */
     if ($Config) {
         $Index = Index::instance();
         $User = User::instance();
         $this->js_internal('window.cs	= ' . _json_encode(['base_url' => $Config->base_url(), 'current_base_url' => $Config->base_url() . '/' . (defined('IN_ADMIN') && IN_ADMIN ? 'admin/' : '') . MODULE, 'public_key' => Core::instance()->public_key, 'module' => MODULE, 'in_admin' => (int) (defined('IN_ADMIN') && IN_ADMIN), 'is_admin' => (int) $User->admin(), 'is_user' => (int) $User->user(), 'is_guest' => (int) $User->guest(), 'debug' => (int) $User->guest(), 'cookie_prefix' => $Config->core['cookie_prefix'], 'cookie_domain' => $Config->core['cookie_domain'][$Config->server['mirror_index']], 'cookie_path' => $Config->core['cookie_path'][$Config->server['mirror_index']], 'protocol' => $Config->server['protocol'], 'route' => $Config->route, 'route_path' => $Index->route_path, 'route_ids' => $Index->route_ids]) . ';', 'code', true);
         if ($User->guest()) {
             $this->js('cs.rules_text = ' . _json_encode(get_core_ml_text('rules')) . ';', 'code');
         }
         if (!$Config->core['cache_compress_js_css']) {
             $this->js('cs.Language = ' . _json_encode(Language::instance()) . ';', 'code');
         }
     }
     /**
      * Forming <head> content
      */
     $this->core_css[0] = implode('', array_unique($this->core_css[0]));
     $this->core_css[1] = implode('', array_unique($this->core_css[1]));
     $this->css[0] = implode('', array_unique($this->css[0]));
     $this->css[1] = implode('', array_unique($this->css[1]));
     $this->core_js[0] = implode('', array_unique($this->core_js[0]));
     $this->core_js[1] = implode('', array_unique($this->core_js[1]));
     $this->js[0] = implode('', array_unique($this->js[0]));
     $this->js[1] = implode('', array_unique($this->js[1]));
     if (file_exists(THEMES . "/{$this->theme}/{$this->color_scheme}/img/favicon.png")) {
         $favicon = "themes/{$this->theme}/{$this->color_scheme}/img/favicon.png";
     } elseif (file_exists(THEMES . "/{$this->theme}/{$this->color_scheme}/img/favicon.ico")) {
         $favicon = "themes/{$this->theme}/{$this->color_scheme}/img/favicon.ico";
     } elseif (file_exists(THEMES . "/{$this->theme}/img/favicon.png")) {
         $favicon = "themes/{$this->theme}/img/favicon.png";
     } elseif (file_exists(THEMES . "/{$this->theme}/img/favicon.ico")) {
         $favicon = "themes/{$this->theme}/img/favicon.ico";
     } else {
         $favicon = 'favicon.ico';
     }
     $this->Head = h::title($this->Title) . h::meta(['charset' => 'utf-8'], $this->Description ? ['name' => 'description', 'content' => $this->Description] : false, ['name' => 'generator', 'content' => base64_decode('Q2xldmVyU3R5bGUgQ01TIGJ5IE1va3J5bnNreWkgTmF6YXI=')], defined('ADMIN') && ADMIN || defined('API') && API ? ['name' => 'robots', 'content' => 'noindex,nofollow'] : false) . h::base($Config ? ['href' => $Config->base_url() . '/'] : false) . $this->Head . h::link([['rel' => 'shortcut icon', 'href' => $favicon]], $this->link ?: false) . $this->core_css[0] . $this->css[0] . h::style($this->core_css[1] . $this->css[1] ?: false) . h::script($this->core_js[1] . $this->js[1]);
     if ($Config->core['put_js_after_body']) {
         $this->post_Body .= $this->core_js[0] . $this->js[0];
     } else {
         $this->Head .= $this->core_js[0] . $this->js[0];
     }
     /**
      * Generation of Open Graph protocol information
      */
     $this->og_generation();
     /**
      * Getting footer information
      */
     $this->get_footer();
     /**
      * Menu generation
      */
     $Index = Index::instance();
     if (!$this->main_menu && $Index->main_menu) {
         $this->main_menu = h::{'li| a'}($Index->main_menu);
     }
     if ($Index->main_sub_menu) {
         if (!$this->main_sub_menu) {
             foreach ($Index->main_sub_menu as $item) {
                 if (isset($item[1], $item[1]['class']) && $item[1]['class'] == 'uk-active') {
                     if ($Index->main_menu_more) {
                         $item[0] .= ' ' . h::icon('caret-down');
                     }
                     $item[1]['class'] = trim(str_replace('uk-active', '', $item[1]['class']));
                     $this->main_sub_menu .= h::{'li.uk-active[data-uk-dropdown=]'}(h::a($item) . ($Index->main_menu_more ? h::{'div.uk-dropdown.uk-dropdown-small ul.uk-nav.uk-nav-dropdown li| a'}($Index->main_menu_more) : ''));
                 } else {
                     $this->main_sub_menu .= h::{'li a'}($item);
                 }
             }
         }
     } elseif (!$this->main_menu && $Index->main_menu_more) {
         $this->main_menu = h::{'li| a'}($Index->main_menu_more);
     }
     /**
      * Substitution of information into template
      */
     $this->Html = str_replace(['<!--pre_Html-->', '<!--head-->', '<!--pre_Body-->', '<!--header-->', '<!--main-menu-->', '<!--main-sub-menu-->', '<!--main-menu-more-->', '<!--user-avatar-image-->', '<!--header_info-->', '<!--left_blocks-->', '<!--top_blocks-->', '<!--content-->', '<!--bottom_blocks-->', '<!--right_blocks-->', '<!--footer-->', '<!--post_Body-->', '<!--post_Html-->'], [$this->pre_Html, h::level($this->Head, $this->level['Head']), h::level($this->pre_Body, $this->level['pre_Body']), h::level($this->Header, $this->level['Header']), h::level($this->main_menu, $this->level['main_menu']), h::level($this->main_sub_menu, $this->level['main_sub_menu']), h::level($this->main_menu_more, $this->level['main_menu_more']), $this->user_avatar_image, h::level($this->header_info, $this->level['header_info']), h::level($this->Left, $this->level['Left']), h::level($this->Top, $this->level['Top']), h::level($this->Content, $this->level['Content']), h::level($this->Bottom, $this->level['Bottom']), h::level($this->Right, $this->level['Right']), h::level($this->Footer, $this->level['Footer']), h::level($this->post_Body, $this->level['post_Body']), $this->post_Html], $this->Html);
     return $this;
 }
Example #9
0
 /**
  * Confirmation of password restoring process
  *
  * @param string		$key
  *
  * @return array|bool			array('id' => <i>id</i>, 'password' => <i>password</i>) or <b>false</b> on failure
  */
 function restore_password_confirmation($key)
 {
     if (!is_md5($key)) {
         return false;
     }
     $id = $this->db_prime()->qfs(["SELECT `id`\n\t\t\tFROM `[prefix]users`\n\t\t\tWHERE\n\t\t\t\t`reg_key`\t= '%s' AND\n\t\t\t\t`status`\t= '%s'\n\t\t\tLIMIT 1", $key, self::STATUS_ACTIVE]);
     if (!$id) {
         return false;
     }
     $data = $this->get('data', $id);
     if (!isset($data['restore_until'])) {
         return false;
     } elseif ($data['restore_until'] < TIME) {
         unset($data['restore_until']);
         $this->set('data', $data, $id);
         return false;
     }
     unset($data['restore_until']);
     $Config = Config::instance();
     $password = password_generate($Config->core['password_min_length'], $Config->core['password_min_strength']);
     $this->set(['password_hash' => hash('sha512', hash('sha512', $password) . Core::instance()->public_key), 'data' => $data], null, $id);
     $this->add_session($id);
     return ['id' => $id, 'password' => $password];
 }
Example #10
0
$Config = Config::instance();
$L = Language::instance();
$Page = Page::instance();
$rc = $Config->route;
$ajax = $Config->server['ajax'];
if (isset($rc[2])) {
    switch ($rc[2]) {
        case 'clean_cache':
            if ($Cache->clean()) {
                $Cache->disable();
                $Page->content($ajax ? _json_encode(h::{'p.uk-alert.uk-alert-success'}($L->done)) : 1);
            } else {
                $Page->content($ajax ? _json_encode(h::{'p.uk-alert.uk-alert-danger'}($L->error)) : 0);
            }
            break;
        case 'clean_pcache':
            if (clean_pcache()) {
                if (!isset($rc[3])) {
                    time_limit_pause();
                    Core::instance()->api_request('System/admin/cache/clean_pcache/api');
                    time_limit_pause(false);
                }
                $Page->content($ajax ? _json_encode(h::{'p.uk-alert.uk-alert-success'}($L->done)) : 1);
            } else {
                $Page->content($ajax ? _json_encode(h::{'p.uk-alert.uk-alert-danger'}($L->error)) : 0);
            }
            break;
    }
} else {
    $Page->content($ajax ? _json_encode(h::{'p.uk-alert.uk-alert-danger'}($L->error)) : 0);
}
Example #11
0
/**
 * Check dependencies for new component (during installation/updating/enabling)
 *
 * @param string		$name	Name of new component
 * @param string		$type	Type of new component module|plugin
 * @param null|string	$dir	Path to new component (if null - component should be found among installed)
 * @param string		$mode	Mode of checking for modules install|update|enable
 *
 * @return bool
 */
function check_dependencies($name, $type, $dir = null, $mode = 'enable')
{
    if (!$dir) {
        switch ($type) {
            case 'module':
                $dir = MODULES . "/{$name}";
                break;
            case 'plugin':
                $dir = PLUGINS . "/{$name}";
                break;
            default:
                return false;
        }
    }
    if (!file_exists("{$dir}/meta.json")) {
        return true;
    }
    $meta = file_get_json("{$dir}/meta.json");
    $Config = Config::instance();
    $Core = Core::instance();
    $L = Language::instance();
    $Page = Page::instance();
    if (isset($meta['db_support']) && !empty($meta['db_support'])) {
        $return = false;
        if (in_array($Core->db_type, $meta['db_support'])) {
            $return = true;
        } else {
            foreach ($Config->db as $database) {
                if (isset($database['type']) && in_array($database['type'], $meta['db_support'])) {
                    $return = true;
                    break;
                }
            }
            unset($database);
        }
        if (!$return) {
            $Page->warning($L->compatible_databases_not_found(implode('", "', $meta['db_support'])));
        } elseif (!$Config->core['simple_admin_mode']) {
            $Page->success($L->compatible_databases(implode('", "', $meta['db_support'])));
        }
    } else {
        $return = true;
    }
    if (isset($meta['storage_support']) && !empty($meta['storage_support'])) {
        $return_s = false;
        if (in_array($Core->storage_type, $meta['storage_support'])) {
            $return_s = true;
        } else {
            foreach ($Config->storage as $storage) {
                if (in_array($storage['connection'], $meta['storage_support'])) {
                    $return_s = true;
                    break;
                }
            }
            unset($storage);
        }
        if (!$return_s) {
            $Page->warning($L->compatible_storages_not_found(implode('", "', $meta['storage_support'])));
        } elseif (!$Config->core['simple_admin_mode']) {
            $Page->success($L->compatible_storages(implode('", "', $meta['storage_support'])));
        }
        $return = $return && $return_s;
        unset($return_s);
    }
    $provide = [];
    $require = [];
    $conflict = [];
    if (isset($meta['provide'])) {
        $provide = (array) $meta['provide'];
    }
    if (isset($meta['require']) && !empty($meta['require'])) {
        $require = dep_normal((array) $meta['require']);
    }
    if (isset($meta['conflict']) && !empty($meta['conflict'])) {
        $conflict = dep_normal((array) $meta['conflict']);
    }
    unset($meta);
    /**
     * Checking for compatibility with modules
     */
    $return_m = true;
    foreach ($Config->components['modules'] as $module => $module_data) {
        /**
         * If module uninstalled, disabled (in enable check mode), module name is the same as checked or meta.json file absent
         * Then skip this module
         */
        if (!file_exists(MODULES . "/{$module}/meta.json")) {
            continue;
        }
        $module_meta = file_get_json(MODULES . "/{$module}/meta.json");
        if ($module_data['active'] == -1 || $mode == 'enable' && $module_data['active'] == 0 || $module == $name && $type == 'module') {
            /**
             * If module updates, check update possibility from current version
             */
            if ($module == $name && $type == 'module' && $mode == 'update' && isset($meta['update_from']) && version_compare($meta['update_from_version'], $module_meta['version'], '>')) {
                if ($return_m) {
                    $Page->warning($L->dependencies_not_satisfied);
                }
                $Page->warning($L->module_cant_be_updated_from_version_to_supported_only($module, $module_meta['version'], $meta['version'], $meta['update_from_version']));
                return false;
            }
            continue;
        }
        /**
         * If some module already provides the same functionality
         */
        if (!empty($provide) && isset($module_meta['provide']) && !empty($module_meta['provide']) && ($intersect = array_intersect($provide, (array) $module_meta['provide']))) {
            if ($return_m) {
                $Page->warning($L->dependencies_not_satisfied);
            }
            $return_m = false;
            $Page->warning($L->module_already_provides_functionality($module, implode('", "', $intersect)));
        }
        unset($intersect);
        /**
         * Checking for required packages
         */
        if (!empty($require) && isset($require[$module_meta['package']])) {
            if (version_compare($module_meta['version'], $require[$module_meta['package']][1], $require[$module_meta['package']][0])) {
                unset($require[$module_meta['package']]);
            } else {
                if ($return_m) {
                    $Page->warning($L->dependencies_not_satisfied);
                }
                $return_m = false;
                $Page->warning($L->unsatisfactory_version_of_the_module($module, $require[$module_meta['package']][0] . ' ' . $require[$module_meta['package']][1], $module_meta['version']));
            }
        }
        /**
         * Checking for required functionality
         */
        if (!empty($require) && isset($module_meta['provide']) && !empty($module_meta['provide'])) {
            foreach ((array) $module_meta['provide'] as $p) {
                unset($require[$p]);
            }
            unset($p);
        }
        /**
         * Checking for conflict packages
         */
        if (!empty($conflict) && isset($module_meta['conflict']) && !empty($module_meta['conflict'])) {
            if (version_compare($module_meta['version'], $conflict[$module_meta['package']][1], $conflict[$module_meta['package']][0])) {
                if ($return_m) {
                    $Page->warning($L->dependencies_not_satisfied);
                }
                $return_m = false;
                $Page->warning($L->conflict_module($module_meta['package'], $module) . ($conflict[$module_meta['package']][1] != 0 ? $L->compatible_package_versions($require[$module_meta['package']][0] . ' ' . $require[$module_meta['package']][1]) : $L->package_is_incompatible($module_meta['package'])));
            }
        }
    }
    $return = $return && $return_m;
    unset($return_m, $module, $module_data, $module_meta);
    /**
     * Checking for compatibility with plugins
     */
    $return_p = true;
    foreach ($Config->components['plugins'] as $plugin) {
        if ($plugin == $name && $type == 'plugin' || !file_exists(PLUGINS . "/{$plugin}/meta.json")) {
            continue;
        }
        $plugin_meta = file_get_json(PLUGINS . "/{$plugin}/meta.json");
        /**
         * If some plugin already provides the same functionality
         */
        if (!empty($provide) && isset($plugin_meta['provide']) && is_array($plugin_meta['provide']) && !empty($plugin_meta['provide']) && ($intersect = array_intersect($provide, $plugin_meta['provide']))) {
            if ($return_p) {
                $Page->warning($L->dependencies_not_satisfied);
            }
            $return_p = false;
            $Page->warning($L->plugin_already_provides_functionality($plugin, implode('", "', $intersect)));
        }
        unset($intersect);
        /**
         * Checking for required packages
         */
        if (isset($require[$plugin_meta['package']])) {
            if (version_compare($plugin_meta['version'], $require[$plugin_meta['package']][1], $require[$plugin_meta['package']][0])) {
                unset($require[$plugin_meta['package']]);
            } else {
                if ($return_p) {
                    $Page->warning($L->dependencies_not_satisfied);
                }
                $return_p = false;
                $Page->warning($L->unsatisfactory_version_of_the_plugin($plugin, $require[$plugin_meta['package']][0] . ' ' . $require[$plugin_meta['package']][1], $plugin_meta['version']));
            }
        }
        /**
         * Checking for required functionality
         */
        if (!empty($require) && isset($plugin_meta['provide']) && !empty($plugin_meta['provide'])) {
            foreach ((array) $plugin_meta['provide'] as $p) {
                unset($require[$p]);
            }
            unset($p);
        }
        /**
         * Checking for conflict packages
         */
        if (isset($plugin_meta['conflict']) && is_array($plugin_meta['conflict']) && !empty($plugin_meta['conflict'])) {
            if (version_compare($plugin_meta['version'], $conflict[$plugin_meta['package']][1], $conflict[$plugin_meta['package']][0])) {
                if ($return_p) {
                    $Page->warning($L->dependencies_not_satisfied);
                }
                $return_p = false;
                $Page->warning($L->conflict_plugin($plugin) . ($conflict[$plugin_meta['package']][1] != 0 ? $L->compatible_package_versions($require[$plugin_meta['package']][0] . ' ' . $require[$plugin_meta['package']][1]) : $L->package_is_incompatible($plugin_meta['package'])));
            }
        }
    }
    $return = $return && $return_p;
    unset($return_p, $plugin, $plugin_meta, $provide, $conflict);
    /**
     * If some required packages missing
     */
    $return_r = true;
    if (!empty($require)) {
        foreach ($require as $package => $details) {
            if ($return_r) {
                $Page->warning($L->dependencies_not_satisfied);
            }
            $return_r = false;
            $Page->warning($L->package_or_functionality_not_found($details[1] ? "{$package} {$details['0']} {$details['1']}" : $package));
        }
    }
    return $return && $return_r;
}
Example #12
0
 /**
  * Set basic language
  */
 protected function construct()
 {
     $this->fixed_language = FIXED_LANGUAGE;
     $this->change(Core::instance()->language);
 }
Example #13
0
 function __construct()
 {
     $this->cache_size = Core::instance()->cache_size * 1024 * 1024;
 }