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 14013 Atli 5,058
Recognized Expert Expert
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_functi ons.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
Recognized Expert Expert
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 class
class Session
{
// Define the properties:
|
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>
</head>
<style type="text/css">
|
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 submitting user
information into my creation script, I get the following error from the
page that is suppose to insert the user data into the database, create
a code, then send an email out for verification.
Parse error: parse error, unexpected $end in...
|
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 where the inital " started? I find
myself adding /* */ blocks or cutting/pasting sections of code out in
order to find where the error occured.
Wouldn't it it be nice if the warning message included the line in teh
source where the initial quote ...
|
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')
VALUES ('$_POST', '$_POST', '$_POST')
mysql_query($sql)";
When I view the code in Internet Explorer I get the following error message:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or...
| |
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
3. drop_table :users
4.
5. create_table :users, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8' do |t|
6. t.column :first_name, :string
|
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 script, but if i disable an if statement (code below) then my code functions correctly...
if($specs == "DT")
{
$angle = $specs;
$rating = $specs;
if($angle == "00" || $angle == "30")
|
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 /home/www/zammarket.freehostia.com/signup.php on line 22
Line 22 is the last line in the file.
My code is here:
<?php
echo "Starting...";
@mysql_connect(My_Sql_Server, My_DB, My_Password) or die("Cannot Connect To DB!");
@mysql_select_db(My_DB) or die("Cannot...
|
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", $formName);
// 06-22-07 - the next commands try to import all the functions that the
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |