Skip to content

Commit 473799e

Browse files
author
ifsale
committed
new release
1 parent ed3fefd commit 473799e

16 files changed

+778
-121
lines changed

PtcAuth.php

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
1010
* @link http://phptoolcase.com
1111
*/
12-
12+
1313
class PtcAuth
1414
{
1515
/**
@@ -33,7 +33,7 @@ public static function once( $userID , $expires = false )
3333
return static::_processLogin( $rand , 'none' , $expires );
3434
}
3535
if ( !$user = static::user( $userID ) ){ return false; }
36-
return static::_processLogin( $user->{ $columns[ 'unique_key' ] } , 'none' , $expires );
36+
return static::_processLogin( $user->{$columns[ 'unique_key' ] } , 'none' , $expires );
3737
}
3838
/**
3939
*
@@ -128,8 +128,8 @@ public static function verify( $code , $newCode = false )
128128
{
129129
$result = 3;
130130
static::_fireEvent( 'verifying' , array( &$code ) );
131-
static::_connection( )->setFetchMode( PDO::FETCH_OBJ );
132-
$user = static::_connection( static::$_options[ 'users_table' ] )
131+
static::_connection( )->setFetchMode( \PDO::FETCH_OBJ );
132+
$user = static::_connection( static::$_options[ 'users_table' ])
133133
->where( static::$_tableColumns[ 'verification' ] , '=' , $code )
134134
->row( );
135135
if ( !$user ){ $result = 2; } // code not found
@@ -156,9 +156,9 @@ public static function verify( $code , $newCode = false )
156156
*/
157157
public static function user( $value = null )
158158
{
159-
$connection = ( static::$_options[ 'model' ] ) ?
160-
static::$_options[ 'model' ] : static::_connection( static::$_options[ 'users_table' ] );
161-
static::_connection( )->setFetchMode( PDO::FETCH_OBJ );
159+
$connection = ( static::$_options[ 'model' ] ) ? static::$_options[ 'model' ] :
160+
static::_connection( static::$_options[ 'users_table' ] );
161+
static::_connection( )->setFetchMode( \PDO::FETCH_OBJ );
162162
if ( is_array( $value ) )
163163
{
164164
foreach( $value as $k => $v )
@@ -238,13 +238,14 @@ public static function configure( $options = array( ) , $columns = array( ) )
238238
static::$_tableColumns = ( empty( $columns ) ) ? static::$_tableColumns : $columns;
239239
if ( !static::_checkConfig( static::$_tableColumns ) ){ return false; }
240240
static::_debug( array( static::$_options , static::$_tableColumns ) ,
241-
'User options set for authentication component!', static::$_options[ 'debug_category' ] );
241+
'User options set for authentication component!',
242+
static::$_options[ 'debug_category' ] );
242243
return static::$_configured = true;
243244
}
244245
/**
245246
*
246247
*/
247-
public static function setup( )
248+
public static function setUp( )
248249
{
249250
if ( !static::_isConfigured( ) ){ return false; };
250251
$qb = static::_connection( );
@@ -272,9 +273,8 @@ public static function setup( )
272273
*/
273274
public static function random( $length = 50 , $characters = null )
274275
{
275-
276276
$characters = ( $characters ) ? $characters :
277-
'0123456789abcdefghijklmnopqrstuvwxyz';
277+
'0123456789abcdefghijklmnopqrstuvwxyz';
278278
$string = '';
279279
for ( $p = 0; $p < $length; $p++ )
280280
{
@@ -300,7 +300,7 @@ public static function makeTime( $value = '7' )
300300
return ( time( ) + 60 * intval( $value ) ); // *minutes
301301
case false !== stripos( $value , 's' ) :
302302
return ( time( ) + 1 * intval( $value ) ); // *seconds
303-
default: return ( time( ) + 60 * 60 * 24 * intval( $value ) ); // *days
303+
default: return ( time( ) + 60 * 60 * 24 * intval( $value ) ); // days
304304
}
305305
}
306306
/**
@@ -434,7 +434,7 @@ public static function sendMail( $param , $emailTpl = array( ) , $extraData = ar
434434
}
435435
foreach ( $columns as $k => $v )
436436
{
437-
if ( null === $v ){ continue; }
437+
if ( !$v ){ continue; }
438438
$header = str_replace( '{' . $k . '}' , @$user->{ $v } , $header );
439439
$subject = str_replace( '{' . $k . '}' , @$user->{ $v } , $subject );
440440
$message = str_replace( '{' . $k . '}' , @$user->{ $v } , $message );
@@ -504,15 +504,16 @@ public static function login( $email , $password )
504504
/**
505505
*
506506
*/
507-
public static function setExpired( $recordID = null )
507+
public static function setExpired( $record = null )
508508
{
509509
if ( !static::_isConfigured( ) ){ return false; }
510510
$qb = static::_connection( static::$_options[ 'login_table' ] );
511-
if ( $recordID )
511+
if ( $record )
512512
{
513-
return $qb->where( 'id' , '=' , $recordID )
513+
$result = $qb->where( 'id' , '=' , $record )
514514
->update( array( 'expired' => 1) )
515515
->run( );
516+
return $result;
516517
}
517518
$qb->where( 'expires' , '<' , $qb->raw( 'NOW()' ) )
518519
->update( array( 'expired' => 1) )
@@ -535,7 +536,7 @@ public static function check( )
535536
}
536537
}
537538
if ( !isset( $_SESSION[ 'user_id' ] ) ){ return false; }
538-
static::_connection( )->setFetchMode( PDO::FETCH_OBJ );
539+
static::_connection( )->setFetchMode( \PDO::FETCH_OBJ );
539540
$login_data = static::_connection( static::$_options[ 'login_table' ] )
540541
->where( 'user_id' , '=' , $_SESSION[ 'user_id' ] )
541542
->where( 'expired' , '!=' , 1 )
@@ -600,7 +601,7 @@ public static function observe( $class = null )
600601
'path' => '/' ,
601602
'domain' => null ,
602603
'secure' => null ,
603-
'http_only' => null
604+
'http_only' => null
604605
) ,
605606
'guard' => array
606607
(
@@ -719,7 +720,7 @@ protected static function _checkCookie( )
719720
if ( !$data ){ return false; }
720721
$cookie = json_decode( $data );
721722
if ( !@$cookie[ 0 ] || !$cookie[ 1 ] || !$cookie[ 2 ] ){ return false; }
722-
static::_connection( )->setFetchMode( PDO::FETCH_OBJ );
723+
static::_connection( )->setFetchMode( \PDO::FETCH_OBJ );
723724
$user = static::_connection( static::$_options[ 'users_table' ] )
724725
->where( static::$_tableColumns[ 'unique_key' ] , '=' , $cookie[ 0 ] )
725726
->row( );

PtcDb.php

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
1010
* @link http://phptoolcase.com
1111
*/
12-
12+
1313
class PtcDb
1414
{
1515
/**

PtcDebug.php

100755100644
Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static function setErrorHandler( $dieOnFatal = true )
6666
{
6767
ini_set( 'display_errors' , false );
6868
ini_set( 'html_errors' , false );
69-
if ( !@static::$_options[ 'error_reporting' ] )
69+
if ( !isset( static::$_options[ 'error_reporting' ] ) )
7070
{
7171
@static::$_options[ 'error_reporting' ] = static::$_defaultOptions[ 'error_reporting' ];
7272
}
@@ -152,15 +152,19 @@ public static function load( $options = null )
152152
set_exception_handler( array( $called_class , 'exceptionHandler' ) );
153153
$buffer .= "<br>Exception Handler turned on!";
154154
}
155-
if ( static::$_options[ 'debug_console' ] ) // try to laod the console class
155+
if ( static::$_options[ 'debug_console' ] ) // try to load the console class
156156
{
157157
static::$_consoleStarted = false;
158158
$buffer.='<br>Console debug turned on';
159159
if ( file_exists( dirname( __FILE__ ) . '/PhpConsole/__autoload.php' ) )
160160
{
161161
require_once( dirname(__FILE__).'/PhpConsole/__autoload.php' );
162162
static::$_consoleStarted = true;
163-
\PhpConsole\Helper::register( );
163+
$instance = \PhpConsole\Connector::getInstance( );
164+
$instance->setHeadersLimit( static::$_options[ 'max_header_size' ] );
165+
$instance->getDebugDispatcher( )->setDumper(
166+
new \PhpConsole\Dumper( static::$_options[ 'max_dump_depth' ] ) );
167+
//$instance->getDebugDispatcher( )->detectTraceAndSource = true;
164168
$buffer .= ", phpConsole class started!";
165169
}
166170
else{ $buffer .= ', but could not find phpConsole class!'; }
@@ -636,7 +640,8 @@ public static function msgType( $msg = NULL )
636640
'enable_inspector' => true , // enable variables inspector, use declare(ticks=n); in code block
637641
'code_coverage' => true, // enable code coverage analysis, use "full" to start globally
638642
'trace_functions' => true, // enable function calls tracing, use "full" to start globally
639-
'exclude_categories' => array( 'Event Manager' , 'Autoloader' , 'Router Config' , 'View Config' ) // exclude categories from the output
643+
'exclude_categories' => array( ) , // exclude categories from the output
644+
'max_header_size' => 4096 // maximum header size for phpconsole
640645
);
641646
/**
642647
* Array of methods excluded from the backtrace
@@ -736,10 +741,13 @@ public static function msgType( $msg = NULL )
736741
.msgTable tr.php-warning td{background-color:yellow;}
737742
.msgTable tr.php-error td{background-color:orange;}
738743
.msgTable tr.inspector td{background-color:lightgreen;}
739-
.innerTable a.php-notice{color:lightblue;}
740-
.innerTable a.exception{color:greenyellow;}.innerTable a.php-warning{color:yellow;}
741-
.innerTable a.php-error{color:orange;}.innerTable a.inspector{color:lightgreen;}
742-
.innerTable a.general{color:darkgrey;}.innerTable a.show-all{color:red;}
744+
.innerTable a.php-notice{color:lightblue;!important;}
745+
.innerTable a.exception{color:greenyellow !important;}
746+
.innerTable a.php-warning{color:yellow !important;}
747+
.innerTable a.php-error{color:orange !important;}
748+
.innerTable a.inspector{color:lightgreen !important;}
749+
.innerTable a.general{color:darkgrey !important;}
750+
.innerTable a.show-all{color:red !important;}.innerTable a.top-links{color:white;}
743751
#ptcDebugFilterBar{background-color:black;margin-bottom:8px;padding:4px;
744752
font-size:13px;}.innerTable{z-index:10000;position:relative;background:#eee;
745753
height:300px;padding:30px 10px 0 10px;overflow:auto;clear:both;}
@@ -782,8 +790,8 @@ protected static function _debugConsole()
782790
$arr=array( 'errline' => $php_trace[ 'line' ] , 'errfile' => $php_trace[ 'file' ] );
783791
}
784792
$statement = ( @$arr[ 'console_statement' ] ) ?
785-
strip_tags( preg_replace( "=<br */?>=i" , "\n" ,
786-
@$arr[ 'console_statement' ] ) ) : null;
793+
strip_tags( preg_replace( "=<br */?>=i" , "\n" ,
794+
@$arr[ 'console_statement' ] ) ) : null;
787795
$statement .= ( @$arr[ 'console_time' ] ) ? ' [time: ' . $arr[ 'console_time' ] . ']' : '';
788796
$console_type = '[' . @end( @explode( '/' , $arr[ 'errfile' ][ 0 ] ) ) . ':';
789797
$console_type .= $arr[ 'errline' ][ 0 ] . ']';
@@ -797,24 +805,24 @@ protected static function _debugConsole()
797805
}
798806
else
799807
{
800-
\PC::debug( $console_type , $arr[ 'console_category' ] . '.file' );
808+
$handler->debug( $console_type , strtolower( $arr[ 'console_category' ] ) . '.file' );
801809
if ( $statement )
802-
{
803-
\PC::debug( $statement , $arr[ 'console_category' ] . '.message' );
810+
{
811+
$handler->debug( $statement , strtolower( $arr[ 'console_category' ] ) . '.message' );
804812
}
805813
if ( @$arr[ 'console_string' ] )
806814
{
807-
\PC::debug( $arr[ 'console_string' ] , $arr[ 'console_category' ] . '.result' );
815+
$handler->debug( $arr[ 'console_string' ] , strtolower( $arr[ 'console_category' ] . '.data' ) );
808816
}
809817
if ( @$arr[ 'errfile' ] )
810818
{
811819
unset( $arr[ 'errfile' ][ 0 ] );
812820
if ( !empty( $arr[ 'errfile' ] ) )
813821
{
814-
\PC::debug( $arr[ 'errfile' ] , $arr[ 'console_category' ] . '.trace' );
822+
$handler->debug( $arr[ 'errfile' ] , strtolower( $arr[ 'console_category' ] . '.trace' ) );
815823
}
816824
}
817-
//\PC::debug( $arr , $arr[ 'console_category' ] . '[full]' );
825+
//$handler->debug( $arr , strtolower( $arr[ 'console_category' ] . '[full]' ) );
818826
}
819827
}
820828
}
@@ -826,8 +834,8 @@ protected static function _debugConsole()
826834
}
827835
$time = ( ( static::$_endTime - static::$_startTime ) - static::$_tickTime );
828836
$console_final = 'Seconds: ' . round( $time , 3 ) . ' | Milliseconds: ' . round( $time * 1000 , 3 );
829-
\PC::debug( array( @get_included_files( ) ) , static::$_options[ 'default_category' ] . '.includedFiles' );
830-
\PC::debug( 'Global Execution Time ' . $console_final , static::$_options[ 'default_category' ] );
837+
$handler->debug( array( @get_included_files( ) ) , strtolower( static::$_options[ 'default_category' ] . '.includes' ) );
838+
$handler->debug( 'Global Execution Time ' . $console_final , strtolower( static::$_options[ 'default_category' ] ) );
831839
}
832840
/**
833841
* Checks if a given ip has access
@@ -1399,6 +1407,7 @@ protected static function _lastError()
13991407
$err_type=static::msgType( $error['type'] );
14001408
if($err_type=='Php Error')
14011409
{
1410+
ini_set( 'memory_limit' , memory_get_usage( true ) + 1000000 );
14021411
$err=array('errno'=>$err_type,'errstr'=>$error['message'],
14031412
'errfile'=>$error['file'],'errline'=>$error['line']);
14041413
static::_buildBuffer('log','{errorHandler}',$err);
@@ -1502,7 +1511,7 @@ protected static function _buildHtmlTable( $type )
15021511
{
15031512
$cat_id = str_replace( ' ' , '-' , strtolower( $k ) );
15041513
$div .= '<a href="#" onClick="ptc_filter_categories(\'' . $type .
1505-
'Table\',\'' . $cat_id . '\')" class="' . $cat_id . '">' . $k . "(" . $v . ")</a> | ";
1514+
'Table\',\'' . $cat_id . '\')" class="top-links ' . $cat_id . '">' . $k . "(" . $v . ")</a> | ";
15061515
}
15071516
$div = substr( $div , 0 , -3 );
15081517
$div .= '</div>';
@@ -1976,29 +1985,27 @@ function ptc_show_string(elId,link)
19761985
};
19771986
function ptc_show_trace(className,link)
19781987
{
1979-
var elements=document.getElementsByClassName(\'\'+className+\'\');
1980-
for(i in elements)
1988+
var elements = document.getElementsByClassName(\'\'+className+\'\');
1989+
for ( var i = 0; i < elements.length; i++ )
19811990
{
1982-
if(elements[i].hasOwnProperty(\'style\'))
1991+
if(elements[i].style.display=="none")
19831992
{
1984-
if(elements[i].style.display=="none")
1985-
{
1986-
link.innerHTML=link.innerHTML.replace("\u21d3","\u21d1");
1987-
elements[i].style.display=\'\';
1988-
}
1989-
else
1990-
{
1991-
link.innerHTML=link.innerHTML.replace("\u21d1","\u21d3");
1992-
elements[i].style.display=\'none\';
1993-
}
1993+
link.innerHTML=link.innerHTML.replace("\u21d3","\u21d1");
1994+
elements[i].style.display=\'\';
1995+
}
1996+
else
1997+
{
1998+
link.innerHTML=link.innerHTML.replace("\u21d1","\u21d3");
1999+
elements[i].style.display=\'none\';
19942000
}
19952001
}
19962002
};
19972003
function ptc_read_code(filename,line)
19982004
{
19992005
var query="http://' . addslashes( $_SERVER[ 'HTTP_HOST' ] ) .
20002006
$path = addslashes( str_replace( realpath( $_SERVER[ 'DOCUMENT_ROOT' ] ) ,
2001-
'' , realpath( dirname( __FILE__ ) ) ) ) . '/PtcDebug.php?ptc_read_file="+filename;
2007+
'' , realpath( dirname( __FILE__ ) ) ) ) . '/PtcDebug.php?session_name=' .
2008+
session_name( ) . '&ptc_read_file="+filename;
20022009
if(line){query+="&ptc_read_line="+line;}
20032010
newwindow=window.open(query,"name","height=350,width=820");
20042011
if(window.focus){newwindow.focus()};
@@ -2019,7 +2026,8 @@ function ptc_search_string( )
20192026
var query="http://' . addslashes( $_SERVER[ 'HTTP_HOST' ] ) .
20202027
$path = addslashes( str_replace( realpath( $_SERVER[ 'DOCUMENT_ROOT' ] ) ,
20212028
'' , realpath( dirname( __FILE__ ) ) ) ) .
2022-
'/PtcDebug.php?ptc_search_files="+document.getElementsByName("ptc_search_files")[0].value;
2029+
'/PtcDebug.php?session_name=' . session_name( ) .
2030+
'&ptc_search_files="+document.getElementsByName("ptc_search_files")[0].value;
20232031
query+="&ptc_search_path="+document.getElementsByName("ptc_search_path")[0].value;
20242032
newwindow=window.open(query,"name","height=350,width=1220");
20252033
if(window.focus){newwindow.focus()};
@@ -2225,8 +2233,9 @@ public static function showSearchPopup( $string , $path = null )
22252233
/**
22262234
* Calls highlight file method to show source code, session_start() must be active for security reasons
22272235
*/
2228-
if ( @$_GET[ 'ptc_read_file' ] )
2236+
if ( isset( $_GET[ 'ptc_read_file' ] ) )
22292237
{
2238+
session_name( $_GET[ 'session_name' ] );
22302239
@session_start( );
22312240
if ( !@$_SESSION[ 'ptcdebug' ][ 'code_highlighter' ] ) { exit( ); }
22322241
echo PtcDebug::highlightFile( $_GET[ 'ptc_read_file' ] , @$_GET[ 'ptc_read_line' ] );
@@ -2235,8 +2244,9 @@ public static function showSearchPopup( $string , $path = null )
22352244
/**
22362245
* Shows a popup with string search results, session_start() must be active for security reasons
22372246
*/
2238-
if ( @$_GET[ 'ptc_search_files' ] )
2247+
if ( isset( $_GET[ 'ptc_search_files' ] ) )
22392248
{
2249+
session_name( $_GET[ 'session_name' ] );
22402250
@session_start( );
22412251
if ( !@$_SESSION[ 'ptcdebug' ][ 'search_files' ] ) { exit( ); }
22422252
echo PtcDebug::showSearchPopup( $_GET[ 'ptc_search_files' ] , @$_GET[ 'ptc_search_path' ] );

0 commit comments

Comments
 (0)