AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.217.80
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/public_html/lrsys_apps/mundotennis/application/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/public_html/lrsys_apps/mundotennis/application/helpers/ibilling_misc.php
<?php

function get_client_ip() {
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        $ip = $_SERVER['REMOTE_ADDR'];
    }

    return $ip;
}

function ib_post($param, $defvalue = '') {
    if (!isset($_POST[$param])) {
        return $defvalue;
    } else {
        return $_POST[$param];
    }
}

function _log($description, $type = '', $userid = '0') {
    $d = ORM::for_table('sys_logs')->create();
    $d->date = date('Y-m-d H:i:s');
    $d->type = $type;
    $d->description = $description;
    $d->userid = $userid;
    $d->ip = $_SERVER["REMOTE_ADDR"];
    $d->save();
}

$admin_extra_nav = array(
    0 => '',
    1 => '',
    2 => '',
    3 => '',
    4 => '',
    5 => '',
    6 => '',
    7 => '',
    8 => '',
    9 => '',
    10 => ''
);

$client_extra_nav = array(
    0 => '',
    1 => '',
    2 => '',
    3 => '',
    4 => '',
    5 => '',
    6 => '',
    7 => '',
    8 => '',
    9 => '',
    10 => ''
);

// pego a url
$url_arr = explode('=',$_SERVER['REQUEST_URI']);
$url_aux = '';
if(isset($url_arr[1]))
{
    $url_aux = $url_arr[1];
}
$active = '';
global $ui;
$ui->assign('_urlsubmenu', $url_aux);


/*
 *
 * Create Menu dynamically for plugins and hooks
 *
 * @param string $name name of the menu
 * @param string $link link of the menu
 * @param string $c controller name to set menu active
 * @param string fontawesome or iBilling icon name
 * @param int $position position of the menu
 * @param array $submenu submenu items
 *
 * */

function add_menu_admin($name, $link = '#', $c = '', $icon = 'icon-leaf', $position = 5, $submenu = array(), $id_aux = null) {
	if(isset($_SESSION['uid'])) {
		$user = User::_info();
	}
        
        // pego a url
        $url_arr = explode('=',$_SERVER['REQUEST_URI']);
        $url_aux = '';
        if(isset($url_arr[1]))
        {
            $url_aux = U.$url_arr[1];
        }
        $active = '';
        
        // ERP-269 Horizontal Menus
	global $horizontal_menus;
	$related_plugins = [];
	$module = (isset($_SESSION['module'])) ? $_SESSION['module'] : '';
	foreach($horizontal_menus as $hmenu) {
		if($hmenu['alias'] == $module) {
			$related_plugins = json_decode($hmenu['related_plugins'], true);
		}
	}

	$is_horizontal_menus = false;
	if(!isset($related_plugins[1]) || in_array($c, $related_plugins[1])) {
		$is_horizontal_menus = true;
	}

	// Verifica se o role do usuário tem permissão para o módulo
	// TODO: a segunda condição do if é uma solução temporária e deve ser
	// TODO: removida assim que possível, ver ERP-131
	if(isset($user) && (has_access($user['roleid'], $c) || $c == "module_stock/stock") && $is_horizontal_menus) {

		global $admin_extra_nav, $routes;
		global $_L;

		
		if (!empty($submenu)) {

			$s = '';
			//busca dados do pluggin instalado
			$d = ORM::for_table('sys_pl')->where('c', $c)->find_one();
			if ($d) {
				//Verifica se existe nova versão do pluggin
				if (isset($_SESSION['plugins'])) {
					$plugin = $_SESSION['plugins'];
					if ($plugin[$c] > $d->version) {
						$s .= ' <li><a href="' . U . 'settings/plugin_auto_update/' . $c . '/" ><i class="fa fa-refresh"></i><span class="nav-label">' . $_L['Module Update'] . '</span></a></li>';
					}
				}
			}
                        
			foreach ($submenu as $menu) {

                                $active_submenu = '';
                                if ($menu['link'] == $url_aux) {
                                        $active = 'active';
                                        $active_submenu = 'sub_active';
                                }
                                
				if (isset($menu['target'])) {
					$target = 'target="' . $menu['target'] . '"';
				} else {
					$target = '';
				}
				$s .= ' <li class="' . $active_submenu . '" ><a href="' . $menu['link'] . '" ' . $target . '>' . $menu['name'] . '</a></li>';
			}

			$admin_extra_nav[$position] .= '<li class="' . $active . '" id="li_' . $c .$id_aux.'">
						<a href="' . $link . '"><i class="' . $icon . '"></i> <span class="nav-label">' . $name . ' </span><span class="fa arrow"></span></a>
	
	<ul class="nav nav-second-level">
	' . $s . '
	</ul>
	</li>';
		} else {
			$admin_extra_nav[$position] .= '<li class="' . $active . '" id="li_' . $c . '"><a href="' . $link . '"><i class="' . $icon . '"></i> <span class="nav-label">' . $name . '</span></a></li>';
		}
    }
}

