예제 #1
0
파일: Quiz.php 프로젝트: h-inuzuka/quiz
 public function show()
 {
     $app = \Slim\Slim::getInstance();
     $quizzes = new M_Quiz();
     $quizList = $quizzes->getQuizzes();
     //         var_dump($quizList);
     //         exit;
     $count = 0;
     foreach ($quizList as $quiz) {
         array_splice($quizList[$count], 0, 0, Common::getTargetColumn(M_Quiz::find($quiz['id'])->questions, 'original'));
         $count++;
     }
     $app->render('Quiz/show.twig', ['quiz_list' => $quizList]);
 }
 public function setConfigValueAction()
 {
     $vm = new ViewModel();
     $vm->setTerminal(true);
     $sessionStorage = new SessionStorage();
     $configStorage = new ConfigStorage($this->serviceLocator->get('adb'));
     $request = $this->getRequest();
     if (!$request->isPost()) {
         $id = $this->params()->fromQuery('id');
         if ($id === null) {
             // no config value id given
             $vm->setVariable('error', true);
             return $vm;
         }
         $currentValue = $configStorage->getRecord($id);
         $token = Common::generateToken();
         $vm->setVariables(['token' => $token, 'id' => $id, 'c_name' => $currentValue['c_name'], 'c_value' => $currentValue['c_value'], 'e_value' => $currentValue['e_value']]);
         $sessionStorage->setValue('set-config-value-token', $token);
         return $vm;
     }
     $vm->setTemplate('admin/config/empty.phtml');
     $post = $request->getPost();
     $token = $post['token'];
     $storedToken = $sessionStorage->getValue('set-config-value-token');
     $sessionStorage->setValue('set-config-value-token', null);
     if ($token != $storedToken) {
         echo XmlResponder::generalResponse('300', 'Invalid token provided');
         return $vm;
     }
     $id = isset($post['id']) ? $post['id'] : null;
     $c_name = $post['c_name'];
     $c_value = $post['c_value'];
     $e_value = $post['e_value'];
     $newId = $configStorage->setValue($c_name, $c_value);
     if (!empty($e_value)) {
         $configStorage->setExtendedValue($newId, $e_value);
     } else {
         // remove extension if exists
         $rec = $configStorage->getRecord($newId);
         if ($rec['extended'] > 0) {
             $configStorage->removeExtension($rec['extended']);
         }
     }
     echo XmlResponder::generalResponse('200', 'OK');
     return $vm;
 }
예제 #3
0
파일: Question.php 프로젝트: h-inuzuka/quiz
 public function getAllQuestions()
 {
     $questionAll = Question::all();
     $questionList = Common\Common::getTargetColumn($questionAll, 'original');
     return $questionList;
 }
예제 #4
0
파일: Quiz.php 프로젝트: h-inuzuka/quiz
 public function getQuiz($quizId)
 {
     $quiz = Quiz::find($quizId);
     $questionList = Common\Common::getTargetColumn($quiz, 'original');
     return $questionList;
 }
예제 #5
0
 public function getDomainLowestPrice($domain, $price)
 {
     //(class,two,three,长度,域名主体)
     list($class, $two, $three, $domainLen, $domainMain) = \common\domain\Domain::getDomainClass($domain);
     // 获取一口价最低价提示配置
     $buynowLowest = \core\Config::item('buynow_lowest')->toArray();
     // 获取域名主体$domainMain 以及 域名后缀 $domainTld
     $domainTld = \common\Common::getDomainAllTld($domain);
     // 获取域名所属类型
     $domainType = $this->getDomainType($class, $domainMain, $domainTld, $domainLen);
     if (!$domainType) {
         return false;
     }
     // 获取返回该域名最低价。未匹配到返回false
     if (isset($buynowLowest[$domainTld][$domainLen][$domainType])) {
         $price = $buynowLowest[$domainTld][$domainLen][$domainType];
         return $price * 10000;
     }
     return false;
 }
예제 #6
0
 private function uploadImage($path)
 {
     $imageInfo = getimagesize($path);
     $w = $imageInfo[0];
     $h = $imageInfo[1];
     $aspect = 'box';
     if ($h > $w) {
         $aspect = 'vertical';
     } elseif ($w > $h) {
         $aspect = 'horizontal';
     }
     $image = $this->loadImage($path);
     if ($image === false) {
         error_log('invalid image ' . $path);
         return false;
     }
     switch ($aspect) {
         case 'box':
         case 'horizontal':
             $ratio = $h / $w;
             $resized = imagescale($image, 900, 900 * $ratio);
             break;
         default:
             $ratio = $w / $h;
             $resized = imagescale($image, 900 * $ratio, 900);
     }
     $filename = md5(Common::generateRandomString(20)) . '.jpg';
     imagejpeg($resized, \SmConfig::imagePath . $filename, 60);
     imagedestroy($image);
     imagedestroy($resized);
     return $filename;
 }
예제 #7
0
파일: Answer.php 프로젝트: h-inuzuka/quiz
 public function getAnswers()
 {
     $answerFindResult = Answer::all();
     $answerList = Common\Common::getTargetColumn($answerFindResult, 'original');
     return $answerList;
 }
예제 #8
0
파일: Domain.php 프로젝트: nicklos17/eapi
 private static function getClass($domainBody)
 {
     $class = 3;
     if (preg_match("/^\\d+\$/", $domainBody)) {
         $class = 1;
     } elseif (\common\Common::isCnBody($domainBody)) {
         $class = 4;
     } elseif (preg_match("/^[a-z]+\$/", $domainBody)) {
         $class = 2;
     }
     return $class;
 }