コード例 #1
0
/**
 * Removes hook for parsecode.
 *
 * @since 1.0.0
 * @uses $parsecode_tags
 *
 * @param string $tag parsecode tag to remove hook for.
 */
function remove_parsecode($tag)
{
    global $parsecode_tags;
    if ('' == _trim($tag)) {
        $message = _t('Invalid parsecode name: empty name given.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    unset($parsecode_tags[$tag]);
}
コード例 #2
0
ファイル: UTF8.php プロジェクト: braf/phalcana-core
 /**
  * Strips whitespace (or other UTF-8 characters) from the beginning and
  * end of a string. This is a UTF8-aware version of [trim](http://php.net/trim).
  *
  *     $str = UTF8::trim($str);
  *
  * @author  Andreas Gohr <*****@*****.**>
  * @param   string  $str        input string
  * @param   string  $charlist   string of characters to remove
  * @return  string
  */
 public static function trim($str, $charlist = null)
 {
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require Phalcana::$di->get('fs')->findFile('utf8', __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = true;
     }
     return _trim($str, $charlist);
 }
コード例 #3
0
ファイル: core-function.php プロジェクト: parkerj/eduTrac-SIS
/**
 * Performs a check within a php script and returns any other files
 * that might have been required or included.
 *
 * @since 6.2.0
 * @param string $file_name
 *            PHP script to check.
 */
function etsis_php_check_includes($file_name)
{
    if ('' == _trim($file_name)) {
        $message = _t('Invalid file name: empty file name given.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    // NOTE that any file coming into this function has already passed the syntax check, so
    // we can assume things like proper line terminations
    $includes = [];
    // Get the directory name of the file so we can prepend it to relative paths
    $dir = dirname($file_name);
    // Split the contents of $fileName about requires and includes
    // We need to slice off the first element since that is the text up to the first include/require
    $requireSplit = array_slice(preg_split('/require|include/i', _file_get_contents($file_name)), 1);
    // For each match
    foreach ($requireSplit as $string) {
        // Substring up to the end of the first line, i.e. the line that the require is on
        $string = substr($string, 0, strpos($string, ";"));
        // If the line contains a reference to a variable, then we cannot analyse it
        // so skip this iteration
        if (strpos($string, "\$") !== false) {
            continue;
        }
        // Split the string about single and double quotes
        $quoteSplit = preg_split('/[\'"]/', $string);
        // The value of the include is the second element of the array
        // Putting this in an if statement enforces the presence of '' or "" somewhere in the include
        // includes with any kind of run-time variable in have been excluded earlier
        // this just leaves includes with constants in, which we can't do much about
        if ($include = $quoteSplit[1]) {
            // If the path is not absolute, add the dir and separator
            // Then call realpath to chop out extra separators
            if (strpos($include, ':') === FALSE) {
                $include = realpath($dir . DS . $include);
            }
            array_push($includes, $include);
        }
    }
    return $includes;
}
コード例 #4
0
ファイル: index.post.php プロジェクト: hypnomez/opir.org
 * @license		MIT License, see license.txt
 */
namespace cs\modules\Home;

use cs\User;
$User = User::instance();
$Events = Events::instance();
if (!$User->user()) {
    error_code(403);
    return;
}
if (!isset($_POST['category'], $_POST['timeout'], $_POST['lat'], $_POST['lng'], $_POST['visible'], $_POST['text'], $_POST['time'], $_POST['time_interval'], $_POST['img'])) {
    error_code(400);
    return;
}
if (in_array(AUTOMAIDAN_GROUP, $User->get_groups()) && !in_array($_POST['category'], [1, 3, 6, 7, 8, 17, 21, 22])) {
    // Magic numbers - id of categories, where confirmation is needed
    error_code(403);
    return;
}
$tags = [];
if ($_POST['address_details']) {
    $tags = _trim(explode(',', $_POST['address_details']));
    $last = count($tags) - 1;
    if (preg_match('/^[0-9].*/s', $tags[$last])) {
        unset($tags[$last]);
    }
}
if (!$Events->add($_POST['category'], $_POST['timeout'], $_POST['lat'], $_POST['lng'], $_POST['visible'], $_POST['text'], $_POST['time'], $_POST['time_interval'], $_POST['img'], $tags)) {
    error_code(500);
}
コード例 #5
0
 public static function trim($str, $charlist = NULL)
 {
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require JsonApiApplication::find_file("utf8", __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = TRUE;
     }
     return _trim($str, $charlist);
 }
コード例 #6
0
ファイル: form.router.php プロジェクト: parkerj/eduTrac-SIS
      */
     if (isset($_COOKIE['SCREENLOCK'])) {
         redirect(get_base_url() . 'lock' . '/');
     }
 });
 $app->match('GET|POST', '/school/(\\d+)/', function ($id) use($app, $css, $js, $flashNow) {
     if ($app->req->isPost()) {
         $school = $app->db->school();
         foreach ($_POST as $k => $v) {
             $school->{$k} = $v;
         }
         $school->where('schoolID = ?', $id);
         if ($school->update()) {
             etsis_cache_flush_namespace('sch');
             $app->flash('success_message', $flashNow->notice(200));
             etsis_logger_activity_log_write('Update Record', 'School', _filter_input_string(INPUT_POST, 'schoolName') . ' (' . _trim(_filter_input_string(INPUT_POST, 'schoolCode')) . ')', get_persondata('uname'));
         } else {
             $app->flash('error_message', $flashNow->notice(409));
         }
         redirect($app->req->server['HTTP_REFERER']);
     }
     $school = $app->db->school()->where('schoolID = ?', $id);
     $q = etsis_cache_get($id, 'sch');
     if (empty($q)) {
         $q = $school->find(function ($data) {
             $array = [];
             foreach ($data as $d) {
                 $array[] = $d;
             }
             return $array;
         });
コード例 #7
0
ファイル: utf8.php プロジェクト: ultimateprogramer/cms
 /**
  * Strips whitespace (or other UTF-8 characters) from the beginning and
  * end of a string
  *
  * This is a UTF8-aware version of [trim](http://php.net/trim).
  *
  * Example:
  * ~~~
  * $str = UTF8::trim($str);
  * ~~~
  *
  * @author  Andreas Gohr <*****@*****.**>
  *
  * @param   string  $str       Input string
  * @param   string  $charlist  String of characters to remove [Optional]
  *
  * @return  string
  *
  * @uses    Kohana::find_file
  */
 public static function trim($str, $charlist = NULL)
 {
     UTF8::_load(__FUNCTION__);
     return _trim($str, $charlist);
 }
コード例 #8
0
ファイル: users.php プロジェクト: hypnomez/opir.org
         case '!=':
         case '>':
         case '<':
         case '>=':
         case '<=':
         case 'LIKE':
         case 'NOT LIKE':
         case 'REGEXP':
         case 'NOT REGEXP':
             $search_text_ = $users_db->s($search_text);
             $where = $where_func("`%%` {$search_mode} {$search_text_}");
             unset($search_text_);
             break;
         case 'IN':
         case 'NOT IN':
             $search_text_ = implode(", ", $users_db->s(_trim(explode(',', $search_text), "\n'")));
             $where = $where_func("`%%` {$search_mode} ({$search_text_})");
             unset($search_text_);
             break;
     }
 }
 $results_count = $users_db->qfs(["SELECT COUNT(`id`)\n\t\tFROM `[prefix]users`\n\t\tWHERE\n\t\t\t(\n\t\t\t\t{$where}\n\t\t\t) AND\n\t\t\t`status` != '%s'", User::STATUS_NOT_ACTIVATED]);
 if ($results_count) {
     $from = $start * $limit;
     $users_ids = $users_db->qfas(["SELECT `id`\n\t\t\tFROM `[prefix]users`\n\t\t\tWHERE\n\t\t\t\t(\n\t\t\t\t\t{$where}\n\t\t\t\t) AND\n\t\t\t\t`status` != '%s'\n\t\t\tORDER BY `id`\n\t\t\tLIMIT {$from}, {$limit}", User::STATUS_NOT_ACTIVATED]);
     unset($from);
 }
 $users_list = [];
 if (isset($users_ids) && is_array($users_ids)) {
     foreach ($users_ids as $id) {
         $is_guest = $id == User::GUEST_ID;
コード例 #9
0
ファイル: appl.router.php プロジェクト: parkerj/eduTrac-SIS
         $post = $_POST['inst'];
         $inst = $app->db->institution()->whereLike('instName', "%{$post}%")->_or_()->whereLike('fice_ceeb', "%{$post}%");
         $q = $inst->find(function ($data) {
             $array = [];
             foreach ($data as $d) {
                 $array[] = $d;
             }
             return $array;
         });
     }
     $app->view->display('application/inst', ['title' => 'Institution Search', 'cssArray' => $css, 'jsArray' => $js, 'search' => $q]);
 });
 $app->match('GET|POST', '/inst/add/', function () use($app, $css, $js, $flashNow) {
     if ($app->req->isPost()) {
         $inst = $app->db->institution();
         $inst->fice_ceeb = _trim((int) $_POST['fice_ceeb']);
         $inst->instType = $_POST['instType'];
         $inst->instName = $_POST['instName'];
         $inst->city = $_POST['city'];
         $inst->state = $_POST['state'];
         $inst->country = $_POST['country'];
         if ($inst->save()) {
             $ID = $inst->lastInsertId();
             $app->flash('success_message', $flashNow->notice(200));
             etsis_logger_activity_log_write('New Record', 'Institution', $_POST['instName'], get_persondata('uname'));
             redirect(get_base_url() . 'appl/inst' . '/' . $ID . '/');
         } else {
             $app->flash('error_message', $flashNow->notice(409));
             redirect($app->req->server['HTTP_REFERER']);
         }
     }
コード例 #10
0
ファイル: Precincts.php プロジェクト: hypnomez/opir.org
 /**
  * Precincts search
  *
  * @param string       $text
  * @param bool|float[] $coordinates
  * @param int          $limit
  *
  * @return array|bool
  */
 function search($text, $coordinates = false, $limit = 20)
 {
     $order = 'ORDER BY `district` = 0 DESC, `id` ASC';
     if ($coordinates && isset($coordinates[0], $coordinates[1])) {
         $coordinates = _float($coordinates);
         $order = "ORDER BY `district` = 0 DESC, SQRT(POW(`lat` - {$coordinates['0']}, 2) + POW(`lng` - {$coordinates['0']}, 2)) ASC";
     }
     $where = [];
     $params = [];
     if (is_numeric($text)) {
         /**
          * Search for precinct number
          */
         if (strlen($text) > 3 || (int) $text > 225) {
             $where[] = "`number` LIKE '%s%%'";
             $params[] = $text;
         } else {
             $where[] = "(`district` = '%s' OR (`district` = '0' AND `number` = '%s'))";
             $params[] = $text;
             $params[] = $text;
         }
     } else {
         $where[] = "(\n\t\t\t\tMATCH (`address_uk`) AGAINST ('%s' IN BOOLEAN MODE) > 0 OR\n\t\t\t\tMATCH (`address_en`) AGAINST ('%s' IN BOOLEAN MODE) > 0 OR\n\t\t\t\tMATCH (`address_ru`) AGAINST ('%s' IN BOOLEAN MODE) > 0\n\t\t\t)";
         $s = '+' . implode(_trim(explode(' ', trim($text))), '* +') . '*';
         $params[] = $s;
         $params[] = $s;
         $params[] = $s;
     }
     if ($where) {
         $where = 'WHERE ' . implode(' AND ', $where);
     } else {
         $where = '';
     }
     return $this->db()->qfas(["SELECT `id`\n\t\t\tFROM `{$this->table}`\n\t\t\t{$where}\n\t\t\t{$order}\n\t\t\tLIMIT {$limit}", $params]);
 }
コード例 #11
0
 * Before route check.
 */
$app->before('GET|POST', '/plugins.*', function () {
    if (!hasPermission('access_plugin_screen')) {
        redirect(get_base_url() . 'dashboard' . '/');
    }
});
$css = ['css/admin/module.admin.page.form_elements.min.css', 'css/admin/module.admin.page.tables.min.css'];
$js = ['components/modules/admin/forms/elements/bootstrap-select/assets/lib/js/bootstrap-select.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-select/assets/custom/js/bootstrap-select.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/select2/assets/lib/js/select2.js?v=v2.1.0', 'components/modules/admin/forms/elements/select2/assets/custom/js/select2.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-datepicker/assets/lib/js/bootstrap-datepicker.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-datepicker/assets/custom/js/bootstrap-datepicker.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-timepicker/assets/lib/js/bootstrap-timepicker.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-timepicker/assets/custom/js/bootstrap-timepicker.init.js?v=v2.1.0', 'components/modules/admin/tables/datatables/assets/lib/js/jquery.dataTables.min.js?v=v2.1.0', 'components/modules/admin/tables/datatables/assets/lib/extras/TableTools/media/js/TableTools.min.js?v=v2.1.0', 'components/modules/admin/tables/datatables/assets/custom/js/DT_bootstrap.js?v=v2.1.0', 'components/modules/admin/tables/datatables/assets/custom/js/datatables.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/jCombo/jquery.jCombo.min.js', 'components/modules/admin/forms/elements/jasny-fileupload/assets/js/bootstrap-fileupload.js?v=v2.1.0'];
$app->group('/plugins', function () use($app, $css, $js) {
    $app->get('/', function () use($app, $css, $js) {
        $app->view->display('plugins/index', ['title' => _t('Plugins'), 'cssArray' => $css, 'jsArray' => $js]);
    });
    $app->get('/activate/', function () use($app) {
        ob_start();
        $plugin_name = _trim(_filter_input_string(INPUT_GET, 'id'));
        /**
         * This function will validate a plugin and make sure
         * there are no errors before activating it.
         *
         * @since 6.2.0
         */
        etsis_validate_plugin($plugin_name);
        if (ob_get_length() > 0) {
            $output = ob_get_clean();
            $error = new \app\src\etError('unexpected_output', _t('The plugin generated unexpected output.'), $output);
            $app->flash('error_message', $error);
        }
        ob_end_clean();
        redirect($app->req->server['HTTP_REFERER']);
    });
コード例 #12
0
ファイル: Mail.php プロジェクト: hypnomez/opir.org
 /**
  * Sending of email
  *
  * @param array|string|string[]			$email			if emails without names - string (may be several emails separated by comma) or
  * 														1-dimensional array(<i>email</i>)<br>
  * 														else - 2-dimensional array(<i>email</i>, <i>name</i>) must be given
  * @param string						$subject		Mail subject
  * @param string						$body			html body
  * @param string|null					$body_text		plain text body
  * @param array|null|string				$attachments	1- or 2-dimensional array of array(<i>path</i>, <i>name</i>) or simply string
  * 														with path to the file in file system
  * @param array|null|string|string[]	$reply_to		Similar to <b>$email</b>
  * @param bool|string					$signature		<b>true</b> - add system signature<br>
  * 														<b>false</b> - without signature<br>
  * 														<b>string</b> - custom signature
  * @return bool
  */
 function send_to($email, $subject, $body, $body_text = null, $attachments = null, $reply_to = null, $signature = true)
 {
     if (empty($email) || empty($subject) || empty($body)) {
         return false;
     }
     if (is_array($email)) {
         if (count($email) == 2) {
             $this->AddAddress($email[0], $email[1]);
         } else {
             foreach ($email as $m) {
                 if (is_array($m)) {
                     $this->AddAddress($m[0], $m[1]);
                 } else {
                     $this->AddAddress($m);
                 }
             }
         }
     } else {
         $email = _trim(explode(',', $email));
         foreach ($email as $e) {
             $this->AddAddress($e);
         }
         unset($e, $email);
     }
     $this->Subject = $subject;
     if ($signature === true) {
         if ($signature = get_core_ml_text('mail_signature')) {
             $signature = "{$this->LE}-- {$this->LE}.{$signature}";
         }
     } elseif ($signature) {
         $signature = "{$this->LE}-- {$this->LE}" . xap($signature, true);
     } else {
         $signature = '';
     }
     $this->Body = $this->body_normalization($body, $signature);
     if ($body_text) {
         $this->AltBody = $body_text . strip_tags($signature);
     }
     if (is_array($attachments)) {
         if (count($attachments) == 2) {
             $this->AddStringAttachment($attachments[0], $attachments[1]);
         } else {
             foreach ($attachments as $a) {
                 if (is_array($a)) {
                     $this->AddStringAttachment($a[0], $a[1]);
                 } else {
                     $this->AddStringAttachment($a, pathinfo($a, PATHINFO_FILENAME));
                 }
             }
         }
     } elseif (is_string($attachments)) {
         $this->AddStringAttachment($attachments, pathinfo($attachments, PATHINFO_FILENAME));
     }
     if (is_array($reply_to)) {
         if (count($reply_to) == 2) {
             $this->AddReplyTo($reply_to[0], $reply_to[1]);
         } else {
             foreach ($reply_to as $r) {
                 if (is_array($r)) {
                     $this->AddReplyTo($r[0], $r[1]);
                 } else {
                     $this->AddReplyTo($r);
                 }
             }
         }
     } elseif (is_string($reply_to)) {
         $this->AddReplyTo($reply_to);
     }
     $result = $this->Send();
     $this->ClearAddresses();
     $this->ClearAttachments();
     $this->ClearReplyTos();
     return $result;
 }
コード例 #13
0
ファイル: dependency.php プロジェクト: parkerj/eduTrac-SIS
/**
 * Wrapper function for Hooks::do_action() and
 * executes functions hooked on a specific action hook.
 *
 * @since 6.0.03
 * @deprecated since 6.2.0
 * @param string $hook
 *            The name of the action which should be executed.
 * @param mixed $arg
 *            Additional arguments passed to functions hooked to the action.
 * @return mixed|null
 */
function do_action($hook, $arg = '')
{
    if ('' == _trim($hook)) {
        $message = _t('Invalid do_action hook: empty hook name given.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    if (!is_string($hook)) {
        $message = _t('Invalid do_action hook: hook name must be a string.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    $app = \Liten\Liten::getInstance();
    return $app->hook->do_action($hook, $arg);
}
コード例 #14
0
     $sacp = $app->db->stu_program();
     $sacp->stuID = $id;
     $sacp->acadProgCode = _trim($_POST['acadProgCode']);
     $sacp->currStatus = $_POST['currStatus'];
     $sacp->statusDate = $app->db->NOW();
     $sacp->startDate = $_POST['startDate'];
     $sacp->endDate = $_POST['endDate'];
     $sacp->approvedBy = get_persondata('personID');
     $sacp->antGradDate = $_POST['antGradDate'];
     $sacp->advisorID = $_POST['advisorID'];
     $sacp->catYearCode = $_POST['catYearCode'];
     if ($sacp->save()) {
         if (count($sql[0]['id']) <= 0) {
             $al = $app->db->stu_acad_level();
             $al->stuID = $id;
             $al->acadProgCode = _trim($_POST['acadProgCode']);
             $al->acadLevelCode = $decode[0]['acadLevelCode'];
             $al->addDate = $app->db->NOW();
             $al->save();
         }
         $app->flash('success_message', $flashNow->notice(200));
         etsis_logger_activity_log_write('New Record', 'Student Academic Program', get_name($id), get_persondata('uname'));
         redirect(get_base_url() . 'stu' . '/' . $id . '/' . bm());
     } else {
         $app->flash('error_message', $flashNow->notice(409));
         $app->req->server['HTTP_REFERER'];
     }
     etsis_cache_delete($id, 'stu');
 }
 $stu = $app->db->student()->where('stuID = ?', $id);
 $q = $stu->find(function ($data) {
コード例 #15
0
      * @param array $sect Course section object.
      */
     $app->hook->do_action('save_course_sec_db_table', $sect);
     if ($sect->save()) {
         $ID = $sect->lastInsertId();
         $section = ["sectionNumber" => _trim($_POST['sectionNumber']), "courseSecCode" => _trim($sc), "courseID" => $_POST['courseID'], "locationCode" => _trim($_POST['locationCode']), "termCode" => _trim($_POST['termCode']), "courseCode" => _trim($_POST['courseCode']), "secShortTitle" => $_POST['secShortTitle'], "startDate" => $_POST['startDate'], "endDate" => $_POST['endDate'], "deptCode" => _trim($_POST['deptCode']), "minCredit" => $_POST['minCredit'], "ceu" => $_POST['ceu'], "courseSection" => _trim($courseSection), "courseLevelCode" => _trim($_POST['courseLevelCode']), "acadLevelCode" => _trim($_POST['acadLevelCode']), "currStatus" => $_POST['currStatus'], "statusDate" => $_POST['statusDate'], "comment" => $_POST['comment'], "approvedDate" => $_POST['approvedDate'], "approvedBy" => $_POST['approvedBy'], "secLongTitle" => $crse->courseLongTitle, "section" => _trim($courseSection), "description" => $crse->courseDesc];
         /**
          * Fires after a course section has been created.
          * 
          * @since 6.1.07
          * @param array $section Course section data array.
          */
         $app->hook->do_action('post_save_course_sec', $section);
         etsis_cache_flush_namespace('sect');
         $app->flash('success_message', $flashNow->notice(200));
         etsis_logger_activity_log_write('New Record', 'Course Section', _trim($courseSection), get_persondata('uname'));
         redirect(get_base_url() . 'sect' . '/' . $ID . '/');
     } else {
         $app->flash('error_message', $flashNow->notice(409));
         redirect($app->req->server['HTTP_REFERER']);
     }
 }
 /**
  * If the database table doesn't exist, then it
  * is false and a 404 should be sent.
  */
 if ($crse == false) {
     $app->view->display('error/404', ['title' => '404 Error']);
 } elseif (empty($crse) == true) {
     $app->view->display('error/404', ['title' => '404 Error']);
 } elseif (count($crse->courseID) <= 0) {
コード例 #16
0
/**
 * is_ferpa function added to check for
 * active FERPA restrictions for students.
 *
 * @since 4.5
 * @param int $id
 *            Student's ID.
 */
function is_ferpa($id)
{
    if ('' == _trim($id)) {
        $message = _t('Invalid student ID: empty ID given.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    if (!is_numeric($id)) {
        $message = _t('Invalid student ID: student id must be numeric.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    $app = \Liten\Liten::getInstance();
    $ferpa = $app->db->query("SELECT\n                        rstrID\n                    FROM restriction\n                    WHERE stuID = ?\n                    AND rstrCode = 'FERPA'\n                    AND (endDate = '' OR endDate = '0000-00-00')", [$id]);
    $q = $ferpa->find(function ($data) {
        $array = [];
        foreach ($data as $d) {
            $array[] = $d;
        }
        return $array;
    });
    if (count($q) > 0) {
        return _t('Yes');
    } else {
        return _t('No');
    }
}
コード例 #17
0
 public static function getQueryString($omitKey = '', $omitBlank = false, $specifyRequest = '')
 {
     $query_string = "";
     foreach ($_POST as $key => $value) {
         if (($omitBlank == false || _trim($value) != "") && $key != $omitKey) {
             if ($query_string == "") {
                 $query_string = $key . "=" . urlencode($value);
             } else {
                 if (strpos($query_string, "&" . $key . "=") === false) {
                     $query_string .= "&" . $key . "=" . urlencode($value);
                 }
             }
         }
     }
     foreach ($_GET as $key => $value) {
         if (($omitBlank == false || _trim($value) != "") && $key != $omitKey) {
             if ($query_string == "") {
                 $query_string = $key . "=" . urlencode($value);
             } else {
                 if (strpos($query_string, "&" . $key . "=") === false) {
                     $query_string .= "&" . $key . "=" . urlencode($value);
                 }
             }
         }
     }
     return $query_string;
 }
コード例 #18
0
/**
 * Prepare string to use in keywords meta tag
 *
 * @param string	$text
 *
 * @return string
 */
function keywords($text)
{
    return implode(', ', _trim(explode(' ', str_replace([',', '.', '!', '?', '-', '–', '&'], '', $text))));
}
コード例 #19
0
ファイル: fun.php プロジェクト: froq/froq
/**
 * Default value getter for none variables.
 * @param  any $a
 * @param  any $b
 * @return any
 */
function if_none($a, $b)
{
    return none !== _trim($a) ? $a : $b;
}
コード例 #20
0
ファイル: UTF8.php プロジェクト: Chinese1904/openclassifieds2
 /**
  * Strips whitespace (or other UTF-8 characters) from the beginning and
  * end of a string. This is a UTF8-aware version of [trim](http://php.net/trim).
  *
  *     $str = UTF8::trim($str);
  *
  * @author  Andreas Gohr <*****@*****.**>
  * @param   string  $str        input string
  * @param   string  $charlist   string of characters to remove
  * @return  string
  */
 public static function trim($str, $charlist = NULL)
 {
     if (!isset(UTF8::$called[__FUNCTION__])) {
         require Kohana::find_file('utf8', __FUNCTION__);
         // Function has been called
         UTF8::$called[__FUNCTION__] = TRUE;
     }
     return _trim($str, $charlist);
 }
コード例 #21
0
/**
 * Shows selected person's initials instead of
 * his/her's full name.
 *
 * @since 4.1.6
 * @param int $ID
 *            Person ID
 * @param int $initials
 *            Number of initials to show.
 * @return string
 */
function get_initials($ID, $initials = 2)
{
    if ('' == _trim($ID)) {
        $message = _t('Invalid person ID: empty ID given.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    if (!is_numeric($ID)) {
        $message = _t('Invalid person ID: person id must be numeric.');
        _incorrectly_called(__FUNCTION__, $message, '6.2.0');
        return;
    }
    $name = get_person_by('personID', $ID);
    if ($initials == 2) {
        return mb_substr(_h($name->fname), 0, 1, 'UTF-8') . '. ' . mb_substr(_h($name->lname), 0, 1, 'UTF-8') . '.';
    } else {
        return _h($name->lname) . ', ' . mb_substr(_h($name->fname), 0, 1, 'UTF-8') . '.';
    }
}
コード例 #22
0
ファイル: lib.utf8.php プロジェクト: abhinay100/forma_app
 /**
  * Strips whitespace (or other UTF-8 characters) from the beginning and
  * end of a string.
  * @see http://php.net/trim
  *
  * @author  Andreas Gohr <*****@*****.**>
  *
  * @param   string   input string
  * @param   string   string of characters to remove
  * @return  string
  */
 public static function trim($str, $charlist = NULL)
 {
     require_once dirname(__FILE__) . '/' . __FUNCTION__ . '.php';
     return _trim($str, $charlist);
 }
コード例 #23
0
ファイル: save.php プロジェクト: hypnomez/opir.org
     switch ($item) {
         case 'name':
         case 'closed_title':
         case 'closed_text':
         case 'footer_text':
         case 'mail_from_name':
         case 'mail_signature':
         case 'rules':
             $value = set_core_ml_text($item, $value);
             break;
         case 'url':
         case 'cookie_domain':
         case 'cookie_path':
         case 'ip_black_list':
         case 'ip_admin_list':
             $value = _trim(explode("\n", $value));
             if ($value[0] == '') {
                 $value = [];
             }
     }
     $temp[$item] = xap($value, true);
     if ($item == 'theme') {
         $temp['color_scheme'] = $Config->core['color_schemes'][$temp['theme']][0];
     }
 }
 unset($item, $value);
 if ($part == 'routing' || $part == 'replace') {
     $temp['in'] = explode("\n", $temp['in']);
     $temp['out'] = explode("\n", $temp['out']);
     foreach ($temp['in'] as $i => $value) {
         if (empty($value)) {
コード例 #24
0
 public function __construct(\Liten\Liten $liten = null)
 {
     $this->app = !empty($liten) ? $liten : \Liten\Liten::getInstance();
     if (ETSIS_FILE_CACHE_LOW_RAM && function_exists('memory_get_usage')) {
         $limit = _trim(ini_get('memory_limit'));
         $mod = strtolower($limit[strlen($limit) - 1]);
         switch ($mod) {
             case 'g':
                 $limit *= 1073741824;
                 break;
             case 'm':
                 $limit *= 1048576;
                 break;
             case 'k':
                 $limit *= 1024;
                 break;
         }
         if ($limit <= 0) {
             $limit = 0;
         }
         $this->_memory_limit = $limit;
         $limit = _trim(ETSIS_FILE_CACHE_LOW_RAM);
         $mod = strtolower($limit[strlen($limit) - 1]);
         switch ($mod) {
             case 'g':
                 $limit *= 1073741824;
                 break;
             case 'm':
                 $limit *= 1048576;
                 break;
             case 'k':
                 $limit *= 1024;
                 break;
         }
         $this->_memory_low = $limit;
     } else {
         $this->_memory_limit = 0;
         $this->_memory_low = 0;
     }
     /**
      * Filter sets whether caching is enabled or not.
      *
      * @since 6.2.0
      * @var bool
      */
     $this->enable = $this->app->hook->apply_filter('enable_caching', true);
     $this->persist = $this->enable && true;
     /**
      * File system cache directory.
      */
     $dir = $this->app->config('file.savepath') . 'cache';
     /**
      * Fiter the file cache directory in order to override it
      * in case some systems are having issues.
      *
      * @since 6.2.0
      * @param string $dir
      *            The directory where file system cache files are saved.
      */
     $cacheDir = $this->app->hook->apply_filter('filesystem_cache_dir', $dir);
     /**
      * If the cache directory does not exist, the create it first
      * before trying to call it for use.
      */
     if (!is_dir($cacheDir) || !file_exists($cacheDir)) {
         _mkdir($cacheDir);
     }
     /**
      * If the directory isn't writable, throw an exception.
      */
     if (!etsis_is_writable($cacheDir)) {
         return new \app\src\Core\Exception\Exception(_t('Could not create the file cache directory.'), 'cookie_cache');
     }
     /**
      * Cache directory is set.
      */
     $this->_dir = $cacheDir . DS;
 }
コード例 #25
0
/**
 * Custom error log function for better PHP logging.
 * 
 * @since 6.2.11
 * @param string $name
 *            Log channel and log file prefix.
 * @param string $message
 *            Message printed to log.
 * @param string $level The logging level.
 */
function etsis_monolog($name, $message, $level = 'addInfo')
{
    $log = new \Monolog\Logger(_trim($name));
    $log->pushHandler(new \Monolog\Handler\StreamHandler(APP_PATH . 'tmp' . DS . 'logs' . DS . _trim($name) . '.' . date('m-d-Y') . '.txt'));
    $log->{$level}($message);
}
コード例 #26
0
ファイル: utf8.php プロジェクト: momoim/momo-api
 /**
  * Strips whitespace (or other UTF-8 characters) from the beginning and
  * end of a string.
  * @see http://php.net/trim
  *
  * @author  Andreas Gohr <*****@*****.**>
  *
  * @param   string   input string
  * @param   string   string of characters to remove
  * @return  string
  */
 public static function trim($str, $charlist = NULL)
 {
     if (!isset(self::$called[__FUNCTION__])) {
         require SYSPATH . 'core/utf8/' . __FUNCTION__ . EXT;
         // Function has been called
         self::$called[__FUNCTION__] = TRUE;
     }
     return _trim($str, $charlist);
 }
コード例 #27
0
ファイル: Request.class.php プロジェクト: asimo124/PHPClasses
 public static function getQueryString($omitKey = 'dir', $omitBlank = false)
 {
     $query_string = "";
     foreach ($_POST as $key => $value) {
         if (is_array($value) && count($value) > 0) {
             if ($query_string == "") {
                 $i = 0;
                 foreach ($value as $index => $item) {
                     if ($i == $index) {
                         $query_string = $key . "[]=" . urlencode($item);
                     } else {
                         $query_string = $key . "[{$index}]=" . urlencode($item);
                     }
                     $i++;
                 }
             } else {
                 $i = 0;
                 foreach ($value as $index => $item) {
                     if ($i == $index) {
                         $query_string .= "&" . $key . "[]=" . urlencode($item);
                     } else {
                         $query_string .= "&" . $key . "[{$index}]=" . urlencode($item);
                     }
                     $i++;
                 }
             }
         } else {
             if (($omitBlank == false || _trim($value) != "") && $key != $omitKey) {
                 if ($query_string == "") {
                     $query_string = $key . "=" . urlencode($value);
                 } else {
                     $query_string .= "&" . $key . "=" . urlencode($value);
                 }
             }
         }
     }
     foreach ($_GET as $key => $value) {
         if (is_array($value) && count($value) > 0) {
             if ($query_string == "") {
                 $i = 0;
                 foreach ($value as $index => $item) {
                     if ($i == $index) {
                         $query_string = $key . "[]=" . urlencode($item);
                     } else {
                         $query_string = $key . "[{$index}]=" . urlencode($item);
                     }
                     $i++;
                 }
             } else {
                 $i = 0;
                 foreach ($value as $index => $item) {
                     if ($i == $index) {
                         $query_string .= "&" . $key . "[]=" . urlencode($item);
                     } else {
                         $query_string .= "&" . $key . "[{$index}]=" . urlencode($item);
                     }
                     $i++;
                 }
             }
         } else {
             if (($omitBlank == false || _trim($value) != "") && $key != $omitKey) {
                 if ($query_string == "") {
                     $query_string = $key . "=" . urlencode($value);
                 } else {
                     $query_string .= "&" . $key . "=" . urlencode($value);
                 }
             }
         }
     }
     return $query_string;
 }