Typo fix, removed unused code & updated documentation

pull/612/merge
TimZ99 2018-07-11 00:27:06 +02:00
parent 476c59eb47
commit f21f3db19e
No known key found for this signature in database
GPG Key ID: 4D8268DC68E8339D
12 changed files with 27 additions and 31 deletions

View File

@ -669,7 +669,7 @@ function psm_GET($key, $alt = null) {
/** /**
* Try existence of a POST var, if not return the alternative * Try existence of a POST var, if not return the alternative
* @param string $key * @param string $key
* @param string $alt * @param string|array|bool $alt
* @return mixed * @return mixed
*/ */
function psm_POST($key, $alt = null) { function psm_POST($key, $alt = null) {

View File

@ -58,7 +58,7 @@ class InstallController extends AbstractController {
'index', 'config', 'install' 'index', 'config', 'install'
), 'index'); ), 'index');
$this->twig->addGlobal('subtitle', psm_get_lang('system,', 'install')); $this->twig->addGlobal('subtitle', psm_get_lang('system', 'install'));
} }
/** /**

View File

@ -38,7 +38,7 @@ abstract class AbstractServerController extends AbstractController {
/** /**
* Get all servers for the current user * 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 * @return array
*/ */
public function getServers($server_id = null) { public function getServers($server_id = null) {

View File

@ -137,7 +137,7 @@ class LogController extends AbstractServerController {
* Get all the log entries for a specific $type * Get all the log entries for a specific $type
* *
* @param string $type status/email/sms * @param string $type status/email/sms
* @return array * @return \PDOStatement array
*/ */
public function getEntries($type) { public function getEntries($type) {
$sql_join = ''; $sql_join = '';
@ -172,7 +172,7 @@ class LogController extends AbstractServerController {
* Get all the user entries for a specific $log_id * Get all the user entries for a specific $log_id
* *
* @param $log_id * @param $log_id
* @return array * @return \PDOStatement array
*/ */
protected function getLogUsers($log_id) { protected function getLogUsers($log_id) {
return $this->db->query( return $this->db->query(

View File

@ -239,8 +239,6 @@ class ServerController extends AbstractServerController {
return $this->executeIndex(); return $this->executeIndex();
} }
$encrypted_password = '';
if (!empty($_POST['website_password'])) { if (!empty($_POST['website_password'])) {
$new_password = psm_POST('website_password'); $new_password = psm_POST('website_password');
@ -251,7 +249,7 @@ class ServerController extends AbstractServerController {
if ($new_password == $hash) { if ($new_password == $hash) {
$encrypted_password = $edit_server['website_password']; $encrypted_password = $edit_server['website_password'];
} else { } 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 { } else {
// We need the server id to encrypt the password. Encryption will be done after the server is added // We need the server id to encrypt the password. Encryption will be done after the server is added
@ -263,7 +261,7 @@ class ServerController extends AbstractServerController {
'label' => trim(strip_tags(psm_POST('label', ''))), 'label' => trim(strip_tags(psm_POST('label', ''))),
'ip' => trim(strip_tags(psm_POST('ip', ''))), 'ip' => trim(strip_tags(psm_POST('ip', ''))),
'timeout' => (isset($_POST['timeout']) && intval($_POST['timeout']) > 0) ? intval($_POST['timeout']) : null, '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, 'website_password' => $encrypted_password,
'port' => intval(psm_POST('port', 0)), 'port' => intval(psm_POST('port', 0)),
'type' => psm_POST('type', ''), 'type' => psm_POST('type', ''),
@ -332,7 +330,7 @@ class ServerController extends AbstractServerController {
if (!empty($_POST['website_password'])) { if (!empty($_POST['website_password'])) {
$cleanWebsitePassword = array( $cleanWebsitePassword = array(
'website_password' => psm_password_encrypt( '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') psm_POST('website_password')
), ),
); );

View File

@ -104,7 +104,7 @@ class Database {
* If you dont want to fetch a result, use exec(). * If you dont want to fetch a result, use exec().
* @param string $query SQL query * @param string $query SQL query
* @param boolean $fetch automatically fetch results, or return PDOStatement? * @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) { public function query($query, $fetch = true) {
// Execute query and process results // Execute query and process results
@ -140,7 +140,7 @@ class Database {
/** /**
* Execute SQL statement and return number of affected rows * Execute SQL statement and return number of affected rows
* @param string $query * @param string $query
* @return int|\PDOStatement * @return int
*/ */
public function exec($query) { public function exec($query) {
try { try {
@ -183,7 +183,7 @@ class Database {
* @param string $limit limit. for example: 0,30 * @param string $limit limit. for example: 0,30
* @param array $orderby fields for the orderby clause * @param array $orderby fields for the orderby clause
* @param string $direction ASC or DESC. Defaults to ASC * @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') { public function select($table, $where = null, $fields = null, $limit = '', $orderby = null, $direction = 'ASC') {
// build query // build query
@ -253,7 +253,8 @@ class Database {
* Insert or update data to the database * Insert or update data to the database
* @param string $table table name * @param string $table table name
* @param array $data data to save or insert * @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) { public function save($table, array $data, $where = null) {
if ($where === null) { if ($where === null) {
@ -280,9 +281,8 @@ class Database {
if ($exec) { if ($exec) {
return $this->exec($query); return $this->exec($query);
} else {
return $this->query($query);
} }
return $this->query($query);
} }
/** /**
@ -294,7 +294,7 @@ class Database {
* that do not match the fields provided in the first record will be * that do not match the fields provided in the first record will be
* skipped. * skipped.
* *
* @param type $table * @param string $table
* @param array $data * @param array $data
* @return \PDOStatement * @return \PDOStatement
* @see insert() * @see insert()

View File

@ -374,7 +374,7 @@ class User {
/** /**
* Change the password of a user * Change the password of a user
* @param int $user_id * @param int|\PDOStatement $user_id
* @param string $password * @param string $password
* @return boolean TRUE on success, FALSE on failure * @return boolean TRUE on success, FALSE on failure
*/ */

View File

@ -37,11 +37,11 @@ namespace psm\Txtmsg;
* Requirements: cURL v7.18.1+ and OpenSSL 0.9.8j+ * Requirements: cURL v7.18.1+ and OpenSSL 0.9.8j+
*/ */
class CMBulkSMS extends Core { class CMBulkSMS extends Core {
/** @var bool|null True when cURL request succeeded */ /** @var bool True when cURL request succeeded */
public $result; public $result = true;
/** @var string|null Contains error message if cURL request failed */ /** @var string Contains error message if cURL request failed */
public $error; public $error = '';
/** @var bool Set to true for debug output/logging */ /** @var bool Set to true for debug output/logging */
protected $debug = false; protected $debug = false;
@ -75,7 +75,7 @@ class CMBulkSMS extends Core {
* *
* @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Csample_requests * @see https://docs.cmtelecom.com/bulk-sms/v1.0#/send_a_message%7Csample_requests
* @param string $message Your text message * @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) { public function sendSMS($message) {
// Check if recipient and text message are available // Check if recipient and text message are available
@ -210,12 +210,11 @@ class CMBulkSMS extends Core {
$cErrorCode = curl_errno($cr); $cErrorCode = curl_errno($cr);
curl_close($cr); curl_close($cr);
$this->result = true;
// set result and log error if needed // set result and log error if needed
if ($cError) { if ($cError) {
$this->error = 'Response: CM SMS API:'.$cResponse.' cURL Error Code: '.$cErrorCode.'"'.$cError.'"'; $this->error = 'Response: CM SMS API:'.$cResponse.' cURL Error Code: '.$cErrorCode.'"'.$cError.'"';
error_log($this->error, E_USER_ERROR); error_log($this->error, E_USER_ERROR);
$this->result = $this->error; $this->result = false;
} }
// Debug output // Debug output
@ -226,6 +225,6 @@ class CMBulkSMS extends Core {
echo $debug; echo $debug;
} }
return $this->result; return $this->result ? $this->result : $this->error;
} }
} }

View File

@ -56,7 +56,7 @@ abstract class Core implements TxtmsgInterface {
/** /**
* Add new recipient to the list * Add new recipient to the list
* *
* @param unknown_type $recipient * @param string|int $recipient
*/ */
public function addRecipients($recipient) { public function addRecipients($recipient) {
array_push($this->recipients, $recipient); array_push($this->recipients, $recipient);

View File

@ -75,8 +75,7 @@ class Smsglobal extends Core {
$result = curl_exec($curl); $result = curl_exec($curl);
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE); $httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$result = curl_exec($curl);
$err = curl_errno($curl); $err = curl_errno($curl);
if ($err != 0 || substr($result, 0, 5) != "OK: 0") { if ($err != 0 || substr($result, 0, 5) != "OK: 0") {

View File

@ -45,7 +45,7 @@ class ServerValidator {
/** /**
* Check if the server id exists * Check if the server id exists
* @param int $server_id * @param int|\PDOStatement $server_id
* @return boolean * @return boolean
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */

View File

@ -366,7 +366,7 @@ class StatusNotifier {
/** /**
* Get all users for the provided server id * Get all users for the provided server id
* @param int $server_id * @param int $server_id
* @return array * @return \PDOStatement array
*/ */
public function getUsers($server_id) { public function getUsers($server_id) {
// find all the users with this server listed // find all the users with this server listed