e107sk.com

Content Category How to update old plugins

Tuesday 28 April 2020 comments: 0

if e_PLUGIN is used

Check it with any part that use SEF-URL links f.e. /news/   (news.php works)

You need to change:

<a href='".e_PLUGIN."tagcloud/tagcloud.php'>".LAN_TG6."</a>

to

<a href='".e_PLUGIN_ABS."tagcloud/tagcloud.php'>".LAN_TG6."</a>

 After using SEF-URL links for the plugin itself, all links have to be changed.

Tables are not created on 07 Jan 2020

Old plugin.php is used

Check if plugin.php doesn't use TYPE = MYISAM; 

You need to change it to: ENGINE=MyISAM;

For future update check if there are no space before comma like this: VARCHAR( 50 ) NOT NULL ,

it will cause the update needed message or errors with your SQL verification.

How to update old queries on 22 Dec 2019

queries used in old plugins maybe don't work [...]

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("...", "*", true, true);
$sql2 = new db;

replace:

$sql2 = e107::getDb();

This code doesn't work anymore:  

(not $row[0], but the key has to be used)

$sql->db_Select("chatbox2", "MAX(cb2_id)");
$row = $sql->db_Fetch();
echo $row[0];

Replaced: 


$sql->select("chatbox2", "MAX(cb2_id) AS lastId" );
$row = $sql->fetch();
//echo $row[0];
echo $row['lastId'];

Admin menu on 12 Sep 2019

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

  function renderMenu() {
     
	     include (e_PLUGIN.'efiction/admin_menu.php');
 
	} 

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. 

Queries - How To replace old db_fetch() on 07 Mar 2019

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

Old constants not used anymore on 02 Aug 2018

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)

Check if plugin is installed on 31 Jul 2018

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');

Replacing old constants on 31 Jul 2018

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

Other links

Follow us