By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,645 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,645 IT Pros & Developers. It's quick & easy.

Parse error: syntax error, unexpected $end

akohistani
P: 4
I am having Parse error problem with my newly purchased Php upload script I have uploaded the script and I get the error below

Parse error: syntax error, unexpected $end in URL/functions.php on line 400

Someone please help me I contacted the owner of the script where I purchased he is not replying me I bought it from http://www.scubadivingcalculators.com/

and this is the url where I have uploaded the script http://www.afghan123.com/music/upload

Here is the functions.php source cod:
Expand|Select|Wrap|Line Numbers
  1. <?
  2.  
  3. function print_configure_page()
  4. {
  5.   global $mess, $font, $normalfontcolor, $selectedfontcolor, $homeurl, $languages;
  6.   global $uploadcentercaption,$logged_user_name,$mailfunctionsenabled;
  7.   global $tablecolor,$bordercolor,$headercolor,$headerfontcolor;
  8.   global $mailinfopage;
  9.  
  10.  
  11. echo "<p>&nbsp;</p>
  12.    <table border=\"0\" width=\"85%\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\">
  13.      <tr>
  14.        <th align=\"left\" bgcolor=\"$headercolor\" valign=\"middle\"><font size=\"2\" face=\"$font\" color=\"$headerfontcolor\">$mess[165]:</font></th>
  15.      </tr>";
  16.  
  17.  
  18.   $handle=opendir("include");
  19.   while ($filename = readdir($handle))
  20.   {
  21. //    if(eregi("\.txt$|\.htm$|\.html$|\.php$",$filename))
  22.     if(eregi("\.txt$|\.htm$|\.html$",$filename))
  23.     {
  24.       if (!is_dir("include/$filename"))
  25.       {
  26. echo"
  27.     <tr>
  28.       <td align=\"left\" bgColor=\"$tablecolor\"><font size=\"1\" face=\"$font\" color=\"$normalfontcolor\"><a href=\"configure.php?action=editfile&filename=$filename\">$filename</a></font></td>
  29.     </tr>";
  30.       }
  31.     }
  32.   }
  33.   closedir($handle);
  34.  
  35.  
  36. echo"</table>";
  37.  
  38. }
  39.  
  40. function show_file_editor($filename)
  41. {
  42.   global $mess, $font, $normalfontcolor, $selectedfontcolor, $languages;
  43.   global $tablecolor,$bordercolor,$headercolor,$headerfontcolor;
  44.  
  45.   if (!file_exists("include/$filename"))
  46.     return;
  47.  
  48.   $max_caracters = filesize("include/$filename");
  49.   $fp=@fopen("include/$filename","r");
  50.   $filebody = fread($fp, $max_caracters);
  51.   fclose($fp);
  52.  
  53. echo "<p>&nbsp;</p>
  54.   <table border=\"0\" width=\"85%\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\">
  55.     <tr>
  56.       <th align=\"left\" bgcolor=\"$headercolor\" valign=\"middle\"><font size=\"2\" face=\"$font\" color=\"$headerfontcolor\">$mess[166]:</font></th>
  57.     </tr>
  58.     <tr>
  59.       <td align=\"left\" bgColor=\"$tablecolor\">
  60.         <form name=\"editfile\" action=\"configure.php\" enctype=\"multipart/form-data\" method=\"post\" style=\"margin: 0\">
  61.           <input type=\"hidden\" name=\"action\" value=\"savefile\">
  62.           <input type=\"hidden\" name=\"filename\" value=\"$filename\">
  63.           <textarea name=\"filebody\" cols=\"82\" rows=\"20\">$filebody</textarea>
  64.           <input type=\"submit\" value=\"$mess[168]\">
  65.         </form>
  66.       </td>
  67.     </tr>
  68.   </table>";
  69. }
  70.  
  71. function show_default($message)
  72. {
  73.   global $logged_user_name, $mess;
  74.  
  75.   if ($logged_user_name != "")
  76.   {
  77.     if (check_is_user_session_active($logged_user_name))
  78.     {
  79.       // If user already entered, show logout screen
  80.       if ($message == "")
  81.         $message = $mess[164];
  82.       place_message($mess[164], $logged_user_name.": ".$message, "<a href=\"login.php?action=logout\">".$mess[72]."</a> <a href=\"index.php\">".$mess[133]."</a>");
  83.       show_menu(1, 'configure.php');
  84.       print_configure_page();
  85.       return;
  86.     }
  87.   }
  88.   // Show default window
  89.   if ($message == "")
  90.     $message = $mess[42];
  91.   place_message($mess[164], $message, "<a href=\"login.php\">".$mess[71]."</a> <a href=\"index.php\">".$mess[133]."</a>");
  92.   show_menu(0, 'configure.php');
  93. }
  94.  
  95. //----------------------------------------------------------------------------
  96. //      MAIN
  97. //----------------------------------------------------------------------------
  98.  
  99. header("Expires: Mon, 03 Jan 2000 00:00:00 GMT");
  100. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  101. header("Cache-Control: no-cache, must-revalidate");
  102. header("Pragma: no-cache");
  103.  
  104. include("include/conf.php");
  105. include("functions.php");
  106. if (!isset($action))
  107.   $action = "";
  108. if (!isset($filename))
  109.   $filename = "";
  110. if (!isset($language))
  111.   $language=$dft_language;
  112. if ($language=="")
  113.   $language=$dft_language;
  114. require("include/${language}.php");
  115. if (!isset($skinindex))
  116.   $skinindex = 0;
  117. if ($skinindex > count($skins))
  118.   $skinindex = 0;
  119. $bordercolor=$skins[$skinindex]["bordercolor"];
  120. $headercolor = $skins[$skinindex]["headercolor"];
  121. $tablecolor=$skins[$skinindex]["tablecolor"];
  122. $lightcolor=$skins[$skinindex]["lightcolor"];
  123. $headerfontcolor=$skins[$skinindex]["headerfontcolor"];
  124. $normalfontcolor=$skins[$skinindex]["normalfontcolor"];
  125. $selectedfontcolor=$skins[$skinindex]["selectedfontcolor"];
  126.  
  127. if (!isset($logged_user_name))
  128.   $logged_user_name = "";
  129.  
  130. switch($action)
  131. {
  132.  
  133. case "savelanguage";
  134.   change_language();
  135.   require("include/${language}.php");
  136.   page_header($page_title);
  137.   show_default($mess[41]);
  138. break;
  139.  
  140.  
  141. case "selectskin";
  142.   change_skin();
  143.   require("include/${language}.php");
  144.   page_header($page_title);
  145.   show_default($mess[96]);
  146. break;
  147.  
  148.  
  149. case "editfile";
  150.   if ($logged_user_name != "")
  151.   {
  152.     if (check_is_user_session_active($logged_user_name))
  153.     {
  154.       require("include/${language}.php");
  155.       page_header($page_title);
  156.       place_message($mess[164], $logged_user_name.": ".$mess[166], "<a href=\"login.php?action=logout\">".$mess[72]."</a> <a href=\"index.php\">".$mess[133]."</a>");
  157.       show_menu(1, 'configure.php');
  158.       show_file_editor($filename);
  159.     }
  160.   }
  161. break;
  162.  
  163. case "savefile";
  164.   if ($logged_user_name != "")
  165.   {
  166.     if (check_is_user_session_active($logged_user_name))
  167.     {
  168.       require("include/${language}.php");
  169.       page_header($page_title);
  170.       if (!isset($filebody))
  171.         break;
  172.       $filebody = stripslashes($filebody);
  173.       $fp=@fopen("include/$filename","w+");
  174.       fwrite($fp, $filebody);
  175.       fclose($fp);
  176.       show_default(sprintf($mess[167], $filename));
  177.     }
  178.   }
  179. break;
  180.  
  181. //----------------------------------------------------------------------------
  182. //      DEFAULT
  183. //----------------------------------------------------------------------------
  184.  
  185.  
  186. default;
  187.   require("include/${language}.php");
  188.   page_header($page_title);
  189.   show_default("");
  190.   break;
  191. }
  192.  
  193.  
  194. include($footerpage);
  195. ?>
  196.  
