Skip to content

Commit f9f0d3c

Browse files
committed
Some PSR-0, PSR-1 and PSR-2 applied
1 parent 724b106 commit f9f0d3c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+372
-307
lines changed

config.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
<?php
2-
$config = Array(
2+
$config = array(
33
'default_controller' => 'Welcome',
44
'default_action' => 'Index',
5-
'production' => True,
5+
'production' => true,
66
'default_layout' => 'layout',
77
'timezone' => 'Europe/Amsterdam',
8-
'log' => Array(
8+
'log' => array(
99
'driver' => 'file',
1010
'threshold' => 1, /* 0: Disable Logging 1: Error 2: Notice 3: Info 4: Warning 5: Debug */
11-
'file' => Array(
11+
'file' => array(
1212
'directory' => 'logs'
1313
)
1414
),
15-
'database' => Array(
15+
'database' => array(
1616
'driver' => 'redis',
17-
'mysql' => Array(
17+
'mysql' => array(
1818
'host' => 'localhost',
1919
'username' => 'root',
2020
'password' => 'root'
2121
),
22-
'redis' => Array(
23-
Array(
22+
'redis' => array(
23+
array(
2424
'host' => 'localhost',
2525
'port' => '6379',
26-
'password' => Null,
26+
'password' => null,
2727
'database' => 0,
2828
'max_databases' => 16, /* Manual configuration of max databases for Redis < 2.6 */
29-
'stats' => Array(
29+
'stats' => array(
3030
'enable' => 1,
3131
'database' => 0,
3232
),
33-
'dbNames' => Array( /* Name databases. key should be database id and value is the name */
33+
'dbNames' => array( /* Name databases. key should be database id and value is the name */
3434
),
3535
),
3636
),
3737
),
38-
'session' => Array(
38+
'session' => array(
3939
'lifetime' => 7200,
4040
'gc_probability' => 2,
4141
'name' => 'phpredminsession'
4242
),
43-
'gearman' => Array(
43+
'gearman' => array(
4444
'host' => '127.0.0.1',
4545
'port' => 4730
4646
),
47-
'terminal' => Array(
48-
'enable' => True,
47+
'terminal' => array(
48+
'enable' => true,
4949
'history' => 200
5050
)
5151
);

controllers/actions.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ public function resetAction()
1414
{
1515
$this->statsModel->resetStats();
1616

17-
$this->template->render(True);
17+
$this->template->render(true);
1818
}
1919

2020
public function fallAction()
2121
{
2222
$this->db->flushAll();
2323

24-
$this->template->render(True);
24+
$this->template->render(true);
2525
}
2626

2727
public function fdbAction()
2828
{
2929
$this->db->flushDB();
3030

31-
$this->template->render(True);
31+
$this->template->render(true);
3232
}
3333
}

controllers/cron.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Cron_Controller extends Controller
44
{
55
public function indexAction()
66
{
7-
foreach($this->app->config['database']['redis'] as $serverId => $server) {
7+
foreach ($this->app->config['database']['redis'] as $serverId => $server) {
88
if (!empty($server['stats']['enable'])) {
99
$time = time();
1010

@@ -24,15 +24,15 @@ public function indexAction()
2424
if ($info['aof_enabled']) {
2525
$statsModel->addKey('aof_size', $info['aof_current_size'], $time);
2626
$statsModel->addKey('aof_base', $info['aof_base_size'], $time);
27-
}
27+
}
2828

2929
foreach ($this->infoModel->getDbs($info) as $i) {
3030
if (preg_match('/^keys=([0-9]+),expires=([0-9]+)$/', $info["db{$i}"], $matches)) {
3131
$statsModel->addKey("db{$i}:keys", $matches[1], $time);
3232
$statsModel->addKey("db{$i}:expired_keys", $matches[2], $time);
3333
}
34-
}
34+
}
3535
}
36-
}
36+
}
3737
}
3838
}

controllers/gearman.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ public function deleteKeys($job)
3232
$db->del("phpredmin:gearman:requests:{$data['key']}");
3333

3434
foreach ($keys as $key) {
35-
if ($db->delete($key) !== False) {
35+
if ($db->delete($key) !== false) {
3636
$db->incrBy("phpredmin:gearman:deleted:{$data['key']}", 1);
3737
$db->expireAt("phpredmin:gearman:deleted:{$data['key']}", strtotime('+10 minutes'));
38-
} else
38+
} else {
3939
Log::factory()->write(Log::INFO, "Unable to delete {$key}", 'Gearman');
40+
}
4041
}
4142

4243
$db->del("phpredmin:gearman:deletecount:{$data['key']}");

controllers/hashes.php

+23-19
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ class Hashes_Controller extends Controller
44
{
55
public function addAction()
66
{
7-
$added = False;
7+
$added = false;
88

99
if ($this->router->method == Router::POST) {
10-
$value = $this->inputs->post('value', Null);
11-
$key = $this->inputs->post('key', Null);
12-
$hashkey = $this->inputs->post('hashkey', Null);
10+
$value = $this->inputs->post('value', null);
11+
$key = $this->inputs->post('key', null);
12+
$hashkey = $this->inputs->post('hashkey', null);
1313

14-
if (isset($value) && trim($value) != '' && isset($key) && trim($key) != '' && isset($hashkey) && trim($hashkey) != '')
15-
if ($this->db->hSet($key, $hashkey, $value) !== False)
16-
$added = True;
14+
if (isset($value) && trim($value) != '' && isset($key) && trim($key) != '' && isset($hashkey) && trim($hashkey) != '') {
15+
if ($this->db->hSet($key, $hashkey, $value) !== false) {
16+
$added = true;
17+
}
18+
}
1719
}
1820

1921
Template::factory('json')->render($added);
@@ -23,7 +25,7 @@ public function viewAction($key)
2325
{
2426
$members = $this->db->hGetAll(urldecode($key));
2527

26-
Template::factory()->render('hashes/view', Array('members' => $members, 'key' => urldecode($key)));
28+
Template::factory()->render('hashes/view', array('members' => $members, 'key' => urldecode($key)));
2729
}
2830

2931
public function deleteAction($key, $member)
@@ -34,35 +36,37 @@ public function deleteAction($key, $member)
3436
public function delallAction()
3537
{
3638
if ($this->router->method == Router::POST) {
37-
$results = Array();
39+
$results = array();
3840
$values = $this->inputs->post('values', array());
39-
$keyinfo = $this->inputs->post('keyinfo', Null);
41+
$keyinfo = $this->inputs->post('keyinfo', null);
4042

41-
foreach ($values as $key => $value)
43+
foreach ($values as $key => $value) {
4244
$results[$value] = $this->db->hDel($keyinfo, $value);
45+
}
4346

4447
Template::factory('json')->render($results);
4548
}
4649
}
4750

4851
public function editAction($key, $member)
4952
{
50-
$edited = Null;
53+
$edited = null;
5154

5255
if ($this->router->method == Router::POST) {
53-
$newvalue = $this->inputs->post('newvalue', Null);
54-
$member = $this->inputs->post('member', Null);
55-
$key = $this->inputs->post('key', Null);
56+
$newvalue = $this->inputs->post('newvalue', null);
57+
$member = $this->inputs->post('member', null);
58+
$key = $this->inputs->post('key', null);
5659

5760
if (!isset($newvalue) || trim($newvalue) == '' || !isset($key) || trim($key) == '' ||
58-
!isset($member) || trim($member) == '')
59-
$edited = False;
60-
elseif ($this->db->hDel($key, $member))
61+
!isset($member) || trim($member) == '') {
62+
$edited = false;
63+
} elseif ($this->db->hDel($key, $member)) {
6164
$edited = $this->db->hSet($key, $member, $newvalue);
65+
}
6266
}
6367

6468
$value = $this->db->hGet(urldecode($key), urldecode($member));
6569

66-
Template::factory()->render('hashes/edit', Array('member' => urldecode($member), 'key' => urldecode($key), 'value' => $value, 'edited' => $edited));
70+
Template::factory()->render('hashes/edit', array('member' => urldecode($member), 'key' => urldecode($key), 'value' => $value, 'edited' => $edited));
6771
}
6872
}

controllers/keys.php

+40-37
Original file line numberDiff line numberDiff line change
@@ -4,70 +4,71 @@ class Keys_Controller extends Controller
44
{
55
public function searchAction()
66
{
7-
$key = $this->inputs->get('key', Null);
7+
$key = $this->inputs->get('key', null);
88
$keys = array();
99

1010
if (isset($key) && trim($key) != '') {
1111
$keys = $this->db->keys($key);
1212
asort($keys);
13-
}
13+
}
1414

15-
Template::factory()->render('keys/search', Array('keys' => $keys, 'search' => $key));
15+
Template::factory()->render('keys/search', array('keys' => $keys, 'search' => $key));
1616
}
1717

1818
public function moveAction($key)
1919
{
20-
$moved = Null;
20+
$moved = null;
2121

2222
if ($this->router->method == Router::POST) {
23-
$db = $this->inputs->post('db', Null);
24-
$key = $this->inputs->post('key', Null);
23+
$db = $this->inputs->post('db', null);
24+
$key = $this->inputs->post('key', null);
2525

26-
if (!isset($db) || trim($db) == '' || !isset($key) || trim($key) == '')
27-
$moved = False;
28-
else
26+
if (!isset($db) || trim($db) == '' || !isset($key) || trim($key) == '') {
27+
$moved = false;
28+
} else {
2929
$moved = $this->db->move($key, $db);
30+
}
3031
}
3132

3233
Template::factory()->render('keys/move', array('moved' => $moved, 'key' => urldecode($key)));
3334
}
3435

3536
public function renameAction($key)
3637
{
37-
$renamed = Null;
38+
$renamed = null;
3839

3940
if ($this->router->method == Router::POST) {
40-
$newkey = $this->inputs->post('newkey', Null);
41-
$key = $this->inputs->post('key', Null);
41+
$newkey = $this->inputs->post('newkey', null);
42+
$key = $this->inputs->post('key', null);
4243

43-
if (!isset($newkey) || trim($newkey) == '' || !isset($key) || trim($key) == '')
44-
$renamed = False;
45-
else
44+
if (!isset($newkey) || trim($newkey) == '' || !isset($key) || trim($key) == '') {
45+
$renamed = false;
46+
} else {
4647
$renamed = $this->db->rename($key, $newkey);
48+
}
4749
}
4850

4951
Template::factory()->render('keys/rename', array('renamed' => $renamed, 'key' => urldecode($key)));
5052
}
5153

5254
public function expireAction($key)
5355
{
54-
$updated = Null;
56+
$updated = null;
5557
$oldttl = $this->db->ttl(urldecode($key));
5658

5759
if ($this->router->method == Router::POST) {
58-
$ttl = $this->inputs->post('ttl', Null);
59-
$key = $this->inputs->post('key', Null);
60-
61-
if (!isset($ttl) || trim($ttl) == '' || !isset($key) || trim($key) == '')
62-
$updated = False;
63-
else
64-
if ((int)$ttl > 0)
65-
$updated = $this->db->expire($key, $ttl);
66-
else
67-
if ($oldttl > 0)
68-
$updated = $this->db->persist($key);
69-
else
70-
$updated = True;
60+
$ttl = $this->inputs->post('ttl', null);
61+
$key = $this->inputs->post('key', null);
62+
63+
if (!isset($ttl) || trim($ttl) == '' || !isset($key) || trim($key) == '') {
64+
$updated = false;
65+
} elseif ((int)$ttl > 0) {
66+
$updated = $this->db->expire($key, $ttl);
67+
} elseif ($oldttl > 0) {
68+
$updated = $this->db->persist($key);
69+
} else {
70+
$updated = true;
71+
}
7172
}
7273

7374

@@ -78,12 +79,13 @@ public function expireAction($key)
7879
public function moveallAction()
7980
{
8081
if ($this->router->method == Router::POST) {
81-
$results = Array();
82+
$results = array();
8283
$values = $this->inputs->post('values', array());
8384
$destination = $this->inputs->post('destination');
8485

85-
foreach ($values as $key => $value)
86+
foreach ($values as $key => $value) {
8687
$results[$value] = $this->db->move($value, $destination);
88+
}
8789

8890
Template::factory('json')->render($results);
8991
}
@@ -92,11 +94,12 @@ public function moveallAction()
9294
public function delallAction()
9395
{
9496
if ($this->router->method == Router::POST) {
95-
$results = Array();
97+
$results = array();
9698
$values = $this->inputs->post('values', array());
9799

98-
foreach ($values as $key => $value)
100+
foreach ($values as $key => $value) {
99101
$results[$value] = $this->db->del($value);
102+
}
100103

101104
Template::factory('json')->render($results);
102105
}
@@ -105,18 +108,18 @@ public function delallAction()
105108
public function bulkdeleteAction()
106109
{
107110
if ($this->router->method == Router::POST) {
108-
$key = $this->inputs->post('key', Null);
111+
$key = $this->inputs->post('key', null);
109112

110113
if (isset($key) && trim($key) != '') {
111114
$config = App::instance()->config;
112115
$client = new GearmanClient();
113116

114117
$client->addServer($config['gearman']['host'], $config['gearman']['port']);
115-
$client->doBackground('delete_keys',
118+
$client->doBackground('delete_keys',
116119
serialize(array(
117120
'key' => $key,
118121
'server' => $this->app->current,
119-
))
122+
))
120123
);
121124
}
122125
}
@@ -134,7 +137,7 @@ public function deleteinfoAction($key)
134137

135138
if ($total === false && $count !== false && $requests == 1) {
136139
$total = $count;
137-
}
140+
}
138141

139142
$result = array($total, $count);
140143

0 commit comments

Comments
 (0)