· 8 years ago · Aug 01, 2018, 08:32 AM
1<?php
2
3
4define('DEMO_SETUP_SITE', 'xxx');
5define('DEMO_DB_SERVER', 'xxxx');
6define('DEMO_DB_USERNAME', 'xxx');
7define('DEMO_DB_PASSWORD', 'xxxx');
8define('DEMO_DB_DATABASE', 'mnkras29');
9define('DEMO_ADMIN_EMAIL', 'admin@xxx.com');
10define('DEMO_ADMIN_PASSWORD', 'admin'); // CHANGE THIS
11define('DEMO_USER_USERNAME', 'demo'); // This user will be the administrative user given out to visitors to the demo.
12define('DEMO_USER_EMAIL', 'demo@xxx.com');
13define('DEMO_USER_PASSWORD', 'demo');
14define('PASSWORD_SALT', 'xxxx');
15define('MANUAL_PASSWORD_SALT', 'xxxx');
16define('PACKAGES_TO_INSTALL', 'advertisement,asmiller_gallery,blog,calendar,code_blocks,comet_chat,contact_directory,core_commerce,core_commerce_ups,datadisplay,date_nav,davidmirv_core_commerce_fedex,defunct_social_icons,defunct_testimonials,discussion,document_library,expandable_content,flash_audio,flash_embed,flash_gallery,flash_video,flickr,gallery,get_directions,google_gadget,iframe,jereme_my_gamer_card,jereme_tweetcrete,kenburns,login,markdown,matogertel_area_splitter,message_of_the_day,music,pageear,paymate,paypal_donations_box,premium_google_map,randomizer,remo_equation,remo_expand,reviews,ryan_page_value,scrapbook_tabs,si_browser_update,si_mysql_optimize,simplecast,simpleevent,simplenews,simpleprofessional,sisimizis_download_folder,superfish,syntax_highlighter,textfiletable,theme_column_cruiser,theme_corporateamerica,theme_dreamy,theme_featuring,theme_fluidity,theme_halloween,theme_innovation,theme_lazydays,theme_loadfoov2,theme_mint_chocolate_chip,theme_natural_essence,theme_neuphoric,theme_officespace,theme_orange_sunset,theme_orangeandblack,theme_saltpepper,theme_squarely,theme_touching,theme_whitespace,tony_billboards,tony_file_details,tony_mailing_list,tony_next_previous,tony_popup,tony_pro_photo,tony_stats,tony_user_info,travisn_spacer,viddler,vimeo,zoom_image'); // separate with a comma. These must be in your packages/ directory
17//define('PACKAGES_TO_INSTALL', 'advertisement,asmiller_gallery'); // separate with a comma. These must be in your packages/ directory
18
19
20
21error_reporting(E_ALL ^ E_NOTICE);
22ini_set('display_errors', 1);
23define('C5_ENVIRONMENT_ONLY', true);
24define('DISPATCHER_FILENAME', 'reset.php');
25require('concrete/dispatcher.php');
26
27// Remove config/site.php
28unlink(DIR_CONFIG_SITE . '/site.php');
29echo "Deleteted site.php <br>";
30// Remove all files from the files directory
31function removeDemoFiles($path) {
32 // Add trailing slash to $path if one is not there
33 if (substr($path, -1, 1) != "/") $path .= "/";
34 foreach (glob($path . "*") as $file) {
35 // Remove each file in this Directory
36 if (is_file($file) === TRUE) {
37 unlink($file);
38 echo "Removed File:".$file."<br>";
39 } else if (is_dir($file) === TRUE) {
40 removeDemoFiles($file);
41 }
42 }
43 // Remove Directory once Files have been removed (If Exists)
44 if (is_dir($path) === TRUE && $path != DIR_FILES_UPLOADED . '/') {
45 rmdir($path);
46 echo 'Removed directory: ' . $path . '<br>';
47 }
48}
49removeDemoFiles(DIR_FILES_UPLOADED . '/');
50
51// Reset the database
52$db = Loader::db();
53$tables = $db->GetCol('show tables from ' . DEMO_DB_DATABASE);
54foreach($tables as $t) {
55 $db->Execute('drop table ' . DEMO_DB_DATABASE . '.' . $t);
56}
57echo "cleared tables <br>";
58// reinstall.
59$data = array();
60$data['DB_SERVER'] = DEMO_DB_SERVER;
61$data['DB_USERNAME'] = DEMO_DB_USERNAME;
62$data['DB_PASSWORD'] = DEMO_DB_PASSWORD;
63$data['DB_DATABASE'] = DEMO_DB_DATABASE;
64$data['SITE'] = DEMO_SETUP_SITE;
65$data['uEmail'] = DEMO_ADMIN_EMAIL;
66$data['uPassword'] = DEMO_ADMIN_PASSWORD;
67$data['INSTALL_SAMPLE_CONTENT'] = 1;
68
69// note - since the install routine references $_POST directly we have to
70// set our post to our $data array
71$_POST = $data;
72
73// reinstall
74Loader::controller('/install');
75$installController = new InstallController();
76$installController->setInstallData($data);
77$installController->configure();
78
79$u = new User();
80$u->logout();
81
82// Setup registration options
83
84Config::save('ENABLE_USER_PROFILES', true);
85Config::save('ENABLE_REGISTRATION_CAPTCHA', true);
86Config::save('ENABLE_REGISTRATION', true);
87Config::save('USER_VALIDATE_EMAIL', false);
88Config::save('USER_VALIDATE_EMAIL_REQUIRED', false);
89Config::save('USER_REGISTRATION_APPROVAL_REQUIRED', false);
90Config::save('ENABLE_CACHE', 0);
91Config::save('ENABLE_MARKETPLACE_SUPPORT', 0 );
92
93// create the demo user that has some limited administrative access
94$data = array();
95$data['uName'] = DEMO_USER_USERNAME;
96$data['uEmail'] = DEMO_USER_EMAIL;
97$data['uPassword'] = DEMO_USER_PASSWORD;
98$data['uPasswordConfirm'] = DEMO_USER_PASSWORD;
99$demoUser = UserInfo::register($data);
100$adminGroup = Group::getByID(ADMIN_GROUP_ID);
101$demoU = $demoUser->getUserObject();
102$demoU->enterGroup($adminGroup);
103
104// Lock down file set permissions
105Loader::model('file_set');
106$fs = FileSet::getGlobal();
107$fs->setPermissions($adminGroup, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_ALL, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE, FilePermissions::PTYPE_NONE);
108
109// Disable emails on site.
110$configFile = DIR_BASE."/config/site.php";
111$fp = fopen($configFile,'a');
112fwrite($fp, "
113<?php define('ENABLE_EMAILS', false); ?>");
114fwrite($fp, "
115<?php define('REDIRECT_TO_BASE_URL', false); ?>");
116fwrite($fp, "
117<?php define('UPLOAD_FILE_EXTENSIONS_CONFIGURABLE', false); ?>");
118fclose($fp);
119echo "Wrote config <br>";
120// finally, we install the packages we wish to install.
121// These must be located in the root packages/ directory
122echo "Installing packages <br>";
123$packages = explode(',',PACKAGES_TO_INSTALL);
124foreach($packages as $pkgHandle) {
125 $pkgHandle = trim($pkgHandle);
126 $pkg = @Loader::package($pkgHandle);
127 echo 'Installed Package: ' . $pkgHandle . '<br>';
128 if (is_object($pkg)) {
129 @$pkg->install();
130 }
131}
132echo "Done!";
133?>