function osTicketSession($ttl = 0)
 {
     $this->ttl = $ttl ?: ini_get('session.gc_maxlifetime') ?: SESSION_TTL;
     // Set osTicket specific session name.
     session_name('OSTSESSID');
     // Forced cleanup on shutdown
     register_shutdown_function('session_write_close');
     // Set session cleanup time to match TTL
     ini_set('session.gc_maxlifetime', $ttl);
     if (OsticketConfig::getDBVersion()) {
         return session_start();
     }
     # Cookies
     // Avoid setting a cookie domain without a dot, thanks
     // http://stackoverflow.com/a/1188145
     $domain = null;
     if (isset($_SERVER['HTTP_HOST']) && strpos($_SERVER['HTTP_HOST'], '.') !== false && !Validator::is_ip($_SERVER['HTTP_HOST'])) {
         // Remote port specification, as it will make an invalid domain
         list($domain) = explode(':', $_SERVER['HTTP_HOST']);
     }
     session_set_cookie_params($ttl, ROOT_PATH, $domain, osTicket::is_https());
     //Set handlers.
     session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
     //Start the session.
     session_start();
 }
Example #2
0
 function osTicketSession($ttl = 0)
 {
     $this->ttl = $ttl ?: ini_get('session.gc_maxlifetime') ?: SESSION_TTL;
     // Set osTicket specific session name.
     session_name('OSTSESSID');
     // Forced cleanup on shutdown
     register_shutdown_function('session_write_close');
     // Set session cleanup time to match TTL
     ini_set('session.gc_maxlifetime', $ttl);
     if (OsticketConfig::getDBVersion()) {
         return session_start();
     }
     # Cookies
     // Avoid setting a cookie domain without a dot, thanks
     // http://stackoverflow.com/a/1188145
     $domain = null;
     if (isset($_SERVER['HTTP_HOST']) && strpos($_SERVER['HTTP_HOST'], '.') !== false && !Validator::is_ip($_SERVER['HTTP_HOST'])) {
         // Remote port specification, as it will make an invalid domain
         list($domain) = explode(':', $_SERVER['HTTP_HOST']);
     }
     session_set_cookie_params($ttl, ROOT_PATH, $domain, osTicket::is_https());
     if (!defined('SESSION_BACKEND')) {
         define('SESSION_BACKEND', 'db');
     }
     try {
         $bk = SESSION_BACKEND;
         if (!class_exists(self::$backends[$bk])) {
             $bk = 'db';
         }
         $this->backend = new self::$backends[$bk]($this->ttl);
     } catch (Exception $x) {
         // Use the database for sessions
         trigger_error($x->getMessage(), E_USER_WARNING);
         $this->backend = new self::$backends['db']($this->ttl);
     }
     if ($this->backend instanceof SessionBackend) {
         // Set handlers.
         session_set_save_handler(array($this->backend, 'open'), array($this->backend, 'close'), array($this->backend, 'read'), array($this->backend, 'write'), array($this->backend, 'destroy'), array($this->backend, 'gc'));
     }
     // Start the session.
     session_start();
 }
Example #3
0
?>
 <input type="hidden" name="do" value="mass_process" >
<input type="hidden" id="action" name="a" value="sort" >
 <table class="list" border="0" cellspacing="1" cellpadding="0" width="940">
    <caption><span style="display:inline-block;vertical-align:middle"><?php 
echo $showing;
?>
</span>
    <div class="pull-right">Sorting Mode:
        <select name="help_topic_sort_mode" onchange="javascript:
    var $form = $(this).closest('form');
    $form.find('input[name=a]').val('sort');
    $form.submit();
">
<?php 
foreach (OsticketConfig::allTopicSortModes() as $i => $m) {
    echo sprintf('<option value="%s"%s>%s</option>', $i, $i == $cfg->getTopicSortMode() ? ' selected="selected"' : '', $m);
}
?>
        </select>
    </div>
    </caption>
    <thead>
        <tr>
            <th width="7" style="height:20px;">&nbsp;</th>
            <th style="padding-left:4px;vertical-align:middle" width="360">Help Topic</th>
            <th style="padding-left:4px;vertical-align:middle" width="80">Status</th>
            <th style="padding-left:4px;vertical-align:middle" width="100">Type</th>
            <th style="padding-left:4px;vertical-align:middle" width="100">Priority</th>
            <th style="padding-left:4px;vertical-align:middle" width="160">Department</th>
            <th style="padding-left:4px;vertical-align:middle" width="150" nowrap>Last Updated</th>
