}
    public static function add_help($caption, $file, $open = null, $c = null)
    {
        if ($caption instanceof Module) {
            if (!isset($open)) {
                trigger_error('Missing argument 2 for Module::help()');
            }
            $mod = $caption;
            $caption = $file;
            $file = $mod->get_module_dir() . 'help/' . $open;
            $open = $c;
        }
        if ($open == null) {
            $open = false;
        }
        $_SESSION['client']['help'][$caption] = array($open, $file);
    }
    public static function clean_help()
    {
        $_SESSION['client']['help'] = array();
    }
    public static function get_href()
    {
        return 'href="' . self::Instance()->get_module_dir() . 'help.php?cid=' . CID . '" target="_blank"';
        // 15:20
    }
}
Module::register_method('help', array('Base_MainModuleIndicatorCommon', 'add_help'));
//interactive ts
on_init(array('Base_MainModuleIndicatorCommon', 'clean_help'));
Exemplo n.º 2
0
        $ls_langs = explode(',', @file_get_contents(DATA_DIR . '/Base_Lang/cache'));
        $all_langs = self::get_all_languages();
        $ret = array();
        foreach ($ls_langs as $lang_code) {
            if (isset($all_langs[$lang_code])) {
                $ret[$lang_code] = $all_langs[$lang_code] . " ({$lang_code})";
            }
        }
        return $ret;
    }
}
function __($string, $arg2 = array())
{
    return Base_LangCommon::translate($string, $arg2);
}
function _V($string, $arg2 = array())
{
    // ****** _V Definition - variable translations
    return Base_LangCommon::translate($string, $arg2);
}
function _M($string, $arg2 = array())
{
    // ****** _M Definition - mark translations - doesn't translate, only marks string to translate
    return Base_LangCommon::translate($string, $arg2, false);
}
Module::register_method('t', array('Base_LangCommon', 'ts'));
// DEPRECATED
Module::register_method('ht', array('Base_LangCommon', 'ts'));
// DEPRECATED
on_init(array('Base_LangCommon', 'load'));
Exemplo n.º 3
0
    public static function homepage_icon()
    {
        Utils_ShortcutCommon::add(array('Ctrl', 'H'), 'function(){' . Module::create_href_js(array('Base_HomePage_load' => '1')) . '}');
    }
    public static function get_my_homepage()
    {
        $clearance = Base_AclCommon::get_clearance();
        $sql = 'SELECT home_page FROM base_home_page AS bhp WHERE ';
        $vals = array();
        if ($clearance != null) {
            $sql .= ' NOT EXISTS (SELECT * FROM base_home_page_clearance WHERE home_page_id=bhp.id AND ' . implode(' AND ', array_fill(0, count($clearance), 'clearance!=%s')) . ')';
            $vals = array_values($clearance);
        } else {
            $sql .= ' NOT EXISTS (SELECT * FROM base_home_page_clearance WHERE home_page_id=bhp.id)';
        }
        $sql .= ' ORDER BY priority';
        $page = DB::GetOne($sql, $vals);
        $pages = self::get_home_pages();
        return isset($pages[$page]) ? $pages[$page] : array();
    }
    public static function get_href()
    {
        return Module::create_href(array('Base_HomePage_load' => '1'));
    }
}
if (isset($_REQUEST['Base_HomePage_load'])) {
    unset($_REQUEST['Base_HomePage_load']);
    $_REQUEST = array_merge($_REQUEST, Base_BoxCommon::create_href_array(null, Base_BoxCommon::get_main_module_name()));
}
on_init(array('Base_HomePageCommon', 'homepage_icon'));
Exemplo n.º 4
0
    {
        return __('Simple aplet which displays your last login information (date, IP adress)');
    }
    public static function admin_caption()
    {
        return array('label' => __('Login Audit'), 'section' => __('User Management'));
    }
    public static function body_access()
    {
        return Acl::is_user();
    }
    public static function init()
    {
        if ((!isset($_SESSION['base_login_audit']) || !isset($_SESSION['base_login_audit_user']) || $_SESSION['base_login_audit_user'] != Acl::get_user()) && Acl::is_user()) {
            $now = time();
            $remote_address = get_client_ip_address();
            $remote_host = gethostbyaddr($remote_address);
            DB::Execute('INSERT INTO base_login_audit(user_login_id,start_time,end_time,ip_address,host_name) VALUES(%d,%T,%T,%s,%s)', array(Acl::get_user(), $now, $now, $remote_address, $remote_host));
            $_SESSION['base_login_audit'] = DB::Insert_ID('base_login_audit', 'id');
            $_SESSION['base_login_audit_user'] = Acl::get_user();
        }
    }
    public static function update()
    {
        if (isset($_SESSION['base_login_audit']) && isset($_SESSION['base_login_audit_user']) && $_SESSION['base_login_audit_user'] == Acl::get_user()) {
            DB::Execute('UPDATE base_login_audit SET end_time=%T WHERE id=%d', array(time(), $_SESSION['base_login_audit']));
        }
    }
}
on_init(array('CRM_LoginAuditCommon', 'init'));
register_shutdown_function(array('CRM_LoginAuditCommon', 'update'));
Exemplo n.º 5
0
 public function construct()
 {
     $this->tb = $this->init_module(Utils_TabbedBrowser::module_name());
     on_init(array('Base_ActionBarCommon', 'show_quick_access_shortcuts'), array(false));
 }
