Exemple #1
0
function wikilang($s)
{
    $url = "http://en.wikipedia.org/w/api.php?action=opensearch&search=" . urlencode($s) . "&format=xml&limit=1";
    $page = rcurl($url);
    $xml = simplexml_load_string($page);
    //var_dump($xml);
    $wikiUrlTitle = (string) $xml->Section->Item->Text;
    $wikiUrlTitle = preg_replace('/\\s/', '%20', $wikiUrlTitle);
    $url = 'http://en.wikipedia.org/w/api.php' . '?format=json&action=query&prop=langlinks&lllimit=500&redirects=1' . '&titles=' . htmlentities($wikiUrlTitle);
    $res = rcurl($url);
    $result = json_decode($res);
    $keys = get_object_vars($result->query->pages);
    if (is_array($keys)) {
        $object = array_pop($keys);
        if (!is_array($object->langlinks)) {
            return "N/A";
        }
        foreach ($object->langlinks as $lang_entry) {
            if ($lang_entry->lang == 'he') {
                return $lang_entry->{'*'};
            }
        }
    }
    //if not translation found
    return "N/A";
}
 private function get_rebot($word)
 {
     $appkey = "4374c255d2a9bc4b336c4e040a741465";
     $reply = "";
     if (!empty($word)) {
         $r_url = "http://dev.skjqr.com/api/weixin.php?email=164559653@qq.com&appkey=" . $appkey . "&msg=" . $word;
         $reply = rcurl($r_url, '', 'get');
     }
     $regex = "/\\[msg\\](.*)\\[\\/msg\\]/i";
     if (preg_match($regex, $reply, $matches)) {
         if (isset($matches[1])) {
             return $matches[1];
         }
     }
     return "";
 }
 function cl_login()
 {
     $data = array("user[email]" => "*****@*****.**", "user[password]" => "bingle");
     $result = rcurl('http://www.coollive.com.cn/member/login', $data, "post");
     var_export($result);
     exit;
 }
                 $filename_arr = explode(".", $filename);
                 $pic_name = $filename_arr[0];
                 $new_file = $root_path . '/public/data/images/video/cut/' . $pic_name . '.jpg';
                 $ffmpeg_cmd = '/data/software/simple-rtmp-server/trunk/objs/ffmpeg/bin/ffmpeg -y -i ' . $root_path . '/public/data/video/live/' . $filename . ' -ss 00:00:01 -f image2 -vframes 1 ' . $new_file;
                 $ret = exec($ffmpeg_cmd);
                 if (file_exists($new_file)) {
                     $ext = "jpg";
                     $savePath = $root_path . "/public/data/images/video/cut/";
                     $saveName = $pic_name . '.jpg';
                     $ret = saveThumbImg_ex($ext, $savePath, $saveName, 187, 140, '187x140_');
                     saveThumbImg_ex($ext, $savePath, $saveName, 100, 75, '100x75_');
                     saveThumbImg_ex($ext, $savePath, $saveName, 120, 90, '120x90_');
                     $ret = saveThumbImg_ex($ext, $savePath, $saveName, 85, 64, '85x64_');
                     if ($ret == 0) {
                         $data = array('vid' => $id, 'pic_name' => $saveName);
                         $res = rcurl($api_url, $data);
                     }
                 }
                 echo "####{$ret}#####";
             } else {
                 echo date() . "[ERROR]" . $root_path . $video_path . "/" . $filename . " not exist.";
             }
         }
         @unlink($filePath);
     }
     closedir($dh);
 }
 if ($c == 0) {
     echo "\nWaiting for 5 seconds....\n";
     sleep(5);
 } else {