Skip to content

Commit

Permalink
Typo fix, removed unused code & updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TimZ99 committed Jul 12, 2018
1 parent 476c59e commit f21f3db
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/includes/functions.inc.php
Expand Up @@ -669,7 +669,7 @@ function psm_GET($key, $alt = null) {
/**
* Try existence of a POST var, if not return the alternative
* @param string $key
* @param string $alt
* @param string|array|bool $alt
* @return mixed
*/
function psm_POST($key, $alt = null) {
Expand Down
2 changes: 1 addition & 1 deletion src/psm/Module/Install/Controller/InstallController.php
Expand Up @@ -58,7 +58,7 @@ function __construct(Database $db, \Twig_Environment $twig) {
'index', 'config', 'install'
), 'index');

$this->twig->addGlobal('subtitle', psm_get_lang('system,', 'install'));
$this->twig->addGlobal('subtitle', psm_get_lang('system', 'install'));
}

/**
Expand Down
Expand Up @@ -38,7 +38,7 @@ function __construct(Database $db, \Twig_Environment $twig) {

/**
* Get all servers for the current user
* @param int $server_id if true only that server will be retrieved.
* @param Countable|array|\PDOStatement $server_id (int) if true only that server will be retrieved.
* @return array
*/
public function getServers($server_id = null) {
Expand Down
4 changes: 2 additions & 2 deletions src/psm/Module/Server/Controller/LogController.php
Expand Up @@ -137,7 +137,7 @@ protected function executeDelete() {
* Get all the log entries for a specific $type
*
* @param string $type status/email/sms
* @return array
* @return \PDOStatement array
*/
public function getEntries($type) {
$sql_join = '';
Expand Down Expand Up @@ -172,7 +172,7 @@ public function getEntries($type) {
* Get all the user entries for a specific $log_id
*
* @param $log_id
* @return array
* @return \PDOStatement array
*/
protected function getLogUsers($log_id) {
return $this->db->query(
Expand Down
8 changes: 3 additions & 5 deletions src/psm/Module/Server/Controller/ServerController.php
Expand Up @@ -239,8 +239,6 @@ protected function executeSave() {
return $this->executeIndex();
}

$encrypted_password = '';

if (!empty($_POST['website_password'])) {
$new_password = psm_POST('website_password');

Expand All @@ -251,7 +249,7 @@ protected function executeSave() {
if ($new_password == $hash) {
$encrypted_password = $edit_server['website_password'];
} else {
$encrypted_password = psm_password_encrypt($this->server_id.psm_get_conf('password_encrypt_key'), $new_password);
$encrypted_password = psm_password_encrypt(strval($this->server_id).psm_get_conf('password_encrypt_key'), $new_password);
}
} else {
// We need the server id to encrypt the password. Encryption will be done after the server is added
Expand All @@ -263,7 +261,7 @@ protected function executeSave() {
'label' => trim(strip_tags(psm_POST('label', ''))),
'ip' => trim(strip_tags(psm_POST('ip', ''))),
'timeout' => (isset($_POST['timeout']) && intval($_POST['timeout']) > 0) ? intval($_POST['timeout']) : null,
'website_username' => psm_POST('website_username', null),
'website_username' => psm_POST('website_username'),
'website_password' => $encrypted_password,
'port' => intval(psm_POST('port', 0)),
'type' => psm_POST('type', ''),
Expand Down Expand Up @@ -332,7 +330,7 @@ protected function executeSave() {
if (!empty($_POST['website_password'])) {
$cleanWebsitePassword = array(
'website_password' => psm_password_encrypt(
$this->server_id.psm_get_conf('password_encrypt_key'),
strval($this->server_id).psm_get_conf('password_encrypt_key'),
psm_POST('website_password')
),
);
Expand Down
14 changes: 7 additions & 7 deletions src/psm/Service/Database.php
Expand Up @@ -104,7 +104,7 @@ function __construct($host = null, $user = null, $pass = null, $db = null, $port
* If you dont want to fetch a result, use exec().
* @param string $query SQL query
* @param boolean $fetch automatically fetch results, or return PDOStatement?
* @return array|\PDOStatement if $fetch = true, array, otherwise \PDOStatement
* @return \PDOStatement|int|bool|array object
*/
public function query($query, $fetch = true) {
// Execute query and process results
Expand Down Expand Up @@ -140,7 +140,7 @@ public function query($query, $fetch = true) {
/**
* Execute SQL statement and return number of affected rows
* @param string $query
* @return int|\PDOStatement
* @return int
*/
public function exec($query) {
try {
Expand Down Expand Up @@ -183,7 +183,7 @@ public function execute($query, $parameters, $fetch = true) {
* @param string $limit limit. for example: 0,30
* @param array $orderby fields for the orderby clause
* @param string $direction ASC or DESC. Defaults to ASC
* @return array multi dimensional array with results
* @return \PDOStatement array multi dimensional array with results
*/
public function select($table, $where = null, $fields = null, $limit = '', $orderby = null, $direction = 'ASC') {
// build query
Expand Down Expand Up @@ -253,7 +253,8 @@ public function delete($table, $where = null) {
* Insert or update data to the database
* @param string $table table name
* @param array $data data to save or insert
* @param mixed $where either string ('user_id=2' or just '2' (works only with primary field)) or array with where clause (only when updating)
* @param string|array $where either string ('user_id=2' or just '2' (works only with primary field)) or array with where clause (only when updating)
* @return int|array|\PDOStatement
*/
public function save($table, array $data, $where = null) {
if ($where === null) {
Expand All @@ -280,9 +281,8 @@ public function save($table, array $data, $where = null) {

if ($exec) {
return $this->exec($query);
} else {
return $this->query($query);
}
return $this->query($query);
}

/**
Expand All @@ -294,7 +294,7 @@ public function save($table, array $data, $where = null) {
* that do not match the fields provided in the first record will be
* skipped.
*
* @param type $table
* @param string $table
* @param array $data
* @return \PDOStatement
* @see insert()
Expand Down
2 changes: 1 addition & 1 deletion src/psm/Service/User.php
Expand Up @@ -374,7 +374,7 @@ public function verifyPasswordResetToken($user_id, $token) {

/**
* Change the password of a user
* @param int $user_id
* @param int|\PDOStatement $user_id
* @param string $password
* @return boolean TRUE on success, FALSE on failure
*/
Expand Down
15 changes: 7 additions & 8 deletions src/psm/Txtmsg/CMBulkSMS.php
Expand Up @@ -37,11 +37,11 @@
* Requirements: cURL v7.18.1+ and OpenSSL 0.9.8j+
*/
class CMBulkSMS extends Core {
/** @var bool|null True when cURL request succeeded */
public $result;
/** @var bool True when cURL request succeeded */
public $result = true;

/** @var string|null Contains error message if cURL request failed */
public $error;
/** @var string Contains error message if cURL request failed */
public $error = '';

/** @var bool Set to true for debug output/logging */
protected $debug = false;
Expand Down Expand Up @@ -75,7 +75,7 @@ class CMBulkSMS extends Core {
*
* @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Csample_requests
* @param string $message Your text message
* @return boolean True when cURL request was successful
* @return bool|string true when cURL request was successful, otherwise string with error message
*/
public function sendSMS($message) {
// Check if recipient and text message are available
Expand Down Expand Up @@ -210,12 +210,11 @@ protected function executeCurlRequest() {
$cErrorCode = curl_errno($cr);
curl_close($cr);

$this->result = true;
// set result and log error if needed
if ($cError) {
$this->error = 'Response: CM SMS API:'.$cResponse.' cURL Error Code: '.$cErrorCode.'"'.$cError.'"';
error_log($this->error, E_USER_ERROR);
$this->result = $this->error;
$this->result = false;
}

// Debug output
Expand All @@ -226,6 +225,6 @@ protected function executeCurlRequest() {
echo $debug;
}

return $this->result;
return $this->result ? $this->result : $this->error;
}
}
2 changes: 1 addition & 1 deletion src/psm/Txtmsg/Core.php
Expand Up @@ -56,7 +56,7 @@ public function setOriginator($originator) {
/**
* Add new recipient to the list
*
* @param unknown_type $recipient
* @param string|int $recipient
*/
public function addRecipients($recipient) {
array_push($this->recipients, $recipient);
Expand Down
3 changes: 1 addition & 2 deletions src/psm/Txtmsg/Smsglobal.php
Expand Up @@ -75,8 +75,7 @@ public function sendSMS($message) {

$result = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);

$result = curl_exec($curl);

$err = curl_errno($curl);

if ($err != 0 || substr($result, 0, 5) != "OK: 0") {
Expand Down
2 changes: 1 addition & 1 deletion src/psm/Util/Server/ServerValidator.php
Expand Up @@ -45,7 +45,7 @@ public function __construct(\psm\Service\Database $db) {

/**
* Check if the server id exists
* @param int $server_id
* @param int|\PDOStatement $server_id
* @return boolean
* @throws \InvalidArgumentException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/psm/Util/Server/Updater/StatusNotifier.php
Expand Up @@ -366,7 +366,7 @@ protected function notifyByTelegram($users) {
/**
* Get all users for the provided server id
* @param int $server_id
* @return array
* @return \PDOStatement array
*/
public function getUsers($server_id) {
// find all the users with this server listed
Expand Down

0 comments on commit f21f3db

Please sign in to comment.