Nod's Useful Scripts

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Nodws

Domain DeveloperVIP Member
Impact
266
PHP:
 Nod's Useful Scripts :)[/b]

Random Password Generator
[PHP]<?php
function cp($length=8,$use_upper=1,$use_lower=1,$use_number=1,$use_custom=""){
	$upper = "ABCDEFGHJKLMNPQRSTUVWXYZ";
	$lower = "abcdefghikmnopqrst";
	$number = "2345679";
	if($use_upper){
		$seed_length += 26;
		$seed .= $upper;
	}
	if($use_lower){
		$seed_length += 26;
		$seed .= $lower;
	}
	if($use_number){
		$seed_length += 10;
		$seed .= $number;
	}
	if($use_custom){
		$seed_length +=strlen($use_custom);
		$seed .= $use_custom;
	}
	for($x=1;$x<=$length;$x++){
		$password .= $seed{rand(0,$seed_length-1)};
	}
	return($password);
}
echo cp();
//Will Print password like: wNFclGol
?>
Just call with Echo ;)

-------------------------------------------

Replace Illegal Character with valid character function
PHP:
<?
$string= "Hi, I am a string!! and I      need$to be $$$$$$$ stripped-s_s";

function sstring($ss,$e)
{
$sg = ereg_replace("[^A-Za-z0-9".$e."]", $e, $ss);
$sg = str_replace($e.$e.$e,$e,$sg);
$sg = str_replace($e.$e,$e,str_replace($e.$e,$e,$sg));
return $sg;
}
echo sstring($string,"_");
// First parameter is string, Second is character to replace illegal chars with 
//will print Hi_I_am_a_string_and_I_need_be_stripped_s_s
?>
in this case Will replace Everything with _ except for Letters, Numbers and the given character :)

Rep and NP$ always welcome :tu:

------------------------------------------------

Auto Sanitize all GET and POST variables

PHP:
<?
function sanitize($var, $quotes = false) {
        if (is_array($var)) {   //run each array item through this function (by reference)       
            foreach ($var as &$val) {
                $val = sanitize($val);
            }
        }
        else if (is_string($var)) { //clean strings
            $var = mysql_real_escape_string($var);
            if ($quotes) {
                $var = "'". $var ."'";
            }
        }
        else if (is_null($var)) {   //convert null variables to SQL NULL
            $var = "NULL";
        }
        else if (is_bool($var)) {   //convert boolean variables to binary boolean
            $var = ($var) ? 1 : 0;
        }
        return $var;
    }

$_GET=sanitize($_GET);
$_POST=sanitize($_POST);
?>
Just Copy/Paste and use GET and POST vars as normal
 
Last edited:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
0
Close
sure just set
$length=64
and add ASCII characters to the $upper variable
 
0
Close
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back