Example #1
0
 /**
  * Получение типа файла
  * @param string $name имя файла
  * @param string $mime MIME тип файла
  * @return array массив: имя файлового типа, допустимых типов файлов и 
  * допустимых MIME типов файла
  * @throws EngineException
  */
 protected function get_type($name, $mime)
 {
     $file_type = file::o()->get_filetype($name);
     foreach (self::$file_types as $ftype => $arr) {
         if (!$arr["allowed"]) {
             continue;
         }
         if (!$this->url) {
             $mimes = $arr["MIMES"];
             if ($mimes && !checkpos($mimes, $mime)) {
                 continue;
             }
         }
         $types = $arr["types"];
         if (!checkpos($types, $file_type)) {
             continue;
         }
         $type = $ftype;
         break;
     }
     if (!$type) {
         throw new EngineException('file_no_type');
     }
     return array($type, $types, $mimes);
 }
Example #2
0
 /**
  * Установка цвета темы
  * @param string $color имя цвета
  * @return string установленный цвет
  */
 public function set_color($color)
 {
     $vars = $this->init_cfg(null, null);
     $def = strtolower($vars['default_name']);
     $defc = strtolower($vars['color_default']);
     $color = strtolower($color);
     $allowed = strtolower($vars['allowed_colors']);
     if ($color == strtolower($def)) {
         $color_path = "";
     } else {
         if (!checkpos($allowed, $color, "|")) {
             if (checkpos($allowed, $defc, "|")) {
                 $color = $defc;
             } else {
                 return $this->set_color($def);
             }
         }
         if (!validword($color)) {
             $color_path = "";
         } else {
             $color_path = COLORS_PATH . "/" . $color . "/";
         }
     }
     $this->assign('color_path', $color_path);
     globals::s('color_path', $color_path);
     return $color;
 }