Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * Several functions to help the cli setup of CONTENIDO
  4:  *
  5:  * @package Setup
  6:  * @subpackage Setup
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Mischa Holz
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: /**
 18:  * Prints some text to the console
 19:  *
 20:  * @param string $str string which should be printed
 21:  * @param number $tab number of tab characters which should preceed the string
 22:  */
 23: function prnt($str = '', $tab = 0) {
 24:     for ($i = 0; $i < $tab; $i++) {
 25:         echo("\t");
 26:     }
 27:     echo($str);
 28: }
 29: 
 30: /**
 31:  * Prints some text and a new line to the console
 32:  *
 33:  * @param string $str string which should be printed
 34:  * @param number $tab number of tab characters which should preceed the string
 35:  */
 36: function prntln($str = '', $tab = 0) {
 37:     prnt($str . "\n\r", $tab);
 38: }
 39: 
 40: /**
 41:  * Prints some text to the console and jumps back to the beginning of the line
 42:  *
 43:  * @param string $str string which should be printed
 44:  */
 45: function prntst($str = '') {
 46:     echo($str . "\r");
 47: }
 48: 
 49: /**
 50:  * Ask the user for a password and erase it if he is done entering it.
 51:  * Since the Windows console does not understand ANSI sequences the
 52:  * function will print a warning for the user instead.
 53:  *
 54:  * @param string $title label text
 55:  * @param number $tab number of tabs which should preceed the label text
 56:  * @return string user entered password
 57:  */
 58: function passwordPrompt($title, $tab = 0) {
 59:     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
 60:         prntln(i18n('Be careful! The password will be readable in the console window!', 'setup'), $tab);
 61:     }
 62:     prnt($title . ': ', $tab);
 63:     $line = trim(fgets(STDIN));
 64:     if (!(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')) {
 65:         echo("\033[1A"); // move the cursor up one line
 66:         prnt($title . ': ', $tab); // reprint the label
 67:         for ($i = 0; $i < strlen($line); $i++) {
 68:             echo("*"); // replace the password with asterisks
 69:         }
 70:         echo("\r\n");
 71:     }
 72:     return $line;
 73: }
 74: 
 75: /**
 76:  * Prints a progress bar to the console
 77:  *
 78:  * @param int $width Widht of the progress bar in characters
 79:  * @param int $filled Percent value to which it should be filled (e.g. 45)
 80:  */
 81: function progressBar($width, $filled) {
 82:     echo("\r");
 83:     echo("|");
 84:     $i = 0;
 85:     for ($i = 0; $i <= $filled / 100 * $width; $i++) {
 86:         echo("#");
 87:     }
 88:     for ($j = $i; $j <= $width; $j++) {
 89:         echo(" ");
 90:     }
 91:     echo("| ");
 92:     prnt(round($filled) . "%");
 93: }
 94: 
 95: /**
 96:  * Initializes the globals the CONTENIDO setup needs
 97:  */
 98: function initializeVariables() {
 99:     global $cfg, $_SESSION;
100: 
101:     $cfg['db'] = array(
102:         'connection' => array(
103:             'host'     => '',
104:             'user'     => '',
105:             'password' => '',
106:             'charset'  => '',
107:             'database' => ''
108:         ),
109:         'haltBehavior'    => 'report',
110:         'haltMsgPrefix'   => (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] . ' ' : '',
111:         'enableProfiling' => false
112:     );
113:     $_SESSION['setuptype'] = 'setup';
114:     $_SESSION['dbname'] = '';
115:     $_SESSION['configmode'] = 'save';
116:     $_SESSION["override_root_http_path"] = '';
117:     $_SESSION['clientmode'] = '';
118:     $_SESSION['adminpass'] = '';
119:     $_SESSION['adminmail'] = '';
120:     $_SESSION['dbprefix'] = '';
121: }
122: 
123: /**
124:  * Checks to see if all the installation settings are valid and have been entered
125:  *
126:  * @return boolean true if every setting has been entered
127:  */
128: function checkInstallationSettings() {
129:     global $cfg, $_SESSION;
130: 
131:     $fine = true;
132: 
133:     if ($cfg['db']['connection']['host'] == '') {
134:         prntln(i18n('You did not specify a database host!', 'setup'));
135:         $fine = false;
136:     }
137:     if ($cfg['db']['connection']['user'] == '') {
138:         prntln(i18n('You did not specify a database user!', 'setup'));
139:         $fine = false;
140:     }
141:     if ($cfg['db']['connection']['password'] == '') {
142:         prntln(i18n('You did not specify a database password!', 'setup'));
143:         $fine = false;
144:     }
145:     if ($cfg['db']['connection']['charset'] == '') {
146:         prntln(i18n('You did not specify a database charset!', 'setup'));
147:         $fine = false;
148:     }
149:     if ($_SESSION['dbcollation'] == '') {
150:         prntln(i18n('You did not specify a database collation!', 'setup'));
151:         $fine = false;
152:     }
153:     if ($cfg['db']['connection']['database'] == '') {
154:         prntln(i18n('You did not specify a database name!', 'setup'));
155:         $fine = false;
156:     }
157:     if ($_SESSION['dbprefix'] == '') {
158:         prntln(i18n('You did not specify a database prefix!', 'setup'));
159:         $fine = false;
160:     }
161: 
162:     // append a slash to the http path if it isn't there already
163:     if (!(substr($_SESSION['override_root_http_path'], -strlen("/")) === "/")) {
164:         $_SESSION['override_root_http_path'] = $_SESSION['override_root_http_path'] . "/";
165:     }
166:     if ($_SESSION['override_root_http_path'] == '') {
167:         prntln(i18n('You did not specify an http root path!', 'setup'));
168:         $fine = false;
169:     }
170:     if ($_SESSION['clientmode'] == '') {
171:         prntln(i18n('You did not specify if you want to install the example client or not!', 'setup'));
172:         $fine = false;
173:     }
174:     if (!($_SESSION['clientmode'] == "CLIENTEXAMPLES" || $_SESSION['clientmode'] == "CLIENTMODULES" || $_SESSION['clientmode'] == "NOCLIENT")) {
175:         prntln(i18n('You did not specify if you want to install the example client or not!', 'setup'));
176:         $fine = false;
177:     }
178:     if ($_SESSION['adminpass'] == '') {
179:         prntln(i18n('You did not specify an admin password!', 'setup'));
180:         $fine = false;
181:     }
182:     if ($_SESSION['adminmail'] == '') {
183:         prntln(i18n('You did not specify an admin email!', 'setup'));
184:         $fine = false;
185:     }
186: 
187:     return $fine;
188: }
189: 
190: /**
191:  * Converts unix-style CLI arguments into an array
192:  *
193:  * @return array An array representing the arguments and switches provided to the script
194:  */
195: function getArgs() {
196:     $args = $_SERVER['argv'];
197: 
198:     $out = array();
199:     $last_arg = null;
200: 
201:     for ($i = 1, $il = sizeof($args); $i < $il; $i++) {
202:         if (preg_match("/^--(.+)/", $args[$i], $match)) {
203:             $parts = explode("=", $match[1]);
204:             $key = preg_replace("/[^a-z0-9]+/", "", $parts[0]);
205: 
206:             if (isset($parts[1])) {
207:                 $out[$key] = $parts[1];
208:             } else {
209:                 $out[$key] = true;
210:             }
211:             $last_arg = $key;
212:         } else if (preg_match("/^-([a-zA-Z0-9]+)/", $args[$i], $match)) {
213:             for ($j = 0, $jl = strlen($match[1]); $j < $jl; $j++) {
214:                 $key = $match[1]{$j};
215:                 $out[$key] = true;
216:             }
217:             $last_arg = $key;
218:         } else if ($last_arg !== null) {
219:             $out[$last_arg] = $args[$i];
220:         }
221:     }
222:     return $out;
223: }
224: 
225: /**
226:  * Prints the help text
227:  */
228: function printHelpText() {
229:     prntln("\r" . i18n('CONTENIDO setup script', 'setup'));
230:     prntln(i18n('This script will install CONTENIDO to your computer', 'setup'));
231:     prntln();
232:     prntln(i18n("CONTENIDO can be installed using the interactive mode or a non-interactive mode.", 'setup'));
233:     prntln(i18n("If the script is executed without any parameters it will look for the\nautoinstall.ini file (or any other file specified with \"--file\").", 'setup'));
234:     prntln(i18n("If that file is present, the non-interactive mode will be used. The script will\nask for user input in the case of errors though.\nIf you want to prevent the script from ever waiting for user input use\n\"--non-interactive\".", 'setup'));
235:     prntln(i18n("In case the ini file can not be found, the script will wait for user input\non all relevant information.", 'setup'));
236:     prntln();
237:     prntln('--interactive, -i');
238:     prntln(i18n("Forces the script to be interactive and wait for user input even if the\n\tautoinstall.ini file is present.", 'setup'), 1);
239:     prntln('--non-interactive');
240:     prntln(i18n("Will prevent all waiting for user input. The script will abort\n\tin case of any errors", 'setup'), 1);
241:     prntln('--file [' . i18n('file', 'setup') . ']');
242:     prntln(i18n('Use [file] instead of the default autoinstall.ini.', 'setup'), 1);
243:     prntln('--locale [' . i18n('language code', 'setup') . ']');
244:     prntln(i18n("Provide a country and language code to use. Defaults to \"en_US\"", 'setup'), 1);
245:     prntln('--help, -h');
246:     prntln(i18n('Prints this help text', 'setup'), 1);
247:     prntln();
248:     prntln(i18n("Furthermore, you can use parameters to overwrite setup settings.\nUse \"--[ini-group].[ini-name]=\"value\" (e.g. --db.host=\"localhost\")", 'setup'));
249:     prntln();
250:     prntln('CONTENIDO version ' . CON_SETUP_VERSION);
251: }
252: 
253: ?>
254: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen