LEPTON CMS 7.0.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
function.load_module.php
Go to the documentation of this file.
1<?php
2
18// include secure.php to protect this file and the whole CMS!
19if(!defined("SEC_FILE")){define("SEC_FILE",'/framework/secure.php' );}
20if (defined('LEPTON_PATH')) {
21 include LEPTON_PATH.SEC_FILE;
22} else {
23 $oneback = "../";
24 $root = $oneback;
25 $level = 1;
26 while (($level < 10) && (!file_exists($root.SEC_FILE))) {
27 $root .= $oneback;
28 $level += 1;
29 }
30 if (file_exists($root.SEC_FILE)) {
31 include $root.SEC_FILE;
32 } else {
33 trigger_error(sprintf("[ <b>%s</b> ] Can't include secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
34 }
35}
36// end include secure file
37
38
46function load_module( $directory, $install = false )
47{
48 global $MESSAGE;
50
51 if (is_dir( LEPTON_PATH.'/modules/'.$directory) && file_exists(LEPTON_PATH.'/modules/'.$directory .'/info.php'))
52 {
53 require LEPTON_PATH.'/modules/'.$directory.'/info.php';
54
55 $module_function = strtolower( $module_function );
56 if(!isset($module_delete))
57 {
58 $module_delete = true;
59 }
60
61 // Check that it doesn't already exist
62 $sqlwhere = " type = 'module' AND directory = '".$module_directory."' ";
63 if ( $database->get_one("SELECT COUNT(*) FROM ".TABLE_PREFIX."addons WHERE ".$sqlwhere) > 0 )
64 {
65 $sql_job = "update";
66 }
67 else
68 {
69 $sql_job = "insert";
70 $sqlwhere = '';
71 }
72
73 $fields = array(
74 'directory' => $module_directory,
75 'name' => $module_name,
76 'description' => $module_description,
77 'type' => 'module',
78 'function' => strtolower( $module_function ),
79 'to_delete' => intval( $module_delete ),
80 'version' => $module_version,
81 'platform' => $module_platform,
82 'author' => $module_author,
83 'license' => $module_license
84 );
85
86 if (isset($module_guid))
87 {
88 $fields['guid'] = $module_guid;
89 }
90
91 $database->build_and_execute(
92 $sql_job,
93 TABLE_PREFIX . "addons",
94 $fields,
95 $sqlwhere
96 );
97
98
99 // Run installation script
100 if (($install === true) && (file_exists(LEPTON_PATH.'/modules/'.$directory.'/install.php')))
101 {
102 require LEPTON_PATH.'/modules/'.$directory.'/install.php';
103 }
104 }
105}
static getInstance(array &$settings=[])
$database
Definition constants.php:52
load_module( $directory, $install=false)