Jump to content

I suck


shage

Recommended Posts

I have learned alot so far today but every time i try to fix this code i get another error somewhere else

 

function showtemplatebar( )
{
    $what = $_REQUEST['what'];
    $r = fngetarray( );
    if ( strlen( $what ) )
    {
        $id = $_REQUEST['id'];
        $id = trim( $id );
        $idname = $_REQUEST['name'];
        $idname = trim( $idname );
        $idname = str_replace( " ", "-", $idname );
        $name = $_REQUEST['name'];
        $name = trim( $name );
        $catdesc = $_REQUEST['catdesc'];
        $catdesc = trim( $name );
    switch ($what) {
        case 'addnew_show':
    echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n               <html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n                  <title>Creating new template</title>\r\n                  <head>\r\n                     <script type=\"text/JavaScript\">\r\n                     <!--\r\n                        function   myAddElement(sname) {\r\n                              var obj = window.opener.parent.document.getElementById(sname);\r\n                              if (obj) {\r\n                                 var n  = document.createElement('input');\r\n                                 n.setAttribute('name',  sname);\r\n                                 n.setAttribute('type',  'hidden');\r\n                                 if (obj.type == 'checkbox') {\r\n                                    if (obj.checked) {\r\n                                       n.setAttribute('value', '1');\r\n                                    } else {\r\n                                       n.setAttribute('value', '0');\r\n                                    }\r\n                                 } else {\r\n                                    n.setAttribute('value', obj.value);\r\n                                 }\r\n\r\n                                 var myform = document.getElementById(\"myform\");\r\n                                 myform.appendChild(n);\r\n                              }\r\n                        }\r\n                        function  myonload() {\r\n";
        foreach ( $r[0] as $key=>$value )
        {
            echo "                              myAddElement('";
            echo $key;
            echo "');\r\n                           ";
        }
        echo "                        }\r\n                     //-->\r\n                     </script>\r\n                  </head>\r\n                  <body onload=\"myonload()\">\r\n                    <center>\r\n                     <form action=core.php?uuaction=ShowTemplateBar&what=addnew method=post id=myform name=myform>\r\n                        You current text and settings will be saved as a template.<br>Enter a name for the new template:\r\n                        <input type=text name=tname value=\"\"><br>\r\n                        <input type=submit value=Save>\r\n                     </form>\r\n                     </center>\r\n                  </body>\r\n               </html>\r\n               ";
    case'addnew':
        $tempr['templatename'] = $_REQUEST['tname'];
        if ( get_magic_quotes_gpc( ) )
        {
            $tempr['templatename'] = stripslashes( get_magic_quotes_gpc( ) );
        }
        foreach ( $r[0] as $key=>$value )
        {
            if ( isset( $Var_4 ) )
            {
                $tempr[$key] = $_REQUEST[$key];
                if ( get_magic_quotes_gpc( ) )
                {
                    $tempr[$key] = stripslashes( get_magic_quotes_gpc( ) );
                }
            }
        }
        $_REQUEST[$r] = $tempr;
        fnsavearray( $r );
        echo "               <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n               <html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n                  <title>Creating new template</title>\r\n                  <script type=\"text/JavaScript\">\r\n                     <!--\r\n                     window.opener.location.reload();\r\n                     //-->\r\n                  </script>\r\n                  <body>\r\n                     <center>\r\n                     Your template has been saved. <br>\r\n                     <input type=button value=OK onclick=\"self.close()\">\r\n                     </center>\r\n                  </body>\r\n               </html>\r\n\r\n               ";
    case 'save_show':
        echo "               <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n               <html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n               <head>\r\n                     <script type=\"text/JavaScript\">\r\n                     <!--\r\n                        function   myAddElement(sname) {\r\n                              var obj = window.opener.parent.document.getElementById(sname);\r\n                              if (obj) {\r\n                                 var n  = document.createElement('input');\r\n                                 n.setAttribute('name',  sname);\r\n                                 n.setAttribute('type',  'hidden');\r\n                                 if (obj.type == 'checkbox') {\r\n                                    if (obj.checked) {\r\n                                       n.setAttribute('value', '1');\r\n                                    } else {\r\n                                       n.setAttribute('value', '0');\r\n                                    }\r\n                                 } else {\r\n                                    n.setAttribute('value', obj.value);\r\n                                 }\r\n\r\n                                 var myform = document.getElementById(\"myform\");\r\n                                 myform.appendChild(n);\r\n                              }\r\n                        }\r\n                        function  myonload() {\r\n                           ";
        foreach ( $r[0] as $key=>$value )
        {
            echo "                              myAddElement('";
            echo $key;
            echo "');\r\n                           ";
        }
        echo "                        }\r\n                     //-->\r\n                     </script>\r\n               </head>\r\n               <body onload=\"myonload()\">\r\n                  <center>\r\n\r\n\r\n                     <form action=\"core.php\" method=post id=myform name=myform>\r\n\r\n                     <input type=hidden name=uuaction value=ShowTemplateBar>\r\n                     <input type=hidden name=what value=save>\r\n                     <input type=hidden name=id value=";
        echo $_REQUEST['id'];
        echo ">\r\n                     Do you want to save current template and settings to<br> '";
        echo $r[$_REQUEST['id']]['templatename'];
        echo "'?<br><br>\r\n                     <input type=\"submit\" value=\"Yes\">\r\n                     <input type=button onclick=\"self.close()\" value=\"No\"><br>\r\n\r\n                     </form>\r\n                  </center>\r\n\r\n\r\n               </body>\r\n               </html>\r\n\r\n               ";
    case 'save' :
        $tempr['templatename'] = $r[$_REQUEST['id']]['templatename'];
        foreach ( $r[0] as $key=>$value )
        {
            if ( isset( $_REQUEST ) )
            {
                $tempr[$key] = $_REQUEST[$key];
                if ( get_magic_quotes_gpc( ) )
                {
                    $tempr[$key] = stripslashes( get_magic_quotes_gpc( ) );
                }
            }
        }
        $r[$_REQUEST['id']] = $tempr;
        fnsavearray( $r );
        $r = fngetarray( );
        echo "               <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n               <html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head>\r\n               <script type=\"text/JavaScript\">\r\n               <!--\r\n               //self.close();\r\n               window.opener.location.reload();\r\n               //-->\r\n               </script>\r\n               <body>\r\n                  <center>\r\n                  Your template has been saved.<br><br>\r\n                  <input type=button value=OK onclick=\"self.close()\">\r\n                  </center>\r\n               </body>\r\n               </html>\r\n\r\n               ";
    case 'delete':
        fnsavearray($r);
        header( "Location: core.php?uuaction=ShowTemplateBar" );
    }
    else
    {
    default :
        echo "\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\r\n<title>Template Manager</title>\r\n\r\n<script type=\"text/JavaScript\">\r\n<!--\r\nvar TempArr=new Array();\r\n";
        foreach ( $r as $key=>$value )
        {
            echo "TempArr[".$key."] = new Array();\n";
            foreach ( $r[$key] as $key2=>$value2 )
            {
                $res = "";
                $i = 0;
                for ( ; $i < strlen( $value2 ); ++$i )
                {
                    if ( 0 < $i )
                    {
                        $res .= ", ";
                    }
                    $res .= ord( substr( $value2, $i, 1 ) );
                }
                echo "TempArr[".$key."]['$key2'] = String.fromCharCode($res);\n";
            }
        }
        echo "\r\nfunction fninsert(vv) {\r\n   var MySection = new Array();\r\n   MySection = parent.document.post.content.value = TempArr[vv.options[vv.selectedIndex].value];\r\n\r\n   for (key in MySection) {\r\n      var obj = parent.document.getElementById(key);\r\n      if (obj) {\r\n         if (obj.type == 'checkbox') {\r\n            if (MySection[key] == '1') {\r\n             obj.checked = true;\r\n            } else {\r\n             obj.checked = false;\r\n            }\r\n         } else {                         // text type\r\n            obj.value = MySection[key];\r\n            if (obj.type == 'select-one') {    obj.onchange();     }\r\n         }\r\n\r\n      }\r\n   }\r\n}\r\nfunction fnaddnew() {\r\n   window.open(\"core.php?uuaction=ShowTemplateBar&what=addnew_show\",\"mywindow\",\"location=0,status=0,scrollbars=1,width=300,height=150\");\r\n}\r\nfunction fnsave(vv) {\r\n//   if (confirm(\"Are you sure you want to save current template to '\"+vv.options[vv.selectedIndex].text+\"'?\")) {\r\n      window.open(\"core.php?uuaction=ShowTemplateBar&what=save_show&id=\"+vv.options[vv.selectedIndex].value,\"mywindow\",\"location=0,status=0,scrollbars=1,width=300,height=150\");\r\n//   }\r\n}\r\n\r\nfunction fndelete(vv) {\r\n   if (vv.options[vv.selectedIndex].value <= 3 ) {      alert(\"Sorry, '\"+vv.options[vv.selectedIndex].text+\"' option cannot be deleted as you can lost this template and feel sad\");return;}\r\n\r\n   if (confirm(\"Are you sure you want delete '\"+vv.options[vv.selectedIndex].text+\"'?\")) {\r\n      self.location.href = \"core.php?uuaction=ShowTemplateBar&what=delete&id=\"+vv.options[vv.selectedIndex].value;\r\n   }\r\n\r\n}\r\n\r\n\r\n//-->\r\n</script>\r\n</head>\r\n\r\n<body leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" marginheight=\"0\" >\r\n\r\n<div>\r\n<form name=\"form1\" id=\"form1\">\r\n  <select name=\"menu1\">\r\n";
        foreach ( $r as $key=>$value )
        {
            echo "<option value=".$key.">$value['templatename']</option>"";
        }
        echo "\r\n  </select>\r\n  <input type=\"button\" name=\"insert\" value=\"Insert\" onclick=\"fninsert(menu1)\">\r\n   \r\n  <input type=\"button\" name=\"create\" value=\"New\"    onclick=\"fnaddnew()\">\r\n  <input type=\"button\" name=\"save\"   value=\"Save\"   onclick=\"fnsave(menu1)\">\r\n  <input type=\"button\" name=\"delete\" value=\"Delete\" onclick=\"fndelete(menu1)\">\r\n</form>\r\n</div>\r\n</body>\r\n</html>\r\n";
    }
}

Link to comment
https://forums.phpfreaks.com/topic/54465-i-suck/
Share on other sites

ill highlite it

 

function showtemplatebar( )
{
    $what = $_REQUEST['what'];
    $r = fngetarray( );
    if ( strlen( $what ) )
    {
        $id = $_REQUEST['id'];
        $id = trim( $id );
        $idname = $_REQUEST['name'];
        $idname = trim( $idname );
        $idname = str_replace( " ", "-", $idname );
        $name = $_REQUEST['name'];
        $name = trim( $name );
        $catdesc = $_REQUEST['catdesc'];
        $catdesc = trim( $name );
    switch ($what) {
        case 'addnew_show':
    echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n               <html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n                  <title>Creating new template</title>\r\n                  <head>\r\n                     <script type=\"text/JavaScript\">\r\n                     <!--\r\n                        function   myAddElement(sname) {\r\n                              var obj = window.opener.parent.document.getElementById(sname);\r\n                              if (obj) {\r\n                                 var n  = document.createElement('input');\r\n                                 n.setAttribute('name',  sname);\r\n                                 n.setAttribute('type',  'hidden');\r\n                                 if (obj.type == 'checkbox') {\r\n                                    if (obj.checked) {\r\n                                       n.setAttribute('value', '1');\r\n                                    } else {\r\n                                       n.setAttribute('value', '0');\r\n                                    }\r\n                                 } else {\r\n                                    n.setAttribute('value', obj.value);\r\n                                 }\r\n\r\n                                 var myform = document.getElementById(\"myform\");\r\n                                 myform.appendChild(n);\r\n                              }\r\n                        }\r\n                        function  myonload() {\r\n";
        foreach ( $r[0] as $key=>$value )
        {
            echo "                              myAddElement('";
            echo $key;
            echo "');\r\n                           ";
        }
        echo "                        }\r\n                     //-->\r\n                     </script>\r\n                  </head>\r\n                  <body onload=\"myonload()\">\r\n                    <center>\r\n                     <form action=core.php?uuaction=ShowTemplateBar&what=addnew method=post id=myform name=myform>\r\n                        You current text and settings will be saved as a template.<br>Enter a name for the new template:\r\n                        <input type=text name=tname value=\"\"><br>\r\n                        <input type=submit value=Save>\r\n                     </form>\r\n                     </center>\r\n                  </body>\r\n               </html>\r\n               ";
    case'addnew':
        $tempr['templatename'] = $_REQUEST['tname'];
        if ( get_magic_quotes_gpc( ) )
        {
            $tempr['templatename'] = stripslashes( get_magic_quotes_gpc( ) );
        }
        foreach ( $r[0] as $key=>$value )
        {
            if ( isset( $Var_4 ) )
            {
                $tempr[$key] = $_REQUEST[$key];
                if ( get_magic_quotes_gpc( ) )
                {
                    $tempr[$key] = stripslashes( get_magic_quotes_gpc( ) );
                }
            }
        }
        $_REQUEST[$r] = $tempr;
        fnsavearray( $r );
        echo "               <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n               <html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n                  <title>Creating new template</title>\r\n                  <script type=\"text/JavaScript\">\r\n                     <!--\r\n                     window.opener.location.reload();\r\n                     //-->\r\n                  </script>\r\n                  <body>\r\n                     <center>\r\n                     Your template has been saved. <br>\r\n                     <input type=button value=OK onclick=\"self.close()\">\r\n                     </center>\r\n                  </body>\r\n               </html>\r\n\r\n               ";
    case 'save_show':
        echo "               <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n               <html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n               <head>\r\n                     <script type=\"text/JavaScript\">\r\n                     <!--\r\n                        function   myAddElement(sname) {\r\n                              var obj = window.opener.parent.document.getElementById(sname);\r\n                              if (obj) {\r\n                                 var n  = document.createElement('input');\r\n                                 n.setAttribute('name',  sname);\r\n                                 n.setAttribute('type',  'hidden');\r\n                                 if (obj.type == 'checkbox') {\r\n                                    if (obj.checked) {\r\n                                       n.setAttribute('value', '1');\r\n                                    } else {\r\n                                       n.setAttribute('value', '0');\r\n                                    }\r\n                                 } else {\r\n                                    n.setAttribute('value', obj.value);\r\n                                 }\r\n\r\n                                 var myform = document.getElementById(\"myform\");\r\n                                 myform.appendChild(n);\r\n                              }\r\n                        }\r\n                        function  myonload() {\r\n                           ";
        foreach ( $r[0] as $key=>$value )
        {
            echo "                              myAddElement('";
            echo $key;
            echo "');\r\n                           ";
        }
        echo "                        }\r\n                     //-->\r\n                     </script>\r\n               </head>\r\n               <body onload=\"myonload()\">\r\n                  <center>\r\n\r\n\r\n                     <form action=\"core.php\" method=post id=myform name=myform>\r\n\r\n                     <input type=hidden name=uuaction value=ShowTemplateBar>\r\n                     <input type=hidden name=what value=save>\r\n                     <input type=hidden name=id value=";
        echo $_REQUEST['id'];
        echo ">\r\n                     Do you want to save current template and settings to<br> '";
        echo $r[$_REQUEST['id']]['templatename'];
        echo "'?<br><br>\r\n                     <input type=\"submit\" value=\"Yes\">\r\n                     <input type=button onclick=\"self.close()\" value=\"No\"><br>\r\n\r\n                     </form>\r\n                  </center>\r\n\r\n\r\n               </body>\r\n               </html>\r\n\r\n               ";
    case 'save' :
        $tempr['templatename'] = $r[$_REQUEST['id']]['templatename'];
        foreach ( $r[0] as $key=>$value )
        {
            if ( isset( $_REQUEST ) )
            {
                $tempr[$key] = $_REQUEST[$key];
                if ( get_magic_quotes_gpc( ) )
                {
                    $tempr[$key] = stripslashes( get_magic_quotes_gpc( ) );
                }
            }
        }
        $r[$_REQUEST['id']] = $tempr;
        fnsavearray( $r );
        $r = fngetarray( );
        echo "               <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n               <html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head>\r\n               <script type=\"text/JavaScript\">\r\n               <!--\r\n               //self.close();\r\n               window.opener.location.reload();\r\n               //-->\r\n               </script>\r\n               <body>\r\n                  <center>\r\n                  Your template has been saved.<br><br>\r\n                  <input type=button value=OK onclick=\"self.close()\">\r\n                  </center>\r\n               </body>\r\n               </html>\r\n\r\n               ";
    case 'delete':
        fnsavearray($r);
        header( "Location: core.php?uuaction=ShowTemplateBar" );
    }
   [b] else[/b]
    {
    default :
        echo "\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />\r\n<title>Template Manager</title>\r\n\r\n<script type=\"text/JavaScript\">\r\n<!--\r\nvar TempArr=new Array();\r\n";
        foreach ( $r as $key=>$value )
        {
            echo "TempArr[".$key."] = new Array();\n";
            foreach ( $r[$key] as $key2=>$value2 )
            {
                $res = "";
                $i = 0;
                for ( ; $i < strlen( $value2 ); ++$i )
                {
                    if ( 0 < $i )
                    {
                        $res .= ", ";
                    }
                    $res .= ord( substr( $value2, $i, 1 ) );
                }
                echo "TempArr[".$key."]['$key2'] = String.fromCharCode($res);\n";
            }
        }
        echo "\r\nfunction fninsert(vv) {\r\n   var MySection = new Array();\r\n   MySection = parent.document.post.content.value = TempArr[vv.options[vv.selectedIndex].value];\r\n\r\n   for (key in MySection) {\r\n      var obj = parent.document.getElementById(key);\r\n      if (obj) {\r\n         if (obj.type == 'checkbox') {\r\n            if (MySection[key] == '1') {\r\n             obj.checked = true;\r\n            } else {\r\n             obj.checked = false;\r\n            }\r\n         } else {                         // text type\r\n            obj.value = MySection[key];\r\n            if (obj.type == 'select-one') {    obj.onchange();     }\r\n         }\r\n\r\n      }\r\n   }\r\n}\r\nfunction fnaddnew() {\r\n   window.open(\"core.php?uuaction=ShowTemplateBar&what=addnew_show\",\"mywindow\",\"location=0,status=0,scrollbars=1,width=300,height=150\");\r\n}\r\nfunction fnsave(vv) {\r\n//   if (confirm(\"Are you sure you want to save current template to '\"+vv.options[vv.selectedIndex].text+\"'?\")) {\r\n      window.open(\"core.php?uuaction=ShowTemplateBar&what=save_show&id=\"+vv.options[vv.selectedIndex].value,\"mywindow\",\"location=0,status=0,scrollbars=1,width=300,height=150\");\r\n//   }\r\n}\r\n\r\nfunction fndelete(vv) {\r\n   if (vv.options[vv.selectedIndex].value <= 3 ) {      alert(\"Sorry, '\"+vv.options[vv.selectedIndex].text+\"' option cannot be deleted as you can lost this template and feel sad\");return;}\r\n\r\n   if (confirm(\"Are you sure you want delete '\"+vv.options[vv.selectedIndex].text+\"'?\")) {\r\n      self.location.href = \"core.php?uuaction=ShowTemplateBar&what=delete&id=\"+vv.options[vv.selectedIndex].value;\r\n   }\r\n\r\n}\r\n\r\n\r\n//-->\r\n</script>\r\n</head>\r\n\r\n<body leftmargin=\"0\" topmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\" marginwidth=\"0\" marginheight=\"0\" >\r\n\r\n<div>\r\n<form name=\"form1\" id=\"form1\">\r\n  <select name=\"menu1\">\r\n";
        foreach ( $r as $key=>$value )
        {
            echo "<option value=".$key.">$value['templatename']</option>"
}
        echo " \r\n  </select>\r\n  <input type=\"button\" name=\"insert\" value=\"Insert\" onclick=\"fninsert(menu1)\">\r\n   \r\n  <input type=\"button\" name=\"create\" value=\"New\"    onclick=\"fnaddnew()\">\r\n  <input type=\"button\" name=\"save\"   value=\"Save\"   onclick=\"fnsave(menu1)\">\r\n  <input type=\"button\" name=\"delete\" value=\"Delete\" onclick=\"fndelete(menu1)\">\r\n</form>\r\n</div>\r\n</body>\r\n</html>\r\n"";
    }
}

Link to comment
https://forums.phpfreaks.com/topic/54465-i-suck/#findComment-269380
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.