fix PSR coding style
This commit is contained in:
parent
e2d8a94e28
commit
af474f0189
11
_admin.php
11
_admin.php
@ -10,7 +10,6 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -35,12 +34,12 @@ class packmanBehaviors
|
|||||||
public static function adminDashboardFavorites($core, $favs)
|
public static function adminDashboardFavorites($core, $favs)
|
||||||
{
|
{
|
||||||
$favs->register('pacKman', [
|
$favs->register('pacKman', [
|
||||||
'title' => __('Packages repository'),
|
'title' => __('Packages repository'),
|
||||||
'url' => 'plugin.php?p=pacKman#packman-repository-repository',
|
'url' => 'plugin.php?p=pacKman#packman-repository-repository',
|
||||||
'small-icon' => 'index.php?pf=pacKman/icon.png',
|
'small-icon' => 'index.php?pf=pacKman/icon.png',
|
||||||
'large-icon' => 'index.php?pf=pacKman/icon-big.png',
|
'large-icon' => 'index.php?pf=pacKman/icon-big.png',
|
||||||
'permissions' => $core->auth->isSuperAdmin(),
|
'permissions' => $core->auth->isSuperAdmin(),
|
||||||
'active_cb' => [
|
'active_cb' => [
|
||||||
'packmanBehaviors',
|
'packmanBehaviors',
|
||||||
'adminDashboardFavoritesActive'
|
'adminDashboardFavoritesActive'
|
||||||
]
|
]
|
||||||
|
31
_config.php
31
_config.php
@ -10,7 +10,6 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_MODULE')) {
|
if (!defined('DC_CONTEXT_MODULE')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -22,24 +21,24 @@ $redir = empty($_REQUEST['redir']) ?
|
|||||||
$core->blog->settings->addNamespace('pacKman');
|
$core->blog->settings->addNamespace('pacKman');
|
||||||
$s = $core->blog->settings->pacKman;
|
$s = $core->blog->settings->pacKman;
|
||||||
|
|
||||||
$packman_pack_nocomment = $s->packman_pack_nocomment;
|
$packman_pack_nocomment = $s->packman_pack_nocomment;
|
||||||
$packman_pack_fixnewline = $s->packman_pack_fixnewline;
|
$packman_pack_fixnewline = $s->packman_pack_fixnewline;
|
||||||
$packman_pack_overwrite = $s->packman_pack_overwrite;
|
$packman_pack_overwrite = $s->packman_pack_overwrite;
|
||||||
$packman_pack_filename = $s->packman_pack_filename;
|
$packman_pack_filename = $s->packman_pack_filename;
|
||||||
$packman_secondpack_filename = $s->packman_secondpack_filename;
|
$packman_secondpack_filename = $s->packman_secondpack_filename;
|
||||||
$packman_pack_repository = $s->packman_pack_repository;
|
$packman_pack_repository = $s->packman_pack_repository;
|
||||||
$packman_pack_excludefiles = $s->packman_pack_excludefiles;
|
$packman_pack_excludefiles = $s->packman_pack_excludefiles;
|
||||||
|
|
||||||
# -- Set settings --
|
# -- Set settings --
|
||||||
if (!empty($_POST['save'])) {
|
if (!empty($_POST['save'])) {
|
||||||
try {
|
try {
|
||||||
$packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']);
|
$packman_pack_nocomment = !empty($_POST['packman_pack_nocomment']);
|
||||||
$packman_pack_fixnewline = !empty($_POST['packman_pack_fixnewline']);
|
$packman_pack_fixnewline = !empty($_POST['packman_pack_fixnewline']);
|
||||||
$packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']);
|
$packman_pack_overwrite = !empty($_POST['packman_pack_overwrite']);
|
||||||
$packman_pack_filename = $_POST['packman_pack_filename'];
|
$packman_pack_filename = $_POST['packman_pack_filename'];
|
||||||
$packman_secondpack_filename = $_POST['packman_secondpack_filename'];
|
$packman_secondpack_filename = $_POST['packman_secondpack_filename'];
|
||||||
$packman_pack_repository = path::real($_POST['packman_pack_repository'], false);
|
$packman_pack_repository = path::real($_POST['packman_pack_repository'], false);
|
||||||
$packman_pack_excludefiles = $_POST['packman_pack_excludefiles'];
|
$packman_pack_excludefiles = $_POST['packman_pack_excludefiles'];
|
||||||
|
|
||||||
$check = libPackman::is_configured(
|
$check = libPackman::is_configured(
|
||||||
$core,
|
$core,
|
||||||
@ -78,7 +77,9 @@ echo '
|
|||||||
<p><label for="packman_pack_repository">' . __('Path to repository:') . ' ' .
|
<p><label for="packman_pack_repository">' . __('Path to repository:') . ' ' .
|
||||||
form::field('packman_pack_repository', 65, 255, $packman_pack_repository, 'maximal') .
|
form::field('packman_pack_repository', 65, 255, $packman_pack_repository, 'maximal') .
|
||||||
'</label></p>' .
|
'</label></p>' .
|
||||||
'<p class="form-note">' . sprintf(__('Preconization: %s'), $core->blog->public_path ?
|
'<p class="form-note">' . sprintf(
|
||||||
|
__('Preconization: %s'),
|
||||||
|
$core->blog->public_path ?
|
||||||
$core->blog->public_path : __("Blog's public directory")
|
$core->blog->public_path : __("Blog's public directory")
|
||||||
) . '</p>
|
) . '</p>
|
||||||
</div>
|
</div>
|
||||||
@ -96,7 +97,7 @@ form::field('packman_secondpack_filename', 65, 255, $packman_secondpack_filename
|
|||||||
'</label></p>
|
'</label></p>
|
||||||
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%-%version%') . '</p>
|
<p class="form-note">' . sprintf(__('Preconization: %s'), '%type%-%id%-%version%') . '</p>
|
||||||
|
|
||||||
<p><label class="classic" for="packman_pack_overwrite">'.
|
<p><label class="classic" for="packman_pack_overwrite">' .
|
||||||
form::checkbox('packman_pack_overwrite', 1, $packman_pack_overwrite) . ' ' .
|
form::checkbox('packman_pack_overwrite', 1, $packman_pack_overwrite) . ' ' .
|
||||||
__('Overwrite existing package') . '</label></p>
|
__('Overwrite existing package') . '</label></p>
|
||||||
|
|
||||||
|
13
_define.php
13
_define.php
@ -10,7 +10,6 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -21,11 +20,11 @@ $this->registerModule(
|
|||||||
'Jean-Christian Denis',
|
'Jean-Christian Denis',
|
||||||
'2021.10.28',
|
'2021.10.28',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.19']],
|
'requires' => [['core', '2.19']],
|
||||||
'permissions' => null,
|
'permissions' => null,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/pacKman',
|
'support' => 'https://github.com/JcDenis/pacKman',
|
||||||
'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman',
|
'details' => 'https://plugins.dotaddict.org/dc2/details/pacKman',
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/pacKman/master/dcstore.xml'
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/pacKman/master/dcstore.xml'
|
||||||
]
|
]
|
||||||
);
|
);
|
24
_install.php
24
_install.php
@ -10,15 +10,14 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- Module specs --
|
# -- Module specs --
|
||||||
|
|
||||||
$dc_min = '2.18';
|
$dc_min = '2.18';
|
||||||
$mod_id = 'pacKman';
|
$mod_id = 'pacKman';
|
||||||
$mod_conf = [
|
$mod_conf = [
|
||||||
[
|
[
|
||||||
'packman_menu_plugins',
|
'packman_menu_plugins',
|
||||||
@ -72,7 +71,8 @@ try {
|
|||||||
if (version_compare(
|
if (version_compare(
|
||||||
$core->getVersion($mod_id),
|
$core->getVersion($mod_id),
|
||||||
$core->plugins->moduleInfo($mod_id, 'version'),
|
$core->plugins->moduleInfo($mod_id, 'version'),
|
||||||
'>=')) {
|
'>='
|
||||||
|
)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,15 +80,22 @@ try {
|
|||||||
if (!method_exists('dcUtils', 'versionsCompare')
|
if (!method_exists('dcUtils', 'versionsCompare')
|
||||||
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
|
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
|
||||||
throw new Exception(sprintf(
|
throw new Exception(sprintf(
|
||||||
'%s requires Dotclear %s', $mod_id, $dc_min
|
'%s requires Dotclear %s',
|
||||||
|
$mod_id,
|
||||||
|
$dc_min
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set module settings
|
# Set module settings
|
||||||
$core->blog->settings->addNamespace($mod_id);
|
$core->blog->settings->addNamespace($mod_id);
|
||||||
foreach($mod_conf as $v) {
|
foreach ($mod_conf as $v) {
|
||||||
$core->blog->settings->{$mod_id}->put(
|
$core->blog->settings->{$mod_id}->put(
|
||||||
$v[0], $v[2], $v[3], $v[1], false, true
|
$v[0],
|
||||||
|
$v[2],
|
||||||
|
$v[3],
|
||||||
|
$v[1],
|
||||||
|
false,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,8 +106,7 @@ try {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -10,13 +10,12 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = dirname(__FILE__) . '/inc/';
|
$d = dirname(__FILE__) . '/inc/';
|
||||||
|
|
||||||
$__autoload['dcPackman'] = $d . 'class.dc.packman.php';
|
$__autoload['dcPackman'] = $d . 'class.dc.packman.php';
|
||||||
$__autoload['libPackman'] = $d . 'lib.packman.php';
|
$__autoload['libPackman'] = $d . 'lib.packman.php';
|
||||||
$__autoload['packmanFileZip'] = $d . 'lib.packman.filezip.php';
|
$__autoload['packmanFileZip'] = $d . 'lib.packman.filezip.php';
|
@ -10,7 +10,6 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -18,43 +17,67 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||||||
$mod_id = 'pacKman';
|
$mod_id = 'pacKman';
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'settings',
|
/* type */
|
||||||
/* action */ 'delete_all',
|
'settings',
|
||||||
/* ns */ $mod_id,
|
/* action */
|
||||||
/* desc */ __('delete all settings')
|
'delete_all',
|
||||||
|
/* ns */
|
||||||
|
$mod_id,
|
||||||
|
/* desc */
|
||||||
|
__('delete all settings')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'plugins',
|
/* type */
|
||||||
/* action */ 'delete',
|
'plugins',
|
||||||
/* ns */ $mod_id,
|
/* action */
|
||||||
/* desc */ __('delete plugin files')
|
'delete',
|
||||||
|
/* ns */
|
||||||
|
$mod_id,
|
||||||
|
/* desc */
|
||||||
|
__('delete plugin files')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'versions',
|
/* type */
|
||||||
/* action */ 'delete',
|
'versions',
|
||||||
/* ns */ $mod_id,
|
/* action */
|
||||||
/* desc */ __('delete the version number')
|
'delete',
|
||||||
|
/* ns */
|
||||||
|
$mod_id,
|
||||||
|
/* desc */
|
||||||
|
__('delete the version number')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
/* type */ 'settings',
|
/* type */
|
||||||
/* action */ 'delete_all',
|
'settings',
|
||||||
/* ns */ $mod_id,
|
/* action */
|
||||||
/* desc */ sprintf(__('delete all %s settings'), $mod_id)
|
'delete_all',
|
||||||
|
/* ns */
|
||||||
|
$mod_id,
|
||||||
|
/* desc */
|
||||||
|
sprintf(__('delete all %s settings'), $mod_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
/* type */ 'plugins',
|
/* type */
|
||||||
/* action */ 'delete',
|
'plugins',
|
||||||
/* ns */ $mod_id,
|
/* action */
|
||||||
/* desc */ sprintf(__('delete %s plugin files'), $mod_id)
|
'delete',
|
||||||
|
/* ns */
|
||||||
|
$mod_id,
|
||||||
|
/* desc */
|
||||||
|
sprintf(__('delete %s plugin files'), $mod_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
/* type */ 'versions',
|
/* type */
|
||||||
/* action */ 'delete',
|
'versions',
|
||||||
/* ns */ $mod_id,
|
/* action */
|
||||||
/* desc */ sprintf(__('delete %s version number'), $mod_id)
|
'delete',
|
||||||
|
/* ns */
|
||||||
|
$mod_id,
|
||||||
|
/* desc */
|
||||||
|
sprintf(__('delete %s version number'), $mod_id)
|
||||||
);
|
);
|
@ -10,7 +10,6 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -31,7 +30,7 @@ class dcPackman
|
|||||||
|
|
||||||
public static function quote_exclude($exclude)
|
public static function quote_exclude($exclude)
|
||||||
{
|
{
|
||||||
foreach($exclude AS $k => $v) {
|
foreach ($exclude as $k => $v) {
|
||||||
$exclude[$k] = '#(^|/)(' . str_replace(
|
$exclude[$k] = '#(^|/)(' . str_replace(
|
||||||
['.', '*'],
|
['.', '*'],
|
||||||
['\.', '.*?'],
|
['\.', '.*?'],
|
||||||
@ -51,9 +50,9 @@ class dcPackman
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = files::scanDir($root);
|
$files = files::scanDir($root);
|
||||||
$zip_files = [];
|
$zip_files = [];
|
||||||
foreach($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (!preg_match('#(^|/)(.*?)\.zip(/|$)#', $file)) {
|
if (!preg_match('#(^|/)(.*?)\.zip(/|$)#', $file)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -65,16 +64,16 @@ class dcPackman
|
|||||||
}
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach($zip_files as $zip_file) {
|
foreach ($zip_files as $zip_file) {
|
||||||
$zip = new fileUnzip($root . '/' . $zip_file);
|
$zip = new fileUnzip($root . '/' . $zip_file);
|
||||||
|
|
||||||
$zip_root_dir = $zip->getRootDir();
|
$zip_root_dir = $zip->getRootDir();
|
||||||
|
|
||||||
if ($zip_root_dir != false) {
|
if ($zip_root_dir != false) {
|
||||||
$define = $zip_root_dir . '/_define.php';
|
$define = $zip_root_dir . '/_define.php';
|
||||||
$has_define = $zip->hasFile($define);
|
$has_define = $zip->hasFile($define);
|
||||||
} else {
|
} else {
|
||||||
$define = '_define.php';
|
$define = '_define.php';
|
||||||
$has_define = $zip->hasFile($define);
|
$has_define = $zip->hasFile($define);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +92,7 @@ class dcPackman
|
|||||||
$themes->requireDefine($cache, $zip_root_dir);
|
$themes->requireDefine($cache, $zip_root_dir);
|
||||||
$res[$i] = $themes->getModules($zip_root_dir);
|
$res[$i] = $themes->getModules($zip_root_dir);
|
||||||
}
|
}
|
||||||
$res[$i]['id'] = $zip_root_dir;
|
$res[$i]['id'] = $zip_root_dir;
|
||||||
$res[$i]['root'] = $root . '/' . $zip_file;
|
$res[$i]['root'] = $root . '/' . $zip_file;
|
||||||
|
|
||||||
unlink($cache . '_define.php');
|
unlink($cache . '_define.php');
|
||||||
@ -113,7 +112,7 @@ class dcPackman
|
|||||||
|
|
||||||
$exclude = self::getExclude($exclude);
|
$exclude = self::getExclude($exclude);
|
||||||
|
|
||||||
foreach($files as $file) {
|
foreach ($files as $file) {
|
||||||
if (!($file = self::getFile($file, $info))
|
if (!($file = self::getFile($file, $info))
|
||||||
|| !($dest = self::getOverwrite($overwrite, $root, $file))
|
|| !($dest = self::getOverwrite($overwrite, $root, $file))
|
||||||
) {
|
) {
|
||||||
@ -131,7 +130,7 @@ class dcPackman
|
|||||||
}
|
}
|
||||||
$zip = new packmanFileZip($fp);
|
$zip = new packmanFileZip($fp);
|
||||||
|
|
||||||
foreach($exclude AS $e) {
|
foreach ($exclude as $e) {
|
||||||
$zip->addExclusion($e);
|
$zip->addExclusion($e);
|
||||||
}
|
}
|
||||||
$zip->addDirectory(
|
$zip->addDirectory(
|
||||||
@ -201,9 +200,10 @@ class dcPackman
|
|||||||
$file
|
$file
|
||||||
);
|
);
|
||||||
$parts = explode('/', $file);
|
$parts = explode('/', $file);
|
||||||
foreach($parts as $i => $part) {
|
foreach ($parts as $i => $part) {
|
||||||
$parts[$i] = files::tidyFileName($part);
|
$parts[$i] = files::tidyFileName($part);
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode('/', $parts) . '.zip';
|
return implode('/', $parts) . '.zip';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,11 +10,10 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class packmanFileZip extends fileZip
|
class packmanFileZip extends fileZip
|
||||||
{
|
{
|
||||||
public static $remove_comment = false;
|
public static $remove_comment = false;
|
||||||
public static $fix_newline = false;
|
public static $fix_newline = false;
|
||||||
|
|
||||||
protected function writeFile($name, $file, $size, $mtime)
|
protected function writeFile($name, $file, $size, $mtime)
|
||||||
{
|
{
|
||||||
@ -29,17 +28,17 @@ class packmanFileZip extends fileZip
|
|||||||
|
|
||||||
//cleanup file contents
|
//cleanup file contents
|
||||||
// at this time only php files
|
// at this time only php files
|
||||||
if (self::$remove_comment && substr($file,-4) == '.php') {
|
if (self::$remove_comment && substr($file, -4) == '.php') {
|
||||||
$content = self::removePHPComment($content);
|
$content = self::removePHPComment($content);
|
||||||
}
|
}
|
||||||
if (self::$fix_newline && substr($file,-4) == '.php') {
|
if (self::$fix_newline && substr($file, -4) == '.php') {
|
||||||
$content = self::fixNewline($content);
|
$content = self::fixNewline($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
$unc_len = strlen($content);
|
$unc_len = strlen($content);
|
||||||
$crc = crc32($content);
|
$crc = crc32($content);
|
||||||
$zdata = gzdeflate($content);
|
$zdata = gzdeflate($content);
|
||||||
$c_len = strlen($zdata);
|
$c_len = strlen($zdata);
|
||||||
|
|
||||||
unset($content);
|
unset($content);
|
||||||
|
|
||||||
@ -47,8 +46,7 @@ class packmanFileZip extends fileZip
|
|||||||
$mtime = $this->makeTime($mtime);
|
$mtime = $this->makeTime($mtime);
|
||||||
|
|
||||||
# Data descriptor
|
# Data descriptor
|
||||||
$data_desc =
|
$data_desc = "\x50\x4b\x03\x04" .
|
||||||
"\x50\x4b\x03\x04" .
|
|
||||||
"\x14\x00" . # ver needed to extract
|
"\x14\x00" . # ver needed to extract
|
||||||
"\x00\x00" . # gen purpose bit flag
|
"\x00\x00" . # gen purpose bit flag
|
||||||
"\x08\x00" . # compression method
|
"\x08\x00" . # compression method
|
||||||
@ -58,7 +56,7 @@ class packmanFileZip extends fileZip
|
|||||||
pack('V', $c_len) . # compressed filesize
|
pack('V', $c_len) . # compressed filesize
|
||||||
pack('V', $unc_len) . # uncompressed filesize
|
pack('V', $unc_len) . # uncompressed filesize
|
||||||
pack('v', strlen($name)) . # length of filename
|
pack('v', strlen($name)) . # length of filename
|
||||||
pack('v' ,0) . # extra field length
|
pack('v', 0) . # extra field length
|
||||||
$name . # end of "local file header" segment
|
$name . # end of "local file header" segment
|
||||||
$zdata . # "file data" segment
|
$zdata . # "file data" segment
|
||||||
pack('V', $crc) . # crc32
|
pack('V', $crc) . # crc32
|
||||||
@ -71,8 +69,7 @@ class packmanFileZip extends fileZip
|
|||||||
$new_offset = $this->old_offset + strlen($data_desc);
|
$new_offset = $this->old_offset + strlen($data_desc);
|
||||||
|
|
||||||
# Add to central directory record
|
# Add to central directory record
|
||||||
$cdrec =
|
$cdrec = "\x50\x4b\x01\x02" .
|
||||||
"\x50\x4b\x01\x02" .
|
|
||||||
"\x00\x00" . # version made by
|
"\x00\x00" . # version made by
|
||||||
"\x14\x00" . # version needed to extract
|
"\x14\x00" . # version needed to extract
|
||||||
"\x00\x00" . # gen purpose bit flag
|
"\x00\x00" . # gen purpose bit flag
|
||||||
@ -88,7 +85,7 @@ class packmanFileZip extends fileZip
|
|||||||
pack('v', 0) . # disk number start
|
pack('v', 0) . # disk number start
|
||||||
pack('v', 0) . # internal file attributes
|
pack('v', 0) . # internal file attributes
|
||||||
pack('V', 32) . # external file attributes - 'archive' bit set
|
pack('V', 32) . # external file attributes - 'archive' bit set
|
||||||
pack('V', $this->old_offset). # relative offset of local header
|
pack('V', $this->old_offset) . # relative offset of local header
|
||||||
$name;
|
$name;
|
||||||
|
|
||||||
$this->old_offset = $new_offset;
|
$this->old_offset = $new_offset;
|
||||||
@ -119,6 +116,7 @@ class packmanFileZip extends fileZip
|
|||||||
$newStr .= $token;
|
$newStr .= $token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $newStr;
|
return $newStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -99,7 +98,8 @@ class libPackman
|
|||||||
'</table>' .
|
'</table>' .
|
||||||
'<p class="checkboxes-helpers"></p>' .
|
'<p class="checkboxes-helpers"></p>' .
|
||||||
'<p>' .
|
'<p>' .
|
||||||
(!empty($_REQUEST['redir']) ?
|
(
|
||||||
|
!empty($_REQUEST['redir']) ?
|
||||||
form::hidden(
|
form::hidden(
|
||||||
['redir'],
|
['redir'],
|
||||||
html::escapeHTML($_REQUEST['redir'])
|
html::escapeHTML($_REQUEST['redir'])
|
||||||
@ -109,7 +109,7 @@ class libPackman
|
|||||||
form::hidden(['type'], $type) .
|
form::hidden(['type'], $type) .
|
||||||
form::hidden(['action'], 'packup') .
|
form::hidden(['action'], 'packup') .
|
||||||
'<input type="submit" name="packup" value="' .
|
'<input type="submit" name="packup" value="' .
|
||||||
__('Pack up selected modules') .'" />' .
|
__('Pack up selected modules') . '" />' .
|
||||||
$core->formNonce() . '</p>' .
|
$core->formNonce() . '</p>' .
|
||||||
'</form>' .
|
'</form>' .
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ class libPackman
|
|||||||
'</tr>';
|
'</tr>';
|
||||||
|
|
||||||
$dup = [];
|
$dup = [];
|
||||||
foreach(self::sort($modules) AS $module) {
|
foreach (self::sort($modules) as $module) {
|
||||||
if (isset($dup[$module['root']])) {
|
if (isset($dup[$module['root']])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ class libPackman
|
|||||||
'</td>' .
|
'</td>' .
|
||||||
'<td class="nowrap">' .
|
'<td class="nowrap">' .
|
||||||
'<a class="packman-download" href="plugin.php?p=pacKman&package=' .
|
'<a class="packman-download" href="plugin.php?p=pacKman&package=' .
|
||||||
basename($module['root']) . '&repo=' . $type . '" title="'. __('Download') . '">' .
|
basename($module['root']) . '&repo=' . $type . '" title="' . __('Download') . '">' .
|
||||||
html::escapeHTML(basename($module['root'])) . '</a>' .
|
html::escapeHTML(basename($module['root'])) . '</a>' .
|
||||||
'</td>' .
|
'</td>' .
|
||||||
'</tr>';
|
'</tr>';
|
||||||
@ -206,7 +206,7 @@ class libPackman
|
|||||||
protected static function sort($modules)
|
protected static function sort($modules)
|
||||||
{
|
{
|
||||||
$key = $ver = [];
|
$key = $ver = [];
|
||||||
foreach($modules as $i => $module) {
|
foreach ($modules as $i => $module) {
|
||||||
$key[$i] = $module['id'] ?? $i;
|
$key[$i] = $module['id'] ?? $i;
|
||||||
$ver[$i] = $module['version'];
|
$ver[$i] = $module['version'];
|
||||||
}
|
}
|
||||||
|
54
index.php
54
index.php
@ -10,7 +10,6 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -18,8 +17,8 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||||||
dcPage::checkSuper();
|
dcPage::checkSuper();
|
||||||
|
|
||||||
# Queries
|
# Queries
|
||||||
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
$action = $_POST['action'] ?? '';
|
||||||
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
|
$type = isset($_POST['type']) && in_array($_POST['type'], ['plugins', 'themes', 'repository']) ? $_POST['type'] : '';
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
$core->blog->settings->addNamespace('pacKman');
|
$core->blog->settings->addNamespace('pacKman');
|
||||||
@ -30,23 +29,22 @@ if (!isset($core->themes)) {
|
|||||||
$core->themes = new dcThemes($core);
|
$core->themes = new dcThemes($core);
|
||||||
$core->themes->loadModules($core->blog->themes_path, null);
|
$core->themes->loadModules($core->blog->themes_path, null);
|
||||||
}
|
}
|
||||||
$themes = $core->themes;
|
$themes = $core->themes;
|
||||||
$plugins = $core->plugins;
|
$plugins = $core->plugins;
|
||||||
|
|
||||||
# Paths
|
# Paths
|
||||||
$ppexp = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
$ppexp = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
|
||||||
$pppop = array_pop($ppexp);
|
$pppop = array_pop($ppexp);
|
||||||
$plugins_path = path::real($pppop);
|
$plugins_path = path::real($pppop);
|
||||||
$themes_path = $core->blog->themes_path;
|
$themes_path = $core->blog->themes_path;
|
||||||
$repo_path = $s->packman_pack_repository;
|
$repo_path = $s->packman_pack_repository;
|
||||||
|
|
||||||
# Rights
|
# Rights
|
||||||
$is_writable = libPackman::is_writable(
|
$is_writable = libPackman::is_writable(
|
||||||
$s->packman_pack_repository,
|
$s->packman_pack_repository,
|
||||||
$s->packman_pack_filename
|
$s->packman_pack_filename
|
||||||
);
|
);
|
||||||
$is_editable =
|
$is_editable = !empty($type)
|
||||||
!empty($type)
|
|
||||||
&& !empty($_POST['modules'])
|
&& !empty($_POST['modules'])
|
||||||
&& is_array($_POST['modules']);
|
&& is_array($_POST['modules']);
|
||||||
|
|
||||||
@ -73,7 +71,7 @@ try {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($modules as $f) {
|
foreach ($modules as $f) {
|
||||||
if (preg_match('/' . preg_quote($_REQUEST['package']) . '$/', $f['root'])
|
if (preg_match('/' . preg_quote($_REQUEST['package']) . '$/', $f['root'])
|
||||||
&& is_file($f['root']) && is_readable($f['root'])
|
&& is_file($f['root']) && is_readable($f['root'])
|
||||||
) {
|
) {
|
||||||
@ -97,7 +95,6 @@ try {
|
|||||||
header('Content-Type: text/plain');
|
header('Content-Type: text/plain');
|
||||||
http::head(404, 'Not Found');
|
http::head(404, 'Not Found');
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
} elseif (!empty($action) && !$is_editable) {
|
} elseif (!empty($action) && !$is_editable) {
|
||||||
throw new Exception('No selected modules');
|
throw new Exception('No selected modules');
|
||||||
|
|
||||||
@ -108,19 +105,19 @@ try {
|
|||||||
throw new Exception('No such module');
|
throw new Exception('No such module');
|
||||||
}
|
}
|
||||||
|
|
||||||
$module = ${$type}->getModules($id);
|
$module = ${$type}->getModules($id);
|
||||||
$module['id'] = $id;
|
$module['id'] = $id;
|
||||||
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
$module['type'] = $type == 'themes' ? 'theme' : 'plugin';
|
||||||
|
|
||||||
$root = $s->packman_pack_repository;
|
$root = $s->packman_pack_repository;
|
||||||
$files = [
|
$files = [
|
||||||
$s->packman_pack_filename,
|
$s->packman_pack_filename,
|
||||||
$s->packman_secondpack_filename
|
$s->packman_secondpack_filename
|
||||||
];
|
];
|
||||||
$nocomment = $s->packman_pack_nocomment;
|
$nocomment = $s->packman_pack_nocomment;
|
||||||
$fixnewline = $s->packman_pack_fixnewline;
|
$fixnewline = $s->packman_pack_fixnewline;
|
||||||
$overwrite = $s->packman_pack_overwrite;
|
$overwrite = $s->packman_pack_overwrite;
|
||||||
$exclude = explode(',', $s->packman_pack_excludefiles);
|
$exclude = explode(',', $s->packman_pack_excludefiles);
|
||||||
|
|
||||||
# --BEHAVIOR-- packmanBeforeCreatePackage
|
# --BEHAVIOR-- packmanBeforeCreatePackage
|
||||||
$core->callBehavior('packmanBeforeCreatePackage', $core, $module);
|
$core->callBehavior('packmanBeforeCreatePackage', $core, $module);
|
||||||
@ -129,7 +126,6 @@ try {
|
|||||||
|
|
||||||
# --BEHAVIOR-- packmanAfterCreatePackage
|
# --BEHAVIOR-- packmanAfterCreatePackage
|
||||||
$core->callBehavior('packmanAfterCreatePackage', $core, $module);
|
$core->callBehavior('packmanAfterCreatePackage', $core, $module);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
@ -142,10 +138,10 @@ try {
|
|||||||
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-' . $type);
|
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-' . $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete
|
# Delete
|
||||||
} elseif ($action == 'delete') {
|
} elseif ($action == 'delete') {
|
||||||
foreach ($_POST['modules'] as $root => $id) {
|
foreach ($_POST['modules'] as $root => $id) {
|
||||||
if (!file_exists($root) || !files::isDeletable($root)) {
|
if (!file_exists($root) || !files::isDeletable($root)) {
|
||||||
throw new Exception('Undeletable file: ' . $root);
|
throw new Exception('Undeletable file: ' . $root);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +158,7 @@ try {
|
|||||||
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
|
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
} elseif ($action == 'install') {
|
} elseif ($action == 'install') {
|
||||||
foreach ($_POST['modules'] as $root => $id) {
|
foreach ($_POST['modules'] as $root => $id) {
|
||||||
|
|
||||||
@ -178,7 +174,6 @@ try {
|
|||||||
|
|
||||||
# --BEHAVIOR-- packmanAfterInstallPackage
|
# --BEHAVIOR-- packmanAfterInstallPackage
|
||||||
$core->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
|
$core->callBehavior('packmanAfterInstallPackage', $type, $id, $root);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
@ -191,7 +186,7 @@ try {
|
|||||||
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
|
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Copy
|
# Copy
|
||||||
} elseif (strpos($action, 'copy_to_') !== false) {
|
} elseif (strpos($action, 'copy_to_') !== false) {
|
||||||
if ($action == 'copy_to_plugins') {
|
if ($action == 'copy_to_plugins') {
|
||||||
$dest = $plugins_path;
|
$dest = $plugins_path;
|
||||||
@ -218,7 +213,7 @@ try {
|
|||||||
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
|
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Move
|
# Move
|
||||||
} elseif (strpos($action, 'move_to_') !== false) {
|
} elseif (strpos($action, 'move_to_') !== false) {
|
||||||
if ($action == 'move_to_plugins') {
|
if ($action == 'move_to_plugins') {
|
||||||
$dest = $plugins_path;
|
$dest = $plugins_path;
|
||||||
@ -246,7 +241,7 @@ try {
|
|||||||
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
|
$core->adminurl->redirect('admin.plugin.pacKman', [], '#packman-repository-' . $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(Exception $e) {
|
} catch (Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,9 +258,9 @@ echo
|
|||||||
'</head><body>' .
|
'</head><body>' .
|
||||||
|
|
||||||
dcPage::breadcrumb([
|
dcPage::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
__('pacKman') => ''
|
__('pacKman') => ''
|
||||||
]).
|
]) .
|
||||||
dcPage::notices();
|
dcPage::notices();
|
||||||
|
|
||||||
if ($core->error->flag()) {
|
if ($core->error->flag()) {
|
||||||
@ -274,7 +269,6 @@ if ($core->error->flag()) {
|
|||||||
'<a href="plugins.php?module=pacKman&conf=1&redir=' .
|
'<a href="plugins.php?module=pacKman&conf=1&redir=' .
|
||||||
urlencode('plugin.php?p=pacKman') . '">' . __('Configuration') . '</a>' .
|
urlencode('plugin.php?p=pacKman') . '">' . __('Configuration') . '</a>' .
|
||||||
'</p>';
|
'</p>';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$repo_path_modules = array_merge(
|
$repo_path_modules = array_merge(
|
||||||
dcPackman::getPackages(
|
dcPackman::getPackages(
|
||||||
|
Loading…
Reference in New Issue
Block a user