Knowledge Base / Category / Old Plugins Updating

Old Plugins Updating

Where can you download the "old" v1 plugins?

Sources of old plugins

other sources than e107.org
Some of these plugins are accessible via e107.org and menu 'Get plugins'.

Then you can try to find them via Plugin Manager in your e107 installation.

Or you can look at
https://github.com/Jimmi08/e107-old-plugins


If you have plugin that is not listed there and you use it, let me know.

Good source for old plugins too:
http://v1.e107hungary.org/download.php

Queries - How To Update Old Plugins For Php 7

queries used in old plugins maybe don't work in Php 7

Quickly way how to fix old queries
Here are combinations about different queries I found in old plugins.  Some time past and I wasn't able to remember how to replace them again. So now I note any combination I find.

$query = @mysql_query("SELECT game_id FROM ".MPREFIX."arcade_favourites WHERE user_id=".USERID."");
$checkfavs = mysql_fetch_assoc($query);

replace:

$sql->gen("...");
$checkfavs = $sql->fetch('assoc');
$sql->mySQLresult = @mysql_query("SELECT ...");
$rows = $sql->db_Rows();

replace:

$rows = $sql->gen("...");
$sql->mySQLresult = @mysql_query("SELECT SUM(duration) as dur FROM ".MPREFIX."arcade_scores WHERE game_id='".$_POST['gameid']."' and user_id = ".$result['user_id']."");
$duration = $sql->db_Fetch();

replace:

$sql->gen("...");
$duration = $sql->fetch();
$sql->mySQLresult = @mysql_query("UPDATE ".MPREFIX."arcade_games SET times_played = times_played   1 WHERE game_id = '".intval($_POST['gameid'])."';");
$sendpm = mysql_query("INSERT INTO ".MPREFIX."private_msg (pm_id, pm_from, pm_to, pm_sent, pm_read, pm_subject, pm_text, pm_sent_del, pm_read_del, pm_attachments, pm_option, pm_size) VALUES('0', '".USERID."', '".$row['user_id']."', '".intval(time())."', '0', 'Arcade Challenge Recieved!', '".$msg."', '1', '0', '', '', '".intval($size)."' ) ");

replace:

$sql->gen("..."); 
$sendpm = $sql->gen("...");
$class = @mysql_query("SELECT * FROM ".MPREFIX."arcade_categories WHERE cat_id='".$row['cat_id']."'");
$class = mysql_fetch_array($class);

replace:

$class = $sql->retrieve("...");

Replacing old constants

to get them working with SEF-URL enabled

e_SELF, e_BASE
e_SELF
- you can replace it with e_REQUEST_URL or e_REQUEST_SELF.
If you are in admin and you are using new admin ui with custom form, you should use e_REQUEST_URL (url parameters are without change)

e_REQUEST_SELF has the same value as e_SELF. (I replace it just to be sure that this form for checked and work)


e_BASE it should be replaced with e_HTTP

Check if plugin is installed

e107::isInstalled('pluginname');

e107::isInstalled('pluginname');
Before:

$islistinstalled = $sql->count('plugin', '(*)', 'WHERE plugin_path ="list_new" AND plugin_installflag ="1"');

Now:

$islistinstalled = e107::isInstalled('list_new');

Next examples:
$iscopperinstalled = e107::isInstalled('coppermine_menu');
$isguestbookinstalled = e107::isInstalled('guestbook');
$ischatboxinstalled = e107::isInstalled('chatbox_menu');
$ischatboxIIinstalled = e107::isInstalled('chatbox2_menu');
$isforuminstalled = e107::isInstalled('forum');
$isyoutubeinstalled = e107::isInstalled('ytm_gallery');
$iskroozearcadeinstalled = e107::isInstalled('kroozearcade_menu');
$islinkpageinstalled = e107::isInstalled('links_page');
$isjokeinstalled = e107::isInstalled('jokes_menu');
$isbloginstalled = e107::isInstalled('userjournals_menu');
$issuggestioninstalled = e107::isInstalled('suggestions_menu');
$isloginstalled = e107::isInstalled('log');

Old constants not used anymore

Constants that doesn't work anymore

ADMIN_PAGE
ADMIN_PAGE is not defined anymore in e_notify.php

if(defined('ADMIN_PAGE') && ADMIN_PAGE === true)
replace by
if(ADMIN_AREA)

How to replace form fields

No comment

how to replace old form fields with new ones

TEXT FIELD

