Atualizando registros
This commit is contained in:
parent
23e3320f89
commit
3240cbb001
1290 changed files with 375796 additions and 0 deletions
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Ignora a pasta de arquivos armazenados
|
||||
#app/storage/files/
|
||||
|
||||
# Ignora a pasta de arquivos temporários
|
||||
app/storage/temp/
|
||||
|
||||
bkps
|
||||
ajuste/
|
||||
.vscode
|
||||
ajuste
|
||||
|
||||
# Ignora arquivo de configuração
|
||||
#app/config/
|
||||
37
Dockerfile
Normal file
37
Dockerfile
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# Usa a imagem oficial PHP 8.4 com Apache
|
||||
FROM php:8.4-apache
|
||||
|
||||
# Atualiza o sistema e instala dependências básicas
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libpng-dev \
|
||||
libjpeg-dev \
|
||||
libonig-dev libxml2-dev zip unzip curl git libzip-dev libfreetype6-dev libjpeg62-turbo-dev && docker-php-ext-configure gd --with-freetype --with-jpeg && docker-php-ext-install -j$(nproc) gd mbstring && docker-php-ext-install pdo pdo_mysql mysqli zip && docker-php-ext-enable opcache
|
||||
|
||||
|
||||
# Habilita o módulo de reescrita do Apache (útil para Laravel ou outros frameworks)
|
||||
RUN a2enmod rewrite
|
||||
|
||||
# Adiciona a diretiva ServerName globalmente
|
||||
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
|
||||
|
||||
# Substitui a configuração padrão do Apache para permitir .htaccess
|
||||
COPY ./apache/000-default.conf /etc/apache2/sites-available/000-default.conf
|
||||
|
||||
# Copia os arquivos do projeto para a pasta padrão do Apache
|
||||
COPY . /var/www/html/
|
||||
|
||||
# Cria os diretórios de upload, caso não existam
|
||||
RUN mkdir -p /var/www/html/ged/documents \
|
||||
&& mkdir -p /var/www/html/ged/financial
|
||||
|
||||
# Define permissões apropriadas
|
||||
RUN chown -R www-data:www-data /var/www/html && find /var/www/html -type d -exec chmod 755 {} + && find /var/www/html -type f -exec chmod 644 {} +
|
||||
|
||||
# Define o diretório de trabalho
|
||||
WORKDIR /var/www/html
|
||||
|
||||
# Expõe a porta padrão HTTP
|
||||
EXPOSE 80
|
||||
|
||||
# Comando de inicialização (padrão do Apache na imagem oficial)
|
||||
CMD ["apache2-foreground"]
|
||||
12
apache/000-default.conf
Normal file
12
apache/000-default.conf
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<VirtualHost *:80>
|
||||
DocumentRoot /var/www/html
|
||||
|
||||
<Directory /var/www/html>
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
27
config/config.json
Normal file
27
config/config.json
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
|
||||
"app" : {
|
||||
|
||||
"title" : "API Monitor",
|
||||
"version" : "1",
|
||||
"release" : "1",
|
||||
"url_aplication" : "https://api-api-monitor.gbrqne.easypanel.host/",
|
||||
"session_time" : "30",
|
||||
"mail": {
|
||||
"host": "mail.oriustecnologia.com.br",
|
||||
"username": "naoresponda@oriustecnologia.com.br",
|
||||
"password": "@Star147oi.",
|
||||
"port": "465",
|
||||
"from": {
|
||||
"email": "naoresponda@oriustecnologia.com.br",
|
||||
"name": "API Monitor Oriustecnologia"
|
||||
}
|
||||
},
|
||||
"security" : {"method": "aes-256-cbc",
|
||||
"first_key": "1B0B043A1C185F261D",
|
||||
"second_key": "1B0B043A0C05422C1E0A",
|
||||
"hash": "43170E01071F0D3B1437"
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
89
router.php
Normal file
89
router.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
require_once('./vendor/autoload.php');
|
||||
|
||||
/** Carrego o arquivo de configuração */
|
||||
$settings = (object)json_decode(file_get_contents('config/config.json'));
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\controller\main\Main;
|
||||
use vendor\controller\routers\RouterValidate;
|
||||
|
||||
/** Instânciamento de classes */
|
||||
$Main = new Main;
|
||||
$RouterValidate = new RouterValidate;
|
||||
|
||||
// error_reporting(E_ALL);
|
||||
// ini_set('display_errors', 'On');
|
||||
|
||||
try {
|
||||
|
||||
/** Parâmetros de Entrada */
|
||||
$RouterValidate->setTable(@(string)filter_input(INPUT_POST, 'TABLE', FILTER_SANITIZE_SPECIAL_CHARS));
|
||||
$RouterValidate->setAction(@(string)filter_input(INPUT_POST, 'ACTION', FILTER_SANITIZE_SPECIAL_CHARS));
|
||||
$RouterValidate->setFolder(@(string)filter_input(INPUT_POST, 'FOLDER', FILTER_SANITIZE_SPECIAL_CHARS));
|
||||
|
||||
/** Verifico a existência de erros */
|
||||
if (!empty($RouterValidate->getErrors())) {
|
||||
|
||||
/** Mensagem de erro */
|
||||
throw new Exception($RouterValidate->getErrors());
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
/** Verifico se o arquivo de ação existe */
|
||||
if (is_file($RouterValidate->getFullPath())) {
|
||||
|
||||
/** Inicio a coleta de dados */
|
||||
ob_start();
|
||||
|
||||
/** Inclusão do arquivo desejado */
|
||||
@include_once $RouterValidate->getFullPath();
|
||||
|
||||
/** Prego a estrutura do arquivo */
|
||||
$div = ob_get_contents();
|
||||
|
||||
/** Removo o arquivo incluido */
|
||||
ob_clean();
|
||||
|
||||
/** Result **/
|
||||
$result = array(
|
||||
|
||||
'cod' => 200,
|
||||
'data' => $div,
|
||||
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
/** Mensagem de erro */
|
||||
throw new Exception('Erro :: Não há arquivo para ação informada.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
} catch (Exception $exception) {
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'message' => $exception->getMessage(),
|
||||
'title' => 'Atenção',
|
||||
'type' => 'exception'
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
}
|
||||
142
vendor/action/client/client_save.php
vendored
Normal file
142
vendor/action/client/client_save.php
vendored
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\model\Client;
|
||||
use vendor\controller\client\ClientValidate;
|
||||
|
||||
try{
|
||||
|
||||
/** Verifica se o token de acesso é válido */
|
||||
if($Main->verifyToken()){
|
||||
|
||||
/** Instânciamento de classes */
|
||||
$Client = new Client();
|
||||
$ClientValidate = new ClientValidate();
|
||||
|
||||
/** Parametros de entrada */
|
||||
$clientId = isset($_POST['client_id']) ? (int)filter_input(INPUT_POST, 'client_id', FILTER_SANITIZE_SPECIAL_CHARS) : 0 ;
|
||||
$cns = isset($_POST['cns']) ? (string)filter_input(INPUT_POST, 'cns', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$name = isset($_POST['name']) ? (string)filter_input(INPUT_POST, 'name', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$state = isset($_POST['state']) ? (string)filter_input(INPUT_POST, 'state', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$city = isset($_POST['city']) ? (string)filter_input(INPUT_POST, 'city', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$responsible = isset($_POST['responsible']) ? (string)filter_input(INPUT_POST, 'responsible', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$consultant = isset($_POST['consultant']) ? (string)filter_input(INPUT_POST, 'consultant', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$typeContract = isset($_POST['type_contract']) ? (string)filter_input(INPUT_POST, 'type_contract', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
|
||||
|
||||
/** Validando os campos de entrada */
|
||||
$ClientValidate->setClientId($clientId);
|
||||
$ClientValidate->setCns($cns);
|
||||
$ClientValidate->setName($name);
|
||||
$ClientValidate->setState($state);
|
||||
$ClientValidate->setCity($city);
|
||||
$ClientValidate->setResponsible($responsible);
|
||||
$ClientValidate->setConsultant($consultant);
|
||||
$ClientValidate->setTypeContract($typeContract);
|
||||
|
||||
/** Verifico a existência de erros */
|
||||
if (!empty($ClientValidate->getErrors())) {
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'title' => 'Atenção',
|
||||
'message' => '<div class="alert alert-danger" role="alert">'.$ClientValidate->getErrors().'</div>',
|
||||
|
||||
];
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
/** Efetua um novo cadastro ou salva os novos dados */
|
||||
if ($Client->Save($ClientValidate->getClientId(),
|
||||
$ClientValidate->getCns(),
|
||||
$ClientValidate->getName(),
|
||||
$ClientValidate->getState(),
|
||||
$ClientValidate->getCity(),
|
||||
$ClientValidate->getResponsible(),
|
||||
$ClientValidate->getConsultant(),
|
||||
$ClientValidate->getTypeContract())){
|
||||
|
||||
|
||||
/** Adição de elementos na array */
|
||||
$message = '<div class="alert alert-success" role="alert"> <b>'.($ClientValidate->getClientId() > 0 ? 'Cadastro atualizado com sucesso' : 'Cadastro efetuado com sucesso').' </b></div>';
|
||||
|
||||
/** Result **/
|
||||
$result = [
|
||||
|
||||
'cod' => 200,
|
||||
'title' => 'Atenção',
|
||||
'message' => $message,
|
||||
'redirect' => '',
|
||||
|
||||
];
|
||||
|
||||
} else {
|
||||
|
||||
/** Verifica se houve erros no SQL */
|
||||
if($Client->getErrors()){
|
||||
|
||||
/** Adição de elementos na array */
|
||||
$message = '<div class="alert alert-success" role="alert">' . $Client->getErrors() .'</div>';
|
||||
|
||||
} else {
|
||||
|
||||
/** Adição de elementos na array */
|
||||
$message = '<div class="alert alert-success" role="alert">' . ($ClientValidate->getClientid() > 0 ? 'Não foi possível atualizar o cadastro' : 'Não foi possível efetuar o cadastro') .'</div>';
|
||||
}
|
||||
|
||||
/** Result **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'title' => 'Atenção',
|
||||
'message' => $message,
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
/** Caso o token de acesso seja inválido, informo */
|
||||
}else{
|
||||
|
||||
/** Informa que o usuário precisa efetuar autenticação junto ao sistema */
|
||||
$authenticate = true;
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException('Sua sessão expirou é necessário efetuar nova autenticação junto ao sistema', 0);
|
||||
}
|
||||
|
||||
} catch (Exception $exception) {
|
||||
|
||||
/** Controle de mensagens */
|
||||
/*$message = '<span class="badge badge-primary">Detalhes.:</span> ' . 'código = ' . $exception->getCode() . ' - linha = ' . $exception->getLine() . ' - arquivo = ' . $exception->getFile() . '</br>';
|
||||
$message .= '<span class="badge badge-primary">Mensagem.:</span> ' . $exception->getMessage();*/
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 500,
|
||||
'message' => '<div class="alert alert-danger" role="alert">'.$exception->getMessage().'</div>',
|
||||
'title' => 'Atenção',
|
||||
'type' => 'exception',
|
||||
'authenticate' => $authenticate
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
}
|
||||
486
vendor/action/log/log_save.php
vendored
Normal file
486
vendor/action/log/log_save.php
vendored
Normal file
|
|
@ -0,0 +1,486 @@
|
|||
<?php
|
||||
|
||||
/** Carregamento da classe de gerar PDF */
|
||||
require_once('vendor/library/mpdf/vendor/autoload.php');
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\model\Log;
|
||||
use vendor\model\Client;
|
||||
use vendor\model\Backup;
|
||||
use vendor\model\Station;
|
||||
use vendor\model\StationDisk;
|
||||
use vendor\model\StationFolder;
|
||||
use vendor\controller\log\LogValidate;
|
||||
|
||||
try {
|
||||
|
||||
/** Instânciamento de classes */
|
||||
$Log = new Log();
|
||||
$Client = new Client();
|
||||
$Backup = new Backup();
|
||||
$Station = new Station();
|
||||
$StationDisk = new StationDisk();
|
||||
$LogValidate = new LogValidate();
|
||||
$StationFolder = new StationFolder();
|
||||
|
||||
/** Parametros de entrada */
|
||||
$key = isset($_POST['key']) ? (string)filter_input(INPUT_POST, 'key', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$file = isset($_POST['file']) ? (string)filter_input(INPUT_POST, 'file', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$dir = 'rel/';
|
||||
$header = '';
|
||||
$body = '';
|
||||
$i = 0;
|
||||
$robot = 0;
|
||||
$color = 0;
|
||||
$serverName = null;
|
||||
$urlRel = $_SERVER['HTTP_HOST'];
|
||||
|
||||
/** Efetua a verificação dos campos de entrada */
|
||||
$LogValidate->setKey($key);
|
||||
$LogValidate->setFile($file);
|
||||
|
||||
/** Verifica se não existem erros a serem informados,
|
||||
* caso não haja erro(s) salvo os dados ou
|
||||
* efetua o cadastro de um novo*/
|
||||
|
||||
/** Verifico a existência de erros */
|
||||
if (!empty($LogValidate->getErrors())) {
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException($LogValidate->getErrors(), 0);
|
||||
} else {
|
||||
|
||||
/** Converte o json em objeto para manipular o mesmo */
|
||||
$jsonLog = json_decode($LogValidate->getFile());
|
||||
|
||||
/** Verifica se o cliente informado existe */
|
||||
$ClientResult = $Client->GetCns($jsonLog->cns);
|
||||
|
||||
/** Caso o cliente não exista, cadastro o mesmo */
|
||||
if ($ClientResult->client_id == 0) {
|
||||
|
||||
/** Caso o cliente não exista, cadastra o novo */
|
||||
if (!$Client->Save(
|
||||
null,
|
||||
$jsonLog->cns,
|
||||
$jsonLog->cartorio,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)) {
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException('Não foi possível cadastrar o cartório', 0);
|
||||
}
|
||||
}
|
||||
|
||||
/** Id do cliente */
|
||||
$clientId = $ClientResult->client_id > 0 ? $ClientResult->client_id : $Client->getId();
|
||||
|
||||
/** Consulta se a estação já foi cadastrada */
|
||||
$StationResult = $Station->Search($clientId, $jsonLog->estacao);
|
||||
|
||||
/** Verifica se a estação já foi cadastrada */
|
||||
if ($StationResult->station_id == 0) {
|
||||
|
||||
if (!$Station->Save(
|
||||
null,
|
||||
$clientId,
|
||||
null,
|
||||
trim($jsonLog->estacao),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
1,
|
||||
trim($jsonLog->server->sistema_operacional),
|
||||
trim($jsonLog->server->cpu),
|
||||
trim($jsonLog->server->memory)
|
||||
)) {
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException($Station->getErrors(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
/** Id da estação */
|
||||
$stationId = $StationResult->station_id > 0 ? $StationResult->station_id : $Station->getId();
|
||||
|
||||
// Percorre cada disco (C:, D:, etc.)
|
||||
foreach ($jsonLog->disk as $drive => $details) {
|
||||
|
||||
/** Consulta se o disco já foi cadastrado */
|
||||
$StationDiskResult = $StationDisk->Search($stationId, $drive);
|
||||
|
||||
/** Prepara o Id da estação */
|
||||
$stationDiskId = $StationDiskResult->station_disk_id > 0 ? $StationDiskResult->station_disk_id : 0;
|
||||
|
||||
// Percorre cada atributo do disco
|
||||
$i = 0;
|
||||
foreach ($details as $key => $value) {
|
||||
|
||||
if ($i == 0) {
|
||||
$capacidade = $value;
|
||||
}
|
||||
|
||||
if ($i == 1) {
|
||||
$utilizados = $value;
|
||||
}
|
||||
|
||||
if ($i == 2) {
|
||||
$disponivel = $value;
|
||||
}
|
||||
|
||||
if ($i == 3) {
|
||||
$disponivel_percentual = $value;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
/** Grava o novo disco ou atualiza o atual */
|
||||
if (!$StationDisk->Save(
|
||||
$stationDiskId,
|
||||
$stationId,
|
||||
$drive,
|
||||
$capacidade,
|
||||
$utilizados,
|
||||
$disponivel,
|
||||
$disponivel_percentual
|
||||
)) {
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException($StationDisk->getErrors(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Percorre a pasta Ged
|
||||
foreach ($jsonLog->ged as $path => $details) {
|
||||
|
||||
/** Consulta se o disco já foi cadastrado */
|
||||
$StationFolderResult = $StationFolder->Search($stationId, $path);
|
||||
|
||||
/** Prepara o Id da estação */
|
||||
$stationFolderId = $StationFolderResult->station_folder_id > 0 ? $StationFolderResult->station_folder_id : 0;
|
||||
|
||||
// Percorre cada atributo da pasta
|
||||
foreach ($details as $key => $value) {
|
||||
|
||||
/** Grava uma nova pasta ou atualiza o atual */
|
||||
if (!$StationFolder->Save(
|
||||
$stationFolderId,
|
||||
$stationId,
|
||||
$path,
|
||||
$value,
|
||||
$value
|
||||
)) {
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException($StationDisk->getErrors(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Exclui os registros anteriores */
|
||||
$Backup->Delete($clientId, $stationId);
|
||||
|
||||
// Percorre a pasta Backup
|
||||
foreach ($jsonLog->backup as $file => $details) {
|
||||
|
||||
|
||||
// Percorre cada atributo da pasta
|
||||
$i = 0;
|
||||
foreach ($details as $key => $value) {
|
||||
|
||||
if ($i == 0) {
|
||||
$fileDate = $Main->DataDB($value);
|
||||
}
|
||||
|
||||
if ($i == 1) {
|
||||
$fileHour = $value;
|
||||
}
|
||||
|
||||
if ($i == 2) {
|
||||
$period = $value;
|
||||
}
|
||||
|
||||
if ($i == 3) {
|
||||
$day = $value;
|
||||
}
|
||||
|
||||
if ($i == 4) {
|
||||
$size = $value;
|
||||
}
|
||||
|
||||
if ($i == 5) {
|
||||
$path = $value;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
/** Grava o arquivo de backup */
|
||||
$Backup->Save(
|
||||
$clientId,
|
||||
$stationId,
|
||||
$file,
|
||||
$fileDate,
|
||||
$fileHour,
|
||||
$period,
|
||||
$day,
|
||||
$size,
|
||||
$path
|
||||
);
|
||||
}
|
||||
|
||||
/** Exclui o log anterior da estação correspondente */
|
||||
$Log->Delete($clientId, $stationId);
|
||||
|
||||
/** Grava o arquivo de log */
|
||||
if (!$Log->Save($clientId, $stationId, $LogValidate->getFile())) {
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException('Não foi possível cadastrar o arquivo de log', 0);
|
||||
}
|
||||
|
||||
/** Gera o PDF com o resumo do cartório */
|
||||
|
||||
/** Aumenta o uso de memória */
|
||||
ini_set('memory_limit', '512M');
|
||||
|
||||
/** Inicio do relatório */
|
||||
|
||||
/** Instancia da classe Mpdf */
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'mode' => 'utf-8',
|
||||
'orientation' => 'L'
|
||||
]);
|
||||
|
||||
/** Prepara o cabeçalho */
|
||||
$header = ' <table width="100%" style="margin:none; font-size:11px; font-family:Arial, Helvetica, sans-serif; border-collapse: collapse">';
|
||||
$header .= ' <tr>';
|
||||
$header .= ' <td style="text-align: center; width: 95px"><img src="img/logo2.png" style="max-width:140px; padding: 2px; margin-right:30px"/></td>';
|
||||
$header .= ' <td colspan="6">';
|
||||
$header .= ' <h1>' . $ClientResult->name . '</h1>';
|
||||
$header .= ' </td>';
|
||||
$header .= ' </tr>';
|
||||
$header .= ' </table>';
|
||||
|
||||
/** Define i cabeçalho do relatório */
|
||||
$mpdf->SetHTMLHeader($header);
|
||||
|
||||
/** Define o rodapé do relatório */
|
||||
$mpdf->SetHTMLFooter('
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td width="100%" align="center">{PAGENO}/{nbpg}</td>
|
||||
</tr>
|
||||
</table>');
|
||||
|
||||
/** Adicionar as margens da página */
|
||||
$mpdf->AddPageByArray([
|
||||
'margin-top' => 28
|
||||
]);
|
||||
|
||||
|
||||
/** Consulta a quantidade de registros */
|
||||
$StationResult = $Station->All($clientId);
|
||||
|
||||
/** Lista as estações do cliente */
|
||||
foreach ($StationResult as $StationKey => $Result) {
|
||||
|
||||
/** Inicio do corpo do relatório */
|
||||
|
||||
/** Dados do servidor */
|
||||
$body .= ' <table width="100%" style="margin:none; font-size:11px; font-family:Arial, Helvetica, sans-serif; border-collapse: collapse;">';
|
||||
$body .= ' <tr>';
|
||||
$body .= ' <td colspan="4"><h3>Detalhes Servidor</h3></td>';
|
||||
$body .= ' <tr/> ';
|
||||
$body .= ' <tr style="background-color: #333;">';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">DESCRIÇÃO</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">SO</td>';
|
||||
// $body .= ' <td style="color: #FFF; padding: 4px; text-align: center; width: 90px">CPU</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center">MEMÓRIA</td>';
|
||||
$body .= ' </tr>';
|
||||
$body .= ' <tr style="background-color: #EEEEEE;">';
|
||||
$body .= ' <td style="text-align: center; width: 33%">' . $Result->description . '</td>';
|
||||
$body .= ' <td style="text-align: center; width: 33%">' . $Result->operating_system . '</td>';
|
||||
// $body .= ' <td style="text-align: center; width: 90px">'.htmlspecialchars($Result->cpu).'</td>';
|
||||
$body .= ' <td style="text-align: center; width: 33%">' . $Result->memory . '</td>';
|
||||
$body .= ' </tr>';
|
||||
$body .= ' </table>';
|
||||
|
||||
|
||||
/** Discos */
|
||||
$body .= ' <table width="100%" style="margin:none; margin-top:40px; font-size:11px; font-family:Arial, Helvetica, sans-serif; border-collapse: collapse;">';
|
||||
$body .= ' <tr>';
|
||||
$body .= ' <td colspan="4"><h3>Discos</h3></td>';
|
||||
$body .= ' <tr/> ';
|
||||
$body .= ' <tr style="background-color: #333;">';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">DESCRIÇÃO</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">CAPACIDADE</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">UTILIZADOS</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center">DISPONÍVEL</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center">DISPONÍVEL %</td>';
|
||||
$body .= ' </tr>';
|
||||
|
||||
/** Consulta a quantidade de registros */
|
||||
$StationDiskResult = $StationDisk->All($Result->station_id);
|
||||
|
||||
/** Lista as estações do cliente */
|
||||
foreach ($StationDiskResult as $StationDiskKey => $ResultDisk) {
|
||||
|
||||
|
||||
$body .= ' <tr ' . ($i % 2 == 0 ? 'style="background-color: #EEEEEE;"' : '') . '>';
|
||||
$body .= ' <td width="160" align="center">' . $ResultDisk->description . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . $ResultDisk->capacity . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . $ResultDisk->used . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . $ResultDisk->available . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . $ResultDisk->available_percentage . '%</td>';
|
||||
$body .= ' </tr>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
$body .= ' </table>';
|
||||
|
||||
|
||||
|
||||
/** Ged */
|
||||
$body .= ' <table width="100%" style="margin:none; font-size:11px; margin-top:40px; font-family:Arial, Helvetica, sans-serif; border-collapse: collapse;">';
|
||||
$body .= ' <tr>';
|
||||
$body .= ' <td colspan="4"><h3>Ged</h3></td>';
|
||||
$body .= ' <tr/> ';
|
||||
$body .= ' <tr style="background-color: #333;">';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">ATUALIZADO</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">PATH</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">QTDE</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center">QTDE ATUAL</td>';
|
||||
$body .= ' </tr>';
|
||||
|
||||
/** Consulta a quantidade de registros */
|
||||
$StationFolderResult = $StationFolder->All($Result->station_id);
|
||||
|
||||
/** Lista as estações do cliente */
|
||||
foreach ($StationFolderResult as $StationFolderKey => $ResultFolder) {
|
||||
|
||||
|
||||
$body .= ' <tr ' . ($i % 2 == 0 ? 'style="background-color: #EEEEEE;"' : '') . '>';
|
||||
$body .= ' <td width="160" align="center">' . (!empty($ResultFolder->last_update) ? date('d/m/Y H:i:s', strtotime($ResultFolder->last_update)) : null) . '</td>';
|
||||
$body .= ' <td width="160">' . $ResultFolder->folder_path . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . $ResultFolder->amount_of_files . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . $ResultFolder->amount_of_files_current . '</td>';
|
||||
$body .= ' </tr>';
|
||||
$i++;
|
||||
}
|
||||
|
||||
$body .= ' </table>';
|
||||
|
||||
|
||||
|
||||
/** Backup */
|
||||
$body .= ' <table width="100%" style="margin:none; font-size:11px; margin-top:40px; font-family:Arial, Helvetica, sans-serif; border-collapse: collapse;">';
|
||||
$body .= ' <tr>';
|
||||
$body .= ' <td colspan="4"><h3>Backup</h3></td>';
|
||||
$body .= ' <tr/> ';
|
||||
$body .= ' <tr style="background-color: #333;">';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">ARQUIVO</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">DATA</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">HORA</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center;">DIA</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center">TAMANHO</td>';
|
||||
$body .= ' <td style="color: #FFF; padding: 4px; text-align: center">CAMINHO</td>';
|
||||
$body .= ' </tr>';
|
||||
|
||||
/** Consulta a quantidade de registros */
|
||||
$BackupResult = $Backup->All($Result->client_id, $Result->station_id);
|
||||
|
||||
/** Lista as estações do cliente */
|
||||
foreach ($BackupResult as $BackupKey => $ResultBackup) {
|
||||
|
||||
/** Verifica se existe arquivo com arquivo menor que 1kb */
|
||||
if (strpos($ResultBackup->size, "B") !== false) {
|
||||
|
||||
/** Limpa o nome do tamanho do arquivo */
|
||||
$size = str_replace('B', '', $ResultBackup->size);
|
||||
$size = str_replace('.', '', $size);
|
||||
|
||||
if ((int)$size < 1024) {
|
||||
|
||||
$robot++;
|
||||
$color++;
|
||||
}
|
||||
}
|
||||
|
||||
$body .= ' <tr style="' . ($color > 0 ? 'background-color: #FFD7AE;' : ($i % 2 == 0 ? 'background-color: #EEEEEE;' : '')) . '">';
|
||||
$body .= ' <td width="160">' . $ResultBackup->file . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . date('d/m/Y', strtotime($ResultBackup->file_date)) . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . date('H:i:s', strtotime($ResultBackup->file_hour)) . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . $ResultBackup->day . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . $ResultBackup->size . '</td>';
|
||||
$body .= ' <td width="160" align="center">' . $ResultBackup->path . '</td>';
|
||||
$body .= ' </tr>';
|
||||
$i++;
|
||||
$color = 0;
|
||||
}
|
||||
|
||||
$body .= ' </table>';
|
||||
|
||||
$serverName = $Result->description;
|
||||
}
|
||||
|
||||
|
||||
/** Acrescenta os dados ao corpo do relatório */
|
||||
$mpdf->WriteHTML($body);
|
||||
|
||||
/** Nome que será dado ao relatório */
|
||||
$nameFile = $ClientResult->cns . '.pdf';
|
||||
|
||||
/** Salva o relatório em uma pasta temporária */
|
||||
$mpdf->Output($dir . $nameFile);
|
||||
|
||||
/** Verifica se o arquivo PDF foi gerado */
|
||||
if (is_file($dir . $nameFile)) {
|
||||
|
||||
/** Verifica se é para enviar a notificação para o Telegram */
|
||||
if ($robot > 0) {
|
||||
|
||||
/** Monta a mensagem de envio */
|
||||
$message = "(" . $ClientResult->cns . ")" . $ClientResult->name . "\n";
|
||||
$message .= "Data: " . date('d/m/Y') . "\n";
|
||||
$message .= "Hora: " . date('H:i:s') . "\n";
|
||||
$message .= "Estação: " . $Result->description . "\n\n";
|
||||
$message .= "Para gerenciamento completo, acesse:\n";
|
||||
$message .= $urlRel."\n\n";
|
||||
$message .= "Acesse o relatório detalhado no link abaixo:\n";
|
||||
$message .= $urlRel . $dir . $nameFile . "\n\n";
|
||||
|
||||
|
||||
/** Envia o log para o bot */
|
||||
$Log->sendMessage($message, $ClientResult->cns);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception $exception) {
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'message' => '<div class="alert alert-danger" role="alert">' . $exception->getMessage() . '</div>',
|
||||
'title' => 'Atenção',
|
||||
'type' => 'exception'
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
}
|
||||
138
vendor/action/station/station_save.php
vendored
Normal file
138
vendor/action/station/station_save.php
vendored
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\model\Station;
|
||||
use vendor\controller\station\StationValidate;
|
||||
|
||||
try{
|
||||
|
||||
/** Instânciamento de classes */
|
||||
$Station = new Station();
|
||||
$StationValidate = new StationValidate();
|
||||
|
||||
/** Parametros de entrada */
|
||||
$description = isset($_POST['description']) ? (string)filter_input(INPUT_POST,'description', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$ip = isset($_POST['ip']) ? (string)filter_input(INPUT_POST,'ip', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$port = isset($_POST['port']) ? (int)filter_input(INPUT_POST,'port', FILTER_SANITIZE_NUMBER_INT) : '';
|
||||
$networkPath = isset($_POST['network_path']) ? (string)filter_input(INPUT_POST,'network_path', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$connectionName = isset($_POST['connection_name']) ? (string)filter_input(INPUT_POST,'connection_name', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$connectionId = isset($_POST['connection_id']) ? (int)filter_input(INPUT_POST,'connection_id', FILTER_SANITIZE_NUMBER_INT) : 0;
|
||||
$connectionUser = isset($_POST['connection_user']) ? (string)filter_input(INPUT_POST,'connection_user', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$connectionPassword = isset($_POST['connection_password']) ? (string)filter_input(INPUT_POST,'connection_password', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$type = isset($_POST['type']) ? (string)filter_input(INPUT_POST,'type', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$observation = isset($_POST['observation']) ? (string)filter_input(INPUT_POST,'observation', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$operatingSystem = isset($_POST['operating_system']) ? (string)filter_input(INPUT_POST,'operating_system', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$cpu = isset($_POST['cpu']) ? (string)filter_input(INPUT_POST,'cpu', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$memory = isset($_POST['memory']) ? (string)filter_input(INPUT_POST,'memory', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$stationId = isset($_POST['station_id']) ? (int)filter_input(INPUT_POST,'station_id', FILTER_SANITIZE_NUMBER_INT) : 0;
|
||||
$clientId = isset($_POST['client_id']) ? (int)filter_input(INPUT_POST,'client_id', FILTER_SANITIZE_NUMBER_INT) : 0;
|
||||
$userId = isset($_SESSION['USERSID']) && $_SESSION['USERSID'] > 0 ? $_SESSION['USERSID'] : 0;
|
||||
|
||||
|
||||
/** Validando os campos de entrada */
|
||||
$StationValidate->setDescription($description);
|
||||
$StationValidate->setIp($ip);
|
||||
$StationValidate->setPort($port);
|
||||
$StationValidate->setNetworkPath($networkPath);
|
||||
$StationValidate->setConnectionName($connectionName);
|
||||
$StationValidate->setConnectionId($connectionId);
|
||||
$StationValidate->setConnectionUser($connectionUser);
|
||||
$StationValidate->setConnectionPassword($connectionPassword);
|
||||
$StationValidate->setType($type);
|
||||
$StationValidate->setObservation($observation);
|
||||
$StationValidate->setOperatingSystem($operatingSystem);
|
||||
$StationValidate->setCpu($cpu);
|
||||
$StationValidate->setMemory($memory);
|
||||
$StationValidate->setStationId($stationId);
|
||||
$StationValidate->setClientId($clientId);
|
||||
$StationValidate->setUserId($userId);
|
||||
|
||||
|
||||
/** Verifico a existência de erros */
|
||||
if (!empty($StationValidate->getErrors())) {
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'title' => 'Atenção',
|
||||
'message' => '<div class="alert alert-danger" role="alert">'.$StationValidate->getErrors().'</div>',
|
||||
|
||||
];
|
||||
|
||||
} else {
|
||||
|
||||
/** Efetua um novo cadastro ou salva os novos dados */
|
||||
if ($Station->Save($StationValidate->getStationId(),
|
||||
$StationValidate->getClientId(),
|
||||
$StationValidate->getUserId(),
|
||||
$StationValidate->getDescription(),
|
||||
$StationValidate->getIp(),
|
||||
$StationValidate->getPort(),
|
||||
$StationValidate->getNetworkPath(),
|
||||
$StationValidate->getConnectionName(),
|
||||
$StationValidate->getConnectionId(),
|
||||
$StationValidate->getConnectionUser(),
|
||||
$StationValidate->getConnectionPassword(),
|
||||
$StationValidate->getObservation(),
|
||||
$StationValidate->getType(),
|
||||
$StationValidate->getOperatingSystem(),
|
||||
$StationValidate->getCpu(),
|
||||
$StationValidate->getMemory())){
|
||||
|
||||
/** Prepara a mensagem de retorno - sucesso */
|
||||
$message = '<div class="alert alert-success" role="alert">'.($StationValidate->getStationId() > 0 ? 'Cadastro atualizado com sucesso' : 'Cadastro efetuado com sucesso').'</div>';
|
||||
|
||||
/** Result **/
|
||||
$result = [
|
||||
|
||||
'cod' => 200,
|
||||
'title' => 'Atenção',
|
||||
'message' => $message,
|
||||
'redirect' => '',
|
||||
|
||||
];
|
||||
|
||||
} else {
|
||||
|
||||
/** Prepara a mensagem de retorno - erro */
|
||||
$message = '<div class="alert alert-success" role="alert">'.($StationValidate->getStationId() > 0 ? 'Não foi possível atualizar o cadastro' : 'Não foi possível efetuar o cadastro') .'</div>';
|
||||
|
||||
/** Result **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'title' => 'Atenção',
|
||||
'message' => $message,
|
||||
'redirect' => '',
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
}catch(Exception $exception){
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'message' => $exception->getMessage(),
|
||||
'title' => 'Erro Interno',
|
||||
'type' => 'exception',
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
}
|
||||
174
vendor/action/users/users_access.php
vendored
Normal file
174
vendor/action/users/users_access.php
vendored
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
<?php
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\model\Users;
|
||||
use vendor\controller\users\UsersValidate;
|
||||
|
||||
try{
|
||||
|
||||
/** Instânciamento de classes */
|
||||
$Users = new Users();
|
||||
$UsersValidate = new UsersValidate();
|
||||
|
||||
/** Parametros de entrada */
|
||||
$userEmail = isset($_POST['user-email']) ? (string)filter_input(INPUT_POST, 'user-email', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$userPassword = isset($_POST['user-password']) ? (string)filter_input(INPUT_POST, 'user-password', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$rememberAccess = isset($_POST['remember_access']) ? (string)filter_input(INPUT_POST, 'remember_access', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
|
||||
|
||||
/** Validando os campos de entrada */
|
||||
$UsersValidate->setEmail($userEmail);
|
||||
$UsersValidate->setPassword($userPassword);
|
||||
|
||||
/** Verifica se não existem erros a serem informados */
|
||||
if (!empty($UsersValidate->getErrors())) {
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException($UsersValidate->getErrors(), 0);
|
||||
|
||||
} else {
|
||||
|
||||
/** Consulta o usuário junto ao banco de dados para verificar se é o primeiro acesso*/
|
||||
$UsersResult = $Users->Access($UsersValidate->getEmail(), $UsersValidate->getPassword(), 'S');
|
||||
|
||||
/** Verifica se não existem resultados */
|
||||
if( !is_object($UsersResult) ){
|
||||
|
||||
/** Consulta o usuário junto ao banco de dados */
|
||||
$UsersResult = $Users->Access($userEmail, $userPassword, '');
|
||||
|
||||
/** Verifica se não existem resultados */
|
||||
if( !is_object($UsersResult) ){
|
||||
|
||||
throw new InvalidArgumentException('Usuário não localizado, verifique o seu e-mail e senha.', 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Caso existam resultados */
|
||||
if( is_object($UsersResult) ){
|
||||
|
||||
/** Verifica se o usuário foi localizado */
|
||||
if($UsersResult->user_id > 0){
|
||||
|
||||
/** Carrega as configurações de criptografia */
|
||||
$config = $Main->LoadConfigPublic();
|
||||
|
||||
/** Parametros para descriptografar dados */
|
||||
$method = $config->{'app'}->{'security'}->{'method'};
|
||||
$firstKey = $config->{'app'}->{'security'}->{'first_key'};
|
||||
|
||||
/** Inicia a sessão do usuário */
|
||||
$Main->SessionStart();
|
||||
|
||||
/** Cria as sessões pessoais necessárias para o usuário */
|
||||
$_SESSION['USERSID'] = (int)$UsersResult->user_id;
|
||||
$_SESSION['USERSACLID'] = (int)$UsersResult->users_acl_id;
|
||||
$_SESSION['USERSEMAIL'] = (string)$UsersResult->email;
|
||||
$_SESSION['USERSNAMEFIRST'] = $Main->decryptData((string)$UsersResult->name_first);
|
||||
$_SESSION['USERSACCESSFIRST'] = (string)$UsersResult->access_first;
|
||||
$_SESSION['USERSACCESSLAST'] = (string)$UsersResult->access_last;
|
||||
|
||||
/** Cria as sessões da empresa a qual o usuário está vinculado */
|
||||
$_SESSION['USERSCOMPANYID'] = (int)$UsersResult->company_id;
|
||||
$_SESSION['USERSCOMPANYFANTASYNAME'] = (string)$UsersResult->fantasy_name;
|
||||
$_SESSION['USERSCOMPANYNAME'] = (string)$UsersResult->company_name;
|
||||
$_SESSION['USERSCOMPANYDOCUMENT'] = (string)$UsersResult->document;
|
||||
|
||||
/** Cria o Token do usuário */
|
||||
$_SESSION['USERSTOKEN'] = $Main->encryptData($config->app->security->hash.'-'.(int)$UsersResult->user_id.'-'.session_id());
|
||||
|
||||
/** Inicialização da sessão do usuário */
|
||||
$_SESSION['USERSSTARTTIME'] = date("Y-m-d H:i:s");
|
||||
|
||||
/** Gera o cookie do usuário com duração de um dia */
|
||||
setcookie("UserEmail", $Main->encryptData($UsersResult->email), time() + (86400 * 30), "/"); // 86400 = 1 day
|
||||
|
||||
if($rememberAccess == 'S'){
|
||||
|
||||
setcookie("UserPassword", $Main->encryptData($UsersValidate->getPassword()), time() + (86400 * 30), "/"); // 86400 = 1 day
|
||||
setcookie("RememberAccess", $rememberAccess, time() + (86400 * 30), "/"); // 86400 = 1 day
|
||||
|
||||
}
|
||||
|
||||
/** Verifica se não é o primeiro acesso para validar a senha */
|
||||
if( (!empty($UsersResult->password)) && (!empty($UsersResult->access_first)) ){
|
||||
|
||||
/** Verifica se a senha informada confere com seu hash */
|
||||
if ( !password_verify($UsersValidate->getPassword(), $UsersResult->password) ) {
|
||||
|
||||
throw new InvalidArgumentException('Autenticação falhou, verifique o seu e-mail e senha.', 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Verifica se não é o primeiro acesso */
|
||||
if($UsersResult->password_temp_confirm == 'N'){
|
||||
|
||||
/** Atualizo o acesso junto ao cadastro do usuário, caso não seja o primeiro acesso */
|
||||
if($Users->AccessInfo('new')){
|
||||
|
||||
|
||||
/** Informa o resultado positivo **/
|
||||
$result = [
|
||||
|
||||
'cod' => 202,
|
||||
'title' => '',
|
||||
'url' => '', # Define uma url especifica dentro da aplicação para carregar
|
||||
'message' => 'Usuário autenticado com sucesso',
|
||||
|
||||
];
|
||||
|
||||
|
||||
}else{/** Falha na gravação de log do usuário */
|
||||
|
||||
throw new InvalidArgumentException('Não foi possível efetuar o log de acesso do usuário', 0);
|
||||
}
|
||||
|
||||
}else{/** Caso seja o primeiro acesso, informo o redirecionamento */
|
||||
|
||||
/** Informa o resultado positivo **/
|
||||
$result = [
|
||||
|
||||
'cod' => 301,
|
||||
'title' => '',
|
||||
'url' => 'first-access',/** Caso seja preciso encaminhar para uma url especifica */
|
||||
'message' => 'É necessário o cadastro da senha definitiva',
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
}else{//Caso o usuário não tenha sido localizado, informo
|
||||
|
||||
throw new InvalidArgumentException('Usuário não localizado, verifique o seu e-mail e senha.', 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}catch(Exception $exception){
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'message' => '<div class="alert alert-danger" role="alert">'.$exception->getMessage().'</div>',
|
||||
'title' => 'Falha na autenticação',
|
||||
'type' => 'exception',
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
}
|
||||
68
vendor/action/users/users_downtime.php
vendored
Normal file
68
vendor/action/users/users_downtime.php
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
try{
|
||||
|
||||
|
||||
/**Caso o usuário esteja logado no sistema e o tempo de inatividade tenha excedido o permitido */
|
||||
if($Main->checkTime($_SESSION['USERSSTARTTIME']) > $Main->getSessionTime())
|
||||
{
|
||||
|
||||
/** Limpa as sessões atuais */
|
||||
foreach($_SESSION as $session){
|
||||
|
||||
unset($session);
|
||||
}
|
||||
|
||||
// gera um novo id para a sessao
|
||||
@session_regenerate_id();
|
||||
|
||||
/** Caso a sessão tenha excedido o tempo máximo ocioso informo */
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'message' => 'Tempo de inatividade atingido',
|
||||
'title' => 'Atenção',
|
||||
'type' => 'exception',
|
||||
'screensaver' => true,
|
||||
'sessionTime' => $Main->getSessionTime()
|
||||
|
||||
];
|
||||
|
||||
}else{
|
||||
|
||||
/** Caso a sessão esteja dentro do tempo permitido ocioso informo */
|
||||
$result = [
|
||||
|
||||
'cod' => 200,
|
||||
'message' => 'Usuário em atividade',
|
||||
'title' => 'Atenção',
|
||||
'sessionTime' => $Main->getSessionTime()
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
}catch(Exception $exception){
|
||||
|
||||
/** Preparo a mensagem de retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'message' => '<div class="alert alert-danger" role="alert">'.$exception->getMessage().'</div>',
|
||||
'title' => 'Atenção',
|
||||
'type' => 'exception',
|
||||
'screensaver' => true,
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
}
|
||||
95
vendor/action/users/users_first_access.php
vendored
Normal file
95
vendor/action/users/users_first_access.php
vendored
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\model\Users;
|
||||
use vendor\controller\users\UsersValidate;
|
||||
|
||||
try{
|
||||
|
||||
/** Verifica se o usuário foi devidamente identificado */
|
||||
if( (isset($_SESSION['USERSID'])) && ($_SESSION['USERSID'] > 0) ){
|
||||
|
||||
/** Instânciamento de classes */
|
||||
$Users = new Users();
|
||||
$UsersValidate = new UsersValidate();
|
||||
|
||||
/** Parametros de entrada */
|
||||
$passwordInform = isset($_POST['password-inform']) ? (string)filter_input(INPUT_POST, 'password-inform', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$passwordConfirm = isset($_POST['password-confirm']) ? (string)filter_input(INPUT_POST, 'password-confirm', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
|
||||
/** Validando os campos de entrada */
|
||||
$UsersValidate->setPassword($passwordInform);
|
||||
$UsersValidate->setPasswordConfirm($passwordConfirm);
|
||||
|
||||
|
||||
/** Verifica se não existem erros a serem informados */
|
||||
if (!empty($UsersValidate->getErrors())) {
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException($UsersValidate->getErrors(), 0);
|
||||
|
||||
} else {
|
||||
|
||||
/** Atualiza a senha do usuário */
|
||||
if( $Users->UpdatePassword($passwordInform) ){
|
||||
|
||||
/** Atualizo o acesso junto ao cadastro do usuário */
|
||||
if($Users->AccessInfo( 'new' ) ){
|
||||
|
||||
/** Informa o primeiro acesso */
|
||||
$_SESSION['USERSACCESSFIRST'] = date('Y-m-d H:i:s');
|
||||
|
||||
/** Informa o resultado positivo **/
|
||||
$result = [
|
||||
|
||||
'cod' => 202 ,
|
||||
'title' => '',
|
||||
'url' => 'home',
|
||||
'message' => 'Usuário autenticado com sucesso',
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
}else{/** Falha na gravação de log do usuário */
|
||||
|
||||
throw new InvalidArgumentException('Não foi possível efetuar o log de acesso do usuário', 0);
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
throw new InvalidArgumentException('Não foi possível cadastrar a senha de acesso, tente novamente dentro de alguns minutos ou entre em contato com o suporte técnico', 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else{/** Informa que o usuário não foi identificado */
|
||||
|
||||
throw new InvalidArgumentException('Usuário não identificado para esta solicitação', 0);
|
||||
}
|
||||
|
||||
|
||||
}catch(Exception $exception){
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'message' => '<div class="alert alert-danger" role="alert">'.$exception->getMessage().'</div>',
|
||||
'title' => 'Falha na autenticação',
|
||||
'type' => 'exception',
|
||||
'authenticate' => $authenticate
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
}
|
||||
61
vendor/action/users/users_logout.php
vendored
Normal file
61
vendor/action/users/users_logout.php
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
try{
|
||||
|
||||
|
||||
/** Inicia a sessão do usuário */
|
||||
$Main->SessionStart();
|
||||
|
||||
// destroi a sessao
|
||||
@session_destroy();
|
||||
|
||||
// gera um novo id para a sessao
|
||||
@session_regenerate_id();
|
||||
|
||||
|
||||
/** Informa o resultado positivo **/
|
||||
$result = [
|
||||
|
||||
'cod' => 99,
|
||||
'title' => '',
|
||||
'url' => '',/** Caso seja preciso redirecionar para uma url especifica */
|
||||
'message' => 'Sessão finalizada com sucesso',
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
}catch(Exception $exception){
|
||||
|
||||
/** Prepara a div com a informação de erro */
|
||||
$div = '<div class="col-lg-12">';
|
||||
$div .= ' <div class="card shadow mb-12">';
|
||||
$div .= ' <div class="card-header py-3">';
|
||||
$div .= ' <h6 class="m-0 font-weight-bold text-primary">Erro(s) encontrados.</h6>';
|
||||
$div .= ' </div>';
|
||||
$div .= ' <div class="card-body">';
|
||||
$div .= ' <p>' . $exception->getFile().'<br/>'.$exception->getMessage().'</p>';
|
||||
$div .= ' </div>';
|
||||
$div .= ' </div>';
|
||||
$div .= '</div>';
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'data' => $div,
|
||||
'title' => 'Erro Interno',
|
||||
'type' => 'exception',
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
}
|
||||
147
vendor/action/users/users_new_session.php
vendored
Normal file
147
vendor/action/users/users_new_session.php
vendored
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\model\Users;
|
||||
use vendor\controller\users\UsersValidate;
|
||||
|
||||
try{
|
||||
|
||||
/** Instânciamento de classes */
|
||||
$Users = new Users();
|
||||
$UsersValidate = new UsersValidate();
|
||||
|
||||
/** Parametros de entrada */
|
||||
$userPassword = isset($_POST['user-password']) ? (string)filter_input(INPUT_POST, 'user-password', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
|
||||
/** Validando os campos de entrada */
|
||||
$UsersValidate->setEmail($Main->decryptData($_COOKIE['UserEmail']));//Autentica o usuário a partir do cookie com o e-mail e a senha informada
|
||||
$UsersValidate->setPassword($userPassword);
|
||||
|
||||
/** Verifica se não existem erros a serem informados */
|
||||
if (!empty($UsersValidate->getErrors())) {
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException($UsersValidate->getErrors(), 0);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
/** Consulta o usuário junto ao banco de dados para verificar se é o primeiro acesso*/
|
||||
$UsersResult = $Users->Access($UsersValidate->getEmail(), $UsersValidate->getPassword(), 'N');
|
||||
|
||||
/** Verifica se existem resultados */
|
||||
if( is_object($UsersResult) ){
|
||||
|
||||
/** Verifica se o usuário foi localizado */
|
||||
if($UsersResult->user_id > 0){
|
||||
|
||||
/** Verifica se a senha informada confere com seu hash */
|
||||
if ( password_verify($UsersValidate->getPassword(), $UsersResult->password) ) {
|
||||
|
||||
/** Carrega as configurações de criptografia */
|
||||
$config = $Main->LoadConfigPublic();
|
||||
|
||||
/** Parametros para descriptografar dados */
|
||||
$method = $config->{'app'}->{'security'}->{'method'};
|
||||
$firstKey = $config->{'app'}->{'security'}->{'first_key'};
|
||||
|
||||
/** Inicia a sessão do usuário */
|
||||
$Main->SessionStart();
|
||||
|
||||
/** Cria as sessões pessoais necessárias para o usuário */
|
||||
$_SESSION['USERSID'] = (int)$UsersResult->user_id;
|
||||
$_SESSION['USERSACLID'] = (int)$UsersResult->users_acl_id;
|
||||
$_SESSION['USERSEMAIL'] = (string)$UsersResult->email;
|
||||
$_SESSION['USERSNAMEFIRST'] = $Main->decryptData((string)$UsersResult->name_first);
|
||||
$_SESSION['USERSACCESSFIRST'] = (string)$UsersResult->access_first;
|
||||
$_SESSION['USERSACCESSLAST'] = (string)$UsersResult->access_last;
|
||||
|
||||
/** Cria as sessões da empresa a qual o usuário está vinculado */
|
||||
$_SESSION['USERSCOMPANYID'] = (int)$UsersResult->company_id;
|
||||
$_SESSION['USERSCOMPANYFANTASYNAME'] = (string)$UsersResult->fantasy_name;
|
||||
$_SESSION['USERSCOMPANYNAME'] = (string)$UsersResult->company_name;
|
||||
$_SESSION['USERSCOMPANYDOCUMENT'] = (string)$UsersResult->document;
|
||||
|
||||
/** Cria o Token do usuário */
|
||||
$_SESSION['USERSTOKEN'] = $Main->encryptData($config->app->security->hash.'-'.(int)$UsersResult->user_id.'-'.session_id());
|
||||
|
||||
/** Inicialização da sessão do usuário */
|
||||
$_SESSION['USERSSTARTTIME'] = date("Y-m-d H:i:s");
|
||||
|
||||
/** Gera o cookie do usuário com duração de um dia */
|
||||
setcookie("UserEmail", $Main->encryptData($UsersResult->email), time() + (86400 * 30), "/"); // 86400 = 1 day
|
||||
|
||||
if($rememberAccess == 'S'){
|
||||
|
||||
setcookie("UserPassword", $Main->encryptData($UsersValidate->getPassword()), time() + (86400 * 30), "/"); // 86400 = 1 day
|
||||
setcookie("RememberAccess", $rememberAccess, time() + (86400 * 30), "/"); // 86400 = 1 day
|
||||
|
||||
}
|
||||
|
||||
/** Atualizo o acesso junto ao cadastro do usuário, caso não seja o primeiro acesso */
|
||||
if($Users->AccessInfo('new')){
|
||||
|
||||
|
||||
/** Informa o resultado positivo **/
|
||||
$result = [
|
||||
|
||||
'cod' => 96,
|
||||
'title' => '',
|
||||
'url' => '', # Define uma url especifica dentro da aplicação para carregar
|
||||
'message' => 'Usuário autenticado com sucesso',
|
||||
'sessionTime' => $Main->getSessionTime()
|
||||
|
||||
];
|
||||
|
||||
|
||||
}else{/** Falha na gravação de log do usuário */
|
||||
|
||||
throw new InvalidArgumentException('Não foi possível efetuar o log de acesso do usuário', 0);
|
||||
}
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
/** Caso a senha não esteja correta informo */
|
||||
}else{
|
||||
|
||||
throw new InvalidArgumentException('Senha informada não confere, tente novamente.', 0);
|
||||
}
|
||||
|
||||
/** Caso o usuário não tenha sido localizado, informo */
|
||||
}else{
|
||||
|
||||
throw new InvalidArgumentException('Usuário não localizado, verifique sua senha.', 0);
|
||||
}
|
||||
|
||||
/** Caso o usuário não tenha sido localizado informo */
|
||||
}else{
|
||||
|
||||
throw new InvalidArgumentException('Usuário não localizado, verifique sua senha.', 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}catch(Exception $exception){
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'message' => '<div class="alert alert-danger" role="alert">'.$exception->getMessage().'</div>',
|
||||
'title' => 'Falha na autenticação',
|
||||
'type' => 'exception',
|
||||
'screensaver' => true,
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
}
|
||||
165
vendor/action/users/users_save.php
vendored
Normal file
165
vendor/action/users/users_save.php
vendored
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
<?php
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\model\Users;
|
||||
use vendor\controller\mail\Mail;
|
||||
use vendor\controller\users\UsersValidate;
|
||||
|
||||
try{
|
||||
|
||||
/** Verifica se o token de acesso é válido */
|
||||
if($Main->verifyToken()){
|
||||
|
||||
/** Instânciamento de classes */
|
||||
$Users = new Users();
|
||||
$Mail = new Mail();
|
||||
$UsersValidate = new UsersValidate();
|
||||
|
||||
/** Parametros de entrada */
|
||||
$usersId = isset($_POST['users_id']) ? (int)filter_input(INPUT_POST, 'users_id', FILTER_SANITIZE_NUMBER_INT) : 0 ;
|
||||
$clientsId = isset($_POST['clients_id']) ? (int)filter_input(INPUT_POST, 'clients_id', FILTER_SANITIZE_NUMBER_INT) : 0;
|
||||
$companyId = isset($_POST['company_id']) ? (int)filter_input(INPUT_POST, 'company_id', FILTER_SANITIZE_SPECIAL_CHARS) : 0;
|
||||
$nameFirst = isset($_POST['name_first']) ? (string)filter_input(INPUT_POST, 'name_first', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$nameLast = isset($_POST['name_last']) ? (string)filter_input(INPUT_POST, 'name_last', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$email = isset($_POST['email']) ? (string)filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL) : '';
|
||||
$birthDate = isset($_POST['birth_date']) ? (string)filter_input(INPUT_POST, 'birth_date', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$genre = isset($_POST['genre']) ? (string)filter_input(INPUT_POST, 'genre', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$active = isset($_POST['active']) ? (string)filter_input(INPUT_POST, 'active', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$administrator = isset($_POST['administrator']) ? (string)filter_input(INPUT_POST, 'administrator', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$passwordTempConfirm = isset($_POST['password_temp_confirm']) ? (string)filter_input(INPUT_POST, 'password_temp_confirm', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$password = isset($_POST['password_temp']) ? (string)filter_input(INPUT_POST, 'password_temp', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
$passwordTemp = isset($_POST['password_temp']) ? (string)filter_input(INPUT_POST, 'password_temp', FILTER_SANITIZE_SPECIAL_CHARS) : '';
|
||||
|
||||
/** Validando os campos de entrada */
|
||||
$UsersValidate->setUsersId($usersId);
|
||||
$UsersValidate->setClientsId($clientsId);
|
||||
$UsersValidate->setCompanyId($companyId);
|
||||
$UsersValidate->setNameFirst($nameFirst);
|
||||
$UsersValidate->setNameLast($nameLast);
|
||||
$UsersValidate->setEmail($email);
|
||||
$UsersValidate->setBirthDate($birthDate);
|
||||
$UsersValidate->setGenre($genre);
|
||||
$UsersValidate->setActive($active);
|
||||
$UsersValidate->setAdministrator($administrator);
|
||||
$UsersValidate->setPasswordTempConfirm($passwordTempConfirm);
|
||||
$UsersValidate->setPassword($password);
|
||||
$UsersValidate->setPasswordTemp($passwordTemp);
|
||||
|
||||
/** Verifico a existência de erros */
|
||||
if (!empty($UsersValidate->getErrors())) {
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'title' => 'Atenção',
|
||||
'message' => '<div class="alert alert-danger" role="alert">'.$UsersValidate->getErrors().'</div>',
|
||||
|
||||
];
|
||||
|
||||
} else {
|
||||
|
||||
/** Verifica se o usuário já se encontra cadastrado */
|
||||
if($Users->CheckEmail($UsersValidate->getUsersId(), $UsersValidate->getClientsId(), $UsersValidate->getEmail()) > 0){
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException('O e-mail informado já está sendo utilizado', 0);
|
||||
}
|
||||
|
||||
|
||||
/** Efetua um novo cadastro ou salva os novos dados */
|
||||
if ($Users->Save($UsersValidate->getUsersId(), $UsersValidate->getClientsId(), $UsersValidate->getCompanyId(), $UsersValidate->getNameFirst(), $UsersValidate->getNameLast(), $UsersValidate->getEmail(), $UsersValidate->getBirthDate(), $UsersValidate->getGenre(), $UsersValidate->getActive(), $UsersValidate->getAdministrator(), $UsersValidate->getPassword(), $UsersValidate->getPasswordTemp(), $UsersValidate->getPasswordTempConfirm())){
|
||||
|
||||
|
||||
/** Verifica se é para enviar e-mail de acesso ao usuário */
|
||||
if($UsersValidate->getPasswordTempConfirm() == 'S'){
|
||||
|
||||
/** Trata a mensagem a ser enviada */
|
||||
$body = str_replace('{[EMAIL]}', $UsersValidate->getEmail(), base64_decode($settings->app->mail->messages->new_user));
|
||||
$body = str_replace('{[SENHA]}', $UsersValidate->getPassword(), $body);
|
||||
|
||||
/** Envia a mensagem */
|
||||
$Mail->sendMail($settings->app->mail->host,# Servidor do e-mail
|
||||
$settings->app->mail->username,# Usuário do e-mail
|
||||
$settings->app->mail->password,# Senha do e-mail de envio
|
||||
$settings->app->mail->port,# Porta de envio
|
||||
$settings->app->mail->from->email,# E-mail de envio
|
||||
$settings->app->mail->from->name,# Nome de envio
|
||||
$UsersValidate->getEmail(),# E-mai destino
|
||||
$settings->app->mail->from->name,# Nome destino
|
||||
'Dados de acesso para ambiente de impressão de boletos',# Assunto do e-mail
|
||||
$body# Mensagem a ser enviada
|
||||
);
|
||||
}
|
||||
|
||||
/** Adição de elementos na array */
|
||||
$message = '<div class="alert alert-success" role="alert">'.($UsersValidate->getUsersId() > 0 ? 'Cadastro atualizado com sucesso' : 'Cadastro efetuado com sucesso').'</div>';
|
||||
|
||||
/** Result **/
|
||||
$result = [
|
||||
|
||||
'cod' => 200,
|
||||
'title' => 'Atenção',
|
||||
'message' => $message,
|
||||
'redirect' => '',
|
||||
|
||||
];
|
||||
|
||||
} else {
|
||||
|
||||
/** Adição de elementos na array */
|
||||
$message = '<div class="alert alert-success" role="alert">' . ($UsersValidate->getUsersId() > 0 ? 'Não foi possível atualizar o cadastro' : 'Não foi possível efetuar o cadastro') .'</div>';
|
||||
|
||||
/** Result **/
|
||||
$result = [
|
||||
|
||||
'cod' => 0,
|
||||
'title' => 'Atenção',
|
||||
'message' => $message,
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
/** Caso o token de acesso seja inválido, informo */
|
||||
}else{
|
||||
|
||||
/** Informa que o usuário precisa efetuar autenticação junto ao sistema */
|
||||
$authenticate = true;
|
||||
|
||||
/** Informo */
|
||||
throw new InvalidArgumentException('Sua sessão expirou é necessário efetuar nova autenticação junto ao sistema', 0);
|
||||
}
|
||||
|
||||
} catch (Exception $exception) {
|
||||
|
||||
/** Controle de mensagens */
|
||||
/*$message = '<span class="badge badge-primary">Detalhes.:</span> ' . 'código = ' . $exception->getCode() . ' - linha = ' . $exception->getLine() . ' - arquivo = ' . $exception->getFile() . '</br>';
|
||||
$message .= '<span class="badge badge-primary">Mensagem.:</span> ' . $exception->getMessage();*/
|
||||
|
||||
/** Preparo o formulario para retorno **/
|
||||
$result = [
|
||||
|
||||
'cod' => 500,
|
||||
'message' => '<div class="alert alert-danger" role="alert">'.$exception->getMessage().'</div>',
|
||||
'title' => 'Atenção',
|
||||
'type' => 'exception',
|
||||
'authenticate' => $authenticate
|
||||
|
||||
];
|
||||
|
||||
/** Envio **/
|
||||
echo json_encode($result);
|
||||
|
||||
/** Paro o procedimento **/
|
||||
exit;
|
||||
|
||||
}
|
||||
8
vendor/autoload.php
vendored
Normal file
8
vendor/autoload.php
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
spl_autoload_register(function ($className) {
|
||||
|
||||
$filePath = str_replace('\\', DIRECTORY_SEPARATOR, $className);
|
||||
require_once($filePath . '.class.php');
|
||||
|
||||
});
|
||||
329
vendor/controller/backup/BackupValidate.class.php
vendored
Normal file
329
vendor/controller/backup/BackupValidate.class.php
vendored
Normal file
|
|
@ -0,0 +1,329 @@
|
|||
<?php
|
||||
/**
|
||||
* Classe BackupValidate.class.php
|
||||
* @filesource
|
||||
* @autor Kenio de Souza
|
||||
* @copyright Copyright 2024 - Souza Consultoria Tecnológica
|
||||
* @package vendor
|
||||
* @subpackage controller/backup
|
||||
* @version 1.0
|
||||
* @date 10/08/2024
|
||||
*/
|
||||
|
||||
|
||||
/** Defino o local onde esta a classe */
|
||||
namespace vendor\controller\backup;
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\controller\main\Main;
|
||||
|
||||
class BackupValidate
{
/** Declaro as variavéis da classe */
private $Main = null;
|
||||
private $errors = array();
|
||||
private $info = null;
|
||||
private $backupId = null;
private $clientId = null;
private $file = null;
private $fileDate = null;
private $fileHour = null;
private $period = null;
private $day = null;
private $size = null;
private $path = null;
private $dateRegister = null;
/** Construtor da classe */
|
||||
function __construct()
{
|
||||
|
||||
/** Instânciamento da classe de validação */
|
||||
$this->Main = new Main();
|
||||
|
||||
}
|
||||
/** Método trata campo backup_id */
|
||||
public function setBackupId(int $backupId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->backupId = isset($backupId) ? $this->Main->antiInjection($backupId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->backupId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "backup_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo client_id */
|
||||
public function setClientId(int $clientId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->clientId = isset($clientId) ? $this->Main->antiInjection($clientId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->clientId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "client_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo file */
|
||||
public function setFile(string $file) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->file = isset($file) ? $this->Main->antiInjection($file) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->file))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "file", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo file_date */
|
||||
public function setFileDate(string $fileDate) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->fileDate = isset($fileDate) ? $this->Main->antiInjection($fileDate) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->fileDate))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "file_date", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo file_hour */
|
||||
public function setFileHour(string $fileHour) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->fileHour = isset($fileHour) ? $this->Main->antiInjection($fileHour) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->fileHour))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "file_hour", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo period */
|
||||
public function setPeriod(int $period) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->period = isset($period) ? $this->Main->antiInjection($period) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->period))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "period", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo day */
|
||||
public function setDay(string $day) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->day = isset($day) ? $this->Main->antiInjection($day) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->day))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "day", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo size */
|
||||
public function setSize(string $size) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->size = isset($size) ? $this->Main->antiInjection($size) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->size))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "size", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo path */
|
||||
public function setPath(string $path) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->path = isset($path) ? $this->Main->antiInjection($path) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->path))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "path", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo date_register */
|
||||
public function setDateRegister(string $dateRegister) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->dateRegister = isset($dateRegister) ? $this->Main->antiInjection($dateRegister) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->dateRegister))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "date_register", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo backup_id */
|
||||
public function getBackupId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->backupId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo client_id */
|
||||
public function getClientId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->clientId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo file */
|
||||
public function getFile() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->file;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo file_date */
|
||||
public function getFileDate() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->fileDate;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo file_hour */
|
||||
public function getFileHour() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->fileHour;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo period */
|
||||
public function getPeriod() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->period;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo day */
|
||||
public function getDay() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->day;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo size */
|
||||
public function getSize() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->size;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo path */
|
||||
public function getPath() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->path;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo date_register */
|
||||
public function getDateRegister() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->dateRegister;
|
||||
|
||||
}
|
||||
|
||||
public function getErrors(): ? string
|
||||
{
|
||||
|
||||
/** Verifico se deve informar os erros */
|
||||
if (count($this->errors)) {
|
||||
|
||||
/** Verifica a quantidade de erros para informar a legenda */
|
||||
$this->info = count($this->errors) > 1 ? '<center>Os seguintes erros foram encontrados</center>' : '<center>O seguinte erro foi encontrado</center>';
|
||||
|
||||
/** Lista os erros */
|
||||
foreach ($this->errors as $keyError => $error) {
|
||||
|
||||
/** Monto a mensagem de erro */
|
||||
$this->info .= '</br>' . ($keyError + 1) . ' - ' . $error;
|
||||
|
||||
}
|
||||
|
||||
/** Retorno os erros encontrados */
|
||||
return (string)$this->info;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function __destruct(){}
|
||||
}
|
||||
318
vendor/controller/client/ClientValidate.class.php
vendored
Normal file
318
vendor/controller/client/ClientValidate.class.php
vendored
Normal file
|
|
@ -0,0 +1,318 @@
|
|||
<?php
|
||||
/**
|
||||
* Classe ClientValidate.class.php
|
||||
* @filesource
|
||||
* @autor Kenio de Souza
|
||||
* @copyright Copyright 2024 - Souza Consultoria Tecnológica
|
||||
* @package vendor
|
||||
* @subpackage controller/client
|
||||
* @version 1.0
|
||||
* @date 07/08/2024
|
||||
*/
|
||||
|
||||
|
||||
/** Defino o local onde esta a classe */
|
||||
namespace vendor\controller\client;
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\controller\main\Main;
|
||||
|
||||
class ClientValidate
|
||||
{
|
||||
/** Declaro as variavéis da classe */
|
||||
private $Main = null;
|
||||
private $errors = array();
|
||||
private $info = null;
|
||||
private $clientId = null;
|
||||
private $cns = null;
|
||||
private $name = null;
|
||||
private $dateRegister = null;
|
||||
private $state = null;
|
||||
private $city = null;
|
||||
private $responsible = null;
|
||||
private $consultant = null;
|
||||
private $typeContract = null;
|
||||
|
||||
/** Construtor da classe */
|
||||
function __construct()
|
||||
{
|
||||
|
||||
/** Instânciamento da classe de validação */
|
||||
$this->Main = new Main();
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo client_id */
|
||||
public function setClientId(int $clientId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->clientId = isset($clientId) ? $this->Main->antiInjection($clientId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->clientId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "client_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo cns */
|
||||
public function setCns(string $cns) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->cns = isset($cns) ? $this->Main->antiInjection($cns) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->cns))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo CNS deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo name */
|
||||
public function setName(string $name) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->name = isset($name) ? $this->Main->antiInjection($name) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->name))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "name", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo date_register */
|
||||
public function setDateRegister(string $dateRegister) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->dateRegister = isset($dateRegister) ? $this->Main->antiInjection($dateRegister) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->dateRegister))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "date_register", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo state */
|
||||
public function setState(string $state) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->state = isset($state) ? $this->Main->antiInjection($state) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->state))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo Estado/UF deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo city */
|
||||
public function setCity(string $city) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->city = isset($city) ? $this->Main->antiInjection($city) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->city))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "cidade deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo responsible */
|
||||
public function setResponsible(string $responsible) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->responsible = isset($responsible) ? $this->Main->antiInjection($responsible) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->responsible))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo responsável deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo consultant */
|
||||
public function setConsultant(string $consultant) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->consultant = isset($consultant) ? $this->Main->antiInjection($consultant) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->consultant))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo consultor deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo type_contract */
|
||||
public function setTypeContract(string $typeContract) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->typeContract = isset($typeContract) ? $this->Main->antiInjection($typeContract) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->typeContract))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo contrato deve ser selecionado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo client_id */
|
||||
public function getClientId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->clientId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo cns */
|
||||
public function getCns() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->cns;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo name */
|
||||
public function getName() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->name;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo date_register */
|
||||
public function getDateRegister() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->dateRegister;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo state */
|
||||
public function getState() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->state;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo city */
|
||||
public function getCity() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->city;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo responsible */
|
||||
public function getResponsible() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->responsible;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo consultant */
|
||||
public function getConsultant() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->consultant;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo type_contract */
|
||||
public function getTypeContract() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->typeContract;
|
||||
|
||||
}
|
||||
|
||||
public function getErrors(): ? string
|
||||
{
|
||||
|
||||
/** Verifico se deve informar os erros */
|
||||
if (count($this->errors)) {
|
||||
|
||||
/** Verifica a quantidade de erros para informar a legenda */
|
||||
$this->info = count($this->errors) > 1 ? '<center>Os seguintes erros foram encontrados</center>' : '<center>O seguinte erro foi encontrado</center>';
|
||||
|
||||
/** Lista os erros */
|
||||
foreach ($this->errors as $keyError => $error) {
|
||||
|
||||
/** Monto a mensagem de erro */
|
||||
$this->info .= '</br>' . ($keyError + 1) . ' - ' . $error;
|
||||
|
||||
}
|
||||
|
||||
/** Retorno os erros encontrados */
|
||||
return (string)$this->info;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function __destruct(){}
|
||||
|
||||
}
|
||||
227
vendor/controller/log/LogValidate.class.php
vendored
Normal file
227
vendor/controller/log/LogValidate.class.php
vendored
Normal file
|
|
@ -0,0 +1,227 @@
|
|||
<?php
|
||||
/**
|
||||
* Classe LogValidate.class.php
|
||||
* @filesource
|
||||
* @autor Kenio de Souza
|
||||
* @copyright Copyright 2024 - Souza Consultoria Tecnológica
|
||||
* @package vendor
|
||||
* @subpackage controller/log
|
||||
* @version 1.0
|
||||
* @date 07/08/2024
|
||||
*/
|
||||
|
||||
|
||||
/** Defino o local onde esta a classe */
|
||||
namespace vendor\controller\log;
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\controller\main\Main;
|
||||
|
||||
class LogValidate
|
||||
{
|
||||
/** Declaro as variavéis da classe */
|
||||
private $Main = null;
|
||||
private $errors = array();
|
||||
private $info = null;
|
||||
private $logId = null;
|
||||
private $clientId = null;
|
||||
private $datePost = null;
|
||||
private $file = null;
|
||||
private $key = null;
|
||||
private $b64 = null;
|
||||
|
||||
/** Construtor da classe */
|
||||
function __construct()
|
||||
{
|
||||
|
||||
/** Instânciamento da classe de validação */
|
||||
$this->Main = new Main();
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo key */
|
||||
public function setKey(string $key) : void
|
||||
{
|
||||
|
||||
$this->key = !empty($key) ? $this->Main->antiInjection($key) : null;
|
||||
|
||||
/** Verifica se a chave foi informada */
|
||||
if(!empty($key))
|
||||
{
|
||||
|
||||
// Verifica se a senha tem pelo menos 8 caracteres
|
||||
if (strlen($this->key) < 8) {
|
||||
|
||||
array_push($this->errors, 'A senha deve ter pelo menos 8 caracteres.');
|
||||
}
|
||||
|
||||
// Verifica se a senha contém pelo menos uma letra maiúscula
|
||||
if (!preg_match('/[A-Z]/', $this->key)) {
|
||||
|
||||
array_push($this->errors, 'A senha deve conter pelo menos uma letra maiúscula.');
|
||||
}
|
||||
|
||||
// Verifica se a senha contém pelo menos uma letra minúscula
|
||||
if (!preg_match('/[a-z]/', $this->key)) {
|
||||
|
||||
array_push($this->errors, 'A senha deve conter pelo menos uma letra minúscula.');
|
||||
}
|
||||
|
||||
// Verifica se a senha contém pelo menos um número
|
||||
if (!preg_match('/\d/', $this->key)) {
|
||||
|
||||
array_push($this->errors, 'A senha deve conter pelo menos um número.');
|
||||
}
|
||||
|
||||
// Verifica se a senha contém pelo menos um caractere especial
|
||||
if (!preg_match('/[\W_]/', $this->key)) {
|
||||
|
||||
array_push($this->errors, 'A senha deve conter pelo menos um caractere especial.');
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'É preciso informar uma chave válida');
|
||||
}
|
||||
}
|
||||
|
||||
/** Método trata campo log_id */
|
||||
public function setLogId(int $logId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->logId = isset($logId) ? $this->Main->antiInjection($logId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->logId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "log_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo client_id */
|
||||
public function setClientId(int $clientId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->clientId = isset($clientId) ? $this->Main->antiInjection($clientId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->clientId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "client_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo date_post */
|
||||
public function setDatePost(string $datePost) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->datePost = isset($datePost) ? $this->Main->antiInjection($datePost) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->datePost))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "date_post", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo file */
|
||||
public function setFile(string $file) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->file = isset($file) ? base64_decode($this->Main->antiInjection($file)) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->file))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "file", deve ser informado');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/** Método retorna campo log_id */
|
||||
public function getLogId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->logId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo client_id */
|
||||
public function getClientId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->clientId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo date_post */
|
||||
public function getDatePost() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->datePost;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo file */
|
||||
public function getFile() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->file;
|
||||
|
||||
}
|
||||
|
||||
public function getErrors(): ? string
|
||||
{
|
||||
|
||||
/** Verifico se deve informar os erros */
|
||||
if (count($this->errors)) {
|
||||
|
||||
/** Verifica a quantidade de erros para informar a legenda */
|
||||
$this->info = count($this->errors) > 1 ? '<center>Os seguintes erros foram encontrados</center>' : '<center>O seguinte erro foi encontrado</center>';
|
||||
|
||||
/** Lista os erros */
|
||||
foreach ($this->errors as $keyError => $error) {
|
||||
|
||||
/** Monto a mensagem de erro */
|
||||
$this->info .= '</br>' . ($keyError + 1) . ' - ' . $error;
|
||||
|
||||
}
|
||||
|
||||
/** Retorno os erros encontrados */
|
||||
return (string)$this->info;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function __destruct(){}
|
||||
|
||||
}
|
||||
|
||||
1387
vendor/controller/main/Main.class.php
vendored
Normal file
1387
vendor/controller/main/Main.class.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
138
vendor/controller/routers/RouterValidate.class.php
vendored
Normal file
138
vendor/controller/routers/RouterValidate.class.php
vendored
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
/** Defino o local da classes */
|
||||
namespace vendor\controller\Routers;
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\controller\main\Main;
|
||||
|
||||
class RouterValidate
|
||||
{
|
||||
|
||||
/** Parâmetros da classes */
|
||||
private $Main = null;
|
||||
private $errors = array();
|
||||
private $info = null;
|
||||
|
||||
private $table = null;
|
||||
private $action = null;
|
||||
private $folder = null;
|
||||
|
||||
/** Método construtor */
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
/** Instânciamento de classes */
|
||||
$this->Main = new Main();
|
||||
|
||||
}
|
||||
|
||||
public function setTable(string $table): void
|
||||
{
|
||||
|
||||
/** Tratamento da informação */
|
||||
$this->table = strtolower(isset($table) ? $this->Main->antiInjection($table) : null);
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->table)) {
|
||||
|
||||
/** Adiciono um elemento a array */
|
||||
array_push($this->errors, ' O campo "Tabela", deve ser válido ');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setAction(string $action): void
|
||||
{
|
||||
|
||||
/** Tratamento da informação */
|
||||
$this->action = strtolower(isset($action) ? $this->Main->antiInjection($action) : null);
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->action)) {
|
||||
|
||||
/** Adiciono um elemento a array */
|
||||
array_push($this->errors, ' O campo "Ação", deve ser válido ');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setFolder(string $folder): void
|
||||
{
|
||||
|
||||
/** Tratamento da informação */
|
||||
$this->folder = strtolower(isset($folder) ? $this->Main->antiInjection($folder) : null);
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->folder)) {
|
||||
|
||||
/** Adiciono um elemento a array */
|
||||
array_push($this->errors, ' O campo "Pasta", deve ser válido ');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getTable(): string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->table;
|
||||
|
||||
}
|
||||
|
||||
public function getAction(): string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->action;
|
||||
|
||||
}
|
||||
|
||||
public function getFolder(): string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->folder;
|
||||
|
||||
}
|
||||
|
||||
public function getFullPath(): string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)'vendor/' . $this->getFolder() . '/' . $this->getTable() . '/' . $this->getAction() . '.php';
|
||||
|
||||
}
|
||||
|
||||
public function getErrors(): ? string
|
||||
{
|
||||
|
||||
/** Verifico se deve informar os erros */
|
||||
if (count($this->errors)) {
|
||||
|
||||
/** Verifica a quantidade de erros para informar a legenda */
|
||||
$this->info = count($this->errors) > 1 ? '<center>Os seguintes erros foram encontrados</center>' : '<center>O seguinte erro foi encontrado</center>';
|
||||
|
||||
/** Lista os erros */
|
||||
foreach ($this->errors as $keyError => $error) {
|
||||
|
||||
/** Monto a mensagem de erro */
|
||||
$this->info .= '</br>' . ($keyError + 1) . ' - ' . $error;
|
||||
|
||||
}
|
||||
|
||||
/** Retorno os erros encontrados */
|
||||
return (string)$this->info;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
515
vendor/controller/station/StationValidate.class.php
vendored
Normal file
515
vendor/controller/station/StationValidate.class.php
vendored
Normal file
|
|
@ -0,0 +1,515 @@
|
|||
<?php
|
||||
/**
|
||||
* Classe StationValidate.class.php
|
||||
* @filesource
|
||||
* @autor Kenio de Souza
|
||||
* @copyright Copyright 2024 - Souza Consultoria Tecnológica
|
||||
* @package vendor
|
||||
* @subpackage controller/station
|
||||
* @version 1.0
|
||||
* @date 07/08/2024
|
||||
*/
|
||||
|
||||
|
||||
/** Defino o local onde esta a classe */
|
||||
namespace vendor\controller\station;
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\controller\main\Main;
|
||||
|
||||
class StationValidate
|
||||
{
|
||||
/** Declaro as variavéis da classe */
|
||||
private $Main = null;
|
||||
private $errors = array();
|
||||
private $info = null;
|
||||
private $stationId = null;
|
||||
private $clientId = null;
|
||||
private $userId = null;
|
||||
private $description = null;
|
||||
private $ip = null;
|
||||
private $port = null;
|
||||
private $networkPath = null;
|
||||
private $connectionName = null;
|
||||
private $connectionId = null;
|
||||
private $connectionUser = null;
|
||||
private $connectionPassword = null;
|
||||
private $observation = null;
|
||||
private $type = null;
|
||||
private $operatingSystem = null;
|
||||
private $cpu = null;
|
||||
private $memory = null;
|
||||
|
||||
/** Construtor da classe */
|
||||
function __construct()
|
||||
{
|
||||
|
||||
/** Instânciamento da classe de validação */
|
||||
$this->Main = new Main();
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo station_id */
|
||||
public function setStationId(int $stationId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->stationId = isset($stationId) ? $this->Main->antiInjection($stationId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->stationId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "station_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo client_id */
|
||||
public function setClientId(int $clientId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->clientId = isset($clientId) ? $this->Main->antiInjection($clientId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->clientId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O cliente deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo user_id */
|
||||
public function setUserId(int $userId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->userId = $userId > 0 ? (int)$this->Main->antiInjection($userId) : 0;
|
||||
|
||||
// /** Verifica se a informação foi informada */
|
||||
// if(empty($this->userId))
|
||||
// {
|
||||
|
||||
// /** Adição de elemento */
|
||||
// array_push($this->errors, 'O campo "user_id", deve ser informado');
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo decription */
|
||||
public function setDescription(string $description) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->description = isset($description) ? $this->Main->antiInjection($description) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->description))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo descrição deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo type */
|
||||
public function setType(string $type) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->type = isset($type) ? $this->Main->antiInjection($type) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->type))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O tipo de estação deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** Método trata campo memory */
|
||||
public function setMemory(string $memory) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->memory = isset($memory) ? $this->Main->antiInjection($memory) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->memory))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'A memória da estação deve ser informada');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo cpu */
|
||||
public function setCpu(string $cpu) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->cpu = isset($cpu) ? $this->Main->antiInjection($cpu) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->cpu))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'A CPU da estação deve ser informada');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo type */
|
||||
public function setOperatingSystem(string $operatingSystem) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->operatingSystem = isset($operatingSystem) ? $this->Main->antiInjection($operatingSystem) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->operatingSystem))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O sistema operacional deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo ip */
|
||||
public function setIp(string $ip) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->ip = isset($ip) ? $this->Main->antiInjection($ip) : null;
|
||||
|
||||
// /** Verifica se a informação foi informada */
|
||||
// if(empty($this->ip))
|
||||
// {
|
||||
|
||||
// /** Adição de elemento */
|
||||
// array_push($this->errors, 'O campo IP deve ser informado');
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo port */
|
||||
public function setPort(int $port) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->port = isset($port) ? $this->Main->antiInjection($port) : null;
|
||||
|
||||
// /** Verifica se a informação foi informada */
|
||||
// if(empty($this->port))
|
||||
// {
|
||||
|
||||
// /** Adição de elemento */
|
||||
// array_push($this->errors, 'O campo porta deve ser informada');
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo network_path */
|
||||
public function setNetworkPath(string $networkPath) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->networkPath = isset($networkPath) ? $this->Main->antiInjection($networkPath) : null;
|
||||
|
||||
// /** Verifica se a informação foi informada */
|
||||
// if(empty($this->networkPath))
|
||||
// {
|
||||
|
||||
// /** Adição de elemento */
|
||||
// array_push($this->errors, 'O campo caminho da rede deve ser informado');
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo connection_name */
|
||||
public function setConnectionName(string $connectionName) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->connectionName = isset($connectionName) ? $this->Main->antiInjection($connectionName) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->connectionName))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo nome software de conexão deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo connection_id */
|
||||
public function setConnectionId(string $connectionId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->connectionId = isset($connectionId) ? $this->Main->antiInjection($connectionId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->connectionId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo ID da conexão deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo connection_user */
|
||||
public function setConnectionUser(string $connectionUser) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->connectionUser = isset($connectionUser) ? $this->Main->antiInjection($connectionUser) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->connectionUser))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo usuário da conexão deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo connection_password */
|
||||
public function setConnectionPassword(string $connectionPassword) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->connectionPassword = isset($connectionPassword) ? $this->Main->antiInjection($connectionPassword) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->connectionPassword))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo senha da conexão deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo observation */
|
||||
public function setObservation(string $observation) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->observation = isset($observation) ? $this->Main->antiInjection($observation) : null;
|
||||
|
||||
// /** Verifica se a informação foi informada */
|
||||
// if(empty($this->observation))
|
||||
// {
|
||||
|
||||
// /** Adição de elemento */
|
||||
// array_push($this->errors, 'O campo observação deve ser informado');
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo station_id */
|
||||
public function getStationId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->stationId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo client_id */
|
||||
public function getClientId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->clientId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo user_id */
|
||||
public function getUserId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->userId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo description */
|
||||
public function getDescription() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->description;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo ip */
|
||||
public function getIp() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->ip;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo type */
|
||||
public function getType() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->type;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo Operating_System */
|
||||
public function getOperatingSystem() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->operatingSystem;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo port */
|
||||
public function getPort() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->port;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo cpu */
|
||||
public function getCpu() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->cpu;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo memory */
|
||||
public function getMemory() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->memory;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo network_path */
|
||||
public function getNetworkPath() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->networkPath;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo connection_name */
|
||||
public function getConnectionName() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->connectionName;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo connection_id */
|
||||
public function getConnectionId() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->connectionId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo connection_user */
|
||||
public function getConnectionUser() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->connectionUser;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo connection_password */
|
||||
public function getConnectionPassword() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->connectionPassword;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo observation */
|
||||
public function getObservation() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->observation;
|
||||
|
||||
}
|
||||
|
||||
public function getErrors(): ? string
|
||||
{
|
||||
|
||||
/** Verifico se deve informar os erros */
|
||||
if (count($this->errors)) {
|
||||
|
||||
/** Verifica a quantidade de erros para informar a legenda */
|
||||
$this->info = count($this->errors) > 1 ? '<center>Os seguintes erros foram encontrados</center>' : '<center>O seguinte erro foi encontrado</center>';
|
||||
|
||||
/** Lista os erros */
|
||||
foreach ($this->errors as $keyError => $error) {
|
||||
|
||||
/** Monto a mensagem de erro */
|
||||
$this->info .= '</br>' . ($keyError + 1) . ' - ' . $error;
|
||||
|
||||
}
|
||||
|
||||
/** Retorno os erros encontrados */
|
||||
return (string)$this->info;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function __destruct(){}
|
||||
|
||||
}
|
||||
275
vendor/controller/station_disk/StationDiskValidate.class.php
vendored
Normal file
275
vendor/controller/station_disk/StationDiskValidate.class.php
vendored
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
<?php
|
||||
/**
|
||||
* Classe StationDiskValidate.class.php
|
||||
* @filesource
|
||||
* @autor Kenio de Souza
|
||||
* @copyright Copyright 2024 - Souza Consultoria Tecnológica
|
||||
* @package vendor
|
||||
* @subpackage controller/station_disk
|
||||
* @version 1.0
|
||||
* @date 10/08/2024
|
||||
*/
|
||||
|
||||
|
||||
/** Defino o local onde esta a classe */
|
||||
namespace vendor\controller\station_disk;
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\controller\main\Main;
|
||||
|
||||
class StationDiskValidate
{
/** Declaro as variavéis da classe */
private $Main = null;
|
||||
private $errors = array();
|
||||
private $info = null;
|
||||
private $stationDiskId = null;
private $stationId = null;
private $description = null;
private $capacity = null;
private $used = null;
private $available = null;
private $availablePercentage = null;
private $registrationDate = null;
/** Construtor da classe */
|
||||
function __construct()
{
|
||||
|
||||
/** Instânciamento da classe de validação */
|
||||
$this->Main = new Main();
|
||||
|
||||
}
|
||||
/** Método trata campo station_disk_id */
|
||||
public function setStationDiskId(int $stationDiskId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->stationDiskId = isset($stationDiskId) ? $this->Main->antiInjection($stationDiskId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->stationDiskId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "station_disk_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo station_id */
|
||||
public function setStationId(int $stationId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->stationId = isset($stationId) ? $this->Main->antiInjection($stationId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->stationId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "station_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo description */
|
||||
public function setDescription(string $description) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->description = isset($description) ? $this->Main->antiInjection($description) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->description))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "description", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo capacity */
|
||||
public function setCapacity(string $capacity) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->capacity = isset($capacity) ? $this->Main->antiInjection($capacity) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->capacity))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "capacity", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo used */
|
||||
public function setUsed(string $used) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->used = isset($used) ? $this->Main->antiInjection($used) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->used))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "used", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo available */
|
||||
public function setAvailable(string $available) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->available = isset($available) ? $this->Main->antiInjection($available) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->available))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "available", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo available_percentage */
|
||||
public function setAvailablePercentage(string $availablePercentage) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->availablePercentage = isset($availablePercentage) ? $this->Main->antiInjection($availablePercentage) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->availablePercentage))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "available_percentage", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo registration_date */
|
||||
public function setRegistrationDate(string $registrationDate) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->registrationDate = isset($registrationDate) ? $this->Main->antiInjection($registrationDate) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->registrationDate))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "registration_date", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo station_disk_id */
|
||||
public function getStationDiskId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->stationDiskId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo station_id */
|
||||
public function getStationId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->stationId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo description */
|
||||
public function getDescription() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->description;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo capacity */
|
||||
public function getCapacity() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->capacity;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo used */
|
||||
public function getUsed() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->used;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo available */
|
||||
public function getAvailable() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->available;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo available_percentage */
|
||||
public function getAvailablePercentage() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->availablePercentage;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo registration_date */
|
||||
public function getRegistrationDate() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->registrationDate;
|
||||
|
||||
}
|
||||
|
||||
public function getErrors(): ? string
|
||||
{
|
||||
|
||||
/** Verifico se deve informar os erros */
|
||||
if (count($this->errors)) {
|
||||
|
||||
/** Verifica a quantidade de erros para informar a legenda */
|
||||
$this->info = count($this->errors) > 1 ? '<center>Os seguintes erros foram encontrados</center>' : '<center>O seguinte erro foi encontrado</center>';
|
||||
|
||||
/** Lista os erros */
|
||||
foreach ($this->errors as $keyError => $error) {
|
||||
|
||||
/** Monto a mensagem de erro */
|
||||
$this->info .= '</br>' . ($keyError + 1) . ' - ' . $error;
|
||||
|
||||
}
|
||||
|
||||
/** Retorno os erros encontrados */
|
||||
return (string)$this->info;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function __destruct(){}
|
||||
}
|
||||
248
vendor/controller/station_folder/StationFolderValidate.class.php
vendored
Normal file
248
vendor/controller/station_folder/StationFolderValidate.class.php
vendored
Normal file
|
|
@ -0,0 +1,248 @@
|
|||
<?php
|
||||
/**
|
||||
* Classe StationFolderValidate.class.php
|
||||
* @filesource
|
||||
* @autor Kenio de Souza
|
||||
* @copyright Copyright 2024 - Souza Consultoria Tecnológica
|
||||
* @package vendor
|
||||
* @subpackage controller/station_folder
|
||||
* @version 1.0
|
||||
* @date 07/08/2024
|
||||
*/
|
||||
|
||||
|
||||
/** Defino o local onde esta a classe */
|
||||
namespace vendor\controller\station_folder;
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\controller\main\Main;
|
||||
|
||||
class StationFolderValidate
{
/** Declaro as variavéis da classe */
private $Main = null;
|
||||
private $errors = array();
|
||||
private $info = null;
|
||||
private $stationFolderId = null;
private $stationId = null;
private $folderPath = null;
private $amountOfFiles = null;
private $amountOfFilesCurrent = null;
private $dateRegister = null;
private $lastUpdate = null;
/** Construtor da classe */
|
||||
function __construct()
{
|
||||
|
||||
/** Instânciamento da classe de validação */
|
||||
$this->Main = new Main();
|
||||
|
||||
}
|
||||
/** Método trata campo station_folder_id */
|
||||
public function setStationFolderId(int $stationFolderId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->stationFolderId = isset($stationFolderId) ? $this->Main->antiInjection($stationFolderId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->stationFolderId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "station_folder_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo station_id */
|
||||
public function setStationId(int $stationId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->stationId = isset($stationId) ? $this->Main->antiInjection($stationId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->stationId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "station_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo folder_path */
|
||||
public function setFolderPath(string $folderPath) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->folderPath = isset($folderPath) ? $this->Main->antiInjection($folderPath) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->folderPath))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "folder_path", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo amount_of_files */
|
||||
public function setAmountOfFiles(int $amountOfFiles) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->amountOfFiles = isset($amountOfFiles) ? $this->Main->antiInjection($amountOfFiles) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->amountOfFiles))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "amount_of_files", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo amount_of_files_current */
|
||||
public function setAmountOfFilesCurrent(int $amountOfFilesCurrent) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->amountOfFilesCurrent = isset($amountOfFilesCurrent) ? $this->Main->antiInjection($amountOfFilesCurrent) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->amountOfFilesCurrent))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "amount_of_files_current", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo date_register */
|
||||
public function setDateRegister(string $dateRegister) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->dateRegister = isset($dateRegister) ? $this->Main->antiInjection($dateRegister) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->dateRegister))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "date_register", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo last_update */
|
||||
public function setLastUpdate(string $lastUpdate) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->lastUpdate = isset($lastUpdate) ? $this->Main->antiInjection($lastUpdate) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->lastUpdate))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "last_update", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo station_folder_id */
|
||||
public function getStationFolderId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->stationFolderId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo station_id */
|
||||
public function getStationId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->stationId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo folder_path */
|
||||
public function getFolderPath() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->folderPath;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo amount_of_files */
|
||||
public function getAmountOfFiles() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->amountOfFiles;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo amount_of_files_current */
|
||||
public function getAmountOfFilesCurrent() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->amountOfFilesCurrent;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo date_register */
|
||||
public function getDateRegister() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->dateRegister;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo last_update */
|
||||
public function getLastUpdate() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->lastUpdate;
|
||||
|
||||
}
|
||||
|
||||
public function getErrors(): ? string
|
||||
{
|
||||
|
||||
/** Verifico se deve informar os erros */
|
||||
if (count($this->errors)) {
|
||||
|
||||
/** Verifica a quantidade de erros para informar a legenda */
|
||||
$this->info = count($this->errors) > 1 ? '<center>Os seguintes erros foram encontrados</center>' : '<center>O seguinte erro foi encontrado</center>';
|
||||
|
||||
/** Lista os erros */
|
||||
foreach ($this->errors as $keyError => $error) {
|
||||
|
||||
/** Monto a mensagem de erro */
|
||||
$this->info .= '</br>' . ($keyError + 1) . ' - ' . $error;
|
||||
|
||||
}
|
||||
|
||||
/** Retorno os erros encontrados */
|
||||
return (string)$this->info;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function __destruct(){}
|
||||
}
|
||||
518
vendor/controller/user/UserValidate.class.php
vendored
Normal file
518
vendor/controller/user/UserValidate.class.php
vendored
Normal file
|
|
@ -0,0 +1,518 @@
|
|||
<?php
|
||||
/**
|
||||
* Classe UserValidate.class.php
|
||||
* @filesource
|
||||
* @autor Kenio de Souza
|
||||
* @copyright Copyright 2024 - Souza Consultoria Tecnológica
|
||||
* @package vendor
|
||||
* @subpackage controller/user
|
||||
* @version 1.0
|
||||
* @date 07/08/2024
|
||||
*/
|
||||
|
||||
|
||||
/** Defino o local onde esta a classe */
|
||||
namespace vendor\controller\user;
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\controller\main\Main;
|
||||
|
||||
class UserValidate
{
/** Declaro as variavéis da classe */
private $Main = null;
|
||||
private $errors = array();
|
||||
private $info = null;
|
||||
private $userId = null;
private $nameFirst = null;
private $nameLast = null;
private $email = null;
private $password = null;
private $passwordTemp = null;
private $active = null;
private $birthDate = null;
private $genre = null;
private $dateRegister = null;
private $accessFirst = null;
private $accessLast = null;
private $administrator = null;
private $passwordTempConfirm = null;
private $usersIdCreate = null;
private $usersIdUpdate = null;
private $usersIdDelete = null;
/** Construtor da classe */
|
||||
function __construct()
{
|
||||
|
||||
/** Instânciamento da classe de validação */
|
||||
$this->Main = new Main();
|
||||
|
||||
}
|
||||
/** Método trata campo user_id */
|
||||
public function setUserId(int $userId) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->userId = isset($userId) ? $this->Main->antiInjection($userId) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->userId))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "user_id", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo name_first */
|
||||
public function setNameFirst(string $nameFirst) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->nameFirst = isset($nameFirst) ? $this->Main->antiInjection($nameFirst) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->nameFirst))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "name_first", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo name_last */
|
||||
public function setNameLast(string $nameLast) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->nameLast = isset($nameLast) ? $this->Main->antiInjection($nameLast) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->nameLast))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "name_last", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo email */
|
||||
public function setEmail(string $email) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->email = isset($email) ? $this->Main->antiInjection($email) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->email))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "email", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo password */
|
||||
public function setPassword(string $password) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->password = isset($password) ? $this->Main->antiInjection($password) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->password))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "password", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo password_temp */
|
||||
public function setPasswordTemp(string $passwordTemp) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->passwordTemp = isset($passwordTemp) ? $this->Main->antiInjection($passwordTemp) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->passwordTemp))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "password_temp", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo active */
|
||||
public function setActive(string $active) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->active = isset($active) ? $this->Main->antiInjection($active) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->active))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "active", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo birth_date */
|
||||
public function setBirthDate(string $birthDate) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->birthDate = isset($birthDate) ? $this->Main->antiInjection($birthDate) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->birthDate))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "birth_date", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo genre */
|
||||
public function setGenre(string $genre) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->genre = isset($genre) ? $this->Main->antiInjection($genre) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->genre))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "genre", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo date_register */
|
||||
public function setDateRegister(string $dateRegister) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->dateRegister = isset($dateRegister) ? $this->Main->antiInjection($dateRegister) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->dateRegister))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "date_register", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo access_first */
|
||||
public function setAccessFirst(string $accessFirst) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->accessFirst = isset($accessFirst) ? $this->Main->antiInjection($accessFirst) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->accessFirst))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "access_first", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo access_last */
|
||||
public function setAccessLast(string $accessLast) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->accessLast = isset($accessLast) ? $this->Main->antiInjection($accessLast) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->accessLast))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "access_last", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo administrator */
|
||||
public function setAdministrator(string $administrator) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->administrator = isset($administrator) ? $this->Main->antiInjection($administrator) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->administrator))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "administrator", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo password_temp_confirm */
|
||||
public function setPasswordTempConfirm(string $passwordTempConfirm) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->passwordTempConfirm = isset($passwordTempConfirm) ? $this->Main->antiInjection($passwordTempConfirm) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->passwordTempConfirm))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "password_temp_confirm", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo users_id_create */
|
||||
public function setUsersIdCreate(int $usersIdCreate) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->usersIdCreate = isset($usersIdCreate) ? $this->Main->antiInjection($usersIdCreate) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->usersIdCreate))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "users_id_create", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo users_id_update */
|
||||
public function setUsersIdUpdate(int $usersIdUpdate) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->usersIdUpdate = isset($usersIdUpdate) ? $this->Main->antiInjection($usersIdUpdate) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->usersIdUpdate))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "users_id_update", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método trata campo users_id_delete */
|
||||
public function setUsersIdDelete(int $usersIdDelete) : void
|
||||
{
|
||||
|
||||
/** Trata a entrada da informação */
|
||||
$this->usersIdDelete = isset($usersIdDelete) ? $this->Main->antiInjection($usersIdDelete) : null;
|
||||
|
||||
/** Verifica se a informação foi informada */
|
||||
if(empty($this->usersIdDelete))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "users_id_delete", deve ser informado');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo user_id */
|
||||
public function getUserId() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->userId;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo name_first */
|
||||
public function getNameFirst() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->nameFirst;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo name_last */
|
||||
public function getNameLast() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->nameLast;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo email */
|
||||
public function getEmail() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->email;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo password */
|
||||
public function getPassword() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->password;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo password_temp */
|
||||
public function getPasswordTemp() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->passwordTemp;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo active */
|
||||
public function getActive() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->active;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo birth_date */
|
||||
public function getBirthDate() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->birthDate;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo genre */
|
||||
public function getGenre() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->genre;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo date_register */
|
||||
public function getDateRegister() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->dateRegister;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo access_first */
|
||||
public function getAccessFirst() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->accessFirst;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo access_last */
|
||||
public function getAccessLast() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->accessLast;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo administrator */
|
||||
public function getAdministrator() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->administrator;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo password_temp_confirm */
|
||||
public function getPasswordTempConfirm() : ? string
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (string)$this->passwordTempConfirm;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo users_id_create */
|
||||
public function getUsersIdCreate() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->usersIdCreate;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo users_id_update */
|
||||
public function getUsersIdUpdate() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->usersIdUpdate;
|
||||
|
||||
}
|
||||
|
||||
/** Método retorna campo users_id_delete */
|
||||
public function getUsersIdDelete() : ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->usersIdDelete;
|
||||
|
||||
}
|
||||
|
||||
public function getErrors(): ? string
|
||||
{
|
||||
|
||||
/** Verifico se deve informar os erros */
|
||||
if (count($this->errors)) {
|
||||
|
||||
/** Verifica a quantidade de erros para informar a legenda */
|
||||
$this->info = count($this->errors) > 1 ? '<center>Os seguintes erros foram encontrados</center>' : '<center>O seguinte erro foi encontrado</center>';
|
||||
|
||||
/** Lista os erros */
|
||||
foreach ($this->errors as $keyError => $error) {
|
||||
|
||||
/** Monto a mensagem de erro */
|
||||
$this->info .= '</br>' . ($keyError + 1) . ' - ' . $error;
|
||||
|
||||
}
|
||||
|
||||
/** Retorno os erros encontrados */
|
||||
return (string)$this->info;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function __destruct(){}
|
||||
}
|
||||
431
vendor/controller/users/UsersValidate.class.php
vendored
Normal file
431
vendor/controller/users/UsersValidate.class.php
vendored
Normal file
|
|
@ -0,0 +1,431 @@
|
|||
<?php
|
||||
|
||||
/** Defino o local da classes */
|
||||
namespace vendor\controller\users;
|
||||
|
||||
/** Importação de classes */
|
||||
use vendor\controller\main\Main;
|
||||
|
||||
class UsersValidate
|
||||
{
|
||||
|
||||
/** Parâmetros da classes */
|
||||
private $Main = null;
|
||||
private $errors = array();
|
||||
private $info = null;
|
||||
private $usersId = null;
|
||||
private $companyId = null;
|
||||
private $nameFirst = null;
|
||||
private $nameLast = null;
|
||||
private $email = null;
|
||||
private $birthDate = null;
|
||||
private $genre = null;
|
||||
private $active = null;
|
||||
private $administrator = null;
|
||||
private $passwordTemp = null;
|
||||
private $password = null;
|
||||
private $passwordConfirm = null;
|
||||
private $passwordTempConfirm = null;
|
||||
private $method = null;
|
||||
private $firstKey = null;
|
||||
private $secondKey = null;
|
||||
private $emailAccess = null;
|
||||
private $clientsId = null;
|
||||
|
||||
/** Método construtor */
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
/** Instânciamento de classes */
|
||||
$this->Main = new Main();
|
||||
|
||||
}
|
||||
|
||||
public function setUsersId(int $usersId): void
|
||||
{
|
||||
|
||||
/** Tratamento da informação */
|
||||
$this->usersId = $usersId > 0 ? (int)$this->Main->antiInjection($usersId) : 0;
|
||||
|
||||
/** Validação da informação */
|
||||
if ($this->usersId < 0)
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Usuário ID", deve ser válido');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setClientsId(int $clientsId): void
|
||||
{
|
||||
|
||||
/** Tratamento da informação */
|
||||
$this->clientsId = $clientsId > 0 ? (int)$this->Main->antiInjection($clientsId) : 0;
|
||||
|
||||
}
|
||||
|
||||
public function setCompanyId(int $companyId) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->companyId = $this->Main->antiInjection($companyId);
|
||||
|
||||
/** Validação da informação */
|
||||
if ($this->companyId <= 0)
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Empresa ID", deve ser válido');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setNameFirst(string $nameFirst) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->nameFirst = $this->Main->antiInjection($nameFirst);
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->nameFirst))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Primeiro Nome", deve ser preenchido');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setNameLast(string $nameLast) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->nameLast = $this->Main->antiInjection($nameLast);
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->nameLast))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Último Nome", deve ser preenchido');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setEmail(string $email) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->email = $this->Main->antiInjection($email);
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->email))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Email", deve ser preenchido');
|
||||
|
||||
/** Verifica se o e-mail informado é válido */
|
||||
}else if(!$this->Main->validarEmail($email)){
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'Informe um "Email" válido');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setBirthDate(string $birthDate) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->birthDate = isset($birthDate) ? $this->Main->antiInjection($birthDate) : '';
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->birthDate))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Data de Nascimento", deve ser preenchido');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setGenre(string $genre) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->genre = $this->Main->antiInjection($genre);
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->genre))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Gênero", deve ser preenchido');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setActive(string $active) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->active = $this->Main->antiInjection($active);
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->active))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Ativo", deve ser preenchido');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setAdministrator(string $administrator) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->administrator = $this->Main->antiInjection($administrator);
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->administrator))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Administrador", deve ser preenchido');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setPasswordTempConfirm(string $password_temp_confirm) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->passwordTempConfirm = $this->Main->antiInjection($password_temp_confirm);
|
||||
|
||||
}
|
||||
|
||||
public function setPasswordTemp(string $passwordTemp) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->passwordTemp = $this->Main->antiInjection($passwordTemp);
|
||||
|
||||
/** Verifica se é para validar a senha temporária */
|
||||
if($this->passwordTempConfirm === 'S'){
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->passwordTemp))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Senha Temporária", deve ser preenchido');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setPassword(string $password) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->password = $this->Main->antiInjection($password);
|
||||
|
||||
/** Verifica se é para validar a senha temporária */
|
||||
if( ($this->passwordTempConfirm === 'S') || ($this->passwordTempConfirm === null) ){
|
||||
|
||||
/** Validação da informação */
|
||||
if (empty($this->password))
|
||||
{
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Senha", deve ser preenchido');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setPasswordConfirm(string $passwordConfirm) : void
|
||||
{
|
||||
|
||||
/** Tratamento das informações */
|
||||
$this->passwordConfirm = $this->Main->antiInjection($passwordConfirm);
|
||||
|
||||
/** Verifica se a confirmação da senha foi informada */
|
||||
if( empty($this->passwordConfirm) ){
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'O campo "Confirmar senha", deve ser preenchido');
|
||||
|
||||
/** Verifica se a senha informada confere com a confirmação da senha */
|
||||
}else{
|
||||
|
||||
/** Verifica se a senhas são idênticas */
|
||||
if(trim($this->password) !== trim($this->passwordConfirm)){
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'As senhas informadas não conferem.');
|
||||
|
||||
/** Verifica se a senha informada contém os caracteres necessários */
|
||||
}elseif( !$this->Main->validatePasswordStrength($this->password) ){
|
||||
|
||||
/** Adição de elemento */
|
||||
array_push($this->errors, 'A senha de acesso precisa ter letras e números e pelo menos uma letra maiúscula ou minúscula e ter no mínimo oito(8) dígitos e no máximo dez(10) dígitos.');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getUserId(): ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->usersId;
|
||||
|
||||
}
|
||||
|
||||
public function getClientsId(): ? int
|
||||
{
|
||||
|
||||
/** Retorno da informação */
|
||||
return (int)$this->clientsId;
|
||||
|
||||
}
|
||||
|
||||
public function getUsersId() : ? int
|
||||
{
|
||||
|
||||
return (int)$this->usersId;
|
||||
|
||||
}
|
||||
|
||||
public function getCompanyId() : ? int
|
||||
{
|
||||
|
||||
return (int)$this->companyId;
|
||||
|
||||
}
|
||||
|
||||
/** Retorna o primeiro nome do usuário criptografado */
|
||||
public function getNameFirst() : ? string
|
||||
{
|
||||
|
||||
/** Retorna name_first criptografado */
|
||||
return $this->Main->encryptData($this->nameFirst);
|
||||
|
||||
}
|
||||
|
||||
/** Retorna o segundo nome do usuário criptografado */
|
||||
public function getNameLast() : ? string
|
||||
{
|
||||
|
||||
/** Retorna name_last criptografado */
|
||||
return $this->Main->encryptData($this->nameLast);
|
||||
|
||||
}
|
||||
|
||||
/** Retorna o email do usuário criptografado */
|
||||
public function getEmail() : ? string
|
||||
{
|
||||
|
||||
/** Retorna email criptografado */
|
||||
return $this->email;
|
||||
|
||||
}
|
||||
|
||||
public function getBirthDate() : ? string
|
||||
{
|
||||
|
||||
return (string)$this->Main->DataDB($this->birthDate);
|
||||
|
||||
}
|
||||
|
||||
public function getGenre() : ? string
|
||||
{
|
||||
|
||||
return $this->genre;
|
||||
|
||||
}
|
||||
|
||||
public function getActive() : ? string
|
||||
{
|
||||
|
||||
return $this->active;
|
||||
|
||||
}
|
||||
|
||||
public function getAdministrator() : ? string
|
||||
{
|
||||
|
||||
return $this->administrator;
|
||||
|
||||
}
|
||||
|
||||
public function getPasswordTempConfirm() : ? string
|
||||
{
|
||||
|
||||
return $this->passwordTempConfirm;
|
||||
}
|
||||
|
||||
public function getPasswordTemp() : ? string
|
||||
{
|
||||
|
||||
return (string)$this->passwordTemp;
|
||||
|
||||
}
|
||||
|
||||
public function getPassword() : ? string
|
||||
{
|
||||
|
||||
return (string)$this->password;
|
||||
|
||||
}
|
||||
|
||||
public function getErrors(): ? string
|
||||
{
|
||||
|
||||
/** Verifico se deve informar os erros */
|
||||
if (count($this->errors)) {
|
||||
|
||||
/** Verifica a quantidade de erros para informar a legenda */
|
||||
$this->info = count($this->errors) > 1 ? '<center>Os seguintes erros foram encontrados</center>' : '<center>O seguinte erro foi encontrado</center>';
|
||||
|
||||
/** Lista os erros */
|
||||
foreach ($this->errors as $keyError => $error) {
|
||||
|
||||
/** Monto a mensagem de erro */
|
||||
$this->info .= '</br>' . ($keyError + 1) . ' - ' . $error;
|
||||
|
||||
}
|
||||
|
||||
/** Retorno os erros encontrados */
|
||||
return (string)$this->info;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** destrutor da classe */
|
||||
public function __destruct(){}
|
||||
|
||||
}
|
||||
104
vendor/library/Excel/Writer.php
vendored
Normal file
104
vendor/library/Excel/Writer.php
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/*
|
||||
* Module written/ported by Xavier Noguer <xnoguer@rezebra.com>
|
||||
*
|
||||
* PERL Spreadsheet::WriteExcel module.
|
||||
*
|
||||
* The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
* <jmcnamara@cpan.org>
|
||||
*
|
||||
* I _DO_ maintain this code, and John McNamara has nothing to do with the
|
||||
* porting of this code to PHP. Any questions directly related to this
|
||||
* class library should be directed to me.
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
require_once 'PEAR.php';
|
||||
require_once 'Spreadsheet/Excel/Writer/Workbook.php';
|
||||
|
||||
/**
|
||||
* Class for writing Excel Spreadsheets. This class should change COMPLETELY.
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@rezebra.com>
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
|
||||
class Spreadsheet_Excel_Writer extends Spreadsheet_Excel_Writer_Workbook
|
||||
{
|
||||
/**
|
||||
* The constructor. It just creates a Workbook
|
||||
*
|
||||
* @param string $filename The optional filename for the Workbook.
|
||||
* @return Spreadsheet_Excel_Writer_Workbook The Workbook created
|
||||
*/
|
||||
function Spreadsheet_Excel_Writer($filename = '')
|
||||
{
|
||||
$this->_filename = $filename;
|
||||
$this->Spreadsheet_Excel_Writer_Workbook($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send HTTP headers for the Excel file.
|
||||
*
|
||||
* @param string $filename The filename to use for HTTP headers
|
||||
* @access public
|
||||
*/
|
||||
function send($filename)
|
||||
{
|
||||
header("Content-type: application/vnd.ms-excel");
|
||||
header("Content-Disposition: attachment; filename=\"$filename\"");
|
||||
header("Expires: 0");
|
||||
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
|
||||
header("Pragma: public");
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function for writing formulas
|
||||
* Converts a cell's coordinates to the A1 format.
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param integer $row Row for the cell to convert (0-indexed).
|
||||
* @param integer $col Column for the cell to convert (0-indexed).
|
||||
* @return string The cell identifier in A1 format
|
||||
*/
|
||||
function rowcolToCell($row, $col)
|
||||
{
|
||||
if ($col > 255) { //maximum column value exceeded
|
||||
return new PEAR_Error("Maximum column value exceeded: $col");
|
||||
}
|
||||
|
||||
$int = (int)($col / 26);
|
||||
$frac = $col % 26;
|
||||
$chr1 = '';
|
||||
|
||||
if ($int > 0) {
|
||||
$chr1 = chr(ord('A') + $int - 1);
|
||||
}
|
||||
|
||||
$chr2 = chr(ord('A') + $frac);
|
||||
$row++;
|
||||
|
||||
return $chr1 . $chr2 . $row;
|
||||
}
|
||||
}
|
||||
?>
|
||||
267
vendor/library/Excel/Writer/BIFFwriter.php
vendored
Normal file
267
vendor/library/Excel/Writer/BIFFwriter.php
vendored
Normal file
|
|
@ -0,0 +1,267 @@
|
|||
<?php
|
||||
/*
|
||||
* Module written/ported by Xavier Noguer <xnoguer@php.net>
|
||||
*
|
||||
* The majority of this is _NOT_ my code. I simply ported it from the
|
||||
* PERL Spreadsheet::WriteExcel module.
|
||||
*
|
||||
* The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
* <jmcnamara@cpan.org>
|
||||
*
|
||||
* I _DO_ maintain this code, and John McNamara has nothing to do with the
|
||||
* porting of this code to PHP. Any questions directly related to this
|
||||
* class library should be directed to me.
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@php.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
require_once 'PEAR.php';
|
||||
|
||||
/**
|
||||
* Class for writing Excel BIFF records.
|
||||
*
|
||||
* From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation):
|
||||
*
|
||||
* BIFF (BInary File Format) is the file format in which Excel documents are
|
||||
* saved on disk. A BIFF file is a complete description of an Excel document.
|
||||
* BIFF files consist of sequences of variable-length records. There are many
|
||||
* different types of BIFF records. For example, one record type describes a
|
||||
* formula entered into a cell; one describes the size and location of a
|
||||
* window into a document; another describes a picture format.
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
|
||||
class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||
{
|
||||
/**
|
||||
* The BIFF/Excel version (5).
|
||||
* @var integer
|
||||
*/
|
||||
var $_BIFF_version = 0x0500;
|
||||
|
||||
/**
|
||||
* The byte order of this architecture. 0 => little endian, 1 => big endian
|
||||
* @var integer
|
||||
*/
|
||||
var $_byte_order;
|
||||
|
||||
/**
|
||||
* The string containing the data of the BIFF stream
|
||||
* @var string
|
||||
*/
|
||||
var $_data;
|
||||
|
||||
/**
|
||||
* The size of the data in bytes. Should be the same as strlen($this->_data)
|
||||
* @var integer
|
||||
*/
|
||||
var $_datasize;
|
||||
|
||||
/**
|
||||
* The maximun length for a BIFF record. See _addContinue()
|
||||
* @var integer
|
||||
* @see _addContinue()
|
||||
*/
|
||||
var $_limit;
|
||||
|
||||
/**
|
||||
* The temporary dir for storing the OLE file
|
||||
* @var string
|
||||
*/
|
||||
var $_tmp_dir;
|
||||
|
||||
/**
|
||||
* The temporary file for storing the OLE file
|
||||
* @var string
|
||||
*/
|
||||
var $_tmp_file;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function Spreadsheet_Excel_Writer_BIFFwriter()
|
||||
{
|
||||
$this->_byte_order = '';
|
||||
$this->_data = '';
|
||||
$this->_datasize = 0;
|
||||
$this->_limit = 2080;
|
||||
$this->_tmp_dir = '';
|
||||
// Set the byte order
|
||||
$this->_setByteOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the byte order and store it as class data to avoid
|
||||
* recalculating it for each call to new().
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _setByteOrder()
|
||||
{
|
||||
// Check if "pack" gives the required IEEE 64bit float
|
||||
$teststr = pack("d", 1.2345);
|
||||
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
|
||||
if ($number == $teststr) {
|
||||
$byte_order = 0; // Little Endian
|
||||
} elseif ($number == strrev($teststr)){
|
||||
$byte_order = 1; // Big Endian
|
||||
} else {
|
||||
// Give up. I'll fix this in a later version.
|
||||
return $this->raiseError("Required floating point format ".
|
||||
"not supported on this platform.");
|
||||
}
|
||||
$this->_byte_order = $byte_order;
|
||||
}
|
||||
|
||||
/**
|
||||
* General storage function
|
||||
*
|
||||
* @param string $data binary data to prepend
|
||||
* @access private
|
||||
*/
|
||||
function _prepend($data)
|
||||
{
|
||||
if (strlen($data) > $this->_limit) {
|
||||
$data = $this->_addContinue($data);
|
||||
}
|
||||
$this->_data = $data.$this->_data;
|
||||
$this->_datasize += strlen($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* General storage function
|
||||
*
|
||||
* @param string $data binary data to append
|
||||
* @access private
|
||||
*/
|
||||
function _append($data)
|
||||
{
|
||||
if (strlen($data) > $this->_limit) {
|
||||
$data = $this->_addContinue($data);
|
||||
}
|
||||
$this->_data = $this->_data.$data;
|
||||
$this->_datasize += strlen($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Excel BOF record to indicate the beginning of a stream or
|
||||
* sub-stream in the BIFF file.
|
||||
*
|
||||
* @param integer $type Type of BIFF file to write: 0x0005 Workbook,
|
||||
* 0x0010 Worksheet.
|
||||
* @access private
|
||||
*/
|
||||
function _storeBof($type)
|
||||
{
|
||||
$record = 0x0809; // Record identifier
|
||||
|
||||
// According to the SDK $build and $year should be set to zero.
|
||||
// However, this throws a warning in Excel 5. So, use magic numbers.
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$length = 0x0008;
|
||||
$unknown = '';
|
||||
$build = 0x096C;
|
||||
$year = 0x07C9;
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$length = 0x0010;
|
||||
$unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8
|
||||
$build = 0x0DBB;
|
||||
$year = 0x07CC;
|
||||
}
|
||||
$version = $this->_BIFF_version;
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvvv", $version, $type, $build, $year);
|
||||
$this->_prepend($header . $data . $unknown);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Excel EOF record to indicate the end of a BIFF stream.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _storeEof()
|
||||
{
|
||||
$record = 0x000A; // Record identifier
|
||||
$length = 0x0000; // Number of bytes to follow
|
||||
$header = pack("vv", $record, $length);
|
||||
$this->_append($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
|
||||
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits
|
||||
* must be split up into CONTINUE blocks.
|
||||
*
|
||||
* This function takes a long BIFF record and inserts CONTINUE records as
|
||||
* necessary.
|
||||
*
|
||||
* @param string $data The original binary data to be written
|
||||
* @return string A very convenient string of continue blocks
|
||||
* @access private
|
||||
*/
|
||||
function _addContinue($data)
|
||||
{
|
||||
$limit = $this->_limit;
|
||||
$record = 0x003C; // Record identifier
|
||||
|
||||
// The first 2080/8224 bytes remain intact. However, we have to change
|
||||
// the length field of the record.
|
||||
$tmp = substr($data, 0, 2).pack("v", $limit-4).substr($data, 4, $limit - 4);
|
||||
|
||||
$header = pack("vv", $record, $limit); // Headers for continue records
|
||||
|
||||
// Retrieve chunks of 2080/8224 bytes +4 for the header.
|
||||
$data_length = strlen($data);
|
||||
for ($i = $limit; $i < ($data_length - $limit); $i += $limit) {
|
||||
$tmp .= $header;
|
||||
$tmp .= substr($data, $i, $limit);
|
||||
}
|
||||
|
||||
// Retrieve the last chunk of data
|
||||
$header = pack("vv", $record, strlen($data) - $i);
|
||||
$tmp .= $header;
|
||||
$tmp .= substr($data, $i, strlen($data) - $i);
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the temp dir used for storing the OLE file
|
||||
*
|
||||
* @access public
|
||||
* @param string $dir The dir to be used as temp dir
|
||||
* @return true if given dir is valid, false otherwise
|
||||
*/
|
||||
function setTempDir($dir)
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$this->_tmp_dir = $dir;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
1109
vendor/library/Excel/Writer/Format.php
vendored
Normal file
1109
vendor/library/Excel/Writer/Format.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
1703
vendor/library/Excel/Writer/Parser.php
vendored
Normal file
1703
vendor/library/Excel/Writer/Parser.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
230
vendor/library/Excel/Writer/Validator.php
vendored
Normal file
230
vendor/library/Excel/Writer/Validator.php
vendored
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
<?php
|
||||
/*
|
||||
* Module written by Herman Kuiper <herman@ozuzo.net>
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
//require_once('PEAR.php');
|
||||
|
||||
// Possible operator types
|
||||
|
||||
/*
|
||||
FIXME: change prefixes
|
||||
*/
|
||||
define("OP_BETWEEN", 0x00);
|
||||
define("OP_NOTBETWEEN", 0x01);
|
||||
define("OP_EQUAL", 0x02);
|
||||
define("OP_NOTEQUAL", 0x03);
|
||||
define("OP_GT", 0x04);
|
||||
define("OP_LT", 0x05);
|
||||
define("OP_GTE", 0x06);
|
||||
define("OP_LTE", 0x07);
|
||||
|
||||
/**
|
||||
* Baseclass for generating Excel DV records (validations)
|
||||
*
|
||||
* @author Herman Kuiper
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
class Spreadsheet_Excel_Writer_Validator
|
||||
{
|
||||
var $_type;
|
||||
var $_style;
|
||||
var $_fixedList;
|
||||
var $_blank;
|
||||
var $_incell;
|
||||
var $_showprompt;
|
||||
var $_showerror;
|
||||
var $_title_prompt;
|
||||
var $_descr_prompt;
|
||||
var $_title_error;
|
||||
var $_descr_error;
|
||||
var $_operator;
|
||||
var $_formula1;
|
||||
var $_formula2;
|
||||
/**
|
||||
* The parser from the workbook. Used to parse validation formulas also
|
||||
* @var Spreadsheet_Excel_Writer_Parser
|
||||
*/
|
||||
var $_parser;
|
||||
|
||||
function Spreadsheet_Excel_Writer_Validator(&$parser)
|
||||
{
|
||||
$this->_parser = $parser;
|
||||
$this->_type = 0x01; // FIXME: add method for setting datatype
|
||||
$this->_style = 0x00;
|
||||
$this->_fixedList = false;
|
||||
$this->_blank = false;
|
||||
$this->_incell = false;
|
||||
$this->_showprompt = false;
|
||||
$this->_showerror = true;
|
||||
$this->_title_prompt = "\x00";
|
||||
$this->_descr_prompt = "\x00";
|
||||
$this->_title_error = "\x00";
|
||||
$this->_descr_error = "\x00";
|
||||
$this->_operator = 0x00; // default is equal
|
||||
$this->_formula1 = '';
|
||||
$this->_formula2 = '';
|
||||
}
|
||||
|
||||
function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true)
|
||||
{
|
||||
$this->_showprompt = $showPrompt;
|
||||
$this->_title_prompt = $promptTitle;
|
||||
$this->_descr_prompt = $promptDescription;
|
||||
}
|
||||
|
||||
function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true)
|
||||
{
|
||||
$this->_showerror = $showError;
|
||||
$this->_title_error = $errorTitle;
|
||||
$this->_descr_error = $errorDescription;
|
||||
}
|
||||
|
||||
function allowBlank()
|
||||
{
|
||||
$this->_blank = true;
|
||||
}
|
||||
|
||||
function onInvalidStop()
|
||||
{
|
||||
$this->_style = 0x00;
|
||||
}
|
||||
|
||||
function onInvalidWarn()
|
||||
{
|
||||
$this->_style = 0x01;
|
||||
}
|
||||
|
||||
function onInvalidInfo()
|
||||
{
|
||||
$this->_style = 0x02;
|
||||
}
|
||||
|
||||
function setFormula1($formula)
|
||||
{
|
||||
// Parse the formula using the parser in Parser.php
|
||||
$error = $this->_parser->parse($formula);
|
||||
if (PEAR::isError($error)) {
|
||||
return $this->_formula1;
|
||||
}
|
||||
|
||||
$this->_formula1 = $this->_parser->toReversePolish();
|
||||
if (PEAR::isError($this->_formula1)) {
|
||||
return $this->_formula1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function setFormula2($formula)
|
||||
{
|
||||
// Parse the formula using the parser in Parser.php
|
||||
$error = $this->_parser->parse($formula);
|
||||
if (PEAR::isError($error)) {
|
||||
return $this->_formula2;
|
||||
}
|
||||
|
||||
$this->_formula2 = $this->_parser->toReversePolish();
|
||||
if (PEAR::isError($this->_formula2)) {
|
||||
return $this->_formula2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function _getOptions()
|
||||
{
|
||||
$options = $this->_type;
|
||||
$options |= $this->_style << 3;
|
||||
if ($this->_fixedList) {
|
||||
$options |= 0x80;
|
||||
}
|
||||
if ($this->_blank) {
|
||||
$options |= 0x100;
|
||||
}
|
||||
if (!$this->_incell) {
|
||||
$options |= 0x200;
|
||||
}
|
||||
if ($this->_showprompt) {
|
||||
$options |= 0x40000;
|
||||
}
|
||||
if ($this->_showerror) {
|
||||
$options |= 0x80000;
|
||||
}
|
||||
$options |= $this->_operator << 20;
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function _getData()
|
||||
{
|
||||
$title_prompt_len = strlen($this->_title_prompt);
|
||||
$descr_prompt_len = strlen($this->_descr_prompt);
|
||||
$title_error_len = strlen($this->_title_error);
|
||||
$descr_error_len = strlen($this->_descr_error);
|
||||
|
||||
$formula1_size = strlen($this->_formula1);
|
||||
$formula2_size = strlen($this->_formula2);
|
||||
|
||||
$data = pack("V", $this->_getOptions());
|
||||
$data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt;
|
||||
$data .= pack("vC", $title_error_len, 0x00) . $this->_title_error;
|
||||
$data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt;
|
||||
$data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error;
|
||||
|
||||
$data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1;
|
||||
$data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation
|
||||
{
|
||||
function Spreadsheet_Excel_Writer_Validation_list()
|
||||
{
|
||||
parent::Spreadsheet_Excel_Writer_Validation();
|
||||
$this->_type = 0x03;
|
||||
}
|
||||
|
||||
function setList($source, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
$this->_fixedList = true;
|
||||
|
||||
$source = implode("\x00", $source);
|
||||
$this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source;
|
||||
}
|
||||
|
||||
function setRow($row, $col1, $col2, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
//$this->_formula1 = ...;
|
||||
}
|
||||
|
||||
function setCol($col, $row1, $row2, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
//$this->_formula1 = ...;
|
||||
}
|
||||
}*/
|
||||
|
||||
?>
|
||||
1611
vendor/library/Excel/Writer/Workbook.php
vendored
Normal file
1611
vendor/library/Excel/Writer/Workbook.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
3596
vendor/library/Excel/Writer/Worksheet.php
vendored
Normal file
3596
vendor/library/Excel/Writer/Worksheet.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
81
vendor/library/Excel/demo.php
vendored
Normal file
81
vendor/library/Excel/demo.php
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
//documentation on the spreadsheet package is at:
|
||||
//http://pear.php.net/manual/en/package.fileformats.spreadsheet-excel-writer.php
|
||||
chdir('phpxls');
|
||||
require_once 'Writer.php';
|
||||
chdir('..');
|
||||
|
||||
$sheet1 = array(
|
||||
array('eventid','eventtitle' ,'datetime' ,'description' ,'notes' ),
|
||||
array('5' ,'Education Seminar','2010-05-12 08:00:00','Increase your WPM','' ),
|
||||
array('6' ,'Work Party' ,'2010-05-13 15:30:00','Boss\'s Bday' ,'bring tacos'),
|
||||
array('7' ,'Conference Call' ,'2010-05-14 11:00:00','access code x4321','' ),
|
||||
array('8' ,'Day Off' ,'2010-05-15' ,'Go to Home Depot' ,'' ),
|
||||
);
|
||||
|
||||
$sheet2 = array(
|
||||
array('eventid','funny_name' ),
|
||||
array('32' ,'Adam Baum' ),
|
||||
array('33' ,'Anne Teak' ),
|
||||
array('34' ,'Ali Katt' ),
|
||||
array('35' ,'Anita Bath' ),
|
||||
array('36' ,'April Schauer'),
|
||||
array('37' ,'Bill Board' ),
|
||||
);
|
||||
|
||||
$workbook = new Spreadsheet_Excel_Writer();
|
||||
|
||||
$format_und =& $workbook->addFormat();
|
||||
$format_und->setBottom(2);//thick
|
||||
$format_und->setBold();
|
||||
$format_und->setBgColor('black');
|
||||
$format_und->setColor('white');
|
||||
$format_und->setFontFamily('Arial');
|
||||
$format_und->setSize(8);
|
||||
|
||||
$format_reg =& $workbook->addFormat();
|
||||
$format_reg->setColor('black');
|
||||
$format_reg->setFontFamily('Arial');
|
||||
$format_reg->setSize(8);
|
||||
|
||||
$arr = array(
|
||||
'Calendar'=>$sheet1,
|
||||
'Names' =>$sheet2,
|
||||
);
|
||||
|
||||
foreach($arr as $wbname=>$rows)
|
||||
{
|
||||
$rowcount = count($rows);
|
||||
$colcount = count($rows[0]);
|
||||
|
||||
$worksheet =& $workbook->addWorksheet($wbname);
|
||||
|
||||
|
||||
|
||||
$worksheet->setColumn(0,0, 6.14);//setColumn(startcol,endcol,float)
|
||||
$worksheet->setColumn(1,3,15.00);
|
||||
$worksheet->setColumn(4,4, 8.00);
|
||||
|
||||
for( $j=0; $j<$rowcount; $j++ )
|
||||
{
|
||||
for($i=0; $i<$colcount;$i++)
|
||||
{
|
||||
$fmt =& $format_reg;
|
||||
if ($j==0)
|
||||
$fmt =& $format_und;
|
||||
|
||||
if (isset($rows[$j][$i]))
|
||||
{
|
||||
$data=$rows[$j][$i];
|
||||
$worksheet->write($j, $i, $data, $fmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$workbook->send('test.xls');
|
||||
$workbook->close();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
?>
|
||||
|
||||
65
vendor/library/Excel/excel.php
vendored
Normal file
65
vendor/library/Excel/excel.php
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
/**Carrega a biblioteca par agerar o arquivo*/
|
||||
chdir('phpxls');
|
||||
require_once 'Writer.php';
|
||||
chdir('..');
|
||||
|
||||
/**Instancia da classe*/
|
||||
$workbook = new Spreadsheet_Excel_Writer(date("Y-m-d").'-'.rand(999,99999).'.xls');
|
||||
|
||||
/**Defino o header da planilha*/
|
||||
$header =& $workbook->addFormat();
|
||||
$header->setBottom(2);//thick
|
||||
$header->setBold();
|
||||
$header->setBgColor('black');
|
||||
$header->setFgColor(22);
|
||||
$header->setColor('black');
|
||||
$header->setFontFamily('Arial');
|
||||
$header->setSize(8);
|
||||
$header->setAlign('center');
|
||||
|
||||
//Criação da página
|
||||
$worksheet =& $workbook->addWorksheet("Lista");
|
||||
|
||||
//Defino o body da planilha
|
||||
$body =& $workbook->addFormat();
|
||||
$body->setColor('black');
|
||||
$body->setFontFamily('Arial');
|
||||
$body->setSize(8);
|
||||
|
||||
//Definições das colunas
|
||||
$worksheet->setColumn(0,0,30);//Coluna inicial, coluna final, largura
|
||||
$worksheet->setColumn(1,1,30);
|
||||
$worksheet->setColumn(2,2,5);
|
||||
$worksheet->setColumn(3,3,10);
|
||||
$worksheet->setColumn(4,5,12);
|
||||
|
||||
//Escrevendo o header da planilha
|
||||
$worksheet->write(0, 0, "NOME", $header);//Linha, coluna, label, parametros
|
||||
$worksheet->write(0, 1, "E-MAIL", $header);
|
||||
$worksheet->write(0, 2, "SEXO", $header);
|
||||
$worksheet->write(0, 3, "NASCIMENTO", $header);
|
||||
$worksheet->write(0, 4, "CPF", $header);
|
||||
|
||||
$line=1;//Linha inicial
|
||||
$col=0;//Coluna inicial
|
||||
|
||||
for($i=0;$i<10;$i++)
|
||||
{
|
||||
|
||||
//Escrevendo o body da planilha
|
||||
$worksheet->write($line, $col++, "Kenio de Souza", $body);
|
||||
$worksheet->write($line, $col++, "kenio_souza@hotmail.com", $body);
|
||||
$worksheet->write($line, $col++, "M", $body);
|
||||
$worksheet->write($line, $col++, "07/09/1977", $body);
|
||||
$worksheet->writeString($line, $col++, rand(0,99999999999), $body);
|
||||
//Obs: Utiliza-se writeString para escrever numeros em forma de string,
|
||||
//senão o excel irá ignorar os zeros a esquerda
|
||||
|
||||
$line++;
|
||||
$col=0;
|
||||
}
|
||||
|
||||
//Envio o arquivo para download
|
||||
//$workbook->send(date("Y-m-d").'-'.rand(999,99999).'.xls');
|
||||
$workbook->close();
|
||||
271
vendor/library/Excel/oleread.inc
vendored
Normal file
271
vendor/library/Excel/oleread.inc
vendored
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
<?php
|
||||
define('NUM_BIG_BLOCK_DEPOT_BLOCKS_POS', 0x2c);
|
||||
define('SMALL_BLOCK_DEPOT_BLOCK_POS', 0x3c);
|
||||
define('ROOT_START_BLOCK_POS', 0x30);
|
||||
define('BIG_BLOCK_SIZE', 0x200);
|
||||
define('SMALL_BLOCK_SIZE', 0x40);
|
||||
define('EXTENSION_BLOCK_POS', 0x44);
|
||||
define('NUM_EXTENSION_BLOCK_POS', 0x48);
|
||||
define('PROPERTY_STORAGE_BLOCK_SIZE', 0x80);
|
||||
define('BIG_BLOCK_DEPOT_BLOCKS_POS', 0x4c);
|
||||
define('SMALL_BLOCK_THRESHOLD', 0x1000);
|
||||
// property storage offsets
|
||||
define('SIZE_OF_NAME_POS', 0x40);
|
||||
define('TYPE_POS', 0x42);
|
||||
define('START_BLOCK_POS', 0x74);
|
||||
define('SIZE_POS', 0x78);
|
||||
define('IDENTIFIER_OLE', pack("CCCCCCCC",0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1));
|
||||
|
||||
//echo 'ROOT_START_BLOCK_POS = '.ROOT_START_BLOCK_POS."\n";
|
||||
|
||||
//echo bin2hex($data[ROOT_START_BLOCK_POS])."\n";
|
||||
//echo "a=";
|
||||
//echo $data[ROOT_START_BLOCK_POS];
|
||||
//function log
|
||||
|
||||
function GetInt4d($data, $pos)
|
||||
{
|
||||
$value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24);
|
||||
if ($value>=4294967294)
|
||||
{
|
||||
$value=-2;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
class OLERead {
|
||||
var $data = '';
|
||||
|
||||
|
||||
function OLERead(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
function read($sFileName){
|
||||
|
||||
// check if file exist and is readable (Darko Miljanovic)
|
||||
if(!is_readable($sFileName)) {
|
||||
$this->error = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->data = @file_get_contents($sFileName);
|
||||
if (!$this->data) {
|
||||
$this->error = 1;
|
||||
return false;
|
||||
}
|
||||
//echo IDENTIFIER_OLE;
|
||||
//echo 'start';
|
||||
if (substr($this->data, 0, 8) != IDENTIFIER_OLE) {
|
||||
$this->error = 1;
|
||||
return false;
|
||||
}
|
||||
$this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
|
||||
$this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS);
|
||||
$this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS);
|
||||
$this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS);
|
||||
$this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS);
|
||||
|
||||
/*
|
||||
echo $this->numBigBlockDepotBlocks." ";
|
||||
echo $this->sbdStartBlock." ";
|
||||
echo $this->rootStartBlock." ";
|
||||
echo $this->extensionBlock." ";
|
||||
echo $this->numExtensionBlocks." ";
|
||||
*/
|
||||
//echo "sbdStartBlock = $this->sbdStartBlock\n";
|
||||
$bigBlockDepotBlocks = array();
|
||||
$pos = BIG_BLOCK_DEPOT_BLOCKS_POS;
|
||||
// echo "pos = $pos";
|
||||
$bbdBlocks = $this->numBigBlockDepotBlocks;
|
||||
|
||||
if ($this->numExtensionBlocks != 0) {
|
||||
$bbdBlocks = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS)/4;
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $bbdBlocks; $i++) {
|
||||
$bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
|
||||
$pos += 4;
|
||||
}
|
||||
|
||||
|
||||
for ($j = 0; $j < $this->numExtensionBlocks; $j++) {
|
||||
$pos = ($this->extensionBlock + 1) * BIG_BLOCK_SIZE;
|
||||
$blocksToRead = min($this->numBigBlockDepotBlocks - $bbdBlocks, BIG_BLOCK_SIZE / 4 - 1);
|
||||
|
||||
for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; $i++) {
|
||||
$bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos);
|
||||
$pos += 4;
|
||||
}
|
||||
|
||||
$bbdBlocks += $blocksToRead;
|
||||
if ($bbdBlocks < $this->numBigBlockDepotBlocks) {
|
||||
$this->extensionBlock = GetInt4d($this->data, $pos);
|
||||
}
|
||||
}
|
||||
|
||||
// var_dump($bigBlockDepotBlocks);
|
||||
|
||||
// readBigBlockDepot
|
||||
$pos = 0;
|
||||
$index = 0;
|
||||
$this->bigBlockChain = array();
|
||||
|
||||
for ($i = 0; $i < $this->numBigBlockDepotBlocks; $i++) {
|
||||
$pos = ($bigBlockDepotBlocks[$i] + 1) * BIG_BLOCK_SIZE;
|
||||
//echo "pos = $pos";
|
||||
for ($j = 0 ; $j < BIG_BLOCK_SIZE / 4; $j++) {
|
||||
$this->bigBlockChain[$index] = GetInt4d($this->data, $pos);
|
||||
$pos += 4 ;
|
||||
$index++;
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($this->bigBlockChain);
|
||||
//echo '=====2';
|
||||
// readSmallBlockDepot();
|
||||
$pos = 0;
|
||||
$index = 0;
|
||||
$sbdBlock = $this->sbdStartBlock;
|
||||
$this->smallBlockChain = array();
|
||||
|
||||
while ($sbdBlock != -2) {
|
||||
|
||||
$pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE;
|
||||
|
||||
for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) {
|
||||
$this->smallBlockChain[$index] = GetInt4d($this->data, $pos);
|
||||
$pos += 4;
|
||||
$index++;
|
||||
}
|
||||
|
||||
$sbdBlock = $this->bigBlockChain[$sbdBlock];
|
||||
}
|
||||
|
||||
|
||||
// readData(rootStartBlock)
|
||||
$block = $this->rootStartBlock;
|
||||
$pos = 0;
|
||||
$this->entry = $this->__readData($block);
|
||||
|
||||
/*
|
||||
while ($block != -2) {
|
||||
$pos = ($block + 1) * BIG_BLOCK_SIZE;
|
||||
$this->entry = $this->entry.substr($this->data, $pos, BIG_BLOCK_SIZE);
|
||||
$block = $this->bigBlockChain[$block];
|
||||
}
|
||||
*/
|
||||
//echo '==='.$this->entry."===";
|
||||
$this->__readPropertySets();
|
||||
|
||||
}
|
||||
|
||||
function __readData($bl) {
|
||||
$block = $bl;
|
||||
$pos = 0;
|
||||
$data = '';
|
||||
|
||||
while ($block != -2) {
|
||||
$pos = ($block + 1) * BIG_BLOCK_SIZE;
|
||||
$data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE);
|
||||
//echo "pos = $pos data=$data\n";
|
||||
$block = $this->bigBlockChain[$block];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function __readPropertySets(){
|
||||
$offset = 0;
|
||||
//var_dump($this->entry);
|
||||
while ($offset < strlen($this->entry)) {
|
||||
$d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE);
|
||||
|
||||
$nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8);
|
||||
|
||||
$type = ord($d[TYPE_POS]);
|
||||
//$maxBlock = strlen($d) / BIG_BLOCK_SIZE - 1;
|
||||
|
||||
$startBlock = GetInt4d($d, START_BLOCK_POS);
|
||||
$size = GetInt4d($d, SIZE_POS);
|
||||
|
||||
$name = '';
|
||||
for ($i = 0; $i < $nameSize ; $i++) {
|
||||
$name .= $d[$i];
|
||||
}
|
||||
|
||||
$name = str_replace("\x00", "", $name);
|
||||
|
||||
$this->props[] = array (
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
'startBlock' => $startBlock,
|
||||
'size' => $size);
|
||||
|
||||
if (($name == "Workbook") || ($name == "Book")) {
|
||||
$this->wrkbook = count($this->props) - 1;
|
||||
}
|
||||
|
||||
if ($name == "Root Entry") {
|
||||
$this->rootentry = count($this->props) - 1;
|
||||
}
|
||||
|
||||
//echo "name ==$name=\n";
|
||||
|
||||
|
||||
$offset += PROPERTY_STORAGE_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getWorkBook(){
|
||||
if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){
|
||||
// getSmallBlockStream(PropertyStorage ps)
|
||||
|
||||
$rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']);
|
||||
|
||||
$streamData = '';
|
||||
$block = $this->props[$this->wrkbook]['startBlock'];
|
||||
//$count = 0;
|
||||
$pos = 0;
|
||||
while ($block != -2) {
|
||||
$pos = $block * SMALL_BLOCK_SIZE;
|
||||
$streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE);
|
||||
|
||||
$block = $this->smallBlockChain[$block];
|
||||
}
|
||||
|
||||
return $streamData;
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
$numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE;
|
||||
if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) {
|
||||
$numBlocks++;
|
||||
}
|
||||
|
||||
if ($numBlocks == 0) return '';
|
||||
|
||||
//echo "numBlocks = $numBlocks\n";
|
||||
//byte[] streamData = new byte[numBlocks * BIG_BLOCK_SIZE];
|
||||
//print_r($this->wrkbook);
|
||||
$streamData = '';
|
||||
$block = $this->props[$this->wrkbook]['startBlock'];
|
||||
//$count = 0;
|
||||
$pos = 0;
|
||||
//echo "block = $block";
|
||||
while ($block != -2) {
|
||||
$pos = ($block + 1) * BIG_BLOCK_SIZE;
|
||||
$streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE);
|
||||
$block = $this->bigBlockChain[$block];
|
||||
}
|
||||
//echo 'stream'.$streamData;
|
||||
return $streamData;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
229
vendor/library/Excel/phpxls/ChainedBlockStream.php
vendored
Normal file
229
vendor/library/Excel/phpxls/ChainedBlockStream.php
vendored
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
<?php
|
||||
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Stream wrapper for reading data stored in an OLE file.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
* @author Christian Schmidt <schmidt@php.net>
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: ChainedBlockStream.php,v 1.1 2007/02/13 21:00:42 schmidt Exp $
|
||||
* @link http://pear.php.net/package/OLE
|
||||
* @since File available since Release 0.6.0
|
||||
*/
|
||||
|
||||
require_once 'PEAR.php';
|
||||
require_once 'OLE.php';
|
||||
|
||||
/**
|
||||
* Stream wrapper for reading data stored in an OLE file. Implements methods
|
||||
* for PHP's stream_wrapper_register(). For creating streams using this
|
||||
* wrapper, use OLE_PPS_File::getStream().
|
||||
*
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
* @author Christian Schmidt <schmidt@php.net>
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: @package_version@
|
||||
* @link http://pear.php.net/package/OLE
|
||||
* @since Class available since Release 0.6.0
|
||||
*/
|
||||
class OLE_ChainedBlockStream extends PEAR
|
||||
{
|
||||
/**
|
||||
* The OLE container of the file that is being read.
|
||||
* @var OLE
|
||||
*/
|
||||
var $ole;
|
||||
|
||||
/**
|
||||
* Parameters specified by fopen().
|
||||
* @var array
|
||||
*/
|
||||
var $params;
|
||||
|
||||
/**
|
||||
* The binary data of the file.
|
||||
* @var string
|
||||
*/
|
||||
var $data;
|
||||
|
||||
/**
|
||||
* The file pointer.
|
||||
* @var int byte offset
|
||||
*/
|
||||
var $pos;
|
||||
|
||||
/**
|
||||
* Implements support for fopen().
|
||||
* For creating streams using this wrapper, use OLE_PPS_File::getStream().
|
||||
* @param string resource name including scheme, e.g.
|
||||
* ole-chainedblockstream://oleInstanceId=1
|
||||
* @param string only "r" is supported
|
||||
* @param int mask of STREAM_REPORT_ERRORS and STREAM_USE_PATH
|
||||
* @param string absolute path of the opened stream (out parameter)
|
||||
* @return bool true on success
|
||||
*/
|
||||
function stream_open($path, $mode, $options, &$openedPath)
|
||||
{
|
||||
if ($mode != 'r') {
|
||||
if ($options & STREAM_REPORT_ERRORS) {
|
||||
trigger_error('Only reading is supported', E_USER_WARNING);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 25 is length of "ole-chainedblockstream://"
|
||||
parse_str(substr($path, 25), $this->params);
|
||||
if (!isset($this->params['oleInstanceId'],
|
||||
$this->params['blockId'],
|
||||
$GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']])) {
|
||||
|
||||
if ($options & STREAM_REPORT_ERRORS) {
|
||||
trigger_error('OLE stream not found', E_USER_WARNING);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$this->ole = $GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']];
|
||||
|
||||
$blockId = $this->params['blockId'];
|
||||
$this->data = '';
|
||||
if (isset($this->params['size']) &&
|
||||
$this->params['size'] < $this->ole->bigBlockThreshold &&
|
||||
$blockId != $this->ole->root->_StartBlock) {
|
||||
|
||||
// Block id refers to small blocks
|
||||
$rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock);
|
||||
while ($blockId != -2) {
|
||||
$pos = $rootPos + $blockId * $this->ole->bigBlockSize;
|
||||
$blockId = $this->ole->sbat[$blockId];
|
||||
fseek($this->ole->_file_handle, $pos);
|
||||
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
|
||||
}
|
||||
} else {
|
||||
// Block id refers to big blocks
|
||||
while ($blockId != -2) {
|
||||
$pos = $this->ole->_getBlockOffset($blockId);
|
||||
fseek($this->ole->_file_handle, $pos);
|
||||
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
|
||||
$blockId = $this->ole->bbat[$blockId];
|
||||
}
|
||||
}
|
||||
if (isset($this->params['size'])) {
|
||||
$this->data = substr($this->data, 0, $this->params['size']);
|
||||
}
|
||||
|
||||
if ($options & STREAM_USE_PATH) {
|
||||
$openedPath = $path;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements support for fclose().
|
||||
* @return string
|
||||
*/
|
||||
function stream_close()
|
||||
{
|
||||
$this->ole = null;
|
||||
unset($GLOBALS['_OLE_INSTANCES']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements support for fread(), fgets() etc.
|
||||
* @param int maximum number of bytes to read
|
||||
* @return string
|
||||
*/
|
||||
function stream_read($count)
|
||||
{
|
||||
if ($this->stream_eof()) {
|
||||
return false;
|
||||
}
|
||||
$s = substr($this->data, $this->pos, $count);
|
||||
$this->pos += $count;
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements support for feof().
|
||||
* @return bool TRUE if the file pointer is at EOF; otherwise FALSE
|
||||
*/
|
||||
function stream_eof()
|
||||
{
|
||||
$eof = $this->pos >= strlen($this->data);
|
||||
// Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508
|
||||
if (version_compare(PHP_VERSION, '5.0', '>=') &&
|
||||
version_compare(PHP_VERSION, '5.1', '<')) {
|
||||
|
||||
$eof = !$eof;
|
||||
}
|
||||
return $eof;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the position of the file pointer, i.e. its offset into the file
|
||||
* stream. Implements support for ftell().
|
||||
* @return int
|
||||
*/
|
||||
function stream_tell()
|
||||
{
|
||||
return $this->pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements support for fseek().
|
||||
* @param int byte offset
|
||||
* @param int SEEK_SET, SEEK_CUR or SEEK_END
|
||||
* @return bool
|
||||
*/
|
||||
function stream_seek($offset, $whence)
|
||||
{
|
||||
if ($whence == SEEK_SET && $offset >= 0) {
|
||||
$this->pos = $offset;
|
||||
} elseif ($whence == SEEK_CUR && -$offset <= $this->pos) {
|
||||
$this->pos += $offset;
|
||||
} elseif ($whence == SEEK_END && -$offset <= sizeof($this->data)) {
|
||||
$this->pos = strlen($this->data) + $offset;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements support for fstat(). Currently the only supported field is
|
||||
* "size".
|
||||
* @return array
|
||||
*/
|
||||
function stream_stat()
|
||||
{
|
||||
return array(
|
||||
'size' => strlen($this->data),
|
||||
);
|
||||
}
|
||||
|
||||
// Methods used by stream_wrapper_register() that are not implemented:
|
||||
// bool stream_flush ( void )
|
||||
// int stream_write ( string data )
|
||||
// bool rename ( string path_from, string path_to )
|
||||
// bool mkdir ( string path, int mode, int options )
|
||||
// bool rmdir ( string path, int options )
|
||||
// bool dir_opendir ( string path, int options )
|
||||
// array url_stat ( string path, int flags )
|
||||
// string dir_readdir ( void )
|
||||
// bool dir_rewinddir ( void )
|
||||
// bool dir_closedir ( void )
|
||||
}
|
||||
|
||||
?>
|
||||
290
vendor/library/Excel/phpxls/Console/Getopt.php
vendored
Normal file
290
vendor/library/Excel/phpxls/Console/Getopt.php
vendored
Normal file
|
|
@ -0,0 +1,290 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Andrei Zmievski <andrei@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: Getopt.php,v 1.4 2007/06/12 14:58:56 cellog Exp $
|
||||
|
||||
require_once 'PEAR.php';
|
||||
|
||||
/**
|
||||
* Command-line options parsing class.
|
||||
*
|
||||
* @author Andrei Zmievski <andrei@php.net>
|
||||
*
|
||||
*/
|
||||
class Console_Getopt {
|
||||
/**
|
||||
* Parses the command-line options.
|
||||
*
|
||||
* The first parameter to this function should be the list of command-line
|
||||
* arguments without the leading reference to the running program.
|
||||
*
|
||||
* The second parameter is a string of allowed short options. Each of the
|
||||
* option letters can be followed by a colon ':' to specify that the option
|
||||
* requires an argument, or a double colon '::' to specify that the option
|
||||
* takes an optional argument.
|
||||
*
|
||||
* The third argument is an optional array of allowed long options. The
|
||||
* leading '--' should not be included in the option name. Options that
|
||||
* require an argument should be followed by '=', and options that take an
|
||||
* option argument should be followed by '=='.
|
||||
*
|
||||
* The return value is an array of two elements: the list of parsed
|
||||
* options and the list of non-option command-line arguments. Each entry in
|
||||
* the list of parsed options is a pair of elements - the first one
|
||||
* specifies the option, and the second one specifies the option argument,
|
||||
* if there was one.
|
||||
*
|
||||
* Long and short options can be mixed.
|
||||
*
|
||||
* Most of the semantics of this function are based on GNU getopt_long().
|
||||
*
|
||||
* @param array $args an array of command-line arguments
|
||||
* @param string $short_options specifies the list of allowed short options
|
||||
* @param array $long_options specifies the list of allowed long options
|
||||
*
|
||||
* @return array two-element array containing the list of parsed options and
|
||||
* the non-option arguments
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
function getopt2($args, $short_options, $long_options = null)
|
||||
{
|
||||
return Console_Getopt::doGetopt(2, $args, $short_options, $long_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function expects $args to start with the script name (POSIX-style).
|
||||
* Preserved for backwards compatibility.
|
||||
* @see getopt2()
|
||||
*/
|
||||
function getopt($args, $short_options, $long_options = null)
|
||||
{
|
||||
return Console_Getopt::doGetopt(1, $args, $short_options, $long_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual implementation of the argument parsing code.
|
||||
*/
|
||||
function doGetopt($version, $args, $short_options, $long_options = null)
|
||||
{
|
||||
// in case you pass directly readPHPArgv() as the first arg
|
||||
if (PEAR::isError($args)) {
|
||||
return $args;
|
||||
}
|
||||
if (empty($args)) {
|
||||
return array(array(), array());
|
||||
}
|
||||
$opts = array();
|
||||
$non_opts = array();
|
||||
|
||||
settype($args, 'array');
|
||||
|
||||
if ($long_options) {
|
||||
sort($long_options);
|
||||
}
|
||||
|
||||
/*
|
||||
* Preserve backwards compatibility with callers that relied on
|
||||
* erroneous POSIX fix.
|
||||
*/
|
||||
if ($version < 2) {
|
||||
if (isset($args[0]{0}) && $args[0]{0} != '-') {
|
||||
array_shift($args);
|
||||
}
|
||||
}
|
||||
|
||||
reset($args);
|
||||
while (list($i, $arg) = each($args)) {
|
||||
|
||||
/* The special element '--' means explicit end of
|
||||
options. Treat the rest of the arguments as non-options
|
||||
and end the loop. */
|
||||
if ($arg == '--') {
|
||||
$non_opts = array_merge($non_opts, array_slice($args, $i + 1));
|
||||
break;
|
||||
}
|
||||
|
||||
if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) {
|
||||
$non_opts = array_merge($non_opts, array_slice($args, $i));
|
||||
break;
|
||||
} elseif (strlen($arg) > 1 && $arg{1} == '-') {
|
||||
$error = Console_Getopt::_parseLongOption(substr($arg, 2), $long_options, $opts, $args);
|
||||
if (PEAR::isError($error))
|
||||
return $error;
|
||||
} elseif ($arg == '-') {
|
||||
// - is stdin
|
||||
$non_opts = array_merge($non_opts, array_slice($args, $i));
|
||||
break;
|
||||
} else {
|
||||
$error = Console_Getopt::_parseShortOption(substr($arg, 1), $short_options, $opts, $args);
|
||||
if (PEAR::isError($error))
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
||||
return array($opts, $non_opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
function _parseShortOption($arg, $short_options, &$opts, &$args)
|
||||
{
|
||||
for ($i = 0; $i < strlen($arg); $i++) {
|
||||
$opt = $arg{$i};
|
||||
$opt_arg = null;
|
||||
|
||||
/* Try to find the short option in the specifier string. */
|
||||
if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':')
|
||||
{
|
||||
return PEAR::raiseError("Console_Getopt: unrecognized option -- $opt");
|
||||
}
|
||||
|
||||
if (strlen($spec) > 1 && $spec{1} == ':') {
|
||||
if (strlen($spec) > 2 && $spec{2} == ':') {
|
||||
if ($i + 1 < strlen($arg)) {
|
||||
/* Option takes an optional argument. Use the remainder of
|
||||
the arg string if there is anything left. */
|
||||
$opts[] = array($opt, substr($arg, $i + 1));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Option requires an argument. Use the remainder of the arg
|
||||
string if there is anything left. */
|
||||
if ($i + 1 < strlen($arg)) {
|
||||
$opts[] = array($opt, substr($arg, $i + 1));
|
||||
break;
|
||||
} else if (list(, $opt_arg) = each($args)) {
|
||||
/* Else use the next argument. */;
|
||||
if (Console_Getopt::_isShortOpt($opt_arg) || Console_Getopt::_isLongOpt($opt_arg)) {
|
||||
return PEAR::raiseError("Console_Getopt: option requires an argument -- $opt");
|
||||
}
|
||||
} else {
|
||||
return PEAR::raiseError("Console_Getopt: option requires an argument -- $opt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$opts[] = array($opt, $opt_arg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
function _isShortOpt($arg)
|
||||
{
|
||||
return strlen($arg) == 2 && $arg[0] == '-' && preg_match('/[a-zA-Z]/', $arg[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
function _isLongOpt($arg)
|
||||
{
|
||||
return strlen($arg) > 2 && $arg[0] == '-' && $arg[1] == '-' &&
|
||||
preg_match('/[a-zA-Z]+$/', substr($arg, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
function _parseLongOption($arg, $long_options, &$opts, &$args)
|
||||
{
|
||||
@list($opt, $opt_arg) = explode('=', $arg, 2);
|
||||
$opt_len = strlen($opt);
|
||||
|
||||
for ($i = 0; $i < count($long_options); $i++) {
|
||||
$long_opt = $long_options[$i];
|
||||
$opt_start = substr($long_opt, 0, $opt_len);
|
||||
$long_opt_name = str_replace('=', '', $long_opt);
|
||||
|
||||
/* Option doesn't match. Go on to the next one. */
|
||||
if ($long_opt_name != $opt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$opt_rest = substr($long_opt, $opt_len);
|
||||
|
||||
/* Check that the options uniquely matches one of the allowed
|
||||
options. */
|
||||
if ($i + 1 < count($long_options)) {
|
||||
$next_option_rest = substr($long_options[$i + 1], $opt_len);
|
||||
} else {
|
||||
$next_option_rest = '';
|
||||
}
|
||||
if ($opt_rest != '' && $opt{0} != '=' &&
|
||||
$i + 1 < count($long_options) &&
|
||||
$opt == substr($long_options[$i+1], 0, $opt_len) &&
|
||||
$next_option_rest != '' &&
|
||||
$next_option_rest{0} != '=') {
|
||||
return PEAR::raiseError("Console_Getopt: option --$opt is ambiguous");
|
||||
}
|
||||
|
||||
if (substr($long_opt, -1) == '=') {
|
||||
if (substr($long_opt, -2) != '==') {
|
||||
/* Long option requires an argument.
|
||||
Take the next argument if one wasn't specified. */;
|
||||
if (!strlen($opt_arg) && !(list(, $opt_arg) = each($args))) {
|
||||
return PEAR::raiseError("Console_Getopt: option --$opt requires an argument");
|
||||
}
|
||||
if (Console_Getopt::_isShortOpt($opt_arg) || Console_Getopt::_isLongOpt($opt_arg)) {
|
||||
return PEAR::raiseError("Console_Getopt: option requires an argument --$opt");
|
||||
}
|
||||
}
|
||||
} else if ($opt_arg) {
|
||||
return PEAR::raiseError("Console_Getopt: option --$opt doesn't allow an argument");
|
||||
}
|
||||
|
||||
$opts[] = array('--' . $opt, $opt_arg);
|
||||
return;
|
||||
}
|
||||
|
||||
return PEAR::raiseError("Console_Getopt: unrecognized option --$opt");
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely read the $argv PHP array across different PHP configurations.
|
||||
* Will take care on register_globals and register_argc_argv ini directives
|
||||
*
|
||||
* @access public
|
||||
* @return mixed the $argv PHP array or PEAR error if not registered
|
||||
*/
|
||||
function readPHPArgv()
|
||||
{
|
||||
global $argv;
|
||||
if (!is_array($argv)) {
|
||||
if (!@is_array($_SERVER['argv'])) {
|
||||
if (!@is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) {
|
||||
return PEAR::raiseError("Console_Getopt: Could not read cmd args (register_argc_argv=Off?)");
|
||||
}
|
||||
return $GLOBALS['HTTP_SERVER_VARS']['argv'];
|
||||
}
|
||||
return $_SERVER['argv'];
|
||||
}
|
||||
return $argv;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
241
vendor/library/Excel/phpxls/ExcelWriter/BIFFwriter.php
vendored
Normal file
241
vendor/library/Excel/phpxls/ExcelWriter/BIFFwriter.php
vendored
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
<?php
|
||||
/*
|
||||
* Module written/ported by Xavier Noguer <xnoguer@php.net>
|
||||
*
|
||||
* The majority of this is _NOT_ my code. I simply ported it from the
|
||||
* PERL Spreadsheet::WriteExcel module.
|
||||
*
|
||||
* The author of the Spreadsheet::WriteExcel module is John McNamara
|
||||
* <jmcnamara@cpan.org>
|
||||
*
|
||||
* I _DO_ maintain this code, and John McNamara has nothing to do with the
|
||||
* porting of this code to PHP. Any questions directly related to this
|
||||
* class library should be directed to me.
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@php.net
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
require_once 'PEAR.php';
|
||||
|
||||
/**
|
||||
* Class for writing Excel BIFF records.
|
||||
*
|
||||
* From "MICROSOFT EXCEL BINARY FILE FORMAT" by Mark O'Brien (Microsoft Corporation):
|
||||
*
|
||||
* BIFF (BInary File Format) is the file format in which Excel documents are
|
||||
* saved on disk. A BIFF file is a complete description of an Excel document.
|
||||
* BIFF files consist of sequences of variable-length records. There are many
|
||||
* different types of BIFF records. For example, one record type describes a
|
||||
* formula entered into a cell; one describes the size and location of a
|
||||
* window into a document; another describes a picture format.
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
|
||||
class Spreadsheet_Excel_Writer_BIFFwriter extends PEAR
|
||||
{
|
||||
/**
|
||||
* The BIFF/Excel version (5).
|
||||
* @var integer
|
||||
*/
|
||||
var $_BIFF_version = 0x0500;
|
||||
|
||||
/**
|
||||
* The byte order of this architecture. 0 => little endian, 1 => big endian
|
||||
* @var integer
|
||||
*/
|
||||
var $_byte_order;
|
||||
|
||||
/**
|
||||
* The string containing the data of the BIFF stream
|
||||
* @var string
|
||||
*/
|
||||
var $_data;
|
||||
|
||||
/**
|
||||
* The size of the data in bytes. Should be the same as strlen($this->_data)
|
||||
* @var integer
|
||||
*/
|
||||
var $_datasize;
|
||||
|
||||
/**
|
||||
* The maximun length for a BIFF record. See _addContinue()
|
||||
* @var integer
|
||||
* @see _addContinue()
|
||||
*/
|
||||
var $_limit;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
|
||||
function __construct(){}
|
||||
|
||||
function Spreadsheet_Excel_Writer_BIFFwriter()
|
||||
{
|
||||
$this->_byte_order = '';
|
||||
$this->_data = '';
|
||||
$this->_datasize = 0;
|
||||
$this->_limit = 2080;
|
||||
// Set the byte order
|
||||
$this->_setByteOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the byte order and store it as class data to avoid
|
||||
* recalculating it for each call to new().
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _setByteOrder()
|
||||
{
|
||||
// Check if "pack" gives the required IEEE 64bit float
|
||||
$teststr = pack("d", 1.2345);
|
||||
$number = pack("C8", 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
|
||||
if ($number == $teststr) {
|
||||
$byte_order = 0; // Little Endian
|
||||
} elseif ($number == strrev($teststr)){
|
||||
$byte_order = 1; // Big Endian
|
||||
} else {
|
||||
// Give up. I'll fix this in a later version.
|
||||
return $this->raiseError("Required floating point format ".
|
||||
"not supported on this platform.");
|
||||
}
|
||||
$this->_byte_order = $byte_order;
|
||||
}
|
||||
|
||||
/**
|
||||
* General storage function
|
||||
*
|
||||
* @param string $data binary data to prepend
|
||||
* @access private
|
||||
*/
|
||||
function _prepend($data)
|
||||
{
|
||||
if (strlen($data) > $this->_limit) {
|
||||
$data = $this->_addContinue($data);
|
||||
}
|
||||
$this->_data = $data.$this->_data;
|
||||
$this->_datasize += strlen($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* General storage function
|
||||
*
|
||||
* @param string $data binary data to append
|
||||
* @access private
|
||||
*/
|
||||
function _append($data)
|
||||
{
|
||||
if (strlen($data) > $this->_limit) {
|
||||
$data = $this->_addContinue($data);
|
||||
}
|
||||
$this->_data = $this->_data.$data;
|
||||
$this->_datasize += strlen($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Excel BOF record to indicate the beginning of a stream or
|
||||
* sub-stream in the BIFF file.
|
||||
*
|
||||
* @param integer $type Type of BIFF file to write: 0x0005 Workbook,
|
||||
* 0x0010 Worksheet.
|
||||
* @access private
|
||||
*/
|
||||
function _storeBof($type)
|
||||
{
|
||||
$record = 0x0809; // Record identifier
|
||||
|
||||
// According to the SDK $build and $year should be set to zero.
|
||||
// However, this throws a warning in Excel 5. So, use magic numbers.
|
||||
if ($this->_BIFF_version == 0x0500) {
|
||||
$length = 0x0008;
|
||||
$unknown = '';
|
||||
$build = 0x096C;
|
||||
$year = 0x07C9;
|
||||
} elseif ($this->_BIFF_version == 0x0600) {
|
||||
$length = 0x0010;
|
||||
$unknown = pack("VV", 0x00000041, 0x00000006); //unknown last 8 bytes for BIFF8
|
||||
$build = 0x0DBB;
|
||||
$year = 0x07CC;
|
||||
}
|
||||
$version = $this->_BIFF_version;
|
||||
|
||||
$header = pack("vv", $record, $length);
|
||||
$data = pack("vvvv", $version, $type, $build, $year);
|
||||
$this->_prepend($header . $data . $unknown);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes Excel EOF record to indicate the end of a BIFF stream.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _storeEof()
|
||||
{
|
||||
$record = 0x000A; // Record identifier
|
||||
$length = 0x0000; // Number of bytes to follow
|
||||
$header = pack("vv", $record, $length);
|
||||
$this->_append($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel limits the size of BIFF records. In Excel 5 the limit is 2084 bytes. In
|
||||
* Excel 97 the limit is 8228 bytes. Records that are longer than these limits
|
||||
* must be split up into CONTINUE blocks.
|
||||
*
|
||||
* This function takes a long BIFF record and inserts CONTINUE records as
|
||||
* necessary.
|
||||
*
|
||||
* @param string $data The original binary data to be written
|
||||
* @return string A very convenient string of continue blocks
|
||||
* @access private
|
||||
*/
|
||||
function _addContinue($data)
|
||||
{
|
||||
$limit = $this->_limit;
|
||||
$record = 0x003C; // Record identifier
|
||||
|
||||
// The first 2080/8224 bytes remain intact. However, we have to change
|
||||
// the length field of the record.
|
||||
$tmp = substr($data, 0, 2).pack("v", $limit-4).substr($data, 4, $limit - 4);
|
||||
|
||||
$header = pack("vv", $record, $limit); // Headers for continue records
|
||||
|
||||
// Retrieve chunks of 2080/8224 bytes +4 for the header.
|
||||
$data_length = strlen($data);
|
||||
for ($i = $limit; $i < ($data_length - $limit); $i += $limit) {
|
||||
$tmp .= $header;
|
||||
$tmp .= substr($data, $i, $limit);
|
||||
}
|
||||
|
||||
// Retrieve the last chunk of data
|
||||
$header = pack("vv", $record, strlen($data) - $i);
|
||||
$tmp .= $header;
|
||||
$tmp .= substr($data, $i, strlen($data) - $i);
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
}
|
||||
?>
|
||||
1102
vendor/library/Excel/phpxls/ExcelWriter/Format.php
vendored
Normal file
1102
vendor/library/Excel/phpxls/ExcelWriter/Format.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
1689
vendor/library/Excel/phpxls/ExcelWriter/Parser.php
vendored
Normal file
1689
vendor/library/Excel/phpxls/ExcelWriter/Parser.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
230
vendor/library/Excel/phpxls/ExcelWriter/Validator.php
vendored
Normal file
230
vendor/library/Excel/phpxls/ExcelWriter/Validator.php
vendored
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
<?php
|
||||
/*
|
||||
* Module written by Herman Kuiper <herman@ozuzo.net>
|
||||
*
|
||||
* License Information:
|
||||
*
|
||||
* Spreadsheet_Excel_Writer: A library for generating Excel Spreadsheets
|
||||
* Copyright (c) 2002-2003 Xavier Noguer xnoguer@rezebra.com
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
//require_once('PEAR.php');
|
||||
|
||||
// Possible operator types
|
||||
|
||||
/*
|
||||
FIXME: change prefixes
|
||||
*/
|
||||
define("OP_BETWEEN", 0x00);
|
||||
define("OP_NOTBETWEEN", 0x01);
|
||||
define("OP_EQUAL", 0x02);
|
||||
define("OP_NOTEQUAL", 0x03);
|
||||
define("OP_GT", 0x04);
|
||||
define("OP_LT", 0x05);
|
||||
define("OP_GTE", 0x06);
|
||||
define("OP_LTE", 0x07);
|
||||
|
||||
/**
|
||||
* Baseclass for generating Excel DV records (validations)
|
||||
*
|
||||
* @author Herman Kuiper
|
||||
* @category FileFormats
|
||||
* @package Spreadsheet_Excel_Writer
|
||||
*/
|
||||
class Spreadsheet_Excel_Writer_Validator
|
||||
{
|
||||
var $_type;
|
||||
var $_style;
|
||||
var $_fixedList;
|
||||
var $_blank;
|
||||
var $_incell;
|
||||
var $_showprompt;
|
||||
var $_showerror;
|
||||
var $_title_prompt;
|
||||
var $_descr_prompt;
|
||||
var $_title_error;
|
||||
var $_descr_error;
|
||||
var $_operator;
|
||||
var $_formula1;
|
||||
var $_formula2;
|
||||
/**
|
||||
* The parser from the workbook. Used to parse validation formulas also
|
||||
* @var Spreadsheet_Excel_Writer_Parser
|
||||
*/
|
||||
var $_parser;
|
||||
|
||||
function Spreadsheet_Excel_Writer_Validator(&$parser)
|
||||
{
|
||||
$this->_parser = $parser;
|
||||
$this->_type = 0x01; // FIXME: add method for setting datatype
|
||||
$this->_style = 0x00;
|
||||
$this->_fixedList = false;
|
||||
$this->_blank = false;
|
||||
$this->_incell = false;
|
||||
$this->_showprompt = false;
|
||||
$this->_showerror = true;
|
||||
$this->_title_prompt = "\x00";
|
||||
$this->_descr_prompt = "\x00";
|
||||
$this->_title_error = "\x00";
|
||||
$this->_descr_error = "\x00";
|
||||
$this->_operator = 0x00; // default is equal
|
||||
$this->_formula1 = '';
|
||||
$this->_formula2 = '';
|
||||
}
|
||||
|
||||
function setPrompt($promptTitle = "\x00", $promptDescription = "\x00", $showPrompt = true)
|
||||
{
|
||||
$this->_showprompt = $showPrompt;
|
||||
$this->_title_prompt = $promptTitle;
|
||||
$this->_descr_prompt = $promptDescription;
|
||||
}
|
||||
|
||||
function setError($errorTitle = "\x00", $errorDescription = "\x00", $showError = true)
|
||||
{
|
||||
$this->_showerror = $showError;
|
||||
$this->_title_error = $errorTitle;
|
||||
$this->_descr_error = $errorDescription;
|
||||
}
|
||||
|
||||
function allowBlank()
|
||||
{
|
||||
$this->_blank = true;
|
||||
}
|
||||
|
||||
function onInvalidStop()
|
||||
{
|
||||
$this->_style = 0x00;
|
||||
}
|
||||
|
||||
function onInvalidWarn()
|
||||
{
|
||||
$this->_style = 0x01;
|
||||
}
|
||||
|
||||
function onInvalidInfo()
|
||||
{
|
||||
$this->_style = 0x02;
|
||||
}
|
||||
|
||||
function setFormula1($formula)
|
||||
{
|
||||
// Parse the formula using the parser in Parser.php
|
||||
$error = $this->_parser->parse($formula);
|
||||
if (PEAR::isError($error)) {
|
||||
return $this->_formula1;
|
||||
}
|
||||
|
||||
$this->_formula1 = $this->_parser->toReversePolish();
|
||||
if (PEAR::isError($this->_formula1)) {
|
||||
return $this->_formula1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function setFormula2($formula)
|
||||
{
|
||||
// Parse the formula using the parser in Parser.php
|
||||
$error = $this->_parser->parse($formula);
|
||||
if (PEAR::isError($error)) {
|
||||
return $this->_formula2;
|
||||
}
|
||||
|
||||
$this->_formula2 = $this->_parser->toReversePolish();
|
||||
if (PEAR::isError($this->_formula2)) {
|
||||
return $this->_formula2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function _getOptions()
|
||||
{
|
||||
$options = $this->_type;
|
||||
$options |= $this->_style << 3;
|
||||
if ($this->_fixedList) {
|
||||
$options |= 0x80;
|
||||
}
|
||||
if ($this->_blank) {
|
||||
$options |= 0x100;
|
||||
}
|
||||
if (!$this->_incell) {
|
||||
$options |= 0x200;
|
||||
}
|
||||
if ($this->_showprompt) {
|
||||
$options |= 0x40000;
|
||||
}
|
||||
if ($this->_showerror) {
|
||||
$options |= 0x80000;
|
||||
}
|
||||
$options |= $this->_operator << 20;
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function _getData()
|
||||
{
|
||||
$title_prompt_len = strlen($this->_title_prompt);
|
||||
$descr_prompt_len = strlen($this->_descr_prompt);
|
||||
$title_error_len = strlen($this->_title_error);
|
||||
$descr_error_len = strlen($this->_descr_error);
|
||||
|
||||
$formula1_size = strlen($this->_formula1);
|
||||
$formula2_size = strlen($this->_formula2);
|
||||
|
||||
$data = pack("V", $this->_getOptions());
|
||||
$data .= pack("vC", $title_prompt_len, 0x00) . $this->_title_prompt;
|
||||
$data .= pack("vC", $title_error_len, 0x00) . $this->_title_error;
|
||||
$data .= pack("vC", $descr_prompt_len, 0x00) . $this->_descr_prompt;
|
||||
$data .= pack("vC", $descr_error_len, 0x00) . $this->_descr_error;
|
||||
|
||||
$data .= pack("vv", $formula1_size, 0x0000) . $this->_formula1;
|
||||
$data .= pack("vv", $formula2_size, 0x0000) . $this->_formula2;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/*class Spreadsheet_Excel_Writer_Validation_List extends Spreadsheet_Excel_Writer_Validation
|
||||
{
|
||||
function Spreadsheet_Excel_Writer_Validation_list()
|
||||
{
|
||||
parent::Spreadsheet_Excel_Writer_Validation();
|
||||
$this->_type = 0x03;
|
||||
}
|
||||
|
||||
function setList($source, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
$this->_fixedList = true;
|
||||
|
||||
$source = implode("\x00", $source);
|
||||
$this->_formula1 = pack("CCC", 0x17, strlen($source), 0x0c) . $source;
|
||||
}
|
||||
|
||||
function setRow($row, $col1, $col2, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
//$this->_formula1 = ...;
|
||||
}
|
||||
|
||||
function setCol($col, $row1, $row2, $incell = true)
|
||||
{
|
||||
$this->_incell = $incell;
|
||||
//$this->_formula1 = ...;
|
||||
}
|
||||
}*/
|
||||
|
||||
?>
|
||||
1533
vendor/library/Excel/phpxls/ExcelWriter/Workbook.php
vendored
Normal file
1533
vendor/library/Excel/phpxls/ExcelWriter/Workbook.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
3502
vendor/library/Excel/phpxls/ExcelWriter/Worksheet.php
vendored
Normal file
3502
vendor/library/Excel/phpxls/ExcelWriter/Worksheet.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
570
vendor/library/Excel/phpxls/OLE.php
vendored
Normal file
570
vendor/library/Excel/phpxls/OLE.php
vendored
Normal file
|
|
@ -0,0 +1,570 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2002 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Xavier Noguer <xnoguer@php.net> |
|
||||
// | Based on OLE::Storage_Lite by Kawai, Takanori |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: OLE.php,v 1.15 2007/12/18 20:59:11 schmidt Exp $
|
||||
|
||||
|
||||
/**
|
||||
* Constants for OLE package
|
||||
*/
|
||||
define('OLE_PPS_TYPE_ROOT', 5);
|
||||
define('OLE_PPS_TYPE_DIR', 1);
|
||||
define('OLE_PPS_TYPE_FILE', 2);
|
||||
define('OLE_DATA_SIZE_SMALL', 0x1000);
|
||||
define('OLE_LONG_INT_SIZE', 4);
|
||||
define('OLE_PPS_SIZE', 0x80);
|
||||
|
||||
require_once 'PEAR.php';
|
||||
|
||||
/**
|
||||
* Array for storing OLE instances that are accessed from
|
||||
* OLE_ChainedBlockStream::stream_open().
|
||||
* @var array
|
||||
*/
|
||||
$GLOBALS['_OLE_INSTANCES'] = array();
|
||||
|
||||
/**
|
||||
* OLE package base class.
|
||||
*
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @author Christian Schmidt <schmidt@php.net>
|
||||
*/
|
||||
class OLE extends PEAR
|
||||
{
|
||||
|
||||
/**
|
||||
* The file handle for reading an OLE container
|
||||
* @var resource
|
||||
*/
|
||||
var $_file_handle;
|
||||
|
||||
/**
|
||||
* Array of PPS's found on the OLE container
|
||||
* @var array
|
||||
*/
|
||||
var $_list;
|
||||
|
||||
/**
|
||||
* Root directory of OLE container
|
||||
* @var OLE_PPS_Root
|
||||
*/
|
||||
var $root;
|
||||
|
||||
/**
|
||||
* Big Block Allocation Table
|
||||
* @var array (blockId => nextBlockId)
|
||||
*/
|
||||
var $bbat;
|
||||
|
||||
/**
|
||||
* Short Block Allocation Table
|
||||
* @var array (blockId => nextBlockId)
|
||||
*/
|
||||
var $sbat;
|
||||
|
||||
/**
|
||||
* Size of big blocks. This is usually 512.
|
||||
* @var int number of octets per block.
|
||||
*/
|
||||
var $bigBlockSize;
|
||||
|
||||
/**
|
||||
* Size of small blocks. This is usually 64.
|
||||
* @var int number of octets per block
|
||||
*/
|
||||
var $smallBlockSize;
|
||||
|
||||
/**
|
||||
* Creates a new OLE object
|
||||
* @access public
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->_list = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor (using PEAR)
|
||||
* Just closes the file handle on the OLE file.
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _OLE()
|
||||
{
|
||||
fclose($this->_file_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an OLE container from the contents of the file given.
|
||||
*
|
||||
* @access public
|
||||
* @param string $file
|
||||
* @return mixed true on success, PEAR_Error on failure
|
||||
*/
|
||||
function read($file)
|
||||
{
|
||||
$fh = @fopen($file, "r");
|
||||
if (!$fh) {
|
||||
return $this->raiseError("Can't open file $file");
|
||||
}
|
||||
$this->_file_handle = $fh;
|
||||
|
||||
$signature = fread($fh, 8);
|
||||
if ("\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1" != $signature) {
|
||||
return $this->raiseError("File doesn't seem to be an OLE container.");
|
||||
}
|
||||
fseek($fh, 28);
|
||||
if (fread($fh, 2) != "\xFE\xFF") {
|
||||
// This shouldn't be a problem in practice
|
||||
return $this->raiseError("Only Little-Endian encoding is supported.");
|
||||
}
|
||||
// Size of blocks and short blocks in bytes
|
||||
$this->bigBlockSize = pow(2, $this->_readInt2($fh));
|
||||
$this->smallBlockSize = pow(2, $this->_readInt2($fh));
|
||||
|
||||
// Skip UID, revision number and version number
|
||||
fseek($fh, 44);
|
||||
// Number of blocks in Big Block Allocation Table
|
||||
$bbatBlockCount = $this->_readInt4($fh);
|
||||
|
||||
// Root chain 1st block
|
||||
$directoryFirstBlockId = $this->_readInt4($fh);
|
||||
|
||||
// Skip unused bytes
|
||||
fseek($fh, 56);
|
||||
// Streams shorter than this are stored using small blocks
|
||||
$this->bigBlockThreshold = $this->_readInt4($fh);
|
||||
// Block id of first sector in Short Block Allocation Table
|
||||
$sbatFirstBlockId = $this->_readInt4($fh);
|
||||
// Number of blocks in Short Block Allocation Table
|
||||
$sbbatBlockCount = $this->_readInt4($fh);
|
||||
// Block id of first sector in Master Block Allocation Table
|
||||
$mbatFirstBlockId = $this->_readInt4($fh);
|
||||
// Number of blocks in Master Block Allocation Table
|
||||
$mbbatBlockCount = $this->_readInt4($fh);
|
||||
$this->bbat = array();
|
||||
|
||||
// Remaining 4 * 109 bytes of current block is beginning of Master
|
||||
// Block Allocation Table
|
||||
$mbatBlocks = array();
|
||||
for ($i = 0; $i < 109; $i++) {
|
||||
$mbatBlocks[] = $this->_readInt4($fh);
|
||||
}
|
||||
|
||||
// Read rest of Master Block Allocation Table (if any is left)
|
||||
$pos = $this->_getBlockOffset($mbatFirstBlockId);
|
||||
for ($i = 0; $i < $mbbatBlockCount; $i++) {
|
||||
fseek($fh, $pos);
|
||||
for ($j = 0; $j < $this->bigBlockSize / 4 - 1; $j++) {
|
||||
$mbatBlocks[] = $this->_readInt4($fh);
|
||||
}
|
||||
// Last block id in each block points to next block
|
||||
$pos = $this->_getBlockOffset($this->_readInt4($fh));
|
||||
}
|
||||
|
||||
// Read Big Block Allocation Table according to chain specified by
|
||||
// $mbatBlocks
|
||||
for ($i = 0; $i < $bbatBlockCount; $i++) {
|
||||
$pos = $this->_getBlockOffset($mbatBlocks[$i]);
|
||||
fseek($fh, $pos);
|
||||
for ($j = 0 ; $j < $this->bigBlockSize / 4; $j++) {
|
||||
$this->bbat[] = $this->_readInt4($fh);
|
||||
}
|
||||
}
|
||||
|
||||
// Read short block allocation table (SBAT)
|
||||
$this->sbat = array();
|
||||
$shortBlockCount = $sbbatBlockCount * $this->bigBlockSize / 4;
|
||||
$sbatFh = $this->getStream($sbatFirstBlockId);
|
||||
for ($blockId = 0; $blockId < $shortBlockCount; $blockId++) {
|
||||
$this->sbat[$blockId] = $this->_readInt4($sbatFh);
|
||||
}
|
||||
fclose($sbatFh);
|
||||
|
||||
$this->_readPpsWks($directoryFirstBlockId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $blockId block id
|
||||
* @return int byte offset from beginning of file
|
||||
* @access private
|
||||
*/
|
||||
function _getBlockOffset($blockId)
|
||||
{
|
||||
return 512 + $blockId * $this->bigBlockSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream for use with fread() etc. External callers should
|
||||
* use OLE_PPS_File::getStream().
|
||||
* @param int|PPS $blockIdOrPps block id or PPS
|
||||
* @return resource read-only stream
|
||||
*/
|
||||
function getStream($blockIdOrPps)
|
||||
{
|
||||
include_once 'OLE/ChainedBlockStream.php';
|
||||
static $isRegistered = false;
|
||||
if (!$isRegistered) {
|
||||
stream_wrapper_register('ole-chainedblockstream',
|
||||
'OLE_ChainedBlockStream');
|
||||
$isRegistered = true;
|
||||
}
|
||||
|
||||
// Store current instance in global array, so that it can be accessed
|
||||
// in OLE_ChainedBlockStream::stream_open().
|
||||
// Object is removed from self::$instances in OLE_Stream::close().
|
||||
$GLOBALS['_OLE_INSTANCES'][] = $this;
|
||||
$instanceId = end(array_keys($GLOBALS['_OLE_INSTANCES']));
|
||||
|
||||
$path = 'ole-chainedblockstream://oleInstanceId=' . $instanceId;
|
||||
if (is_a($blockIdOrPps, 'OLE_PPS')) {
|
||||
$path .= '&blockId=' . $blockIdOrPps->_StartBlock;
|
||||
$path .= '&size=' . $blockIdOrPps->Size;
|
||||
} else {
|
||||
$path .= '&blockId=' . $blockIdOrPps;
|
||||
}
|
||||
return fopen($path, 'r');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a signed char.
|
||||
* @param resource $fh file handle
|
||||
* @return int
|
||||
* @access private
|
||||
*/
|
||||
function _readInt1($fh)
|
||||
{
|
||||
list(, $tmp) = unpack("c", fread($fh, 1));
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an unsigned short (2 octets).
|
||||
* @param resource $fh file handle
|
||||
* @return int
|
||||
* @access private
|
||||
*/
|
||||
function _readInt2($fh)
|
||||
{
|
||||
list(, $tmp) = unpack("v", fread($fh, 2));
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an unsigned long (4 octets).
|
||||
* @param resource file handle
|
||||
* @return int
|
||||
* @access private
|
||||
*/
|
||||
function _readInt4($fh)
|
||||
{
|
||||
list(, $tmp) = unpack("V", fread($fh, 4));
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information about all PPS's on the OLE container from the PPS WK's
|
||||
* creates an OLE_PPS object for each one.
|
||||
*
|
||||
* @access private
|
||||
* @param integer $blockId the block id of the first block
|
||||
* @return mixed true on success, PEAR_Error on failure
|
||||
*/
|
||||
function _readPpsWks($blockId)
|
||||
{
|
||||
$fh = $this->getStream($blockId);
|
||||
for ($pos = 0; ; $pos += 128) {
|
||||
fseek($fh, $pos, SEEK_SET);
|
||||
$nameUtf16 = fread($fh, 64);
|
||||
$nameLength = $this->_readInt2($fh);
|
||||
$nameUtf16 = substr($nameUtf16, 0, $nameLength - 2);
|
||||
// Simple conversion from UTF-16LE to ISO-8859-1
|
||||
$name = str_replace("\x00", "", $nameUtf16);
|
||||
$type = $this->_readInt1($fh);
|
||||
switch ($type) {
|
||||
case OLE_PPS_TYPE_ROOT:
|
||||
require_once 'OLE/PPS/Root.php';
|
||||
$pps = new OLE_PPS_Root(null, null, array());
|
||||
$this->root = $pps;
|
||||
break;
|
||||
case OLE_PPS_TYPE_DIR:
|
||||
$pps = new OLE_PPS(null, null, null, null, null,
|
||||
null, null, null, null, array());
|
||||
break;
|
||||
case OLE_PPS_TYPE_FILE:
|
||||
require_once 'OLE/PPS/File.php';
|
||||
$pps = new OLE_PPS_File($name);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
fseek($fh, 1, SEEK_CUR);
|
||||
$pps->Type = $type;
|
||||
$pps->Name = $name;
|
||||
$pps->PrevPps = $this->_readInt4($fh);
|
||||
$pps->NextPps = $this->_readInt4($fh);
|
||||
$pps->DirPps = $this->_readInt4($fh);
|
||||
fseek($fh, 20, SEEK_CUR);
|
||||
$pps->Time1st = OLE::OLE2LocalDate(fread($fh, 8));
|
||||
$pps->Time2nd = OLE::OLE2LocalDate(fread($fh, 8));
|
||||
$pps->_StartBlock = $this->_readInt4($fh);
|
||||
$pps->Size = $this->_readInt4($fh);
|
||||
$pps->No = count($this->_list);
|
||||
$this->_list[] = $pps;
|
||||
|
||||
// check if the PPS tree (starting from root) is complete
|
||||
if (isset($this->root) &&
|
||||
$this->_ppsTreeComplete($this->root->No)) {
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose($fh);
|
||||
|
||||
// Initialize $pps->children on directories
|
||||
foreach ($this->_list as $pps) {
|
||||
if ($pps->Type == OLE_PPS_TYPE_DIR || $pps->Type == OLE_PPS_TYPE_ROOT) {
|
||||
$nos = array($pps->DirPps);
|
||||
$pps->children = array();
|
||||
while ($nos) {
|
||||
$no = array_pop($nos);
|
||||
if ($no != -1) {
|
||||
$childPps = $this->_list[$no];
|
||||
$nos[] = $childPps->PrevPps;
|
||||
$nos[] = $childPps->NextPps;
|
||||
$pps->children[] = $childPps;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* It checks whether the PPS tree is complete (all PPS's read)
|
||||
* starting with the given PPS (not necessarily root)
|
||||
*
|
||||
* @access private
|
||||
* @param integer $index The index of the PPS from which we are checking
|
||||
* @return boolean Whether the PPS tree for the given PPS is complete
|
||||
*/
|
||||
function _ppsTreeComplete($index)
|
||||
{
|
||||
return isset($this->_list[$index]) &&
|
||||
($pps = $this->_list[$index]) &&
|
||||
($pps->PrevPps == -1 ||
|
||||
$this->_ppsTreeComplete($pps->PrevPps)) &&
|
||||
($pps->NextPps == -1 ||
|
||||
$this->_ppsTreeComplete($pps->NextPps)) &&
|
||||
($pps->DirPps == -1 ||
|
||||
$this->_ppsTreeComplete($pps->DirPps));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a PPS is a File PPS or not.
|
||||
* If there is no PPS for the index given, it will return false.
|
||||
* @param integer $index The index for the PPS
|
||||
* @return bool true if it's a File PPS, false otherwise
|
||||
* @access public
|
||||
*/
|
||||
function isFile($index)
|
||||
{
|
||||
if (isset($this->_list[$index])) {
|
||||
return ($this->_list[$index]->Type == OLE_PPS_TYPE_FILE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a PPS is a Root PPS or not.
|
||||
* If there is no PPS for the index given, it will return false.
|
||||
* @param integer $index The index for the PPS.
|
||||
* @return bool true if it's a Root PPS, false otherwise
|
||||
* @access public
|
||||
*/
|
||||
function isRoot($index)
|
||||
{
|
||||
if (isset($this->_list[$index])) {
|
||||
return ($this->_list[$index]->Type == OLE_PPS_TYPE_ROOT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the total number of PPS's found in the OLE container.
|
||||
* @return integer The total number of PPS's found in the OLE container
|
||||
* @access public
|
||||
*/
|
||||
function ppsTotal()
|
||||
{
|
||||
return count($this->_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets data from a PPS
|
||||
* If there is no PPS for the index given, it will return an empty string.
|
||||
* @param integer $index The index for the PPS
|
||||
* @param integer $position The position from which to start reading
|
||||
* (relative to the PPS)
|
||||
* @param integer $length The amount of bytes to read (at most)
|
||||
* @return string The binary string containing the data requested
|
||||
* @access public
|
||||
* @see OLE_PPS_File::getStream()
|
||||
*/
|
||||
function getData($index, $position, $length)
|
||||
{
|
||||
// if position is not valid return empty string
|
||||
if (!isset($this->_list[$index]) ||
|
||||
$position >= $this->_list[$index]->Size ||
|
||||
$position < 0) {
|
||||
|
||||
return '';
|
||||
}
|
||||
$fh = $this->getStream($this->_list[$index]);
|
||||
$data = stream_get_contents($fh, $length, $position);
|
||||
fclose($fh);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data length from a PPS
|
||||
* If there is no PPS for the index given, it will return 0.
|
||||
* @param integer $index The index for the PPS
|
||||
* @return integer The amount of bytes in data the PPS has
|
||||
* @access public
|
||||
*/
|
||||
function getDataLength($index)
|
||||
{
|
||||
if (isset($this->_list[$index])) {
|
||||
return $this->_list[$index]->Size;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to transform ASCII text to Unicode
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param string $ascii The ASCII string to transform
|
||||
* @return string The string in Unicode
|
||||
*/
|
||||
static function Asc2Ucs($ascii)
|
||||
{
|
||||
$rawname = '';
|
||||
for ($i = 0; $i < strlen($ascii); $i++) {
|
||||
$rawname .= $ascii{$i} . "\x00";
|
||||
}
|
||||
return $rawname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function
|
||||
* Returns a string for the OLE container with the date given
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
* @param integer $date A timestamp
|
||||
* @return string The string for the OLE container
|
||||
*/
|
||||
static function LocalDate2OLE($date = null)
|
||||
{
|
||||
if (!isset($date)) {
|
||||
return "\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
}
|
||||
|
||||
// factor used for separating numbers into 4 bytes parts
|
||||
$factor = pow(2, 32);
|
||||
|
||||
// days from 1-1-1601 until the beggining of UNIX era
|
||||
$days = 134774;
|
||||
// calculate seconds
|
||||
$big_date = $days * 24 * 3600 +
|
||||
gmmktime(date("H",$date),date("i",$date),date("s",$date),
|
||||
date("m",$date),date("d",$date),date("Y",$date));
|
||||
// multiply just to make MS happy
|
||||
$big_date *= 10000000;
|
||||
|
||||
$high_part = floor($big_date / $factor);
|
||||
// lower 4 bytes
|
||||
$low_part = floor((($big_date / $factor) - $high_part) * $factor);
|
||||
|
||||
// Make HEX string
|
||||
$res = '';
|
||||
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$hex = $low_part % 0x100;
|
||||
$res .= pack('c', $hex);
|
||||
$low_part /= 0x100;
|
||||
}
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
$hex = $high_part % 0x100;
|
||||
$res .= pack('c', $hex);
|
||||
$high_part /= 0x100;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a timestamp from an OLE container's date
|
||||
* @param integer $string A binary string with the encoded date
|
||||
* @return string The timestamp corresponding to the string
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static function OLE2LocalDate($string)
|
||||
{
|
||||
if (strlen($string) != 8) {
|
||||
return new PEAR_Error("Expecting 8 byte string");
|
||||
}
|
||||
|
||||
// factor used for separating numbers into 4 bytes parts
|
||||
$factor = pow(2,32);
|
||||
$high_part = 0;
|
||||
for ($i = 0; $i < 4; $i++) {
|
||||
list(, $high_part) = unpack('C', $string{(7 - $i)});
|
||||
if ($i < 3) {
|
||||
$high_part *= 0x100;
|
||||
}
|
||||
}
|
||||
$low_part = 0;
|
||||
for ($i = 4; $i < 8; $i++) {
|
||||
list(, $low_part) = unpack('C', $string{(7 - $i)});
|
||||
if ($i < 7) {
|
||||
$low_part *= 0x100;
|
||||
}
|
||||
}
|
||||
$big_date = ($high_part * $factor) + $low_part;
|
||||
// translate to seconds
|
||||
$big_date /= 10000000;
|
||||
|
||||
// days from 1-1-1601 until the beggining of UNIX era
|
||||
$days = 134774;
|
||||
|
||||
// translate to seconds from beggining of UNIX era
|
||||
$big_date -= $days * 24 * 3600;
|
||||
return floor($big_date);
|
||||
}
|
||||
}
|
||||
?>
|
||||
224
vendor/library/Excel/phpxls/OLE/PPS.php
vendored
Normal file
224
vendor/library/Excel/phpxls/OLE/PPS.php
vendored
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2002 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Xavier Noguer <xnoguer@php.net> |
|
||||
// | Based on OLE::Storage_Lite by Kawai, Takanori |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: PPS.php,v 1.7 2007/02/13 21:00:42 schmidt Exp $
|
||||
|
||||
|
||||
require_once 'PEAR.php';
|
||||
require_once 'OLE.php';
|
||||
|
||||
/**
|
||||
* Class for creating PPS's for OLE containers
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
class OLE_PPS extends PEAR
|
||||
{
|
||||
/**
|
||||
* The PPS index
|
||||
* @var integer
|
||||
*/
|
||||
var $No;
|
||||
|
||||
/**
|
||||
* The PPS name (in Unicode)
|
||||
* @var string
|
||||
*/
|
||||
var $Name;
|
||||
|
||||
/**
|
||||
* The PPS type. Dir, Root or File
|
||||
* @var integer
|
||||
*/
|
||||
var $Type;
|
||||
|
||||
/**
|
||||
* The index of the previous PPS
|
||||
* @var integer
|
||||
*/
|
||||
var $PrevPps;
|
||||
|
||||
/**
|
||||
* The index of the next PPS
|
||||
* @var integer
|
||||
*/
|
||||
var $NextPps;
|
||||
|
||||
/**
|
||||
* The index of it's first child if this is a Dir or Root PPS
|
||||
* @var integer
|
||||
*/
|
||||
var $DirPps;
|
||||
|
||||
/**
|
||||
* A timestamp
|
||||
* @var integer
|
||||
*/
|
||||
var $Time1st;
|
||||
|
||||
/**
|
||||
* A timestamp
|
||||
* @var integer
|
||||
*/
|
||||
var $Time2nd;
|
||||
|
||||
/**
|
||||
* Starting block (small or big) for this PPS's data inside the container
|
||||
* @var integer
|
||||
*/
|
||||
var $_StartBlock;
|
||||
|
||||
/**
|
||||
* The size of the PPS's data (in bytes)
|
||||
* @var integer
|
||||
*/
|
||||
var $Size;
|
||||
|
||||
/**
|
||||
* The PPS's data (only used if it's not using a temporary file)
|
||||
* @var string
|
||||
*/
|
||||
var $_data;
|
||||
|
||||
/**
|
||||
* Array of child PPS's (only used by Root and Dir PPS's)
|
||||
* @var array
|
||||
*/
|
||||
var $children = array();
|
||||
|
||||
/**
|
||||
* Pointer to OLE container
|
||||
* @var OLE
|
||||
*/
|
||||
var $ole;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*
|
||||
* @access public
|
||||
* @param integer $No The PPS index
|
||||
* @param string $name The PPS name
|
||||
* @param integer $type The PPS type. Dir, Root or File
|
||||
* @param integer $prev The index of the previous PPS
|
||||
* @param integer $next The index of the next PPS
|
||||
* @param integer $dir The index of it's first child if this is a Dir or Root PPS
|
||||
* @param integer $time_1st A timestamp
|
||||
* @param integer $time_2nd A timestamp
|
||||
* @param string $data The (usually binary) source data of the PPS
|
||||
* @param array $children Array containing children PPS for this PPS
|
||||
*/
|
||||
function __construct(){}
|
||||
|
||||
function OLE_PPS($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children)
|
||||
{
|
||||
$this->No = $No;
|
||||
$this->Name = $name;
|
||||
$this->Type = $type;
|
||||
$this->PrevPps = $prev;
|
||||
$this->NextPps = $next;
|
||||
$this->DirPps = $dir;
|
||||
$this->Time1st = $time_1st;
|
||||
$this->Time2nd = $time_2nd;
|
||||
$this->_data = $data;
|
||||
$this->children = $children;
|
||||
if ($data != '') {
|
||||
$this->Size = strlen($data);
|
||||
} else {
|
||||
$this->Size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of data saved for this PPS
|
||||
*
|
||||
* @access private
|
||||
* @return integer The amount of data (in bytes)
|
||||
*/
|
||||
function _DataLen()
|
||||
{
|
||||
if (!isset($this->_data)) {
|
||||
return 0;
|
||||
}
|
||||
if (isset($this->_PPS_FILE)) {
|
||||
fseek($this->_PPS_FILE, 0);
|
||||
$stats = fstat($this->_PPS_FILE);
|
||||
return $stats[7];
|
||||
} else {
|
||||
return strlen($this->_data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string with the PPS's WK (What is a WK?)
|
||||
*
|
||||
* @access private
|
||||
* @return string The binary string
|
||||
*/
|
||||
function _getPpsWk()
|
||||
{
|
||||
$ret = $this->Name;
|
||||
for ($i = 0; $i < (64 - strlen($this->Name)); $i++) {
|
||||
$ret .= "\x00";
|
||||
}
|
||||
$ret .= pack("v", strlen($this->Name) + 2) // 66
|
||||
. pack("c", $this->Type) // 67
|
||||
. pack("c", 0x00) //UK // 68
|
||||
. pack("V", $this->PrevPps) //Prev // 72
|
||||
. pack("V", $this->NextPps) //Next // 76
|
||||
. pack("V", $this->DirPps) //Dir // 80
|
||||
. "\x00\x09\x02\x00" // 84
|
||||
. "\x00\x00\x00\x00" // 88
|
||||
. "\xc0\x00\x00\x00" // 92
|
||||
. "\x00\x00\x00\x46" // 96 // Seems to be ok only for Root
|
||||
. "\x00\x00\x00\x00" // 100
|
||||
. OLE::LocalDate2OLE($this->Time1st) // 108
|
||||
. OLE::LocalDate2OLE($this->Time2nd) // 116
|
||||
. pack("V", isset($this->_StartBlock)?
|
||||
$this->_StartBlock:0) // 120
|
||||
. pack("V", $this->Size) // 124
|
||||
. pack("V", 0); // 128
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates index and pointers to previous, next and children PPS's for this
|
||||
* PPS. I don't think it'll work with Dir PPS's.
|
||||
*
|
||||
* @access private
|
||||
* @param array &$pps_array Reference to the array of PPS's for the whole OLE
|
||||
* container
|
||||
* @return integer The index for this PPS
|
||||
*/
|
||||
function _savePpsSetPnt(&$pps_array)
|
||||
{
|
||||
$pps_array[count($pps_array)] = &$this;
|
||||
$this->No = count($pps_array) - 1;
|
||||
$this->PrevPps = 0xFFFFFFFF;
|
||||
$this->NextPps = 0xFFFFFFFF;
|
||||
if (count($this->children) > 0) {
|
||||
$this->DirPps = $this->children[0]->_savePpsSetPnt($pps_array);
|
||||
} else {
|
||||
$this->DirPps = 0xFFFFFFFF;
|
||||
}
|
||||
return $this->No;
|
||||
}
|
||||
}
|
||||
?>
|
||||
125
vendor/library/Excel/phpxls/OLE/PPS/File.php
vendored
Normal file
125
vendor/library/Excel/phpxls/OLE/PPS/File.php
vendored
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2002 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Xavier Noguer <xnoguer@php.net> |
|
||||
// | Based on OLE::Storage_Lite by Kawai, Takanori |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: File.php,v 1.12 2008/02/02 21:00:37 schmidt Exp $
|
||||
|
||||
|
||||
require_once 'OLE/PPS.php';
|
||||
require_once 'System.php';
|
||||
|
||||
/**
|
||||
* Class for creating File PPS's for OLE containers
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
class OLE_PPS_File extends OLE_PPS
|
||||
{
|
||||
/**
|
||||
* The temporary dir for storing the OLE file
|
||||
* @var string
|
||||
*/
|
||||
var $_tmp_dir;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*
|
||||
* @access public
|
||||
* @param string $name The name of the file (in Unicode)
|
||||
* @see OLE::Asc2Ucs()
|
||||
*/
|
||||
function __construct($name)
|
||||
{
|
||||
$this->_tmp_dir = System::tmpdir();
|
||||
$this->OLE_PPS(
|
||||
null,
|
||||
$name,
|
||||
OLE_PPS_TYPE_FILE,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'',
|
||||
array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the temp dir used for storing the OLE file
|
||||
*
|
||||
* @access public
|
||||
* @param string $dir The dir to be used as temp dir
|
||||
* @return true if given dir is valid, false otherwise
|
||||
*/
|
||||
function setTempDir($dir)
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$this->_tmp_dir = $dir;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization method. Has to be called right after OLE_PPS_File().
|
||||
*
|
||||
* @access public
|
||||
* @return mixed true on success. PEAR_Error on failure
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_File");
|
||||
$fh = @fopen($this->_tmp_filename, "w+b");
|
||||
if ($fh == false) {
|
||||
return $this->raiseError("Can't create temporary file");
|
||||
}
|
||||
$this->_PPS_FILE = $fh;
|
||||
if ($this->_PPS_FILE) {
|
||||
fseek($this->_PPS_FILE, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append data to PPS
|
||||
*
|
||||
* @access public
|
||||
* @param string $data The data to append
|
||||
*/
|
||||
function append($data)
|
||||
{
|
||||
if ($this->_PPS_FILE) {
|
||||
fwrite($this->_PPS_FILE, $data);
|
||||
} else {
|
||||
$this->_data .= $data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stream for reading this file using fread() etc.
|
||||
* @return resource a read-only stream
|
||||
*/
|
||||
function getStream()
|
||||
{
|
||||
$this->ole->getStream($this);
|
||||
}
|
||||
}
|
||||
?>
|
||||
486
vendor/library/Excel/phpxls/OLE/PPS/Root.php
vendored
Normal file
486
vendor/library/Excel/phpxls/OLE/PPS/Root.php
vendored
Normal file
|
|
@ -0,0 +1,486 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2002 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Xavier Noguer <xnoguer@php.net> |
|
||||
// | Based on OLE::Storage_Lite by Kawai, Takanori |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: Root.php,v 1.10 2008/02/02 21:00:37 schmidt Exp $
|
||||
|
||||
|
||||
require_once 'OLE/PPS.php';
|
||||
require_once 'System.php';
|
||||
|
||||
/**
|
||||
* Class for creating Root PPS's for OLE containers
|
||||
*
|
||||
* @author Xavier Noguer <xnoguer@php.net>
|
||||
* @category Structures
|
||||
* @package OLE
|
||||
*/
|
||||
class OLE_PPS_Root extends OLE_PPS
|
||||
{
|
||||
/**
|
||||
* The temporary dir for storing the OLE file
|
||||
* @var string
|
||||
*/
|
||||
var $_tmp_dir;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param integer $time_1st A timestamp
|
||||
* @param integer $time_2nd A timestamp
|
||||
*/
|
||||
function __construct($time_1st, $time_2nd, $raChild)
|
||||
{
|
||||
$this->_tmp_dir = System::tmpdir();
|
||||
$this->OLE_PPS(
|
||||
null,
|
||||
OLE::Asc2Ucs('Root Entry'),
|
||||
OLE_PPS_TYPE_ROOT,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$time_1st,
|
||||
$time_2nd,
|
||||
null,
|
||||
$raChild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the temp dir used for storing the OLE file
|
||||
*
|
||||
* @access public
|
||||
* @param string $dir The dir to be used as temp dir
|
||||
* @return true if given dir is valid, false otherwise
|
||||
*/
|
||||
function setTempDir($dir)
|
||||
{
|
||||
if (is_dir($dir)) {
|
||||
$this->_tmp_dir = $dir;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for saving the whole OLE container (including files).
|
||||
* In fact, if called with an empty argument (or '-'), it saves to a
|
||||
* temporary file and then outputs it's contents to stdout.
|
||||
*
|
||||
* @param string $filename The name of the file where to save the OLE container
|
||||
* @access public
|
||||
* @return mixed true on success, PEAR_Error on failure
|
||||
*/
|
||||
function save($filename)
|
||||
{
|
||||
// Initial Setting for saving
|
||||
$this->_BIG_BLOCK_SIZE = pow(2,
|
||||
((isset($this->_BIG_BLOCK_SIZE))? $this->_adjust2($this->_BIG_BLOCK_SIZE) : 9));
|
||||
$this->_SMALL_BLOCK_SIZE= pow(2,
|
||||
((isset($this->_SMALL_BLOCK_SIZE))? $this->_adjust2($this->_SMALL_BLOCK_SIZE): 6));
|
||||
|
||||
// Open temp file if we are sending output to stdout
|
||||
if (($filename == '-') || ($filename == '')) {
|
||||
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
|
||||
$this->_FILEH_ = @fopen($this->_tmp_filename,"w+b");
|
||||
if ($this->_FILEH_ == false) {
|
||||
return $this->raiseError("Can't create temporary file.");
|
||||
}
|
||||
} else {
|
||||
$this->_FILEH_ = @fopen($filename, "wb");
|
||||
if ($this->_FILEH_ == false) {
|
||||
return $this->raiseError("Can't open $filename. It may be in use or protected.");
|
||||
}
|
||||
}
|
||||
// Make an array of PPS's (for Save)
|
||||
$aList = array();
|
||||
$this->_savePpsSetPnt($aList);
|
||||
// calculate values for header
|
||||
list($iSBDcnt, $iBBcnt, $iPPScnt) = $this->_calcSize($aList); //, $rhInfo);
|
||||
// Save Header
|
||||
$this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt);
|
||||
|
||||
// Make Small Data string (write SBD)
|
||||
$this->_data = $this->_makeSmallData($aList);
|
||||
|
||||
// Write BB
|
||||
$this->_saveBigData($iSBDcnt, $aList);
|
||||
// Write PPS
|
||||
$this->_savePps($aList);
|
||||
// Write Big Block Depot and BDList and Adding Header informations
|
||||
$this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt);
|
||||
// Close File, send it to stdout if necessary
|
||||
if (($filename == '-') || ($filename == '')) {
|
||||
fseek($this->_FILEH_, 0);
|
||||
fpassthru($this->_FILEH_);
|
||||
@fclose($this->_FILEH_);
|
||||
// Delete the temporary file.
|
||||
@unlink($this->_tmp_filename);
|
||||
} else {
|
||||
@fclose($this->_FILEH_);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate some numbers
|
||||
*
|
||||
* @access private
|
||||
* @param array $raList Reference to an array of PPS's
|
||||
* @return array The array of numbers
|
||||
*/
|
||||
function _calcSize(&$raList)
|
||||
{
|
||||
// Calculate Basic Setting
|
||||
list($iSBDcnt, $iBBcnt, $iPPScnt) = array(0,0,0);
|
||||
$iSmallLen = 0;
|
||||
$iSBcnt = 0;
|
||||
for ($i = 0; $i < count($raList); $i++) {
|
||||
if ($raList[$i]->Type == OLE_PPS_TYPE_FILE) {
|
||||
$raList[$i]->Size = $raList[$i]->_DataLen();
|
||||
if ($raList[$i]->Size < OLE_DATA_SIZE_SMALL) {
|
||||
$iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
|
||||
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
|
||||
} else {
|
||||
$iBBcnt += (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
|
||||
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
$iSmallLen = $iSBcnt * $this->_SMALL_BLOCK_SIZE;
|
||||
$iSlCnt = floor($this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE);
|
||||
$iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt)? 1:0);
|
||||
$iBBcnt += (floor($iSmallLen / $this->_BIG_BLOCK_SIZE) +
|
||||
(( $iSmallLen % $this->_BIG_BLOCK_SIZE)? 1: 0));
|
||||
$iCnt = count($raList);
|
||||
$iBdCnt = $this->_BIG_BLOCK_SIZE / OLE_PPS_SIZE;
|
||||
$iPPScnt = (floor($iCnt/$iBdCnt) + (($iCnt % $iBdCnt)? 1: 0));
|
||||
|
||||
return array($iSBDcnt, $iBBcnt, $iPPScnt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for caculating a magic value for block sizes
|
||||
*
|
||||
* @access private
|
||||
* @param integer $i2 The argument
|
||||
* @see save()
|
||||
* @return integer
|
||||
*/
|
||||
function _adjust2($i2)
|
||||
{
|
||||
$iWk = log($i2)/log(2);
|
||||
return ($iWk > floor($iWk))? floor($iWk)+1:$iWk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save OLE header
|
||||
*
|
||||
* @access private
|
||||
* @param integer $iSBDcnt
|
||||
* @param integer $iBBcnt
|
||||
* @param integer $iPPScnt
|
||||
*/
|
||||
function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt)
|
||||
{
|
||||
$FILE = $this->_FILEH_;
|
||||
|
||||
// Calculate Basic Setting
|
||||
$iBlCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE;
|
||||
$i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE;
|
||||
|
||||
$iBdExL = 0;
|
||||
$iAll = $iBBcnt + $iPPScnt + $iSBDcnt;
|
||||
$iAllW = $iAll;
|
||||
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0);
|
||||
$iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0);
|
||||
|
||||
// Calculate BD count
|
||||
if ($iBdCnt > $i1stBdL) {
|
||||
while (1) {
|
||||
$iBdExL++;
|
||||
$iAllW++;
|
||||
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0);
|
||||
$iBdCnt = floor(($iAllW + $iBdCntW) / $iBlCnt) + ((($iAllW+$iBdCntW) % $iBlCnt)? 1: 0);
|
||||
if ($iBdCnt <= ($iBdExL*$iBlCnt+ $i1stBdL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save Header
|
||||
fwrite($FILE,
|
||||
"\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1"
|
||||
. "\x00\x00\x00\x00"
|
||||
. "\x00\x00\x00\x00"
|
||||
. "\x00\x00\x00\x00"
|
||||
. "\x00\x00\x00\x00"
|
||||
. pack("v", 0x3b)
|
||||
. pack("v", 0x03)
|
||||
. pack("v", -2)
|
||||
. pack("v", 9)
|
||||
. pack("v", 6)
|
||||
. pack("v", 0)
|
||||
. "\x00\x00\x00\x00"
|
||||
. "\x00\x00\x00\x00"
|
||||
. pack("V", $iBdCnt)
|
||||
. pack("V", $iBBcnt+$iSBDcnt) //ROOT START
|
||||
. pack("V", 0)
|
||||
. pack("V", 0x1000)
|
||||
. pack("V", 0) //Small Block Depot
|
||||
. pack("V", 1)
|
||||
);
|
||||
// Extra BDList Start, Count
|
||||
if ($iBdCnt < $i1stBdL) {
|
||||
fwrite($FILE,
|
||||
pack("V", -2). // Extra BDList Start
|
||||
pack("V", 0) // Extra BDList Count
|
||||
);
|
||||
} else {
|
||||
fwrite($FILE, pack("V", $iAll+$iBdCnt) . pack("V", $iBdExL));
|
||||
}
|
||||
|
||||
// BDList
|
||||
for ($i = 0; $i < $i1stBdL && $i < $iBdCnt; $i++) {
|
||||
fwrite($FILE, pack("V", $iAll+$i));
|
||||
}
|
||||
if ($i < $i1stBdL) {
|
||||
for ($j = 0; $j < ($i1stBdL-$i); $j++) {
|
||||
fwrite($FILE, (pack("V", -1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saving big data (PPS's with data bigger than OLE_DATA_SIZE_SMALL)
|
||||
*
|
||||
* @access private
|
||||
* @param integer $iStBlk
|
||||
* @param array &$raList Reference to array of PPS's
|
||||
*/
|
||||
function _saveBigData($iStBlk, &$raList)
|
||||
{
|
||||
$FILE = $this->_FILEH_;
|
||||
|
||||
// cycle through PPS's
|
||||
for ($i = 0; $i < count($raList); $i++) {
|
||||
if ($raList[$i]->Type != OLE_PPS_TYPE_DIR) {
|
||||
$raList[$i]->Size = $raList[$i]->_DataLen();
|
||||
if (($raList[$i]->Size >= OLE_DATA_SIZE_SMALL) ||
|
||||
(($raList[$i]->Type == OLE_PPS_TYPE_ROOT) && isset($raList[$i]->_data)))
|
||||
{
|
||||
// Write Data
|
||||
if (isset($raList[$i]->_PPS_FILE)) {
|
||||
$iLen = 0;
|
||||
fseek($raList[$i]->_PPS_FILE, 0); // To The Top
|
||||
while($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
|
||||
$iLen += strlen($sBuff);
|
||||
fwrite($FILE, $sBuff);
|
||||
}
|
||||
} else {
|
||||
fwrite($FILE, $raList[$i]->_data);
|
||||
}
|
||||
|
||||
if ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE) {
|
||||
for ($j = 0; $j < ($this->_BIG_BLOCK_SIZE - ($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)); $j++) {
|
||||
fwrite($FILE, "\x00");
|
||||
}
|
||||
}
|
||||
// Set For PPS
|
||||
$raList[$i]->_StartBlock = $iStBlk;
|
||||
$iStBlk +=
|
||||
(floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
|
||||
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0));
|
||||
}
|
||||
// Close file for each PPS, and unlink it
|
||||
if (isset($raList[$i]->_PPS_FILE)) {
|
||||
@fclose($raList[$i]->_PPS_FILE);
|
||||
$raList[$i]->_PPS_FILE = null;
|
||||
@unlink($raList[$i]->_tmp_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get small data (PPS's with data smaller than OLE_DATA_SIZE_SMALL)
|
||||
*
|
||||
* @access private
|
||||
* @param array &$raList Reference to array of PPS's
|
||||
*/
|
||||
function _makeSmallData(&$raList)
|
||||
{
|
||||
$sRes = '';
|
||||
$FILE = $this->_FILEH_;
|
||||
$iSmBlk = 0;
|
||||
|
||||
for ($i = 0; $i < count($raList); $i++) {
|
||||
// Make SBD, small data string
|
||||
if ($raList[$i]->Type == OLE_PPS_TYPE_FILE) {
|
||||
if ($raList[$i]->Size <= 0) {
|
||||
continue;
|
||||
}
|
||||
if ($raList[$i]->Size < OLE_DATA_SIZE_SMALL) {
|
||||
$iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
|
||||
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0);
|
||||
// Add to SBD
|
||||
for ($j = 0; $j < ($iSmbCnt-1); $j++) {
|
||||
fwrite($FILE, pack("V", $j+$iSmBlk+1));
|
||||
}
|
||||
fwrite($FILE, pack("V", -2));
|
||||
|
||||
// Add to Data String(this will be written for RootEntry)
|
||||
if ($raList[$i]->_PPS_FILE) {
|
||||
fseek($raList[$i]->_PPS_FILE, 0); // To The Top
|
||||
while ($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
|
||||
$sRes .= $sBuff;
|
||||
}
|
||||
} else {
|
||||
$sRes .= $raList[$i]->_data;
|
||||
}
|
||||
if ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) {
|
||||
for ($j = 0; $j < ($this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)); $j++) {
|
||||
$sRes .= "\x00";
|
||||
}
|
||||
}
|
||||
// Set for PPS
|
||||
$raList[$i]->_StartBlock = $iSmBlk;
|
||||
$iSmBlk += $iSmbCnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
$iSbCnt = floor($this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE);
|
||||
if ($iSmBlk % $iSbCnt) {
|
||||
for ($i = 0; $i < ($iSbCnt - ($iSmBlk % $iSbCnt)); $i++) {
|
||||
fwrite($FILE, pack("V", -1));
|
||||
}
|
||||
}
|
||||
return $sRes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves all the PPS's WKs
|
||||
*
|
||||
* @access private
|
||||
* @param array $raList Reference to an array with all PPS's
|
||||
*/
|
||||
function _savePps(&$raList)
|
||||
{
|
||||
// Save each PPS WK
|
||||
for ($i = 0; $i < count($raList); $i++) {
|
||||
fwrite($this->_FILEH_, $raList[$i]->_getPpsWk());
|
||||
}
|
||||
// Adjust for Block
|
||||
$iCnt = count($raList);
|
||||
$iBCnt = $this->_BIG_BLOCK_SIZE / OLE_PPS_SIZE;
|
||||
if ($iCnt % $iBCnt) {
|
||||
for ($i = 0; $i < (($iBCnt - ($iCnt % $iBCnt)) * OLE_PPS_SIZE); $i++) {
|
||||
fwrite($this->_FILEH_, "\x00");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saving Big Block Depot
|
||||
*
|
||||
* @access private
|
||||
* @param integer $iSbdSize
|
||||
* @param integer $iBsize
|
||||
* @param integer $iPpsCnt
|
||||
*/
|
||||
function _saveBbd($iSbdSize, $iBsize, $iPpsCnt)
|
||||
{
|
||||
$FILE = $this->_FILEH_;
|
||||
// Calculate Basic Setting
|
||||
$iBbCnt = $this->_BIG_BLOCK_SIZE / OLE_LONG_INT_SIZE;
|
||||
$i1stBdL = ($this->_BIG_BLOCK_SIZE - 0x4C) / OLE_LONG_INT_SIZE;
|
||||
|
||||
$iBdExL = 0;
|
||||
$iAll = $iBsize + $iPpsCnt + $iSbdSize;
|
||||
$iAllW = $iAll;
|
||||
$iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0);
|
||||
$iBdCnt = floor(($iAll + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0);
|
||||
// Calculate BD count
|
||||
if ($iBdCnt >$i1stBdL) {
|
||||
while (1) {
|
||||
$iBdExL++;
|
||||
$iAllW++;
|
||||
$iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0);
|
||||
$iBdCnt = floor(($iAllW + $iBdCntW) / $iBbCnt) + ((($iAllW+$iBdCntW) % $iBbCnt)? 1: 0);
|
||||
if ($iBdCnt <= ($iBdExL*$iBbCnt+ $i1stBdL)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Making BD
|
||||
// Set for SBD
|
||||
if ($iSbdSize > 0) {
|
||||
for ($i = 0; $i < ($iSbdSize - 1); $i++) {
|
||||
fwrite($FILE, pack("V", $i+1));
|
||||
}
|
||||
fwrite($FILE, pack("V", -2));
|
||||
}
|
||||
// Set for B
|
||||
for ($i = 0; $i < ($iBsize - 1); $i++) {
|
||||
fwrite($FILE, pack("V", $i+$iSbdSize+1));
|
||||
}
|
||||
fwrite($FILE, pack("V", -2));
|
||||
|
||||
// Set for PPS
|
||||
for ($i = 0; $i < ($iPpsCnt - 1); $i++) {
|
||||
fwrite($FILE, pack("V", $i+$iSbdSize+$iBsize+1));
|
||||
}
|
||||
fwrite($FILE, pack("V", -2));
|
||||
// Set for BBD itself ( 0xFFFFFFFD : BBD)
|
||||
for ($i = 0; $i < $iBdCnt; $i++) {
|
||||
fwrite($FILE, pack("V", 0xFFFFFFFD));
|
||||
}
|
||||
// Set for ExtraBDList
|
||||
for ($i = 0; $i < $iBdExL; $i++) {
|
||||
fwrite($FILE, pack("V", 0xFFFFFFFC));
|
||||
}
|
||||
// Adjust for Block
|
||||
if (($iAllW + $iBdCnt) % $iBbCnt) {
|
||||
for ($i = 0; $i < ($iBbCnt - (($iAllW + $iBdCnt) % $iBbCnt)); $i++) {
|
||||
fwrite($FILE, pack("V", -1));
|
||||
}
|
||||
}
|
||||
// Extra BDList
|
||||
if ($iBdCnt > $i1stBdL) {
|
||||
$iN=0;
|
||||
$iNb=0;
|
||||
for ($i = $i1stBdL;$i < $iBdCnt; $i++, $iN++) {
|
||||
if ($iN >= ($iBbCnt - 1)) {
|
||||
$iN = 0;
|
||||
$iNb++;
|
||||
fwrite($FILE, pack("V", $iAll+$iBdCnt+$iNb));
|
||||
}
|
||||
fwrite($FILE, pack("V", $iBsize+$iSbdSize+$iPpsCnt+$i));
|
||||
}
|
||||
if (($iBdCnt-$i1stBdL) % ($iBbCnt-1)) {
|
||||
for ($i = 0; $i < (($iBbCnt - 1) - (($iBdCnt - $i1stBdL) % ($iBbCnt - 1))); $i++) {
|
||||
fwrite($FILE, pack("V", -1));
|
||||
}
|
||||
}
|
||||
fwrite($FILE, pack("V", -2));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
344
vendor/library/Excel/phpxls/OS/Guess.php
vendored
Normal file
344
vendor/library/Excel/phpxls/OS/Guess.php
vendored
Normal file
|
|
@ -0,0 +1,344 @@
|
|||
<?php
|
||||
/**
|
||||
* The OS_Guess class
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Guess.php,v 1.26 2008/01/03 20:26:34 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since PEAR 0.1
|
||||
*/
|
||||
|
||||
// {{{ uname examples
|
||||
|
||||
// php_uname() without args returns the same as 'uname -a', or a PHP-custom
|
||||
// string for Windows.
|
||||
// PHP versions prior to 4.3 return the uname of the host where PHP was built,
|
||||
// as of 4.3 it returns the uname of the host running the PHP code.
|
||||
//
|
||||
// PC RedHat Linux 7.1:
|
||||
// Linux host.example.com 2.4.2-2 #1 Sun Apr 8 20:41:30 EDT 2001 i686 unknown
|
||||
//
|
||||
// PC Debian Potato:
|
||||
// Linux host 2.4.17 #2 SMP Tue Feb 12 15:10:04 CET 2002 i686 unknown
|
||||
//
|
||||
// PC FreeBSD 3.3:
|
||||
// FreeBSD host.example.com 3.3-STABLE FreeBSD 3.3-STABLE #0: Mon Feb 21 00:42:31 CET 2000 root@example.com:/usr/src/sys/compile/CONFIG i386
|
||||
//
|
||||
// PC FreeBSD 4.3:
|
||||
// FreeBSD host.example.com 4.3-RELEASE FreeBSD 4.3-RELEASE #1: Mon Jun 25 11:19:43 EDT 2001 root@example.com:/usr/src/sys/compile/CONFIG i386
|
||||
//
|
||||
// PC FreeBSD 4.5:
|
||||
// FreeBSD host.example.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Feb 6 23:59:23 CET 2002 root@example.com:/usr/src/sys/compile/CONFIG i386
|
||||
//
|
||||
// PC FreeBSD 4.5 w/uname from GNU shellutils:
|
||||
// FreeBSD host.example.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Wed Feb i386 unknown
|
||||
//
|
||||
// HP 9000/712 HP-UX 10:
|
||||
// HP-UX iq B.10.10 A 9000/712 2008429113 two-user license
|
||||
//
|
||||
// HP 9000/712 HP-UX 10 w/uname from GNU shellutils:
|
||||
// HP-UX host B.10.10 A 9000/712 unknown
|
||||
//
|
||||
// IBM RS6000/550 AIX 4.3:
|
||||
// AIX host 3 4 000003531C00
|
||||
//
|
||||
// AIX 4.3 w/uname from GNU shellutils:
|
||||
// AIX host 3 4 000003531C00 unknown
|
||||
//
|
||||
// SGI Onyx IRIX 6.5 w/uname from GNU shellutils:
|
||||
// IRIX64 host 6.5 01091820 IP19 mips
|
||||
//
|
||||
// SGI Onyx IRIX 6.5:
|
||||
// IRIX64 host 6.5 01091820 IP19
|
||||
//
|
||||
// SparcStation 20 Solaris 8 w/uname from GNU shellutils:
|
||||
// SunOS host.example.com 5.8 Generic_108528-12 sun4m sparc
|
||||
//
|
||||
// SparcStation 20 Solaris 8:
|
||||
// SunOS host.example.com 5.8 Generic_108528-12 sun4m sparc SUNW,SPARCstation-20
|
||||
//
|
||||
// Mac OS X (Darwin)
|
||||
// Darwin home-eden.local 7.5.0 Darwin Kernel Version 7.5.0: Thu Aug 5 19:26:16 PDT 2004; root:xnu/xnu-517.7.21.obj~3/RELEASE_PPC Power Macintosh
|
||||
//
|
||||
// Mac OS X early versions
|
||||
//
|
||||
|
||||
// }}}
|
||||
|
||||
/* TODO:
|
||||
* - define endianness, to allow matchSignature("bigend") etc.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Retrieves information about the current operating system
|
||||
*
|
||||
* This class uses php_uname() to grok information about the current OS
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Gregory Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
class OS_Guess
|
||||
{
|
||||
var $sysname;
|
||||
var $nodename;
|
||||
var $cpu;
|
||||
var $release;
|
||||
var $extra;
|
||||
|
||||
function OS_Guess($uname = null)
|
||||
{
|
||||
list($this->sysname,
|
||||
$this->release,
|
||||
$this->cpu,
|
||||
$this->extra,
|
||||
$this->nodename) = $this->parseSignature($uname);
|
||||
}
|
||||
|
||||
function parseSignature($uname = null)
|
||||
{
|
||||
static $sysmap = array(
|
||||
'HP-UX' => 'hpux',
|
||||
'IRIX64' => 'irix',
|
||||
);
|
||||
static $cpumap = array(
|
||||
'i586' => 'i386',
|
||||
'i686' => 'i386',
|
||||
'ppc' => 'powerpc',
|
||||
);
|
||||
if ($uname === null) {
|
||||
$uname = php_uname();
|
||||
}
|
||||
$parts = split('[[:space:]]+', trim($uname));
|
||||
$n = count($parts);
|
||||
|
||||
$release = $machine = $cpu = '';
|
||||
$sysname = $parts[0];
|
||||
$nodename = $parts[1];
|
||||
$cpu = $parts[$n-1];
|
||||
$extra = '';
|
||||
if ($cpu == 'unknown') {
|
||||
$cpu = $parts[$n-2];
|
||||
}
|
||||
|
||||
switch ($sysname) {
|
||||
case 'AIX' :
|
||||
$release = "$parts[3].$parts[2]";
|
||||
break;
|
||||
case 'Windows' :
|
||||
switch ($parts[1]) {
|
||||
case '95/98':
|
||||
$release = '9x';
|
||||
break;
|
||||
default:
|
||||
$release = $parts[1];
|
||||
break;
|
||||
}
|
||||
$cpu = 'i386';
|
||||
break;
|
||||
case 'Linux' :
|
||||
$extra = $this->_detectGlibcVersion();
|
||||
// use only the first two digits from the kernel version
|
||||
$release = ereg_replace('^([[:digit:]]+\.[[:digit:]]+).*', '\1', $parts[2]);
|
||||
break;
|
||||
case 'Mac' :
|
||||
$sysname = 'darwin';
|
||||
$nodename = $parts[2];
|
||||
$release = $parts[3];
|
||||
if ($cpu == 'Macintosh') {
|
||||
if ($parts[$n - 2] == 'Power') {
|
||||
$cpu = 'powerpc';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'Darwin' :
|
||||
if ($cpu == 'Macintosh') {
|
||||
if ($parts[$n - 2] == 'Power') {
|
||||
$cpu = 'powerpc';
|
||||
}
|
||||
}
|
||||
$release = ereg_replace('^([[:digit:]]+\.[[:digit:]]+).*', '\1', $parts[2]);
|
||||
break;
|
||||
default:
|
||||
$release = ereg_replace('-.*', '', $parts[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (isset($sysmap[$sysname])) {
|
||||
$sysname = $sysmap[$sysname];
|
||||
} else {
|
||||
$sysname = strtolower($sysname);
|
||||
}
|
||||
if (isset($cpumap[$cpu])) {
|
||||
$cpu = $cpumap[$cpu];
|
||||
}
|
||||
return array($sysname, $release, $cpu, $extra, $nodename);
|
||||
}
|
||||
|
||||
function _detectGlibcVersion()
|
||||
{
|
||||
static $glibc = false;
|
||||
if ($glibc !== false) {
|
||||
return $glibc; // no need to run this multiple times
|
||||
}
|
||||
$major = $minor = 0;
|
||||
include_once "System.php";
|
||||
// Use glibc's <features.h> header file to
|
||||
// get major and minor version number:
|
||||
if (@file_exists('/usr/include/features.h') &&
|
||||
@is_readable('/usr/include/features.h')) {
|
||||
if (!@file_exists('/usr/bin/cpp') || !@is_executable('/usr/bin/cpp')) {
|
||||
$features_file = fopen('/usr/include/features.h', 'rb');
|
||||
while (!feof($features_file)) {
|
||||
$line = fgets($features_file, 8192);
|
||||
if (!$line || (strpos($line, '#define') === false)) {
|
||||
continue;
|
||||
}
|
||||
if (strpos($line, '__GLIBC__')) {
|
||||
// major version number #define __GLIBC__ version
|
||||
$line = preg_split('/\s+/', $line);
|
||||
$glibc_major = trim($line[2]);
|
||||
if (isset($glibc_minor)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (strpos($line, '__GLIBC_MINOR__')) {
|
||||
// got the minor version number
|
||||
// #define __GLIBC_MINOR__ version
|
||||
$line = preg_split('/\s+/', $line);
|
||||
$glibc_minor = trim($line[2]);
|
||||
if (isset($glibc_major)) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
fclose($features_file);
|
||||
if (!isset($glibc_major) || !isset($glibc_minor)) {
|
||||
return $glibc = '';
|
||||
}
|
||||
return $glibc = 'glibc' . trim($glibc_major) . "." . trim($glibc_minor) ;
|
||||
} // no cpp
|
||||
$tmpfile = System::mktemp("glibctest");
|
||||
$fp = fopen($tmpfile, "w");
|
||||
fwrite($fp, "#include <features.h>\n__GLIBC__ __GLIBC_MINOR__\n");
|
||||
fclose($fp);
|
||||
$cpp = popen("/usr/bin/cpp $tmpfile", "r");
|
||||
while ($line = fgets($cpp, 1024)) {
|
||||
if ($line{0} == '#' || trim($line) == '') {
|
||||
continue;
|
||||
}
|
||||
if (list($major, $minor) = explode(' ', trim($line))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
pclose($cpp);
|
||||
unlink($tmpfile);
|
||||
} // features.h
|
||||
if (!($major && $minor) && @is_link('/lib/libc.so.6')) {
|
||||
// Let's try reading the libc.so.6 symlink
|
||||
if (ereg('^libc-(.*)\.so$', basename(readlink('/lib/libc.so.6')), $matches)) {
|
||||
list($major, $minor) = explode('.', $matches[1]);
|
||||
}
|
||||
}
|
||||
if (!($major && $minor)) {
|
||||
return $glibc = '';
|
||||
}
|
||||
return $glibc = "glibc{$major}.{$minor}";
|
||||
}
|
||||
|
||||
function getSignature()
|
||||
{
|
||||
if (empty($this->extra)) {
|
||||
return "{$this->sysname}-{$this->release}-{$this->cpu}";
|
||||
}
|
||||
return "{$this->sysname}-{$this->release}-{$this->cpu}-{$this->extra}";
|
||||
}
|
||||
|
||||
function getSysname()
|
||||
{
|
||||
return $this->sysname;
|
||||
}
|
||||
|
||||
function getNodename()
|
||||
{
|
||||
return $this->nodename;
|
||||
}
|
||||
|
||||
function getCpu()
|
||||
{
|
||||
return $this->cpu;
|
||||
}
|
||||
|
||||
function getRelease()
|
||||
{
|
||||
return $this->release;
|
||||
}
|
||||
|
||||
function getExtra()
|
||||
{
|
||||
return $this->extra;
|
||||
}
|
||||
|
||||
function matchSignature($match)
|
||||
{
|
||||
if (is_array($match)) {
|
||||
$fragments = $match;
|
||||
} else {
|
||||
$fragments = explode('-', $match);
|
||||
}
|
||||
$n = count($fragments);
|
||||
$matches = 0;
|
||||
if ($n > 0) {
|
||||
$matches += $this->_matchFragment($fragments[0], $this->sysname);
|
||||
}
|
||||
if ($n > 1) {
|
||||
$matches += $this->_matchFragment($fragments[1], $this->release);
|
||||
}
|
||||
if ($n > 2) {
|
||||
$matches += $this->_matchFragment($fragments[2], $this->cpu);
|
||||
}
|
||||
if ($n > 3) {
|
||||
$matches += $this->_matchFragment($fragments[3], $this->extra);
|
||||
}
|
||||
return ($matches == $n);
|
||||
}
|
||||
|
||||
function _matchFragment($fragment, $value)
|
||||
{
|
||||
if (strcspn($fragment, '*?') < strlen($fragment)) {
|
||||
$reg = '^' . str_replace(array('*', '?', '/'), array('.*', '.', '\\/'), $fragment) . '$';
|
||||
return eregi($reg, $value);
|
||||
}
|
||||
return ($fragment == '*' || !strcasecmp($fragment, $value));
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Local Variables:
|
||||
* indent-tabs-mode: nil
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
*/
|
||||
?>
|
||||
1120
vendor/library/Excel/phpxls/PEAR.php
vendored
Normal file
1120
vendor/library/Excel/phpxls/PEAR.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
223
vendor/library/Excel/phpxls/PEAR/Autoloader.php
vendored
Normal file
223
vendor/library/Excel/phpxls/PEAR/Autoloader.php
vendored
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
<?php
|
||||
/**
|
||||
* Class auto-loader
|
||||
*
|
||||
* PHP versions 4
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Autoloader.php,v 1.14 2008/01/03 20:26:34 cellog Exp $
|
||||
* @link http://pear.php.net/manual/en/core.ppm.php#core.ppm.pear-autoloader
|
||||
* @since File available since Release 0.1
|
||||
* @deprecated File deprecated in Release 1.4.0a1
|
||||
*/
|
||||
|
||||
// /* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
|
||||
if (!extension_loaded("overload")) {
|
||||
// die hard without ext/overload
|
||||
die("Rebuild PHP with the `overload' extension to use PEAR_Autoloader");
|
||||
}
|
||||
|
||||
/**
|
||||
* Include for PEAR_Error and PEAR classes
|
||||
*/
|
||||
require_once "PEAR.php";
|
||||
|
||||
/**
|
||||
* This class is for objects where you want to separate the code for
|
||||
* some methods into separate classes. This is useful if you have a
|
||||
* class with not-frequently-used methods that contain lots of code
|
||||
* that you would like to avoid always parsing.
|
||||
*
|
||||
* The PEAR_Autoloader class provides autoloading and aggregation.
|
||||
* The autoloading lets you set up in which classes the separated
|
||||
* methods are found. Aggregation is the technique used to import new
|
||||
* methods, an instance of each class providing separated methods is
|
||||
* stored and called every time the aggregated method is called.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/manual/en/core.ppm.php#core.ppm.pear-autoloader
|
||||
* @since File available since Release 0.1
|
||||
* @deprecated File deprecated in Release 1.4.0a1
|
||||
*/
|
||||
class PEAR_Autoloader extends PEAR
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
/**
|
||||
* Map of methods and classes where they are defined
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_autoload_map = array();
|
||||
|
||||
/**
|
||||
* Map of methods and aggregate objects
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
var $_method_map = array();
|
||||
|
||||
// }}}
|
||||
// {{{ addAutoload()
|
||||
|
||||
/**
|
||||
* Add one or more autoload entries.
|
||||
*
|
||||
* @param string $method which method to autoload
|
||||
*
|
||||
* @param string $classname (optional) which class to find the method in.
|
||||
* If the $method parameter is an array, this
|
||||
* parameter may be omitted (and will be ignored
|
||||
* if not), and the $method parameter will be
|
||||
* treated as an associative array with method
|
||||
* names as keys and class names as values.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function addAutoload($method, $classname = null)
|
||||
{
|
||||
if (is_array($method)) {
|
||||
array_walk($method, create_function('$a,&$b', '$b = strtolower($b);'));
|
||||
$this->_autoload_map = array_merge($this->_autoload_map, $method);
|
||||
} else {
|
||||
$this->_autoload_map[strtolower($method)] = $classname;
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ removeAutoload()
|
||||
|
||||
/**
|
||||
* Remove an autoload entry.
|
||||
*
|
||||
* @param string $method which method to remove the autoload entry for
|
||||
*
|
||||
* @return bool TRUE if an entry was removed, FALSE if not
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function removeAutoload($method)
|
||||
{
|
||||
$method = strtolower($method);
|
||||
$ok = isset($this->_autoload_map[$method]);
|
||||
unset($this->_autoload_map[$method]);
|
||||
return $ok;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ addAggregateObject()
|
||||
|
||||
/**
|
||||
* Add an aggregate object to this object. If the specified class
|
||||
* is not defined, loading it will be attempted following PEAR's
|
||||
* file naming scheme. All the methods in the class will be
|
||||
* aggregated, except private ones (name starting with an
|
||||
* underscore) and constructors.
|
||||
*
|
||||
* @param string $classname what class to instantiate for the object.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function addAggregateObject($classname)
|
||||
{
|
||||
$classname = strtolower($classname);
|
||||
if (!class_exists($classname)) {
|
||||
$include_file = preg_replace('/[^a-z0-9]/i', '_', $classname);
|
||||
include_once $include_file;
|
||||
}
|
||||
$obj =& new $classname;
|
||||
$methods = get_class_methods($classname);
|
||||
foreach ($methods as $method) {
|
||||
// don't import priviate methods and constructors
|
||||
if ($method{0} != '_' && $method != $classname) {
|
||||
$this->_method_map[$method] = $obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ removeAggregateObject()
|
||||
|
||||
/**
|
||||
* Remove an aggregate object.
|
||||
*
|
||||
* @param string $classname the class of the object to remove
|
||||
*
|
||||
* @return bool TRUE if an object was removed, FALSE if not
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function removeAggregateObject($classname)
|
||||
{
|
||||
$ok = false;
|
||||
$classname = strtolower($classname);
|
||||
reset($this->_method_map);
|
||||
while (list($method, $obj) = each($this->_method_map)) {
|
||||
if (is_a($obj, $classname)) {
|
||||
unset($this->_method_map[$method]);
|
||||
$ok = true;
|
||||
}
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ __call()
|
||||
|
||||
/**
|
||||
* Overloaded object call handler, called each time an
|
||||
* undefined/aggregated method is invoked. This method repeats
|
||||
* the call in the right aggregate object and passes on the return
|
||||
* value.
|
||||
*
|
||||
* @param string $method which method that was called
|
||||
*
|
||||
* @param string $args An array of the parameters passed in the
|
||||
* original call
|
||||
*
|
||||
* @return mixed The return value from the aggregated method, or a PEAR
|
||||
* error if the called method was unknown.
|
||||
*/
|
||||
function __call($method, $args, &$retval)
|
||||
{
|
||||
$method = strtolower($method);
|
||||
if (empty($this->_method_map[$method]) && isset($this->_autoload_map[$method])) {
|
||||
$this->addAggregateObject($this->_autoload_map[$method]);
|
||||
}
|
||||
if (isset($this->_method_map[$method])) {
|
||||
$retval = call_user_func_array(array($this->_method_map[$method], $method), $args);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
overload("PEAR_Autoloader");
|
||||
|
||||
?>
|
||||
486
vendor/library/Excel/phpxls/PEAR/Builder.php
vendored
Normal file
486
vendor/library/Excel/phpxls/PEAR/Builder.php
vendored
Normal file
|
|
@ -0,0 +1,486 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Builder for building PHP extensions (PECL packages)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Builder.php,v 1.34 2008/05/12 23:43:21 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*
|
||||
* TODO: log output parameters in PECL command line
|
||||
* TODO: msdev path in configuration
|
||||
*/
|
||||
|
||||
/**
|
||||
* Needed for extending PEAR_Builder
|
||||
*/
|
||||
require_once 'PEAR/Common.php';
|
||||
require_once 'PEAR/PackageFile.php';
|
||||
/**
|
||||
* Class to handle building (compiling) extensions.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since PHP 4.0.2
|
||||
* @see http://pear.php.net/manual/en/core.ppm.pear-builder.php
|
||||
*/
|
||||
class PEAR_Builder extends PEAR_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $php_api_version = 0;
|
||||
var $zend_module_api_no = 0;
|
||||
var $zend_extension_api_no = 0;
|
||||
|
||||
var $extensions_built = array();
|
||||
|
||||
/**
|
||||
* @var string Used for reporting when it is not possible to pass function
|
||||
* via extra parameter, e.g. log, msdevCallback
|
||||
*/
|
||||
var $current_callback = null;
|
||||
|
||||
// used for msdev builds
|
||||
var $_lastline = null;
|
||||
var $_firstline = null;
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Builder constructor.
|
||||
*
|
||||
* @param object $ui user interface object (instance of PEAR_Frontend_*)
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Builder(&$ui)
|
||||
{
|
||||
parent::PEAR_Common();
|
||||
$this->setFrontendObject($ui);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ _build_win32()
|
||||
|
||||
/**
|
||||
* Build an extension from source on windows.
|
||||
* requires msdev
|
||||
*/
|
||||
function _build_win32($descfile, $callback = null)
|
||||
{
|
||||
if (is_object($descfile)) {
|
||||
$pkg = $descfile;
|
||||
$descfile = $pkg->getPackageFile();
|
||||
} else {
|
||||
$pf = &new PEAR_PackageFile($this->config, $this->debug);
|
||||
$pkg = &$pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL);
|
||||
if (PEAR::isError($pkg)) {
|
||||
return $pkg;
|
||||
}
|
||||
}
|
||||
$dir = dirname($descfile);
|
||||
$old_cwd = getcwd();
|
||||
|
||||
if (!file_exists($dir) || !is_dir($dir) || !chdir($dir)) {
|
||||
return $this->raiseError("could not chdir to $dir");
|
||||
}
|
||||
// packages that were in a .tar have the packagefile in this directory
|
||||
$vdir = $pkg->getPackage() . '-' . $pkg->getVersion();
|
||||
if (file_exists($dir) && is_dir($vdir)) {
|
||||
if (chdir($vdir)) {
|
||||
$dir = getcwd();
|
||||
} else {
|
||||
return $this->raiseError("could not chdir to " . realpath($vdir));
|
||||
}
|
||||
}
|
||||
|
||||
$this->log(2, "building in $dir");
|
||||
|
||||
$dsp = $pkg->getPackage().'.dsp';
|
||||
if (!file_exists("$dir/$dsp")) {
|
||||
return $this->raiseError("The DSP $dsp does not exist.");
|
||||
}
|
||||
// XXX TODO: make release build type configurable
|
||||
$command = 'msdev '.$dsp.' /MAKE "'.$pkg->getPackage(). ' - Release"';
|
||||
|
||||
$err = $this->_runCommand($command, array(&$this, 'msdevCallback'));
|
||||
if (PEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
|
||||
// figure out the build platform and type
|
||||
$platform = 'Win32';
|
||||
$buildtype = 'Release';
|
||||
if (preg_match('/.*?'.$pkg->getPackage().'\s-\s(\w+)\s(.*?)-+/i',$this->_firstline,$matches)) {
|
||||
$platform = $matches[1];
|
||||
$buildtype = $matches[2];
|
||||
}
|
||||
|
||||
if (preg_match('/(.*)?\s-\s(\d+).*?(\d+)/',$this->_lastline,$matches)) {
|
||||
if ($matches[2]) {
|
||||
// there were errors in the build
|
||||
return $this->raiseError("There were errors during compilation.");
|
||||
}
|
||||
$out = $matches[1];
|
||||
} else {
|
||||
return $this->raiseError("Did not understand the completion status returned from msdev.exe.");
|
||||
}
|
||||
|
||||
// msdev doesn't tell us the output directory :/
|
||||
// open the dsp, find /out and use that directory
|
||||
$dsptext = join(file($dsp),'');
|
||||
|
||||
// this regex depends on the build platform and type having been
|
||||
// correctly identified above.
|
||||
$regex ='/.*?!IF\s+"\$\(CFG\)"\s+==\s+("'.
|
||||
$pkg->getPackage().'\s-\s'.
|
||||
$platform.'\s'.
|
||||
$buildtype.'").*?'.
|
||||
'\/out:"(.*?)"/is';
|
||||
|
||||
if ($dsptext && preg_match($regex,$dsptext,$matches)) {
|
||||
// what we get back is a relative path to the output file itself.
|
||||
$outfile = realpath($matches[2]);
|
||||
} else {
|
||||
return $this->raiseError("Could not retrieve output information from $dsp.");
|
||||
}
|
||||
// realpath returns false if the file doesn't exist
|
||||
if ($outfile && copy($outfile, "$dir/$out")) {
|
||||
$outfile = "$dir/$out";
|
||||
}
|
||||
|
||||
$built_files[] = array(
|
||||
'file' => "$outfile",
|
||||
'php_api' => $this->php_api_version,
|
||||
'zend_mod_api' => $this->zend_module_api_no,
|
||||
'zend_ext_api' => $this->zend_extension_api_no,
|
||||
);
|
||||
|
||||
return $built_files;
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ msdevCallback()
|
||||
function msdevCallback($what, $data)
|
||||
{
|
||||
if (!$this->_firstline)
|
||||
$this->_firstline = $data;
|
||||
$this->_lastline = $data;
|
||||
call_user_func($this->current_callback, $what, $data);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ _harventInstDir
|
||||
/**
|
||||
* @param string
|
||||
* @param string
|
||||
* @param array
|
||||
* @access private
|
||||
*/
|
||||
function _harvestInstDir($dest_prefix, $dirname, &$built_files)
|
||||
{
|
||||
$d = opendir($dirname);
|
||||
if (!$d)
|
||||
return false;
|
||||
|
||||
$ret = true;
|
||||
while (($ent = readdir($d)) !== false) {
|
||||
if ($ent{0} == '.')
|
||||
continue;
|
||||
|
||||
$full = $dirname . DIRECTORY_SEPARATOR . $ent;
|
||||
if (is_dir($full)) {
|
||||
if (!$this->_harvestInstDir(
|
||||
$dest_prefix . DIRECTORY_SEPARATOR . $ent,
|
||||
$full, $built_files)) {
|
||||
$ret = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$dest = $dest_prefix . DIRECTORY_SEPARATOR . $ent;
|
||||
$built_files[] = array(
|
||||
'file' => $full,
|
||||
'dest' => $dest,
|
||||
'php_api' => $this->php_api_version,
|
||||
'zend_mod_api' => $this->zend_module_api_no,
|
||||
'zend_ext_api' => $this->zend_extension_api_no,
|
||||
);
|
||||
}
|
||||
}
|
||||
closedir($d);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ build()
|
||||
|
||||
/**
|
||||
* Build an extension from source. Runs "phpize" in the source
|
||||
* directory, but compiles in a temporary directory
|
||||
* (/var/tmp/pear-build-USER/PACKAGE-VERSION).
|
||||
*
|
||||
* @param string|PEAR_PackageFile_v* $descfile path to XML package description file, or
|
||||
* a PEAR_PackageFile object
|
||||
*
|
||||
* @param mixed $callback callback function used to report output,
|
||||
* see PEAR_Builder::_runCommand for details
|
||||
*
|
||||
* @return array an array of associative arrays with built files,
|
||||
* format:
|
||||
* array( array( 'file' => '/path/to/ext.so',
|
||||
* 'php_api' => YYYYMMDD,
|
||||
* 'zend_mod_api' => YYYYMMDD,
|
||||
* 'zend_ext_api' => YYYYMMDD ),
|
||||
* ... )
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @see PEAR_Builder::_runCommand
|
||||
*/
|
||||
function build($descfile, $callback = null)
|
||||
{
|
||||
$this->current_callback = $callback;
|
||||
if (PEAR_OS == "Windows") {
|
||||
return $this->_build_win32($descfile,$callback);
|
||||
}
|
||||
if (PEAR_OS != 'Unix') {
|
||||
return $this->raiseError("building extensions not supported on this platform");
|
||||
}
|
||||
if (is_object($descfile)) {
|
||||
$pkg = $descfile;
|
||||
$descfile = $pkg->getPackageFile();
|
||||
if (is_a($pkg, 'PEAR_PackageFile_v1')) {
|
||||
$dir = dirname($descfile);
|
||||
} else {
|
||||
$dir = $pkg->_config->get('temp_dir') . '/' . $pkg->getName();
|
||||
// automatically delete at session end
|
||||
$this->addTempFile($dir);
|
||||
}
|
||||
} else {
|
||||
$pf = &new PEAR_PackageFile($this->config);
|
||||
$pkg = &$pf->fromPackageFile($descfile, PEAR_VALIDATE_NORMAL);
|
||||
if (PEAR::isError($pkg)) {
|
||||
return $pkg;
|
||||
}
|
||||
$dir = dirname($descfile);
|
||||
}
|
||||
$old_cwd = getcwd();
|
||||
if (!file_exists($dir) || !is_dir($dir) || !chdir($dir)) {
|
||||
return $this->raiseError("could not chdir to $dir");
|
||||
}
|
||||
$vdir = $pkg->getPackage() . '-' . $pkg->getVersion();
|
||||
if (is_dir($vdir)) {
|
||||
chdir($vdir);
|
||||
}
|
||||
$dir = getcwd();
|
||||
$this->log(2, "building in $dir");
|
||||
putenv('PATH=' . $this->config->get('bin_dir') . ':' . getenv('PATH'));
|
||||
$err = $this->_runCommand("phpize", array(&$this, 'phpizeCallback'));
|
||||
if (PEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
if (!$err) {
|
||||
return $this->raiseError("`phpize' failed");
|
||||
}
|
||||
|
||||
// {{{ start of interactive part
|
||||
$configure_command = "$dir/configure";
|
||||
$configure_options = $pkg->getConfigureOptions();
|
||||
if ($configure_options) {
|
||||
foreach ($configure_options as $o) {
|
||||
$default = array_key_exists('default', $o) ? $o['default'] : null;
|
||||
list($r) = $this->ui->userDialog('build',
|
||||
array($o['prompt']),
|
||||
array('text'),
|
||||
array($default));
|
||||
if (substr($o['name'], 0, 5) == 'with-' &&
|
||||
($r == 'yes' || $r == 'autodetect')) {
|
||||
$configure_command .= " --$o[name]";
|
||||
} else {
|
||||
$configure_command .= " --$o[name]=".trim($r);
|
||||
}
|
||||
}
|
||||
}
|
||||
// }}} end of interactive part
|
||||
|
||||
// FIXME make configurable
|
||||
if(!$user=getenv('USER')){
|
||||
$user='defaultuser';
|
||||
}
|
||||
$build_basedir = "/var/tmp/pear-build-$user";
|
||||
$build_dir = "$build_basedir/$vdir";
|
||||
$inst_dir = "$build_basedir/install-$vdir";
|
||||
$this->log(1, "building in $build_dir");
|
||||
if (is_dir($build_dir)) {
|
||||
System::rm(array('-rf', $build_dir));
|
||||
}
|
||||
if (!System::mkDir(array('-p', $build_dir))) {
|
||||
return $this->raiseError("could not create build dir: $build_dir");
|
||||
}
|
||||
$this->addTempFile($build_dir);
|
||||
if (!System::mkDir(array('-p', $inst_dir))) {
|
||||
return $this->raiseError("could not create temporary install dir: $inst_dir");
|
||||
}
|
||||
$this->addTempFile($inst_dir);
|
||||
|
||||
if (getenv('MAKE')) {
|
||||
$make_command = getenv('MAKE');
|
||||
} else {
|
||||
$make_command = 'make';
|
||||
}
|
||||
$to_run = array(
|
||||
$configure_command,
|
||||
$make_command,
|
||||
"$make_command INSTALL_ROOT=\"$inst_dir\" install",
|
||||
"find \"$inst_dir\" | xargs ls -dils"
|
||||
);
|
||||
if (!file_exists($build_dir) || !is_dir($build_dir) || !chdir($build_dir)) {
|
||||
return $this->raiseError("could not chdir to $build_dir");
|
||||
}
|
||||
putenv('PHP_PEAR_VERSION=1.7.2');
|
||||
foreach ($to_run as $cmd) {
|
||||
$err = $this->_runCommand($cmd, $callback);
|
||||
if (PEAR::isError($err)) {
|
||||
chdir($old_cwd);
|
||||
return $err;
|
||||
}
|
||||
if (!$err) {
|
||||
chdir($old_cwd);
|
||||
return $this->raiseError("`$cmd' failed");
|
||||
}
|
||||
}
|
||||
if (!($dp = opendir("modules"))) {
|
||||
chdir($old_cwd);
|
||||
return $this->raiseError("no `modules' directory found");
|
||||
}
|
||||
$built_files = array();
|
||||
$prefix = exec("php-config --prefix");
|
||||
$this->_harvestInstDir($prefix, $inst_dir . DIRECTORY_SEPARATOR . $prefix, $built_files);
|
||||
chdir($old_cwd);
|
||||
return $built_files;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ phpizeCallback()
|
||||
|
||||
/**
|
||||
* Message callback function used when running the "phpize"
|
||||
* program. Extracts the API numbers used. Ignores other message
|
||||
* types than "cmdoutput".
|
||||
*
|
||||
* @param string $what the type of message
|
||||
* @param mixed $data the message
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function phpizeCallback($what, $data)
|
||||
{
|
||||
if ($what != 'cmdoutput') {
|
||||
return;
|
||||
}
|
||||
$this->log(1, rtrim($data));
|
||||
if (preg_match('/You should update your .aclocal.m4/', $data)) {
|
||||
return;
|
||||
}
|
||||
$matches = array();
|
||||
if (preg_match('/^\s+(\S[^:]+):\s+(\d{8})/', $data, $matches)) {
|
||||
$member = preg_replace('/[^a-z]/', '_', strtolower($matches[1]));
|
||||
$apino = (int)$matches[2];
|
||||
if (isset($this->$member)) {
|
||||
$this->$member = $apino;
|
||||
//$msg = sprintf("%-22s : %d", $matches[1], $apino);
|
||||
//$this->log(1, $msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _runCommand()
|
||||
|
||||
/**
|
||||
* Run an external command, using a message callback to report
|
||||
* output. The command will be run through popen and output is
|
||||
* reported for every line with a "cmdoutput" message with the
|
||||
* line string, including newlines, as payload.
|
||||
*
|
||||
* @param string $command the command to run
|
||||
*
|
||||
* @param mixed $callback (optional) function to use as message
|
||||
* callback
|
||||
*
|
||||
* @return bool whether the command was successful (exit code 0
|
||||
* means success, any other means failure)
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _runCommand($command, $callback = null)
|
||||
{
|
||||
$this->log(1, "running: $command");
|
||||
$pp = popen("$command 2>&1", "r");
|
||||
if (!$pp) {
|
||||
return $this->raiseError("failed to run `$command'");
|
||||
}
|
||||
if ($callback && $callback[0]->debug == 1) {
|
||||
$olddbg = $callback[0]->debug;
|
||||
$callback[0]->debug = 2;
|
||||
}
|
||||
|
||||
while ($line = fgets($pp, 1024)) {
|
||||
if ($callback) {
|
||||
call_user_func($callback, 'cmdoutput', $line);
|
||||
} else {
|
||||
$this->log(2, rtrim($line));
|
||||
}
|
||||
}
|
||||
if ($callback && isset($olddbg)) {
|
||||
$callback[0]->debug = $olddbg;
|
||||
}
|
||||
if (is_resource($pp)) {
|
||||
$exitcode = pclose($pp);
|
||||
} else {
|
||||
$exitcode = -1;
|
||||
}
|
||||
return ($exitcode == 0);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ log()
|
||||
|
||||
function log($level, $msg)
|
||||
{
|
||||
if ($this->current_callback) {
|
||||
if ($this->debug >= $level) {
|
||||
call_user_func($this->current_callback, 'output', $msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return PEAR_Common::log($level, $msg);
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
1615
vendor/library/Excel/phpxls/PEAR/ChannelFile.php
vendored
Normal file
1615
vendor/library/Excel/phpxls/PEAR/ChannelFile.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
73
vendor/library/Excel/phpxls/PEAR/ChannelFile/Parser.php
vendored
Normal file
73
vendor/library/Excel/phpxls/PEAR/ChannelFile/Parser.php
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_ChannelFile_Parser for parsing channel.xml
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Parser.php,v 1.5 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base xml parser class
|
||||
*/
|
||||
require_once 'PEAR/XMLParser.php';
|
||||
require_once 'PEAR/ChannelFile.php';
|
||||
/**
|
||||
* Parser for channel.xml
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a1
|
||||
*/
|
||||
class PEAR_ChannelFile_Parser extends PEAR_XMLParser
|
||||
{
|
||||
var $_config;
|
||||
var $_logger;
|
||||
var $_registry;
|
||||
|
||||
function setConfig(&$c)
|
||||
{
|
||||
$this->_config = &$c;
|
||||
$this->_registry = &$c->getRegistry();
|
||||
}
|
||||
|
||||
function setLogger(&$l)
|
||||
{
|
||||
$this->_logger = &$l;
|
||||
}
|
||||
|
||||
function parse($data, $file)
|
||||
{
|
||||
if (PEAR::isError($err = parent::parse($data, $file))) {
|
||||
return $err;
|
||||
}
|
||||
$ret = new PEAR_ChannelFile;
|
||||
$ret->setConfig($this->_config);
|
||||
if (isset($this->_logger)) {
|
||||
$ret->setLogger($this->_logger);
|
||||
}
|
||||
$ret->fromArray($this->_unserializedData);
|
||||
// make sure the filelist is in the easy to read format needed
|
||||
$ret->flattenFilelist();
|
||||
$ret->setPackagefile($file, $archive);
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
?>
|
||||
416
vendor/library/Excel/phpxls/PEAR/Command.php
vendored
Normal file
416
vendor/library/Excel/phpxls/PEAR/Command.php
vendored
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Command, command pattern class
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Command.php,v 1.39 2008/01/03 20:26:34 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* Needed for error handling
|
||||
*/
|
||||
require_once 'PEAR.php';
|
||||
require_once 'PEAR/Frontend.php';
|
||||
require_once 'PEAR/XMLParser.php';
|
||||
|
||||
/**
|
||||
* List of commands and what classes they are implemented in.
|
||||
* @var array command => implementing class
|
||||
*/
|
||||
$GLOBALS['_PEAR_Command_commandlist'] = array();
|
||||
|
||||
/**
|
||||
* List of commands and their descriptions
|
||||
* @var array command => description
|
||||
*/
|
||||
$GLOBALS['_PEAR_Command_commanddesc'] = array();
|
||||
|
||||
/**
|
||||
* List of shortcuts to common commands.
|
||||
* @var array shortcut => command
|
||||
*/
|
||||
$GLOBALS['_PEAR_Command_shortcuts'] = array();
|
||||
|
||||
/**
|
||||
* Array of command objects
|
||||
* @var array class => object
|
||||
*/
|
||||
$GLOBALS['_PEAR_Command_objects'] = array();
|
||||
|
||||
/**
|
||||
* PEAR command class, a simple factory class for administrative
|
||||
* commands.
|
||||
*
|
||||
* How to implement command classes:
|
||||
*
|
||||
* - The class must be called PEAR_Command_Nnn, installed in the
|
||||
* "PEAR/Common" subdir, with a method called getCommands() that
|
||||
* returns an array of the commands implemented by the class (see
|
||||
* PEAR/Command/Install.php for an example).
|
||||
*
|
||||
* - The class must implement a run() function that is called with three
|
||||
* params:
|
||||
*
|
||||
* (string) command name
|
||||
* (array) assoc array with options, freely defined by each
|
||||
* command, for example:
|
||||
* array('force' => true)
|
||||
* (array) list of the other parameters
|
||||
*
|
||||
* The run() function returns a PEAR_CommandResponse object. Use
|
||||
* these methods to get information:
|
||||
*
|
||||
* int getStatus() Returns PEAR_COMMAND_(SUCCESS|FAILURE|PARTIAL)
|
||||
* *_PARTIAL means that you need to issue at least
|
||||
* one more command to complete the operation
|
||||
* (used for example for validation steps).
|
||||
*
|
||||
* string getMessage() Returns a message for the user. Remember,
|
||||
* no HTML or other interface-specific markup.
|
||||
*
|
||||
* If something unexpected happens, run() returns a PEAR error.
|
||||
*
|
||||
* - DON'T OUTPUT ANYTHING! Return text for output instead.
|
||||
*
|
||||
* - DON'T USE HTML! The text you return will be used from both Gtk,
|
||||
* web and command-line interfaces, so for now, keep everything to
|
||||
* plain text.
|
||||
*
|
||||
* - DON'T USE EXIT OR DIE! Always use pear errors. From static
|
||||
* classes do PEAR::raiseError(), from other classes do
|
||||
* $this->raiseError().
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
class PEAR_Command
|
||||
{
|
||||
// {{{ factory()
|
||||
|
||||
/**
|
||||
* Get the right object for executing a command.
|
||||
*
|
||||
* @param string $command The name of the command
|
||||
* @param object $config Instance of PEAR_Config object
|
||||
*
|
||||
* @return object the command object or a PEAR error
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static function &factory($command, &$config)
|
||||
{
|
||||
if (empty($GLOBALS['_PEAR_Command_commandlist'])) {
|
||||
PEAR_Command::registerCommands();
|
||||
}
|
||||
if (isset($GLOBALS['_PEAR_Command_shortcuts'][$command])) {
|
||||
$command = $GLOBALS['_PEAR_Command_shortcuts'][$command];
|
||||
}
|
||||
if (!isset($GLOBALS['_PEAR_Command_commandlist'][$command])) {
|
||||
$a = PEAR::raiseError("unknown command `$command'");
|
||||
return $a;
|
||||
}
|
||||
$class = $GLOBALS['_PEAR_Command_commandlist'][$command];
|
||||
if (!class_exists($class)) {
|
||||
require_once $GLOBALS['_PEAR_Command_objects'][$class];
|
||||
}
|
||||
if (!class_exists($class)) {
|
||||
$a = PEAR::raiseError("unknown command `$command'");
|
||||
return $a;
|
||||
}
|
||||
$ui =& PEAR_Command::getFrontendObject();
|
||||
$obj = &new $class($ui, $config);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ & getObject()
|
||||
function &getObject($command)
|
||||
{
|
||||
$class = $GLOBALS['_PEAR_Command_commandlist'][$command];
|
||||
if (!class_exists($class)) {
|
||||
require_once $GLOBALS['_PEAR_Command_objects'][$class];
|
||||
}
|
||||
if (!class_exists($class)) {
|
||||
return PEAR::raiseError("unknown command `$command'");
|
||||
}
|
||||
$ui =& PEAR_Command::getFrontendObject();
|
||||
$config = &PEAR_Config::singleton();
|
||||
$obj = &new $class($ui, $config);
|
||||
return $obj;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ & getFrontendObject()
|
||||
|
||||
/**
|
||||
* Get instance of frontend object.
|
||||
*
|
||||
* @return object|PEAR_Error
|
||||
* @static
|
||||
*/
|
||||
static function &getFrontendObject()
|
||||
{
|
||||
$a = &PEAR_Frontend::singleton();
|
||||
return $a;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ & setFrontendClass()
|
||||
|
||||
/**
|
||||
* Load current frontend class.
|
||||
*
|
||||
* @param string $uiclass Name of class implementing the frontend
|
||||
*
|
||||
* @return object the frontend object, or a PEAR error
|
||||
* @static
|
||||
*/
|
||||
static function &setFrontendClass($uiclass)
|
||||
{
|
||||
$a = &PEAR_Frontend::setFrontendClass($uiclass);
|
||||
return $a;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ setFrontendType()
|
||||
|
||||
/**
|
||||
* Set current frontend.
|
||||
*
|
||||
* @param string $uitype Name of the frontend type (for example "CLI")
|
||||
*
|
||||
* @return object the frontend object, or a PEAR error
|
||||
* @static
|
||||
*/
|
||||
static function setFrontendType($uitype)
|
||||
{
|
||||
$uiclass = 'PEAR_Frontend_' . $uitype;
|
||||
return PEAR_Command::setFrontendClass($uiclass);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ registerCommands()
|
||||
|
||||
/**
|
||||
* Scan through the Command directory looking for classes
|
||||
* and see what commands they implement.
|
||||
*
|
||||
* @param bool (optional) if FALSE (default), the new list of
|
||||
* commands should replace the current one. If TRUE,
|
||||
* new entries will be merged with old.
|
||||
*
|
||||
* @param string (optional) where (what directory) to look for
|
||||
* classes, defaults to the Command subdirectory of
|
||||
* the directory from where this file (__FILE__) is
|
||||
* included.
|
||||
*
|
||||
* @return bool TRUE on success, a PEAR error on failure
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static function registerCommands($merge = false, $dir = null)
|
||||
{
|
||||
$parser = new PEAR_XMLParser;
|
||||
if ($dir === null) {
|
||||
$dir = dirname(__FILE__) . '/Command';
|
||||
}
|
||||
if (!is_dir($dir)) {
|
||||
return PEAR::raiseError("registerCommands: opendir($dir) '$dir' does not exist or is not a directory");
|
||||
}
|
||||
$dp = @opendir($dir);
|
||||
if (empty($dp)) {
|
||||
return PEAR::raiseError("registerCommands: opendir($dir) failed");
|
||||
}
|
||||
if (!$merge) {
|
||||
$GLOBALS['_PEAR_Command_commandlist'] = array();
|
||||
}
|
||||
while ($entry = readdir($dp)) {
|
||||
if ($entry{0} == '.' || substr($entry, -4) != '.xml') {
|
||||
continue;
|
||||
}
|
||||
$class = "PEAR_Command_".substr($entry, 0, -4);
|
||||
$file = "$dir/$entry";
|
||||
$parser->parse(file_get_contents($file));
|
||||
$implements = $parser->getData();
|
||||
// List of commands
|
||||
if (empty($GLOBALS['_PEAR_Command_objects'][$class])) {
|
||||
$GLOBALS['_PEAR_Command_objects'][$class] = "$dir/" . substr($entry, 0, -4) .
|
||||
'.php';
|
||||
}
|
||||
foreach ($implements as $command => $desc) {
|
||||
if ($command == 'attribs') {
|
||||
continue;
|
||||
}
|
||||
if (isset($GLOBALS['_PEAR_Command_commandlist'][$command])) {
|
||||
return PEAR::raiseError('Command "' . $command . '" already registered in ' .
|
||||
'class "' . $GLOBALS['_PEAR_Command_commandlist'][$command] . '"');
|
||||
}
|
||||
$GLOBALS['_PEAR_Command_commandlist'][$command] = $class;
|
||||
$GLOBALS['_PEAR_Command_commanddesc'][$command] = $desc['summary'];
|
||||
if (isset($desc['shortcut'])) {
|
||||
$shortcut = $desc['shortcut'];
|
||||
if (isset($GLOBALS['_PEAR_Command_shortcuts'][$shortcut])) {
|
||||
return PEAR::raiseError('Command shortcut "' . $shortcut . '" already ' .
|
||||
'registered to command "' . $command . '" in class "' .
|
||||
$GLOBALS['_PEAR_Command_commandlist'][$command] . '"');
|
||||
}
|
||||
$GLOBALS['_PEAR_Command_shortcuts'][$shortcut] = $command;
|
||||
}
|
||||
if (isset($desc['options']) && $desc['options']) {
|
||||
foreach ($desc['options'] as $oname => $option) {
|
||||
if (isset($option['shortopt']) && strlen($option['shortopt']) > 1) {
|
||||
return PEAR::raiseError('Option "' . $oname . '" short option "' .
|
||||
$option['shortopt'] . '" must be ' .
|
||||
'only 1 character in Command "' . $command . '" in class "' .
|
||||
$class . '"');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ksort($GLOBALS['_PEAR_Command_shortcuts']);
|
||||
ksort($GLOBALS['_PEAR_Command_commandlist']);
|
||||
@closedir($dp);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getCommands()
|
||||
|
||||
/**
|
||||
* Get the list of currently supported commands, and what
|
||||
* classes implement them.
|
||||
*
|
||||
* @return array command => implementing class
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static function getCommands()
|
||||
{
|
||||
if (empty($GLOBALS['_PEAR_Command_commandlist'])) {
|
||||
PEAR_Command::registerCommands();
|
||||
}
|
||||
return $GLOBALS['_PEAR_Command_commandlist'];
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getShortcuts()
|
||||
|
||||
/**
|
||||
* Get the list of command shortcuts.
|
||||
*
|
||||
* @return array shortcut => command
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static function getShortcuts()
|
||||
{
|
||||
if (empty($GLOBALS['_PEAR_Command_shortcuts'])) {
|
||||
PEAR_Command::registerCommands();
|
||||
}
|
||||
return $GLOBALS['_PEAR_Command_shortcuts'];
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getGetoptArgs()
|
||||
|
||||
/**
|
||||
* Compiles arguments for getopt.
|
||||
*
|
||||
* @param string $command command to get optstring for
|
||||
* @param string $short_args (reference) short getopt format
|
||||
* @param array $long_args (reference) long getopt format
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static function getGetoptArgs($command, &$short_args, &$long_args)
|
||||
{
|
||||
if (empty($GLOBALS['_PEAR_Command_commandlist'])) {
|
||||
PEAR_Command::registerCommands();
|
||||
}
|
||||
if (isset($GLOBALS['_PEAR_Command_shortcuts'][$command])) {
|
||||
$command = $GLOBALS['_PEAR_Command_shortcuts'][$command];
|
||||
}
|
||||
if (!isset($GLOBALS['_PEAR_Command_commandlist'][$command])) {
|
||||
return null;
|
||||
}
|
||||
$obj = &PEAR_Command::getObject($command);
|
||||
return $obj->getGetoptArgs($command, $short_args, $long_args);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getDescription()
|
||||
|
||||
/**
|
||||
* Get description for a command.
|
||||
*
|
||||
* @param string $command Name of the command
|
||||
*
|
||||
* @return string command description
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static function getDescription($command)
|
||||
{
|
||||
if (!isset($GLOBALS['_PEAR_Command_commanddesc'][$command])) {
|
||||
return null;
|
||||
}
|
||||
return $GLOBALS['_PEAR_Command_commanddesc'][$command];
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getHelp()
|
||||
|
||||
/**
|
||||
* Get help for command.
|
||||
*
|
||||
* @param string $command Name of the command to return help for
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static function getHelp($command)
|
||||
{
|
||||
$cmds = PEAR_Command::getCommands();
|
||||
if (isset($GLOBALS['_PEAR_Command_shortcuts'][$command])) {
|
||||
$command = $GLOBALS['_PEAR_Command_shortcuts'][$command];
|
||||
}
|
||||
if (isset($cmds[$command])) {
|
||||
$obj = &PEAR_Command::getObject($command);
|
||||
return $obj->getHelp($command);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
203
vendor/library/Excel/phpxls/PEAR/Command/Auth.php
vendored
Normal file
203
vendor/library/Excel/phpxls/PEAR/Command/Auth.php
vendored
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Command_Auth (login, logout commands)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Auth.php,v 1.31 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
require_once 'PEAR/Config.php';
|
||||
|
||||
/**
|
||||
* PEAR commands for login/logout
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
class PEAR_Command_Auth extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'login' => array(
|
||||
'summary' => 'Connects and authenticates to remote server',
|
||||
'shortcut' => 'li',
|
||||
'function' => 'doLogin',
|
||||
'options' => array(),
|
||||
'doc' => '<channel name>
|
||||
Log in to a remote channel server. If <channel name> is not supplied,
|
||||
the default channel is used. To use remote functions in the installer
|
||||
that require any kind of privileges, you need to log in first. The
|
||||
username and password you enter here will be stored in your per-user
|
||||
PEAR configuration (~/.pearrc on Unix-like systems). After logging
|
||||
in, your username and password will be sent along in subsequent
|
||||
operations on the remote server.',
|
||||
),
|
||||
'logout' => array(
|
||||
'summary' => 'Logs out from the remote server',
|
||||
'shortcut' => 'lo',
|
||||
'function' => 'doLogout',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
Logs out from the remote server. This command does not actually
|
||||
connect to the remote server, it only deletes the stored username and
|
||||
password from your user configuration.',
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Auth constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Auth(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doLogin()
|
||||
|
||||
/**
|
||||
* Execute the 'login' command.
|
||||
*
|
||||
* @param string $command command name
|
||||
*
|
||||
* @param array $options option_name => value
|
||||
*
|
||||
* @param array $params list of additional parameters
|
||||
*
|
||||
* @return bool TRUE on success or
|
||||
* a PEAR error on failure
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function doLogin($command, $options, $params)
|
||||
{
|
||||
$reg = &$this->config->getRegistry();
|
||||
|
||||
// If a parameter is supplied, use that as the channel to log in to
|
||||
if (isset($params[0])) {
|
||||
$channel = $params[0];
|
||||
} else {
|
||||
$channel = $this->config->get('default_channel');
|
||||
}
|
||||
|
||||
$chan = $reg->getChannel($channel);
|
||||
if (PEAR::isError($chan)) {
|
||||
return $this->raiseError($chan);
|
||||
}
|
||||
$server = $this->config->get('preferred_mirror', null, $channel);
|
||||
$remote = &$this->config->getRemote();
|
||||
$username = $this->config->get('username', null, $channel);
|
||||
if (empty($username)) {
|
||||
$username = isset($_ENV['USER']) ? $_ENV['USER'] : null;
|
||||
}
|
||||
$this->ui->outputData("Logging in to $server.", $command);
|
||||
|
||||
list($username, $password) = $this->ui->userDialog(
|
||||
$command,
|
||||
array('Username', 'Password'),
|
||||
array('text', 'password'),
|
||||
array($username, '')
|
||||
);
|
||||
$username = trim($username);
|
||||
$password = trim($password);
|
||||
|
||||
$ourfile = $this->config->getConfFile('user');
|
||||
if (!$ourfile) {
|
||||
$ourfile = $this->config->getConfFile('system');
|
||||
}
|
||||
|
||||
$this->config->set('username', $username, 'user', $channel);
|
||||
$this->config->set('password', $password, 'user', $channel);
|
||||
|
||||
if ($chan->supportsREST()) {
|
||||
$ok = true;
|
||||
} else {
|
||||
$remote->expectError(401);
|
||||
$ok = $remote->call('logintest');
|
||||
$remote->popExpect();
|
||||
}
|
||||
if ($ok === true) {
|
||||
$this->ui->outputData("Logged in.", $command);
|
||||
// avoid changing any temporary settings changed with -d
|
||||
$ourconfig = new PEAR_Config($ourfile, $ourfile);
|
||||
$ourconfig->set('username', $username, 'user', $channel);
|
||||
$ourconfig->set('password', $password, 'user', $channel);
|
||||
$ourconfig->store();
|
||||
} else {
|
||||
return $this->raiseError("Login failed!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doLogout()
|
||||
|
||||
/**
|
||||
* Execute the 'logout' command.
|
||||
*
|
||||
* @param string $command command name
|
||||
*
|
||||
* @param array $options option_name => value
|
||||
*
|
||||
* @param array $params list of additional parameters
|
||||
*
|
||||
* @return bool TRUE on success or
|
||||
* a PEAR error on failure
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function doLogout($command, $options, $params)
|
||||
{
|
||||
$reg = &$this->config->getRegistry();
|
||||
$channel = $this->config->get('default_channel');
|
||||
$chan = $reg->getChannel($channel);
|
||||
if (PEAR::isError($chan)) {
|
||||
return $this->raiseError($chan);
|
||||
}
|
||||
$server = $this->config->get('preferred_mirror');
|
||||
$this->ui->outputData("Logging out from $server.", $command);
|
||||
$this->config->remove('username');
|
||||
$this->config->remove('password');
|
||||
$this->config->store();
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
26
vendor/library/Excel/phpxls/PEAR/Command/Auth.xml
vendored
Normal file
26
vendor/library/Excel/phpxls/PEAR/Command/Auth.xml
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<commands version="1.0">
|
||||
<login>
|
||||
<summary>Connects and authenticates to remote server</summary>
|
||||
<shortcut>li</shortcut>
|
||||
<function>doLogin</function>
|
||||
<options />
|
||||
<doc><channel name>
|
||||
Log in to a remote channel server. <channel name> is not supplied,
|
||||
the default channel is used. To use remote functions in the installer
|
||||
that require any kind of privileges, you need to log in first. The
|
||||
username and password you enter here will be stored in your per-user
|
||||
PEAR configuration (~/.pearrc on Unix-like systems). After logging
|
||||
in, your username and password will be sent along in subsequent
|
||||
operations on the remote server.</doc>
|
||||
</login>
|
||||
<logout>
|
||||
<summary>Logs out from the remote server</summary>
|
||||
<shortcut>lo</shortcut>
|
||||
<function>doLogout</function>
|
||||
<options />
|
||||
<doc>
|
||||
Logs out from the remote server. This command does not actually
|
||||
connect to the remote server, it only deletes the stored username and
|
||||
password from your user configuration.</doc>
|
||||
</logout>
|
||||
</commands>
|
||||
104
vendor/library/Excel/phpxls/PEAR/Command/Build.php
vendored
Normal file
104
vendor/library/Excel/phpxls/PEAR/Command/Build.php
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Command_Auth (build command)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Tomas V.V.Cox <cox@idecnet.com>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Build.php,v 1.14 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
|
||||
/**
|
||||
* PEAR commands for building extensions.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Tomas V.V.Cox <cox@idecnet.com>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
class PEAR_Command_Build extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'build' => array(
|
||||
'summary' => 'Build an Extension From C Source',
|
||||
'function' => 'doBuild',
|
||||
'shortcut' => 'b',
|
||||
'options' => array(),
|
||||
'doc' => '[package.xml]
|
||||
Builds one or more extensions contained in a package.'
|
||||
),
|
||||
);
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Build constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Build(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doBuild()
|
||||
|
||||
function doBuild($command, $options, $params)
|
||||
{
|
||||
require_once 'PEAR/Builder.php';
|
||||
if (sizeof($params) < 1) {
|
||||
$params[0] = 'package.xml';
|
||||
}
|
||||
$builder = &new PEAR_Builder($this->ui);
|
||||
$this->debug = $this->config->get('verbose');
|
||||
$err = $builder->build($params[0], array(&$this, 'buildCallback'));
|
||||
if (PEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ buildCallback()
|
||||
|
||||
function buildCallback($what, $data)
|
||||
{
|
||||
if (($what == 'cmdoutput' && $this->debug > 1) ||
|
||||
($what == 'output' && $this->debug > 0)) {
|
||||
$this->ui->outputData(rtrim($data), 'build');
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
10
vendor/library/Excel/phpxls/PEAR/Command/Build.xml
vendored
Normal file
10
vendor/library/Excel/phpxls/PEAR/Command/Build.xml
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<commands version="1.0">
|
||||
<build>
|
||||
<summary>Build an Extension From C Source</summary>
|
||||
<function>doBuild</function>
|
||||
<shortcut>b</shortcut>
|
||||
<options />
|
||||
<doc>[package.xml]
|
||||
Builds one or more extensions contained in a package.</doc>
|
||||
</build>
|
||||
</commands>
|
||||
737
vendor/library/Excel/phpxls/PEAR/Command/Channels.php
vendored
Normal file
737
vendor/library/Excel/phpxls/PEAR/Command/Channels.php
vendored
Normal file
|
|
@ -0,0 +1,737 @@
|
|||
<?php
|
||||
// /* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
/**
|
||||
* PEAR_Command_Channels (list-channels, update-channels, channel-delete, channel-add,
|
||||
* channel-update, channel-info, channel-alias, channel-discover commands)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Channels.php,v 1.57 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
|
||||
/**
|
||||
* PEAR commands for managing channels.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a1
|
||||
*/
|
||||
class PEAR_Command_Channels extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'list-channels' => array(
|
||||
'summary' => 'List Available Channels',
|
||||
'function' => 'doList',
|
||||
'shortcut' => 'lc',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
List all available channels for installation.
|
||||
',
|
||||
),
|
||||
'update-channels' => array(
|
||||
'summary' => 'Update the Channel List',
|
||||
'function' => 'doUpdateAll',
|
||||
'shortcut' => 'uc',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
List all installed packages in all channels.
|
||||
'
|
||||
),
|
||||
'channel-delete' => array(
|
||||
'summary' => 'Remove a Channel From the List',
|
||||
'function' => 'doDelete',
|
||||
'shortcut' => 'cde',
|
||||
'options' => array(),
|
||||
'doc' => '<channel name>
|
||||
Delete a channel from the registry. You may not
|
||||
remove any channel that has installed packages.
|
||||
'
|
||||
),
|
||||
'channel-add' => array(
|
||||
'summary' => 'Add a Channel',
|
||||
'function' => 'doAdd',
|
||||
'shortcut' => 'ca',
|
||||
'options' => array(),
|
||||
'doc' => '<channel.xml>
|
||||
Add a private channel to the channel list. Note that all
|
||||
public channels should be synced using "update-channels".
|
||||
Parameter may be either a local file or remote URL to a
|
||||
channel.xml.
|
||||
'
|
||||
),
|
||||
'channel-update' => array(
|
||||
'summary' => 'Update an Existing Channel',
|
||||
'function' => 'doUpdate',
|
||||
'shortcut' => 'cu',
|
||||
'options' => array(
|
||||
'force' => array(
|
||||
'shortopt' => 'f',
|
||||
'doc' => 'will force download of new channel.xml if an existing channel name is used',
|
||||
),
|
||||
'channel' => array(
|
||||
'shortopt' => 'c',
|
||||
'arg' => 'CHANNEL',
|
||||
'doc' => 'will force download of new channel.xml if an existing channel name is used',
|
||||
),
|
||||
),
|
||||
'doc' => '[<channel.xml>|<channel name>]
|
||||
Update a channel in the channel list directly. Note that all
|
||||
public channels can be synced using "update-channels".
|
||||
Parameter may be a local or remote channel.xml, or the name of
|
||||
an existing channel.
|
||||
'
|
||||
),
|
||||
'channel-info' => array(
|
||||
'summary' => 'Retrieve Information on a Channel',
|
||||
'function' => 'doInfo',
|
||||
'shortcut' => 'ci',
|
||||
'options' => array(),
|
||||
'doc' => '<package>
|
||||
List the files in an installed package.
|
||||
'
|
||||
),
|
||||
'channel-alias' => array(
|
||||
'summary' => 'Specify an alias to a channel name',
|
||||
'function' => 'doAlias',
|
||||
'shortcut' => 'cha',
|
||||
'options' => array(),
|
||||
'doc' => '<channel> <alias>
|
||||
Specify a specific alias to use for a channel name.
|
||||
The alias may not be an existing channel name or
|
||||
alias.
|
||||
'
|
||||
),
|
||||
'channel-discover' => array(
|
||||
'summary' => 'Initialize a Channel from its server',
|
||||
'function' => 'doDiscover',
|
||||
'shortcut' => 'di',
|
||||
'options' => array(),
|
||||
'doc' => '[<channel.xml>|<channel name>]
|
||||
Initialize a channel from its server and create a local channel.xml.
|
||||
If <channel name> is in the format "<username>:<password>@<channel>" then
|
||||
<username> and <password> will be set as the login username/password for
|
||||
<channel>. Use caution when passing the username/password in this way, as
|
||||
it may allow other users on your computer to briefly view your username/
|
||||
password via the system\'s process list.
|
||||
'
|
||||
),
|
||||
);
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Registry constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Channels(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doList()
|
||||
|
||||
function _sortChannels($a, $b)
|
||||
{
|
||||
return strnatcasecmp($a->getName(), $b->getName());
|
||||
}
|
||||
|
||||
function doList($command, $options, $params)
|
||||
{
|
||||
$reg = &$this->config->getRegistry();
|
||||
$registered = $reg->getChannels();
|
||||
usort($registered, array(&$this, '_sortchannels'));
|
||||
$i = $j = 0;
|
||||
$data = array(
|
||||
'caption' => 'Registered Channels:',
|
||||
'border' => true,
|
||||
'headline' => array('Channel', 'Summary')
|
||||
);
|
||||
foreach ($registered as $channel) {
|
||||
$data['data'][] = array($channel->getName(),
|
||||
$channel->getSummary());
|
||||
}
|
||||
if (count($registered)==0) {
|
||||
$data = '(no registered channels)';
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
function doUpdateAll($command, $options, $params)
|
||||
{
|
||||
$reg = &$this->config->getRegistry();
|
||||
$channels = $reg->getChannels();
|
||||
|
||||
$success = true;
|
||||
foreach ($channels as $channel) {
|
||||
if ($channel->getName() != '__uri') {
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$err = $this->doUpdate('channel-update',
|
||||
$options,
|
||||
array($channel->getName()));
|
||||
if (PEAR::isError($err)) {
|
||||
$this->ui->outputData($err->getMessage(), $command);
|
||||
$success = false;
|
||||
} else {
|
||||
$success &= $err;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
function doInfo($command, $options, $params)
|
||||
{
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("No channel specified");
|
||||
}
|
||||
$reg = &$this->config->getRegistry();
|
||||
$channel = strtolower($params[0]);
|
||||
if ($reg->channelExists($channel)) {
|
||||
$chan = $reg->getChannel($channel);
|
||||
if (PEAR::isError($chan)) {
|
||||
return $this->raiseError($chan);
|
||||
}
|
||||
} else {
|
||||
if (strpos($channel, '://')) {
|
||||
$downloader = &$this->getDownloader();
|
||||
$tmpdir = $this->config->get('temp_dir');
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$loc = $downloader->downloadHttp($channel, $this->ui, $tmpdir);
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($loc)) {
|
||||
return $this->raiseError('Cannot open "' . $channel .
|
||||
'" (' . $loc->getMessage() . ')');
|
||||
} else {
|
||||
$contents = implode('', file($loc));
|
||||
}
|
||||
} else {
|
||||
if (file_exists($params[0])) {
|
||||
$fp = fopen($params[0], 'r');
|
||||
if (!$fp) {
|
||||
return $this->raiseError('Cannot open "' . $params[0] . '"');
|
||||
}
|
||||
} else {
|
||||
return $this->raiseError('Unknown channel "' . $channel . '"');
|
||||
}
|
||||
$contents = '';
|
||||
while (!feof($fp)) {
|
||||
$contents .= fread($fp, 1024);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
if (!class_exists('PEAR_ChannelFile')) {
|
||||
require_once 'PEAR/ChannelFile.php';
|
||||
}
|
||||
$chan = new PEAR_ChannelFile;
|
||||
$chan->fromXmlString($contents);
|
||||
$chan->validate();
|
||||
if ($errs = $chan->getErrors(true)) {
|
||||
foreach ($errs as $err) {
|
||||
$this->ui->outputData($err['level'] . ': ' . $err['message']);
|
||||
}
|
||||
return $this->raiseError('Channel file "' . $params[0] . '" is not valid');
|
||||
}
|
||||
}
|
||||
if ($chan) {
|
||||
$channel = $chan->getName();
|
||||
$caption = 'Channel ' . $channel . ' Information:';
|
||||
$data1 = array(
|
||||
'caption' => $caption,
|
||||
'border' => true);
|
||||
$data1['data']['server'] = array('Name and Server', $chan->getName());
|
||||
if ($chan->getAlias() != $chan->getName()) {
|
||||
$data1['data']['alias'] = array('Alias', $chan->getAlias());
|
||||
}
|
||||
$data1['data']['summary'] = array('Summary', $chan->getSummary());
|
||||
$validate = $chan->getValidationPackage();
|
||||
$data1['data']['vpackage'] = array('Validation Package Name', $validate['_content']);
|
||||
$data1['data']['vpackageversion'] =
|
||||
array('Validation Package Version', $validate['attribs']['version']);
|
||||
$d = array();
|
||||
$d['main'] = $data1;
|
||||
|
||||
$data['data'] = array();
|
||||
$data['caption'] = 'Server Capabilities';
|
||||
$data['headline'] = array('Type', 'Version/REST type', 'Function Name/REST base');
|
||||
$capabilities = $chan->getFunctions('xmlrpc');
|
||||
$soaps = $chan->getFunctions('soap');
|
||||
if ($capabilities || $soaps || $chan->supportsREST()) {
|
||||
if ($capabilities) {
|
||||
if (!isset($capabilities[0])) {
|
||||
$capabilities = array($capabilities);
|
||||
}
|
||||
foreach ($capabilities as $protocol) {
|
||||
$data['data'][] = array('xmlrpc', $protocol['attribs']['version'],
|
||||
$protocol['_content']);
|
||||
}
|
||||
}
|
||||
if ($soaps) {
|
||||
if (!isset($soaps[0])) {
|
||||
$soaps = array($soaps);
|
||||
}
|
||||
foreach ($soaps as $protocol) {
|
||||
$data['data'][] = array('soap', $protocol['attribs']['version'],
|
||||
$protocol['_content']);
|
||||
}
|
||||
}
|
||||
if ($chan->supportsREST()) {
|
||||
$funcs = $chan->getFunctions('rest');
|
||||
if (!isset($funcs[0])) {
|
||||
$funcs = array($funcs);
|
||||
}
|
||||
foreach ($funcs as $protocol) {
|
||||
$data['data'][] = array('rest', $protocol['attribs']['type'],
|
||||
$protocol['_content']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data['data'][] = array('No supported protocols');
|
||||
}
|
||||
$d['protocols'] = $data;
|
||||
$data['data'] = array();
|
||||
$mirrors = $chan->getMirrors();
|
||||
if ($mirrors) {
|
||||
$data['caption'] = 'Channel ' . $channel . ' Mirrors:';
|
||||
unset($data['headline']);
|
||||
foreach ($mirrors as $mirror) {
|
||||
$data['data'][] = array($mirror['attribs']['host']);
|
||||
$d['mirrors'] = $data;
|
||||
}
|
||||
foreach ($mirrors as $i => $mirror) {
|
||||
$data['data'] = array();
|
||||
$data['caption'] = 'Mirror ' . $mirror['attribs']['host'] . ' Capabilities';
|
||||
$data['headline'] = array('Type', 'Version/REST type', 'Function Name/REST base');
|
||||
$capabilities = $chan->getFunctions('xmlrpc', $mirror['attribs']['host']);
|
||||
$soaps = $chan->getFunctions('soap', $mirror['attribs']['host']);
|
||||
if ($capabilities || $soaps || $chan->supportsREST($mirror['attribs']['host'])) {
|
||||
if ($capabilities) {
|
||||
if (!isset($capabilities[0])) {
|
||||
$capabilities = array($capabilities);
|
||||
}
|
||||
foreach ($capabilities as $protocol) {
|
||||
$data['data'][] = array('xmlrpc', $protocol['attribs']['version'],
|
||||
$protocol['_content']);
|
||||
}
|
||||
}
|
||||
if ($soaps) {
|
||||
if (!isset($soaps[0])) {
|
||||
$soaps = array($soaps);
|
||||
}
|
||||
foreach ($soaps as $protocol) {
|
||||
$data['data'][] = array('soap', $protocol['attribs']['version'],
|
||||
$protocol['_content']);
|
||||
}
|
||||
}
|
||||
if ($chan->supportsREST($mirror['attribs']['host'])) {
|
||||
$funcs = $chan->getFunctions('rest', $mirror['attribs']['host']);
|
||||
if (!isset($funcs[0])) {
|
||||
$funcs = array($funcs);
|
||||
}
|
||||
foreach ($funcs as $protocol) {
|
||||
$data['data'][] = array('rest', $protocol['attribs']['type'],
|
||||
$protocol['_content']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data['data'][] = array('No supported protocols');
|
||||
}
|
||||
$d['mirrorprotocols' . $i] = $data;
|
||||
}
|
||||
}
|
||||
$this->ui->outputData($d, 'channel-info');
|
||||
} else {
|
||||
return $this->raiseError('Serious error: Channel "' . $params[0] .
|
||||
'" has a corrupted registry entry');
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
function doDelete($command, $options, $params)
|
||||
{
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError('channel-delete: no channel specified');
|
||||
}
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (!$reg->channelExists($params[0])) {
|
||||
return $this->raiseError('channel-delete: channel "' . $params[0] . '" does not exist');
|
||||
}
|
||||
$channel = $reg->channelName($params[0]);
|
||||
if ($channel == 'pear.php.net') {
|
||||
return $this->raiseError('Cannot delete the pear.php.net channel');
|
||||
}
|
||||
if ($channel == 'pecl.php.net') {
|
||||
return $this->raiseError('Cannot delete the pecl.php.net channel');
|
||||
}
|
||||
if ($channel == '__uri') {
|
||||
return $this->raiseError('Cannot delete the __uri pseudo-channel');
|
||||
}
|
||||
if (PEAR::isError($err = $reg->listPackages($channel))) {
|
||||
return $err;
|
||||
}
|
||||
if (count($err)) {
|
||||
return $this->raiseError('Channel "' . $channel .
|
||||
'" has installed packages, cannot delete');
|
||||
}
|
||||
if (!$reg->deleteChannel($channel)) {
|
||||
return $this->raiseError('Channel "' . $channel . '" deletion failed');
|
||||
} else {
|
||||
$this->config->deleteChannel($channel);
|
||||
$this->ui->outputData('Channel "' . $channel . '" deleted', $command);
|
||||
}
|
||||
}
|
||||
|
||||
function doAdd($command, $options, $params)
|
||||
{
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError('channel-add: no channel file specified');
|
||||
}
|
||||
if (strpos($params[0], '://')) {
|
||||
$downloader = &$this->getDownloader();
|
||||
$tmpdir = $this->config->get('temp_dir');
|
||||
if (!file_exists($tmpdir)) {
|
||||
require_once 'System.php';
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$err = System::mkdir(array('-p', $tmpdir));
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($err)) {
|
||||
return $this->raiseError('channel-add: temp_dir does not exist: "' .
|
||||
$tmpdir .
|
||||
'" - You can change this location with "pear config-set temp_dir"');
|
||||
}
|
||||
}
|
||||
if (!is_writable($tmpdir)) {
|
||||
return $this->raiseError('channel-add: temp_dir is not writable: "' .
|
||||
$tmpdir .
|
||||
'" - You can change this location with "pear config-set temp_dir"');
|
||||
}
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$loc = $downloader->downloadHttp($params[0], $this->ui, $tmpdir, null, false);
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($loc)) {
|
||||
return $this->raiseError('channel-add: Cannot open "' . $params[0] .
|
||||
'" (' . $loc->getMessage() . ')');
|
||||
} else {
|
||||
list($loc, $lastmodified) = $loc;
|
||||
$contents = implode('', file($loc));
|
||||
}
|
||||
} else {
|
||||
$lastmodified = $fp = false;
|
||||
if (file_exists($params[0])) {
|
||||
$fp = fopen($params[0], 'r');
|
||||
}
|
||||
if (!$fp) {
|
||||
return $this->raiseError('channel-add: cannot open "' . $params[0] . '"');
|
||||
}
|
||||
$contents = '';
|
||||
while (!feof($fp)) {
|
||||
$contents .= fread($fp, 1024);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
if (!class_exists('PEAR_ChannelFile')) {
|
||||
require_once 'PEAR/ChannelFile.php';
|
||||
}
|
||||
$channel = new PEAR_ChannelFile;
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$result = $channel->fromXmlString($contents);
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (!$result) {
|
||||
$exit = false;
|
||||
if (count($errors = $channel->getErrors(true))) {
|
||||
foreach ($errors as $error) {
|
||||
$this->ui->outputData(ucfirst($error['level'] . ': ' . $error['message']));
|
||||
if (!$exit) {
|
||||
$exit = $error['level'] == 'error' ? true : false;
|
||||
}
|
||||
}
|
||||
if ($exit) {
|
||||
return $this->raiseError('channel-add: invalid channel.xml file');
|
||||
}
|
||||
}
|
||||
}
|
||||
$reg = &$this->config->getRegistry();
|
||||
if ($reg->channelExists($channel->getName())) {
|
||||
return $this->raiseError('channel-add: Channel "' . $channel->getName() .
|
||||
'" exists, use channel-update to update entry');
|
||||
}
|
||||
$ret = $reg->addChannel($channel, $lastmodified);
|
||||
if (PEAR::isError($ret)) {
|
||||
return $ret;
|
||||
}
|
||||
if (!$ret) {
|
||||
return $this->raiseError('channel-add: adding Channel "' . $channel->getName() .
|
||||
'" to registry failed');
|
||||
}
|
||||
$this->config->setChannels($reg->listChannels());
|
||||
$this->config->writeConfigFile();
|
||||
$this->ui->outputData('Adding Channel "' . $channel->getName() . '" succeeded', $command);
|
||||
}
|
||||
|
||||
function doUpdate($command, $options, $params)
|
||||
{
|
||||
$tmpdir = $this->config->get('temp_dir');
|
||||
if (!file_exists($tmpdir)) {
|
||||
require_once 'System.php';
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$err = System::mkdir(array('-p', $tmpdir));
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($err)) {
|
||||
return $this->raiseError('channel-add: temp_dir does not exist: "' .
|
||||
$tmpdir .
|
||||
'" - You can change this location with "pear config-set temp_dir"');
|
||||
}
|
||||
}
|
||||
if (!is_writable($tmpdir)) {
|
||||
return $this->raiseError('channel-add: temp_dir is not writable: "' .
|
||||
$tmpdir .
|
||||
'" - You can change this location with "pear config-set temp_dir"');
|
||||
}
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("No channel file specified");
|
||||
}
|
||||
$lastmodified = false;
|
||||
if ((!file_exists($params[0]) || is_dir($params[0]))
|
||||
&& $reg->channelExists(strtolower($params[0]))) {
|
||||
$c = $reg->getChannel(strtolower($params[0]));
|
||||
if (PEAR::isError($c)) {
|
||||
return $this->raiseError($c);
|
||||
}
|
||||
$this->ui->outputData("Updating channel \"$params[0]\"", $command);
|
||||
$dl = &$this->getDownloader(array());
|
||||
// if force is specified, use a timestamp of "1" to force retrieval
|
||||
$lastmodified = isset($options['force']) ? false : $c->lastModified();
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$contents = $dl->downloadHttp('http://' . $c->getName() . '/channel.xml',
|
||||
$this->ui, $tmpdir, null, $lastmodified);
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($contents)) {
|
||||
return $this->raiseError('Cannot retrieve channel.xml for channel "' .
|
||||
$c->getName() . '" (' . $contents->getMessage() . ')');
|
||||
}
|
||||
list($contents, $lastmodified) = $contents;
|
||||
if (!$contents) {
|
||||
$this->ui->outputData("Channel \"$params[0]\" is up to date");
|
||||
return;
|
||||
}
|
||||
$contents = implode('', file($contents));
|
||||
if (!class_exists('PEAR_ChannelFile')) {
|
||||
require_once 'PEAR/ChannelFile.php';
|
||||
}
|
||||
$channel = new PEAR_ChannelFile;
|
||||
$channel->fromXmlString($contents);
|
||||
if (!$channel->getErrors()) {
|
||||
// security check: is the downloaded file for the channel we got it from?
|
||||
if (strtolower($channel->getName()) != strtolower($c->getName())) {
|
||||
if (isset($options['force'])) {
|
||||
$this->ui->log(0, 'WARNING: downloaded channel definition file' .
|
||||
' for channel "' . $channel->getName() . '" from channel "' .
|
||||
strtolower($c->getName()) . '"');
|
||||
} else {
|
||||
return $this->raiseError('ERROR: downloaded channel definition file' .
|
||||
' for channel "' . $channel->getName() . '" from channel "' .
|
||||
strtolower($c->getName()) . '"');
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (strpos($params[0], '://')) {
|
||||
$dl = &$this->getDownloader();
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$loc = $dl->downloadHttp($params[0],
|
||||
$this->ui, $tmpdir, null, $lastmodified);
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($loc)) {
|
||||
return $this->raiseError("Cannot open " . $params[0] .
|
||||
' (' . $loc->getMessage() . ')');
|
||||
} else {
|
||||
list($loc, $lastmodified) = $loc;
|
||||
$contents = implode('', file($loc));
|
||||
}
|
||||
} else {
|
||||
$fp = false;
|
||||
if (file_exists($params[0])) {
|
||||
$fp = fopen($params[0], 'r');
|
||||
}
|
||||
if (!$fp) {
|
||||
return $this->raiseError("Cannot open " . $params[0]);
|
||||
}
|
||||
$contents = '';
|
||||
while (!feof($fp)) {
|
||||
$contents .= fread($fp, 1024);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
if (!class_exists('PEAR_ChannelFile')) {
|
||||
require_once 'PEAR/ChannelFile.php';
|
||||
}
|
||||
$channel = new PEAR_ChannelFile;
|
||||
$channel->fromXmlString($contents);
|
||||
}
|
||||
$exit = false;
|
||||
if (count($errors = $channel->getErrors(true))) {
|
||||
foreach ($errors as $error) {
|
||||
$this->ui->outputData(ucfirst($error['level'] . ': ' . $error['message']));
|
||||
if (!$exit) {
|
||||
$exit = $error['level'] == 'error' ? true : false;
|
||||
}
|
||||
}
|
||||
if ($exit) {
|
||||
return $this->raiseError('Invalid channel.xml file');
|
||||
}
|
||||
}
|
||||
if (!$reg->channelExists($channel->getName())) {
|
||||
return $this->raiseError('Error: Channel "' . $channel->getName() .
|
||||
'" does not exist, use channel-add to add an entry');
|
||||
}
|
||||
$ret = $reg->updateChannel($channel, $lastmodified);
|
||||
if (PEAR::isError($ret)) {
|
||||
return $ret;
|
||||
}
|
||||
if (!$ret) {
|
||||
return $this->raiseError('Updating Channel "' . $channel->getName() .
|
||||
'" in registry failed');
|
||||
}
|
||||
$this->config->setChannels($reg->listChannels());
|
||||
$this->config->writeConfigFile();
|
||||
$this->ui->outputData('Update of Channel "' . $channel->getName() . '" succeeded');
|
||||
}
|
||||
|
||||
function &getDownloader()
|
||||
{
|
||||
if (!class_exists('PEAR_Downloader')) {
|
||||
require_once 'PEAR/Downloader.php';
|
||||
}
|
||||
$a = new PEAR_Downloader($this->ui, array(), $this->config);
|
||||
return $a;
|
||||
}
|
||||
|
||||
function doAlias($command, $options, $params)
|
||||
{
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (sizeof($params) == 1) {
|
||||
return $this->raiseError('No channel alias specified');
|
||||
}
|
||||
if (sizeof($params) != 2) {
|
||||
return $this->raiseError(
|
||||
'Invalid format, correct is: channel-alias channel alias');
|
||||
}
|
||||
if (!$reg->channelExists($params[0], true)) {
|
||||
if ($reg->isAlias($params[0])) {
|
||||
$extra = ' (use "channel-alias ' . $reg->channelName($params[0]) . ' ' .
|
||||
strtolower($params[1]) . '")';
|
||||
} else {
|
||||
$extra = '';
|
||||
}
|
||||
return $this->raiseError('"' . $params[0] . '" is not a valid channel' . $extra);
|
||||
}
|
||||
if ($reg->isAlias($params[1])) {
|
||||
return $this->raiseError('Channel "' . $reg->channelName($params[1]) . '" is ' .
|
||||
'already aliased to "' . strtolower($params[1]) . '", cannot re-alias');
|
||||
}
|
||||
$chan = &$reg->getChannel($params[0]);
|
||||
if (PEAR::isError($chan)) {
|
||||
return $this->raiseError('Corrupt registry? Error retrieving channel "' . $params[0] .
|
||||
'" information (' . $chan->getMessage() . ')');
|
||||
}
|
||||
// make it a local alias
|
||||
if (!$chan->setAlias(strtolower($params[1]), true)) {
|
||||
return $this->raiseError('Alias "' . strtolower($params[1]) .
|
||||
'" is not a valid channel alias');
|
||||
}
|
||||
$reg->updateChannel($chan);
|
||||
$this->ui->outputData('Channel "' . $chan->getName() . '" aliased successfully to "' .
|
||||
strtolower($params[1]) . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
* The channel-discover command
|
||||
*
|
||||
* @param string $command command name
|
||||
* @param array $options option_name => value
|
||||
* @param array $params list of additional parameters.
|
||||
* $params[0] should contain a string with either:
|
||||
* - <channel name> or
|
||||
* - <username>:<password>@<channel name>
|
||||
* @return null|PEAR_Error
|
||||
*/
|
||||
function doDiscover($command, $options, $params)
|
||||
{
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("No channel server specified");
|
||||
}
|
||||
|
||||
// Look for the possible input format "<username>:<password>@<channel>"
|
||||
if (preg_match('/^(.+):(.+)@(.+)\\z/', $params[0], $matches)) {
|
||||
$username = $matches[1];
|
||||
$password = $matches[2];
|
||||
$channel = $matches[3];
|
||||
} else {
|
||||
$channel = $params[0];
|
||||
}
|
||||
|
||||
if ($reg->channelExists($channel)) {
|
||||
if ($reg->isAlias($channel)) {
|
||||
return $this->raiseError("A channel alias named \"$channel\" " .
|
||||
'already exists, aliasing channel "' . $reg->channelName($channel)
|
||||
. '"');
|
||||
} else {
|
||||
return $this->raiseError("Channel \"$channel\" is already initialized");
|
||||
}
|
||||
}
|
||||
$this->pushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$err = $this->doAdd($command, $options, array('http://' . $channel . '/channel.xml'));
|
||||
$this->popErrorHandling();
|
||||
if (PEAR::isError($err)) {
|
||||
return $this->raiseError("Discovery of channel \"$channel\" failed (" .
|
||||
$err->getMessage() . ')');
|
||||
}
|
||||
|
||||
// Store username/password if they were given
|
||||
// Arguably we should do a logintest on the channel here, but since
|
||||
// that's awkward on a REST-based channel (even "pear login" doesn't
|
||||
// do it for those), and XML-RPC is deprecated, it's fairly pointless.
|
||||
if (isset($username)) {
|
||||
$this->config->set('username', $username, 'user', $channel);
|
||||
$this->config->set('password', $password, 'user', $channel);
|
||||
$this->config->store();
|
||||
$this->ui->outputData("Stored login for channel \"$channel\" using username \"$username\"", $command);
|
||||
}
|
||||
|
||||
$this->ui->outputData("Discovery of channel \"$channel\" succeeded", $command);
|
||||
}
|
||||
}
|
||||
?>
|
||||
98
vendor/library/Excel/phpxls/PEAR/Command/Channels.xml
vendored
Normal file
98
vendor/library/Excel/phpxls/PEAR/Command/Channels.xml
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<commands version="1.0">
|
||||
<list-channels>
|
||||
<summary>List Available Channels</summary>
|
||||
<function>doList</function>
|
||||
<shortcut>lc</shortcut>
|
||||
<options />
|
||||
<doc>
|
||||
List all available channels for installation.
|
||||
</doc>
|
||||
</list-channels>
|
||||
<update-channels>
|
||||
<summary>Update the Channel List</summary>
|
||||
<function>doUpdateAll</function>
|
||||
<shortcut>uc</shortcut>
|
||||
<options />
|
||||
<doc>
|
||||
List all installed packages in all channels.
|
||||
</doc>
|
||||
</update-channels>
|
||||
<channel-delete>
|
||||
<summary>Remove a Channel From the List</summary>
|
||||
<function>doDelete</function>
|
||||
<shortcut>cde</shortcut>
|
||||
<options />
|
||||
<doc><channel name>
|
||||
Delete a channel from the registry. You may not
|
||||
remove any channel that has installed packages.
|
||||
</doc>
|
||||
</channel-delete>
|
||||
<channel-add>
|
||||
<summary>Add a Channel</summary>
|
||||
<function>doAdd</function>
|
||||
<shortcut>ca</shortcut>
|
||||
<options />
|
||||
<doc><channel.xml>
|
||||
Add a private channel to the channel list. Note that all
|
||||
public channels should be synced using "update-channels".
|
||||
Parameter may be either a local file or remote URL to a
|
||||
channel.xml.
|
||||
</doc>
|
||||
</channel-add>
|
||||
<channel-update>
|
||||
<summary>Update an Existing Channel</summary>
|
||||
<function>doUpdate</function>
|
||||
<shortcut>cu</shortcut>
|
||||
<options>
|
||||
<force>
|
||||
<shortopt>f</shortopt>
|
||||
<doc>will force download of new channel.xml if an existing channel name is used</doc>
|
||||
</force>
|
||||
<channel>
|
||||
<shortopt>c</shortopt>
|
||||
<arg>CHANNEL</arg>
|
||||
<doc>will force download of new channel.xml if an existing channel name is used</doc>
|
||||
</channel>
|
||||
</options>
|
||||
<doc>[<channel.xml>|<channel name>]
|
||||
Update a channel in the channel list directly. Note that all
|
||||
public channels can be synced using "update-channels".
|
||||
Parameter may be a local or remote channel.xml, or the name of
|
||||
an existing channel.
|
||||
</doc>
|
||||
</channel-update>
|
||||
<channel-info>
|
||||
<summary>Retrieve Information on a Channel</summary>
|
||||
<function>doInfo</function>
|
||||
<shortcut>ci</shortcut>
|
||||
<options />
|
||||
<doc><package>
|
||||
List the files in an installed package.
|
||||
</doc>
|
||||
</channel-info>
|
||||
<channel-alias>
|
||||
<summary>Specify an alias to a channel name</summary>
|
||||
<function>doAlias</function>
|
||||
<shortcut>cha</shortcut>
|
||||
<options />
|
||||
<doc><channel> <alias>
|
||||
Specify a specific alias to use for a channel name.
|
||||
The alias may not be an existing channel name or
|
||||
alias.
|
||||
</doc>
|
||||
</channel-alias>
|
||||
<channel-discover>
|
||||
<summary>Initialize a Channel from its server</summary>
|
||||
<function>doDiscover</function>
|
||||
<shortcut>di</shortcut>
|
||||
<options />
|
||||
<doc>[<channel.xml>|<channel name>]
|
||||
Initialize a channel from its server and create a local channel.xml.
|
||||
If <channel name> is in the format "<username>:<password>@<channel>" then
|
||||
<username> and <password> will be set as the login username/password for
|
||||
<channel>. Use caution when passing the username/password in this way, as
|
||||
it may allow other users on your computer to briefly view your username/
|
||||
password via the system's process list.
|
||||
</doc>
|
||||
</channel-discover>
|
||||
</commands>
|
||||
291
vendor/library/Excel/phpxls/PEAR/Command/Common.php
vendored
Normal file
291
vendor/library/Excel/phpxls/PEAR/Command/Common.php
vendored
Normal file
|
|
@ -0,0 +1,291 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Command_Common base class
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Common.php,v 1.36 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR.php';
|
||||
|
||||
/**
|
||||
* PEAR commands base class
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
class PEAR_Command_Common extends PEAR
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
/**
|
||||
* PEAR_Config object used to pass user system and configuration
|
||||
* on when executing commands
|
||||
*
|
||||
* @var PEAR_Config
|
||||
*/
|
||||
var $config;
|
||||
/**
|
||||
* @var PEAR_Registry
|
||||
* @access protected
|
||||
*/
|
||||
var $_registry;
|
||||
|
||||
/**
|
||||
* User Interface object, for all interaction with the user.
|
||||
* @var object
|
||||
*/
|
||||
var $ui;
|
||||
|
||||
var $_deps_rel_trans = array(
|
||||
'lt' => '<',
|
||||
'le' => '<=',
|
||||
'eq' => '=',
|
||||
'ne' => '!=',
|
||||
'gt' => '>',
|
||||
'ge' => '>=',
|
||||
'has' => '=='
|
||||
);
|
||||
|
||||
var $_deps_type_trans = array(
|
||||
'pkg' => 'package',
|
||||
'ext' => 'extension',
|
||||
'php' => 'PHP',
|
||||
'prog' => 'external program',
|
||||
'ldlib' => 'external library for linking',
|
||||
'rtlib' => 'external runtime library',
|
||||
'os' => 'operating system',
|
||||
'websrv' => 'web server',
|
||||
'sapi' => 'SAPI backend'
|
||||
);
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Common constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Common(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR();
|
||||
$this->config = &$config;
|
||||
$this->ui = &$ui;
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ getCommands()
|
||||
|
||||
/**
|
||||
* Return a list of all the commands defined by this class.
|
||||
* @return array list of commands
|
||||
* @access public
|
||||
*/
|
||||
function getCommands()
|
||||
{
|
||||
$ret = array();
|
||||
foreach (array_keys($this->commands) as $command) {
|
||||
$ret[$command] = $this->commands[$command]['summary'];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getShortcuts()
|
||||
|
||||
/**
|
||||
* Return a list of all the command shortcuts defined by this class.
|
||||
* @return array shortcut => command
|
||||
* @access public
|
||||
*/
|
||||
function getShortcuts()
|
||||
{
|
||||
$ret = array();
|
||||
foreach (array_keys($this->commands) as $command) {
|
||||
if (isset($this->commands[$command]['shortcut'])) {
|
||||
$ret[$this->commands[$command]['shortcut']] = $command;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getOptions()
|
||||
|
||||
function getOptions($command)
|
||||
{
|
||||
$shortcuts = $this->getShortcuts();
|
||||
if (isset($shortcuts[$command])) {
|
||||
$command = $shortcuts[$command];
|
||||
}
|
||||
if (isset($this->commands[$command]) &&
|
||||
isset($this->commands[$command]['options'])) {
|
||||
return $this->commands[$command]['options'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getGetoptArgs()
|
||||
|
||||
function getGetoptArgs($command, &$short_args, &$long_args)
|
||||
{
|
||||
$short_args = "";
|
||||
$long_args = array();
|
||||
if (empty($this->commands[$command]) || empty($this->commands[$command]['options'])) {
|
||||
return;
|
||||
}
|
||||
reset($this->commands[$command]['options']);
|
||||
while (list($option, $info) = each($this->commands[$command]['options'])) {
|
||||
$larg = $sarg = '';
|
||||
if (isset($info['arg'])) {
|
||||
if ($info['arg']{0} == '(') {
|
||||
$larg = '==';
|
||||
$sarg = '::';
|
||||
$arg = substr($info['arg'], 1, -1);
|
||||
} else {
|
||||
$larg = '=';
|
||||
$sarg = ':';
|
||||
$arg = $info['arg'];
|
||||
}
|
||||
}
|
||||
if (isset($info['shortopt'])) {
|
||||
$short_args .= $info['shortopt'] . $sarg;
|
||||
}
|
||||
$long_args[] = $option . $larg;
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getHelp()
|
||||
/**
|
||||
* Returns the help message for the given command
|
||||
*
|
||||
* @param string $command The command
|
||||
* @return mixed A fail string if the command does not have help or
|
||||
* a two elements array containing [0]=>help string,
|
||||
* [1]=> help string for the accepted cmd args
|
||||
*/
|
||||
function getHelp($command)
|
||||
{
|
||||
$config = &PEAR_Config::singleton();
|
||||
if (!isset($this->commands[$command])) {
|
||||
return "No such command \"$command\"";
|
||||
}
|
||||
$help = null;
|
||||
if (isset($this->commands[$command]['doc'])) {
|
||||
$help = $this->commands[$command]['doc'];
|
||||
}
|
||||
if (empty($help)) {
|
||||
// XXX (cox) Fallback to summary if there is no doc (show both?)
|
||||
if (!isset($this->commands[$command]['summary'])) {
|
||||
return "No help for command \"$command\"";
|
||||
}
|
||||
$help = $this->commands[$command]['summary'];
|
||||
}
|
||||
if (preg_match_all('/{config\s+([^\}]+)}/e', $help, $matches)) {
|
||||
foreach($matches[0] as $k => $v) {
|
||||
$help = preg_replace("/$v/", $config->get($matches[1][$k]), $help);
|
||||
}
|
||||
}
|
||||
return array($help, $this->getHelpArgs($command));
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getHelpArgs()
|
||||
/**
|
||||
* Returns the help for the accepted arguments of a command
|
||||
*
|
||||
* @param string $command
|
||||
* @return string The help string
|
||||
*/
|
||||
function getHelpArgs($command)
|
||||
{
|
||||
if (isset($this->commands[$command]['options']) &&
|
||||
count($this->commands[$command]['options']))
|
||||
{
|
||||
$help = "Options:\n";
|
||||
foreach ($this->commands[$command]['options'] as $k => $v) {
|
||||
if (isset($v['arg'])) {
|
||||
if ($v['arg'][0] == '(') {
|
||||
$arg = substr($v['arg'], 1, -1);
|
||||
$sapp = " [$arg]";
|
||||
$lapp = "[=$arg]";
|
||||
} else {
|
||||
$sapp = " $v[arg]";
|
||||
$lapp = "=$v[arg]";
|
||||
}
|
||||
} else {
|
||||
$sapp = $lapp = "";
|
||||
}
|
||||
if (isset($v['shortopt'])) {
|
||||
$s = $v['shortopt'];
|
||||
$help .= " -$s$sapp, --$k$lapp\n";
|
||||
} else {
|
||||
$help .= " --$k$lapp\n";
|
||||
}
|
||||
$p = " ";
|
||||
$doc = rtrim(str_replace("\n", "\n$p", $v['doc']));
|
||||
$help .= " $doc\n";
|
||||
}
|
||||
return $help;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ run()
|
||||
|
||||
function run($command, $options, $params)
|
||||
{
|
||||
if (empty($this->commands[$command]['function'])) {
|
||||
// look for shortcuts
|
||||
foreach (array_keys($this->commands) as $cmd) {
|
||||
if (isset($this->commands[$cmd]['shortcut']) && $this->commands[$cmd]['shortcut'] == $command) {
|
||||
if (empty($this->commands[$cmd]['function'])) {
|
||||
return $this->raiseError("unknown command `$command'");
|
||||
} else {
|
||||
$func = $this->commands[$cmd]['function'];
|
||||
}
|
||||
$command = $cmd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$func = $this->commands[$command]['function'];
|
||||
}
|
||||
return $this->$func($command, $options, $params);
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
422
vendor/library/Excel/phpxls/PEAR/Command/Config.php
vendored
Normal file
422
vendor/library/Excel/phpxls/PEAR/Command/Config.php
vendored
Normal file
|
|
@ -0,0 +1,422 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Command_Config (config-show, config-get, config-set, config-help, config-create commands)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Config.php,v 1.56 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
|
||||
/**
|
||||
* PEAR commands for managing configuration data.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
class PEAR_Command_Config extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'config-show' => array(
|
||||
'summary' => 'Show All Settings',
|
||||
'function' => 'doConfigShow',
|
||||
'shortcut' => 'csh',
|
||||
'options' => array(
|
||||
'channel' => array(
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'show configuration variables for another channel',
|
||||
'arg' => 'CHAN',
|
||||
),
|
||||
),
|
||||
'doc' => '[layer]
|
||||
Displays all configuration values. An optional argument
|
||||
may be used to tell which configuration layer to display. Valid
|
||||
configuration layers are "user", "system" and "default". To display
|
||||
configurations for different channels, set the default_channel
|
||||
configuration variable and run config-show again.
|
||||
',
|
||||
),
|
||||
'config-get' => array(
|
||||
'summary' => 'Show One Setting',
|
||||
'function' => 'doConfigGet',
|
||||
'shortcut' => 'cg',
|
||||
'options' => array(
|
||||
'channel' => array(
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'show configuration variables for another channel',
|
||||
'arg' => 'CHAN',
|
||||
),
|
||||
),
|
||||
'doc' => '<parameter> [layer]
|
||||
Displays the value of one configuration parameter. The
|
||||
first argument is the name of the parameter, an optional second argument
|
||||
may be used to tell which configuration layer to look in. Valid configuration
|
||||
layers are "user", "system" and "default". If no layer is specified, a value
|
||||
will be picked from the first layer that defines the parameter, in the order
|
||||
just specified. The configuration value will be retrieved for the channel
|
||||
specified by the default_channel configuration variable.
|
||||
',
|
||||
),
|
||||
'config-set' => array(
|
||||
'summary' => 'Change Setting',
|
||||
'function' => 'doConfigSet',
|
||||
'shortcut' => 'cs',
|
||||
'options' => array(
|
||||
'channel' => array(
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'show configuration variables for another channel',
|
||||
'arg' => 'CHAN',
|
||||
),
|
||||
),
|
||||
'doc' => '<parameter> <value> [layer]
|
||||
Sets the value of one configuration parameter. The first argument is
|
||||
the name of the parameter, the second argument is the new value. Some
|
||||
parameters are subject to validation, and the command will fail with
|
||||
an error message if the new value does not make sense. An optional
|
||||
third argument may be used to specify in which layer to set the
|
||||
configuration parameter. The default layer is "user". The
|
||||
configuration value will be set for the current channel, which
|
||||
is controlled by the default_channel configuration variable.
|
||||
',
|
||||
),
|
||||
'config-help' => array(
|
||||
'summary' => 'Show Information About Setting',
|
||||
'function' => 'doConfigHelp',
|
||||
'shortcut' => 'ch',
|
||||
'options' => array(),
|
||||
'doc' => '[parameter]
|
||||
Displays help for a configuration parameter. Without arguments it
|
||||
displays help for all configuration parameters.
|
||||
',
|
||||
),
|
||||
'config-create' => array(
|
||||
'summary' => 'Create a Default configuration file',
|
||||
'function' => 'doConfigCreate',
|
||||
'shortcut' => 'coc',
|
||||
'options' => array(
|
||||
'windows' => array(
|
||||
'shortopt' => 'w',
|
||||
'doc' => 'create a config file for a windows install',
|
||||
),
|
||||
),
|
||||
'doc' => '<root path> <filename>
|
||||
Create a default configuration file with all directory configuration
|
||||
variables set to subdirectories of <root path>, and save it as <filename>.
|
||||
This is useful especially for creating a configuration file for a remote
|
||||
PEAR installation (using the --remoteconfig option of install, upgrade,
|
||||
and uninstall).
|
||||
',
|
||||
),
|
||||
);
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Config constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Config(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ doConfigShow()
|
||||
|
||||
function doConfigShow($command, $options, $params)
|
||||
{
|
||||
if (is_array($params)) {
|
||||
$layer = isset($params[0]) ? $params[0] : NULL;
|
||||
} else {
|
||||
$layer = NULL;
|
||||
}
|
||||
|
||||
// $params[0] -> the layer
|
||||
if ($error = $this->_checkLayer($layer)) {
|
||||
return $this->raiseError("config-show:$error");
|
||||
}
|
||||
$keys = $this->config->getKeys();
|
||||
sort($keys);
|
||||
$channel = isset($options['channel']) ? $options['channel'] :
|
||||
$this->config->get('default_channel');
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (!$reg->channelExists($channel)) {
|
||||
return $this->raiseError('Channel "' . $channel . '" does not exist');
|
||||
}
|
||||
$data = array('caption' => 'Configuration (channel ' . $channel . '):');
|
||||
foreach ($keys as $key) {
|
||||
$type = $this->config->getType($key);
|
||||
$value = $this->config->get($key, $layer, $channel);
|
||||
if ($type == 'password' && $value) {
|
||||
$value = '********';
|
||||
}
|
||||
if ($value === false) {
|
||||
$value = 'false';
|
||||
} elseif ($value === true) {
|
||||
$value = 'true';
|
||||
}
|
||||
$data['data'][$this->config->getGroup($key)][] = array($this->config->getPrompt($key) , $key, $value);
|
||||
}
|
||||
foreach ($this->config->getLayers() as $layer) {
|
||||
$data['data']['Config Files'][] = array(ucfirst($layer) . ' Configuration File', 'Filename' , $this->config->getConfFile($layer));
|
||||
}
|
||||
|
||||
$this->ui->outputData($data, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doConfigGet()
|
||||
|
||||
function doConfigGet($command, $options, $params)
|
||||
{
|
||||
if (!is_array($params)) {
|
||||
$args_cnt = 0;
|
||||
} else {
|
||||
$args_cnt = count($params);
|
||||
}
|
||||
|
||||
switch ($args_cnt) {
|
||||
case 1:
|
||||
$config_key = $params[0];
|
||||
$layer = NULL;
|
||||
break;
|
||||
case 2:
|
||||
$config_key = $params[0];
|
||||
$layer = $params[1];
|
||||
if ($error = $this->_checkLayer($layer)) {
|
||||
return $this->raiseError("config-get:$error");
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
return $this->raiseError("config-get expects 1 or 2 parameters");
|
||||
}
|
||||
|
||||
$channel = isset($options['channel']) ? $options['channel'] : $this->config->get('default_channel');
|
||||
$reg = &$this->config->getRegistry();
|
||||
|
||||
if (!$reg->channelExists($channel)) {
|
||||
return $this->raiseError('Channel "' . $channel . '" does not exist');
|
||||
}
|
||||
|
||||
$this->ui->outputData($this->config->get($config_key, $layer, $channel), $command);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doConfigSet()
|
||||
|
||||
function doConfigSet($command, $options, $params)
|
||||
{
|
||||
// $param[0] -> a parameter to set
|
||||
// $param[1] -> the value for the parameter
|
||||
// $param[2] -> the layer
|
||||
$failmsg = '';
|
||||
if (sizeof($params) < 2 || sizeof($params) > 3) {
|
||||
$failmsg .= "config-set expects 2 or 3 parameters";
|
||||
return PEAR::raiseError($failmsg);
|
||||
}
|
||||
if (isset($params[2]) && ($error = $this->_checkLayer($params[2]))) {
|
||||
$failmsg .= $error;
|
||||
return PEAR::raiseError("config-set:$failmsg");
|
||||
}
|
||||
$channel = isset($options['channel']) ? $options['channel'] :
|
||||
$this->config->get('default_channel');
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (!$reg->channelExists($channel)) {
|
||||
return $this->raiseError('Channel "' . $channel . '" does not exist');
|
||||
}
|
||||
if ($params[0] == 'default_channel') {
|
||||
if (!$reg->channelExists($params[1])) {
|
||||
return $this->raiseError('Channel "' . $params[1] . '" does not exist');
|
||||
}
|
||||
}
|
||||
if (count($params) == 2) {
|
||||
array_push($params, 'user');
|
||||
$layer = 'user';
|
||||
} else {
|
||||
$layer = $params[2];
|
||||
}
|
||||
array_push($params, $channel);
|
||||
if (!call_user_func_array(array(&$this->config, 'set'), $params))
|
||||
{
|
||||
array_pop($params);
|
||||
$failmsg = "config-set (" . implode(", ", $params) . ") failed, channel $channel";
|
||||
} else {
|
||||
$this->config->store($layer);
|
||||
}
|
||||
if ($failmsg) {
|
||||
return $this->raiseError($failmsg);
|
||||
}
|
||||
$this->ui->outputData('config-set succeeded', $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doConfigHelp()
|
||||
|
||||
function doConfigHelp($command, $options, $params)
|
||||
{
|
||||
if (empty($params)) {
|
||||
$params = $this->config->getKeys();
|
||||
}
|
||||
$data['caption'] = "Config help" . ((count($params) == 1) ? " for $params[0]" : '');
|
||||
$data['headline'] = array('Name', 'Type', 'Description');
|
||||
$data['border'] = true;
|
||||
foreach ($params as $name) {
|
||||
$type = $this->config->getType($name);
|
||||
$docs = $this->config->getDocs($name);
|
||||
if ($type == 'set') {
|
||||
$docs = rtrim($docs) . "\nValid set: " .
|
||||
implode(' ', $this->config->getSetValues($name));
|
||||
}
|
||||
$data['data'][] = array($name, $type, $docs);
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doConfigCreate()
|
||||
|
||||
function doConfigCreate($command, $options, $params)
|
||||
{
|
||||
if (count($params) != 2) {
|
||||
return PEAR::raiseError('config-create: must have 2 parameters, root path and ' .
|
||||
'filename to save as');
|
||||
}
|
||||
$root = $params[0];
|
||||
// Clean up the DIRECTORY_SEPARATOR mess
|
||||
$ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
|
||||
$root = preg_replace(array('!\\\\+!', '!/+!', "!$ds2+!"),
|
||||
array('/', '/', '/'),
|
||||
$root);
|
||||
if ($root{0} != '/') {
|
||||
if (isset($options['windows'])) {
|
||||
if (!preg_match('/^[A-Za-z]:/', $root)) {
|
||||
return PEAR::raiseError('Root directory must be an absolute path beginning ' .
|
||||
'with "\\" or "C:\\", was: "' . $root . '"');
|
||||
}
|
||||
} else {
|
||||
return PEAR::raiseError('Root directory must be an absolute path beginning ' .
|
||||
'with "/", was: "' . $root . '"');
|
||||
}
|
||||
}
|
||||
$windows = isset($options['windows']);
|
||||
if ($windows) {
|
||||
$root = str_replace('/', '\\', $root);
|
||||
}
|
||||
if (!file_exists($params[1])) {
|
||||
if (!@touch($params[1])) {
|
||||
return PEAR::raiseError('Could not create "' . $params[1] . '"');
|
||||
}
|
||||
}
|
||||
$params[1] = realpath($params[1]);
|
||||
$config = &new PEAR_Config($params[1], '#no#system#config#', false, false);
|
||||
if ($root{strlen($root) - 1} == '/') {
|
||||
$root = substr($root, 0, strlen($root) - 1);
|
||||
}
|
||||
$config->noRegistry();
|
||||
$config->set('php_dir', $windows ? "$root\\pear\\php" : "$root/pear/php", 'user');
|
||||
$config->set('data_dir', $windows ? "$root\\pear\\data" : "$root/pear/data");
|
||||
$config->set('www_dir', $windows ? "$root\\pear\\www" : "$root/pear/www");
|
||||
$config->set('cfg_dir', $windows ? "$root\\pear\\cfg" : "$root/pear/cfg");
|
||||
$config->set('ext_dir', $windows ? "$root\\pear\\ext" : "$root/pear/ext");
|
||||
$config->set('doc_dir', $windows ? "$root\\pear\\docs" : "$root/pear/docs");
|
||||
$config->set('test_dir', $windows ? "$root\\pear\\tests" : "$root/pear/tests");
|
||||
$config->set('cache_dir', $windows ? "$root\\pear\\cache" : "$root/pear/cache");
|
||||
$config->set('download_dir', $windows ? "$root\\pear\\download" : "$root/pear/download");
|
||||
$config->set('temp_dir', $windows ? "$root\\pear\\temp" : "$root/pear/temp");
|
||||
$config->set('bin_dir', $windows ? "$root\\pear" : "$root/pear");
|
||||
$config->writeConfigFile();
|
||||
$this->_showConfig($config);
|
||||
$this->ui->outputData('Successfully created default configuration file "' . $params[1] . '"',
|
||||
$command);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
function _showConfig(&$config)
|
||||
{
|
||||
$params = array('user');
|
||||
$keys = $config->getKeys();
|
||||
sort($keys);
|
||||
$channel = 'pear.php.net';
|
||||
$data = array('caption' => 'Configuration (channel ' . $channel . '):');
|
||||
foreach ($keys as $key) {
|
||||
$type = $config->getType($key);
|
||||
$value = $config->get($key, 'user', $channel);
|
||||
if ($type == 'password' && $value) {
|
||||
$value = '********';
|
||||
}
|
||||
if ($value === false) {
|
||||
$value = 'false';
|
||||
} elseif ($value === true) {
|
||||
$value = 'true';
|
||||
}
|
||||
$data['data'][$config->getGroup($key)][] =
|
||||
array($config->getPrompt($key) , $key, $value);
|
||||
}
|
||||
foreach ($config->getLayers() as $layer) {
|
||||
$data['data']['Config Files'][] =
|
||||
array(ucfirst($layer) . ' Configuration File', 'Filename' ,
|
||||
$config->getConfFile($layer));
|
||||
}
|
||||
|
||||
$this->ui->outputData($data, 'config-show');
|
||||
return true;
|
||||
}
|
||||
// {{{ _checkLayer()
|
||||
|
||||
/**
|
||||
* Checks if a layer is defined or not
|
||||
*
|
||||
* @param string $layer The layer to search for
|
||||
* @return mixed False on no error or the error message
|
||||
*/
|
||||
function _checkLayer($layer = null)
|
||||
{
|
||||
if (!empty($layer) && $layer != 'default') {
|
||||
$layers = $this->config->getLayers();
|
||||
if (!in_array($layer, $layers)) {
|
||||
return " only the layers: \"" . implode('" or "', $layers) . "\" are supported";
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
92
vendor/library/Excel/phpxls/PEAR/Command/Config.xml
vendored
Normal file
92
vendor/library/Excel/phpxls/PEAR/Command/Config.xml
vendored
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<commands version="1.0">
|
||||
<config-show>
|
||||
<summary>Show All Settings</summary>
|
||||
<function>doConfigShow</function>
|
||||
<shortcut>csh</shortcut>
|
||||
<options>
|
||||
<channel>
|
||||
<shortopt>c</shortopt>
|
||||
<doc>show configuration variables for another channel</doc>
|
||||
<arg>CHAN</arg>
|
||||
</channel>
|
||||
</options>
|
||||
<doc>[layer]
|
||||
Displays all configuration values. An optional argument
|
||||
may be used to tell which configuration layer to display. Valid
|
||||
configuration layers are "user", "system" and "default". To display
|
||||
configurations for different channels, set the default_channel
|
||||
configuration variable and run config-show again.
|
||||
</doc>
|
||||
</config-show>
|
||||
<config-get>
|
||||
<summary>Show One Setting</summary>
|
||||
<function>doConfigGet</function>
|
||||
<shortcut>cg</shortcut>
|
||||
<options>
|
||||
<channel>
|
||||
<shortopt>c</shortopt>
|
||||
<doc>show configuration variables for another channel</doc>
|
||||
<arg>CHAN</arg>
|
||||
</channel>
|
||||
</options>
|
||||
<doc><parameter> [layer]
|
||||
Displays the value of one configuration parameter. The
|
||||
first argument is the name of the parameter, an optional second argument
|
||||
may be used to tell which configuration layer to look in. Valid configuration
|
||||
layers are "user", "system" and "default". If no layer is specified, a value
|
||||
will be picked from the first layer that defines the parameter, in the order
|
||||
just specified. The configuration value will be retrieved for the channel
|
||||
specified by the default_channel configuration variable.
|
||||
</doc>
|
||||
</config-get>
|
||||
<config-set>
|
||||
<summary>Change Setting</summary>
|
||||
<function>doConfigSet</function>
|
||||
<shortcut>cs</shortcut>
|
||||
<options>
|
||||
<channel>
|
||||
<shortopt>c</shortopt>
|
||||
<doc>show configuration variables for another channel</doc>
|
||||
<arg>CHAN</arg>
|
||||
</channel>
|
||||
</options>
|
||||
<doc><parameter> <value> [layer]
|
||||
Sets the value of one configuration parameter. The first argument is
|
||||
the name of the parameter, the second argument is the new value. Some
|
||||
parameters are subject to validation, and the command will fail with
|
||||
an error message if the new value does not make sense. An optional
|
||||
third argument may be used to specify in which layer to set the
|
||||
configuration parameter. The default layer is "user". The
|
||||
configuration value will be set for the current channel, which
|
||||
is controlled by the default_channel configuration variable.
|
||||
</doc>
|
||||
</config-set>
|
||||
<config-help>
|
||||
<summary>Show Information About Setting</summary>
|
||||
<function>doConfigHelp</function>
|
||||
<shortcut>ch</shortcut>
|
||||
<options />
|
||||
<doc>[parameter]
|
||||
Displays help for a configuration parameter. Without arguments it
|
||||
displays help for all configuration parameters.
|
||||
</doc>
|
||||
</config-help>
|
||||
<config-create>
|
||||
<summary>Create a Default configuration file</summary>
|
||||
<function>doConfigCreate</function>
|
||||
<shortcut>coc</shortcut>
|
||||
<options>
|
||||
<windows>
|
||||
<shortopt>w</shortopt>
|
||||
<doc>create a config file for a windows install</doc>
|
||||
</windows>
|
||||
</options>
|
||||
<doc><root path> <filename>
|
||||
Create a default configuration file with all directory configuration
|
||||
variables set to subdirectories of <root path>, and save it as <filename>.
|
||||
This is useful especially for creating a configuration file for a remote
|
||||
PEAR installation (using the --remoteconfig option of install, upgrade,
|
||||
and uninstall).
|
||||
</doc>
|
||||
</config-create>
|
||||
</commands>
|
||||
1188
vendor/library/Excel/phpxls/PEAR/Command/Install.php
vendored
Normal file
1188
vendor/library/Excel/phpxls/PEAR/Command/Install.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
259
vendor/library/Excel/phpxls/PEAR/Command/Install.xml
vendored
Normal file
259
vendor/library/Excel/phpxls/PEAR/Command/Install.xml
vendored
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
<commands version="1.0">
|
||||
<install>
|
||||
<summary>Install Package</summary>
|
||||
<function>doInstall</function>
|
||||
<shortcut>i</shortcut>
|
||||
<options>
|
||||
<force>
|
||||
<shortopt>f</shortopt>
|
||||
<doc>will overwrite newer installed packages</doc>
|
||||
</force>
|
||||
<loose>
|
||||
<shortopt>l</shortopt>
|
||||
<doc>do not check for recommended dependency version</doc>
|
||||
</loose>
|
||||
<nodeps>
|
||||
<shortopt>n</shortopt>
|
||||
<doc>ignore dependencies, install anyway</doc>
|
||||
</nodeps>
|
||||
<register-only>
|
||||
<shortopt>r</shortopt>
|
||||
<doc>do not install files, only register the package as installed</doc>
|
||||
</register-only>
|
||||
<soft>
|
||||
<shortopt>s</shortopt>
|
||||
<doc>soft install, fail silently, or upgrade if already installed</doc>
|
||||
</soft>
|
||||
<nobuild>
|
||||
<shortopt>B</shortopt>
|
||||
<doc>don't build C extensions</doc>
|
||||
</nobuild>
|
||||
<nocompress>
|
||||
<shortopt>Z</shortopt>
|
||||
<doc>request uncompressed files when downloading</doc>
|
||||
</nocompress>
|
||||
<installroot>
|
||||
<shortopt>R</shortopt>
|
||||
<arg>DIR</arg>
|
||||
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT), use packagingroot for RPM</doc>
|
||||
</installroot>
|
||||
<packagingroot>
|
||||
<shortopt>P</shortopt>
|
||||
<arg>DIR</arg>
|
||||
<doc>root directory used when packaging files, like RPM packaging</doc>
|
||||
</packagingroot>
|
||||
<ignore-errors>
|
||||
<doc>force install even if there were errors</doc>
|
||||
</ignore-errors>
|
||||
<alldeps>
|
||||
<shortopt>a</shortopt>
|
||||
<doc>install all required and optional dependencies</doc>
|
||||
</alldeps>
|
||||
<onlyreqdeps>
|
||||
<shortopt>o</shortopt>
|
||||
<doc>install all required dependencies</doc>
|
||||
</onlyreqdeps>
|
||||
<offline>
|
||||
<shortopt>O</shortopt>
|
||||
<doc>do not attempt to download any urls or contact channels</doc>
|
||||
</offline>
|
||||
<pretend>
|
||||
<shortopt>p</shortopt>
|
||||
<doc>Only list the packages that would be downloaded</doc>
|
||||
</pretend>
|
||||
</options>
|
||||
<doc>[channel/]<package> ...
|
||||
Installs one or more PEAR packages. You can specify a package to
|
||||
install in four ways:
|
||||
|
||||
"Package-1.0.tgz" : installs from a local file
|
||||
|
||||
"http://example.com/Package-1.0.tgz" : installs from
|
||||
anywhere on the net.
|
||||
|
||||
"package.xml" : installs the package described in
|
||||
package.xml. Useful for testing, or for wrapping a PEAR package in
|
||||
another package manager such as RPM.
|
||||
|
||||
"Package[-version/state][.tar]" : queries your default channel's server
|
||||
({config master_server}) and downloads the newest package with
|
||||
the preferred quality/state ({config preferred_state}).
|
||||
|
||||
To retrieve Package version 1.1, use "Package-1.1," to retrieve
|
||||
Package state beta, use "Package-beta." To retrieve an uncompressed
|
||||
file, append .tar (make sure there is no file by the same name first)
|
||||
|
||||
To download a package from another channel, prefix with the channel name like
|
||||
"channel/Package"
|
||||
|
||||
More than one package may be specified at once. It is ok to mix these
|
||||
four ways of specifying packages.
|
||||
</doc>
|
||||
</install>
|
||||
<upgrade>
|
||||
<summary>Upgrade Package</summary>
|
||||
<function>doInstall</function>
|
||||
<shortcut>up</shortcut>
|
||||
<options>
|
||||
<force>
|
||||
<shortopt>f</shortopt>
|
||||
<doc>overwrite newer installed packages</doc>
|
||||
</force>
|
||||
<loose>
|
||||
<shortopt>l</shortopt>
|
||||
<doc>do not check for recommended dependency version</doc>
|
||||
</loose>
|
||||
<nodeps>
|
||||
<shortopt>n</shortopt>
|
||||
<doc>ignore dependencies, upgrade anyway</doc>
|
||||
</nodeps>
|
||||
<register-only>
|
||||
<shortopt>r</shortopt>
|
||||
<doc>do not install files, only register the package as upgraded</doc>
|
||||
</register-only>
|
||||
<nobuild>
|
||||
<shortopt>B</shortopt>
|
||||
<doc>don't build C extensions</doc>
|
||||
</nobuild>
|
||||
<nocompress>
|
||||
<shortopt>Z</shortopt>
|
||||
<doc>request uncompressed files when downloading</doc>
|
||||
</nocompress>
|
||||
<installroot>
|
||||
<shortopt>R</shortopt>
|
||||
<arg>DIR</arg>
|
||||
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT)</doc>
|
||||
</installroot>
|
||||
<ignore-errors>
|
||||
<doc>force install even if there were errors</doc>
|
||||
</ignore-errors>
|
||||
<alldeps>
|
||||
<shortopt>a</shortopt>
|
||||
<doc>install all required and optional dependencies</doc>
|
||||
</alldeps>
|
||||
<onlyreqdeps>
|
||||
<shortopt>o</shortopt>
|
||||
<doc>install all required dependencies</doc>
|
||||
</onlyreqdeps>
|
||||
<offline>
|
||||
<shortopt>O</shortopt>
|
||||
<doc>do not attempt to download any urls or contact channels</doc>
|
||||
</offline>
|
||||
<pretend>
|
||||
<shortopt>p</shortopt>
|
||||
<doc>Only list the packages that would be downloaded</doc>
|
||||
</pretend>
|
||||
</options>
|
||||
<doc><package> ...
|
||||
Upgrades one or more PEAR packages. See documentation for the
|
||||
"install" command for ways to specify a package.
|
||||
|
||||
When upgrading, your package will be updated if the provided new
|
||||
package has a higher version number (use the -f option if you need to
|
||||
upgrade anyway).
|
||||
|
||||
More than one package may be specified at once.
|
||||
</doc>
|
||||
</upgrade>
|
||||
<upgrade-all>
|
||||
<summary>Upgrade All Packages</summary>
|
||||
<function>doInstall</function>
|
||||
<shortcut>ua</shortcut>
|
||||
<options>
|
||||
<nodeps>
|
||||
<shortopt>n</shortopt>
|
||||
<doc>ignore dependencies, upgrade anyway</doc>
|
||||
</nodeps>
|
||||
<register-only>
|
||||
<shortopt>r</shortopt>
|
||||
<doc>do not install files, only register the package as upgraded</doc>
|
||||
</register-only>
|
||||
<nobuild>
|
||||
<shortopt>B</shortopt>
|
||||
<doc>don't build C extensions</doc>
|
||||
</nobuild>
|
||||
<nocompress>
|
||||
<shortopt>Z</shortopt>
|
||||
<doc>request uncompressed files when downloading</doc>
|
||||
</nocompress>
|
||||
<installroot>
|
||||
<shortopt>R</shortopt>
|
||||
<arg>DIR</arg>
|
||||
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT)</doc>
|
||||
</installroot>
|
||||
<ignore-errors>
|
||||
<doc>force install even if there were errors</doc>
|
||||
</ignore-errors>
|
||||
<loose>
|
||||
<doc>do not check for recommended dependency version</doc>
|
||||
</loose>
|
||||
</options>
|
||||
<doc>
|
||||
Upgrades all packages that have a newer release available. Upgrades are
|
||||
done only if there is a release available of the state specified in
|
||||
"preferred_state" (currently {config preferred_state}), or a state considered
|
||||
more stable.
|
||||
</doc>
|
||||
</upgrade-all>
|
||||
<uninstall>
|
||||
<summary>Un-install Package</summary>
|
||||
<function>doUninstall</function>
|
||||
<shortcut>un</shortcut>
|
||||
<options>
|
||||
<nodeps>
|
||||
<shortopt>n</shortopt>
|
||||
<doc>ignore dependencies, uninstall anyway</doc>
|
||||
</nodeps>
|
||||
<register-only>
|
||||
<shortopt>r</shortopt>
|
||||
<doc>do not remove files, only register the packages as not installed</doc>
|
||||
</register-only>
|
||||
<installroot>
|
||||
<shortopt>R</shortopt>
|
||||
<arg>DIR</arg>
|
||||
<doc>root directory used when installing files (ala PHP's INSTALL_ROOT)</doc>
|
||||
</installroot>
|
||||
<ignore-errors>
|
||||
<doc>force install even if there were errors</doc>
|
||||
</ignore-errors>
|
||||
<offline>
|
||||
<shortopt>O</shortopt>
|
||||
<doc>do not attempt to uninstall remotely</doc>
|
||||
</offline>
|
||||
</options>
|
||||
<doc>[channel/]<package> ...
|
||||
Uninstalls one or more PEAR packages. More than one package may be
|
||||
specified at once. Prefix with channel name to uninstall from a
|
||||
channel not in your default channel ({config default_channel})
|
||||
</doc>
|
||||
</uninstall>
|
||||
<bundle>
|
||||
<summary>Unpacks a Pecl Package</summary>
|
||||
<function>doBundle</function>
|
||||
<shortcut>bun</shortcut>
|
||||
<options>
|
||||
<destination>
|
||||
<shortopt>d</shortopt>
|
||||
<arg>DIR</arg>
|
||||
<doc>Optional destination directory for unpacking (defaults to current path or "ext" if exists)</doc>
|
||||
</destination>
|
||||
<force>
|
||||
<shortopt>f</shortopt>
|
||||
<doc>Force the unpacking even if there were errors in the package</doc>
|
||||
</force>
|
||||
</options>
|
||||
<doc><package>
|
||||
Unpacks a Pecl Package into the selected location. It will download the
|
||||
package if needed.
|
||||
</doc>
|
||||
</bundle>
|
||||
<run-scripts>
|
||||
<summary>Run Post-Install Scripts bundled with a package</summary>
|
||||
<function>doRunScripts</function>
|
||||
<shortcut>rs</shortcut>
|
||||
<options />
|
||||
<doc><package>
|
||||
Run post-installation scripts in package <package>, if any exist.
|
||||
</doc>
|
||||
</run-scripts>
|
||||
</commands>
|
||||
153
vendor/library/Excel/phpxls/PEAR/Command/Mirror.php
vendored
Normal file
153
vendor/library/Excel/phpxls/PEAR/Command/Mirror.php
vendored
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Command_Mirror (download-all command)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Alexander Merz <alexmerz@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Mirror.php,v 1.20 2008/04/11 01:16:40 dufuz Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
|
||||
/**
|
||||
* PEAR commands for providing file mirrors
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Alexander Merz <alexmerz@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.2.0
|
||||
*/
|
||||
class PEAR_Command_Mirror extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'download-all' => array(
|
||||
'summary' => 'Downloads each available package from the default channel',
|
||||
'function' => 'doDownloadAll',
|
||||
'shortcut' => 'da',
|
||||
'options' => array(
|
||||
'channel' =>
|
||||
array(
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'specify a channel other than the default channel',
|
||||
'arg' => 'CHAN',
|
||||
),
|
||||
),
|
||||
'doc' => '
|
||||
Requests a list of available packages from the default channel ({config default_channel})
|
||||
and downloads them to current working directory. Note: only
|
||||
packages within preferred_state ({config preferred_state}) will be downloaded'
|
||||
),
|
||||
);
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Mirror constructor.
|
||||
*
|
||||
* @access public
|
||||
* @param object PEAR_Frontend a reference to an frontend
|
||||
* @param object PEAR_Config a reference to the configuration data
|
||||
*/
|
||||
function PEAR_Command_Mirror(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
/**
|
||||
* For unit-testing
|
||||
*/
|
||||
function &factory($a)
|
||||
{
|
||||
$a = &PEAR_Command::factory($a, $this->config);
|
||||
return $a;
|
||||
}
|
||||
|
||||
// {{{ doDownloadAll()
|
||||
/**
|
||||
* retrieves a list of avaible Packages from master server
|
||||
* and downloads them
|
||||
*
|
||||
* @access public
|
||||
* @param string $command the command
|
||||
* @param array $options the command options before the command
|
||||
* @param array $params the stuff after the command name
|
||||
* @return bool true if succesful
|
||||
* @throw PEAR_Error
|
||||
*/
|
||||
function doDownloadAll($command, $options, $params)
|
||||
{
|
||||
$savechannel = $this->config->get('default_channel');
|
||||
$reg = &$this->config->getRegistry();
|
||||
$channel = isset($options['channel']) ? $options['channel'] :
|
||||
$this->config->get('default_channel');
|
||||
if (!$reg->channelExists($channel)) {
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return $this->raiseError('Channel "' . $channel . '" does not exist');
|
||||
}
|
||||
$this->config->set('default_channel', $channel);
|
||||
$this->ui->outputData('Using Channel ' . $this->config->get('default_channel'));
|
||||
$chan = $reg->getChannel($channel);
|
||||
if (PEAR::isError($chan)) {
|
||||
return $this->raiseError($chan);
|
||||
}
|
||||
if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
$remoteInfo = array_flip($rest->listPackages($base, $channel));
|
||||
} else {
|
||||
$remote = &$this->config->getRemote();
|
||||
$stable = ($this->config->get('preferred_state') == 'stable');
|
||||
$remoteInfo = $remote->call("package.listAll", true, $stable, false);
|
||||
}
|
||||
if (PEAR::isError($remoteInfo)) {
|
||||
return $remoteInfo;
|
||||
}
|
||||
$cmd = &$this->factory("download");
|
||||
if (PEAR::isError($cmd)) {
|
||||
return $cmd;
|
||||
}
|
||||
$this->ui->outputData('Using Preferred State of ' .
|
||||
$this->config->get('preferred_state'));
|
||||
$this->ui->outputData('Gathering release information, please wait...');
|
||||
/**
|
||||
* Error handling not necessary, because already done by
|
||||
* the download command
|
||||
*/
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$err = $cmd->run('download', array('downloadonly' => true), array_keys($remoteInfo));
|
||||
PEAR::staticPopErrorHandling();
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
if (PEAR::isError($err)) {
|
||||
$this->ui->outputData($err->getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
18
vendor/library/Excel/phpxls/PEAR/Command/Mirror.xml
vendored
Normal file
18
vendor/library/Excel/phpxls/PEAR/Command/Mirror.xml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<commands version="1.0">
|
||||
<download-all>
|
||||
<summary>Downloads each available package from the default channel</summary>
|
||||
<function>doDownloadAll</function>
|
||||
<shortcut>da</shortcut>
|
||||
<options>
|
||||
<channel>
|
||||
<shortopt>c</shortopt>
|
||||
<doc>specify a channel other than the default channel</doc>
|
||||
<arg>CHAN</arg>
|
||||
</channel>
|
||||
</options>
|
||||
<doc>
|
||||
Requests a list of available packages from the default channel ({config default_channel})
|
||||
and downloads them to current working directory. Note: only
|
||||
packages within preferred_state ({config preferred_state}) will be downloaded</doc>
|
||||
</download-all>
|
||||
</commands>
|
||||
843
vendor/library/Excel/phpxls/PEAR/Command/Package.php
vendored
Normal file
843
vendor/library/Excel/phpxls/PEAR/Command/Package.php
vendored
Normal file
|
|
@ -0,0 +1,843 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Command_Package (package, package-validate, cvsdiff, cvstag, package-dependencies,
|
||||
* sign, makerpm, convert commands)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Martin Jansen <mj@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Package.php,v 1.128 2008/03/29 21:06:58 dufuz Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
|
||||
/**
|
||||
* PEAR commands for login/logout
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Martin Jansen <mj@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: @package_version@
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
|
||||
class PEAR_Command_Package extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'package' => array(
|
||||
'summary' => 'Build Package',
|
||||
'function' => 'doPackage',
|
||||
'shortcut' => 'p',
|
||||
'options' => array(
|
||||
'nocompress' => array(
|
||||
'shortopt' => 'Z',
|
||||
'doc' => 'Do not gzip the package file'
|
||||
),
|
||||
'showname' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'Print the name of the packaged file.',
|
||||
),
|
||||
),
|
||||
'doc' => '[descfile] [descfile2]
|
||||
Creates a PEAR package from its description file (usually called
|
||||
package.xml). If a second packagefile is passed in, then
|
||||
the packager will check to make sure that one is a package.xml
|
||||
version 1.0, and the other is a package.xml version 2.0. The
|
||||
package.xml version 1.0 will be saved as "package.xml" in the archive,
|
||||
and the other as "package2.xml" in the archive"
|
||||
'
|
||||
),
|
||||
'package-validate' => array(
|
||||
'summary' => 'Validate Package Consistency',
|
||||
'function' => 'doPackageValidate',
|
||||
'shortcut' => 'pv',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
',
|
||||
),
|
||||
'cvsdiff' => array(
|
||||
'summary' => 'Run a "cvs diff" for all files in a package',
|
||||
'function' => 'doCvsDiff',
|
||||
'shortcut' => 'cd',
|
||||
'options' => array(
|
||||
'quiet' => array(
|
||||
'shortopt' => 'q',
|
||||
'doc' => 'Be quiet',
|
||||
),
|
||||
'reallyquiet' => array(
|
||||
'shortopt' => 'Q',
|
||||
'doc' => 'Be really quiet',
|
||||
),
|
||||
'date' => array(
|
||||
'shortopt' => 'D',
|
||||
'doc' => 'Diff against revision of DATE',
|
||||
'arg' => 'DATE',
|
||||
),
|
||||
'release' => array(
|
||||
'shortopt' => 'R',
|
||||
'doc' => 'Diff against tag for package release REL',
|
||||
'arg' => 'REL',
|
||||
),
|
||||
'revision' => array(
|
||||
'shortopt' => 'r',
|
||||
'doc' => 'Diff against revision REV',
|
||||
'arg' => 'REV',
|
||||
),
|
||||
'context' => array(
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'Generate context diff',
|
||||
),
|
||||
'unified' => array(
|
||||
'shortopt' => 'u',
|
||||
'doc' => 'Generate unified diff',
|
||||
),
|
||||
'ignore-case' => array(
|
||||
'shortopt' => 'i',
|
||||
'doc' => 'Ignore case, consider upper- and lower-case letters equivalent',
|
||||
),
|
||||
'ignore-whitespace' => array(
|
||||
'shortopt' => 'b',
|
||||
'doc' => 'Ignore changes in amount of white space',
|
||||
),
|
||||
'ignore-blank-lines' => array(
|
||||
'shortopt' => 'B',
|
||||
'doc' => 'Ignore changes that insert or delete blank lines',
|
||||
),
|
||||
'brief' => array(
|
||||
'doc' => 'Report only whether the files differ, no details',
|
||||
),
|
||||
'dry-run' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'Don\'t do anything, just pretend',
|
||||
),
|
||||
),
|
||||
'doc' => '<package.xml>
|
||||
Compares all the files in a package. Without any options, this
|
||||
command will compare the current code with the last checked-in code.
|
||||
Using the -r or -R option you may compare the current code with that
|
||||
of a specific release.
|
||||
',
|
||||
),
|
||||
'cvstag' => array(
|
||||
'summary' => 'Set CVS Release Tag',
|
||||
'function' => 'doCvsTag',
|
||||
'shortcut' => 'ct',
|
||||
'options' => array(
|
||||
'quiet' => array(
|
||||
'shortopt' => 'q',
|
||||
'doc' => 'Be quiet',
|
||||
),
|
||||
'reallyquiet' => array(
|
||||
'shortopt' => 'Q',
|
||||
'doc' => 'Be really quiet',
|
||||
),
|
||||
'slide' => array(
|
||||
'shortopt' => 'F',
|
||||
'doc' => 'Move (slide) tag if it exists',
|
||||
),
|
||||
'delete' => array(
|
||||
'shortopt' => 'd',
|
||||
'doc' => 'Remove tag',
|
||||
),
|
||||
'dry-run' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'Don\'t do anything, just pretend',
|
||||
),
|
||||
),
|
||||
'doc' => '<package.xml> [files...]
|
||||
Sets a CVS tag on all files in a package. Use this command after you have
|
||||
packaged a distribution tarball with the "package" command to tag what
|
||||
revisions of what files were in that release. If need to fix something
|
||||
after running cvstag once, but before the tarball is released to the public,
|
||||
use the "slide" option to move the release tag.
|
||||
|
||||
to include files (such as a second package.xml, or tests not included in the
|
||||
release), pass them as additional parameters.
|
||||
',
|
||||
),
|
||||
'package-dependencies' => array(
|
||||
'summary' => 'Show package dependencies',
|
||||
'function' => 'doPackageDependencies',
|
||||
'shortcut' => 'pd',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
List all dependencies the package has.'
|
||||
),
|
||||
'sign' => array(
|
||||
'summary' => 'Sign a package distribution file',
|
||||
'function' => 'doSign',
|
||||
'shortcut' => 'si',
|
||||
'options' => array(
|
||||
'verbose' => array(
|
||||
'shortopt' => 'v',
|
||||
'doc' => 'Display GnuPG output',
|
||||
),
|
||||
),
|
||||
'doc' => '<package-file>
|
||||
Signs a package distribution (.tar or .tgz) file with GnuPG.',
|
||||
),
|
||||
'makerpm' => array(
|
||||
'summary' => 'Builds an RPM spec file from a PEAR package',
|
||||
'function' => 'doMakeRPM',
|
||||
'shortcut' => 'rpm',
|
||||
'options' => array(
|
||||
'spec-template' => array(
|
||||
'shortopt' => 't',
|
||||
'arg' => 'FILE',
|
||||
'doc' => 'Use FILE as RPM spec file template'
|
||||
),
|
||||
'rpm-pkgname' => array(
|
||||
'shortopt' => 'p',
|
||||
'arg' => 'FORMAT',
|
||||
'doc' => 'Use FORMAT as format string for RPM package name, %s is replaced
|
||||
by the PEAR package name, defaults to "PEAR::%s".',
|
||||
),
|
||||
),
|
||||
'doc' => '<package-file>
|
||||
|
||||
Creates an RPM .spec file for wrapping a PEAR package inside an RPM
|
||||
package. Intended to be used from the SPECS directory, with the PEAR
|
||||
package tarball in the SOURCES directory:
|
||||
|
||||
$ pear makerpm ../SOURCES/Net_Socket-1.0.tgz
|
||||
Wrote RPM spec file PEAR::Net_Geo-1.0.spec
|
||||
$ rpm -bb PEAR::Net_Socket-1.0.spec
|
||||
...
|
||||
Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
|
||||
',
|
||||
),
|
||||
'convert' => array(
|
||||
'summary' => 'Convert a package.xml 1.0 to package.xml 2.0 format',
|
||||
'function' => 'doConvert',
|
||||
'shortcut' => 'c2',
|
||||
'options' => array(
|
||||
'flat' => array(
|
||||
'shortopt' => 'f',
|
||||
'doc' => 'do not beautify the filelist.',
|
||||
),
|
||||
),
|
||||
'doc' => '[descfile] [descfile2]
|
||||
Converts a package.xml in 1.0 format into a package.xml
|
||||
in 2.0 format. The new file will be named package2.xml by default,
|
||||
and package.xml will be used as the old file by default.
|
||||
This is not the most intelligent conversion, and should only be
|
||||
used for automated conversion or learning the format.
|
||||
'
|
||||
),
|
||||
);
|
||||
|
||||
var $output;
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Package constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Package(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ _displayValidationResults()
|
||||
|
||||
function _displayValidationResults($err, $warn, $strict = false)
|
||||
{
|
||||
foreach ($err as $e) {
|
||||
$this->output .= "Error: $e\n";
|
||||
}
|
||||
foreach ($warn as $w) {
|
||||
$this->output .= "Warning: $w\n";
|
||||
}
|
||||
$this->output .= sprintf('Validation: %d error(s), %d warning(s)'."\n",
|
||||
sizeof($err), sizeof($warn));
|
||||
if ($strict && sizeof($err) > 0) {
|
||||
$this->output .= "Fix these errors and try again.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
function &getPackager()
|
||||
{
|
||||
if (!class_exists('PEAR_Packager')) {
|
||||
require_once 'PEAR/Packager.php';
|
||||
}
|
||||
$a = &new PEAR_Packager;
|
||||
return $a;
|
||||
}
|
||||
|
||||
function &getPackageFile($config, $debug = false, $tmpdir = null)
|
||||
{
|
||||
if (!class_exists('PEAR_Common')) {
|
||||
require_once 'PEAR/Common.php';
|
||||
}
|
||||
if (!class_exists('PEAR_PackageFile')) {
|
||||
require_once 'PEAR/PackageFile.php';
|
||||
}
|
||||
$a = &new PEAR_PackageFile($config, $debug, $tmpdir);
|
||||
$common = new PEAR_Common;
|
||||
$common->ui = $this->ui;
|
||||
$a->setLogger($common);
|
||||
return $a;
|
||||
}
|
||||
// {{{ doPackage()
|
||||
|
||||
function doPackage($command, $options, $params)
|
||||
{
|
||||
$this->output = '';
|
||||
$pkginfofile = isset($params[0]) ? $params[0] : 'package.xml';
|
||||
$pkg2 = isset($params[1]) ? $params[1] : null;
|
||||
if (!$pkg2 && !isset($params[0])) {
|
||||
if (file_exists('package2.xml')) {
|
||||
$pkg2 = 'package2.xml';
|
||||
}
|
||||
}
|
||||
$packager = &$this->getPackager();
|
||||
$compress = empty($options['nocompress']) ? true : false;
|
||||
$result = $packager->package($pkginfofile, $compress, $pkg2);
|
||||
if (PEAR::isError($result)) {
|
||||
return $this->raiseError($result);
|
||||
}
|
||||
// Don't want output, only the package file name just created
|
||||
if (isset($options['showname'])) {
|
||||
$this->output = $result;
|
||||
}
|
||||
if ($this->output) {
|
||||
$this->ui->outputData($this->output, $command);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doPackageValidate()
|
||||
|
||||
function doPackageValidate($command, $options, $params)
|
||||
{
|
||||
$this->output = '';
|
||||
if (sizeof($params) < 1) {
|
||||
$params[0] = "package.xml";
|
||||
}
|
||||
$obj = &$this->getPackageFile($this->config, $this->_debug);
|
||||
$obj->rawReturn();
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL);
|
||||
if (PEAR::isError($info)) {
|
||||
$info = $obj->fromPackageFile($params[0], PEAR_VALIDATE_NORMAL);
|
||||
} else {
|
||||
$archive = $info->getArchiveFile();
|
||||
$tar = &new Archive_Tar($archive);
|
||||
$tar->extract(dirname($info->getPackageFile()));
|
||||
$info->setPackageFile(dirname($info->getPackageFile()) . DIRECTORY_SEPARATOR .
|
||||
$info->getPackage() . '-' . $info->getVersion() . DIRECTORY_SEPARATOR .
|
||||
basename($info->getPackageFile()));
|
||||
}
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
$valid = false;
|
||||
if ($info->getPackagexmlVersion() == '2.0') {
|
||||
if ($valid = $info->validate(PEAR_VALIDATE_NORMAL)) {
|
||||
$info->flattenFileList();
|
||||
$valid = $info->validate(PEAR_VALIDATE_PACKAGING);
|
||||
}
|
||||
} else {
|
||||
$valid = $info->validate(PEAR_VALIDATE_PACKAGING);
|
||||
}
|
||||
$err = $warn = array();
|
||||
if ($errors = $info->getValidationWarnings()) {
|
||||
foreach ($errors as $error) {
|
||||
if ($error['level'] == 'warning') {
|
||||
$warn[] = $error['message'];
|
||||
} else {
|
||||
$err[] = $error['message'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->_displayValidationResults($err, $warn);
|
||||
$this->ui->outputData($this->output, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doCvsTag()
|
||||
|
||||
function doCvsTag($command, $options, $params)
|
||||
{
|
||||
$this->output = '';
|
||||
$_cmd = $command;
|
||||
if (sizeof($params) < 1) {
|
||||
$help = $this->getHelp($command);
|
||||
return $this->raiseError("$command: missing parameter: $help[0]");
|
||||
}
|
||||
$obj = &$this->getPackageFile($this->config, $this->_debug);
|
||||
$info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL);
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
$err = $warn = array();
|
||||
if (!$info->validate()) {
|
||||
foreach ($info->getValidationWarnings() as $error) {
|
||||
if ($error['level'] == 'warning') {
|
||||
$warn[] = $error['message'];
|
||||
} else {
|
||||
$err[] = $error['message'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$this->_displayValidationResults($err, $warn, true)) {
|
||||
$this->ui->outputData($this->output, $command);
|
||||
return $this->raiseError('CVS tag failed');
|
||||
}
|
||||
$version = $info->getVersion();
|
||||
$cvsversion = preg_replace('/[^a-z0-9]/i', '_', $version);
|
||||
$cvstag = "RELEASE_$cvsversion";
|
||||
$files = array_keys($info->getFilelist());
|
||||
$command = "cvs";
|
||||
if (isset($options['quiet'])) {
|
||||
$command .= ' -q';
|
||||
}
|
||||
if (isset($options['reallyquiet'])) {
|
||||
$command .= ' -Q';
|
||||
}
|
||||
$command .= ' tag';
|
||||
if (isset($options['slide'])) {
|
||||
$command .= ' -F';
|
||||
}
|
||||
if (isset($options['delete'])) {
|
||||
$command .= ' -d';
|
||||
}
|
||||
$command .= ' ' . $cvstag . ' ' . escapeshellarg($params[0]);
|
||||
array_shift($params);
|
||||
if (count($params)) {
|
||||
// add in additional files to be tagged
|
||||
$files = array_merge($files, $params);
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
$command .= ' ' . escapeshellarg($file);
|
||||
}
|
||||
if ($this->config->get('verbose') > 1) {
|
||||
$this->output .= "+ $command\n";
|
||||
}
|
||||
$this->output .= "+ $command\n";
|
||||
if (empty($options['dry-run'])) {
|
||||
$fp = popen($command, "r");
|
||||
while ($line = fgets($fp, 1024)) {
|
||||
$this->output .= rtrim($line)."\n";
|
||||
}
|
||||
pclose($fp);
|
||||
}
|
||||
$this->ui->outputData($this->output, $_cmd);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doCvsDiff()
|
||||
|
||||
function doCvsDiff($command, $options, $params)
|
||||
{
|
||||
$this->output = '';
|
||||
if (sizeof($params) < 1) {
|
||||
$help = $this->getHelp($command);
|
||||
return $this->raiseError("$command: missing parameter: $help[0]");
|
||||
}
|
||||
$obj = &$this->getPackageFile($this->config, $this->_debug);
|
||||
$info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL);
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
$err = $warn = array();
|
||||
if (!$info->validate()) {
|
||||
foreach ($info->getValidationWarnings() as $error) {
|
||||
if ($error['level'] == 'warning') {
|
||||
$warn[] = $error['message'];
|
||||
} else {
|
||||
$err[] = $error['message'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$this->_displayValidationResults($err, $warn, true)) {
|
||||
$this->ui->outputData($this->output, $command);
|
||||
return $this->raiseError('CVS diff failed');
|
||||
}
|
||||
$info1 = $info->getFilelist();
|
||||
$files = $info1;
|
||||
$cmd = "cvs";
|
||||
if (isset($options['quiet'])) {
|
||||
$cmd .= ' -q';
|
||||
unset($options['quiet']);
|
||||
}
|
||||
if (isset($options['reallyquiet'])) {
|
||||
$cmd .= ' -Q';
|
||||
unset($options['reallyquiet']);
|
||||
}
|
||||
if (isset($options['release'])) {
|
||||
$cvsversion = preg_replace('/[^a-z0-9]/i', '_', $options['release']);
|
||||
$cvstag = "RELEASE_$cvsversion";
|
||||
$options['revision'] = $cvstag;
|
||||
unset($options['release']);
|
||||
}
|
||||
$execute = true;
|
||||
if (isset($options['dry-run'])) {
|
||||
$execute = false;
|
||||
unset($options['dry-run']);
|
||||
}
|
||||
$cmd .= ' diff';
|
||||
// the rest of the options are passed right on to "cvs diff"
|
||||
foreach ($options as $option => $optarg) {
|
||||
$arg = $short = false;
|
||||
if (isset($this->commands[$command]['options'][$option])) {
|
||||
$arg = $this->commands[$command]['options'][$option]['arg'];
|
||||
$short = $this->commands[$command]['options'][$option]['shortopt'];
|
||||
}
|
||||
$cmd .= $short ? " -$short" : " --$option";
|
||||
if ($arg && $optarg) {
|
||||
$cmd .= ($short ? '' : '=') . escapeshellarg($optarg);
|
||||
}
|
||||
}
|
||||
foreach ($files as $file) {
|
||||
$cmd .= ' ' . escapeshellarg($file['name']);
|
||||
}
|
||||
if ($this->config->get('verbose') > 1) {
|
||||
$this->output .= "+ $cmd\n";
|
||||
}
|
||||
if ($execute) {
|
||||
$fp = popen($cmd, "r");
|
||||
while ($line = fgets($fp, 1024)) {
|
||||
$this->output .= rtrim($line)."\n";
|
||||
}
|
||||
pclose($fp);
|
||||
}
|
||||
$this->ui->outputData($this->output, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doPackageDependencies()
|
||||
|
||||
function doPackageDependencies($command, $options, $params)
|
||||
{
|
||||
// $params[0] -> the PEAR package to list its information
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("bad parameter(s), try \"help $command\"");
|
||||
}
|
||||
$obj = &$this->getPackageFile($this->config, $this->_debug);
|
||||
$info = $obj->fromAnyFile($params[0], PEAR_VALIDATE_NORMAL);
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
$deps = $info->getDeps();
|
||||
if (is_array($deps)) {
|
||||
if ($info->getPackagexmlVersion() == '1.0') {
|
||||
$data = array(
|
||||
'caption' => 'Dependencies for pear/' . $info->getPackage(),
|
||||
'border' => true,
|
||||
'headline' => array("Required?", "Type", "Name", "Relation", "Version"),
|
||||
);
|
||||
|
||||
foreach ($deps as $d) {
|
||||
if (isset($d['optional'])) {
|
||||
if ($d['optional'] == 'yes') {
|
||||
$req = 'No';
|
||||
} else {
|
||||
$req = 'Yes';
|
||||
}
|
||||
} else {
|
||||
$req = 'Yes';
|
||||
}
|
||||
if (isset($this->_deps_rel_trans[$d['rel']])) {
|
||||
$rel = $this->_deps_rel_trans[$d['rel']];
|
||||
} else {
|
||||
$rel = $d['rel'];
|
||||
}
|
||||
|
||||
if (isset($this->_deps_type_trans[$d['type']])) {
|
||||
$type = ucfirst($this->_deps_type_trans[$d['type']]);
|
||||
} else {
|
||||
$type = $d['type'];
|
||||
}
|
||||
|
||||
if (isset($d['name'])) {
|
||||
$name = $d['name'];
|
||||
} else {
|
||||
$name = '';
|
||||
}
|
||||
|
||||
if (isset($d['version'])) {
|
||||
$version = $d['version'];
|
||||
} else {
|
||||
$version = '';
|
||||
}
|
||||
|
||||
$data['data'][] = array($req, $type, $name, $rel, $version);
|
||||
}
|
||||
} else { // package.xml 2.0 dependencies display
|
||||
require_once 'PEAR/Dependency2.php';
|
||||
$deps = $info->getDependencies();
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (is_array($deps)) {
|
||||
$d = new PEAR_Dependency2($this->config, array(), '');
|
||||
$data = array(
|
||||
'caption' => 'Dependencies for ' . $info->getPackage(),
|
||||
'border' => true,
|
||||
'headline' => array("Required?", "Type", "Name", 'Versioning', 'Group'),
|
||||
);
|
||||
foreach ($deps as $type => $subd) {
|
||||
$req = ($type == 'required') ? 'Yes' : 'No';
|
||||
if ($type == 'group') {
|
||||
$group = $subd['attribs']['name'];
|
||||
} else {
|
||||
$group = '';
|
||||
}
|
||||
if (!isset($subd[0])) {
|
||||
$subd = array($subd);
|
||||
}
|
||||
foreach ($subd as $groupa) {
|
||||
foreach ($groupa as $deptype => $depinfo) {
|
||||
if ($deptype == 'attribs') {
|
||||
continue;
|
||||
}
|
||||
if ($deptype == 'pearinstaller') {
|
||||
$deptype = 'pear Installer';
|
||||
}
|
||||
if (!isset($depinfo[0])) {
|
||||
$depinfo = array($depinfo);
|
||||
}
|
||||
foreach ($depinfo as $inf) {
|
||||
$name = '';
|
||||
if (isset($inf['channel'])) {
|
||||
$alias = $reg->channelAlias($inf['channel']);
|
||||
if (!$alias) {
|
||||
$alias = '(channel?) ' .$inf['channel'];
|
||||
}
|
||||
$name = $alias . '/';
|
||||
}
|
||||
if (isset($inf['name'])) {
|
||||
$name .= $inf['name'];
|
||||
} elseif (isset($inf['pattern'])) {
|
||||
$name .= $inf['pattern'];
|
||||
} else {
|
||||
$name .= '';
|
||||
}
|
||||
if (isset($inf['uri'])) {
|
||||
$name .= ' [' . $inf['uri'] . ']';
|
||||
}
|
||||
if (isset($inf['conflicts'])) {
|
||||
$ver = 'conflicts';
|
||||
} else {
|
||||
$ver = $d->_getExtraString($inf);
|
||||
}
|
||||
$data['data'][] = array($req, ucfirst($deptype), $name,
|
||||
$ver, $group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->ui->outputData($data, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fallback
|
||||
$this->ui->outputData("This package does not have any dependencies.", $command);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doSign()
|
||||
|
||||
function doSign($command, $options, $params)
|
||||
{
|
||||
require_once 'System.php';
|
||||
require_once 'Archive/Tar.php';
|
||||
// should move most of this code into PEAR_Packager
|
||||
// so it'll be easy to implement "pear package --sign"
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("bad parameter(s), try \"help $command\"");
|
||||
}
|
||||
if (!file_exists($params[0])) {
|
||||
return $this->raiseError("file does not exist: $params[0]");
|
||||
}
|
||||
$obj = $this->getPackageFile($this->config, $this->_debug);
|
||||
$info = $obj->fromTgzFile($params[0], PEAR_VALIDATE_NORMAL);
|
||||
if (PEAR::isError($info)) {
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
$tar = new Archive_Tar($params[0]);
|
||||
$tmpdir = System::mktemp('-d pearsign');
|
||||
if (!$tar->extractList('package2.xml package.xml package.sig', $tmpdir)) {
|
||||
return $this->raiseError("failed to extract tar file");
|
||||
}
|
||||
if (file_exists("$tmpdir/package.sig")) {
|
||||
return $this->raiseError("package already signed");
|
||||
}
|
||||
$packagexml = 'package.xml';
|
||||
if (file_exists("$tmpdir/package2.xml")) {
|
||||
$packagexml = 'package2.xml';
|
||||
}
|
||||
if (file_exists("$tmpdir/package.sig")) {
|
||||
unlink("$tmpdir/package.sig");
|
||||
}
|
||||
if (!file_exists("$tmpdir/$packagexml")) {
|
||||
return $this->raiseError("Extracted file $tmpdir/$packagexml not found.");
|
||||
}
|
||||
$input = $this->ui->userDialog($command,
|
||||
array('GnuPG Passphrase'),
|
||||
array('password'));
|
||||
if (!isset($input[0])) {
|
||||
//use empty passphrase
|
||||
$input[0] = '';
|
||||
}
|
||||
|
||||
$devnull = (isset($options['verbose'])) ? '' : ' 2>/dev/null';
|
||||
$gpg = popen("gpg --batch --passphrase-fd 0 --armor --detach-sign --output $tmpdir/package.sig $tmpdir/$packagexml" . $devnull, "w");
|
||||
if (!$gpg) {
|
||||
return $this->raiseError("gpg command failed");
|
||||
}
|
||||
fwrite($gpg, "$input[0]\n");
|
||||
if (pclose($gpg) || !file_exists("$tmpdir/package.sig")) {
|
||||
return $this->raiseError("gpg sign failed");
|
||||
}
|
||||
if (!$tar->addModify("$tmpdir/package.sig", '', $tmpdir)) {
|
||||
return $this->raiseError('failed adding signature to file');
|
||||
}
|
||||
|
||||
$this->ui->outputData("Package signed.", $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
/**
|
||||
* For unit testing purposes
|
||||
*/
|
||||
function &getInstaller(&$ui)
|
||||
{
|
||||
if (!class_exists('PEAR_Installer')) {
|
||||
require_once 'PEAR/Installer.php';
|
||||
}
|
||||
$a = &new PEAR_Installer($ui);
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* For unit testing purposes
|
||||
*/
|
||||
function &getCommandPackaging(&$ui, &$config)
|
||||
{
|
||||
if (!class_exists('PEAR_Command_Packaging')) {
|
||||
if ($fp = @fopen('PEAR/Command/Packaging.php', 'r', true)) {
|
||||
fclose($fp);
|
||||
include_once 'PEAR/Command/Packaging.php';
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists('PEAR_Command_Packaging')) {
|
||||
$a = &new PEAR_Command_Packaging($ui, $config);
|
||||
} else {
|
||||
$a = null;
|
||||
}
|
||||
return $a;
|
||||
}
|
||||
|
||||
// {{{ doMakeRPM()
|
||||
|
||||
function doMakeRPM($command, $options, $params)
|
||||
{
|
||||
|
||||
// Check to see if PEAR_Command_Packaging is installed, and
|
||||
// transparently switch to use the "make-rpm-spec" command from it
|
||||
// instead, if it does. Otherwise, continue to use the old version
|
||||
// of "makerpm" supplied with this package (PEAR).
|
||||
$packaging_cmd = $this->getCommandPackaging($this->ui, $this->config);
|
||||
if ($packaging_cmd !== null) {
|
||||
$this->ui->outputData('PEAR_Command_Packaging is installed; using '.
|
||||
'newer "make-rpm-spec" command instead');
|
||||
return $packaging_cmd->run('make-rpm-spec', $options, $params);
|
||||
} else {
|
||||
$this->ui->outputData('WARNING: "pear makerpm" is no longer available; an '.
|
||||
'improved version is available via "pear make-rpm-spec", which '.
|
||||
'is available by installing PEAR_Command_Packaging');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function doConvert($command, $options, $params)
|
||||
{
|
||||
$packagexml = isset($params[0]) ? $params[0] : 'package.xml';
|
||||
$newpackagexml = isset($params[1]) ? $params[1] : dirname($packagexml) .
|
||||
DIRECTORY_SEPARATOR . 'package2.xml';
|
||||
$pkg = &$this->getPackageFile($this->config, $this->_debug);
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$pf = $pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (!PEAR::isError($pf)) {
|
||||
if (is_a($pf, 'PEAR_PackageFile_v2')) {
|
||||
$this->ui->outputData($packagexml . ' is already a package.xml version 2.0');
|
||||
return true;
|
||||
}
|
||||
$gen = &$pf->getDefaultGenerator();
|
||||
$newpf = &$gen->toV2();
|
||||
$newpf->setPackagefile($newpackagexml);
|
||||
$gen = &$newpf->getDefaultGenerator();
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$state = (isset($options['flat']) ? PEAR_VALIDATE_PACKAGING : PEAR_VALIDATE_NORMAL);
|
||||
$saved = $gen->toPackageFile(dirname($newpackagexml), $state,
|
||||
basename($newpackagexml));
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($saved)) {
|
||||
if (is_array($saved->getUserInfo())) {
|
||||
foreach ($saved->getUserInfo() as $warning) {
|
||||
$this->ui->outputData($warning['message']);
|
||||
}
|
||||
}
|
||||
$this->ui->outputData($saved->getMessage());
|
||||
return true;
|
||||
}
|
||||
$this->ui->outputData('Wrote new version 2.0 package.xml to "' . $saved . '"');
|
||||
return true;
|
||||
} else {
|
||||
if (is_array($pf->getUserInfo())) {
|
||||
foreach ($pf->getUserInfo() as $warning) {
|
||||
$this->ui->outputData($warning['message']);
|
||||
}
|
||||
}
|
||||
return $this->raiseError($pf);
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
194
vendor/library/Excel/phpxls/PEAR/Command/Package.xml
vendored
Normal file
194
vendor/library/Excel/phpxls/PEAR/Command/Package.xml
vendored
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
<commands version="1.0">
|
||||
<package>
|
||||
<summary>Build Package</summary>
|
||||
<function>doPackage</function>
|
||||
<shortcut>p</shortcut>
|
||||
<options>
|
||||
<nocompress>
|
||||
<shortopt>Z</shortopt>
|
||||
<doc>Do not gzip the package file</doc>
|
||||
</nocompress>
|
||||
<showname>
|
||||
<shortopt>n</shortopt>
|
||||
<doc>Print the name of the packaged file.</doc>
|
||||
</showname>
|
||||
</options>
|
||||
<doc>[descfile] [descfile2]
|
||||
Creates a PEAR package from its description file (usually called
|
||||
package.xml). If a second packagefile is passed in, then
|
||||
the packager will check to make sure that one is a package.xml
|
||||
version 1.0, and the other is a package.xml version 2.0. The
|
||||
package.xml version 1.0 will be saved as "package.xml" in the archive,
|
||||
and the other as "package2.xml" in the archive"
|
||||
</doc>
|
||||
</package>
|
||||
<package-validate>
|
||||
<summary>Validate Package Consistency</summary>
|
||||
<function>doPackageValidate</function>
|
||||
<shortcut>pv</shortcut>
|
||||
<options />
|
||||
<doc>
|
||||
</doc>
|
||||
</package-validate>
|
||||
<cvsdiff>
|
||||
<summary>Run a "cvs diff" for all files in a package</summary>
|
||||
<function>doCvsDiff</function>
|
||||
<shortcut>cd</shortcut>
|
||||
<options>
|
||||
<quiet>
|
||||
<shortopt>q</shortopt>
|
||||
<doc>Be quiet</doc>
|
||||
</quiet>
|
||||
<reallyquiet>
|
||||
<shortopt>Q</shortopt>
|
||||
<doc>Be really quiet</doc>
|
||||
</reallyquiet>
|
||||
<date>
|
||||
<shortopt>D</shortopt>
|
||||
<doc>Diff against revision of DATE</doc>
|
||||
<arg>DATE</arg>
|
||||
</date>
|
||||
<release>
|
||||
<shortopt>R</shortopt>
|
||||
<doc>Diff against tag for package release REL</doc>
|
||||
<arg>REL</arg>
|
||||
</release>
|
||||
<revision>
|
||||
<shortopt>r</shortopt>
|
||||
<doc>Diff against revision REV</doc>
|
||||
<arg>REV</arg>
|
||||
</revision>
|
||||
<context>
|
||||
<shortopt>c</shortopt>
|
||||
<doc>Generate context diff</doc>
|
||||
</context>
|
||||
<unified>
|
||||
<shortopt>u</shortopt>
|
||||
<doc>Generate unified diff</doc>
|
||||
</unified>
|
||||
<ignore-case>
|
||||
<shortopt>i</shortopt>
|
||||
<doc>Ignore case, consider upper- and lower-case letters equivalent</doc>
|
||||
</ignore-case>
|
||||
<ignore-whitespace>
|
||||
<shortopt>b</shortopt>
|
||||
<doc>Ignore changes in amount of white space</doc>
|
||||
</ignore-whitespace>
|
||||
<ignore-blank-lines>
|
||||
<shortopt>B</shortopt>
|
||||
<doc>Ignore changes that insert or delete blank lines</doc>
|
||||
</ignore-blank-lines>
|
||||
<brief>
|
||||
<doc>Report only whether the files differ, no details</doc>
|
||||
</brief>
|
||||
<dry-run>
|
||||
<shortopt>n</shortopt>
|
||||
<doc>Don't do anything, just pretend</doc>
|
||||
</dry-run>
|
||||
</options>
|
||||
<doc><package.xml>
|
||||
Compares all the files in a package. Without any options, this
|
||||
command will compare the current code with the last checked-in code.
|
||||
Using the -r or -R option you may compare the current code with that
|
||||
of a specific release.
|
||||
</doc>
|
||||
</cvsdiff>
|
||||
<cvstag>
|
||||
<summary>Set CVS Release Tag</summary>
|
||||
<function>doCvsTag</function>
|
||||
<shortcut>ct</shortcut>
|
||||
<options>
|
||||
<quiet>
|
||||
<shortopt>q</shortopt>
|
||||
<doc>Be quiet</doc>
|
||||
</quiet>
|
||||
<reallyquiet>
|
||||
<shortopt>Q</shortopt>
|
||||
<doc>Be really quiet</doc>
|
||||
</reallyquiet>
|
||||
<slide>
|
||||
<shortopt>F</shortopt>
|
||||
<doc>Move (slide) tag if it exists</doc>
|
||||
</slide>
|
||||
<delete>
|
||||
<shortopt>d</shortopt>
|
||||
<doc>Remove tag</doc>
|
||||
</delete>
|
||||
<dry-run>
|
||||
<shortopt>n</shortopt>
|
||||
<doc>Don't do anything, just pretend</doc>
|
||||
</dry-run>
|
||||
</options>
|
||||
<doc><package.xml>
|
||||
Sets a CVS tag on all files in a package. Use this command after you have
|
||||
packaged a distribution tarball with the "package" command to tag what
|
||||
revisions of what files were in that release. If need to fix something
|
||||
after running cvstag once, but before the tarball is released to the public,
|
||||
use the "slide" option to move the release tag.
|
||||
</doc>
|
||||
</cvstag>
|
||||
<package-dependencies>
|
||||
<summary>Show package dependencies</summary>
|
||||
<function>doPackageDependencies</function>
|
||||
<shortcut>pd</shortcut>
|
||||
<options />
|
||||
<doc>
|
||||
List all dependencies the package has.</doc>
|
||||
</package-dependencies>
|
||||
<sign>
|
||||
<summary>Sign a package distribution file</summary>
|
||||
<function>doSign</function>
|
||||
<shortcut>si</shortcut>
|
||||
<options />
|
||||
<doc><package-file>
|
||||
Signs a package distribution (.tar or .tgz) file with GnuPG.</doc>
|
||||
</sign>
|
||||
<makerpm>
|
||||
<summary>Builds an RPM spec file from a PEAR package</summary>
|
||||
<function>doMakeRPM</function>
|
||||
<shortcut>rpm</shortcut>
|
||||
<options>
|
||||
<spec-template>
|
||||
<shortopt>t</shortopt>
|
||||
<arg>FILE</arg>
|
||||
<doc>Use FILE as RPM spec file template</doc>
|
||||
</spec-template>
|
||||
<rpm-pkgname>
|
||||
<shortopt>p</shortopt>
|
||||
<arg>FORMAT</arg>
|
||||
<doc>Use FORMAT as format string for RPM package name, %s is replaced
|
||||
by the PEAR package name, defaults to "PEAR::%s".</doc>
|
||||
</rpm-pkgname>
|
||||
</options>
|
||||
<doc><package-file>
|
||||
|
||||
Creates an RPM .spec file for wrapping a PEAR package inside an RPM
|
||||
package. Intended to be used from the SPECS directory, with the PEAR
|
||||
package tarball in the SOURCES directory:
|
||||
|
||||
$ pear makerpm ../SOURCES/Net_Socket-1.0.tgz
|
||||
Wrote RPM spec file PEAR::Net_Geo-1.0.spec
|
||||
$ rpm -bb PEAR::Net_Socket-1.0.spec
|
||||
...
|
||||
Wrote: /usr/src/redhat/RPMS/i386/PEAR::Net_Socket-1.0-1.i386.rpm
|
||||
</doc>
|
||||
</makerpm>
|
||||
<convert>
|
||||
<summary>Convert a package.xml 1.0 to package.xml 2.0 format</summary>
|
||||
<function>doConvert</function>
|
||||
<shortcut>c2</shortcut>
|
||||
<options>
|
||||
<flat>
|
||||
<shortopt>f</shortopt>
|
||||
<doc>do not beautify the filelist.</doc>
|
||||
</flat>
|
||||
</options>
|
||||
<doc>[descfile] [descfile2]
|
||||
Converts a package.xml in 1.0 format into a package.xml
|
||||
in 2.0 format. The new file will be named package2.xml by default,
|
||||
and package.xml will be used as the old file by default.
|
||||
This is not the most intelligent conversion, and should only be
|
||||
used for automated conversion or learning the format.
|
||||
</doc>
|
||||
</convert>
|
||||
</commands>
|
||||
376
vendor/library/Excel/phpxls/PEAR/Command/Pickle.php
vendored
Normal file
376
vendor/library/Excel/phpxls/PEAR/Command/Pickle.php
vendored
Normal file
|
|
@ -0,0 +1,376 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Command_Pickle (pickle command)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 2005-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Pickle.php,v 1.8 2008/01/29 03:21:01 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
|
||||
/**
|
||||
* PEAR commands for login/logout
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 2005-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.1
|
||||
*/
|
||||
|
||||
class PEAR_Command_Pickle extends PEAR_Command_Common
|
||||
{
|
||||
var $commands = array(
|
||||
'pickle' => array(
|
||||
'summary' => 'Build PECL Package',
|
||||
'function' => 'doPackage',
|
||||
'shortcut' => 'pi',
|
||||
'options' => array(
|
||||
'nocompress' => array(
|
||||
'shortopt' => 'Z',
|
||||
'doc' => 'Do not gzip the package file'
|
||||
),
|
||||
'showname' => array(
|
||||
'shortopt' => 'n',
|
||||
'doc' => 'Print the name of the packaged file.',
|
||||
),
|
||||
),
|
||||
'doc' => '[descfile]
|
||||
Creates a PECL package from its package2.xml file.
|
||||
|
||||
An automatic conversion will be made to a package.xml 1.0 and written out to
|
||||
disk in the current directory as "package.xml". Note that
|
||||
only simple package.xml 2.0 will be converted. package.xml 2.0 with:
|
||||
|
||||
- dependency types other than required/optional PECL package/ext/php/pearinstaller
|
||||
- more than one extsrcrelease or zendextsrcrelease
|
||||
- zendextbinrelease, extbinrelease, phprelease, or bundle release type
|
||||
- dependency groups
|
||||
- ignore tags in release filelist
|
||||
- tasks other than replace
|
||||
- custom roles
|
||||
|
||||
will cause pickle to fail, and output an error message. If your package2.xml
|
||||
uses any of these features, you are best off using PEAR_PackageFileManager to
|
||||
generate both package.xml.
|
||||
'
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* PEAR_Command_Package constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Pickle(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For unit-testing ease
|
||||
*
|
||||
* @return PEAR_Packager
|
||||
*/
|
||||
function &getPackager()
|
||||
{
|
||||
if (!class_exists('PEAR_Packager')) {
|
||||
require_once 'PEAR/Packager.php';
|
||||
}
|
||||
$a = &new PEAR_Packager;
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* For unit-testing ease
|
||||
*
|
||||
* @param PEAR_Config $config
|
||||
* @param bool $debug
|
||||
* @param string|null $tmpdir
|
||||
* @return PEAR_PackageFile
|
||||
*/
|
||||
function &getPackageFile($config, $debug = false, $tmpdir = null)
|
||||
{
|
||||
if (!class_exists('PEAR_Common')) {
|
||||
require_once 'PEAR/Common.php';
|
||||
}
|
||||
if (!class_exists('PEAR_PackageFile')) {
|
||||
require_once 'PEAR/PackageFile.php';
|
||||
}
|
||||
$a = &new PEAR_PackageFile($config, $debug, $tmpdir);
|
||||
$common = new PEAR_Common;
|
||||
$common->ui = $this->ui;
|
||||
$a->setLogger($common);
|
||||
return $a;
|
||||
}
|
||||
|
||||
function doPackage($command, $options, $params)
|
||||
{
|
||||
$this->output = '';
|
||||
$pkginfofile = isset($params[0]) ? $params[0] : 'package2.xml';
|
||||
$packager = &$this->getPackager();
|
||||
if (PEAR::isError($err = $this->_convertPackage($pkginfofile))) {
|
||||
return $err;
|
||||
}
|
||||
$compress = empty($options['nocompress']) ? true : false;
|
||||
$result = $packager->package($pkginfofile, $compress, 'package.xml');
|
||||
if (PEAR::isError($result)) {
|
||||
return $this->raiseError($result);
|
||||
}
|
||||
// Don't want output, only the package file name just created
|
||||
if (isset($options['showname'])) {
|
||||
$this->ui->outputData($result, $command);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function _convertPackage($packagexml)
|
||||
{
|
||||
$pkg = &$this->getPackageFile($this->config);
|
||||
$pf2 = &$pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
|
||||
if (!is_a($pf2, 'PEAR_PackageFile_v2')) {
|
||||
return $this->raiseError('Cannot process "' .
|
||||
$packagexml . '", is not a package.xml 2.0');
|
||||
}
|
||||
require_once 'PEAR/PackageFile/v1.php';
|
||||
$pf = new PEAR_PackageFile_v1;
|
||||
$pf->setConfig($this->config);
|
||||
if ($pf2->getPackageType() != 'extsrc' && $pf2->getPackageType() != 'zendextsrc') {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml .
|
||||
'", is not an extension source package. Using a PEAR_PackageFileManager-based ' .
|
||||
'script is an option');
|
||||
}
|
||||
if (is_array($pf2->getUsesRole())) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml .
|
||||
'", contains custom roles. Using a PEAR_PackageFileManager-based script or ' .
|
||||
'the convert command is an option');
|
||||
}
|
||||
if (is_array($pf2->getUsesTask())) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml .
|
||||
'", contains custom tasks. Using a PEAR_PackageFileManager-based script or ' .
|
||||
'the convert command is an option');
|
||||
}
|
||||
$deps = $pf2->getDependencies();
|
||||
if (isset($deps['group'])) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml .
|
||||
'", contains dependency groups. Using a PEAR_PackageFileManager-based script ' .
|
||||
'or the convert command is an option');
|
||||
}
|
||||
if (isset($deps['required']['subpackage']) ||
|
||||
isset($deps['optional']['subpackage'])) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml .
|
||||
'", contains subpackage dependencies. Using a PEAR_PackageFileManager-based '.
|
||||
'script is an option');
|
||||
}
|
||||
if (isset($deps['required']['os'])) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml .
|
||||
'", contains os dependencies. Using a PEAR_PackageFileManager-based '.
|
||||
'script is an option');
|
||||
}
|
||||
if (isset($deps['required']['arch'])) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml .
|
||||
'", contains arch dependencies. Using a PEAR_PackageFileManager-based '.
|
||||
'script is an option');
|
||||
}
|
||||
$pf->setPackage($pf2->getPackage());
|
||||
$pf->setSummary($pf2->getSummary());
|
||||
$pf->setDescription($pf2->getDescription());
|
||||
foreach ($pf2->getMaintainers() as $maintainer) {
|
||||
$pf->addMaintainer($maintainer['role'], $maintainer['handle'],
|
||||
$maintainer['name'], $maintainer['email']);
|
||||
}
|
||||
$pf->setVersion($pf2->getVersion());
|
||||
$pf->setDate($pf2->getDate());
|
||||
$pf->setLicense($pf2->getLicense());
|
||||
$pf->setState($pf2->getState());
|
||||
$pf->setNotes($pf2->getNotes());
|
||||
$pf->addPhpDep($deps['required']['php']['min'], 'ge');
|
||||
if (isset($deps['required']['php']['max'])) {
|
||||
$pf->addPhpDep($deps['required']['php']['max'], 'le');
|
||||
}
|
||||
if (isset($deps['required']['package'])) {
|
||||
if (!isset($deps['required']['package'][0])) {
|
||||
$deps['required']['package'] = array($deps['required']['package']);
|
||||
}
|
||||
foreach ($deps['required']['package'] as $dep) {
|
||||
if (!isset($dep['channel'])) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
|
||||
' contains uri-based dependency on a package. Using a ' .
|
||||
'PEAR_PackageFileManager-based script is an option');
|
||||
}
|
||||
if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
|
||||
' contains dependency on a non-standard channel package. Using a ' .
|
||||
'PEAR_PackageFileManager-based script is an option');
|
||||
}
|
||||
if (isset($dep['conflicts'])) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
|
||||
' contains conflicts dependency. Using a ' .
|
||||
'PEAR_PackageFileManager-based script is an option');
|
||||
}
|
||||
if (isset($dep['exclude'])) {
|
||||
$this->ui->outputData('WARNING: exclude tags are ignored in conversion');
|
||||
}
|
||||
if (isset($dep['min'])) {
|
||||
$pf->addPackageDep($dep['name'], $dep['min'], 'ge');
|
||||
}
|
||||
if (isset($dep['max'])) {
|
||||
$pf->addPackageDep($dep['name'], $dep['max'], 'le');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($deps['required']['extension'])) {
|
||||
if (!isset($deps['required']['extension'][0])) {
|
||||
$deps['required']['extension'] = array($deps['required']['extension']);
|
||||
}
|
||||
foreach ($deps['required']['extension'] as $dep) {
|
||||
if (isset($dep['conflicts'])) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
|
||||
' contains conflicts dependency. Using a ' .
|
||||
'PEAR_PackageFileManager-based script is an option');
|
||||
}
|
||||
if (isset($dep['exclude'])) {
|
||||
$this->ui->outputData('WARNING: exclude tags are ignored in conversion');
|
||||
}
|
||||
if (isset($dep['min'])) {
|
||||
$pf->addExtensionDep($dep['name'], $dep['min'], 'ge');
|
||||
}
|
||||
if (isset($dep['max'])) {
|
||||
$pf->addExtensionDep($dep['name'], $dep['max'], 'le');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($deps['optional']['package'])) {
|
||||
if (!isset($deps['optional']['package'][0])) {
|
||||
$deps['optional']['package'] = array($deps['optional']['package']);
|
||||
}
|
||||
foreach ($deps['optional']['package'] as $dep) {
|
||||
if (!isset($dep['channel'])) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
|
||||
' contains uri-based dependency on a package. Using a ' .
|
||||
'PEAR_PackageFileManager-based script is an option');
|
||||
}
|
||||
if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' .
|
||||
' contains dependency on a non-standard channel package. Using a ' .
|
||||
'PEAR_PackageFileManager-based script is an option');
|
||||
}
|
||||
if (isset($dep['exclude'])) {
|
||||
$this->ui->outputData('WARNING: exclude tags are ignored in conversion');
|
||||
}
|
||||
if (isset($dep['min'])) {
|
||||
$pf->addPackageDep($dep['name'], $dep['min'], 'ge', 'yes');
|
||||
}
|
||||
if (isset($dep['max'])) {
|
||||
$pf->addPackageDep($dep['name'], $dep['max'], 'le', 'yes');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($deps['optional']['extension'])) {
|
||||
if (!isset($deps['optional']['extension'][0])) {
|
||||
$deps['optional']['extension'] = array($deps['optional']['extension']);
|
||||
}
|
||||
foreach ($deps['optional']['extension'] as $dep) {
|
||||
if (isset($dep['exclude'])) {
|
||||
$this->ui->outputData('WARNING: exclude tags are ignored in conversion');
|
||||
}
|
||||
if (isset($dep['min'])) {
|
||||
$pf->addExtensionDep($dep['name'], $dep['min'], 'ge', 'yes');
|
||||
}
|
||||
if (isset($dep['max'])) {
|
||||
$pf->addExtensionDep($dep['name'], $dep['max'], 'le', 'yes');
|
||||
}
|
||||
}
|
||||
}
|
||||
$contents = $pf2->getContents();
|
||||
$release = $pf2->getReleases();
|
||||
if (isset($releases[0])) {
|
||||
return $this->raiseError('Cannot safely process "' . $packagexml . '" contains '
|
||||
. 'multiple extsrcrelease/zendextsrcrelease tags. Using a PEAR_PackageFileManager-based script ' .
|
||||
'or the convert command is an option');
|
||||
}
|
||||
if ($configoptions = $pf2->getConfigureOptions()) {
|
||||
foreach ($configoptions as $option) {
|
||||
$pf->addConfigureOption($option['name'], $option['prompt'],
|
||||
isset($option['default']) ? $option['default'] : false);
|
||||
}
|
||||
}
|
||||
if (isset($release['filelist']['ignore'])) {
|
||||
return $this->raiseError('Cannot safely process "' . $packagexml . '" contains '
|
||||
. 'ignore tags. Using a PEAR_PackageFileManager-based script or the convert' .
|
||||
' command is an option');
|
||||
}
|
||||
if (isset($release['filelist']['install']) &&
|
||||
!isset($release['filelist']['install'][0])) {
|
||||
$release['filelist']['install'] = array($release['filelist']['install']);
|
||||
}
|
||||
if (isset($contents['dir']['attribs']['baseinstalldir'])) {
|
||||
$baseinstalldir = $contents['dir']['attribs']['baseinstalldir'];
|
||||
} else {
|
||||
$baseinstalldir = false;
|
||||
}
|
||||
if (!isset($contents['dir']['file'][0])) {
|
||||
$contents['dir']['file'] = array($contents['dir']['file']);
|
||||
}
|
||||
foreach ($contents['dir']['file'] as $file) {
|
||||
if ($baseinstalldir && !isset($file['attribs']['baseinstalldir'])) {
|
||||
$file['attribs']['baseinstalldir'] = $baseinstalldir;
|
||||
}
|
||||
$processFile = $file;
|
||||
unset($processFile['attribs']);
|
||||
if (count($processFile)) {
|
||||
foreach ($processFile as $name => $task) {
|
||||
if ($name != $pf2->getTasksNs() . ':replace') {
|
||||
return $this->raiseError('Cannot safely process "' . $packagexml .
|
||||
'" contains tasks other than replace. Using a ' .
|
||||
'PEAR_PackageFileManager-based script is an option.');
|
||||
}
|
||||
$file['attribs']['replace'][] = $task;
|
||||
}
|
||||
}
|
||||
if (!in_array($file['attribs']['role'], PEAR_Common::getFileRoles())) {
|
||||
return $this->raiseError('Cannot safely convert "' . $packagexml .
|
||||
'", contains custom roles. Using a PEAR_PackageFileManager-based script ' .
|
||||
'or the convert command is an option');
|
||||
}
|
||||
if (isset($release['filelist']['install'])) {
|
||||
foreach ($release['filelist']['install'] as $installas) {
|
||||
if ($installas['attribs']['name'] == $file['attribs']['name']) {
|
||||
$file['attribs']['install-as'] = $installas['attribs']['as'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$pf->addFile('/', $file['attribs']['name'], $file['attribs']);
|
||||
}
|
||||
if ($pf2->getChangeLog()) {
|
||||
$this->ui->outputData('WARNING: changelog is not translated to package.xml ' .
|
||||
'1.0, use PEAR_PackageFileManager-based script if you need changelog-' .
|
||||
'translation for package.xml 1.0');
|
||||
}
|
||||
$gen = &$pf->getDefaultGenerator();
|
||||
$gen->toPackageFile('.');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
40
vendor/library/Excel/phpxls/PEAR/Command/Pickle.xml
vendored
Normal file
40
vendor/library/Excel/phpxls/PEAR/Command/Pickle.xml
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<commands version="1.0">
|
||||
<pickle>
|
||||
<summary>Build PECL Package</summary>
|
||||
<function>doPackage</function>
|
||||
<shortcut>pi</shortcut>
|
||||
<options>
|
||||
<nocompress>
|
||||
<shortopt>Z</shortopt>
|
||||
<doc>Do not gzip the package file</doc>
|
||||
</nocompress>
|
||||
<showname>
|
||||
<shortopt>n</shortopt>
|
||||
<doc>Print the name of the packaged file.</doc>
|
||||
</showname>
|
||||
</options>
|
||||
<doc>[descfile] [descfile2]
|
||||
Creates a PECL package from its description file (usually called
|
||||
package.xml). If a second packagefile is passed in, then
|
||||
the packager will check to make sure that one is a package.xml
|
||||
version 1.0, and the other is a package.xml version 2.0. The
|
||||
package.xml version 1.0 will be saved as "package.xml" in the archive,
|
||||
and the other as "package2.xml" in the archive"
|
||||
|
||||
If no second file is passed in, and [descfile] is a package.xml 2.0,
|
||||
an automatic conversion will be made to a package.xml 1.0. Note that
|
||||
only simple package.xml 2.0 will be converted. package.xml 2.0 with:
|
||||
|
||||
- dependency types other than required/optional PECL package/ext/php/pearinstaller
|
||||
- more than one extsrcrelease/zendextsrcrelease
|
||||
- zendextbinrelease, extbinrelease, phprelease, or bundle release type
|
||||
- dependency groups
|
||||
- ignore tags in release filelist
|
||||
- tasks other than replace
|
||||
- custom roles
|
||||
|
||||
will cause pickle to fail, and output an error message. If your package2.xml
|
||||
uses any of these features, you are best off using PEAR_PackageFileManager to
|
||||
generate both package.xml.</doc>
|
||||
</pickle>
|
||||
</commands>
|
||||
1070
vendor/library/Excel/phpxls/PEAR/Command/Registry.php
vendored
Normal file
1070
vendor/library/Excel/phpxls/PEAR/Command/Registry.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
58
vendor/library/Excel/phpxls/PEAR/Command/Registry.xml
vendored
Normal file
58
vendor/library/Excel/phpxls/PEAR/Command/Registry.xml
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<commands version="1.0">
|
||||
<list>
|
||||
<summary>List Installed Packages In The Default Channel</summary>
|
||||
<function>doList</function>
|
||||
<shortcut>l</shortcut>
|
||||
<options>
|
||||
<channel>
|
||||
<shortopt>c</shortopt>
|
||||
<doc>list installed packages from this channel</doc>
|
||||
<arg>CHAN</arg>
|
||||
</channel>
|
||||
<allchannels>
|
||||
<shortopt>a</shortopt>
|
||||
<doc>list installed packages from all channels</doc>
|
||||
</allchannels>
|
||||
<channelinfo>
|
||||
<shortopt>i</shortopt>
|
||||
<doc>output fully channel-aware data, even on failure</doc>
|
||||
</channelinfo>
|
||||
</options>
|
||||
<doc><package>
|
||||
If invoked without parameters, this command lists the PEAR packages
|
||||
installed in your php_dir ({config php_dir}). With a parameter, it
|
||||
lists the files in a package.
|
||||
</doc>
|
||||
</list>
|
||||
<list-files>
|
||||
<summary>List Files In Installed Package</summary>
|
||||
<function>doFileList</function>
|
||||
<shortcut>fl</shortcut>
|
||||
<options />
|
||||
<doc><package>
|
||||
List the files in an installed package.
|
||||
</doc>
|
||||
</list-files>
|
||||
<shell-test>
|
||||
<summary>Shell Script Test</summary>
|
||||
<function>doShellTest</function>
|
||||
<shortcut>st</shortcut>
|
||||
<options />
|
||||
<doc><package> [[relation] version]
|
||||
Tests if a package is installed in the system. Will exit(1) if it is not.
|
||||
<relation> The version comparison operator. One of:
|
||||
<, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne
|
||||
<version> The version to compare with
|
||||
</doc>
|
||||
</shell-test>
|
||||
<info>
|
||||
<summary>Display information about a package</summary>
|
||||
<function>doInfo</function>
|
||||
<shortcut>in</shortcut>
|
||||
<options />
|
||||
<doc><package>
|
||||
Displays information about a package. The package argument may be a
|
||||
local package file, an URL to a package file, or the name of an
|
||||
installed package.</doc>
|
||||
</info>
|
||||
</commands>
|
||||
812
vendor/library/Excel/phpxls/PEAR/Command/Remote.php
vendored
Normal file
812
vendor/library/Excel/phpxls/PEAR/Command/Remote.php
vendored
Normal file
|
|
@ -0,0 +1,812 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Command_Remote (remote-info, list-upgrades, remote-list, search, list-all, download,
|
||||
* clear-cache commands)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Remote.php,v 1.107 2008/04/11 01:16:40 dufuz Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
require_once 'PEAR/REST.php';
|
||||
|
||||
/**
|
||||
* PEAR commands for remote server querying
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
class PEAR_Command_Remote extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ command definitions
|
||||
|
||||
var $commands = array(
|
||||
'remote-info' => array(
|
||||
'summary' => 'Information About Remote Packages',
|
||||
'function' => 'doRemoteInfo',
|
||||
'shortcut' => 'ri',
|
||||
'options' => array(),
|
||||
'doc' => '<package>
|
||||
Get details on a package from the server.',
|
||||
),
|
||||
'list-upgrades' => array(
|
||||
'summary' => 'List Available Upgrades',
|
||||
'function' => 'doListUpgrades',
|
||||
'shortcut' => 'lu',
|
||||
'options' => array(
|
||||
'channelinfo' => array(
|
||||
'shortopt' => 'i',
|
||||
'doc' => 'output fully channel-aware data, even on failure',
|
||||
),
|
||||
),
|
||||
'doc' => '[preferred_state]
|
||||
List releases on the server of packages you have installed where
|
||||
a newer version is available with the same release state (stable etc.)
|
||||
or the state passed as the second parameter.'
|
||||
),
|
||||
'remote-list' => array(
|
||||
'summary' => 'List Remote Packages',
|
||||
'function' => 'doRemoteList',
|
||||
'shortcut' => 'rl',
|
||||
'options' => array(
|
||||
'channel' =>
|
||||
array(
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'specify a channel other than the default channel',
|
||||
'arg' => 'CHAN',
|
||||
)
|
||||
),
|
||||
'doc' => '
|
||||
Lists the packages available on the configured server along with the
|
||||
latest stable release of each package.',
|
||||
),
|
||||
'search' => array(
|
||||
'summary' => 'Search remote package database',
|
||||
'function' => 'doSearch',
|
||||
'shortcut' => 'sp',
|
||||
'options' => array(
|
||||
'channel' =>
|
||||
array(
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'specify a channel other than the default channel',
|
||||
'arg' => 'CHAN',
|
||||
),
|
||||
'allchannels' => array(
|
||||
'shortopt' => 'a',
|
||||
'doc' => 'search packages from all known channels',
|
||||
),
|
||||
'channelinfo' => array(
|
||||
'shortopt' => 'i',
|
||||
'doc' => 'output fully channel-aware data, even on failure',
|
||||
),
|
||||
),
|
||||
'doc' => '[packagename] [packageinfo]
|
||||
Lists all packages which match the search parameters. The first
|
||||
parameter is a fragment of a packagename. The default channel
|
||||
will be used unless explicitly overridden. The second parameter
|
||||
will be used to match any portion of the summary/description',
|
||||
),
|
||||
'list-all' => array(
|
||||
'summary' => 'List All Packages',
|
||||
'function' => 'doListAll',
|
||||
'shortcut' => 'la',
|
||||
'options' => array(
|
||||
'channel' =>
|
||||
array(
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'specify a channel other than the default channel',
|
||||
'arg' => 'CHAN',
|
||||
),
|
||||
'channelinfo' => array(
|
||||
'shortopt' => 'i',
|
||||
'doc' => 'output fully channel-aware data, even on failure',
|
||||
),
|
||||
),
|
||||
'doc' => '
|
||||
Lists the packages available on the configured server along with the
|
||||
latest stable release of each package.',
|
||||
),
|
||||
'download' => array(
|
||||
'summary' => 'Download Package',
|
||||
'function' => 'doDownload',
|
||||
'shortcut' => 'd',
|
||||
'options' => array(
|
||||
'nocompress' => array(
|
||||
'shortopt' => 'Z',
|
||||
'doc' => 'download an uncompressed (.tar) file',
|
||||
),
|
||||
),
|
||||
'doc' => '<package>...
|
||||
Download package tarballs. The files will be named as suggested by the
|
||||
server, for example if you download the DB package and the latest stable
|
||||
version of DB is 1.6.5, the downloaded file will be DB-1.6.5.tgz.',
|
||||
),
|
||||
'clear-cache' => array(
|
||||
'summary' => 'Clear Web Services Cache',
|
||||
'function' => 'doClearCache',
|
||||
'shortcut' => 'cc',
|
||||
'options' => array(),
|
||||
'doc' => '
|
||||
Clear the XML-RPC/REST cache. See also the cache_ttl configuration
|
||||
parameter.
|
||||
',
|
||||
),
|
||||
);
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Remote constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Remote(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
function _checkChannelForStatus($channel, $chan)
|
||||
{
|
||||
if (PEAR::isError($chan)) {
|
||||
$this->raiseError($chan);
|
||||
}
|
||||
if (!is_a($chan, 'PEAR_ChannelFile')) {
|
||||
return $this->raiseError('Internal corruption error: invalid channel "' .
|
||||
$channel . '"');
|
||||
}
|
||||
$rest = new PEAR_REST($this->config);
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$mirror = $this->config->get('preferred_mirror', null,
|
||||
$channel);
|
||||
$a = $rest->downloadHttp('http://' . $channel .
|
||||
'/channel.xml', $chan->lastModified());
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (!PEAR::isError($a) && $a) {
|
||||
$this->ui->outputData('WARNING: channel "' . $channel . '" has ' .
|
||||
'updated its protocols, use "channel-update ' . $channel .
|
||||
'" to update');
|
||||
}
|
||||
}
|
||||
|
||||
// {{{ doRemoteInfo()
|
||||
|
||||
function doRemoteInfo($command, $options, $params)
|
||||
{
|
||||
if (sizeof($params) != 1) {
|
||||
return $this->raiseError("$command expects one param: the remote package name");
|
||||
}
|
||||
$savechannel = $channel = $this->config->get('default_channel');
|
||||
$reg = &$this->config->getRegistry();
|
||||
$package = $params[0];
|
||||
$parsed = $reg->parsePackageName($package, $channel);
|
||||
if (PEAR::isError($parsed)) {
|
||||
return $this->raiseError('Invalid package name "' . $package . '"');
|
||||
}
|
||||
|
||||
$channel = $parsed['channel'];
|
||||
$this->config->set('default_channel', $channel);
|
||||
$chan = $reg->getChannel($channel);
|
||||
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
|
||||
return $e;
|
||||
}
|
||||
if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
$info = $rest->packageInfo($base, $parsed['package'], $channel);
|
||||
} else {
|
||||
$r = &$this->config->getRemote();
|
||||
$info = $r->call('package.info', $parsed['package']);
|
||||
}
|
||||
if (PEAR::isError($info)) {
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return $this->raiseError($info);
|
||||
}
|
||||
if (!isset($info['name'])) {
|
||||
return $this->raiseError('No remote package "' . $package . '" was found');
|
||||
}
|
||||
|
||||
$installed = $reg->packageInfo($info['name'], null, $channel);
|
||||
$info['installed'] = $installed['version'] ? $installed['version'] : '- no -';
|
||||
if (is_array($info['installed'])) {
|
||||
$info['installed'] = $info['installed']['release'];
|
||||
}
|
||||
|
||||
$this->ui->outputData($info, $command);
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doRemoteList()
|
||||
|
||||
function doRemoteList($command, $options, $params)
|
||||
{
|
||||
$savechannel = $channel = $this->config->get('default_channel');
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (isset($options['channel'])) {
|
||||
$channel = $options['channel'];
|
||||
if ($reg->channelExists($channel)) {
|
||||
$this->config->set('default_channel', $channel);
|
||||
} else {
|
||||
return $this->raiseError('Channel "' . $channel . '" does not exist');
|
||||
}
|
||||
}
|
||||
$chan = $reg->getChannel($channel);
|
||||
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
|
||||
return $e;
|
||||
}
|
||||
$list_options = false;
|
||||
if ($this->config->get('preferred_state') == 'stable') {
|
||||
$list_options = true;
|
||||
}
|
||||
if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) {
|
||||
// use faster list-all if available
|
||||
$rest = &$this->config->getREST('1.1', array());
|
||||
$available = $rest->listAll($base, $list_options, true, false, false, $chan->getName());
|
||||
} elseif ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
$available = $rest->listAll($base, $list_options, true, false, false, $chan->getName());
|
||||
} else {
|
||||
$r = &$this->config->getRemote();
|
||||
if ($channel == 'pear.php.net') {
|
||||
// hack because of poor pearweb design
|
||||
$available = $r->call('package.listAll', true, $list_options, false);
|
||||
} else {
|
||||
$available = $r->call('package.listAll', true, $list_options);
|
||||
}
|
||||
}
|
||||
if (PEAR::isError($available)) {
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return $this->raiseError($available);
|
||||
}
|
||||
$i = $j = 0;
|
||||
$data = array(
|
||||
'caption' => 'Channel ' . $channel . ' Available packages:',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Version'),
|
||||
'channel' => $channel
|
||||
);
|
||||
if (count($available)==0) {
|
||||
$data = '(no packages available yet)';
|
||||
} else {
|
||||
foreach ($available as $name => $info) {
|
||||
$data['data'][] = array($name, (isset($info['stable']) && $info['stable'])
|
||||
? $info['stable'] : '-n/a-');
|
||||
}
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doListAll()
|
||||
|
||||
function doListAll($command, $options, $params)
|
||||
{
|
||||
$savechannel = $channel = $this->config->get('default_channel');
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (isset($options['channel'])) {
|
||||
$channel = $options['channel'];
|
||||
if ($reg->channelExists($channel)) {
|
||||
$this->config->set('default_channel', $channel);
|
||||
} else {
|
||||
return $this->raiseError("Channel \"$channel\" does not exist");
|
||||
}
|
||||
}
|
||||
$list_options = false;
|
||||
if ($this->config->get('preferred_state') == 'stable') {
|
||||
$list_options = true;
|
||||
}
|
||||
$chan = $reg->getChannel($channel);
|
||||
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
|
||||
return $e;
|
||||
}
|
||||
if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.1', $this->config->get('preferred_mirror'))) {
|
||||
// use faster list-all if available
|
||||
$rest = &$this->config->getREST('1.1', array());
|
||||
$available = $rest->listAll($base, $list_options, false, false, false, $chan->getName());
|
||||
} elseif ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
$available = $rest->listAll($base, $list_options, false, false, false, $chan->getName());
|
||||
} else {
|
||||
$r = &$this->config->getRemote();
|
||||
if ($channel == 'pear.php.net') {
|
||||
// hack because of poor pearweb design
|
||||
$available = $r->call('package.listAll', true, $list_options, false);
|
||||
} else {
|
||||
$available = $r->call('package.listAll', true, $list_options);
|
||||
}
|
||||
}
|
||||
if (PEAR::isError($available)) {
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return $this->raiseError('The package list could not be fetched from the remote server. Please try again. (Debug info: "' . $available->getMessage() . '")');
|
||||
}
|
||||
$data = array(
|
||||
'caption' => 'All packages [Channel ' . $channel . ']:',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Latest', 'Local'),
|
||||
'channel' => $channel,
|
||||
);
|
||||
if (isset($options['channelinfo'])) {
|
||||
// add full channelinfo
|
||||
$data['caption'] = 'Channel ' . $channel . ' All packages:';
|
||||
$data['headline'] = array('Channel', 'Package', 'Latest', 'Local',
|
||||
'Description', 'Dependencies');
|
||||
}
|
||||
$local_pkgs = $reg->listPackages($channel);
|
||||
|
||||
foreach ($available as $name => $info) {
|
||||
$installed = $reg->packageInfo($name, null, $channel);
|
||||
if (is_array($installed['version'])) {
|
||||
$installed['version'] = $installed['version']['release'];
|
||||
}
|
||||
$desc = $info['summary'];
|
||||
if (isset($params[$name])) {
|
||||
$desc .= "\n\n".$info['description'];
|
||||
}
|
||||
if (isset($options['mode']))
|
||||
{
|
||||
if ($options['mode'] == 'installed' && !isset($installed['version'])) {
|
||||
continue;
|
||||
}
|
||||
if ($options['mode'] == 'notinstalled' && isset($installed['version'])) {
|
||||
continue;
|
||||
}
|
||||
if ($options['mode'] == 'upgrades'
|
||||
&& (!isset($installed['version']) || version_compare($installed['version'],
|
||||
$info['stable'], '>='))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$pos = array_search(strtolower($name), $local_pkgs);
|
||||
if ($pos !== false) {
|
||||
unset($local_pkgs[$pos]);
|
||||
}
|
||||
|
||||
if (isset($info['stable']) && !$info['stable']) {
|
||||
$info['stable'] = null;
|
||||
}
|
||||
|
||||
if (isset($options['channelinfo'])) {
|
||||
// add full channelinfo
|
||||
if ($info['stable'] === $info['unstable']) {
|
||||
$state = $info['state'];
|
||||
} else {
|
||||
$state = 'stable';
|
||||
}
|
||||
$latest = $info['stable'].' ('.$state.')';
|
||||
$local = '';
|
||||
if (isset($installed['version'])) {
|
||||
$inst_state = $reg->packageInfo($name, 'release_state', $channel);
|
||||
$local = $installed['version'].' ('.$inst_state.')';
|
||||
}
|
||||
|
||||
$packageinfo = array(
|
||||
$channel,
|
||||
$name,
|
||||
$latest,
|
||||
$local,
|
||||
isset($desc) ? $desc : null,
|
||||
isset($info['deps']) ? $info['deps'] : null,
|
||||
);
|
||||
} else {
|
||||
$packageinfo = array(
|
||||
$reg->channelAlias($channel) . '/' . $name,
|
||||
isset($info['stable']) ? $info['stable'] : null,
|
||||
isset($installed['version']) ? $installed['version'] : null,
|
||||
isset($desc) ? $desc : null,
|
||||
isset($info['deps']) ? $info['deps'] : null,
|
||||
);
|
||||
}
|
||||
$data['data'][$info['category']][] = $packageinfo;
|
||||
}
|
||||
|
||||
if (isset($options['mode']) && in_array($options['mode'], array('notinstalled', 'upgrades'))) {
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
$this->ui->outputData($data, $command);
|
||||
return true;
|
||||
}
|
||||
foreach ($local_pkgs as $name) {
|
||||
$info = &$reg->getPackage($name, $channel);
|
||||
$data['data']['Local'][] = array(
|
||||
$reg->channelAlias($channel) . '/' . $info->getPackage(),
|
||||
'',
|
||||
$info->getVersion(),
|
||||
$info->getSummary(),
|
||||
$info->getDeps()
|
||||
);
|
||||
}
|
||||
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
$this->ui->outputData($data, $command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doSearch()
|
||||
|
||||
function doSearch($command, $options, $params)
|
||||
{
|
||||
if ((!isset($params[0]) || empty($params[0]))
|
||||
&& (!isset($params[1]) || empty($params[1])))
|
||||
{
|
||||
return $this->raiseError('no valid search string supplied');
|
||||
};
|
||||
|
||||
$channelinfo = isset($options['channelinfo']);
|
||||
$reg = &$this->config->getRegistry();
|
||||
if (isset($options['allchannels'])) {
|
||||
// search all channels
|
||||
unset($options['allchannels']);
|
||||
$channels = $reg->getChannels();
|
||||
$errors = array();
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
foreach ($channels as $channel) {
|
||||
if ($channel->getName() != '__uri') {
|
||||
$options['channel'] = $channel->getName();
|
||||
$ret = $this->doSearch($command, $options, $params);
|
||||
if (PEAR::isError($ret)) {
|
||||
$errors[] = $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (count($errors) !== 0) {
|
||||
// for now, only give first error
|
||||
return PEAR::raiseError($errors[0]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
$savechannel = $channel = $this->config->get('default_channel');
|
||||
$package = $params[0];
|
||||
$summary = isset($params[1]) ? $params[1] : false;
|
||||
if (isset($options['channel'])) {
|
||||
$reg = &$this->config->getRegistry();
|
||||
$channel = $options['channel'];
|
||||
if ($reg->channelExists($channel)) {
|
||||
$this->config->set('default_channel', $channel);
|
||||
} else {
|
||||
return $this->raiseError('Channel "' . $channel . '" does not exist');
|
||||
}
|
||||
}
|
||||
$chan = $reg->getChannel($channel);
|
||||
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
|
||||
return $e;
|
||||
}
|
||||
if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
$available = $rest->listAll($base, false, false, $package, $summary, $chan->getName());
|
||||
} else {
|
||||
$r = &$this->config->getRemote();
|
||||
$available = $r->call('package.search', $package, $summary, true,
|
||||
$this->config->get('preferred_state') == 'stable', true);
|
||||
}
|
||||
if (PEAR::isError($available)) {
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return $this->raiseError($available);
|
||||
}
|
||||
if (!$available && !$channelinfo) {
|
||||
// clean exit when not found, no error !
|
||||
$data = 'no packages found that match pattern "' . $package . '", for channel '.$channel.'.';
|
||||
$this->ui->outputData($data);
|
||||
$this->config->set('default_channel', $channel);
|
||||
return true;
|
||||
}
|
||||
if ($channelinfo) {
|
||||
$data = array(
|
||||
'caption' => 'Matched packages, channel ' . $channel . ':',
|
||||
'border' => true,
|
||||
'headline' => array('Channel', 'Package', 'Stable/(Latest)', 'Local'),
|
||||
'channel' => $channel
|
||||
);
|
||||
} else {
|
||||
$data = array(
|
||||
'caption' => 'Matched packages, channel ' . $channel . ':',
|
||||
'border' => true,
|
||||
'headline' => array('Package', 'Stable/(Latest)', 'Local'),
|
||||
'channel' => $channel
|
||||
);
|
||||
}
|
||||
|
||||
if (!$available && $channelinfo) {
|
||||
unset($data['headline']);
|
||||
$data['data'] = 'No packages found that match pattern "' . $package . '".';
|
||||
$available = array();
|
||||
}
|
||||
foreach ($available as $name => $info) {
|
||||
$installed = $reg->packageInfo($name, null, $channel);
|
||||
$desc = $info['summary'];
|
||||
if (isset($params[$name]))
|
||||
$desc .= "\n\n".$info['description'];
|
||||
|
||||
if (!isset($info['stable']) || !$info['stable']) {
|
||||
$version_remote = 'none';
|
||||
} else {
|
||||
if ($info['unstable']) {
|
||||
$version_remote = $info['unstable'];
|
||||
} else {
|
||||
$version_remote = $info['stable'];
|
||||
}
|
||||
$version_remote .= ' ('.$info['state'].')';
|
||||
}
|
||||
$version = is_array($installed['version']) ? $installed['version']['release'] :
|
||||
$installed['version'];
|
||||
if ($channelinfo) {
|
||||
$packageinfo = array(
|
||||
$channel,
|
||||
$name,
|
||||
$version_remote,
|
||||
$version,
|
||||
$desc,
|
||||
);
|
||||
} else {
|
||||
$packageinfo = array(
|
||||
$name,
|
||||
$version_remote,
|
||||
$version,
|
||||
$desc,
|
||||
);
|
||||
}
|
||||
$data['data'][$info['category']][] = $packageinfo;
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
$this->config->set('default_channel', $channel);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
function &getDownloader($options)
|
||||
{
|
||||
if (!class_exists('PEAR_Downloader')) {
|
||||
require_once 'PEAR/Downloader.php';
|
||||
}
|
||||
$a = &new PEAR_Downloader($this->ui, $options, $this->config);
|
||||
return $a;
|
||||
}
|
||||
// {{{ doDownload()
|
||||
|
||||
function doDownload($command, $options, $params)
|
||||
{
|
||||
// make certain that dependencies are ignored
|
||||
$options['downloadonly'] = 1;
|
||||
|
||||
// eliminate error messages for preferred_state-related errors
|
||||
/* TODO: Should be an option, but until now download does respect
|
||||
prefered state */
|
||||
/* $options['ignorepreferred_state'] = 1; */
|
||||
// eliminate error messages for preferred_state-related errors
|
||||
|
||||
$downloader = &$this->getDownloader($options);
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$e = $downloader->setDownloadDir(getcwd());
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($e)) {
|
||||
return $this->raiseError('Current directory is not writeable, cannot download');
|
||||
}
|
||||
$errors = array();
|
||||
$downloaded = array();
|
||||
$err = $downloader->download($params);
|
||||
if (PEAR::isError($err)) {
|
||||
return $err;
|
||||
}
|
||||
$errors = $downloader->getErrorMsgs();
|
||||
if (count($errors)) {
|
||||
foreach ($errors as $error) {
|
||||
$this->ui->outputData($error);
|
||||
}
|
||||
return $this->raiseError("$command failed");
|
||||
}
|
||||
$downloaded = $downloader->getDownloadedPackages();
|
||||
foreach ($downloaded as $pkg) {
|
||||
$this->ui->outputData("File $pkg[file] downloaded", $command);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function downloadCallback($msg, $params = null)
|
||||
{
|
||||
if ($msg == 'done') {
|
||||
$this->bytes_downloaded = $params;
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doListUpgrades()
|
||||
|
||||
function doListUpgrades($command, $options, $params)
|
||||
{
|
||||
require_once 'PEAR/Common.php';
|
||||
if (isset($params[0]) && !is_array(PEAR_Common::betterStates($params[0]))) {
|
||||
return $this->raiseError($params[0] . ' is not a valid state (stable/beta/alpha/devel/etc.) try "pear help list-upgrades"');
|
||||
}
|
||||
$savechannel = $channel = $this->config->get('default_channel');
|
||||
$reg = &$this->config->getRegistry();
|
||||
foreach ($reg->listChannels() as $channel) {
|
||||
$inst = array_flip($reg->listPackages($channel));
|
||||
if (!count($inst)) {
|
||||
continue;
|
||||
}
|
||||
if ($channel == '__uri') {
|
||||
continue;
|
||||
}
|
||||
$this->config->set('default_channel', $channel);
|
||||
if (empty($params[0])) {
|
||||
$state = $this->config->get('preferred_state');
|
||||
} else {
|
||||
$state = $params[0];
|
||||
}
|
||||
$caption = $channel . ' Available Upgrades';
|
||||
$chan = $reg->getChannel($channel);
|
||||
if (PEAR::isError($e = $this->_checkChannelForStatus($channel, $chan))) {
|
||||
return $e;
|
||||
}
|
||||
if ($chan->supportsREST($this->config->get('preferred_mirror')) &&
|
||||
$base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) {
|
||||
$rest = &$this->config->getREST('1.0', array());
|
||||
if (empty($state) || $state == 'any') {
|
||||
$state = false;
|
||||
} else {
|
||||
$caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')';
|
||||
}
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$latest = $rest->listLatestUpgrades($base, $state, $inst, $channel, $reg);
|
||||
PEAR::staticPopErrorHandling();
|
||||
} else {
|
||||
$remote = &$this->config->getRemote();
|
||||
$remote->pushErrorHandling(PEAR_ERROR_RETURN);
|
||||
if (empty($state) || $state == 'any') {
|
||||
$latest = $remote->call("package.listLatestReleases");
|
||||
} else {
|
||||
$latest = $remote->call("package.listLatestReleases", $state);
|
||||
$caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')';
|
||||
}
|
||||
$remote->popErrorHandling();
|
||||
}
|
||||
if (PEAR::isError($latest)) {
|
||||
$this->ui->outputData($latest->getMessage());
|
||||
continue;
|
||||
}
|
||||
$caption .= ':';
|
||||
if (PEAR::isError($latest)) {
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return $latest;
|
||||
}
|
||||
$data = array(
|
||||
'caption' => $caption,
|
||||
'border' => 1,
|
||||
'headline' => array('Channel', 'Package', 'Local', 'Remote', 'Size'),
|
||||
'channel' => $channel
|
||||
);
|
||||
foreach ((array)$latest as $pkg => $info) {
|
||||
$package = strtolower($pkg);
|
||||
if (!isset($inst[$package])) {
|
||||
// skip packages we don't have installed
|
||||
continue;
|
||||
}
|
||||
extract($info);
|
||||
$inst_version = $reg->packageInfo($package, 'version', $channel);
|
||||
$inst_state = $reg->packageInfo($package, 'release_state', $channel);
|
||||
if (version_compare("$version", "$inst_version", "le")) {
|
||||
// installed version is up-to-date
|
||||
continue;
|
||||
}
|
||||
if ($filesize >= 20480) {
|
||||
$filesize += 1024 - ($filesize % 1024);
|
||||
$fs = sprintf("%dkB", $filesize / 1024);
|
||||
} elseif ($filesize > 0) {
|
||||
$filesize += 103 - ($filesize % 103);
|
||||
$fs = sprintf("%.1fkB", $filesize / 1024.0);
|
||||
} else {
|
||||
$fs = " -"; // XXX center instead
|
||||
}
|
||||
$data['data'][] = array($channel, $pkg, "$inst_version ($inst_state)", "$version ($state)", $fs);
|
||||
}
|
||||
if (isset($options['channelinfo'])) {
|
||||
if (empty($data['data'])) {
|
||||
unset($data['headline']);
|
||||
if (count($inst) == 0) {
|
||||
$data['data'] = '(no packages installed)';
|
||||
} else {
|
||||
$data['data'] = '(no upgrades available)';
|
||||
}
|
||||
}
|
||||
$this->ui->outputData($data, $command);
|
||||
} else {
|
||||
if (empty($data['data'])) {
|
||||
$this->ui->outputData('Channel ' . $channel . ': No upgrades available');
|
||||
} else {
|
||||
$this->ui->outputData($data, $command);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->config->set('default_channel', $savechannel);
|
||||
return true;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doClearCache()
|
||||
|
||||
function doClearCache($command, $options, $params)
|
||||
{
|
||||
$cache_dir = $this->config->get('cache_dir');
|
||||
$verbose = $this->config->get('verbose');
|
||||
$output = '';
|
||||
if (!file_exists($cache_dir) || !is_dir($cache_dir)) {
|
||||
return $this->raiseError("$cache_dir does not exist or is not a directory");
|
||||
}
|
||||
if (!($dp = @opendir($cache_dir))) {
|
||||
return $this->raiseError("opendir($cache_dir) failed: $php_errormsg");
|
||||
}
|
||||
if ($verbose >= 1) {
|
||||
$output .= "reading directory $cache_dir\n";
|
||||
}
|
||||
$num = 0;
|
||||
while ($ent = readdir($dp)) {
|
||||
if (preg_match('/^xmlrpc_cache_[a-z0-9]{32}\\z/', $ent) ||
|
||||
preg_match('/rest.cache(file|id)\\z/', $ent)) {
|
||||
$path = $cache_dir . DIRECTORY_SEPARATOR . $ent;
|
||||
if (file_exists($path)) {
|
||||
$ok = @unlink($path);
|
||||
} else {
|
||||
$ok = false;
|
||||
$php_errormsg = '';
|
||||
}
|
||||
if ($ok) {
|
||||
if ($verbose >= 2) {
|
||||
$output .= "deleted $path\n";
|
||||
}
|
||||
$num++;
|
||||
} elseif ($verbose >= 1) {
|
||||
$output .= "failed to delete $path $php_errormsg\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dp);
|
||||
if ($verbose >= 1) {
|
||||
$output .= "$num cache entries cleared\n";
|
||||
}
|
||||
$this->ui->outputData(rtrim($output), $command);
|
||||
return $num;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
108
vendor/library/Excel/phpxls/PEAR/Command/Remote.xml
vendored
Normal file
108
vendor/library/Excel/phpxls/PEAR/Command/Remote.xml
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<commands version="1.0">
|
||||
<remote-info>
|
||||
<summary>Information About Remote Packages</summary>
|
||||
<function>doRemoteInfo</function>
|
||||
<shortcut>ri</shortcut>
|
||||
<options />
|
||||
<doc><package>
|
||||
Get details on a package from the server.</doc>
|
||||
</remote-info>
|
||||
<list-upgrades>
|
||||
<summary>List Available Upgrades</summary>
|
||||
<function>doListUpgrades</function>
|
||||
<shortcut>lu</shortcut>
|
||||
<options />
|
||||
<doc>[preferred_state]
|
||||
List releases on the server of packages you have installed where
|
||||
a newer version is available with the same release state (stable etc.)
|
||||
or the state passed as the second parameter.</doc>
|
||||
</list-upgrades>
|
||||
<remote-list>
|
||||
<summary>List Remote Packages</summary>
|
||||
<function>doRemoteList</function>
|
||||
<shortcut>rl</shortcut>
|
||||
<options>
|
||||
<channel>
|
||||
<shortopt>c</shortopt>
|
||||
<doc>specify a channel other than the default channel</doc>
|
||||
<arg>CHAN</arg>
|
||||
</channel>
|
||||
<channelinfo>
|
||||
<shortopt>i</shortopt>
|
||||
<doc>output fully channel-aware data, even on failure</doc>
|
||||
</channelinfo>
|
||||
</options>
|
||||
<doc>
|
||||
Lists the packages available on the configured server along with the
|
||||
latest stable release of each package.</doc>
|
||||
</remote-list>
|
||||
<search>
|
||||
<summary>Search remote package database</summary>
|
||||
<function>doSearch</function>
|
||||
<shortcut>sp</shortcut>
|
||||
<options>
|
||||
<channel>
|
||||
<shortopt>c</shortopt>
|
||||
<doc>specify a channel other than the default channel</doc>
|
||||
<arg>CHAN</arg>
|
||||
</channel>
|
||||
<allchannels>
|
||||
<shortopt>a</shortopt>
|
||||
<doc>search packages from all known channels</doc>
|
||||
</allchannels>
|
||||
<channelinfo>
|
||||
<shortopt>i</shortopt>
|
||||
<doc>output fully channel-aware data, even on failure</doc>
|
||||
</channelinfo>
|
||||
</options>
|
||||
<doc>[packagename] [packageinfo]
|
||||
Lists all packages which match the search parameters. The first
|
||||
parameter is a fragment of a packagename. The default channel
|
||||
will be used unless explicitly overridden. The second parameter
|
||||
will be used to match any portion of the summary/description</doc>
|
||||
</search>
|
||||
<list-all>
|
||||
<summary>List All Packages</summary>
|
||||
<function>doListAll</function>
|
||||
<shortcut>la</shortcut>
|
||||
<options>
|
||||
<channel>
|
||||
<shortopt>c</shortopt>
|
||||
<doc>specify a channel other than the default channel</doc>
|
||||
<arg>CHAN</arg>
|
||||
</channel>
|
||||
<channelinfo>
|
||||
<shortopt>i</shortopt>
|
||||
<doc>output fully channel-aware data, even on failure</doc>
|
||||
</channelinfo>
|
||||
</options>
|
||||
<doc>
|
||||
Lists the packages available on the configured server along with the
|
||||
latest stable release of each package.</doc>
|
||||
</list-all>
|
||||
<download>
|
||||
<summary>Download Package</summary>
|
||||
<function>doDownload</function>
|
||||
<shortcut>d</shortcut>
|
||||
<options>
|
||||
<nocompress>
|
||||
<shortopt>Z</shortopt>
|
||||
<doc>download an uncompressed (.tar) file</doc>
|
||||
</nocompress>
|
||||
</options>
|
||||
<doc><package>...
|
||||
Download package tarballs. The files will be named as suggested by the
|
||||
server, for example if you download the DB package and the latest stable
|
||||
version of DB is 1.6.5, the downloaded file will be DB-1.6.5.tgz.</doc>
|
||||
</download>
|
||||
<clear-cache>
|
||||
<summary>Clear Web Services Cache</summary>
|
||||
<function>doClearCache</function>
|
||||
<shortcut>cc</shortcut>
|
||||
<options />
|
||||
<doc>
|
||||
Clear the XML-RPC/REST cache. See also the cache_ttl configuration
|
||||
parameter.
|
||||
</doc>
|
||||
</clear-cache>
|
||||
</commands>
|
||||
345
vendor/library/Excel/phpxls/PEAR/Command/Test.php
vendored
Normal file
345
vendor/library/Excel/phpxls/PEAR/Command/Test.php
vendored
Normal file
|
|
@ -0,0 +1,345 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Command_Test (run-tests)
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Martin Jansen <mj@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Test.php,v 1.27 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR/Command/Common.php';
|
||||
|
||||
/**
|
||||
* PEAR commands for login/logout
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Martin Jansen <mj@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
|
||||
class PEAR_Command_Test extends PEAR_Command_Common
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
var $commands = array(
|
||||
'run-tests' => array(
|
||||
'summary' => 'Run Regression Tests',
|
||||
'function' => 'doRunTests',
|
||||
'shortcut' => 'rt',
|
||||
'options' => array(
|
||||
'recur' => array(
|
||||
'shortopt' => 'r',
|
||||
'doc' => 'Run tests in child directories, recursively. 4 dirs deep maximum',
|
||||
),
|
||||
'ini' => array(
|
||||
'shortopt' => 'i',
|
||||
'doc' => 'actual string of settings to pass to php in format " -d setting=blah"',
|
||||
'arg' => 'SETTINGS'
|
||||
),
|
||||
'realtimelog' => array(
|
||||
'shortopt' => 'l',
|
||||
'doc' => 'Log test runs/results as they are run',
|
||||
),
|
||||
'quiet' => array(
|
||||
'shortopt' => 'q',
|
||||
'doc' => 'Only display detail for failed tests',
|
||||
),
|
||||
'simple' => array(
|
||||
'shortopt' => 's',
|
||||
'doc' => 'Display simple output for all tests',
|
||||
),
|
||||
'package' => array(
|
||||
'shortopt' => 'p',
|
||||
'doc' => 'Treat parameters as installed packages from which to run tests',
|
||||
),
|
||||
'phpunit' => array(
|
||||
'shortopt' => 'u',
|
||||
'doc' => 'Search parameters for AllTests.php, and use that to run phpunit-based tests
|
||||
If none is found, all .phpt tests will be tried instead.',
|
||||
),
|
||||
'tapoutput' => array(
|
||||
'shortopt' => 't',
|
||||
'doc' => 'Output run-tests.log in TAP-compliant format',
|
||||
),
|
||||
'cgi' => array(
|
||||
'shortopt' => 'c',
|
||||
'doc' => 'CGI php executable (needed for tests with POST/GET section)',
|
||||
'arg' => 'PHPCGI',
|
||||
),
|
||||
'coverage' => array(
|
||||
'shortopt' => 'x',
|
||||
'doc' => 'Generate a code coverage report (requires Xdebug 2.0.0+)',
|
||||
),
|
||||
),
|
||||
'doc' => '[testfile|dir ...]
|
||||
Run regression tests with PHP\'s regression testing script (run-tests.php).',
|
||||
),
|
||||
);
|
||||
|
||||
var $output;
|
||||
|
||||
// }}}
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* PEAR_Command_Test constructor.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PEAR_Command_Test(&$ui, &$config)
|
||||
{
|
||||
parent::PEAR_Command_Common($ui, $config);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ doRunTests()
|
||||
|
||||
function doRunTests($command, $options, $params)
|
||||
{
|
||||
if (isset($options['phpunit']) && isset($options['tapoutput'])) {
|
||||
return $this->raiseError('ERROR: cannot use both --phpunit and --tapoutput at the same time');
|
||||
}
|
||||
require_once 'PEAR/Common.php';
|
||||
require_once 'System.php';
|
||||
$log = new PEAR_Common;
|
||||
$log->ui = &$this->ui; // slightly hacky, but it will work
|
||||
$tests = array();
|
||||
$depth = isset($options['recur']) ? 4 : 1;
|
||||
|
||||
if (!count($params)) {
|
||||
$params[] = '.';
|
||||
}
|
||||
if (isset($options['package'])) {
|
||||
$oldparams = $params;
|
||||
$params = array();
|
||||
$reg = &$this->config->getRegistry();
|
||||
foreach ($oldparams as $param) {
|
||||
$pname = $reg->parsePackageName($param, $this->config->get('default_channel'));
|
||||
if (PEAR::isError($pname)) {
|
||||
return $this->raiseError($pname);
|
||||
}
|
||||
|
||||
$package = &$reg->getPackage($pname['package'], $pname['channel']);
|
||||
if (!$package) {
|
||||
return PEAR::raiseError('Unknown package "' .
|
||||
$reg->parsedPackageNameToString($pname) . '"');
|
||||
}
|
||||
|
||||
$filelist = $package->getFilelist();
|
||||
foreach ($filelist as $name => $atts) {
|
||||
if (isset($atts['role']) && $atts['role'] != 'test') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($options['phpunit']) && preg_match('/AllTests\.php\\z/i', $name)) {
|
||||
$params[] = $atts['installed_as'];
|
||||
continue;
|
||||
} elseif (!preg_match('/\.phpt\\z/', $name)) {
|
||||
continue;
|
||||
}
|
||||
$params[] = $atts['installed_as'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($params as $p) {
|
||||
if (is_dir($p)) {
|
||||
if (isset($options['phpunit'])) {
|
||||
$dir = System::find(array($p, '-type', 'f',
|
||||
'-maxdepth', $depth,
|
||||
'-name', 'AllTests.php'));
|
||||
if (count($dir)) {
|
||||
foreach ($dir as $p) {
|
||||
$p = realpath($p);
|
||||
if (!count($tests) ||
|
||||
(count($tests) && strlen($p) < strlen($tests[0]))) {
|
||||
// this is in a higher-level directory, use this one instead.
|
||||
$tests = array($p);
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$dir = System::find(array($p, '-type', 'f',
|
||||
'-maxdepth', $depth,
|
||||
'-name', '*.phpt'));
|
||||
$tests = array_merge($tests, $dir);
|
||||
} else {
|
||||
if (isset($options['phpunit'])) {
|
||||
if (preg_match('/AllTests\.php\\z/i', $p)) {
|
||||
$p = realpath($p);
|
||||
if (!count($tests) ||
|
||||
(count($tests) && strlen($p) < strlen($tests[0]))) {
|
||||
// this is in a higher-level directory, use this one instead.
|
||||
$tests = array($p);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file_exists($p) && preg_match('/\.phpt$/', $p)) {
|
||||
$tests[] = $p;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!preg_match('/\.phpt\\z/', $p)) {
|
||||
$p .= '.phpt';
|
||||
}
|
||||
$dir = System::find(array(dirname($p), '-type', 'f',
|
||||
'-maxdepth', $depth,
|
||||
'-name', $p));
|
||||
$tests = array_merge($tests, $dir);
|
||||
}
|
||||
}
|
||||
|
||||
$ini_settings = '';
|
||||
if (isset($options['ini'])) {
|
||||
$ini_settings .= $options['ini'];
|
||||
}
|
||||
|
||||
if (isset($_ENV['TEST_PHP_INCLUDE_PATH'])) {
|
||||
$ini_settings .= " -d include_path={$_ENV['TEST_PHP_INCLUDE_PATH']}";
|
||||
}
|
||||
|
||||
if ($ini_settings) {
|
||||
$this->ui->outputData('Using INI settings: "' . $ini_settings . '"');
|
||||
}
|
||||
$skipped = $passed = $failed = array();
|
||||
$tests_count = count($tests);
|
||||
$this->ui->outputData('Running ' . $tests_count . ' tests', $command);
|
||||
$start = time();
|
||||
if (isset($options['realtimelog']) && file_exists('run-tests.log')) {
|
||||
unlink('run-tests.log');
|
||||
}
|
||||
|
||||
if (isset($options['tapoutput'])) {
|
||||
$tap = '1..' . $tests_count . "\n";
|
||||
}
|
||||
|
||||
require_once 'PEAR/RunTest.php';
|
||||
$run = new PEAR_RunTest($log, $options);
|
||||
$run->tests_count = $tests_count;
|
||||
|
||||
if (isset($options['coverage']) && extension_loaded('xdebug')){
|
||||
$run->xdebug_loaded = true;
|
||||
} else {
|
||||
$run->xdebug_loaded = false;
|
||||
}
|
||||
|
||||
$j = $i = 1;
|
||||
foreach ($tests as $t) {
|
||||
if (isset($options['realtimelog'])) {
|
||||
$fp = @fopen('run-tests.log', 'a');
|
||||
if ($fp) {
|
||||
fwrite($fp, "Running test [$i / $tests_count] $t...");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
|
||||
if (isset($options['phpunit'])) {
|
||||
$result = $run->runPHPUnit($t, $ini_settings);
|
||||
} else {
|
||||
$result = $run->run($t, $ini_settings, $j);
|
||||
}
|
||||
PEAR::staticPopErrorHandling();
|
||||
if (PEAR::isError($result)) {
|
||||
$this->ui->log($result->getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($options['tapoutput'])) {
|
||||
$tap .= $result[0] . ' ' . $i . $result[1] . "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($options['realtimelog'])) {
|
||||
$fp = @fopen('run-tests.log', 'a');
|
||||
if ($fp) {
|
||||
fwrite($fp, "$result\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result == 'FAILED') {
|
||||
$failed[] = $t;
|
||||
}
|
||||
if ($result == 'PASSED') {
|
||||
$passed[] = $t;
|
||||
}
|
||||
if ($result == 'SKIPPED') {
|
||||
$skipped[] = $t;
|
||||
}
|
||||
|
||||
$j++;
|
||||
}
|
||||
|
||||
$total = date('i:s', time() - $start);
|
||||
if (isset($options['tapoutput'])) {
|
||||
$fp = @fopen('run-tests.log', 'w');
|
||||
if ($fp) {
|
||||
fwrite($fp, $tap, strlen($tap));
|
||||
fclose($fp);
|
||||
$this->ui->outputData('wrote TAP-format log to "' .realpath('run-tests.log') .
|
||||
'"', $command);
|
||||
}
|
||||
} else {
|
||||
if (count($failed)) {
|
||||
$output = "TOTAL TIME: $total\n";
|
||||
$output .= count($passed) . " PASSED TESTS\n";
|
||||
$output .= count($skipped) . " SKIPPED TESTS\n";
|
||||
$output .= count($failed) . " FAILED TESTS:\n";
|
||||
foreach ($failed as $failure) {
|
||||
$output .= $failure . "\n";
|
||||
}
|
||||
|
||||
$mode = isset($options['realtimelog']) ? 'a' : 'w';
|
||||
$fp = @fopen('run-tests.log', $mode);
|
||||
|
||||
if ($fp) {
|
||||
fwrite($fp, $output, strlen($output));
|
||||
fclose($fp);
|
||||
$this->ui->outputData('wrote log to "' . realpath('run-tests.log') . '"', $command);
|
||||
}
|
||||
} elseif (file_exists('run-tests.log') && !is_dir('run-tests.log')) {
|
||||
@unlink('run-tests.log');
|
||||
}
|
||||
}
|
||||
$this->ui->outputData('TOTAL TIME: ' . $total);
|
||||
$this->ui->outputData(count($passed) . ' PASSED TESTS', $command);
|
||||
$this->ui->outputData(count($skipped) . ' SKIPPED TESTS', $command);
|
||||
if (count($failed)) {
|
||||
$this->ui->outputData(count($failed) . ' FAILED TESTS:', $command);
|
||||
foreach ($failed as $failure) {
|
||||
$this->ui->outputData($failure, $command);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
54
vendor/library/Excel/phpxls/PEAR/Command/Test.xml
vendored
Normal file
54
vendor/library/Excel/phpxls/PEAR/Command/Test.xml
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<commands version="1.0">
|
||||
<run-tests>
|
||||
<summary>Run Regression Tests</summary>
|
||||
<function>doRunTests</function>
|
||||
<shortcut>rt</shortcut>
|
||||
<options>
|
||||
<recur>
|
||||
<shortopt>r</shortopt>
|
||||
<doc>Run tests in child directories, recursively. 4 dirs deep maximum</doc>
|
||||
</recur>
|
||||
<ini>
|
||||
<shortopt>i</shortopt>
|
||||
<doc>actual string of settings to pass to php in format " -d setting=blah"</doc>
|
||||
<arg>SETTINGS</arg>
|
||||
</ini>
|
||||
<realtimelog>
|
||||
<shortopt>l</shortopt>
|
||||
<doc>Log test runs/results as they are run</doc>
|
||||
</realtimelog>
|
||||
<quiet>
|
||||
<shortopt>q</shortopt>
|
||||
<doc>Only display detail for failed tests</doc>
|
||||
</quiet>
|
||||
<simple>
|
||||
<shortopt>s</shortopt>
|
||||
<doc>Display simple output for all tests</doc>
|
||||
</simple>
|
||||
<package>
|
||||
<shortopt>p</shortopt>
|
||||
<doc>Treat parameters as installed packages from which to run tests</doc>
|
||||
</package>
|
||||
<phpunit>
|
||||
<shortopt>u</shortopt>
|
||||
<doc>Search parameters for AllTests.php, and use that to run phpunit-based tests.
|
||||
If none is found, all .phpt tests will be tried instead.</doc>
|
||||
</phpunit>
|
||||
<tapoutput>
|
||||
<shortopt>t</shortopt>
|
||||
<doc>Output run-tests.log in TAP-compliant format</doc>
|
||||
</tapoutput>
|
||||
<cgi>
|
||||
<shortopt>c</shortopt>
|
||||
<doc>CGI php executable (needed for tests with POST/GET section)</doc>
|
||||
<arg>PHPCGI</arg>
|
||||
</cgi>
|
||||
<coverage>
|
||||
<shortopt>x</shortopt>
|
||||
<doc>Generate a code coverage report (requires Xdebug 2.0.0+)</doc>
|
||||
</coverage>
|
||||
</options>
|
||||
<doc>[testfile|dir ...]
|
||||
Run regression tests with PHP's regression testing script (run-tests.php).</doc>
|
||||
</run-tests>
|
||||
</commands>
|
||||
1126
vendor/library/Excel/phpxls/PEAR/Common.php
vendored
Normal file
1126
vendor/library/Excel/phpxls/PEAR/Common.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
2163
vendor/library/Excel/phpxls/PEAR/Config.php
vendored
Normal file
2163
vendor/library/Excel/phpxls/PEAR/Config.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
498
vendor/library/Excel/phpxls/PEAR/Dependency.php
vendored
Normal file
498
vendor/library/Excel/phpxls/PEAR/Dependency.php
vendored
Normal file
|
|
@ -0,0 +1,498 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Dependency
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* THIS FILE IS DEPRECATED IN FAVOR OF DEPENDENCY2.PHP, AND IS NOT USED IN THE INSTALLER
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Tomas V.V.Cox <cox@idecnet.com>
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Dependency.php,v 1.43 2008/01/03 20:26:34 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
|
||||
require_once "PEAR.php";
|
||||
require_once "OS/Guess.php";
|
||||
|
||||
define('PEAR_DEPENDENCY_MISSING', -1);
|
||||
define('PEAR_DEPENDENCY_CONFLICT', -2);
|
||||
define('PEAR_DEPENDENCY_UPGRADE_MINOR', -3);
|
||||
define('PEAR_DEPENDENCY_UPGRADE_MAJOR', -4);
|
||||
define('PEAR_DEPENDENCY_BAD_DEPENDENCY', -5);
|
||||
define('PEAR_DEPENDENCY_MISSING_OPTIONAL', -6);
|
||||
define('PEAR_DEPENDENCY_CONFLICT_OPTIONAL', -7);
|
||||
define('PEAR_DEPENDENCY_UPGRADE_MINOR_OPTIONAL', -8);
|
||||
define('PEAR_DEPENDENCY_UPGRADE_MAJOR_OPTIONAL', -9);
|
||||
|
||||
/**
|
||||
* Dependency check for PEAR packages
|
||||
*
|
||||
* The class is based on the dependency RFC that can be found at
|
||||
* http://cvs.php.net/cvs.php/pearweb/rfc. It requires PHP >= 4.1
|
||||
*
|
||||
* @author Tomas V.V.Vox <cox@idecnet.com>
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
*/
|
||||
class PEAR_Dependency
|
||||
{
|
||||
// {{{ constructor
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param object Registry object
|
||||
* @return void
|
||||
*/
|
||||
function PEAR_Dependency(&$registry)
|
||||
{
|
||||
$this->registry = &$registry;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ callCheckMethod()
|
||||
|
||||
/**
|
||||
* This method maps the XML dependency definition to the
|
||||
* corresponding one from PEAR_Dependency
|
||||
*
|
||||
* <pre>
|
||||
* $opts => Array
|
||||
* (
|
||||
* [type] => pkg
|
||||
* [rel] => ge
|
||||
* [version] => 3.4
|
||||
* [name] => HTML_Common
|
||||
* [optional] => false
|
||||
* )
|
||||
* </pre>
|
||||
*
|
||||
* @param string Error message
|
||||
* @param array Options
|
||||
* @return boolean
|
||||
*/
|
||||
function callCheckMethod(&$errmsg, $opts)
|
||||
{
|
||||
$rel = isset($opts['rel']) ? $opts['rel'] : 'has';
|
||||
$req = isset($opts['version']) ? $opts['version'] : null;
|
||||
$name = isset($opts['name']) ? $opts['name'] : null;
|
||||
$channel = isset($opts['channel']) ? $opts['channel'] : 'pear.php.net';
|
||||
$opt = (isset($opts['optional']) && $opts['optional'] == 'yes') ?
|
||||
$opts['optional'] : null;
|
||||
$errmsg = '';
|
||||
switch ($opts['type']) {
|
||||
case 'pkg':
|
||||
return $this->checkPackage($errmsg, $name, $req, $rel, $opt, $channel);
|
||||
break;
|
||||
case 'ext':
|
||||
return $this->checkExtension($errmsg, $name, $req, $rel, $opt);
|
||||
break;
|
||||
case 'php':
|
||||
return $this->checkPHP($errmsg, $req, $rel);
|
||||
break;
|
||||
case 'prog':
|
||||
return $this->checkProgram($errmsg, $name);
|
||||
break;
|
||||
case 'os':
|
||||
return $this->checkOS($errmsg, $name);
|
||||
break;
|
||||
case 'sapi':
|
||||
return $this->checkSAPI($errmsg, $name);
|
||||
break;
|
||||
case 'zend':
|
||||
return $this->checkZend($errmsg, $name);
|
||||
break;
|
||||
default:
|
||||
return "'{$opts['type']}' dependency type not supported";
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ checkPackage()
|
||||
|
||||
/**
|
||||
* Package dependencies check method
|
||||
*
|
||||
* @param string $errmsg Empty string, it will be populated with an error message, if any
|
||||
* @param string $name Name of the package to test
|
||||
* @param string $req The package version required
|
||||
* @param string $relation How to compare versions with each other
|
||||
* @param bool $opt Whether the relationship is optional
|
||||
* @param string $channel Channel name
|
||||
*
|
||||
* @return mixed bool false if no error or the error string
|
||||
*/
|
||||
function checkPackage(&$errmsg, $name, $req = null, $relation = 'has',
|
||||
$opt = false, $channel = 'pear.php.net')
|
||||
{
|
||||
if (is_string($req) && substr($req, 0, 2) == 'v.') {
|
||||
$req = substr($req, 2);
|
||||
}
|
||||
switch ($relation) {
|
||||
case 'has':
|
||||
if (!$this->registry->packageExists($name, $channel)) {
|
||||
if ($opt) {
|
||||
$errmsg = "package `$channel/$name' is recommended to utilize some features.";
|
||||
return PEAR_DEPENDENCY_MISSING_OPTIONAL;
|
||||
}
|
||||
$errmsg = "requires package `$channel/$name'";
|
||||
return PEAR_DEPENDENCY_MISSING;
|
||||
}
|
||||
return false;
|
||||
case 'not':
|
||||
if ($this->registry->packageExists($name, $channel)) {
|
||||
$errmsg = "conflicts with package `$channel/$name'";
|
||||
return PEAR_DEPENDENCY_CONFLICT;
|
||||
}
|
||||
return false;
|
||||
case 'lt':
|
||||
case 'le':
|
||||
case 'eq':
|
||||
case 'ne':
|
||||
case 'ge':
|
||||
case 'gt':
|
||||
$version = $this->registry->packageInfo($name, 'version', $channel);
|
||||
if (!$this->registry->packageExists($name, $channel)
|
||||
|| !version_compare("$version", "$req", $relation))
|
||||
{
|
||||
$code = $this->codeFromRelation($relation, $version, $req, $opt);
|
||||
if ($opt) {
|
||||
$errmsg = "package `$channel/$name' version " . $this->signOperator($relation) .
|
||||
" $req is recommended to utilize some features.";
|
||||
if ($version) {
|
||||
$errmsg .= " Installed version is $version";
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
$errmsg = "requires package `$channel/$name' " .
|
||||
$this->signOperator($relation) . " $req";
|
||||
return $code;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
$errmsg = "relation '$relation' with requirement '$req' is not supported (name=$channel/$name)";
|
||||
return PEAR_DEPENDENCY_BAD_DEPENDENCY;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ checkPackageUninstall()
|
||||
|
||||
/**
|
||||
* Check package dependencies on uninstall
|
||||
*
|
||||
* @param string $error The resultant error string
|
||||
* @param string $warning The resultant warning string
|
||||
* @param string $name Name of the package to test
|
||||
* @param string $channel Channel name of the package
|
||||
*
|
||||
* @return bool true if there were errors
|
||||
*/
|
||||
function checkPackageUninstall(&$error, &$warning, $package, $channel = 'pear.php.net')
|
||||
{
|
||||
$channel = strtolower($channel);
|
||||
$error = null;
|
||||
$channels = $this->registry->listAllPackages();
|
||||
foreach ($channels as $channelname => $packages) {
|
||||
foreach ($packages as $pkg) {
|
||||
if ($pkg == $package && $channel == $channelname) {
|
||||
continue;
|
||||
}
|
||||
$deps = $this->registry->packageInfo($pkg, 'release_deps', $channel);
|
||||
if (empty($deps)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($deps as $dep) {
|
||||
$depchannel = isset($dep['channel']) ? $dep['channel'] : 'pear.php.net';
|
||||
if ($dep['type'] == 'pkg' && (strcasecmp($dep['name'], $package) == 0) &&
|
||||
($depchannel == $channel)) {
|
||||
if ($dep['rel'] == 'ne') {
|
||||
continue;
|
||||
}
|
||||
if (isset($dep['optional']) && $dep['optional'] == 'yes') {
|
||||
$warning .= "\nWarning: Package '$depchannel/$pkg' optionally depends on '$channel:/package'";
|
||||
} else {
|
||||
$error .= "Package '$depchannel/$pkg' depends on '$channel/$package'\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ($error) ? true : false;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ checkExtension()
|
||||
|
||||
/**
|
||||
* Extension dependencies check method
|
||||
*
|
||||
* @param string $name Name of the extension to test
|
||||
* @param string $req_ext_ver Required extension version to compare with
|
||||
* @param string $relation How to compare versions with eachother
|
||||
* @param bool $opt Whether the relationship is optional
|
||||
*
|
||||
* @return mixed bool false if no error or the error string
|
||||
*/
|
||||
function checkExtension(&$errmsg, $name, $req = null, $relation = 'has',
|
||||
$opt = false)
|
||||
{
|
||||
if ($relation == 'not') {
|
||||
if (extension_loaded($name)) {
|
||||
$errmsg = "conflicts with PHP extension '$name'";
|
||||
return PEAR_DEPENDENCY_CONFLICT;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!extension_loaded($name)) {
|
||||
if ($relation == 'ne') {
|
||||
return false;
|
||||
}
|
||||
if ($opt) {
|
||||
$errmsg = "'$name' PHP extension is recommended to utilize some features";
|
||||
return PEAR_DEPENDENCY_MISSING_OPTIONAL;
|
||||
}
|
||||
$errmsg = "'$name' PHP extension is not installed";
|
||||
return PEAR_DEPENDENCY_MISSING;
|
||||
}
|
||||
if ($relation == 'has') {
|
||||
return false;
|
||||
}
|
||||
$code = false;
|
||||
if (is_string($req) && substr($req, 0, 2) == 'v.') {
|
||||
$req = substr($req, 2);
|
||||
}
|
||||
$ext_ver = phpversion($name);
|
||||
$operator = $relation;
|
||||
// Force params to be strings, otherwise the comparation will fail (ex. 0.9==0.90)
|
||||
if (!version_compare("$ext_ver", "$req", $operator)) {
|
||||
$errmsg = "'$name' PHP extension version " .
|
||||
$this->signOperator($operator) . " $req is required";
|
||||
$code = $this->codeFromRelation($relation, $ext_ver, $req, $opt);
|
||||
if ($opt) {
|
||||
$errmsg = "'$name' PHP extension version " . $this->signOperator($operator) .
|
||||
" $req is recommended to utilize some features";
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ checkOS()
|
||||
|
||||
/**
|
||||
* Operating system dependencies check method
|
||||
*
|
||||
* @param string $os Name of the operating system
|
||||
*
|
||||
* @return mixed bool false if no error or the error string
|
||||
*/
|
||||
function checkOS(&$errmsg, $os)
|
||||
{
|
||||
// XXX Fixme: Implement a more flexible way, like
|
||||
// comma separated values or something similar to PEAR_OS
|
||||
static $myos;
|
||||
if (empty($myos)) {
|
||||
$myos = new OS_Guess();
|
||||
}
|
||||
// only 'has' relation is currently supported
|
||||
if ($myos->matchSignature($os)) {
|
||||
return false;
|
||||
}
|
||||
$errmsg = "'$os' operating system not supported";
|
||||
return PEAR_DEPENDENCY_CONFLICT;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ checkPHP()
|
||||
|
||||
/**
|
||||
* PHP version check method
|
||||
*
|
||||
* @param string $req which version to compare
|
||||
* @param string $relation how to compare the version
|
||||
*
|
||||
* @return mixed bool false if no error or the error string
|
||||
*/
|
||||
function checkPHP(&$errmsg, $req, $relation = 'ge')
|
||||
{
|
||||
// this would be a bit stupid, but oh well :)
|
||||
if ($relation == 'has') {
|
||||
return false;
|
||||
}
|
||||
if ($relation == 'not') {
|
||||
$errmsg = "Invalid dependency - 'not' is allowed when specifying PHP, you must run PHP in PHP";
|
||||
return PEAR_DEPENDENCY_BAD_DEPENDENCY;
|
||||
}
|
||||
if (substr($req, 0, 2) == 'v.') {
|
||||
$req = substr($req,2, strlen($req) - 2);
|
||||
}
|
||||
$php_ver = phpversion();
|
||||
$operator = $relation;
|
||||
if (!version_compare("$php_ver", "$req", $operator)) {
|
||||
$errmsg = "PHP version " . $this->signOperator($operator) .
|
||||
" $req is required";
|
||||
return PEAR_DEPENDENCY_CONFLICT;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ checkProgram()
|
||||
|
||||
/**
|
||||
* External program check method. Looks for executable files in
|
||||
* directories listed in the PATH environment variable.
|
||||
*
|
||||
* @param string $program which program to look for
|
||||
*
|
||||
* @return mixed bool false if no error or the error string
|
||||
*/
|
||||
function checkProgram(&$errmsg, $program)
|
||||
{
|
||||
// XXX FIXME honor safe mode
|
||||
$exe_suffix = OS_WINDOWS ? '.exe' : '';
|
||||
$path_elements = explode(PATH_SEPARATOR, getenv('PATH'));
|
||||
foreach ($path_elements as $dir) {
|
||||
$file = $dir . DIRECTORY_SEPARATOR . $program . $exe_suffix;
|
||||
if (file_exists($file) && is_executable($file)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$errmsg = "'$program' program is not present in the PATH";
|
||||
return PEAR_DEPENDENCY_MISSING;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ checkSAPI()
|
||||
|
||||
/**
|
||||
* SAPI backend check method. Version comparison is not yet
|
||||
* available here.
|
||||
*
|
||||
* @param string $name name of SAPI backend
|
||||
* @param string $req which version to compare
|
||||
* @param string $relation how to compare versions (currently
|
||||
* hardcoded to 'has')
|
||||
* @return mixed bool false if no error or the error string
|
||||
*/
|
||||
function checkSAPI(&$errmsg, $name, $req = null, $relation = 'has')
|
||||
{
|
||||
// XXX Fixme: There is no way to know if the user has or
|
||||
// not other SAPI backends installed than the installer one
|
||||
|
||||
$sapi_backend = php_sapi_name();
|
||||
// Version comparisons not supported, sapi backends don't have
|
||||
// version information yet.
|
||||
if ($sapi_backend == $name) {
|
||||
return false;
|
||||
}
|
||||
$errmsg = "'$sapi_backend' SAPI backend not supported";
|
||||
return PEAR_DEPENDENCY_CONFLICT;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ checkZend()
|
||||
|
||||
/**
|
||||
* Zend version check method
|
||||
*
|
||||
* @param string $req which version to compare
|
||||
* @param string $relation how to compare the version
|
||||
*
|
||||
* @return mixed bool false if no error or the error string
|
||||
*/
|
||||
function checkZend(&$errmsg, $req, $relation = 'ge')
|
||||
{
|
||||
if (substr($req, 0, 2) == 'v.') {
|
||||
$req = substr($req,2, strlen($req) - 2);
|
||||
}
|
||||
$zend_ver = zend_version();
|
||||
$operator = substr($relation,0,2);
|
||||
if (!version_compare("$zend_ver", "$req", $operator)) {
|
||||
$errmsg = "Zend version " . $this->signOperator($operator) .
|
||||
" $req is required";
|
||||
return PEAR_DEPENDENCY_CONFLICT;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ signOperator()
|
||||
|
||||
/**
|
||||
* Converts text comparing operators to them sign equivalents
|
||||
*
|
||||
* Example: 'ge' to '>='
|
||||
*
|
||||
* @access public
|
||||
* @param string Operator
|
||||
* @return string Sign equivalent
|
||||
*/
|
||||
function signOperator($operator)
|
||||
{
|
||||
switch($operator) {
|
||||
case 'lt': return '<';
|
||||
case 'le': return '<=';
|
||||
case 'gt': return '>';
|
||||
case 'ge': return '>=';
|
||||
case 'eq': return '==';
|
||||
case 'ne': return '!=';
|
||||
default:
|
||||
return $operator;
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ codeFromRelation()
|
||||
|
||||
/**
|
||||
* Convert relation into corresponding code
|
||||
*
|
||||
* @access public
|
||||
* @param string Relation
|
||||
* @param string Version
|
||||
* @param string Requirement
|
||||
* @param bool Optional dependency indicator
|
||||
* @return integer
|
||||
*/
|
||||
function codeFromRelation($relation, $version, $req, $opt = false)
|
||||
{
|
||||
$code = PEAR_DEPENDENCY_BAD_DEPENDENCY;
|
||||
switch ($relation) {
|
||||
case 'gt': case 'ge': case 'eq':
|
||||
// upgrade
|
||||
$have_major = preg_replace('/\D.*/', '', $version);
|
||||
$need_major = preg_replace('/\D.*/', '', $req);
|
||||
if ($need_major > $have_major) {
|
||||
$code = $opt ? PEAR_DEPENDENCY_UPGRADE_MAJOR_OPTIONAL :
|
||||
PEAR_DEPENDENCY_UPGRADE_MAJOR;
|
||||
} else {
|
||||
$code = $opt ? PEAR_DEPENDENCY_UPGRADE_MINOR_OPTIONAL :
|
||||
PEAR_DEPENDENCY_UPGRADE_MINOR;
|
||||
}
|
||||
break;
|
||||
case 'lt': case 'le': case 'ne':
|
||||
$code = $opt ? PEAR_DEPENDENCY_CONFLICT_OPTIONAL :
|
||||
PEAR_DEPENDENCY_CONFLICT;
|
||||
break;
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
?>
|
||||
1299
vendor/library/Excel/phpxls/PEAR/Dependency2.php
vendored
Normal file
1299
vendor/library/Excel/phpxls/PEAR/Dependency2.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
713
vendor/library/Excel/phpxls/PEAR/DependencyDB.php
vendored
Normal file
713
vendor/library/Excel/phpxls/PEAR/DependencyDB.php
vendored
Normal file
|
|
@ -0,0 +1,713 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_DependencyDB, advanced installed packages dependency database
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Tomas V. V. Cox <cox@idecnet.com>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: DependencyDB.php,v 1.37 2008/01/03 20:26:35 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
|
||||
/**
|
||||
* Needed for error handling
|
||||
*/
|
||||
require_once 'PEAR.php';
|
||||
require_once 'PEAR/Config.php';
|
||||
|
||||
$GLOBALS['_PEAR_DEPENDENCYDB_INSTANCE'] = array();
|
||||
/**
|
||||
* Track dependency relationships between installed packages
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @author Tomas V.V.Cox <cox@idec.net.com>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a1
|
||||
*/
|
||||
class PEAR_DependencyDB
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
/**
|
||||
* This is initialized by {@link setConfig()}
|
||||
* @var PEAR_Config
|
||||
* @access private
|
||||
*/
|
||||
var $_config;
|
||||
/**
|
||||
* This is initialized by {@link setConfig()}
|
||||
* @var PEAR_Registry
|
||||
* @access private
|
||||
*/
|
||||
var $_registry;
|
||||
/**
|
||||
* Filename of the dependency DB (usually .depdb)
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_depdb = false;
|
||||
/**
|
||||
* File name of the lockfile (usually .depdblock)
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_lockfile = false;
|
||||
/**
|
||||
* Open file resource for locking the lockfile
|
||||
* @var resource|false
|
||||
* @access private
|
||||
*/
|
||||
var $_lockFp = false;
|
||||
/**
|
||||
* API version of this class, used to validate a file on-disk
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_version = '1.0';
|
||||
/**
|
||||
* Cached dependency database file
|
||||
* @var array|null
|
||||
* @access private
|
||||
*/
|
||||
var $_cache;
|
||||
|
||||
// }}}
|
||||
// {{{ & singleton()
|
||||
|
||||
/**
|
||||
* Get a raw dependency database. Calls setConfig() and assertDepsDB()
|
||||
* @param PEAR_Config
|
||||
* @param string|false full path to the dependency database, or false to use default
|
||||
* @return PEAR_DependencyDB|PEAR_Error
|
||||
* @static
|
||||
*/
|
||||
static function &singleton(&$config, $depdb = false)
|
||||
{
|
||||
if (!isset($GLOBALS['_PEAR_DEPENDENCYDB_INSTANCE']
|
||||
[$config->get('php_dir', null, 'pear.php.net')])) {
|
||||
$a = new PEAR_DependencyDB;
|
||||
$GLOBALS['_PEAR_DEPENDENCYDB_INSTANCE']
|
||||
[$config->get('php_dir', null, 'pear.php.net')] = &$a;
|
||||
$a->setConfig($config, $depdb);
|
||||
if (PEAR::isError($e = $a->assertDepsDB())) {
|
||||
return $e;
|
||||
}
|
||||
}
|
||||
return $GLOBALS['_PEAR_DEPENDENCYDB_INSTANCE']
|
||||
[$config->get('php_dir', null, 'pear.php.net')];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the registry/location of dependency DB
|
||||
* @param PEAR_Config|false
|
||||
* @param string|false full path to the dependency database, or false to use default
|
||||
*/
|
||||
function setConfig(&$config, $depdb = false)
|
||||
{
|
||||
if (!$config) {
|
||||
$this->_config = &PEAR_Config::singleton();
|
||||
} else {
|
||||
$this->_config = &$config;
|
||||
}
|
||||
$this->_registry = &$this->_config->getRegistry();
|
||||
if (!$depdb) {
|
||||
$this->_depdb = $this->_config->get('php_dir', null, 'pear.php.net') .
|
||||
DIRECTORY_SEPARATOR . '.depdb';
|
||||
} else {
|
||||
$this->_depdb = $depdb;
|
||||
}
|
||||
$this->_lockfile = dirname($this->_depdb) . DIRECTORY_SEPARATOR . '.depdblock';
|
||||
}
|
||||
// }}}
|
||||
|
||||
function hasWriteAccess()
|
||||
{
|
||||
if (!file_exists($this->_depdb)) {
|
||||
$dir = $this->_depdb;
|
||||
while ($dir && $dir != '.') {
|
||||
$dir = dirname($dir); // cd ..
|
||||
if ($dir != '.' && file_exists($dir)) {
|
||||
if (is_writeable($dir)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return is_writeable($this->_depdb);
|
||||
}
|
||||
|
||||
// {{{ assertDepsDB()
|
||||
|
||||
/**
|
||||
* Create the dependency database, if it doesn't exist. Error if the database is
|
||||
* newer than the code reading it.
|
||||
* @return void|PEAR_Error
|
||||
*/
|
||||
function assertDepsDB()
|
||||
{
|
||||
if (!is_file($this->_depdb)) {
|
||||
$this->rebuildDB();
|
||||
} else {
|
||||
$depdb = $this->_getDepDB();
|
||||
// Datatype format has been changed, rebuild the Deps DB
|
||||
if ($depdb['_version'] < $this->_version) {
|
||||
$this->rebuildDB();
|
||||
}
|
||||
if ($depdb['_version']{0} > $this->_version{0}) {
|
||||
return PEAR::raiseError('Dependency database is version ' .
|
||||
$depdb['_version'] . ', and we are version ' .
|
||||
$this->_version . ', cannot continue');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of installed packages that depend on this package
|
||||
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2|array
|
||||
* @return array|false
|
||||
*/
|
||||
function getDependentPackages(&$pkg)
|
||||
{
|
||||
$data = $this->_getDepDB();
|
||||
if (is_object($pkg)) {
|
||||
$channel = strtolower($pkg->getChannel());
|
||||
$package = strtolower($pkg->getPackage());
|
||||
} else {
|
||||
$channel = strtolower($pkg['channel']);
|
||||
$package = strtolower($pkg['package']);
|
||||
}
|
||||
if (isset($data['packages'][$channel][$package])) {
|
||||
return $data['packages'][$channel][$package];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of the actual dependencies of installed packages that depend on
|
||||
* a package.
|
||||
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2|array
|
||||
* @return array|false
|
||||
*/
|
||||
function getDependentPackageDependencies(&$pkg)
|
||||
{
|
||||
$data = $this->_getDepDB();
|
||||
if (is_object($pkg)) {
|
||||
$channel = strtolower($pkg->getChannel());
|
||||
$package = strtolower($pkg->getPackage());
|
||||
} else {
|
||||
$channel = strtolower($pkg['channel']);
|
||||
$package = strtolower($pkg['package']);
|
||||
}
|
||||
$depend = $this->getDependentPackages($pkg);
|
||||
if (!$depend) {
|
||||
return false;
|
||||
}
|
||||
$dependencies = array();
|
||||
foreach ($depend as $info) {
|
||||
$temp = $this->getDependencies($info);
|
||||
foreach ($temp as $dep) {
|
||||
if (strtolower($dep['dep']['channel']) == strtolower($channel) &&
|
||||
strtolower($dep['dep']['name']) == strtolower($package)) {
|
||||
if (!isset($dependencies[$info['channel']])) {
|
||||
$dependencies[$info['channel']] = array();
|
||||
}
|
||||
if (!isset($dependencies[$info['channel']][$info['package']])) {
|
||||
$dependencies[$info['channel']][$info['package']] = array();
|
||||
}
|
||||
$dependencies[$info['channel']][$info['package']][] = $dep;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of dependencies of this installed package
|
||||
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2|array
|
||||
* @return array|false
|
||||
*/
|
||||
function getDependencies(&$pkg)
|
||||
{
|
||||
if (is_object($pkg)) {
|
||||
$channel = strtolower($pkg->getChannel());
|
||||
$package = strtolower($pkg->getPackage());
|
||||
} else {
|
||||
$channel = strtolower($pkg['channel']);
|
||||
$package = strtolower($pkg['package']);
|
||||
}
|
||||
$data = $this->_getDepDB();
|
||||
if (isset($data['dependencies'][$channel][$package])) {
|
||||
return $data['dependencies'][$channel][$package];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether $parent depends on $child, near or deep
|
||||
* @param array|PEAR_PackageFile_v2|PEAR_PackageFile_v2
|
||||
* @param array|PEAR_PackageFile_v2|PEAR_PackageFile_v2
|
||||
*/
|
||||
function dependsOn($parent, $child)
|
||||
{
|
||||
$c = array();
|
||||
$this->_getDepDB();
|
||||
return $this->_dependsOn($parent, $child, $c);
|
||||
}
|
||||
|
||||
function _dependsOn($parent, $child, &$checked)
|
||||
{
|
||||
if (is_object($parent)) {
|
||||
$channel = strtolower($parent->getChannel());
|
||||
$package = strtolower($parent->getPackage());
|
||||
} else {
|
||||
$channel = strtolower($parent['channel']);
|
||||
$package = strtolower($parent['package']);
|
||||
}
|
||||
if (is_object($child)) {
|
||||
$depchannel = strtolower($child->getChannel());
|
||||
$deppackage = strtolower($child->getPackage());
|
||||
} else {
|
||||
$depchannel = strtolower($child['channel']);
|
||||
$deppackage = strtolower($child['package']);
|
||||
}
|
||||
if (isset($checked[$channel][$package][$depchannel][$deppackage])) {
|
||||
return false; // avoid endless recursion
|
||||
}
|
||||
$checked[$channel][$package][$depchannel][$deppackage] = true;
|
||||
if (!isset($this->_cache['dependencies'][$channel][$package])) {
|
||||
return false;
|
||||
}
|
||||
foreach ($this->_cache['dependencies'][$channel][$package] as $info) {
|
||||
if (isset($info['dep']['uri'])) {
|
||||
if (is_object($child)) {
|
||||
if ($info['dep']['uri'] == $child->getURI()) {
|
||||
return true;
|
||||
}
|
||||
} elseif (isset($child['uri'])) {
|
||||
if ($info['dep']['uri'] == $child['uri']) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (strtolower($info['dep']['channel']) == strtolower($depchannel) &&
|
||||
strtolower($info['dep']['name']) == strtolower($deppackage)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
foreach ($this->_cache['dependencies'][$channel][$package] as $info) {
|
||||
if (isset($info['dep']['uri'])) {
|
||||
if ($this->_dependsOn(array(
|
||||
'uri' => $info['dep']['uri'],
|
||||
'package' => $info['dep']['name']), $child, $checked)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ($this->_dependsOn(array(
|
||||
'channel' => $info['dep']['channel'],
|
||||
'package' => $info['dep']['name']), $child, $checked)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register dependencies of a package that is being installed or upgraded
|
||||
* @param PEAR_PackageFile_v2|PEAR_PackageFile_v2
|
||||
*/
|
||||
function installPackage(&$package)
|
||||
{
|
||||
$data = $this->_getDepDB();
|
||||
unset($this->_cache);
|
||||
$this->_setPackageDeps($data, $package);
|
||||
$this->_writeDepDB($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove dependencies of a package that is being uninstalled, or upgraded.
|
||||
*
|
||||
* Upgraded packages first uninstall, then install
|
||||
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2|array If an array, then it must have
|
||||
* indices 'channel' and 'package'
|
||||
*/
|
||||
function uninstallPackage(&$pkg)
|
||||
{
|
||||
$data = $this->_getDepDB();
|
||||
unset($this->_cache);
|
||||
if (is_object($pkg)) {
|
||||
$channel = strtolower($pkg->getChannel());
|
||||
$package = strtolower($pkg->getPackage());
|
||||
} else {
|
||||
$channel = strtolower($pkg['channel']);
|
||||
$package = strtolower($pkg['package']);
|
||||
}
|
||||
if (!isset($data['dependencies'][$channel][$package])) {
|
||||
return true;
|
||||
}
|
||||
foreach ($data['dependencies'][$channel][$package] as $dep) {
|
||||
$found = false;
|
||||
if (isset($dep['dep']['uri'])) {
|
||||
$depchannel = '__uri';
|
||||
} else {
|
||||
$depchannel = strtolower($dep['dep']['channel']);
|
||||
}
|
||||
if (isset($data['packages'][$depchannel][strtolower($dep['dep']['name'])])) {
|
||||
foreach ($data['packages'][$depchannel][strtolower($dep['dep']['name'])] as
|
||||
$i => $info) {
|
||||
if ($info['channel'] == $channel &&
|
||||
$info['package'] == $package) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($found) {
|
||||
unset($data['packages'][$depchannel][strtolower($dep['dep']['name'])][$i]);
|
||||
if (!count($data['packages'][$depchannel][strtolower($dep['dep']['name'])])) {
|
||||
unset($data['packages'][$depchannel][strtolower($dep['dep']['name'])]);
|
||||
if (!count($data['packages'][$depchannel])) {
|
||||
unset($data['packages'][$depchannel]);
|
||||
}
|
||||
} else {
|
||||
$data['packages'][$depchannel][strtolower($dep['dep']['name'])] =
|
||||
array_values(
|
||||
$data['packages'][$depchannel][strtolower($dep['dep']['name'])]);
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($data['dependencies'][$channel][$package]);
|
||||
if (!count($data['dependencies'][$channel])) {
|
||||
unset($data['dependencies'][$channel]);
|
||||
}
|
||||
if (!count($data['dependencies'])) {
|
||||
unset($data['dependencies']);
|
||||
}
|
||||
if (!count($data['packages'])) {
|
||||
unset($data['packages']);
|
||||
}
|
||||
$this->_writeDepDB($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild the dependency DB by reading registry entries.
|
||||
* @return true|PEAR_Error
|
||||
*/
|
||||
function rebuildDB()
|
||||
{
|
||||
$depdb = array('_version' => $this->_version);
|
||||
if (!$this->hasWriteAccess()) {
|
||||
// allow startup for read-only with older Registry
|
||||
return $depdb;
|
||||
}
|
||||
$packages = $this->_registry->listAllPackages();
|
||||
if (PEAR::isError($packages)) {
|
||||
return $packages;
|
||||
}
|
||||
foreach ($packages as $channel => $ps) {
|
||||
foreach ($ps as $package) {
|
||||
$package = $this->_registry->getPackage($package, $channel);
|
||||
if (PEAR::isError($package)) {
|
||||
return $package;
|
||||
}
|
||||
$this->_setPackageDeps($depdb, $package);
|
||||
}
|
||||
}
|
||||
$error = $this->_writeDepDB($depdb);
|
||||
if (PEAR::isError($error)) {
|
||||
return $error;
|
||||
}
|
||||
$this->_cache = $depdb;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register usage of the dependency DB to prevent race conditions
|
||||
* @param int one of the LOCK_* constants
|
||||
* @return true|PEAR_Error
|
||||
* @access private
|
||||
*/
|
||||
function _lock($mode = LOCK_EX)
|
||||
{
|
||||
if (!eregi('Windows 9', php_uname())) {
|
||||
if ($mode != LOCK_UN && is_resource($this->_lockFp)) {
|
||||
// XXX does not check type of lock (LOCK_SH/LOCK_EX)
|
||||
return true;
|
||||
}
|
||||
$open_mode = 'w';
|
||||
// XXX People reported problems with LOCK_SH and 'w'
|
||||
if ($mode === LOCK_SH) {
|
||||
if (!file_exists($this->_lockfile)) {
|
||||
touch($this->_lockfile);
|
||||
} elseif (!is_file($this->_lockfile)) {
|
||||
return PEAR::raiseError('could not create Dependency lock file, ' .
|
||||
'it exists and is not a regular file');
|
||||
}
|
||||
$open_mode = 'r';
|
||||
}
|
||||
|
||||
if (!is_resource($this->_lockFp)) {
|
||||
$this->_lockFp = @fopen($this->_lockfile, $open_mode);
|
||||
}
|
||||
if (!is_resource($this->_lockFp)) {
|
||||
return PEAR::raiseError("could not create Dependency lock file" .
|
||||
(isset($php_errormsg) ? ": " . $php_errormsg : ""));
|
||||
}
|
||||
if (!(int)flock($this->_lockFp, $mode)) {
|
||||
switch ($mode) {
|
||||
case LOCK_SH: $str = 'shared'; break;
|
||||
case LOCK_EX: $str = 'exclusive'; break;
|
||||
case LOCK_UN: $str = 'unlock'; break;
|
||||
default: $str = 'unknown'; break;
|
||||
}
|
||||
return PEAR::raiseError("could not acquire $str lock ($this->_lockfile)");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release usage of dependency DB
|
||||
* @return true|PEAR_Error
|
||||
* @access private
|
||||
*/
|
||||
function _unlock()
|
||||
{
|
||||
$ret = $this->_lock(LOCK_UN);
|
||||
if (is_resource($this->_lockFp)) {
|
||||
fclose($this->_lockFp);
|
||||
}
|
||||
$this->_lockFp = null;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the dependency database from disk, or return the cache
|
||||
* @return array|PEAR_Error
|
||||
*/
|
||||
function _getDepDB()
|
||||
{
|
||||
if (!$this->hasWriteAccess()) {
|
||||
return array('_version' => $this->_version);
|
||||
}
|
||||
if (isset($this->_cache)) {
|
||||
return $this->_cache;
|
||||
}
|
||||
if (!$fp = fopen($this->_depdb, 'r')) {
|
||||
$err = PEAR::raiseError("Could not open dependencies file `".$this->_depdb."'");
|
||||
return $err;
|
||||
}
|
||||
$rt = get_magic_quotes_runtime();
|
||||
set_magic_quotes_runtime(0);
|
||||
clearstatcache();
|
||||
fclose($fp);
|
||||
$data = unserialize(file_get_contents($this->_depdb));
|
||||
set_magic_quotes_runtime($rt);
|
||||
$this->_cache = $data;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out the dependency database to disk
|
||||
* @param array the database
|
||||
* @return true|PEAR_Error
|
||||
* @access private
|
||||
*/
|
||||
function _writeDepDB(&$deps)
|
||||
{
|
||||
if (PEAR::isError($e = $this->_lock(LOCK_EX))) {
|
||||
return $e;
|
||||
}
|
||||
if (!$fp = fopen($this->_depdb, 'wb')) {
|
||||
$this->_unlock();
|
||||
return PEAR::raiseError("Could not open dependencies file `".$this->_depdb."' for writing");
|
||||
}
|
||||
$rt = get_magic_quotes_runtime();
|
||||
set_magic_quotes_runtime(0);
|
||||
fwrite($fp, serialize($deps));
|
||||
set_magic_quotes_runtime($rt);
|
||||
fclose($fp);
|
||||
$this->_unlock();
|
||||
$this->_cache = $deps;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all dependencies from a package in the dependencies database, in essence
|
||||
* "installing" the package's dependency information
|
||||
* @param array the database
|
||||
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
|
||||
* @access private
|
||||
*/
|
||||
function _setPackageDeps(&$data, &$pkg)
|
||||
{
|
||||
$pkg->setConfig($this->_config);
|
||||
if ($pkg->getPackagexmlVersion() == '1.0') {
|
||||
$gen = &$pkg->getDefaultGenerator();
|
||||
$deps = $gen->dependenciesToV2();
|
||||
} else {
|
||||
$deps = $pkg->getDeps(true);
|
||||
}
|
||||
if (!$deps) {
|
||||
return;
|
||||
}
|
||||
if (!is_array($data)) {
|
||||
$data = array();
|
||||
}
|
||||
if (!isset($data['dependencies'])) {
|
||||
$data['dependencies'] = array();
|
||||
}
|
||||
if (!isset($data['dependencies'][strtolower($pkg->getChannel())])) {
|
||||
$data['dependencies'][strtolower($pkg->getChannel())] = array();
|
||||
}
|
||||
$data['dependencies'][strtolower($pkg->getChannel())][strtolower($pkg->getPackage())]
|
||||
= array();
|
||||
if (isset($deps['required']['package'])) {
|
||||
if (!isset($deps['required']['package'][0])) {
|
||||
$deps['required']['package'] = array($deps['required']['package']);
|
||||
}
|
||||
foreach ($deps['required']['package'] as $dep) {
|
||||
$this->_registerDep($data, $pkg, $dep, 'required');
|
||||
}
|
||||
}
|
||||
if (isset($deps['optional']['package'])) {
|
||||
if (!isset($deps['optional']['package'][0])) {
|
||||
$deps['optional']['package'] = array($deps['optional']['package']);
|
||||
}
|
||||
foreach ($deps['optional']['package'] as $dep) {
|
||||
$this->_registerDep($data, $pkg, $dep, 'optional');
|
||||
}
|
||||
}
|
||||
if (isset($deps['required']['subpackage'])) {
|
||||
if (!isset($deps['required']['subpackage'][0])) {
|
||||
$deps['required']['subpackage'] = array($deps['required']['subpackage']);
|
||||
}
|
||||
foreach ($deps['required']['subpackage'] as $dep) {
|
||||
$this->_registerDep($data, $pkg, $dep, 'required');
|
||||
}
|
||||
}
|
||||
if (isset($deps['optional']['subpackage'])) {
|
||||
if (!isset($deps['optional']['subpackage'][0])) {
|
||||
$deps['optional']['subpackage'] = array($deps['optional']['subpackage']);
|
||||
}
|
||||
foreach ($deps['optional']['subpackage'] as $dep) {
|
||||
$this->_registerDep($data, $pkg, $dep, 'optional');
|
||||
}
|
||||
}
|
||||
if (isset($deps['group'])) {
|
||||
if (!isset($deps['group'][0])) {
|
||||
$deps['group'] = array($deps['group']);
|
||||
}
|
||||
foreach ($deps['group'] as $group) {
|
||||
if (isset($group['package'])) {
|
||||
if (!isset($group['package'][0])) {
|
||||
$group['package'] = array($group['package']);
|
||||
}
|
||||
foreach ($group['package'] as $dep) {
|
||||
$this->_registerDep($data, $pkg, $dep, 'optional',
|
||||
$group['attribs']['name']);
|
||||
}
|
||||
}
|
||||
if (isset($group['subpackage'])) {
|
||||
if (!isset($group['subpackage'][0])) {
|
||||
$group['subpackage'] = array($group['subpackage']);
|
||||
}
|
||||
foreach ($group['subpackage'] as $dep) {
|
||||
$this->_registerDep($data, $pkg, $dep, 'optional',
|
||||
$group['attribs']['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($data['dependencies'][strtolower($pkg->getChannel())]
|
||||
[strtolower($pkg->getPackage())] == array()) {
|
||||
unset($data['dependencies'][strtolower($pkg->getChannel())]
|
||||
[strtolower($pkg->getPackage())]);
|
||||
if (!count($data['dependencies'][strtolower($pkg->getChannel())])) {
|
||||
unset($data['dependencies'][strtolower($pkg->getChannel())]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array the database
|
||||
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
|
||||
* @param array the specific dependency
|
||||
* @param required|optional whether this is a required or an optional dep
|
||||
* @param string|false dependency group this dependency is from, or false for ordinary dep
|
||||
*/
|
||||
function _registerDep(&$data, &$pkg, $dep, $type, $group = false)
|
||||
{
|
||||
$info = array(
|
||||
'dep' => $dep,
|
||||
'type' => $type,
|
||||
'group' => $group);
|
||||
|
||||
if (isset($dep['channel'])) {
|
||||
$depchannel = $dep['channel'];
|
||||
} else {
|
||||
$depchannel = '__uri';
|
||||
}
|
||||
if (!isset($data['dependencies'])) {
|
||||
$data['dependencies'] = array();
|
||||
}
|
||||
if (!isset($data['dependencies'][strtolower($pkg->getChannel())])) {
|
||||
$data['dependencies'][strtolower($pkg->getChannel())] = array();
|
||||
}
|
||||
if (!isset($data['dependencies'][strtolower($pkg->getChannel())][strtolower($pkg->getPackage())])) {
|
||||
$data['dependencies'][strtolower($pkg->getChannel())][strtolower($pkg->getPackage())] = array();
|
||||
}
|
||||
$data['dependencies'][strtolower($pkg->getChannel())][strtolower($pkg->getPackage())][]
|
||||
= $info;
|
||||
if (isset($data['packages'][strtolower($depchannel)][strtolower($dep['name'])])) {
|
||||
$found = false;
|
||||
foreach ($data['packages'][strtolower($depchannel)][strtolower($dep['name'])]
|
||||
as $i => $p) {
|
||||
if ($p['channel'] == strtolower($pkg->getChannel()) &&
|
||||
$p['package'] == strtolower($pkg->getPackage())) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
$data['packages'][strtolower($depchannel)][strtolower($dep['name'])][]
|
||||
= array('channel' => strtolower($pkg->getChannel()),
|
||||
'package' => strtolower($pkg->getPackage()));
|
||||
}
|
||||
} else {
|
||||
if (!isset($data['packages'])) {
|
||||
$data['packages'] = array();
|
||||
}
|
||||
if (!isset($data['packages'][strtolower($depchannel)])) {
|
||||
$data['packages'][strtolower($depchannel)] = array();
|
||||
}
|
||||
if (!isset($data['packages'][strtolower($depchannel)][strtolower($dep['name'])])) {
|
||||
$data['packages'][strtolower($depchannel)][strtolower($dep['name'])] = array();
|
||||
}
|
||||
$data['packages'][strtolower($depchannel)][strtolower($dep['name'])][]
|
||||
= array('channel' => strtolower($pkg->getChannel()),
|
||||
'package' => strtolower($pkg->getPackage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
1752
vendor/library/Excel/phpxls/PEAR/Downloader.php
vendored
Normal file
1752
vendor/library/Excel/phpxls/PEAR/Downloader.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
1853
vendor/library/Excel/phpxls/PEAR/Downloader/Package.php
vendored
Normal file
1853
vendor/library/Excel/phpxls/PEAR/Downloader/Package.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
985
vendor/library/Excel/phpxls/PEAR/ErrorStack.php
vendored
Normal file
985
vendor/library/Excel/phpxls/PEAR/ErrorStack.php
vendored
Normal file
|
|
@ -0,0 +1,985 @@
|
|||
<?php
|
||||
/**
|
||||
* Error Stack Implementation
|
||||
*
|
||||
* This is an incredibly simple implementation of a very complex error handling
|
||||
* facility. It contains the ability
|
||||
* to track multiple errors from multiple packages simultaneously. In addition,
|
||||
* it can track errors of many levels, save data along with the error, context
|
||||
* information such as the exact file, line number, class and function that
|
||||
* generated the error, and if necessary, it can raise a traditional PEAR_Error.
|
||||
* It has built-in support for PEAR::Log, to log errors as they occur
|
||||
*
|
||||
* Since version 0.2alpha, it is also possible to selectively ignore errors,
|
||||
* through the use of an error callback, see {@link pushCallback()}
|
||||
*
|
||||
* Since version 0.3alpha, it is possible to specify the exception class
|
||||
* returned from {@link push()}
|
||||
*
|
||||
* Since version PEAR1.3.2, ErrorStack no longer instantiates an exception class. This can
|
||||
* still be done quite handily in an error callback or by manipulating the returned array
|
||||
* @category Debugging
|
||||
* @package PEAR_ErrorStack
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 2004-2008 Greg Beaver
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: ErrorStack.php,v 1.28 2008/01/03 20:26:35 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR_ErrorStack
|
||||
*/
|
||||
|
||||
/**
|
||||
* Singleton storage
|
||||
*
|
||||
* Format:
|
||||
* <pre>
|
||||
* array(
|
||||
* 'package1' => PEAR_ErrorStack object,
|
||||
* 'package2' => PEAR_ErrorStack object,
|
||||
* ...
|
||||
* )
|
||||
* </pre>
|
||||
* @access private
|
||||
* @global array $GLOBALS['_PEAR_ERRORSTACK_SINGLETON']
|
||||
*/
|
||||
$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] = array();
|
||||
|
||||
/**
|
||||
* Global error callback (default)
|
||||
*
|
||||
* This is only used if set to non-false. * is the default callback for
|
||||
* all packages, whereas specific packages may set a default callback
|
||||
* for all instances, regardless of whether they are a singleton or not.
|
||||
*
|
||||
* To exclude non-singletons, only set the local callback for the singleton
|
||||
* @see PEAR_ErrorStack::setDefaultCallback()
|
||||
* @access private
|
||||
* @global array $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK']
|
||||
*/
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'] = array(
|
||||
'*' => false,
|
||||
);
|
||||
|
||||
/**
|
||||
* Global Log object (default)
|
||||
*
|
||||
* This is only used if set to non-false. Use to set a default log object for
|
||||
* all stacks, regardless of instantiation order or location
|
||||
* @see PEAR_ErrorStack::setDefaultLogger()
|
||||
* @access private
|
||||
* @global array $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER']
|
||||
*/
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = false;
|
||||
|
||||
/**
|
||||
* Global Overriding Callback
|
||||
*
|
||||
* This callback will override any error callbacks that specific loggers have set.
|
||||
* Use with EXTREME caution
|
||||
* @see PEAR_ErrorStack::staticPushCallback()
|
||||
* @access private
|
||||
* @global array $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER']
|
||||
*/
|
||||
$GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array();
|
||||
|
||||
/**#@+
|
||||
* One of four possible return values from the error Callback
|
||||
* @see PEAR_ErrorStack::_errorCallback()
|
||||
*/
|
||||
/**
|
||||
* If this is returned, then the error will be both pushed onto the stack
|
||||
* and logged.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_PUSHANDLOG', 1);
|
||||
/**
|
||||
* If this is returned, then the error will only be pushed onto the stack,
|
||||
* and not logged.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_PUSH', 2);
|
||||
/**
|
||||
* If this is returned, then the error will only be logged, but not pushed
|
||||
* onto the error stack.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_LOG', 3);
|
||||
/**
|
||||
* If this is returned, then the error is completely ignored.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_IGNORE', 4);
|
||||
/**
|
||||
* If this is returned, then the error is logged and die() is called.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_DIE', 5);
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Error code for an attempt to instantiate a non-class as a PEAR_ErrorStack in
|
||||
* the singleton method.
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_ERR_NONCLASS', 1);
|
||||
|
||||
/**
|
||||
* Error code for an attempt to pass an object into {@link PEAR_ErrorStack::getMessage()}
|
||||
* that has no __toString() method
|
||||
*/
|
||||
define('PEAR_ERRORSTACK_ERR_OBJTOSTRING', 2);
|
||||
/**
|
||||
* Error Stack Implementation
|
||||
*
|
||||
* Usage:
|
||||
* <code>
|
||||
* // global error stack
|
||||
* $global_stack = &PEAR_ErrorStack::singleton('MyPackage');
|
||||
* // local error stack
|
||||
* $local_stack = new PEAR_ErrorStack('MyPackage');
|
||||
* </code>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @version 1.7.2
|
||||
* @package PEAR_ErrorStack
|
||||
* @category Debugging
|
||||
* @copyright 2004-2008 Greg Beaver
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: ErrorStack.php,v 1.28 2008/01/03 20:26:35 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR_ErrorStack
|
||||
*/
|
||||
class PEAR_ErrorStack {
|
||||
/**
|
||||
* Errors are stored in the order that they are pushed on the stack.
|
||||
* @since 0.4alpha Errors are no longer organized by error level.
|
||||
* This renders pop() nearly unusable, and levels could be more easily
|
||||
* handled in a callback anyway
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_errors = array();
|
||||
|
||||
/**
|
||||
* Storage of errors by level.
|
||||
*
|
||||
* Allows easy retrieval and deletion of only errors from a particular level
|
||||
* @since PEAR 1.4.0dev
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_errorsByLevel = array();
|
||||
|
||||
/**
|
||||
* Package name this error stack represents
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
var $_package;
|
||||
|
||||
/**
|
||||
* Determines whether a PEAR_Error is thrown upon every error addition
|
||||
* @var boolean
|
||||
* @access private
|
||||
*/
|
||||
var $_compat = false;
|
||||
|
||||
/**
|
||||
* If set to a valid callback, this will be used to generate the error
|
||||
* message from the error code, otherwise the message passed in will be
|
||||
* used
|
||||
* @var false|string|array
|
||||
* @access private
|
||||
*/
|
||||
var $_msgCallback = false;
|
||||
|
||||
/**
|
||||
* If set to a valid callback, this will be used to generate the error
|
||||
* context for an error. For PHP-related errors, this will be a file
|
||||
* and line number as retrieved from debug_backtrace(), but can be
|
||||
* customized for other purposes. The error might actually be in a separate
|
||||
* configuration file, or in a database query.
|
||||
* @var false|string|array
|
||||
* @access protected
|
||||
*/
|
||||
var $_contextCallback = false;
|
||||
|
||||
/**
|
||||
* If set to a valid callback, this will be called every time an error
|
||||
* is pushed onto the stack. The return value will be used to determine
|
||||
* whether to allow an error to be pushed or logged.
|
||||
*
|
||||
* The return value must be one an PEAR_ERRORSTACK_* constant
|
||||
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
|
||||
* @var false|string|array
|
||||
* @access protected
|
||||
*/
|
||||
var $_errorCallback = array();
|
||||
|
||||
/**
|
||||
* PEAR::Log object for logging errors
|
||||
* @var false|Log
|
||||
* @access protected
|
||||
*/
|
||||
var $_logger = false;
|
||||
|
||||
/**
|
||||
* Error messages - designed to be overridden
|
||||
* @var array
|
||||
* @abstract
|
||||
*/
|
||||
var $_errorMsgs = array();
|
||||
|
||||
/**
|
||||
* Set up a new error stack
|
||||
*
|
||||
* @param string $package name of the package this error stack represents
|
||||
* @param callback $msgCallback callback used for error message generation
|
||||
* @param callback $contextCallback callback used for context generation,
|
||||
* defaults to {@link getFileLine()}
|
||||
* @param boolean $throwPEAR_Error
|
||||
*/
|
||||
function PEAR_ErrorStack($package, $msgCallback = false, $contextCallback = false,
|
||||
$throwPEAR_Error = false)
|
||||
{
|
||||
$this->_package = $package;
|
||||
$this->setMessageCallback($msgCallback);
|
||||
$this->setContextCallback($contextCallback);
|
||||
$this->_compat = $throwPEAR_Error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a single error stack for this package.
|
||||
*
|
||||
* Note that all parameters are ignored if the stack for package $package
|
||||
* has already been instantiated
|
||||
* @param string $package name of the package this error stack represents
|
||||
* @param callback $msgCallback callback used for error message generation
|
||||
* @param callback $contextCallback callback used for context generation,
|
||||
* defaults to {@link getFileLine()}
|
||||
* @param boolean $throwPEAR_Error
|
||||
* @param string $stackClass class to instantiate
|
||||
* @static
|
||||
* @return PEAR_ErrorStack
|
||||
*/
|
||||
static function &singleton($package, $msgCallback = false, $contextCallback = false,
|
||||
$throwPEAR_Error = false, $stackClass = 'PEAR_ErrorStack')
|
||||
{
|
||||
if (isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
|
||||
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
|
||||
}
|
||||
if (!class_exists($stackClass)) {
|
||||
if (function_exists('debug_backtrace')) {
|
||||
$trace = debug_backtrace();
|
||||
}
|
||||
PEAR_ErrorStack::staticPush('PEAR_ErrorStack', PEAR_ERRORSTACK_ERR_NONCLASS,
|
||||
'exception', array('stackclass' => $stackClass),
|
||||
'stack class "%stackclass%" is not a valid class name (should be like PEAR_ErrorStack)',
|
||||
false, $trace);
|
||||
}
|
||||
$GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package] =
|
||||
new $stackClass($package, $msgCallback, $contextCallback, $throwPEAR_Error);
|
||||
|
||||
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal error handler for PEAR_ErrorStack class
|
||||
*
|
||||
* Dies if the error is an exception (and would have died anyway)
|
||||
* @access private
|
||||
*/
|
||||
function _handleError($err)
|
||||
{
|
||||
if ($err['level'] == 'exception') {
|
||||
$message = $err['message'];
|
||||
if (isset($_SERVER['REQUEST_URI'])) {
|
||||
echo '<br />';
|
||||
} else {
|
||||
echo "\n";
|
||||
}
|
||||
var_dump($err['context']);
|
||||
die($message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up a PEAR::Log object for all error stacks that don't have one
|
||||
* @param Log $log
|
||||
* @static
|
||||
*/
|
||||
static function setDefaultLogger(&$log)
|
||||
{
|
||||
if (is_object($log) && method_exists($log, 'log') ) {
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = &$log;
|
||||
} elseif (is_callable($log)) {
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = &$log;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up a PEAR::Log object for this error stack
|
||||
* @param Log $log
|
||||
*/
|
||||
function setLogger(&$log)
|
||||
{
|
||||
if (is_object($log) && method_exists($log, 'log') ) {
|
||||
$this->_logger = &$log;
|
||||
} elseif (is_callable($log)) {
|
||||
$this->_logger = &$log;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an error code => error message mapping callback
|
||||
*
|
||||
* This method sets the callback that can be used to generate error
|
||||
* messages for any instance
|
||||
* @param array|string Callback function/method
|
||||
*/
|
||||
function setMessageCallback($msgCallback)
|
||||
{
|
||||
if (!$msgCallback) {
|
||||
$this->_msgCallback = array(&$this, 'getErrorMessage');
|
||||
} else {
|
||||
if (is_callable($msgCallback)) {
|
||||
$this->_msgCallback = $msgCallback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an error code => error message mapping callback
|
||||
*
|
||||
* This method returns the current callback that can be used to generate error
|
||||
* messages
|
||||
* @return array|string|false Callback function/method or false if none
|
||||
*/
|
||||
function getMessageCallback()
|
||||
{
|
||||
return $this->_msgCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a default callback to be used by all error stacks
|
||||
*
|
||||
* This method sets the callback that can be used to generate error
|
||||
* messages for a singleton
|
||||
* @param array|string Callback function/method
|
||||
* @param string Package name, or false for all packages
|
||||
* @static
|
||||
*/
|
||||
static function setDefaultCallback($callback = false, $package = false)
|
||||
{
|
||||
if (!is_callable($callback)) {
|
||||
$callback = false;
|
||||
}
|
||||
$package = $package ? $package : '*';
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'][$package] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a callback that generates context information (location of error) for an error stack
|
||||
*
|
||||
* This method sets the callback that can be used to generate context
|
||||
* information for an error. Passing in NULL will disable context generation
|
||||
* and remove the expensive call to debug_backtrace()
|
||||
* @param array|string|null Callback function/method
|
||||
*/
|
||||
function setContextCallback($contextCallback)
|
||||
{
|
||||
if ($contextCallback === null) {
|
||||
return $this->_contextCallback = false;
|
||||
}
|
||||
if (!$contextCallback) {
|
||||
$this->_contextCallback = array(&$this, 'getFileLine');
|
||||
} else {
|
||||
if (is_callable($contextCallback)) {
|
||||
$this->_contextCallback = $contextCallback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an error Callback
|
||||
* If set to a valid callback, this will be called every time an error
|
||||
* is pushed onto the stack. The return value will be used to determine
|
||||
* whether to allow an error to be pushed or logged.
|
||||
*
|
||||
* The return value must be one of the ERRORSTACK_* constants.
|
||||
*
|
||||
* This functionality can be used to emulate PEAR's pushErrorHandling, and
|
||||
* the PEAR_ERROR_CALLBACK mode, without affecting the integrity of
|
||||
* the error stack or logging
|
||||
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
|
||||
* @see popCallback()
|
||||
* @param string|array $cb
|
||||
*/
|
||||
function pushCallback($cb)
|
||||
{
|
||||
array_push($this->_errorCallback, $cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a callback from the error callback stack
|
||||
* @see pushCallback()
|
||||
* @return array|string|false
|
||||
*/
|
||||
function popCallback()
|
||||
{
|
||||
if (!count($this->_errorCallback)) {
|
||||
return false;
|
||||
}
|
||||
return array_pop($this->_errorCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a temporary overriding error callback for every package error stack
|
||||
*
|
||||
* Use this to temporarily disable all existing callbacks (can be used
|
||||
* to emulate the @ operator, for instance)
|
||||
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
|
||||
* @see staticPopCallback(), pushCallback()
|
||||
* @param string|array $cb
|
||||
* @static
|
||||
*/
|
||||
static function staticPushCallback($cb)
|
||||
{
|
||||
array_push($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'], $cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a temporary overriding error callback
|
||||
* @see staticPushCallback()
|
||||
* @return array|string|false
|
||||
* @static
|
||||
*/
|
||||
static function staticPopCallback()
|
||||
{
|
||||
$ret = array_pop($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK']);
|
||||
if (!is_array($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'])) {
|
||||
$GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array();
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an error to the stack
|
||||
*
|
||||
* If the message generator exists, it is called with 2 parameters.
|
||||
* - the current Error Stack object
|
||||
* - an array that is in the same format as an error. Available indices
|
||||
* are 'code', 'package', 'time', 'params', 'level', and 'context'
|
||||
*
|
||||
* Next, if the error should contain context information, this is
|
||||
* handled by the context grabbing method.
|
||||
* Finally, the error is pushed onto the proper error stack
|
||||
* @param int $code Package-specific error code
|
||||
* @param string $level Error level. This is NOT spell-checked
|
||||
* @param array $params associative array of error parameters
|
||||
* @param string $msg Error message, or a portion of it if the message
|
||||
* is to be generated
|
||||
* @param array $repackage If this error re-packages an error pushed by
|
||||
* another package, place the array returned from
|
||||
* {@link pop()} in this parameter
|
||||
* @param array $backtrace Protected parameter: use this to pass in the
|
||||
* {@link debug_backtrace()} that should be used
|
||||
* to find error context
|
||||
* @return PEAR_Error|array if compatibility mode is on, a PEAR_Error is also
|
||||
* thrown. If a PEAR_Error is returned, the userinfo
|
||||
* property is set to the following array:
|
||||
*
|
||||
* <code>
|
||||
* array(
|
||||
* 'code' => $code,
|
||||
* 'params' => $params,
|
||||
* 'package' => $this->_package,
|
||||
* 'level' => $level,
|
||||
* 'time' => time(),
|
||||
* 'context' => $context,
|
||||
* 'message' => $msg,
|
||||
* //['repackage' => $err] repackaged error array/Exception class
|
||||
* );
|
||||
* </code>
|
||||
*
|
||||
* Normally, the previous array is returned.
|
||||
*/
|
||||
function push($code, $level = 'error', $params = array(), $msg = false,
|
||||
$repackage = false, $backtrace = false)
|
||||
{
|
||||
$context = false;
|
||||
// grab error context
|
||||
if ($this->_contextCallback) {
|
||||
if (!$backtrace) {
|
||||
$backtrace = debug_backtrace();
|
||||
}
|
||||
$context = call_user_func($this->_contextCallback, $code, $params, $backtrace);
|
||||
}
|
||||
|
||||
// save error
|
||||
$time = explode(' ', microtime());
|
||||
$time = $time[1] + $time[0];
|
||||
$err = array(
|
||||
'code' => $code,
|
||||
'params' => $params,
|
||||
'package' => $this->_package,
|
||||
'level' => $level,
|
||||
'time' => $time,
|
||||
'context' => $context,
|
||||
'message' => $msg,
|
||||
);
|
||||
|
||||
if ($repackage) {
|
||||
$err['repackage'] = $repackage;
|
||||
}
|
||||
|
||||
// set up the error message, if necessary
|
||||
if ($this->_msgCallback) {
|
||||
$msg = call_user_func_array($this->_msgCallback,
|
||||
array(&$this, $err));
|
||||
$err['message'] = $msg;
|
||||
}
|
||||
$push = $log = true;
|
||||
$die = false;
|
||||
// try the overriding callback first
|
||||
$callback = $this->staticPopCallback();
|
||||
if ($callback) {
|
||||
$this->staticPushCallback($callback);
|
||||
}
|
||||
if (!is_callable($callback)) {
|
||||
// try the local callback next
|
||||
$callback = $this->popCallback();
|
||||
if (is_callable($callback)) {
|
||||
$this->pushCallback($callback);
|
||||
} else {
|
||||
// try the default callback
|
||||
$callback = isset($GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'][$this->_package]) ?
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'][$this->_package] :
|
||||
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK']['*'];
|
||||
}
|
||||
}
|
||||
if (is_callable($callback)) {
|
||||
switch(call_user_func($callback, $err)){
|
||||
case PEAR_ERRORSTACK_IGNORE:
|
||||
return $err;
|
||||
break;
|
||||
case PEAR_ERRORSTACK_PUSH:
|
||||
$log = false;
|
||||
break;
|
||||
case PEAR_ERRORSTACK_LOG:
|
||||
$push = false;
|
||||
break;
|
||||
case PEAR_ERRORSTACK_DIE:
|
||||
$die = true;
|
||||
break;
|
||||
// anything else returned has the same effect as pushandlog
|
||||
}
|
||||
}
|
||||
if ($push) {
|
||||
array_unshift($this->_errors, $err);
|
||||
if (!isset($this->_errorsByLevel[$err['level']])) {
|
||||
$this->_errorsByLevel[$err['level']] = array();
|
||||
}
|
||||
$this->_errorsByLevel[$err['level']][] = &$this->_errors[0];
|
||||
}
|
||||
if ($log) {
|
||||
if ($this->_logger || $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER']) {
|
||||
$this->_log($err);
|
||||
}
|
||||
}
|
||||
if ($die) {
|
||||
die();
|
||||
}
|
||||
if ($this->_compat && $push) {
|
||||
return $this->raiseError($msg, $code, null, null, $err);
|
||||
}
|
||||
return $err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static version of {@link push()}
|
||||
*
|
||||
* @param string $package Package name this error belongs to
|
||||
* @param int $code Package-specific error code
|
||||
* @param string $level Error level. This is NOT spell-checked
|
||||
* @param array $params associative array of error parameters
|
||||
* @param string $msg Error message, or a portion of it if the message
|
||||
* is to be generated
|
||||
* @param array $repackage If this error re-packages an error pushed by
|
||||
* another package, place the array returned from
|
||||
* {@link pop()} in this parameter
|
||||
* @param array $backtrace Protected parameter: use this to pass in the
|
||||
* {@link debug_backtrace()} that should be used
|
||||
* to find error context
|
||||
* @return PEAR_Error|array if compatibility mode is on, a PEAR_Error is also
|
||||
* thrown. see docs for {@link push()}
|
||||
* @static
|
||||
*/
|
||||
static function staticPush($package, $code, $level = 'error', $params = array(),
|
||||
$msg = false, $repackage = false, $backtrace = false)
|
||||
{
|
||||
$s = &PEAR_ErrorStack::singleton($package);
|
||||
if ($s->_contextCallback) {
|
||||
if (!$backtrace) {
|
||||
if (function_exists('debug_backtrace')) {
|
||||
$backtrace = debug_backtrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return $s->push($code, $level, $params, $msg, $repackage, $backtrace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an error using PEAR::Log
|
||||
* @param array $err Error array
|
||||
* @param array $levels Error level => Log constant map
|
||||
* @access protected
|
||||
*/
|
||||
function _log($err)
|
||||
{
|
||||
if ($this->_logger) {
|
||||
$logger = &$this->_logger;
|
||||
} else {
|
||||
$logger = &$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'];
|
||||
}
|
||||
if (is_a($logger, 'Log')) {
|
||||
$levels = array(
|
||||
'exception' => PEAR_LOG_CRIT,
|
||||
'alert' => PEAR_LOG_ALERT,
|
||||
'critical' => PEAR_LOG_CRIT,
|
||||
'error' => PEAR_LOG_ERR,
|
||||
'warning' => PEAR_LOG_WARNING,
|
||||
'notice' => PEAR_LOG_NOTICE,
|
||||
'info' => PEAR_LOG_INFO,
|
||||
'debug' => PEAR_LOG_DEBUG);
|
||||
if (isset($levels[$err['level']])) {
|
||||
$level = $levels[$err['level']];
|
||||
} else {
|
||||
$level = PEAR_LOG_INFO;
|
||||
}
|
||||
$logger->log($err['message'], $level, $err);
|
||||
} else { // support non-standard logs
|
||||
call_user_func($logger, $err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pop an error off of the error stack
|
||||
*
|
||||
* @return false|array
|
||||
* @since 0.4alpha it is no longer possible to specify a specific error
|
||||
* level to return - the last error pushed will be returned, instead
|
||||
*/
|
||||
function pop()
|
||||
{
|
||||
$err = @array_shift($this->_errors);
|
||||
if (!is_null($err)) {
|
||||
@array_pop($this->_errorsByLevel[$err['level']]);
|
||||
if (!count($this->_errorsByLevel[$err['level']])) {
|
||||
unset($this->_errorsByLevel[$err['level']]);
|
||||
}
|
||||
}
|
||||
return $err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop an error off of the error stack, static method
|
||||
*
|
||||
* @param string package name
|
||||
* @return boolean
|
||||
* @since PEAR1.5.0a1
|
||||
*/
|
||||
function staticPop($package)
|
||||
{
|
||||
if ($package) {
|
||||
if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
|
||||
return false;
|
||||
}
|
||||
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->pop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether there are any errors on the stack
|
||||
* @param string|array Level name. Use to determine if any errors
|
||||
* of level (string), or levels (array) have been pushed
|
||||
* @return boolean
|
||||
*/
|
||||
function hasErrors($level = false)
|
||||
{
|
||||
if ($level) {
|
||||
return isset($this->_errorsByLevel[$level]);
|
||||
}
|
||||
return count($this->_errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all errors since last purge
|
||||
*
|
||||
* @param boolean set in order to empty the error stack
|
||||
* @param string level name, to return only errors of a particular severity
|
||||
* @return array
|
||||
*/
|
||||
function getErrors($purge = false, $level = false)
|
||||
{
|
||||
if (!$purge) {
|
||||
if ($level) {
|
||||
if (!isset($this->_errorsByLevel[$level])) {
|
||||
return array();
|
||||
} else {
|
||||
return $this->_errorsByLevel[$level];
|
||||
}
|
||||
} else {
|
||||
return $this->_errors;
|
||||
}
|
||||
}
|
||||
if ($level) {
|
||||
$ret = $this->_errorsByLevel[$level];
|
||||
foreach ($this->_errorsByLevel[$level] as $i => $unused) {
|
||||
// entries are references to the $_errors array
|
||||
$this->_errorsByLevel[$level][$i] = false;
|
||||
}
|
||||
// array_filter removes all entries === false
|
||||
$this->_errors = array_filter($this->_errors);
|
||||
unset($this->_errorsByLevel[$level]);
|
||||
return $ret;
|
||||
}
|
||||
$ret = $this->_errors;
|
||||
$this->_errors = array();
|
||||
$this->_errorsByLevel = array();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether there are any errors on a single error stack, or on any error stack
|
||||
*
|
||||
* The optional parameter can be used to test the existence of any errors without the need of
|
||||
* singleton instantiation
|
||||
* @param string|false Package name to check for errors
|
||||
* @param string Level name to check for a particular severity
|
||||
* @return boolean
|
||||
* @static
|
||||
*/
|
||||
static function staticHasErrors($package = false, $level = false)
|
||||
{
|
||||
if ($package) {
|
||||
if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
|
||||
return false;
|
||||
}
|
||||
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->hasErrors($level);
|
||||
}
|
||||
foreach ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $obj) {
|
||||
if ($obj->hasErrors($level)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all errors since last purge, organized by package
|
||||
* @since PEAR 1.4.0dev BC break! $level is now in the place $merge used to be
|
||||
* @param boolean $purge Set to purge the error stack of existing errors
|
||||
* @param string $level Set to a level name in order to retrieve only errors of a particular level
|
||||
* @param boolean $merge Set to return a flat array, not organized by package
|
||||
* @param array $sortfunc Function used to sort a merged array - default
|
||||
* sorts by time, and should be good for most cases
|
||||
* @static
|
||||
* @return array
|
||||
*/
|
||||
static function staticGetErrors($purge = false, $level = false, $merge = false,
|
||||
$sortfunc = array('PEAR_ErrorStack', '_sortErrors'))
|
||||
{
|
||||
$ret = array();
|
||||
if (!is_callable($sortfunc)) {
|
||||
$sortfunc = array('PEAR_ErrorStack', '_sortErrors');
|
||||
}
|
||||
foreach ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $obj) {
|
||||
$test = $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->getErrors($purge, $level);
|
||||
if ($test) {
|
||||
if ($merge) {
|
||||
$ret = array_merge($ret, $test);
|
||||
} else {
|
||||
$ret[$package] = $test;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($merge) {
|
||||
usort($ret, $sortfunc);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error sorting function, sorts by time
|
||||
* @access private
|
||||
*/
|
||||
function _sortErrors($a, $b)
|
||||
{
|
||||
if ($a['time'] == $b['time']) {
|
||||
return 0;
|
||||
}
|
||||
if ($a['time'] < $b['time']) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard file/line number/function/class context callback
|
||||
*
|
||||
* This function uses a backtrace generated from {@link debug_backtrace()}
|
||||
* and so will not work at all in PHP < 4.3.0. The frame should
|
||||
* reference the frame that contains the source of the error.
|
||||
* @return array|false either array('file' => file, 'line' => line,
|
||||
* 'function' => function name, 'class' => class name) or
|
||||
* if this doesn't work, then false
|
||||
* @param unused
|
||||
* @param integer backtrace frame.
|
||||
* @param array Results of debug_backtrace()
|
||||
* @static
|
||||
*/
|
||||
static function getFileLine($code, $params, $backtrace = null)
|
||||
{
|
||||
if ($backtrace === null) {
|
||||
return false;
|
||||
}
|
||||
$frame = 0;
|
||||
$functionframe = 1;
|
||||
if (!isset($backtrace[1])) {
|
||||
$functionframe = 0;
|
||||
} else {
|
||||
while (isset($backtrace[$functionframe]['function']) &&
|
||||
$backtrace[$functionframe]['function'] == 'eval' &&
|
||||
isset($backtrace[$functionframe + 1])) {
|
||||
$functionframe++;
|
||||
}
|
||||
}
|
||||
if (isset($backtrace[$frame])) {
|
||||
if (!isset($backtrace[$frame]['file'])) {
|
||||
$frame++;
|
||||
}
|
||||
$funcbacktrace = $backtrace[$functionframe];
|
||||
$filebacktrace = $backtrace[$frame];
|
||||
$ret = array('file' => $filebacktrace['file'],
|
||||
'line' => $filebacktrace['line']);
|
||||
// rearrange for eval'd code or create function errors
|
||||
if (strpos($filebacktrace['file'], '(') &&
|
||||
preg_match(';^(.*?)\((\d+)\) : (.*?)\\z;', $filebacktrace['file'],
|
||||
$matches)) {
|
||||
$ret['file'] = $matches[1];
|
||||
$ret['line'] = $matches[2] + 0;
|
||||
}
|
||||
if (isset($funcbacktrace['function']) && isset($backtrace[1])) {
|
||||
if ($funcbacktrace['function'] != 'eval') {
|
||||
if ($funcbacktrace['function'] == '__lambda_func') {
|
||||
$ret['function'] = 'create_function() code';
|
||||
} else {
|
||||
$ret['function'] = $funcbacktrace['function'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($funcbacktrace['class']) && isset($backtrace[1])) {
|
||||
$ret['class'] = $funcbacktrace['class'];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard error message generation callback
|
||||
*
|
||||
* This method may also be called by a custom error message generator
|
||||
* to fill in template values from the params array, simply
|
||||
* set the third parameter to the error message template string to use
|
||||
*
|
||||
* The special variable %__msg% is reserved: use it only to specify
|
||||
* where a message passed in by the user should be placed in the template,
|
||||
* like so:
|
||||
*
|
||||
* Error message: %msg% - internal error
|
||||
*
|
||||
* If the message passed like so:
|
||||
*
|
||||
* <code>
|
||||
* $stack->push(ERROR_CODE, 'error', array(), 'server error 500');
|
||||
* </code>
|
||||
*
|
||||
* The returned error message will be "Error message: server error 500 -
|
||||
* internal error"
|
||||
* @param PEAR_ErrorStack
|
||||
* @param array
|
||||
* @param string|false Pre-generated error message template
|
||||
* @static
|
||||
* @return string
|
||||
*/
|
||||
static function getErrorMessage(&$stack, $err, $template = false)
|
||||
{
|
||||
if ($template) {
|
||||
$mainmsg = $template;
|
||||
} else {
|
||||
$mainmsg = $stack->getErrorMessageTemplate($err['code']);
|
||||
}
|
||||
$mainmsg = str_replace('%__msg%', $err['message'], $mainmsg);
|
||||
if (is_array($err['params']) && count($err['params'])) {
|
||||
foreach ($err['params'] as $name => $val) {
|
||||
if (is_array($val)) {
|
||||
// @ is needed in case $val is a multi-dimensional array
|
||||
$val = @implode(', ', $val);
|
||||
}
|
||||
if (is_object($val)) {
|
||||
if (method_exists($val, '__toString')) {
|
||||
$val = $val->__toString();
|
||||
} else {
|
||||
PEAR_ErrorStack::staticPush('PEAR_ErrorStack', PEAR_ERRORSTACK_ERR_OBJTOSTRING,
|
||||
'warning', array('obj' => get_class($val)),
|
||||
'object %obj% passed into getErrorMessage, but has no __toString() method');
|
||||
$val = 'Object';
|
||||
}
|
||||
}
|
||||
$mainmsg = str_replace('%' . $name . '%', $val, $mainmsg);
|
||||
}
|
||||
}
|
||||
return $mainmsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard Error Message Template generator from code
|
||||
* @return string
|
||||
*/
|
||||
function getErrorMessageTemplate($code)
|
||||
{
|
||||
if (!isset($this->_errorMsgs[$code])) {
|
||||
return '%__msg%';
|
||||
}
|
||||
return $this->_errorMsgs[$code];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Error Message Template array
|
||||
*
|
||||
* The array format must be:
|
||||
* <pre>
|
||||
* array(error code => 'message template',...)
|
||||
* </pre>
|
||||
*
|
||||
* Error message parameters passed into {@link push()} will be used as input
|
||||
* for the error message. If the template is 'message %foo% was %bar%', and the
|
||||
* parameters are array('foo' => 'one', 'bar' => 'six'), the error message returned will
|
||||
* be 'message one was six'
|
||||
* @return string
|
||||
*/
|
||||
function setErrorMessageTemplate($template)
|
||||
{
|
||||
$this->_errorMsgs = $template;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* emulate PEAR::raiseError()
|
||||
*
|
||||
* @return PEAR_Error
|
||||
*/
|
||||
function raiseError()
|
||||
{
|
||||
require_once 'PEAR.php';
|
||||
$args = func_get_args();
|
||||
return call_user_func_array(array('PEAR', 'raiseError'), $args);
|
||||
}
|
||||
}
|
||||
$stack = &PEAR_ErrorStack::singleton('PEAR_ErrorStack');
|
||||
$stack->pushCallback(array('PEAR_ErrorStack', '_handleError'));
|
||||
?>
|
||||
397
vendor/library/Excel/phpxls/PEAR/Exception.php
vendored
Normal file
397
vendor/library/Excel/phpxls/PEAR/Exception.php
vendored
Normal file
|
|
@ -0,0 +1,397 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */
|
||||
/**
|
||||
* PEAR_Exception
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Tomas V. V. Cox <cox@idecnet.com>
|
||||
* @author Hans Lellelid <hans@velum.net>
|
||||
* @author Bertrand Mansion <bmansion@mamasam.com>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Exception.php,v 1.29 2008/01/03 20:26:35 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.3.3
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Base PEAR_Exception Class
|
||||
*
|
||||
* 1) Features:
|
||||
*
|
||||
* - Nestable exceptions (throw new PEAR_Exception($msg, $prev_exception))
|
||||
* - Definable triggers, shot when exceptions occur
|
||||
* - Pretty and informative error messages
|
||||
* - Added more context info available (like class, method or cause)
|
||||
* - cause can be a PEAR_Exception or an array of mixed
|
||||
* PEAR_Exceptions/PEAR_ErrorStack warnings
|
||||
* - callbacks for specific exception classes and their children
|
||||
*
|
||||
* 2) Ideas:
|
||||
*
|
||||
* - Maybe a way to define a 'template' for the output
|
||||
*
|
||||
* 3) Inherited properties from PHP Exception Class:
|
||||
*
|
||||
* protected $message
|
||||
* protected $code
|
||||
* protected $line
|
||||
* protected $file
|
||||
* private $trace
|
||||
*
|
||||
* 4) Inherited methods from PHP Exception Class:
|
||||
*
|
||||
* __clone
|
||||
* __construct
|
||||
* getMessage
|
||||
* getCode
|
||||
* getFile
|
||||
* getLine
|
||||
* getTraceSafe
|
||||
* getTraceSafeAsString
|
||||
* __toString
|
||||
*
|
||||
* 5) Usage example
|
||||
*
|
||||
* <code>
|
||||
* require_once 'PEAR/Exception.php';
|
||||
*
|
||||
* class Test {
|
||||
* function foo() {
|
||||
* throw new PEAR_Exception('Error Message', ERROR_CODE);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* function myLogger($pear_exception) {
|
||||
* echo $pear_exception->getMessage();
|
||||
* }
|
||||
* // each time a exception is thrown the 'myLogger' will be called
|
||||
* // (its use is completely optional)
|
||||
* PEAR_Exception::addObserver('myLogger');
|
||||
* $test = new Test;
|
||||
* try {
|
||||
* $test->foo();
|
||||
* } catch (PEAR_Exception $e) {
|
||||
* print $e;
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Tomas V.V.Cox <cox@idecnet.com>
|
||||
* @author Hans Lellelid <hans@velum.net>
|
||||
* @author Bertrand Mansion <bmansion@mamasam.com>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.3.3
|
||||
*
|
||||
*/
|
||||
class PEAR_Exception extends Exception
|
||||
{
|
||||
const OBSERVER_PRINT = -2;
|
||||
const OBSERVER_TRIGGER = -4;
|
||||
const OBSERVER_DIE = -8;
|
||||
protected $cause;
|
||||
private static $_observers = array();
|
||||
private static $_uniqueid = 0;
|
||||
private $_trace;
|
||||
|
||||
/**
|
||||
* Supported signatures:
|
||||
* - PEAR_Exception(string $message);
|
||||
* - PEAR_Exception(string $message, int $code);
|
||||
* - PEAR_Exception(string $message, Exception $cause);
|
||||
* - PEAR_Exception(string $message, Exception $cause, int $code);
|
||||
* - PEAR_Exception(string $message, PEAR_Error $cause);
|
||||
* - PEAR_Exception(string $message, PEAR_Error $cause, int $code);
|
||||
* - PEAR_Exception(string $message, array $causes);
|
||||
* - PEAR_Exception(string $message, array $causes, int $code);
|
||||
* @param string exception message
|
||||
* @param int|Exception|PEAR_Error|array|null exception cause
|
||||
* @param int|null exception code or null
|
||||
*/
|
||||
public function __construct($message, $p2 = null, $p3 = null)
|
||||
{
|
||||
if (is_int($p2)) {
|
||||
$code = $p2;
|
||||
$this->cause = null;
|
||||
} elseif (is_object($p2) || is_array($p2)) {
|
||||
// using is_object allows both Exception and PEAR_Error
|
||||
if (is_object($p2) && !($p2 instanceof Exception)) {
|
||||
if (!class_exists('PEAR_Error') || !($p2 instanceof PEAR_Error)) {
|
||||
throw new PEAR_Exception('exception cause must be Exception, ' .
|
||||
'array, or PEAR_Error');
|
||||
}
|
||||
}
|
||||
$code = $p3;
|
||||
if (is_array($p2) && isset($p2['message'])) {
|
||||
// fix potential problem of passing in a single warning
|
||||
$p2 = array($p2);
|
||||
}
|
||||
$this->cause = $p2;
|
||||
} else {
|
||||
$code = null;
|
||||
$this->cause = null;
|
||||
}
|
||||
parent::__construct($message, $code);
|
||||
$this->signal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $callback - A valid php callback, see php func is_callable()
|
||||
* - A PEAR_Exception::OBSERVER_* constant
|
||||
* - An array(const PEAR_Exception::OBSERVER_*,
|
||||
* mixed $options)
|
||||
* @param string $label The name of the observer. Use this if you want
|
||||
* to remove it later with removeObserver()
|
||||
*/
|
||||
public static function addObserver($callback, $label = 'default')
|
||||
{
|
||||
self::$_observers[$label] = $callback;
|
||||
}
|
||||
|
||||
public static function removeObserver($label = 'default')
|
||||
{
|
||||
unset(self::$_observers[$label]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int unique identifier for an observer
|
||||
*/
|
||||
public static function getUniqueId()
|
||||
{
|
||||
return self::$_uniqueid++;
|
||||
}
|
||||
|
||||
private function signal()
|
||||
{
|
||||
foreach (self::$_observers as $func) {
|
||||
if (is_callable($func)) {
|
||||
call_user_func($func, $this);
|
||||
continue;
|
||||
}
|
||||
settype($func, 'array');
|
||||
switch ($func[0]) {
|
||||
case self::OBSERVER_PRINT :
|
||||
$f = (isset($func[1])) ? $func[1] : '%s';
|
||||
printf($f, $this->getMessage());
|
||||
break;
|
||||
case self::OBSERVER_TRIGGER :
|
||||
$f = (isset($func[1])) ? $func[1] : E_USER_NOTICE;
|
||||
trigger_error($this->getMessage(), $f);
|
||||
break;
|
||||
case self::OBSERVER_DIE :
|
||||
$f = (isset($func[1])) ? $func[1] : '%s';
|
||||
die(printf($f, $this->getMessage()));
|
||||
break;
|
||||
default:
|
||||
trigger_error('invalid observer type', E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return specific error information that can be used for more detailed
|
||||
* error messages or translation.
|
||||
*
|
||||
* This method may be overridden in child exception classes in order
|
||||
* to add functionality not present in PEAR_Exception and is a placeholder
|
||||
* to define API
|
||||
*
|
||||
* The returned array must be an associative array of parameter => value like so:
|
||||
* <pre>
|
||||
* array('name' => $name, 'context' => array(...))
|
||||
* </pre>
|
||||
* @return array
|
||||
*/
|
||||
public function getErrorData()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exception that caused this exception to be thrown
|
||||
* @access public
|
||||
* @return Exception|array The context of the exception
|
||||
*/
|
||||
public function getCause()
|
||||
{
|
||||
return $this->cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function must be public to call on caused exceptions
|
||||
* @param array
|
||||
*/
|
||||
public function getCauseMessage(&$causes)
|
||||
{
|
||||
$trace = $this->getTraceSafe();
|
||||
$cause = array('class' => get_class($this),
|
||||
'message' => $this->message,
|
||||
'file' => 'unknown',
|
||||
'line' => 'unknown');
|
||||
if (isset($trace[0])) {
|
||||
if (isset($trace[0]['file'])) {
|
||||
$cause['file'] = $trace[0]['file'];
|
||||
$cause['line'] = $trace[0]['line'];
|
||||
}
|
||||
}
|
||||
$causes[] = $cause;
|
||||
if ($this->cause instanceof PEAR_Exception) {
|
||||
$this->cause->getCauseMessage($causes);
|
||||
} elseif ($this->cause instanceof Exception) {
|
||||
$causes[] = array('class' => get_class($this->cause),
|
||||
'message' => $this->cause->getMessage(),
|
||||
'file' => $this->cause->getFile(),
|
||||
'line' => $this->cause->getLine());
|
||||
} elseif (class_exists('PEAR_Error') && $this->cause instanceof PEAR_Error) {
|
||||
$causes[] = array('class' => get_class($this->cause),
|
||||
'message' => $this->cause->getMessage(),
|
||||
'file' => 'unknown',
|
||||
'line' => 'unknown');
|
||||
} elseif (is_array($this->cause)) {
|
||||
foreach ($this->cause as $cause) {
|
||||
if ($cause instanceof PEAR_Exception) {
|
||||
$cause->getCauseMessage($causes);
|
||||
} elseif ($cause instanceof Exception) {
|
||||
$causes[] = array('class' => get_class($cause),
|
||||
'message' => $cause->getMessage(),
|
||||
'file' => $cause->getFile(),
|
||||
'line' => $cause->getLine());
|
||||
} elseif (class_exists('PEAR_Error') && $cause instanceof PEAR_Error) {
|
||||
$causes[] = array('class' => get_class($cause),
|
||||
'message' => $cause->getMessage(),
|
||||
'file' => 'unknown',
|
||||
'line' => 'unknown');
|
||||
} elseif (is_array($cause) && isset($cause['message'])) {
|
||||
// PEAR_ErrorStack warning
|
||||
$causes[] = array(
|
||||
'class' => $cause['package'],
|
||||
'message' => $cause['message'],
|
||||
'file' => isset($cause['context']['file']) ?
|
||||
$cause['context']['file'] :
|
||||
'unknown',
|
||||
'line' => isset($cause['context']['line']) ?
|
||||
$cause['context']['line'] :
|
||||
'unknown',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getTraceSafe()
|
||||
{
|
||||
if (!isset($this->_trace)) {
|
||||
$this->_trace = $this->getTrace();
|
||||
if (empty($this->_trace)) {
|
||||
$backtrace = debug_backtrace();
|
||||
$this->_trace = array($backtrace[count($backtrace)-1]);
|
||||
}
|
||||
}
|
||||
return $this->_trace;
|
||||
}
|
||||
|
||||
public function getErrorClass()
|
||||
{
|
||||
$trace = $this->getTraceSafe();
|
||||
return $trace[0]['class'];
|
||||
}
|
||||
|
||||
public function getErrorMethod()
|
||||
{
|
||||
$trace = $this->getTraceSafe();
|
||||
return $trace[0]['function'];
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
if (isset($_SERVER['REQUEST_URI'])) {
|
||||
return $this->toHtml();
|
||||
}
|
||||
return $this->toText();
|
||||
}
|
||||
|
||||
public function toHtml()
|
||||
{
|
||||
$trace = $this->getTraceSafe();
|
||||
$causes = array();
|
||||
$this->getCauseMessage($causes);
|
||||
$html = '<table border="1" cellspacing="0">' . "\n";
|
||||
foreach ($causes as $i => $cause) {
|
||||
$html .= '<tr><td colspan="3" bgcolor="#ff9999">'
|
||||
. str_repeat('-', $i) . ' <b>' . $cause['class'] . '</b>: '
|
||||
. htmlspecialchars($cause['message']) . ' in <b>' . $cause['file'] . '</b> '
|
||||
. 'on line <b>' . $cause['line'] . '</b>'
|
||||
. "</td></tr>\n";
|
||||
}
|
||||
$html .= '<tr><td colspan="3" bgcolor="#aaaaaa" align="center"><b>Exception trace</b></td></tr>' . "\n"
|
||||
. '<tr><td align="center" bgcolor="#cccccc" width="20"><b>#</b></td>'
|
||||
. '<td align="center" bgcolor="#cccccc"><b>Function</b></td>'
|
||||
. '<td align="center" bgcolor="#cccccc"><b>Location</b></td></tr>' . "\n";
|
||||
|
||||
foreach ($trace as $k => $v) {
|
||||
$html .= '<tr><td align="center">' . $k . '</td>'
|
||||
. '<td>';
|
||||
if (!empty($v['class'])) {
|
||||
$html .= $v['class'] . $v['type'];
|
||||
}
|
||||
$html .= $v['function'];
|
||||
$args = array();
|
||||
if (!empty($v['args'])) {
|
||||
foreach ($v['args'] as $arg) {
|
||||
if (is_null($arg)) $args[] = 'null';
|
||||
elseif (is_array($arg)) $args[] = 'Array';
|
||||
elseif (is_object($arg)) $args[] = 'Object('.get_class($arg).')';
|
||||
elseif (is_bool($arg)) $args[] = $arg ? 'true' : 'false';
|
||||
elseif (is_int($arg) || is_double($arg)) $args[] = $arg;
|
||||
else {
|
||||
$arg = (string)$arg;
|
||||
$str = htmlspecialchars(substr($arg, 0, 16));
|
||||
if (strlen($arg) > 16) $str .= '…';
|
||||
$args[] = "'" . $str . "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
$html .= '(' . implode(', ',$args) . ')'
|
||||
. '</td>'
|
||||
. '<td>' . (isset($v['file']) ? $v['file'] : 'unknown')
|
||||
. ':' . (isset($v['line']) ? $v['line'] : 'unknown')
|
||||
. '</td></tr>' . "\n";
|
||||
}
|
||||
$html .= '<tr><td align="center">' . ($k+1) . '</td>'
|
||||
. '<td>{main}</td>'
|
||||
. '<td> </td></tr>' . "\n"
|
||||
. '</table>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function toText()
|
||||
{
|
||||
$causes = array();
|
||||
$this->getCauseMessage($causes);
|
||||
$causeMsg = '';
|
||||
foreach ($causes as $i => $cause) {
|
||||
$causeMsg .= str_repeat(' ', $i) . $cause['class'] . ': '
|
||||
. $cause['message'] . ' in ' . $cause['file']
|
||||
. ' on line ' . $cause['line'] . "\n";
|
||||
}
|
||||
return $causeMsg . $this->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
7
vendor/library/Excel/phpxls/PEAR/FixPHP5PEARWarnings.php
vendored
Normal file
7
vendor/library/Excel/phpxls/PEAR/FixPHP5PEARWarnings.php
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
if ($skipmsg) {
|
||||
$a = &new $ec($code, $mode, $options, $userinfo);
|
||||
} else {
|
||||
$a = &new $ec($message, $code, $mode, $options, $userinfo);
|
||||
}
|
||||
?>
|
||||
223
vendor/library/Excel/phpxls/PEAR/Frontend.php
vendored
Normal file
223
vendor/library/Excel/phpxls/PEAR/Frontend.php
vendored
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Frontend, the singleton-based frontend for user input/output
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Frontend.php,v 1.13 2008/01/03 20:26:35 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
|
||||
/**
|
||||
* Which user interface class is being used.
|
||||
* @var string class name
|
||||
*/
|
||||
$GLOBALS['_PEAR_FRONTEND_CLASS'] = 'PEAR_Frontend_CLI';
|
||||
|
||||
/**
|
||||
* Instance of $_PEAR_Command_uiclass.
|
||||
* @var object
|
||||
*/
|
||||
$GLOBALS['_PEAR_FRONTEND_SINGLETON'] = null;
|
||||
|
||||
/**
|
||||
* Singleton-based frontend for PEAR user input/output
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a1
|
||||
*/
|
||||
class PEAR_Frontend extends PEAR
|
||||
{
|
||||
/**
|
||||
* Retrieve the frontend object
|
||||
* @return PEAR_Frontend_CLI|PEAR_Frontend_Web|PEAR_Frontend_Gtk
|
||||
* @static
|
||||
*/
|
||||
static function &singleton($type = null)
|
||||
{
|
||||
if ($type === null) {
|
||||
if (!isset($GLOBALS['_PEAR_FRONTEND_SINGLETON'])) {
|
||||
$a = false;
|
||||
return $a;
|
||||
}
|
||||
return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
|
||||
} else {
|
||||
$a = PEAR_Frontend::setFrontendClass($type);
|
||||
return $a;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the frontend class that will be used by calls to {@link singleton()}
|
||||
*
|
||||
* Frontends are expected to conform to the PEAR naming standard of
|
||||
* _ => DIRECTORY_SEPARATOR (PEAR_Frontend_CLI is in PEAR/Frontend/CLI.php)
|
||||
* @param string $uiclass full class name
|
||||
* @return PEAR_Frontend
|
||||
* @static
|
||||
*/
|
||||
static function &setFrontendClass($uiclass)
|
||||
{
|
||||
if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) &&
|
||||
is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], $uiclass)) {
|
||||
return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
|
||||
}
|
||||
if (!class_exists($uiclass)) {
|
||||
$file = str_replace('_', '/', $uiclass) . '.php';
|
||||
if (PEAR_Frontend::isIncludeable($file)) {
|
||||
include_once $file;
|
||||
}
|
||||
}
|
||||
if (class_exists($uiclass)) {
|
||||
$obj = &new $uiclass;
|
||||
// quick test to see if this class implements a few of the most
|
||||
// important frontend methods
|
||||
if (is_a($obj, 'PEAR_Frontend')) {
|
||||
$GLOBALS['_PEAR_FRONTEND_SINGLETON'] = &$obj;
|
||||
$GLOBALS['_PEAR_FRONTEND_CLASS'] = $uiclass;
|
||||
return $obj;
|
||||
} else {
|
||||
$err = PEAR::raiseError("not a frontend class: $uiclass");
|
||||
return $err;
|
||||
}
|
||||
}
|
||||
$err = PEAR::raiseError("no such class: $uiclass");
|
||||
return $err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the frontend class that will be used by calls to {@link singleton()}
|
||||
*
|
||||
* Frontends are expected to be a descendant of PEAR_Frontend
|
||||
* @param PEAR_Frontend
|
||||
* @return PEAR_Frontend
|
||||
* @static
|
||||
*/
|
||||
static function &setFrontendObject($uiobject)
|
||||
{
|
||||
if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) &&
|
||||
is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], get_class($uiobject))) {
|
||||
return $GLOBALS['_PEAR_FRONTEND_SINGLETON'];
|
||||
}
|
||||
if (!is_a($uiobject, 'PEAR_Frontend')) {
|
||||
$err = PEAR::raiseError('not a valid frontend class: (' .
|
||||
get_class($uiobject) . ')');
|
||||
return $err;
|
||||
}
|
||||
$GLOBALS['_PEAR_FRONTEND_SINGLETON'] = &$uiobject;
|
||||
$GLOBALS['_PEAR_FRONTEND_CLASS'] = get_class($uiobject);
|
||||
return $uiobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path relative or absolute include path
|
||||
* @return boolean
|
||||
* @static
|
||||
*/
|
||||
static function isIncludeable($path)
|
||||
{
|
||||
if (file_exists($path) && is_readable($path)) {
|
||||
return true;
|
||||
}
|
||||
$fp = @fopen($path, 'r', true);
|
||||
if ($fp) {
|
||||
fclose($fp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PEAR_Config
|
||||
*/
|
||||
function setConfig(&$config)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This can be overridden to allow session-based temporary file management
|
||||
*
|
||||
* By default, all files are deleted at the end of a session. The web installer
|
||||
* needs to be able to sustain a list over many sessions in order to support
|
||||
* user interaction with install scripts
|
||||
*/
|
||||
function addTempFile($file)
|
||||
{
|
||||
$GLOBALS['_PEAR_Common_tempfiles'][] = $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log an action
|
||||
*
|
||||
* @param string $msg the message to log
|
||||
* @param boolean $append_crlf
|
||||
* @return boolean true
|
||||
* @abstract
|
||||
*/
|
||||
function log($msg, $append_crlf = true)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a post-installation script
|
||||
*
|
||||
* @param array $scripts array of post-install scripts
|
||||
* @abstract
|
||||
*/
|
||||
function runPostinstallScripts(&$scripts)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Display human-friendly output formatted depending on the
|
||||
* $command parameter.
|
||||
*
|
||||
* This should be able to handle basic output data with no command
|
||||
* @param mixed $data data structure containing the information to display
|
||||
* @param string $command command from which this method was called
|
||||
* @abstract
|
||||
*/
|
||||
function outputData($data, $command = '_default')
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a modal form dialog and return the given input
|
||||
*
|
||||
* A frontend that requires multiple requests to retrieve and process
|
||||
* data must take these needs into account, and implement the request
|
||||
* handling code.
|
||||
* @param string $command command from which this method was called
|
||||
* @param array $prompts associative array. keys are the input field names
|
||||
* and values are the description
|
||||
* @param array $types array of input field types (text, password,
|
||||
* etc.) keys have to be the same like in $prompts
|
||||
* @param array $defaults array of default values. again keys have
|
||||
* to be the same like in $prompts. Do not depend
|
||||
* on a default value being set.
|
||||
* @return array input sent by the user
|
||||
* @abstract
|
||||
*/
|
||||
function userDialog($command, $prompts, $types = array(), $defaults = array())
|
||||
{
|
||||
}
|
||||
}
|
||||
?>
|
||||
794
vendor/library/Excel/phpxls/PEAR/Frontend/CLI.php
vendored
Normal file
794
vendor/library/Excel/phpxls/PEAR/Frontend/CLI.php
vendored
Normal file
|
|
@ -0,0 +1,794 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Frontend_CLI
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: CLI.php,v 1.68 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 0.1
|
||||
*/
|
||||
/**
|
||||
* base class
|
||||
*/
|
||||
require_once 'PEAR/Frontend.php';
|
||||
|
||||
/**
|
||||
* Command-line Frontend for the PEAR Installer
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Stig Bakken <ssb@php.net>
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 0.1
|
||||
*/
|
||||
class PEAR_Frontend_CLI extends PEAR_Frontend
|
||||
{
|
||||
// {{{ properties
|
||||
|
||||
/**
|
||||
* What type of user interface this frontend is for.
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $type = 'CLI';
|
||||
var $lp = ''; // line prefix
|
||||
|
||||
var $params = array();
|
||||
var $term = array(
|
||||
'bold' => '',
|
||||
'normal' => '',
|
||||
);
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ constructor
|
||||
|
||||
function PEAR_Frontend_CLI()
|
||||
{
|
||||
parent::PEAR();
|
||||
$term = getenv('TERM'); //(cox) $_ENV is empty for me in 4.1.1
|
||||
if (function_exists('posix_isatty') && !posix_isatty(1)) {
|
||||
// output is being redirected to a file or through a pipe
|
||||
} elseif ($term) {
|
||||
// XXX can use ncurses extension here, if available
|
||||
if (preg_match('/^(xterm|vt220|linux)/', $term)) {
|
||||
$this->term['bold'] = sprintf("%c%c%c%c", 27, 91, 49, 109);
|
||||
$this->term['normal']=sprintf("%c%c%c", 27, 91, 109);
|
||||
} elseif (preg_match('/^vt100/', $term)) {
|
||||
$this->term['bold'] = sprintf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0);
|
||||
$this->term['normal']=sprintf("%c%c%c%c%c", 27, 91, 109, 0, 0);
|
||||
}
|
||||
} elseif (OS_WINDOWS) {
|
||||
// XXX add ANSI codes here
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ displayLine(text)
|
||||
|
||||
function displayLine($text)
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::displayLine deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _displayLine($text)
|
||||
{
|
||||
print "$this->lp$text\n";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ display(text)
|
||||
|
||||
function display($text)
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::display deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _display($text)
|
||||
{
|
||||
print $text;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ displayError(eobj)
|
||||
|
||||
/**
|
||||
* @param object PEAR_Error object
|
||||
*/
|
||||
function displayError($eobj)
|
||||
{
|
||||
return $this->_displayLine($eobj->getMessage());
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ displayFatalError(eobj)
|
||||
|
||||
/**
|
||||
* @param object PEAR_Error object
|
||||
*/
|
||||
function displayFatalError($eobj)
|
||||
{
|
||||
$this->displayError($eobj);
|
||||
if (class_exists('PEAR_Config')) {
|
||||
$config = &PEAR_Config::singleton();
|
||||
if ($config->get('verbose') > 5) {
|
||||
if (function_exists('debug_print_backtrace')) {
|
||||
debug_print_backtrace();
|
||||
} elseif (function_exists('debug_backtrace')) {
|
||||
$trace = debug_backtrace();
|
||||
$raised = false;
|
||||
foreach ($trace as $i => $frame) {
|
||||
if (!$raised) {
|
||||
if (isset($frame['class']) && strtolower($frame['class']) ==
|
||||
'pear' && strtolower($frame['function']) == 'raiseerror') {
|
||||
$raised = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!isset($frame['class'])) {
|
||||
$frame['class'] = '';
|
||||
}
|
||||
if (!isset($frame['type'])) {
|
||||
$frame['type'] = '';
|
||||
}
|
||||
if (!isset($frame['function'])) {
|
||||
$frame['function'] = '';
|
||||
}
|
||||
if (!isset($frame['line'])) {
|
||||
$frame['line'] = '';
|
||||
}
|
||||
$this->_displayLine("#$i: $frame[class]$frame[type]$frame[function] $frame[line]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ displayHeading(title)
|
||||
|
||||
function displayHeading($title)
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::displayHeading deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _displayHeading($title)
|
||||
{
|
||||
print $this->lp.$this->bold($title)."\n";
|
||||
print $this->lp.str_repeat("=", strlen($title))."\n";
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
/**
|
||||
* Instruct the runInstallScript method to skip a paramgroup that matches the
|
||||
* id value passed in.
|
||||
*
|
||||
* This method is useful for dynamically configuring which sections of a post-install script
|
||||
* will be run based on the user's setup, which is very useful for making flexible
|
||||
* post-install scripts without losing the cross-Frontend ability to retrieve user input
|
||||
* @param string
|
||||
*/
|
||||
function skipParamgroup($id)
|
||||
{
|
||||
$this->_skipSections[$id] = true;
|
||||
}
|
||||
|
||||
function runPostinstallScripts(&$scripts)
|
||||
{
|
||||
foreach ($scripts as $i => $script) {
|
||||
$this->runInstallScript($scripts[$i]->_params, $scripts[$i]->_obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $xml contents of postinstallscript tag
|
||||
* @param object $script post-installation script
|
||||
* @param string install|upgrade
|
||||
*/
|
||||
function runInstallScript($xml, &$script)
|
||||
{
|
||||
$this->_skipSections = array();
|
||||
if (!is_array($xml) || !isset($xml['paramgroup'])) {
|
||||
$script->run(array(), '_default');
|
||||
} else {
|
||||
$completedPhases = array();
|
||||
if (!isset($xml['paramgroup'][0])) {
|
||||
$xml['paramgroup'] = array($xml['paramgroup']);
|
||||
}
|
||||
foreach ($xml['paramgroup'] as $group) {
|
||||
if (isset($this->_skipSections[$group['id']])) {
|
||||
// the post-install script chose to skip this section dynamically
|
||||
continue;
|
||||
}
|
||||
if (isset($group['name'])) {
|
||||
$paramname = explode('::', $group['name']);
|
||||
if ($lastgroup['id'] != $paramname[0]) {
|
||||
continue;
|
||||
}
|
||||
$group['name'] = $paramname[1];
|
||||
if (isset($answers)) {
|
||||
if (isset($answers[$group['name']])) {
|
||||
switch ($group['conditiontype']) {
|
||||
case '=' :
|
||||
if ($answers[$group['name']] != $group['value']) {
|
||||
continue 2;
|
||||
}
|
||||
break;
|
||||
case '!=' :
|
||||
if ($answers[$group['name']] == $group['value']) {
|
||||
continue 2;
|
||||
}
|
||||
break;
|
||||
case 'preg_match' :
|
||||
if (!@preg_match('/' . $group['value'] . '/',
|
||||
$answers[$group['name']])) {
|
||||
continue 2;
|
||||
}
|
||||
break;
|
||||
default :
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$lastgroup = $group;
|
||||
if (isset($group['instructions'])) {
|
||||
$this->_display($group['instructions']);
|
||||
}
|
||||
if (!isset($group['param'][0])) {
|
||||
$group['param'] = array($group['param']);
|
||||
}
|
||||
if (isset($group['param'])) {
|
||||
if (method_exists($script, 'postProcessPrompts')) {
|
||||
$prompts = $script->postProcessPrompts($group['param'], $group['id']);
|
||||
if (!is_array($prompts) || count($prompts) != count($group['param'])) {
|
||||
$this->outputData('postinstall', 'Error: post-install script did not ' .
|
||||
'return proper post-processed prompts');
|
||||
$prompts = $group['param'];
|
||||
} else {
|
||||
foreach ($prompts as $i => $var) {
|
||||
if (!is_array($var) || !isset($var['prompt']) ||
|
||||
!isset($var['name']) ||
|
||||
($var['name'] != $group['param'][$i]['name']) ||
|
||||
($var['type'] != $group['param'][$i]['type'])) {
|
||||
$this->outputData('postinstall', 'Error: post-install script ' .
|
||||
'modified the variables or prompts, severe security risk. ' .
|
||||
'Will instead use the defaults from the package.xml');
|
||||
$prompts = $group['param'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$answers = $this->confirmDialog($prompts);
|
||||
} else {
|
||||
$answers = $this->confirmDialog($group['param']);
|
||||
}
|
||||
}
|
||||
if ((isset($answers) && $answers) || !isset($group['param'])) {
|
||||
if (!isset($answers)) {
|
||||
$answers = array();
|
||||
}
|
||||
array_unshift($completedPhases, $group['id']);
|
||||
if (!$script->run($answers, $group['id'])) {
|
||||
$script->run($completedPhases, '_undoOnError');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$script->run($completedPhases, '_undoOnError');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask for user input, confirm the answers and continue until the user is satisfied
|
||||
* @param array an array of arrays, format array('name' => 'paramname', 'prompt' =>
|
||||
* 'text to display', 'type' => 'string'[, default => 'default value'])
|
||||
* @return array
|
||||
*/
|
||||
function confirmDialog($params)
|
||||
{
|
||||
$answers = array();
|
||||
$prompts = $types = array();
|
||||
foreach ($params as $param) {
|
||||
$prompts[$param['name']] = $param['prompt'];
|
||||
$types[$param['name']] = $param['type'];
|
||||
if (isset($param['default'])) {
|
||||
$answers[$param['name']] = $param['default'];
|
||||
} else {
|
||||
$answers[$param['name']] = '';
|
||||
}
|
||||
}
|
||||
$tried = false;
|
||||
do {
|
||||
if ($tried) {
|
||||
$i = 1;
|
||||
foreach ($answers as $var => $value) {
|
||||
if (!strlen($value)) {
|
||||
echo $this->bold("* Enter an answer for #" . $i . ": ({$prompts[$var]})\n");
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$answers = $this->userDialog('', $prompts, $types, $answers);
|
||||
$tried = true;
|
||||
} while (is_array($answers) && count(array_filter($answers)) != count($prompts));
|
||||
return $answers;
|
||||
}
|
||||
// {{{ userDialog(prompt, [type], [default])
|
||||
|
||||
function userDialog($command, $prompts, $types = array(), $defaults = array(),
|
||||
$screensize = 20)
|
||||
{
|
||||
if (!is_array($prompts)) {
|
||||
return array();
|
||||
}
|
||||
$testprompts = array_keys($prompts);
|
||||
$result = $defaults;
|
||||
if (!defined('STDIN')) {
|
||||
$fp = fopen('php://stdin', 'r');
|
||||
} else {
|
||||
$fp = STDIN;
|
||||
}
|
||||
reset($prompts);
|
||||
if (count($prompts) == 1 && $types[key($prompts)] == 'yesno') {
|
||||
foreach ($prompts as $key => $prompt) {
|
||||
$type = $types[$key];
|
||||
$default = @$defaults[$key];
|
||||
print "$prompt ";
|
||||
if ($default) {
|
||||
print "[$default] ";
|
||||
}
|
||||
print ": ";
|
||||
if (version_compare(phpversion(), '5.0.0', '<')) {
|
||||
$line = fgets($fp, 2048);
|
||||
} else {
|
||||
if (!defined('STDIN')) {
|
||||
define('STDIN', fopen('php://stdin', 'r'));
|
||||
}
|
||||
$line = fgets(STDIN, 2048);
|
||||
}
|
||||
if ($default && trim($line) == "") {
|
||||
$result[$key] = $default;
|
||||
} else {
|
||||
$result[$key] = trim($line);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
while (true) {
|
||||
$descLength = max(array_map('strlen', $prompts));
|
||||
$descFormat = "%-{$descLength}s";
|
||||
$last = count($prompts);
|
||||
|
||||
$i = 0;
|
||||
foreach ($prompts as $n => $var) {
|
||||
printf("%2d. $descFormat : %s\n", ++$i, $prompts[$n], isset($result[$n]) ?
|
||||
$result[$n] : null);
|
||||
}
|
||||
|
||||
print "\n1-$last, 'all', 'abort', or Enter to continue: ";
|
||||
$tmp = trim(fgets($fp, 1024));
|
||||
if (empty($tmp)) {
|
||||
break;
|
||||
}
|
||||
if ($tmp == 'abort') {
|
||||
return false;
|
||||
}
|
||||
if (isset($testprompts[(int)$tmp - 1])) {
|
||||
$var = $testprompts[(int)$tmp - 1];
|
||||
$desc = $prompts[$var];
|
||||
$current = @$result[$var];
|
||||
print "$desc [$current] : ";
|
||||
$tmp = trim(fgets($fp, 1024));
|
||||
if (trim($tmp) !== '') {
|
||||
$result[$var] = trim($tmp);
|
||||
}
|
||||
} elseif ($tmp == 'all') {
|
||||
foreach ($prompts as $var => $desc) {
|
||||
$current = $result[$var];
|
||||
print "$desc [$current] : ";
|
||||
$tmp = trim(fgets($fp, 1024));
|
||||
if (trim($tmp) !== '') {
|
||||
$result[$var] = trim($tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!defined('STDIN')) {
|
||||
fclose($fp);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ userConfirm(prompt, [default])
|
||||
|
||||
function userConfirm($prompt, $default = 'yes')
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::userConfirm not yet converted", E_USER_ERROR);
|
||||
static $positives = array('y', 'yes', 'on', '1');
|
||||
static $negatives = array('n', 'no', 'off', '0');
|
||||
print "$this->lp$prompt [$default] : ";
|
||||
$fp = fopen("php://stdin", "r");
|
||||
$line = fgets($fp, 2048);
|
||||
fclose($fp);
|
||||
$answer = strtolower(trim($line));
|
||||
if (empty($answer)) {
|
||||
$answer = $default;
|
||||
}
|
||||
if (in_array($answer, $positives)) {
|
||||
return true;
|
||||
}
|
||||
if (in_array($answer, $negatives)) {
|
||||
return false;
|
||||
}
|
||||
if (in_array($default, $positives)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ startTable([params])
|
||||
|
||||
function startTable($params = array())
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::startTable deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _startTable($params = array())
|
||||
{
|
||||
$params['table_data'] = array();
|
||||
$params['widest'] = array(); // indexed by column
|
||||
$params['highest'] = array(); // indexed by row
|
||||
$params['ncols'] = 0;
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ tableRow(columns, [rowparams], [colparams])
|
||||
|
||||
function tableRow($columns, $rowparams = array(), $colparams = array())
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::tableRow deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _tableRow($columns, $rowparams = array(), $colparams = array())
|
||||
{
|
||||
$highest = 1;
|
||||
for ($i = 0; $i < sizeof($columns); $i++) {
|
||||
$col = &$columns[$i];
|
||||
if (isset($colparams[$i]) && !empty($colparams[$i]['wrap'])) {
|
||||
$col = wordwrap($col, $colparams[$i]['wrap'], "\n", 0);
|
||||
}
|
||||
if (strpos($col, "\n") !== false) {
|
||||
$multiline = explode("\n", $col);
|
||||
$w = 0;
|
||||
foreach ($multiline as $n => $line) {
|
||||
if (strlen($line) > $w) {
|
||||
$w = strlen($line);
|
||||
}
|
||||
}
|
||||
$lines = sizeof($multiline);
|
||||
} else {
|
||||
$w = strlen($col);
|
||||
}
|
||||
|
||||
if (isset($this->params['widest'][$i])) {
|
||||
if ($w > $this->params['widest'][$i]) {
|
||||
$this->params['widest'][$i] = $w;
|
||||
}
|
||||
} else {
|
||||
$this->params['widest'][$i] = $w;
|
||||
}
|
||||
$tmp = count_chars($columns[$i], 1);
|
||||
// handle unix, mac and windows formats
|
||||
$lines = (isset($tmp[10]) ? $tmp[10] : (isset($tmp[13]) ? $tmp[13] : 0)) + 1;
|
||||
if ($lines > $highest) {
|
||||
$highest = $lines;
|
||||
}
|
||||
}
|
||||
if (sizeof($columns) > $this->params['ncols']) {
|
||||
$this->params['ncols'] = sizeof($columns);
|
||||
}
|
||||
$new_row = array(
|
||||
'data' => $columns,
|
||||
'height' => $highest,
|
||||
'rowparams' => $rowparams,
|
||||
'colparams' => $colparams,
|
||||
);
|
||||
$this->params['table_data'][] = $new_row;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ endTable()
|
||||
|
||||
function endTable()
|
||||
{
|
||||
trigger_error("PEAR_Frontend_CLI::endTable deprecated", E_USER_ERROR);
|
||||
}
|
||||
|
||||
function _endTable()
|
||||
{
|
||||
extract($this->params);
|
||||
if (!empty($caption)) {
|
||||
$this->_displayHeading($caption);
|
||||
}
|
||||
if (count($table_data) == 0) {
|
||||
return;
|
||||
}
|
||||
if (!isset($width)) {
|
||||
$width = $widest;
|
||||
} else {
|
||||
for ($i = 0; $i < $ncols; $i++) {
|
||||
if (!isset($width[$i])) {
|
||||
$width[$i] = $widest[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
$border = false;
|
||||
if (empty($border)) {
|
||||
$cellstart = '';
|
||||
$cellend = ' ';
|
||||
$rowend = '';
|
||||
$padrowend = false;
|
||||
$borderline = '';
|
||||
} else {
|
||||
$cellstart = '| ';
|
||||
$cellend = ' ';
|
||||
$rowend = '|';
|
||||
$padrowend = true;
|
||||
$borderline = '+';
|
||||
foreach ($width as $w) {
|
||||
$borderline .= str_repeat('-', $w + strlen($cellstart) + strlen($cellend) - 1);
|
||||
$borderline .= '+';
|
||||
}
|
||||
}
|
||||
if ($borderline) {
|
||||
$this->_displayLine($borderline);
|
||||
}
|
||||
for ($i = 0; $i < sizeof($table_data); $i++) {
|
||||
extract($table_data[$i]);
|
||||
if (!is_array($rowparams)) {
|
||||
$rowparams = array();
|
||||
}
|
||||
if (!is_array($colparams)) {
|
||||
$colparams = array();
|
||||
}
|
||||
$rowlines = array();
|
||||
if ($height > 1) {
|
||||
for ($c = 0; $c < sizeof($data); $c++) {
|
||||
$rowlines[$c] = preg_split('/(\r?\n|\r)/', $data[$c]);
|
||||
if (sizeof($rowlines[$c]) < $height) {
|
||||
$rowlines[$c] = array_pad($rowlines[$c], $height, '');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ($c = 0; $c < sizeof($data); $c++) {
|
||||
$rowlines[$c] = array($data[$c]);
|
||||
}
|
||||
}
|
||||
for ($r = 0; $r < $height; $r++) {
|
||||
$rowtext = '';
|
||||
for ($c = 0; $c < sizeof($data); $c++) {
|
||||
if (isset($colparams[$c])) {
|
||||
$attribs = array_merge($rowparams, $colparams);
|
||||
} else {
|
||||
$attribs = $rowparams;
|
||||
}
|
||||
$w = isset($width[$c]) ? $width[$c] : 0;
|
||||
//$cell = $data[$c];
|
||||
$cell = $rowlines[$c][$r];
|
||||
$l = strlen($cell);
|
||||
if ($l > $w) {
|
||||
$cell = substr($cell, 0, $w);
|
||||
}
|
||||
if (isset($attribs['bold'])) {
|
||||
$cell = $this->bold($cell);
|
||||
}
|
||||
if ($l < $w) {
|
||||
// not using str_pad here because we may
|
||||
// add bold escape characters to $cell
|
||||
$cell .= str_repeat(' ', $w - $l);
|
||||
}
|
||||
|
||||
$rowtext .= $cellstart . $cell . $cellend;
|
||||
}
|
||||
if (!$border) {
|
||||
$rowtext = rtrim($rowtext);
|
||||
}
|
||||
$rowtext .= $rowend;
|
||||
$this->_displayLine($rowtext);
|
||||
}
|
||||
}
|
||||
if ($borderline) {
|
||||
$this->_displayLine($borderline);
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ outputData()
|
||||
|
||||
function outputData($data, $command = '_default')
|
||||
{
|
||||
switch ($command) {
|
||||
case 'channel-info':
|
||||
foreach ($data as $type => $section) {
|
||||
if ($type == 'main') {
|
||||
$section['data'] = array_values($section['data']);
|
||||
}
|
||||
$this->outputData($section);
|
||||
}
|
||||
break;
|
||||
case 'install':
|
||||
case 'upgrade':
|
||||
case 'upgrade-all':
|
||||
if (isset($data['release_warnings'])) {
|
||||
$this->_displayLine('');
|
||||
$this->_startTable(array(
|
||||
'border' => false,
|
||||
'caption' => 'Release Warnings'
|
||||
));
|
||||
$this->_tableRow(array($data['release_warnings']), null, array(1 => array('wrap' => 55)));
|
||||
$this->_endTable();
|
||||
$this->_displayLine('');
|
||||
}
|
||||
$this->_displayLine($data['data']);
|
||||
break;
|
||||
case 'search':
|
||||
$this->_startTable($data);
|
||||
if (isset($data['headline']) && is_array($data['headline'])) {
|
||||
$this->_tableRow($data['headline'], array('bold' => true), array(1 => array('wrap' => 55)));
|
||||
}
|
||||
|
||||
foreach($data['data'] as $category) {
|
||||
foreach($category as $pkg) {
|
||||
$this->_tableRow($pkg, null, array(1 => array('wrap' => 55)));
|
||||
}
|
||||
};
|
||||
$this->_endTable();
|
||||
break;
|
||||
case 'list-all':
|
||||
if (!isset($data['data'])) {
|
||||
$this->_displayLine('No packages in channel');
|
||||
break;
|
||||
}
|
||||
$this->_startTable($data);
|
||||
if (isset($data['headline']) && is_array($data['headline'])) {
|
||||
$this->_tableRow($data['headline'], array('bold' => true), array(1 => array('wrap' => 55)));
|
||||
}
|
||||
|
||||
foreach($data['data'] as $category) {
|
||||
foreach($category as $pkg) {
|
||||
unset($pkg[4]);
|
||||
unset($pkg[5]);
|
||||
$this->_tableRow($pkg, null, array(1 => array('wrap' => 55)));
|
||||
}
|
||||
};
|
||||
$this->_endTable();
|
||||
break;
|
||||
case 'config-show':
|
||||
$data['border'] = false;
|
||||
$opts = array(0 => array('wrap' => 30),
|
||||
1 => array('wrap' => 20),
|
||||
2 => array('wrap' => 35));
|
||||
$this->_startTable($data);
|
||||
if (isset($data['headline']) && is_array($data['headline'])) {
|
||||
$this->_tableRow($data['headline'],
|
||||
array('bold' => true),
|
||||
$opts);
|
||||
}
|
||||
foreach($data['data'] as $group) {
|
||||
foreach($group as $value) {
|
||||
if ($value[2] == '') {
|
||||
$value[2] = "<not set>";
|
||||
}
|
||||
$this->_tableRow($value, null, $opts);
|
||||
}
|
||||
}
|
||||
$this->_endTable();
|
||||
break;
|
||||
case 'remote-info':
|
||||
$d = $data;
|
||||
$data = array(
|
||||
'caption' => 'Package details:',
|
||||
'border' => false,
|
||||
'data' => array(
|
||||
array("Latest", $data['stable']),
|
||||
array("Installed", $data['installed']),
|
||||
array("Package", $data['name']),
|
||||
array("License", $data['license']),
|
||||
array("Category", $data['category']),
|
||||
array("Summary", $data['summary']),
|
||||
array("Description", $data['description']),
|
||||
),
|
||||
);
|
||||
if (isset($d['deprecated']) && $d['deprecated']) {
|
||||
$conf = &PEAR_Config::singleton();
|
||||
$reg = $conf->getRegistry();
|
||||
$name = $reg->parsedPackageNameToString($d['deprecated'], true);
|
||||
$data['data'][] = array('Deprecated! use', $name);
|
||||
}
|
||||
default: {
|
||||
if (is_array($data)) {
|
||||
$this->_startTable($data);
|
||||
$count = count($data['data'][0]);
|
||||
if ($count == 2) {
|
||||
$opts = array(0 => array('wrap' => 25),
|
||||
1 => array('wrap' => 48)
|
||||
);
|
||||
} elseif ($count == 3) {
|
||||
$opts = array(0 => array('wrap' => 30),
|
||||
1 => array('wrap' => 20),
|
||||
2 => array('wrap' => 35)
|
||||
);
|
||||
} else {
|
||||
$opts = null;
|
||||
}
|
||||
if (isset($data['headline']) && is_array($data['headline'])) {
|
||||
$this->_tableRow($data['headline'],
|
||||
array('bold' => true),
|
||||
$opts);
|
||||
}
|
||||
foreach($data['data'] as $row) {
|
||||
$this->_tableRow($row, null, $opts);
|
||||
}
|
||||
$this->_endTable();
|
||||
} else {
|
||||
$this->_displayLine($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ log(text)
|
||||
|
||||
|
||||
function log($text, $append_crlf = true)
|
||||
{
|
||||
if ($append_crlf) {
|
||||
return $this->_displayLine($text);
|
||||
}
|
||||
return $this->_display($text);
|
||||
}
|
||||
|
||||
|
||||
// }}}
|
||||
// {{{ bold($text)
|
||||
|
||||
function bold($text)
|
||||
{
|
||||
if (empty($this->term['bold'])) {
|
||||
return strtoupper($text);
|
||||
}
|
||||
return $this->term['bold'] . $text . $this->term['normal'];
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
1723
vendor/library/Excel/phpxls/PEAR/Installer.php
vendored
Normal file
1723
vendor/library/Excel/phpxls/PEAR/Installer.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
253
vendor/library/Excel/phpxls/PEAR/Installer/Role.php
vendored
Normal file
253
vendor/library/Excel/phpxls/PEAR/Installer/Role.php
vendored
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Installer_Role
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Role.php,v 1.20 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
|
||||
/**
|
||||
* base class for installer roles
|
||||
*/
|
||||
require_once 'PEAR/Installer/Role/Common.php';
|
||||
require_once 'PEAR/XMLParser.php';
|
||||
/**
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a1
|
||||
*/
|
||||
class PEAR_Installer_Role
|
||||
{
|
||||
/**
|
||||
* Set up any additional configuration variables that file roles require
|
||||
*
|
||||
* Never call this directly, it is called by the PEAR_Config constructor
|
||||
* @param PEAR_Config
|
||||
* @access private
|
||||
* @static
|
||||
*/
|
||||
static function initializeConfig(&$config)
|
||||
{
|
||||
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
|
||||
PEAR_Installer_Role::registerRoles();
|
||||
}
|
||||
foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $class => $info) {
|
||||
if (!$info['config_vars']) {
|
||||
continue;
|
||||
}
|
||||
$config->_addConfigVars($class, $info['config_vars']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PEAR_PackageFile_v2
|
||||
* @param string role name
|
||||
* @param PEAR_Config
|
||||
* @return PEAR_Installer_Role_Common
|
||||
* @static
|
||||
*/
|
||||
static function &factory($pkg, $role, &$config)
|
||||
{
|
||||
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
|
||||
PEAR_Installer_Role::registerRoles();
|
||||
}
|
||||
if (!in_array($role, PEAR_Installer_Role::getValidRoles($pkg->getPackageType()))) {
|
||||
$a = false;
|
||||
return $a;
|
||||
}
|
||||
$a = 'PEAR_Installer_Role_' . ucfirst($role);
|
||||
if (!class_exists($a)) {
|
||||
require_once str_replace('_', '/', $a) . '.php';
|
||||
}
|
||||
$b = new $a($config);
|
||||
return $b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of file roles that are valid for the particular release type.
|
||||
*
|
||||
* For instance, src files serve no purpose in regular php releases.
|
||||
* @param string
|
||||
* @param bool clear cache
|
||||
* @return array
|
||||
* @static
|
||||
*/
|
||||
static function getValidRoles($release, $clear = false)
|
||||
{
|
||||
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
|
||||
PEAR_Installer_Role::registerRoles();
|
||||
}
|
||||
static $ret = array();
|
||||
if ($clear) {
|
||||
$ret = array();
|
||||
}
|
||||
if (isset($ret[$release])) {
|
||||
return $ret[$release];
|
||||
}
|
||||
$ret[$release] = array();
|
||||
foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
|
||||
if (in_array($release, $okreleases['releasetypes'])) {
|
||||
$ret[$release][] = strtolower(str_replace('PEAR_Installer_Role_', '', $role));
|
||||
}
|
||||
}
|
||||
return $ret[$release];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of roles that require their files to be installed
|
||||
*
|
||||
* Most roles must be installed, but src and package roles, for instance
|
||||
* are pseudo-roles. src files are compiled into a new extension. Package
|
||||
* roles are actually fully bundled releases of a package
|
||||
* @param bool clear cache
|
||||
* @return array
|
||||
* @static
|
||||
*/
|
||||
static function getInstallableRoles($clear = false)
|
||||
{
|
||||
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
|
||||
PEAR_Installer_Role::registerRoles();
|
||||
}
|
||||
static $ret;
|
||||
if ($clear) {
|
||||
unset($ret);
|
||||
}
|
||||
if (!isset($ret)) {
|
||||
$ret = array();
|
||||
foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
|
||||
if ($okreleases['installable']) {
|
||||
$ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of roles that are affected by the baseinstalldir attribute
|
||||
*
|
||||
* Most roles ignore this attribute, and instead install directly into:
|
||||
* PackageName/filepath
|
||||
* so a tests file tests/file.phpt is installed into PackageName/tests/filepath.php
|
||||
* @param bool clear cache
|
||||
* @return array
|
||||
* @static
|
||||
*/
|
||||
static function getBaseinstallRoles($clear = false)
|
||||
{
|
||||
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
|
||||
PEAR_Installer_Role::registerRoles();
|
||||
}
|
||||
static $ret;
|
||||
if ($clear) {
|
||||
unset($ret);
|
||||
}
|
||||
if (!isset($ret)) {
|
||||
$ret = array();
|
||||
foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
|
||||
if ($okreleases['honorsbaseinstall']) {
|
||||
$ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of file roles that should be analyzed for PHP content at package time,
|
||||
* like the "php" role.
|
||||
* @param bool clear cache
|
||||
* @return array
|
||||
* @static
|
||||
*/
|
||||
static function getPhpRoles($clear = false)
|
||||
{
|
||||
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
|
||||
PEAR_Installer_Role::registerRoles();
|
||||
}
|
||||
static $ret;
|
||||
if ($clear) {
|
||||
unset($ret);
|
||||
}
|
||||
if (!isset($ret)) {
|
||||
$ret = array();
|
||||
foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
|
||||
if ($okreleases['phpfile']) {
|
||||
$ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan through the Command directory looking for classes
|
||||
* and see what commands they implement.
|
||||
* @param string which directory to look for classes, defaults to
|
||||
* the Installer/Roles subdirectory of
|
||||
* the directory from where this file (__FILE__) is
|
||||
* included.
|
||||
*
|
||||
* @return bool TRUE on success, a PEAR error on failure
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
static function registerRoles($dir = null)
|
||||
{
|
||||
$GLOBALS['_PEAR_INSTALLER_ROLES'] = array();
|
||||
$parser = new PEAR_XMLParser;
|
||||
if ($dir === null) {
|
||||
$dir = dirname(__FILE__) . '/Role';
|
||||
}
|
||||
if (!file_exists($dir) || !is_dir($dir)) {
|
||||
return PEAR::raiseError("registerRoles: opendir($dir) failed: does not exist/is not directory");
|
||||
}
|
||||
$dp = @opendir($dir);
|
||||
if (empty($dp)) {
|
||||
return PEAR::raiseError("registerRoles: opendir($dir) failed: $php_errmsg");
|
||||
}
|
||||
while ($entry = readdir($dp)) {
|
||||
if ($entry{0} == '.' || substr($entry, -4) != '.xml') {
|
||||
continue;
|
||||
}
|
||||
$class = "PEAR_Installer_Role_".substr($entry, 0, -4);
|
||||
// List of roles
|
||||
if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'][$class])) {
|
||||
$file = "$dir/$entry";
|
||||
$parser->parse(file_get_contents($file));
|
||||
$data = $parser->getData();
|
||||
if (!is_array($data['releasetypes'])) {
|
||||
$data['releasetypes'] = array($data['releasetypes']);
|
||||
}
|
||||
$GLOBALS['_PEAR_INSTALLER_ROLES'][$class] = $data;
|
||||
}
|
||||
}
|
||||
closedir($dp);
|
||||
ksort($GLOBALS['_PEAR_INSTALLER_ROLES']);
|
||||
PEAR_Installer_Role::getBaseinstallRoles(true);
|
||||
PEAR_Installer_Role::getInstallableRoles(true);
|
||||
PEAR_Installer_Role::getPhpRoles(true);
|
||||
PEAR_Installer_Role::getValidRoles('****', true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
108
vendor/library/Excel/phpxls/PEAR/Installer/Role/Cfg.php
vendored
Normal file
108
vendor/library/Excel/phpxls/PEAR/Installer/Role/Cfg.php
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Installer_Role_Cfg
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 2007-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Cfg.php,v 1.8 2008/05/14 21:26:30 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.7.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 2007-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.7.0
|
||||
*/
|
||||
class PEAR_Installer_Role_Cfg extends PEAR_Installer_Role_Common
|
||||
{
|
||||
/**
|
||||
* @var PEAR_Installer
|
||||
*/
|
||||
var $installer;
|
||||
/**
|
||||
* the md5 of the original file
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
var $md5 = null;
|
||||
/**
|
||||
* Do any unusual setup here
|
||||
* @param PEAR_Installer
|
||||
* @param PEAR_PackageFile_v2
|
||||
* @param array file attributes
|
||||
* @param string file name
|
||||
*/
|
||||
function setup(&$installer, $pkg, $atts, $file)
|
||||
{
|
||||
$this->installer = &$installer;
|
||||
$reg = &$this->installer->config->getRegistry();
|
||||
$package = $reg->getPackage($pkg->getPackage(), $pkg->getChannel());
|
||||
if ($package) {
|
||||
$filelist = $package->getFilelist();
|
||||
if (isset($filelist[$file]) && isset($filelist[$file]['md5sum'])) {
|
||||
$this->md5 = $filelist[$file]['md5sum'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null)
|
||||
{
|
||||
$test = parent::processInstallation($pkg, $atts, $file, $tmp_path, $layer);
|
||||
if (@file_exists($test[2]) && @file_exists($test[3])) {
|
||||
$md5 = md5_file($test[2]);
|
||||
// configuration has already been installed, check for mods
|
||||
if ($md5 !== $this->md5 && $md5 !== md5_file($test[3])) {
|
||||
// configuration has been modified, so save our version as
|
||||
// configfile-version
|
||||
$old = $test[2];
|
||||
$test[2] .= '.new-' . $pkg->getVersion();
|
||||
// backup original and re-install it
|
||||
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
|
||||
$tmpcfg = $this->config->get('temp_dir');
|
||||
$newloc = System::mkdir(array('-p', $tmpcfg));
|
||||
if (!$newloc) {
|
||||
// try temp_dir
|
||||
$newloc = System::mktemp(array('-d'));
|
||||
if (!$newloc || PEAR::isError($newloc)) {
|
||||
PEAR::popErrorHandling();
|
||||
return PEAR::raiseError('Could not save existing configuration file '.
|
||||
$old . ', unable to install. Please set temp_dir ' .
|
||||
'configuration variable to a writeable location and try again');
|
||||
}
|
||||
} else {
|
||||
$newloc = $tmpcfg;
|
||||
}
|
||||
$temp_file = $newloc . DIRECTORY_SEPARATOR . uniqid('savefile');
|
||||
if (!@copy($old, $temp_file)) {
|
||||
PEAR::popErrorHandling();
|
||||
return PEAR::raiseError('Could not save existing configuration file '.
|
||||
$old . ', unable to install. Please set temp_dir ' .
|
||||
'configuration variable to a writeable location and try again');
|
||||
}
|
||||
PEAR::popErrorHandling();
|
||||
$this->installer->log(0, "WARNING: configuration file $old is being installed as $test[2], you should manually merge in changes to the existing configuration file");
|
||||
$this->installer->addFileOperation('rename', array($temp_file, $old, false));
|
||||
$this->installer->addFileOperation('delete', array($temp_file));
|
||||
}
|
||||
}
|
||||
return $test;
|
||||
}
|
||||
}
|
||||
?>
|
||||
15
vendor/library/Excel/phpxls/PEAR/Installer/Role/Cfg.xml
vendored
Normal file
15
vendor/library/Excel/phpxls/PEAR/Installer/Role/Cfg.xml
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<role version="1.0">
|
||||
<releasetypes>php</releasetypes>
|
||||
<releasetypes>extsrc</releasetypes>
|
||||
<releasetypes>extbin</releasetypes>
|
||||
<releasetypes>zendextsrc</releasetypes>
|
||||
<releasetypes>zendextbin</releasetypes>
|
||||
<installable>1</installable>
|
||||
<locationconfig>cfg_dir</locationconfig>
|
||||
<honorsbaseinstall />
|
||||
<unusualbaseinstall>1</unusualbaseinstall>
|
||||
<phpfile />
|
||||
<executable />
|
||||
<phpextension />
|
||||
<config_vars />
|
||||
</role>
|
||||
180
vendor/library/Excel/phpxls/PEAR/Installer/Role/Common.php
vendored
Normal file
180
vendor/library/Excel/phpxls/PEAR/Installer/Role/Common.php
vendored
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
/**
|
||||
* Base class for all installation roles.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2006 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Common.php,v 1.12 2006/10/19 23:55:32 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
/**
|
||||
* Base class for all installation roles.
|
||||
*
|
||||
* This class allows extensibility of file roles. Packages with complex
|
||||
* customization can now provide custom file roles along with the possibility of
|
||||
* adding configuration values to match.
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2006 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a1
|
||||
*/
|
||||
class PEAR_Installer_Role_Common
|
||||
{
|
||||
/**
|
||||
* @var PEAR_Config
|
||||
* @access protected
|
||||
*/
|
||||
var $config;
|
||||
|
||||
/**
|
||||
* @param PEAR_Config
|
||||
*/
|
||||
function PEAR_Installer_Role_Common(&$config)
|
||||
{
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve configuration information about a file role from its XML info
|
||||
*
|
||||
* @param string $role Role Classname, as in "PEAR_Installer_Role_Data"
|
||||
* @return array
|
||||
*/
|
||||
function getInfo($role)
|
||||
{
|
||||
if (empty($GLOBALS['_PEAR_INSTALLER_ROLES'][$role])) {
|
||||
return PEAR::raiseError('Unknown Role class: "' . $role . '"');
|
||||
}
|
||||
return $GLOBALS['_PEAR_INSTALLER_ROLES'][$role];
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called for each file to set up the directories and files
|
||||
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
|
||||
* @param array attributes from the <file> tag
|
||||
* @param string file name
|
||||
* @return array an array consisting of:
|
||||
*
|
||||
* 1 the original, pre-baseinstalldir installation directory
|
||||
* 2 the final installation directory
|
||||
* 3 the full path to the final location of the file
|
||||
* 4 the location of the pre-installation file
|
||||
*/
|
||||
function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null)
|
||||
{
|
||||
$roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' .
|
||||
ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this)))));
|
||||
if (PEAR::isError($roleInfo)) {
|
||||
return $roleInfo;
|
||||
}
|
||||
if (!$roleInfo['locationconfig']) {
|
||||
return false;
|
||||
}
|
||||
if ($roleInfo['honorsbaseinstall']) {
|
||||
$dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'], $layer,
|
||||
$pkg->getChannel());
|
||||
if (!empty($atts['baseinstalldir'])) {
|
||||
$dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
|
||||
}
|
||||
} elseif ($roleInfo['unusualbaseinstall']) {
|
||||
$dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'],
|
||||
$layer, $pkg->getChannel()) . DIRECTORY_SEPARATOR . $pkg->getPackage();
|
||||
if (!empty($atts['baseinstalldir'])) {
|
||||
$dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir'];
|
||||
}
|
||||
} else {
|
||||
$dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'],
|
||||
$layer, $pkg->getChannel()) . DIRECTORY_SEPARATOR . $pkg->getPackage();
|
||||
}
|
||||
if (dirname($file) != '.' && empty($atts['install-as'])) {
|
||||
$dest_dir .= DIRECTORY_SEPARATOR . dirname($file);
|
||||
}
|
||||
if (empty($atts['install-as'])) {
|
||||
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file);
|
||||
} else {
|
||||
$dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as'];
|
||||
}
|
||||
$orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file;
|
||||
|
||||
// Clean up the DIRECTORY_SEPARATOR mess
|
||||
$ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR;
|
||||
|
||||
list($dest_dir, $dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"),
|
||||
array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR,
|
||||
DIRECTORY_SEPARATOR),
|
||||
array($dest_dir, $dest_file, $orig_file));
|
||||
return array($save_destdir, $dest_dir, $dest_file, $orig_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the configuration variable that specifies the location of this file
|
||||
* @return string|false
|
||||
*/
|
||||
function getLocationConfig()
|
||||
{
|
||||
$roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' .
|
||||
ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this)))));
|
||||
if (PEAR::isError($roleInfo)) {
|
||||
return $roleInfo;
|
||||
}
|
||||
return $roleInfo['locationconfig'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Do any unusual setup here
|
||||
* @param PEAR_Installer
|
||||
* @param PEAR_PackageFile_v2
|
||||
* @param array file attributes
|
||||
* @param string file name
|
||||
*/
|
||||
function setup(&$installer, $pkg, $atts, $file)
|
||||
{
|
||||
}
|
||||
|
||||
function isExecutable()
|
||||
{
|
||||
$roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' .
|
||||
ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this)))));
|
||||
if (PEAR::isError($roleInfo)) {
|
||||
return $roleInfo;
|
||||
}
|
||||
return $roleInfo['executable'];
|
||||
}
|
||||
|
||||
function isInstallable()
|
||||
{
|
||||
$roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' .
|
||||
ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this)))));
|
||||
if (PEAR::isError($roleInfo)) {
|
||||
return $roleInfo;
|
||||
}
|
||||
return $roleInfo['installable'];
|
||||
}
|
||||
|
||||
function isExtension()
|
||||
{
|
||||
$roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' .
|
||||
ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this)))));
|
||||
if (PEAR::isError($roleInfo)) {
|
||||
return $roleInfo;
|
||||
}
|
||||
return $roleInfo['phpextension'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
34
vendor/library/Excel/phpxls/PEAR/Installer/Role/Data.php
vendored
Normal file
34
vendor/library/Excel/phpxls/PEAR/Installer/Role/Data.php
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Installer_Role_Data
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Data.php,v 1.7 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a1
|
||||
*/
|
||||
class PEAR_Installer_Role_Data extends PEAR_Installer_Role_Common {}
|
||||
?>
|
||||
15
vendor/library/Excel/phpxls/PEAR/Installer/Role/Data.xml
vendored
Normal file
15
vendor/library/Excel/phpxls/PEAR/Installer/Role/Data.xml
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<role version="1.0">
|
||||
<releasetypes>php</releasetypes>
|
||||
<releasetypes>extsrc</releasetypes>
|
||||
<releasetypes>extbin</releasetypes>
|
||||
<releasetypes>zendextsrc</releasetypes>
|
||||
<releasetypes>zendextbin</releasetypes>
|
||||
<installable>1</installable>
|
||||
<locationconfig>data_dir</locationconfig>
|
||||
<honorsbaseinstall />
|
||||
<unusualbaseinstall />
|
||||
<phpfile />
|
||||
<executable />
|
||||
<phpextension />
|
||||
<config_vars />
|
||||
</role>
|
||||
34
vendor/library/Excel/phpxls/PEAR/Installer/Role/Doc.php
vendored
Normal file
34
vendor/library/Excel/phpxls/PEAR/Installer/Role/Doc.php
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Installer_Role_Doc
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Doc.php,v 1.7 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a1
|
||||
*/
|
||||
class PEAR_Installer_Role_Doc extends PEAR_Installer_Role_Common {}
|
||||
?>
|
||||
15
vendor/library/Excel/phpxls/PEAR/Installer/Role/Doc.xml
vendored
Normal file
15
vendor/library/Excel/phpxls/PEAR/Installer/Role/Doc.xml
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<role version="1.0">
|
||||
<releasetypes>php</releasetypes>
|
||||
<releasetypes>extsrc</releasetypes>
|
||||
<releasetypes>extbin</releasetypes>
|
||||
<releasetypes>zendextsrc</releasetypes>
|
||||
<releasetypes>zendextbin</releasetypes>
|
||||
<installable>1</installable>
|
||||
<locationconfig>doc_dir</locationconfig>
|
||||
<honorsbaseinstall />
|
||||
<unusualbaseinstall />
|
||||
<phpfile />
|
||||
<executable />
|
||||
<phpextension />
|
||||
<config_vars />
|
||||
</role>
|
||||
34
vendor/library/Excel/phpxls/PEAR/Installer/Role/Ext.php
vendored
Normal file
34
vendor/library/Excel/phpxls/PEAR/Installer/Role/Ext.php
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* PEAR_Installer_Role_Ext
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
||||
* the PHP License and are unable to obtain it through the web, please
|
||||
* send a note to license@php.net so we can mail you a copy immediately.
|
||||
*
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Ext.php,v 1.7 2008/01/03 20:26:36 cellog Exp $
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since File available since Release 1.4.0a1
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category pear
|
||||
* @package PEAR
|
||||
* @author Greg Beaver <cellog@php.net>
|
||||
* @copyright 1997-2008 The PHP Group
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version Release: 1.7.2
|
||||
* @link http://pear.php.net/package/PEAR
|
||||
* @since Class available since Release 1.4.0a1
|
||||
*/
|
||||
class PEAR_Installer_Role_Ext extends PEAR_Installer_Role_Common {}
|
||||
?>
|
||||
12
vendor/library/Excel/phpxls/PEAR/Installer/Role/Ext.xml
vendored
Normal file
12
vendor/library/Excel/phpxls/PEAR/Installer/Role/Ext.xml
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<role version="1.0">
|
||||
<releasetypes>extbin</releasetypes>
|
||||
<releasetypes>zendextbin</releasetypes>
|
||||
<installable>1</installable>
|
||||
<locationconfig>ext_dir</locationconfig>
|
||||
<honorsbaseinstall>1</honorsbaseinstall>
|
||||
<unusualbaseinstall />
|
||||
<phpfile />
|
||||
<executable />
|
||||
<phpextension>1</phpextension>
|
||||
<config_vars />
|
||||
</role>
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue