示例#1
0
 /**
  * Return the content of the file imsmanifest.xml
  * @return content of the imsmanifest.xml file as a string or FALSE
  *  it there is any error.
  */
 function ReadImsmanifest()
 {
     $filename = $this->path . '/imsmanifest.xml';
     if (strpos($filename, 'http') === 0) {
         // Remote manifest
         require_once _lib_ . '/lib.fsock_wrapper.php';
         $fsock = new FSock();
         $contents = $fsock->send_request($filename, '80', '');
         if (!$contents) {
             $this->setError(SPSCORM_E_FILENOTFOND, 'File: ' . $this->path . '/imsmanifest.xml not found');
             return FALSE;
         }
     } else {
         // Local manifest
         $handle = @fopen($filename, 'r');
         if ($handle === FALSE) {
             $this->setError(SPSCORM_E_FILENOTFOND, 'File: ' . $this->path . '/imsmanifest.xml not found');
             return FALSE;
         }
         $contents = fread($handle, filesize($filename));
         fclose($handle);
     }
     return $contents;
 }
示例#2
0
 function _api_request($service, $method, $params, $parname = false)
 {
     require_once _base_ . '/lib/lib.json.php';
     require_once _base_ . '/lib/lib.fsock_wrapper.php';
     $server = Get::sett('bbb_server', false);
     $output = false;
     $_parname = $parname ? $parname . "=" : "";
     if ($server && $service && $method) {
         $url = 'http://' . $server . '/api/' . $service . '/' . $method;
         $json = new Services_JSON();
         $fsock = new FSock();
         //check user login
         if ($service != 'auth') {
             $auth_code = $this->get_auth_code();
             if (!$auth_code) {
                 //make login
                 $auth_code = $this->api_login();
             } else {
                 //verify if login is valid
                 if (!$this->api_verify()) {
                     $auth_code = $this->api_login();
                 }
             }
             if ($auth_code) {
                 $other_header = array(_BBB_AUTH_CODE => $auth_code, "Content-type" => "application/x-www-form-urlencoded");
                 $post = $_parname . urlencode($json->encode($params));
                 $res_json = $fsock->post_request($url, Get::sett('bbb_port', '80'), $post, $other_header);
                 if ($res_json) {
                     $output = $json->decode($res_json);
                 }
             }
         } else {
             $post = $_parname . urlencode($json->encode($params));
             $other_header = array("Content-type" => "application/x-www-form-urlencoded");
             if ($method != 'login') {
                 $other_header[_BBB_AUTH_CODE] = $this->get_auth_code();
             }
             $res_json = $fsock->post_request($url, Get::sett('bbb_port', '80'), $post, $other_header);
             if ($res_json) {
                 $output = $json->decode($res_json);
             }
         }
     }
     return $output;
 }