LEPTON CMS 7.2.0
feel free to keep it strictly simple...
Loading...
Searching...
No Matches
lepton_handle.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
25{
26 const HTACCESS_PATH = SECURE_PATH.'/.htaccess';
27 const HTPASSWD_PATH = SECURE_PATH.'/.htpasswd';
28 const ALT_BACKEND_FILE = '/templates/'.DEFAULT_THEME.'/backend/backend/'; // alternative backend file
29 const ALT_FRONTEND_FILE = '/templates/'.TEMPLATE.'/frontend/'; // alternative frontend file
30
31 // [0] class-constants
33 "&amp;lt;" => "<",
34 "&lt;" => "<",
35 "&amp;gt;" => ">",
36 "&gt;" => ">",
37 "&amp;amp;" => "&",
38 "&amp;" => "&",
39 "&quot;" => "\"",
40 "&#039;" => "'"
41 ];
42
49 static public bool $display_errors = true;
50
58 static public function setDisplay(bool $bUseDisplay = true): void
59 {
60 self::$display_errors = $bUseDisplay;
61 }
62
69 public function __call(string $name, array $arguments): void
70 {
71 $msg = "Unknown class-method: '".$name."'\nParams:\n";
72 $msg .= LEPTON_tools::display($arguments, "pre");
73 echo LEPTON_tools::display($msg, "pre", "ui message red");
74 }
75
82 public static function __callStatic(string $name, array $arguments): void
83 {
84 $msg = "Unknown static class-method: '".$name."'\nParams:\n";
85 $msg .= LEPTON_tools::display($arguments, "pre");
86 echo LEPTON_tools::display($msg, "pre", "ui message red");
87 }
88
108 static public function install_table(string $table_name='', string $table_fields=''): bool
109 {
110 if (($table_name == '') || ($table_fields == '')) {
111 return false;
112 }
114 $table = TABLE_PREFIX . $table_name;
115 $database->simple_query("CREATE TABLE `" . $table . "` (" . $table_fields . ") ");
116
117 return true;
118 }
119
138 static public function encrypt_table(string $table_name ='', array $aListOfFields =[], string $field_condition =''): bool
139 {
140 if ($table_name == '')
141 {
142 return false;
143 }
144 if (!is_array($aListOfFields))
145 {
146 LEPTON_tools::display("REQUIRED list of names nof table fields must be an array!", "div", "ui red message");
147 return false;
148 }
149
150 if ( $field_condition == '' ) {
151 return false;
152 }
153
155 self::create_sik_table($table_name); // keep in mind, that drop_table adds the table_prefix
156
157 //get table content
158 $table_content = array();
159 $database->execute_query(
160 "SELECT * FROM ".TABLE_PREFIX.$table_name." ",
161 true,
162 $table_content,
163 true
164 );
165
166 foreach ($table_content as $to_encrypt)
167 {
168 $database->secure_build_and_execute('UPDATE', TABLE_PREFIX . $table_name, $to_encrypt, '' . $field_condition . ' =' . $to_encrypt[$field_condition], $aListOfFields);
169 }
170
171 return true;
172 }
173
174
193 static public function decrypt_table(string $table_name = '', array $aListOfFields = [], string $field_condition = '')
194 {
195 if ($table_name == '')
196 {
197 return false;
198 }
199
200 if (!is_array($aListOfFields))
201 {
202 LEPTON_tools::display("REQUIRED list of names of table-fields must be an array!", "div", "ui red message");
203 return false;
204 }
205
206 if ($field_condition == '')
207 {
208 return false;
209 }
210
212 self::create_sik_table($table_name); // keep in mind, that drop_table adds the table_prefix
213
214 //get table content
215 $table_content = array();
216 $database->secure_execute_query(
217 "SELECT * FROM " . TABLE_PREFIX . $table_name . " ",
218 true,
219 $table_content,
220 true,
221 $aListOfFields
222 );
223
224 foreach ($table_content as $to_decrypt)
225 {
226 $result = $database->build_and_execute(
227 'UPDATE', TABLE_PREFIX.$table_name,
228 $to_decrypt,
229 $field_condition.' ='.$to_decrypt[$field_condition]
230 );
231 }
232
233 return true;
234 }
235
254 static public function insert_values(string $table_name='', string $field_values =''): bool
255 {
256 if (($table_name == '') || ($field_values == '')) {
257 return false;
258 }
259
261 $table = TABLE_PREFIX . $table_name;
262 $database->simple_query("INSERT INTO `" . $table . "` VALUES " . $field_values . " ");
263
264 return true;
265 }
266
267
280 static public function drop_table(string $table_name=''): bool
281 {
282 if ($table_name == '')
283 {
284 return false;
285 }
287 $table = TABLE_PREFIX . $table_name;
288
289 $database->simple_query("DROP TABLE IF EXISTS `" . $table . "` ");
290
291 return true;
292 }
293
304 static public function rename_table(string $table_name =''): bool
305 {
306 if ($table_name == '')
307 {
308 return false;
309 }
311 $table_source = TABLE_PREFIX . $table_name;
312 $table_target = TABLE_PREFIX . 'xsik_' . $table_name;
313 self::drop_table('xsik_' . $table_name);
314 $database->simple_query("RENAME TABLE `" . $table_source . "` TO `" . $table_target . "` ");
315
316 return true;
317 }
318
328 static public function create_sik_table(string $table_name =''): bool
329 {
330 if ($table_name == '')
331 {
332 return false;
333 }
335 $table_source = TABLE_PREFIX . $table_name;
336 $table_target = TABLE_PREFIX . 'xsik_' . $table_name;
337 self::drop_table('xsik_' . $table_name); // keep in mind, that drop_table adds the table_prefix
338 $database->simple_query("CREATE TABLE `" . $table_target . "` LIKE `" . $table_source . "`");
339 $database->simple_query("INSERT INTO `" . $table_target . "` SELECT * FROM `" . $table_source . "`");
340
341 return true;
342 }
343
359 static public function delete_obsolete_files(string|array ...$aFileNames): void
360 {
361 if (is_string($aFileNames))
362 {
363 $aFileNames = [ $aFileNames ];
364 }
365
366 foreach ($aFileNames as $del)
367 {
368 if (is_array($del))
369 {
370 foreach ($del as $subItem)
371 {
373 }
374 }
375 else
376 {
377 $temp_path = ((!str_contains($del, LEPTON_PATH)) ? LEPTON_PATH : "") . $del;
378 if (file_exists($temp_path))
379 {
380 $result = unlink($temp_path);
381 if (false === $result)
382 {
383 echo "<p>Cannot delete file " . $temp_path . ". Please check file permissions and ownership or delete file manually.</p>";
384 }
385 }
386 }
387 }
388 }
389
403 static public function delete_obsolete_directories(array|string $directory_names=[]): void
404 {
405 if (is_string($directory_names))
406 {
407 $directory_names = [$directory_names];
408 }
409
410 self::register('rm_full_dir');
411
412 foreach ($directory_names as $del)
413 {
414 $temp_path = LEPTON_PATH . $del;
415 if (file_exists($temp_path))
416 {
417 $result = rm_full_dir($temp_path);
418 if (false === $result)
419 {
420 echo "Cannot delete directory ".$temp_path.". Please check directory permissions and ownership or deleted directories manually.";
421 }
422 }
423 }
424 }
425
440 static public function rename_directories(array|string $directory_names=[]): void
441 {
442 if (is_string($directory_names))
443 {
444 $directory_names = [$directory_names];
445 }
446
447 self::register('rename_recursive_dirs');
448 foreach ($directory_names as $rename)
449 {
450 $source_path = LEPTON_PATH . $rename['source'];
451 $target_path = LEPTON_PATH . $rename['target'];
452 if (file_exists($source_path))
453 {
454
455 $result = rename_recursive_dirs($source_path, $target_path);
456 if (false === $result)
457 {
458 echo "Cannot rename file ".$source_path.". Please check directory permissions and ownership manually.";
459 }
460
461 }
462 }
463 }
464
478 static public function include_files(array|string $file_names=[], bool $interrupt=true): void
479 {
480 if (is_string($file_names))
481 {
482 $file_names = [$file_names];
483 }
484
485 foreach ($file_names as $requestedFile)
486 {
487 $temp_path = LEPTON_PATH . $requestedFile;
488 if (file_exists($temp_path))
489 {
490 require_once $temp_path;
491 } elseif($interrupt === true)
492 {
494 "<pre class='ui message'>\nCan't include: ".$temp_path."\n</pre>",
495 "pre",
496 "ui message orange"
497 );
498 }
499 }
500 }
501
502
516 static public function require_alternative(string $file_name, string $usage = 'backend'): bool
517 {
518 if (($usage == 'frontend') || ($usage == 'backend'))
519 {
520 $temp_path = LEPTON_PATH.(($usage === 'backend') ? self::ALT_BACKEND_FILE : self::ALT_FRONTEND_FILE).$file_name;
521
522 if (file_exists($temp_path))
523 {
524 require_once $temp_path;
525 return true;
526 }
527 }
528 return false;
529 }
530
544 static public function install_modules(array $module_names = [] ): void
545 {
546 global $module_name, $module_license, $module_author, $module_directory, $module_version, $module_function, $module_description, $module_platform, $module_guid, $lepton_platform;
547 if (is_string($module_names))
548 {
549 $module_names = [$module_names];
550 }
551 LEPTON_handle::register('load_module');
553
554 foreach ($module_names as $temp_addon)
555 {
556 $test = $database->get_one("SELECT `addon_id` FROM `" . TABLE_PREFIX . "addons` WHERE `directory` = '" . $temp_addon . "' ");
557
558 if (is_null($test))
559 {
560 $module_vars = [
561 'module_license', 'module_author' , 'module_name', 'module_directory',
562 'module_version', 'module_function', 'module_description',
563 'module_platform', 'module_guid'
564 ];
565
566 foreach ($module_vars as $varname)
567 {
568 if (isset(${$varname}))
569 {
570 unset(${$varname});
571 }
572 }
573
574 $temp_path = LEPTON_PATH .'/modules/'.$temp_addon ;
575 require $temp_path.'/info.php';
576 load_module( $temp_addon, true );
577 }
578 }
579 }
580
581
595 static public function upgrade_modules(string|array $module_names = []): void
596 {
597 if (is_string($module_names))
598 {
599 $module_names = array($module_names);
600 }
601
602 LEPTON_handle::register('load_module');
603 foreach ($module_names as $update)
604 {
605 $temp_path = LEPTON_PATH . "/modules/" . $update . "/upgrade.php";
606 if (file_exists($temp_path))
607 {
608 // call upgrade-script direct
609 require $temp_path;
611 // update db entries
612 load_module( $update, false );
613
614 // unset module vars
615 foreach(
616 [
617 'module_license', 'module_author' , 'module_name', 'module_directory',
618 'module_version', 'module_function', 'module_description',
619 'module_platform', 'module_guid'
620 ] as $varname
621 )
622 {
623 if (isset(${$varname}))
624 {
625 unset(${$varname});
626 }
627 }
628 }
629 }
630 }
631
648 static public function install_droplets(string $module_name='',string|array $zip_names=[]): void
649 {
650 droplets::getInstance();
651
652 if (is_string($zip_names))
653 {
654 $zip_names = array($zip_names);
655 }
656 foreach ($zip_names as $to_install)
657 {
658 $temp_path = LEPTON_PATH . "/modules/" . $module_name . "/install/".$to_install.".zip";
659 if (file_exists($temp_path))
660 {
661 $result = droplet_install($temp_path, LEPTON_PATH . '/temp/unzip/');
662 if (count($result['errors']) > 0)
663 {
664 die ('ERROR: file is missing: <b> ' . (implode('<br />\n', $result['errors'])) . ' </b>.');
665 }
666 }
667 }
668 self::delete_obsolete_directories(array("/modules/" . $module_name . "/install"));
669 }
670
671
685 static public function uninstall_droplets(string|array $droplet_names = []): void
686 {
687 if (is_string($droplet_names))
688 {
689 $droplet_names = [$droplet_names];
690 }
692
693 foreach ($droplet_names as $to_uninstall)
694 {
695 $to_delete = [];
696 $database->execute_query(
697 "SELECT `id` FROM ".TABLE_PREFIX."mod_droplets WHERE `name` = '".$to_uninstall."' ",
698 true,
699 $to_delete,
700 false
701 );
702 if (isset($to_delete['id']))
703 {
704 $database->simple_query("DELETE FROM `" . TABLE_PREFIX . "mod_droplets` WHERE `id` = " . $to_delete['id']);
705 $database->simple_query("DELETE FROM `" . TABLE_PREFIX . "mod_droplets_permissions` WHERE `id` = " . $to_delete['id']);
706 }
707 }
708 }
709
731 static function register(): bool
732 {
733 if (0 === func_num_args())
734 {
735 return false;
736 }
737
738 $all_args = func_get_args();
739 foreach($all_args as &$param)
740 {
741 if (true === is_array($param))
742 {
743 foreach ($param as $ref)
744 {
745 self::register($ref);
746 }
747 }
748 else
749 {
750 if (!function_exists($param))
751 {
752 $lookUpPath = LEPTON_PATH . "/framework/functions/function." . $param . ".php";
753 if (file_exists($lookUpPath))
754 {
755 require_once $lookUpPath;
756 }
757 }
758 }
759 }
760 return true;
761 }
762
782 public static function checkEmailChars(string $sEmail): bool
783 {
784 $add_custom = '';
785 $ini_file_name = LEPTON_PATH."/config/lepton.ini.php";
786
787 if (true === file_exists($ini_file_name))
788 {
789 $config = parse_ini_string(";" . file_get_contents($ini_file_name), true);
790 if ($config['custom_vars']['additional_email_chars'] != '')
791 {
792 $add_custom = $config['custom_vars']['additional_email_chars'];
793 }
794 }
795 return !((false === filter_var($sEmail, FILTER_VALIDATE_EMAIL)
796 || (!preg_match('#^[' .LEPTON_core::getInstance()->email_chars.$add_custom.']+$#', $sEmail))));
797 }
798
810 public static function checkStringSecure(string $sString): bool
811 {
812 return (preg_match('/^['.LEPTON_core::getInstance()->string_secure.']+$/i', $sString) === 1);
813 }
814
815
835 public static function checkPasswordChars(string $sPassword): bool
836 {
837 $add_custom = '';
838 $ini_file_name = LEPTON_PATH . "/config/lepton.ini.php";
839
840 if (true === file_exists($ini_file_name))
841 {
842 $config = parse_ini_string(";" . file_get_contents($ini_file_name), true);
843 if ($config['custom_vars']['additional_password_chars'] != '')
844 {
845 $add_custom = $config['custom_vars']['additional_password_chars'];
846 }
847 }
848 return !((false === !preg_match('/[^'.LEPTON_core::getInstance()->password_chars.$add_custom.']/', $sPassword)));
849 }
850
851
852
872 public static function checkUsernameChars(string $sName): bool
873 {
874 $add_custom = '';
875 $ini_file_name = LEPTON_PATH."/config/lepton.ini.php";
876
877 if (true === file_exists($ini_file_name))
878 {
879 $config = parse_ini_string(";".file_get_contents($ini_file_name), true);
880 if ($config['custom_vars']['additional_usernames_chars'] != '')
881 {
882 $add_custom = $config['custom_vars']['additional_usernames_chars'];
883 }
884 }
885
886 return !!preg_match("#^[" . LEPTON_core::getInstance()->username_chars . $add_custom . "]+$#", $sName);
887 }
888
915 public static function checkHexChars(string $sHexHash): bool
916 {
917 return !!preg_match("~^[".LEPTON_core::getInstance()->hex_chars."]+$~", $sHexHash);
918 }
919
928 public static function restoreSpecialChars(string &$sAnyString, array $aAnyAssocArray = self::SPECIAL_CHARS_RESTORE): void
929 {
930 $aLookUp = array_keys($aAnyAssocArray);
931 $aReplace = array_values($aAnyAssocArray);
932
933 $sAnyString = str_replace($aLookUp, $aReplace, $sAnyString);
934 }
935
936
942 public static function restoreStandardProtection() : bool
943 {
944 if (file_exists(self::HTACCESS_PATH))
945 {
946 unlink(self::HTACCESS_PATH);
947 unlink(self::HTPASSWD_PATH);
948 }
949 $admin_username = LEPTON_database::getInstance()->get_one("SELECT username FROM " . TABLE_PREFIX . "users WHERE user_id = 1 ");
950 $htuser = $admin_username;
951 $random_value = random_int(100000,999999);
952 $htpassword = password_hash((string)$random_value, PASSWORD_DEFAULT );
953
954$htcontent = "# .htaccess-Datei
955AuthType Basic
956AuthName 'Protected area - Please insert password!'
957AuthUserFile ".self::HTPASSWD_PATH."
958require user ".$htuser."
959";
960
961$htpwcontent = "# Password file, user:".$htuser.", password: ".$random_value."
962".$htuser.":".$htpassword."
963";
964
965 file_put_contents(self::HTACCESS_PATH,$htcontent);
966 file_put_contents(self::HTPASSWD_PATH,$htpwcontent);
967
968 return true;
969 }
970
979 public static function createStandardProtection(string $path = '/temp/secure/', string $username = ''): bool
980 {
981 if($username == '')
982 {
983 echo LEPTON_tools::display('USERNAME is mandantory as second parameter in this method', 'pre', 'ui red message');
984 return false;
985 }
986
987 if (file_exists(LEPTON_PATH . $path . '/.htaccess'))
988 {
989 unlink(LEPTON_PATH.$path.'/.htaccess');
990 unlink(LEPTON_PATH.$path.'/.htpasswd');
991 }
992
993 $htuser = $username;
994 $random_value = random_int(100000,999999);
995 $htpassword = password_hash((string)$random_value, PASSWORD_DEFAULT );
996
997$htcontent = "# .htaccess-Datei
998AuthType Basic
999AuthName 'Protected area - Please insert password!'
1000AuthUserFile ".LEPTON_PATH.$path."/.htpasswd
1001require user ".$htuser."
1002";
1003
1004$htpwcontent = "# Password file, user:".$htuser.", password: ".$random_value."
1005".$htuser.":".$htpassword."
1006";
1007
1008 file_put_contents(LEPTON_PATH . $path . '/.htaccess', $htcontent);
1009 file_put_contents(LEPTON_PATH . $path . '/.htpasswd', $htpwcontent);
1010
1011 return true;
1012 }
1013
1029 static function array_orderby(array $array, string $on, int $order = SORT_ASC): array
1030 {
1031 $new_array = [];
1032 $sortable_array = [];
1033
1034 if (!empty($array))
1035 {
1036 // 1
1037 $lookUpKeys = explode(",", $on);
1038 $keys = array_map("trim", $lookUpKeys);
1039 $keepAssoc = false;
1040 foreach ($array as $k => $v)
1041 {
1042 if (is_array($v))
1043 {
1044 if (isset($v[$keys[0]]))
1045 {
1046 $sortable_array[$k] = "";
1047 foreach ($keys as $term)
1048 {
1049 if (isset($v[$term]))
1050 {
1051 $sortable_array[$k] .= $v[$term];
1052 }
1053 }
1054 }
1055 } else {
1056 $sortable_array[$k] = $v;
1057 $keepAssoc = true;
1058 }
1059 }
1060
1061 switch ($order)
1062 {
1063 case SORT_ASC:
1064 asort($sortable_array, SORT_NATURAL|SORT_FLAG_CASE);
1065 break;
1066
1067 case SORT_DESC:
1068 arsort($sortable_array, SORT_NATURAL|SORT_FLAG_CASE);
1069 break;
1070
1071 default:
1072 LEPTON_tools::display(__CLASS__." [10023] No order match!", "pre", "ui message red");
1073 break;
1074 }
1075
1076 foreach ($sortable_array as $k => $v)
1077 {
1078 if ($keepAssoc === true)
1079 {
1080 $new_array[$k] = $array[$k];
1081 } else {
1082 $new_array[] = $array[$k];
1083 }
1084 }
1085 }
1086
1087 return $new_array;
1088 }
1090 // [5.4.1]
1091 static public function themeExists(string $sThemeName = ""): bool
1092 {
1093 $result = LEPTON_database::getInstance()->get_one("SELECT `directory` FROM `".TABLE_PREFIX."addons` WHERE `directory` ='".$sThemeName."'");
1094 return (!is_null($result));
1095 }
1096
1121 static public function moveThemeFiles(string $sModuleDirectory = ""): void
1122 {
1123 $sSingleModuleDirectory = self::getModuleDirectory($sModuleDirectory);
1124
1125 // get all themes
1126 $aAllThemes = self::getAllThemes();
1127 foreach ($aAllThemes as $sForTheme)
1128 {
1129 $sBaseSourcePath = LEPTON_PATH . "/modules/" . $sSingleModuleDirectory . "/backendthemes/" . $sForTheme;
1130 $sTargetPath = LEPTON_PATH . "/templates/" . $sForTheme . "/backend/" . $sSingleModuleDirectory;
1131
1132 if (true === file_exists($sBaseSourcePath))
1133 {
1134 self::copyThemeFilesRecursive($sBaseSourcePath, $sTargetPath);
1135 }
1136 }
1137 }
1138
1139 // [5.4.3] Internal
1146 static public function copyThemeFilesRecursive(string $dirsource, string $dirdest, int $deep = 0): bool
1147 {
1148 if (true === is_dir($dirsource))
1149 {
1150 if(($deep === 0) && (false === is_dir($dirdest)))
1151 {
1152 LEPTON_core::make_dir($dirdest);
1153 }
1154 $dir= dir($dirsource);
1155 while ( $file = $dir->read() )
1156 {
1157 if( $file[0] === "." )
1158 {
1159 continue;
1160 }
1161 if( !is_dir($dirsource."/".$file) )
1162 {
1163 copy($dirsource . "/" . $file, $dirdest . "/" . $file);
1164 LEPTON_core::change_mode($dirdest . "/" . $file);
1165 } else {
1166 LEPTON_core::make_dir($dirdest . "/" . $file);
1167 self::copyThemeFilesRecursive($dirsource . "/" . $file, $dirdest . '/' . $file, $deep + 1);
1168 }
1169
1170 }
1171 $dir->close();
1172 }
1173 if ($deep == 0)
1174 {
1175 // Is this a working copy? If not ... we try to remove the unneeded files here
1176 if (!file_exists(dirname($dirsource, 2) . "/.git"))
1177 {
1178 LEPTON_handle::register("rm_full_dir");
1179 rm_full_dir( $dirsource );
1180 }
1181 }
1182 return true;
1183 }
1184
1185 // [5.4.4] Deletes all "theme" specific files of a given module from all installed themes.
1190 static public function removeAllThemeFiles(string $sModuleDirectory = ""): void
1191 {
1192 $sSingleModuleDirectory = self::getModuleDirectory($sModuleDirectory);
1193 $aAllThemes = self::getAllThemes();
1194
1195 foreach ($aAllThemes as $aTempThemeDirectory)
1196 {
1197 self::delete_obsolete_directories(["/templates/" . $aTempThemeDirectory . "/backend/" . $sSingleModuleDirectory]);
1198 }
1199 }
1200
1201 // [5.4.5] Try to get the module directory
1206 static public function getModuleDirectory(string $anyNameOrPath = ""): string
1207 {
1208 if (empty($anyNameOrPath))
1209 {
1210 return "";
1211 }
1212
1218 $backtrace = debug_backtrace();
1219 $aTempTest = [""];
1220 if (isset($backtrace[1]['file']))
1221 {
1222 $aTempTest = self::getPathElements($backtrace[1]['file']);
1223 }
1224
1225 // [5.4.5.3] try to extract the module directory
1226 $aTemp = self::getPathElements($anyNameOrPath);
1227
1228 return ($aTemp[0] === $aTempTest[0]) ? $aTemp[0] : "";
1229 }
1230
1231 // [5.4.6] Internal
1235 static public function getAllThemes(): array
1236 {
1237 $aAllThemes = [];
1238 LEPTON_database::getInstance()->execute_query(
1239 "SELECT `directory` FROM `" . TABLE_PREFIX . "addons` WHERE `function` = 'theme'",
1240 true,
1241 $aAllThemes,
1242 true
1243 );
1244 $aReturnValues = [];
1245 foreach($aAllThemes as $aTempTheme)
1246 {
1247 $aReturnValues[] = $aTempTheme["directory"];
1248 }
1249 return $aReturnValues;
1250 }
1251
1259 final static public function getPathElements(string $anyNameOrPath = ""): array
1260 {
1261 return explode(
1262 DIRECTORY_SEPARATOR,
1263 str_replace(
1264 LEPTON_PATH . DIRECTORY_SEPARATOR . "modules" . DIRECTORY_SEPARATOR,
1265 "",
1266 $anyNameOrPath
1267 ));
1268 }
1269
1280 static public function createGUID(): string
1281 {
1282 if (function_exists('com_create_guid'))
1283 {
1284 $guid = com_create_guid();
1285 $guid = strtolower($guid);
1286 if (str_starts_with($guid, '{'))
1287 {
1288 $guid = substr($guid, 1);
1289 }
1290 if (strpos($guid, '}') == strlen($guid) - 1)
1291 {
1292 $guid = substr($guid, 0, strlen($guid) - 1);
1293 }
1294 return $guid;
1295 }
1296 else
1297 {
1298 return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
1299 random_int(0, 0xffff),
1300 random_int(0, 0xffff),
1301 random_int(0, 0xffff),
1302 random_int(0, 0xffff),
1303 random_int(0, 0x0fff) | 0x4000,
1304 random_int(0, 0x3fff) | 0x8000,
1305 random_int(0, 0xffff),
1306 random_int(0, 0xffff)
1307 );
1308 }
1309 }
1310}
static getInstance(array &$settings=[])
static copyThemeFilesRecursive(string $dirsource, string $dirdest, int $deep=0)
static getAllThemes()
static getPathElements(string $anyNameOrPath="")
static setDisplay(bool $bUseDisplay=true)
static themeExists(string $sThemeName="")
static encrypt_table(string $table_name='', array $aListOfFields=[], string $field_condition='')
static moveThemeFiles(string $sModuleDirectory="")
static createStandardProtection(string $path='/temp/secure/', string $username='')
static require_alternative(string $file_name, string $usage='backend')
static install_droplets(string $module_name='', string|array $zip_names=[])
static __callStatic(string $name, array $arguments)
static array_orderby(array $array, string $on, int $order=SORT_ASC)
static restoreStandardProtection()
static rename_table(string $table_name='')
static include_files(array|string $file_names=[], bool $interrupt=true)
static drop_table(string $table_name='')
static checkPasswordChars(string $sPassword)
static delete_obsolete_files(string|array ... $aFileNames)
static uninstall_droplets(string|array $droplet_names=[])
static restoreSpecialChars(string &$sAnyString, array $aAnyAssocArray=self::SPECIAL_CHARS_RESTORE)
static removeAllThemeFiles(string $sModuleDirectory="")
const ALT_FRONTEND_FILE
static upgrade_modules(string|array $module_names=[])
static install_table(string $table_name='', string $table_fields='')
static checkHexChars(string $sHexHash)
static create_sik_table(string $table_name='')
static delete_obsolete_directories(array|string $directory_names=[])
static install_modules(array $module_names=[])
static checkEmailChars(string $sEmail)
__call(string $name, array $arguments)
static checkUsernameChars(string $sName)
const SPECIAL_CHARS_RESTORE
static rename_directories(array|string $directory_names=[])
static bool $display_errors
static getModuleDirectory(string $anyNameOrPath="")
static insert_values(string $table_name='', string $field_values='')
static checkStringSecure(string $sString)
static decrypt_table(string $table_name='', array $aListOfFields=[], string $field_condition='')
static display(mixed $something_to_display="", string $tag="pre", string|null $css_class=null, bool|null $useVarDump=null)
$database
Definition constants.php:52
load_module( $directory, $install=false)
rename_recursive_dirs(string $dirsource, string $dirdest, int $deep=0)
rm_full_dir(string $directory)