-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ura soul
committed
Jun 20, 2016
1 parent
6917f89
commit 80f4ccd
Showing
67 changed files
with
3,798 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
/** | ||
* Delete a bookmark | ||
* | ||
* @package Bookmarks | ||
*/ | ||
|
||
$guid = get_input('guid'); | ||
$bookmark = get_entity($guid); | ||
//error_log('my delete bookmark action'); | ||
if (elgg_instanceof($bookmark, 'object', 'bookmarks') && $bookmark->canEdit()) { | ||
$container = $bookmark->getContainerEntity(); | ||
$thumbnail = $bookmark->thumbnail; | ||
$smallthumbnail = $bookmark->smallthumb; | ||
$mediumthumbnail = $bookmark->mediumthumb; | ||
$largethumbnail = $bookmark->largethumb; | ||
$bookmark_owner_guid = $bookmark->getOwnerGUID(); | ||
if ($bookmark->delete()) { | ||
$result = removeBookmarkThumbnails($thumbnail, $smallthumbnail, $mediumthumbnail, $largethumbnail, $bookmark_owner_guid); | ||
system_message(elgg_echo("bookmarks:delete:success")); | ||
if (elgg_instanceof($container, 'group')) { | ||
forward("bookmarks/group/$container->guid/all"); | ||
} else { | ||
forward("bookmarks/owner/$container->username"); | ||
} | ||
} | ||
} | ||
|
||
register_error(elgg_echo("bookmarks:delete:failed")); | ||
forward(REFERER); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
if ($guid = (int) get_input('guid')) | ||
$entity = get_entity($guid); | ||
|
||
if($url = get_input('url')) | ||
{ | ||
if (!preg_match("#^((ht|f)tps?:)?//#i", $url)) { | ||
$url = "http://$url"; | ||
} | ||
//TODO: use locale and region code to get correct language for current user's language | ||
//$user = elgg_get_logged_in_user_entity(); | ||
//$language = $user->language; | ||
|
||
$local_code = 'en_US'; | ||
$url_query = parse_url($url,PHP_URL_QUERY); | ||
if ($url_query) | ||
{ | ||
$url = $url . '&locale=' . $local_code; | ||
} | ||
else | ||
{ | ||
$url = $url . '?locale=' . $local_code; | ||
} | ||
|
||
} | ||
|
||
// scan target page for opengraph data | ||
$graph_data = interconnected_get_graph_data($entity, $url); | ||
if ($graph_data) | ||
{ | ||
$output = '<result>'; | ||
// search the open graph data contents and process as needed | ||
foreach ($graph_data as $key => $value) | ||
{ | ||
switch ($key) | ||
{ | ||
// search opengraph data for images and use the 1st one located | ||
case 'image': | ||
{ | ||
$thumbnail = file_get_contents($value); | ||
if ($thumbnail) | ||
{ | ||
|
||
if (interconnected_update_thumbnail($entity, TRUE, $url)) | ||
{ | ||
$user = elgg_get_logged_in_user_entity(); | ||
$output .= '<src>' . elgg_get_site_url() . 'mod/interconnected/pages/bookmarks/thumbnail.php?guid=' . $user->guid . '&size=temp</src>'; | ||
} | ||
} | ||
break; | ||
} | ||
case 'title': | ||
{ | ||
if ($value != '') | ||
$output .= '<title>' . $value . '</title>'; | ||
break; | ||
} | ||
case 'description': | ||
{ | ||
if ($value != '') | ||
$output .= '<description>' . $value . '</description>'; | ||
break; | ||
} | ||
} | ||
} | ||
$output .= '</result>'; | ||
|
||
echo $output; | ||
} | ||
else | ||
{ | ||
echo '<result><none>no_data</none></result>'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
/** | ||
* Elgg bookmarks save action | ||
* | ||
* @package Bookmarks | ||
*/ | ||
|
||
$title = htmlspecialchars(get_input('title', '', false), ENT_QUOTES, 'UTF-8'); | ||
$description = get_input('description'); | ||
$address = get_input('address'); | ||
$access_id = get_input('access_id'); | ||
$tags = get_input('tags'); | ||
$guid = get_input('guid'); | ||
$share = get_input('share'); | ||
$container_guid = get_input('container_guid', elgg_get_logged_in_user_guid()); | ||
|
||
elgg_make_sticky_form('bookmarks'); | ||
|
||
// don't use elgg_normalize_url() because we don't want | ||
// relative links resolved to this site. | ||
if ($address && !preg_match("#^((ht|f)tps?:)?//#i", $address)) { | ||
$address = "http://$address"; | ||
} | ||
|
||
if (!$title || !$address) { | ||
register_error(elgg_echo('bookmarks:save:failed')); | ||
forward(REFERER); | ||
} | ||
|
||
// see https://bugs.php.net/bug.php?id=51192 | ||
$php_5_2_13_and_below = version_compare(PHP_VERSION, '5.2.14', '<'); | ||
$php_5_3_0_to_5_3_2 = version_compare(PHP_VERSION, '5.3.0', '>=') && | ||
version_compare(PHP_VERSION, '5.3.3', '<'); | ||
|
||
$validated = false; | ||
if ($php_5_2_13_and_below || $php_5_3_0_to_5_3_2) { | ||
$tmp_address = str_replace("-", "", $address); | ||
$validated = filter_var($tmp_address, FILTER_VALIDATE_URL); | ||
} else { | ||
$validated = filter_var($address, FILTER_VALIDATE_URL); | ||
} | ||
if (!$validated) { | ||
register_error(elgg_echo('bookmarks:save:failed')); | ||
forward(REFERER); | ||
} | ||
|
||
if ($guid == 0) { | ||
$bookmark = new ElggObject; | ||
$bookmark->subtype = "bookmarks"; | ||
$bookmark->container_guid = (int)get_input('container_guid', elgg_get_logged_in_user_guid()); | ||
$new = true; | ||
} else { | ||
$bookmark = get_entity($guid); | ||
if (!$bookmark->canEdit()) { | ||
system_message(elgg_echo('bookmarks:save:failed')); | ||
forward(REFERRER); | ||
} | ||
} | ||
|
||
$tagarray = string_to_tag_array($tags); | ||
|
||
$bookmark->title = $title; | ||
$bookmark->address = $address; | ||
$bookmark->description = $description; | ||
$bookmark->access_id = $access_id; | ||
$bookmark->tags = $tagarray; | ||
if (elgg_is_active_plugin('containers')) | ||
$bookmark->container_guid = $container_guid; | ||
|
||
if ($bookmark->save()) { | ||
//grab remote thumbnail for cache | ||
$result = interconnected_update_thumbnail($bookmark); | ||
//error_log('result of update thumbs: ' . $result); | ||
elgg_clear_sticky_form('bookmarks'); | ||
|
||
// @todo | ||
if (is_array($shares) && sizeof($shares) > 0) { | ||
foreach($shares as $share) { | ||
$share = (int) $share; | ||
add_entity_relationship($bookmark->getGUID(), 'share', $share); | ||
} | ||
} | ||
system_message(elgg_echo('bookmarks:save:success')); | ||
|
||
//add to river only if new | ||
if ($new) { | ||
elgg_create_river_item(array( | ||
'view' => 'river/object/bookmarks/create', | ||
'action_type' => 'create', | ||
'subject_guid' => elgg_get_logged_in_user_guid(), | ||
'object_guid' => $bookmark->getGUID(), | ||
)); | ||
} | ||
|
||
forward($bookmark->getURL()); | ||
} else { | ||
register_error(elgg_echo('bookmarks:save:failed')); | ||
forward("bookmarks"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
$url = trim(get_input('url')); | ||
$url_data = interconnected_analyze_url($url); | ||
|
||
if ($url_data['in_site'] == 1) | ||
{ | ||
// if (($url_data['handler'] != 'admin')&&($url_data['handler'] != 'activity')&&($url_data['handler'] != 'messages')&&($url_data['handler'] != 'members')&&($url_data['handler'] != 'search')) | ||
// { | ||
$count_shares = elgg_get_plugin_setting('count_shares', 'interconnected'); | ||
|
||
if ($count_shares == 1) | ||
$share_data = interconnected_get_counts($url, $url_data['handler'] , $url_data['guid']); | ||
// } | ||
echo '<result><shares>' . json_encode($share_data) . '</shares></result>'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
// Strip out any leading http:// or https:// | ||
// if other protocols such as ftp are present, | ||
// the intention is they'll fail regex further down | ||
|
||
$url = trim(get_input('url')); | ||
|
||
if (stripos($url, 'https://') === 0) | ||
{ | ||
$url = substr($url, 8); | ||
$portno = 443; | ||
} | ||
else | ||
{ | ||
if (stripos($url, 'http://') === 0) | ||
{ | ||
$url = substr($url, 7); | ||
} | ||
$portno = 80; | ||
} | ||
// Get the string index of the first forward slash | ||
// if there is none, add one at the end | ||
$slashIdx = strpos($url, '/'); | ||
if ($slashIdx === false) { | ||
$slashIdx = strlen($url); | ||
$url .= '/'; | ||
} | ||
|
||
//$regex_expression = '_^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/\S*)?$_iuS'; | ||
|
||
$regex_expression = '_^(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)(?:\.(?:[a-z\x{00a1}-\x{ffff}0-9]-*)*[a-z\x{00a1}-\x{ffff}0-9]+)*(?:\.(?:[a-z\x{00a1}-\x{ffff}]{2,})))(?::\d{2,5})?(?:/\S*)?$_iuS'; | ||
// Regex validation of URL string | ||
|
||
if (!preg_match($regex_expression, $url)) | ||
$result = '20 invalid URL string'; | ||
else { | ||
//echo '<result><status>' . $url . ' | OK</status></result>'; | ||
|
||
// Prepare for fsocketopen call | ||
// Split the URL into domain and path | ||
$domain = substr($url, 0, $slashIdx); | ||
$path = substr($url, $slashIdx); | ||
//error_log('domain = ' . $domain); | ||
//error_log('path = ' . $path); | ||
$method = "HEAD"; // HEAD request is more efficient | ||
$http_response = ""; | ||
$http_request = $method ." ". $path ." HTTP/1.1\r\n"; | ||
$http_request .= "Host: ".$domain."\r\n"; | ||
$http_request .= "User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)\r\n\r\n"; | ||
|
||
if ($portno == 443) | ||
$domain = 'tls://' . $domain; | ||
|
||
// Attempt to connect to this domain | ||
$fp = @fsockopen($domain, $portno, $errno, $errstr); | ||
if ($fp) { | ||
fputs($fp, $http_request); | ||
|
||
// Read first 64 bytes of response | ||
$http_response = fgets($fp, 64); | ||
fclose($fp); | ||
|
||
// regex out the HTTP status code | ||
// then validate whether the code is a 200 OK or 301/302 redirect | ||
preg_match('/HTTP\/\d\.\d (\d{3})/', $http_response, $matches); | ||
if (in_array(intval($matches[1]), array(200, 301, 302))) | ||
$result = '10 valid - ' . $http_response . '; ' . $domain . '; ' . $portno; | ||
else | ||
$result = '30 http error - ' . $http_response . '; ' . $domain . '; ' . $portno; | ||
} | ||
else | ||
$result = '40 unknown host: ' . $errstr; | ||
} | ||
|
||
echo '<result><status>' . $result . '</status></result>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
//require_once(elgg_get_plugins_path() . 'interconnected/lib/interconnected.php'); | ||
// from engine/start.php | ||
error_log('interconnected icon upgrade: start action'); | ||
global $START_MICROTIME; | ||
$batch_run_time_in_secs = 5; | ||
if ($status = get_input("upgrade_completed")) { | ||
error_log($status); | ||
} | ||
|
||
if (get_input("upgrade_completed")) { | ||
// set the upgrade as completed | ||
$factory = new ElggUpgrade(); | ||
$upgrade = $factory->getUpgradeFromPath("admin/upgrades/interconnected_icons"); | ||
if ($upgrade instanceof ElggUpgrade) { | ||
$upgrade->setCompleted(); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
// Offset is the total amount of errors so far. We skip these | ||
// annotations to prevent them from possibly repeating the same error. | ||
$offset = (int) get_input("offset", 0); | ||
$limit = 5; | ||
error_log('OFFSET = ' . $offset); | ||
$access_status = access_get_show_hidden_status(); | ||
access_show_hidden_entities(true); | ||
|
||
// don"t want any event or plugin hook handlers from plugins to run | ||
$original_events = _elgg_services()->events; | ||
$original_hooks = _elgg_services()->hooks; | ||
//_elgg_services()->events = new Elgg_EventsService(); | ||
//_elgg_services()->hooks = new Elgg_PluginHooksService(); | ||
|
||
elgg_register_plugin_hook_handler("permissions_check", "all", "elgg_override_permissions"); | ||
elgg_register_plugin_hook_handler("container_permissions_check", "all", "elgg_override_permissions"); | ||
_elgg_services()->db->disableQueryCache(); | ||
|
||
$success_count = 0; | ||
$error_count = 0; | ||
$warning_count = 0; | ||
|
||
while ((microtime(true) - $START_MICROTIME) < $batch_run_time_in_secs) | ||
{ | ||
$options["count"] = false; | ||
$options["offset"] = $offset; | ||
$options["limit"] = $limit; | ||
$options["type"] = 'object'; | ||
$options["subtype"] = 'bookmarks'; | ||
$options["order_by"] = 'e.time_created asc'; | ||
error_log('interconnected icon upgrade: before processing loop'); | ||
$bookmarks = elgg_get_entities($options); | ||
foreach ($bookmarks as $bookmark) | ||
{ | ||
error_log('interconnected icon upgrade: entity = ' . $bookmark->guid); | ||
$result = interconnected_update_thumbnail($bookmark); | ||
if ($result == TRUE) { | ||
$success_count++; | ||
} | ||
elseif ($result == 'no_image') | ||
{ | ||
$warning_count++; | ||
} | ||
elseif ($result == 'error') | ||
{ | ||
$error_count++; | ||
} | ||
} | ||
} | ||
|
||
access_show_hidden_entities($access_status); | ||
|
||
// replace events and hooks | ||
//_elgg_services()->events = $original_events; | ||
//_elgg_services()->hooks = $original_hooks; | ||
_elgg_services()->db->enableQueryCache(); | ||
|
||
// Give some feedback for the UI | ||
echo json_encode(array( | ||
"numSuccess" => $success_count, | ||
"numWarnings" => $warning_count, | ||
"numErrors" => $error_count | ||
)); |
Oops, something went wrong.