/usr/share/cherokee/admin/wizards/zend.py is in cherokee-admin 1.2.101-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | # -*- coding: utf-8 -*-
#
# Zend Wizard
#
# Authors:
# Taher Shihadeh <taher@octality.com>
#
# Copyright (C) 2010 Alvaro Lopez Ortega
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
#
# Tested:
# 2009/10/xx: Zend 1.9.3 / Cherokee 0.99.25
# 2010/04/19: Zend 1.9.4 / Cherokee 0.99.45b
#
import os
import re
import CTK
import Wizard
import validations
from util import *
NOTE_WELCOME_H1 = N_("Welcome to the Zend Wizard")
NOTE_WELCOME_P1 = N_('<a target="_blank" href="http://www.zend.com/">Zend</a> Framework is a simple, straightforward, open-source software framework for PHP 5 designed to eliminate the tedious details of coding and let you focus on the big picture.')
NOTE_WELCOME_P2 = N_('One of its strengths is the highly modular Model-View-Controller (MVC) design, making your code more reusable and easier to maintain.')
NOTE_LOCAL_H1 = N_("Application Source Code")
NOTE_LOCAL_DIR = N_("Local directory where the Zend source code is located. Example: /usr/share/php/data/zend.")
ERROR_NO_SRC = N_("Does not look like a Zend source directory.")
NOTE_HOST_H1 = N_("New Virtual Server Details")
NOTE_HOST = N_("Host name of the virtual server that is about to be created.")
NOTE_WEBDIR = N_("Web directory where you want Zend to be accessible. (Example: /zend)")
NOTE_WEBDIR_H1 = N_("Public Web Directory")
PREFIX = 'tmp!wizard!zend'
URL_APPLY = r'/wizard/vserver/zend/apply'
CONFIG_DIR = """
%(pre_rule_plus1)s!document_root = %(local_src_dir)s
%(pre_rule_plus1)s!match = directory
%(pre_rule_plus1)s!match!directory = %(web_dir)s
%(pre_rule_plus1)s!match!final = 0
# PHP rule
%(pre_rule_minus2)s!match = and
%(pre_rule_minus2)s!match!final = 1
%(pre_rule_minus2)s!match!left = directory
%(pre_rule_minus2)s!match!left!directory = %(web_dir)s
%(pre_rule_minus2)s!match!right = exists
%(pre_rule_minus2)s!match!right!iocache = 1
%(pre_rule_minus2)s!match!right!match_any = 1
%(pre_rule_minus2)s!match!right!match_index_files = 0
%(pre_rule_minus2)s!match!right!match_only_files = 1
%(pre_rule_minus2)s!handler = file
%(pre_rule_minus2)s!handler!iocache = 1
%(pre_rule_minus3)s!match = request
%(pre_rule_minus3)s!match!request = %(web_dir)s/.+
%(pre_rule_minus3)s!handler = redir
%(pre_rule_minus3)s!handler!rewrite!1!show = 0
%(pre_rule_minus3)s!handler!rewrite!1!substring = %(web_dir)s/index.php
"""
CONFIG_VSERVER = """
%(pre_vsrv)s!nick = %(host)s
%(pre_vsrv)s!document_root = %(local_src_dir)s
%(pre_vsrv)s!directory_index = index.php,index.html
# PHP rule
%(pre_rule_minus1)s!handler = common
%(pre_rule_minus1)s!match = fullpath
%(pre_rule_minus1)s!match!fullpath!1 = /
%(pre_rule_minus2)s!handler = common
%(pre_rule_minus2)s!match = exists
%(pre_rule_minus2)s!match!match_any = 1
%(pre_rule_minus2)s!match!match_index_files = 0
%(pre_rule_minus2)s!match!match_only_files = 1
%(pre_rule_minus3)s!handler = redir
%(pre_rule_minus3)s!handler!rewrite!1!regex = ^.*$
%(pre_rule_minus3)s!handler!rewrite!1!show = 0
%(pre_rule_minus3)s!handler!rewrite!1!substring = /index.php
%(pre_rule_minus3)s!match = default
%(pre_rule_minus3)s!match!final = 1
"""
class Commit:
def Commit_VServer (self):
# Create the new Virtual Server
next = CTK.cfg.get_next_entry_prefix('vserver')
CTK.cfg['%s!nick'%(next)] = CTK.cfg.get_val('%s!host'%(PREFIX))
Wizard.CloneLogsCfg_Apply ('%s!logs_as_vsrv'%(PREFIX), next)
# PHP
php = CTK.load_module ('php', 'wizards')
error = php.wizard_php_add (next)
if error:
return {'ret': 'error', 'errors': {'msg': error}}
php_info = php.get_info (next)
# Zend
props = cfg_get_surrounding_repls ('pre_rule', php_info['rule'])
props['pre_vsrv'] = next
props['host'] = CTK.cfg.get_val('%s!host' %(PREFIX))
props['local_src_dir'] = CTK.cfg.get_val('%s!sources' %(PREFIX))
config = CONFIG_VSERVER %(props)
CTK.cfg.apply_chunk (config)
# Clean up
CTK.cfg.normalize ('%s!rule'%(next))
CTK.cfg.normalize ('vserver')
del (CTK.cfg[PREFIX])
return CTK.cfg_reply_ajax_ok()
def Commit_Rule (self):
vsrv_num = CTK.cfg.get_val ('%s!vsrv_num'%(PREFIX))
next = 'vserver!%s' %(vsrv_num)
# PHP
php = CTK.load_module ('php', 'wizards')
error = php.wizard_php_add (next)
if error:
return {'ret': 'error', 'errors': {'msg': error}}
php_info = php.get_info (next)
# Zend
props = cfg_get_surrounding_repls ('pre_rule', php_info['rule'])
props['pre_vsrv'] = next
props['web_dir'] = CTK.cfg.get_val('%s!web_dir' %(PREFIX))
props['local_src_dir'] = CTK.cfg.get_val('%s!sources' %(PREFIX))
config = CONFIG_DIR %(props)
CTK.cfg.apply_chunk (config)
# Clean up
CTK.cfg.normalize ('%s!rule'%(next))
del (CTK.cfg[PREFIX])
return CTK.cfg_reply_ajax_ok()
def __call__ (self):
if CTK.post.pop('final'):
# Apply POST
CTK.cfg_apply_post()
# VServer or Rule?
if CTK.cfg.get_val ('%s!vsrv_num'%(PREFIX)):
return self.Commit_Rule()
return self.Commit_VServer()
return CTK.cfg_apply_post()
class WebDirectory:
def __call__ (self):
table = CTK.PropsTable()
table.Add (_('Web Directory'), CTK.TextCfg ('%s!web_dir'%(PREFIX), False, {'value': '/zend', 'class': 'noauto'}), _(NOTE_WEBDIR))
vsrv_num = CTK.cfg.get_val ('%s!vsrv_num'%(PREFIX))
submit = CTK.Submitter (URL_APPLY)
submit += CTK.Hidden('final', '1')
submit += table
cont = CTK.Container()
cont += CTK.RawHTML ('<h2>%s</h2>' %(_(NOTE_WEBDIR_H1)))
cont += submit
cont += CTK.DruidButtonsPanel_PrevCreate_Auto()
return cont.Render().toStr()
class Host:
def __call__ (self):
table = CTK.PropsTable()
table.Add (_('New Host Name'), CTK.TextCfg ('%s!host'%(PREFIX), False, {'value': 'zend.example.com', 'class': 'noauto'}), _(NOTE_HOST))
table.Add (_('Use Same Logs as'), Wizard.CloneLogsCfg('%s!logs_as_vsrv'%(PREFIX)), _(Wizard.CloneLogsCfg.NOTE))
submit = CTK.Submitter (URL_APPLY)
submit += CTK.Hidden('final', '1')
submit += table
cont = CTK.Container()
cont += CTK.RawHTML ('<h2>%s</h2>' %(_(NOTE_HOST_H1)))
cont += submit
cont += CTK.DruidButtonsPanel_PrevCreate_Auto()
return cont.Render().toStr()
class LocalSource:
def __call__ (self):
table = CTK.PropsTable()
table.Add (_('Source Directory'), CTK.TextCfg ('%s!sources'%(PREFIX), False, {'value': '/var/www'}), _(NOTE_LOCAL_DIR))
submit = CTK.Submitter (URL_APPLY)
submit += table
cont = CTK.Container()
cont += CTK.RawHTML ('<h2>%s</h2>' %(_(NOTE_LOCAL_H1)))
cont += submit
cont += CTK.DruidButtonsPanel_PrevNext_Auto()
return cont.Render().toStr()
class PHP:
def __call__ (self):
php = CTK.load_module ('php', 'wizards')
return php.External_FindPHP()
class Welcome:
def __call__ (self):
cont = CTK.Container()
cont += CTK.RawHTML ('<h2>%s</h2>' %(_(NOTE_WELCOME_H1)))
cont += Wizard.Icon ('zend', {'class': 'wizard-descr'})
box = CTK.Box ({'class': 'wizard-welcome'})
box += CTK.RawHTML ('<p>%s</p>' %(_(NOTE_WELCOME_P1)))
box += CTK.RawHTML ('<p>%s</p>' %(_(NOTE_WELCOME_P2)))
box += Wizard.CookBookBox ('cookbook_zend')
cont += box
# Send the VServer num if it's a Rule
tmp = re.findall (r'^/wizard/vserver/(\d+)/', CTK.request.url)
if tmp:
submit = CTK.Submitter (URL_APPLY)
submit += CTK.Hidden('%s!vsrv_num'%(PREFIX), tmp[0])
cont += submit
cont += CTK.DruidButtonsPanel_Next_Auto()
return cont.Render().toStr()
VALS = [
('%s!sources' %(PREFIX), validations.is_not_empty),
('%s!host' %(PREFIX), validations.is_not_empty),
('%s!web_dir' %(PREFIX), validations.is_not_empty),
('%s!sources' %(PREFIX), validations.is_local_dir_exists),
('%s!host' %(PREFIX), validations.is_new_vserver_nick),
('%s!web_dir' %(PREFIX), validations.is_dir_formatted),
]
# VServer
CTK.publish ('^/wizard/vserver/zend$', Welcome)
CTK.publish ('^/wizard/vserver/zend/2$', PHP)
CTK.publish ('^/wizard/vserver/zend/3$', LocalSource)
CTK.publish ('^/wizard/vserver/zend/4$', Host)
# Rule
CTK.publish ('^/wizard/vserver/(\d+)/zend$', Welcome)
CTK.publish ('^/wizard/vserver/(\d+)/zend/2$', PHP)
CTK.publish ('^/wizard/vserver/(\d+)/zend/3$', LocalSource)
CTK.publish ('^/wizard/vserver/(\d+)/zend/4$', WebDirectory)
# Common
CTK.publish (r'^%s'%(URL_APPLY), Commit, method="POST", validation=VALS)
|