From ff722906b7f8503bc1bbf0bf3a81f7658d66921f Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Sat, 19 Apr 2014 23:06:48 -0400 Subject: [PATCH 01/66] Holy shit, this is really really nasty old JS code. I would love to dump this if possible. --- themes/lite/wz_tooltip.js | 576 ++++++++++++++++++++++---------------- 1 file changed, 338 insertions(+), 238 deletions(-) diff --git a/themes/lite/wz_tooltip.js b/themes/lite/wz_tooltip.js index 01f55f2d..2ffa50fe 100644 --- a/themes/lite/wz_tooltip.js +++ b/themes/lite/wz_tooltip.js @@ -1,7 +1,14 @@ +/*jshint bitwise:false, curly:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:false, strict:false, browser:true */ +/* + This is rather old JS code that is quite problematic (use of global namespace) and + is also likely full of bugs. I would really like to remove this from the Shimmie + imageboard if possible. + - jgen +*/ /* This notice must be untouched at all times. Copyright (c) 2002-2008 Walter Zorn. All rights reserved. -wz_tooltip.js v. 5.31 +wz_tooltip.js v. 5.31 The latest version is available at http://www.walterzorn.com @@ -40,13 +47,13 @@ For more details on the GNU Lesser General Public License, see http://www.gnu.org/copyleft/lesser.html */ -var config = new Object(); +var config = {}; // new Object(); //=================== GLOBAL TOOLTIP CONFIGURATION =========================// -var tt_Debug = true // false or true - recommended: false once you release your page to the public -var tt_Enabled = true // Allows to (temporarily) suppress tooltips, e.g. by providing the user with a button that sets this global variable to false -var TagsToTip = true // false or true - if true, HTML elements to be converted to tooltips via TagToTip() are automatically hidden; +var tt_Debug = true; // false or true - recommended: false once you release your page to the public +var tt_Enabled = true; // Allows to (temporarily) suppress tooltips, e.g. by providing the user with a button that sets this global variable to false +var TagsToTip = true; // false or true - if true, HTML elements to be converted to tooltips via TagToTip() are automatically hidden; // if false, you should hide those HTML elements yourself // For each of the following config variables there exists a command, which is @@ -55,52 +62,52 @@ var TagsToTip = true // false or true - if true, HTML elements to be converted // configuration. Order of commands is arbitrary. // Example: onmouseover="Tip('Tooltip text', LEFT, true, BGCOLOR, '#FF9900', FADEIN, 400)" -config. Above = false // false or true - tooltip above mousepointer -config. BgColor = '#E2E7FF' // Background colour (HTML colour value, in quotes) -config. BgImg = '' // Path to background image, none if empty string '' -config. BorderColor = '#003099' -config. BorderStyle = 'solid' // Any permitted CSS value, but I recommend 'solid', 'dotted' or 'dashed' -config. BorderWidth = 1 -config. CenterMouse = false // false or true - center the tip horizontally below (or above) the mousepointer -config. ClickClose = false // false or true - close tooltip if the user clicks somewhere -config. ClickSticky = false // false or true - make tooltip sticky if user left-clicks on the hovered element while the tooltip is active -config. CloseBtn = false // false or true - closebutton in titlebar -config. CloseBtnColors = ['#990000', '#FFFFFF', '#DD3333', '#FFFFFF'] // [Background, text, hovered background, hovered text] - use empty strings '' to inherit title colours -config. CloseBtnText = ' X ' // Close button text (may also be an image tag) -config. CopyContent = true // When converting a HTML element to a tooltip, copy only the element's content, rather than converting the element by its own -config. Delay = 400 // Time span in ms until tooltip shows up -config. Duration = 0 // Time span in ms after which the tooltip disappears; 0 for infinite duration, < 0 for delay in ms _after_ the onmouseout until the tooltip disappears -config. Exclusive = false // false or true - no other tooltip can appear until the current one has actively been closed -config. FadeIn = 100 // Fade-in duration in ms, e.g. 400; 0 for no animation -config. FadeOut = 100 -config. FadeInterval = 30 // Duration of each fade step in ms (recommended: 30) - shorter is smoother but causes more CPU-load -config. Fix = null // Fixated position, two modes. Mode 1: x- an y-coordinates in brackets, e.g. [210, 480]. Mode 2: Show tooltip at a position related to an HTML element: [ID of HTML element, x-offset, y-offset from HTML element], e.g. ['SomeID', 10, 30]. Value null (default) for no fixated positioning. -config. FollowMouse = true // false or true - tooltip follows the mouse -config. FontColor = '#000044' -config. FontFace = 'Verdana,Geneva,sans-serif' -config. FontSize = '8pt' // E.g. '9pt' or '12px' - unit is mandatory -config. FontWeight = 'normal' // 'normal' or 'bold'; -config. Height = 0 // Tooltip height; 0 for automatic adaption to tooltip content, < 0 (e.g. -100) for a maximum for automatic adaption -config. JumpHorz = false // false or true - jump horizontally to other side of mouse if tooltip would extend past clientarea boundary -config. JumpVert = true // false or true - jump vertically " -config. Left = false // false or true - tooltip on the left of the mouse -config. OffsetX = 14 // Horizontal offset of left-top corner from mousepointer -config. OffsetY = 8 // Vertical offset -config. Opacity = 100 // Integer between 0 and 100 - opacity of tooltip in percent -config. Padding = 3 // Spacing between border and content -config. Shadow = false // false or true -config. ShadowColor = '#C0C0C0' -config. ShadowWidth = 5 -config. Sticky = false // false or true - fixate tip, ie. don't follow the mouse and don't hide on mouseout -config. TextAlign = 'left' // 'left', 'right' or 'justify' -config. Title = '' // Default title text applied to all tips (no default title: empty string '') -config. TitleAlign = 'left' // 'left' or 'right' - text alignment inside the title bar -config. TitleBgColor = '' // If empty string '', BorderColor will be used -config. TitleFontColor = '#FFFFFF' // Color of title text - if '', BgColor (of tooltip body) will be used -config. TitleFontFace = '' // If '' use FontFace (boldified) -config. TitleFontSize = '' // If '' use FontSize -config. TitlePadding = 2 -config. Width = 0 // Tooltip width; 0 for automatic adaption to tooltip content; < -1 (e.g. -240) for a maximum width for that automatic adaption; +config. Above = false; // false or true - tooltip above mousepointer +config. BgColor = '#E2E7FF'; // Background colour (HTML colour value, in quotes) +config. BgImg = ''; // Path to background image, none if empty string '' +config. BorderColor = '#003099'; +config. BorderStyle = 'solid'; // Any permitted CSS value, but I recommend 'solid', 'dotted' or 'dashed' +config. BorderWidth = 1; +config. CenterMouse = false; // false or true - center the tip horizontally below (or above) the mousepointer +config. ClickClose = false; // false or true - close tooltip if the user clicks somewhere +config. ClickSticky = false; // false or true - make tooltip sticky if user left-clicks on the hovered element while the tooltip is active +config. CloseBtn = false; // false or true - closebutton in titlebar +config. CloseBtnColors = ['#990000', '#FFFFFF', '#DD3333', '#FFFFFF']; // [Background, text, hovered background, hovered text] - use empty strings '' to inherit title colours +config. CloseBtnText = ' X '; // Close button text (may also be an image tag) +config. CopyContent = true; // When converting a HTML element to a tooltip, copy only the element's content, rather than converting the element by its own +config. Delay = 400; // Time span in ms until tooltip shows up +config. Duration = 0; // Time span in ms after which the tooltip disappears; 0 for infinite duration, < 0 for delay in ms _after_ the onmouseout until the tooltip disappears +config. Exclusive = false; // false or true - no other tooltip can appear until the current one has actively been closed +config. FadeIn = 100; // Fade-in duration in ms, e.g. 400; 0 for no animation +config. FadeOut = 100; +config. FadeInterval = 30; // Duration of each fade step in ms (recommended: 30) - shorter is smoother but causes more CPU-load +config. Fix = null; // Fixated position, two modes. Mode 1: x- an y-coordinates in brackets, e.g. [210, 480]. Mode 2: Show tooltip at a position related to an HTML element: [ID of HTML element, x-offset, y-offset from HTML element], e.g. ['SomeID', 10, 30]. Value null (default) for no fixated positioning. +config. FollowMouse = true; // false or true - tooltip follows the mouse +config. FontColor = '#000044'; +config. FontFace = 'Verdana,Geneva,sans-serif'; +config. FontSize = '8pt'; // E.g. '9pt' or '12px' - unit is mandatory +config. FontWeight = 'normal'; // 'normal' or 'bold'; +config. Height = 0; // Tooltip height; 0 for automatic adaption to tooltip content, < 0 (e.g. -100) for a maximum for automatic adaption +config. JumpHorz = false; // false or true - jump horizontally to other side of mouse if tooltip would extend past clientarea boundary +config. JumpVert = true; // false or true - jump vertically " +config. Left = false; // false or true - tooltip on the left of the mouse +config. OffsetX = 14; // Horizontal offset of left-top corner from mousepointer +config. OffsetY = 8; // Vertical offset +config. Opacity = 100; // Integer between 0 and 100 - opacity of tooltip in percent +config. Padding = 3; // Spacing between border and content +config. Shadow = false; // false or true +config. ShadowColor = '#C0C0C0'; +config. ShadowWidth = 5; +config. Sticky = false; // false or true - fixate tip, ie. don't follow the mouse and don't hide on mouseout +config. TextAlign = 'left'; // 'left', 'right' or 'justify' +config. Title = ''; // Default title text applied to all tips (no default title: empty string '') +config. TitleAlign = 'left'; // 'left' or 'right' - text alignment inside the title bar +config. TitleBgColor = ''; // If empty string '', BorderColor will be used +config. TitleFontColor = '#FFFFFF'; // Color of title text - if '', BgColor (of tooltip body) will be used +config. TitleFontFace = ''; // If '' use FontFace (boldified) +config. TitleFontSize = ''; // If '' use FontSize +config. TitlePadding = 2; +config. Width = 0; // Tooltip width; 0 for automatic adaption to tooltip content; < -1 (e.g. -240) for a maximum width for that automatic adaption; // -1: tooltip width confined to the width required for the titlebar //======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============// @@ -115,25 +122,27 @@ function Tip() function TagToTip() { var t2t = tt_GetElt(arguments[0]); - if(t2t) + if(t2t) { tt_Tip(arguments, t2t); + } } function UnTip() { tt_OpReHref(); - if(tt_aV[DURATION] < 0 && (tt_iState & 0x2)) + if(tt_aV[DURATION] < 0 && (tt_iState & 0x2)) { tt_tDurt.Timer("tt_HideInit()", -tt_aV[DURATION], true); - else if(!(tt_aV[STICKY] && (tt_iState & 0x2))) + } else if(!(tt_aV[STICKY] && (tt_iState & 0x2))) { tt_HideInit(); + } } -//================== PUBLIC PLUGIN API =====================================// +//================== PUBLIC PLUGIN API =====================================// // Extension eventhandlers currently supported: // OnLoadConfig, OnCreateContentString, OnSubDivsCreated, OnShow, OnMoveBefore, // OnMoveAfter, OnHideInit, OnHide, OnKill var tt_aElt = new Array(10), // Container DIV, outer title & body DIVs, inner title & body TDs, closebutton SPAN, shadow DIVs, and IFRAME to cover windowed elements in IE -tt_aV = new Array(), // Caches and enumerates config data for currently active tooltip +tt_aV = [], // Caches and enumerates config data for currently active tooltip tt_sContent, // Inner tooltip text or HTML tt_t2t, tt_t2tDad, // Tag converted to tip, and its DOM parent element tt_musX, tt_musY, @@ -202,18 +211,21 @@ function tt_Hide() tt_tWaitMov.EndTimer(); tt_bWait = false; } - if(tt_aV[CLICKCLOSE] || tt_aV[CLICKSTICKY]) + if(tt_aV[CLICKCLOSE] || tt_aV[CLICKSTICKY]) { tt_RemEvtFnc(document, "mouseup", tt_OnLClick); + } tt_ExtCallFncs(0, "Kill"); // In case of a TagToTip tip, hide converted DOM node and // re-insert it into DOM - if(tt_t2t && !tt_aV[COPYCONTENT]) + if(tt_t2t && !tt_aV[COPYCONTENT]) { tt_UnEl2Tip(); + } tt_iState = 0; tt_over = null; tt_ResetMainDiv(); - if(tt_aElt[tt_aElt.length - 1]) + if(tt_aElt[tt_aElt.length - 1]) { tt_aElt[tt_aElt.length - 1].style.display = "none"; + } } } function tt_GetElt(id) @@ -248,30 +260,32 @@ function tt_GetClientH() } function tt_GetEvtX(e) { - return (e ? ((typeof(e.pageX) != tt_u) ? e.pageX : (e.clientX + tt_GetScrollX())) : 0); + return (e ? ((typeof(e.pageX) !== tt_u) ? e.pageX : (e.clientX + tt_GetScrollX())) : 0); } function tt_GetEvtY(e) { - return (e ? ((typeof(e.pageY) != tt_u) ? e.pageY : (e.clientY + tt_GetScrollY())) : 0); + return (e ? ((typeof(e.pageY) !== tt_u) ? e.pageY : (e.clientY + tt_GetScrollY())) : 0); } function tt_AddEvtFnc(el, sEvt, PFnc) { if(el) { - if(el.addEventListener) + if(el.addEventListener) { el.addEventListener(sEvt, PFnc, false); - else + } else { el.attachEvent("on" + sEvt, PFnc); + } } } function tt_RemEvtFnc(el, sEvt, PFnc) { if(el) { - if(el.removeEventListener) + if(el.removeEventListener) { el.removeEventListener(sEvt, PFnc, false); - else + } else { el.detachEvent("on" + sEvt, PFnc); + } } } function tt_GetDad(el) @@ -280,15 +294,18 @@ function tt_GetDad(el) } function tt_MovDomNode(el, dadFrom, dadTo) { - if(dadFrom) + if(dadFrom) { dadFrom.removeChild(el); - if(dadTo) + } + if(dadTo) { dadTo.appendChild(el); + } } //====================== PRIVATE ===========================================// -var tt_aExt = new Array(), // Array of extension objects - +// JSHint doesn't like the use of "new Number(0)" at all. +//noinspection JSHint +var tt_aExt = [], // Array of extension objects tt_db, tt_op, tt_ie, tt_ie56, tt_bBoxOld, // Browser flags tt_body, tt_ovr_, // HTML element the mouse is currently over @@ -299,8 +316,7 @@ tt_opa, // Currently applied opacity tt_bJmpVert, tt_bJmpHorz,// Tip temporarily on other side of mouse tt_elDeHref, // The tag from which we've removed the href attribute // Timer -tt_tShow = new Number(0), tt_tHide = new Number(0), tt_tDurt = new Number(0), -tt_tFade = new Number(0), tt_tWaitMov = new Number(0), +tt_tShow = new Number(0), tt_tHide = new Number(0), tt_tDurt = new Number(0), tt_tFade = new Number(0), tt_tWaitMov = new Number(0), tt_bWait = false, tt_u = "undefined"; @@ -309,15 +325,17 @@ function tt_Init() { tt_MkCmdEnum(); // Send old browsers instantly to hell - if(!tt_Browser() || !tt_MkMainDiv()) + if(!tt_Browser() || !tt_MkMainDiv()) { return; + } tt_IsW3cBox(); tt_OpaSupport(); tt_AddEvtFnc(document, "mousemove", tt_Move); // In Debug mode we search for TagToTip() calls in order to notify // the user if they've forgotten to set the TagsToTip config flag - if(TagsToTip || tt_Debug) + if(TagsToTip || tt_Debug) { tt_SetOnloadFnc(); + } // Ensure the tip be hidden when the page unloads tt_AddEvtFnc(window, "unload", tt_Hide); } @@ -325,25 +343,27 @@ function tt_Init() function tt_MkCmdEnum() { var n = 0; - for(var i in config) + for(var i in config) { eval("window." + i.toString().toUpperCase() + " = " + n++); + } tt_aV.length = n; } function tt_Browser() { var n, nv, n6, w3c; - n = navigator.userAgent.toLowerCase(), + n = navigator.userAgent.toLowerCase(); nv = navigator.appVersion; - tt_op = (document.defaultView && typeof(eval("w" + "indow" + "." + "o" + "p" + "er" + "a")) != tt_u); - tt_ie = n.indexOf("msie") != -1 && document.all && !tt_op; + tt_op = (document.defaultView && typeof(eval("w" + "indow" + "." + "o" + "p" + "er" + "a")) !== tt_u); + tt_ie = n.indexOf("msie") !== -1 && document.all && !tt_op; if(tt_ie) { - var ieOld = (!document.compatMode || document.compatMode == "BackCompat"); + var ieOld = (!document.compatMode || document.compatMode === "BackCompat"); tt_db = !ieOld ? document.documentElement : (document.body || null); - if(tt_db) - tt_ie56 = parseFloat(nv.substring(nv.indexOf("MSIE") + 5)) >= 5.5 - && typeof document.body.style.maxHeight == tt_u; + if(tt_db) { + tt_ie56 = parseFloat(nv.substring(nv.indexOf("MSIE") + 5)) >= 5.5 && + typeof document.body.style.maxHeight === tt_u; + } } else { @@ -352,7 +372,7 @@ function tt_Browser() : null); if(!tt_op) { - n6 = document.defaultView && typeof document.defaultView.getComputedStyle != tt_u; + n6 = document.defaultView && typeof document.defaultView.getComputedStyle !== tt_u; w3c = !n6 && document.getElementById; } } @@ -362,12 +382,13 @@ function tt_Browser() { if(tt_body && tt_db) { - if(document.attachEvent || document.addEventListener) + if(document.attachEvent || document.addEventListener) { return true; + } + } + else { + tt_Err("wz_tooltip.js must be included INSIDE the body section, immediately after the opening <body> tag.", false); } - else - tt_Err("wz_tooltip.js must be included INSIDE the body section," - + " immediately after the opening <body> tag.", false); } tt_db = null; return false; @@ -375,12 +396,14 @@ function tt_Browser() function tt_MkMainDiv() { // Create the tooltip DIV - if(tt_body.insertAdjacentHTML) + if(tt_body.insertAdjacentHTML) { tt_body.insertAdjacentHTML("afterBegin", tt_MkMainDivHtm()); - else if(typeof tt_body.innerHTML != tt_u && document.createElement && tt_body.appendChild) + } else if(typeof tt_body.innerHTML !== tt_u && document.createElement && tt_body.appendChild) { tt_body.appendChild(tt_MkMainDivDom()); - if(window.tt_GetMainDivRefs /* FireFox Alzheimer */ && tt_GetMainDivRefs()) + } + if(window.tt_GetMainDivRefs /* FireFox Alzheimer */ && tt_GetMainDivRefs()) { return true; + } tt_db = null; return false; } @@ -395,8 +418,9 @@ function tt_MkMainDivHtm() function tt_MkMainDivDom() { var el = document.createElement("div"); - if(el) + if(el) { el.id = "WzTtDiV"; + } return el; } function tt_GetMainDivRefs() @@ -405,8 +429,9 @@ function tt_GetMainDivRefs() if(tt_ie56 && tt_aElt[0]) { tt_aElt[tt_aElt.length - 1] = tt_GetElt("WzTtIfRm"); - if(!tt_aElt[tt_aElt.length - 1]) + if(!tt_aElt[tt_aElt.length - 1]) { tt_aElt[0] = null; + } } if(tt_aElt[0]) { @@ -432,7 +457,7 @@ function tt_IsW3cBox() css.padding = "10px"; css.width = "40px"; - tt_bBoxOld = (tt_GetDivW(tt_aElt[0]) == 40); + tt_bBoxOld = (tt_GetDivW(tt_aElt[0]) === 40); css.padding = "0px"; tt_ResetMainDiv(); } @@ -440,11 +465,11 @@ function tt_OpaSupport() { var css = tt_body.style; - tt_flagOpa = (typeof(css.KhtmlOpacity) != tt_u) ? 2 - : (typeof(css.KHTMLOpacity) != tt_u) ? 3 - : (typeof(css.MozOpacity) != tt_u) ? 4 - : (typeof(css.opacity) != tt_u) ? 5 - : (typeof(css.filter) != tt_u) ? 1 + tt_flagOpa = (typeof(css.KhtmlOpacity) !== tt_u) ? 2 + : (typeof(css.KHTMLOpacity) !== tt_u) ? 3 + : (typeof(css.MozOpacity) !== tt_u) ? 4 + : (typeof(css.opacity) !== tt_u) ? 5 + : (typeof(css.filter) !== tt_u) ? 1 : 0; } // Ported from http://dean.edwards.name/weblog/2006/06/again/ @@ -453,12 +478,14 @@ function tt_SetOnloadFnc() { tt_AddEvtFnc(document, "DOMContentLoaded", tt_HideSrcTags); tt_AddEvtFnc(window, "load", tt_HideSrcTags); - if(tt_body.attachEvent) + if(tt_body.attachEvent) { tt_body.attachEvent("onreadystatechange", function() { - if(tt_body.readyState == "complete") + if(tt_body.readyState === "complete") { tt_HideSrcTags(); + } } ); + } if(/WebKit|KHTML/i.test(navigator.userAgent)) { var t = setInterval(function() { @@ -472,14 +499,16 @@ function tt_SetOnloadFnc() } function tt_HideSrcTags() { - if(!window.tt_HideSrcTags || window.tt_HideSrcTags.done) + if(!window.tt_HideSrcTags || window.tt_HideSrcTags.done) { return; + } window.tt_HideSrcTags.done = true; - if(!tt_HideSrcTagsRecurs(tt_body)) - tt_Err("There are HTML elements to be converted to tooltips.\nIf you" - + " want these HTML elements to be automatically hidden, you" - + " must edit wz_tooltip.js, and set TagsToTip in the global" - + " tooltip configuration to true.", true); + if(!tt_HideSrcTagsRecurs(tt_body)) { + tt_Err("There are HTML elements to be converted to tooltips.\nIf you" + + " want these HTML elements to be automatically hidden, you" + + " must edit wz_tooltip.js, and set TagsToTip in the global" + + " tooltip configuration to true.", true); + } } function tt_HideSrcTagsRecurs(dad) { @@ -491,18 +520,20 @@ function tt_HideSrcTagsRecurs(dad) for(var i = a ? a.length : 0; i;) {--i; - if(!tt_HideSrcTagsRecurs(a[i])) + if(!tt_HideSrcTagsRecurs(a[i])) { return false; + } ovr = a[i].getAttribute ? (a[i].getAttribute("onmouseover") || a[i].getAttribute("onclick")) - : (typeof a[i].onmouseover == "function") ? (a[i].onmouseover || a[i].onclick) + : (typeof a[i].onmouseover === "function") ? (a[i].onmouseover || a[i].onclick) : null; if(ovr) { asT2t = ovr.toString().match(/TagToTip\s*\(\s*'[^'.]+'\s*[\),]/); if(asT2t && asT2t.length) { - if(!tt_HideSrcTag(asT2t[0])) + if(!tt_HideSrcTag(asT2t[0])) { return false; + } } } } @@ -518,27 +549,32 @@ function tt_HideSrcTag(sT2t) el = tt_GetElt(id); if(el) { - if(tt_Debug && !TagsToTip) + if(tt_Debug && !TagsToTip) { return false; - else + } else { el.style.display = "none"; + } + } + else { + tt_Err("Invalid ID\n'" + id + "'\npassed to TagToTip(). There exists no HTML element with that ID.", true); } - else - tt_Err("Invalid ID\n'" + id + "'\npassed to TagToTip()." - + " There exists no HTML element with that ID.", true); return true; } function tt_Tip(arg, t2t) { - if(!tt_db || (tt_iState & 0x8)) + if(!tt_db || (tt_iState & 0x8)) { return; - if(tt_iState) + } + if(tt_iState) { tt_Hide(); - if(!tt_Enabled) + } + if(!tt_Enabled) { return; + } tt_t2t = t2t; - if(!tt_ReadCmds(arg)) + if(!tt_ReadCmds(arg)) { return; + } tt_iState = 0x1 | 0x4; tt_AdaptConfig1(); tt_MkTipContent(arg); @@ -561,52 +597,62 @@ function tt_ReadCmds(a) // First load the global config values, to initialize also values // for which no command is passed i = 0; - for(var j in config) + for(var j in config) { tt_aV[i++] = config[j]; + } // Then replace each cached config value for which a command is // passed (ensure the # of command args plus value args be even) if(a.length & 1) { - for(i = a.length - 1; i > 0; i -= 2) + for(i = a.length - 1; i > 0; i -= 2) { tt_aV[a[i - 1]] = a[i]; + } return true; } - tt_Err("Incorrect call of Tip() or TagToTip().\n" - + "Each command must be followed by a value.", true); + tt_Err("Incorrect call of Tip() or TagToTip().\n Each command must be followed by a value.", true); return false; } function tt_AdaptConfig1() { tt_ExtCallFncs(0, "LoadConfig"); // Inherit unspecified title formattings from body - if(!tt_aV[TITLEBGCOLOR].length) + if(!tt_aV[TITLEBGCOLOR].length) { tt_aV[TITLEBGCOLOR] = tt_aV[BORDERCOLOR]; - if(!tt_aV[TITLEFONTCOLOR].length) + } + if(!tt_aV[TITLEFONTCOLOR].length) { tt_aV[TITLEFONTCOLOR] = tt_aV[BGCOLOR]; - if(!tt_aV[TITLEFONTFACE].length) + } + if(!tt_aV[TITLEFONTFACE].length) { tt_aV[TITLEFONTFACE] = tt_aV[FONTFACE]; - if(!tt_aV[TITLEFONTSIZE].length) + } + if(!tt_aV[TITLEFONTSIZE].length) { tt_aV[TITLEFONTSIZE] = tt_aV[FONTSIZE]; + } if(tt_aV[CLOSEBTN]) { // Use title colours for non-specified closebutton colours - if(!tt_aV[CLOSEBTNCOLORS]) + if(!tt_aV[CLOSEBTNCOLORS]) { tt_aV[CLOSEBTNCOLORS] = new Array("", "", "", ""); + } for(var i = 4; i;) {--i; - if(!tt_aV[CLOSEBTNCOLORS][i].length) + if(!tt_aV[CLOSEBTNCOLORS][i].length) { tt_aV[CLOSEBTNCOLORS][i] = (i & 1) ? tt_aV[TITLEFONTCOLOR] : tt_aV[TITLEBGCOLOR]; + } } // Enforce titlebar be shown - if(!tt_aV[TITLE].length) + if(!tt_aV[TITLE].length) { tt_aV[TITLE] = " "; + } } // Circumvents broken display of images and fade-in flicker in Geckos < 1.8 - if(tt_aV[OPACITY] == 100 && typeof tt_aElt[0].style.MozOpacity != tt_u && !Array.every) + if(tt_aV[OPACITY] === 100 && typeof tt_aElt[0].style.MozOpacity !== tt_u && !Array.every) { tt_aV[OPACITY] = 99; + } // Smartly shorten the delay for fade-in tooltips - if(tt_aV[FADEIN] && tt_flagOpa && tt_aV[DELAY] > 100) + if(tt_aV[FADEIN] && tt_flagOpa && tt_aV[DELAY] > 100) { tt_aV[DELAY] = Math.max(tt_aV[DELAY] - tt_aV[FADEIN], 100); + } } function tt_AdaptConfig2() { @@ -621,13 +667,15 @@ function tt_MkTipContent(a) { if(tt_t2t) { - if(tt_aV[COPYCONTENT]) + if(tt_aV[COPYCONTENT]) { tt_sContent = tt_t2t.innerHTML; - else + } else { tt_sContent = ""; + } } - else + else { tt_sContent = a[0]; + } tt_ExtCallFncs(0, "CreateContentString"); } function tt_MkTipSubDivs() @@ -637,44 +685,45 @@ function tt_MkTipSubDivs() tt_aElt[0].style.width = tt_GetClientW() + "px"; tt_aElt[0].innerHTML = - ('' - + (tt_aV[TITLE].length ? - ('<div id="WzTiTl" style="position:relative;z-index:1;">' - + '<table id="WzTiTlTb"' + sTbTrTd + 'id="WzTiTlI" style="' + sCss + '">' - + tt_aV[TITLE] - + '</td>' - + (tt_aV[CLOSEBTN] ? - ('<td align="right" style="' + sCss - + 'text-align:right;">' - + '<span id="WzClOsE" style="position:relative;left:2px;padding-left:2px;padding-right:2px;' - + 'cursor:' + (tt_ie ? 'hand' : 'pointer') - + ';" onmouseover="tt_OnCloseBtnOver(1)" onmouseout="tt_OnCloseBtnOver(0)" onclick="tt_HideInit()">' - + tt_aV[CLOSEBTNTEXT] - + '</span></td>') + ('' + + (tt_aV[TITLE].length ? + ('<div id="WzTiTl" style="position:relative;z-index:1;">' + + '<table id="WzTiTlTb"' + sTbTrTd + 'id="WzTiTlI" style="' + sCss + '">' + + tt_aV[TITLE] + + '</td>' + + (tt_aV[CLOSEBTN] ? + ('<td align="right" style="' + sCss + 'text-align:right;">' + + '<span id="WzClOsE" style="position:relative;left:2px;padding-left:2px;padding-right:2px;' + + 'cursor:' + (tt_ie ? 'hand' : 'pointer') + + ';" onmouseover="tt_OnCloseBtnOver(1)" onmouseout="tt_OnCloseBtnOver(0)" onclick="tt_HideInit()">' + + tt_aV[CLOSEBTNTEXT] + + '</span></td>') + : '') + + '</tr></tbody></table></div>') + : '') + + '<div id="WzBoDy" style="position:relative;z-index:0;">' + + '<table' + sTbTrTd + 'id="WzBoDyI" style="' + sCss + '">' + + tt_sContent + + '</td></tr></tbody></table></div>' + + (tt_aV[SHADOW] ? + ('<div id="WzTtShDwR" style="position:absolute;overflow:hidden;"></div>' + + '<div id="WzTtShDwB" style="position:relative;overflow:hidden;"></div>') : '') - + '</tr></tbody></table></div>') - : '') - + '<div id="WzBoDy" style="position:relative;z-index:0;">' - + '<table' + sTbTrTd + 'id="WzBoDyI" style="' + sCss + '">' - + tt_sContent - + '</td></tr></tbody></table></div>' - + (tt_aV[SHADOW] - ? ('<div id="WzTtShDwR" style="position:absolute;overflow:hidden;"></div>' - + '<div id="WzTtShDwB" style="position:relative;overflow:hidden;"></div>') - : '') ); tt_GetSubDivRefs(); // Convert DOM node to tip - if(tt_t2t && !tt_aV[COPYCONTENT]) + if(tt_t2t && !tt_aV[COPYCONTENT]) { tt_El2Tip(); + } tt_ExtCallFncs(0, "SubDivsCreated"); } function tt_GetSubDivRefs() { var aId = new Array("WzTiTl", "WzTiTlTb", "WzTiTlI", "WzClOsE", "WzBoDy", "WzBoDyI", "WzTtShDwB", "WzTtShDwR"); - for(var i = aId.length; i; --i) + for(var i = aId.length; i; --i) { tt_aElt[i] = tt_GetElt(aId[i - 1]); + } } function tt_FormatTip() { @@ -691,8 +740,9 @@ function tt_FormatTip() css.paddingLeft = css.paddingRight = (padT + 2) + "px"; css = tt_aElt[3].style; css.color = tt_aV[TITLEFONTCOLOR]; - if(tt_aV[WIDTH] == -1) + if(tt_aV[WIDTH] === -1) { css.whiteSpace = "nowrap"; + } css.fontFamily = tt_aV[TITLEFONTFACE]; css.fontSize = tt_aV[TITLEFONTSIZE]; css.fontWeight = "bold"; @@ -707,17 +757,20 @@ function tt_FormatTip() css.fontSize = tt_aV[TITLEFONTSIZE]; css.fontWeight = "bold"; } - if(tt_aV[WIDTH] > 0) + if(tt_aV[WIDTH] > 0) { tt_w = tt_aV[WIDTH]; + } else { tt_w = tt_GetDivW(tt_aElt[3]) + tt_GetDivW(tt_aElt[4]); // Some spacing between title DIV and closebutton - if(tt_aElt[4]) + if(tt_aElt[4]) { tt_w += pad; + } // Restrict auto width to max width - if(tt_aV[WIDTH] < -1 && tt_w > -tt_aV[WIDTH]) + if(tt_aV[WIDTH] < -1 && tt_w > -tt_aV[WIDTH]) { tt_w = -tt_aV[WIDTH]; + } } // Ensure the top border of the body DIV be covered by the title DIV iOffY = -wBrd; @@ -737,19 +790,22 @@ function tt_FormatTip() css.borderStyle = tt_aV[BORDERSTYLE]; css.borderWidth = wBrd + "px"; } - if(tt_aV[BGCOLOR].length) + if(tt_aV[BGCOLOR].length) { css.background = tt_aV[BGCOLOR]; - if(tt_aV[BGIMG].length) + } + if(tt_aV[BGIMG].length) { css.backgroundImage = "url(" + tt_aV[BGIMG] + ")"; + } css.padding = pad + "px"; css.textAlign = tt_aV[TEXTALIGN]; if(tt_aV[HEIGHT]) { css.overflow = "auto"; - if(tt_aV[HEIGHT] > 0) + if(tt_aV[HEIGHT] > 0) { css.height = (tt_aV[HEIGHT] + iAdd) + "px"; - else + } else { tt_h = iAdd - tt_aV[HEIGHT]; + } } // TD inside body DIV css = tt_aElt[6].style; @@ -758,22 +814,25 @@ function tt_FormatTip() css.fontSize = tt_aV[FONTSIZE]; css.fontWeight = tt_aV[FONTWEIGHT]; css.textAlign = tt_aV[TEXTALIGN]; - if(tt_aV[WIDTH] > 0) + if(tt_aV[WIDTH] > 0) { w = tt_aV[WIDTH]; // Width like title (if existent) - else if(tt_aV[WIDTH] == -1 && tt_w) + } else if(tt_aV[WIDTH] === -1 && tt_w) { w = tt_w; + } else { // Measure width of the body's inner TD, as some browsers would expand // the container and outer body DIV to 100% w = tt_GetDivW(tt_aElt[6]); // Restrict auto width to max width - if(tt_aV[WIDTH] < -1 && w > -tt_aV[WIDTH]) + if(tt_aV[WIDTH] < -1 && w > -tt_aV[WIDTH]) { w = -tt_aV[WIDTH]; + } } - if(w > tt_w) + if(w > tt_w) { tt_w = w; + } tt_w += iAdd; //--------- Shadow DIVs ------------ @@ -795,8 +854,9 @@ function tt_FormatTip() css.width = tt_aV[SHADOWWIDTH] + "px"; css.background = tt_aV[SHADOWCOLOR]; } - else + else { iOffSh = 0; + } //-------- Container DIV ------- tt_SetTipOpa(tt_aV[FADEIN] ? 0 : tt_aV[OPACITY]); @@ -812,15 +872,17 @@ function tt_FixSize(iOffY, iOffSh) wOut = tt_w - ((tt_aV[SHADOW]) ? tt_aV[SHADOWWIDTH] : 0); // Body wIn = wOut; - if(!tt_bBoxOld) + if(!tt_bBoxOld) { wIn -= (pad + wBrd) << 1; + } tt_aElt[5].style.width = wIn + "px"; // Title if(tt_aElt[1]) { wIn = wOut - ((tt_aV[TITLEPADDING] + 2) << 1); - if(!tt_bBoxOld) + if(!tt_bBoxOld) { wOut = wIn; + } tt_aElt[1].style.width = wOut + "px"; tt_aElt[2].style.width = wIn + "px"; } @@ -830,15 +892,17 @@ function tt_FixSize(iOffY, iOffSh) h = tt_GetDivH(tt_aElt[5]); if(h > tt_h) { - if(!tt_bBoxOld) + if(!tt_bBoxOld) { tt_h -= (pad + wBrd) << 1; + } tt_aElt[5].style.height = tt_h + "px"; } } tt_h = tt_GetDivH(tt_aElt[0]) + iOffY; // Right shadow - if(tt_aElt[8]) + if(tt_aElt[8]) { tt_aElt[8].style.height = (tt_h - iOffSh) + "px"; + } i = tt_aElt.length - 1; if(tt_aElt[i]) { @@ -852,25 +916,30 @@ function tt_DeAlt(el) if(el) { - if(el.alt) + if(el.alt) { el.alt = ""; - if(el.title) + } + if(el.title) { el.title = ""; + } aKid = el.childNodes || el.children || null; if(aKid) { - for(var i = aKid.length; i;) + for(var i = aKid.length; i;) { tt_DeAlt(aKid[--i]); + } } } } // This hack removes the native tooltips over links in Opera function tt_OpDeHref(el) { - if(!tt_op) + if(!tt_op) { return; - if(tt_elDeHref) + } + if(tt_elDeHref) { tt_OpReHref(); + } while(el) { if(el.hasAttribute && el.hasAttribute("href")) @@ -928,18 +997,20 @@ function tt_UnEl2Tip() } function tt_OverInit() { - if(window.event) + if(window.event) { tt_over = window.event.target || window.event.srcElement; - else + } else { tt_over = tt_ovr_; + } tt_DeAlt(tt_over); tt_OpDeHref(tt_over); } function tt_ShowInit() { tt_tShow.Timer("tt_Show()", tt_aV[DELAY], true); - if(tt_aV[CLICKCLOSE] || tt_aV[CLICKSTICKY]) + if(tt_aV[CLICKCLOSE] || tt_aV[CLICKSTICKY]) { tt_AddEvtFnc(document, "mouseup", tt_OnLClick); + } } function tt_Show() { @@ -947,17 +1018,21 @@ function tt_Show() // Override the z-index of the topmost wz_dragdrop.js D&D item css.zIndex = Math.max((window.dd && dd.z) ? (dd.z + 2) : 0, 1010); - if(tt_aV[STICKY] || !tt_aV[FOLLOWMOUSE]) + if(tt_aV[STICKY] || !tt_aV[FOLLOWMOUSE]) { tt_iState &= ~0x4; - if(tt_aV[EXCLUSIVE]) + } + if(tt_aV[EXCLUSIVE]) { tt_iState |= 0x8; - if(tt_aV[DURATION] > 0) + } + if(tt_aV[DURATION] > 0) { tt_tDurt.Timer("tt_HideInit()", tt_aV[DURATION], true); - tt_ExtCallFncs(0, "Show") + } + tt_ExtCallFncs(0, "Show"); css.visibility = "visible"; tt_iState |= 0x2; - if(tt_aV[FADEIN]) + if(tt_aV[FADEIN]) { tt_Fade(0, 0, tt_aV[OPACITY], Math.round(tt_aV[FADEIN] / tt_aV[FADEINTERVAL])); + } tt_ShowIfrm(); } function tt_ShowIfrm() @@ -975,8 +1050,9 @@ function tt_ShowIfrm() } function tt_Move(e) { - if(e) + if(e) { tt_ovr_ = e.target || e.srcElement; + } e = e || window.event; if(e) { @@ -988,8 +1064,9 @@ function tt_Move(e) // Prevent jam of mousemove events if(!tt_op && !tt_ie) { - if(tt_bWait) + if(tt_bWait) { return; + } tt_bWait = true; tt_tWaitMov.Timer("tt_bWait = false;", 1, true); } @@ -998,9 +1075,10 @@ function tt_Move(e) tt_iState &= ~0x4; tt_PosFix(); } - else if(!tt_ExtCallFncs(e, "MoveBefore")) + else if(!tt_ExtCallFncs(e, "MoveBefore")) { tt_SetTipPos(tt_Pos(0), tt_Pos(1)); - tt_ExtCallFncs([tt_musX, tt_musY], "MoveAfter") + } + tt_ExtCallFncs([tt_musX, tt_musY], "MoveAfter"); } } function tt_Pos(iDim) @@ -1032,44 +1110,54 @@ function tt_Pos(iDim) } if(bJmpMod) { - if(tt_aV[cmdAlt] && (!bJmp || tt_CalcPosAlt(iDim) >= iScrl + 16)) + if(tt_aV[cmdAlt] && (!bJmp || tt_CalcPosAlt(iDim) >= iScrl + 16)) { iX = tt_PosAlt(iDim); - else if(!tt_aV[cmdAlt] && bJmp && tt_CalcPosDef(iDim) > iMax - 16) + } + else if(!tt_aV[cmdAlt] && bJmp && tt_CalcPosDef(iDim) > iMax - 16) { iX = tt_PosAlt(iDim); - else + } else { iX = tt_PosDef(iDim); + } } else { iX = iMus; - if(tt_aV[cmdAlt]) + if(tt_aV[cmdAlt]) { iX -= cx + tt_aV[cmdOff] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0); - else + } + else { iX += tt_aV[cmdOff]; + } } // Prevent tip from extending past clientarea boundary - if(iX > iMax) + if(iX > iMax) { iX = bJmpMod ? tt_PosAlt(iDim) : iMax; + } // In case of insufficient space on both sides, ensure the left/upper part // of the tip be visible - if(iX < iScrl) + if(iX < iScrl) { iX = bJmpMod ? tt_PosDef(iDim) : iScrl; + } return iX; } function tt_PosDef(iDim) { - if(iDim) + if(iDim) { tt_bJmpVert = tt_aV[ABOVE]; - else + } + else { tt_bJmpHorz = tt_aV[LEFT]; + } return tt_CalcPosDef(iDim); } function tt_PosAlt(iDim) { - if(iDim) + if(iDim) { tt_bJmpVert = !tt_aV[ABOVE]; - else + } + else { tt_bJmpHorz = !tt_aV[LEFT]; + } return tt_CalcPosAlt(iDim); } function tt_CalcPosDef(iDim) @@ -1080,31 +1168,34 @@ function tt_CalcPosAlt(iDim) { var cmdOff = iDim ? OFFSETY : OFFSETX; var dx = tt_aV[cmdOff] - (tt_aV[SHADOW] ? tt_aV[SHADOWWIDTH] : 0); - if(tt_aV[cmdOff] > 0 && dx <= 0) + if(tt_aV[cmdOff] > 0 && dx <= 0) { dx = 1; + } return((iDim ? (tt_musY - tt_h) : (tt_musX - tt_w)) - dx); } function tt_PosFix() { var iX, iY; - if(typeof(tt_aV[FIX][0]) == "number") + if(typeof(tt_aV[FIX][0]) === "number") { iX = tt_aV[FIX][0]; iY = tt_aV[FIX][1]; } else { - if(typeof(tt_aV[FIX][0]) == "string") + if(typeof(tt_aV[FIX][0]) === "string") { el = tt_GetElt(tt_aV[FIX][0]); // First slot in array is direct reference to HTML element - else + } else { el = tt_aV[FIX][0]; + } iX = tt_aV[FIX][1]; iY = tt_aV[FIX][2]; // By default, vert pos is related to bottom edge of HTML element - if(!tt_aV[ABOVE] && el) + if(!tt_aV[ABOVE] && el) { iY += tt_GetDivH(el); + } for(; el; el = el.offsetParent) { iX += el.offsetLeft || 0; @@ -1113,8 +1204,9 @@ function tt_PosFix() } // For a fixed tip positioned above the mouse, use the bottom edge as anchor // (recommended by Christophe Rebeschini, 31.1.2008) - if(tt_aV[ABOVE]) + if(tt_aV[ABOVE]) { iY -= tt_h; + } tt_SetTipPos(iX, iY); } function tt_Fade(a, now, z, n) @@ -1122,26 +1214,26 @@ function tt_Fade(a, now, z, n) if(n) { now += Math.round((z - now) / n); - if((z > a) ? (now >= z) : (now <= z)) + if((z > a) ? (now >= z) : (now <= z)) { now = z; - else - tt_tFade.Timer( - "tt_Fade(" - + a + "," + now + "," + z + "," + (n - 1) - + ")", - tt_aV[FADEINTERVAL], - true - ); + } else { + tt_tFade.Timer( "tt_Fade(" + a + "," + now + "," + z + "," + (n - 1) + ")", tt_aV[FADEINTERVAL], true); + } + } + if (now) { + tt_SetTipOpa(now); + } else { + tt_Hide(); } - now ? tt_SetTipOpa(now) : tt_Hide(); } function tt_SetTipOpa(opa) { // To circumvent the opacity nesting flaws of IE, we set the opacity // for each sub-DIV separately, rather than for the container DIV. tt_SetOpa(tt_aElt[5], opa); - if(tt_aElt[1]) + if(tt_aElt[1]) { tt_SetOpa(tt_aElt[1], opa); + } if(tt_aV[SHADOW]) { opa = Math.round(opa * 0.8); @@ -1161,15 +1253,16 @@ function tt_OnLClick(e) { // Ignore right-clicks e = e || window.event; - if(!((e.button && e.button & 2) || (e.which && e.which == 3))) + if(!((e.button && e.button & 2) || (e.which && e.which === 3))) { if(tt_aV[CLICKSTICKY] && (tt_iState & 0x4)) { tt_aV[STICKY] = true; tt_iState &= ~0x4; } - else if(tt_aV[CLICKCLOSE]) + else if(tt_aV[CLICKCLOSE]) { tt_HideInit(); + } } } function tt_Int(x) @@ -1180,9 +1273,10 @@ function tt_Int(x) } Number.prototype.Timer = function(s, iT, bUrge) { - if(!this.value || bUrge) + if(!this.value || bUrge) { this.value = window.setTimeout(s, iT); -} + } +}; Number.prototype.EndTimer = function() { if(this.value) @@ -1190,19 +1284,19 @@ Number.prototype.EndTimer = function() window.clearTimeout(this.value); this.value = 0; } -} +}; function tt_GetWndCliSiz(s) { var db, y = window["inner" + s], sC = "client" + s, sN = "number"; - if(typeof y == sN) + if(typeof y === sN) { var y2; return( // Gecko or Opera with scrollbar // ... quirks mode - ((db = document.body) && typeof(y2 = db[sC]) == sN && y2 && y2 <= y) ? y2 + ((db = document.body) && typeof(y2 = db[sC]) === sN && y2 && y2 <= y) ? y2 // ... strict mode - : ((db = document.documentElement) && typeof(y2 = db[sC]) == sN && y2 && y2 <= y) ? y2 + : ((db = document.documentElement) && typeof(y2 = db[sC]) === sN && y2 && y2 <= y) ? y2 // No scrollbar, or clientarea size == 0, or other browser (KHTML etc.) : y ); @@ -1221,7 +1315,7 @@ function tt_SetOpa(el, opa) var css = el.style; tt_opa = opa; - if(tt_flagOpa == 1) + if(tt_flagOpa === 1) { if(opa < 100) { @@ -1229,23 +1323,27 @@ function tt_SetOpa(el, opa) // 1.) Once a CSS filter has been applied, fonts are no longer // anti-aliased, so we store the previous 'non-filter' to be // able to restore it - if(typeof(el.filtNo) == tt_u) + if(typeof(el.filtNo) === tt_u) { el.filtNo = css.filter; + } // 2.) A DIV cannot be made visible in a single step if an // opacity < 100 has been applied while the DIV was hidden - var bVis = css.visibility != "hidden"; + var bVis = css.visibility !== "hidden"; // 3.) In IE6, applying an opacity < 100 has no effect if the - // element has no layout (position, size, zoom, ...) + // element has no layout (position, size, zoom, ...) css.zoom = "100%"; - if(!bVis) + if(!bVis) { css.visibility = "visible"; + } css.filter = "alpha(opacity=" + opa + ")"; - if(!bVis) + if(!bVis) { css.visibility = "hidden"; + } } - else if(typeof(el.filtNo) != tt_u) + else if(typeof(el.filtNo) !== tt_u) { // Restore 'non-filter' css.filter = el.filtNo; + } } else { @@ -1265,8 +1363,9 @@ function tt_SetOpa(el, opa) } function tt_Err(sErr, bIfDebug) { - if(tt_Debug || !bIfDebug) + if(tt_Debug || !bIfDebug) { alert("Tooltip Script Error Message:\n\n" + sErr); + } } //============ EXTENSION (PLUGIN) MANAGER ===============// @@ -1292,8 +1391,9 @@ function tt_ExtCallFncs(arg, sFnc) {--i; var fnc = tt_aExt[i]["On" + sFnc]; // Call the method the extension has defined for this event - if(fnc && fnc(arg)) + if(fnc && fnc(arg)) { b = true; + } } return b; } From 57a390eaabe2fb756b797170ffdd9b99fced9813 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Sat, 19 Apr 2014 23:38:42 -0400 Subject: [PATCH 02/66] Massive linting! --- ext/chatbox/js/yshout.js | 241 ++++++++++++++++++++------------------- 1 file changed, 122 insertions(+), 119 deletions(-) diff --git a/ext/chatbox/js/yshout.js b/ext/chatbox/js/yshout.js index be4fb4b9..4593aa2b 100644 --- a/ext/chatbox/js/yshout.js +++ b/ext/chatbox/js/yshout.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, devel:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + String.prototype.sReplace = function(find, replace) { return this.split(find).join(replace); }; @@ -5,7 +7,7 @@ String.prototype.sReplace = function(find, replace) { String.prototype.repeat = function(times) { var rep = new Array(times + 1); return rep.join(this); -} +}; var YShout = function() { var self = this; @@ -13,7 +15,7 @@ var YShout = function() { $(document).ready(function() { self.init.apply(self, args); }); -} +}; var yShout; @@ -35,15 +37,17 @@ YShout.prototype = { this.options = jQuery.extend(dOptions, options); this.postNum = 0; - this.floodAttempt = 0; + this.floodAttempt = 0; // Correct for missing trailing / - if ((this.options.yPath.length > 0) && (this.options.yPath.charAt(this.options.yPath.length - 1) != '/')) + if ((this.options.yPath.length > 0) && (this.options.yPath.charAt(this.options.yPath.length - 1) !== '/')) { this.options.yPath += '/'; + } if (this.options.yLink) { - if (this.options.yLink.charAt(0) != '#') + if (this.options.yLink.charAt(0) !== '#') { this.options.yLink = '#' + this.options.yLink; + } $(this.options.yLink).click(function() { self.openYShout.apply(self); @@ -59,21 +63,16 @@ YShout.prototype = { return false; }); this.load(true); - } else + } else { this.load(); - - + } }, load: function(hidden) { - if ($('#yshout').length == 0) return; + if ($('#yshout').length === 0) { return; } + + if (hidden) { $('#yshout').css('display', 'none'); } - if (hidden) $('#yshout').css('display', 'none'); - - - - - this.ajax(this.initialLoad, { reqType: 'init', yPath: this.options.yPath, @@ -83,32 +82,28 @@ YShout.prototype = { initialLoad: function(updates) { - - - - if (updates.yError) alert('There appears to be a problem: \n' + updates.yError + '\n\nIf you haven\'t already, try chmodding everything inside the YShout directory to 777.'); - - - - var self = this; - + if (updates.yError) { + alert('There appears to be a problem: \n' + updates.yError + '\n\nIf you haven\'t already, try chmodding everything inside the YShout directory to 777.'); + } + + var self = this; - this.prefs = jQuery.extend(updates.prefs, this.options.prefs); this.initForm(); this.initRefresh(); this.initLinks(); - if (this.prefs.flood) this.initFlood(); + if (this.prefs.flood) { this.initFlood(); } - if (updates.nickname) + if (updates.nickname) { $('#ys-input-nickname') .removeClass('ys-before-focus') .addClass( 'ys-after-focus') .val(updates.nickname); + } - if (updates) + if (updates) { this.updates(updates); - + } if (!this.prefs.doTruncate) { $('#ys-posts').css('height', $('#ys-posts').height + 'px'); @@ -132,14 +127,14 @@ YShout.prototype = { '<input id="ys-input-nickname" value="' + nickname + '" type="hidden" accesskey="N" maxlength="' + this.prefs.nicknameLength + '" class="ys-before-focus" />' + '<input id="ys-input-message" value="' + this.prefs.defaultMessage + '" type="text" accesskey="M" maxlength="' + this.prefs.messageLength + '" class="ys-before-focus" />' + (this.prefs.showSubmit ? '<input id="ys-input-submit" value="' + this.prefs.defaultSubmit + '" accesskey="S" type="submit" />' : '') + - (this.prefs.postFormLink == 'cp' ? '<a title="View YShout Control Panel" class="ys-post-form-link" id="ys-cp-link" href="' + this.options.yPath + 'cp/index.php">Admin CP</a>' : '') + - (this.prefs.postFormLink == 'history' ? '<a title="View YShout History" class="ys-post-form-link" id="ys-history-link" href="' + this.options.yPath + 'history/index.php?log=' + this.options.log + '">View History</a>' : '') + + (this.prefs.postFormLink === 'cp' ? '<a title="View YShout Control Panel" class="ys-post-form-link" id="ys-cp-link" href="' + this.options.yPath + 'cp/index.php">Admin CP</a>' : '') + + (this.prefs.postFormLink === 'history' ? '<a title="View YShout History" class="ys-post-form-link" id="ys-history-link" href="' + this.options.yPath + 'history/index.php?log=' + this.options.log + '">View History</a>' : '') + '</fieldset></form>'; var postsDiv = '<div id="ys-posts"></div>'; - if (this.prefs.inverse) $('#yshout').html(postForm + postsDiv); - else $('#yshout').html(postsDiv + postForm); + if (this.prefs.inverse) { $('#yshout').html(postForm + postsDiv); } + else { $('#yshout').html(postsDiv + postForm); } $('#ys-posts') .before('<div id="ys-before-posts"></div>') @@ -158,32 +153,35 @@ YShout.prototype = { var keypress = function(e) { var key = window.event ? e.keyCode : e.which; - if (key == 13 || key == 3) { + if (key === 13 || key === 3) { self.send.apply(self); return false; } }; var focus = function() { - if (this.value == defaults[this.id]) + if (this.value === defaults[this.id]) { $(this).removeClass('ys-before-focus').addClass( 'ys-after-focus').val(''); + } }; var blur = function() { - if (this.value == '') - $(this).removeClass('ys-after-focus').addClass('ys-before-focus').val(defaults[this.id]); + if (this.value === '') { + $(this).removeClass('ys-after-focus').addClass('ys-before-focus').val(defaults[this.id]); + } }; $('#ys-input-message').keypress(keypress).focus(focus).blur(blur); $('#ys-input-nickname').keypress(keypress).focus(focus).blur(blur); - $('#ys-input-submit').click(function(){ self.send.apply(self) }); - $('#ys-post-form').submit(function(){ return false }); + $('#ys-input-submit').click(function(){ self.send.apply(self); }); + $('#ys-post-form').submit(function(){ return false; }); }, initRefresh: function() { var self = this; - if (this.refreshTimer) clearInterval(this.refreshTimer) + if (this.refreshTimer) { clearInterval(this.refreshTimer); } + this.refreshTimer = setInterval(function() { self.ajax(self.updates, { reqType: 'refresh' }); }, this.prefs.refresh); // ! 3000..? @@ -201,7 +199,7 @@ YShout.prototype = { }, initLinks: function() { - if ($.browser.msie) return; + if ($.browser.msie) { return; } var self = this; @@ -219,7 +217,7 @@ YShout.prototype = { openCP: function() { var self = this; - if (this.cpOpen) return; + if (this.cpOpen) { return; } this.cpOpen = true; var url = this.options.yPath + 'cp/index.php'; @@ -247,7 +245,7 @@ YShout.prototype = { openHistory: function() { var self = this; - if (this.hOpen) return; + if (this.hOpen) { return; } this.hOpen = true; var url = this.options.yPath + 'history/index.php?log='+ this.options.log; $('body').append('<div id="ys-overlay"></div><div class="ys-window" id="ys-history"><a title="Close history" href="#" id="ys-closeoverlay-link">Close</a><a title="View Admin CP" href="#" id="ys-switchoverlay-link">View Admin CP</a><object class="ys-browser" id="history-browser" data="' + url +'" type="text/html">Something went horribly wrong.</object></div>'); @@ -273,9 +271,9 @@ YShout.prototype = { openYShout: function() { var self = this; - if (this.ysOpen) return; + if (this.ysOpen) { return; } this.ysOpen = true; - url = this.options.yPath + 'example/yshout.html'; + var url = this.options.yPath + 'example/yshout.html'; $('body').append('<div id="ys-overlay"></div><div class="ys-window" id="ys-yshout"><a title="Close YShout" href="#" id="ys-closeoverlay-link">Close</a><object class="ys-browser" id="yshout-browser" data="' + url +'" type="text/html">Something went horribly wrong.</object></div>'); @@ -292,25 +290,26 @@ YShout.prototype = { }, send: function() { - if (!this.validate()) return; - if (this.prefs.flood && this.floodControl) return; + if (!this.validate()) { return; } + if (this.prefs.flood && this.floodControl) { return; } var postNickname = $('#ys-input-nickname').val(), postMessage = $('#ys-input-message').val(); - if (postMessage == '/cp') + if (postMessage === '/cp') { this.openCP(); - else if (postMessage == '/history') + } else if (postMessage === '/history') { this.openHistory(); - else + } else { this.ajax(this.updates, { reqType: 'post', nickname: postNickname, message: postMessage }); + } - $('#ys-input-message').val('') + $('#ys-input-message').val(''); - if (this.prefs.flood) this.flood(); + if (this.prefs.flood) { this.flood(); } }, validate: function() { @@ -321,21 +320,23 @@ YShout.prototype = { var showInvalid = function(input) { $(input).removeClass('ys-input-valid').addClass('ys-input-invalid')[0].focus(); error = true; - } + }; var showValid = function(input) { $(input).removeClass('ys-input-invalid').addClass('ys-input-valid'); + }; + + if (nickname === '' || nickname === this.prefs.defaultNickname) { + showInvalid('#ys-input-nickname'); + } else { + showValid('#ys-input-nickname'); } - if (nickname == '' || nickname == this.prefs.defaultNickname) - showInvalid('#ys-input-nickname'); - else - showValid('#ys-input-nickname'); - - if (message == '' || message == this.prefs.defaultMessage) + if (message === '' || message === this.prefs.defaultMessage) { showInvalid('#ys-input-message'); - else + } else { showValid('#ys-input-message'); + } return !error; }, @@ -351,8 +352,9 @@ YShout.prototype = { this.floodAttempt++; this.disable(); - if (this.floodAttempt == this.prefs.autobanFlood) + if (this.floodAttempt === this.prefs.autobanFlood) { this.banSelf('You have been banned for flooding the shoutbox!'); + } setTimeout(function() { self.floodCount = 0; @@ -371,12 +373,13 @@ YShout.prototype = { }, findBySame: function(ip) { - if (!$.browser.safari) return; + if (!$.browser.safari) {return;} var same = []; for (var i = 0; i < this.p.length; i++) { - if (this.p[i].adminInfo.ip == ip) + if (this.p[i].adminInfo.ip === ip) { same.push(this.p[i]); + } } for (var j = 0; j < same.length; j++) { @@ -385,22 +388,23 @@ YShout.prototype = { }, updates: function(updates) { - if (!updates) return; - if (updates.prefs) this.prefs = updates.prefs; - if (updates.posts) this.posts(updates.posts); - if (updates.banned) this.banned(); + if (!updates) {return;} + if (updates.prefs) {this.prefs = updates.prefs;} + if (updates.posts) {this.posts(updates.posts);} + if (updates.banned) {this.banned();} }, banned: function() { var self = this; clearInterval(this.refreshTimer); clearInterval(this.floodTimer); - if (this.initializing) + if (this.initializing) { $('#ys-post-form').css('display', 'none'); - else + } else { $('#ys-post-form').fadeOut(this.animSpeed); - - if ($('#ys-banned').length == 0) { + } + + if ($('#ys-banned').length === 0) { $('#ys-input-message')[0].blur(); $('#ys-posts').append('<div id="ys-banned"><span>You\'re banned. Click <a href="#" id="ys-unban-self">here</a> to unban yourself if you\'re an admin. If you\'re not, go <a href="' + this.options.yPath + 'cp/index.php" id="ys-banned-cp-link">log in</a>!</span></div>'); @@ -411,14 +415,15 @@ YShout.prototype = { $('#ys-unban-self').click(function() { self.ajax(function(json) { - if (!json.error) + if (!json.error) { self.unbanned(); - else if (json.error == 'admin') + } else if (json.error === 'admin') { alert('You can only unban yourself if you\'re an admin.'); + } }, { reqType: 'unbanself' }); return false; }); - } + } }, unbanned: function() { @@ -452,9 +457,9 @@ YShout.prototype = { var d = date(ts); var h = d.getHours(), m = d.getMinutes(); - if (self.prefs.timestamp == 12) { + if (self.prefs.timestamp === 12) { h = (h > 12 ? h - 12 : h); - if (h == 0) h = 12; + if (h === 0) { h = 12; } } return pad(h) + ':' + pad(m); @@ -463,15 +468,15 @@ YShout.prototype = { var dateStr = function(ts) { var t = date(ts); - var Y = t.getFullYear(); - var M = t.getMonth(); - var D = t.getDay(); - var d = t.getDate(); - var day = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][D]; - var mon = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', - 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][M]; + var Y = t.getFullYear(); + var M = t.getMonth(); + var D = t.getDay(); + var d = t.getDate(); + var day = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][D]; + var mon = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][M]; - return day + ' ' + mon + '. ' + d + ', ' + Y; + return day + ' ' + mon + '. ' + d + ', ' + Y; }; var self = this; @@ -488,18 +493,19 @@ YShout.prototype = { (this.prefs.timestamp> 0 ? '<span class="ys-post-timestamp">' + time(post.timestamp) + '</span> ' : '') + '<span class="ys-post-nickname">' + post.nickname + this.prefs.nicknameSeparator + '</span> ' + '<span class="ys-post-message">' + post.message + '</span> ' + - '<span class="ys-post-info' + (this.prefs.info == 'overlay' ? ' ys-info-overlay' : ' ys-info-inline') + '">' + (post.adminInfo ? '<em>IP:</em> ' + post.adminInfo.ip + ', ' : '') + '<em>Posted:</em> ' + dateStr(post.timestamp) + ' at ' + time(post.timestamp) + '.</span>' + + '<span class="ys-post-info' + (this.prefs.info === 'overlay' ? ' ys-info-overlay' : ' ys-info-inline') + '">' + (post.adminInfo ? '<em>IP:</em> ' + post.adminInfo.ip + ', ' : '') + '<em>Posted:</em> ' + dateStr(post.timestamp) + ' at ' + time(post.timestamp) + '.</span>' + '<span class="ys-post-actions"><a title="Show post information" class="ys-info-link" href="#">Info</a>' + (post.adminInfo ? ' | <a title="Delete post" class="ys-delete-link" href="#">Delete</a> | ' + (post.banned ? '<a title="Unban user" class="ys-ban-link" href="#">Unban</a>' : '<a title="Ban user" class="ys-ban-link" href="#">Ban</a>') : '') + '</span>' + '</div>'; - if (this.prefs.inverse) $('#ys-posts').prepend(html); - else $('#ys-posts').append(html); + if (this.prefs.inverse) { $('#ys-posts').prepend(html); } + else { $('#ys-posts').append(html); } this.p.push(post); $('#' + id) .find('.ys-post-nickname').click(function() { - if (post.adminInfo) + if (post.adminInfo) { self.findBySame(post.adminInfo.ip); + } }).end() .find('.ys-info-link').toggle( function() { self.showInfo.apply(self, [id, this]); return false; }, @@ -515,22 +521,24 @@ YShout.prototype = { showInfo: function(id, el) { var jEl = $('#' + id + ' .ys-post-info'); - if (this.prefs.info == 'overlay') + if (this.prefs.info === 'overlay') { jEl.css('display', 'block').fadeIn(this.animSpeed); - else + } else { jEl.slideDown(this.animSpeed); + } - el.innerHTML ='Close Info' + el.innerHTML = 'Close Info'; return false; }, hideInfo: function(id, el) { var jEl = $('#' + id + ' .ys-post-info'); - if (this.prefs.info == 'overlay') + if (this.prefs.info === 'overlay') { jEl.fadeOut(this.animSpeed); - else + } else { jEl.slideUp(this.animSpeed); - + } + el.innerHTML = 'Info'; return false; }, @@ -558,26 +566,24 @@ YShout.prototype = { return; } //alert('p: ' + this.p + ' / ' + this.p.length); - if (json.bannedSelf) + if (json.bannedSelf) { self.banned(); // ? - - else + } else { $.each(self.p, function(i) { - if (this.adminInfo && this.adminInfo.ip == post.adminInfo.ip) + if (this.adminInfo && this.adminInfo.ip === post.adminInfo.ip) { $('#' + this.id) .addClass('ys-banned-post') .find('.ys-ban-link').html('Unban'); + } }); - + } }, pars); link.innerHTML = 'Banning...'; return false; - break; case 'Banning...': return false; - break; case 'Unban': var pars = { @@ -591,26 +597,24 @@ YShout.prototype = { case 'admin': self.error('You\'re not an admin. Log in through the Admin CP to unban people.'); return; - break; } } $.each(self.p, function(i) { - if (this.adminInfo && this.adminInfo.ip == post.adminInfo.ip) + if (this.adminInfo && this.adminInfo.ip === post.adminInfo.ip) { $('#' + this.id) .removeClass('ys-banned-post') .find('.ys-ban-link').html('Ban'); + } }); }, pars); link.innerHTML = 'Unbanning...'; return false; - break; case 'Unbanning...': return false; - break; } }, @@ -618,7 +622,7 @@ YShout.prototype = { var self = this; var link = $('#' + id).find('.ys-delete-link')[0]; - if (link.innerHTML == 'Deleting...') return; + if (link.innerHTML === 'Deleting...') { return; } var pars = { reqType: 'delete', @@ -631,7 +635,6 @@ YShout.prototype = { case 'admin': self.error('You\'re not an admin. Log in through the Admin CP to ban people.'); return; - break; } } self.reload(); @@ -639,15 +642,15 @@ YShout.prototype = { link.innerHTML = 'Deleting...'; return false; - }, banSelf: function(reason) { var self = this; this.ajax(function(json) { - if (json.error == false) + if (json.error === false) { self.banned(); + } }, { reqType: 'banself', nickname: $('#ys-input-nickname').val() @@ -711,22 +714,24 @@ YShout.prototype = { truncate: function(clearAll) { var truncateTo = clearAll ? 0 : this.prefs.truncate; var posts = $('#ys-posts .ys-post').length; - if (posts <= truncateTo) return; + if (posts <= truncateTo) { return; } //alert(this.initializing); if (this.prefs.doTruncate || this.initializing) { var diff = posts - truncateTo; - for (var i = 0; i < diff; i++) + for (var i = 0; i < diff; i++) { this.p.shift(); + } // $('#ys-posts .ys-post:gt(' + truncateTo + ')').remove(); - if (this.prefs.inverse) + if (this.prefs.inverse) { $('#ys-posts .ys-post:gt(' + (truncateTo - 1) + ')').remove(); - else + } else { $('#ys-posts .ys-post:lt(' + (posts - truncateTo) + ')').remove(); + } } - this.markEnds(); + this.markEnds(); }, markEnds: function() { @@ -767,11 +772,11 @@ YShout.prototype = { json: function(parse) { this.d('In json: ' + parse); var json = eval('(' + parse + ')'); - if (!this.checkError(json)) return json; + if (!this.checkError(json)) { return json; } }, checkError: function(json) { - if (!json.yError) return false; + if (!json.yError) { return false; } this.d('Error: ' + json.yError); return true; @@ -790,10 +795,8 @@ YShout.prototype = { dataType: html ? 'text' : 'json', data: pars, success: function(parse) { -var arr = [parse]; - + var arr = [parse]; callback.apply(self, arr); - } }); }, From 21e1359b86a94e09f644d1d9039875d31ef63ee3 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Sun, 20 Apr 2014 05:07:26 -0400 Subject: [PATCH 03/66] Avoid short open tag for PHP. --- ext/chatbox/history/index.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ext/chatbox/history/index.php b/ext/chatbox/history/index.php index fd3d8e02..aadd2853 100644 --- a/ext/chatbox/history/index.php +++ b/ext/chatbox/history/index.php @@ -83,7 +83,6 @@ if (isset($_POST['p'])) { } ?> - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> @@ -109,13 +108,13 @@ if (isset($_POST['p'])) { <div id="top"> <h1>YShout.History</h1> <div id="controls"> - <? if($admin) : ?> + <?php if($admin) : ?> <a id="clear-log" href="#">Clear this log</a>, or <a id="clear-logs" href="#">Clear all logs</a>. - <? endif; ?> + <?php endif; ?> <select id="log"> - <? + <?php for ($i = 1; $i <= $prefs['logs']; $i++) echo '<option' . ($log == $i ? ' selected' : '') . ' rel="' . $i . '">Log ' . $i . '</option>' . "\n"; ?> From 8cdf91982751ad5becbedcb3a96f0542f7bd2265 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Wed, 23 Apr 2014 22:43:42 -0400 Subject: [PATCH 04/66] More linting. This time of the JavaScript for the chat-box extension. --- ext/chatbox/cp/js/admincp.js | 105 +++++++++++++++++------------- ext/chatbox/history/js/history.js | 59 ++++++++--------- 2 files changed, 87 insertions(+), 77 deletions(-) diff --git a/ext/chatbox/cp/js/admincp.js b/ext/chatbox/cp/js/admincp.js index ba4ca788..3fe93b27 100644 --- a/ext/chatbox/cp/js/admincp.js +++ b/ext/chatbox/cp/js/admincp.js @@ -1,7 +1,11 @@ +/*jshint bitwise:true, curly:true, devel:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + Array.prototype.inArray = function (value) { - for (var i = 0; i < this.length; i++) - if (this[i] === value) + for (var i = 0; i < this.length; i++) { + if (this[i] === value) { return true; + } + } return false; }; @@ -25,8 +29,9 @@ AdminCP.prototype = { this.initializing = true; this.loginForm(); this.initEvents(); - if (this.loaded()) this.afterLogin(); - else { + if (this.loaded()) { + this.afterLogin(); + } else { $('#login-password')[0].focus(); } @@ -54,10 +59,11 @@ AdminCP.prototype = { $('.logout').click(function() { self.logout(); return false; }); // Show the nav - if (this.initializing) + if (this.initializing) { $('#nav ul').css('display', 'block'); - else + } else { $('#nav ul').slideDown(); + } // Some css for betterlookingness $('#preferences-form fieldset:odd').addClass('odd'); @@ -75,10 +81,11 @@ AdminCP.prototype = { // If they want to go directly to a section var anchor = this.getAnchor(); - if (anchor.length > 0 && ['preferences', 'bans', 'about'].inArray(anchor)) + if (anchor.length > 0 && ['preferences', 'bans', 'about'].inArray(anchor)) { self.show(anchor); - else + } else { self.show('preferences'); + } }, initEventsAfter: function() { @@ -101,15 +108,16 @@ AdminCP.prototype = { // Preferences $('#preferences-form input').keypress(function(e) { var key = window.event ? e.keyCode : e.which; - if (key == 13 || key == 3) { + if (key === 13 || key === 3) { self.changePref.apply(self, [$(this).attr('rel'), this.value]); return false; } }).focus(function() { this.name = this.value; }).blur(function() { - if (this.name != this.value) + if (this.name !== this.value) { self.changePref.apply(self, [$(this).attr('rel'), this.value]); + } }); $('#preferences-form select').change(function() { @@ -125,10 +133,11 @@ AdminCP.prototype = { 'value': value }; this.ajax(function(json) { - if (!json.error) + if (!json.error) { this.done(); - else + } else { alert(json.error); + } }, pars); }, @@ -137,20 +146,20 @@ AdminCP.prototype = { var pars = { mode: 'resetpreferences' - } + }; this.ajax(function(json) { this.done(); - if (json.prefs) - for(pref in json.prefs) { + if (json.prefs) { + for (pref in json.prefs) { var value = json.prefs[pref]; var el = $('#preferences-form input[@rel=' + pref + '], select[@rel=' + pref + ']')[0]; - if (el.type == 'text') + if (el.type === 'text') { el.value = value; - else { - if (value == true) value = 'true'; - if (value == false) value = 'false'; + } else { + if (value === true) { value = 'true'; } + if (value === false) { value = 'false'; } $('#preferences-form select[@rel=' + pref + ']') .find('option') @@ -158,11 +167,10 @@ AdminCP.prototype = { .end() .find('option[@rel=' + value + ']') .attr('selected', 'yeah'); - } } - }, pars); - + } + }, pars); }, invalidPassword: function() { @@ -230,49 +238,53 @@ AdminCP.prototype = { // if (!sections.inArray(section)) section = 'preferences'; if ($.browser.msie) { - if (section == 'preferences') + if (section === 'preferences') { $('#preferences select').css('display', 'block'); - else + } else { $('#preferences select').css('display', 'none'); + } } - if (section == this.curSection) return; + if (section === this.curSection) { return; } + this.curSection = section; $('#' + section)[0].style.zIndex = ++this.z; - if (this.initializing) + + if (this.initializing) { $('#' + section).css('display', 'block'); - else + } else { $('#' + section).fadeIn(this.animSpeed, callback); + } }, showPrefPane: function(pane) { var self = this; - if (pane == this.curPrefPane) return; + if (pane === this.curPrefPane) { return; } this.curPrefPane = pane; $('#preferences .cp-pane').css('display', 'none'); $('#cp-pane-' + pane).css('display', 'block').fadeIn(this.animSpeed, function() { - if (self.curPrefPane == pane) + if (self.curPrefPane === pane) { $('#preferences .cp-pane').not('#cp-pane-' + pane).css('display', 'none'); - else + } else { $('#cp-pane-' + pane).css('display', 'none'); - + } }); }, showAboutPane: function(pane) { var self = this; - if (pane == this.curAboutPane) return; + if (pane === this.curAboutPane) { return; } this.curAboutPane = pane; $('#about .cp-pane').css('display', 'none'); $('#cp-pane-' + pane).css('display', 'block').fadeIn(this.animSpeed, function() { - if (self.curAboutPane == pane) + if (self.curAboutPane === pane) { $('#about .cp-pane').not('#cp-pane-' + pane).css('display', 'none'); - else + } else { $('#cp-pane-' + pane).css('display', 'none'); - + } }); }, @@ -281,13 +293,15 @@ AdminCP.prototype = { $.post('ajax.php', pars, function(parse) { // alert(parse); - if (parse) - if (html) + if (parse) { + if (html) { callback.apply(self, [parse]); - else + } else { callback.apply(self, [self.json(parse)]); - else + } + } else { callback.apply(self); + } }); }, @@ -297,7 +311,7 @@ AdminCP.prototype = { }, loaded: function() { - return ($('#cp-loaded').length == 1); + return ($('#cp-loaded').length === 1); }, loading: function() { @@ -325,10 +339,11 @@ AdminCP.prototype = { }, getAnchor: function() { - var href = window.location.href; - if (href.indexOf('#') > -1 ) - return href.substr(href.indexOf('#') + 1).toLowerCase(); - return ''; + var href = window.location.href; + if (href.indexOf('#') > -1 ) { + return href.substr(href.indexOf('#') + 1).toLowerCase(); + } + return ''; }, unban: function(ip, el) { @@ -357,7 +372,7 @@ AdminCP.prototype = { var pars = { mode: 'unbanall' - } + }; this.ajax(function(json) { this.done(); diff --git a/ext/chatbox/history/js/history.js b/ext/chatbox/history/js/history.js index c301bde4..438c5c90 100644 --- a/ext/chatbox/history/js/history.js +++ b/ext/chatbox/history/js/history.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, devel:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + var History = function() { var self = this; var args = arguments; @@ -17,13 +19,11 @@ History.prototype = { $('body').ScrollToAnchors({ duration: 800 }); }, - initEvents: function() { var self = this; this.initLogEvents(); - // Select log $('#log').change(function() { var logIndex = $(this).find('option[@selected]').attr('rel'); @@ -31,15 +31,13 @@ History.prototype = { var pars = { p: 'yes', log: logIndex - } + }; self.ajax(function(html) { - $('#ys-posts').html(html) + $('#ys-posts').html(html); $('#yshout').fadeIn(); self.initLogEvents(); }, pars, true, 'index.php'); - - }); // Clear the log @@ -56,13 +54,12 @@ History.prototype = { self.error('You\'re not an admin. Log in through the admin CP to clear the log.'); el.innerHTML = 'Clear this log'; return; - break; } } $('#ys-posts').html(self.noPosts); self.initLogEvents(); - el.innerHTML = 'Clear this log' + el.innerHTML = 'Clear this log'; }, pars); this.innerHTML = 'Clearing...'; @@ -80,16 +77,15 @@ History.prototype = { if (json.error) { switch(json.error) { case 'admin': - el.innerHTML = 'Clear all logs' + el.innerHTML = 'Clear all logs'; self.error('You\'re not an admin. Log in through the admin CP to clear logs.'); return; - break; } } $('#ys-posts').html(self.noPosts); self.initLogEvents(); - el.innerHTML = 'Clear all logs' + el.innerHTML = 'Clear all logs'; }, pars); this.innerHTML = 'Clearing...'; @@ -115,27 +111,29 @@ History.prototype = { showInfo: function(id, el) { var jEl = $('#' + id + ' .ys-post-info'); - if (jEl.length == 0) return false; + if (jEl.length === 0) { return false; } - if (this.prefsInfo == 'overlay') + if (this.prefsInfo === 'overlay') { jEl.css('display', 'block').fadeIn(this.animSpeed); - else + } else { jEl.slideDown(this.animSpeed); + } - el.innerHTML ='Close Info' + el.innerHTML ='Close Info'; return false; }, hideInfo: function(id, el) { var jEl = $('#' + id + ' .ys-post-info'); - if (jEl.length == 0) return false; + if (jEl.length === 0) { return false; } - if (this.prefsInfo == 'overlay') + if (this.prefsInfo === 'overlay') { jEl.fadeOut(this.animSpeed); - else + } else { jEl.slideUp(this.animSpeed); - + } + el.innerHTML = 'Info'; return false; }, @@ -144,7 +142,8 @@ History.prototype = { var self = this; var link = $('#' + post.id).find('.ys-ban-link')[0]; - switch(link.innerHTML) { + switch(link.innerHTML) + { case 'Ban': var pIP = $(post).find('.ys-h-ip').html(); var pNickname = $(post).find('.ys-h-nickname').html(); @@ -175,11 +174,9 @@ History.prototype = { link.innerHTML = 'Banning...'; return false; - break; case 'Banning...': return false; - break; case 'Unban': var pIP = $(post).find('.ys-h-ip').html(); @@ -194,7 +191,6 @@ History.prototype = { case 'admin': self.error('You\'re not an admin. Log in through the admin CP to unban people.'); return; - break; } } @@ -207,11 +203,9 @@ History.prototype = { link.innerHTML = 'Unbanning...'; return false; - break; case 'Unbanning...': return false; - break; } }, @@ -219,7 +213,7 @@ History.prototype = { var self = this; var link = $('#' + post.id).find('.ys-delete-link')[0]; - if (link.innerHTML == 'Deleting...') return; + if (link.innerHTML === 'Deleting...') { return; } var pUID = $(post).find('.ys-h-uid').html(); @@ -234,7 +228,6 @@ History.prototype = { case 'admin': self.error('You\'re not an admin. Log in through the admin CP to ban people.'); return; - break; } } @@ -260,16 +253,18 @@ History.prototype = { var self = this; - if (page == null) page = '../yshout.php'; + if (page === null) { page = '../yshout.php'; } $.post(page, pars, function(parse) { - if (parse) - if (html) + if (parse) { + if (html) { callback.apply(self, [parse]); - else + } else { callback.apply(self, [self.json(parse)]); - else + } + } else { callback.apply(self); + } }); }, From a0ab3864c08f16371b50d0524608303e3a056f8c Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Wed, 23 Apr 2014 23:01:51 -0400 Subject: [PATCH 05/66] Push the headers for the chatbox even further down to make sure that jQuery is already loaded. --- ext/chatbox/js/yshout.js | 2 +- ext/chatbox/main.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/chatbox/js/yshout.js b/ext/chatbox/js/yshout.js index 7aa85963..f54d6dda 100644 --- a/ext/chatbox/js/yshout.js +++ b/ext/chatbox/js/yshout.js @@ -382,7 +382,7 @@ YShout.prototype = { same.push(this.p[i]); } } - + for (var j = 0; j < same.length; j++) { $('#' + same[j].id).fadeTo(this.animSpeed, 0.8).fadeTo(this.animSpeed, 1); } diff --git a/ext/chatbox/main.php b/ext/chatbox/main.php index 8d52bd6a..7951492d 100644 --- a/ext/chatbox/main.php +++ b/ext/chatbox/main.php @@ -25,7 +25,7 @@ class Chatbox extends Extension { nickname = '{$user->name}'; new YShout({ yPath: '$yPath' }); </script> - ", 500); + ", 5000); // loads the chatbox at the set location $html = "<div id=\"yshout\"></div>"; From b775c007cd1acc115cd0cc12229a864d35e88337 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Wed, 23 Apr 2014 23:07:10 -0400 Subject: [PATCH 06/66] Give these HTML headers some slight priority over the default value of 50. --- core/page.class.php | 12 ++++++------ ext/chatbox/main.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/page.class.php b/core/page.class.php index f56a4d46..db588e94 100644 --- a/core/page.class.php +++ b/core/page.class.php @@ -251,11 +251,11 @@ class Page { $data_href = get_base_href(); $theme_name = $config->get_string('theme', 'default'); - $this->add_html_header("<script type='text/javascript'>base_href = '$data_href';</script>"); + $this->add_html_header("<script type='text/javascript'>base_href = '$data_href';</script>", 40); # 404/static handler will map these to themes/foo/bar.ico or lib/static/bar.ico - $this->add_html_header("<link rel='icon' type='image/x-icon' href='$data_href/favicon.ico'>"); - $this->add_html_header("<link rel='apple-touch-icon' href='$data_href/apple-touch-icon.png'>"); + $this->add_html_header("<link rel='icon' type='image/x-icon' href='$data_href/favicon.ico'>", 41); + $this->add_html_header("<link rel='apple-touch-icon' href='$data_href/apple-touch-icon.png'>", 42); $css_files = array(); $css_latest = 0; @@ -275,7 +275,7 @@ class Page { } file_put_contents($css_cache_file, $css_data); } - $this->add_html_header("<link rel='stylesheet' href='$data_href/$css_cache_file' type='text/css'>"); + $this->add_html_header("<link rel='stylesheet' href='$data_href/$css_cache_file' type='text/css'>", 43); $js_files = array(); $js_latest = 0; @@ -291,10 +291,10 @@ class Page { } file_put_contents($js_cache_file, $js_data); } - $this->add_html_header("<script src='$data_href/$js_cache_file' type='text/javascript'></script>"); + $this->add_html_header("<script src='$data_href/$js_cache_file' type='text/javascript'></script>", 44); } } class MockPage extends Page { } -?> + diff --git a/ext/chatbox/main.php b/ext/chatbox/main.php index 7951492d..8d52bd6a 100644 --- a/ext/chatbox/main.php +++ b/ext/chatbox/main.php @@ -25,7 +25,7 @@ class Chatbox extends Extension { nickname = '{$user->name}'; new YShout({ yPath: '$yPath' }); </script> - ", 5000); + ", 500); // loads the chatbox at the set location $html = "<div id=\"yshout\"></div>"; From 2dc6e054c8c58e89729cc61b63ca4df6dc2453f9 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Wed, 23 Apr 2014 23:28:05 -0400 Subject: [PATCH 07/66] These sorts are necessary on the header arrays, otherwise the relative priority of certain headers is not respected. --- themes/lite/layout.class.php | 1 + themes/warm/layout.class.php | 1 + 2 files changed, 2 insertions(+) diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index 3cf8e9d9..b8b480fe 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -20,6 +20,7 @@ class Layout { $contact_link = $config->get_string('contact_link'); $header_html = ""; + ksort($page->html_headers); foreach($page->html_headers as $line) { $header_html .= "\t\t$line\n"; } diff --git a/themes/warm/layout.class.php b/themes/warm/layout.class.php index afac42b0..46e79774 100644 --- a/themes/warm/layout.class.php +++ b/themes/warm/layout.class.php @@ -16,6 +16,7 @@ class Layout { $contact_link = $config->get_string('contact_link'); $header_html = ""; + ksort($page->html_headers); foreach($page->html_headers as $line) { $header_html .= "\t\t$line\n"; } From 31501e48fe73898525336d9b118a563090bfae8b Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Wed, 23 Apr 2014 23:31:20 -0400 Subject: [PATCH 08/66] More JS linting. --- lib/shimmie.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/shimmie.js b/lib/shimmie.js index 2a1f09ed..457cb71b 100644 --- a/lib/shimmie.js +++ b/lib/shimmie.js @@ -1,3 +1,4 @@ +/*jshint bitwise:false, curly:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:false, strict:false, browser:true */ // Adding jQuery ui stuff $(document).ready(function() { @@ -49,7 +50,7 @@ $(document).ready(function() { if(sidebar_hidden.hasOwnProperty(i) && sidebar_hidden[i].length > 0) { $(sidebar_hidden[i]+" .blockbody").hide(); } - }; + } } catch(err) { var sidebar_hidden = []; @@ -59,7 +60,7 @@ $(document).ready(function() { var tob = $(tid+" .blockbody"); $(elm).click(function(e) { tob.slideToggle("slow"); - if(sidebar_hidden.indexOf(tid) == -1) { + if(sidebar_hidden.indexOf(tid) === -1) { sidebar_hidden.push(tid); } else { @@ -70,7 +71,7 @@ $(document).ready(function() { } } $.cookie("ui-sidebar-hidden", sidebar_hidden.join("|"), {path: '/', expires: 365}); - }) + }); }); $(".shm-unlocker").each(function(idx, elm) { @@ -143,9 +144,9 @@ function getCookie( name ) { if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) { return null; } - if ( start == -1 ) return null; + if ( start === -1 ) { return null; } var end = document.cookie.indexOf( ";", len ); - if ( end == -1 ) end = document.cookie.length; + if ( end === -1 ) { end = document.cookie.length; } return unescape( document.cookie.substring( len, end ) ); } @@ -164,10 +165,11 @@ function setCookie( name, value, expires, path, domain, secure ) { } function deleteCookie( name, path, domain ) { - if ( getCookie( name ) ) document.cookie = name + "=" + + if ( getCookie( name ) ) { document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; + } } function replyTo(imageId, commentId, userId) { From 887f963e178e084bf0d6440ab6d979cbad2184d0 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Wed, 23 Apr 2014 23:38:53 -0400 Subject: [PATCH 09/66] Add the jshint comment to alter how scrutinzer-ci deals with the js. --- ext/blotter/script.js | 2 ++ ext/tagger/script.js | 2 ++ ext/tagger/webtoolkit.drag.js | 2 ++ ext/twitter_soc/script.js | 2 ++ ext/update/script.js | 2 ++ ext/upload/bookmarklet.js | 2 ++ 6 files changed, 12 insertions(+) diff --git a/ext/blotter/script.js b/ext/blotter/script.js index e2f4f892..05b65ff1 100644 --- a/ext/blotter/script.js +++ b/ext/blotter/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + $(document).ready(function() { $(".shm-blotter2-toggle").click(function() { $(".shm-blotter2").slideToggle("slow", function() { diff --git a/ext/tagger/script.js b/ext/tagger/script.js index e01c8168..282ec02e 100644 --- a/ext/tagger/script.js +++ b/ext/tagger/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Tagger - Advanced Tagging v2 * * Author: Artanis (Erik Youngren <artanis.00@gmail.com>) * diff --git a/ext/tagger/webtoolkit.drag.js b/ext/tagger/webtoolkit.drag.js index 3ba87507..325f89a7 100644 --- a/ext/tagger/webtoolkit.drag.js +++ b/ext/tagger/webtoolkit.drag.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + /** * * Crossbrowser Drag Handler diff --git a/ext/twitter_soc/script.js b/ext/twitter_soc/script.js index 06457f3a..839a19a5 100644 --- a/ext/twitter_soc/script.js +++ b/ext/twitter_soc/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + // jquery.tweet.js - See http://tweet.seaofclouds.com/ or https://github.com/seaofclouds/tweet for more info // Copyright (c) 2008-2011 Todd Matthews & Steve Purcell (function($) { diff --git a/ext/update/script.js b/ext/update/script.js index dea04c24..c2719786 100644 --- a/ext/update/script.js +++ b/ext/update/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + $(function() { if($('#updatecheck').length !== 0){ $.getJSON('https://api.github.com/repos/shish/shimmie2/commits', function(data){ diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index 0c4dda31..12597503 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + /* Imageboard to Shimmie */ // This should work with "most" sites running Danbooru/Gelbooru/Shimmie // maxsize, supext, CA are set inside the bookmarklet (see theme.php) From a105090039a96cf230f5b81d109e167e59631b18 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Wed, 23 Apr 2014 23:39:09 -0400 Subject: [PATCH 10/66] Some more JS linting. --- ext/blotter/script.js | 2 +- ext/tag_editcloud/script.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/blotter/script.js b/ext/blotter/script.js index 05b65ff1..25e3188c 100644 --- a/ext/blotter/script.js +++ b/ext/blotter/script.js @@ -11,7 +11,7 @@ $(document).ready(function() { } }); }); - if($.cookie("ui-blotter2-hidden") == 'true') { + if($.cookie("ui-blotter2-hidden") === 'true') { $(".shm-blotter2").hide(); } }); diff --git a/ext/tag_editcloud/script.js b/ext/tag_editcloud/script.js index b71818c4..377fa469 100644 --- a/ext/tag_editcloud/script.js +++ b/ext/tag_editcloud/script.js @@ -1,16 +1,18 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + Array.prototype.editcloud_contains = function (ele) { for (var i = 0; i < this.length; i++) { - if (this[i] == ele) { + if (this[i] === ele) { return true; } } return false; }; Array.prototype.editcloud_remove = function (ele) { - var arr = new Array(); + var arr = []; var count = 0; for (var i = 0; i < this.length; i++) { - if (this[i] != ele) { + if (this[i] !== ele) { arr[count] = this[i]; count++; } @@ -25,8 +27,8 @@ function tageditcloud_toggle_extra(hide) { } var el = document.getElementById('tagcloud_extra'); - el.style.display = (el.style.display != 'none' ? 'none' : '' ); - hide.innerHTML = (el.style.display != 'none' ? 'show fewer tags' : hide_text ); + el.style.display = (el.style.display !== 'none' ? 'none' : '' ); + hide.innerHTML = (el.style.display !== 'none' ? 'show fewer tags' : hide_text ); } function tageditcloud_toggle_tag(ele,fullTag) { From 4b90faf89d6aa7b4108a35d26479757fdf79c84b Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 00:55:14 -0400 Subject: [PATCH 11/66] Even more linting of JS files. --- ext/mass_tagger/script.js | 2 ++ ext/notes/script.js | 14 ++++++++------ ext/pools/script.js | 2 ++ ext/tagger/script.js | 2 +- ext/twitter_soc/script.js | 22 +++++++++++----------- lib/shimmie.js | 2 +- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/ext/mass_tagger/script.js b/ext/mass_tagger/script.js index 1cc4077c..966e8ac2 100644 --- a/ext/mass_tagger/script.js +++ b/ext/mass_tagger/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + function activate_mass_tagger ( image_link ) { $(".shm-thumb").each( function ( index, block ) { diff --git a/ext/notes/script.js b/ext/notes/script.js index c8bafab7..43f492b2 100644 --- a/ext/notes/script.js +++ b/ext/notes/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + $(function() { if(window.notes) { $('#main_image').imgNotes({notes: window.notes}); @@ -36,9 +38,9 @@ $(function() { }); function showaddnote (img, area) { - imgOffset = $(img).offset(); - form_left = parseInt(imgOffset.left) + parseInt(area.x1); - form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5; + var imgOffset = $(img).offset(); + var form_left = parseInt(imgOffset.left) + parseInt(area.x1); + var form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5; $('#noteform').css({ left: form_left + 'px', top: form_top + 'px'}); $('#noteform').show(); @@ -50,9 +52,9 @@ function showaddnote (img, area) { } function showeditnote (img, area) { - imgOffset = $(img).offset(); - form_left = parseInt(imgOffset.left) + area.x1; - form_top = parseInt(imgOffset.top) + area.y2; + var imgOffset = $(img).offset(); + var form_left = parseInt(imgOffset.left) + area.x1; + var form_top = parseInt(imgOffset.top) + area.y2; $('#noteEditForm').css({ left: form_left + 'px', top: form_top + 'px'}); $('#noteEditForm').show(); diff --git a/ext/pools/script.js b/ext/pools/script.js index 505718a9..c5e91d4e 100644 --- a/ext/pools/script.js +++ b/ext/pools/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ + $(function() { var order_pool = $.cookie("shm_ui-order-pool") || "created"; $("#order_pool option[value="+order_pool+"]").attr("selected", true); diff --git a/ext/tagger/script.js b/ext/tagger/script.js index 282ec02e..7a10f162 100644 --- a/ext/tagger/script.js +++ b/ext/tagger/script.js @@ -44,7 +44,7 @@ var Tagger = { var id = "tagger_alert-"+type var t_alert = byId(id); if (t_alert) { - if(text == false) { + if(text === false) { // remove t_alert.parentNode.removeChild(t_alert); } else { diff --git a/ext/twitter_soc/script.js b/ext/twitter_soc/script.js index 839a19a5..62e316d0 100644 --- a/ext/twitter_soc/script.js +++ b/ext/twitter_soc/script.js @@ -29,7 +29,7 @@ twitter_search_url: "search.twitter.com", // [string] custom twitter search url, if any (apigee, etc.) template: "{avatar}{time}{join}{text}", // [string or function] template used to construct each tweet <li> - see code for available vars comparator: function(tweet1, tweet2) { // [function] comparator used to sort tweets (see Array.sort) - return tweet2["tweet_time"] - tweet1["tweet_time"]; + return tweet2.tweet_time - tweet1.tweet_time; }, filter: function(tweet) { // [function] whether or not to include a particular tweet (be sure to also set 'fetch') return true; @@ -48,7 +48,7 @@ result = result.replace(new RegExp('{'+key+'}','g'), val === null ? '' : val); } return result; - } else return template(info); + } else { return template(info); } } // Export the t function for use when passing a function as the 'template' option $.extend({tweet: {t: t}}); @@ -71,7 +71,7 @@ linkUser: replacer(/(^|[\W])@(\w+)/gi, "$1@<a href=\"http://"+s.twitter_url+"/$2\">$2</a>"), // Support various latin1 (\u00**) and arabic (\u06**) alphanumeric chars linkHash: replacer(/(?:^| )[\#]+([\w\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0600-\u06ff]+)/gi, - ' <a href="http://'+s.twitter_search_url+'/search?q=&tag=$1&lang=all'+((s.username && s.username.length == 1 && !s.list) ? '&from='+s.username.join("%2BOR%2B") : '')+'">#$1</a>'), + ' <a href="http://'+s.twitter_search_url+'/search?q=&tag=$1&lang=all'+((s.username && s.username.length === 1 && !s.list) ? '&from='+s.username.join("%2BOR%2B") : '')+'">#$1</a>'), capAwesome: replacer(/\b(awesome)\b/gi, '<span class="awesome">$1</span>'), capEpic: replacer(/\b(epic)\b/gi, '<span class="epic">$1</span>'), makeHeart: replacer(/(<)+[3]/gi, "<tt class='heart'>♥</tt>") @@ -83,7 +83,7 @@ var text = match; for(var i = 0; i < entities.length; ++i) { var entity = entities[i]; - if (entity.url == url && entity.expanded_url) { + if (entity.url === url && entity.expanded_url) { url = entity.expanded_url; text = entity.display_url; break; @@ -139,14 +139,14 @@ } function build_api_url() { - var proto = ('https:' == document.location.protocol ? 'https:' : 'http:'); + var proto = ('https:' === document.location.protocol ? 'https:' : 'http:'); var count = (s.fetch === null) ? s.count : s.fetch; var common_params = '&include_entities=1&callback=?'; if (s.list) { return proto+"//"+s.twitter_api_url+"/1/"+s.username[0]+"/lists/"+s.list+"/statuses.json?page="+s.page+"&per_page="+count+common_params; } else if (s.favorites) { return proto+"//"+s.twitter_api_url+"/favorites/"+s.username[0]+".json?page="+s.page+"&count="+count+common_params; - } else if (s.query === null && s.username.length == 1) { + } else if (s.query === null && s.username.length === 1) { return proto+'//'+s.twitter_api_url+'/1/statuses/user_timeline.json?screen_name='+s.username[0]+'&count='+count+(s.retweets ? '&include_rts=1' : '')+'&page='+s.page+common_params; } else { var query = (s.query || 'from:'+s.username.join(' OR from:')); @@ -174,9 +174,9 @@ o.screen_name = item.from_user || item.user.screen_name; o.avatar_size = s.avatar_size; o.avatar_url = extract_avatar_url(item, (document.location.protocol === 'https:')); - o.retweet = typeof(item.retweeted_status) != 'undefined'; + o.retweet = typeof(item.retweeted_status) !== 'undefined'; o.tweet_time = parse_date(item.created_at); - o.join_text = s.join_text == "auto" ? build_auto_join_text(item.text) : s.join_text; + o.join_text = s.join_text === "auto" ? build_auto_join_text(item.text) : s.join_text; o.tweet_id = item.id_str; o.twitter_base = "http://"+s.twitter_url+"/"; o.user_url = o.twitter_base+o.screen_name; @@ -215,10 +215,10 @@ } $(widget).bind("tweet:load", function(){ - if (s.loading_text) $(widget).empty().append(loading); + if (s.loading_text) { $(widget).empty().append(loading); } $.getJSON(build_api_url(), function(data){ $(widget).empty().append(list); - if (s.intro_text) list.before(intro); + if (s.intro_text) { list.before(intro); } list.empty(); var tweets = $.map(data.results || data, extract_template_data); @@ -228,7 +228,7 @@ children('li:odd').addClass('tweet_even').end(). children('li:even').addClass('tweet_odd'); - if (s.outro_text) list.after(outro); + if (s.outro_text) { list.after(outro); } $(widget).trigger("loaded").trigger((tweets.length === 0 ? "empty" : "full")); if (s.refresh_interval) { window.setTimeout(function() { $(widget).trigger("tweet:load"); }, 1000 * s.refresh_interval); diff --git a/lib/shimmie.js b/lib/shimmie.js index 457cb71b..79419237 100644 --- a/lib/shimmie.js +++ b/lib/shimmie.js @@ -141,7 +141,7 @@ function getHTTPObject() { function getCookie( name ) { var start = document.cookie.indexOf( name + "=" ); var len = start + name.length + 1; - if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) { + if ( ( !start ) && ( name !== document.cookie.substring( 0, name.length ) ) ) { return null; } if ( start === -1 ) { return null; } From 51c145d5c9494cf04d55bb2cb670a85036c694b2 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 01:08:47 -0400 Subject: [PATCH 12/66] Some more linting on the bookmarklet.js file. --- ext/upload/bookmarklet.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index 12597503..26b4766c 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -1,4 +1,4 @@ -/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ +/*jshint bitwise:true, curly:true, devel:true, forin:false, noarg:true, undef:true, strict:false, browser:true, jquery:true */ /* Imageboard to Shimmie */ // This should work with "most" sites running Danbooru/Gelbooru/Shimmie @@ -9,10 +9,7 @@ var toobig = "The file you are trying to upload is too big to upload!"; var notsup = "The file you are trying to upload is not supported!"; if(CA === 0 || CA > 2) { // Default - if(confirm("Keep existing tags?\n(Cancel will prompt for new tags)")) { - // Do nothing - } - else { + if (confirm("Keep existing tags?\n(Cancel will prompt for new tags)") === false) { var tag = prompt("Enter Tags", ""); var chk = 1; // This makes sure it doesn't use current tags. } @@ -41,14 +38,14 @@ if(document.getElementById("post_tag_string") !== null) { var source = "http://" + document.location.hostname + document.location.href.match("\/posts\/[0-9]+"); var rlist = $('[name="post[rating]"]'); - for(x=0;x<3;x++){ - var rating = (rlist[x].checked == true ? rlist[x].value : rating); + for( var x=0; x < 3; x++){ + var rating = (rlist[x].checked === true ? rlist[x].value : rating); } var fileinfo = $('#sidebar > section:eq(3) > ul > :contains("Size") > a'); var furl = "http://" + document.location.hostname + fileinfo.attr('href'); var fs = fileinfo.text().split(" "); - var filesize = (fs[1] == "MB" ? fs[0] * 1024 : fs[0]); + var filesize = (fs[1] === "MB" ? fs[0] * 1024 : fs[0]); if(supext.search(furl.match("[a-zA-Z0-9]+$")[0]) !== -1){ if(filesize <= maxsize){ @@ -86,12 +83,12 @@ else if(document.getElementById('tag-sidebar') !== null) { }else if(source.search("gelbooru\\.com") >= 0){ var fileinfo = document.getElementById('pfd').parentNode.parentNode.getElementsByTagName('a')[0]; //gelbooru has no easy way to select the original image link, so we need to double check it is the correct link. - fileinfo = (fileinfo.getAttribute('href') == "#" ? document.getElementById('pfd').parentNode.parentNode.getElementsByTagName('a')[1] : fileinfo); + fileinfo = (fileinfo.getAttribute('href') === "#" ? document.getElementById('pfd').parentNode.parentNode.getElementsByTagName('a')[1] : fileinfo); } fileinfo = fileinfo || document.getElementsByTagName('embed')[0]; //If fileinfo is null then image is most likely flash. var furl = fileinfo.href || fileinfo.src; var fs = (fileinfo.innerText.match(/[0-9]+ (KB|MB)/) || ["0 KB"])[0].split(" "); - var filesize = (fs[1] == "MB" ? fs[0] * 1024 : fs[0]); + var filesize = (fs[1] === "MB" ? fs[0] * 1024 : fs[0]); if(supext.search(furl.match("[a-zA-Z0-9]+$")[0]) !== -1){ if(filesize <= maxsize){ @@ -118,8 +115,8 @@ else if(document.getElementById('tag-sidebar') !== null) { * This crazy way of checking "should" work with older releases though * (Seems to work with 2009~ ver) */ -else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-]+\: ") == 0) { - if(typeof tag !=="ftp://ftp." && chk !==1) { +else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-]+\: ") === 0) { + if(typeof tag !== "ftp://ftp." && chk !==1) { var tag = document.getElementsByTagName("title")[0].innerHTML.match("Image [0-9.-]+\: (.*)")[1]; } @@ -128,7 +125,7 @@ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.- // TODO: Make file size show on all themes // (Only seems to show in lite/Danbooru themes.) - if(tag.search(/\bflash\b/) == -1) { + if(tag.search(/\bflash\b/) === -1) { var img = document.getElementById("main_image").src; if(supext.search(img.match(".*\\.([a-z0-9]+)")[1]) !== -1) { location.href = ste+img+"&tags="+tag+"&source="+source; From 866d39a68ef5f23d40d31ed590ab7ecf39c373cd Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 01:15:03 -0400 Subject: [PATCH 13/66] The 'tags' box actually has a different ID. --- ext/tag_editcloud/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/tag_editcloud/script.js b/ext/tag_editcloud/script.js index 377fa469..8fb87a1e 100644 --- a/ext/tag_editcloud/script.js +++ b/ext/tag_editcloud/script.js @@ -44,5 +44,5 @@ function tageditcloud_toggle_tag(ele,fullTag) { } taglist.value = tags.join(' '); - document.getElementById('tags').focus(); + document.getElementById('tag_editor').focus(); } From 506e699f8a4881de46e4dfe29cd6540929878251 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 01:15:30 -0400 Subject: [PATCH 14/66] Not sure if we really need the triple equals. --- ext/tag_editcloud/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/tag_editcloud/script.js b/ext/tag_editcloud/script.js index 8fb87a1e..71a9c287 100644 --- a/ext/tag_editcloud/script.js +++ b/ext/tag_editcloud/script.js @@ -1,8 +1,8 @@ -/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ +/*jshint bitwise:true, curly:true, eqeqeq: false, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ Array.prototype.editcloud_contains = function (ele) { for (var i = 0; i < this.length; i++) { - if (this[i] === ele) { + if (this[i] == ele) { return true; } } @@ -12,7 +12,7 @@ Array.prototype.editcloud_remove = function (ele) { var arr = []; var count = 0; for (var i = 0; i < this.length; i++) { - if (this[i] !== ele) { + if (this[i] != ele) { arr[count] = this[i]; count++; } From afc01fda5f282b6109cf666b50e3158afa685c1d Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 01:36:04 -0400 Subject: [PATCH 15/66] Prevent scrutinizer-ci from complaining about these fall-thoughs. --- core/util.inc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/util.inc.php b/core/util.inc.php index b2dfa436..e724c690 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -167,8 +167,11 @@ function parse_shorthand_int($limit) { $value = $m[1]; if (isset($m[2])) { switch(strtolower($m[2])) { + /** @noinspection PhpMissingBreakStatementInspection */ case 'g': $value *= 1024; // fall through + /** @noinspection PhpMissingBreakStatementInspection */ case 'm': $value *= 1024; // fall through + /** @noinspection PhpMissingBreakStatementInspection */ case 'k': $value *= 1024; break; default: $value = -1; } From dbe30ad37d6baad6c06d92643fa82eafb77d2573 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 01:36:30 -0400 Subject: [PATCH 16/66] Rename variable to make it more clear. --- core/imageboard.pack.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 8e21de8b..899855d4 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -682,8 +682,8 @@ class Image { else { $expansions = Tag::resolve_wildcard($term); if($expansions && $positive) $positive_tag_count++; - foreach($expansions as $term) { - $tag_querylets[] = new TagQuerylet($term, $positive); + foreach($expansions as $expanded_term) { + $tag_querylets[] = new TagQuerylet($expanded_term, $positive); } } } From 67c087c30fd50e60383de712263bb948975a9a33 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 04:30:58 -0400 Subject: [PATCH 17/66] From stack-overflow: The 'var' keyword is for declaring class variables in PHP4. It works in PHP5 but can raise an E_STRICT warning in from version 5.0.0 up to version 5.1.2, as it has been deprecated. Changing to public as that is really what these variables are anyways. --- core/imageboard.pack.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 899855d4..bafe738b 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -36,14 +36,14 @@ require_once "lib/flexihash.php"; * sound file, or any other supported upload type. */ class Image { - var $id = null; - var $height, $width; - var $hash, $filesize; - var $filename, $ext; - var $owner_ip; - var $posted; - var $source; - var $locked; + public $id = null; + public $height, $width; + public $hash, $filesize; + public $filename, $ext; + public $owner_ip; + public $posted; + public $source; + public $locked; /** * One will very rarely construct an image directly, more common From f67220f64bdf5dcc1d318e85e92c5f6e408ae984 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 04:36:05 -0400 Subject: [PATCH 18/66] From stack-overflow: The 'var' keyword is for declaring class variables in PHP4. It works in PHP5 but can raise an E_STRICT warning in from version 5.0.0 up to version 5.1.2, as it has been deprecated. Changing to public as that is really what these variables are anyways. --- core/block.class.php | 10 +++++----- core/database.class.php | 8 ++++---- core/email.class.php | 22 +++++++++++----------- core/event.class.php | 6 +++--- core/extension.class.php | 2 +- core/user.class.php | 10 +++++----- core/userclass.class.php | 6 +++--- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/core/block.class.php b/core/block.class.php index 149a0a13..4fd0c28d 100644 --- a/core/block.class.php +++ b/core/block.class.php @@ -8,14 +8,14 @@ class Block { * * @retval string */ - var $header; + public $header; /** * The content * * @retval string */ - var $body; + public $body; /** * Where the block should be placed. The default theme supports @@ -23,7 +23,7 @@ class Block { * * @retval string */ - var $section; + public $section; /** * How far down the section the block should appear, higher @@ -32,12 +32,12 @@ class Block { * * @retval int */ - var $position; + public $position; /** * */ - var $id; + public $id; public function __construct($header, $body, /*string*/ $section="main", /*int*/ $position=50, $id=null) { $this->header = $header; diff --git a/core/database.class.php b/core/database.class.php index 5a889878..c4aface5 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -45,7 +45,7 @@ class ImgQuerylet { // }}} // {{{ db engines class DBEngine { - var $name = null; + public $name = null; public function init($db) {} @@ -58,7 +58,7 @@ class DBEngine { } } class MySQL extends DBEngine { - var $name = "mysql"; + public $name = "mysql"; public function init($db) { $db->exec("SET NAMES utf8;"); @@ -84,7 +84,7 @@ class MySQL extends DBEngine { } } class PostgreSQL extends DBEngine { - var $name = "pgsql"; + public $name = "pgsql"; public function init($db) { $db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';"); @@ -123,7 +123,7 @@ function _concat($a, $b) { return $a . $b; } function _lower($a) { return strtolower($a); } class SQLite extends DBEngine { - var $name = "sqlite"; + public $name = "sqlite"; public function init($db) { ini_set('sqlite.assoc_case', 0); diff --git a/core/email.class.php b/core/email.class.php index 63677b09..82c50c81 100644 --- a/core/email.class.php +++ b/core/email.class.php @@ -4,17 +4,17 @@ class Email { /** * A generic email. */ - var $to; - var $subject; - var $header; - var $style; - var $header_img; - var $sitename; - var $sitedomain; - var $siteemail; - var $date; - var $body; - var $footer; + public $to; + public $subject; + public $header; + public $style; + public $header_img; + public $sitename; + public $sitedomain; + public $siteemail; + public $date; + public $body; + public $footer; public function __construct($to, $subject, $header, $body) { global $config; diff --git a/core/event.class.php b/core/event.class.php index 7e069e2d..713aba0f 100644 --- a/core/event.class.php +++ b/core/event.class.php @@ -26,9 +26,9 @@ class InitExtEvent extends Event {} * $event->get_arg(0) = "42" */ class PageRequestEvent extends Event { - var $args; - var $arg_count; - var $part_count; + public $args; + public $arg_count; + public $part_count; public function __construct($path) { global $config; diff --git a/core/extension.class.php b/core/extension.class.php index 9d881c80..824cb6e1 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -81,7 +81,7 @@ */ abstract class Extension { /** this theme's Themelet object */ - var $theme; + public $theme; /** @private */ var $_child; diff --git a/core/user.class.php b/core/user.class.php index 3adceadc..3de02a6b 100644 --- a/core/user.class.php +++ b/core/user.class.php @@ -11,11 +11,11 @@ function _new_user($row) { * The currently logged in user will always be accessable via the global variable $user */ class User { - var $id; - var $name; - var $email; - var $join_date; - var $passhash; + public $id; + public $name; + public $email; + public $join_date; + public $passhash; /* @var UserClass */ var $class; diff --git a/core/userclass.class.php b/core/userclass.class.php index a8bec4e5..1d13688c 100644 --- a/core/userclass.class.php +++ b/core/userclass.class.php @@ -2,9 +2,9 @@ $_user_classes = array(); class UserClass { - var $name = null; - var $parent = null; - var $abilities = array(); + public $name = null; + public $parent = null; + public $abilities = array(); public function __construct($name, $parent=null, $abilities=array()) { global $_user_classes; From f9c8a1720e8de3ded4e2b5102a32117a1756d2c3 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 04:41:13 -0400 Subject: [PATCH 19/66] Comment out dead variables. --- themes/danbooru/comment.theme.php | 8 ++++---- themes/danbooru2/comment.theme.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php index f9fcdfca..f7146beb 100644 --- a/themes/danbooru/comment.theme.php +++ b/themes/danbooru/comment.theme.php @@ -49,7 +49,7 @@ class CustomCommentListTheme extends CommentListTheme { $comment_count = count($comments); if($comment_limit > 0 && $comment_count > $comment_limit) { - $hidden = $comment_count - $comment_limit; + //$hidden = $comment_count - $comment_limit; $comment_html .= "<p>showing $comment_limit of $comment_count comments</p>"; $comments = array_slice($comments, -$comment_limit); } @@ -93,9 +93,9 @@ class CustomCommentListTheme extends CommentListTheme { $tfe = new TextFormattingEvent($comment->comment); send_event($tfe); - $i_uid = int_escape($comment->owner_id); + //$i_uid = int_escape($comment->owner_id); $h_name = html_escape($comment->owner_name); - $h_poster_ip = html_escape($comment->poster_ip); + //$h_poster_ip = html_escape($comment->poster_ip); $h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted); $i_comment_id = int_escape($comment->comment_id); $i_image_id = int_escape($comment->image_id); @@ -107,7 +107,7 @@ class CustomCommentListTheme extends CommentListTheme { $h_del = $user->can("delete_comment") ? ' - <a onclick="return confirm(\'Delete comment by '.$h_name.':\\n'.$stripped_nonl.'\');" '. 'href="'.make_link('comment/delete/'.$i_comment_id.'/'.$i_image_id).'">Del</a>' : ''; - $h_imagelink = $trim ? "<a href='".make_link("post/view/$i_image_id")."'>>>></a>\n" : ""; + //$h_imagelink = $trim ? "<a href='".make_link("post/view/$i_image_id")."'>>>></a>\n" : ""; if($trim) { return "<p class='comment'>$h_userlink $h_del<br/>$h_posted<br/>$h_comment</p>"; } diff --git a/themes/danbooru2/comment.theme.php b/themes/danbooru2/comment.theme.php index f9fcdfca..f7146beb 100644 --- a/themes/danbooru2/comment.theme.php +++ b/themes/danbooru2/comment.theme.php @@ -49,7 +49,7 @@ class CustomCommentListTheme extends CommentListTheme { $comment_count = count($comments); if($comment_limit > 0 && $comment_count > $comment_limit) { - $hidden = $comment_count - $comment_limit; + //$hidden = $comment_count - $comment_limit; $comment_html .= "<p>showing $comment_limit of $comment_count comments</p>"; $comments = array_slice($comments, -$comment_limit); } @@ -93,9 +93,9 @@ class CustomCommentListTheme extends CommentListTheme { $tfe = new TextFormattingEvent($comment->comment); send_event($tfe); - $i_uid = int_escape($comment->owner_id); + //$i_uid = int_escape($comment->owner_id); $h_name = html_escape($comment->owner_name); - $h_poster_ip = html_escape($comment->poster_ip); + //$h_poster_ip = html_escape($comment->poster_ip); $h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted); $i_comment_id = int_escape($comment->comment_id); $i_image_id = int_escape($comment->image_id); @@ -107,7 +107,7 @@ class CustomCommentListTheme extends CommentListTheme { $h_del = $user->can("delete_comment") ? ' - <a onclick="return confirm(\'Delete comment by '.$h_name.':\\n'.$stripped_nonl.'\');" '. 'href="'.make_link('comment/delete/'.$i_comment_id.'/'.$i_image_id).'">Del</a>' : ''; - $h_imagelink = $trim ? "<a href='".make_link("post/view/$i_image_id")."'>>>></a>\n" : ""; + //$h_imagelink = $trim ? "<a href='".make_link("post/view/$i_image_id")."'>>>></a>\n" : ""; if($trim) { return "<p class='comment'>$h_userlink $h_del<br/>$h_posted<br/>$h_comment</p>"; } From 868f8c922531e6c313c5917d39310ce6a6d44cbe Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 04:44:28 -0400 Subject: [PATCH 20/66] Commenting out dead variables and dead code. --- themes/futaba/comment.theme.php | 8 ++++---- themes/warm/layout.class.php | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index f65b0b14..eeeb72c4 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -6,8 +6,8 @@ class CustomCommentListTheme extends CommentListTheme { public function display_comment_list($images, $page_number, $total_pages, $can_post) { global $config, $page; - $prev = $page_number - 1; - $next = $page_number + 1; + //$prev = $page_number - 1; + //$next = $page_number + 1; $page_title = $config->get_string('title'); $page->set_title($page_title); @@ -63,9 +63,9 @@ class CustomCommentListTheme extends CommentListTheme { $tfe = new TextFormattingEvent($comment->comment); send_event($tfe); - $i_uid = int_escape($comment->owner_id); + //$i_uid = int_escape($comment->owner_id); $h_name = html_escape($comment->owner_name); - $h_poster_ip = html_escape($comment->poster_ip); + //$h_poster_ip = html_escape($comment->poster_ip); $h_comment = ($trim ? substr($tfe->stripped, 0, 50)."..." : $tfe->formatted); $i_comment_id = int_escape($comment->comment_id); $i_image_id = int_escape($comment->image_id); diff --git a/themes/warm/layout.class.php b/themes/warm/layout.class.php index 46e79774..ba17a673 100644 --- a/themes/warm/layout.class.php +++ b/themes/warm/layout.class.php @@ -9,7 +9,7 @@ class Layout { public function display_page(Page $page) { global $config; - $theme_name = $config->get_string('theme', 'default'); + //$theme_name = $config->get_string('theme', 'default'); $site_name = $config->get_string('title'); $data_href = get_base_href(); $main_page = $config->get_string('main_page'); @@ -49,12 +49,13 @@ class Layout { $debug = get_debug_info(); $contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>"; - $subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>"; + /*$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>"; $wrapper = ""; if(strlen($page->heading) > 100) { $wrapper = ' style="height: 3em; overflow: auto;"'; } + */ $flash = get_prefixed_cookie("flash_message"); $flash_html = ""; From 332c8538b73834968953a7c3c154b58adf8ee4da Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 04:46:23 -0400 Subject: [PATCH 21/66] Change the function syntax to quiet JSHint. --- ext/tagger/webtoolkit.drag.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/tagger/webtoolkit.drag.js b/ext/tagger/webtoolkit.drag.js index 325f89a7..f18c6c2e 100644 --- a/ext/tagger/webtoolkit.drag.js +++ b/ext/tagger/webtoolkit.drag.js @@ -20,9 +20,9 @@ var DragHandler = { oElem.onmousedown = DragHandler._dragBegin; // callbacks - oElem.dragBegin = new Function(); - oElem.drag = new Function(); - oElem.dragEnd = new Function(); + oElem.dragBegin = function () {}; + oElem.drag = function () {}; + oElem.dragEnd = function () {}; return oElem; }, From 0501e05cff4f90a82032b3b937bc11acba20c95c Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 05:09:16 -0400 Subject: [PATCH 22/66] Comment out dead code/vars. --- themes/lite/layout.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index b8b480fe..11adcedd 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -82,6 +82,8 @@ class Layout { // hack $qp = explode("/", ltrim(@$_GET["q"], "/")); $hw = class_exists("Wiki"); + $cs = ""; + // php sucks switch($qp[0]) { default: @@ -145,12 +147,12 @@ class Layout { $debug = get_debug_info(); $contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>"; - $subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>"; + //$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>"; - $wrapper = ""; + /*$wrapper = ""; if(strlen($page->heading) > 100) { $wrapper = ' style="height: 3em; overflow: auto;"'; - } + }*/ if($page->left_enabled==false) { $left_block_html = ""; $main_block_html = "<article id='body_noleft'>$main_block_html</article>"; @@ -241,7 +243,7 @@ EOD; $re1='.*?'; $re2='((?:[a-z][a-z_]+))'; - if ($c=preg_match_all ("/".$re1.$re2."/is", $url, $matches)) { + if (preg_match_all ("/".$re1.$re2."/is", $url, $matches)) { $url=$matches[1][0]; } From e2f5c7a6ec54fd48eaf79798d6c1bb15218d2126 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 05:09:38 -0400 Subject: [PATCH 23/66] Check for null, just in case. --- ext/source_history/main.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ext/source_history/main.php b/ext/source_history/main.php index 366ea7cf..ff74c853 100644 --- a/ext/source_history/main.php +++ b/ext/source_history/main.php @@ -140,13 +140,20 @@ class Source_History extends Extension { } // lets get the values out of the result - $stored_result_id = $result['id']; + //$stored_result_id = $result['id']; $stored_image_id = $result['image_id']; $stored_source = $result['source']; log_debug("source_history", 'Reverting source of Image #'.$stored_image_id.' to ['.$stored_source.']'); + + $image = Image::by_id($stored_image_id); + + if (is_null($image)) { + die('Error: No image with the id ('.$stored_image_id.') was found. Perhaps the image was deleted while processing this request.'); + } + // all should be ok so we can revert by firing the SetUserSources event. - send_event(new SourceSetEvent(Image::by_id($stored_image_id), $stored_source)); + send_event(new SourceSetEvent($image, $stored_source)); // all should be done now so redirect the user back to the image $page->set_mode("redirect"); @@ -309,8 +316,15 @@ class Source_History extends Extension { $stored_source = $result['source']; log_debug("source_history", 'Reverting source of Image #'.$stored_image_id.' to ['.$stored_source.']'); + + $image = Image::by_id($stored_image_id); + + if (is_null($image)) { + die('Error: No image with the id ('.$stored_image_id.') was found. Perhaps the image was deleted while processing this request.'); + } + // all should be ok so we can revert by firing the SetSources event. - send_event(new SourceSetEvent(Image::by_id($stored_image_id), $stored_source)); + send_event(new SourceSetEvent($image, $stored_source)); $this->theme->add_status('Reverted Change','Reverted Image #'.$image_id.' to Source History #'.$stored_result_id.' ('.$row['source'].')'); } } From ce524e8729c9d88299cb2cf6cec4db62701161ad Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 05:25:12 -0400 Subject: [PATCH 24/66] This variable does exist, it is actually pulled from the database. Making it explicit for the linter. --- core/imageboard.pack.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index bafe738b..d09fb75b 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -40,7 +40,7 @@ class Image { public $height, $width; public $hash, $filesize; public $filename, $ext; - public $owner_ip; + public $owner_id, $owner_ip; public $posted; public $source; public $locked; From 7e41194b7f23994c43c8d0e6a76383b4a1ba5746 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 05:29:02 -0400 Subject: [PATCH 25/66] Shish you are too clever for scrutinizer-ci. --- core/imageboard.pack.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index d09fb75b..0992ded9 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -41,7 +41,7 @@ class Image { public $hash, $filesize; public $filename, $ext; public $owner_id, $owner_ip; - public $posted; + public $posted, $posted_timestamp; public $source; public $locked; @@ -54,7 +54,7 @@ class Image { foreach($row as $name => $value) { // some databases use table.name rather than name $name = str_replace("images.", "", $name); - $this->$name = $value; // hax + $this->$name = $value; // hax, this is likely the cause of much scrutinizer-ci complaints. } $this->posted_timestamp = strtotime($this->posted); // pray $this->locked = bool_escape($this->locked); From c4dcba1e9160f02a58b87c0a88e7e32718c81e48 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 05:37:26 -0400 Subject: [PATCH 26/66] Explicitly check for the existence of these properties before attempting to use them. --- core/basethemelet.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/basethemelet.class.php b/core/basethemelet.class.php index 94cfc159..430597b8 100644 --- a/core/basethemelet.class.php +++ b/core/basethemelet.class.php @@ -56,13 +56,13 @@ class BaseThemelet { $custom_classes = ""; if(class_exists("Relationships")){ - if($image->parent_id !== NULL){ $custom_classes .= "shm-thumb-has_parent "; } - if($image->has_children == TRUE){ $custom_classes .= "shm-thumb-has_child "; } + if(property_exists('Image', 'parent_id') && $image->parent_id !== NULL){ $custom_classes .= "shm-thumb-has_parent "; } + if(property_exists('Image', 'has_children') && $image->has_children == TRUE){ $custom_classes .= "shm-thumb-has_child "; } } return "<a href='$h_view_link' class='thumb shm-thumb shm-thumb-link {$custom_classes}' data-tags='$h_tags' data-post-id='$i_id'>". - "<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' height='{$tsize[1]}' width='{$tsize[0]}' src='$h_thumb_link'>". - "</a>\n"; + "<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' height='{$tsize[1]}' width='{$tsize[0]}' src='$h_thumb_link'>". + "</a>\n"; } From 993aacaea5d980664cc853f0c6207f2506502493 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 16:55:34 -0400 Subject: [PATCH 27/66] Update comment to reflect that a bug has been filed with PHP-analyzer. --- core/util.inc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index e724c690..95014ed9 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -870,9 +870,11 @@ function transload($url, $mfile) { fwrite($fp, $data); fclose($fp); - // Scrutinizer-ci complains that $http_response_header not defined. - // However, it is auto defined by PHP. - // See: http://us2.php.net/manual/en/reserved.variables.httpresponseheader.php + // + // Scrutinizer-ci complains that $http_response_header does not exist, + // however, $http_response_header is actually a super-global. + // I have filed a bug with PHP-Analyzer here: https://github.com/scrutinizer-ci/php-analyzer/issues/212 + // $headers = http_parse_headers(implode("\n", $http_response_header)); return $headers; From 7b90331f0243f7d27b348a50a02fee64ad2476f4 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 16:56:04 -0400 Subject: [PATCH 28/66] Add missing semi-colon. --- ext/simpletest/main.php | 1 + ext/tagger/webtoolkit.drag.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/simpletest/main.php b/ext/simpletest/main.php index 523204cb..b3972cb5 100644 --- a/ext/simpletest/main.php +++ b/ext/simpletest/main.php @@ -91,6 +91,7 @@ define('ADMIN_PASS', "demo"); * A set of common SCore activities to test */ class SCoreWebTestCase extends WebTestCase { + /** * Click on a link or a button */ diff --git a/ext/tagger/webtoolkit.drag.js b/ext/tagger/webtoolkit.drag.js index f18c6c2e..68d48f4a 100644 --- a/ext/tagger/webtoolkit.drag.js +++ b/ext/tagger/webtoolkit.drag.js @@ -84,4 +84,4 @@ var DragHandler = { DragHandler._oElem = null; } -} +}; From 709366b70c1f2dc24cde8ceca253b9d1c5209b1c Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 18:44:46 -0400 Subject: [PATCH 29/66] Explicitly declare these class variables. --- ext/shimmie_api/main.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ext/shimmie_api/main.php b/ext/shimmie_api/main.php index da65a2d6..0ea29ead 100644 --- a/ext/shimmie_api/main.php +++ b/ext/shimmie_api/main.php @@ -21,6 +21,17 @@ class _SafeImage { #{"id":"2","height":"768","width":"1024","hash":"71cdfaabbcdad3f777e0b60418532e94","filesize":"439561","filename":"HeilAmu.png","ext":"png","owner_ip":"0.0.0.0","posted":"0000-00-00 00:00:00","source":null,"locked":"N","owner_id":"0","rating":"u","numeric_score":"0","text_score":"0","notes":"0","favorites":"0","posted_timestamp":-62169955200,"tag_array":["cat","kunimitsu"]} + public $id; + public $height; + public $width; + public $hash; + public $filesize; + public $ext; + public $posted; + public $source; + public $owner_id; + public $tags; + function __construct(Image $img) { $this->id = $img->id; $this->height = $img->height; @@ -146,4 +157,4 @@ class ShimmieApi extends Extension { } } } -?> + From 286e75bef0cf0db9103dfeb2dacb47249499d5d8 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 18:45:54 -0400 Subject: [PATCH 30/66] Scrutinizer complains that these functions aren't defined, yet they really are. --- themes/lite/layout.class.php | 114 +++++++++++++++++------------------ 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index 11adcedd..9d12c6d5 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -8,6 +8,63 @@ * some other sites, packaged in a light blue color. */ class Layout { + + /** + * A handy function which does exactly what it says in the method name + */ + private function block_to_html($block, $hidable=false, $salt="") { + $h = $block->header; + $b = $block->body; + $i = str_replace(' ', '_', $h) . $salt; + $html = "<section id='$i'>"; + if(!is_null($h)) { + if($salt == "main") { + $html .= "<div class='maintop navside tab shm-toggler' data-toggle-sel='#$i'>$h</div>"; + } else { + $html .= "<div class='navtop navside tab shm-toggler' data-toggle-sel='#$i'>$h</div>"; + } + } + if(!is_null($b)) { + if($salt =="main") { + $html .= "<div class='blockbody'>$b</div>"; + } + else { + $html .= " + <div class='navside tab'>$b</div> + "; + } + } + $html .= "</section>"; + return $html; + } + + private function navlinks($link, $desc, $pages_matched) { + /** + * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) + */ + $html = null; + $url = ltrim($_GET['q'], "/"); + + $re1='.*?'; + $re2='((?:[a-z][a-z_]+))'; + + if (preg_match_all ("/".$re1.$re2."/is", $url, $matches)) { + $url=$matches[1][0]; + } + + $count_pages_matched = count($pages_matched); + + for($i=0; $i < $count_pages_matched; $i++) { + if($url == $pages_matched[$i]) { + $html = "<a class='tab-selected' href='$link'>$desc</a>"; + } + } + + if(is_null($html)) {$html = "<a class='tab' href='$link'>$desc</a>";} + + return $html; + } + /** * turns the Page into HTML */ @@ -203,61 +260,4 @@ class Layout { </html> EOD; } - - /** - * A handy function which does exactly what it says in the method name - */ - private function block_to_html($block, $hidable=false, $salt="") { - $h = $block->header; - $b = $block->body; - $i = str_replace(' ', '_', $h) . $salt; - $html = "<section id='$i'>"; - if(!is_null($h)) { - if($salt == "main") { - $html .= "<div class='maintop navside tab shm-toggler' data-toggle-sel='#$i'>$h</div>"; - } else { - $html .= "<div class='navtop navside tab shm-toggler' data-toggle-sel='#$i'>$h</div>"; - } - } - if(!is_null($b)) { - if($salt =="main") { - $html .= "<div class='blockbody'>$b</div>"; - } - else { - $html .= " - <div class='navside tab'>$b</div> - "; - } - } - $html .= "</section>"; - return $html; - } - - private function navlinks($link, $desc, $pages_matched) { - /** - * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) - */ - $html = null; - $url = ltrim($_GET['q'], "/"); - - $re1='.*?'; - $re2='((?:[a-z][a-z_]+))'; - - if (preg_match_all ("/".$re1.$re2."/is", $url, $matches)) { - $url=$matches[1][0]; - } - - $count_pages_matched = count($pages_matched); - - for($i=0; $i < $count_pages_matched; $i++) { - if($url == $pages_matched[$i]) { - $html = "<a class='tab-selected' href='$link'>$desc</a>"; - } - } - - if(is_null($html)) {$html = "<a class='tab' href='$link'>$desc</a>";} - - return $html; - } } -?> From ab3f9850e43fe7374abfb104006e7fdd9faa0115 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 19:01:47 -0400 Subject: [PATCH 31/66] Removing the closing PHP "?>" tag as per style guidelines. --- core/basethemelet.class.php | 2 +- core/block.class.php | 2 +- core/config.class.php | 2 +- core/database.class.php | 2 +- core/email.class.php | 2 +- core/event.class.php | 2 +- core/exceptions.class.php | 2 +- core/extension.class.php | 2 +- core/imageboard.pack.php | 2 +- core/sys_config.inc.php | 3 ++- core/user.class.php | 2 +- core/userclass.class.php | 2 +- core/util.inc.php | 2 +- ext/chatbox/php/ajaxcall.class.php | 4 ++-- ext/comment/theme.php | 2 +- ext/upload/main.php | 2 +- ext/upload/test.php | 2 +- ext/upload/theme.php | 2 +- themes/danbooru2/comment.theme.php | 2 +- themes/lite/comment.theme.php | 1 - themes/lite/custompage.class.php | 2 +- themes/lite/setup.theme.php | 2 +- themes/lite/themelet.class.php | 2 +- themes/lite/user.theme.php | 2 +- themes/lite/view.theme.php | 2 +- 25 files changed, 26 insertions(+), 26 deletions(-) diff --git a/core/basethemelet.class.php b/core/basethemelet.class.php index 430597b8..49be4a41 100644 --- a/core/basethemelet.class.php +++ b/core/basethemelet.class.php @@ -115,4 +115,4 @@ class BaseThemelet { .'<br><< '.$pages_html.' >>'; } } -?> + diff --git a/core/block.class.php b/core/block.class.php index 4fd0c28d..21b50dd1 100644 --- a/core/block.class.php +++ b/core/block.class.php @@ -71,4 +71,4 @@ class NavBlock extends Block { parent::__construct("Navigation", "<a href='".make_link()."'>Index</a>", "left", 0); } } -?> + diff --git a/core/config.class.php b/core/config.class.php index 96e6e156..7b0f6f1f 100644 --- a/core/config.class.php +++ b/core/config.class.php @@ -224,4 +224,4 @@ class MockConfig extends HardcodeConfig { parent::__construct($config); } } -?> + diff --git a/core/database.class.php b/core/database.class.php index c4aface5..1fbfb2f8 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -553,4 +553,4 @@ class MockDatabase extends Database { public function create_table($name, $def) {} public function connect_engine() {} } -?> + diff --git a/core/email.class.php b/core/email.class.php index 82c50c81..8dd2db58 100644 --- a/core/email.class.php +++ b/core/email.class.php @@ -116,4 +116,4 @@ Copyright (C) <a href="'.$this->sitedomain.'">'.$this->sitename.'</a><br /> return $sent; } } -?> + diff --git a/core/event.class.php b/core/event.class.php index 713aba0f..b1c66b6a 100644 --- a/core/event.class.php +++ b/core/event.class.php @@ -265,4 +265,4 @@ class LogEvent extends Event { $this->time = time(); } } -?> + diff --git a/core/exceptions.class.php b/core/exceptions.class.php index f9648bf8..fd52b7af 100644 --- a/core/exceptions.class.php +++ b/core/exceptions.class.php @@ -8,4 +8,4 @@ class SCoreException extends Exception {} * A fairly common, generic exception */ class PermissionDeniedException extends SCoreException {} -?> + diff --git a/core/extension.class.php b/core/extension.class.php index 824cb6e1..5730e4ac 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -231,4 +231,4 @@ abstract class DataHandlerExtension extends Extension { abstract protected function create_image_from_data($filename, $metadata); abstract protected function create_thumb($hash); } -?> + diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 0992ded9..f9053ce7 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -1143,4 +1143,4 @@ function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) { } } -?> + diff --git a/core/sys_config.inc.php b/core/sys_config.inc.php index c70acb93..bd9f0616 100644 --- a/core/sys_config.inc.php +++ b/core/sys_config.inc.php @@ -46,4 +46,5 @@ _d("EXTRA_EXTS", ""); // optional extra extensions */ _d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version _d("ENABLED_EXTS", CORE_EXTS.",".EXTRA_EXTS); -?> + + diff --git a/core/user.class.php b/core/user.class.php index 3de02a6b..bb63523e 100644 --- a/core/user.class.php +++ b/core/user.class.php @@ -218,4 +218,4 @@ class MockUser extends User { parent::__construct($row); } } -?> + diff --git a/core/userclass.class.php b/core/userclass.class.php index 1d13688c..d960f954 100644 --- a/core/userclass.class.php +++ b/core/userclass.class.php @@ -164,4 +164,4 @@ new UserClass("hellbanned", "user", array( )); @include_once "data/config/user-classes.conf.php"; -?> + diff --git a/core/util.inc.php b/core/util.inc.php index 95014ed9..77c6c33e 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -1461,4 +1461,4 @@ function _end_coverage() { file_put_contents("$absolute_path/$t.$n.log", gzdeflate(serialize(xdebug_get_code_coverage()))); } } -?> + diff --git a/ext/chatbox/php/ajaxcall.class.php b/ext/chatbox/php/ajaxcall.class.php index 7d175b25..05aa5c06 100644 --- a/ext/chatbox/php/ajaxcall.class.php +++ b/ext/chatbox/php/ajaxcall.class.php @@ -272,8 +272,8 @@ $send['error'] = false; } - echo jsonEncode($send); + echo jsonEncode($send); } } -?> \ No newline at end of file + diff --git a/ext/comment/theme.php b/ext/comment/theme.php index 7821b68c..3a08c695 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -296,4 +296,4 @@ class CommentListTheme extends Themelet { '; } } -?> + diff --git a/ext/upload/main.php b/ext/upload/main.php index e0a2c9b8..155bb75c 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -388,4 +388,4 @@ class Upload extends Extension { } // }}} } -?> + diff --git a/ext/upload/test.php b/ext/upload/test.php index 7a9c1281..7eb0b08d 100644 --- a/ext/upload/test.php +++ b/ext/upload/test.php @@ -39,4 +39,4 @@ class UploadTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 464d8ee9..e1c9692d 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -319,4 +319,4 @@ class UploadTheme extends Themelet { "; } } -?> + diff --git a/themes/danbooru2/comment.theme.php b/themes/danbooru2/comment.theme.php index f7146beb..826c87d4 100644 --- a/themes/danbooru2/comment.theme.php +++ b/themes/danbooru2/comment.theme.php @@ -121,4 +121,4 @@ class CustomCommentListTheme extends CommentListTheme { } } } -?> + diff --git a/themes/lite/comment.theme.php b/themes/lite/comment.theme.php index 97676e24..9c4638ea 100644 --- a/themes/lite/comment.theme.php +++ b/themes/lite/comment.theme.php @@ -9,4 +9,3 @@ class CustomCommentListTheme extends CommentListTheme { return $this->rr(parent::build_postbox($image_id)); } } -?> diff --git a/themes/lite/custompage.class.php b/themes/lite/custompage.class.php index 1e71720b..16d676cf 100644 --- a/themes/lite/custompage.class.php +++ b/themes/lite/custompage.class.php @@ -6,4 +6,4 @@ class CustomPage extends Page { $this->left_enabled = false; } } -?> + diff --git a/themes/lite/setup.theme.php b/themes/lite/setup.theme.php index 282e80b6..a1e9e72d 100644 --- a/themes/lite/setup.theme.php +++ b/themes/lite/setup.theme.php @@ -34,4 +34,4 @@ class CustomSetupTheme extends SetupTheme { return $this->rr($html); } } -?> + diff --git a/themes/lite/themelet.class.php b/themes/lite/themelet.class.php index 49477ac5..939c0a6b 100644 --- a/themes/lite/themelet.class.php +++ b/themes/lite/themelet.class.php @@ -66,4 +66,4 @@ class Themelet extends BaseThemelet { </div>"; } } -?> + diff --git a/themes/lite/user.theme.php b/themes/lite/user.theme.php index f3b11a8d..21a6544c 100644 --- a/themes/lite/user.theme.php +++ b/themes/lite/user.theme.php @@ -96,4 +96,4 @@ class CustomUserPageTheme extends UserPageTheme { parent::display_user_page($duser, $stats); } } -?> + diff --git a/themes/lite/view.theme.php b/themes/lite/view.theme.php index 419b3571..b9e2db75 100644 --- a/themes/lite/view.theme.php +++ b/themes/lite/view.theme.php @@ -55,4 +55,4 @@ class CustomViewImageTheme extends ViewImageTheme { return $html; } } -?> + From 4cc31df7372fdb0bff698ccfee9aaba90e0ea18f Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 19:02:43 -0400 Subject: [PATCH 32/66] Update the comments to PHPDoc style guidelines. --- ext/upload/main.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/ext/upload/main.php b/ext/upload/main.php index 155bb75c..a7d32f61 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -15,9 +15,9 @@ class DataUploadEvent extends Event { /** * Some data is being uploaded. * This should be caught by a file handler. - * @param $user The user uploading the data. - * @param $tmpname The temporary file used for upload. - * @param $metadata Info about the file, should contain at least "filename", "extension", "tags" and "source". + * -- Removed: param $user The user uploading the data. + * @param $tmpname string The temporary file used for upload. + * @param $metadata array Info about the file, should contain at least "filename", "extension", "tags" and "source". */ public function __construct(/*string*/ $tmpname, /*array*/ $metadata) { assert(file_exists($tmpname)); @@ -59,7 +59,6 @@ class Upload extends Extension { else { $this->is_full = $free_num < MIN_FREE_SPACE; } - } public function onPostListBuilding(PostListBuildingEvent $event) { @@ -235,8 +234,8 @@ class Upload extends Extension { * * TODO: Make these messages user/admin editable * - * @param $error_code PHP error code (int) - * @retval String + * @param $error_code integer PHP error code + * @return String */ private function upload_error_message($error_code) { switch ($error_code) { @@ -258,10 +257,14 @@ class Upload extends Extension { return 'Unknown upload error'; } } - + /** * Handle an upload. - * @retval bool TRUE on upload successful. + * @param $file + * @param $tags + * @param $source + * @param string $replace + * @return bool TRUE on upload successful. */ private function try_upload($file, $tags, $source, $replace='') { global $page, $config, $user; @@ -310,7 +313,11 @@ class Upload extends Extension { /** * Handle an transload. - * @retval bool TRUE on transload successful. + * @param $url + * @param $tags + * @param $source + * @param string $replace + * @return bool TRUE on transload successful. */ private function try_transload($url, $tags, $source, $replace='') { global $page, $config, $user; From 2706f72ce489a949f6a61c9ef38e2a7098c5ec8e Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 19:08:23 -0400 Subject: [PATCH 33/66] Update and fix the PHPDoc comments. --- core/event.class.php | 14 +++++----- core/imageboard.pack.php | 54 ++++++++++++++++++++++-------------- core/user.class.php | 10 +++---- themes/lite/layout.class.php | 4 +-- 4 files changed, 47 insertions(+), 35 deletions(-) diff --git a/core/event.class.php b/core/event.class.php index b1c66b6a..766a2c0f 100644 --- a/core/event.class.php +++ b/core/event.class.php @@ -63,7 +63,7 @@ class PageRequestEvent extends Event { * * If it matches, store the remaining path elements in $args * - * @retval bool + * @return bool */ public function page_matches(/*string*/ $name) { $parts = explode("/", $name); @@ -85,7 +85,7 @@ class PageRequestEvent extends Event { /** * Get the n th argument of the page request (if it exists.) * @param $n integer - * @retval The argmuent (string) or NULL + * @return The argmuent (string) or NULL */ public function get_arg(/*int*/ $n) { $offset = $this->part_count + $n; @@ -99,7 +99,7 @@ class PageRequestEvent extends Event { /** * Returns the number of arguments the page request has. - * @retval int + * @return int */ public function count_args() { return (int)($this->arg_count - $this->part_count); @@ -227,28 +227,28 @@ class LogEvent extends Event { /** * a category, normally the extension name * - * @retval string + * @return string */ var $section; /** * See python... * - * @retval int + * @return int */ var $priority = 0; /** * Free text to be logged * - * @retval text + * @return text */ var $message; /** * The time that the event was created * - * @retval int + * @return int */ var $time; diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index f9053ce7..3992f79b 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -68,7 +68,8 @@ class Image { /** * Find an image by ID * - * @retval Image + * @param $id + * @return Image */ public static function by_id(/*int*/ $id) { assert(is_numeric($id)); @@ -80,7 +81,8 @@ class Image { /** * Find an image by hash * - * @retval Image + * @param $hash + * @return Image */ public static function by_hash(/*string*/ $hash) { assert(is_string($hash)); @@ -92,7 +94,8 @@ class Image { /** * Pick a random image out of a set * - * @retval Image + * @param array $tags + * @return Image */ public static function by_random($tags=array()) { assert(is_array($tags)); @@ -107,7 +110,11 @@ class Image { /** * Search for an array of images * - * @retval Array + * @param $start + * @param $limit + * @param array $tags + * @throws SCoreException + * @return Array */ public static function find_images(/*int*/ $start, /*int*/ $limit, $tags=array()) { assert(is_numeric($start)); @@ -192,7 +199,9 @@ class Image { * Rather than simply $this_id + 1, one must take into account * deleted images and search queries * - * @retval Image + * @param array $tags + * @param bool $next + * @return Image */ public function get_next($tags=array(), $next=true) { assert(is_array($tags)); @@ -224,7 +233,8 @@ class Image { /** * The reverse of get_next * - * @retval Image + * @param array $tags + * @return Image */ public function get_prev($tags=array()) { return $this->get_next($tags, false); @@ -233,7 +243,7 @@ class Image { /** * Find the User who owns this Image * - * @retval User + * @return User */ public function get_owner() { return User::by_id($this->owner_id); @@ -271,7 +281,7 @@ class Image { /** * Get the URL for the full size image * - * @retval string + * @return string */ public function get_image_link() { global $config; @@ -296,7 +306,7 @@ class Image { * Get a short link to the full size image * * @deprecated - * @retval string + * @return string */ public function get_short_link() { global $config; @@ -306,7 +316,7 @@ class Image { /** * Get the URL for the thumbnail * - * @retval string + * @return string */ public function get_thumb_link() { global $config; @@ -331,7 +341,7 @@ class Image { * Get the tooltip for this image, formatted according to the * configured template * - * @retval string + * @return string */ public function get_tooltip() { global $config; @@ -360,7 +370,7 @@ class Image { /** * Figure out where the full size image is on disk * - * @retval string + * @return string */ public function get_image_filename() { return warehouse_path("images", $this->hash); @@ -369,7 +379,7 @@ class Image { /** * Figure out where the thumbnail is on disk * - * @retval string + * @return string */ public function get_thumb_filename() { return warehouse_path("thumbs", $this->hash); @@ -378,7 +388,7 @@ class Image { /** * Get the original filename * - * @retval string + * @return string */ public function get_filename() { return $this->filename; @@ -387,7 +397,7 @@ class Image { /** * Get the image's mime type * - * @retval string + * @return string */ public function get_mime_type() { return getMimeType($this->get_image_filename(), $this->get_ext()); @@ -396,7 +406,7 @@ class Image { /** * Get the image's filename extension * - * @retval string + * @return string */ public function get_ext() { return $this->ext; @@ -405,7 +415,7 @@ class Image { /** * Get the image's source URL * - * @retval string + * @return string */ public function get_source() { return $this->source; @@ -426,7 +436,7 @@ class Image { /** * Check if the image is locked. - * @retval bool + * @return bool */ public function is_locked() { return $this->locked; @@ -542,7 +552,9 @@ class Image { /** * Someone please explain this * - * @retval string + * @param $tmpl + * @param string $_escape + * @return string */ public function parse_link_template($tmpl, $_escape="url_escape") { global $config; @@ -1104,7 +1116,7 @@ class Tag { /** * Move a file from PHP's temporary area into shimmie's image storage - * heirachy, or throw an exception trying + * hierarchy, or throw an exception trying */ function move_upload_to_archive(DataUploadEvent $event) { $target = warehouse_path("images", $event->hash); @@ -1116,7 +1128,7 @@ function move_upload_to_archive(DataUploadEvent $event) { } /** - * Given a full size pair of dimentions, return a pair scaled down to fit + * Given a full size pair of dimensions, return a pair scaled down to fit * into the configured thumbnail square, with ratio intact */ function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) { diff --git a/core/user.class.php b/core/user.class.php index bb63523e..3117385e 100644 --- a/core/user.class.php +++ b/core/user.class.php @@ -108,7 +108,7 @@ class User { /** * Test if this user is anonymous (not logged in) * - * @retval bool + * @return bool */ public function is_anonymous() { global $config; @@ -118,7 +118,7 @@ class User { /** * Test if this user is logged in * - * @retval bool + * @return bool */ public function is_logged_in() { global $config; @@ -128,7 +128,7 @@ class User { /** * Test if this user is an administrator * - * @retval bool + * @return bool */ public function is_admin() { return ($this->class->name === "admin"); @@ -157,7 +157,7 @@ class User { /** * Get a snippet of HTML which will render the user's avatar, be that * a local file, a remote file, a gravatar, a something else, etc - * @retval String of HTML + * @return String of HTML */ public function get_avatar_html() { // FIXME: configurable @@ -186,7 +186,7 @@ class User { * the form was generated within the session. Salted and re-hashed so that * reading a web page from the user's cache doesn't give access to the session key * - * @retval String containing auth token (MD5sum) + * @return String containing auth token (MD5sum) */ public function get_auth_token() { global $config; diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index 9d12c6d5..73ae0a4e 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -259,5 +259,5 @@ class Layout { </body> </html> EOD; - } -} + } /* end of function display_page() */ +} /* end of class Layout */ From b3077d5bcdfc845fe722c58f77c5f7416d8a974f Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 19:13:20 -0400 Subject: [PATCH 34/66] Removing the closing PHP "?>" tag as per style guidelines. --- index.php | 2 +- themes/danbooru/comment.theme.php | 2 +- themes/danbooru/custompage.class.php | 2 +- themes/danbooru/index.theme.php | 2 +- themes/danbooru/layout.class.php | 2 +- themes/danbooru/tag_list.theme.php | 2 +- themes/danbooru/themelet.class.php | 2 +- themes/danbooru/upload.theme.php | 2 +- themes/danbooru/user.theme.php | 2 +- themes/danbooru/view.theme.php | 2 +- themes/danbooru2/admin.theme.php | 2 +- themes/danbooru2/custompage.class.php | 2 +- themes/danbooru2/ext_manager.theme.php | 2 +- themes/danbooru2/index.theme.php | 2 +- themes/danbooru2/layout.class.php | 2 +- themes/danbooru2/tag_list.theme.php | 2 +- themes/danbooru2/themelet.class.php | 2 +- themes/danbooru2/upload.theme.php | 2 +- themes/danbooru2/user.theme.php | 2 +- themes/danbooru2/view.theme.php | 2 +- themes/default/layout.class.php | 2 +- themes/default/themelet.class.php | 2 +- themes/futaba/comment.theme.php | 2 +- themes/futaba/custompage.class.php | 2 +- themes/futaba/layout.class.php | 2 +- themes/futaba/themelet.class.php | 2 +- themes/futaba/view.theme.php | 2 +- themes/warm/layout.class.php | 2 +- themes/warm/themelet.class.php | 2 +- themes/warm/upload.theme.php | 2 +- themes/warm/user.theme.php | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/index.php b/index.php index 28d6811a..1599e2c4 100644 --- a/index.php +++ b/index.php @@ -100,4 +100,4 @@ catch(Exception $e) { _fatal_error($e); ctx_log_ender(); } -?> + diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php index f7146beb..826c87d4 100644 --- a/themes/danbooru/comment.theme.php +++ b/themes/danbooru/comment.theme.php @@ -121,4 +121,4 @@ class CustomCommentListTheme extends CommentListTheme { } } } -?> + diff --git a/themes/danbooru/custompage.class.php b/themes/danbooru/custompage.class.php index 1e71720b..16d676cf 100644 --- a/themes/danbooru/custompage.class.php +++ b/themes/danbooru/custompage.class.php @@ -6,4 +6,4 @@ class CustomPage extends Page { $this->left_enabled = false; } } -?> + diff --git a/themes/danbooru/index.theme.php b/themes/danbooru/index.theme.php index b27aa028..47bd2d9a 100644 --- a/themes/danbooru/index.theme.php +++ b/themes/danbooru/index.theme.php @@ -58,4 +58,4 @@ class CustomIndexTheme extends IndexTheme { return $table; } } -?> + diff --git a/themes/danbooru/layout.class.php b/themes/danbooru/layout.class.php index 27af8810..ca0f3fe0 100644 --- a/themes/danbooru/layout.class.php +++ b/themes/danbooru/layout.class.php @@ -265,4 +265,4 @@ EOD; return $html; } } -?> + diff --git a/themes/danbooru/tag_list.theme.php b/themes/danbooru/tag_list.theme.php index 3c168380..6628ca29 100644 --- a/themes/danbooru/tag_list.theme.php +++ b/themes/danbooru/tag_list.theme.php @@ -6,4 +6,4 @@ class CustomTagListTheme extends TagListTheme { parent::display_page($page); } } -?> + diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php index b69c5288..9eb986c7 100644 --- a/themes/danbooru/themelet.class.php +++ b/themes/danbooru/themelet.class.php @@ -48,4 +48,4 @@ class Themelet extends BaseThemelet { return "<div id='paginator'>$prev_html $first_html $pdots $pages_html $ndots $last_html $next_html</div>"; } } -?> + diff --git a/themes/danbooru/upload.theme.php b/themes/danbooru/upload.theme.php index 7e5f75bf..a7047cf3 100644 --- a/themes/danbooru/upload.theme.php +++ b/themes/danbooru/upload.theme.php @@ -11,4 +11,4 @@ class CustomUploadTheme extends UploadTheme { parent::display_page($page); } } -?> + diff --git a/themes/danbooru/user.theme.php b/themes/danbooru/user.theme.php index fba58e8d..9990879e 100644 --- a/themes/danbooru/user.theme.php +++ b/themes/danbooru/user.theme.php @@ -98,4 +98,4 @@ class CustomUserPageTheme extends UserPageTheme { parent::display_user_page($duser, $stats); } } -?> + diff --git a/themes/danbooru/view.theme.php b/themes/danbooru/view.theme.php index 19aa4fcf..427d4f48 100644 --- a/themes/danbooru/view.theme.php +++ b/themes/danbooru/view.theme.php @@ -51,4 +51,4 @@ class CustomViewImageTheme extends ViewImageTheme { return $html; } } -?> + diff --git a/themes/danbooru2/admin.theme.php b/themes/danbooru2/admin.theme.php index b08d12c3..2007705d 100644 --- a/themes/danbooru2/admin.theme.php +++ b/themes/danbooru2/admin.theme.php @@ -8,4 +8,4 @@ class CustomAdminPageTheme extends AdminPageTheme { } } -?> + diff --git a/themes/danbooru2/custompage.class.php b/themes/danbooru2/custompage.class.php index 1e71720b..16d676cf 100644 --- a/themes/danbooru2/custompage.class.php +++ b/themes/danbooru2/custompage.class.php @@ -6,4 +6,4 @@ class CustomPage extends Page { $this->left_enabled = false; } } -?> + diff --git a/themes/danbooru2/ext_manager.theme.php b/themes/danbooru2/ext_manager.theme.php index 67449dcf..1c42e2e8 100644 --- a/themes/danbooru2/ext_manager.theme.php +++ b/themes/danbooru2/ext_manager.theme.php @@ -11,4 +11,4 @@ class CustomExtManagerTheme extends ExtManagerTheme { } } -?> + diff --git a/themes/danbooru2/index.theme.php b/themes/danbooru2/index.theme.php index 4d0ca68f..090cd248 100644 --- a/themes/danbooru2/index.theme.php +++ b/themes/danbooru2/index.theme.php @@ -58,4 +58,4 @@ class CustomIndexTheme extends IndexTheme { return $table; } } -?> + diff --git a/themes/danbooru2/layout.class.php b/themes/danbooru2/layout.class.php index d7e108b2..e937ed8b 100644 --- a/themes/danbooru2/layout.class.php +++ b/themes/danbooru2/layout.class.php @@ -291,4 +291,4 @@ EOD; return $html; } } -?> + diff --git a/themes/danbooru2/tag_list.theme.php b/themes/danbooru2/tag_list.theme.php index 3c168380..6628ca29 100644 --- a/themes/danbooru2/tag_list.theme.php +++ b/themes/danbooru2/tag_list.theme.php @@ -6,4 +6,4 @@ class CustomTagListTheme extends TagListTheme { parent::display_page($page); } } -?> + diff --git a/themes/danbooru2/themelet.class.php b/themes/danbooru2/themelet.class.php index b69c5288..9eb986c7 100644 --- a/themes/danbooru2/themelet.class.php +++ b/themes/danbooru2/themelet.class.php @@ -48,4 +48,4 @@ class Themelet extends BaseThemelet { return "<div id='paginator'>$prev_html $first_html $pdots $pages_html $ndots $last_html $next_html</div>"; } } -?> + diff --git a/themes/danbooru2/upload.theme.php b/themes/danbooru2/upload.theme.php index 7e5f75bf..a7047cf3 100644 --- a/themes/danbooru2/upload.theme.php +++ b/themes/danbooru2/upload.theme.php @@ -11,4 +11,4 @@ class CustomUploadTheme extends UploadTheme { parent::display_page($page); } } -?> + diff --git a/themes/danbooru2/user.theme.php b/themes/danbooru2/user.theme.php index fba58e8d..9990879e 100644 --- a/themes/danbooru2/user.theme.php +++ b/themes/danbooru2/user.theme.php @@ -98,4 +98,4 @@ class CustomUserPageTheme extends UserPageTheme { parent::display_user_page($duser, $stats); } } -?> + diff --git a/themes/danbooru2/view.theme.php b/themes/danbooru2/view.theme.php index 11956fc9..bd6e5f45 100644 --- a/themes/danbooru2/view.theme.php +++ b/themes/danbooru2/view.theme.php @@ -64,4 +64,4 @@ class CustomViewImageTheme extends ViewImageTheme { return "$h_search"; } } -?> + diff --git a/themes/default/layout.class.php b/themes/default/layout.class.php index 078e143f..87b86d31 100644 --- a/themes/default/layout.class.php +++ b/themes/default/layout.class.php @@ -94,4 +94,4 @@ $header_html EOD; } } -?> + diff --git a/themes/default/themelet.class.php b/themes/default/themelet.class.php index d13596ce..77c927c3 100644 --- a/themes/default/themelet.class.php +++ b/themes/default/themelet.class.php @@ -1,3 +1,3 @@ <?php class Themelet extends BaseThemelet {} -?> + diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index eeeb72c4..35e74d7d 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -89,4 +89,4 @@ class CustomCommentListTheme extends CommentListTheme { } } } -?> + diff --git a/themes/futaba/custompage.class.php b/themes/futaba/custompage.class.php index 1e71720b..16d676cf 100644 --- a/themes/futaba/custompage.class.php +++ b/themes/futaba/custompage.class.php @@ -6,4 +6,4 @@ class CustomPage extends Page { $this->left_enabled = false; } } -?> + diff --git a/themes/futaba/layout.class.php b/themes/futaba/layout.class.php index b42c9ad2..a2f1c370 100644 --- a/themes/futaba/layout.class.php +++ b/themes/futaba/layout.class.php @@ -102,4 +102,4 @@ $header_html EOD; } } -?> + diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index 5770b05b..5044c3fe 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -50,4 +50,4 @@ class Themelet extends BaseThemelet { return "<p class='paginator'>$prev_html $pages_html $next_html</p>"; } } -?> + diff --git a/themes/futaba/view.theme.php b/themes/futaba/view.theme.php index c8c3519b..54b66e88 100644 --- a/themes/futaba/view.theme.php +++ b/themes/futaba/view.theme.php @@ -8,4 +8,4 @@ class CustomViewImageTheme extends ViewImageTheme { $page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 10)); } } -?> + diff --git a/themes/warm/layout.class.php b/themes/warm/layout.class.php index ba17a673..2b55f32f 100644 --- a/themes/warm/layout.class.php +++ b/themes/warm/layout.class.php @@ -110,4 +110,4 @@ $header_html EOD; } } -?> + diff --git a/themes/warm/themelet.class.php b/themes/warm/themelet.class.php index d13596ce..77c927c3 100644 --- a/themes/warm/themelet.class.php +++ b/themes/warm/themelet.class.php @@ -1,3 +1,3 @@ <?php class Themelet extends BaseThemelet {} -?> + diff --git a/themes/warm/upload.theme.php b/themes/warm/upload.theme.php index 6950e18a..bb9dcd34 100644 --- a/themes/warm/upload.theme.php +++ b/themes/warm/upload.theme.php @@ -9,4 +9,4 @@ class CustomUploadTheme extends UploadTheme { $page->add_block(new Block("Upload", "Disk nearly full, uploads disabled", "head", 20)); } } -?> + diff --git a/themes/warm/user.theme.php b/themes/warm/user.theme.php index 638af836..96db52b8 100644 --- a/themes/warm/user.theme.php +++ b/themes/warm/user.theme.php @@ -27,4 +27,4 @@ class CustomUserPageTheme extends UserPageTheme { $page->add_block(new Block("Login", $html, "head", 90)); } } -?> + From 6e4ae229ef2b8a4c3f9d4061e9a9f87f5c828648 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 19:13:41 -0400 Subject: [PATCH 35/66] Explicitly declare this class variable --- ext/upload/main.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ext/upload/main.php b/ext/upload/main.php index a7d32f61..028c2857 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -42,6 +42,9 @@ class UploadException extends SCoreException {} * This also includes transloaded files as well. */ class Upload extends Extension { + + public $is_full; + // early, so it can stop the DataUploadEvent before any data handlers see it public function get_priority() {return 40;} From 780d5f8709722f64ca1c0ab561e398501f479229 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 22:13:00 -0400 Subject: [PATCH 36/66] More linting. Explicitly declare these class variables, as well as comment out dead code. --- ext/chatbox/php/ajaxcall.class.php | 16 +++++---- ext/chatbox/php/filestorage.class.php | 5 ++- ext/chatbox/php/functions.php | 9 +++-- ext/chatbox/php/yshout.class.php | 1 - ext/tagger/script.js | 31 ++++++++-------- ext/tagger/theme.php | 8 +++-- themes/futaba/themelet.class.php | 12 +++---- themes/lite/layout.class.php | 51 ++++++++++++++------------- 8 files changed, 69 insertions(+), 64 deletions(-) diff --git a/ext/chatbox/php/ajaxcall.class.php b/ext/chatbox/php/ajaxcall.class.php index 05aa5c06..affeafc7 100644 --- a/ext/chatbox/php/ajaxcall.class.php +++ b/ext/chatbox/php/ajaxcall.class.php @@ -1,5 +1,8 @@ <?php class AjaxCall { + + public $reqType; + function AjaxCall($log = null) { header('Content-type: application/json'); session_start(); @@ -24,8 +27,10 @@ $ys = ys($_SESSION['yLog']); if ($ys->banned(ip())) { $this->sendBanned(); break; } - if ($post = $ys->post($nickname, $message)) // To use $post somewheres later - $this->sendUpdates(); + if ($post = $ys->post($nickname, $message)) { + // To use $post somewheres later + $this->sendUpdates(); + } break; case 'refresh': @@ -138,7 +143,6 @@ $send['error'] = false; echo jsonEncode($send); - } function unbanSelf() { @@ -235,7 +239,7 @@ } function clearLog() { - $log = $_POST['log']; + //$log = $_POST['log']; $send = array(); $ys = ys($_SESSION['yLog']); @@ -254,10 +258,10 @@ function clearLogs() { global $prefs; - $log = $_POST['log']; + //$log = $_POST['log']; $send = array(); - $ys = ys($_SESSION['yLog']); + //$ys = ys($_SESSION['yLog']); switch(true) { case !loggedIn(): diff --git a/ext/chatbox/php/filestorage.class.php b/ext/chatbox/php/filestorage.class.php index 35b8ede1..a7ab5ba4 100644 --- a/ext/chatbox/php/filestorage.class.php +++ b/ext/chatbox/php/filestorage.class.php @@ -2,6 +2,8 @@ class FileStorage { + public $shoutLog, $path, $handle; + function FileStorage($path, $shoutLog = false) { $this->shoutLog = $shoutLog; $folder = 'logs'; @@ -56,7 +58,6 @@ class FileStorage { fseek($this->handle, 0); //return stream_get_contents($this->handle); return file_get_contents($this->path); - } function write($contents) { @@ -79,7 +80,5 @@ class FileStorage { $this->save($default, false); return $default; } - } -?> \ No newline at end of file diff --git a/ext/chatbox/php/functions.php b/ext/chatbox/php/functions.php index 07078599..c61a65e3 100644 --- a/ext/chatbox/php/functions.php +++ b/ext/chatbox/php/functions.php @@ -16,8 +16,8 @@ } function getVar($name) { - if (isset($_POST[$name])) return $_POST[$name]; - if (isset($_GET[$name])) return $_GET[$name]; + if (isset($_POST[$name])) { return $_POST[$name]; } + if (isset($_GET[$name])) { return $_GET[$name]; } return null; } @@ -28,7 +28,7 @@ } function magic($s) { - if (get_magic_quotes_gpc()) $s = stripslashes($s); + if (get_magic_quotes_gpc()) { $s = stripslashes($s); } return $s; } @@ -147,6 +147,5 @@ return $_SESSION['yLoginHash'] == md5($prefs['password']); return false; - } -?> \ No newline at end of file + diff --git a/ext/chatbox/php/yshout.class.php b/ext/chatbox/php/yshout.class.php index b5b83e0b..e0074cba 100644 --- a/ext/chatbox/php/yshout.class.php +++ b/ext/chatbox/php/yshout.class.php @@ -250,4 +250,3 @@ class YShout { } -?> \ No newline at end of file diff --git a/ext/tagger/script.js b/ext/tagger/script.js index 7a10f162..9f0987d3 100644 --- a/ext/tagger/script.js +++ b/ext/tagger/script.js @@ -1,4 +1,4 @@ -/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */ +/*jshint dojo:true, forin:false, nonew:true, undef:true, strict:false, browser:true, jquery:true */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Tagger - Advanced Tagging v2 * @@ -27,7 +27,7 @@ var Tagger = { this.tag.suggest = null; this.tag.image_tags(); - // reveal + // reveal this.editor.container.style.display = ""; // dragging @@ -41,7 +41,7 @@ var Tagger = { }, alert : function (type,text,timeout) { - var id = "tagger_alert-"+type + var id = "tagger_alert-"+type; var t_alert = byId(id); if (t_alert) { if(text === false) { @@ -152,10 +152,10 @@ var Tagger = { }, ajax : function (url, callback) { - var http = (new XMLHttpRequest || new ActiveXObject("Microsoft.XMLHTTP")); + var http = (new XMLHttpRequest() || new ActiveXObject("Microsoft.XMLHTTP")); http.open("GET",url,true); http.onreadystatechange = function () { - if(http.readyState == 4) callback(http); + if(http.readyState == 4) { callback(http); } }; http.send(null); } @@ -164,22 +164,19 @@ var Tagger = { position : { set : function (x,y) { if (!x || !y) { - with(this.parent.editor.container.style) { - top = "25px"; - left = ""; - right = "25px"; - bottom = ""; - } + this.parent.editor.container.style.top = "25px"; + this.parent.editor.container.style.left = ""; + this.parent.editor.container.style.right = "25px"; + this.parent.editor.container.style.bottom = ""; + var xy = this.get(); x = xy[0]; y = xy[1]; } - with(this.parent.editor.container.style) { - top = y+"px"; - left = x+"px"; - right = ""; - bottom = ""; - } + this.parent.editor.container.style.top = y+"px"; + this.parent.editor.container.style.left = x+"px"; + this.parent.editor.container.style.right = ""; + this.parent.editor.container.style.bottom = ""; }, get : function () { diff --git a/ext/tagger/theme.php b/ext/tagger/theme.php index 733db116..398fea7d 100644 --- a/ext/tagger/theme.php +++ b/ext/tagger/theme.php @@ -11,10 +11,14 @@ class taggerTheme extends Themelet { // Initialization code $base_href = get_base_href(); // TODO: AJAX test and fallback. + $page->add_html_header("<script src='$base_href/ext/tagger/webtoolkit.drag.js' type='text/javascript'></script>"); $page->add_block(new Block(null, - "<script type='text/javascript'>Tagger.initialize(" - .$event->get_image()->id.");</script>","main",1000)); + "<script type='text/javascript'> + $( document ).ready(function() { + Tagger.initialize(".$event->get_image()->id."); + }); + </script>","main",1000)); // Tagger block $page->add_block( new Block( diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index 5044c3fe..151f952b 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -11,7 +11,7 @@ class Themelet extends BaseThemelet { private function gen_page_link($base_url, $query, $page, $name) { $link = make_link("$base_url/$page", $query); - return "[<a href='$link'>$name</a>]"; + return "[<a href='$link'>{$name}</a>]"; } private function gen_page_link_block($base_url, $query, $page, $current_page, $name) { @@ -25,16 +25,16 @@ class Themelet extends BaseThemelet { private function build_paginator($current_page, $total_pages, $base_url, $query) { $next = $current_page + 1; $prev = $current_page - 1; - $rand = mt_rand(1, $total_pages); + //$rand = mt_rand(1, $total_pages); $at_start = ($current_page <= 1 || $total_pages <= 1); $at_end = ($current_page >= $total_pages); - $first_html = $at_start ? "First" : $this->gen_page_link($base_url, $query, 1, "First"); + //$first_html = $at_start ? "First" : $this->gen_page_link($base_url, $query, 1, "First"); $prev_html = $at_start ? "Prev" : $this->gen_page_link($base_url, $query, $prev, "Prev"); - $random_html = $this->gen_page_link($base_url, $query, $rand, "Random"); + //$random_html = $this->gen_page_link($base_url, $query, $rand, "Random"); $next_html = $at_end ? "Next" : $this->gen_page_link($base_url, $query, $next, "Next"); - $last_html = $at_end ? "Last" : $this->gen_page_link($base_url, $query, $total_pages, "Last"); + //$last_html = $at_end ? "Last" : $this->gen_page_link($base_url, $query, $total_pages, "Last"); $start = $current_page-5 > 1 ? $current_page-5 : 1; $end = $start+10 < $total_pages ? $start+10 : $total_pages; @@ -47,7 +47,7 @@ class Themelet extends BaseThemelet { //return "<p class='paginator'>$first_html | $prev_html | $random_html | $next_html | $last_html". // "<br><< $pages_html >></p>"; - return "<p class='paginator'>$prev_html $pages_html $next_html</p>"; + return "<p class='paginator'>{$prev_html} {$pages_html} {$next_html}</p>"; } } diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index 73ae0a4e..f4922887 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -16,21 +16,21 @@ class Layout { $h = $block->header; $b = $block->body; $i = str_replace(' ', '_', $h) . $salt; - $html = "<section id='$i'>"; + $html = "<section id='{$i}'>"; if(!is_null($h)) { if($salt == "main") { - $html .= "<div class='maintop navside tab shm-toggler' data-toggle-sel='#$i'>$h</div>"; + $html .= "<div class='maintop navside tab shm-toggler' data-toggle-sel='#{$i}'>{$h}</div>"; } else { - $html .= "<div class='navtop navside tab shm-toggler' data-toggle-sel='#$i'>$h</div>"; + $html .= "<div class='navtop navside tab shm-toggler' data-toggle-sel='#{$i}'>{$h}</div>"; } } if(!is_null($b)) { if($salt =="main") { - $html .= "<div class='blockbody'>$b</div>"; + $html .= "<div class='blockbody'>{$b}</div>"; } else { $html .= " - <div class='navside tab'>$b</div> + <div class='navside tab'>{$b}</div> "; } } @@ -56,11 +56,11 @@ class Layout { for($i=0; $i < $count_pages_matched; $i++) { if($url == $pages_matched[$i]) { - $html = "<a class='tab-selected' href='$link'>$desc</a>"; + $html = "<a class='tab-selected' href='{$link}'>{$desc}</a>"; } } - if(is_null($html)) {$html = "<a class='tab' href='$link'>$desc</a>";} + if(is_null($html)) {$html = "<a class='tab' href='{$link}'>{$desc}</a>";} return $html; } @@ -79,12 +79,12 @@ class Layout { $header_html = ""; ksort($page->html_headers); foreach($page->html_headers as $line) { - $header_html .= "\t\t$line\n"; + $header_html .= "\t\t{$line}\n"; } $menu = "<div class='menu'> - <script type='text/javascript' src='$data_href/themes/$theme_name/wz_tooltip.js'></script> - <a href='".make_link()."' onmouseover='Tip('Home', BGCOLOR, '#C3D2E0', FADEIN, 100)' onmouseout='UnTip()'><img src='$data_href/favicon.ico' style='position: relative; top: 3px;'></a> + <script type='text/javascript' src='{$data_href}/themes/{$theme_name}/wz_tooltip.js'></script> + <a href='".make_link()."' onmouseover='Tip('Home', BGCOLOR, '#C3D2E0', FADEIN, 100)' onmouseout='UnTip()'><img src='{$data_href}/favicon.ico' style='position: relative; top: 3px;'></a> <b>{$site_name}</b> "; // Custom links: These appear on the menu. @@ -105,7 +105,7 @@ class Layout { $custom_links .= $this->navlinks(make_link('wiki/rules'), "Rules", array("wiki/rules")); $custom_links .= $this->navlinks(make_link('wiki'), "Wiki", array("wiki")); } - $menu .= "$custom_links</div>"; + $menu .= "{$custom_links}</div>"; $left_block_html = ""; $main_block_html = ""; @@ -134,11 +134,9 @@ class Layout { $custom_sublinks = "<div class='sbar'>"; // hack - global $user; $username = url_escape($user->name); // hack $qp = explode("/", ltrim(@$_GET["q"], "/")); - $hw = class_exists("Wiki"); $cs = ""; // php sucks @@ -153,12 +151,14 @@ class Layout { # the subnav links aren't shown, but it would # be nice to be correct case "post": - if(class_exists("NumericScore")){ $cs .= "<b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a><b>/</b><a href='".make_link('popular_by_month')."'>Month</a><b>/</b><a href='".make_link('popular_by_year')."'>Year</a> ";} + if(class_exists("NumericScore")){ + $cs .= "<b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a><b>/</b><a href='".make_link('popular_by_month')."'>Month</a><b>/</b><a href='".make_link('popular_by_year')."'>Year</a> "; + } $cs .= "<a class='tab' href='".make_link('post/list')."'>All</a>"; - if(class_exists("Favorites")){ $cs .= "<a class='tab' href='".make_link("post/list/favorited_by=$username/1")."'>My Favorites</a>";} + if(class_exists("Favorites")){ $cs .= "<a class='tab' href='".make_link("post/list/favorited_by={$username}/1")."'>My Favorites</a>";} if(class_exists("RSS_Images")){ $cs .= "<a class='tab' href='".make_link('rss/images')."'>Feed</a>";} if(class_exists("Random_Image")){ $cs .= "<a class='tab' href='".make_link("random_image/view")."'>Random Image</a>";} - if($hw){ $cs .= "<a class='tab' href='".make_link("wiki/posts")."'>Help</a>"; + if(class_exists("Wiki")){ $cs .= "<a class='tab' href='".make_link("wiki/posts")."'>Help</a>"; }else{ $cs .= "<a class='tab' href='".make_link("ext_doc/index")."'>Help</a>";} break; case "comment": @@ -187,7 +187,7 @@ class Layout { $cs .= "<a class='tab' href='".make_link("ext_doc/tag_edit")."'>Help</a>"; break; case "upload": - if($hw) $cs .= "<a class='tab' href='".make_link("wiki/upload_guidelines")."'>Guidelines</a>"; + if(class_exists("Wiki")) { $cs .= "<a class='tab' href='".make_link("wiki/upload_guidelines")."'>Guidelines</a>"; } break; case "random": $cs .= "<a class='tab' href='".make_link('random/view')."'>Shuffle</a>"; @@ -197,25 +197,28 @@ class Layout { $cs .= "<a class='tab' href='".make_link('featured/download')."'>Download</a>"; break; } - if($cs == "") {$custom_sublinks = "";} else { - $custom_sublinks .= "$cs</div>";} + if($cs == "") { + $custom_sublinks = ""; + } else { + $custom_sublinks .= "$cs</div>"; + } $debug = get_debug_info(); - $contact = empty($contact_link) ? "" : "<br><a href='mailto:$contact_link'>Contact</a>"; + $contact = empty($contact_link) ? "" : "<br><a href='mailto:{$contact_link}'>Contact</a>"; //$subheading = empty($page->subheading) ? "" : "<div id='subtitle'>{$page->subheading}</div>"; /*$wrapper = ""; if(strlen($page->heading) > 100) { $wrapper = ' style="height: 3em; overflow: auto;"'; }*/ - if($page->left_enabled==false) { + if($page->left_enabled == false) { $left_block_html = ""; - $main_block_html = "<article id='body_noleft'>$main_block_html</article>"; + $main_block_html = "<article id='body_noleft'>{$main_block_html}</article>"; } else { - $left_block_html = "<nav>$left_block_html</nav>"; - $main_block_html = "<article>$main_block_html</article>"; + $left_block_html = "<nav>{$left_block_html}</nav>"; + $main_block_html = "<article>{$main_block_html}</article>"; } $flash = get_prefixed_cookie("flash_message"); From 4ec5a7ce52f7468f313b15b7d96269d26617e8c8 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 22:22:16 -0400 Subject: [PATCH 37/66] Removing the closing PHP "?>" tag as per style guidelines. --- ext/blocks/main.php | 2 +- ext/blocks/theme.php | 2 +- ext/bookmarks/test.php | 3 +-- ext/bookmarks/theme.php | 2 +- ext/comment/main.php | 2 +- ext/comment/test.php | 2 +- ext/featured/main.php | 2 +- ext/featured/test.php | 2 +- ext/featured/theme.php | 2 +- 9 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ext/blocks/main.php b/ext/blocks/main.php index c80ce1af..9cd8f253 100644 --- a/ext/blocks/main.php +++ b/ext/blocks/main.php @@ -85,4 +85,4 @@ class Blocks extends Extension { } } } -?> + diff --git a/ext/blocks/theme.php b/ext/blocks/theme.php index 08f2eb1f..00cfd170 100644 --- a/ext/blocks/theme.php +++ b/ext/blocks/theme.php @@ -43,4 +43,4 @@ class BlocksTheme extends Themelet { $page->add_block(new Block("Block Editor", $html)); } } -?> + diff --git a/ext/bookmarks/test.php b/ext/bookmarks/test.php index 9bd0692a..66d41a96 100644 --- a/ext/bookmarks/test.php +++ b/ext/bookmarks/test.php @@ -1,4 +1,3 @@ - <?php class BookmarksTest extends ShimmieWebTestCase { function testBookmarks() { @@ -6,4 +5,4 @@ class BookmarksTest extends ShimmieWebTestCase { $this->get_page("bookmark/remove"); } } -?> + diff --git a/ext/bookmarks/theme.php b/ext/bookmarks/theme.php index 83c43b42..a1cb7b42 100644 --- a/ext/bookmarks/theme.php +++ b/ext/bookmarks/theme.php @@ -2,4 +2,4 @@ class BookmarksTheme extends Themelet { } -?> + diff --git a/ext/comment/main.php b/ext/comment/main.php index e6132807..5e3c870d 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -558,4 +558,4 @@ class CommentList extends Extension { } // }}} } -?> + diff --git a/ext/comment/test.php b/ext/comment/test.php index 600b2edc..1cae2054 100644 --- a/ext/comment/test.php +++ b/ext/comment/test.php @@ -101,4 +101,4 @@ class CommentListTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/featured/main.php b/ext/featured/main.php index 01bf6475..e0a23676 100644 --- a/ext/featured/main.php +++ b/ext/featured/main.php @@ -86,4 +86,4 @@ class Featured extends Extension { } } } -?> + diff --git a/ext/featured/test.php b/ext/featured/test.php index 293efe69..2308238e 100644 --- a/ext/featured/test.php +++ b/ext/featured/test.php @@ -30,4 +30,4 @@ class FeaturedTest extends ShimmieWebTestCase { $this->assert_no_text("Featured Image"); } } -?> + diff --git a/ext/featured/theme.php b/ext/featured/theme.php index 77afe5ff..35a64a36 100644 --- a/ext/featured/theme.php +++ b/ext/featured/theme.php @@ -34,4 +34,4 @@ class FeaturedTheme extends Themelet { "; } } -?> + From 860af2555035d681b49d65cb026351b4c3cd021a Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 22:22:45 -0400 Subject: [PATCH 38/66] Need to pull in the global $user variable. --- ext/bookmarks/main.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ext/bookmarks/main.php b/ext/bookmarks/main.php index 93661086..d864d92a 100644 --- a/ext/bookmarks/main.php +++ b/ext/bookmarks/main.php @@ -32,8 +32,7 @@ class Bookmarks extends Extension { } protected function install() { - global $database; - global $config; + global $database, $config; // shortcut to latest if($config->get_int("ext_bookmarks_version") < 1) { @@ -61,9 +60,9 @@ class Bookmarks extends Extension { } private function add_bookmark(/*string*/ $url, /*string*/ $title) { - global $database; + global $database, $user; $sql = "INSERT INTO bookmark(owner_id, url, title) VALUES (?, ?, ?)"; $database->Execute($sql, array($user->id, $url, $title)); } } -?> + From daee99c1bccb692a2c30a37f97d155c13ad8b057 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 22:28:53 -0400 Subject: [PATCH 39/66] Removing the closing PHP "?>" tag as per style guidelines. --- ext/handle_pixel/main.php | 2 +- ext/handle_pixel/test.php | 2 +- ext/handle_pixel/theme.php | 2 +- ext/handle_video/main.php | 2 +- ext/handle_video/theme.php | 2 +- ext/home/main.php | 2 +- ext/home/test.php | 2 +- ext/home/theme.php | 2 +- ext/image/main.php | 2 +- ext/image/test.php | 2 +- ext/image/theme.php | 2 +- ext/index/main.php | 2 +- ext/index/test.php | 2 +- ext/index/theme.php | 2 +- ext/user/main.php | 2 +- ext/user/theme.php | 2 +- ext/view/main.php | 2 +- ext/wiki/main.php | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index 0ee4ca69..bf345352 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -177,4 +177,4 @@ class PixelFileHandler extends DataHandlerExtension { } // }}} } -?> + diff --git a/ext/handle_pixel/test.php b/ext/handle_pixel/test.php index ac8411c8..c8096114 100644 --- a/ext/handle_pixel/test.php +++ b/ext/handle_pixel/test.php @@ -14,4 +14,4 @@ class PixelHandlerTest extends ShimmieWebTestCase { # FIXME: test that it gets displayed properly } } -?> + diff --git a/ext/handle_pixel/theme.php b/ext/handle_pixel/theme.php index 74f9af4c..de8c0c60 100644 --- a/ext/handle_pixel/theme.php +++ b/ext/handle_pixel/theme.php @@ -31,4 +31,4 @@ class PixelFileHandlerTheme extends Themelet { $page->add_block(new Block("Image", $html, "main", 10)); } } -?> + diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index 9d34d436..e08c005a 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -79,4 +79,4 @@ class VideoFileHandler extends DataHandlerExtension { return FALSE; } } -?> + diff --git a/ext/handle_video/theme.php b/ext/handle_video/theme.php index 3e584ce3..d6d7f723 100644 --- a/ext/handle_video/theme.php +++ b/ext/handle_video/theme.php @@ -37,4 +37,4 @@ else { $page->add_block(new Block("Video", $html, "main", 10)); } } -?> + diff --git a/ext/home/main.php b/ext/home/main.php index 2c585a1a..d170b135 100644 --- a/ext/home/main.php +++ b/ext/home/main.php @@ -80,4 +80,4 @@ class Home extends Extension { return $this->theme->build_body($sitename, $main_links, $main_text, $contact_link, $num_comma, $counter_text); } } -?> + diff --git a/ext/home/test.php b/ext/home/test.php index ada45afe..3a142074 100644 --- a/ext/home/test.php +++ b/ext/home/test.php @@ -8,4 +8,4 @@ class HomeTest extends ShimmieWebTestCase { # FIXME: test search box } } -?> + diff --git a/ext/home/theme.php b/ext/home/theme.php index c93cdf13..2d4fa889 100644 --- a/ext/home/theme.php +++ b/ext/home/theme.php @@ -55,4 +55,4 @@ EOD </div>"; } } -?> + diff --git a/ext/image/main.php b/ext/image/main.php index 32d1bf97..ccb07112 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -441,4 +441,4 @@ class ImageIO extends Extension { } // end of class ImageIO -?> + diff --git a/ext/image/test.php b/ext/image/test.php index 0bb36eef..3e5a94b3 100644 --- a/ext/image/test.php +++ b/ext/image/test.php @@ -23,4 +23,4 @@ class ImageTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/image/theme.php b/ext/image/theme.php index 9a07b7fe..36145c07 100644 --- a/ext/image/theme.php +++ b/ext/image/theme.php @@ -32,4 +32,4 @@ class ImageIOTheme extends Themelet { return $html; } } -?> + diff --git a/ext/index/main.php b/ext/index/main.php index e2664883..1c00bdad 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -381,4 +381,4 @@ class Index extends Extension { $this->stpen++; } } -?> + diff --git a/ext/index/test.php b/ext/index/test.php index 509ab7ff..6496882b 100644 --- a/ext/index/test.php +++ b/ext/index/test.php @@ -112,4 +112,4 @@ class IndexTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/index/theme.php b/ext/index/theme.php index 7c04910b..81fb318f 100644 --- a/ext/index/theme.php +++ b/ext/index/theme.php @@ -106,4 +106,4 @@ and of course start organising your images :-) return $table; } } -?> + diff --git a/ext/user/main.php b/ext/user/main.php index 67755004..0c94c5d0 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -585,4 +585,4 @@ class UserPage extends Extension { } // }}} } -?> + diff --git a/ext/user/theme.php b/ext/user/theme.php index 2f0c0363..7d749de8 100644 --- a/ext/user/theme.php +++ b/ext/user/theme.php @@ -235,4 +235,4 @@ class UserPageTheme extends Themelet { } // }}} } -?> + diff --git a/ext/view/main.php b/ext/view/main.php index c97e0592..35bb8081 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -139,4 +139,4 @@ class ViewImage extends Extension { $this->theme->display_page($event->get_image(), $iibbe->parts); } } -?> + diff --git a/ext/wiki/main.php b/ext/wiki/main.php index 94f9fb0f..d1457584 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -483,4 +483,4 @@ class Wiki extends Extension { } // }}} } -?> + From 50686ac61ec182492477f213bacfd6f8a0c413a3 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 22:29:29 -0400 Subject: [PATCH 40/66] More linting, fix PHPDoc style. --- ext/image/main.php | 2 +- ext/image/theme.php | 8 +++++--- ext/index/script.js | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/image/main.php b/ext/image/main.php index ccb07112..d9a2edbb 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -418,7 +418,7 @@ class ImageIO extends Extension { inspected later by an admin? */ log_debug("image", "Removing image with hash ".$existing->hash); - $existing->remove_image_only(); // Actually delete the old image file from disk + $existing->remove_image_only(); // Actually delete the old image file from disk // Update the data in the database. $database->Execute( diff --git a/ext/image/theme.php b/ext/image/theme.php index 36145c07..072888bf 100644 --- a/ext/image/theme.php +++ b/ext/image/theme.php @@ -4,7 +4,8 @@ class ImageIOTheme extends Themelet { * Display a link to delete an image * (Added inline Javascript to confirm the deletion) * - * @param $image_id The image to delete + * @param $image_id integer The image to delete + * @return string */ public function get_deleter_html(/*int*/ $image_id) { global $config; @@ -18,11 +19,12 @@ class ImageIOTheme extends Themelet { return $html; } - + /** * Display link to replace the image * - * @param $image_id The image to replace + * @param $image_id integer The image to replace + * @return string */ public function get_replace_html(/*int*/ $image_id) { $html = make_form(make_link("image/replace"))." diff --git a/ext/index/script.js b/ext/index/script.js index 6842ef34..7fd63d6a 100644 --- a/ext/index/script.js +++ b/ext/index/script.js @@ -1,3 +1,5 @@ +/*jshint bitwise:false, curly:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:false, strict:false, browser:true, jquery:true */ + $(function() { var blocked_tags = ($.cookie("ui-blocked-tags") || "").split(" "); var needs_refresh = false; From b241390fa410b58899639c89a4077e59a1bc5ebc Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 22:34:45 -0400 Subject: [PATCH 41/66] Removing the closing PHP "?>" tag as per style guidelines. --- ext/admin/main.php | 2 +- ext/admin/test.php | 2 +- ext/admin/theme.php | 2 +- ext/alias_editor/main.php | 2 +- ext/alias_editor/theme.php | 2 +- ext/arrowkey_navigation/main.php | 2 +- ext/artists/main.php | 2 +- ext/artists/test.php | 2 +- ext/artists/theme.php | 2 +- ext/ban_words/main.php | 2 +- ext/ban_words/test.php | 2 +- ext/blotter/main.php | 2 +- ext/blotter/test.php | 2 +- ext/blotter/theme.php | 2 +- ext/browser_search/main.php | 2 +- ext/browser_search/test.php | 2 +- ext/custom_html_headers/main.php | 2 +- ext/et/main.php | 2 +- ext/et/theme.php | 2 +- ext/ext_manager/main.php | 2 +- ext/ext_manager/test.php | 2 +- ext/ext_manager/theme.php | 2 +- ext/pools/main.php | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ext/admin/main.php b/ext/admin/main.php index 68273195..dc8be5f0 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -257,4 +257,4 @@ class AdminPage extends Extension { return true; } } -?> + diff --git a/ext/admin/test.php b/ext/admin/test.php index 73bc7629..3aad3d93 100644 --- a/ext/admin/test.php +++ b/ext/admin/test.php @@ -80,4 +80,4 @@ class AdminPageTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/admin/theme.php b/ext/admin/theme.php index 3eefdb11..d1f8c71b 100644 --- a/ext/admin/theme.php +++ b/ext/admin/theme.php @@ -68,4 +68,4 @@ class AdminPageTheme extends Themelet { return $html; } } -?> + diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php index 54015ab9..883292d9 100644 --- a/ext/alias_editor/main.php +++ b/ext/alias_editor/main.php @@ -153,4 +153,4 @@ class AliasEditor extends Extension { // missing out the images tagged with the oldtag public function get_priority() {return 60;} } -?> + diff --git a/ext/alias_editor/theme.php b/ext/alias_editor/theme.php index 173f7bd2..21a984b8 100644 --- a/ext/alias_editor/theme.php +++ b/ext/alias_editor/theme.php @@ -73,4 +73,4 @@ class AliasEditorTheme extends Themelet { $this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages); } } -?> + diff --git a/ext/arrowkey_navigation/main.php b/ext/arrowkey_navigation/main.php index b1c1b972..4d248f32 100644 --- a/ext/arrowkey_navigation/main.php +++ b/ext/arrowkey_navigation/main.php @@ -79,4 +79,4 @@ class ArrowkeyNavigation extends Extension { return $pageinfo; } } -?> + diff --git a/ext/artists/main.php b/ext/artists/main.php index f74022d5..43edec08 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -1221,4 +1221,4 @@ class Artists extends Extension { return $result; } } -?> + diff --git a/ext/artists/test.php b/ext/artists/test.php index 7f794343..767d764b 100644 --- a/ext/artists/test.php +++ b/ext/artists/test.php @@ -5,4 +5,4 @@ class ArtistTest extends ShimmieWebTestCase { $this->get_page("post/list/author=bob/1"); } } -?> + diff --git a/ext/artists/theme.php b/ext/artists/theme.php index c6d957a3..3cecede4 100644 --- a/ext/artists/theme.php +++ b/ext/artists/theme.php @@ -514,4 +514,4 @@ class ArtistsTheme extends Themelet { } } -?> + diff --git a/ext/ban_words/main.php b/ext/ban_words/main.php index 88fe247a..027f8d8f 100644 --- a/ext/ban_words/main.php +++ b/ext/ban_words/main.php @@ -101,4 +101,4 @@ xanax public function get_priority() {return 30;} } -?> + diff --git a/ext/ban_words/test.php b/ext/ban_words/test.php index e9f9cee8..37c0cfda 100644 --- a/ext/ban_words/test.php +++ b/ext/ban_words/test.php @@ -42,4 +42,4 @@ class BanWordsTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/blotter/main.php b/ext/blotter/main.php index f02e1461..191d20ff 100644 --- a/ext/blotter/main.php +++ b/ext/blotter/main.php @@ -131,4 +131,4 @@ class Blotter extends Extension { $this->theme->display_blotter($entries); } } -?> + diff --git a/ext/blotter/test.php b/ext/blotter/test.php index 1e532906..20c321b0 100644 --- a/ext/blotter/test.php +++ b/ext/blotter/test.php @@ -34,4 +34,4 @@ class BlotterTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/blotter/theme.php b/ext/blotter/theme.php index 23395bc5..27987687 100644 --- a/ext/blotter/theme.php +++ b/ext/blotter/theme.php @@ -176,4 +176,4 @@ class BlotterTheme extends Themelet { return $html; } } -?> + diff --git a/ext/browser_search/main.php b/ext/browser_search/main.php index 266c7cd1..719dddfc 100644 --- a/ext/browser_search/main.php +++ b/ext/browser_search/main.php @@ -101,4 +101,4 @@ class BrowserSearch extends Extension { $event->panel->add_block($sb); } } -?> + diff --git a/ext/browser_search/test.php b/ext/browser_search/test.php index 0f7ce77f..e0df2f92 100644 --- a/ext/browser_search/test.php +++ b/ext/browser_search/test.php @@ -5,4 +5,4 @@ class BrowserSearchTest extends SCoreWebTestCase { $this->get_page("browser_search/test"); } } -?> + diff --git a/ext/custom_html_headers/main.php b/ext/custom_html_headers/main.php index 4bb00058..d8dc8b57 100644 --- a/ext/custom_html_headers/main.php +++ b/ext/custom_html_headers/main.php @@ -71,4 +71,4 @@ class custom_html_headers extends Extension { } } } -?> + diff --git a/ext/et/main.php b/ext/et/main.php index 570eb3da..d08fd552 100644 --- a/ext/et/main.php +++ b/ext/et/main.php @@ -83,4 +83,4 @@ class ET extends Extension { return $info; } } -?> + diff --git a/ext/et/theme.php b/ext/et/theme.php index 265b019a..2239807b 100644 --- a/ext/et/theme.php +++ b/ext/et/theme.php @@ -59,4 +59,4 @@ EOD; return $html; } } -?> + diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index fdd59c4e..1dc41624 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -199,4 +199,4 @@ class ExtManager extends Extension { } } } -?> + diff --git a/ext/ext_manager/test.php b/ext/ext_manager/test.php index 1ef29a37..4a4b0601 100644 --- a/ext/ext_manager/test.php +++ b/ext/ext_manager/test.php @@ -23,4 +23,4 @@ class ExtManagerTest extends SCoreWebTestCase { # FIXME: test that some extensions can be added and removed? :S } } -?> + diff --git a/ext/ext_manager/theme.php b/ext/ext_manager/theme.php index 0b9cb270..fa340d41 100644 --- a/ext/ext_manager/theme.php +++ b/ext/ext_manager/theme.php @@ -136,4 +136,4 @@ class ExtManagerTheme extends Themelet { $page->add_block(new Block("Documentation", $html)); } } -?> + diff --git a/ext/pools/main.php b/ext/pools/main.php index 965fb98e..40270a0b 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -881,4 +881,4 @@ class Pools extends Extension { } } -?> + From a7faefc5e0981ff34fb1aad11384c9976f73794d Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Thu, 24 Apr 2014 22:35:01 -0400 Subject: [PATCH 42/66] Spelling. --- tests/test_install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_install.php b/tests/test_install.php index 80a4d20d..2c2cbace 100644 --- a/tests/test_install.php +++ b/tests/test_install.php @@ -21,7 +21,7 @@ $db = $options["d"]; $host = rtrim(trim(trim($options["h"], '"')), "/"); // Check if they are empty. -if (empty($db)){ die("Error: need to specifiy a database for the test environment."); } +if (empty($db)){ die("Error: need to specify a database for the test environment."); } if (empty($host)){ $host = "http://127.0.0.1"; } define("_TRAVIS_DATABASE", $db); From dcadfc395ab3d91d42ce3f0d1ee5c207828268c1 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 14:14:22 -0400 Subject: [PATCH 43/66] Move this code back down. --- themes/lite/layout.class.php | 114 ++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index f4922887..69f4a6a7 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -9,62 +9,6 @@ */ class Layout { - /** - * A handy function which does exactly what it says in the method name - */ - private function block_to_html($block, $hidable=false, $salt="") { - $h = $block->header; - $b = $block->body; - $i = str_replace(' ', '_', $h) . $salt; - $html = "<section id='{$i}'>"; - if(!is_null($h)) { - if($salt == "main") { - $html .= "<div class='maintop navside tab shm-toggler' data-toggle-sel='#{$i}'>{$h}</div>"; - } else { - $html .= "<div class='navtop navside tab shm-toggler' data-toggle-sel='#{$i}'>{$h}</div>"; - } - } - if(!is_null($b)) { - if($salt =="main") { - $html .= "<div class='blockbody'>{$b}</div>"; - } - else { - $html .= " - <div class='navside tab'>{$b}</div> - "; - } - } - $html .= "</section>"; - return $html; - } - - private function navlinks($link, $desc, $pages_matched) { - /** - * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) - */ - $html = null; - $url = ltrim($_GET['q'], "/"); - - $re1='.*?'; - $re2='((?:[a-z][a-z_]+))'; - - if (preg_match_all ("/".$re1.$re2."/is", $url, $matches)) { - $url=$matches[1][0]; - } - - $count_pages_matched = count($pages_matched); - - for($i=0; $i < $count_pages_matched; $i++) { - if($url == $pages_matched[$i]) { - $html = "<a class='tab-selected' href='{$link}'>{$desc}</a>"; - } - } - - if(is_null($html)) {$html = "<a class='tab' href='{$link}'>{$desc}</a>";} - - return $html; - } - /** * turns the Page into HTML */ @@ -263,4 +207,62 @@ class Layout { </html> EOD; } /* end of function display_page() */ + + + /** + * A handy function which does exactly what it says in the method name + */ + private function block_to_html($block, $hidable=false, $salt="") { + $h = $block->header; + $b = $block->body; + $i = str_replace(' ', '_', $h) . $salt; + $html = "<section id='{$i}'>"; + if(!is_null($h)) { + if($salt == "main") { + $html .= "<div class='maintop navside tab shm-toggler' data-toggle-sel='#{$i}'>{$h}</div>"; + } else { + $html .= "<div class='navtop navside tab shm-toggler' data-toggle-sel='#{$i}'>{$h}</div>"; + } + } + if(!is_null($b)) { + if($salt =="main") { + $html .= "<div class='blockbody'>{$b}</div>"; + } + else { + $html .= " + <div class='navside tab'>{$b}</div> + "; + } + } + $html .= "</section>"; + return $html; + } + + private function navlinks($link, $desc, $pages_matched) { + /** + * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) + */ + $html = null; + $url = ltrim($_GET['q'], "/"); + + $re1='.*?'; + $re2='((?:[a-z][a-z_]+))'; + + if (preg_match_all ("/".$re1.$re2."/is", $url, $matches)) { + $url=$matches[1][0]; + } + + $count_pages_matched = count($pages_matched); + + for($i=0; $i < $count_pages_matched; $i++) { + if($url == $pages_matched[$i]) { + $html = "<a class='tab-selected' href='{$link}'>{$desc}</a>"; + } + } + + if(is_null($html)) {$html = "<a class='tab' href='{$link}'>{$desc}</a>";} + + return $html; + } + } /* end of class Layout */ From 6724f2b75a536eb51b29b71002a1727cbb3224dc Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 14:17:44 -0400 Subject: [PATCH 44/66] Make these functions public to prevent scrutinizer from complaining. --- themes/lite/layout.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index 69f4a6a7..29c0bb3d 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -212,7 +212,7 @@ EOD; /** * A handy function which does exactly what it says in the method name */ - private function block_to_html($block, $hidable=false, $salt="") { + public function block_to_html($block, $hidable=false, $salt="") { $h = $block->header; $b = $block->body; $i = str_replace(' ', '_', $h) . $salt; @@ -238,7 +238,7 @@ EOD; return $html; } - private function navlinks($link, $desc, $pages_matched) { + public function navlinks($link, $desc, $pages_matched) { /** * Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.) */ From 7ef68b15f928d22c756e6de7de0495f76f42b1df Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 15:38:15 -0400 Subject: [PATCH 45/66] Fix indentation. --- ext/user/main.php | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/ext/user/main.php b/ext/user/main.php index 0c94c5d0..31c6bb37 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -147,11 +147,13 @@ class UserPage extends Extension { // Try forwarding to same page on logout unless user comes from registration page if ($config->get_int("user_loginshowprofile",0) == 0 && - isset($_SERVER['HTTP_REFERER']) && - strstr($_SERVER['HTTP_REFERER'], "post/")) - $page->set_redirect ($_SERVER['HTTP_REFERER']); - else - $page->set_redirect(make_link()); + isset($_SERVER['HTTP_REFERER']) && + strstr($_SERVER['HTTP_REFERER'], "post/")) + { + $page->set_redirect ($_SERVER['HTTP_REFERER']); + } else { + $page->set_redirect(make_link()); + } } if(!$user->check_auth_token()) { @@ -349,13 +351,16 @@ class UserPage extends Extension { $this->set_login_cookie($duser->name, $pass); log_info("user", "{$user->class->name} logged in"); $page->set_mode("redirect"); - - // Try returning to previous page - if ($config->get_int("user_loginshowprofile",0) == 0 && - isset($_SERVER['HTTP_REFERER']) && - strstr($_SERVER['HTTP_REFERER'], "post/")) - $page->set_redirect($_SERVER['HTTP_REFERER']); - else $page->set_redirect(make_link("user")); + + // Try returning to previous page + if ($config->get_int("user_loginshowprofile",0) == 0 && + isset($_SERVER['HTTP_REFERER']) && + strstr($_SERVER['HTTP_REFERER'], "post/")) + { + $page->set_redirect($_SERVER['HTTP_REFERER']); + } else { + $page->set_redirect(make_link("user")); + } } else { log_warning("user", "Failed to log in as ".html_escape($name)." [$hash]"); From 478eb3a4cca607ef3b22805cd56da59e88d74d4c Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 15:39:00 -0400 Subject: [PATCH 46/66] Linting: Check for null return value, and throw an exception if null. --- ext/user/main.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ext/user/main.php b/ext/user/main.php index 31c6bb37..130930dd 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -50,6 +50,8 @@ class UserDeletionEvent extends Event { class UserCreationException extends SCoreException {} +class NullUserException extends SCoreException {} + class UserPage extends Extension { public function onInitExt(InitExtEvent $event) { global $config; @@ -163,6 +165,9 @@ class UserPage extends Extension { else if($event->get_arg(0) == "change_pass") { if(isset($_POST['id']) && isset($_POST['pass1']) && isset($_POST['pass2'])) { $duser = User::by_id($_POST['id']); + if ( ! $duser instanceof User) { + throw new NullUserException("Error: the user id does not exist!"); + } $pass1 = $_POST['pass1']; $pass2 = $_POST['pass2']; $this->change_password_wrapper($duser, $pass1, $pass2); @@ -171,6 +176,9 @@ class UserPage extends Extension { else if($event->get_arg(0) == "change_email") { if(isset($_POST['id']) && isset($_POST['address'])) { $duser = User::by_id($_POST['id']); + if ( ! $duser instanceof User) { + throw new NullUserException("Error: the user id does not exist!"); + } $address = $_POST['address']; $this->change_email_wrapper($duser, $address); } @@ -179,6 +187,9 @@ class UserPage extends Extension { global $_user_classes; if(isset($_POST['id']) && isset($_POST['class'])) { $duser = User::by_id($_POST['id']); + if ( ! $duser instanceof User) { + throw new NullUserException("Error: the user id does not exist!"); + } $class = $_POST['class']; if(!array_key_exists($class, $_user_classes)) { throw Exception("Invalid user class: ".html_escape($class)); @@ -495,6 +506,9 @@ class UserPage extends Extension { if($user->class->name == "admin") { $duser = User::by_id($_POST['id']); + if ( ! $duser instanceof User) { + throw new NullUserException("Error: the user id does not exist!"); + } $duser->set_class($class); flash_message("Class changed"); From 141ec532368b36c869d835ffa3be54a445c68b6f Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 15:55:31 -0400 Subject: [PATCH 47/66] Rename these class functions to prevent warnings from scrutinizer. --- themes/futaba/themelet.class.php | 10 +++++----- themes/lite/themelet.class.php | 32 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index 151f952b..27f35ceb 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -30,11 +30,11 @@ class Themelet extends BaseThemelet { $at_start = ($current_page <= 1 || $total_pages <= 1); $at_end = ($current_page >= $total_pages); - //$first_html = $at_start ? "First" : $this->gen_page_link($base_url, $query, 1, "First"); - $prev_html = $at_start ? "Prev" : $this->gen_page_link($base_url, $query, $prev, "Prev"); - //$random_html = $this->gen_page_link($base_url, $query, $rand, "Random"); - $next_html = $at_end ? "Next" : $this->gen_page_link($base_url, $query, $next, "Next"); - //$last_html = $at_end ? "Last" : $this->gen_page_link($base_url, $query, $total_pages, "Last"); + //$first_html = $at_start ? "First" : $this->litetheme_gen_page_link($base_url, $query, 1, "First"); + $prev_html = $at_start ? "Prev" : $this->gen_page_link($base_url, $query, $prev, "Prev"); + //$random_html = $this->litetheme_gen_page_link($base_url, $query, $rand, "Random"); + $next_html = $at_end ? "Next" : $this->gen_page_link($base_url, $query, $next, "Next"); + //$last_html = $at_end ? "Last" : $this->litetheme_gen_page_link($base_url, $query, $total_pages, "Last"); $start = $current_page-5 > 1 ? $current_page-5 : 1; $end = $start+10 < $total_pages ? $start+10 : $total_pages; diff --git a/themes/lite/themelet.class.php b/themes/lite/themelet.class.php index 939c0a6b..631ef171 100644 --- a/themes/lite/themelet.class.php +++ b/themes/lite/themelet.class.php @@ -16,25 +16,25 @@ class Themelet extends BaseThemelet { */ public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) { if($total_pages == 0) $total_pages = 1; - $body = $this->build_paginator($page_number, $total_pages, $base, $query); + $body = $this->litetheme_build_paginator($page_number, $total_pages, $base, $query); $page->add_block(new Block(null, $body, "main", 90)); } - private function gen_page_link($base_url, $query, $page, $name, $link_class=null) { + private function litetheme_gen_page_link($base_url, $query, $page, $name, $link_class=null) { $link = make_link("$base_url/$page", $query); - return "<a class='$link_class' href='$link'>$name</a>"; + return "<a class='$link_class' href='$link'>$name</a>"; } - private function gen_page_link_block($base_url, $query, $page, $current_page, $name) { + private function litetheme_gen_page_link_block($base_url, $query, $page, $current_page, $name) { $paginator = ""; - - if($page == $current_page) {$link_class = "tab-selected";} else {$link_class = "";} - $paginator .= $this->gen_page_link($base_url, $query, $page, $name, $link_class); - - return $paginator; + + if($page == $current_page) {$link_class = "tab-selected";} else {$link_class = "";} + $paginator .= $this->litetheme_gen_page_link($base_url, $query, $page, $name, $link_class); + + return $paginator; } - private function build_paginator($current_page, $total_pages, $base_url, $query) { + private function litetheme_build_paginator($current_page, $total_pages, $base_url, $query) { $next = $current_page + 1; $prev = $current_page - 1; $rand = mt_rand(1, $total_pages); @@ -42,18 +42,18 @@ class Themelet extends BaseThemelet { $at_start = ($current_page <= 1 || $total_pages <= 1); $at_end = ($current_page >= $total_pages); - $first_html = $at_start ? "<span class='tab'>First</span>" : $this->gen_page_link($base_url, $query, 1, "First"); - $prev_html = $at_start ? "<span class='tab'>Prev</span>" : $this->gen_page_link($base_url, $query, $prev, "Prev"); - $random_html = $this->gen_page_link($base_url, $query, $rand, "Random"); - $next_html = $at_end ? "<span class='tab'>Next</span>" : $this->gen_page_link($base_url, $query, $next, "Next"); - $last_html = $at_end ? "<span class='tab'>Last</span>" : $this->gen_page_link($base_url, $query, $total_pages, "Last"); + $first_html = $at_start ? "<span class='tab'>First</span>" : $this->litetheme_gen_page_link($base_url, $query, 1, "First"); + $prev_html = $at_start ? "<span class='tab'>Prev</span>" : $this->litetheme_gen_page_link($base_url, $query, $prev, "Prev"); + $random_html = $this->litetheme_gen_page_link($base_url, $query, $rand, "Random"); + $next_html = $at_end ? "<span class='tab'>Next</span>" : $this->litetheme_gen_page_link($base_url, $query, $next, "Next"); + $last_html = $at_end ? "<span class='tab'>Last</span>" : $this->litetheme_gen_page_link($base_url, $query, $total_pages, "Last"); $start = $current_page-5 > 1 ? $current_page-5 : 1; $end = $start+10 < $total_pages ? $start+10 : $total_pages; $pages = array(); foreach(range($start, $end) as $i) { - $pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, $i); + $pages[] = $this->litetheme_gen_page_link_block($base_url, $query, $i, $current_page, $i); } $pages_html = implode(" ", $pages); From 9acf6c7f19d5c258f34cf3871c700fc7beb9c5bb Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 15:57:23 -0400 Subject: [PATCH 48/66] Rename these class functions to prevent warnings from scrutinizer. --- themes/futaba/themelet.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index 27f35ceb..393afc60 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -5,24 +5,24 @@ class Themelet extends BaseThemelet { */ public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $position=90) { if($total_pages == 0) $total_pages = 1; - $body = $this->build_paginator($page_number, $total_pages, $base, $query); + $body = $this->futaba_build_paginator($page_number, $total_pages, $base, $query); $page->add_block(new Block(null, $body, "main", $position)); } - private function gen_page_link($base_url, $query, $page, $name) { + private function futaba_gen_page_link($base_url, $query, $page, $name) { $link = make_link("$base_url/$page", $query); return "[<a href='$link'>{$name}</a>]"; } - private function gen_page_link_block($base_url, $query, $page, $current_page, $name) { + private function futaba_gen_page_link_block($base_url, $query, $page, $current_page, $name) { $paginator = ""; if($page == $current_page) $paginator .= "<b>"; - $paginator .= $this->gen_page_link($base_url, $query, $page, $name); + $paginator .= $this->futaba_gen_page_link($base_url, $query, $page, $name); if($page == $current_page) $paginator .= "</b>"; return $paginator; } - private function build_paginator($current_page, $total_pages, $base_url, $query) { + private function futaba_build_paginator($current_page, $total_pages, $base_url, $query) { $next = $current_page + 1; $prev = $current_page - 1; //$rand = mt_rand(1, $total_pages); @@ -31,9 +31,9 @@ class Themelet extends BaseThemelet { $at_end = ($current_page >= $total_pages); //$first_html = $at_start ? "First" : $this->litetheme_gen_page_link($base_url, $query, 1, "First"); - $prev_html = $at_start ? "Prev" : $this->gen_page_link($base_url, $query, $prev, "Prev"); + $prev_html = $at_start ? "Prev" : $this->futaba_gen_page_link($base_url, $query, $prev, "Prev"); //$random_html = $this->litetheme_gen_page_link($base_url, $query, $rand, "Random"); - $next_html = $at_end ? "Next" : $this->gen_page_link($base_url, $query, $next, "Next"); + $next_html = $at_end ? "Next" : $this->futaba_gen_page_link($base_url, $query, $next, "Next"); //$last_html = $at_end ? "Last" : $this->litetheme_gen_page_link($base_url, $query, $total_pages, "Last"); $start = $current_page-5 > 1 ? $current_page-5 : 1; @@ -41,7 +41,7 @@ class Themelet extends BaseThemelet { $pages = array(); foreach(range($start, $end) as $i) { - $pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, $i); + $pages[] = $this->futaba_gen_page_link_block($base_url, $query, $i, $current_page, $i); } $pages_html = implode(" ", $pages); From 5b5fd955b7a8ec4c3ef5f32e4d51c5e84a9374be Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 16:07:30 -0400 Subject: [PATCH 49/66] New exception type. --- core/exceptions.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/exceptions.class.php b/core/exceptions.class.php index fd52b7af..d627dc3c 100644 --- a/core/exceptions.class.php +++ b/core/exceptions.class.php @@ -9,3 +9,11 @@ class SCoreException extends Exception {} */ class PermissionDeniedException extends SCoreException {} +/** + * Class ImageDoesNotExist + * + * This exception is used when an Image cannot be found by ID. + * + * Example: Image::by_id(-1) returns null + */ +class ImageDoesNotExist extends SCoreException {} From b4e6c0b743fd98dda01daf11e38145f85259f577 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 16:08:00 -0400 Subject: [PATCH 50/66] Explicitly check if we can actually find the image by Id. --- ext/tag_history/main.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ext/tag_history/main.php b/ext/tag_history/main.php index b6e6605c..e3c60131 100644 --- a/ext/tag_history/main.php +++ b/ext/tag_history/main.php @@ -143,10 +143,15 @@ class Tag_History extends Extension { $stored_result_id = $result['id']; $stored_image_id = int_escape($result['image_id']); $stored_tags = $result['tags']; - + + $image = Image::by_id($stored_image_id); + if ( ! $image instanceof Image) { + throw new ImageDoesNotExist("Error: cannot find any image with the ID = ". $stored_image_id); + } + log_debug("tag_history", 'Reverting tags of Image #'.$stored_image_id.' to ['.$stored_tags.']'); // all should be ok so we can revert by firing the SetUserTags event. - send_event(new TagSetEvent(Image::by_id($stored_image_id), $stored_tags)); + send_event(new TagSetEvent($image, $stored_tags)); // all should be done now so redirect the user back to the image $page->set_mode("redirect"); @@ -307,10 +312,15 @@ class Tag_History extends Extension { $stored_result_id = int_escape($result['id']); $stored_image_id = int_escape($result['image_id']); $stored_tags = $result['tags']; - + + $image = Image::by_id($stored_image_id); + if ( ! $image instanceof Image) { + throw new ImageDoesNotExist("Error: cannot find any image with the ID = ". $stored_image_id); + } + log_debug("tag_history", 'Reverting tags of Image #'.$stored_image_id.' to ['.$stored_tags.']'); // all should be ok so we can revert by firing the SetTags event. - send_event(new TagSetEvent(Image::by_id($stored_image_id), $stored_tags)); + send_event(new TagSetEvent($image, $stored_tags)); $this->theme->add_status('Reverted Change','Reverted Image #'.$image_id.' to Tag History #'.$stored_result_id.' ('.$row['tags'].')'); } } @@ -373,4 +383,4 @@ class Tag_History extends Extension { } } } -?> + From bcd3f991decd2a5167a5c4707b331503f4cdba80 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 17:34:20 -0400 Subject: [PATCH 51/66] Removing the closing PHP "?>" tag as per style guidelines. --- ext/danbooru_api/main.php | 2 +- ext/numeric_score/main.php | 2 +- ext/numeric_score/theme.php | 2 +- ext/resize/main.php | 2 +- ext/resize/theme.php | 2 +- ext/tips/main.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php index 2b475a9e..8edba323 100644 --- a/ext/danbooru_api/main.php +++ b/ext/danbooru_api/main.php @@ -435,4 +435,4 @@ class DanbooruApi extends Extension { } } -?> + diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index e9a471f5..a5f58440 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -300,4 +300,4 @@ class NumericScore extends Extension { array("imageid" => $image_id, "id" => $image_id)); } } -?> + diff --git a/ext/numeric_score/theme.php b/ext/numeric_score/theme.php index e805c929..e089bc74 100644 --- a/ext/numeric_score/theme.php +++ b/ext/numeric_score/theme.php @@ -89,4 +89,4 @@ class NumericScoreTheme extends Themelet { } } -?> + diff --git a/ext/resize/main.php b/ext/resize/main.php index 705980eb..59880c35 100644 --- a/ext/resize/main.php +++ b/ext/resize/main.php @@ -312,4 +312,4 @@ class ResizeImage extends Extension { log_info("resize", "Resized Image #{$image_obj->id} - New hash: {$new_hash}"); } } -?> + diff --git a/ext/resize/theme.php b/ext/resize/theme.php index e19a8e32..3d09e1f0 100644 --- a/ext/resize/theme.php +++ b/ext/resize/theme.php @@ -35,4 +35,4 @@ class ResizeImageTheme extends Themelet { $page->add_block(new Block($title, $message)); } } -?> + diff --git a/ext/tips/main.php b/ext/tips/main.php index d1c08929..bef66c60 100644 --- a/ext/tips/main.php +++ b/ext/tips/main.php @@ -151,4 +151,4 @@ class Tips extends Extension { $database->execute("DELETE FROM tips WHERE id = ?", array($tipID)); } } -?> + From 1e15c5e47afeba57c3e26bf9c5df9e50bc259afe Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 17:38:25 -0400 Subject: [PATCH 52/66] Explicitly declare this class variable --- ext/chatbox/php/ajaxcall.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/chatbox/php/ajaxcall.class.php b/ext/chatbox/php/ajaxcall.class.php index affeafc7..149a2ecc 100644 --- a/ext/chatbox/php/ajaxcall.class.php +++ b/ext/chatbox/php/ajaxcall.class.php @@ -2,6 +2,7 @@ class AjaxCall { public $reqType; + public $updates; function AjaxCall($log = null) { header('Content-type: application/json'); From 3a1197256aea6dc569781aa2d9f637a8190dcacf Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 17:39:06 -0400 Subject: [PATCH 53/66] Need to pull in the global $page variable for this method. --- ext/resize/main.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/resize/main.php b/ext/resize/main.php index 59880c35..72b29231 100644 --- a/ext/resize/main.php +++ b/ext/resize/main.php @@ -59,7 +59,8 @@ class ResizeImage extends Extension { } public function onDataUpload(DataUploadEvent $event) { - global $config; + global $config, $page; + $image_obj = Image::by_id($event->image_id); if($config->get_bool("resize_upload") == true && ($image_obj->ext == "jpg" || $image_obj->ext == "png" || $image_obj->ext == "gif")){ From 6f685ca2273606a029d70d421e86f83be16018ea Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 17:39:46 -0400 Subject: [PATCH 54/66] Use the method from core/util to parse the bool from the DB instead. --- ext/tips/main.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/tips/main.php b/ext/tips/main.php index bef66c60..94f8bf2f 100644 --- a/ext/tips/main.php +++ b/ext/tips/main.php @@ -137,9 +137,9 @@ class Tips extends Extension { $tip = $database->get_row("SELECT * FROM tips WHERE id = ? ", array($tipID)); - if($tip['enable'] == "Y") { + if (bool_escape($tip['enable'])) { $enable = "N"; - } elseif($tip['enable'] == "N") { + } else { $enable = "Y"; } From c85630198f308638d46f18ad8374081e380384d8 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 17:40:14 -0400 Subject: [PATCH 55/66] These variables where never defined depending on the execution path. --- ext/danbooru_api/main.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php index 8edba323..af254ec7 100644 --- a/ext/danbooru_api/main.php +++ b/ext/danbooru_api/main.php @@ -261,6 +261,8 @@ class DanbooruApi extends Extension { if(($event->get_arg(1) == 'find_posts') || (($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'index.xml'))) { $this->authenticate_user(); + $start = 0; + if(isset($_GET['md5'])) { $md5list = explode(",",$_GET['md5']); @@ -268,6 +270,7 @@ class DanbooruApi extends Extension { { $results[] = Image::by_hash($md5); } + $count = count($results); } elseif(isset($_GET['id'])) { $idlist = explode(",",$_GET['id']); @@ -275,6 +278,7 @@ class DanbooruApi extends Extension { { $results[] = Image::by_id($id); } + $count = count($results); } else { $limit = isset($_GET['limit']) ? int_escape($_GET['limit']) : 100; @@ -294,7 +298,7 @@ class DanbooruApi extends Extension { // Now we have the array $results filled with Image objects // Let's display them - $xml = "<posts count=\"$count\" offset=\"$start\">\n"; + $xml = "<posts count=\"{$count}\" offset=\"{$start}\">\n"; foreach($results as $img) { // Sanity check to see if $img is really an image object From 3e899710d7d1cf0d05278c7b98f7d44ce038a5a6 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 17:40:42 -0400 Subject: [PATCH 56/66] Stop scrutinizer from complaining here. --- ext/numeric_score/main.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index a5f58440..e2754f5a 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -137,6 +137,10 @@ class NumericScore extends Extension { else if($event->page_matches("popular_by_year")){ $dte = array($totaldate, $year, "\\y\\e\\a\\r\=Y", "year"); } + else { + // this should never happen due to the fact that the page event is already matched against earlier. + throw new UnexpectedValueException("Error: Invalid page event."); + } $sql .= " AND NOT numeric_score=0 ORDER BY numeric_score DESC LIMIT :limit OFFSET 0"; //filter images by score != 0 + date > limit to max images on one page > order from highest to lowest score From 5f2be45f68e381dd2beeef415c317d093941c99e Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 21:42:52 -0400 Subject: [PATCH 57/66] Fix the PHPDoc comments on these. --- core/util.inc.php | 63 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index 77c6c33e..5700463c 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -10,6 +10,7 @@ require_once "lib/context.php"; /** * Make some data safe for printing into HTML * + * @param $input * @return string */ function html_escape($input) { @@ -19,6 +20,7 @@ function html_escape($input) { /** * Make sure some data is safe to be used in integer context * + * @param $input * @return int */ function int_escape($input) { @@ -32,6 +34,7 @@ function int_escape($input) { /** * Make sure some data is safe to be used in URL context * + * @param $input * @return string */ function url_escape($input) { @@ -66,6 +69,7 @@ function url_escape($input) { /** * Make sure some data is safe to be used in SQL context * + * @param $input * @return string */ function sql_escape($input) { @@ -77,6 +81,7 @@ function sql_escape($input) { /** * Turn all manner of HTML / INI / JS / DB booleans into a PHP one * + * @param $input * @return boolean */ function bool_escape($input) { @@ -112,6 +117,7 @@ function bool_escape($input) { * Some functions require a callback function for escaping, * but we might not want to alter the data * + * @param $input * @return string */ function no_escape($input) { @@ -156,6 +162,7 @@ function truncate($string, $limit, $break=" ", $pad="...") { /** * Turn a human readable filesize into an integer, eg 1KB -> 1024 * + * @param $limit * @return int */ function parse_shorthand_int($limit) { @@ -185,6 +192,7 @@ function parse_shorthand_int($limit) { /** * Turn an integer into a human readable filesize, eg 1024 -> 1KB * + * @param $int * @return string */ function to_shorthand_int($int) { @@ -206,6 +214,8 @@ function to_shorthand_int($int) { /** * Turn a date into a time, a date, an "X minutes ago...", etc * + * @param $date + * @param bool $html * @return string */ function autodate($date, $html=true) { @@ -217,6 +227,7 @@ function autodate($date, $html=true) { /** * Check if a given string is a valid date-time. ( Format: yyyy-mm-dd hh:mm:ss ) * + * @param $dateTime * @return boolean */ function isValidDateTime($dateTime) { @@ -232,6 +243,7 @@ function isValidDateTime($dateTime) { /** * Check if a given string is a valid date. ( Format: yyyy-mm-dd ) * + * @param $date * @return boolean */ function isValidDate($date) { @@ -251,6 +263,8 @@ function isValidDate($date) { * * FIXME: also check that IP ban ext is installed * + * @param $ip + * @param $ban_reason * @return string */ function show_ip($ip, $ban_reason) { @@ -298,6 +312,8 @@ function endsWith(/*string*/ $haystack, /*string*/ $needle) { * * eg make_link("post/list") becomes "/v2/index.php?q=post/list" * + * @param null $page + * @param null $query * @return string */ function make_link($page=null, $query=null) { @@ -334,6 +350,7 @@ function make_link($page=null, $query=null) { /** * Take the current URL and modify some paramaters * + * @param $changes * @return string */ function modify_current_url($changes) { @@ -375,6 +392,7 @@ function modify_url($url, $changes) { /** * Turn a relative link into an absolute one, including hostname * + * @param $link * @return string */ function make_http(/*string*/ $link) { @@ -388,11 +406,11 @@ function make_http(/*string*/ $link) { /** * Make a form tag with relevant auth token and stuff * - * @param target string - * @param method string - * @param multipart boolean - * @param form_id string - * @param onsubmit string + * @param string $target + * @param string $method + * @param bool $multipart + * @param string $form_id + * @param string $onsubmit * * @return string */ @@ -508,16 +526,18 @@ function captcha_check() { \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /** -* Get MIME type for file -* -* The contents of this function are taken from the __getMimeType() function -* from the "Amazon S3 PHP class" which is Copyright (c) 2008, Donovan Schönknecht -* and released under the 'Simplified BSD License'. -* -* @internal Used to get mime types -* @param string &$file File path -* @return string -*/ + * Get MIME type for file + * + * The contents of this function are taken from the __getMimeType() function + * from the "Amazon S3 PHP class" which is Copyright (c) 2008, Donovan Schönknecht + * and released under the 'Simplified BSD License'. + * + * @internal Used to get mime types + * @param string &$file File path + * @param string $ext + * @param bool $list + * @return string + */ function getMimeType($file, $ext="", $list=false) { // Static extension lookup @@ -642,6 +662,8 @@ function _count_execs($db, $sql, $inputarray) { /** * Compare two Block objects, used to sort them before being displayed * + * @param Block $a + * @param Block $b * @return int */ function blockcmp(Block $a, Block $b) { @@ -705,6 +727,7 @@ function get_memory_limit() { * Get the currently active IP, masked to make it not change when the last * octet or two change, for use in session cookies and such * + * @param Config $config * @return string */ function get_session_ip(Config $config) { @@ -791,6 +814,7 @@ function get_base_href() { * A shorthand way to send a TextFormattingEvent and get the * results * + * @param $string * @return string */ function format_text(/*string*/ $string) { @@ -1009,6 +1033,8 @@ function get_request_id() { /** * Remove an item from an array * + * @param $array + * @param $to_remove * @return array */ function array_remove($array, $to_remove) { @@ -1027,6 +1053,8 @@ function array_remove($array, $to_remove) { * * Also removes duplicate values from the array. * + * @param $array + * @param $element * @return array */ function array_add($array, $element) { @@ -1040,6 +1068,7 @@ function array_add($array, $element) { /** * Return the unique elements of an array, case insensitively * + * @param $array * @return array */ function array_iunique($array) { @@ -1063,6 +1092,8 @@ function array_iunique($array) { * * from http://uk.php.net/network * + * @param $IP + * @param $CIDR * @return bool */ function ip_in_range($IP, $CIDR) { @@ -1123,7 +1154,7 @@ function deltree($f) { } /** - * Copy an entire file heirachy + * Copy an entire file hierarchy * * from a comment on http://uk.php.net/copy */ From 8f6046784847f5e69c224df3d046815388089b2c Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 22:33:57 -0400 Subject: [PATCH 58/66] This code doesn't seem to actually be used by anything at all. --- core/extension.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/extension.class.php b/core/extension.class.php index 5730e4ac..1a0d50c5 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -220,12 +220,15 @@ abstract class DataHandlerExtension extends Extension { } } + /* public function onSetupBuilding(SetupBuildingEvent $event) { $sb = $this->setup(); if($sb) $event->panel->add_block($sb); } protected function setup() {} + */ + abstract protected function supported_ext($ext); abstract protected function check_contents($tmpname); abstract protected function create_image_from_data($filename, $metadata); From 1ca3865a1c5b4847eaa7485b42f5dc86751b5b56 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 22:54:51 -0400 Subject: [PATCH 59/66] Removing the closing PHP "?>" tag as per style guidelines. (Also see: https://stackoverflow.com/questions/4410704/why-would-one-omit-the-close-tag ) --- ext/alias_editor/test.php | 2 +- ext/amazon_s3/main.php | 2 +- ext/bbcode/main.php | 2 +- ext/bbcode/test.php | 2 +- ext/blocks/test.php | 2 +- ext/bulk_add/main.php | 2 +- ext/bulk_add/test.php | 2 +- ext/bulk_add/theme.php | 2 +- ext/bulk_add_csv/main.php | 2 +- ext/bulk_add_csv/theme.php | 2 +- ext/bulk_remove/main.php | 2 +- ext/chatbox/main.php | 2 +- ext/chatbox/preferences.php | 2 +- ext/cron_uploader/main.php | 2 +- ext/danbooru_api/test.php | 2 +- ext/downtime/main.php | 2 +- ext/downtime/test.php | 2 +- ext/downtime/theme.php | 2 +- ext/emoticons/main.php | 2 +- ext/emoticons/test.php | 2 +- ext/emoticons/theme.php | 2 +- ext/et/test.php | 2 +- ext/favorites/main.php | 2 +- ext/favorites/test.php | 2 +- ext/favorites/theme.php | 2 +- ext/forum/main.php | 2 +- ext/forum/theme.php | 2 +- ext/google_analytics/main.php | 2 +- ext/handle_404/main.php | 2 +- ext/handle_404/test.php | 2 +- ext/handle_archive/main.php | 2 +- ext/handle_flash/main.php | 2 +- ext/handle_flash/theme.php | 2 +- ext/handle_ico/main.php | 2 +- ext/handle_ico/test.php | 2 +- ext/handle_ico/theme.php | 2 +- ext/handle_mp3/main.php | 2 +- ext/handle_mp3/theme.php | 2 +- ext/handle_svg/main.php | 2 +- ext/handle_svg/test.php | 2 +- ext/handle_svg/theme.php | 2 +- ext/hellban/main.php | 2 +- ext/holiday/main.php | 2 +- ext/holiday/theme.php | 2 +- ext/image_hash_ban/main.php | 2 +- ext/image_hash_ban/test.php | 2 +- ext/image_hash_ban/theme.php | 2 +- ext/image_view_counter/main.php | 2 +- ext/ipban/main.php | 2 +- ext/ipban/test.php | 2 +- ext/ipban/theme.php | 2 +- ext/link_image/main.php | 2 +- ext/link_image/test.php | 2 +- ext/link_image/theme.php | 2 +- ext/log_db/main.php | 2 +- ext/log_db/test.php | 2 +- ext/log_db/theme.php | 2 +- ext/log_net/main.php | 2 +- ext/mail/main.php | 2 +- ext/mass_tagger/main.php | 2 +- ext/mass_tagger/theme.php | 2 +- ext/not_a_tag/main.php | 2 +- ext/not_a_tag/theme.php | 2 +- ext/notes/main.php | 2 +- ext/notes/theme.php | 2 +- ext/numeric_score/test.php | 2 +- ext/oekaki/main.php | 2 +- ext/oekaki/test.php | 2 +- ext/oekaki/theme.php | 2 +- ext/pm/main.php | 2 +- ext/pm/test.php | 2 +- ext/pm/theme.php | 2 +- ext/pm_triggers/main.php | 2 +- ext/pools/test.php | 2 +- ext/pools/theme.php | 2 +- ext/qr_code/main.php | 2 +- ext/qr_code/theme.php | 2 +- ext/random_image/main.php | 2 +- ext/random_image/test.php | 2 +- ext/random_image/theme.php | 2 +- ext/random_list/main.php | 2 +- ext/rating/main.php | 2 +- ext/rating/test.php | 2 +- ext/rating/theme.php | 2 +- ext/regen_thumb/main.php | 2 +- ext/regen_thumb/test.php | 2 +- ext/regen_thumb/theme.php | 2 +- ext/relatationships/main.php | 2 +- ext/relatationships/theme.php | 2 +- ext/report_image/main.php | 2 +- ext/report_image/test.php | 2 +- ext/report_image/theme.php | 2 +- ext/res_limit/main.php | 2 +- ext/res_limit/test.php | 2 +- ext/rotate/main.php | 2 +- ext/rotate/theme.php | 2 +- ext/rss_comments/main.php | 2 +- ext/rss_comments/test.php | 2 +- ext/rss_images/main.php | 2 +- ext/rss_images/test.php | 2 +- ext/rss_images/theme.php | 2 +- ext/setup/main.php | 2 +- ext/setup/test.php | 2 +- ext/setup/theme.php | 2 +- ext/shimmie_api/test.php | 2 +- ext/simpletest/main.php | 2 +- ext/simpletest/theme.php | 2 +- ext/site_description/main.php | 2 +- ext/site_description/test.php | 2 +- ext/sitemap/main.php | 2 +- ext/sitemap/test.php | 2 +- ext/source_history/main.php | 2 +- ext/source_history/theme.php | 2 +- ext/tag_categories/main.php | 2 +- ext/tag_edit/main.php | 2 +- ext/tag_edit/test.php | 2 +- ext/tag_edit/theme.php | 2 +- ext/tag_editcloud/main.php | 2 +- ext/tag_history/test.php | 2 +- ext/tag_history/theme.php | 2 +- ext/tag_list/main.php | 2 +- ext/tag_list/test.php | 2 +- ext/tag_list/theme.php | 2 +- ext/tagger/main.php | 2 +- ext/tagger/theme.php | 2 +- ext/tips/test.php | 2 +- ext/tips/theme.php | 2 +- ext/twitter_soc/main.php | 2 +- ext/twitter_soc/test.php | 2 +- ext/twitter_soc/theme.php | 2 +- ext/update/main.php | 2 +- ext/update/theme.php | 2 +- ext/upgrade/main.php | 2 +- ext/user/test.php | 2 +- ext/view/test.php | 2 +- ext/view/theme.php | 2 +- ext/wiki/test.php | 2 +- ext/wiki/theme.php | 2 +- ext/word_filter/main.php | 2 +- ext/word_filter/test.php | 2 +- 140 files changed, 140 insertions(+), 140 deletions(-) diff --git a/ext/alias_editor/test.php b/ext/alias_editor/test.php index f1f9c6a1..2aa3ab78 100644 --- a/ext/alias_editor/test.php +++ b/ext/alias_editor/test.php @@ -97,4 +97,4 @@ class AliasEditorTest extends ShimmieWebTestCase { */ } } -?> + diff --git a/ext/amazon_s3/main.php b/ext/amazon_s3/main.php index b4191a69..7b39e5a2 100644 --- a/ext/amazon_s3/main.php +++ b/ext/amazon_s3/main.php @@ -72,4 +72,4 @@ class UploadS3 extends Extension { } } } -?> + diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php index 4b10a5c7..9812d0ca 100644 --- a/ext/bbcode/main.php +++ b/ext/bbcode/main.php @@ -156,4 +156,4 @@ class BBCode extends FormatterExtension { return $text; } } -?> + diff --git a/ext/bbcode/test.php b/ext/bbcode/test.php index a24c548f..14aac004 100644 --- a/ext/bbcode/test.php +++ b/ext/bbcode/test.php @@ -81,4 +81,4 @@ class BBCodeUnitTest extends UnitTestCase { return $bb->strip($in); } } -?> + diff --git a/ext/blocks/test.php b/ext/blocks/test.php index a68442b3..d6f91a38 100644 --- a/ext/blocks/test.php +++ b/ext/blocks/test.php @@ -8,4 +8,4 @@ class BlocksTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/bulk_add/main.php b/ext/bulk_add/main.php index cf58e4a3..ea590a3f 100644 --- a/ext/bulk_add/main.php +++ b/ext/bulk_add/main.php @@ -111,4 +111,4 @@ class BulkAdd extends Extension { } } } -?> + diff --git a/ext/bulk_add/test.php b/ext/bulk_add/test.php index 40b4d4e5..3f57fe99 100644 --- a/ext/bulk_add/test.php +++ b/ext/bulk_add/test.php @@ -31,4 +31,4 @@ class BulkAddTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/bulk_add/theme.php b/ext/bulk_add/theme.php index 3df8a40b..787a4532 100644 --- a/ext/bulk_add/theme.php +++ b/ext/bulk_add/theme.php @@ -42,4 +42,4 @@ class BulkAddTheme extends Themelet { $this->messages[] = new Block($title, $body); } } -?> + diff --git a/ext/bulk_add_csv/main.php b/ext/bulk_add_csv/main.php index 4ff15773..7fd6d2a7 100644 --- a/ext/bulk_add_csv/main.php +++ b/ext/bulk_add_csv/main.php @@ -136,4 +136,4 @@ class BulkAddCSV extends Extension { fclose($csvhandle); } } -?> + diff --git a/ext/bulk_add_csv/theme.php b/ext/bulk_add_csv/theme.php index dfff459b..01c2e21f 100644 --- a/ext/bulk_add_csv/theme.php +++ b/ext/bulk_add_csv/theme.php @@ -41,4 +41,4 @@ class BulkAddCSVTheme extends Themelet { $this->messages[] = new Block($title, $body); } } -?> + diff --git a/ext/bulk_remove/main.php b/ext/bulk_remove/main.php index 2e609386..592d85f6 100644 --- a/ext/bulk_remove/main.php +++ b/ext/bulk_remove/main.php @@ -130,4 +130,4 @@ class BulkRemove extends Extension { $image_arr = $_POST["bulk_remove_images"]; } } -?> + diff --git a/ext/chatbox/main.php b/ext/chatbox/main.php index 8d52bd6a..0f65d31b 100644 --- a/ext/chatbox/main.php +++ b/ext/chatbox/main.php @@ -33,4 +33,4 @@ class Chatbox extends Extension { $page->add_block($chatblock); } } -?> + diff --git a/ext/chatbox/preferences.php b/ext/chatbox/preferences.php index ef79bbf1..cc72b33b 100644 --- a/ext/chatbox/preferences.php +++ b/ext/chatbox/preferences.php @@ -71,4 +71,4 @@ resetPrefs(); //loadPrefs(); -?> + diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 24c62c55..97f4062c 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -415,4 +415,4 @@ class CronUploader extends Extension { file_put_contents ($log_path, $content); } } -?> + diff --git a/ext/danbooru_api/test.php b/ext/danbooru_api/test.php index a5218626..3717ed80 100644 --- a/ext/danbooru_api/test.php +++ b/ext/danbooru_api/test.php @@ -23,4 +23,4 @@ class DanbooruApiTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/downtime/main.php b/ext/downtime/main.php index 63421db8..2c857fba 100644 --- a/ext/downtime/main.php +++ b/ext/downtime/main.php @@ -40,4 +40,4 @@ class Downtime extends Extension { else return false; } } -?> + diff --git a/ext/downtime/test.php b/ext/downtime/test.php index 868eeef6..77657dff 100644 --- a/ext/downtime/test.php +++ b/ext/downtime/test.php @@ -20,4 +20,4 @@ class DowntimeTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/downtime/theme.php b/ext/downtime/theme.php index cec59c7b..aae0cca5 100644 --- a/ext/downtime/theme.php +++ b/ext/downtime/theme.php @@ -59,4 +59,4 @@ class DowntimeTheme extends Themelet { EOD; } } -?> + diff --git a/ext/emoticons/main.php b/ext/emoticons/main.php index ec7a071d..a33b06c7 100644 --- a/ext/emoticons/main.php +++ b/ext/emoticons/main.php @@ -32,4 +32,4 @@ class EmoticonList extends Extension { } } } -?> + diff --git a/ext/emoticons/test.php b/ext/emoticons/test.php index 3758ce3b..7f9237c7 100644 --- a/ext/emoticons/test.php +++ b/ext/emoticons/test.php @@ -19,4 +19,4 @@ class EmoticonTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/emoticons/theme.php b/ext/emoticons/theme.php index 22eaa350..dff9f98a 100644 --- a/ext/emoticons/theme.php +++ b/ext/emoticons/theme.php @@ -18,4 +18,4 @@ class EmoticonListTheme extends Themelet { $page->set_data($html); } } -?> + diff --git a/ext/et/test.php b/ext/et/test.php index 6d4fcae8..d6df53b9 100644 --- a/ext/et/test.php +++ b/ext/et/test.php @@ -7,4 +7,4 @@ class ETTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/favorites/main.php b/ext/favorites/main.php index 10242e53..e90aa009 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -196,4 +196,4 @@ class Favorites extends Extension { array("image_id"=>$image->id)); } } -?> + diff --git a/ext/favorites/test.php b/ext/favorites/test.php index 34dc91eb..c3c4b8d1 100644 --- a/ext/favorites/test.php +++ b/ext/favorites/test.php @@ -30,4 +30,4 @@ class FavoritesTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/favorites/theme.php b/ext/favorites/theme.php index 14a4fd39..d530e497 100644 --- a/ext/favorites/theme.php +++ b/ext/favorites/theme.php @@ -35,4 +35,4 @@ class FavoritesTheme extends Themelet { } } -?> + diff --git a/ext/forum/main.php b/ext/forum/main.php index 62951e4f..1fea2064 100644 --- a/ext/forum/main.php +++ b/ext/forum/main.php @@ -412,4 +412,4 @@ class Forum extends Extension { } } } -?> + diff --git a/ext/forum/theme.php b/ext/forum/theme.php index 78c06261..74d7c5df 100644 --- a/ext/forum/theme.php +++ b/ext/forum/theme.php @@ -229,4 +229,4 @@ class ForumTheme extends Themelet { return $html; } } -?> + diff --git a/ext/google_analytics/main.php b/ext/google_analytics/main.php index f1ef0b08..3f0f8608 100644 --- a/ext/google_analytics/main.php +++ b/ext/google_analytics/main.php @@ -35,4 +35,4 @@ class google_analytics extends Extension { } } } -?> + diff --git a/ext/handle_404/main.php b/ext/handle_404/main.php index cc41b03d..fd00790c 100644 --- a/ext/handle_404/main.php +++ b/ext/handle_404/main.php @@ -50,4 +50,4 @@ class Handle404 extends Extension { public function get_priority() {return 99;} } -?> + diff --git a/ext/handle_404/test.php b/ext/handle_404/test.php index 452af8da..ad6d3943 100644 --- a/ext/handle_404/test.php +++ b/ext/handle_404/test.php @@ -10,4 +10,4 @@ class Handle404Test extends SCoreWebTestCase { $this->assert_response(200); } } -?> + diff --git a/ext/handle_archive/main.php b/ext/handle_archive/main.php index f4dfe3dc..3f61ad60 100644 --- a/ext/handle_archive/main.php +++ b/ext/handle_archive/main.php @@ -110,4 +110,4 @@ class ArchiveFileHandler extends Extension { // $this->theme->add_status("Adding $subdir", $list); } } -?> + diff --git a/ext/handle_flash/main.php b/ext/handle_flash/main.php index 88becce7..f84153ad 100644 --- a/ext/handle_flash/main.php +++ b/ext/handle_flash/main.php @@ -46,4 +46,4 @@ class FlashFileHandler extends DataHandlerExtension { return true; } } -?> + diff --git a/ext/handle_flash/theme.php b/ext/handle_flash/theme.php index 6b956a75..e4557088 100644 --- a/ext/handle_flash/theme.php +++ b/ext/handle_flash/theme.php @@ -23,4 +23,4 @@ class FlashFileHandlerTheme extends Themelet { $page->add_block(new Block("Flash Animation", $html, "main", 10)); } } -?> + diff --git a/ext/handle_ico/main.php b/ext/handle_ico/main.php index 07fa97ec..dae069c8 100644 --- a/ext/handle_ico/main.php +++ b/ext/handle_ico/main.php @@ -107,4 +107,4 @@ class IcoFileHandler extends Extension { return true; } } -?> + diff --git a/ext/handle_ico/test.php b/ext/handle_ico/test.php index dd362055..9292a4a5 100644 --- a/ext/handle_ico/test.php +++ b/ext/handle_ico/test.php @@ -17,4 +17,4 @@ class IcoHandlerTest extends ShimmieWebTestCase { # FIXME: test that it gets displayed properly } } -?> + diff --git a/ext/handle_ico/theme.php b/ext/handle_ico/theme.php index 27b1ae74..aa092709 100644 --- a/ext/handle_ico/theme.php +++ b/ext/handle_ico/theme.php @@ -9,4 +9,4 @@ class IcoFileHandlerTheme extends Themelet { $page->add_block(new Block("Image", $html, "main", 10)); } } -?> + diff --git a/ext/handle_mp3/main.php b/ext/handle_mp3/main.php index 2a81fcbb..be807472 100644 --- a/ext/handle_mp3/main.php +++ b/ext/handle_mp3/main.php @@ -59,4 +59,4 @@ class MP3FileHandler extends DataHandlerExtension { return FALSE; } } -?> + diff --git a/ext/handle_mp3/theme.php b/ext/handle_mp3/theme.php index 59ecefac..d6beb126 100644 --- a/ext/handle_mp3/theme.php +++ b/ext/handle_mp3/theme.php @@ -20,4 +20,4 @@ class MP3FileHandlerTheme extends Themelet { $page->add_block(new Block("Music", $html, "main", 10)); } } -?> + diff --git a/ext/handle_svg/main.php b/ext/handle_svg/main.php index 76b9a18d..d27bb6f0 100644 --- a/ext/handle_svg/main.php +++ b/ext/handle_svg/main.php @@ -103,4 +103,4 @@ class MiniSVGParser { function endElement($parser, $name) { } } -?> + diff --git a/ext/handle_svg/test.php b/ext/handle_svg/test.php index 934d6ef6..f6420684 100644 --- a/ext/handle_svg/test.php +++ b/ext/handle_svg/test.php @@ -34,4 +34,4 @@ class SVGHandlerTest extends ShimmieWebTestCase { # FIXME: test that it gets displayed properly } } -?> + diff --git a/ext/handle_svg/theme.php b/ext/handle_svg/theme.php index 304baf79..76d76aa3 100644 --- a/ext/handle_svg/theme.php +++ b/ext/handle_svg/theme.php @@ -12,4 +12,4 @@ class SVGFileHandlerTheme extends Themelet { $page->add_block(new Block("Image", $html, "main", 10)); } } -?> + diff --git a/ext/hellban/main.php b/ext/hellban/main.php index ae6e2be6..cac33ee9 100644 --- a/ext/hellban/main.php +++ b/ext/hellban/main.php @@ -22,4 +22,4 @@ class HellBan extends Extension { } } } -?> + diff --git a/ext/holiday/main.php b/ext/holiday/main.php index f435099a..be23350c 100644 --- a/ext/holiday/main.php +++ b/ext/holiday/main.php @@ -29,4 +29,4 @@ class Holiday extends Extension { } } } -?> + diff --git a/ext/holiday/theme.php b/ext/holiday/theme.php index 2012f3ee..fa32d350 100644 --- a/ext/holiday/theme.php +++ b/ext/holiday/theme.php @@ -17,4 +17,4 @@ class HolidayTheme extends Themelet { } } } -?> + diff --git a/ext/image_hash_ban/main.php b/ext/image_hash_ban/main.php index 410f0b41..5037c844 100644 --- a/ext/image_hash_ban/main.php +++ b/ext/image_hash_ban/main.php @@ -158,4 +158,4 @@ class ImageBan extends Extension { // in before resolution limit plugin public function get_priority() {return 30;} } -?> + diff --git a/ext/image_hash_ban/test.php b/ext/image_hash_ban/test.php index 9af952e8..d84889fd 100644 --- a/ext/image_hash_ban/test.php +++ b/ext/image_hash_ban/test.php @@ -34,4 +34,4 @@ class HashBanTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/image_hash_ban/theme.php b/ext/image_hash_ban/theme.php index 87c70cb1..0c759a4a 100644 --- a/ext/image_hash_ban/theme.php +++ b/ext/image_hash_ban/theme.php @@ -92,4 +92,4 @@ class ImageBanTheme extends Themelet { return $html; } } -?> + diff --git a/ext/image_view_counter/main.php b/ext/image_view_counter/main.php index a5da3593..4d8fa1cf 100644 --- a/ext/image_view_counter/main.php +++ b/ext/image_view_counter/main.php @@ -105,4 +105,4 @@ class image_view_counter extends Extension { return $view_count; } } -?> + diff --git a/ext/ipban/main.php b/ext/ipban/main.php index c566f47a..67e363fa 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -284,4 +284,4 @@ class IPBan extends Extension { } // }}} } -?> + diff --git a/ext/ipban/test.php b/ext/ipban/test.php index 9fd636d4..4e4226b6 100644 --- a/ext/ipban/test.php +++ b/ext/ipban/test.php @@ -25,5 +25,5 @@ class IPBanTest extends SCoreWebTestCase { # FIXME: test that the IP is actually banned } } -?> + diff --git a/ext/ipban/theme.php b/ext/ipban/theme.php index e9e927b6..9b9996e6 100644 --- a/ext/ipban/theme.php +++ b/ext/ipban/theme.php @@ -57,4 +57,4 @@ class IPBanTheme extends Themelet { $page->add_block(new Block("Edit IP Bans", $html)); } } -?> + diff --git a/ext/link_image/main.php b/ext/link_image/main.php index 3183a41d..75f97221 100644 --- a/ext/link_image/main.php +++ b/ext/link_image/main.php @@ -34,4 +34,4 @@ class LinkImage extends Extension { 'text_link' => $text_link); } } -?> + diff --git a/ext/link_image/test.php b/ext/link_image/test.php index 83f641f7..1e70a4d2 100644 --- a/ext/link_image/test.php +++ b/ext/link_image/test.php @@ -22,4 +22,4 @@ class LinkImageTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/link_image/theme.php b/ext/link_image/theme.php index 24de94dc..f92891c6 100644 --- a/ext/link_image/theme.php +++ b/ext/link_image/theme.php @@ -91,4 +91,4 @@ class LinkImageTheme extends Themelet { "; } } -?> + diff --git a/ext/log_db/main.php b/ext/log_db/main.php index 126a6f66..c72c51cd 100644 --- a/ext/log_db/main.php +++ b/ext/log_db/main.php @@ -135,4 +135,4 @@ class LogDatabase extends Extension { } } } -?> + diff --git a/ext/log_db/test.php b/ext/log_db/test.php index f2e9b8dd..2314d41f 100644 --- a/ext/log_db/test.php +++ b/ext/log_db/test.php @@ -10,4 +10,4 @@ class LogDatabaseTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/log_db/theme.php b/ext/log_db/theme.php index 77705826..1b0ba8b0 100644 --- a/ext/log_db/theme.php +++ b/ext/log_db/theme.php @@ -103,4 +103,4 @@ class LogDatabaseTheme extends Themelet { return "<a href='".make_link("post/view/$iid")."'>Image #$iid</a>"; } } -?> + diff --git a/ext/log_net/main.php b/ext/log_net/main.php index f82d01d3..8a0fdd8a 100644 --- a/ext/log_net/main.php +++ b/ext/log_net/main.php @@ -46,4 +46,4 @@ class LogNet extends Extension { } } } -?> + diff --git a/ext/mail/main.php b/ext/mail/main.php index 7d0ac454..d4b8007f 100644 --- a/ext/mail/main.php +++ b/ext/mail/main.php @@ -42,4 +42,4 @@ class MailTest extends Extension { } } } -?> + diff --git a/ext/mass_tagger/main.php b/ext/mass_tagger/main.php index 2216699b..aa9e650e 100644 --- a/ext/mass_tagger/main.php +++ b/ext/mass_tagger/main.php @@ -57,4 +57,4 @@ class MassTagger extends Extension { $page->set_redirect($_SERVER['HTTP_REFERER']); } } -?> + diff --git a/ext/mass_tagger/theme.php b/ext/mass_tagger/theme.php index 5a844bac..56a2273a 100644 --- a/ext/mass_tagger/theme.php +++ b/ext/mass_tagger/theme.php @@ -24,4 +24,4 @@ class MassTaggerTheme extends Themelet { $page->add_block( $block ); } } -?> + diff --git a/ext/not_a_tag/main.php b/ext/not_a_tag/main.php index 5dcb41fc..777d6dbe 100644 --- a/ext/not_a_tag/main.php +++ b/ext/not_a_tag/main.php @@ -119,4 +119,4 @@ class NotATag extends Extension { else {return array();} } } -?> + diff --git a/ext/not_a_tag/theme.php b/ext/not_a_tag/theme.php index 543af6f5..d5b39cf0 100644 --- a/ext/not_a_tag/theme.php +++ b/ext/not_a_tag/theme.php @@ -55,4 +55,4 @@ class NotATagTheme extends Themelet { $this->display_paginator($page, "untag/list", null, $page_number, $page_count); } } -?> + diff --git a/ext/notes/main.php b/ext/notes/main.php index cfbb6259..b241343d 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -609,4 +609,4 @@ class Notes extends Extension { } } -?> + diff --git a/ext/notes/theme.php b/ext/notes/theme.php index 99359b92..6f3fb9c9 100644 --- a/ext/notes/theme.php +++ b/ext/notes/theme.php @@ -236,4 +236,4 @@ class NotesTheme extends Themelet { $this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages); } } -?> + diff --git a/ext/numeric_score/test.php b/ext/numeric_score/test.php index 69f1d64f..ed230272 100644 --- a/ext/numeric_score/test.php +++ b/ext/numeric_score/test.php @@ -54,4 +54,4 @@ class NumericScoreTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/oekaki/main.php b/ext/oekaki/main.php index 6c114537..b9081fe1 100644 --- a/ext/oekaki/main.php +++ b/ext/oekaki/main.php @@ -87,4 +87,4 @@ class Oekaki extends Extension { } } } -?> + diff --git a/ext/oekaki/test.php b/ext/oekaki/test.php index f4257590..07ca4ec3 100644 --- a/ext/oekaki/test.php +++ b/ext/oekaki/test.php @@ -6,4 +6,4 @@ class OekakiTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/oekaki/theme.php b/ext/oekaki/theme.php index 468c0bdb..8a0ee9b9 100644 --- a/ext/oekaki/theme.php +++ b/ext/oekaki/theme.php @@ -61,4 +61,4 @@ class OekakiTheme extends Themelet { , "left", 21)); // upload is 20 } } -?> + diff --git a/ext/pm/main.php b/ext/pm/main.php index 9cd781e7..2deaf4e4 100644 --- a/ext/pm/main.php +++ b/ext/pm/main.php @@ -210,4 +210,4 @@ class PrivMsg extends Extension { return $count; } } -?> + diff --git a/ext/pm/test.php b/ext/pm/test.php index 0717433a..f08a0274 100644 --- a/ext/pm/test.php +++ b/ext/pm/test.php @@ -50,4 +50,4 @@ class PrivMsgTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/pm/theme.php b/ext/pm/theme.php index 7b0f5be1..79001617 100644 --- a/ext/pm/theme.php +++ b/ext/pm/theme.php @@ -70,4 +70,4 @@ EOD; $page->add_block(new Block("Message from {$from->name}", format_text($pm->message), "main", 10)); } } -?> + diff --git a/ext/pm_triggers/main.php b/ext/pm_triggers/main.php index a09454a1..7cb80013 100644 --- a/ext/pm_triggers/main.php +++ b/ext/pm_triggers/main.php @@ -26,4 +26,4 @@ class PMTrigger extends Extension { ))); } } -?> + diff --git a/ext/pools/test.php b/ext/pools/test.php index ea8015c3..8a59dce9 100644 --- a/ext/pools/test.php +++ b/ext/pools/test.php @@ -38,4 +38,4 @@ class PoolsTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/pools/theme.php b/ext/pools/theme.php index fd25d431..c8cc4e02 100644 --- a/ext/pools/theme.php +++ b/ext/pools/theme.php @@ -423,4 +423,4 @@ class PoolsTheme extends Themelet { $this->display_paginator($page, "pool/updated", null, $pageNumber, $totalPages); } } -?> + diff --git a/ext/qr_code/main.php b/ext/qr_code/main.php index ed671fd3..4fe864d8 100644 --- a/ext/qr_code/main.php +++ b/ext/qr_code/main.php @@ -12,4 +12,4 @@ class QRImage extends Extension { $this->theme->links_block(make_http(make_link('image/'.$event->image->id.'.jpg'))); } } -?> + diff --git a/ext/qr_code/theme.php b/ext/qr_code/theme.php index 8f6103de..3e82351d 100644 --- a/ext/qr_code/theme.php +++ b/ext/qr_code/theme.php @@ -6,4 +6,4 @@ class QRImageTheme extends Themelet { "QR Code","<img alt='QR Code' src='http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=$link' />","left",50)); } } -?> + diff --git a/ext/random_image/main.php b/ext/random_image/main.php index 0d799855..1d2d194a 100644 --- a/ext/random_image/main.php +++ b/ext/random_image/main.php @@ -76,4 +76,4 @@ class RandomImage extends Extension { } } } -?> + diff --git a/ext/random_image/test.php b/ext/random_image/test.php index 4d30c0e1..f11c83ef 100644 --- a/ext/random_image/test.php +++ b/ext/random_image/test.php @@ -55,4 +55,4 @@ class RandomTest extends ShimmieWebTestCase { $this->assert_no_text("Random Image"); } } -?> + diff --git a/ext/random_image/theme.php b/ext/random_image/theme.php index 87806bec..1210959e 100644 --- a/ext/random_image/theme.php +++ b/ext/random_image/theme.php @@ -24,4 +24,4 @@ class RandomImageTheme extends Themelet { "; } } -?> + diff --git a/ext/random_list/main.php b/ext/random_list/main.php index c9671309..609766fb 100644 --- a/ext/random_list/main.php +++ b/ext/random_list/main.php @@ -51,4 +51,4 @@ class RandomList extends Extension { $event->panel->add_block($sb); } } -?> + diff --git a/ext/rating/main.php b/ext/rating/main.php index eda01145..c9f3c8aa 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -235,4 +235,4 @@ class Ratings extends Extension { } } } -?> + diff --git a/ext/rating/test.php b/ext/rating/test.php index ac092c2f..81d02dfc 100644 --- a/ext/rating/test.php +++ b/ext/rating/test.php @@ -52,4 +52,4 @@ class RatingTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/rating/theme.php b/ext/rating/theme.php index 3e9437a6..4fde8274 100644 --- a/ext/rating/theme.php +++ b/ext/rating/theme.php @@ -45,4 +45,4 @@ class RatingsTheme extends Themelet { } } -?> + diff --git a/ext/regen_thumb/main.php b/ext/regen_thumb/main.php index b417e539..4c12f0c4 100644 --- a/ext/regen_thumb/main.php +++ b/ext/regen_thumb/main.php @@ -31,4 +31,4 @@ class RegenThumb extends Extension { } } } -?> + diff --git a/ext/regen_thumb/test.php b/ext/regen_thumb/test.php index cb2139f6..e2b5dc63 100644 --- a/ext/regen_thumb/test.php +++ b/ext/regen_thumb/test.php @@ -12,4 +12,4 @@ class RegenThumbTest extends ShimmieWebTestCase { # FIXME: test that the thumb's modified time has been updated } } -?> + diff --git a/ext/regen_thumb/theme.php b/ext/regen_thumb/theme.php index 6f5720a7..68d7904c 100644 --- a/ext/regen_thumb/theme.php +++ b/ext/regen_thumb/theme.php @@ -24,4 +24,4 @@ class RegenThumbTheme extends Themelet { $page->add_block(new Block("Thumbnail", $this->build_thumb_html($image))); } } -?> + diff --git a/ext/relatationships/main.php b/ext/relatationships/main.php index b1be3c36..846687a1 100644 --- a/ext/relatationships/main.php +++ b/ext/relatationships/main.php @@ -120,4 +120,4 @@ class Relationships extends Extension { } } } -?> + diff --git a/ext/relatationships/theme.php b/ext/relatationships/theme.php index b40c6289..a73e2293 100644 --- a/ext/relatationships/theme.php +++ b/ext/relatationships/theme.php @@ -42,4 +42,4 @@ class RelationshipsTheme extends Themelet { return $html; } } -?> + diff --git a/ext/report_image/main.php b/ext/report_image/main.php index a21a0581..b99f7030 100644 --- a/ext/report_image/main.php +++ b/ext/report_image/main.php @@ -181,4 +181,4 @@ class ReportImage extends Extension { // * Version 0.2b - 10/27/07 - Now supports Shimmie2 RC2! // * Version 0.2a - 10/24/07 - Fixed some SQL issues. I will make sure to test before commiting :) // * Version 0.2 - 10/24/07 - First public release. -?> + diff --git a/ext/report_image/test.php b/ext/report_image/test.php index cb1339db..65b89aef 100644 --- a/ext/report_image/test.php +++ b/ext/report_image/test.php @@ -37,4 +37,4 @@ class ReportImageTest extends ShimmieWebTestCase { # FIXME: test that >>123 works } } -?> + diff --git a/ext/report_image/theme.php b/ext/report_image/theme.php index b62fd02a..35aca30f 100644 --- a/ext/report_image/theme.php +++ b/ext/report_image/theme.php @@ -78,4 +78,4 @@ class ReportImageTheme extends Themelet { $page->add_block(new Block("Report Image", $html, "left")); } } -?> + diff --git a/ext/res_limit/main.php b/ext/res_limit/main.php index c17ad203..34b0f90d 100644 --- a/ext/res_limit/main.php +++ b/ext/res_limit/main.php @@ -70,4 +70,4 @@ class ResolutionLimit extends Extension { $event->panel->add_block($sb); } } -?> + diff --git a/ext/res_limit/test.php b/ext/res_limit/test.php index 2707923a..9d66d3ce 100644 --- a/ext/res_limit/test.php +++ b/ext/res_limit/test.php @@ -110,4 +110,4 @@ class ResLimitTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/rotate/main.php b/ext/rotate/main.php index cde59505..5e1c8af8 100644 --- a/ext/rotate/main.php +++ b/ext/rotate/main.php @@ -231,4 +231,4 @@ class RotateImage extends Extension { log_info("rotate", "Rotated Image #{$image_id} - New hash: {$new_hash}"); } } -?> + diff --git a/ext/rotate/theme.php b/ext/rotate/theme.php index ddef58c7..c6481469 100644 --- a/ext/rotate/theme.php +++ b/ext/rotate/theme.php @@ -25,4 +25,4 @@ class RotateImageTheme extends Themelet { $page->add_block(new Block($title, $message)); } } -?> + diff --git a/ext/rss_comments/main.php b/ext/rss_comments/main.php index a141cc39..7ae90be5 100644 --- a/ext/rss_comments/main.php +++ b/ext/rss_comments/main.php @@ -75,4 +75,4 @@ EOD; } } } -?> + diff --git a/ext/rss_comments/test.php b/ext/rss_comments/test.php index e6062c29..1036c177 100644 --- a/ext/rss_comments/test.php +++ b/ext/rss_comments/test.php @@ -19,4 +19,4 @@ class RSSCommentsTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/rss_images/main.php b/ext/rss_images/main.php index f9d4b330..cef02075 100644 --- a/ext/rss_images/main.php +++ b/ext/rss_images/main.php @@ -112,4 +112,4 @@ class RSS_Images extends Extension { return $data; } } -?> + diff --git a/ext/rss_images/test.php b/ext/rss_images/test.php index 9447ecc6..4322b308 100644 --- a/ext/rss_images/test.php +++ b/ext/rss_images/test.php @@ -33,4 +33,4 @@ class RSSImagesTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/rss_images/theme.php b/ext/rss_images/theme.php index d1f2734f..ef4ac101 100644 --- a/ext/rss_images/theme.php +++ b/ext/rss_images/theme.php @@ -1,4 +1,4 @@ <?php /* needed for access to build_thumb_html */ class RSS_ImagesTheme extends Themelet {} -?> + diff --git a/ext/setup/main.php b/ext/setup/main.php index d6c0cd45..f34e0d4d 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -306,4 +306,4 @@ class Setup extends Extension { } } } -?> + diff --git a/ext/setup/test.php b/ext/setup/test.php index c990f2ee..6114b030 100644 --- a/ext/setup/test.php +++ b/ext/setup/test.php @@ -28,4 +28,4 @@ class SetupTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/setup/theme.php b/ext/setup/theme.php index 3bad7007..99fa314a 100644 --- a/ext/setup/theme.php +++ b/ext/setup/theme.php @@ -96,4 +96,4 @@ class SetupTheme extends Themelet { return $html; } } -?> + diff --git a/ext/shimmie_api/test.php b/ext/shimmie_api/test.php index 961afa0a..c8dfa91c 100644 --- a/ext/shimmie_api/test.php +++ b/ext/shimmie_api/test.php @@ -26,4 +26,4 @@ class ShimmieApiTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/simpletest/main.php b/ext/simpletest/main.php index b3972cb5..2ff0abf0 100644 --- a/ext/simpletest/main.php +++ b/ext/simpletest/main.php @@ -258,4 +258,4 @@ class SimpleSCoreTest extends Extension { } } } -?> + diff --git a/ext/simpletest/theme.php b/ext/simpletest/theme.php index 4ed982d9..44d22a8c 100644 --- a/ext/simpletest/theme.php +++ b/ext/simpletest/theme.php @@ -84,4 +84,4 @@ class SCoreWebReporter extends HtmlReporter { /** @private */ class SCoreCLIReporter extends TextReporter { } -?> + diff --git a/ext/site_description/main.php b/ext/site_description/main.php index 9adaa5d3..80563617 100644 --- a/ext/site_description/main.php +++ b/ext/site_description/main.php @@ -30,4 +30,4 @@ class SiteDescription extends Extension { $event->panel->add_block($sb); } } -?> + diff --git a/ext/site_description/test.php b/ext/site_description/test.php index ee27e2fc..293c6a1a 100644 --- a/ext/site_description/test.php +++ b/ext/site_description/test.php @@ -15,4 +15,4 @@ class SiteDescriptionTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/sitemap/main.php b/ext/sitemap/main.php index 056d07fe..7172dc21 100644 --- a/ext/sitemap/main.php +++ b/ext/sitemap/main.php @@ -164,4 +164,4 @@ class XMLSitemap extends Extension { $page->set_data($xml); } } -?> + diff --git a/ext/sitemap/test.php b/ext/sitemap/test.php index 0d420888..fa459d9b 100644 --- a/ext/sitemap/test.php +++ b/ext/sitemap/test.php @@ -6,4 +6,4 @@ class XMLSitemapTest extends ShimmieWebTestCase { $this->get_page('sitemap.xml'); } } -?> + diff --git a/ext/source_history/main.php b/ext/source_history/main.php index ff74c853..a9eab563 100644 --- a/ext/source_history/main.php +++ b/ext/source_history/main.php @@ -387,4 +387,4 @@ class Source_History extends Extension { } } } -?> + diff --git a/ext/source_history/theme.php b/ext/source_history/theme.php index 29bcc019..4399c300 100644 --- a/ext/source_history/theme.php +++ b/ext/source_history/theme.php @@ -134,4 +134,4 @@ class Source_HistoryTheme extends Themelet { $this->messages[] = '<p><b>'. $title .'</b><br>'. $body .'</p>'; } } -?> + diff --git a/ext/tag_categories/main.php b/ext/tag_categories/main.php index 80f62e88..4e0fbdda 100644 --- a/ext/tag_categories/main.php +++ b/ext/tag_categories/main.php @@ -146,4 +146,4 @@ class TagCategories extends Extension { } } -?> + diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index eb58efe3..8161af83 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -320,4 +320,4 @@ class TagEdit extends Extension { } } } -?> + diff --git a/ext/tag_edit/test.php b/ext/tag_edit/test.php index a88bfc37..89541830 100644 --- a/ext/tag_edit/test.php +++ b/ext/tag_edit/test.php @@ -68,4 +68,4 @@ class TagEditTest extends ShimmieWebTestCase { } */ } -?> + diff --git a/ext/tag_edit/theme.php b/ext/tag_edit/theme.php index 4cd67bae..4e1650cc 100644 --- a/ext/tag_edit/theme.php +++ b/ext/tag_edit/theme.php @@ -134,4 +134,4 @@ class TagEditTheme extends Themelet { "; } } -?> + diff --git a/ext/tag_editcloud/main.php b/ext/tag_editcloud/main.php index d74e061e..d1cd2bd2 100644 --- a/ext/tag_editcloud/main.php +++ b/ext/tag_editcloud/main.php @@ -156,4 +156,4 @@ class TagEditCloud extends Extension { return ($user->can("edit_image_tag") && (!$image->is_locked() || $user->can("edit_image_lock"))); } } -?> + diff --git a/ext/tag_history/test.php b/ext/tag_history/test.php index 5ca06e44..ae8f2bdf 100644 --- a/ext/tag_history/test.php +++ b/ext/tag_history/test.php @@ -20,4 +20,4 @@ class TagHistoryTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/tag_history/theme.php b/ext/tag_history/theme.php index 62efac5a..1f516d64 100644 --- a/ext/tag_history/theme.php +++ b/ext/tag_history/theme.php @@ -146,4 +146,4 @@ class Tag_HistoryTheme extends Themelet { $this->messages[] = '<p><b>'. $title .'</b><br>'. $body .'</p>'; } } -?> + diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 3677c98a..53f748ea 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -492,4 +492,4 @@ class TagList extends Extension { } // }}} } -?> + diff --git a/ext/tag_list/test.php b/ext/tag_list/test.php index fc574eab..6b50fc87 100644 --- a/ext/tag_list/test.php +++ b/ext/tag_list/test.php @@ -34,4 +34,4 @@ class TagListTest extends ShimmieWebTestCase { } } } -?> + diff --git a/ext/tag_list/theme.php b/ext/tag_list/theme.php index 87866476..525330e2 100644 --- a/ext/tag_list/theme.php +++ b/ext/tag_list/theme.php @@ -272,4 +272,4 @@ class TagListTheme extends Themelet { return make_link("post/list/$u_tag/1"); } } -?> + diff --git a/ext/tagger/main.php b/ext/tagger/main.php index 4df81ee8..553a8fc6 100644 --- a/ext/tagger/main.php +++ b/ext/tagger/main.php @@ -139,4 +139,4 @@ class TaggerXML extends Extension { "SELECT COUNT(*) FROM `tags` $query",$values)->fields['COUNT(*)']; } } -?> + diff --git a/ext/tagger/theme.php b/ext/tagger/theme.php index 398fea7d..27ac184a 100644 --- a/ext/tagger/theme.php +++ b/ext/tagger/theme.php @@ -66,4 +66,4 @@ EOD; return $html; } } -?> + diff --git a/ext/tips/test.php b/ext/tips/test.php index 7e3998a6..6b5e6c1a 100644 --- a/ext/tips/test.php +++ b/ext/tips/test.php @@ -68,4 +68,4 @@ class TipsTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/tips/theme.php b/ext/tips/theme.php index 2f4b84ba..2aa3ef51 100644 --- a/ext/tips/theme.php +++ b/ext/tips/theme.php @@ -92,4 +92,4 @@ class TipsTheme extends Themelet { $page->add_block(new Block("All Tips", $html, "main", 20)); } } -?> + diff --git a/ext/twitter_soc/main.php b/ext/twitter_soc/main.php index c81a2d6a..0242c7d4 100644 --- a/ext/twitter_soc/main.php +++ b/ext/twitter_soc/main.php @@ -21,4 +21,4 @@ class TwitterSoc extends Extension { $event->panel->add_block($sb); } } -?> + diff --git a/ext/twitter_soc/test.php b/ext/twitter_soc/test.php index 438e530b..cbc700de 100644 --- a/ext/twitter_soc/test.php +++ b/ext/twitter_soc/test.php @@ -26,4 +26,4 @@ class TwitterSocTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/twitter_soc/theme.php b/ext/twitter_soc/theme.php index efbf7959..c8685f4b 100644 --- a/ext/twitter_soc/theme.php +++ b/ext/twitter_soc/theme.php @@ -22,4 +22,4 @@ $(function() { ', "left", 25)); } } -?> + diff --git a/ext/update/main.php b/ext/update/main.php index 6cd29b26..8804e787 100644 --- a/ext/update/main.php +++ b/ext/update/main.php @@ -109,4 +109,4 @@ class Update extends Extension { } } -?> + diff --git a/ext/update/theme.php b/ext/update/theme.php index 4823e0c6..e3dffb6a 100644 --- a/ext/update/theme.php +++ b/ext/update/theme.php @@ -11,4 +11,4 @@ class UpdateTheme extends Themelet { $page->add_block(new Block("Software Update", $html, "main", 75)); } } -?> + diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index d7967754..477452cb 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -95,4 +95,4 @@ class Upgrade extends Extension { public function get_priority() {return 5;} } -?> + diff --git a/ext/user/test.php b/ext/user/test.php index 8655cd5e..cd55086b 100644 --- a/ext/user/test.php +++ b/ext/user/test.php @@ -37,4 +37,4 @@ class UserPageTest extends SCoreWebTestCase { $this->assert_text("demo"); } } -?> + diff --git a/ext/view/test.php b/ext/view/test.php index 9338f841..2398e356 100644 --- a/ext/view/test.php +++ b/ext/view/test.php @@ -42,4 +42,4 @@ class ViewTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/view/theme.php b/ext/view/theme.php index c043ff83..a2775c8b 100644 --- a/ext/view/theme.php +++ b/ext/view/theme.php @@ -90,4 +90,4 @@ class ViewImageTheme extends Themelet { return $html; } } -?> + diff --git a/ext/wiki/test.php b/ext/wiki/test.php index 7694a496..3cbbd44c 100644 --- a/ext/wiki/test.php +++ b/ext/wiki/test.php @@ -111,4 +111,4 @@ class WikiTest extends SCoreWebTestCase { $this->log_out(); } } -?> + diff --git a/ext/wiki/theme.php b/ext/wiki/theme.php index 54e7338d..99b94a41 100644 --- a/ext/wiki/theme.php +++ b/ext/wiki/theme.php @@ -106,4 +106,4 @@ class WikiTheme extends Themelet { "; } } -?> + diff --git a/ext/word_filter/main.php b/ext/word_filter/main.php index f85cc3de..0ce8d5ea 100644 --- a/ext/word_filter/main.php +++ b/ext/word_filter/main.php @@ -48,4 +48,4 @@ class WordFilter extends Extension { return $map; } } -?> + diff --git a/ext/word_filter/test.php b/ext/word_filter/test.php index 5fbe0f19..6b3df0b2 100644 --- a/ext/word_filter/test.php +++ b/ext/word_filter/test.php @@ -53,4 +53,4 @@ class WordFilterTest extends ShimmieWebTestCase { $this->log_out(); } } -?> + From 24371d8c3443440085cc6f2772a8434745dacedf Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 23:19:18 -0400 Subject: [PATCH 60/66] Fix the PHP Doc comments. --- core/util.inc.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index 5700463c..60a95b6f 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -312,8 +312,8 @@ function endsWith(/*string*/ $haystack, /*string*/ $needle) { * * eg make_link("post/list") becomes "/v2/index.php?q=post/list" * - * @param null $page - * @param null $query + * @param null|string $page + * @param null|string $query * @return string */ function make_link($page=null, $query=null) { @@ -348,7 +348,7 @@ function make_link($page=null, $query=null) { /** - * Take the current URL and modify some paramaters + * Take the current URL and modify some parameters * * @param $changes * @return string @@ -392,7 +392,7 @@ function modify_url($url, $changes) { /** * Turn a relative link into an absolute one, including hostname * - * @param $link + * @param string $link * @return string */ function make_http(/*string*/ $link) { @@ -433,6 +433,11 @@ function mtimefile($file) { return "$data_href/$file?$mtime"; } +/** + * Return the current theme as a string + * + * @return string + */ function get_theme() { global $config; $theme = $config->get_string("theme", "default"); From e6b1d514d1162ee34622276af3ce5faf8f1a95a8 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Fri, 25 Apr 2014 23:22:34 -0400 Subject: [PATCH 61/66] Some more type hinting via the comments. --- core/imageboard.pack.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 3992f79b..3c0d61c9 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -68,7 +68,7 @@ class Image { /** * Find an image by ID * - * @param $id + * @param int $id * @return Image */ public static function by_id(/*int*/ $id) { @@ -81,7 +81,7 @@ class Image { /** * Find an image by hash * - * @param $hash + * @param string $hash * @return Image */ public static function by_hash(/*string*/ $hash) { @@ -110,8 +110,8 @@ class Image { /** * Search for an array of images * - * @param $start - * @param $limit + * @param int $start + * @param int $limit * @param array $tags * @throws SCoreException * @return Array @@ -423,6 +423,8 @@ class Image { /** * Set the image's source URL + * + * @param string $new_source */ public function set_source(/*string*/ $new_source) { global $database; @@ -978,6 +980,9 @@ class Image { class Tag { /** * Remove any excess fluff from a user-input tag + * + * @param string $tag + * @return mixed */ public static function sanitise($tag) { assert(is_string($tag)); From 298344048cfe852640ac67f266770126511ef5b4 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Sat, 26 Apr 2014 00:27:16 -0400 Subject: [PATCH 62/66] Make these functions public to prevent scrutinizer from complaining. --- ext/comment/main.php | 2 +- ext/ouroboros_api/main.php | 17 +++++++++++------ themes/futaba/comment.theme.php | 4 ++-- themes/futaba/themelet.class.php | 16 ++++++++-------- themes/lite/themelet.class.php | 6 +++--- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/ext/comment/main.php b/ext/comment/main.php index 5e3c870d..f64247e2 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -332,7 +332,7 @@ class CommentList extends Extension { $image = null; // this is "clever", I may live to regret it } } - if(!is_null($image)) $images[] = array($image, $comments); + if(!is_null($image)) $images[] = array($image, $comments); } } diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php index fa9ef5da..c223690c 100644 --- a/ext/ouroboros_api/main.php +++ b/ext/ouroboros_api/main.php @@ -573,12 +573,17 @@ class OuroborosAPI extends Extension protected function postShow($id = null) { if (!is_null($id)) { - $post = new _SafeOuroborosImage(Image::by_id($id)); - $this->sendData('post', $post); - } else { - $this->sendResponse(424, 'ID is mandatory'); - } - } + $image = Image::by_id($id); + if ( ! $image instanceof Image) { + $this->sendResponse(404, 'ID not found'); + } else { + $post = new _SafeOuroborosImage($image); + $this->sendData('post', $post); + } + } else { + $this->sendResponse(424, 'ID is mandatory'); + } + } /** * Wrapper for getting a list of posts diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index 35e74d7d..2b4c3518 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -1,7 +1,7 @@ <?php class CustomCommentListTheme extends CommentListTheme { - var $inner_id = 0; + public $inner_id = 0; public function display_comment_list($images, $page_number, $total_pages, $can_post) { global $config, $page; @@ -51,7 +51,7 @@ class CustomCommentListTheme extends CommentListTheme { // sidebar fails in this theme } - private function build_upload_box() { + public function build_upload_box() { return "[[ insert upload-and-comment extension here ]]"; } diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index 393afc60..e79ff53c 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -9,12 +9,12 @@ class Themelet extends BaseThemelet { $page->add_block(new Block(null, $body, "main", $position)); } - private function futaba_gen_page_link($base_url, $query, $page, $name) { + public function futaba_gen_page_link($base_url, $query, $page, $name) { $link = make_link("$base_url/$page", $query); return "[<a href='$link'>{$name}</a>]"; } - private function futaba_gen_page_link_block($base_url, $query, $page, $current_page, $name) { + public function futaba_gen_page_link_block($base_url, $query, $page, $current_page, $name) { $paginator = ""; if($page == $current_page) $paginator .= "<b>"; $paginator .= $this->futaba_gen_page_link($base_url, $query, $page, $name); @@ -22,7 +22,7 @@ class Themelet extends BaseThemelet { return $paginator; } - private function futaba_build_paginator($current_page, $total_pages, $base_url, $query) { + public function futaba_build_paginator($current_page, $total_pages, $base_url, $query) { $next = $current_page + 1; $prev = $current_page - 1; //$rand = mt_rand(1, $total_pages); @@ -30,11 +30,11 @@ class Themelet extends BaseThemelet { $at_start = ($current_page <= 1 || $total_pages <= 1); $at_end = ($current_page >= $total_pages); - //$first_html = $at_start ? "First" : $this->litetheme_gen_page_link($base_url, $query, 1, "First"); - $prev_html = $at_start ? "Prev" : $this->futaba_gen_page_link($base_url, $query, $prev, "Prev"); - //$random_html = $this->litetheme_gen_page_link($base_url, $query, $rand, "Random"); - $next_html = $at_end ? "Next" : $this->futaba_gen_page_link($base_url, $query, $next, "Next"); - //$last_html = $at_end ? "Last" : $this->litetheme_gen_page_link($base_url, $query, $total_pages, "Last"); + //$first_html = $at_start ? "First" : $this->futaba_gen_page_link($base_url, $query, 1, "First"); + $prev_html = $at_start ? "Prev" : $this->futaba_gen_page_link($base_url, $query, $prev, "Prev"); + //$random_html = $this->futaba_gen_page_link($base_url, $query, $rand, "Random"); + $next_html = $at_end ? "Next" : $this->futaba_gen_page_link($base_url, $query, $next, "Next"); + //$last_html = $at_end ? "Last" : $this->futaba_gen_page_link($base_url, $query, $total_pages, "Last"); $start = $current_page-5 > 1 ? $current_page-5 : 1; $end = $start+10 < $total_pages ? $start+10 : $total_pages; diff --git a/themes/lite/themelet.class.php b/themes/lite/themelet.class.php index 631ef171..2c10869f 100644 --- a/themes/lite/themelet.class.php +++ b/themes/lite/themelet.class.php @@ -20,12 +20,12 @@ class Themelet extends BaseThemelet { $page->add_block(new Block(null, $body, "main", 90)); } - private function litetheme_gen_page_link($base_url, $query, $page, $name, $link_class=null) { + public function litetheme_gen_page_link($base_url, $query, $page, $name, $link_class=null) { $link = make_link("$base_url/$page", $query); return "<a class='$link_class' href='$link'>$name</a>"; } - private function litetheme_gen_page_link_block($base_url, $query, $page, $current_page, $name) { + public function litetheme_gen_page_link_block($base_url, $query, $page, $current_page, $name) { $paginator = ""; if($page == $current_page) {$link_class = "tab-selected";} else {$link_class = "";} @@ -34,7 +34,7 @@ class Themelet extends BaseThemelet { return $paginator; } - private function litetheme_build_paginator($current_page, $total_pages, $base_url, $query) { + public function litetheme_build_paginator($current_page, $total_pages, $base_url, $query) { $next = $current_page + 1; $prev = $current_page - 1; $rand = mt_rand(1, $total_pages); From efb5038b20e735dcbdc4e76f398f1849859aae6b Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Sat, 26 Apr 2014 03:15:44 -0400 Subject: [PATCH 63/66] This file no longer exists. --- .scrutinizer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index f1eef101..f3c4b2f2 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -3,4 +3,4 @@ imports: - php filter: - excluded_paths: [lib/*,ext/chatbox/js/jquery.js] + excluded_paths: [lib/*] From a8dd045586462b8e879913a3d42ba6c14e0e1b6f Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Sat, 26 Apr 2014 03:56:06 -0400 Subject: [PATCH 64/66] Combine these if statements into one to reduce the cyclomatic complexity. --- ext/notes/main.php | 36 +++++++++++++----------------------- ext/notes/theme.php | 2 +- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/ext/notes/main.php b/ext/notes/main.php index b241343d..3a259c1c 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -323,26 +323,16 @@ class Notes extends Extension { $noteText = mysql_real_escape_string(html_escape($_POST["note_text"])); // validate parameters - if(is_null($imageID) || !is_numeric($imageID)) - return; - - if(is_null($noteID) || !is_numeric($noteID)) - return; - - if(is_null($noteX1) || !is_numeric($noteX1)) - return; - - if(is_null($noteY1) || !is_numeric($noteY1)) - return; - - if(is_null($noteHeight) || !is_numeric($noteHeight)) - return; - - if(is_null($noteWidth) || !is_numeric($noteWidth)) - return; - - if(is_null($noteText) || strlen($noteText) == 0) + if (is_null($imageID) || !is_numeric($imageID) || + is_null($noteID) || !is_numeric($noteID) || + is_null($noteX1) || !is_numeric($noteX1) || + is_null($noteY1) || !is_numeric($noteY1) || + is_null($noteHeight) || !is_numeric($noteHeight) || + is_null($noteWidth) || !is_numeric($noteWidth) || + is_null($noteText) || strlen($noteText) == 0) + { return; + } global $database; $database->execute("UPDATE notes ". @@ -369,11 +359,11 @@ class Notes extends Extension { $noteID = int_escape($_POST["note_id"]); // validate parameters - if(is_null($imageID) || !is_numeric($imageID)) - return; - - if(is_null($noteID) || !is_numeric($noteID)) + if( is_null($imageID) || !is_numeric($imageID) || + is_null($noteID) || !is_numeric($noteID)) + { return; + } global $database; diff --git a/ext/notes/theme.php b/ext/notes/theme.php index 6f3fb9c9..38e7a968 100644 --- a/ext/notes/theme.php +++ b/ext/notes/theme.php @@ -235,5 +235,5 @@ class NotesTheme extends Themelet { $this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages); } -} +} From 4e9e5ca2bef72b7a40c147f2c57bebed76092785 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Sat, 26 Apr 2014 05:01:49 -0400 Subject: [PATCH 65/66] Fixing/adding/cleaning up the PHP Doc comments. --- core/basethemelet.class.php | 51 +++++++++++++++++++++++++++--- core/block.class.php | 25 ++++++++++++--- core/event.class.php | 21 +++++++++++-- core/imageboard.pack.php | 30 +++++++++++++++--- core/user.class.php | 53 +++++++++++++++++++++++++++++--- core/userclass.class.php | 7 +++++ themes/futaba/themelet.class.php | 40 ++++++++++++++++++++++-- 7 files changed, 204 insertions(+), 23 deletions(-) diff --git a/core/basethemelet.class.php b/core/basethemelet.class.php index 49be4a41..3d62d3da 100644 --- a/core/basethemelet.class.php +++ b/core/basethemelet.class.php @@ -1,10 +1,18 @@ <?php + /** + * Class BaseThemelet + * * A collection of common functions for theme parts */ class BaseThemelet { + /** * Generic error message display + * + * @param int $code + * @param string $title + * @param string $message */ public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) { global $page; @@ -24,7 +32,6 @@ class BaseThemelet { $page->add_block(new Block("Error", $message)); } - /** * A specific, common error message */ @@ -36,6 +43,9 @@ class BaseThemelet { /** * Generic thumbnail code; returns HTML rather than adding * a block since thumbs tend to go inside blocks... + * + * @param Image $image + * @return string */ public function build_thumb_html(Image $image) { global $config; @@ -65,9 +75,14 @@ class BaseThemelet { "</a>\n"; } - /** - * Add a generic paginator + * Add a generic paginator. + * + * @param Page $page + * @param string $base + * @param string $query + * @param int $page_number + * @param int $total_pages */ public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) { if($total_pages == 0) $total_pages = 1; @@ -75,11 +90,28 @@ class BaseThemelet { $page->add_block(new Block(null, $body, "main", 90, "paginator")); } + /** + * Generate a single HTML link. + * + * @param string $base_url + * @param string $query + * @param int|string $page + * @param string $name + * @return string + */ private function gen_page_link($base_url, $query, $page, $name) { $link = make_link($base_url.'/'.$page, $query); return '<a href="'.$link.'">'.$name.'</a>'; } - + + /** + * @param string $base_url + * @param string $query + * @param int|string $page + * @param int|string $current_page + * @param string $name + * @return string + */ private function gen_page_link_block($base_url, $query, $page, $current_page, $name) { $paginator = ""; if($page == $current_page) $paginator .= "<b>"; @@ -87,7 +119,16 @@ class BaseThemelet { if($page == $current_page) $paginator .= "</b>"; return $paginator; } - + + /** + * Build the paginator. + * + * @param int $current_page + * @param int $total_pages + * @param string $base_url + * @param string $query + * @return string + */ private function build_paginator($current_page, $total_pages, $base_url, $query) { $next = $current_page + 1; $prev = $current_page - 1; diff --git a/core/block.class.php b/core/block.class.php index 21b50dd1..bdbc215f 100644 --- a/core/block.class.php +++ b/core/block.class.php @@ -6,14 +6,14 @@ class Block { /** * The block's title * - * @retval string + * @var string */ public $header; /** * The content * - * @retval string + * @var string */ public $body; @@ -21,7 +21,7 @@ class Block { * Where the block should be placed. The default theme supports * "main" and "left", other themes can add their own areas * - * @retval string + * @var string */ public $section; @@ -30,15 +30,24 @@ class Block { * numbers appear lower. The scale is 0-100 by convention, * though any number or string will work. * - * @retval int + * @var int */ public $position; /** - * + * @var int */ public $id; + /** + * Construct a block. + * + * @param string $header + * @param string $body + * @param string $section + * @param int $position + * @param null|int $id + */ public function __construct($header, $body, /*string*/ $section="main", /*int*/ $position=50, $id=null) { $this->header = $header; $this->body = $body; @@ -47,6 +56,12 @@ class Block { $this->id = str_replace(' ', '_', is_null($id) ? (is_null($header) ? md5($body) : $header) . $section : $id); } + /** + * Get the HTML for this block. + * + * @param bool $hidable + * @return string + */ public function get_html($hidable=false) { $h = $this->header; $b = $this->body; diff --git a/core/event.class.php b/core/event.class.php index 766a2c0f..2b824e5b 100644 --- a/core/event.class.php +++ b/core/event.class.php @@ -30,6 +30,9 @@ class PageRequestEvent extends Event { public $arg_count; public $part_count; + /** + * @param string $path + */ public function __construct($path) { global $config; @@ -63,6 +66,7 @@ class PageRequestEvent extends Event { * * If it matches, store the remaining path elements in $args * + * @param string $name * @return bool */ public function page_matches(/*string*/ $name) { @@ -84,8 +88,9 @@ class PageRequestEvent extends Event { /** * Get the n th argument of the page request (if it exists.) - * @param $n integer - * @return The argmuent (string) or NULL + * + * @param int $n + * @return string|null The argmuent (string) or NULL */ public function get_arg(/*int*/ $n) { $offset = $this->part_count + $n; @@ -108,6 +113,10 @@ class PageRequestEvent extends Event { /* * Many things use these functions */ + + /** + * @return array + */ public function get_search_terms() { $search_terms = array(); if($this->count_args() === 2) { @@ -115,6 +124,10 @@ class PageRequestEvent extends Event { } return $search_terms; } + + /** + * @return int + */ public function get_page_number() { $page_number = 1; if($this->count_args() === 1) { @@ -126,6 +139,10 @@ class PageRequestEvent extends Event { if($page_number === 0) $page_number = 1; // invalid -> 0 return $page_number; } + + /** + * @return int + */ public function get_page_size() { global $config; return $config->get_int('index_images'); diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 3c0d61c9..8c8e27b0 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -152,6 +152,9 @@ class Image { /** * Count the number of image results for a given search + * + * @param array $tags + * @return mixed */ public static function count_images($tags=array()) { assert(is_array($tags)); @@ -181,6 +184,9 @@ class Image { /** * Count the number of pages for a given search + * + * @param array $tags + * @return float */ public static function count_pages($tags=array()) { assert(is_array($tags)); @@ -250,7 +256,9 @@ class Image { } /** - * Set the image's owner + * Set the image's owner. + * + * @param User $owner */ public function set_owner(User $owner) { global $database; @@ -272,7 +280,9 @@ class Image { } /** - * Get this image's tags as a string + * Get this image's tags as a string. + * + * @return string */ public function get_tag_list() { return Tag::implode($this->get_tag_array()); @@ -1022,6 +1032,10 @@ class Tag { return $tag_array; } + /** + * @param $tags + * @return string + */ public static function implode($tags) { assert(is_string($tags) || is_array($tags)); @@ -1036,6 +1050,10 @@ class Tag { return $tags; } + /** + * @param string $tag + * @return string + */ public static function resolve_alias($tag) { assert(is_string($tag)); @@ -1084,8 +1102,8 @@ class Tag { /** * This function takes a list (array) of tags and changes any tags that have aliases * - * @param $tags Array of tags - * @return Array of tags + * @param array $tags Array of tags + * @return array of tags */ public static function resolve_aliases($tags) { assert(is_array($tags)); @@ -1135,6 +1153,10 @@ function move_upload_to_archive(DataUploadEvent $event) { /** * Given a full size pair of dimensions, return a pair scaled down to fit * into the configured thumbnail square, with ratio intact + * + * @param int $orig_width + * @param int $orig_height + * @return array */ function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) { global $config; diff --git a/core/user.class.php b/core/user.class.php index 3117385e..94e22c63 100644 --- a/core/user.class.php +++ b/core/user.class.php @@ -8,16 +8,23 @@ function _new_user($row) { /** * An object representing a row in the "users" table. * - * The currently logged in user will always be accessable via the global variable $user + * The currently logged in user will always be accessible via the global variable $user */ class User { + /** @var int */ public $id; + + /** @var string */ public $name; + + /** @var string */ public $email; + public $join_date; + public $passhash; - /* @var UserClass */ + /** @var UserClass */ var $class; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -44,6 +51,13 @@ class User { $this->class = $_user_classes[$row["class"]]; } + /** + * Construct a User by session. + * + * @param string $name + * @param string $session + * @return null|User + */ public static function by_session(/*string*/ $name, /*string*/ $session) { global $config, $database; $row = $database->cache->get("user-session-$name-$session"); @@ -60,6 +74,11 @@ class User { return is_null($row) ? null : new User($row); } + /** + * Construct a User by session. + * @param int $id + * @return null|User + */ public static function by_id(/*int*/ $id) { assert(is_numeric($id)); global $database; @@ -72,6 +91,11 @@ class User { return is_null($row) ? null : new User($row); } + /** + * Construct a User by name. + * @param string $name + * @return null|User + */ public static function by_name(/*string*/ $name) { assert(is_string($name)); global $database; @@ -79,6 +103,12 @@ class User { return is_null($row) ? null : new User($row); } + /** + * Construct a User by name and hash. + * @param string $name + * @param string $hash + * @return null|User + */ public static function by_name_and_hash(/*string*/ $name, /*string*/ $hash) { assert(is_string($name)); assert(is_string($hash)); @@ -88,6 +118,11 @@ class User { return is_null($row) ? null : new User($row); } + /** + * @param int $offset + * @param int $limit + * @return array + */ public static function by_list(/*int*/ $offset, /*int*/ $limit=50) { assert(is_numeric($offset)); assert(is_numeric($limit)); @@ -97,8 +132,12 @@ class User { } - /* - * useful user object functions start here + /* useful user object functions start here */ + + + /** + * @param string $ability + * @return bool */ public function can($ability) { return $this->class->can($ability); @@ -134,6 +173,9 @@ class User { return ($this->class->name === "admin"); } + /** + * @param string $class + */ public function set_class(/*string*/ $class) { assert(is_string($class)); global $database; @@ -141,6 +183,9 @@ class User { log_info("core-user", 'Set class for '.$this->name.' to '.$class); } + /** + * @param string $password + */ public function set_password(/*string*/ $password) { global $database; $hash = md5(strtolower($this->name) . $password); diff --git a/core/userclass.class.php b/core/userclass.class.php index d960f954..ee6871ea 100644 --- a/core/userclass.class.php +++ b/core/userclass.class.php @@ -19,6 +19,13 @@ class UserClass { $_user_classes[$name] = $this; } + /** + * Determine if this class of user can perform an action or has ability. + * + * @param string $ability + * @return bool + * @throws SCoreException + */ public function can(/*string*/ $ability) { global $config; diff --git a/themes/futaba/themelet.class.php b/themes/futaba/themelet.class.php index e79ff53c..3f38fdfc 100644 --- a/themes/futaba/themelet.class.php +++ b/themes/futaba/themelet.class.php @@ -1,7 +1,15 @@ <?php class Themelet extends BaseThemelet { + /** - * Add a generic paginator + * Add a generic paginator. + * + * @param Page $page + * @param string $base + * @param string $query + * @param int $page_number + * @param int $total_pages + * @param int $position */ public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $position=90) { if($total_pages == 0) $total_pages = 1; @@ -9,11 +17,28 @@ class Themelet extends BaseThemelet { $page->add_block(new Block(null, $body, "main", $position)); } + /** + * Generate a single HTML link. + * + * @param string $base_url + * @param string $query + * @param int|string $page + * @param string $name + * @return string + */ public function futaba_gen_page_link($base_url, $query, $page, $name) { $link = make_link("$base_url/$page", $query); return "[<a href='$link'>{$name}</a>]"; } - + + /** + * @param string $base_url + * @param string $query + * @param int|string $page + * @param int|string $current_page + * @param string $name + * @return string + */ public function futaba_gen_page_link_block($base_url, $query, $page, $current_page, $name) { $paginator = ""; if($page == $current_page) $paginator .= "<b>"; @@ -21,7 +46,16 @@ class Themelet extends BaseThemelet { if($page == $current_page) $paginator .= "</b>"; return $paginator; } - + + /** + * Build the paginator. + * + * @param int $current_page + * @param int $total_pages + * @param string $base_url + * @param string $query + * @return string + */ public function futaba_build_paginator($current_page, $total_pages, $base_url, $query) { $next = $current_page + 1; $prev = $current_page - 1; From 95ba85ee43cd313637cc549bbb4f9deb7a841749 Mon Sep 17 00:00:00 2001 From: jgen <jeffgenovy@gmail.com> Date: Sat, 26 Apr 2014 05:32:15 -0400 Subject: [PATCH 66/66] This js file relies on functions defined in 'shimmie.js' which is all globed together when rendering a page. Adding an ignore line to scrutinizer to prevent false-positives. --- .scrutinizer.yml | 2 +- ext/tagger/script.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index f3c4b2f2..4ff51349 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -3,4 +3,4 @@ imports: - php filter: - excluded_paths: [lib/*] + excluded_paths: [lib/*,ext/tagger/script.js] diff --git a/ext/tagger/script.js b/ext/tagger/script.js index 9f0987d3..511a2684 100644 --- a/ext/tagger/script.js +++ b/ext/tagger/script.js @@ -1,11 +1,11 @@ -/*jshint dojo:true, forin:false, nonew:true, undef:true, strict:false, browser:true, jquery:true */ +/*jshint forin:false, nonew:true, undef:true, strict:false, browser:true, jquery:true */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Tagger - Advanced Tagging v2 * * Author: Artanis (Erik Youngren <artanis.00@gmail.com>) * * Do not remove this notice. * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - + var Tagger = { initialize : function (image_id) { // object navigation