Skip to content
Snippets Groups Projects
README.md 1.51 KiB
Newer Older
Nitestryker's avatar
Nitestryker committed
webtools.class.php
==================
Nitestryker's avatar
Nitestryker committed
a php class with useful tools

### Usage Examples:

Nitestryker's avatar
Nitestryker committed
###### Connect to MySQL 
 
 example:
 
Open($database, $server, $username, $password, $charset, $pcon = true or false)

setting the db params
```PHP
  $db = new webtools();
  if (! $db->Open("database", "db_server", "db_username", "db_password")) { 
    $db->Kill(); 
} 
 // successful connection do this


```
or you can use the pre-set params
```PHP
$db = new webtools();
 if (! $db->Open()) { 
    $db->Kill(); 
}
 // successful connection  do this 
 

Nitestryker's avatar
Nitestryker committed
```
######  IP to Location 
 
info params ( statusCode, statusMessage, ipAddress, countryCode, countryName,regionName , cityName , zipCode , latitude , longitude, timeZone )  

```PHP
$ip = webtools::ipLocation('ip_address', 'info_param');

Nitestryker's avatar
Nitestryker committed
```


Nitestryker's avatar
Nitestryker committed
###### Create a Salted md5 password 
```PHP
$password_string = "password_here"; 
$salted_md5 = webtools::SaltedMd5($password_string)

```
###### Validate a Salted md5 password (boolean)

```PHP
 $check = webtools::validateSaltedMd5($salted_md5, $password_string);
```

Nitestryker's avatar
Nitestryker committed
###### Shorten URL with Bitly API
```PHP
$get = new webtools();
Nitestryker's avatar
Nitestryker committed
$results = $get->bitlyShorten('http:/www.website.com','bitly_username','Bitly_API_key');
Nitestryker's avatar
Nitestryker committed
echo $results;
```
###### Email validation

```PHP
$check = new webtools();
if ($check->validEmail($email))
{
      /* if email is vaild  do this */
Nitestryker's avatar
Nitestryker committed
   
Nitestryker's avatar
Nitestryker committed
}
else
{
      /* if email is not valid do this */
Nitestryker's avatar
Nitestryker committed
    
Nitestryker's avatar
Nitestryker committed
}
```
###### Sanatize User's Input

```PHP
$new = new webtools();
$clean_data = $new->clean($data);
echo $clean_data;
```