reportingsjr Posted September 20, 2006 Share Posted September 20, 2006 I thought it would be neat to make a file with a bunch of custom functions, so people can download the file, put it on their server, and then just include it to have some functions you wouldnt normally have.So.. who's up for it? I am !If you didnt get it: This is just for fun, so people can have custom functions that are easy to use. They will just be a bunch of random ones to . If you want to help ill set up a php file, and people can email me scripts/functions or post them here. You will get credit for every function you make! If I start getting way too many scripts to add I will probably set up a ftp and domain and just let people edit it. But I will make it back up with a new file evrery 10 or so minutes so people dont delete the whole thing.Start sending them in, and I will make a list here .SOURCE CODE BELOW Link to comment Share on other sites More sharing options...
reportingsjr Posted September 20, 2006 Author Share Posted September 20, 2006 The file is at http://excibius.com/customfunctions/functions.phphere is the source code: //connects to database//CREATED BY: Reportingsjrfunction mysql_connector($host, $username, $password, $db){ $connection = mysql_connect($host, $username, $password); if($connection){ if(mysql_select_db($db)){ return true; }else{ return false; } }else{ return false; }}//testing function mysql_connecter()echo "mysql_connector(): ";if(mysql_connector()){ echo "succesful!<br />";}else{ echo "failed!<br />";}//encrypts anything you put in it and returns the encrypted thing//useful for passwords. Impossible to crack , pretty much//CREATED BY: Reportingsjrfunction cryption($var, $salt){ $super_salt = sha1($salt) . md5($salt); $salted = $var; $salted .= $salt; $salted .= $var; $salted .= $var; $salted .= $salt; $reversed = strrev($salted); $salted .= $salt; $salted .= $reversed; $salted .= $super_salt; $crypt2 = md5($salted); $final = sha1($crypt2); return $final;}//testing function cryption()echo "cryption(): crypting 'reportingsr' with salt 'ja1qd6': " . cryption('reportingsjr', 'ja1qd6') . "<br />";//Will generate a random string with numbers and letters, as long as specified length//CREATED BY: Reportingsjrfunction rand_str($length){ $pattern = "1234567890abcdefghijklmnopqrstuvwxyz"; for($i=0;$i<$length;$i++) { if(isset($key)) $key .= $pattern{rand(0,35)}; else $key = $pattern{rand(0,35)}; } return $key;}echo "rand_str(): creating a random string with a length of 13 - " . rand_str('13') . "<br />"; That encryption is super hard to crack, escpecially if the person uses a good salt .I will keep updating. If you dont know php/cant write a function just post the idea for it here and I will try to make it happen! Link to comment Share on other sites More sharing options...
DeathRay2K Posted September 20, 2006 Share Posted September 20, 2006 Its being stupid, and the functions wont work for some weird reason!Anyways, the file is http://excibius.com/customfunctions/functions.php You have to put that in a zip or something for people to be able to download it, because it just parses it if its left as a php file. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 21, 2006 Share Posted September 21, 2006 Or write highlight_file(__FILE__); at the top.But people will obviously want to remove that if they use it. Link to comment Share on other sites More sharing options...
reportingsjr Posted September 21, 2006 Author Share Posted September 21, 2006 Yea i know, I will do that later though. So you want to help?Also: I will post the source on here.. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 21, 2006 Share Posted September 21, 2006 If I get a chance later I'll look through my utility functions and see if I have anything to add. One of them would be a function to redirect and ensure the session stays set, good for a login page. I'll see if I have anything else. Link to comment Share on other sites More sharing options...
reportingsjr Posted September 21, 2006 Author Share Posted September 21, 2006 mmkay! Any ideas for a functions? I cant really think of any =\ Link to comment Share on other sites More sharing options...
murfitUK Posted September 24, 2006 Share Posted September 24, 2006 I'd like a function please!! I'm trying to create one now but maybe someone has already done it.Someone has taken a quiz and scored eg 15 out of 20. Pass these two numbers to the function, it calculates the percentage score (eg 75%) and it draws a narrow, long box with green for the first 75% of the width and red for the last 25%.I'm thinking about a table of say 300px long and 10px tall, and then having two td's of a width specified in %age terms.I'll let you know how I get on but if anyone has already got something like this.....! Link to comment Share on other sites More sharing options...
murfitUK Posted September 24, 2006 Share Posted September 24, 2006 Well, I've made a start. If anyone's interested:http://www.murfituk.com/graphscore/example.php(Now - has anyone got a php function to clean spilt coffee from a keyboard?) Link to comment Share on other sites More sharing options...
aquatsr Posted September 24, 2006 Share Posted September 24, 2006 (Now - has anyone got a php function to clean spilt coffee from a keyboard?)Only in C++ Link to comment Share on other sites More sharing options...
boen_robot Posted September 24, 2006 Share Posted September 24, 2006 I think this is what Web Services exist for. Let me explain...reportingsjr can make a PHP file on his server that will serve as a Web Service server. It will contain a function he created for others to reuse. A Web Services client will connect to that file and pass arguments for his function. The function returns a result or a set of results based on the arguments which the client then uses as (s)he pleases.If reportingsjr decides to alter the function, he can do it on his server and anyone using the function will use the result from the updated version.Without web services, the new version of the code will have to be posted and re-edited by everyone who has used the old one. Link to comment Share on other sites More sharing options...
jhecht Posted September 24, 2006 Share Posted September 24, 2006 Yeah sure i'd help with this... just need to know what kind of functions people want/need. function checkscore($right,$total,$width=300,$height=15){/* width is the width of the div/table that you are going to use, height is the height of the div/table; */$wrong = (int)$total-(int)$right;//Number of wrong answers, just in case you want to output it somewhere.$percentRight = $right/$total;//Number of percents right; obvious;$right_width = $percentRight * $width;//How big the percentage of what is right will be;$table = "<table width=\"$width\" height=\"$height\">\n";$table.= "<tr>\n";$table.= "<td width=\"$right_width\" bgcolor=\"green\"> </td>\n<td bgcolor=\"red\">\n \n</td>\n";$table.="</tr>\n";return $table;} Dont know if it works... didnt test it, but that should be something like what you need. Link to comment Share on other sites More sharing options...
reportingsjr Posted September 25, 2006 Author Share Posted September 25, 2006 Sorry! I was unaware this had more posts! Boen, can people include files on my server? I thought you couldnt do that, but if you can it would be awesome!!heres a code to do exactly what you want murfit! I actually made one of these for my poll . function percent_bar($right, $total, $height = 20, $width = 300){ if($right > $total || $total == "0"){ echo "An error has occured with the percent graph!!"; }else{ if($height < "20" || $width < "50"){ echo "The specified width and height are not lare enough for this graph!!"; }else{ $percent_width = $width/100; $decimal_percent = $right/$total; $percent = $decimal_percent * 100; $total_percent = $percent * $percent_width; $percent_wrong = 100 - $percent; $total_percent_wrong = $percent * $percent_width; echo "<div style='width: {$width}px; height: {$height}px; background-color: #FF0000;text-align: right;color: brown;'><div style='background-color: #00FF00; width: {$total_percent}px; text-align: left;float: left;height: 100%;'>{$percent}%</div>{$percent_wrong}%</div>"; } }} thats what you want!Give me a while to fix it up, gotta make it nice!!Done!Its on http://excibius.com/customfunctions/functions.php , I might make it so you can put your own lengths and widths and such.. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 25, 2006 Share Posted September 25, 2006 Ooops, I forgot to check at home. For the percent bar, it would probably be easier to just generate an image. I did that for something, so I'll add that to my list of things to do when I get home. Link to comment Share on other sites More sharing options...
reportingsjr Posted September 25, 2006 Author Share Posted September 25, 2006 Its just as easy to do mine too . But yea, gd library would be easy to, I guess. Link to comment Share on other sites More sharing options...
DeathRay2K Posted September 26, 2006 Share Posted September 26, 2006 Easy enough. function percentbar($correct, $total, $width, $height) { $percent = $correct / $total; $percent *= $width; $im = imagecreatetruecolor($width, $height); $green = imagecolorallocate($im, 0, 255, 0); $red = imagecolorallocate($im, 255, 0, 0); imagefilledrectangle($im, -1, 0, $percent, $height - 1, $green); imagefilledrectangle($im, $percent, 0, $width, $height - 1, $red); imagepng($im); imagedestroy($im); } Link to comment Share on other sites More sharing options...
reportingsjr Posted September 26, 2006 Author Share Posted September 26, 2006 Thank you death! This should work considering the image is being created in another file, and there wont be any direct output from it (later). I will add this as soon as I finish working on my game!I am forced by my parents to stay up until 12:30 am in the morning lol. And its a school day. I have to go to the hospital and take an EEG (electrical somethin something) to monitor my brain activity or something. Meh, gotta have 4 hours or less of sleep -.- . Link to comment Share on other sites More sharing options...
murfitUK Posted September 26, 2006 Share Posted September 26, 2006 I get a call to undefined function for the imagefilledrectangle thing. Does this mean my php is out of date? I'm on version 4.4.2. Daren't try to upgrade as it took me long enough to get this one up and working.Good luck with the EEG reportingsjr. Hope its nothing too serious. Link to comment Share on other sites More sharing options...
boen_robot Posted September 27, 2006 Share Posted September 27, 2006 Boen, can people include files on my server?The point is for them NOT to upload things on your server, but have it on their own, yet share it's capabilities with others. When they need a change they do it and everyone else uses the new function instantly.Constructing a SOAP server and client however is not exactly a straight process. When I have the time and nerves to make a site of mine, I would probably post some "how-to"s for this there. Until then... dunno. Share functions the old fasion way I guess. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now