Subversion Repositories stackman

Compare Revisions

No changes between revisions

Regard whitespace Rev 3 → Rev 4

/trunk/SSH/defaults/.stam_config
7,4 → 7,10
db_pass=
db_base=stackman
 
weblog_host=localhost
weblog_user=root
weblog_pass=
weblog_base=stackman
weblog_password=
 
simulation=0
/trunk/SSH/stam
19,8 → 19,8
 
# Read in the system identifier
if [ $IS_BATCHMODE -eq 0 ]; then
echo "Terminal Stackman 2.3"
echo "(C) 2013-2017 ViaThinkSoft"
echo "Terminal Stackman 2.4"
echo "(C) 2013-2019 ViaThinkSoft"
echo ""
 
if [ -f ~/".autorun" ]; then
95,6 → 95,7
if [ -f ~/.stam_history_mir ]; then
echo "$inp" >> ~/.stam_history_mir
fi
"$DIR"/weblog_add "$inp"
 
# Split command and (single combined) argument
cmd=$( echo "$inp" | cut -d " " -f 1 )
/trunk/SSH/stam_weblog.sql
0,0 → 1,6
CREATE TABLE `stam_weblog` (
`id` int(21) NOT NULL AUTO_INCREMENT,
`ts` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`inp` varchar(1024) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/trunk/SSH/weblog_add
0,0 → 1,62
#!/usr/bin/php
<?php
 
require_once __DIR__ . '/includes/db.inc.php';
require_once __DIR__ . '/includes/src.inc.php';
 
if ($argc <> 2) {
echo "Syntax: $argv[0] <line>\n";
exit(2);
}
 
if (isset($stam_cfg['weblog_host']) && !empty($stam_cfg['weblog_host'])) {
db_close();
 
$weblog_host = $stam_cfg['weblog_host'];
$weblog_user = $stam_cfg['weblog_user'];
$weblog_pass = $stam_cfg['weblog_pass'];
$weblog_base = $stam_cfg['weblog_base'];
 
if (!db_connect($weblog_host, $weblog_user, $weblog_pass)) {
fwrite(STDERR, "Weblog MySQL connect error\n");
exit(2);
}
 
if (!db_select_db($weblog_base)) {
fwrite(STDERR, "Weblog MySQL DB select error\n");
weblog_close();
exit(2);
}
 
$ent = rtrim($argv[1]);
 
if (isset($stam_cfg['weblog_password']) && !empty($stam_cfg['weblog_password'])) {
$iv = 'AAAAAAAAAAAAAAAA';
$ent = base64_encode(openssl_encrypt($ent, 'AES-128-CBC', $stam_cfg['weblog_password'], OPENSSL_RAW_DATA, $iv));
}
 
$x = db_query("INSERT INTO stam_weblog (ts, inp) VALUES (
NOW(),
'".db_real_escape_string($ent)."'
)");
if (!$x) {
fwrite(STDERR, db_error()."\n");
db_close();
exit(1);
}
 
$id = db_insert_id();
if (!$id) {
fwrite(STDERR, "Error: Could not insert\n");
db_close();
exit(1);
}
 
echo green("Weblog written <$id> <$ent>!\n");
}
 
# ---
 
function green($txt) {
return "\033[1;32;40m".$txt."\033[0m";
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/SSH/weblog_read
0,0 → 1,47
#!/usr/bin/php
<?php
 
require_once __DIR__ . '/includes/db.inc.php';
require_once __DIR__ . '/includes/src.inc.php';
 
if ($argc <> 1) {
echo "Syntax: $argv[0]\n";
exit(2);
}
 
if (isset($stam_cfg['weblog_host']) && !empty($stam_cfg['weblog_host'])) {
db_close();
 
$weblog_host = $stam_cfg['weblog_host'];
$weblog_user = $stam_cfg['weblog_user'];
$weblog_pass = $stam_cfg['weblog_pass'];
$weblog_base = $stam_cfg['weblog_base'];
 
if (!db_connect($weblog_host, $weblog_user, $weblog_pass)) {
fwrite(STDERR, "Weblog MySQL connect error\n");
exit(2);
}
 
if (!db_select_db($weblog_base)) {
fwrite(STDERR, "Weblog MySQL DB select error\n");
weblog_close();
exit(2);
}
 
$res = db_query("select * from stam_weblog order by id asc");
while ($row = db_fetch_array($res)) {
$ent = $row['inp'];
if (isset($stam_cfg['weblog_password']) && !empty($stam_cfg['weblog_password'])) {
$iv = 'AAAAAAAAAAAAAAAA';
$ent = openssl_decrypt(base64_decode($ent), 'AES-128-CBC', $stam_cfg['weblog_password'], OPENSSL_RAW_DATA, $iv);
}
echo $row['ts'] . ': ' . $ent . "\n";
 
}
}
 
# ---
 
function green($txt) {
return "\033[1;32;40m".$txt."\033[0m";
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/SSH/weblog_rewrite
0,0 → 1,66
#!/usr/bin/php
<?php
 
require_once __DIR__ . '/includes/db.inc.php';
require_once __DIR__ . '/includes/src.inc.php';
 
if ($argc <> 1) {
echo "Syntax: $argv[0]\n";
exit(2);
}
 
if (isset($stam_cfg['weblog_host']) && !empty($stam_cfg['weblog_host'])) {
db_close();
 
$weblog_host = $stam_cfg['weblog_host'];
$weblog_user = $stam_cfg['weblog_user'];
$weblog_pass = $stam_cfg['weblog_pass'];
$weblog_base = $stam_cfg['weblog_base'];
 
if (!db_connect($weblog_host, $weblog_user, $weblog_pass)) {
fwrite(STDERR, "Weblog MySQL connect error\n");
exit(2);
}
 
if (!db_select_db($weblog_base)) {
fwrite(STDERR, "Weblog MySQL DB select error\n");
weblog_close();
exit(2);
}
 
db_query("TRUNCATE TABLE stam_weblog");
 
$home = posix_getpwuid(posix_getuid())['dir'];
$ents = file($home.'/.stam_history');
foreach ($ents as $ent) {
if (isset($stam_cfg['weblog_password']) && !empty($stam_cfg['weblog_password'])) {
$iv = 'AAAAAAAAAAAAAAAA';
$ent = base64_encode(openssl_encrypt($ent, 'AES-128-CBC', $stam_cfg['weblog_password'], OPENSSL_RAW_DATA, $iv));
}
 
$x = db_query("INSERT INTO stam_weblog (ts, inp) VALUES (
NOW(),
'".db_real_escape_string($ent)."'
)");
if (!$x) {
fwrite(STDERR, db_error()."\n");
db_close();
exit(1);
}
 
$id = db_insert_id();
if (!$id) {
fwrite(STDERR, "Error: Could not insert\n");
db_close();
exit(1);
}
 
echo green("Weblog written <$id> <$ent>!\n");
}
}
 
# ---
 
function green($txt) {
return "\033[1;32;40m".$txt."\033[0m";
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property