Skip to content

Commit 7ce6f23

Browse files
author
Blake Bertuccelli
authored
Merge pull request #48 from bbertucc/mvp-2-scanner_revamp
Mvp 2 scanner revamp
2 parents a04fe11 + 5414013 commit 7ce6f23

36 files changed

Lines changed: 1921 additions & 991 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.DS_Store
2-
.vscode
2+
.vscode
3+
login/
4+
config.php

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Equalify is in an Alpha MVP "Wild West" phase.
44

55
The only limits are your imagination.
66

7-
I know limits will be created eventually.
7+
I know this wild west needs rules eventually.
88

99
For now, let's hack!
1010

@@ -22,7 +22,7 @@ I'm up for any new coding standards!
2222

2323
Exceptions allow me to log errors.
2424

25-
**I consider User Errors System Errors. 🚩**
25+
**I consider User Errors System Errors.**
2626

2727
What some platforms display a warning for, like "wrong password," I ring alarm bells for.
2828

@@ -34,14 +34,14 @@ Users should never hit roadblocks.
3434

3535
Equalify is being designed as open as possible.
3636

37-
Eventually, I imagine people will want different accounts.
37+
## Usable hooks and patterns.
3838

39-
Like so many features, we will build an auth system when folks request it.
39+
Checkout [/models/hooks.php](/models/hooks.php) and the `_scan` pattern in [/actions/scan_all_pages.php](/actions/scan_all_pages.php).
4040

