[ PHPXref.com ] [ Generated: Sun Jul 20 16:25:17 2008 ] [ ActionApps 2.8.1b ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> offline.php3 (source)

   1  <?php
   2  //$Id: offline.php3,v 1.11 2005/04/24 21:48:11 honzam Exp $
   3  /* 
   4  Copyright (C) 1999, 2000 Association for Progressive Communications 
   5  http://www.apc.org/
   6  
   7      This program is free software; you can redistribute it and/or modify
   8      it under the terms of the GNU General Public License as published by
   9      the Free Software Foundation; either version 2 of the License, or
  10      (at your option) any later version.
  11  
  12      This program is distributed in the hope that it will be useful,
  13      but WITHOUT ANY WARRANTY; without even the implied warranty of
  14      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15      GNU General Public License for more details.
  16  
  17      You should have received a copy of the GNU General Public License
  18      along with this program (LICENSE); if not, write to the Free Software
  19      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  */
  21   
  22  // script for off-line filling (items send in some XML format, currently WDDX)
  23  
  24  // Parameters:
  25  //   slice_id     - id of slice into which the item is added
  26  //   offline_data - set of WDDXed items to fill in
  27  //   del_url      - url to point the script if filling is successfull 
  28  //                  (should delete local copy of file with wddx)
  29  
  30  // handle with PHP magic quotes - quote the variables if quoting is set off
  31  function Myaddslashes($val, $n=1) {
  32    if (!is_array($val)) {
  33      return addslashes($val);
  34    }  
  35    for (reset($val); list($k, $v) = each($val); )
  36      $ret[$k] = Myaddslashes($v, $n+1);
  37    return $ret;
  38  }    
  39  
  40  if (!get_magic_quotes_gpc()) { 
  41    // Overrides GPC variables 
  42    if ( isset($HTTP_GET_VARS) AND is_array($HTTP_GET_VARS))
  43      for (reset($HTTP_GET_VARS); list($k, $v) = each($HTTP_GET_VARS); ) 
  44        $$k = Myaddslashes($v); 
  45    if ( isset($HTTP_POST_VARS) AND is_array($HTTP_POST_VARS))
  46      for (reset($HTTP_POST_VARS); list($k, $v) = each($HTTP_POST_VARS); ) 
  47        $$k = Myaddslashes($v); 
  48    if ( isset($HTTP_COOKIE_VARS) AND is_array($HTTP_COOKIE_VARS))
  49      for (reset($HTTP_COOKIE_VARS); list($k, $v) = each($HTTP_COOKIE_VARS); ) 
  50        $$k = Myaddslashes($v); 
  51  }
  52  
  53  require_once  "./include/config.php3";
  54  require_once $GLOBALS['AA_INC_PATH']."locsess.php3";
  55  require_once $GLOBALS['AA_INC_PATH']."util.php3";
  56  require_once $GLOBALS['AA_INC_PATH']."varset.php3";
  57  require_once $GLOBALS['AA_INC_PATH']."itemfunc.php3";
  58  require_once $GLOBALS['AA_INC_PATH']."notify.php3";
  59  require_once $GLOBALS['AA_INC_PATH']."xmlparse.php3";
  60  require_once $GLOBALS['AA_INC_PATH']."pagecache.php3";
  61  require_once $GLOBALS['AA_INC_PATH']."feeding.php3";
  62  
  63  function SendErrorPage($txt) {
  64    HTMLPageBegin();
  65    echo "</head><body>".$txt."</body></html>";
  66    exit;
  67  }  
  68  
  69  function SendOkPage($txt) {
  70    HTMLPageBegin();
  71    echo "</head><body>".$txt."</body></html>";
  72    exit;
  73  }  
  74  
  75    // init used objects
  76  $db = new DB_AA;
  77  $err["Init"] = "";          // error array (Init - just for initializing variable
  78  $varset = new Cvarset();
  79  $itemvarset = new Cvarset();
  80  
  81  if ( !$slice_id )
  82    SendErrorPage(_m("Slice ID not defined"));
  83  
  84  $error = "";
  85  $ok = "";
  86  
  87  $p_slice_id = q_pack_id($slice_id);
  88  $slice_info = GetSliceInfo($slice_id);
  89  
  90  $offline_data = stripslashes($offline_data);
  91  $offline_data = str_replace(chr(14),' ',$offline_data);  // remove wrong chars
  92  
  93  if ( !$slice_info )
  94    SendErrorPage(_m("Bad slice ID"));
  95  
  96  if ( $slice_info["permit_offline_fill"] < 1 )
  97    SendErrorPage(_m("You don't have permission to fill this slice off-line"));
  98   else
  99    $bin2fill = $slice_info["permit_offline_fill"]; 
 100    
 101    // get slice fields and its priorities in inputform
 102  list($fields,$prifields) = GetSliceFields($slice_id);   
 103  
 104  $packets = explode( "<wddxPacket", $offline_data );
 105  
 106  // print_r($packets);
 107  
 108  reset($packets);
 109  while ( list(,$packet) = each($packets) ) {
 110    if ( strlen($packet) < 6 )   // throw first, it should be "";
 111      continue;
 112    switch (StoreWDDX2DB( "<wddxPacket".$packet,$slice_id,$fields,$bin2fill)) {
 113     case WDDX_DUPLICATED:
 114       $ok .= MsgOk( _m("Duplicated item send - skipped") );  // this is error but not fatal - i
 115       break;
 116     case WDDX_BAD_PACKET:
 117       $error .= MsgErr( _m("Wrong data (WDDX packet)") );
 118       break;
 119     case WDDX_OK:
 120       $ok .= MsgOk( _m("Item OK - stored in database") );  // this is error but not fatal - i
 121       break;
 122    }   
 123  }  
 124  
 125  if ( $error )
 126    SendErrorPage( $error );
 127   else
 128    SendOkPage( "$ok<br>". _m("Now you can dalete local file. ") . 
 129                    " <a href='$del_url'>"._m(" Delete ")."</a>", $del_url );
 130  
 131  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]