Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ISPConfig 3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lolo888
ISPConfig 3
Commits
7d4360a0
Commit
7d4360a0
authored
May 31, 2012
by
tbrehm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added server part of the aps installer.
parent
55e22012
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
943 additions
and
5 deletions
+943
-5
install/sql/incremental/upd_0034.sql
install/sql/incremental/upd_0034.sql
+1
-0
install/sql/ispconfig3.sql
install/sql/ispconfig3.sql
+1
-0
interface/lib/classes/aps_crawler.inc.php
interface/lib/classes/aps_crawler.inc.php
+9
-3
interface/lib/classes/aps_guicontroller.inc.php
interface/lib/classes/aps_guicontroller.inc.php
+5
-1
interface/web/sites/aps_cron_apscrawler_if.php
interface/web/sites/aps_cron_apscrawler_if.php
+3
-0
server/lib/classes/aps_base.inc.php
server/lib/classes/aps_base.inc.php
+109
-0
server/lib/classes/aps_installer.inc.php
server/lib/classes/aps_installer.inc.php
+670
-0
server/mods-available/web_module.inc.php
server/mods-available/web_module.inc.php
+37
-1
server/plugins-available/aps_plugin.inc.php
server/plugins-available/aps_plugin.inc.php
+108
-0
No files found.
install/sql/incremental/upd_0034.sql
View file @
7d4360a0
...
...
@@ -46,6 +46,7 @@ CREATE TABLE IF NOT EXISTS `aps_packages` (
`category`
varchar
(
255
)
NOT
NULL
,
`version`
varchar
(
20
)
NOT
NULL
,
`release`
int
(
4
)
NOT
NULL
,
`package_url`
TEXT
NOT
NULL
,
`package_status`
int
(
1
)
NOT
NULL
DEFAULT
'2'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
;
...
...
install/sql/ispconfig3.sql
View file @
7d4360a0
...
...
@@ -94,6 +94,7 @@ CREATE TABLE IF NOT EXISTS `aps_packages` (
`category`
varchar
(
255
)
NOT
NULL
,
`version`
varchar
(
20
)
NOT
NULL
,
`release`
int
(
4
)
NOT
NULL
,
`package_url`
TEXT
NOT
NULL
,
`package_status`
int
(
1
)
NOT
NULL
DEFAULT
'2'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
;
...
...
interface/lib/classes/aps_crawler.inc.php
View file @
7d4360a0
...
...
@@ -34,6 +34,9 @@ require_once('aps_base.inc.php');
class
ApsCrawler
extends
ApsBase
{
public
$app_download_url_list
=
array
();
/**
* Constructor
*
...
...
@@ -290,6 +293,8 @@ class ApsCrawler extends ApsBase
$app_dl
=
parent
::
getXPathValue
(
$sxe
,
"entry[position()=1]/link[@a:type='aps']/@href"
);
$app_filesize
=
parent
::
getXPathValue
(
$sxe
,
"entry[position()=1]/link[@a:type='aps']/@length"
);
$app_metafile
=
parent
::
getXPathValue
(
$sxe
,
"entry[position()=1]/link[@a:type='meta']/@href"
);
$this
->
app_download_url_list
[
$app_name
.
'-'
.
$new_ver
.
'.app.zip'
]
=
$app_dl
;
// Skip ASP.net packages because they can't be used at all
$asp_handler
=
parent
::
getXPathValue
(
$sxe
,
'//aspnet:handler'
);
...
...
@@ -476,12 +481,13 @@ class ApsCrawler extends ApsBase
$path_query
=
$this
->
db
->
queryAllRecords
(
'SELECT path AS Path FROM aps_packages;'
);
foreach
(
$path_query
as
$path
)
$existing_packages
[]
=
$path
[
'Path'
];
$diff
=
array_diff
(
$existing_packages
,
$pkg_list
);
foreach
(
$diff
as
$todelete
)
foreach
(
$diff
as
$todelete
)
{
/*$this->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_ERROR_NOMETA."'
WHERE path = '".$this->db->quote($todelete)."';");*/
$tmp
=
$this
->
db
->
queryOneRecord
(
"SELECT id FROM aps_packages WHERE path = '"
.
$this
->
db
->
quote
(
$todelete
)
.
"';"
);
$this
->
db
->
datalogUpdate
(
'aps_packages'
,
"package_status = "
.
PACKAGE_ERROR_NOMETA
,
'id'
,
$tmp
[
'id'
]);
unset
(
$tmp
);
}
// Register all new packages
$new_packages
=
array_diff
(
$pkg_list
,
$existing_packages
);
...
...
@@ -515,10 +521,10 @@ class ApsCrawler extends ApsBase
".$this->db->quote($pkg_release).", ".PACKAGE_ENABLED.");");
*/
$insert_data
=
"(`path`, `name`, `category`, `version`, `release`, `package_status`) VALUES
$insert_data
=
"(`path`, `name`, `category`, `version`, `release`, `package_
url`, `package_
status`) VALUES
('"
.
$this
->
db
->
quote
(
$pkg
)
.
"', '"
.
$this
->
db
->
quote
(
$pkg_name
)
.
"',
'"
.
$this
->
db
->
quote
(
$pkg_category
)
.
"', '"
.
$this
->
db
->
quote
(
$pkg_version
)
.
"',
"
.
$this
->
db
->
quote
(
$pkg_release
)
.
", "
.
PACKAGE_ENABLED
.
");"
;
"
.
$this
->
db
->
quote
(
$pkg_release
)
.
",
'"
.
$this
->
db
->
quote
(
$this
->
app_download_url_list
[
$pkg
])
.
"',
"
.
PACKAGE_ENABLED
.
");"
;
$this
->
app
->
db
->
datalogInsert
(
'aps_packages'
,
$insert_data
,
'id'
);
}
...
...
interface/lib/classes/aps_guicontroller.inc.php
View file @
7d4360a0
...
...
@@ -199,6 +199,8 @@ class ApsGUIController extends ApsBase
{
global
$app
;
include_once
(
ISPC_WEB_PATH
.
'/sites/tools.inc.php'
);
$webserver_id
=
0
;
$websrv
=
$this
->
db
->
queryOneRecord
(
"SELECT * FROM web_domain WHERE domain = '"
.
$this
->
db
->
quote
(
$settings
[
'main_domain'
])
.
"';"
);
if
(
!
empty
(
$websrv
))
$webserver_id
=
$websrv
[
'server_id'
];
...
...
@@ -256,9 +258,11 @@ class ApsGUIController extends ApsBase
if
(
$tmp
[
'number'
]
==
0
)
break
;
}
$mysql_db_password
=
$settings
[
'main_database_password'
];
//* Create the mysql database
$insert_data
=
"(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `parent_domain_id`, `type`, `database_name`, `database_user`, `database_password`, `database_charset`, `remote_access`, `remote_ips`, `backup_copies`, `active`, `backup_interval`)
VALUES( "
.
$websrv
[
'sys_userid'
]
.
", "
.
$websrv
[
'sys_groupid'
]
.
", 'riud', '"
.
$websrv
[
'sys_perm_group'
]
.
"', '',
$mysql_db_server_id
, "
.
$websrv
[
'domain_id'
]
.
", 'mysql', '
$mysql_db_name
', '
$mysql_db_user
',
'
$mysql_db_password
'
, '', '
$mysql_db_remote_access
', '
$mysql_db_remote_ips
', "
.
$websrv
[
'backup_copies'
]
.
", 'y', '"
.
$websrv
[
'backup_interval'
]
.
"')"
;
VALUES( "
.
$websrv
[
'sys_userid'
]
.
", "
.
$websrv
[
'sys_groupid'
]
.
", 'riud', '"
.
$websrv
[
'sys_perm_group'
]
.
"', '',
$mysql_db_server_id
, "
.
$websrv
[
'domain_id'
]
.
", 'mysql', '
$mysql_db_name
', '
$mysql_db_user
',
PASSWORD('
$mysql_db_password
')
, '', '
$mysql_db_remote_access
', '
$mysql_db_remote_ips
', "
.
$websrv
[
'backup_copies'
]
.
", 'y', '"
.
$websrv
[
'backup_interval'
]
.
"')"
;
$app
->
db
->
datalogInsert
(
'web_database'
,
$insert_data
,
'database_id'
);
//* Add db details to package settings
...
...
interface/web/sites/aps_cron_apscrawler_if.php
View file @
7d4360a0
...
...
@@ -32,6 +32,9 @@ require_once('../../lib/app.inc.php');
//require_once('classes/class.crawler.php');
$app
->
load
(
'aps_crawler'
);
if
(
!@
ini_get
(
'allow_url_fopen'
))
$app
->
error
(
'allow_url_fopen is not enabled'
);
if
(
!
function_exists
(
'curl_version'
))
$app
->
error
(
'cURL is not available'
);
$log_prefix
=
'APS crawler cron: '
;
$aps
=
new
ApsCrawler
(
$app
,
true
);
// true = Interface mode, false = Server mode
...
...
server/lib/classes/aps_base.inc.php
0 → 100644
View file @
7d4360a0
<?php
/*
Copyright (c) 2012, ISPConfig UG
Contributors: web wack creations, http://www.web-wack.at
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Constants describing instances
define
(
'INSTANCE_PENDING'
,
0
);
define
(
'INSTANCE_INSTALL'
,
1
);
define
(
'INSTANCE_ERROR'
,
2
);
define
(
'INSTANCE_SUCCESS'
,
3
);
define
(
'INSTANCE_REMOVE'
,
4
);
// Constants describing packages
define
(
'PACKAGE_LOCKED'
,
1
);
define
(
'PACKAGE_ENABLED'
,
2
);
define
(
'PACKAGE_OUTDATED'
,
3
);
define
(
'PACKAGE_ERROR_NOMETA'
,
4
);
class
ApsBase
{
protected
$app
=
null
;
protected
$db
=
null
;
protected
$log_prefix
=
''
;
protected
$fetch_url
=
''
;
protected
$aps_version
=
''
;
protected
$packages_dir
=
''
;
protected
$temp_pkg_dir
=
''
;
protected
$interface_pkg_dir
=
''
;
protected
$interface_mode
=
false
;
// server mode by default
/**
* Constructor
*
* @param $app the application instance (db handle + log method)
* @param $interface_mode act in interface (true) or server mode (false)
* @param $log_prefix a prefix to set before all log entries
*/
public
function
__construct
(
$app
,
$log_prefix
=
'APS: '
,
$interface_mode
=
false
)
{
$this
->
db
=
$app
->
db
;
$this
->
app
=
$app
;
$this
->
log_prefix
=
$log_prefix
;
$this
->
interface_mode
=
$interface_mode
;
$this
->
fetch_url
=
'apscatalog.com'
;
$this
->
aps_version
=
'1'
;
$this
->
packages_dir
=
ISPC_ROOT_PATH
.
'/aps_packages'
;
$this
->
interface_pkg_dir
=
ISPC_ROOT_PATH
.
'/web/sites/aps_meta_packages'
;
}
/**
* Converts a given value to it's native representation in 1024 units
*
* @param $value the size to convert
* @return integer and string
*/
public
function
convertSize
(
$value
)
{
$unit
=
array
(
'Bytes'
,
'KB'
,
'MB'
,
'GB'
,
'TB'
);
return
@
round
(
$value
/
pow
(
1024
,
(
$i
=
floor
(
log
(
$value
,
1024
)))),
2
)
.
' '
.
$unit
[
$i
];
}
/**
* Determine a specific xpath from a given SimpleXMLElement handle. If the
* element is found, it's string representation is returned. If not,
* the return value will stay empty
*
* @param $xml_handle the SimpleXMLElement handle
* @param $query the XPath query
* @param $array define whether to return an array or a string
* @return $ret the return string
*/
protected
function
getXPathValue
(
$xml_handle
,
$query
,
$array
=
false
)
{
$ret
=
''
;
$xp_result
=
@
(
$xml_handle
->
xpath
(
$query
))
?
$xml_handle
->
xpath
(
$query
)
:
false
;
if
(
$xp_result
!==
false
)
$ret
=
((
$array
===
false
)
?
(
string
)
$xp_result
[
0
]
:
$xp_result
);
return
$ret
;
}
}
?>
\ No newline at end of file
server/lib/classes/aps_installer.inc.php
0 → 100644
View file @
7d4360a0
This diff is collapsed.
Click to expand it.
server/mods-available/web_module.inc.php
View file @
7d4360a0
...
...
@@ -52,7 +52,19 @@ class web_module {
'web_folder_user_delete'
,
'web_backup_insert'
,
'web_backup_update'
,
'web_backup_delete'
);
'web_backup_delete'
,
'aps_instance_insert'
,
'aps_instance_update'
,
'aps_instance_delete'
,
'aps_instance_setting_insert'
,
'aps_instance_setting_update'
,
'aps_instance_setting_delete'
,
'aps_package_insert'
,
'aps_package_update'
,
'aps_package_delete'
,
'aps_setting_insert'
,
'aps_setting_update'
,
'aps_setting_delete'
);
//* This function is called during ispconfig installation to determine
// if a symlink shall be created for this plugin.
...
...
@@ -98,6 +110,10 @@ class web_module {
$app
->
modules
->
registerTableHook
(
'web_folder'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'web_folder_user'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'web_backup'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'aps_instances'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'aps_instances_settings'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'aps_packages'
,
'web_module'
,
'process'
);
$app
->
modules
->
registerTableHook
(
'aps_settings'
,
'web_module'
,
'process'
);
// Register service
$app
->
services
->
registerService
(
'httpd'
,
'web_module'
,
'restartHttpd'
);
...
...
@@ -149,6 +165,26 @@ class web_module {
if
(
$action
==
'u'
)
$app
->
plugins
->
raiseEvent
(
'web_backup_update'
,
$data
);
if
(
$action
==
'd'
)
$app
->
plugins
->
raiseEvent
(
'web_backup_delete'
,
$data
);
break
;
case
'aps_instances'
:
if
(
$action
==
'i'
)
$app
->
plugins
->
raiseEvent
(
'aps_instance_insert'
,
$data
);
if
(
$action
==
'u'
)
$app
->
plugins
->
raiseEvent
(
'aps_instance_update'
,
$data
);
if
(
$action
==
'd'
)
$app
->
plugins
->
raiseEvent
(
'aps_instance_delete'
,
$data
);
break
;
case
'aps_instances_settings'
:
if
(
$action
==
'i'
)
$app
->
plugins
->
raiseEvent
(
'aps_instance_setting_insert'
,
$data
);
if
(
$action
==
'u'
)
$app
->
plugins
->
raiseEvent
(
'aps_instance_setting_update'
,
$data
);
if
(
$action
==
'd'
)
$app
->
plugins
->
raiseEvent
(
'aps_instance_setting_delete'
,
$data
);
break
;
case
'aps_packages'
:
if
(
$action
==
'i'
)
$app
->
plugins
->
raiseEvent
(
'aps_package_insert'
,
$data
);
if
(
$action
==
'u'
)
$app
->
plugins
->
raiseEvent
(
'aps_package_update'
,
$data
);
if
(
$action
==
'd'
)
$app
->
plugins
->
raiseEvent
(
'aps_package_delete'
,
$data
);
break
;
case
'aps_settings'
:
if
(
$action
==
'i'
)
$app
->
plugins
->
raiseEvent
(
'aps_setting_insert'
,
$data
);
if
(
$action
==
'u'
)
$app
->
plugins
->
raiseEvent
(
'aps_setting_update'
,
$data
);
if
(
$action
==
'd'
)
$app
->
plugins
->
raiseEvent
(
'aps_setting_delete'
,
$data
);
break
;
}
// end switch
}
// end function
...
...
server/plugins-available/aps_plugin.inc.php
0 → 100644
View file @
7d4360a0
<?php
/*
Copyright (c) 2012, ISPConfig UG
Contributors: web wack creations, http://www.web-wack.at
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once
(
ISPC_ROOT_PATH
.
'/lib/classes/aps_installer.inc.php'
);
//require_once(ISPC_ROOT_PATH.'/lib/classes/class.installer.php');
class
aps_plugin
{
public
$plugin_name
=
'aps_plugin'
;
public
$class_name
=
'aps_plugin'
;
//* This function is called during ispconfig installation to determine
// if a symlink shall be created for this plugin.
function
onInstall
()
{
global
$conf
;
if
(
$conf
[
'services'
][
'web'
]
==
true
)
{
return
true
;
}
else
{
return
false
;
}
}
/**
* This method gets called when the plugin is loaded
*/
public
function
onLoad
()
{
global
$app
;
// Register the available events
$app
->
plugins
->
registerEvent
(
'aps_instance_install'
,
$this
->
plugin_name
,
'install'
);
$app
->
plugins
->
registerEvent
(
'aps_instance_update'
,
$this
->
plugin_name
,
'install'
);
$app
->
plugins
->
registerEvent
(
'aps_instance_delete'
,
$this
->
plugin_name
,
'delete'
);
}
/**
* (Re-)install a package
*/
public
function
install
(
$event_name
,
$data
)
{
global
$app
,
$conf
;
$app
->
log
(
"Starting APS install"
,
LOGLEVEL_DEBUG
);
if
(
!
isset
(
$data
[
'new'
][
'id'
]))
return
false
;
$instanceid
=
$data
[
'new'
][
'id'
];
if
(
$data
[
'new'
][
'instance_status'
]
==
INSTANCE_INSTALL
)
{
$aps
=
new
ApsInstaller
(
$app
);
$app
->
log
(
"Running installHandler"
,
LOGLEVEL_DEBUG
);
$aps
->
installHandler
(
$instanceid
,
'install'
);
}
}
/**
* Update an existing instance (currently unused)
*/
/*
public function update($event_name, $data)
{
}
*/
/**
* Uninstall an instance
*/
public
function
delete
(
$event_name
,
$data
)
{
global
$app
,
$conf
;
if
(
!
isset
(
$data
[
'new'
][
'id'
]))
return
false
;
$instanceid
=
$data
[
'new'
][
'id'
];
if
(
$data
[
'new'
][
'instance_status'
]
==
INSTANCE_REMOVE
)
{
$aps
=
new
ApsInstaller
(
$app
);
$aps
->
installHandler
(
$instanceid
,
'install'
);
}
}
}
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment