Passed
Push — master ( 198af9...25de8d )
by RN
02:50
created

_requestData()   D

Complexity

Conditions 18
Paths 70

Size

Total Lines 52
Code Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 18
eloc 36
c 1
b 0
f 0
nc 70
nop 4
dl 0
loc 52
rs 4.8666

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
            __($terminate_msg);
266
            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...
267
        }
268
269
        return $csrf === _CSRF();
270
    }
271
}
272
273
if (!function_exists('_a')) {
274
    function _a($title, $link, $options = array(), $escape = false)
275
    {
276
        if ($escape === false) {
277
            $anchor = '<a href="'.$link.'" ';
278
279
            if (isset($options) && count($options)) {
280
                foreach ($options as $key => $value) {
281
                    $anchor.= $key.'="'.$value.'" ';
282
                }
283
            }
284
            $anchor.= '>'.$title.'</a>';
285
        } else {
286
            $anchor = '<a href="'._($link).'" ';
287
288
            if (isset($options) && count($options)) {
289
                foreach ($options as $key => $value) {
290
                    $anchor.= _($key).'="'._($value).'" ';
291
                }
292
            }
293
            $anchor.= '>'._($title).'</a>';
294
        }
295
296
        return $anchor;
297
    }
298
}
299
300
if (!function_exists('__a')) {
301
    function __a($title, $link, $options = array(), $escape = false)
302
    {
303
        echo _a($title, $link, $options, $escape);
304
    }
305
}
306
307
if (!function_exists('_css')) {
308
    function _css($links, $defer = false, $version = false)
309
    {
310
        $css = '';
311
        if (is_array($links) && count($links)) {
312
            foreach ($links as $key => $value) {
313
                if ($version) {
314
                    $value = $value.'?v='.$version;
315
                }
316
                $css.= '<link rel="stylesheet" href="'.str_replace(['http://','https://'], '//', $value).'" ';
317
                if (!is_int($key)) {
318
                    $css.= 'id="'.$key.'" ';
319
                }
320
                if ($defer===true) {
321
                    $css.= ' defer ';
322
                }
323
                $css.='>'."\r\n";
324
            }
325
        } elseif ($links!='') {
326
            if ($version) {
327
                $links = $links.'?v='.$version;
328
            }
329
            $css.= '<link rel="stylesheet" href="'.str_replace(['http://','https://'], '//', $links).'" ';
330
            if ($defer===true) {
331
                $css.= ' defer ';
332
            }
333
            $css.='>'."\r\n";
334
        }
335
        return $css;
336
    }
337
}
338
339
if (!function_exists('__css')) {
340
    function __css($links, $defer = false, $version = false)
341
    {
342
        echo _css($links, $defer, $version);
343
    }
344
}
345
346
if (!function_exists('_url')) {
347
    function _url($url, $absolute = true)
348
    {
349
        if ($absolute === true) {
350
            return $url;
351
        }
352
353
        return APP_URL.$url;
354
    }
355
}
356
357
if (!function_exists('__url')) {
358
    function __url($url, $absolute = true)
359
    {
360
        echo _url($url, $absolute);
361
    }
362
}
363
364
if (!function_exists('_js')) {
365
    function _js($links, $defer = false, $version = false)
366
    {
367
        $js = '';
368
        if (is_array($links) && count($links)) {
369
            foreach ($links as $key => $value) {
370
                if ($version) {
371
                    $value = $value.'?v='.$version;
372
                }
373
                $js.= '<script src="'.str_replace(['http://','https://'], '//', $value).'" ';
374
                if (!is_int($key)) {
375
                    $js.= 'id="'.$key.'" ';
376
                }
377
                if ($defer===true) {
378
                    $js.= ' defer ';
379
                }
380
                $js.='></script>'."\r\n";
381
            }
382
        } elseif ($links!='') {
383
            if ($version) {
384
                $links = $links.'?v='.$version;
385
            }
386
            $js.= '<script src="'.str_replace(['http://','https://'], '//', $links).'" ';
387
            if ($defer===true) {
388
                $js.= ' defer ';
389
            }
390
            $js.='></script>'."\r\n";
391
        }
392
        return $js;
393
    }
394
}
395
396
if (!function_exists('__js')) {
397
    function __js($links, $defer = false, $version = false)
398
    {
399
        echo _js($links, $defer, $version);
400
    }
401
}
402
403
if (!function_exists('_auth')) {
404
    function _auth($backend = true)
405
    {
406
        $for     = ($backend === true ? 'backend' : 'frontend');
407
408
        if (isset($_SESSION[$for]) &&
409
            isset($_SESSION[$for]['auth']) &&
410
            isset($_SESSION[$for]['auth']['id']) &&
411
            $_SESSION[$for]['auth']['id']>0) {
412
            return true;
413
        }
414
415
        return false;
416
    }
417
}
418
419
if (!function_exists('_checkAuth')) {
420
    function _checkAuth($backend = true, $redirectIfLogin = false)
421
    {
422
        if (_auth($backend) === false) {
423
            if ($backend === true) {
424
                if ($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] != str_replace(
425
                    array('http://','https://'),
426
                    '',
427
                    _config('APP_URL')._config('ADMIN_LOGOUT_REDIRECT')
428
                )) {
429
                    _redirect(_config('APP_URL')._config('ADMIN_LOGOUT_REDIRECT'));
430
                }
431
            } else {
432
                _redirect(_config('APP_URL')._config('LOGOUT_REDIRECT'));
433
            }
434
        }
435
436
        if (_auth($backend) === true) {
437
            if ($redirectIfLogin === true && $backend === true) {
438
                _redirect(_config('APP_URL')._config('ADMIN_LOGIN_REDIRECT'));
439
            } elseif ($redirectIfLogin === true && $backend === false) {
440
                _redirect(_config('APP_URL')._config('LOGIN_REDIRECT'));
441
            }
442
        }
443
    }
