CONTEST - Submit your PHP [CLOSED]
Here you will find the latest competition contest and the entries for them. Hurry and submit yours now.
5 posts
Page 1 of 1
Hey guys,
I have an AWESOME prize to give away to you folks! Get excited for this one
Details:
Ends 17th November 2016
I will pick a winner myself
How to enter:
Submit your favourite PHP snippets. Simple. I am doing a lot of PHP programming at the moment and it would be nice to have a few examples up my sleeve if I need it.
Any snippet you submit will not be used commercially or redistributed so don't worry.
Here's the good part!
You will receive a copy of:
Lumino City
Broken Age
Titan Souls
I have played Broken Age on PC as I bought a copy when it was released and it's a really fun, challenging game that requires you to pay a lot of attention to detail. At least I had to anyway lol
If I haven't been clear on anything just ask and I will explain myself, but all you need to do is submit your PHP snippet and have your chance to win those three games
I have an AWESOME prize to give away to you folks! Get excited for this one

Details:
Ends 17th November 2016
I will pick a winner myself
How to enter:
Submit your favourite PHP snippets. Simple. I am doing a lot of PHP programming at the moment and it would be nice to have a few examples up my sleeve if I need it.
Any snippet you submit will not be used commercially or redistributed so don't worry.
Here's the good part!
You will receive a copy of:
Lumino City
Broken Age
Titan Souls
I have played Broken Age on PC as I bought a copy when it was released and it's a really fun, challenging game that requires you to pay a lot of attention to detail. At least I had to anyway lol
If I haven't been clear on anything just ask and I will explain myself, but all you need to do is submit your PHP snippet and have your chance to win those three games

Last edited by smashapps on Fri Nov 18, 2016 7:14 am, edited 1 time in total.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
Here's one to get the Video ID from a Youtube 'watch' URL.
Example URL:
Example URL:
https://www.youtube.com/watch?v=IgQWRuo2D6wThis is the code:
Code: Select all
Usage:
function youtubevideoid($videourl)
{
if (preg_match('![?&]{1}v=([^&]+)!', $videourl . '&', $m))
return $m[1];
}
Code: Select all
Will return:
youtubevideoid("https://www.youtube.com/watch?v=IgQWRuo2D6w");
IgQWRuo2D6w
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Heres my no database required login
I was bored one day and decided to make this login system that doesnt require any database.
It saves all userdata to a file, of own choice with encrypted names and passwords
I made it just for fun to check out some functions of php
Class: Rollover to view spoiler
Usage: Rollover to view spoiler
I was bored one day and decided to make this login system that doesnt require any database.
It saves all userdata to a file, of own choice with encrypted names and passwords
I made it just for fun to check out some functions of php
Class: Rollover to view spoiler
Code: Select all
[/spoiler]<?php
class user {
private $credentials_file;
public function __construct($credentials_file){
$this->credentials_file = $credentials_file;
if(!file_exists($credentials_file)){
file_put_contents($credentials_file, serialize(array()));
}
}
function salt($length){
$output = '';
$i = 0;
$chars = array_merge(range('A','Z'), range('a','z'), range('0','9'));
$count = count($chars) - 1;
while($i < $length){
$output .= $chars[mt_rand(0,$count)];
$i++;
}
return $output;
}
function encrypt($input, $key) {
if (strlen($key) >= 33){
$key = substr($key, 0, 32 - strlen($key));
}
$size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($size, MCRYPT_RAND);
$output = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, utf8_encode($input), MCRYPT_MODE_ECB, $iv);
return $output;
}
function decrypt($input, $key) {
if (strlen($key) >= 33){
$key = substr($key, 0, 32 - strlen($key));
}
$size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($size, MCRYPT_RAND);
$output = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $input, MCRYPT_MODE_ECB, $iv);
return $output;
}
function create($username, $password, $salt){
$credentials_file = $this->credentials_file;
$username = $this->encrypt($username, $salt);
$password = $this->encrypt($password, $salt);
$credentials = file_get_contents($credentials_file);
$credentials = unserialize($credentials);
if(!array_key_exists($username, $credentials)){
$credentials[$username] = $password;
$output = array("status" => true, "reason" => "User created");
} else {
$output = array("status" => true, "reason" => "User already exists");
}
$credentials = serialize($credentials);
file_put_contents($credentials_file, $credentials);
return $output;
}
function remove($username, $password, $salt){
$credentials_file = $this->credentials_file;
$username = $this->encrypt($username, $salt);
$password = $this->encrypt($password, $salt);
$credentials = file_get_contents($credentials_file);
$credentials = unserialize($credentials);
if(array_key_exists($username, $credentials)){
if($credentials[$username] == $password){
unset($credentials[$username]);
$credentials = serialize($credentials);
file_put_contents($credentials_file, $credentials);
$output = array("status" => true, "reason" => "User succesfully removed");
} else {
$output = array("status" => true, "reason" => "Wrong password");
}
} else {
$output = array("status" => true, "reason" => "User dosent exists");
}
return $output;
}
function login($username, $password, $salt){
session_start();
$credentials_file = $this->credentials_file;
$original_username = $username;
$username = $this->encrypt($username, $salt);
$password = $this->encrypt($password, $salt);
$credentials = file_get_contents($credentials_file);
$credentials = unserialize($credentials);
if(array_key_exists($username, $credentials)){
if($credentials[$username] == $password){
$_SESSION['auth'] = 2;
$_SESSION['username'] = $original_username;
$output = array("status" => true, "reason" => "User succesfully logged in");
} else {
$output = array("status" => true, "reason" => "Wrong password");
}
} else {
$output = array("status" => true, "reason" => "User dosent exists");
}
return $output;
}
}
?>
Usage: Rollover to view spoiler
Code: Select all
[/spoiler]<meta charset="UTF-8">
<?php
require_once('classes/user.php');
$user = new user('permission.ini');
$salt = "TYe0Z8TEHvJElf0eHs3iUai2GjU4WCG7";
/* //Create user */
if(isset($_GET['username']) != '' && isset($_GET['password']) != ''){
$username = $_GET['username'];
$password = $_GET['password'];
$create = $user->create($username, $password, $salt);
if($create['status']){
echo $create['reason'];
}
}
echo '<br>';
/* //User login */
if(isset($_GET['username']) != '' && isset($_GET['password']) != ''){
$username = $_GET['username'];
$password = $_GET['password'];
$remove = $user->login($username, $password, $salt);
if($remove['status']){
echo $remove['reason'];
}
}
echo '<br>';
//User remove
if(isset($_GET['username']) != '' && isset($_GET['password']) != ''){
$username = $_GET['username'];
$password = $_GET['password'];
$login = $user->remove($username, $password, $salt);
if($login['status']){
echo $login['reason'];
}
}
echo '<br><br><br>';
@session_start();
var_dump($_SESSION);
?>
Still 6 days to go if you want to enter the contest 

My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
Okay guys the contest is over!
the winner is CodenStuff, congratulations. Sorry AnoPem
the winner is CodenStuff, congratulations. Sorry AnoPem

My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023