4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Plugins => Topic started by: thunderstrike on August 07, 2007, 07:41:23 PM
-
Hi,
past days, I create a MOD called: MOD Compare - for surprise. Allow for MOD builder troubleshoot users - install their MOD. Two click need to see result. Hope you like - long time waited for all ... think ... ;)
[Upgrade - 16-02-2008] - I create v2.0. Please see upgrade for new version (need install v1.0 if no have).
- Specs:
- AJAX select file.
- Upgrade tag remove (no need).
- Good detect of constants.
- URL of forum author topic add with BLANK target.
- SQL storage (tmp table) and order value by asc for line text value and delete fields after file is select.
NO KAI - NO DEMO KAI :!:
[Version v1.0]
// Step 1
In admin/plugins, create file: mod_compare.php .
Copy content:
<?php // PLUGIN_TITLE: MOD Compare
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: batch_import.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.4 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
$nozip = 1;
define('IN_CP', 1);
define('ROOT_PATH', "./../../");
require(ROOT_PATH.'admin/admin_global.php');
show_admin_header();
if ($action == "") {
$action = "select_mod_files";
}
if ($action == "select_mod_files") {
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>";
echo "<td width=\"100%\">\n";
echo "<form method=\"post\" action=\"" . $site_sess->url(get_basefile(stripslashes($HTTP_SERVER_VARS['PHP_SELF']))). "\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"show_mod_files\">\n";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"100%\" class=\"tableseparator\" align=\"center\">" . $lang['mod_compare_choose_file']. "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width=\"100%\" class=\"tablerow\"> </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width=\"100%\" class=\"tablerow\">\n";
echo "<center><select name=\"select_mod_file\">\n";
if ($handle = @opendir(ROOT_PATH . MODS_INSTALL_DIR)) {
while (false !== ($file = @readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<option value=\"" . $file . "\">" . $file . "</option>";
}
}
}
echo "</select>";
echo "<br /><br /><input type=\"submit\" name=\"submit\" value=\"" . $lang['submit'] . "\" class=\"button\" />";
echo "</form></center></td>";
echo "</tr>";
echo "<tr>";
echo "<td width=\"100%\" class=\"tablerow\"> </td>";
echo "</tr>";
echo "<tr>";
echo "<td width=\"100%\" class=\"tableseparator\"> </td>";
echo "</tr>";
echo "</table>";
echo "</td>";
echo "</tr>";
echo "</table>";
@closedir($handle);
}
if ($action == "show_mod_files") {
if (isset($HTTP_POST_VARS['select_mod_file'])) {
$select_mod_file = (isset($HTTP_POST_VARS['select_mod_file'])) ? get_basefile(stripslashes($HTTP_POST_VARS['select_mod_file'])) : "";
}
if (isset($select_mod_file) && empty($select_mod_file)) {
echo $lang['mod_compare_if_empty_file'];
}
$file = stripslashes(ROOT_PATH . MODS_INSTALL_DIR . "/" . $select_mod_file);
$lines = file($file);
if (isset($file) && !empty($file) && isset($lines) && !empty($lines)) {
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td width=\"100%\">";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td width=\"100%\" class=\"tablerow\"><a href=\"" . $site_sess->url(get_basefile(stripslashes($HTTP_SERVER_VARS['PHP_SELF']))) . "\">" . $lang['mod_compare_go_back'] . "</a></td>";
echo "</tr>";
echo "</table>";
echo "<form method=\"post\" action=\"" . $site_sess->url(get_basefile(stripslashes($HTTP_SERVER_VARS['PHP_SELF']))). "\">\n";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td width=\"100%\" class=\"tableseparator\" align=\"center\">" . $lang['mod_compare_file_name_title'] . get_basefile(stripslashes($file)) . "</td>";
echo "</tr>";
echo "</table>";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td width=\"100%\" class=\"tablerow\"> </td>";
echo "</tr>";
echo "<tr>";
echo "<td width=\"100%\" class=\"tablerow\">";
echo "<center><textarea name=\"compare_files\" cols=\"180\" rows=\"20\">\n";
$begin_mod_constant_line = array();
$end_mod_constant_line = array();
$begin_update_constant_line = array();
$end_update_constant_line = array();
$author_constant_line = array();
$name_constant_line = array();
$release_constant_line = array();
$support_constant_line = array();
$description_constant_line = array();
$begin_assistance_constant_line = array();
$end_assistance_constant_line = array();
$constant_key_lines = array();
$forimages_core_version = array();
while (list($key, $val) = each($lines)) {
$key = $key + 1;
if (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/\/\/ MOD/", $val)) {
$constant_key_lines[] = $key;
$begin_mod_constant_line[] = format_text(stripslashes($val), 2);
echo format_text(stripslashes($val), 2);
} elseif (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/\/\/ End of MOD/", $val)) {
$constant_key_lines[] = $key;
$end_mod_constant_line[] = format_text(stripslashes($val), 2);
echo format_text(stripslashes($val), 2);
} elseif (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/\/\/ Update/", $val)) {
$constant_key_lines[] = $key;
$begin_update_constant_line[] = format_text(stripslashes($val), 2);
echo format_text(stripslashes($val), 2);
} elseif (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/\/\/ End of Update/", $val)) {
$constant_key_lines[] = $key;
$end_update_constant_line[] = format_text(stripslashes($val), 2);
echo format_text(stripslashes($val), 2);
} elseif (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/\/\/ Assistance/", $val)) {
$constant_key_lines[] = $key;
$begin_assistance_constant_line[] = format_text(stripslashes($val), 2);
echo format_text(stripslashes($val), 2);
} elseif (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/\/\/ End of Assistance/", $val)) {
$constant_key_lines[] = $key;
$end_assistance_constant_line[] = format_text(stripslashes($val), 2);
echo format_text(stripslashes($val), 2);
} elseif (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/\/\/ Author/", $val)) {
$author_constant_line[] = format_text(stripslashes($val), 2);
//echo format_text(stripslashes($val), 2);
} elseif (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/\/\/ Name/", $val)) {
$name_constant_line[] = format_text(stripslashes($val), 2);
//echo format_text(stripslashes($val), 2);
} elseif (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/\/\/ Release/", $val)) {
$release_constant_line[] = format_text(stripslashes($val), 2);
//echo format_text(stripslashes($val), 2);
} elseif (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/\/\/ Support/", $val) && preg_match('@^(?:http://)?([^/]+)@i', $val)) {
$support_constant_line[] = "<a href=\"" . $val . "\" target=\"_blank\">" . format_text(stripslashes($val), 2) . "</a>";
//echo format_text(stripslashes($val), 2);
} elseif (preg_match("/\/\/ Description/", $val) && preg_match("/[a-zA-Z0-9\.\,;:%&#@!\^-_~`\"'\[\]\{\}\*\/\?\(\)\n\r]/", $val)) {
$description_constant_line[] = format_text(stripslashes($val), 2);
//echo format_text(stripslashes($val), 2);
} elseif (preg_match("/[\$A-Za-z0-9\-\_]/", $val) && preg_match("/Scriptversion/", $val)) {
$forimages_core_version[] = format_text(stripslashes($val), 2);
} else {
echo format_text(stripslashes($val), 2);
}
}
echo "</textarea></form></center></td>";
echo "</tr>";
echo "<tr>";
echo "<td width=\"100%\" class=\"tablerow\"> </td>";
echo "</tr>";
echo "</table>";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td width=\"100%\" class=\"tableseparator\" align=\"center\">" . $lang['mod_compare_diagnostic_title'] . "</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=\"100%\" class=\"tablerow\"> </td>";
echo "</tr>";
echo "</table>";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td width=\"100%\" class=\"tablerow\" align=\"center\">";
if (defined('SCRIPT_VERSION') && isset($forimages_core_version) && is_array($forimages_core_version) && !empty($forimages_core_version)) {
while (list(, $val) = each($forimages_core_version)) {
$val = str_replace("*", "", $val);
$val = preg_replace("/[^0-9\.]+/i", "", $val);
if ($val == SCRIPT_VERSION) {
echo $lang['mod_compare_match_script_version_text'] . "<b>v" . $val . "</b> - <font color=\"green\">" . $lang['mod_compare_found_entry_text'] . "</font>";
} else {
echo $lang['mod_compare_no_match_script_version_text'];
}
}
echo "<br />";
}
if (function_exists('phpversion')) {
echo $lang['mod_compare_php_version_text'] . "<b>v" . phpversion() . "</b> - <font color=\"green\">" . $lang['mod_compare_found_entry_text'] . "</font>";
echo "<br />";
}
if (function_exists('get_mysql_version')) {
echo $lang['mod_compare_mysql_version_text'] . "<b>v" . get_mysql_version() . "</b> - <font color=\"green\">" . $lang['mod_compare_found_entry_text'] . "</font>";
echo "<br />";
}
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=\"100%\" class=\"tablerow\"> </td>";
echo "</tr>";
echo "</table>";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td width=\"100%\" class=\"tableseparator\" align=\"center\">Description</td>";
echo "</tr>";
echo "<tr>";
echo "<td width=\"100%\" class=\"tablerow\"> </td>";
echo "</tr>";
echo "</table>";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>";
echo "<td width=\"100%\" class=\"tablerow\" align=\"center\">";
if (isset($author_constant_line) && is_array($author_constant_line) && !empty($author_constant_line)) {
echo $lang['mod_compare_author_title'];
while (list(, $val) = each($author_constant_line)) {
$val = str_replace("// Author:", "", $val);
echo "<b>" . $val . "</b>";
}
echo "<br />";
}
if (isset($name_constant_line) && is_array($name_constant_line) && !empty($name_constant_line)) {
echo $lang['mod_compare_name_title'];
while (list(, $val) = each($name_constant_line)) {
$val = str_replace("// Name:", "", $val);
echo "<b>" . $val . "</b>";
}
echo "<br />";
}
if (isset($release_constant_line) && is_array($release_constant_line) && !empty($release_constant_line)) {
echo $lang['mod_compare_release_title'];
while (list(, $val) = each($release_constant_line)) {
$val = str_replace("// Release:", "", $val);
echo "<b>" . $val . "</b>";
}
echo "<br />";
}
echo $lang['mod_compare_forimages_copyright_title'];
echo "<br />";
if (isset($support_constant_line) && is_array($support_constant_line) && !empty($support_constant_line)) {
echo $lang['mod_compare_support_title'];
while (list(, $val) = each($support_constant_line)) {
$val = str_replace("// Support:", "", $val);
echo "<b>" . stripslashes($val) . "</b>";
}
echo "<br />";
}
if (isset($description_constant_line) && is_array($description_constant_line) && !empty($description_constant_line)) {
echo "<br />";
echo $lang['mod_compare_description_title'];
while (list(, $val) = each($description_constant_line)) {
$val = str_replace("// Description:", "", $val);
echo "<b>" . $val . "</b>";
}
echo "<br />";
}
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width=\"100%\" class=\"tablerow\"> </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"100%\" class=\"tableseparator\" align=\"center\">" . $lang['mod_compare_begin_end_title'] . "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"100%\" class=\"tablerow\"> </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"50%\" class=\"tablerow\" align=\"center\">\n";
if (isset($begin_mod_constant_line) && isset($constant_key_lines) && is_array($begin_mod_constant_line) && !empty($begin_mod_constant_line) && is_array($constant_key_lines) && !empty($constant_key_lines)) {
while (list(, $val) = each($begin_mod_constant_line)) {
while (list(, $val1) = each($constant_key_lines)) {
echo $lang['mod_compare_line_title'] . "<b>" . $val1 . "</b>: " . $val;
break;
}
}
echo "<br />";
}
if (isset($end_mod_constant_line) && isset($constant_key_lines) && is_array($end_mod_constant_line) && !empty($end_mod_constant_line) && is_array($constant_key_lines) && !empty($constant_key_lines)) {
while (list(, $val) = each($end_mod_constant_line)) {
while (list(, $val1) = each($constant_key_lines)) {
echo $lang['mod_compare_line_title'] . "<b>" . $val1 . "</b>: " . $val;
break;
}
}
echo "<br />";
}
echo " </td></tr><tr><td width=\"50%\" class=\"tablerow\" align=\"center\">";
if (isset($begin_update_constant_line) && isset($constant_key_lines) && is_array($begin_update_constant_line) && !empty($begin_update_constant_line) && is_array($constant_key_lines) && !empty($constant_key_lines)) {
while (list(, $val) = each($begin_update_constant_line)) {
while (list(, $val1) = each($constant_key_lines)) {
echo $lang['mod_compare_line_title'] . "<b>" . $val1 . "</b>: " . $val;
break;
}
}
echo "<br />";
}
if (isset($end_update_constant_line) && isset($constant_key_lines) && is_array($end_update_constant_line) && !empty($end_update_constant_line) && is_array($constant_key_lines) && !empty($constant_key_lines)) {
while (list(, $val) = each($end_update_constant_line)) {
while (list(, $val1) = each($constant_key_lines)) {
echo $lang['mod_compare_line_title'] . "<b>" . $val1 . "</b>: " . $val;
break;
}
}
echo "<br />";
}
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
if (isset($begin_assistance_constant_line) && is_array($begin_assistance_constant_line) && !empty($begin_assistance_constant_line) && isset($end_assistance_constant_line) && is_array($end_assistance_constant_line) && !empty($end_assistance_constant_line)) {
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"100%\" class=\"tablerow\"> </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"50%\" class=\"tablerow\" align=\"center\">";
if (isset($begin_assistance_constant_line) && isset($constant_key_lines) && is_array($begin_assistance_constant_line) && !empty($begin_assistance_constant_line) && is_array($constant_key_lines) && !empty($constant_key_lines)) {
while (list(, $val) = each($begin_assistance_constant_line)) {
while (list(, $val1) = each($constant_key_lines)) {
echo $lang['mod_compare_line_title'] . "<b>" . $val1 . "</b>: " . $val;
break;
}
}
//echo "<br />";
}
echo " </td></tr><tr><td width=\"50%\" class=\"tablerow\" align=\"center\">";
if (isset($end_assistance_constant_line) && isset($constant_key_lines) && is_array($end_assistance_constant_line) && !empty($end_assistance_constant_line) && is_array($constant_key_lines) && !empty($constant_key_lines)) {
while (list(, $val) = each($end_assistance_constant_line)) {
while (list(, $val1) = each($constant_key_lines)) {
echo $lang['mod_compare_line_title'] . "<b>" . $val1 . "</b>: " . $val;
break;
}
}
echo "<br />";
}
echo "</td>";
echo "</tr>";
echo "</table>\n";
}
echo "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"100%\" class=\"tablerow\"> </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width=\"100%\" class=\"tableseparator\"> </td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
}
}
show_admin_footer();
?>
// Step 2
In includes/constants.php file
add top of ?>:
define('MODS_INSTALL_DIR', 'mods_install'); // Change folder name.
Warn: Change 'mods_install' for your personal folder MOD install.
// Step 3
Create (on ROOT_PATH) the folder name you type on step 2 (read warn).
// Step 4
In lang/english/admin.php file:
After:
$lang['save_settings_success'] = "Settings saved";
add:
//-----------------------------------------------------
//--- MOD Compare -------------------------------------
//-----------------------------------------------------
$lang['mod_compare_choose_file'] = "Choose file";
$lang['mod_compare_if_empty_file'] = "Please choose file from your MOD install folder.";
$lang['mod_compare_go_back'] = "[ Go back ]";
$lang['mod_compare_file_name_title'] = "Filename: ";
$lang['mod_compare_diagnostic_title'] = "Diagnostic";
$lang['mod_compare_match_script_version_text'] = "Match version (core and this file): ";
$lang['mod_compare_found_entry_text'] = "found !";
$lang['mod_compare_no_match_version_text'] = "No identical version. <b>Upgrade to last !</b>";
$lang['mod_compare_php_version_text'] = "PHP Version: ";
$lang['mod_compare_mysql_version_text'] = "mySQL Version: ";
$lang['mod_compare_author_title'] = "Author: ";
$lang['mod_compare_name_title'] = "Name: ";
$lang['mod_compare_release_title'] = "Release: ";
$lang['mod_compare_forimages_copyright_title'] = "4images Copyright: <b>Jan Sorgalla</b>";
$lang['mod_compare_support_title'] = "Support: ";
$lang['mod_compare_description_title'] = "Description: ";
$lang['mod_compare_begin_end_title'] = "Begin / End MOD line";
$lang['mod_compare_line_title'] = "Line: ";
// Here how works
4images coder codes new MOD - must respect 5 constant:
1st step (top file)
// Author: Coder name.
// Name: MOD name.
// Release: version number + date (examp: v1.0 - August 7 2007 - good for upgrade too)
// Support: http://www.4homepages.de/forum
// Description: MOD description (what is do).
Then, if modify core file and need addon -
// MOD: Your MOD
// End of MOD: Your MOD
For upgrade:
// Upgrade: Your MOD (+ new date release).
// End of Upgrade: Your MOD
(Both can use). ;)
If new file / new upgrade file, sure to put the 5 constant + beginning of title + end. ;)
Warn: Constant no optional - MUST be used this way.
Examp:
// MOD: << No matter after >>
// MOD: is static (same for update).
Forgot say:
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: mod_compare.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.4 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
This block must stay in PHP file (core / new no matter) on top (<?php - > block).
All lines identify when choose file (begin of each constant + end of each constant). Diagnostic include.
2nd step:
- new constant add - (optional)
Optional:
// Assistance: your keyword
// End of Assistance: your keyword
[Version v2.0]
// Step 1
In admin/plugins - replace full code of mod_compare.php file with this:
<?php // PLUGIN_TITLE: MOD Compare
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: mod_compare.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.6 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) fweitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
// Author: Coder name.
// Name: MOD name.
// Release: version number + date (e.g: v2.0 - February 16 - good for upgrade too)
// Support: http://www.4homepages.de/forum
// Description: MOD description (what is do).
// MOD: MOD Compare
$nozip = 1;
define('IN_CP', 1);
define('ROOT_PATH', "./../../");
require(ROOT_PATH.'admin/admin_global.php');
define('MOD_COMPARE_TABLE', $table_prefix . 'mod_compare');
$substr_self_url = str_replace("plugins/", "", $self_url);
show_admin_header();
if ($action == "") {
$action = "show_mod_compare";
}
if ($action == "show_mod_compare") {
?>
<form>
<?php echo $lang['mod_compare_select_file']; ?>
<select name="mod_compare" onchange="showFileName(this.value)" class="select" />
<option>---</option>
<?php
if (is_dir(ROOT_PATH . MODS_INSTALL_DIR)) {
$handle = @opendir(ROOT_PATH . MODS_INSTALL_DIR);
while (false !== ($file = @readdir($handle))) {
if ($file != ".." && $file != "." && preg_match("/[a-z0-9_]/", $file) && preg_match("/\.php$/", $file) && preg_match("/\<?php/", $file, $regs) && $file != $substr_self_url) {
?>
<option value="<?php echo get_basefile(stripslashes(trim($file))); ?>"><?php echo get_basefile(stripslashes(trim($file))); ?></option>
<?php
}
}
@closedir($handle);
}
?>
</select>
</form>
<table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
<tr class="tableseparator">
<td width="100%" class="tableheader"> <?php echo $lang['mod_compare_title']; ?></td>
</tr>
<tr class="tableseparator">
<td width="100%" class="tablerow"> </td>
</tr>
<tr class="tableseparator">
<td width="100%"><div id="mcint"> </div></td>
</tr>
</table>
<?php
}
if ($action == "exec_mod_compare") {
if (isset($HTTP_GET_VARS['file_name'])) {
$file_name = (isset($HTTP_GET_VARS['file_name'])) ? format_text(trim($HTTP_GET_VARS['file_name']), 2) : "";
} else {
$file_name = "---";
}
if (empty($file_name)) {
$file_name = "---";
}
if ($file_name == "---") {
exit;
} else {
$lines = @file(ROOT_PATH . MOD_COMPARE_DIR . "/" . $file_name);
$sql = "
CREATE TABLE IF NOT EXISTS " . MOD_COMPARE_TABLE . " (
field_id INT(11) NOT NULL AUTO_INCREMENT,
constant_id INT(11) NOT NULL DEFAULT '0',
constant_name VARCHAR(255) NOT NULL DEFAULT '',
field_date INT(11) NOT NULL DEFAULT '0',
PRIMARY KEY(field_id)
) TYPE=MyISAM
";
$result = $site_db->query($sql);
?>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" class="tableheader"> <?php echo $lang['mod_compare_author_specs']; ?></td>
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" class="tablerow"> </td>
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
<?php
// Defines author.
foreach ($lines as $line_num => $line) {
$line_num = $line_num + 1;
if (preg_match("/\/\/ Author\:/", $line)) {
if (preg_match("/(.+)\:(.+)/", $line, $regs)) {
$regs[1] = str_replace("//", "", $regs[1]);
?>
<tr class="tableseparator">
<td width="100%" class="tablerow" align="center"><b><?php echo format_text(trim($regs[1]), 2); ?></b>: <?php echo format_text(trim($regs[2]), 2); ?><br /><?php echo "\n"; ?></td>
</tr>
<?php
}
}
}
// Defines name.
foreach ($lines as $line_num => $line) {
$line_num = $line_num + 1;
if (preg_match("/\/\/ Name\:/", $line)) {
if (preg_match("/(.+)\:(.+)/", $line, $regs)) {
$regs[1] = str_replace("//", "", $regs[1]);
?>
<tr class="tableseparator">
<td width="100%" class="tablerow" align="center"><b><?php echo format_text(trim($regs[1]), 2); ?></b>: <?php echo format_text(trim($regs[2]), 2); ?><br /><?php echo "\n"; ?></td>
</tr>
<?php
}
}
}
// Defines release.
foreach ($lines as $line_num => $line) {
$line_num = $line_num + 1;
if (preg_match("/\/\/ Release\:/", $line)) {
if (preg_match("/(.+)\:(.+)/", $line, $regs)) {
$regs[1] = str_replace("//", "", $regs[1]);
?>
<tr class="tableseparator">
<td width="100%" class="tablerow" align="center"><b><?php echo format_text(trim($regs[1]), 2); ?></b>: <?php echo format_text(trim($regs[2]), 2); ?><br /><?php echo "\n"; ?></td>
</tr>
<?php
}
}
}
// Defines support
foreach ($lines as $line_num => $line) {
$line_num = $line_num + 1;
if (preg_match("//\/\ Support\:/", $line)) {
if (preg_match("/(.+)\:(.+)\:(.+)/", $line, $regs)) {
$regs[1] = str_replace("//", "", $regs[1]);
$protocol = $regs[2];
$domain = $regs[3];
?>
<tr class="tableseparator">
<td width="100%" class="tablerow" align="center"><b><?php echo format_text(trim($regs[1]), 2); ?></b>: <a href="<?php echo $protocol . ":" . $domain; ?>" target="_blank"><?php echo $protocol . ":" . $domain; ?></a><br /><?php echo "\n"; ?></td>
</tr>
<?php
}
}
}
?>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" class="tablerow"> </td>
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" class="tableheader"> <?php echo $lang['mod_compare_description_title']; ?></td>
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
<?php
// Defines description
foreach ($lines as $line_num => $line) {
$line_num = $line_num + 1;
if (preg_match("/\/\/ Description\:/", $line)) {
if (preg_match("/(.+)\:(.+)/", $line, $regs)) {
$regs[1] = str_replace("//", "", $regs[1]);
?>
<tr class="tableseparator">
<td width="100%" class="tablerow"><p align="justify"><br /> <?php echo format_text(trim($regs[2]), 2); ?><br /><br /><?php echo "\n"; ?></p></td>
</tr>
<?php
}
}
}
?>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" class="tablerow"> </td>
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" class="tableheader"> <?php echo $file_name; ?></td>
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" class="tablerow"> </td>
</tr>
</table>
<?php
$sort_list = array();
$sort_text = array();
// Defines Begin MOD.
foreach ($lines as $line_num => $line) {
$line_num = $line_num + 1;
if (preg_match("/\/\/ MOD\:/", $line)) {
$sort_list[] = "{$line_num} => ";
$sort_text[] = format_text(trim($line), 2);
}
}
// Defines End MOD.
foreach ($lines as $line_num => $line) {
$line_num = $line_num + 1;
if (preg_match("/\/\/ End of MOD\:/", $line)) {
$sort_list[] = "{$line_num} => ";
$sort_text[] = format_text(trim($line), 2);
}
}
// Defines Begin Assistance.
foreach ($lines as $line_num => $line) {
$line_num = $line_num + 1;
if (preg_match("/\/\/ Assistance\:/", $line)) {
$sort_list[] = "{$line_num} => ";
$sort_text[] = format_text(trim($line), 2);
}
}
// Defines End Assistance.
foreach ($lines as $line_num => $line) {
$line_num = $line_num + 1;
if (preg_match("/\/\/ End of assistance\:/", $line)) {
$sort_list[] = "{$line_num} => ";
$sort_text[] = format_text(trim($line), 2);
}
}
$num_sort_list = sizeof($sort_list);
$num_sort_text = sizeof($sort_text);
$valid = false;
for ($i = 0; $i < $num_sort_list; $i++) {
for ($j = 0; $j < $num_sort_text; $j++) {
$site_db->query("INSERT INTO " . MOD_COMPARE_TABLE . " (field_id, constant_id, constant_name, field_date) VALUES (NULL, '" . $sort_list[$j] . "', '" . $sort_text[$j] . "', '" . time() . "')");
$valid = true;
}
break;
}
unset ($sort_list);
unset ($sort_text);
if ($valid == true) {
$sql = "
SELECT constant_id, constant_name, field_date
FROM " . MOD_COMPARE_TABLE . "
ORDER BY constant_id ASC
";
$result = $site_db->query($sql);
$counter = 0;
while ($line_row = $site_db->fetch_array($result)) {
$constant_id = $line_row['constant_id'];
$constant_name = format_text(trim($line_row['constant_name']), 2);
$field_date = (function_exists('get_universal_field_date')) ? get_universal_field_date($line_row['field_date']) : format_date($config['date_format'], $line_row['field_date']);
?>
<table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
<tr class="tableseparator">
<?php
if (preg_match("/\/\/ MOD\:/", $constant_name)) {
?>
<td width="50%" class="tablerow" align="center"><?php echo $lang['mod_compare_begin_line'] . $constant_id; ?><br /><?php echo $constant_name; ?></td>
<?php
} elseif (preg_match("/\/\/ End of MOD\:/", $constant_name)) {
?>
<td width="50%" class="tablerow" align="center"><br /><?php echo $lang['mod_compare_end_line'] . $constant_id; ?><br /><?php echo $constant_name; ?><hr /></td>
<?php
}
?>
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0" class="tableborder" />
<tr class="tableseparator">
<?php
if (preg_match("/\/\/ Assistance\:/", $constant_name)) {
?>
<td width="50%" class="tablerow" align="center"><?php echo $lang['mod_compare_begin_line'] . $constant_id; ?><br /><?php echo $constant_name; ?></td>
<?php
} elseif (preg_match("/\/\/ End of assistance\:/", $constant_name)) {
?>
<td width="50%" class="tablerow" align="center"><br /><?php echo $lang['mod_compare_end_line'] . $constant_id; ?><br /><?php echo $constant_name; ?><hr /></td>
<?php
}
?>
</tr>
</table>
<?php
$counter++;
if ($counter % 2 == 0) {
?>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" class="tablerow"> </td>
</tr>
</table>
<?php
}
}
?>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" class="tableheader"> <?php echo $lang['mod_compare_author_bibliography']; ?></td>
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" align="center" class="tablerow"><br /><span class=\"smalltext\"><b>MOD Compare</b> - created by <a href="http://www.4homepages.de/forum/index.php?topic=19856.0" target="_blank" />Thunderstrike</a> - 2007-2008<br />Version 2.0<br />(Test with <b>4images v1.76 - PHP v5.2.5 - mySQL v5.0.45</b>)</span><br /><br /></td>
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" class="tableheader"> </td>
</tr>
</table>
<?php
$site_db->query("DELETE FROM " . MOD_COMPARE_TABLE);
} else {
echo "Error";
}
?>
</td>
</tr>
</table>
<?php
}
}
show_admin_footer();
// End of MOD: MOD Compare
?>
// Step 2
In lang/english/admin.php file,
replace full lang block code (MOD Compare) with this:
//-----------------------------------------------------
//--- MOD Compare -------------------------------------
//-----------------------------------------------------
$lang['mod_compare_title'] = "MOD Compare";
$lang['mod_compare_author_specs'] = "Author Specs";
$lang['mod_compare_select_file'] = "Select file: ";
$lang['mod_compare_description_title'] = "Description";
$lang['mod_compare_begin_line'] = "Begin line: ";
$lang['mod_compare_end_line'] = "End line: ";
$lang['mod_compare_author_bibliography'] = "Bibliography";
// Step 3
In admin/admin_functions.php file,
find:
<script type="text/javascript" language="javascript" src="<?php echo ROOT_PATH; ?>admin/calendar.js"></script>
add after:
<?php
// MOD: MOD Compare
if (preg_match("/mod_compare.php/", $self_url)) {
?>
<script src="<?php echo ROOT_PATH; ?>admin/mod_compare.js"></script>
<?php
}
// End of MOD: MOD Compare
?>
// Step 4
In admin, create file: mod_compare.js .
Add:
var xmlHttp
function showFileName(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="./../../admin/plugins/mod_compare.php"
url=url+"?action=exec_mod_compare&file_name="+str
//url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("mcint").innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
// Step 5
Set CHMOD 755 to MODS_INSTALL_DIR (no need for full write now).
// Is work
ACP - > Plugins - > MOD Compare . After you upload target file of MOD coder in MODS_INSTALL_DIR, select file in form and file is load. ;)
This give better forum support to user have problem find content.
E.g: http://www.4homepages.de/forum/index.php?topic=18296.0
Easy trace. ;)
Hope you like. Rate for it. :D
-
... a very interesting ACP Plugin Extension ...
... I test it with some of my mods ... and it works perfectly ...
... I made some little design changes ...
- one pixelboder for the tables
- cellpadding=3
- textarea -> cols=140
... I think it is a MOD like an old TheOracle-MOD in the best way ... :mrgreen:
-
nice mood :D
-
Thank for posting and voting. Feel grate tell you. This will reduce post on forum when user try install MOD. 8)
-
@Mawenzi:
Possible to make topic sticky ? This kind of MOD help lot - future. :)
-
@ thunderstrike
... but wrong forum ... I can't handle this mod here in this forum (Moderator: Acidgod) ...
... I can't move it to the forum "Mods & Plugins (Releases & Support)" ... only from "Mods & Plugins (Requests & Discussions)" ...
... you should repost it in "Mods & Plugins (Requests & Discussions)" ... only copy and paste ... ;)
-
No wrong forum - is troubleshooting MOD (axception). :mrgreen:
-
If Jan axcept to change forum :arrow: VBulletin, I connek on target MOD topic and say user - update ready. Code there but SMF no use direc topic (no PEAR need + KH).
-
... you should repost it in "Mods & Plugins (Requests & Discussions)" ... only copy and paste ... ;)
... from there I can move the MOD to "Mods & Plugins (Releases & Support)" ... :!:
... and there I can make the topic sticky ... :!:
... and now it's your turn ... ;)
-
Yes, got it 1st time. Thank for note. ;)
-
New constant add. Read 2nd step. :)
-
I ended up with this when I clicked on the Mod Compare:
Fatal error: Call to undefined function get_basefile() in /home/glad/public_html/dloads/admin/plugins/mod_compare.php on line 42
I think Step 2 confused me a bit...
-
No confuse ... get_basefile() is use in 4images v1.7.4. If see error, mean you no use v1.7.4 of 4images. If do, miss some step in upgrade from v1.7.3 to v1.7.4. ;)
-
Ok.... as I said in the other thread, I use 1.71 because of all the hacks I have put into it.
So now, to use this to keep track of Mods, I need to install 1.74. It won't have what I need, hack wise.
Thus, I may as well start from absolute scratch again with 1.74 and re-add in all the hacks I did.
Thus, this Mod Compare would do me no good.
This did nothing to help solve the problem I'm having (per the other thread) and now I've wasted a good amount of the day over nothing.
*sigh*
-
Thus, this Mod Compare would do me no good.
Stay with 4images v1.7.1 if like. This MOD is NOT going behind of code because 1 user has old version of 4images. Install fresh copy of v1.7.4 and see the difference.
-
How can I? 1.74 isn't integrated with vBulletin, nor does it have the hacks installed that I need. So if I install it, what am I looking at? Something that has nothing to do with my site is what.
Not to worry, though... I am starting from scratch since there is no help on what I need. Rather there is a "buy this now! UPGRADE" sales pitch going on rather than assistance :)
-
Offtopic. If have question about MOD, please post. If no, create new topic in feedback & suggestion for opinion.
-
I asked for help on a particular thing in another thread. YOU sent me to this thread.
http://www.4homepages.de/forum/index.php?topic=18430
-
Correct. I help you resolve upgrade from v1.71 to v1.74 without affect.
-
'fraid not.
You asked me to install 1.7.4. Does me no good without the mods I already made to 1.7.1.
-
Does me no good without the mods I already made to 1.7.1.
Pain of opensource. Everyone has to live with it.
-
I create v2.0 of MOD. Good for use and patch. ;)
-
Hi
I'm Tring to understand what this mod make
what it compare
so please some one tell me
I need to compare between 2 images
is this make what i need