function passDataToApplication($url)
{
    $_SERVER['REQUEST_URI'] = modifyUrl($url);
    $_GET['loggedAt'] = getLoggedAt();
    require_once __DIR__ . '/../app/bootstrap.php.cache';
    require_once __DIR__ . '/../app/AppKernel.php';
    $kernel = new AppKernel('prod', false);
    $kernel->loadClassCache();
    $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
    $kernel->handle($request);
}
 protected function handleRequest(Request $request, $uri, $parameters = array(), $environment = "setup_test")
 {
     $data = json_decode($request->getContent(), true);
     if (!array_key_exists("authKey", $data) || !$this->verifyAuthKey($data["authKey"])) {
         $response["success"] = false;
         $response["message"] = "Invalid Authentication Key";
         $response["errors"] = array();
         return new JsonResponse($response);
     }
     try {
         $kernel = new \AppKernel($environment, true);
         $internalRequest = Request::create($uri, "GET", $parameters);
         return $kernel->handle($internalRequest);
     } catch (\Exception $e) {
         $response["success"] = false;
         $response["message"] = "Generic Error";
         $response["errors"] = [$e->getMessage()];
         return new JsonResponse($response);
     }
 }
 /**
  * Handles the given request by setting up a setup_test environment.
  *
  * @param Request $request
  * @param         $uri
  * @param array   $parameters
  * @param string  $environment
  *
  * @return JsonResponse|\Symfony\Component\HttpFoundation\Response
  */
 protected function handleRequest(Request $request, $uri, $parameters = [], $environment = 'setup_test')
 {
     $data = json_decode($request->getContent(), true);
     if (!array_key_exists('authKey', $data) || !$this->verifyAuthKey($data['authKey'])) {
         $response['success'] = false;
         $response['message'] = 'Invalid Authentication Key';
         $response['errors'] = [];
         return new JsonResponse($response);
     }
     $parameters['authKey'] = $data['authKey'];
     try {
         $kernel = new \AppKernel($environment, true);
         $internalRequest = Request::create($uri, 'GET', $parameters);
         return $kernel->handle($internalRequest);
     } catch (\Exception $e) {
         $response['success'] = false;
         $response['message'] = 'Generic Error';
         $response['errors'] = [$e->getMessage()];
         return new JsonResponse($response);
     }
 }
Example #4
0
 public function authenticate(MOXMAN_Auth_User $user)
 {
     $config = MOXMAN::getConfig();
     // Load environment and session logic
     if (!$this->isSessionLoaded) {
         $kernel = new AppKernel($config->get("SymfonyAuthenticator.environment", "prod"), false);
         $kernel->loadClassCache();
         $request = Request::createFromGlobals();
         $kernel->handle($request);
         $this->isSessionLoaded = true;
     }
     // Get all session data
     $session = new Session();
     $session = $session->all();
     // Check logged in key
     $loggedInKey = $config->get("SymfonyAuthenticator.logged_in_key", "isLoggedIn");
     $sessionValue = isset($session[$loggedInKey]) ? $session[$loggedInKey] : false;
     if (!$sessionValue || $sessionValue === "false") {
         return false;
     }
     // Extend config with session prefixed sessions
     $sessionConfig = array();
     $configPrefix = $config->get("SymfonyAuthenticator.config_prefix", "moxiemanager");
     if ($configPrefix) {
         foreach ($session as $key => $value) {
             if (strpos($key, $configPrefix) === 0) {
                 $sessionConfig[substr($key, strlen($configPrefix) + 1)] = $value;
             }
         }
     }
     // Extend the config with the session config
     $config->extend($sessionConfig);
     // Replace ${user} with all config items
     $key = $config->get("SessionAuthenticator.user_key", "user");
     if ($key && isset($session[$key])) {
         $config->replaceVariable("user", $session[$key]);
         $user->setName($session[$key]);
     }
     return true;
 }
Example #5
0
<?php

// this check prevents access to debug front controllers that are deployed by accident to production servers.
// feel free to remove this, extend it, or make something more sophisticated.
if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
    die('You are not allowed to access this file. Check ' . basename(__FILE__) . ' for more information.');
}
require_once __DIR__ . '/../app/AppKernel.php';
use Symfony\Component\HttpFoundation\Request;
$kernel = new AppKernel('dev', true);
$kernel->handle(new Request())->send();
Example #6
0
<?php

/*
 * This file is part of the ACME PHP library.
 *
 * (c) Titouan Galopin <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
require_once __DIR__ . '/bootstrap.php';
require_once __DIR__ . '/AppKernel.php';
$kernel = new AppKernel('test', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, false);
$response->send();
$kernel->terminate($request, $response);
Example #7
0
 /**
  * This is the same as invoke(), but it does *not* include exception
  * handling.
  *
  * @param array $args
  *   The parts of the URL which identify the intended CiviCRM page
  *   (e.g. array('civicrm', 'event', 'register')).
  * @return string
  *   HTML. For non-HTML content, invoke() may call print() and exit().
  */
 public static function _invoke($args)
 {
     if ($args[0] !== 'civicrm') {
         return NULL;
     }
     // CRM-15901: Turn off PHP errors display for all ajax calls
     if (CRM_Utils_Array::value(1, $args) == 'ajax' || CRM_Utils_Array::value('snippet', $_REQUEST)) {
         ini_set('display_errors', 0);
     }
     if (!defined('CIVICRM_SYMFONY_PATH')) {
         // Traditional Civi invocation path
         self::hackMenuRebuild($args);
         // may exit
         self::init($args);
         self::hackStandalone($args);
         $item = self::getItem($args);
         return self::runItem($item);
     } else {
         // Symfony-based invocation path
         require_once CIVICRM_SYMFONY_PATH . '/app/bootstrap.php.cache';
         require_once CIVICRM_SYMFONY_PATH . '/app/AppKernel.php';
         $kernel = new AppKernel('dev', TRUE);
         $kernel->loadClassCache();
         $response = $kernel->handle(Symfony\Component\HttpFoundation\Request::createFromGlobals());
         if (preg_match(':^text/html:', $response->headers->get('Content-Type'))) {
             // let the CMS handle the trappings
             return $response->getContent();
         } else {
             $response->send();
             exit;
         }
     }
 }
Example #8
0
// Use APC for autoloading to improve performance.
// Change 'sf2' to a unique prefix in order to prevent cache key conflicts
// with other applications also using APC.
/*
$apcLoader = new ApcClassLoader('sf2', $loader);
$loader->unregister();
$apcLoader->register(true);
*/
require_once __DIR__ . '/../app/AppKernel.php';
use Symfony\Component\Yaml\Yaml;
$maintenanceMode = file_exists(__DIR__ . '/../app/config/.update');
$authorized = false;
if (file_exists($file = __DIR__ . '/../app/config/ip_white_list.yml')) {
    $ips = Yaml::parse($file);
    $authorized = false;
    foreach ($ips as $ip) {
        if ($ip === $_SERVER['REMOTE_ADDR']) {
            $authorized = true;
        }
    }
}
if (!$maintenanceMode || $authorized) {
    $request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
    $kernel = new AppKernel('prod', false);
    $kernel->loadClassCache();
    $kernel->handle($request)->send();
    //$kernel->terminate($request, $response);
} else {
    $url = $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '/../maintenance.php';
    header("Location: http://{$url}");
}
Example #9
0
<?php

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\ApacheRequest;
umask(00);
$loader = (require_once __DIR__ . '/../app/bootstrap.php.cache');
$loader = new ApcClassLoader('SymfonyBigaEdition', $loader);
$loader->register(true);
require_once __DIR__ . '/../app/AppKernel.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$response = $kernel->handle($request = ApacheRequest::createFromGlobals());
$response->send();
$kernel->terminate($request, $response);
Example #10
0
<?php

use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = (require_once __DIR__ . '/../app/bootstrap.php.cache');
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
$request = Request::createFromGlobals();
$response = $kernel->handle($request)->send();
$kernel->terminate($request, $response);
Example #11
0
<?php

use Symfony\Component\HttpFoundation\Request;
$loader = (require_once __DIR__ . '/../app/bootstrap.php.cache');
require_once __DIR__ . '/../app/AppKernel.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
Example #12
0
<?php

use Symfony\Component\HttpFoundation\Request;
require_once __DIR__ . '/../app/autoload.php';
require_once __DIR__ . '/../app/AppBootstrap.php';
require_once __DIR__ . '/../app/AppKernel.php';
$request = Request::createFromGlobals();
$bootstrap = new Bootstrap('prod');
$kernel = new AppKernel($request, $bootstrap->routes, $bootstrap->conf);
$kernel->handle();
Example #13
0
<?php

return;
// @todo replace with a better check
// @todo using filesystem ACLs is recommended, but what should we do by default?
//umask(0002); // This will let the permissions be 0775
umask(00);
// This will let the permissions be 0777
use ZenMagick\Http\Request;
//$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__ . '/../app/autoload.php';
require_once __DIR__ . '/../app/AppKernel.php';
// @todo remove context from here altogether!
$application = new AppKernel('install', true, 'admin');
//$application->loadClassCache();
$request = Request::createFromGlobals();
$response = $application->handle($request);
$response->send();
$application->terminate($request, $response);
Example #14
0
<?php

require_once __DIR__ . '/../app/bootstrap.php.cache';
require_once __DIR__ . '/../app/AppKernel.php';
use Symfony\Component\HttpFoundation\Request;
$kernel = new AppKernel('dev', false);
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
$handle = $kernel->handle($request);
$container = $kernel->getContainer();
$em = $container->get('doctrine')->getEntityManager();
Example #15
0
<?php

// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
umask(00);
// this check prevents access to debug front controllers that are deployed by accident to production servers.
// feel free to remove this, extend it, or make something more sophisticated.
if (isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']) || !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
    header('HTTP/1.0 403 Forbidden');
    exit('You are not allowed to access this file. Check ' . basename(__FILE__) . ' for more information.');
}
require_once __DIR__ . '/../app/bootstrap.php.cache';
require_once __DIR__ . '/../app/AppKernel.php';
use Symfony\Component\HttpFoundation\Request;
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$kernel->handle(Request::createFromGlobals())->send();
 protected static function _invoke($args)
 {
     if ($args[0] !== 'civicrm') {
         return;
     }
     // CRM-15901: Turn off PHP errors display for all ajax calls
     if (CRM_Utils_Array::value(1, $args) == 'ajax' || CRM_Utils_Array::value('snippet', $_REQUEST)) {
         ini_set('display_errors', 0);
     }
     if (!defined('CIVICRM_SYMFONY_PATH')) {
         try {
             // Traditional Civi invocation path
             self::hackMenuRebuild($args);
             // may exit
             self::init($args);
             self::hackStandalone($args);
             $item = self::getItem($args);
             return self::runItem($item);
         } catch (CRM_Core_EXCEPTION $e) {
             $params = $e->getErrorData();
             $message = $e->getMessage();
             if (isset($params['legacy_status_bounce'])) {
                 //@todo remove this- see comments on
                 //https://github.com/eileenmcnaughton/civicrm-core/commit/ae686b09e2c987091612bb25ba0a58e520a203e7
                 CRM_Core_Error::statusBounce($params['message']);
             } else {
                 $session = CRM_Core_Session::singleton();
                 $session->setStatus($message, CRM_Utils_Array::value('message_title', $params), CRM_Utils_Array::value('message_type', $params, 'error'));
                 // @todo remove this code - legacy redirect path is an interim measure for moving redirects out of BAO
                 // to somewhere slightly more acceptable. they should not be part of the exception class & should
                 // be managed @ the form level - if you find a form that is triggering this piece of code
                 // you should log a ticket for it to be removed with details about the form you were on.
                 if (!empty($params['legacy_redirect_path'])) {
                     if (CRM_Utils_System::isDevelopment()) {
                         // here we could set a message telling devs to log it per above
                     }
                     CRM_Utils_System::redirect($params['legacy_redirect_path'], $params['legacy_redirect_query']);
                 }
             }
         } catch (Exception $e) {
             // Recall: CRM_Core_Config is initialized before calling CRM_Core_Invoke
             $config = CRM_Core_Config::singleton();
             return CRM_Core_Error::handleUnhandledException($e);
             /*
                     if ($config->backtrace) {
                       return CRM_Core_Error::formatHtmlException($e);
                     } else {
                      // TODO
                     }*/
         }
     } else {
         // Symfony-based invocation path
         require_once CIVICRM_SYMFONY_PATH . '/app/bootstrap.php.cache';
         require_once CIVICRM_SYMFONY_PATH . '/app/AppKernel.php';
         $kernel = new AppKernel('dev', true);
         $kernel->loadClassCache();
         $response = $kernel->handle(Symfony\Component\HttpFoundation\Request::createFromGlobals());
         // $response->send();
         return $response->getContent();
     }
 }
