This just includes some basic functions for php that can help you out greatly. THis file can be found HERE (http://dubzone.us/scripts/php/basicfunctions.txt) to be included with your script if wanted. It is not recommended, but it is possible to eval(file_get_contents($link)); if you would like to have the dynamically updating version, but most people would not advise that as it imposes security issues since I could easily modify it and break into your scripts (which I wouldn't, I respect your security and wish the same to me).

/*
* @credit Dubz
*
* Checks if the user is on a proxy network
* NOTE: This is not 100% guaranteed and may return false positives if the client is running a webserver
*
* @return A boolean regarding if they are on a proxy
*/
function usingProxy()
{
return checkPort(getIP(), 80);
}
?>

Thanks for the tip. Although I've been coding in PHP for a few years now, I still don't know all the functions (especially since I've taught myself the whole way through). I'll definitely have to update that on the file and use it instead. It was nice for me to make it though since it gave me a challenge and some practice on using recursion which is also a good thing, but every coder knows resources are important!

Dubz

02-28-2013, 08:34 PM

The code that is listed in this post is current, however the link is not currently working. I will try to get a working link soon for anyone who cares for updates for it (not too often).

Dubz

04-06-2013, 03:50 AM

I have created a couple more functions and added them to the list for those who would like them. If you would like to stay updated, you can use the link here (http://dubone.us/scripts/php/basicfunctions.php) for now but I will try to keep updating it here as well (I don't add too many functions that often). Please don't hotlink to the file as it is on free hosting and I don't have unlimited bandwidth. If anyone knows of a place this can be hosted and linked to (without the link changing on updates) for free and has a good uptime, please let me know.

/*
* @credit kbluhm
*
* Turns an array into a string to be saved to a php file
* Used to save an array to a php file instead of a text file, which will not show up if ran
*
* @param $array Array to be converted to string
* @param $arrayName Name to be used for array in return
* @return Returns a string of a php array in standard php format
*
*/
function array2Text($array, $name = 'array')
{
$text = '$'.$name.' = '.var_export($array, true).';';
}

/*
* @credit Dubz
*
* Checks if the user is on a proxy network
* NOTE: This is not 100% guaranteed and may return false positives if the client is running a webserver
*
* @return A boolean regarding if they are on a proxy
*/
function usingProxy()
{
$blockedPorts = array('80', '443');
foreach($blockedPorts as $port)
{
if(checkPort(getIP(), $port))
return true;
}
return false;
}

/*
* @Credit Dubz
*
* Tells if a number is within the given range
*
* @param $num The number to check
* @param $low The lower number of the range
* @param $high The higher number of the range
* @return A boolen telling if the number is in the range
*/
function in_range($num, $low, $high)
{
return (($num >= $low) && ($num <= $high));
}

var_export isn't vetry friendly though when it comes to getting the thing back as a php arrray.

For that, use serialize() and unserialize() instead :thumbsup:

Dubz

10-06-2013, 06:07 AM

var_export isn't vetry friendly though when it comes to getting the thing back as a php arrray.

For that, use serialize() and unserialize() instead :thumbsup:

I used var_export so you could convert it to add to a php file and include in your scripts. Why would I rewrite a function to call a second function that I can't really change like this? It's worked for me so far with quotes and apostrophes and such, no problem yet.

Dubz

07-18-2014, 08:09 PM

I know it's been a while since anyone has posted in this thread or since I've said anything but I just wanted to inform everyone that I have moved this script onto GitHub to be more "coder friendly" and whatnot. I know GitHub is more secure and has more features than a simple hosted script I do so that is why I am doing this. The link to the repo will be shown below along with a link to the file directly (for those who don't know how to use GitHub).

If anyone has any simple functions they would like to see added to this just post the function below in the same format as the rest of them (with the comment header before it) and I will look over them. Keep in mind that they should not depend on other files/functions outside this script! Also, feel free to improve any functions listed or another member's function they post (if any do).