/**
* Returns all available packages.
*
* @param bool $filterInstalled True to only return installed packages
*
* @return Package[]
*/
public function getAvailablePackages($filterInstalled = true)
{
$dh = $this->application->make('helper/file');
$packages = $dh->getDirectoryContents(DIR_PACKAGES);
if ($filterInstalled) {
$handles = self::getInstalledHandles();
// strip out packages we've already installed
$packagesTemp = array();
foreach ($packages as $p) {
if (!in_array($p, $handles)) {
$packagesTemp[] = $p;
}
}
$packages = $packagesTemp;
}
if (count($packages) > 0) {
$packagesTemp = array();
// get package objects from the file system
foreach ($packages as $p) {
if (file_exists(DIR_PACKAGES . '/' . $p . '/' . FILENAME_CONTROLLER)) {
$pkg = $this->getClass($p);
if (!empty($pkg)) {
$packagesTemp[] = $pkg;
}
}
}
$packages = $packagesTemp;
}
return $packages;
}
/**
* Upload Image to Imgur
*
* @param string $image A binary file (path to file), base64 data, or a URL for an image. (up to 10MB)
* @param string $type Image type. Use Mechpave\ImgurClient\Model\ImageModel
* @param string $title The title of the image
* @param string $description The description of the image
* @param string $album The id of the album you want to add the image to. For anonymous albums, {album} should be the deletehash that is returned at creation.
* @param string $name The name of the file
* @throws \UnexpectedValueException
* @return ImageInterface
*/
public function upload($image, $type, $title = null, $description = null, $album = null, $name = null)
{
if ($type == ImageModel::TYPE_FILE) {
//check if file exists and get its contents
if (!file_exists($image)) {
throw new \UnexpectedValueException('Provided file does not exist');
}
$contents = file_get_contents($image);
if (!$contents) {
throw new \UnexpectedValueException('Could not get file contents');
}
$image = $contents;
}
$postData = ['image' => $image, 'type' => $type];
if ($title) {
$postData['title'] = $title;
}
if ($name) {
$postData['name'] = $name;
}
if ($description) {
$postData['description'] = $description;
}
if ($album) {
$postData['album'] = $album;
}
$response = $this->httpClient->post('image', $postData);
$image = $this->imageMapper->buildImage($response->getBody()['data']);
return $image;
}
function doAction($action)
{
$id = $_POST['id'];
$mapFile = "map/" . $id . ".map";
$offlineFile = "map/offline/" . $id . ".js";
switch ($action) {
case "save":
if (!is_dir("map")) {
mkdir("map");
mkdir("map/offline");
}
file_put_contents($mapFile, $_POST['data']);
file_put_contents($offlineFile, "Map.level[" . $id . "] = " . $_POST['data']);
return $_POST['data'];
break;
case "load":
if (!empty($_POST['offlineMode'])) {
return file_get_contents($offlineFile);
}
if (file_exists($mapFile)) {
return file_get_contents($mapFile);
}
echo "Echo file not found: " . $mapFile;
ThrowNotFound();
break;
}
}
/**
* Executes the check itselfs
*
* @return boolean
*/
public function check()
{
$this->isFound = file_exists($this->filename);
$this->isReadable = is_readable($this->filename);
$result = $this->isFound && $this->isReadable;
return $result;
}
/**
* Defined by Zend_Filter_Interface
*
* Decrypts the file $value with the defined settings
*
* @param string $value Full path of file to change
* @return string The filename which has been set, or false when there were errors
*/
public function filter($value)
{
if (!file_exists($value)) {
//require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("File '{$value}' not found");
}
if (!isset($this->_filename)) {
$this->_filename = $value;
}
if (file_exists($this->_filename) and !is_writable($this->_filename)) {
//require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("File '{$this->_filename}' is not writable");
}
$content = file_get_contents($value);
if (!$content) {
//require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("Problem while reading file '{$value}'");
}
$decrypted = parent::filter($content);
$result = file_put_contents($this->_filename, $decrypted);
if (!$result) {
//require_once 'Zend/Filter/Exception.php';
throw new Zend_Filter_Exception("Problem while writing file '{$this->_filename}'");
}
return $this->_filename;
}
function load($tpl_view, $body_view = null, $data = null)
{
if (!is_null($body_view)) {
if (file_exists(APPPATH . 'views/' . $tpl_view . '/' . $body_view)) {
$body_view_path = $tpl_view . '/' . $body_view;
} else {
if (file_exists(APPPATH . 'views/' . $tpl_view . '/' . $body_view . '.php')) {
$body_view_path = $tpl_view . '/' . $body_view . '.php';
} else {
if (file_exists(APPPATH . 'views/' . $body_view)) {
$body_view_path = $body_view;
} else {
if (file_exists(APPPATH . 'views/' . $body_view . '.php')) {
$body_view_path = $body_view . '.php';
} else {
show_error('Unable to load the requested file: ' . $tpl_name . '/' . $view_name . '.php');
}
}
}
}
$body = $this->ci->load->view($body_view_path, $data, TRUE);
if (is_null($data)) {
$data = array('body' => $body);
} else {
if (is_array($data)) {
$data['body'] = $body;
} else {
if (is_object($data)) {
$data->body = $body;
}
}
}
}
$this->ci->load->view('templates/' . $tpl_view, $data);
}
/**
* Load metadata about an HTML document using Aperture.
*
* @param string $htmlFile File on disk containing HTML.
*
* @return array
*/
protected static function getApertureFields($htmlFile)
{
$xmlFile = tempnam('/tmp', 'apt');
$cmd = static::getApertureCommand($htmlFile, $xmlFile, 'filecrawler');
exec($cmd);
// If we failed to process the file, give up now:
if (!file_exists($xmlFile)) {
throw new \Exception('Aperture failed.');
}
// Extract and decode the full text from the XML:
$xml = str_replace(chr(0), ' ', file_get_contents($xmlFile));
@unlink($xmlFile);
preg_match('/<plainTextContent[^>]*>([^<]*)</ms', $xml, $matches);
$final = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
// Extract the title from the XML:
preg_match('/<title[^>]*>([^<]*)</ms', $xml, $matches);
$title = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
// Extract the keywords from the XML:
preg_match_all('/<keyword[^>]*>([^<]*)</ms', $xml, $matches);
$keywords = [];
if (isset($matches[1])) {
foreach ($matches[1] as $current) {
$keywords[] = trim(html_entity_decode($current, ENT_QUOTES, 'UTF-8'));
}
}
// Extract the description from the XML:
preg_match('/<description[^>]*>([^<]*)</ms', $xml, $matches);
$description = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
// Send back the extracted fields:
return ['title' => $title, 'keywords' => $keywords, 'description' => $description, 'fulltext' => $final];
}
function includePeer($path = "general")
{
$_path = _FM_HOME_DIR . DS . 'symbiosis' . DS . _FM_PEER . DS . str_replace('.', DS, $path) . '.php';
if (file_exists($_path)) {
require_once $_path;
}
}
public function __construct(EngineInterface $engine, $proxyPath = null)
{
$this->engine = $engine;
if (file_exists($proxyPath)) {
unlink($this->proxyPath);
}
}
public function get()
{
$id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : exit;
if ($data = $this->db->getby_id($id)) {
if (!($str = S('dbsource_' . $id))) {
if ($data['type'] == 1) {
// 自定义SQL调用
$get_db = Loader::model("get_model");
$sql = $data['data'] . (!empty($data['num']) ? " LIMIT {$data['num']}" : '');
$str = $get_db->query($sql);
} else {
$filepath = APPS_PATH . $data['application'] . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . $data['application'] . '_tag.php';
if (file_exists($filepath)) {
$yun_tag = Loader::lib($data['application'] . ':' . $data['application'] . '_tag');
if (!method_exists($yun_tag, $data['do'])) {
exit;
}
$sql = string2array($data['data']);
$sql['do'] = $data['do'];
$sql['limit'] = $data['num'];
unset($data['num']);
$str = $yun_tag->{$data}['do']($sql);
} else {
exit;
}
}
if ($data['cache']) {
S('tpl_data/dbsource_' . $id, $str, $data['cache']);
}
}
echo $this->_format($data['id'], $str, $data['dis_type']);
}
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$path = $input->getArgument('path');
if (!file_exists($path)) {
$output->writeln("{$path} is not a file or a path");
}
$filePaths = [];
if (is_file($path)) {
$filePaths = [realpath($path)];
} elseif (is_dir($path)) {
$filePaths = array_diff(scandir($path), array('..', '.'));
} else {
$output->writeln("{$path} is not known.");
}
$generator = new StopwordGenerator($filePaths);
if ($input->getArgument('type') === 'json') {
echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
echo json_last_error_msg();
die;
$output->write(json_encode($this->toArray($generator->getStopwords())));
} else {
$stopwords = $generator->getStopwords();
$stdout = fopen('php://stdout', 'w');
echo 'token,freq' . PHP_EOL;
foreach ($stopwords as $token => $freq) {
fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL;
}
fclose($stdout);
}
}
public static function setHistoryFile($file)
{
if (file_exists($file)) {
readline_read_history($file);
}
self::$history_file = $file;
}
public static function prepare_dir($prefix)
{
$config = midcom_baseclasses_components_configuration::get('midcom.helper.filesync', 'config');
$path = $config->get('filesync_path');
if (!file_exists($path)) {
$parent = dirname($path);
if (!is_writable($parent)) {
throw new midcom_error("Directory {$parent} is not writable");
}
if (!mkdir($path)) {
throw new midcom_error("Failed to create directory {$path}. Reason: " . $php_errormsg);
}
}
if (substr($path, -1) != '/') {
$path .= '/';
}
$module_dir = "{$path}{$prefix}";
if (!file_exists($module_dir)) {
if (!is_writable($path)) {
throw new midcom_error("Directory {$path} is not writable");
}
if (!mkdir($module_dir)) {
throw new midcom_error("Failed to create directory {$module_dir}. Reason: " . $php_errormsg);
}
}
return "{$module_dir}/";
}
/**
* Get the URL to uploads_path folder
*
* @param string $path
* @param bool $secure
* @return string
*/
function uploads_path($upload)
{
if (file_exists(public_path() . 'uploads/' . $upload)) {
return 'no image broh';
}
return public_path() . '/uploads/' . ltrim($upload, '/');
}
function __construct()
{
$this->l = \OC::$server->getL10N('lib');
$version = OC_Util::getVersion();
$this->defaultEntity = 'ownCloud';
/* e.g. company name, used for footers and copyright notices */
$this->defaultName = 'ownCloud';
/* short name, used when referring to the software */
$this->defaultTitle = 'ownCloud';
/* can be a longer name, for titles */
$this->defaultBaseUrl = 'https://owncloud.org';
$this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/';
$this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
$this->defaultiTunesAppId = '543672169';
$this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
$this->defaultDocBaseUrl = 'https://doc.owncloud.org';
$this->defaultDocVersion = $version[0] . '.' . $version[1];
// used to generate doc links
$this->defaultSlogan = $this->l->t('web services under your control');
$this->defaultLogoClaim = '';
$this->defaultMailHeaderColor = '#1d2d44';
/* header color of mail notifications */
$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
if (file_exists($themePath)) {
// prevent defaults.php from printing output
ob_start();
require_once $themePath;
ob_end_clean();
if (class_exists('OC_Theme')) {
$this->theme = new OC_Theme();
}
}
}
public function index()
{
$this->load->language('payment/authorizenet_aim');
$data['text_credit_card'] = $this->language->get('text_credit_card');
$data['text_wait'] = $this->language->get('text_wait');
$data['entry_cc_owner'] = $this->language->get('entry_cc_owner');
$data['entry_cc_number'] = $this->language->get('entry_cc_number');
$data['entry_cc_expire_date'] = $this->language->get('entry_cc_expire_date');
$data['entry_cc_cvv2'] = $this->language->get('entry_cc_cvv2');
$data['button_confirm'] = $this->language->get('button_confirm');
$data['months'] = array();
for ($i = 1; $i <= 12; $i++) {
$data['months'][] = array('text' => strftime('%B', mktime(0, 0, 0, $i, 1, 2000)), 'value' => sprintf('%02d', $i));
}
$today = getdate();
$data['year_expire'] = array();
for ($i = $today['year']; $i < $today['year'] + 11; $i++) {
$data['year_expire'][] = array('text' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)), 'value' => strftime('%Y', mktime(0, 0, 0, 1, 1, $i)));
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/authorizenet_aim.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/payment/authorizenet_aim.tpl', $data);
} else {
return $this->load->view('default/template/payment/authorizenet_aim.tpl', $data);
}
}
public function index()
{
$this->load->model('design/layout');
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$this->load->model('catalog/information');
if (isset($this->request->get['route'])) {
$route = (string) $this->request->get['route'];
} else {
$route = 'common/home';
}
$layout_id = 0;
if ($route == 'product/category' && isset($this->request->get['path'])) {
$path = explode('_', (string) $this->request->get['path']);
$layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));
}
if ($route == 'product/product' && isset($this->request->get['product_id'])) {
$layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
}
if ($route == 'information/information' && isset($this->request->get['information_id'])) {
$layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
}
if (!$layout_id) {
$layout_id = $this->model_design_layout->getLayout($route);
}
if (!$layout_id) {
$layout_id = $this->config->get('config_layout_id');
}
$module_data = array();
$this->load->model('setting/extension');
$extensions = $this->model_setting_extension->getExtensions('module');
foreach ($extensions as $extension) {
$modules = $this->config->get($extension['code'] . '_module');
if ($modules) {
foreach ($modules as $module) {
if ($module['layout_id'] == $layout_id && $module['position'] == 'header_top' && $module['status']) {
$module_data[] = array('code' => $extension['code'], 'setting' => $module, 'sort_order' => $module['sort_order']);
}
}
}
}
$sort_order = array();
foreach ($module_data as $key => $value) {
$sort_order[$key] = $value['sort_order'];
}
array_multisort($sort_order, SORT_ASC, $module_data);
$this->data['modules'] = array();
foreach ($module_data as $module) {
$module = $this->getChild('module/' . $module['code'], $module['setting']);
if ($module) {
$this->data['modules'][] = $module;
}
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_top.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/header_top.tpl';
} else {
$this->template = 'default/template/common/header_top.tpl';
}
$this->render();
}
public function indexAction()
{
$container = $this->container;
$conn = $this->get('doctrine')->getConnection();
$dir = $container->getParameter('doctrine_migrations.dir_name');
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
$configuration = new Configuration($conn);
$configuration->setMigrationsNamespace($container->getParameter('doctrine_migrations.namespace'));
$configuration->setMigrationsDirectory($dir);
$configuration->registerMigrationsFromDirectory($dir);
$configuration->setName($container->getParameter('doctrine_migrations.name'));
$configuration->setMigrationsTableName($container->getParameter('doctrine_migrations.table_name'));
$versions = $configuration->getMigrations();
foreach ($versions as $version) {
$migration = $version->getMigration();
if ($migration instanceof ContainerAwareInterface) {
$migration->setContainer($container);
}
}
$migration = new Migration($configuration);
$migrated = $migration->migrate();
// ...
}
/**
* Make sure if user want to replace existing class.
*
* @param string $path
* @param bool $force
*/
protected function makeSure($path, $force)
{
if ($force === false and file_exists($path) and $this->confirm('File already exists, do you want to replace? [y|N]') === false) {
$this->warn('==> Cannot generate command because destination file already exists.');
die(1);
}
}
/**
* 店铺介绍页面
*/
public function jieshao()
{
$id = $_GET['id'];
$M = new ForemanviewModel();
$info = $M->getforemaninfo($id);
if ($info) {
if (empty($info['logo']) || !file_exists("." . $info['logo'])) {
$info['logo'] = "/Public/web/images/nopic_193.jpg";
}
#获取代表作品
$M1 = new CaseModel();
$info[caseinfo] = $M1->getcase($info[zuopin]);
$this->assign("info", $info);
#获取 业主合影
$M2 = new HeyingModel();
$hylist = $M2->getheying($id);
#var_dump($hylist);
$this->assign("hylist", $hylist);
#施工工地
$M3 = new GongdiModel();
$sggdstr = $M3->getsggdstr($id);
$this->assign("sggdstr", $sggdstr);
$sggdlist = $M3->getsggdlist($id);
$this->assign("sggdlist", $sggdlist);
$this->assign("id", $id);
} else {
$this->error("该工长已经被禁止,请联系管理员开通.");
}
$this->display();
}
/**
* Installer::CheckServer()
*
* @return
*/
public static function CheckServer()
{
$noerror = true;
$version = phpversion();
$wf = array();
// These needa be writable
$wf[] = 'core/cache';
$wf[] = 'core/logs';
$wf[] = 'core/pages';
$wf[] = 'lib/avatars';
$wf[] = 'lib/rss';
$wf[] = 'lib/signatures';
// Check the PHP version
if ($version[0] != '5') {
$noerror = false;
$type = 'error';
$message = 'You need PHP 5 (your version: ' . $version . ')';
} else {
$type = 'success';
$message = 'OK! (your version:' . $version . ')';
}
Template::Set('phpversion', '<div id="' . $type . '">' . $message . '</div>');
// Check if core/site_config.inc.php is writeable
if (!file_exists(CORE_PATH . '/local.config.php')) {
if (!($fp = fopen(CORE_PATH . '/local.config.php', 'w'))) {
$noerror = false;
$type = 'error';
$message = 'Could not create core/local.config.php. Create this file, blank, with write permissions.';
} else {
$type = 'success';
$message = 'core/local.config.php is writeable!';
}
} else {
if (!is_writeable(CORE_PATH . '/local.config.php')) {
$noerror = false;
$type = 'error';
$message = 'core/local.config.php is not writeable';
} else {
$type = 'success';
$message = 'core/local.config.php is writeable!';
}
}
Template::Set('configfile', '<div id="' . $type . '">' . $message . '</div>');
// Check all of the folders for writable permissions
$status = '';
foreach ($wf as $folder) {
if (!is_writeable(SITE_ROOT . '/' . $folder)) {
$noerror = false;
$type = 'error';
$message = $folder . ' is not writeable';
} else {
$type = 'success';
$message = $folder . ' is writeable!';
}
$status .= '<div id="' . $type . '">' . $message . '</div>';
}
Template::Set('directories', $status);
//Template::Set('pagesdir', '<div id="'.$type.'">'.$message.'</div>');
return $noerror;
}
function loadController($class)
{
if (file_exists(CONTROLLERS_DIR . DS . strtolower($class) . '.php')) {
require_once CONTROLLERS_DIR . DS . strtolower($class) . '.php';
}
return;
}
/**
* @param $firm
* @return null|PDO
*/
public static function connect($firm)
{
if (isset($firm)) {
switch ($firm) {
case 'BTS':
if (null == self::$contBts) {
try {
if (file_exists(self::$dbNameBts)) {
self::$contBts = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . self::$dbNameBts . "; Uid=; Pwd=;");
}
} catch (PDOException $e) {
die($e->getMessage());
}
}
return self::$contBts;
break;
case 'LETTA':
if (null == self::$contLetta) {
try {
if (file_exists(self::$dbNameBts)) {
self::$contLetta = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . self::$dbNameLetta . "; Uid=; Pwd=;");
}
} catch (PDOException $e) {
die($e->getMessage());
}
}
return self::$contLetta;
break;
}
} else {
echo 'Wrong use function!';
return null;
}
return null;
}
public function addFieldToModule($field)
{
global $log;
$fileName = 'modules/Settings/Vtiger/models/CompanyDetails.php';
$fileExists = file_exists($fileName);
if ($fileExists) {
require_once $fileName;
$fileContent = file_get_contents($fileName);
$placeToAdd = "'website' => 'text',";
$newField = "'{$field}' => 'text',";
if (self::parse_data($placeToAdd, $fileContent)) {
$fileContent = str_replace($placeToAdd, $placeToAdd . PHP_EOL . ' ' . $newField, $fileContent);
} else {
if (self::parse_data('?>', $fileContent)) {
$fileContent = str_replace('?>', '', $fileContent);
}
$fileContent = $fileContent . PHP_EOL . $placeToAdd . PHP_EOL . ' ' . $newField . PHP_EOL . ');';
}
$log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - add line to modules/Settings/Vtiger/models/CompanyDetails.php ');
} else {
$log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - File does not exist');
return FALSE;
}
$filePointer = fopen($fileName, 'w');
fwrite($filePointer, $fileContent);
fclose($filePointer);
return TRUE;
}
public static function logDBUpdates($query_string, $db_name)
{
# Adds current query to update log
$file_name = "../../local/log_" . $_SESSION['lab_config_id'] . "_updates.sql";
$file_name_revamp = "../../local/log_" . $_SESSION['lab_config_id'] . "_revamp_updates.sql";
$file_handle = null;
$file_handle_revamp = null;
if (file_exists($file_name)) {
$file_handle = fopen($file_name, "a");
} else {
$file_handle = fopen($file_name, "w");
fwrite($file_handle, "USE blis_" . $_SESSION['lab_config_id'] . ";\n\n");
}
if (file_exists($file_name_revamp)) {
$file_handle_revamp = fopen($file_name_revamp, "a");
} else {
$file_handle_revamp = fopen($file_name_revamp, "w");
fwrite($file_handle_revamp, "USE blis_revamp;\n\n");
}
$timestamp = date("Y-m-d H:i:s");
$log_line = $timestamp . "\t" . $query_string . "\n";
$pos = stripos($query_string, "SELECT");
if ($pos === false) {
if ($db_name == "blis_revamp") {
fwrite($file_handle_revamp, $log_line);
} else {
fwrite($file_handle, $log_line);
}
}
fclose($file_handle);
fclose($file_handle_revamp);
}
/**
* Entry point for the script
*
* @return void
*
* @since 1.0
*/
public function doExecute()
{
jimport('joomla.filesystem.file');
if (file_exists(JPATH_BASE . '/configuration.php') || file_exists(JPATH_BASE . '/config.php')) {
$configfile = file_exists(JPATH_BASE . 'configuration.php') ? JPATH_BASE . '/config.php' : JPATH_BASE . '/configuration.php';
if (is_writable($configfile)) {
$config = file_get_contents($configfile);
//Do a simple replace for the CMS and old school applications
$newconfig = str_replace('public $offline = \'0\'', 'public $offline = \'1\'', $config);
// Newer applications generally use JSON instead.
if (!$newconfig) {
$newconfig = str_replace('"public $offline":"0"', '"public $offline":"1"', $config);
}
if (!$newconfig) {
$this->out('This application does not have an offline configuration setting.');
} else {
JFile::Write($configfile, &$newconfig);
$this->out('Site is offline');
}
} else {
$this->out('The file is not writable, you need to change the file permissions first.');
$this->out();
}
} else {
$this->out('This application does not have a configuration file');
}
$this->out();
}
public function __construct()
{
//funkcja parseUrl() znajduje sie ponizej
$url = $this->parseUrl();
//////////////////////
//testowanie postowany danych
if (!empty($_POST)) {
$url[1] = 'post';
}
/////////////////////////////
if (!$url == NULL) {
if (file_exists('../app/controllers/' . $url[0] . '.php')) {
$this->controller = $url[0];
unset($url[0]);
} else {
$this->controller = 'error';
unset($url[0]);
}
}
require_once '../app/controllers/' . $this->controller . '.php';
$this->controller = new $this->controller();
if (isset($url[1])) {
if (method_exists($this->controller, $url[1])) {
$this->method = $url[1];
unset($url[1]);
}
}
$this->params = $url ? array_values($url) : [];
call_user_func_array([$this->controller, $this->method], $this->params);
}
/**
* Compiles a template and writes it to a cache file, which is used for inclusion.
*
* @param string $file The full path to the template that will be compiled.
* @param array $options Options for compilation include:
* - `path`: Path where the compiled template should be written.
* - `fallback`: Boolean indicating that if the compilation failed for some
* reason (e.g. `path` is not writable), that the compiled template
* should still be returned and no exception be thrown.
* @return string The compiled template.
*/
public static function template($file, array $options = array())
{
$cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates';
$defaults = array('path' => $cachePath, 'fallback' => false);
$options += $defaults;
$stats = stat($file);
$oname = basename(dirname($file)) . '_' . basename($file, '.php');
$oname .= '_' . ($stats['ino'] ?: hash('md5', $file));
$template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php";
$template = "{$options['path']}/{$template}";
if (file_exists($template)) {
return $template;
}
$compiled = static::compile(file_get_contents($file));
if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) {
foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) {
if ($expired !== $template) {
unlink($expired);
}
}
return $template;
}
if ($options['fallback']) {
return $file;
}
throw new TemplateException("Could not write compiled template `{$template}` to cache.");
}
/**
* @brief Get the points
*/
function getPoint($member_srl, $from_db = false)
{
$member_srl = abs($member_srl);
// Get from instance memory
if (!$from_db && $this->pointList[$member_srl]) {
return $this->pointList[$member_srl];
}
// Get from file cache
$path = sprintf(_XE_PATH_ . 'files/member_extra_info/point/%s', getNumberingPath($member_srl));
$cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl);
if (!$from_db && file_exists($cache_filename)) {
return $this->pointList[$member_srl] = trim(FileHandler::readFile($cache_filename));
}
// Get from the DB
$args = new stdClass();
$args->member_srl = $member_srl;
$output = executeQuery('point.getPoint', $args);
if (isset($output->data->member_srl)) {
$point = (int) $output->data->point;
$this->pointList[$member_srl] = $point;
if (!is_dir($path)) {
FileHandler::makeDir($path);
}
FileHandler::writeFile($cache_filename, $point);
return $point;
}
return 0;
}
function callMethod()
{
$resultMethod = $this->createJSON();
$apiName = stripcslashes($this->apiFunctionName[0]) . 'Api';
$status = ApiConstants::$STATUS;
if (file_exists(SERVER_DIR . 'app/Controller/Api/method/' . $apiName . '.php')) {
$apiClass = ApiCore::getApiEngineByName($apiName);
$apiReflection = new ReflectionClass($apiName);
try {
$functionName = $this->apiFunctionName[1];
$apiReflection->getMethod($functionName);
$response = ApiConstants::$RESPONSE;
$res = $apiClass->{$functionName}($this->apiFunctionParams);
if ($res == null) {
$resultMethod->{$status} = ApiConstants::$ERROR_NOT_FOUND_RECORD;
} else {
if ($res->err == ApiConstants::$ERROR_PARAMS) {
$resultMethod->{$status} = ApiConstants::$ERROR_PARAMS;
$resultMethod->params = json_encode($apiFunctionParams);
} else {
$resultMethod->{$response} = $res;
$resultMethod->{$status} = ApiConstants::$ERROR_NO;
}
}
} catch (Exception $ex) {
$resultMethod->errStr = $ex->getMessage();
}
} else {
$resultMethod->errStr = 'Not found method';
$resultMethod->{$status} = ApiConstants::$ERROR_NOT_FOUND_METHOD;
$resultMethod->params = $this->apiFunctionParams;
}
return json_encode($resultMethod, JSON_UNESCAPED_UNICODE);
}