MyBB Community Forums

Full Version: Porblem template & variables
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
In /inc/plugins/ban.php i've create this template:

<label><input type=\"checkbox\" class=\"checkbox\" name=\"ban\" value=\"1\">{$lang->ban_to_user}</label>

<div class=\"div1\"> <div style=\"overflow-y: auto; max-height: 700px;\" class=\"modal_{$id}\">
 <form action=\"ban.php\" method=\"post\" class=\"banUser_{$id}\" onsubmit=\"javascript: return Ban.submitBan({$id});\">
  <input type=\"hidden\" name=\"my_post_key\" value=\"{$mybb->post_code}\" /> <input type=\"hidden\" name=\"action\" value=\"do_ban\" />
  <input type=\"hidden\" name=\"tid\" value=\"{$id}\" /> <input type=\"hidden\" name=\"type\" value=\"{$ban_type}\" />
   <input type=\"hidden\" name=\"no_modal\" value=\"1\" /> <table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\">
    <tr> <td class=\"thead\" colspan=\"2\"><strong>{$ban_title}</strong> </tr> <tr> <td class=\"tcat\" colspan=\"2\">{$lang->ban_to_mod}</td> </tr>{$ban_reasons}</tr>{$ban_types}</tr>{$ban_whoban}</tr></table> </form>
<script type=\"text/javascript\"> 

$(document).ready(function() {

  if($(\"#ban_reasons option:selected\").val() != 'others')

 { $(\"#reasons\").hide(); }

  $(\"#ban_reasons\").change(function() 

    { if($(this).find(\"option:selected\").val() == 'others')
    
     { $(\"#reasons\").show(); return; } $(\"#reasons\").hide(); 

     });

       if($(\"#types option:selected\").val() != 'thread' && $(\"#types option:selected\").val() != 'forum' && $(\"#types option:selected\").val() != 'all')

 { $(\"#whoban\").hide();
   $(\"#banauthorthread\").hide(); }

  $(\"#types\").change(function() 

    { if($(this).find(\"option:selected\").val() == 'thread')

     { $(\"#whoban\").show(); return;
       $(\"#banauthorthread\").show(); return;
      }

      if ($(this).find(\"option:selected\").val() == 'forum' || $(this).find(\"option:selected\").val() == 'all')

        { $(\"#whoban\").show(); return;
       $(\"#banauthorthread\").hide(); return;
      }

      $(\"#whoban\").hide();
      $(\"#banauthorthread\").hide();

    });
  

  if($(\"#whoban option:selected\").val() != \"choose_user\") 

    { $(\"#banuser\").hide(); }

$(\"#whoban\").change(function()

  { if($(this).find(\"option:selected\").val() == \"choose_user\")

          
       { $(\"#banuser\").show; return; }

       $(\"#banuser\").hide();

   });

         });

  </script> </div> </div>


<script type=\"text/javascript\">
  $(document).ready(function() {
    $('.div1').hide();
    $('.checkbox').click(function(){
      if ($(this).is(\":checked\")) {
        $('.div1').fadeIn(\"slow\");
      } 

      if ($(this).is(\":not(:checked)\")) {
        $('.div1').fadeOut(\"slow\");
      }
    });
  });

</script>

In inc/functions_ban.php and in /ban.php will be set the var $id and $ban_types, $ban_whoban, and $ban_reasons

In normal web site this template became so:



<label><input type="checkbox" class="checkbox" name="ban" value="1">Ban an user</label>

<div class="div1"> <div style="overflow-y: auto; max-height: 700px;" class="modal_">
 <form action="ban.php" method="post" class="banUser_" onsubmit="javascript: return Ban.submitBan();">
  <input type="hidden" name="my_post_key" value="8b6f55ed769714e4dd8dd455a53c979b" /> <input type="hidden" name="action" value="do_ban" />
  <input type="hidden" name="tid" value="" /> <input type="hidden" name="type" value="" />
   <input type="hidden" name="no_modal" value="1" /> <table border="0" cellspacing="" cellpadding="" class="tborder">
    <tr> <td class="thead" colspan="2"><strong></strong> </tr> <tr> <td class="tcat" colspan="2"></td> </tr></tr></tr></tr></table> </form>
<script type="text/javascript"> 

$(document).ready(function() {

  if($("#ban_reasons option:selected").val() != 'others')

 { $("#reasons").hide(); }

  $("#ban_reasons").change(function() 

    { if($(this).find("option:selected").val() == 'others')
    
     { $("#reasons").show(); return; } $("#reasons").hide(); 

     });

       if($("#types option:selected").val() != 'thread' && $("#types option:selected").val() != 'forum' && $("#types option:selected").val() != 'all')

 { $("#whoban").hide();
   $("#banauthorthread").hide(); }

  $("#types").change(function() 

    { if($(this).find("option:selected").val() == 'thread')

     { $("#whoban").show(); return;
       $("#banauthorthread").show(); return;
      }

      if ($(this).find("option:selected").val() == 'forum' || $(this).find("option:selected").val() == 'all')

        { $("#whoban").show(); return;
       $("#banauthorthread").hide(); return;
      }

      $("#whoban").hide();
      $("#banauthorthread").hide();

    });
  

  if($("#whoban option:selected").val() != "choose_user") 

    { $("#banuser").hide(); }

$("#whoban").change(function()

  { if($(this).find("option:selected").val() == "choose_user")

          
       { $("#banuser").show; return; }

       $("#banuser").hide();

   });

         });

  </script> </div> </div>


<script type="text/javascript">
  $(document).ready(function() {
    $('.div1').hide();
    $('.checkbox').click(function(){
      if ($(this).is(":checked")) {
        $('.div1').fadeIn("slow");
      } 

      if ($(this).is(":not(:checked)")) {
        $('.div1').fadeOut("slow");
      }
    });
  });

</script>


var $theme['borderwidth'] and $theme[''] and $id and others variables became ""

Why?

How fix
Have you made sure to declare those variables as globals?
How?

$GLOBALS['var'] ?
Add a backshash before $ and ' in plugin template:

{\$theme[\'borderwidth\']}
{\$theme[\'tablespace\']}
{\$id}
(2015-01-22, 06:02 PM)SvePu Wrote: [ -> ]Add a backshash before $ and ' in plugin template:


{\$theme[\'borderwidth\']}
{\$theme[\'tablespace\']}
{\$id}


Lol why before $ ?
(2015-01-22, 07:15 PM)The_Dark Wrote: [ -> ]Lol why before $ ?

Have you tried? - Didn't work?
There is no PHP syntax case where both $ and ' would need to be escaped..
// Either..
$code = 'Don\'t escape anything besides \' here, so $ and " should stay as they are';
// or..
$code = "\$ (if not a part of an interpolated variable) and \" should be escaped here but no need to touch ' because it's just a regular character'";
// not to mention heredoc where both quote characters are irrelevant
http://php.net/manual/en/language.types.string.php
IMO:
If you insert a template to database without "$db->escape_string(TEMPLATE)" you have to mask $ and ' - with "$db->escape_string(TEMPLATE)" you only have to mask $
(2015-01-22, 07:36 PM)SvePu Wrote: [ -> ]
(2015-01-22, 07:15 PM)The_Dark Wrote: [ -> ]Lol why before $ ?

Have you tried? - Didn't work?



This error > Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 263455867 bytes) in /membri/yugiohspirits/inc/class_error.php on line 224


link > http://yugiohspirits.altervista.org/show...53#pid1753
I've tried it with one of my plugins. When I insert a custon template into db without masking $ then I also have blank quotes in table cellpadding/cellspacing.
Pages: 1 2