Exemplo n.º 1
0
function message_show_all($user_id, $msgbox)
{
    assert(is_numeric($user_id));
    assert(is_string($msgbox));
    // Display all messages
    $found_messages = 0;
    $result = sql_query("SELECT * FROM m_messages WHERE deleted=0 AND type='" . $msgbox . "' AND user_id=" . $user_id . " ORDER BY DATETIME DESC");
    while ($message = sql_fetchrow($result)) {
        message_view($msgbox, $message);
        $found_messages = 1;
    }
    // If there were no messages, display something else..
    if ($found_messages == 0) {
        print_line("<center>Your messagebox is empty...</center><br>");
    }
}
Exemplo n.º 2
0
Arquivo: util.php Projeto: igorw/edn
function dump($data, $depth = 0)
{
    if (is_array($data)) {
        print_line('[', $depth);
        foreach ($data as $key => $value) {
            if (!is_int($key)) {
                print_line("{$key} =>", $depth + 1);
            }
            dump($value, $depth + 2);
        }
        print_line(']', $depth);
        return;
    }
    if (is_object($data)) {
        if (method_exists($data, '__toString')) {
            $class = get_class($data);
            print_line("[{$class}] {$data}", $depth);
            return;
        }
        $class = get_class($data);
        print_line("[{$class}] {", $depth);
        if ($data instanceof \IteratorAggregate) {
            $iterator = $data->getIterator();
        } elseif ($data instanceof \Iterator) {
            $iterator = $data;
        } else {
            $iterator = new \ArrayIterator((array) $data);
        }
        for ($iterator->rewind(); $iterator->valid(); $iterator->next()) {
            if (!is_int($iterator->key())) {
                dump($iterator->key(), $depth + 1);
            }
            dump($iterator->current(), $depth + 2);
        }
        print_line('}', $depth);
        return;
    }
    if (is_string($data)) {
        print_line('"' . $data . '"', $depth);
        return;
    }
    print_line($data, $depth);
}
Exemplo n.º 3
0
function trade_show_routes($user_id)
{
    assert(is_numeric($user_id));
    global $_GALAXY;
    $firstrow = 1;
    $result = sql_query("SELECT * FROM a_trades");
    while ($traderoute = sql_fetchrow($result)) {
        $src_planet = anomaly_get_anomaly($traderoute['src_planet_id']);
        $dst_planet = anomaly_get_anomaly($traderoute['dst_planet_id']);
        // We don't own the source or destination planet... skip it..
        if ($src_planet['user_id'] != $user_id and $dst_planet['user_id'] != $user_id) {
            continue;
        }
        $vessel = vessel_get_vessel($traderoute['vessel_id']);
        $ore1 = "";
        $ore2 = "";
        if ($traderoute['src_ore'] == ORE_NONE) {
            $ore1 = "None, ";
        } elseif ($traderoute['src_ore'] == ORE_ALL) {
            $ore1 = "All ores, ";
        } else {
            $ores = csl($traderoute['src_ore']);
            foreach ($ores as $ore) {
                $ore1 .= ore_get_ore_name($ore) . ", ";
            }
        }
        // Chop off last comma
        $ore1 = substr_replace($ore1, "", -2);
        if ($traderoute['dst_ore'] == ORE_NONE) {
            $ore2 = "None, ";
        } elseif ($traderoute['dst_ore'] == ORE_ALL) {
            $ore2 = "All ores, ";
        } else {
            $ores = csl($traderoute['dst_ore']);
            foreach ($ores as $ore) {
                $ore2 .= ore_get_ore_name($ore) . ", ";
            }
        }
        // Chop off last comma
        $ore2 = substr_replace($ore2, "", -2);
        if ($firstrow == 1) {
            $firstrow = 0;
            print_remark("Vessel table");
            echo "<table align=center width=80% border=0>\n";
            echo "  <tr class=wb>";
            echo "<th>Vessel</th>";
            echo "<th>Source</th>";
            echo "<th>Ores</th>";
            echo "<th>Destination</th>";
            echo "<th>Ores</th>";
            echo "</tr>\n";
        }
        echo "  <tr class=bl>\n";
        echo "    <td>&nbsp;<img src=" . $_CONFIG['URL'] . $_GALAXY['image_dir'] . "/ships/trade.jpg>&nbsp;<a href=vessel.php?cmd=" . encrypt_get_vars("showvid") . "&vid=" . encrypt_get_vars($vessel['id']) . ">" . $vessel['name'] . "</a>&nbsp;</td>\n";
        echo "    <td>&nbsp;<a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($src_planet['id']) . ">" . $src_planet['name'] . "</a>&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $ore1 . "&nbsp;</td>\n";
        echo "    <td>&nbsp;<a href=anomaly.php?cmd=" . encrypt_get_vars("show") . "&aid=" . encrypt_get_vars($dst_planet['id']) . ">" . $dst_planet['name'] . "</a>&nbsp;</td>\n";
        echo "    <td>&nbsp;" . $ore2 . "&nbsp;</td>\n";
        echo "  </tr>\n";
    }
    if ($firstrow == 0) {
        echo "</table>\n";
        echo "<br><br>\n";
    } else {
        print_line("There are currently no traderoutes available.");
    }
}
Exemplo n.º 4
0
    $data['name'] = 0;
    $data['uid'] = 0;
    comm_send_to_server("PRESET", $data, $ok, $errors);
}
if ($cmd == "create") {
    $distance = substr($ne_distance, 0, 5);
    $angle = substr($ne_angle, 0, 6);
    if (!preg_match("/^\\d+\$/", $distance)) {
        print_line("<li><font color=red>You should enter a distance in the format ######.</font>\n");
    } elseif (!preg_match("/^\\d{1,6}\$/", $angle)) {
        print_line("<li><font color=red>You should enter an angle in the format ######.</font>\n");
    } else {
        if ($distance < $_GALAXY['galaxy_core']) {
            print_line("<li><font color=red>You cannot fly that far into the galaxy core. Try a higher distance (minimum is " . $_GALAXY['galaxy_core'] . ").</font>\n");
        } elseif ($distance > $_GALAXY['galaxy_size']) {
            print_line("<li><font color=red>You cannot fly outside of the galaxy. Try a lower distance (maximum is " . $_GALAXY['galaxy_size'] . ").</font>\n");
        } else {
            $ok = "";
            $errors['PARAMS'] = "Incorrect parameters specified..\n";
            $errors['NAME'] = "The preset name you already used.\n";
            $data['action'] = "create";
            $data['distance'] = $distance;
            $data['angle'] = $angle;
            $data['name'] = $ne_name;
            $data['uid'] = $uid;
            $data['pid'] = 0;
            comm_send_to_server("PRESET", $data, $ok, $errors);
        }
    }
}
// Show command, always executed.
 * @author Gassan Idriss <*****@*****.**>
*/
require_once dirname(__FILE__) . '/functions.php';
if (!isset($argv[1]) || !isset($argv[2])) {
    print_line(PHP_EOL . 'Usage:');
    print_line("\t" . 'php ' . $_SERVER['SCRIPT_NAME'] . ' /path/to/fragment.xml ClassName [/out/dir]');
    print_line("\t" . 'php ' . $_SERVER['SCRIPT_NAME'] . ' "<XML></XML>" ClassName [/out/dir]', true);
}
$sourceXml = $argv[1];
$targetClass = $argv[2];
$targetDir = isset($argv[3]) && is_dir($argv[3]) ? $argv[3] : dirname(__FILE__);
if (!is_dir($targetDir)) {
    print_line(spritnf('Dir %s Not Found', $targetDir), true);
}
if (file_exists($sourceXml)) {
    $xml = new \SimpleXMLElement(file_get_contents($sourceXml));
} else {
    $xml = new \SimpleXMLElement($sourceXml);
}
$setters = '';
$assertions = '';
foreach ($xml->children() as $child) {
    print_line($child->getName());
    $name = $child->getName();
    $camelName = $name;
    $camelName[0] = strtolower($camelName[0]);
    $setters .= generate_setter($name, $camelName);
    $assertions .= generate_assertion($name, $camelName);
}
$template = replace_template(dirname(__FILE__) . '/generate_class_from_xml_fragment_class_template.php.template', array('{name}' => $targetClass, '{setters}' => $setters, '{assertions}' => $assertions, '{expected_xml}' => $xml->saveXML(), '{xml_assertions}' => null));
file_put_contents($targetDir . '/' . $targetClass . 'Test.php', $template);
Exemplo n.º 6
0
        if (!$chunk) {
            continue;
        }
        $tree = $tree . '/' . $chunk;
        array_push($paths, $tree);
    }
    $paths = array_reverse($paths);
    foreach ($paths as $path) {
        if (is_file($path . '/wp-config.php')) {
            define('ABSPATH', $path . '/');
            break;
        }
    }
}
if (!defined('ABSPATH')) {
    print_line("Unable to determine wordpress path. Please set it using WORDPRESS_PATH.");
    die;
}
$_SERVER = array("HTTP_HOST" => "disqus.com", "SCRIPT_NAME" => "", "PHP_SELF" => __FILE__, "SERVER_NAME" => "localhost", "REQUEST_URI" => "/", "REQUEST_METHOD" => "GET");
require_once ABSPATH . 'wp-config.php';
// swap out the object cache due to memory constraints
global $wp_object_cache;
class DummyWP_Object_Cache extends WP_Object_Cache
{
    function set($id, $data, $group = 'default', $expire = '')
    {
        return;
    }
    function delete($id, $group = 'default', $force = false)
    {
        return;
Exemplo n.º 7
0
function print_item($url, $short_name, $long_name, $logo, $level, $type)
{
    $href_start = "";
    $href_end = "";
    $img = "&nbsp;";
    $skip_space = 3;
    global $member, $contrib, $partner;
    global $organization, $individual;
    global $num_members, $num_contribs, $num_partners;
    global $num_organizations, $num_individuals;
    if (!empty($url)) {
        $href_start = "<a href=\"{$url}\">";
        $href_end = "</a>";
    }
    print "<tr>\n";
    # Organization
    $org = "{$href_start}{$short_name}{$href_end}";
    if (!empty($long_name)) {
        $org .= "<br>{$long_name}";
    }
    print "<td>{$org}</td>\n";
    print "<td width={$skip_space}>&nbsp;</td>\n";
    # Type
    print "<td align=\"center\">";
    if ($type == $organization) {
        print "Organization";
        ++$num_organizations;
    } else {
        if ($type == $individual) {
            print "Individual";
            ++$num_individuals;
        }
    }
    print "</td>\n";
    # Status
    print "<td align=\"center\">";
    if ($level == $member) {
        print "Member";
        ++$num_members;
    } else {
        if ($level == $contrib) {
            print "Contributor";
            ++$num_contribs;
        } else {
            if ($level == $partner) {
                print "Partner";
                ++$num_partners;
            }
        }
    }
    print "</td>\n<td width={$skip_space}>&nbsp;</td>\n";
    # Logo
    if (!empty($logo)) {
        $size = GetImageSize($logo);
        print "<td align=center>{$href_start}<img src=\"{$logo}\" {$size['3']} border=\"0\">{$href_end}</td>\n";
    } else {
        print "<td>&nbsp;</td>\n";
    }
    print "</tr>\n\n";
    print_line();
}
function print_orders($sourceid)
{
    /*
    name:
    print_orders($sourceid)
    returns:
    0 - no error
    1 - no orders to be printed
    2 - template parsing error
    3 - error setting orders printed
    other - mysql error number
    */
    $sourceid = $_SESSION['sourceid'];
    debug_msg(__FILE__, __LINE__, "BEGIN PRINTING");
    $query = "SELECT * FROM `orders` WHERE `sourceid`='{$sourceid}' AND `printed` IS NULL AND `suspend`='0' ORDER BY dest_id ASC, priority ASC, associated_id ASC, id ASC";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return mysql_errno();
    }
    if (!mysql_num_rows($res)) {
        return ERR_ORDER_NOT_FOUND;
    }
    $newassociated_id = "";
    $tablenum = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'sources', "name", $sourceid);
    $tpl_print = new template();
    $output['orders'] = '';
    $msg = "";
    while ($arr = mysql_fetch_array($res)) {
        $oldassociated_id = $newassociated_id;
        $newassociated_id = $arr['associated_id'];
        if (isset($priority)) {
            $oldpriority = $priority;
        } else {
            $oldpriority = 0;
        }
        $priority = $arr['priority'];
        if ($oldassociated_id != "") {
            $olddestid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $oldassociated_id));
            $olddest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $olddestid);
            $olddestname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $olddestid);
        } else {
            $olddestid = 0;
        }
        $destid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $newassociated_id));
        $dest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $destid);
        $destname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $destid);
        $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid);
        if ($destid != $olddestid || $priority != $oldpriority) {
            if ($destid != $olddestid && $olddestid != "") {
                $tpl_print->assign("date", printer_print_date());
                $tpl_print->assign("gonow", printer_print_gonow($oldpriority, $dest_language));
                $tpl_print->assign("page_cut", printer_print_cut());
                // strips the last newline that has been put
                $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1);
                if (table_is_takeaway($sourceid)) {
                    $print_tpl_file = 'ticket_takeaway';
                } else {
                    $print_tpl_file = 'ticket';
                }
                if ($err = $tpl_print->set_print_template_file($olddestid, $print_tpl_file)) {
                    return $err;
                }
                if ($err = $tpl_print->parse()) {
                    $msg = "Error in " . __FUNCTION__ . " - ";
                    $msg .= 'error: ' . $err . "\n";
                    echo nl2br($msg) . "\n";
                    error_msg(__FILE__, __LINE__, $msg);
                    return ERR_PARSING_TEMPLATE;
                }
                $tpl_print->restore_curly();
                $msg = $tpl_print->getOutput();
                $tpl_print->reset_vars();
                $output['orders'] = '';
                $msg = str_replace("'", "", $msg);
                if ($outerr = print_line($olddestid, $msg)) {
                    return $outerr;
                }
            } elseif ($priority != $oldpriority && $oldpriority != "") {
                $tpl_print->assign("date", printer_print_date());
                $tpl_print->assign("gonow", printer_print_gonow($oldpriority, $dest_language));
                $tpl_print->assign("page_cut", printer_print_cut());
                // strips the last newline that has been put
                $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1);
                if (table_is_takeaway($sourceid)) {
                    $print_tpl_file = 'ticket_takeaway';
                } else {
                    $print_tpl_file = 'ticket';
                }
                if ($err = $tpl_print->set_print_template_file($destid, $print_tpl_file)) {
                    return $err;
                }
                if ($err = $tpl_print->parse()) {
                    $msg = "Error in " . __FUNCTION__ . " - ";
                    $msg .= 'error: ' . $err . "\n";
                    error_msg(__FILE__, __LINE__, $msg);
                    echo nl2br($msg) . "\n";
                    return ERR_PARSING_TEMPLATE;
                }
                $tpl_print->restore_curly();
                $msg = $tpl_print->getOutput();
                $tpl_print->reset_vars();
                $output['orders'] = '';
                $msg = str_replace("'", "", $msg);
                if ($outerr = print_line($destid, $msg)) {
                    return $outerr;
                }
            }
            if (table_is_takeaway($sourceid)) {
                $takeaway_data = takeaway_get_customer_data($sourceid);
                $output['takeaway'] = ucfirst(lang_get($dest_language, 'PRINTS_TAKEAWAY')) . " - ";
                $output['takeaway'] .= $takeaway_data['takeaway_hour'] . ":" . $takeaway_data['takeaway_minute'] . "\n";
                $output['takeaway'] .= $takeaway_data['takeaway_surname'] . "\n";
                $tpl_print->assign("takeaway", $output['takeaway']);
            }
            $output['table'] = ucfirst(lang_get($dest_language, 'PRINTS_TABLE')) . ": " . $tablenum;
            $tpl_print->assign("table", $output['table']);
            $user = new user($_SESSION['userid']);
            $output['waiter'] = ucfirst(lang_get($dest_language, 'PRINTS_WAITER')) . ": " . $user->data['name'];
            $tpl_print->assign("waiter", $output['waiter']);
            $output['priority'] = ucfirst(lang_get($dest_language, 'PRINTS_PRIORITY')) . ": " . $priority . "\n";
            $tpl_print->assign("priority", $output['priority']);
            $output['people'] = ucfirst(lang_get($dest_language, 'PRINTS_PEOPLE')) . ": " . table_people_number($sourceid) . "\n";
            $tpl_print->assign("people", $output['people']);
            $table = new table($sourceid);
            $table->fetch_data(true);
            if ($cust_id = $table->data['customer']) {
                $cust = new customer($cust_id);
                $output['customer'] = ucfirst(lang_get($dest_language, 'CUSTOMER')) . ": " . $cust->data['surname'] . ' ' . $cust->data['name'];
                $tpl_print->assign("customer_name", $output['customer']);
                $output['customer'] = $cust->data['address'];
                $tpl_print->assign("customer_address", $output['customer']);
                $output['customer'] = $cust->data['zip'];
                $tpl_print->assign("customer_zip_code", $output['customer']);
                $output['customer'] = $cust->data['city'];
                $tpl_print->assign("customer_city", $output['customer']);
                $output['customer'] = ucfirst(lang_get($dest_language, 'VAT_ACCOUNT')) . ": " . $cust->data['vat_account'];
                $tpl_print->assign("customer_vat_account", $output['customer']);
            }
        }
        $output['orders'] .= printer_print_row($arr, $destid);
        $printed_orders[] = $arr['id'];
        if ($newassociated_id != $oldassociated_id) {
            // if we're in this function, it means that we changed associated_id id
            // and also that mods have been printed on the same sheet
            if (CONF_PRINT_BARCODES && $arr['dishid'] != MOD_ID) {
                $output['orders'] .= print_barcode($newassociated_id);
            }
        }
        if (CONF_PRINT_BARCODES && $arr['dishid'] != MOD_ID) {
            $output['orders'] .= print_barcode($newassociated_id);
        }
        $tpl_print->assign("orders", $output['orders']);
    }
    $destid = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dishes', "destid", get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'orders', 'dishid', $newassociated_id));
    $dest = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "dest", $destid);
    $destname = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "name", $destid);
    $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid);
    if (CONF_PRINT_BARCODES) {
        $tpl_print->assign("barcode", print_barcode($newassociated_id));
    }
    $tpl_print->assign("date", printer_print_date());
    $tpl_print->assign("gonow", printer_print_gonow($priority, $dest_language));
    $tpl_print->assign("page_cut", printer_print_cut());
    // strips the last newline that has been put
    $output['orders'] = substr($output['orders'], 0, strlen($output['orders']) - 1);
    if (table_is_takeaway($sourceid)) {
        $print_tpl_file = 'ticket_takeaway';
    } else {
        $print_tpl_file = 'ticket';
    }
    if ($err = $tpl_print->set_print_template_file($destid, $print_tpl_file)) {
        return $err;
    }
    if ($err = $tpl_print->parse()) {
        $err_msg = "Error in " . __FUNCTION__ . " - ";
        $err_msg .= 'error: ' . $err . "\n";
        error_msg(__FILE__, __LINE__, $err_msg);
        echo nl2br($err_msg) . "\n";
        return ERR_PARSING_TEMPLATE;
    }
    $tpl_print->restore_curly();
    $msg = $tpl_print->getOutput();
    $tpl_print->reset_vars();
    $output['orders'] = '';
    $msg = str_replace("'", "", $msg);
    if ($outerr = print_line($destid, $msg)) {
        return $outerr;
    }
    foreach ($printed_orders as $val) {
        if ($err = print_set_printed($val)) {
            return $err;
        }
    }
    // there was an error setting orders as printed
    if ($err) {
        return ERR_ORDER_NOT_SET_AS_PRINTED;
    }
    return 0;
}
Exemplo n.º 9
0
/**
	print out the key value pairs from the supplied has as HTML
	@param hash $hash a hash (sic)
	@return NULL
*/
function print_hash($hash)
{
    foreach ($hash as $key => $value) {
        echo $key . ": " . $value . '<br>';
    }
}
/**
	print out line of text with a label, to be used between PRE tags
	@param string $label a descriptive label or title
	@param string $line the text to display
	@return NULL
*/
function print_line($label, $line)
{
    echo $label . ": " . $line . "\n";
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>BaseElements Plug-In HTTP Test Helper</title>
</head>
<body>
<?php 
Exemplo n.º 10
0
<?php

// Include Files
include "../includes.inc.php";
// Session Identification
session_identification("admin");
print_header();
print_title("Tick Scheme");
$ticks = calc_sector_ticks($_GALAXY['galaxy_size'], 0, $_GALAXY['galaxy_size'], 180, 99);
print_line("Crossing ticks at warp 9.9: {$ticks}");
$ticks = calc_sector_ticks($_GALAXY['galaxy_size'], 0, $_GALAXY['galaxy_size'], 180, 50);
print_line("Crossing ticks at warp 5.0: {$ticks}");
$ticks = calc_sector_ticks($_GALAXY['galaxy_size'], 0, $_GALAXY['galaxy_size'], 180, 10);
print_line("Crossing ticks at warp 1.0: {$ticks}");
warp_scheme(99);
warp_scheme(50);
warp_scheme(10);
print_footer();
exit;
function warp_scheme($warp)
{
    $result = sql_query("SELECT COUNT(*) AS nr FROM s_sectors");
    $tmp = sql_fetchrow($result);
    $count = $tmp['nr'];
    if ($count > 30) {
        $count = 30;
        echo "WARNING: Only the first 30 sectors are viewed now!!!<br>\n";
    }
    $result = sql_query("SELECT * FROM s_sectors");
    print "<table align=center border=1>";
    print "  <tr><th colspan=" . ($count + 1) . ">Warp Factor " . $warp . "</th></tr>";
Exemplo n.º 11
0
<?php

// Include Files
include "includes.inc.php";
// Session Identification
session_identification();
print_header();
print_title("Vessel upgrade");
// can we build ships already?
$user = user_get_user($_USER['id']);
if ($user['impulse'] == 0) {
    print_line("You cannot build ships yet");
    print_footer();
    exit;
}
// Get a ship if we didn't select one
if (!isset($_GET['vid'])) {
    choose_vessel($_USER['id']);
    print_footer();
    exit;
}
$vid = decrypt_get_vars($_GET['vid']);
// Go to the first stage if no stage is selected
if (isset($_GET['stage'])) {
    $stage = decrypt_get_vars($_GET['stage']);
} else {
    $stage = 1;
}
// Do upgrade (depending on stage)
if ($stage == 1) {
    upgrade_speed($_USER, $vid);
Exemplo n.º 12
0
function show_constructions($anomaly_id)
{
    assert(is_numeric($anomaly_id));
    // Get global information stuff
    $planet = anomaly_get_anomaly($anomaly_id);
    $user = user_get_user($planet['user_id']);
    // And get the ores from the planet
    $result = sql_query("SELECT * FROM g_ores WHERE planet_id=" . $anomaly_id);
    $ores = sql_fetchrow($result);
    // Get all buildings that are currently build on the planet
    $surface = planet_get_surface($anomaly_id);
    $current_buildings = csl($surface['csl_building_id']);
    // If we've got an headquarter and it's inactive, we cannot build anything.. :(
    if (in_array(BUILDING_HEADQUARTER_INACTIVE, $current_buildings)) {
        print_line("Your headquarter is currently inactive due to insufficent resources for its upkeep. You cannot build anything on this planet until you replenish your resources.");
        $cannot_build = true;
        return;
    }
    print_subtitle("Construction on planet " . $planet['name']);
    // And get all buildings, compare wether or not we may build them...
    $result = sql_query("SELECT * FROM s_buildings ORDER BY id");
    while ($building = sql_fetchrow($result)) {
        // Default, we can build this
        $cannot_build = false;
        // Stage -1: Check planet class when we want to build a headquarter
        if ($building['id'] == BUILDING_HEADQUARTER) {
            if (!planet_is_habitable($anomaly_id)) {
                $cannot_build = true;
            }
        }
        // Stage 0: Check building_level
        if ($building['build_level'] > $user['building_level']) {
            $cannot_build = true;
        }
        // Stage 1: Building Count Check
        // Build counter check
        if ($building['max'] > 0) {
            $times_already_build = 0;
            for ($i = 0; $i != count($current_buildings); $i++) {
                if (building_active_or_inactive($current_buildings[$i]) == $building['id']) {
                    $times_already_build++;
                }
            }
            // Cannot build cause we already have MAX buildings of this kind.. :(
            // building['max'] = 0 means unlimited buildings...
            if ($times_already_build == $building['max']) {
                $cannot_build = true;
            }
        }
        // Stage 2: Dependency Check
        // Get all dependencies
        $buildings_needed = csl($building['csl_depends']);
        // Do we need them? If not, skip dependency-check.
        if (!empty($building['csl_depends'])) {
            $deps_found = count($buildings_needed);
            // Count to zero...
            while (list($key, $building_dep_id) = each($buildings_needed)) {
                if ($building_dep_id == "") {
                    $deps_found--;
                    continue;
                }
                // Get all dependencies
                if (in_array($building_dep_id, $current_buildings)) {
                    $deps_found--;
                    // Found in current_buildings?
                    // Decrease counter
                }
            }
        } else {
            // No need for deps
            $deps_found = 0;
            // Zero is good...
        }
        // Not all dependencies found, we cannot build it.. :(
        if ($deps_found > 0) {
            $cannot_build = true;
        }
        // Stage 3: Show building if we can build it..
        if ($cannot_build == false) {
            building_show_details($building['id'], $planet['id'], $user['user_id'], $ores['stock_ores']);
        }
    }
}
    if (!file_exists($testsDir . DIRECTORY_SEPARATOR . $testFileName)) {
        $missingTests[] = $testFileName;
    }
}
foreach ($testsDirFiles as $testsDirFile) {
    $filename = @end(explode('/', $testsDirFile));
    $fragFileName = str_replace('Test.php', '.php', $filename);
    if (!file_exists($srcDir . DIRECTORY_SEPARATOR . $fragFileName)) {
        $testsWithoutFragments[] = $fragFileName;
    }
}
array_walk($missingTests, function ($v, $k) {
    global $createMissingTests, $deleteTestsWithoutFragments, $srcDir, $testsDir;
    print_line('Missing Test: ' . $v);
    if (true === $createMissingTests) {
        print_line('Created Missing Test: ' . $v);
        file_put_contents($testsDir . DIRECTORY_SEPARATOR . $v, '');
    }
});
array_walk($testsWithoutFragments, function ($v, $k) {
    global $createMissingTests, $deleteTestsWithoutFragments, $srcDir, $testsDir;
    print_line('Test Missing Fragment: ' . $v);
    if (true === $deleteTestsWithoutFragments) {
        print_line('Removed Test Without Fragment: ' . $v);
        @unlink($testsDir . DIRECTORY_SEPARATOR . $v);
    }
});
/*
print_r($testsWithoutFragments);

print_r($missingTests);*/
Exemplo n.º 14
0
function passtrough($url)
{
    assert(!empty($url));
    print_header("<meta http-equiv=\"refresh\" CONTENT=\"1; URL={$url}\">");
    print_subtitle("<b>Loading...</b>");
    print_line("<a href=\"{$url}\">Click here if you are not being redirected...</a>");
    print_footer();
}
Exemplo n.º 15
0
			<table BORDER=0 BGCOLOR=white>
			<font size=-1>
			<tr bgcolor=black>
			    <th width=80><a class=tooltip href="#"><font color=white><center><b>Callsign</b></center></font><span><b>Callsign of the DD-mode user</b></span></a></th>
			    <th width=80><a class=tooltip href="#"><font color=white><center><b>IP Address</b></center></font><span><b>Dynamic IP address of the DD-Mode user</b></span></a></th>
			    <th width=130><a class=tooltip href="#"><font color=white><center><b>Start Time (UTC)</b></center></font><span><b>Start time of DHCP lease</b>(UTC)</span></a></th>
			    <th width=130><a class=tooltip href="#"><font color=white><center><b>End Time (UTC)</b></center></font><span><b>End time of DHCP Lease</b>Expire time of DHCP lease (UTC)</span></a></th>
			    <th width=130><a class=tooltip href="#"><font color=white><center><b>MAC</b></center></font><span><b>MAC address of device</b>vendor information</span></a></th>
			    <th width=80><a class=tooltip href="#"><font color=white><center><b>Lease State</b></center></font><span><b>State of DHCP Lease</b></span></a></th>
			</tr>

			<?php 
                    $ci = 0;
                    for ($line = count($dhcptable) - 1; $line >= 0; $line--) {
                        $ci++;
                        if ($ci > 1) {
                            $ci = 0;
                        }
                        print "<tr bgcolor=\"{$col[$ci]}\">";
                        print_line($dhcptable[$line]);
                        print "</tr>";
                    }
                    fclose($open_file);
                    echo "</table>";
                }
            } else {
                echo "<p class='error'>The DHCP leases file does not exist or does not have sufficient read privileges.</p>";
            }
        }
    }
}
Exemplo n.º 16
0
function bill_print()
{
    /*
    name:
    bill_print()
    returns:
    0 - no error
    1 - Printer not found for output tyoe
    2 - No order selected
    3 - Printing error
    other - mysql error number
    */
    // type: 	0: reserved
    //			1: bill
    //			2. invoice
    //			3. receipt
    //	we have to translate them to the mgmt_type values in order to be correctely
    //	written and read in the log
    //	mgmt_type:	3: invoice
    //				4: bill
    //				5: receipt
    global $tpl;
    global $output_page;
    $output['orders'] = '';
    $output_page = '';
    //connect to printer by client IP
    $clientip = "";
    if (isset($clientip)) {
        unset($clientip);
    }
    $clientip = getenv('REMOTE_ADDR');
    //end:connect to printer by client IP
    if ($_SESSION['bill_printed']) {
        return 0;
    }
    $_SESSION['bill_printed'] = 1;
    $type = $_SESSION['type'];
    $keep_separated = bill_check_keep_separated();
    $type = receipt_type_waiter2mgmt($type);
    // CRYPTO
    if (!bill_check_empty()) {
        $receipt_id = receipt_insert($_SESSION['account'], $type);
    }
    $printing_enabled = $arr['print_bill'];
    $tpl_print = new template();
    switch ($_SESSION['type']) {
        case 1:
            $query = "SELECT * FROM `dests` WHERE `bill`='1' AND `deleted`='0'";
            $template_type = 'bill';
            break;
        case 2:
            $query = "SELECT * FROM `dests` WHERE `invoice`='1' AND `deleted`='0'";
            $template_type = 'invoice';
            break;
        case 3:
            $query = "SELECT * FROM `dests` WHERE `receipt`='1' AND `deleted`='0'";
            $template_type = 'receipt';
            break;
        default:
            $query = "SELECT * FROM `dests` WHERE `bill`='1' AND `deleted`='0'";
            $template_type = 'bill';
    }
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return ERR_MYSQL;
    }
    //connect to printer by client IP
    while ($row = mysql_fetch_array($res)) {
        if ($row['dest_ip'] == '') {
            if ($row['dest'] != '') {
                $destid = $row['id'];
                $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid);
            } else {
                return ERR_PRINTER_NOT_FOUND_FOR_SELECTED_TYPE;
            }
        } elseif ($row['dest'] != '' && $row['dest_ip'] != '') {
            $ippart = explode("|", $row['dest_ip']);
            if (in_array($clientip, $ippart)) {
                $destid = $row['id'];
                break;
            }
            $dest_language = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'dests', "language", $destid);
        } else {
            return ERR_PRINTER_NOT_FOUND_FOR_SELECTED_TYPE;
        }
    }
    if ($err = $tpl_print->set_print_template_file($destid, $template_type)) {
        return $err;
    }
    // reset the counter and the message to be sent to the printer
    $total = 0;
    $msg = "";
    $tablenum = get_db_data(__FILE__, __LINE__, $_SESSION['common_db'], 'sources', "name", $_SESSION['sourceid']);
    $output['table'] = ucfirst(lang_get($dest_language, 'PRINTS_TABLE')) . " {$tablenum} \n";
    $tpl_print->assign("table", $output['table']);
    // writes the table num to video
    $output_page .= ucfirst(phr('TABLE_NUMBER')) . ": {$tablenum}     ";
    $table = new table($_SESSION['sourceid']);
    $table->fetch_data(true);
    if ($cust_id = $table->data['customer']) {
        $cust = new customer($cust_id);
        $output['customer'] = ucfirst(lang_get($dest_language, 'CUSTOMER')) . ": " . $cust->data['surname'] . ' ' . $cust->data['name'];
        $tpl_print->assign("customer_name", $output['customer']);
        $output['customer'] = $cust->data['address'];
        $tpl_print->assign("customer_address", $output['customer']);
        $output['customer'] = $cust->data['zip'];
        $tpl_print->assign("customer_zip_code", $output['customer']);
        $output['customer'] = $cust->data['city'];
        $tpl_print->assign("customer_city", $output['customer']);
        $output['customer'] = ucfirst(lang_get($dest_language, 'VAT_ACCOUNT')) . ": " . $cust->data['vat_account'];
        $tpl_print->assign("customer_vat_account", $output['customer']);
    }
    if (bill_check_empty()) {
        return ERR_NO_ORDER_SELECTED;
    }
    //mizuko : swap qty with name
    $output_page .= "<table bgcolor=\"" . COLOR_TABLE_GENERAL . "\">\r\n\t<thead>\r\n\t<tr>\r\n\t<th scope=col>" . ucfirst(phr('NAME')) . "</th>\r\n\t<th scope=col>" . ucfirst(phr('QUANTITY_ABBR')) . "</th>\r\n\t<th scope=col>" . ucfirst(phr('PRICE')) . "</th>\r\n\t</tr>\r\n\t</thead>\r\n\t<tbody>";
    $class = COLOR_ORDER_PRINTED;
    ksort($_SESSION['separated']);
    // the next for prints the list and the chosen dishes
    for (reset($_SESSION['separated']); list($key, $value) = each($_SESSION['separated']);) {
        $output['orders'] .= bill_print_row($key, $value, $destid);
    }
    $tpl_print->assign("orders", $output['orders']);
    if ($_SESSION['discount']['type'] == "amount" || $_SESSION['discount']['type'] == "percent") {
        $output['discount'] = bill_print_discount($receipt_id, $destid);
        $tpl_print->assign("discount", $output['discount']);
    }
    $total = bill_calc_vat();
    $total_discounted = bill_calc_discount($total);
    // updates the receipt value, has to be before print totals!
    receipt_update_amounts($_SESSION['account'], $total_discounted, $receipt_id);
    $output['total'] = bill_print_total($receipt_id, $destid);
    $tpl_print->assign("total", $output['total']);
    if (SHOW_CHANGE == 1) {
        $output['change'] = bill_print_change($total_discounted['total']);
        $tpl_print->assign("change", $output['change']);
    }
    //mizuko
    $user = new user($_SESSION['userid']);
    $output['waiter'] = ucfirst(lang_get($dest_language, 'PRINTS_WAITER')) . ": " . $user->data['name'];
    $tpl_print->assign("waiter", $output['waiter']);
    $tpl_print->assign("date", printer_print_date());
    //end mizuko
    $output_page .= "\r\n\t</tbody>\r\n\t</table>";
    $output['receipt_id'] = bill_print_receipt_id($receipt_id, $destid);
    $tpl_print->assign("receipt_id", $output['receipt_id']);
    $output['taxes'] = bill_print_taxes($receipt_id, $destid);
    $tpl_print->assign("taxes", $output['taxes']);
    if ($err = $tpl_print->parse()) {
        $msg = "Error in " . __FUNCTION__ . " - ";
        $msg .= 'error: ' . $err . "\n";
        error_msg(__FILE__, __LINE__, $msg);
        echo nl2br($msg) . "\n";
        return ERR_PARSING_TEMPLATE;
    }
    $tpl_print->restore_curly();
    $msg = $tpl_print->getOutput();
    $msg = str_replace("'", "", $msg);
    if ($printing_enabled) {
        if ($err = print_line($arr['id'], $msg)) {
            // the process is stopped so we delete the created receipt
            receipt_delete($_SESSION['account'], $receipt_id);
            return $err;
        }
    }
    ksort($_SESSION['separated']);
    // sets the log
    for (reset($_SESSION['separated']); list($key, $value) = each($_SESSION['separated']);) {
        if ($err_logger = bill_logger($key, $receipt_id)) {
            debug_msg(__FILE__, __LINE__, __FUNCTION__ . ' - receipt_id: ' . $receipt_id . ' - logger return code: ' . $err_logger);
        } else {
            debug_msg(__FILE__, __LINE__, __FUNCTION__ . ' - receipt_id: ' . $receipt_id . ' - logged');
        }
    }
    return 0;
}
function perihelion_die($title, $line)
{
    global $_CONFIG;
    print_header();
    print_title($title);
    print_line($line);
    print_line("<img src=" . $_CONFIG['IMAGE_URL'] . "/backgrounds/perihelion-small.jpg>");
    print_footer();
    exit;
}
Exemplo n.º 18
0
        $ne_science_ratio = $user['science_ratio'];
    }
    if ($ne_building_rate == "") {
        $ne_building_rate = $user['science_building'];
    }
    if ($ne_vessel_rate == "") {
        $ne_vessel_rate = $user['science_vessel'];
    }
    if ($ne_invention_rate == "") {
        $ne_invention_rate = $user['science_invention'];
    }
    if ($ne_explore_rate == "") {
        $ne_explore_rate = $user['science_explore'];
    }
    if ($ne_building_rate + $ne_vessel_rate + $ne_invention_rate + $ne_explore_rate != 100) {
        print_line("<font color=red><center><strong>Warning:</strong><br>Your percentage settings must be equal to 100%!<br>New rating is not set!</center></font>");
    } else {
        $ok = "";
        $errors['PARAMS'] = "Incorrect parameters specified..\n";
        $errors['100'] = "The rating must add to 100%\n";
        $data['id'] = user_ourself();
        $data['ratio'] = $ne_science_ratio;
        $data['invention'] = $ne_invention_rate;
        $data['building'] = $ne_building_rate;
        $data['vessel'] = $ne_vessel_rate;
        $data['explore'] = $ne_explore_rate;
        comm_send_to_server("SCIENCE", $data, $ok, $errors);
    }
}
// Show user info
if ($uid == "") {
<?php

/**
 * Defining and calling functions with optional arguments
 */
function print_line($output, $suffix = PHP_EOL, $prefix = '')
{
    echo $prefix . $output . $suffix;
}
// Will print "Hello<br />"
print_line("Hello", "<br />");
// Will print "Hello\n"
print_line("Hello");
// Will print "<li>Hello</li>"
print_line("Hello", "</li>", "<li>");
Exemplo n.º 20
0
function convert_query($string, $return_error = false)
{
    global $convert_dbs, $to_prefix, $command_line, $smcFunc;
    // Debugging?
    if (isset($_REQUEST['debug'])) {
        $_SESSION['convert_debug'] = !empty($_REQUEST['debug']);
    }
    if (trim($string) == 'TRUNCATE ' . $GLOBALS['to_prefix'] . 'attachments') {
        removeAllAttachments();
    }
    if ($convert_dbs != 'smf_db') {
        $clean = '';
        $old_pos = 0;
        $pos = -1;
        while (true) {
            $pos = strpos($string, '\'', $pos + 1);
            if ($pos === false) {
                break;
            }
            $clean .= substr($string, $old_pos, $pos - $old_pos);
            while (true) {
                $pos1 = strpos($string, '\'', $pos + 1);
                $pos2 = strpos($string, '\\', $pos + 1);
                if ($pos1 === false) {
                    break;
                } elseif ($pos2 == false || $pos2 > $pos1) {
                    $pos = $pos1;
                    break;
                }
                $pos = $pos2 + 1;
            }
            $clean .= '%s';
            $old_pos = $pos + 1;
        }
        $clean .= substr($string, $old_pos);
        $clean = trim(preg_replace('~\\s+~s', ' ', $clean));
        if (strpos($string, $to_prefix) === false) {
            preg_match('~limit (\\d+)(?:, (\\d+))?\\s*$~is', $string, $limit);
            if (!empty($limit)) {
                $string = preg_replace('~limit (\\d+)(?:, (\\d+))?$~is', '', $string);
                if (!isset($limit[2])) {
                    $limit[2] = $limit[1];
                    $limit[1] = 0;
                }
            }
            if ($convert_dbs == 'odbc') {
                if (!empty($limit)) {
                    $string = preg_replace('~^\\s*select~is', 'SELECT TOP ' . ($limit[1] + $limit[2]), $string);
                }
                $result = @odbc_exec($GLOBALS['odbc_connection'], $string);
                if (!empty($limit) && !empty($limit[1])) {
                    odbc_fetch_row($result, $limit[1]);
                }
            } elseif ($convert_dbs == 'ado') {
                if (!empty($limit)) {
                    $string = preg_replace('~^\\s*select~is', 'SELECT TOP ' . ($limit[1] + $limit[2]), $string);
                }
                if (PHP_VERSION >= 5) {
                    eval('
						try
						{
							$result = $GLOBALS[\'ado_connection\']->Execute($string);
						}
						catch (com_exception $err)
						{
							$result = false;
						}');
                } else {
                    $result = @$GLOBALS['ado_connection']->Execute($string);
                }
                if ($result !== false && !empty($limit) && !empty($limit[1])) {
                    $result->Move($limit[1], 1);
                }
            }
            $not_smf_dbs = true;
        } else {
            $result = $smcFunc['db_query']('', $string, array('overide_security' => true, 'db_error_skip' => true));
        }
    } else {
        $result = $smcFunc['db_query']('', $string, array('overide_security' => true, 'db_error_skip' => true));
    }
    if ($result !== false || $return_error) {
        return $result;
    }
    if (empty($not_smf_dbs)) {
        $db_error = $smcFunc['db_error']();
        $db_errno = $smcFunc['db_title'] == 'MySQL' ? mysql_errno() : ($smcFunc['db_title'] == 'SQLite' ? sqlite_last_error() : ($smcFunc['db_title'] == 'PostgreSQL' ? pg_last_error() : $smcFunc['db_error']()));
        // FIrst log it.
        // In the future this may return the actual file it came from.
        if (isset($_GET['debug']) || isset($_POST['debug'])) {
            convert_error_hanlder($db_error, $string, 'Converter File', $db_errno, true);
        }
        // Error numbers:
        //    1016: Can't open file '....MYI'
        //    2013: Lost connection to server during query.
        if (trim($db_errno) == 1016) {
            if (preg_match('~(?:\'([^\\.\']+)~', $db_error, $match) != 0 && !empty($match[1])) {
                $smcFunc['db_query']('', "\n\t\t\t\t\tREPAIR TABLE {$match['1']}", 'security_override');
            }
            $result = $smcFunc['db_query']('', $string, 'security_override');
            if ($result !== false) {
                return $result;
            }
        } elseif (trim($db_errno) == 2013) {
            $result = $smcFunc['db_query']('', $string, 'security_override');
            if ($result !== false) {
                return $result;
            }
        }
        // Attempt to allow big selects, only for mysql so far though.
        if ($smcFunc['db_title'] == 'MySQL' && (trim($db_errno) == 1104 || strpos($db_error, 'use SET SQL_BIG_SELECTS=1') !== false)) {
            $results = $smcFunc['db_query']('', "SELECT @@SQL_BIG_SELECTS, @SQL_MAX_JOIN_SIZE", 'security_override');
            list($big_selects, $sql_max_join) = $smcFunc['db_fetch_row']($results);
            // Only waste a query if its worth it.
            if (empty($big_selects) || $big_selects != 1 && $big_selects != '1') {
                $smcFunc['db_query']('', "SET @@SQL_BIG_SELECTS = 1", 'security_override');
            }
            // Lets set MAX_JOIN_SIZE to something we should
            if (empty($sql_max_join) || $sql_max_join == '18446744073709551615' && sql_max_join == '18446744073709551615') {
                $smcFunc['db_query']('', "SET @@SQL_MAX_JOIN_SIZE = 18446744073709551615", 'security_override');
            }
            // Try again.
            $result = $smcFunc['db_query']('', $string, 'security_override');
            if ($result !== false) {
                return $result;
            }
        }
    } elseif ($convert_dbs == 'odbc') {
        $db_error = odbc_errormsg($GLOBALS['odbc_connection']);
    } elseif ($convert_dbs == 'ado') {
        $error = $GLOBALS['ado_connection']->Errors[0];
        $db_error = $error->Description;
    }
    // Get the query string so we pass everything.
    if (isset($_REQUEST['start'])) {
        $_GET['start'] = $_REQUEST['start'];
    }
    $query_string = '';
    foreach ($_GET as $k => $v) {
        $query_string .= '&' . $k . '=' . $v;
    }
    if (strlen($query_string) != 0) {
        $query_string = '?' . strtr(substr($query_string, 1), array('&' => '&amp;'));
    }
    if ($command_line) {
        print_line("Unsuccessful! Database error message:\n" . $db_error);
        die;
    }
    echo '
			<strong>Unsuccessful!</strong><br />

			This query:<blockquote>' . nl2br(htmlspecialchars(trim($string))) . ';</blockquote>

			Caused the error:<br />
			<blockquote>' . nl2br(htmlspecialchars($db_error)) . '</blockquote>

			<form action="', $_SERVER['PHP_SELF'], $query_string, '" method="post">
				<input type="submit" value="Try again" class="button_submit" />
			</form>
		</div>';
    template_convert_below();
    die;
}
Exemplo n.º 21
0
function print_separator()
{
    print_new_line();
    print_line(is_cli() ? '-------------------------' : '<hr>');
    print_new_line();
}
Exemplo n.º 22
0
 public static function invoke($_conf = array())
 {
     try {
         Browser::time("invoked");
         $global_config = array_merge(array('CONTROLLER' => 'web.php', 'DEFAULT_DB' => 'DB1', 'CONSOLE_FUN' => 'console.log', 'RX_MODE_DEBUG' => FALSE, 'PROJECT_ROOT_DIR' => "./"), $_conf);
         // Loads all the Constants
         define('PROJECT_ROOT_DIR', $global_config['PROJECT_ROOT_DIR']);
         define('PROJECT_ID', md5(PROJECT_ROOT_DIR . $global_config['CONTROLLER']));
         FileUtil::$PROJECT_ROOT_DIR = PROJECT_ROOT_DIR;
         include_once 'constants.php';
         ob_start();
         session_start();
         Config::load(PROJECT_ROOT_DIR . "app/meta/project.properties", PROJECT_ROOT_DIR . "config/project.properties", $global_config);
         // Initialze Rudrax
         self::init();
         Browser::time("After Init");
         $config = Config::getSection("GLOBAL");
         $db_connect = false;
         Browser::time("Before DB Connect");
         /**
          * NOTE:- NO need to connect DB automatically, it should be connecte donly when required;
          */
         // if (isset ( $config ["DEFAULT_DB"] )) {
         // $RDb = self::getDB ( $config ["DEFAULT_DB"] );
         // $db_connect = true;
         // }
         Browser::time("Before-First Reload");
         // Define Custom Request Plugs
         if (FIRST_RELOAD) {
             ClassUtil::scan();
         }
         self::findAndExecuteController();
         self::invokeController();
         return null;
         Browser::time("Before Saving");
         Config::save();
         Browser::time("Invoked:Ends");
     } catch (Exception $e) {
         print_line($e->getMessage());
         print_line($e->getTraceAsString());
     }
 }
Exemplo n.º 23
0
/**
 * Shortcut for getting user input and checking against regex pattern provided.
 */
function get_input($prompt, $pattern = NULL, $allow_empty = FALSE)
{
    $response = NULL;
    while (!$response) {
        print $prompt . " ";
        $handle = fopen("php://stdin", "r");
        $line = trim(fgets($handle));
        if ($pattern) {
            preg_match($pattern, $line, $matches, PREG_OFFSET_CAPTURE);
            if ($matches[0]) {
                $response = $line;
                if ($allow_empty) {
                    break;
                    // if empty is allowed and found, short-circuit loop
                }
            } else {
                print_line('[ERROR] Response not valid.');
            }
        } else {
            $response = $line;
        }
    }
    return $response;
}
Exemplo n.º 24
0
{
    foreach ($hash as $key => $value) {
        echo format_key_value_pair($key, $value) . '<br>';
    }
}
/**
	print out line of text with a label, to be used between PRE tags
	@param string $label a descriptive label or title
	@param string $line the text to display
	@return NULL
*/
function print_line($label, $line)
{
    echo format_key_value_pair($label, $line) . "\n";
}
/**
	extract an element from an array without generating e_notice 'errors'
	when the key is not set
	@param array $array the array to access
	@param string $key the array element to retrieve
	@return string the value for the key or an empty string when the key is not set
*/
function value_for_key($array, $key)
{
    $value = '';
    if (isset($array[$key])) {
        $value = $array[$key];
    }
    return $value;
}
?>
Exemplo n.º 25
0
 function make_printable($result, $i = 0)
 {
     global $oids, $str;
     if (isset($result['headerlength'])) {
         $length = $result['length'] - $result['headerlength'];
     } else {
         $length = 'inf';
         $result['headerlength'] = 2;
     }
     if (isset($result['constant'])) {
         $constructed = is_array($result['content'][0]);
         print_line($result['start'], $i, $length, $result['headerlength'], $constructed, 'cont [ ' . $result['constant'] . ' ]');
         if ($constructed) {
             foreach ($result['content'] as $content) {
                 make_printable($content, $i + 1);
             }
         }
         return;
     }
     switch ($result['type']) {
         case FILE_ASN1_TYPE_SEQUENCE:
         case FILE_ASN1_TYPE_SET:
             $type = $result['type'] == FILE_ASN1_TYPE_SEQUENCE ? 'SEQUENCE' : 'SET';
             print_line($result['start'], $i, $length, $result['headerlength'], true, $type);
             for ($j = 0; $j < count($result['content']); $j++) {
                 make_printable($result['content'][$j], $i + 1);
             }
             break;
         case FILE_ASN1_TYPE_INTEGER:
             $value = $result['content']->toHex(true);
             if (empty($value)) {
                 $value = '00';
             }
             print_line($result['start'], $i, $length, $result['headerlength'], false, 'INTEGER', strtoupper($value));
             break;
         case FILE_ASN1_TYPE_OBJECT_IDENTIFIER:
             $oid = isset($oids[$result['content']]) ? $oids[$result['content']] : $result['content'];
             print_line($result['start'], $i, $length, $result['headerlength'], false, 'OBJECT', $oid);
             break;
         case FILE_ASN1_TYPE_BIT_STRING:
             print_line($result['start'], $i, $length, $result['headerlength'], false, 'BIT STRING');
             break;
         case FILE_ASN1_TYPE_BOOLEAN:
             print_line($result['start'], $i, $length, $result['headerlength'], false, 'BOOLEAN', ord(substr($str, $result['start'] + $result['headerlength'], $result['length'] - $result['headerlength'])));
             break;
         case FILE_ASN1_TYPE_OCTET_STRING:
             print_line($result['start'], $i, $length, $result['headerlength'], false, 'OCTET STRING');
             /*if (is_array($result['content'])) {
                   for ($j = 0; $j < count($result['content']); $j++) {
                       make_printable($result['content'][$j], $i + 1);
                   }
               }*/
             break;
         case FILE_ASN1_TYPE_NULL:
             print_line($result['start'], $i, $length, $result['headerlength'], false, 'NULL');
             break;
         case FILE_ASN1_TYPE_NUMERIC_STRING:
             $type = 'NUMERICSTRING';
         case FILE_ASN1_TYPE_PRINTABLE_STRING:
             if (!isset($type)) {
                 $type = 'PRINTABLESTRING';
             }
         case FILE_ASN1_TYPE_TELETEX_STRING:
             if (!isset($type)) {
                 $type = 'T61STRING';
             }
         case FILE_ASN1_TYPE_VIDEOTEX_STRING:
             if (!isset($type)) {
                 $type = 'VIDEOTEXSTRING';
             }
         case FILE_ASN1_TYPE_VISIBLE_STRING:
             if (!isset($type)) {
                 $type = 'VISIBLESTRING';
             }
         case FILE_ASN1_TYPE_IA5_STRING:
             if (!isset($type)) {
                 $type = 'IA5STRING';
             }
         case FILE_ASN1_TYPE_GRAPHIC_STRING:
             if (!isset($type)) {
                 $type = 'GRAPHICSTRING';
             }
         case FILE_ASN1_TYPE_GENERAL_STRING:
             if (!isset($type)) {
                 $type = 'GENERALSTRING';
             }
         case FILE_ASN1_TYPE_UTF8_STRING:
             if (!isset($type)) {
                 $type = 'UTF8STRING';
             }
         case FILE_ASN1_TYPE_BMP_STRING:
             if (!isset($type)) {
                 $type = 'BMPSTRING';
             }
             print_line($result['start'], $i, $length, $result['headerlength'], false, $type, $result['content']);
             break;
         case FILE_ASN1_TYPE_GENERALIZED_TIME:
         case FILE_ASN1_TYPE_UTC_TIME:
             $type = $result['type'] == FILE_ASN1_TYPE_GENERALIZED_TIME ? 'GENERALIZEDTIME' : 'UTCTIME';
             print_line($result['start'], $i, $length, $result['headerlength'], false, $type, substr($str, $result['start'] + $result['headerlength'], $result['length'] - $result['headerlength']));
     }
 }
Exemplo n.º 26
0
{
    // we build up a string, then log it, as multiple calls to error_log() are not guaranteed to be contiguous
    $log = "\n\n[********************LinkedIn API Diagnostics**************************]\n\n";
    if (!is_null($exception)) {
        $log .= "|-> " . $exception->getMessage() . " <-|";
        $debugInfo = $exception->debugInfo;
    } else {
        $debugInfo = $oauth->debugInfo;
    }
    $log .= "\n|-> " . API_CONSUMER_KEY . " <-|";
    $log .= "\n|-> " . $debugInfo["sbs"] . " <-|";
    $log .= "\n\n[*****Sent*****]\n";
    $log .= "\n|-> " . str_replace(array("\r\n", "\r", "\n"), array("\\[rn]", "\\[r]", "\\[n]"), $debugInfo["headers_sent"]) . " <-|";
    $log .= "\n|-> " . str_replace(array("\r\n", "\r", "\n"), array("\\[rn]", "\\[r]", "\\[n]"), $debugInfo["body_sent"]) . " <-|";
    $log .= "\n\n[*****Received*****]\n";
    $log .= "\n|-> " . str_replace(array("\r\n", "\r", "\n"), array("\\[rn]", "\\[r]", "\\[n]"), $debugInfo["headers_recv"]) . " <-|";
    $log .= "\n|-> " . str_replace(array("\r\n", "\r", "\n"), array("\\[rn]", "\\[r]", "\\[n]"), $debugInfo["body_recv"]) . " <-|";
    $log .= "\n\n[******************End LinkedIn API Diagnostics************************]\n\n";
    error_log($log);
}
// Now demonstrate a request failing
print_line("\n********Intentionally causing an error to occur to demonstrate error logger********");
$api_url = "https://api.linkedin.com/v1/people/FOOBARBAZ";
// in helpers.php, we defined a global exception handler
// but still wrapping this in a try/catch to demonstrate
// the logger functionality all in one place
try {
    $oauth->fetch($api_url, null, OAUTH_HTTP_METHOD_GET);
} catch (Exception $e) {
    log_diagnostics_info($oauth, $e);
}
Exemplo n.º 27
0
    if ($row['od_settle_case'] == '계좌이체') {
        $tot['receiptiche'] += $row['od_receipt_price'];
    }
    if ($row['od_settle_case'] == '휴대폰') {
        $tot['receipthp'] += $row['od_receipt_price'];
    }
    if ($row['od_settle_case'] == '신용카드') {
        $tot['receiptcard'] += $row['od_receipt_price'];
    }
    $tot['receiptpoint'] += $row['od_receipt_point'];
    $tot['misu'] += $row['od_misu'];
}
if ($i == 0) {
    echo '<tr><td colspan="12" class="empty_table">자료가 없습니다.</td></tr>';
} else {
    print_line($save);
}
?>
    </tbody>
    <tfoot>
    <tr>
        <td>합 계</td>
        <td><?php 
echo number_format($tot['ordercount']);
?>
</td>
        <td><?php 
echo number_format($tot['orderprice']);
?>
</td>
        <td><?php 
Exemplo n.º 28
0
                    $containing_items[] = $row;
                    $is_included = TRUE;
                }
            }
        }
        if (!$is_included) {
            print_line($row, $checked, $k);
        }
        $k = 1 - $k;
    }
    if (!empty($containing_items)) {
        echo '<tr><td colspan="3"><b>' . JText::_('Allready added calendars:') . '</b></td></tr>';
        $k = 0;
        for ($i = 0, $n = count($containing_items); $i < $n; $i++) {
            $row = $containing_items[$i];
            print_line($row, '', $k);
            $k = 1 - $k;
        }
    }
    ?>