Exemplo n.º 6
0
            if (preg_match('/^\\-?\\d+$/', $int)) {
                return array($int . '.' . $fraction, $cur_id);
            }
        }
        return null;
    }
    private static $cache;
    public static function load_cache()
    {
        if (!isset(self::$cache)) {
            self::$cache = DB::GetAssoc('SELECT id,pos_before,symbol,decimals,code,thousand_sign,decimal_sign FROM utils_currency');
        }
    }
    public static function load_js()
    {
        self::load_cache();
        load_js('modules/Utils/CurrencyField/currency.js');
        $currencies = Utils_CurrencyFieldCommon::get_all_currencies();
        $js = 'Utils_CurrencyField.currencies=new Array();';
        foreach ($currencies as $k => $v) {
            $symbol = Utils_CurrencyFieldCommon::get_symbol($k);
            $position = Utils_CurrencyFieldCommon::get_symbol_position($k);
            $curr_format = '-?([0-9]*)\\' . Utils_CurrencyFieldCommon::get_decimal_point($k) . '?[0-9]{0,' . Utils_CurrencyFieldCommon::get_precission($k) . '}';
            $js .= 'Utils_CurrencyField.currencies[' . $k . ']={' . '"decp":"' . Utils_CurrencyFieldCommon::get_decimal_point($k) . '",' . '"thop":"' . Utils_CurrencyFieldCommon::get_thousand_point($k) . '",' . '"symbol_before":"' . ($position ? $symbol : '') . '",' . '"symbol_after":"' . (!$position ? $symbol : '') . '",' . '"dec_digits":' . Utils_CurrencyFieldCommon::get_precission($k) . ',' . '"regex":' . json_encode($curr_format) . '};';
        }
        eval_js_once($js);
    }
}
$GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES']['currency'] = array('modules/Utils/CurrencyField/currency.php', 'HTML_QuickForm_currency');
on_init(array('Utils_CurrencyFieldCommon', 'load_js'));
Exemplo n.º 7
0
                        $msgs[] = array('title' => $title, 'body' => $body);
                    }
                }
            }
            $remote_token = md5($uid . '#' . Base_UserCommon::get_user_login($uid) . '#' . $token);
            $ret[$remote_token] = $msgs ? $msgs : '0';
            $map[$remote_token] = $token;
        }
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://telegram.epesicrm.com/");
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($ret));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $status = curl_exec($ch);
        curl_close($ch);
        $status = @json_decode($status);
        if (is_array($status)) {
            foreach ($status as $remove) {
                if (isset($map[$remove])) {
                    DB::Execute('UPDATE base_notify SET telegram=0 WHERE token=%s', array($map[$remove]));
                    unset($notified_cache[$map[$remove]]);
                }
            }
            foreach ($notified_cache as $token => $nc) {
                Base_NotifyCommon::set_notified_cache($nc, $token, $refresh_time);
            }
        }
    }
}
on_init(array('Base_NotifyCommon', 'init'));
Exemplo n.º 8
0
 public static function process($url, $history_call = false, $refresh = false)
 {
     if (MODULE_TIMES) {
         $time = microtime(true);
     }
     $url = str_replace('&', '&', $url);
     //do we need this if we set arg_separator.output to &?
     if ($url) {
         $_POST = array();
         parse_str($url, $_POST);
         if (get_magic_quotes_gpc()) {
             $_POST = undoMagicQuotes($_POST);
         }
         $_GET = $_REQUEST =& $_POST;
     }
     ModuleManager::load_modules();
     self::check_firstrun();
     if ($history_call === '0') {
         History::clear();
     } elseif ($history_call) {
         History::set_id($history_call);
     }
     //on init call methods...
     $ret = on_init(null, null, null, true);
     foreach ($ret as $k) {
         call_user_func_array($k['func'], $k['args']);
     }
     $root =& ModuleManager::create_root();
     self::go($root);
     //go somewhere else?
     $loc = location(null, true);
     //on exit call methods...
     $ret = on_exit(null, null, null, true, $loc === false);
     foreach ($ret as $k) {
         call_user_func_array($k['func'], $k['args']);
     }
     if ($loc !== false) {
         if (isset($_REQUEST['__action_module__'])) {
             $loc['__action_module__'] = $_REQUEST['__action_module__'];
         }
         //clean up
         foreach (self::$content as $k => $v) {
             unset(self::$content[$k]);
         }
         foreach (self::$jses as $k => $v) {
             if ($v[1]) {
                 unset(self::$jses[$k]);
             }
         }
         //go
         $loc['__location'] = microtime(true);
         return self::process(http_build_query($loc), false, true);
     }
     $debug = '';
     if (DEBUG && ($debug_diff = @(include_once 'tools/Diff.php'))) {
         require_once 'tools/Text/Diff/Renderer/inline.php';
         $diff_renderer = new Text_Diff_Renderer_inline();
     }
     //clean up old modules
     if (isset($_SESSION['client']['__module_content__'])) {
         $to_cleanup = array_keys($_SESSION['client']['__module_content__']);
         foreach ($to_cleanup as $k) {
             $mod = ModuleManager::get_instance($k);
             if ($mod === null) {
                 $xx = explode('/', $k);
                 $yy = explode('|', $xx[count($xx) - 1]);
                 $mod = $yy[0];
                 if (is_callable(array($mod . 'Common', 'destroy'))) {
                     call_user_func(array($mod . 'Common', 'destroy'), $k, isset($_SESSION['client']['__module_vars__'][$k]) ? $_SESSION['client']['__module_vars__'][$k] : null);
                 }
                 if (DEBUG) {
                     $debug .= 'Clearing mod vars & module content ' . $k . '<br>';
                 }
                 unset($_SESSION['client']['__module_vars__'][$k]);
                 unset($_SESSION['client']['__module_content__'][$k]);
             }
         }
     }
     $reloaded = array();
     foreach (self::$content as $k => $v) {
         $reload = $v['module']->get_reload();
         $parent = $v['module']->get_parent_path();
         if (DEBUG && REDUCING_TRANSFER) {
             $debug .= '<hr style="height: 3px; background-color:black">';
             $debug .= '<b> Checking ' . $k . ', &nbsp;&nbsp;&nbsp; parent=' . $v['module']->get_parent_path() . '</b><ul>' . '<li>Force - ' . (isset($reload) ? print_r($reload, true) : 'not set') . '</li>' . '<li>First display - ' . (isset($_SESSION['client']['__module_content__'][$k]) ? 'no</li>' . '<li>Content changed - ' . ($_SESSION['client']['__module_content__'][$k]['value'] !== $v['value'] ? 'yes' : 'no') . '</li>' . '<li>JS changed - ' . ($_SESSION['client']['__module_content__'][$k]['js'] !== $v['js'] ? 'yes' : 'no') : 'yes') . '</li>' . '<li>Parent reloaded - ' . (isset($reloaded[$parent]) ? 'yes' : 'no') . '</li>' . '<li>History call - ' . ($history_call ? 'yes' : 'no') . '</li>' . '</ul>';
         }
         if (!REDUCING_TRANSFER || (!isset($reload) && (!isset($_SESSION['client']['__module_content__'][$k]) || $_SESSION['client']['__module_content__'][$k]['value'] !== $v['value'] || $_SESSION['client']['__module_content__'][$k]['js'] !== $v['js']) || $history_call || $reload == true || isset($reloaded[$parent]))) {
             //force reload or parent reloaded
             if (DEBUG && isset($_SESSION['client']['__module_content__'])) {
                 $debug .= '<b>Reloading: ' . (isset($v['span']) ? ';&nbsp;&nbsp;&nbsp;&nbsp;span=' . $v['span'] . ',' : '') . '&nbsp;&nbsp;&nbsp;&nbsp;triggered=' . ($reload == true ? 'force' : 'auto') . ',&nbsp;&nbsp;</b><hr><b>New value:</b><br><pre>' . htmlspecialchars($v['value']) . '</pre>' . (isset($_SESSION['client']['__module_content__'][$k]['value']) ? '<hr><b>Old value:</b><br><pre>' . htmlspecialchars($_SESSION['client']['__module_content__'][$k]['value']) . '</pre>' : '');
                 if ($debug_diff && isset($_SESSION['client']['__module_content__'][$k]['value'])) {
                     $xxx = new Text_Diff(explode("\n", $_SESSION['client']['__module_content__'][$k]['value']), explode("\n", $v['value']));
                     $debug .= '<hr><b>Diff:</b><br><pre>' . $diff_renderer->render($xxx) . '</pre>';
                 }
                 $debug .= '<hr style="height: 5px; background-color:black">';
             }
             if (isset($v['span'])) {
                 self::text($v['value'], $v['span']);
             }
             if ($v['js']) {
                 self::js(join(";", $v['js']));
             }
             if (REDUCING_TRANSFER) {
                 $_SESSION['client']['__module_content__'][$k]['value'] = $v['value'];
                 $_SESSION['client']['__module_content__'][$k]['js'] = $v['js'];
             }
             $_SESSION['client']['__module_content__'][$k]['parent'] = $parent;
             $reloaded[$k] = true;
             if (method_exists($v['module'], 'reloaded')) {
                 $v['module']->reloaded();
             }
         }
     }
     foreach ($_SESSION['client']['__module_content__'] as $k => $v) {
         if (!array_key_exists($k, self::$content) && isset($reloaded[$v['parent']])) {
             if (DEBUG) {
                 $debug .= 'Reloading missing ' . $k . '<hr>';
             }
             if (isset($v['span'])) {
                 self::text($v['value'], $v['span']);
             }
             if (isset($v['js']) && $v['js']) {
                 self::js(join(";", $v['js']));
             }
             $reloaded[$k] = true;
         }
     }
     if (DEBUG) {
         $debug .= 'vars ' . CID . ': ' . print_r($_SESSION['client']['__module_vars__'], true) . '<br>';
         $debug .= 'user=' . Base_AclCommon::get_user() . '<br>';
         if (isset($_REQUEST['__action_module__'])) {
             $debug .= 'action module=' . $_REQUEST['__action_module__'] . '<br>';
         }
     }
     $debug .= self::debug();
     if (MODULE_TIMES) {
         foreach (self::$content as $k => $v) {
             $style = 'color:red;font-weight:bold';
             if ($v['time'] < 0.5) {
                 $style = 'color:orange;font-weight:bold';
             }
             if ($v['time'] < 0.05) {
                 $style = 'color:green;font-weight:bold';
             }
             $debug .= 'Time of loading module <b>' . $k . '</b>: <i>' . '<span style="' . $style . ';">' . number_format($v['time'], 4) . '</span>' . '</i><br>';
         }
         $debug .= 'Page renderered in ' . (microtime(true) - $time) . 's<hr>';
     }
     if (SQL_TIMES) {
         $debug .= '<font size="+1">QUERIES</font><br>';
         $queries = DB::GetQueries();
         $sum = 0;
         $qty = 0;
         foreach ($queries as $kk => $q) {
             $style = 'color:red;font-weight:bold';
             if ($q['time'] < 0.5) {
                 $style = 'color:orange;font-weight:bold';
             }
             if ($q['time'] < 0.05) {
                 $style = 'color:green';
             }
             for ($kkk = 0; $kkk < $kk; $kkk++) {
                 if ($queries[$kkk]['args'] == $q['args']) {
                     $style .= ';text-decoration:underline';
                 }
             }
             $debug .= '<span style="' . $style . ';">' . '<b>' . $q['func'] . '</b> ' . htmlspecialchars(var_export($q['args'], true)) . ' <i><b>' . number_format($q['time'], 4) . '</b></i>' . (isset($q['caller']) ? ', ' . $q['caller'] : '') . '<br>' . '</span>';
             $sum += $q['time'];
             $qty++;
         }
         $debug .= '<b>Number of queries:</b> ' . $qty . '<br>';
         $debug .= '<b>Queries times:</b> ' . $sum . '<br>';
     }
     if (!isset($_SESSION['client']['custom_debug']) || $debug != $_SESSION['client']['custom_debug']) {
         self::text($debug, 'debug');
         if ($debug) {
             Epesi::js("\$('debug_content').style.display='block';");
         }
         $_SESSION['client']['custom_debug'] = $debug;
     }
     if (!$history_call && !History::soft_call()) {
         History::set();
     }
     if (!$history_call) {
         self::js('Epesi.history_add(' . History::get_id() . ')');
     }
     self::send_output();
 }