Esempio n. 1
0
 protected function verifyToken()
 {
     $gAuthServerConfig = $this->settings['App_auth'];
     if (!$gAuthServerConfig) {
         $this->user = array('user_id' => $this->input['user_id'], 'user_name' => $this->input['user_name'], 'group_type' => 1, 'appid' => $this->input['appid'], 'display_name' => $this->input['user_name'], 'visit_client' => 0);
         return;
     }
     if (!class_exists('curl')) {
         include_once ROOT_PATH . 'lib/class/curl.class.php';
     }
     $curl = new curl($gAuthServerConfig['host'], $gAuthServerConfig['dir']);
     $curl->initPostData();
     $postdata = array('appid' => $this->input['appid'], 'appkey' => $this->input['appkey'], 'access_token' => $this->input['access_token'], 'mod_uniqueid' => MOD_UNIQUEID, 'app_uniqueid' => APP_UNIQUEID, 'a' => 'get_user_info');
     foreach ($postdata as $k => $v) {
         $curl->addRequestData($k, $v);
     }
     $ret = $curl->request('get_access_token.php');
     //判定终端是否需要登录授权
     if ($ret['ErrorCode']) {
         $this->errorOutput($ret['ErrorCode']);
     }
     $this->user = $ret[0];
     if ($this->input['m2o_ckey'] == CUSTOM_APPKEY) {
         $this->user['group_type'] = 1;
     }
 }
Esempio n. 2
0
 function readFeed($url, $type = '')
 {
     $this->url = $url;
     $this->type = $type;
     $urltocapture = new curl($this->url);
     $urltocapture->setopt(CURLOPT_HTTPGET, true);
     $this->fileRead = $urltocapture->exec();
     if (empty($this->fileRead) or !$this->fileRead) {
         return 101;
     }
     $ext = new btext();
     $this->feedArray = $ext->xml2array($this->fileRead);
     switch ($this->type) {
         case 'youtube':
             return $this->youtube();
             break;
         case 'vimeo':
             return $this->vimeo();
             break;
         case 'dailymotion':
             return $this->dailymotion();
             break;
         default:
             return false;
             break;
     }
 }
 /**
  * The contructor is a copy of the stock simplepie File class which has
  * been modifed to add in use the Moodle curl class rather than php curl
  * functions.
  */
 function moodle_simplepie_file($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false)
 {
     $this->url = $url;
     $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL;
     $curl = new curl();
     $curl->setopt(array('CURLOPT_HEADER' => true));
     try {
         $this->headers = $curl->get($url);
     } catch (moodle_exception $e) {
         $this->error = 'cURL Error: ' . $curl->error;
         $this->success = false;
         return false;
     }
     $parser =& new SimplePie_HTTP_Parser($this->headers);
     if ($parser->parse()) {
         $this->headers = $parser->headers;
         $this->body = $parser->body;
         $this->status_code = $parser->status_code;
         if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) {
             $this->redirects++;
             $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url);
             return $this->SimplePie_File($location, $timeout, $redirects, $headers);
         }
     }
 }
Esempio n. 4
0
 public function __getConfig()
 {
     //获取mediaserver的里面视频类型的配置
     if ($this->settings['App_mediaserver']) {
         $curl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir'] . 'admin/');
         $curl->setReturnFormat('json');
         $curl->initPostData();
         $curl->addRequestData('a', '__getConfig');
         $m_config = $curl->request('index.php');
     }
     if ($m_config && is_array($m_config)) {
         $video_type = $m_config[0]['video_type']['allow_type'];
     } else {
         $video_type = $this->default_type;
     }
     $video_type_arr = explode(',', $video_type);
     $flash_video_type = '';
     foreach ($video_type_arr as $k => $v) {
         $flash_video_type .= '*' . $v . ';';
     }
     $video_types = str_replace('.', '', $video_type);
     $this->settings['flash_video_type'] = $flash_video_type;
     $this->settings['video_type'] = $video_types;
     parent::__getConfig();
 }
Esempio n. 5
0
 function definition()
 {
     global $DB, $CFG, $COURSE;
     $mform =& $this->_form;
     $mform->addElement('textarea', 'querysql', get_string('querysql', 'block_configurable_reports'), 'rows="35" cols="80"');
     $mform->addRule('querysql', get_string('required'), 'required', null, 'client');
     $mform->setType('querysql', PARAM_RAW);
     $mform->addElement('hidden', 'courseid', $COURSE->id);
     $mform->setType('courseid', PARAM_INT);
     $this->add_action_buttons();
     $mform->addElement('static', 'note', '', get_string('listofsqlreports', 'block_configurable_reports'));
     if ($userandrepo = get_config('block_configurable_reports', 'sharedsqlrepository')) {
         $c = new curl();
         $res = $c->get("https://api.github.com/repos/{$userandrepo}/contents/");
         $res = json_decode($res);
         if (is_array($res)) {
             $reportcategories = array(get_string('choose'));
             foreach ($res as $item) {
                 if ($item->type == 'dir') {
                     $reportcategories[$item->path] = $item->path;
                 }
             }
             $mform->addElement('select', 'reportcategories', get_string('reportcategories', 'block_configurable_reports'), $reportcategories, array('onchange' => 'M.block_configurable_reports.onchange_reportcategories(this,"' . sesskey() . '")'));
             $mform->addElement('select', 'reportsincategory', get_string('reportsincategory', 'block_configurable_reports'), $reportcategories, array('onchange' => 'M.block_configurable_reports.onchange_reportsincategory(this,"' . sesskey() . '")'));
             $mform->addElement('textarea', 'remotequerysql', get_string('remotequerysql', 'block_configurable_reports'), 'rows="15" cols="90"');
         }
     }
     //$this->add_action_buttons();
 }
Esempio n. 6
0
function getTitle($url)
{
    include '../includes/curl.php';
    $newc = new curl();
    $fd = $newc->getFile($url);
    if ($fd) {
        // Get title from title tag
        preg_match_all('/<title>(.*)<\\/title>/si', $fd, $matches);
        $title = $matches[1][0];
        // Get encoding from charset attribute
        preg_match_all('/<meta.*charset=([^;"]*)">/i', $fd, $matches);
        $encoding = strtoupper($matches[1][0]);
        // Convert to UTF-8 from the original encoding
        $title = @mb_convert_encoding($title, 'UTF-8', $encoding);
        if (strlen($title) > 0) {
            return $title;
        } else {
            // No title, so return filename
            $uriparts = explode('/', $url);
            $filename = end($uriparts);
            unset($uriparts);
            return $filename;
        }
    } else {
        return false;
    }
}
Esempio n. 7
0
 public function getVideoDownLoadUrl()
 {
     $content = file_get_contents($this->url);
     preg_match('#movieDescription=\'([^\']+)\'#', $content, $result);
     if (!($title = $result[1])) {
         preg_match("#<title>(.+)</title>#", $content, $result);
         $title = $result[1];
     }
     $title = iconv('gb2312//ignore', 'utf-8', $title);
     $this->title = $title;
     preg_match('#<source src="([^"]+)#', $content, $src) or preg_match('#<source type="[^"]+" src="([^"]+)"#', $content, $src);
     $videoSrc = $src[1] ? $src[1] : '';
     if ($videoSrc) {
         preg_match('#(.+)-mobile.mp4#', $videoSrc, $sdUrls);
         $sdUrl = $sdUrls[1] . '.flv';
         $hdUrl = preg_replace('#SD#', 'HD', $sdUrl);
         $curl = new curl();
         $sdHeader = $curl->curlGet302($sdUrl);
         $hdHeader = $curl->curlGet302($hdUrl);
         $sdSize = $curl->getSize($sdHeader);
         $hdSize = $curl->getSize($hdHeader);
         if ($sdSize > $hdSize) {
             $url = $sdUrl;
         } else {
             $url = $hdUrl;
         }
         $this->ext = 'flv';
     } else {
         preg_match('#["\'](.+)-list.m3u8["\']#', $content, $urls) || preg_match('#["\'](.+).m3u8["\']#', $content, $urls);
         $url = $urls[1] . '.mp4';
         $this->ext = 'mp4';
     }
     return $url;
 }
