select($table, "*", ["opid" => $opid, "ORDER" => ["id" => "DESC"], "LIMIT" => $limit]); } elseif ($opid) { $datatable = $jakdb->select($table, "*", ["opid" => $opid, "ORDER" => ["id" => "DESC"]]); } elseif (!empty($limit)) { $datatable = $jakdb->select($table, "*", ["ORDER" => ["id" => "DESC"], "LIMIT" => $limit]); } else { $datatable = $jakdb->select($table, "*", ["ORDER" => ["id" => "DESC"]]); } if (!empty($datatable)) return $datatable; } // Get the available front end packages function jak_get_templates() { // Get the template folder $packdir = '../'.'template/'; return array_diff(scandir($packdir), array('..', '.', 'index.html', '.DS_Store')); } // Search for lang files in the admin folder, only choose .ini files. function jak_get_chat_templates() { // Get the chat template folder $packdir = '../'.'lctemplate/'; return array_diff(scandir($packdir), array('..', '.', 'index.html', '.DS_Store')); } // Make the filename beautiful function jak_tpl_name($tpl) { // First we remove the .php $tpl = substr($tpl, 0, -4); // Then we remove the _ $tpl = str_replace("_", " ", $tpl); // Finally we make each first letter uppercase $tpl = ucwords($tpl); return $tpl; } // Get files function jak_get_templates_files($directory) { foreach (glob($directory."*.php") as $file) { $getTPL[] = basename($file); } if (!empty($getTPL)) return $getTPL; } // Get avatar sets function jak_get_avatar_sets($template) { // Get the avatar folder $packdir = '../'.'lctemplate/'.$template.'/avatar/'; return array_diff(scandir($packdir), array('..', '.', 'index.html', '.DS_Store')); } // Get avatar images function jak_get_avatar_images($template, $avatarset) { // Get the avatar folder $packdir = '../lctemplate/'.$template.'/avatar/'.$avatarset.'/'; foreach (glob($packdir."*.jpg") as $file) { $getAva[] = $file; } if (!empty($getAva)) return $getAva; } // Search for lang files in the admin folder, only choose .ini files. function jak_get_sound_files() { $getsound = array(); global $jakdb; // Get the sounds from the installed packages $packsound = $jakdb->select("chatwidget", "template", ["GROUP" => "template"]); if (isset($packsound) && !empty($packsound)) { foreach ($packsound as $v) { $packagef = 'lctemplate/'.$v.'/'; if (file_exists('../'.$packagef.'config.php')) { include_once '../'.$packagef.'config.php'; if (isset($jakgraphix["sound"]) && !empty($jakgraphix["sound"])) { // Get the general sounds $dynsound = '../'.$packagef.$jakgraphix["sound"]; if ($dynhandle = opendir($dynsound)) { /* This is the correct way to loop over the directory. */ while (false !== ($dynfile = readdir($dynhandle))) { $dynshowsound = substr($dynfile, strrpos($dynfile, '.')); if ($dynfile != '.' && $dynfile != '..' && $dynshowsound == '.mp3') { $getsound[] = $packagef.$jakgraphix["sound"].substr($dynfile, 0, -4); } } closedir($dynhandle); } } } } } // Get the general sounds $soundir = '../sound/'; if ($handle = opendir($soundir)) { /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { $showsound = substr($file, strrpos($file, '.')); if ($file != '.' && $file != '..' && $showsound == '.mp3') { $getsound[] = 'sound/'.substr($file, 0, -4); } } closedir($handle); return $getsound; } } // Remove chat options because of the template function jak_remove_chat_options($opid, $formtype, $widgetid) { global $jakdb; if ($jakdb->delete("chatsettings", ["AND" => ["opid" => $opid, "widgetid" => $widgetid, "formtype" => $formtype]])) { return true; } } // Get all user out the database limited with the paginator function jak_get_user_all($table, $userid, $limit = '') { global $jakdb; if ($userid) { if ($limit == "meandsibling") { $datausr = $jakdb->select($table, "*", ["OR" => ["id" => $userid, "opid" => $userid]]); } elseif ($limit == "siblings") { $datausr = $jakdb->select($table, "*", ["AND" => ["opid" => $userid, "extraop" => 1]]); } else { $datausr = $jakdb->select($table, "*", ["id" => $userid]); } } else { $datausr = $jakdb->select($table, "*", ["LIMIT" => $limit]); } return $datausr; } // Check if user exist and it is possible to delete ## (config.php) function jak_user_exist_deletable($id) { $useridarray = explode(',', JAK_SUPERADMIN); // check if userid is protected in the config.php if (in_array($id, $useridarray)) { return false; } else { global $jakdb; if ($jakdb->has("user", ["id" => $id])) return true; } return false; } function secondsToTime($seconds,$time) { $singletime = explode(",", $time); if (is_numeric($seconds)) { $dtF = new DateTime("@0"); $dtT = new DateTime("@$seconds"); return $dtF->diff($dtT)->format('%a '.$singletime[0].', %h '.$singletime[1].', %i '.$singletime[2].' '.$singletime[4].' %s '.$singletime[3]); } else { return '0 '.$singletime[0].', 0 '.$singletime[1].', 0 '.$singletime[2].' '.$singletime[4].' 0 '.$singletime[3]; } } // Get the custom fields ready to serve function jak_get_custom_fields_tpl($opid, $widgetid, $template, $formtype, $formfields, $buttons, $slideimg) { global $jakdb; $fields = $translations = ''; if (isset($formfields) && !empty($formfields)) { foreach ($formfields as $v) { // We explode each form $fvalue = explode(":#:", $v); // Get the correct fields $formdata = $jakdb->get('chatsettings', ["lang", "settname", "settvalue"], ["AND" => ["opid" => $opid, "widgetid" => $widgetid, "template" => $template, "formtype" => $formtype, "settname" => jak_clean_string($fvalue[4])]]); if ($fvalue[0] == 3 || $fvalue[0] == 4 || $fvalue[0] == 5) { $fieldoptions = explode(",", $fvalue[2]); // Set translation to false because it does not exist $tl = false; } // We will need a hidden input fields to find out what we need to save $fields .= ''; if ($fvalue[0] == 1) { // INPUT $fields .= '