Skip to content

Commit

Permalink
Bringing nominate this endpoint up to date with latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
AramZS committed Apr 10, 2018
2 parents 84c66a2 + 7b0d997 commit 6b4bd15
Show file tree
Hide file tree
Showing 359 changed files with 58,723 additions and 6,042 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
39 changes: 39 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,39 @@
{
"env": {
"browser": true
},
"extends": [
"eslint:recommended",
"prettier"
],
"rules": {
"indent": [
"error",
"tab",
{
"FunctionExpression": {"body": 1, "parameters": 2},
"CallExpression": {"arguments": "first"},
"ArrayExpression": "first",
"ObjectExpression": "first"
}
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
},
"globals": {
"require": true
},
"plugins": [
"prettier"
]
}
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -193,4 +193,5 @@ $RECYCLE.BIN/
## Node etc
#############
node_modules/*
node_modules
node_modules
assets/stats-app/node_modules
18 changes: 10 additions & 8 deletions Application.php
@@ -1,8 +1,9 @@
<?php
namespace PressForward;

// var_dump('2<pre>');
// var_dump(__NAMESPACE__); //die();
$obj = new Loader;
$obj = new Loader();
// $obj->test();
use Intraxia\Jaxion\Core\Application as JaxionCore;
// use Intraxia\Jaxion\Contract\Core\Application as ApplicationContract;
Expand All @@ -25,6 +26,7 @@ class Application extends JaxionCore {
'PressForward\Core\Providers\ModulesProvider',
'PressForward\Core\Providers\AJAXServiceProvider',
'PressForward\Core\Providers\APIProvider',
'PressForward\Core\Providers\BookmarkletProvider',
// 'PressForward\Core\Providers\CoreServiceProvider',
// 'PressForward\Core\Providers\EmbedServiceProvider',
// 'PressForward\Core\Providers\RouterServiceProvider',
Expand All @@ -34,21 +36,21 @@ class Application extends JaxionCore {
*/
public function activate() {
global $wp_rewrite;
define( 'VERSION', '4.2.2' );
define( 'VERSION', '5.1.0' );
$current_version = VERSION; // define this constant in the loader file
$saved_version = get_option( 'pf_version' );
$saved_version = get_option( 'pf_version' );

// This is a new installation
if ( ! $saved_version ) {
// Do whatever you need to do during first installation
$check = pressforward( 'schema.feeds' )->create(
'http://pressforward.org/feed/',
array(
'title' => 'PressForward',
'htmlUrl' => 'http://pressforward.org/',
'description' => 'The news feed for the PressForward project.',
'type' => 'rss',
'module_added' => 'rss-import',
'title' => 'PressForward',
'htmlUrl' => 'http://pressforward.org/',
'description' => 'The news feed for the PressForward project.',
'type' => 'rss',
'module_added' => 'rss-import',
)
);

Expand Down
42 changes: 24 additions & 18 deletions Controllers/HTTPTools.php
Expand Up @@ -12,12 +12,12 @@ class HTTPTools {

function __construct( URLResolver $resolver, System $system, Metas $meta ) {
$this->url_resolver = $resolver;
$this->system = $system;
$this->meta = $meta;
$this->system = $system;
$this->meta = $meta;
}

public function resolve_source_url( $url ) {
$url = $this->resolve_a_url( $url );
$url = $this->resolve_a_url( $url );
$url_array = parse_url( $url );
if ( empty( $url_array['host'] ) ) {
return;
Expand Down Expand Up @@ -64,9 +64,9 @@ public function resolve_a_url( $url ) {
*/
public function aggregation_services() {
return array(
'Google' => 'google.com',
'Tweeted Times' => 'tweetedtimes.com',
);
'Google' => 'google.com',
'Tweeted Times' => 'tweetedtimes.com',
);
}

/**
Expand All @@ -78,7 +78,7 @@ public function aggregation_services() {
* @return bool True value for a submitted URL that matches an aggregation service.
*/
public function url_is_aggregation_service( $url ) {
$check = false;
$check = false;
$services = $this->aggregation_services();
foreach ( $services as $service ) {
$pos = strpos( $url, $service );
Expand All @@ -90,8 +90,8 @@ public function url_is_aggregation_service( $url ) {
}

function attempt_to_get_cookiepath() {
$reset = true;
$upload_dir = wp_upload_dir();
$reset = true;
$upload_dir = wp_upload_dir();
$cookie_path = $upload_dir['basedir'] . 'cookie.txt';
if ( ! is_file( $cookie_path ) ) {
touch( $cookie_path );
Expand All @@ -112,11 +112,12 @@ function attempt_to_get_cookiepath() {
}

function get_url_content( $url, $function = false ) {
$args = func_get_args();
$url = str_replace( '&amp;','&', $url );
$args = func_get_args();
$url = str_replace( '&amp;', '&', $url );
$url_first = $url;
if ( ! $function ) {
$r = set_url_scheme( $url, 'http' );
$url = set_url_scheme( $url, 'http' );
$r = false;
} else {
$args[0] = $url;
unset( $args[1] );
Expand All @@ -128,7 +129,7 @@ function get_url_content( $url, $function = false ) {
$non_ssl_url = set_url_scheme( $url, 'http' );
if ( $non_ssl_url != $url ) {
$args[0] = $non_ssl_url;
$r = call_user_func_array( $function, $args );
$r = call_user_func_array( $function, $args );
// var_dump($url); die();
}
// $r = false;
Expand All @@ -144,9 +145,9 @@ function get_url_content( $url, $function = false ) {
}
}
}
$response = $r;
$response = $r;
$loaded_extensions = get_loaded_extensions();
if ( empty( $response ) || is_wp_error( $response ) || ( ! empty( $response ) && ! empty( $response['headers'] ) && isset( $response['headers']['content-length'] ) && ( 50 > strlen( $response['headers']['content-length'] ) ) ) && in_array( 'curl', $loaded_extensions ) ) {
if ( (false === $response) || empty( $response ) || is_wp_error( $response ) || ( ! empty( $response ) && ! empty( $response['headers'] ) && isset( $response['headers']['content-length'] ) && ( 50 > strlen( $response['headers']['content-length'] ) ) ) && in_array( 'curl', $loaded_extensions ) ) {
$cookie_path = 'cookie.txt';
if ( defined( 'COOKIE_PATH_FOR_CURL' ) ) {
$cookie_path = constant( 'COOKIE_PATH_FOR_CURL' );
Expand All @@ -170,12 +171,17 @@ function get_url_content( $url, $function = false ) {
curl_setopt( $curl, constant( 'CURLOPT_TIMEOUT' ), 15 );
curl_setopt( $curl, constant( 'CURLOPT_SSL_VERIFYHOST' ), false );
curl_setopt( $curl, constant( 'CURLOPT_SSL_VERIFYPEER' ), false );
curl_setopt( $curl, constant( 'CURLOPT_USERAGENT' ), 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)' );
$fetch_ua = apply_filters( 'pf_useragent_retrieval_control', 'facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)' );
curl_setopt( $curl, constant( 'CURLOPT_USERAGENT' ), $fetch_ua );
// The following 2 set up lines work with sites like www.nytimes.com
curl_setopt( $curl, constant( 'CURLOPT_COOKIEFILE' ), $cookie_path ); // you can change this path to whetever you want.
curl_setopt( $curl, constant( 'CURLOPT_COOKIEJAR' ), $cookie_path ); // you can change this path to whetever you want.

$response = mb_convert_encoding( curl_exec( $curl ), 'HTML-ENTITIES', 'UTF-8' );
$encode = apply_filters( 'pf_encoding_retrieval_control', true );
if ($encode){
$response = mb_convert_encoding( curl_exec( $curl ), 'HTML-ENTITIES', 'UTF-8' );
} else {
$response = curl_exec( $curl );
}
// Will return false or the content.
curl_close( $curl );
return array( 'body' => $response );
Expand Down

0 comments on commit 6b4bd15

Please sign in to comment.