public function Reconcile() { DB::zdb()->update(Invite::$TABLE, array("redeemed_by" => Auth::Obj()->User()->ID(), "available" => 0), "code = '{$this->code}'"); Log::Activity("reconciled invitation code " . $this->code); }
public static function Create() { try { DB::zdb()->beginTransaction(); // Create empty cube. DB::zdb()->insert( Cube::$TABLE, array( "name" => "New Cube", "revision" => 1, "owner" => Auth::Obj()->User()->ID() ) ); // Insert CDP for free. require_once "Records/entry.php"; DB::zdb()->insert( Entry::$TABLE, array( "card" => 1, "cube" => DB::zdb()->lastInsertId() ) ); DB::zdb()->commit(); } catch ( Exception $e ) { DB::zdb()->rollBack(); Log::Failure(print_r($e, true)); } }
public static function Activity($action, $user=1) { if ( $user == 1 && Auth::Obj()->Authenticated() ) $user = Auth::Obj()->User()->ID(); DB::zdb()->insert("activity", array("action" => $action, "user" => $user, "date" => date("Y-m-d H:i:s"))); }
public static function Obj() { static $obj; if ( !$obj ) { $local = "en"; if ( Auth::Obj()->Authenticated() ) { $local = Auth::Obj()->User()->Local(); } $obj = new View($local); } return $obj; }
public static function Create($post=NULL) { $invite = new Invite($post["code"]); if ( !$invite->Available() ) { throw new Exception("Invite has already been redeemed."); } if ( App::Obj()->UseFacebook() ) { require_once "Tools/Facebook/facebook.php"; $fb = new Facebook( App::Obj()->FacebookSettings() ); $user = $fb->getUser(); if ( $user ) { $data = $fb->api("/me"); $fbId = $data["id"]; if ( ! $fbId ) throw new Exception("FB ID invalid"); $in = array("facebook" => $fbId); DB::zdb()->insert("users", $in); Auth::Obj()->LogIn(); } } else { unset($post["pass2"]); unset($post["code"]); $pass = $post["pass"]; $post["pass"] = md5($post["pass"]); $n = DB::zdb()->insert("users", $post); Auth::Obj()->LogIn($post["user"], $pass); } if ( Auth::Obj()->Authenticated() ) { $invite->Reconcile(); Log::Activity("created their user account"); } }
<?php if ( !Auth::Obj()->CanAccess(2) ) return; ob_start(); include "Requests/set_list.php"; $out = ob_get_contents(); ob_end_clean(); ?> <script type="text/javascript"> var aSet = 0; function reload_set_list() { log("reload"); $.ajax({ url: "request.php?a=set_list", success: function(data, textStatus, jqXHR) { $("#set_list")[0].innerHTML = data; } }); } function add_set() { $.ajax({ url: "request.php?a=new_set", success: function(data, textStatus, jqXHR) {
<?php // Grab Cuber Tools require_once("Tools/cuber.php"); require_once("Tools/Facebook/facebook.php"); // Production Environment if ( App::Obj()->UseFacebook() ) { if ( Auth::Obj()->Authenticated() ) { header("Location: home.php"); } else { Auth::Obj()->LogIn(); if ( isset($_GET["code"]) ) { View::Obj()->Title("Cuber - Cube Management Software by Ryan Knuesel"); View::Obj()->MainView("invitation"); } else { $fb = new Facebook(App::Obj()->FacebookSettings()); $loginurl = $fb->getLoginUrl(); header("Location: $loginurl"); } } } // Dev environment else
<?php // Grab Cuber Tools require_once("Tools/cuber.php"); if ( Auth::Obj()->Authenticated() ) { View::Obj()->Title("Cuber - Cube Management Software by Ryan Knuesel"); View::Obj()->MainView("home"); } else { header("Location: /"); } ?>
<?php // **** // **** // Legacy Notice // This file is conforms to a very bad design. The new one is much better, // but this file is part of a component that is going to be scrapped anyway. // For a better example, look at the Views/Components/cube/ folder. // **** // **** require_once "Records/invite.php"; echo Invite::Create(Auth::Obj()->User())->Code(); ?>
<?php $user = Auth::Obj()->User(); $data = $user->Data(); if ( $data ) : ?> <section id="top"> <span id="top_tab">Cuber</span> </section> <?php else: ?> <section id="top"> <span id="top_tab" style="border-color:red;">Cuber<span style="color:red">:dev</span></span> </section> <?php endif; ?>
<?php if ( !Auth::Obj()->CanAccess(2) ) return; // need to use the Invite model $s = DB::zdb()->select() ->from("invites") ->where("owner = ?", Auth::Obj()->User()->ID()) ->where("available = 1"); $invites = DB::zdb()->fetchAll($s); $out = array(); foreach( $invites as $invite ) $out[] = $invite["code"]; $codes = @implode("<br />", $out); $ct = count($out); ?> <script type="text/javascript"> function new_invite() { $.ajax({ url: "request.php?a=new_invite", success: function(data, textStatus, jqXHR) { $("#invites")[0].innerHTML += ( "<br />" + data ); } }); } </script> <section id="invites"> Invites: <?php echo $ct; ?>
<?php // Grab Cuber Tools require_once("Tools/cuber.php"); if ( Auth::Obj()->Authenticated() && Auth::Obj()->CanAccess(2) ) { View::Obj()->Title("Cuber Admin - Cube Management Software by Ryan Knuesel"); View::Obj()->MainView("admin"); } else { header("Location: /"); } ?>
<?php // ** // * Cube Select // * Component // * #viewportA // * // * Author: Ryan Knuesel // ** foreach ( Cube::CubesForUser(Auth::Obj()->User()) as $cube ) $cube->DrawCubeCell(); Cube::DrawAddCubeCell(); ?>