diff --git a/e107_core/shortcodes/batch/fpw_shortcodes.php b/e107_core/shortcodes/batch/fpw_shortcodes.php new file mode 100644 index 000000000..3a6e42015 --- /dev/null +++ b/e107_core/shortcodes/batch/fpw_shortcodes.php @@ -0,0 +1,105 @@ +imageCode = true; + $this->secImg = e107::getSecureImg(); + } + } + + function sc_fpw_username($parm = null) // used when email login is disabled + { + + // return ""; + return e107::getForm()->text('username'); // $frm->userpicker()? + } + + function sc_fpw_useremail($parm = null) + { + + // return ''; + // return ""; + return e107::getForm()->email('email', '', 200, array('placeholder' => 'Email', 'required' => 'required')); + } + + function sc_fpw_submit($parm = null) + { + + // return ''; + // return ""; + $label = deftrue('LAN_FPW_102', LAN_SUBMIT); + + return e107::getForm()->button('pwsubmit', $label); + } + + function sc_fpw_captcha_lan($parm = null) + { + + return LAN_ENTER_CODE; + } + + function sc_fpw_captcha_hidden($parm = null) + { + + return; // no longer required - included in renderInput(); + } + + /** + * @param string $parm + * @return mixed|null|string + */ + function sc_fpw_captcha_img($parm = '') + { + + if($this->imageCode) + { + return $this->secImg->renderImage(); + } + + return null; + } + + /** + * @param string $parm + * @return mixed|null|string + */ + function sc_fpw_captcha_input($parm = null) + { + + if($this->imageCode) + { + return $this->secImg->renderInput(); + } + + return null; + } + + function sc_fpw_logo($parm = '') + { + // Unused at the moment. + } + + function sc_fpw_text($parm = null) + { + return deftrue('LAN_FPW_101', "Not to worry. Just enter your email address below and we'll send you an instruction email for recovery."); + } +} \ No newline at end of file diff --git a/e107_core/shortcodes/batch/news_shortcodes.php b/e107_core/shortcodes/batch/news_shortcodes.php index b36b941bf..418229cad 100644 --- a/e107_core/shortcodes/batch/news_shortcodes.php +++ b/e107_core/shortcodes/batch/news_shortcodes.php @@ -720,7 +720,7 @@ class news_shortcodes extends e_shortcode $class = !empty($parm['class']) ? "class='".$parm['class']."'" : ''; - if ($this->news_item['news_extended'] && ($this->param['current_action'] != 'extend' || $parm == 'force')) + if (!empty($this->news_item) && $this->news_item['news_extended'] && ($this->param['current_action'] != 'extend' || $parm == 'force')) { $es = (defined('EXTENDEDSTRING')) ? EXTENDEDSTRING : LAN_MORE; $es1 = (defined('PRE_EXTENDEDSTRING')) ? PRE_EXTENDEDSTRING : ''; diff --git a/e107_core/shortcodes/batch/search_shortcodes.php b/e107_core/shortcodes/batch/search_shortcodes.php new file mode 100644 index 000000000..ab55de5ed --- /dev/null +++ b/e107_core/shortcodes/batch/search_shortcodes.php @@ -0,0 +1,30 @@ +text('q','', 50, ['size'=>$size, 'class'=>$class]); + // return ""; + } + + + function sc_search_button($parm=null) + { + $class = isset($parm['class']) ? $parm['class'] : 'btn-default btn-secondary button search'; + return e107::getForm()->button('s','Search','submit', LAN_SEARCH, ['class'=>$class]); + // return ""; + } + + +} \ No newline at end of file diff --git a/e107_core/shortcodes/batch/signup_shortcodes.php b/e107_core/shortcodes/batch/signup_shortcodes.php index df4dea3cc..47bd9da3f 100755 --- a/e107_core/shortcodes/batch/signup_shortcodes.php +++ b/e107_core/shortcodes/batch/signup_shortcodes.php @@ -467,6 +467,11 @@ class signup_shortcodes extends e_shortcode function sc_signup_extended_user_fields($parm = null) { + if(empty($this->template['extended-user-fields'])) + { + return (ADMIN) ? "SIGNUP 'extended-user-fields' template not defined" : ''; + } + $text = ""; diff --git a/e107_core/shortcodes/single/custom.php b/e107_core/shortcodes/single/custom.php index 9eabee4e0..91b7303ac 100644 --- a/e107_core/shortcodes/single/custom.php +++ b/e107_core/shortcodes/single/custom.php @@ -4,7 +4,14 @@ function custom_shortcode($parm) $pref = e107::getPref(); $tp = e107::getParser(); $e107 = e107::getInstance(); - $custom_query = explode('+', $parm); + + $custom_query = !empty($parm) ? explode('+', $parm) : array(); + + if(empty($custom_query[0])) + { + return null; + } + switch($custom_query[0]) { case 'login': @@ -25,7 +32,7 @@ function custom_shortcode($parm) } else { - $ret .= "
\n
\n".LAN_LOGINMENU_1."  \n".LAN_LOGINMENU_2."  \n"; + $ret .= "\n
\n".LAN_LOGINMENU_1."  \n".LAN_LOGINMENU_2."  \n"; $ret .= ($pref['user_tracking'] == "cookie") ? "".LAN_LOGINMENU_6."  \n" : ""; $ret .= ""; if (intval($pref['user_reg'])===1) @@ -55,7 +62,7 @@ function custom_shortcode($parm) } else { - $quotes = file($qotdf_file); + $quotes = file($qotd_file); $quote = $tp->toHTML($quotes[rand(0, count($quotes) -1 )], true); } return $quote; @@ -74,7 +81,7 @@ function custom_shortcode($parm) { $selected = ($languageFolder == e_LANGUAGE) ? ' selected="selected"' : ''; $text .= ' - '; + '; } $text .= ' diff --git a/e107_core/shortcodes/single/e_image.sc b/e107_core/shortcodes/single/e_image.sc index 990bb6140..d5ca0a99c 100644 --- a/e107_core/shortcodes/single/e_image.sc +++ b/e107_core/shortcodes/single/e_image.sc @@ -1,2 +1 @@ -global $IMAGES_DIRECTORY; -return $IMAGES_DIRECTORY; +return e107::getFolder('IMAGES'); // $IMAGES_DIRECTORY; diff --git a/e107_core/shortcodes/single/email.sc b/e107_core/shortcodes/single/email.sc index 972d3da0e..b6a4d665a 100644 --- a/e107_core/shortcodes/single/email.sc +++ b/e107_core/shortcodes/single/email.sc @@ -1,14 +1,18 @@ e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE."/lan_user.php"); -global $tp; +if(!is_string($parm)) +{ + return null; +} + if (substr($parm, -5) === '-link') { $parm = substr($parm, 0, -5); - return ($user_hideemail && !ADMIN) ? "".LAN_143."" : $tp->toHTML($parm,TRUE); + return ($user_hideemail && !ADMIN) ? "".LAN_143."" : e107::getParser()->toHTML($parm,TRUE); } else { - return ($user_hideemail && !ADMIN) ? "".LAN_143."" : $parm; + return ($user_hideemail && !ADMIN) ? "".LAN_143."" : ($parm); } diff --git a/e107_core/shortcodes/single/email_item.sc b/e107_core/shortcodes/single/email_item.sc index 2dea063e4..3af8cb83f 100644 --- a/e107_core/shortcodes/single/email_item.sc +++ b/e107_core/shortcodes/single/email_item.sc @@ -5,6 +5,10 @@ if (!check_class(varset($pref['email_item_class'],e_UC_MEMBER))) return ''; } +if(empty($parm)) +{ + return null; +} $parms = explode("^",$parm); diff --git a/e107_core/shortcodes/single/emailto.sc b/e107_core/shortcodes/single/emailto.sc index 4711aee13..9e6e45e20 100644 --- a/e107_core/shortcodes/single/emailto.sc +++ b/e107_core/shortcodes/single/emailto.sc @@ -5,7 +5,12 @@ if (!USER) return ""; } -$image = IMAGE_email; +if(empty($parm)) +{ + return null; +} + +$image = defset('IMAGE_email'); if(is_numeric($parm)) { diff --git a/e107_core/shortcodes/single/extended.sc b/e107_core/shortcodes/single/extended.sc index 71c4cddd7..ee124d929 100755 --- a/e107_core/shortcodes/single/extended.sc +++ b/e107_core/shortcodes/single/extended.sc @@ -1,5 +1,9 @@ //this shortcode is deprecated due to a conflict with the news {EXTENDED} shortcode. // Use USER_EXTENDED instead. -global $tp; -return $tp->parseTemplate("{USER_EXTENDED=$parm}"); +if(empty($parm)) +{ + return null; +} + +return e107::getParser()->parseTemplate("{USER_EXTENDED=$parm}"); diff --git a/e107_core/shortcodes/single/extended_icon.sc b/e107_core/shortcodes/single/extended_icon.sc index eeabc58be..5540a4cb5 100644 --- a/e107_core/shortcodes/single/extended_icon.sc +++ b/e107_core/shortcodes/single/extended_icon.sc @@ -1,5 +1,10 @@ //USAGE: {EXTENDED_ICON=.} //EXAMPLE: {EXTENDED_ICON=user_gender.5} will show the icon of the extended field user_gender for user #5 +if(empty($parm) || !is_string($parm)) +{ + return null; +} + $parms = explode(".", $parm); -global $tp; -return $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.icon.{$parms[1]}}"); + +return e107::getParser()->parseTemplate("{USER_EXTENDED={$parms[0]}.icon.{$parms[1]}}"); diff --git a/e107_core/shortcodes/single/extended_text.sc b/e107_core/shortcodes/single/extended_text.sc index 409a2eacc..7b6c1cb34 100644 --- a/e107_core/shortcodes/single/extended_text.sc +++ b/e107_core/shortcodes/single/extended_text.sc @@ -1,5 +1,10 @@ //USAGE: {EXTENDED_TEXT=.} //EXAMPLE: {EXTENDED_TEXT=user_gender.5} will show the text of the extended field user_gender for user #5 + +if(empty($parm) || !is_string($parm)) +{ + return null; +} $parms = explode(".", $parm); global $tp; -return $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.text.{$parms[1]}}"); +return e107::getParser()->parseTemplate("{USER_EXTENDED={$parms[0]}.text.{$parms[1]}}"); diff --git a/e107_core/shortcodes/single/extended_value.sc b/e107_core/shortcodes/single/extended_value.sc index 75c33abc8..67ae5941e 100644 --- a/e107_core/shortcodes/single/extended_value.sc +++ b/e107_core/shortcodes/single/extended_value.sc @@ -1,5 +1,9 @@ //USAGE: {EXTENDED_VALUE=.} //EXAMPLE: {EXTENDED_VALUE=user_gender.5} will show the value of the extended field user_gender for user #5 +if(empty($parm) || !is_string($parm)) +{ + return null; +} + $parms = explode(".", $parm); -global $tp; -return $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.value.{$parms[1]}}"); +return e107::getParser()->parseTemplate("{USER_EXTENDED={$parms[0]}.value.{$parms[1]}}"); diff --git a/e107_core/shortcodes/single/iconpicker.php b/e107_core/shortcodes/single/iconpicker.php index 16f066ea7..e7112dbfd 100644 --- a/e107_core/shortcodes/single/iconpicker.php +++ b/e107_core/shortcodes/single/iconpicker.php @@ -9,9 +9,16 @@ function iconpicker_shortcode($parm) { + if(empty($parm)) + { + return null; + } + $parms = array(); + parse_str($parm, $parms); $name = varset($parms['id']); + $sql = e107::getDb(); $frm = e107::getForm(); @@ -41,7 +48,7 @@ function iconpicker_shortcode($parm) $str = ""; } - $str .= "{$row["; + $str .= "{$row["; $lastsize = $size; @@ -52,4 +59,3 @@ function iconpicker_shortcode($parm) } -?> \ No newline at end of file diff --git a/e107_core/shortcodes/single/imagepreview.php b/e107_core/shortcodes/single/imagepreview.php index 679d0adfe..e96d31a66 100644 --- a/e107_core/shortcodes/single/imagepreview.php +++ b/e107_core/shortcodes/single/imagepreview.php @@ -3,6 +3,11 @@ function imagepreview_shortcode($parm) { + if(empty($parm)) + { + return null; + } + list($name, $width, $height, $nothumb) = explode("|",$parm, 4); $name = rawurldecode(varset($name));//avoid warnings diff --git a/e107_core/shortcodes/single/imageselector.php b/e107_core/shortcodes/single/imageselector.php index ad7aaaf66..2c87ba67b 100644 --- a/e107_core/shortcodes/single/imageselector.php +++ b/e107_core/shortcodes/single/imageselector.php @@ -8,6 +8,11 @@ function imageselector_shortcode($parm = '', $mod = '') $sql = e107::getDb('imageselector.sc'); $tp = e107::getParser(); + if(empty($parm)) + { + return null; + } + if (strpos($parm, "=") !== false) { // query style parms. parse_str($parm, $parms); diff --git a/e107_core/shortcodes/single/lan.php b/e107_core/shortcodes/single/lan.php index 21d9cc0ae..1baa5d6f1 100644 --- a/e107_core/shortcodes/single/lan.php +++ b/e107_core/shortcodes/single/lan.php @@ -3,6 +3,11 @@ function lan_shortcode($parm = '') { + if(empty($parm)) + { + return null; + } + $lan = trim($parm); if(defined($lan)) { diff --git a/e107_core/shortcodes/single/languagelinks.php b/e107_core/shortcodes/single/languagelinks.php index 13ac85abf..8788e516e 100644 --- a/e107_core/shortcodes/single/languagelinks.php +++ b/e107_core/shortcodes/single/languagelinks.php @@ -51,10 +51,13 @@ function languagelinks_shortcode($parm = '') define('LANGLINKS_SEPARATOR', ' | '); } - $tmp = explode('|', $parm, 2); - $parm = $tmp[0]; - $parms = array(); - if(isset($tmp[1])) parse_str($tmp[1], $parms); + if(is_string($parm)) + { + $tmp = explode('|', $parm, 2); + $parm = $tmp[0]; + $parms = array(); + if(isset($tmp[1])) parse_str($tmp[1], $parms); + } // ignore Query string if required by parms or external code, false by default if(!defined('LANGLINKS_NOQUERY')) @@ -67,8 +70,6 @@ function languagelinks_shortcode($parm = '') define('LANGLINKS_HOME', isset($parms['home'])); } - /*require_once(e_HANDLER.'language_class.php'); - $slng = new language;*/ $slng = e107::getLanguage(); if(!empty($parm)) diff --git a/e107_core/shortcodes/single/menu.php b/e107_core/shortcodes/single/menu.php index 0b1cff2ce..01c938b7b 100644 --- a/e107_core/shortcodes/single/menu.php +++ b/e107_core/shortcodes/single/menu.php @@ -6,7 +6,12 @@ if(!defined('e107_INIT')) function menu_shortcode($parm, $mode='') { - + + if(empty($parm)) + { + return null; + } + if(is_array($parm)) //v2.x format allowing for parms. {MENU: path=y&count=x} { list($plugin,$menu) = explode("/",$parm['path'],2); diff --git a/e107_core/shortcodes/single/menuarea.php b/e107_core/shortcodes/single/menuarea.php index 06d6e1a1b..1c793ec7c 100644 --- a/e107_core/shortcodes/single/menuarea.php +++ b/e107_core/shortcodes/single/menuarea.php @@ -20,6 +20,10 @@ if(!defined('e107_INIT')) function menuarea_shortcode($parm, $mode='') { + if(empty($parm)) + { + return null; + } return e107::getMenu()->renderArea($parm); diff --git a/e107_core/shortcodes/single/news_categories.sc b/e107_core/shortcodes/single/news_categories.sc index e9d74bada..89fb1224b 100644 --- a/e107_core/shortcodes/single/news_categories.sc +++ b/e107_core/shortcodes/single/news_categories.sc @@ -15,6 +15,8 @@ $pref = e107::getPref(); $tp = e107::getParser(); $scbatch = e107::getScBatch('news'); + + $cString = 'nq_news_categories_sc'; $cached = e107::getCache()->retrieve($cString); @@ -174,10 +176,12 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols; //$row['category_name'] = $category_name; //$row['category_icon'] = $category_icon; $row = array_merge($row, $row3); + $textbody .= $ix -> render_newsitem($row, 'return', '', $NEWSCAT_ITEM, $param); - + } } + // ---------------------------------- $search[0] = "/\{NEWSCATICON\}(.*?)/si"; $replace[0] = $scbatch->sc_newscaticon('url'); diff --git a/e107_core/shortcodes/single/picture.sc b/e107_core/shortcodes/single/picture.sc index afb78dcf4..f440c7e19 100644 --- a/e107_core/shortcodes/single/picture.sc +++ b/e107_core/shortcodes/single/picture.sc @@ -4,9 +4,12 @@ if(empty($parm) && is_numeric($loop_uid)) { $parm = $loop_uid; } + +$image = ''; + if(is_numeric($parm)) { - if((int) $parm == USERID) + if((int) $parm == USERID && deftrue('USERPHOTO')) { $image = USERPHOTO; } @@ -22,7 +25,12 @@ elseif($parm) } else { - $image = USERPHOTO; + $image = deftrue('USERPHOTO'); +} + +if(empty($image)) +{ + return null; } return e107::getParser()->parseTemplate("{USER_AVATAR=".$image."}",true); diff --git a/e107_core/shortcodes/single/plugin.php b/e107_core/shortcodes/single/plugin.php index ac38ef342..62f5a4495 100644 --- a/e107_core/shortcodes/single/plugin.php +++ b/e107_core/shortcodes/single/plugin.php @@ -3,6 +3,11 @@ function plugin_shortcode($parm = '') { + if(empty($parm)) + { + return null; + } + $tp = e107::getParser(); @list($menu,$parms) = explode('|',$parm.'|', 2); diff --git a/e107_core/shortcodes/single/print_item.sc b/e107_core/shortcodes/single/print_item.sc index 66c2604fe..123e6e1a4 100644 --- a/e107_core/shortcodes/single/print_item.sc +++ b/e107_core/shortcodes/single/print_item.sc @@ -1,5 +1,9 @@ //".IMAGE_profile.""; +return "".defset('IMAGE_profile').""; diff --git a/e107_core/shortcodes/single/search.php b/e107_core/shortcodes/single/search.php new file mode 100644 index 000000000..b0e87877f --- /dev/null +++ b/e107_core/shortcodes/single/search.php @@ -0,0 +1,87 @@ + getArray('search_prefs'); + + $search_prefs = e107::getConfig('search')->getPref(); + + + if(!empty($search_prefs['plug_handlers']) && is_array($search_prefs['plug_handlers'])) + { + foreach($search_prefs['plug_handlers'] as $plug_dir => $active) + { + if(is_readable(e_PLUGIN . $plug_dir . "/e_search.php")) + { + $ref[$plug_dir] = $plug_dir; + } + } + } + if(!empty($parm) && !empty($ref[$parm])) + { + $page = $ref[$parm]; + } + elseif($parm == 'all' && defined('e_PAGE') && !empty($ref[e_PAGE])) + { + $page = $ref[e_PAGE]; + } + else + { + $page = 'all'; + } + + if(empty($SEARCH_SHORTCODE)) + { + return null; + } + + $sc = e107::getScBatch('search'); + $sc->wrapper('search/shortcode'); + + $text .= "
\n"; + $text .= "\n"; + $text .= "\n"; + + if(defined('SEARCH_SHORTCODE_REF') && SEARCH_SHORTCODE_REF != '') + { + $text .= "\n"; + } + + $text .= e107::getParser()->parseTemplate($SEARCH_SHORTCODE, true, $sc); + + $text .= "\n
"; + + return $text; + + +} \ No newline at end of file diff --git a/e107_core/shortcodes/single/search.sc b/e107_core/shortcodes/single/search.sc deleted file mode 100644 index 17c245611..000000000 --- a/e107_core/shortcodes/single/search.sc +++ /dev/null @@ -1,63 +0,0 @@ -// getArray('search_prefs'); - - $search_prefs = e107::getConfig('search')->getPref(); - - - if(is_array($search_prefs['plug_handlers'])) - { - foreach ($search_prefs['plug_handlers'] as $plug_dir => $active) - { - if (is_readable(e_PLUGIN.$plug_dir."/e_search.php")) - { - $ref[$plug_dir] = $plug_dir; - } - } - } - if($ref[$parm]!= ''){ - $page = $ref[$parm]; - }elseif($parm='all' && $ref[e_PAGE] != ''){ - $page = $ref[e_PAGE]; - }else{ - $page = 'all'; - } - - $text .= "
\n"; - $text .= "\n"; - $text .= "\n"; - - if (defined('SEARCH_SHORTCODE_REF') && SEARCH_SHORTCODE_REF != '') { - $text .= "\n"; - } - - $text .= $SEARCH_SHORTCODE; - - $text .="\n
"; - - return $text; diff --git a/e107_core/shortcodes/single/setstyle.php b/e107_core/shortcodes/single/setstyle.php index 9f29b080c..977600782 100644 --- a/e107_core/shortcodes/single/setstyle.php +++ b/e107_core/shortcodes/single/setstyle.php @@ -6,6 +6,11 @@ global $style; // BC $style = $parm; // BC + if(empty($parm)) + { + return null; + } + e107::getRender()->setStyle($parm); } diff --git a/e107_core/shortcodes/single/sitelinks.sc b/e107_core/shortcodes/single/sitelinks.sc index e8614029a..018c22e46 100644 --- a/e107_core/shortcodes/single/sitelinks.sc +++ b/e107_core/shortcodes/single/sitelinks.sc @@ -1,8 +1,11 @@ global $eMenuActive,$linkstyle; // PHP warnings FIX - Deprecated menus, $eMenuActive not set -//if(!in_array('edynamic_menu',$eMenuActive) && !in_array('tree_menu',$eMenuActive) && !in_array('q_tree_menu',$eMenuActive)) +//if(!empty($parm) && is_string($parm) && !in_array('edynamic_menu',$eMenuActive) && !in_array('tree_menu',$eMenuActive) && !in_array('q_tree_menu',$eMenuActive)) + + +if(is_string($parm)) { - $tmp = explode(":",$parm); + $tmp = explode(":", $parm); $linktype = $tmp[0]; $cat = (isset($tmp[1])) ? $tmp[1] : 1; $css_class = (isset($tmp[2])) ? $tmp[2] : false; diff --git a/e107_core/shortcodes/single/sitelinks_alt.php b/e107_core/shortcodes/single/sitelinks_alt.php index 9b93fe7e8..4cbc75b9a 100644 --- a/e107_core/shortcodes/single/sitelinks_alt.php +++ b/e107_core/shortcodes/single/sitelinks_alt.php @@ -16,6 +16,11 @@ class sitelinks_alt static function sitelinks_alt_shortcode($parm) { + if(empty($parm)) + { + return null; + } + $params = explode('+', $parm); if (vartrue($params[0]) && ($params[0] != 'no_icons') && ($params[0] != 'default')) diff --git a/e107_core/shortcodes/single/sublinks.php b/e107_core/shortcodes/single/sublinks.php index 970d7d748..1b8210b81 100644 --- a/e107_core/shortcodes/single/sublinks.php +++ b/e107_core/shortcodes/single/sublinks.php @@ -4,40 +4,46 @@ function sublinks_shortcode($parm) { - global $sql,$linkstyle;; - if($parm){ - list($page,$cat) = explode(":",$parm); + global $sql, $linkstyle;; + + if($parm) + { + list($page, $cat) = explode(":", $parm); } - $page = ($page) ? $page : e_PAGE; - $cat = ($cat) ? $cat : 1; + $page = isset($page) ? $page : defset('e_PAGE'); + $cat = isset($cat) ? $cat : 1; - require_once(e_HANDLER."sitelinks_class.php"); + require_once(e_HANDLER . "sitelinks_class.php"); $sublinks = new sitelinks; - if(function_exists("linkstyle")){ - $style = linkstyle($linkstyle); - }else{ - $style=""; + if(function_exists("linkstyle")) + { + $style = linkstyle($linkstyle); + } + else + { + $style = array('prelink' => '', 'postlink'=>''); } $text = "\n\n\n\n"; - $text .= $style['prelink']; - $sql->select("links", "link_id","link_url= '{$page}' AND link_category = {$cat} LIMIT 1"); - $row = $sql->fetch(); - $parent = $row['link_id']; - - $link_total = $sql->select("links", "*", "link_class IN (".USERCLASS_LIST.") AND link_parent={$parent} ORDER BY link_order ASC"); - while($linkInfo = $sql->fetch()) + $text .= $style['prelink']; + if($sql->select("links", "link_id", "link_url= '{$page}' AND link_category = {$cat} LIMIT 1")) { - $text .= $sublinks->makeLink($linkInfo,TRUE, $style, false); - } + $row = $sql->fetch(); + $parent = (int) $row['link_id']; - $text .= $style['postlink']; + $link_total = $sql->select("links", "*", "link_class IN (" . USERCLASS_LIST . ") AND link_parent={$parent} ORDER BY link_order ASC"); + while($linkInfo = $sql->fetch()) + { + $text .= $sublinks->makeLink($linkInfo, true, $style, false); + } + + $text .= $style['postlink']; + } $text .= "\n\n\n\n"; - return $text; + return $text; } -?> \ No newline at end of file diff --git a/e107_core/shortcodes/single/uploadfile.php b/e107_core/shortcodes/single/uploadfile.php index a82c9399d..9d01c2226 100644 --- a/e107_core/shortcodes/single/uploadfile.php +++ b/e107_core/shortcodes/single/uploadfile.php @@ -75,11 +75,16 @@ function uploadfile_shortcode($parm) { return LAN_UPLOAD_SERVEROFF; } - if(USER_AREA === TRUE && !check_class(e107::getPref('upload_class'))) + if(deftrue('USER_AREA') && !check_class(e107::getPref('upload_class'))) { return LAN_DISABLED; } + if(empty($parm)) + { + return null; + } + $parm = explode('|', $parm, 2); $path = $parm[0]; @@ -142,15 +147,15 @@ function uploadfile_shortcode($parm) $onclickd = " onclick=\"duplicateHTML('{$parms['up_row']}','{$parms['up_container']}');\""; $name = $parms['name'].'[]'; - $text .=" + $text ="
- "; + "; // Media Manager does the submit, not the shortcode. if(!$parms['disable_button']) - $text .= ""; + $text .= ""; $text .= "
diff --git a/e107_core/shortcodes/single/url.php b/e107_core/shortcodes/single/url.php index cb55ecb4e..7ffdbe19f 100644 --- a/e107_core/shortcodes/single/url.php +++ b/e107_core/shortcodes/single/url.php @@ -7,7 +7,22 @@ */ function url_shortcode($parm) { - list($route, $parms) = eHelper::scDualParams($parm); + if(empty($parm)) + { + return null; + } + + $tmp = eHelper::scDualParams($parm); + + $route = varset($tmp[1]); + $parms = varset($tmp[2]); + + if(empty($route)) + { + return null; + } + +// list($route, $parms) = eHelper::scDualParams($parm); if(empty($route)) return ''; $options = array(); @@ -16,5 +31,6 @@ function url_shortcode($parm) $options = $parms['options']; unset($parms['options']); } + return e107::getUrl()->create($route, $parms, $options); } diff --git a/e107_core/shortcodes/single/user_extended_old.sc b/e107_core/shortcodes/single/user_extended_old.sc deleted file mode 100644 index a01b941c9..000000000 --- a/e107_core/shortcodes/single/user_extended_old.sc +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt) - * $Id$ - * - * Extended user field shortcode -*/ - -/** - * - * USAGE: {USER_EXTENDED=.[text|value|icon|text_value].} - * EXAMPLE: {USER_EXTENDED=user_gender.value.5} will show the value of the extended field user_gender for user #5 - */ -e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_user_extended.php'); -$parms = explode('.', $parm); -global $currentUser, $tp, $loop_uid, $e107, $sc_style; -if(isset($loop_uid) && intval($loop_uid) == 0) { return ''; } -$key = $parms[0].".".$parms[1]; -$sc_style['USER_EXTENDED']['pre'] = (isset($sc_style['USER_EXTENDED'][$key]['pre']) ? $sc_style['USER_EXTENDED'][$key]['pre'] : ''); -$sc_style['USER_EXTENDED']['post'] = (isset($sc_style['USER_EXTENDED'][$key]['post']) ? $sc_style['USER_EXTENDED'][$key]['post'] : ''); -include_once(e_HANDLER.'user_extended_class.php'); -$ueStruct = e107_user_extended::user_extended_getStruct(); - -$uid = intval(varset($parms[2],0)); -if($uid == 0) -{ - if(isset($loop_uid) && intval($loop_uid) > 0) - { - $uid = $loop_uid; - } - else - { - $uid = USERID; - } -} - -$udata = e107::user($uid); - -$udata['user_class'] .= ($udata['user_class'] == '' ? '' : ','); -$udata['user_class'] .= e_UC_PUBLIC.",".e_UC_MEMBER; -if($udata['user_admin'] == 1) -{ - $udata['user_class'].= ','.e_UC_ADMIN; -} - - - -// Need to pick up the 'miscellaneous' category - anything which isn't in a named category. Have to control visibility on a field by field basis -// And I don't think this should apply to icons -/** - * @todo - must be a better way of picking up the 'Miscellaneous' category - */ -e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_user.php'); -if (($parms[1] != 'icon') && ($parms[0] != LAN_USER_44)) -{ - $ret_cause = 0; - if (!check_class($ueStruct["user_".$parms[0]]['user_extended_struct_applicable'], $udata['user_class'])) $ret_cause = 1; - if (!check_class($ueStruct["user_".$parms[0]]['user_extended_struct_read'], $udata['user_class'])) $ret_cause = 2; - if (($ueStruct["user_".$parms[0]]['user_extended_struct_read'] == e_UC_READONLY && (!ADMIN && $udata['user_id'] != USERID))) $ret_cause = 3; - if ((!ADMIN && substr($ueStruct["user_".$parms[0]]['user_extended_struct_parms'], -1) == 1 - && strpos($udata['user_hidden_fields'], "^user_".$parms[0]."^") !== FALSE && $uid != USERID)) $ret_cause = 4; - if ($ret_cause != 0) - { - return FALSE; - } -} - -if($parms[1] == 'text_value') -{ - $_value = $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.value}"); - if($_value) - { - $__pre = (isset($sc_style['USER_EXTENDED'][$key]['pre']) ? $sc_style['USER_EXTENDED'][$key]['pre'] : ''); - $__post = (isset($sc_style['USER_EXTENDED'][$key]['post']) ? $sc_style['USER_EXTENDED'][$key]['post'] : ''); - $_text = $tp->parseTemplate("{USER_EXTENDED={$parms[0]}.text}"); - $_mid = (isset($sc_style['USER_EXTENDED'][$key]['mid']) ? $sc_style['USER_EXTENDED'][$key]['mid'] : ''); - return $__pre.$_text.$_mid.$_value.$__post; - } - return false; -} - -if ($parms[1] == 'text') -{ - $text_val = $ueStruct['user_'.$parms[0]]['user_extended_struct_text']; - if($text_val) - { - return (defined($text_val) ? constant($text_val) : $text_val); - } - else - { - return FALSE; - } -} - -if ($parms[1] == 'icon') -{ - if(defined(strtoupper($parms[0]).'_ICON')) - { - return constant(strtoupper($parms[0]).'_ICON'); - } - elseif(is_readable(e_IMAGE."user_icons/user_{$parms[0]}.png")) - { - return ""; - } - elseif(is_readable(e_IMAGE."user_icons/{$parms[0]}.png")) - { - return ""; - } - //return ''; - return FALSE; -} - -if ($parms[1] == 'value') -{ - $uVal = str_replace(chr(1), '', $udata['user_'.$parms[0]]); - switch ($ueStruct["user_".$parms[0]]['user_extended_struct_type']) - { - case EUF_DB_FIELD : // check for db_lookup type - $tmp = explode(',',$ueStruct['user_'.$parms[0]]['user_extended_struct_values']); - $sql_ue = new db; // Use our own DB object to avoid conflicts - if($sql_ue->select($tmp[0],"{$tmp[1]}, {$tmp[2]}","{$tmp[1]} = '{$uVal}'")) - { - $row = $sql_ue->fetch(); - $ret_data = $row[$tmp[2]]; - } - else - { - $ret_data = FALSE; - } - break; - case EUF_DATE : //check for 0000-00-00 in date field - if($uVal == '0000-00-00') { $uVal = ''; } - $ret_data = $uVal; - break; - case EUF_PREDEFINED : // Predefined field - have to look up display string in relevant file - $ret_data = e107_user_extended::user_extended_display_text($ueStruct['user_'.$parms[0]]['user_extended_struct_values'],$uVal); - break; - default : - $ret_data = $uVal; - } - if($ret_data != '') - { - return $tp->toHTML($ret_data, TRUE, 'no_make_clickable', "class:{$udata['user_class']}"); - } - return FALSE; -} -// return TRUE; -return FALSE; \ No newline at end of file diff --git a/e107_core/shortcodes/single/usersearch.php b/e107_core/shortcodes/single/usersearch.php index ae84df63e..7a83759c2 100644 --- a/e107_core/shortcodes/single/usersearch.php +++ b/e107_core/shortcodes/single/usersearch.php @@ -54,4 +54,3 @@ function usersearch_shortcode($parm) $ret .= ""; return $ret; } -?> \ No newline at end of file diff --git a/e107_core/templates/search_template.php b/e107_core/templates/search_template.php index a68eeb575..fd16d9d68 100644 --- a/e107_core/templates/search_template.php +++ b/e107_core/templates/search_template.php @@ -11,8 +11,8 @@ if (!defined('SEARCH_SHORTCODE_REF')) { if(!isset($SEARCH_SHORTCODE)) { - - $SEARCH_SHORTCODE = " + // + $SEARCH_SHORTCODE = " "; /* // Image Version Example @@ -135,36 +135,36 @@ if(!isset($POST_CHECKBOXES)) $SEARCH_TEMPLATE['form']['start'] = ' -
-
- -
{SEARCH_MAIN} -
-
-
- {SEARCH_ENHANCED} -
- '; + +
+ +
{SEARCH_MAIN} +
+
+
+ {SEARCH_ENHANCED} +
+ '; $SEARCH_TEMPLATE['form']['advanced'] = ' -
- -
- - {SEARCH_ADV_B} - -
-
'; +
+ +
+ + {SEARCH_ADV_B} + +
+
'; $SEARCH_TEMPLATE['form']['enhanced'] = ' -
- -
- {ENHANCED_FIELD} -
-
'; +
+ +
+ {ENHANCED_FIELD} +
+
'; /* @@ -178,14 +178,14 @@ $SEARCH_TEMPLATE['form']['type'] = ' */ $SEARCH_TEMPLATE['form']['category'] = ' -
- -
- {SEARCH_MAIN_CHECKBOXES}{SEARCH_DROPDOWN}  -
- -
- {SEARCH_ADVANCED}'; +
+ +
+ {SEARCH_MAIN_CHECKBOXES}{SEARCH_DROPDOWN}  +
+ +
+ {SEARCH_ADVANCED}'; $SEARCH_TEMPLATE['form']['end'] = "
@@ -194,15 +194,10 @@ $SEARCH_TEMPLATE['form']['end'] = " $SEARCH_TEMPLATE['form']['advanced-combo'] = '
{SEARCH_ADV_TEXT}
'; -/* -" - ".LAN_SEARCH_19."
- {SEARCH_MAIN_CHECKALL} {SEARCH_MAIN_UNCHECKALL} - - - {SEARCH_MAIN_CHECKBOXES}{SEARCH_DROPDOWN} {SEARCH_ADVANCED} -
- - "; -*/ +$SEARCH_TEMPLATE['shortcode'] = " + {SEARCH_INPUT} + {SEARCH_BUTTON} +"; + + diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index 5c3bf691a..0c9bc2d7f 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -298,7 +298,7 @@ class comment $text .= " - + diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 04b873aad..a642a5ed3 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -856,15 +856,15 @@ class e_parse_shortcode { // TODO use Library Manager... e107::js('footer', '{e_WEB}js/jquery.contenteditable.js', 'jquery', 2); - - $_SESSION['editable'][e_TOKEN] = $this->editableCodes; + $token = defset('e_TOKEN','token-missing'); + $_SESSION['editable'][$token] = $this->editableCodes; e107::js('footer-inline', '$(".e-editable-front").each(function () { var sc = $(this).attr("data-edit-sc"); var id = $(this).attr("data-edit-id"); - var token = "'.e_TOKEN.'"; + var token = "'.$token.'"; var box = $(this).parent("div, span"); var container = this; @@ -1334,7 +1334,7 @@ class e_parse_shortcode $error['problem'] = $scCode; e107::getDebug()->logCode(-2, $code, null, print_a($error,true)); - + trigger_error("Couldn't parse {".$code."} legacy shortcode at line ".$t->getLine().".\n". $t->getMessage(), E_USER_NOTICE); } if($ret === false && E107_DEBUG_LEVEL > 0 ) // Error in Code. diff --git a/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php b/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php index 8b33de5e7..bba280eb1 100644 --- a/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php @@ -86,11 +86,11 @@ class forum_shortcodes extends e_shortcode return " \n - + - + - + \n
".IMAGE_new_small."".defset('IMAGE_new_small')." ".LAN_FORUM_0039."".IMAGE_nonew_small."".defset('IMAGE_nonew_small')." ".LAN_FORUM_0040."".IMAGE_closed_small."".defset('IMAGE_closed_small')." ".LAN_FORUM_0041."
\n"; } diff --git a/e107_tests/tests/unit/e107_user_extendedTest.php b/e107_tests/tests/unit/e107_user_extendedTest.php index d1db73938..90a554a72 100644 --- a/e107_tests/tests/unit/e107_user_extendedTest.php +++ b/e107_tests/tests/unit/e107_user_extendedTest.php @@ -353,7 +353,7 @@ 'user_extended_struct_default' => 'F', 'user_extended_struct_read' => '0', 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', + 'user_extended_struct_required' => '1', 'user_extended_struct_signup' => '0', 'user_extended_struct_applicable' => '0', 'user_extended_struct_order' => '2', @@ -774,7 +774,7 @@ 'user_extended_struct_default' => 'F', 'user_extended_struct_read' => '0', 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', + 'user_extended_struct_required' => '1', 'user_extended_struct_signup' => '0', 'user_extended_struct_applicable' => '0', 'user_extended_struct_order' => '2', @@ -791,7 +791,7 @@ 'user_extended_struct_default' => '', 'user_extended_struct_read' => '0', 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', + 'user_extended_struct_required' => '1', 'user_extended_struct_signup' => '0', 'user_extended_struct_applicable' => '0', 'user_extended_struct_order' => '5', @@ -808,7 +808,7 @@ 'user_extended_struct_default' => '', 'user_extended_struct_read' => '0', 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', + 'user_extended_struct_required' => '1', 'user_extended_struct_signup' => '0', 'user_extended_struct_applicable' => '0', 'user_extended_struct_order' => '9', @@ -939,7 +939,7 @@ 'user_extended_struct_default' => 'F', 'user_extended_struct_read' => '0', 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', + 'user_extended_struct_required' => '1', 'user_extended_struct_signup' => '0', 'user_extended_struct_applicable' => '0', 'user_extended_struct_order' => '2', @@ -956,7 +956,7 @@ 'user_extended_struct_default' => '', 'user_extended_struct_read' => '0', 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', + 'user_extended_struct_required' => '1', 'user_extended_struct_signup' => '0', 'user_extended_struct_applicable' => '0', 'user_extended_struct_order' => '5', @@ -973,7 +973,7 @@ 'user_extended_struct_default' => '', 'user_extended_struct_read' => '0', 'user_extended_struct_write' => '0', - 'user_extended_struct_required' => '0', + 'user_extended_struct_required' => '1', 'user_extended_struct_signup' => '0', 'user_extended_struct_applicable' => '0', 'user_extended_struct_order' => '9', diff --git a/e107_tests/tests/unit/e_formTest.php b/e107_tests/tests/unit/e_formTest.php index 530ce91b4..fecda0e14 100644 --- a/e107_tests/tests/unit/e_formTest.php +++ b/e107_tests/tests/unit/e_formTest.php @@ -164,7 +164,7 @@ class e_formTest extends \Codeception\Test\Unit e107::includeLan(e_PLUGIN.'forum/languages/English/English_front.php'); include_once(e_CORE."templates/admin_icons_template.php"); include_once(e_PLUGIN.'forum/forum_class.php'); - include_once(e_PLUGIN.'forum/templates/forum_icons_template.php'); + require_once(e_PLUGIN.'forum/templates/forum_icons_template.php'); $legacyDir = APP_PATH."/e107_files/downloadimages/"; $legacyFile = APP_PATH."/e107_files/downloadimages/butterfly.jpg"; diff --git a/e107_tests/tests/unit/e_parse_shortcodeTest.php b/e107_tests/tests/unit/e_parse_shortcodeTest.php index 253954024..b1dd995d8 100644 --- a/e107_tests/tests/unit/e_parse_shortcodeTest.php +++ b/e107_tests/tests/unit/e_parse_shortcodeTest.php @@ -541,6 +541,8 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit $this->fail($e->getMessage()); } + $sc->__construct(); + $exclude = array('sc_signup_coppa_text'); // uses random email obfiscation. $this->processShortcodeMethods($sc, $exclude); @@ -858,7 +860,20 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit public function testFpwShortcodes() // todo move fpw shortcodes out of fpw.php to its own file. { + require_once(e_CORE."shortcodes/batch/fpw_shortcodes.php"); + try + { + $sc = $this->make('fpw_shortcodes'); + } + catch (Exception $e) + { + $this->fail($e->getMessage()); + } + + $sc->__construct(); + + $this->processShortcodeMethods($sc); } @@ -1417,6 +1432,57 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit + } + + /** + * Execute all single shortcodes to check for PHP errors. + */ + public function testSingleShortcodes() + { + $list = scandir(e_CORE."shortcodes/single"); + $tp = e107::getParser(); + + $parms = array( + 'email' => 'myemail@somewhere.com-link', + 'emailto' => '2', + 'email_item' => 'Some Message^plugin:forum.45', + 'glyph' => 'fa-anchor', + 'url' => 'news/view/item|news_id=1&news_sef=sef-string&category_id=1&category_sef=category-sef&options[full]=1', + 'user_extended' => 'name.text.1', + 'lan' => 'LAN_EDIT', + 'search' => 'all' + ); + + foreach($list as $sc) + { + $ext = pathinfo($sc); + $name = $ext['filename']; + + if($ext['extension'] !== 'sc' && $ext['extension'] !== 'php') + { + continue; + } + + + $shortcode = '{'; + $shortcode .= strtoupper($name); + $shortcode .= isset($parms[$name]) ? '='.$parms[$name] : ''; + $shortcode .= '}'; + // echo "\n".$shortcode."\n"; + $result = $tp->parseTemplate($shortcode,true); + + if($name === 'search') + { + echo $result."\n\n"; + } + + if(isset($parms[$name]) && $name !== 'user_extended') + { + $this->assertNotEmpty($result, $shortcode." returned nothing!"); + } + + } + } diff --git a/fpw.php b/fpw.php index f559b1cc0..f61a13090 100644 --- a/fpw.php +++ b/fpw.php @@ -35,88 +35,6 @@ else } -class fpw_shortcodes extends e_shortcode -{ - private $secImg; - - function __construct() - { - parent::__construct(); - global $sec_img; - $this->secImg = $sec_img; - } - - function sc_fpw_username($parm=null) // used when email login is disabled - { - // return ""; - return e107::getForm()->text('username'); // $frm->userpicker()? - } - - function sc_fpw_useremail($parm=null) - { - // return ''; - // return ""; - return e107::getForm()->email('email', '', 200, array('placeholder' => 'Email', 'required' => 'required')); - } - - function sc_fpw_submit($parm=null) - { - // return ''; - // return ""; - $label = deftrue('LAN_FPW_102', LAN_SUBMIT); - return e107::getForm()->button('pwsubmit', $label); - } - - function sc_fpw_captcha_lan($parm=null) - { - return LAN_ENTER_CODE; - } - - function sc_fpw_captcha_hidden($parm=null) - { - return; // no longer required - included in renderInput(); - } - - /** - * @param string $parm - * @return mixed|null|string - */ - function sc_fpw_captcha_img($parm='') - { - if(USE_IMAGECODE) - { - return $this->secImg->renderImage(); - } - - return null; - } - - /** - * @param string $parm - * @return mixed|null|string - */ - function sc_fpw_captcha_input($parm=null) - { - if(USE_IMAGECODE) - { - return $this->secImg->renderInput(); - } - - return null; - } - - function sc_fpw_logo($parm='') - { - // Unused at the moment. - } - - function sc_fpw_text($parm=null) - { - return deftrue('LAN_FPW_101',"Not to worry. Just enter your email address below and we'll send you an instruction email for recovery."); - } -} - - if ($pref['membersonly_enabled']) { $sc = array ( @@ -407,7 +325,6 @@ $sc = array(); // needed? if(deftrue('BOOTSTRAP')) { - // TODO do we want the
element outside the template? $FPW_TABLE = ""; if(getperms('0')) @@ -426,7 +343,7 @@ elseif(!$FPW_TABLE) $caption = LAN_03; } -$sc = new fpw_shortcodes; +$sc = e107::getScBatch('fpw'); // fpw_shortcodes; // New Shortcode names in v2. BC Fix. $bcShortcodes = array('{FPW_TABLE_SECIMG_LAN}', '{FPW_TABLE_SECIMG_HIDDEN}', '{FPW_TABLE_SECIMG_SECIMG}', '{FPW_TABLE_SECIMG_TEXTBOC}'); @@ -435,8 +352,6 @@ $FPW_TABLE = str_replace($bcShortcodes,$nwShortcodes,$FPW_TABLE); $text = $tp->parseTemplate($FPW_TABLE, true, $sc); -// $text = $tp->simpleParse($FPW_TABLE, $sc); - $ns->tablerender($caption, $text, 'fpw'); require_once(FOOTERF);