├── .gitattributes ├── CONTRIBUTING.md ├── LICENSE ├── README.md └── Upload ├── admin ├── jscripts │ └── asb │ │ ├── asb_inline.js │ │ ├── asb_inline.min.js │ │ ├── asb_modal.js │ │ ├── asb_modal.min.js │ │ ├── asb_scripts.js │ │ ├── asb_scripts.min.js │ │ ├── asb_sideboxes.js │ │ └── asb_sideboxes.min.js └── styles │ └── default │ ├── asb │ └── global.css │ └── images │ └── asb │ ├── add.png │ ├── delete.png │ ├── donate.png │ ├── edit.png │ ├── help.png │ ├── logo.png │ ├── manage.png │ ├── pixel.png │ ├── settings.png │ ├── trashcan_bg.png │ └── visibility.png ├── images └── asb │ ├── left_arrow.png │ ├── right_arrow.png │ ├── see_all.png │ └── transparent.png ├── inc ├── languages │ └── english │ │ ├── admin │ │ ├── asb.lang.php │ │ └── asb_addon.lang.php │ │ ├── asb.lang.php │ │ └── asb_addon.lang.php └── plugins │ ├── adv_sidebox.php │ ├── asb.php │ └── asb │ ├── acp.php │ ├── classes │ ├── AdvancedSideboxCache.php │ ├── AdvancedSideboxInstaller.php │ ├── CustomSidebox.php │ ├── ExternalModule010000.php │ ├── ExternalModuleInterface010000.php │ ├── HTMLGenerator010000.php │ ├── MalleableObject010000.php │ ├── MalleableObjectInterface010000.php │ ├── PortableObject010102.php │ ├── PortableObjectInterface010100.php │ ├── ScriptInfo.php │ ├── SideboxExternalModule.php │ ├── SideboxObject.php │ ├── StorableObject010001.php │ ├── StorableObjectInterface010000.php │ ├── WildcardPluginCache010300.php │ ├── WildcardPluginCacheInterface010200.php │ ├── WildcardPluginInstaller020000.php │ ├── WildcardPluginInstallerInterface010000.php │ └── index.html │ ├── cleanup.php │ ├── forum.php │ ├── functions.php │ ├── functions_acp.php │ ├── functions_addon.php │ ├── index.html │ ├── install.php │ ├── install_data.php │ ├── modules │ ├── birthdays.php │ ├── forum_age.php │ ├── goals.php │ ├── index.html │ ├── latest_threads.php │ ├── private_messages.php │ ├── rand_quote.php │ ├── recent_posts.php │ ├── search_box.php │ ├── slideshow.php │ ├── staff_online_box.php │ ├── statistics.php │ ├── top_poster.php │ ├── welcome_box.php │ └── whosonline.php │ └── upgrade.php └── jscripts └── asb ├── Slideshow.js ├── Slideshow.min.js ├── asb.js ├── asb.min.js ├── asb_xmlhttp.js └── asb_xmlhttp.min.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | First of all, thanks for your interest in contributing to Advanced Sidebox. This document is intended to ease the process for first time contributors and long-time contributors alike. 2 | 3 | ## Reporting Bugs/Requesting Features 4 | 5 | - If you have found a bug in the plugin, or you would like to request a new feature, create a new issue. 6 | - If you would like to send a pull request to add a new feature or fix a bug, we are thrilled, but please create an issue so that we can reach a consensus on how to handle the patch/enhancement. 7 | - Please do not attempt to hijack an exisitng issue to discuss separate issues, create a new issue. 8 | - Please try to contain issues to one problem, create a new issue. 9 | 10 | ## Submitting Pull Requests 11 | 12 | - No PR shall be accepted to the `master` branch. 13 | - Code should conform to PSR-2 coding standards 14 | - The first commit in the PR must be titled after this pattern: `Fixes #{Issue Number}` e.g. "Fixes #474". 15 | - If there are multiple commits in the PR, subsequent commits must be title after this pattern: `For #{Issue Number}` e.g. "For #474" 16 | - Commit titles may include any other text after the required pattern as long as it is separated by at least one space. 17 | - PR must include the issue that is being addressed anywhere in the title e.g. #474 18 | 19 | ## Editing Documentation 20 | 21 | This project's wiki is currently closed to public edits. If you are interested in contributing to the documentation of this software please contact the project administrator via email: `admin@rantcentralforums.com` 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Advanced-Sidebox 3.1.19 2 | 3 |

4 | Advanced Sidebox Logo 5 |

6 | 7 |

8 | A plugin for MyBB forums that displays custom boxes on various forum pages. 9 |