Esempio n. 8
0
 /**
  * @param mixed $path
  * @param string $search
  * @return array
  */
 public function get_listing($path = '', $page = '')
 {
     global $CFG, $OUTPUT;
     $ret = array();
     $curl = new curl();
     $msg = $curl->head($this->file_url);
     $info = $curl->get_info();
     if ($info['http_code'] != 200) {
         $ret['e'] = $msg;
     } else {
         $ret['list'] = array();
         $ret['nosearch'] = true;
         $ret['nologin'] = true;
         $filename = $this->guess_filename($info['url'], $info['content_type']);
         if (strstr($info['content_type'], 'text/html') || empty($info['content_type'])) {
             // analysis this web page, general file list
             $ret['list'] = array();
             $content = $curl->get($info['url']);
             $this->analyse_page($info['url'], $content, $ret);
         } else {
             // download this file
             $ret['list'][] = array('title' => $filename, 'source' => $this->file_url, 'thumbnail' => $OUTPUT->old_icon_url(file_extension_icon($filename, 32)));
         }
     }
     return $ret;
 }
Esempio n. 9
0
 function getPublicKeyFromServer($server, $email)
 {
     /* refactor to 
     		$command = "gpg --keyserver ".escapeshellarg($server)." --search-keys ".escapeshellarg($email)."";
     		echo "$command\n\n";
     		
     		//execute the gnupg command
     		exec($command, $result);
     		*/
     $curl = new curl();
     // get Fingerprint
     $data = $curl->get("http://" . $server . ":11371/pks/lookup?search=" . urlencode($email) . "&op=index&fingerprint=on&exact=on");
     $data = $data['FILE'];
     preg_match_all("/<pre>([\\s\\S]*?)<\\/pre>/", $data, $matches);
     //$pub = $matches[1][1];
     preg_match_all("/<a href=\"(.*?)\">(\\w*)<\\/a>/", $matches[1][1], $matches);
     $url = $matches[1][0];
     $keyID = $matches[2][0];
     // get Public Key
     $data = $curl->get("http://" . $server . ":11371" . $url);
     $data = $data['FILE'];
     preg_match_all("/<pre>([\\s\\S]*?)<\\/pre>/", $data, $matches);
     $pub_key = trim($matches[1][0]);
     return array("keyID" => $keyID, "public_key" => $pub_key);
 }
Esempio n. 10
0
 function post()
 {
     $service_url = 'http://www.andreseloysv.com/epg/response.php';
     $curl = curl_init($service_url);
     $curl_post_data = array('firstName' => $this->firstName, 'lastName' => $this->lastName, 'creditCardNumber' => $this->creditCardNumber, 'ccv' => $this->ccv, 'expiration_month' => $this->expiration_month, 'expiration_year' => $this->expiration_year, 'amount' => $this->amount);
     $sender = new curl($service_url, $curl_post_data);
     $result = $sender->post();
     return $result;
 }
Esempio n. 11
0
 public function query($data)
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     $c = new curl();
     $options = array('returntransfer' => true);
     $result = $c->post($this->_gatewayURL, $data, $options);
     return $result;
 }
Esempio n. 12
0
function add_bookmark($uname, $title, $folderid, $url, $description, $tags = "", $newPublic = false, $date = NULL)
{
    $resultArr = array();
    $resultArr['success'] = false;
    include 'conn.php';
    require_once dirname(__FILE__) . '/protection.php';
    if ($date != "") {
        $date = "'{$date}'";
    } else {
        $date = "now()";
    }
    // Cut data to respect maximum length
    if (!empty($title)) {
        $title = substr($title, 0, 100);
    }
    if (!empty($description)) {
        $description = substr($description, 0, 150);
    }
    //$Query = sprintf("INSERT INTO " . TABLE_PREFIX . "favourites (Name , Title , FolderID , Url , Description, ADD_DATE) " . "values('" . $uname . "', %s,'" . $folderid . "', %s, %s, $date) ", quote_smart($title), quote_smart($url), quote_smart($description));
    $Query = "INSERT INTO " . TABLE_PREFIX . "favourites (Name , Title , FolderID , Url , Description, ADD_DATE) values(?, ?, ?, ?, ?, {$date})";
    $sth = $dblink->prepare($Query);
    $dataBookmark = array($uname, $title, $folderid, $url, $description);
    $AffectedRows = $sth->execute($dataBookmark);
    $rec_id = $dblink->lastInsertID(TABLE_PREFIX . "favourites", 'ID');
    if (PEAR::isError($AffectedRows)) {
        $resultArr['success'] = true;
        //echo 'ERROR: '. $AffectedRows->getMessage(). ' :: ' . $AffectedRows->getUserInfo();
    } else {
        $resultArr['success'] = true;
        $tags = trim($tags);
        if (TAGS && $tags != "") {
            require_once dirname(__FILE__) . '/tags_functions.php';
            //Remove any commas, dots, quotes, plus signs since the user might use commas to seperate tags rather than spaces
            $toRemove = array('"', "'", ",", "+");
            $tags = str_replace($toRemove, "", $tags);
            $tags = filter($tags);
            if ($tags != null && $newPublic) {
                // cut tags if too long > 150 chars
                $tags = substr($tags, 0, 150);
                //Add the tags
                addTags($tags);
                //Store the tags with the bookmark
                storeTags($rec_id, $tags);
            }
            if (USE_SCREENSHOT && CURL_AVAILABLE) {
                require_once dirname(__FILE__) . '/curl.php';
                $newc = new curl();
                $urlScreenshot = sprintf(SCREENSHOT_URL, $url);
                //echo $urlScreenshot;
                $fd = $newc->getFile($urlScreenshot);
            }
        }
    }
    return $resultArr;
}
Esempio n. 13
0
 public function get_water_config()
 {
     global $gGlobalConfig;
     $curl = new curl($gGlobalConfig['App_material']['host'], $gGlobalConfig['App_material']['dir']);
     $curl->setSubmitType('get');
     $curl->initPostData();
     $curl->addRequestData('a', 'get_water_config');
     $ret = $curl->request('water.php');
     $this->addItem($ret[0]);
     $this->output();
 }
