Skip to content
This repository has been archived by the owner on Apr 24, 2019. It is now read-only.

Commit

Permalink
Tons of queued changes from the last six months of my private fork. S…
Browse files Browse the repository at this point in the history
…ome good UI cleanup and added the Activations logic.
  • Loading branch information
Tyler Hall committed Apr 18, 2011
1 parent 3f6daaa commit bf002d3
Show file tree
Hide file tree
Showing 19 changed files with 1,026 additions and 121 deletions.
173 changes: 173 additions & 0 deletions activations.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<?PHP
require 'includes/master.inc.php';
$Auth->requireAdmin('login.php');
$nav = 'activations';

$applications = DBObject::glob('Application', 'SELECT * FROM shine_applications ORDER BY name');

$db = Database::getDatabase();

if(isset($_GET['q']))
{
$q = $_GET['q'];
$_q = $db->escape($q);
$search_sql = " AND (name LIKE '%$_q%' OR serial_number LIKE '%$_q%' OR ip LIKE '%$_q%') ";
}
else
{
$q = '';
$search_sql = '';
}

if(isset($_GET['id']))
{
$app_id = intval($_GET['id']);
$total_num_activations = $db->getValue("SELECT COUNT(*) FROM shine_activations WHERE app_id = $app_id $search_sql ORDER BY dt DESC");
$pager = new Pager(@$_GET['page'], 100, $total_num_activations);
$activations = DBObject::glob('Activation', "SELECT * FROM shine_activations WHERE app_id = $app_id $search_sql ORDER BY dt DESC LIMIT {$pager->firstRecord}, {$pager->perPage}");
$where = " AND app_id = $app_id ";
$app_name = $applications[$app_id]->name;
}
else
{
$total_num_activations = $db->getValue("SELECT COUNT(*) FROM shine_activations WHERE 1 = 1 $search_sql ");
$pager = new Pager(@$_GET['page'], 100, $total_num_activations);
$activations = DBObject::glob('Activation', "SELECT * FROM shine_activations WHERE 1 = 1 $search_sql ORDER BY dt DESC LIMIT {$pager->firstRecord}, {$pager->perPage}");
$where = '';
$app_name = 'All';
}

$available_apps = $db->getValues("SELECT app_id FROM shine_activations GROUP BY app_id");

$top_emails = $db->getRows("SELECT COUNT(*) as num, name from shine_activations GROUP BY name ORDER BY num DESC LIMIT 5");
$top_serials = $db->getRows("SELECT COUNT(*) as num, serial_number from shine_activations GROUP BY serial_number ORDER BY num DESC LIMIT 5");
$top_ips = $db->getRows("SELECT COUNT(*) as num, ip from shine_activations GROUP BY ip ORDER BY num DESC LIMIT 5");
?>
<?PHP include('inc/header.inc.php'); ?>

<div id="bd">
<div id="yui-main">
<div class="yui-b"><div class="yui-g">


<div class="block tabs spaces">
<div class="hd">
<h2>Activations</h2>
<ul>
<li class="<?PHP if(!isset($_GET['id'])) echo 'active'; ?>"><a href="activations.php">All Activations</a></li>
<?PHP foreach($applications as $a) : if(!in_array($a->id, $available_apps)) continue; ?>
<li class="<?PHP if(@$_GET['id'] == $a->id) echo 'active'; ?>"><a href="activations.php?id=<?PHP echo $a->id; ?>"><?PHP echo $a->name; ?></a></li>
<?PHP endforeach; ?>
</ul>
<div class="clear"></div>
</div>
<div class="bd">
<ul class="pager">
<li><a href="activations.php?page=<?PHP echo $pager->prevPage(); ?>&amp;id=<?PHP echo @$app_id; ?>">&#171; Prev</a></li>
<?PHP for($i = 1; $i <= $pager->numPages; $i++) : ?>
<?PHP if($i == $pager->page) : ?>
<li class="active"><a href="activations.php?page=<?PHP echo $i; ?>&amp;id=<?PHP echo @$app_id; ?>"><?PHP echo $i; ?></a></li>
<?PHP else : ?>
<li><a href="activations.php?page=<?PHP echo $i; ?>&amp;id=<?PHP echo @$app_id; ?>"><?PHP echo $i; ?></a></li>
<?PHP endif; ?>
<?PHP endfor; ?>
<li><a href="activations.php?page=<?PHP echo $pager->nextPage(); ?>&amp;id=<?PHP echo @$app_id; ?>">Next &#187;</a></li>
</ul>
<div class="clear"></div>

