Example #1
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 * 
 * 
 */
require_once __DIR__ . "/../../session.php";
require_once __DIR__ . "/../../moneyio.php";
open_session();
$rol_name = $_POST["name"];
$rol_descr = $_POST["descr"];
$rol_id = $_GET["rol_id"];
/// The param id is linked into form of mio-themes/raw/mio-rol/update/update.php when:
/// <form action="...'....'/mio-rol/update/rol.php?rol_id=<php echo $rol_info->rol_id; CLOSE_PHP_TAG>"
if (isset($_SESSION["mio-username"]) && !empty($_SESSION["mio-username"]) && isset($_SESSION["mio-username_id"]) && !empty($_SESSION["mio-username_id"]) && isset($_SESSION["mio-pic"]) && !empty($_SESSION["mio-pic"])) {
    if (isset($rol_name) && !empty($rol_name) && isset($rol_descr) && !empty($rol_descr) && isset($rol_id) && !empty($rol_id)) {
        require_once __DIR__ . "/rol_func.php";
        if (update_rol($rol_name, $rol_descr, $rol_id)) {
            echo get_message("rol_updated");
        } else {
            echo get_message("rol_not_updated");
        }
    }
} else {
    echo get_message("no_session");
}
<?php

include_once 'config.php';
$db = $_GET["db"];
$df = $_GET["df"];
$sql_db = $_GET["sql_db"];
$sql_df = $_GET["sql_df"];
$rol = $_GET["rol"];
$today = date("m.d.y");
$file = "extract/rolmre_cant_" . $rol . "_" . $today . ".txt";
$data = get_all($sql_db, $sql_df, $rol);
$rol_id = insert_rol("rolmre_cantine", $sql_db, $sql_df, $file, $rol);
update_rol($sql_db, $sql_df, $rol_id);
$fh = fopen($file, 'w') or die("can't open file");
fwrite($fh, $data);
fclose($fh);
//print_r($data);
output_file($file, "rolmre_cant_" . $rol . "_" . $today . ".txt", "text/txt");
function output_file($file, $name, $mime_type = '')
{
    /*
    This function takes a path to a file to output ($file), 
    the filename that the browser will see ($name) and 
    the MIME type of the file ($mime_type, optional).
    
    If you want to do something on download abort/finish,
    register_shutdown_function('function_name');
    */
    if (!is_readable($file)) {
        die('File not found or inaccessible!');
    }