Skip to content

Commit

Permalink
I should probably just start an entirely new repo with actual good co…
Browse files Browse the repository at this point in the history
…mmit practices.
  • Loading branch information
slifty committed Jun 3, 2014
1 parent f4ac626 commit 0b07fe9
Show file tree
Hide file tree
Showing 55 changed files with 1,271 additions and 407 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
conf.php
.htaccess
scrapers/*
rake/scrapers/*
14 changes: 0 additions & 14 deletions .htaccess-default

This file was deleted.

21 changes: 10 additions & 11 deletions README
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
== INSTALL ==
cp conf-default.php conf.php
edit conf.php
cp .htaccess-default .htaccess
edit .htaccess
php install.php
php datarake.php

vi conf.php
php rake/db_rake.php
php rake/data_rake.php

== UPDATE ==
php install.php

php rake/db_rake.php

== DATA REFRESH ==
// CAUTION: this may delete data you wanted to keep -- be sure to backup the schema if you want to retain your information
php datarake.php
php rake/data_rake.php


==Fake lightweight "Framework"==
Models are in the models folder
No controllers, but instead actions are autorouted to the proper page
URL style is "something.com/?p=[page]&a=[action]
DIR style is /pages/[page]/[action].php
URL style is "something.com/[page]/[action]
DIR style is /pages/[page]/[action].php

API URL style is "something.com/api/[page]/[action]
API DIR style is /api/[page]/[method]_[action].php
14 changes: 2 additions & 12 deletions api/claims/post_claims.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?PHP
set_include_path($_SERVER['DOCUMENT_ROOT']);
require_once("conf.php");
include_once("models/Claim.php");
include_once("models/Snippet.php");
//ini_set('memory_limit', '-1'); // HORRIBLE IDEA but needed for the moment. Need to go through and optimize / remove leaks

$collectionJSON = "";
if($resourceIdentifier) {
Expand All @@ -16,6 +11,8 @@
$context = utf8_decode($_POST['context']);
$oid = isset($_POST['oid'])?$_POST['oid']:0;



// Get a narrow list of possible snippets
$possible_snippets = Snippet::getObjectsByContext($context, Snippet::MATCH_LOOSE);

Expand Down Expand Up @@ -69,13 +66,10 @@
}

// We now have a vector of hot spots, find the top phrase candidates
//print_r($match_tracker);
$finalists = array();
for($x = 0 ; $x < sizeof($match_tracker) ; $x++) {
$non_stop_cutoff = max(2, floor($match_tracker[$x]["non_stop_word_count"] * .5));
$cutoff = floor($match_tracker[$x]["word_count"] * .6);
//echo($match_tracker[$x]["word_count"]." :: ".$match_tracker[$x]["non_stop_word_count"]."\n");
//echo($non_stop_cutoff." :: ".$cutoff."\n");
$match_start = -1;
$match_end = -1;
for($y = 0 ; $y < sizeof($token_strings) ; $y++) {
Expand All @@ -87,20 +81,16 @@
);
$match_start = -1;
$match_end = -1;
//echo("END"."\n");
}

if(($match_tracker[$x]["matches"][$y] >= $cutoff)
&& ($match_tracker[$x]["non_stop_matches"][$y] >= $non_stop_cutoff)) {
if($match_start == -1) {
$match_start = $y;
//echo("START"."\n");
}
}
elseif($match_start != -1)
$match_end = $y + $match_tracker[$x]["matches"][$y];

//echo($x." ::".$match_tracker[$x]["matches"][$y].":".$match_tracker[$x]["non_stop_matches"][$y].":: ".$token_strings[$y]."\n");

}
}
Expand Down
1 change: 0 additions & 1 deletion api/corpus_items/get_corpus_items.php

This file was deleted.

5 changes: 0 additions & 5 deletions api/snippets/post_snippets.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<?PHP
set_include_path($_SERVER['DOCUMENT_ROOT']);
require_once("conf.php");
include_once("models/Claim.php");
include_once("models/Snippet.php");

$collectionJSON = "";
if($resourceIdentifier) {
// Return a single object
Expand Down
34 changes: 24 additions & 10 deletions conf-default.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
<?php
// Time settings
date_default_timezone_set("America/New_York");
// Set Time Zone


// DB Settings
// ReCaptcha Settings
global $RECAPTCHA_PUBLIC_KEY, $RECAPTCHA_PRIVATE_KEY;
$RECAPTCHA_PUBLIC_KEY = "";
$RECAPTCHA_PRIVATE_KEY = "";

// DB Connection Settings
global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASS, $MYSQL_DB;
$MYSQL_HOST = "";
$MYSQL_USER = "";
$MYSQL_PASS = "";
$MYSQL_DB = "";

// Site Settings
global $SITE_ROOT, $SITE_DOMAIN;
$SITE_ROOT = "";
$SITE_DOMAIN = "127.0.0.1";
// Memcache Connection Settings
global $MEMCACHE_HOST, $MEMCACHE_PORT
$MEMCACHE_HOST = "";
$MEMCACHE_PORT = 11211;

// Bootstrap Settings
global $BASE_DIRECTORY;
# If you are hosting Truth Goggles in your base directory
$BASE_DIRECTORY = "/";

# If you are hosting Truth Goggles in a subdirectory (replace [subdirectory path] with the appropriate path)
# $ROOT = "/[subdirectory path]/";

// Thermonuclear Disaster Prevention
global $ALLOW_THERMONUCLEAR_DISASTER;
$ALLOW_THERMONUCLEAR_DISASTER = false;

// API Settings
global $API_RELATED_CLAIMS;
$API_RELATED_CLAIMS = "";
?>
19 changes: 8 additions & 11 deletions api.php → includes/engine/api.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
<?PHP
set_include_path($_SERVER['DOCUMENT_ROOT']);

require_once("conf.php");
set_include_path($_SERVER['DOCUMENT_ROOT'].$BASE_DIRECTORY."../");
header('Content-type: text/javascript');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type');

$params = explode('/',(isset($_GET['q'])?$_GET['q']:""));
$resourceType = preg_replace('[^A-Za-z0-9_]',"",isset($params[0])?$params[0]:"");

$parsed_url = parse_url($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
$path_items = array_splice(explode("/", $parsed_url['path']), substr_count($BASE_DIRECTORY, "/") + 1);

$resourceType = preg_replace('[^A-Za-z0-9_]',"",isset($path_items[0])?$path_items[0]:"");
$requestMethod = preg_replace('[^A-Za-z0-9_]',"",strtolower($_SERVER['REQUEST_METHOD']));

$resourceIdentifier = isset($params[1])?$params[1]:"";
$resourceIdentifier = isset($path_items[1])?$path_items[1]:"";

$jsonp = isset($_GET['jsonp'])?true:false;
$callback = isset($_GET['callback'])?$_GET['callback']:"goggles_".$requestMethod."_".$resourceType."_callback";
$resourceIdentifier = isset($_GET['r'])?$_GET['r']:null|$resourceIdentifier|null;

$path = "api/".$resourceType."/".$requestMethod."_".$resourceType.".php";

if(file_exists($path))
include_once($path);
else {
echo("ERR: Invalid API Call");
}
include_once($path);
?>
Loading

0 comments on commit 0b07fe9

Please sign in to comment.