Author: gassla
Date: Thu May 31 13:47:53 2007
New Revision: 484

URL: http://svn.gna.org/viewcvs/phplinker?rev=484&view=rev
Log:
#219

Added:
    trunk/www/admin/api/update_url_stats.php   (with props)
Modified:
    trunk/www/lib/url.php

Added: trunk/www/admin/api/update_url_stats.php
URL: 
http://svn.gna.org/viewcvs/phplinker/trunk/www/admin/api/update_url_stats.php?rev=484&view=auto
==============================================================================
--- trunk/www/admin/api/update_url_stats.php (added)
+++ trunk/www/admin/api/update_url_stats.php Thu May 31 13:47:53 2007
@@ -1,0 +1,79 @@
+<?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$
+   * @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'])){
+  echo("error\t"._("You're not allowed to access this script!"));
+  exit;
+ }
+
+$debug=false;
+
+if(isset($_POST['debug']) && $_POST['debug']==1){
+  $debug=true;
+ }
+
+header("Content-type: text/plain");
+if(isset($_POST) && count($_POST)>0){
+  foreach($_POST as $type => $url){
+    if( preg_match("/^url_\d+/", $type) ){
+      list(,$num)=split("_",$type);
+
+      $valid=true;
+
+      if(empty($url)){
+       echo("error\turl_$num invalid value\n");
+       $valid=false;
+      }
+
+      if(!isset($_POST["hit_$num"]) ){
+       echo("error\thit_$num doesn't exist\n");
+       $valid=false;
+      }else if(isset($_POST["hit_$num"]) && 
!osh_check_unsigned_int($_POST["hit_$num"]) ){
+       echo("error\thit_$num invalid value\n");
+       $valid=false;
+      }
+
+      if(!isset($_POST["date_update_$num"]) ){
+       echo("error\tdate_update_$num doesn't exist\n");
+       $valid=false;
+      }else if(isset($_POST["date_update_$num"]) && 
!check_url_date_update($_POST["date_update_$num"]) ){
+       echo("error\tdate_update_$num invalid value\n");
+       $valid=false;
+      }
+
+      if($valid && !$debug){
+       
linker_update_url_stats($url,$_POST["hit_$num"],$_POST["date_update_$num"]);
+       echo "OK";
+      }
+    }
+  }
+ }else{
+  echo "error\tinvalid argument";
+ }
+
+?>

Propchange: trunk/www/admin/api/update_url_stats.php
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: trunk/www/lib/url.php
URL: 
http://svn.gna.org/viewcvs/phplinker/trunk/www/lib/url.php?rev=484&r1=483&r2=484&view=diff
==============================================================================
--- trunk/www/lib/url.php (original)
+++ trunk/www/lib/url.php Thu May 31 13:47:53 2007
@@ -126,7 +126,19 @@
     return false;
 }
 
-function linker_update_url($id_url){
+function linker_update_url_stats($url,$hit,$date_update){
+  $url=strtolower(urldecode($url));
+  $url=preg_replace('/^http:\/\//','',$url);
+  $url=preg_replace('/\/$/','',$url);
+  return sql_query('die', __FILE__, __LINE__, __FUNCTION__,"UPDATE url SET 
hit=$hit, last_update='$date_update' WHERE url RLIKE '$url' ");
+}
 
+function check_url_date_update($date_update){
+  $date=split("-",$date_update);
+  if(count($date)==3){
+    return checkdate($date[1],$date[2],$date[0]);
+  }
+  return false;
 }
-?>
+
+?>


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

Reply via email to