示例#1
0
文件: Project.php 项目: schpill/thin
 public static function makeKey($type)
 {
     $dir = static::checkDir($type);
     $key = Inflector::quickRandom(9);
     $check = STORAGE_PATH . DS . 'project' . DS . $dir . DS . $key . '.' . Inflector::lower($type);
     if (File::exists($check)) {
         return static::makeKey($type);
     }
     return $key;
 }
示例#2
0
文件: Cart.php 项目: schpill/thin
 private static function _makeKey($keyLength = 9)
 {
     $key = Inflector::quickRandom($keyLength);
     if (!Arrays::in($key, static::$keys)) {
         static::$keys[] = $key;
         return $key;
     } else {
         return static::_makeKey($keyLength);
     }
 }
示例#3
0
文件: Blog.php 项目: schpill/thin
 public static function makeKey()
 {
     $key = Inflector::quickRandom(9);
     $check = STORAGE_PATH . DS . 'articles' . DS . $key . '.message';
     if (File::exists($check)) {
         return static::makeKey();
     }
     return $key;
 }
示例#4
0
 public static function makeView($campaign, $user)
 {
     $dirStatsViews = STORAGE_PATH . DS . 'newsletters' . DS . 'stats' . DS . 'views';
     $dirCampaign = $dirStatsViews . DS . $campaign->getId();
     if (!is_dir($dirCampaign)) {
         mkdir($dirCampaign, 0777);
     }
     $dirUser = $dirCampaign . DS . $user->getId();
     if (!is_dir($dirUser)) {
         mkdir($dirUser, 0777);
     }
     $count = glob($dirUser . DS . '*.count', GLOB_NOSORT);
     if (!count($count)) {
         $key = Inflector::quickRandom(9);
         $newCount = $dirUser . DS . $key . '.count';
         $initialize = new viewCount();
         $initialize->setId($key);
         $initialize->setCampaign($campaign->getId());
         $initialize->setUser($user->getId());
         $initialize->setCount(0);
         $initialize->setDates(array());
         $serialize = serialize($initialize);
         File::delete($newCount);
         File::put($newCount, $serialize);
         return $initialize;
     } else {
         return static::getObject(current($count));
     }
 }