function add_menu_client($name, $link = '#', $c = '', $icon = 'icon-leaf', $position = 3, $submenu = array()) {

    global $client_extra_nav, $routes;

    $active = '';
    if ((isset($routes['0'])) AND ( $routes['0']) == $c) {
        $active = 'active';
    } elseif ((isset($routes['2'])) AND ( $routes['2']) == $c) {
        $active = 'active';
    } else {
        
    }
    if (!empty($submenu)) {
        $s = '';

        foreach ($submenu as $menu) {
            if (isset($menu['target'])) {
                $target = 'target="' . $menu['target'] . '"';
            } else {
                $target = '';
            }
            $s .= ' <li><a href="' . $menu['link'] . '" ' . $target . '>' . $menu['name'] . '</a></li>';
        }

        $client_extra_nav[$position] .= '<li class="' . $active . '">
                    <a href="' . $link . '"><i class="' . $icon . '"></i> <span class="nav-label">' . $name . ' </span><span class="fa arrow"></span></a>

<ul class="nav nav-second-level">
' . $s . '
</ul>
</li>';
    } else {
        $client_extra_nav[$position] .= '<li class="' . $active . '"><a href="' . $link . '"><i class="' . $icon . '"></i> <span class="nav-label">' . $name . '</span></a></li>';
    }
}

$sub_menu_admin = array();
$sub_menu_admin['settings'] = array();
$sub_menu_admin['appearance'] = array();
$sub_menu_admin['crm'] = array();
$sub_menu_admin['reports'] = array();

function add_sub_menu_admin($parent, $name, $link) {
    global $sub_menu_admin;
    $sub_menu_admin[$parent][] = '<li><a href="' . $link . '">' . $name . '</a></li>';
}

function add_option($option, $value) {

    $d = ORM::for_table('sys_appconfig')->where('setting', $option)->find_one();
    if ($d) {
        return false;
    } else {
        //add option
        $c = ORM::for_table('sys_appconfig')->create();
        $c->setting = $option;
        $c->value = $value;
        $c->save();
        return true;
    }
}

function get_option($option) {
    $d = ORM::for_table('sys_appconfig')->where('setting', $option)->find_one();
    if ($d) {
        return $d['value'];
    } else {
        return false;
    }
}

function update_option($option, $value) {

    $d = ORM::for_table('sys_appconfig')->where('setting', $option)->find_one();
    if ($d) {
        $d->value = $value;
        $d->save();
        return true;
    } else {
        return false;
    }
}

function delete_option($option) {
    $d = ORM::for_table('sys_appconfig')->where('setting', $option)->find_one();
    if ($d) {
        $d->delete();
        return true;
    } else {
        return false;
    }
}

function ib_die($msg = '') {
    echo $msg;
    exit;
}

function ib_close() {
    exit;
}

function get_custom_field_value($fid, $rid) {

    $d = ORM::for_table('crm_customfieldsvalues')->where('fieldid', $fid)->where('relid', $rid)->find_one();

    return $d['fvalue'];
}

function ib_pg_count() {
    $d = ORM::for_table('sys_pg')->where('status', 'Active')->count();
    return $d;
}

