Project

General

Profile

« Previous | Next » 

Revision 1891

Added by Dietmar over 11 years ago

! update captcha_control module set version to 1.2.1

View differences:

upgrade.php
14 14
 * @lastmodified    $Date$
15 15
 *
16 16
 */
17

  
18
// prevent this file from being accessed directly
17
// Must include code to stop this file being access directly
19 18
/* -------------------------------------------------------- */
20
if(defined('WB_PATH') == false)
21
{
22
	// Stop this file being access directly
23
		die('<head><title>Access denied</title></head><body><h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2></body></html>');
19
// Must include code to stop this file being accessed directly
20
if(!defined('WB_URL')) {
21
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
22
	throw new IllegalFileException();
24 23
}
25 24
/* -------------------------------------------------------- */
26
$msg = '';
27
$sTable = TABLE_PREFIX.'mod_captcha_control';
28
if(($sOldType = $database->getTableEngine($sTable))) {
29
	if(('myisam' != strtolower($sOldType))) {
30
		if(!$database->query('ALTER TABLE `'.$sTable.'` Engine = \'MyISAM\' ')) {
31
			$msg = $database->get_error();
25

  
26
	function mod_captcha_control_upgrade($bDebug=false) {
27
		global $OK ,$FAIL;
28
		$database=WbDatabase::getInstance();
29
		$msg = array();
30
		$callingScript = $_SERVER["SCRIPT_NAME"];
31
		// check if upgrade startet by upgrade-script to echo a message
32
		$tmp = 'upgrade-script.php';
33
		$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
34
// check for missing tables, if true stop the upgrade
35
		$aTable = array('mod_captcha_control');
36
		$aPackage = UpgradeHelper::existsAllTables($aTable);
37
		if( sizeof($aPackage) > 0){
38
			$msg[] =  'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ',$aPackage).' missing! '.$FAIL;
39
			$msg[] = 'Captcha control upgrade failed'." $FAIL";
40
			if($globalStarted) {
41
				echo '<strong>'.implode('<br />',$msg).'</strong><br />';
42
			}
43
			return ( ($globalStarted==true ) ? $globalStarted : $msg);
44
		} else {
45
			for($x=0; $x<sizeof($aTable);$x++) {
46
				if(($sOldType = $database->getTableEngine($database->TablePrefix.$aTable[$x]))) {
47
					if(('myisam' != strtolower($sOldType))) {
48
						if(!$database->query('ALTER TABLE `'.$database->TablePrefix.$aTable[$x].'` Engine = \'MyISAM\' ')) {
49
							$msg[] = $database->get_error();
50
						} else{
51
							$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` changed to Engine = \'MyISAM\''." $OK";
52
						}
53
					} else {
54
						$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` has Engine = \'MyISAM\''." $OK";
55
					}
56
				} else {
57
					$msg[] = $database->get_error();
58
				}
59
			}
60
// change table structure
61
			$sTable = $database->TablePrefix.'mod_captcha_control';
62
			$sDescription = 'int(11) NOT NULL DEFAULT \'1\'';
63
			$sFieldName = 'enabled_captcha';
64
			if(!$database->field_modify($sTable,$sFieldName,$sDescription)) {
65
				$msg[] = ''.$database->get_error();
66
			} else {
67
				$msg[] = 'Field ( `enabled_captcha` ) description has been changed successfully'." $OK";
68
			}
69
			$sFieldName = 'enabled_asp';
70
			if(!$database->field_modify($sTable,$sFieldName,$sDescription)) {
71
				$msg[] = ''.$database->get_error();
72
			} else {
73
				$msg[] = 'Field ( `enabled_asp` ) description has been changed successfully'." $OK";
74
			}
75
// only for upgrade-script
76
			if($globalStarted) {
77
				if($bDebug) {
78
					echo '<strong>'.implode('<br />',$msg).'</strong><br />';
79
				}
80
			}
32 81
		}
82
		$msg[] = 'Captcha control upgrade successfull finished '." $OK";
83
		if($globalStarted) {
84
			echo "<strong>Captcha control upgrade successfull finished $OK</strong><br />";
85
		}
86
		return ( ($globalStarted==true ) ? $globalStarted : $msg);
33 87
	}
34
} else {
35
	$msg = $database->get_error();
88
// ------------------------------------
89

  
90
$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
91
// Don't show the messages twice
92
if( is_array($msg = mod_captcha_control_upgrade($bDebugModus)) ) {
93
	echo '<strong>'.implode('<br />',$msg).'</strong><br />';
36 94
}
37
// ------------------------------------

Also available in: Unified diff