Jul 17 '08 #1
Share this Question
Share on Google+
9 Replies


Atli
Expert 5K+
P: 5,058
Hi. Welcome to Bytes!

I'm not entirely sure you've posted the correct code.
The error states that there is a problem on line 400, which doesn't exists.
Not to mention that on line 105 you actually include the "functions.php" file :)

And please post you code inside [code] tags in the future.
Thanks.
Jul 17 '08 #2

hsriat
Expert 100+
P: 1,654
Rework on your {curly braces}, your problem would be solved.
Jul 17 '08 #3

akohistani
P: 4
Your are right that was a different file here is the functions.php file source code

Expand|Select|Wrap|Line Numbers
  1. <?
  2.  
  3. function page_header($title)
  4. {
  5.   global $charsetencoding,$skins,$skinindex,$headerpage;
  6.  
  7.   $bodytag = $skins[$skinindex]["bodytag"];
  8.   echo "<html><head><title>$title</title>";
  9.   if ($charsetencoding != "")
  10.     echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=$charsetencoding\">";
  11.   echo "<style type=\"text/css\"></style></head><body $bodytag>";
  12.   if (file_exists($headerpage))
  13.     include($headerpage);        // Include user portion of page
  14. }
  15.  
  16. function place_message($welcomestring, $message, $link)
  17. {
  18. global $mess, $font, $normalfontcolor, $selectedfontcolor, $homeurl, $languages;
  19. global $uploadcentercaption,$show_configuration_menu,$allow_choose_language;
  20. global $tablecolor,$bordercolor,$headercolor,$headerfontcolor;
  21.  
  22. echo "
  23. <div align=\"center\">
  24.   <table border=\"0\" width=\"85%\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\">
  25.     <tr>
  26.       <td align=\"left\" bgcolor=\"$headercolor\" colspan=\"4\">
  27.         <table border=\"0\" width=\"100%\">
  28.           <tr>
  29.             <th align=\"left\" bgcolor=\"$headercolor\" valign=\"middle\" width=\"50%\">
  30.               <h1><font color=\"$headerfontcolor\" size=\"5\"><b>$uploadcentercaption</b></font></h1>
  31.             </th>
  32.             <td align=\"right\" bgcolor=\"$headercolor\" valign=\"middle\" width=\"50%\" nowrap>
  33.               <p><font face=\"$font\" size=\"1\" color=\"$headerfontcolor\">$welcomestring</font></p>
  34.             </td>
  35.           </tr>
  36.         </table>
  37.       </td>
  38.     </tr>";
  39.  
  40. if ($message != "")
  41. {
  42. echo "<tr>
  43.       <td align=\"left\" bgcolor=\"$tablecolor\" valign=\"middle\">
  44.         <table border=\"0\" width=\"100%\">
  45.           <tr>
  46.             <th align=\"left\" valign=\"middle\" width=\"60%\">
  47.               <font size=\"1\" face=\"$font\" color=\"$selectedfontcolor\">&raquo;</font>
  48.  
  49.               <font size=\"1\" face=\"$font\" color=\"$normalfontcolor\">
  50.               $message</font></th>
  51.             <td align=\"right\" valign=\"middle\" width=\"40%\">
  52.               <a href=\"$homeurl\">
  53.                 <img src=\"images/home.gif\" alt=\"$mess[25]\" border=\"0\" /></a>";
  54.  
  55.   if ((!$show_configuration_menu) && ($allow_choose_language))
  56.   {
  57.     echo "&nbsp;&nbsp;&nbsp;";
  58.     while (list($langid, $langdata) = each($languages))
  59.     {
  60.      echo "<a href=\"index.php?action=savelanguage&language=";
  61.      echo $langid;
  62.      echo "\"><img src=\"";
  63.      echo $langdata["LangFlag"];
  64.      echo "\" border=\"1\" alt=\"";
  65.      echo $langdata["LangName"];
  66.      echo "\"></a>\n";
  67.     }
  68.   }
  69.  
  70. echo "         $link
  71.             </td>
  72.           </tr>
  73.         </table>
  74.       </td>
  75.     </tr>";
  76.  
  77. }
  78. echo "</table>";
  79. }
  80.  
  81. function load_user_profile($username)
  82. {
  83.   global $accounts_path, $enc_user_pass, $enc_logged_user_id, $user_email;
  84.   global $user_status, $activationcode, $user_temp_info, $user_wish_receive_digest;
  85.   global $default_user_status,$user_account_creation_time;
  86.  
  87.   $enc_user_pass="";
  88.   $enc_logged_user_id=0;
  89.   $user_email="";
  90.   $user_status=$default_user_status;
  91.   $activationcode=1;
  92.   $user_temp_info="";
  93.   $user_wish_receive_digest=0;
  94.   $user_account_creation_time=0;
  95.  
  96.   $userfilename = "$accounts_path/$username";
  97.   if (!file_exists($userfilename))
  98.     return;
  99.  
  100.   $fp=@fopen($userfilename,"r");
  101.   if($fp)
  102.   {
  103.     if(!feof($fp))
  104.       $enc_user_pass=rtrim(fgets($fp, 255));
  105.     if(!feof($fp))
  106.       $enc_logged_user_id=rtrim(fgets($fp, 255));
  107.     if(!feof($fp))
  108.       $user_email=rtrim(fgets($fp, 255));
  109.     if(!feof($fp))
  110.       $user_status=rtrim(fgets($fp, 255));
  111.     if(!feof($fp))
  112.       $activationcode=rtrim(fgets($fp, 255));
  113.     if(!feof($fp))
  114.       $user_temp_info=rtrim(fgets($fp, 255));
  115.     if(!feof($fp))
  116.       $user_wish_receive_digest=rtrim(fgets($fp, 255));
  117.     if(!feof($fp))
  118.       $user_account_creation_time=rtrim(fgets($fp, 255));
  119.   }
  120.   fclose($fp);
  121. }
  122.  
  123.  
  124. function save_user_profile($username)
  125. {
  126.   global $accounts_path, $enc_user_pass, $enc_logged_user_id, $user_email;
  127.   global $user_status, $activationcode, $user_temp_info, $user_wish_receive_digest;
  128.   global $user_account_creation_time;
  129.  
  130.   $userfilename = "$accounts_path/$username";
  131.   $fp = fopen($userfilename, "w+"); // File named as User Name
  132.   fwrite($fp, $enc_user_pass);      // 1st line: Encrypted user password
  133.   fwrite($fp, "\n");
  134.   fwrite($fp, $enc_logged_user_id); // 2nd line: Encrypted user session ID, 0 - if user logged out
  135.   fwrite($fp, "\n");
  136.   fwrite($fp, $user_email);         // 3rd line: User E-Mail address
  137.   fwrite($fp, "\n");
  138.   fwrite($fp, $user_status);    // 4 line: account status: 0 - Administrator, 1 - Power User, 2 - Normal User, 3 - Viewer (view only), 4 - Uploader (upload only)
  139.   fwrite($fp, "\n");
  140.   fwrite($fp, $activationcode); // 5 line: 1 - if account active, 0 - if disabled, other value - activation code
  141.   fwrite($fp, "\n");
  142.   fwrite($fp, $user_temp_info); // 6 line: any temporary information
  143.   fwrite($fp, "\n");
  144.   fwrite($fp, $user_wish_receive_digest);  // 7 line: User wish to receive files digest via e-mail
  145.   fwrite($fp, "\n");
  146.   fwrite($fp, $user_account_creation_time);  // 8 line: The time when user account created
  147.   fwrite($fp, "\n");
  148.   fclose($fp);
  149. }
  150.  
  151. function check_is_user_session_active($username)
  152. {
  153.   global $accounts_path,$logged_user_id,$enc_logged_user_id;
  154.   // Check user session id
  155.   load_user_profile($username);
  156.   return (md5($logged_user_id) == $enc_logged_user_id);
  157. }
  158.  
  159. function check_user_password($username, $password)
  160. {
  161.   global $accounts_path,$enc_user_pass;
  162.   // Check user session id
  163.   $userfilename = "$accounts_path/$username";
  164.   load_user_profile($username);
  165.   return (md5($password) == $enc_user_pass);
  166. }
  167.  
  168. function change_language()
  169. {
  170.   global $HTTP_GET_VARS, $language, $languages, $timeoffset, $GMToffset;
  171.   global $cookiepath,$cookiedomain,$second_cookiepath, $second_cookiedomain;
  172.   global $cookiesecure;
  173.  
  174.   $language=$HTTP_GET_VARS["language"];
  175.   setcookie("language",$language,time()+31536000,$cookiepath,$cookiedomain, $cookiesecure);  // 1 year
  176.   if ($second_cookiedomain != "")
  177.     setcookie("language",$language,time()+31536000, $second_cookiepath, $second_cookiedomain, $cookiesecure); // 1 year
  178.   $timeoffset = -$GMToffset + $languages[$language]["TimeZone"];
  179. }
  180.  
  181. function change_skin()
  182. {
  183.   global $HTTP_GET_VARS, $skinindex, $skins, $bordercolor, $headercolor, $tablecolor;
  184.   global $lightcolor, $headerfontcolor, $normalfontcolor, $selectedfontcolor;
  185.   global $cookiepath,$cookiedomain,$second_cookiepath, $second_cookiedomain;
  186.   $skinindex=$HTTP_GET_VARS["skinindex"];
  187.   if ($skinindex > count($skins))
  188.     $skinindex = 0;
  189.   setcookie("skinindex",$skinindex,time()+31536000);  // 1 year
  190.   if ($second_cookiedomain != "")
  191.     setcookie("skinindex",$skinindex,time()+31536000, $second_cookiepath, $second_cookiedomain, $cookiesecure); // 1 year
  192.   $bordercolor=$skins[$skinindex]["bordercolor"];
  193.   $headercolor = $skins[$skinindex]["headercolor"];
  194.   $tablecolor=$skins[$skinindex]["tablecolor"];
  195.   $lightcolor=$skins[$skinindex]["lightcolor"];
  196.   $headerfontcolor=$skins[$skinindex]["headerfontcolor"];
  197.   $normalfontcolor=$skins[$skinindex]["normalfontcolor"];
  198.   $selectedfontcolor=$skins[$skinindex]["selectedfontcolor"];
  199. }
  200.  
  201. function show_menu($isuserloggedin, $scriptname)
  202. {
  203.   global $show_configuration_menu;
  204.   if ($show_configuration_menu)
  205.   {
  206.     include("dynmenu.php");
  207.     build_menu($isuserloggedin, $scriptname);
  208.   }
  209. }
  210.  
  211. function generate_password()
  212. {
  213.   // Generate new password
  214.   $consonants="BCDFGHJKLMNPQRSTWXVZ";
  215.   $vowels="AEIOUY";
  216.   mt_srand((double)microtime()*1000000);
  217.   $leng=mt_rand(3,5);
  218.   $newpass="";
  219.   for ($i = 0; $i < $leng; $i++)
  220.   {
  221.     mt_srand((double)microtime()*1000000);
  222.     $newpass.=$consonants[mt_rand(0,19)].$vowels[mt_rand(0,5)];
  223.   }
  224.   return $newpass;
  225. }
  226.  
  227. function userslist($order = "name")
  228. {
  229.   global $accounts_path, $user_account_creation_time, $user_status, $activationcode, $user_wish_receive_digest, $user_email;
  230.   $userslist = "";
  231.   // Browse each user
  232.   $handle=opendir($accounts_path);
  233.   while ($filename = readdir($handle))
  234.   {
  235.     if (substr($filename,0,1) != ".")
  236.     {
  237.       if (!is_dir("$accounts_path/$filename"))
  238.       {
  239.         if ($order == "name")
  240.           $userslist[$filename] = $filename;
  241.         else
  242.         {
  243.           if (($order == "uploaded") || ($order == "downloaded") || ($order == "emailed") || ($order == "access"))
  244.           {
  245.             list($files_uploaded, $files_downloaded, $files_emailed, $last_acess_time) = load_userstat($filename);
  246.             if ($order == "uploaded")
  247.               $userslist[$filename] = $files_uploaded;
  248.             if ($order == "downloaded")
  249.               $userslist[$filename] = $files_downloaded;
  250.             if ($order == "emailed")
  251.               $userslist[$filename] = $files_emailed;
  252.             if ($order == "access")
  253.               $userslist[$filename] = $last_acess_time;
  254.           }
  255.           else
  256.           {
  257.             load_user_profile($filename);
  258.             if ($order == "date")
  259.               $userslist[$filename] = $user_account_creation_time;
  260.             if ($order == "status")
  261.               $userslist[$filename] = $user_status;
  262.             if ($order == "activestatus")
  263.               $userslist[$filename] = $activationcode;
  264.             if ($order == "receivedigest")
  265.               $userslist[$filename] = $user_wish_receive_digest;
  266.             if ($order == "email")
  267.               $userslist[$filename] = $user_email;
  268.           }
  269.         }
  270.       }
  271.     }
  272.   }
  273.   closedir($handle);
  274.   if (($order == "uploaded") || ($order == "downloaded") || ($order == "emailed"))
  275.     arsort($userslist);
  276.   else
  277.     asort($userslist);
  278.   return $userslist;
  279. }
  280.  
  281. function load_userstat($username)
  282. {
  283.   global $accounts_stat_path;
  284.   $files_uploaded = 0;
  285.   $files_downloaded = 0;
  286.   $files_emailed = 0;
  287.   $last_acess_time = 0;
  288.  
  289.   $userfilename = "$accounts_stat_path/$username.stat";
  290.   if (file_exists($userfilename))
  291.   {
  292.     $fp=@fopen($userfilename,"r");
  293.     if($fp)
  294.     {
  295.       if(!feof($fp))
  296.         $files_uploaded=rtrim(fgets($fp, 255));
  297.       if(!feof($fp))
  298.         $files_downloaded=rtrim(fgets($fp, 255));
  299.       if(!feof($fp))
  300.         $files_emailed=rtrim(fgets($fp, 255));
  301.       if(!feof($fp))
  302.         $last_acess_time=rtrim(fgets($fp, 255));
  303.     }
  304.     fclose($fp);
  305.   }
  306.   return array($files_uploaded, $files_downloaded, $files_emailed, $last_acess_time);
  307. }
  308.  
  309. function save_userstat($username, $files_uploaded, $files_downloaded, $files_emailed, $last_acess_time)
  310. {
  311.   global $accounts_stat_path;
  312.  
  313.   $userfilename = "$accounts_stat_path/$username.stat";
  314.   $fp=fopen($userfilename,"w+");
  315.   if($fp)
  316.   {
  317.     fwrite($fp, $files_uploaded);
  318.     fwrite($fp, "\n");
  319.     fwrite($fp, $files_downloaded);
  320.     fwrite($fp, "\n");
  321.     fwrite($fp, $files_emailed);
  322.     fwrite($fp, "\n");
  323.     fwrite($fp, $last_acess_time);
  324.     fwrite($fp, "\n");
  325.   }
  326.   fclose($fp);
  327. }
  328.  
  329. class MIME_MAIL {
  330.   var $attachments = array();
  331.   var $from = "";
  332.   var $subject = "";
  333.   var $body = "";
  334.   var $charset = "";
  335.  
  336.   function MIME_MAIL($from = "", $subject = "", $body = "", $charset = "")
  337.   {
  338.     $this->from = $from;
  339.     $this->subject = $subject;
  340.     $this->body = $body;
  341.     $this->charset = $charset;
  342.   }
  343.  
  344.   function attachment($name = "", $contents = "",
  345.                       $type = "application/octet-stream", $encoding = "base64")
  346.   {
  347.     $this->attachments[] = array("filename" => $name,
  348.                                  "type" => $type,
  349.                                  "encoding" => $encoding,
  350.                                  "data" => $contents);
  351.   }
  352.  
  353.   function _build()
  354.   {
  355.     mt_srand((double)microtime()*1000000);
  356.     $boundary = '--b'.md5(uniqid(mt_rand())) . getmypid();
  357.  
  358.     if ($this->from != "")
  359.       $ret = "From: " . $this->from . "\n";
  360.     else
  361.       $ret = "";
  362.  
  363.     $ret .= "MIME-Version: 1.0\n";
  364.     $ret .= "Content-Type: multipart/mixed; ";
  365.     $ret .= "boundary=\"$boundary\"\n\n";
  366.  
  367.  
  368.     $ret .= "This is a MIME encoded message. \n\n";
  369.     $ret .= "--$boundary\n";
  370.  
  371.     $ret .= "Content-Type: text/plain";
  372.     if ($this->charset != "")
  373.       $ret .= "; charset=$this->charset";
  374.  
  375.     $ret .= "\n";
  376.     $ret .= "Content-Transfer-Encoding: 8bit\n\n";
  377.     $ret .= $this->body . "\n--$boundary";
  378.  
  379.     foreach($this->attachments as $attachment)
  380.     {
  381.       $attachment["data"] = base64_encode($attachment["data"]);
  382.       $attachment["data"] = chunk_split($attachment["data"]);
  383.       $data =
  384.         "Content-Type: $attachment[type]";
  385.         if ($attachment["filename"] != "")
  386.           $data .= "; name = \"$attachment[filename]\"";
  387.         else
  388.           $data .= "";
  389.         $data .= "\n" .
  390.         "Content-Transfer-Encoding: $attachment[encoding]" .
  391.         "\n\n$attachment[data]\n";
  392.       $ret .= "\n$data\n--$boundary";
  393.     }
  394.     $ret .= "--\n";
  395.     return($ret);
  396.   }
  397.  
  398.   function send($to)
  399.   {
  400.     return @mail($to, $this->subject, "", $this->_build());
  401.   }
  402.  
  403.  
  404.   function add_html($html_message)
  405.   {
  406.     $this->attachment("", $html_message, "text/html");
  407.   }
  408.  
  409.   function mime_type($filename)
  410.   {
  411.     if(eregi("\.zip$",$filename)) $mimet="application/zip";
  412.     else if (eregi("\.gtar$",$filename)) $mimet="application/x-gtar";
  413.     else if (eregi("\.tar$",$filename)) $mimet="application/x-tar";
  414.     else if (eregi("\.gif$",$filename)) $mimet="image/gif";
  415.     else if (eregi("\.jpeg$",$filename)) $mimet="image/jpeg";
  416.     else if (eregi("\.jpg$",$filename)) $mimet="image/jpeg";
  417.     else if (eregi("\.tiff$",$filename)) $mimet="image/tiff";
  418.     else if (eregi("\.tif$",$filename)) $mimet="image/tiff";
  419.     else if (eregi("\.rtf$",$filename)) $mimet="application/rtf";
  420.     else if (eregi("\.wav$",$filename)) $mimet="audio/x-wav";
  421.     else if (eregi("\.html$",$filename)) $mimet="text/html";
  422.     else if (eregi("\.htm$",$filename)) $mimet="text/html";
  423.     else if (eregi("\.txt$",$filename)) $mimet="text/plain";
  424.     else if (eregi("\.pdf$",$filename)) $mimet="application/pdf";
  425.     else if (eregi("\.eps$",$filename)) $mimet="application/postscript";
  426.     else if (eregi("\.ps$",$filename)) $mimet="application/postscript";
  427.     else if (eregi("\.avi$",$filename)) $mimet="video/x-msvideo";
  428.     else if (eregi("\.mpeg$",$filename)) $mimet="video/mpeg";
  429.     else if (eregi("\.mpg$",$filename)) $mimet="video/mpeg";
  430.     else if (eregi("\.qt$",$filename)) $mimet="video/quicktime";
  431.     else if (eregi("\.mov$",$filename)) $mimet="video/quicktime";
  432.     else if (eregi("\.doc$",$filename)) $mimet="application/msword";
  433.     else $mimet="application/octet-stream";
  434.     return $mimet;
  435.   }
  436.  
  437.   function add_file($filename)
  438.   {
  439.     if (!file_exists($filename))
  440.       return;
  441.     $fp=@fopen($filename,"rb");
  442.     $contents = fread($fp, filesize($filename));
  443.     fclose($fp);
  444.     $this->attachment(basename($filename), $contents, $this->mime_type($filename));
  445.   }
  446.  
  447. } // Enc of class MIME_MAIL
  448.  
  449. ?>
  450.  