<table>
<thead>
<tr>
<td>Application</td>
<td>Email</td>
<td>Activation Date</td>
<td>Serial Number</td>
<td>IP</td>
</tr>
</thead>
<tbody>
<?PHP foreach($activations as $act) : ?>
<tr class="<?PHP if($act->order_id == '') { echo 'fraud'; } ?>">
<td><?PHP echo $act->applicationName(); ?></td>
<td><a href="order.php?id=<?PHP echo $act->order_id; ?>"><?PHP echo $act->name; ?></a></td>
<td><?PHP echo dater($act->dt, 'm/d/Y g:ia') ?></td>
<td><?PHP echo array_shift(explode('-', $act->serial_number)); ?>...</td>
<td><?PHP echo $act->ip; ?></td>
</tr>
<?PHP endforeach; ?>
</tbody>
</table>

<ul class="pager">
<li><a href="activations.php?page=<?PHP echo $pager->prevPage(); ?>&amp;id=<?PHP echo @$app_id; ?>">&#171; Prev</a></li>
<?PHP for($i = 1; $i <= $pager->numPages; $i++) : ?>
<?PHP if($i == $pager->page) : ?>
<li class="active"><a href="activations.php?page=<?PHP echo $i; ?>&amp;id=<?PHP echo @$app_id; ?>"><?PHP echo $i; ?></a></li>
<?PHP else : ?>
<li><a href="activations.php?page=<?PHP echo $i; ?>&amp;id=<?PHP echo @$app_id; ?>"><?PHP echo $i; ?></a></li>
<?PHP endif; ?>
<?PHP endfor; ?>
<li><a href="activations.php?page=<?PHP echo $pager->nextPage(); ?>&amp;id=<?PHP echo @$app_id; ?>">Next &#187;</a></li>
</ul>
<div class="clear"></div>
</div>
</div>

</div></div>
</div>
<div id="sidebar" class="yui-b">
<div class="block">
<div class="hd">
Search Activations
</div>
<div class="bd">
<form action="activations.php?id=<?PHP echo @$app_id; ?>" method="get">
<p><input type="text" name="q" value="<?PHP echo @$q; ?>" id="q" class="text">
<span class="info">Searches email, serial number, and IP address.</span></p>
<p><input type="submit" name="btnSearch" value="Search" id="btnSearch"></p>
</form>
</div>
</div>

<div class="block">
<div class="hd">
<h2>Top Emails</h2>
</div>
<div class="bd">
<ul class="biglist">
<?PHP foreach($top_emails as $x) : ?>
<li><a href="activations.php?q=<?PHP echo $x['name']; ?>"><?PHP echo $x['name']; ?> (<?PHP echo $x['num']; ?>)</a></li>
<?PHP endforeach; ?>
</ul>
</div>
</div>

<div class="block">
<div class="hd">
<h2>Top Serials</h2>
</div>
<div class="bd">
<ul class="biglist">
<?PHP foreach($top_serials as $x) : ?>
<li><a href="activations.php?q=<?PHP echo $x['serial_number']; ?>"><?PHP echo array_shift(explode('-', $x['serial_number'])); ?>... (<?PHP echo $x['num']; ?>)</a></li>
<?PHP endforeach; ?>
</ul>
</div>
</div>

<div class="block">
<div class="hd">
<h2>Top IPs</h2>
</div>
<div class="bd">
<ul class="biglist">
<?PHP foreach($top_ips as $x) : ?>
<li><a href="activations.php?q=<?PHP echo $x['ip']; ?>"><?PHP echo $x['ip']; ?> (<?PHP echo $x['num']; ?>)</a></li>
<?PHP endforeach; ?>
</ul>
</div>
</div>
</div>
</div>

<?PHP include('inc/footer.inc.php'); ?>
28 changes: 18 additions & 10 deletions application.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
$app->return_url = $_POST['return_url'];
$app->fs_security_key = $_POST['fs_security_key'];
$app->tweet_terms = $_POST['tweet_terms'];
$app->upgrade_app_id = $_POST['upgrade_app_id'];
$app->update();
redirect('application.php?id=' . $app->id);
}
Expand All @@ -60,6 +61,7 @@
$return_url = $_POST['return_url'];
$fs_security_key = $_POST['fs_security_key'];
$tweet_terms = $_POST['tweet_terms'];
$upgrade_app_id = $_POST['upgrade_app_id'];
}
}
else
Expand All @@ -85,7 +87,10 @@
$return_url = $app->return_url;
$fs_security_key = $app->fs_security_key;
$tweet_terms = $app->tweet_terms;
$upgrade_app_id = $app->upgrade_app_id;
}

