コード例 #1
0
ファイル: gv_send.php プロジェクト: bobrock/vesuvius
function gv_send($gmail, $gmail_pwd, $msg)
{
    try {
        $gv = new GoogleVoice($gmail, $gmail_pwd);
        $arr = splitText($msg, ' ', 140);
        $i = count($arr) - 1;
        while ($i >= 0) {
            $gv->sms($a[1], $arr[$i]);
            $i--;
        }
        // echo sent successfully
        //$global['xajax_res']->addAppend('rezLog', 'innerHTML', '<br>New SMS message was sent to '. $a[0]. ', status: '.$gv->status);
    } catch (Exception $e) {
        // echo save error
        //em_save_post_error($id, $_SESSION['user'], $e->getMessage());
        // echo error
        //$global['xajax_res']->addAppend('rezLog', 'innerHTML', '<br>SMS error:'. $e->getMessage());
    }
}
コード例 #2
0
ファイル: tw_send.php プロジェクト: bobrock/vesuvius
function tw_send($consumer_key, $consumer_secret, $token, $secret, $msg)
{
    try {
        $twitterObj = new EpiTwitter($consumer_key, $consumer_secret, $token, $secret);
        //$a[0], $a[1], $a[2], $a[3]);
        $arr = splitText($msg, ' ', 140);
        $i = count($arr) - 1;
        while ($i >= 0) {
            $status = $twitterObj->post('/statuses/update.json', array('status' => $arr[$i]));
            $i--;
        }
        // echo post sent successfully
        //$global['xajax_res']->addAppend('rezLog', 'innerHTML', '<br>New post was sent to Twitter');
    } catch (Exception $e) {
        // save error
        //em_save_post_error($id, $_SESSION['user'], $e->getMessage());
        // echo error
        //$global['xajax_res']->addAppend('rezLog', 'innerHTML', '<br>Twitter error:'.$e->getMessage());
    }
}
コード例 #3
0
ファイル: edit_archivedtexts.php プロジェクト: hans/lwt
                    $message = 'Unarchived Text(s): ' . $count;
                }
            }
        }
    }
}
// DEL
if (isset($_REQUEST['del'])) {
    $message = runsql('delete from archivedtexts where AtID = ' . $_REQUEST['del'], "Archived Texts deleted");
    adjust_autoincr('archivedtexts', 'AtID');
    runsql("DELETE archtexttags FROM (archtexttags LEFT JOIN archivedtexts on AgAtID = AtID) WHERE AtID IS NULL", '');
} elseif (isset($_REQUEST['unarch'])) {
    $message2 = runsql('insert into texts (TxLgID, TxTitle, TxText, TxAudioURI) select AtLgID, AtTitle, AtText, AtAudioURI from archivedtexts where AtID = ' . $_REQUEST['unarch'], "Texts added");
    $id = get_last_key();
    runsql('insert into texttags (TtTxID, TtT2ID) select ' . $id . ', AgT2ID from archtexttags where AgAtID = ' . $_REQUEST['unarch'], "");
    splitText(get_first_value('select TxText as value from texts where TxID = ' . $id), get_first_value('select TxLgID as value from texts where TxID = ' . $id), $id);
    $message1 = runsql('delete from archivedtexts where AtID = ' . $_REQUEST['unarch'], "Archived Texts deleted");
    $message = $message1 . " / " . $message2 . " / Sentences added: " . get_first_value('select count(*) as value from sentences where SeTxID = ' . $id) . " / Text items added: " . get_first_value('select count(*) as value from textitems where TiTxID = ' . $id);
    adjust_autoincr('archivedtexts', 'AtID');
    runsql("DELETE archtexttags FROM (archtexttags LEFT JOIN archivedtexts on AgAtID = AtID) WHERE AtID IS NULL", '');
} elseif (isset($_REQUEST['op'])) {
    // UPDATE
    if ($_REQUEST['op'] == 'Change') {
        $message = runsql('update archivedtexts set ' . 'AtLgID = ' . $_REQUEST["AtLgID"] . ', ' . 'AtTitle = ' . convert_string_to_sqlsyntax($_REQUEST["AtTitle"]) . ', ' . 'AtText = ' . convert_string_to_sqlsyntax($_REQUEST["AtText"]) . ', ' . 'AtAudioURI = ' . convert_string_to_sqlsyntax($_REQUEST["AtAudioURI"]) . ' ' . 'where AtID = ' . $_REQUEST["AtID"], "Updated");
        $id = $_REQUEST["AtID"];
    }
    saveArchivedTextTags($id);
}
// CHG
if (isset($_REQUEST['chg'])) {
    $sql = 'select AtLgID, AtTitle, AtText, AtAudioURI from archivedtexts where AtID = ' . $_REQUEST['chg'];
コード例 #4
0
ファイル: edit_languages.php プロジェクト: hans/lwt
// REFRESH
if (isset($_REQUEST['refresh'])) {
    $id = $_REQUEST['refresh'] + 0;
    $message2 = runsql('delete from sentences where SeLgID = ' . $id, "Sentences deleted");
    $message3 = runsql('delete from textitems where TiLgID = ' . $id, "Text items deleted");
    adjust_autoincr('sentences', 'SeID');
    adjust_autoincr('textitems', 'TiID');
    $sql = "select TxID, TxText from texts where TxLgID = " . $id . " order by TxID";
    $res = mysql_query($sql);
    if ($res == FALSE) {
        die("Invalid Query: {$sql}");
    }
    while ($record = mysql_fetch_assoc($res)) {
        $txtid = $record["TxID"];
        $txttxt = $record["TxText"];
        splitText($txttxt, $id, $txtid);
    }
    mysql_free_result($res);
    $message = $message2 . " / " . $message3 . " / Sentences added: " . get_first_value('select count(*) as value from sentences where SeLgID = ' . $id) . " / Text items added: " . get_first_value('select count(*) as value from textitems where TiLgID = ' . $id);
}
// DEL
if (isset($_REQUEST['del'])) {
    $anztexts = get_first_value('select count(TxID) as value from texts where TxLgID = ' . $_REQUEST['del']);
    $anzarchtexts = get_first_value('select count(AtID) as value from archivedtexts where AtLgID = ' . $_REQUEST['del']);
    $anzwords = get_first_value('select count(WoID) as value from words where WoLgID = ' . $_REQUEST['del']);
    if ($anztexts > 0 || $anzarchtexts > 0 || $anzwords > 0) {
        $message = 'You must first delete texts, archived texts and words with this language!';
    } else {
        $message = runsql('delete from languages where LgID = ' . $_REQUEST['del'], "Deleted");
        adjust_autoincr('languages', 'LgID');
    }
コード例 #5
0
ファイル: edit_texts.php プロジェクト: robotmay/lwt
            pageend();
            exit;
        } elseif (substr($_REQUEST['op'], 0, 4) == 'Save') {
            $message1 = runsql('insert into texts (TxLgID, TxTitle, TxText, TxAudioURI) values( ' . $_REQUEST["TxLgID"] . ', ' . convert_string_to_sqlsyntax($_REQUEST["TxTitle"]) . ', ' . convert_string_to_sqlsyntax($_REQUEST["TxText"]) . ', ' . convert_string_to_sqlsyntax($_REQUEST["TxAudioURI"]) . ' ' . ')', "Saved");
            $id = get_last_key();
            saveTextTags($id);
        } elseif (substr($_REQUEST['op'], 0, 6) == 'Change') {
            $message1 = runsql('update texts set ' . 'TxLgID = ' . $_REQUEST["TxLgID"] . ', ' . 'TxTitle = ' . convert_string_to_sqlsyntax($_REQUEST["TxTitle"]) . ', ' . 'TxText = ' . convert_string_to_sqlsyntax($_REQUEST["TxText"]) . ', ' . 'TxAudioURI = ' . convert_string_to_sqlsyntax($_REQUEST["TxAudioURI"]) . ' ' . 'where TxID = ' . $_REQUEST["TxID"], "Updated");
            $id = $_REQUEST["TxID"];
            saveTextTags($id);
        }
        $message2 = runsql('delete from sentences where SeTxID = ' . $id, "Sentences deleted");
        $message3 = runsql('delete from textitems where TiTxID = ' . $id, "Textitems deleted");
        adjust_autoincr('sentences', 'SeID');
        adjust_autoincr('textitems', 'TiID');
        splitText(get_first_value('select TxText as value from texts where TxID = ' . $id), $_REQUEST["TxLgID"], $id);
        $message = $message1 . " / " . $message2 . " / " . $message3 . " / Sentences added: " . get_first_value('select count(*) as value from sentences where SeTxID = ' . $id) . " / Text items added: " . get_first_value('select count(*) as value from textitems where TiTxID = ' . $id);
        if (substr($_REQUEST['op'], -8) == "and Open") {
            header('Location: do_text.php?start=' . $id);
            exit;
        }
    }
}
if (isset($_REQUEST['new'])) {
    // NEW
    ?>

	<h4>New Text <a target="_blank" href="info.htm#howtotext"><img src="icn/question-frame.png" title="Help" alt="Help" /></a> </h4>
	<form class="validate" action="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
コード例 #6
0
function splitText($text, $pieces)
{
    if (1 == $pieces) {
        return trim($text);
    } else {
        if (2 == $pieces) {
            $halfPos = mb_strlen($text) / 2;
            $firstSpacePos = mb_strpos($text, ' ', $halfPos);
            return trim(mb_substr($text, 0, $firstSpacePos)) . "\n" . trim(mb_substr($text, $firstSpacePos + 1));
        } else {
            if (3 == $pieces) {
                $thirdPos = mb_strlen($text) / 3;
                $firstSpacePos = trim(mb_strpos($text, ' ', $thirdPos));
                return trim(mb_substr($text, 0, $firstSpacePos)) . "\n" . splitText(mb_substr($text, $firstSpacePos + 1), 2);
            }
        }
    }
    return $text;
}
コード例 #7
0
ファイル: utilities.inc.php プロジェクト: russell359/lwt
function check_update_db()
{
    global $debug;
    $tables = array();
    $res = mysql_query("SHOW TABLES");
    if ($res == FALSE) {
        die("SHOW TABLES error");
    }
    while ($row = mysql_fetch_row($res)) {
        $tables[] = $row[0];
    }
    mysql_free_result($res);
    $count = 0;
    // counter for cache rebuild
    // Rebuild Tables if missing
    if (in_array('archivedtexts', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding archivedtexts</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS archivedtexts ( AtID int(11) unsigned NOT NULL AUTO_INCREMENT, AtLgID int(11) unsigned NOT NULL, AtTitle varchar(200) NOT NULL, AtText text NOT NULL, AtAudioURI varchar(200) DEFAULT NULL, PRIMARY KEY (AtID), KEY AtLgID (AtLgID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array('languages', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding languages</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS languages ( LgID int(11) unsigned NOT NULL AUTO_INCREMENT, LgName varchar(40) NOT NULL, LgDict1URI varchar(200) NOT NULL, LgDict2URI varchar(200) DEFAULT NULL, LgGoogleTranslateURI varchar(200) DEFAULT NULL, LgGoogleTTSURI varchar(200) DEFAULT NULL, LgTextSize int(5) unsigned NOT NULL DEFAULT '100', LgCharacterSubstitutions varchar(500) NOT NULL, LgRegexpSplitSentences varchar(500) NOT NULL, LgExceptionsSplitSentences varchar(500) NOT NULL, LgRegexpWordCharacters varchar(500) NOT NULL, LgRemoveSpaces int(1) unsigned NOT NULL DEFAULT '0', LgSplitEachChar int(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (LgID), UNIQUE KEY LgName (LgName) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array('sentences', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding sentences</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS sentences ( SeID int(11) unsigned NOT NULL AUTO_INCREMENT, SeLgID int(11) unsigned NOT NULL, SeTxID int(11) unsigned NOT NULL, SeOrder int(11) unsigned NOT NULL, SeText text, PRIMARY KEY (SeID), KEY SeLgID (SeLgID), KEY SeTxID (SeTxID), KEY SeOrder (SeOrder) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
        $count++;
    }
    if (in_array('settings', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding settings</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS settings ( StKey varchar(40) NOT NULL, StValue varchar(40) DEFAULT NULL, PRIMARY KEY (StKey) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array('textitems', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding textitems</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS textitems ( TiID int(11) unsigned NOT NULL AUTO_INCREMENT, TiLgID int(11) unsigned NOT NULL, TiTxID int(11) unsigned NOT NULL, TiSeID int(11) unsigned NOT NULL, TiOrder int(11) unsigned NOT NULL, TiWordCount int(1) unsigned NOT NULL, TiText varchar(250) NOT NULL, TiTextLC varchar(250) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, TiIsNotWord tinyint(1) NOT NULL, PRIMARY KEY (TiID), KEY TiLgID (TiLgID), KEY TiTxID (TiTxID), KEY TiSeID (TiSeID), KEY TiOrder (TiOrder), KEY TiTextLC (TiTextLC), KEY TiIsNotWord (TiIsNotWord) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
        $count++;
    }
    if (in_array('texts', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding texts</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS texts ( TxID int(11) unsigned NOT NULL AUTO_INCREMENT, TxLgID int(11) unsigned NOT NULL, TxTitle varchar(200) NOT NULL, TxText text NOT NULL, TxAudioURI varchar(200) DEFAULT NULL, PRIMARY KEY (TxID), KEY TxLgID (TxLgID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array('words', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding words</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS words ( WoID int(11) unsigned NOT NULL AUTO_INCREMENT, WoLgID int(11) unsigned NOT NULL, WoText varchar(250) NOT NULL, WoTextLC varchar(250) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, WoStatus tinyint(4) NOT NULL, WoTranslation varchar(500) NOT NULL DEFAULT '*', WoRomanization varchar(100) DEFAULT NULL, WoSentence varchar(1000) DEFAULT NULL, WoCreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, WoStatusChanged timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (WoID), UNIQUE KEY WoLgIDTextLC (WoLgID,WoTextLC), KEY WoLgID (WoLgID), KEY WoStatus (WoStatus), KEY WoTextLC (WoTextLC), KEY WoTranslation (WoTranslation(333)), KEY WoCreated (WoCreated), KEY WoStatusChanged (WoStatusChanged) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array('tags', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding tags</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS tags ( TgID int(11) unsigned NOT NULL AUTO_INCREMENT, TgText varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, TgComment varchar(200) NOT NULL, PRIMARY KEY (TgID), UNIQUE KEY TgText (TgText) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array('wordtags', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding wordtags</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS wordtags ( WtWoID int(11) unsigned NOT NULL, WtTgID int(11) unsigned NOT NULL, PRIMARY KEY (WtWoID,WtTgID), KEY WtTgID (WtTgID), KEY WtWoID (WtWoID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array('tags2', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding tags2</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS tags2 ( T2ID int(11) unsigned NOT NULL AUTO_INCREMENT, T2Text varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, T2Comment varchar(200) NOT NULL, PRIMARY KEY (T2ID), UNIQUE KEY T2Text (T2Text) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array('texttags', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding texttags</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS texttags ( TtTxID int(11) unsigned NOT NULL, TtT2ID int(11) unsigned NOT NULL, PRIMARY KEY (TtTxID,TtT2ID), KEY TtTxID (TtTxID), KEY TtT2ID (TtT2ID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if (in_array('archtexttags', $tables) == FALSE) {
        if ($debug) {
            echo '<p>DEBUG: rebuilding archtexttags</p>';
        }
        runsql("CREATE TABLE IF NOT EXISTS archtexttags ( AgAtID int(11) unsigned NOT NULL, AgT2ID int(11) unsigned NOT NULL, PRIMARY KEY (AgAtID,AgT2ID), KEY AgAtID (AgAtID), KEY AgT2ID (AgT2ID) ) ENGINE=MyISAM DEFAULT CHARSET=utf8", '');
    }
    if ($count > 0) {
        // Rebuild Text Cache if cache tables new
        if ($debug) {
            echo '<p>DEBUG: rebuilding cache tables</p>';
        }
        $sql = "select TxID, TxLgID from texts";
        $res = mysql_query($sql);
        if ($res == FALSE) {
            die("Invalid Query: {$sql}");
        }
        while ($record = mysql_fetch_assoc($res)) {
            $id = $record['TxID'];
            runsql('delete from sentences where SeTxID = ' . $id, "");
            runsql('delete from textitems where TiTxID = ' . $id, "");
            adjust_autoincr('sentences', 'SeID');
            adjust_autoincr('textitems', 'TiID');
            splitText(get_first_value('select TxText as value from texts where TxID = ' . $id), $record['TxLgID'], $id);
        }
        mysql_free_result($res);
    }
    // Version
    $res = mysql_query("select StValue as value from settings where StKey = 'dbversion'");
    if (mysql_errno() != 0) {
        die('There is something wrong with your database ' . $dbname . '. Please reinstall.');
    }
    $record = mysql_fetch_assoc($res);
    if ($record) {
        $dbversion = $record["value"];
    } else {
        $dbversion = 'v001000000';
        saveSetting('dbversion', $dbversion);
        if ($debug) {
            echo '<p>DEBUG: DB version not found, set to: ' . $dbversion . '</p>';
        }
    }
    mysql_free_result($res);
    // Do DB Updates
    $currversion = get_version_number();
    if ($currversion > $dbversion) {
        if ($currversion > 'v001000000') {
            // updates for all versions > 1.0.0
            if ($debug) {
                echo '<p>DEBUG: Doing db-upgrade ' . $currversion . ' &gt; v001000000</p>';
            }
            runsql("ALTER TABLE words ADD WoTodayScore DOUBLE NOT NULL DEFAULT 0, ADD WoTomorrowScore DOUBLE NOT NULL DEFAULT 0, ADD WoRandom DOUBLE NOT NULL DEFAULT 0", '');
            runsql("ALTER TABLE words ADD INDEX WoTodayScore (WoTodayScore), ADD INDEX WoTomorrowScore (WoTomorrowScore), ADD INDEX WoRandom (WoRandom)", '');
            runsql("UPDATE words SET " . make_score_random_insert_update('u'), '');
        }
        if ($currversion > 'v001001001') {
            if ($debug) {
                echo '<p>DEBUG: Doing db-upgrade ' . $currversion . ' &gt; v001001001</p>';
            }
            // updates for all versions > 1.1.1 :
            // New: Table "tags", created above
            // New: Table "wordtags", created above
        }
        if ($currversion > 'v001002002') {
            if ($debug) {
                echo '<p>DEBUG: Doing db-upgrade ' . $currversion . ' &gt; v001002002</p>';
            }
            // updates for all versions > 1.2.2 :
            // New: Table "tags2", created above
            // New: Table "texttags", created above
            // New: Table "archtexttags", created above
            runsql("ALTER TABLE languages ADD LgRightToLeft INT(1) UNSIGNED NOT NULL DEFAULT  0", '');
        }
        // set to current.
        saveSetting('dbversion', $currversion);
    }
    // Do Scoring once per day, clean Word/Texttags, and optimize db
    $lastscorecalc = getSetting('lastscorecalc');
    $today = date('Y-m-d');
    if ($lastscorecalc != $today) {
        if ($debug) {
            echo '<p>DEBUG: Doing score recalc. Today: ' . $today . ' / Last: ' . $lastscorecalc . '</p>';
        }
        runsql("UPDATE words SET " . make_score_random_insert_update('u'), '');
        runsql("DELETE wordtags FROM (wordtags LEFT JOIN tags on WtTgID = TgID) WHERE TgID IS NULL", '');
        runsql("DELETE wordtags FROM (wordtags LEFT JOIN words on WtWoID = WoID) WHERE WoID IS NULL", '');
        runsql("DELETE texttags FROM (texttags LEFT JOIN tags2 on TtT2ID = T2ID) WHERE T2ID IS NULL", '');
        runsql("DELETE texttags FROM (texttags LEFT JOIN texts on TtTxID = TxID) WHERE TxID IS NULL", '');
        runsql("DELETE archtexttags FROM (archtexttags LEFT JOIN tags2 on AgT2ID = T2ID) WHERE T2ID IS NULL", '');
        runsql("DELETE archtexttags FROM (archtexttags LEFT JOIN archivedtexts on AgAtID = AtID) WHERE AtID IS NULL", '');
        optimizedb();
        saveSetting('lastscorecalc', $today);
    }
}