Revision 1420
Added by Dietmar almost 14 years ago
install.php | ||
---|---|---|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category module |
|
5 |
* @package droplet |
|
6 |
* @author Ruud Eisinga (Ruud) John (PCWacht) |
|
7 |
* @author WebsiteBaker Project |
|
8 |
* @copyright 2004-2009, Ryan Djurovich |
|
9 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
10 |
* @link http://www.websitebaker2.org/ |
|
11 |
* @license http://www.gnu.org/licenses/gpl.html |
|
12 |
* @platform WebsiteBaker 2.8.x |
|
13 |
* @requirements PHP 5.2.2 and higher |
|
14 |
* @version $Id$ |
|
15 |
* @filesource $HeadURL$ |
|
16 |
* @lastmodified $Date$ |
|
17 |
* |
|
18 |
*/ |
|
19 |
|
|
20 |
// prevent this file from being accessed directly |
|
21 |
if(!defined('WB_PATH')) die(header('Location: ../../index.php')); |
|
22 |
|
|
23 |
global $admin; |
|
24 |
|
|
25 |
$table = TABLE_PREFIX .'mod_droplets'; |
|
26 |
$database->query("DROP TABLE IF EXISTS `$table`"); |
|
27 |
|
|
28 |
$database->query("CREATE TABLE `$table` ( |
|
29 |
`id` INT NOT NULL auto_increment, |
|
30 |
`name` VARCHAR(32) NOT NULL, |
|
31 |
`code` LONGTEXT NOT NULL , |
|
32 |
`description` TEXT NOT NULL, |
|
33 |
`modified_when` INT NOT NULL default '0', |
|
34 |
`modified_by` INT NOT NULL default '0', |
|
35 |
`active` INT NOT NULL default '0', |
|
36 |
`admin_edit` INT NOT NULL default '0', |
|
37 |
`admin_view` INT NOT NULL default '0', |
|
38 |
`show_wysiwyg` INT NOT NULL default '0', |
|
39 |
`comments` TEXT NOT NULL, |
|
40 |
PRIMARY KEY ( `id` ) |
|
41 |
)" |
|
42 |
); |
|
43 |
|
|
44 |
//add all droplets from the droplet subdirectory |
|
45 |
$folder=opendir(WB_PATH.'/modules/droplets/example/.'); |
|
46 |
$names = array(); |
|
47 |
while ($file = readdir($folder)) { |
|
48 |
$ext=strtolower(substr($file,-4)); |
|
49 |
if ($ext==".php"){ |
|
50 |
if ($file<>"index.php" ) { |
|
51 |
$names[count($names)] = $file; |
|
52 |
} |
|
53 |
} |
|
54 |
} |
|
55 |
closedir($folder); |
|
56 |
|
|
57 |
foreach ($names as $dropfile) { |
|
58 |
$droplet = addslashes(getDropletCodeFromFile($dropfile)); |
|
59 |
if ($droplet != "") { |
|
60 |
$description = "Example Droplet"; |
|
61 |
$comments = "Example Droplet"; |
|
62 |
$cArray = explode("\n",$droplet); |
|
63 |
if (substr($cArray[0],0,3) == "//:") { |
|
64 |
$description = trim(substr($cArray[0],3)); |
|
65 |
array_shift ( $cArray ); |
|
66 |
} |
|
67 |
if (substr($cArray[0],0,3) == "//:") { |
|
68 |
$comments = trim(substr($cArray[0],3)); |
|
69 |
array_shift ( $cArray ); |
|
70 |
} |
|
71 |
$droplet = implode ( "\n", $cArray ); |
|
72 |
$name = substr($dropfile,0,-4); |
|
73 |
$modified_when = time(); |
|
74 |
$modified_by = method_exists($admin, 'get_user_id') ? $admin->get_user_id() : 1; |
|
75 |
$database->query("INSERT INTO `$table` |
|
76 |
(name, code, description, comments, active, modified_when, modified_by) |
|
77 |
VALUES |
|
78 |
('$name', '$droplet', '$description', '$comments', '1', '$modified_when', '$modified_by')"); |
|
79 |
|
|
80 |
// do not output anything if this script is called during fresh installation |
|
81 |
if (method_exists($admin, 'get_user_id')) echo "Droplet import: $name<br/>"; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
function getDropletCodeFromFile ( $dropletfile ) { |
|
86 |
$data = ""; |
|
87 |
$filename = WB_PATH."/modules/droplets/example/".$dropletfile; |
|
88 |
if (file_exists($filename)) { |
|
89 |
$filehandle = fopen ($filename, "r"); |
|
90 |
$data = fread ($filehandle, filesize ($filename)); |
|
91 |
fclose($filehandle); |
|
92 |
// unlink($filename); doesnt work in unix |
|
93 |
} |
|
94 |
return $data; |
|
95 |
} |
|
1 |
<?php |
|
2 |
/** |
|
3 |
* |
|
4 |
* @category module |
|
5 |
* @package droplet |
|
6 |
* @author Ruud Eisinga (Ruud) John (PCWacht) |
|
7 |
* @author WebsiteBaker Project |
|
8 |
* @copyright 2004-2009, Ryan Djurovich |
|
9 |
* @copyright 2009-2011, Website Baker Org. e.V. |
|
10 |
* @link http://www.websitebaker2.org/ |
|
11 |
* @license http://www.gnu.org/licenses/gpl.html |
|
12 |
* @platform WebsiteBaker 2.8.x |
|
13 |
* @requirements PHP 5.2.2 and higher |
|
14 |
* @version $Id$ |
|
15 |
* @filesource $HeadURL$ |
|
16 |
* @lastmodified $Date$ |
|
17 |
* |
|
18 |
*/ |
|
19 |
// Must include code to stop this file being access directly |
|
20 |
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); } |
|
21 |
|
|
22 |
global $admin; |
|
23 |
|
|
24 |
$table = TABLE_PREFIX .'mod_droplets'; |
|
25 |
$database->query("DROP TABLE IF EXISTS `$table`"); |
|
26 |
|
|
27 |
$database->query("CREATE TABLE `$table` ( |
|
28 |
`id` INT NOT NULL auto_increment, |
|
29 |
`name` VARCHAR(32) NOT NULL, |
|
30 |
`code` LONGTEXT NOT NULL , |
|
31 |
`description` TEXT NOT NULL, |
|
32 |
`modified_when` INT NOT NULL default '0', |
|
33 |
`modified_by` INT NOT NULL default '0', |
|
34 |
`active` INT NOT NULL default '0', |
|
35 |
`admin_edit` INT NOT NULL default '0', |
|
36 |
`admin_view` INT NOT NULL default '0', |
|
37 |
`show_wysiwyg` INT NOT NULL default '0', |
|
38 |
`comments` TEXT NOT NULL, |
|
39 |
PRIMARY KEY ( `id` ) |
|
40 |
)" |
|
41 |
); |
|
42 |
|
|
43 |
//add all droplets from the droplet subdirectory |
|
44 |
$folder=opendir(WB_PATH.'/modules/droplets/example/.'); |
|
45 |
$names = array(); |
|
46 |
while ($file = readdir($folder)) { |
|
47 |
$ext=strtolower(substr($file,-4)); |
|
48 |
if ($ext==".php"){ |
|
49 |
if ($file<>"index.php" ) { |
|
50 |
$names[count($names)] = $file; |
|
51 |
} |
|
52 |
} |
|
53 |
} |
|
54 |
closedir($folder); |
|
55 |
|
|
56 |
foreach ($names as $dropfile) { |
|
57 |
$droplet = addslashes(getDropletCodeFromFile($dropfile)); |
|
58 |
if ($droplet != "") { |
|
59 |
$description = "Example Droplet"; |
|
60 |
$comments = "Example Droplet"; |
|
61 |
$cArray = explode("\n",$droplet); |
|
62 |
if (substr($cArray[0],0,3) == "//:") { |
|
63 |
$description = trim(substr($cArray[0],3)); |
|
64 |
array_shift ( $cArray ); |
|
65 |
} |
|
66 |
if (substr($cArray[0],0,3) == "//:") { |
|
67 |
$comments = trim(substr($cArray[0],3)); |
|
68 |
array_shift ( $cArray ); |
|
69 |
} |
|
70 |
$droplet = implode ( "\n", $cArray ); |
|
71 |
$name = substr($dropfile,0,-4); |
|
72 |
$modified_when = time(); |
|
73 |
$modified_by = method_exists($admin, 'get_user_id') ? $admin->get_user_id() : 1; |
|
74 |
$database->query("INSERT INTO `$table` |
|
75 |
(name, code, description, comments, active, modified_when, modified_by) |
|
76 |
VALUES |
|
77 |
('$name', '$droplet', '$description', '$comments', '1', '$modified_when', '$modified_by')"); |
|
78 |
|
|
79 |
// do not output anything if this script is called during fresh installation |
|
80 |
if (method_exists($admin, 'get_user_id')) echo "Droplet import: $name<br/>"; |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
function getDropletCodeFromFile ( $dropletfile ) { |
|
85 |
$data = ""; |
|
86 |
$filename = WB_PATH."/modules/droplets/example/".$dropletfile; |
|
87 |
if (file_exists($filename)) { |
|
88 |
$filehandle = fopen ($filename, "r"); |
|
89 |
$data = fread ($filehandle, filesize ($filename)); |
|
90 |
fclose($filehandle); |
|
91 |
// unlink($filename); doesnt work in unix |
|
92 |
} |
|
93 |
return $data; |
|
94 |
} |
|
96 | 95 |
?> |
Also available in: Unified diff
YGN Ethical Hacker Group (2.8.2 / 2.9.0)