Bläddra i källkod

Shorten long link with abbrr.com

vbracco 18 år sedan
förälder
incheckning
643ed9be2b
5 ändrade filer med 28 tillägg och 2 borttagningar
  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 Visa fil

391
 									$template->mostrarPlantilla();
391
 									$template->mostrarPlantilla();
392
 									break;
392
 									break;
393
 								case "4":
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
 									$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
397
 									$register["title"] = ($register["title"]=="")? $register["url"] : $register["title"];
395
 									$input = array("{Id_Post}", "{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
398
 									$input = array("{Id_Post}", "{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
396
 									$output = array($register["id_post"], $formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
399
 									$output = array($register["id_post"], $formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);

+ 11 - 0
admin/options.php Visa fil

48
 			die();
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
 		header("Location: ".$conf->urlGelato."/admin/options.php?modified=true");
56
 		header("Location: ".$conf->urlGelato."/admin/options.php?modified=true");
52
 		die();
57
 		die();
53
 	} else {
58
 	} else {
196
 											<option value="12,Pacific/Fiji" <?php echo ($conf->offsetCity=="Pacific/Fiji")? "selected=\"selected\"":"" ?>>(GMT +12:00) Fiji, Kamchatka, Marshall Is.</option>
201
 											<option value="12,Pacific/Fiji" <?php echo ($conf->offsetCity=="Pacific/Fiji")? "selected=\"selected\"":"" ?>>(GMT +12:00) Fiji, Kamchatka, Marshall Is.</option>
197
 										</select>
202
 										</select>
198
 									</li>
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
 								</ul>
210
 								</ul>
200
 							</fieldset>
211
 							</fieldset>
201
 							<p>
212
 							<p>

+ 2 - 0
classes/configuration.class.php Visa fil

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

+ 8 - 2
index.php Visa fil

129
                                                 $template->mostrarPlantilla();
129
                                                 $template->mostrarPlantilla();
130
                                                 break;
130
                                                 break;
131
                                         case "4":
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
 												$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
136
 												$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
134
                                                 $output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
137
                                                 $output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
135
                                                 
138
                                                 
224
                                 $template->mostrarPlantilla();
227
                                 $template->mostrarPlantilla();
225
                                 break;
228
                                 break;
226
                         case "4":
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
 								$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
234
 								$input = array("{Date_Added}", "{Permalink}", "{URL}", "{Name}", "{Description}", "{URL_Tumble}");
229
                                 $output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
235
                                 $output = array($formatedDate, $permalink, $register["url"], $register["title"], $register["description"], $conf->urlGelato);
230
                                 
236
                                 

+ 4 - 0
update.php Visa fil

36
 $db->ejecutarConsulta($sqlStr);
36
 $db->ejecutarConsulta($sqlStr);
37
 		
37
 		
38
 $sqlStr = "INSERT INTO `".Table_prefix."options` VALUES ('offset_time', '-6');";
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
 $db->ejecutarConsulta($sqlStr);
44
 $db->ejecutarConsulta($sqlStr);
41
 
45