Skip to content

Commit

Permalink
Merge pull request #48 from bbertucc/mvp-2-scanner_revamp
Browse files Browse the repository at this point in the history
Mvp 2 scanner revamp
  • Loading branch information
Blake Bertuccelli authored Jun 15, 2022
2 parents a04fe11 + 5414013 commit 7ce6f23
Show file tree
Hide file tree
Showing 36 changed files with 1,921 additions and 991 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.DS_Store
.vscode
.vscode
login/
config.php
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Equalify is in an Alpha MVP "Wild West" phase.

The only limits are your imagination.

I know limits will be created eventually.
I know this wild west needs rules eventually.

For now, let's hack!

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

Exceptions allow me to log errors.

**I consider User Errors System Errors. 🚩**
**I consider User Errors System Errors.**

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

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

Equalify is being designed as open as possible.

Eventually, I imagine people will want different accounts.
## Usable hooks and patterns.

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

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

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

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

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Everyone should have access to online information.

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


## How will Equalify increase accessibility?

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

## Download and Use
1. Download or clone [the latest release](https://github.com/bbertucc/equalify/releases).
2. Update `config.php` info.
3. Upload/run on your server - PHP 8 and MySQL is required.
4. Checkout our [demo video](https://www.youtube.com/watch?v=PASHGkgjVqY) for usage tips.
5. Report [issues](https://github.com/bbertucc/equalify/issues), questions, and patches.
2. Change `sample-config.php` to `config.php` and update info.
3. Upload/run on a Linux server (PHP 8 + MySQL required).
4. Report [issues](https://github.com/bbertucc/equalify/issues), questions, and patches.
5. Checkout our [demo video](https://www.youtube.com/watch?v=yrsG32G3I0g) for usage tips.
6. Report [issues](https://github.com/bbertucc/equalify/issues), questions, and patches.

Not a technical user? Signup for our early access program at [equalify.app](https://equalify.app/).

## Special Thanks
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.
Expand Down
81 changes: 8 additions & 73 deletions actions/add_site.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,85 +19,20 @@

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

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

// Site URL changes to the curled URL.
$site_url = $curled_site['url'];

// Single pages are saved with the following pramenters
$type = 'single_page';
$status = 'active';
$site = $curled_site['url'];
$is_parent = 1;
DataAccess::add_page($site_url, $type, $status, $site, $is_parent );

// WordPress and XML deals with adding pages similarly,
// so their functions are wrapped in one condition.
}elseif($type == 'wordpress' || $type == 'xml' ){

// WordPress API is queried to create sites.
if($type == 'wordpress' )
$curled_site = wordpress_site_adder($site_url);

// .XML adder can create lots of pages.
if($type == 'xml' )
$curled_site = xml_site_adder($site_url);

// Both XML and WP deliver similar content.
$pages = $curled_site['contents'];
$site_url = $curled_site['url'];

// We're setting the status and adding pages here so we
// do not have to call the db inside "models/adders.php",
// keeping each model focused on distinct functions.
$pages_records = [];
foreach ($pages as &$page):

// Though these variables were set, we must reset them for
// one page, since we have now generated many pages.
if($site_url == $page['url']){
$is_parent = 1;

// This will be used later..
$has_parent = true;

}else{
$is_parent = '';
}

// Push each page to pages' records.
array_push(
$pages_records,
array(
'url' => $page['url'],
'site' => $site_url,
'is_parent' => $is_parent,
'status' => 'active',
'type' => $type
)
);

endforeach;

// Some newly created record arrays do not have existing sites
// and do not contain a parent because API/XML records contain
// different URLs than the URL where the API/XML exists. In that
// case, the first record, which is often the homepage, becomes
// the parent.
if(!isset($has_parent) && !isset($existing_site)){
$first_record = &$pages_records[0];
$first_record['is_parent'] = 1;
}

// Finalllly, we can add pages to the DB.
DataAccess::add_pages($pages_records);
// .XML sites use the latest version of XML standards.
}elseif($type == 'xml'){
xml_site_adder($site_url);

// Since we're passing type through a URL, we have a fallback
// in case someone passes an unsupported 'type'.
}else{
die('"'.$type.'" sites are unsupported.');
throw new Exception('"'.$type.'" sites are unsupported');
}

// Back home we go.
Expand Down
14 changes: 2 additions & 12 deletions actions/delete_alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
$id = filter_input(INPUT_GET, 'id', FILTER_VALIDATE_INT);
if(empty($id))
throw new Exception('ID "'.$id.'" is invalid format.');
if(!empty($_GET['site_details_redirect'])){
$site_details_redirect = $_GET['site_details_redirect'];
}else{
$site_details_redirect = NULL;
}

// Do the deletion.
$filters = [array(
Expand All @@ -20,10 +15,5 @@
)];
DataAccess::delete_alerts($filters);

// When the work is done, we can triumphantly return to
// wherever we came from.
if(empty($site_details_redirect)){
header('Location: ../index.php?view=alerts&status=success');
}else{
header('Location: ../index.php?view=site_details&id='.$site_details_redirect.'&status=success');
}
// When the work is done, we can triumphantly go back.
header('Location: ../index.php?view=alerts');
24 changes: 24 additions & 0 deletions actions/delete_alert_tab.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
// Info on DB must be declared to use db.php models.
require_once '../config.php';
require_once '../models/db.php';

// Setup variables.
$alert_tab = $_GET['tab'];

// Get existing meta.
$alert_tabs = unserialize(DataAccess::get_meta_value('alert_tabs'));

// Remove the tab.
unset($alert_tabs['tabs'][$alert_tab]);

// Change the current tab to the first tab,
// which can never be deleted.
$alert_tabs['current_tab'] = 1;

// Save view data with data that MySQL understands.
$serialized_alert_tabs = serialize($alert_tabs);
DataAccess::update_meta_value('alert_tabs', $serialized_alert_tabs);

// Reload alerts page.
header('Location: ../index.php?view=alerts');
8 changes: 8 additions & 0 deletions actions/get_alerts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
// Require files to control db.
require '../config.php';
require '../models/db.php';

// This changes the little red number asyncronistically with JS
// embedded in the view file.
echo DataAccess::count_alerts();
10 changes: 10 additions & 0 deletions actions/get_scans.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
// Require files to control db.
require '../config.php';
require '../models/db.php';
require '../models/view_components.php';

// Scan info is passed to JSON on the view, so that we can do
// async scans.
$scans = DataAccess::get_scans();
the_scan_rows($scans);
13 changes: 13 additions & 0 deletions actions/queue_scan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
// Require files to control db.
require_once '../config.php';
require_once '../models/db.php';
require_once '../models/cron.php';

// Add scan to queue.
$time = date('Y-m-d H:i:s');
DataAccess::add_scan('queued', $time);

// Return to scan page without 'success' because
// queuing a scan is feedback enough.
header('Location: ../index.php?view=scans');
Loading

0 comments on commit 7ce6f23

Please sign in to comment.