aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--index.php27
1 files changed, 17 insertions, 10 deletions
diff --git a/index.php b/index.php
index 2ff2505a..39230c80 100644
--- a/index.php
+++ b/index.php
@@ -1176,6 +1176,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history)
1176 die('Wrong token.'); 1176 die('Wrong token.');
1177 } 1177 }
1178 1178
1179 $count = 0;
1179 // Delete a tag: 1180 // Delete a tag:
1180 if (isset($_POST['deletetag']) && !empty($_POST['fromtag'])) { 1181 if (isset($_POST['deletetag']) && !empty($_POST['fromtag'])) {
1181 $needle = trim($_POST['fromtag']); 1182 $needle = trim($_POST['fromtag']);
@@ -1184,13 +1185,16 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history)
1184 foreach($linksToAlter as $key=>$value) 1185 foreach($linksToAlter as $key=>$value)
1185 { 1186 {
1186 $tags = explode(' ',trim($value['tags'])); 1187 $tags = explode(' ',trim($value['tags']));
1187 unset($tags[array_search($needle,$tags)]); // Remove tag. 1188 if (($pos = array_search($needle,$tags)) !== false) {
1188 $value['tags']=trim(implode(' ',$tags)); 1189 unset($tags[$pos]); // Remove tag.
1189 $LINKSDB[$key]=$value; 1190 $value['tags']=trim(implode(' ',$tags));
1190 $history->updateLink($LINKSDB[$key]); 1191 $LINKSDB[$key]=$value;
1192 $history->updateLink($LINKSDB[$key]);
1193 ++$count;
1194 }
1191 } 1195 }
1192 $LINKSDB->save($conf->get('resource.page_cache')); 1196 $LINKSDB->save($conf->get('resource.page_cache'));
1193 echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?do=changetag\';</script>'; 1197 echo '<script>alert("Tag was removed from '.$count.' links.");document.location=\'?do=changetag\';</script>';
1194 exit; 1198 exit;
1195 } 1199 }
1196 1200
@@ -1202,13 +1206,16 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history)
1202 foreach($linksToAlter as $key=>$value) { 1206 foreach($linksToAlter as $key=>$value) {
1203 $tags = preg_split('/\s+/', trim($value['tags'])); 1207 $tags = preg_split('/\s+/', trim($value['tags']));
1204 // Replace tags value. 1208 // Replace tags value.
1205 $tags[array_search($needle, $tags)] = trim($_POST['totag']); 1209 if (($pos = array_search($needle,$tags)) !== false) {
1206 $value['tags'] = implode(' ', array_unique($tags)); 1210 $tags[$pos] = trim($_POST['totag']);
1207 $LINKSDB[$key] = $value; 1211 $value['tags'] = implode(' ', array_unique($tags));
1208 $history->updateLink($LINKSDB[$key]); 1212 $LINKSDB[$key] = $value;
1213 $history->updateLink($LINKSDB[$key]);
1214 ++$count;
1215 }
1209 } 1216 }
1210 $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk. 1217 $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk.
1211 echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode(escape($_POST['totag'])).'\';</script>'; 1218 echo '<script>alert("Tag was renamed in '.$count.' links.");document.location=\'?searchtags='.urlencode(escape($_POST['totag'])).'\';</script>';
1212 exit; 1219 exit;
1213 } 1220 }
1214 } 1221 }