function ib_add_field_value($fieldid, $relid, $fvalue) {
    $d = ORM::for_table('crm_customfieldsvalues')->create();
    $d->fieldid = $fieldid;
    $d->relid = $relid;
    $d->fvalue = $fvalue;
    $d->save();
    return true;
}

// Date Related

function ib_today() {
    return date('Y-m-d');
}

function ib_after_1_month($from = '', $format = 'mysql') {

    if ($from == '') {
        $from = strtotime(date('Y-m-d'));
    }

    if ($format == 'mysql') {
        $format = 'Y-m-d';
    }

    return date($format, strtotime('+1 month', $from));
}

function ib_lan_get_line($line, $fallback = '') {

    global $_L;
    if (isset($_L[$line])) {
        return str_replace($line, $_L[$line], $line);
    } elseif ($fallback != '') {
        return $fallback;
    } else {

        return $line;
    }
}

function d2($msg = 'I am here!') {

    if (is_array($msg)) {
        foreach ($msg as $m) {
            echo $m . ' |
';
        }
    } else {
        echo $msg;
    }

    exit;
}

function d2c($data) {

    if (is_array($data))
        $output = "<script>console.log( 'Debug Objects: " . implode(',', $data) . "' );</script>";
    else
        $output = "<script>console.log( 'Debug Objects: " . $data . "' );</script>";

    echo $output;
}

function lan() {
    global $config;
    return $config['language'];
}

function add_js($f = array(), $v = '') {

    global $ui;
    global $pl_path;

    if ($v == '') {
        $ver = '';
    } else {
        $ver = '?ver=' . $v;
    }
    $gen = '';
    if (is_array($f)) {
        foreach ($f as $p) {
            $gen .= '<script type="text/javascript" src="' . $pl_path . 'js/' . $p . '.js' . $ver . '"></script>
        ';
        }

        $ui->assign('xfooter', $gen);

        return true;
    }

    return false;
}

function add_js_external($url = array()) {



    $gen = '';
    if (is_array($url)) {
        foreach ($url as $u) {
            $gen .= '<script type="text/javascript" src="' . APP_URL . '/' . $u . '.js"></script>
        ';
        }



        return $gen;
    }

    return false;
}

function add_js_internal($paths = array()) {



    $gen = '';
    if (is_array($paths)) {
        foreach ($paths as $u) {
            $gen .= '<script type="text/javascript" src="' . APP_URL . '/' . $u . '.js"></script>
        ';
        }



        return $gen;
    }

    return false;
}

function set_tpl($path) {
    global $ui;
    $ui->assign('tplheader', $path . 'header');
    $ui->assign('tplfooter', $path . 'footer');
}

function set_admin_header($path) {
    global $ui;
    $ui->assign('tplheader', $path);
}

function set_admin_footer($path) {
    global $ui;
    $ui->assign('tplfooter', $path);
}

function set_admin_nav($path) {
    global $ui;
    $ui->assign('tplnav', $path);
}

function language_append($path) {
    global $_L;
    $file = 'application/plugins/' . $path;
    include ($file);
}

function lan_register($path) {

    $x = include $path;


    var_dump($x);
    exit;
}

function add_plugin_ui_header_admin($header = '') {
    global $plugin_ui_header_admin;
    array_push($plugin_ui_header_admin, $header);
}

function add_css_admin($path) {
    global $plugin_ui_header_admin_css;
    array_push($plugin_ui_header_admin_css, $path);
}

function add_plugin_ui_header_client($header = '') {
    global $plugin_ui_header_client;
    array_push($plugin_ui_header_client, $header);
}

function add_css_client($path) {
    global $plugin_ui_header_client_css;
    array_push($plugin_ui_header_client_css, $path);
}

function i_close($msg = '') {
    echo $msg;
    exit;
}

