/** * Determines the request type (php, or file) and dispatches control to the appropriate * classes and functions */ public function dispatch() { $res_script = null; list($file_type, $file_path, $success) = $this->parseRequestURL(); if ($success) { switch ($file_type) { case 'php': self::$request_type = 'script'; if (!($script = getShadowedPath($file_path))) { out_error404(F_NOT_FOUND, $file_path); } if (!$this->current_route) { $this->current_route = $_SERVER['PHP_SELF']; $this->route_query_str = $_SERVER['QUERY_STRING']; } else { $this->route_query_str = $this->org_query_str; } $res_script = $this->bootApp($file_path); break; default: self::$request_type = 'file'; $download_manager = new PADownloadManager($file_path); if (!$download_manager->getFile()) { out_error404($download_manager->lastError(), $file_path); } exit; } } else { out_error404(F_NO_ROUTE); } return $res_script; }
function __construct($inputFormat) { Logger::log("Enter: creating new Normalizer class"); // no need to call parent::__construct $filename = 'api/ProfileIO/xsl/' . $inputFormat . '.xsl'; $xslfile = getShadowedPath($filename); if ($xslfile) { $stylesheet = DOMDocument::load($xslfile); $this->importStylesheet($stylesheet); } else { throw new PAException(FILE_NOT_FOUND, "couldn't read transformation stylesheet: {$filename}"); } Logger::log("Exit: creating new Normalizer class"); }
function exception_handler($exception) { // clean out any buffering so we can write straight to the client // while (ob_end_clean()); try { while ($exception->getCode() == 100 && strpos($exception->getMessage(), "no such table") != -1) { // See if the database hasn't been populated. // (Note: we use 'while' here rather than 'if' so we can use break // to avoid this turning into a mess of nested blocks). // First, make sure we have a working database connection. try { $sth = Dal::query("SHOW TABLES"); } catch (CNException $e) { // The database connection isn't working - so fall through to // the normal error handler. break; } // Now run through the results and see if we can find a familiar // table. $found = 0; while ($r = $sth->fetchRow()) { if ($r[0] == "page_settings") { $found = 1; break; } } if ($found) { // ok, the db *has* been populated - fall through break; } // If we get this far, it means that the DB isn't populated, so we // show a message to the user (who is presumably an admin, // installing the system). // global var $path_prefix has been removed - please, use PA::$path static variable ?> <h1>Database not populated</h1> <p>Before you can run Cyberspace-Networks, you need to populate the database by running the script <code><?php echo PA::$path; ?> /api/DB/CNDB.mysql</code> on your database. You can do it in the MySQL console like this:</p> <pre><i>user</i>@<i>server</i>:<?php echo PA::$path; ?> $ <b>mysql -u <i>username</i> -p</b> Enter password: <b><i>password</i></b> Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 63048 to server version: 4.1.14-Debian_6-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> <b>use paalpha</b> Database changed mysql> <b>source <?php echo PA::$path; ?> /api/DB/CNDB.mysql</b></pre> <?php exit; } // render an error message $code_esc = intval($exception->getCode()); $msg_esc = htmlspecialchars($exception->getMessage()); $traceback = $exception->getTraceAsString(); //$template_file = getShadowedPath(PA::$theme_path . '/cnexception.php'); $template_file = getShadowedPath('web/Themes/Default/cnexception.php'); $template = new Template($template_file); $template->set('code_esc', $code_esc); $template->set('msg_esc', $msg_esc); $template->set('traceback', $traceback); echo $template->fetch(); /* $page = new PageRenderer(NULL, NULL, "Error $code_esc: $msg_esc", "container_one_column.php"); $msg_tpl = new Template(CURRENT_THEME_FSPATH."/error_middle.tpl"); $msg_tpl->set('code', $code_esc); $msg_tpl->set('msg', $msg_esc); $page->add_module("middle", "top", $msg_tpl->fetch()); $css_path = PA::$theme_url . '/layout.css'; $page->add_header_css($css_path); $css_path = PA::$theme_url . '/network_skin.css'; $page->add_header_css($css_path); $page->header->set('navigation_links', null);//setting the links to null echo $page->render(); */ // write a copy into the log Logger::log("An exception occurred: code " . $exception->getCode() . ", message " . $exception->getMessage() . "\nLast error: " . var_export(error_get_last(), TRUE) . "\n" . $exception->getTraceAsString(), LOGGER_ERROR); } catch (Exception $e) { // If an error occurred in PageRenderer or something, present a much plainer screen with both errors: echo "<h1>Lots of errors occurred!</h1>\n<p>An error occurred, then the error handler crashed while trying to handle the error. Whoops!</p>\n<p><b>Here are the details of the original error:</b></p>\n<p>" . $exception->getMessage() . "</p>\n<pre>" . $exception->getTraceAsString() . "</pre>\n<p><b>Here are the details of the second error:</b></p>\n<p>" . $e->getMessage() . "</p>\n<pre>" . $e->getTraceAsString() . "</pre>"; } exit; }
/** * Load internationalization string files * * */ public function loadLanguageFiles() { $culture_file = getShadowedPath(PA::$config_path . '/i18n.xml'); $culture_data = new XmlConfig($culture_file); if ($culture_data->docLoaded) { PA::$culture_data = $culture_data->asArray(); } else { throw new BootStrapException("Error - Can't load \"{$culture_file}\" culture file.", BootStrapException::UNRECOVERABLE_BOOT_EXCEPTION); } $this->installed_languages = $this->getLanguagesList(); session_start(); if (!empty($this->request_data['lang'])) { if (array_key_exists($this->request_data['lang'], $this->installed_languages)) { $this->current_lang = $this->request_data['lang']; $_SESSION['user_lang'] = $this->current_lang; } } else { if (isset($_SESSION['user_lang'])) { $this->current_lang = $_SESSION['user_lang']; } else { if (PA::$config->pa_installed) { $net_info = get_network_info(); $net_settings = unserialize($net_info->extra); $this->current_lang = isset($net_settings['default_language']) ? $net_settings['default_language'] : 'english'; } } } session_commit(); if ($this->current_lang) { PA::$language = $this->current_lang; } ob_start(); global $TRANSLATED_STRINGS; $strings_file = getShadowedPath("web/languages/" . PA::$language . "/strings.php"); try { if (file_exists($strings_file)) { eval('?>' . (require_once $strings_file)); } $msg_handler = getShadowedPath("web/languages/" . PA::$language . "/MessagesHandler.php"); if (file_exists($msg_handler)) { eval('?>' . (require_once $msg_handler)); } else { eval('?>' . (require_once getShadowedPath("web/languages/english/MessagesHandler.php"))); } } catch (Exception $e) { // Either an invalid language was selected, or one (e.g. English) without a strings.php file. $TRANSLATED_STRINGS = array(); throw new BootStrapException($e->message, 1); } return ob_get_clean(); }
/** * function to get the detail of the skin by reading its config file. */ function skin_details($skin_name) { $config_file = getShadowedPath('web/' . PA::$theme_rel . '/skins/' . $skin_name . '/config.xml'); $skin_info = array(); if ($config_file) { $xml_doc = new DomDocument(); $xml_doc->load($config_file); $config_params = array('name', 'previewImage', 'networkCssFile', 'groupCssFile', 'userCssFile', 'headerImage', 'userheaderImage', 'groupheaderImage', 'headerImageOk'); foreach ($config_params as $param) { $node_obj = $xml_doc->getElementsByTagName($param); if (isset($node_obj->item(0)->nodeValue) && $node_obj->item(0)->nodeValue != 'none') { $skin_info[$param] = $node_obj->item(0)->nodeValue; } else { $skin_info[$param] = null; } } } return $skin_info; }
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @author [creator, or "Original Author"] * @license http://bit.ly/aVWqRV PayAsYouGo License * @copyright Copyright (c) 2010 Broadband Mechanics * @package PeopleAggregator */ $login_required = TRUE; //including necessary files $use_theme = 'Beta'; //TODO : Remove this when new UI is completely implemented. include_once "web/includes/page.php"; require_once "web/includes/network.inc.php"; $authorization_required = TRUE; if (!empty($_POST)) { $error = false; $file = getShadowedPath('config/profanity_words.txt'); if (!$file || !($handle = fopen($file, 'w+'))) { $msg = 5040; $error = TRUE; } if ($handle) { if (fwrite($handle, $_POST['file_text']) === FALSE) { $msg = 5041; $error = TRUE; } else { //'Profanity word list has been successfully updated.' $error = false; $msg = 5043; // PA::$config->profanity = explode("\r\n", $_POST['file_text']); } fclose($handle);
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @package * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @subpackage * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @description * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @note * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @todo * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @version 0.0.0-1 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @author Cyberspace Networks <*****@*****.**> * @license GNU General Public License * @copyright Copyright (c) 2000-2014 Cyberspace Networks * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * The lastest version of Cyberspace Networks CoreSystem can be obtained from: * http://developer.cyberspace-networks.com/ * For questions, help, comments, discussion, etc. please visit * https://github.com/CyberspaceNetworks/CoreSystem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ require_once "api/CNTheme/CNTemplate.php"; $theme_url = PA::$theme_url; $uname = empty($_SESSION['user']['name']) ? '' : htmlspecialchars($_SESSION['user']['name']); $template_file = getShadowedPath('web/Themes/Default/cnmaintenance.php'); $template = new Template($template_file); $template->set('theme_url', $theme_url); $template->set('uname', $uname); echo $template->fetch();
private function dbTest() { global $peepagg_dsn; $params = $this->test_data; if (empty($params['db_user'])) { $this->note("You must supply a database user name", 'error'); return false; } if (empty($params['db_name'])) { $this->note("You must supply a database name", 'error'); return false; } if (empty($params['db_host'])) { $this->note("You must supply a host name", 'error'); return false; } if (empty($params['db_password'])) { $this->note("You may not use a blank password for the MySQL connection", 'error'); return false; } $user_link = @mysql_connect($params['db_host'], $params['db_user'], $params['db_password']); // If the installer wishes to use an existing db instead of creating one. $user_db = FALSE; if ($user_link) { $this->note("Able to connect to the MySQL server at <code>{$params['db_host']}</code> with supplied login details.", 'ok'); // make sure the DB isn't already populated if (!mysql_select_db($params['db_name'], $user_link)) { mysql_close($user_link); $user_link = FALSE; if (!empty($params['mysql_root_username']) && !empty($params['mysql_root_password'])) { // if we have root credentials we will try to create database - so, no exit yet! $this->note("Database <code>{$params['db_name']}</code> does not exist or is inaccessible.", 'info'); } else { $this->note("Database <code>{$params['db_name']}</code> does not exist or is inaccessible.", 'error'); return false; } } else { $sth = $this->run_query("SHOW TABLES", $user_link); if (mysql_num_rows($sth)) { if ($params['create_db'] == "true") { $this->note("The database <code>{$params['db_name']}</code> already contains data. Please wipe it out or recreate the database before installing PeopleAggregator.", 'error'); return false; } else { $this->note("Found database with data. Assuming it is an existing PA install...", "ok"); $user_db = TRUE; } } } } else { if (!empty($params['mysql_root_username'])) { // if we have root credentials we will try to create database - so, no exit yet! $this->note("It is recommended to have a password on the root user's account", 'warn'); } else { $this->note("Unable to connect to the MySQL server using the supplied login details", 'error'); return false; } } if (!$user_link && !$user_db && !empty($params['mysql_root_username'])) { $this->note("Trying administrator login..."); $admin_link = @mysql_connect($params['db_host'], $params['mysql_root_username'], $params['mysql_root_password']); if (!$admin_link) { $this->note("Unable to connect to the MySQL server with the supplied login details or as an administrator", 'error'); return false; } else { $this->note("Able to connect to the MySQL server with the supplied administrator login details - a new database will be created.", 'ok'); } // make sure the db doesn't already exist if (mysql_select_db($params['db_name'], $admin_link)) { $this->note("The database <code>{$params['db_name']}</code> already exists. Please, choose a different name for a new database.", 'error'); return false; } // create it $sql = "CREATE DATABASE " . $this->db_esc($params['db_name']); // $rollback_cmds[] = array("sql", "DROP DATABASE ".$this->db_esc($params['db_name']), $admin_link); $this->run_query($sql, $admin_link); // now grant permissions with successively looser hostnames until // we find one that lets the web server access the database. foreach (array("localhost", "localhost.localdomain", $_SERVER['SERVER_NAME'], gethostbyname($_SERVER['SERVER_NAME']), "%") as $server_host) { $sql = "GRANT ALL ON " . $this->db_esc($params['db_name']) . ".* TO " . $this->db_esc($params['db_user']) . "@" . $this->db_esc($server_host) . " IDENTIFIED BY '" . mysql_real_escape_string($params['db_password']) . "'"; $this->run_query($sql, $admin_link); if (($user_link = mysql_connect($params['db_host'], $params['db_user'], $params['db_password'])) && mysql_select_db($params['db_name'], $user_link)) { $this->note("Successfully logged in to new database using credentials from host {$server_host}", 'ok'); break; } } if (!$user_link) { $this->note("Failed to grant access credentials that would allow the web server to access the database. Please try creating the database manually.", 'error'); return false; } } if (!$user_link) { $this->note("Something went wrong - we should have successfully connected to the DB by now", 'error'); return false; } if (!$user_db) { $this->note("The database was successfully created.", 'ok'); // now set up databases $this->note("Initializing database ... ", 'info'); // Parag Jagdale - 10/16/10: Add ability to specify seed file that contains data to insert if (isset($params['insert_seed_data'])) { // use the PeepAgg structure and seed files if ($sql_file = getShadowedPath("web/install/PeepAgg.structure.mysql")) { if ($this->run_query_file($sql_file, $user_link)) { $this->note("The database structure was successfully created.", 'ok'); define("CURRENT_DB", $params['db_name']); $peepagg_dsn = "mysql://" . $params['db_user'] . ":" . $params['db_password'] . "@" . $params['db_host'] . "/" . $params['db_name']; $this->peepagg_dsn = $peepagg_dsn; $this->admin_exsts = false; } } else { $this->note("File <code>{$sql_file}</code> does not exists.", 'error'); return false; } // run the PeepAgg seed file if ($sql_file = getShadowedPath("web/install/PeepAgg.seed.mysql")) { if ($this->run_query_file($sql_file, $user_link)) { $this->note("The database was successfully inserted with seed data.", 'ok'); $peepagg_dsn = "mysql://" . $params['db_user'] . ":" . $params['db_password'] . "@" . $params['db_host'] . "/" . $params['db_name']; $this->peepagg_dsn = $peepagg_dsn; $this->admin_exsts = false; } } else { $this->note("File <code>{$sql_file}</code> does not exists.", 'error'); return false; } $this->admin_exists = $this->check_admin_exists($user_link); } else { // use the normal PeepAgg.mysql which contains both the structure and basic data to seed all in one file if ($sql_file = getShadowedPath("web/install/PeepAgg.mysql")) { if ($this->run_query_file($sql_file, $user_link)) { $this->note("The database was successfully populated.", 'ok'); define("CURRENT_DB", $params['db_name']); $peepagg_dsn = "mysql://" . $params['db_user'] . ":" . $params['db_password'] . "@" . $params['db_host'] . "/" . $params['db_name']; $this->peepagg_dsn = $peepagg_dsn; $this->admin_exsts = false; } else { $this->note("The installer is unable to execute MySQL queries.", 'error'); return false; } } else { $this->note("File <code>{$fn}</code> does not exists.", 'error'); return false; } } // Parag Jagdale - 10/17/10: end } else { define("CURRENT_DB", $params['db_name']); $peepagg_dsn = "mysql://" . $params['db_user'] . ":" . $params['db_password'] . "@" . $params['db_host'] . "/" . $params['db_name']; $this->peepagg_dsn = $peepagg_dsn; $this->admin_exists = $this->check_admin_exists($user_link); } // now run upgrade scripts $this->note("Running database upgrade script.", 'info'); try { $network_prefix = 'default'; require_once "web/update/run_scripts.php"; run_update_scripts(true); $this->note("The database was successfully upgraded.", 'ok'); } catch (Exception $e) { $this->note("Error updating database: " . $e->getMessage(), 'error'); return false; } return true; }
public function get_link_hosts() { $file = getShadowedPath('api/Comment/two-level-tlds.txt'); $content = ''; if ($file) { $content = file_get_contents($file); } $two_level_tlds = array_flip(explode("\n", $content)); $hosts = array(); foreach ($this->get_links() as $url => $linktexts) { $hostname_parsed = parse_url($url); $hostname_bits = explode(".", $hostname_parsed['host']); if (count($hostname_bits) < 2) { //$msg .= "<li>invalid hostname: ".htmlspecialchars($url)."</li>"; continue; } // chop off the last two $last_two = implode(".", array_slice($hostname_bits, -2)); // $top_domain_length = 3 for country domains like coffee.gen.nz, or = 2 for intl domains like topicexchange.com $top_domain_length = isset($two_level_tlds[$last_two]) ? 3 : 2; if (count($hostname_bits) < $top_domain_length) { //$msg .= "<li>invalid hostname (too short for CCTLD): ".htmlspecialchars($url)."</li>"; continue; } // extract the domain name (TLD + next host part) $domain = strtolower(implode(".", array_slice($hostname_bits, -$top_domain_length))); if (!isset($hosts[$domain])) { $hosts[$domain] = array(); } $hosts[$domain][] = array($url, $linktexts); } return $hosts; }
* For questions, help, comments, discussion, etc. please visit * https://github.com/CyberspaceNetworks/CoreSystem * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ include dirname(__FILE__) . "/../cnproject_config.php"; include dirname(__FILE__) . "/../cnautoload.php"; require_once dirname(__FILE__) . "/../cncore/web/includes/classes/CN.php"; require_once dirname(__FILE__) . "/../cncore/web/includes/classes/CNBootStrap.php"; require_once dirname(__FILE__) . "/../cncore/web/includes/classes/CNDispatcher.php"; require_once dirname(__FILE__) . "/../cncore/web/includes/classes/CNDownloadManager.php"; require_once dirname(__FILE__) . "/../cncore/api/CNProfiler/CNProfiler.php"; if (isset($_GET['profiler']) && $_GET['profiler'] == 1) { PA::$profiler = new PAProfiler(); PA::$profiler->startTimer('PADispatcher'); } $dispatcher = new PADispatcher($auto_load_list); // User.php must be included after a new PADispatcher object is created // otherwise the installation of CN breaks. require_once getShadowedPath('api/CNUser/CNUser.php'); $script = $dispatcher->dispatch(); if (PA::$profiler) { PA::$profiler->stopTimer('PADispatcher'); } if (PA::$profiler) { PA::$profiler->startTimer('Main Script', $script); } require_once $script; if (PA::$profiler) { PA::$profiler->stopTimer('Main Script'); } exit;
private function download() { switch ($this->file_type) { case 'json': if (!($json = getShadowedPath($this->file_path))) { self::$last_error = __(F_NOT_FOUND); return false; } $content_length = filesize($json); $this->doStatistics($content_length); header("Content-type: application/json; charset: UTF-8"); header("Cache-Control: no-cache, no-store, max-age=0, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Pragma: no-cache"); header("Content-Length: " . (int) $content_length); flush(); readfile($json); break; case 'xml': case 'xspf': if (!($xml = getShadowedPath($this->file_path))) { self::$last_error = __(F_NOT_FOUND); return false; } $content_length = filesize($xml); $this->doStatistics($content_length); header("Content-Type: application/{$this->file_type}; charset: UTF-8"); header("Cache-Control: no-cache, no-store, max-age=0, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Pragma: no-cache"); header("Content-Length: " . (int) $content_length); flush(); readfile($xml); break; case 'htm': case 'html': if (!($html = getShadowedPath($this->file_path))) { self::$last_error = __(F_NOT_FOUND); return false; } return $this->streamFiles($html, "text/html; charset: UTF-8"); break; case 'js': if (!($script = getShadowedPath($this->file_path))) { self::$last_error = __(F_NOT_FOUND); return false; } return $this->streamFiles($script, "text/javascript; charset: UTF-8"); break; case 'css': if (!($style = getShadowedPath($this->file_path))) { self::$last_error = __(F_NOT_FOUND); return false; } return $this->streamFiles($style, "text/css; charset: UTF-8"); break; case 'gif': case 'png': case 'jpg': case 'jpeg': // if($this->file_type == 'jpg') $this->file_type = 'jpeg'; if (!($image = getShadowedPath($this->file_path))) { self::$last_error = __(F_NOT_FOUND); return false; } return $this->streamFiles($image, "image/{$this->file_type}"); break; case "ico": if (!($style = getShadowedPath($this->file_path))) { self::$last_error = __(F_NOT_FOUND); return false; } return $this->streamFiles($style, "image/x-icon"); break; case "asf": case "avi": case "csv": case "doc": case "docx": case "exe": case "cab": case "jar": case "mov": case "mp3": case "mpg": case "mpeg": case "pdf": case "ppt": case "pptx": case "rar": case "txt": case "htc": case "wav": case "wma": case "wmv": case "zip": case "swf": if (!($file_download = getShadowedPath($this->file_path))) { self::$last_error = __(F_NOT_FOUND); return false; } return $this->streamDownloads($file_download, $this->file_type); break; default: self::$last_error = __(F_NOT_ALLOW); return false; } return true; }
<?php /** ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * [filename] is a part of PeopleAggregator. * [description including history] * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @author [creator, or "Original Author"] * @license http://bit.ly/aVWqRV PayAsYouGo License * @copyright Copyright (c) 2010 Broadband Mechanics * @package PeopleAggregator */ //require_once dirname(__FILE__)."/../config.inc"; // global var $path_prefix has been removed - please, use PA::$path static variable //require_once "web/includes/functions/html_generate.php"; //require_once "web/includes/functions/validations.php"; //require_once "api/User/User.php"; require_once "api/Theme/Template.php"; $theme_url = PA::$theme_url; $uname = empty($_SESSION['user']['name']) ? '' : htmlspecialchars($_SESSION['user']['name']); $template_file = getShadowedPath('web/Themes/Default/maintenance.tpl'); $template = new Template($template_file); $template->set('theme_url', $theme_url); $template->set('uname', $uname); echo $template->fetch();
* */ /** This file is used to change the skin of the network. * Anonymous user can not access this page; */ error_reporting(E_ALL); $login_required = TRUE; //including necessary files $use_theme = 'Beta'; //TODO : Remove this when new UI is completely implemented. include_once "web/includes/page.php"; require_once "web/includes/network.inc.php"; // For authentication $error = FALSE; if (!empty($_POST)) { $file = getShadowedPath('config/domain_names.txt'); if (!$file || !($handle = fopen($file, 'w+'))) { $msg = 5040; $error = TRUE; } if (fwrite($handle, $_POST['file_text']) === FALSE) { $msg = 5041; $error = TRUE; } fclose($handle); if (!$error) { $msg = 5042; } } function setup_module($column, $module, $obj) {
private function GET_step_3($params) { global $app; if ($this->error) { return $this->msg_unable_to_continue($params); } list($info, $results) = $this->get_config_section('database', "@readonly='false'"); $section_name = $info['name']; $form = new PAForm('pa_inst'); $form->openTag('fieldset'); $form->addContentTag('legend', array('value' => $info['description'])); $form->addHtml('<p class="inst_info">' . __('If you are upgrading from an existing PeopleAggregator install, you can choose to use an existing database. Otherwise, a new database should be created.') . '</p>'); $form->addHtml('<div>'); $form->addHtml('<ol style="list-style:none; line-height:20px;"><li>Create New Database'); $form->addInputTag('radio', array('id' => 'create_db', 'name' => 'pa_inst[create_db]', 'value' => 'true', 'checked' => 'true')); $form->addHtml('</li><li>Use Existing Database'); $form->addInputTag('radio', array('id' => 'use_existing_db', 'name' => 'pa_inst[create_db]', 'value' => 'false')); $form->addHtml('</div>'); $form->addHtml('<div>'); $form->addHtml('<p class="inst_info">' . __('Please complete the following information so PeopleAggregator can access your database.') . '</p>'); $form->addInputField('text', __('Database name'), array('id' => 'db_name', 'required' => true, 'value' => '')); $form->addInputField('text', __('Database host'), array('id' => 'db_host', 'required' => true, 'value' => '')); /* foreach($results as $key => $data) { $form->addInputField('text', $data['attributes']['description'], array('id' => $key, 'required' => true, 'value' => $data['value']) ); }*/ $form->addHtml('<p class="inst_info">' . __('Please provide PeopleAggregator with a MySQL username and password for the database.') . '</p>'); $form->addInputField('text', __('Database User Name'), array('id' => 'db_user', 'required' => true, 'value' => '')); $form->addInputField('password', __('Database password'), array('id' => 'db_password', 'required' => true, 'value' => '')); $form->addHtml('<p class="inst_info root_info">' . __('If you would like PeopleAggregator to create this user for you, please provide your MySQL root password.') . '</p>'); $form->addInputField('text', __('MySQL root username'), array('id' => 'mysql_root_username', 'required' => false, 'value' => '', 'css_class' => 'field root_info')); $form->addInputField('password', __('MySQL root password'), array('id' => 'mysql_root_password', 'required' => false, 'value' => '', 'css_class' => 'field root_info')); // Parag Jagdale - 10/17/10: If a seed file and a structure file is detected, we can offer the administrator the option to seed their database // during installation with seed data. This is useful during the development phase of a project, or when creating a // fresh installation. // TODO: test this with seed and structure file in /PACORE, not just /PAPROJECT if (getShadowedPath("web/install/PeepAgg.structure.mysql")) { if ($sql_file = getShadowedPath("web/install/PeepAgg.seed.mysql")) { $form->addHtml('<p class="inst_info seed_field">' . __('PeopleAggregator has detected a seed file. Check the box below if you wish to insert seed data from the file.</p>')); $form->addInputField('checkbox', __('Insert seed data from ' . basename($sql_file)), array('id' => 'insert_seed_data', 'required' => false, 'value' => '', 'css_class' => 'field seed_field')); } } // Parag Jagdale - 10/17/10 end $form->addInputTag('hidden', array('id' => 'section_name', 'value' => $section_name)); $form->addHtml('</div>'); $form->closeTag('fieldset'); $html = $form->getHtml(); $nav = "\n <a class='bt back' href='?step=" . ($this->curr_step > 1 ? $this->curr_step - 1 : 1) . "' alt='previous'></a>\n <a class='bt submit' href='#' alt='submit' onclick='document.forms[\"pa_inst\"].submit();'></a>\n "; $data = array('message' => !empty($params['message']) ? $params['message'] : '', 'title' => $params['title'], 'step' => $this->curr_step, 'navig' => $nav, 'content' => $html); return $data; }