コード例 #1
0
ファイル: engine.php プロジェクト: xshifty/duntxt
function answer(array $options)
{
    $callbacks = array_values($options);
    $answers = array_keys($options);
    $menu = array_map(function ($value, $index) {
        return sprintf("%s) %s", $index + 1, $value);
    }, $answers, array_keys($answers));
    while (true) {
        narrate(["Choose an option and press [ENTER]:"], 1);
        narrate($menu);
        $selected = readline();
        if (isset($callbacks[intval($selected) - 1])) {
            $next = $callbacks[intval($selected) - 1];
            break;
        }
        narrate(["Invalid answer!"], 1);
    }
    if (is_callable($next)) {
        $list = array_keys($options);
        dialog("You", [$list[intval($selected) - 1]]);
        $next();
    }
}
コード例 #2
0
ファイル: dialog.php プロジェクト: jean-pasqualini/ia
    $errors[] = 'ERROR #' . $errno . ': ' . $errstr . ' (' . $errfile . ', line ' . $errline . ')';
    return TRUE;
}
###################################################################################################
# main
###################################################################################################
if (!posix_isatty(STDOUT)) {
    trigger_error('wrong terminal');
    exit;
}
ncurses_init();
error_reporting(E_ALL);
$errors = array();
set_error_handler('my_error_handler');
$main_window = ncurses_newwin(0, 0, 0, 0);
ncurses_getmaxyx($main_window, $rows, $cols);
ncurses_keypad($main_window, TRUE);
$message = <<<EOM
Mr. Treehorn draws a lot of water in this town. You don't draw shit, Lebowski. 
Now we got a nice, quiet little beach community here, and I aim to keep it 
nice and quiet. So let me make something plain. I don't like 
you sucking around, bothering our citizens, Lebowski. 
I don't like your jerk-off name. I don't like your jerk-off face. 
I don't like your jerk-off behavior, and I don't like you, jerk-off. 
Do I make myself clear?
EOM;
$result = dialog(array('message' => $message, 'rows' => -1, 'cols' => -1, 'buttons' => array('Yes', 'No', 'I\'m sorry, I wasn\'t listening')));
ncurses_end();
if (!empty($errors)) {
    print join("\n", $errors) . "\n";
}
コード例 #3
0
ファイル: game.php プロジェクト: xshifty/duntxt
function unknownManIntroduction()
{
    dialog("Unknown Man", ["Oh! Very good!", "Do you remember the day you father die?", "..."]);
    narrate(["To be continued..."]);
    gameOver();
}
コード例 #4
0
ファイル: submit.php プロジェクト: pedcards/paging
// Send the pin to the SNPP server
$snppPage = fgets($snppPointer);
fwrite($snppPointer, "MESS " . $message . "\r\n");
// Send the message to the SNPP Server
$snppMsg = fgets($snppPointer);
fwrite($snppPointer, "SEND\r\n");
// Send
$snppSend = fgets($snppPointer);
fwrite($snppPointer, "QUIT\r\n");
// Send QUIT to the SNPP Server
$snppQuit = fgets($snppPointer);
fclose($snppPointer);
// Close the connection
// Testing for a server response code 250 (good).
// If doesn't meet this, then error back.
//echo $snppSend;
if (substr($snppSend, 0, 3) === "250") {
    $success = 1;
    dialog('SUCCESS!', 'green', $smsMsg . ' sent!*', '<small>*hopefully you won\'t regret what you just sent!</small>', 'pager.jpg', 'pager', '', '', 'b');
    exit;
} else {
    if ($snppPage[0] === "4" || $snppPage[0] === "5") {
        $success = false;
        dialog('SERVER ERROR', 'red', 'ERROR!!!', 'Message failed to send!<br>' . $snppSend . '<br>', 'dead_ipod.jpg', 'bummer', 'b', 'a', 'b');
    }
}
?>

</body>
</HTML>
コード例 #5
0
ファイル: module.inc.php プロジェクト: hiproz/zhaotaoci.cc
     cache_module();
     dmsg('更新成功', $this_forward);
     break;
 case 'cache':
     cache_module();
     dmsg('更新成功', '?file=' . $file);
     break;
 case 'ckdir':
     if (!preg_match("/^[0-9a-z_-]+\$/i", $moduledir)) {
         dialog('不是一个合法的目录名,请更换一个再试');
     }
     $r = $db->get_one("SELECT moduleid FROM {$DT_PRE}module WHERE moduledir='{$moduledir}'");
     if ($r || is_dir(DT_ROOT . '/' . $moduledir . '/')) {
         dialog('该目录名已经被使用,请更换一个再试');
     }
     dialog('目录名可以使用');
     break;
 default:
     $sysmodules = get_modules();
     $modules = $_modules = array();
     $result = $db->query("SELECT * FROM {$DT_PRE}module ORDER BY listorder ASC,moduleid DESC");
     while ($r = $db->fetch_array($result)) {
         if ($r['moduleid'] == 1) {
             continue;
         }
         $r['installdate'] = timetodate($r['installtime'], 3);
         $r['modulename'] = isset($sysmodules[$r['module']]) ? $sysmodules[$r['module']]['name'] : '外链';
         if ($r['disabled']) {
             $_modules[] = $r;
         } else {
             $modules[] = $r;
コード例 #6
0
ファイル: category.inc.php プロジェクト: hcd2008/destoon
             }
             $catid += 1;
         } else {
             $catid = $fid + $num;
         }
     } else {
         $do->cache();
         dmsg('更新成功', "?mid={$mid}&file={$file}");
     }
     msg('ID从' . $fid . '至' . ($catid - 1) . '更新成功' . progress($sid, $fid, $tid), "?mid={$mid}&file={$file}&action={$action}&sid={$sid}&fid={$catid}&tid={$tid}&num={$num}");
     break;
 case 'ckdir':
     if ($do->get_catdir($catdir)) {
         dialog('目录名可以使用');
     } else {
         dialog('目录名不合法或者已经被使用');
     }
     break;
 case 'url':
     foreach ($CATEGORY as $c) {
         update_category($c);
     }
     $do->cache();
     dmsg('更新成功', "?mid={$mid}&file={$file}");
     break;
 case 'cache':
     $do->repair();
     dmsg('更新成功', "?mid={$mid}&file={$file}");
     break;
 case 'delete':
     if ($catid) {
コード例 #7
0
ファイル: setting.inc.php プロジェクト: hcd2008/destoon
         $smtp_pass = $DT['smtp_pass'];
     }
     $DT['mail_type'] = $mail_type;
     $DT['smtp_host'] = $smtp_host;
     $DT['smtp_port'] = $smtp_port;
     $DT['smtp_auth'] = $smtp_auth;
     $DT['smtp_user'] = $smtp_user;
     $DT['smtp_pass'] = $smtp_pass;
     $DT['mail_sender'] = $mail_sender;
     $DT['mail_name'] = $mail_name;
     $DT['mail_delimiter'] = $mail_delimiter;
     $DT['mail_sign'] = '<br/>------------------------------------<br><a href="http://www.destoon.com/" target="_blank">Send By Destoon Mail Tester</a>';
     if (send_mail($testemail, $DT['sitename'] . '邮件发送测试', '<b>恭喜!您的站点[' . $DT['sitename'] . ']邮件发送设置成功!</b>')) {
         dialog('邮件已发送至' . $testemail . ',请注意查收', $mail_sender);
     }
     dialog('邮件发送失败,请检查设置');
 } else {
     $tab = isset($tab) ? intval($tab) : 0;
     $all = isset($all) ? intval($all) : 0;
     if ($submit) {
         if (!preg_match("/^[0-9a-z]{10,}\$/i", $config['authkey'])) {
             $config['authkey'] = random(18);
         }
         if ($setting['safe_domain']) {
             $setting['safe_domain'] = str_replace('http://', '', $setting['safe_domain']);
             if (substr($setting['safe_domain'], 0, 4) == 'www.') {
                 $setting['safe_domain'] = substr($setting['safe_domain'], 4);
             }
         }
         if (substr($config['url'], -1) != '/') {
             $config['url'] = $config['url'] . '/';
コード例 #8
0
ファイル: index.php プロジェクト: eebrah/deliveries
				<ul>
					<li>
						<a href="?section=agents&amp;action=view&amp;target=' . $agentID . '">view</a>
					</li>
					<li>
						<a href="?section=agents&amp;action=edit&amp;target=' . $agentID . '">edit</a>
					</li>
				</ul>
			</td>
		</tr>';
                    }
                    $pageBody .= '
	</tbody>
</table>';
                } else {
                    $pageBody = dialog(DIALOG_INFO, "no agents listed");
                }
                break;
            case "add":
                break;
            case "edit":
                break;
            case "view":
                break;
            case "delete":
                break;
        }
        break;
}
$format = "html";
if (isset($_REQUEST["format"])) {
コード例 #9
0
ファイル: setting.inc.php プロジェクト: hiproz/zhaotaoci.cc
     if ($itemid) {
         foreach (array(DT_ROOT . '/file/flash/', DT_ROOT . '/file/image/', DT_ROOT . '/file/script/', DT_ROOT . '/skin/' . $CFG['skin'] . '/', DT_ROOT . '/' . $MODULE[2]['moduledir'] . '/image/', DT_ROOT . '/' . $MODULE[4]['moduledir'] . '/skin/') as $d) {
             $s = str_replace(DT_ROOT, DT_ROOT . '/file/static', $d);
             dir_copy($d, $s);
         }
         foreach (array(DT_ROOT . '/favicon.ico', DT_ROOT . '/lang/' . DT_LANG . '/lang.js') as $d) {
             $s = str_replace(DT_ROOT, DT_ROOT . '/file/static', $d);
             file_copy($d, $s);
         }
     }
     include tpl('static');
     break;
 case 'cache':
     $dc->set('destoon', 'b2b', 3600);
     $pass = $dc->get('destoon') == 'b2b' ? 1 : 0;
     dialog('测试结果:' . ($pass ? '<span class="f_green">成功</span>' : '<span class="f_red">失败</span>') . '&nbsp; &nbsp;缓存类型:' . $CFG['cache'] . '<div style="padding:10px 0 10px 0;">如果类型不正确,请先保存设置再测试</div>');
     break;
 case 'html':
     tohtml('index');
     $dc->set('destoon', 'b2b', 3600);
     $dc->get('destoon') == 'b2b' or dalert('缓存类型' . $CFG['cache'] . '测试失败,' . ($CFG['cache'] == 'file' ? '请检查file目录是否可写' : '请立即更换'), '?moduleid=' . $moduleid . '&file=' . $file . '&tab=2');
     dmsg('更新成功', '?moduleid=' . $moduleid . '&file=' . $file . '&tab=' . $tab);
     break;
 default:
     $tab = isset($tab) ? intval($tab) : 0;
     $all = isset($all) ? intval($all) : 0;
     if ($submit) {
         if ($setting['safe_domain']) {
             $setting['safe_domain'] = str_replace('http://', '', $setting['safe_domain']);
             if (substr($setting['safe_domain'], 0, 4) == 'www.') {
                 $setting['safe_domain'] = substr($setting['safe_domain'], 4);