PHP - Php Code Can Not Read File From /var/tmp Folder Which Is Not Created By Apache
I am using apache web server on linux. I am using php for coding. My php code is not able to read the files from /var/tmp folder. If apache itself creates some files in /var/tmp folder then php code is able to read it. Why this permission denied issues are there though full access permissions are given to each file?
Similar TutorialsI am using apache web server on linux. I am using PHP for web designing. On web server, i want to show the configuration data by reading the ini file. I am creating this ini file from one php code itself. If this php code i run through linux terminal, the file is created with file and group owner as root.(i am having sudo rights on machine) Then if i try to read the ini file from my apache web server, it gives warning as failed to open stream: permission denied. I have tried changing the owner, and permissions to 777 of the file. Still it is not readable.
On the other hand, if i run the php code of ini file creation through web server, ini file is created with file and group owner as apche. and web server is able to read/ write the file.
But i want to create that file from root or some other user and later read/written by apache.
How to give this access permission?
I'm using the following code to create a folder from a text field and works fine. I would like to upload 3 files in the created folder. <?php // set our absolute path to the directories will be created in: $path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/'; if (isset($_POST['create'])) { // Grab our form Data $dirName = isset($_POST['dirName'])?$_POST['dirName']:false; // first validate the value: if ($dirName !== false && preg_match('~([^A-Z0-9]+)~i', $dirName, $matches) === 0) { // We have a valid directory: if (!is_dir($path . $dirName)) { // We are good to create this directory: if (mkdir($path . $dirName, 0775)) { $success = "Your directory has been created succesfully!<br /><br />"; }else { $error = "Unable to create dir {$dirName}."; } }else { $error = "Directory {$dirName} already exists."; } }else { // Invalid data, htmlenttie them incase < > were used. $dirName = htmlentities($dirName); $error = "You have invalid values in {$dirName}."; } } ?> <html> <head><title>Make Directory</title></head> <body> <?php echo (isset($success)?"<h3>$success</h3>":""); ?> <h2>Make Directory on Server</h2> <?php echo (isset($error)?'<span style="color:red;">' . $error . '</span>':''); ?> <form name="phpMkDIRForm" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Enter a Directory Name (Alpha-Numeric only): <input type="text" value="" name="dirName" /><br /> <input type="submit" name="create" value="Create Directory" /> </form> </body> </html> Hi, I've written a script for a client which creates a folder on the server using mkdir. The client wanted this folder to be created for them (don't ask why, it's complicated!), then they wanted to be able to FTP in and add files into the folder using FTP. The problem is that the script creates the file with a group of 99. When the client tries to FTP in and add their files, they get the following error: '550 Can't create directory: Permission denied', presumably because they're in a different group. What I need to be able to do is get the script to create a folder with a different group, so that my client can FTP their files into it. I thought I would be able to use PHP's chgrp after mkdir, as follows: mkdir($filepath, 0777) chgrp($filepath, 501); However then I get "Warning: chgrp() [function.chgrp]: Operation not permitted". I realise from reading the manual that I need to be a superuser to do this, which my web script obviously isn't. My question is, how can I get around this? Is there some setting in Apache that I can set? Thanks in advance for any help! Willo Hi all, I'm trying to echo all the files in the folder 'pics' <?php $dir = "pics/"; // Open a directory, and read its contents if (is_dir($dir)){ if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false){ echo '<img src="pics/' .$file . '" width="120px" height="120px" />'; } closedir($dh); } } ?>
The above code outputs the following. (there is only one image in the folder) So the code gets the image correctly and works with multiple images in the folder, but also produces two broken pathways at the beginning. <img src="pics/." width="120px" height="120px" /><img src="pics/.." width="120px" height="120px" /><img src="pics/j1.jpg" width="120px" height="120px" />
My question is why, I can't figure out what is happening. Any pointers or explanations would be appreciated. Cheers for your time.
Paul
Hi, how to let php read the url in folder form instead of querystring? e.g. www.example.com/index.php?post=123 www.example.com/post/123/ both is actually directed to the same page - index.php, but how to make it read like a folder when the physical path doesn't really exist? Day
I'm using Codeigniter and inside the framework I create a file with PHP code If I try to point to it, the web-server doesn't deliver due to permission issues.
All this is done in a 'register function' where I create some fields in a SQL
If I put the user credentials into the database 'by hand' and likewise when I
I'm pretty sure this issue has been existed before and I'd appreciate any help.
Thanks for your help in forward. Gee Edited August 17, 2020 by bogusHi guys, I've just started using xampp for php. My friend sent me the files i've attached below to see if apache is working for me, but i don't understand why they won't work together. Basically the .html file opens a simple login which works fine. When the password is typed in it should direct me to some links, but for some reason it doesn't. It does however look like the apache server is working fine - it could be something with the code i'm really not to sure. When i try to log in these are one set of the errors it gives me: Warning: file_get_contents(listlinks.array) [function.file-get-contents]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 8 Warning: sqlite_open() [function.sqlite-open]: unable to open database: /Applications/XAMPP/xamppfiles/htdocs/Test1/userlinks.sqlite in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 16 Warning: sqlite_query() expects parameter 1 to be resource, string given in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 20 Warning: sqlite_fetch_array() expects parameter 1 to be resource, null given in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 21 Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php: in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 25 Warning: sqlite_close() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/test1/userlinks.php on line 61 I've literally just started learning web scripting so i apologise for over-looking anything simple. The login.php file is also supposed to be .html aswel - i just changed it to upload. Thanks in advance, Josh. I have a page using forms to help build listing templates for eBay. I have a folder where I have hundreds of logos stored. I know the logo names but not their extensions. . . . I have to test each potential (jpg, jpeg, gif, png, etc.) until I guess right. Here is an example code for the web form:
<form action="extension_test2.php" method="post"> <p>Logo: <input name="e" value="" type="text" size="15" maxlength="30" /><p> <input name="Submit" type="Submit"/> </form> and the form's result: <? $e =$_POST['e']; if(!empty($e)) { echo '<img src="http://www.gbamedica...ebayimg/logos/'.$e.'">'; }; ?> Here is a link to the example: http://www.gbamedica...ension_test.php Use "olympus.jpg" for test. I am looking for code that can determine the file type and dynamically add the extension. Can it be done? This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=351056.0 I need to reach Win server, scan shared folder and find out what is last created file name on this folder, and than copy this file to local folder. BUT main problem is smb, never used it before, and this is what i came up with, but no luck.
require_once('smbclient.php'); $latest = null; $smbc = new smbclient ('//10.1.1.10/Share/Address Verification/', 'domain\\username', 'password'); if ($handle = opendir($smbc)) { $latest = null; while (($cur = readdir($handle) !== false)) { if ($latest == null || filectime($cur) > filectime($latest)) { $latest = $cur; } } closedir($handle); } return $latest;please help, returns Warning: opendir() expects parameter 1 to be string Hey guys,
I'm facing an issue compiling the above stack from a source code inside lxc using centos 6.5 as a domain OS.
[lxc@lxc1 httpd-2.4.9]$ ./configure --with-included-apr checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu configu configu Configuring Apache Portable Runtime library... configu configuring package in srclib/apr now checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu Configuring APR library Platform: x86_64-unknown-linux-gnu checking for working mkdir -p... yes APR Version: 1.5.1 checking for chosen layout... apr checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... configu error: in `/home/lxc/httpd-2.4.9/srclib/apr': configu error: cannot run C compiled programs. If you meant to cross compile, use `--host'. See `config.log' for more details configure failed for srclib/apr This problem has been detected by me when I replaced my desktop machine with new one and installed a centOS again. This such a problem never happened before using my old machine with the same version of OS and libvirt. Just to be clear, a new selinux policy into a "domain machine" has been created to be able to use the "dbus daemon" to all containers and if I try to complile this stack from source using the "domain os" this problem never happens at all. All "Development tools" is installed to this particular container, in case someone asks me why I get the following error message - "configu error: cannot run C compiled programs" Any ideas? Edited by jazzman1, 08 June 2014 - 01:37 PM. Hello, We've been working on a page that allows users to create their own avatar to be displayed on their page. We can get the script working but the only way to show the image is to save it to a temp folder, we want to just save the string in the database and let the php show this wehen required here are the file http://test.digitaldemocracy.org.uk/test_avatar.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="John Munro, Democratise Ltd" /> <meta name="copyright" content="Democratise Ltd 2010" /> <meta name="description" content="Digital Democracy -" /> <meta name="keywords" content=" add here" /> <meta name="robots" content="index, follow" /> <meta name="revisit-after" content="1 week" /> <meta http-equiv="Page-Exit" content="blendTrans(Duration=0.5)" /> <link rel="SHORTCUT ICON" href="http://www.digitaldemocracy.co.uk/favicon.ico" /> <title>Digital Democracy -</title> <link href="css/site.css" rel="stylesheet" type="text/css" /> <link href="css/basic.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" href="avatars/avatar.css" type="text/css" /> <script type="text/javascript" src="avatars/avatar.js"></script> <style type="text/css"> /*<![CDATA[*/ <!-- body { background-image: url(images/background_paper.jpg); background-repeat: repeat; } --> /*]]>*/ </style> <script type="text/javascript"> //<![CDATA[ var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-15681567-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); //]]> </script> </head> <body> <div id="wrapper"> <div id="inner_wrapper"> <div class="header"> <div class="header_logo"> <img src="images/header_logo.png" width="190" height="55" alt="Digital Democracy" /> </div> <div class="header_link"> Make a<br/>proposal </div> <div class="header_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="header_link"> View<br/>proposal </div> <div class="header_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="header_link"> Vote on top<br/>proposal </div> <div class="header_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="header_link"> View<br/>results </div> <div class="header_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="header_link_single_line"> Profile </div> <div class="header_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="header_link_single_line"> More </div> <div id="header_search_bar"> <form action="Search" method="post"> <input name="Search" type="text" value="Search" size="15" /> <input name="Submit" type="button" value="Go" /> </form> </div> <div class="header_login"> <span class="header_login_text">Login / Register</span> </div> </div> <div id="info"> <div id="chosen_avatar"> <!--<p> avatar to be shown here when completed only - image shown below is thee to reference the saved code</p>--> <p><img src="<?php if (!empty($image)) { echo $filename; } else { echo 'http://test.digitaldemocracy.org.uk/avatar_creator.php?avatar[background]=bg_08&avatar[body]=body_01&avatar[head]=head_01&avatar[eyes]=blank&avatar[mouth]=blank&avatar[moustache]=blank&avatar[glasses]=blank&avatar[male_hair]=blank&avatar[female_hair]=blank';} ?>" title="Your chosen avatar (assembled as a PNG image)" alt="Your chosen avatar (PNG image)" /></p> <p>Your chosen avatar</p> </div> <form action="http://test.digitaldemocracy.org.uk/avatar_creator.php" method="get"> <div id="avatar_section"> <div id="avatar_stack"> <p> <img src="avatars/bg_01.png" alt="" /><input name="avatar[background]" type="radio" value="bg_01" checked="checked" /> <img src="avatars/bg_02.png" alt="" /><input name="avatar[background]" type="radio" value="bg_02" /> <img src="avatars/bg_03.png" alt="" /><input name="avatar[background]" type="radio" value="bg_03" /> <img src="avatars/bg_04.png" alt="" /><input name="avatar[background]" type="radio" value="bg_04" /> <img src="avatars/bg_05.png" alt="" /><input name="avatar[background]" type="radio" value="bg_05" /> <img src="avatars/bg_06.png" alt="" /><input name="avatar[background]" type="radio" value="bg_06" /> <img src="avatars/bg_07.png" alt="" /><input name="avatar[background]" type="radio" value="bg_07" /> <img src="avatars/bg_08.png" alt="" /><input name="avatar[background]" type="radio" value="bg_08" /> <img src="avatars/bg_09.png" alt="" /><input name="avatar[background]" type="radio" value="bg_09" /> </p> <p> <img src="avatars/body_01.png" alt="" /><input name="avatar[body]" type="radio" value="body_01" checked="checked" /> <img src="avatars/body_02.png" alt="" /><input name="avatar[body]" type="radio" value="body_02" /> <img src="avatars/body_03.png" alt="" /><input name="avatar[body]" type="radio" value="body_03" /> <img src="avatars/body_04.png" alt="" /><input name="avatar[body]" type="radio" value="body_04" /> <img src="avatars/body_05.png" alt="" /><input name="avatar[body]" type="radio" value="body_05" /> <img src="avatars/body_06.png" alt="" /><input name="avatar[body]" type="radio" value="body_06" /> <img src="avatars/body_07.png" alt="" /><input name="avatar[body]" type="radio" value="body_07" /> <img src="avatars/body_08.png" alt="" /><input name="avatar[body]" type="radio" value="body_08" /> </p> <p> <img src="avatars/head_01.png" alt="" /><input name="avatar[head]" type="radio" value="head_01" checked="checked" /> <img src="avatars/head_02.png" alt="" /><input name="avatar[head]" type="radio" value="head_02" /> <img src="avatars/head_03.png" alt="" /><input name="avatar[head]" type="radio" value="head_03" /> <img src="avatars/head_04.png" alt="" /><input name="avatar[head]" type="radio" value="head_04" /> <img src="avatars/head_05.png" alt="" /><input name="avatar[head]" type="radio" value="head_05" /> <img src="avatars/head_06.png" alt="" /><input name="avatar[head]" type="radio" value="head_06" /> <img src="avatars/head_07.png" alt="" /><input name="avatar[head]" type="radio" value="head_07" /> <img src="avatars/head_08.png" alt="" /><input name="avatar[head]" type="radio" value="head_08" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[eyes]" type="radio" value="blank" checked="checked" /> <img src="avatars/eyes_1.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_1" /> <img src="avatars/eyes_2.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_2" /> <img src="avatars/eyes_3.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_3" /> <img src="avatars/eyes_4.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_4" /> <img src="avatars/eyes_5.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_5" /> <img src="avatars/eyes_6.png" alt="" /><input name="avatar[eyes]" type="radio" value="eyes_6" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[mouth]" type="radio" value="blank" checked="checked" /> <img src="avatars/mouth_1.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_1" /> <img src="avatars/mouth_2.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_2" /> <img src="avatars/mouth_3.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_3" /> <img src="avatars/mouth_4.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_4" /> <img src="avatars/mouth_5.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_5" /> <img src="avatars/mouth_6.png" alt="" /><input name="avatar[mouth]" type="radio" value="mouth_6" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[moustache]" type="radio" value="blank" checked="checked" /> <img src="avatars/moustache_01.png" alt="" /><input name="avatar[moustache]" type="radio" value="moustache_01" /> <img src="avatars/moustache_02.png" alt="" /><input name="avatar[moustache]" type="radio" value="moustache_02" /> <img src="avatars/moustache_03.png" alt="" /><input name="avatar[moustache]" type="radio" value="moustache_03" /> <img src="avatars/moustache_04.png" alt="" /><input name="avatar[moustache]" type="radio" value="moustache_04" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[glasses]" type="radio" value="blank" checked="checked" /> <img src="avatars/glasses_01.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_01" /> <img src="avatars/glasses_02.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_02" /> <img src="avatars/glasses_03.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_03" /> <img src="avatars/glasses_04.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_04" /> <img src="avatars/glasses_05.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_05" /> <img src="avatars/glasses_06.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_06" /> <img src="avatars/glasses_07.png" alt="" /><input name="avatar[glasses]" type="radio" value="glasses_07" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[hair 1]" type="radio" value="blank" checked="checked" /> <img src="avatars/m_hair_01.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_01" /> <img src="avatars/m_hair_02.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_02" /> <img src="avatars/m_hair_03.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_03" /> <img src="avatars/m_hair_04.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_04" /> <img src="avatars/m_hair_05.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_05" /> <img src="avatars/m_hair_06.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_06" /> <img src="avatars/m_hair_07.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_07" /> <img src="avatars/m_hair_08.png" alt="" /><input name="avatar[hair 1]" type="radio" value="m_hair_08" /> </p> <p> <img src="avatars/blank.png" alt="" /><input name="avatar[hair 2]" type="radio" value="blank" checked="checked" /> <img src="avatars/f_hair_01.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_01" /> <img src="avatars/f_hair_02.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_02" /> <img src="avatars/f_hair_03.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_03" /> <img src="avatars/f_hair_04.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_04" /> <img src="avatars/f_hair_05.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_05" /> <img src="avatars/f_hair_06.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_06" /> <img src="avatars/f_hair_07.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_07" /> <img src="avatars/f_hair_08.png" alt="" /><input name="avatar[hair 2]" type="radio" value="f_hair_08" /> </p> </div> </div> <p> </p> <p id="submit" > <input type="submit" value="Click here to save your personalised Avatar" /> </p> </form> <div id="hidden_spacer"> <p> </p> </div> </div> </div> </div> <div class="footer"> <div class="footer_content"> <div id="footer_democratise"> © Democratise Ltd </div> <div class="footer_link_single_line"> About us </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> Contact </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> Blog </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> Help </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> </div> <div class="footer_link_spacer"> <img src="images/header_link_spacer.png" width="5" height="55" alt="Digital Democracy - Link Spacer image" /> </div> <div class="footer_link_single_line"> Privacy </div> </div> </div> </body> </html> And the file that runs the php and creates the images is <?php # form inputs in the correct stacking order from bottom to top $form_fields = array('background', 'body', 'head', 'eyes', 'mouth', 'moustache', 'glasses', 'hair 1', 'hair 2'); ob_start(); if(!isset($_GET['avatar'])) die; validate_inputs($form_fields); $filename = create_avatar($form_fields); //ob_end_clean(); //echo "hello"; //$image = output_image(ob_get_clean()); $image_output = ob_get_contents(); //ob_end_clean(); //echo $image; //$image = ob_get_contents(); //$image="data:image/png;base64, base64_encode($image)"; $image = 'test.digitaldemocracy.org.uk' . $_SERVER['REQUEST_URI']; //$image = $_SERVER['REQUEST_URI']; //echo $image; function validate_inputs($inputs) { foreach($inputs as $item) { if((preg_match('@(\.|/)@', $_GET['avatar'][$item])) or (!is_file('avatars/'.$_GET['avatar'][$item].'.png'))) { die(); } } } function create_avatar($inputs) { while($inputs) { $layer = @imagecreatefrompng('avatars/'. ($file = $_GET['avatar'][array_shift($inputs)]). '.png') or die('I could not open the avatars/'.$file); $layerWidth = imageSX($layer); $layerHeight = imageSY($layer); if(!isset($slate)) { $slate = @imagecreatetruecolor($layerWidth, $layerHeight); } @imagecopy($slate, $layer, 0, 0, 0, 0, $layerWidth, $layerHeight); @imagedestroy($layer); } imagetruecolortopalette ($slate, false, 256); //header('Content-Type: image/png'); $filename = 'temp'. rand(1,50) . '.png'; imagepng($slate, $filename); //imagepng($slate); imagedestroy($slate); return $filename; } function output_image($image) { $hash = md5($image); if(isset($_SERVER['HTTP_IF_NONE_MATCH'])){ if($hash == trim($_SERVER['HTTP_IF_NONE_MATCH'], '"')){ header("HTTP/1.x 304 Not Modified"); header('Etag: "'.$hash.'"'); die(); } } //header('Etag: "'.$hash.'"'); //header('Content-Type: image/png'); //imagepng($image); //echo $image; //return $image; } //header ("Location:test_avatar.php?image=$image"); include 'test_avatar.php'; ?> If anybody can help us it would be very appreciated Thanks John Munro Democratise.org Hey, I'm writing an application that tracks attendance. There are multiple events ('events' table), in which members that are present will be found. (When an event file is uploaded, it has all members that attended the event, and adds the event entry in 'events', as well as adding each member to the 'attendance' table, with event_id(eid) and the 'did_attend' value as '1'. When the event is edited, it needs to find the other members that AREN'T in the events table, and add them to the 'attendance' table. When I use this code, it apparently keeps adding the same members. Will a LIMIT 1 stop this? I has about 65,000+ entries added before I stopped the execution of the script. Thanks! Code: [Select] $sql2 = mysql_query("SELECT * FROM members WHERE status=1 ORDER BY mid ASC"); while($row = mysql_fetch_assoc($sql2)){ $sql3 = mysql_query("SELECT * FROM attendance WHERE event='$eid' ORDER BY member ASC"); while($row2 = mysql_fetch_assoc($sql3)){ if($row2[mid] == $row[mid]){ // if the member is in the attendance db, skip }else{ //if member is not in attendance, write zero--- causing multiple entries (50,000+) $qry = mysql_query("INSERT INTO attendance (member,event,did_attend) VALUES ('$row[mid]','$eid','0')"); if(!$qry){ die("SQL: ".mysql_error()); }else{ $msg = "<br />Member ".$row[mid]." marked as absent."; } } } } I got a question im using izabi for me im one who loves the software. But there some quirks that they forgot to add when making the mail system. I was wondering how it would be possible to code in a peice of php where it says read after someone read the email. If you need a copy of the mail mail script let me know. I am very new to PHP and haven't wriiten an update program except in the class I took about 4 years ago using MYSQL.
The company I work for is using PDO so I am having a little bit of a learning curve.
I have a table with a checkbox at the end and I want to insert the records from the table into a new file I created called
OPPSHEDT
SHEDORD Order Number 14 Char
SHEDBORD BackOrder Number 2 Char
SHEDPKD Picked Cases 9,0 Decimal
SHEDSHP Shipped Cases 9,0 Decimal
I'm just not sure how to write the update program to read the array of records and run through the loop and insert the items checked. I saw some other examples on here and all over the internet but they were using mysql. I have a copy of the code to create my table below.
I'd appreciate the help if you can.
Thanks.
ShipEstimate.php 6.41KB
4 downloads
Hi again.... I'm working on a project that creates a profile page for the user (i.e. 'username.php') when they register. Because there are two ways to register, through Facebook and through the website itself, there has to be an if statement in this page that it crates as to which ID to use for that user. Because Facebook usernames are not unique, we must identify a user through their OAuth User ID which is a 10 digit number. When a user registers through the website itself, usernames are unique so their profile page can be ID'd by their username. Here's the code that creates that profile page: function createProfile($user) { $userFile = 'users/'.$result['oauth_uid'].'.php'; $fh = fopen($userFile, 'w') or die("can't open file"); $stringData = "<?php\n" . '$pageowner = "' . $result['oauth_uid'] . '";' . "\n" . 'include "profile.php";' . "\n?>"; fwrite($fh, $stringData); fclose($fh); } $user is the username passed to the function when it's called. Currently that is set to create a line of code in the new profile page ('userid'.php) that looks like this: <?php $pageowner = "100001745088506"; include "profile.php"; ?> I want to add an IF to that page that follows this structu if oauth_provider == facebook { $pageowner = "oauth_uid" } else { $pageowner = username } But I don't know how to write that he $stringData = "<?php\n" . '$pageowner = "' . $result['oauth_uid'] . '";' . "\n" . 'include "profile.php";' . "\n?>"; to make it show up in the page it creates. I want that if statement to be written IN the page that is created. I just don't know the syntax well enough yet to do that. Would somebody help me out or point me in the right direction? Thanks! Hi there, I have an xml file which actually hold the currency conversion information which I downloaded from xe.com In the xml, the currency section snapshot looks like this: <currency> <csymbol>EUR</csymbol> <cname>Euro</cname> <crate>0.713</crate> <cinverse>1.403 </cinverse> </currency> this is the conversion of USD to Euro. And it tells how much is 1USD gonna be in Euros. i.e 1 USD = 0.713 EUR I have a product page on my website having the rates shown in USD. For the visitor is accessing the page from Europe it has to show the converted price in Euros. My application can detect the visitors country if hes accessing the page from Europe so that is not a problem. I just need to read the xml file and display the converted price based on the rates in the xml file. How can I read the xml file and output the price in Euros based on the rate. Thank you. All comments and feedbacks are always welcome how can I make php read a file with ids in the format 23423423 32423423 23423454 56667777 and output each id to $id[]? [LIST=1] CSV File Reading Displaying CSV file: Clicking the Show Logfile.txt link at the top of the page should display the CSV records inside logfile.txt Displaying CSV records formatted : Clicking the Show logfile.txt Formatted should display the CSV records formatted in an HTML table is descending order (more recent records are at the top). Use this function to convert CSV records back to an array : fgetcsv() I have most of this done and the problem I'm having is trying to read what I put into the file. (I hard coded what should go into the file). Could you tell me what I'm doing wrong and what I should do to fix it? Code: [Select] <? if ($_POST['_act'] = 'csv'): $fp = fopen('logfile.txt', 'a'); while (($data = fgetcsv($fp, 1000, ",")) !== FALSE){ print_r($data); } fclose($fp); endif; if ($_SERVER['REQUEST_METHOD'] == 'POST'): if (empty($_POST['fullname'])): $errMsg['fullname'] = "Please fill in Your Full Name."; endif; if (ereg("'Mr\. '", $_POST['fullname']) == false): $errMsg['fullname'] = "Please fill in Your Full Name."; endif; print_r($errMsgs); echo count($errMsgs); if (count($disperrMsgs > 0)): $dispErrMsgs = true; else: $fp = fopen('logfile.txt', 'a'); $fputcsv($fp, array("test", "lol", "roool")); fclose($fp); $dispSuccessMsg = true; endif; endif; ?> <html> <head> <style type="text/css"> h1 {color:red} div.error {border: 1px solid red; margin: 20px; padding: 20px; width: 400px} table {border: 1px solid #CCC; margin: 20px; border-collapse: collapse;} td, th {border: 1px solid #DDD; padding: 2px} th {background-color:#363; color: white} td.error {color:red} div.success {border: 1px solid green; margin: 20px; padding: 20px; width: 400px; color:green} </style> </head> <body> <h1> Form Validation Lab with Reg Expressions </h1> <p><a href="<?= $_SERVER['PHP_SELF'] ?> ">Refresh This Page</a> | <a href="./logfile.txt">Show Logfile.txt</a> | <a href="<?= $_SERVER['PHP_SELF'] ?>?_act=csv">Show logfile.txt Formatted</a> <a href="<?= $_SERVER['PHP_SELF'] ?>?_act=clear">Clear logfile.txt </a></p> <? if ($dispErrMsgs): ?> <div class="error"> <p>There are errors in the code: </p> <ol> <? foreach($errMsg as $errMsgs ): ?> <li><?= $errMsgs ?></li> <? endforeach; ?> </ol> </div> <? endif; ?> <? if ($dispSuccessMsg): ?> <div class="success"> <p>Thank you for your submission. </p> </div> <? endif; ?> <form action="<?= $_SERVER['PHP_SELF'] ?>" name="getstuff" method="post" > <input type="hidden" name="_act" value="post"> <table cellspacing = "0"> <tr> <th width="78">Full Name:</th> <td width="184"><input name="fullname" type="text" class="textbox" value="<? $_POST['fullname']; ?>" size="20" ></td> <td width="626" >Salution of Mr. or Mrs. followed by two text strings separated by any number of spaces. </td> </tr> <tr> <th>Street:</th> <td><input name="street" type="text" class="textbox" value="<? $_POST['street']; ?>" size="30"></td> <td >2 or 3 digit number followed by a text string ending with Street or Road separated by any number of spaces. </td> <tr> <th>Phone:</th> <td><input name="phone" type="text" class="textbox" value="<? $_POST['phone']; ?>" size="20"></td> <td >10 digits, first 3 digits have optional parentheses, either side of digits 456 are optional space, dot or hyphen. </td> </tr> <tr> <th>PostalCode:</th> <td><input name="postcode" type="text" class="textbox" value="<? $_POST['postcode']; ?>" size="8" maxlength="8"></td> <td > Postal Code: Char Char Digit Hyphen/space Char Digit Digit (No XYZ or 0's. Case insensitive. )</td> </tr> <tr> <th>Email:</th> <td><input name="email" type="text" class="textbox" value="<? $_POST['email']; ?>" size="25" maxlength="40"></td> <td > Must accept as a minimum : a@b.com</td> </tr> </table> <input name="reset" type='button' class="button" value='RESET' onClick="location.href = location.href"> <input name="_submit" type="submit" class="button" value="Submit me now!!!" > </form> <p id="notice">Everything below here is for testing purposes Don't remove this from your lab as I will use these buttons to fill your form with good and bad data as I mark it.</p> <script> az=document.getstuff; function goodstuff(){ az.fullname.value=" Mr. Joe Smith "; az.street.value="135 Fennell Road "; az.phone.value="905-575.1212"; az.postcode.value="Ln9-T23"; az.email.value="jsmith@gov.ca"; } function goodstuff2(){ az.fullname.value=" Mrs. Josephine Smith "; az.street.value=" 13 Fennell Street"; az.phone.value=" (905)-575.1212 "; az.postcode.value=" Ln9 T23"; az.email.value=" jsmith@gov.ca "; } function badstuff(){ az.fullname.value="Miss Josephine Smith"; az.street.value="1 Somewhere Avenue"; az.phone.value="905575122"; az.postcode.value="Z8N 3T2"; az.email.value="jsmith$gov#ca"; } function badstuff2(){ az.fullname.value=" Joe Smith "; az.street.value=" 1392 Fennell Street"; az.phone.value="[905] 575-1212"; az.postcode.value=" Ly9 T20"; az.email.value=" @jsmith$gov#ca"; } function goodandbad(){ az.fullname.value="Mrs. Joe"; az.street.value=" 135 Fennell Avenue West"; az.phone.value="905:5751212"; az.postcode.value=" L99-T23"; az.email.value=" jsmith@.gov.ca "; } </script> <form> <input type=button class="button" onClick="goodstuff();" value="Fill form with good values " length=100 > <input type=button class="button" onClick="goodstuff2();" value="Fill form with good values 2 " > <input type=button class="button" onClick="badstuff();" value="Fill form with BAD values "> <input type=button class="button" onClick="badstuff2();" value="Fill form with BAD values 2 "> <input type=button class="button" onClick="goodandbad();" value="Fill form with Good and BAD values 2"> <br> </form> </BODY> </HTML> Hello, I'm trying to have my index.php to open/run another test.php file. I'm having my own server that I play with, that I run Ubuntu on. So the index.php are located at /var/www/ directory, but I want to run a file that are located at /testing/test.php The final test.php is file for showing pictures, and I don't want to out all the pictures under the /var/www/ location. It's alot of photos. I don't know much about php but I have been trying this: <?php header("Location: /var/www/testing/test.php"); //These below are desperat old tries. //header("Location: ./testing/test.php"); //header("Location: ../testing/test.php"); //$handle = fopen("/privat/Web_pictures/test.php", "r"); //"/testing/test.php" // header("Location: ./test.php"); //This one actually works, but I'm still in the wrong folder (/var/www/) echo "test "; // NN4 requires that we output something... exit(); ?> Thankful for help! |