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

title

Body

[close]

/ -> keywordmgr.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/keywordmgr.php,v $

  15    $Revision: 1.5 $

  16    $Author: gaugau $

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

  18  **********************************************/
  19  
  20  define('IN_COPPERMINE', true);
  21  define('KEYWORDMGR_PHP', true);
  22  define('SEARCH_PHP', true);
  23  require ('include/init.inc.php');
  24  //Die if not admin_mode

  25  if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__);
  26  
  27  pageheader($lang_keywordmgr_php['title']);
  28  
  29  starttable("100%", $lang_keywordmgr_php['title'], 3);
  30  echo <<<EOT
  31        <tr>
  32            <td class="tablef"><b>{$lang_keywordmgr_php['edit']}</b></td>
  33            <td class="tablef"><b>{$lang_keywordmgr_php['delete']}</b></td>
  34            <td class="tablef"><b>{$lang_keywordmgr_php['search']}</b></td>
  35        </tr>
  36  
  37  EOT;
  38  
  39  switch($_REQUEST['page']) {
  40  
  41  default :
  42  case 'display':
  43  
  44  $result = cpg_db_query("select keywords from {$CONFIG['TABLE_PICTURES']}");
  45  if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['non_exist_ap']);
  46    // Find unique keywords

  47     $total_array = array();
  48  
  49     while (list($keywords) = mysql_fetch_row($result)) {
  50         $array = explode(' ',$keywords);
  51  
  52         foreach($array as $word)
  53         {
  54           if ($word == '.' || $word == '' || $word == ' ' ) continue;
  55           $orig_word = $word;
  56           $single_word = addslashes($word);
  57           $lowercase_word = utf_strtolower($single_word);
  58           $lowercase_word = addslashes($lowercase_word);
  59           $word = <<<EOT
  60           <td class="tableb">
  61           <input type="radio" class="radio" name="keywordEdit" value="$lowercase_word" onClick="document.keywordForm.newword.value='$single_word'" id="$lowercase_word" />
  62           <label for="$lowercase_word" class="clickable_option">
  63           <img src="images/edit.gif" width="16" height="16" border="0" alt="" title="{$lang_keywordmgr_php['edit']} &quot;$orig_word&quot;" /> &quot;<i>$orig_word</i>&quot;
  64           </label>
  65           </td>
  66  EOT;
  67           $word .= '<td class="tableb"><a href="keywordmgr.php?page=delete&amp;remov='.$single_word.'" onclick="return confirm(\''.sprintf($lang_keywordmgr_php['confirm_delete'], '&quot;'.$single_word.'&quot;').'\')">';
  68           $word .= '<img src="images/delete.gif" width="16" height="16" border="0" alt="" title="'.sprintf($lang_keywordmgr_php['keyword_del'],'&quot;'.$orig_word.'&quot;').'" /> '.$orig_word;
  69           $word .= <<<EOT
  70           </a></td>
  71           <td class="tableb"><a href="thumbnails.php?album=search&amp;search=$orig_word" target="_blank">
  72  EOT;
  73  
  74           $word .= sprintf($lang_keywordmgr_php['keyword_test_search'], '&quot;<i>'.$orig_word.'</i>&quot;');
  75           $word .= '</a></td>';
  76  
  77             if (!in_array($word,$total_array)) $total_array[] = $word;
  78         }
  79     }
  80  
  81     sort($total_array);
  82  
  83     $output = implode("</tr>\n<tr>", $total_array);
  84  
  85     echo <<<EOT
  86  <form name="keywordForm" action="keywordmgr.php?page=changeword" method="post">
  87  $output
  88  <tr><td colspan="5" class="tablef" align="center">
  89     <input type="text" name="newword" />
  90     <input type="submit" value="{$lang_keywordmgr_php['change_keyword']}" />
  91  </td></tr>
  92  </form>
  93  EOT;
  94  
  95  
  96  
  97  break;
  98  
  99  
 100  case 'changeword':
 101  
 102     if ($_REQUEST['keywordEdit'] && $_REQUEST['newword'])
 103     {
 104         $keywordEdit = addslashes($_REQUEST['keywordEdit']);
 105  
 106         $query = "SELECT `pid`,`keywords` FROM {$CONFIG['TABLE_PICTURES']} WHERE CONCAT(' ',`keywords`,' ') LIKE '% {$keywordEdit} %'";
 107         $result = cpg_db_query($query) or die(mysql_error());
 108  
 109         while (list($id,$keywords) = mysql_fetch_row($result))
 110         {
 111             $array_new = array();
 112             $array_old = explode(" ", addslashes(trim($keywords)));
 113  
 114             foreach($array_old as $word)
 115             {
 116                 // convert old to new if its the same word

 117                 if (utf_strtolower($word) == $keywordEdit) $word = addslashes($_REQUEST['newword']);
 118  
 119                 // rebuild array to reprocess it

 120                 $array_new[] = $word;
 121             }
 122  
 123             $keywords = implode(" ", $array_new);
 124             $newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET `keywords` = '$keywords' WHERE `pid` = '$id'";
 125         }
 126     }
 127     $newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET `keywords` = TRIM(REPLACE(`keywords`,'  ',' '))";
 128  
 129     foreach ($newquerys as $query) { $result = cpg_db_query($query) or die($query."<br />".mysql_error()); }
 130  
 131     header("Location: keywordmgr.php?page=display");
 132  
 133  break;
 134  
 135  case 'delete':
 136  
 137         $keywordEdit = addslashes($_REQUEST['remov']);
 138  
 139         $query = "SELECT `pid`,`keywords` FROM {$CONFIG['TABLE_PICTURES']} WHERE CONCAT(' ',`keywords`,' ') LIKE '% {$keywordEdit} %'";
 140         $result = cpg_db_query($query) or die(mysql_error());
 141  
 142         while (list($id,$keywords) = mysql_fetch_row($result))
 143         {
 144             $array_new = array();
 145             $array_old = explode(" ", addslashes(trim($keywords)));
 146  
 147             foreach($array_old as $word)
 148             {
 149                 // convert old to new if its the same word

 150                 if (utf_strtolower($word) == $keywordEdit) $word = '';
 151  
 152                 // rebuild array to reprocess it

 153                 $array_new[] = $word;
 154             }
 155  
 156             $keywords = implode(" ", $array_new);
 157             $newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET `keywords` = '$keywords' WHERE `pid` = '$id'";
 158         }
 159  
 160     $newquerys[] = "UPDATE {$CONFIG['TABLE_PICTURES']} SET `keywords` = TRIM(REPLACE(`keywords`,'  ',' '))";
 161  
 162     foreach ($newquerys as $query) { $result = cpg_db_query($query) or die($query."<br />".mysql_error()); }
 163  
 164     header("Location: ?page=display");
 165  
 166  break;
 167  
 168  }
 169  endtable();
 170  if ($CONFIG['clickable_keyword_search'] != 0) {
 171      include ('include/keyword.inc.php');
 172  }
 173  pagefooter();
 174  ob_end_flush();
 175  ?>


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