当前位置: 首页>>代码示例>>PHP>>正文


PHP Helpers::get_string方法代码示例

本文整理汇总了PHP中Helpers::get_string方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::get_string方法的具体用法?PHP Helpers::get_string怎么用?PHP Helpers::get_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Helpers的用法示例。


在下文中一共展示了Helpers::get_string方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 /**
  * Add an entry to the login tracking table.
  *
  * @param int $user_id
  * @param int $success
  * @param string $message
  * @return bool|mixed
  */
 public function add($user_id = 0, $success = 0, $message = '')
 {
     $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION);
     // input validation
     if (!Helpers::is_valid_int($user_id, true)) {
         $this->Log->write('user_id is not a valid integer', Log::LOG_LEVEL_WARNING);
         return false;
     }
     if (!Helpers::is_valid_int($success, true)) {
         $this->Log->write('success is not a valid integer', Log::LOG_LEVEL_WARNING);
         return false;
     }
     if (!in_array($success, array(0, 1))) {
         $this->Log->write('success is not 0 or 1', Log::LOG_LEVEL_WARNING, $success);
         return false;
     }
     if (!is_string($message)) {
         $message = Helpers::get_string($message);
     }
     // get values from PHP
     $ip_address = $_SERVER['REMOTE_ADDR'];
     $user_agent = $_SERVER['HTTP_USER_AGENT'];
     $session_id = session_id();
     if (!Helpers::is_string_ne($session_id)) {
         session_start();
         $session_id = session_id();
     }
     // prepare values for insert
     $pairs = array('user_id' => $user_id, 'ip_address' => $ip_address, 'user_agent' => $user_agent, 'success' => $success, 'session_id' => $session_id, 'message' => $message);
     $insert_id = $this->insert($this->table, $pairs);
     $this->Log->write('insert_id', Log::LOG_LEVEL_USER, $insert_id);
     return $insert_id;
 }
开发者ID:mts7,项目名称:mtsapps-framework,代码行数:41,代码来源:Login.php

示例2: handleError

 /**
  * Return error message, based on upload error status.
  *
  * @param int $error
  * @return bool|string
  */
 private function handleError($error)
 {
     $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION);
     if (!Helpers::is_valid_int($error, true)) {
         $this->Log->write('Cannot handle an error that is not a positive integer.', Log::LOG_LEVEL_WARNING);
         return false;
     }
     switch ($error) {
         case UPLOAD_ERR_INI_SIZE:
             $message = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.';
             break;
         case UPLOAD_ERR_FORM_SIZE:
             $message = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.';
             break;
         case UPLOAD_ERR_PARTIAL:
             $message = 'The uploaded file was only partially uploaded.';
             break;
         case UPLOAD_ERR_NO_FILE:
             $message = 'No file was uploaded.';
             break;
         case UPLOAD_ERR_NO_TMP_DIR:
             $message = 'Missing a temporary folder.';
             break;
         case UPLOAD_ERR_CANT_WRITE:
             $message = 'Failed to write file to disk.';
             break;
         case UPLOAD_ERR_EXTENSION:
             $message = 'A PHP extension stopped the file upload.';
             break;
         default:
             $message = 'Unknown upload error (' . Helpers::get_string($error) . ')';
             break;
     }
     $this->Log->write('Error: ' . $message, Log::LOG_LEVEL_ERROR);
     return $message;
 }
开发者ID:mts7,项目名称:mtsapps-framework,代码行数:42,代码来源:Upload.php

示例3: savePassword

 /**
  * Save the password in the database.
  *
  * @param string $password
  * @return bool|mixed
  */
 private function savePassword($password = '')
 {
     $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION);
     // input validation
     if (!Helpers::is_string_ne($password)) {
         $this->Log->write('password must be provided', Log::LOG_LEVEL_WARNING);
         return false;
     }
     $pairs = array('password' => $password);
     $updated = $this->update($this->table, $pairs, array($this->id_field => $this->id));
     $this->Log->write('password saved', Log::LOG_LEVEL_USER, Helpers::get_string($updated));
     return $updated;
 }