444
}
445
446
if (!function_exists('_role')) {
447
    function _role($backend = true)
448
    {
449
        $for     = ($backend === true ? 'backend' : 'frontend');
450
451
        if (isset($_SESSION[$for]) &&
452
            isset($_SESSION[$for]['auth']) &&
453
            isset($_SESSION[$for]['auth']['groups'])) {
454
            return $_SESSION[$for]['auth']['groups'];
455
        }
456
457
        return false;
458
    }
459
}
460
461
if (!function_exists('_setAuthSession')) {
462
    function _setAuthSession($rows, $backend = true)
463
    {
464
        $for = ($backend === true ? 'backend' : 'frontend');
465
        $filtered = array_filter($rows, function ($key) {
466
            return !in_array($key, ['password']);
467
        }, ARRAY_FILTER_USE_KEY);
468
469
        $_SESSION[$for]['auth'] = $filtered;
470
    }
471
}
472
473
if (!function_exists('_destroyAuthSession')) {
474
    function _destroyAuthSession($backend = true)
475
    {
476
        $for = ($backend === true ? 'backend' : 'frontend');
477
        $_SESSION[$for]['auth'] = null;
478
    }
479
}
480
481
if (!function_exists('_getAuthSession')) {
482
    function _getAuthSession($key = 'id', $backend = true)
483
    {
484
        $for = ($backend === true ? 'backend' : 'frontend');
485
        if (isset($_SESSION[$for]) &&
486
            isset($_SESSION[$for]['auth']) &&
487
            isset($_SESSION[$for]['auth']['id']) &&
488
            $_SESSION[$for]['auth']['id']>0) {
489
            if ($key == 'role') {
490
                return $_SESSION[$for]['auth']['groups'] == 1 ? 'Administrator' : 'Operator';
491
            }
492
493
            if (isset($_SESSION[$for]['auth'][$key])) {
494
                return $_SESSION[$for]['auth'][$key];
495
            }
496
        }
497
    }
498
}
499
500
if (!function_exists('__getAuthSession')) {
501
    function __getAuthSession($key = 'id', $backend = true)
502
    {
503
        __(_getAuthSession($key, $backend));
504
    }
505
}
506
507
if (!function_exists('_flashSession')) {
508
    function _flashSession($backend = true)
509
    {
510
        $for     = ($backend === true ? 'backend' : 'frontend');
511
        $session = array();
512
        $str     = '';
513
        
514
        if (isset($_SESSION[$for]) &&  isset($_SESSION[$for]['flash'])) {
515
            $session = $_SESSION[$for]['flash'];
516
        }
517
518
        if (count($session)) {
519
            $str     = '<br/><br/>';
520
            foreach ($session as $key => $value) {
521
                if ($backend===true) {
522
                    $key2 = 'warning';
523
                    if ($key=='danger') {
524
                        $key2 = 'error';
525
                    } elseif ($key=='error') {
526
                        $key2 = 'error';
527
                    } elseif ($key=='success') {
528
                        $key2 = 'check_circle';
529
                    } elseif ($key=='warning') {
530
                        $key2 = 'warning';
531
                    } elseif ($key=='info') {
532
                        $key2 = 'priority_high';
533
                    }
534
535
                    $str.= '<div class="card green lighten-1 flashContainer">
536
                            <div class="row">
537
                              <div class="col m10">
538
                                <div class="card-content white-text">
539
                                  <h5><i class="material-icons small-icons">'.$key2.'</i> '.ucfirst($key).'</h5>
540
                                  <p>'.$value.'</p>
541
                              </div>
542
                            </div>
543
                            <div class="col m2">
544
                              <a href="javascript:;" class="right white-text" target="_self">
545
                                <i class="material-icons small-icons flashClose">close</i>
546
                              </a>
547
                            </div>
548
                          </div>
549
                         </div>';
550
                } else {
551
                    $str.= '<div class="alert alert-'.$key.' alert-dismissible" role="alert">
552
                            <button type="button" class="close" data-dismiss="alert">
553
                                <span aria-hidden="true">×</span><span class="sr-only">Close</span>
554
                            </button>
555
                            <strong>'.ucfirst($key).'</strong> '.$value.'
556
                          </div>';
557
                }
558
            }
559
        }
560
561
        $_SESSION[$for]['flash'] = null;
562
        return $str;
563
    }
564
}
565
566
if (!function_exists('__flashSession')) {
567
    function __flashSession($backend = true)
568
    {
569
        echo _flashSession($backend);
570
    }
571
}
572
573
if (!function_exists('_setFlash')) {
574
    function _setFlash($msg_type, $msg, $backend = true)
575
    {
576
        $for = ($backend === true ? 'backend' : 'frontend');
577
        $_SESSION[$for]['flash'][$msg_type] = $msg;
578
    }
579
}
580
581
if (!function_exists('_redirect')) {
582
    function _redirect($url, $code = 200)
0 ignored issues
show
Unused Code introduced by
The parameter $code is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

582
    function _redirect($url, /** @scrutinizer ignore-unused */ $code = 200)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
583
    {
584
        if ($url=='back') {
585
            $url = $_SERVER['HTTP_REFERER'];
586
        }
587
        header("Location: ".$url);
588
        exit();
589
    }
590
}
591
592
if (!function_exists('_upload')) {
593
    function _upload($tmp_name, $attachment)
594
    {
595
        move_uploaded_file($tmp_name, UPLOAD_DIR."$attachment");
596
    }
597
}
598
599
if (!function_exists('_slug')) {
600
    function _slug($string)
601
    {
602
        return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $string)));
