Esempio n. 1
0
 function handleDocumentInfo(PHPCrawlerDocumentInfo $p)
 {
     $u = $p->url;
     $c = $p->http_status_code;
     $s = $p->source;
     if ($c == 200 && $s != "") {
         $html = str_get_html($s);
         if (is_object($html)) {
             $d = "";
             $do = $html->find("meta[name=description]", 0);
             if ($do) {
                 $d = $do->content;
             }
             $t = $html->find("title", 0);
             if ($t) {
                 $t = $t->innertext;
                 addURL($t, $u, $d);
             }
             $html->clear();
             unset($html);
         }
     }
 }
Esempio n. 2
0
/**
 * Import nodes and connections from the given CIF url for the selected nodeids into the given map.
 * The node import limit is set by '$CFG->ImportLimit'.
 * @param url the url for the CIF data to load
 * @param mapid the id of the map to get alerts for
 * @param selectedids an array of the CIF node ides to import
 * @param poses an array of the positions of the nodes in the map each array item is in
 * the format 'x:y' and the position in the array should correspond ot the position of
 * its node in the selectednodeids array.
 * before it is considered out of date and should be refetched and recalculated.
 * Defaults to 60 seconds.
 * @param private true if the data should be created as private, else false.
 * @return View object of the map or Error.
 *
 */
function addNodesAndConnectionsFromJsonld($url, $mapid, $selectedids, $poses, $private)
{
    global $USER, $HUB_FLM, $CFG, $ERROR;
    require_once $HUB_FLM->getCodeDirPath("core/io/catalyst/catalyst_jsonld_reader.class.php");
    require_once $HUB_FLM->getCodeDirPath("core/lib/url-validation.class.php");
    //error_log(print_r($selectedids, true));
    if (count($selectedids) > $CFG->ImportLimit) {
        $ERROR = new error();
        $ERROR->createAccessDeniedError();
        return $ERROR;
    }
    //error_log(print_r($poses, true));
    // Check if the map is in a group and if so get the group id.
    $groupid = "";
    $v = new View($mapid);
    $view = $v->load();
    if (!$view instanceof Error) {
        if (isset($view->viewnode->groups)) {
            $groups = $view->viewnode->groups;
            if (count($groups) > 0) {
                $groupid = $groups[0]->groupid;
            }
        }
    } else {
        return $view;
    }
    // make sure current user in group, if group set.
    if ($groupid != "") {
        $group = new Group($groupid);
        if (!$group instanceof Error) {
            if (!$group->ismember($USER->userid)) {
                $error = new Error();
                return $error->createNotInGroup($group->name);
            }
        }
    }
    $withhistory = false;
    $withvotes = false;
    $reader = new catalyst_jsonld_reader();
    $reader = $reader->load($url, $withhistory, $withvotes);
    if (!$reader instanceof Error) {
        $nodeset = $reader->nodeSet;
        $nodes = $nodeset->nodes;
        $count = count($nodes);
        $newnodeSet = new NodeSet();
        $newNodeCheck = array();
        for ($i = 0; $i < $count; $i++) {
            $node = $nodes[$i];
            $position = array_search($node->nodeid, $selectedids);
            //error_log("position:".$position);
            if ($position !== FALSE) {
                $position = intval($position);
                $positem = $poses[$position];
                $positemArray = explode(":", $positem);
                $xpos = "";
                $ypos = "";
                if (count($positemArray) == 2) {
                    $xpos = $positemArray[0];
                    $ypos = $positemArray[1];
                }
                //error_log("xpos:".$xpos.":ypos:".$ypos);
                $role = getRoleByName($node->rolename);
                $description = "";
                if (isset($node->description)) {
                    $description = $node->description;
                }
                $newnode = addNode($node->name, $description, $private, $role->roleid);
                //error_log(print_r($newnode, true));
                if (!$newnode instanceof Error) {
                    $newNodeCheck[$node->nodeid] = $newnode;
                    //error_log($node->nodeid);
                    // if we have positioning information add the node to the map.
                    if ($xpos != "" && $ypos != "") {
                        $viewnode = $view->addNode($newnode->nodeid, $xpos, $ypos);
                        //if (!$viewnode instanceof Error) {
                    }
                    if (isset($node->homepage) && $node->homepage != "") {
                        $URLValidator = new mrsnk_URL_validation($node->homepage, MRSNK_URL_DO_NOT_PRINT_ERRORS, MRSNK_URL_DO_NOT_CONNECT_2_URL);
                        if ($URLValidator->isValid()) {
                            $urlObj = addURL($node->homepage, $node->homepage, "", $private, "", "", "", "cohere", "");
                            $newnode->addURL($urlObj->urlid, "");
                            // Add url to group? - not done on forms at present
                        } else {
                            error_log('Invalid node homepage: ' . $node->homepage . ': for ' . $node->nodeid);
                        }
                    }
                    if (isset($node->users[0])) {
                        $user = $node->users[0];
                        if (isset($user->homepage) && $user->homepage != "") {
                            $URLValidator = new mrsnk_URL_validation($user->homepage, MRSNK_URL_DO_NOT_PRINT_ERRORS, MRSNK_URL_DO_NOT_CONNECT_2_URL);
                            if ($URLValidator->isValid()) {
                                $urlObj = addURL($user->homepage, $user->homepage, "", $private, "", "", "", "cohere", "");
                                $newnode->addURL($urlObj->urlid, "");
                                // Add url to group? - not done on forms at present
                            } else {
                                error_log('Invalid user homepage: ' . $user->homepage . ': for ' . $user->userid);
                            }
                        }
                    }
                    //if ($groupid != "") {
                    //	$newnode->addGroup($groupid);
                    //}
                    $newnodeSet->add($newnode);
                } else {
                    error_log(print_r($newnode, true));
                }
            }
        }
        $connectionset = $reader->connectionSet;
        $connections = $connectionset->connections;
        $count = count($connections);
        for ($i = 0; $i < $count; $i++) {
            $conn = $connections[$i];
            $from = $conn->from;
            $to = $conn->to;
            $fromrole = $conn->fromrole;
            $torole = $conn->torole;
            if (isset($newNodeCheck[$from->nodeid]) && isset($newNodeCheck[$to->nodeid])) {
                $newFromNode = $newNodeCheck[$from->nodeid];
                $newToNode = $newNodeCheck[$to->nodeid];
                // Might not need this as it might be done already
                //if ($newFromNode->role->name != $fromrole->name) {
                //	updateNodeRole($newFromNode->nodeid,$fromrole->name);
                //}
                $linklabelname = $conn->linklabelname;
                //error_log($linklabelname);
                $lt = getLinkTypeByLabel($linklabelname);
                if (!$lt instanceof Error) {
                    $linkType = $lt->linktypeid;
                    //$frole = getRoleByName($fromrole->name);
                    //$trole = getRoleByName($torole->name);
                    $connection = addConnection($newFromNode->nodeid, $newFromNode->role->roleid, $linkType, $newToNode->nodeid, $newToNode->role->roleid, 'N', "");
                    //error_log(print_r($connection, true));
                    if (!$connection instanceof Error) {
                        // add to group
                        if (isset($groupid) && $groupid != "") {
                            $connection->addGroup($groupid);
                        }
                        $viewcon = $view->addConnection($connection->connid);
                        //error_log(print_r($viewcon,true));
                    } else {
                        error_log(print_r($connection, true));
                    }
                } else {
                    error_log("for label:" . $linklabelname . ":" . print_r($lt, true));
                }
            }
        }
    } else {
        return $reader;
    }
    return $view;
}
Esempio n. 3
0
     break;
     /** URLS **/
 /** URLS **/
 case "autocompleteurldetails":
     $url = required_param('url', PARAM_URL);
     $response = autoCompleteURLDetails($url);
     break;
 case "addurl":
     $url = required_param('url', PARAM_URL);
     $title = required_param('title', PARAM_TEXT);
     $desc = required_param('desc', PARAM_TEXT);
     $clip = optional_param('clip', "", PARAM_TEXT);
     $clippath = urldecode(optional_param('clippath', "", PARAM_HTML));
     //$cliphtml = urldecode(optional_param('cliphtml',"",PARAM_HTML));
     $cliphtml = "";
     $response = addURL($url, $title, $desc, $private, $clip, $clippath, $cliphtml);
     break;
 case "deleteurl":
     $urlid = required_param('urlid', PARAM_ALPHANUMEXT);
     $response = deleteURL($urlid);
     break;
     /** CONNECTING NODE AND URL **/
 /** CONNECTING NODE AND URL **/
 case "addurltonode":
     $urlid = required_param('urlid', PARAM_ALPHANUMEXT);
     $nodeid = required_param('nodeid', PARAM_ALPHANUMEXT);
     $comments = optional_param("comments", "", PARAM_TEXT);
     $response = addURLToNode($urlid, $nodeid, $comments);
     break;
     /** CONNECTIONS **/
 /** CONNECTIONS **/
