public static function inform($course, $id) { global $DB, $OUTPUT, $USER; $entry = self::get_one($id); // No restriction // Valid forever $value = get_user_key('blocks/quickmail', $USER->id, $course->id); $url = self::base_url($course->id); $approval_url = self::base_url($course->id, array('id' => $id, 'action' => self::VERIFY, 'activator' => $USER->id, 'key' => $value)); $a = new stdClass(); $a->address = $entry->address; $a->url = html_writer::link($approval_url, $approval_url->out()); $a->course = $course->fullname; $a->fullname = fullname($USER); $from = quickmail::_s('alternate_from'); $subject = quickmail::_s('alternate_subject'); $html_body = quickmail::_s('alternate_body', $a); $body = strip_tags($html_body); // Send email $user = clone $USER; $user->email = $entry->address; $user->firstname = quickmail::_s('pluginname'); $user->lastname = quickmail::_s('alternate'); $result = email_to_user($user, $from, $subject, $body, $html_body); // Create the event, trigger it. $event = \block_quickmail\event\alternate_email_added::create(array('courseid' => $course->id, 'context' => context_course::instance($course->id), 'other' => array('address' => $entry->address))); $event->trigger(); $html = $OUTPUT->box_start(); if ($result) { $html .= $OUTPUT->notification(quickmail::_s('entry_saved', $entry), 'notifysuccess'); $html .= html_writer::tag('p', quickmail::_s('entry_success', $entry)); } else { $html .= $OUTPUT->notification(quickmail::_s('entry_failure', $entry)); } $html .= $OUTPUT->continue_button($url); $html .= $OUTPUT->box_end(); return $html; }
echo WEB_PATH; ?> /uname/<?php echo $sd['sd_userid']; ?> " target="_blank" title="<?php echo get_user_name($sd['sd_userid']); ?> "><img alt="<?php echo $sd['sd_title']; ?> " src="<?php echo G_UPLOAD_PATH; ?> /<?php echo get_user_key($sd['sd_userid'], 'img', '8080'); ?> " width="40" height="40"><i></i></a></p> <p class="u-info"><span><a href="<?php echo WEB_PATH; ?> /uname/<?php echo $sd['sd_userid']; ?> " target="_blank" title="<?php echo get_user_name($sd['sd_userid']); ?> "><?php echo get_user_name($sd['sd_userid']); ?> </a><em><?php
public function getLotteryList() { $FIdx = $this->segment(4); $EIdx = 10; //$this->segment(5); $isCount = $this->segment(6); $shopsum = $this->db->GetList("select * from `@#_shoplist` where `q_end_time` !='' "); //最新揭晓 $shoplist['listItems'] = $this->db->GetList("select * from `@#_shoplist` where `q_end_time` !='' ORDER BY `q_end_time` DESC limit {$FIdx},{$EIdx}"); if (empty($shoplist['listItems'])) { $shoplist['code'] = 1; } else { foreach ($shoplist['listItems'] as $key => $val) { //查询出购买次数 $recodeinfo = $this->db->GetOne("select `gonumber` from `@#_member_go_record` where `uid` ='{$val['q_uid']}' and `shopid`='{$val['id']}' "); //echo "select `gonumber` from `@#_member_go_record` where `uid` !='$val[q_uid]' and `shopid`='$val[id]' "; $shoplist['listItems'][$key]['q_user'] = get_user_name($val['q_uid']); $shoplist['listItems'][$key]['userphoto'] = get_user_key($val['q_uid'], 'img'); $shoplist['listItems'][$key]['q_end_time'] = microt($val['q_end_time']); $shoplist['listItems'][$key]['gonumber'] = $recodeinfo['gonumber']; } $shoplist['code'] = 0; $shoplist['count'] = count($shopsum); } echo json_encode($shoplist); }
</div> </div> <div class="clearfix gray9 limit-user"> <a class="fl z-Limg" href="location.href='<?php echo WEB_PATH; ?> /uname/<?php echo idjia($shop['q_uid']); ?> "> <s></s> <img border="0" src="<?php echo G_UPLOAD_PATH; ?> /<?php echo get_user_key($shop['q_uid'], 'img'); ?> "> </a> <p> 恭喜<span class="z-user blue" onclick="location.href='<?php echo WEB_PATH; ?> /uname/<?php echo idjia($shop['q_uid']); ?> '"><?php echo get_user_name($shop['q_uid']); ?> </span>获得 </p>
?> </span></div> </div> <div class="share_goods"> <div class="share-get"> <a class="fl-img" href="<?php echo WEB_PATH; ?> /uname/<?php echo idjia($shaidan['sd_userid']); ?> " target="_blank"><img src="<?php echo G_UPLOAD_PATH; ?> /<?php echo get_user_key($shaidan['sd_userid'], 'img', '8080'); ?> "></a> <div class="share-getinfo"> <p class="getinfo-name">幸运获得者:<a class="blue Fb" href="<?php echo WEB_PATH; ?> /uname/<?php echo idjia($shaidan['sd_userid']); ?> " target="_blank"><?php echo userid($shaidan['sd_userid'], 'username'); ?> </a></p> <p>总共<?php echo _cfg('web_name_two');
<section class="clearfix g-member"> <div class="clearfix m-round m-name"> <div class="fl f-Himg"> <a href="<?php echo WEB_PATH; ?> /mobile/mobile/userindex/<?php echo $member['uid']; ?> " class="z-Himg"> <img src="<?php echo G_UPLOAD_PATH; ?> /<?php echo get_user_key($member['uid'], 'img'); ?> " border=0/></a> <p class="u-name"><b class="z-name gray01"><?php echo get_user_name($member['uid']); ?> </b><em>(<?php echo $member['mobile']; ?> )</em></p> <span class="z-class-icon01 gray02"><s></s><?php echo $member['yungoudj']; ?> </span> <li style="margin-top: -38px;margin-left: 70px;color:#666;">经验值: <?php echo $member['jingyan'];
public static function inform($course, $id) { global $DB, $OUTPUT, $USER; $entry = self::get_one($id); // No restriction. // Valid forever. $value = get_user_key('blocks/clampmail', $USER->id, $course->id); $url = self::base_url($course->id); $approval_url = self::base_url($course->id, array('id' => $id, 'action' => self::VERIFY, 'activator' => $USER->id, 'key' => $value)); $a = new stdClass(); $a->address = $entry->address; $a->url = html_writer::link($approval_url, $approval_url->out()); $a->course = $course->fullname; $a->fullname = fullname($USER); $from = clampmail::_s('alternate_from'); $subject = clampmail::_s('alternate_subject'); $html_body = clampmail::_s('alternate_body', $a); $body = strip_tags($html_body); // Send email. $user = clone $USER; $user->email = $entry->address; $user->firstname = clampmail::_s('pluginname'); $user->lastname = clampmail::_s('alternate'); $result = email_to_user($user, $from, $subject, $body, $html_body); // Add to log. add_to_log($course->id, 'clampmail', 'add', $url->out(), clampmail::_s('alternate') . ' ' . $entry->address); $html = $OUTPUT->box_start(); if ($result) { $html .= $OUTPUT->notification(clampmail::_s('entry_saved', $entry), 'notifysuccess'); $html .= html_writer::tag('p', clampmail::_s('entry_success', $entry)); } else { $html .= $OUTPUT->notification(clampmail::_s('entry_failure', $entry)); } $html .= $OUTPUT->continue_button($url); $html .= $OUTPUT->box_end(); return $html; }
/** * Ensure that the parsed data is valid, and if the handler requires address validation, validate the sender against * the user record of identified user record. * * @param string $address The fully formed e-mail address to process. * @return int The validation status. */ protected function validate($address) { if (!$this->record) { // The record does not exist, so there is nothing to validate against. return self::VALIDATION_INVALID_ADDRESS_FORMAT; } // Build the list of validation errors. $returnvalue = 0; if (!$this->handler) { $returnvalue += self::VALIDATION_UNKNOWN_HANDLER; } else { if (!$this->handler->enabled) { $returnvalue += self::VALIDATION_DISABLED_HANDLER; } } if (!isset($this->record->data) || !$this->record->data) { $returnvalue += self::VALIDATION_UNKNOWN_DATAKEY; } else { if ($this->record->data->expires != 0 && $this->record->data->expires < time()) { $returnvalue += self::VALIDATION_EXPIRED_DATAKEY; } else { if (!$this->record->user) { $returnvalue += self::VALIDATION_UNKNOWN_USER; } else { if ($this->record->user->deleted || !$this->record->user->confirmed) { $returnvalue += self::VALIDATION_DISABLED_USER; } $userkey = get_user_key('messageinbound_handler', $this->record->user->id); $hashvalidation = substr(md5($this->record->data->datakey . $userkey), 0, self::HASHSIZE) == $this->record->datakey; if (!$hashvalidation) { // The address data did not check out, so the originator is deemed invalid. $returnvalue += self::VALIDATION_INVALID_HASH; } if ($this->handler->validateaddress) { // Validation of the sender's e-mail address is also required. if ($address !== $this->record->user->email) { // The e-mail address of the originator did not match the // address held on record for this user. $returnvalue += self::VALIDATION_ADDRESS_MISMATCH; } } } } } return $returnvalue; }
echo $sd['sd_thumbs']; ?> "></a></dt> <dd class="share-name gray02"> <a href="<?php echo WEB_PATH; ?> /uname/<?php echo idjia($sd['sd_userid']); ?> " class="name-img"> <img id="imgUserPhoto" src="<?php echo G_UPLOAD_PATH; ?> /<?php echo get_user_key($sd['sd_userid'], 'img', '3030'); ?> " width="50" height="50" border="0"/> </a> <div class="share-name-r"> <span class="gray03"> <a href="<?php echo WEB_PATH; ?> /uname/<?php echo idjia($sd['sd_userid']); ?> " class="blue"><?php echo get_user_name($sd['sd_userid'], 'username'); ?> </a><?php
$s3ql['from'] = 'authority'; list($valid, $authorities) = apiQuery($s3ql); $json_auth = 'authorities=' . json_encode($authorities) . ''; #And the protocols because authroties don't have a protocol value, only an id $s3ql = array('user_id' => '1', 'db' => $db); $s3ql['from'] = 'protocol'; list($valid, $protocols) = apiQuery($s3ql); $json_prot = 'protocols=' . json_encode($protocols) . ''; $newProt = array(); if (is_array($protocols)) { foreach ($protocols as $prot) { $newProt[$prot['item_id']] = $prot['label']; } } if (!$key) { $key = get_user_key($user_id, $db); } #now encode the authorities for the javascript that is coming // //if(is_array($authorities)){ //foreach ($authorities as $authority) { // $json_auth_label[] = $authority['DisplayLabel']; // $json_auth_url[] = $authority['URI']; // $json_auth_protocol[] = $authority['Protocols']; // $json_auth_template[] = $authority['Template']; //} //$json_auth='authorities='.json_encode($json_auth).''; // //} ?> <body>
$ln = 1; if (is_array($shaidan)) { foreach ($shaidan as $sd) { ?> <div class="cSingleInfo"> <dl class="fl"><a href="<?php echo WEB_PATH; ?> /mobile/mobile/userindex/<?php echo $sd['sd_userid']; ?> "><img src="<?php echo G_UPLOAD_PATH; ?> /<?php echo get_user_key($sd['sd_userid'], 'img'); ?> "><b></b></a></dl> <div class="cSingleR m-round" id="<?php echo $sd['sd_id']; ?> "> <ul> <li><em class="blue" uweb="<?php echo $sd['sd_userid']; ?> "><?php echo userid($sd['sd_userid'], 'username'); ?> </em><strong>:</strong><span><?php echo $sd['sd_title'];
*/ ini_set('display_errors', 0); if ($_REQUEST['su3d']) { ini_set('display_errors', 1); } if (file_exists('config.inc.php')) { include 'config.inc.php'; } else { echo '<meta http-equiv="refresh" content= "0; target="_parent" url="login.php?error=2">'; exit; } #Get the key, send it to check validity $key = $_GET['key']; include_once 'core.header.php'; if (!$key) { $key = get_user_key($_SESSION['user']['account_id'], $_SESSION['db']); } #$args ='?key='.$_request['key'].'&url='.$_request['url'].'&project_id='.$_request['project_id'].'&resource_id='.$_request['resource_id']; #include_once 'webActions.php'; echo '<frameset rows="20%,80%" border="2">'; echo '<frame src="' . $action['header'] . '§ion_num=5" name="header">'; #echo '<frame src="'.$action['sparqlform'].'" name="sparqlframes" border="1">'; echo '<frame src="' . $action['sparqlform'] . '&key=' . $key . '" name="sparqlframes" border="1">'; ?> </frameset> </head> <body> </body>
?> <ul id="prevPeriod" class="m-round" codeid="<?php echo $gorecode['shopid']; ?> " uweb="<?php echo $gorecode['uid']; ?> "> <li class="fl"><s></s><img src="<?php echo G_TEMPLATES_IMAGE; ?> /mobile/loading.gif" src2="<?php echo G_UPLOAD_PATH; ?> /<?php echo get_user_key($itemlist[0]['q_uid'], 'img'); ?> "/></li> <li class="fr"><b class="z-arrow"></b></li> <li class="getInfo"> <dd> <em class="blue"><?php echo get_user_name($itemlist[0]['q_uid']); ?> </em>(<?php echo get_ip($gorecode['id'], 'ipcity'); ?> ) </dd> <dd>总共云购:<em class="orange arial"><?php echo $gorecode['gonumber'];
function URIinfo($uid, $user_id, $key, $db, $timer = array()) { $uid_info = uid($uid); $element = $GLOBALS['s3codes'][substr($uid, 0, 1)]; $local_info = s3info($element, ereg_replace('^' . letter($uid), '', $uid), $db); #echo $uid.'<pre>';print_r($local_info);exit; if (is_array($local_info) && !empty($local_info)) { $uid_info['Did'] = $GLOBALS['Did']; $uid_info['uid'] = $uid; $element_info = $local_info; $letter = strtoupper(substr($element, 0, 1)); $info = include_all(compact('elements', 'letter', 'element_info', 'user_id', 'db', 'key', 'timer')); $info['remote_uri'] = 0; #echo '<pre>';print_r($info);exit; } if ($uid_info['Did'] == $GLOBALS['Did'] || $uid_info['Did'] == S3DB_URI_BASE) { if (is_array($local_info) && !empty($local_info)) { $uid = str_replace(S3DB_URI_BASE . '/', '', $uid_info['uid']); $uid_info['Did'] = $GLOBALS['Did']; $uid_info['uid'] = $uid; $element_info = s3info($element, ereg_replace('^' . letter($uid), '', $uid), $db); $letter = strtoupper(substr($element, 0, 1)); $info = include_all(compact('elements', 'letter', 'element_info', 'user_id', 'db', 'key')); $info['remote_uri'] = 0; } else { $info = false; } #echo 'loca'.$uid;exit; #$info = URI($uid_info['uid'], $user_id, $db); #$info['remote_uri']=0; } else { #echo 'ola'.$uid;exit; $key = $key != '' ? $key : get_user_key($user_id, $db); #echo $user_id;exit; $info = remoteURI($letter . $uid_info['uid'], $key, $user_id, $db); #echo '<pre>';print_r($info);exit; $info['remote_uri'] = 1; if (!is_array($info) || empty($info)) { $info = URI($uid, $user_id, $db); } if (!is_array($info)) { $info = false; } } #echo '<pre>';print_r($info);exit; return $info; }
foreach ($cords as $c) { ?> <ul> <li class="rBg"><a href="<?php echo WEB_PATH; ?> /mobile/mobile/userindex/<?php echo $c['uid']; ?> "> <img id="imgUserPhoto" src="<?php echo G_UPLOAD_PATH; ?> /<?php echo get_user_key($c['uid'], 'img'); ?> " border="0"/> <s></s></a> </li> <!-- <li class="rInfo"><a href="<?php echo WEB_PATH; ?> /mobile/mobile/userindex/<?php echo $c['uid']; ?> "><?php echo userid($c['uid'], 'username'); ?> </a> <strong><?php
/** * Get the RSS Token from a given user id * * @param int $userid The user id * @return string the RSS token for the user */ function rss_get_token($userid) { return get_user_key('rss', $userid); }
public function lottery_shop_json() { if (!isset($_GET['gid'])) { echo json_encode(array("error" => '1')); return; exit; } $gid = trim($_GET['gid']); $times = (int) System::load_sys_config('system', 'goods_end_time'); if (!$times) { $times = 1; } $db = System::load_sys_class('model'); $gid = safe_replace($gid); $gid = str_ireplace("select", "", $gid); $gid = str_ireplace("union", "", $gid); $gid = str_ireplace("'", "", $gid); $gid = str_ireplace("%27", "", $gid); $gid = trim($gid, ','); if (!$gid) { $info = $db->GetOne("select qishu,xsjx_time,id,zongrenshu,thumb,title,q_uid,q_user,q_user_code,q_end_time,yunjiage from `@#_shoplist` where `q_showtime` = 'Y' order by `q_end_time` ASC"); } else { $infos = $db->GetList("select qishu,xsjx_time,id,zongrenshu,thumb,title,q_uid,q_user,q_user_code,q_end_time,yunjiage from `@#_shoplist` where `q_showtime` = 'Y' order by `q_end_time` ASC "); $gid = @explode('_', $gid); $info = false; foreach ($infos as $infov) { if (!in_array($infov['id'], $gid)) { $info = $infov; break; } } } if (!$info) { echo json_encode(array("error" => '1')); return; exit; } // //time格式 // // // $list_geshi=explode(".",$info['q_end_time']); // // $time_geshi = data("Y年m月d日 H:i",$info['q_end_time']); // System::load_sys_fun("my"); //$jiexiao_time = microt($info['q_end_time'],'r'); if ($info['xsjx_time']) { $info['q_end_time'] = $info['q_end_time'] + $times; } System::load_sys_fun("user"); $user = unserialize($info['q_user']); $user = get_user_name($info['q_uid'], "username"); $uid = $info['q_uid']; $upload = G_UPLOAD_PATH; $q_time = substr($info['q_end_time'], 0, 10); $city = get_uid_ip($info['q_user_code'], 'ipcity'); if ($q_time <= time()) { $db->Query("update `@#_shoplist` SET `q_showtime` = 'N' where `id` = '{$info['id']}' and `q_showtime` = 'Y' and `q_uid` is not null"); echo json_encode(array("error" => '-1')); return; exit; } $user_touxiang = get_user_key($info['q_uid'], 'img'); //缺中奖用户头像 来自城市 完整用户ID $user_shop_number = $db->GetOne("select sum(gonumber) as gonumber from `@#_member_go_record` where `uid`= '{$uid}' and `shopid` = '{$info['id']}' and `shopqishu` = '{$info['qishu']}'"); $user_shop_number = $user_shop_number['gonumber']; $times = $q_time - time(); $zhongjiangid = $uid + 1000000000; echo json_encode(array("error" => "0", "time_geshi" => $info['q_end_time'], "city" => "{$city}", "user_touxiang" => "{$user_touxiang}", "user_shop_number" => "{$user_shop_number}", "user" => "{$user}", "zongrenshu" => $info['zongrenshu'], "q_user_code" => $info['q_user_code'], "qishu" => $info['qishu'], "upload" => $upload, "thumb" => $info['thumb'], "id" => $info['id'], "uid" => "{$zhongjiangid}", "title" => $info['title'], "user" => $user, "times" => $times)); exit; }
function sparql($I) { ##Parse the query and build the dataset #global $timer; if (is_file(S3DB_SERVER_ROOT . '/pearlib/Benchmark/Timer.php')) { require_once S3DB_SERVER_ROOT . '/pearlib/Benchmark/Timer.php'; $timer = new Benchmark_Timer(); $timer->start(); } extract($I); ##To use SPARQL with ARC library, we will need it to work with a remote endpoint. That means that we do not want to configure ARC as a datastore, but rather to retrieve the data from s3db deployments, convert it to RDF and then use ARC to run the query on it /* ARC2 static class inclusion */ ini_set("include_path", S3DB_SERVER_ROOT . "/pearlib/arc" . PATH_SEPARATOR . ini_get("include_path")); include_once "ARC2.php"; $s3ql['url'] = $in['url'] != '' ? $in['url'] : $default_uri; $s3ql['key'] = $in['key'] != '' ? $in['key'] : get_user_key($user_id, $db); $q = $in['query']; list($query, $triples, $prefixes) = parse_sparql_query($q, $s3ql); $bq .= "PREFIX " . implode("\n PREFIX ", $query['prefix']) . "\n "; $bq .= "SELECT " . $query['select'][0] . "\n "; $bq .= "FROM" . implode(" FROM ", $query['from']) . "\n "; $bq .= "WHERE " . $query['where'][0] . "\n "; preg_match_all('(\\?[A-Za-z0-9]+) ', $bq, $vars); if ($vars[0]) { $vars = array_unique($vars[0]); $sparql_vars = implode(" ", $vars); } if ($query['select'][0] != "" && $query['select'][0] != "*") { $outputCols = explode(" ", trim($query['select'][0])); $outputCols = array_filter($outputCols); $outputCols = array_intersect($vars, $outputCols); } $sparql = ereg_replace("FROM(.*)WHERE", "WHERE", $bq); #lets preprocess the order by which the must be queries must be performed to optimize speedness list($iterations, $scrambled) = iterationOrder($triples, $prefixes, true); ##$rdf_results will contain the totality of triples retrieved from s3db; ##Start a rdf-api model $iterations = array_values($iterations); $rdf = S3DB_URI_BASE . '/s3dbcore/model.n3'; #base s3db rdf model $filename = md5($rdf); $file_place = $GLOBALS['uploads'] . '/'; #$queryModel = rdf2php($rdf); #$data = $queryModel->sparqlQuery($sparql); #echo '<pre>';print_r($data);exit; if ($timer) { $timer->setMarker('Core model read into results'); } $rdf_results = array(); $performedQueries = array(); $r = 0; foreach ($iterations as $it => $triples2query) { $S3QL = array(); $S3QLfinal = array(); foreach ($triples2query as $i => $tripleInd) { $tripleString = $tripleInd; list($subject, $predicate, $object) = explode(' ', trim($tripleString)); $subject = ereg_replace('^<|>$', '', $subject); $predicate = ereg_replace('^<|>$', '', $predicate); $object = ereg_replace('^<|>$', '', $object); $triple = compact('subject', 'predicate', 'object'); #sparql triple is used to calculate the values of the variables in the triple #$sparql_triple = $sparql_prefixes_default.' SELECT * WHERE { '.ltrim($tripleString).' . }'; #now lets interpret the triple to explore the space of possible queries on S3QL $pack = compact('triple', 's3ql', 'user_id', 'db', 'prefixes', 'varType', 'discoveredData', 'it', 'varTypeWhere', 'collected_data', 'performedQueries'); $sp = sparql_navigator($pack); extract($sp); # if($timer) $timer->setMarker('Built query '.$i); ##Remove queries that were already performed if ($S3QL[0]) { foreach ($S3QL as $s => $q) { $S3QLfinal[] = $q; $queried_elements[] = $element[$s]; } $localQueries[$tripleString] = $localQueries[0]; $remoteQueries[$tripleString] = $remoteQueries[0]; $localQueries = array_filter($localQueries); $remoteQueries = array_filter($remoteQueries); } } $S3QL = $S3QLfinal; ##Remove repeated queries $S3QL = array_unique($S3QL); #if only the s3ql is requested, we can return it now if ($in['output'] == 'S3QL') { foreach ($localQueries as $sparqlVersion => $s3qlVersion) { $Q[]['S3QL'] = S3QLQuery($s3qlVersion); } foreach ($remoteQueries as $rq) { $Q[]['S3QL'] = $rq; } $root = 's3ql'; #root is just the word that xml should parse as the root for each entry $data = $Q; $cols = array('S3QL'); $format = $in['format'] == '' ? 'html' : $in['format']; $z = compact('data', 'cols', 'format', 'root'); $out = outputFormat($z); return array(true, $out); } #If paralel library is activated, use it for the data. Otherwise use the custom version #$query_answers_file = 'sparql_query_ans'.rand(100,200); $a=fopen($query_answers_file, 'a'); if (!empty($S3QL)) { if (extension_loaded('curl') && $goparallel) { // Create cURL handlers if ($timer) { $timer->setMarker('Starting queries from group ' . $it); } foreach ($S3QL as $k => $url) { $qURL = $url; $ch[$k] = curl_init(); // Set options curl_setopt($ch[$k], CURLOPT_URL, $qURL . '&format=php'); curl_setopt($ch[$k], CURLOPT_RETURNTRANSFER, 1); } $mh = curl_multi_init(); foreach ($S3QL as $k => $url) { curl_multi_add_handle($mh, $ch[$k]); } $running = null; do { curl_multi_exec($mh, $running); if ($timer) { $timer->setMarker('Query ' . $k . ' of group ' . $it . ' executed'); } } while ($running > 0); foreach ($S3QL as $k => $url) { $answer[$k] = curl_multi_getcontent($ch[$k]); if (!empty($answer[$k])) { #@fwrite($a, $answer[$k]); ##This is what takes the longest after the query, can it be replaced? $ans = unserialize($answer[$k]); $letter = $queried_elements[$r][0]; if (empty($ans)) { ##is this query part is not optional, then the result will be null ##TO BE DEVELOPED SOON } else { $rdf_results[$letter][] = $ans; } $r++; ##Add the triples to already existing triples #Line up the answer with the model if ($timer) { $timer->setMarker('Query ' . $it . '=>' . $k . ' converted to php '); } } } curl_multi_close($mh); ####Time count #$time_end = microtime(true); #$time = $time_end - $time_start; #echo "Query took ".$time." seconds\n";exit; ### } else { #Now solve the remaining triples with the constants found in this one if (is_array($localQueries) && !empty($localQueries)) { foreach ($localQueries as $sparql_triple => $s3ql) { $s3ql = array_filter(array_diff_key($s3ql, array('url' => ''))); $answer = localQ($s3ql); if (!empty($answer)) { $rdfanswer = rdf2php($answer); #Line up the answer with the model $queryModel->addModel($rdfanswer); #Now perform the query on the small model to find a constant for the remaining queries #list($data,$discovered, $discoveredData,$queryModel) = executeQuery($queryModel,$sparql_triple,$discovered,$format); } } } if (is_array($remoteQueries) && !empty($remoteQueries)) { foreach ($remoteQueries as $remoteQuery) { $answer = remoteQ($remoteQuery); if (!empty($answer)) { $rdfanswer = rdf2php($answer); #Line up the answer with the model $queryModel->addModel($rdfanswer); #Now perform the query on the small model to find a constant for the remaining queries #list($data,$discovered, $discoveredData,$queryModel) = executeQuery($queryModel,$sparql_triple,$discovered,$format); } } } } } } ##Get the data from the file ##Now, add the dictionary data if ($complete) { include_once S3DB_SERVER_ROOT . '/s3dbcore/dictionary.php'; $s3qlN = compact('user_id', 'db'); $s3qlN['from'] = 'link'; $s3qlN['format'] = 'php'; $links = query_user_dictionaries($s3qlN, $db, $user_id); $links = unserialize($links); $rdf_results['E'][0] = $links; $s3qlN = compact('user_id', 'db'); $s3qlN['from'] = 'namespaces'; $s3qlN['format'] = 'php'; $ns = query_user_dictionaries($s3qlN, $db, $user_id); $ns = unserialize($ns); if ($timer) { $timer->setMarker('Dictionary links retrieved'); } } ##Convert the result into an RDF file $data_triples = array(); if (is_array($rdf_results)) { foreach ($rdf_results as $letter => $results2rdfize) { $dont_skip_core_name = false; $dont_skip_serialized = true; if (ereg('S', $letter)) { $dont_skip_serialized = false; } if (ereg('C|R|P', $letter)) { $dont_skip_core_name = true; } foreach ($results2rdfize as $k => $data) { $tmp_triples = rdf_encode($data, $letter, 'array', $s3ql['db'], $ns, $collected_data, $dont_skip_serialized, $dont_skip_core_name); if (is_array($tmp_triples)) { $data_triples = array_merge($data_triples, $tmp_triples); } } } } if (!empty($data_triples)) { $tmp['ns'] = $prefixes; /* #this one for turtle $parser = ARC2::getComponent('TurtleParser', $a); $index = ARC2::getSimpleIndex($triples, false) ; # false -> non-flat version $rdf_doc = $parser->toTurtle($index,$prefixes); */ $parser = ARC2::getComponent('RDFXMLParser', $tmp); $index = ARC2::getSimpleIndex($data_triples, false); /* false -> non-flat version */ $rdf_doc = $parser->toRDFXML($index, $prefixes); $filename = S3DB_SERVER_ROOT . '/tmp/' . random_string(15) . '.rdf'; $rr = fopen($filename, 'a+'); fwrite($rr, $rdf_doc); fclose($rr); if ($timer) { $timer->setMarker(count($data_triples) . ' triples written to file ' . $filename); } ##The better strategy would be to let the client cpu resolve the query; return the graphs with the rdf so that a sparql on the client can handle it if ($return_file_name) { if (filesize($filename) > 0) { return array(true, $filename); } else { return array(false); } exit; } if ($redirect) { ##And now use an external service ( I gave up with ARC) to parse the query $url2search = str_replace(S3DB_SERVER_ROOT, S3DB_URI_BASE, $filename); ##Giving up on ARC, surrender to sparql.com $remote_endpoint = "http://sparql.org/sparql?query="; $bq = ereg_replace("FROM <.*>", "FROM <" . $url2search . ">", $bq); $bq = urlencode($bq); $remote_endpoint .= $bq . '&default-graph-uri=&stylesheet=/xml-to-html.xsl'; return array(true, $remote_endpoint); } #echo $filename;exit; #And finally perform the query on the model. $queryModel = rdf2php($filename); $format = $in['format'] != '' ? $in['format'] : 'html'; unlink($filename); if ($timer) { $timer->setMarker('Data converted to a model the rdf-api can query'); } if (eregi('^(sparql-xml|sparql-html)$', $format)) { switch ($format) { case 'sparql-xml': $result = $queryModel->sparqlQuery($sparql, 'XML'); break; case 'sparql-html': $result = $queryModel->sparqlQuery($sparql, 'HTML'); if ($_REQUEST['su3d']) { $timer->stop(); $profiling = $timer->getProfiling(); echo "Query took " . $profiling[count($profiling) - 1]['total'] . ' sec'; } break; } if ($result) { return array(true, $result); } else { return false; } } elseif ($format == 'html.form') { $form .= ' <html> <head> </head><body> <form method="GET" action="sparql.php" id="sparqlform"> <h5>Target Deployment(s)</h5> <input type="hidden" name="key" value="' . $s3ql['key'] . '"/> <input type="hidden" name="format" value="' . $_REQUEST['format'] . '"/> <input type = "text" id="url" size = "100%" value="' . $GLOBALS['url'] . '" name="url"> <h5>SPARQL <a href="http://www.w3.org/TR/rdf-sparql-query/" target="_blank">(help!!)</a></h5> <br /> <textarea cols="100" id="sparql" rows="10" name = "query">' . stripslashes($sparql) . '</textarea><br /> <input type="submit" value="SPARQL this!" id="submitsparql"></body> </form> '; $form .= '<br />' . count($data) . " rows"; $form .= '<br />Query took ' . (strtotime(date('His')) - $start) . ' sec'; if (count($data) > 0) { return array(true, $form); } else { return array(false); } } else { #and output the result according to requested format $data = $queryModel->sparqlQuery($sparql); if ($timer) { $timer->setMarker('Query on SPARQL data executed by rdf-api.'); } if (is_array($outputCols) && !empty($outputCols)) { ##only this one are to be shown in the final result $vars = $outputCols; } $cleanCols = array(); foreach ($vars as $varname) { $cleanCols[] = ereg_replace('^\\?', '', $varname); } $outputData = array(); if (is_array($data)) { foreach ($data as $s => $sparql_line) { foreach ($sparql_line as $sparql_var => $sparql_var_value) { if ($sparql_var_value->uri != '') { $outputData[$s][ereg_replace('^\\?', '', $sparql_var)] = $sparql_var_value->uri; } elseif ($sparql_var_value->label != '') { $outputData[$s][ereg_replace('^\\?', '', $sparql_var)] = $sparql_var_value->label; } else { $outputData[$s][ereg_replace('^\\?', '', $sparql_var)] = ""; } } } } if ($timer) { $timer->setMarker('Data converted in a format that fun outputformat can read'); } #$timer ->display(); #root is just the word that xml should parse as the root for each entry $root = 'sparql'; if ($timer) { $timer->setMarker('All variables fitted into their places to represent in the final output'); } $data = $outputData; $cols = $cleanCols; if ($_REQUEST['su3d']) { $timer->stop(); $profiling = $timer->getProfiling(); echo "Query took " . $profiling[count($profiling) - 1]['total'] . ' sec<br>'; } $z = compact('data', 'cols', 'format', 'root'); $out = outputFormat($z); echo $out; exit; if (count($data) > 0) { return array(true, $out); } else { return array(false); } } } else { return array(false); } #else { #$out= formatReturn($GLOBALS['error_codes']['no_results'], 'Your query did not return any results.', $format,''); #} }
foreach ($datas as $row) { ?> <ul> <li><a href="<?php echo WEB_PATH; ?> /uname/<?php echo $row['uid'] + 1000000000; ?> " target="_blank"> <img id="imgUserPhoto" src="<?php echo G_UPLOAD_PATH; ?> /<?php echo get_user_key($row, 'img'); ?> " border="0"/> </a></li> <li><a href="<?php echo WEB_PATH; ?> /uname/<?php echo $row['uid'] + 1000000000; ?> " target="_blank"> <?php echo get_user_name($row); ?> </a>刚刚<?php