<commit_before><?php
/**
* $Id: backup.import.php,v 1.5 2005-03-30 06:48:45 thorstenr Exp $
*
* The import function to import the phpMyFAQ backups
*
* @author       <NAME> <<EMAIL>>
* @since        2003-02-24
* @copyright    (c) 2001-2005 phpMyFAQ Team
* 
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
* 
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*/
if ($permission["restore"]) {
?>
	<h2><?php print $PMF_LANG["ad_csv_rest"]; ?></h2>
<?php
    if (isset($_FILES["userfile"]["type"]) && ($_FILES["userfile"]["type"] == "application/octet-stream" || $_FILES["userfile"]["type"] == "text/plain")) {
    	$ok = 1;
    	$fp = fopen($_FILES["userfile"]["tmp_name"], "r");
    	$dat = fgets($fp, 65536);
    	
    	if (substr($dat, 0, 10) != "-- pmf1.5") {
    		print $PMF_LANG["ad_csv_no"];
    		$ok = 0;
        } else {
    		$dat = substr($dat, 7, strlen($dat)-6);
    		$tbl = explode(" ", $dat);
    		for ($h = 0; $h <= 10; $h++) {
    			if (isset($tbl[$h])) {
    				$mquery[] = "DELETE FROM ".trim($tbl[$h]);
                }
            }
    		$ok = 1;
        }
    	
    	if ($ok == 1) {
    		print "<p>".$PMF_LANG["ad_csv_prepare"]."</p>\n";
            $dat = trim($dat);
            while (($dat = fgets($fp, 65536))) {
    			if (substr($dat, 0, 1) != "#") {
    				$mquery[] = trim(substr($dat, 0, -1));
                }
            }
    		fclose($fp);
    		
    		$k = 0;
    		$g = 0;
    		print "<p>".$PMF_LANG["ad_csv_process"]."</p>\n";
    		$anz = count($mquery);
    		$kg = "";
    		for ($i = 0; $i < $anz; $i++) {
    			$kg = $db->query($mquery[$i]);
    			if (!$kg) {
    				print "<div style=\"font-size: 9px;\"><b>Query</b>: \"".$mquery[$i]."\" <span style=\"color: red;\">failed (Reason: ".$db->error().")</span></div>\n";
                } else {
    				print "<div style=\"font-size: 9px;\"><b>Query</b>: <!-- \"".$mquery[$i]."\" --> <span style=\"color: green;\">okay</span></div>\n";
                }
            }
    		print "<p>".$i." ".$PMF_LANG["ad_csv_of"]." ".$anz." ".$PMF_LANG["ad_csv_suc"]."</p>\n";
        }
    } else {
    	print "<p>".$PMF_LANG["ad_csv_no"]."</p>";
    }
} else {
    print $PMF_LANG["err_NotAuth"];
}
<commit_msg>Bugfix: added text/x-sql file type for Linux users<commit_after><?php
/**
* $Id: backup.import.php,v 1.6 2005-03-31 09:32:27 thorstenr Exp $
*
* The import function to import the phpMyFAQ backups
*
* @author       <NAME> <<EMAIL>>
* @since        2003-02-24
* @copyright    (c) 2001-2005 phpMyFAQ Team
* 
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
* 
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*/
if ($permission["restore"]) {
?>
	<h2><?php print $PMF_LANG["ad_csv_rest"]; ?></h2>
<?php
    if (isset($_FILES["userfile"]["type"]) && ($_FILES["userfile"]["type"] == "application/octet-stream" || $_FILES["userfile"]["type"] == "text/plain" || $_FILES["userfile"]["type"] == "text/x-sql")) {
    	$ok = 1;
    	$fp = fopen($_FILES["userfile"]["tmp_name"], "r");
    	$dat = fgets($fp, 65536);
    	
    	if (substr($dat, 0, 10) != "-- pmf1.5") {
    		print $PMF_LANG["ad_csv_no"];
    		$ok = 0;
        } else {
    		$dat = substr($dat, 7, strlen($dat)-6);
    		$tbl = explode(" ", $dat);
    		for ($h = 0; $h <= 10; $h++) {
    			if (isset($tbl[$h])) {
    				$mquery[] = "DELETE FROM ".trim($tbl[$h]);
                }
            }
    		$ok = 1;
        }
    	
    	if ($ok == 1) {
    		print "<p>".$PMF_LANG["ad_csv_prepare"]."</p>\n";
            $dat = trim($dat);
            while (($dat = fgets($fp, 65536))) {
    			if (substr($dat, 0, 1) != "#") {
    				$mquery[] = trim(substr($dat, 0, -1));
                }
            }
    		fclose($fp);
    		
    		$k = 0;
    		$g = 0;
    		print "<p>".$PMF_LANG["ad_csv_process"]."</p>\n";
    		$anz = count($mquery);
    		$kg = "";
    		for ($i = 0; $i < $anz; $i++) {
    			$kg = $db->query($mquery[$i]);
    			if (!$kg) {
    				print "<div style=\"font-size: 9px;\"><b>Query</b>: \"".$mquery[$i]."\" <span style=\"color: red;\">failed (Reason: ".$db->error().")</span></div>\n";
                } else {
    				print "<div style=\"font-size: 9px;\"><b>Query</b>: <!-- \"".$mquery[$i]."\" --> <span style=\"color: green;\">okay</span></div>\n";
                }
            }
    		print "<p>".$i." ".$PMF_LANG["ad_csv_of"]." ".$anz." ".$PMF_LANG["ad_csv_suc"]."</p>\n";
        }
    } else {
    	print "<p>".$PMF_LANG["ad_csv_no"]."</p>";
    }
} else {
    print $PMF_LANG["err_NotAuth"];
}

{'fraction_non_alphanumeric': 0.22448210922787193, 'fraction_numerical': 0.02598870056497175, 'mean_word_length': 2.2622850122850124, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '224455', 'n_tokens_mistral': 2126, 'n_tokens_neox': 1997, 'n_words': 449}