예제 #1
0
 /**
  * Used as a shortcut to have all classes in a directory extend.
  * For example if a class XenPlus_Extend_Model_User existed and this was called with getExtension($className, 'XenPlus_Extend_')
  * then it would return true when XenForo_Model_User is called, then you could add it to $extend in your listener.
  * 
  * @param  string $className 
  * @param  string $prefix    
  * @param  string $replace   
  * @return mixed false if no class, string of new class if it exists
  */
 public function getExtension($className, $prefix = '', $replace = 'XenForo_')
 {
     $className = $prefix . $className;
     if ($replace) {
         $className = str_replace($replace, '', $className);
     }
     $filename = XenForo_Autoloader::getInstance()->autoloaderClassToFile($className);
     return $filename && file_exists($filename) ? $className : false;
 }
예제 #2
0
 public function __construct($root = XF_ROOT)
 {
     $startTime = microtime(true);
     $fileDir = $root;
     require $fileDir . '/library/XenForo/Autoloader.php';
     XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
     XenForo_Application::initialize($fileDir . '/library', $fileDir, true, array('resetOutputBuffering' => false));
     XenForo_Application::set('page_start_time', $startTime);
     XenForo_Session::startPublicSession();
 }
예제 #3
0
 public function __construct()
 {
     $startTime = microtime(true);
     $fileDir = XF_ROOT;
     require $fileDir . '/library/XenForo/Autoloader.php';
     XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
     XenForo_Application::initialize($fileDir . '/library', $fileDir);
     XenForo_Application::set('page_start_time', $startTime);
     XenForo_Session::startPublicSession();
 }
예제 #4
0
 public function actionIndex()
 {
     $class = $this->_input->filterSingle('class', XenForo_Input::STRING);
     if ($class) {
         return $this->responseReroute(__CLASS__, 'view');
     }
     $addOns = $this->_getAddOnModel()->getAllAddOns();
     $xenOptions = XenForo_Application::get('options');
     $addOnSelected = '';
     if ($xenOptions->th_models_enableAddOnChooser) {
         $addOnId = $this->_input->filterSingle('addon_id', XenForo_Input::STRING);
         if (!empty($GLOBALS['ThemeHouse_Models_Route_PrefixAdmin_Models']) && !$addOnId) {
             $addOnId = XenForo_Helper_Cookie::getCookie('edit_addon_id');
         }
         if ($addOnId && !empty($addOns[$addOnId])) {
             XenForo_Helper_Cookie::setCookie('edit_addon_id', $addOnId);
             $addOn = $addOns[$addOnId];
             $addOnSelected = $addOnId;
             $this->canonicalizeRequestUrl(XenForo_Link::buildAdminLink('add-ons/models', $addOn));
         } else {
             $this->canonicalizeRequestUrl(XenForo_Link::buildAdminLink('add-ons/models'));
             XenForo_Helper_Cookie::deleteCookie('edit_addon_id');
         }
     }
     $addOns['XenForo'] = array('addon_id' => 'XenForo', 'active' => true, 'title' => 'XenForo');
     $rootPath = XenForo_Autoloader::getInstance()->getRootDir();
     $models = array();
     $modelCount = 0;
     $totalModels = 0;
     foreach ($addOns as $addOnId => $addOn) {
         $modelPath = $rootPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $addOnId) . DIRECTORY_SEPARATOR . 'Model';
         if (!file_exists($modelPath)) {
             continue;
         }
         $directory = new RecursiveDirectoryIterator($modelPath);
         $iterator = new RecursiveIteratorIterator($directory);
         $regex = new RegexIterator($iterator, '/^.+\\.php$/i', RecursiveRegexIterator::GET_MATCH);
         foreach ($regex as $fileinfo) {
             $classPath = str_replace($rootPath, '', $fileinfo[0]);
             $classPath = pathinfo($classPath, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . pathinfo($classPath, PATHINFO_FILENAME);
             $dirs = explode(DIRECTORY_SEPARATOR, $classPath);
             $dirs = array_filter($dirs);
             $className = implode('_', $dirs);
             if (!$xenOptions->th_models_enableAddOnChooser || !$addOnSelected || $addOnId == $addOnSelected) {
                 $models[$addOnId][$className] = array('class' => $className, 'filename' => pathinfo($classPath, PATHINFO_FILENAME));
                 $modelCount++;
             }
             $totalModels++;
         }
     }
     unset($addOns['XenForo']);
     $viewParams = array('addOns' => $addOns, 'addOnSelected' => $addOnSelected, 'models' => $models, 'modelCount' => $modelCount, 'totalModels' => $totalModels);
     return $this->responseView('ThemeHouse_Models_ViewAdmin_Model_List', 'th_model_list_models', $viewParams);
 }
예제 #5
0
파일: Asset.php 프로젝트: billyprice1/bdApi
 public function actionGetSdk()
 {
     $prefix = $this->_input->filterSingle('prefix', XenForo_Input::STRING);
     $prefix = preg_replace('/[^a-zA-Z0-9]/', '', $prefix);
     $sdkPath = XenForo_Autoloader::getInstance()->getRootDir() . '/../js/bdApi/full/sdk.js';
     $sdk = file_get_contents($sdkPath);
     $sdk = str_replace('{prefix}', $prefix, $sdk);
     $sdk = str_replace('{data_uri}', XenForo_Link::buildPublicLink('canonical:misc/api-data'), $sdk);
     $sdk = str_replace('{request_uri}', bdApi_Data_Helper_Core::safeBuildApiLink('index'), $sdk);
     header('Content-Type: application/x-javascript; charset=utf-8');
     header('Cache-Control: public, max-age=31536000');
     header(sprintf('Last-Modified: %s', gmstrftime("%a, %d %b %Y %T %Z", filemtime($sdkPath))));
     die($sdk);
 }
예제 #6
0
 public static function start()
 {
     global $site_ways;
     if (class_exists('XenForo_Autoloader')) {
         return;
     }
     if (empty($site_ways['main_cms'])) {
         exit('[MCMS] Не проинициализирован путь до дирректории Xenforo, проверьте опцию $site_ways[\'main_cms\'] в настройках скрипта авторизации.');
     }
     if (!file_exists($site_ways['main_cms'] . 'library/XenForo/Autoloader.php')) {
         exit('[MCMS] Файл "' . $site_ways['main_cms'] . 'library/XenForo/Autoloader.php" отсутствует. Путь до дирректории Xenforo указан не верно, проверьте опцию $site_ways[\'main_cms\'] в настройках скрипта авторизации.');
     }
     require $site_ways['main_cms'] . '/library/XenForo/Autoloader.php';
     XenForo_Autoloader::getInstance()->setupAutoloader($site_ways['main_cms'] . 'library');
     XenForo_Application::initialize($site_ways['main_cms'] . 'library', $site_ways['main_cms']);
     XenForo_Application::set('page_start_time', microtime(true));
 }
