imagepng($im, $fileName);
    imagedestroy($im);
}
// The PHP ICO Generator
require './php-ico-master/class-php-ico.php';
// フォーマット(ico or png)
$format = $_POST["format"];
// 出力先(file path)
if ($format == "ico") {
    $destination = $dirPath . '/' . $fa . '.ico';
} else {
    $destination = $fileName;
}
// ファビコンの作成(generate favicon using The PHP ICO Generator)
if ($format == "ico") {
    $ico_lib = new PHP_ICO($fileName);
    $ico_lib->save_ico($destination);
}
// ファイル名(file name)
if ($format == "ico") {
    $fname = $fa . '.ico';
} else {
    $fname = $fa . '.png';
}
// ダウンロードの処理(download)
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($destination));
header('Content-disposition: attachment; filename="' . $fname . '"');
readfile($destination);
// ダウンロード後ファイルを削除する(delete files)
unlink($fileName);
Exemple #2
0
 /**
  * @method POST
  */
 function update()
 {
     // get token
     $token = Utilities::ValidateJWTToken();
     // check if token is not null
     if ($token != NULL) {
         parse_str($this->request->data, $request);
         // parse request
         $url = $request['url'];
         $type = $request['type'];
         $site = Site::GetBySiteId($token->SiteId);
         if ($type == 'logo') {
             Site::EditLogo($token->SiteId, $url);
         } else {
             if ($type == 'alt') {
                 Site::EditAltLogo($token->SiteId, $url);
             } else {
                 if ($type == 'paypal') {
                     Site::EditPayPalLogo($token->SiteId, $url);
                 } else {
                     if ($type == 'icon') {
                         Site::EditIcon($token->SiteId, $url);
                         $source = SITES_LOCATION . '/' . $site['FriendlyId'] . '/files/' . $url;
                         // create the icon
                         $destination = SITES_LOCATION . '/' . $site['FriendlyId'] . '/favicon.ico';
                         $ico_lib = new PHP_ICO($source, array(array(32, 32), array(64, 64)));
                         $ico_lib->save_ico($destination);
                     }
                 }
             }
         }
         // publish site content
         Publish::PublishContent($token->SiteId);
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
     return new Tonic\Response(Tonic\Response::NOTIMPLEMENTED);
 }
Exemple #3
0
 /**
  * @method POST
  */
 function update()
 {
     // get an authuser
     $authUser = new AuthUser();
     if (isset($authUser->UserUniqId)) {
         // check if authorized
         parse_str($this->request->data, $request);
         // parse request
         $url = $request['url'];
         $type = $request['type'];
         if ($type == 'logo') {
             Site::EditLogo($authUser->SiteUniqId, $url);
         } else {
             if ($type == 'icon') {
                 Site::EditIcon($authUser->SiteUniqId, $url);
                 // create the icon
                 $source = '../sites/' . $authUser->SiteFriendlyId . '/files/' . $url;
                 $destination = '../sites/' . $authUser->SiteFriendlyId . '/favicon.ico';
                 if (file_exists($source)) {
                     $ico_lib = new PHP_ICO($source, array(array(32, 32), array(64, 64)));
                     $ico_lib->save_ico($destination);
                 }
             } else {
                 if ($type == 'paypal') {
                     Site::EditPayPalLogoUrl($authUser->SiteUniqId, $url);
                 }
             }
         }
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
     return new Tonic\Response(Tonic\Response::NOTIMPLEMENTED);
 }
   copy('gazie_site_menu_ri.png','gazie_site'.$company_id.'/gazie_site_menu_ri.png');
   copy('gazie_site_noimage.png','gazie_site'.$company_id.'/gazie_site_noimage.png');
   /* ATTENZIONE !!! Questi file vengono trasferiti sulla directory specifica per ogni azienda
    * solo la prima volta pertanto chi vuole personalizzarli può farlo modificando a piacimento
    * solo quelli della directory gazie_siteNNN mentre i file DI BASE presenti sul modulo "inform"
    * vengono sovrascritti dagli aggiornamenti  
    */
   @mkdir('gazie_site'.$company_id.'/images');
 }
 // creo la favicon
 $file=fopen('gazie_data.tmp','w+');
 fwrite($file,$admin_aziend['image']);
 fclose($file);
 $imgd=getimagesize('gazie_data.tmp',$info);
 $mime_logo=substr($imgd['mime'],-3);
 $ico_lib = new PHP_ICO('gazie_data.tmp',array(64,64));
 $ico_lib->save_ico( 'gazie_site'.$company_id.'/favicon.ico' );
 copy('gazie_data.tmp','gazie_site'.$company_id.'/gazie_site_logo.'.$mime_logo);
 // creo i file delle pagine sul filesystem del server
 $db_data=$form['page'];
 foreach ($pages_name_and_descri as $k=>$v) {
     $file = fopen('gazie_site'.$company_id.'/'.$v['name'].".html", "w");
     if ( $v['name']=='product' && $form['listin']>0 ) { // alla pagina dei prodotti aggiungo la tabella degli articoli con o senza prezzi listino
         $form['page'][$k]['data'] .= createProductTable($company_id,$form['listin'],$admin_aziend['decimal_price'],$admin_aziend['colore']);
     }
     $html = createHtmlPage($form['title'],$form['subtitle'],$form['author'],$form['keywords'], $pages_name_and_descri,$form['page'][$k], $mime_logo);
     fwrite($file, $html);
     fclose($file);
 }
 $r=filesTransfer($form['server'],$form['user'],$form['pass'],$form['path'],$company_id);
 if (!$r){ // Š tutto è andato a buon fine
Exemple #5
0
 /**
  * @method POST
  */
 function update()
 {
     // get token
     $token = Utilities::ValidateJWTToken(apache_request_headers());
     // check if token is not null
     if ($token != NULL) {
         parse_str($this->request->data, $request);
         // parse request
         $url = $request['url'];
         $type = $request['type'];
         $site = Site::GetBySiteId($token->SiteId);
         if ($type == 'logo') {
             Site::EditLogo($token->SiteId, $url);
         } else {
             if ($type == 'icon') {
                 Site::EditIcon($token->SiteId, $url);
                 if (FILES_ON_S3 == true) {
                     $bucket = $site['Bucket'];
                     $imagesURL = str_replace('{{bucket}}', $bucket, S3_URL);
                     $imagesURL = str_replace('{{site}}', $site['FriendlyId'], $imagesURL);
                     $source = $imagesURL . '/files/' . $url;
                 } else {
                     $source = SITES_LOCATION . '/' . $site['FriendlyId'] . '/files/' . $url;
                 }
                 // create the icon
                 $destination = SITES_LOCATION . '/' . $site['FriendlyId'] . '/favicon.ico';
                 $ico_lib = new PHP_ICO($source, array(array(32, 32), array(64, 64)));
                 $ico_lib->save_ico($destination);
             }
         }
         // publish site JSON
         Publish::PublishSiteJSON($token->SiteId);
         return new Tonic\Response(Tonic\Response::OK);
     } else {
         // unauthorized access
         return new Tonic\Response(Tonic\Response::UNAUTHORIZED);
     }
     return new Tonic\Response(Tonic\Response::NOTIMPLEMENTED);
 }
 public static function create_favicon($dir_name, $image, $sizes = false)
 {
     it_classes_load('it-file-utility.php');
     require_once dirname(__FILE__) . '/classes/class-php-ico.php';
     if (!is_array($sizes) || false === $sizes) {
         $sizes = array(array(16, 16), array(24, 24), array(32, 32), array(48, 48));
     }
     $ico = new PHP_ICO($image, $sizes);
     $path = ITFileUtility::get_writable_directory($dir_name);
     while (empty($name) || file_exists("{$path}/{$name}")) {
         $name = ITUtility::get_random_string(array(6, 10)) . '.ico';
     }
     $result = $ico->save_ico("{$path}/{$name}");
     if (true != $result) {
         return false;
     }
     @chmod("{$path}/{$name}", 0644);
     return "{$path}/{$name}";
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     $baseDir = Director::baseFolder() . '/assets/Theme';
     if (!is_dir($baseDir)) {
         mkdir($baseDir, 0777, true);
     }
     $changes = array_keys($this->owner->getChangedFields(false, 1));
     $shouldCompile = false;
     foreach ($changes as $change) {
         if (in_array($change, self::$styles_variables)) {
             $shouldCompile = true;
         }
     }
     // Create theme according to colors
     if (!empty($_POST['RefreshTheme']) || $shouldCompile) {
         $this->compileStyles();
     }
     // Create favicon
     $destination = Director::baseFolder() . $this->FaviconPath();
     if ($this->owner->IconID && (!empty($_POST['RefreshIcon']) || $this->owner->isChanged('IconID'))) {
         $source = $this->owner->Icon()->getFullPath();
         $ico_lib = new PHP_ICO($source, array(array(16, 16)));
         try {
             $ico_lib->save_ico($destination);
         } catch (Exception $ex) {
             SS_Log::log('Failed to create favicon : ' . $ex->getMessage(), SS_Log::DEBUG);
         }
     }
 }
 /**
  *
  *
  * @param $GD
  * @param $TargetPath
  */
 public static function imageIco($gd, $targetPath)
 {
     $imagePath = tempnam(sys_get_temp_dir(), 'iconify');
     imagepng($gd, $imagePath);
     $icoLib = new PHP_ICO($imagePath, [[16, 16]]);
     $icoLib->save_ico($targetPath);
     unlink($imagePath);
 }