603
    }
604
}
605
606
if (!function_exists('_numberToCurrency')) {
607
    function _numberToCurrency($num)
608
    {
609
        if (setlocale(LC_MONETARY, 'en_IN')) {
610
            return money_format('%.0n', $num);
611
        }
612
        
613
        $explrestunits = "" ;
614
        if (strlen($num)>3) {
615
            $lastthree = substr($num, strlen($num)-3, strlen($num));
616
             // extracts the last three digits
617
            $restunits = substr($num, 0, strlen($num)-3);
618
            // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
619
            $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits;
620
621
            $expunit = str_split($restunits, 2);
622
            $sizeof  = sizeof($expunit);
623
            for ($i=0; $i<$sizeof; $i++) {
624
                // creates each of the 2's group and adds a comma to the end
625
                if ($i==0) {
626
                    // if is first value , convert into integer
627
                    $explrestunits .= (int)$expunit[$i].",";
628
                } else {
629
                    $explrestunits .= $expunit[$i].",";
630
                }
631
            }
632
            $thecash = $explrestunits.$lastthree;
633
        } else {
634
            $thecash = $num;
635
        }
636
        return '₹ ' . $thecash;
637
    }
638
}
639
640
if (!function_exists('getQueryStrings')) {
641
    function getQueryStrings($url = '')
642
    {
643
        $data = array();
644
        $query = ltrim(strstr($url, '?'), '?');
645
        $arr = explode('&', $query);
646
        if (is_array($arr) && count($arr)) {
647
            foreach ($arr as $value) {
648
                $split = explode('=', $value);
649
                if (isset($split[0])) {
650
                    $data[$split[0]] = isset($split[1]) ? $split[1] : null;
651
                }
652
            }
653
        }
654
        return $data;
655
    }
656
}
657
658
if (!function_exists('_requestData')) {
659
    function _requestData($var, $default = null, $method = 'post', $format = null)
660
    {
661
        switch (strtolower($method)) {
662
            case 'get': //$from = $_GET;
663
            //for godaddy which creates problem in $_GET
664
                $from = getQueryStrings($_SERVER['REQUEST_URI']);
665
                break;
666
            case 'post':
667
                $from = $_POST;
668
                break;
669
            case 'request':
670
            case 'any':
671
                $from = $_REQUEST;
672
                break;
673
        }
674
675
        if ($format == null) {
676
            if (!isset($from[$var])) {
677
                return $default;
678
            }
679
680
            if ($default == null) {
681
                if ($from[$var]== '') {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $from does not seem to be defined for all execution paths leading up to this point.
Loading history...
682
                    return $default;
683
                }
684
                
685
                return $from[$var];
686
            } else {
687
                if ($from[$var]== '') {
688
                    return $default;
689
                }
690
691
                return $from[$var];
692
            }
693
            
694
        }
695
        
696
        switch (strtolower($format)) {
697
            case 'upper':
698
                $retVal = isset($from[$var]) ? strtoupper($from[$var]) : $default;
699
            break;
700
            case 'lower':
701
                $retVal = isset($from[$var]) ? strtolower($from[$var]) : $default;
702
            break;
703
            case 'int':
704
                $retVal = isset($from[$var]) ? (int)$from[$var] : $default;
705
            break;
706
            case 'float':
707
                $retVal = isset($from[$var]) ? (float)$from[$var] : $default;
708
            break;
709
        }
710
        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...
711
    }
712
}
713
714
if (!function_exists('_getData')) {
715
    function _getData($var, $default = null, $format = null)
716
    {
717
        return _requestData($var, $default, 'get', $format);
718
    }
719
}
720
721
if (!function_exists('_postData')) {
722
    function _postData($var, $default = null, $format = null)
723
    {
724
        return _requestData($var, $default, 'post', $format);
725
    }
726
}
727
728
function _encodeString($string)
729
{
730
    $result       = $string;
731
    $arrayLetters = array('C', 'R', 'U', 'Z', 'M', 'I', 'N', 'I');
732
    $limit        = count($arrayLetters) - 1;
733
    $num          = mt_rand(0, $limit);
734
735
    for ($i = 1; $i <= $num; $i++) {
736
        $result = base64_encode($result);
737
    }
738
    $result = $result . '::' . $arrayLetters[$num];
739
    $result = base64_encode($result);
740
    return str_replace('=', '~~', $result);
741
}
742
743
function _decodeString($string)
744
{
745
    $string = str_replace('~~', '=', $string);
746
    $result = base64_decode($string);
747
    list($result, $letra) = explode('::', $result);
748
    $arrayLetters = array('C', 'R', 'U', 'Z', 'M', 'I', 'N', 'I');
749
    $totalCount = count($arrayLetters);
750
751
    for ($i = 0; $i <$totalCount; $i++) {
752
        if ($arrayLetters[$i] == $letra) {
753
            for ($j = 1; $j <= $i; $j++) {
754
                $result = base64_decode($result);
755
            }
756
            break;
757
        }
758
    }
759
    return $result;
760
}
761