10 | 11 | ASB is ***the*** side box plugin for MyBB forums. It is versatile, powerful, and built using the advice of its users. 12 | 13 | ## Features: 14 | 15 | * create an **unlimited** amount of side **boxes** on the left, right or both 16 | * **add** side boxes **to** almost **any page** 17 | * side boxes can be create**d using core modules** (listed below) or **static HTML** created by the admin 18 | * static HTML (termed **custom** side **boxes**) may be **imported**/**exported** to XML to backup, restore and share 19 | * side boxes expand/collapse just like the MyBB core windows 20 | * JavaScript **visibility toggle** icons for columns (uses **cookies** to remember states) 21 | * intuitive, **drag and drop**, side box management interface in ACP 22 | * context-sensitive **help pages** in ACP 23 | * easily **extensible** from single file modules for **third-party** developers and the hobbyist admin 24 | * **CodeMirror** supported when editing custom side boxes (if enabled in ACP) 25 | * compatible with **Page Manager** pages and custom scripts 26 | * **AJAX Update** integrated into the core and eight of the core modules! (listed below) 27 | 28 | 29 | ## Controls: 30 | 31 | * which user **group(s)** the side boxes display for 32 | * which **script(s)** the side boxes display in 33 | * which **theme(s)** the side boxes display on 34 | * disable the plugin for **specific themes** 35 | * admin **option to allow users to disable side boxes** globally from usercp.php 36 | 37 | 38 | ## Current default side box types available: 39 | 40 | * ![New](https://i.imgur.com/FMH0S6f.png) Birthdays 41 | * ![New](https://i.imgur.com/FMH0S6f.png) Forum Age ![AJAX-ready](http://i.imgur.com/nw832ed.png) 42 | * Forum Goals ![AJAX-ready](http://i.imgur.com/nw832ed.png) 43 | * Top Poster 44 | * Slideshow 45 | * Recent Posts ![AJAX-ready](http://i.imgur.com/nw832ed.png) 46 | * Who's Online ![AJAX-ready](http://i.imgur.com/nw832ed.png) 47 | * Latest Threads ![AJAX-ready](http://i.imgur.com/nw832ed.png) 48 | * Welcome 49 | * Statistics 50 | * Private Messages ![AJAX-ready](http://i.imgur.com/nw832ed.png) 51 | * Search 52 | * Random Quotes ![AJAX-ready](http://i.imgur.com/nw832ed.png) 53 | * Staff Online ![AJAX-ready](http://i.imgur.com/nw832ed.png) 54 | * You can also create your own custom box types with static content -------------------------------------------------------------------------------- /Upload/admin/jscripts/asb/asb_inline.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Plugin Name: Advanced Sidebox for MyBB 1.8.x 3 | * Copyright 2014 WildcardSearch 4 | * http://www.rantcentralforums.com 5 | * 6 | * inline controls 7 | */ 8 | 9 | /** 10 | * @var object the inline controls module 11 | */ 12 | var ASB = (function(a, $) { 13 | /** 14 | * @var int the currently checked 15 | */ 16 | var checkCount = 0, 17 | 18 | /** 19 | * @var object the default language 20 | */ 21 | lang = { 22 | go: 'Go', 23 | noSelection: 'You did not select anything.', 24 | }; 25 | 26 | /** 27 | * initiate the selected count and observe inputs 28 | * 29 | * @return void 30 | */ 31 | function init() { 32 | initialCount(); 33 | $('#asb_select_all').click(selectAll); 34 | $('.asb_check').click(keepCount); 35 | $('#asb_inline_clear').click(clearAll); 36 | $('#asb_inline_submit').click(submitCheck); 37 | } 38 | 39 | /** 40 | * allow custom language overrides 41 | * 42 | * @param object the custom language 43 | * @return void 44 | */ 45 | function setup(language) { 46 | $.extend(lang, language || {}); 47 | } 48 | 49 | /** 50 | * squeal if admin is submitting inline with nothing checked 51 | * 52 | * @param object the event 53 | * @return void 54 | */ 55 | function submitCheck(e) { 56 | if (!checkCount) { 57 | e.preventDefault(); 58 | $.jGrowl(lang.noSelection); 59 | } 60 | } 61 | 62 | /** 63 | * sync all check boxes on this page with the master 64 | * 65 | * @param object the event 66 | * @return void 67 | */ 68 | function selectAll(e) { 69 | var onOff = false; 70 | 71 | if($(this).prop("checked")) { 72 | onOff = true; 73 | } 74 | setAllChecks(onOff); 75 | } 76 | 77 | /** 78 | * set all check boxes on this page on/off 79 | * 80 | * @param bool true for checked, false for unchecked 81 | * @return void 82 | */ 83 | function setAllChecks(onOff) { 84 | if (onOff !== true) { 85 | onOff = false; 86 | } 87 | checkCount = 0; 88 | $('#asb_select_all').prop("checked", onOff); 89 | $('.asb_check').each(function(k, check) { 90 | $(check).prop("checked", onOff); 91 | if (onOff) { 92 | ++checkCount; 93 | } 94 | }); 95 | updateCheckCount(); 96 | } 97 | 98 | /** 99 | * adjust checked count on-the-fly 100 | * 101 | * @param object the event 102 | * @return void 103 | */ 104 | function keepCount(e) { 105 | if(this.checked) { 106 | ++checkCount; 107 | } else { 108 | --checkCount; 109 | } 110 | updateCheckCount(); 111 | } 112 | 113 | /** 114 | * update the go button text to reflect the currently checked count 115 | * 116 | * @return void 117 | */ 118 | function updateCheckCount() { 119 | $('#asb_inline_submit').val(lang.go + ' (' + checkCount + ')'); 120 | } 121 | 122 | /** 123 | * clear all check boxes when the clear button is clicked 124 | * 125 | * @param object the event 126 | * @return void 127 | */ 128 | function clearAll(e) { 129 | setAllChecks(); 130 | } 131 | 132 | /** 133 | * count the initially checked boxes 134 | * 135 | * @return void 136 | */ 137 | function initialCount() { 138 | checkCount = 0; 139 | $('.asb_check').each(function(k, check) { 140 | if ($(check).prop("checked")) { 141 | ++checkCount; 142 | } 143 | }); 144 | updateCheckCount(); 145 | } 146 | 147 | $(init); 148 | 149 | // the public method 150 | a.inline = { 151 | setup: setup, 152 | }; 153 | 154 | return a; 155 | })(ASB || {}, jQuery); 156 | -------------------------------------------------------------------------------- /Upload/admin/jscripts/asb/asb_inline.min.js: -------------------------------------------------------------------------------- 1 | var ASB=function(f,b){function h(a){c||(a.preventDefault(),b.jGrowl(e.noSelection))}function k(a){a=!1;b(this).prop("checked")&&(a=!0);g(a)}function g(a){!0!==a&&(a=!1);c=0;b("#asb_select_all").prop("checked",a);b(".asb_check").each(function(e,d){b(d).prop("checked",a);a&&++c});d()}function l(a){this.checked?++c:--c;d()}function d(){b("#asb_inline_submit").val(e.go+" ("+c+")")}function m(a){g()}function n(){c=0;b(".asb_check").each(function(a,d){b(d).prop("checked")&&++c});d()}var c=0,e={go:"Go", 2 | noSelection:"You did not select anything."};b(function(){n();b("#asb_select_all").click(k);b(".asb_check").click(l);b("#asb_inline_clear").click(m);b("#asb_inline_submit").click(h)});f.inline={setup:function(a){b.extend(e,a||{})}};return f}(ASB||{},jQuery); -------------------------------------------------------------------------------- /Upload/admin/jscripts/asb/asb_modal.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Plugin Name: Advanced Sidebox for MyBB 1.8.x 3 | * Copyright 2014 WildcardSearch 4 | * http://www.rantcentralforums.com 5 | * 6 | * intercept the submit button, submit 7 | * with ajax, and eval return scripts 8 | */ 9 | 10 | !function($) { 11 | function init() { 12 | $("#modalSubmit").click(submitForm); 13 | } 14 | 15 | function submitForm (e) { 16 | e.preventDefault(); 17 | 18 | $.ajax({ 19 | type: "POST", 20 | url: $("#modal_form").attr("action") + "&ajax=1", 21 | data: $("#modal_form").serialize(), 22 | success: function(data) { 23 | $(data).filter("script").each(function(e) { 24 | eval($(this).text()); 25 | }); 26 | $.modal.close(); 27 | }, 28 | error: function(jqXHR, textStatus, errorThrown) { 29 | alert(textStatus + 30 | "\n\n" + 31 | errorThrown); 32 | }, 33 | }); 34 | } 35 | 36 | $(init); 37 | }(jQuery); 38 | -------------------------------------------------------------------------------- /Upload/admin/jscripts/asb/asb_modal.min.js: -------------------------------------------------------------------------------- 1 | !function($){function init(){$("#modalSubmit").click(submitForm)}function submitForm(e){e.preventDefault();$.ajax({type:"POST",url:$("#modal_form").attr("action")+"&ajax=1",data:$("#modal_form").serialize(),success:function(data){$(data).filter("script").each(function(e){eval($(this).text())});$.modal.close()},error:function(jqXHR,textStatus,errorThrown){alert(textStatus+"\n\n"+errorThrown)}})}$(init)}(jQuery); -------------------------------------------------------------------------------- /Upload/admin/jscripts/asb/asb_scripts.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Plugin Name: Advanced Sidebox for MyBB 1.8.x 3 | * Copyright 2014 WildcardSearch 4 | * http://www.rantcentralforums.com 5 | * 6 | * this file contains JavaScript for the ACP script edit functions 7 | */ 8 | 9 | var ASB = (function(a, $) { 10 | var current = "", 11 | lang = { 12 | nothing_found: "nothing found", 13 | hooks: "hooks", 14 | actions: "actions", 15 | templates: "templates", 16 | error_file_name_empty: "no file name", 17 | error_file_does_not_exist: "file does not exist", 18 | error_file_empty: "file empty or corrupted", 19 | }; 20 | 21 | /** 22 | * hide/show the appropriate inputs based on current values, 23 | * observe action/hook/template detection drop-downs and 24 | * bind detection to changing of the script filename 25 | * 26 | * @return void 27 | */ 28 | function init() { 29 | // only show replace all options when selected 30 | new Peeker($(".replace_all"), $("#replace_content"), /1/, true); 31 | 32 | // hide search & replace inputs when replacing 33 | new Peeker($(".replace_all"), $("#header_search"), /0/, true); 34 | new Peeker($(".replace_all"), $("#footer_search"), /0/, true); 35 | 36 | // if we are eval()ing, hide all the inputs that are unnecessary 37 | new Peeker($(".eval"), $("#template_row"), /0/, true); 38 | new Peeker($(".eval"), $("#header_search"), /0/, true); 39 | new Peeker($(".eval"), $("#footer_search"), /0/, true); 40 | new Peeker($(".eval"), $("#replace_all"), /0/, true); 41 | new Peeker($(".eval"), $("#replace_content"), /0/, true); 42 | 43 | if ($("#replace_all_yes").prop("checked")) { 44 | $("#header_search").hide(); 45 | $("#footer_search").hide(); 46 | } else { 47 | $("#replace_content").hide(); 48 | } 49 | 50 | if ($("#eval_yes").prop("checked")) { 51 | $("#header_search").hide(); 52 | $("#footer_search").hide(); 53 | $("#template_row").hide(); 54 | $("#replace_all").hide(); 55 | $("#replace_content").hide(); 56 | } 57 | 58 | // watch the "detected" selectors and send the chosen 59 | // item to the appropriate text box 60 | observeInputs(); 61 | 62 | /* 63 | * watch the file name input and if it has changed on blur 64 | * attempt to detect hooks, template and URL attributes 65 | * (page, action)and display them as selectable lists 66 | */ 67 | $("#filename").blur(update); 68 | } 69 | 70 | /** 71 | * show the spinners and launch the detection request 72 | * 73 | * @param Event the blur event object 74 | * @return void 75 | */ 76 | function update(event) { 77 | // if nothing has changed, get out 78 | if (this.value == current || 79 | this.value == "") { 80 | return; 81 | } 82 | 83 | // otherwise, update the current script 84 | current = this.value; 85 | 86 | // hide the "detected" selectors 87 | $("#hook_list").hide(); 88 | $("#template_list").hide(); 89 | $("#action_list").hide(); 90 | 91 | // show all the spinners 92 | $("div.ajax_spinners").show(); 93 | 94 | $.ajax({ 95 | type: "post", 96 | url: "index.php", 97 | data: { 98 | module: "config-asb", 99 | action: "xmlhttp", 100 | mode: "analyze_script", 101 | filename: this.value, 102 | selected: { 103 | hook: $("#hook").val(), 104 | template: $("#template_name").val(), 105 | action: $("#action").val(), 106 | }, 107 | }, 108 | success: showResults, 109 | error: function(jqXHR, textStatus, errorThrown) { 110 | alert("error" + 111 | "\n\n" + 112 | textStatus + 113 | "\n\n" + 114 | errorThrown); 115 | }, 116 | }); 117 | } 118 | 119 | /** 120 | * hide the spinners and build the select elements 121 | * 122 | * @param Response the XMLHTTP response object 123 | * @return void 124 | */ 125 | function showResults(info) { 126 | var $fileInfo = $("#file_info"), 127 | errorMessage; 128 | 129 | // hide all the spinners 130 | $("div.ajax_spinners").hide(); 131 | 132 | // check for errors 133 | if (typeof info.error !== "undefined") { 134 | switch (info.error) { 135 | case 1: 136 | errorMessage = lang.error_file_name_empty; 137 | break; 138 | case 3: 139 | errorMessage = lang.error_file_empty; 140 | break; 141 | default: 142 | errorMessage = lang.error_file_does_not_exist; 143 | break; 144 | } 145 | 146 | $fileInfo.html(errorMessage); 147 | return; 148 | } else { 149 | $fileInfo.html("") 150 | } 151 | 152 | /* 153 | * use each of the key words in the array to 154 | * show detected items or a message that there 155 | * was nothing to show 156 | */ 157 | $.each(["hook", "template", "action"], function(i, k) { 158 | // make the plural version 159 | var ks = k + "s", 160 | // the no content message 161 | html = '' + lang.nothing_found.replace("{1}", lang[ks]) + ""; 162 | 163 | // if there is info... 164 | if (info[ks]) { 165 | // ...overwrite the no content message 166 | html = info[ks]; 167 | } 168 | $("#" + k + "_list").html(html).show(); 169 | }); 170 | 171 | // re-do our observation of the selectors now that they have been rebuilt 172 | observeInputs(); 173 | } 174 | 175 | /** 176 | * insert the chosen item from the select elements into the appropriate input 177 | * 178 | * @param Response the XMLHTTP response object 179 | * @return void 180 | */ 181 | function observeInputs() { 182 | if ($("#hook_selector")) { 183 | $("#hook_selector").change(function(event) { 184 | var val = this.value; 185 | if (val == 0) { 186 | val = ""; 187 | } 188 | $("#hook").val(val); 189 | }); 190 | } 191 | 192 | if ($("#template_selector")) { 193 | $("#template_selector").change(function(event) { 194 | var val = this.value; 195 | if (val == 0) { 196 | val = ""; 197 | } 198 | $("#template_name").val(val); 199 | }); 200 | } 201 | 202 | if ($("#action_selector")) { 203 | $("#action_selector").change(function(event) { 204 | var val = this.value; 205 | if (val == 0) { 206 | val = ""; 207 | } 208 | $("#action").val(val); 209 | }); 210 | } 211 | } 212 | 213 | /** 214 | * store the script currently being edited and 215 | * get the local language 216 | * 217 | * @param String the current file name 218 | * @return void 219 | */ 220 | function setup(value, language) { 221 | current = value || ""; 222 | $.extend(lang, language || {}); 223 | } 224 | 225 | $(init); 226 | 227 | a.scripts = { 228 | setup: setup, 229 | }; 230 | 231 | return a; 232 | })(ASB || {}, jQuery); 233 | -------------------------------------------------------------------------------- /Upload/admin/jscripts/asb/asb_scripts.min.js: -------------------------------------------------------------------------------- 1 | var ASB=(function(i,f){var g="",b={nothing_found:"nothing found",hooks:"hooks",actions:"actions",templates:"templates",error_file_name_empty:"no file name",error_file_does_not_exist:"file does not exist",error_file_empty:"file empty or corrupted"};function j(){new Peeker(f(".replace_all"),f("#replace_content"),/1/,true);new Peeker(f(".replace_all"),f("#header_search"),/0/,true);new Peeker(f(".replace_all"),f("#footer_search"),/0/,true);new Peeker(f(".eval"),f("#template_row"),/0/,true);new Peeker(f(".eval"),f("#header_search"),/0/,true);new Peeker(f(".eval"),f("#footer_search"),/0/,true);new Peeker(f(".eval"),f("#replace_all"),/0/,true);new Peeker(f(".eval"),f("#replace_content"),/0/,true);if(f("#replace_all_yes").prop("checked")){f("#header_search").hide();f("#footer_search").hide()}else{f("#replace_content").hide()}if(f("#eval_yes").prop("checked")){f("#header_search").hide();f("#footer_search").hide();f("#template_row").hide();f("#replace_all").hide();f("#replace_content").hide()}h();f("#filename").blur(e)}function e(a){if(this.value==g||this.value==""){return}g=this.value;f("#hook_list").hide();f("#template_list").hide();f("#action_list").hide();f("div.ajax_spinners").show();f.ajax({type:"post",url:"index.php",data:{module:"config-asb",action:"xmlhttp",mode:"analyze_script",filename:this.value,selected:{hook:f("#hook").val(),template:f("#template_name").val(),action:f("#action").val()}},success:d,error:function(k,m,l){alert("error\n\n"+m+"\n\n"+l)}})}function d(l){var a=f("#file_info"),k;f("div.ajax_spinners").hide();if(typeof l.error!=="undefined"){switch(l.error){case 1:k=b.error_file_name_empty;break;case 3:k=b.error_file_empty;break;default:k=b.error_file_does_not_exist;break}a.html(k);return}else{a.html("")}f.each(["hook","template","action"],function(o,m){var p=m+"s",n=''+b.nothing_found.replace("{1}",b[p])+"";if(l[p]){n=l[p]}f("#"+m+"_list").html(n).show()});h()}function h(){if(f("#hook_selector")){f("#hook_selector").change(function(a){var k=this.value;if(k==0){k=""}f("#hook").val(k)})}if(f("#template_selector")){f("#template_selector").change(function(a){var k=this.value;if(k==0){k=""}f("#template_name").val(k)})}if(f("#action_selector")){f("#action_selector").change(function(a){var k=this.value;if(k==0){k=""}f("#action").val(k)})}}function c(a,k){g=a||"";f.extend(b,k||{})}f(j);i.scripts={setup:c};return i})(ASB||{},jQuery); -------------------------------------------------------------------------------- /Upload/admin/jscripts/asb/asb_sideboxes.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Plugin Name: Advanced Sidebox for MyBB 1.8.x 3 | * Copyright 2014 WildcardSearch 4 | * http://www.rantcentralforums.com 5 | * 6 | * this file contains JavaScript for the ACP side box functions 7 | */ 8 | 9 | var ASB = (function(a, $) { 10 | /** 11 | * build the columns, observe the edit links on all side box divs, 12 | * remove the delete icons from side box divs and replace 13 | * the module links with a plain text title 14 | * 15 | * @return void 16 | */ 17 | function init() { 18 | $(".draggable").draggable({ 19 | revert: true, 20 | start: function(e, ui) { 21 | ui.helper.css("z-index", 999); 22 | }, 23 | stop: function(e, ui) { 24 | ui.helper.css("z-index", 50); 25 | }, 26 | }); 27 | 28 | $(".sortable").sortable({ 29 | connectWith: ".column", 30 | update: function(e, ui) { 31 | var container = $(this); 32 | 33 | $.ajax({ 34 | type: "post", 35 | url: "index.php", 36 | data: { 37 | module: "config-asb", 38 | action: "xmlhttp", 39 | mode: "order", 40 | pos: container.prop("id"), 41 | data: container.sortable("serialize"), 42 | }, 43 | success: function(response) { 44 | if (!response) { 45 | return; 46 | } 47 | 48 | // if the admin session has expired 49 | if (typeof response == "string" && 50 | response.search('value="login"') != -1) { 51 | // show them the login page 52 | location.reload(true); 53 | } 54 | 55 | var ids = response.split(","); 56 | 57 | // clean the input 58 | $(ids).each(function(i, id) { 59 | ids[i] = parseInt(id); 60 | }); 61 | removeDivs(ids); 62 | }, 63 | error: function(jqXHR, textStatus, errorThrown) { 64 | alert(textStatus + 65 | "\n\n" + 66 | errorThrown); 67 | }, 68 | }); 69 | }, 70 | }).disableSelection(); 71 | 72 | $(".droppable").droppable({ 73 | accept: ".draggable", 74 | hoverClass: "hover", 75 | drop: create, 76 | }); 77 | 78 | // observe the edit links on side boxes 79 | $("a[id^='edit_sidebox_']").click(edit); 80 | 81 | // remove the delete icon as we have the trash column 82 | $(".del_icon").remove(); 83 | 84 | // replace all the links with their titles 85 | $(".add_box_link").each(function(i, e) { 86 | e.replaceWith($(e).html()); 87 | }); 88 | } 89 | 90 | /* side boxes */ 91 | 92 | /** 93 | * open a modal dialog to edit the chosen side box 94 | * 95 | * @param Event the click event object 96 | * @return void 97 | */ 98 | function edit(event) { 99 | /** 100 | * stop the link from redirecting the user-- 101 | * set up this way so that if JS is disabled 102 | * the user goes to a standard form rather than 103 | * a modal edit form 104 | */ 105 | event.preventDefault(); 106 | 107 | loadModal($(this).prop("href") + "&ajax=1"); 108 | } 109 | 110 | /** 111 | * open a modal dialog to create a new side box 112 | * 113 | * @param event 114 | * @param object the UI information 115 | * @return void 116 | */ 117 | function create(e, ui) { 118 | // sort by position 119 | var pos = ($(this).prop("id") == "left_column") ? 0 : 1, 120 | url = "index.php?module=config-asb&action=edit_box&ajax=1&box=0&addon=" + ui.draggable.prop("id") + "&pos=" + pos; 121 | 122 | loadModal(url); 123 | } 124 | 125 | /** 126 | * open a modal 127 | * 128 | * @param String 129 | * @return void 130 | */ 131 | function loadModal(url) { 132 | $.get(url, 133 | function (html) { 134 | if (!html || 135 | html.length == 0) { 136 | return; 137 | } 138 | 139 | // if the admin session has expired 140 | if (typeof html == "string" && 141 | html.search("errors") != -1 && 142 | html.search("login") != -1) { 143 | // redirect to the login page 144 | location.reload(true); 145 | return; 146 | } 147 | 148 | // show the modal 149 | $(html).appendTo("body").modal({ 150 | fadeDuration: 250, 151 | zIndex: (typeof modal_zindex !== "undefined" ? modal_zindex : 9999), 152 | }); 153 | }); 154 | } 155 | 156 | /* side box divs */ 157 | 158 | /** 159 | * create a simple side box div to be completed by updateDiv 160 | * 161 | * @param int id 162 | * @param string title 163 | * @param string column id 164 | * @return void 165 | */ 166 | function createDiv(id, title, columnId) { 167 | if (!$("#" + columnId)) { 168 | return; 169 | } 170 | 171 | $("#" + columnId).append($("
", { 172 | id: "sidebox_" + id, 173 | "class": "sidebox", 174 | }).html(title)); 175 | } 176 | 177 | /** 178 | * update a side box's div with new info 179 | * 180 | * @param int id 181 | * @return void 182 | */ 183 | function updateDiv(id) { 184 | var sideboxId = "#sidebox_" + id; 185 | if (!$(sideboxId)) { 186 | return; 187 | } 188 | 189 | $(sideboxId).load("index.php", { 190 | module: "config-asb", 191 | action: "xmlhttp", 192 | mode: "build_info", 193 | id: id, 194 | ajax: "1", 195 | }); 196 | } 197 | 198 | /** 199 | * delete one or more side box div elements by id 200 | * 201 | * @param Array ids 202 | * @return void 203 | */ 204 | function removeDivs(ids) { 205 | if (ids.length == 0) { 206 | return; 207 | } 208 | 209 | var i, sideboxId, sidebox; 210 | for (i = 0; i < ids.length; i++) { 211 | sideboxId = "#sidebox_" + ids[i]; 212 | if (!$(sideboxId)) { 213 | continue; 214 | } 215 | 216 | // change the text and fade the
out 217 | sidebox = $(sideboxId); 218 | sidebox.css({ 219 | backgroundColor: "#f00", 220 | }); 221 | sidebox.html(lang.deleting_sidebox); 222 | sidebox.fadeOut(800, function() { 223 | $(this).remove(); 224 | }); 225 | } 226 | } 227 | 228 | $(init); 229 | 230 | a.sidebox = { 231 | createDiv: createDiv, 232 | updateDiv: updateDiv, 233 | }; 234 | 235 | return a; 236 | })(ASB || {}, jQuery); 237 | -------------------------------------------------------------------------------- /Upload/admin/jscripts/asb/asb_sideboxes.min.js: -------------------------------------------------------------------------------- 1 | var ASB=(function(h,c){function j(){c(".draggable").draggable({revert:true,start:function(k,a){a.helper.css("z-index",999)},stop:function(k,a){a.helper.css("z-index",50)}});c(".sortable").sortable({connectWith:".column",update:function(l,k){var a=c(this);c.ajax({type:"post",url:"index.php",data:{module:"config-asb",action:"xmlhttp",mode:"order",pos:a.prop("id"),data:a.sortable("serialize")},success:function(m){if(!m){return}if(typeof m=="string"&&m.search('value="login"')!=-1){location.reload(true)}var n=m.split(",");c(n).each(function(o,p){n[o]=parseInt(p)});e(n)},error:function(m,o,n){alert(o+"\n\n"+n)}})}}).disableSelection();c(".droppable").droppable({accept:".draggable",hoverClass:"hover",drop:d});c("a[id^='edit_sidebox_']").click(i);c(".del_icon").remove();c(".add_box_link").each(function(a,k){k.replaceWith(c(k).html())})}function i(a){a.preventDefault();g(c(this).prop("href")+"&ajax=1")}function d(l,k){var m=(c(this).prop("id")=="left_column")?0:1,a="index.php?module=config-asb&action=edit_box&ajax=1&box=0&addon="+k.draggable.prop("id")+"&pos="+m;g(a)}function g(a){c.get(a,function(k){if(!k||k.length==0){return}if(typeof k=="string"&&k.search("errors")!=-1&&k.search("login")!=-1){location.reload(true);return}c(k).appendTo("body").modal({fadeDuration:250,zIndex:(typeof modal_zindex!=="undefined"?modal_zindex:9999)})})}function f(l,k,a){if(!c("#"+a)){return}c("#"+a).append(c("
",{id:"sidebox_"+l,"class":"sidebox"}).html(k))}function b(k){var a="#sidebox_"+k;if(!c(a)){return}c(a).load("index.php",{module:"config-asb",action:"xmlhttp",mode:"build_info",id:k,ajax:"1"})}function e(k){if(k.length==0){return}var a,m,l;for(a=0;a 20 | -------------------------------------------------------------------------------- /Upload/inc/plugins/adv_sidebox.php: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb.php: -------------------------------------------------------------------------------- 1 |
Please make sure IN_MYBB is defined.'); 13 | } 14 | 15 | // for modules 16 | define('IN_ASB', true); 17 | define('ASB_MODULES_DIR', MYBB_ROOT.'inc/plugins/asb/modules'); 18 | define('ASB_VERSION', '3.1.19'); 19 | define('ASB_CUSTOM_VERSION', '2.0'); 20 | define('ASB_SCRIPT_VERSION', '2.0'); 21 | 22 | // register custom class autoloader 23 | spl_autoload_register('asbClassAutoload'); 24 | 25 | // some basic functions used everywhere 26 | require_once MYBB_ROOT.'inc/plugins/asb/functions.php'; 27 | 28 | // load the install/admin routines only if in ACP. 29 | if (defined('IN_ADMINCP')) { 30 | require_once MYBB_ROOT.'inc/plugins/asb/acp.php'; 31 | } else { 32 | require_once MYBB_ROOT.'inc/plugins/asb/forum.php'; 33 | } 34 | 35 | /** 36 | * class autoloader 37 | * 38 | * @param string the name of the class to load 39 | */ 40 | function asbClassAutoload($className) 41 | { 42 | $path = MYBB_ROOT."inc/plugins/asb/classes/{$className}.php"; 43 | 44 | if (file_exists($path)) { 45 | require_once $path; 46 | } 47 | } 48 | 49 | ?> 50 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/AdvancedSideboxCache.php: -------------------------------------------------------------------------------- 1 | read(); 44 | 45 | // if the cache has never been built or has been marked as changed 46 | // then rebuild and store it 47 | if ((int) $data['last_run'] == 0 || 48 | $data['has_changed']) { 49 | $this->buildCache($data); 50 | $this->update(null, $data); 51 | } 52 | 53 | // returned the cached info 54 | return $data; 55 | } 56 | 57 | /** 58 | * build all of the relevant info needed to manage side boxes 59 | * 60 | * @param array cache data variable 61 | * @return void 62 | */ 63 | public function buildCache(&$data) 64 | { 65 | global $db; 66 | 67 | // fresh start 68 | $data['custom'] = $data['sideboxes'] = $data['scripts'] = $data['all_scripts'] = array(); 69 | 70 | // update the run time and changed flag before we even start 71 | $data['last_run'] = TIME_NOW; 72 | $data['has_changed'] = false; 73 | 74 | // get all the active scripts' info 75 | $allScripts = asbGetAllScripts(); 76 | 77 | // no scripts, no work to do 78 | if (!is_array($allScripts) || 79 | empty($allScripts)) { 80 | return; 81 | } 82 | 83 | // store the script definitions and a master list 84 | foreach ($allScripts as $filename => $script) { 85 | $data['scripts'][$filename] = $script; 86 | } 87 | $data['all_scripts'] = array_keys($allScripts); 88 | 89 | // load all detected modules 90 | $addons = asbGetAllModules(); 91 | 92 | // get any custom boxes 93 | $custom = asbGetAllCustomBoxes(); 94 | 95 | // get any sideboxes 96 | $sideboxes = asbGetAllSideBoxes(); 97 | 98 | if (!is_array($sideboxes) || 99 | empty($sideboxes)) { 100 | return; 101 | } 102 | 103 | foreach ($sideboxes as $sidebox) { 104 | // build basic data 105 | $scripts = $sidebox->get('scripts'); 106 | $id = (int) $sidebox->get('id'); 107 | $pos = $sidebox->get('position') ? 1 : 0; 108 | $data['sideboxes'][$id] = $sidebox->get('data'); 109 | $module = $sidebox->get('box_type'); 110 | 111 | // no scripts == all scripts 112 | if (empty($scripts)) { 113 | // add this side box to the 'global' set (to be merged with the current script when applicable) 114 | $scripts = array('global'); 115 | } 116 | 117 | // for each script in which the side box is used, add a pointer and if it is a custom box, cache its contents 118 | foreach ($scripts as $filename) { 119 | // side box from a module? 120 | if (isset($addons[$module]) && 121 | $addons[$module] instanceof SideboxExternalModule) { 122 | // store the module name and all the template vars used 123 | $data['scripts'][$filename]['sideboxes'][$pos][$id] = $module; 124 | $data['scripts'][$filename]['template_vars'][$id] = "{$module}_{$id}"; 125 | 126 | // if there are any templates get their names so we can cache them 127 | $templates = $addons[$module]->get('templates'); 128 | if (is_array($templates) && 129 | !empty($templates)) { 130 | foreach ($templates as $template) { 131 | $data['scripts'][$filename]['templates'][] = $template['title']; 132 | } 133 | } 134 | 135 | // AJAX? 136 | if ($addons[$module]->xmlhttp && 137 | $sidebox->hasSettings) { 138 | $settings = $sidebox->get('settings'); 139 | 140 | // again, default here is off if anything goes wrong 141 | if ($settings['xmlhttp_on']) { 142 | // if all is good add the script building info 143 | $data['scripts'][$filename]['extra_scripts'][$id]['position'] = $pos; 144 | $data['scripts'][$filename]['extra_scripts'][$id]['module'] = $module; 145 | $data['scripts'][$filename]['extra_scripts'][$id]['rate'] = $settings['xmlhttp_on']; 146 | } 147 | } 148 | 149 | if ($addons[$module]->hasScripts) { 150 | foreach ($addons[$module]->get('scripts') as $script) { 151 | $data['scripts'][$filename]['js'][$script] = $script; 152 | } 153 | } 154 | // side box from a custom box? 155 | } else if(isset($custom[$module]) && 156 | $custom[$module] instanceof CustomSidebox) { 157 | // store the pointer 158 | $data['scripts'][$filename]['sideboxes'][$pos][$id] = $module; 159 | $data['scripts'][$filename]['template_vars'][$id] = "{$module}_{$id}"; 160 | 161 | // and cache the contents 162 | $data['custom'][$module] = $custom[$module]->get('data'); 163 | } 164 | } 165 | } 166 | } 167 | } 168 | 169 | ?> 170 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/AdvancedSideboxInstaller.php: -------------------------------------------------------------------------------- 1 | 40 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/CustomSidebox.php: -------------------------------------------------------------------------------- 1 | noStore[] = 'baseName'; 51 | parent::__construct($data); 52 | } 53 | 54 | /** 55 | * attempts to load the side box's data from the db, or if given no data create a blank object 56 | * 57 | * @param array|int data or id 58 | * @return bool true on success, false on fail 59 | */ 60 | public function load($data) 61 | { 62 | if (parent::load($data)) { 63 | $this->baseName = 'asb_custom_'.$this->id; 64 | return true; 65 | } 66 | return false; 67 | } 68 | 69 | /** 70 | * removes the custom side box from the database 71 | * 72 | * @param bool prevent removal of sideboxes of this type? 73 | * @return bool success/fail 74 | */ 75 | public function remove($noCleanup=false) 76 | { 77 | // unless specifically requested otherwise clean up 78 | if (!$noCleanup) { 79 | $this->removeChildren(); 80 | } 81 | return parent::remove(); 82 | } 83 | 84 | /** 85 | * delete all the side boxes of this type 86 | * 87 | * @return void 88 | */ 89 | protected function removeChildren() 90 | { 91 | global $db; 92 | 93 | // delete all boxes of this type in use 94 | $module = $db->escape_string(strtolower($this->baseName)); 95 | $db->delete_query('asb_sideboxes', "LOWER(box_type)='{$module}'"); 96 | } 97 | 98 | /** 99 | * builds the content for the template variable used for this custom box 100 | * 101 | * @param string 102 | * @return bool success/fail 103 | */ 104 | public function buildTemplate($template_variable) 105 | { 106 | global $$template_variable, $mybb, $lang; 107 | 108 | $content = $this->content; 109 | $returnVal = true; 110 | 111 | // if the user doesn't want content then at least make it validate 112 | if (strlen($content) == 0) { 113 | $returnVal = false; 114 | $content = ' 115 | 116 | 117 | '; 118 | } else { 119 | $content = str_replace("\\'", "'", addslashes($content)); 120 | eval("\${$template_variable} = \"{$content}\";"); 121 | } 122 | return $returnVal; 123 | } 124 | } 125 | 126 | ?> 127 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/ExternalModule010000.php: -------------------------------------------------------------------------------- 1 | valid = $this->load($module); 53 | } 54 | 55 | /** 56 | * attempt to load the module's info 57 | * 58 | * @param string base name of the module to load 59 | * @return bool true on success, false on fail 60 | */ 61 | public function load($module) 62 | { 63 | if (!$module || 64 | !$this->path || 65 | !$this->prefix) { 66 | return false; 67 | } 68 | 69 | // store the unique name 70 | $this->baseName = trim($module); 71 | 72 | // store the info 73 | $info = $this->run('info'); 74 | return $this->set($info); 75 | } 76 | 77 | /** 78 | * safely access the module's functions 79 | * 80 | * @param string function name 81 | * @param array 82 | * @return mixed 83 | */ 84 | public function run($function_name, $args = '') 85 | { 86 | $function_name = trim($function_name); 87 | if (!$function_name || 88 | !$this->baseName || 89 | !$this->path || 90 | !$this->prefix) { 91 | return false; 92 | } 93 | 94 | $fullpath = "{$this->path}/{$this->baseName}.php"; 95 | if (!file_exists($fullpath)) { 96 | return false; 97 | } 98 | require_once $fullpath; 99 | 100 | $this_function = "{$this->prefix}_{$this->baseName}_{$function_name}"; 101 | if (!function_exists($this_function)) { 102 | return false; 103 | } 104 | return $this_function($args); 105 | } 106 | 107 | /** 108 | * physically delete the module from the server 109 | * 110 | * @return bool 111 | */ 112 | public function remove() 113 | { 114 | $filename = "{$this->path}/{$this->baseName}.php"; 115 | @unlink($filename); 116 | 117 | return !file_exists($filename); 118 | } 119 | } 120 | 121 | ?> 122 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/ExternalModuleInterface010000.php: -------------------------------------------------------------------------------- 1 | 20 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/HTMLGenerator010000.php: -------------------------------------------------------------------------------- 1 | input 25 | * variable names, add custom keys in 26 | * __construct() or in-line 27 | */ 28 | public $allowed_url_keys = array( 29 | 'module', 30 | 'action', 31 | 'mode', 32 | 'id', 33 | 'uid', 34 | 'tid', 35 | 'page', 36 | 'my_post_key', 37 | ); 38 | 39 | /** 40 | * @var array 41 | */ 42 | public $allowed_img_properties = array( 43 | 'id', 44 | 'name', 45 | 'title', 46 | 'alt', 47 | 'style', 48 | 'class', 49 | 'onclick', 50 | ); 51 | 52 | /** 53 | * @var array 54 | */ 55 | public $allowed_link_properties = array( 56 | 'id', 57 | 'name', 58 | 'title', 59 | 'style', 60 | 'class', 61 | 'onclick', 62 | 'target', 63 | ); 64 | 65 | /** 66 | * constructor 67 | * 68 | * @param string base URL 69 | * @param string|array 1+ key names 70 | * @return void 71 | */ 72 | public function __construct($url = '', $extra_keys = '') 73 | { 74 | // custom base URL? 75 | if (trim($url)) { 76 | $this->base_url = trim($url); 77 | } 78 | 79 | // custom keys? 80 | if (!$extra_keys) { 81 | return; 82 | } 83 | 84 | foreach ((array) $extra_keys as $key) { 85 | $key = trim($key); 86 | if ($key && 87 | !in_array($key, $this->allowed_url_keys)) { 88 | $this->allowed_url_keys[] = $key; 89 | } 90 | } 91 | } 92 | 93 | /** 94 | * builds a URL from standard options array 95 | * 96 | * @param array 97 | * @param string override URL base 98 | * @param bool override URL encoded ampersand 99 | * @return string URL 100 | */ 101 | public function url($options = array(), $base_url = '', $encoded = true) 102 | { 103 | $url = $this->base_url; 104 | if ($base_url && 105 | trim($base_url)) { 106 | $url = $base_url; 107 | } 108 | 109 | $amp = '&'; 110 | if ($encoded) { 111 | $amp = '&'; 112 | } 113 | $sep = $amp; 114 | if (strpos($url, '?') === false) { 115 | $sep = '?'; 116 | } 117 | 118 | // check for the allowed options 119 | foreach ((array) $this->allowed_url_keys as $item) { 120 | if (isset($options[$item]) && 121 | $options[$item]) { 122 | // and add them if set 123 | $url .= "{$sep}{$item}={$options[$item]}"; 124 | $sep = $amp; 125 | } 126 | } 127 | return $url; 128 | } 129 | 130 | /** 131 | * builds an HTML anchor from the provided options 132 | * 133 | * @param string 134 | * @param string 135 | * @param array 136 | * @param array 137 | * @return string 138 | */ 139 | public function link($url = '', $caption = '', $options = '', $icon_options = array()) 140 | { 141 | $properties = $this->build_property_list($options, $this->allowed_link_properties); 142 | 143 | if (isset($options['icon'])) { 144 | $icon_img = $this->img($options['icon'], $icon_options); 145 | $icon_link = <<{$icon_img}  147 | EOF; 148 | } 149 | 150 | if (!$url) { 151 | $url = $this->url(); 152 | } 153 | if (!isset($caption) || 154 | !$caption) { 155 | $caption = $url; 156 | } 157 | 158 | return <<{$caption} 160 | EOF; 161 | } 162 | 163 | /** 164 | * generate HTML image markup 165 | * 166 | * @param string 167 | * @param array 168 | * @return string 169 | */ 170 | public function img($url, $options = array()) 171 | { 172 | $properties = $this->build_property_list($options, $this->allowed_img_properties); 173 | 174 | return << 176 | EOF; 177 | } 178 | 179 | /** 180 | * build HTML property list 181 | * 182 | * @param array 183 | * @param array 184 | * @return string 185 | */ 186 | protected function build_property_list($options = array(), $allowed = array()) 187 | { 188 | if (!is_array($options) || 189 | !is_array($allowed)) { 190 | return false; 191 | } 192 | 193 | foreach ($allowed as $key) { 194 | if (isset($options[$key]) && 195 | $options[$key]) { 196 | $property_list .= << 206 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/MalleableObject010000.php: -------------------------------------------------------------------------------- 1 | $property; 30 | } 31 | } 32 | return $returnArray; 33 | } else { 34 | if (property_exists($this, $properties)) { 35 | return $this->$properties; 36 | } 37 | return false; 38 | } 39 | } 40 | 41 | /** 42 | * sets a single property or multiple properties at once 43 | * 44 | * @param array|string 45 | * @param mixed the property value 46 | * @return bool success/fail 47 | */ 48 | public function set($properties, $value = '') 49 | { 50 | if (!is_array($properties)) { 51 | $properties = array($properties => $value); 52 | } 53 | 54 | foreach ($properties as $property => $value) { 55 | if (isset($value) && 56 | property_exists($this, $property)) { 57 | $this->$property = $value; 58 | } 59 | } 60 | return true; 61 | } 62 | 63 | /** 64 | * allows access to the protected valid property 65 | * 66 | * @return bool the valid property value 67 | */ 68 | public function isValid() 69 | { 70 | return $this->valid; 71 | } 72 | } 73 | 74 | ?> 75 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/MalleableObjectInterface010000.php: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/PortableObject010102.php: -------------------------------------------------------------------------------- 1 | tableName || 23 | !$this->id) { 24 | return false; 25 | } 26 | 27 | $row = $this->buildRow(); 28 | $id = (int) $this->id; 29 | 30 | if (!$row) { 31 | return false; 32 | } 33 | 34 | $options = $this->buildOptions($options); 35 | $xml = $this->buildXml($row, $options); 36 | 37 | if ($return === true) { 38 | return $xml; 39 | } 40 | 41 | $this->output($xml, $options); 42 | 43 | return true; 44 | } 45 | 46 | /** 47 | * import an object from XML 48 | * 49 | * @param string the contents of the XML file to be imported 50 | * @return bool success/fail 51 | */ 52 | public function import($xml) 53 | { 54 | $tree = $this->getTree($xml); 55 | if (!is_array($tree) || 56 | !is_array($tree[$this->tableName])) { 57 | return false; 58 | } 59 | 60 | foreach ($tree[$this->tableName] as $property => $entry) { 61 | // skip the info 62 | if (in_array($property, array('tag', 'value', 'attributes')) || 63 | !is_array($entry) || 64 | empty($entry)) { 65 | continue; 66 | } 67 | 68 | foreach ($entry as $key => $value) { 69 | // skip the info 70 | if (in_array($key, array('tag', 'value'))) { 71 | continue; 72 | } 73 | 74 | // get the field name from the array key 75 | $newKey = explode('-', $key); 76 | $newKey = $newKey[0]; 77 | 78 | // is it a valid property name for this object? 79 | if (property_exists($this, $newKey)) { 80 | // then store it 81 | $this->$newKey = $value['value']; 82 | } 83 | } 84 | } 85 | return true; 86 | } 87 | 88 | public function output($xml, $options = '') 89 | { 90 | // send out headers (opens a save dialogue) 91 | header("Content-Disposition: attachment; filename={$options['filename']}"); 92 | header('Content-Type: application/xml'); 93 | header('Content-Length: ' . strlen($xml)); 94 | header('Pragma: no-cache'); 95 | header('Expires: 0'); 96 | echo <<getCleanIdentifier(); 106 | $defaultValues = array( 107 | "charset" => 'UTF-8', 108 | "version" => '1.0', 109 | "website" => 'http://www.rantcentralforums.com', 110 | "filename" => "{$this->tableName}_{$name}-backup.xml", 111 | ); 112 | 113 | // try to get MyBB default charset 114 | if (isset($lang->settings['charset'])) { 115 | $defaultValues['charset'] = $lang->settings['charset']; 116 | } 117 | 118 | if (is_array($options) && 119 | !empty($options)) { 120 | foreach ($defaultValues as $key => $value) { 121 | if (!isset($options[$key]) || 122 | !$options[$key]) { 123 | $options[$key] = $value; 124 | } 125 | } 126 | } else { 127 | $options = $defaultValues; 128 | } 129 | return $options; 130 | } 131 | 132 | public function buildXml($rows, $options = '') 133 | { 134 | return << 136 | <{$this->tableName} version="{$options['version']}" xmlns="{$options['website']}"> 137 | <{$this->tableName}_{$this->id}> 138 | {$rows} 139 | tableName}_{$this->id}> 140 | tableName}> 141 | EOF; 142 | } 143 | 144 | /** 145 | * build a single row of XML markup for this object 146 | * 147 | * @return string|bool the XML markup or false on fail 148 | */ 149 | public function buildRow() 150 | { 151 | // object must have been saved (it exists in the db) in order to be exported 152 | if (!$this->tableName || 153 | !$this->id) { 154 | return false; 155 | } 156 | 157 | $row = ''; 158 | $id = (int) $this->id; 159 | foreach ($this as $property => $value) { 160 | // skip inherited properties 161 | if (in_array($property, $this->noStore)) { 162 | continue; 163 | } 164 | $row .= << 166 | 167 | EOF; 168 | } 169 | return $row; 170 | } 171 | 172 | /** 173 | * process the XML 174 | * 175 | * @param string 176 | * @return array|bool 177 | */ 178 | protected function getTree($xml) 179 | { 180 | if (!$xml) { 181 | return false; 182 | } 183 | 184 | require_once MYBB_ROOT . 'inc/class_xml.php'; 185 | $parser = new XMLParser($xml); 186 | return $parser->get_tree(); 187 | } 188 | 189 | /** 190 | * returns the name, title or id to be used as a unique identifier 191 | * 192 | * @access private 193 | * @return string the identifier 194 | */ 195 | protected function getCleanIdentifier() 196 | { 197 | if (property_exists($this, 'name') && 198 | trim($this->name)) { 199 | $name = $this->name; 200 | } else if (property_exists($this, 'title') && 201 | trim($this->title)) { 202 | $name = $this->title; 203 | } 204 | 205 | if (!$name) { 206 | return (int) $this->id; 207 | } 208 | 209 | // clean and return 210 | $find = array( 211 | "#(\s)+#s", 212 | "#[^\w_]#is" 213 | ); 214 | $replace = array( 215 | '_', 216 | '' 217 | ); 218 | return preg_replace($find, $replace, strtolower(trim($name))); 219 | } 220 | } 221 | 222 | ?> 223 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/PortableObjectInterface010100.php: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/ScriptInfo.php: -------------------------------------------------------------------------------- 1 | 94 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/SideboxExternalModule.php: -------------------------------------------------------------------------------- 1 | compatibility || 114 | version_compare('2.1', $this->compatibility, '>')) { 115 | return false; 116 | } 117 | 118 | $this->hasSettings = !empty($this->settings); 119 | $this->hasScripts = !empty($this->scripts); 120 | $oldVersion = $this->getCacheVersion(); 121 | 122 | // new module 123 | if ((!isset($oldVersion) || 124 | $oldVersion === 0) && 125 | !defined('IN_ASB_UNINSTALL')) { 126 | $this->install(); 127 | // newly updated module 128 | } elseif ($oldVersion && 129 | version_compare($oldVersion, $this->version, '<') && 130 | !defined('IN_ASB_UNINSTALL')) { 131 | $this->upgrade(); 132 | // pre-existing module 133 | } else { 134 | // otherwise mark upgrade status 135 | $this->isUpgraded = $this->isInstalled = true; 136 | } 137 | return true; 138 | } 139 | 140 | /** 141 | * install templates if they exist to allow the add-on module to function correctly 142 | * 143 | * @param bool remove install data before beginning? 144 | * @return void 145 | */ 146 | public function install($cleanup=true) 147 | { 148 | global $db; 149 | 150 | // already installed? unless $cleanup is specifically denied... 151 | if ($this->isInstalled && 152 | $cleanup) { 153 | // ...remove the leftovers before installing 154 | $this->uninstall(); 155 | } 156 | 157 | $this->isUpgraded = $this->isInstalled = true; 158 | $this->setCacheVersion(); 159 | 160 | // if there are no templates we're done 161 | if (!is_array($this->templates)) { 162 | return; 163 | } 164 | 165 | $insertArray = array(); 166 | foreach ($this->templates as $template) { 167 | $template['sid'] = -2; 168 | $query = $db->simple_select('templates', '*', "title='{$template['title']}' AND sid IN('-2', '-1')"); 169 | 170 | // if it exists, update 171 | if ($db->num_rows($query) > 0) { 172 | $db->update_query('templates', $template, "title='{$template['title']}' AND sid IN('-2', '-1')"); 173 | } else { 174 | // if not, create a new template 175 | $insertArray[] = $template; 176 | } 177 | } 178 | 179 | if (!empty($insertArray)) { 180 | $db->insert_query_multiple('templates', $insertArray); 181 | } 182 | } 183 | 184 | /** 185 | * remove any templates used by the module and clean up any boxes created 186 | * using this add-on module 187 | * 188 | * @param bool remove children 189 | * @return void 190 | */ 191 | public function uninstall($cleanup=true) 192 | { 193 | $this->unsetCacheVersion(); 194 | 195 | // unless specifically asked not to, delete any boxes that use this module 196 | if ($cleanup) { 197 | $this->removeChildren(); 198 | } 199 | 200 | // if there are no templates we're done 201 | if (!is_array($this->templates)) { 202 | return; 203 | } 204 | 205 | // remove them all 206 | $deleteList = $sep = ''; 207 | foreach ($this->templates as $template) { 208 | $deleteList .= "{$sep}'{$template['title']}'"; 209 | $sep = ','; 210 | } 211 | 212 | if ($deleteList) { 213 | global $db; 214 | $db->delete_query('templates', "title IN({$deleteList})"); 215 | } 216 | } 217 | 218 | /** 219 | * called upon add-on version change to verify module's templates/settings 220 | * 221 | * @return void 222 | */ 223 | protected function upgrade() 224 | { 225 | global $db; 226 | 227 | // don't waste time if everything is in order 228 | if ($this->isUpgraded) { 229 | return; 230 | } 231 | 232 | // if any templates were dropped in this version 233 | if (is_array($this->discarded_templates)) { 234 | // delete them 235 | $deleteList = $sep = ''; 236 | foreach ($this->discarded_templates as $template) { 237 | $deleteList .= "{$sep}'{$template}'"; 238 | $sep = ','; 239 | } 240 | 241 | if ($deleteList) { 242 | $db->delete_query('templates', "title IN({$deleteList})"); 243 | } 244 | } 245 | 246 | /* 247 | * install the updated module 248 | * 249 | * $cleanup = false directs the install method not to uninstall the module as normal 250 | */ 251 | $this->install(false); 252 | if ($this->hasSettings) { 253 | $this->updateChildren(); 254 | } 255 | 256 | // update the version cache and the upgrade is complete 257 | $this->isUpgraded = $this->setCacheVersion(); 258 | $this->isInstalled = true; 259 | } 260 | 261 | /** 262 | * uninstalls (if necessary) and physically deletes the module from the server 263 | * 264 | * @return bool success/fail 265 | */ 266 | public function remove() 267 | { 268 | // make sure no trash is left behind 269 | $this->uninstall(); 270 | 271 | // nuke it 272 | $filename = "{$this->path}/{$this->baseName}.php"; 273 | @unlink($filename); 274 | 275 | return !file_exists($filename); 276 | } 277 | 278 | /** 279 | * delete all the side boxes of this type 280 | * 281 | * @return void 282 | */ 283 | protected function removeChildren() 284 | { 285 | global $db; 286 | 287 | // delete all boxes of this type in use 288 | $module = $db->escape_string(strtolower($this->baseName)); 289 | $db->delete_query('asb_sideboxes', "LOWER(box_type)='{$module}'"); 290 | } 291 | 292 | /** 293 | * update settings for side boxes of this type 294 | * 295 | * @return void 296 | */ 297 | protected function updateChildren() 298 | { 299 | global $db; 300 | 301 | // get all boxes of this type in use 302 | $module = $db->escape_string(strtolower($this->baseName)); 303 | $query = $db->simple_select('asb_sideboxes', '*', "LOWER(box_type)='{$module}'"); 304 | if ($db->num_rows($query) == 0) { 305 | // this module has no children so we are done 306 | return; 307 | } 308 | 309 | // loop through all the children 310 | while ($data = $db->fetch_array($query)) { 311 | // create a new SideboxObject from the data 312 | $sidebox = new SideboxObject($data); 313 | 314 | if (!$sidebox->isValid()) { 315 | // something went wrong and this box has no ID 316 | // if we continue, we'll be creating a side box 317 | continue; 318 | } 319 | 320 | // retrieve the settings 321 | $sideboxSettings = $sidebox->get('settings'); 322 | 323 | // unset any removed settings 324 | foreach ($sideboxSettings as $name => $setting) { 325 | if (!isset($this->settings[$name])) { 326 | unset($sideboxSettings[$name]); 327 | } 328 | } 329 | 330 | // update any settings which are missing 331 | foreach ($this->settings as $name => $setting) { 332 | if (!isset($sideboxSettings[$name])) { 333 | // new setting-- default value 334 | $sideboxSettings[$name] = $this->settings[$name]['value']; 335 | } 336 | } 337 | 338 | // save the side box 339 | $sidebox->set('settings', $sideboxSettings); 340 | $sidebox->save(); 341 | } 342 | } 343 | 344 | /** 345 | * version control 346 | * 347 | * @return string|int version or 0 348 | */ 349 | protected function getCacheVersion() 350 | { 351 | $addonVersions = AdvancedSideboxCache::getInstance()->read('addon_versions'); 352 | 353 | if (is_array($addonVersions) && 354 | isset($addonVersions[$this->baseName]) && 355 | isset($addonVersions[$this->baseName]['version'])) { 356 | return $addonVersions[$this->baseName]['version']; 357 | } 358 | return 0; 359 | } 360 | 361 | /** 362 | * version control 363 | * 364 | * @return bool true 365 | */ 366 | protected function setCacheVersion() 367 | { 368 | $myCache = AdvancedSideboxCache::getInstance(); 369 | 370 | // update version cache to latest 371 | $addonVersions = $myCache->read('addon_versions'); 372 | $addonVersions[$this->baseName]['version'] = $this->version; 373 | $myCache->update('addon_versions', $addonVersions); 374 | return true; 375 | } 376 | 377 | /** 378 | * version control 379 | * 380 | * @return bool true 381 | */ 382 | protected function unsetCacheVersion() 383 | { 384 | $myCache = AdvancedSideboxCache::getInstance(); 385 | 386 | $addonVersions = $myCache->read('addon_versions'); 387 | if (isset($addonVersions[$this->baseName])) { 388 | unset($addonVersions[$this->baseName]); 389 | } 390 | $myCache->update('addon_versions', $addonVersions); 391 | return true; 392 | } 393 | 394 | /** 395 | * runs template building code for the module 396 | * 397 | * @return mixed|bool return value of function or false 398 | */ 399 | public function buildTemplate($settings, $template_var, $width, $script) 400 | { 401 | foreach (array('settings', 'template_var', 'width', 'script') as $key) { 402 | $args[$key] = $$key; 403 | } 404 | return $this->run('build_template', $args); 405 | } 406 | 407 | /** 408 | * run the modules XMLHTTP function 409 | * 410 | * @param int UNIX timestamp representing last update 411 | * @param array settings 412 | * @param int column width 413 | * @return mixed|bool return value of function or false 414 | */ 415 | public function doXmlhttp($dateline, $settings, $width) 416 | { 417 | foreach (array('dateline', 'settings', 'width') as $key) { 418 | $args[$key] = $$key; 419 | } 420 | return $this->run('xmlhttp', $args); 421 | } 422 | 423 | /** 424 | * run the module's settings_load function 425 | * 426 | * @return mixed|bool return value of function or false 427 | */ 428 | public function doSettingsLoad() 429 | { 430 | return $this->run('settings_load', $settings); 431 | } 432 | 433 | /** 434 | * run the module's settings_save function 435 | * 436 | * @param array settings 437 | * @return mixed|bool return value of function or false 438 | */ 439 | public function doSettingsSave($settings) 440 | { 441 | $returnVal = $this->run('settings_save', $settings); 442 | if ($returnVal) { 443 | return $returnVal; 444 | } 445 | return $settings; 446 | } 447 | } 448 | 449 | ?> 450 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/SideboxObject.php: -------------------------------------------------------------------------------- 1 | noStore[] = 'hasSettings'; 81 | parent::__construct($data); 82 | } 83 | 84 | /** 85 | * create a sidebox/load a side box 86 | * 87 | * @param array|int data or id 88 | * @return bool true on success, false on fail 89 | */ 90 | public function load($data) 91 | { 92 | if (!parent::load($data)) { 93 | return false; 94 | } 95 | 96 | foreach (array('settings', 'groups', 'scripts', 'themes') as $property) { 97 | if (property_exists($this, $property) && 98 | isset($this->$property)) { 99 | // if so decode them 100 | $this->$property = json_decode($this->$property, true); 101 | } 102 | } 103 | 104 | $this->hasSettings = (is_array($this->settings) && !empty($this->settings)); 105 | return true; 106 | } 107 | } 108 | 109 | ?> 110 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/StorableObject010001.php: -------------------------------------------------------------------------------- 1 | valid = $this->load($data); 43 | } 44 | 45 | /** 46 | * load the object from the database 47 | * 48 | * @param array|int 49 | * @return bool 50 | */ 51 | public function load($data) 52 | { 53 | if (!isset($data) || 54 | !$data || 55 | (int) $data == 0) { 56 | return false; 57 | } 58 | 59 | if (!is_array($data) && 60 | $this->tableName) { 61 | // attempt to load the object by ID 62 | global $db; 63 | $data = (int) $data; 64 | $query = $db->simple_select($this->tableName, '*', "id='{$data}'"); 65 | 66 | // if it exists 67 | if ($db->num_rows($query) == 1) { 68 | // store it in our passed var 69 | $data = $db->fetch_array($query); 70 | } 71 | } 72 | 73 | // if we have a (hopefully) valid array 74 | if (is_array($data) && 75 | !empty($data)) { 76 | // store it in the object 77 | foreach ($data as $key => $val) { 78 | if (property_exists($this, $key)) { 79 | $this->$key = $this->data[$key] = $val; 80 | } 81 | } 82 | return true; 83 | } 84 | // new blank object 85 | return false; 86 | } 87 | 88 | /** 89 | * stores the objects data in the database 90 | * 91 | * @return mixed|bool return of db wrapper or false 92 | */ 93 | public function save() 94 | { 95 | global $db; 96 | 97 | $this->data = array(); 98 | foreach ($this as $property => $value) { 99 | if (in_array($property, $this->noStore)) { 100 | continue; 101 | } 102 | 103 | switch (gettype($this->$property)) { 104 | case 'boolean': 105 | $this->data[$property] = (bool) $value; 106 | break; 107 | case 'integer': 108 | $this->data[$property] = (int) $value; 109 | break; 110 | case 'NULL': 111 | $this->data[$property] = null; 112 | break; 113 | case 'double': 114 | $this->data[$property] = (float) $value; 115 | break; 116 | case 'string': 117 | $this->data[$property] = $db->escape_string($value); 118 | break; 119 | case 'array': 120 | case 'object': 121 | case 'resource': 122 | $this->data[$property] = $db->escape_string(json_encode($value)); 123 | break; 124 | } 125 | } 126 | $this->data['dateline'] = TIME_NOW; 127 | 128 | // insert or update depending upon the content of ID 129 | if ($this->id) { 130 | // return true/false 131 | return $db->update_query($this->tableName, $this->data, "id='{$this->id}'"); 132 | } else { 133 | // return the ID on success/false on fail 134 | return $this->id = $db->insert_query($this->tableName, $this->data); 135 | } 136 | } 137 | 138 | /** 139 | * remove the object from the database 140 | * 141 | * @return mixed|bool return of db wrapper or false 142 | */ 143 | public function remove($noCleanup = false) 144 | { 145 | // valid ID and DB info? 146 | if (!$this->id || 147 | !$this->tableName) { 148 | return false; 149 | } 150 | 151 | global $db; 152 | return $db->delete_query($this->tableName, "id='{$this->id}'"); 153 | } 154 | } 155 | 156 | ?> 157 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/StorableObjectInterface010000.php: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/WildcardPluginCache010300.php: -------------------------------------------------------------------------------- 1 | cacheData = $cache->read($this->cacheKey); 29 | } 30 | 31 | /** 32 | * retrieve an individual cache entry 33 | * 34 | * @param string the name of the entry 35 | * @return bool 36 | */ 37 | public function read($key = null) 38 | { 39 | if ($key === null) { 40 | if ($this->subKey) { 41 | return $this->cacheData[$this->subKey]; 42 | } 43 | return $this->cacheData; 44 | } 45 | 46 | if ($this->subKey && 47 | isset($this->cacheData[$this->subKey][$key])) { 48 | return $this->cacheData[$this->subKey][$key]; 49 | } elseif (isset($this->cacheData[$key])) { 50 | return $this->cacheData[$key]; 51 | } 52 | return false; 53 | } 54 | 55 | /** 56 | * update the value of a single cache entry 57 | * 58 | * @param string the name of the entry 59 | * @param mixed the value of the entry 60 | * @param bool true to save immediately or 61 | * false (default) to wait till shut down 62 | * @param bool true (default) to update the 63 | * entire cache in the db 64 | * @return void 65 | */ 66 | public function update($key = null, $val, $hard = false) 67 | { 68 | if ($key === null) { 69 | if ($this->subKey) { 70 | $this->cacheData[$this->subKey] = $val; 71 | } else { 72 | $this->cacheData = $val; 73 | } 74 | } else { 75 | if ($this->subKey) { 76 | $this->cacheData[$this->subKey][$key] = $val; 77 | } else { 78 | $this->cacheData[$key] = $val; 79 | } 80 | } 81 | $this->hasChanged($hard); 82 | } 83 | 84 | /** 85 | * save the entire cache to the db 86 | * 87 | * @return void 88 | */ 89 | public function save() 90 | { 91 | global $cache; 92 | $cache->update($this->cacheKey, $this->cacheData); 93 | } 94 | 95 | /** 96 | * clear the entire cache 97 | * 98 | * @param bool true to clear and save immediately or 99 | * false (default) to wait till shut down 100 | * @return void 101 | */ 102 | public function clear($hard = false) 103 | { 104 | if ($this->subKey) { 105 | $this->cacheData[$this->subKey] = null; 106 | } else { 107 | $this->cacheData = null; 108 | } 109 | $this->hasChanged($hard); 110 | } 111 | 112 | /** 113 | * mark the cache as in need of saving if shut 114 | * down functionality is enabled, or save immediately 115 | * if not 116 | * 117 | * @param bool true to clear and save immediately or 118 | * false (default) to wait till shut down 119 | * @return void 120 | */ 121 | protected function hasChanged($hard = false) 122 | { 123 | global $mybb; 124 | if ($hard || 125 | !$mybb->use_shutdown) { 126 | $this->save(); 127 | return; 128 | } 129 | 130 | add_shutdown(array($this, 'save')); 131 | } 132 | 133 | /** 134 | * get the cached version 135 | * 136 | * @return string|int 137 | */ 138 | public function getVersion() 139 | { 140 | $version = trim($this->read('version')); 141 | if (!$version) { 142 | $version = 0; 143 | } 144 | return $version; 145 | } 146 | 147 | /** 148 | * set the cached version 149 | * 150 | * @param string 151 | * @return string|int 152 | */ 153 | public function setVersion($version) 154 | { 155 | $this->update('version', trim($version)); 156 | } 157 | } 158 | 159 | ?> 160 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/WildcardPluginCacheInterface010200.php: -------------------------------------------------------------------------------- 1 | 21 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/WildcardPluginInstallerInterface010000.php: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/classes/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | forbidden 8 | 23 | 24 | 25 |
you don't have permission to access this resource
26 | 27 | 28 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/cleanup.php: -------------------------------------------------------------------------------- 1 | settings['bburl']}/{$config['admin_dir']}/index.php?module=config-plugins"); 47 | 48 | ?> 49 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/functions_addon.php: -------------------------------------------------------------------------------- 1 | \s\(\)])(http|https|ftp|news){1}://([^\/\"\s\<\[\.]+\.([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i", '', $message); 42 | $message = preg_replace("#([\>\s\(\)])(www|ftp)\.(([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i", '', $message); 43 | return my_substr($message, 1); 44 | } 45 | 46 | /** 47 | * build a cleaned list of numeric ids and optionally return it as an SQL IN() function 48 | * 49 | * @param int|string id or comma-separated list of ids 50 | * @param string field name 51 | * @param bool present the id list as SQL IN()? 52 | * @return string id list 53 | */ 54 | function asbBuildIdList($ids, $field='id', $wrap=true) 55 | { 56 | if (strlen($ids) == 0) { 57 | return false; 58 | } 59 | 60 | if (strpos($ids, ',') !== false) { 61 | $idArray = explode(',', $ids); 62 | 63 | foreach ($idArray as $key => $id) { 64 | if((int) $id == 0) 65 | { 66 | unset($idArray[$key]); 67 | } 68 | } 69 | 70 | if (count($idArray) > 1) { 71 | $idList = implode(',', $idArray); 72 | } elseif (count($idArray) == 1) { 73 | $idList = (int) $idArray[key($idArray)]; 74 | } 75 | } else { 76 | $idList = (int) $ids; 77 | } 78 | 79 | if (!$idList) { 80 | return false; 81 | } 82 | 83 | if ($wrap && 84 | $field) { 85 | $idList = <<isDot()) { 152 | continue; 153 | } 154 | 155 | if ($file->isDir()) { 156 | // no recursion, just skip this 157 | if (!$recursive) { 158 | continue; 159 | } 160 | 161 | // get the files from this directory 162 | $subFiles = asbGetImagesFromPath($folder.'/'.$file->getFilename(), $subfolder.$file->getFilename(), $recursive); 163 | if ($subFiles) { 164 | $filenames .= "{$sep}{$subFiles}"; 165 | $sep = ','; 166 | } 167 | continue; 168 | } 169 | 170 | // only certain extensions allowed 171 | $extension = pathinfo($file->getFilename(), PATHINFO_EXTENSION); 172 | if (!in_array($extension, array('gif', 'png', 'jpg', 'jpeg'))) { 173 | continue; 174 | } 175 | 176 | $filenames .= "{$sep}'{$subfolder}{$file->getFilename()}'"; 177 | $sep = ','; 178 | } 179 | return $filenames; 180 | } 181 | 182 | ?> 183 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | forbidden 8 | 23 | 24 | 25 |
you don't have permission to access this resource
26 | 27 | 28 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/install.php: -------------------------------------------------------------------------------- 1 |
Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * information about the plugin used by MyBB for display as well as to connect with updates 18 | * 19 | * @return array plugin info 20 | */ 21 | function asb_info() 22 | { 23 | global $mybb, $lang, $cp_style, $cache; 24 | 25 | if (!$lang->asb) { 26 | $lang->load('asb'); 27 | } 28 | 29 | $extraLinks = '
'; 30 | $settingsLink = asbBuildSettingsLink(); 31 | if ($settingsLink) { 32 | if (file_exists(MYBB_ROOT.'inc/plugins/asb/cleanup.php') && 33 | file_exists(MYBB_ROOT.'inc/plugins/adv_sidebox/acp_functions.php')) { 34 | $removeLink = << 37 | {$lang->asb_remove_old_files_desc}
{$lang->asb_remove_old_files} 38 | 39 | EOF; 40 | } 41 | 42 | // only show Manage Sideboxes link if active 43 | $pluginList = $cache->read('plugins'); 44 | $manageLink = ''; 45 | if (!empty($pluginList['active']) && 46 | is_array($pluginList['active']) && 47 | in_array('asb', $pluginList['active'])) { 48 | $url = ASB_URL; 49 | $manageLink = << 51 | {$lang->asb_manage_sideboxes} 52 | 53 | EOF; 54 | } 55 | 56 | $settingsLink = << 58 | {$settingsLink} 59 | 60 | EOF; 61 | $extraLinks = << 63 | {$settingsLink} 64 | {$manageLink}{$removeLink} 65 |
  • 66 | {$lang->asb_help} 67 |
  • 68 | 69 | EOF; 70 | 71 | $asbDescription = << 73 | 74 | 75 | 76 | {$lang->asb_description1}

    {$lang->asb_description2}{$extraLinks} 77 | 78 | 79 | {$lang->asb_logo}

    80 | 81 | 82 | 83 | 84 | 85 | EOF; 86 | } else { 87 | $asbDescription = $lang->asb_description1; 88 | } 89 | 90 | $name = <<{$lang->asb} 92 | EOF; 93 | $author = <<Wildcard 95 | EOF; 96 | 97 | // This array returns information about the plugin, some of which was prefabricated above based on whether the plugin has been installed or not. 98 | return array( 99 | 'name' => $name, 100 | 'description' => $asbDescription, 101 | 'website' => 'https://github.com/WildcardSearch/Advanced-Sidebox', 102 | 'author' => $author, 103 | 'authorsite' => 'http://www.rantcentralforums.com', 104 | 'version' => ASB_VERSION, 105 | 'compatibility' => '18*', 106 | 'codename' => 'asb', 107 | ); 108 | } 109 | 110 | /** 111 | * check to see if the plugin's settings group is installed-- assume the plugin is installed if so 112 | * 113 | * @return bool true if installed, false if not 114 | */ 115 | function asb_is_installed() 116 | { 117 | return asbGetSettingsGroup(); 118 | } 119 | 120 | /** 121 | * add tables, a column to the mybb_users table (show_sidebox), 122 | * install the plugin setting group (asb_settings), settings, templates and 123 | * check for existing modules and install any detected 124 | * 125 | * @return void 126 | */ 127 | function asb_install() 128 | { 129 | global $lang; 130 | 131 | if (!$lang->asb) { 132 | $lang->load('asb'); 133 | } 134 | 135 | AdvancedSideboxInstaller::getInstance()->install(); 136 | 137 | $addons = asbGetAllModules(); 138 | foreach ($addons as $addon) { 139 | $addon->install(); 140 | } 141 | 142 | asbCreateScriptInfo(); 143 | 144 | @unlink(MYBB_ROOT.'inc/plugins/adv_sidebox.php'); 145 | } 146 | 147 | /** 148 | * handle version control (a la pavemen), upgrade if necessary and 149 | * change permissions for ASB 150 | * 151 | * @return void 152 | */ 153 | function asb_activate() 154 | { 155 | global $asbOldVersion; 156 | 157 | $myCache = AdvancedSideboxCache::getInstance(); 158 | 159 | // if we just upgraded... 160 | $asbOldVersion = $myCache->getVersion(); 161 | if (isset($asbOldVersion) && 162 | $asbOldVersion && 163 | version_compare($asbOldVersion, ASB_VERSION, '<')) { 164 | require_once MYBB_ROOT.'inc/plugins/asb/upgrade.php'; 165 | } 166 | 167 | $myCache->setVersion(ASB_VERSION); 168 | 169 | // change the permissions to on by default 170 | change_admin_permission('config', 'asb'); 171 | 172 | require_once MYBB_ROOT . '/inc/adminfunctions_templates.php'; 173 | find_replace_templatesets('usercp_options', "#" . preg_quote('{$board_style}') . "#i", '{$asbShowSideboxes}{$board_style}'); 174 | } 175 | 176 | /** 177 | * disable admin permissions 178 | * 179 | * @return void 180 | */ 181 | function asb_deactivate() 182 | { 183 | // remove the permissions 184 | change_admin_permission('config', 'asb', -1); 185 | 186 | require_once MYBB_ROOT . '/inc/adminfunctions_templates.php'; 187 | find_replace_templatesets('usercp_options', "#" . preg_quote('{$asbShowSideboxes}') . "#i", ''); 188 | } 189 | 190 | /** 191 | * drop the table added to the DB and the column added to 192 | * the mybb_users table (show_sidebox), 193 | * delete the plugin settings, templates and style sheets 194 | * 195 | * @return void 196 | */ 197 | function asb_uninstall() 198 | { 199 | if (!defined('IN_ASB_UNINSTALL')) { 200 | define('IN_ASB_UNINSTALL', true); 201 | } 202 | 203 | global $mybb; 204 | 205 | // remove the modules first 206 | $addons = asbGetAllModules(); 207 | 208 | // if there are add-on modules installed 209 | if (is_array($addons)) { 210 | // uninstall them 211 | foreach ($addons as $addon) { 212 | $addon->uninstall(); 213 | } 214 | } 215 | 216 | AdvancedSideboxInstaller::getInstance()->uninstall(); 217 | 218 | // delete our cached version 219 | AdvancedSideboxCache::getInstance()->clear(); 220 | } 221 | 222 | /* 223 | * settings 224 | */ 225 | 226 | /** 227 | * retrieves the plugin's settings group gid if it exists 228 | * attempts to cache repeat calls 229 | * 230 | * @return int gid 231 | */ 232 | function asbGetSettingsGroup() 233 | { 234 | static $gid; 235 | 236 | // if we have already stored the value 237 | if (!isset($gid)) { 238 | global $db; 239 | 240 | $query = $db->simple_select('settinggroups', 'gid', "name='asb_settings'"); 241 | $gid = (int) $db->fetch_field($query, 'gid'); 242 | } 243 | 244 | return $gid; 245 | } 246 | 247 | /** 248 | * builds the url to modify plugin settings if given valid info 249 | * 250 | * @param int settings group id 251 | * @return string url 252 | */ 253 | function asbBuildSettingsUrl($gid) 254 | { 255 | if ($gid) { 256 | return 'index.php?module=config-settings&action=change&gid='.$gid; 257 | } 258 | } 259 | 260 | /** 261 | * builds a link to modify plugin settings if it exists 262 | * 263 | * @return string html 264 | */ 265 | function asbBuildSettingsLink() 266 | { 267 | global $lang; 268 | 269 | if (!$lang->asb) { 270 | $lang->load('asb'); 271 | } 272 | 273 | $gid = asbGetSettingsGroup(); 274 | 275 | // does the group exist? 276 | if ($gid) { 277 | // if so build the URL 278 | $url = asbBuildSettingsUrl($gid); 279 | 280 | // did we get a URL? 281 | if ($url) { 282 | // if so build the link 283 | return "asb_plugin_settings}\">{$lang->asb_plugin_settings}"; 284 | } 285 | } 286 | return false; 287 | } 288 | 289 | /** 290 | * create the default script information rows (tailored to mimic the previous versions) 291 | * 292 | * @param bool return associative array? 293 | * @return array|true see above dependency 294 | */ 295 | function asbCreateScriptInfo($return=false) 296 | { 297 | $scripts = array( 298 | 'index' => array( 299 | 'title' => 'Index', 300 | 'filename' => 'index.php', 301 | 'template_name' => 'index', 302 | 'hook' => 'index_start', 303 | 'find_top' => '{$header}', 304 | 'find_bottom' => '{$footer}', 305 | 'replace_all' => 0, 306 | 'eval' => 0, 307 | 'active' => 1, 308 | ), 309 | 'forumdisplay' => array( 310 | 'title' => 'Forum Display', 311 | 'filename' => 'forumdisplay.php', 312 | 'template_name' => 'forumdisplay_threadlist', 313 | 'hook' => 'forumdisplay_start', 314 | 'find_top' => '
    315 | {$newthread} 316 |
    ', 317 | 'find_bottom' => '{$inline_edit_js}', 318 | 'replace_all' => 0, 319 | 'eval' => 0, 320 | 'active' => 1, 321 | ), 322 | 'showthread' => array( 323 | 'title' => 'Show Thread', 324 | 'filename' => 'showthread.php', 325 | 'template_name' => 'showthread', 326 | 'hook' => 'showthread_start', 327 | 'find_top' => '{$ratethread}', 328 | 'find_bottom' => '{$footer}', 329 | 'replace_all' => 0, 330 | 'eval' => 0, 331 | 'active' => 1, 332 | ), 333 | 'member' => array( 334 | 'title' => 'Member Profile', 335 | 'filename' => 'member.php', 336 | 'action' => 'profile', 337 | 'template_name' => 'member_profile', 338 | 'hook' => 'member_profile_start', 339 | 'find_top' => '{$header}', 340 | 'find_bottom' => '{$footer}', 341 | 'replace_all' => 0, 342 | 'eval' => 0, 343 | 'active' => 1, 344 | ), 345 | 'memberlist' => array( 346 | 'title' => 'Member List', 347 | 'filename' => 'memberlist.php', 348 | 'template_name' => 'memberlist', 349 | 'hook' => 'memberlist_start', 350 | 'find_top' => '{$multipage}', 351 | 'find_bottom' => '{$footer}', 352 | 'replace_all' => 0, 353 | 'eval' => 0, 354 | 'active' => 1, 355 | ), 356 | 'showteam' => array( 357 | 'title' => 'Forum Team', 358 | 'filename' => 'showteam.php', 359 | 'template_name' => 'showteam', 360 | 'hook' => 'showteam_start', 361 | 'find_top' => '{$header}', 362 | 'find_bottom' => '{$footer}', 363 | 'replace_all' => 0, 364 | 'eval' => 0, 365 | 'active' => 1, 366 | ), 367 | 'stats' => array( 368 | 'title' => 'Statistics', 369 | 'filename' => 'stats.php', 370 | 'template_name' => 'stats', 371 | 'hook' => 'stats_start', 372 | 'find_top' => '{$header}', 373 | 'find_bottom' => '{$footer}', 374 | 'replace_all' => 0, 375 | 'eval' => 0, 376 | 'active' => 1, 377 | ), 378 | 'portal' => array( 379 | 'title' => 'Portal', 380 | 'filename' => 'portal.php', 381 | 'template_name' => 'portal', 382 | 'hook' => 'portal_start', 383 | 'replace_all' => 1, 384 | 'replacement' => << 386 | 387 | {\$mybb->settings['bbname']} 388 | {\$headerinclude} 389 | 390 | 391 | {\$header} 392 | {\$asb_left} 393 | {\$announcements} 394 | {\$asb_right} 395 | {\$footer} 396 | 397 | 398 | EOF 399 | , 400 | 'eval' => 0, 401 | 'active' => 1, 402 | ), 403 | ); 404 | 405 | if ($return == false) { 406 | foreach ($scripts as $info) { 407 | $script = new ScriptInfo($info); 408 | $script->save(); 409 | } 410 | 411 | return true; 412 | } else { 413 | foreach ($scripts as $key => $info) { 414 | $returnArray[$key] = new ScriptInfo($info); 415 | } 416 | return $returnArray; // upgrade script will save these script defs 417 | } 418 | } 419 | 420 | /** 421 | * rebuilds the theme exclude list ACP setting 422 | * 423 | * @return string|bool html or false 424 | */ 425 | function asbBuildThemeExcludeSelect() 426 | { 427 | global $lang; 428 | if (!$lang->asb) { 429 | $lang->load('asb'); 430 | } 431 | 432 | $allThemes = asbGetAllThemes(true); 433 | 434 | $themeCount = min(5, count($allThemes)); 435 | if ($themeCount == 0) { 436 | return << 439 | 440 | 441 | 442 | EOF; 443 | } 444 | 445 | // Create an option for each theme and insert code to unserialize each option and 'remember' settings 446 | foreach ($allThemes as $tid => $name) { 447 | $name = addcslashes($name, '"'); 448 | $themeSelect .= <<{$name} 450 | EOF; 451 | } 452 | 453 | // put it all together 454 | return << 457 | {$themeSelect} 458 | 459 | 460 | EOF; 461 | } 462 | 463 | ?> 464 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/birthdays.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array 20 | */ 21 | function asb_birthdays_info() 22 | { 23 | global $lang; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array ( 30 | 'title' => $lang->asb_birthdays_title, 31 | 'description' => $lang->asb_birthdays_description, 32 | 'wrap_content' => true, 33 | 'version' => '1.0.0', 34 | 'compatibility' => '2.1', 35 | 'templates' => array( 36 | array( 37 | 'title' => 'asb_birthdays', 38 | 'template' => << 40 | 41 | {\$lang->asb_birthdays_todays_birthdays} 42 | 43 | {\$todaysBirthdays} 44 | 45 | 46 | {\$lang->asb_birthdays_upcoming_birthdays} 47 | 48 | {\$upcomingBirthdays} 49 | EOF 50 | ), 51 | array( 52 | 'title' => 'asb_birthdays_user_row', 53 | 'template' => << 55 | 56 | {\$avatar} ({\$user[\'age\']}){\$name} 57 | 58 | 59 | 60 | EOF 61 | ), 62 | array( 63 | 'title' => 'asb_birthdays_no_birthdays', 64 | 'template' => << 66 | 67 | {\$noBirthdays} 68 | 69 | 70 | 71 | EOF 72 | ), 73 | array( 74 | 'title' => 'asb_birthdays_user_avatar', 75 | 'template' => << 77 | 78 | EOF 79 | ), 80 | ), 81 | ); 82 | } 83 | 84 | /** 85 | * handles display of children of this addon at page load 86 | * 87 | * @param array 88 | * @return bool success/fail 89 | */ 90 | function asb_birthdays_build_template($args) 91 | { 92 | extract($args); 93 | global $$template_var, $lang; 94 | 95 | if (!$lang->asb_addon) { 96 | $lang->load('asb_addon'); 97 | } 98 | 99 | $birthdays_status = asb_birthdays_get_birthdays($args); 100 | if (!$birthdays_status) { 101 | $$template_var = "{$lang->asb_birthdays_no_content}"; 102 | return false; 103 | } 104 | 105 | $$template_var = $birthdays_status; 106 | return true; 107 | } 108 | 109 | /** 110 | * build the content based on settings 111 | * 112 | * @param array 113 | * @return string 114 | */ 115 | function asb_birthdays_get_birthdays($args) 116 | { 117 | global $mybb, $db, $lang, $templates, $cache; 118 | 119 | if (!$lang->asb_addon) { 120 | $lang->load('asb_addon'); 121 | } 122 | 123 | extract($args); 124 | 125 | require_once MYBB_ROOT.'inc/functions_calendar.php'; 126 | $day = my_date('j'); 127 | $month = my_date('n'); 128 | $year = my_date('Y'); 129 | 130 | $todaysBirthdayUsers = get_birthdays($month, $day); 131 | $upcomingBirthdayUsers = get_birthdays($month); 132 | 133 | $userAvatars = $userAvatarList = array(); 134 | foreach ($upcomingBirthdayUsers as $users) { 135 | foreach ($users as $user) { 136 | $userAvatarList[] = $user['uid']; 137 | } 138 | } 139 | 140 | $userAvatarList = implode(',', $userAvatarList); 141 | if (!empty($userAvatarList)) { 142 | $query = $db->simple_select('users', 'uid, avatar, avatardimensions', "uid IN({$userAvatarList})"); 143 | 144 | while ($user = $db->fetch_array($query)) { 145 | $userAvatars[$user['uid']] = format_avatar($user['avatar'], $user['avatardimensions'], '20x20'); 146 | } 147 | } 148 | 149 | $alreadyDone = array(); 150 | $altbg = 'trow1'; 151 | $todaysBirthdays = ''; 152 | foreach ($todaysBirthdayUsers as $user) { 153 | if ($user['birthdayprivacy'] != 'all') { 154 | continue; 155 | } 156 | 157 | $name = format_name(htmlspecialchars_uni($user['username']), $user['usergroup'], $user['displaygroup']); 158 | $profileLink = get_profile_link($user['uid']); 159 | 160 | $birthday = my_date('F jS, Y', strtotime("{$year}-{$day}-{$month}")); 161 | $userInfo = $lang->sprintf($lang->asb_birthdays_user_info, $user['age'], $birthday); 162 | 163 | $avatarInfo = $userAvatars[$user['uid']]; 164 | eval("\$avatar = \"{$templates->get('asb_birthdays_user_avatar')}\";"); 165 | 166 | eval("\$todaysBirthdays .= \"{$templates->get('asb_birthdays_user_row')}\";"); 167 | 168 | $altbg = alt_trow(); 169 | $alreadyDone[$user['uid']] = true; 170 | } 171 | 172 | if (!$todaysBirthdays) { 173 | $noBirthdays = $lang->asb_birthdays_no_birthdays_today; 174 | eval("\$todaysBirthdays = \"{$templates->get('asb_birthdays_no_birthdays')}\";"); 175 | } 176 | 177 | // build the user list 178 | $altbg = 'trow1'; 179 | $upcomingBirthdays = ''; 180 | foreach ($upcomingBirthdayUsers as $date => $users) { 181 | foreach ($users as $user) { 182 | $dateParts = explode('-', $date); 183 | $userDay = $dateParts[0]; 184 | if ($user['birthdayprivacy'] != 'all' || 185 | $alreadyDone[$user['uid']] || 186 | $userDay <= $day) { 187 | continue; 188 | } 189 | 190 | $name = format_name(htmlspecialchars_uni($user['username']), $user['usergroup'], $user['displaygroup']); 191 | $profileLink = get_profile_link($user['uid']); 192 | 193 | $birthday = my_date('F jS, Y', strtotime("{$year}-{$date}")); 194 | $userInfo = $lang->sprintf($lang->asb_birthdays_user_info, $user['age'], $birthday); 195 | 196 | $avatarInfo = $userAvatars[$user['uid']]; 197 | eval("\$avatar = \"{$templates->get('asb_birthdays_user_avatar')}\";"); 198 | 199 | eval("\$upcomingBirthdays .= \"{$templates->get('asb_birthdays_user_row')}\";"); 200 | 201 | $altbg = alt_trow(); 202 | } 203 | } 204 | 205 | if (!$upcomingBirthdays) { 206 | $noBirthdays = $lang->asb_birthdays_no_upcoming_birthdays; 207 | eval("\$upcomingBirthdays = \"{$templates->get('asb_birthdays_no_birthdays')}\";"); 208 | } 209 | 210 | eval("\$returnValue = \"{$templates->get('asb_birthdays')}\";"); 211 | return $returnValue; 212 | } 213 | 214 | ?> 215 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/forum_age.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array 20 | */ 21 | function asb_forum_age_info() 22 | { 23 | global $lang; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array ( 30 | 'title' => $lang->asb_forum_age_title, 31 | 'description' => $lang->asb_forum_age_description, 32 | 'wrap_content' => true, 33 | 'version' => '1.0.0', 34 | 'compatibility' => '2.1', 35 | 'xmlhttp' => true, 36 | 'settings' => array( 37 | 'forum_age_date_format' => array( 38 | 'name' => 'forum_age_date_format', 39 | 'title' => $lang->asb_forum_age_forum_age_date_format_title, 40 | 'description' => $lang->asb_forum_age_forum_age_date_format_description, 41 | 'optionscode' => <<asb_forum_age_optionscode_year} 44 | 2={$lang->asb_forum_age_optionscode_month} 45 | 3={$lang->asb_forum_age_optionscode_week} 46 | 4={$lang->asb_forum_age_optionscode_day} 47 | 5={$lang->asb_forum_age_optionscode_hour} 48 | 6={$lang->asb_forum_age_optionscode_minute} 49 | 7={$lang->asb_forum_age_optionscode_second} 50 | EOF 51 | , 52 | 'value' => 'year', 53 | ), 54 | 'show_creation_date' => array( 55 | 'name' => 'show_creation_date', 56 | 'title' => $lang->asb_forum_age_show_creation_date_title, 57 | 'description' => $lang->asb_forum_age_show_creation_date_description, 58 | 'optionscode' => 'yesno', 59 | 'value' => '1', 60 | ), 61 | 'creation_date_format' => array( 62 | 'name' => 'creation_date_format', 63 | 'title' => $lang->asb_forum_age_creation_date_format_title, 64 | 'description' => $lang->asb_forum_age_creation_date_format_description, 65 | 'optionscode' => 'text', 66 | 'value' => 'F jS, Y', 67 | ), 68 | 'xmlhttp_on' => array( 69 | 'name' => 'xmlhttp_on', 70 | 'title' => $lang->asb_xmlhttp_on_title, 71 | 'description' => $lang->asb_xmlhttp_on_description, 72 | 'optionscode' => 'text', 73 | 'value' => '0', 74 | ), 75 | ), 76 | 'templates' => array( 77 | array( 78 | 'title' => 'asb_forum_age', 79 | 'template' => << 81 | {\$forumAge} 82 | {\$creationDate} 83 | EOF 84 | ), 85 | array( 86 | 'title' => 'asb_forum_age_creation_date', 87 | 'template' => << 90 | {\$creationText} 91 | 92 | EOF 93 | ), 94 | array( 95 | 'title' => 'asb_forum_age_text', 96 | 'template' => <<{\$forumAgeText} 98 | EOF 99 | ), 100 | ), 101 | ); 102 | } 103 | 104 | /** 105 | * handles display of children of this addon at page load 106 | * 107 | * @param array 108 | * @return bool success/fail 109 | */ 110 | function asb_forum_age_build_template($args) 111 | { 112 | extract($args); 113 | global $$template_var, $lang; 114 | 115 | if (!$lang->asb_addon) { 116 | $lang->load('asb_addon'); 117 | } 118 | 119 | $forum_age_status = asb_forum_age_get_forum_age($args); 120 | if (!$forum_age_status) { 121 | $$template_var = "{$lang->asb_forum_age_no_content}"; 122 | return false; 123 | } 124 | 125 | $$template_var = $forum_age_status; 126 | return true; 127 | } 128 | 129 | /** 130 | * AJAX 131 | * 132 | * @param array 133 | * @return string 134 | */ 135 | function asb_forum_age_xmlhttp($args) 136 | { 137 | $forum_age_status = asb_forum_age_get_forum_age($args); 138 | if ($forum_age_status) { 139 | return $forum_age_status; 140 | } 141 | return 'nochange'; 142 | } 143 | 144 | /** 145 | * build the content based on settings 146 | * 147 | * @param array 148 | * @return string 149 | */ 150 | function asb_forum_age_get_forum_age($args) 151 | { 152 | global $mybb, $db, $lang, $templates; 153 | 154 | if (!$lang->asb_addon) { 155 | $lang->load('asb_addon'); 156 | } 157 | 158 | extract($args); 159 | 160 | // get the forum creation date 161 | $query = $db->simple_select('users', 'regdate', "uid='1'"); 162 | if ($db->num_rows($query) == 0) { 163 | return false; 164 | } 165 | 166 | $creationDateStamp = $db->fetch_field($query, 'regdate'); 167 | 168 | // if we are showing the creation date, include the footer 169 | if ($settings['show_creation_date']) { 170 | $format = $mybb->settings['dateformat']; 171 | if ($settings['creation_date_format']) { 172 | $format = $settings['creation_date_format']; 173 | } 174 | 175 | $creationDate = my_date($format, $creationDateStamp); 176 | $creationText = $lang->sprintf($lang->asb_forum_age_founded_message, $creationDate); 177 | eval("\$creationDate = \"{$templates->get('asb_forum_age_creation_date')}\";"); 178 | } 179 | 180 | // information for all increments 181 | $allInfo = array( 182 | 1 => array('name' => 'year', 'inSeconds' => 365 * 24 * 60 * 60), 183 | 2 => array('name' => 'month', 'inSeconds' => 30 * 24 * 60 * 60), 184 | 3 => array('name' => 'week', 'inSeconds' => 7 * 24 * 60 * 60), 185 | 4 => array('name' => 'day', 'inSeconds' => 24 * 60 * 60), 186 | 5 => array('name' => 'hour', 'inSeconds' => 60 * 60), 187 | 6 => array('name' => 'minute', 'inSeconds' => 60), 188 | 7 => array('name' => 'second', 'inSeconds' => 1), 189 | ); 190 | 191 | /** 192 | * loop through each increment and determine whether that 193 | * increment should be shown, hidden, or replaced 194 | */ 195 | $start = $settings['forum_age_date_format']; 196 | $age = TIME_NOW - $creationDateStamp; 197 | foreach ($allInfo as $i => $info) { 198 | $varName = $info['name'].'s'; 199 | $$varName = 0; 200 | 201 | if ($age > $info['inSeconds']) { 202 | $$varName = (int) ($age / $info['inSeconds']); 203 | $age = $age - ($$varName * $info['inSeconds']); 204 | } 205 | 206 | $key = "asb_forum_age_{$info['name']}"; 207 | $data = $$varName; 208 | if ($$varName > 1) { 209 | $key .= 's'; 210 | } elseif ($$varName == 0) { 211 | $data = $lang->asb_forum_age_less_than; 212 | } 213 | 214 | $forumAgeArray[] = $lang->sprintf($lang->$key, $data); 215 | } 216 | 217 | // remove increments before the selected value that are empty 218 | for ($x = 2; $x < 8; $x++) { 219 | $varName = $allInfo[$x - 1]['name'].'s'; 220 | if ($settings['forum_age_date_format'] >= $x && 221 | $$varName == 0) { 222 | array_shift($forumAgeArray); 223 | $start--; 224 | } 225 | } 226 | 227 | // remove increments after the selected value 228 | for ($x = $start; $x < 7; $x++) { 229 | unset($forumAgeArray[$x]); 230 | } 231 | 232 | // add "and" if there is more than one entry 233 | if (count($forumAgeArray) > 1) { 234 | $forumAgeArray[count($forumAgeArray) - 1] = $lang->asb_forum_age_and.$forumAgeArray[count($forumAgeArray) - 1]; 235 | } 236 | 237 | // compile the time text 238 | $forumAgeText = implode(', ', $forumAgeArray); 239 | eval("\$forumAgeText = \"{$templates->get('asb_forum_age_text')}\";"); 240 | $forumAge = $lang->sprintf($lang->asb_forum_age_text, $mybb->settings['bbname'], $forumAgeText); 241 | 242 | eval("\$returnValue = \"{$templates->get('asb_forum_age')}\";"); 243 | return $returnValue; 244 | } 245 | 246 | /** 247 | * insert peeker for creation date 248 | * 249 | * @return void 250 | */ 251 | function asb_forum_age_settings_load() 252 | { 253 | echo << 256 | new Peeker($(".setting_show_creation_date"), $("#row_setting_creation_date_format"), /1/, true); 257 | 258 | EOF; 259 | } 260 | 261 | ?> 262 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/goals.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array 20 | */ 21 | function asb_goals_info() 22 | { 23 | global $lang; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array ( 30 | 'title' => $lang->asb_goals_title, 31 | 'description' => $lang->asb_goals_description, 32 | 'wrap_content' => true, 33 | 'version' => '1.0.1', 34 | 'compatibility' => '2.1', 35 | 'xmlhttp' => true, 36 | 'settings' => array( 37 | 'goal_type' => array( 38 | 'name' => 'goal_type', 39 | 'title' => $lang->asb_goals_goal_type_title, 40 | 'description' => $lang->asb_goals_goal_type_description, 41 | 'optionscode' => <<asb_goals_goal_type_optionscode_posts} 44 | 2={$lang->asb_goals_goal_type_optionscode_threads} 45 | 3={$lang->asb_goals_goal_type_optionscode_users} 46 | EOF 47 | , 48 | 'value' => '1', 49 | ), 50 | 'goal' => array( 51 | 'name' => 'goal', 52 | 'title' => $lang->asb_goals_goal_title, 53 | 'description' => $lang->asb_goals_goal_description, 54 | 'optionscode' => 'text', 55 | 'value' => '100000', 56 | ), 57 | 'success_image' => array( 58 | 'name' => 'success_image', 59 | 'title' => $lang->asb_goals_success_image_title, 60 | 'description' => $lang->asb_goals_success_image_description, 61 | 'optionscode' => 'text', 62 | 'value' => '', 63 | ), 64 | 'xmlhttp_on' => array( 65 | 'name' => 'xmlhttp_on', 66 | 'title' => $lang->asb_xmlhttp_on_title, 67 | 'description' => $lang->asb_xmlhttp_on_description, 68 | 'optionscode' => 'text', 69 | 'value' => '0', 70 | ), 71 | ), 72 | 'templates' => array( 73 | array( 74 | 'title' => 'asb_goals', 75 | 'template' => << 77 | {\$progress} 78 | 79 | 80 | {\$stats} 81 | 82 | EOF 83 | ), 84 | array( 85 | 'title' => 'asb_goals_goal_reached', 86 | 'template' => <<{\$goal_reached_message}{\$successImage} 88 | EOF 89 | ), 90 | array( 91 | 'title' => 'asb_goals_progress', 92 | 'template' => <<{\$percentage}% {\$progress_message}
    94 |
    95 |
    96 |
    97 |
    98 | EOF 99 | ), 100 | array( 101 | 'title' => 'asb_goals_goal_reached_image', 102 | 'template' => << 105 | EOF 106 | ), 107 | ), 108 | ); 109 | } 110 | 111 | /** 112 | * handles display of children of this addon at page load 113 | * 114 | * @param array 115 | * @return bool success/fail 116 | */ 117 | function asb_goals_build_template($args) 118 | { 119 | extract($args); 120 | global $$template_var, $lang; 121 | 122 | if (!$lang->asb_addon) { 123 | $lang->load('asb_addon'); 124 | } 125 | 126 | $goalStatus = asb_goals_get_progress($args); 127 | if (!$goalStatus) { 128 | $$template_var = "{$lang->asb_goals_no_content}"; 129 | return false; 130 | } 131 | 132 | $$template_var = $goalStatus; 133 | return true; 134 | } 135 | 136 | /** 137 | * AJAX 138 | * 139 | * @param array 140 | * @return string 141 | */ 142 | function asb_goals_xmlhttp($args) 143 | { 144 | $goalStatus = asb_goals_get_progress($args); 145 | if ($goalStatus) { 146 | return $goalStatus; 147 | } 148 | return 'nochange'; 149 | } 150 | 151 | /** 152 | * build the content based on settings 153 | * 154 | * @param array 155 | * @return string 156 | */ 157 | function asb_goals_get_progress($args) 158 | { 159 | global $lang, $templates, $db; 160 | 161 | if (!$lang->asb_addon) { 162 | $lang->load('asb_addon'); 163 | } 164 | 165 | extract($args); 166 | 167 | $returnValue = ''; 168 | $table = 'forums'; 169 | $field = 'posts'; 170 | $function = 'SUM'; 171 | $goal_type_plural = $lang->asb_goals_posts; 172 | switch((int) $settings['goal_type']) { 173 | case 2: 174 | $field = 'threads'; 175 | $goal_type_plural = $lang->asb_goals_threads; 176 | break; 177 | case 3: 178 | $table = 'users'; 179 | $goal_type_plural = $lang->asb_goals_users; 180 | $field = 'uid'; 181 | $function = 'COUNT'; 182 | break; 183 | } 184 | 185 | $query = $db->simple_select($table, "{$function}({$field}) AS total"); 186 | $total = $db->fetch_field($query, 'total'); 187 | $formatted_total = my_number_format($total); 188 | $goal = (int) $settings['goal']; 189 | $formatted_goal = my_number_format($goal); 190 | 191 | if ($total >= $goal) { 192 | $percentage = 100; 193 | $stats = $lang->asb_goals_footer_goal_reached; 194 | $goal_reached_message = $lang->sprintf($lang->asb_goals_goal_reached, $formatted_goal, $goal_type_plural); 195 | 196 | $successImage = ''; 197 | if ($settings['success_image']) { 198 | eval("\$successImage = \"{$templates->get('asb_goals_goal_reached_image')}\";"); 199 | } 200 | 201 | eval("\$progress = \"{$templates->get('asb_goals_goal_reached')}\";"); 202 | } else { 203 | $itemsLeft = my_number_format($goal - $total); 204 | $percentage = round(($total / $goal) * 100, 1); 205 | $stats = $lang->sprintf($lang->asb_goals_footer_progress, $itemsLeft, $goal_type_plural); 206 | $progress_message = $lang->sprintf($lang->asb_goals_progress_message, $formatted_goal, $goal_type_plural); 207 | $progress_bar_title = $lang->sprintf($lang->asb_goals_progress_bar_title, $formatted_total, $formatted_goal); 208 | eval("\$progress = \"{$templates->get('asb_goals_progress')}\";"); 209 | } 210 | 211 | eval("\$returnValue = \"{$templates->get('asb_goals')}\";"); 212 | return $returnValue; 213 | } 214 | 215 | ?> 216 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | forbidden 8 | 23 | 24 | 25 |
    you don't have permission to access this resource
    26 | 27 | 28 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/private_messages.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array module info 20 | */ 21 | function asb_private_messages_info() 22 | { 23 | global $lang; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array( 30 | 'title' => $lang->asb_private_messages, 31 | 'description' => $lang->asb_private_messages_desc, 32 | 'wrap_content' => true, 33 | 'xmlhttp' => true, 34 | 'version' => '1.1.1', 35 | 'compatibility' => '2.1', 36 | 'settings' => array( 37 | 'xmlhttp_on' => array( 38 | 'name' => 'xmlhttp_on', 39 | 'title' => $lang->asb_xmlhttp_on_title, 40 | 'description' => $lang->asb_xmlhttp_on_description, 41 | 'optionscode' => 'text', 42 | 'value' => '0', 43 | ), 44 | ), 45 | 'templates' => array( 46 | array( 47 | 'title' => 'asb_pms', 48 | 'template' => << 50 | 51 | {\$lang->asb_pms_received_new}

    52 | » {\$mybb->user[\'pms_unread\']} {\$lang->asb_pms_unread}
    53 | » {\$mybb->user[\'pms_total\']} {\$lang->asb_pms_total}
    54 | 55 | 56 | EOF 57 | ), 58 | ), 59 | ); 60 | } 61 | 62 | /** 63 | * handles display of children of this addon at page load 64 | * 65 | * @param array info from child box 66 | * @return bool success/fail 67 | */ 68 | function asb_private_messages_build_template($args) 69 | { 70 | extract($args); 71 | global $$template_var, $lang; // <-- important! 72 | 73 | if (!$lang->asb_addon) { 74 | $lang->load('asb_addon'); 75 | } 76 | 77 | $pmessages = asb_private_messages_get_messages(); 78 | 79 | if ($pmessages) { 80 | $$template_var = $pmessages; 81 | return true; 82 | } else { 83 | $pm_message = $lang->sprintf($lang->asb_pms_user_disabled_pms, "settings['bburl']}/usercp.php?action=options\">{$lang->welcome_usercp}"); 84 | $$template_var = << 86 | {$pm_message} 87 | 88 | EOF; 89 | return false; 90 | } 91 | } 92 | 93 | /** 94 | * handles display of children of this addon via AJAX 95 | * 96 | * @param array info from child box 97 | * @return void 98 | */ 99 | function asb_private_messages_xmlhttp($args) 100 | { 101 | extract($args); 102 | global $db, $mybb; 103 | 104 | $query = $db->simple_select('privatemessages', '*', "dateline > {$dateline} AND toid='{$mybb->user['uid']}'"); 105 | 106 | if ($db->num_rows($query) > 0) { 107 | $pmessages = asb_private_messages_get_messages(); 108 | 109 | if ($pmessages) { 110 | return $pmessages; 111 | } 112 | } 113 | return 'nochange'; 114 | } 115 | 116 | /** 117 | * get the user's private messages 118 | * 119 | * @return string|bool html or success/fail 120 | */ 121 | function asb_private_messages_get_messages() 122 | { 123 | global $db, $mybb, $templates, $lang; 124 | 125 | // Load global and custom language phrases 126 | if (!$lang->asb_addon) { 127 | $lang->load('asb_addon'); 128 | } 129 | 130 | if ($mybb->user['uid'] == 0) { 131 | // guest 132 | $pmessages = $lang->sprintf("{$lang->asb_pms_no_messages}", "settings['bburl']}/member.php?action=login\">{$lang->asb_pms_login}", "settings['bburl']}/member.php?action=register\">{$lang->asb_pms_register}"); 133 | $ret_val = false; 134 | } else { 135 | // has the user disabled pms? 136 | if ($mybb->user['receivepms']) { 137 | // does admin allow pms? 138 | if (!$mybb->usergroup['canusepms'] || 139 | !$mybb->settings['enablepms']) { 140 | // if not tell them 141 | $pmessages = $lang->sprintf("{$lang->asb_pms_disabled_by_admin}", "settings['bburl']}/usercp.php?action=options\">{$lang->welcome_usercp}"); 142 | $ret_val = false; 143 | } else { 144 | // if so show the user their PM info 145 | $username = build_profile_link(format_name($mybb->user['username'], $mybb->user['usergroup'], $mybb->user['displaygroup']), $mybb->user['uid']); 146 | $lang->asb_pms_received_new = $lang->sprintf($lang->asb_pms_received_new, $username, $mybb->user['pms_unread']); 147 | 148 | eval("\$pmessages = \"{$templates->get('asb_pms')}\";"); 149 | } 150 | } else { 151 | // user has disabled PMs 152 | $pmessages = ''; 153 | } 154 | } 155 | return $pmessages; 156 | } 157 | 158 | ?> 159 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/rand_quote.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array module info 20 | */ 21 | function asb_rand_quote_info() 22 | { 23 | global $lang; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array( 30 | 'title' => $lang->asb_random_quotes, 31 | 'description' => $lang->asb_random_quotes_desc, 32 | 'wrap_content' => true, 33 | 'xmlhttp' => true, 34 | 'version' => '1.5.1', 35 | 'compatibility' => '2.1', 36 | 'settings' => array( 37 | 'forum_show_list' => array( 38 | 'sid' => 'NULL', 39 | 'name' => 'forum_show_list', 40 | 'title' => $lang->asb_forum_show_list_title, 41 | 'description' => $lang->asb_forum_show_list_desc, 42 | 'optionscode' => 'text', 43 | 'value' => '', 44 | ), 45 | 'forum_hide_list' => array( 46 | 'sid' => 'NULL', 47 | 'name' => 'forum_hide_list', 48 | 'title' => $lang->asb_forum_hide_list_title, 49 | 'description' => $lang->asb_forum_hide_list_desc, 50 | 'optionscode' => 'text', 51 | 'value' => '', 52 | ), 53 | 'thread_show_list' => array( 54 | 'sid' => 'NULL', 55 | 'name' => 'thread_show_list', 56 | 'title' => $lang->asb_thread_show_list_title, 57 | 'description' => $lang->asb_thread_show_list_desc, 58 | 'optionscode' => 'text', 59 | 'value' => '', 60 | ), 61 | 'thread_hide_list' => array( 62 | 'sid' => 'NULL', 63 | 'name' => 'thread_hide_list', 64 | 'title' => $lang->asb_thread_hide_list_title, 65 | 'description' => $lang->asb_thread_hide_list_desc, 66 | 'optionscode' => 'text', 67 | 'value' => '', 68 | ), 69 | 'min_length' => array( 70 | 'sid' => 'NULL', 71 | 'name' => 'min_length', 72 | 'title' => $lang->asb_random_quotes_min_quote_length_title, 73 | 'description' => $lang->asb_random_quotes_min_quote_length_desc, 74 | 'optionscode' => 'text', 75 | 'value' => '20', 76 | ), 77 | 'max_length' => array( 78 | 'sid' => 'NULL', 79 | 'name' => 'max_length', 80 | 'title' => $lang->asb_random_quotes_max_quote_length_title, 81 | 'description' => $lang->asb_random_quotes_max_quote_length, 82 | 'optionscode' => 'text', 83 | 'value' => '160', 84 | ), 85 | 'default_text' => array( 86 | 'sid' => 'NULL', 87 | 'name' => 'default_text', 88 | 'title' => $lang->asb_random_quotes_default_text_title, 89 | 'description' => $lang->asb_random_quotes_default_text_desc, 90 | 'optionscode' => 'text', 91 | 'value' => '', 92 | ), 93 | 'important_threads_only' => array( 94 | 'sid' => 'NULL', 95 | 'name' => 'important_threads_only', 96 | 'title' => $lang->asb_important_threads_only_title, 97 | 'description' => $lang->asb_important_threads_only_desc, 98 | 'optionscode' => 'yesno', 99 | 'value' => '0', 100 | ), 101 | 'xmlhttp_on' => array( 102 | 'sid' => 'NULL', 103 | 'name' => 'xmlhttp_on', 104 | 'title' => $lang->asb_xmlhttp_on_title, 105 | 'description' => $lang->asb_xmlhttp_on_description, 106 | 'optionscode' => 'text', 107 | 'value' => '0', 108 | ), 109 | ), 110 | 'discarded_templates' => array( 111 | 'rand_quote_sidebox', 112 | ), 113 | 'templates' => array( 114 | array( 115 | 'title' => 'asb_rand_quote_sidebox', 116 | 'template' => << 118 | 119 | {\$thread_title_link} 120 | 121 | 122 | 123 | 124 | {\$avatar_alt} {\$username} 125 | 126 | 127 | 128 | 129 | {\$new_message} 130 | 131 | {\$read_more} 132 | EOF 133 | ), 134 | array( 135 | 'title' => 'asb_rand_quote_read_more', 136 | 'template' => << 139 | 140 | 141 | 142 | 143 | EOF 144 | ), 145 | ), 146 | ); 147 | } 148 | 149 | /** 150 | * handles display of children of this addon at page load 151 | * 152 | * @param array information from child box 153 | * @return bool success/fail 154 | */ 155 | function asb_rand_quote_build_template($args) 156 | { 157 | extract($args); 158 | 159 | global $$template_var, $lang; 160 | 161 | if (!$lang->asb_addon) { 162 | $lang->load('asb_addon'); 163 | } 164 | 165 | $this_quote = asb_rand_quote_get_quote($settings, $width); 166 | if ($this_quote) { 167 | $$template_var = $this_quote; 168 | return true; 169 | } else { 170 | // show the table only if there are posts 171 | $$template_var = << 173 | 174 | {$lang->asb_random_quotes_no_posts} 175 | 176 | 177 | EOF; 178 | return false; 179 | } 180 | } 181 | 182 | /** 183 | * handles display of children of this addon via AJAX 184 | * 185 | * @param array info from child box 186 | * @return void 187 | */ 188 | function asb_rand_quote_xmlhttp($args) 189 | { 190 | extract($args); 191 | 192 | // get a quote and return it 193 | $this_quote = asb_rand_quote_get_quote($settings, $width); 194 | if ($this_quote) { 195 | return $this_quote; 196 | } 197 | return 'nochange'; 198 | } 199 | 200 | /** 201 | * get random quotes 202 | * 203 | * @param array settings 204 | * @param int column width 205 | * @return string|bool html or success/fail 206 | */ 207 | function asb_rand_quote_get_quote($settings, $width) 208 | { 209 | global $db, $mybb, $templates, $lang, $theme; 210 | 211 | if (!$lang->asb_addon) { 212 | $lang->load('asb_addon'); 213 | } 214 | 215 | // get forums user cannot view 216 | $unviewable = get_unviewable_forums(true); 217 | if ($unviewable) { 218 | $unviewwhere = " AND p.fid NOT IN ({$unviewable})"; 219 | } 220 | 221 | // get inactive forums 222 | $inactive = get_inactive_forums(); 223 | if ($inactive) { 224 | $inactivewhere = " AND p.fid NOT IN ({$inactive})"; 225 | } 226 | 227 | if ($settings['important_threads_only']) { 228 | $important_threads = ' AND NOT t.sticky=0'; 229 | } 230 | 231 | // build the exclude conditions 232 | $show['fids'] = asbBuildIdList($settings['forum_show_list'], 'p.fid'); 233 | $show['tids'] = asbBuildIdList($settings['thread_show_list'], 'p.tid'); 234 | $hide['fids'] = asbBuildIdList($settings['forum_hide_list'], 'p.fid'); 235 | $hide['tids'] = asbBuildIdList($settings['thread_hide_list'], 'p.tid'); 236 | $where['show'] = asbBuildSqlWhere($show, ' OR '); 237 | $where['hide'] = asbBuildSqlWhere($hide, ' OR ', ' NOT '); 238 | $query_where = $important_threads.$unviewwhere.$inactivewhere.asbBuildSqlWhere($where, ' AND ', ' AND '); 239 | 240 | $post_query = $db->query(" 241 | SELECT 242 | p.pid, p.message, p.fid, p.tid, p.subject, p.uid, 243 | u.username, u.usergroup, u.displaygroup, u.avatar, 244 | t.sticky 245 | FROM {$db->table_prefix}posts p 246 | LEFT JOIN {$db->table_prefix}users u ON (u.uid=p.uid) 247 | LEFT JOIN {$db->table_prefix}threads t ON (t.tid=p.tid) 248 | WHERE 249 | p.visible='1'{$query_where} 250 | ORDER BY 251 | RAND() 252 | LIMIT 1;" 253 | ); 254 | 255 | // if there was 1... 256 | if ($db->num_rows($post_query) == 0) { 257 | return false; 258 | } 259 | 260 | $rand_post = $db->fetch_array($post_query); 261 | 262 | // build a post parser 263 | require_once MYBB_ROOT.'inc/class_parser.php'; 264 | $parser = new postParser; 265 | 266 | // we just need the text and smilies (we'll parse them after we check length) 267 | $pattern = "|[[\/\!]*?[^\[\]]*?]|si"; 268 | $new_message = asbStripUrls(preg_replace($pattern, '$1', $rand_post['message'])); 269 | 270 | // get some dimensions that make sense in relation to column width 271 | $asb_width = (int) $width; 272 | $asb_inner_size = $asb_width * .83; 273 | $avatar_size = (int) ($asb_inner_size / 5); 274 | $font_size = $asb_width / 4.5; 275 | 276 | $font_size = max(10, min(16, $font_size)); 277 | $username_font_size = (int) ($font_size * .9); 278 | $title_font_size = (int) ($font_size * .65); 279 | $message_font_size = (int) $font_size; 280 | 281 | if (strlen($new_message) < $settings['min_length']) { 282 | if ($settings['default_text']) { 283 | $new_message = $settings['default_text']; 284 | } else { 285 | // nothing to show 286 | return false; 287 | } 288 | } 289 | 290 | if ($settings['max_length'] && 291 | strlen($new_message) > $settings['max_length']) { 292 | $new_message = substr($new_message, 0, $settings['max_length']).'...'; 293 | } 294 | 295 | // set up the user name link so that it displays correctly for the display group of the user 296 | $plain_text_username = htmlspecialchars_uni($rand_post['username']); 297 | $username = format_name($plain_text_username, $rand_post['usergroup'], $rand_post['displaygroup']); 298 | $author_link = get_profile_link($rand_post['uid']); 299 | $post_link = get_post_link($rand_post['pid'], $rand_post['tid']).'#pid'.$rand_post['pid']; 300 | $thread_link = get_thread_link($rand_post['tid']); 301 | 302 | // allow smilies, but kill 303 | $parser_options = array('allow_smilies' => 1); 304 | $new_message = str_replace(array('
    ', '/me'), array('', " * {$plain_text_username}"), $parser->parse_message($new_message.' ', $parser_options)); 305 | 306 | $avatar_info = format_avatar($rand_post['avatar']); 307 | $avatar_filename = $avatar_info['image']; 308 | 309 | $avatar_alt = $lang->sprintf($lang->asb_random_quote_users_profile, $plain_text_username); 310 | 311 | eval("\$read_more = \"{$templates->get('asb_rand_quote_read_more')}\";"); 312 | 313 | if (my_strlen($rand_post['subject']) > 40) { 314 | $rand_post['subject'] = my_substr($rand_post['subject'], 0, 40).'...'; 315 | } 316 | 317 | if (substr(strtolower($rand_post['subject']), 0, 3) == 're:') { 318 | $rand_post['subject'] = substr($rand_post['subject'], 3); 319 | } 320 | 321 | $rand_post['subject'] = htmlspecialchars_uni($parser->parse_badwords($rand_post['subject'])); 322 | 323 | $thread_title_link = <<{$rand_post['subject']} 325 | EOF; 326 | 327 | // eval() the template 328 | eval("\$this_quote = \"{$templates->get('asb_rand_quote_sidebox')}\";"); 329 | return $this_quote; 330 | } 331 | 332 | ?> 333 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/recent_posts.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array module info 20 | */ 21 | function asb_recent_posts_info() 22 | { 23 | global $lang; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array( 30 | 'title' => $lang->asb_recent_posts, 31 | 'description' => $lang->asb_recent_posts_desc, 32 | 'version' => '1.3.2', 33 | 'compatibility' => '2.1', 34 | 'wrap_content' => true, 35 | 'xmlhttp' => true, 36 | 'settings' => array( 37 | 'max_posts' => array( 38 | 'name' => 'max_posts', 39 | 'title' => $lang->asb_recent_posts_max_title, 40 | 'description' => $lang->asb_recent_posts_max_description, 41 | 'optionscode' => 'text', 42 | 'value' => '5', 43 | ), 44 | 'max_length' => array( 45 | 'name' => 'max_length', 46 | 'title' => $lang->asb_recent_posts_max_length_title, 47 | 'description' => $lang->asb_recent_posts_max_length_description, 48 | 'optionscode' => 'text', 49 | 'value' => '20', 50 | ), 51 | 'max_thread_title_length' => array( 52 | 'name' => 'max_thread_title_length', 53 | 'title' => $lang->asb_max_thread_title_length_title, 54 | 'description' => $lang->asb_max_thread_title_length_desc, 55 | 'optionscode' => 'text', 56 | 'value' => '40', 57 | ), 58 | 'forum_show_list' => array( 59 | 'name' => 'forum_show_list', 60 | 'title' => $lang->asb_forum_show_list_title, 61 | 'description' => $lang->asb_forum_show_list_desc, 62 | 'optionscode' => 'text', 63 | 'value' => '', 64 | ), 65 | 'forum_hide_list' => array( 66 | 'name' => 'forum_hide_list', 67 | 'title' => $lang->asb_forum_hide_list_title, 68 | 'description' => $lang->asb_forum_hide_list_desc, 69 | 'optionscode' => 'text', 70 | 'value' => '', 71 | ), 72 | 'thread_show_list' => array( 73 | 'name' => 'thread_show_list', 74 | 'title' => $lang->asb_thread_show_list_title, 75 | 'description' => $lang->asb_thread_show_list_desc, 76 | 'optionscode' => 'text', 77 | 'value' => '', 78 | ), 79 | 'thread_hide_list' => array( 80 | 'name' => 'thread_hide_list', 81 | 'title' => $lang->asb_thread_hide_list_title, 82 | 'description' => $lang->asb_thread_hide_list_desc, 83 | 'optionscode' => 'text', 84 | 'value' => '', 85 | ), 86 | 'important_threads_only' => array( 87 | 'name' => 'important_threads_only', 88 | 'title' => $lang->asb_important_threads_only_title, 89 | 'description' => $lang->asb_important_threads_only_desc, 90 | 'optionscode' => 'yesno', 91 | 'value' => '0', 92 | ), 93 | 'xmlhttp_on' => array( 94 | 'name' => 'xmlhttp_on', 95 | 'title' => $lang->asb_xmlhttp_on_title, 96 | 'description' => $lang->asb_xmlhttp_on_description, 97 | 'optionscode' => 'text', 98 | 'value' => '0', 99 | ), 100 | ), 101 | 'templates' => array( 102 | array( 103 | 'title' => 'asb_recent_posts_post', 104 | 'template' => << 106 | 107 | {\$post[\'subject\']} 108 | 109 | 110 | 111 | {\$post_excerpt}{\$post_author} — {\$lastposttime} 112 | 113 | EOF 114 | ), 115 | ), 116 | ); 117 | } 118 | 119 | /** 120 | * handles display of children of this addon at page load 121 | * 122 | * @param array information from child box 123 | * @return bool sucess/fail 124 | */ 125 | function asb_recent_posts_build_template($args) 126 | { 127 | extract($args); 128 | global $$template_var, $lang; 129 | 130 | if (!$lang->asb_addon) { 131 | $lang->load('asb_addon'); 132 | } 133 | 134 | // get the posts (or at least attempt to) 135 | $all_posts = recent_posts_get_postlist($settings); 136 | 137 | if ($all_posts) { 138 | // if there are posts, show them 139 | $$template_var = $all_posts; 140 | return true; 141 | } else { 142 | // if not, show nothing 143 | $$template_var = <<{$lang->asb_recent_posts_no_posts} 145 | EOF; 146 | return false; 147 | } 148 | } 149 | 150 | /** 151 | * handles display of children of this addon via AJAX 152 | * 153 | * @param array info from child box 154 | * @return void 155 | */ 156 | function asb_recent_posts_xmlhttp($args) 157 | { 158 | extract($args); 159 | $all_posts = recent_posts_get_postlist($settings); 160 | 161 | if (!$all_posts) { 162 | return 'nochange'; 163 | } 164 | return $all_posts; 165 | } 166 | 167 | /** 168 | * get random quotes 169 | * 170 | * @param array settings 171 | * @return string|bool html or success/fail 172 | */ 173 | function recent_posts_get_postlist($settings) 174 | { 175 | global $db, $mybb, $templates, $lang, $cache, $postlist, $gotounread, $theme; 176 | 177 | // load custom language phrases 178 | if (!$lang->asb_addon) { 179 | $lang->load('asb_addon'); 180 | } 181 | 182 | // get forums user cannot view 183 | $unviewable = get_unviewable_forums(true); 184 | if ($unviewable) { 185 | $unviewwhere = " AND p.fid NOT IN ({$unviewable})"; 186 | } 187 | 188 | // get inactive forums 189 | $inactive = get_inactive_forums(); 190 | if ($inactive) { 191 | $inactivewhere = " AND p.fid NOT IN ({$inactive})"; 192 | } 193 | 194 | if ($settings['important_threads_only']) { 195 | $important_threads = ' AND NOT t.sticky=0'; 196 | } 197 | 198 | // build the exclude conditions 199 | $show['fids'] = asbBuildIdList($settings['forum_show_list'], 'p.fid'); 200 | $show['tids'] = asbBuildIdList($settings['thread_show_list'], 'p.tid'); 201 | $hide['fids'] = asbBuildIdList($settings['forum_hide_list'], 'p.fid'); 202 | $hide['tids'] = asbBuildIdList($settings['thread_hide_list'], 'p.tid'); 203 | $where['show'] = asbBuildSqlWhere($show, ' OR '); 204 | $where['hide'] = asbBuildSqlWhere($hide, ' OR ', ' NOT '); 205 | $query_where = $important_threads.$unviewwhere.$inactivewhere.asbBuildSqlWhere($where, ' AND ', ' AND '); 206 | 207 | $altbg = alt_trow(); 208 | $maxtitlelen = 48; 209 | $postlist = ''; 210 | 211 | // Query for the latest forum discussions 212 | $query = $db->query(" 213 | SELECT p.tid, p.pid, p.message, p.fid, p.dateline, p.subject, 214 | u.username, u.uid, u.displaygroup, u.usergroup, 215 | t.sticky 216 | FROM {$db->table_prefix}posts p 217 | LEFT JOIN {$db->table_prefix}users u ON (u.uid=p.uid) 218 | LEFT JOIN {$db->table_prefix}threads t ON (t.tid=p.tid) 219 | WHERE 220 | p.visible='1'{$query_where} 221 | ORDER BY 222 | p.dateline DESC 223 | LIMIT 224 | 0, ".(int) $settings['max_posts'] 225 | ); 226 | 227 | if ($db->num_rows($query) == 0) { 228 | // no content 229 | return false; 230 | } 231 | 232 | // Build a post parser 233 | require_once MYBB_ROOT.'inc/class_parser.php'; 234 | $parser = new postParser; 235 | 236 | $post_cache = array(); 237 | while ($post = $db->fetch_array($query)) { 238 | $post_cache[$post['pid']] = $post; 239 | } 240 | 241 | foreach ($post_cache as $post) { 242 | $forumpermissions[$post['fid']] = forum_permissions($post['fid']); 243 | 244 | // make sure we can view this post 245 | if($forumpermissions[$post['fid']]['canview'] == 0 || $forumpermissions[$post['fid']]['canviewthreads'] == 0 || $forumpermissions[$post['fid']]['canonlyviewownthreads'] == 1 && $post['uid'] != $mybb->user['uid']) 246 | { 247 | continue; 248 | } 249 | 250 | $lastposttime = my_date($mybb->settings['timeformat'], $post['dateline']); 251 | 252 | // don't link to guest's profiles (they have no profile). 253 | if ($post['uid'] == 0) { 254 | $post_author = $post['username']; 255 | } else { 256 | $post_author_name = format_name($post['username'], $post['usergroup'], $post['displaygroup']); 257 | $post_author = build_profile_link($post_author_name, $post['uid']); 258 | } 259 | 260 | if (substr(strtolower($post['subject']), 0, 3) == 're:') { 261 | $post['subject'] = substr($post['subject'], 3); 262 | } 263 | 264 | $max_len = (int) $settings['max_thread_title_length']; 265 | if ($max_len > 0 && 266 | my_strlen($post['subject']) > $max_len) { 267 | $post['subject'] = my_substr($post['subject'], 0, $max_len).$lang->asb_recent_posts_title_ellipsis; 268 | } 269 | 270 | $post['subject'] = htmlspecialchars_uni($parser->parse_badwords($post['subject'])); 271 | $post['link'] = get_post_link($post['pid'], $post['tid'])."#pid{$post['pid']}"; 272 | 273 | // we just need the text and smilies (we'll parse them after we check length) 274 | $pattern = "|[[\/\!]*?[^\[\]]*?]|si"; 275 | $post_excerpt = strip_tags(str_replace('
    ', '', asbStripUrls(preg_replace($pattern, '$1', $post['message'])))); 276 | $post_excerpt = htmlspecialchars_uni($parser->parse_badwords($post_excerpt)); 277 | 278 | if ($settings['max_length'] && 279 | strlen($post_excerpt) > $settings['max_length']) { 280 | $post_excerpt = my_substr($post_excerpt, 0, $settings['max_length']).$lang->asb_recent_posts_ellipsis; 281 | } 282 | 283 | eval("\$postlist .= \"{$templates->get('asb_recent_posts_post')}\";"); 284 | $altbg = alt_trow(); 285 | } 286 | return $postlist; 287 | } 288 | 289 | ?> 290 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/search_box.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array module info 20 | */ 21 | function asb_search_box_info() 22 | { 23 | global $lang; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array( 30 | 'title' => $lang->asb_search, 31 | 'description' => $lang->asb_search_desc, 32 | 'wrap_content' => true, 33 | 'version' => '1.2.1', 34 | 'compatibility' => '2.1', 35 | 'templates' => array( 36 | array( 37 | 'title' => 'asb_search', 38 | 'template' => << 40 | 41 |
    42 | 43 | 44 | 45 | 46 |
    47 | 48 | 49 | 50 |

    51 |
    52 | 53 | 54 | 55 |

    56 |
    57 | 58 | {\$gobutton} 59 |

    60 | 61 | ({\$lang->asb_search_advanced_search}) 62 | 63 | 64 | 65 | EOF 66 | ), 67 | ), 68 | ); 69 | } 70 | 71 | /** 72 | * handles display of children of this addon at page load 73 | * 74 | * @param array info from child box 75 | * @return bool sucess/fail 76 | */ 77 | function asb_search_box_build_template($args) 78 | { 79 | extract($args); 80 | global $$template_var; 81 | 82 | global $mybb, $templates, $lang, $gobutton; 83 | 84 | // Load global and custom language phrases 85 | if (!$lang->asb_addon) { 86 | $lang->load('asb_addon'); 87 | } 88 | 89 | eval("\$".$template_var." = \"{$templates->get('asb_search')}\";"); 90 | return true; 91 | } 92 | 93 | ?> 94 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/slideshow.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array module info 20 | */ 21 | function asb_slideshow_info() 22 | { 23 | global $lang; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array( 30 | 'title' => $lang->asb_slideshow, 31 | 'description' => $lang->asb_slideshow_desc, 32 | 'wrap_content' => true, 33 | 'version' => '1.1', 34 | 'compatibility' => '2.1', 35 | 'scripts' => array( 36 | 'Slideshow', 37 | ), 38 | 'settings' => array( 39 | 'folder' => array( 40 | 'name' => 'folder', 41 | 'title' => $lang->asb_slideshow_folder_title, 42 | 'description' => $lang->asb_slideshow_folder_description, 43 | 'optionscode' => 'text', 44 | 'value' => 'images', 45 | ), 46 | 'recursive' => array( 47 | 'name' => 'recursive', 48 | 'title' => $lang->asb_slideshow_recursive_title, 49 | 'description' => $lang->asb_slideshow_recursive_description, 50 | 'optionscode' => 'yesno', 51 | 'value' => '0', 52 | ), 53 | 'rate' => array( 54 | 'name' => 'rate', 55 | 'title' => $lang->asb_slideshow_rate_title, 56 | 'description' => $lang->asb_slideshow_rate_description, 57 | 'optionscode' => 'text', 58 | 'value' => '10', 59 | ), 60 | 'shuffle' => array( 61 | 'name' => 'shuffle', 62 | 'title' => $lang->asb_slideshow_shuffle_title, 63 | 'description' => $lang->asb_slideshow_shuffle_description, 64 | 'optionscode' => 'yesno', 65 | 'value' => '1', 66 | ), 67 | 'fade_rate' => array( 68 | 'name' => 'fade_rate', 69 | 'title' => $lang->asb_slideshow_fade_rate_title, 70 | 'description' => $lang->asb_slideshow_fade_rate_description, 71 | 'optionscode' => 'text', 72 | 'value' => '1', 73 | ), 74 | 'footer_text' => array( 75 | 'name' => 'footer_text', 76 | 'title' => $lang->asb_slideshow_footer_text_title, 77 | 'description' => $lang->asb_slideshow_footer_text_description, 78 | 'optionscode' => 'text', 79 | 'value' => '', 80 | ), 81 | 'footer_url' => array( 82 | 'name' => 'footer_url', 83 | 'title' => $lang->asb_slideshow_footer_url_title, 84 | 'description' => $lang->asb_slideshow_footer_url_description, 85 | 'optionscode' => 'text', 86 | 'value' => '', 87 | ), 88 | 'max_width' => array( 89 | 'name' => 'max_width', 90 | 'title' => $lang->asb_slideshow_max_width_title, 91 | 'description' => $lang->asb_slideshow_max_width_description, 92 | 'optionscode' => 'text', 93 | 'value' => '', 94 | ), 95 | 'max_height' => array( 96 | 'name' => 'max_height', 97 | 'title' => $lang->asb_slideshow_max_height_title, 98 | 'description' => $lang->asb_slideshow_max_height_description, 99 | 'optionscode' => 'text', 100 | 'value' => '', 101 | ), 102 | 'maintain_height' => array( 103 | 'name' => 'maintain_height', 104 | 'title' => $lang->asb_slideshow_maintain_height_title, 105 | 'description' => $lang->asb_slideshow_maintain_height_description, 106 | 'optionscode' => 'yesno', 107 | 'value' => '1', 108 | ), 109 | ), 110 | 'templates' => array( 111 | array( 112 | 'title' => 'asb_slideshow', 113 | 'template' => << 115 | 116 |
    117 | 132 | 133 | {\$footer} 134 | EOF 135 | ), 136 | array( 137 | 'title' => 'asb_slideshow_footer', 138 | 'template' => << 141 | 142 | 145 | 146 | 147 | EOF 148 | ), 149 | ), 150 | ); 151 | } 152 | 153 | /** 154 | * handles display of children of this addon at page load 155 | * 156 | * @param array info from child box 157 | * @return bool success/fail 158 | */ 159 | function asb_slideshow_build_template($args) 160 | { 161 | extract($args); 162 | 163 | global $$template_var, $mybb, $templates; 164 | 165 | $shuffle = $settings['shuffle'] ? 'true' : 'false'; 166 | $folder = $settings['folder']; 167 | $rate = (int) $settings['rate'] ? (int) $settings['rate'] : 10; 168 | $fade_rate = (float) $settings['fade_rate'] ? (int) ($settings['fade_rate'] * 1000) : 400; 169 | 170 | $filenames = asbGetImagesFromPath($folder, '', $settings['recursive']); 171 | if (!$filenames) { 172 | $$template_var = << 174 | {$lang->asb_slideshow_no_images} 175 | 176 | EOF; 177 | return false; 178 | } 179 | 180 | if ($settings['footer_text'] && $settings['footer_url']) { 181 | eval ("\$footer = \"{$templates->get('asb_slideshow_footer')}\";"); 182 | } 183 | 184 | $max_width = (int) $settings['max_width']; 185 | $max_height = (int) $settings['max_height']; 186 | $maintain_height = (int) $settings['maintain_height']; 187 | 188 | $width = $width * .9; 189 | eval("\$\$template_var = \"{$templates->get('asb_slideshow')}\";"); 190 | 191 | return true; 192 | } 193 | 194 | ?> 195 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/staff_online_box.php: -------------------------------------------------------------------------------- 1 | asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array( 30 | 'title' => $lang->asb_staff_online, 31 | 'description' => $lang->asb_staff_online_desc, 32 | 'version' => '1.4.4', 33 | 'compatibility' => '2.1', 34 | 'wrap_content' => true, 35 | 'xmlhttp' => true, 36 | 'settings' => array( 37 | 'max_staff' => array( 38 | 'name' => 'max_staff', 39 | 'title' => $lang->asb_staff_online_max_staff_title, 40 | 'description' => $lang->asb_staff_online_max_staff_desc, 41 | 'optionscode' => 'text', 42 | 'value' => '5', 43 | ), 44 | 'group_show_list' => array( 45 | 'name' => 'group_show_list', 46 | 'title' => $lang->asb_group_show_list_title, 47 | 'description' => $lang->asb_group_show_list_desc, 48 | 'optionscode' => 'text', 49 | 'value' => '', 50 | ), 51 | 'group_hide_list' => array( 52 | 'name' => 'group_hide_list', 53 | 'title' => $lang->asb_group_hide_list_title, 54 | 'description' => $lang->asb_group_hide_list_desc, 55 | 'optionscode' => 'text', 56 | 'value' => '', 57 | ), 58 | 'xmlhttp_on' => array( 59 | 'name' => 'xmlhttp_on', 60 | 'title' => $lang->asb_xmlhttp_on_title, 61 | 'description' => $lang->asb_xmlhttp_on_description, 62 | 'optionscode' => 'text', 63 | 'value' => '0', 64 | ), 65 | ), 66 | 'discarded_templates' => array( 67 | 'asb_staff_online', 68 | ), 69 | 'templates' => array( 70 | array( 71 | 'title' => 'asb_staff_online_bit', 72 | 'template' => << 74 | 75 | 76 | 77 | 80 | 83 | 84 | 85 | 88 | 89 |
    78 | {\$staff_avatar_alt} 79 | 81 | {\$staff_username} 82 |
    86 | {\$staff_badge} 87 |
    90 | 91 | 92 | EOF 93 | ), 94 | ), 95 | ); 96 | } 97 | 98 | /** 99 | * handles display of children of this addon at page load 100 | * 101 | * @param array info from child box 102 | * @return bool success/fail 103 | */ 104 | function asb_staff_online_box_build_template($args) 105 | { 106 | extract($args); 107 | global $$template_var, $lang; 108 | 109 | if (!$lang->asb_addon) { 110 | $lang->load('asb_addon'); 111 | } 112 | 113 | $all_online_staff = asb_staff_online_box_get_online_staff($settings, $width); 114 | 115 | if ($all_online_staff) { 116 | $$template_var = $all_online_staff; 117 | return true; 118 | } else { 119 | $$template_var = << 121 | {$lang->asb_staff_online_no_staff_online} 122 | 123 | EOF; 124 | return false; 125 | } 126 | } 127 | 128 | /** 129 | * handles display of children of this addon via AJAX 130 | * 131 | * @param array info from child box 132 | * @return void 133 | */ 134 | function asb_staff_online_box_xmlhttp($args) 135 | { 136 | extract($args); 137 | $all_online_staff = asb_staff_online_box_get_online_staff($settings, $width); 138 | 139 | if ($all_online_staff) { 140 | return $all_online_staff; 141 | } 142 | return 'nochange'; 143 | } 144 | 145 | /** 146 | * get staff members currently online 147 | * 148 | * @param array settings 149 | * @param int column width 150 | * @return string|bool html or false 151 | */ 152 | function asb_staff_online_box_get_online_staff($settings, $width) 153 | { 154 | global $db, $mybb, $templates, $lang, $cache, $theme; 155 | 156 | if (!$lang->asb_addon) { 157 | $lang->load('asb_addon'); 158 | } 159 | 160 | // get our setting value 161 | $max_rows = (int) $settings['max_staff']; 162 | 163 | // if max_rows is set to 0 then show nothing 164 | if (!$max_rows) { 165 | return false; 166 | } 167 | 168 | // store our users and groups here 169 | $usergroups = array(); 170 | $users = array(); 171 | 172 | // build user group exclusions (if any) 173 | $show = asbBuildIdList($settings['group_show_list'], 'gid'); 174 | $hide = asbBuildIdList($settings['group_hide_list'], 'gid'); 175 | $where['show'] = asbBuildSqlWhere($show, ' OR '); 176 | $where['hide'] = asbBuildSqlWhere($hide, ' OR ', ' NOT '); 177 | $group_where = asbBuildSqlWhere($where, ' AND ', ' AND '); 178 | 179 | // get all the groups admin has specified should be shown on showteam.php 180 | $query = $db->simple_select('usergroups', 'gid, title, usertitle, image', "showforumteam=1{$group_where}", array('order_by' => 'disporder')); 181 | while ($usergroup = $db->fetch_array($query)) { 182 | // store them in our array 183 | $usergroups[$usergroup['gid']] = $usergroup; 184 | } 185 | 186 | // get all the users of those specific groups 187 | $groups_in = implode(',', array_keys($usergroups)); 188 | 189 | // if there were no groups... 190 | if (!$groups_in) { 191 | // there is nothing to show 192 | return false; 193 | } 194 | 195 | // set the time based on ACP settings 196 | $timesearch = TIME_NOW - $mybb->settings['wolcutoff']; 197 | 198 | // get all the users that are in staff groups that have been online within the allowed cutoff time 199 | $query = $db->query(" 200 | SELECT 201 | s.sid, s.ip, s.uid, s.time, s.location, 202 | u.username, u.invisible, u.usergroup, u.displaygroup, u.avatar 203 | FROM {$db->table_prefix}sessions s 204 | LEFT JOIN {$db->table_prefix}users u ON (s.uid=u.uid) 205 | WHERE 206 | (displaygroup IN ($groups_in) OR (displaygroup='0' AND usergroup IN ($groups_in))) AND s.time > '{$timesearch}' 207 | ORDER BY 208 | u.username ASC, s.time DESC 209 | "); 210 | 211 | // loop through our users 212 | while ($user = $db->fetch_array($query)) { 213 | // if displaygroup is not 0, display primary group 214 | if ($user['displaygroup'] != 0) { 215 | // then use this group 216 | $group = $user['displaygroup']; 217 | } else { 218 | // otherwise use the primary group 219 | $group = $user['usergroup']; 220 | } 221 | 222 | // if this user group is in a staff group then add the info to the list 223 | if ($usergroups[$group]) { 224 | $usergroups[$group]['user_list'][$user['uid']] = $user; 225 | } 226 | } 227 | 228 | // make sure we start from nothing 229 | $grouplist = ''; 230 | $counter = 1; 231 | 232 | // loop through each user group 233 | foreach ($usergroups as $usergroup) { 234 | // if there are no users or we have reached our limit... 235 | if (!isset($usergroup['user_list']) || $counter > $max_rows) { 236 | // skip an iteration 237 | continue; 238 | } 239 | 240 | // we use this for the alternating table row bgcolor 241 | $bgcolor = ''; 242 | 243 | // loop through all users 244 | foreach ($usergroup['user_list'] as $user) { 245 | // if we are over our limit 246 | if ($counter > $max_rows) { 247 | // don't add any more 248 | continue; 249 | } 250 | 251 | // prepare the info 252 | // alt and title for image are the same 253 | $staff_avatar_alt = $staff_avatar_title = "{$user['username']}'s profile"; 254 | 255 | // if the user has an avatar then display it, otherwise force the default avatar. 256 | $avatar_info = format_avatar($user['avatar']); 257 | $staff_avatar_filename = $avatar_info['image']; 258 | 259 | // avatar properties 260 | $staff_avatar_dimensions = '100%'; 261 | 262 | // user name link properties 263 | $staff_link_title = $user['username']; 264 | $staff_username = format_name($user['username'], $user['usergroup'], $user['displaygroup']); 265 | 266 | // link (for avatar and user name) 267 | $staff_profile_link = get_profile_link($user['uid']); 268 | 269 | // badge alt and title are the same 270 | $staff_badge_alt = $staff_badge_title = $usergroup['usertitle']; 271 | 272 | // if the user's group has a badge image... 273 | $staff_badge = $staff_badge_alt; 274 | if ($usergroup['image']) { 275 | // store it (if nothing is store alt property will display group default usertitle) 276 | $staff_badge_filename = $usergroup['image']; 277 | 278 | $staff_badge = << 280 | EOF; 281 | } 282 | 283 | // give us an alternating bgcolor 284 | $bgcolor = alt_trow(); 285 | 286 | // incremenet the counter 287 | ++$counter; 288 | 289 | // add this row to the table 290 | eval("\$online_staff .= \"{$templates->get("asb_staff_online_bit")}\";"); 291 | } 292 | } 293 | 294 | // if there were staff members online... 295 | if ($online_staff) { 296 | // show them 297 | return $online_staff; 298 | } else { 299 | // otherwise apologize profusely 300 | return false; 301 | } 302 | } 303 | 304 | ?> 305 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/statistics.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array module info 20 | */ 21 | function asb_statistics_info() 22 | { 23 | global $lang; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array( 30 | 'title' => $lang->asb_stats, 31 | 'description' => $lang->asb_stats_desc, 32 | 'wrap_content' => true, 33 | 'version' => '1.2', 34 | 'compatibility' => '2.1', 35 | 'settings' => array( 36 | 'format_username' => array( 37 | 'name' => 'format_username', 38 | 'title' => $lang->asb_stats_format_usernames_title, 39 | 'description' => $lang->asb_stats_format_usernames_desc, 40 | 'optionscode' => 'yesno', 41 | 'value' => '0', 42 | ), 43 | ), 44 | 'templates' => array( 45 | array( 46 | 'title' => 'asb_statistics', 47 | 'template' => << 49 | 50 | 51 | » {\$lang->asb_stats_num_members}: {\$statistics[\'numusers\']}
    52 | » {\$lang->asb_stats_latest_member}: {\$newestmember}
    53 | » {\$lang->asb_stats_num_threads}: {\$statistics[\'numthreads\']}
    54 | » {\$lang->asb_stats_num_posts}: {\$statistics[\'numposts\']} 55 |

    {\$lang->asb_stats_full_stats} 56 |
    57 | 58 | 59 | EOF 60 | ), 61 | ), 62 | ); 63 | } 64 | 65 | /** 66 | * handles display of children of this addon at page load 67 | * 68 | * @param array info from child box 69 | * @return bool success/fail 70 | */ 71 | function asb_statistics_build_template($args) 72 | { 73 | extract($args); 74 | global $$template_var, $mybb, $cache, $templates, $lang; 75 | 76 | // Load global and custom language phrases 77 | if (!$lang->asb_addon) { 78 | $lang->load('asb_addon'); 79 | } 80 | 81 | // get forum statistics 82 | $statistics = $cache->read('stats'); 83 | $statistics['numthreads'] = my_number_format($statistics['numthreads']); 84 | $statistics['numposts'] = my_number_format($statistics['numposts']); 85 | $statistics['numusers'] = my_number_format($statistics['numusers']); 86 | 87 | $newestmember = "{$lang->asb_stats_no_one}"; 88 | if ($statistics['lastusername']) { 89 | if ($settings['format_username']) { 90 | $last_user = get_user($statistics['lastuid']); 91 | $last_username = format_name($last_user['username'], $last_user['usergroup'], $last_user['displaygroup']); 92 | } else { 93 | $last_username = $statistics['lastusername']; 94 | } 95 | $newestmember = build_profile_link($last_username, $statistics['lastuid']); 96 | } 97 | 98 | eval("\$".$template_var." = \"{$templates->get('asb_statistics')}\";"); 99 | return true; 100 | } 101 | 102 | ?> 103 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/welcome_box.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array module info 20 | */ 21 | function asb_welcome_box_info() 22 | { 23 | global $lang; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array( 30 | 'title' => $lang->asb_welcome, 31 | 'description' => $lang->asb_welcome_desc, 32 | 'wrap_content' => true, 33 | 'version' => '1.3.4', 34 | 'compatibility' => '2.1', 35 | 'templates' => array( 36 | array( 37 | 'title' => 'asb_welcome', 38 | 'template' => << 40 | 41 | {\$welcometext} 42 | 43 | 44 | EOF 45 | ), 46 | array( 47 | 'title' => 'asb_welcome_membertext', 48 | 'template' => <<{\$lang->asb_welcome_member_welcome_lastvisit}: {\$lastvisit}
    50 | {\$lang->since_then}
    51 | » {\$lang->asb_welcome_new_announcements}
    52 | » {\$lang->asb_welcome_new_threads}
    53 | » {\$lang->asb_welcome_new_posts}

    54 | {\$lang->welcome_newposts}
    {\$lang->asb_welcome_view_todays} 55 | 56 | EOF 57 | ), 58 | array( 59 | 'title' => 'asb_welcome_guesttext', 60 | 'template' => <<{\$lang->asb_welcome_guest_welcome_registration}
    62 |
    63 |
    64 | 65 | 66 | {\$username}


    67 | {\$lang->password}


    68 |

    69 | 70 |
    71 | EOF 72 | ), 73 | ), 74 | ); 75 | } 76 | 77 | /** 78 | * handles display of children of this addon at page load 79 | * 80 | * @param array info from child box 81 | * @return bool true on success, false on fail/no content 82 | */ 83 | function asb_welcome_box_build_template($args) 84 | { 85 | extract($args); 86 | global $$template_var, $db, $mybb, $templates, $lang, $lastvisit, $theme, $user_avatar; 87 | 88 | // Load global and custom language phrases 89 | if (!$lang->asb_addon) { 90 | $lang->load('asb_addon'); 91 | } 92 | 93 | if ($mybb->user['uid'] != 0) { 94 | // Get number of new posts, threads, announcements 95 | $query = $db->simple_select('posts', 'COUNT(pid) AS newposts', "visible=1 AND dateline > '{$mybb->user['lastvisit']}' {$unviewwhere}"); 96 | $newposts = $db->fetch_field($query, 'newposts'); 97 | if ($newposts) { 98 | // If there aren't any new posts, there is no point in wasting two more queries 99 | $query = $db->simple_select('threads', 'COUNT(tid) AS newthreads', "visible=1 AND dateline > '{$mybb->user['lastvisit']}' {$unviewwhere}"); 100 | $newthreads = $db->fetch_field($query, 'newthreads'); 101 | 102 | $announcementsfids = explode(',', $mybb->settings['portal_announcementsfid']); 103 | if (is_array($announcementsfids)) { 104 | foreach ($announcementsfids as $fid) { 105 | $fid_array[] = intval($fid); 106 | } 107 | 108 | $announcementsfids = implode(',', $fid_array); 109 | $query = $db->simple_select('threads', 'COUNT(tid) AS newann', "visible=1 AND dateline > '{$mybb->user['lastvisit']}' AND fid IN ({$announcementsfids}) {$unviewwhere}"); 110 | $newann = $db->fetch_field($query, 'newann'); 111 | } 112 | 113 | if (!$newthreads) { 114 | $newthreads = 0; 115 | } 116 | 117 | if (!$newann) { 118 | $newann = 0; 119 | } 120 | } else { 121 | $newposts = 0; 122 | $newthreads = 0; 123 | $newann = 0; 124 | } 125 | 126 | // Make the text 127 | if ($newann == 1) { 128 | $lang->asb_welcome_new_announcements = $lang->asb_welcome_new_announcement; 129 | } else { 130 | $lang->asb_welcome_new_announcements = $lang->sprintf($lang->asb_welcome_new_announcements, $newann ? $newann : '0'); 131 | } 132 | if ($newthreads == 1) { 133 | $lang->asb_welcome_new_threads = $lang->asb_welcome_new_thread; 134 | } else { 135 | $lang->asb_welcome_new_threads = $lang->sprintf($lang->asb_welcome_new_threads, $newthreads ? $newthreads : '0'); 136 | } 137 | if ($newposts == 1) { 138 | $lang->asb_welcome_new_posts = $lang->asb_welcome_new_post; 139 | } else { 140 | $lang->asb_welcome_new_posts = $lang->sprintf($lang->asb_welcome_new_posts, $newposts ? $newposts : '0'); 141 | } 142 | 143 | $avatar_width = (int) ($width / 5); 144 | 145 | $avatar_info = format_avatar($mybb->user['avatar']); 146 | $avatar_filename = $avatar_info['image']; 147 | 148 | $user_avatar = <<{$mybb->user['username']}'s profile  150 | EOF; 151 | 152 | eval("\$welcometext = \"{$templates->get('asb_welcome_membertext')}\";"); 153 | } else { 154 | $lang->asb_welcome_guest_welcome_registration = $lang->sprintf($lang->asb_welcome_guest_welcome_registration, $mybb->settings['bburl'].'/member.php?action=register'); 155 | $mybb->user['username'] = $lang->guest; 156 | switch ($mybb->settings['username_method']) { 157 | case 0: 158 | $username = $lang->username; 159 | break; 160 | case 1: 161 | $username = $lang->username1; 162 | break; 163 | case 2: 164 | $username = $lang->username2; 165 | break; 166 | default: 167 | $username = $lang->username; 168 | break; 169 | } 170 | eval("\$welcometext = \"{$templates->get('asb_welcome_guesttext')}\";"); 171 | } 172 | 173 | $lang->welcome = $lang->sprintf($lang->welcome, $mybb->user['username']); 174 | eval("\$".$template_var." = \"{$templates->get('asb_welcome')}\";"); 175 | return true; 176 | } 177 | 178 | ?> 179 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/modules/whosonline.php: -------------------------------------------------------------------------------- 1 |
    Please make sure IN_MYBB is defined.'); 14 | } 15 | 16 | /** 17 | * provide info to ASB about the addon 18 | * 19 | * @return array module info 20 | */ 21 | function asb_whosonline_info() 22 | { 23 | global $db, $lang, $theme; 24 | 25 | if (!$lang->asb_addon) { 26 | $lang->load('asb_addon'); 27 | } 28 | 29 | return array( 30 | 'title' => $lang->asb_wol, 31 | 'description' => $lang->asb_wol_desc, 32 | 'version' => '1.4.6', 33 | 'compatibility' => '2.1', 34 | 'wrap_content' => true, 35 | 'xmlhttp' => true, 36 | 'settings' => array( 37 | 'show_avatars' => array( 38 | 'name' => 'show_avatars', 39 | 'title' => $lang->asb_show_avatars_title, 40 | 'description' => $lang->asb_show_avatars_desc, 41 | 'optionscode' => 'yesno', 42 | 'value' => '1', 43 | ), 44 | 'asb_avatar_per_row' => array( 45 | 'name' => 'asb_avatar_per_row', 46 | 'title' => $lang->asb_wol_num_avatars_per_row_title, 47 | 'description' => $lang->asb_wol_num_avatars_per_row_desc, 48 | 'optionscode' => 'text', 49 | 'value' => '4', 50 | ), 51 | 'asb_avatar_max_rows' => array( 52 | 'name' => 'asb_avatar_max_rows', 53 | 'title' => $lang->asb_wol_avatar_max_rows_title, 54 | 'description' => $lang->asb_wol_avatar_max_rows_desc, 55 | 'optionscode' => 'text', 56 | 'value' => '3', 57 | ), 58 | 'asb_avatar_maintain_aspect' => array( 59 | 'name' => 'asb_avatar_maintain_aspect', 60 | 'title' => $lang->asb_wol_avatar_maintain_aspect_title, 61 | 'description' => $lang->asb_wol_avatar_maintain_aspect_desc, 62 | 'optionscode' => 'yesno', 63 | 'value' => '0', 64 | ), 65 | 'xmlhttp_on' => array( 66 | 'name' => 'xmlhttp_on', 67 | 'title' => $lang->asb_xmlhttp_on_title, 68 | 'description' => $lang->asb_xmlhttp_on_description, 69 | 'optionscode' => 'text', 70 | 'value' => '0', 71 | ), 72 | ), 73 | 'templates' => array( 74 | array( 75 | 'title' => 'asb_whosonline', 76 | 'template' => << 78 | 79 | {\$lang->asb_wol_online_users} [{\$lang->asb_wol_complete_list}]
    » {\$lang->asb_wol_online_counts}
    80 | 81 | 82 | 83 | 84 | 85 | 86 | {\$onlinemembers} 87 | 88 |
    89 | 90 | 91 | EOF 92 | ), 93 | array( 94 | 'title' => 'asb_whosonline_memberbit_name', 95 | 'template' => <<{\$user[\'username\']} 97 | EOF 98 | ), 99 | array( 100 | 'title' => 'asb_whosonline_memberbit_avatar', 101 | 'template' => <<{\$lang->asb_wol_avatar} 103 | EOF 104 | ), 105 | array( 106 | 'title' => 'asb_whosonline_memberbit_see_all', 107 | 'template' => <<{\$lang->asb_wol_see_all_alt} 109 | EOF 110 | ), 111 | ), 112 | ); 113 | } 114 | 115 | /** 116 | * handles display of children of this addon at page load 117 | * 118 | * @param array info from child box 119 | * @return bool success/fail 120 | */ 121 | function asb_whosonline_build_template($args) 122 | { 123 | extract($args); 124 | global $$template_var, $lang; 125 | 126 | if (!$lang->asb_addon) { 127 | $lang->load('asb_addon'); 128 | } 129 | 130 | // get the online members 131 | $all_onlinemembers = asb_whosonline_get_online_members($settings, $width); 132 | 133 | // if there are members online... 134 | if ($all_onlinemembers) { 135 | // set out template variable to the returned member list and return true 136 | $$template_var = $all_onlinemembers; 137 | return true; 138 | } else { 139 | // show the table only if there are threads 140 | $$template_var = <<{$lang->asb_wol_no_one_online} 142 | EOF; 143 | return false; 144 | } 145 | } 146 | 147 | /** 148 | * handles display of children of this addon via AJAX 149 | * 150 | * @param array information from child box 151 | * @return void 152 | */ 153 | function asb_whosonline_xmlhttp($args) 154 | { 155 | extract($args); 156 | $all_onlinemembers = asb_whosonline_get_online_members($settings, $width); 157 | 158 | if ($all_onlinemembers) { 159 | return $all_onlinemembers; 160 | } 161 | return 'nochange'; 162 | } 163 | 164 | /** 165 | * get the members currently online 166 | * 167 | * @param array settings 168 | * @param int column width 169 | * @return string|bool html or false 170 | */ 171 | function asb_whosonline_get_online_members($settings, $width) 172 | { 173 | global $db, $mybb, $templates, $lang, $cache, $theme; 174 | 175 | // Load global and custom language phrases 176 | if (!$lang->asb_addon) { 177 | $lang->load('asb_addon'); 178 | } 179 | 180 | $all_users = array(); 181 | 182 | // width 183 | $rowlength = (int) $settings['asb_avatar_per_row']; 184 | if ($rowlength == 0) { 185 | return false; 186 | } 187 | 188 | $max_rows = (int) $settings['asb_avatar_max_rows']; 189 | $row = 1; 190 | $avatar_count = 0; 191 | $enough_already = false; 192 | $sep = ''; 193 | 194 | // Scale the avatars based on the width of the side boxes in Admin CP 195 | $avatar_height = $avatar_width = (int) ($width * .83) / $rowlength; 196 | $avatar_margin = (int) ($avatar_width *.02); 197 | 198 | $timesearch = TIME_NOW - $mybb->settings['wolcutoff']; 199 | $guestcount = 0; 200 | $membercount = 0; 201 | $onlinemembers = ''; 202 | $query = $db->write_query(" 203 | SELECT s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup, u.avatar, u.avatardimensions 204 | FROM {$db->table_prefix}sessions s 205 | LEFT JOIN {$db->table_prefix}users u ON (s.uid=u.uid) 206 | WHERE s.time > '{$timesearch}' 207 | ORDER BY u.username ASC, s.time DESC 208 | "); 209 | 210 | while ($user = $db->fetch_array($query)) { 211 | // create a key to test if this user is a search bot. 212 | $botkey = my_strtolower(str_replace('bot=', '', $user['sid'])); 213 | 214 | if ($user['uid'] == '0') { 215 | ++$guestcount; 216 | } elseif (my_strpos($user['sid'], 'bot=') !== false && $session->bots[$botkey]) { 217 | // The user is a search bot. 218 | $onlinemembers .= format_name($session->bots[$botkey], $session->botgroup); 219 | ++$botcount; 220 | } else { 221 | $all_users[] = $user; 222 | } 223 | } 224 | 225 | foreach ($all_users as $user) { 226 | if ($doneusers[$user['uid']] < $user['time'] || 227 | !$doneusers[$user['uid']]) { 228 | ++$membercount; 229 | 230 | $doneusers[$user['uid']] = $user['time']; 231 | 232 | // If the user is logged in anonymously, update the count for that. 233 | if ($user['invisible'] == 1) { 234 | ++$anoncount; 235 | } 236 | 237 | if ((($user['invisible'] == 1 && 238 | ($mybb->usergroup['canviewwolinvis'] == 1 || 239 | $user['uid'] == $mybb->user['uid'])) || 240 | $user['invisible'] != 1) && 241 | $user['usergroup'] != 7) { 242 | $user['profilelink'] = get_profile_link($user['uid']); 243 | 244 | if ($settings['show_avatars']) { 245 | $avatar_info = format_avatar($user['avatar']); 246 | $avatar_filename = $avatar_info['image']; 247 | 248 | $avatar_height_style = " min-height: {$avatar_height}px; max-height: {$avatar_height}px;"; 249 | $avatar_width_style = " min-width: {$avatar_width}px; max-width: {$avatar_width}px;"; 250 | if ($settings['asb_avatar_maintain_aspect']) { 251 | // Check the avatar's dimensions, then constrain it by its largest dimension 252 | $avatar_dimensions = explode('|', $user['avatardimensions']); 253 | 254 | if ($avatar_dimensions[0] > $avatar_dimensions[1]) { 255 | $avatar_height_style = ''; 256 | } else { 257 | $avatar_width_style = ''; 258 | } 259 | } 260 | 261 | // if this is the last allowable avatar (conforming to ACP settings) 262 | if ($avatar_count >= (($max_rows * $rowlength) - 1) && 263 | $avatar_count) { 264 | // check to see if we've already handled this, if so, do nothing 265 | if (!$enough_already) { 266 | // ...if not, set a flag 267 | $enough_already = true; 268 | 269 | // ...and insert link to the WOL full list 270 | eval("\$onlinemembers .= \"{$templates->get('asb_whosonline_memberbit_see_all', 1, 0)}\";"); 271 | } 272 | // ...otherwise, add it to the list 273 | } else { 274 | eval("\$onlinemembers .= \"{$templates->get('asb_whosonline_memberbit_avatar', 1, 0)}\";"); 275 | 276 | // If we reach the end of the row, insert a
    277 | if (($membercount - (($row - 1) * $rowlength)) == $rowlength) { 278 | $onlinemembers .= ''; 279 | ++$row; 280 | } 281 | ++$avatar_count; 282 | } 283 | } else { 284 | $user['username'] = format_name(trim($user['username']), $user['usergroup'], $user['displaygroup']); 285 | eval("\$onlinemembers .= \"{$templates->get('asb_whosonline_memberbit_name', 1, 0)}\";"); 286 | $sep = $lang->comma.' '; 287 | } 288 | } else { 289 | --$membercount; 290 | } 291 | } 292 | } 293 | 294 | if (!$settings['show_avatars']) { 295 | $onlinemembers = ''.$onlinemembers.''; 296 | } 297 | $onlinecount = $membercount + $guestcount + $botcount; 298 | 299 | // If we can see invisible users add them to the count 300 | if ($mybb->usergroup['canviewwolinvis'] == 1) { 301 | $onlinecount += $anoncount; 302 | } 303 | 304 | // If we can't see invisible users but the user is an invisible user increment the count by one 305 | if ($mybb->usergroup['canviewwolinvis'] != 1 && 306 | $mybb->user['invisible'] == 1) { 307 | ++$onlinecount; 308 | } 309 | 310 | // Most users online 311 | $mostonline = $cache->read('mostonline'); 312 | if ($onlinecount > $mostonline['numusers']) { 313 | $time = TIME_NOW; 314 | $mostonline['numusers'] = $onlinecount; 315 | $mostonline['time'] = $time; 316 | $cache->update('mostonline', $mostonline); 317 | } 318 | $recordcount = $mostonline['numusers']; 319 | $recorddate = my_date($mybb->settings['dateformat'], $mostonline['time']); 320 | $recordtime = my_date($mybb->settings['timeformat'], $mostonline['time']); 321 | 322 | if ($onlinecount == 1) { 323 | $lang->asb_wol_online_users = $lang->asb_wol_online_user; 324 | } else { 325 | $lang->asb_wol_online_users = $lang->sprintf($lang->asb_wol_online_users, $onlinecount); 326 | } 327 | $lang->asb_wol_online_counts = $lang->sprintf($lang->asb_wol_online_counts, $membercount, $guestcount); 328 | 329 | if ($membercount) { 330 | eval("\$onlinemembers = \"{$templates->get('asb_whosonline')}\";"); 331 | return $onlinemembers; 332 | } else { 333 | return false; 334 | } 335 | } 336 | 337 | /** 338 | * insert peeker for creation date 339 | * 340 | * @return void 341 | */ 342 | function asb_whosonline_settings_load() 343 | { 344 | echo << 347 | new Peeker($(".setting_show_avatars"), $("#row_setting_asb_avatar_per_row, #row_setting_asb_avatar_max_rows, #row_setting_asb_avatar_maintain_aspect"), /1/, true); 348 | 349 | EOF; 350 | } 351 | 352 | ?> 353 | -------------------------------------------------------------------------------- /Upload/inc/plugins/asb/upgrade.php: -------------------------------------------------------------------------------- 1 | asb) { 12 | $lang->load('asb'); 13 | } 14 | 15 | AdvancedSideboxInstaller::getInstance()->install(); 16 | 17 | $removedAdminFolders = $removedForumFolders = $removedAdminFiles = $removedForumFiles = array(); 18 | 19 | /* < 2.1 */ 20 | if (version_compare($asbOldVersion, '2.1', '<')) { 21 | $sideboxes = asbGetAllSideBoxes(); 22 | foreach ($sideboxes as $sidebox) { 23 | $settings = array(); 24 | foreach ((array) $sidebox->get('settings') as $name => $setting) { 25 | $settings[$name] = $setting['value']; 26 | } 27 | $sidebox->set('settings', $settings); 28 | $sidebox->save(); 29 | } 30 | 31 | for ($x = 1; $x < 4; $x++) { 32 | $moduleName = 'example'; 33 | if ($x != 1) { 34 | $moduleName .= $x; 35 | } 36 | 37 | $module = new SideboxExternalModule($moduleName); 38 | $module->remove(); 39 | } 40 | 41 | asbCacheHasChanged(); 42 | 43 | $removedForumFiles = array( 44 | 'jscripts/asb.js', 45 | 'jscripts/asb_xmlhttp.js', 46 | ); 47 | 48 | $removedAdminFiles = array( 49 | 'jscripts/asb.js', 50 | 'jscripts/asb_modal.js', 51 | 'jscripts/asb_scripts.js', 52 | 'jscripts/asb_sideboxes.js', 53 | ); 54 | } 55 | 56 | /* < 3.1 */ 57 | if (version_compare($asbOldVersion, '3.1', '<')) { 58 | $removedForumFiles = array_merge($removedForumFiles, array( 59 | 'inc/plugins/asb/classes/installer.php', 60 | 'inc/plugins/asb/classes/malleable.php', 61 | 'inc/plugins/asb/classes/portable.php', 62 | 'inc/plugins/asb/classes/storable.php', 63 | 'inc/plugins/asb/classes/sidebox.php', 64 | 'inc/plugins/asb/classes/custom.php', 65 | 'inc/plugins/asb/classes/module.php', 66 | 'inc/plugins/asb/classes/html_generator.php', 67 | 'inc/plugins/asb/classes/script_info.php', 68 | 'inc/plugins/asb/classes/template_handler.php', 69 | )); 70 | 71 | $removedForumFolders[] = 'inc/plugins/asb/images'; 72 | } 73 | 74 | /* < 3.1.1 */ 75 | if (version_compare($asbOldVersion, '3.1.1', '<')) { 76 | $removedAdminFiles[] = 'styles/asb_acp.css'; 77 | 78 | } 79 | 80 | /* < 3.1.2 */ 81 | if (version_compare($asbOldVersion, '3.1.2', '<')) { 82 | $removedForumFolders[] = 'inc/plugins/asb/help'; 83 | $removedAdminFiles = array_merge($removedAdminFiles, array( 84 | 'jscripts/asb/asb.js', 85 | 'jscripts/asb/asb.min.js', 86 | )); 87 | } 88 | 89 | /* < 3.1.4 */ 90 | if (version_compare($asbOldVersion, '3.1.4', '<')) { 91 | $db->modify_column('asb_sideboxes', 'title', 'TEXT'); 92 | } 93 | 94 | /* < 3.1.5 */ 95 | if (version_compare($asbOldVersion, '3.1.5', '<')) { 96 | $removedForumFiles = array_merge($removedForumFiles, array( 97 | 'inc/plugins/asb/classes/acp.php', 98 | 'inc/plugins/asb/classes/forum.php', 99 | 'inc/plugins/asb/classes/xmlhttp.php', 100 | )); 101 | } 102 | 103 | /* < 3.1.7 */ 104 | if (version_compare($asbOldVersion, '3.1.7', '<')) { 105 | $removedForumFiles = array_merge($removedForumFiles, array( 106 | 'inc/plugins/asb/classes/ExternalModule.php', 107 | 'inc/plugins/asb/classes/HTMLGenerator.php', 108 | 'inc/plugins/asb/classes/MalleableObject.php', 109 | 'inc/plugins/asb/classes/StorableObject.php', 110 | 'inc/plugins/asb/classes/PortableObject.php', 111 | 'inc/plugins/asb/classes/WildcardPluginInstaller.php', 112 | 'inc/plugins/asb/functions_install.php', 113 | )); 114 | } 115 | 116 | /* < 3.1.12 */ 117 | if (version_compare($asbOldVersion, '3.1.12', '<')) { 118 | $removedForumFiles = array_merge($removedForumFiles, array( 119 | 'inc/plugins/asb/classes/WildcardPluginInstaller010202.php', 120 | 'inc/plugins/asb/classes/PortableObject010000.php', 121 | )); 122 | } 123 | 124 | /* < 3.1.13 */ 125 | if (version_compare($asbOldVersion, '3.1.13', '<')) { 126 | $removedForumFiles[] = 'inc/plugins/asb/classes/WildcardPluginInstaller010302.php'; 127 | } 128 | 129 | if (!empty($removedForumFiles)) { 130 | foreach ($removedForumFiles as $file) { 131 | @unlink(MYBB_ROOT.$file); 132 | } 133 | } 134 | 135 | if (!empty($removedForumFolders)) { 136 | foreach ($removedForumFolders as $folder) { 137 | @my_rmdir_recursive(MYBB_ROOT.$folder); 138 | @rmdir(MYBB_ROOT.$folder); 139 | } 140 | } 141 | 142 | if (!empty($removedAdminFiles)) { 143 | foreach ($removedAdminFiles as $file) { 144 | @unlink(MYBB_ADMIN_DIR.$file); 145 | } 146 | } 147 | 148 | if (!empty($removedAdminFolders)) { 149 | foreach ($removedAdminFolders as $folder) { 150 | @my_rmdir_recursive(MYBB_ADMIN_DIR.$folder); 151 | @rmdir(MYBB_ADMIN_DIR.$folder); 152 | } 153 | } 154 | 155 | ?> 156 | -------------------------------------------------------------------------------- /Upload/jscripts/asb/Slideshow.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Plugin Name: Advanced Sidebox for MyBB 1.8.x 3 | * Copyright 2014 WildcardSearch 4 | * http://www.rantcentralforums.com 5 | * 6 | * this file contains a module for the Slideshow box addon as well as 7 | * some helpers (Timers/Effects) 8 | */ 9 | 10 | var ASB = (function(a, $) { 11 | /** 12 | * constructor for slideshow objects-- commandeers an element and cycles 13 | * through a defined set of images using configurable options 14 | * 15 | * @param String the id of the containing
    16 | * @param Object settings for the object 17 | * @return void 18 | */ 19 | function Slideshow(container, options) { 20 | if (!$("#" + container).length) { 21 | return; 22 | } 23 | 24 | this.options = { 25 | rate: 10, 26 | shuffle: false, 27 | fadeRate: 400, 28 | size: 100, 29 | maxWidth: 0, 30 | maxHeight: 0, 31 | maintainHeight: 1, 32 | }; 33 | $.extend(this.options, options || {}); 34 | 35 | this.startHeight = this.options.size; 36 | if (this.options.maxHeight > 0 && 37 | this.options.maintainHeight) { 38 | this.startHeight = this.options.maxHeight; 39 | } 40 | 41 | // set up the container 42 | this.container = $("#" + container); 43 | this.container.css({ 44 | width: this.options.size + "px", 45 | height: this.startHeight + "px", 46 | marginLeft: "auto", 47 | marginRight: "auto", 48 | position: "relative", 49 | }); 50 | 51 | // no images, no have slide show 52 | if (typeof this.options.images === "undefined" || 53 | this.options.images.length == 0) { 54 | return; 55 | } 56 | 57 | this.current = 0; 58 | if (this.options.shuffle) { 59 | this.options.images.sort(function() { 60 | return 0.5 - Math.random(); 61 | }); 62 | } 63 | 64 | // create the main image holder, set it up and insert it into the container 65 | this.mainImage = $("", { 66 | src: this.getCurrentImage(), 67 | }).css({ 68 | display: "none", 69 | position: "absolute", 70 | left: "0px", 71 | top: "0px", 72 | }); 73 | this.container.append(this.mainImage); 74 | 75 | // clone the main image, store it as a buffer and insert it into the container 76 | this.bufferImage = this.mainImage.clone(); 77 | this.container.append(this.bufferImage); 78 | 79 | this.cloneWidth = this.cloneHeight = 0; 80 | 81 | /** 82 | * get things going and begin cycling when the page loads 83 | * and end when the user leaves 84 | */ 85 | this.showCurrent(); 86 | $($.proxy(this.run, this)); 87 | $(window).on("unload", $.proxy(this.stop, this)); 88 | } 89 | 90 | /** 91 | * ready the slideshow to go another round 92 | * 93 | * @return void 94 | */ 95 | function run() { 96 | this.timeOutId = setTimeout($.proxy(this.showNext, this), this.options.rate * 1000); 97 | } 98 | 99 | /** 100 | * end the slideshow 101 | * 102 | * @return void 103 | */ 104 | function stop() { 105 | clearTimeout(this.timeOutId); 106 | } 107 | 108 | /** 109 | * build the image file name 110 | * 111 | * @return string 112 | */ 113 | function getCurrentImage() { 114 | return this.options.folder ? 115 | this.options.folder + "/" + this.options.images[this.current] : 116 | this.options.images[this.current]; 117 | } 118 | 119 | /** 120 | * do the buffer swap and cycle to the next image 121 | * 122 | * @return void 123 | */ 124 | function nextImage() { 125 | this.bufferImage.prop("title", this.mainImage.prop("title")); 126 | this.bufferImage.prop("alt", this.mainImage.prop("alt")); 127 | this.bufferImage.prop("src", this.mainImage.prop("src")); 128 | this.resizeImage(this.bufferImage).show(); 129 | this.mainImage.hide(); 130 | 131 | this.current++; 132 | if (this.options.images.length <= this.current) { 133 | this.current = 0; 134 | } 135 | } 136 | 137 | /** 138 | * load the current image and perform the transition 139 | * 140 | * @return void 141 | */ 142 | function showCurrent() { 143 | this.mainImage.prop("title", this.options.images[this.current]); 144 | this.mainImage.prop("alt", this.options.images[this.current]); 145 | this.mainImage.prop("src", this.getCurrentImage()); 146 | 147 | /* 148 | * clone the main image and display it off-screen in order to 149 | * get the correct size 150 | */ 151 | this.clone = $("", { 152 | src: this.mainImage.prop("src"), 153 | }).css({ 154 | position: "absolute", 155 | display: "block", 156 | }); 157 | $("body").append(this.clone); 158 | 159 | this.clone.on("load", $.proxy(this.resize, this)).each(function() { 160 | if (this.complete) { 161 | $(this).load(); 162 | } 163 | }); 164 | 165 | // fade in the new image 166 | $(this.mainImage).fadeIn(this.options.fadeRate); 167 | 168 | // if we have already initialized, fade out the old image 169 | if (this.running) { 170 | $(this.bufferImage).fadeOut(this.options.fadeRate); 171 | } 172 | this.running = true; 173 | } 174 | 175 | /** 176 | * when the clone loads, get its dimensions and use them to resize the 177 | * main image 178 | * 179 | * @return - void 180 | */ 181 | function resize(e) { 182 | var height = this.clone.height(), 183 | width = this.clone.width(), 184 | ratio; 185 | 186 | // maintain the ratio and resize if necessary 187 | if (height > width) { 188 | ratio = height / width; 189 | 190 | this.cloneWidth = parseInt(this.options.size / ratio); 191 | this.cloneHeight = this.options.size; 192 | 193 | if (this.options.maxWidth > 0 && 194 | this.cloneWidth > this.options.maxWidth) { 195 | this.cloneWidth = this.options.maxWidth; 196 | this.cloneHeight = parseInt(this.options.maxWidth * ratio); 197 | } 198 | 199 | if (this.options.maxHeight > 0 && 200 | this.cloneHeight > this.options.maxHeight) { 201 | this.cloneWidth = parseInt(this.options.maxHeight / ratio); 202 | this.cloneHeight = this.options.maxHeight; 203 | } 204 | } else if (width > height) { 205 | ratio = width / height; 206 | 207 | this.cloneWidth = this.options.size; 208 | this.cloneHeight = parseInt(this.options.size / ratio); 209 | 210 | if (this.options.maxWidth > 0 && 211 | this.cloneWidth > this.options.maxWidth) { 212 | this.cloneWidth = this.options.maxWidth; 213 | this.cloneHeight = parseInt(this.options.maxWidth / ratio); 214 | } 215 | 216 | if (this.options.maxHeight > 0 && 217 | this.cloneHeight > this.options.maxHeight) { 218 | this.cloneWidth = parseInt(this.options.maxHeight * ratio); 219 | this.cloneHeight = this.options.maxHeight; 220 | } 221 | } else { 222 | this.cloneHeight = this.cloneWidth = this.options.size; 223 | 224 | if (this.options.maxWidth > 0 && 225 | this.cloneWidth > this.options.maxWidth) { 226 | this.cloneHeight = this.cloneWidth = this.options.maxWidth; 227 | } 228 | 229 | if (this.options.maxHeight > 0 && 230 | this.cloneHeight > this.options.maxHeight) { 231 | this.cloneWidth = this.cloneHeight = this.options.maxHeight; 232 | } 233 | } 234 | 235 | this.clone.remove(); 236 | this.resizeImage(this.mainImage); 237 | } 238 | 239 | /** 240 | * apply the stored dimensions to a given element 241 | * 242 | * @param Object the DOM Element Object 243 | * @return Object the DOM Element Object 244 | */ 245 | function resizeImage(el) { 246 | style = { 247 | height: this.cloneHeight + "px", 248 | width: this.cloneWidth + "px", 249 | left: parseInt((this.options.size / 2) - (this.cloneWidth / 2)) + "px", 250 | top: parseInt((this.startHeight / 2) - (this.cloneHeight / 2)) + "px", 251 | }; 252 | 253 | if (!this.options.maintainHeight) { 254 | this.container.css("height", this.cloneHeight + "px"); 255 | style.top = "0px"; 256 | } 257 | 258 | el.css(style); 259 | 260 | return el; 261 | } 262 | 263 | /** 264 | * called cyclically to advance to the next image and restart the timer 265 | * 266 | * @param Object the DOM Element Object 267 | * @return Object the DOM Element Object 268 | */ 269 | function showNext() { 270 | if (this.container.width() > 0) { 271 | this.nextImage(); 272 | this.showCurrent(); 273 | } 274 | this.run(); 275 | } 276 | 277 | Slideshow.prototype = { 278 | run: run, 279 | stop: stop, 280 | showCurrent: showCurrent, 281 | getCurrentImage: getCurrentImage, 282 | nextImage: nextImage, 283 | showNext: showNext, 284 | resize: resize, 285 | resizeImage: resizeImage, 286 | }; 287 | 288 | a.modules = $.extend({ 289 | Slideshow: Slideshow, 290 | }, a.modules || {}); 291 | 292 | return a; 293 | })(ASB || {}, jQuery); 294 | -------------------------------------------------------------------------------- /Upload/jscripts/asb/Slideshow.min.js: -------------------------------------------------------------------------------- 1 | var ASB=(function(l,h){function d(a,m){if(!h("#"+a).length){return}this.options={rate:10,shuffle:false,fadeRate:400,size:100,maxWidth:0,maxHeight:0,maintainHeight:1};h.extend(this.options,m||{});this.startHeight=this.options.size;if(this.options.maxHeight>0&&this.options.maintainHeight){this.startHeight=this.options.maxHeight}this.container=h("#"+a);this.container.css({width:this.options.size+"px",height:this.startHeight+"px",marginLeft:"auto",marginRight:"auto",position:"relative"});if(typeof this.options.images==="undefined"||this.options.images.length==0){return}this.current=0;if(this.options.shuffle){this.options.images.sort(function(){return 0.5-Math.random()})}this.mainImage=h("",{src:this.getCurrentImage()}).css({display:"none",position:"absolute",left:"0px",top:"0px"});this.container.append(this.mainImage);this.bufferImage=this.mainImage.clone();this.container.append(this.bufferImage);this.cloneWidth=this.cloneHeight=0;this.showCurrent();h(h.proxy(this.run,this));h(window).on("unload",h.proxy(this.stop,this))}function g(){this.timeOutId=setTimeout(h.proxy(this.showNext,this),this.options.rate*1000)}function j(){clearTimeout(this.timeOutId)}function b(){return this.options.folder?this.options.folder+"/"+this.options.images[this.current]:this.options.images[this.current]}function f(){this.bufferImage.prop("title",this.mainImage.prop("title"));this.bufferImage.prop("alt",this.mainImage.prop("alt"));this.bufferImage.prop("src",this.mainImage.prop("src"));this.resizeImage(this.bufferImage).show();this.mainImage.hide();this.current++;if(this.options.images.length<=this.current){this.current=0}}function i(){this.mainImage.prop("title",this.options.images[this.current]);this.mainImage.prop("alt",this.options.images[this.current]);this.mainImage.prop("src",this.getCurrentImage());this.clone=h("",{src:this.mainImage.prop("src")}).css({position:"absolute",display:"block"});h("body").append(this.clone);this.clone.on("load",h.proxy(this.resize,this)).each(function(){if(this.complete){h(this).load()}});h(this.mainImage).fadeIn(this.options.fadeRate);if(this.running){h(this.bufferImage).fadeOut(this.options.fadeRate)}this.running=true}function c(o){var a=this.clone.height(),n=this.clone.width(),m;if(a>n){m=a/n;this.cloneWidth=parseInt(this.options.size/m);this.cloneHeight=this.options.size;if(this.options.maxWidth>0&&this.cloneWidth>this.options.maxWidth){this.cloneWidth=this.options.maxWidth;this.cloneHeight=parseInt(this.options.maxWidth*m)}if(this.options.maxHeight>0&&this.cloneHeight>this.options.maxHeight){this.cloneWidth=parseInt(this.options.maxHeight/m);this.cloneHeight=this.options.maxHeight}}else{if(n>a){m=n/a;this.cloneWidth=this.options.size;this.cloneHeight=parseInt(this.options.size/m);if(this.options.maxWidth>0&&this.cloneWidth>this.options.maxWidth){this.cloneWidth=this.options.maxWidth;this.cloneHeight=parseInt(this.options.maxWidth/m)}if(this.options.maxHeight>0&&this.cloneHeight>this.options.maxHeight){this.cloneWidth=parseInt(this.options.maxHeight*m);this.cloneHeight=this.options.maxHeight}}else{this.cloneHeight=this.cloneWidth=this.options.size;if(this.options.maxWidth>0&&this.cloneWidth>this.options.maxWidth){this.cloneHeight=this.cloneWidth=this.options.maxWidth}if(this.options.maxHeight>0&&this.cloneHeight>this.options.maxHeight){this.cloneWidth=this.cloneHeight=this.options.maxHeight}}}this.clone.remove();this.resizeImage(this.mainImage)}function k(a){style={height:this.cloneHeight+"px",width:this.cloneWidth+"px",left:parseInt((this.options.size/2)-(this.cloneWidth/2))+"px",top:parseInt((this.startHeight/2)-(this.cloneHeight/2))+"px"};if(!this.options.maintainHeight){this.container.css("height",this.cloneHeight+"px");style.top="0px"}a.css(style);return a}function e(){if(this.container.width()>0){this.nextImage();this.showCurrent()}this.run()}d.prototype={run:g,stop:j,showCurrent:i,getCurrentImage:b,nextImage:f,showNext:e,resize:c,resizeImage:k};l.modules=h.extend({Slideshow:d},l.modules||{});return l})(ASB||{},jQuery); -------------------------------------------------------------------------------- /Upload/jscripts/asb/asb.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Plugin Name: Advanced Sidebox for MyBB 1.8.x 3 | * Copyright 2014 WildcardSearch 4 | * http://www.rantcentralforums.com 5 | * 6 | * this file contains handlers for the side box toggle icon scripts 7 | */ 8 | 9 | !function($) { 10 | /** 11 | * observe the toggle icons links 12 | * 13 | * @return void 14 | */ 15 | function init() { 16 | if ($("#asb_hide_column_left")) { 17 | // left show/hide icon click 18 | $("#asb_hide_column_left").click(toggle); 19 | } 20 | 21 | if ($("#asb_hide_column_right")) { 22 | // left show/hide icon click 23 | $("#asb_hide_column_right").click(toggle); 24 | } 25 | } 26 | 27 | /** 28 | * toggle the side box column controlled by the clicked icon and 29 | * use cookies to preserve settings 30 | * 31 | * @param Event the click event object 32 | * @return void 33 | */ 34 | function toggle(event) { 35 | // the link does nothing if JS is deactivated and until the page has fully loaded 36 | event.preventDefault(); 37 | 38 | var position = "left"; 39 | if (this.id == "asb_hide_column_right") { 40 | position = "right"; 41 | } 42 | 43 | var cookieName = "asb_hide_" + position, 44 | column = $("#asb_" + position + "_column_id"), 45 | closeIcon = $("#asb_" + position + "_close"), 46 | openIcon = $("#asb_" + position + "_open"); 47 | 48 | // get the cookie 49 | var hide = Cookie.get(cookieName); 50 | 51 | // if it isn't set or its zero then we are hiding 52 | if (hide == 0 || 53 | typeof hide == "undefined") { 54 | column.hide(); 55 | closeIcon.hide(); 56 | openIcon.show(); 57 | Cookie.set(cookieName, 1); 58 | } else { 59 | // otherwise we are showing 60 | column.show(); 61 | closeIcon.show(); 62 | openIcon.hide(); 63 | Cookie.unset(cookieName); 64 | } 65 | } 66 | $(init); 67 | }(jQuery); 68 | -------------------------------------------------------------------------------- /Upload/jscripts/asb/asb.min.js: -------------------------------------------------------------------------------- 1 | !function(b){function c(){if(b("#asb_hide_column_left")){b("#asb_hide_column_left").click(a)}if(b("#asb_hide_column_right")){b("#asb_hide_column_right").click(a)}}function a(h){h.preventDefault();var d="left";if(this.id=="asb_hide_column_right"){d="right"}var j="asb_hide_"+d,g=b("#asb_"+d+"_column_id"),i=b("#asb_"+d+"_close"),e=b("#asb_"+d+"_open");var f=Cookie.get(j);if(f==0||typeof f=="undefined"){g.hide();i.hide();e.show();Cookie.set(j,1)}else{g.show();i.show();e.hide();Cookie.unset(j)}}b(c)}(jQuery); -------------------------------------------------------------------------------- /Upload/jscripts/asb/asb_xmlhttp.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Plugin Name: Advanced Sidebox for MyBB 1.8.x 3 | * Copyright 2014 WildcardSearch 4 | * http://www.rantcentralforums.com 5 | * 6 | * this file contains a custom class for the AJAX refresh functionality for 7 | * side box modules and a function to create objects for all the add-on modules 8 | * represented on the forum 9 | */ 10 | 11 | var ASB = (function(a, $) { 12 | /** 13 | * constructor: sets up the object and starts the timer 14 | * 15 | * @param string container id 16 | * @param string url 17 | * @param object options 18 | * @return void 19 | */ 20 | function SideboxUpdater(container, url, options) { 21 | this.options = $.extend({}, options || {}); 22 | 23 | // now get this instance's overrides and options 24 | this.frequency = (this.options.frequency || 30); 25 | this.decay = this.options.decay = (this.options.decay || 1); 26 | this.container = $("#" + container).children("tbody"); 27 | this.options.url = url; 28 | this.options.complete = $.proxy(this.updateComplete, this); 29 | 30 | // if the server is on a different timezone, get the offset in seconds 31 | this.phpTimeDiff = Math.floor(this.options.data.dateline - (new Date().getTime() / 1000)); 32 | 33 | // initiate the timer 34 | this.start(); 35 | } 36 | 37 | /** 38 | * initiate the timer 39 | * 40 | * @return void 41 | */ 42 | function start() { 43 | this.timer = setTimeout($.proxy(this.onTimerEvent, this), (this.decay * this.frequency) * 1000); 44 | } 45 | 46 | /** 47 | * halt the timer 48 | * 49 | * @return void 50 | */ 51 | function stop() { 52 | clearTimeout(this.timer); 53 | } 54 | 55 | /** 56 | * check the XMLHTTP response and update the side box if there are changes 57 | * 58 | * @param Response 59 | * @return void 60 | */ 61 | function updateComplete(response) { 62 | // good response? 63 | if (response.responseText && 64 | response.responseText != "nochange") { 65 | // might add this option later 66 | this.decay = this.options.decay; 67 | 68 | // update the side box's 69 | this.container.html(response.responseText); 70 | 71 | } else { 72 | // currently does nothing, but left in to add this option 73 | this.decay = this.decay * this.options.decay; 74 | } 75 | 76 | // last update time 77 | this.options.data.dateline = Math.floor(new Date().getTime() / 1000 + this.phpTimeDiff); 78 | 79 | // key up to do it again 80 | this.timer = setTimeout($.proxy(this.onTimerEvent, this), (this.decay * this.frequency) * 1000); 81 | } 82 | 83 | /** 84 | * send an AJAX request unless the side box is collapsed 85 | * 86 | * @return void 87 | */ 88 | function onTimerEvent() { 89 | // don't update collapsed side boxes (thanks again, Destroy666) 90 | if (this.container.width() <= 0 && 91 | this.container.height() <= 0) { 92 | // just reset the timer and get out 93 | this.timer = setTimeout($.proxy(this.onTimerEvent, this), (this.decay * this.frequency) * 1000); 94 | return; 95 | } 96 | 97 | // and finally, this is what we are doing every {rate} seconds 98 | $.ajax(this.options); 99 | } 100 | 101 | SideboxUpdater.prototype = { 102 | start: start, 103 | stop: stop, 104 | updateComplete: updateComplete, 105 | onTimerEvent: onTimerEvent, 106 | }; 107 | 108 | /** 109 | * prepare the Updater objects 110 | * 111 | * @param array options 112 | * @param object widths for both positions 113 | * @return void 114 | */ 115 | function buildUpdaters(updaters, widths, script) { 116 | // no objects in the array 117 | if (updaters.length == 0) { 118 | // get out 119 | return; 120 | } 121 | 122 | var this_id = "", width = 0; 123 | for (var i = 0; i < updaters.length; i++) { 124 | // build the element ID 125 | this_id = updaters[i].addon + "_main_" + updaters[i].id; 126 | 127 | if (!$("#" + this_id)) { 128 | continue; 129 | } 130 | 131 | // get the correct width 132 | width = widths.left; 133 | if (updaters[i].position) { 134 | width = widths.right; 135 | } 136 | 137 | // this object will only update when a valid response is received 138 | new SideboxUpdater(this_id, "xmlhttp.php", { 139 | type: "get", 140 | data: { 141 | action: "asb", 142 | id: updaters[i].id, 143 | addon: updaters[i].addon, 144 | dateline: updaters[i].dateline, 145 | width: width, 146 | script: script, 147 | }, 148 | frequency: updaters[i].rate 149 | }); 150 | } 151 | } 152 | 153 | a.ajax = { 154 | buildUpdaters: buildUpdaters, 155 | }; 156 | 157 | return a; 158 | })(ASB || {}, jQuery); 159 | -------------------------------------------------------------------------------- /Upload/jscripts/asb/asb_xmlhttp.min.js: -------------------------------------------------------------------------------- 1 | var ASB=(function(c,f){function e(a,k,j){this.options=f.extend({},j||{});this.frequency=(this.options.frequency||30);this.decay=this.options.decay=(this.options.decay||1);this.container=f("#"+a).children("tbody");this.options.url=k;this.options.complete=f.proxy(this.updateComplete,this);this.phpTimeDiff=Math.floor(this.options.data.dateline-(new Date().getTime()/1000));this.start()}function i(){this.timer=setTimeout(f.proxy(this.onTimerEvent,this),(this.decay*this.frequency)*1000)}function d(){clearTimeout(this.timer)}function h(a){if(a.responseText&&a.responseText!="nochange"){this.decay=this.options.decay;this.container.html(a.responseText)}else{this.decay=this.decay*this.options.decay}this.options.data.dateline=Math.floor(new Date().getTime()/1000+this.phpTimeDiff);this.timer=setTimeout(f.proxy(this.onTimerEvent,this),(this.decay*this.frequency)*1000)}function g(){if(this.container.width()<=0&&this.container.height()<=0){this.timer=setTimeout(f.proxy(this.onTimerEvent,this),(this.decay*this.frequency)*1000);return}f.ajax(this.options)}e.prototype={start:i,stop:d,updateComplete:h,onTimerEvent:g};function b(m,l,a){if(m.length==0){return}var n="",k=0;for(var j=0;j