Jul 21 '08 #4

code green
Expert 100+
P: 1,726
Listen to what hsriat is telling you.
It is a missing curly brace
Jul 21 '08 #5

akohistani
P: 4
Code Green could you please explain to me? as I am totally new with PHP this is the first script I have used I really can't figuer it out if you check the could for me that will be your favor.
Jul 21 '08 #6

code green
Expert 100+
P: 1,726
OK no problem. This error means the compiler has found an end of file marker ie >? when it wasn't expecting one.
This usually means, in fact I personally have found it to always mean,
there is an opening curly brace { without a corresponding closing curly brace }.
This confuses the hell out of the compiler, hence the error.
I am sorry, but I do not have time to wade through your code to find the error.
That should prove a useful learning tool for you.
Good Luck
Jul 21 '08 #7

Atli
Expert 5K+
P: 5,058
This usually means, in fact I personally have found it to always mean,
there is an opening curly brace { without a corresponding closing curly brace }.
That has also been my experience. 99% of these errors are caused by mismatched curly-braces.
But I've gone through the code in my own IDE and I can't seem to find any such mismatch.
Not to mention that the error is pointing at line 400, which is a statement, but it usually points to the end of a curly brace when there is a mismatch.

Going over line 400, I do see some potential problems.
For example, you add the body to the additional headers. Should that not be passed in the 3'rd parameter of the mail() function instead?

Try removing the @ in front of the function call... see if it is suppressing an error message that can help.
Jul 21 '08 #8

akohistani
P: 4
Removing @ changes resolves the error but some warning appears here is the url to check it out http://www.afghan123.com/music/upload
Jul 21 '08 #9

code green
Expert 100+
P: 1,726
Seems OK now akohistani
Jul 23 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.