Esempio n. 14
0
 public function column_node()
 {
     $curl = new curl($this->settings['App_publishcontent']['host'], $this->settings['App_publishcontent']['dir'] . 'admin/');
     $curl->initPostData();
     $curl->addRequestData('a', 'get_all_columns');
     $return = $curl->request('column.php');
     if (is_array($return) && !$return['ErrorCode']) {
         exit(json_encode($return));
     }
     exit($return);
 }
Esempio n. 15
0
 public function request($method, $params = array())
 {
     $c = new curl();
     $r = $c->request($this->url . $this->api_key . "/" . $method, 'POST', $params);
     $j = json_decode($r, true);
     if ($j) {
         return $j;
     } else {
         return $r;
     }
 }
Esempio n. 16
0
 public function get_video($vid = 0)
 {
     global $gGlobalConfig;
     include_once ROOT_PATH . 'lib/class/curl.class.php';
     $livmedia = new curl($gGlobalConfig['App_livmedia']['host'], $gGlobalConfig['App_livmedia']['dir'] . 'admin/');
     $livmedia->initPostData();
     $livmedia->addRequestData('id', $vid);
     $livmedia->addRequestData('a', 'detail');
     $vodinfo = $livmedia->request('vod.php');
     $vodinfo = $vodinfo[0];
     return is_array($vodinfo) && !empty($vodinfo) ? $vodinfo : array();
 }
Esempio n. 17
0
 private function get_mediaserver_config()
 {
     //获取需要修改的配置
     $curl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir']);
     $curl->setSubmitType('post');
     $curl->setReturnFormat('json');
     $curl->initPostData();
     $curl->addRequestData('a', 'settings');
     $settings = $curl->request('configuare.php');
     $config = array('default_record_file_path' => !empty($settings) ? $settings['define']['UPLOAD_DIR'] : '');
     return $config;
 }
Esempio n. 18
0
 public function select_videos()
 {
     $curl = new curl($this->settings['App_livmedia']['host'], $this->settings['App_livmedia']['dir']);
     $curl->setSubmitType('get');
     $curl->initPostData();
     foreach ($this->input as $k => $v) {
         $curl->addRequestData($k, $v);
     }
     $return = $curl->request('vod_get_many_videos.php');
     $this->addItem($return[0]);
     $this->output();
 }
Esempio n. 19
0
 public function callBack()
 {
     $record = json_decode(html_entity_decode($this->input['data']), 1);
     $curl = new curl($this->settings['App_mediaserver']['host'], $this->settings['App_mediaserver']['dir'] . 'admin/');
     $curl->setSubmitType('post');
     $curl->initPostData();
     $data = array('id' => $record['id'], 'is_time_shift' => $record['time_shift'] ? 1 : 0, 'title' => $record['title'] ? $record['title'] : '精彩节目', 'filepath' => $record['file_path'], 'source' => $record['source'], 'is_mark' => $record['is_allow'], 'vod_sort_id' => $record['vod_sort_id'], 'audit_auto' => $record['audit_auto'], 'column_id' => $record['column_id'], 'channel_id' => $record['channel_id'], 'vod_leixing' => 3, 'start' => '0', 'end' => $record['duration'] * 1000, 'starttime' => $record['start_time'], 'create_time' => -1, 'force_recodec' => $record['force_codec'], 'appid' => $record['appid'], 'appkey' => $record['appkey'], 'comment' => $record['comment'], 'user_id' => $record['user_id'], 'user_name' => $record['user_name']);
     foreach ($data as $k => $v) {
         $curl->addRequestData($k, $v);
     }
     include_once ROOT_PATH . 'lib/class/program_record.class.php';
     $obj_record = new programRecord();
     $tmp_ret = array();
     switch ($record['exit_status']) {
         case 0:
             //出错
             $data = array('text' => '录制失败', 'state' => 2, 'content_id' => $record['id'], 'conid' => $record['id']);
             $tmp_ret = $obj_record->updateLogs($data);
             if ($tmp_ret) {
                 $obj_record->update_record_state($record['id']);
             }
             break;
         case 1:
             //成功
             $data = array('text' => '录制成功', 'state' => 1, 'content_id' => $record['id'], 'conid' => $record['id']);
             $tmp_ret = $obj_record->updateLogs($data);
             if ($tmp_ret) {
                 $obj_record->update_record_state($record['id']);
             }
             break;
         case 2:
             //停止录制
             /*
             			$data = array(
             				'text' => '停止录制',
             				'state' => 2,
             				'content_id' => $record['id'],
             				'conid' => $record['id'],
             			);
             			$obj_live->updateLogs($data);
             			$obj_live->update_record_state($record['id']);
             */
             $this->addItem(array());
             $this->output();
             break;
         default:
             break;
     }
     $ret = $curl->request('create.php');
     $this->addItem($ret);
     $this->output();
 }
Esempio n. 20
0
 private function _get_collection($keyword)
 {
     global $OUTPUT;
     $list = array();
     $this->api = 'http://www.merlot.org/merlot/materials.rest?keywords=' . urlencode($keyword) . '&licenseKey=' . $this->licensekey;
     $c = new curl(array('cache' => true, 'module_cache' => 'repository'));
     $content = $c->get($this->api);
     $xml = simplexml_load_string($content);
     foreach ($xml->results->material as $entry) {
         $list[] = array('title' => (string) $entry->title, 'thumbnail' => $OUTPUT->pix_url('f/unknown-32')->out(false), 'date' => userdate((int) $entry->creationDate), 'size' => '', 'source' => (string) $entry->URL);
     }
     return $list;
 }
Esempio n. 21
0
 public function get_apps()
 {
     $curl = new curl($this->settings['App_auth']['host'], $this->settings['App_auth']['dir']);
     $apps = $curl->request('applications.php');
     $appdata = array();
     if ($apps) {
         foreach ($apps as $app) {
             $appdata[$app['bundle']] = $app['name'];
         }
     }
     $this->addItem($appdata);
     $this->output();
 }
Esempio n. 22
0
 public function upload()
 {
     if ($_FILES['videofile']) {
         $this->errorOutput('没有视频文件');
     }
     if (!($server = $this->select_server())) {
         $this->errorOutput('服务器已经满,不能上传视频,请稍等片刻');
     }
     $curl = new curl($server['host'], $server['dir']);
     $curl->setSubmitType('post');
     $curl->initPostData();
     $curl->addFile($_FILES);
     $info = $curl->request('create.php');
 }
Esempio n. 23
0
 private function add2log($content, $operation = 'login')
 {
     $curl = new curl($this->settings['App_logs']['host'], $this->settings['App_logs']['dir'] . 'admin/');
     $curl->setSubmitType('post');
     $curl->setReturnFormat('json');
     $curl->initPostData();
     $curl->addRequestData('a', 'create');
     $curl->addRequestData('bundle_id', 'm2o');
     $curl->addRequestData('moudle_id', 'm2o');
     $curl->addRequestData('operation', $operation);
     $curl->addRequestData('title', $content);
     $ret = $curl->request('logs_update.php');
     return $ret;
 }
