Project

General

Profile

« Previous | Next » 

Revision 1503

Added by Dietmar over 13 years ago

change sql statements to strict in module droplets
fix vars in compatibility mode for versions before 2.8.1 in frontend.functions.php

View differences:

install.php
16 16
 * @lastmodified    $Date$
17 17
 *
18 18
 */
19
// Must include code to stop this file being access directly
20
if(defined('WB_PATH') == false) { die("Cannot access this file directly"); }
19
/* -------------------------------------------------------- */
20
// Must include code to stop this file being accessed directly
21
if(!defined('WB_PATH')) {
21 22

  
23
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
24
	throw new IllegalFileException();
25
}
26
/* -------------------------------------------------------- */
27

  
22 28
global $admin;
23 29

  
24
$table = TABLE_PREFIX .'mod_droplets';
25
$database->query("DROP TABLE IF EXISTS `$table`");
30
$sql  = 'DROP TABLE IF EXISTS `'.TABLE_PREFIX.'mod_droplets` ';
31
$database->query($sql);
26 32

  
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
);
33
$sql  = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_droplets` ( ';
34
$sql .= '`id` INT NOT NULL auto_increment, ';
35
$sql .= '`name` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci  NOT NULL, ';
36
$sql .= '`code` LONGTEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci  NOT NULL , ';
37
$sql .= '`description` TEXT  CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, ';
38
$sql .= '`modified_when` INT NOT NULL default \'0\', ';
39
$sql .= '`modified_by` INT NOT NULL default \'0\', ';
40
$sql .= '`active` INT NOT NULL default \'0\', ';
41
$sql .= '`admin_edit` INT NOT NULL default \'0\', ';
42
$sql .= '`admin_view` INT NOT NULL default \'0\', ';
43
$sql .= '`show_wysiwyg` INT NOT NULL default \'0\', ';
44
$sql .= '`comments` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci  NOT NULL, ';
45
$sql .= 'PRIMARY KEY ( `id` ) ';
46
$sql .= ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
47
$database->query($sql);
42 48

  
43 49
//add all droplets from the droplet subdirectory
44
$folder=opendir(WB_PATH.'/modules/droplets/example/.'); 
50
$folder=opendir(WB_PATH.'/modules/droplets/example/.');
45 51
$names = array();
46 52
while ($file = readdir($folder)) {
47 53
	$ext=strtolower(substr($file,-4));
48 54
	if ($ext==".php"){
49 55
		if ($file<>"index.php" ) {
50
			$names[count($names)] = $file; 
56
			$names[count($names)] = $file;
51 57
		}
52 58
	}
53 59
}
......
71 77
		$name = substr($dropfile,0,-4);
72 78
		$modified_when = time();
73 79
		$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')");
80
		$sql  = 'INSERT INTO `'.TABLE_PREFIX.'mod_droplets` SET ';
81
		$sql .= '`name` = \''.$name.'\', ';
82
		$sql .= '`code` = \''.$droplet.'\', ';
83
		$sql .= '`description` = \''.$description.'\', ';
84
		$sql .= '`comments` = \''.$comments.'\', ';
85
		$sql .= '`active` = 1, ';
86
		$sql .= '`modified_when` = '.$modified_when.', ';
87
		$sql .= '`modified_by` = '.$modified_by;
88
		$database->query($sql);
78 89
		
79 90
		// do not output anything if this script is called during fresh installation
80 91
		if (method_exists($admin, 'get_user_id')) echo "Droplet import: $name<br/>";
81
	}  
92
	}
82 93
}
83 94

  
84 95
function getDropletCodeFromFile ( $dropletfile ) {
85
	$data = "";
96
	$data = '';
86 97
	$filename = WB_PATH."/modules/droplets/example/".$dropletfile;
87 98
	if (file_exists($filename)) {
88 99
		$filehandle = fopen ($filename, "r");
......
92 103
	}	
93 104
	return $data;
94 105
}
95
?>

Also available in: Unified diff