예제 #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
파일: Newsletter.php 프로젝트: schpill/thin
 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));
     }
 }