PHP - Set Require_once? So The File Is Not Loaded Later On In The Script.
Is it possible to set the require_once, so that later in the script PHP does not require_once the file?
Code: [Select] $file = $root.'filename.php'; set_require_once($file);//this would be nice require_once($file);//so this does not load Similar TutorialsHi everyone! I've been working on a php script to replace links that contain a query with direct links to the files they would redirect to. PLEASE HELP! I need help I am a new php user, and am trying to understand how to read a .txt file into an array then to retrieve the index of the array at will. Code: [Select] <?php //echo $myfile = fopen("ArrayTestFile.txt", "r") . "File exists: " or die("File does not exist or you lack permission to open it! "); //echo "The contents of the file is " . file_get_contents("ArrayTestFile.txt") . "<br />"; $fh = fopen("ArrayTestFile.txt", 'r+') or die("Failure"); $array = array(); //creation of array $num = fgets($fh);// recursive call variable $num fgets(.txt line) for ($i = 0; $i <= 5; $i++) //for loop loads first 5 of .txt { $array["i"] = $num; //loads each line of .txt into the array at the loops index. echo "Line " . $i . " of the array is " . $array["i"]; // displays the contents of the array in a print message } ?> Thank you. MOD EDIT: code tags added. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=358359.0 I'm restarting this under a new subject b/c I learned some things after I initially posted and the subject heading is no longer accurate. What would cause this behavior - when I populate session vars from a MYSQL query, they stick, if I populate them from an MSSQL query, they drop. It doesn't matter if I get to the next page using a header redirect or a form submit. I have two session vars I'm loading from a MYSQL query and they remain, the two loaded from MSSQL disappear. I have confirmed that all four session vars are loading ok initially and I can echo them out to the page, but when the application moves to next page via redirect or form submit, the two vars loaded from MSSQL are empty. Any ideas? Hi, I think I understand this but want to check. If I have files register, user.class and dbconnect. If both register and user.class use require_once dbconnect will the dbconnect still only be required on the first time? Ben I was wondering how to get around the security warning that pops up when I add require_once ('includes/prochart.php') to my webpage. I edited my .htaccess file to make all pages https, but when i do this include it isn't considered a secure page so an annoying popup comes up that you have to click no on to load my content. Is there a way around this? I have a page that was working perfectly. I decided to move that page. Once I did that, I changed my require_once statement to reflect that the page had moved. Although the paths seem correct, I am getting this error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '../../../data/MoStopsDEV/ConnectionStrings.php' (include_path='.;C:\Program Files\Jcx.Software\VS.Php\2008\php 5\pear;C:\Program Files\Jcx.Software\VS.Php\2008\') I researched this error but am not able to find anything helpful. Any ideas? I'm writing a rather large script and it appears that I'm running into some require_once problems. So far I only have a few files wrote for my script.. ./includes/objects/database.class.php require_once("../../config.php"); ./test.php require_once("./config.php"); require_once("./includes/objects/database.class.php"); When I try running the test.php I get the following error: Code: [Select] Warning: require_once(../../config.inc.php) [function.require-once]: failed to open stream: No such file or directory in /includes/objects/database.class.php on line 27 Fatal error: require_once() [function.require]: Failed opening required '../../config.inc.php' (include_path='.:/opt/lampp/lib/php') in /includes/objects/database.class.php on line 27 However, when I run the database.class.php by itself it doesn't have any errors at all and it requires (sounds weird.. includes I guess?) the file just fine. I only get the above error from running test.php. I'm running on a local environment using XAMPP so there might be some php configuration option that I'm not aware of. I've tried doing some reading and I'm honestly not sure what could be the problem. Help? im writing php application in windows 7 using apachi . iwant to include php file to another php file. This is the code. test.php ------------- before <?php require_once 'footer.php'; ?> after fotter.php -------------- test 1 ------------------------- test2 when I include the above footer.php into test.php file I got the following result. before <?php require_once 'footer.php'; ?> after Could you please tell me wher i goes woring? I have 4 php files. 1. dbuser.php, declares class dbuser.php, no includes 2. dbobject.php, declares class dbobject.php, includes file 1. 3. casedetails.php, includes files 1 and 2 4. viewcase.php, includes files 1 and 3. When I try to run file 4, i get cannot redeclare class dbuser.php - error Even every require is followed by _once, but I still get "Cannot redeclare class dbuser"-error when running file 4. Full PHP-code below. I tried also putting "if(!class_exists('dbuser')) { ... " around class dbuser declaration but I still got the same error.. Is this a bug in PHP? I'm running version 5.x on apache 2 Thanks! 1. dbuser.php Code: [Select] <?PHP //$time = round(microtime(), 3); session_start(); require_once("settings.php"); //this is just simple array class dbuser { //Constructor function __construct($username=NULL, $password=NULL, $cookies=FALSE) { //Yhdistet��n tietokantaan ja k�ynnistet��n sessio require_once("dbconnect.php"); //Jos ei annettu parametrein� kayttajanimea ja salasanaa if (!isset($username) | !isset($password)) { //Jos salasana ja kayttaja tallennettu SESSION variableen if (isset($_SESSION['user']['email']) && $this->checkFingerprint($_SESSION['user']['fingerprint'])) { $this->logged = TRUE; foreach($_SESSION['user'] as $key => $value) { $this->$key=$value; } //Jos salasana ja kayttaja tallennettu kekseihin } elseif ( isset($_COOKIE['email']) && isset($_COOKIE['password']) ) { $this->logged = ($this->login($_COOKIE['email'], $_COOKIE['password'], FALSE, TRUE)); } //Jos annettu parametrein� knimi ja pwd } else { $this->logged = ($this->login($username, $password, $cookies, FALSE)); } //Costructor loppuu } //Kirjautuu sisaan, ottaa parametreina knimen ja pwd:n sek� tallennetaanko kekseihin, sa sen onko pwd kryptattu valmiiksi public function login($username, $password, $cookies=FALSE, $precrypted=FALSE) { global $settings; if ($precrypted) { $password = mysql_real_escape_string($password); } else { $password = sha1($password); } $username = mysql_real_escape_string($username); //MySQL query $time = time(); $loginQuery = "SELECT * FROM users WHERE email='$username' AND salasana='$password' AND aktiivinen='1' AND (vanhenee>'$time' OR vanhenee='')"; $fprint = $this->createFingerprint(); if($precrypted) { $loginQuery .= " AND fingerprint='$fprint'"; } $result = mysql_query($loginQuery) or trigger_error(mysql_error); $login = mysql_num_rows($result) or trigger_error(mysql_error()); if ($login != 1) { setcookie("email",'',-100000, "/"); setcookie("password",'',-100000, "/"); mysql_close(); session_destroy(); return FALSE; } else { $result = mysql_fetch_assoc($result); foreach ($result as $field => $value) { $this->$field=$value; $_SESSION['user'][$field] = $value; } $update = "UPDATE users SET kirjautunut='" . time() . "' WHERE id='" . $this->id . "'"; mysql_query($update) or trigger_error(mysql_error()); $update = "UPDATE users SET fingerprint='" . $fprint . "' WHERE id='" . $this->id . "'"; mysql_query($update) or trigger_error(mysql_error()); $this->kirjautunut=time(); $_SESSION['user']['kirjautunut'] = time(); if ($cookies) { setcookie("email",$username,($settings['REMEMBER_LOGIN_DURATION'] + time()), "/"); setcookie("password",$password,($settings['REMEMBER_LOGIN_DURATION'] + time()), "/"); } return TRUE; } } public function adduser($values) { if ($this->logged) { $insert = "INSERT INTO users ("; $vals = " VALUES("; $values['salasana'] = sha1($values['salasana']); foreach($values as $key => $value) { $insert .= mysql_real_escape_string($key) . ', '; $vals .= "'" . mysql_real_escape_string($value) . "', "; } $insert = substr($insert, 0, -2); $vals = substr($vals , 0, -2); $insert .= ')'; $vals .= ')'; $insert .= $vals; mysql_query($insert) or trigger_error(mysql_error()); return TRUE; } else { return FALSE; } } public function getusers($where=NULL, $order=NULL, $desc=NULL) { $query = "SELECT * FROM users"; if (isset($where)) { $query .= " WHERE "; foreach($where as $column => $value) { $query .= $column . " = '" . $value . "' AND "; } $query = substr($query, 0 ,-4); } if (isset($order)) { $query .= " ORDER BY " . $order . " "; } if (isset($desc)) { $query .= 'DESC'; } $values = mysql_query($query) or trigger_error(mysql_error()); $counter = 0; while ($row = mysql_fetch_assoc($values)) { foreach ($row as $key => $value) { $return[$counter][$key] = $value; } $counter++; } return $return; } public function update($id, $data) { $insert = "UPDATE users SET "; foreach($data as $key => $value) { $insert .= $key . '='; $insert .= "'" .$value . "', "; } $insert = substr($insert, 0, -2); $insert .= " WHERE id = '" . $id . "'" ; unset($data['id']); mysql_query($insert) or trigger_error(mysql_error()); } public function remove($id) { $rem = "DELETE FROM users WHERE id=$id LIMIT 1"; mysql_query($rem) or trigger_error(mysql_error()); } private function createFingerprint() { $print = "NJIARDL"; $print .= $_SERVER['HTTP_USER_AGENT']; $print .= $_SERVER['REMOTE_ADDR']; return md5($print); } private function checkFingerprint($real) { $print = $this->createFingerprint(); if ($real == $print) { return TRUE; } else { return FALSE; } } // Class dbuser loppuu } 2. dbobject.php Code: [Select] <?PHP //$time = round(microtime(), 3); require_once("dbuser.php"); .... lots of irrelevant code... class dbobject { .... ?> 3. Code: [Select] <?PHP require_once('../PHPcore/dbuser.php'); // this causes the error somehow... $user = new dbuser(); if(!$user->logged) { Header("Location:index.php"); } ... Lots of irrelevant code.. 4. I tried running this file when got the error... Code: [Select] <?PHP session_start(); require_once("PHPcore/dbuser.php"); $user = new dbuser(); if(!$user->logged) { Header("Location:index.php"); } require_once("views/casedetails.php"); Need help urgent. the website sudden prompt out error below: Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(/var/www/vhosts/db2020.co.uk/application/application/config/admin/config.live.php) is not within the allowed path(s): (/var/www/vhosts/db2020.co.uk/subdomains/admin/httpdocs:/tmp) in /var/www/vhosts/db2020.co.uk/subdomains/admin/httpdocs/index.php on line 11 Warning: require_once(/var/www/vhosts/db2020.co.uk/application/application/config/admin/config.live.php) [function.require-once]: failed to open stream: Operation not permitted in /var/www/vhosts/db2020.co.uk/subdomains/admin/httpdocs/index.php on line 11 Fatal error: require_once() [function.require]: Failed opening required '/var/www/vhosts/db2020.co.uk/application/application/config/admin/config.live.php' (include_path='.:') in /var/www/vhosts/db2020.co.uk/subdomains/admin/httpdocs/index.php on line 11 and also after this problem occur, trafic of this domain go overlimit. how can i solve this problem? urgent.... website = https://db2020.co.uk/ thanks. Hello, all: been trying to convert this little single-file upload to multiple by naming each file form-field as "userfile[]" as it's supposed to automatically treat them as an array.. but no luck! Can you guide me as to what am I doing wrong?? appreciate the help! Code: [Select] <?php if (!isset($_REQUEST["seenform"])) { ?> <form enctype="multipart/form-data" action="#" method="post"> Upload file: <input name="userfile[]" type="file" id="userfile[]"> Upload file: <input name="userfile[]" type="file" id="userfile[]"> <input type="submit" value="Upload"> <input type="hidden" name="seenform"> </form> <?php } else { // upload begins $userfiles = array($_FILES['userfile']); foreach ($userfiles as $userfile) { // foreach begins $uploaded_dir = "uploads/"; $userfile = $_FILES['userfile']["name"]; $path = $uploaded_dir . $userfile; if (move_uploaded_file($_FILES['userfile']["tmp_name"], $path)) { print "$userfile file moved"; // do something with the file here } else { print "Move failed"; } } // foreach ends } // upload ends ?> Hi,
I hope someone can help. I am fairly new to php and have the following problem that I cannot get a solution for.
We are building a logon system for a website and are receiving the following error.
?>PHP Warning: require_once(classes/Config.php): failed to open stream: No such file or directory in C:\Domains\hellopoker.co.za\wwwroot\test\php\core\init.php on line 22 PHP Fatal error: require_once(): Failed opening required 'classes/Config.php' (include_path='.;C:\php\pear') in C:\Domains\hellopoker.co.za\wwwroot\test\php\core\init.php on line 22
Code for index.php
<?php require_once 'core/init.php'; echo Config::get('mysql/host'); ?> Code for config.php <?php class Config{ public static function get ($path = null){ if ($path){ $config = $GLOBALS['config']; $path = explore('/',$path); foreach($path as $bit){ if(isset($config[$bit])){ echo 'Set'; } } } } } ?> Code for init.php <?php session_start(); $GLOBALS['config'] = array( 'mysql' => array( 'mysql' => 'xxxxxxx', 'username' => 'xxxxxx', 'password' => 'xxxxxxx', 'db' => 'xxxxxxx' ), 'remember' => array( 'cookie_name' => 'hash', 'cookie_expiry' => 604800 ), 'session' => array( 'session_name' => 'user' ) ); spl_autoload_register(function($class) { require_once 'classes/' . $class . '.php'; }); ?> ?> Any help will be greatly be appreciated. Hey all So have been working on a file upload script, it was uploading the file but also adding the path name instead of NULL to mysql when no image was to upload, that is now fixed however now it won't upload the actual image to the directory. I tried undoing the mysql changes but it still won't upload the image to the directory. Am testing on my own computer using xampp so no file permission issues, plus it was working before. Any help much appreciated. Thanks <?php $product_code = mysqli_real_escape_string($conn, $_POST['product_code']); $product_name = mysqli_real_escape_string($conn, $_POST['product_name']); $category = mysqli_real_escape_string($conn, $_POST['category']); $filter = mysqli_real_escape_string($conn, $_POST['filter']); $description = mysqli_real_escape_string($conn, $_POST['description']); $specification = mysqli_real_escape_string($conn, $_POST['specification']); $price = mysqli_real_escape_string($conn, $_POST['price']); $target_dir = "../images/products/"; if (!isset ($_FILES["img1"]["name"])) { $target_file1 = NULL; } else { if (!empty($_FILES["img1"]["name"])) { $target_file1 = $target_dir . basename($_FILES["img1"]["name"]); } else { $target_file1 = NULL; } } if (!isset ($_FILES["img2"]["name"])) { $target_file2 = NULL; } else { if (!empty($_FILES["img2"]["name"])) { $target_file2 = $target_dir . basename($_FILES["img2"]["name"]); } else { $target_file2 = NULL; } } if (!isset ($_FILES["img3"]["name"])) { $target_file3 = NULL; } else { if (!empty($_FILES["img3"]["name"])) { $target_file3 = $target_dir . basename($_FILES["img3"]["name"]); } else { $target_file3 = NULL; } } if (!isset ($_FILES["img4"]["name"])) { $target_file4 = NULL; } else { if (!empty($_FILES["img4"]["name"])) { $target_file4 = $target_dir . basename($_FILES["img4"]["name"]); } else { $target_file4 = NULL; } } $uploadOk = 1; $imageFileType1 = strtolower(pathinfo($target_file1,PATHINFO_EXTENSION)); $imageFileType2= strtolower(pathinfo($target_file2,PATHINFO_EXTENSION)); $imageFileType3 = strtolower(pathinfo($target_file3,PATHINFO_EXTENSION)); $imageFileType4 = strtolower(pathinfo($target_file4,PATHINFO_EXTENSION)); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check1 = getimagesize($_FILES["img1"]["tmp_name"]); $check2 = getimagesize($_FILES["img2"]["tmp_name"]); $check3 = getimagesize($_FILES["img3"]["tmp_name"]); $check4 = getimagesize($_FILES["img4"]["tmp_name"]); if($check1 !== false) { echo "File is an image - " . $check1["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } if (file_exists($target_file1)) { echo "Sorry, image one already exists."; $uploadOk = 0; } if($imageFileType1 != "jpg" && $imageFileType1 != "png" && $imageFileType1 != "jpeg" && $imageFileType1 != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed for img1."; $uploadOk = 0; } if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["img1"]["tmp_name"], $target_file1)) { echo "The file ". htmlspecialchars( basename( $_FILES["img1"]["name"])). " has been uploaded."; } else { echo "Sorry, there was an error uploading image one."; } } echo '<br />'; if($check2 !== false) { echo "File is an image - " . $check2["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } if (file_exists($target_file2)) { echo "Sorry, image two already exists."; $uploadOk = 0; } if($imageFileType2 != "jpg" && $imageFileType2 != "png" && $imageFileType2 != "jpeg" && $imageFileType2 != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed for img2."; $uploadOk = 0; } if (isset ($target_file2)) { if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["img2"]["tmp_name"], $target_file2)) { echo "The file ". htmlspecialchars( basename( $_FILES["img1"]["name"])). " has been uploaded."; } else { echo "Sorry, there was an error uploading image two."; } } } echo '<br />'; if($check3 !== false) { echo "File is an image - " . $check3["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } if (file_exists($target_file3)) { echo "Sorry, image three already exists."; $uploadOk = 0; } if($imageFileType3 != "jpg" && $imageFileType3 != "png" && $imageFileType3 != "jpeg" && $imageFileType3 != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed for img3."; $uploadOk = 0; } if (isset ($target_file3)) { if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["img3"]["tmp_name"], $target_file3)) { echo "The file ". htmlspecialchars( basename( $_FILES["img3"]["name"])). " has been uploaded."; } else { echo "Sorry, there was an error uploading image three."; } } } echo '<br />'; if($check4 !== false) { echo "File is an image - " . $check4["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } if (file_exists($target_file4)) { echo "Sorry, image four already exists."; $uploadOk = 0; } if($imageFileType4 != "jpg" && $imageFileType4 != "png" && $imageFileType4 != "jpeg" && $imageFileType4 != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed for img4."; $uploadOk = 0; } if (isset ($target_file4)) { if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["img4"]["tmp_name"], $target_file4)) { echo "The file ". htmlspecialchars( basename( $_FILES["img4"]["name"])). " has been uploaded."; } else { echo "Sorry, there was an error uploading image four."; } } } } echo '<br />'; $image1 = basename($target_file1); $image2 = basename($target_file2); $image3 = basename($target_file3); $image4 = basename($target_file4); // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } $sql = "INSERT INTO products (product_code, product_name, category, filter, description, specification, img1, img2, img3, img4, price) VALUES('$product_code', '$product_name', '$category', '$filter', '$description', '$specification', '$image1', '$image2', '$image3', '$image4', '$price')"; if (mysqli_query($conn, $sql)) { echo "Product Added successfully, Now on to the Sizes"; } else { echo "Error: " . $sql . "<br>" . mysqli_error($conn); } ?>
Well, im a n00b for php, and what i need is a php script which will read data from .xml file and write it into .txt file. Can someone help me? Example of .xml file : <?xml version="1.0" encoding="utf-8"?> <tv generator-info-name="NeTXMLTV/1.0.0.0" source-info-url="http://www.net-tv.hr/" source-info-name="NeT TV XMLTV" source-data-url="http://www.net-tv.hr/xmltv/net-pregled-programa-xmltv.xml"> <programme channel="NeT TV" start="20110413063000 +0200" stop="20110413080000 +0200"> <title lang="hr">JUTARNJI EXPRESS</title> <category lang="hr">glazbeno-informativni program</category> <desc lang="hr">Glazbeno informativna emisija sa servisnim informacijama i jutarnjim temperaturama, idealna za jutarnje buđenje uz toplu kavu ili čaj....</desc> </programme> </tv> I need the .txt file to look like this: 201104130630 - 201104130800 JUTARNJI EXPRESS glazbeno-informativni program Glazbeno informativna emisija sa servisnim informacijama i jutarnjim temperaturama, idealna za jutarnje buđenje uz toplu kavu ili čaj.... Can someone please help me? thanks I'm trying to make a simple website where people register to my website. When the user doesn't fill anything inside the boxes they get a message "Please fill all required fields" on the register.php page On my local host require_once works good. It shows up.
But when i upload the files to my sever the require_once does not show up on the register.php It just refreshes and i dont get the message "Please fill all required fields"
This is the code that works in local host but not in a live server <?php require_once 'messages.php'; ?>
Here is my full code
Register page: <html> <?php require_once 'messages.php'; ?> <br><br> <form action="register-clicked.php" method="POST"> Username:<br> <input type="text" name="usernamebox" placeholder="Enter Username Here"> <br><br> Email:<br> <input type="text" name="emailbox" placeholder="Enter email here"> <br><br> Password:<br> <input type="password" name="passwordbox" placeholder="Enter password here"> <br><br> Confirm Password:<br> <input type="password" name="passwordconfirmbox" placeholder="Re-enter password here"> <br><br> <input type="submit" name="submitbox" value="Press to submit"> <br><br> </form> </html>
Register clicked <?php session_start(); $data = $_POST; if( empty($data['usernamebox']) || empty($data['emailbox']) || empty($data['passwordbox']) || empty($data['passwordconfirmbox'])) { $_SESSION['messages'][] = 'Please fill all required fields'; header('Location: register.php'); exit; } if ($data['passwordbox'] !== $data['passwordconfirmbox']) { $_SESSION['messages'][] = 'Passwords do not match'; header('Location: register.php'); exit; } $dsn = 'mysql:dbname=mydatabase;host=localhost'; $dbUser='myuser'; $dbPassword= 'password'; try{ $connection = new PDO($dsn, $dbUser, $dbPassword); } catch (PDOException $exception){ $_SESSION['messages'][] = 'Connection failed: ' . $exception->getMessage(); header('Location: register.php'); exit; }
messages.php <?php session_start(); if (empty($_SESSION['messages'])){ return; } $messages = $_SESSION['messages']; unset($_SESSION['messages']); ?> <ul> <?php foreach ($messages as $message): ?> <li><?php echo $message; ?></li> <?php endforeach; ?> </ul> Edited Wednesday at 12:49 AM by bee65 As the title above says im trying to use this code: Code: [Select] require_once("http://www.example.com/connect_file.php"); its giving this error: Warning: mysql_query() [function.mysql-query]: Access denied for user 'username'@'localhost' (using password: NO) in /template/header.php on line 56 if i was to just use this code it works fine: Code: [Select] require_once("./connect_file.php"); Just incase it makes a difference, im testing this on index.php, however the codes above are not inside index.php, instead they are inside my /templates/header.php file which is included at the top of index.php any ideas? Hello, I'm planning on making a website where people are able to upload files and directly link to them. Ideally, I want to keep the same file names that the people use when they upload the file. I was planning on keeping the directory that stored all of the files outside of the www directory and disable execute permissions. However, how would I avoid file overwriting with the same file name? I am trying to split large csv file into manageable files to upload to database, I wrote this code and it does the job but I need to speed it up to get around the 30 second time out in php can anyone help? Code: [Select] <?php $files = glob('*.txt'); foreach ($files as $file) { $handle1 = fopen($file, "r"); $size = filesize($file); if($size > 20000000){ $line=1; $handle2 = fopen($line.$file, "w"); while (($data = fgetcsv($handle1, 10000, ",")) !== FALSE) { $row = ($data[0]."[,]".$data[1]."[,]".$data[2]."[,]".$data[3]."[,]".$data[4]."[,]".$data[5]."[,]".$data[6]."[,]".$data[7]."[,]".$data[8]."[,]".$data[9]."[,]".$data[10]."[,]".$data[11]."[,]".$data[12]."[,]".$data[13]."[,]".$data[14]."[,]".$data[15]."[,]".$data[16]."[,]".$data[17]."[,]".$data[18]."[,]".$data[19]."[,]".$data[20]."[,]".$data[21]."[,]".$data[22]."[,]".$data[23]."[,]".$data[24]."[,]".$data[25]."[,]".$data[26]."[,]".$data[27]."[,]".$data[28]."[,]".$data[29]."[,]".$data[30]."[,]".$data[31]."[,]".$data[32]."[,]".$data[33]."[,]".$data[34]."[,]".$data[35]."[,]".$data[36]."[,]".$data[37]."[,]".$data[38]."[,]".$data[39]."[,]".$data[40]); if(strlen($row)>10) { $row = str_replace('"','',$row); $row = explode("[,]", $row); fputcsv($handle2, $row); $line++; if($line == 100000){ $handle2 = fopen($line.$file, "w"); } if ($line == 200000){ $handle2 = fopen($line.$file, "w"); } if ($line == 300000){ $handle2 = fopen($line.$file, "w"); } if ($line == 400000){ $handle2 = fopen($line.$file, "w"); } if ($line == 500000){ $handle2 = fopen($line.$file, "w"); } if ($line == 600000){ $handle2 = fopen($line.$file, "w"); } if ($line == 700000){ $handle2 = fopen($line.$file, "w"); } if($line == 800000){ $handle2 = fopen($line.$file, "w"); } if ($line == 900000){ $handle2 = fopen($line.$file, "w"); } if ($line == 1000000){ $handle2 = fopen($line.$file, "w"); } if ($line == 1100000){ $handle2 = fopen($line.$file, "w"); } if ($line == 1200000){ $handle2 = fopen($line.$file, "w"); } if ($line == 1300000){ $handle2 = fopen($line.$file, "w"); } if ($line == 1400000){ $handle2 = fopen($line.$file, "w"); } if ($line == 1500000){ $handle2 = fopen($line.$file, "w"); } if ($line == 1600000){ $handle2 = fopen($line.$file, "w"); } if ($line == 1700000){ $handle2 = fopen($line.$file, "w"); } if ($line == 1800000){ $handle2 = fopen($line.$file, "w"); } if ($line == 1900000){ $handle2 = fopen($line.$file, "w"); } if ($line == 2000000){ $handle2 = fopen($line.$file, "w"); } if ($line == 2100000){ $handle2 = fopen($line.$file, "w"); } } } } } fclose($handle1); fclose($handle2); ?>Thanks everyone Hi all, This is probably a very basic question, but it's the first time I've had to deal with it and I can't find a direct answer anywhere online. I have blocked direct access to a file that a user has uploaded in the Apache configuration and in the .htaccess file, so that the file is only accessible through a viewing (PHP) script, which will determine whether the access is allowed or not depending on several factors. What is the actual code I need to give access? Thanks! |