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: copy file with a specific begining like 'thumb_' php  (Read 3498 times)

0 Members and 1 Guest are viewing this topic.

nasirmulani

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
  • *Banned*
copy file with a specific begining like 'thumb_' php
« on: September 02, 2007, 10:33:57 am »

could some help in writing a php code for copying specific files that start with 'thumb_' only and no other file. like we copy files with specific extension i want to copy files with specific starting. guys please help.

this is the code i am using but its not reading the content of the folder, it does  not read the file in a folder, i want to implement it for subdirs also.

Code: [Select]
<html><body>

<form action="copy.php" method="GET">
Source: <input type="text" name="source" />
Dest: <input type="text" name="dest" />
<input type="submit" />
</form>
</body></html>
<?php

function full_copy$source$target )
    {
        if ( 
is_dir$source ) )
        {
           @
mkdir$target );
           echo 
"<b>Creating dir:</b>".$target." <br/>";
            
$d dir$source );
           
            while ( 
FALSE !== ( $entry $d->read() ) )
            {
                if ( 
$entry == '.' || $entry == '..' )
                {
                    continue;
                }
               
                
$Entry $source '/' $entry;           
                if ( 
is_dir$Entry ) )
                {
                  
full_copy$Entry$target '/' $entry );
                  echo 
"<b>Copying file: </b> ".$target '/' $entry ."<br />" ;
                  continue;
                }

foreach (
glob("thumb_*") as $filename) {
    if (
copy($Entry.'/'.$filename,$target '/' $entry .'/'.$filename)) {
      echo 
"$filename copied to thumbs/$filename<br />";
    } else {
      echo 
"Unamble to copy $filename to thumbs/$filename<br />";
    }
  }
                  }
           
            
$d->close();
        }else
        {
  foreach (
glob("thumb_*") as $filename) {
    if (
copy($source.'/'.$filename,$target '/'.$filename)) {
      echo 
"$filename copied to thumbs/$filename<br />";
    } else {
      echo 
"Unamble to copy $filename to thumbs/$filename<br />";
    }
  }


        }

}

//*****************************

if (isset($_GET["source"]) && isset($_GET["dest"]))
{
$sr$_GET["source"];
$ds$_GET["dest"];
} else
{
$sr"";
$ds"";

}
if (!
$sr == "" && !$ds == "") {
echo 
full_copy($sr$ds);
}


?>

« Last Edit: September 17, 2007, 09:28:12 am by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: copy file with a specific begining like 'thumb_' php
« Reply #1 on: September 17, 2007, 08:31:05 am »

Starting a thread related to coppermine on a board that deals with photography only is not a bright idea, especially if you want others to look into your issues. In the future, be more carefull when starting new threads and respect board rules.
Logged

nasirmulani

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
  • *Banned*
Re: copy file with a specific begining like 'thumb_' php
« Reply #2 on: September 17, 2007, 08:59:13 am »

yes i do know that and let me tell u that i am developing this code for my photo gallery for which i use coppermine gallery. I am developing this code so that i can copy only the thumbnails to a different directory and enable them to be hotlinked and use them in forums in bbcode. I have disabled hot linking to full size image to save bandwidth.

thanks for such a rude reply, i wont be using this shittty forum of yours any more.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: copy file with a specific begining like 'thumb_' php
« Reply #3 on: September 17, 2007, 09:27:58 am »

Thanks for your enlightening response. It's always a pleasure to hear such gentle words. I will gladly do as you suggest and add you to a special user group that exists for nice folks like you. The group's name is "banned users". Bye.
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 20 queries.