function replace_content($src, $dest, $filters)
{
    global $params, $ImgPath;
    if (isset($filters) && $filters['name'] == 'resize') {
        if (empty($dest)) {
            $dest = $ImgPath . basename($src);
        }
        $filename = basename($src);
        $source_path = dirname(dirname(__FILE__) . '/templates/' . $src);
        $target_path = dirname($dest);
        $thumb_file = convert_resize($filename, $source_path, $target_path, $filters['width'], $filters['height']);
        debugout($thumb_file);
    } else {
        if ($filters[0] == 'params') {
            if (is_file(G5_WS_ADMIN_PATH . '/templates/' . $src) && file_exists(G5_WS_ADMIN_PATH . '/templates/' . $src)) {
                $content = file_get_contents(G5_WS_ADMIN_PATH . '/templates/' . $src);
                if (!is_null($params)) {
                    $content = content_filters($content, $params);
                }
                $fp = fopen($dest, 'a+');
                fwrite($fp, $content, strlen($content));
                fclose($fp);
                chmod($dest, G5_FILE_PERMISSION);
            } else {
                return false;
            }
        } else {
            if (empty($dest)) {
                $dest = $ImgPath . basename($src);
            }
            if (is_file(G5_WS_ADMIN_PATH . '/templates/' . $src) && file_exists(G5_WS_ADMIN_PATH . '/templates/' . $src)) {
                $content = file_get_contents(G5_WS_ADMIN_PATH . '/templates/' . $src);
                $fp = fopen($dest, 'a+');
                fwrite($fp, $content, strlen($content));
                fclose($fp);
                chmod($dest, G5_FILE_PERMISSION);
            } else {
                return false;
            }
        }
    }
}
function isClaimed($accessToken, $orcID, $mainurl)
{
    $uri = $mainurl . '/v1.1/search/orcid-bio';
    $query = 'orcid:' . $orcID;
    $uri = $uri . "?q=" . $query;
    debugout("Finding info for OrcID " . $orcID);
    $curl_handle = curl_init();
    curl_setopt($curl_handle, CURLOPT_HEADER, false);
    curl_setopt($curl_handle, CURLINFO_HEADER_OUT, false);
    // enable tracking
    curl_setopt($curl_handle, CURLOPT_URL, $uri);
    curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($curl_handle, CURLOPT_TIMEOUT, 10);
    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl_handle, CURLOPT_USERAGENT, 'TAMU_Library');
    curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array("Accept: application/orcid+xml"));
    $content = curl_exec($curl_handle);
    $headerSent = curl_getinfo($curl_handle, CURLINFO_HEADER_OUT);
    // request headers
    $http_status = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
    curl_close($curl_handle);
    try {
        $xml = simplexml_load_string($content);
        $orcID = $xml->{'orcid-search-results'}->{'orcid-search-result'}->{'orcid-profile'}->{'orcid-identifier'}->{'path'};
        if (validorcID($orcID)) {
            $givenNames = $xml->{'orcid-search-results'}->{'orcid-search-result'}->{'orcid-profile'}->{'orcid-bio'}->{'personal-details'}->{'given-names'};
        } else {
            $givenNames == NULL;
        }
    } catch (Exception $e) {
        // handle the error
        echo "error";
        echo "<br><br>";
        $givenNames = 0;
        echo $e->getMessage();
    }
    if ($givenNames == "Reserved For Claim") {
        return "waiting";
    } elseif ($givenNames != NULL) {
        return "claimed";
    } elseif ($givenNames == NULL) {
        return "not found";
    } else {
        return "error";
    }
    return;
}
示例#3
0
function answer_guest_count($su_id)
{
    global $g5;
    $sql = "select count(sur_id) from {$g5['surveys_r_table']} where su_id = '{$su_id}' and mb_id = '' group by mb_id ";
    debugout($sql);
}