function fill_template_session($daten_config, $daten_config1, $u_template) { if (!$daten_config['value']) { if (check_template($u_template)) { $_SESSION['template'] = $u_template; } else { $_SESSION['template'] = $daten_config1['value']; } } else { $_SESSION['template'] = $daten_config['value']; } }
function syn_templates() { global $db, $tpf; $dirs = scandir(PHPDISK_ROOT . 'templates'); sort($dirs); for ($i = 0; $i < count($dirs); $i++) { if (check_template($dirs[$i])) { $arr[] = $dirs[$i]; } } $q = $db->query("select * from {$tpf}templates where actived=1"); while ($rs = $db->fetch_array($q)) { if (check_template($rs['tpl_name'])) { $active_templates .= $rs['tpl_name'] . ','; } } $db->free($q); unset($rs); if (trim(substr($active_templates, 0, -1))) { $active_arr = explode(',', $active_templates); } for ($i = 0; $i < count($arr); $i++) { $tmp = get_template_info($arr[$i]); if (@in_array($arr[$i], $active_arr)) { $sql_do .= "('" . $db->escape($arr[$i]) . "','1','" . $db->escape(trim($tmp['tpl_type'])) . "'),"; } else { $sql_do .= "('" . $db->escape($arr[$i]) . "','0','" . $db->escape(trim($tmp['tpl_type'])) . "'),"; } } $sql_do = substr($sql_do, 0, -1); $db->query_unbuffered("truncate table {$tpf}templates;"); $db->query_unbuffered("replace into {$tpf}templates(tpl_name,actived,tpl_type) values {$sql_do} ;"); $num = @$db->result_first("select count(*) from {$tpf}templates where tpl_type='admin' and actived=1"); if (!$num) { $db->query_unbuffered("update {$tpf}templates set actived=1 where tpl_name='admin'"); } $num = @$db->result_first("select count(*) from {$tpf}templates where tpl_type='user' and actived=1"); if (!$num) { $db->query_unbuffered("update {$tpf}templates set actived=1 where tpl_name='default'"); } return true; }
public static function init_lang_tpl() { global $C, $settings, $auth; $dir = PHPDISK_ROOT . 'system/global/'; make_dir($dir); $file = $dir . 'lang_settings.inc.php'; file_exists($file) ? require_once $file : lang_cache(); $file = $dir . 'tpl_settings.inc.php'; file_exists($file) ? require_once $file : tpl_cache(); if (count($tpl_settings)) { foreach ($tpl_settings as $v) { if ($v[actived] && $v[tpl_type] == 'user') { $user_tpl_dir = $v[tpl_name]; } if ($v[actived] && $v[tpl_type] == 'admin') { $admin_tpl_dir = $v[tpl_name]; } } } if (count($lang_settings)) { foreach ($lang_settings as $v) { if ($v[actived]) { $lang_name = $v[lang_name]; } } } if ($settings[open_switch_tpls]) { $ptpl = gpc('ptpl', 'C', ''); $user_tpl_dir = $C[tpl_name] = $ptpl ? check_template($ptpl) ? $ptpl : $user_tpl_dir : $user_tpl_dir; //$C[tpl_name] = $user_tpl_dir; } $arr = get_template_info($user_tpl_dir); $is_fms = $arr['template_core'] == 'fms' && $auth[open_fms] ? 1 : 0; $user_tpl_dir = $user_tpl_dir ? "templates/{$user_tpl_dir}/" : 'templates/default/'; $admin_tpl_dir = $admin_tpl_dir ? "templates/{$admin_tpl_dir}/" : 'templates/admin/'; $lang_name = $lang_name ? $lang_name : 'zh_cn'; return array('user_tpl_dir' => $user_tpl_dir, 'admin_tpl_dir' => $admin_tpl_dir, 'lang_name' => $lang_name, 'fms' => $is_fms); }
$table->construct_row(); $table->output($lang->search_results); } else { $template_list = array(); while ($template = $db->fetch_array($query)) { $template_list[$template['sid']][$template['title']] = $template; } $count = 0; foreach ($template_list as $sid => $templates) { ++$count; $search_header = $lang->sprintf($lang->search_header, htmlspecialchars_uni($mybb->input['find']), $template_sets[$sid]); $table->construct_header($search_header, array("colspan" => 2)); foreach ($templates as $title => $template) { // Do replacement $newtemplate = str_ireplace($mybb->input['find'], $mybb->input['replace'], $template['template']); if ($newtemplate != $template['template'] && check_template($newtemplate) === false) { // If the template is different, that means the search term has been found. if (trim($mybb->input['replace']) != "") { if ($template['sid'] == -2) { // The template is a master template. We have to make a new custom template. $new_template = array("title" => $db->escape_string($title), "template" => $db->escape_string($newtemplate), "sid" => 1, "version" => $mybb->version_code, "status" => '', "dateline" => TIME_NOW); $new_tid = $db->insert_query("templates", $new_template); $label = $lang->sprintf($lang->search_created_custom, $template['title']); $url = "index.php?module=style-templates&action=edit_template&title=" . urlencode($template['title']) . "&sid=1"; } else { // The template is a custom template. Replace as normal. // Update the template if there is a replacement term $updatedtemplate = array("template" => $db->escape_string($newtemplate)); $db->update_query("templates", $updatedtemplate, "tid='" . $template['tid'] . "'"); $label = $lang->sprintf($lang->search_updated, $template['title']); $url = "index.php?module=style-templates&action=edit_template&title=" . urlencode($template['title']) . "&sid={$template['sid']}";
} $page->add_breadcrumb_item($lang->system_health, "index.php?module=tools-system_health"); $sub_tabs['system_health'] = array('title' => $lang->system_health, 'link' => "index.php?module=tools-system_health", 'description' => $lang->system_health_desc); $sub_tabs['utf8_conversion'] = array('title' => $lang->utf8_conversion, 'link' => "index.php?module=tools-system_health&action=utf8_conversion", 'description' => $lang->utf8_conversion_desc2); $sub_tabs['template_check'] = array('title' => $lang->check_templates, 'link' => "index.php?module=tools-system_health&action=check_templates", 'description' => $lang->check_templates_desc); $plugins->run_hooks("admin_tools_system_health_begin"); if ($mybb->input['action'] == "do_check_templates" && $mybb->request_method == "post") { $plugins->run_hooks("admin_tools_system_health_template_do_check_start"); $query = $db->simple_select("templates", "*", "", array("order_by" => "sid, title", "order_dir" => "ASC")); if (!$db->num_rows($query)) { flash_message($lang->error_invalid_input, 'error'); admin_redirect("index.php?module=tools-system_health"); } $t_cache = array(); while ($template = $db->fetch_array($query)) { if (check_template($template['template']) == true) { $t_cache[$template['sid']][] = $template; } } if (empty($t_cache)) { flash_message($lang->success_templates_checked, 'success'); admin_redirect("index.php?module=tools-system_health"); } $plugins->run_hooks("admin_tools_system_health_template_do_check"); $page->add_breadcrumb_item($lang->check_templates); $page->output_header($lang->check_templates); $page->output_nav_tabs($sub_tabs, 'template_check'); $page->output_inline_error(array($lang->check_templates_info_desc)); $templatesets = array(-2 => array("title" => "MyBB Master Templates")); $query = $db->simple_select("templatesets", "*"); while ($set = $db->fetch_array($query)) {
$folder = htmlentities($_POST['folder']); if (!preg_match("/^[a-zA-Z0-9._-]+\$/", $name)) { $msg = _addons_message_error_name . "<br>"; $error = true; } if (!preg_match("/^[a-zA-Z0-9._-]+\$/", $game)) { $msg = _addons_message_error_game . "<br>"; $error = true; } else { $stmt = $mysqli->prepare("SELECT id FROM templates WHERE name = ?"); $stmt->bind_param('i', $game); $stmt->execute(); $stmt->bind_result($template_id); $stmt->fetch(); $stmt->close(); if (check_template($template_id)) { $msg = _message_addon_error; $error = true; } } if (isValidURL($url) == false) { $msg = _addons_message_error_url; $error = true; } if ($error == false) { $stmt = $mysqli->prepare("SELECT id FROM templates WHERE name = ?"); $stmt->bind_param('i', $game); $stmt->execute(); $stmt->bind_result($template_id); $stmt->fetch(); $stmt->close();
function save_partner_meta($post_id, $post, $update) { global $meta_keys; global $wpdb; $file_id = null; $restrict_to = null; $new_settings = null; // If this isn't a 'partner' post, don't update it. if ('partner' != $post->post_type) { return; } // Delete any previous errors //error_log(print_R($_POST, true)); if (isset($_POST['registerforevent_nonce']) && !wp_verify_nonce($_POST['registerforevent_nonce'], 'registerforevent')) { return $post_id; } //error_log(print_R($_POST, true)); if (!current_user_can('edit_post', $post_id)) { return $post_id; } //error_log(print_R($_POST, true)); if (isset($_POST['event']) && !empty($_POST['event'])) { $new_settings = $_POST['event']; } else { return $post_id; } //error_log(print_R($_POST, true)); //error_log('new settings p '. print_R($_POST, true)); //error_log('new settings '. print_R($new_settings, true)); //error_log('meta '. print_R($meta_keys, true)); foreach ($meta_keys as $k) { if (isset($new_settings[$k])) { //error_log($k.' = '. $new_settings[$k].'||'. intval( $new_settings[$k] ) ); if (in_array($k, array('privacy', 'organizer_id', 'venue_id', 'venue_organizer_id', 'capacity'))) { if ($new_settings[$k] != '') { update_post_meta($post_id, $k, bigintval($new_settings[$k])); } else { update_post_meta($post_id, $k, ''); } } else { if (in_array($k, array('custom_header', 'custom_footer'))) { $new_settings[$k] = htmlspecialchars($new_settings[$k]); update_post_meta($post_id, $k, wp_filter_post_kses($new_settings[$k])); } elseif (in_array($k, array('organizer_logo'))) { $new_settings[$k] = str_replace(get_option('siteurl'), '', $new_settings[$k]); update_post_meta($post_id, $k, sanitize_text_field($new_settings[$k])); } else { update_post_meta($post_id, $k, sanitize_text_field($new_settings[$k])); } //error_log($k.' = '. $new_settings[$k] ) ; } } } // Save post template if (isset($_POST['post_template'])) { update_post_meta($post_id, '_post_template', sanitize_text_field($_POST['post_template'])); } // Make sure no cached data exists delete_transient('partners_' . $post_id); $settings = array(); foreach ($meta_keys as $k) { $settings[$k] = $_POST['event'][$k]; } set_transient('partners_' . $post_id, $settings, 86400); // Check if the template file is on place check_template(); $wpdb->update($wpdb->prefix . "posts", array('post_name' => sanitize_title_with_dashes($new_settings['organizer_shortname'])), array('ID' => $post_id)); /* wpdb->update( $wpdb->prefix . "posts", array( 'post_name' => sanitize_title_with_dashes( $new_settings['organizer_shortname'] ), ), array('ID' => $post_id)); $post = get_post($post_id); $post->post_name = sanitize_title_with_dashes( $new_settings['organizer_shortname'] ); wp_update_post( $post ); */ return $post_id; }
function ougc_awards_activate() { global $PL, $lang, $cache, $awards; $awards->lang_load(); ougc_awards_deactivate(); // Add settings group $PL->settings('ougc_awards', $lang->setting_group_ougc_awards, $lang->setting_group_ougc_awards_desc, array('postbit' => array('title' => $lang->setting_ougc_awards_postbit, 'description' => $lang->setting_ougc_awards_postbit_desc, 'optionscode' => 'text', 'value' => 4), 'profile' => array('title' => $lang->setting_ougc_awards_profile, 'description' => $lang->setting_ougc_awards_profile_desc, 'optionscode' => 'text', 'value' => 4), 'modcp' => array('title' => $lang->setting_ougc_awards_modcp, 'description' => $lang->setting_ougc_awards_modcp_desc, 'optionscode' => 'yesno', 'value' => 1), 'modgroups' => array('title' => $lang->setting_ougc_awards_modgroups, 'description' => $lang->setting_ougc_awards_modgroups_desc, 'optionscode' => 'groupselect', 'value' => '3,4,6'), 'pagegroups' => array('title' => $lang->setting_ougc_awards_pagegroups, 'description' => $lang->setting_ougc_awards_pagegroups_desc, 'optionscode' => 'groupselect', 'value' => '2,3,4,5,6'), 'perpage' => array('title' => $lang->setting_ougc_awards_perpage, 'description' => $lang->setting_ougc_awards_perpage_desc, 'optionscode' => 'text', 'value' => 20), 'sendpm' => array('title' => $lang->setting_ougc_awards_sendpm, 'description' => $lang->setting_ougc_awards_sendpm_desc, 'optionscode' => 'yesno', 'value' => 1))); // Add template group $PL->templates('ougcawards', '<lang:setting_group_ougc_awards>', array('modcp_manage' => '<form action="modcp.php" method="post"> <input type="hidden" name="action" value="awards" /> <input type="hidden" name="manage" value="{$mybb->input[\'manage\']}" /> <input type="hidden" name="aid" value="{$mybb->input[\'aid\']}" /> <table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder"> <tr> <td class="thead" colspan="2"> <strong>{$lang->ougc_awards_modcp_title_give}</strong> </td> </tr> <tr> <td class="trow1" width="25%"><strong>{$lang->ougc_awards_modcp_username}:</strong></td> <td class="trow1" width="75%"><input type="text" class="textbox" name="username" id="username" value="{$mybb->input[\'username\']}" size="25" /></td> </tr> {$reason} </table> <br /> <div align="center"> <input type="submit" class="button" value="{$lang->ougc_awards_modcp_give}" /> </div> </form> <link rel="stylesheet" href="{$mybb->asset_url}/jscripts/select2/select2.css"> <script type="text/javascript" src="{$mybb->asset_url}/jscripts/select2/select2.min.js"></script> <script type="text/javascript"> <!-- if(use_xmlhttprequest == "1") { MyBB.select2(); $("#username").select2({ placeholder: "{$lang->search_user}", minimumInputLength: 3, maximumSelectionSize: 3, multiple: false, ajax: { // instead of writing the function to execute the request we use Select2\'s convenient helper url: "xmlhttp.php?action=get_users", dataType: \'json\', data: function (term, page) { return { query: term, // search term }; }, results: function (data, page) { // parse the results into the format expected by Select2. // since we are using custom formatting functions we do not need to alter remote JSON data return {results: data}; } }, initSelection: function(element, callback) { var value = $(element).val(); if (value !== "") { callback({ id: value, text: value }); } }, // Allow the user entered text to be selected as well createSearchChoice:function(term, data) { if ( $(data).filter( function() { return this.text.localeCompare(term)===0; }).length===0) { return {id:term, text:term}; } }, }); } // --> </script>', 'modcp_nav' => '<tr><td class="trow1 smalltext"><a href="modcp.php?action=awards" class="modcp_nav_item" style="background: url(\'images/modcp/awards.png\') no-repeat left center;">{$lang->ougc_awards_modcp_nav}</a></td></tr>', 'modcp' => '<html> <head> <title>{$mybb->settings[\'bbname\']} - {$lang->ougc_awards_modcp_nav}</title> {$headerinclude} </head> <body> {$header} <table width="100%" border="0" align="center"> <tr> {$modcp_nav} <td valign="top"> {$errors} {$content} </td> </tr> </table> {$footer} </body> </html>', 'modcp_list_empty' => '<tr> <td class="trow1" colspan="4" align="center"> {$lang->ougc_awards_modcp_list_empty} </td> </tr>', 'modcp_list' => '<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder"> <tr> <td class="thead" colspan="4"> <a href="{$mybb->settings[\'bburl\']}/modcp.php?action=awards&manage=update_cache" style="float:right;" class="smalltext">({$lang->ougc_awards_modcp_cache})</a> <strong>{$lang->ougc_awards_modcp_nav}</strong> </td> </tr> <tr> <td class="tcat smalltext" colspan="4"> <strong>{$lang->ougc_awards_modcp_list_desc}</strong> </td> </tr> {$awardlist} </table> <span class="smalltext">{$lang->ougc_awards_modcp_list_note}</span>', 'modcp_list_award' => '<tr> <td class="trow1" align="center" width="1%"><a href="{$mybb->settings[\'bburl\']}/awards.php?view={$award[\'aid\']}" title="{$award[\'name\']}"><img src="{$award[\'image\']}" alt="{$award[\'name\']}" /></a></td> <td class="trow1" width="15%">{$award[\'name\']}</td> <td class="trow1">{$award[\'description\']}</td> <td class="trow1" align="center" width="15%">[<a href="{$mybb->settings[\'bburl\']}/modcp.php?action=awards&manage=give&aid={$award[\'aid\']}">{$lang->ougc_awards_modcp_give}</a> | <a href="{$mybb->settings[\'bburl\']}/modcp.php?action=awards&manage=revoke&aid={$award[\'aid\']}">{$lang->ougc_awards_modcp_revoke}</a>]</td> </tr>', 'modcp_manage_reason' => '<tr> <td class="trow2" width="25%"><strong>{$lang->ougc_awards_modcp_reason}:</strong></td> <td class="trow2" width="75%"><textarea type="text" class="textarea" name="reason" id="reason" rows="4" cols="40">{$mybb->input[\'reason\']}</textarea></td> </tr>', 'postbit' => '{$br}<a href="{$mybb->settings[\'bburl\']}/awards.php?view={$award[\'aid\']}" title="{$award[\'name\']}"><img src="{$award[\'image\']}" alt="{$award[\'name\']}" /></a>', 'profile' => '<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder tfixed"> <tr> <td class="thead"><strong>{$lang->ougc_awards_profile_title}</strong></td> </tr> {$awardlist} {$multipage} </table> <br />', 'profile_row' => '<tr> <td class="{$trow}"> <span class="float_right smalltext">{$award[\'date\']}</span> {$award[\'name\']} </td> </tr><tr> <td class="{$trow}" style="vertical-align: middle;"> <a href="{$mybb->settings[\'bburl\']}/awards.php?view={$award[\'aid\']}" title="{$award[\'name\']}"><img src="{$award[\'image\']}" alt="{$award[\'name\']}" /></a> {$award[\'reason\']} </td> </tr>', 'profile_row_empty' => '<tr> <td class="trow1"> {$lang->ougc_awards_profile_empty} </td> </tr>', 'page' => '<html> <head> <title>{$mybb->settings[\'bbname\']} - {$lang->ougc_awards_page_title}</title> {$headerinclude} </head> <body> {$header} {$content} {$multipage} {$footer} </body> </html>', 'page_list' => '<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder"> <tr> <td class="thead" colspan="4"> <strong>{$lang->ougc_awards_page_title}</strong> </td> </tr> <tr> <td class="tcat smalltext" align="center" width="1%"><strong>{$lang->ougc_awards_page_list_award}</strong></td> <td class="tcat smalltext" width="15%"><strong>{$lang->ougc_awards_page_list_name}</strong></td> <td class="tcat smalltext"><strong>{$lang->ougc_awards_page_list_description}</strong></td> </tr> {$award_list} </table>', 'page_list_award' => '<tr> <td class="{$trow}" align="center"><a href="{$mybb->settings[\'bburl\']}/awards.php?view={$award[\'aid\']}" title="{$award[\'name\']}"><img src="{$award[\'image\']}" alt="{$award[\'name\']}" /></a></td> <td class="{$trow}"><a href="{$mybb->settings[\'bburl\']}/awards.php?view={$award[\'aid\']}" title="{$award[\'name\']}">{$award[\'name\']}</a></td> <td class="{$trow}">{$award[\'description\']}</td> </tr>', 'page_list_empty' => '<tr> <td class="trow1" colspan="4" align="center"> {$lang->ougc_awards_page_list_empty} </td> </tr>', 'page_view' => '<table border="0" cellspacing="{$theme[\'borderwidth\']}" cellpadding="{$theme[\'tablespace\']}" class="tborder"> <tr> <td class="thead" colspan="4"> <strong>{$award[\'name\']}</strong> </td> </tr> <tr> <td class="tcat smalltext" width="15%"><strong>{$lang->ougc_awards_modcp_username}</strong></td> <td class="tcat smalltext"><strong>{$lang->ougc_awards_modcp_reason}</strong></td> <td class="tcat smalltext" align="center" width="20%"><strong>{$lang->ougc_awards_page_view_date}</strong></td> </tr> {$users_list} </table>', 'page_view_empty' => '<tr> <td class="trow1" colspan="3" align="center">{$lang->ougc_awards_page_view_empty}</td> </tr>', 'page_view_row' => '<tr> <td class="{$trow}">{$gived[\'username\']}</td> <td class="{$trow}">{$gived[\'reason\']}</td> <td class="{$trow}" align="center">{$gived[\'date\']}</td> </tr>')); // Modify templates require_once MYBB_ROOT . '/inc/adminfunctions_templates.php'; find_replace_templatesets('postbit', '#' . preg_quote('{$post[\'user_details\']}') . '#', '{$post[\'user_details\']}{$post[\'ougc_awards\']}'); find_replace_templatesets('postbit_classic', '#' . preg_quote('{$post[\'user_details\']}') . '#', '{$post[\'user_details\']}{$post[\'ougc_awards\']}'); find_replace_templatesets('member_profile', '#' . preg_quote('{$signature}') . '#', '{$signature}{$memprofile[\'ougc_awards\']}'); find_replace_templatesets('modcp_nav', '#' . preg_quote('{$modcp_nav_users}') . '#', '{$modcp_nav_users}<!--OUGC_AWARDS-->'); // Update administrator permissions change_admin_permission('tools', 'ougc_awards'); // Insert/update version into cache $plugins = $cache->read('ougc_plugins'); if (!$plugins) { $plugins = array(); } $info = ougc_awards_info(); if (!isset($plugins['awards'])) { $plugins['awards'] = $info['versioncode']; } /*~*~* RUN UPDATES START *~*~*/ if ($plugins['awards'] <= 1800) { global $db; $tmpls = array('modcp_ougc_awards' => 'ougcawards_modcp', 'modcp_ougc_awards_manage' => 'ougcawards_modcp_manage', 'modcp_ougc_awards_nav' => 'ougcawards_modcp_nav', 'modcp_ougc_awards_list' => 'ougcawards_modcp_list', 'modcp_ougc_awards_list_empty' => 'ougcawards_modcp_list_empty', 'modcp_ougc_awards_list_award' => 'ougcawards_modcp_list_award', 'modcp_ougc_awards_manage_reason' => 'ougcawards_modcp_manage_reason', 'postbit_ougc_awards' => 'ougcawards_postbit', 'member_profile_ougc_awards_row_empty' => 'ougcawards_profile_row_empty', 'member_profile_ougc_awards_row' => 'ougcawards_profile_row', 'member_profile_ougc_awards' => 'ougcawards_profile', 'ougc_awards_page' => 'ougcawards_page', 'ougc_awards_page_list' => 'ougcawards_page_list', 'ougc_awards_page_list_award' => 'ougcawards_page_list_award', 'ougc_awards_page_list_empty' => 'ougcawards_page_list_empty', 'ougc_awards_page_user' => 'ougcawards_page_user', 'ougc_awards_page_user_award' => 'ougcawards_page_user_award', 'ougc_awards_page_user_empty' => 'ougcawards_page_user_empty', 'ougc_awards_page_view' => 'ougcawards_page_view', 'ougc_awards_page_view_empty' => 'ougcawards_page_view_empty', 'ougc_awards_page_view_row' => 'ougcawards_page_view_row'); // Try to update old templates $query = $db->simple_select('templates', '*', $where); while ($tmpl = $db->fetch_array($query)) { check_template($tmpl['template']) or $tmplcache[$tmpl['title']] = $tmpl; } foreach ($tmpls as $oldtitle => $newtitle) { $db->update_query('templates', 'title=\'' . $db->escape_string($oldtitle) . '\' AND sid=\'-2\'', array('title' => $db->escape_string($newtitle), 'version' => 1, 'dateline' => TIME_NOW)); } // Rebuild templates static $done = false; if (!$done) { $done = true; $funct = __FUNCTION__; $funct(); } // Delete old templates if not updated $tmpls['ougc_awards_image'] = ''; $db->delete_query('templates', 'title IN(\'' . implode('\', \'', array_keys(array_map(array($db, 'escape_string'), $tmpls))) . '\') AND sid=\'-2\''); // Modify table colunms $db->modify_column('ougc_awards', 'aid', 'int UNSIGNED NOT NULL AUTO_INCREMENT'); $db->modify_column('ougc_awards', 'pm', 'text NOT NULL'); !$db->field_exists('users', 'ougc_awards') or $db->drop_column('ougc_awards', 'users'); if (!$db->field_exists('disporder', 'ougc_awards')) { $db->add_column('ougc_awards', 'disporder', 'smallint(5) NOT NULL DEFAULT \'0\''); } $db->modify_column('ougc_awards_users', 'gid', 'int UNSIGNED NOT NULL AUTO_INCREMENT'); $db->modify_column('ougc_awards_users', 'uid', 'int NOT NULL DEFAULT \'0\''); $db->modify_column('ougc_awards_users', 'aid', 'int NOT NULL DEFAULT \'0\''); $db->modify_column('ougc_awards_users', 'reason', 'text NOT NULL'); if (!$db->index_exists('ougc_awards_users', 'uidaid')) { $db->write_query('ALTER TABLE ' . TABLE_PREFIX . 'ougc_awards_users ADD UNIQUE KEY uidaid (uid,aid)'); } if (!$db->index_exists('ougc_awards_users', 'aiduid')) { $db->write_query('CREATE INDEX aiduid ON ' . TABLE_PREFIX . 'ougc_awards_users (aid,uid)'); } // Delete old template group $db->delete_query('templategroups', 'prefix=\'ougc_awards\''); // Now we need to refresh the cache. $awards->update_cache(); } /*~*~* RUN UPDATES END *~*~*/ $plugins['awards'] = $info['versioncode']; $cache->update('ougc_plugins', $plugins); }
/** * Import an entire theme (stylesheets, properties & templates) from an XML file. * * @param string The contents of the XML file * @param array Optional array of options or overrides * @return boolean True on success, false on failure */ function import_theme_xml($xml, $options = array()) { global $mybb, $db; require_once MYBB_ROOT . "inc/class_xml.php"; $parser = new XMLParser($xml); $tree = $parser->get_tree(); if (!is_array($tree) || !is_array($tree['theme'])) { return -1; } $theme = $tree['theme']; // Do we have MyBB 1.2 template's we're importing? $css_120 = ""; if (is_array($theme['cssbits'])) { $cssbits = kill_tags($theme['cssbits']); foreach ($cssbits as $name => $values) { $css_120 .= "{$name} {\n"; foreach ($values as $property => $value) { if (is_array($value)) { $property = str_replace('_', ':', $property); $css_120 .= "}\n{$name} {$property} {\n"; foreach ($value as $property2 => $value2) { $css_120 .= "\t{$property2}: {$value2}\n"; } } else { $css_120 .= "\t{$property}: {$value}\n"; } } $css_120 .= "}\n"; } } if (is_array($theme['themebits'])) { $themebits = kill_tags($theme['themebits']); $theme['properties']['tag'] = 'properties'; foreach ($themebits as $name => $value) { if ($name == "extracss") { $css_120 .= $value; continue; } $theme['properties'][$name] = $value; } } if ($css_120) { $css_120 = upgrade_css_120_to_140($css_120); $theme['stylesheets']['tag'] = 'stylesheets'; $theme['stylesheets']['stylesheet'][0]['tag'] = 'stylesheet'; $theme['stylesheets']['stylesheet'][0]['attributes'] = array('name' => 'global.css', 'version' => $mybb->version_code); $theme['stylesheets']['stylesheet'][0]['value'] = $css_120; unset($theme['cssbits']); unset($theme['themebits']); } if (is_array($theme['properties'])) { foreach ($theme['properties'] as $property => $value) { if ($property == "tag" || $property == "value") { continue; } $properties[$property] = $value['value']; } } if (empty($mybb->input['name'])) { $name = $theme['attributes']['name']; } else { $name = $mybb->input['name']; } $version = $theme['attributes']['version']; $query = $db->simple_select("themes", "tid", "name='" . $db->escape_string($name) . "'", array("limit" => 1)); $existingtheme = $db->fetch_array($query); if ($options['force_name_check'] && $existingtheme['tid']) { return -3; } else { if ($existingtheme['tid']) { $options['tid'] = $existingtheme['tid']; } } if ($mybb->version_code != $version && $options['version_compat'] != 1) { return -2; } // Do we have any templates to insert? if (!empty($theme['templates']['template']) && !$options['no_templates']) { if ($options['templateset']) { $sid = $options['templateset']; } else { $sid = $db->insert_query("templatesets", array('title' => $db->escape_string($name) . " Templates")); } $templates = $theme['templates']['template']; if (is_array($templates)) { // Theme only has one custom template if (array_key_exists("attributes", $templates)) { $templates = array($templates); } } $security_check = false; $templatecache = array(); foreach ($templates as $template) { if (check_template($template['value'])) { $security_check = true; break; } $templatecache[] = array("title" => $db->escape_string($template['attributes']['name']), "template" => $db->escape_string($template['value']), "sid" => $db->escape_string($sid), "version" => $db->escape_string($template['attributes']['version']), "dateline" => TIME_NOW); } if ($security_check == true) { return -4; } foreach ($templatecache as $template) { // PostgreSQL causes apache to stop sending content sometimes and // causes the page to stop loading during many queries all at one time if ($db->engine == "pgsql") { echo " "; flush(); } $db->insert_query("templates", $template); } $properties['templateset'] = $sid; } // Not overriding an existing theme if (!$options['tid']) { // Insert the theme $theme_id = build_new_theme($name, $properties, $options['parent']); } else { $db->delete_query("themestylesheets", "tid='{$options['tid']}'"); $db->update_query("themes", array("properties" => $db->escape_string(serialize($properties))), "tid='{$options['tid']}'"); $theme_id = $options['tid']; } // If we have any stylesheets, process them if (!empty($theme['stylesheets']['stylesheet']) && !$options['no_stylesheets']) { // Are we dealing with a single stylesheet? if (isset($theme['stylesheets']['stylesheet']['tag'])) { // Trick the system into thinking we have a good array =P $theme['stylesheets']['stylesheet'] = array($theme['stylesheets']['stylesheet']); } foreach ($theme['stylesheets']['stylesheet'] as $stylesheet) { if (substr($stylesheet['attributes']['name'], -4) != ".css") { continue; } if (!$stylesheet['attributes']['lastmodified']) { $stylesheet['attributes']['lastmodified'] = TIME_NOW; } $new_stylesheet = array("name" => $db->escape_string($stylesheet['attributes']['name']), "tid" => $theme_id, "attachedto" => $db->escape_string($stylesheet['attributes']['attachedto']), "stylesheet" => $db->escape_string($stylesheet['value']), "lastmodified" => intval($stylesheet['attributes']['lastmodified']), "cachefile" => $db->escape_string($stylesheet['attributes']['name'])); $sid = $db->insert_query("themestylesheets", $new_stylesheet); $css_url = "css.php?stylesheet={$sid}"; $cached = cache_stylesheet($theme_id, $stylesheet['attributes']['name'], $stylesheet['value']); if ($cached) { $css_url = $cached; } $attachedto = $stylesheet['attributes']['attachedto']; if (!$attachedto) { $attachedto = "global"; } // private.php?compose,folders|usercp.php,global|global $attachedto = explode("|", $attachedto); foreach ($attachedto as $attached_file) { $attached_actions = explode(",", $attached_file); $attached_file = array_shift($attached_actions); if (count($attached_actions) == 0) { $attached_actions = array("global"); } foreach ($attached_actions as $action) { $theme_stylesheets[$attached_file][$action][] = $css_url; } } } // Now we have our list of built stylesheets, save them $updated_theme = array("stylesheets" => $db->escape_string(serialize($theme_stylesheets))); $db->update_query("themes", $updated_theme, "tid='{$theme_id}'"); } update_theme_stylesheet_list($theme_id); // And done? return $theme_id; }
$error = true; } } if ($gameq != "") { if (!preg_match("/^[a-zA-Z0-9\\s]+\$/", $gameq)) { $msg = _templates_gameq_error . " <br>"; $error = true; } } if ($type == "steamcmd") { } elseif ($type == "image") { } else { $error = true; $msg = _templates_invalid_type; } if (check_template($name, $row[0])) { $error = true; $msg = _template_exists; } if ($error == false) { if ($limited == true) { $stmt = $mysqli->prepare("UPDATE templates SET name_internal = ?,type_name = ?, map_path = ?, gameq = ?, app_set_config = ?, appid = ? WHERE id = ?"); $stmt->bind_param('sssssii', $internal, $type_name, $path, $gameq, $app_set_config, $appid, $row[0]); $stmt->execute(); $stmt->close(); } else { $stmt = $mysqli->prepare("UPDATE templates SET name_internal = ?,type_name = ?,type = ?,name = ?,map_path = ?, gameq = ?, app_set_config = ?, appid = ? WHERE id = ?"); $stmt->bind_param('sssssssii', $internal, $type_name, $type, $name, $path, $gameq, $app_set_config, $appid, $row[0]); $stmt->execute(); $stmt->close(); }
/** * * Update sidebar template * * @param string $defaultTemplate */ public function updateSidebarTemplate($defaultTemplate) { //global $_sidebar; $pathTemplate = APP_DIR . '/templates/frontend/' . $defaultTemplate . '/template.json'; if ($resource = check_template($pathTemplate)) { $_sidebars = $resource['sidebars']; if (count($_sidebars)) { /** * @var CoreSidebars[] $allSidebar */ $allSidebar = CoreSidebars::find(['conditions' => 'theme_name = ?1', 'bind' => [1 => $defaultTemplate]]); $sidebarBaseNames = array_column($_sidebars, 'baseName'); //Remove old sidebar in current templates foreach ($allSidebar as $oldSidebar) { if (!in_array($oldSidebar->sidebar_base_name, $sidebarBaseNames)) { /** * @var CoreWidgetValues[] $oldWidgetsValueInSidebar */ $oldWidgetsValueInSidebar = CoreWidgetValues::find(['conditions' => 'theme_name = ?0 AND sidebar_base_name = ?1', 'bind' => [$defaultTemplate, $oldSidebar->sidebar_base_name]]); foreach ($oldWidgetsValueInSidebar as $oldWidgetValueInSidebar) { $oldWidgetValueInSidebar->delete(); } $oldSidebar->delete(); } } foreach ($_sidebars as $s) { $CoreSidebars = CoreSidebars::findFirst(['conditions' => 'sidebar_base_name = ?1 AND theme_name = ?2', 'bind' => [1 => $s['baseName'], 2 => $defaultTemplate]]); if (is_object($CoreSidebars) && isset($CoreSidebars->sidebar_base_name)) { $CoreSidebars->sidebar_base_name = $s['baseName']; $CoreSidebars->save(); } else { $CoreSidebars = new CoreSidebars(); $CoreSidebars->sidebar_base_name = $s['baseName']; $CoreSidebars->theme_name = $defaultTemplate; $CoreSidebars->sidebar_name = $s['name']; $CoreSidebars->ordering = 0; $CoreSidebars->published = 1; $CoreSidebars->location = 'frontend'; $CoreSidebars->save(); } } } } }
/** * Update template information * * @param string $location Value backend|frontend */ private function _updateAllTemplate($location) { if ($location === 'frontend' || $location === 'backend') { $templates = get_child_folder(APP_DIR . '/templates/' . $location . '/'); if (count($templates)) { $templateTmp = []; foreach ($templates as $template) { $templateTmp[] = "'" . $template . "'"; } /** * @var CoreTemplates[] $templateMustDelete */ $templateMustDelete = CoreTemplates::find(['conditions' => 'base_name NOT IN(' . implode(',', $templateTmp) . ") AND location='" . $location . "'"]); if (count($templateMustDelete) > 0) { foreach ($templateMustDelete as $tMD) { if (method_exists($tMD, "delete")) { $tMD->delete(); } } } foreach ($templates as $template) { $pathTemplate = APP_DIR . '/templates/' . $location . '/' . $template . '/template.json'; if ($resource = check_template($pathTemplate)) { $templateObject = CoreTemplates::findFirst('base_name ="' . $template . '" AND location = "' . $location . '"'); if (!$templateObject) { $templateObject = new CoreTemplates(); $templateObject->base_name = $template; $templateObject->published = 0; $templateObject->location = $location; } $templateObject->name = $resource['name']; $templateObject->uri = $resource['uri']; $templateObject->author = $resource['author']; $templateObject->authorUri = $resource['authorUri']; $templateObject->version = $resource['version']; $templateObject->tag = $resource['tag']; $templateObject->description = $resource['description']; if (!$templateObject->save()) { $this->flashSession->error(__('m_template_notice_not_update_template', ['1' => $templateObject->name, '2' => '$location', '3' => APP_DIR . '/templates/{$location}/' . $templateObject->base_name . '/template.json'])); } } else { $this->flashSession->error(__('m_template_notice_not_update_template', ['1' => 'Base name: ' . $template, '2' => '$location', '3' => APP_DIR . '/templates/{$location}/' . $template . '/template.json'])); } } /** * @var CoreTemplates[] $templatePublished */ $templatePublished = CoreTemplates::find('published = 1 AND location="' . $location . '"'); if (!count($templatePublished)) { /** * @var CoreTemplates $templateDefault */ $templateDefault = CoreTemplates::findFirst('base_name = "default" AND location="frontend"'); if ($templateDefault) { $templateDefault->published = 1; $templateDefault->save(); } } } } }
$stmt->execute(); $stmt->bind_result($game, $db_appid); $stmt->fetch(); $stmt->close(); if ($game == "") { exit; } if (port_exists($dedi_ip, $port)) { $msg = _gameserver_port_in_use; $error = true; } if (check_dedi_id($dedicated)) { $msg = _gameserver_dedi_id_invalid; $error = true; } if (check_template($game)) { $msg = _message_template_error; $error = true; } if (check_user_id($user_gs)) { $msg = _gameserver_user_invalid; $error = true; } $installed = check_game_installed($dedicated, $game); if ($installed[0] != 1) { $error = true; $msg = $installed[1]; } if ($error == false) { $i = 1; if ($mass == 0) {
function check_aws_settings($hostid) { if (check_template($hostid, "AmazonEC2")) { $owner = get_owner($hostid); if (!empty($owner)) { $owner_hostid = $owner["hostid"]; } else { return false; } } elseif (check_template($hostid, "AWSAccount")) { $owner_hostid = $hostid; } else { return false; } // check credentials $access_key = get_macro($owner_hostid, '{$KEY}'); $secret_key = get_macro($owner_hostid, '{$SECRET}'); if (!empty($access_key) && !empty($secret_key)) { return true; } return false; }