$tableArray = explode(' ', $sql);
$tableName = str_replace('`', '', $tableArray[2]);
+ // Debug log
+ /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ',tableName=' . $tableName);
+
// Shall we add/drop?
if (((strpos($sql, 'ADD') !== false) || (strpos($sql, 'DROP') !== false) || (strpos($sql, 'CHANGE') !== false)) && ($noIndex === true)) {
// Try two columns, one should fix
foreach (array(4,5) as $idx) {
+ // If an entry is not set, abort here
+ if (!isset($tableArray[$idx])) {
+ // Debug log this
+ logDebugMessage(__FUNCTION__, __LINE__, 'columnName=' . $columnName . ',idx=' . $idx . ',sql=' . $sql . ' is missing!');
+ } // END - if
+
// And column name as well
$columnName = str_replace('`', '', $tableArray[$idx]);
// Abort here because it is alreay there
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Skipped: ' . $sql);
break;
+ } elseif ((SQL_HASZERONUMS($result)) && (strpos($sql, 'DROP') !== false)) {
+ // Abort here because we tried to drop a column which is not there (never created maybe)
+ break;
} elseif ($columnName != 'KEY') {
// Something didn't fit, we better log it
logDebugMessage(__FUNCTION__, __LINE__, 'Possible problem: ' . $sql . ',hasZeroNums=' . intval(SQL_HASZERONUMS($result)) . '');
break;
case '0.2.4': // SQL queries for v0.2.4
- $auto_type = 'png'; // PNG image is the default
- if ((isIncludeReadable('theme/'.getCurrentTheme().'/images/code_bg.jpg')) && function_exists('imagecreatefromjpeg')) {
+ // PNG image is the default
+ $auto_type = 'png';
+
+ // Is the JPEG file found and required PHP function there?
+ if ((isFileReadable(getPath() . 'theme/' . getCurrentTheme() . '/images/code_bg.jpg')) && function_exists('imagecreatefromjpeg')) {
// Switch to JPEG format
$auto_type = 'jpg';
- }
+ } // END - if
addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_config` ADD `img_type` ENUM('jpg','png') NOT NULL DEFAULT '" . $auto_type . "'");
// Update notes (these will be set as task text!)
break;
case '0.6.8': // SQL queries for v0.6.8
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_admin_menu`
-CHANGE `action` `action` VARCHAR(50) NOT NULL,
-CHANGE `what` `what` VARCHAR(50) NULL DEFAULT NULL');
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_guest_menu`
-CHANGE `action` `action` VARCHAR(50) NOT NULL,
-CHANGE `what` `what` VARCHAR(50) NULL DEFAULT NULL');
- addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_member_menu`
-CHANGE `action` `action` VARCHAR(50) NOT NULL,
-CHANGE `what` `what` VARCHAR(50) NULL DEFAULT NULL');
+ addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_admin_menu` CHANGE `action` `action` VARCHAR(50) NOT NULL');
+ addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_admin_menu` CHANGE `what` `what` VARCHAR(50) NULL DEFAULT NULL');
+ addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_guest_menu` CHANGE `action` `action` VARCHAR(50) NOT NULL');
+ addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_admin_menu` CHANGE `what` `what` VARCHAR(50) NULL DEFAULT NULL');
+ addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_member_menu` CHANGE `action` `action` VARCHAR(50) NOT NULL');
+ addExtensionSql('ALTER TABLE `{?_MYSQL_PREFIX?}_admin_menu` CHANGE `what` `what` VARCHAR(50) NULL DEFAULT NULL');
// Update notes (these will be set as task text!)
setExtensionUpdateNotes("Spalten verkürzt, damit die Schlüssel passen.");
// Insert the code in $img_code into jpeg or PNG image
function generateImageOrCode ($img_code, $headerSent = true) {
// Is the code size oversized or shouldn't we display it?
- if ((strlen($img_code) > 6) || (empty($img_code)) || (getConfig('code_length') == '0')) {
+ if ((strlen($img_code) > 6) || (empty($img_code)) || (getCodeLength() == '0')) {
// Stop execution of function here because of over-sized code length
- debug_report_bug(__FUNCTION__, __LINE__, 'img_code ' . $img_code .' has invalid length. img_code()=' . strlen($img_code) . ' code_length=' . getConfig('code_length'));
+ debug_report_bug(__FUNCTION__, __LINE__, 'img_code ' . $img_code .' has invalid length. img_code()=' . strlen($img_code) . ' code_length=' . getCodeLength());
} elseif ($headerSent === false) {
// Return an HTML code here
return '<img src="{%url=img.php?code=' . $img_code . '%}" alt="Image" />';
$img = sprintf("%s/theme/%s/images/code_bg.%s",
getPath(),
getCurrentTheme(),
- getConfig('img_type')
+ getImgType()
);
// Is it readable?
if (isFileReadable($img)) {
// Switch image type
- switch (getConfig('img_type')) {
- case 'jpg':
- // Okay, load image and hide all errors
+ switch (getImgType()) {
+ case 'jpg': // Okay, load image and hide all errors
$image = imagecreatefromjpeg($img);
break;
- case 'png':
- // Okay, load image and hide all errors
+ case 'png': // Okay, load image and hide all errors
$image = imagecreatefrompng($img);
break;
} // END - switch
} else {
- // Exit function here
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("File for image type %s not found.", getConfig('img_type')));
+ // Silently log the error
+ logDebugMessage(__FUNCTION__, __LINE__, sprintf("File for image-type %s in theme %s not found.", getImgType(), getCurrentTheme()));
return;
}
imagestring($image, 5, 14, 2, $img_code, $text_color);
// Return to browser
- setContentType('image/' . getConfig('img_type'));
+ setContentType('image/' . getImgType());
// Output image with matching image factory
- switch (getConfig('img_type')) {
+ switch (getImgType()) {
case 'jpg': imagejpeg($image); break;
case 'png': imagepng($image); break;
} // END - switch
// Output error messages in a fasioned way and die...
function app_die ($F, $L, $message) {
// Check if Script is already dieing and not let it kill itself another 1000 times
- if (!isset($GLOBALS['app_died'])) {
- // Make sure, that the script realy realy diese here and now
- $GLOBALS['app_died'] = true;
+ if (isset($GLOBALS['app_died'])) {
+ // Script tried to kill itself twice
+ die('[' . __FUNCTION__ . ':' . __LINE__ . ']: Script wanted to kill itself more than once! Raw message=' . $message . ', file/function=' . $F . ', line=' . $L);
+ } // END - if
- // Set content type as text/html
- setContentType('text/html');
+ // Make sure, that the script realy realy diese here and now
+ $GLOBALS['app_died'] = true;
- // Load header
- loadIncludeOnce('inc/header.php');
+ // Set content type as text/html
+ setContentType('text/html');
- // Rewrite message for output
- $message = sprintf(getMessage('MAILER_HAS_DIED'), basename($F), $L, $message);
+ // Load header
+ loadIncludeOnce('inc/header.php');
- // Load the message template
- loadTemplate('app_die_message', false, $message);
+ // Rewrite message for output
+ $message = sprintf(getMessage('MAILER_HAS_DIED'), basename($F), $L, $message);
- // Load footer
- loadIncludeOnce('inc/footer.php');
- } else {
- // Script tried to kill itself twice
- die('['.__FUNCTION__.':'.__LINE__.']: Script wanted to kill itself more than once! Raw message=' . $message . ', file/function=' . $F . ', line=' . $L);
- }
+ // Load the message template
+ loadTemplate('app_die_message', false, $message);
+
+ // Load footer
+ loadIncludeOnce('inc/footer.php');
}
// Display parsing time and number of SQL queries in footer
// Add code
$r .= '<span class="linetext">' . encodeEntities($c) . '</span></div>';
- }
+ } // END - foreach
return '<div class="code">' . $r . '</div>';
}
// Send out mails depending on the 'mod/modes' combination
// @TODO Lame description for this function
function sendModeMails ($mod, $modes) {
+ // Init user data
+ $content = array ();
+
// Load hash
if (fetchUserData(getMemberId())) {
// Extract salt from cookie
$sub_mem = '{--MEMBER_CHANGED_DATA--}';
// Output success message
- $content = '<span class="message">{--MEMBER_MYDATA_MAIL_SENT--}</span>';
+ $content['message'] = '<span class="message">{--MEMBER_MYDATA_MAIL_SENT--}</span>';
break;
default: // Unsupported module!
logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unsupported module %s detected.", $mod));
- $content = '<span class="notice">{--UNKNOWN_MODULE--}</span>';
+ $content['message'] = '<span class="notice">{--UNKNOWN_MODULE--}</span>';
break;
} // END - switch
} else {
// Passwords mismatch
- $content = '<span class="notice">{--MEMBER_PASSWORD_ERROR--}</span>';
+ $content['message'] = '<span class="notice">{--MEMBER_PASSWORD_ERROR--}</span>';
}
} else {
// Could not load profile
- $content = '<span class="notice">{--MEMBER_CANNOT_LOAD_PROFILE--}</span>';
+ $content['message'] = '<span class="notice">{--MEMBER_CANNOT_LOAD_PROFILE--}</span>';
}
// Send email to user if required
- if ((!empty($sub_mem)) && (!empty($message))) {
+ if ((!empty($sub_mem)) && (!empty($message)) && (!empty($content['email']))) {
// Send member mail
sendEmail($content['email'], $sub_mem, $message);
} // END - if
// Send only if no other error has occured
- if (empty($content)) {
- if ((!empty($sub_adm)) && (!empty($message_admin))) {
- // Send admin mail
- sendAdminNotification($sub_adm, $message_admin, $content, getMemberId());
- } elseif (isAdminNotificationEnabled()) {
- // Cannot send mails to admin!
- $content = '{--CANNOT_SEND_ADMIN_MAILS--}';
- } else {
- // No mail to admin
- $content = '<span class="message">{--MEMBER_MYDATA_MAIL_SENT--}</span>';
- }
- } // END - if
+ if ((!empty($sub_adm)) && (!empty($message_admin)) && (isAdminNotificationEnabled())) {
+ // Send admin mail
+ sendAdminNotification($sub_adm, $message_admin, $content, getMemberId());
+ } elseif (isAdminNotificationEnabled()) {
+ // Cannot send mails to admin!
+ $content['message'] = '{--CANNOT_SEND_ADMIN_MAILS--}';
+ } else {
+ // No mail to admin
+ $content['message'] = '<span class="message">{--MEMBER_MYDATA_MAIL_SENT--}</span>';
+ }
// Load template
- loadTemplate('admin_settings_saved', false, $content);
+ loadTemplate('admin_settings_saved', false, $content['message']);
}
// Generates a 'selection box' from given array
// Walk through all options
foreach ($options as $option) {
- // Add the <option> entry
+ // Add the <option> entry from ...
if (empty($optionContent)) {
- // ... from template
+ // ... template
$OUT .= loadTemplate('select_' . $name . $extraName . '_option', true, $option);
} else {
- // Direct HTML code
+ // ... direct HTML code
$OUT .= '<option value="' . $option[$optionValue] . '">' . $option[$optionContent] . '</option>';
}
} // END - foreach
// Switch color if called from loadTemplate()
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'SWITCH:' . $template);
$GLOBALS['color_switch'][$template] = 3 - $GLOBALS['color_switch'][$template];
- } // END - if
+ }
// Return CSS class name
if ($return === true) {