add comment to cron.d-template; fix linker class to void double-slash after redirectTo, fixes #1372

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2014-01-30 11:42:16 +01:00
parent 658a9288f1
commit c5cb91a882
7 changed files with 60 additions and 66 deletions

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* This file is part of the Froxlor project. * This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors). * Copyright (c) 2003-2009 the SysCP Team (see authors).
@@ -15,8 +16,8 @@
* *
*/ */
class linker class linker {
{
private $protocol = ''; private $protocol = '';
private $username = ''; private $username = '';
private $password = ''; private $password = '';
@@ -26,23 +27,21 @@ class linker
private $args = array(); private $args = array();
public function __construct($file = 'index.php', $sessionid = '', $hostname = '', $protocol = '', $port = '', $username = '', $password = '') public function __construct($file = 'index.php', $sessionid = '', $hostname = '', $protocol = '', $port = '', $username = '', $password = '') {
{ // Set the basic parts of our URL
# Set the basic parts of our URL
$this->protocol = $protocol; $this->protocol = $protocol;
$this->username = $username; $this->username = $username;
$this->password = $password; $this->password = $password;
$this->hostname = $hostname; $this->hostname = $hostname;
$this->port = $port; $this->port = $port;
$this->filename = $file; $this->filename = $file;
# @TODO: Remove this // @TODO: Remove this
$this->args['s'] = $sessionid; $this->args['s'] = $sessionid;
} }
public function __set($key, $value) public function __set($key, $value) {
{
switch(strtolower($key)) switch (strtolower($key)) {
{
case 'protocol': $this->protocol = $value; break; case 'protocol': $this->protocol = $value; break;
case 'username': $this->username = $value; break; case 'username': $this->username = $value; break;
case 'password': $this->password = $value; break; case 'password': $this->password = $value; break;
@@ -54,111 +53,94 @@ class linker
return true; return true;
} }
public function add($key, $value) public function add($key, $value) {
{ // Add a new value to our parameters (overwrite = enabled)
# Add a new value to our parameters (overwrite = enabled)
$this->args[$key] = $value; $this->args[$key] = $value;
} }
public function del($key) public function del($key) {
{ // If the key exists in our array -> delete it
# If the key exists in our array -> delete it if (isset($this->args[$key])) {
if (isset($this->args[$key]))
{
unset($this->args[$key]); unset($this->args[$key]);
} }
} }
public function delAll() public function delAll() {
{ // Just resetting the array
# Just resetting the array // Until the sessionid can be removed: save it
# Until the sessionid can be removed: save it // @TODO: Remove this
# @TODO: Remove this
$this->args = array('s' => $this->args['s']); $this->args = array('s' => $this->args['s']);
} }
public function getLink() public function getLink() {
{
$link = ''; $link = '';
# Build the basic URL // Build the basic URL
if (strlen($this->protocol) > 0 && strlen($this->hostname) > 0) if (strlen($this->protocol) > 0 && strlen($this->hostname) > 0) {
{
$link = $this->protocol . '://'; $link = $this->protocol . '://';
} }
# Let's see if we shall use a username in the URL // Let's see if we shall use a username in the URL
# This is only available if a hostname is used as well // This is only available if a hostname is used as well
if (strlen($this->username) > 0 && strlen($this->hostname) > 0) if (strlen($this->username) > 0 && strlen($this->hostname) > 0) {
{
$link .= urlencode($this->username); $link .= urlencode($this->username);
# Maybe we even have to append a password? // Maybe we even have to append a password?
if ($this->password != '') if ($this->password != '') {
{
$link .= ':' . urlencode($this->password); $link .= ':' . urlencode($this->password);
} }
# At least a username was given, add the @ to allow appending the hostname // At least a username was given, add the @ to allow appending the hostname
$link .= '@'; $link .= '@';
} }
# Add hostname, port and filename to the URL // Add hostname, port and filename to the URL
if (strlen($this->hostname) > 0) if (strlen($this->hostname) > 0) {
{
$link .= $this->hostname; $link .= $this->hostname;
# A port may only be used if hostname is used as well // A port may only be used if hostname is used as well
if (strlen($this->port) > 0) if (strlen($this->port) > 0) {
{
$link .= ':' . $this->port; $link .= ':' . $this->port;
} }
$link .= '/';
} }
# Overwrite $this->args with parameters of this function (if necessary) // Overwrite $this->args with parameters of this function (if necessary)
if(func_num_args() == 1 && is_array(func_get_arg(0))) if (func_num_args() == 1 && is_array(func_get_arg(0))) {
{
$arguments = func_get_arg(0); $arguments = func_get_arg(0);
$this->args = array_merge($this->args, $arguments); $this->args = array_merge($this->args, $arguments);
} }
# temporary until frontcontroller exists // temporary until frontcontroller exists
# We got a section in the URL -> morph AREA and section into filename // We got a section in the URL -> morph AREA and section into filename
# @TODO: Remove this // @TODO: Remove this
if (isset($this->args['section']) && strlen($this->args['section']) > 0) if (isset($this->args['section']) && strlen($this->args['section']) > 0) {
{
$link .= AREA . '_' . $this->args['section'] . '.php'; $link .= AREA . '_' . $this->args['section'] . '.php';
unset($this->args['section']); unset($this->args['section']);
} } else {
else // filename has a prefixed slash
{
$link .= $this->filename; $link .= $this->filename;
} }
# Let's see if we are done (no arguments in query) // Let's see if we are done (no arguments in query)
if (count($this->args) == 0) if (count($this->args) == 0) {
{
return $link; return $link;
} }
# We have parameters, add them with a "?" // We have parameters, add them with a "?"
$link .= "?"; $link .= "?";
# Loop through arguments and add them to the link // Loop through arguments and add them to the link
foreach ($this->args as $key => $value) foreach ($this->args as $key => $value) {
{ // For all but the first argument, prepend "&amp;"
# For all but the first argument, prepend "&amp;" if (substr($link, -1) != "?") {
if (substr($link, -1) != "?")
{
$link .= "&"; $link .= "&";
} }
# Encode parameters and add them to the link // Encode parameters and add them to the link
$link .= urlencode($key) . '=' . urlencode($value); $link .= urlencode($key) . '=' . urlencode($value);
} }
# Reset our class for further use // Reset our class for further use
$this->delAll(); $this->delAll();
return $link; return $link;
} }

View File

@@ -5,4 +5,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# #
# Regular cron jobs for the froxlor package # Regular cron jobs for the froxlor package
# #
# Please check that all following paths are correct
#
*/5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q <BASE_PATH>scripts/froxlor_master_cronjob.php */5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q <BASE_PATH>scripts/froxlor_master_cronjob.php

View File

@@ -5,4 +5,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# #
# Regular cron jobs for the froxlor package # Regular cron jobs for the froxlor package
# #
# Please check that all following paths are correct
#
*/5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q <BASE_PATH>scripts/froxlor_master_cronjob.php */5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q <BASE_PATH>scripts/froxlor_master_cronjob.php

View File

@@ -5,4 +5,6 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin
# #
# Regular cron jobs for the froxlor package # Regular cron jobs for the froxlor package
# #
# Please check that all following paths are correct
#
*/5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q /srv/www/froxlor/scripts/froxlor_master_cronjob.php */5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q /srv/www/froxlor/scripts/froxlor_master_cronjob.php

View File

@@ -5,4 +5,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# #
# Regular cron jobs for the froxlor package # Regular cron jobs for the froxlor package
# #
# Please check that all following paths are correct
#
*/5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q <BASE_PATH>scripts/froxlor_master_cronjob.php */5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q <BASE_PATH>scripts/froxlor_master_cronjob.php

View File

@@ -5,4 +5,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# #
# Regular cron jobs for the froxlor package # Regular cron jobs for the froxlor package
# #
# Please check that all following paths are correct
#
*/5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q <BASE_PATH>scripts/froxlor_master_cronjob.php */5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q <BASE_PATH>scripts/froxlor_master_cronjob.php

View File

@@ -5,4 +5,6 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# #
# Regular cron jobs for the froxlor package # Regular cron jobs for the froxlor package
# #
# Please check that all following paths are correct
#
*/5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q <BASE_PATH>scripts/froxlor_master_cronjob.php */5 * * * * root /usr/bin/nice -n 5 /usr/bin/php5 -q <BASE_PATH>scripts/froxlor_master_cronjob.php