1+ <?php
2+
3+ function dateFormat ($ date ){
4+ return date ("d M Y h:i A " ,strtotime ($ date ));
5+ }
6+
7+ function makePaginate (&$ query , $ config ){
8+ $ limit = $ query ->perPage ();
9+ $ total = $ query ->total ();
10+ $ page = $ query ->currentPage ();
11+ $ first = $ total > 0 ? (($ page * $ limit ) - $ limit +1 ) : 0 ;
12+ $ last = ($ total > ($ page * $ limit )) ? ($ page * $ limit ) : $ total ;
13+
14+ $ query ->paginate_text = "Showing <span> " . ($ first ) ."</span> to <span> " . $ last ."</span> of <span> " . $ total ."</span> entries " ;
15+
16+ $ config ['use_page_numbers ' ] = TRUE ;
17+ $ config ['reuse_query_string ' ] = TRUE ;
18+ $ config ['total_rows ' ] = $ total ;
19+ $ config ['per_page ' ] = $ limit ;
20+ $ config ['full_tag_open ' ] = '<ul class="pagination m-0 ml-auto"> ' ;
21+ $ config ['full_tag_close ' ] = '</ul> ' ;
22+ $ config ['num_tag_open ' ] = '<li class="page-item"> ' ;
23+ $ config ['num_tag_close ' ] = '</li> ' ;
24+ $ config ['cur_tag_open ' ] = '<li class="page-item active"><span class="page-link"> ' ;
25+ $ config ['cur_tag_close ' ] = '<span class="sr-only">(current)</span></span></li> ' ;
26+ $ config ['next_tag_open ' ] = '<li class="page-item"> ' ;
27+ $ config ['next_tagl_close ' ] = '<span aria-hidden="true">»</span></li> ' ;
28+ $ config ['prev_tag_open ' ] = '<li class="page-item"> ' ;
29+ $ config ['prev_tagl_close ' ] = '</li> ' ;
30+ $ config ['first_tag_open ' ] = '<li class="page-item"> ' ;
31+ $ config ['first_tagl_close ' ] = '</li> ' ;
32+ $ config ['last_tag_open ' ] = '<li class="page-item"> ' ;
33+ $ config ['last_tagl_close ' ] = '</li> ' ;
34+ $ config ['next_link ' ] = 'Next <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><polyline points="9 18 15 12 9 6"></polyline></svg> ' ;
35+ $ config ['prev_link ' ] = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><polyline points="15 18 9 12 15 6"></polyline></svg> Prev ' ;
36+ $ config ['attributes ' ] = array ('class ' => 'page-link ' );
37+
38+ $ ci = &get_instance ();
39+ $ ci ->pagination ->initialize ($ config );
40+ $ query ->paginate = $ ci ->pagination ->create_links ();
41+ }
42+
43+ function bcrypt_hash ($ password , $ work_factor = 8 ){
44+ if (! function_exists ('openssl_random_pseudo_bytes ' )) {
45+ throw new Exception ('Bcrypt requires openssl PHP extension ' );
46+ }
47+
48+ if ($ work_factor < 4 || $ work_factor > 31 ) $ work_factor = 8 ;
49+ $ salt =
50+ '$2a$ ' . str_pad ($ work_factor , 2 , '0 ' , STR_PAD_LEFT ) . '$ ' .
51+ substr (
52+ strtr (base64_encode (openssl_random_pseudo_bytes (16 )), '+ ' , '. ' ),
53+ 0 , 22
54+ )
55+ ;
56+
57+ return crypt ($ password , $ salt );
58+ }
59+
60+ function bcrypt_check ($ password , $ stored_hash , $ legacy_handler = NULL ){
61+ if (bcrypt_is_legacy_hash ($ stored_hash )) {
62+ if ($ legacy_handler ) return call_user_func ($ legacy_handler , $ password , $ stored_hash );
63+ else throw new Exception ('Unsupported hash format ' );
64+ }
65+
66+ return crypt ($ password , $ stored_hash ) == $ stored_hash ;
67+ }
68+
69+ function bcrypt_is_legacy_hash ($ hash ) { return substr ($ hash , 0 , 4 ) != '$2a$ ' ; }
0 commit comments