コード例 #1
0
ファイル: locations_model.php プロジェクト: phn007/MyTools
 /**
  * Retrieve a list of the available locations within Reseller Central.
  */
 function get()
 {
     $locations = $this->resellercentralQuery('getLocations');
     if ($locations['success'] != 'true') {
         die('No result');
     }
     $p = new TablePrinter(['ID', 'Location', 'Priority']);
     foreach ($locations['sql'] as $loc) {
         $p->addRow($loc['location_id'], $loc['location'], $loc['priority']);
     }
     $p->output();
 }
コード例 #2
0
ファイル: packages_model.php プロジェクト: phn007/MyTools
 /**
  * Retrieve a list of the available locations within Reseller Central.
  */
 function get($account)
 {
     $apiKey = $this->getApiKey($account);
     $params = array('api_key' => $apiKey);
     $packages = $this->resellercentralQuery('getPackages', $params);
     if ($packages['success'] != 'true') {
         die('No result');
     }
     $p = new TablePrinter(['ID', 'Name', 'Quota', 'bandwidth', 'quotausage', 'bwusage', 'accounts']);
     foreach ($packages['sql'] as $pack) {
         $p->addRow($pack['pack_id'], $pack['name'], $pack['quota'], $pack['bandwidth'], $pack['quotausage'], $pack['bwusage'], $pack['accounts']);
     }
     $p->output();
 }
コード例 #3
0
 function printResult($data, $result, $type)
 {
     $p = new TablePrinter(['No.', 'Merchant', 'Product Number']);
     $i = 1;
     foreach ($data['merchantProductNumber'] as $merchant => $number) {
         $p->addRow($i, $merchant, $number);
         $i++;
     }
     $p->output();
     echo "\n";
     echo 'Total Products: ' . $data['totalProducts'];
     echo "\n";
     if ('byProducts' == $type) {
         echo 'Domain Number: ' . $result;
     }
     if ('byDomains' == $type) {
         echo 'Product Number Per Domain: ' . $result;
     }
 }
コード例 #4
0
ファイル: Example.php プロジェクト: elagith/learningMaterial
<?php

require '../TablePrinter.php';
require 'Loggr.php';
require 'Loggr/EchoOut.php';
require 'Product.php';
require 'PurchaseManager.php';
require 'IoC.php';
IoC::register('Logger', function () {
    return new Loggr(new Loggr\EchoOut());
});
IoC::register('Product', function ($name, $price) {
    return new Product($name, $price);
});
$pm = new PurchaseManager();
$store = [new Product('Juice', '1.99'), new Product('Milk', '3.99'), new Product('Water', '0.99')];
$pm->purchase($store[0]);
$pm->purchase($store[1]);
$pm->purchaseDiscountedProduct($store[2], 50);
$tp = new TablePrinter(['Product', 'Price']);
echo "You've purchased:\n";
foreach ($pm->purchaseHistory() as $purchase) {
    $tp->addRow($purchase->getName(), '$' . $purchase->getPrice());
}
$tp->output();
コード例 #5
0
ファイル: functions.php プロジェクト: N3X15/ATBBS-Plus
function show_trash($uid, $silence = false)
{
    $output = '<table><thead><tr> <th class="minimal">Headline</th> <th>Body</th> <th class="minimal">Time since deletion ▼</th> </tr></thead> <tbody>';
    $trash = DB::GetAll('SELECT headline, body, time FROM {P}Trash WHERE uid = ' . DB::Q($uid) . ' ORDER BY time DESC');
    $table = new TablePrinter('tblTrash');
    $columns = array('Headline', 'Body', 'Time since deletion ▼');
    $table->DefineColumns($columns, 'Body');
    foreach ($trash as $row) {
        if (empty($row['headline'])) {
            $row['headline'] = '<span class="unimportant">(Reply.)</span>';
        } else {
            $row['headline'] = htmlspecialchars($row['headline']);
        }
        $values = array($row['headline'], nl2br(htmlspecialchars($row['body'])), '<span class="help" title="' . format_date($row['time']) . '">' . calculate_age($row['time']) . '</span>');
        $table->Row($values);
    }
    if ($table->num_rows_fetched === 0) {
        return false;
    }
    return $table;
}
コード例 #6
0
ファイル: failed_postings.php プロジェクト: N3X15/ATBBS-Plus
<?php

require 'includes/header.php';
update_activity('failed_postings');
$page_title = 'Failed postings';
Output::Assign('sidebar', $sidebar);
Output::$tpl->display('dashhead.tpl.php');
$items_per_page = ITEMS_PER_PAGE;
$res = DB::Execute('SELECT time, uid, reason, headline, body FROM {P}FailedPostings ORDER BY time DESC LIMIT ' . $items_per_page);
$table = new TablePrinter('tblFail');
$columns = array('Error message', 'Poster', 'Age ▼');
if (isPowerUser()) {
    array_splice($columns, 1, 1);
}
$table->DefineColumns($columns, 'Error message');
while (list($fail_time, $fail_uid, $fail_reason, $fail_headline, $fail_body) = $res->FetchRow()) {
    if (strlen($fail_body) > 600) {
        $fail_body = substr($fail_body, 0, 600) . ' …';
    }
    $tooltip = '';
    if (empty($fail_headline)) {
        $tooltip = $fail_body;
    } else {
        if (!empty($fail_body)) {
            $tooltip = 'Headline: ' . $fail_headline . ' Body: ' . $fail_body;
        }
    }
    $fail_reasons = unserialize($fail_reason);
    $error_message = '<ul class="error_message';
    if (!empty($tooltip)) {
        $error_message .= ' help';
コード例 #7
0
ファイル: Post.php プロジェクト: elagith/learningMaterial
    }
    public function getTags()
    {
        return ['#awesome', '#evenmoreawesome'];
    }
}
class FakeORM
{
    public $id;
    // Stubbed out instead of making a DB call
    public static function find($id)
    {
        return new static($id);
    }
    // Stubbed out instead of making a DB call
    public function __construct($id)
    {
        $this->id = $id;
    }
}
class Post extends FakeORM
{
    use Categorizable, Taggable;
    protected $categoryTableName = 'post_categories';
    protected $tagTableName = 'post_tags';
}
$post = Post::find(1);
$tp = new TablePrinter(['Method', 'Names', 'Results']);
$tp->addRow('Post::getCategoryTable()', $post->getCategoryTable(), join(', ', $post->getCategories()));
$tp->addRow('Post::getTagTable()', $post->getTagTable(), join(', ', $post->getTags()));
echo $tp->output();
コード例 #8
0
ファイル: Example.php プロジェクト: elagith/learningMaterial
    }
    public function doSomething()
    {
        return 'Something';
    }
    public function aGenericMethod()
    {
        return 9000;
    }
    public function mixItUp()
    {
        return parent::aGenericMethod() . ' ' . parent::doSomething() . ' ' . $this->doSomething();
    }
}
$a = new A();
$b = new B();
$c = new C();
$p = new TablePrinter(['Method', 'Result']);
$p->addRow("A::aGenericMethod()", $a->aGenericMethod());
$p->addRow("B::aGenericMethod()", $b->aGenericMethod());
$p->addRow("C::aGenericMethod()", $c->aGenericMethod());
$p->addRow("B::doSomething()", $b->doSomething());
$p->addRow("C::doSomething()", $c->doSomething());
$p->addRow("C::mixItUp()", $c->mixItUp());
$p->output();
echo "\n\n";
$p = new TablePrinter(['Class', 'setting', 'anotherSetting']);
$p->addRow("A", print_r($a->setting, true), print_r($a->anotherSetting, true));
$p->addRow("B", print_r($b->setting, true), print_r($b->anotherSetting, true));
$p->addRow("C", print_r($c->setting, true), print_r($c->anotherSetting, true));
$p->output();
コード例 #9
0
ファイル: accounts_model.php プロジェクト: phn007/MyTools
 function displayResults($accounts)
 {
     $i = 1;
     $p = new TablePrinter(['Number', 'Domain', 'User', 'IP Address', 'Location', 'Quota', 'Bandwidth', 'Total Quota', 'Total BW', 'Status']);
     foreach ($accounts as $acc) {
         $p->addRow($i, $acc['domain'], $acc['username'], $acc['ip'], $acc['location'], $acc['rquota'], $acc['rbandwidth'], $acc['rtotal_disk'], $acc['rtotal_bw'], $acc['status']);
         $i++;
     }
     $p->output();
 }
コード例 #10
0
ファイル: private_messages.php プロジェクト: N3X15/ATBBS-Plus
		$res=DB::Execute("SELECT pmID,pmThread,pmTitle,pmDateSent,pmFrom,pmFlags FROM {P}PMs WHERE pmTo='{$User->ID}' AND (pmFlags&1)=0 ORDER BY pmDateSent DESC");
		$pms=array();
		while(list($id,$thread,$title,$date,$from,$flags)=$res->FetchRow())
		{
			if(!array_key_exists($thread,$pms))
				$pms[$thread]=array($date,$title);

			if($date>$pms[$thread][0])
				$pms[$thread][0]=$date;
			if($thread==0)
			{
				$pms[$thread][1]=$title;
				$pms[$thread][2]=$from;
			}
		}
		$pt=new TablePrinter('tblPMs');
		$pt->DefineColumns(array('Subject','From','Sent'),'Subject');
		foreach($pms as $id=>$details)
		{
			//var_dump($pms);
			$pt->Row(array(
				'<a href="'.THISURL.'/private_messages.php/thread/'.$id.'/">'.htmlspecialchars($details[1]).'</a>',
				'<a href="'.THISURL.'/private_messages.php/compose/'.$details[2].'/">'.$details[2].'</a>',
				calculate_age($details[0]).' ago'
			));
		}
		echo $pt->Output();
		?>
		<ul class="menu"><li><a href="<?=THISURL?>/private_messages.php/compose/">Compose New Message</a></li></ul>
<?
		break;
コード例 #11
0
ファイル: Example.php プロジェクト: elagith/learningMaterial
<?php

require '../TablePrinter.php';
require 'User.php';
require 'UserRepository.php';
$repo = new UserRepository();
$users = $repo->getAllCreatedBefore(2014, ['take' => 2]);
$tp = new TablePrinter(['Class', 'Username', 'Created This Year']);
foreach ($users as $user) {
    $tp->addRow(get_class($user), $user->username, $user->createdThisYear() ? 'Yes' : 'No');
}
echo $tp->output();
コード例 #12
0
ファイル: controlpanel.php プロジェクト: N3X15/ATBBS-Plus
					defuck_comment(DB::Q($_POST['filter'][$i])),
					DB::Q($_POST['reason'][$i]),
					intval($_POST['type'][$i]),
					ParseExpiry($_POST['duration'][$i]),
					DB::Q($_POST['replace'][$i]));
				$c++;
			}
			if($c>0)DB::Execute($sql);
		}
		redirect('Done.');
		break;
	case 'read_appeals':
		$page_title="Appeals";
		echo '<form action="/controlpanel/process_appeals/" method="post">';
		
		$slt=new TablePrinter('UIDAppeals');
		$slt->DefineColumns(array('Unban/Deny Appeal','UID','IP Address','Banned For','Appeal'),'UID/IP');
		$slt->SetTDClass('Appeal','appeal');

		$i=0;
		$res=DB::Execute("SELECT uid, ip, reason, appeal FROM {P}Bans WHERE appeal!=''");

		while(list($uid,$reason,$appeal)=$res->FetchRow())
		{
			$slt->Row(array(
					'<input type="checkbox" name="unban_uid[]" value="'.$uid.'" /><input type="checkbox" name="deny_appeal[]" value="'.$uid.'" />',
					$uid,$ip,
					$reason,
					htmlspecialchars($appeal)));
		}
		echo $slt.'<input type="submit" value="Unban"></forms>';
