Ejemplo n.º 1
0
 private function createFileName()
 {
     return utilsGmp::getRandStr() . '-' . utilsGmp::getRandStr() . '-' . utilsGmp::getRandStr() . '-' . utilsGmp::getRandStr();
 }
Ejemplo n.º 2
0
 public function downloadIconFromUrl($url)
 {
     $filename = basename($url);
     if (empty($filename)) {
         $this->pushError(__('File not found', GMP_LANG_CODE));
         return false;
     }
     $imageinfo = getimagesize($url, $imgProp);
     if (empty($imageinfo)) {
         $this->pushError(__('Cannot get image', GMP_LANG_CODE));
         return false;
     }
     $fileExt = str_replace("image/", "", $imageinfo['mime']);
     $filename = utilsGmp::getRandStr(8) . "." . $fileExt;
     $dest = $this->getIconsFullPath() . $filename;
     file_put_contents($dest, fopen($url, 'r'));
     $newIconId = frameGmp::_()->getTable('icons')->store(array('path' => $filename), "insert");
     if ($newIconId) {
         return array('id' => $newIconId, 'path' => $this->getIconsFullDir() . $filename);
     } else {
         $this->pushError(__('cannot insert to table', GMP_LANG_CODE));
         return false;
     }
 }