예제 #1
0
 /**
  * Create Users
  * @example  $users->create('admin', 'password', '*****@*****.**');
  * @return booleon
  */
 public function create($username, $password, $email, $ex_data = NULL)
 {
     // Data information
     $this->data['username'] = $username;
     $this->data['password'] = Strong::factory()->hash_password($password);
     $this->data['email'] = $email;
     if (is_array($ex_data)) {
         foreach ($ex_data as $key => $value) {
             $this->data[$key] = $value;
         }
     }
     // Set the save field
     $this->db->insert($this->table, $this->data);
     $this->user_id = $this->db->insert_id();
     if ((bool) $this->user_id) {
         return $this->user_id;
     }
 }
예제 #2
0
 /**
  * Protect a page, route, controller, url
  * @param string $name
  * @return boolean
  */
 public static function protect($name = 'default')
 {
     if (!Strong::getInstance($name)->loggedIn()) {
         return false;
     }
     return true;
 }
예제 #3
0
 protected function createGeneralContent()
 {
     $mainTag = new Div();
     $goods = new DBGoodsType();
     $itemId = Utils::getFromGET("page_id");
     $goods->executeRequest(DB::TABLE_GOODS__KEY_ITEM, $itemId, DB::TABLE_GOODS___ORDER, DB::ASC);
     $response = $goods->getResponse();
     $mainTag->addStyleClasses(["single_item"]);
     $row = mysql_fetch_array($response);
     if ($row) {
         $imagePathes = FileUtils::getFilesByPrefixByDescription(Constants::DEFAULT_ROOT_CATALOG_PATH . DIRECTORY_SEPARATOR . $itemId . DIRECTORY_SEPARATOR, Constants::SMALL_IMAGE, 'jpg');
         $filesSmall = FileUtils::getFilesByPrefixByDescription(Constants::DEFAULT_ROOT_CATALOG_PATH . DIRECTORY_SEPARATOR . $itemId . DIRECTORY_SEPARATOR, Constants::SMALL_IMAGE, "jpg");
         $filesMedium = FileUtils::getFilesByPrefixByDescription(Constants::DEFAULT_ROOT_CATALOG_PATH . DIRECTORY_SEPARATOR . $itemId . DIRECTORY_SEPARATOR, Constants::MEDIUM_IMAGE, "jpg");
         $firstImage = FileUtils::getFirstFileInDirectoryByPrefixByDescription(Constants::DEFAULT_ROOT_CATALOG_PATH . DIRECTORY_SEPARATOR . $itemId . DIRECTORY_SEPARATOR, Constants::MEDIUM_IMAGE, 'jpg');
         if ($firstImage == '') {
             $firstImage = FileUtils::getCapImage(Labels::CAP_IMAGE_FOR_CLOTHING);
         }
         sort($imagePathes);
         sort($filesSmall);
         sort($filesMedium);
         $defaultBackgroundImage = $this->getFirstImage($itemId, Constants::MEDIUM_IMAGE);
         $titleBlock = new Strong();
         $titleBlock->addStyleClasses(["title", "f-30"]);
         $titleBlock->addChild($row[DB::TABLE_GOODS__NAME]);
         $this->updateTitleTagChildren([$row[DB::TABLE_GOODS__NAME] . ' - ']);
         $metaDesc = new Meta();
         $metaDesc->addAttributes(["name" => "description", "content" => "на этой странице Вы найдете подробное описание для товара " . $row[DB::TABLE_GOODS__NAME] . ", а также сможете пролистать фотографии и просмотреть их увеличенную версию"]);
         $this->addMetaTags($metaDesc);
         $infoBlock = new Div();
         $infoBlock->addStyleClass("info");
         $leftBlock = new Div();
         $leftBlock->addStyleClasses(["left_block"]);
         $bigImg = new Div();
         $bigImg->addStyleClasses(["big_img", "float_left"]);
         $bigImg->addAttribute("style", "background-image: url({$defaultBackgroundImage});filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$defaultBackgroundImage}',sizingMethod='scale');-ms-filter: \"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$defaultBackgroundImage}',sizingMethod='scale')\";");
         $square = new Div();
         $square->addStyleClass("squareX");
         $zoom = new Div();
         $zoom->addStyleClass("zoom_image");
         $zoom->addAttribute("style", "background-image: url(.{$defaultBackgroundImage}.)");
         $img1 = new Img();
         $img1->addAttribute("src", $firstImage);
         $img1->updateId("main_gallery_image");
         $img2 = new Img();
         $img2->addAttribute("src", $firstImage);
         $img2->updateId("img_effect");
         $square->addChildList([$zoom, $img1, $img2]);
         $square->addChildList($this->getImageSwitcher());
         $leftBlock->addChildList([$square, $this->getPreviewImages($filesMedium, Constants::MEDIUM_IMAGE . "images", false)]);
         $rightBlock = new Div();
         $rightBlock->addStyleClasses(["right_block"]);
         $overviewImgs = $this->getPreviewImages($filesSmall, Constants::SMALL_IMAGE . "images", true);
         $overviewImgs->updateId("gallery");
         $overviewImgs->addStyleClass("w-100p");
         $rightBlock->addChildList([$overviewImgs]);
         $index = 0;
         $imgList = new Div();
         $imgList->addStyleClass("scroll_child");
         /*foreach($imagePathes as $imagePath) {
               if (count(trim($imagePath)) != 0) {
                   $index++;
                   $activeImg = '';
                   $cursor = 'review';
                   if ($index == 1) {
                       $active = 'preview_image_current_border';
                       $activeImg = 'img_to_front';
                   } else {
                       $active = "preview_image_hover_border";
                       $cursor = 'cursor_pointer';
                   }
                   $imgItem = new Div();
                   $imgItem->addStyleClasses(["image_item", "float_left", $cursor]);
                   $zoomWindowContainer = new Div();
                   $zoomWindowContainer->addStyleClass("zoom_window_container");
                   $zoomWindow = new Div();
                   $zoomWindow->addStyleClass("zoom_window");
                   $zoomWindowContainer->addChild($zoomWindow);
                   $previewImgBorder = new Div();
                   $previewImgBorder->addStyleClasses("preview_image_border", $active);
                   $previewImage = new Img();
                   $previewImage->addAttribute("src", $imagePath);
                   $previewImage->addStyleClasses(["preview_image", $activeImg]);
                   $imgItem->addChildList([$zoomWindowContainer, $previewImgBorder, $previewImage]);
               }
           }*/
     }
     $description = $this->getImageDescription($row[DB::TABLE_GOODS__DESCRIPTION]);
     return $mainTag->addChildList([$titleBlock, $infoBlock->addChildList([$leftBlock, $rightBlock, $description])]);
 }
예제 #4
0
 /**
  * HTTPAuth based authentication
  * 
  * This method will check the HTTP request headers for previous authentication. If
  * the request has already authenticated, the next middleware is called. Otherwise,
  * a 401 Authentication Required response is returned to the client.
  * 
  * @param Strong $auth 
  * @param object $req
  */
 private function httpauth(Strong $auth, $req)
 {
     $res = $this->app->response();
     $authUser = $req->headers('PHP_AUTH_USER');
     $authPass = $req->headers('PHP_AUTH_PW');
     if ($authUser && $authPass && $auth->login($authUser, $authPass)) {
         $this->next->call();
     } else {
         $res->status(401);
         $res->header('WWW-Authenticate', sprintf('Basic realm="%s"', $this->config['realm']));
     }
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function parse($node)
 {
     return parent::parse($node);
 }