Przeglądaj źródła

Shorten long link with abbrr.com

vbracco 16 lat temu
rodzic
commit
643ed9be2b
5 zmienionych plików z 28 dodań i 2 usunięć
  1. 3 0
      admin/index.php
  2. 11 0
      admin/options.php
  3. 2 0
      classes/configuration.class.php
  4. 8 2
      index.php
  5. 4 0
      update.php

+ 3 - 0
admin/index.php Wyświetl plik

@@ -391,6 +391,9 @@ if ($user->isAdmin()) {
391 391
 									$template->mostrarPlantilla();
392 392
 									break;
393 393
 								case "4":
394
+									if($conf->shorten_links){
395
+										$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
396
+									}
394 397
 									$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
395 398
 									$input = array("{Id_Post}", "{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
396 399
 									$output = array($register["id_post"], $formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);

+ 11 - 0
admin/options.php Wyświetl plik

@@ -48,6 +48,11 @@ if ($user->isAdmin()) {
48 48
 			die();
49 49
 		}
50 50
 		
51
+		if (!$tumble->saveOption($_POST["shorten_links"], "shorten_links")) {
52
+			header("Location: ".$conf->urlGelato."/admin/options.php?error=1&des=".$conf->merror);
53
+			die();
54
+		}
55
+		
51 56
 		header("Location: ".$conf->urlGelato."/admin/options.php?modified=true");
52 57
 		die();
53 58
 	} else {
@@ -196,6 +201,12 @@ if ($user->isAdmin()) {
196 201
 											<option value="12,Pacific/Fiji" <?php echo ($conf->offsetCity=="Pacific/Fiji")? "selected=\"selected\"":"" ?>>(GMT +12:00) Fiji, Kamchatka, Marshall Is.</option>
197 202
 										</select>
198 203
 									</li>
204
+									<li class="select"><label for="shorten_links"><?php echo __("Shorten long URLs:")?></label>
205
+										<select name="shorten_links" id="shorten_links">
206
+											<option value="1" <?php if($conf->shorten_links) echo "selected"; ?>><?php echo __("Active")?></option>
207
+											<option value="0" <?php if(!$conf->shorten_links) echo "selected"; ?>><?php echo __("Deactive")?></option>
208
+										</select>
209
+									</li>
199 210
 								</ul>
200 211
 							</fieldset>
201 212
 							<p>

+ 2 - 0
classes/configuration.class.php Wyświetl plik

@@ -28,6 +28,7 @@ class configuration extends Conexion_Mysql {
28 28
 	var $richText;
29 29
 	var $offset_city;
30 30
 	var $offset_time;
31
+	var $shorten_links;
31 32
 	
32 33
 	
33 34
 	function configuration() {
@@ -52,6 +53,7 @@ class configuration extends Conexion_Mysql {
52 53
 			$this->offsetCity = $this->get_option("offset_city");
53 54
 			$this->offsetTime = $this->get_option("offset_time");
54 55
 			$this->allowComments = $this->get_option("allow_comments");
56
+			$this->shorten_links = $this->get_option("shorten_links");
55 57
 		} else {
56 58
 			if($isFeed) {
57 59
 				header("HTTP/1.0 503 Service Unavailable"); 

+ 8 - 2
index.php Wyświetl plik

@@ -129,7 +129,10 @@ $template = new plantillas($conf->template);
129 129
                                                 $template->mostrarPlantilla();
130 130
                                                 break;
131 131
                                         case "4":
132
-                                                $register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
132
+                                                if($conf->shorten_links){
133
+													$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
134
+												}
135
+												$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
133 136
 												$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
134 137
                                                 $output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
135 138
                                                 
@@ -224,7 +227,10 @@ $template = new plantillas($conf->template);
224 227
                                 $template->mostrarPlantilla();
225 228
                                 break;
226 229
                         case "4":
227
-                                $register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
230
+                                if($conf->shorten_links){
231
+									$register["url"] = _file_get_contents("http://api.abbrr.com/api.php?out=link&url=".$register["url"]);
232
+								}
233
+								$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
228 234
 								$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
229 235
                                 $output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
230 236
                                 

+ 4 - 0
update.php Wyświetl plik

@@ -36,6 +36,10 @@ $sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('offset_city', 'Mexico/
36 36
 $db->ejecutarConsulta($sqlStr);
37 37
 		
38 38
 $sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('offset_time', '-6');";
39
+
40
+$db->ejecutarConsulta($sqlStr);
41
+		
42
+$sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('shorten_links', '0');";
39 43
 		
40 44
 $db->ejecutarConsulta($sqlStr);
41 45