function inner_contents($lk) {

    $url_string = '?ng=';
    $inner_contents = '';

    //TODO: verificar uma forma melhor de não pedir o registro do IBILLING
    if ($lk = 'LRSYS') {
        return $inner_contents;
    }

    $lc = md5(APP_URL . $url_string);

    if ($lc != $lk) {

        $smarty_cache = 'PGRpdiBjbGFzcz0iYWxlcnQgYWxlcnQtZGFuZ2VyIj5QbGVhc2UgQWN0aXZhdGUgWW91ciBpQmlsbGluZy4gPGEgY2xhc3M9ImJ0biBidG4tc3VjY2VzcyIgaHJlZj0iP25nPXNldHRpbmdzL2FjdGl2YXRlX2xpY2Vuc2UvIj5DbGljayBIZXJlIHRvIEFjdGl2YXRlPC9hPjwvZGl2Pg==';

        $inner_contents = base64_decode($smarty_cache);
    }

    return $inner_contents;
}

function ib_http_request($url, $method = 'GET', $params = array(), $headers = array(), $resp_header = false, $follow_redirect = false) {

    $response = '';



    if (!is_callable('curl_init')) {

        throw new Exception('CURL Not available in this Server.');
    }

    switch ($method) {

        case 'GET':

            $q = '';
            foreach ($params as $key => $value) {

                $value = urlencode($value);

                $q .= $key . '=' . $value . '&';
            }

            $req = $url;

            if ($q != '') {
                $q = rtrim($q, '&');

                $req = $url . '?' . $q;
            }



            try {
                $ch = curl_init();

                if (FALSE === $ch)
                    throw new Exception('failed to initialize');

                if (!empty($headers)) {

                    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                }

                curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_URL, $req);

                if ($follow_redirect) {
                    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
                }

                if ($resp_header) {
                    curl_setopt($ch, CURLOPT_HEADER, 1);
                }

                $response = curl_exec($ch);

                if (FALSE === $response)
                    throw new Exception(curl_error($ch), curl_errno($ch));
                curl_close($ch);
            } catch (Exception $e) {

                throw new Exception($e->getCode() . ' ' . $e->getMessage());
            }










            break;

        case 'POST':

            try {
                $ch = curl_init();

                if (FALSE === $ch)
                    throw new Exception('failed to initialize');

                if (!empty($headers)) {

                    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                }

                curl_setopt($ch, CURLOPT_URL, $url);
                curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

                if ($resp_header) {
                    curl_setopt($ch, CURLOPT_HEADER, 1);
                }

                $response = curl_exec($ch);

                if (FALSE === $response)
                    throw new Exception(curl_error($ch), curl_errno($ch));
                curl_close($ch);
            } catch (Exception $e) {

                throw new Exception($e->getCode() . ' ' . $e->getMessage());
            }




            break;
    }

    return $response;
}

function db_find_many($table, $columns = array()) {

    $d = ORM::for_table($table);

    foreach ($columns as $column) {
        $d->select($column);
    }

    $ret = $d->find_many();

    return $ret;
}

function db_find_array($table, $columns = array(), $order_by = '') {

    $d = ORM::for_table($table);

    foreach ($columns as $column) {
        $d->select($column);
    }

    if ($order_by != '') {

        $o = explode(':', $order_by);

        if ($o[0] == 'asc') {
            $d->order_by_asc($o[1]);
        } elseif ($o[0] == 'desc') {
            $d->order_by_desc($o[1]);
        } else {
            $d->order_by_desc($order_by);
        }
    }

    $ret = $d->find_array();

    return $ret;
}

function db_find_one($table, $id) {

    $d = ORM::for_table($table)->find_one($id);

    if ($d) {
        return $d;
    } else {
        return false;
    }
}

function db_delete_row($table, $id) {

    $d = ORM::for_table($table)->find_one($id);
    if ($d) {
        $d->delete();
        return true;
    } else {
        return false;
    }
}

function route($id, $default = '') {

    global $routes;

    if (isset($routes[$id]) && $routes[$id] != '') {
        return $routes[$id];
    } else {

        return $default;
    }
}

function is_dev() {

    global $_app_stage;

    if ($_app_stage != "Dev") {

        die("Unable to handle your request in Live Mode.");
    }
}

