Calling all PHP Programmers:
I will be putting together a PHP framework for all DIC users to use and help evolve. This framework will not be like ZEND and Cake, mainly because I want it light. I want it to be a couple of folders that the user can drop and get running. PLEASE LET ME KNOW IF YOU ARE WILLING TO WORK ON ANY PART OF THIS AND I WILL ADD YOUR NAME TO THE SECTION. PLEASE REMEMBER TO INCLUDE YOUR SQL and DATABASE SCHEMA. So what I am thinking is as follows:
- Constants (gregwhitworth)
CLASSES:
Database:
- Add (gregwhitworth)
- Update (gregwhitworth)
- Count
- Delete (gregwhitworth)
- Connect (gregwhitworth)
SESSION
- Is Admin (gregwhitworth | Dormilich)
- Return User Role (gregwhitworth | Dormilich)
- Is logged in (gregwhitworth | Dormilich)
- Return Username (gregwhitworth | Dormilich)
User Management:
- Add User
- Delete User
- Edit User
- Create Roles
- Delete Roles
- Modify User Roles
- Login User
- Logout User
User Queries:
- User Queries
- Admin Queries
- etc.
File Management
- Upload File (gregwhitworth)
- File/Directory Exists (gregwhitworth)
- Delete File (gregwhitworth)
- Rename File
Security:
- XSS (gregwhitworth)
- SQL Injection (gregwhitworth)
FUNCTIONS
- Is email (gregwhitworth)
- Encrypt (gregwhitworth)
- Decrypt (gregwhitworth)
- Is SSN (gregwhitworth)
- Is Phone Number (gregwhitworth)
Error/Info Message Handling:
- Return Message (calebj | Dormilich)
- Clear Message (calebj | Dormilich)
- Create Message (calebj | Dormilich)
- Is Message Set (calebj | Dormilich)
Please feel free to send me any functions that have helped you out on a day to day basis to add to the functions file. Understandably this will take some coordination on our part, as the SESSION class developer will need information from the USER MANAGEMENT developer and all will need the DATABASE class developer's info. Let me know what you are willing to work on.
I will update this when I can...
I will be putting together a PHP framework for all DIC users to use and help evolve. This framework will not be like ZEND and Cake, mainly because I want it light. I want it to be a couple of folders that the user can drop and get running. PLEASE LET ME KNOW IF YOU ARE WILLING TO WORK ON ANY PART OF THIS AND I WILL ADD YOUR NAME TO THE SECTION. PLEASE REMEMBER TO INCLUDE YOUR SQL and DATABASE SCHEMA. So what I am thinking is as follows:
- Constants (gregwhitworth)
CLASSES:
Database:
- Add (gregwhitworth)
- Update (gregwhitworth)
- Count
- Delete (gregwhitworth)
- Connect (gregwhitworth)
SESSION
- Is Admin (gregwhitworth | Dormilich)
- Return User Role (gregwhitworth | Dormilich)
- Is logged in (gregwhitworth | Dormilich)
- Return Username (gregwhitworth | Dormilich)
User Management:
- Add User
- Delete User
- Edit User
- Create Roles
- Delete Roles
- Modify User Roles
- Login User
- Logout User
User Queries:
- User Queries
- Admin Queries
- etc.
File Management
- Upload File (gregwhitworth)
- File/Directory Exists (gregwhitworth)
- Delete File (gregwhitworth)
- Rename File
Security:
- XSS (gregwhitworth)
- SQL Injection (gregwhitworth)
FUNCTIONS
- Is email (gregwhitworth)
- Encrypt (gregwhitworth)
- Decrypt (gregwhitworth)
- Is SSN (gregwhitworth)
- Is Phone Number (gregwhitworth)
Error/Info Message Handling:
- Return Message (calebj | Dormilich)
- Clear Message (calebj | Dormilich)
- Create Message (calebj | Dormilich)
- Is Message Set (calebj | Dormilich)
Please feel free to send me any functions that have helped you out on a day to day basis to add to the functions file. Understandably this will take some coordination on our part, as the SESSION class developer will need information from the USER MANAGEMENT developer and all will need the DATABASE class developer's info. Let me know what you are willing to work on.
I will update this when I can...
13 Comments On This Entry
Page 1 of 1
calebjonasson
24 September 2010 - 10:44 AM
functions for authentication:
<?php
//will work if there are ranks going from 1 - 9
function admin($var = 8){
if($_SESSION['SESS_RANK'] < $var || !isset($_SESSION['SESS_RANK'])){
set_error_message('You must have a rank of: '.rank_case($var));
header('location: index.php');
exit();
}
}
// authentication used in if statements
function adminb($var = 8){
if($_SESSION['SESS_RANK'] < $var || !isset($_SESSION['SESS_RANK'])){
return false;
}else{
return true;
}
}
//Used to check if the user is logged in or not.
function auth(){
//Start session
//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
set_error_message('You must be logged in to do that.');
header("location: denied.php");
exit();
}
}
function authb(){
if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')){
return false;
}else{
return true;
}
}
//This is used to display the rank of the user based on session.
function rank_case($var = 0){
switch ($var){
case 0: return "Member";
case 1: return "";
case 2: return "";
case 3: return "";
case 4: return "";
case 5: return "Moderator";
case 6: return "";
case 7: return "";
case 8: return "Admin";
case 9: return "Leader";
}
}
?>
calebjonasson
24 September 2010 - 11:18 AM
Handling error messages
Here are some php functions that will allow the user to see some error messages or messages in general.
This will need to be appended to the style.css sheet.
The functions display_message and display_error_message can be added to the general page structure near the top so if there is an error message it will be displayed but then if the page is refreshed it will be cleared.
Here are some php functions that will allow the user to see some error messages or messages in general.
<?php
function set_error_message($var = "There was a problem."){
$_SESSION['SESS_ERROR_MESSAGE'] = $var;
}
function display_error_message(){
$t1 = $_SESSION['SESS_ERROR_MESSAGE'];
if(isset($t1)){
echo '<div class="error-message">'.$t1.'</div>';
}
clear_error_message();
}
function clear_error_message(){
$_SESSION['SESS_ERROR_MESSAGE'] = null;
}
function set_message($var){
$_SESSION['SESS_MESSAGE'] = $var;
}
function display_message(){
$t1 = $_SESSION['SESS_MESSAGE'];
if(isset($t1)){
echo '<div class="good-message">'.$t1.'</div>';
}
clear_message();
}
function clear_message(){
$_SESSION['SESS_MESSAGE'] = null;
}
?>
This will need to be appended to the style.css sheet.
.error-message{
padding:5px 10px;
margin: 10px 0;
color: #000;
background: #cc3333;
-moz-border-radius:3px;
-webkit-border-radius:3px;
font-size: 14px;
}
.good-message{
padding:5px 10px;
margin: 10px 0;
color: #000;
background: #D0E86D;
-moz-border-radius:3px;
-webkit-border-radius:3px;
font-size: 14px;
}
The functions display_message and display_error_message can be added to the general page structure near the top so if there is an error message it will be displayed but then if the page is refreshed it will be cleared.
calebjonasson
24 September 2010 - 11:52 AM
haha awesome.
I have this function that I just finished to check an email address.
I have this function that I just finished to check an email address.
<?php
function check_email($email, $rec = 'MX'){
$email = trim($email);
$v1 = strstr($email, ' ');
if($v1 != null){
return false;
}
list($start, $domain) = split("@", $email);
if(isset($start) && isset($domain) && eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) > 0){
if(!empty($domain)) {
if( $rec == '' ) $rec = "MX";
exec("nslookup -type=$recType $hostName", $result);
foreach ($result as $line) {
if(eregi("^$hostName",$line)) {
echo "hostname is good";
return true;
}
}
return false;
}
return false;
}return false;
}
?>
calebjonasson
24 September 2010 - 01:18 PM
Oh wow that is great. I can work on phone numbers when I have some more free time. Possibly tonight. I would also like to do the encrypt/decrypt.
Here are two quick little functions that will redirect the user back if there is an issue. The here() function should be placed in the page so we can redirect back if there are issues with some back-end editting.
Here are two quick little functions that will redirect the user back if there is an issue. The here() function should be placed in the page so we can redirect back if there are issues with some back-end editting.
<?php
function back(){
session_start();
header('location: '.$_SESSION['back']);
}
function here(){
$_SESSION['back'] = $_SERVER['REQUEST_URI'];
}
?>
Dormilich
25 September 2010 - 04:53 AM
out of curiousity, what do you use for database handling? and why on earth are the errors saved in a session?
I can throw in a session handler and an error handler.
I can throw in a session handler and an error handler.
creativecoding
28 September 2010 - 06:14 PM
File upload.
<?
// Choose where to uploads will go.
$target_path = "uploads/";
//Do not edit below this line
$sub = $_POST['submit'];
if(isset($sub)){
if(!is_dir($target_path)){
@mkdir($target_path, 0777);
}
$doRename = $_POST['rename'];
$rename = $_POST['newname'];
$target_path = $target_path . basename( $_FILES['file1']['name']);
$target_path = str_replace("..", "", $target_path);
$ext = substr($_FILES['file1']['name'], strrpos($_FILES['file1']['name'], '.') + 1);
$ext = strtolower($ext);
$err = false;
if($ext == "gif" || $ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "zip" || $ext == "bmp" || $ext == "rar"){
$err = false;
}
else{
$err = true;
}
if(!$err == true){
if(move_uploaded_file($_FILES['file1']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['file1']['name']).
" has been uploaded.";
} else{
echo "There was an error uploading the file.";
}
}
else{
echo "That file type is not allowed.";
}
}
else{
?>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input name="file1" type="file" /><br />
<input type="submit" value="Upload" name="submit" />
</form>
<?php
}
?>
calebjonasson
20 July 2011 - 12:27 PM
Hey, this project seems to have simmered down and fizzled out. I'm still interested in the idea if you guys are and I was thinking that we should move it to an open source github project. thoughts?
calebjonasson
20 July 2011 - 12:27 PM
Hey, this project seems to have simmered down and fizzled out. I'm still interested in the idea if you guys are and I was thinking that we should move it to an open source github project. thoughts?
Page 1 of 1
Trackbacks for this entry [ Trackback URL ]
Tags
My Blog Links
Recent Entries
Recent Comments
-
-
-
calebjonasson
on Jul 20 2011 12:27 PM
The Official, ehem, The Unofficial Dream in Code PHP Framework! -
calebjonasson
on Jul 20 2011 12:27 PM
The Official, ehem, The Unofficial Dream in Code PHP Framework! -
Search My Blog
0 user(s) viewing
0 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)
|
|



13 Comments









|