Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: My_eGallery converter 0.1  (Read 33491 times)

0 Members and 1 Guest are viewing this topic.

mnt

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
My_eGallery converter 0.1
« on: March 14, 2006, 04:44:30 pm »

have fun with it.

Code: [Select]
<pre><?
  /* My_eGallery converter 0.1
  ** Slapped together on 14.3.2006 by mnt /ät/ codeninja.de
  **
  ** Copy all your files from gallery/ to albums/
  ** Just stringreplace "cpg_" with your own prefix, eg. "gpc144_"
  ** Do the same if your nuke-prefix isn't "nuke_"
  **
  ** Consider temporarily raising the php memory limit if you got very big jpegs in your gallery
  **
  ** This script also generates thumbs and normals, because admin_tools are a pain in the ass in my opinion
  ** gallery.gif and thumb/ will be removed, as no longer needed
  */

  error_reporting(E_ALL);
  set_time_limit(0);
  @mysql_connect("localhost","xxx","xxx");
  @mysql_select_db("xxx");

//  mysql_query("TRUNCATE TABLE `cpg_albums`");
//  mysql_query("TRUNCATE TABLE `cpg_pictures`");
//  mysql_query("TRUNCATE TABLE `cpg_comments`");

////////////////////////////////////////////////////////////////////////////////

   if (!function_exists('scandir')) {
      function scandir($dir = './', $sort = 0) {
         $dir_open = @ opendir($dir);
         if (! $dir_open) return false;
         while (($dir_content = readdir($dir_open)) !== false) $files[] = $dir_content;
         if ($sort == 1) rsort($files, SORT_STRING);
         else sort($files, SORT_STRING);
         return $files;
      }
   }

  //lifted from pixtool resize_func:
  function doresize($filename,$target,$maxsize,$maxsizey=false,$forceoverwrite=false,$onlydown=false){
   if (!file_exists("$filename")) { return false; }
   
   if ($maxsizey==false) { $maxsizey=$maxsize; }
   
   if (!file_exists($filename)) { return false; }
   if (file_exists("$target")) { if (!$forceoverwrite) { return false; } }
   
    $groessen=@getimagesize($filename);
    $o_width=$groessen[0];
    $o_height=$groessen[1];
    if ($o_width==0) { return; }
    $d_width=$o_width/$maxsize;
    $d_height=$o_height/$maxsizey;
   
    if ($d_width>=$d_height) { //querformat
      $n_width=$maxsize;
      $n_height=round($o_height/$d_width);
     } else {
      $n_height=$maxsizey;
      $n_width=round($o_width/$d_height);
     }
   
     if ($onlydown) {
        if (($n_width>=$o_width) and ($n_height>=$o_height)) { return false; }
     }
   
     switch ($groessen[2]) {
        case 1: $image = imagecreatefromgif($filename); break;
        case 2: $image = imagecreatefromjpeg($filename); break;
        case 3: $image = imagecreatefrompng($filename); break;
     }
   
     if ($image) {
       $tn = imagecreatetruecolor($n_width,$n_height);
       imagecopyresampled($tn,$image,0,0,0,0,$n_width,$n_height,$o_width,$o_height);
       switch ($groessen[2]) {
         case 1:imagegif($tn,"$target");
         case 2:imagejpeg($tn,"$target",80); break;
         case 3:imagepng($tn,"$target"); break;
       }
       imagedestroy($tn);
     }
     @imagedestroy($image);
   
     return true;
  }
   
