Jump to content

treeleaf20

Members
  • Posts

    76
  • Joined

  • Last visited

    Never

Everything posted by treeleaf20

  1. Even if I remove that from the code it still doesn't work. I just added that as more of a debugging tool to see if the file even had contents in it. Either way, it still doesn't work.
  2. All, I've got the following code to force a file download for a zipfile that I just created: $zip_name = 'download.zip'; $result = create_zip($other_files_to_zip,$zip_name,true); if($result){ echo "The filesize is: ".filesize($zip_name); header('Content-Type: application/zip'); header('Content-disposition: attachment; filename=filename.zip'); header('Content-Length: ' . filesize($zip_name)); readfile($zip_name); } When I echo out the filesize it shows a correct size and it prompts me to download the filename.zip which is ok since it's just a filename but then when I save the document and try and open Windows says that Windows cannot open the folder because the folder is invalid. Any ideas on how to resolve an issue like this? Thanks in advance!
  3. That did the trick, I'm using domain.com. How can I tell what version of PHP they are using? Thanks!
  4. If I make it: $oldKey = null; I get the following error: Parse error: syntax error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /usr/local/pem/vhosts/243668/webspace/httpdocs/offers/form_key.php on line 5 If I make it: var $oldKey; I get the following error: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /usr/local/pem/vhosts/243668/webspace/httpdocs/offers/form_key.php on line 7 Thanks.
  5. All, I'm getting the following error when I work with a class: Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /webspace/httpdocs/offers/form_key.php on line 5 The complete code for this is class is: <?php class Form_Key { protected $oldKey; public function __construct() { // Ensure we have an available session if ( NULL == session_id() ) { session_start(); } // Grab our former key for validation if ( isset( $_SESSION['form_key'] ) ) { $this->oldKey = $_SESSION['form_key']; } // Assign the new key $_SESSION['form_key'] = md5( uniqid( mt_rand(), TRUE ) ); } public function isValid() { return 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['form_key'] ) && '' != trim( $_POST['form_key'] ) && '' != trim( $this->oldKey ) && $_POST['form_key'] === $this->oldKey; } public function getKey() { return $_SESSION['form_key']; } public function getOldKey() { return $this->oldKey; } public function render() { return '<input type="hidden" name="form_key" value="' . $_SESSION['form_key'] . '" />'; } public function __toString() { return $this->render(); } } ?> The line that is giving the issue is this line: protected $oldKey; Is it ok just to remove this line?? If I comment it out it gives me the same message but for line 7, which is this one: public function __construct() Anyone have any ideas? Thanks in advance.
  6. All, I have a zip code and for example the zip code is 01101. How can I determine if the first character in this is a zero? Thanks in advance.
  7. All, I'm trying to use some code to get some file contents from another website and am looking at performance. What is the quicker way and better for my resources to get out to websites, is it cURL or by using file_get_contents? Thanks in advance.
  8. So I tested this, here is the code: <script> function check_out(pic_id){ //alert(pic_id); url = "check_out.php?work_id=" + pic_id; window.location.href = url; refreshWorkQueue(pic_id); } </script> The refreshWorkQueue is the AJAX function and the AJAX function is in an external js file. It's weird and the result is not what I expected. The AJAX file actually gives me alerts before the file download is prompted. Also If I comment out the url and the window.location.href and then execute this it actually returns my AJAX file so I'm back to the drawing board. Has anyone else had any luck with this? Thanks in advance.
  9. Unfortunately, that didn't do the trick. Any other ideas?
  10. All, I found the following script to do the download: $resultsetpic = mysql_fetch_array($resultpic); $filename = "full_size/$resultsetpic[filename]"; // don't accept other directories $size = @getimagesize($filename); $fp = @fopen($filename, "rb"); if ($size && $fp) { header("Content-type: {$size['mime']}"); header("Content-Length: " . filesize($filename)); header("Content-Disposition: attachment; filename=$filename"); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); fpassthru($fp); exit; } This downloads the file fine. However what I would like to do is also refresh the page that the user was just on. So I tried to add this: $resultsetpic = mysql_fetch_array($resultpic); $filename = "full_size/$resultsetpic[filename]"; // don't accept other directories $size = @getimagesize($filename); $fp = @fopen($filename, "rb"); if ($size && $fp) { header("Content-type: {$size['mime']}"); header("Content-Length: " . filesize($filename)); header("Content-Disposition: attachment; filename=$filename"); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); fpassthru($fp); exit; } $target = "work_queue.php"; header("Location:". $target); However, this doesn't reload the page they were on. Any ideas on how to do this? Thanks in advance.
  11. All, I have the following text: <bold>Our Services Include:<endbold> <bullet>Construction<endbullet><bullet>Landscaping<endbullet> Then I have the following PHP to replace the contents: $qrytxt = "Select * from texts where text_id='2'"; $resulttxt = mysql_query($qrytxt); $resultsettxt = mysql_fetch_array($resulttxt); $newtxt = $resultsettxt['text']; $newtxt = str_replace("<endbullet><bullet>", "</li><li>", $newtxt); $newtxt = str_replace("<bullet>", "<li>", $newtxt); $newtxt = str_replace("<endbullet>", "</li><br>", $newtxt); $newtxt = str_replace("<bold>", "<strong>", $newtxt); $newtxt = str_replace("<endbold>", "</strong>", $newtxt); echo nl2br($newtxt); My problem is that if it is the first <bullet> then I want it to replace to <ul><li> instead of just a <li> and also if it's the last <endbullet> then I want it to replace it with </li></ul> Any ideas on how to do that? Thanks in advance.
  12. All, I have the two following URLs: http://photos-c.ak.fbcdn.net/photos-.../n47602684_30183939_7359.jpg http://photos-c.ak.fbcdn.net/photos-.../n38801267_31342580_3128.jpg Basically they always end in a .jpg, .gif or .png and then I always want to take it from the the .jpg, .gif or .png to the previous / So for this I'd like to grab: n38801267_31342580_3128.jpg and n47602684_30183939_7359.jpg What is the best way to do this? Thanks in advance!
  13. All, I have the following code that works good: $contents = file_get_contents( $picbigid[$i] ); $bytesWritten = file_put_contents( $saveLocation . basename($picbigid[$i]) , $contents ); This gets the original image size of the image. Is there anyway to still use file_put_contents and just resize it to 100x100 without doing an imagecreatefromjpeg etc? Thanks for the help in advance!
  14. All, I have the following checkbox code: echo "<input name=\"picbigid[]\" type=\"checkbox\" value=\"$pic[src_big]\">"; I then want to select all the checkboxes so I have this code: echo "<input type=\"button\" name=\"CheckAll\" value=\"Check All\" onClick=\"checkAll(document.photos.picbigid)\"> <input type=\"button\" name=\"UnCheckAll\" value=\"Uncheck All\" onClick=\"uncheckAll(document.photos.picbigid)\">"; [code=php:0] My JS function is: [code] function checkAll(field) { for (i = 0; i < field.length; i++) field[i].checked = true ; } function uncheckAll(field) { for (i = 0; i < field.length; i++) field[i].checked = false ; } If I do it like this: echo "<input name=\"picbigid\" type=\"checkbox\" value=\"$pic[src_big]\">"; It works but I can't have it like that because the form posts to another PHP page that needs the input name as an array. Any ideas? Thanks!
  15. All, Is it possible to do a file upload from another site? So for something quick like this: $source = $_FILES['fupload']['tmp_name']; $target = $path_to_image_directory . $filename; move_uploaded_file($source, $target); Is there anyway to make the $source something like: $source = "http://www.site.com/pictures?id=12345"; $target = $path_to_image_directory . $filename; move_uploaded_file($source, $target); Any ideas? Thanks!
  16. For some reason this won't work. I put in the CSS and actually change the percbar in the CSS so my CSS looks like this: CSS: div.fullbar { width: 1em; height: 20em; } div.percbar { border: 1px solid #555555; background-color: #fff; width:100%; } And my PHP looks like: <? $percent1 = "90%"; $percent2 = "10%"; ?> </form> <div class="fullbar"> <div class="percbar" style="height:<? echo $percent1; ?>;"> </div> <div class="percbar" style="height:<? echo $percent2; ?>;"> </div> </div> So I just hardcoded the values in for now. They both show up for they are the same size. Any ideas?
  17. All, I have the following code: <form action="" name="myform" method="post"> <input type="hidden" id="picimages" name="picimages" value="<?php echo $resultsetstory['bigger_id']; ?>" /> <p> <label> <input type="radio" id="picimages" name="picimages" value="<?php echo $resultsetstory['picture_id']; ?>" /> <?php if($resultsetstory['title']<>""){ echo $resultsetstory['title']; }else{ echo "Image 1"; } ?> </label> <br /> <label> <input type="radio" id="picimages" name="picimages" value="<?php echo $resultsetpic2['picture_id']; ?>" /> <?php if($resultsetpic2['title']<>""){ echo $resultsetpic2['title']; }else{ echo "Image 2"; } ?> </label> <br /> <input name="submit" type="button" value="Vote!" onclick="javascript:voteupdate(this.myform);"/> </p> </form> When I submit this, it goes to this function: function voteupdate(obj) { var poststr = "picimage=" + document.getElementById("picimage").value + "&bigger_id=" + encodeURI( document.getElementById("bigger_id").value ); alert(poststr); makePOSTRequest('voteresults.php', poststr); } However I can't get the value of the radio group for the one that is selected. Can someone see what is wrong? Thanks.
  18. All, I'm trying to add a voting system to my site and when someone submits a form I want a dynamic horizontal bar graph to be displayed. Any ideas on a good script is? I can submit the data, process the data. I just need a script to dsiplay it in a bar graph. Thanks in advance.
  19. Nevermind, I'm an idiot. Need to assign and ID to it.
  20. All, I have the following code: var poststr = "statusupdate=" + encodeURI( document.getElementById("statusupdate").value ) + "&user_name=" + encodeURI( document.getElementById("user_name").value ) + "&twitteryes=" + encodeURI ( document.getElementById("twitteryes").checked ) + "&currentstatus=" + encodeURI( document.getElementById("currentstatus").value ); It seems to be failing on the "&twitteryes=" + encodeURI (document.getElementById("twitteryes").checked ) If I remove it, this part works fine. This is the HTML code: <input type="checkbox" name="twitteryes" value="yesplease" /> Thanks in advance.
  21. All, I have the following code: $username = 'user'; $password = 'pass!'; $status = urlencode(stripslashes(urldecode('There is a new picture posted. Go check it out now: http://website.com/comment.php?picture_id=$id'))); if ($status) { $tweetUrl = 'http://www.twitter.com/statuses/update.xml'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "$tweetUrl"); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status"); curl_setopt($curl, CURLOPT_USERPWD, "$username:$password"); $result = curl_exec($curl); When I try and post this to Twitter everything posts fine except for the $id. How can I post this? Thanks in advance.
  22. Also I have that and then call this function when the page loads in the body onload command. It will load the original page and then switch the url and load it again. How can I get it so that it does the url and then load the page?
  23. All, If I have the following URL: http://example.com/viewpage.php?id=test Then when I write a hash the URL goes to: http://example.com/viewpage.php?id=test#id=nexttest I have the following code: function redirectHash() { var hash = location.hash; if (hash){ hash = hash.replace('#', ''); location.href = hash; } } </script> Currently this code would try and redirect me to http://example.com/id=nexttest How can I get it so that it keeps everything before the ? and just updates the id part? Thanks in advance.
  24. I tried this: var imgs = document.getElementsByTagName("img"); for ( var d = 0; d < imgs.length; ++d ) { var img = imgs[d]; if ( img.className == "showpictureid" ) { imgid = imgs[d].getAttribute("id"); //alert("The image id is" + imgid); } } But it doesn't work. The PHP code is: echo "<div style=\"position:relative;\"><img src=\"uploaded_files/$resultsetstory[image_id]\" class=\"showpictureid\" id=\"$resultsetstory[image_id]\" onclick=\"javascript:getpic(this.myform2);\"></div>";
  25. Actually, I'd use: function redirectHash() { var hash = location.hash; if (hash){ hash = hash.replace('#', ''); location.href = hash; } } </script> But I'd have to parse out the picture_id. If it's contained in an <img> tag and will always have an id of "showpictureid" how can I find this id? Thanks.
×
×
  • 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.