コード例 #1
0
ファイル: theme.php プロジェクト: anastiel/lainchan
function rand_build($action, $settings)
{
    $rand = new rand();
    $rand->settings = $settings;
    file_write($settings['uri'] . '/index.html', $rand->build());
    file_write($settings['uri'] . '/rand.js', Element('themes/rand/rand.js', array()));
}
コード例 #2
0
ファイル: rand.php プロジェクト: dalinhuang/zotop
 public static function guid($mix = '', $len = 32)
 {
     if (is_object($mix) && function_exists('spl_object_hash')) {
         return spl_object_hash($mix);
     } elseif (is_resource($mix)) {
         $mix = get_resource_type($mix) . strval($mix);
     } else {
         $mix = empty($mix) ? rand::string(32) : $mix;
         $mix = serialize($mix);
     }
     return md5($mix);
 }
コード例 #3
0
ファイル: file.php プロジェクト: dalinhuang/zotop
 /**
  * 上传文件
  *
  * @param string $name  FILE字段名称
  * @param string $path  上传的路径
  * @param string $ext   扩展名
  * @param boolean $rename 是否重新命名
  * @return array
  */
 public static function upload($name, $path, $ext, $rename = true)
 {
     if (!dir::exists(dirname($path))) {
         dir::create(dirname($path));
     }
     $ext = explode(',', $ext);
     $files = $_FILES[$name];
     $attachments = array();
     //转换数组
     if (is_array($files['name'])) {
         foreach ($files as $key => $var) {
             foreach ($var as $id => $val) {
                 $attachments[$id][$key] = $val;
             }
         }
     } else {
         $attachments[] = $files;
     }
     //上传
     $return = array();
     foreach ($attachments as $k => $file) {
         if (in_array(self::ext($file['name']), $ext)) {
             $tmp = $path;
             if ($rename) {
                 $tmp .= DS . rand::string(10) . self::ext($file['name']);
             } else {
                 $tmp .= DS . $file['name'];
             }
             @move_uploaded_file($file['name'], $tmp);
             $return[] = $tmp;
             @unlink($file['tmp_name']);
         } else {
             $return[] = false;
         }
     }
     return $return;
 }
コード例 #4
0
ファイル: zotop.php プロジェクト: dalinhuang/zotop
 public static function instance($classname, $method = '', $args = array())
 {
     static $instances = array();
     $id = empty($args) ? strtolower($classname . $method) : strtolower($classname . $method . rand::guid($args));
     if (!isset($instances[$id])) {
         if (class_exists($classname)) {
             $instance = new $classname();
             if (method_exists($instance, $method)) {
                 $instances[$id] = call_user_func_array(array(&$instance, $method), $args);
             } else {
                 $instances[$id] = $instance;
             }
         } else {
             zotop::error($classname . ' not found!');
         }
     }
     return $instances[$id];
 }