function csp_po_ajax_handle_scan_source_file() { csp_po_check_security(); require_once('includes/class-translationfile.php'); $textdomain = $_POST['textdomain']; //TODO: give the domain into translation file as default domain $pofile = new CspTranslationFile(); //BUGFIX: 1.90 - may be, we have only the mo but no po, so we dump it out as base po file first if (!file_exists($_POST['pofile'])) { //try implicite convert first and reopen as po second if($pofile->read_mofile(substr($_POST['pofile'],0,-2)."mo", $csp_l10n_plurals)) { $pofile->write_pofile($_POST['pofile']); } } if ($pofile->read_pofile($_POST['pofile'])) { if ((int)$_POST['num'] == 0) { $pofile->parsing_init(); } $php_files = explode("|", $_POST['php']); $s = (int)$_POST['num']; $e = min($s + (int)$_POST['cnt'], count($php_files)); $last = ($e >= count($php_files)); for ($i=$s; $i<$e; $i++) { $pofile->parsing_add_messages($_POST['path'], $php_files[$i], $textdomain); } if ($last) { $pofile->parsing_finalize($textdomain); } if ($pofile->write_pofile($_POST['pofile'], $last)) { header('Content-Type: application/json'); echo '{ title: "'.date(__('m/d/Y H:i:s',CSP_PO_TEXTDOMAIN), filemtime($_POST['pofile']))." ".file_permissions($_POST['pofile']).'" }'; } else{ header('Status: 404 Not Found'); header('HTTP/1.1 404 Not Found'); echo sprintf(__("You do not have the permission to write the file '%s'.", CSP_PO_TEXTDOMAIN), $_POST['pofile']); } } else{ header('Status: 404 Not Found'); header('HTTP/1.1 404 Not Found'); echo sprintf(__("You do not have the permission to read the file '%s'.", CSP_PO_TEXTDOMAIN), $_POST['pofile']); } exit(); }
function csp_po_ajax_handle_scan_source_file() { csp_po_check_security(); $low_mem_scanning = (bool) get_option('codestyling-localization.low-memory', false); require_once 'includes/class-translationfile.php'; require_once 'includes/locale-definitions.php'; $textdomain = $_POST['textdomain']; //TODO: give the domain into translation file as default domain $pofile = new CspTranslationFile($_POST['type']); //BUGFIX: 1.90 - may be, we have only the mo but no po, so we dump it out as base po file first if (!file_exists($_POST['pofile'])) { //try implicite convert first and reopen as po second if ($pofile->read_mofile(substr($_POST['pofile'], 0, -2) . "mo", $csp_l10n_plurals, false, $textdomain)) { $pofile->write_pofile($_POST['pofile']); } } if ($pofile->read_pofile($_POST['pofile'])) { if ((int) $_POST['num'] == 0) { $pofile->parsing_init(); } $php_files = explode("|", $_POST['php']); $s = (int) $_POST['num']; $e = min($s + (int) $_POST['cnt'], count($php_files)); $last = $e >= count($php_files); for ($i = $s; $i < $e; $i++) { if ($low_mem_scanning) { $options = array('type' => $_POST['type'], 'path' => $_POST['path'], 'textdomain' => $_POST['textdomain'], 'file' => $php_files[$i]); $r = wp_remote_post(CSP_PO_BASE_URL . '/includes/low-memory-parsing.php', array('body' => $options)); $data = unserialize(base64_decode($r['body'])); $pofile->add_messages($data); } else { $pofile->parsing_add_messages($_POST['path'], $php_files[$i], $textdomain); } } if ($last) { $pofile->parsing_finalize($textdomain); } if ($pofile->write_pofile($_POST['pofile'], $last)) { header('Content-Type: application/json'); echo '{ title: "' . date(__('m/d/Y H:i:s', CSP_PO_TEXTDOMAIN), filemtime($_POST['pofile'])) . " " . file_permissions($_POST['pofile']) . '" }'; } else { header('Status: 404 Not Found'); header('HTTP/1.1 404 Not Found'); echo sprintf(__("You do not have the permission to write to the file '%s'.", CSP_PO_TEXTDOMAIN), $_POST['pofile']); } } else { header('Status: 404 Not Found'); header('HTTP/1.1 404 Not Found'); echo sprintf(__("You do not have the permission to read the file '%s'.", CSP_PO_TEXTDOMAIN), $_POST['pofile']); } exit; }