Esempio n. 24
0
 }
 public function __destruct()
 {
     parent::__destruct();
 }
 public function convert()
 {
     global $gGlobalConfig;
     include_once ROOT_PATH . 'lib/class/curl.class.php';
     if ($gGlobalConfig['App_officeconvert']) {
         $curl = new curl($gGlobalConfig['App_officeconvert']['host'], $gGlobalConfig['App_officeconvert']['dir']);
     }
     $curl->setSubmitType('post');
     $curl->setReturnFormat('json');
     $curl->initPostData();
     $curl->addRequestData('custom_appid', CUSTOM_APPID);
     $curl->addRequestData('custom_appkey', CUSTOM_APPKEY);
     $curl->addFile($_FILES);
     $result = $curl->request('convert.php');
     //var_dump($result);exit;
     $path = 'cache/word/zip_' . uniqid() . '/';
     $zipDir = ROOT_PATH . $path;
     $return = array();
     if (hg_mkdir($zipDir) && is_writeable($zipDir)) {
         $zipFile = $zipDir . 'word.zip';
         file_put_contents($zipFile, $result);
         $unzipDir = $zipDir . 'unzip/';
         if (hg_mkdir($unzipDir) && is_writeable($unzipDir)) {
             $unzipCmd = ' unzip ' . $zipFile . ' -d ' . realpath($unzipDir);
             exec($unzipCmd);
             $rmZip = ' rm -f ' . $zipFile;
             exec($rmZip);
Esempio n. 25
0
 public function send($data)
 {
     global $gGlobalConfig;
     include_once ROOT_PATH . 'lib/class/curl.class.php';
     $curl = new curl($gGlobalConfig['App_vote']['host'], $gGlobalConfig['App_vote']['dir']);
     $curl->setSubmitType('post');
     foreach ($data as $k => $v) {
         if ($v['order_id'] == '0') {
             $curl->addRequestData('title', $v['value']);
             $curl->addRequestData('vote_question_id', $gGlobalConfig['des']['0']);
             $curl->addRequestData('id', $v['id']);
             //record_person 的id
             foreach ($data as $key => $value) {
                 if ($value['type'] == 'file') {
                     $sql = 'select * from ' . DB_PREFIX . 'materials where id = ' . $value['value'];
                     $pic = $this->db->fetch_all($sql);
                     $pic = $pic['0'];
                     $indexpic = array('host' => $pic['host'], 'dir' => $pic['dir'], 'filepath' => $pic['material_path'], 'filename' => $pic['pic_name']);
                 }
             }
             $curl->addRequestData('pictures_info', serialize($indexpic));
             $curl->addRequestData('a', vote_option);
             $ret = $curl->request('vote_option.php');
             if ($ret) {
                 $sql = 'update ' . DB_PREFIX . 'record_person set stat = 1 where id=' . $v['id'];
                 $this->db->query($sql);
             }
         }
     }
 }
Esempio n. 26
0
 public function setting()
 {
     $data = array('id' => intval($this->user['id']), 'password' => trim($this->input['password']), 'password_again' => trim($this->input['password_again']), 'old_password' => trim($this->input['old_password']));
     if ($data['password'] && $data['password'] != $data['password_again']) {
         $this->ReportError('两次输入的密码不一样');
     }
     $curl = new curl($this->settings['App_auth']['host'], $this->settings['App_auth']['dir']);
     $curl->setSubmitType('post');
     $curl->setReturnFormat('json');
     $curl->initPostData();
     $curl->addRequestData('a', 'update_password');
     foreach ($data as $key => $val) {
         $curl->addRequestData($key, $val);
     }
     if ($_FILES['Filedata']) {
         $curl->addFile($_FILES);
     }
     $return = $curl->request('member.php');
     if ($return && $return[0]) {
         if ($return[0]['error'] == -1) {
             $this->ReportError('原始密码错误');
         }
     }
     $this->redirect('更新成功');
 }
Esempio n. 27
0
    }
    public function __destruct()
    {
        parent::__destruct();
    }
    /**
	 * 转换word文档
	 */
    public function convert()
    {
        $app_id = isset($this->input['custom_appid']) ? trim($this->input['custom_appid']) : '';
        $app_key = isset($this->input['custom_appkey']) ? trim($this->input['custom_appkey']) : '';
        if (empty($app_id) || empty($app_key)) {
            $this->errorOutput(PARAM_WRONG);
        }
        //先验证是否有权限
        $auth = new Auth();
        $auth_info = $auth->getAccessToken($app_id, $app_key);
        if (!$auth_info) {
            $this->errorOutput(NO_AUTH);
        }
        //处理上传的word文档
        $gGlobalConfig['officeconvert'] = array('host' => '10.0.1.59:8080', 'dir' => 'officeConverter/');
        $curl = new curl($gGlobalConfig['officeconvert']['host'], $gGlobalConfig['officeconvert']['dir']);
        $curl->setSubmitType('post');
        $curl->setReturnFormat('str');
        $curl->initPostData();
        $curl->addFile($_FILES);
        $curl->addRequestData('custom_appid', $app_id);
        $curl->addRequestData('custom_appkey', $app_key);
 /**
  * Processes the message and sends a notification via airnotifier
  *
  * @param stdClass $eventdata the event data submitted by the message sender plus $eventdata->savedmessageid
  * @return true if ok, false if error
  */
 public function send_message($eventdata)
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     if (!empty($CFG->noemailever)) {
         // Hidden setting for development sites, set in config.php if needed.
         debugging('$CFG->noemailever active, no airnotifier message sent.', DEBUG_MINIMAL);
         return true;
     }
     // Skip any messaging suspended and deleted users.
     if ($eventdata->userto->auth === 'nologin' or $eventdata->userto->suspended or $eventdata->userto->deleted) {
         return true;
     }
     // Site id, to map with Moodle Mobile stored sites.
     $siteid = md5($CFG->wwwroot . $eventdata->userto->username);
     // Airnotifier can handle custom requests using processors (that are Airnotifier plugins).
     // In the extra parameter we indicate which processor to use and also additional data to be handled by the processor.
     // Here we clone the eventdata object because will be deleting/adding attributes.
     $extra = clone $eventdata;
     // Delete attributes that may content private information.
     if (!empty($eventdata->userfrom)) {
         $extra->userfromid = $eventdata->userfrom->id;
         $extra->userfromfullname = fullname($eventdata->userfrom);
         unset($extra->userfrom);
     }
     $extra->usertoid = $eventdata->userto->id;
     unset($extra->userto);
     $extra->processor = 'moodle';
     $extra->site = $siteid;
     $extra->date = !empty($eventdata->timecreated) ? $eventdata->timecreated : time();
     $extra->notification = !empty($eventdata->notification) ? 1 : 0;
     // We are sending to message to all devices.
     $airnotifiermanager = new message_airnotifier_manager();
     $devicetokens = $airnotifiermanager->get_user_devices($CFG->airnotifiermobileappname, $eventdata->userto->id);
     foreach ($devicetokens as $devicetoken) {
         if (!$devicetoken->enable) {
             continue;
         }
         // Sending the message to the device.
         $serverurl = $CFG->airnotifierurl . ':' . $CFG->airnotifierport . '/api/v2/push/';
         $header = array('Accept: application/json', 'X-AN-APP-NAME: ' . $CFG->airnotifierappname, 'X-AN-APP-KEY: ' . $CFG->airnotifieraccesskey);
         $curl = new curl();
         $curl->setHeader($header);
         $params = array('device' => $devicetoken->platform, 'token' => $devicetoken->pushid, 'extra' => $extra);
         // JSON POST raw body request.
         $resp = $curl->post($serverurl, json_encode($params));
     }
     return true;
 }
Esempio n. 29
0
 function handle_post()
 {
     if (is_array($this->josn_array)) {
         $json = json_encode($this->josn_array);
     }
     $token_obj = new TokenWechat(APPID, APPSECRET);
     $access_token = $token_obj->get_token();
     $url = sprintf('https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=%s', $access_token);
     import("curl.lib");
     $curl = new curl();
     $curl->setOpt(CURLOPT_RETURNTRANSFER, TRUE);
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, FALSE);
     $result = $curl->post($url, $json);
     return $result;
 }
Esempio n. 30
0
 function request($url)
 {
     $hash = md5($url);
     $cache = SCHED_API_DIR . '/cache/' . $hash;
     // TODO check if cache is expired; make expired admin option
     if (file_exists($cache)) {
         $out = file_get_contents($cache);
     } else {
         $c = new curl($url);
         $out = $c->exec();
         $c->close();
         file_put_contents($cache, $out);
     }
     return $out;
 }