public function collectData(array $param) { function getMetadata($id) { $metadata = array(); $html2 = file_get_html('http://www.dailymotion.com/video/' . $id) or $this->returnError('Could not request Dailymotion.', 404); $metadata['title'] = $html2->find('meta[property=og:title]', 0)->getAttribute('content'); $metadata['timestamp'] = strtotime($html2->find('meta[property=video:release_date]', 0)->getAttribute('content')); $metadata['thumbnailUri'] = $html2->find('meta[property=og:image]', 0)->getAttribute('content'); $metadata['uri'] = $html2->find('meta[property=og:url]', 0)->getAttribute('content'); return $metadata; } $html = ''; $limit = 5; $count = 0; if (isset($param['u'])) { // user timeline mode $this->request = $param['u']; $html = file_get_html('http://www.dailymotion.com/user/' . urlencode($this->request) . '/1') or $this->returnError('Could not request Dailymotion.', 404); } else { if (isset($param['p'])) { // playlist mode $this->request = strtok($param['p'], '_'); $html = file_get_html('http://www.dailymotion.com/playlist/' . urlencode($this->request) . '') or $this->returnError('Could not request Dailymotion.', 404); } else { if (isset($param['s'])) { // search mode $this->request = $param['s']; $page = 1; if (isset($param['pa'])) { $page = (int) preg_replace("/[^0-9]/", '', $param['pa']); } $html = file_get_html('http://www.dailymotion.com/search/' . urlencode($this->request) . '/' . $page . '') or $this->returnError('Could not request Dailymotion.', 404); } else { $this->returnError('You must either specify a Dailymotion username (?u=...) or a playlist id (?p=...) or search (?s=...)', 400); } } } foreach ($html->find('div.media a.preview_link') as $element) { if ($count < $limit) { $item = new \Item(); $item->id = str_replace('/video/', '', strtok($element->href, '_')); $metadata = getMetadata($item->id); $item->uri = $metadata['uri']; $item->thumbnailUri = $metadata['thumbnailUri']; $item->title = $metadata['title']; $item->timestamp = $metadata['timestamp']; $item->content = '<a href="' . $item->uri . '"><img src="' . $item->thumbnailUri . '" /></a><br><a href="' . $item->uri . '">' . $item->title . '</a>'; $this->items[] = $item; $count++; } } }
function _get_btsConfig($raw) { $meta = ''; $body =& $raw; while (true) { list($line, $body) = explode("\n", $body, 2); if ($line[0] == '#') { continue; } if (strpos($line, ':') === false or trim($line) == '') { break; } $meta .= $line . "\n"; } return getMetadata($meta, 1); }
function processor_bts($formatter, $value = '', $options = '') { global $DBInfo; $rating_script =& $GLOBALS['rating_script']; $script = <<<SCRIPT <script type="text/javascript"> /*<![CDATA[*/ /* from bugzilla script with small fix */ /* Outputs a link to call replyToComment(); used to reduce HTML output */ function addReplyLink(id) { /* XXX this should really be updated to use the DOM Core's * createElement, but finding a container isn't trivial */ document.write('[<a href="#add_comment" onclick="replyToComment(' + id + ');">reply<' + '/a>]'); } /* Adds the reply text to the `comment' textarea */ function replyToComment(id) { /* pre id="comment_name_N" */ var text_elem = document.getElementById('comment_text_'+id); var text = getText(text_elem); /* make sure we split on all newlines -- IE or Moz use \\r and \\n * respectively */ text = text.split(/\\r|\\n/); var replytext = ""; for (var i=0; i < text.length; i++) { replytext += "> " + text[i] + "\\n"; } replytext = "(In reply to comment #" + id + ")\\n" + replytext + "\\n"; /* <textarea name="savetext"> */ var textarea = document.getElementsByTagName('textarea'); textarea[0].value += replytext; textarea[0].focus(); } if (!Node) { /* MSIE doesn't define Node, so provide a compatibility array */ var Node = { TEXT_NODE: 3, ENTITY_REFERENCE_NODE: 5 }; } /* Concatenates all text from element's childNodes. This is used * instead of innerHTML because we want the actual text (and * innerText is non-standard) */ function getText(element) { var child, text = ""; for (var i=0; i < element.childNodes.length; i++) { child = element.childNodes[i]; var type = child.nodeType; if (type == Node.TEXT_NODE || type == Node.ENTITY_REFERENCE_NODE) { text += child.nodeValue; } else { /* recurse into nodes of other types */ text += getText(child); } } return text; } /*]]>*/ </script> SCRIPT; if ($value[0] == '#' and $value[1] == '!') { list($arg, $value) = explode("\n", $value, 2); } if (!empty($arg)) { # get parameters list($tag, $user, $date, $title) = explode(" ", $line, 4); if (preg_match('/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/', $user)) { $user = "******"; } if ($date && $date[10] == 'T') { $date[10] = ' '; $time = strtotime($date . ' GMT'); $date = '@ ' . date('Y-m-d [h:i a]', $time); } } $bts_conf = 'BugTrack/Config'; if ($DBInfo->hasPage($bts_conf)) { $p = new WikiPage($bts_conf); $config_raw = $p->get_raw_body(); $confs = _get_btsConfig($config_raw); #print_r($confs); } $body = $value; # parse metadata $meta = ''; while (true) { list($line, $body) = explode("\n", $body, 2); if (isset($line[0]) and $line[0] == '#') { continue; } if (strpos($line, ':') === false or !trim($line)) { break; } $meta .= $line . "\n"; } $metas = getMetadata($meta); $head = "##[[InputForm(form:get:bts)]]\n##[[HTML(<table width='100%'><tr><td @@ valign='top'>)]]\n"; $extra = ''; $attr = '<tablewidth="100%">'; $sep = 1; foreach ($metas as $k => $v) { $kk = $k; if (in_array($k, array('Version', 'Component'))) { $kk = str_replace(' ', '-', ucwords($metas['Product'])) . '-' . $k; } if ($k[0] == 'X' and $k[1] == '-') { if (isset($confs[$kk])) { $v = '[[InputForm(:' . _($kk) . ':' . str_replace($v, $v . ' 1', $confs[$kk]) . ')]]'; } $k = substr($k, 2); if (substr($k, 0, 9) == 'Separator') { $sep++; $head .= "\n##\n##[[HTML(</td><td @@ valign='top'>)]]\n"; $attr = '<tablewidth="100%">'; } else { if (substr($k, 0, 4) == 'Date') { $v = '[[DateTime(' . $v . ')]]'; } $head .= "||" . $attr . " ''" . $k . "'' || " . $v . " ||\n"; $attr = ''; } } else { if ($k == 'Summary' or $k == 'Keywords') { $v = str_replace(':', ':', $v); $v = '[[InputForm(input:' . _($k) . ':' . $confs[$k] . ':' . $v . ')]]'; $extra .= "|| '''" . _($k) . "'''''':'''||{$v}||\n"; } else { if (isset($confs[$kk])) { $v = '[[InputForm(:' . _($kk) . ':' . str_replace($v, $v . ' 1', $confs[$kk]) . ')]]'; } $head .= "||" . $attr . "<width='30%'> '''" . _($k) . "'''''':'''||" . $v . " ||\n"; $attr = ''; } } } $attr = 'width="100%"'; if ($sep > 1) { $attr = 'width="' . 100 / $sep . '%"'; } $head = preg_replace('/@@/', $attr, $head); $head .= "\n##\n##[[HTML(</td></tr></table>)]]\n" . $extra . "\n" . "[[InputForm(submit:" . _("Save Changes") . ")]]\n##[[InputForm]]"; #print '<pre>'.$head.'</pre>'; print <<<HEAD <fieldset id="bts-properties"><legend>Change Properties</legend> HEAD; $formatter->send_page($head, $options); print <<<TAIL </fieldset> TAIL; if ($body) { $options['nosisters'] = 1; $copy = $body; $hidden = ''; #list($comment,$copy)=explode("----\n",$copy,2); $tmp = explode("----\n", $copy, 2); $comment = $tmp[0]; $copy = isset($tmp[1]) ? $tmp[1] : ''; while (!empty($comment)) { #list($comment,$copy)=explode("----\n",$copy,2); $tmp = explode("----\n", $copy, 2); $comment = $tmp[0]; $copy = isset($tmp[1]) ? $tmp[1] : ''; if (preg_match('/^Comment-Id:\\s*(\\d+)/i', $comment, $m)) { list($myhead, $my) = explode("\n\n", $comment, 2); $hidden .= '<pre style="display:none;" id="comment_text_' . $m[1] . '">' . _html_escape($my) . '</pre>'; } } ob_start(); # add some basic rule/repl for bts $rule = "/----\nComment-Id:\\s*(\\d+)\n" . "From:\\s*([^\n]+)\nDate:\\s*([^\n]+)\n\n/im"; $repl = "----\n'''Comment-Id:''' [#c\\1][#c\\1 #\\1] by \\2 on [[DateTime(\\3)]] [reply \\1]\n\n"; $body = preg_replace($rule, $repl, $body); $formatter->quote_style = 'bts-comment'; $options['usemeta'] = 1; # $formatter->baserule[] = "/^((-=)+-?\$)/"; $formatter->baserule[] = "/ comment #(\\d+)\\b/"; $formatter->baserule[] = "/Bug #?(\\d+)\\b/"; $formatter->baserule[] = "/\\[reply (\\d+)\\]/"; $formatter->baserepl[] = "<hr />\n"; $formatter->baserepl[] = " comment [#c\\1 #\\1]"; $formatter->baserepl[] = "wiki:BugTrack:\\1"; $formatter->baserepl[] = "<script type='text/javascript'><!--\n addReplyLink(\\1); //--></script>"; # $formatter->send_page($body, $options); $msg = ob_get_contents(); ob_end_clean(); } $msg .= $formatter->macro_repl('Comment(meta)', '', $options); if (!empty($bts_script)) { return $msg . $hidden; } $bts_script = 1; return $script . $msg . $hidden; }
function render($sourceDir, $targetDir, $template, $dir, $baseUrl, $relativeUrl = '/', $breadcrumbs = array(), $breadcrumbSeparator) { $info = array(); $error = array(); $htmldoctreeInfo = '<p>Generated with <a href="http://www.nterms.com/tools/htmldoctree">HTMLDocTree</a></p>'; $info[] = "Entering directory: <em>" . $sourceDir . '</em><br/>'; $source = opendir($sourceDir); $target = opendir($targetDir); // generate the breadcrumb $meta = array(); if (is_file($sourceDir . DS . 'index.html')) { $content = getFileContent($sourceDir . DS . 'index.html'); $meta = getMetadata($content); } $title = isset($meta['title']) ? $meta['title'] : basename($dir); $dirUrl = $baseUrl . $relativeUrl; $breadcrumbs[] = ' <span class="breadcrumb-node link"><a href="' . $dirUrl . '" title="' . $title . '" >' . $title . '</a></span>'; if ($source) { if ($target) { while ($item = readdir($source)) { if ($item == '.' || $item == '..') { continue; } $srcPath = $sourceDir . DS . $item; $destPath = $targetDir . DS . $item; $info[] = "Processing node: <em>" . $srcPath . '</em><br/>'; if (is_dir($srcPath)) { if (!is_dir($destPath)) { //unlink($path); $info[] = "Creating directory: <em>" . $destPath . '</em><br/>'; if (!mkdir($destPath)) { $error[] = "Creating directory failed: <em>" . $destPath . '</em><br/>'; return; } } render($srcPath, $destPath, $template, $dir . DS . $item, $baseUrl, $relativeUrl . '/' . $item, $breadcrumbs, $breadcrumbSeparator); } if (is_file($srcPath)) { if (strpos($srcPath, ".html") > 0) { $itemId = str_replace(".html", '', $item); $pageId = $dir . '/' . $itemId; $pageUrl = $baseUrl . $dir . '/' . $item; $replacementPatterns = array('/<!-- *{content} *-->/i', '/<!-- *{breadcrumb} *-->/i', '/<!-- *{title} *-->/i', '/<!-- *{description} *-->/i', '/<!-- *{disqus_identifier} *-->/i', '/<!-- *{disqus_url} *-->/i', '/<!-- *{htmldoctree} *-->/i'); $replacementStrings = array('content', 'beadcrumb', 'title', 'description', $pageId, $pageUrl, $htmldoctreeInfo); $info[] = "Creating file: <em>" . $destPath . '</em>'; $dest = fopen($destPath, 'w'); if (!$dest) { $error[] = "Creating file failed: <em>" . $destPath . '</em>'; } $content = getFileContent($srcPath); // get metadata if available $meta = getMetadata($content); $html = setMetadata($meta, $html); $replacementStrings[0] = $content; //$html = str_replace("<!-- {content} -->", $content, $template); //$html = str_replace("<!-- {disqus_identifier} -->", $pageId, $html); //$html = str_replace("<!-- {disqus_url} -->", $pageUrl, $html); //$html = str_replace("<!-- {htmldoctree} -->", $htmldoctreeInfo, $html); // page title and description $title = isset($meta['title']) ? $meta['title'] : str_replace('-', ' ', ucfirst($itemId)); $description = isset($meta['description']) ? $meta['description'] : ''; $replacementStrings[2] = $title; $replacementStrings[3] = $description; // breadcrumbs $itemUrl = $baseUrl . $relativeUrl . '/' . $item; $itemBreadcrumbs = $breadcrumbs; $itemBreadcrumbs[] = '<span class="breadcrumb-node last">' . $title . '</span>'; $breadcrumb = implode(' <span class="breadcrumb-node separator"> ' . $breadcrumbSeparator . ' </span> ', $itemBreadcrumbs); $replacementStrings[1] = $breadcrumb; //$breadcrumb .= ' > ' . $title; //'<a href="' . $itemUrl . '" title="' . $title . '" >' . $title . '</a>'; $html = preg_replace($replacementPatterns, $replacementStrings, $template, 1); //$breadcrumbs = array(); fwrite($dest, $html); fclose($dest); } else { $info[] = "Copying file: <em>" . $srcPath . '</em>'; if (!copy($srcPath, $destPath)) { $error[] = "Copying file failed: <em>" . $srcPath . '</em>'; } } } } } else { $error[] = "Processing failed on directory: <em>" . $targetDir . '</em><br/>'; } } else { $error[] = "Processing failed on directory: <em>" . $sourceDir . '</em><br/>'; } return array('info' => $info, 'error' => $error); }
$response = deleteApplication($email, $password, $dbName, $appId); } if (isOK($response)) { printResult($response, "DELETING APPLICATION FROM CVS FAILED", " Application {$appId} has been deleted from the database {$dbName}." . PHP_EOL . " ---- DELETING APPLICATION FROM CVS SUCCESSFULLY COMPLETED ----"); } else { echo $response->getMessage(); } break; case "addItem": echo "Adding item..." . PHP_EOL; $email = getEMail(); $password = getPassword(); $dbName = getDbName(); $filePath = getItemPath(); $identifier = getIdentifier(); $metadata = getMetadata(); $msg = validateItemPath($filePath); if (isset($msg)) { echo $msg; break; } $fileName = basename($filePath); $parentFolder = dirname($filePath); $oldFileName = $fileName; $msg = replaceWhitespaces($fileName, $parentFolder); if (isset($msg)) { break; } else { $filePath = substr_replace($filePath, $fileName, strlen($filePath) - strlen($oldFileName)); } echo PHP_EOL . "Uploading " . $filePath . "..." . PHP_EOL;
array_push($line, implode("|",$value)); } if($line){ print ">>>".$recid." ".implode(",",$line)."<br/>"; //$outp = $outp.implode(",",$line)."\n"; fwrite($fp, implode(",",$line)."\n"); } $res->close(); */ fclose($fp); } //save csv output for dataset: records of particular record type //file_put_contents($rtfolder."/".$rt.".csv", $outp); $rectypedef = mysqli__select_array($mysqli, 'select rty_Name, rty_Description from defRecTypes where rty_ID=' . $rt); //save metadata for dataset $meta = getMetadata($rectypedef[0], 'Heurist db ' . HEURIST_DBNAME . '. Rectype#' . $rt . '. ' . $rectypedef[1], 'DATASET'); //$datatable = $meta->dataTables->addChild('dataTable'); $dataTable = $meta->addChild('dataTables')->addChild('dataTable'); $columns = $dataTable->addChild('dataTableColumns'); $cnt = 0; foreach ($recstruc as $dt_id => $detail) { $column = $columns->addChild('dataTableColumn'); if ($detail[3] == "date" || $detail[3] == "year") { $column->columnDataType = 'DATETIME'; } else { if ($detail[3] == "integer") { $column->columnDataType = 'BIGINT'; } else { if ($detail[3] == "float") { $column->columnDataType = 'DOUBLE'; } else {
echo '<td class="header" id="full"> Author</td>'; echo '<td class="header" id="date"> Date</td>'; echo '<td class="header" id="publisher"> Publisher</td>'; echo '<td class="header" id="pubPlace"> Place Published </td>'; echo '</tr>'; mysql_data_seek($dependency_ids, 0); // for each sentence ID associated with the matching dependencies // fetch metadata and print it out $counter = 0; while ($row = mysql_fetch_array($dependency_ids)) { $counter += 1; // only display( the correct page if ($counter <= $pageLength * (1 + $page) && $counter > $pageLength * $page) { $toHighlight = explode(' ', strtolower($row['dep'] . ' ' . $row['gov'])); $sent_id = $row['sentence_id']; $metadata = getMetadata($sent_id); $row2 = mysql_fetch_array($metadata); if (strlen($row2['sentence']) > 0) { echo '<tr class="search-result">'; //hidden inputs echo '<td class="hidden-id">'; echo '<a href="view.php?id=' . $row2['id'] . '_' . $sent_id . '"><img class="view" src="img/view.png" dep="' . $row['id'] . '" value="' . $row2['id'] . '_' . $sent_id . '">'; echo '</a></td>'; // rest of result echo '<td>'; foreach (explode(' ', $row2['sentence']) as $word) { $highlight = indexOf(strtolower($word), $toHighlight); if ($highlight >= 0 or strtolower($word) == strtolower($row['gov']) or strtolower($word) == strtolower($row['dep'])) { echo '<span class="highlight' . $highlight % 10 . '">' . $word . ' </span>'; } else { echo $word . ' ';