Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by Ustag

  1. Hi, I have a mysqli_query that goes like this: $result = mysqli_query($db, "INSERT INTO device(`Identifier`, `IsAllowedToPost`)VALUES('ABC123', 0)") or die(error_log(mysqli_error($db), 3, "php_error.log")); It does not work and the logs either tells me "1", "0" or nothing depending on which method I try to log the error with. How can I get a better error message to log in my file? 1 or 0 means nothing to me. The current code gives me no error message at all in my file and the data does not get stored in the database.
  2. ok what I did to fix this was to delete my .htaccess and create a new php.ini file and start over.
  3. I've found many topics on how to fix this but nothing seem to work for me.I am uploading files trough ftp with a php script and what I am doing to make this work so far is this: editing .htaccess to make php settings allow a file of 10mb for sure: php_value session.gc_maxlifetime 86400php_value max_input_time 86400php_value max_execution_time 86400php_value upload_max_filesize 1100Mphp_value post_max_size 1100Mphp_value memory_limit 1100M Using custom timeout setting like this:ftp_connect($ftp_server, 21, 120000) Editing the same options as above in the actual php.ini file. I also have this in my php script: set_time_limit(0);And this: ini_set('upload_max_filesize',1100000000); What I get now is this error message when trying to upload a file of around 10mb: POST Content-Length of 10550339 bytes exceeds the limit of 10485760 bytes in Unknown on line 0 If I look in phpinfo(); ite tells me that post_max_size = 10M and upload_max_filesize = 10M even if I changed it. How come? Could it be my webhost that prevents this from increasing???
  4. if I drop 2 files will it do this: create barcreate bar trigger progressFunctiontrigger progressFunction or this: create bartrigger progressFunction create bartrigger progressFunction ?
  5. edit: I regret my post, im just lost ^^
  6. Shouldnt this work? function progressFunction(evt) { //give each bar a % calculator var bars = document.getElementsByTagName('progress'); for (var i=0; i<bars.length; i++) { var progressBar = document.getElementById('progressBar' + i); var percentageDiv = document.getElementById('report' + i); if (evt.lengthComputable) { progressBar.max = evt.total; progressBar.value = evt.loaded; percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%"; } } }
  7. I use the example at the bottom of that page you gave me but I want to edit this to fit my needs. This is my code now to give me one progress bar for each file dragged on to the dropzone, my problem is how I can also give each progrss bar its own % calculator. <script type="text/javascript"> function sendFile(file) { var uri = "upload.php"; var xhr = new XMLHttpRequest(); var fd = new FormData(); xhr.upload.addEventListener("progress", progressFunction, false); xhr.open("POST", uri, true); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { // Handle response. //alert(xhr.responseText); var percentageDiv = document.getElementById("report"); percentageDiv.innerHTML = 'Transfer complete'; } } fd.append('myFile', file); // Initiate a multipart/form-data upload xhr.send(fd); } window.onload = function() { var dropzone = document.getElementById("dropzone"); dropzone.ondragover = dropzone.ondragenter = function(event) { event.stopPropagation(); event.preventDefault(); } dropzone.ondrop = function(event) { event.stopPropagation(); event.preventDefault(); var filesArray = event.dataTransfer.files; for (var i=0; i<filesArray.length; i++) { var progressDiv = document.getElementById('progressDiv'); var pbar = document.createElement('progress'); var br = document.createElement('br'); var report = document.createElement('div'); pbar.setAttribute('id', 'progressBar' + i); pbar.setAttribute('value', '0'); pbar.setAttribute('max', '100'); report.setAttribute('id', 'report' + i) progressDiv.appendChild(pbar); progressDiv.appendChild(br); progressDiv.appendChild(report); progressDiv.appendChild(br); sendFile(filesArray[i]); } } } function progressFunction(evt) { var progressBar = document.getElementById('progressBar' + i); var percentageDiv = document.getElementById('report' + i); if (evt.lengthComputable) { progressBar.max = evt.total; progressBar.value = evt.loaded; percentageDiv.innerHTML = Math.round(evt.loaded / evt.total * 100) + "%"; } }</script> The function progressFunction(evt) can not be placed in the for loop, then it will not work. Does anybody know how I could solve this? Thank you.
  8. Hello, im trying to create a nice file uploader using XmlHttpRequest so that we can get a nice progress bar and stuff without reloading the page. When I try to upload using my code the progress bar does show and count % up untill completed but no file is being uploded. I will show you my code and tell you what I think is wrong, but I will strip it down a bit. This is my js part: function uploadFile() { var xhrObj = new XMLHttpRequest(); var filesToBeUploaded = document.getElementById("fileControl"); var file = "filename="+filesToBeUploaded.files[0]; xhrObj.upload.addEventListener("progress", progressFunction, false); xhrObj.upload.addEventListener("load", transferCompleteFunction, false); xhrObj.open("POST", "upload.php", true); xhrObj.setRequestHeader("Content-type", file.type); xhrObj.send(file); } My form is not important, its a button with onclick="uploadFile()". But my upload.php might not be correct. This is where I wonder if I can use this:move_uploaded_file($_FILES['Filedata']['tmp_name'], "files/".$name."/".$filename) my upload.php: <?phpsession_start(); //Set some variables$name = $_SESSION['name'];$filename = $_POST['filename'];$key = uniqid(); // Move uploaded fileset_time_limit(0); if(move_uploaded_file($_FILES['Filedata']['tmp_name'], "files/".$name."/".$filename)){ // Update database}?>
  9. hi I have problem with my file uploader which dont make sense for me. I am trying to upload 3 files with the following code but only one of them is being uploaded and its the .xbst file. Please have a look, it gives me no error message at all: //image file if (($_FILES['image']['error'] == 0) && ($_FILES["image"]["type"] == true)) { $ext = substr(strrchr($_FILES["image"]["name"], '.'), 1); if (($ext == "jpg") || ($ext == "JPG") || ($ext == "jpeg") || ($ext == "JPEG")) { if(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name , 0755); } elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation , 0755); } elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/img".$key)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/img".$key , 0755); } else { move_uploaded_file($_FILES["image"]["tmp_name"], "inc/scripts/xenobot/hscript/".$name."/".$vocation."/img".$key."/".$_FILES["image"]["name"]); } } else { echo "Filetype not allowed: ".$_FILES["image"]["name"]; }} //xbst file if (($_FILES['settings']['error'] == 0) && ($settings == true)) { $ext = substr(strrchr($_FILES["settings"]["name"], '.'), 1); if (($ext == "xbst") || ($ext == "XBST")) { if(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name , 0755); } elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation , 0755); } else { move_uploaded_file($_FILES["settings"]["tmp_name"], "inc/scripts/xenobot/hscript/".$name."/".$vocation."/".$_FILES["settings"]["name"]); } } else { echo "Filetype not allowed: ".$_FILES["settings"]["name"]; }}//lua file if (($_FILES['script']['error'] == 0) && ($script == true)) { $ext = substr(strrchr($_FILES["script"]["name"], '.'), 1); if (($ext == "lua") || ($ext == "LUA")) { if(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name , 0755); } elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation , 0755); } elseif(file_exists($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/lua".$key)==false) { mkdir($thisdir ."/inc/scripts/xenobot/hscript/".$name."/".$vocation."/lua".$key , 0755); } else { move_uploaded_file($_FILES["script"]["tmp_name"], "inc/scripts/xenobot/hscript/".$name."/".$vocation."/lua".$key."/".$_FILES["script"]["name"]); } } else { echo "Filetype not allowed: ".$_FILES["script"]["name"]; }} Thank you for your time!
  10. Ustag

    sorting arrays

    Hi, I am generating a bunch of arrays but I would like to change the order of these. This is my code now: $players_killed['time'] = strtotime($time);$players_killed['name'] = ': '.$player;arsort($players_killed, SORT_NUMERIC);echo var_dump($players_killed) .'<br>'; And this is the output: array(2) { ["time"]=> int(1334027580) ["name"]=> string(106) ": Brbasher" }array(2) { ["time"]=> int(1334029860) ["name"]=> string(102) ": Dynext" }array(2) { ["time"]=> int(1334029260) ["name"]=> string(110) ": Kronigrass" }array(2) { ["time"]=> int(1334036580) ["name"]=> string(108) ": Poliminia" } How can I make them order by the time value? My attempt with arsort($players_killed, SORT_NUMERIC); sure failed.
  11. Thank you all but my solution will be to break this down and add substr($td2->nodeValue, 0, 3) and substr($td2->nodeValue, 5, 2) in to variables that will give me "Apr" and "08". Thanks !
  12. var_dump(substr($td2->nodeValue, 0, 3)); = string(3) "Apr"var_dump(substr($td2->nodeValue, 0, 4)); = string(4) "Apr´┐Ż"var_dump(substr($td2->nodeValue, 0, 5)); = string(5) "Apr "var_dump(substr($td2->nodeValue, 0, 6)); = string(6) "Apr 0"var_dump(substr($td2->nodeValue, 0, 7)); = string(7) "Apr 08" Does this tell me anything? ^^
  13. Adding "Killed" and using substr($td2->nodeValue, 0, 6) == "Apr 08" did not work eather. And how come echo substr($td2->nodeValue, 0, 7) = "Apr 08" and echo substr($td2->nodeValue, 0, 6) = "Apr 0"? I just noticed in their source code it says "Apr& #160;08", what is "& #160;" (without the whitespace)?
  14. Hi, I am scraping a game page in order to grab certain info about a player. What I scrape is the info under "Character Deaths" for example on this page: http://www.tibia.com...s&name=Brunkarn This code will print all killed players in April: if((substr($td2->nodeValue, 0, 3) == "Apr") && (substr($td2->nextSibling->nodeValue, 0, 6) == Killed)){echo $player.': '.substr($td2->nodeValue, 0, 7).'<br>';} It prints "Brunkarn: Apr 08". now if I replace this: substr($td2->nodeValue, 0, 3) == "Apr") with this: substr($td2->nodeValue, 0, 7) == "Apr 08") I get no result anymore, why? When I echo substr($td2->nodeValue, 0, 7) I get "Apr 08". Sorry if I post in wrong section, please move this.
  15. Ustag

    comparing arrays

    Thank you very much, my solution is this: $compare_names = array_intersect($players_world, $players_guild);foreach($compare_names as $names_online) {echo $names_online.'<br>';}
  16. Ustag

    comparing arrays

    Hello, I have a problem comparing arrays and printing them. My code looks soemthing like this: $players_world = array();$players_world[] = $td->nodeValue; $players_guild = array();$players_guild[] = $td2->nodeValue; echo array_intersect($players_world, $players_guild); This should print a number of names but I only get "Array", how come?
  17. Ustag

    not auto resizing

    thank you that helps much =)
  18. Ustag

    not auto resizing

    Hello, this is what I get from adding these things to these elements: on .txt I add this: position: absolute;top: 355px; on h1 I add this: position:absolute;top: 300px; outcome:http://www.tibiatrad.../antik/mynt.php How can I make the wrap to auto expand with its biggest child?This is how it looked before I added the code:http://www.kihlbergantik.se/mynt.php Tip: Firebug is a great addon for mozilla to easily check out my css problem. Thanks for reading.
  19. Ustag

    php socks to grab info

    I'm experimenting with socks, learning this and that ^^ but thank you both.
  20. Hello, im trying to use socks to grab only time and the "killed by" text from the character deaths from this page:http://www.tibia.com...ters&name=Apaci I use this code and ofc it gives me the whole page, now how can I filter what I get so that I only get the parts that I want? $fp = fsockopen("www.tibia.com", 80, $errno, $errstr, 30);if (!$fp){ echo "$errstr ($errno)<br />\n";}else{$out = "GET /community/?subtopic=characters&name=Apaci HTTP/1.1\r\n";$out .= "Host: www.tibia.com\r\n";$out .= "Connection: Close\r\n";$out .= "Accept: text/plain\r\n\r\n"; fwrite($fp, $out);$lines = Array();while (!feof($fp)){ $lines[] = fgets($fp, 1024);} for($i=0; $i<count($lines); $i++){ echo $lines[$i];} fclose($fp); }
  21. Ustag

    File Download Problem

    I read that too late to try it, sorry, but my solution was to delete this file and find another one that works for me Thank you both for your time!
  22. Ustag

    File Download Problem

    I just notice that jpg files downloaded with this scripts get corrupt while the image works fine when downloading it trough ftp... i go crazy now :'(also now it downloads dl.php with not the script in it but the $fullPath printed in it...
  23. Ustag

    File Download Problem

    Yes, I hardcoded also and I still get this problem, maybe there is something with my php.ini?
  24. Ustag

    File Download Problem

    Adding escapeshellarg gives me dl.php as blank page and error message: [09-Nov-2011 08:23:33] PHP Warning: fopen('/home2/hulk/public_html/filepage/filefolder/username/aha,00.txt'): failed to open stream: No such file or directory in /home2/hulk/public_html/filepage/dl.php on line 30[09-Nov-2011 08:23:33] PHP Warning: fclose(): supplied argument is not a valid stream resource in /home2/hulk/public_html/filepage/dl.php on line 48 line 30 is: if ($fd = fopen (escapeshellarg($fullPath), "r")) {line48 is: fclose ($fd); And this is hapening on files even without comma.
  • Create New...