CHANGED order of parameters
Before:
function form_text($form_name, $form_size, $form_value, $form_maxlength = FALSE, $form_class = "tbox form-control", $form_readonly = "", $form_tooltip = "", $form_js = "") {
...
	return "\n<input class='".$form_class."' type="text">";
}
Now:
function text($name, $value = '', $maxlength = 80, $options= array()) 
{
...
	return "<input type='".$type."' name="{$name}" value="{$value}">get_attributes($options, $name)." />";
}
replacing:
$f->form_text($pname."_title", "40", $tp->toHTML($fi["title"]), "200", "form-control")
$frm->text($pname."_title", $tp->toHTML($fi["title"]),  "200", 'size=40&class=form-control')
So: 1. rename method name 2. delete 2rd parameter (4th becames 3rd) 3. set former size parameter like size=99 as 4th parameter Options: - if parameter class is not defined, class tbox is used - if bootstrap 3 (not 4) is used, class form-control is used NOTE for me: ALWAYS set class, not let it for core - selectize script is used if you use options 'id' and 'selectize' (then class is emptied) - option 'type' is available (only email, otherwise has value text) - option 'typehead' with value 'users' is marked as removed soon Example with placeholder:
$frm->text($pname."_googlemap",  $tp->toHTML($fi["googlemap"]), "200", "size=40&class=form-control&placeholder=".CUP_INFO_ADDRESS)

Textarea

Before;
function form_textarea($form_name, $form_columns, $form_rows, $form_value, $form_js = "", $form_style = "", $form_wrap = "", $form_readonly = "", $form_tooltip = "") {
...
		return "\n<textarea class="tbox form-control">".$form_value."</textarea>";
Now:
function textarea($name, $value, $rows = 10, $cols = 80, $options = array(), $counter = false) {
...
		return "<textarea>get_attributes($options, $name).">{$value}</textarea>".(false !== $counter ? $this->hidden('__'.$name.'autoheight_opt', $counter) : '');
CHANGED order of parameters
So: - swap 4th and 2nd parameters - everything else move to options - set 6th parameter as true Example:
$frm->form_textarea($pname."_info", "10", "20", $tp->toHTML($fi["info"]), "200", "form-control")
$frm->text($pname."_googlemap",  $tp->toHTML($fi["googlemap"]), "200", "size=40&class=form-control&placeholder=".CUP_INFO_ADDRESS)

Open form

CHANGED order of parameters
$frm->form-open("post", e_SELF, $pname."_form", "", " class='form-horizontal'")
- rename method - move form name as first parameter - replace 3rd with NULL (in this case e_REQUEST_URI is used)
$frm->open($pname."_form",'post', null, array('class'=>'form-horizontal'))

Checkbox

function form_checkbox($form_name, $form_value, $form_checked = 0, $form_tooltip = "", $form_js = "") {
function checkbox($name, $value, $checked = false, $options = array())

Select

just renaming method select_open option select_close
function form_option($form_option, $form_selected = "", $form_value = "", $form_js = "") {
...
return "\n";
}
function option($option_title, $value, $selected = false, $options = '')
return "";

Queries - How To replace old db_fetch()

Examples how to replace not supported db_fetch()

Quickly way how to fix old queries
$sql->db_Select('gold_asset', 'gasset_asset', 'where gasset_user_id =' . USERID, 'nowhere', false);<br>
while ($gasset_row = $sql->db_Fetch())

replace:

$gasset_records = e107::getDb()->retrieve('gold_asset', 'gasset_asset', 'gasset_user_id =' . USERID, true);
foreach($gasset_records AS $gasset_row)
Notice:
- nowhere parameter removed
- where word removed
- false changed to true
$userfound = $sql -> db_Select("onlineinfo_read","*","user_id=".USERID."");

replace:

$userfound = $sql -> select("onlineinfo_read","*","WHERE user_id=".USERID."", true);
Notice:
- added Where
- added 4th parameter

Admin menu

Combination new and old way

How to use new Admin UI just for part of plugin

Old plugins way:

file admin_menu.php

and there something like this:

show_admin_menu(_CLANWARS, $action, $var);

New way:

class clanwars_adminArea extends e_admin_dispatcher
{

...

protected $adminMenu = array(
'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => 'P'), 
);

...

}

If there is useless to override all plugin and you need to replace just some its parts:

in new file: 

add to class clanwars_adminArea

public function renderMenu() {
include_lan(e_PLUGIN.'clanwars/admin_menu.php');
show_admin_menu(_CLANWARS, $action, $var);
}

in old admin_menu change e_SELF to file name

$var['Mail']['text'] = _WWARSMAIL;
$var['Mail']['link'] = "admin_old.php?Mail";
$var['Prefs']['text'] = "Prefs";
$var['Prefs']['link'] = "admin_prefs.php";

This way you have the same menu for new and old parts and you can replace old parts by little steps, not everything at once.