Skip to main content

Get the version of opencart from the index file using an external script.

If you are writing standalone scripts that are using the informations from opencart this small function can be useful. It will return the current version of opencart.



function getcurrentversion($indexfile='index.php'){
    if(file_exists($indexfile)) {
        $fd = fopen($indexfile,'r');
        if(empty($fd)){return false;}
        while (!feof($fd)) {
            $buffer = fgets($fd);
            if(preg_match("#define\('VERSION', '(.*?)'\);#",$buffer,$matches)){
                fclose($fd);
                return $matches[1];
            }
        }
        fclose($fd);
    } else {
        return false;
    }
}


I add also a switch with different opencart versions. Not very useful but there are also older and not (not anymore) documented versions.



switch($version){
    case '2.2.0.0':
    break;
    case '2.1.0.2':
    break;
    case '2.1.0.1':
    break;
    case '2.0.3.1':
    break;
    case '2.0.2.0':
    break;
    case '2.0.1.1':
    break;
    case '2.0.1.0':
    break;
    case '2.0.0.0':
    break;
    case '1.5.6.4':
    break;
    case '1.5.6.3':
    break;
    case '1.5.6.2':
    break;
    case '1.5.6.1':
    break;
    case '1.5.6':
    break;
    case '1.5.5.1':
    break;
    case '1.5.4.1':
    break;
    case '1.5.4':
    break;
    case '1.5.0':
    break;
    case '1.5.0.1':
    break;
    case '1.5.0.2':
    break;
    case '1.5.0.3':
    break;
    case '1.5.0.4':
    break;
    case '1.5.0.5':
    break;
    case '1.5.1':
    break;
    case '1.5.1.1':
    break;
    case '1.5.1.2':
    break;
    case '1.5.1.3':
    break;
    case '1.5.2':
    break;
    case '1.5.2.1':
    break;
    case '1.5.3':
    break;
    case '1.5.3.1':
    break;
    case default
        die('Cannot determine your Opencart Version');
    break;
}

Comments

Popular posts from this blog

Moodle 3.8.1+ - path leak via errors in several files

Moodle 3.8.1+ ----------------------------------------------- File: admin/mailout-debugger.php #!/usr/bin/php Notice : Disabled. in \admin\mailout-debugger.php on line 73 File: admin/settings/appearance.php Notice : Undefined variable: hassiteconfig in \admin\settings\appearance.php on line 10 Fatal error : Uncaught Error: Call to undefined function has_any_capability() in \admin\settings\appearance.php:10 Stack trace: #0 {main} thrown in \admin\settings\appearance.php on line 10 File: admin/settings/badges.php Notice : Undefined variable: hassiteconfig in \admin\settings\badges.php on line 30 Fatal error : Uncaught Error: Call to undefined function has_any_capability() in \admin\settings\badges.php:30 Stack trace: #0 {main} thrown in \admin\settings\badges.php on line 30 File: admin/settings/courses.php Notice : Undefined variable: hassiteconfig in \admin\settings\courses.php on line 32 Fatal error : Uncaught Error: Call to undefined function

2022 - Remove (the too many) Ads from Memu launcher

Simple method Download from pureapk "MEmu Launcher2" ex: MEmu Launcher2_v6.0.9_apkpure.com Install "System app remover" (root) remove from system apps the "memu launcher 2" import the "purified" MEmu Launcher2 apk with the Memu utility ("apk" on the right toolbar) Longer method Install "Export Apk" Export the memu launcher2  Install purify https://github.com/echo-devim/purify/raw/master/Purify.apk use purify with the exported memu launcher 2 Install "System app remover" (root) remove from system apps the "memu launcher 2" import the "purified" MEmu Launcher2 apk with the Memu utility ("apk" on the right toolbar)