Example #17
0
 public function run()
 {
     $response = $this->kernel->handle($this->request);
     $response->send();
     $this->kernel->terminate($this->request, $response);
 }
 /**
  * AuthBridge constructor.
  * @param $symfonyRootPath
  * @param $symfonyUrl
  */
 function __construct($symfonyRootPath, $symfonyUrl, $groupManager = null)
 {
     global $wgHooks;
     $this->symfonyRootPath = $symfonyRootPath;
     $this->symfonyUrl = $symfonyUrl;
     // Set some MediaWiki Values
     // This requires a user be logged into the wiki to make changes.
     $GLOBALS['wgGroupPermissions']['*']['edit'] = false;
     // Specify who may create new accounts:
     $GLOBALS['wgGroupPermissions']['*']['createaccount'] = false;
     if (is_dir($this->symfonyRootPath)) {
         // Load Hooks
         $wgHooks['UserLoginForm'][] = array($this, 'onUserLoginForm', false);
         $wgHooks['UserLoginComplete'][] = $this;
         $wgHooks['UserLogout'][] = $this;
         $wgHooks['UserLoadFromSession'][] = array($this, 'AutoAuthenticateOverSymfony');
         $wgHooks['UserLogout'][] = array($this, 'logoutForm');
         $wgHooks['UserLoginForm'][] = array($this, 'loginForm');
         $loader = (require $this->symfonyRootPath . '/app/autoload.php');
         require_once $this->symfonyRootPath . '/var/bootstrap.php.cache';
         if (false) {
             Debug::enable();
             $kernel = new \AppKernel('dev', true);
         } else {
             $kernel = new \AppKernel('prod', false);
         }
         //Request::enableHttpMethodParameterOverride();
         $request = Request::createFromGlobals();
         $kernel->handle($request);
         $this->symfonyConatiner = $kernel->getContainer();
         if ($groupManager && $this->symfonyConatiner->has($groupManager)) {
             $groupBridge = new GroupBridge($this, $groupManager);
             $groupBridge->initGroups();
             $groupBridge->setUpGroupNamespaces();
         }
     } else {
         trigger_error("Symfony System not found! Login is not possible!", E_USER_NOTICE);
     }
 }
Example #19
0
<?php

require_once __DIR__ . '/constants.php';
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/application/bootstrap.php.cache';
require_once __DIR__ . '/application/AppKernel.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
 * THIS FILE IS STIL THERE FOR LEGACY (NOT BASED ON INDEX.PHP) FILES
 * IT'S COPYIED FROM INDEX.PHP
 */
/**
 * Create Symfony kernel
 */
if (APPLICATION_ENV === 'production') {
    $kernel = new AppKernel('prod', false);
} else {
    if (APPLICATION_ENV === 'development' || APPLICATION_ENV === 'dev') {
        $kernel = new AppKernel('dev', true);
    } else {
        $kernel = new AppKernel(APPLICATION_ENV, true);
    }
}
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$response = $kernel->handle($request, \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, false);
$response->send();
$kernel->terminate($request, $response);