Example #4
0
 /**
  * Loads data from the I18N_DIR for the target language into the
  * database. This is intended to be done at the time of installation;
  * however, care should be taken in this process to ensure that the
  * process could be repeated if an administrator wanted to change the
  * system language and reload the data.
  */
 function loadDefaultData()
 {
     # notrans -- do not translate the contents of this array
     $models = array('department.yaml' => 'Dept::create', 'sla.yaml' => 'SLA::create', 'form.yaml' => 'DynamicForm::create', 'list.yaml' => 'DynamicList::create', 'help_topic.yaml' => 'Topic::create', 'filter.yaml' => 'Filter::create', 'team.yaml' => 'Team::create', 'organization.yaml' => 'Organization::__create', 'ticket_status.yaml' => 'TicketStatus::__create', 'group.yaml' => 'Group::create', 'file.yaml' => 'AttachmentFile::create', 'sequence.yaml' => 'Sequence::__create');
     $errors = array();
     foreach ($models as $yaml => $m) {
         if ($objects = $this->getTemplate($yaml)->getData()) {
             foreach ($objects as $o) {
                 if ($m && is_callable($m)) {
                     @call_user_func_array($m, array($o, &$errors));
                 }
                 // TODO: Add a warning to the success page for errors
                 //       found here
                 $errors = array();
             }
         }
     }
     // Priorities
     $priorities = $this->getTemplate('priority.yaml')->getData();
     foreach ($priorities as $name => $info) {
         $sql = 'INSERT INTO ' . PRIORITY_TABLE . ' SET priority=' . db_input($name) . ', priority_id=' . db_input($info['priority_id']) . ', priority_desc=' . db_input($info['priority_desc']) . ', priority_color=' . db_input($info['priority_color']) . ', priority_urgency=' . db_input($info['priority_urgency']);
         db_query($sql);
     }
     // Configuration
     require_once INCLUDE_DIR . 'class.config.php';
     if (($tpl = $this->getTemplate('config.yaml')) && ($data = $tpl->getData())) {
         foreach ($data as $section => $items) {
             $_config = new Config($section);
             foreach ($items as $key => $value) {
                 $_config->set($key, $value);
             }
         }
     }
     // Load core config
     $_config = new OsticketConfig();
     // Determine reasonable default max_file_size
     $max_size = Format::filesize2bytes(strtoupper(ini_get('upload_max_filesize')));
     $val = (int) $max_size / 2;
     $po2 = 1;
     while ($po2 < $val) {
         $po2 <<= 1;
     }
     $_config->set('max_file_size', $po2);
     // Pages and content
     foreach (array('landing', 'thank-you', 'offline', 'registration-staff', 'pwreset-staff', 'banner-staff', 'registration-client', 'pwreset-client', 'banner-client', 'registration-confirm', 'registration-thanks', 'access-link') as $type) {
         $tpl = $this->getTemplate("templates/page/{$type}.yaml");
         if (!($page = $tpl->getData())) {
             continue;
         }
         $sql = 'INSERT INTO ' . PAGE_TABLE . ' SET type=' . db_input($type) . ', name=' . db_input($page['name']) . ', body=' . db_input($page['body']) . ', lang=' . db_input($tpl->getLang()) . ', notes=' . db_input($page['notes']) . ', created=NOW(), updated=NOW(), isactive=1';
         if (db_query($sql) && ($id = db_insert_id()) && in_array($type, array('landing', 'thank-you', 'offline'))) {
             $_config->set("{$type}_page_id", $id);
         }
     }
     // Default Language
     $_config->set('system_language', $this->langs[0]);
     // content_id defaults to the `id` field value
     db_query('UPDATE ' . PAGE_TABLE . ' SET content_id=id');
     // Canned response examples
     if (($tpl = $this->getTemplate('templates/premade.yaml')) && ($canned = $tpl->getData())) {
         foreach ($canned as $c) {
             if (($id = Canned::create($c, $errors)) && isset($c['attachments'])) {
                 $premade = Canned::lookup($id);
                 foreach ($c['attachments'] as $a) {
                     $premade->attachments->save($a, false);
                 }
             }
         }
     }
     // Email templates
     // TODO: Lookup tpl_id
     if ($objects = $this->getTemplate('email_template_group.yaml')->getData()) {
         foreach ($objects as $o) {
             $o['lang_id'] = $this->langs[0];
             $tpl = EmailTemplateGroup::create($o, $errors);
         }
     }
     // This shouldn't be necessary
     $tpl = EmailTemplateGroup::lookup(1);
     foreach ($tpl::$all_names as $name => $info) {
         if (($tp = $this->getTemplate("templates/email/{$name}.yaml")) && ($t = $tp->getData())) {
             $t['tpl_id'] = $tpl->getId();
             $t['code_name'] = $name;
             $id = EmailTemplate::create($t, $errors);
             if ($id && ($template = EmailTemplate::lookup($id)) && ($ids = Draft::getAttachmentIds($t['body']))) {
                 $template->attachments->upload($ids, true);
             }
         }
     }
 }