Page 1 of 2

The ultimate mod

Posted: Tue Jun 28, 2022 3:17 pm
by davidefa
Every software should have an 'ultimate' block/plugin/something... now is meteotemplate's turn.
This mod will add 3 icons in the control panel to install:
- unofficial blocks
- unofficial plugins
- unofficial mods
As the name implies, these are all unofficial updates, from a repository maintained by me, which contains the same blocks/plugins/mods published in this forum, but in a centralized manner.
In this way it should be easier to update meteotemplate ( without searching the whole forum ), directly from the control panel.

This is an initial release. I'd like to extend it:
- adding version selection support ( now you can only update to last version )
- adding a mod undo option ( mods are potentially dangerous, so an undo should restore the previous situation, in case... )
- adding a 'repository plugin' ( for those who want to create their own repository )
- adding the support of multiple repositories
- adding the support of installation from a given url
Any suggestion is welcome.

P.S.
I'm in the process of extracting from the forum any block/plugin/mod already published. Any help is welcome

INSTALLATION
Copy the zipped archive in the meteotemplate root directory and unzip the file ( it will overwrite 'a few' files in the admin directory, it is always a good idea to make a backup before installing a mod ).

v1.0 28/6/2022
- initial release

v1.1 8/7/2022
- corrected mod install
- added block duplication feature, it should be enough for 'simple blocks' ( for more complex ones you also need the 'iframe' block )


unofficial01.png
unofficial01.png (440.37 KiB) Viewed 64306 times

Re: The ultimate mod

Posted: Tue Jun 28, 2022 4:27 pm
by alexvanuxem
+10000!

Great job!

can't wait to test the mod!

This will be a new version of MT?

KR

A

Re: The ultimate mod

Posted: Tue Jun 28, 2022 5:12 pm
by alexvanuxem
Hi Davidefa,

These are three blocks I made airqualityindoor: a second block to show next to the airquality block, a block which shows the indoor AQ

forecastBE: a simple block to show the Belgium KMI widget (based on forecastNL)

and weathernetworksblock: there I changed the link to CWOP, the normal one is not working, if you are not an official member of cwop (official members are US only).

hope this will help for the library.
weatherNetworksBlock.zip
(1.92 KiB) Downloaded 1431 times
airQualitySensorIndoor.zip
(45.81 KiB) Downloaded 1027 times
forecastBE.zip
(1.87 KiB) Downloaded 1256 times

Re: The ultimate mod

Posted: Tue Jun 28, 2022 8:34 pm
by davidefa
Good

Re: The ultimate mod

Posted: Fri Jul 01, 2022 2:08 pm
by alexvanuxem
Hi David!

Thanks for the ultimate mod, works well.
Now I got the latest versions of all, I use!

two small issues : the riset block I have is 7.3, the mod shows an update to 7.4, but can't seem to update it.
It keeps hanging on 7.3. Don't find a update either to 7.4 in this forum.

in the unofficial mod section I can't download them, error: Unable to load file from http://realrunning.netsons.org/template ... repository

thx man!

Re: The ultimate mod

Posted: Sat Oct 01, 2022 11:54 am
by meteoesine
just to know,
Does the unofficial mod installation work or is it still being tested?
i mean i have already installed all mods but it looks like they are not.
did I do something wrong?

Re: The ultimate mod

Posted: Sat Oct 01, 2022 11:07 pm
by andyk1
I installed the ultimate mode by David's directions and it worked as he described. The only issue I have is I cannot get PHP to work in php 8.0 or 8.1 on my host server which is IONOS.COM. other than that it works... at least till December 31st.

Describe the issue you are having in more detail if you can.

Your site looks nice and organized. The one thing I recommend is to turn on other languages in the upper right corner as people like me do not speak your language and have to guess the lay out to offer help but that is your choice.

Also, I'm not sure if it's out of the testing phase but works as is for me as I said. Big THANK YOU to David.

Andy

Re: The ultimate mod

Posted: Mon Dec 19, 2022 12:35 am
by spd2612
I installed ultimate mod 8.1.1 in my new install of meteotemplate which is working great runs PHP 8.1.13, apache2
it added all the links in the CP but when I click I get a error this page isnt working and when a check the error I get looks like its looking for a table thats not there I reclicked on the test connection in main setup and its ok how does this table 'hurricanepub.mt_mods get created

Warning: Undefined array key "HTTP_X_FORWARDED_FOR" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 116

Warning: Undefined array key "HTTP_CLIENT_IP" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 117

