467,910 Members | 1,559 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,910 developers. It's quick & easy.

Parse Error - Unexpected T_OBJECT_OPERATOR

I'm trying to run a script and it's throwing the following error:
Expand|Select|Wrap|Line Numbers
  1. Parse error: syntax error, unexpected T_OBJECT_OPERATOR in openfile.php on line 41
  2.  
Here is the openfile.php file and I have bolded line 41. Any ideas/help would be greatly appreciated!
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. /* 
  4.   This file is responsible for the download of the files
  5. */
  6.  
  7. require_once('../../../wp-config.php');
  8.  
  9. global $user_ID, $wpdb, $table_prefix;
  10.  
  11. require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 
  12.  
  13. include_once("uploader_functions.php");
  14.  
  15. $id = (int) $_GET['file'];
  16.  
  17. $result = @$wpdb->get_row("SELECT fileName, type, title, downloads
  18.                             FROM ".$table_prefix."document
  19.                             WHERE id = ".$id."
  20.                            ;");
  21.  
  22. if(!isset($result->title)){
  23.  
  24.   $info = get_bloginfo("url");
  25.  
  26.   header("Location: ".$info."/wp-content/plugins/wp-publications-archive/notFound.php");
  27.  
  28.   return;
  29.  
  30.  
  31. $downloads = $result->downloads + 1;
  32. $wpdb->query("UPDATE ".$table_prefix."document 
  33.                     SET downloads = ".$downloads."
  34.                     WHERE id = ".$id.";");
  35.  
  36. $fTitle = $result->title;                         
  37.  
  38. $fPath = $result->fileName;
  39.  
  40. $fType = wpup_upGetType($result->type)->extName;
  41.  
  42. $fName = basename($fPath); //Get filename //thanks to brian.m.turnbull
  43.  
  44. $origname = preg_replace('/_#_#\d*/','',$fName); //Remove the _#_#$id //thanks to brian.m.turnbull
  45.  
  46. $permission = "all";
  47.  
  48. $plugin_name = "wp_uploader";
  49.  
  50. if (class_exists("userGroups"))
  51.   $user = new userGroups;
  52.  
  53. if (class_exists("userGroups") && $user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
  54.  
  55.   header('Content-type: "'.$fType.'"');
  56.  
  57.   header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
  58.  
  59.   readfile($fPath);
  60.  
  61. }  
  62.  
  63. if (class_exists("userGroups") && !$user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
  64.  
  65.   $info = get_bloginfo("url");
  66.  
  67.   header("Location: ".$info."/wp-content/plugins/wp-publications-archive/access.php");
  68.  
  69. }
  70.  
  71. if (!class_exists("userGroups")){
  72.  
  73.   header('Content-type: "'.$fType.'"');
  74.  
  75.   header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
  76.  
  77.   readfile($fPath);
  78.  
  79. }
  80.  
  81. ?>
  82.  
Sep 17 '07 #1
  • viewed: 13639
Share:
5 Replies
Atli
Expert 4TB
Hi Devereaux. Welcome to The Scripts!

Are you sure the result you are getting from the wpup_upGetType() function is a valid object? Is it possible that is returns something else, like say false if it fails?

Also, please use [code] tags when posting code. It is impossible to read it without them.
Sep 17 '07 #2
Thanks so much for the reply. I must admit I'm a bit of a hack with PHP so forgive my lack of true expertise. However, I'm fairly positive of the result. The function itself is in uploader_functions.php and is as follows:

Expand|Select|Wrap|Line Numbers
  1. /*
  2. * Funtion used to get all the details of a file by the given id
  3. * @param id of the file type
  4. * @return array contaninning all the details of the given file type
  5. */
  6. function wpup_upGetType($id){
  7.   global $wpdb, $table_prefix;
  8.   return $type = $wpdb->get_row("SELECT *
  9.                               FROM ".$table_prefix."type
  10.                               WHERE id = ".$id."
  11.                               ;");
  12. }
  13.  
Sorry about not using the code tags before. I am using PHP 4.4.4, Apache 1.3.37 and MySQL 4.1.22

If there is more that I can do to help debug please let me know and I will work through that. Thanks again!!!
Sep 17 '07 #3
Alright I resolved my own issue. The single line of code had to be split into to lines as shown below in the new openfile.php file. Thanks for taking a look though - much appreciated!

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. /* 
  4.   This file is responsible for the download of the files
  5. */
  6.  
  7. require_once('../../../wp-config.php');
  8.  
  9. global $user_ID, $wpdb, $table_prefix;
  10.  
  11. require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 
  12.  
  13. include_once("uploader_functions.php");
  14.  
  15. $id = (int) $_GET['file'];
  16.  
  17. $result = @$wpdb->get_row("SELECT fileName, type, title, downloads
  18.                             FROM ".$table_prefix."document
  19.                             WHERE id = ".$id."
  20.                            ;");
  21.  
  22. if(!isset($result->title)){
  23.  
  24.   $info = get_bloginfo("url");
  25.  
  26.   header("Location: ".$info."/wp-content/plugins/wp-publications-archive/notFound.php");
  27.  
  28.   return;
  29.  
  30.  
  31. $downloads = $result->downloads + 1;
  32. $wpdb->query("UPDATE ".$table_prefix."document 
  33.                     SET downloads = ".$downloads."
  34.                     WHERE id = ".$id.";");
  35.  
  36. $fTitle = $result->title;                         
  37.  
  38. $fPath = $result->fileName;
  39.  
  40. $fType = wpup_upGetType($result->type);
  41. $fType = $result->extName;
  42.  
  43. $fName = basename($fPath); //Get filename //thanks to brian.m.turnbull
  44.  
  45. $origname = preg_replace('/_#_#\d*/','',$fName); //Remove the _#_#$id //thanks to brian.m.turnbull
  46.  
  47. $permission = "all";
  48.  
  49. $plugin_name = "wp_uploader";
  50.  
  51. if (class_exists("userGroups"))
  52.   $user = new userGroups;
  53.  
  54. if (class_exists("userGroups") && $user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
  55.  
  56.   header('Content-type: "'.$fType.'"');
  57.  
  58.   header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
  59.  
  60.   readfile($fPath);
  61.  
  62. }  
  63.  
  64. if (class_exists("userGroups") && !$user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
  65.  
  66.   $info = get_bloginfo("url");
  67.  
  68.   header("Location: ".$info."/wp-content/plugins/wp-publications-archive/access.php");
  69.  
  70. }
  71.  
  72. if (!class_exists("userGroups")){
  73.  
  74.   header('Content-type: "'.$fType.'"');
  75.  
  76.   header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
  77.  
  78.   readfile($fPath);
  79.  
  80. }
  81.  
  82. ?> 
  83.  
Sep 17 '07 #4
Well, this doesn't work after all - it does but it's inconsistent. The files will open but only some of the time. :-) Very strange....
Sep 17 '07 #5
Atli
Expert 4TB
Well, this doesn't work after all - it does but it's inconsistent. The files will open but only some of the time. :-) Very strange....
I see.

Are you getting any errors?

Try checking it the $result object has a value for 'extName'.
Expand|Select|Wrap|Line Numbers
  1. print_r($result);
  2.  
Sep 17 '07 #6

Post your reply

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

Similar topics

2 posts views Thread by sky2070 | last post: by
3 posts views Thread by Marten van Urk | last post: by
6 posts views Thread by Ehartwig | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.