$_REQUEST['cat'] = 'spam';
            $_REQUEST['docid'] = "ticket_" . $row_spam['nTicketId'];
            if ($filtertype == "SUBJECT") {
                $_REQUEST['document'] = $row_spam['vTitle'];
            } else {
                if ($filtertype == "BODY") {
                    $_REQUEST['document'] = $row_spam['tQuestion'];
                } else {
                    if ($filtertype == "BOTH") {
                        $_REQUEST['document'] = $row_spam['vTitle'] . " " . $row_spam['tQuestion'];
                    }
                }
            }
            //$_REQUEST['document']=$row_spam['vTitle'];
            //echo " doc==". $_REQUEST['document'];
            train();
            $val = $row_spam['nDeptId'];
            $var_machineip = $row_spam['vMachineIP'];
            $var_message_main = $row_spam['tQuestion'];
            $sql = "insert into sptbl_spam_tickets(nSpamTicketId,nDeptId,vTitle,tQuestion,dPostDate,vMachineIP)\r\n\t\t\t\t\tvalues('','" . $val . "','" . mysql_real_escape_string($row_spam['vTitle']) . "','" . mysql_real_escape_string($var_message_main) . "',now(),\r\n\t\t\t\t\t'" . mysql_real_escape_string($var_machineip) . "')";
            executeQuery($sql, $conn);
        }
    }
    $message = "";
    deleteChecked($var_list, $message);
    $message = "<font color=\"red\">" . $updatedtickets . MESSAGE_RECORD_MOVED_SUCCESSFULLY . "</font><br>";
}
if ($_POST["del"] == "UP") {
    $frm_status = $_POST['cmbStatus'];
    $updatedtickets = 0;
    for ($i = 0; $i < count($_POST["chkDeleteTickets"]); $i++) {
Esempio n. 2
0
File: index.php Progetto: 0-php/AI
<?php

/**
 * A very simple executable script to train and use the LanguageDetector
 * class. For now it will not use a more complex (and better) structure like
 * Symfony\Console\Application but it will be a self contained little script.
 */
include "vendor/autoload.php";
try {
    $command = isset($_POST['command']) ? $_POST['command'] : "";
    switch ($command) {
        case "train":
            train($argv);
            break;
        case "evaluate":
            evaluate($argv);
            break;
        case "classify":
            classify($argv);
            break;
        case "help":
        default:
            help();
            break;
    }
} catch (Exception $e) {
    echo PHP_EOL, $e->getMessage(), PHP_EOL, PHP_EOL;
}
/**
 * Just echo a simple help message
 */
Esempio n. 3
0
// initialize client object
$api = new FacePPClient($api_key, $api_secret);
// the list of person_name to train and recognize for
$person_names = array("denny", "beauty");
// store the face_ids obtained by detection/detect API
$face_ids = array();
// register new people, detect faces
foreach ($person_names as $person_name) {
    detect($api, $person_name, $face_ids);
}
// the name of group for testing
$group = "sample_group";
// generate a new group, add people into group
create_group($api, $group, $person_names);
// generate training model for group
train($api, $group);
// finally, search people in the group
recognize($api, $person_names[0], $group);
/* 
 *	create new person, detect faces from person's image_url
 */
function detect(&$api, $person_name, &$face_ids)
{
    // obtain photo_url to train
    $url = getTrainingUrl($person_name);
    // detect faces in this photo
    $result = $api->face_detect($url);
    // skip errors
    if (empty($result->face)) {
        return false;
    }
Esempio n. 4
0
 public function responseMsg()
 {
     //get post data, May be due to the different environments
     $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
     //extract post data
     if (!empty($postStr)) {
         $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
         $fromUsername = $postObj->FromUserName;
         $toUsername = $postObj->ToUserName;
         $msgType = $postObj->MsgType;
         if ($msgType == "text") {
             $keyword = trim($postObj->Content);
             $time = time();
             $textTpl = "<xml>\n\t\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t</xml>";
             if (!empty($keyword)) {
                 $api_key = "SEwcXuDQE7ZcGM0Fxz2B02zb";
                 // initialize client object
                 $api = new BaiduTranslateClient($api_key);
                 $result = $api->translate($keyword, "auto", "auto");
                 $contentStr = "Translation Failed!";
                 if (!empty($result->trans_result)) {
                     if (count($result->trans_result) > 0) {
                         $contentStr = $result->trans_result[0]->dst;
                     }
                 }
                 $msgType = "text";
                 //$contentStr = "Hi, I'm Mars Robot! 有何贵干? 你可以发送位置,试试看。";
                 $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
                 echo $resultStr;
             } else {
                 echo "Input something...";
             }
         } else {
             if ($msgType == "location") {
                 $location_x = $postObj->Location_X;
                 $location_y = $postObj->Location_Y;
                 $scale = $postObj->Scale;
                 $label = $postObj->Label;
                 $time = time();
                 $textTpl = "<xml>\n\t\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t</xml>";
                 $api_key = "0e4fde2b4acbc043abdb68df511359ae";
                 // initialize client object
                 $api = new BaiduMapClient($api_key);
                 $result = $api->geocoder_location($location_x . "," . $location_y);
                 if (!empty($result)) {
                     $msgType = "text";
                     $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $label . $result);
                     echo $resultStr;
                 }
             } else {
                 if ($msgType == "image") {
                     $url = $postObj->PicUrl;
                     $time = time();
                     $api_key = "e336859e1099669c6662a3ca76c590b8";
                     $api_secret = "HcMo_lQFQ4RZ1qrijxjjnzoHeNjxMc18";
                     // initialize client object
                     $api = new FacePPClient($api_key, $api_secret);
                     $person_name = md5(time() . rand());
                     //$file_name = $this->getFileByWget($url, $person_name . ".jpg");
                     $ret = $this->downloadImage($url, "/home/clasix/sites/weixin/images/" . $person_name);
                     if (!$ret) {
                         $textTpl = "<xml>\n\t\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t</xml>";
                         $msgType = "text";
                         $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, "File Download Failed!");
                         echo $resultStr;
                     } else {
                         //
                         // do search by url_img
                         $group = "sample_group";
                         $face_ids = array();
                         detect($api, $person_name, $face_ids);
                         $result = recognize($api, $person_name, $group);
                         if (!empty($result)) {
                             $textTpl = "<xml>\n\t\t\t\t\t\t\t\t\t <ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t\t\t <FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t\t\t <CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t\t\t <MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t\t\t <Content><![CDATA[]]></Content>\n\t\t\t\t\t\t\t\t\t <ArticleCount>1</ArticleCount>\n\t\t\t\t\t\t\t\t\t <Articles>\n\t\t\t\t\t\t\t\t\t <item>\n\t\t\t\t\t\t\t\t\t <Title><![CDATA[Similar Pic]]></Title>\n\t\t\t\t\t\t\t\t\t <Description><![CDATA[nothing]]></Description>\n\t\t\t\t\t\t\t\t\t <PicUrl><![CDATA[%s]]></PicUrl>\n\t\t\t\t\t\t\t\t\t <Url><![CDATA[%s]]></Url>\n\t\t\t\t\t\t\t\t\t </item>\n\t\t\t\t\t\t\t\t\t </Articles>\n\t\t\t\t\t\t\t\t\t <FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t\t </xml>";
                             $msgType = "news";
                             $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, getWeiXinUrl($result), getWeiXinUrl($result));
                             echo $resultStr;
                         } else {
                             $textTpl = "<xml>\n\t\t\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t\t</xml>";
                             $msgType = "text";
                             $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, "No Similar Pictures");
                             echo $resultStr;
                         }
                         // do train job
                         $api->group_add_person($person_name, $group);
                         train($api, $group);
                     }
                 } else {
                     echo "";
                     exit;
                 }
             }
         }
     } else {
         echo "";
         exit;
     }
 }