• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

marscoin / martianrepublic / 22642820042

03 Mar 2026 09:08PM UTC coverage: 5.205% (+0.6%) from 4.588%
22642820042

push

github

Lennart Lopin
security: Phase 2 - CSRF, SQL, error pages, security headers

22 of 187 new or added lines in 4 files covered. (11.76%)

190 of 3650 relevant lines covered (5.21%)

0.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/Http/Controllers/Citizen/IdentityController.php
1
<?php
2
namespace App\Http\Controllers\Citizen;
3

4
use App\Http\Controllers\Controller;
5
use Illuminate\Http\Request;
6
use Illuminate\Support\Facades\DB;
7
use Illuminate\Support\Facades\Auth;
8
use App\Models\Profile;
9
use App\Models\Feed;
10
use App\Models\User;
11
use App\Models\Proposals;
12
use App\Models\HDWallet;
13
use App\Models\CivicWallet;
14
use App\Models\Citizen;
15
use Illuminate\Support\Facades\View;
16
use App\Includes\jsonRPCClient;
17
use App\Includes\AppHelper;
18
use App\Exceptions\Handler;
19
use Exception;
20
use Carbon\Carbon;
21

22

23
class IdentityController extends Controller
24
{
25

26
        /**
27
         * Setup the layout used by the controller.
28
         *
29
         * @return void
30
         */
31

32
        public function __construct()
×
33
        {
34
        }
×
35

36

37
        //Get all public registrations and display table
38
        //
39
    protected function showAll()
×
40
        {
41
                if (Auth::check()) {
×
42
                        $uid = Auth::user()->id;
×
43
                        $profile = Profile::where('userid', '=', $uid)->first();
×
44
                        $wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
45
                        $citcache = Citizen::where('userid', '=', $uid)->first();
×
46
                        if (!$profile) {
×
47
                                return redirect('/twofa');
×
48
                        } else {
49
                                if ($profile->openchallenge == 1 || is_null($profile->openchallenge)) {
×
50
                                        return redirect('/twofachallenge');
×
51
                                }
52
                        }
53
                        $view = View::make('citizen.registry');
×
54
                        $view->wallet_open = $profile->civic_wallet_open;
×
55
                        $view->isCitizen = $profile->citizen;
×
56
                        $view->citcache = $citcache;
×
57
                        $view->isGP  = $profile->general_public;
×
58
                        $view->mePublic = Feed::where('userid', '=', $uid)->where('tag', '=', "GP")->first();
×
59
                        $view->meCitizen = Feed::where('userid', '=', $uid)->where('tag', '=', "CT")->first();
×
60
                        $view->feed = Feed::where('userid', '=', $uid)->whereNotNull('mined')->whereNotIn('tag', ['GP','CT'])->orderBy('created_at', 'desc')->get();
×
61
                        $view->endorsed = array();
×
62
                        
63
                        //6462 is our test account Roberta Draper
NEW
64
                        $view->everyPublic = DB::select('SELECT u.*, p.*, c.*, ( SELECT f.txid FROM feed f WHERE f.userid = u.id AND f.tag = ? ORDER BY f.id DESC LIMIT 1) AS txid, ( SELECT f.mined FROM feed f WHERE f.userid = u.id AND f.tag = ? ORDER BY f.id DESC LIMIT 1) AS mined FROM users u JOIN profile p ON u.id = p.userid JOIN citizen c ON u.id = c.userid WHERE EXISTS ( SELECT 1 FROM feed f WHERE f.userid = u.id AND f.tag = ?) AND u.id NOT IN (?, ?) ORDER BY mined DESC', ['GP', 'GP', 'GP', 6462, 7601]);
×
65
                        
NEW
66
                        $view->everyCitizen = DB::select('SELECT u.*, p.*, c.*, ( SELECT f.txid FROM feed f WHERE f.userid = u.id AND f.tag = ? ORDER BY f.id DESC LIMIT 1 ) AS txid, ( SELECT f.mined FROM feed f WHERE f.userid = u.id AND f.tag = ? ORDER BY f.id DESC LIMIT 1 ) AS mined FROM users u JOIN profile p ON u.id = p.userid JOIN citizen c ON u.id = c.userid WHERE EXISTS ( SELECT 1 FROM feed f WHERE f.userid = u.id AND f.tag = ? ) AND u.id NOT IN (?) ORDER BY mined DESC', ['CT', 'CT', 'CT', 6462]);
×
67
                        
NEW
68
                        $view->everyApplicant = DB::select('SELECT profile.userid, users.fullname, citizen.*, civic_wallet.public_addr AS address FROM users, profile, civic_wallet, citizen WHERE profile.userid = users.id AND users.id = civic_wallet.user_id AND citizen.userid = users.id AND profile.has_application = ? AND users.id NOT IN (?)', [1, 6462]);
×
69
                        
70
                        $view->recentActivityCount = Feed::where('userid', $uid)->where('mined', '>=', Carbon::now()->subDay())->count();
×
71

72
                        if ($wallet) {
×
73
                                $view->balance = 0;
×
74
                                $view->public_address = $wallet['public_addr'];
×
75
                                $view->endorsed = Feed::where('message', '=', $wallet['public_addr'])->where('tag', '=', "ED")->get();
×
76
                        } else {
77
                                $view->balance = 0;
×
78
                                $view->public_address = "";
×
79
                        }
80

81
                        return $view;
×
82

83

84
                }else{
85
            return redirect('/login');
×
86
        }
87

88
                
89
        }
90

91

92

93
        protected function printout()
×
94
        {
95
                if (Auth::check()) {
×
96
                        $uid = Auth::user()->id;
×
97
                        $profile = Profile::where('userid', '=', $uid)->first();
×
98
                        $civic_wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
99
                        $view = View::make('citizen.printout');
×
100
                        $citcache = Citizen::where('userid', '=', $uid)->first();
×
101
                        $view->fullname = $citcache->firstname . " " . $citcache->lastname;
×
102
                        
103
                        if ($civic_wallet) {
×
104
                                $view->public_address = $civic_wallet['public_addr'];
×
105
                        } else {
106
                                $view->balance = 0;
×
107
                                $view->public_address = "";
×
108
                        }
109
                        return $view;
×
110
                }else{
111
            return redirect('/login');
×
112
        }
113
        }
114

115

116
        protected function printout2()
×
117
        {
118
                if (Auth::check()) {
×
119
                        $uid = Auth::user()->id;
×
120
                        $profile = Profile::where('userid', '=', $uid)->first();
×
121
                        $civic_wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
122
                        $view = View::make('citizen.themes.printout2');
×
123
                        $citcache = Citizen::where('userid', '=', $uid)->first();
×
124
                        $view->fullname = $citcache->firstname . " " . $citcache->lastname;
×
125
                        
126
                        if ($civic_wallet) {
×
127
                                $view->public_address = $civic_wallet['public_addr'];
×
128
                        } else {
129
                                $view->balance = 0;
×
130
                                $view->public_address = "";
×
131
                        }
132
                        return $view;
×
133
                }else{
134
            return redirect('/login');
×
135
        }
136
        }
137

138

139

140
        protected function printout3()
×
141
        {
142
                if (Auth::check()) {
×
143
                        $uid = Auth::user()->id;
×
144
                        $profile = Profile::where('userid', '=', $uid)->first();
×
145
                        $civic_wallet = CivicWallet::where('user_id', '=', $uid)->first();
×
146
                        $view = View::make('citizen.themes.printout3');
×
147
                        $citcache = Citizen::where('userid', '=', $uid)->first();
×
148
                        $view->fullname = $citcache->firstname . " " . $citcache->lastname;
×
149
                        
150
                        if ($civic_wallet) {
×
151
                                $view->public_address = $civic_wallet['public_addr'];
×
152
                        } else {
153
                                $view->balance = 0;
×
154
                                $view->public_address = "";
×
155
                        }
156
                        return $view;
×
157
                }else{
158
            return redirect('/login');
×
159
        }
160
        }
161

162

163

164

165
        //Get profile view of another Martian Citizen
166
        //
167
    protected function showId($address)
×
168
        {
169
                
170
                if (Auth::check()) {
×
171
                        $uid = Auth::user()->id;
×
172
                        //Martian user we are looking at
173
                        $martian = Citizen::where('public_address', '=', $address)->first();
×
174
                        $martian_profile = Profile::where('userid', '=', $martian->userid)->first();
×
175
                        $martian_proposals = Proposals::where('user_id', '=', $martian->userid)->count();
×
176
                        $myprofile = Profile::where('userid', '=', $uid)->first();
×
177

178
                        if (!$myprofile) {
×
179
                                return redirect('/twofa');
×
180
                        } else {
181
                                if ($myprofile->openchallenge == 1 || is_null($myprofile->openchallenge)) {
×
182
                                        return redirect('/twofachallenge');
×
183
                                }
184
                        }
185
                        $view = View::make('citizen.martian');
×
186
                        $view->wallet_open = $myprofile->civic_wallet_open;
×
187

188

189
                        $view->isCitizen = $martian_profile->citizen;
×
190
                        $view->endorsements = $martian_profile->endorse_cnt;
×
191
                        $view->proposals = $martian_proposals;
×
192
                        $view->isGP  = $martian_profile->general_public;
×
193
                        $view->mePublic = Feed::where('userid', '=', $martian->userid)->where('tag', '=', "GP")->first();
×
194
                        $view->meCitizen = Feed::where('userid', '=', $martian->userid)->where('tag', '=', "CT")->first();
×
195
                        $view->endorsed = Feed::where('userid', '=', $martian->userid)->where('tag', '=', "ED")->count();
×
196

197

198
                        $view->citcache = $martian;
×
199

200
                        return $view;
×
201

202

203
                }else{
204
            return redirect('/login');
×
205
        }
206

207
                
208
        }
209

210

211

212
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc