[ PHPXref.com ] [ Generated: Sun Jul 20 17:05:41 2008 ] [ Coppermine 1.4.5 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> searchnew.php (source)

   1  <?php
   2  /*************************

   3    Coppermine Photo Gallery

   4    ************************

   5    Copyright (c) 2003-2006 Coppermine Dev Team

   6    v1.1 originally written by Gregory DEMAR

   7  

   8    This program is free software; you can redistribute it and/or modify

   9    it under the terms of the GNU General Public License as published by

  10    the Free Software Foundation; either version 2 of the License, or

  11    (at your option) any later version.

  12    ********************************************

  13    Coppermine version: 1.4.5

  14    $Source: /cvsroot/coppermine/stable/searchnew.php,v $

  15    $Revision: 1.19 $

  16    $Author: gaugau $

  17    $Date: 2006/03/02 08:17:40 $

  18  **********************************************/
  19  
  20  define('IN_COPPERMINE', true);
  21  define('SEARCHNEW_PHP', true);
  22  
  23  require ('include/init.inc.php');
  24  
  25  if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
  26  
  27  /**

  28   * Local functions definition

  29   */
  30  
  31  /**

  32   * albumselect()

  33   *

  34   * return the HTML code for a listbox with name $id that contains the list

  35   * of all albums

  36   *

  37   * @param string $id the name of the listbox

  38   * @return the HTML code

  39   */
  40  
  41  
  42   function albumselect($id = "album") {
  43  // frogfoot re-wrote this function to present the list in categorized, sorted and nicely formatted order

  44  
  45      global $CONFIG, $lang_search_new_php, $cpg_udb;
  46      static $select = "";
  47  
  48      // Reset counter

  49      $list_count = 0;
  50  
  51      if ($select == "") {
  52          $result = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = 0");
  53          while ($row = mysql_fetch_array($result)) {
  54              // Add to multi-dim array for later sorting

  55              $listArray[$list_count]['cat'] = $lang_search_new_php['albums_no_category'];
  56              $listArray[$list_count]['aid'] = $row['aid'];
  57              $listArray[$list_count]['title'] = $row['title'];
  58              $list_count++;
  59          }
  60          mysql_free_result($result);
  61  
  62          $result = cpg_db_query("SELECT DISTINCT a.aid as aid, a.title as title, c.name as cname FROM {$CONFIG['TABLE_ALBUMS']} as a, {$CONFIG['TABLE_CATEGORIES']} as c WHERE a.category = c.cid AND a.category < '" . FIRST_USER_CAT . "'");
  63          while ($row = mysql_fetch_array($result)) {
  64              // Add to multi-dim array for later sorting

  65              $listArray[$list_count]['cat'] = $row['cname'];
  66              $listArray[$list_count]['aid'] = $row['aid'];
  67              $listArray[$list_count]['title'] = $row['title'];
  68              $list_count++;
  69          }
  70          mysql_free_result($result);
  71  
  72          //if (defined('UDB_INTEGRATION')) {

  73              $sql = $cpg_udb->get_batch_add_album_list();
  74          /*} else {

  75              $sql = "SELECT aid, CONCAT('(', user_name, ') ', title) AS title " . "FROM {$CONFIG['TABLE_ALBUMS']} AS a " . "INNER JOIN {$CONFIG['TABLE_USERS']} AS u ON category = (" . FIRST_USER_CAT . " + user_id)";

  76          }*/
  77          $result = cpg_db_query($sql);
  78          while ($row = mysql_fetch_array($result)) {
  79              // Add to multi-dim array for later sorting

  80              $listArray[$list_count]['cat'] = $lang_search_new_php['personal_albums'];
  81              $listArray[$list_count]['aid'] = $row['aid'];
  82              $listArray[$list_count]['title'] = $row['title'];
  83              $list_count++;
  84          }
  85          mysql_free_result($result);
  86  
  87          $select = '<option value="0">' . $lang_search_new_php['select_album'] . "</option>\n";
  88  
  89          // Sort the pulldown options by category and album name

  90          $listArray = array_csort($listArray,'cat','title');
  91  
  92          // Create the nicely sorted and formatted drop down list

  93          $alb_cat = '';
  94          foreach ($listArray as $val) {
  95              if ($val['cat'] != $alb_cat) {
  96            if ($alb_cat) $select .= "</optgroup>\n";
  97                  $select .= '<optgroup label="' . $val['cat'] . '">' . "\n";
  98                  $alb_cat = $val['cat'];
  99              }
 100              $select .= '<option value="' . $val['aid'] . '"' . ($val['aid'] == $sel_album ? ' selected' : '') . '>   ' . $val['title'] . "</option>\n";
 101          }
 102          if ($alb_cat) $select .= "</optgroup>\n";
 103      }
 104  
 105      return "\n<select name=\"$id\" class=\"listbox\">\n$select</select>\n";
 106  }
 107  
 108  /**

 109   * dirheader()

 110   *

 111   * return the HTML code for the row to be displayed when we start a new

 112   * directory

 113   *

 114   * @param  $dir the directory

 115   * @param  $dirid the name of the listbox that will list the albums

 116   * @return the HTML code

 117   */
 118  function dirheader($dir, $dirid)
 119  {
 120      global $CONFIG, $lang_search_new_php,$lang_check_uncheck_all;
 121      $warning = '';
 122  
 123      if (!is_writable($CONFIG['fullpath'] . $dir))
 124          $warning = "<tr><td class=\"tableh2\" valign=\"middle\" colspan=\"3\">\n" . "<b>{$lang_search_new_php['warning']}</b>: {$lang_search_new_php['change_perm']}</td></tr>\n";
 125      return "<tr><td class=\"tableh2\"><input type=\"checkbox\" name=\"checkAll2\" onClick=\"selectAll(this,'pics');\" class=\"checkbox\" title=\"".$lang_check_uncheck_all."\" /></td><td class=\"tableh2\" valign=\"middle\" align=\"right\" colspan=\"2\">\n" .
 126      sprintf($lang_search_new_php['target_album'], $dir, albumselect($dirid)) . "</td></tr>\n" . $warning;
 127  }
 128  
 129  /**

 130   * picrow()

 131   *

 132   * return the HTML code for a row to be displayed for an image

 133   * the row contains a checkbox, the image name, a thumbnail

 134   *

 135   * @param  $picfile the full path of the file that contains the picture

 136   * @param  $picid the name of the check box

 137   * @return the HTML code

 138   */
 139  function picrow($picfile, $picid, $albid)
 140  {
 141      global $CONFIG, $expic_array;
 142  
 143      $encoded_picfile = base64_encode($picfile);
 144      $picname = $CONFIG['fullpath'] . $picfile;
 145      $pic_url = urlencode($picfile);
 146      $pic_fname = basename($picfile);
 147      $pic_dirname = dirname($picname);
 148  
 149      $thumb_file = dirname($picname) . '/' . $CONFIG['thumb_pfx'] . $pic_fname;
 150      if (file_exists($thumb_file)) {
 151          $thumb_info = getimagesize($picname);
 152          $thumb_size = compute_img_size($thumb_info[0], $thumb_info[1], 48);
 153          $img = '<img src="' . path2url($thumb_file) . '" ' . $thumb_size['geom'] . ' class="thumbnail" border="0" alt="" />';
 154      } elseif (is_image($picname)) {
 155          $img = '<img src="showthumb.php?picfile=' . $pic_url . '&amp;size=48" class="thumbnail" border="0" alt="" />';
 156      } else {
 157          $file['filepath'] = $pic_dirname.'/'; //substr($picname,0,strrpos($picname,'/'))

 158          $file['filename'] = $pic_fname;
 159          $filepathname = get_pic_url($file,'thumb');
 160          //$mime_content = cpg_get_type($picname);

 161          //$extension = file_exists("images/thumb_{$mime_content['extension']}.jpg") ? $mime_content['extension']:$mime_content['content'];

 162          //$img = '<img src="images/thumb_'.$extension.'.jpg" class="thumbnail" width="48" border="0" alt="" />';

 163          $img = '<img src="'.$filepathname.'" class="thumbnail" width="48" border="0" alt="" />';
 164      }
 165  
 166      if (filesize($picname) && is_readable($picname)) {
 167          //$fullimagesize = getimagesize($picname); COMMENTED OUT FOR VIDEO SUPPORT

 168          $winsizeX = ($fullimagesize[0] + 16);
 169          $winsizeY = ($fullimagesize[1] + 16);
 170  
 171          //$checked = isset($expic_array[$picfile]) || !$fullimagesize ? '' : 'checked';

 172  
 173          $checked = isset($expic_array[$picfile]) ? '' : 'checked';
 174  
 175          return <<<EOT
 176          <tr>
 177                  <td class="tableb" valign="middle">
 178                          <input name="pics[]" id="picselector" type="checkbox" value="$picid" $checked />
 179                          <input name="album_lb_id_$picid" type="hidden" value="$albid" />
 180                          <input name="picfile_$picid" type="hidden" value="$encoded_picfile" />
 181                  </td>
 182                  <td class="tableb" valign="middle" width="100%">
 183                          <a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&amp;picfile=$pic_url', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width=$winsizeX, height=$winsizeY')">$pic_fname</a>
 184                  </td>
 185                  <td class="tableb" valign="middle" align="center">
 186                          <a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&amp;picfile=$pic_url', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width=$winsizeX, height=$winsizeY')"><img src="images/spacer.gif" width="1" height="48" border="0" alt="" />$img<br /></a>
 187                  </td>
 188          </tr>
 189  EOT;
 190      } else {
 191          $winsizeX = (300);
 192          $winsizeY = (300);
 193          return <<<EOT
 194          <tr>
 195                  <td class="tableb" valign="middle">
 196                          &nbsp;
 197                  </td>
 198                  <td class="tableb" valign="middle" width="100%">
 199                          <i>$pic_fname</i>
 200                  </td>
 201                  <td class="tableb" valign="middle" align="center">
 202                          <a href="javascript:;" onclick= "MM_openBrWindow('displayimage.php?fullsize=1&amp;picfile=$pic_url', 'ImageViewer', 'toolbar=yes, status=yes, resizable=yes, width=$winsizeX, height=$winsizeY')"><img src="showthumb.php?picfile=$pic_url&amp;size=48" class="thumbnail" border="0" alt="" /><br /></a>
 203                  </td>
 204          </tr>
 205  EOT;
 206      }
 207  }
 208  
 209  /**

 210   * getfoldercontent()

 211   *

 212   * return the files and directories of a folder in two arrays

 213   *

 214   * @param  $folder the folder to read

 215   * @param  $dir_array the array that will contain name of sub-dir

 216   * @param  $pic_array the array that will contain name of picture

 217   * @param  $expic_array an array that contains pictures already in db

 218   * @return

 219   */
 220  function getfoldercontent($folder, &$dir_array, &$pic_array, &$expic_array)
 221  {
 222      global $CONFIG;
 223      $dir = opendir($CONFIG['fullpath'] . $folder);
 224      while ($file = readdir($dir)) {
 225          if (is_dir($CONFIG['fullpath'] . $folder . $file)) {
 226              if ($file != "." && $file != ".." && $CONFIG['fullpath'] . $folder . $file != $CONFIG['fullpath'].'/edit' && $CONFIG['fullpath'] . $folder . $file != $CONFIG['fullpath'].'/'.substr($CONFIG['userpics'],0,strlen($CONFIG['userpics'])-1)) {
 227                  $dir_array[] = $file;
 228              }
 229          }
 230          if (is_file($CONFIG['fullpath'] . $folder . $file)) {
 231              if (strncmp($file, $CONFIG['thumb_pfx'], strlen($CONFIG['thumb_pfx'])) != 0 && strncmp($file, $CONFIG['normal_pfx'], strlen($CONFIG['normal_pfx'])) != 0 && $file != 'index.html') {
 232                  $newfile = replace_forbidden($file);
 233                  if ($newfile != $file) {
 234                    //File name has been changed, let's get a unique filename and rename the existing file.

 235                    $matches = array();
 236                    if (!preg_match("/(.+)\.(.*?)\Z/", $newfile, $matches)) {
 237                        $matches[1] = 'invalid_fname';
 238                        $matches[2] = 'xxx';
 239                    }
 240  
 241                    if ($matches[2] == '' || !is_known_filetype($matches)) {
 242                        cpg_die(ERROR, sprintf($lang_db_input_php['err_invalid_fext'], $CONFIG['allowed_file_extensions']), __FILE__, __LINE__);
 243                    }
 244  
 245                    // Create a unique name for the uploaded file

 246                    $nr = 0;
 247                    $picture_name = $matches[1] . '.' . $matches[2];
 248                    while (file_exists($CONFIG['fullpath'] . $folder . $picture_name)) {
 249                      $picture_name = $matches[1] . '~' . $nr++ . '.' . $matches[2];
 250                    }
 251                    @rename($CONFIG['fullpath'] . $folder . $file, $CONFIG['fullpath'] . $folder . $picture_name);
 252                    $file = $picture_name;
 253                  }
 254                  $pic_array[] = $file;
 255              }
 256          }
 257      }
 258      closedir($dir);
 259  
 260      natcasesort($dir_array);
 261      natcasesort($pic_array);
 262  }
 263  
 264  function display_dir_tree($folder, $ident)
 265  {
 266      global $CONFIG, $lang_search_new_php; //$PHP_SELF,

 267      $dir_path = $CONFIG['fullpath'] . $folder;
 268  
 269      if (!is_readable($dir_path)) return;
 270  
 271      $dir = opendir($dir_path);
 272      static $dirCounter = 0;
 273      while ($file = readdir($dir)) { // loop looking for files - start
 274          if (is_dir($CONFIG['fullpath'] . $folder . $file) &&
 275              substr($file,0,1) != "." &&
 276              strpos($file,"'") == FALSE &&
 277              strpos($file,trim($CONFIG['userpics'],'/')) === FALSE &&
 278              strpos($file,'edit') === FALSE &&
 279              strpos($file,'CVS') === FALSE) {
 280                  $start_target = $folder . $file;
 281                  $dir_path = $CONFIG['fullpath'] . $folder . $file;
 282  
 283                  $warnings = '';
 284                  if (!is_writable($dir_path)) $warnings .= $lang_search_new_php['dir_ro'];
 285                  if (!is_readable($dir_path)) $warnings .= $lang_search_new_php['dir_cant_read'];
 286  
 287                  if ($warnings) $warnings = '&nbsp;&nbsp;&nbsp;<b>' . $warnings . '<b>';
 288  
 289                  echo <<<EOT
 290                              <tr>
 291                                      <td class="tableb">
 292                                              $ident<img src="images/folder.gif" border="0" alt="" />&nbsp;<a href= "{$_SERVER['PHP_SELF']}?startdir=$start_target">$file</a>$warnings
 293                                      </td>
 294                              </tr>
 295  EOT;
 296                  $dirCounter++;
 297                  display_dir_tree($folder . $file . '/', $ident . '&nbsp;&nbsp;&nbsp;&nbsp;');
 298          }
 299      } // loop looking for files - end

 300      closedir($dir);
 301      if ($dirCounter == 0) {
 302      echo '
 303                          <tr>
 304                                  <td class="tableb">';
 305      echo '                                   ' . sprintf($lang_search_new_php['no_folders'],trim($CONFIG['fullpath'],'/'),trim($CONFIG['fullpath'],'/'),trim($CONFIG['userpics'],'/'));
 306      echo '
 307                                      </td>
 308                          </tr>';
 309      }
 310  
 311  }
 312  
 313  /**

 314   * getallpicindb()

 315   *

 316   * Fill an array where keys are the full path of all images in the picture table

 317   *

 318   * @param  $pic_array the array to be filled

 319   * @return

 320   */
 321  function getallpicindb(&$pic_array, $startdir)
 322  {
 323      global $CONFIG;
 324  
 325      $sql = "SELECT filepath, filename " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE filepath LIKE '$startdir%'";
 326      $result = cpg_db_query($sql);
 327      while ($row = mysql_fetch_array($result)) {
 328          $pic_file = $row['filepath'] . $row['filename'];
 329          $pic_array[$pic_file] = 1;
 330      }
 331      mysql_free_result($result);
 332  }
 333  
 334  /**

 335   * getallalbumsindb()

 336   *

 337   * Fill an array with all albums where keys are aid of albums and values are

 338   * album title

 339   *

 340   * @param  $album_array the array to be filled

 341   * @return

 342   */
 343  function getallalbumsindb(&$album_array)
 344  {
 345      global $CONFIG;
 346  
 347      $sql = "SELECT aid, title " . "FROM {$CONFIG['TABLE_ALBUMS']} " . "WHERE 1";
 348      $result = cpg_db_query($sql);
 349  
 350      while ($row = mysql_fetch_array($result)) {
 351          $album_array[$row['aid']] = $row['title'];
 352      }
 353      mysql_free_result($result);
 354  }
 355  
 356  /**

 357   * CPGscandir() //renamed because php5 has same function as scandir()

 358   *

 359   * recursive function that scan a directory, create the HTML code for each

 360   * picture and add new pictures in an array

 361   *

 362   * @param  $dir the directory to be scanned

 363   * @param  $expic_array the array that contains pictures already in DB

 364   * @param  $newpic_array the array that contains new pictures found

 365   * @return

 366   */
 367  function CPGscandir($dir, &$expic_array)
 368  {
 369          $dir = str_replace(".","" ,$dir);
 370      static $dir_id = 0;
 371      static $count = 0;
 372      static $pic_id = 0;
 373  
 374      $pic_array = array();
 375      $dir_array = array();
 376      getfoldercontent($dir, $dir_array, $pic_array, $expic_array);
 377  
 378      if (count($pic_array) > 0) {
 379          $dir_id_str = sprintf("d%04d", $dir_id++);
 380          echo dirheader($dir, $dir_id_str);
 381          foreach ($pic_array as $picture) {
 382              $count++;
 383              $pic_id_str = sprintf("i%04d", $pic_id++);
 384              echo picrow($dir . $picture, $pic_id_str, $dir_id_str);
 385          }
 386      }
 387      if (count($dir_array) > 0) {
 388          foreach ($dir_array as $directory) {
 389              if (substr($directory,0,1) != ".") // added do not show folders with dots: gaugau 03-11-02
 390              CPGscandir($dir . $directory . '/', $expic_array);
 391          }
 392      }
 393      return $count;
 394  }
 395  
 396  /**

 397   * Main code

 398   */
 399  
 400  $album_array = array();
 401  getallalbumsindb($album_array);
 402  // We need at least one album

 403  if (!count($album_array)) {
 404      cpg_die(ERROR, $lang_search_new_php['need_one_album'], __FILE__, __LINE__);
 405  }
 406  
 407  if (isset($_POST['insert'])) {
 408      if (!isset($_POST['pics'])) cpg_die(ERROR, $lang_search_new_php['no_pic_to_add'], __FILE__, __LINE__);
 409  
 410      pageheader($lang_search_new_php['page_title']);
 411      $help = '&nbsp;'.cpg_display_help('f=index.htm&amp;as=ftp&amp;ae=ftp_end&amp;top=1#ftp_show_result', '600', '400');
 412      starttable("100%");
 413      echo <<<EOT
 414          <tr>
 415                  <td colspan="4" class="tableh1"><h2>{$lang_search_new_php['insert']}$help</h2></td>
 416          </tr>
 417          <tr>
 418                  <td class="tableh2" valign="middle" align="center"><b>{$lang_search_new_php['folder']}</b></td>
 419                  <td class="tableh2" valign="middle" align="center"><b>{$lang_search_new_php['image']}</b></td>
 420                  <td class="tableh2" valign="middle" align="center"><b>{$lang_search_new_php['album']}</b></td>
 421                  <td class="tableh2" valign="middle" align="center"><b>{$lang_search_new_php['result']}</b></td>
 422          </tr>
 423  EOT;
 424  
 425      $count = 0;
 426      foreach ($_POST['pics'] as $pic_id) {
 427          $album_lb_id = $_POST['album_lb_id_' . $pic_id];
 428          $album_id = $_POST[$album_lb_id];
 429  
 430          $edit_album_array[] = $album_id; //Load the album number into an array for later

 431  
 432          $pic_file = base64_decode($_POST['picfile_' . $pic_id]);
 433          $dir_name = dirname($pic_file) . "/";
 434          $file_name = basename($pic_file);
 435  
 436          if ($album_id) {
 437              // To avoid problems with PHP scripts max execution time limit, each picture is

 438              // added individually using a separate script that returns an image

 439              $status = "<a href=\"addpic.php?aid=$album_id&pic_file=" . ($_POST['picfile_' . $pic_id]) . "&amp;reload=" . uniqid('') . "\"><img src=\"addpic.php?aid=$album_id&amp;pic_file=" . ($_POST['picfile_' . $pic_id]) . "&amp;reload=" . uniqid('') . "\" class=\"thumbnail\" border=\"0\" width=\"24\" height=\"24\" alt=\"{$lang_search_new_php['result_icon']}\" /><br /></a>";
 440              $album_name = $album_array[$album_id];
 441              //$edit_pics_content .= '<a href="editpics.php?album='.$album_id. '">' . $lang_search_new_php['edit_pics'] . ' : ' . $album_name . '</a><br />';

 442          } else {
 443              $album_name = $lang_search_new_php['no_album'];
 444              $status = "<img src=\"images/up_na.gif\" alt=\"" . $lang_search_new_php['no_album'] . "\" class=\"thumbnail\" border=\"0\" width=\"24\" height=\"24\" /><br />";
 445          }
 446          echo "<tr>\n";
 447          echo "<td class=\"tableb\" valign=\"middle\" align=\"left\">$dir_name</td>\n";
 448          echo "<td class=\"tableb\" valign=\"middle\" align=\"left\">$file_name</td>\n";
 449          echo "<td class=\"tableb\" valign=\"middle\" align=\"left\">$album_name</td>\n";
 450          echo "<td class=\"tableb\" valign=\"middle\" align=\"center\">$status</td>\n";
 451          echo "</tr>\n";
 452          $count++;
 453          flush();
 454      }
 455  
 456      // Eliminate the duplicate albums from the edit_album_array

 457      $edit_album_array = array_unique($edit_album_array);
 458      // Display the albums that have new pictures added

 459      foreach ($edit_album_array as $edit_album)
 460      {
 461        $edit_pics_content .= $lang_search_new_php['album'] . ' &laquo;' . $album_array[$edit_album] .'&raquo;: ';
 462        $edit_pics_content .= '<a href="editpics.php?album='.$edit_album. '" class="admin_menu">' . $lang_search_new_php['edit_pics'] . '</a> ';
 463        $edit_pics_content .= '<a href="modifyalb.php?album='.$edit_album. '" class="admin_menu">' . $lang_search_new_php['edit_properties'] . '</a> ';
 464        $edit_pics_content .= '<a href="thumbnails.php?album='.$edit_album. '" class="admin_menu">' . $lang_search_new_php['view_thumbs'] . '</a> ';
 465        $edit_pics_content .= '<br />';
 466      }
 467  
 468      echo <<<EOT
 469          <tr>
 470                  <td class="tableh2" colspan="4">
 471                          <b>{$lang_search_new_php['be_patient']}</b>
 472                  </td>
 473          </tr>
 474          <tr>
 475                  <td class="tableb" colspan="4">
 476                          {$lang_search_new_php['notes']}
 477                  </td>
 478          </tr>
 479          <tr>
 480                  <td class="tableb" colspan="4">
 481                  <p align="center">{$edit_pics_content}</p>
 482                  </td>
 483          </tr>
 484  
 485  EOT;
 486      endtable();
 487      pagefooter();
 488      ob_end_flush();
 489  } elseif (isset($_GET['startdir'])) {
 490      pageheader($lang_search_new_php['page_title']);
 491      $help = '&nbsp;'.cpg_display_help('f=index.htm&amp;as=ftp&amp;ae=ftp_end&amp;top=1#ftp_select_file', '550', '400');
 492      echo <<<EOT
 493          <script language="javascript" type="text/javascript">
 494          <!--
 495          function selectAll(d,box) {
 496            var f = document.selectPics;
 497            for (i = 0; i < f.length; i++) {
 498              //alert (f[i].name.indexOf(box));

 499              if (f[i].type == "checkbox" && f[i].name.indexOf(box) >= 0) {
 500                if (d.checked) {
 501                  f[i].checked = true;
 502                } else {
 503                  f[i].checked = false;
 504                }
 505              }
 506            }
 507            if (d.name == "checkAll") {
 508                document.getElementsByName('checkAll2')[0].checked = document.getElementsByName('checkAll')[0].checked;
 509            } else {
 510                document.getElementsByName('checkAll')[0].checked = document.getElementsByName('checkAll2')[0].checked;
 511            }
 512          }
 513          -->
 514          </script>
 515          <form method="post" action="{$_SERVER['PHP_SELF']}?insert=1" name="selectPics" style="margin:0px;padding:0px">
 516  EOT;
 517      starttable("100%");
 518      echo <<<EOT
 519          <tr>
 520                  <td colspan="3" class="tableh1"><h2>{$lang_search_new_php['list_new_pic']}$help</h2></td>
 521          </tr>
 522  
 523  EOT;
 524      $expic_array = array();
 525      getallpicindb($expic_array, $_GET['startdir']);
 526      if (CPGscandir($_GET['startdir'] . '/', $expic_array)) {
 527          echo <<<EOT
 528          <tr>
 529                  <td class="tablef">
 530                      <input type="checkbox" name="checkAll" onClick="selectAll(this,'pics');" class="checkbox" title="$lang_check_uncheck_all" />
 531                  </td>
 532                  <td colspan="2" align="center" class="tablef">
 533                          <input type="submit" class="button" name="insert" value="{$lang_search_new_php['insert_selected']}" />
 534                  </td>
 535          </tr>
 536  
 537  EOT;
 538      } else {
 539          echo <<<EOT
 540          <tr>
 541                  <td colspan="3" align="center" class="tableb">
 542                          <br /><br />
 543                          <b>{$lang_search_new_php['no_pic_found']}</b>
 544                          <br /><br /><br />
 545                  </td>
 546          </tr>
 547  
 548  EOT;
 549      }
 550      endtable();
 551      print '        </form>';
 552      pagefooter();
 553      ob_end_flush();
 554  } else {
 555      pageheader($lang_search_new_php['page_title']);
 556      $help = '&nbsp;'.cpg_display_help('f=index.htm&amp;as=ftp&amp;ae=ftp_end&amp;top=1', '600', '450');
 557      print '<form name="interfaceconfig" action="'.$_SERVER['PHP_SELF'].'" method="post" style="margin:0px;padding:0px">';
 558      starttable(-1, $lang_search_new_php['select_dir'].$help);
 559  
 560      // write the interface change to the db

 561      if (isset($_POST['update_config'])) {
 562          $value = $_POST['browse_batch_add'];
 563          cpg_db_query("UPDATE {$CONFIG['TABLE_CONFIG']} SET value = '$value' WHERE name = 'browse_batch_add'");
 564          $CONFIG['browse_batch_add'] = $value;
 565          if ($CONFIG['log_mode'] == CPG_LOG_ALL) {
 566              log_write('CONFIG UPDATE SQL: '.
 567                "UPDATE {$CONFIG['TABLE_CONFIG']} SET value = '$value' WHERE name = 'browse_batch_add'\n".
 568                'TIME: '.date("F j, Y, g:i a")."\n".
 569                'USER: '.$USER_DATA['user_name'],
 570                CPG_DATABASE_LOG
 571                );
 572          }
 573      }
 574  
 575  
 576      $iframe_startfolder .= str_replace('searchnew.php', '', __FILE__).rtrim($CONFIG['fullpath'], '/').'/';
 577      $iframe_hide = rawurlencode('.,..,CVS,edit,'.rtrim($CONFIG['userpics'], '/'));
 578      print '    <tr>'."\n";
 579      print '        <td class="tableb" align="center">'."\n";
 580      if ($CONFIG['browse_batch_add'] == 1) {
 581          print '            <iframe src="minibrowser.php?startfolder='.$iframe_startfolder.'&amp;parentform=choosefolder&amp;formelementname=startdir&amp;no_popup=1&amp;limitfolder='.$iframe_startfolder.'&amp;hidefolders='.$iframe_hide.'&amp;linktarget='.$_SERVER['PHP_SELF'].'&amp;searchnew_php=1&amp;radio=0" width="95%" height="400" name="popup_in_a_box">'."\n";
 582      }
 583      display_dir_tree('', '');
 584      if ($CONFIG['browse_batch_add'] == 1) {
 585          print '            </iframe>'."\n";
 586      }
 587      print '        </td>'."\n";
 588      print '    </tr>'."\n";
 589  
 590      // configure batch-add interface (classic or browsable)

 591      $yes_selected = $CONFIG['browse_batch_add'] ? 'checked="checked"' : '';
 592      $no_selected = !$CONFIG['browse_batch_add'] ? 'checked="checked"' : '';
 593      $help = cpg_display_help('f=index.htm&amp;as=admin_general_browsable_batch_add&amp;ae=admin_general_browsable_batch_add_end', '500', '300');
 594      echo <<<EOT
 595          <tr>
 596                  <td class="tableb">
 597                          <b>{$lang_search_new_php['select_dir_msg']}</b>
 598                  </td>
 599          </tr>
 600          <tr>
 601              <td class="tablef" colspan="6">
 602                          {$lang_search_new_php['browse_batch_add']}
 603                          $help
 604                          &nbsp;&nbsp;
 605                          <input type="radio" id="browse_batch_add1" name="browse_batch_add" value="1"  onclick="document.interfaceconfig.submit();" $yes_selected /><label for="browse_batch_add1" class="clickable_option">$lang_yes</label>
 606                          &nbsp;&nbsp;
 607                          <input type="radio" id="browse_batch_add0" name="browse_batch_add" value="0"  onclick="document.interfaceconfig.submit();" $no_selected /><label for="browse_batch_add0" class="clickable_option">$lang_no</label>
 608                          &nbsp;&nbsp;
 609                          <input type="hidden" name="update_config" value="1" />
 610                  </td>
 611          </tr>
 612  EOT;
 613  
 614      endtable();
 615      print '        </form>';
 616      pagefooter();
 617      ob_end_flush();
 618  }
 619  
 620  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]