function ib_money_format($amount, $config, $symbol = '') {

    if ($symbol == '') {
        $currency_code = $config['currency_code'];
    } else {
        $currency_code = $symbol;
    }


    $thousand_separator_placement = $config['thousand_separator_placement'];
    $currency_decimal_digits = $config['currency_decimal_digits'];
    $currency_symbol_position = $config['currency_symbol_position'];
    $dec_point = $config['dec_point'];
    $thousands_sep = $config['thousands_sep'];


    if ($currency_decimal_digits == 'true') {
        $dec_digit = 2;
    } else {
        $dec_digit = 0;
    }

    if ($currency_symbol_position == 's') {
        $retval = number_format($amount, $dec_digit, $dec_point, $thousands_sep) . $currency_code;
    } else {
        $retval = $currency_code . ' ' . number_format($amount, $dec_digit, $dec_point, $thousands_sep);
    }



    return $retval;
}

function buscaVersoesPluginsExterno() {
    global $db_externo_host, $db_externo_user, $db_externo_password, $db_externo_name;

    if (isset($db_externo_host)) {
        //Busca as versões mais atuais dos plugins
        $conn = mysqli_connect($db_externo_host, $db_externo_user, $db_externo_password, $db_externo_name);
        if (!$conn) {
            //ERRO AO conectar
        } else {
            $retorno = $conn->query("SELECT spv.plugin,spv.version FROM sys_pl_version spv WHERE version=(SELECT max(sv.version) FROM sys_pl_version sv WHERE sv.plugin=spv.plugin)");

            while ($r = $retorno->fetch_assoc()) {
                $plugin[$r['plugin']] = $r['version'];
            }
            if (isset($plugin)) {
                $_SESSION['plugins'] = $plugin;
            }
        }
    }
}

/*
 * @deprecated
 * use ib_posted_data
 * */

function ib_get_posted_data() {

    $data = array();

    foreach ($_POST as $key => $value) {
        $data[$key] = trim($value);
    }

    return $data;
}

function ib_posted_data() {

    $data = array();

    foreach ($_POST as $key => $value) {
        $data[$key] = trim($value);
    }

    return $data;
}

function ib_js_date_format($format, $js = 'moment') {

    if ($js == 'moment') {

        $format = str_replace('d', 'DD', $format);
        $format = str_replace('M', 'MMM', $format);
        $format = str_replace('m', 'MM', $format);
        $format = str_replace('Y', 'YYYY', $format);
        $format = str_replace('jS', 'Do', $format);
        return $format;
    } elseif ($js = 'picker') {
        $format = str_replace('d', 'dd', $format);
        $format = str_replace('m', 'mm', $format);
        $format = str_replace('Y', 'yyyy', $format);
        $format = str_replace('M', 'mmm', $format);
        $format = str_replace('jS', 'd', $format);
        return $format;
    } else {

        $format = str_replace('d', 'DD', $format);
        $format = str_replace('m', 'MM', $format);
        $format = str_replace('Y', 'YYYY', $format);
        $format = str_replace('M', 'MMM', $format);
        $format = str_replace('jS', 'Do', $format);
        return $format;
    }
}

function has_access($rid, $shortname, $action = 'view') {

    if ($rid == 0) {
        return true;
    }

    $d = ORM::for_table('sys_staffpermissions')->where('rid', $rid)->where('shortname', $shortname)->find_one();

    if ($d) {

        switch ($action) {

            case 'view':

                if ($d->can_view == 1) {
                    return true;
                } else {
                    return false;
                }

                break;

            case 'edit':

                if ($d->can_edit == 1) {
                    return true;
                } else {
                    return false;
                }

                break;

            case 'create':

                if ($d->can_create == 1) {
                    return true;
                } else {
                    return false;
                }

                break;

            case 'delete':

                if ($d->can_delete == 1) {
                    return true;
                } else {
                    return false;
                }

                break;

            default:
                return false;
        }
    } else {
        return false;
    }
}

function addPermission($pname, $shortname) {

    $d = ORM::for_table('sys_permissions')->where('shortname', $shortname)->find_one();

    if ($d) {
        return false;
    } else {
        $p = ORM::for_table('sys_permissions')->create();
        $p->pname = $pname;
        $p->shortname = $shortname;
        $p->save();
        return $p->id();
    }
}

function deletePermission($shortname) {

    $d = ORM::for_table('sys_permissions')->where('shortname', $shortname)->find_one();

    if ($d) {
        $d->delete();
        return true;
    } else {
        return false;
    }
}