4141
## Progress Depends on Bugs
4242
I am inspired by the development of [Gutenberg](https://github.com/WordPress/gutenberg).
4343

44-
A community of engaged devs builds the future of WordPress around issues that can be easily reported by any user.
44+
A community of engaged devs builds the future of WordPress around issues that are reported by users.
4545

4646
I hope folks, no matter their expertise, contribute to Equalify.
4747

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Everyone should have access to online information.
1414

1515
🛠️ Contribute with a pull request or [new issue](https://github.com/bbertucc/equalify/issues).
1616

17-
1817
## How will Equalify increase accessibility?
1918

2019
Equalify creates deep integrations with services that run your website.
@@ -43,10 +42,13 @@ The goal: **Equalify every website.**
4342

4443
## Download and Use
4544
1. Download or clone [the latest release](https://github.com/bbertucc/equalify/releases).
46-
2. Update `config.php` info.
47-
3. Upload/run on your server - PHP 8 and MySQL is required.
48-
4. Checkout our [demo video](https://www.youtube.com/watch?v=PASHGkgjVqY) for usage tips.
49-
5. Report [issues](https://github.com/bbertucc/equalify/issues), questions, and patches.
45+
2. Change `sample-config.php` to `config.php` and update info.
46+
3. Upload/run on a Linux server (PHP 8 + MySQL required).
47+
4. Report [issues](https://github.com/bbertucc/equalify/issues), questions, and patches.
48+
5. Checkout our [demo video](https://www.youtube.com/watch?v=yrsG32G3I0g) for usage tips.
49+
6. Report [issues](https://github.com/bbertucc/equalify/issues), questions, and patches.
50+
51+
Not a technical user? Signup for our early access program at [equalify.app](https://equalify.app/).
5052

5153
## Special Thanks
5254
A chaos wizard 🧙 and many brilliant brains help Equalify. Special shoutout to [Pantheon](https://pantheon.io/) and [Little Forest](https://littleforest.co.uk/feature/web-accessibility/) for providing funding for Drupalcon tickets and other great resources that help this project grow. Yi, Kate, Bill, Dash, Sylvia, Anne, Doug, Matt, Nathan, and John- You are the braintrust behind any great idea. Brad- You push me to code better. [@ebertucc](https://github.com/ebertucc) and [@jrchamp](https://github.com/jrchamp)- I consider y'all first contributors - woot woot! & Grace- You are the 🔥 behind everything I do.

actions/add_site.php

Lines changed: 8 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -19,85 +19,20 @@
1919

2020
// Static pages are treated as sites in themselves.
2121
if($type == 'single_page' ){
22+
single_page_adder($site_url);
2223

23-
// The adder cURLs the site to test if the URL can be scanned.
24-
$curled_site = single_page_adder($site_url);
24+
// WordPress sites are added via their API.
25+
}elseif($type == 'wordpress'){
26+
wordpress_site_adder($site_url);
2527

26-
// Site URL changes to the curled URL.
27-
$site_url = $curled_site['url'];
28-
29-
// Single pages are saved with the following pramenters
30-
$type = 'single_page';
31-
$status = 'active';
32-
$site = $curled_site['url'];
33-
$is_parent = 1;
34-
DataAccess::add_page($site_url, $type, $status, $site, $is_parent );
35-
36-
// WordPress and XML deals with adding pages similarly,
37-
// so their functions are wrapped in one condition.
38-
}elseif($type == 'wordpress' || $type == 'xml' ){
39-
40-
// WordPress API is queried to create sites.
41-
if($type == 'wordpress' )
42-
$curled_site = wordpress_site_adder($site_url);
43-
44-
// .XML adder can create lots of pages.
45-
if($type == 'xml' )
46-
$curled_site = xml_site_adder($site_url);
47-
48-
// Both XML and WP deliver similar content.
49-
$pages = $curled_site['contents'];
50-
$site_url = $curled_site['url'];
51-
52-
// We're setting the status and adding pages here so we
53-
// do not have to call the db inside "models/adders.php",
54-
// keeping each model focused on distinct functions.
55-
$pages_records = [];
56-
foreach ($pages as &$page):
57-
58-
// Though these variables were set, we must reset them for
59-
// one page, since we have now generated many pages.
60-
if($site_url == $page['url']){
61-
$is_parent = 1;
62-
63-
// This will be used later..
64-
$has_parent = true;
65-
66-
}else{
67-
$is_parent = '';
68-
}
69-
70-
// Push each page to pages' records.
71-
array_push(
72-
$pages_records,
73-
array(
74-
'url' => $page['url'],
75-
'site' => $site_url,
76-
'is_parent' => $is_parent,
77-
'status' => 'active',
78-
'type' => $type
79-
)
80-
);
81-
82-
endforeach;
83-
84-
// Some newly created record arrays do not have existing sites
85-
// and do not contain a parent because API/XML records contain
86-
// different URLs than the URL where the API/XML exists. In that
87-
// case, the first record, which is often the homepage, becomes
88-
// the parent.
89-
if(!isset($has_parent) && !isset($existing_site)){
90-
$first_record = &$pages_records[0];
91-
$first_record['is_parent'] = 1;
92-
}
93-
94-
// Finalllly, we can add pages to the DB.
95-
DataAccess::add_pages($pages_records);
28+
// .XML sites use the latest version of XML standards.
29+
}elseif($type == 'xml'){
30+
xml_site_adder($site_url);
9631

9732
// Since we're passing type through a URL, we have a fallback
9833
// in case someone passes an unsupported 'type'.
9934
}else{
100-
die('"'.$type.'" sites are unsupported.');
35+
throw new Exception('"'.$type.'" sites are unsupported');
10136
}
10237

10338
// Back home we go.

actions/delete_alert.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
$id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
88
if(empty($id))
99
throw new Exception('ID "'.$id.'" is invalid format.');
10-
if(!empty($_GET['site_details_redirect'])){
11-
$site_details_redirect = $_GET['site_details_redirect'];
12-
}else{
13-
$site_details_redirect = NULL;
14-
}
1510

1611
// Do the deletion.
1712
$filters = [array(
@@ -20,10 +15,5 @@
2015
)];
2116
DataAccess::delete_alerts($filters);
2217

23-
// When the work is done, we can triumphantly return to
24-
// wherever we came from.
25-
if(empty($site_details_redirect)){
26-
header('Location: ../index.php?view=alerts&status=success');
27-
}else{
28-
header('Location: ../index.php?view=site_details&id='.$site_details_redirect.'&status=success');
29-
}
18+
// When the work is done, we can triumphantly go back.
19+
header('Location: ../index.php?view=alerts');

actions/delete_alert_tab.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
// Info on DB must be declared to use db.php models.
3+
require_once '../config.php';
4+
require_once '../models/db.php';
5+
6+
// Setup variables.
7+
$alert_tab = $_GET['tab'];
8+
9+
// Get existing meta.
10+
$alert_tabs = unserialize(DataAccess::get_meta_value('alert_tabs'));
11+
12+
// Remove the tab.
13+
unset($alert_tabs['tabs'][$alert_tab]);
14+
15+
// Change the current tab to the first tab,
16+
// which can never be deleted.
17+
$alert_tabs['current_tab'] = 1;
18+
19+
// Save view data with data that MySQL understands.
20+
$serialized_alert_tabs = serialize($alert_tabs);
21+
DataAccess::update_meta_value('alert_tabs', $serialized_alert_tabs);
22+
23+
// Reload alerts page.
24+
header('Location: ../index.php?view=alerts');

actions/get_alerts.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
// Require files to control db.
3+
require '../config.php';
4+
require '../models/db.php';
5+
6+
// This changes the little red number asyncronistically with JS
7+
// embedded in the view file.
8+
echo DataAccess::count_alerts();

actions/get_scans.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
// Require files to control db.
3+
require '../config.php';
4+
require '../models/db.php';
5+
require '../models/view_components.php';
6+
7+
// Scan info is passed to JSON on the view, so that we can do
8+
// async scans.
9+
$scans = DataAccess::get_scans();
10+
the_scan_rows($scans);

actions/queue_scan.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
// Require files to control db.
3+
require_once '../config.php';
4+
require_once '../models/db.php';
5+
require_once '../models/cron.php';
6+
7+
// Add scan to queue.
8+
$time = date('Y-m-d H:i:s');
9+
DataAccess::add_scan('queued', $time);
10+
11+
// Return to scan page without 'success' because
12+
// queuing a scan is feedback enough.
13+
header('Location: ../index.php?view=scans');

0 commit comments

Comments
 (0)