コード例 #13
0
ファイル: action.php プロジェクト: N3X15/ATBBS-Plus
     $page_title = 'Delete page';
     if (isset($_POST['id'])) {
         DB::Execute('DELETE FROM {P}Pages WHERE id = ' . intval($id));
         redirect('Page deleted.');
     }
     break;
 case 'ban_uid':
     if (!$moderator && !$administrator) {
         add_error('You are not wise enough.', true);
     }
     if (!id_exists($_GET['id'])) {
         add_error('There is no such user.', true);
     }
     $uid = $_GET['id'];
     $page_title = 'Ban poster ' . $id;
     $slt = new TablePrinter('Bans');
     $slt->DefineColumns(array('Confirm', 'UID', 'IP'), 'IP');
     $i = 0;
     $slt->Row(array('<input type="hidden" name="uid[' . $i . ']" value="' . $uid . '"><input type="hidden" name="ip[' . $i . ']" value="-"><input type="checkbox" name="confirm[' . $i . ']" value="1" checked="checked" />', $uid, $ip));
     Output::$tpl->display('controlpanel/banform.start.php');
     echo $slt->Output('ban-ees');
     Output::$tpl->display('controlpanel/banform.end.php');
     include 'includes/footer.php';
     exit;
     break;
     break;
 case 'unban_uid':
     if (!$moderator && !$administrator) {
         add_error('You are not wise enough.', true);
     }
     if (!id_exists($_GET['id'])) {
コード例 #14
0
ファイル: topic.tpl.php プロジェクト: N3X15/ATBBS-Plus
?>
">
				Cite
			</a>
		</li>
	</ul>
</div>
<?
	// Store information for the next round.
	$c++;
	$prevtime=$reply->Time;
endforeach;
if(isPowerUser()):?>
<h2>UID Dump</h2>
<?
$uidt=new TablePrinter('tblUIDs');
$uidt->DefineColumns(array('UID','Names'),'Names');
foreach($this->topic->UIDs as $uid=>$names)
{
	if($uid!='admin')
		$uid=sprintf('<a href="%1$sprofile/%2$s">%2$s</a>',THISURL,$uid);
	$uidt->Row(array($uid,implode(', ',$names)));
}
echo $uidt;
?>
<?endif;?>

<ul class="menu">
	<li>
		<a href="<?php 
echo rel2Abs('/new_reply/' . $_GET['id']);
コード例 #15
0
ファイル: stuff.php プロジェクト: N3X15/ATBBS-Plus
echo SITE_TITLE;
?>
's post count.</p>
<?if(FALSE):?>
	<h2>Debugging Shit ($_SESSION)</h2>
<?
$table=new TablePrinter('tblSession');
$table->DefineColumns(array('Variable','Value'),'Value');

foreach($_SESSION as $k=>$v) $table->Row(array($k,$v));

echo $table;
?>
	<h2>Debugging Shit ($User)</h2>
<?
$table=new TablePrinter('tblUser');
$table->DefineColumns(array('Variable','Value'),'Value');

foreach($User as $k=>$v)
{
	if(is_array($v))
		$v='<pre>'.htmlentities(var_export($v,true)).'</pre>';
	$table->Row(array($k,$v));
}

echo $table;
endif;
Output::$tpl->display('dashfooter.tpl.php');
require('includes/footer.php');

?>
コード例 #16
0
ファイル: profile.php プロジェクト: N3X15/ATBBS-Plus
								
		$topics->Row($values);
	}
	echo $topics;
}

