text
stringlengths
2
1.03M
<ul class="media-list"> @foreach ($microposts as $micropost) <?php $user = $micropost->user; ?> <li class="media"> <div class="media-left"> <img class="media-object img-rounded" src="{{ Gravatar::src($user->email, 50) }}" alt=""> </div> <div class="media-body"> <div> {!! link_to_route('users.show', $user->name, ['id' => $user->id]) !!} <span class="text-muted">posted at {{ $micropost->created_at }}</span> </div> <div> <p>{!! nl2br(e($micropost->content)) !!}</p> </div> <div> @include('micropost_favorite.favorite_button', ['user' => $user]) @if (Auth::user()->id == $micropost->user_id) {!! Form::open(['route' => ['microposts.destroy', $micropost->id], 'method' => 'delete']) !!} {!! Form::submit('Delete', ['class' => 'btn btn-danger btn-xs']) !!} {!! Form::close() !!} @endif </div> </div> </li> @endforeach </ul> {!! $microposts->render() !!}
<?php use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $model app\models\Subcategoria */ $this->title = 'Update Subcategoria: ' . $model->id; $this->params['breadcrumbs'][] = ['label' => 'Subcategorias', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; $this->params['breadcrumbs'][] = 'Update'; ?> <div class="subcategoria-update"> <h1><?= Html::encode($this->title) ?></h1> <?= $this->render('_form', [ 'model' => $model, ]) ?> </div>
<!DOCTYPE html> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="csrf-token" content="{{ csrf_token() }}"> <title>{{ config('app.name', 'Los Lira') }}</title> <!-- Fonts --> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap"> <link rel="shortcut icon" href="img/Captura.ico"> <!-- Styles --> <link rel="stylesheet" href="{{ mix('css/app.css') }}"> @livewireStyles <!-- Scripts --> <script src="{{ mix('js/app.js') }}" defer></script> </head> <body class="font-sans antialiased"> <x-jet-banner /> <div class="min-h-screen bg-gray-100"> @livewire('navigation-menu') <!-- Page Heading --> @if (isset($header)) <header class="bg-white shadow"> <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8"> {{ $header }} </div> </header> @endif <!-- Page Content --> <main> {{ $slot }} </main> </div> @stack('modals') @livewireScripts <footer class="app-footer"> <center> <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8"> <center>&copy; 2021 <a href="https://github.com/LunarioRebollar" target="_blank">Invernadero Los Lira</a></center> </div> </center> </footer> </body> </html>
<?php /** * Created by PhpStorm. * User: rock * Date: 12/14/16 * Time: 12:24 PM */ class RunSWMSetTicketsDelegate extends AbstractDelegate { protected $type = self::DELEGATE_TYPE_ACTION; /** * @param array $params * @return mixed */ public function run(array $params) { $OrderModel = new OrderModel(); $OrderModel->unserialize($params['object']); $OrdersServices = OrdersServicesRepository::findByIdAndOrderId($OrderModel->getOrderId(), $params['serviceId']); if (is_null($OrdersServices)) { $this->setError(OrdersErrors::SERVICE_NOT_FOUND); return; } if ($OrdersServices->getServiceType() != 2) { $this->setError(OrdersErrors::SET_TICKETS_FOR_AVIA_ONLY); return; } $SWM_FSM = new StateMachine($OrdersServices); if (!$SWM_FSM->can('SERVICESETTICKETS')) { $this->setError(OrdersErrors::SERVICE_STATUS_IS_BLOCKING_ACTION); return null; } $params['orderModel'] = $OrderModel->serialize(); $params['orderId'] = $OrderModel->getOrderId(); $SWMResponse = $SWM_FSM->apply('SERVICESETTICKETS', $params); if ($SWMResponse['status']) { $this->setError($SWMResponse['status']); return; } } }
<!DOCTYPE html> <html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="csrf-token" content="{{ csrf_token() }}"> <title>{{ config('app.name', 'Laravel') }}</title> <!-- Fonts --> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap"> <!-- Styles --> <link rel="stylesheet" href="{{ mix('css/app.css') }}"> @livewireStyles <!-- Scripts --> <script src="{{ mix('js/app.js') }}" defer></script> @stack('scripts') </head> <body class="font-sans antialiased"> <x-jet-banner /> <div class="min-h-screen bg-gray-100"> @livewire('navigation-menu') <!-- Page Heading --> @if (isset($header)) <header class="bg-white shadow"> <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8"> {{ $header }} </div> </header> @endif <!-- Page Content --> <main> {{ $slot }} </main> </div> @stack('modals') @livewireScripts </body> </html>
<?php use yii\helpers\Url; use yii\helpers\Html; use yii\helpers\ArrayHelper; use kartik\grid\GridView; use kartik\export\ExportMenu; use kartik\widgets\Select2; use common\models\entity\Category; /* @var $this yii\web\View */ /* @var $searchModel common\models\search\ProductSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Laporan Stok Barang'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="product-index"> <?php $exportColumns = [ [ 'class' => 'yii\grid\SerialColumn', ], 'id', 'name', 'price', 'desc', 'mainImage', 'category.category:text:Category', 'created_at:datetime', 'createdBy.username:text:Created By', 'updated_at:datetime', 'updatedBy.username:text:Updated By', ]; $exportMenu = ExportMenu::widget([ 'dataProvider' => $dataProvider, 'columns' => $exportColumns, 'filename' => 'Product', 'fontAwesome' => true, 'dropdownOptions' => [ 'label' => 'Export', 'class' => 'btn btn-default' ], 'target' => ExportMenu::TARGET_SELF, 'exportConfig' => [ ExportMenu::FORMAT_CSV => false, ExportMenu::FORMAT_EXCEL => false, ExportMenu::FORMAT_HTML => false, ], 'styleOptions' => [ ExportMenu::FORMAT_EXCEL_X => [ 'font' => [ 'color' => ['argb' => '00000000'], ], 'fill' => [ // 'type' => PHPExcel_Style_Fill::FILL_NONE, 'color' => ['argb' => 'DDDDDDDD'], ], ], ], 'pjaxContainerId' => 'grid', ]); $gridColumns = [ [ 'class' => 'yii\grid\SerialColumn', 'headerOptions' => ['class' => 'text-right serial-column'], 'contentOptions' => ['class' => 'text-right serial-column'], ], // 'id', 'name', [ 'attribute' => 'price', 'format' => 'integer', 'headerOptions' => ['class' => 'text-right'], 'contentOptions' => ['class' => 'text-right'], ], 'stock', [ 'attribute' => 'category_id', 'value' => 'category.category', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Category::find()->orderBy('category')->asArray()->all(), 'id', 'category'), 'filterInputOptions'=>['placeholder'=>''], 'filterWidgetOptions' => [ 'pluginOptions' => ['allowClear'=>true], ], ], // 'created_at:integer', // 'created_by:integer', // 'updated_at:integer', // 'updated_by:integer', ]; ?> <?= GridView::widget([ 'dataProvider' => $dataProvider, 'responsiveWrap' => false, 'pjax' => true, 'hover' => true, 'striped' => false, 'bordered' => false, 'toolbar'=> [ Html::a('<i class="fa fa-repeat"></i> ' . 'Reload', ['index'], ['data-pjax'=>0, 'class'=>'btn btn-default']), '{toggleData}', $exportMenu, ], 'panel' => [ 'type' => 'no-border transparent', 'heading' => false, 'before' => '{summary}', 'after' => false, ], 'panelBeforeTemplate' => ' <div class="row"> <div class="col-sm-8"> <div class="btn-toolbar kv-grid-toolbar" role="toolbar"> {toolbar} </div> </div> <div class="col-sm-4"> <div class="pull-right"> {before} </div> </div> </div> <div class="clearfix"></div> ', 'pjaxSettings' => ['options' => ['id' => 'grid']], 'filterModel' => $searchModel, 'columns' => $gridColumns, ]); ?> </div>
<?php // -------------------------------------------------------------------------------- // PhpConcept Library - Zip Module 2.8.2 // -------------------------------------------------------------------------------- // License GNU/LGPL - Vincent Blavet - August 2009 // http://www.phpconcept.net // -------------------------------------------------------------------------------- // // Presentation : // PclZip is a PHP library that manage ZIP archives. // So far tests show that archives generated by PclZip are readable by // WinZip application and other tools. // // Description : // See readme.txt and http://www.phpconcept.net // // Warning : // This library and the associated files are non commercial, non professional // work. // It should not have unexpected results. However if any damage is caused by // this software the author can not be responsible. // The use of this software is at the risk of the user. // // -------------------------------------------------------------------------------- // $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $ // -------------------------------------------------------------------------------- // ----- Constants if (!defined('PCLZIP_READ_BLOCK_SIZE')) { define( 'PCLZIP_READ_BLOCK_SIZE', 2048 ); } // ----- File list separator // In version 1.x of PclZip, the separator for file list is a space // (which is not a very smart choice, specifically for windows paths !). // A better separator should be a comma (,). This constant gives you the // abilty to change that. // However notice that changing this value, may have impact on existing // scripts, using space separated filenames. // Recommanded values for compatibility with older versions : //define( 'PCLZIP_SEPARATOR', ' ' ); // Recommanded values for smart separation of filenames. if (!defined('PCLZIP_SEPARATOR')) { define( 'PCLZIP_SEPARATOR', ',' ); } // ----- Error configuration // 0 : PclZip Class integrated error handling // 1 : PclError external library error handling. By enabling this // you must ensure that you have included PclError library. // [2,...] : reserved for futur use if (!defined('PCLZIP_ERROR_EXTERNAL')) { define( 'PCLZIP_ERROR_EXTERNAL', 0 ); } // ----- Optional static temporary directory // By default temporary files are generated in the script current // path. // If defined : // - MUST BE terminated by a '/'. // - MUST be a valid, already created directory // Samples : // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' ); // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' ); if (!defined('PCLZIP_TEMPORARY_DIR')) { define( 'PCLZIP_TEMPORARY_DIR', '' ); } // ----- Optional threshold ratio for use of temporary files // Pclzip sense the size of the file to add/extract and decide to // use or not temporary file. The algorythm is looking for // memory_limit of PHP and apply a ratio. // threshold = memory_limit * ratio. // Recommended values are under 0.5. Default 0.47. // Samples : // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 ); if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) { define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 ); } // -------------------------------------------------------------------------------- // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED ***** // -------------------------------------------------------------------------------- // ----- Global variables $g_pclzip_version = "2.8.2"; // ----- Error codes // -1 : Unable to open file in binary write mode // -2 : Unable to open file in binary read mode // -3 : Invalid parameters // -4 : File does not exist // -5 : Filename is too long (max. 255) // -6 : Not a valid zip file // -7 : Invalid extracted file size // -8 : Unable to create directory // -9 : Invalid archive extension // -10 : Invalid archive format // -11 : Unable to delete file (unlink) // -12 : Unable to rename file (rename) // -13 : Invalid header checksum // -14 : Invalid archive size define( 'PCLZIP_ERR_USER_ABORTED', 2 ); define( 'PCLZIP_ERR_NO_ERROR', 0 ); define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 ); define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 ); define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 ); define( 'PCLZIP_ERR_MISSING_FILE', -4 ); define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 ); define( 'PCLZIP_ERR_INVALID_ZIP', -6 ); define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 ); define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 ); define( 'PCLZIP_ERR_BAD_EXTENSION', -9 ); define( 'PCLZIP_ERR_BAD_FORMAT', -10 ); define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 ); define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 ); define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 ); define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 ); define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 ); define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 ); define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 ); define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 ); define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 ); define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 ); define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 ); // ----- Options values define( 'PCLZIP_OPT_PATH', 77001 ); define( 'PCLZIP_OPT_ADD_PATH', 77002 ); define( 'PCLZIP_OPT_REMOVE_PATH', 77003 ); define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 ); define( 'PCLZIP_OPT_SET_CHMOD', 77005 ); define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 ); define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 ); define( 'PCLZIP_OPT_BY_NAME', 77008 ); define( 'PCLZIP_OPT_BY_INDEX', 77009 ); define( 'PCLZIP_OPT_BY_EREG', 77010 ); define( 'PCLZIP_OPT_BY_PREG', 77011 ); define( 'PCLZIP_OPT_COMMENT', 77012 ); define( 'PCLZIP_OPT_ADD_COMMENT', 77013 ); define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 ); define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 ); define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 ); define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 ); // Having big trouble with crypt. Need to multiply 2 long int // which is not correctly supported by PHP ... //define( 'PCLZIP_OPT_CRYPT', 77018 ); define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 ); define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 ); define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 ); define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 ); define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias // ----- File description attributes define( 'PCLZIP_ATT_FILE_NAME', 79001 ); define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 ); define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 ); define( 'PCLZIP_ATT_FILE_MTIME', 79004 ); define( 'PCLZIP_ATT_FILE_CONTENT', 79005 ); define( 'PCLZIP_ATT_FILE_COMMENT', 79006 ); // ----- Call backs values define( 'PCLZIP_CB_PRE_EXTRACT', 78001 ); define( 'PCLZIP_CB_POST_EXTRACT', 78002 ); define( 'PCLZIP_CB_PRE_ADD', 78003 ); define( 'PCLZIP_CB_POST_ADD', 78004 ); /* For futur use define( 'PCLZIP_CB_PRE_LIST', 78005 ); define( 'PCLZIP_CB_POST_LIST', 78006 ); define( 'PCLZIP_CB_PRE_DELETE', 78007 ); define( 'PCLZIP_CB_POST_DELETE', 78008 ); */ // -------------------------------------------------------------------------------- // Class : PclZip // Description : // PclZip is the class that represent a Zip archive. // The public methods allow the manipulation of the archive. // Attributes : // Attributes must not be accessed directly. // Methods : // PclZip() : Object creator // create() : Creates the Zip archive // listContent() : List the content of the Zip archive // extract() : Extract the content of the archive // properties() : List the properties of the archive // -------------------------------------------------------------------------------- class PclZip { // ----- Filename of the zip file var $zipname = ''; // ----- File descriptor of the zip file var $zip_fd = 0; // ----- Internal error handling var $error_code = 1; var $error_string = ''; // ----- Current status of the magic_quotes_runtime // This value store the php configuration for magic_quotes // The class can then disable the magic_quotes and reset it after var $magic_quotes_status; // -------------------------------------------------------------------------------- // Function : PclZip() // Description : // Creates a PclZip object and set the name of the associated Zip archive // filename. // Note that no real action is taken, if the archive does not exist it is not // created. Use create() for that. // -------------------------------------------------------------------------------- function PclZip($p_zipname) { // ----- Tests the zlib if (!function_exists('gzopen')) { die('Abort '.basename(__FILE__).' : Missing zlib extensions'); } // ----- Set the attributes $this->zipname = $p_zipname; $this->zip_fd = 0; $this->magic_quotes_status = -1; // ----- Return return; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : // create($p_filelist, $p_add_dir="", $p_remove_dir="") // create($p_filelist, $p_option, $p_option_value, ...) // Description : // This method supports two different synopsis. The first one is historical. // This method creates a Zip Archive. The Zip file is created in the // filesystem. The files and directories indicated in $p_filelist // are added in the archive. See the parameters description for the // supported format of $p_filelist. // When a directory is in the list, the directory and its content is added // in the archive. // In this synopsis, the function takes an optional variable list of // options. See bellow the supported options. // Parameters : // $p_filelist : An array containing file or directory names, or // a string containing one filename or one directory name, or // a string containing a list of filenames and/or directory // names separated by spaces. // $p_add_dir : A path to add before the real path of the archived file, // in order to have it memorized in the archive. // $p_remove_dir : A path to remove from the real path of the file to archive, // in order to have a shorter path memorized in the archive. // When $p_add_dir and $p_remove_dir are set, $p_remove_dir // is removed first, before $p_add_dir is added. // Options : // PCLZIP_OPT_ADD_PATH : // PCLZIP_OPT_REMOVE_PATH : // PCLZIP_OPT_REMOVE_ALL_PATH : // PCLZIP_OPT_COMMENT : // PCLZIP_CB_PRE_ADD : // PCLZIP_CB_POST_ADD : // Return Values : // 0 on failure, // The list of the added files, with a status of the add action. // (see PclZip::listContent() for list entry format) // -------------------------------------------------------------------------------- function create($p_filelist) { $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Set default values $v_options = array(); $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; // ----- Look for variable options arguments $v_size = func_num_args(); // ----- Look for arguments if ($v_size > 1) { // ----- Get the arguments $v_arg_list = func_get_args(); // ----- Remove from the options list the first argument array_shift($v_arg_list); $v_size--; // ----- Look for first arg if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { // ----- Parse the options $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (PCLZIP_OPT_REMOVE_PATH => 'optional', PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', PCLZIP_OPT_ADD_PATH => 'optional', PCLZIP_CB_PRE_ADD => 'optional', PCLZIP_CB_POST_ADD => 'optional', PCLZIP_OPT_NO_COMPRESSION => 'optional', PCLZIP_OPT_COMMENT => 'optional', PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', PCLZIP_OPT_TEMP_FILE_ON => 'optional', PCLZIP_OPT_TEMP_FILE_OFF => 'optional' //, PCLZIP_OPT_CRYPT => 'optional' )); if ($v_result != 1) { return 0; } } // ----- Look for 2 args // Here we need to support the first historic synopsis of the // method. else { // ----- Get the first argument $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0]; // ----- Look for the optional second argument if ($v_size == 2) { $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; } else if ($v_size > 2) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); return 0; } } } // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); // ----- Init $v_string_list = array(); $v_att_list = array(); $v_filedescr_list = array(); $p_result_list = array(); // ----- Look if the $p_filelist is really an array if (is_array($p_filelist)) { // ----- Look if the first element is also an array // This will mean that this is a file description entry if (isset($p_filelist[0]) && is_array($p_filelist[0])) { $v_att_list = $p_filelist; } // ----- The list is a list of string names else { $v_string_list = $p_filelist; } } // ----- Look if the $p_filelist is a string else if (is_string($p_filelist)) { // ----- Create a list from the string $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); } // ----- Invalid variable type for $p_filelist else { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist"); return 0; } // ----- Reformat the string list if (sizeof($v_string_list) != 0) { foreach ($v_string_list as $v_string) { if ($v_string != '') { $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; } else { } } } // ----- For each file in the list check the attributes $v_supported_attributes = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' ,PCLZIP_ATT_FILE_MTIME => 'optional' ,PCLZIP_ATT_FILE_CONTENT => 'optional' ,PCLZIP_ATT_FILE_COMMENT => 'optional' ); foreach ($v_att_list as $v_entry) { $v_result = $this->privFileDescrParseAtt($v_entry, $v_filedescr_list[], $v_options, $v_supported_attributes); if ($v_result != 1) { return 0; } } // ----- Expand the filelist (expand directories) $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); if ($v_result != 1) { return 0; } // ----- Call the create fct $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options); if ($v_result != 1) { return 0; } // ----- Return return $p_result_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : // add($p_filelist, $p_add_dir="", $p_remove_dir="") // add($p_filelist, $p_option, $p_option_value, ...) // Description : // This method supports two synopsis. The first one is historical. // This methods add the list of files in an existing archive. // If a file with the same name already exists, it is added at the end of the // archive, the first one is still present. // If the archive does not exist, it is created. // Parameters : // $p_filelist : An array containing file or directory names, or // a string containing one filename or one directory name, or // a string containing a list of filenames and/or directory // names separated by spaces. // $p_add_dir : A path to add before the real path of the archived file, // in order to have it memorized in the archive. // $p_remove_dir : A path to remove from the real path of the file to archive, // in order to have a shorter path memorized in the archive. // When $p_add_dir and $p_remove_dir are set, $p_remove_dir // is removed first, before $p_add_dir is added. // Options : // PCLZIP_OPT_ADD_PATH : // PCLZIP_OPT_REMOVE_PATH : // PCLZIP_OPT_REMOVE_ALL_PATH : // PCLZIP_OPT_COMMENT : // PCLZIP_OPT_ADD_COMMENT : // PCLZIP_OPT_PREPEND_COMMENT : // PCLZIP_CB_PRE_ADD : // PCLZIP_CB_POST_ADD : // Return Values : // 0 on failure, // The list of the added files, with a status of the add action. // (see PclZip::listContent() for list entry format) // -------------------------------------------------------------------------------- function add($p_filelist) { $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Set default values $v_options = array(); $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE; // ----- Look for variable options arguments $v_size = func_num_args(); // ----- Look for arguments if ($v_size > 1) { // ----- Get the arguments $v_arg_list = func_get_args(); // ----- Remove form the options list the first argument array_shift($v_arg_list); $v_size--; // ----- Look for first arg if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { // ----- Parse the options $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (PCLZIP_OPT_REMOVE_PATH => 'optional', PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', PCLZIP_OPT_ADD_PATH => 'optional', PCLZIP_CB_PRE_ADD => 'optional', PCLZIP_CB_POST_ADD => 'optional', PCLZIP_OPT_NO_COMPRESSION => 'optional', PCLZIP_OPT_COMMENT => 'optional', PCLZIP_OPT_ADD_COMMENT => 'optional', PCLZIP_OPT_PREPEND_COMMENT => 'optional', PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', PCLZIP_OPT_TEMP_FILE_ON => 'optional', PCLZIP_OPT_TEMP_FILE_OFF => 'optional' //, PCLZIP_OPT_CRYPT => 'optional' )); if ($v_result != 1) { return 0; } } // ----- Look for 2 args // Here we need to support the first historic synopsis of the // method. else { // ----- Get the first argument $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0]; // ----- Look for the optional second argument if ($v_size == 2) { $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1]; } else if ($v_size > 2) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); // ----- Return return 0; } } } // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); // ----- Init $v_string_list = array(); $v_att_list = array(); $v_filedescr_list = array(); $p_result_list = array(); // ----- Look if the $p_filelist is really an array if (is_array($p_filelist)) { // ----- Look if the first element is also an array // This will mean that this is a file description entry if (isset($p_filelist[0]) && is_array($p_filelist[0])) { $v_att_list = $p_filelist; } // ----- The list is a list of string names else { $v_string_list = $p_filelist; } } // ----- Look if the $p_filelist is a string else if (is_string($p_filelist)) { // ----- Create a list from the string $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist); } // ----- Invalid variable type for $p_filelist else { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist"); return 0; } // ----- Reformat the string list if (sizeof($v_string_list) != 0) { foreach ($v_string_list as $v_string) { $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string; } } // ----- For each file in the list check the attributes $v_supported_attributes = array ( PCLZIP_ATT_FILE_NAME => 'mandatory' ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional' ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional' ,PCLZIP_ATT_FILE_MTIME => 'optional' ,PCLZIP_ATT_FILE_CONTENT => 'optional' ,PCLZIP_ATT_FILE_COMMENT => 'optional' ); foreach ($v_att_list as $v_entry) { $v_result = $this->privFileDescrParseAtt($v_entry, $v_filedescr_list[], $v_options, $v_supported_attributes); if ($v_result != 1) { return 0; } } // ----- Expand the filelist (expand directories) $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options); if ($v_result != 1) { return 0; } // ----- Call the create fct $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options); if ($v_result != 1) { return 0; } // ----- Return return $p_result_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : listContent() // Description : // This public method, gives the list of the files and directories, with their // properties. // The properties of each entries in the list are (used also in other functions) : // filename : Name of the file. For a create or add action it is the filename // given by the user. For an extract function it is the filename // of the extracted file. // stored_filename : Name of the file / directory stored in the archive. // size : Size of the stored file. // compressed_size : Size of the file's data compressed in the archive // (without the headers overhead) // mtime : Last known modification date of the file (UNIX timestamp) // comment : Comment associated with the file // folder : true | false // index : index of the file in the archive // status : status of the action (depending of the action) : // Values are : // ok : OK ! // filtered : the file / dir is not extracted (filtered by user) // already_a_directory : the file can not be extracted because a // directory with the same name already exists // write_protected : the file can not be extracted because a file // with the same name already exists and is // write protected // newer_exist : the file was not extracted because a newer file exists // path_creation_fail : the file is not extracted because the folder // does not exist and can not be created // write_error : the file was not extracted because there was a // error while writing the file // read_error : the file was not extracted because there was a error // while reading the file // invalid_header : the file was not extracted because of an archive // format error (bad file header) // Note that each time a method can continue operating when there // is an action error on a file, the error is only logged in the file status. // Return Values : // 0 on an unrecoverable failure, // The list of the files in the archive. // -------------------------------------------------------------------------------- function listContent() { $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Check archive if (!$this->privCheckFormat()) { return(0); } // ----- Call the extracting fct $p_list = array(); if (($v_result = $this->privList($p_list)) != 1) { unset($p_list); return(0); } // ----- Return return $p_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : // extract($p_path="./", $p_remove_path="") // extract([$p_option, $p_option_value, ...]) // Description : // This method supports two synopsis. The first one is historical. // This method extract all the files / directories from the archive to the // folder indicated in $p_path. // If you want to ignore the 'root' part of path of the memorized files // you can indicate this in the optional $p_remove_path parameter. // By default, if a newer file with the same name already exists, the // file is not extracted. // // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append // at the end of the path value of PCLZIP_OPT_PATH. // Parameters : // $p_path : Path where the files and directories are to be extracted // $p_remove_path : First part ('root' part) of the memorized path // (if any similar) to remove while extracting. // Options : // PCLZIP_OPT_PATH : // PCLZIP_OPT_ADD_PATH : // PCLZIP_OPT_REMOVE_PATH : // PCLZIP_OPT_REMOVE_ALL_PATH : // PCLZIP_CB_PRE_EXTRACT : // PCLZIP_CB_POST_EXTRACT : // Return Values : // 0 or a negative value on failure, // The list of the extracted files, with a status of the action. // (see PclZip::listContent() for list entry format) // -------------------------------------------------------------------------------- function extract() { $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Check archive if (!$this->privCheckFormat()) { return(0); } // ----- Set default values $v_options = array(); // $v_path = "./"; $v_path = ''; $v_remove_path = ""; $v_remove_all_path = false; // ----- Look for variable options arguments $v_size = func_num_args(); // ----- Default values for option $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; // ----- Look for arguments if ($v_size > 0) { // ----- Get the arguments $v_arg_list = func_get_args(); // ----- Look for first arg if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { // ----- Parse the options $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (PCLZIP_OPT_PATH => 'optional', PCLZIP_OPT_REMOVE_PATH => 'optional', PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', PCLZIP_OPT_ADD_PATH => 'optional', PCLZIP_CB_PRE_EXTRACT => 'optional', PCLZIP_CB_POST_EXTRACT => 'optional', PCLZIP_OPT_SET_CHMOD => 'optional', PCLZIP_OPT_BY_NAME => 'optional', PCLZIP_OPT_BY_EREG => 'optional', PCLZIP_OPT_BY_PREG => 'optional', PCLZIP_OPT_BY_INDEX => 'optional', PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional', PCLZIP_OPT_REPLACE_NEWER => 'optional' ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', PCLZIP_OPT_TEMP_FILE_ON => 'optional', PCLZIP_OPT_TEMP_FILE_OFF => 'optional' )); if ($v_result != 1) { return 0; } // ----- Set the arguments if (isset($v_options[PCLZIP_OPT_PATH])) { $v_path = $v_options[PCLZIP_OPT_PATH]; } if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; } if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; } if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { // ----- Check for '/' in last path char if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { $v_path .= '/'; } $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; } } // ----- Look for 2 args // Here we need to support the first historic synopsis of the // method. else { // ----- Get the first argument $v_path = $v_arg_list[0]; // ----- Look for the optional second argument if ($v_size == 2) { $v_remove_path = $v_arg_list[1]; } else if ($v_size > 2) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); // ----- Return return 0; } } } // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); // ----- Trace // ----- Call the extracting fct $p_list = array(); $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options); if ($v_result < 1) { unset($p_list); return(0); } // ----- Return return $p_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : // extractByIndex($p_index, $p_path="./", $p_remove_path="") // extractByIndex($p_index, [$p_option, $p_option_value, ...]) // Description : // This method supports two synopsis. The first one is historical. // This method is doing a partial extract of the archive. // The extracted files or folders are identified by their index in the // archive (from 0 to n). // Note that if the index identify a folder, only the folder entry is // extracted, not all the files included in the archive. // Parameters : // $p_index : A single index (integer) or a string of indexes of files to // extract. The form of the string is "0,4-6,8-12" with only numbers // and '-' for range or ',' to separate ranges. No spaces or ';' // are allowed. // $p_path : Path where the files and directories are to be extracted // $p_remove_path : First part ('root' part) of the memorized path // (if any similar) to remove while extracting. // Options : // PCLZIP_OPT_PATH : // PCLZIP_OPT_ADD_PATH : // PCLZIP_OPT_REMOVE_PATH : // PCLZIP_OPT_REMOVE_ALL_PATH : // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and // not as files. // The resulting content is in a new field 'content' in the file // structure. // This option must be used alone (any other options are ignored). // PCLZIP_CB_PRE_EXTRACT : // PCLZIP_CB_POST_EXTRACT : // Return Values : // 0 on failure, // The list of the extracted files, with a status of the action. // (see PclZip::listContent() for list entry format) // -------------------------------------------------------------------------------- //function extractByIndex($p_index, options...) function extractByIndex($p_index) { $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Check archive if (!$this->privCheckFormat()) { return(0); } // ----- Set default values $v_options = array(); // $v_path = "./"; $v_path = ''; $v_remove_path = ""; $v_remove_all_path = false; // ----- Look for variable options arguments $v_size = func_num_args(); // ----- Default values for option $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; // ----- Look for arguments if ($v_size > 1) { // ----- Get the arguments $v_arg_list = func_get_args(); // ----- Remove form the options list the first argument array_shift($v_arg_list); $v_size--; // ----- Look for first arg if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) { // ----- Parse the options $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (PCLZIP_OPT_PATH => 'optional', PCLZIP_OPT_REMOVE_PATH => 'optional', PCLZIP_OPT_REMOVE_ALL_PATH => 'optional', PCLZIP_OPT_EXTRACT_AS_STRING => 'optional', PCLZIP_OPT_ADD_PATH => 'optional', PCLZIP_CB_PRE_EXTRACT => 'optional', PCLZIP_CB_POST_EXTRACT => 'optional', PCLZIP_OPT_SET_CHMOD => 'optional', PCLZIP_OPT_REPLACE_NEWER => 'optional' ,PCLZIP_OPT_STOP_ON_ERROR => 'optional' ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional', PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional', PCLZIP_OPT_TEMP_FILE_ON => 'optional', PCLZIP_OPT_TEMP_FILE_OFF => 'optional' )); if ($v_result != 1) { return 0; } // ----- Set the arguments if (isset($v_options[PCLZIP_OPT_PATH])) { $v_path = $v_options[PCLZIP_OPT_PATH]; } if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) { $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH]; } if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH]; } if (isset($v_options[PCLZIP_OPT_ADD_PATH])) { // ----- Check for '/' in last path char if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) { $v_path .= '/'; } $v_path .= $v_options[PCLZIP_OPT_ADD_PATH]; } if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) { $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE; } else { } } // ----- Look for 2 args // Here we need to support the first historic synopsis of the // method. else { // ----- Get the first argument $v_path = $v_arg_list[0]; // ----- Look for the optional second argument if ($v_size == 2) { $v_remove_path = $v_arg_list[1]; } else if ($v_size > 2) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments"); // ----- Return return 0; } } } // ----- Trace // ----- Trick // Here I want to reuse extractByRule(), so I need to parse the $p_index // with privParseOptions() $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index); $v_options_trick = array(); $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, array (PCLZIP_OPT_BY_INDEX => 'optional' )); if ($v_result != 1) { return 0; } $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX]; // ----- Look for default option values $this->privOptionDefaultThreshold($v_options); // ----- Call the extracting fct if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) { return(0); } // ----- Return return $p_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : // delete([$p_option, $p_option_value, ...]) // Description : // This method removes files from the archive. // If no parameters are given, then all the archive is emptied. // Parameters : // None or optional arguments. // Options : // PCLZIP_OPT_BY_INDEX : // PCLZIP_OPT_BY_NAME : // PCLZIP_OPT_BY_EREG : // PCLZIP_OPT_BY_PREG : // Return Values : // 0 on failure, // The list of the files which are still present in the archive. // (see PclZip::listContent() for list entry format) // -------------------------------------------------------------------------------- function delete() { $v_result=1; // ----- Reset the error handler $this->privErrorReset(); // ----- Check archive if (!$this->privCheckFormat()) { return(0); } // ----- Set default values $v_options = array(); // ----- Look for variable options arguments $v_size = func_num_args(); // ----- Look for arguments if ($v_size > 0) { // ----- Get the arguments $v_arg_list = func_get_args(); // ----- Parse the options $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array (PCLZIP_OPT_BY_NAME => 'optional', PCLZIP_OPT_BY_EREG => 'optional', PCLZIP_OPT_BY_PREG => 'optional', PCLZIP_OPT_BY_INDEX => 'optional' )); if ($v_result != 1) { return 0; } } // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Call the delete fct $v_list = array(); if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) { $this->privSwapBackMagicQuotes(); unset($v_list); return(0); } // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Return return $v_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : deleteByIndex() // Description : // ***** Deprecated ***** // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered. // -------------------------------------------------------------------------------- function deleteByIndex($p_index) { $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index); // ----- Return return $p_list; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : properties() // Description : // This method gives the properties of the archive. // The properties are : // nb : Number of files in the archive // comment : Comment associated with the archive file // status : not_exist, ok // Parameters : // None // Return Values : // 0 on failure, // An array with the archive properties. // -------------------------------------------------------------------------------- function properties() { // ----- Reset the error handler $this->privErrorReset(); // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Check archive if (!$this->privCheckFormat()) { $this->privSwapBackMagicQuotes(); return(0); } // ----- Default properties $v_prop = array(); $v_prop['comment'] = ''; $v_prop['nb'] = 0; $v_prop['status'] = 'not_exist'; // ----- Look if file exists if (@is_file($this->zipname)) { // ----- Open the zip file if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) { $this->privSwapBackMagicQuotes(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); // ----- Return return 0; } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privSwapBackMagicQuotes(); return 0; } // ----- Close the zip file $this->privCloseFd(); // ----- Set the user attributes $v_prop['comment'] = $v_central_dir['comment']; $v_prop['nb'] = $v_central_dir['entries']; $v_prop['status'] = 'ok'; } // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Return return $v_prop; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : duplicate() // Description : // This method creates an archive by copying the content of an other one. If // the archive already exist, it is replaced by the new one without any warning. // Parameters : // $p_archive : The filename of a valid archive, or // a valid PclZip object. // Return Values : // 1 on success. // 0 or a negative value on error (error code). // -------------------------------------------------------------------------------- function duplicate($p_archive) { $v_result = 1; // ----- Reset the error handler $this->privErrorReset(); // ----- Look if the $p_archive is a PclZip object if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) { // ----- Duplicate the archive $v_result = $this->privDuplicate($p_archive->zipname); } // ----- Look if the $p_archive is a string (so a filename) else if (is_string($p_archive)) { // ----- Check that $p_archive is a valid zip file // TBC : Should also check the archive format if (!is_file($p_archive)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'"); $v_result = PCLZIP_ERR_MISSING_FILE; } else { // ----- Duplicate the archive $v_result = $this->privDuplicate($p_archive); } } // ----- Invalid variable else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); $v_result = PCLZIP_ERR_INVALID_PARAMETER; } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : merge() // Description : // This method merge the $p_archive_to_add archive at the end of the current // one ($this). // If the archive ($this) does not exist, the merge becomes a duplicate. // If the $p_archive_to_add archive does not exist, the merge is a success. // Parameters : // $p_archive_to_add : It can be directly the filename of a valid zip archive, // or a PclZip object archive. // Return Values : // 1 on success, // 0 or negative values on error (see below). // -------------------------------------------------------------------------------- function merge($p_archive_to_add) { $v_result = 1; // ----- Reset the error handler $this->privErrorReset(); // ----- Check archive if (!$this->privCheckFormat()) { return(0); } // ----- Look if the $p_archive_to_add is a PclZip object if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) { // ----- Merge the archive $v_result = $this->privMerge($p_archive_to_add); } // ----- Look if the $p_archive_to_add is a string (so a filename) else if (is_string($p_archive_to_add)) { // ----- Create a temporary archive $v_object_archive = new PclZip($p_archive_to_add); // ----- Merge the archive $v_result = $this->privMerge($v_object_archive); } // ----- Invalid variable else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add"); $v_result = PCLZIP_ERR_INVALID_PARAMETER; } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : errorCode() // Description : // Parameters : // -------------------------------------------------------------------------------- function errorCode() { if (PCLZIP_ERROR_EXTERNAL == 1) { return(PclErrorCode()); } else { return($this->error_code); } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : errorName() // Description : // Parameters : // -------------------------------------------------------------------------------- function errorName($p_with_code=false) { $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR', PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL', PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL', PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER', PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE', PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG', PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP', PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE', PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL', PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION', PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT', PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL', PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL', PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM', PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE', PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE', PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE' ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION' ); if (isset($v_name[$this->error_code])) { $v_value = $v_name[$this->error_code]; } else { $v_value = 'NoName'; } if ($p_with_code) { return($v_value.' ('.$this->error_code.')'); } else { return($v_value); } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : errorInfo() // Description : // Parameters : // -------------------------------------------------------------------------------- function errorInfo($p_full=false) { if (PCLZIP_ERROR_EXTERNAL == 1) { return(PclErrorString()); } else { if ($p_full) { return($this->errorName(true)." : ".$this->error_string); } else { return($this->error_string." [code ".$this->error_code."]"); } } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS ***** // ***** ***** // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY ***** // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privCheckFormat() // Description : // This method check that the archive exists and is a valid zip archive. // Several level of check exists. (futur) // Parameters : // $p_level : Level of check. Default 0. // 0 : Check the first bytes (magic codes) (default value)) // 1 : 0 + Check the central directory (futur) // 2 : 1 + Check each file header (futur) // Return Values : // true on success, // false on error, the error code is set. // -------------------------------------------------------------------------------- function privCheckFormat($p_level=0) { $v_result = true; // ----- Reset the file system cache clearstatcache(); // ----- Reset the error handler $this->privErrorReset(); // ----- Look if the file exits if (!is_file($this->zipname)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'"); return(false); } // ----- Check that the file is readeable if (!is_readable($this->zipname)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'"); return(false); } // ----- Check the magic code // TBC // ----- Check the central header // TBC // ----- Check each file header // TBC // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privParseOptions() // Description : // This internal methods reads the variable list of arguments ($p_options_list, // $p_size) and generate an array with the options and values ($v_result_list). // $v_requested_options contains the options that can be present and those that // must be present. // $v_requested_options is an array, with the option value as key, and 'optional', // or 'mandatory' as value. // Parameters : // See above. // Return Values : // 1 on success. // 0 on failure. // -------------------------------------------------------------------------------- function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false) { $v_result=1; // ----- Read the options $i=0; while ($i<$p_size) { // ----- Check if the option is supported if (!isset($v_requested_options[$p_options_list[$i]])) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method"); // ----- Return return PclZip::errorCode(); } // ----- Look for next option switch ($p_options_list[$i]) { // ----- Look for options that request a path value case PCLZIP_OPT_PATH : case PCLZIP_OPT_REMOVE_PATH : case PCLZIP_OPT_ADD_PATH : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } // ----- Get the value $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); $i++; break; case PCLZIP_OPT_TEMP_FILE_THRESHOLD : // ----- Check the number of parameters if (($i+1) >= $p_size) { PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); return PclZip::errorCode(); } // ----- Check for incompatible options if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); return PclZip::errorCode(); } // ----- Check the value $v_value = $p_options_list[$i+1]; if ((!is_integer($v_value)) || ($v_value<0)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'"); return PclZip::errorCode(); } // ----- Get the value (and convert it in bytes) $v_result_list[$p_options_list[$i]] = $v_value*1048576; $i++; break; case PCLZIP_OPT_TEMP_FILE_ON : // ----- Check for incompatible options if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'"); return PclZip::errorCode(); } $v_result_list[$p_options_list[$i]] = true; break; case PCLZIP_OPT_TEMP_FILE_OFF : // ----- Check for incompatible options if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'"); return PclZip::errorCode(); } // ----- Check for incompatible options if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'"); return PclZip::errorCode(); } $v_result_list[$p_options_list[$i]] = true; break; case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } // ----- Get the value if ( is_string($p_options_list[$i+1]) && ($p_options_list[$i+1] != '')) { $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE); $i++; } else { } break; // ----- Look for options that request an array of string for value case PCLZIP_OPT_BY_NAME : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } // ----- Get the value if (is_string($p_options_list[$i+1])) { $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1]; } else if (is_array($p_options_list[$i+1])) { $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; } else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } $i++; break; // ----- Look for options that request an EREG or PREG expression case PCLZIP_OPT_BY_EREG : // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG // to PCLZIP_OPT_BY_PREG $p_options_list[$i] = PCLZIP_OPT_BY_PREG; case PCLZIP_OPT_BY_PREG : //case PCLZIP_OPT_CRYPT : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } // ----- Get the value if (is_string($p_options_list[$i+1])) { $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; } else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } $i++; break; // ----- Look for options that takes a string case PCLZIP_OPT_COMMENT : case PCLZIP_OPT_ADD_COMMENT : case PCLZIP_OPT_PREPEND_COMMENT : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" .PclZipUtilOptionText($p_options_list[$i]) ."'"); // ----- Return return PclZip::errorCode(); } // ----- Get the value if (is_string($p_options_list[$i+1])) { $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; } else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '" .PclZipUtilOptionText($p_options_list[$i]) ."'"); // ----- Return return PclZip::errorCode(); } $i++; break; // ----- Look for options that request an array of index case PCLZIP_OPT_BY_INDEX : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } // ----- Get the value $v_work_list = array(); if (is_string($p_options_list[$i+1])) { // ----- Remove spaces $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', ''); // ----- Parse items $v_work_list = explode(",", $p_options_list[$i+1]); } else if (is_integer($p_options_list[$i+1])) { $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1]; } else if (is_array($p_options_list[$i+1])) { $v_work_list = $p_options_list[$i+1]; } else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } // ----- Reduce the index list // each index item in the list must be a couple with a start and // an end value : [0,3], [5-5], [8-10], ... // ----- Check the format of each item $v_sort_flag=false; $v_sort_value=0; for ($j=0; $j<sizeof($v_work_list); $j++) { // ----- Explode the item $v_item_list = explode("-", $v_work_list[$j]); $v_size_item_list = sizeof($v_item_list); // ----- TBC : Here we might check that each item is a // real integer ... // ----- Look for single value if ($v_size_item_list == 1) { // ----- Set the option value $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0]; } elseif ($v_size_item_list == 2) { // ----- Set the option value $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0]; $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1]; } else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } // ----- Look for list sort if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) { $v_sort_flag=true; // ----- TBC : An automatic sort should be writen ... // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start']; } // ----- Sort the items if ($v_sort_flag) { // TBC : To Be Completed } // ----- Next option $i++; break; // ----- Look for options that request no value case PCLZIP_OPT_REMOVE_ALL_PATH : case PCLZIP_OPT_EXTRACT_AS_STRING : case PCLZIP_OPT_NO_COMPRESSION : case PCLZIP_OPT_EXTRACT_IN_OUTPUT : case PCLZIP_OPT_REPLACE_NEWER : case PCLZIP_OPT_STOP_ON_ERROR : $v_result_list[$p_options_list[$i]] = true; break; // ----- Look for options that request an octal value case PCLZIP_OPT_SET_CHMOD : // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } // ----- Get the value $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1]; $i++; break; // ----- Look for options that request a call-back case PCLZIP_CB_PRE_EXTRACT : case PCLZIP_CB_POST_EXTRACT : case PCLZIP_CB_PRE_ADD : case PCLZIP_CB_POST_ADD : /* for futur use case PCLZIP_CB_PRE_DELETE : case PCLZIP_CB_POST_DELETE : case PCLZIP_CB_PRE_LIST : case PCLZIP_CB_POST_LIST : */ // ----- Check the number of parameters if (($i+1) >= $p_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } // ----- Get the value $v_function_name = $p_options_list[$i+1]; // ----- Check that the value is a valid existing function if (!function_exists($v_function_name)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'"); // ----- Return return PclZip::errorCode(); } // ----- Set the attribute $v_result_list[$p_options_list[$i]] = $v_function_name; $i++; break; default : // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown parameter '" .$p_options_list[$i]."'"); // ----- Return return PclZip::errorCode(); } // ----- Next options $i++; } // ----- Look for mandatory options if ($v_requested_options !== false) { for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { // ----- Look for mandatory option if ($v_requested_options[$key] == 'mandatory') { // ----- Look if present if (!isset($v_result_list[$key])) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); // ----- Return return PclZip::errorCode(); } } } } // ----- Look for default values if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) { } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privOptionDefaultThreshold() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privOptionDefaultThreshold(&$p_options) { $v_result=1; if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) { return $v_result; } // ----- Get 'memory_limit' configuration value $v_memory_limit = ini_get('memory_limit'); $v_memory_limit = trim($v_memory_limit); $last = strtolower(substr($v_memory_limit, -1)); if($last == 'g') //$v_memory_limit = $v_memory_limit*1024*1024*1024; $v_memory_limit = $v_memory_limit*1073741824; if($last == 'm') //$v_memory_limit = $v_memory_limit*1024*1024; $v_memory_limit = $v_memory_limit*1048576; if($last == 'k') $v_memory_limit = $v_memory_limit*1024; $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); // ----- Sanity check : No threshold if value lower than 1M if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) { unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]); } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privFileDescrParseAtt() // Description : // Parameters : // Return Values : // 1 on success. // 0 on failure. // -------------------------------------------------------------------------------- function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false) { $v_result=1; // ----- For each file in the list check the attributes foreach ($p_file_list as $v_key => $v_value) { // ----- Check if the option is supported if (!isset($v_requested_options[$v_key])) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file"); // ----- Return return PclZip::errorCode(); } // ----- Look for attribute switch ($v_key) { case PCLZIP_ATT_FILE_NAME : if (!is_string($v_value)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); return PclZip::errorCode(); } $p_filedescr['filename'] = PclZipUtilPathReduction($v_value); if ($p_filedescr['filename'] == '') { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'"); return PclZip::errorCode(); } break; case PCLZIP_ATT_FILE_NEW_SHORT_NAME : if (!is_string($v_value)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); return PclZip::errorCode(); } $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value); if ($p_filedescr['new_short_name'] == '') { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'"); return PclZip::errorCode(); } break; case PCLZIP_ATT_FILE_NEW_FULL_NAME : if (!is_string($v_value)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); return PclZip::errorCode(); } $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value); if ($p_filedescr['new_full_name'] == '') { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'"); return PclZip::errorCode(); } break; // ----- Look for options that takes a string case PCLZIP_ATT_FILE_COMMENT : if (!is_string($v_value)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'"); return PclZip::errorCode(); } $p_filedescr['comment'] = $v_value; break; case PCLZIP_ATT_FILE_MTIME : if (!is_integer($v_value)) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'"); return PclZip::errorCode(); } $p_filedescr['mtime'] = $v_value; break; case PCLZIP_ATT_FILE_CONTENT : $p_filedescr['content'] = $v_value; break; default : // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown parameter '".$v_key."'"); // ----- Return return PclZip::errorCode(); } // ----- Look for mandatory options if ($v_requested_options !== false) { for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) { // ----- Look for mandatory option if ($v_requested_options[$key] == 'mandatory') { // ----- Look if present if (!isset($p_file_list[$key])) { PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")"); return PclZip::errorCode(); } } } } // end foreach } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privFileDescrExpand() // Description : // This method look for each item of the list to see if its a file, a folder // or a string to be added as file. For any other type of files (link, other) // just ignore the item. // Then prepare the information that will be stored for that file. // When its a folder, expand the folder with all the files that are in that // folder (recursively). // Parameters : // Return Values : // 1 on success. // 0 on failure. // -------------------------------------------------------------------------------- function privFileDescrExpand(&$p_filedescr_list, &$p_options) { $v_result=1; // ----- Create a result list $v_result_list = array(); // ----- Look each entry for ($i=0; $i<sizeof($p_filedescr_list); $i++) { // ----- Get filedescr $v_descr = $p_filedescr_list[$i]; // ----- Reduce the filename $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false); $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']); // ----- Look for real file or folder if (file_exists($v_descr['filename'])) { if (@is_file($v_descr['filename'])) { $v_descr['type'] = 'file'; } else if (@is_dir($v_descr['filename'])) { $v_descr['type'] = 'folder'; } else if (@is_link($v_descr['filename'])) { // skip continue; } else { // skip continue; } } // ----- Look for string added as file else if (isset($v_descr['content'])) { $v_descr['type'] = 'virtual_file'; } // ----- Missing file else { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist"); // ----- Return return PclZip::errorCode(); } // ----- Calculate the stored filename $this->privCalculateStoredFilename($v_descr, $p_options); // ----- Add the descriptor in result list $v_result_list[sizeof($v_result_list)] = $v_descr; // ----- Look for folder if ($v_descr['type'] == 'folder') { // ----- List of items in folder $v_dirlist_descr = array(); $v_dirlist_nb = 0; if ($v_folder_handler = @opendir($v_descr['filename'])) { while (($v_item_handler = @readdir($v_folder_handler)) !== false) { // ----- Skip '.' and '..' if (($v_item_handler == '.') || ($v_item_handler == '..')) { continue; } // ----- Compose the full filename $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler; // ----- Look for different stored filename // Because the name of the folder was changed, the name of the // files/sub-folders also change if (($v_descr['stored_filename'] != $v_descr['filename']) && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) { if ($v_descr['stored_filename'] != '') { $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler; } else { $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler; } } $v_dirlist_nb++; } @closedir($v_folder_handler); } else { // TBC : unable to open folder in read mode } // ----- Expand each element of the list if ($v_dirlist_nb != 0) { // ----- Expand if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) { return $v_result; } // ----- Concat the resulting list $v_result_list = array_merge($v_result_list, $v_dirlist_descr); } else { } // ----- Free local array unset($v_dirlist_descr); } } // ----- Get the result list $p_filedescr_list = $v_result_list; // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privCreate() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privCreate($p_filedescr_list, &$p_result_list, &$p_options) { $v_result=1; $v_list_detail = array(); // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Open the file in write mode if (($v_result = $this->privOpenFd('wb')) != 1) { // ----- Return return $v_result; } // ----- Add the list of files $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options); // ----- Close $this->privCloseFd(); // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privAdd() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privAdd($p_filedescr_list, &$p_result_list, &$p_options) { $v_result=1; $v_list_detail = array(); // ----- Look if the archive exists or is empty if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) { // ----- Do a create $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options); // ----- Return return $v_result; } // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Open the zip file if (($v_result=$this->privOpenFd('rb')) != 1) { // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Return return $v_result; } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); return $v_result; } // ----- Go to beginning of File @rewind($this->zip_fd); // ----- Creates a temporay file $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; // ----- Open the temporary file in write mode if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); // ----- Return return PclZip::errorCode(); } // ----- Copy the files from the archive to the temporary file // TBC : Here I should better append the file and go back to erase the central dir $v_size = $v_central_dir['offset']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = fread($this->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Swap the file descriptor // Here is a trick : I swap the temporary fd with the zip fd, in order to use // the following methods on the temporary fil and not the real archive $v_swap = $this->zip_fd; $this->zip_fd = $v_zip_temp_fd; $v_zip_temp_fd = $v_swap; // ----- Add the files $v_header_list = array(); if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) { fclose($v_zip_temp_fd); $this->privCloseFd(); @unlink($v_zip_temp_name); $this->privSwapBackMagicQuotes(); // ----- Return return $v_result; } // ----- Store the offset of the central dir $v_offset = @ftell($this->zip_fd); // ----- Copy the block of file headers from the old archive $v_size = $v_central_dir['size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($v_zip_temp_fd, $v_read_size); @fwrite($this->zip_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Create the Central Dir files header for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) { // ----- Create the file header if ($v_header_list[$i]['status'] == 'ok') { if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { fclose($v_zip_temp_fd); $this->privCloseFd(); @unlink($v_zip_temp_name); $this->privSwapBackMagicQuotes(); // ----- Return return $v_result; } $v_count++; } // ----- Transform the header to a 'usable' info $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); } // ----- Zip file comment $v_comment = $v_central_dir['comment']; if (isset($p_options[PCLZIP_OPT_COMMENT])) { $v_comment = $p_options[PCLZIP_OPT_COMMENT]; } if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) { $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT]; } if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) { $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment; } // ----- Calculate the size of the central header $v_size = @ftell($this->zip_fd)-$v_offset; // ----- Create the central dir footer if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) { // ----- Reset the file list unset($v_header_list); $this->privSwapBackMagicQuotes(); // ----- Return return $v_result; } // ----- Swap back the file descriptor $v_swap = $this->zip_fd; $this->zip_fd = $v_zip_temp_fd; $v_zip_temp_fd = $v_swap; // ----- Close $this->privCloseFd(); // ----- Close the temporary file @fclose($v_zip_temp_fd); // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Delete the zip file // TBC : I should test the result ... @unlink($this->zipname); // ----- Rename the temporary file // TBC : I should test the result ... //@rename($v_zip_temp_name, $this->zipname); PclZipUtilRename($v_zip_temp_name, $this->zipname); // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privOpenFd() // Description : // Parameters : // -------------------------------------------------------------------------------- function privOpenFd($p_mode) { $v_result=1; // ----- Look if already open if ($this->zip_fd != 0) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open'); // ----- Return return PclZip::errorCode(); } // ----- Open the zip file if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode'); // ----- Return return PclZip::errorCode(); } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privCloseFd() // Description : // Parameters : // -------------------------------------------------------------------------------- function privCloseFd() { $v_result=1; if ($this->zip_fd != 0) @fclose($this->zip_fd); $this->zip_fd = 0; // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privAddList() // Description : // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is // different from the real path of the file. This is usefull if you want to have PclTar // running in any directory, and memorize relative path from an other directory. // Parameters : // $p_list : An array containing the file or directory names to add in the tar // $p_result_list : list of added files with their properties (specially the status field) // $p_add_dir : Path to add in the filename path archived // $p_remove_dir : Path to remove in the filename path archived // Return Values : // -------------------------------------------------------------------------------- // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options) function privAddList($p_filedescr_list, &$p_result_list, &$p_options) { $v_result=1; // ----- Add the files $v_header_list = array(); if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) { // ----- Return return $v_result; } // ----- Store the offset of the central dir $v_offset = @ftell($this->zip_fd); // ----- Create the Central Dir files header for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) { // ----- Create the file header if ($v_header_list[$i]['status'] == 'ok') { if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) { // ----- Return return $v_result; } $v_count++; } // ----- Transform the header to a 'usable' info $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); } // ----- Zip file comment $v_comment = ''; if (isset($p_options[PCLZIP_OPT_COMMENT])) { $v_comment = $p_options[PCLZIP_OPT_COMMENT]; } // ----- Calculate the size of the central header $v_size = @ftell($this->zip_fd)-$v_offset; // ----- Create the central dir footer if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) { // ----- Reset the file list unset($v_header_list); // ----- Return return $v_result; } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privAddFileList() // Description : // Parameters : // $p_filedescr_list : An array containing the file description // or directory names to add in the zip // $p_result_list : list of added files with their properties (specially the status field) // Return Values : // -------------------------------------------------------------------------------- function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options) { $v_result=1; $v_header = array(); // ----- Recuperate the current number of elt in list $v_nb = sizeof($p_result_list); // ----- Loop on the files for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) { // ----- Format the filename $p_filedescr_list[$j]['filename'] = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false); // ----- Skip empty file names // TBC : Can this be possible ? not checked in DescrParseAtt ? if ($p_filedescr_list[$j]['filename'] == "") { continue; } // ----- Check the filename if ( ($p_filedescr_list[$j]['type'] != 'virtual_file') && (!file_exists($p_filedescr_list[$j]['filename']))) { PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist"); return PclZip::errorCode(); } // ----- Look if it is a file or a dir with no all path remove option // or a dir with all its path removed // if ( (is_file($p_filedescr_list[$j]['filename'])) // || ( is_dir($p_filedescr_list[$j]['filename']) if ( ($p_filedescr_list[$j]['type'] == 'file') || ($p_filedescr_list[$j]['type'] == 'virtual_file') || ( ($p_filedescr_list[$j]['type'] == 'folder') && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) ) { // ----- Add the file $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header, $p_options); if ($v_result != 1) { return $v_result; } // ----- Store the file infos $p_result_list[$v_nb++] = $v_header; } } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privAddFile() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privAddFile($p_filedescr, &$p_header, &$p_options) { $v_result=1; // ----- Working variable $p_filename = $p_filedescr['filename']; // TBC : Already done in the fileAtt check ... ? if ($p_filename == "") { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); // ----- Return return PclZip::errorCode(); } // ----- Look for a stored different filename /* TBC : Removed if (isset($p_filedescr['stored_filename'])) { $v_stored_filename = $p_filedescr['stored_filename']; } else { $v_stored_filename = $p_filedescr['stored_filename']; } */ // ----- Set the file properties clearstatcache(); $p_header['version'] = 20; $p_header['version_extracted'] = 10; $p_header['flag'] = 0; $p_header['compression'] = 0; $p_header['crc'] = 0; $p_header['compressed_size'] = 0; $p_header['filename_len'] = strlen($p_filename); $p_header['extra_len'] = 0; $p_header['disk'] = 0; $p_header['internal'] = 0; $p_header['offset'] = 0; $p_header['filename'] = $p_filename; // TBC : Removed $p_header['stored_filename'] = $v_stored_filename; $p_header['stored_filename'] = $p_filedescr['stored_filename']; $p_header['extra'] = ''; $p_header['status'] = 'ok'; $p_header['index'] = -1; // ----- Look for regular file if ($p_filedescr['type']=='file') { $p_header['external'] = 0x00000000; $p_header['size'] = filesize($p_filename); } // ----- Look for regular folder else if ($p_filedescr['type']=='folder') { $p_header['external'] = 0x00000010; $p_header['mtime'] = filemtime($p_filename); $p_header['size'] = filesize($p_filename); } // ----- Look for virtual file else if ($p_filedescr['type'] == 'virtual_file') { $p_header['external'] = 0x00000000; $p_header['size'] = strlen($p_filedescr['content']); } // ----- Look for filetime if (isset($p_filedescr['mtime'])) { $p_header['mtime'] = $p_filedescr['mtime']; } else if ($p_filedescr['type'] == 'virtual_file') { $p_header['mtime'] = time(); } else { $p_header['mtime'] = filemtime($p_filename); } // ------ Look for file comment if (isset($p_filedescr['comment'])) { $p_header['comment_len'] = strlen($p_filedescr['comment']); $p_header['comment'] = $p_filedescr['comment']; } else { $p_header['comment_len'] = 0; $p_header['comment'] = ''; } // ----- Look for pre-add callback if (isset($p_options[PCLZIP_CB_PRE_ADD])) { // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_header, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);'); $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header); if ($v_result == 0) { // ----- Change the file status $p_header['status'] = "skipped"; $v_result = 1; } // ----- Update the informations // Only some fields can be modified if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']); } } // ----- Look for empty stored filename if ($p_header['stored_filename'] == "") { $p_header['status'] = "filtered"; } // ----- Check the path length if (strlen($p_header['stored_filename']) > 0xFF) { $p_header['status'] = 'filename_too_long'; } // ----- Look if no error, or file not skipped if ($p_header['status'] == 'ok') { // ----- Look for a file if ($p_filedescr['type'] == 'file') { // ----- Look for using temporary file to zip if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) { $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options); if ($v_result < PCLZIP_ERR_NO_ERROR) { return $v_result; } } // ----- Use "in memory" zip algo else { // ----- Open the source file if (($v_file = @fopen($p_filename, "rb")) == 0) { PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); return PclZip::errorCode(); } // ----- Read the file content $v_content = @fread($v_file, $p_header['size']); // ----- Close the file @fclose($v_file); // ----- Calculate the CRC $p_header['crc'] = @crc32($v_content); // ----- Look for no compression if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { // ----- Set header parameters $p_header['compressed_size'] = $p_header['size']; $p_header['compression'] = 0; } // ----- Look for normal compression else { // ----- Compress the content $v_content = @gzdeflate($v_content); // ----- Set header parameters $p_header['compressed_size'] = strlen($v_content); $p_header['compression'] = 8; } // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { @fclose($v_file); return $v_result; } // ----- Write the compressed (or not) content @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); } } // ----- Look for a virtual file (a file from string) else if ($p_filedescr['type'] == 'virtual_file') { $v_content = $p_filedescr['content']; // ----- Calculate the CRC $p_header['crc'] = @crc32($v_content); // ----- Look for no compression if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) { // ----- Set header parameters $p_header['compressed_size'] = $p_header['size']; $p_header['compression'] = 0; } // ----- Look for normal compression else { // ----- Compress the content $v_content = @gzdeflate($v_content); // ----- Set header parameters $p_header['compressed_size'] = strlen($v_content); $p_header['compression'] = 8; } // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { @fclose($v_file); return $v_result; } // ----- Write the compressed (or not) content @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']); } // ----- Look for a directory else if ($p_filedescr['type'] == 'folder') { // ----- Look for directory last '/' if (@substr($p_header['stored_filename'], -1) != '/') { $p_header['stored_filename'] .= '/'; } // ----- Set the file properties $p_header['size'] = 0; //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked $p_header['external'] = 0x00000010; // Value for a folder : to be checked // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { return $v_result; } } } // ----- Look for post-add callback if (isset($p_options[PCLZIP_CB_POST_ADD])) { // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_header, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. // eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);'); $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header); if ($v_result == 0) { // ----- Ignored $v_result = 1; } // ----- Update the informations // Nothing can be modified } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privAddFileUsingTempFile() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options) { $v_result=PCLZIP_ERR_NO_ERROR; // ----- Working variable $p_filename = $p_filedescr['filename']; // ----- Open the source file if (($v_file = @fopen($p_filename, "rb")) == 0) { PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); return PclZip::errorCode(); } // ----- Creates a compressed temporary file $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) { fclose($v_file); PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); return PclZip::errorCode(); } // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks $v_size = filesize($p_filename); while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($v_file, $v_read_size); //$v_binary_data = pack('a'.$v_read_size, $v_buffer); @gzputs($v_file_compressed, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Close the file @fclose($v_file); @gzclose($v_file_compressed); // ----- Check the minimum file size if (filesize($v_gzip_temp_name) < 18) { PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes'); return PclZip::errorCode(); } // ----- Extract the compressed attributes if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) { PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); return PclZip::errorCode(); } // ----- Read the gzip file header $v_binary_data = @fread($v_file_compressed, 10); $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data); // ----- Check some parameters $v_data_header['os'] = bin2hex($v_data_header['os']); // ----- Read the gzip file footer @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8); $v_binary_data = @fread($v_file_compressed, 8); $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data); // ----- Set the attributes $p_header['compression'] = ord($v_data_header['cm']); //$p_header['mtime'] = $v_data_header['mtime']; $p_header['crc'] = $v_data_footer['crc']; $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18; // ----- Close the file @fclose($v_file_compressed); // ----- Call the header generation if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { return $v_result; } // ----- Add the compressed data if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) { PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); return PclZip::errorCode(); } // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks fseek($v_file_compressed, 10); $v_size = $p_header['compressed_size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($v_file_compressed, $v_read_size); //$v_binary_data = pack('a'.$v_read_size, $v_buffer); @fwrite($this->zip_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Close the file @fclose($v_file_compressed); // ----- Unlink the temporary file @unlink($v_gzip_temp_name); // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privCalculateStoredFilename() // Description : // Based on file descriptor properties and global options, this method // calculate the filename that will be stored in the archive. // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privCalculateStoredFilename(&$p_filedescr, &$p_options) { $v_result=1; // ----- Working variables $p_filename = $p_filedescr['filename']; if (isset($p_options[PCLZIP_OPT_ADD_PATH])) { $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH]; } else { $p_add_dir = ''; } if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) { $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH]; } else { $p_remove_dir = ''; } if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) { $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH]; } else { $p_remove_all_dir = 0; } // ----- Look for full name change if (isset($p_filedescr['new_full_name'])) { // ----- Remove drive letter if any $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']); } // ----- Look for path and/or short name change else { // ----- Look for short name change // Its when we cahnge just the filename but not the path if (isset($p_filedescr['new_short_name'])) { $v_path_info = pathinfo($p_filename); $v_dir = ''; if ($v_path_info['dirname'] != '') { $v_dir = $v_path_info['dirname'].'/'; } $v_stored_filename = $v_dir.$p_filedescr['new_short_name']; } else { // ----- Calculate the stored filename $v_stored_filename = $p_filename; } // ----- Look for all path to remove if ($p_remove_all_dir) { $v_stored_filename = basename($p_filename); } // ----- Look for partial path remove else if ($p_remove_dir != "") { if (substr($p_remove_dir, -1) != '/') $p_remove_dir .= "/"; if ( (substr($p_filename, 0, 2) == "./") || (substr($p_remove_dir, 0, 2) == "./")) { if ( (substr($p_filename, 0, 2) == "./") && (substr($p_remove_dir, 0, 2) != "./")) { $p_remove_dir = "./".$p_remove_dir; } if ( (substr($p_filename, 0, 2) != "./") && (substr($p_remove_dir, 0, 2) == "./")) { $p_remove_dir = substr($p_remove_dir, 2); } } $v_compare = PclZipUtilPathInclusion($p_remove_dir, $v_stored_filename); if ($v_compare > 0) { if ($v_compare == 2) { $v_stored_filename = ""; } else { $v_stored_filename = substr($v_stored_filename, strlen($p_remove_dir)); } } } // ----- Remove drive letter if any $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename); // ----- Look for path to add if ($p_add_dir != "") { if (substr($p_add_dir, -1) == "/") $v_stored_filename = $p_add_dir.$v_stored_filename; else $v_stored_filename = $p_add_dir."/".$v_stored_filename; } } // ----- Filename (reduce the path of stored name) $v_stored_filename = PclZipUtilPathReduction($v_stored_filename); $p_filedescr['stored_filename'] = $v_stored_filename; // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privWriteFileHeader() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privWriteFileHeader(&$p_header) { $v_result=1; // ----- Store the offset position of the file $p_header['offset'] = ftell($this->zip_fd); // ----- Transform UNIX mtime to DOS format mdate/mtime $v_date = getdate($p_header['mtime']); $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; // ----- Packed data $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, $p_header['version_extracted'], $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], $p_header['compressed_size'], $p_header['size'], strlen($p_header['stored_filename']), $p_header['extra_len']); // ----- Write the first 148 bytes of the header in the archive fputs($this->zip_fd, $v_binary_data, 30); // ----- Write the variable fields if (strlen($p_header['stored_filename']) != 0) { fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); } if ($p_header['extra_len'] != 0) { fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privWriteCentralFileHeader() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privWriteCentralFileHeader(&$p_header) { $v_result=1; // TBC //for(reset($p_header); $key = key($p_header); next($p_header)) { //} // ----- Transform UNIX mtime to DOS format mdate/mtime $v_date = getdate($p_header['mtime']); $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; // ----- Packed data $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02015b50, $p_header['version'], $p_header['version_extracted'], $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], $p_header['compressed_size'], $p_header['size'], strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']); // ----- Write the 42 bytes of the header in the zip file fputs($this->zip_fd, $v_binary_data, 46); // ----- Write the variable fields if (strlen($p_header['stored_filename']) != 0) { fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); } if ($p_header['extra_len'] != 0) { fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']); } if ($p_header['comment_len'] != 0) { fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']); } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privWriteCentralHeader() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) { $v_result=1; // ----- Packed data $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment)); // ----- Write the 22 bytes of the header in the zip file fputs($this->zip_fd, $v_binary_data, 22); // ----- Write the variable fields if (strlen($p_comment) != 0) { fputs($this->zip_fd, $p_comment, strlen($p_comment)); } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privList() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privList(&$p_list) { $v_result=1; // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Open the zip file if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) { // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode'); // ----- Return return PclZip::errorCode(); } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privSwapBackMagicQuotes(); return $v_result; } // ----- Go to beginning of Central Dir @rewind($this->zip_fd); if (@fseek($this->zip_fd, $v_central_dir['offset'])) { $this->privSwapBackMagicQuotes(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); // ----- Return return PclZip::errorCode(); } // ----- Read each entry for ($i=0; $i<$v_central_dir['entries']; $i++) { // ----- Read the file header if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) { $this->privSwapBackMagicQuotes(); return $v_result; } $v_header['index'] = $i; // ----- Get the only interesting attributes $this->privConvertHeader2FileInfo($v_header, $p_list[$i]); unset($v_header); } // ----- Close the zip file $this->privCloseFd(); // ----- Magic quotes trick $this->privSwapBackMagicQuotes(); // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privConvertHeader2FileInfo() // Description : // This function takes the file informations from the central directory // entries and extract the interesting parameters that will be given back. // The resulting file infos are set in the array $p_info // $p_info['filename'] : Filename with full path. Given by user (add), // extracted in the filesystem (extract). // $p_info['stored_filename'] : Stored filename in the archive. // $p_info['size'] = Size of the file. // $p_info['compressed_size'] = Compressed size of the file. // $p_info['mtime'] = Last modification date of the file. // $p_info['comment'] = Comment associated with the file. // $p_info['folder'] = true/false : indicates if the entry is a folder or not. // $p_info['status'] = status of the action on the file. // $p_info['crc'] = CRC of the file content. // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privConvertHeader2FileInfo($p_header, &$p_info) { $v_result=1; // ----- Get the interesting attributes $v_temp_path = PclZipUtilPathReduction($p_header['filename']); $p_info['filename'] = $v_temp_path; $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']); $p_info['stored_filename'] = $v_temp_path; $p_info['size'] = $p_header['size']; $p_info['compressed_size'] = $p_header['compressed_size']; $p_info['mtime'] = $p_header['mtime']; $p_info['comment'] = $p_header['comment']; $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); $p_info['index'] = $p_header['index']; $p_info['status'] = $p_header['status']; $p_info['crc'] = $p_header['crc']; // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privExtractByRule() // Description : // Extract a file or directory depending of rules (by index, by name, ...) // Parameters : // $p_file_list : An array where will be placed the properties of each // extracted file // $p_path : Path to add while writing the extracted files // $p_remove_path : Path to remove (from the file memorized path) while writing the // extracted files. If the path does not match the file path, // the file is extracted with its memorized path. // $p_remove_path does not apply to 'list' mode. // $p_path and $p_remove_path are commulative. // Return Values : // 1 on success,0 or less on error (see error code list) // -------------------------------------------------------------------------------- function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) { $v_result=1; // ----- Magic quotes trick $this->privDisableMagicQuotes(); // ----- Check the path if ( ($p_path == "") || ( (substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../") && (substr($p_path,1,2)!=":/"))) $p_path = "./".$p_path; // ----- Reduce the path last (and duplicated) '/' if (($p_path != "./") && ($p_path != "/")) { // ----- Look for the path end '/' while (substr($p_path, -1) == "/") { $p_path = substr($p_path, 0, strlen($p_path)-1); } } // ----- Look for path to remove format (should end by /) if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) { $p_remove_path .= '/'; } $p_remove_path_size = strlen($p_remove_path); // ----- Open the zip file if (($v_result = $this->privOpenFd('rb')) != 1) { $this->privSwapBackMagicQuotes(); return $v_result; } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); return $v_result; } // ----- Start at beginning of Central Dir $v_pos_entry = $v_central_dir['offset']; // ----- Read each entry $j_start = 0; for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { // ----- Read next Central dir entry @rewind($this->zip_fd); if (@fseek($this->zip_fd, $v_pos_entry)) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); // ----- Return return PclZip::errorCode(); } // ----- Read the file header $v_header = array(); if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); return $v_result; } // ----- Store the index $v_header['index'] = $i; // ----- Store the file position $v_pos_entry = ftell($this->zip_fd); // ----- Look for the specific extract rules $v_extract = false; // ----- Look for extract by name rule if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { // ----- Look if the filename is in the list for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) { // ----- Look for a directory if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { // ----- Look if the directory is in the filename path if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { $v_extract = true; } } // ----- Look for a filename elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { $v_extract = true; } } } // ----- Look for extract by ereg rule // ereg() is deprecated with PHP 5.3 /* else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) { $v_extract = true; } } */ // ----- Look for extract by preg rule else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) { $v_extract = true; } } // ----- Look for extract by index rule else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { // ----- Look if the index is in the list for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) { if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { $v_extract = true; } if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { $j_start = $j+1; } if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { break; } } } // ----- Look for no rule, which means extract all the archive else { $v_extract = true; } // ----- Check compression method if ( ($v_extract) && ( ($v_header['compression'] != 8) && ($v_header['compression'] != 0))) { $v_header['status'] = 'unsupported_compression'; // ----- Look for PCLZIP_OPT_STOP_ON_ERROR if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { $this->privSwapBackMagicQuotes(); PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, "Filename '".$v_header['stored_filename']."' is " ."compressed by an unsupported compression " ."method (".$v_header['compression'].") "); return PclZip::errorCode(); } } // ----- Check encrypted files if (($v_extract) && (($v_header['flag'] & 1) == 1)) { $v_header['status'] = 'unsupported_encryption'; // ----- Look for PCLZIP_OPT_STOP_ON_ERROR if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { $this->privSwapBackMagicQuotes(); PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, "Unsupported encryption for " ." filename '".$v_header['stored_filename'] ."'"); return PclZip::errorCode(); } } // ----- Look for real extraction if (($v_extract) && ($v_header['status'] != 'ok')) { $v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++]); if ($v_result != 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); return $v_result; } $v_extract = false; } // ----- Look for real extraction if ($v_extract) { // ----- Go to the file position @rewind($this->zip_fd); if (@fseek($this->zip_fd, $v_header['offset'])) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); // ----- Return return PclZip::errorCode(); } // ----- Look for extraction as string if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) { $v_string = ''; // ----- Extracting the file $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options); if ($v_result1 < 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); return $v_result1; } // ----- Get the only interesting attributes if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); return $v_result; } // ----- Set the file content $p_file_list[$v_nb_extracted]['content'] = $v_string; // ----- Next extracted file $v_nb_extracted++; // ----- Look for user callback abort if ($v_result1 == 2) { break; } } // ----- Look for extraction in standard output elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) { // ----- Extracting the file in standard output $v_result1 = $this->privExtractFileInOutput($v_header, $p_options); if ($v_result1 < 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); return $v_result1; } // ----- Get the only interesting attributes if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); return $v_result; } // ----- Look for user callback abort if ($v_result1 == 2) { break; } } // ----- Look for normal extraction else { // ----- Extracting the file $v_result1 = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options); if ($v_result1 < 1) { $this->privCloseFd(); $this->privSwapBackMagicQuotes(); return $v_result1; } // ----- Get the only interesting attributes if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); return $v_result; } // ----- Look for user callback abort if ($v_result1 == 2) { break; } } } } // ----- Close the zip file $this->privCloseFd(); $this->privSwapBackMagicQuotes(); // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privExtractFile() // Description : // Parameters : // Return Values : // // 1 : ... ? // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback // -------------------------------------------------------------------------------- function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options) { $v_result=1; // ----- Read the file header if (($v_result = $this->privReadFileHeader($v_header)) != 1) { // ----- Return return $v_result; } // ----- Check that the file header is coherent with $p_entry info if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { // TBC } // ----- Look for all path to remove if ($p_remove_all_path == true) { // ----- Look for folder entry that not need to be extracted if (($p_entry['external']&0x00000010)==0x00000010) { $p_entry['status'] = "filtered"; return $v_result; } // ----- Get the basename of the path $p_entry['filename'] = basename($p_entry['filename']); } // ----- Look for path to remove else if ($p_remove_path != "") { if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) { // ----- Change the file status $p_entry['status'] = "filtered"; // ----- Return return $v_result; } $p_remove_path_size = strlen($p_remove_path); if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) { // ----- Remove the path $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); } } // ----- Add the path if ($p_path != '') { $p_entry['filename'] = $p_path."/".$p_entry['filename']; } // ----- Check a base_dir_restriction if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) { $v_inclusion = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], $p_entry['filename']); if ($v_inclusion == 0) { PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, "Filename '".$p_entry['filename']."' is " ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION"); return PclZip::errorCode(); } } // ----- Look for pre-extract callback if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); if ($v_result == 0) { // ----- Change the file status $p_entry['status'] = "skipped"; $v_result = 1; } // ----- Look for abort result if ($v_result == 2) { // ----- This status is internal and will be changed in 'skipped' $p_entry['status'] = "aborted"; $v_result = PCLZIP_ERR_USER_ABORTED; } // ----- Update the informations // Only some fields can be modified $p_entry['filename'] = $v_local_header['filename']; } // ----- Look if extraction should be done if ($p_entry['status'] == 'ok') { // ----- Look for specific actions while the file exist if (file_exists($p_entry['filename'])) { // ----- Look if file is a directory if (is_dir($p_entry['filename'])) { // ----- Change the file status $p_entry['status'] = "already_a_directory"; // ----- Look for PCLZIP_OPT_STOP_ON_ERROR // For historical reason first PclZip implementation does not stop // when this kind of error occurs. if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, "Filename '".$p_entry['filename']."' is " ."already used by an existing directory"); return PclZip::errorCode(); } } // ----- Look if file is write protected else if (!is_writeable($p_entry['filename'])) { // ----- Change the file status $p_entry['status'] = "write_protected"; // ----- Look for PCLZIP_OPT_STOP_ON_ERROR // For historical reason first PclZip implementation does not stop // when this kind of error occurs. if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Filename '".$p_entry['filename']."' exists " ."and is write protected"); return PclZip::errorCode(); } } // ----- Look if the extracted file is older else if (filemtime($p_entry['filename']) > $p_entry['mtime']) { // ----- Change the file status if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) { } else { $p_entry['status'] = "newer_exist"; // ----- Look for PCLZIP_OPT_STOP_ON_ERROR // For historical reason first PclZip implementation does not stop // when this kind of error occurs. if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) { PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Newer version of '".$p_entry['filename']."' exists " ."and option PCLZIP_OPT_REPLACE_NEWER is not selected"); return PclZip::errorCode(); } } } else { } } // ----- Check the directory availability and create it if necessary else { if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) $v_dir_to_check = $p_entry['filename']; else if (!strstr($p_entry['filename'], "/")) $v_dir_to_check = ""; else $v_dir_to_check = dirname($p_entry['filename']); if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { // ----- Change the file status $p_entry['status'] = "path_creation_fail"; // ----- Return //return $v_result; $v_result = 1; } } } // ----- Look if extraction should be done if ($p_entry['status'] == 'ok') { // ----- Do the extraction (if not a folder) if (!(($p_entry['external']&0x00000010)==0x00000010)) { // ----- Look for not compressed file if ($p_entry['compression'] == 0) { // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { // ----- Change the file status $p_entry['status'] = "write_error"; // ----- Return return $v_result; } // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks $v_size = $p_entry['compressed_size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($this->zip_fd, $v_read_size); /* Try to speed up the code $v_binary_data = pack('a'.$v_read_size, $v_buffer); @fwrite($v_dest_file, $v_binary_data, $v_read_size); */ @fwrite($v_dest_file, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Closing the destination file fclose($v_dest_file); // ----- Change the file mtime touch($p_entry['filename'], $p_entry['mtime']); } else { // ----- TBC // Need to be finished if (($p_entry['flag'] & 1) == 1) { PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.'); return PclZip::errorCode(); } // ----- Look for using temporary file to unzip if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) { $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options); if ($v_result < PCLZIP_ERR_NO_ERROR) { return $v_result; } } // ----- Look for extract in memory else { // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); // ----- Decompress the file $v_file_content = @gzinflate($v_buffer); unset($v_buffer); if ($v_file_content === FALSE) { // ----- Change the file status // TBC $p_entry['status'] = "error"; return $v_result; } // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { // ----- Change the file status $p_entry['status'] = "write_error"; return $v_result; } // ----- Write the uncompressed data @fwrite($v_dest_file, $v_file_content, $p_entry['size']); unset($v_file_content); // ----- Closing the destination file @fclose($v_dest_file); } // ----- Change the file mtime @touch($p_entry['filename'], $p_entry['mtime']); } // ----- Look for chmod option if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) { // ----- Change the mode of the file @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]); } } } // ----- Change abort status if ($p_entry['status'] == "aborted") { $p_entry['status'] = "skipped"; } // ----- Look for post-extract callback elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); // ----- Look for abort result if ($v_result == 2) { $v_result = PCLZIP_ERR_USER_ABORTED; } } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privExtractFileUsingTempFile() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privExtractFileUsingTempFile(&$p_entry, &$p_options) { $v_result=1; // ----- Creates a temporary file $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz'; if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) { fclose($v_file); PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode'); return PclZip::errorCode(); } // ----- Write gz file format header $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3)); @fwrite($v_dest_file, $v_binary_data, 10); // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks $v_size = $p_entry['compressed_size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($this->zip_fd, $v_read_size); //$v_binary_data = pack('a'.$v_read_size, $v_buffer); @fwrite($v_dest_file, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Write gz file format footer $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']); @fwrite($v_dest_file, $v_binary_data, 8); // ----- Close the temporary file @fclose($v_dest_file); // ----- Opening destination file if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { $p_entry['status'] = "write_error"; return $v_result; } // ----- Open the temporary gz file if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) { @fclose($v_dest_file); $p_entry['status'] = "read_error"; PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode'); return PclZip::errorCode(); } // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks $v_size = $p_entry['size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @gzread($v_src_file, $v_read_size); //$v_binary_data = pack('a'.$v_read_size, $v_buffer); @fwrite($v_dest_file, $v_buffer, $v_read_size); $v_size -= $v_read_size; } @fclose($v_dest_file); @gzclose($v_src_file); // ----- Delete the temporary file @unlink($v_gzip_temp_name); // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privExtractFileInOutput() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privExtractFileInOutput(&$p_entry, &$p_options) { $v_result=1; // ----- Read the file header if (($v_result = $this->privReadFileHeader($v_header)) != 1) { return $v_result; } // ----- Check that the file header is coherent with $p_entry info if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { // TBC } // ----- Look for pre-extract callback if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); if ($v_result == 0) { // ----- Change the file status $p_entry['status'] = "skipped"; $v_result = 1; } // ----- Look for abort result if ($v_result == 2) { // ----- This status is internal and will be changed in 'skipped' $p_entry['status'] = "aborted"; $v_result = PCLZIP_ERR_USER_ABORTED; } // ----- Update the informations // Only some fields can be modified $p_entry['filename'] = $v_local_header['filename']; } // ----- Trace // ----- Look if extraction should be done if ($p_entry['status'] == 'ok') { // ----- Do the extraction (if not a folder) if (!(($p_entry['external']&0x00000010)==0x00000010)) { // ----- Look for not compressed file if ($p_entry['compressed_size'] == $p_entry['size']) { // ----- Read the file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); // ----- Send the file to the output echo $v_buffer; unset($v_buffer); } else { // ----- Read the compressed file in a buffer (one shot) $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']); // ----- Decompress the file $v_file_content = gzinflate($v_buffer); unset($v_buffer); // ----- Send the file to the output echo $v_file_content; unset($v_file_content); } } } // ----- Change abort status if ($p_entry['status'] == "aborted") { $p_entry['status'] = "skipped"; } // ----- Look for post-extract callback elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); // ----- Look for abort result if ($v_result == 2) { $v_result = PCLZIP_ERR_USER_ABORTED; } } return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privExtractFileAsString() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privExtractFileAsString(&$p_entry, &$p_string, &$p_options) { $v_result=1; // ----- Read the file header $v_header = array(); if (($v_result = $this->privReadFileHeader($v_header)) != 1) { // ----- Return return $v_result; } // ----- Check that the file header is coherent with $p_entry info if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) { // TBC } // ----- Look for pre-extract callback if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) { // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);'); $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header); if ($v_result == 0) { // ----- Change the file status $p_entry['status'] = "skipped"; $v_result = 1; } // ----- Look for abort result if ($v_result == 2) { // ----- This status is internal and will be changed in 'skipped' $p_entry['status'] = "aborted"; $v_result = PCLZIP_ERR_USER_ABORTED; } // ----- Update the informations // Only some fields can be modified $p_entry['filename'] = $v_local_header['filename']; } // ----- Look if extraction should be done if ($p_entry['status'] == 'ok') { // ----- Do the extraction (if not a folder) if (!(($p_entry['external']&0x00000010)==0x00000010)) { // ----- Look for not compressed file // if ($p_entry['compressed_size'] == $p_entry['size']) if ($p_entry['compression'] == 0) { // ----- Reading the file $p_string = @fread($this->zip_fd, $p_entry['compressed_size']); } else { // ----- Reading the file $v_data = @fread($this->zip_fd, $p_entry['compressed_size']); // ----- Decompress the file if (($p_string = @gzinflate($v_data)) === FALSE) { // TBC } } // ----- Trace } else { // TBC : error : can not extract a folder in a string } } // ----- Change abort status if ($p_entry['status'] == "aborted") { $p_entry['status'] = "skipped"; } // ----- Look for post-extract callback elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) { // ----- Generate a local information $v_local_header = array(); $this->privConvertHeader2FileInfo($p_entry, $v_local_header); // ----- Swap the content to header $v_local_header['content'] = $p_string; $p_string = ''; // ----- Call the callback // Here I do not use call_user_func() because I need to send a reference to the // header. // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);'); $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header); // ----- Swap back the content to header $p_string = $v_local_header['content']; unset($v_local_header['content']); // ----- Look for abort result if ($v_result == 2) { $v_result = PCLZIP_ERR_USER_ABORTED; } } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privReadFileHeader() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privReadFileHeader(&$p_header) { $v_result=1; // ----- Read the 4 bytes signature $v_binary_data = @fread($this->zip_fd, 4); $v_data = unpack('Vid', $v_binary_data); // ----- Check signature if ($v_data['id'] != 0x04034b50) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); // ----- Return return PclZip::errorCode(); } // ----- Read the first 42 bytes of the header $v_binary_data = fread($this->zip_fd, 26); // ----- Look for invalid block size if (strlen($v_binary_data) != 26) { $p_header['filename'] = ""; $p_header['status'] = "invalid_header"; // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); // ----- Return return PclZip::errorCode(); } // ----- Extract the values $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); // ----- Get filename $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']); // ----- Get extra_fields if ($v_data['extra_len'] != 0) { $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']); } else { $p_header['extra'] = ''; } // ----- Extract properties $p_header['version_extracted'] = $v_data['version']; $p_header['compression'] = $v_data['compression']; $p_header['size'] = $v_data['size']; $p_header['compressed_size'] = $v_data['compressed_size']; $p_header['crc'] = $v_data['crc']; $p_header['flag'] = $v_data['flag']; $p_header['filename_len'] = $v_data['filename_len']; // ----- Recuperate date in UNIX format $p_header['mdate'] = $v_data['mdate']; $p_header['mtime'] = $v_data['mtime']; if ($p_header['mdate'] && $p_header['mtime']) { // ----- Extract time $v_hour = ($p_header['mtime'] & 0xF800) >> 11; $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; $v_seconde = ($p_header['mtime'] & 0x001F)*2; // ----- Extract date $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; $v_month = ($p_header['mdate'] & 0x01E0) >> 5; $v_day = $p_header['mdate'] & 0x001F; // ----- Get UNIX date format $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); } else { $p_header['mtime'] = time(); } // TBC //for(reset($v_data); $key = key($v_data); next($v_data)) { //} // ----- Set the stored filename $p_header['stored_filename'] = $p_header['filename']; // ----- Set the status field $p_header['status'] = "ok"; // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privReadCentralFileHeader() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privReadCentralFileHeader(&$p_header) { $v_result=1; // ----- Read the 4 bytes signature $v_binary_data = @fread($this->zip_fd, 4); $v_data = unpack('Vid', $v_binary_data); // ----- Check signature if ($v_data['id'] != 0x02015b50) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); // ----- Return return PclZip::errorCode(); } // ----- Read the first 42 bytes of the header $v_binary_data = fread($this->zip_fd, 42); // ----- Look for invalid block size if (strlen($v_binary_data) != 42) { $p_header['filename'] = ""; $p_header['status'] = "invalid_header"; // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); // ----- Return return PclZip::errorCode(); } // ----- Extract the values $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); // ----- Get filename if ($p_header['filename_len'] != 0) $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']); else $p_header['filename'] = ''; // ----- Get extra if ($p_header['extra_len'] != 0) $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']); else $p_header['extra'] = ''; // ----- Get comment if ($p_header['comment_len'] != 0) $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']); else $p_header['comment'] = ''; // ----- Extract properties // ----- Recuperate date in UNIX format //if ($p_header['mdate'] && $p_header['mtime']) // TBC : bug : this was ignoring time with 0/0/0 if (1) { // ----- Extract time $v_hour = ($p_header['mtime'] & 0xF800) >> 11; $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; $v_seconde = ($p_header['mtime'] & 0x001F)*2; // ----- Extract date $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; $v_month = ($p_header['mdate'] & 0x01E0) >> 5; $v_day = $p_header['mdate'] & 0x001F; // ----- Get UNIX date format $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); } else { $p_header['mtime'] = time(); } // ----- Set the stored filename $p_header['stored_filename'] = $p_header['filename']; // ----- Set default status to ok $p_header['status'] = 'ok'; // ----- Look if it is a directory if (substr($p_header['filename'], -1) == '/') { //$p_header['external'] = 0x41FF0010; $p_header['external'] = 0x00000010; } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privCheckFileHeaders() // Description : // Parameters : // Return Values : // 1 on success, // 0 on error; // -------------------------------------------------------------------------------- function privCheckFileHeaders(&$p_local_header, &$p_central_header) { $v_result=1; // ----- Check the static values // TBC if ($p_local_header['filename'] != $p_central_header['filename']) { } if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) { } if ($p_local_header['flag'] != $p_central_header['flag']) { } if ($p_local_header['compression'] != $p_central_header['compression']) { } if ($p_local_header['mtime'] != $p_central_header['mtime']) { } if ($p_local_header['filename_len'] != $p_central_header['filename_len']) { } // ----- Look for flag bit 3 if (($p_local_header['flag'] & 8) == 8) { $p_local_header['size'] = $p_central_header['size']; $p_local_header['compressed_size'] = $p_central_header['compressed_size']; $p_local_header['crc'] = $p_central_header['crc']; } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privReadEndCentralDir() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privReadEndCentralDir(&$p_central_dir) { $v_result=1; // ----- Go to the end of the zip file $v_size = filesize($this->zipname); @fseek($this->zip_fd, $v_size); if (@ftell($this->zip_fd) != $v_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\''); // ----- Return return PclZip::errorCode(); } // ----- First try : look if this is an archive with no commentaries (most of the time) // in this case the end of central dir is at 22 bytes of the file end $v_found = 0; if ($v_size > 26) { @fseek($this->zip_fd, $v_size-22); if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); // ----- Return return PclZip::errorCode(); } // ----- Read for bytes $v_binary_data = @fread($this->zip_fd, 4); $v_data = @unpack('Vid', $v_binary_data); // ----- Check signature if ($v_data['id'] == 0x06054b50) { $v_found = 1; } $v_pos = ftell($this->zip_fd); } // ----- Go back to the maximum possible size of the Central Dir End Record if (!$v_found) { $v_maximum_size = 65557; // 0xFFFF + 22; if ($v_maximum_size > $v_size) $v_maximum_size = $v_size; @fseek($this->zip_fd, $v_size-$v_maximum_size); if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\''); // ----- Return return PclZip::errorCode(); } // ----- Read byte per byte in order to find the signature $v_pos = ftell($this->zip_fd); $v_bytes = 0x00000000; while ($v_pos < $v_size) { // ----- Read a byte $v_byte = @fread($this->zip_fd, 1); // ----- Add the byte //$v_bytes = ($v_bytes << 8) | Ord($v_byte); // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); // ----- Compare the bytes if ($v_bytes == 0x504b0506) { $v_pos++; break; } $v_pos++; } // ----- Look if not found end of central dir if ($v_pos == $v_size) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature"); // ----- Return return PclZip::errorCode(); } } // ----- Read the first 18 bytes of the header $v_binary_data = fread($this->zip_fd, 18); // ----- Look for invalid block size if (strlen($v_binary_data) != 18) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data)); // ----- Return return PclZip::errorCode(); } // ----- Extract the values $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); // ----- Check the global size if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { // ----- Removed in release 2.2 see readme file // The check of the file size is a little too strict. // Some bugs where found when a zip is encrypted/decrypted with 'crypt'. // While decrypted, zip has training 0 bytes if (0) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'The central dir is not at the end of the archive.' .' Some trailing bytes exists after the archive.'); // ----- Return return PclZip::errorCode(); } } // ----- Get comment if ($v_data['comment_size'] != 0) { $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']); } else $p_central_dir['comment'] = ''; $p_central_dir['entries'] = $v_data['entries']; $p_central_dir['disk_entries'] = $v_data['disk_entries']; $p_central_dir['offset'] = $v_data['offset']; $p_central_dir['size'] = $v_data['size']; $p_central_dir['disk'] = $v_data['disk']; $p_central_dir['disk_start'] = $v_data['disk_start']; // TBC //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) { //} // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDeleteByRule() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privDeleteByRule(&$p_result_list, &$p_options) { $v_result=1; $v_list_detail = array(); // ----- Open the zip file if (($v_result=$this->privOpenFd('rb')) != 1) { // ----- Return return $v_result; } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privCloseFd(); return $v_result; } // ----- Go to beginning of File @rewind($this->zip_fd); // ----- Scan all the files // ----- Start at beginning of Central Dir $v_pos_entry = $v_central_dir['offset']; @rewind($this->zip_fd); if (@fseek($this->zip_fd, $v_pos_entry)) { // ----- Close the zip file $this->privCloseFd(); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); // ----- Return return PclZip::errorCode(); } // ----- Read each entry $v_header_list = array(); $j_start = 0; for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { // ----- Read the file header $v_header_list[$v_nb_extracted] = array(); if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) { // ----- Close the zip file $this->privCloseFd(); return $v_result; } // ----- Store the index $v_header_list[$v_nb_extracted]['index'] = $i; // ----- Look for the specific extract rules $v_found = false; // ----- Look for extract by name rule if ( (isset($p_options[PCLZIP_OPT_BY_NAME])) && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) { // ----- Look if the filename is in the list for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) { // ----- Look for a directory if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") { // ----- Look if the directory is in the filename path if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) { $v_found = true; } elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) { $v_found = true; } } // ----- Look for a filename elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) { $v_found = true; } } } // ----- Look for extract by ereg rule // ereg() is deprecated with PHP 5.3 /* else if ( (isset($p_options[PCLZIP_OPT_BY_EREG])) && ($p_options[PCLZIP_OPT_BY_EREG] != "")) { if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { $v_found = true; } } */ // ----- Look for extract by preg rule else if ( (isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) { if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) { $v_found = true; } } // ----- Look for extract by index rule else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) { // ----- Look if the index is in the list for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) { if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) { $v_found = true; } if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) { $j_start = $j+1; } if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) { break; } } } else { $v_found = true; } // ----- Look for deletion if ($v_found) { unset($v_header_list[$v_nb_extracted]); } else { $v_nb_extracted++; } } // ----- Look if something need to be deleted if ($v_nb_extracted > 0) { // ----- Creates a temporay file $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; // ----- Creates a temporary zip archive $v_temp_zip = new PclZip($v_zip_temp_name); // ----- Open the temporary zip file in write mode if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) { $this->privCloseFd(); // ----- Return return $v_result; } // ----- Look which file need to be kept for ($i=0; $i<sizeof($v_header_list); $i++) { // ----- Calculate the position of the header @rewind($this->zip_fd); if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) { // ----- Close the zip file $this->privCloseFd(); $v_temp_zip->privCloseFd(); @unlink($v_zip_temp_name); // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); // ----- Return return PclZip::errorCode(); } // ----- Read the file header $v_local_header = array(); if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) { // ----- Close the zip file $this->privCloseFd(); $v_temp_zip->privCloseFd(); @unlink($v_zip_temp_name); // ----- Return return $v_result; } // ----- Check that local file header is same as central file header if ($this->privCheckFileHeaders($v_local_header, $v_header_list[$i]) != 1) { // TBC } unset($v_local_header); // ----- Write the file header if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) { // ----- Close the zip file $this->privCloseFd(); $v_temp_zip->privCloseFd(); @unlink($v_zip_temp_name); // ----- Return return $v_result; } // ----- Read/write the data block if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) { // ----- Close the zip file $this->privCloseFd(); $v_temp_zip->privCloseFd(); @unlink($v_zip_temp_name); // ----- Return return $v_result; } } // ----- Store the offset of the central dir $v_offset = @ftell($v_temp_zip->zip_fd); // ----- Re-Create the Central Dir files header for ($i=0; $i<sizeof($v_header_list); $i++) { // ----- Create the file header if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) { $v_temp_zip->privCloseFd(); $this->privCloseFd(); @unlink($v_zip_temp_name); // ----- Return return $v_result; } // ----- Transform the header to a 'usable' info $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); } // ----- Zip file comment $v_comment = ''; if (isset($p_options[PCLZIP_OPT_COMMENT])) { $v_comment = $p_options[PCLZIP_OPT_COMMENT]; } // ----- Calculate the size of the central header $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset; // ----- Create the central dir footer if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) { // ----- Reset the file list unset($v_header_list); $v_temp_zip->privCloseFd(); $this->privCloseFd(); @unlink($v_zip_temp_name); // ----- Return return $v_result; } // ----- Close $v_temp_zip->privCloseFd(); $this->privCloseFd(); // ----- Delete the zip file // TBC : I should test the result ... @unlink($this->zipname); // ----- Rename the temporary file // TBC : I should test the result ... //@rename($v_zip_temp_name, $this->zipname); PclZipUtilRename($v_zip_temp_name, $this->zipname); // ----- Destroy the temporary archive unset($v_temp_zip); } // ----- Remove every files : reset the file else if ($v_central_dir['entries'] != 0) { $this->privCloseFd(); if (($v_result = $this->privOpenFd('wb')) != 1) { return $v_result; } if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) { return $v_result; } $this->privCloseFd(); } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDirCheck() // Description : // Check if a directory exists, if not it creates it and all the parents directory // which may be useful. // Parameters : // $p_dir : Directory path to check. // Return Values : // 1 : OK // -1 : Unable to create directory // -------------------------------------------------------------------------------- function privDirCheck($p_dir, $p_is_dir=false) { $v_result = 1; // ----- Remove the final '/' if (($p_is_dir) && (substr($p_dir, -1)=='/')) { $p_dir = substr($p_dir, 0, strlen($p_dir)-1); } // ----- Check the directory availability if ((is_dir($p_dir)) || ($p_dir == "")) { return 1; } // ----- Extract parent directory $p_parent_dir = dirname($p_dir); // ----- Just a check if ($p_parent_dir != $p_dir) { // ----- Look for parent directory if ($p_parent_dir != "") { if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) { return $v_result; } } } // ----- Create the directory if (!@mkdir($p_dir, 0777)) { // ----- Error log PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'"); // ----- Return return PclZip::errorCode(); } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privMerge() // Description : // If $p_archive_to_add does not exist, the function exit with a success result. // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privMerge(&$p_archive_to_add) { $v_result=1; // ----- Look if the archive_to_add exists if (!is_file($p_archive_to_add->zipname)) { // ----- Nothing to merge, so merge is a success $v_result = 1; // ----- Return return $v_result; } // ----- Look if the archive exists if (!is_file($this->zipname)) { // ----- Do a duplicate $v_result = $this->privDuplicate($p_archive_to_add->zipname); // ----- Return return $v_result; } // ----- Open the zip file if (($v_result=$this->privOpenFd('rb')) != 1) { // ----- Return return $v_result; } // ----- Read the central directory informations $v_central_dir = array(); if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) { $this->privCloseFd(); return $v_result; } // ----- Go to beginning of File @rewind($this->zip_fd); // ----- Open the archive_to_add file if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1) { $this->privCloseFd(); // ----- Return return $v_result; } // ----- Read the central directory informations $v_central_dir_to_add = array(); if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) { $this->privCloseFd(); $p_archive_to_add->privCloseFd(); return $v_result; } // ----- Go to beginning of File @rewind($p_archive_to_add->zip_fd); // ----- Creates a temporay file $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp'; // ----- Open the temporary file in write mode if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) { $this->privCloseFd(); $p_archive_to_add->privCloseFd(); PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode'); // ----- Return return PclZip::errorCode(); } // ----- Copy the files from the archive to the temporary file // TBC : Here I should better append the file and go back to erase the central dir $v_size = $v_central_dir['offset']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = fread($this->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Copy the files from the archive_to_add into the temporary file $v_size = $v_central_dir_to_add['offset']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Store the offset of the central dir $v_offset = @ftell($v_zip_temp_fd); // ----- Copy the block of file headers from the old archive $v_size = $v_central_dir['size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($this->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Copy the block of file headers from the archive_to_add $v_size = $v_central_dir_to_add['size']; while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size); @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Merge the file comments $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment']; // ----- Calculate the size of the (new) central header $v_size = @ftell($v_zip_temp_fd)-$v_offset; // ----- Swap the file descriptor // Here is a trick : I swap the temporary fd with the zip fd, in order to use // the following methods on the temporary fil and not the real archive fd $v_swap = $this->zip_fd; $this->zip_fd = $v_zip_temp_fd; $v_zip_temp_fd = $v_swap; // ----- Create the central dir footer if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) { $this->privCloseFd(); $p_archive_to_add->privCloseFd(); @fclose($v_zip_temp_fd); $this->zip_fd = null; // ----- Reset the file list unset($v_header_list); // ----- Return return $v_result; } // ----- Swap back the file descriptor $v_swap = $this->zip_fd; $this->zip_fd = $v_zip_temp_fd; $v_zip_temp_fd = $v_swap; // ----- Close $this->privCloseFd(); $p_archive_to_add->privCloseFd(); // ----- Close the temporary file @fclose($v_zip_temp_fd); // ----- Delete the zip file // TBC : I should test the result ... @unlink($this->zipname); // ----- Rename the temporary file // TBC : I should test the result ... //@rename($v_zip_temp_name, $this->zipname); PclZipUtilRename($v_zip_temp_name, $this->zipname); // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDuplicate() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privDuplicate($p_archive_filename) { $v_result=1; // ----- Look if the $p_archive_filename exists if (!is_file($p_archive_filename)) { // ----- Nothing to duplicate, so duplicate is a success. $v_result = 1; // ----- Return return $v_result; } // ----- Open the zip file if (($v_result=$this->privOpenFd('wb')) != 1) { // ----- Return return $v_result; } // ----- Open the temporary file in write mode if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) { $this->privCloseFd(); PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode'); // ----- Return return PclZip::errorCode(); } // ----- Copy the files from the archive to the temporary file // TBC : Here I should better append the file and go back to erase the central dir $v_size = filesize($p_archive_filename); while ($v_size != 0) { $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = fread($v_zip_temp_fd, $v_read_size); @fwrite($this->zip_fd, $v_buffer, $v_read_size); $v_size -= $v_read_size; } // ----- Close $this->privCloseFd(); // ----- Close the temporary file @fclose($v_zip_temp_fd); // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privErrorLog() // Description : // Parameters : // -------------------------------------------------------------------------------- function privErrorLog($p_error_code=0, $p_error_string='') { if (PCLZIP_ERROR_EXTERNAL == 1) { PclError($p_error_code, $p_error_string); } else { $this->error_code = $p_error_code; $this->error_string = $p_error_string; } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privErrorReset() // Description : // Parameters : // -------------------------------------------------------------------------------- function privErrorReset() { if (PCLZIP_ERROR_EXTERNAL == 1) { PclErrorReset(); } else { $this->error_code = 0; $this->error_string = ''; } } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privDisableMagicQuotes() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privDisableMagicQuotes() { $v_result=1; // ----- Look if function exists if ( (!function_exists("get_magic_quotes_runtime")) || (!function_exists("set_magic_quotes_runtime"))) { return $v_result; } // ----- Look if already done if ($this->magic_quotes_status != -1) { return $v_result; } // ----- Get and memorize the magic_quote value $this->magic_quotes_status = @get_magic_quotes_runtime(); // ----- Disable magic_quotes if ($this->magic_quotes_status == 1) { @set_magic_quotes_runtime(0); } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : privSwapBackMagicQuotes() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function privSwapBackMagicQuotes() { $v_result=1; // ----- Look if function exists if ( (!function_exists("get_magic_quotes_runtime")) || (!function_exists("set_magic_quotes_runtime"))) { return $v_result; } // ----- Look if something to do if ($this->magic_quotes_status != -1) { return $v_result; } // ----- Swap back magic_quotes if ($this->magic_quotes_status == 1) { @set_magic_quotes_runtime($this->magic_quotes_status); } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- } // End of class // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilPathReduction() // Description : // Parameters : // Return Values : // -------------------------------------------------------------------------------- function PclZipUtilPathReduction($p_dir) { $v_result = ""; // ----- Look for not empty path if ($p_dir != "") { // ----- Explode path by directory names $v_list = explode("/", $p_dir); // ----- Study directories from last to first $v_skip = 0; for ($i=sizeof($v_list)-1; $i>=0; $i--) { // ----- Look for current path if ($v_list[$i] == ".") { // ----- Ignore this directory // Should be the first $i=0, but no check is done } else if ($v_list[$i] == "..") { $v_skip++; } else if ($v_list[$i] == "") { // ----- First '/' i.e. root slash if ($i == 0) { $v_result = "/".$v_result; if ($v_skip > 0) { // ----- It is an invalid path, so the path is not modified // TBC $v_result = $p_dir; $v_skip = 0; } } // ----- Last '/' i.e. indicates a directory else if ($i == (sizeof($v_list)-1)) { $v_result = $v_list[$i]; } // ----- Double '/' inside the path else { // ----- Ignore only the double '//' in path, // but not the first and last '/' } } else { // ----- Look for item to skip if ($v_skip > 0) { $v_skip--; } else { $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); } } } // ----- Look for skip if ($v_skip > 0) { while ($v_skip > 0) { $v_result = '../'.$v_result; $v_skip--; } } } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilPathInclusion() // Description : // This function indicates if the path $p_path is under the $p_dir tree. Or, // said in an other way, if the file or sub-dir $p_path is inside the dir // $p_dir. // The function indicates also if the path is exactly the same as the dir. // This function supports path with duplicated '/' like '//', but does not // support '.' or '..' statements. // Parameters : // Return Values : // 0 if $p_path is not inside directory $p_dir // 1 if $p_path is inside directory $p_dir // 2 if $p_path is exactly the same as $p_dir // -------------------------------------------------------------------------------- function PclZipUtilPathInclusion($p_dir, $p_path) { $v_result = 1; // ----- Look for path beginning by ./ if ( ($p_dir == '.') || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) { $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1); } if ( ($p_path == '.') || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) { $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1); } // ----- Explode dir and path by directory separator $v_list_dir = explode("/", $p_dir); $v_list_dir_size = sizeof($v_list_dir); $v_list_path = explode("/", $p_path); $v_list_path_size = sizeof($v_list_path); // ----- Study directories paths $i = 0; $j = 0; while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { // ----- Look for empty dir (path reduction) if ($v_list_dir[$i] == '') { $i++; continue; } if ($v_list_path[$j] == '') { $j++; continue; } // ----- Compare the items if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) { $v_result = 0; } // ----- Next items $i++; $j++; } // ----- Look if everything seems to be the same if ($v_result) { // ----- Skip all the empty items while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { // ----- There are exactly the same $v_result = 2; } else if ($i < $v_list_dir_size) { // ----- The path is shorter than the dir $v_result = 0; } } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilCopyBlock() // Description : // Parameters : // $p_mode : read/write compression mode // 0 : src & dest normal // 1 : src gzip, dest normal // 2 : src normal, dest gzip // 3 : src & dest gzip // Return Values : // -------------------------------------------------------------------------------- function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0) { $v_result = 1; if ($p_mode==0) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($p_src, $v_read_size); @fwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } else if ($p_mode==1) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @gzread($p_src, $v_read_size); @fwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } else if ($p_mode==2) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @fread($p_src, $v_read_size); @gzwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } else if ($p_mode==3) { while ($p_size != 0) { $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE); $v_buffer = @gzread($p_src, $v_read_size); @gzwrite($p_dest, $v_buffer, $v_read_size); $p_size -= $v_read_size; } } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilRename() // Description : // This function tries to do a simple rename() function. If it fails, it // tries to copy the $p_src file in a new $p_dest file and then unlink the // first one. // Parameters : // $p_src : Old filename // $p_dest : New filename // Return Values : // 1 on success, 0 on failure. // -------------------------------------------------------------------------------- function PclZipUtilRename($p_src, $p_dest) { $v_result = 1; // ----- Try to rename the files if (!@rename($p_src, $p_dest)) { // ----- Try to copy & unlink the src if (!@copy($p_src, $p_dest)) { $v_result = 0; } else if (!@unlink($p_src)) { $v_result = 0; } } // ----- Return return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilOptionText() // Description : // Translate option value in text. Mainly for debug purpose. // Parameters : // $p_option : the option value. // Return Values : // The option text value. // -------------------------------------------------------------------------------- function PclZipUtilOptionText($p_option) { $v_list = get_defined_constants(); for (reset($v_list); $v_key = key($v_list); next($v_list)) { $v_prefix = substr($v_key, 0, 10); if (( ($v_prefix == 'PCLZIP_OPT') || ($v_prefix == 'PCLZIP_CB_') || ($v_prefix == 'PCLZIP_ATT')) && ($v_list[$v_key] == $p_option)) { return $v_key; } } $v_result = 'Unknown'; return $v_result; } // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // Function : PclZipUtilTranslateWinPath() // Description : // Translate windows path by replacing '\' by '/' and optionally removing // drive letter. // Parameters : // $p_path : path to translate. // $p_remove_disk_letter : true | false // Return Values : // The path translated. // -------------------------------------------------------------------------------- function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true) { if (stristr(php_uname(), 'windows')) { // ----- Look for potential disk letter if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) { $p_path = substr($p_path, $v_position+1); } // ----- Change potential windows directory separator if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { $p_path = strtr($p_path, '\\', '/'); } } return $p_path; } // -------------------------------------------------------------------------------- ?>
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; /** * Eloquent class to describe the reg_collection table * * automatically generated by ModelGenerator.php */ class Collection extends Model { protected $table = 'reg_collection'; use SoftDeletes; public function getDates() { return array('deleted_at', 'last_updated'); } protected $fillable = array('deleted_at', 'last_updated', 'name', 'uri', 'pref_label'); public function UserCreator() { return $this->belongsTo('App\Models\User', 'created_user_id', 'id'); } public function UserUpdater() { return $this->belongsTo('App\Models\User', 'updated_user_id', 'id'); } public function Vocabulary() { return $this->belongsTo('App\Models\Vocabulary', 'vocabulary_id', 'id'); } public function Status() { return $this->belongsTo('App\Models\Status', 'status_id', 'id'); } }
--TEST-- openssl_decrypt() with GCM cipher algorithm tests --SKIPIF-- <?php if (!extension_loaded("openssl")) die("skip"); if (!in_array('aes-128-gcm', openssl_get_cipher_methods())) die("skip: aes-128-gcm not available"); ?> --FILE-- <?php require_once __DIR__ . "/cipher_tests.inc"; $method = 'aes-128-gcm'; $tests = openssl_get_cipher_tests($method); foreach ($tests as $idx => $test) { echo "TEST $idx\n"; $pt = openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA, $test['iv'], $test['tag'], $test['aad']); var_dump($test['pt'] === $pt); } // no IV var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA, NULL, $test['tag'], $test['aad'])); // failed because no AAD var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA, $test['iv'], $test['tag'])); // failed because wrong tag var_dump(openssl_decrypt($test['ct'], $method, $test['key'], OPENSSL_RAW_DATA, $test['iv'], str_repeat('x', 16), $test['aad'])); ?> --EXPECTF-- TEST 0 bool(true) TEST 1 bool(true) TEST 2 bool(true) TEST 3 bool(true) TEST 4 bool(true) TEST 5 bool(true) Warning: openssl_decrypt(): Setting of IV length for AEAD mode failed in %s on line %d bool(false) bool(false) bool(false)
<?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\data; use Yii; use yii\base\InvalidConfigException; use yii\base\Object; use yii\helpers\Html; use yii\helpers\Inflector; use yii\web\Request; /** * Sort represents information relevant to sorting. * * When data needs to be sorted according to one or several attributes, * we can use Sort to represent the sorting information and generate * appropriate hyperlinks that can lead to sort actions. * * A typical usage example is as follows, * * ```php * function actionIndex() * { * $sort = new Sort([ * 'attributes' => [ * 'age', * 'name' => [ * 'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC], * 'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC], * 'default' => SORT_DESC, * 'label' => 'Name', * ], * ], * ]); * * $models = Article::find() * ->where(['status' => 1]) * ->orderBy($sort->orders) * ->all(); * * return $this->render('index', [ * 'models' => $models, * 'sort' => $sort, * ]); * } * ``` * * View: * * ```php * // display links leading to sort actions * echo $sort->link('name') . ' | ' . $sort->link('age'); * * foreach ($models as $model) { * // display $model here * } * ``` * * In the above, we declare two [[attributes]] that support sorting: name and age. * We pass the sort information to the Article query so that the query results are * sorted by the orders specified by the Sort object. In the view, we show two hyperlinks * that can lead to pages with the data sorted by the corresponding attributes. * * @property array $attributeOrders Sort directions indexed by attribute names. Sort direction can be either * `SORT_ASC` for ascending order or `SORT_DESC` for descending order. This property is read-only. * @property array $orders The columns (keys) and their corresponding sort directions (values). This can be * passed to [[\yii\db\Query::orderBy()]] to construct a DB query. This property is read-only. * * @author Qiang Xue <qiang.xue@gmail.com> * @since 2.0 */ class Sort extends Object { /** * @var boolean whether the sorting can be applied to multiple attributes simultaneously. * Defaults to false, which means each time the data can only be sorted by one attribute. */ public $enableMultiSort = false; /** * @var array list of attributes that are allowed to be sorted. Its syntax can be * described using the following example: * * ```php * [ * 'age', * 'name' => [ * 'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC], * 'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC], * 'default' => SORT_DESC, * 'label' => 'Name', * ], * ] * ``` * * In the above, two attributes are declared: "age" and "name". The "age" attribute is * a simple attribute which is equivalent to the following: * * ```php * 'age' => [ * 'asc' => ['age' => SORT_ASC], * 'desc' => ['age' => SORT_DESC], * 'default' => SORT_ASC, * 'label' => Inflector::camel2words('age'), * ] * ``` * * The "name" attribute is a composite attribute: * * - The "name" key represents the attribute name which will appear in the URLs leading * to sort actions. * - The "asc" and "desc" elements specify how to sort by the attribute in ascending * and descending orders, respectively. Their values represent the actual columns and * the directions by which the data should be sorted by. * - The "default" element specifies by which direction the attribute should be sorted * if it is not currently sorted (the default value is ascending order). * - The "label" element specifies what label should be used when calling [[link()]] to create * a sort link. If not set, [[Inflector::camel2words()]] will be called to get a label. * Note that it will not be HTML-encoded. * * Note that if the Sort object is already created, you can only use the full format * to configure every attribute. Each attribute must include these elements: `asc` and `desc`. */ public $attributes = []; /** * @var string the name of the parameter that specifies which attributes to be sorted * in which direction. Defaults to 'sort'. * @see params */ public $sortParam = 'sort'; /** * @var array the order that should be used when the current request does not specify any order. * The array keys are attribute names and the array values are the corresponding sort directions. For example, * * ```php * [ * 'name' => SORT_ASC, * 'created_at' => SORT_DESC, * ] * ``` * * @see attributeOrders */ public $defaultOrder; /** * @var string the route of the controllers action for displaying the sorted contents. * If not set, it means using the currently requested route. */ public $route; /** * @var string the character used to separate different attributes that need to be sorted by. */ public $separator = ','; /** * @var array parameters (name => value) that should be used to obtain the current sort directions * and to create new sort URLs. If not set, $_GET will be used instead. * * In order to add hash to all links use `array_merge($_GET, ['#' => 'my-hash'])`. * * The array element indexed by [[sortParam]] is considered to be the current sort directions. * If the element does not exist, the [[defaultOrder|default order]] will be used. * * @see sortParam * @see defaultOrder */ public $params; /** * @var \yii\web\UrlManager the URL manager used for creating sort URLs. If not set, * the "urlManager" application component will be used. */ public $urlManager; /** * Normalizes the [[attributes]] property. */ public function init() { $attributes = []; foreach ($this->attributes as $name => $attribute) { if (!is_array($attribute)) { $attributes[$attribute] = [ 'asc' => [$attribute => SORT_ASC], 'desc' => [$attribute => SORT_DESC], ]; } elseif (!isset($attribute['asc'], $attribute['desc'])) { $attributes[$name] = array_merge([ 'asc' => [$name => SORT_ASC], 'desc' => [$name => SORT_DESC], ], $attribute); } else { $attributes[$name] = $attribute; } } $this->attributes = $attributes; } /** * Returns the columns and their corresponding sort directions. * @param boolean $recalculate whether to recalculate the sort directions * @return array the columns (keys) and their corresponding sort directions (values). * This can be passed to [[\yii\db\Query::orderBy()]] to construct a DB query. */ public function getOrders($recalculate = false) { $attributeOrders = $this->getAttributeOrders($recalculate); $orders = []; foreach ($attributeOrders as $attribute => $direction) { $definition = $this->attributes[$attribute]; $columns = $definition[$direction === SORT_ASC ? 'asc' : 'desc']; foreach ($columns as $name => $dir) { $orders[$name] = $dir; } } return $orders; } /** * @var array the currently requested sort order as computed by [[getAttributeOrders]]. */ private $_attributeOrders; /** * Returns the currently requested sort information. * @param boolean $recalculate whether to recalculate the sort directions * @return array sort directions indexed by attribute names. * Sort direction can be either `SORT_ASC` for ascending order or * `SORT_DESC` for descending order. */ public function getAttributeOrders($recalculate = false) { if ($this->_attributeOrders === null || $recalculate) { $this->_attributeOrders = []; if (($params = $this->params) === null) { $request = Yii::$app->getRequest(); $params = $request instanceof Request ? $request->getQueryParams() : []; } if (isset($params[$this->sortParam]) && is_scalar($params[$this->sortParam])) { $attributes = explode($this->separator, $params[$this->sortParam]); foreach ($attributes as $attribute) { $descending = false; if (strncmp($attribute, '-', 1) === 0) { $descending = true; $attribute = substr($attribute, 1); } if (isset($this->attributes[$attribute])) { $this->_attributeOrders[$attribute] = $descending ? SORT_DESC : SORT_ASC; if (!$this->enableMultiSort) { return $this->_attributeOrders; } } } } if (empty($this->_attributeOrders) && is_array($this->defaultOrder)) { $this->_attributeOrders = $this->defaultOrder; } } return $this->_attributeOrders; } /** * Returns the sort direction of the specified attribute in the current request. * @param string $attribute the attribute name * @return boolean|null Sort direction of the attribute. Can be either `SORT_ASC` * for ascending order or `SORT_DESC` for descending order. Null is returned * if the attribute is invalid or does not need to be sorted. */ public function getAttributeOrder($attribute) { $orders = $this->getAttributeOrders(); return isset($orders[$attribute]) ? $orders[$attribute] : null; } /** * Generates a hyperlink that links to the sort action to sort by the specified attribute. * Based on the sort direction, the CSS class of the generated hyperlink will be appended * with "asc" or "desc". * @param string $attribute the attribute name by which the data should be sorted by. * @param array $options additional HTML attributes for the hyperlink tag. * There is one special attribute `label` which will be used as the label of the hyperlink. * If this is not set, the label defined in [[attributes]] will be used. * If no label is defined, [[\yii\helpers\Inflector::camel2words()]] will be called to get a label. * Note that it will not be HTML-encoded. * @return string the generated hyperlink * @throws InvalidConfigException if the attribute is unknown */ public function link($attribute, $options = []) { if (($direction = $this->getAttributeOrder($attribute)) !== null) { $class = $direction === SORT_DESC ? 'desc' : 'asc'; if (isset($options['class'])) { $options['class'] .= ' ' . $class; } else { $options['class'] = $class; } } $url = $this->createUrl($attribute); $options['data-sort'] = $this->createSortParam($attribute); if (isset($options['label'])) { $label = $options['label']; unset($options['label']); } else { if (isset($this->attributes[$attribute]['label'])) { $label = $this->attributes[$attribute]['label']; } else { $label = Inflector::camel2words($attribute); } } return Html::a($label, $url, $options); } /** * Creates a URL for sorting the data by the specified attribute. * This method will consider the current sorting status given by [[attributeOrders]]. * For example, if the current page already sorts the data by the specified attribute in ascending order, * then the URL created will lead to a page that sorts the data by the specified attribute in descending order. * @param string $attribute the attribute name * @param boolean $absolute whether to create an absolute URL. Defaults to `false`. * @return string the URL for sorting. False if the attribute is invalid. * @throws InvalidConfigException if the attribute is unknown * @see attributeOrders * @see params */ public function createUrl($attribute, $absolute = false) { if (($params = $this->params) === null) { $request = Yii::$app->getRequest(); $params = $request instanceof Request ? $request->getQueryParams() : []; } $params[$this->sortParam] = $this->createSortParam($attribute); $params[0] = $this->route === null ? Yii::$app->controller->getRoute() : $this->route; $urlManager = $this->urlManager === null ? Yii::$app->getUrlManager() : $this->urlManager; if ($absolute) { return $urlManager->createAbsoluteUrl($params); } else { return $urlManager->createUrl($params); } } /** * Creates the sort variable for the specified attribute. * The newly created sort variable can be used to create a URL that will lead to * sorting by the specified attribute. * @param string $attribute the attribute name * @return string the value of the sort variable * @throws InvalidConfigException if the specified attribute is not defined in [[attributes]] */ public function createSortParam($attribute) { if (!isset($this->attributes[$attribute])) { throw new InvalidConfigException("Unknown attribute: $attribute"); } $definition = $this->attributes[$attribute]; $directions = $this->getAttributeOrders(); if (isset($directions[$attribute])) { $direction = $directions[$attribute] === SORT_DESC ? SORT_ASC : SORT_DESC; unset($directions[$attribute]); } else { $direction = isset($definition['default']) ? $definition['default'] : SORT_ASC; } if ($this->enableMultiSort) { $directions = array_merge([$attribute => $direction], $directions); } else { $directions = [$attribute => $direction]; } $sorts = []; foreach ($directions as $attribute => $direction) { $sorts[] = $direction === SORT_DESC ? '-' . $attribute : $attribute; } return implode($this->separator, $sorts); } /** * Returns a value indicating whether the sort definition supports sorting by the named attribute. * @param string $name the attribute name * @return boolean whether the sort definition supports sorting by the named attribute. */ public function hasAttribute($name) { return isset($this->attributes[$name]); } }
<?php namespace App; use Illuminate\Database\Eloquent\Model; class Post extends Model { protected $guarded = []; public function user() { return $this->belongsTo(User::class); } public function image() { return $this->morphOne(Image::class, 'imageable'); } public function comments() { return $this->morphMany(Comment::class, 'commentable'); } }
<?php namespace LanguageServerProtocol; class DocumentColorClientCapabilities { /** * Whether text document synchronization supports dynamic registration. * * @var bool|null */ public $dynamicRegistration; public function __construct( bool $dynamicRegistration = null ) { $this->dynamicRegistration = $dynamicRegistration; } }
<?php namespace Illuminate\Mail\Transport; use Swift_Transport; use Swift_Mime_Message; use Swift_Events_EventListener; use GuzzleHttp\ClientInterface; class MailgunTransport implements Swift_Transport { /** * Guzzle client instance. * * @var \GuzzleHttp\ClientInterface */ protected $client; /** * The Mailgun API key. * * @var string */ protected $key; /** * The Mailgun domain. * * @var string */ protected $domain; /** * THe Mailgun API end-point. * * @var string */ protected $url; /** * Create a new Mailgun transport instance. * * @param \GuzzleHttp\ClientInterface $client * @param string $key * @param string $domain * @return void */ public function __construct(ClientInterface $client, $key, $domain) { $this->client = $client; $this->key = $key; $this->setDomain($domain); } /** * {@inheritdoc} */ public function isStarted() { return true; } /** * {@inheritdoc} */ public function start() { return true; } /** * {@inheritdoc} */ public function stop() { return true; } /** * {@inheritdoc} */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { $options = ['auth' => ['api', $this->key], 'multipart' => [ ['name' => 'to', 'contents' => $this->getTo($message)], ['name' => 'message', 'contents' => (string) $message, 'filename' => 'message.mime'], ]]; return $this->client->post($this->url, $options); } /** * {@inheritdoc} */ public function registerPlugin(Swift_Events_EventListener $plugin) { // } /** * Get the "to" payload field for the API request. * * @param \Swift_Mime_Message $message * @return array */ protected function getTo(Swift_Mime_Message $message) { $formatted = []; $contacts = array_merge( (array) $message->getTo(), (array) $message->getCc(), (array) $message->getBcc() ); foreach ($contacts as $address => $display) { $formatted[] = $display ? $display." <$address>" : $address; } return implode(',', $formatted); } /** * Get the API key being used by the transport. * * @return string */ public function getKey() { return $this->key; } /** * Set the API key being used by the transport. * * @param string $key * @return void */ public function setKey($key) { return $this->key = $key; } /** * Get the domain being used by the transport. * * @return string */ public function getDomain() { return $this->domain; } /** * Set the domain being used by the transport. * * @param string $domain * @return void */ public function setDomain($domain) { $this->url = 'https://api.mailgun.net/v3/'.$domain.'/messages.mime'; return $this->domain = $domain; } }
<?php namespace Agrinesia\Modes; use Illuminate\Database\Eloquent\Model; class ActivityLog extends Model { protected $fillable = [ 'subject', 'url', 'method', 'ip', 'agent', 'user_id', ]; public function creator() { return $this->belongsTo(User::class,'user_id'); } }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="apple-touch-icon" sizes="76x76" href="../assets/img/apple-icon.png"> <link rel="icon" type="image/png" href="../assets/img/favicon.png"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <title> @yield('titre') </title> <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' /> <!-- Fonts and icons --> <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet" /> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous"> <!-- CSS Files --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <link href="../assets/css/bootstrap.min.css" rel="stylesheet" /> <link href="../assets/css/now-ui-dashboard.css?v=1.5.0" rel="stylesheet" /> <!-- CSS Just for demo purpose, don't include it in your project --> <link href="../assets/demo/demo.css" rel="stylesheet" /> </head> <body class=""> <div class="wrapper "> <div class="sidebar" data-color="orange"> <!-- Tip 1: You can change the color of the sidebar using: data-color="blue | green | orange | red | yellow" --> <div class="logo"> <a href="http://www.creative-tim.com" class="simple-text logo-mini"> COS </a> <a href="http://www.creative-tim.com" class="simple-text logo-normal"> Commission des oeuvre sociale </a> </div> <div class="sidebar-wrapper" id="sidebar-wrapper"> <ul class="nav"> <li> <a href="./dashboard"> <i class="now-ui-icons design_app"></i> <p>Dashboard</p> </a> </li> <li> <a href="./users"> <i class="now-ui-icons users_single-02"></i> <p>User Profile</p> </a> </li> <li> <a href="./roles"> <i class="now-ui-icons users_single-02"></i> <p>User Roles</p> </a> </li> <li> <a href="./employer"> <i class="now-ui-icons design_bullet-list-67"></i> <p>Liste Des Employées</p> </a> </li> <li> <a href="./operation"> <i class="now-ui-icons design_bullet-list-67"></i> <p>Liste Des Operations</p> </a> </li> <li> <a href="./achatpret"> <i class="now-ui-icons design_bullet-list-67"></i> <p>Liste Des Achats et Prets</p> </a> </li> <li> <a href="./prime"> <i class="now-ui-icons design_bullet-list-67"></i> <p>Liste Des Primes </p> </a> </li> <li> <a href="./paiement"> <i class="now-ui-icons design_bullet-list-67"></i> <p>Liste Des Paiements </p> </a> </li> <li> <a href="./aide"> <i class="now-ui-icons design_bullet-list-67"></i> <p>Liste Des Aides Sociales</p> </a> </li> </ul> </div> </div> <div class="main-panel" id="main-panel"> <!-- Navbar --> <nav class="navbar navbar-expand-lg navbar-transparent bg-primary navbar-absolute"> <div class="container-fluid"> <div class="navbar-wrapper"> <div class="navbar-toggle"> <button type="button" class="navbar-toggler"> <span class="navbar-toggler-bar bar1"></span> <span class="navbar-toggler-bar bar2"></span> <span class="navbar-toggler-bar bar3"></span> </button> </div> <a class="navbar-brand" href="">Comission des oeuvres sociales</a> </div> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigation" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-bar navbar-kebab"></span> <span class="navbar-toggler-bar navbar-kebab"></span> <span class="navbar-toggler-bar navbar-kebab"></span> </button> <div class="collapse navbar-collapse justify-content-end" id="navigation"> <form> <div class="input-group no-border"> <input type="text" value="" class="form-control" placeholder="Search..."> <div class="input-group-append"> <div class="input-group-text"> <i class="now-ui-icons ui-1_zoom-bold"></i> </div> </div> </div> </form> <ul class="navbar-nav"> <li class="nav-item dropdown"> <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre> {{ Auth::user()->name }} </a> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown"> <a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();"> {{ __('Logout') }} </a> <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none"> @csrf </form> </li> </ul> </div> </div> </nav> <!-- End Navbar --> <div class="panel-header panel-header-sm"> </div> @yield('content') <footer class="footer"> <div class=" container-fluid "> <nav> </nav> </footer> </div> </div> <!-- Core JS Files --> <script src="../assets/js/core/jquery.min.js"></script> <script src="../assets/js/core/popper.min.js"></script> <script src="../assets/js/core/bootstrap.min.js"></script> <script src="../assets/js/plugins/perfect-scrollbar.jquery.min.js"></script> <!-- Google Maps Plugin --> <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE"></script> <!-- Chart JS --> <script src="../assets/js/plugins/chartjs.min.js"></script> <!-- Notifications Plugin --> <script src="../assets/js/plugins/bootstrap-notify.js"></script> <!-- Control Center for Now Ui Dashboard: parallax effects, scripts for the example pages etc --> <script src="../assets/js/now-ui-dashboard.min.js?v=1.5.0" type="text/javascript"></script><!-- Now Ui Dashboard DEMO methods, don't include it in your project! --> <script src="../assets/demo/demo.js"></script> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> </body> </html>
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Tahun_akademik extends CI_Controller { public function index() { // Memanggil data di dalam database melalui Model $data['tahun_akademik'] = $this->tahunakademik_model->tampil_data('tahun_akademik')->result(); $this->load->view('templates_administrator/header'); $this->load->view('templates_administrator/sidebar'); $this->load->view('administrator/tahun_akademik', $data); $this->load->view('templates_administrator/footer'); } public function tambah_tahun_akademik() { $data['tahun_akademik'] = $this->tahunakademik_model->tampil_data('tahun_akademik')->result(); $this->load->view('templates_administrator/header'); $this->load->view('templates_administrator/sidebar'); $this->load->view('administrator/tahun_akademik_form', $data); $this->load->view('templates_administrator/footer'); } public function tambah_tahun_akademik_aksi() { $this->_rules(); if ($this->form_validation->run() == FALSE) { // Jika gagal kembali ke Function tambah prodi $this->tambah_tahun_akademik(); } else { // Jika benar, data masuk ke database $tahun_akademik = $this->input->post('tahun_akademik'); $semester = $this->input->post('semester'); $status = $this->input->post('status'); $data = [ 'tahun_akademik' => $tahun_akademik, 'semester' => $semester, 'status' => $status ]; $this->tahunakademik_model->insert_data($data, 'tahun_akademik'); $this->session->set_flashdata('pesan', '<div class="alert alert-success" role="alert">Data Tahun Akademik berhasil di tambahkan </div>'); redirect('administrator/tahun_akademik'); } } public function _rules() { $this->form_validation->set_rules('tahun_akademik','tahun_akademik','required',[ 'required' => 'Tahun Akademik Wajib di isi' ]); $this->form_validation->set_rules('semester','semester','required',[ 'required' => 'Semester Wajib di isi atau di pilih' ]); $this->form_validation->set_rules('status','status','required',[ 'required' => 'Status Wajib di isi atau di pilih' ]); } public function update($id) { $where = ['id_thn_akademik' => $id]; $data['tahun_akademik'] = $this->tahunakademik_model->edit_data($where, 'tahun_akademik')->result(); $this->load->view('templates_administrator/header'); $this->load->view('templates_administrator/sidebar'); $this->load->view('administrator/tahun_akademik_update', $data); $this->load->view('templates_administrator/footer'); } public function update_aksi() { $id = $this->input->post('id_thn_akademik'); $tahun_akademik = $this->input->post('tahun_akademik'); $semester = $this->input->post('semester'); $status = $this->input->post('status'); $data = [ 'tahun_akademik' => $tahun_akademik, 'semester' => $semester, 'status' => $status ]; $where = ['id_thn_akademik' => $id]; $this->tahunakademik_model->update_data($where, $data, 'tahun_akademik'); $this->session->set_flashdata('pesan', '<div class="alert alert-success" role="alert">Data berhasil Tahun Akademik di update</div>'); redirect('administrator/tahun_akademik'); } public function delete($id) { $where = ['id_thn_akademik' => $id]; $this->tahunakademik_model->hapus_data($where, 'tahun_akademik'); $this->session->set_flashdata('pesan', '<div class="alert alert-danger" role="alert">Data Tahun Akademik berhasil di hapus</div>'); redirect('administrator/tahun_akademik'); } }
@extends('layouts.app') @section('content') <div class="content-container"> <!-- cover photo --> <div class="cover-wallpaper" data-photo="{{'/images/conferences/'. $conference->photo->path}}"> <!-- heading --> <h1>{{$conference->title}}</h1> <!-- buttons --> @if(count($conference->plays) > 0) <div class="col-lg-2 pull-right"> <a href="{{route('conference.plays.view', $conference->id)}}" class="btn pull-right btn-success">View Plays</a> @endif @if(count($conference->gallery) > 0) <a class="btn btn-primary pull-right" href="{{route('gallery.view', $conference->gallery->id)}}">View Gallery</a> </div> @endif <!-- /.buttons --> </div> <!-- /.cover photo --> <!-- content --> <div class="col-lg-10"> <hr> <div class="panel panel-body"> <div class="col-lg-8 col-lg-offset-3"> <div class="excerpt"> <h2 class="lead">{{$conference->excerpt}} <small>({{$conference->year}})</small> </h2> {{-- this syntax doesn't escape html tags, which tinymce stores data as, so we usethis to retain the html structure--}} <div class="excerpt"> {!! $conference->details !!} </div> <div class="text-center"> <small>Last updated {{$conference->updated_at->diffForHumans()}}</small> </div> </div> </div> </div> </div> <!-- /.content --> </div> @endsection @section('scripts') <script> $(document).ready(function () { $('.cover-wallpaper').each(function () { // get the currently iterating row var row = $(this); // assign the row's data (image link) to a photo variable var photo = row.data('photo'); $(this).css('background', 'linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)),' + ' url("' + photo + '")' + '') .addClass('bg-fit'); }); }); </script> @endsection
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Sentinel; use App\User; use Session; class UserController extends Controller { public function create_user_admin() { $new_user =[ 'email' => 'ann@gmail.com', 'password' => '1234', 'first_name' => 'Ann', 'last_name' => 'arwatchanakarn', ]; $register = Sentinel::registerAndActivate($new_user); $role = Sentinel::findRoleBySlug('admin'); $role->users()->attach($register); echo "Finish"; } public function create_user_admin_9() { for($i=1;$i<10;$i++) { $new_user =[ 'email' => 'admin'.$i.'@gmail.com', 'password' => '1234', 'first_name' => 'first_sale'.$i, 'last_name' => 'last_sale'.$i, ]; $register = Sentinel::registerAndActivate($new_user); $role = Sentinel::findRoleBySlug('admin'); $role->users()->attach($register); echo "Finish"; } } public function create_user_sale() { for($i=1;$i<10;$i++) { $new_user =[ 'email' => 'sale'.$i.'@gmail.com', 'password' => '1234', 'first_name' => 'first_sale'.$i, 'last_name' => 'last_sale'.$i, ]; $register = Sentinel::registerAndActivate($new_user); $role = Sentinel::findRoleBySlug('sale'); $role->users()->attach($register); echo "Finish"; } } public function create_user_super() { $new_user =[ 'email' => 'naunpun.m@gmail.com', 'password' => '1234', 'first_name' => 'ann', 'last_name' => 'naunpun', ]; $register = Sentinel::registerAndActivate($new_user); $role = Sentinel::findRoleBySlug('super'); $role->users()->attach($register); echo "Finish"; } public function activate_user($id) { $user = Sentinel::findById($id); $activation = Activation::create($user); echo "ok"; } public function login(Request $request) { $email = $request->input('email'); $password = $request->input('password'); $credentials = [ 'email' => $email, 'password' => $password, ]; $user_available = Sentinel::authenticate($credentials); if($user_available!="") { $user = Sentinel::getUser(); session(['user'=>$user]); if ($user->inRole('admin')) { return Redirect('/admin/checkupdate'); } elseif($user->inRole('sale')) { return Redirect('/sale/home'); } elseif($user->inRole('super')) { return Redirect('/super/home'); } } else { Session::flash('message', 'E-mail หรือ Password ไม่ถูกต้อง กรุณากรอกใหม่'); return redirect('/login'); } } public function logout() { Session::forget('new_record'); Session::forget('record'); Session::forget('edit_record'); Session::forget('mem_sale'); Session::forget('mem_selected_record'); Session::forget('mem_selected_record_list'); Session::forget('mem_selected_record_extend'); Session::forget('mem_selected_record_waiting'); Session::forget('mem_selected_record_noreply'); Session::forget('mem_selected_record_new'); Session::forget('mem_selected_record_list_noreply'); Session::forget('mem_selected_record_list_extend'); Session::forget('mem_selected_record_list_waiting'); Session::forget('mem_selected_record_list_new'); Session::forget('preview_record_list_array'); Session::forget('select_record_info'); // session(['mem_selected_record_extend' // session(['mem_selected_record_list_new' //sale Session::forget('user'); Session::forget('sale_filled'); Session::forget('select_record'); Session::forget('sale_filled_edit'); Session::forget('select_record_info'); Session::forget('edit_record_info'); Sentinel::logout(); return Redirect('/login'); } public function checkdi() { if(Sentinel::check()) { return Sentinel::check(); } else { echo "TEST"; } } }
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('role_id')->default(4); $table->string('name'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); $table->timestamps(); $table->softDeletes(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } }
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Setup\Test\Unit\Module\Di\App\Task; use Magento\Setup\Module\Di\App\Task\Operation\ApplicationCodeGenerator; use Magento\Setup\Module\Di\Code\Reader\ClassesScanner; use Magento\Setup\Module\Di\Code\Scanner; use Magento\Setup\Module\Di\Code\Scanner\DirectoryScanner; use Magento\Setup\Module\Di\Code\Scanner\PhpScanner; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class ApplicationCodeGeneratorTest extends TestCase { /** * @var Scanner\DirectoryScanner|MockObject */ private $directoryScannerMock; /** * @var Scanner\PhpScanner|MockObject */ private $phpScannerMock; /** * @var ClassesScanner|MockObject */ private $classesScannerMock; protected function setUp(): void { $this->directoryScannerMock = $this->getMockBuilder( DirectoryScanner::class )->disableOriginalConstructor() ->getMock(); $this->phpScannerMock = $this->getMockBuilder(PhpScanner::class) ->disableOriginalConstructor() ->getMock(); $this->classesScannerMock = $this->getMockBuilder(ClassesScanner::class) ->disableOriginalConstructor() ->getMock(); } /** * @param array $data * * @dataProvider doOperationWrongDataDataProvider */ public function testDoOperationWrongData($data) { $model = new ApplicationCodeGenerator( $this->classesScannerMock, $this->phpScannerMock, $this->directoryScannerMock, $data ); $this->classesScannerMock->expects($this->never()) ->method('getList'); $this->directoryScannerMock->expects($this->never()) ->method('scan'); $this->phpScannerMock->expects($this->never()) ->method('collectEntities'); $this->assertEmpty($model->doOperation()); } /** * @return array */ public function doOperationWrongDataDataProvider() { return [ [[]], [['filePatterns' => ['php' => '*.php']]], [['path' => 'path']], ]; } public function testDoOperation() { $data = [ 'paths' => ['path/to/app'], 'filePatterns' => ['php' => '.php'], 'excludePatterns' => ['/\/Test\//'] ]; $files = ['php' => []]; $model = new ApplicationCodeGenerator( $this->classesScannerMock, $this->phpScannerMock, $this->directoryScannerMock, $data ); $this->classesScannerMock->expects($this->once()) ->method('getList') ->with($data['paths'][0]); $this->directoryScannerMock->expects($this->once()) ->method('scan') ->with( $data['paths'][0], $data['filePatterns'], $data['excludePatterns'] )->willReturn($files); $this->phpScannerMock->expects($this->once()) ->method('collectEntities') ->with($files['php']) ->willReturn([]); $this->assertEmpty($model->doOperation()); } }
<?php use common\base\MultiModel; use yii\bootstrap\ActiveForm; use yii\helpers\Html; /** * @var $this yii\web\View * @var $model MultiModel * @var $languages array */ ?> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model->getModel('source'), 'category')->textInput(['maxlength' => 32]) ?> <?php echo $form->field($model->getModel('source'), 'message')->textInput() ?> <?php if (!$model->getModel('source')->isNewRecord) { ?> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><?php echo Yii::t('backend', 'Translations') ?></h3> </div> <div class="panel-body"> <?php foreach ($languages as $language => $name) { echo $form->field($model->getModel($language), 'translation')->textInput([ 'id' => $language . '-translation', 'name' => $language . '[translation]', ])->label($name); } ?> </div> </div> <?php } ?> <div class="form-group"> <?php echo Html::submitButton(Yii::t('backend', 'Save'), ['class' => 'btn btn-primary']) ?> </div> <?php ActiveForm::end(); ?>
<?php $this->load->view('professor/header'); ?> <div class="content"> <main> <div class="container-fluid"> <style> .result li{ margin: 0; padding: 7px 10px; border: 1px solid #CCCCCC; border-top: none; cursor: pointer; list-style-type:none; height:60px; } .result{ margin:0; padding:0; } .result li:hover{ background: #f2f2f2; } .result li.selected {background:yellow} #group-info{ width:100%; height:200px; } .leftimage{ float:left; } .leftimage img{ width:50px; height:50px; } .rightimage{ height:50px; line-height:50px; float:left; } .fullwidth{ width:100%; } .img70{ margin-top:5px; margin-bottom:5px; width:70px; height:70px; border-radius:50%; } </style> <br clear="all"> <?php foreach($projects as $key=>$project){ $teamlead=$project->t_lead; ?> <!-- DataTales Example --> <div class="card shadow mb-4"> <div class="card-header py-3"> <h6 class="m-0 font-weight-bold text-primary">Team</h6> </div> <div class="card-body"> <br clear="all"> <div class="col-lg-6"> <div class="control-group"> <label >Team Members:</label> <div class="controls"> <div class="search-box"> <input type="text" autocomplete="off" id="SearchU" class="fullwidth" placeholder="Search Student..." /> <ul class="result"></ul> </div> </div> </div> </div> <br clear="all"> <div id="users_names" class="row"> <?php if($team!=null){ $i=0; foreach($team as $key=>$tmember){ $tid= $team[$i]['id']; $uphoto="profile.png"; if($team[$i]['uphoto']!=""){ $uphoto=$team[$i]['uphoto']; } ?> <div class="col-lg-3 col-sm-6 text-center" id="usert<?php echo $team[$i]['id'];?>"> <div class="card"> <div class="card-block"> <div class="card-title bg-primary"> <img src="<?php echo base_url();?>assets/profile/<?php echo $uphoto;?>" class="img70"/> </div> <div class="card-text"> <strong> Name:<?php echo $team[$i]['uname'];?><br> <div id="lead<?php echo $tid;?>" class="userlead<?php echo $team[$i]['user_id'];?>"> <?php if($team[$i]['user_id']==$teamlead){ echo "<span class='text-warning'>Team Leader*</span>"; }else{ ?> <a href="#" onclick="teamlead('<?php echo $tid;?>')"class="text-success"> Make Team Lead</a> <?php } ?> </div> <div id="remove<?php echo $tid;?>"> <a href="#" onclick="remove('<?php echo $tid;?>')" class="text-danger"> Remove Member</a> </a> </div> </strong> </div> </div> </div> </div> <?php $i++; } }else{ } ?> </div> </div> </div> <?php }?> <script src="<?php echo base_url();?>assets/ckeditor/ckeditor.js"></script> <script> $(document).ready(function(){ $('.search-box input[type="text"]').on("keyup input", function(){ /* Get input value on change */ var inputVal = $(this).val(); if(inputVal.length==0){ $(".result").html(""); } if(inputVal.length>1){ var resultDropdown = $(this).siblings(".result"); if(inputVal.length){ $.post("<?php echo base_url();?>Professor/searchUser", {term: inputVal}).done(function(data){ // Display the returned data in browser resultDropdown.html(data); }); } else{ resultDropdown.empty(); } } }); // Set search input value on click of result item $(document).on("click", ".result li", function(){ $(this).parents(".search-box").find('input[type="text"]').val(""); $('.result').html(""); }); }); function addMember($id){ $.ajax({ type: "POST", url: "<?php echo base_url();?>Professor/addMember", data: { uid:$id, pid:<?php echo $pid;?> } }).done(function (result) { if(result=="duplicate"){ alert("User is already part of team."); }else{ $("#users_names").html( result+$("#users_names").html()); } }); } function teamlead(tid){ msg='<span class="text-warning">Team Leader*</span>'; $.ajax({ type: "POST", url: "<?php echo base_url();?>Professor/teamLead", data: { tid:tid } }).done(function (result) { if(result=="already"){ alert("User is already team leader."); }else{ if(result==true){ $("#lead"+tid).html(msg); }else{ var classId=$(".userlead"+result).attr("id"); var arrayc=classId.split("d"); mymsg='<a href="#" onclick="teamlead('+result+')" class="text-success"> Make Team Lead</a>'; $(".userlead"+result).html(mymsg); $("#lead"+tid).html(msg); } } }); } function remove(tid){ $.ajax({ type: "POST", url: "<?php echo base_url();?>Professor/removemem", data: { tid:tid } }).done(function (result) { if(result=="already"){ alert("User is already removed."); }else{ $("#usert"+tid).css("display","none"); } }); } </script> </main> </div> </div> <?php $this->load->view('professor/footer.php'); ?>
<?php namespace App\Support\GitHub\Entities; use App\Support\GitHub\Enums\RunConclusion; use Illuminate\Support\Collection; class WorkflowRunCollection extends Collection { /** @param array<int, WorkflowRun> $items */ public function __construct($items = []) { parent::__construct($items); } public function containsActiveRuns(): bool { return $this->contains(fn (WorkflowRun $workflowRun) => $workflowRun->didNotComplete()); } public function allCompletedSuccessfully(): bool { if ($this->containsActiveRuns()) { return false; } return ! $this->contains(fn (WorkflowRun $workflowRun) => ! ($workflowRun->conclusion()->getValue() === RunConclusion::Success)); } }
<?php /** * Created by PhpStorm. * User: yakov * Date: 11.05.2018 * Time: 19:20 */ namespace AppBundle\DataFixtures\ORM; use AppBundle\Entity\Genus; use Doctrine\Bundle\FixturesBundle\ORMFixtureInterface; use Doctrine\Common\Persistence\ObjectManager; use Nelmio\Alice\Fixtures; class LoadFixtures implements ORMFixtureInterface { public function load(ObjectManager $manager) { $objects = Fixtures::load( __DIR__.'/fixtures.yml', $manager, [ 'providers' => [$this] ]); } public function genus() { $genera = [ 'Octopus', 'Balaena', 'Orcinus', 'Hippocampus', 'Asterias', 'Amphiprion', 'Carcharodon', 'Aurelia', 'Cucumaria', 'Balistoides', 'Paralithodes', 'Chelonia', 'Trichechus', 'Eumetopias' ]; $key = array_rand($genera); return $genera[$key]; } }
<?php return [ /* |-------------------------------------------------------------------------- | Third Party Services |-------------------------------------------------------------------------- | | This file is for storing the credentials for third party services such | as Mailgun, Postmark, AWS and more. This file provides the de facto | location for this type of information, allowing packages to have | a conventional file to locate the various service credentials. | */ 'mailgun' => [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), ], 'postmark' => [ 'token' => env('POSTMARK_TOKEN'), ], 'ses' => [ 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], 'facebook' => [ 'client_id' => '2211510102312134', 'client_secret' => 'dc8881a379d78fdeafd6ac1474e561fd', 'redirect' => 'http://gastos.test:8888/login/facebook/callback', ], ];
<div style="padding:10px; border-top: 1px solid LightGray;"> <span>Nous suivre:&nbsp;&nbsp;</span> <a style="" href="https://www.facebook.com/yetecan224/"> <img src="{{ $message->embed(asset('/uploads/emails/facebook-64.png')) }}" height="30" width="30" alt=""> </a> &nbsp; <a href="https://twitter.com/yetecan"> <img src="{{ $message->embed(asset('/uploads/emails/twitter-64.png')) }}" height="30" width="30" alt=""> </a> &nbsp; <a href="https://www.linkedin.com/company/yetecan" > <img src="{{ $message->embed(asset('/uploads/emails/linkedin-64.png')) }}" height="30" width="30" alt=""> </a> </div>
<!-- BEGIN: Header--> <nav class="header-navbar navbar-expand-lg navbar navbar-with-menu floating-nav navbar-light navbar-shadow"> <div class="navbar-wrapper"> <div class="navbar-container content"> <div class="navbar-collapse" id="navbar-mobile"> <div class="mr-auto float-left bookmark-wrapper d-flex align-items-center"> <ul class="nav navbar-nav"> <li class="nav-item mobile-menu d-xl-none mr-auto"><a class="nav-link nav-menu-main menu-toggle hidden-xs" href="#"><i class="ficon feather icon-menu"></i></a></li> </ul> </div> <ul class="nav navbar-nav float-right"> <li class="dropdown dropdown-language nav-item"> <a class="dropdown-toggle nav-link" id="dropdown-flag" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-globe fa-2x"></i></a> <div class="dropdown-menu" aria-labelledby="dropdown-flag"> @foreach(LaravelLocalization::getSupportedLocales() as $localeCode => $properties) <a class="dropdown-item" rel="alternate" hreflang="{{ $localeCode }}" href="{{ LaravelLocalization::getLocalizedURL($localeCode, null, [], true) }}"> {{ $properties['native'] }} </a> @endforeach </div> </li> <li class="dropdown dropdown-user nav-item"><a class="dropdown-toggle nav-link dropdown-user-link" href="#" data-toggle="dropdown"> <div class="user-nav d-sm-flex d-none"><span class="user-name text-bold-600">{{ auth()->user()->first_name}} {{ auth()->user()->last_name}}</span></div><span><img class="round" src="{{asset('dashboard_files/images/portrait/small/avatar-s-11.jpg')}}" alt="avatar" height="40" width="40"></span> </a> <div class="dropdown-menu dropdown-menu-right"> <a class="dropdown-item" href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();"><i class="feather icon-power"></i> Logout</a> <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;"> @csrf </form> </div> </li> </ul> </div> </div> </div> </nav> <!-- END: Header--> <!-- BEGIN: Main Menu--> <div class="main-menu menu-fixed menu-dark menu-accordion menu-shadow" data-scroll-to-active="true"> <div class="navbar-header"> <ul class="nav navbar-nav flex-row"> <li class="nav-item mr-auto"><a class="navbar-brand" href="../../../html/ltr/vertical-menu-template-semi-dark/index.html"> <div class="brand-logo"></div> <h2 class="brand-text mb-0">Vuexy</h2> </a></li> </ul> </div> <div class="shadow-bottom"></div> <div class="main-menu-content"> <ul class="navigation navigation-main" id="main-menu-navigation" data-menu="menu-navigation"> <li class=" nav-item"><a href="{{route('dashboard.welcome')}}"><i class="feather icon-home"></i><span class="menu-title">@lang('site.dashboard')</span></a> </li> @if(auth()->user()->hasPermission('read_categories')) <li class="nav-item"><a href="{{route('dashboard.categories.index')}}"><i class="feather icon-list"></i><span class="menu-title">@lang('site.categories')</span></a> </li> @endif @if(auth()->user()->hasPermission('read_products')) <li class="nav-item"><a href="{{route('dashboard.products.index')}}"><i class="fa fa-th"></i></i><span class="menu-title">@lang('site.products')</span></a> </li> @endif @if(auth()->user()->hasPermission('read_clients')) <li class="nav-item"><a href="{{route('dashboard.clients.index')}}"><i class="fa fa-users"></i><span class="menu-title">@lang('site.clients')</span></a> </li> @endif @if(auth()->user()->hasPermission('read_orders')) <li class="nav-item"><a href="{{route('dashboard.orders.index')}}"><i class="fa fa-th"></i></i><span class="menu-title">@lang('site.orders')</span></a> </li> @endif @if(auth()->user()->hasPermission('read_users')) <li class="nav-item"><a href="{{route('dashboard.users.index')}}"><i class="feather icon-users"></i><span class="menu-title">@lang('site.users')</span></a> </li> @endif </li> </ul> </div> </div> <!-- END: Main Menu-->
<?php use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $model app\models\CleanService */ $this->title = 'Update Clean Service: ' . $model->clean_id; $this->params['breadcrumbs'][] = ['label' => 'Clean Services', 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => $model->clean_id, 'url' => ['view', 'id' => $model->clean_id]]; $this->params['breadcrumbs'][] = 'Update'; ?> <div class="clean-service-update" style="margin-left:210px"> <h1><?= Html::encode($this->title) ?></h1> <?= $this->render('_form', [ 'model' => $model, 'data'=>$data, ]) ?> </div>
<?php /** * Created by Hisune EchartsPHP AutoGenerate. * @author: Hisune <hi@hisune.com> */ namespace Hisune\EchartsPHP\Doc\IDE\Polar\Tooltip\AxisPointer; use Hisune\EchartsPHP\Property; /** * @property string $color Default: '#555' * 线的颜色。 * * 颜色可以使用 RGB 表示,比如 rgb(128, 128, 128),如果想要加上 alpha 通道表示不透明度,可以使用 RGBA,比如 rgba(128, 128, 128, 0.5),也可以使用十六进制格式,比如 #ccc。除了纯色之外颜色也支持渐变色和纹理填充 * // 线性渐变,前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1,相当于在图形包围盒中的百分比,如果 globalCoord 为 `true`,则该四个值是绝对的像素位置 * color: { * type: linear, * x: 0, * y: 0, * x2: 0, * y2: 1, * colorStops: [{ * offset: 0, color: red // 0% 处的颜色 * }, { * offset: 1, color: blue // 100% 处的颜色 * }], * globalCoord: false // 缺省为 false * } * // 径向渐变,前三个参数分别是圆心 x, y 和半径,取值同线性渐变 * color: { * type: radial, * x: 0.5, * y: 0.5, * r: 0.5, * colorStops: [{ * offset: 0, color: red // 0% 处的颜色 * }, { * offset: 1, color: blue // 100% 处的颜色 * }], * globalCoord: false // 缺省为 false * } * // 纹理填充 * color: { * image: imageDom, // 支持为 HTMLImageElement, HTMLCanvasElement,不支持路径字符串 * repeat: repeat // 是否平铺, 可以是 repeat-x, repeat-y, no-repeat * } * * @property int $width Default: 1 * 线宽。 * * @property string $type Default: 'dashed' * 线的类型。 * 可选: * * solid * dashed * dotted * * @property int $shadowBlur * 图形阴影的模糊大小。该属性配合 shadowColor,shadowOffsetX, shadowOffsetY 一起设置图形的阴影效果。 * 示例: * { * shadowColor: rgba(0, 0, 0, 0.5), * shadowBlur: 10 * } * * @property string $shadowColor * 阴影颜色。支持的格式同color。 * * @property int $shadowOffsetX Default: 0 * 阴影水平方向上的偏移距离。 * * @property int $shadowOffsetY Default: 0 * 阴影垂直方向上的偏移距离。 * * @property int $opacity * 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。 * * {_more_} */ class CrossStyle extends Property {}
<div class="left ml10" style="width:98%"> <h1 class="column_head mt10"> <a href="/people/not_viewed?mode=new" style="<?=request::get('mode')=='new' ? '' : 'color:white;'?>"><?=t('Новые пользователи')?> <?=$new_users_count?> </a> &nbsp;&nbsp;| &nbsp;&nbsp; <a href="/people/not_viewed" style="<?=request::get('mode')=='new' ? 'color:white;' : ''?>"><?=t('Пользователи з доп.инфо')?> <?=$additional_count?></a> </h1> <? if ( !$users) { ?> <div class="acenter fs11 quiet m10 p10"><?=t('Новых пользователей еще нет')?></div> <? } else { ?> <div style="width:200px; font-size: 90%;" class="ml10 left mt10 mr5"> <? foreach ( $users as $id ) { ?> <? include dirname(__FILE__) . '/../../search/views/partials/outlook.php' ?> <? } ?> </div> <div style="width:500px; font-size: 80%;" class="ml10 left mr10"> <table width="60%" height="100%" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td valign="middle" align="center" id="user_outlook_data"> <- <?=t('выберите участника')?> </td> </tr> </table> </div> <div class="clear"></div> <div class="right mr10 pager"><?=pager_helper::get_full($pager)?></div> <? } ?> </div> <script type="text/javascript"> jQuery(document).ready(function($){ $('.outlook_user').click(function(){ var id = $(this).attr('rel'); $('#user_outlook_data').html("<img src='https://s1.meritokrat.org/common/loaging.gif' style='margin-top:200px;'>"); $('.outlook_user').removeClass('lgray'); $(this).addClass('lgray'); $.get('/people/one_not_viewed', { id: id }, function(data) { $('#user_outlook_data').html(data); }); }); }); </script>
<?php // This file is auto-generated, don't edit it. Thanks. namespace AlibabaCloud\SDK\Cms\V20190101\Models\DescribeSiteMonitorAttributeResponse; use AlibabaCloud\SDK\Cms\V20190101\Models\DescribeSiteMonitorAttributeResponse\metricRules\metricRule; use AlibabaCloud\Tea\Model; class metricRules extends Model { /** * @description MetricRule * * @var array */ public $metricRule; protected $_name = [ 'metricRule' => 'MetricRule', ]; public function validate() { Model::validateRequired('metricRule', $this->metricRule, true); } public function toMap() { $res = []; if (null !== $this->metricRule) { $res['MetricRule'] = []; if (null !== $this->metricRule && \is_array($this->metricRule)) { $n = 0; foreach ($this->metricRule as $item) { $res['MetricRule'][$n++] = null !== $item ? $item->toMap() : $item; } } } return $res; } /** * @param array $map * * @return metricRules */ public static function fromMap($map = []) { $model = new self(); if (isset($map['MetricRule'])) { if (!empty($map['MetricRule'])) { $model->metricRule = []; $n = 0; foreach ($map['MetricRule'] as $item) { $model->metricRule[$n++] = null !== $item ? metricRule::fromMap($item) : $item; } } } return $model; } }
<?php namespace App\Http\Controllers\admin; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Author; use App\Book; use App\Http\Requests\AuthorRulesRequest; class AuthorController extends Controller { public function show($id) { $author = Author::find($id); return view('admin/author-list', [ 'author' => $author ] ); } public function create(AuthorRulesRequest $request) { Author::create($request->all()); return redirect()->route('mainAdmin'); } public function update(AuthorRulesRequest $request, $id) { $author = Author::find($id); $author->update($request->all()); return redirect()->route('mainAdmin'); } public function delete($id) { Book::where('author_id', $id)->delete(); Author::find($id)->delete(); return redirect()->route('mainAdmin'); } }
<!DOCTYPE html> <html lang="en"> <head> <?php $data['tittle'] = "Pegadaian"; $this->load->view('template/head', $data); ?> </head> <body class="app sidebar-mini rtl"> <!-- Navbar--> <header class="app-header"><a class="app-header__logo" href="#">Pegadaian</a> <?php $this->load->view('template/header') ?> </header> <!-- Sidebar menu--> <div class="app-sidebar__overlay" data-toggle="sidebar"></div> <?php $this->load->view('template/menu') ?> <main class="app-content"> <div class="app-title"> <div> <h1><i class="fa fa-bar-chart"></i> Edit Penilaian Karyawan Oprasional</h1> <p>MENGATASI MASALAH TANPA MASALAH!!!</p> </div> <ul class="app-breadcrumb breadcrumb"> <li class="breadcrumb-item"><i class="fa fa-home fa-lg"></i></li> <li class="breadcrumb-item"><a href="<?= Base_url();?>Home/edit_nilai_kar">Hasil Penilaian Karyawan</a></li> <li class="breadcrumb-item">Edit Nilai Karyawan</li> </ul> </div> <?= $this->session->flashdata('status_insert'); ?> <div class="row"> <div class="col-md-12"> <div class="tile"> <div class="card-body"> <div class="tile-title-w-btn"> <h3 class="title">Penampilan dan Perilaku <i>Frontliners</i></h3> </div> <div class="row"> <div class="form-group mx-sm-3 mb-2"> <?= form_open('Home/data_nilai_kar'); ?> <input type="month" name="entry_date" class="form-control"> <small class="form-text text-muted">Pilih Bulan yang akan anda cari</small> <input type="hidden" name="nik" value="<?= $this->uri->segment(3); ?>"> </div> <button class="btn btn-info mb-5" name="cari_data_nilai" type="submit"><i class="fa fa-search fa-fw"></i> Cari</button> <?= form_close() ?> </div> <?= form_open('Home/in_edit_kar'); ?> <table class="table table-bordered table-sm"> <thead> <tr bgcolor="#F5F5F5"> <th rowspan="2">NO</th> <th rowspan="2">OBYEK PENGAMATAN</th> <th rowspan="2">TANGGAL</th> <th colspan="4">NILAI</th> </tr> <tr bgcolor="#F5F5F5"> <th>1 (Kurang)</th> <th>2 (Cukup)</th> <th>3 (Bagus)</th> <th>4 (Sangat Bagus)</th> </tr> </thead> <tbody> <?php if (isset($_POST['cari_data_nilai'])) { $nexttype= 0; foreach ($nli_kar as $key) { $aspek = $nexttype == $key['aspek']? "":$key['nama_aspek']; if ($aspek != "") { $n=1; ?> <tr> <td colspan="10"><b><?= $key['nama_aspek']; ?></b></td> </tr> <?php }?> <tr> <td width="20" valign="top"><?=$n;?></td> <td valign="top"> <?= $key['nama_faktor'] ?> <input type="hidden" name="id_faktor[]" value="<?=$key['id_faktor'];?>" > <input type="hidden" name="id_nilai[]" value="<?=$key['id_nilai'];?>" > </td> <td class="text-center" ><?= $key['entry_date'] ?></td> <td valign="top" align="center"> <div class="animated-radio-button"> <label> <input type="radio" name="nilai[]<?=$key['id_nilai'];?>" value="1" <?=$key['nilai']==1? "checked":"";?> ><span class="label-text"></span> </label> </div> </td> <td valign="top" align="center"> <div class="animated-radio-button"> <label> <input type="radio" name="nilai[]<?=$key['id_nilai'];?>" value="2" <?=$key['nilai']==2? "checked":"";?> ><span class="label-text"></span> </label> </div> </td> <td valign="top" align="center"> <div class="animated-radio-button"> <label> <input type="radio" name="nilai[]<?=$key['id_nilai'];?>" value="3" <?=$key['nilai']==3? "checked":"";?> ><span class="label-text"></span> </label> </div> </td> <td valign="top" align="center"> <div class="animated-radio-button"> <label> <input type="radio" name="nilai[]<?=$key['id_nilai'];?>" value="4" <?=$key['nilai']==4? "checked":"";?> ><span class="label-text"></span> </label> </div> </td> </tr> <?php $nexttype = $key['aspek']; $n++; } ?> <?php } else { ?> <tr> <td colspan="7" class="text-center" >Data Tidak Ditemukan</td> </tr> <?php } ?> </tbody> </table> <hr align="right" color="black"> <div class="modal-footer"> <a class="btn btn-secondary" href="<?= Base_url();?>Home/edit_nilai_kar"><i class="fa fa-arrow-left"></i>Kembali</a> <button class="btn btn-primary" name="submit" type="submit"><i class="fa fa-fw fa-floppy-o"></i>Simpan</button> </div> <?= form_close() ?> </div> </div> </div> </div> <footer> <!-- footer area start--> <?php $this->load->view('template/footer') ?> <!-- footer area end--> </footer> </main> <?php $this->load->view('template/script') ?> <script type="text/javascript"> $('.select2').select2(); </script> </body> </html>
<?php declare(strict_types=1); namespace WoohooLabs\Yin\Tests\JsonApi\Double; use WoohooLabs\Yin\JsonApi\Exception\DefaultExceptionFactory; use WoohooLabs\Yin\JsonApi\Request\JsonApiRequest; use WoohooLabs\Yin\JsonApi\Serializer\JsonDeserializer; use Zend\Diactoros\ServerRequest; use Zend\Diactoros\StreamFactory; class StubJsonApiRequest extends JsonApiRequest { public static function create(array $queryParams = []): StubJsonApiRequest { return new StubJsonApiRequest($queryParams); } public function __construct(array $queryParams = []) { $streamFactory = new StreamFactory(); parent::__construct( new ServerRequest([], [], null, null, $streamFactory->createStream(), [], [], $queryParams), new DefaultExceptionFactory(), new JsonDeserializer() ); } }
<?php namespace XF\ModeratorLog; use XF\Entity\ModeratorLog; use XF\Mvc\Entity\Entity; class ProfilePostComment extends AbstractHandler { public function isLoggable(Entity $content, $action, \XF\Entity\User $actor) { switch ($action) { case 'edit': if ($actor->user_id == $content->user_id) { return false; } } return parent::isLoggable($content, $action, $actor); } protected function getLogActionForChange(Entity $content, $field, $newValue, $oldValue) { switch ($field) { case 'message': return 'edit'; case 'message_state': if ($newValue == 'visible' && $oldValue == 'moderated') { return 'approve'; } else if ($newValue == 'visible' && $oldValue == 'deleted') { return 'undelete'; } else if ($newValue == 'deleted') { $reason = $content->DeletionLog ? $content->DeletionLog->delete_reason : ''; return ['delete_soft', ['reason' => $reason]]; } else if ($newValue == 'moderated') { return 'unapprove'; } break; } return false; } protected function setupLogEntityContent(ModeratorLog $log, Entity $content) { /** @var \XF\Entity\Post $content */ $log->content_user_id = $content->user_id; $log->content_username = $content->username; $log->content_title = ''; $log->content_url = \XF::app()->router('public')->buildLink('nopath:profile-posts/comments', $content); $log->discussion_content_type = 'profile_post'; $log->discussion_content_id = $content->profile_post_id; } public function getContentTitle(ModeratorLog $log) { return \XF::phrase('profile_post_comment_by_x', [ 'username' => $log->content_username ])->render('raw'); } }
<?php namespace App\Http\Controllers\OldDB; use Illuminate\Http\Request; use App\Models\OldDB\OldAgents; use App\Models\Employees\Agents; use App\Http\Controllers\Controller; use App\Models\OldDB\BillingInvoices; use App\Models\OldDB\BillingInvoicesItems; use App\Models\DocManagement\Transactions\Contracts\Contracts; class CommissionPaymentsController extends Controller { public function make_payment_from_commission(Request $request) { $Agent_ID = $request -> Agent_ID; $Contract_ID = $request -> Contract_ID; $payments = json_decode($request -> payments, true); $paid_with = 'commission'; $contract = Contracts::find($Contract_ID); $address = $contract -> FullStreetAddress.' '.$contract -> City.', '.$contract -> StateOrProvince.' '.$contract -> PostalCode; $agent = Agents::find($Agent_ID); $old_agent = OldAgents::find($Agent_ID); $class_dues = ''; $class_eno = ''; foreach($payments as $payment) { $description = $payment['description']; $amount = preg_replace('/[,\$]+/', '', $payment['amount']); $type = $payment['type']; $invoice = new BillingInvoices(); $invoice -> Contract_ID = $Contract_ID; $invoice -> in_agent_id = $Agent_ID; $invoice -> in_amount = $amount; $invoice -> in_date_sent = date('Y-m-d'); $invoice -> in_agent_fullname = $agent -> full_name; $invoice -> in_agent_email = $agent -> email; $invoice -> in_paid = 'yes'; $invoice -> in_notes = 'Commission from '.$address; $invoice -> in_company = $agent -> company; $invoice -> in_date_paid = date('Y-m-d'); $invoice -> payment_type = $paid_with; $invoice -> py_desc = 'Commission from '.$address; $invoice -> prop_address = $address; $invoice -> created_by = auth() -> user() -> name; if($type == 'dues') { $prev_balance = $old_agent -> balance; $new_balance = $prev_balance - $amount; $invoice -> in_agent_balance = $new_balance; $invoice -> in_agent_prev_balance = $prev_balance; $invoice -> in_type = 'payment'; $old_agent -> update([ 'balance' => $new_balance ]); $class_dues = 'text-success'; } else if($type == 'eno') { $prev_balance_eno = $old_agent -> balance_eno; $new_balance_eno = $prev_balance_eno - $amount; $invoice -> in_agent_balance_eno = $new_balance_eno; $invoice -> in_agent_prev_balance_eno = $prev_balance_eno; $invoice -> in_type = 'paymentEno'; $old_agent -> update([ 'balance_eno' => $new_balance_eno ]); $class_eno = 'text-success'; } $invoice -> save(); $invoice_id = $invoice -> id; $invoice_items = new BillingInvoicesItems(); $invoice_items -> in_item_quantity = 1; $invoice_items -> in_item_desc = $description; $invoice_items -> in_item_amount = $amount; $invoice_items -> in_item_total = $amount; $invoice_items -> in_invoice_id = $invoice_id; $invoice_items -> in_item_agent_id = $Agent_ID; $invoice_items -> in_item_agent = $agent -> full_name; $invoice_items -> save(); } $balances = ' <table class="table table-hover table-sm"> <thead> <th></th> <th>Previous Balance</th> <th>Current Balance</th> </thead> <tbody> <tr> <td>Dues</td> <td>$'.number_format($prev_balance, 2).'</td> <td class="'.$class_dues.'">$'.number_format($new_balance, 2).'</td> </tr> <tr> <td>E&O</td> <td>$'.number_format($prev_balance_eno, 2).'</td> <td class="'.$class_eno.'">$'.number_format($new_balance_eno, 2).'</td> </tr> </tbody> </table> '; return compact('balances'); } }
<?php /* Oxygen Webhelp Plugin Copyright (c) 1998-2021 Syncro Soft SRL, Romania. All rights reserved. */ class MissingPageFilter implements IFilter { private $baseDir; private $pageField; /** * Constructor */ function __construct($baseDir, $field) { $this->baseDir = $baseDir; $this->pageField = $field; } /** * * @see IFilter::filter() */ public function filter($AssociativeRowArray) { // __BASE_DIR__ $toReturn = false; $file = $this->baseDir . DIRECTORY_SEPARATOR . str_replace("/", DIRECTORY_SEPARATOR, $AssociativeRowArray[$this->pageField]); if (!file_exists($file)) { $toReturn = true; } return $toReturn; } public function getSqlFilterClause() { return null; } } ?>
<?php namespace Hollogram\LaravelStapler; use Hollogram\Stapler\Interfaces\Config; use Illuminate\Contracts\Config\Repository; class IlluminateConfig implements Config { /** * An instance of Laravel's config class. * * @var Repository */ protected $config; /** * The name of the package this driver is being used with. * * @var string */ protected $packageName; /** * The separator between package name and item. * * @var string */ protected $separator; /** * Constructor method. * * @param Repository $config * @param string $packageName * @param string $separator */ public function __construct(Repository $config, $packageName = null, $separator = '::') { $this->config = $config; $this->packageName = $packageName; $this->separator = $separator; } /** * Retrieve a configuration value. * * @param $name * * @return mixed */ public function get($name) { $item = $this->getItemPath($name); return $this->config->get($item); } /** * Set a configuration value. * * @param $name * @param $value * * @return mixed */ public function set($name, $value) { $item = $this->getItemPath($name); return $this->config->set($item, $value); } /** * Return the path to an item so that it can be loaded via config. * We need to append the package name to the item separated * with '::' for L4 and '.' for L5. * * @param string $item * * @return string */ protected function getItemPath($item) { return $this->packageName.$this->separator.$item; } }
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Module extends AdminController { public $updater; public function __construct() { parent::__construct(); $this->updater = new \Kanti\HubUpdater(array( "cacheFile" => "moduleInfo.json",//name of the InformationCacheFile(in cacheDir) "holdTime" => 10, //time(seconds) the Cached-Information will be used "versionFile" => "moduleVersion.json",//name of the InstalledVersionInformation is safed(in cacheDir) "name" => 'yayalaressa/respandra-modules', //Repository to watch "prerelease" => true //accept prereleases? )); } public function index() { if ($this->updater->able()) { $info = $this->updater->getNewestInfo(); $this->theme->render('admin/updater', array( 'title' => 'Updater', 'heading' => 'Your module a wait update!', 'is_role' => 'admin', 'breadcrumb' => 'Update module', 'button' => 'Update to ' . $info['tag_name'], 'update' => $info, 'url' => site_url() . 'admin/updater/module/do_update' )); } else { $info = $this->updater->getCurrentInfo(); $this->theme->render('admin/updater', array( 'title' => 'Updater', 'heading' => 'Your module is already the latest version.', 'is_role' => 'admin', 'breadcrumb' => 'Update module', 'button' => 'Official repository', 'update' => $info, 'url' => 'https://yayalaressa.github.io/respandra-modules/' )); } } public function do_update() { if($this->updater->able()) { $this->updater->update(); redirect(site_url() . 'admin/updater/module'); } else { redirect(site_url() . 'admin/updater/module'); } } }
<?php namespace OuterEdge\BulkActions\Ui\Component\Action; class AddParams extends \Magento\Ui\Component\Action { protected $urlBuilder; public function __construct( \Magento\Framework\View\Element\UiComponent\ContextInterface $context, \Magento\Framework\UrlInterface $urlBuilder, array $components = array(), array $data = array(), $actions = null ) { parent::__construct($context, $components, $data, $actions); $this->urlBuilder = $urlBuilder; } public function prepare() { parent::prepare(); $config = $this->getConfiguration(); $params = array('notify' => '1'); $config['url'] = $this->urlBuilder->getUrl('shipbulkactions/order/massordership/', $params); $this->setData('config', $config); } }
<?php namespace Oro\Bundle\UIBundle\Tests\Route; use Oro\Bundle\UIBundle\Route\Router; class RouterTest extends \PHPUnit_Framework_TestCase { protected $request; protected $route; /** * @var Router */ protected $router; public function setUp() { $this->request = $this->getMock('Symfony\Component\HttpFoundation\Request'); $this->route = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Routing\Router') ->disableOriginalConstructor() ->getMock(); $this->router = new Router($this->request, $this->route); } public function testActionRedirect() { $testUrl = 'test\\url\\index.html'; $this->request->expects($this->once()) ->method('get') ->will($this->returnValue(Router::ACTION_SAVE_AND_STAY)); $this->route->expects($this->once()) ->method('generate') ->will($this->returnValue($testUrl)); $redirect = $this->router->actionRedirect( array( 'route' => 'test_route', 'parameters' => array('id' => 1), ), array() ); $this->assertEquals($testUrl, $redirect->getTargetUrl()); } public function testSaveAndCloseActionRedirect() { $testUrl = 'save_and_close.html'; $this->request->expects($this->once()) ->method('get') ->will($this->returnValue('test')); $this->route->expects($this->once()) ->method('generate') ->will($this->returnValue($testUrl)); /** * @var \Symfony\Component\HttpFoundation\RedirectResponse */ $redirect = $this->router->actionRedirect( array(), array( 'route' => 'test_route', 'parameters' => array('id' => 1), ) ); $this->assertEquals($testUrl, $redirect->getTargetUrl()); } public function testWrongParametersActionRedirect() { $this->setExpectedException('\LogicException'); $this->router->actionRedirect( array(), array() ); } }
<div class="modal fade permiss" id="modal-permiss"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span></button> <h4 class="modal-title">Cấp quyền</h4> </div> <div class="modal-body"> <button class="btn btn-primary uploader" data-access="uploader">uploader</button> <button class="btn btn-success mod" data-access="mod">mod</button> <button class="btn btn-warning statistic" data-access="statistic">statistic</button> <button class="btn btn-danger admin" data-access="admin">admin</button> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary pull-left" data-dismiss="modal">Đồng ý</button> <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Hủy</button> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </div>
<?php /* CommcloudVoiceBundle:Admin:createactivitytemplate.html.twig */ class __TwigTemplate_f8b7ede7e864bd3c0aa115c11a2d07f45454a37e65bbc909abb54278475258c4 extends Twig_Template { public function __construct(Twig_Environment $env) { parent::__construct($env); $this->parent = false; $this->blocks = array( ); } protected function doDisplay(array $context, array $blocks = array()) { // line 1 echo "<section class=\"content\"> <div class=\"row\"> <div class=\"col-md-12\"> <div class=\"box box-danger\"> <div class=\"box-header with-border\"> <h3 class=\"box-title\">Create Activity Template</h3> <!--<div class=\"box-tools pull-right\"> \t\t\t\t\t\t\t\t<button type=\"button\" class=\"btn btn-box-tool\" data-widget=\"collapse\"><i class=\"fa fa-minus\"></i></button> \t\t\t\t\t\t\t\t<button type=\"button\" class=\"btn btn-box-tool\" data-widget=\"remove\"><i class=\"fa fa-times\"></i></button> \t\t\t\t\t\t\t</div>--> </div> <div class=\"box-body\"> <div class=\"row\"> <div class=\"col-md-6\"> <h4>Activity Template</h4> <input id=\"btnAdd\" type=\"button\" class=\"btn btn-danger btn-block btn-flat\" value=\"Add\" /> <br /> <br /> </div> <div class=\"col-md-6\"> <div id=\"activityTemplateContainer\"> <!-- Fields will be added here --> </div> <br/> <input id=\"btnGet\" type=\"button\" class=\"btn btn-danger btn-block btn-flat\" value=\"Get Values\" /> </div> </div> </div> <!-- /.box-body --> </div> </div> </div> </section> <script type=\"text/javascript\"> // \$(document).ready(function() { \$(\"#btnAdd\").bind(\"click\", function() { // alert(\"Add Button is clicked!!!\"); var div = \$(\"<div id='element' />\"); div.html(GetDynamicTextBox(\"\")); \$(\"#activityTemplateContainer\").append(div); }); var i = 0; \$(\"#btnGet\").bind(\"click\", function() { var values = []; \$(\"input[name=DynamicTextBox]\").each(function() { values[i] = \$(this).val(); i++; }); //console.log(values); var str_json = JSON.stringify(values); //console.log(\"Activity Template: str_json: \"+str_json); \$.ajax({ url: \"activity_template_action.php\", async: true, type: \"POST\", data: str_json, success: function() { //response = \$(this).responseText; //alert(resposne); //if(response == \"success\"){ \$(\"#alert\").addClass(\"in alert-success\"); //} }, error: function() { } }) }); /*\$(\"body\").on(\"click\", \".remove\", function() { alert(\"Remove called\"); \$(this).closest(\"div\").remove(); });*/ // \$(\"#remove\").click(function(){ // alert(\"Remove button is clicked!!!\"); // }); \$(\"#alertClose\").click(function() { \$(this).parent().removeClass('in'); }); // }); function GetDynamicTextBox(value) { return '<input name = \"DynamicTextBox\" type=\"text\" value = \"' + value + '\" placeholder=\"Attribute Name\"/>' + '<input type=\"button\" id=\"remove\" value=\"Remove\" class=\"btn btn-danger btn-block btn-flat\" onClick=\"removeElement(\\'activityTemplateContainer\\', \\'element\\');\" />' } function removeElement(parentDiv, childDiv){ if (childDiv == parentDiv) { alert(\"The parent div cannot be removed.\"); } else if (document.getElementById(childDiv)) { var child = document.getElementById(childDiv); var parent = document.getElementById(parentDiv); parent.removeChild(child); } else { alert(\"Child div has already been removed or does not exist.\"); return false; } } </script>"; } public function getTemplateName() { return "CommcloudVoiceBundle:Admin:createactivitytemplate.html.twig"; } public function getDebugInfo() { return array ( 19 => 1,); } } /* <section class="content">*/ /* <div class="row">*/ /* <div class="col-md-12">*/ /* <div class="box box-danger">*/ /* <div class="box-header with-border">*/ /* <h3 class="box-title">Create Activity Template</h3>*/ /* <!--<div class="box-tools pull-right">*/ /* <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>*/ /* <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>*/ /* </div>-->*/ /* </div>*/ /* <div class="box-body">*/ /* <div class="row">*/ /* <div class="col-md-6">*/ /* <h4>Activity Template</h4>*/ /* <input id="btnAdd" type="button" class="btn btn-danger btn-block btn-flat" value="Add" />*/ /* <br />*/ /* <br />*/ /* </div>*/ /* <div class="col-md-6">*/ /* <div id="activityTemplateContainer">*/ /* <!-- Fields will be added here -->*/ /* </div>*/ /* <br/>*/ /* <input id="btnGet" type="button" class="btn btn-danger btn-block btn-flat" value="Get Values" />*/ /* </div>*/ /* </div>*/ /* </div>*/ /* <!-- /.box-body -->*/ /* </div>*/ /* </div>*/ /* </div>*/ /* </section>*/ /* <script type="text/javascript">*/ /* // $(document).ready(function() {*/ /* $("#btnAdd").bind("click", function() {*/ /* // alert("Add Button is clicked!!!");*/ /* var div = $("<div id='element' />");*/ /* div.html(GetDynamicTextBox(""));*/ /* $("#activityTemplateContainer").append(div);*/ /* });*/ /* var i = 0;*/ /* $("#btnGet").bind("click", function() {*/ /* var values = [];*/ /* $("input[name=DynamicTextBox]").each(function() {*/ /* values[i] = $(this).val();*/ /* i++;*/ /* });*/ /* //console.log(values);*/ /* var str_json = JSON.stringify(values);*/ /* //console.log("Activity Template: str_json: "+str_json);*/ /* $.ajax({*/ /* url: "activity_template_action.php",*/ /* async: true,*/ /* type: "POST",*/ /* data: str_json,*/ /* success: function() {*/ /* //response = $(this).responseText;*/ /* //alert(resposne);*/ /* //if(response == "success"){*/ /* $("#alert").addClass("in alert-success");*/ /* //}*/ /* },*/ /* error: function() {*/ /* */ /* }*/ /* })*/ /* });*/ /* /*$("body").on("click", ".remove", function() {*/ /* alert("Remove called");*/ /* $(this).closest("div").remove();*/ /* });*//* */ /* // $("#remove").click(function(){*/ /* // alert("Remove button is clicked!!!");*/ /* // });*/ /* $("#alertClose").click(function() {*/ /* $(this).parent().removeClass('in');*/ /* });*/ /* // });*/ /* */ /* function GetDynamicTextBox(value) {*/ /* return '<input name = "DynamicTextBox" type="text" value = "' + value + '" placeholder="Attribute Name"/>' +*/ /* '<input type="button" id="remove" value="Remove" class="btn btn-danger btn-block btn-flat" onClick="removeElement(\'activityTemplateContainer\', \'element\');" />'*/ /* }*/ /* */ /* function removeElement(parentDiv, childDiv){*/ /* if (childDiv == parentDiv) {*/ /* alert("The parent div cannot be removed.");*/ /* }*/ /* else if (document.getElementById(childDiv)) {*/ /* var child = document.getElementById(childDiv);*/ /* var parent = document.getElementById(parentDiv);*/ /* parent.removeChild(child);*/ /* }*/ /* else {*/ /* alert("Child div has already been removed or does not exist.");*/ /* return false;*/ /* }*/ /* }*/ /* </script>*/
<?php use app\models\db\ProductOptionParam; use yii\widgets\Pjax; use yii\grid\GridView; use yii\helpers\Html; /* @var ProductOptionParam $optionParam */ /* @var \yii\web\View $this */ ?> <div class="modal-body"></div> <div class="modal-footer"> <button type="button" class="btn btn-primary" data-dismiss="modal">Сохранить</button> <button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button> </div>
<?php namespace ORO\Bundle\IssueBundle\Tests\Unit\Handler; use ORO\Bundle\IssueBundle\Form\Handler\IssueHandler; use ORO\Bundle\IssueBundle\Entity\Issue; use Oro\Bundle\UserBundle\Entity\User; class IssueHandlerTest extends \PHPUnit_Framework_TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject */ private $form; /** * @var \PHPUnit_Framework_MockObject_MockObject */ private $request; /** * @var \PHPUnit_Framework_MockObject_MockObject */ private $om; /** * @var User|\PHPUnit_Framework_MockObject_MockObject */ private $user; /** * @var Issue|\PHPUnit_Framework_MockObject_MockObject */ private $issue; /** * @var IssueHandler */ private $handler; protected function setUp() { $this->form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); $this->request = $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); $this->om = $this->getMock('Doctrine\Common\Persistence\ObjectManager'); $this->issue = $this->getMockBuilder('ORO\Bundle\IssueBundle\Entity\Issue') ->disableOriginalConstructor() ->getMock(); $this->user = $this->getMock('Oro\Bundle\UserBundle\Entity\User'); $this->handler = new IssueHandler($this->form, $this->request, $this->om); } public function testGoodRequest() { $this->form->expects($this->once()) ->method('setData'); $this->request->expects($this->once()) ->method('getMethod') ->will($this->returnValue('POST')); $this->form->expects($this->once()) ->method('submit'); $this->form->expects($this->once()) ->method('isValid') ->will($this->returnValue('true')); $this->om->expects($this->once()) ->method('persist') ->with($this->equalTo($this->issue)); $this->om->expects($this->once()) ->method('flush'); $this->assertTrue($this->handler->process($this->issue)); } public function testBadRequest() { $this->form->expects($this->once()) ->method('setData'); $this->request->expects($this->once()) ->method('getMethod') ->will($this->returnValue('GET')); $this->form->expects($this->never()) ->method('submit'); $this->form->expects($this->never()) ->method('isValid') ->will($this->returnValue(true)); $this->om->expects($this->never()) ->method('persist'); $this->om->expects($this->never()) ->method('flush'); $this->assertFalse($this->handler->process($this->issue)); } public function testNotValidForm() { $this->form->expects($this->once()) ->method('setData'); $this->request->expects($this->once()) ->method('getMethod') ->will($this->returnValue('POST')); $this->form->expects($this->once()) ->method('submit'); $this->form->expects($this->once()) ->method('isValid') ->will($this->returnValue(false)); $this->om->expects($this->never()) ->method('persist'); $this->om->expects($this->never()) ->method('flush'); $this->assertFalse($this->handler->process($this->issue)); } }
<?php /** * Axo - Console Micro-Framework * * @author Ampersa Ltd <contact@ampersa.co.uk> * @license MIT * @copyright © Copyright Ampersa Ltd 2017. */ namespace System\Commands; use System\Log\Log; use System\Console\Command; class NewCommand extends Command { protected $signature = 'new (Create a new command) {--namespace : The namespace to create the command in ?} {--description : A description for the command ?} {--directory : The directory to store the new command in ?} {name : The name of the command file} {command : The command signature to run the new command}'; /** * Run the program * @return Response */ public function run() { if (file_exists($this->option('dir', './commands').'/'.$this->argument('name').'.php')) { $this->error(sprintf('Command %s already exists', $this->argument('name'))); die; } if (!is_writable($this->option('dir', './commands'))) { $this->error(sprintf('Command directory (%s) is not writable', $this->argument('dir', '/commands'))); die; } $stubFile = file_get_contents(__DIR__.'/../Console/stubs/command.stub'); $variables = [ 'COMMAND_NAME' => $this->argument('name'), 'COMMAND_COMMAND' => $this->argument('command'), 'COMMAND_DESCRIPTION' => $this->option('description', ''), 'COMMAND_NAMESPACE' => $this->option('namespace', 'Commands'), ]; $newFileContents = $this->parseStubVariables($stubFile, $variables); // Create the new Command file in place and put contents $newFile = fopen($this->option('dir', './commands').'/'.$this->argument('name').'.php', 'w'); fwrite($newFile, $newFileContents); fclose($newFile); Log::info(sprintf('New Command %s created at %s', $this->argument('name'), $this->option('dir', './commands').'/'.$this->argument('name').'.php')); $this->output(sprintf('New command %s created', $this->argument('name'))); } /** * Parse the stub variables * @param string $stub * @param array $variables * @return string */ private function parseStubVariables($stub, $variables) { return preg_replace_callback('/\{\$([\w]+)\}/', function ($matches) use ($variables) { if (array_key_exists($matches[1], $variables)) { return $variables[$matches[1]]; } return null; }, $stub); } }
<?php /** * @package Joomla.Site * @subpackage mod_menu * * @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; // Include the menu functions only once JLoader::register('ModMenuHelper', __DIR__ . '/helper.php'); $list = ModMenuHelper::getList($params); $base = ModMenuHelper::getBase($params); $active = ModMenuHelper::getActive($params); $default = ModMenuHelper::getDefault(); $active_id = $active->id; $default_id = $default->id; $path = $base->tree; $showAll = $params->get('showAllChildren'); $class_sfx = htmlspecialchars($params->get('class_sfx'), ENT_COMPAT, 'UTF-8'); if (count($list)) { require JModuleHelper::getLayoutPath('mod_menu', $params->get('layout', 'default')); }
<?php namespace Database\Seeders; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Support\Facades\DB; use Illuminate\Database\Seeder; class UsersSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->insert([ 'username'=>'nmhien', 'password'=>'nmhien12', ]); DB::table('users')->insert([ 'username'=>'ntan', 'password'=>'ntan12', ]); DB::table('users')->insert([ 'username'=>'nmquan', 'password'=>'nmquan12', ]); } }
<?php namespace App; use Illuminate\Database\Eloquent\Model; class Permission extends Model { // public $timestamps = false; protected $fillable = [ 'user_id','permission_level', ]; }
<?php namespace App\Http\Controllers; use App\Models\Proveedor; use Illuminate\Http\Request; class ProveedorController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // return view("proveedores.listado", ["proveedores" => Proveedor::all()] ); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // return view("proveedores.crear"); } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $prov = new Proveedor(); $prov->nombre = $request->nombre; $prov->razon_social = $request->razonSocial; $prov->saldo = 0.0; $prov->save(); return redirect()->route("proveedores.index"); } /** * Display the specified resource. * * @param \App\Models\Proveedor $proveedor * @return \Illuminate\Http\Response */ public function show(Proveedor $proveedor) { // return view("proveedores.mostrar", ["proveedor"=>$proveedor]); } /** * Show the form for editing the specified resource. * * @param \App\Models\Proveedor $proveedor * @return \Illuminate\Http\Response */ public function edit(Proveedor $proveedor) { return view ("proveedores.actualizar", ["proveedor"=>$proveedor] ); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\Proveedor $proveedor * @return \Illuminate\Http\Response */ public function update(Request $request, Proveedor $proveedor) { // $proveedor->nombre = $request->nombre; $proveedor->razon_social = $request->razonSocial; $proveedor->save(); return redirect()->route("proveedors.index"); } /** * Remove the specified resource from storage. * * @param \App\Models\Proveedor $proveedor * @return \Illuminate\Http\Response */ public function destroy(Proveedor $proveedor) { // $proveedor->delete(); redirect()->route("proveedors.index"); } }
@include('admin.layout.header') <body> <div class="dashboard-main-wrapper"> @include('admin.layout.navbar') @include('admin.layout.sidebar') <div class="dashboard-wrapper"> <div class="container-fluid dashboard-content"> <div class="row"> <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12"> @include('admin.layout.errors') <div class="card"> <h5 class="card-header">Create New Category</h5> <div class="card-body"> <form action="{{route('admin.coupoun.postNew')}}" method="post"> @csrf <div class="form-group"> <label>Coupon Code </label> <input type="text" class="form-control" name="coupoun_code" value="{{old('coupoun_code') ?? ''}}" placeholder="Enter Coupoun Code Here" required> </div> <div class="form-group"> <label>Type</label> <select name="discount_type" class="form-control" required> <option value="percent">Percent</option> <option value="fixed">Fixed</option> </select> </div> <div class="form-group"> <label>Amount</label> <input type="number" class="form-control" name="discount_amount" value="{{old('amount') ?? ''}}" placeholder="Enter a Number Here ..." required> </div> <div class="form-group"> <label>Available Coupons <small>0 Means Infinite</small></label> <input type="number" class="form-control" name="amount" value="{{old('amount') ?? ''}}" placeholder="Enter a Number Here ..." required> </div> <button type="submit" class="btn btn-success btn-rounded">Submit</button> </form> </div> </div> </div> </div> </div> </div> <!-- ============================================================== --> <!-- end main wrapper --> <!-- ============================================================== --> </div> <!-- ============================================================== --> <!-- end main wrapper --> <!-- ============================================================== --> @include('admin.layout.scripts') </body> </html>
<?php namespace App\Http\Controllers\Common; use App\Facades\Staff; use App\Http\Controllers\Controller; use App\Http\Requests\UpdatePasswordRequest; use App\Models\StaffModel; class UpdatePasswordController extends Controller { private $staffModel; public function __construct(StaffModel $staffModel) { $this->staffModel = $staffModel; } public function getForm() { if (Staff::getChangedPassword()){ return redirect(route('_dashboard')); } if (!Staff::isLogged()) { return redirect(route('_login')); } return view('common.update_password'); } public function change(UpdatePasswordRequest $request) { $this->staffModel->updatePassword($request->input('password')); flash_success(trans('common/common.text_update_success')); return redirect(route('_dashboard')); } }
<?php /** * The template for displaying 404 pages (not found). * * @package nobs */ get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <section class="error-404 not-found"> <header class="page-header"> <h1 class="page-title"><a href="<?php echo get_option('home'); ?>"><?php _e( 'Umpikuja.', 'nobs' ); ?></a></h1> </header><!-- .page-header --> </section><!-- .error-404 --> </main><!-- #main --> </div><!-- #primary --> <?php get_footer(); ?>
<?php namespace Nemundo\Workflow\App\Wiki\Data\Hyperlink; use Nemundo\Model\Data\AbstractModelUpdate; class HyperlinkUpdate extends AbstractModelUpdate { /** * @var HyperlinkModel */ public $model; /** * @var string */ public $title; /** * @var string */ public $url; public function __construct() { parent::__construct(); $this->model = new HyperlinkModel(); } public function update() { $this->typeValueList->setModelValue($this->model->title, $this->title); $this->typeValueList->setModelValue($this->model->url, $this->url); parent::update(); } }
<?php class rexseo_robots { private $robots_txt; /** * CONSTRUCTOR */ public function rexseo_robots() { global $REX; $this->robots_txt = ''; } /** * SET CONTENT OF ROBOTS.TXT * * @return (string) robots.txt */ public function setContent($content) { global $REX; $out = ''; $langs = array_keys($REX['CLANG']); // get clang ids foreach ($langs as $lang) { $query = "SELECT id FROM ".$REX['TABLE_PREFIX']."article WHERE seo_noindex = '1' AND status = 1 AND clang = " . $lang; $sql = new rex_sql(); $sql->setQuery($query); for ($i = 1; $i <= $sql->getRows(); $i++) { $out .= "Disallow: /" . seo42::getTrimmedUrl($sql->getValue('id'), $lang) . "\r\n"; $sql->next(); } } if ($out != '') { $out = "User-agent: *" . "\r\n" . $out . "\r\n"; } if ($out == '' && $content == '') { $this->robots_txt = 'User-agent: *' . "\r\n" . 'Disallow:'; } else { $this->robots_txt = $out . $content; } } /** * INSERT SITEMAP LINK INTO ROBOTS.TXT * * @return (string) robots.txt */ public function addSitemapLink() { $this->robots_txt = rtrim($this->robots_txt, "\r\n"); $this->robots_txt .= "\r\n" . PHP_EOL.'Sitemap: '.seo42::getBaseUrl().'sitemap.xml'; } /** * RETURN ROBOTS.TXT * * @return (string) robots.txt */ public function get() { return $this->robots_txt; } /** * SEND ROBOTS.TXT */ public function send() { $robots = self::get(); while (ob_get_level()) { ob_end_clean(); } header('Content-Type: text/plain; charset=utf-8'); header('Content-Length: '.strlen($robots)); // no indexing header('X-Robots-Tag: noindex, noarchive'); // no caching header('Cache-Control: must-revalidate, proxy-revalidate, post-check=0, pre-check=0, private'); header('Pragma: no-cache'); header('Expires: -1'); echo $robots; die(); } }
<?php /** * Created by PhpStorm. * User: Administrator * Date: 2018/5/9 0009 * Time: 下午 12:00 */ namespace app\admin\model; use think\Model; use think\Validate; use app\lib\upload\uploadExcel; use app\lib\enum\OrderStatusEnum; ini_set('max_execution_time', '180'); class UploadTao extends Model { public function OrderList($file, $typeId) { $result = (new UploadExcel())->UploadFile($file, '买家会员名'); if ($result['valid'] == 4) { /** 循环读取每个单元格的数据 */ $sheet = $result['data']['sheet']; $where = array(); $i = 0; $j = 0;//成功 $k = 0;//已上传 $g = 0;//更新 for ($row = 2; $row <= $result['data']['highestRow']; $row++) {//行数是以第1行开始,这里示例中excel有3列字段 $orderId = $sheet->getCell('A' . $row)->getValue(); $actualPay = $sheet->getCell('I' . $row)->getValue(); $BuyerName = $sheet->getCell('B' . $row)->getValue(); $phone = $sheet->getCell('Q' . $row)->getValue(); $BuyerMessage = $sheet->getCell('L' . $row)->getValue(); $address = $sheet->getCell('N' . $row)->getValue(); $orderPayTime = $sheet->getCell('S' . $row)->getValue(); $orderStates = $sheet->getCell('K' . $row)->getValue(); $refundM = $sheet->getCell('AX' . $row)->getValue(); $orderId = ltrim($orderId, '="'); $orderId = rtrim($orderId, '"'); $phone = ltrim($phone, "'"); $where[$row]['tb_orderid'] = $orderId; $where[$row]['tb_actualpay'] = $actualPay; $where[$row]['tb_Buyername'] = $BuyerName; $where[$row]['tb_Buyermessage'] = $BuyerMessage; $where[$row]['tb_address'] = $address; $where[$row]['tb_orderpaytime'] = $orderPayTime; $where[$row]['tb_phone'] = $phone; $where[$row]['tb_refundm'] = $refundM; $where[$row]['createtime'] = time(); $where[$row]['type_id'] = $typeId; //states 1.买家已付款,等待卖家发货 2.卖家已发货,等待买家确认 3. 交易关闭 4.交易成功 5.退款 $orderStates = (new OrderStatusEnum())->getOrderStates($orderStates); $where[$row]['states'] = $orderStates; if ($where && $orderPayTime != "") { $j++; $res = db('tborder')->where('tb_orderid', $orderId)->field('tb_id,states')->find(); if ($where[$row]['states'] != $res['states']) { $g++; db('tborder')->where('tb_orderid', $orderId)->update(['states' => $where[$row]['states']]); } //halt($res); if (!isset($res['tb_id'])) { $i++; db('tborder')->insert($where[$row]); } else { $k++; //db('tborder')->where('tb_orderid',$orderId)->save($where[$row]); } } } if ($i != 0) { //return ['valid'=>4,'msg'=>'添加'.$textName.'数据成功']; return ['valid' => 4, 'msg' => '共上传' . $j . '条数据,其中' . $i . '条成功上传,' . $k . '条数据已上传过' . $g . '条数据更新成功']; } else { return ['valid' => 1, 'msg' => '共上传' . $j . '条数据,其中' . $i . '条成功上传,' . $k . '条数据已上传过' . $g . '条数据更新成功']; } } else { return $result; } } public function OrderOver($file, $typeId) { $result = (new UploadExcel())->UploadFile($file, '买家会员名'); if ($result['valid'] == 4) { /** 循环读取每个单元格的数据 */ $sheet = $result['data']['sheet']; $where = array(); $i = 0; $j = 0;//成功 $k = 0;//已上传 $g = 0;//更新 for ($row = 2; $row <= $result['data']['highestRow']; $row++) {//行数是以第1行开始,这里示例中excel有3列字段 $orderId = $sheet->getCell('A' . $row)->getValue(); $orderStates = $sheet->getCell('K' . $row)->getValue(); $orderId = ltrim($orderId, '="'); $orderId = rtrim($orderId, '"'); $where[$row]['tb_orderid'] = $orderId; $where[$row]['createtime'] = time(); $where[$row]['type_id'] = $typeId; //states 1.买家已付款,等待卖家发货 2.卖家已发货,等待买家确认 3. 交易关闭 4.交易成功 5.退款 $orderStates = (new OrderStatusEnum())->getOrderStates($orderStates); if ($orderStates == 4) { $orderStates = 6; } $where[$row]['states'] = $orderStates; if ($where) { $j++; $res = db('tborder')->where('tb_orderid', $orderId)->field('tb_id,states')->find(); if ($where[$row]['states'] != $res['states']) { $g++; db('tborder')->where('tb_orderid', $orderId)->update(['states' => $where[$row]['states']]); } //halt($res); if (!isset($res['tb_id'])) { $i++; db('tborder')->insert($where[$row]); } else { $k++; db('tborder')->where('tb_orderid', $orderId)->save($where[$row]); } } } if ($i != 0) { //return ['valid'=>4,'msg'=>'添加'.$textName.'数据成功']; return ['valid' => 4, 'msg' => '共上传' . $j . '条数据,其中' . $i . '条成功上传' . $k . '条数据已上传过' . $g . '条数据更新成功']; } else { return ['valid' => 1, 'msg' => '共上传' . $j . '条数据,其中' . $i . '条成功上传' . $k . '条数据已上传过' . $g . '条数据更新成功']; } } else { return $result; } } public function OrderType($file, $typeId) { $result = (new UploadExcel())->UploadFile($file, '标题'); if ($result['valid'] == 4) { /** 循环读取每个单元格的数据 */ $sheet = $result['data']['sheet']; $where = array(); $i = 0; $k = 0; $j = 0; for ($row = 2; $row <= $result['data']['highestRow']; $row++) { $orderId = $sheet->getCell('A' . $row)->getValue(); $title = $sheet->getCell('B' . $row)->getValue(); $number = $sheet->getCell('D' . $row)->getValue(); $orderId = ltrim($orderId, '="'); $orderId = rtrim($orderId, '"'); $where[$row]['tbt_orderid'] = $orderId; $where[$row]['tbt_title'] = $title; $where[$row]['tbt_purchasen'] = $number; $where[$row]['createtime'] = time(); $where[$row]['type_id'] = $typeId; //halt($where); if ($where) { $j++; $res = db('tbtype')->where('tbt_orderid', $orderId)->where('tbt_title', $title)->field('tbt_id')->find(); //halt($res); if (!isset($res['tbt_id'])) { $i++; db('tbtype')->insert($where[$row]); } else { $k++; } } } if ($i != 0) { //return ['valid'=>4,'msg'=>'添加'.$textName.'数据成功']; return ['valid' => 4, 'msg' => '共上传' . $j . '条数据,其中' . $i . '条成功上传' . $k . '条数据已上传过']; } else { return ['valid' => 1, 'msg' => '共上传' . $j . '条数据,其中' . $i . '条成功上传' . $k . '条数据已上传过']; } } else { return $result; } } public function OrderEvaluate($file) { $result = (new UploadExcel())->UploadFile($file, '会员状态'); if ($result['valid'] == 4) { /** 循环读取每个单元格的数据 */ $sheet = $result['data']['sheet']; $where = array(); $i = 0; $k = 0; $j = 0; for ($row = 2; $row <= $result['data']['highestRow']; $row++) { $name = $sheet->getCell('A' . $row)->getValue(); $releaseTime = $sheet->getCell('D' . $row)->getValue(); $evaluate = $sheet->getCell('E' . $row)->getValue(); $where[$row]['tbm_name'] = $name; $where[$row]['tbm_time'] = $releaseTime; $where[$row]['tbm_text'] = $evaluate; $where[$row]['createtime'] = time(); //halt($where); if ($where) { $j++; $res = db('tbmessage')->where('tbm_time', $releaseTime)->where('tbm_name', $name)->field('tbm_id')->find(); //halt($res); if (!isset($res['tb_id'])) { $i++; db('tbmessage')->insert($where[$row]); } else { $k++; } } } if ($i != 0) { //return ['valid'=>4,'msg'=>'添加'.$textName.'数据成功']; return ['valid' => 4, 'msg' => '共上传' . $j . '条数据,其中' . $i . '条成功上传' . $k . '条数据已上传过']; } else { return ['valid' => 1, 'msg' => '共上传' . $j . '条数据,其中' . $i . '条成功上传' . $k . '条数据已上传过']; } } else { return $result; } } }
<?php return [ 'dashboard' => 'Tablero', 'administration' => 'Admin', 'flight' => 'Vuelo|Vuelos', 'livemap' => 'Mapa en vivo', 'pilot' => 'Piloto|Pilotos', 'pirep' => 'PIREP|PIREPs', 'newestpilots' => 'Nuevos pilotos', 'profile' => 'Perfil', 'email' => 'Email', 'pilot_id' => 'Pilot ID', 'register' => 'Registrarse', 'login' => 'Iniciar sesión', 'logout' => 'Cerrar sesión', 'timezone' => 'Zona horaria', 'country' => 'País', 'download' => 'Descarga|Descargas', 'from' => 'de', 'to' => 'a', 'state' => 'Situación', 'status' => 'Estado', 'departure' => 'Salida', 'arrival' => 'Llegada', 'aircraft' => 'Aeronave', 'airline' => 'Aerolínea', 'subfleet' => 'Subfleet', 'distance' => 'Distancia', 'fuel' => 'Combustible', 'metar' => 'METAR', 'hour' => 'Hora|Horas', 'minute' => 'Minuto|Minutos', 'note' => 'Nota|Notas', 'field' => 'Campo|Campos', 'name' => 'Nombre', 'value' => 'Valor|Valores', 'remark' => 'Observación|Observaciones', 'find' => 'Encontrar', 'reset' => 'Reiniciar', 'submit' => 'Enviar', 'edit' => 'Editar', 'close' => 'Cerrar', 'whoops' => 'Ups', 'hello' => 'Hola', 'regards' => 'Saludos', 'rightsreserved' => 'Todos los derechos reservados', 'active' => 'Activo', 'inactive' => 'Inactivo', 'yes' => 'Sí', 'no' => 'No', 'or' => 'o', 'days' => [ 'mon' => 'lunes', 'tues' => 'martes', 'wed' => 'miércoles', 'thurs' => 'jueves', 'fri' => 'viernes', 'sat' => 'sábado', 'sun' => 'domingo', ], ];
<?php namespace FilippoToso\Travelport\Vehicle; class BillingPointOfSaleInfo { /** * @var string $OriginApplication */ public $OriginApplication = null; /** * @var anonymous398 $CIDBNumber */ public $CIDBNumber = null; /** * @param string $OriginApplication * @param anonymous398 $CIDBNumber */ public function __construct($OriginApplication = null, $CIDBNumber = null) { $this->OriginApplication = $OriginApplication; $this->CIDBNumber = $CIDBNumber; } /** * @return string */ public function getOriginApplication() { return $this->OriginApplication; } /** * @param string $OriginApplication * @return \FilippoToso\Travelport\Vehicle\BillingPointOfSaleInfo */ public function setOriginApplication($OriginApplication) { $this->OriginApplication = $OriginApplication; return $this; } /** * @return anonymous398 */ public function getCIDBNumber() { return $this->CIDBNumber; } /** * @param anonymous398 $CIDBNumber * @return \FilippoToso\Travelport\Vehicle\BillingPointOfSaleInfo */ public function setCIDBNumber($CIDBNumber) { $this->CIDBNumber = $CIDBNumber; return $this; } }
<div class="block description-product"> <div class="subtitle">Lista de ventas</div> @if($sales->count()) <table class="table"> <thead> <tr> <th>Tipo</th> <th>Folio</th> <th>Fecha de venta</th> </tr> </thead> <tbody> @foreach($sales as $sale) <tr class="text-center"> <td class="text-left">{{ $sale->type }}</td> <td> <a href="{{ route('sale.show', [$sale->folio, $sale->id]) }}"> {{ $sale->folio }} </a> </td> <td>{{ $sale->created_at->format('h:m:i A / d-m-Y') }}</td> </tr> @endforeach </tbody> </table> {{ $sales->links() }} @else <p class="title-clear">No se ha registrado ninguna venta.</p> @endif </div>
<?php /** * Anything that implements HiddenClass won't be shown in user-interface elements. For example, * DataObjects that implement HiddenClass won't be showing in the "new page" dropdown. * @package framework */ interface HiddenClass { }
<footer class="footer has-cards"> <div class="container"> <div class="row row-grid align-items-center my-md"> <!-- Footer Title --> <div class="col-lg-6"> <h3 class="text-primary font-weight-light mb-2">شكرًا على دعمنا!</h3> <h4 class="mb-0 font-weight-light">يمكنك متابعتنا على هذه المنصات أيضًا.</h4> </div> <!-- Social Media Links --> <div class="col-lg-6 text-lg-center btn-wrapper text-center"> <a target="_blank" href="https://twitter.com/RoyalAnimeCom" class="btn btn-neutral btn-icon-only btn-twitter btn-round btn-lg" data-toggle="tooltip" data-original-title="Follow us" rel="external nofollow" title="twitter"> <i class="fa fa-twitter"></i> </a> <a target="_blank" href="https://www.facebook.com/RoyalAnimeOfficial" class="btn btn-neutral btn-icon-only btn-facebook btn-round btn-lg" data-toggle="tooltip" data-original-title="Like us" rel="external nofollow" title="facebook"> <i class="fa fa-facebook-square"></i> </a> <a target="_blank" href="https://pinterest.com/RoyalAnimeOfficial" class="btn btn-neutral btn-icon-only btn-pinterest btn-round btn-lg" data-toggle="tooltip" data-original-title="Follow Us" rel="external nofollow" title="pinterest"> <i class="fa fa-pinterest"></i> </a> </div> </div> <hr> <!-- Footer Links --> <div class="row align-items-center justify-content-md-between"> <div class="col-md-6 text-center text-md-left"> <!-- Copyrights and Website Link --> <div class="copyright"> {{ now()->year }} &copy; <a href="/" title="الصفحة الرئيسية">Royal Anime</a> </div> </div> <!-- Main Links --> <div class="col-md-6 text-center text-md-left"> <ul class="nav nav-footer justify-content-center"> <li class="nav-item"> <a href="/" class="nav-link mx-3" title="الصفحة الرئيسية">رويال أنمي</a> </li> <li class="nav-item"> <a href="/about" class="nav-link mx-3" title="المزيد عنا">المزيد عنا</a> </li> <li class="nav-item"> <a href="/blog" class="nav-link mx-3" title="المدونة">المدونة</a> </li> </ul> </div> </div> </div> </footer>
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Documents extends Model { public function docdetails(){ return $this->hasMany(DocumentDetail::class, 'document_no','document_no'); } }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- CSRF Token --> <meta name="csrf-token" content="{{ csrf_token() }}"> <title>{{ config('app.name', 'Set The Title') }}</title> <!-- Bootstrap --> <link rel="stylesheet" href="/css/bootstrap.min.css"/> <link href="/css/sidemenu.css" rel="stylesheet"> <link href='http://fonts.googleapis.com/css?family=Lato&subset=latin,latin-ext' rel='stylesheet' type='text/css'> <link rel="icon" href="/images/favicon.png" /> <!-- Scripts --> <script> window.Laravel = {!! json_encode([ 'csrfToken' => csrf_token(), ]) !!}; </script> </head> <body> <div class="register"> <div class="wrap"> <nav class="nav-bar navbar-inverse" role="navigation"> <div id ="top-menu" class="container-fluid active"> <a class="navbar-brand" href="#">Brand</a> <ul class="nav navbar-nav"> <form id="qform" class="navbar-form pull-left" role="search"> <input type="text" class="form-control" placeholder="Search" /> </form> <li class="dropdown movable"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="caret"></span><span class="fa fa-4x fa-child"></span></a> <ul class="dropdown-menu" role="menu"> <li><a href="#"><span class="fa fa-user"></span>My Profile</a></li> <li><a href="#"><span class="fa fa-gear"></span>Settings</a></li> <li class="divider"></li> <li><a href="#"><span class="fa fa-power-off"></span>Logout</a></li> </ul> </li> </ul> </div> </nav> <aside id="side-menu" class="aside" role="navigation"> <ul class="nav nav-list accordion"> <li class="nav-header"> <div class="link"><i class="fa fa-lg fa-globe"></i>Portal<i class="fa fa-chevron-down"></i></div> <ul class="submenu"> <li><a href="#">Dashboard</a></li> <li><a href="#">Settings</a></li> <li><a href="#">Administration</a></li> </ul> </li> <li class="nav-header"> <div class="link"><i class="fa fa-lg fa-users"></i>Users<i class="fa fa-chevron-down"></i></div> <ul class="submenu"> <li><a href="#">Users</a></li> <li><a href="#">New User</a></li> </ul> </li> <li class="nav-header"> <div class="link"><i class="fa fa-cloud"></i>Sites<i class="fa fa-chevron-down"></i></div> <ul class="submenu"> <li><a href="#">Search Sites</a></li> <li><a href="#">New Site</a></li> <li><a href="#">Jobs</a></li> </ul> </li> <li class="nav-header"> <div class="link"><i class="fa fa-lg fa-map-marker"></i>Zones<i class="fa fa-chevron-down"></i></div> <ul class="submenu"> <li><a href="#">Search Zones</a></li> <li><a href="#">New Zone</a></li> </ul> </li> <li class="nav-header"> <div class="link"><i class="fa fa-lg fa-file-image-o"></i>Reports<i class="fa fa-chevron-down"></i></div> <ul class="submenu"> <li><a href="#">Entries</a></li> <li><a href="#">Redirects</a></li> <li><a href="#">Pingbacks</a></li> <li><a href="#">Tags</a></li> </ul> </li> </ul> </aside> <!--Body content--> <div class="content"> <div class="top-bar"> <a href="#menu" class="side-menu-link burger"> <span class='burger_inside' id='bgrOne'></span> <span class='burger_inside' id='bgrTwo'></span> <span class='burger_inside' id='bgrThree'></span> </a> </div> <section class="content-inner"> <h2>Sample</h2> <h3>A responsive Top and Side Menu, resize your browser to find out</h3> </section> </div> </div> @yield('content') </div> <!-- Scripts --> <script src="/js/app.js"></script> <script src="/js/jquery-3.2.0.min.js"></script> <script src="/js/bootstrap.min.js"></script> </body> </html>
<div class="page view"> <h2><?php echo __('Balance');?></h2> Paypal-Account: <?php echo Configure::read('PayPal.username')?><br /> Live Mode: <?php echo $this->Format->yesNo(Configure::read('PayPal.live')); ?> <h3>Current Balance</h3> <?php echo $this->Numeric->money($balance['AMOUNT']); echo pre($balance); ?> <h3>Logo</h3> <?php if (empty($image)) { echo 'kein Logo'; } else { echo $this->Html->image($image['url']); //echo '<div>'; if ($image['result']) { echo 'Bild ist OK'; } else { echo 'Bild hat die falschen Maße'; } //echo '</div>'; } ?> </div>
<div class="title"> <h2><?php echo $player['User'][$userFields['username']]; ?></h2> </div> <div class="container"> <dl class="dl-horizontal"> <dt><?php echo __d('tournament', 'Points'); ?></dt> <dd><?php echo number_format($player['Player']['points']); ?></dd> <dt><?php echo __d('tournament', 'Wins'); ?></dt> <dd><?php echo number_format($player['Player']['wins']); ?></dd> <dt><?php echo __d('tournament', 'Losses'); ?></dt> <dd><?php echo number_format($player['Player']['losses']); ?></dd> <dt><?php echo __d('tournament', 'Ties'); ?></dt> <dd><?php echo number_format($player['Player']['ties']); ?></dd> </dl> <?php if (!empty($player['Team'])) { echo $this->element('panels/player_teams'); } if (!empty($player['Event'])) { echo $this->element('panels/player_events'); } ?> </div>
<?php namespace App\Http\Resources; use Illuminate\Http\Resources\Json\JsonResource; use App\Http\Resources\ServicioCollection; class CitaResource extends JsonResource { /** * Transform the resource into an array. * * @param \Illuminate\Http\Request $request * @return array */ public function toArray($request) { return [ 'id' => $this->id, 'horaInicio' => $this->hora_inicio, 'horaTermina' => $this->horaTermina, 'duracion' => $this->duracion(), 'servicios' => new ServicioCollection($this->servicios), //hacer opcion para que no retorne los peluqueros 'nombreCliente' => $this->nombre, 'peluquero' => $this->peluquero->nombre, ]; } }
<?php namespace Psalm\Internal\Analyzer\Statements; use PhpParser; use Psalm\Internal\Analyzer\FunctionLikeAnalyzer; use Psalm\Internal\Analyzer\StatementsAnalyzer; use Psalm\Internal\Analyzer\Statements\Expression\Fetch\VariableFetchAnalyzer; use Psalm\CodeLocation; use Psalm\Context; use Psalm\Issue\InvalidGlobal; use Psalm\IssueBuffer; use function is_string; class GlobalAnalyzer { public static function analyze( StatementsAnalyzer $statements_analyzer, PhpParser\Node\Stmt\Global_ $stmt, Context $context, ?Context $global_context ) : void { if (!$context->collect_initializations && !$global_context) { if (IssueBuffer::accepts( new InvalidGlobal( 'Cannot use global scope here', new CodeLocation($statements_analyzer, $stmt) ), $statements_analyzer->getSource()->getSuppressedIssues() )) { // fall through } } $source = $statements_analyzer->getSource(); $function_storage = $source instanceof FunctionLikeAnalyzer ? $source->getFunctionLikeStorage($statements_analyzer) : null; foreach ($stmt->vars as $var) { if ($var instanceof PhpParser\Node\Expr\Variable) { if (is_string($var->name)) { $var_id = '$' . $var->name; if ($var->name === 'argv' || $var->name === 'argc') { $context->vars_in_scope[$var_id] = VariableFetchAnalyzer::getGlobalType($var_id); } elseif (isset($function_storage->global_types[$var_id])) { $context->vars_in_scope[$var_id] = clone $function_storage->global_types[$var_id]; $context->vars_possibly_in_scope[$var_id] = true; } else { $context->vars_in_scope[$var_id] = $global_context && $global_context->hasVariable($var_id, $statements_analyzer) ? clone $global_context->vars_in_scope[$var_id] : VariableFetchAnalyzer::getGlobalType($var_id); $context->vars_possibly_in_scope[$var_id] = true; $context->byref_constraints[$var_id] = new \Psalm\Internal\ReferenceConstraint(); } } } } } }
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('first_name')->nullable(); $table->string('last_name')->nullable(); $table->string('username')->nullable(); $table->string('chat_id'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } }
<?php namespace PostFinanceCheckout\Webhook; /** * Webhook processor to handle transaction state transitions. */ class Transaction extends AbstractOrderRelated { /** * * @see AbstractOrderRelated::load_entity() * @return \PostFinanceCheckout\Sdk\Model\Transaction */ protected function loadEntity(Request $request){ $transaction_service = new \PostFinanceCheckout\Sdk\Service\TransactionService(\PostFinanceCheckoutHelper::instance($this->registry)->getApiClient()); return $transaction_service->read($request->getSpaceId(), $request->getEntityId()); } protected function getOrderId($transaction){ /* @var \PostFinanceCheckout\Sdk\Model\Transaction $transaction */ return $transaction->getMerchantReference(); } protected function getTransactionId($transaction){ /* @var \PostFinanceCheckout\Sdk\Model\Transaction $transaction */ return $transaction->getId(); } protected function processOrderRelatedInner(array $order_info, $transaction){ /* @var \PostFinanceCheckout\Sdk\Model\Transaction $transaction */ $transaction_info = \PostFinanceCheckout\Entity\TransactionInfo::loadByOrderId($this->registry, $order_info['order_id']); \PostFinanceCheckoutHelper::instance($this->registry)->ensurePaymentCode($order_info, $transaction); if ($transaction->getState() != $transaction_info->getState()) { switch ($transaction->getState()) { case \PostFinanceCheckout\Sdk\Model\TransactionState::CONFIRMED: $this->processing($transaction, $order_info); break; case \PostFinanceCheckout\Sdk\Model\TransactionState::PROCESSING: $this->confirm($transaction, $order_info); break; case \PostFinanceCheckout\Sdk\Model\TransactionState::AUTHORIZED: $this->authorize($transaction, $order_info); break; case \PostFinanceCheckout\Sdk\Model\TransactionState::DECLINE: $this->decline($transaction, $order_info); break; case \PostFinanceCheckout\Sdk\Model\TransactionState::FAILED: $this->failed($transaction, $order_info); break; case \PostFinanceCheckout\Sdk\Model\TransactionState::FULFILL: if ($transaction_info->getState() != 'AUTHORIZED' && $transaction_info->getState() != 'COMPLETED') { $this->authorize($transaction, $order_info); } $this->fulfill($transaction, $order_info); break; case \PostFinanceCheckout\Sdk\Model\TransactionState::VOIDED: $this->voided($transaction, $order_info); break; case \PostFinanceCheckout\Sdk\Model\TransactionState::COMPLETED: $this->waiting($transaction, $order_info); break; default: // Nothing to do. break; } } \PostFinanceCheckout\Service\Transaction::instance($this->registry)->updateTransactionInfo($transaction, $order_info['order_id']); } protected function processing(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_processing_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_processing')); } protected function confirm(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_processing_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_confirm')); } protected function authorize(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_authorized_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_authorize')); } protected function waiting(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_completed_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_waiting')); } protected function decline(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_decline_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_decline')); } protected function failed(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_failed_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_failed')); } protected function fulfill(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_fulfill_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_fulfill')); } protected function voided(\PostFinanceCheckout\Sdk\Model\Transaction $transaction, array $order_info){ \PostFinanceCheckoutHelper::instance($this->registry)->addOrderHistory($order_info['order_id'], 'postfinancecheckout_voided_status_id', \PostFinanceCheckoutHelper::instance($this->registry)->getTranslation('message_webhook_voided')); } }
<?php namespace App; use Illuminate\Database\Eloquent\Model; class SaleProduct extends Model { protected $fillable = ['sale_id', 'product_id', 'quantity', 'unit_price']; public function sale() { $this->belongsTo('App\Sale'); } }
<?php namespace Oro\Bundle\LayoutBundle\Tests\Unit\Layout\Extension; use Oro\Bundle\LayoutBundle\Layout\Extension\ThemeConfiguration; use Oro\Bundle\LayoutBundle\Layout\Extension\ThemeConfigurationProvider; use Oro\Bundle\LayoutBundle\Tests\Unit\Stubs\Bundles\TestBundle\TestBundle; use Oro\Bundle\LayoutBundle\Tests\Unit\Stubs\Bundles\TestBundle2\TestBundle2; use Oro\Component\Config\CumulativeResourceManager; use Oro\Component\Testing\Assert\ArrayContainsConstraint; use Oro\Component\Testing\TempDirExtension; class ThemeConfigurationProviderTest extends \PHPUnit\Framework\TestCase { use TempDirExtension; /** @var ThemeConfigurationProvider */ private $configurationProvider; /** @var string */ private $cacheFile; /** * {@inheritdoc} */ protected function setUp(): void { $bundle1 = new TestBundle(); $bundle2 = new TestBundle2(); CumulativeResourceManager::getInstance() ->clear() ->setBundles([ $bundle1->getName() => get_class($bundle1), $bundle2->getName() => get_class($bundle2) ]); $this->cacheFile = $this->getTempFile('ConfigurationProvider'); $this->configurationProvider = new ThemeConfigurationProvider( $this->cacheFile, false, new ThemeConfiguration(), '[a-zA-Z][a-zA-Z0-9_\-:]*' ); } public function testGetThemeNames() { $result = $this->configurationProvider->getThemeNames(); sort($result); $this->assertEquals(['base', 'oro-black'], $result); } public function testGetThemeDefinitionForUnknownTheme() { $this->assertNull( $this->configurationProvider->getThemeDefinition('unknown') ); } public function testGetThemeDefinitionForEmptyTheme() { $this->assertEquals( [ 'label' => 'Base theme', 'groups' => [], 'image_placeholders' => [] ], $this->configurationProvider->getThemeDefinition('base') ); } public function testGetThemeDefinition() { $expected = [ 'label' => 'Oro Black theme', 'description' => 'Oro Black theme description', 'groups' => ['another'], 'icon' => 'oro-black.ico', 'image_placeholders' => [], 'config' => [ 'assets' => [ 'css' => [ 'inputs' => ['bundles/test/css/scss/main.scss'], 'filters' => ['some_filter'] ] ], 'images' => [ 'types' => [ 'main' => [ 'label' => 'main image type', 'dimensions' => ['original', 'popup'], 'max_number' => 1 ] ], 'dimensions' => [ 'original' => [ 'width' => null, 'height' => null, 'options' => [ 'applyProductImageWatermark' => true ] ], 'popup' => [ 'width' => 610, 'height' => 610, 'options' => [ 'applyProductImageWatermark' => false ] ] ] ], 'page_templates' => [ 'templates' => [ [ 'label' => 'Some label', 'description' => null, 'key' => 'some_key', 'route_name' => 'some_route_name', 'enabled' => null, 'screenshot' => null ], [ 'label' => 'Some label (disabled)', 'description' => 'Disabled', 'key' => 'some_key_disabled', 'route_name' => 'some_route_name_disabled', 'enabled' => false, 'screenshot' => null ], [ 'label' => 'Two columns page', 'description' => 'Two columns template', 'key' => 'two-columns', 'route_name' => 'oro_two_columns_view', 'enabled' => null, 'screenshot' => null ] ], 'titles' => [ 'route_1' => 'Title for route 1', 'route_2' => 'Title for route 2', 'oro_two_columns_view' => 'Two Columns Page' ] ], 'extra_config' => [ 'label' => 'Sample label' ] ] ]; $actual = $this->configurationProvider->getThemeDefinition('oro-black'); // use both ArrayContainsConstraint and assertEquals to strict check of each value in array $this->assertThat($actual, new ArrayContainsConstraint($expected)); self::assertEquals($expected, $actual); } }
<?php namespace App\Jobs; use App\Models\Order; use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; class CloseOrder implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; protected $order; /** * Create a new job instance. * * @return void */ public function __construct(Order $order, $delay) { $this->order = $order; // 设置延迟的时间,delay() 方法的参数代表多少秒之后执行 $this->delay($delay); } /** * Execute the job. * * @return void */ // 定义这个任务类具体的执行逻辑 // 当队列处理器从队列中取出任务时,会调用 handle() 方法 public function handle() { if ($this->order->paid_at) { return; } // 通过事务执行 sql \DB::transaction(function (){ // 将订单的 closed 字段标记为 true,即关闭订单 $this->order->update([ 'closed' => true ]); // 循环遍历订单中的商品 SKU,将订单中的数量加回到 SKU 的库存中去 foreach ($this->order->items as $item) { $item->productSku->addStock($item->amount); } if ($this->order->couponCode) { $this->order->couponCode->changeUsed(false); } }); } }
<?php /** * Pi Engine (http://pialog.org) * * @link http://code.pialog.org for the Pi Engine source repository * @copyright Copyright (c) Pi Engine http://pialog.org * @license http://pialog.org/license.txt BSD 3-Clause License */ /** * Module meta * * @author Taiwen Jiang <taiwenjiang@tsinghua.org.cn> */ return array( // Module meta 'meta' => array( // Module title, required 'title' => _a('System'), // Description, for admin, optional 'description' => _a('For administration of core functions of the site.'), // Version number, required 'version' => '3.5.0', // Distribution license, required 'license' => 'New BSD', // Logo image, for admin, optional 'logo' => 'image/logo.png', // Readme file, for admin, optional 'readme' => 'docs/readme.txt', // Direct download link, available for wget, optional //'download' => 'http://dl.xoopsengine.org/core', // Demo site link, optional 'demo' => 'http://pialog.org', // Module is ready for clone? Default as false 'clonable' => false, //font-awesome: http://fontawesome.io/icons/ 'icon' => 'fa-tachometer' ), // Author information 'author' => array( // Author full name, required 'Dev' => 'Taiwen Jiang; Liu Chuang; Liaowei; Zongshu Lin', 'Architect' => '@taiwen', 'UI/UE' => '@zhangsimon, @loidco, @voltan, Zeng Long', 'QA' => '@MarcoXoops, Zhang Hua, @lavenderli', // Email address, optional 'Email' => 'taiwenjiang@tsinghua.org.cn', // Website link, optional 'Website' => 'http://pialog.org', // Credits and aknowledgement, optional 'Credits' => 'Pi Engine Team; Zend Framework Team; EEFOCUS Team.' ), // Resource 'resource' => array( // Database meta 'database' => array( // SQL schema/data file 'sqlfile' => 'sql/mysql.sql', ), // System config 'config' => 'config.php', // Permission specs 'permission' => 'permission.php', // Block definition 'block' => 'block.php', // Event specs 'event' => 'event.php', // View pages 'page' => 'page.php', // Navigation definition 'navigation' => 'nav.php', // Routes, first in last out; bigger priority earlier out 'route' => 'route.php', ), );
<?php /** * This file is part of the TangoManCMS package. * * Copyright (c) 2018 Matthias Morin <matthias.morin@gmail.com> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace AppBundle\Form\Admin; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Doctrine\ORM\EntityRepository; /** * Class AdminEditGalleryType * * @author Matthias Morin <matthias.morin@gmail.com> */ class AdminEditGalleryType extends AbstractType { /** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add( 'title', TextType::Class, [ 'label' => 'Titre', ] ) ->add( 'subtitle', TextType::Class, [ 'label' => 'Sous-titre', 'required' => false, ] ) ->add( 'summary', TextareaType::Class, [ 'label' => 'Description', 'required' => false, ] ) ->add( 'slug', TextType::Class, [ 'label' => 'Slug', 'required' => false, ] ) ->add( 'tags', EntityType::class, [ 'label' => 'Étiquette', 'class' => 'AppBundle:Tag', // 'empty_data' => null, 'multiple' => true, 'expanded' => true, 'required' => false, 'query_builder' => function (EntityRepository $em) { return $em->createQueryBuilder('t'); }, ] ) ->add( 'pages', EntityType::class, [ 'label' => 'Pages', 'class' => 'AppBundle:Page', 'by_reference' => false, // 'empty_data' => null, 'multiple' => true, 'expanded' => false, 'required' => false, 'query_builder' => function (EntityRepository $em) { return $em->createQueryBuilder('page') ->orderBy('page.title'); }, ] ) ->add( 'posts', EntityType::class, [ 'label' => 'Médias', 'class' => 'AppBundle:Post', 'by_reference' => false, // 'empty_data' => null, 'multiple' => true, 'expanded' => false, 'required' => false, 'query_builder' => function (EntityRepository $em) { return $em->createQueryBuilder('post') ->orderBy('post.title'); }, ] ) ->add( 'published', CheckboxType::class, [ 'label' => 'Publier', 'required' => false, ] ); } /** * @param OptionsResolver $resolver */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults( [ 'data_class' => 'AppBundle\Entity\Section', ] ); } public function getName() { return 'gallery'; } }
<?php namespace newsletter\Test\TestCase\Controller; use Cake\TestSuite\IntegrationTestCase; use newsletter\Controller\CampaignsController; /** * newsletter\Controller\CampaignsController Test Case */ class CampaignsControllerTest extends IntegrationTestCase { /** * Test initial setup * * @return void */ public function testInitialization() { $this->markTestIncomplete('Not implemented yet.'); } }
<?php /* * doctrine-base-repositories (https://github.com/juliangut/doctrine-base-repositories). * Doctrine2 utility repositories. * * @license MIT * @link https://github.com/juliangut/doctrine-base-repositories * @author Julián Gutiérrez <juliangut@gmail.com> */ declare(strict_types=1); require __DIR__ . '/../vendor/autoload.php';
@extends('layouts.admin') @section('title', 'Tambah Semester') @section('content') <div class="container-fluid"> <!-- Page Heading --> <div class="d-sm-flex align-items-center justify-content-between mb-4"> <h1 class="h3 mb-0 text-gray-800">Tambah Data Semester</h1> </div> <div class="card shadow"> <div class="card-body"> <form action="{{ route('semester.store') }}" method="POST"> @csrf <div class="form-group"> <label for="">Semester</label> <input type="text" name="semester" class="form-control" value="{{ old('semester') }}" placeholder="Semester"> </div> <button class="btn btn-block btn-primary" type="submit"> Simpan </button> </form> </div> </div> </div> @endsection
<?php class CountableA implements Countable { public function count() { return 123; } }
<?php namespace TypiCMS\Modules\Dashboard\Repositories; use App; use TypiCMS\Repositories\CacheAbstractDecorator; use TypiCMS\Services\Cache\CacheInterface; class CacheDecorator extends CacheAbstractDecorator implements DashboardInterface { // Class expects a repo and a cache interface public function __construct(DashboardInterface $repo, CacheInterface $cache) { $this->repo = $repo; $this->cache = $cache; } public function getWelcomeMessage() { // Build the cache key, unique per model slug $cacheKey = md5(App::getLocale().'WelcomeMessage'); if ($this->cache->has($cacheKey)) { return $this->cache->get($cacheKey); } $message = $this->repo->getWelcomeMessage(); // Store in cache for next request $this->cache->put($cacheKey, $message); return $message; } public function getModulesList() { // Build the cache key, unique per model slug $cacheKey = md5(App::getLocale().'DashboardModules'); if ($this->cache->has($cacheKey)) { return $this->cache->get($cacheKey); } $modules = $this->repo->getModulesList(); // Store in cache for next request $this->cache->put($cacheKey, $modules); return $modules; } }
@extends('layouts.admin.creationTier') @section('title', 'Contact Person') @section('pagetitle', 'Contact Person') @section('breadcrumb', 'Contact Person') @section('content') <div ng-app="CompanyApp" ng-controller="CompanyController" ng-cloak> <div class="card"> <div class="card-header"> <h3 class="card-title">Contact Person</h3> <a href="#viewContactPerson" class="float-right">View Details</a> </div> <div class="card-body"> <div class="row"> <div class="col"> <img ng-if="catimg" ng-src="<% catimg %>" class="img img-thumbnail" style="width:200px; height:200px;"> </div> </div> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-3" ng-init="getEmployees();"> <label for="select_employee">Select Employee</label> <select class="form-control" id="select_employee" ng-options="user.id as user.first_name for user in Users" ng-model="contactperson.actor_id"> <option value="">Select Employee</option> </select> <i class="text-danger" ng-show="!contactperson.actor_id && showError"><small>Please Select Employee</small></i> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="title">Title</label> <input type="text" class="form-control" id="title" ng-model="contactperson.title" placeholder="Title"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="first_name">First Name</label> <input type="text" class="form-control" id="first_name" ng-model="contactperson.first_name" placeholder="First Name"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="last_name">Last Name</label> <input type="text" class="form-control" id="last_name" ng-model="contactperson.last_name" placeholder="Last Name"/> </div> </div><br/> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-3"> <div class="form-group"> <label for="cat-img">Picture</label> <input type="file" class="form-control" onchange="angular.element(this).scope().readUrl(this);" > </div> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="whatsapp">Whatsapp</label> <input type="text" class="form-control" id="whatsapp" ng-model="contactperson.whatsapp" placeholder="Whatsapp"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="phone_number">Phone Number</label> <input type="text" class="form-control" id="phone_number" ng-model="contactperson.phone_number" placeholder="Phone Number"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="mobile_number">Mobile Number</label> <input type="text" class="form-control" id="mobile_number" ng-model="contactperson.mobile_number" placeholder="Mobile Number"/> </div> </div><br/> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="fax_number">Fax Number</label> <input type="text" class="form-control" id="fax_number" ng-model="contactperson.fax_number" placeholder="Fax Number"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="website">Website</label> <input type="text" class="form-control" id="website" ng-model="contactperson.website" placeholder="Website"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="pinterest">Pinterest</label> <input type="text" class="form-control" id="pinterest" ng-model="contactperson.pinterest" placeholder="Pinterest"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="instagram">Instagram</label> <input type="text" class="form-control" id="instagram" ng-model="contactperson.instagram" placeholder="Instagram"/> </div> </div><br/> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="linkedin">Linkedin</label> <input type="text" class="form-control" id="linkedin" ng-model="contactperson.linkedin" placeholder="Linkedin"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="twitter">Twitter</label> <input type="text" class="form-control" id="twitter" ng-model="contactperson.twitter" placeholder="Twitter"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="facebook">Facebook</label> <input type="text" class="form-control" id="facebook" ng-model="contactperson.facebook" placeholder="Facebook"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="email">Email</label> <input type="text" class="form-control" id="email" ng-model="contactperson.email" placeholder="Email"/> </div> </div><br/> </div> </div><br/> <div class="card"> <div class="card-header"> <h3 class="card-title">Address detail of contact person</h3> </div> <div class="card-body"> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="address_line1">Postal Address Line 1</label> <input type="text" class="form-control" id="address_line1" ng-model="contactperson.address_line_1" placeholder="Postal Address Line 1"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="address_line2">Postal Address Line 2</label> <input type="text" class="form-control" id="address_line2" ng-model="contactperson.address_line_2" placeholder="Postal Address Line 2"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="sector">Sector/Mohallah</label> <input type="text" class="form-control" id="sector" ng-model="contactperson.sector" placeholder="Sector/Mohallah"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="city">City</label> <input type="text" class="form-control" id="city" ng-model="contactperson.city" placeholder="City"/> </div> </div><br/> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="state">State/Province</label> <input type="text" class="form-control" id="state" ng-model="contactperson.state" placeholder="State/Province"/> </div> <div class="col-lg-3 col-md-3 col-sm-3"> <label for="country">Country</label> <input type="text" class="form-control" id="country" ng-model="contactperson.country" placeholder="Country"/> </div> </div><br/> <div class="row"> <div class="col-lg-12 col-md-12 col-sm-12"> <button type="button" class="btn btn-sm btn-success float-right" ng-click="save_contactPerson()">Save</button> </div> </div> </div> </div><br> <div class="card"> <div class="card-header"> <h3 class="card-title" id="viewContactPerson">Contact Person</h3> </div> <div class="card-body table-responsive"> <table class="table table-bordered"> <thead> <tr> <th>Sr#</th> <th>First Name</th> <th>Email</th> <th>Mobile Number</th> <th>Phone Number</th> <th>Whatsapp Number</th> <th>Action</th> </tr> </thead> <tbody ng-init="getContactPersons()"> <tr ng-repeat="contact in contactpersons"> <td ng-bind="$index+1"></td> <td ng-bind="contact.first_name"></td> <td ng-bind="contact.email"></td> <td ng-bind="contact.mobile_number"></td> <td ng-bind="contact.phone_number"></td> <td ng-bind="contact.whatsapp"></td> <td> <div class="btn-group"> <button class="btn btn-xs btn-info" ng-click="editContactPerson(contact.id)">Edit</button> <button class="btn btn-xs btn-danger" ng-click="deleteContactPerson(contact.id)">Delete</button> </div> </td> </tr> </tbody> </table> </div> </div> <input type="hidden" value="<?php echo session('company_id'); ?>" id="company_id"> <input type="hidden" id="appurl" value="<?php echo env('APP_URL'); ?>"> </div> <script src="{{ asset('public/js/angular.min.js')}}"></script> <script> var Company = angular.module('CompanyApp', [], function ($interpolateProvider) { $interpolateProvider.startSymbol('<%'); $interpolateProvider.endSymbol('%>'); }); Company.controller('CompanyController', function ($scope, $http) { $("#employee").addClass('menu-open'); $("#employee a[href='#']").addClass('active'); $("#employee-contact-person").addClass('active'); $scope.url = $("#appurl").val(); $scope.getEmployees = function () { $http.get('getEmployees').then(function (response) { if (response.data.length > 0) { $scope.Users = response.data; } }); }; $scope.save_contactPerson = function(){ $scope.contactperson.company_id = $("#company_id").val(); $scope.contactperson.actor_name = 'employee'; if (!$scope.contactperson.actor_id) { $scope.showError = true; jQuery("input.required").filter(function () { return !this.value; }).addClass("has-error"); } else { var Data = new FormData(); angular.forEach($scope.contactperson, function (v, k) { Data.append(k, v); }); $http.post($scope.url + 'manage-contactperson', Data, {transformRequest: angular.identity, headers: {'Content-Type': undefined}}).then(function (res) { swal({ title: "Save!", text: res.data, type: "success" }); $scope.contactperson = {}; $scope.getContactPersons(); }); } }; $scope.getContactPersons = function () { $scope.contactpersons = {}; $http.get($scope.url + 'get-company-info/employee/'+ $("#company_id").val()).then(function (response) { if (response.data.length > 0) { $scope.contactpersons = response.data; } }); }; $scope.readUrl = function (element) { var reader = new FileReader();//rightbennerimage reader.onload = function (event) { $scope.catimg = event.target.result; $scope.$apply(function ($scope) { $scope.contactperson.userpicture = element.files[0]; }); }; reader.readAsDataURL(element.files[0]); }; $scope.deleteContactPerson = function (id) { swal({ title: "Are you sure?", text: "Your will not be able to recover this record!", type: "warning", showCancelButton: true, confirmButtonClass: "btn-primary", confirmButtonText: "Yes, delete it!", closeOnConfirm: false }, function(){ $http.delete($scope.url + 'manage-contactperson/' + id).then(function (response) { $scope.getContactPersons(); swal("Deleted!", response.data, "success"); }); }); }; $scope.editContactPerson = function (id) { $http.get($scope.url + 'manage-contactperson/' + id + '/edit').then(function (response) { $scope.contactperson = response.data; $scope.getContact($scope.contactperson.contact_id); $scope.getSocialMedia($scope.contactperson.social_id); $scope.getAddress($scope.contactperson.address_id); $scope.catimg = $scope.url +"public/contactperson_picture/" + $scope.contactperson.picture; }); }; $scope.getContact = function(contact_id){ $http.get($scope.url+'getContact/' + contact_id).then(function (response) { if (response.data) { angular.extend($scope.contactperson, response.data); } }); }; $scope.getSocialMedia = function(social_id){ $http.get($scope.url+'getSocialMedia/' + social_id).then(function (response) { if (response.data) { angular.extend($scope.contactperson, response.data); } }); }; $scope.getAddress = function(address_id){ $http.get($scope.url+'getAddress/' + address_id).then(function (response) { if (response.data) { angular.extend($scope.contactperson, response.data); } }); }; }); </script> @endsection
<?php /** * Created by PhpStorm. * User: liulei * Date: 2019/10/3 * Time: 8:42 PM */ require_once '../vendor/autoload.php'; use Review\Task; class ClientTest { public function wait() { // $redis = new Redis(); // $redis->pconnect('127.0.0.1', '6379'); $redis = new stdClass(); $task = new Task($redis, $redis); $ids = $task->setTaskKey('demo')->setCallback(function () { $B = new ClientB(); $B->test(); })->getWaitTaskIds(); return $ids; } } $clientTest = new ClientTest(); $clientTest->wait();
<!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <title>BION - Оценочная компания в Казахстане</title> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta name="csrf-token" content="{{ csrf_token() }}"> <link rel="stylesheet" href="/css/main.css"> <link rel="stylesheet" href="/css/mobile.css"> <link rel="stylesheet" href="/css/desktop.css"> <link rel="stylesheet" href="/css/vendor/lightbox.min.css"> </head> <body> <!-- CLick sounds --> <audio controls id="audio"> <source src="/audio/click.mp3" type="audio/mpeg"> Your browser does not support the audio tag. </audio> <!-- End of CLick sounds --> <div class="firstbg"></div> <div class="secondbg"></div> @yield('content') <footer> {!! $footer !!} </footer> @include('frontend.partials.vue_templates') <script src="/js/vendor/jquery-3.3.1.min.js"></script> <script src="/js/vendor/popper.min.js"></script> <script src="/js/vendor/bootstrap.min.js"></script> <script src="/js/vendor/slick.min.js"></script> <script src="/js/vendor/vue.js"></script> <script src="/js/vendor/jquery.spincrement.min.js"></script> <script src="/js/vendor/lightbox.min.js"></script> <script src="/js/templates.js"></script> <script src="/js/app.js"></script> </body> </html>
@extends('frontend.main_master') @section('content') <div class="body-content" > <div class="container"> <div class="row"> <div class="col-md-2 p-5"> <br> <img class="card-img-top py-5" src="{{ (!empty($user->profile_photo_path)) ? url('uploads/user_images/'.$user->profile_photo_path): url('uploads/no_image.jpg')}}" alt="User Avatar" style="border-radius: 50%" height="100%" width="100%" id="showImage"> <ul class="list-group list-group-flush "><br> <a href="" class="btn btn-primary btn-sm btn-block">Home</a> <a href="{{ route('user.update_profile') }}" class="btn btn-primary btn-sm btn-block">Update Profile </a> <a href="{{ route('user.change_password') }}" class="btn btn-primary btn-sm btn-block">Change Password</a> <a href="{{ route('user.logout') }}" class="btn btn-danger btn-sm btn-block">Logout</a> </ul> </div> <div class="col-md-2"> </div> <div class="col-md-6"> <h3 class="text-center"> <span class="text-primary">Change your password </span> <strong>{{ Auth::user()->name }}</strong> </h3> <div class="card-body"> <form method="POST" action="{{ route('user.change_password_update') }}"> @csrf <div class="form-group"> <div class="row"> <div class="col-12"> <label>Current Password</label> <span >*</span> <div class="input-group"> <div class="input-group-addon"> <i class="fa fa-key"></i> </div> <input type="password" class="form-control unicase-form-control" name="old_password" id="current_password"> </div> </div> <div class="col-12"> <label>New Password</label> <span >*</span> <div class="input-group"> <div class="input-group-addon"> <i class="fa fa-key"></i> </div> <input type="password" class="form-control unicase-form-control" name="pass" id="email"> </div> </div> <div class="col-12"> <label>Confirm Password </label> <span >*</span> <div class="input-group"> <div class="input-group-addon"> <i class="fa fa-key"></i> </div> <input type="password" class="form-control unicase-form-control" name="password_confirmation" id="password_confirmation"> </div> </div> <div class="col-12 mt-10"> <button type="submit" class="btn btn-success"> Save Changes</button> </div> </div> </div> </form> </div> </div> </div> </div> </div> <!-- /.container --> </div> @endsection
@extends('layout.index') @section('content') <section class="page-section clearfix"> <div class="container"> <div class="intro"> <img class="intro-img img-fluid mb-3 mb-lg-0 rounded" src="img/intro.jpg" alt=""> <div class="intro-text left-0 text-center bg-faded p-5 rounded"> <h2 class="section-heading mb-4"> <span class="section-heading-upper"> {{$contenuUn->titre}} </span> <span class="section-heading-lower">{{$contenuUn->soustitre}}</span> </h2> <p class="mb-3"> {{$contenuUn->texte}} </p> <div class="intro-button mx-auto"> <a class="btn btn-primary btn-xl" href="#">Visit Us Today!</a> </div> </div> </div> </div> </section> <section class="page-section cta"> <div class="container"> <div class="row"> <div class="col-xl-9 mx-auto"> <div class="cta-inner text-center rounded"> <h2 class="section-heading mb-4"> <span class="section-heading-upper"> {{$contenuDeux->titre}}</span> <span class="section-heading-lower">{{$contenuDeux->soustitre}}</span> </h2> <p class="mb-0"> {{$contenuDeux->texte}} </p> </div> </div> </div> </div> </section> @endsection
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\User; class homeController extends Controller { public function goHome(){ return view('users.home'); } public function allUsersList(){ $alluserlist = User::all(); return view('users.allUsersList',['alluserlist'=>$alluserlist]); } public function createUser(){ return view('users.newUser'); } public function newUserVerify(Request $req){ // $username = $req->username; // $password = $req->password>; // $= $req->; // $= $req->; // $= $req->; return redirect()->route('home.allUsersList'); // return view('users.allUserList'); } public function myProfile(){ // $this->data['name'] = 'Abdul Kader'; // $this->data['email'] = "kader@gmail.com"; // $this->data['address'] = "Dhaka,Bangladesh"; // $this->data['course'] = ['laravel','React','Vue']; return view('users.userProfile'); } // public function deleteUser(){ // return view('users.home'); // } // public function editUser(){ // return view('users.home'); // } // public function detailsAllUser(){ // return view('users.home'); // } }
<?php use Illuminate\Database\Seeder; class CategoriesTableSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { factory(Picturesque\Category::class, 4)->create(); } }
<?php namespace Coyote\Repositories\Contracts; use Coyote\Repositories\Criteria\Criteria; use Illuminate\Database\Eloquent\Model; interface RepositoryInterface { /** * Creates instance of model * * @return Model * @throws \Exception */ public function makeModel(); /** * @throws \Exception */ public function resetModel(); /** * @return $this */ public function resetCriteria(); /** * @param bool $flag * @return $this */ public function skipCriteria($flag = true); /** * @return mixed */ public function getCriteria(); /** * @param Criteria $criteria * @return $this */ public function getByCriteria(Criteria $criteria); /** * @param Criteria $criteria * @return $this */ public function pushCriteria(Criteria $criteria); /** * @return $this */ public function applyCriteria(); /** * @param array $data * @return mixed */ public function create(array $data); /** * @param array $columns * @return mixed */ public function all($columns = ['*']); /** * @param string $value * @param string $key * @return array */ public function pluck($value, $key = null); /** * @param array $data * @param $id * @param string $attribute * @return mixed */ public function update(array $data, $id, $attribute = 'id'); /** * @param $id * @return mixed */ public function delete($id); /** * @param $id * @param array $columns * @return mixed */ public function find($id, $columns = ['*']); /** * @param array $ids * @param array $columns * @return mixed */ public function findMany(array $ids, $columns = ['*']); /** * @param $id * @param array $columns * @return mixed */ public function findOrFail($id, $columns = ['*']); /** * @param $id * @param array $columns * @return mixed */ public function findOrNew($id, $columns = ['*']); /** * @param $attribute * @param $value * @param array $columns * @return mixed */ public function findBy($attribute, $value, $columns = ['*']); /** * @param $attribute * @param $value * @param array $columns * @return mixed */ public function findAllBy($attribute, $value, $columns = ['*']); /** * @param array $where * @param array $columns * * @return \Illuminate\Database\Eloquent\Collection|null */ public function findWhere($where, $columns = ['*']); /** * Paginate the given query into a simple paginator. * * @param int $perPage * @param array $columns * @param string $pageName * @param int|null $page * @return \Illuminate\Contracts\Pagination\Paginator */ public function simplePaginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null); /** * Get last element. * * @return mixed */ public function last(); /** * Get a new raw query expression. * * @param mixed $value * @return \Illuminate\Database\Query\Expression */ public function raw($value); }
<?php /** * 版权声明 : 地老天荒科技有限公司 * 文件名称 : PageController.php * 创 建 者 : Shi Guang Yu * 创建日期 : 2018/07/20 01:07 * 文件描述 : 后台管理,控制器 * 历史记录 : ----------------------- */ namespace app\page_module\working_version\v1\controller; use think\Controller; use think\Request; use think\facade\Session; use app\login_module\working_version\v1\model\LoginModel; use app\page_module\working_version\v1\service\PageService; class PageController extends Controller { /** * 名 称 : adminPreposition() * 功 能 : 管理员登录前置接口 * 变 量 : -------------------------------------- * 输 入 : -------------------------------------- * 输 出 : -------------------------------------- * 创 建 : 2018/07/16 11:15 */ public function adminPreposition() { // 获取项目域名 $projectUrl = $_SERVER["REQUEST_SCHEME"].'://'; $projectUrl.= $_SERVER["SERVER_NAME"]; $projectUrl.= '/v1/page_module/admin_login'; // 处理项目域名 $route = urlencode($projectUrl); // 拼接公众号登录地址 $url = 'https://open.weixin.qq.com/connect/oauth2/authorize'; $url.= '?appid='.config('v1_config.AppID'); $url.= '&redirect_uri='.$route; $url.= '&response_type=code&scope=snsapi_base'; $url.= '&state=STATE#wechat_redirect'; // 跳转公众号后台登录页面 return '<script>window.location.replace("'.$url.'");</script>'; } /** * 名 称 : adminLogin() * 功 能 : 显示管理员登录页面 * 变 量 : -------------------------------------- * 输 入 : -------------------------------------- * 输 出 : -------------------------------------- * 创 建 : 2018/07/16 11:15 */ public function adminLogin(Request $request) { // 获取code $code = $request->get('code'); // 通过code换取网页授权access_token显示首页 $array = (new LoginLibrary())->loginLibrary($code); // 验证token值 if($array['msg']=='error') return "<h1>{$array['data']}<h1>"; // 获取用户申请管理员操作页面地址 $url = config('html_config.HTTP_URL'); // 获取最高管理员信息 $loginModel = LoginModel::get(1); // 判断用户是不是最高权限管理员 if( ($loginModel) && ($array['data']==$loginModel['user_token']) ) { // 获取域名独立Session信息 $strMd5 = md5($_SERVER["SERVER_NAME"].'login_admin_token'); Session::set($strMd5,$array['data']); $url.= config('html_config.Admin_Index'); }else{ $url.= config('html_config.Admin_Login'); } // 显示注册页面视图 return "<script> window.location.replace('{$url}?token={$array['data']}'); </script>"; } /** * 名 称 : adminDoLogin() * 功 能 : 执行用户登录操作 * 变 量 : -------------------------------------- * 输 入 : (String) $heder['user-key'] => '用户身份标识'; * 输 入 : (String) $post['adminPhone'] => '手机号'; * 输 入 : (String) $post['adminPassword'] => '密码'; * 输 出 : -------------------------------------- * 创 建 : 2018/07/21 11:39 */ public function adminDoLogin(Request $request) { // 引入Service层代码 $res = (new PageService())->adminGet($request->post()); // 判断数据是否正确 if($res['msg']=='error') return returnResponse(1,$res['data']); // 获取用户标识 $userKey = $request->header('user-key'); // 获取域名独立Session信息 $strMd5 = md5($_SERVER["SERVER_NAME"].'login_admin_token'); Session::set($strMd5,$userKey); // 返回正确数据 return returnResponse(0,$res['data'],true); } /** * 名 称 : moduleList() * 功 能 : 获取管理模块信息 * 变 量 : -------------------------------------- * 输 入 : -------------------------------------- * 输 出 : -------------------------------------- * 创 建 : 2018/07/21 10:29 */ public function moduleList() { return "<h1>获取管理模块信息</h1>"; } }
<?php header('Content-Type: text/html; charset=utf-8'); header("Expires: Mon, 12 Jan 1983 05:00:00 GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Cache-Control: no-cache"); header("Cache-Control: post-check=0, pre-check=0"); header("Pragma: no-cache"); ?> <!DOCTYPE html> <html lang="pt-br"> <?php $this->load->view('acesso/head'); ?> <body> <?php $this->load->view('acesso/nav'); ?> <main> <?php $this->load->view('acesso/'.$conteudo); ?> </main> </body> <?php $base = base_url(); ?> <script> let baseUrl = '' baseUrl = '<?php echo $base; ?>' </script> <?php $this->load->view('acesso/footer'); $this->load->view('acesso/scripts'); ?> </html>
<?php /** * @package s9e\TextFormatter * @copyright Copyright (c) 2010-2021 The s9e authors * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ namespace s9e\TextFormatter\Configurator\JavaScript; use s9e\TextFormatter\Configurator\Helpers\RegexpBuilder; use s9e\TextFormatter\Configurator\JavaScript\Code; class StylesheetCompressor { /** * @var string[] List of regular expressions that match strings to deduplicate */ protected $deduplicateTargets = [ '<xsl:template match="', '</xsl:template>', '<xsl:apply-templates/>', '<param name="allowfullscreen" value="true"/>', '<xsl:value-of select="', '<xsl:copy-of select="@', '<iframe allowfullscreen="" scrolling="no"', 'display:block;overflow:hidden;position:relative;padding-bottom:', 'display:inline-block;width:100%;max-width:', ' [-:\\w]++="', '\\{[^}]++\\}', '@[-\\w]{4,}+', '(?<=<)[-:\\w]{4,}+', '(?<==")[^"]{4,}+"' ]; /** * @var array Associative array of string replacements as [match => replace] */ protected $dictionary; /** * @var string Prefix used for dictionary keys */ protected $keyPrefix = '$'; /** * @var integer Number of bytes each global substitution must save to be considered */ public $minSaving = 10; /** * @var array Associative array of [string => saving] */ protected $savings; /** * @var string */ protected $xsl; /** * Encode given stylesheet into a compact JavaScript representation * * @param string $xsl Original stylesheet * @return string JavaScript representation of the compressed stylesheet */ public function encode($xsl) { $this->xsl = $xsl; $this->estimateSavings(); $this->filterSavings(); $this->buildDictionary(); $str = $this->getCompressedStylesheet(); // Split the stylesheet's string into 2000 bytes chunks to appease Google Closure Compiler $js = implode("+\n", array_map('json_encode', str_split($str, 2000))); if (!empty($this->dictionary)) { $js = '(' . $js . ').replace(' . $this->getReplacementRegexp() . ',function(k){return' . json_encode($this->dictionary) . '[k];})'; } return $js; } /** * Build a dictionary of all cost-effective string replacements * * @return void */ protected function buildDictionary() { $keys = $this->getAvailableKeys(); rsort($keys); $this->dictionary = []; arsort($this->savings); foreach (array_keys($this->savings) as $str) { $key = array_pop($keys); if (!$key) { break; } $this->dictionary[$key] = $str; } } /** * Estimate the savings of every possible string replacement * * @return void */ protected function estimateSavings() { $this->savings = []; foreach ($this->getStringsFrequency() as $str => $cnt) { $len = strlen($str); $originalCost = $cnt * $len; $replacementCost = $cnt * 2; $overhead = $len + 6; $this->savings[$str] = $originalCost - ($replacementCost + $overhead); } } /** * Filter the savings according to the minSaving property * * @return void */ protected function filterSavings() { $this->savings = array_filter( $this->savings, function ($saving) { return ($saving >= $this->minSaving); } ); } /** * Return all the possible dictionary keys that are not present in the original stylesheet * * @return string[] */ protected function getAvailableKeys() { return array_diff($this->getPossibleKeys(), $this->getUnavailableKeys()); } /** * Return the stylesheet after dictionary replacements * * @return string */ protected function getCompressedStylesheet() { return strtr($this->xsl, array_flip($this->dictionary)); } /** * Return a list of possible dictionary keys * * @return string[] */ protected function getPossibleKeys() { $keys = []; foreach (range('a', 'z') as $char) { $keys[] = $this->keyPrefix . $char; } return $keys; } /** * Return a regexp that matches all used dictionary keys * * @return string */ protected function getReplacementRegexp() { return '/' . RegexpBuilder::fromList(array_keys($this->dictionary)) . '/g'; } /** * Return the frequency of all deduplicatable strings * * @return array Array of [string => frequency] */ protected function getStringsFrequency() { $regexp = '(' . implode('|', $this->deduplicateTargets) . ')S'; preg_match_all($regexp, $this->xsl, $matches); return array_count_values($matches[0]); } /** * Return the list of possible dictionary keys that appear in the original stylesheet * * @return string[] */ protected function getUnavailableKeys() { preg_match_all('(' . preg_quote($this->keyPrefix) . '.)', $this->xsl, $matches); return array_unique($matches[0]); } }
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Display the pdf file using php</title> </head> <body> <?php $file = 'php_tutorial.pdf'; $filename = 'php_tutorial.pdf'; header('Content-type: application/pdf'); header('Content-Disposition: inline; filename="' . $filename . '"'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($file)); header('Accept-Ranges: bytes'); @readfile($file); ?> <a href="http://www.sanwebtutorials.blogspot.in/">San web corner</a> </body> </html>
<?php namespace App\Http\Controllers; use App\Http\Requests\CreateTabEspARequest; use App\Http\Requests\UpdateTabEspARequest; use App\Repositories\TabEspARepository; use App\Http\Controllers\AppBaseController; use Illuminate\Http\Request; use Flash; use Response; class TabEspAController extends AppBaseController { /** @var TabEspARepository */ private $tabEspARepository; public function __construct(TabEspARepository $tabEspARepo) { $this->tabEspARepository = $tabEspARepo; } /** * Display a listing of the TabEspA. * * @param Request $request * * @return Response */ public function index(Request $request) { $tabEspAs = $this->tabEspARepository->all(); return view('tab_esp_as.index') ->with('tabEspAs', $tabEspAs); } /** * Show the form for creating a new TabEspA. * * @return Response */ public function create() { return view('tab_esp_as.create'); } /** * Store a newly created TabEspA in storage. * * @param CreateTabEspARequest $request * * @return Response */ public function store(CreateTabEspARequest $request) { $input = $request->all(); $tabEspA = $this->tabEspARepository->create($input); Flash::success(__('messages.saved', ['model' => __('models/tabEspAs.singular')])); return redirect(route('tabEspAs.index')); } /** * Display the specified TabEspA. * * @param int $id * * @return Response */ public function show($id) { $tabEspA = $this->tabEspARepository->find($id); if (empty($tabEspA)) { Flash::error(__('messages.not_found', ['model' => __('models/tabEspAs.singular')])); return redirect(route('tabEspAs.index')); } return view('tab_esp_as.show')->with('tabEspA', $tabEspA); } /** * Show the form for editing the specified TabEspA. * * @param int $id * * @return Response */ public function edit($id) { $tabEspA = $this->tabEspARepository->find($id); if (empty($tabEspA)) { Flash::error(__('messages.not_found', ['model' => __('models/tabEspAs.singular')])); return redirect(route('tabEspAs.index')); } return view('tab_esp_as.edit')->with('tabEspA', $tabEspA); } /** * Update the specified TabEspA in storage. * * @param int $id * @param UpdateTabEspARequest $request * * @return Response */ public function update($id, UpdateTabEspARequest $request) { $tabEspA = $this->tabEspARepository->find($id); if (empty($tabEspA)) { Flash::error(__('messages.not_found', ['model' => __('models/tabEspAs.singular')])); return redirect(route('tabEspAs.index')); } $tabEspA = $this->tabEspARepository->update($request->all(), $id); Flash::success(__('messages.updated', ['model' => __('models/tabEspAs.singular')])); return redirect(route('tabEspAs.index')); } /** * Remove the specified TabEspA from storage. * * @param int $id * * @throws \Exception * * @return Response */ public function destroy($id) { $tabEspA = $this->tabEspARepository->find($id); if (empty($tabEspA)) { Flash::error(__('messages.not_found', ['model' => __('models/tabEspAs.singular')])); return redirect(route('tabEspAs.index')); } $this->tabEspARepository->delete($id); Flash::success(__('messages.deleted', ['model' => __('models/tabEspAs.singular')])); return redirect(route('tabEspAs.index')); } }
<!DOCTYPE html> <html lang="en"> <head> <title>Pemetaan Hasil Bumi - Login</title> <!-- BEGIN META --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="keywords" content="your,keywords"> <meta name="description" content="Short explanation about this website"> <!-- END META --> <!-- BEGIN STYLESHEETS --> <link href='http://fonts.googleapis.com/css?family=Roboto:300italic,400italic,300,400,500,700,900' rel='stylesheet' type='text/css'/> <link type="text/css" rel="stylesheet" href="<?php echo base_url();?>assets/css/theme-default/bootstrap.css?1422792965" /> <link type="text/css" rel="stylesheet" href="<?php echo base_url();?>assets/css/theme-default/materialadmin.css?1425466319" /> <link type="text/css" rel="stylesheet" href="<?php echo base_url();?>assets/css/theme-default/font-awesome.min.css?1422529194" /> <link type="text/css" rel="stylesheet" href="<?php echo base_url();?>assets/css/theme-default/material-design-iconic-font.min.css?1421434286" /> <!-- END STYLESHEETS --> <link type="text/css" rel="stylesheet" href="<?php echo base_url();?>assets/css/theme-default/libs/toastr/toastr.css?1425466569" /> <script src="<?php echo base_url();?>assets/js/libs/jquery/jquery-1.11.2.min.js"></script> <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script type="text/javascript" src="<?php echo base_url();?>assets/js/libs/utils/html5shiv.js?1403934957"></script> <script type="text/javascript" src="<?php echo base_url();?>assets/js/libs/utils/respond.min.js?1403934956"></script> <![endif]--> </head> <body class="menubar-hoverable header-fixed"> <!-- BEGIN LOGIN SECTION --> <section class="section-account"> <div class="spacer"></div> <div class="card contain-xs"> <div class="card-head"> <div class="img-backdrop" style="background-image: url('<?php echo base_url();?>assets/img/img16.jpg')"></div> </div> <div class="card-body"> <div class="row"> <div class="col-sm-offset-1 col-sm-10"> <br/> <span class="text-lg text-bold text-primary">PEMETAAN HASIL BUMI</span> <br/><br/><br/> <form class="form floating-label form-validate" novalidate="novalidate" method="post" action="<?php echo base_url() ?>Auth/login"> <div class="form-group"> <input type="text" name="username" value="" class="form-control" required> <label for="username">Username</label> </div> <div class="form-group"> <input type="password" name="password" value="" class="form-control" required> <label for="password">Password</label> <p class="help-block"><a href="<?php echo base_url() ?>Auth/register">Daftar disini</a> | <a href="<?php echo base_url() ?>Auth/forgotten">Lupa password?</a></p> </div> <br/> <div class="row"> <div class="col-xs-6 text-left"> <div class="checkbox checkbox-inline checkbox-styled"> <label> <input type="checkbox" name="remember"> <span>Remember me</span> </label> </div> </div><!--end .col --> <div class="col-xs-6 text-right"> <button type="submit" class="btn btn-primary btn-raised">Sign In</button> </div><!--end .col --> </div><!--end .row --> </form> </div><!--end .col --> </div><!--end .card --> </section> <!-- END LOGIN SECTION --> <!-- BEGIN JAVASCRIPT --> <script type="text/javascript"> $(function() { toastr.options.positionClass = 'toast-bottom-right'; toastr.options.timeOut = 2000; <?php if ($this->session->flashdata('message')==true) { echo $this->session->flashdata('message'); } ?> }) </script> <script src="<?php echo base_url();?>assets/js/libs/jquery/jquery-1.11.2.min.js"></script> <script src="<?php echo base_url();?>assets/js/libs/jquery/jquery-migrate-1.2.1.min.js"></script> <script src="<?php echo base_url();?>assets/js/libs/bootstrap/bootstrap.min.js"></script> <script src="<?php echo base_url();?>assets/js/libs/spin.js/spin.min.js"></script> <script src="<?php echo base_url();?>assets/js/libs/autosize/jquery.autosize.min.js"></script> <script src="<?php echo base_url();?>assets/js/libs/nanoscroller/jquery.nanoscroller.min.js"></script> <script src="<?php echo base_url();?>assets/js/core/source/App.js"></script> <script src="<?php echo base_url();?>assets/js/core/source/AppNavigation.js"></script> <script src="<?php echo base_url();?>assets/js/core/source/AppOffcanvas.js"></script> <script src="<?php echo base_url();?>assets/js/core/source/AppCard.js"></script> <script src="<?php echo base_url();?>assets/js/core/source/AppForm.js"></script> <script src="<?php echo base_url();?>assets/js/libs/toastr/toastr.js"></script> <script src="<?php echo base_url();?>assets/js/libs/jquery-validation/dist/jquery.validate.min.js"></script> <!-- END JAVASCRIPT --> </body> </html>
<?php include("block/frame_top.php");?> <!--main-container-part--> <div id="content"> <!--breadcrumbs--> <?php print($crumbs);?> <!--End-breadcrumbs--> <div class="container-fluid"> <hr/> <div class="row-fluid"> <?php include("page/jjuserLocation.php");?> </div> </div> </div> <!--end-main-container-part--> <!--Footer-part--> <?php include("block/footer.php");?> <!--end-Footer-part--> <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=7oDruIWjAj9Dkm647oak1tN3"></script> <script type="text/javascript"> var map = new BMap.Map("baidumap"); window.map = map; //104.65357,34.443525 var point = new BMap.Point(104.65357, 34.443525); map.addControl(new BMap.NavigationControl()); //添加平移缩放控件 map.addControl(new BMap.ScaleControl()); //添加比例尺控件 map.addControl(new BMap.OverviewMapControl()); //添加缩略地图控件 map.enableScrollWheelZoom(); //启用滚轮放大缩小 map.centerAndZoom(point, 5); var totalPages = 0; var pageNo = 1; var pageSize = 1000; var ALL_LOC_LIST = []; function loadUserLocation(pageNo) { var params = { pageNo: pageNo, pageSize: pageSize }; $.getJSON("/jjuser/getUserLocationList", params, function(data) { totalPages = data.totalPages; pageNo = data.pageNo; showPoint(map, data.userLocationArray); if (pageNo < totalPages) { loadUserLocation(++pageNo); } }); } function showUserWindow(map, point) { var user = point.userInfo; var wiid = "user-window-" + user.userID; var sexName = user.sex == 0 ? "男" : "女"; var sContent = "<h4 style='margin:0 0 5px 0;padding:0.2em 0'>"+user.nickname+"</h4>" + "<img style='float:right;margin:2px' id='" +wiid+ "' src='" + user.headUrl + "' width='64' height='64'/>" + "<p style='margin:0;line-height:1.5;font-size:13px;'>性别:" +sexName+ "</p>" + "<p style='margin:0;line-height:1.5;font-size:13px;'>登录:" +user.lastLoginTime+ "</p>" + "</div>"; var infoWindow = new BMap.InfoWindow(sContent); // 创建信息窗口对象 map.openInfoWindow(infoWindow, point); //开启信息窗口 window.setTimeout(function(){ var imgdom = document.getElementById(wiid); if (imgdom) { imgdom.onload = function (){ infoWindow.redraw(); } } }, 0); } function showPoint(map, pointArray) { var points = [], len = pointArray.length, loc = null, point = null, i; for (i = 0; i < len; i++) { loc = pointArray[i]; point = new BMap.Point(loc.lng, loc.lat); point.userInfo = loc; points.push(point); ALL_LOC_LIST.push(loc); } var options = { size: 3, shape: BMAP_POINT_SHAPE_CIRCLE, color: '#d340c3' }; var pointCollection = new BMap.PointCollection(points, options); // 初始化PointCollection pointCollection.addEventListener('mouseover', function (e) { showUserWindow(map, e.point, e.point.userInfo); }); map.addOverlay(pointCollection); // 添加Overlay } loadUserLocation(1); </script> </body> </html>
<?php must_have_access(); ?> <style> .tpl_previe_overlay{ background: none repeat scroll 0 0 transparent; display: block; height: 100%; left: 0; position: absolute; top: 0; width: 100%; z-index: 995; } </style> <script type="text/javascript"> $(document).ready(function(){ mw.options.form('.<?php print $config['module_class'] ?>', function(){ mw.notification.success("<?php _ejs("Default template saved"); ?>."); }); }); modulePreview = function(el){ var url = el.tagName == 'A' ? el.href : el.src; var modal = mw.dialogIframe({ url:url, name:"preview_" + el.id, title:'Preview Template - <b>' + el.title + "</b>", height:600, template:'mw_modal_simple' }); if(!modal){ mw.tools.highlight(mwd.getElementById("preview_" + el.id).querySelector(".tpl_previe_overlay"), "#ffffff"); } else{ $(modal.container).css("position", "relative").append("<div class='tpl_previe_overlay'></div>"); } } </script> <?php if(isset($params['for'])){ $params['parent-module'] = $params['for']; $params['parent-module-id'] = $params['for']; } if(!isset($params['parent-module'])){ error('parent-module is required'); } if(!isset($params['parent-module-id'])){ error('parent-module-id is required'); } $curent_module = $params['parent-module']; $curent_module_url = module_name_encode($params['parent-module']); $templates = module_templates($params['parent-module']); //$params['type']; $cur_template = get_option('data-template', $params['parent-module-id']); ?> <?php if(is_array( $templates)): ?> <label class="mw-ui-label"><?php _e("Set default skin for the whole website"); ?></label> <select name="data-template" class="mw-ui-field mw_option_field" option_group="<?php print $params['parent-module-id'] ?>" data-refresh="<?php print $params['parent-module-id'] ?>" > <option value="default" <?php if(('default' == $cur_template)): ?> selected="selected" <?php endif; ?>><?php _e("Default"); ?></option> <?php foreach($templates as $item): ?> <?php if((strtolower($item['name']) != 'default')): ?> <option value="<?php print $item['layout_file'] ?>" <?php if(($item['layout_file'] == $cur_template)): ?> selected="selected" <?php endif; ?> > <?php print $item['name'] ?> </option> <?php endif; ?> <?php endforeach; ?> </select> <a class="mw-ui-btn mw-ui-btn-green" href="javascript:;"><?php _e("Get more templates"); ?></a> <div class="mw-admin-templates-browse-holder"> <?php if(is_array($templates )): ?> <?php $i = 1; foreach($templates as $item): ?> <div class="templatePreviewHolder" > <?php if(isset($item['name'])): ?> <h2><?php print $item['name'] ?></h2> <?php if(isset($item['description'])): ?> <small class="templatePreviewDescription"><?php print $item['description'] ?></small> <?php endif; ?> <div class="templatePreviewContainer"> <?php if(isset($item['icon'])){ ?> <img src="<?php print $item['icon'] ?>" /> <?php } else if(isset($item['image'])){ ?> <img src="<?php print $item['image'] ?>" /> <?php } else {; ?> <iframe src="<?php print site_url('clean') ?>/preview_module:<?php print ($curent_module_url) ?>/preview_module_template:<?php print module_name_encode($item['layout_file']) ?>/preview_module_id:skin_num_<?php print $i.md5($curent_module); ?>" frameborder="0" scrolling="no" > </iframe> <?php } ?> <div class="templatePreviewOL"> <div class="templatePreviewOLContent"> <span class="mw-template-name"><?php print $item['name'] ?></span> <span class="mw-ui-btn left mw-ui-btn-green"><?php _e("Use as default"); ?></span> <a onclick="modulePreview(this); return false;" title="<?php print $item['name'] ?>" id="skin_num_<?php print $i.md5($curent_module); ?>" href="<?php print site_url('clean') ?>/preview_module:<?php print ($curent_module_url) ?>/preview_module_template:<?php print module_name_encode($item['layout_file']) ?>/preview_module_id:skin_num_<?php print $i.md5($curent_module); ?>" class="mw-ui-btn mw-ui-btn-blue right"><?php _e("Preview"); ?></a> </div> </div> </div> </div> <?php //d($item); ?> <?php endif; ?> <?php $i++; endforeach ; ?> <?php endif; ?> </div> <?php endif; ?>
<?php /* File name: cupgames.php Last change: Sat Jan 19 10:37:11 EET 2008 Copyright: NRPG (c) 2008 */ define("IN_GAME", true); include("common.php"); limit(); mkglobal("round", false); function paging($pageNum, $where, $pageadd, $rowsPerPage = 16) { $numrows = sql_get("SELECT COUNT(`id`) FROM `match` {$where}", __FILE__, __LINE__); if ($numrows == 0) return false; $offset = ($pageNum - 1) * $rowsPerPage; $result = sql_query("SELECT `id`, `hometeam`, `awayteam`, `start`, `odds`, `better`, `played`, (SELECT `name` FROM `teams` WHERE `id` = `match`.`hometeam`) AS `home`, (SELECT `name` FROM `teams` WHERE `id` = `match`.`awayteam`) AS `away`, `homescore`, `awayscore`, `played` FROM `match` {$where} LIMIT {$offset}, {$rowsPerPage}", __FILE__, __LINE__); table_start(); table_header(HOME, RESULT." / ".START, AWAY, "1", "X", "2"); while ($row = mysql_fetch_assoc($result)) { table_startrow(); if ($row['hometeam'] <= MAX_TEAMS) table_cell(create_link("teamdetails.php?id={$row['hometeam']}", $row['home']), 1, "tb", "", "text-align: right;"); else table_cell(WINNER_FROM_MATCH." {$row['hometeam']}", 1, "tb", "", "text-align: right;"); if ($row['played'] == 'yes') table_cell(create_link("matchreport.php?id={$row['id']}", "{$row['homescore']} - {$row['awayscore']}"), 1, "tb", "", "text-align: center;"); else table_cell($row['start'], 1, "tb", "", "text-align: center;"); if ($row['awayteam'] <= MAX_TEAMS) table_cell(create_link("teamdetails.php?id={$row['awayteam']}", $row['away']), 1, "tb", "", "text-align: left;"); else table_cell(WINNER_FROM_MATCH." {$row['awayteam']}", 1, "tb", "", "text-align: left;"); $odds = format_odds($row['odds'], $row['better'], $row['played'], $row['id']); table_cell($odds[0], 1, "tb", "", "text-align: center;"); table_cell($odds[1], 1, "tb", "", "text-align: center;"); table_cell($odds[2], 1, "tb", "", "text-align: center;"); table_endrow(); } table_end(); br(); $maxPage = ceil($numrows/$rowsPerPage); $next = ""; $last = ""; $first = ""; $prev = ""; if ($pageNum > 1) { $page = $pageNum - 1; $prev = " ".create_link("{$pageadd}&page={$page}", "[".PREVIOUS_PAGE."]")." "; $first = " ".create_link("{$pageadd}&page=1", "[".FIRST_PAGE."]")." "; } if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " ".create_link("{$pageadd}&page={$page}", "[".NEXT_PAGE."]")." "; $last = " ".create_link("{$pageadd}&page={$maxPage}", "[".LAST_PAGE."]")." "; } prnt("{$first} {$prev} ".PAGE." <b>{$pageNum}</b> "._OF." <b>{$maxPage}</b> "._PAGES." {$next} {$last}"); return true; } if (empty($round) || !is_numeric($round) || $round < 1 || $round > 18) { if ($config['cupround'] == 0) $round = 1; else $round = $config['cupround']; } pagestart(SEASON." {$config['season']} - ".FIXTURES_AND_RESULTS.": ".CUP_ROUND." {$round}"); head(SEASON." {$config['season']} - ".FIXTURES_AND_RESULTS.": ".CUP_ROUND." {$round}"); // Header table_start(); table_startrow(); table_th(ROUND.":"); for ($i = 1; $i <= 18; $i++) { if ($i != $round) table_cell(create_link("cupgames.php?round={$i}", $i)); else table_cell($i); } table_endrow(); table_end(); br(); mkglobal("page", false); if (!empty($page) && !is_numeric($page)) info (INVALID_PAGE_NUMBER, ERROR); if (empty($page)) $page = 1; $cupid = sql_get("SELECT `id` FROM `match_type` WHERE `name` = 'CUP'", __FILE__, __LINE__); paging($page, "WHERE `type` = '{$cupid}' AND `round` = '{$round}' AND `season` = {$config['season']}", "cupgames.php?round={$round}", 16); pageend(); ?>
<?php return [ 'name' => 'Homepage' ];
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateBellTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('Bell', function (Blueprint $table) { $table->increments('id'); $table->string('Time'); $table->string('Number_pr'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('Bell'); } }
products.blade.php
<?php namespace App; use Illuminate\Database\Eloquent\Model; class Clients extends Model { protected $guarded = []; public function categories_all(){ return $this->belongsTo(Categories::class,'categ_id','id'); } }