File manager - Edit - /home/theblueo/tv/fb4e3b/php.tar
Back
loco-download.php 0000666 00000005505 15214177126 0010035 0 ustar 00 <?php /** * PO/MO download script */ try { if( 'POST' !== $_SERVER['REQUEST_METHOD'] ){ throw new Exception( 'Method not permitted', 405 ); } // no errors ruining response please if( false === ini_set( 'display_errors', 0 ) ){ error_reporting(0); } if( ! function_exists('current_user_can') || ! class_exists('LocoAdmin') ){ throw new Exception('WordPress not bootstrapped'); } if( ! current_user_can(Loco::admin_capablity()) ){ throw new Exception( __('User does not have permission to manage translations','loco-translate'), 403 ); } if( empty($po) ){ throw new Exception( 'Empty source data', 422 ); } if( empty($path) ){ $name = 'messages.po'; $ext = 'po'; } else { $name = basename($path); $ext = strtolower( pathinfo( $name, PATHINFO_EXTENSION ) ); } // Undo magic quotes if enabled if( get_magic_quotes_gpc() ){ $po = stripslashes( $po ); } // Simple post-through for PO and POT if( 'mo' !== $ext ){ header('Content-Type: application/x-gettext; charset=UTF-8', true ); header('Content-Length: '.strlen($po), true ); header('Content-Disposition: attachment; filename='.$name, true ); echo $po; exit(0); } // Attempt to compile MO direct to file via shell if( $msgfmt = LocoAdmin::msgfmt_command() ){ try { loco_require('build/shell-compiled'); define( 'WHICH_MSGFMT', $msgfmt ); // use temp file if possible, due to stdin size restrictions if( $popath = tempnam( sys_get_temp_dir(), 'loco-' ) ){ register_shutdown_function( 'unlink', $popath ); file_put_contents( $popath, $po ); $mopath = loco_compile_mo_file( $popath, $mopath ); register_shutdown_function( 'unlink', $mopath ); $mo = file_get_contents( $mopath ); } else { $mo = loco_compile_mo( $po ); } } catch( Exception $Ex ){ error_log( $Ex->getMessage(), 0 ); } if( ! $mo ){ throw new Exception( sprintf( __('Failed to compile MO file with %s, check your settings','loco-translate'), WHICH_MSGFMT ) ); } } // Fall back to in-built MO compiler - requires PO is parsed too else { $mo = LocoAdmin::msgfmt_native($po); } // exit with binary MO header('Content-Type: application/x-gettext-translation; charset=UTF-8', true ); header('Content-Length: '.strlen($mo), true ); header('Content-Disposition: attachment; filename='.$name, true ); echo $mo; exit(0); } catch( Exception $Ex ){ require dirname(__FILE__).'/loco-fatal.php'; } loco-posync.php 0000666 00000004503 15214177126 0007536 0 ustar 00 <?php /** * Admin ajax include that syncs PO or POT file with sources */ DOING_AJAX or die(); if( empty($path) || ! isset($name) || empty($type) ){ throw new Exception( __('Invalid data posted to server','loco-translate'), 422 ); } // path is allowed to not exist yet if( '/' !== $path{0} ){ $path = WP_CONTENT_DIR.'/'.$path; } // but package must exist so we can get POT or source /* @var $package LocoPackage */ loco_require('loco-packages','loco-locales'); $package = LocoPackage::get( $name, $type ); if( ! $package ){ throw new Exception( sprintf( __('Package not found called %s','loco-translate'), $name ), 404 ); } while( true ){ // If file we're syncing is POT, we can only sync from sources if( ! LocoAdmin::is_pot($path) ){ // if a POT file exists, sync from that $domain = LocoAdmin::resolve_file_domain($path) or $domain = $package->get_domain(); if( $pot_path = $package->get_pot($domain) ){ $exp = LocoAdmin::parse_po( $pot_path ); if( ! $exp || ( 1 === count($exp) && '' === $exp[0]['source'] ) ){ // fall through to try source code } else { $pot = basename($pot_path); break; } } } // Extract from sources if( $exp = LocoAdmin::xgettext( $package, dirname($path) ) ){ $pot = ''; break; } throw new Exception( __('No strings could be extracted from source code','loco-translate') ); } // sync selected headers $headers = array(); if( '' === $exp[0]['source'] ){ $keep = array('Project-Id-Version','Language-Team','POT-Creation-Date','POT-Revision-Date'); $head = loco_parse_po_headers( $exp[0]['target'] ); $headers = array_intersect_key( $head->export(), array_flip($keep) ); /*/ add prefixed header keys that can't be included above foreach( $head as $key => $value ){ if( 0 === strpos($key, 'X-Poedit-' ) ){ $headers[$key] = $value; } }*/ $exp[0] = array(); } // sync ok. return compact( 'pot', 'exp', 'headers' ); loco-data.php 0000666 00000001011 15214177126 0007123 0 ustar 00 <?php /** * Admin ajax include that returns compiled-in data * Included by loco-ajax.php during Ajax action */ DOING_AJAX or die(); // default is single locale response if( isset($locale) ){ loco_require('loco-locales'); $data = loco_locale_resolve($locale); return array ( 'locales' => array ( $locale => $data->export(), ), ); } throw new Exception( __('Invalid data posted to server','loco-translate'), 422 ); loco-posave.php 0000666 00000012630 15214177126 0007520 0 ustar 00 <?php /** * Admin ajax include that saves PO file from editor to disk * Included by loco-ajax.php during Ajax action */ DOING_AJAX or die(); if( empty($path) || empty($po) || ! isset($name) || empty($type) ){ throw new Exception( __('Invalid data posted to server','loco-translate'), 422 ); } // path is allowed to not exist yet if( '/' !== $path{0} ){ $path = WP_CONTENT_DIR.'/'.$path; } // but package must exist so we can get POT or source /* @var $package LocoPackage */ loco_require('loco-packages','loco-locales'); $package = LocoPackage::get( $name, $type ); if( ! $package ){ throw new Exception( sprintf( __('Package not found called %s','loco-translate'), $name ), 404 ); } $fname = basename($path); $podir = dirname( $path ); $dname = basename( $podir ); $ispot = LocoAdmin::is_pot( $fname ); $ftype = $ispot ? 'POT' : 'PO'; // handle file backups if file exists and enabled if( file_exists($path) ){ $conf = Loco::config(); $num = (int) $conf['num_backups']; if( is_writable($podir) ){ $dest = preg_replace('/\.(pot?)$/i', '-backup-', $path ); // delete oldest backups until we have $num-1 remaining if( $prev = glob( $dest.'*' ) ){ function _loco_sort_backups( $f1, $f2 ){ $t1 = filemtime($f1); $t2 = filemtime($f2); return $t1 < $t2 ? -1 : ( $t2 < $t1 ? 1 : 0 ); } usort( $prev, '_loco_sort_backups' ); foreach( array_slice( $prev, max(0,$num-1) ) as $oldpath ){ register_shutdown_function( 'unlink', $oldpath ); } } // write new backup if( $num ){ $dest .= date('YmdHis').'.'.strtolower($ftype).'~'; copy( $path, $dest ); } } else if( $num ){ throw new Exception( sprintf( __('Web server cannot create backups in "%s". Fix file permissions or disable backups in settings','loco-translate'), basename($podir) ) ); } } // else construct directory tree if file does not exist else if( ! file_exists($podir) && ! mkdir( $path, 0775, true ) ){ $pname = basename( dirname($podir) ); throw new Exception( sprintf( __('Web server cannot create "%s" directory in "%s". Fix file permissions or create it manually.','loco-translate'), $dname, $pname ) ); } else if( ! is_dir($podir) || ! is_writable($podir) ){ throw new Exception( sprintf(__('Web server cannot create files in the "%s" directory. Fix file permissions or use the download function.','loco-translate'), basename($podir) ) ); } // Undo magic quotes if enabled if( get_magic_quotes_gpc() ){ $po = stripslashes( $po ); } // attempt to write PO file $bytes = file_put_contents( $path, $po ); if( false === $bytes ){ throw new Exception( sprintf(__('%s file is not writable by the web server. Fix file permissions or download and copy to "%s/%s".','loco-translate'), $ftype, $dname, $fname ) ); } // primary action ok $response = array ( 'bytes' => $bytes, 'filename' => basename($path), 'modified' => LocoAdmin::format_datetime( filemtime($path) ), ); // flush package from cache, so it's regenerated next list view with new stats $package->uncache(); // attempt to write MO file also, but may fail for numerous reasons. while( ! $ispot ){ try { // check target MO path before compiling $mopath = preg_replace( '/\.po$/', '.mo', $path ); if( ! file_exists($mopath) && ! is_writable( dirname($mopath) ) ){ throw new Exception( __('Cannot create MO file','loco-translate') ); } else if( file_exists($mopath) && ! is_writable($mopath) ){ throw new Exception( __('Cannot overwrite MO file','loco-translate') ); } // attempt to compile MO direct to file via shell if( $msgfmt = LocoAdmin::msgfmt_command() ){ try { $bytes = 0; loco_require('build/shell-compiled'); define( 'WHICH_MSGFMT', $msgfmt ); $mopath = loco_compile_mo_file( $path, $mopath ); $bytes = $mopath && file_exists($mopath) ? filesize($mopath) : 0; } catch( Exception $Ex ){ error_log( $Ex->getMessage(), 0 ); } if( ! $bytes ){ throw new Exception( sprintf( __('Failed to compile MO file with %s, check your settings','loco-translate'), WHICH_MSGFMT ) ); } $response['compiled'] = $bytes; break; } // Fall back to in-built MO compiler - requires PO is parsed too $mo = LocoAdmin::msgfmt_native($po); $bytes = file_put_contents( $mopath, $mo ); if( ! $bytes ){ throw new Exception( __('Failed to write MO file','loco-translate') ); } $response['compiled'] = $bytes; break; } catch( Exception $e ){ $response['compiled'] = $e->getMessage(); break; } } return $response; loco-fail.php 0000666 00000000257 15214177126 0007140 0 ustar 00 <?php /** * Script that deliberately fails */ try { throw new Exception('Unknown error'); } catch( Exception $Ex ){ require dirname(__FILE__).'/loco-fatal.php'; } loco-fatal.php 0000666 00000001547 15214177126 0007317 0 ustar 00 <?php /** * Handle exception with fatal exit */ $status = $Ex->getCode() or $status = 500; $message = $Ex->getMessage(); if( ( isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 'XMLHttpRequest' === $_SERVER['HTTP_X_REQUESTED_WITH'] ) ){ $type = 'application/json; charset=UTF-8'; $body = json_encode( compact('status','message') ); } else { $type = 'text/html; charset=UTF-8'; $body = '<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Error '.$status.'</title> </head> <body> <h1>'.htmlspecialchars($message, ENT_COMPAT, 'UTF-8').'</h1> </body> </html> '; } header( sprintf('HTTP/1.0 %u %s', $status, $message ), true, $status ); header('Content-Type: '.$type, true, $status ); header('Content-Length: '.strlen($body), true, $status ); echo $body; exit(0); loco-ajax.php 0000666 00000002544 15214177126 0007151 0 ustar 00 <?php /** * Admin ajax action wrapper */ try { // no errors ruining json response please if( false === ini_set( 'display_errors', 0 ) ){ error_reporting(0); } if( ! function_exists('current_user_can') || ! class_exists('LocoAdmin') ){ throw new Exception('Ajax action only'); } if( ! current_user_can(Loco::admin_capablity()) ){ throw new Exception( __('User does not have permission to manage translations','loco-translate'), 403 ); } $incphp = isset($action) ? dirname(__FILE__).'/'.$action.'.php' : ''; if( ! $incphp || ! file_exists($incphp) ){ throw new Exception('Bad Ajax action'); } // Ajax action can only exit 200 try { $response = include $incphp; } catch( Exception $Ex ){ $response = array( 'error' => array ( 'code' => $Ex->getCode(), 'message' => $Ex->getMessage(), ) ); } if( ! is_array($response) ){ throw new Exception('Ajax action did not return a response'); } // json ok $body = json_encode( $response ); header('Content-Type: application/json; charset=UTF-8', true ); header('Content-Length: '.strlen($body), true ); echo $body; exit(0); } catch( Exception $Ex ){ require dirname(__FILE__).'/loco-fatal.php'; }
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings