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);
-
-
}
-
-
?>
-
5 13948 Atli 5,058
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....
Atli 5,058
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'. Sign in to post your reply or Sign up for a free account.
Similar topics
by: sky2070 |
last post by:
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ')'
in c:\inetpub\wwwroot\session.php on line 19
can anyone tell me what is wrong with this code???
<?
// Define the Session...
|
by: Marten van Urk |
last post by:
I got the following error in my page Parse error: parse error,
unexpected T_ELSE in line 25
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Club</title>...
|
by: Ehartwig |
last post by:
I recently created a script for user verification, solved my emailing
issues, and then re-created the script in order to work well with the
new PHP 5 that I installed on my server. After...
|
by: Wescotte |
last post by:
The error message Parse error: syntax error, unexpected $end in FILE on
line X is one I run into frequently and I know the cause is I missed an
ending quote.
Is there an easy way to determine...
|
by: Anna MZ |
last post by:
I am new to php and have written the following mysql code to enter the details of a new user in the admin subdomain of my website:
$sql = "INSERT INTO 'users' ('userid', 'username', 'upassword')...
|
by: soidariti |
last post by:
database error - parse error, unexpected $, expecting kEND
AddUserAuthorisationToUsers.rb migration file
1. class AddUserAuthorisationToUsers < ActiveRecord::Migration
2. def self.up
...
|
by: epots9 |
last post by:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/xxx.php on line xxx
I get that message when i try to run my...
|
by: nazgul42 |
last post by:
I am writing a very simple login script for a website that I am also writing, but when I try to run it, the only error I get is:
Parse error: parse error, unexpected $ in...
|
by: Lawrence Krubner |
last post by:
Imagine a template system that works by getting a file, as a string, and
then putting it through eval(), something like this:
$formAsString = $controller->command("readFileAndReturnString",...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: linyimin |
last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |