first commit
This commit is contained in:
103
apps/update/modules/stDevel/actions/actions.class.php
Normal file
103
apps/update/modules/stDevel/actions/actions.class.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* SOTESHOP/stUpdate
|
||||
*
|
||||
* This file is the part of stUpdate application. License: (Open License SOTE) Open License SOTE.
|
||||
* Do not modify this file, system will overwrite it during upgrade.
|
||||
*
|
||||
* @package stUpdate
|
||||
* @subpackage actions
|
||||
* @copyright SOTE (www.sote.pl)
|
||||
* @license http://www.sote.pl/license/open (Open License SOTE) Open License SOTE
|
||||
* @version $Id: actions.class.php 10660 2011-01-30 12:54:51Z marek $
|
||||
* @author Michal Prochowski <michal.prochowski@sote.pl>
|
||||
*/
|
||||
|
||||
/**
|
||||
* stDevelActions
|
||||
*
|
||||
* @package stUpdate
|
||||
* @subpackage actions
|
||||
*/
|
||||
class stDevelActions extends sfActions
|
||||
{
|
||||
public function preExecute()
|
||||
{
|
||||
if (stConfig::getInstance('stRegister')->get('demo'))
|
||||
{
|
||||
return $this->forward404();
|
||||
}
|
||||
}
|
||||
|
||||
public function executePhpInfo()
|
||||
{
|
||||
$iframe=$this->getRequestParameter('iframe');
|
||||
if (! empty($iframe))
|
||||
{
|
||||
$this->iframe=1;
|
||||
$this->setLayout(false);
|
||||
} else {
|
||||
$this->iframe_uri=$this->getRequest()->getUri().'/iframe/1';
|
||||
$this->iframe=0;
|
||||
}
|
||||
}
|
||||
|
||||
public function executeDevel()
|
||||
{
|
||||
$this->hostname = sfContext::getInstance()->getRequest()->getHost();
|
||||
$apps = array('index'=>'frontend', 'backend'=>'backend', 'update'=>'update');
|
||||
$this->stWebRequest = new stWebRequest();
|
||||
$this->hasDevel = false;
|
||||
|
||||
if ($this->getRequest()->getMethod() == sfRequest::POST)
|
||||
{
|
||||
if ($this->getRequest()->hasParameter('devel[devel]'))
|
||||
{
|
||||
if ($this->getRequest()->getParameter('devel[devel]') == 1)
|
||||
{
|
||||
$ip = $this->getRequest()->getParameter('devel[ip]');
|
||||
$content_head = "<?php\nif(\$_SERVER['REMOTE_ADDR'] != '$ip') die();?>";
|
||||
|
||||
foreach($apps as $file=>$app)
|
||||
{
|
||||
$app_web=sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$file.'.php';
|
||||
$app_web_devel=sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$app.'_dev.php';
|
||||
$app_web_content=file_get_contents($app_web);
|
||||
$content=$this->setDevel($content_head.$app_web_content);
|
||||
file_put_contents($app_web_devel, $content);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach($apps as $file=>$app)
|
||||
{
|
||||
$file = SF_ROOT_DIR.DIRECTORY_SEPARATOR.'web'.DIRECTORY_SEPARATOR.$app.'_dev.php';
|
||||
@unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($apps as $app)
|
||||
{
|
||||
$file = SF_ROOT_DIR.DIRECTORY_SEPARATOR.'web'.DIRECTORY_SEPARATOR.$app.'_dev.php';
|
||||
if (file_exists($file)) $this->hasDevel = true;
|
||||
}
|
||||
|
||||
// @todo ass set hasBeta
|
||||
}
|
||||
|
||||
/**
|
||||
* Change files web/{$app}.php to developer mode.
|
||||
*
|
||||
* @param string $app
|
||||
* @return string
|
||||
*/
|
||||
private function setDevel($content)
|
||||
{
|
||||
$content=str_replace("define('SF_ENVIRONMENT', 'prod')","define('SF_ENVIRONMENT', 'dev')",$content);
|
||||
$content=str_replace("define('SF_DEBUG', false)","define('SF_DEBUG', true)",$content);
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
2
apps/update/modules/stDevel/config/security.yml
Normal file
2
apps/update/modules/stDevel/config/security.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
all:
|
||||
is_secure: on
|
||||
55
apps/update/modules/stDevel/templates/develSuccess.php
Normal file
55
apps/update/modules/stDevel/templates/develSuccess.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php use_helper('stUpdate') ?>
|
||||
<?php use_stylesheet('/css/update/stInstallerWebPlugin.css?version=1'); ?>
|
||||
<?php use_stylesheet('/css/update/stDevel.css?version=1'); ?>
|
||||
<?php echo get_partial('stInstallerWeb/menu_top');?>
|
||||
<div id="frame_update">
|
||||
<?php echo get_partial('stInstallerWeb/menu_tools',array('selected'=>'devel'));?>
|
||||
<div class="box_content">
|
||||
<h2 class="title"><?php echo __('Tryb developerski', null, 'stInstallerWeb');?></h2>
|
||||
<div class="content_update_box">
|
||||
<div>
|
||||
<h2 class="subhead_txt_module"><?php echo __('Ustawienia trybu developerskiego')?></h2>
|
||||
</div>
|
||||
<br />
|
||||
<div id="stDevel_form">
|
||||
<?php echo form_tag('devel/devel', array('id' => 'sf_admin_config_form', 'name' => 'sf_admin_config_form'));?>
|
||||
<div class="main">
|
||||
<div class="row">
|
||||
<div class="column" id="txt1"><?php echo __('Adres IP');?>:</div>
|
||||
<div class="column"><?php echo input_tag('devel[ip]',$stWebRequest->getRemoteAddress());?></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="column" id="txt2"><?php echo __('Włącz tryb developerski');?>:</div>
|
||||
<div class="column"><?php echo checkbox_tag('devel[devel]',1,$hasDevel);?></div>
|
||||
</div>
|
||||
<div id="frame_buttons">
|
||||
<?php echo st_get_update_actions_head('style="float:left"') ?>
|
||||
<?php echo st_get_update_action('save', __('Zapisz')) ?>
|
||||
<?php echo st_get_update_action('more', __('PHPINFO'), 'stDevel/phpInfo') ?>
|
||||
<?php echo st_get_update_actions_foot() ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<br />
|
||||
<?php if ($hasDevel): ?>
|
||||
<?php echo __('Linki do stron w trybie developerskim dostępne tylko dla wskazanego IP:') ?>
|
||||
<table style="margin-bottom: 15px;">
|
||||
<tr>
|
||||
<td>
|
||||
<?php echo __('Sklep:')?>
|
||||
</td>
|
||||
<td><a href="<?php echo "http://$hostname/frontend_dev.php" ?>" target="frontend"><?php echo __('http://'.$hostname.'/frontend_dev.php')?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo __('Panel sklepu:')?></td>
|
||||
<td><a href="<?php echo "http://$hostname/backend_dev.php" ?>" target="frontend"><?php echo __('http://'.$hostname.'/backend_dev.php')?></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php endif ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
23
apps/update/modules/stDevel/templates/phpInfoSuccess.php
Normal file
23
apps/update/modules/stDevel/templates/phpInfoSuccess.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php use_stylesheet('/css/update/stInstallerWebPlugin.css?version=1');?>
|
||||
<?php if($iframe == true):?>
|
||||
<html>
|
||||
<body style="background-color: #fff;">
|
||||
<?php phpinfo();?>
|
||||
</body>
|
||||
</html>
|
||||
<?php else:?>
|
||||
<?php echo get_partial('stInstallerWeb/menu_top');?>
|
||||
<div id="frame_update">
|
||||
<?php echo get_partial('stInstallerWeb/menu_tools', array('selected' => 'devel'));?>
|
||||
<div class="box_content">
|
||||
<h2 class="title"><?php echo __('Tryb developerski', null, 'stInstallerWeb');?></h2>
|
||||
<h2 class="subhead_txt_module"><?php echo __('PHPINFO');?></h2>
|
||||
<div class="content_update_box">
|
||||
<iframe src="<?php echo $iframe_uri;?>" width="888" height="600" style="border: 1px solid #ddd; margin-bottom: 10px;">
|
||||
<p>Your browser does not support iframes.</p>
|
||||
</iframe>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
Reference in New Issue
Block a user