$upgrade_apps = DBObject::glob('Application', "SELECT * FROM shine_applications WHERE id <> '{$app->id}' ORDER BY name");
?>
<?PHP include('inc/header.inc.php'); ?>

Expand Down Expand Up @@ -131,6 +136,17 @@
<input type="text" class="text" name="tweet_terms" id="tweet_terms" value="<?PHP echo htmlspecialchars($tweet_terms); ?>">
<span class="info">Seperate with commas</span>
</p>
<p>
<label for="upgrade_app_id">Upgrade App</label><br>
<select name="upgrade_app_id" id="upgrade_app_id">
<option value="">-- None --</option>
<?PHP foreach($upgrade_apps as $a) : ?>
<option <?PHP if($upgrade_app_id == $a->id) echo 'selected="selected"'; ?> value="<?PHP echo $a->id; ?>"><?PHP echo $a->name; ?></option>
<?PHP endforeach; ?>
</select><br/>
<span class="info">Choosing an app here will provide a one-click option to upgrade existing orders to the selected app.</span>
</p>


<hr>

Expand Down Expand Up @@ -167,7 +183,7 @@

<hr>

<h3>Aquatic Prime</h3>
<h3>Licensing</h3>
<p>
<label for="license_type">License Type</label><br>
<select name="license_type" id="license_type">
Expand Down Expand Up @@ -220,7 +236,7 @@
<p>
<label for="email_body">Email Body</label>
<textarea name="email_body" id="email_body" class="text"><?PHP echo $email_body ?></textarea><br>
<span class="info"><strong>Available Substitutions</strong>: {first_name}, {last_name}, {payer_email}, {license}, {1daylink}, {3daylink}, {1weeklink}, {foreverlink}. Add your own in includes/class.objects.php getBody().</span>
<span class="info"><strong>Available Substitutions</strong>: {first_name}, {last_name}, {payer_email}, {license}, {serial_number}, {1daylink}, {3daylink}, {1weeklink}, {foreverlink}. Add your own in includes/class.objects.php getBody().</span>
</p>

<p>
Expand All @@ -236,14 +252,6 @@
</div></div>
</div>
<div id="sidebar" class="yui-b">
<div class="block">
<div class="hd">
<h3>i use this</h3>
</div>
<div class="bd">
<?PHP echo $app->iUseThisHTML(); ?>
</div>
</div>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions css/yuiapp.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ textarea { height:13em; }
.text-center { text-align:center; }
.inline { display:inline; }
.dim { opacity:0.3; }
.fraud { background-color:yellow; }

/* Shine Specific Stuff */
a.big-button {
Expand Down
5 changes: 4 additions & 1 deletion fastspring.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
$o->insert();

$o->generateLicense();
// $o->emailLicense();

if(isset($_POST['sendEmail']) && ($_POST['sendEmail'] == 1)) {
$o->emailLicense();
}

// These are the fields and values you'll need to setup in FastSpring's
// remote notification fulfillment option.
Expand Down
4 changes: 2 additions & 2 deletions inc/nav.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
?>
<div id="navigation">
<ul id="primary-navigation">
<li<?PHP if($nav == 'applications') : ?> class="active"<?PHP endif; ?>><a href="index.php">Applications</a></li>
<li<?PHP if($nav == 'applications') : ?> class="active"<?PHP endif; ?>><a href="index.php">Home</a></li>
<li<?PHP if($nav == 'orders') : ?> class="active"<?PHP endif; ?>><a href="orders.php">Orders</a></li>
<li<?PHP if($nav == 'activations') : ?> class="active"<?PHP endif; ?>><a href="activations.php">Activations</a></li>
<li<?PHP if($nav == 'feedback') : ?> class="active"<?PHP endif; ?>><a href="feedback.php">Feedback (<?PHP echo $feedback_count; ?>)</a></li>
<li<?PHP if($nav == 'tweets') : ?> class="active"<?PHP endif; ?>><a href="tweets.php">Tweets (<?PHP echo $tweet_count; ?>)</a></li>
<li<?PHP if($nav == 'stats') : ?> class="active"<?PHP endif; ?>><a href="stats.php">Sparkle Stats</a></li>
<li<?PHP if($nav == 'tickets') : ?> class="active"<?PHP endif; ?>><a href="tickets.php">Tickets</a></li>
</ul>

<ul id="user-navigation">
Expand Down
Loading

0 comments on commit bf002d3

Please sign in to comment.