////////////////////////////////////////////////////////////////////////////////

  $config=array('alb_list_thumb_size','picture_width','max_upl_width_height','normal_pfx','thumb_pfx');
  foreach ($config as $k) {
     $r=mysql_query("SELECT value FROM cpg_config WHERE name='$k'");
     $config[$k]=mysql_result($r,0);
  }

  $r=mysql_query("SELECT * FROM nuke_gallery_categories ORDER BY gallid ASC");
  while ($rows=mysql_Fetch_assoc($r)) {
     $sql="INSERT INTO cpg_albums (aid,title,description,pos) VALUES (
     '".mysql_escape_string($rows['gallid'])."',
     '".mysql_escape_string($rows['gallname'])."',
     '".mysql_escape_string($rows['description'])."',
     '-".mysql_escape_string($rows['gallid'])."')";

     $path='albums/'.$rows['galloc'].'/';

     echo "$sql\n"; mysql_query($sql);

     if (file_exists($path.'gallery.gif')) {
        unlink($path.'gallery.gif');
     }

     if (is_dir($path.'thumb')) {
        $thumbs=scandir($path.'thumb/');
        foreach ($thumbs as $thumb) {
           if (!is_dir($path.'thumb/'.$thumb)) {
              unlink($path.'thumb/'.$thumb);
           }
        }
        rmdir($path.'thumb/');
     }

     $r2=mysql_query("SELECT * FROM nuke_gallery_pictures WHERE gid=".$rows['gallid']." ORDER BY pid ASC");
     while ($rows2=mysql_fetch_assoc($r2)) {

        $filename=$path.$rows2['img'];
        $normname=$path.$config['normal_pfx'].$rows2['img'];
        $thmbname=$path.$config['thumb_pfx'].$rows2['img'];

        $size=filesize($path.$rows2['img']);
        $tsize=$size;

        doresize($filename,$thmbname,$config['alb_list_thumb_size'],false,false,true);

        $psize=getimagesize($filename);
        if (($psize[0]>$config['picture_width']) or ($psize[1]>$config['picture_width'])) {
           doresize($filename,$normname,$config['picture_width'],false,false,true);
           $tsize=$size+filesize($normname);
        }

        $sql="INSERT INTO cpg_pictures (pid,aid,filepath,filename,filesize,total_filesize,pwidth,pheight,hits,ctime,owner_id,owner_name,approved) VALUES (
             '".mysql_escape_string($rows2['pid'])."',
             '".mysql_escape_string($rows2['gid'])."',
             '".mysql_escape_string($rows['galloc'])."/',
             '".mysql_escape_string($rows2['img'])."',
             '".mysql_escape_string($size)."',
             '".mysql_escape_string($tsize)."',
             '".mysql_escape_string($rows2['width'])."',
             '".mysql_escape_string($rows2['height'])."',
             '".mysql_escape_string($rows2['counter'])."',
             '".mysql_escape_string(strtotime($rows2['date']))."',
             '1',
             'mnt',
             'YES')";

             echo "$sql\n"; mysql_query($sql);
     }
  }

  $r=mysql_query("SELECT * FROM nuke_gallery_comments");
  while ($rows=mysql_Fetch_assoc($r)) {
     $sql="INSERT INTO cpg_comments (pid,msg_author,msg_body,msg_date) VALUES (
     '".mysql_escape_string($rows['pid'])."',
     '".mysql_escape_string($rows['name'])."',
     '".mysql_escape_string($rows['comment'])."',
     '-".mysql_escape_string($rows['date'])."')";
     
     echo "$sql\n"; mysql_query($sql);
  }
?>*** All done.</pre>
« Last Edit: March 14, 2006, 06:57:52 pm by GauGau »
Logged

philou5672

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: My_eGallery converter 0.1
« Reply #1 on: September 15, 2008, 09:40:24 pm »

hello comment marche ce script please?

[translate by PYAP] Hello how this script work please ? [/translate]
« Last Edit: September 16, 2008, 09:21:02 pm by Pascal YAP »
Logged

Nibbler

  • Guest
Re: My_eGallery converter 0.1
« Reply #2 on: September 16, 2008, 08:48:06 pm »

Ask for a translation of the instructions on the french support board.
Logged

adsfgas324

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
    • usa business directory
Re: My_eGallery converter 0.1
« Reply #3 on: February 10, 2011, 12:31:46 pm »

i think that this is a good place, to find Insurance
Logged

jerrykemic99

  • Coppermine newbie
  • Offline Offline
  • Posts: 4
Re: My_eGallery converter 0.1
« Reply #4 on: March 09, 2011, 10:56:11 am »

Nice work!And thanks a lot for my egallery convertor 0.1 information.
Logged
 *Link Removed*
 *Link Removed*
 *Link Removed*
Pages: [1]   Go Up
 

Page created in 0.029 seconds with 20 queries.