Author: rhari
Date: Thu May 31 13:26:12 2007
New Revision: 483

URL: http://svn.gna.org/viewcvs/phplinker?rev=483&view=rev
Log:
#144
Api d'insertion d'url

Added:
    trunk/www/admin/api/insert_url.php

Added: trunk/www/admin/api/insert_url.php
URL: 
http://svn.gna.org/viewcvs/phplinker/trunk/www/admin/api/insert_url.php?rev=483&view=auto
==============================================================================
--- trunk/www/admin/api/insert_url.php (added)
+++ trunk/www/admin/api/insert_url.php Thu May 31 13:26:12 2007
@@ -1,0 +1,70 @@
+<?php
+/*
+    This file is part of PHPLinker.
+
+    PHPLinker is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    PHPLinker is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with PHPLinker; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+*/
+?>
+<?php
+require($_SERVER['DOCUMENT_ROOT']."/includes/start.php");
+
+if (!is_allowed_ip($_SERVER['REMOTE_ADDR'])){
+  echo("error\t"._("You're not allowed to access this script!"));
+  exit;
+ }
+
+extract($_GET);
+if (!isset ($url)){
+  echo ("error\t"._("Missing URL address"));
+  exit;
+ }
+
+if (!isset ($email)){
+  echo ("error\t"._("Missing webmaster email address"));
+  exit;
+ }
+
+if (!isset ($description)){
+  echo ("error\t"._("Missing description"));
+  exit;
+ }
+
+if (!isset($category) or sizeof($category) == 0)
+  $categorized = 0;
+else
+  $categorized = 1;
+
+// echo 'url : '.$url.'<br>';
+// echo 'email : '.$email.'<br>';
+// echo 'description : '.utf8_decode($description).'<br>';
+// echo '<pre>';
+// print_r ($category);
+// echo '</pre>';
+// echo sizeof($category);
+
+$qry = "INSERT INTO url (url, description, last_update, email) VALUES 
('".$url."', '".utf8_decode($description)."', '".date("Y-m-d h:i:s")."', 
'".utf8_decode($email)."')";
+sql_query('die',__FILE__,__LINE__,__FUNCTION__,$qry);
+
+if ($categorized == 1){
+  $know_first = sql_query('die',__FILE__,__LINE__,__FUNCTION__,"SELECT id FROM 
 url ORDER BY id DESC LIMIT 1");
+  $id_url = mysql_result($know_first,0,"id");
+  foreach($category as $value){
+    if (is_numeric($value))
+      $update_cat_url =  
sql_query('die',__FILE__,__LINE__,__FUNCTION__,"INSERT INTO url2category 
(id_url, id_category) VALUES (".$id_url.",".$value.")");
+  }
+ }
+
+linker_log("[API:".$_SERVER['DOCUMENT_ROOT'] ."]Insert URL url_".$id_url);
+?>


_______________________________________________
PHPLinker-commits mailing list
[email protected]
https://mail.gna.org/listinfo/phplinker-commits

Reply via email to