Example #1
0
function processSMSCommand($from, $SMSCommand = "", $playlistName = "")
{
    global $gv, $DEBUG;
    $FPPDStatus = false;
    $output = "";
    //   if($playlistName != "") {
    $PLAYLIST_NAME = trim($playlistName);
    //  } else {
    //           logEntry("No playlist name specified, using Plugin defined playlist: ".$PLAYLIST_NAME);
    //   }
    logEntry("Processing command: " . $SMSCommand . " for playlist: " . $PLAYLIST_NAME);
    $FPPDStatus = isFPPDRunning();
    logEntry("FPPD status: " . $FPPDStatus);
    if ($FPPDStatus != "RUNNING") {
        logEntry("FPPD NOT RUNNING: Sending message to : " . $from . " that FPPD status: " . $FPPDStatus);
        //send a message that the daemon is not running and cannot execute the command
        $gv->sendSMS($from, "FPPD is not running, cannot execute cmd: " . $SMSCommand);
        sleep(1);
        processReadSentMessages();
        return;
    } else {
        logEntry("Sending message to : " . $from . " that FPPD status: " . $FPPDStatus);
        $gv->sendSMS($from, "FPPD is running, I will execute command: " . $SMSCommand);
        sleep(1);
        //if sending a message.. need to clear it as it may hose up the next queue of messages
        processReadSentMessages();
    }
    $cmd = "/opt/fpp/bin/fpp ";
    switch (trim(strtoupper($SMSCommand))) {
        case "PLAY":
            $cmd .= "-P \"" . $PLAYLIST_NAME . "\"";
            break;
        case "STOP":
            $cmd .= "-c stop";
            break;
        case "REPEAT":
            $cmd .= "-p \"" . $PLAYLIST_NAME . "\"";
            break;
        case "STATUS":
            $playlistName = getRunningPlaylist();
            if ($playlistName == null) {
                $playlistName = " No current playlist active or FPPD starting, please try your command again in a few";
            }
            logEntry("Sending SMS to : " . $from . " playlist: " . $playlistName);
            $gv->sendSMS($from, "Playlist STATUS: " . $playlistName);
            break;
        default:
            $cmd = "";
            break;
    }
    if ($cmd != "") {
        logEntry("Executing SMS command: " . $cmd);
        exec($cmd, $output);
        //system($cmd,$output);
    }
    logEntry("Processing command: " . $cmd);
}
Example #2
0
            //$profanityCheck = check_for_profanity_WebPurify($messageText);
            //$profanityCheck = profanityChecker($messageText);
            //if(!$profanityCheck) {
            //returns a list of array,
            if (!$profanityCheck) {
                logEntry("Message: " . $messageText . " PASSED");
                $gv->sendSMS($from, $REPLY_TEXT);
                //$gv->sendSMS($from,"Thank you for your message, it has been added to the queue");
                processSMSMessage($from, $messageText);
                sleep(1);
                processReadSentMessages();
            } else {
                logEntry("message: " . $messageText . " FAILED");
                $gv->sendSMS($from, "Your message contains profanity, sorry. More messages like these will ban your phone number");
                sleep(1);
                processReadSentMessages();
            }
        }
    }
}
if ($IMMEDIATE_OUTPUT != "on" && $IMMEDIATE_OUTPUT != "1") {
    logEntry("NOT immediately outputting to matrix");
} else {
    logEntry("IMMEDIATE OUTPUT ENABLED");
    logEntry("Matrix location: " . $MATRIX_LOCATION);
    logEntry("Matrix Exec page: " . $MATRIX_EXEC_PAGE_NAME);
    if ($MATRIX_LOCATION != "127.0.0.1") {
        $remoteCMD = "/usr/bin/curl -s --basic 'http://" . $MATRIX_LOCATION . "/plugin.php?plugin=" . $MATRIX_MESSAGE_PLUGIN_NAME . "&page=" . $MATRIX_EXEC_PAGE_NAME . "&nopage=1' > /dev/null";
        logEntry("REMOTE MATRIX TRIGGER: " . $remoteCMD);
        exec($remoteCMD);
    } else {