PHP - Upload Failed
Hi guys,
I'm getting the following error when i try to upload an image: Code: [Select] Warning: copy() [function.copy]: open_basedir restriction in effect. File(C:\Windows\Temp\phpAF5B.tmp) is not within the allowed path(s): (C:\Inetpub\vhosts\truvibefm.com\httpdocs\) in C:\Inetpub\vhosts\truvibefm.com\httpdocs\testarea\imageupload\upload.php on line 25 Out of commonsense i check the open_basedir in php.ini and it is set too: C:\Inetpub\vhosts\truvibefm.com\httpdocs Thanks for you time! J My php script is: Code: [Select] <?php $SafeFile = $HTTP_POST_FILES['ufile']['name']; $SafeFile = str_replace("#", "No.", $SafeFile); $SafeFile = str_replace("$", "Dollar", $SafeFile); $SafeFile = str_replace("%", "Percent", $SafeFile); $SafeFile = str_replace("^", "", $SafeFile); $SafeFile = str_replace("&", "and", $SafeFile); $SafeFile = str_replace("*", "", $SafeFile); $SafeFile = str_replace("?", "", $SafeFile); $uploaddir = "uploads/"; $path = $uploaddir.$SafeFile; if($ufile != none){ //AS LONG AS A FILE WAS SELECTED... if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)){ //IF IT HAS BEEN COPIED... //GET FILE NAME $theFileName = $HTTP_POST_FILES['ufile']['name']; //GET FILE SIZE $theFileSize = $HTTP_POST_FILES['ufile']['size']; if ($theFileSize>999999){ //IF GREATER THAN 999KB, DISPLAY AS MB $theDiv = $theFileSize / 1000000; $theFileSize = round($theDiv, 1)." MB"; //round($WhatToRound, $DecimalPlaces) } else { //OTHERWISE DISPLAY AS KB $theDiv = $theFileSize / 1000; $theFileSize = round($theDiv, 1)." KB"; //round($WhatToRound, $DecimalPlaces) } echo <<<UPLS <table cellpadding="5" width="300"> <tr> <td align="Center" colspan="2"><font color="#009900"><b>Upload Successful</b></font></td> </tr> <tr> <td align="right"><b>File Name: </b></td> <td align="left">$theFileName</td> </tr> <tr> <td align="right"><b>File Size: </b></td> <td align="left">$theFileSize</td> </tr> <tr> <td align="right"><b>Directory: </b></td> <td align="left">$uploaddir</td> </tr> </table> UPLS; } else { //PRINT AN ERROR IF THE FILE COULD NOT BE COPIED echo <<<UPLF <table cellpadding="5" width="80%"> <tr> <td align="Center" colspan="2"><font color=\"#C80000\"><b>File could not be uploaded</b></font></td> </tr> </table> UPLF; } } ?> Similar TutorialsThe Script:
<?php if (isset($_POST['submit'])) { $j = 0; //Variable for indexing uploaded image $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded images for ($i = 0; $i < count($_FILES['file']['name']); $i++) {//loop to get individual element from the array $validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of image $j = $j + 1;//increment the number of uploaded images according to the files in array if (($_FILES["file"]["size"][$i] < 100000) //Approx. 100kb files can be uploaded. && in_array($file_extension, $validextensions)) { if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {//if file moved to uploads folder echo $j. ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>'; for ($i = 0; $i < count($_FILES['file']['name']); $i++) { $tqs = "INSERT INTO images (`original_image_name`, `image_file`, `date_created`) VALUES ('" . $_FILES['file']['name'][$i] . "', '" . $new_image_name . "', now())"; $tqr = mysqli_query($dbc, $tqs); } // To create the thumbnails. function make_thumb($src, $dest, $desired_width) { /* read the source image */ $source_image = imagecreatefromjpeg($src); $width = imagesx($source_image); $height = imagesy($source_image); /* find the "desired height" of this thumbnail, relative to the desired width */ $desired_height = floor($height * ($desired_width / $width)); /* create a new, "virtual" image */ $virtual_image = imagecreatetruecolor($desired_width, $desired_height); /* copy source image at a resized size */ imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height); /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); } $src = $target_path; $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/"; $desired_width = 100; make_thumb($src, $dest, $desired_width); } else {//if file was not moved. echo $j. ').<span id="error">please try again!.</span><br/><br/>'; } } else {//if file size and file type was incorrect. echo $j. ').<span id="error">***Invalid file Size or Type***</span><br/><br/>'; } } } ?>With this: $dest = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/thumbs/";I get this error message: Warning: imagejpeg(C:/xampp/htdocs/gallerysite/multiple_image_upload/thumbs/): failed to open stream: No such file or directory in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49With this: $dest = "http://localhost/gallerysite/multiple_image_upload/thumbs/";I get this error message: Warning: imagejpeg(http://localhost/gallerysite/multiple_image_upload/thumbs/): failed to open stream: HTTP wrapper does not support writeable connections in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49When I try deleting the "thumbs" folder and then try to upload an image, then I get this error message: Warning: imagejpeg(C:/xampp/htdocs/gallerysite/multiple_image_upload/thumbs/): failed to open stream: Invalid argument in C:\xampp\htdocs\gallerysite\multiple_image_upload\upload.php on line 49The spot of line 49 is this, at the spot where the script creates the thumbnails: /* create the physical thumbnail image to its destination */ imagejpeg($virtual_image, $dest); }Also, with this part right here I am not getting an error message, which means that this part works fine in comparison: $target_path = $_SERVER['DOCUMENT_ROOT'] . "/gallerysite/multiple_image_upload/uploads/"; //Declaring Path for uploaded imagesThe script itself works fine. The script also uses javascript for multiple image upload. I am using XAMPP. The folder "thumbs" is set to "read-only", when I try to uncheck the "read-only" option in the properties in Windows then it sets itself back again to "read-only". Then again, the script works fine when it comes to the "uploads" folder. This is mentioned in comparison to the "thumbs" folder. Any suggestions on how to solve this? EDIT: I am using XAMPP. The folder "thumbs" is set to "read-only", when I try to uncheck the "read-only" option in the properties in Windows then it sets itself back again to "read-only". I am wondering if I would have issue that the option sets itself back again with Linux? Edited by glassfish, 11 October 2014 - 05:35 PM. Hey! I am trying to get a database table of users but am running into the error: Warning: file_get_contents(http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=user_nodes&user=68583) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 in get_user_from_parameter(nabble:utilities.naml:890) - <n.get_user_from_parameter.as_user_page.do/> - public v in C:\xampp\htdocs\website4js\stanford\loadUsernames.php on line 32 I have looked it up and it may be a security thing...The urls I am getting are http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=user_nodes&user=68583 but the error adds an nodes& part that screws it up. Any way around this? Code: [Select] <?PHP $maxPage = 0; $mainPage = "http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=app_people&node=136"; $mainContent = file_get_contents($mainPage); $pattern = "/(?<=\"Page )\d\d+/"; preg_match_all($pattern, $mainContent, $pageNumb); //find the max page for($i=0;$i<sizeof($pageNumb[0]);$i++) { if($pageNumb[0][$i] > $maxPage) { $maxPage = $pageNumb[0][$i]; } } //echo('Max page is: '.$maxPage.'\n'); //Get an array of all the pages $pages = array(); for($i=1;$i<$maxPage;$i++) { $pages[$i] = "http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=app_people&node=136&i=".($i*20); } //print_r($userPages); //Get personal page urls and add to MySQL mysql_connect("localhost" , "root") or die("Cant connect"); mysql_select_db("protegeusers") or die("Cant find database"); foreach($pages as $url) { $urlContents = file_get_contents($url); $pattern = "/http:\/\/protege-ontology-editor-knowledge-acquisition-system\.136\.n4\.nabble\.com\/template\/NamlServlet\.jtp\?macro=.+;user=\d+/"; preg_match_all($pattern, $urlContents, $personalPage); foreach($personalPage as $user) { for($i=0; $i<sizeof($user);$i++) { [color=green]$userContents = file_get_contents($user[$i]);[/color] $pattern1 = "/user\/SendEmail\.jtp\?type=user.+;user=\d+/"; $pattern2 = "/(?<=\">Send Email to ).+(?=<)/"; preg_match_all($pattern1, $userContents, $userEmail); preg_match_all($pattern2, $userContents, $username); [color=green]print_r($username); print_r($email);[/color] //$query = "INSERT INTO users (username, userurl) values ('$userName','$userUrl')"; //mysql_query($query); } } } ?> I am trying to figure how to code around this. I have a DOM scraper function that pulls urls from my database, opens the page, scrapes the data, and then moves onto the next URL to scrape. my issue is that if the page fails to load the script bombs and I have to restart it again. Trying to figure out how if the Code: [Select] $html->find('div[class="itemHeader address"]') as $div fails to open the page it just skips the DOM inspection. Here is my error... Failed to open stream: HTTP Request failed. Here is where I am at with my script.... Code: [Select] mysql_select_db("scraped") or die(mysql_error()); $result = mysql_query("SELECT PKEY, URL, HASSCRAPED, SHOULDSCRAPE FROM CRAWLED WHERE SHOULDSCRAPE ='1' AND HASSCRAPED = '0'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { mysql_query("UPDATE CRAWLED SET CRAWLED.HASSCRAPED = '1' WHERE CRAWLED.URL = '" . $row['URL'] . "'"); $html = file_get_html($row['URL']); foreach($html->find('div[class="itemHeader address"]') as $div) { foreach($div->find('a') as $element){ $CleanData = CleanData($element->innertext); if (strlen($CleanData[0]) > 5){ mysql_query("INSERT INTO SCRAPED (ADDR1, CITY, STATE, ZIP, URL, DATE) VALUES ('" . $CleanData[0] . "','" . $CleanData[1] . "','" . $CleanData[2] . "','" . $CleanData[3] . "','". $row['URL'] . "','". date( 'Y-m-d H:i:s ' ) ."')"); } } } $html->clear(); unset($html); unset($CleanData); } function CleanData($data) { $NewData = trim($data); $NewData = str_replace("<em>", "", $NewData); $AddrCityStateZip = explode("</em>",$NewData); $CityStateZip = explode(",",$AddrCityStateZip[1]); $StateZip = explode(' ',$CityStateZip[1]); $NewDataArray = array ($AddrCityStateZip[0], $CityStateZip[0], $StateZip[1], $StateZip[2]); return $NewDataArray; unset($NewData); unset($AddrCityStateZip); unset($CityStateZip); unset($StateZip); } mysql_close($link); echo 'Scraping has compleated without error'; I have code written for image uploading, but it doesn't allow multiple images on a single upload, and doesn't re-size. Anyone willing to share a good upload script that will do the following?: -Allow multiple image uploads (10+ per submission), -Re-size images on upload, and -Rename images. Thanks Brett Hi everyone, I have a page that i use to upload images to my website, i got a bit fed up of uploading one at a time so i decided to add multiple file fields to the form to upload multiple images at the same time. Im having a few problems, iv read up he http://www.php.net/manual/en/features.file-upload.multiple.php and it seems all i have to do is add [] to the form names to turn them into arrays. However when i come to upload the images, i keep getting the "$error[] = "Incorrect format!...." error from the code below. I cant seem to figure out what the problem is. Could anybody please point me in the right direction? <?php session_start(); $id = $_SESSION['id']; $connect = mysql_connect("localhost","leemp5_admin","p7031521"); mysql_select_db("leemp5_database"); $query = mysql_query("SELECT * FROM users WHERE id='$id'"); $row = mysql_fetch_assoc($query); $username = $row['username']; $submit = $_POST['submit']; $type = $_FILES['image']['type']; $size = $_FILES['image']['size']; $max_size = "1000"; $width = "100"; $height = "100"; $error = array(); function make_thumb($image_name,$filename,$new_width,$new_height) { $ext=getExtension($image_name); if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) $source_image=imagecreatefromjpeg($image_name); if(!strcmp("png",$ext)) $source_image=imagecreatefrompng($image_name); if(!strcmp("gif",$ext)) $source_image=imagecreatefromgif($image_name); $old_x=imageSX($source_image); $old_y=imageSY($source_image); $ratio1=$old_x/$new_width; $ratio2=$old_y/$new_height; if($ratio1>$ratio2) { $thumb_width=$new_width; $thumb_height=$old_y/$ratio1; } else { $thumb_height=$new_height; $thumb_width=$old_x/$ratio2; } $destination_image=ImageCreateTrueColor($thumb_width,$thumb_height); imagecopyresampled($destination_image,$source_image,0,0,0,0,$thumb_width,$thumb_height,$old_x,$old_y); if(!strcmp("jpg",$ext) || !strcmp("jpeg",$ext)) { imagejpeg($destination_image,$filename); } if(!strcmp("png",$ext)) { imagepng($destination_image,$filename); } if(!strcmp("gif",$ext)) { imagegif($destination_image,$filename); } imagedestroy($destination_image); imagedestroy($source_image); } function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } if($submit) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { $error[] = "Incorrect format! Please make sure your image is a .jpg, .jpeg, .png or .gif file."; } else { $size=getimagesize($_FILES['image']['tmp_name']); $sizekb=filesize($_FILES['image']['tmp_name']); if ($sizekb > $max_size*1024) { $error[] = "Your image is too big! The maximum upload size is 1MB."; } else { $image_name=time().'.'.$extension; $newname="uploads/" . $username . "/images/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { $error[] = "There was an error uploading your image. Please try again!"; } else { $thumb_name='uploads/' . $username . '/images/thumbs/thumb_'.$image_name; $thumb=make_thumb($newname,$thumb_name,$width,$height); } } } } else { $error[] = "Please select an image to upload!"; } if(empty($error)) { echo "Upload Successfully!<br />"; echo '<img src="'.$thumb_name.'">'; mysql_query("INSERT INTO images VALUES ('','$username','$image_name','','','','','uploads/$username/images/$image_name','uploads/$username/images/thumbs/thumb_$image_name','$type','$size')"); } else { echo implode($error); } } ?> <form method="post" enctype="multipart/form-data" action="upload_images.php"> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="file" name="image[]" /><br /> <input type="submit" name="submit" value="Upload"> </form> Thanks $body = <<<EMAIL Hello <[fname]>, You've registered and need to activate your account. Click the link below or paste it into the URL bar of your web browser http://blahblah.com/activate.php?id=<[id]>&code=< Code: [Select] > Thanks! Team EMAIL; The <[id]> isn't working. It literally sends out <[id]> in the email. Hi for the following product.php page.
<?php error_reporting(E_ALL); ini_set('display_errors', '1'); ?> <?php if (isset($_GET['id'])) { // Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $id = preg_replace('#[^0-9]#i', '', $_GET['id']); //$id = $_GET['id']; $sql = mysql_query("SELECT * FROM products WHERE id='$id' LIMIT 1"); $productCount = mysql_num_rows($sql); // count the output amount if ($productCount > 0) { // get all the product details while($row = mysql_fetch_array($sql)){ $product_name = $row["product_name"]; $price = $row["price"]; $details = $row["details"]; $category = $row["category"]; $subcategory = $row["subcategory"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); } } else { echo "That item does not exist."; exit(); } } else { echo "Data to render this page is missing."; exit(); } mysql_close(); ?> <!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" /> <title><?php echo $product_name; ?></title> <link rel="stylesheet" href="style/style.css" type="text/css" media="screen" /> </head> <body> <div align="center" id="mainWrapper"> <?php include_once("template_header.php");?> <div id="pageContent"> <p> </p> <p> </p> <p> </p> <p> </p> <table width="100%" border="0" cellspacing="0" cellpadding="15"> <tr> <td width="19%" valign="bottom"><p><img src="inventory_images/<?php echo $id; ?>.jpg" width="104" height="132" alt="<?php echo $product_name; ?>" /></p> <p><br /> <a href="inventory_images/<?php echo $id; ?>.jpg">View Full Size Image</a></p></td> <td width="81%" valign="top"><h3><?php echo $product_name; ?></h3> <p><?php echo "$".$price; ?><br /> <br /> <?php echo "$subcategory $category"; ?> <br /> <br /> <?php echo $details; ?> <br /> </p> <form id="form1" name="form1" method="post" action="cart.php"> <input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" /> <input type="submit" name="button" id="button" value="Add to Shopping Cart" /> </form> </td> </tr> </table> </div> <?php include_once("template_footer.php");?> </div> </body> </html>when i click on image link.. i get ReadResponse() failed: The server did not return a response for this request. pl help asap Edited by mac_gyver, 25 September 2014 - 08:21 AM. code tags please Can someone help me with my problem i'm trying to make and thing to update my database so i can update first name last name and login but i get a "query failed" update-exec.php <?php //Start session session_start(); //Include database connection details require_once('config.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $fname = clean($_POST['fname']); $lname = clean($_POST['lname']); $login = clean($_POST['login']); //Input Validations if($fname == '') { $errmsg_arr[] = 'First name missing'; $errflag = true; } if($lname == '') { $errmsg_arr[] = 'Last name missing'; $errflag = true; } if($login == '') { $errmsg_arr[] = 'login missing'; $errflag = true; } //Create INSERT query $qry = "INSERT INTO members(firstname, lastname, login,) VALUES('$fname','$lname','$login')"; $result = @mysql_query($qry); //Check whether the query was successful or not if($result) { header("location: member-index.php"); exit(); }else { die("Query failed"); } ?> <form id="loginForm" name="loginForm" method="post" action="update-exec.php"> First Name<input name="fname" type="text" value="<?php echo $_SESSION['SESS_FIRST_NAME'];?>" class="textfield" id="fname" /> Last Name<input name="lname" type="text" value="<?php echo $_SESSION['SESS_LAST_NAME'];?>" class="textfield" id="lname" /> Login<input name="login" type="text" value="<?php echo $_SESSION['SESS_USERNAME'];?>" class="textfield" id="login" /> <input type="submit" name="Submit" value="Update" /> </form> How can I check to see if a query has failed, be it INSERT, UPDATE, DELETE or SELECT? I want to return one value if the query fails, but a different one if it works. For example, if I have a query to delete a row, but somehow this query fails because the row doesn't exist, then I want to check that it's failed and then output a result Ok, I'm having some trouble with file_get_contents failing & am trying to make a loop that will sleep & then retry a maximum of 3 times before giving up & moving to the next item. I tried using a while loop but I'm getting unexpected T_WHILE, which I assume is because it's already in a while loop? I found this: Code: [Select] $maxTries = "3"; for ($try=1; $try<=$maxTries; $try++) { but could use some clarification. Will that only trigger if it failes or do I need to include another if statement like Code: [Select] $myfile = file_get_contents("http://example.com"); if ($myfile === FALSE) { $maxTries = "3"; for ($try=1; $try<=$maxTries; $try++) { sleep(3); $myfile = file_get_contents("http://example.com"); } else { //continue with script I hope that makes sense...trying to explain it as best I can without having to post my actual source code as I've had it stolen off forums before & now I have a clone to compete with. I'm not great at putting this into words so if I need to clarify, please feel free to ask. I appreciate any & all help given. Thanks! I'm having a rough time getting an AS3 application working with a PHP script. The PHP script takes POST variables and then sends an email using SMTP. When running it through a standard HTML form, the PHP side works perfectly. However, when I send the exact same POST variables through AS3 to the script, I get this error. Failed to set sender: phpemailtesting@gmail.com [SMTP: Failed to write to socket: not connected (code: -1, response: )] So, I'm not really sure what the issue is here... Here's some code that might help. //print_r($_POST); require_once('Mail-1.2.0/Mail.php'); $from = isset($_POST['emailfrom']) ? $_POST['emailfrom'] : ''; $to = isset($_POST['emailsubject']) ? $_POST['emailto'] : ''; $bcc = isset($_POST['bcc'])? $_POST['bcc'] : ''; $subject = isset($_POST['emailsubject']) ? $_POST['emailsubject'] : ''; $body = isset($_POST['emailbody']) ? $_POST['emailbody'] : ''; $ssl = isset($_POST['ssl']) ? $_POST['ssl'].'://' : ''; $smtp_server = isset($_POST['smtpserver']) ? $_POST['smtpserver'] : ''; $password = isset($_POST['emailpassword']) ? $_POST['emailpassword'] : ''; $port = isset($_POST['port']) ? $_POST['port'] : ''; $success_counter = 0; $fail_counter = 0; $bigerror; if($from!='' && $to!='' && $subject!='' && $body!='' && $smtp_server!='' && $password!='' && $port!='') { if($bcc!='') { $bcc_array = explode(',',$bcc); } $host = $ssl . $smtp_server; $smtp = Mail::factory('smtp', array('host'=>$host, 'port'=>$port, 'auth'=>true, 'username'=>$from, 'password'=>$password)); $header = array('From'=>$from, 'To'=>$to, 'Subject'=>$subject); $mail = $smtp->send($to, $header, $body); if (PEAR::isError($mail)) { $bigerror = $mail->getMessage(); $fail_counter++; //echo("<p>Message failed".$to." :<br />" . $mail->getMessage() . "</p>"); } else { $success_counter++; //echo("<p>Message successfully sent to <b>". $to ."</b>!</p>"); } for($counter=0; $counter<count($bcc_array) && $counter<=99; $counter++) { $header = array('From'=>$from, 'To'=>$bcc_array[$counter], 'Subject'=>$subject); $mail = $smtp->send($bcc_array[$counter], $header, $body); if (PEAR::isError($mail)) { $bigerror = $mail->getMessage(); //echo("<p>Message failed".$bcc_array[$counter]." :<br />" . $mail->getMessage() . "</p>"); $fail_counter++; } else { //echo("<p>Message successfully sent to <b>". $bcc_array[$counter] ."</b>!</p>"); $success_counter++; } } //echo "<br /><br />Successful emails: " . $success_counter; //echo "<br />Failed emails: " . $fail_counter; echo $success_counter.",".$fail_counter.",".$bigerror; } else { echo "error"; //echo '<p>Some information is missing, please try again!</p>'; } Then, the AS if anybody's interested in seeing it. Code: [Select] //Create loader to load emailer.php var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest("http://tendollartools.com/testmail/emailer.php"); //Create POST variables var variables:URLVariables = new URLVariables(); variables.emailfrom = preferences["smtpLogin"]; variables.emailto = preferences["smtpLogin"]; variables.smtpserver = preferences["smtpServer"]; variables.emailpassword = preferences["smtpPassword"]; variables.ssl = preferences["smtpSSL"]; variables.port = preferences["smtpPort"]; variables.bcc = emails; variables.emailsubject = preferences["emailSubject"]; variables.emailbody = preferences["emailBody"]; //Set method to POST and set variables as the vars to send to emailer.php request.method = URLRequestMethod.POST; request.data = variables; //Load emailer.php and run the onEmailComplete function when finished loading loader.dataFormat = URLLoaderDataFormat.TEXT; loader.addEventListener(Event.COMPLETE, onEmailComplete); loader.load(request); The preferences object has all the correct information in it... so this is where I'm confused. Why will the exact same POST information work from an HTML form, but not when sent through AS? I've got a somewhat simple problem I think.. I'm working on a uni practical, and one of the checkpoints is to limit the number of incorrect login attempts to 2. I know I could do this very easily with session variables, however on the practical sheet, it says that we're not allowed to modify any of the partially implemented code. So I was wondering, what other ways are there to track the number of incorrect logins? If it comes to it, I will just use session variables, as it's pretty much the most sensible way I'd imagine.. but would like to know of any other possible ways.. Cheers Denno Here is my code, below. It is gathering the $url with the corret images. But poduces and error on line 50. Failed to open stream. No such file or directory. By this line: readfile($file_name); What Am I missing, beyond strong programmer mind set. Code: [Select] $merch_map = "http://spot_map"; $dir = "/opt/digistrive/tmp/media/current"; class merch_imgs { public function __construct() { $this->merch_imgs1(); } public function __call($method, $_) { $count = str_replace('merch_imgs', '', $method); echo "$count "; $this->{"merch_imgs" . ++$count}(); } } class thousand_printer extends merch_imgs { public function merch_imgs1000() {} } //03-2012. Location of merchant, if no image use place holder $thumbnails = implode(',', range(1, 10000)); $ext = ".png"; for($thumbnails = 0; $thumbnails < 10000; $thumbnails++) { $url = $merch_map.'/'.$thumbnails.''.$ext; echo $url . '<br>'; //echo '<img src='.$url.' border=0/>'; downloader($url, $dir); } function downloader($url){ $file_name = basename($url); $generated_files = geturl($url, $url); //file_put_contents($file_name); file_put_contents($url, $url = var_export($file_name,true)); $size=strlen($generated_files); if($size==0){exit(0);("<b>Error:</b>not found!");} //header('Content-type: application/force-download'); //header('Content-Disposition: attachment; filename=' . $file_name); //header('Content-Transfer-Encoding: binary'); //header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); //header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); //header('Pragma: public'); //header('Content-Length: ' . $size); readfile($file_name); unlink($file_name); } function geturl($url, $referer) { $headers[] = 'Accept: image/png'; $headers[] = 'Connection: Keep-Alive'; $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; $user_agent = 'ONLY_MY_HOST'; //$useragent = $url; $process = curl_init($url); curl_setopt($process, CURLOPT_HTTPHEADER, $headers); curl_setopt($process, CURLOPT_HEADER, 0); curl_setopt($process, CURLOPT_USERAGENT, $user_agent); curl_setopt($process, CURLOPT_REFERER, $referer); curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); $return = curl_exec($process); curl_close($process); return $return; } //downloader($dir, $url); //Merchant Images if($url && $user_agent){ file_get_contents($url); die(); } XSD
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:simpleType name="MgmtCodetyp"> <xsd:restriction base="xsd:string"> <xsd:pattern value="[A-Z][A-Z]([A-Z]|[0-9])"></xsd:pattern> </xsd:restriction> </xsd:simpleType> <xsd:element name="MgmtCode" type="MgmtCodetyp"></xsd:element> </xsd:schema> XML <MgmtCode>AGF</MgmtCode> PHP Code <?php $file = "data.xml"; function libxml_display_error($error) { $return = "\n"; switch ($error->level) { case LIBXML_ERR_ERROR: $return .= "[ERROR] "; break; case LIBXML_ERR_FATAL: $return .= "[FATAL] "; break; default: $return .= "[UNKNOWN] "; } $return .= trim($error->message); $return .= " [line: $error->line]\n"; return $return; } function libxml_display_errors() { $errors = libxml_get_errors(); foreach ($errors as $error) { if ($error -> level != LIBXML_ERR_WARNING) { print libxml_display_error($error); } } libxml_clear_errors(); } // Enable user error handling libxml_use_internal_errors(true); $xml = new DOMDocument; $xml -> load("kkk.xml"); if (!$xml -> schemaValidate("kkk.xsd")) { libxml_display_errors(); } else { print "no error\n"; } ?> OUTPUT [ERROR] Element 'MgmtCode': [facet 'pattern'] The value 'AGF' is not accepted by the pattern '[A-Z][A-Z]([A-Z]|[0-9])'. [line: 1] [ERROR] Element 'MgmtCode': 'AGF' is not a valid value of the atomic type 'MgmtCodetyp'. [line: 1] ANALYSIS The XML is a perfectly valid xml. I don't understand why it failed the XSD. I am trying to install a wordpress plugin called CiviCRM. I am using the GoDaddy wordpress dashboard to do this. I am getting this error (which is just the first error in a list of several that are appearing): Warning: require(/home/NAME/public_html/wordpress.SITE.com/wp-content/plugins/civicrm/civicrm/vendor/composer/../symfony/polyfill-ctype/bootstrap.php): failed to open stream: No such file or directory in /home/NAME/public_html/wordpress.SITE.com/wp-content/plugins/civicrm/civicrm/vendor/composer/autoload_real.php on line 70 I am looking at the code in file "autoload_real.php" and line 70 reads: require $file; nowhere else in this file is $file defined. the directory "/home/NAME/public_html/wordpress.SITE.com/wp-content/plugins/civicrm/civicrm/vendor/composer/" DOES exist, but the rest of the line "../symfony/polyfill-ctype/bootstrap.php" does not. there are also 3 other errors in eclipse that are indicated and all of those errors are "syntax error: unexpected 'Autoload()'. The 3 different lines of code that throw this error a 1) self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 2) call_user_func(\Composer\Autoload\ComposerStaticInitdb2000479593e65ef23454e56d74a73f::getInitializer($loader)); 3) $includeFiles = Composer\Autoload\ComposerStaticInitdb2000479593e65ef23454e56d74a73f::$files; I'm not really sure what the issue is, as I'm not experienced enough. Any help from the experts here? GoDaddy claims the problem is with the plugin file's coding. Edited October 24, 2019 by ajetrumpetWarning: include(): Failed opening 'lang/en.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/name/public_html/db/config.php on line 13What does the for inclusion mean. Line 13: include 'lang/'.$_SESSION['default_lang'].'.php';Thank you. is this a server problem its the first time ive come across it. does this mean theres a problem with the PDO driver on the Mysql server.??????? is there a way of solving this This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=320768.0 Hi guys, I have a bit of trouble as I am trying to extact the data from mysql database when I enter the url as something like this: Code: [Select] http://www.mysite.com/login.php?user=test&pass=test <?php session_start(); define('DB_HOST', 'localhost'); define('DB_USER', 'myuser'); define('DB_PASSWORD', 'mypass'); define('DB_DATABASE', 'mydbname'); $errmsg_arr = array(); $errflag = false; $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } $db = mysql_select_db(DB_DATABASE); if(!$db) { die("Unable to select database"); } function clean($var){ return mysql_real_escape_string(strip_tags($var)); } $user = clean($_GET['user']); $pass = clean($_GET['pass']); $login = clean($_GET['login']); if($user == '' && $pass == ''){ // both are empty $errmsg_arr[] = 'Both name and email are missing. You must enter one or the other.'; $errflag = true; } if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; echo implode('<br />',$errmsg_arr); } else { $insert = array(); if(isset($_GET['user'])) { $insert[] = 'user = \'' . clean($_GET['user']) .'\''; } if(isset($_GET['pass'])) { $insert[] = 'pass = \'' . clean($_GET['pass']) . '\''; } if(isset($_GET['login'])) { $insert[] = 'login = \'' . clean($_GET['login']) . '\''; } if (count($insert)>0) { $names = implode(',',$insert); if(isset($user) && isset($pass)) { $query = "SELECT username, LoggedUser FROM Login WHERE username='$user'"; $result=mysql_query($query) or die('Error:<br />' . $qry . '<br />' . mysql_error()); echo "<p id='LoggedUser'>"; echo $row['LoggedUser'] . "</p>"; } elseif(isset($user) && isset($login)) { $sql="UPDATE Login SET {$login} where username='{$user}'"; echo "<p id='LoggedUser'>"; echo $row['LoggedUser1'] . "</p>"; } } } ?> when I entered the url, there are empty array which it did not filled on the webpage. I want to extact the data from the database when I enter the url like on above. Please can you help? Thanks, Mark I wish to lockout the user for (3) minutes if they get (4) wrong username/password attempts in (5) minutes.
Is this typically tied to a single IP using $_SERVER['REMOTE_ADDR']?
Is it a good ideal to also check for a given username but from any IP? I might be wrong, but I assume the value in $_SERVER['REMOTE_ADDR'] is under the user's control.
Obviously, a session wouldn't be ideal as the associated cookie is under the user's control. Do I need to use the database or is there a better way?
Any thoughts or advise would be appreciated.
|