Warning: Undefined array key "HTTP_CF_CONNECTING_IP" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 118

Fatal error: Uncaught mysqli_sql_exception: Table 'hurricanepub.mt_mods' doesn't exist in /var/www/hurricanepub/template/admin/modSetupUnofficial.php:34 Stack trace: #0 /var/www/hurricanepub/template/admin/modSetupUnofficial.php(34): mysqli_query() #1 {main} thrown in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 34

Re: The ultimate mod

Posted: Mon Dec 19, 2022 4:13 am
by andyk1
Try it with php 8.0. If not try to create the table with php 7.4 while you have a chance.

Re: The ultimate mod

Posted: Mon Dec 19, 2022 6:00 am
by spd2612
Thanks Andy but I am not going to back down my php to many other things can go wrong besides when it was on windows I was running php 8.1.11 and it worked
Is it suppose to create a new table in mysql ?

Re: The ultimate mod

Posted: Mon Dec 19, 2022 2:52 pm
by spd2612
spd2612 wrote: Mon Dec 19, 2022 12:35 am I installed ultimate mod 8.1.1 in my new install of meteotemplate which is working great runs PHP 8.1.13, apache2
it added all the links in the CP but when I click I get a error this page isnt working and when a check the error I get looks like its looking for a table thats not there I reclicked on the test connection in main setup and its ok how does this table 'hurricanepub.mt_mods get created

Warning: Undefined array key "HTTP_X_FORWARDED_FOR" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 116

Warning: Undefined array key "HTTP_CLIENT_IP" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 117

Warning: Undefined array key "HTTP_CF_CONNECTING_IP" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 118

Fatal error: Uncaught mysqli_sql_exception: Table 'hurricanepub.mt_mods' doesn't exist in /var/www/hurricanepub/template/admin/modSetupUnofficial.php:34 Stack trace: #0 /var/www/hurricanepub/template/admin/modSetupUnofficial.php(34): mysqli_query() #1 {main} thrown in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 34
@Davidefa

I have recreated the user and gave the right permissions, its username@localhost changed the sql connect in main setup to localhost, but
modSetupUnofficial.php still will not create the table. This is Ubunto 22.04 Linux and it is installed in template folder all the rest of the site works great I really dont know how to manually create this table in mysqli
My database is updating weather data just fine as seen in phpmyadmin

Been messing with it but still have this error

Deprecated: Function date_sunrise() is deprecated in /var/www/hurricanepub/template/header.php on line 141

Deprecated: Function date_sunset() is deprecated in /var/www/hurricanepub/template/header.php on line 142

Deprecated: Function date_sunrise() is deprecated in /var/www/hurricanepub/template/header.php on line 313

Deprecated: Function date_sunset() is deprecated in /var/www/hurricanepub/template/header.php on line 314

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/hurricanepub/template/admin/pluginSetupUnofficial.php:56 Stack trace: #0 {main} thrown in /var/www/hurricanepub/template/admin/pluginSetupUnofficial.php on line 56

Re: The ultimate mod

Posted: Tue Dec 20, 2022 5:26 pm
by spd2612
This is what I know hopefully @davidefa will see this my server is as follows
Ubunto 22.04 Apache2
mysql Ver 8.0.31
php 8.1.13

modSetupUnofficial.php will not create the table in Mysql I had to create it manually, may or may not have it correct but it got rid of the mysqli error These errors are after I created the table in mysql manually.
I tested mysql with a simple php code and my user was able to write to it stand alone and create a table

I TESTED MYsql with this code

Code: Select all

<?php 

error_reporting(E_ALL);
ini_set('display_errors', 1);


$DB_HOST = 'localhost'; // Replace
$DB_USER = 'username'; // with
$DB_PASS = 'password'; // your
$DB_NAME = 'yur db'; // own


$db = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if($db->connect_errno > 0) {
  die('Connection failed [' . $db->connect_error . ']');
}

$sql = "CREATE TABLE mt_mods
(id int(11) NOT NULL AUTO_INCREMENT,
 `NAMESPACE` varchar(80) NOT NULL,
  		    `VERSION` varchar(10) NOT NULL,
  		    `STATUS` int(6) NOT NULL,
  		    `DATE` date NOT NULL,
  	 	    PRIMARY KEY (`ID`),
  	 	    UNIQUE KEY `ID` (`ID`)
	  	    ) ENGINE  =  MyISAM  DEFAULT CHARSET  = utf8 COLLATE  = utf8_unicode_ci;");



