|
I'm trying to run a script and it's throwing the following error: -
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in openfile.php on line 41
-
Here is the openfile.php file and I have bolded line 41. Any ideas/help would be greatly appreciated! -
<?php
-
-
/*
-
This file is responsible for the download of the files
-
*/
-
-
require_once('../../../wp-config.php');
-
-
global $user_ID, $wpdb, $table_prefix;
-
-
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
-
-
include_once("uploader_functions.php");
-
-
$id = (int) $_GET['file'];
-
-
$result = @$wpdb->get_row("SELECT fileName, type, title, downloads
-
FROM ".$table_prefix."document
-
WHERE id = ".$id."
-
;");
-
-
if(!isset($result->title)){
-
-
$info = get_bloginfo("url");
-
-
header("Location: ".$info."/wp-content/plugins/wp-publications-archive/notFound.php");
-
-
return;
-
-
}
-
-
$downloads = $result->downloads + 1;
-
$wpdb->query("UPDATE ".$table_prefix."document
-
SET downloads = ".$downloads."
-
WHERE id = ".$id.";");
-
-
$fTitle = $result->title;
-
-
$fPath = $result->fileName;
-
-
$fType = wpup_upGetType($result->type)->extName;
-
-
$fName = basename($fPath); //Get filename //thanks to brian.m.turnbull
-
-
$origname = preg_replace('/_#_#\d*/','',$fName); //Remove the _#_#$id //thanks to brian.m.turnbull
-
-
$permission = "all";
-
-
$plugin_name = "wp_uploader";
-
-
if (class_exists("userGroups"))
-
$user = new userGroups;
-
-
if (class_exists("userGroups") && $user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
-
-
header('Content-type: "'.$fType.'"');
-
-
header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
-
-
readfile($fPath);
-
-
}
-
-
if (class_exists("userGroups") && !$user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
-
-
$info = get_bloginfo("url");
-
-
header("Location: ".$info."/wp-content/plugins/wp-publications-archive/access.php");
-
-
}
-
-
if (!class_exists("userGroups")){
-
-
header('Content-type: "'.$fType.'"');
-
-
header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
-
-
readfile($fPath);
-
-
}
-
-
?>
-
| |
Share:
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.
| | |
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: -
/*
-
* Funtion used to get all the details of a file by the given id
-
* @param id of the file type
-
* @return array contaninning all the details of the given file type
-
*/
-
function wpup_upGetType($id){
-
global $wpdb, $table_prefix;
-
return $type = $wpdb->get_row("SELECT *
-
FROM ".$table_prefix."type
-
WHERE id = ".$id."
-
;");
-
}
-
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!!!
| | |
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! -
<?php
-
-
/*
-
This file is responsible for the download of the files
-
*/
-
-
require_once('../../../wp-config.php');
-
-
global $user_ID, $wpdb, $table_prefix;
-
-
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
-
-
include_once("uploader_functions.php");
-
-
$id = (int) $_GET['file'];
-
-
$result = @$wpdb->get_row("SELECT fileName, type, title, downloads
-
FROM ".$table_prefix."document
-
WHERE id = ".$id."
-
;");
-
-
if(!isset($result->title)){
-
-
$info = get_bloginfo("url");
-
-
header("Location: ".$info."/wp-content/plugins/wp-publications-archive/notFound.php");
-
-
return;
-
-
}
-
-
$downloads = $result->downloads + 1;
-
$wpdb->query("UPDATE ".$table_prefix."document
-
SET downloads = ".$downloads."
-
WHERE id = ".$id.";");
-
-
$fTitle = $result->title;
-
-
$fPath = $result->fileName;
-
-
$fType = wpup_upGetType($result->type);
-
$fType = $result->extName;
-
-
$fName = basename($fPath); //Get filename //thanks to brian.m.turnbull
-
-
$origname = preg_replace('/_#_#\d*/','',$fName); //Remove the _#_#$id //thanks to brian.m.turnbull
-
-
$permission = "all";
-
-
$plugin_name = "wp_uploader";
-
-
if (class_exists("userGroups"))
-
$user = new userGroups;
-
-
if (class_exists("userGroups") && $user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
-
-
header('Content-type: "'.$fType.'"');
-
-
header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
-
-
readfile($fPath);
-
-
}
-
-
if (class_exists("userGroups") && !$user->ugHasAccess($user_ID, $id, $permission, $plugin_name)){
-
-
$info = get_bloginfo("url");
-
-
header("Location: ".$info."/wp-content/plugins/wp-publications-archive/access.php");
-
-
}
-
-
if (!class_exists("userGroups")){
-
-
header('Content-type: "'.$fType.'"');
-
-
header('Content-Disposition: attachment; filename="'.$origname.'"'); //thanks to brian.m.turnbull
-
-
readfile($fPath);
-
-
}
-
-
?>
-
| | |
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....
| | 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'. | | 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
|
8 posts
views
Thread by Wescotte |
last post: by
| | | | |
2 posts
views
Thread by Lawrence Krubner |
last post: by
| | | | | | | | | | |