예제 #7
0
 /**
  * @param $controllerResponse
  * @param $controllerName
  * @param $action
  */
 protected function _postDispatch($controllerResponse, $controllerName, $action)
 {
     parent::_postDispatch($controllerResponse, $controllerName, $action);
     if ($controllerResponse instanceof XenForo_ControllerResponse_View) {
         if (!XenForo_Autoloader::getInstance()->autoload('SimplePortal_BrandingFree')) {
             $controllerResponse->params['show_portal_branding'] = true;
         }
         $portalContainer = $this->getPortalConfig();
         if (isset($portalContainer->container)) {
             $controllerResponse->containerParams = array('containerTemplate' => $portalContainer->container);
         }
         if (SimplePortal_Static::option('defaultSidebar')) {
             $viewParams = $this->_getDefaultSidebarParams();
             $controllerResponse->params += $viewParams;
         }
     }
 }
예제 #8
0
파일: Import.php 프로젝트: Sywooch/forums
 /**
  * Fetches a list of available importers
  *
  * @return array
  */
 public function getImporterList()
 {
     $importerDir = XenForo_Autoloader::getInstance()->getRootDir() . '/XenForo/Importer';
     $importers = array();
     foreach (glob($importerDir . '/*.php') as $importerFile) {
         $key = substr(basename($importerFile), 0, -4);
         if ($key == 'Abstract') {
             continue;
         }
         $importers[$key] = $this->getImporterName($key);
     }
     foreach (self::$extraImporters as $extra) {
         $importers[$extra] = $this->getImporterName($extra);
     }
     natcasesort($importers);
     return $importers;
 }
예제 #9
0
 public function __construct()
 {
     $startTime = microtime(true);
     $xf_path = Yii::getPathOfAlias('webroot') . '/forum';
     Yii::registerAutoloader(array('XenforeLoader', 'autoload'), true);
     XenForo_Autoloader::getInstance()->setupAutoloader($xf_path . '/library');
     XenForo_Application::initialize($xf_path . '/library', $xf_path);
     XenForo_Application::set('page_start_time', $startTime);
     XenForo_Application::disablePhpErrorHandler();
     error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE ^ E_WARNING);
     $dependencies = new XenForo_Dependencies_Public();
     $dependencies->preLoadData();
     XenForo_Session::startPublicSession();
     $this->visitor = XenForo_Visitor::getInstance();
     /*$fc = new XenForo_FrontController(new XenForo_Dependencies_Public());
       ob_start();
       $fc->run();
       $content = ob_get_clean();*/
 }
예제 #10
0
 /**
  * Uses the XenForo_Autoloader to initialize and startPublicSession to get
  * and instance of the Visitor, if there is one. 
  *
  * @return int
  */
 function authenticateSession()
 {
     /**
      * Get the xenForo Autoloader
      */
     if (is_dir($this->fileDir)) {
         require $this->fileDir . '/library/XenForo/Autoloader.php';
         XenForo_Autoloader::getInstance()->setupAutoloader($this->fileDir . '/library');
         /**
          * initialize
          */
         XenForo_Application::initialize($this->fileDir . '/library', $this->fileDir);
         XenForo_Session::startPublicSession();
         $this->xfUser = XenForo_Visitor::getInstance();
         return $this->xfUser->getUserId();
     }
     die('no path');
     // TODO: CI error log
     return false;
 }
예제 #11
0
 protected function _preSave()
 {
     $class = $this->get('route_class');
     if (!XenForo_Application::autoload($class)) {
         $filename = XenForo_Autoloader::getInstance()->getRootDir() . DIRECTORY_SEPARATOR . str_replace("_", DIRECTORY_SEPARATOR, $class) . ".php";
         if (!file_exists(dirname($filename))) {
             XenForo_Helper_File::createDirectory(dirname($filename));
         }
         $options = array('title_plural' => str_replace('-', ' ', $this->get('original_prefix')));
         $phpFile = null;
         switch ($this->get('route_type')) {
             case 'public':
                 $phpFile = new ThemeHouse_RoutePrefixes_PhpFile_Route_Prefix($class, $options);
                 break;
             case 'admin':
                 $phpFile = new ThemeHouse_RoutePrefixes_PhpFile_Route_PrefixAdmin($class, $options);
                 break;
         }
         if (!is_null($phpFile)) {
             $phpFile->export(true);
         }
     }
     return parent::_preSave();
 }
예제 #12
0
 /**
  * Helper method to autoload a class. Could simply call the autoloader directly
  * but this method is recommended to reduce dependencies.
  *
  * @param string $class Class to load
  *
  * @return boolean
  */
 public static function autoload($class)
 {
     return XenForo_Autoloader::getInstance()->autoload($class);
 }
예제 #13
0
 * 
 * This file will hold all code and functions for hooking the theme in with XF
 */
