Пример #1
0
 /**
  * Render the output remotely at ditaa.org
  */
 function _remote($data, $in, $out)
 {
     if (!file_exists($in)) {
         if ($conf['debug']) {
             dbglog($in, 'no such ditaa input file');
         }
         return false;
     }
     $http = new DokuHTTPClient();
     $http->timeout = 30;
     $pass = array();
     $pass['scale'] = $data['scale'];
     $pass['timeout'] = 25;
     $pass['grid'] = io_readFile($in);
     if (!$data['antialias']) {
         $pass['A'] = 'on';
     }
     if (!$data['shadow']) {
         $pass['S'] = 'on';
     }
     if ($data['round']) {
         $pass['r'] = 'on';
     }
     if (!$data['edgesep']) {
         $pass['E'] = 'on';
     }
     $img = $http->post('http://ditaa.org/ditaa/render', $pass);
     if (!$img) {
         return false;
     }
     return io_saveFile($out, $img);
 }
Пример #2
0
 /**
  * Returns the content of a graphviz image.
  * 
  * @param data parameters.
  *           
  * @return PNG image.
  */
 function get_graphviz_image($data)
 {
     global $conf;
     $image = null;
     $gathered_data = $this->get_gathered_data($data);
     $dot_input = $this->get_dot($gathered_data);
     // See if a manual path was given for graphviz
     if ($this->getConf('graphviz_path')) {
         // Local build
         $cmd = $this->getConf('path');
         $cmd .= ' -Tpng';
         $cmd .= ' -K' . $data['layout'];
         $cmd .= ' -o' . escapeshellarg($image);
         //output
         $cmd .= ' ' . escapeshellarg($dot_input);
         //input
         exec($cmd, $image, $error);
         if ($error != 0) {
             if ($conf['debug']) {
                 dbglog(join("\n", $image), 'mindmap command failed: ' . $cmd);
             }
             return false;
         }
     } else {
         // Remote via google chart tools
         $http = new DokuHTTPClient();
         $http->timeout = 30;
         $pass = array();
         $pass['cht'] = 'gv:' . $data['format'];
         $pass['chl'] = $dot_input;
         $image = $http->post('http://chart.apis.google.com/chart', $pass, '&');
         if (!$image) {
             return false;
         }
     }
     return $image;
 }
Пример #3
0
 /**
  * Submits the given data to the given Akismet service.
  * 
  * @param $function string  Akismet service to use. Can be 
  *                          'comment-check', 'submit-ham' or 
  *                          'submit-spam'
  * @param $data     array   Linkback data to submit
  * @return          string  The response of Akismet 
  */
 function _submitData($function, $data)
 {
     $info = $this->getInfo();
     $http = new DokuHTTPClient();
     // The Aksimet guys ask for a verbose UserAgent:
     $http->agent = 'DokuWiki/' . getVersion() . ' | ' . $info['name'] . '/' . $info['date'];
     $http->timeout = 5;
     $resp = $http->post('http://' . $this->getConf('akismet_apikey') . '.rest.akismet.com/1.1/comment-check', $data);
     return $resp;
 }
Пример #4
0
 /**
  * Search for plugins or templates using the given query string
  *
  * @param string $q the query string
  * @return array a list of matching extensions
  */
 public function search($q)
 {
     $query = $this->parse_query($q);
     $query['fmt'] = 'php';
     $httpclient = new DokuHTTPClient();
     $data = $httpclient->post(EXTENSION_REPOSITORY_API, $query);
     if ($data === false) {
         return array();
     }
     $result = unserialize($data);
     $ids = array();
     // store cache info for each extension
     foreach ($result as $ext) {
         $name = $ext['plugin'];
         $cache = new cache('##extension_manager##' . $name, '.repo');
         $cache->storeCache(serialize($ext));
         $ids[] = $name;
     }
     return $ids;
 }
 /**
  * Render the output remotely at google
  */
 function _remote($data, $in, $out)
 {
     if (!file_exists($in)) {
         if ($conf['debug']) {
             dbglog($in, 'no such graphviz input file');
         }
         return false;
     }
     $http = new DokuHTTPClient();
     $http->timeout = 30;
     $pass = array();
     $pass['cht'] = 'gv:' . $data['layout'];
     $pass['chl'] = io_readFile($in);
     $img = $http->post('http://chart.apis.google.com/chart', $pass, '&');
     if (!$img) {
         return false;
     }
     return io_saveFile($out, $img);
 }
Пример #6
0
 /**
  * Render the output remotely at ditaa.org
  */
 function _remote($data, $in, $out)
 {
     if (!file_exists($in)) {
         if ($conf['debug']) {
             dbglog($in, 'no such seqdia input file');
         }
         return false;
     }
     $http = new DokuHTTPClient();
     $http->timeout = 30;
     $pass = array();
     $pass['style'] = $data['style'];
     $pass['message'] = io_readFile($in);
     $result = $http->post('http://www.websequencediagrams.com/index.php', $pass);
     if (!$result) {
         return false;
     }
     $json = new JSON(JSON_LOOSE_TYPE);
     $json->skipnative = true;
     $json_data = $json->decode($result);
     $img = $http->get('http://www.websequencediagrams.com/index.php' . $json_data['img']);
     if (!$img) {
         return false;
     }
     return io_saveFile($out, $img);
 }
Пример #7
0
 /**
  * Sends a Trackback to the given url, using the supplied data.
  * 
  * @param $pingurl string URL to ping
  * @param $trackback_info array Hash containing title, url and blog_name of linking post
  */
 function _ping_page_trackback($pingurl, $linkback_info)
 {
     $http_client = new DokuHTTPClient();
     $success = $http_client->post($pingurl, $linkback_info);
     return $success !== false;
 }