Пример #1
0
<?php

/**
 * Batcher
 *
 * Copyright 2010 by Shaun McCormick <*****@*****.**>
 *
 * This file is part of Batcher, a batch resource editing Extra.
 *
 * Batcher 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.
 *
 * Batcher 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
 * Batcher; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * @package batcher
 */
/**
 * @package batcher
 * @subpackage controllers
 */
require_once dirname(dirname(__FILE__)) . '/model/batcher/batcher.class.php';
$batcher = new Batcher($modx);
return $batcher->initialize('mgr');
Пример #2
0
 public function RawRequest()
 {
     global $v2BatchDebug;
     if (!array_key_exists('CONTENT_TYPE', $_SERVER) && UrlUtils::RequestMethod() != "post") {
         HttpUtils::ApiError(405, "The HTTP verb used is not allowed.");
     }
     $a_data = array();
     // read incoming data
     $input = file_get_contents('php://input');
     if ($v2BatchDebug) {
         file_put_contents("batch.log", "REQUEST:" . $input . "\r\n", FILE_APPEND);
         file_put_contents("batch.log", "\r\n", FILE_APPEND);
     }
     // grab multipart boundary from content type header
     preg_match('/boundary=(.*)$/', $_SERVER['CONTENT_TYPE'], $matches);
     // content type is probably regular form-encoded
     if (!count($matches)) {
         return null;
     }
     $boundary = $matches[1];
     $parsed = $this->ParseData($boundary, $input);
     $result = array();
     if ($v2BatchDebug) {
         file_put_contents("batch.log", "PARSING:" . sizeof($parsed) . "\r\n", FILE_APPEND);
         file_put_contents("batch.log", "\r\n", FILE_APPEND);
     }
     for ($i = 0; $i < sizeof($parsed); $i++) {
         $item = $parsed[$i];
         $item->ResultStatus = 200;
         if ($item->Method == "get") {
             $item->ResultData = HttpUtils::HttpGet($item->Action);
         } else {
             if ($item->Method == "get") {
                 $item->ResultData = HttpUtils::HttpPost($item->Action, $item->Data, "application/atom+xml");
             }
         }
         array_push($result, $item);
     }
     $response = Batcher::Elaborate($result);
     if ($v2BatchDebug) {
         file_put_contents("batch.log", "RESULT:" . $response . "\r\n", FILE_APPEND);
         file_put_contents("batch.log", "\r\n", FILE_APPEND);
     }
 }