thatisme Posted January 9, 2007 Share Posted January 9, 2007 I'm thinking about buying this flash-application; http://www.adriantnt.com/products/rating_system/Since the flash-programmer couldn't answer make question, I ask it here insted. Is it possible to combine this flash-application to a php-scipt to "rank" different votings in a list (ex. 1 to 8) where the highest amount of stars get on the top, and so on.. ?And if there are a way to do this.. where can I find such a script that is easy to use and "combine"? I'm pretty new on php.. Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/ Share on other sites More sharing options...
fert Posted January 9, 2007 Share Posted January 9, 2007 you would have to use flash to post a form Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-156921 Share on other sites More sharing options...
thatisme Posted January 10, 2007 Author Share Posted January 10, 2007 "you would have to use flash to post a form" what u mean? Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-156939 Share on other sites More sharing options...
fert Posted January 10, 2007 Share Posted January 10, 2007 you would use flash to post fields to a PHP script Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-156942 Share on other sites More sharing options...
thatisme Posted January 10, 2007 Author Share Posted January 10, 2007 How do I do that ? ??? Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-156955 Share on other sites More sharing options...
fert Posted January 10, 2007 Share Posted January 10, 2007 Sorry I don't know actionscript Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-156958 Share on other sites More sharing options...
corbin Posted January 10, 2007 Share Posted January 10, 2007 Ummm lemme dig up some flash scripts...aha found one![code]on (release) { theiname = iname.text; theisubject= isubject.text; theiemail = iemail.text; theicomment = icomment.text; submit.enabled = false; cancel.enabled = false; email_error.text = ""; subject_error.text = ""; comment_error.text = ""; name_error.text = ""; name.textColor = 0x000000; email.textColor = 0x000000; subject.textColor = 0x000000; comment.textColor = 0x000000; iname.borderColor = 0x000000; isubject.borderColor = 0x000000; icomment.borderColor = 0x000000; result.text = "Working..."; method = "flash"; if(!alphaonly(iname.text)) { name_error.text = "Please, letters and spaces only"; name_error.borderColor = 0xFF0000; result.text = ""; name.textColor = 0xFF0000; name.enabled = false; result.text = "errors"; } else if(!alphaonly(isubject.text, "1", ".!?")) { subject_error.text = "Please, letters, spaces and '.!?' only"; subject_error.borderColor = 0xFF0000; result.text = ""; subject.textColor = 0xFF0000; submit.enabled = false; } else if(!emailcheck(iemail.text)) { email_error.text = "Please enter a valid e-mail address"; email_error.borderColor = 0xFF0000; result.text = ""; email.textColor = 0xFF0000; submit.enabled = false; } else if(icomment.length < 16) { comment_error.text = "Must be 16-1024 characters"; comment_error.borderColor = 0xFF0000; result.text = ""; comment.textColor = 0xFF0000; submit.enabled = false; } else { //start php and what not loadVariables("act.php",this,"POST"); this.error ? this.error = null : null; this.success = null; this.onData = function() { theerror = this.error; if(this.error != "" || this.error != NULL || this.error != "null") { result.text = theerror; } if(this.success == "y") { nextFrame(); } //result.text = this.error + this.success; } } submit.enabled = true; cancel.enabled = true;}[/code]And this is act.php[code=php:0]<?if($_POST['method'] == "flash") {$output = "error=1&reason=" . urlencode("Unknown error reason");$to = '[email protected]';$subject = $_POST['theisubject'];$message = $_POST['theicomment']."\n\n";$additionalHeaders = "From: {$_POST['theiname']}<{$_POST['theiemail']}>\n";$additionalHeaders .= "Subject: test\n";$additionalHeaders .= 'Reply-To: '.$_POST['theiemail'];if(@mail($to, $subject, $message, $additionalHeaders)) {$output = "success=y";}else {$output = "error=1&reason=" . urlencode("There was an error with the server. Please try later.");}echo $output;}?>[/code]Basically what happens is the actionscript checks for the errors as much as it can (I include a file ot do regexp with since it is not currently integrated with flash) and then if there is no error flash catches it passes it to add.php via the POST variable.What happens is loadVariables("act.php",this,"POST"); passes all the variables to act.php via post and returns the output from act.php to this. For example if you loaded the vars and act outputted "name=corbin" and then you echoed this.name it would say corbin.I'm not sure if this makes sense, and you're probably better off with a flash-php tutorial, but I tried lol. Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157002 Share on other sites More sharing options...
offsprg01 Posted January 10, 2007 Share Posted January 10, 2007 actually corbin that sums it up pretty well, but then agian i'm a flash developer so thats all pretty simple stuff.... /shrugif you are looking to learn flash check out nerdbooks.com and get yourself a visual quick start guide to flash, and a visual quick start quide to action script. the visual quick start series of books is the greatest thing since slice bread, and while you're at it get the vqsg to php. all three books wil cost you about 45-50 dollars from nerdbooks.com there store is down the street from my house, so i have a crap load of their books. Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157103 Share on other sites More sharing options...
thatisme Posted January 10, 2007 Author Share Posted January 10, 2007 corbin: I didn't make much sense to me, sorry.. but thanks anyway :) offsprg01: How would it be possible to combine that flash-application to a php-script to "rank" it?Thank you.. Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157205 Share on other sites More sharing options...
adrianTNT Posted January 10, 2007 Share Posted January 10, 2007 Hello.// I am the one that sells the product.Since I am a flash developer myself (not php developer), the php part of this product was made by someone else so I cannot make such updates that require additional php coding, this is why I suggested to the user that he should ask here about such php modifications.Here are some details about how it words, maybe someone knows how it should be done.The rating system is a swf file that sends and loads data by a php file in background, the flash file sends an id (photo1, photo2) ot the php file and the php file returns the rating score (1..5) and flash file shows the stars (1..5).I think this could be done by adding php script inside the html code of same page, send the id of all items to be rated to the php file and record the answers then display the swf files in the right order according to the answers received.[code]<?php $my_ids = array ('photo1','photo2','photo3');$my_scores = array ();send the id 'photo1' to the php (by GET I think) and record the answer (score 1..5);send the id 'photo2' to the php (by GET I think) and record the answer (score 1..5);send the id 'photo3' to the php (by GET I think) and record the answer (score 1..5);Display the html code to show all swf files in the order according to the scores received above.?>[/code]That should be a way to do it but I don't know if is possible without the product code and since is commercial product I cannot post he files for download. Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157271 Share on other sites More sharing options...
corbin Posted January 11, 2007 Share Posted January 11, 2007 OK so you're trying to make a flash script that lists the top rated X entries or entries descending or something like that?I'm what I would call a 'Flash novice,' but I would make a flash file with a blank text area (or well it formatted so the text area(s) could be populated with text later) and then I would get info from a php file. The php file would do something like "SELECT * FROM table ORDER BY rating DESC" and then it would output it to the flash script. The flash script would loop through it populating names and making links to it and saying the rating and so on...If you're not pulling it from a database that could make things a lot harder... Also, I may be wrong about what you're even trying to do lol... Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157809 Share on other sites More sharing options...
adrianTNT Posted January 11, 2007 Share Posted January 11, 2007 The system doesn't use a database. It saves to plain file.Maybe is not such a good idea to use my rating system in this case.Or if you want to use it then easiest way would be to talk to a php developer after you have the rating system so that person can see the code and chose best solution.When a php developer sees the system it should be easy for him to do the additional code that sorts the swf files inside html code.What I had in mind is a php script that orders the html code for displaying each swf file in correct order. Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157821 Share on other sites More sharing options...
corbin Posted January 11, 2007 Share Posted January 11, 2007 Oh so the desired page would output each actual voting flash app for each voting ID thing in a certain order? Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157829 Share on other sites More sharing options...
adrianTNT Posted January 11, 2007 Share Posted January 11, 2007 Yes, that is the best way I see it. Order html code for displaying each swf file; not order all the items inside one main swf file.Right [b]Thatisme?[/b] Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157832 Share on other sites More sharing options...
corbin Posted January 11, 2007 Share Posted January 11, 2007 I can try to write a PHP script if one of you two can tell me what format the ratings are kept in. Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157852 Share on other sites More sharing options...
thatisme Posted January 11, 2007 Author Share Posted January 11, 2007 Hmm... I've red what you guys have said, but it dosen't make much sense to me... Is it possible in some way to rank them?"I can try to write a PHP script if one of you two can tell me what format the ratings are kept in."That would be great... adrianTNT? Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157862 Share on other sites More sharing options...
corbin Posted January 11, 2007 Share Posted January 11, 2007 Basically what the php script would do would be:Read the file that contains the ratings into an array;Sort the array by average rating descending;output the html in the correct order to have each ranking script with the highest rankings at the top of the page and so on... Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157863 Share on other sites More sharing options...
thatisme Posted January 11, 2007 Author Share Posted January 11, 2007 Alright =)But you are confident that it'll work? Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157878 Share on other sites More sharing options...
corbin Posted January 11, 2007 Share Posted January 11, 2007 No reason it wouldn't work... I just need to know what format the text file that stores the voting stuff is in. I can't write it tonight - bout to go to sleep, but I'll try tommorow. Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157935 Share on other sites More sharing options...
thatisme Posted January 11, 2007 Author Share Posted January 11, 2007 Thank you very much for your time :)Could you make such a script if I buy the flash-application ? Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-157938 Share on other sites More sharing options...
adrianTNT Posted January 11, 2007 Share Posted January 11, 2007 Corbin, the plain file is stored as _id_of_item_to_be_rated.dat and there is a .dat file for each item id to be rated.An example of database file woudl be: video1.dat and its contents is like this:3|68.117.115.1825|34.117.115.122that is user's vote (1..5) | user's ip.now maybe the script can do this....get an array of IDs from the user (items to be rated, e.g video1,video2,video3) and from same directory as the php file read the dat file for each one of them, calculate the average (1 to 5) then print them in the right order, this print will later be the display of the swf file.video1 score 5video2 score 3video3 score 1Do I make sense ? Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-158290 Share on other sites More sharing options...
corbin Posted January 12, 2007 Share Posted January 12, 2007 Ooohhh so files are named like 1.dat 2.dat 3.dat so on?Hmmm I'll try to make something real quick... Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-158884 Share on other sites More sharing options...
corbin Posted January 12, 2007 Share Posted January 12, 2007 I did like adrian said and it lists the files in ascending numeric order. On rank2.php it makes php files with X swf things per file.I'll attach the files, but unless you understand them I suggest not messing with them until I explain them tomorrow (head ache and it's 1:30AM here >.<).Basically they're like mini template based through sprintf if that makes any sense...Live copy running at http://corbin.no-ip.org/rank/And no the script isn't stuck on 3's lol... I used phps random function to generate numbers 1-5 and of course that average would be 2.5 which would round to 3...[attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/33529-combine-flash-and-php/#findComment-158913 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.