' . $lang_search_new_php['select_album'] . '\n';
foreach ($rowset as $row) {
$select .= "\n";
}
}
return "\n\n";
}
/**
* dirheader()
*
* return the HTML code for the row to be displayed when we start a new
* directory
*
* @param $dir the directory
* @param $dirid the name of the listbox that will list the albums
* @return the HTML code
*/
function dirheader($dir, $dirid)
{
global $CONFIG, $lang_search_new_php;
$warning = '';
if (!is_writable($CONFIG['fullpath'] . $dir))
$warning = "
EOT;
display_dir_tree($folder . $file . '/', $ident . ' ');
}
}
closedir($dir);
}
/**
* getallpicindb()
*
* Fill an array where keys are the full path of all images in the picture table
*
* @param $pic_array the array to be filled
* @return
*/
function getallpicindb(&$pic_array, $startdir)
{
global $CONFIG;
$sql = "SELECT filepath, filename " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE filepath LIKE '$startdir%'";
$result = db_query($sql);
while ($row = mysql_fetch_array($result)) {
$pic_file = $row['filepath'] . $row['filename'];
$pic_array[$pic_file] = 1;
}
mysql_free_result($result);
}
/**
* getallalbumsindb()
*
* Fill an array with all albums where keys are aid of albums and values are
* album title
*
* @param $album_array the array to be filled
* @return
*/
function getallalbumsindb(&$album_array)
{
global $CONFIG;
$sql = "SELECT aid, title " . "FROM {$CONFIG['TABLE_ALBUMS']} " . "WHERE 1";
$result = db_query($sql);
while ($row = mysql_fetch_array($result)) {
$album_array[$row['aid']] = $row['title'];
}
mysql_free_result($result);
}
/**
* CPGscandir() //renamed because php5 has same function as scandir()
*
* recursive function that scan a directory, create the HTML code for each
* picture and add new pictures in an array
*
* @param $dir the directory to be scanned
* @param $expic_array the array that contains pictures already in DB
* @param $newpic_array the array that contains new pictures found
* @return
*/
function CPGscandir($dir, &$expic_array)
{
$dir = str_replace(".","" ,$dir);
static $dir_id = 0;
static $count = 0;
static $pic_id = 0;
$pic_array = array();
$dir_array = array();
getfoldercontent($dir, $dir_array, $pic_array, $expic_array);
if (count($pic_array) > 0) {
$dir_id_str = sprintf("d%04d", $dir_id++);
echo dirheader($dir, $dir_id_str);
foreach ($pic_array as $picture) {
$count++;
$pic_id_str = sprintf("i%04d", $pic_id++);
echo picrow($dir . $picture, $pic_id_str, $dir_id_str);
}
}
if (count($dir_array) > 0) {
foreach ($dir_array as $directory) {
if (substr($directory,0,1) != ".") // added do not show folders with dots: gaugau 03-11-02
CPGscandir($dir . $directory . '/', $expic_array);
}
}
return $count;
}
/**
* Main code
*/
$album_array = array();
getallalbumsindb($album_array);
// We need at least one album
if (!count($album_array)) cpg_die(ERROR, $lang_search_new_php['need_one_album'], __FILE__, __LINE__);
if (isset($HTTP_POST_VARS['insert'])) {
if (!isset($HTTP_POST_VARS['pics'])) cpg_die(ERROR, $lang_search_new_php['no_pic_to_add'], __FILE__, __LINE__);
pageheader($lang_search_new_php['page_title']);
starttable("100%");
echo <<
{$lang_search_new_php['insert']}
{$lang_search_new_php['folder']}
{$lang_search_new_php['image']}
{$lang_search_new_php['album']}
{$lang_search_new_php['result']}
EOT;
$count = 0;
foreach ($HTTP_POST_VARS['pics'] as $pic_id) {
$album_lb_id = $HTTP_POST_VARS['album_lb_id_' . $pic_id];
$album_id = $HTTP_POST_VARS[$album_lb_id];
$pic_file = base64_decode($HTTP_POST_VARS['picfile_' . $pic_id]);
$dir_name = dirname($pic_file) . "/";
$file_name = basename($pic_file);
if ($album_id) {
// To avoid problems with PHP scripts max execution time limit, each picture is
// added individually using a separate script that returns an image
$status = " ";
$album_name = $album_array[$album_id];
} else {
$album_name = $lang_search_new_php['no_album'];
$status = " ";
}
echo "