function permissionDenied() {

    r2(U . 'dashboard', 'e', 'Permission Denied');
}

function api_response($data = array()) {

    header('Content-type: application/json');
    echo json_encode($data);
    exit;
}

function client_ip() {
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    } else {
        $ip = $_SERVER['REMOTE_ADDR'];
    }

    return $ip;
}

function backupTotal($mysqli) {
    global $db_host, $db_name;
    try {

        // put a few comments into the SQL file
        $b.=("-- pjl SQL Dump\n");
        $b.=("-- Server version:" . $mysqli->server_info . "\n");
        $b.=("-- Generated: " . date('Y-m-d h:i:s') . "\n");
        $b.=('-- Current PHP version: ' . phpversion() . "\n");
        $b.=('-- Host: ' . $db_host . "\n");
        $b.=('-- Database:' . $db_name . "\n");

        //get a list of all the tables
        $aTables = array();
        $strSQL = 'SHOW TABLES';            // I put the SQL into a variable for debuggin purposes - better that "check syntax near '), "
        if (!$res_tables = $mysqli->query($strSQL))
            throw new Exception("MySQL Error: " . $mysqli->error . 'SQL: ' . $strSQL);

        while ($row = $res_tables->fetch_array()) {
            $aTables[] = $row[0];
        }

        // Don't really need to do this (unless there is loads of data) since PHP will tidy up for us but I think it is better not to be sloppy
        // I don't do this at the end in case there is an Exception
        $res_tables->free();

        //now go through all the tables in the database
        foreach ($aTables as $table) {
            $b.=("-- --------------------------------------------------------\n");
            $b.=("-- Structure for '" . $table . "'\n");
            $b.=("--\n\n");

            // remove the table if it exists
            //  $b.=('DROP TABLE IF EXISTS '.$table.';');
            // ask MySQL how to create the table
            $strSQL = 'SHOW CREATE TABLE ' . $table;
            if (!$res_create = $mysqli->query($strSQL))
                throw new Exception("MySQL Error: " . $mysqli->error . 'SQL: ' . $strSQL);
            $row_create = $res_create->fetch_assoc();

            $b.=("\n" . $row_create['Create Table'] . ";\n");


            $b.=("-- --------------------------------------------------------\n");
            $b.=('-- Dump Data for `' . $table . "`\n");
            $b.=("--\n\n");
            $res_create->free();

            // get the data from the table
            $strSQL = 'SELECT * FROM ' . $table;
            if (!$res_select = $mysqli->query($strSQL))
                throw new Exception("MySQL Error: " . $mysqli->error . 'SQL: ' . $strSQL);

            // get information about the fields
            $fields_info = $res_select->fetch_fields();

            // now we can go through every field/value pair.
            // for each field/value we build a string strFields/strValues
            while ($values = $res_select->fetch_assoc()) {

                $strFields = '';
                $strValues = '';
                foreach ($fields_info as $field) {
                    if ($strFields != '')
                        $strFields .= ',';
                    $strFields .= "`" . $field->name . "`";

                    // put quotes round everything - MYSQL will do type convertion (I hope) - also strip out any nasty characters
                    if ($strValues != '')
                        $strValues .= ',';
                    $strValues .= '"' . preg_replace('/[^(\x20-\x7F)\x0A]*/', '', $values[$field->name] . '"');
                }

                // now we can put the values/fields into the insert command.
                $b.=("INSERT INTO " . $table . " (" . $strFields . ") VALUES (" . $strValues . ");\n");
            }
            $b.=("\n\n\n");

            $res_select->free();
        }
        return $b;
    } catch (Exception $e) {
        return false;
    }
}

/*
 * Função para debug e die, parametro os dados a serem debugados
 * @param array $data
 */
function dd($data)
{
    echo "<pre>";
        var_dump($data);
    echo "</pre>";
    die();
}

/*
 * Função para limpar String
 * @param string $doc
 */
function clearDocs($doc)
{
    $doc = preg_replace("/\D+/", "", $doc);
    return $doc;
}

Anon7 - 2022
AnonSec Team