NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Nod's Useful Scripts :)

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search


Reply
 
LinkBack Thread Tools
Old 12-16-2008, 11:54 AM THREAD STARTER               #1 (permalink)
Senior Member
 
nodws's Avatar
Join Date: Jun 2008
Location: nodws.com
Posts: 1,622
nodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud of
 



Save a Life

[php] Nod's Useful Scripts :)


Random Password Generator
PHP Code:
<?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 Code:
<?
$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);
????: NamePros.com http://www.namepros.com/code/543091-nods-useful-scripts.html
$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

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

Auto Sanitize all GET and POST variables

PHP Code:
<?
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) ? 0;
        }
        return 
$var;
    }

$_GET=sanitize($_GET);
$_POST=sanitize($_POST);
????: NamePros.com http://www.namepros.com/showthread.php?t=543091
?>
Just Copy/Paste and use GET and POST vars as normal
__________________
Last edited by nodws; 12-18-2008 at 01:05 PM.
nodws is offline   Reply With Quote
Old 01-19-2009, 04:21 PM   #2 (permalink)
EGS
NamePros Regular
Join Date: Mar 2006
Location: New Jersey
Posts: 989
EGS is a name known to allEGS is a name known to allEGS is a name known to allEGS is a name known to allEGS is a name known to allEGS is a name known to all
 



This is a great code, but is there anyway you can duplicate this script:
https://www.grc.com/passwords.htm
EGS is offline   Reply With Quote
Old 01-19-2009, 08:18 PM THREAD STARTER               #3 (permalink)
Senior Member
 
nodws's Avatar
Join Date: Jun 2008
Location: nodws.com
Posts: 1,622
nodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud ofnodws has much to be proud of
 



Save a Life
sure just set
$length=64
and add ASCII characters to the $upper variable
__________________
nodws is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 12:02 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger