-
Posts
476 -
Joined
-
Last visited
Everything posted by xProteuSx
-
Please keep in mind that I am a TOTAL NOOB. I am not asking anyone to code my entire project, but I am easily lost in many cases. Your help and patience is much appreciated ... My AS3 code looks something like this: var totalFeatureImageDownloads:Number = 0; //total file size of all feature images, in bytes var totalFeatureImageDownloaded:Number = 0; //total downloaded of all feature images, in bytes for each(var featureimage:XML in xml.featureimages.imgurl) { trace(featureimage); var featureImageRequest:URLRequest = new URLRequest(featureimage); var featureImageLoader:URLLoader = new URLLoader(featureImageRequest); totalFeatureImageDownloads = totalFeatureImageDownloads + featureImageLoader.bytesTotal; trace(featureImageLoader.bytesTotal); } Currently I have 3 images in the XML file, and their URL's are traced properly. However, bytesTotal always equals 0. Also, I know that this loop creates 3 identically named URLRequest's and 3 identically named URLLoaders. I probably need to create 3 differently named ones. I would like all the images to be downloaded simultaneously, and I need to calculate the combined file size for all three, along with the download status as a fraction (bytesLoaded / bytesTotal). I have multiple scenarios like this, and am stuck until I get this finished. Your help is much appreciated. Cheers.
-
Seems like all the code was working ... it was just an issue with refreshing page so that it overwrote the cached files. *sheepish grin*
-
OK, this seems to work (just needed to refresh the browser): copy($file1, $temp1); copy($file2, $temp2); copy($temp1, $file2); copy($temp2, $file1); unset($temp1); unset($temp2);
-
Also tried this: copy($file1, $temp1); copy($file2, $temp2); copy($temp1, $file2); copy($temp2, $file1); unset($temp1); unset($temp2);
-
Yeah, sorry, I had this: rename($file1, $temp1); rename($file2, $file1); rename($temp1, $file2); (I just gave you some other code). This code only does the first half of the job. In the end both thumbs end up being the same.
-
Variables: $img_thumb1 = $nfilename1 = "Venezuela_p79_1000_Bolivares_1998_t.jpg"; $img_thumb2 = $nfilename2 = "Venezuela_p82_20000_Bolivares_1998_t.jpg"; $temp1 = "../upload/283/temp1.jpg"; $temp2 = "../upload/283/temp2.jpg"; $file1 = "../upload/283/" . $img_thumb1; $file2 = "../upload/283/" . $img_thumb2; Different things that I have tried: rename($file1, $temp1); rename($file2, $file1); rename($temp1, $file1); ... and ... copy($file1, $temp1); copy($file2, $temp2); unlink($file1); unlink($file2); rename($temp1, $nfilename2); rename($temp2, $nfilename1); ... and ... rename ($file1, $temp1); rename ($file2, $temp2); rename($temp1, $nfilename2); rename($temp2, $nfilename1); I wonder if this has something to do with 'script speed vs renaming speed' or 'script speed vs copying speed'.
-
Doesn't work for some reason.
-
oops ... Rename($file1, 'temp'); Rename($file2, '$file1); Rename($temp , '$file2');
-
I think you meant: Rename($file1, 'temp'); Rename($file2, '$file1); Rename($temp , '$file1'); ... its been tried
-
I have two files on a server, and I want to swap filenames like this: image1.jpg -> image2.jpg image2.jpg -> image1.jpg I cannot get this to work. Obviously I cannot do it this way because then I would end up with two copies of the same file, so I have tried this: $file1 = "image1.jpg"; $file2 = "image2.jpg"; $temp1 = "temp1.jpg"; $temp2 = "temp2.jpg"; rename($file1, $temp1); rename($file2, $temp2); rename($temp1, $file2); rename($temp2, $file1); Also, I have tried this: $file1 = "image1.jpg"; $file2 = "image2.jpg"; $temp1 = "temp1.jpg"; $temp2 = "temp2.jpg"; copy($file1, $temp1); copy($file2, $temp2); unlink($file1); unlink($file2); rename($temp1, $file2) rename($temp2, $file1); I have spent about 3 hours on this seemingly simple code Please have mercy on me!
-
DaveyK, Yes, these solutions do work so there is nothing wrong, but I wanted to take it to the next level, which requires the solution to read the title meta tag for a page that has a php URL (ie. www.yoursite.com/dir/user?id=33243) and create a url like www.yoursite.com/profile-page-for-username/ (assuming that meta description is 'Profile page for username')
-
Thanks for the replies guys. After I posted this I was able to find the same information on Google. However, what I was not able to find was information on how to make 'vanity urls' using a page title. This is key for me, as it is key for SEO. Any other/more ideas?
-
I don't even know what to type into Google, but I am looking to create something along the lines of the 'Pretty URL' type scripts that change the URL for pages on a site. For example, if I have a page with the following information: URL: www.mysite.com/somepage.html Page Title: this page is awesome Then I need the page to generate this URL: www.mysite.com/this-page-is-awesome/ which would bring up the content from the original URL. Any ideas or pointers? Thanks in advance.
-
Figured this out about 12 seconds after I posted it. I need to copy the file to a file, and not to a directory. So like this: mkdir('../user/dude1/'); mkdir('../user/dude1/images/'); chmod('../user/dude1/images/', 0777); $userdir = '../user/dude1/index.html'; $imgdir = '../user/dude1/images/index.html'; $copyfile = '../user/index.html'; copy($copyfile,$userdir); copy($copyfile,$imgdir); Voila!
-
I am trying to copy an existing file into a newly created directory using PHP, and am getting errors. Here is the code: mkdir('../user/dude1/'); mkdir('../user/dude1/images/'); chmod('../user/dude1/images/', 0777); $userdir = '../user/dude1/'; $imgdir = '../user/dude1/images/'; $copyfile = '../user/index.html'; copy($copyfile,$userdir); copy($copyfile,$imgdir); If I run a file_exists() on $userdir, $imgdir, or $copyfile, they all come back true, and all of these directories and files exist before the copy() command has run. Here is the error that I get: Warning: copy(../user/dude1) [function.copy]: failed to open stream: Is a directory in addcollection.php on line 154 Warning: copy(../user/dude1/images/) [function.copy]: failed to open stream: Is a directory in addcollection.php on line 155 I have also tried using the following file structure: $userdir = '/home/username/public_html/user/dude1'; (for example) ... and I still get the same message, even though I am using things from the 'root'. I have tried a lot of different variations of file structure, names, etc. and I can't get this to work. Your help would be much appreciated. Thank you in advance.
-
Thanks Christian. I have decided to use strip_tags() because I actually want all of the nonsense between the < and > characters gone. I understand that this poses a problem if the user uses one of those within the text, but unless there is a way to determine whether these characters are being used for HTML purposes or not, its something I will have to risk. I've made this comments script pretty public, and I expect there to be a point where I will not be able to administer and regulate all comments myself, and someone might start to post spam using this form -- big no-no for me. Cheers.
-
I think I found something: strip_tags(). Will give that a go.
-
I have written a simple form that stores comments in a database, and displays them on a website where relevant. As such, I have a simple input box for the comment. I was wondering if there is a function or script that will automatically detect and remove HTML tags, so that only text is being saved to the database, and not HTML. As it stands if someone was to put this in the comments section and submit: "I have a cool <a href="http://www.dirtyporn.com">website</a> to share." It would actually display: "I have a cool website to share." And the link would be live. Oh noes, right?
-
kicken, my most humble apologies. I wasn't upset at you -- just getting frustrated. In the end it turned out that I was being dumb ... all too often the case. Thank you for your help (a lot). Jessica, thanks for calling me on it Issue resolved.
-
kicken, Run this: $a = "Tranvaj889"; function randLetter() { $int = rand(0,61); $a_z = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; $rand_letter = $a_z[$int]; return $rand_letter; } $encoded = base64_encode($a); $pass = randLetter() . $encoded . randLetter() . randLetter() . randLetter(); $stripped = substr($pass, 1, (strlen($pass) - 2)); $db_pass = base64_decode($stripped); $final = substr($db_pass, 0, (strlen($db_pass) - 1)); echo 'Original: ' . $a . PHP_EOL; echo '<br />Encoded: ' . $encoded . PHP_EOL; echo '<br />Padded: ' . $pass . PHP_EOL; echo '<br />Stripped: ' . $stripped . PHP_EOL; echo '<br />DB Pass: ' . $db_pass . PHP_EOL; echo '<br />Decoded: ' . $final . PHP_EOL; if ($a == $final) {echo '<br />match<br />';} else {echo '<br />fail<br />';} Output will include: fail
-
I am sorry, but I am starting to get really frustrated. Everyone who has taken the time to take a look at the code (thank you) has given me an answer without running several samples of $a, or have not bothered to run the code at all. kicken, undoubtedly you are better at PHP than I am, however, you sample contains the same %*^#ing problem as mine. Did you select the 'Decoded' output and paste it into notepad as per the original description of this issue? Even running your EXACT code I get the exact same issue. I seriously doubt that this is an issue that has anything to do with stripping those four characters from the password, because, here's the thing: THE ORIGINAL CODE WORKS 95% OF THE TIME. If there was an extra character appended to every string because I have forgotten to delete one, NO PASSWORDS WOULD EVER WORK. I love this forum, I love the users, and I am sincerely grateful for assistance, however everyone is sending me the same response, even though I have already indicated that I have tried these things. If you care to help solve this, follow this from the original instructions: Also, try this: $a = "password'; or $a = "thisismypass"; or $a = "password167"; or $a = "Password345"; And please don't bother telling me how pretty the output looks in your browser window, which does not display the special character that is attached to SOME of the passwords. Cheers.
-
I am getting a really strange issue with a bit of code that I have written. It is used to encode a password and add some random alpha-numeric characters to it. It seems to work the vast majority of the time, but sometimes I get a strange issue. Here's the code: $a = "Tranvaj889"; function randLetter() { $int = rand(0,61); $a_z = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; $rand_letter = $a_z[$int]; return $rand_letter; } $pass = randLetter() . base64_encode($a) . randLetter() . randLetter() . randLetter(); $db_pass = base64_decode(substr($pass, 1, (strlen($pass) - 2))); $final = substr($db_pass, 0, (strlen($db_pass) - 1)); echo 'Original: ' . $a . '<br />'; echo 'Encoded: ' . $pass . '<br />'; echo 'Decoded: ' . $final; This particular example presents the problem. The output will look perfect, like this: Original: Tranvaj889 Encoded: sVHJhbnZhajg4OQ==8FN Decoded: Tranvaj889 However, if I use the mouse to select 'Tranvaj889' (Decoded one) and then paste this into notepad or any file, I get a random special character at the end. I can't post an example here, because the special characters that appear, do not show up in the browser, which is why it took me a while to figure out why my login script was not working. Anyways, I am really confused here, and could use some help. Please keep in mind that this does not occur 95% of the time. IMPORTANT: Please DO NOT reply to this post with the answer that the '- 2' part of the code should be '- 3'. This is not the case, as strlen() starts at 1 and substr() starts at 0. Remember, this works 95% of the time! Is this a bug with base64_encode() / base64_decode()? Or did I just mess something up? I've been trying to sort this out for more than a week now, and some help would be very much appreciated. Cheers, and thanks in advance.
-
I would like to create a hit counter that is linked to a mysql database. I would like to do something like this: <img src="button.jpg" onclick="addhit.php?id=12" /> where addhit.php would have a script that adds a hit to item with id number 12. I can do all of the php no problem, but I just don't know how to create a javascript onclick event that will execute something like that. Please keep in mind that I would like addhit.php to run in the background. I do not wish for it to load any content. I have never done anything like this, so your input and suggestions are much appreciated. Cheers.
-
Pikachu2000, I do understand variable scope, but I didn't know that it differed within a function. I have declared a variable outside of the function, so I thought that I could manipulate it within the function, then be able to echo it outside of the function again, like this: $text = 'Hello World'; function changeText() {$text = 'Bye World';} echo $text; //output should be 'Bye World'
-
I am having a hell of a time returning the proper array values, because the function executes itself from within itself. Any pointers?