Jump to content

CroNiX

Staff Alumni
  • Posts

    1,469
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by CroNiX

  1. You probably want the return WITHIN your foreach() loop if it finds the value foreach ($searched as $skey => $svalue) { if(isset($parents[$key][$skey]) && $parents[$key][$skey] == $svalue) { return $key; //return the key we found } } return false; //didn't find key also, you probably want "isset()", not "IsSet()"
  2. Wouldn't it be better to just do that with a css fixed-width container so the text wraps naturally? If you hard chop the text at 100 chars, it will, most likely, cut some words in half. I'd assume you'd want it to only break on spaces and not in the middle of a word. That can of course be done with PHP, but a fixed-width container is a lot simpler.
  3. When you make a post, on the editor there is a "<>" symbol. Click that and it will create a code start/stop tag. You post your code between those tags so it gets formatted and highlighted like in scootstahs post.
  4. What "extension" error? You're mixing mysql and mysqli functions (mysql_real_escape_string()). Just use mysqli. Are you sure this "JPG" is actually a legitimate jpg file? You are only looking at the file extension and not the mime type. So I could just rename 'some_script.php' to 'some_image.jpg' and upload it and your script will try to process it. Or it could be a gif image renamed with a JPG extension. See this: http://www.finalwebsites.com/php-mime-type-detection/ Another problem I see is this: @$exts = explode("." , $value); and then you use it here: if(@!in_array($exts[1], $allowed)){ You assume here that the file is filename.ext (only one period) and the extension will always be after the very first dot. What if the uploaded file was named filename.small.jpg? It's a legitimate name for a jpg file but your script won't process it the way it's coded because it will look at "small" as the file type.
  5. First, you are suppressing errors using the @ everywhere. That tells php NOT to display errors. But you are having problems with your code...so...you want to see the errors! Hard to tell what the problem is if you're hiding it Instead of testing for upper and lower case scenarios, why not just force the extension to lower case for your comparisons? $extension = strtolower(pathinfo($value, PATHINFO_EXTENSION)); then instead of if($extension=="jpg" || $extension=="jpeg" || $extension=="JPG" || $extension=="JPEG" ){ you could just use if($extension=="jpg" || $extension=="jpeg"){
  6. Geez, someone having a hissy-fit meltdown? Over coding help? I hope you can get over it and enjoy life a bit. You seem pretty miserable to blow up like that when people are just trying to HELP you. And yes, I did read your post and no, you didn't say "no css". I won't call you names though...
  7. Using plain text email, I just put the raw link (no anchor tag) on it's own line starting with http://. MOST email clients will automatically change anything that starts with http:// into a clickable link. Try just using: http://site2.desmond-otoole.co.uk/CustomerRemove.php
  8. After you made your changes to httpd-xampp.conf, did you restart the webserver?
  9. You can also rotate an image with just css without resaving it to a new image.
  10. foreach ($playlists as $playlist) { $json[] = json_decode(file_get_contents($playlist)); } $json = json_encode($json);
  11. The FROM header should be sending from an account on YOUR domain, not what the user filled out on a form. If your domain is xyz.com, then email needs to come FROM some-user@xyz.com. I'd suspect that is the reason for the "spam". Most email servers will flag email as spam if they are not coming from the originating domain that the mail server is using.
  12. @scootstah, not sure what you mean by "output is sent once the script is finished". I believe that's only the case if you're using output buffering?
  13. On an installer we created, after everything is set up as part of the install process it creates a /version.php file, that just contains the current version, ie "2.00.03" as well as sends an email stating that the install succeeded, or failed and if failed it provides the reasons/tracebacks. We ping that file for all of our client domains on a daily basis to see if it's present and what version is returned so we can offer clients an upgrade path if they wish to upgrade or autoupgrade it for them depending on the services they purchased (major releases/minor releases, etc)
  14. You wouldn't want to change the date format that the array is storing. With mine, it's the same format ("datetime" from output of the array) that a mysql datetime column format is in (Y-m-d H:i:s), which allows you to do date calculations easily, like get me all the ones from the "last 30 minutes" or whatever. Instead, you'd want to format it when you loop over the php array and output the html.
  15. You wouldn't want to store 3 separate rows. You'd store in a single row for the transaction, and that row would have a column for adult quantity and child quantity.
  16. The only thing I'd add to this is, in general, all text and images that are hosted on a website are copyrighted by the site owner/company of that website, assuming they are original pieces of work. Even if a user uploads content to that website, such as a photograph they took, that legally now belongs to the website they uploaded it to do what they wish with. This is an implied legal copyright, you don't even have to state it anywhere on the website although most sites do have this in some legal section, terms of use, etc. I'm not a lawyer, but this is my understanding. This is from PHPFreaks own site: If you want to display another copyright holders works on your site, you need to get their written permission or you can face legal action for copyright infringement if they find out and pursue you. Some websites also do have APIs that you can use to display their content without violating any law, assuming you use it within their terms of service.
  17. What doesn't work about it? Strange, it works here. Did you add the open/close php tags to the start/end of the script? Did you add the output that is from the very top of the 2nd code block to the very bottom of the script? When it does: $data = get_pb_data(); echo '<pre>'; print_r($data);
  18. I agree with Scootstah. Store the files on the filesystem where users don't have access. Store the filename in the db along with a document_id, and use that to retrieve the requested purchased document from the fs When a document is purchased, create an entry in a purchased db table showing the user id, document_id, download expiration timestamp, and a randomly generated string which the user will use to download the file. Send a link to the user with the randomly generated string, which your "download" controller (example) will process, http://yoursite.com/download.php/slekj3434jh234kjh243 When the user requests the file from download.php, verify their user_id, document_id and if it's still in the valid expiration time based on the randomly generated string. If it passes, read the file from the filesystem and send the file to the browser forcing a download. You can reset the filename back to the original in the headers, or whatever you want to name it.
  19. It's really best to use real world variable names that make sense and are meaningful so you don't confuse yourself, or someone else who has to work on the code. $a, $b, $c? That makes you have to sit there and decipher everything which wastes time because it's not immediately clear what's going on. It should be easily readable by a human. PHP doesn't care how long your variable names are and it doesn't affect speed or processing, so why not use real words as variable names and save yourself some time and confusion? while($row = mysqli_fetch_assoc($query)){ //... echo $row['id']; echo '<br />'; echo $row['mensagem']; //... }
  20. I was playing with a similar approach that didn't use regex except to extract the GUID status. Barands is a bit cleaner. function get_pb_data() { $pb_data = array(); $base_url = 'http://74.80.133.251/7778/'; // Retrieve main page $base_page = file_get_contents($base_url); // Exit and show error if couldn't be retrieved if ( ! $base_page) { exit('Could not retrieve main page: ' . $base_page); } // These are substring items that will be removed from each line of text of the HTML $items_to_remove = array( "\r", // hidden return chars (if present) '<p> ', // <p> tags with trailing space (note no closing </p>'s in src) '"', // Quotes around username '[', // Bracket around date/time ']', // Bracket around date/time '(W) GUID=' // (W), don't know if needed, and GUID= text ); // Remove the items from the raw page text $base_page = str_replace($items_to_remove, '', $base_page); // Create an array for each line $lines = explode("\n", $base_page); // Cycle through the lines, format the data and store it in a new array foreach($lines as $line) { // Remove the anchor tag from the line to isolate the punkbuster id ($pb_id) $line = strip_tags($line); if (substr_count($line, ' ') == 4) { // Grab the fields by exploding on spaces list($pb_id, $username, $guid, $date, $time) = explode(' ', $line); // Grab the "status" string from the GUID line within () preg_match('/\((.*?)\)/', $guid, $guid_status); // Remove the status string from the GUID line to isolate GUID $guid = str_replace($guid_status[0], '', $guid); // Replace dots with dashes in the date for a mysql valid format $date = str_replace('.', '-', $date); // Store the formatted user data. Normally would go in a db or something... $pb_data[] = array( 'id' => $pb_id, 'username' => $username, 'guid' => $guid, 'guid_status' => $guid_status[1], 'image_source' => $base_url . 'pb' . $pb_id . '.png', 'date' => $date, 'time' => $time, 'datetime' => $date . ' ' . $time ); } } return $pb_data; } output: $data = get_pb_data(); echo '<pre>'; print_r($data); -------------- Array ( [0] => Array ( [id] => 001646 [username] => -=D3G=-RotGM [guid] => 00000000000000076561198133386615 [guid_status] => VALID [image_source] => http://74.80.133.251/7778/pb001646.png [date] => 2015-06-25 [time] => 17:20:36 [datetime] => 2015-06-25 17:20:36 ) [1] => Array ( [id] => 001647 [username] => -=D3G=-Icey842 [guid] => 00000000000000076561198091035675 [guid_status] => VALID [image_source] => http://74.80.133.251/7778/pb001647.png [date] => 2015-06-25 [time] => 17:22:18 [datetime] => 2015-06-25 17:22:18 ) [2] => Array ( [id] => 001648 [username] => budsanonymous [guid] => 00000000000000076561198188792511 [guid_status] => VALID [image_source] => http://74.80.133.251/7778/pb001648.png [date] => 2015-06-25 [time] => 17:23:28 [datetime] => 2015-06-25 17:23:28 ) [3] => Array ( [id] => 001649 [username] => -=D3G=-Roosevelt [guid] => 00000000000000076561198161436214 [guid_status] => VALID [image_source] => http://74.80.133.251/7778/pb001649.png [date] => 2015-06-25 [time] => 17:23:48 [datetime] => 2015-06-25 17:23:48 ) [4] => Array ( [id] => 001650 [username] => -=D3G=-RotGM [guid] => 00000000000000076561198133386615 [guid_status] => VALID [image_source] => http://74.80.133.251/7778/pb001650.png [date] => 2015-06-25 [time] => 17:26:12 [datetime] => 2015-06-25 17:26:12 ) )
  21. echo "<td>".$data[$i + ($j * $rows)]."</td><td><input type='checkbox' name='member' value='".$data[$i + ($j * $rows)]."'></td>\n"; Change name="member[]", with [] after. That's the HTML way to create an array in a form using the same name.
  22. It's a Microsoft IIS webserver config file. Not positive about it, but seems to prevent listing a directory when going to it in your web browser.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.