开发者ID:mts7,项目名称:mtsapps-framework,代码行数:19,代码来源:User.php

示例4: write

 /**
  * Write the message to the log file if the log level is appropriate.
  *
  * @param string $message
  * @param int $log_level
  * @return bool|int
  * @uses Log::$log_level
  * @uses Log::$file
  * @uses Log::$date_format
  * @uses Log::$separator
  * @uses get_string()
  */
 public function write($message = '', $log_level = Log::LOG_LEVEL_SYSTEM_INFORMATION)
 {
     // input validation
     if (!Helpers::is_string_ne($message)) {
         return false;
     }
     if (func_num_args() === 3) {
         $value = func_get_arg(2);
         // check for value and convert it to a string for writing
         if (isset($value)) {
             // convert $value to string
             $value = Helpers::get_string($value);
             // remove HTML line breaks from log message
             $value = str_replace(array("<br />\n", '<br />', '&nbsp;'), array("\n", "\n", ' '), $value);
             $message = $message . ': ' . $value;
         }
     }
     if ($this->log_level <= $log_level && Helpers::is_string_ne($this->file)) {
         // get call string from backtrace
         $call_string = Helpers::get_call_string();
         // build the message
         $message = date($this->date_format) . $this->separator . $call_string . $this->separator . $message;
         $this->messages[] = $message;
         // write the message to the provided log file
         //return file_put_contents($this->log_directory . $this->file, $message . PHP_EOL, FILE_APPEND);
         return fwrite($this->handle, $message . PHP_EOL);
     }
     return true;
 }
开发者ID:mts7,项目名称:mtsapps-framework,代码行数:41,代码来源:Log.php

示例5: insertValues

 /**
  * Insert values into to table.
  *
  * @param string $table
  * @return bool|string
  * @uses DatabaseMap::$to_values
  * @uses Db::buildInsert()
  * @uses Db::begin()
  * @uses Db::query()
  * @uses Db::commit()
  */
 private function insertValues($table = '')
 {
     $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION);
     // input validation
     if (!Helpers::is_string_ne($table) || !Helpers::is_array_ne($this->to_values[$table])) {
         $this->Log->write('table is invalid or to values does not contain table ' . $table, Log::LOG_LEVEL_WARNING);
         return false;
     }
     // get values for table
     $values = $this->to_values[$table];
     // build insert query and parameters
     $result = $this->buildInsert($table, $values, true, true);
     if ($result === false) {
         $this->Log->write('could not build insert for ' . $table, Log::LOG_LEVEL_WARNING);
         return false;
     }
     list($sql, $parameters) = $result;
     $this->Log->write('trying insert query in transaction', Log::LOG_LEVEL_USER);
     $this->begin();
     $this->query($sql, $parameters, 'insert');
     if ($this->debug) {
         $this->Log->write('rolling back transaction due to debug', Log::LOG_LEVEL_USER);
         $this->rollback();
         $output = $sql . PHP_EOL . Helpers::get_string($parameters);
     } else {
         $this->Log->write('committing transaction', Log::LOG_LEVEL_USER);
         $this->commit();
         $output = true;
     }
     return $output;
 }
开发者ID:mts7,项目名称:mtsapps-framework,代码行数:42,代码来源:DatabaseMap.php

示例6: creator

 /**
  * Set and/or get the creator.
  *
  * [@param] string|array|mixed $creator
  * @return string
  */
 public function creator()
 {
     $args = func_get_args();
     if (Helpers::is_array_ne($args)) {
         if (Helpers::is_string_ne($args[0])) {
             $this->creator = $args[0];
         } elseif (Helpers::is_array_ne($args[0])) {
             $this->creator = implode(', ', $args[0]);
         } else {
             $this->creator = Helpers::get_string($args[0]);
         }
     }
     return $this->creator;
 }
开发者ID:mts7,项目名称:mtsapps-framework,代码行数:20,代码来源:PdfMerge.php


注:本文中的Helpers::get_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。