$result = mysqli_query($db,$sql);

    if(!$result) {
        die('There was an error running the query [' . $db->error . ']');
    }

    else {

        echo "Successful query.";

    }

?>
ERRORS IN ultimateMod_1.1

IN modSetupUnofficial.php

Code: Select all

// check if table exixts...
    $result = mysqli_query($con,"SHOW COLUMNS FROM `mt_mods`");
    if (mysqli_errno($con))
        {
	    // create table
	    mysqli_query($con,
		    "CREATE  TABLE  `$dbName`.`mt_mods` (
  		    `ID` int(11) NOT NULL AUTO_INCREMENT,
  		    `NAMESPACE` varchar(80) NOT NULL,
  		    `VERSION` varchar(10) NOT NULL,
  		    `STATUS` int(6) NOT NULL,
  		    `DATE` date NOT NULL,
  	 	    PRIMARY KEY (`ID`),
  	 	    UNIQUE KEY `ID` (`ID`)
	  	    ) ENGINE  =  MyISAM  DEFAULT CHARSET  = utf8 COLLATE  = utf8_unicode_ci;");
IN pluginsetupunofficial.php
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/hurricanepub/template/admin/pluginSetupUnofficial.php:56 Stack trace: #0 {main} thrown in /var/www/hurricanepub/template/admin/pluginSetupUnofficial.php on line 56

IN modSetupUnofficial.php
Warning: Undefined array key "HTTP_X_FORWARDED_FOR" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 116

Warning: Undefined array key "HTTP_CLIENT_IP" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 117

Warning: Undefined array key "HTTP_CF_CONNECTING_IP" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 118

Fatal error: Uncaught mysqli_sql_exception: Unknown column 'NAMESPACE' in 'order clause' in /var/www/hurricanepub/template/admin/modSetupUnofficial.php:51 Stack trace: #0 /var/www/hurricanepub/template/admin/modSetupUnofficial.php(51): mysqli_query() #1 {main} thrown in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 51

IN blockSetupUnofficial.php
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/hurricanepub/template/admin/blockSetupUnofficial.php:63 Stack trace: #0 {main} thrown in /var/www/hurricanepub/template/admin/blockSetupUnofficial.php on line 63

Re: The ultimate mod

Posted: Wed Dec 21, 2022 10:14 pm
by davidefa
Ok, need to verify the problem...

Re: The ultimate mod

Posted: Wed Dec 21, 2022 10:41 pm
by spd2612
Thanks David
It worked when i was in windows with PHP 8.1.11 but I think mysql was 5.7

Re: The ultimate mod

Posted: Thu Dec 22, 2022 12:51 am
by spd2612
I think I got part figured out, got it tested in blockSetupUnofficial.php and pluginSetupUnofficial.php

IN blockSetupUnofficial.php
line 63
for($i=0;$i<count($blocksAvailable);$i++)
change to
for($i=0;$i<count((array)$blocksAvailable);$i++)

IN pluginSetupUnofficial.php
line 56
for($i=0;$i<count($pluginsAvailable);$i++)
Change to
for($i=0;$i<count((array)$pluginsAvailable);$i++)

The above cleared the fatal error in those to files



still have the issue with modSetupUnofficial.php and there are multiple warnings

Warning: Undefined array key "HTTP_X_FORWARDED_FOR" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 116

Warning: Undefined array key "HTTP_CLIENT_IP" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 117

Warning: Undefined array key "HTTP_CF_CONNECTING_IP" in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 118

Fatal error: Uncaught mysqli_sql_exception: Table 'hurricanepub.mt_mods' doesn't exist in /var/www/hurricanepub/template/admin/modSetupUnofficial.php:34 Stack trace: #0 /var/www/hurricanepub/template/admin/modSetupUnofficial.php(34): mysqli_query() #1 {main} thrown in /var/www/hurricanepub/template/admin/modSetupUnofficial.php on line 34

Re: The ultimate mod

Posted: Thu Dec 22, 2022 4:28 pm
by spd2612
Ok here is the issue Dave, the above fix also needs done in modSetupUnofficial.php which I have done.
The Mysql error above is because create database in modSetupUnofficial.php is not creating it in MYsql 8.0.31. I do not understand that as testing the connection in main setup and creating one with that script I have a couple of posts up will create a table .
Meteotemplate is able to write data to the Mysql database as my station data update's
It may be that it cant create as I imported my tables from a backup. I have tryed using root as update with no change in behavior
I dont know how to create the needed table manually or I would try it.
For now to get past the fatal mysql error I created a table MT_MODS and 3 colums in it, just to get past the error
of course https://hurricanepub.com/template/admin ... ficial.php has no mods listed in it

Would really appreciate some help here

Re: The ultimate mod

Posted: Mon Dec 26, 2022 5:47 pm
by spd2612
I Made some progress on this mod to make it work on PHP 8.1.XX

This change takes away the Fatal error: Uncaught mysqli_sql_exception:
and allows it to create the Database in MYSQL
In
modSetupUnofficial.php
Line 19 and 20 add above "session_start();"

Code: Select all

    $driver = new mysqli_driver();
    $driver -> report_mode = MYSQLI_REPORT_OFF;
This is for PHP 8.1.xx

This mod does allow some of it to work you can go into regular block, and Plugins
select and see & download all of them
It still does not populate the columns in the mt_mods in MYSql
so nothing is showing in CP / Unofficial Plugins or Unofficial Blocks but no errors.
Still working on it if anyone wants to help that knows more then me
which does not take much It would be great...

Re: The ultimate mod

Posted: Tue Dec 27, 2022 5:17 am
by andyk1
spd2612 wrote: Mon Dec 19, 2022 6:00 am Thanks Andy but I am not going to back down my php to many other things can go wrong besides when it was on windows I was running php 8.1.11 and it worked
Is it suppose to create a new table in mysql ?
As far as I know... when you add a new sensor it should ask you in https://www.XXX.com/admin/index.php which is your Extra Sensors section of Database to save it or just display without saving in your Db.

Re: The ultimate mod

Posted: Tue Dec 27, 2022 1:09 pm
by spd2612
Andy the ultimate mod seems to be working for me after my last update with the exception of the unofficial section I think the problem there might be that I am not connecting to Davids repository

Re: The ultimate mod

Posted: Tue Dec 27, 2022 3:17 pm
by spd2612
@davidefa

Ok I am guessing this is why nothing is showing in Latest Unofficial version
But the error dosent appear to be anything I can fix looks like it would be a @davidefa fix

This is what I see as the repository
http://realrunning.netsons.org/template ... p?type=mod

http://realrunning.netsons.org/template ... php?errors

And it gives this error

Fatal error: Uncaught ValueError: mb_http_input(): Argument #1 ($type) must be one of "G", "P", "C", "S", "I", or "L" in /home/gepnuiib/public_html/template/scripts/functions.php:28 Stack trace: #0 /home/gepnuiib/public_html/template/scripts/functions.php(28): mb_http_input('UTF-8') #1 /home/gepnuiib/public_html/template/plugins/repository/web/blocks.php(26): include('/home/gepnuiib/...') #2 {main} thrown in /home/gepnuiib/public_html/template/scripts/functions.php on line 28

Re: The ultimate mod

Posted: Wed Dec 28, 2022 8:14 pm
by andyk1
Yeah I'm seeing the same. I am guessing wherever his repository was kept is off line.

Re: The ultimate mod

Posted: Thu Dec 29, 2022 5:07 am
by spd2612
Yes here is what I end up with now I think I have the code cleaned up to run php 8.1.13
8.1 did have allot of changes
It now cretes the table and colums and no errors I think it just cant reach the repository
latest dosent populate

Image

Re: The ultimate mod

Posted: Fri Jan 06, 2023 2:48 pm
by spd2612
@ davidefa

Dave Anybody
Can I have the files to make my own repository
No one is on these forums anymore

Re: The ultimate mod

Posted: Sat Jan 14, 2023 4:46 pm
by spd2612
Not sure why but this did start working
Seems all good now
@davidefa If you need any testing done I would be happy to help

Re: The ultimate mod

Posted: Sun Feb 05, 2023 2:00 pm
by davidefa
Sorry for not being present on the forum lately.
- I had a crash on the repository server ( did not solve it too fast ), this was the cause for the mod not showing any update available
- noticed too that the code that checks the presence of a table fails in php 8.x, the solution is the one you proposed ( setting report_mode = MYSQLI_REPORT_OFF ), maybe this should be made 'sitewide', bud did not check it.
- the fatal error on scripts/functions.php line 28 is removed by commenting the line ( was not functional even in php < 8.0 )
- regarding the repository plugin, I never finished it, never created the page to add/remove/edit blocks/plugins/mods, it has to be done via phpmyadmin ( you have also to create the mt_blocks table via the attached sql )