PHP - Is There A Way To Detect Running A File From A Local Drive.
Similar TutorialsI am new to php and starting to write my first programs. I have a laptop (my local pc) and I am wondering if there is some kind of php-interpreter available so I can test them out on my local machine without having to upload them to my website? Is there anyway I can avoid having to install a web-sever on my machine? Is there an all-in-one php interpreter? (someone suggested something called Xampp, - is this the best?) thanks,, Is there a way to write a file to a directory on my network? I tried creating a shortcut called automated and pointed it to the network path. I also set up a virtual directory called automated in IIS and still could not make it work. I gave it read and write permissions. error Warning: fopen(C:\Inetpub\wwwroot\dompdf\automated\resource.pdf) [function.fopen]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\date.php on line 69 Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 70 Warning: fclose() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 71 code Code: [Select] require_once("dompdf/dompdf_config.inc.php"); $html = '<html><body>'. '<p>Put your html here, or generate it with your favourite '. 'templating system.</p>'. '</body></html>'; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); $pdfoutput = $dompdf->output(); $filename = "C:\\Inetpub\\wwwroot\\dompdf\\automated\\resource.pdf"; $fp = fopen($filename, "a"); fwrite($fp, $pdfoutput); fclose($fp); Folks,
I am building a membership script for 21 months now!!! That long!!!
Not pasting the whole script as really long. Would do your head in. if($_SERVER["REQUEST_METHOD"] == "POST") { if(!isset($_FILES["id_verification_video_file"])) //REtype { echo "no isset"; } else { $id_verification_video_file = $_FILES['id_verification_video_file']; //REtype //Feed Id Video Verification File Upload Directory Path. $directory_path = "uploads/videos/id_verifications/"; //Make Directory under $user in 'uploads/videos/id_verifications' Folder. if(!is_dir("$directory_path" . "$user")) { $mode = "0777"; mkdir("$directory_path" . "$user", "$mode", TRUE); //Thanks Requinix for my "$mode" typo hint. } //Grab Uploading File details. $Errors = Array(); //SHOULD I KEEP THIS LINE OR NOT ? $file_name = $_FILES["id_verification_video_file"]["name"]; $file_tmp = $_FILES["id_verification_video_file"]["tmp_name"]; $file_type = $_FILES["id_verification_video_file"]["type"]; $file_size = $_FILES["id_verification_video_file"]["size"]; $file_error = $_FILES['id_verification_video_file']['error']; //Grab File Extension details. $file_extension = pathinfo($file_name, PATHINFO_EXTENSION); if(file_exists('$directory_path' . '$user/' . '$file_name')) { $Errors[] = "Error: You have already uploaded a video file to verify your ID!"; exit(); } else { //Feed allowed File Extension(s). $allowed_file_extensions = array("mp4" => "video/mp4","wmv" => "video/wmv"); //Feed allowed file size. $max_file_size_allowed_in_bytes = 1024*1024*100; //Allowed limit: 100MB. $max_file_size_allowed_in_kilobytes = 1024*100; $max_file_size_allowed_in_megabytes = 100; $max_file_size_allowed = "$max_file_size_allowed_in_bytes"; //RETYPE //Verify File Extension. if(!array_key_exists($file_extension,$allowed_file_extensions)) die("Error: Select a valid video file format. Select an MP4 or WAV file."); //Verify MIME Type of the file. elseif(!in_array($file_type,$allowed_file_extensions)) { echo "Error:<font size ='5' font color ='red'><b>There was a problem uploading your video file $file_name! Make sure your file is an MP4 or a WAV file. You may try again now.</b></color></size>"; //THANKS TO REQUINIX FOR BRINNGING IT TO MY ATTENTION I AM STILL PROCESSING THE SCRIPT AFTER THIS LINE WHEN I SHOULD NOT. exit(); } //Verify File Size. Allowed Max Limit: 100MB. elseif($file_size>$max_file_size_allowed) die("Error: Your Video File Size is larger than the allowed limit of: $max_file_size_allowed_in_megabytes."); //Fixed variable name typo. Thanks to Requinix & Simon JM. //Move uploaded File to newly created directory on the server. move_uploaded_file("file_tmp","$directory_path" . "$user/" . "$file_name"); //Notify user their File was uploaded successfully. echo "<font size ='5' font color ='red'><b>Your Video File \"$file_name\" has been uploaded successfully! You will get notified once your Id has been verified successfully.</b></color></size>";
Can you spot my coding error ? I have a made a section on my site where I can upload files to a specific directory, rename them and delete them. So I don't have to go through a FTP program. When renaming and deleting a file I connect using FTP commands with PHP, except when uploading. When uploading it gets the file that has been uploaded from the form on the page before which has its own code using <input type="file"> to search for a local file, then when submit is clicked it uploads it. Then on my PHP script it moves that file from the temp upload folder to the actual site. Bottom line is, is there any way I can make a button that opens a file browser on the users PC and returns the filepath chosen? So I can use FTP to upload the file rather than the form? Why does the following code not detect the following file? After I select a file and I click upload, it goes back to the upload form. <?php include_once("includes/config.php"); //grab their type if(!$_COOKIE['user']) { //they are a guest $info = "Guest"; } else { //they are a user $info = $_COOKIE['user']; } if(!$_FILE['file']) { $content = '<form action="submit.php" method="post" enctype="multipart/form-data"> <label for="file">SELECT SKIN:</label> <input type="file" name="file" id="file" /> <input type="submit" name="submit" value="Submit" /> </form>'; } else { if($_FILES['file']['error'] > 0) { $content = "There was an error trying to upload the skin ".$_FILES['file']['name'].".".$_FILES['file']['error']; } } ?> <html> <head> <title><?php $title; ?></title> <link rel="stylesheet" type="text/css" href="theme/style.css" /> </head> <body> <div id="header"> MCSkins </div> <?php echo "Submitting as: ".$info."<br/><br/>".$content; ?> </body> </html> I'm not fluent in php, but I think this should be an easy fix for someone who is. Basically, I have a Wordpress theme that auto generates the images from posts in each slide of the feature slider on the homepage. Goal: for php to remove the css border around the image if it is a .png file Purpose: I want borders on photos in the feature slider, but no borders on images with transparent backgrounds... like free floating logos. So I figured I could use an if/else statement to determine if the file has a .png extension... if it does then it inserts the html style to remove the border. Here is the original code from the theme where it gets the image Code: [Select] <a href="<?php echo($arr[$i]["permalink"]); ?>" title="<?php printf(__('Permanent Link to %s', 'TheCorporation'), $arr[$i]["fulltitle"]) ?>"> <?php print_thumbnail($arr[$i]["thumb"], $arr[$i]["use_timthumb"], $arr[$i]["fulltitle"] , $width, $height, 'thumb'); ?> </a> Here is what I was trying to get to work.. I tried taking the variable for $file from the code I assumed was populating the image path Code: [Select] <?php $file = `print_thumbnail($arr[$i]["thumb"]`; $ext = `pathinfo($file, PATHINFO_EXTENSION)`; ?> <a <?php if($ext == ".png") echo ?>style="border:none 0px !important;" <?php ; else null; ?> href="<?php echo($arr[$i]["permalink"]); ?>" title="<?php printf(__('Permanent Link to %s', 'TheCorporation'), $arr[$i]["fulltitle"]) ?>"> <?php print_thumbnail($arr[$i]["thumb"], $arr[$i]["use_timthumb"], $arr[$i]["fulltitle"] , $width, $height, 'thumb'); ?> </a> Any help would be appreciated. Thanks. Hey everyone, I have an SQL file called "Cype.sql" and I was wanting to have it run when the install feature is going on. However I can't seem to figure out why exactly the code is not working. is it possible to have it run without getting too in depth the PHP coding? I'm not OOP Literate yet. //Connection is opened //While in installation file $sqlFile = "Cype.sql"; if(!file_exists($sqlFile)){ echo "File not found"; } else{ $openFile = fopen($sqlFile, "r"); $tryQuery = mysql_query($openFile); } Now obviously, I'm not the best coder. I've been out of the works of PHP for quite some time now as well. However, I have researched it and found no answers to my issue. Any help would be greatly appreciate. Thank you. This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=305914.0 This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=347581.0 Hi there, Can anybody help me to write php/javascript code which will allow users to open files directly from web browser into desktop application? Here is the specification: I have a photo editing business with many people working in Photoshop. I am currently developing a web based application (joblist) using Javascript and PHP which should allow the photoshop designers to browse and open files/images directly from joblist/web browser into photoshop. The reason I want this instead of browsing folder is that I have a database where I store who worked on which file, when and how long it took. The concept is that, designers will select a file and click on start, as soon as they click on start the original file will open in Photoshop and there will be an entry into database (using PHP). Once they finish the task they will close the file and click on Finish button. My joblist application will be published in a local server and the file will be open on a local network, so when they save the file it will be saved where the source file is located in (local server). The application should work in both PC and Mac. I have already done all other part of the application except file opening directly from browser to desktop application functionality. Anybody can help me to write the code (PHP or Javascript) which can open the file from browser (local server) directly into desktop application e.g. PHotoshop or Illustrator? Thank you very much I look forward to someone's real help! Best regards Mr. Sumon Hello Everyone, I am on windows server and In my ini file server time zone declared as below
[server_settings] but my application installed on another timezone eg: 'America/Los_Angeles' time zone. using date_default_timezone_get() i am always getting Europe/London timezone as it's declared in ini file. How to get local timezone(wherever application is installed) here? Thanks Krish Hi all I was trying to connect to a database which is running on an external host. So i thought i try the stuff below. That didn't work. Is it possible that the host has disabled external connection or something? I tried to add http:// before the domain, but no succes either Code: [Select] <?php $dbc = mysqli_connect('db87654321.somedomain.com','user','pass','database')// this is line 5 or die(mysqli_error($dbc)); echo 'connected'; ?> it gave the following error: Quote Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2005): Unknown MySQL server host 'db87654321.somedomain.com' (11004) in H:\xampp\htdocs\databasetestfile.php on line 5 P.s. the script worked when upload to the server. P.p.s is there something i should be carefull with when connection to an external database? I have a scenario in PHP, i need a smart way: 1. I run one process on background forever, scheduler.php - done 2. User on the web submit their task in DB to be processed by the above process(scheduler.php) - done 3. scheduler.php read the db after every 1 sec, looking for user's task. Problem: Ideally, if it founds like 10 or more tasks it should process them concurently(in parallel)..i.e it should not wait one task to be fully executed so as to run the next one as one task might take a very long time to be fullu executed. I would do like exec("nohup php <path>/file_name.php >> /dev/null 2>&1 &"), but if i have alot of tasks this will create zombie processes. Any smart way to do this will be highly appreciated! Not sure if I'm putting this in the correct spot, but, Can anyone give me a link or an idea of how to fix Drive-By downloads I have on a site I have created? Everything I search for online brings up how to repair an issue someone may have gotten on their computer from a drive-by download, but nothing talks about repairing it on the actual site itself. I don't have any injections or anything, but doing a check on my site from the norton site shows that I have 1 Threat and it's on a contact form page due to Drive-By Downloads, is this from the php tags on the form not being stripped or from the javascript possibly? Some old lady submitted my site to http://safeweb.norton.com/report/show?url=gotmine.com, now I have to fix it I guess. Any help would be great, Thanks. In ubuntu 18.10 , i created a folder name db in the external usb hard dirve changed the ownership to the www-data the apache2 server and set the permissions to 777 , i run this php code and get the permission error: <php chdir('/media/user/e46cafba-2656-4e42-b1c9-6417f28839df/db/'); system('./rs'); ?> but the php code cannot change to the dir and get the error: [21-Feb-2019 10:43:26 UTC] PHP Warning: chdir(): Permission denied (errno 13) in /home/user/www/html/rse4db.php on line 5
This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=346654.0 hello dear php-experts how to testrun a drive with command-line? note: i had several blank screens during the last week does this somewhat have to do with the hard-drive? which tests can be done? how to install linux on a netbook without a dvd-drive.
i think about buying a new notebook there are several ones that come up to mind. question should i buy one without a dvd-drive? there are many many out there - eg the ACER Aspire V3-371-36MA but many of them do not have a dvd. question: how can i install suse linux on this notebook and how should / could i do an update. well - do you reccomend to buy a notebook with a. a dvd drive - is this mandantory b. a notebook with more than 4 gb ram!? love to hear from you hello dear php-experts good day
well at the moment i try to figure out how to test the healthy of my harddrive.
How do I use SMART tools to check on my notebooks hard drive? That is the question of the day for me. i want to run a SMART-Test on my notebook to test the harddrive. i have opensuse 13.1 on the machine: and the SMART-Tools are installed. SMART (Self-Monitoring, Analysis, and Reporting Technology) is a technology included in most hard drives today. Short test: According to the documentation, this command can be given during normal system operation (unless run in captive mode). i can run the test: smartctl --test=short /dev/sda1 see here what happens: martin@linux-70ce:~> su Passwort: linux-70ce:/home/martin # smartctl --test=short /dev/sda1 smartctl 6.2 2013-07-26 r3841 [i686-linux-3.11.10-25-desktop] (SUSE RPM) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org === START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION === Sending command: "Execute SMART Short self-test routine immediately in off-line mode". Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful. Testing has begun. Please wait 2 minutes for test to complete. Test will complete after Tue Jan 20 00:29:16 2015 Use smartctl -X to abort test. linux-70ce:/home/martin # hmm - this seems to be a short (quick ) test. But i have to wait to see the results. Question: do they come to the terminal - are they are shown in the terminal? btw: i also can run the Long Test: The long test can also be run on a live system, and will do a lot deeper testing on the device, however it will take significantly longer to finish. smartctl --test=long /dev/sda smartctl well - how can i run tests on all the partitions: is this possible to do this with only one single step? cfdisk (util-linux 2.23.2) Festplatte: /dev/sda GrM-CM-6M-C~_e: 320072933376 Bytes, 320,0 GB KM-CM-6pfe: 255 Sektoren pro Spur: 63 Zylinder: 38913 Name Flags Part. Typ Dateisystemtyp [Bezeichner] GrM-CM-6M-C~_e (MB) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PrimM-CM-$re Freier Bereich 164,63 * sda4 PrimM-CM-$re LVM2_member 1990,20 * sda2 PrimM-CM-$re LVM2_member 21475,89 * sda5 NC Logische swap 2155,88 * sda6 NC Logische ext4 21475,89 * sda7 NC Logische ext4 272799,63 * Pri/Log Freier Bereich 10,84 * but what can i do if i want to Get it all: there are options to do that - getting it all: The next and last command will output all the information the drive can possibly give. In the response below I have selectively removed a lot of output because there is a lot information to go through. My main point is the command and something I will get to in just a second. smartctl -a /dev/sda Device Mode since the harddrive has differnet partitions - the question arises: how to test all at once? question: which way to get the drive tested in one single step are there options to do that - getting it all in a single command. look forward to any and all hints and help greetings PHP 5.3 on Windows 7 running IIS 7 Hey... when using: Code: [Select] $dom = DOMDocument::load( 'p:\\WebTest\\test1.xml' );where P:\ is a mapped drive, I'm getting: Code: [Select] Warning: DOMDocument::load(): I/O warning : failed to load external entity "file:///p:/WebTest/test1.xml" in ... I've also tried using / instead of \\. If it's on c:\, it works fine, but I can't get the absolute path to work to a mapped drive. If I use \\\ip\\folder\\file (or //ip/folder/file) the page never loads. Any thoughts on getting DOMDocument to look at a shared network location on Windows? Thanks! |