function __construct($content, $pageId, $pageUrl)
 {
     GlizyClassLoader::addLib('Gregwar\\Captcha', __Paths::get('APPLICATION_LIBS') . 'captcha');
     $this->content = $content;
     $this->pageId = $pageId;
     $this->pageUrl = $pageUrl;
     $this->count = count($this->content);
     $this->sessionEx = new org_glizy_SessionEx($pageId);
     $this->captchaBuilder = new Gregwar\Captcha\CaptchaBuilder();
 }
Exemple #2
0
 private function decompressFiles($medias)
 {
     if (!property_exists($medias, '__expand')) {
         return $medias;
     }
     GlizyClassLoader::addLib('VIPSoft\\Unzip', __Paths::get('APPLICATION_LIBS') . 'VIPSoft/Unzip');
     $copyProperties = function (&$properties, &$medias, &$tempMedias, $pos) {
         foreach ($properties as $v) {
             $tempMedias->{$v}[] = @$medias->{$v}[$pos];
         }
     };
     $properties = array_keys(get_object_vars($medias));
     if (!in_array('media_title', $properties)) {
         $properties[] = 'media_title';
     }
     $tempMedias = new StdClass();
     foreach ($properties as $v) {
         $tempMedias->{$v} = array();
     }
     $numUploaded = count($medias->__uploadFilename);
     for ($i = 0; $i < $numUploaded; $i++) {
         if (!$medias->__uploadFilename[$i]) {
             continue;
         }
         if ($medias->__expand[$i] == 1) {
             $unzipper = new VIPSoft\Unzip\Unzip();
             $destFolder = $medias->__uploadFilename[$i] . md5(time());
             $filenames = $unzipper->extract($medias->__uploadFilename[$i], $destFolder);
             foreach ($filenames as $f) {
                 if (strpos($f, '__MACOSX') !== false || strpos($f, '.DS_Store') !== false) {
                     continue;
                 }
                 $filename = $destFolder . '/' . $f;
                 if (is_dir($filename)) {
                     continue;
                 }
                 $pos = count($tempMedias->__uploadFilename);
                 $copyProperties($properties, $medias, $tempMedias, $i);
                 $info = pathinfo($filename);
                 $tempMedias->__uploadFilename[$pos] = $filename;
                 $tempMedias->__originalFileName[$pos] = $info['basename'];
                 $tempMedias->media_title[$pos] = str_replace(array('_', '-'), ' ', $info['filename']);
             }
         } else {
             $copyProperties($properties, $medias, $tempMedias, $i);
         }
     }
     return $tempMedias;
 }