//******************************************************************************
// Pull instantiate and pull the template from the Xenforo system
//******************************************************************************
if (!is_admin()) {
    $XenDynamic_container = true;
    $startTime = microtime(true);
    $XenDynamic_indexFile = "../../../.." . getThemeOption("xenforo_path");
    $fileDir = dirname(__FILE__) . "/{$XenDynamic_indexFile}";
    //    $fileDir = ABSPATH . getThemeOption("xenforo_path");
    //	$fileDir = dirname(__FILE__) . "/../../../.." . getThemeOption("xenforo_path");
    if (!class_exists("XenForo_Autoloader")) {
        require $fileDir . '/library/XenForo/Autoloader.php';
        XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
        XenForo_Application::initialize($fileDir . '/library', $fileDir);
        XenForo_Application::set('page_start_time', $startTime);
        XenForo_Application::disablePhpErrorHandler();
        error_reporting(E_ALL ^ E_NOTICE ^ E_USER_NOTICE ^ E_WARNING);
    }
    ob_start();
    $XenDynamic_fc = new RCBD_XenDynamic_FrontController(new XenForo_Dependencies_Public());
    $xenforoOutput = $XenDynamic_fc->runXenDynamic(ob_get_clean());
    global $templateParts;
    $templateParts = getTemplateParts($xenforoOutput, getThemeOption("xenforo_path"));
}
//******************************************************************************
// This function takes the raw buffer from Xenforo and breaks it into the header
// and the rest of the file it also does some jquery replacements for elements
// that need to be changed on all wordpress templates.
예제 #14
0
            continue;
        }
        $filePath = $HELPER_DIR . '/' . $file;
        if (file_exists($filePath) and strtolower(substr($file, -4)) == '.php') {
            $HELPERS[substr($file, 0, -4)] = $filePath;
        }
    }
    closedir($dh);
}
// load XenForo
@(include $PWD . '/library/XenForo/Autoloader.php');
if (!class_exists('XenForo_Autoloader')) {
    echo "Could not detect XenForo\n";
    exit(-1);
}
XenForo_Autoloader::getInstance()->setupAutoloader($PWD . '/library');
XenForo_Application::initialize($PWD . '/library', $PWD);
// load our functions
@(include $DIR . '/helpers_includes/common.php');
if (!class_exists('Helper_Common')) {
    echo "Corrupted script\n";
    exit(-1);
}
function readline_completion_impl($string, $index)
{
    $readline_info = readline_info();
    $line = substr($readline_info['line_buffer'], 0, $readline_info['end']);
    $parts = Helper_Common::parseCommand($line);
    $candidates = array();
    if (empty($parts)) {
        // no input yet, just return list of helper functions
예제 #15
0
파일: 20150107.php 프로젝트: Sywooch/forums
 /**
  * Gets the autoloader's root directory.
  *
  * @return string
  */
 public function getRootDir()
 {
     return XenForo_Autoloader::getInstance()->getRootDir();
 }
예제 #16
0
<?php

$startTime = microtime(true);
$fileDir = dirname(__FILE__);
$rootPath = realpath($fileDir . '/..');
chdir($rootPath);
require $rootPath . '/library/XenForo/Autoloader.php';
XenForo_Autoloader::getInstance()->setupAutoloader($rootPath . '/library');
XenForo_Application::initialize($rootPath . '/library', $rootPath, false);
XenForo_Application::set('page_start_time', $startTime);
XenForo_Phrase::setPhrases(require $fileDir . '/language_en.php');
XenForo_Template_Install::setFilePath($fileDir . '/templates');
$fc = new XenForo_FrontController(new XenForo_Dependencies_Install());
$fc->run();
예제 #17
0
 public function getCliCommand()
 {
     $rootDir = XenForo_Autoloader::getInstance()->getRootDir();
     $filePath = str_replace('/', DIRECTORY_SEPARATOR, $rootDir . '/XenForo/Install/run-upgrade.php');
     $filePath = @escapeshellarg($filePath);
     if (!$filePath) {
         // I've seen servers disable this function...
         return false;
     }
     return 'php ' . $filePath;
 }
    public function run()
    {
        $allowObjects = false;
        if (isset(self::$_data['codeEventListeners']['load_class_model'])) {
            foreach (self::$_data['codeEventListeners']['load_class_model'] as $codeEventListener) {
                if ($codeEventListener[0] == "ThemeHouse_Objects_Listener_LoadClassModel") {
                    $allowObjects = true;
                    break;
                }
            }
        }
        if ($allowObjects) {
            /* @var $classModel ThemeHouse_Objects_Model_Class */
            $classModel = XenForo_Model::create('ThemeHouse_Objects_Model_Class');
            $classes = $classModel->getAllClasses();
            if (self::$_dependencies instanceof XenForo_Dependencies_Public) {
                $routesPublic = self::$_data['routesPublic'];
            }
            foreach ($classes as $classId => $class) {
                $className = str_replace(" ", "", ucwords(str_replace("_", " ", $classId)));
                // TODO
                XenForo_Model::create('ThemeHouse_Objects_Model_Object');
                if (file_exists(XenForo_Autoloader::getInstance()->autoloaderClassToFile($class['addon_id'] . '_Model_' . $className))) {
                    eval('class XFCP_' . $class['addon_id'] . '_Model_' . $className . ' extends ThemeHouse_ObjectFields_Extend_ThemeHouse_Objects_Model_Object {}');
                } else {
                    eval('class ' . $class['addon_id'] . '_Model_' . $className . ' extends ThemeHouse_ObjectFields_Extend_ThemeHouse_Objects_Model_Object {}');
                }
                XenForo_DataWriter::create('ThemeHouse_Objects_DataWriter_Object');
                if (file_exists(XenForo_Autoloader::getInstance()->autoloaderClassToFile($class['addon_id'] . '_DataWriter_' . $className))) {
                    eval('class XFCP_ThemeHouse_' . $class['addon_id'] . '_DataWriter_' . $className . ' extends ThemeHouse_ObjectFields_DataWriter_Object
{
    protected $_objectCustomFields = array();

    public function __construct($errorHandler = self::ERROR_ARRAY, array $inject = null)
	{
    	parent::__construct($errorHandler, $inject);

    	$this->setExtraData(\'forceSet\', true);
    	$this->set(\'class_id\', \'' . $classId . '\');
    	$this->setExtraData(\'forceSet\', false);
    }

    protected function _getFields()
	{
		$fields = parent::_getFields();

		$fields[\'xf_object\'][\'class_id\'] = array(\'type\' => self::TYPE_STRING, \'default\' => \'' . $classId . '\');

		return $fields;
	}

    public function get($field, $tableName = "")
   	{
    	if ($field != "custom_fields")
    	{
    		$customFields = $this->get("custom_fields");
    		if ($customFields)
    		{
    			$customFields = unserialize($customFields);

		    	$fields = $this->_getObjectFieldDefinitions();
    			if (isset($fields[$field]))
    			{
    				if (isset($this->_objectCustomFields[$field]))
    				{
    					return $this->_objectCustomFields[$field];
    				}
		   			else if (isset($customFields[$field]))
	    			{
    					return $customFields[$field];
					}
    			}
    		}
    	}
    	return parent::get($field, $tableName);
	}

    public function set($field, $value, $tableName = \'\', array $options = null)
   	{
	   	$fields = $this->_getObjectFieldDefinitions();
	   	if (isset($fields[$field]) && !$this->getExtraData(\'forceSet\'))
   		{
    		$this->_objectCustomFields[$field] = $value;
       		return true;
		}
    	return parent::set($field, $value, $tableName, $options);
	}

    public function preSave()
    {
    	$this->setCustomFields($this->_objectCustomFields);
    	parent::preSave();
   	}
}');
                } else {
                    eval('class ThemeHouse_' . $class['addon_id'] . '_DataWriter_' . $className . ' extends ThemeHouse_ObjectFields_Extend_ThemeHouse_Objects_DataWriter_Object
{
    protected $_objectCustomFields = array();

    public function __construct($errorHandler = self::ERROR_ARRAY, array $inject = null)
	{
    	parent::__construct($errorHandler, $inject);

    	$this->setExtraData(\'forceSet\', true);
    	$this->set(\'class_id\', \'' . $classId . '\');
    	$this->setExtraData(\'forceSet\', false);
    }

    protected function _getFields()
	{
		$fields = parent::_getFields();

		$fields[\'xf_object\'][\'class_id\'] = array(\'type\' => self::TYPE_STRING, \'default\' => \'' . $classId . '\');

		return $fields;
	}

    public function get($field, $tableName = "")
   	{
    	if ($field != "custom_fields")
    	{
    		$customFields = $this->get("custom_fields");
    		if ($customFields)
    		{
    			$customFields = unserialize($customFields);

		    	$fields = $this->_getObjectFieldDefinitions();
    			if (isset($fields[$field]))
    			{
    				if (isset($this->_objectCustomFields[$field]))
    				{
    					return $this->_objectCustomFields[$field];
    				}
		   			else if (isset($customFields[$field]))
	    			{
    					return $customFields[$field];
					}
    			}
    		}
    	}
    	return parent::get($field, $tableName);
	}

    public function set($field, $value, $tableName = \'\', array $options = null)
   	{
	   	$fields = $this->_getObjectFieldDefinitions();
	   	if (isset($fields[$field]) && !$this->getExtraData(\'forceSet\'))
   		{
    		$this->_objectCustomFields[$field] = $value;
       		return true;
		}
    	return parent::set($field, $value, $tableName, $options);
	}

    public function preSave()
    {
    	$this->setCustomFields($this->_objectCustomFields);
    	parent::preSave();
    }
}');
                }
                $routePrefix = str_replace("_", "-", $classId) . 's';
                if (isset($routesPublic) && !isset($routesPublic[$routePrefix])) {
                    $routesPublic[$routePrefix] = array('build_link' => 'all', 'route_class' => 'ThemeHouse_Objects_Route_Prefix_Objects');
                }
            }
            if (isset($routesPublic)) {
                XenForo_Link::setHandlerInfoForGroup('public', $routesPublic);
            }
        }
        $cacheRebuilders = array('CustomFields' => 'ThemeHouse_ObjectFields_CacheRebuilder_CustomFields');
        $this->addCacheRebuilders($cacheRebuilders);
    }
예제 #19
0
 public function actionAdd()
 {
     $addOnId = $this->_input->filterSingle('addon_id', XenForo_Input::STRING);
     if (!$addOnId) {
         $addOnModel = $this->_getAddOnModel();
         $viewParams = array('addOnOptions' => $addOnModel->getAddOnOptionsListIfAvailable());
         return $this->responseView('ThemeHouse_Controllers_ViewAdmin_ControllerAdmin_Add_ChooseAddOn', 'th_controller_admin_choose_addon_controllers', $viewParams);
     }
     $dataWriter = $this->_input->filterSingle('datawriter', XenForo_Input::STRING);
     if (!$dataWriter) {
         $dataWriters = array();
         $rootPath = XenForo_Autoloader::getInstance()->getRootDir();
         $dataWriterPath = $rootPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $addOnId) . DIRECTORY_SEPARATOR . 'DataWriter';
         if (!file_exists($dataWriterPath)) {
             return $this->responseError(new XenForo_Phrase('th_no_datawriters_in_this_addon_controller'));
         }
         $directory = new RecursiveDirectoryIterator($dataWriterPath);
         $iterator = new RecursiveIteratorIterator($directory);
         $regex = new RegexIterator($iterator, '/^.+\\.php$/i', RecursiveRegexIterator::GET_MATCH);
         foreach ($regex as $fileinfo) {
             $classPath = str_replace($rootPath, '', $fileinfo[0]);
             $classPath = pathinfo($classPath, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . pathinfo($classPath, PATHINFO_FILENAME);
             $dirs = explode(DIRECTORY_SEPARATOR, $classPath);
             $dirs = array_filter($dirs);
             $className = implode('_', $dirs);
             $dataWriters[$className] = $className;
         }
         $viewParams = array('dataWriters' => $dataWriters, 'addOnSelected' => $addOnId);
         return $this->responseView('ThemeHouse_Controllers_ViewAdmin_ControllerAdmin_Add_ChooseDataWriter', 'th_controller_admin_choose_dw_controllers', $viewParams);
     }
     $dataWriterClassName = $dataWriter;
     if (substr($dataWriterClassName, 0, strlen($addOnId . '_DataWriter_')) != $addOnId . '_DataWriter_') {
         return $this->responseNoPermission();
     }
     $class = $addOnId . '_ControllerAdmin_' . substr($dataWriterClassName, strlen($addOnId . '_DataWriter_'));
     $name = substr(strrchr($dataWriter, '_'), 1);
     $dataWriter = XenForo_DataWriter::create($dataWriter);
     if (!$dataWriter || !$dataWriter instanceof XenForo_DataWriter) {
         return $this->responseNoPermission();
     }
     $fields = $dataWriter->getFields();
     $selectedFields = array();
     $titleField = '';
     foreach ($fields as $table => $tableFields) {
         foreach ($tableFields as $fieldId => $field) {
             $titleField = $fieldId;
             if (empty($field['autoIncrement'])) {
                 $selectedFields[$table][$fieldId] = 1;
                 break 2;
             }
         }
     }
     $dataWriterReflectionClass = new ThemeHouse_Reflection_Class(get_class($dataWriter));
     $getModelMethod = '_get' . $name . 'Model';
     /* @var $reflectionMethod ThemeHouse_Reflection_Method */
     $dataWriterReflectionMethod = $dataWriterReflectionClass->getMethod($getModelMethod, 'ThemeHouse_Reflection_Method');
     $modelClassName = $dataWriterReflectionMethod->getReturnTag();
     $model = XenForo_Model::create($modelClassName);
     if (!$model || !$model instanceof XenForo_Model) {
         return $this->responseNoPermission();
     }
     $modelReflectionClass = new ThemeHouse_Controllers_Reflection_Class_Model(get_class($model));
     $pluralName = $modelReflectionClass->getPluralName();
     $routePrefix = ThemeHouse_Controllers_Helper_RoutePrefix::camelCaseToHyphenCase($pluralName);
     $method = $modelReflectionClass->findGetAllMethod($pluralName, false);
     $viewParams = array('dataWriter' => $dataWriterClassName, 'model' => $modelClassName, 'addOnSelected' => $addOnId, 'method' => $method, 'routePrefix' => $routePrefix, 'fields' => $fields, 'selectedFields' => $selectedFields, 'titleField' => $titleField, 'class' => $class);
     return $this->responseView('ThemeHouse_Controllers_ViewAdmin_ControllerAdmin_Add', 'th_controller_admin_add_controllers', $viewParams);
 }
예제 #20
0
파일: custom.php 프로젝트: Sywooch/forums
<?php

/*
 * @package AJAX_Chat
 * @author Sebastian Tschan
 * @copyright (c) Sebastian Tschan
 * @license GNU Affero General Public License
 * @link https://blueimp.net/ajax/
 */
// Include custom libraries and initialization code here
// How to use XenForo Objects: Once initialized the below you can use XenForo objects
define('XF_ROOT', AJAX_CHAT_PATH . '../');
define('TIMENOW', time());
define('SESSION_BYPASS', false);
// if true: logged in user info and sessions are not needed
require_once XF_ROOT . '/library/XenForo/Autoloader.php';
XenForo_Autoloader::getInstance()->setupAutoloader(XF_ROOT . '/library');
XenForo_Application::initialize(XF_ROOT . '/library', XF_ROOT);
XenForo_Application::set('page_start_time', TIMENOW);
XenForo_Application::disablePhpErrorHandler();
// Loads class dependencies, initilizing XF code events listeners.
$dependencies = new XenForo_Dependencies_Public();
$dependencies->preLoadData();
XenForo_Session::startPublicSession();
error_reporting(E_ALL & ~E_NOTICE);
// Turn off the strict error reporting.
예제 #21
0
<?php

/**
 * Helper Brivium Addon for EventListener.
 *
 * @package Brivium_BriviumHelper
 * Version 1.0.0
 */
$helperDir = XenForo_Autoloader::getInstance()->getRootDir() . '/Brivium/BriviumHelper/';
$helperVersion = 0;
if (is_dir($helperDir)) {
    if ($dh = opendir($helperDir)) {
        while (($folder = readdir($dh)) !== false) {
            if ('.' == $folder || '..' == $folder || filetype($helperDir . $folder) != 'dir') {
                continue;
            }
            if (intval($folder) > $helperVersion) {
                $helperVersion = intval($folder);
            }
        }
        closedir($dh);
    }
}
require_once $helperDir . $helperVersion . '/EventListeners.php';
예제 #22
0
 /**
  *
  * @param string $filename
  * @param boolean $autoload
  * @return number
  */
 protected function _getLibraryListenerFileVersion($filename, $autoload = true)
 {
     $rootDir = XenForo_Autoloader::getInstance()->getRootDir();
     $version = 0;
     $handle = opendir($rootDir . '/Waindigo/Listener/' . $filename);
     if ($handle) {
         while (false !== ($entry = readdir($handle))) {
             if (intval($entry) > $version) {
                 $version = intval($entry);
             }
         }
         if ($autoload) {
             require_once $rootDir . '/Waindigo/Listener/' . $filename . '/' . $version . '.php';
         }
     }
     return $version;
 }
예제 #23
0
파일: api.php 프로젝트: pritcham/XenAPI
 /**
  * Default consturctor, instalizes XenForo classes and models.
  */
 public function __construct()
 {
     $this->xfDir = dirname(__FILE__);
     require_once $this->xfDir . '/library/XenForo/Autoloader.php';
     XenForo_Autoloader::getInstance()->setupAutoloader($this->xfDir . '/library');
     XenForo_Application::initialize($this->xfDir . '/library', $this->xfDir);
     XenForo_Application::set('page_start_time', microtime(TRUE));
     $deps = new XenForo_Dependencies_Public();
     $deps->preLoadData();
     // Disable XenForo's PHP error handler.
     XenForo_Application::disablePhpErrorHandler();
     // Enable error logging for PHP.
     error_reporting(E_ALL & ~E_NOTICE);
     $this->models = new Models();
     // TODO: Don't create models on init, only create them if they're being used (see Models::checkModel($model_name, $model)).
     $this->getModels()->setUserModel(XenForo_Model::create('XenForo_Model_User'));
     $this->getModels()->setAlertModel(XenForo_Model::create('XenForo_Model_Alert'));
     $this->getModels()->setUserFieldModel(XenForo_Model::create('XenForo_Model_UserField'));
     $this->getModels()->setAvatarModel(XenForo_Model::create('XenForo_Model_Avatar'));
     $this->getModels()->setModel('addon', XenForo_Model::create('XenForo_Model_AddOn'));
     $this->getModels()->setModel('database', XenForo_Application::get('db'));
     if ($this->hasAddon('XenResource') && $this->hasModel('XenResource_Model_Resource')) {
         $this->getModels()->setModel('resource', XenForo_Model::create('XenResource_Model_Resource'));
     }
 }
예제 #24
0
<?php

header("Content-Type: text/plain; charset=UTF-8");
// Verify login and password
$login = $_GET['login'];
$password = $_GET['password'];
if (empty($login) || empty($password)) {
    exit('Empty login or password');
}
// Load XenForo core
$dir = dirname(__FILE__);
$libraryDir = $dir . '/library';
require_once $dir . '/library/XenForo/Autoloader.php';
XenForo_Autoloader::getInstance()->setupAutoloader($libraryDir);
XenForo_Application::initialize($libraryDir, $dir);
XenForo_Application::set('page_start_time', microtime(true));
$db = XenForo_Application::get('db');
// Resolve user_id by login
$result = $db->fetchRow('SELECT user_id, username FROM xf_user WHERE username='******' OR email=' . $db->quote($login));
if (!count($result)) {
    exit('Incorrect login');
}
$user_id = $result['user_id'];
$username = $result['username'];
// Get user data
$result = $db->fetchCol('SELECT data FROM xf_user_authenticate WHERE user_id=' . $db->quote($user_id));
if (!count($result)) {
    exit('Unable to get user data: ' . $user_id);
}
$data = $result[0];
// Select authentication core
예제 #25
0
<?php

$rootDir = XenForo_Autoloader::getInstance()->getRootDir();
$version = 0;
if ($handle = opendir($rootDir . '/ThemeHouse/Listener/Template')) {
    while (false !== ($entry = readdir($handle))) {
        if (intval($entry) > $version) {
            $version = intval($entry);
        }
    }
}
require_once $rootDir . '/ThemeHouse/Listener/Template/' . $version . '.php';
예제 #26
0
 private static function _updateAddOnFiles($addOnId, $tempFile)
 {
     $tempDir = $tempFile . '_extracted';
     XenForo_Helper_File::createDirectory($tempDir, false);
     XenForo_Helper_File::makeWritableByFtpUser($tempDir);
     $decompress = new Zend_Filter_Decompress(array('adapter' => 'Zip', 'options' => array('target' => $tempDir)));
     if (!$decompress->filter($tempFile)) {
         throw new XenForo_Exception('Unable to extract add-on package.', true);
     }
     $uploadDir = sprintf('%s/upload', $tempDir);
     if (!is_dir($uploadDir)) {
         throw new XenForo_Exception('Unsupported add-on package (no "upload" directory found).', true);
     }
     $xfDir = dirname(XenForo_Autoloader::getInstance()->getRootDir());
     $files = self::_verifyAddOnFiles($uploadDir, $xfDir);
     $xmlPath = self::_findXmlPath($addOnId, $tempDir, $xfDir, $files);
     self::_moveAddOnFiles($uploadDir, $xfDir, $files);
     return $xmlPath;
 }
예제 #27
0
 public function export($overwrite = false)
 {
     if (!$this->_addOnId) {
         throw new XenForo_Exception('Please specify an add-on id.');
     }
     $filename = str_replace('_', '/', $this->_className) . '.php';
     $existingContents = '';
     $fullFilename = XenForo_Autoloader::getInstance()->getRootDir() . '/' . $filename;
     if (file_exists($fullFilename)) {
         $existingContents = file_get_contents($fullFilename);
         $existingContentsArray = preg_split('/(\\r\\n|\\n|\\r)/', $existingContents);
         foreach ($existingContentsArray as $key => $value) {
             if (rtrim($value) != $value) {
                 $existingContentsArray[$key] = rtrim($value);
             }
         }
         $existingContents = implode("\n", $existingContentsArray);
         $existingContents = str_replace("\t", '	', $existingContents);
         file_put_contents($fullFilename, $existingContents);
         $existingPhpFile = self::createFromContents($this->_className, $existingContents);
     } else {
         if (!file_exists(dirname($fullFilename))) {
             XenForo_Helper_File::createDirectory(dirname($fullFilename));
         }
         $existingPhpFile = self::createFromContents($this->_className);
     }
     $contents = $this->getHeader();
     $this->mergeConstants($existingPhpFile->getConstants());
     if (isset($this->_constants) && !empty($this->_constants)) {
         foreach ($this->_constants as $constantName => $constant) {
             $contents .= $constant->getPhpDocAsString();
             $contents .= "\n\t";
             $contents .= 'const ' . $constant->getConstantName() . ' = ' . $constant->getValue() . ';' . "\n";
         }
     }
     $this->mergeVariables($existingPhpFile->getVariables());
     if (isset($this->_variables) && !empty($this->_variables)) {
         /* @var $variable ThemeHouse_PhpFile_Variable */
         foreach ($this->_variables as $variableName => $variable) {
             $contents .= $variable->getPhpDocAsString();
             $contents .= "\n\t";
             $contents .= $variable->getFullSignatureAsString() . ' = ' . $variable->getValue() . ';' . "\n";
         }
     }
     $this->mergeFunctions($existingPhpFile->getFunctions());
     if (isset($this->_functions) && !empty($this->_functions)) {
         /* @var $function ThemeHouse_PhpFile_Function */
         foreach ($this->_functions as $functionName => $function) {
             $contents .= $function->getPhpDocAsString();
             $contents .= "\n\t";
             $contents .= $function->getFullSignatureAsString();
             $contents .= "\n\t{";
             $contents .= $function->getBodyAsString();
             $contents .= "\n\t}\n";
         }
     }
     $contents .= "}";
     $export = XenForo_CodeEvent::fire('phpfile_export_th', array(&$filename, &$contents, $existingContents, $overwrite, $this->_addOnId));
     if ($export) {
         if (!file_exists(dirname(XenForo_AutoLoader::getInstance()->getRootDir() . '/' . $filename))) {
             mkdir(dirname(XenForo_AutoLoader::getInstance()->getRootDir() . '/' . $filename), 0, true);
         }
         file_put_contents(XenForo_AutoLoader::getInstance()->getRootDir() . '/' . $filename, $contents);
     }
 }
예제 #28
0
 public static function fileExport(array $addOn, DevHelper_Config_Base $config, $exportPath)
 {
     $list = array();
     $classNameByAddOnId = self::getClassName($addOn['addon_id'], false, $config);
     $list['library'] = self::getClassNameInDirectory(XenForo_Autoloader::getInstance()->getRootDir(), $classNameByAddOnId, true);
     if (empty($list['library'])) {
         throw new XenForo_Exception(sprintf('`library` not found for %s', $addOn['addon_id']));
     }
     $jsPath = self::getClassNameInDirectory(realpath(XenForo_Autoloader::getInstance()->getRootDir() . '/../js'), $classNameByAddOnId, true);
     if (!empty($jsPath)) {
         if (is_dir($jsPath)) {
             $list['js'] = $jsPath;
         }
     }
     $stylesDefaultPath = self::getClassNameInDirectory(realpath(XenForo_Autoloader::getInstance()->getRootDir() . '/../styles/default'), $classNameByAddOnId, true);
     if (!empty($stylesDefaultPath)) {
         if (is_dir($stylesDefaultPath)) {
             $list['styles_default'] = $stylesDefaultPath;
         }
     }
     $exportIncludes = $config->getExportIncludes();
     foreach ($exportIncludes as $exportInclude) {
         $exportIncludePath = XenForo_Autoloader::getInstance()->getRootDir() . '/../' . $exportInclude;
         if (file_exists($exportIncludePath)) {
             $list[$exportInclude] = $exportIncludePath;
         }
     }
     // save add-on XML
     $xmlPath = self::getAddOnXmlPath($addOn, null, $config);
     /** @var XenForo_Model_AddOn $addOnModel */
     $addOnModel = XenForo_Model::create('XenForo_Model_AddOn');
     $addOnModel->getAddOnXml($addOn)->save($xmlPath);
     echo "Exported       {$xmlPath} ({$addOn['version_string']}/{$addOn['version_id']})\n";
     DevHelper_Helper_Phrase::parseXmlForPhraseTracking($xmlPath);
     $exportAddOns = $config->getExportAddOns();
     foreach ($exportAddOns as $exportAddOnId) {
         $exportAddOn = $addOnModel->getAddOnById($exportAddOnId);
         if (empty($exportAddOn)) {
             die(sprintf("Could not find add-on %s\n", $exportAddOnId));
         }
         $exportAddOnPath = self::getAddOnXmlPath($addOn, $exportAddOn, $config);
         $addOnModel->getAddOnXml($exportAddOn)->save($exportAddOnPath);
         echo "Exported       {$exportAddOnPath} ({$exportAddOn['version_string']}/{$exportAddOn['version_id']})\n";
     }
     $exportStyles = $config->getExportStyles();
     if (!empty($exportStyles)) {
         /** @var XenForo_Model_Style $styleModel */
         $styleModel = $addOnModel->getModelFromCache('XenForo_Model_Style');
         $styles = $styleModel->getAllStyles();
         $exportedStyleCount = 0;
         foreach ($styles as $style) {
             if (in_array($style['title'], $exportStyles, true)) {
                 $stylePath = self::getStyleXmlPath($addOn, $style, $config);
                 $styleModel->getStyleXml($style)->save($stylePath);
                 echo "Exported       {$stylePath}\n";
                 $exportedStyleCount++;
             }
         }
         if ($exportedStyleCount < count($exportStyles)) {
             die("Not all export styles could be found...\n");
         }
     }
     // generate hashes
     self::generateHashesFile($addOn, $config, $list);
     // check for file_health_check event listener
     /** @var XenForo_Model_CodeEvent $codeEventModel */
     $codeEventModel = XenForo_Model::create('XenForo_Model_CodeEvent');
     $addOnEventListeners = $codeEventModel->getEventListenersByAddOn($addOn['addon_id']);
     $fileHealthCheckFound = false;
     foreach ($addOnEventListeners as $addOnEventListener) {
         if ($addOnEventListener['event_id'] === 'file_health_check') {
             $fileHealthCheckFound = true;
         }
         if (!is_callable(array($addOnEventListener['callback_class'], $addOnEventListener['callback_method']))) {
             die(sprintf("Callback is not callable %s::%s\n", $addOnEventListener['callback_class'], $addOnEventListener['callback_method']));
         }
     }
     if (!$fileHealthCheckFound) {
         // try to generate the file health check event listener ourselves
         if (DevHelper_Generator_Code_Listener::generateFileHealthCheck($addOn, $config)) {
             $fileHealthCheckFound = true;
         }
     }
     if (!$fileHealthCheckFound) {
         die("No `file_health_check` event listener found.\n");
     }
     /** @var XenForo_Application $application */
     $application = XenForo_Application::getInstance();
     $rootPath = realpath($application->getRootDir());
     if (strpos($exportPath, 'upload') === false) {
         $exportPath .= '/upload';
     }
     XenForo_Helper_File::createDirectory($exportPath);
     $exportPath = realpath($exportPath);
     $options = array('extensions' => array('php', 'inc', 'txt', 'xml', 'htm', 'html', 'js', 'css', 'jpg', 'jpeg', 'png', 'gif', 'swf', 'crt', 'pem', 'eot', 'svg', 'ttf', 'woff', 'woff2', 'otf', 'md'), 'filenames_lowercase' => array('license', 'readme', 'copyright', '.htaccess', 'changelog', 'composer.json', 'readme.rdoc', 'version'), 'force' => true, 'addon_id' => $addOn['addon_id'], 'excludes' => array(), 'excludeRegExs' => array());
     $excludes = $config->getExportExcludes();
     foreach ($excludes as $exclude) {
         if (preg_match('/^#.+#$/', $exclude)) {
             $options['excludeRegExs'][] = $exclude;
         } else {
             $options['excludes'][] = $exclude;
         }
     }
     foreach ($list as $type => $entry) {
         self::_fileExport($entry, $exportPath, $rootPath, $options);
     }
     // copy one xml copy to the export directory directory
     $xmlCopyPath = sprintf('%s/%s', dirname($exportPath), basename($xmlPath));
     if (@copy($xmlPath, $xmlCopyPath)) {
         echo "Copied         {$xmlPath} -> {$xmlCopyPath}\n";
     } else {
         echo "Can't cp       {$xmlPath} -> {$xmlCopyPath}\n";
     }
 }
예제 #29
0
 public function actionAdd()
 {
     $addOnId = $this->_input->filterSingle('addon_id', XenForo_Input::STRING);
     if (!$addOnId) {
         $addOnModel = $this->_getAddOnModel();
         $viewParams = array('addOnOptions' => $addOnModel->getAddOnOptionsListIfAvailable());
         return $this->responseView('ThemeHouse_DataWriters_ViewAdmin_DataWriter_Add_ChooseAddOn', 'th_datawriter_choose_addon_datawriters', $viewParams);
     }
     $model = $this->_input->filterSingle('model', XenForo_Input::STRING);
     if (!$model) {
         $models = array();
         $rootPath = XenForo_Autoloader::getInstance()->getRootDir();
         $modelPath = $rootPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $addOnId) . DIRECTORY_SEPARATOR . 'Model';
         if (!file_exists($modelPath)) {
             return $this->responseError(new XenForo_Phrase('th_no_models_in_this_addon_datawriter'));
         }
         $directory = new RecursiveDirectoryIterator($modelPath);
         $iterator = new RecursiveIteratorIterator($directory);
         $regex = new RegexIterator($iterator, '/^.+\\.php$/i', RecursiveRegexIterator::GET_MATCH);
         foreach ($regex as $fileinfo) {
             $classPath = str_replace($rootPath, '', $fileinfo[0]);
             $classPath = pathinfo($classPath, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . pathinfo($classPath, PATHINFO_FILENAME);
             $dirs = explode(DIRECTORY_SEPARATOR, $classPath);
             $dirs = array_filter($dirs);
             $className = implode('_', $dirs);
             $models[$className] = $className;
         }
         $viewParams = array('models' => $models, 'addOnSelected' => $addOnId);
         return $this->responseView('ThemeHouse_DataWriters_ViewAdmin_DataWriter_Add_ChooseModel', 'th_datawriter_choose_model_datawriters', $viewParams);
     }
     $modelClassName = $model;
     if (substr($modelClassName, 0, strlen($addOnId . '_Model_')) != $addOnId . '_Model_') {
         return $this->responseNoPermission();
     }
     $class = $addOnId . '_DataWriter_' . substr($modelClassName, strlen($addOnId . '_Model_'));
     $name = substr(strrchr($model, '_'), 1);
     $model = XenForo_Model::create($model);
     if (!$model || !$model instanceof XenForo_Model) {
         return $this->responseNoPermission();
     }
     $reflectionClass = new ThemeHouse_Reflection_Class(get_class($model));
     $method = 'get' . $name . 'ById';
     $table = 'xf_' . strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name));
     $primaryKey = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $name)) . '_id';
     $primaryKeyType = '';
     $autoIncrement = true;
     $primaryKeyTypes = $this->_getDataWriterHelper()->getDataTypes();
     if ($reflectionClass->hasMethod('get' . $name . 'ById')) {
         /* @var $reflectionMethod ThemeHouse_Reflection_Method */
         $reflectionMethod = $reflectionClass->getMethod($method, 'ThemeHouse_Reflection_Method');
         $body = $reflectionMethod->getBody();
         $pattern = '#\\$this->_getDb\\(\\)->fetchRow\\(\'\\s*SELECT.*FROM\\s+([a-z_]+)\\s+.*WHERE\\s+(?:[a-z_]+.)?([a-z_]+)\\s+#Us';
         preg_match($pattern, $body, $matches);
         if ($matches) {
             $table = $matches[1];
             $primaryKey = $matches[2];
         }
         $parameters = $reflectionMethod->getParameters();
         if (!empty($parameters[0])) {
             try {
                 $primaryKeyType = $parameters[0]->getType();
             } catch (Exception $e) {
             }
         }
     }
     $db = XenForo_Application::getDb();
     $tables = $db->listTables();
     if (in_array($table, $tables)) {
         $columns = $db->fetchAll('DESCRIBE ' . $db->quoteIdentifier($table, true));
         foreach ($columns as $column) {
             if ($column['Key'] == 'PRI') {
                 $primaryKey = $column['Field'];
                 $autoIncrement = $column['Extra'] == 'auto_increment';
             }
         }
         $columns = $db->describeTable($table);
         if ($primaryKey && !empty($columns[$primaryKey])) {
             $primaryKeyType = $columns[$primaryKey]['DATA_TYPE'];
             if (in_array($primaryKeyType, array('char', 'varchar', 'binary', 'varbinary', 'blob', 'tinyblob', 'mediumblob', 'longblob', 'text', 'tinytext', 'mediumtext', 'longtext'))) {
                 $primaryKeyType = 'string';
             } elseif (in_array($primaryKeyType, array('integer', 'int', 'smallint', 'tinyint', 'mediumint', 'bigint'))) {
                 if ($columns[$primaryKey]['UNSIGNED']) {
                     $primaryKeyType = 'uint';
                 } else {
                     $primaryKeyType = 'int';
                 }
             } elseif (in_array($primaryKeyType, array('float', 'double'))) {
                 $primaryKeyType = 'float';
             }
         }
     }
     if (empty($primaryKeyTypes[$primaryKeyType])) {
         $primaryKeyType = 'uint';
     }
     if ($primaryKeyType == 'string') {
         $autoIncrement = false;
     }
     $viewParams = array('model' => $modelClassName, 'addOnSelected' => $addOnId, 'class' => $class, 'method' => $method, 'table' => $table, 'primaryKey' => $primaryKey, 'primaryKeyType' => $primaryKeyType, 'primaryKeyTypes' => $primaryKeyTypes, 'autoIncrement' => $autoIncrement);
     return $this->responseView('ThemeHouse_DataWriters_ViewAdmin_DataWriter_Add', 'th_datawriter_add_datawriters', $viewParams);
 }
예제 #30
0
 public function actionAdd()
 {
     $addOnId = $this->_input->filterSingle('addon_id', XenForo_Input::STRING);
     if (!$addOnId) {
         $addOnModel = $this->_getAddOnModel();
         $viewParams = array('addOnOptions' => $addOnModel->getAddOnOptionsListIfAvailable());
         return $this->responseView('ThemeHouse_Controllers_ViewAdmin_ControllerPublic_Add_ChooseAddOn', 'th_controller_public_choose_addon_controllers', $viewParams);
     }
     $dataWriter = $this->_input->filterSingle('datawriter', XenForo_Input::STRING);
     if (!$dataWriter) {
         $dataWriters = array();
         $rootPath = XenForo_Autoloader::getInstance()->getRootDir();
         $dataWriterPath = $rootPath . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $addOnId) . DIRECTORY_SEPARATOR . 'DataWriter';
         if (!file_exists($dataWriterPath)) {
             return $this->responseError(new XenForo_Phrase('th_no_datawriters_in_this_addon_controller'));
         }
         $directory = new RecursiveDirectoryIterator($dataWriterPath);
         $iterator = new RecursiveIteratorIterator($directory);
         $regex = new RegexIterator($iterator, '/^.+\\.php$/i', RecursiveRegexIterator::GET_MATCH);
         foreach ($regex as $fileinfo) {
             $classPath = str_replace($rootPath, '', $fileinfo[0]);
             $classPath = pathinfo($classPath, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . pathinfo($classPath, PATHINFO_FILENAME);
             $dirs = explode(DIRECTORY_SEPARATOR, $classPath);
             $dirs = array_filter($dirs);
             $className = implode('_', $dirs);
             $dataWriters[$className] = $className;
         }
         $viewParams = array('dataWriters' => $dataWriters, 'addOnSelected' => $addOnId);
         return $this->responseView('ThemeHouse_Controllers_ViewAdmin_ControllerPublic_Add_ChooseDataWriter', 'th_controller_public_choose_datawriter_controllers', $viewParams);
     }
     $dataWriterClassName = $dataWriter;
     if (substr($dataWriterClassName, 0, strlen($addOnId . '_DataWriter_')) != $addOnId . '_DataWriter_') {
         return $this->responseNoPermission();
     }
     $class = $addOnId . '_ControllerPublic_' . substr($dataWriterClassName, strlen($addOnId . '_DataWriter_'));
     $name = substr(strrchr($dataWriter, '_'), 1);
     $dataWriter = XenForo_DataWriter::create($dataWriter);
     if (!$dataWriter || !$dataWriter instanceof XenForo_DataWriter) {
         return $this->responseNoPermission();
     }
     $reflectionClass = new ThemeHouse_Reflection_Class(get_class($dataWriter));
     $viewParams = array('dataWriter' => $dataWriterClassName, 'addOnSelected' => $addOnId, 'class' => $class);
     return $this->responseView('ThemeHouse_Controllers_ViewAdmin_ControllerPublic_Add', 'th_controller_public_add_controllers', $viewParams);
 }