Example #1
0
 public function parseParams()
 {
     $params = array();
     if ($this->uri) {
         $params = array_values(array_filter(explode('/', $this->uri), function ($v) {
             return false == is_blank($v);
         }));
     }
     array_walk($params, function (&$v) {
         $v = rawurldecode($v);
     });
     if ($this->mapkey) {
         $segments = array_values(array_filter(explode('/:', $this->mapkey), function ($v) {
             return false == is_blank($v) and $v != '/';
         }));
         foreach ($segments as $k => $p) {
             if (isset($params[$k])) {
                 $params[$p] = $params[$k];
                 unset($params[$k]);
             } else {
                 $params[$p] = null;
             }
         }
     }
     return $params;
 }
Example #2
0
/**
 * gets Unix timestamp from date string
 * @param string $p_date A valid date/time string (see http://php.net/manual/en/datetime.formats.php)
 * @return false|int a timestamp on success, null date when $p_date is blank or false on failure.
 * @access public
 */
function date_strtotime($p_date)
{
    if (is_blank($p_date)) {
        return date_get_null();
    }
    return strtotime($p_date);
}
Example #3
0
function email_queue_add($p_email_data)
{
    $t_email_data = email_queue_prepare_db($p_email_data);
    # email cannot be blank
    if (is_blank($t_email_data->email)) {
        error_parameters(lang_get('email'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    # subject cannot be blank
    if (is_blank($t_email_data->subject)) {
        error_parameters(lang_get('subject'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    # body cannot be blank
    if (is_blank($t_email_data->body)) {
        error_parameters(lang_get('body'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    $t_email_table = config_get('mantis_email_table');
    $c_email = $t_email_data->email;
    $c_subject = $t_email_data->subject;
    $c_body = $t_email_data->body;
    $c_metadata = serialize($t_email_data->metadata);
    $query = "INSERT INTO {$t_email_table}\r\n\t\t\t\t    ( email,\r\n\t\t\t\t      subject,\r\n\t\t\t\t\t  body,\r\n\t\t\t\t\t  submitted,\r\n\t\t\t\t\t  metadata)\r\n\t\t\t\t  VALUES\r\n\t\t\t\t    ( '{$c_email}',\r\n\t\t\t\t      '{$c_subject}',\r\n\t\t\t\t      '{$c_body}',\r\n\t\t\t\t\t  " . db_now() . ",\r\n\t\t\t\t\t  '{$c_metadata}'\r\n\t\t\t\t\t)";
    db_query($query);
    return db_insert_id($t_email_table);
}
Example #4
0
 public function validate()
 {
     if (is_blank($this->tmp_name)) {
         $this->errors->add('파일을 선택해 주세요.');
         return false;
     }
     if (!empty($this->validate_types) && !in_array($this->type, $this->validate_types)) {
         //$this->errors->add('"' . $this->type . '"은 허용된 파일 타입이 아닙니다.');
         $this->errors->add('허용된 파일 타입이 아닙니다.');
         return false;
     }
     $names = explode('.', $this->name);
     $extension = end($names);
     if (!empty($this->validate_extensions) && !preg_grep("/{$extension}/i", $this->validate_extensions)) {
         //$this->errors->add('"' . end(explode('.', $this->name)) . '"은 허용된 파일 타입이 아닙니다.');
         $this->errors->add('허용된 파일 타입이 아닙니다.');
         return false;
     }
     if ($this->size > $this->max_upload_size) {
         $this->errors->add('최대 크기를 초과하였습니다.');
         return false;
     }
     if ($this->error > 0) {
         $this->errors->add('파일 업로드 중 오류가 발생하였습니다.');
         return false;
     }
     return true;
 }
function custom_function_default_roadmap_print_issue($p_issue_id, $p_issue_level = 0)
{
    static $t_status;
    $t_bug = bug_get($p_issue_id);
    if (bug_is_resolved($p_issue_id)) {
        $t_strike_start = '<strike>';
        $t_strike_end = '</strike>';
    } else {
        $t_strike_start = $t_strike_end = '';
    }
    if ($t_bug->category_id) {
        $t_category_name = category_get_name($t_bug->category_id);
    } else {
        $t_category_name = '';
    }
    $t_category = is_blank($t_category_name) ? '' : '<b>[' . string_display_line($t_category_name) . ']</b> ';
    echo utf8_str_pad('', $p_issue_level * 6, '&#160;'), '- ', $t_strike_start, string_get_bug_view_link($p_issue_id), ': ', $t_category, string_display_line_links($t_bug->summary);
    if ($t_bug->handler_id != 0) {
        echo ' (', prepare_user_name($t_bug->handler_id), ')';
    }
    if (!isset($t_status[$t_bug->status])) {
        $t_status[$t_bug->status] = get_enum_element('status', $t_bug->status, auth_get_current_user_id(), $t_bug->project_id);
    }
    echo ' - ', $t_status[$t_bug->status], $t_strike_end, '.<br />';
}
Example #6
0
/**
 * Add to email queue
 * @param EmailData $p_email_data
 * @return int
 */
function email_queue_add($p_email_data)
{
    $t_email_data = email_queue_prepare_db($p_email_data);
    # email cannot be blank
    if (is_blank($t_email_data->email)) {
        error_parameters(lang_get('email'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    # subject cannot be blank
    if (is_blank($t_email_data->subject)) {
        error_parameters(lang_get('subject'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    # body cannot be blank
    if (is_blank($t_email_data->body)) {
        error_parameters(lang_get('body'));
        trigger_error(ERROR_EMPTY_FIELD, ERROR);
    }
    $t_email_table = db_get_table('email');
    $c_email = $t_email_data->email;
    $c_subject = $t_email_data->subject;
    $c_body = $t_email_data->body;
    $c_metadata = serialize($t_email_data->metadata);
    $query = "INSERT INTO {$t_email_table}\n\t\t\t\t    ( email,\n\t\t\t\t      subject,\n\t\t\t\t\t  body,\n\t\t\t\t\t  submitted,\n\t\t\t\t\t  metadata)\n\t\t\t\t  VALUES\n\t\t\t\t    ( " . db_param() . ",\n\t\t\t\t      " . db_param() . ",\n\t\t\t\t      " . db_param() . ",\n\t\t\t\t\t  " . db_param() . ",\n\t\t\t\t\t  " . db_param() . "\n\t\t\t\t\t)";
    db_query_bound($query, array($c_email, $c_subject, $c_body, db_now(), $c_metadata));
    return db_insert_id($t_email_table, 'email_id');
}
Example #7
0
 public function validate_register()
 {
     if (is_blank($this->comment)) {
         $this->errors->add('댓글을 입력해 주세요.');
         return false;
     }
     return true;
 }
Example #8
0
function fill_blank_array($mas, $str) {
	foreach ($mas as $key => $value) {
		if (is_blank($value)) {
			$mas[$key] = $str;
		}
	}
	return $mas;
}
Example #9
0
function print_unread_icon($p_unread = READ)
{
    $t_icon_path = config_get('icon_path');
    $t_unread_icon_arr = config_get('unread_icon_arr');
    $t_none = NONE;
    if (!is_blank($t_unread_icon_arr[$p_unread])) {
        print "<img src=\"{$t_icon_path}{$t_unread_icon_arr[$p_unread]}\" alt=\"\" />";
    } else {
        print "<img src=\"{$t_icon_path}{$t_status_icon_arr[$t_none]}\" alt=\"\" />";
    }
}
function wiki_mediawiki_get_url_for_page_id($p_page_id)
{
    $t_root_url = config_get_global('wiki_engine_url');
    $t_root_namespace = config_get('wiki_root_namespace');
    if (is_blank($t_root_namespace)) {
        $t_page_id = $p_page_id;
    } else {
        $t_page_id = $t_root_namespace . ':' . $p_page_id;
    }
    return $t_root_url . 'index.php/' . urlencode($t_page_id);
}
 public function url_repo($p_repo, $p_changeset = null)
 {
     $t_rev = '';
     $t_path = '';
     if (!is_null($p_changeset)) {
         $t_rev = '&rev=' . urlencode($p_changeset->revision);
     }
     if (!is_blank($p_repo->info['websvn_path'])) {
         $t_path = '&path=' . urlencode($p_repo->info['websvn_path']);
     }
     return $p_repo->info['websvn_url'] . 'listing.php?repname=' . urlencode($p_repo->info['websvn_name']) . "{$t_path}{$t_rev}&sc=1";
 }
Example #12
0
 public function validate_register()
 {
     if (is_blank($this->subject)) {
         $this->errors->add('제목을 입력해 주세요.');
         return false;
     }
     if (is_blank($this->content)) {
         $this->errors->add('내용을 입력해 주세요.');
         return false;
     }
     return true;
 }
Example #13
0
/**
 * Log an event
 * @param int $p_level
 * @param string $p_msg
 * @return null
 */
function log_event($p_level, $p_msg)
{
    global $g_log_levels;
    # check to see if logging is enabled
    $t_sys_log = config_get_global('log_level');
    if (0 == ($t_sys_log & $p_level)) {
        return;
    }
    $t_now = date(config_get_global('complete_date_format'));
    $t_level = $g_log_levels[$p_level];
    $t_plugin_event = '[' . $t_level . '] ' . $p_msg;
    if (function_exists('event_signal')) {
        event_signal('EVENT_LOG', array($t_plugin_event));
    }
    $t_php_event = $t_now . ' ' . $t_level . ' ' . $p_msg;
    $t_log_destination = config_get_global('log_destination');
    if (is_blank($t_log_destination)) {
        $t_destination = '';
    } else {
        # Use @ to avoid error when there is no delimiter in log destination
        @(list($t_destination, $t_modifiers) = explode(':', $t_log_destination, 2));
    }
    switch ($t_destination) {
        case 'file':
            error_log($t_php_event . PHP_EOL, 3, $t_modifiers);
            break;
        case 'firebug':
            if (!class_exists('FirePHP')) {
                if (file_exists(BASE_PATH . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'FirePHPCore' . DIRECTORY_SEPARATOR . 'FirePHP.class.php')) {
                    require_once BASE_PATH . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'FirePHPCore' . DIRECTORY_SEPARATOR . 'FirePHP.class.php';
                }
            }
            if (class_exists('FirePHP')) {
                static $firephp;
                if ($firephp === null) {
                    $firephp = FirePHP::getInstance(true);
                }
                $firephp->log($t_php_event);
                return;
            }
            // if firebug is not available, fall through
        // if firebug is not available, fall through
        default:
            # use default PHP error log settings
            error_log($t_php_event . PHP_EOL);
            break;
    }
    # If running from command line, echo log event to stdout
    if (php_sapi_name() == 'cli') {
        echo $t_php_event . PHP_EOL;
    }
}
Example #14
0
/**
 * Trae los clientes compuestos del totvs de la base de datos SQL
 * @param bool $id
 */
function getClientesCompuestosTotvs($codigocc)
{
    $sql = "SELECT * FROM `acsa_totvs_clientes_compuestos` WHERE codigocc = '" . $codigocc . "'";
    $conn = getConnection();
    $result = executeSelect($sql, $conn);
    $clientes = array();
    if (mysql_num_rows($result) > 0) {
        while ($row = mysql_fetch_array($result)) {
            $clientes[] = array('codigocc' => trim($row['codigocc']), 'lojacc' => trim($row['lojacc']), 'codigo' => trim($row['codigo']), 'loja' => trim($row['loja']), 'nombre' => trim(is_blank(utf8_encode(stripslashes(str_replace("'", "", $row['nombre']))))));
        }
    }
    echo json_encode($clientes);
}
Example #15
0
/**
 * Get the custom field id given an object ref.  The id is set based on the following algorithm:
 * - id from objectref (if not zero).
 * - id corresponding to name in object ref.
 * - 0, if object ref doesn't contain an id or a name.
 *
 * @param ObjectRef  $p_object_ref   An associate array with "id" and "name" keys.
 */
function mci_get_custom_field_id_from_objectref($p_object_ref)
{
    if ((int) $p_object_ref['id'] != 0) {
        $t_id = (int) $p_object_ref['id'];
    } else {
        if (!is_blank($p_object_ref['name'])) {
            $t_id = custom_field_get_id_from_name($p_object_ref['name']);
        } else {
            $t_id = 0;
        }
    }
    return $t_id;
}
Example #16
0
/**
 * A method that takes in a text argument and extracts all candidate @ mentions
 * from it.  The return list will not include the @ sign and will not include
 * duplicates.  This method is mainly for testability and it doesn't take into
 * consideration whether the @ mentions features is enabled or not.
 *
 * @param string $p_text The text to process.
 * @return array of @ mentions without the @ sign.
 * @private
 */
function mention_get_candidates($p_text)
{
    if (is_blank($p_text)) {
        return array();
    }
    static $s_pattern = null;
    if ($s_pattern === null) {
        $t_quoted_tag = preg_quote(mentions_tag());
        $s_pattern = '/(?:' . '(?<=^|[^\\w])' . '(?<!' . $t_quoted_tag . ')' . $t_quoted_tag . ')' . '([\\w.]*[\\w])' . '(?=[^\\w@]|$)' . '(?!$t_quoted_tag)' . '/';
    }
    preg_match_all($s_pattern, $p_text, $t_mentions);
    return array_unique($t_mentions[1]);
}
function email_group_reminder($p_user_id, $issues)
{
    $t_username = user_get_field($p_user_id, 'username');
    $t_email = user_get_email($p_user_id);
    $t_message = $issues;
    $t_subject = config_get('plugin_Reminder_reminder_subject');
    if (!is_blank($t_email)) {
        email_store($t_email, $t_subject, $t_message);
        if (OFF == config_get('email_send_using_cronjob')) {
            email_send_all();
        }
    }
}
 function query($p_filter_input)
 {
     $invoice = $p_filter_input;
     if (is_blank($invoice)) {
         return;
     }
     plugin_push_current('CustomerManagement');
     if (access_has_global_level(plugin_config_get('view_customer_fields_threshold'))) {
         $t_query = CustomerManagementDao::buildFilterArrayForInvoice($invoice);
     }
     plugin_pop_current();
     return $t_query;
 }
function check_urls($t_urls_in)
{
    $t_urls_in = explode("\n", $t_urls_in);
    $t_urls_out = array();
    foreach ($t_urls_in as $t_url) {
        $t_url = trim($t_url);
        if (is_blank($t_url) || in_array($t_url, $t_urls_out)) {
            continue;
        }
        $t_urls_out[] = $t_url;
    }
    return $t_urls_out;
}
Example #20
0
function print_version_header($p_version_id)
{
    $t_project_id = version_get_field($p_version_id, 'project_id');
    $t_version_name = version_get_field($p_version_id, 'version');
    $t_project_name = project_get_field($t_project_id, 'name');
    $t_release_title = string_display($t_project_name) . ' - ' . string_display($t_version_name);
    echo $t_release_title, '<br />';
    echo str_pad('', strlen($t_release_title), '='), '<br />';
    $t_description = version_get_field($p_version_id, 'description');
    if ($t_description !== false && !is_blank($t_description)) {
        echo string_display("<br />{$t_description}<br /><br />");
    }
}
Example #21
0
/**
 * Get the custom field id given an object ref.  The id is set based on the following algorithm:
 * - id from objectref (if not zero).
 * - id corresponding to name in object ref.
 * - 0, if object ref doesn't contain an id or a name.
 *
 * @param stdClass $p_object_ref An associate array with "id" and "name" keys.
 * @return integer
 */
function mci_get_custom_field_id_from_objectref(stdClass $p_object_ref)
{
    $p_object_ref = SoapObjectsFactory::unwrapObject($p_object_ref);
    if (isset($p_object_ref['id']) && (int) $p_object_ref['id'] != 0) {
        $t_id = (int) $p_object_ref['id'];
    } else {
        if (!is_blank($p_object_ref['name'])) {
            $t_id = custom_field_get_id_from_name($p_object_ref['name']);
        } else {
            $t_id = 0;
        }
    }
    return $t_id;
}
Example #22
0
function ldap_authenticate($p_login_name, $p_password)
{
    # if password is empty and ldap allows anonymous login, then
    # the user will be able to login, hence, we need to check
    # for this special case.
    if (is_blank($p_password)) {
        return false;
    }
    $t_authenticated = new stdClass();
    $t_authenticated->status_ok = TRUE;
    $t_authenticated->status_code = null;
    $t_authenticated->status_verbose = '';
    $authCfg = config_get('authentication');
    $t_ldap_organization = $authCfg['ldap_organization'];
    $t_ldap_root_dn = $authCfg['ldap_root_dn'];
    $t_ldap_uid_field = $authCfg['ldap_uid_field'];
    // 'uid' by default
    $t_username = $p_login_name;
    $t_search_filter = "(&{$t_ldap_organization}({$t_ldap_uid_field}={$t_username}))";
    $t_search_attrs = array($t_ldap_uid_field, 'dn');
    $t_connect = ldap_connect_bind();
    if ($t_connect->status == 0) {
        $t_ds = $t_connect->handler;
        # Search for the user id
        $t_sr = ldap_search($t_ds, $t_ldap_root_dn, $t_search_filter, $t_search_attrs);
        $t_info = ldap_get_entries($t_ds, $t_sr);
        $t_authenticated->status_ok = false;
        $t_authenticated->status_code = ERROR_LDAP_AUTH_FAILED;
        $t_authenticated->status_verbose = 'ERROR_LDAP_AUTH_FAILED';
        if ($t_info) {
            # Try to authenticate to each until we get a match
            for ($idx = 0; $idx < $t_info['count']; $idx++) {
                $t_dn = $t_info[$idx]['dn'];
                # Attempt to bind with the DN and password
                if (@ldap_bind($t_ds, $t_dn, $p_password)) {
                    $t_authenticated->status_ok = true;
                    break;
                    # Don't need to go any further
                }
            }
        }
        ldap_free_result($t_sr);
        ldap_unbind($t_ds);
    } else {
        $t_authenticated->status_ok = false;
        $t_authenticated->status_code = $t_connect->status;
        $t_authenticated->status_verbose = 'LDAP CONNECT FAILED';
    }
    return $t_authenticated;
}
Example #23
0
 public function where($where, $params = array())
 {
     // '$where' is empty?
     if (!is_array($where) && is_blank($where)) {
         return;
     }
     // '$where' is id?
     if (is_numeric($where) || is_numeric_array($where)) {
         $this->where = "{$this->from}.id" . self::id_condition($where);
         return;
     }
     // etc
     $this->where = Context::get('db')->bind_params($where, $params);
 }
Example #24
0
 public function addVersion($projID, $version)
 {
     if (MANTIS_LOCAL) {
         if (version_add($projID, $version, true, $version)) {
             $t_version_id = version_get_id($version, $projID);
             if (!is_blank($v_date_order)) {
                 $t_version = version_get($t_version_id);
                 $t_version->date_order = date("Y-m-d H:i:s", strtotime($v_date_order));
                 version_update($t_version);
             }
         }
     } else {
         $this->client->mc_project_version_add(MANTIS_USER, MANTIS_PWD, array('name' => $version, 'project_id' => $projID, 'description' => $version, 'released' => true));
     }
 }
function custom_function_default_roadmap_print_issue($p_issue_id, $p_issue_level = 0)
{
    $t_bug = bug_get($p_issue_id);
    if (bug_is_resolved($p_issue_id)) {
        $t_strike_start = '<strike>';
        $t_strike_end = '</strike>';
    } else {
        $t_strike_start = $t_strike_end = '';
    }
    $t_category = is_blank($t_bug->category) ? '' : '<b>[' . $t_bug->category . ']</b> ';
    echo str_pad('', $p_issue_level * 6, '&nbsp;'), '- ', $t_strike_start, string_get_bug_view_link($p_issue_id), ': ', $t_category, string_display_line_links($t_bug->summary);
    if ($t_bug->handler_id != 0) {
        echo ' (', prepare_user_name($t_bug->handler_id), ')';
    }
    echo ' - ', get_enum_element('status', $t_bug->status), $t_strike_end, '.<br />';
}
function email_is_valid($p_email)
{
    # if we don't validate then just accept
    if (OFF == config_get('validate_email')) {
        return true;
    }
    if (is_blank($p_email) && ON == config_get('allow_blank_email')) {
        return true;
    }
    # Use a regular expression to check to see if the email is in valid format
    #  x-xx.xxx@yyy.zzz.abc etc.
    if (preg_match(email_get_rfc822_regex(), $p_email, $t_check)) {
        $t_local = $t_check[1];
        $t_domain = $t_check[2];
        # see if we're limited to one domain
        if (ON == config_get('limit_email_domain')) {
            if (0 != strcasecmp($t_limit_email_domain, $t_domain)) {
                return false;
            }
        }
        if (preg_match('/\\[(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)\\]/', $t_domain, $t_check)) {
            # Handle domain-literals of the form '[1.2.3.4]'
            #  as long as each segment is less than 255, we're ok
            if ($t_check[1] <= 255 && $t_check[2] <= 255 && $t_check[3] <= 255 && $t_check[4] <= 255) {
                return true;
            }
        } else {
            if (ON == config_get('check_mx_record')) {
                # Check for valid mx records
                if (getmxrr($t_domain, $temp)) {
                    return true;
                } else {
                    $host = $t_domain . '.';
                    # for no mx record... try dns check
                    if (checkdnsrr($host, 'ANY')) {
                        return true;
                    }
                }
            } else {
                # Email format was valid but did't check for valid mx records
                return true;
            }
        }
    }
    # Everything failed.  The email is invalid
    return false;
}
/**
 * Add an attachment to an existing project.
 *
 * @param string $p_username  The name of the user trying to add an attachment to an issue.
 * @param string $p_password  The password of the user.
 * @param integer $p_project_id  The id of the project to add the attachment to.
 * @param string $p_name  The name of the file.
 * @param string $p_title  The title for the attachment.
 * @param string $p_description  The description for the attachment.
 * @param string $p_file_type The mime type of the file.
 * @param base64Binary $p_content  The attachment to add.
 * @return integer The id of the added attachment.
 */
function mc_project_attachment_add($p_username, $p_password, $p_project_id, $p_name, $p_title, $p_description, $p_file_type, $p_content)
{
    $t_user_id = mci_check_login($p_username, $p_password);
    if ($t_user_id === false) {
        return mci_soap_fault_login_failed();
    }
    # Check if project documentation feature is enabled.
    if (OFF == config_get('enable_project_documentation')) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    if (!access_has_project_level(config_get('upload_project_file_threshold'), $p_project_id, $t_user_id)) {
        return mci_soap_fault_access_denied($t_user_id);
    }
    if (is_blank($p_title)) {
        return SoapObjectsFactory::newSoapFault('Client', 'Title must not be empty.');
    }
    return mci_file_add($p_project_id, $p_name, $p_content, $p_file_type, 'project', $p_title, $p_description, $t_user_id);
}
 /**
  * show list
  */
 public function index($page = '1')
 {
     $page_size = 5;
     // page size
     $offset = ($page - 1) * $page_size;
     $input_keyword = _get('input_keyword');
     $where = array();
     if (!is_blank($input_keyword)) {
         $where[] = "(blog.subject like '%" . Context::get('db')->escape_string($input_keyword) . "%'" . " OR blog.content like '%" . Context::get('db')->escape_string($input_keyword) . "%'" . " OR user.nickname like '%" . Context::get('db')->escape_string($input_keyword) . "%')";
     }
     $where = implode(' AND ', $where);
     // get id(s) in the page
     $blogs = Blog::neo()->join('user')->select('blog.id')->where($where)->limit($offset, $page_size)->find('all');
     $ids = extract_property($blogs);
     // get blogs in the page
     $this->blogs = Blog::neo()->join('user')->join('blog_comment')->order('blog.id DESC')->where($ids)->find('all');
     $this->paging = new Paging(Blog::neo()->count(), $page_size, "/blog/index/<page>?input_keyword={$input_keyword}", $page);
 }
Example #29
0
/**
 * Translates the default date value entered by the creator of the custom
 * field into a date value.  For example, translate '=tomorrow' to tomorrow's
 * date.
 * @param $p_value The default date string.
 * @returns The calculated default date value if $p_value starts with '=',
 *          otherwise, returns $p_value.
 */
function cfdef_prepare_date_default($p_value)
{
    if (is_blank($p_value)) {
        return '';
    }
    $t_value = trim($p_value);
    $t_value_length = utf8_strlen($t_value);
    # We are expanding {tomorrow}, {yesterday}, {+3 days}, {-7 days}, {next week}
    # See strtotime() for more details about supported formats.
    if ($t_value_length >= 3 && $t_value[0] == '{' && $t_value[$t_value_length - 1] == '}') {
        $t_value = utf8_substr($t_value, 1, $t_value_length - 2);
        $t_value = @strtotime($t_value);
        # Different versions of PHP return different values in case of error.
        if ($t_value == -1 || $t_value === false) {
            return '';
        }
    }
    return $t_value;
}
/**
 * The input $p_dir is either ASC or DESC
 * The inputs $p_sort_by and $p_field are compared to see if they match
 * If the fields match then the sort icon is printed
 * This is a convenience feature to push the comparison code into this
 * function instead of in the page(s)
 * $p_field is a constant and $p_sort_by is whatever the page happens to
 * be sorting by at the moment
 * Multiple sort keys are not supported
 * @param int $p_dir
 * @param string $p_sort_by
 * @param string $p_field
 * @return null
 * @access public
 */
function print_sort_icon($p_dir, $p_sort_by, $p_field)
{
    $t_icon_path = config_get('icon_path');
    $t_sort_icon_arr = config_get('sort_icon_arr');
    if ($p_sort_by != $p_field) {
        return;
    }
    if ('DESC' == $p_dir || DESCENDING == $p_dir) {
        $t_dir = DESCENDING;
    } else {
        $t_dir = ASCENDING;
    }
    $t_none = NONE;
    if (!is_blank($t_sort_icon_arr[$t_dir])) {
        echo "<img src=\"{$t_icon_path}{$t_sort_icon_arr[$t_dir]}\" alt=\"\" />";
    } else {
        echo "<img src=\"{$t_icon_path}{$t_status_icon_arr[$t_none]}\" alt=\"\" />";
    }
}