Author: gassla
Date: Wed May 30 15:11:36 2007
New Revision: 467
URL: http://svn.gna.org/viewcvs/phplinker?rev=467&view=rev
Log:
#218
Added:
trunk/www/admin/api/fetch_url_info.php
Modified:
trunk/www/lib/url.php (contents, props changed)
Added: trunk/www/admin/api/fetch_url_info.php
URL:
http://svn.gna.org/viewcvs/phplinker/trunk/www/admin/api/fetch_url_info.php?rev=467&view=auto
==============================================================================
--- trunk/www/admin/api/fetch_url_info.php (added)
+++ trunk/www/admin/api/fetch_url_info.php Wed May 30 15:11:36 2007
@@ -1,0 +1,46 @@
+<?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
+*/
+ /**
+ * @version $Id: fetch_categories.php 464 2007-05-30 08:52:26Z gassla $
+ * @copyright Copyright (c) by ISVTEC
+ * @license GPL v2
+ */
+?>
+<?php
+require($_SERVER['DOCUMENT_ROOT']."/includes/start.php");
+require_once($_SERVER['DOCUMENT_ROOT']."/lib/url.php");
+
+if (!is_allowed_ip($_SERVER['REMOTE_ADDR']))
+ die (_("You're not allowed to access this script!"));
+
+header("Content-type: text/plain");
+if(isset($_GET['url']) && !empty($_GET['url'])){
+ $Url=linker_get_url_info($_GET['url']);
+ if($Url != false){
+
printf("id\t%d\ndescription\t%s\n",$Url->id,utf8_decode($Url->description));
+ $categs=$Url->categories;
+ foreach($categs as $id_categ)
+ echo("category\t$id_categ\n");
+ }
+ }else{
+ echo "provide an argument like fecth_url_info?url=www.example.com";
+ }
+
+
+?>
Modified: trunk/www/lib/url.php
URL:
http://svn.gna.org/viewcvs/phplinker/trunk/www/lib/url.php?rev=467&r1=466&r2=467&view=diff
==============================================================================
--- trunk/www/lib/url.php (original)
+++ trunk/www/lib/url.php Wed May 30 15:11:36 2007
@@ -16,6 +16,11 @@
along with PHPLinker; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+ /**
+ * @version $Id$
+ * @copyright Copyright (c) by ISVTEC
+ * @license GPL v2
+ */
?>
<?php
function linker_get_urls_need_moderation($idf){
@@ -102,4 +107,22 @@
return "";
}
}
+
+function linker_get_url_info($url){
+ $url=strtolower(urldecode($url));
+ $url=preg_replace('/^http:\/\//','',$url);
+ $url=preg_replace('/\/$/','',$url);
+ $res = sql_query('die', __FILE__, __LINE__, __FUNCTION__,"SELECT id, url,
description, categorized FROM url WHERE url RLIKE '$url' ORDER BY last_update
DESC LIMIT 1 ");
+
+ if(mysql_num_rows($res)==1){
+ $Url=mysql_fetch_object($res);
+ $res = sql_query('die', __FILE__, __LINE__, __FUNCTION__,"SELECT
id_category FROM url2category WHERE id_url=".$Url->id );
+ $categs=array();
+ while(list($id_categ)=mysql_fetch_array($res))
+ $categs[]=$id_categ;
+ $Url->categories=$categs;
+ return $Url;
+ }else
+ return false;
+}
?>
Propchange: trunk/www/lib/url.php
------------------------------------------------------------------------------
svn:keywords = Id
_______________________________________________
PHPLinker-commits mailing list
[email protected]
https://mail.gna.org/listinfo/phplinker-commits