Esempio n. 4
0
                 $resourcetitle = $resourceurl;
             }
             // ADD URL TO REF and EVIDENCE
             $clip = "";
             $clippath = "";
             $identifier = "";
             if (isset($resourcecliparray[$i])) {
                 $clip = $resourcecliparray[$i];
             }
             if (isset($resourceclippatharray[$i])) {
                 $clippath = $resourceclippatharray[$i];
             }
             if (isset($identifierarray[$i])) {
                 $identifier = $identifierarray[$i];
             }
             $urlObj = addURL($resourceurl, $resourcetitle, "", $private, $clip, $clippath, "", "cohere", $identifier);
             $issuenode->addURL($urlObj->urlid, "");
             $i++;
         }
     }
 }
 echo "<script type='text/javascript'>";
 if (isset($handler) && $handler != "") {
     echo "try { ";
     echo "window.opener." . $handler . "('" . $issuenode->nodeid . "');";
     echo "}";
     echo "catch(err) {";
     echo "}";
 } else {
     echo "try { ";
     echo 'window.opener.location.reload(true);';
Esempio n. 5
0
<?php

require_once 'config.php';
$_SESSION['url'] = $_REQUEST['url'];
addURL($_REQUEST['url']);
$_SESSION['method'] = $_REQUEST['method'];
$parseURL = parse_url($_REQUEST['url']);
$keyValue = array();
foreach ($_REQUEST['key'] as $k => $key) {
    if (isset($key) && $key != "") {
        $keyValue[$key] = $_REQUEST['value'][$k];
        addKey($key, $parseURL['host']);
    }
}
$_SESSION['key_value'] = $keyValue;
$headerKeyValue = array();
$isContentTypeSet = FALSE;
foreach ($_REQUEST['header_value'] as $k => $value) {
    if (isset($value) && $value != "") {
        if ($_REQUEST['header_key'][$k] == "Content-Type") {
            $isContentTypeSet = TRUE;
        }
        $headerKeyValue[] = $_REQUEST['header_key'][$k] . ": " . $value;
    }
}
$_SESSION['header_key_value'] = $headerKeyValue;
if (!$isContentTypeSet) {
    $headerKeyValue[] = 'Content-Type: multipart/form-data';
}
$headerKeyValue[] = 'Expect:';
$ch = curl_init();