<?php

include 'set_xml_session.php';
include "setup.php";
include "upload.class.php";
header("content-type:application/xml");
//echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">";
//echo"<pre>";
$output = "<?xml version='1.0' encoding='utf-8'?><Result><Status>";
//www.tritonetech.com/php_uploads/porsche/webservice/upload_self_writing_image.php
$up_obj = new UploadAudioFile();
$data = $up_obj->upload_file("./self_writing_image/");
//$filename=$_FILES['userfile']['name'];
$filename = basename($_FILES['userfile']['name']);
$qid = rtrim($filename, '.jpeg');
switch ($data) {
    case "true":
        $query = $_DB->Query("select * from jos_porsche_self_writing_task where written_image='{$filename}'");
        $_DB->Execute("UPDATE jos_porsche_self SET end_time = NOW( ) WHERE id = ( SELECT self_content_id\nFROM jos_porsche_self_writing_task\nWHERE id = '{$qid}' )");
        if ($query == true) {
            $output .= "image updated successfully";
        } else {
            $query = $_DB->Execute("UPDATE jos_porsche_self_writing_task SET written_image='{$filename}' where id='{$qid}'");
            if ($query == true) {
                $output .= "image upload successful";
            } else {
                $output .= "image upload failure";
            }
        }
        echo $output . "</Status></Result>";
        break;
<?php

include 'set_xml_session.php';
include "setup.php";
include "upload.class.php";
$uid = $_SESSION['UID'];
//$uid='107';
header("content-type:application/xml");
//echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">";
//echo"<pre>";
$output = "<?xml version='1.0' encoding='utf-8'?><Result><Status>";
//www.tritonetech.com/php_uploads/porsche/webservice/upload_group_user_audio.php
$up_obj = new UploadAudioFile();
$data = $up_obj->upload_file("./group_user_audio/");
$filename = $_FILES['userfile']['name'];
$qid = rtrim($filename, '.wav');
//echo $qid;
/*$word=strrev($word);
//echo $word."<br/>";
$content_id=trim(strstr($word, '_'),'_');
$content_id=strrev($content_id);*/
//echo $content_id;
switch ($data) {
    case "true":
        /*$query=$_DB->Query("select a.id,a.user_id,b.student_id,b.group_id from jos_porsche_student as a left join jos_porsche_student_module as b on a.id=b.student_id where user_id='$uid'");
        $student=$_DB->GetResultValue($query,0,'student_id');
        $query=$_DB->Query("select id from jos_porsche_group_reading_task where q_s_id='$student_id' and content_id='$content_id'");
        $qid=$_DB->GetResultValue($query,0,'id');*/
        //$query=$_DB->Query("select * from jos_porsche_group_reading_task where id='$qid'");
        //$count=$_DB->GetResultValue($query,0,'filename');
        //print_r($count);
<?php

include 'set_xml_session.php';
include 'setup.php';
include "upload.class.php";
header("content-type:application/xml");
$output = "<?xml version='1.0' encoding='utf-8'?><Result><Status>";
$ability = $_REQUEST['ability'];
$up_obj = new UploadAudioFile();
$data = $up_obj->upload_file("./content_audio/");
$filename = $_FILES['userfile']['name'];
$file = rtrim($filename, '.wav');
$content_id = ltrim($file, $ability);
switch ($data) {
    case "true":
        //$query=$_DB->Query("select * from jos_porsche_$ where words='$word'");
        //$count=$_DB->GetResultNumber($query);
        /*if($count==0)
        	{
        	$query=$_DB->Execute("insert into jos_porsche_words values('','$word','1','','NOW()')");
        		if($query==true)
        		{
        		$status="audio file added";
        		$output.=$status."</Status></Result>";
        		echo $output;
        		}
        		else
        		{
        		$status="audio file not added";
        		$output.=$status."</Status></Result>";
        		echo $output;
<?php

include 'set_xml_session.php';
include 'setup.php';
include 'upload.class.php';
require_once 'FastJSON.class.php';
header("content-type:application/xml");
$output = "<?xml version='1.0' encoding='UTF-8'?><Result><Status>";
session_start();
$uid = $_SESSION['UID'];
//www.tritonetech.com/php_uploads/porsche/webservice/upload_self_reading_audio.php
$up_obj = new UploadAudioFile();
$data = $up_obj->upload_file("./self_reading_audio/");
$filename = $_FILES['userfile']['name'];
$qid = basename($filename, ".wav");
//$self_reading_task_id=basename($filename,".wav");
//var_dump($self_content_id);
switch ($data) {
    case "true":
        $query = $_DB->Query("select * from jos_porsche_self_reading_task where filename='{$filename}'");
        $_DB->Execute("UPDATE jos_porsche_self SET end_time = NOW( ) WHERE id = ( SELECT self_content_id\nFROM jos_porsche_self_reading_task\nWHERE id = '{$qid}' )");
        //UPDATE jos_porsche_self AS a LEFT JOIN jos_porsche_self_reading_task AS b ON a.id = b.self_content_id SET a.end_time = 'NOW()' WHERE b.id = '13'
        if ($query == true) {
            $status = "updated audio successfully";
        } else {
            $query = $_DB->Execute("UPDATE jos_porsche_self_reading_task SET filename='{$filename}' where id='{$qid}'");
            if ($query == true) {
                $status = "audio upload successful";
            } else {
                $status = "audio cannot be uploaded";
            }
<?php

include 'set_xml_session.php';
include 'setup.php';
include 'upload.class.php';
//header("content-type:application/xml");
$output = "<?xml version='1.0' encoding='UTF-8'?><Result><Status>";
$uid = $_SESSION['UID'];
//www.tritonetech.com/php_uploads/porsche/webservice/upload_group_writing_image.php
$up_obj = new UploadAudioFile();
$data = $up_obj->upload_file("./group_writing_image/");
$filename = $_FILES['userfile']['name'];
$qid = basename($filename, ".jpeg");
//$self_reading_task_id=basename($filename,".wav");
//var_dump($self_content_id);
switch ($data) {
    case "true":
        $query = $_DB->Query("select * from jos_porsche_group_writing_task where image='{$filename}'");
        $count = $_DB->GetResultNumber($query);
        if ($count != 0) {
            $status = "updated image successfully";
        } else {
            $time = time();
            $query = $_DB->Execute("UPDATE jos_porsche_group_writing_task SET image='{$filename}',ans_time='{$time}' where id='{$qid}'");
            if ($query == true) {
                $status = "image upload successful";
            } else {
                $status = "play the content first";
            }
        }
        break;
<?php

include 'set_xml_session.php';
include "setup.php";
include "upload.class.php";
header("content-type:application/xml");
$output = "<?xml version='1.0' encoding='utf-8'?><Result><Status>";
$up_obj = new UploadAudioFile();
$data = $up_obj->upload_file("./audio/");
$filename = $_FILES['userfile']['name'];
$word = rtrim($filename, '.wav');
//wwww.tritonetech.com/php_uploads/porsche/webservice/upload_audio.php
switch ($data) {
    case "true":
        $query = $_DB->Query("select * from jos_porsche_words where words='{$word}'");
        $count = $_DB->GetResultNumber($query);
        if ($count == 0) {
            $query = $_DB->Execute("insert into jos_porsche_words values('','{$word}','1','','NOW()')");
            if ($query == true) {
                $status = "audio file added";
                $output .= $status . "</Status></Result>";
                echo $output;
            } else {
                $status = "audio file not added";
                $output .= $status . "</Status></Result>";
                echo $output;
            }
        } else {
            $query = $_DB->Execute("update jos_porsche_words set audio='1',time=NOW() where words='{$word}'");
            if ($query == true) {
                $status = "audio file added";