Hey there want any script coded using PHP? I'll do it for ya! I wanna learn PHP and I am practicing hard to become a good PHP Coder, so if you need any PHP work done, let me know!
Printable View
Hey there want any script coded using PHP? I'll do it for ya! I wanna learn PHP and I am practicing hard to become a good PHP Coder, so if you need any PHP work done, let me know!
Create a php shell.
I think you're aiming way too high. You should focus on small projects whilst at such a level of competence. Perhaps create a thread like this in the future...
"I am pretty good in PHP"
But you don't know what a shell is?
How are you even good in PHP if you can't protect your scripts.
http://en.wikipedia.org/wiki/Backdoor_Shell
@jur13n I am just basically getting good with OOP style and Database driven applications, I am not good with security and stuff, I am trying to learn safe ways of doing that. Thank you for telling me about shells, I will try to read that and try to understand the logic of that and try coding it.
// Edit @jur13n I read that wiki document, shells are viruses, and why do you want to code me one? I don't want to code viruses. Thank you for the Security wiki, it was really informative.
@jur13n can you explain me the logic of how it works? And I'll code it up and PM you the source and you can check if it is correct or not, okay? :P
Could you provide some earlier code samples?
There is no logic to how it works.
The logic is to be made by you.
In every application you create (Yeah, I rather call a website an Application)
You think of your OWN logic to create it.
If you use a framework/template or what so ever.
You just create your OWN logic based on a logic that has been pre-created.
But knowing your skills so far, I don't presume you use any framework/template at all..
- - - Updated - - -
Oh ps.
If you really want to create a good application.
Make me a PDO mysql CRUD REST API in php
There are 3things here;
- CRUD
- REST
- PDO MySQL
Rest is a way of processing a request and/or sending data.
http://en.wikipedia.org/wiki/Represe...state_transfer
PDO MySQL:
http://nl1.php.net/pdo_mysql
use prepared statements etc.
CRUD:
Create, Read, Update, Delete.
- Create = INSERT (mysql)
- Read = SELECT
- Update = UPDATE
- Delete = DELETE
based on mysql stuff
I would like to have a an api, that I can send a request with as example;
SELECT
$param1
FROM $param2
WHERE $param3
I would request A SELECT with 3 parameters.
Make it class based.
This would be a good practice.
@jur13n I tried coding a tpl system but failed, I am going to re-start it after my portfolio is done, and I want more explanation, I dont understand. Plus I code in MySQLi Prepared Statements. ;P
@jur13n no I don't know to work in MVC can you teach me? And I am using MySQLi prepared Statements no mysql, and sure, I will use PDO if you are suggesting me that. I'll google it and try learning it out. And I never uesd RainTPL, I tried to code my own.
How about creating error/exception handling system,
- which would allow to store application level error message(that can be easily integrated with template system)
- for example store custom errors into static variable then retrieve and format them when needed
- enable put limit to log file size
- if log size has exceeded max limit then take appropriate action
- overwrite
- create and write to new file
- ignore
- etc
- option to disable duplicated log writing
- only if log file size do not exceed max log size
- and only if exceed action is not ignore, since it would require open and search old log file(it would be slow on big logs)
- convert php internal errors to exceptions
- add debug options and strict mode
Okey, i got kinda interested making this myself, so here it is :D
PHP Code:/*
* System Definitions
*
*/
define('EXCEPTION_SYSTEM' ,'error_system');
define('EXCEPTION_C_SILENT' ,'error_silent');
define('EXCEPTION_C_USER' ,'error_user');
define('EXCEPTION_C_PHP' ,'error_php');
/*
* Lower level functions
*
* These function must not be dependent on any other function or class.
*
*/
function __write($type,$file,$message,$extension = 'php',$flags = LOCK_EX)
{
file_put_contents(BASE_PATH.'application/storage/'.$type.'/'.$file.'.'.$extension,$message,$flags);
}
/**
* Read Config File
*
* Reads and stores configuration file
*
* [MENTION=1333357818]param[/MENTION] string $name configuration file name
*
* [MENTION=850422]return[/MENTION] array
* [MENTION=2000032449]Throws[/MENTION] Exception
*/
function __config($name)
{
static $configuration = array();
if(isset($configuration[$name])){
return $configuration[$name];
}
$config = NULL;
if(is_file(BASE_PATH.'application/'."configuration/$name.php"))
{
include BASE_PATH.'application/'."configuration/$name.php";
if(is_array($config))
{
$configuration[$name] = $config;
}
else
{
throw new Exception("Configuration file '{$name}' is not in valid format!");
}
}
else
{
throw new Exception("Configuration file '{$name}' cannot be found!");
}
return $configuration[$name];
}
/**
* Get Config File Option
*
* Attempts to get configuration file option value,
* If configuration file is not loaded this function will load it.
*
* [MENTION=1333357818]param[/MENTION] string $name configuration file name
* [MENTION=1333357818]param[/MENTION] string $key configuration key to retrieve
*
* [MENTION=850422]return[/MENTION] mixed
* [MENTION=2000032449]Throws[/MENTION] Exception
*/
function __item($name,$key)
{
if(isset(__config($name)[$key]))
{
return __config($name)[$key];
}
else
{
throw new Exception("Configuration file '$name' do not have required option '$key'!");
}
}
/*
* Higher level functions
*
* These function can depend on other function or class.
*
*/
/**
* [MENTION=1333357818]param[/MENTION] null|string $message
* [MENTION=1333357818]param[/MENTION] string $type
*
* [MENTION=850422]return[/MENTION] array
* [MENTION=2000032449]Throws[/MENTION] Exception
*/
function __exception($message = NULL,$type = EXCEPTION_SYSTEM)
{
static $userExceptions = array();
if($message == NULL)
{
if(isset($userExceptions[$type]))
{
return $userExceptions[$type];
}
}
else
{
$_Write = false;
$_Display = false;
if($type == EXCEPTION_SYSTEM)
{
if(__item('common','DisplayErrors') == true OR __item('common','DebugMode') == true)
{
throw new Exception($message);
}
else
{
$_Display = true;
$_Write = true;
}
}
else
{
if($type == EXCEPTION_C_SILENT OR $type == EXCEPTION_C_PHP)
{
$_Write = true;
}
$userExceptions[$type][] = $message;
}
if(__item('common','DebugMode') == true)
{
$_Write = false;
$_Display = false;
}
if($_Write == true)
{
$Path = BASE_PATH.'application/storage/logs/';
$File = date('d_m_y').'_'.$type;
$Parameters = LOCK_EX | FILE_APPEND;
if(filesize($Path.$File.'.php') > __item('common','ErrorLogMaxSize'))
{
if(__item('common','ErrorExceededSize') == 'overwrite')
{
$Parameters = LOCK_EX;
}
elseif(__item('common','ErrorExceededSize') == 'write_next')
{
$File = $File.'_ex';
}
elseif(__item('common','ErrorExceededSize') == NULL)
{
$_Write = false;
}
}
if($_Write)
{
if(__item('common','ErrorExceededSize') != 'ignore')
{
if(__item('common','WriteDuplicateErrors') == false)
{
$_ErrorLog = file($Path.$File.'.php');
if($_ErrorLog != false)
{
if($key = array_search($message.PHP_EOL,$_ErrorLog) !== FALSE)
{
$_Write = false;
}
}
}
}
if($_Write)
{
__write('logs',$File,$message.PHP_EOL,'php',$Parameters);
}
}
}
if($_Display == true)
{
die("<h2><font color='maroon'>Application Error</font> :(</h2>
<p>Upps, application has experienced errors! We have notified the site owner and we should be up and running
in time!</p>");
}
}
}
/**
* [MENTION=1333357818]param[/MENTION] $errno
* [MENTION=1333357818]param[/MENTION] $errstr
* [MENTION=1333357818]param[/MENTION] $errfile
* [MENTION=1333357818]param[/MENTION] $errline
*/
function __errorHandler($errno,$errstr,$errfile,$errline)
{
$debugMode = __item('common','DebugMode') == true ? EXCEPTION_SYSTEM : EXCEPTION_C_PHP;
$userDebugString = $errstr." on line $errline, file $errfile";
switch($errno)
{
case E_ERROR: __exception($errstr,EXCEPTION_SYSTEM); break;
case E_PARSE: __exception($errstr,EXCEPTION_SYSTEM); break;
case E_CORE_ERROR: __exception($errstr,EXCEPTION_SYSTEM); break;
case E_CORE_WARNING: __exception($errstr,EXCEPTION_SYSTEM); break;
case E_COMPILE_ERROR: __exception($errstr,EXCEPTION_SYSTEM); break;
case E_COMPILE_WARNING: __exception($errstr,EXCEPTION_SYSTEM); break;
case E_USER_ERROR: __exception($errstr,EXCEPTION_SYSTEM); break;
case E_RECOVERABLE_ERROR: __exception($errstr,EXCEPTION_SYSTEM); break;
case E_WARNING: __exception($errstr,EXCEPTION_SYSTEM); break;
case E_USER_WARNING: __exception($errstr,EXCEPTION_SYSTEM); break;
case E_NOTICE: __exception($userDebugString,$debugMode); break;
case E_STRICT: __exception($userDebugString,$debugMode); break;
case E_DEPRECATED: __exception($userDebugString,$debugMode); break;
case E_USER_DEPRECATED: __exception($userDebugString,$debugMode); break;
case E_USER_NOTICE: __exception($userDebugString,$debugMode); break;
}
}
set_error_handler('__errorHandler');
http://easycaptures.com/fs/uploaded/635/3770288590.pngPHP Code:try
{
echo $FuckingArrayThatDoNotExist;
}
catch (Exception $e)
{
echo "
<h2><font color='maroon'>FATAL CORE ERROR</font> :(</h2>
<p>Upps, application core has experienced errors!</p>
<label><b>Message</b></label>
<blockquote>{$e->getMessage()}</blockquote>
<label><b>Exception</b></label>
<blockquote><pre>$e</pre></blockquote>
<label><b>Silent Errors</b></label>
<blockquote><pre>".var_export(__exception(NULL,EXCEPTION_C_SILENT),true)."</pre></blockquote>
<label><b>PHP Errors</b></label>
<blockquote><pre>".var_export(__exception(NULL,EXCEPTION_C_PHP),true)."</pre></blockquote>
<hr>
<p>Powered by X Engine v1.0</p>";
}
Anyway, not recomended to use, only for learning... yeah, i know i bit slacked of :D
EDIT:
Forgot the config file...
PHP Code:/*
* Debug & Error reporting config
*/
/**
* Enable extended error information display
*/
$config['DisplayErrors'] = true;
/**
* When debug mode is enabled write log to disk is
* disabled and all warnings and notices, etc are
* treated as system exceptions, except user and
* silent errors!
*/
$config['DebugMode'] = true;
/**
* If enabled same errors wont be written to log file!
*
* NOTE: This function will increase disk usage!
*/
$config['WriteDuplicateErrors'] = false;
/**
* Max log file size in bytes
*/
$config['ErrorLogMaxSize'] = 1048576 / 2; // 0,5mb
/**
* Action when log file has exceeded max allowed size
*
* Actions
* 'overwrite' Overwrite old log file contents with new one till it again exceed max file size
* 'write_next' Continue write log to new log file
* 'null' Disable writing log for today, log writing will be enabled at next day
* 'ignore' Continue write the same log file, duplicate checking is disabled automatically
*/
$config['ErrorExceededSize'] = 'overwrite';