Beispiel #1
0
function smarty_modifier_idate($string, $format = 'Y-m-d H:i:s', $default_date = '')
{
    if ($string != '') {
        $timestamp = smarty_make_timestamp($string);
    } elseif ($default_date != '') {
        $timestamp = smarty_make_timestamp($default_date);
    } else {
        return;
    }
    return Core_Fun::date($format, $timestamp);
}
Beispiel #2
0
 public static function getRetJson($errorCode, $errorMessage = '', $data = NULL, $callback = NULL)
 {
     if (empty($errorMessage)) {
         $errorMessage = self::getMsg($errorCode);
     }
     $jsonPrototype = array('error_code' => $errorCode, 'error_message' => $errorMessage);
     if (!empty($data)) {
         $jsonPrototype += is_string($data) ? str_replace(array("\r", "\n", "\t"), '', $data) : $data;
     }
     //对变量进行 JSON 编码
     $json = Core_Fun::jsonEncode($jsonPrototype);
     return $json;
 }
Beispiel #3
0
/**
 * Smarty itruncate modifier plugin
 * Smarty 中文截字修正
 *
 * @author   Icehu
 * @param string
 * @param integer
 * @param string
 * @return string
 */
function smarty_modifier_itruncate($string, $length = 80, $etc = '')
{
    if ($length == 0) {
        return '';
    }
    if (strlen($string) > $length) {
        $length -= min($length, strlen($etc));
        $string = Core_Fun::cn_substr($string, $length, $etc);
        return $string;
    } else {
        return $string;
    }
}
Beispiel #4
0
 /**
  * 获取API调用的客户端,无需token
  * @return Core_Open_Client
  */
 public static function getNoneTokenClient()
 {
     if (isset(self::$noneTokenClient)) {
         return self::$noneTokenClient;
     }
     //获取安装时候的key
     $akey = Core_Config::get('appkey', 'basic');
     $skey = Core_Config::get('appsecret', 'basic');
     if (empty($akey) || empty($skey)) {
         Core_Fun::error('key丢失', 102);
     }
     self::$noneTokenClient = new Core_Open_Client($akey, $skey);
     return self::$noneTokenClient;
 }
Beispiel #5
0
 /**
  * 重新封装的get请求.
  *
  * @return mixed
  */
 function get($url, $parameters)
 {
     Core_Fun::apiLog($url, NULL);
     $response = $this->oAuthRequest($url, 'GET', $parameters);
     if ($this->format === 'json') {
         try {
             $response = $this->jsonDecode($response, true);
         } catch (Exception $e) {
             $response = json_decode($response, true);
             Core_Fun::apiLog($url, $response);
             throw $e;
         }
         Core_Fun::apiLog($url, $response);
         return $response;
     }
     return $response;
 }
Beispiel #6
0
/**
 * Smarty iurlencode modifier plugin
 * Smarty Url编码修正
 *
 * @author   Icehu
 */
function smarty_modifier_iurlencode($string)
{
    return Core_Fun::iurlencode($string);
}
Beispiel #7
0
 /** 
  * check that the timestamp is new enough 
  */
 private function check_timestamp($timestamp)
 {
     // verify that timestamp is recentish
     $now = Core_Fun::time();
     if ($now - $timestamp > $this->timestamp_threshold) {
         throw new Core_Exception("Expired timestamp, yours {$timestamp}, ours {$now}");
     }
 }