View Full Version : [php] unexpected T_CONSTANT_ENCAPSED_STRING
questo codice da questo errore:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /membri/mamo139/download.php on line 14
non riesco a capire come mai... grazie :)
<?
if(isset($_GET['id']))
$get_id = ''.$_GET['id'];
else exit(0);
$get_id = str_replace('/','',$get_id);
$get_id = str_replace('\','',$get_id);
$file = "database/".$get_id;
$filename = $get_id;
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$filename.'"');
readfile($file);
?>
Usa le " " (doppi apici) per la funzione header() :)
Usa le " " (doppi apici) per la funzione header() :)
nono nella funzione header() sono usati gli apici singoli ' ' :p
comunque l'errore stava il mio stpidissimo errore stava in $get_id = str_replace('\','',$get_id); che doveva essere $get_id = str_replace('\\','',$get_id);... che errore banale:muro: sono un po arrugginito con sto linguaggio!!!
gia che ci sono faccio un'altra domanda: questo script serve come avrete sicuramente capito a far scaricare dei file presenti nella cartella "database", dalla directory superiore... poiche la cartella "database" così come tutte le altre directory dello stesso livello sono chiuse al pubblico per sicurezza.
è importante che questo script non permetta il download di nessun'altro file all'infuori di quelli contenuti nella cartella download... dite che come misura di sicurezza quei
$get_id = str_replace('/','',$get_id);
$get_id = str_replace('\\','',$get_id);
sono sufficienti??
nono nella funzione header() sono usati gli apici singoli ' ' :p
comunque l'errore stava il mio stpidissimo errore stava in $get_id = str_replace('\','',$get_id); che doveva essere $get_id = str_replace('\\','',$get_id);... che errore banale:muro: sono un po arrugginito con sto linguaggio!!!
gia che ci sono faccio un'altra domanda: questo script serve come avrete sicuramente capito a far scaricare dei file presenti nella cartella "database", dalla directory superiore... poiche la cartella "database" così come tutte le altre directory dello stesso livello sono chiuse al pubblico per sicurezza.
è importante che questo script non permetta il download di nessun'altro file all'infuori di quelli contenuti nella cartella download... dite che come misura di sicurezza quei
$get_id = str_replace('/','',$get_id);
$get_id = str_replace('\\','',$get_id);
sono sufficienti??
Contando le righe del sorgente mi dava errore alla linea dell'header, la prossima volta linka la riga che ti da errore.
Comunque negli header puoi mettere anche le doppie ;)
Contando le righe del sorgente mi dava errore alla linea dell'header, la prossima volta linka la riga che ti da errore.
Comunque negli header puoi mettere anche le doppie ;)
la riga dell'errore segnalata era proprio quella dell'header... segnalava quella perche essendoci stato un errore nel ' ' leggeva come contenuto degli apici fino ad header e quindi l'errore veniva segnalato li...
ecco questa è la versione finale del codice che dovrebbe essere sicura...
che dite??
è sicura?? :)
grazie
<?
if(isset($_GET['id']))
$get_id = $_GET['id'];
else {echo'id non definito! :(';exit(0);}
$indirizzo = str_replace('\\','/',$get_id);
$indirizzo = str_replace('..','',$indirizzo);
$indirizzo = explode('/',$indirizzo);
if(
sizeof($indirizzo) != 2 ||
$indirizzo[0] != 'database'
){
echo 'Non sei autorizzato a scaricare questo file! :)';
exit(0);
}
$file = $get_id;
$filename = $get_id;
if(!is_file($file)){
echo 'Sei autorizzato a scaricare da questa directory ma il file non esiste :p';
exit(0);
}
header('Content-type: text/plain');
$content = 'Content-Disposition: attachment; filename="'.$filename.'"';
header($content);
readfile($file);
?>
matthew85
09-02-2013, 12:26
A me, invece, da sulla riga 26, l'errore è:
"Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /web/htdocs/www.cosmomakeup.it/home/register.php on line 26"
il codice è:
<?php
include("config.php");
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
if($_POST["username"]!="" && $_POST["password"]!="" && $_POST["conferma_password"]!="" && $_POST["nome"]!="" && $_POST["cognome"]!="" && $_POST["partita_iva"]!="" && $_POST["codice_fiscale"]!="" && $_POST["indirizzo"]!="" && $_POST["cap"]!="" && $_POST["citta"]!="" && $_POST["provincia"]!="" && $_POST["mail"])
{
// check if the username is taken
$check = "select id from $table where username = '".$_POST['username']."';";
$qry = mysql_query($check)
or die ("Could not match data because ".mysql_error());
$num_rows = mysql_num_rows($qry);
if ($num_rows != 0) {
echo "Sorry, the username $username is already taken.<br>";
echo "<a href=register.html>Try again</a>";
exit;
} else {
// insert the data
$insert = mysql_query("insert into user (username,password,conferma_password,nome,cognome,partita_iva,codice_fiscale,indirizzo,cap,citta,provincia,mail,newsletter) values ('".$_POST["username"]!="" && $_POST["password"]!="" && $_POST["conferma_password"]!="" && $_POST["nome"]!="" && $_POST["cognome"]!="" && $_POST["partita_iva"]!="" && $_POST["codice_fiscale"]!="" && $_POST["indirizzo"]!="" && $_POST["cap"]!="" && $_POST["citta"]!="" && $_POST["provincia"]!="" && $_POST["mail"]"")
or die("Could not insert data because ".mysql_error());
// print a success message
echo "Your user account has been created!<br>";
echo "Now you can <a href=login.html>log in</a>";
}
}
else echo "Sorry, you have to insert all the fields.<br><a href=register.html>Try again</a>";
?>
e l'errore è su questo:
"$insert = mysql_query("insert into user (username,password,conferma_password,nome,cognome,partita_iva,codice_fiscale,indirizzo,cap,citta,provincia,mail,newsletter) values ('".$_POST["username"]!="" && $_POST["password"]!="" && $_POST["conferma_password"]!="" && $_POST["nome"]!="" && $_POST["cognome"]!="" && $_POST["partita_iva"]!="" && $_POST["codice_fiscale"]!="" && $_POST["indirizzo"]!="" && $_POST["cap"]!="" && $_POST["citta"]!="" && $_POST["provincia"]!="" && $_POST["mail"]"")"
che cosa dovrei fare?
Come posso sistemarlo?
matthew85
15-02-2013, 12:57
Nessuno mi può dare una mano?
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.