</table>
</div>

<input type="hidden" name="option" value="com_gcalendar" /> <input
	type="hidden" name="task" value="" /> <input type="hidden"
	name="boxchecked" value="0" /> <input type="hidden" name="controller"
	value="import" /></form>
	<?php 
}
?>
<div align="center"><br>
Exemplo n.º 29
0
            $eof = 1;
        }
        $wxr = dsq_export_wp($post, $comments);
        $response = $dsq_api->import_wordpress_comments($wxr, $timestamp, $eof);
        if (!($response['group_id'] > 0)) {
            print_line('---------------------------------------------------------');
            print_line('There was an error communicating with DISQUS!');
            print_line($dsq_api->get_last_error());
            print_line('---------------------------------------------------------');
        }
        $group_id = $response['group_id'];
        print_line('    %d comments exported', count($comments), $time);
        $total_exported += count($comments);
        $at += EXPORT_CHUNK_SIZE;
        $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = %d AND comment_agent NOT LIKE 'Disqus/%%' LIMIT " . EXPORT_CHUNK_SIZE . " OFFSET {$at}", $post->ID));
        // assuming the cache is the internal, reset it's value to empty to avoid
        // large memory consumption
        $wp_object_cache->cache = array();
    }
    $time = abs(microtime() - $start);
    print_line('    Done! (took %.2fs)', $time);
}
$total_time = abs(microtime() - $global_start);
print_line('---------------------------------------------------------');
print_line('Done (processing took %.2fs)! %d comments were sent to DISQUS', $total_time, $total_exported);
if ($group_id) {
    print_line('');
    print_line('Status available at http://import.disqus.com/group/%d/', $group_id);
}
print_line('---------------------------------------------------------');
Exemplo n.º 30
0
require_once dirname(__FILE__) . '/functions.php';
$masterXml = simplexml_load_file(dirname(__FILE__) . '/../doc/master_provide.xml');
$fragmentsLocation = dirname(__FILE__) . '/../src/Miva/Provisioning/Builder/Fragment';
if (!is_dir($fragmentsLocation)) {
    print_line('Fragments Path Not Found or Not Directory');
    print_line($fragmentsLocation, true);
}
$domainNames = array();
$storeNames = array();
foreach ($masterXml->xpath('/Provision/Domain') as $d) {
    foreach ($d->children() as $c) {
        $domainNames[$c->getName()] = $c;
    }
}
foreach ($masterXml->xpath('/Provision/Store') as $s) {
    foreach ($s->children() as $c) {
        $storeNames[$c->getName()] = $c;
    }
}
foreach ($storeNames as $s => $e) {
    $_s = str_replace('_', '', $s);
    $path = sprintf('%s/%s.php', $fragmentsLocation, $_s);
    if (!file_exists($path)) {
        print_line($_s . ' - ' . $s);
        //file_put_contents($path, $e->asXml());
    }
}
foreach ($domainNames as $s) {
    #print_line($s);
}