Skip to content

Commit

Permalink
REST service added
Browse files Browse the repository at this point in the history
  • Loading branch information
easterism committed Oct 3, 2014
1 parent eec1239 commit c024cb0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion inc/classes/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function send($in_transaction = false) {
$db = new Db();

if ($db->isModuleActive('queue')) {
require_once($db->getModuleLocation('queue') . '/modQueueController.php');
require_once($db->getModuleLocation('queue') . '/ModQueueController.php');
$queue = new modQueueController();

$queue->createEmail(
Expand Down
29 changes: 28 additions & 1 deletion inc/classes/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function dispatch() {

// Веб-сервис (SOAP)
$matches = array();
if (preg_match('~(wsdl_([a-zA-Z0-9_]+)\.xml|ws_([a-zA-Z0-9_]+)\.php)~', basename($_SERVER['REQUEST_URI']), $matches)) {
if (preg_match('~^(wsdl_([a-zA-Z0-9_]+)\.xml|ws_([a-zA-Z0-9_]+)\.php)~', basename($_SERVER['REQUEST_URI']), $matches)) {

// Инициализация модуля вебсервиса
if ( ! $this->isModuleActive('webservice')) {
Expand Down Expand Up @@ -257,6 +257,33 @@ public function dispatch() {
return $webservice_controller->dispatch_soap($module_name, $service_request_action);
}

// Веб-сервис (REST)
$matches = array();
if (preg_match('~api/([a-zA-Z0-9_]+)(\?|$)~', $_SERVER['REQUEST_URI'], $matches)) {

// Инициализация модуля вебсервиса
if ( ! $this->isModuleActive('webservice')) {
throw new Exception("SYSTEM:Module webservice does not active");
}

$webservice_location = $this->getModuleLocation('webservice');
$webservice_controller_path = $webservice_location . '/ModWebserviceController.php';

if ( ! file_exists($webservice_controller_path)) {
throw new Exception("SYSTEM:Module does not exists");
}

require_once($webservice_controller_path);

if ( ! class_exists('ModWebserviceController')) {
throw new Exception("SYSTEM:Module broken");
}


$webservice_controller = new ModWebserviceController();
return $webservice_controller->dispatch_rest(strtolower($matches[1]));
}


if (!empty($this->auth->ID) && !empty($this->auth->NAME) && is_int($this->auth->ID)) {
// LOG USER ACTIVITY
Expand Down
2 changes: 1 addition & 1 deletion inc/classes/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static function fb($text) {

$cnf = Zend_Registry::get('config');
if ($cnf->log->on) {
require_once('core2/ext/FirePHPCore/fb.php');
require_once('core2/ext/FirePHPCore-0.3.2/lib/FirePHPCore/fb.php');
fb($text);
}
}
Expand Down

0 comments on commit c024cb0

Please sign in to comment.