Hi guys, I've been lurking around here for a while and I knew this would be my best bet with a problem like this. I am in the process of building my second proxy site, MagicProx.com, and I found a very nice template that I liked, but it need a bit of modding to make it work. So with the moderate experience I have in building websites I decided to give it a shot. I have only run into one problem, when I uploaded it to my host and tried to access it I get this error: "Parse error: syntax error, unexpected T_CASE in /home/content/r/o/s/rosspalmer1/html/index.inc.php on line 204" I see nothing wrong with the code as it is the exact same as the one I have on my other site but maybe I'm missing something. Any help would be greatly appreciated. Here is the code: <?php break; case 'error': echo '<div id="error"><p>'; switch ($data['group']) { case 'url': echo '<b>URL Error (' . $data['error'] . ')</b>: '; switch ($data['type']) { case 'internal': $message = 'Failed to connect to the specified host. ' . 'Possible problems are that the server was not found, the connection timed out, or the connection refused by the host. ' . 'Try connecting again and check if the address is correct.'; break; case 'external': switch ($data['error']) { case 1: $message = 'The URL you\'re attempting to access is blacklisted by this server. Please select another URL.'; break; case 2: $message = 'The URL you entered is malformed. Please check whether you entered the correct URL or not.'; break; } break; } break; case 'resource': echo '<b>Resource Error:</b> '; switch ($data['type']) { case 'file_size': $message = 'The file your are attempting to download is too large.<br />' . 'Maxiumum permissible file size is <b>' . number_format($GLOBALS['_config']['max_file_size']/1048576, 2) . ' MB</b><br />' . 'Requested file size is <b>' . number_format($GLOBALS['_content_length']/1048576, 2) . ' MB</b>'; break; case 'hotlinking': $message = 'It appears that you are trying to access a resource through this proxy from a remote Website.<br />' . 'For security reasons, please use the form below to do so.'; break; } break; } echo 'An error has occured while trying to browse through the proxy. <br />' . $message . '</p></div>'; break; ?> Code (markup): Thanks guys
Without seeing the whole file and knowing where line 204 is, it's hard to say exactly. But the two most common causes of this are: 1) You have closed the brace of a switch() so the case: is not inside it. 2) The statement before the case: is missing a semicolon.
Ok well I searched through the script 3 times and still could find nothing wrong with it. Being pretty much a newbie at PHP I thought I'd post the entire script here to see if someone else can catch my foolish mistake. <?php $proxy_name = "MagicProx"; $adcode1 = ' <script type="text/javascript"><!-- google_ad_client = "pub-**************"; /* 250x250, created 4/7/09 */ google_ad_slot = "*******"; google_ad_width = 250; google_ad_height = 250; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>'; $adcode2 = ' <script type="text/javascript"><!-- google_ad_client = "pub-***************"; /* 250x250, created 4/7/09 */ google_ad_slot = "******"; google_ad_width = 250; google_ad_height = 250; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>'; if (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) { exit(0); } echo '<?xml version="1.0" encoding="utf-8"?>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><?php echo $proxy_name;?> | Home</title> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript"> // <![CDATA[ function toggle(objId, togId) { var o = document.getElementById(objId), t = document.getElementById(togId); if (o.style.display == 'none') { o.style.display = 'block'; t.innerHTML = 'Advanced [<font size=2>-</font>]'; } else { o.style.display = 'none'; t.innerHTML = 'Advanced [+]'; } } // ]]> </script> <style type="text/css"> #marqueecontainer{ position: relative; width: 170px; /*marquee width */ height: 150px; /*marquee height */ background-color: white; overflow: hidden; border: 3px solid #ddd; padding: 2px; } .footer { font-size: 12px; color: #000; } </style> <script type="text/javascript"> var delayb4scroll=1000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds) var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10) var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)? ////NO NEED TO EDIT BELOW THIS LINE//////////// var copyspeed=marqueespeed var pausespeed=(pauseit==0)? copyspeed: 0 var actualheight='' function scrollmarquee(){ if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)) cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px" else cross_marquee.style.top=parseInt(marqueeheight)+8+"px" } function initializemarquee(){ cross_marquee=document.getElementById("vmarquee") cross_marquee.style.top=0 marqueeheight=document.getElementById("marqueecontainer").offsetHeight actualheight=cross_marquee.offsetHeight if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit cross_marquee.style.height=marqueeheight+"px" cross_marquee.style.overflow="scroll" return } setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll) } if (window.addEventListener) window.addEventListener("load", initializemarquee, false) else if (window.attachEvent) window.attachEvent("onload", initializemarquee) else if (document.getElementById) window.onload=initializemarquee </script> </head> <body onload="document.getElementById('address_box').focus()"> <div id="wrapper"> <div id="header"><a href="http://www.betaprox.com"><span class="left"></span></a> </div> <div id="menu"> <ul> <li><a href="http://www.magicprox.com">Home</a></li> <li><a href="http://magicprox.com/index.php?q=aHR0cDovL3d3dy5mYWNlYm9vay5jb20v">Facebook</a></li> <li><a href="http://magicprox.com/index.php?q=aHR0cDovL3d3dy5teXNwYWNlLmNvbS8%3D">Myspace</a></li> <li><a href="http://magicprox.com/index.php?q=aHR0cDovL3d3dy55b3V0dWJlLmNvbS8%3D">Youtube</a></li> <li><a href="http://magicprox.com/index.php?q=aHR0cDovL3R3aXR0ZXIuY29tLw%3D%3D">Twitter</a></li> <li><a href="http://magicprox.com/index.php?q=aHR0cDovL3d3dy5nb29nbGUuY29tLw%3D%3D">Google</a></li> <li><a href="http://magicprox.com/index.php?q=aHR0cDovL3d3dy5iZWJvLmNvbS9jL3NpdGUvaW5kZXg%3D">Bebo</a></li> <li><a href="http://magicprox.com/index.php?q=d3d3LmViYXkuY29t&hl=3ed">eBay</a></li> </ul> </div> <div id="sidebar"> <div id="feed"> <a class="feed-button" href="#"> </a> </div> <br /> <p style="width:100%;padding-left:5px;"><b>Sponsors</b></p> <ul> <li></li> <li></li> <li></li> <li></li> <li><a href="#"><?php echo $adcode3;?></a></li> </ul> <br /> <p style="width:100%;padding-left:5px;"> </p> <div id="sidebar-bottom"> </div> </div> <div id="content" style="padding:5px;"> <h2>Welcome to MagicProx.com!</h2> </p> <p>We allow you to browse your favorite sites like Facebook, Myspace, YouTube etc at school or work for absolutely nothing! Enjoy surfing anonymously!<br /> </p> <p> <div id="auth"><p> <b>Enter your username and password for "<?php echo htmlspecialchars($data['realm']) ?>" on <?php echo $GLOBALS['_url_parts']['host'] ?></b> <form method="post" action=""> <input type="hidden" name="<?php echo $GLOBALS['_config']['basic_auth_var_name'] ?>" value="<?php echo base64_encode($data['realm']) ?>" /> <label>Username <input type="text" name="username" value="" /></label> <label>Password <input type="password" name="password" value="" /></label> <input type="submit" value="Login" /> </form></p></div> <?php break; case 'error': echo '<div id="error"><p>'; switch ($data['group']) { case 'url': echo '<b>URL Error (' . $data['error'] . ')</b>: '; switch ($data['type']) { case 'internal': $message = 'Failed to connect to the specified host. ' . 'Possible problems are that the server was not found, the connection timed out, or the connection refused by the host. ' . 'Try connecting again and check if the address is correct.'; break; case 'external': switch ($data['error']) { case 1: $message = 'The URL you\'re attempting to access is blacklisted by this server. Please select another URL.'; break; case 2: $message = 'The URL you entered is malformed. Please check whether you entered the correct URL or not.'; break; } break; } break; case 'resource': echo '<b>Resource Error:</b> '; switch ($data['type']) { case 'file_size': $message = 'The file your are attempting to download is too large.<br />' . 'Maxiumum permissible file size is <b>' . number_format($GLOBALS['_config']['max_file_size']/1048576, 2) . ' MB</b><br />' . 'Requested file size is <b>' . number_format($GLOBALS['_content_length']/1048576, 2) . ' MB</b>'; break; case 'hotlinking': $message = 'It appears that you are trying to access a resource through this proxy from a remote Website.<br />' . 'For security reasons, please use the form below to do so.'; break; } break; } echo 'An error has occured while trying to browse through the proxy. <br />' . $message . '</p></div>'; break; ?> <div style="width:100%;"> <div style="width:49%;float:left;text-align:center;"> <?php echo $adcode1; ?> </div> <div style="width:49%;float:left;text-align:center;"> <?php echo $adcode2; ?> </div> </div> <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> Web Address <input id="address_box" style="width:300px;" type="text" name="<?php echo $GLOBALS['_config']['url_var_name'] ?>" value="<?php echo isset($GLOBALS['_url']) ? htmlspecialchars($GLOBALS['_url']) : '' ?>" onfocus="this.select()" /></label> <input id="go" type="submit" value="Go" /> <span id="options-toggle" class="toggle" onclick="toggle('more_options', 'options-toggle')">Advanced [+]</span><br /> <ul id="more_options" style="display:none;list-style: none;text-align:center;"> <?php foreach ($GLOBALS['_flags'] as $flag_name => $flag_value) { if (!$GLOBALS['_frozen_flags'][$flag_name]) { echo '<li class="option"><label><input type="checkbox" name="' . $GLOBALS['_config']['flags_var_name'] . '[' . $flag_name . ']"' . ($flag_value ? ' checked="checked"' : '') . ' />' . $GLOBALS['_labels'][$flag_name][1] . '</label></li>' . "\n"; } } ?> </ul> </form> </p> </div> <div id="footer"> <div id="footer-valid"> <p>© <?php echo $proxy_name;?> 2009 - <a href="http://whitefyre.com/poxy/">Designed by: </a><a href="http://freeproxysite.com">FreeProxySite -</a><a href="http://whitefyre.com/poxy/"> Powered by: PHProxy</a> - <?php echo date("F j, Y");?><br /> <span class="footer">P<a href="http://proxy.org/">roxy.org</a></span> <span class="footer">| <a href="http://www.addme.com/submission/free-submission-start.php">AddMe.com</a></span></p> </div> </div> </div> </body> </html> Code (markup): Thanks so much in advance guys
Your PHP seems to start in like this: <?php break; case 'error': echo '<div id="error"><p>'; Code (markup): That "case 'error'" is outside of any switch(). That won't work.
To be completely honest I really don't know what it is. It's just a standard Phproxy script, I've used the exact same one on my other site which works perfectly. Sorry for my lack of knowledge.
I actually managed to fix it by adding this peice of code right above the form <?php switch ($data['category']) { case 'auth': ?> Code (markup): But now I'm getting a different error on the last line of the script: " Parse error: syntax error, unexpected $end in /home/content/r/o/s/rosspalmer1/html/index.inc.php on line 307", which is the </html> tag.
the technical answer is that you are probably not closing the statement with a closing bracket } but are you sure that the code you added is in the correct position?
Yep the site is up and running now, working perfectly. All I did was open up a newly downloaded version of Phproxy script and copy and paste the entire form script. Worked like a charm