Passed
Push — master ( eff68a...1bb3d9 )
by RN
02:30
created

_getVarSource()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 13
nc 5
nop 1
dl 0
loc 18
rs 9.5222
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Basic functions for Cruzer Framework
5
 * @author RN Kushwaha <[email protected]>
6
 * @since v 1.0.0 <date: 8th Jan 2018>
7
 */
8
9
define('DATEFORMAT', 'd M, Y');
10
define('DATETIMEFORMAT', 'd M, Y h:i A');
11
12
if (!function_exists('_date')) {
13
    function _date($datetime, $time = true, $format = null)
14
    {
15
        if ($datetime == null || $datetime=='' || $datetime=='0000-00-00' || $datetime=='0000-00-00 00:00:00') {
16
            return;
17
        }
18
        if ($time === true) {
19
            if ($format == null) {
20
                return date(DATETIMEFORMAT, strtotime($datetime));
21
            } else {
22
                return date($format, strtotime($datetime));
23
            }
24
        } else {
25
            if ($format == null) {
26
                return date(DATEFORMAT, strtotime($datetime));
27
            } else {
28
                return date($format, strtotime($datetime));
29
            }
30
        }
31
    }
32
}
33
34
if (!function_exists('__date')) {
35
    function __date($datetime, $time = true, $format = null)
36
    {
37
        echo _date($datetime, $time, $format);
38
    }
39
}
40
41
if (!function_exists('_toDBDate')) {
42
    function _toDBDate($datetime, $options = array())
43
    {
44
        if ($datetime==null || $datetime=='0000-00-00' || $datetime=='0000-00-00 00:00:00') {
45
            return;
46
        }
47
48
        $dates = explode(' ', $datetime);
49
        $datePart = $dates[0];
50
        $parts = explode('/', $datePart);
51
52
        if (isset($options['format']) && $options['format']=='US') {
53
            return $parts[2].'-'.$parts[0].'-'.$parts[1];
54
        }
55
        return $parts[2].'-'.$parts[1].'-'.$parts[0];
56
    }
57
}
58
59
if (!function_exists('_config')) {
60
    function _config($key, $default = '')
61
    {
62
        global $_config;
63
        if (isset($_config) && isset($_config[$key])) {
64
            return $_config[$key];
65
        }
66
        return $default;
67
    }
68
}
69
70
if (!function_exists('humanTiming')) {
71
    function humanTiming($time, $reseverse = false)
72
    {
73
        if ($reseverse === true) {
74
            $time = strtotime($time) - time();
75
        } else {
76
            $time = time() - strtotime($time);
77
        }
78
79
        $time = ($time<1)? 1 : $time;
80
        $tokens = array (
81
          31536000 => 'year',
82
          2592000 => 'month',
83
          604800 => 'week',
84
          86400 => 'day',
85
          3600 => 'hour',
86
          60 => 'minute',
87
          1 => 'second'
88
        );
89
90
        foreach ($tokens as $unit => $text) {
91
            if ($time < $unit) {
92
                continue;
93
            }
94
            $numberOfUnits = floor($time / $unit);
95
            return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
96
        }
97
    }
98
}
99
100
if (!function_exists('_status')) {
101
    function _status($status, $formated = true, $statusFor = 'default')
102
    {
103
        if ($formated === false && $statusFor == 'default') {
104
            switch ($status) {
105
                case '1':
106
                    $statusFormated = 'Active';
107
                    break;
108
                case '0':
109
                    $statusFormated = 'Inactive';
110
                    break;
111
                case '2':
112
                    $statusFormated = 'Blocked';
113
                    break;
114
                default:
115
                    $statusFormated = 'Pending';
116
                    break;
117
            }
118
        } else {
119
            switch ($status) {
120
                case '1':
121
                    $statusFormated = '<span class="label label-success">Active</span>';
122
                    break;
123
                case '0':
124
                    $statusFormated = '<span class="label label-warning">Inactive</span>';
125
                    break;
126
                case '2':
127
                    $statusFormated = '<span class="label label-danger">Blocked</span>';
128
                    break;
129
                default:
130
                    $statusFormated = '<span class="label label-warning">Pending</span>';
131
                    break;
132
            }
133
        }
134
135
        return $statusFormated;
136
    }
137
}
138
139
if (!function_exists('__status')) {
140
    function __status($status, $formated = true, $statusFor = 'default')
141
    {
142
        echo _status($status, $formated, $statusFor);
143
    }
144
}
145
146
if (!function_exists('_matchUrl')) {
147
    function _matchUrl($urlToMatch = '', $requestUrl = '')
148
    {
149
        if (preg_match('/^'.str_replace('/', '\/', $urlToMatch).'/', $requestUrl)) {
150
            return true;
151
        }
152
153
        return false;
154
    }
155
}
156
157
if (!function_exists('_pr')) {
158
    function _pr($arr = array(), $exit = false)
159
    {
160
        echo "<pre>";
161
        print_r($arr);
162
        echo "<pre>";
163
        if ($exit) {
164
            exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
165
        }
166
    }
167
}
168
169
if (!function_exists('__br')) {
170
    function __br($repeat = 1)
171
    {
172
        if ($repeat>0) {
173
            for ($i=0; $i < $repeat; $i++) {
174
                echo "<br/>";
175
            }
176
        }
177
    }
178
}
179
180
if (!function_exists('_')) {
181
    function _($string = null, $print = false)
182
    {
183
        if (func_num_args()==2) {
184
            if ($print) {
185
                echo htmlspecialchars($string);
186
            } else {
187
                 return htmlspecialchars($string);
188
            }
189
        } else {
190
            return htmlspecialchars($string);
191
        }
192
    }
193
}
194
195
if (!function_exists('__')) {
196
    function __($string = null, $escape = true)
197
    {
198
        if ($escape === true) {
199
            echo htmlspecialchars($string);
200
        } else {
201
            echo $string;
202
        }
203
    }
204
}
205
206
if (!function_exists('_form')) {
207
    function _form($action = '', $options = array(), $csrf = true)
208
    {
209
        $form = '<form accept-charset="utf-8" action="'.$action.'"';
210
211
        if (isset($options) && isset($options['method'])) {
212
            $form.= ' method="'.$options['method'].'" ';
213
        } else {
214
            $form.= ' method="POST" ';
215
        }
216
217
        if (isset($options) && isset($options['upload'])) {
218
            $form.= ' enctype="multipart/form-data" ';
219
            unset($options['upload']);
220
        }
221
222
        if (isset($options) && count($options)) {
223
            foreach ($options as $key => $value) {
224
                $form.= $key.'="'.$value.'" ';
225
            }
226
        }
227
        $form.= '>';
228
229
        if ($csrf === true) {
230
            $form.= _CSRF(true);
231
        }
232
233
        return $form;
234
    }
235
}
236
237
if (!function_exists('__form')) {
238
    function __form($action = '', $options = array(), $csrf = true)
239
    {
240
        echo _form($action, $options, $csrf);
241
    }
242
}
243
244
if (!function_exists('_CSRF')) {
245
    function _CSRF($full_field = false)
246
    {
247
        $token = session_id();
248
        $token = sha1($token._config('SECURITY_SALT'));
249
250
        if ($full_field === true) {
251
            return '<input type="hidden" name="_csrf" id="_csrf" value="'.$token.'" style="display:none;"/>';
252
        }
253
        return $token;
254
    }
255
}
256
257
if (!function_exists('_checkCSRF')) {
258
    function _checkCSRF($csrf = '', $terminate = true, $terminate_msg = 'Invalid Token')
259
    {
260
        if ($csrf == '') {
261
            $csrf = isset($_POST['_csrf']) ? $_POST['_csrf'] : (isset($_GET['_csrf']) ? $_GET['_csrf'] : '' );
262
        }
263
264
        if ($csrf !== _CSRF() && $terminate === true) {
265
            throw new Exception($terminate_msg);
266
        }
267
268
        return $csrf === _CSRF();
269
    }
270
}
271
272
if (!function_exists('_a')) {
273
    function _a($title, $link, $options = array(), $escape = false)
274
    {
275
        if ($escape === false) {
276
            $anchor = '<a href="'.$link.'" ';
277
278
            if (isset($options) && count($options)) {
279
                foreach ($options as $key => $value) {
280
                    $anchor.= $key.'="'.$value.'" ';
281
                }
282
            }
283
            $anchor.= '>'.$title.'</a>';
284
        } else {
285
            $anchor = '<a href="'._($link).'" ';
286
287
            if (isset($options) && count($options)) {
288
                foreach ($options as $key => $value) {
289
                    $anchor.= _($key).'="'._($value).'" ';
290
                }
291
            }
292
            $anchor.= '>'._($title).'</a>';
293
        }
294
295
        return $anchor;
296
    }
297
}
298
299
if (!function_exists('__a')) {
300
    function __a($title, $link, $options = array(), $escape = false)
301
    {
302
        echo _a($title, $link, $options, $escape);
303
    }
304
}
305
306
if (!function_exists('_css')) {
307
    function _css($links, $defer = false, $version = false)
308
    {
309
        $css = '';
310
        if (is_array($links) && count($links)) {
311
            foreach ($links as $key => $value) {
312
                if ($version) {
313
                    $value = $value.'?v='.$version;
314
                }
315
                $css.= '<link rel="stylesheet" href="'.str_replace(['http://','https://'], '//', $value).'" ';
316
                if (!is_int($key)) {
317
                    $css.= 'id="'.$key.'" ';
318
                }
319
                if ($defer===true) {
320
                    $css.= ' defer ';
321
                }
322
                $css.='>'."\r\n";
323
            }
324
        } elseif ($links!='') {
325
            if ($version) {
326
                $links = $links.'?v='.$version;
327
            }
328
            $css.= '<link rel="stylesheet" href="'.str_replace(['http://','https://'], '//', $links).'" ';
329
            if ($defer===true) {
330
                $css.= ' defer ';
331
            }
332
            $css.='>'."\r\n";
333
        }
334
        return $css;
335
    }
336
}
337
338
if (!function_exists('__css')) {
339
    function __css($links, $defer = false, $version = false)
340
    {
341
        echo _css($links, $defer, $version);
342
    }
343
}
344
345
if (!function_exists('_url')) {
346
    function _url($url, $absolute = true)
347
    {
348
        if ($absolute === true) {
349
            return $url;
350
        }
351
352
        return APP_URL.$url;
353
    }
354
}
355
356
if (!function_exists('__url')) {
357
    function __url($url, $absolute = true)
358
    {
359
        echo _url($url, $absolute);
360
    }
361
}
362
363
if (!function_exists('_js')) {
364
    function _js($links, $defer = false, $version = false)
365
    {
366
        $js = '';
367
        if (is_array($links) && count($links)) {
368
            foreach ($links as $key => $value) {
369
                if ($version) {
370
                    $value = $value.'?v='.$version;
371
                }
372
                $js.= '<script src="'.str_replace(['http://','https://'], '//', $value).'" ';
373
                if (!is_int($key)) {
374
                    $js.= 'id="'.$key.'" ';
375
                }
376
                if ($defer===true) {
377
                    $js.= ' defer ';
378
                }
379
                $js.='></script>'."\r\n";
380
            }
381
        } elseif ($links!='') {
382
            if ($version) {
383
                $links = $links.'?v='.$version;
384
            }
385
            $js.= '<script src="'.str_replace(['http://','https://'], '//', $links).'" ';
386
            if ($defer===true) {
387
                $js.= ' defer ';
388
            }
389
            $js.='></script>'."\r\n";
390
        }
391
        return $js;
392
    }
393
}
394
395
if (!function_exists('__js')) {
396
    function __js($links, $defer = false, $version = false)
397
    {
398
        echo _js($links, $defer, $version);
399
    }
400
}
401
402
if (!function_exists('_auth')) {
403
    function _auth($backend = true)
404
    {
405
        $for     = ($backend === true ? 'backend' : 'frontend');
406
407
        if (isset($_SESSION[$for]) &&
408
            isset($_SESSION[$for]['auth']) &&
409
            isset($_SESSION[$for]['auth']['id']) &&
410
            $_SESSION[$for]['auth']['id']>0) {
411
            return true;
412
        }
413
414
        return false;
415
    }
416
}
417
418
if (!function_exists('_checkAuth')) {
419
    function _checkAuth($backend = true, $redirectIfLogin = false)
420
    {
421
        if (_auth($backend) === false) {
422
            if ($backend === true) {
423
                if ($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] != str_replace(
424
                    array('http://','https://'),
425
                    '',
426
                    _config('APP_URL')._config('ADMIN_LOGOUT_REDIRECT')
427
                )) {
428
                    _redirect(_config('APP_URL')._config('ADMIN_LOGOUT_REDIRECT'));
429
                }
430
            } else {
431
                _redirect(_config('APP_URL')._config('LOGOUT_REDIRECT'));
432
            }
433
        }
434
435
        if (_auth($backend) === true) {
436
            if ($redirectIfLogin === true && $backend === true) {
437
                _redirect(_config('APP_URL')._config('ADMIN_LOGIN_REDIRECT'));
438
            } elseif ($redirectIfLogin === true && $backend === false) {
439
                _redirect(_config('APP_URL')._config('LOGIN_REDIRECT'));
440
            }
441
        }
442
    }
443
}
444
445
if (!function_exists('_role')) {
446
    function _role($backend = true)
447
    {
448
        $for     = ($backend === true ? 'backend' : 'frontend');
449
450
        if (isset($_SESSION[$for]) &&
451
            isset($_SESSION[$for]['auth']) &&
452
            isset($_SESSION[$for]['auth']['groups'])) {
453
            return $_SESSION[$for]['auth']['groups'];
454
        }
455
456
        return false;
457
    }
458
}
459
460
if (!function_exists('_setAuthSession')) {
461
    function _setAuthSession($rows, $backend = true)
462
    {
463
        $for = ($backend === true ? 'backend' : 'frontend');
464
        $filtered = array_filter($rows, function ($key) {
465
            return !in_array($key, ['password']);
466
        }, ARRAY_FILTER_USE_KEY);
467
468
        $_SESSION[$for]['auth'] = $filtered;
469
    }
470
}
471
472
if (!function_exists('_destroyAuthSession')) {
473
    function _destroyAuthSession($backend = true)
474
    {
475
        $for = ($backend === true ? 'backend' : 'frontend');
476
        $_SESSION[$for]['auth'] = null;
477
    }
478
}
479
480
if (!function_exists('_getAuthSession')) {
481
    function _getAuthSession($key = 'id', $backend = true)
482
    {
483
        $for = ($backend === true ? 'backend' : 'frontend');
484
        if (isset($_SESSION[$for]) &&
485
            isset($_SESSION[$for]['auth']) &&
486
            isset($_SESSION[$for]['auth']['id']) &&
487
            $_SESSION[$for]['auth']['id']>0) {
488
            if ($key == 'role') {
489
                return $_SESSION[$for]['auth']['groups'] == 1 ? 'Administrator' : 'Operator';
490
            }
491
492
            if (isset($_SESSION[$for]['auth'][$key])) {
493
                return $_SESSION[$for]['auth'][$key];
494
            }
495
        }
496
    }
497
}
498
499
if (!function_exists('__getAuthSession')) {
500
    function __getAuthSession($key = 'id', $backend = true)
501
    {
502
        __(_getAuthSession($key, $backend));
503
    }
504
}
505
506
if (!function_exists('_flashSession')) {
507
    function _flashSession($backend = true)
508
    {
509
        $for     = ($backend === true ? 'backend' : 'frontend');
510
        $session = array();
511
        $str     = '';
512
        
513
        if (isset($_SESSION[$for]) &&  isset($_SESSION[$for]['flash'])) {
514
            $session = $_SESSION[$for]['flash'];
515
        }
516
517
        if (count($session)) {
518
            $str     = '<br/><br/>';
519
            foreach ($session as $key => $value) {
520
                if ($backend===true) {
521
                    $key2 = 'warning';
522
                    if ($key=='danger' || $key=='error') {
523
                        $key2 = 'error';
524
                    } elseif ($key=='success') {
525
                        $key2 = 'check_circle';
526
                    } elseif ($key=='info') {
527
                        $key2 = 'priority_high';
528
                    }
529
530
                    $str.= '<div class="card green lighten-1 flashContainer">
531
                            <div class="row">
532
                              <div class="col m10">
533
                                <div class="card-content white-text">
534
                                  <h5><i class="material-icons small-icons">'.$key2.'</i> '.ucfirst($key).'</h5>
535
                                  <p>'.$value.'</p> </div> </div>
536
                            <div class="col m2">
537
                              <a href="javascript:;" class="right white-text" target="_self">
538
                                <i class="material-icons small-icons flashClose">close</i>
539
                              </a> </div> </div> </div>';
540
                } else {
541
                    $str.= '<div class="alert alert-'.$key.' alert-dismissible" role="alert">
542
                            <button type="button" class="close" data-dismiss="alert">
543
                                <span aria-hidden="true">×</span><span class="sr-only">Close</span>
544
                            </button> <strong>'.ucfirst($key).'</strong> '.$value.' </div>';
545
                }
546
            }
547
        }
548
549
        $_SESSION[$for]['flash'] = null;
550
        return $str;
551
    }
552
}
553
554
if (!function_exists('__flashSession')) {
555
    function __flashSession($backend = true)
556
    {
557
        echo _flashSession($backend);
558
    }
559
}
560
561
if (!function_exists('_setFlash')) {
562
    function _setFlash($msg_type, $msg, $backend = true)
563
    {
564
        $for = ($backend === true ? 'backend' : 'frontend');
565
        $_SESSION[$for]['flash'][$msg_type] = $msg;
566
    }
567
}
568
569
if (!function_exists('_redirect')) {
570
    function _redirect($url, $code = 200)
571
    {
572
        if ($url=='back') {
573
            $url = $_SERVER['HTTP_REFERER'];
574
        }
575
        header($_SERVER["SERVER_PROTOCOL"]." $code"); 
576
        header("Location: ".$url);
577
        exit();
578
    }
579
}
580
581
if (!function_exists('_upload')) {
582
    function _upload($tmp_name, $attachment)
583
    {
584
        move_uploaded_file($tmp_name, UPLOAD_DIR."$attachment");
585
    }
586
}
587
588
if (!function_exists('_slug')) {
589
    function _slug($string)
590
    {
591
        return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string)));