if($id_num_replies > 0)
{
	echo '<h4 class="section">Replies</h4>';

	$sql=DB::Prepare('SELECT replies.id, replies.parent_id, replies.time, replies.body, replies.author_ip, topics.headline, topics.time FROM {P}Replies as replies INNER JOIN {P}Topics as topics ON replies.parent_id = topics.id WHERE replies.author = ? ORDER BY id DESC');
	$res=DB::Execute($sql,array($_GET['uid']));

	$stmt->bind_result;
	
	$replies = new TablePrinter('tblReplies');
	$columns = array
	(
		'Reply snippet',
		'Topic',
		'IP address',
		'Age ▼'
	);
	$replies->DefineColumns($columns, 'Topic');
	$replies->SetTDClass('Topic', 'topic_headline');
	$replies->SetTDClass('Reply snippet', 'reply_body_snippet');

	while($row=$res->FetchRow()) 
	{
		list($reply_id, $parent_id, $reply_time, $reply_body, $reply_ip_address, $topic_headline, $topic_time)=$row;
		$values = array 
コード例 #17
0
ファイル: Example.php プロジェクト: elagith/learningMaterial
<?php

require 'ProjectArchiver.php';
require 'ProjectReopener.php';
require '../TablePrinter.php';
require 'Project.php';
require 'ProjectRepository.php';
$repo = new ProjectRepository();
$projects = $repo->all();
// Add 'New Developer' to all projects
foreach ($projects as $project) {
    $project->addCollaborator('New Developer');
}
$tp = new TablePrinter(['Project', 'Status', 'Collaborators']);
foreach ($projects as $p) {
    $tp->addRow($p->getName(), $p->getStatus(), $p->getCollaborators());
}
echo $tp->output();
コード例 #18
0
ファイル: index.php プロジェクト: N3X15/ATBBS-Plus
    setcookie('last_topic', $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'] + 315569260, '/');
}
// If ostrich mode is enabled, fetch a list of blacklisted phrases.
$ignored_phrases = fetch_ignore_list();
// Fetch the {P}Topics appropriate to this page.
$items_per_page = ITEMS_PER_PAGE;
$start_listing_at = $items_per_page * ($current_page - 1);
if ($topics_mode) {
    $sql = "SELECT id, time, replies, visits, headline, body, last_post FROM {P}Topics ORDER BY id DESC LIMIT {$start_listing_at}, {$items_per_page}";
} else {
    $sql = "SELECT id, time, replies, visits, headline, body, last_post FROM {P}Topics ORDER BY last_post DESC LIMIT {$start_listing_at}, {$items_per_page}";
}
$res = DB::Execute($sql);
//$stmt->bind_result($topic_id, $topic_time, $topic_replies, $topic_visits, $topic_headline, $topic_body, $topic_last_post);
// Print the {P}Topics we just fetched in a table.
$table = new TablePrinter('tblBumps');
$order_name = $topics_mode ? 'Age' : 'Last bump';
$columns = array('Headline', 'Snippet', 'Replies', 'Visits', $order_name . ' ▼');
if ($_COOKIE['spoiler_mode'] != 1) {
    // If spoiler mode is disabled, remove the snippet column.
    array_splice($columns, 1, 1);
}
$table->DefineColumns($columns, 'Headline');
$table->SetTDClass('Headline', 'topic_headline');
$table->SetTDClass('Snippet', 'snippet');
if ($res) {
    while (list($topic_id, $topic_time, $topic_replies, $topic_visits, $topic_headline, $topic_body, $topic_last_post) = $res->FetchRow()) {
        // Should we even bother?
        if ($_COOKIE['ostrich_mode'] == 1) {
            foreach ($ignored_phrases as $ignored_phrase) {
                if (stripos($topic_headline, $ignored_phrase) !== false || stripos($topic_body, $ignored_phrase) !== false) {
コード例 #19
0
ファイル: hot_topics.php プロジェクト: N3X15/ATBBS-Plus
<?php

require 'includes/header.php';
$page_title = "Hot topics";
$res = DB::Execute('SELECT headline, id, time, replies FROM {P}Topics ORDER BY replies DESC LIMIT 0, 100');
$t = new TablePrinter('hot_topics');
$t->DefineColumns(array('#', 'Topic', 'Replies'), 'Topic');
$t->SetTDClass('Topic', 'topic_headline');
$i = 0;
while (list($hot_headline, $hot_id, $hot_time, $hot_replies) = $res->FetchRow()) {
    $t->Row(array(++$i, '<a href="/topic/' . $hot_id . '">' . $hot_headline . '</a>', $hot_replies));
}
echo $t;
require 'includes/footer.php';
コード例 #20
0
<?php

require '../TablePrinter.php';
function fetchStrategy($type)
{
    $strategies = ['addition' => function ($v1, $v2) {
        return $v1 + $v2;
    }, 'multiplication' => function ($v1, $v2) {
        return $v1 * $v2;
    }];
    return $strategies[$type];
}
function solveMath($type, $v1, $v2)
{
    $strategy = fetchStrategy($type);
    return $strategy($v1, $v2);
}
$tp = new TablePrinter(['Type', 'Result']);
$tp->addRow('Addition', solveMath('addition', 5, 5));
$tp->addRow('Multiplication', solveMath('multiplication', 5, 5));
echo $tp->output();
コード例 #21
0
ファイル: add_filters.tpl.php プロジェクト: N3X15/ATBBS-Plus
	</p>

	<table>
		<tr>
			<td>
				<

+-----------------------------------+-------------------------------------------+
| +-------------------------------+ |                                           |
| |                               | |                                           |
| |                               | |                                           |
| +-------------------------------+ |                                           |
| [v Hurp a Derp] [x] Confirm       |                                           |
+-----------------------------------+-------------------------------------------+					
<?
$t = new TablePrinter();
$t->DefineColumns(array('Confirm','Filter','Preview'),'Filter');
$i=0;



$opts='';
foreach($this->Options as $optname=>$optvalue)
{
	$opts='<option value="'.$optvalue.'">'.$optname.'</option>';
}

if(!empty($_SESSION['2BFiltered']))
{
	foreach($_SESSION['2BFiltered'] as $filterstring)
	{
コード例 #22
0
ファイル: watchlist.php プロジェクト: N3X15/ATBBS-Plus
update_activity('watchlist');
$page_title = 'Your watchlist';
if (is_array($_POST['rejects'])) {
    $sql = 'DELETE FROM watchlists WHERE ';
    $i = 0;
    foreach ($_POST['rejects'] as $reject_id) {
        if ($i > 0) {
            $sql .= ' OR ';
        }
        $sql .= '(uid = \'' . $User->UID . '\' AND topic_id = ' . intval($reject_id) . ')';
    }
    DB::Execute($sql);
    $_SESSION['notice'] = 'Selected topics unwatched.';
}
echo '<form name="fuck_off" action="" method="post">';
$topics = new TablePrinter('watchlist');
$topic_column = '<script type="text/javascript"> document.write(\'<input type="checkbox" name="master_checkbox" class="inline" onclick="checkOrUncheckAllCheckboxes()" title="Check/uncheck all" /> \');</script>Topic';
$columns = array($topic_column, 'Replies', 'Visits', 'Age', 'Last Post');
$db_columns = array('t.headline', 't.replies', 't.visits', 't.time', 'last_post');
$topics->DefaultSorting('last_post', SORT_DESC, $db_columns);
$topics->DefineColumns($columns, $topic_column);
$topics->SetTDClass($topic_column, 'topic_headline');
DB::ToggleDebug();
$res = DB::Execute('SELECT w.topic_id, t.headline, t.replies, t.visits, t.time, last_post FROM {P}Watchlists as w INNER JOIN {P}Topics as t ON w.topic_id = t.id WHERE w.uid = \'' . $User->ID . '\' ' . $topics->GetOrderSQL());
DB::ToggleDebug();
while (list($topic_id, $topic_headline, $topic_replies, $topic_visits, $topic_time, $last_post) = $res->FetchRow()) {
    $values = array('<input type="checkbox" name="rejects[]" value="' . $topic_id . '" class="inline" /> <a href="/topic/' . $topic_id . '">' . htmlspecialchars($topic_headline) . '</a>', replies($topic_id, $topic_replies), format_number($topic_visits), '<span class="help" title="' . format_date($topic_time) . '">' . calculate_age($topic_time) . '</span>', '<span class="help" title="' . format_date($last_post) . '">' . calculate_age($last_post) . '</span>');
    $topics->Row($values);
}
$num_topics_fetched = $topics->num_rows_fetched;
echo $topics;
コード例 #23
0
ファイル: Strategy.php プロジェクト: elagith/learningMaterial
require '../TablePrinter.php';
class Printer
{
    public function __construct($formatter)
    {
        $this->formatter = $formatter;
    }
    public function printLine($line)
    {
        return $this->formatter->printLine($line);
    }
}
class HTMLFormatter
{
    public function printLine($line)
    {
        return '<h1>' . $line . '</h1>';
    }
}
class CLIFormatter
{
    public function printLine($line)
    {
        return $line;
    }
}
$tp = new TablePrinter(['Strategy', 'Output']);
$tp->addRow('HTML', (new Printer(new HTMLFormatter()))->printLine('Hello, World!'));
$tp->addRow('CLI', (new Printer(new CLIFormatter()))->printLine('Hello, World!'));
echo $tp->output();