Ejemplo n.º 1
0
 /**
  * Translate error message
  * 
  * @param string $string    String to translate
  * @param array $opt        Array of arguments to pass to the translation (like field name)
  * @return string           The translated string if exists else the original string
  */
 protected function translate($string, $opt = array())
 {
     $args = !empty($this->fullName) ? array('name' => $this->fullName) : array('name' => $this->fieldName);
     $args = array_merge($args, $opt);
     $moduleName = get_module_name(get_class($this));
     if ($moduleName !== null) {
         $file = MODULES_DIR . DS . $moduleName . DS . 'i18n' . DS . 'rules.' . I18n::getLang() . '.xml';
     } else {
         $file = FW_DIR . DS . 'form' . DS . 'check' . DS . 'i18n' . DS . 'rules.' . I18n::getLang() . '.xml';
     }
     return I18n::t($file, $string, $args, 'en', 'rules', true);
 }
require_once "DaemonWrapper.php";
$daemon = new DaemonWrapper("apns_push");
$daemon->start($argv);
require_once 'apns_lib.php';
$apns_server = new ApplePushServersPool(APNS_CONNECTIONS_LIMIT);
// this is a daemon so loop forever
d_echo("push daemon activated");
while ($daemon->sleep(APNS_PUSH_REST_TIME)) {
    d_echo("waiting for messages to send...", False);
    db::ping();
    $messages = APNS_DB::get_unsent_notifications();
    while ($message = APNS_DB::fetch_notification($messages)) {
        $data = $message['payload'];
        $device_id = $message['device_id'];
        $device = APNS_DB::get_device($device_id);
        $module_name = get_module_name($message['tag']);
        // we only send to devices that have not been deactived
        // and we only send to enabled modules
        if ($device['active'] == 1 && APNS_DB::is_module_enabled($device_id, $module_name)) {
            // need to compute the number of unread messages
            // to be displayed on "badge" on the device
            $unreads = $device['unread_notifications'];
            // look for an old version of this message
            $old_position = array_search($message['tag'], $unreads);
            if ($old_position !== FALSE) {
                array_splice($unreads, $old_position, 1);
            }
            if (intval($message['has_badge'])) {
                $unreads[] = $message['tag'];
            } else {
                $data->noBadge = 1;
Ejemplo n.º 3
0
    import('io/filesystem/file');
    $lock_file = new File(PATH_TO_ROOT . '/cache/changeday_lock');
    if (!$lock_file->exists()) {
        $lock_file->write('');
        $lock_file->flush();
    }
    $lock_file->lock(false);
    $yesterday_timestamp = time() - 86400;
    if ((int) $Sql->query("\n\t    SELECT COUNT(*)\n            FROM " . DB_TABLE_STATS . "\n            WHERE stats_year = '" . gmdate_format('Y', $yesterday_timestamp, TIMEZONE_SYSTEM) . "' AND\n                stats_month = '" . gmdate_format('m', $yesterday_timestamp, TIMEZONE_SYSTEM) . "' AND\n                stats_day = '" . gmdate_format('d', $yesterday_timestamp, TIMEZONE_SYSTEM) . "'", __LINE__, __FILE__) == 0) {
        $Cache->generate_file('day');
        require_once PATH_TO_ROOT . '/kernel/changeday.php';
        change_day();
    }
    $lock_file->close();
}
define('MODULE_NAME', get_module_name());
if (isset($MODULES[MODULE_NAME])) {
    if ($MODULES[MODULE_NAME]['activ'] == 0) {
        $Errorh->handler('e_unactivated_module', E_USER_REDIRECT);
    } else {
        if (!$User->check_auth($MODULES[MODULE_NAME]['auth'], ACCESS_MODULE)) {
            $Errorh->handler('e_auth', E_USER_REDIRECT);
        }
    }
} elseif (!in_array(MODULE_NAME, array('member', 'admin', 'kernel', ''))) {
    $array_info_module = load_ini_file(PATH_TO_ROOT . '/' . MODULE_NAME . '/lang/', get_ulang());
    if (!empty($array_info_module['name'])) {
        $Errorh->handler('e_uninstalled_module', E_USER_REDIRECT);
    }
}
if ($User->check_level(MEMBER_LEVEL)) {
Ejemplo n.º 4
0
 foreach ($paths as $path) {
     $cmbMibs->addItem('', '---' . $path);
     foreach (glob($path . "/*.txt") as $filename) {
         $modulename = get_module_name($filename);
         if ($modulename) {
             $cmbMibs->addItem($modulename, $modulename);
         }
     }
     foreach (glob($path . "/*.mib") as $filename) {
         $modulename = get_module_name($filename);
         if ($modulename) {
             $cmbMibs->addItem($modulename, $modulename);
         }
     }
     foreach (glob($path . "/*.my") as $filename) {
         $modulename = get_module_name($filename);
         if ($modulename) {
             $cmbMibs->addItem($modulename, $modulename);
         }
     }
 }
 $form->addItem(array(_('MIB') . ':' . SPACE, $cmbMibs, SPACE));
 // server ip textbox
 $ipbServer = new CTextBox('server_ip', $server_ip);
 $form->addItem(array(_('Host') . ':' . SPACE, $ipbServer, SPACE));
 // server port hidden
 $hidPort = new CTag('server_port', $server_port);
 $form->addItem(array($hidPort));
 // snmp version selector
 $cmbSnmpVersion = new CComboBox('snmp_version', $snmp_version);
 foreach (array(ITEM_TYPE_SNMPV1, ITEM_TYPE_SNMPV2C) as $v) {
Ejemplo n.º 5
0
function get_local_templates_dir()
{
    global $arrConf;
    $module_name = get_module_name();
    //folder path for custom templates
    $base_dir = $_SERVER['DOCUMENT_ROOT'];
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    return "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
}