592
    }
593
}
594
595
if (!function_exists('_numberToCurrency')) {
596
    function _numberToCurrency($num)
597
    {
598
        if (setlocale(LC_MONETARY, 'en_IN')) {
599
            return money_format('%.0n', $num);
600
        }
601
        
602
        $explrestunits = "" ;
603
        if (strlen($num)>3) {
604
            $lastthree = substr($num, strlen($num)-3, strlen($num));
605
             // extracts the last three digits
606
            $restunits = substr($num, 0, strlen($num)-3);
607
            // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
608
            $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits;
609
610
            $expunit = str_split($restunits, 2);
611
            $sizeof  = sizeof($expunit);
612
            for ($i=0; $i<$sizeof; $i++) {
613
                // creates each of the 2's group and adds a comma to the end
614
                if ($i==0) {
615
                    // if is first value , convert into integer
616
                    $explrestunits .= (int)$expunit[$i].",";
617
                } else {
618
                    $explrestunits .= $expunit[$i].",";
619
                }
620
            }
621
            $thecash = $explrestunits.$lastthree;
622
        } else {
623
            $thecash = $num;
624
        }
625
        return '₹ ' . $thecash;
626
    }
627
}
628
629
if (!function_exists('getQueryStrings')) {
630
    function getQueryStrings($url = '')
631
    {
632
        $data = array();
633
        $query = ltrim(strstr($url, '?'), '?');
634
        $arr = explode('&', $query);
635
        if (is_array($arr) && count($arr)) {
636
            foreach ($arr as $value) {
637
                $split = explode('=', $value);
638
                if (isset($split[0])) {
639
                    $data[$split[0]] = isset($split[1]) ? $split[1] : null;
640
                }
641
            }
642
        }
643
        return $data;
644
    }
645
}
646
647
if (!function_exists('_getVarSource')) {
648
    function _getVarSource($method)
649
    {
650
        switch (strtolower($method)) {
651
            case 'get': //$from = $_GET;
652
            //for godaddy which creates problem in $_GET
653
                $from = getQueryStrings($_SERVER['REQUEST_URI']);
654
                break;
655
            case 'post':
656
                $from = $_POST;
657
                break;
658
            case 'request':
659
            case 'any':
660
                $from = $_REQUEST;
661
                break;
662
            default: $from = $_REQUEST;
663
        }
664
665
        return $from;
666
    }
667
}
668
669
if (!function_exists('_formatVarFromSource')) {
670
    function _formatVarFromSource($var, $default = null, $format = null)
671
    {
672
        if($format === null )  return;
673
674
        switch (strtolower($format)) {
675
            case 'upper':
676
                $retVal = isset($from[$var]) ? strtoupper($from[$var]) : $default;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $from seems to never exist and therefore isset should always be false.
Loading history...
677
            break;
678
            case 'lower':
679
                $retVal = isset($from[$var]) ? strtolower($from[$var]) : $default;
680
            break;
681
            case 'int':
682
                $retVal = isset($from[$var]) ? (int)$from[$var] : $default;
683
            break;
684
            case 'float':
685
                $retVal = isset($from[$var]) ? (float)$from[$var] : $default;
686
            break;
687
        }
688
689
        return $retVal;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $retVal does not seem to be defined for all execution paths leading up to this point.
Loading history...
690
    }
691
}
692
693
if (!function_exists('_requestData')) {
694
    function _requestData($var, $default = null, $method = 'post', $format = null)
695
    {
696
        $from = _getVarSource($method);
697
698
        if ($format == null) {
699
            if (!isset($from[$var])) {
700
                return $default;
701
            }
702
703
            if ($default == null) {
704
                if ($from[$var]== '') {
705
                    return $default;
706
                }
707
                
708
                return $from[$var];
709
            } else {
710
                if ($from[$var]== '') {
711
                    return $default;
712
                }
713
714
                return $from[$var];
715
            }
716
        }
717
        
718
        $retVal = _formatVarFromSource($var, $default = null, $format = null);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $retVal is correct as _formatVarFromSource($va...= null, $format = null) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
719
        return $retVal;
720
    }
721
}
722
723
if (!function_exists('_getData')) {
724
    function _getData($var, $default = null, $format = null)
725
    {
726
        return _requestData($var, $default, 'get', $format);
727
    }
728
}
729
730
if (!function_exists('_postData')) {
731
    function _postData($var, $default = null, $format = null)
732
    {
733
        return _requestData($var, $default, 'post', $format);
734
    }
735
}
736
737
function _encodeString($string)
738
{
739
    $result       = $string;
740
    $arrayLetters = array('C', 'R', 'U', 'Z', 'M', 'I', 'N', 'I');
741
    $limit        = count($arrayLetters) - 1;
742
    $num          = mt_rand(0, $limit);
743
744
    for ($i = 1; $i <= $num; $i++) {
745
        $result = base64_encode($result);
746
    }
747
    $result = $result . '::' . $arrayLetters[$num];
748
    $result = base64_encode($result);
749
    return str_replace('=', '~~', $result);
750
}
751
752
function _decodeString($string)
753
{
754
    $string = str_replace('~~', '=', $string);
755
    $result = base64_decode($string);
756
    list($result, $letra) = explode('::', $result);
757
    $arrayLetters = array('C', 'R', 'U', 'Z', 'M', 'I', 'N', 'I');
758
    $totalCount = count($arrayLetters);
759
760
    for ($i = 0; $i <$totalCount; $i++) {
761
        if ($arrayLetters[$i] == $letra) {
762
            for ($j = 1; $j <= $i; $j++) {
763
                $result = base64_decode($result);
764
            }
765
            break;
766
        }
767
    }
768
    return $result;
769
}
770