Example #1
0
  function LoadFromDB() {
    $s = new SQLSelect();

    $this->group = PouetGroup::Spawn($this->id);
    $this->addeduser = PouetUser::Spawn($this->group->addedUser);

    // not to boast or anything, but this is f*****g beautiful.

    $sub = new SQLSelect();
    $sub->AddField("max(comments.addedDate) as maxDate");
    $sub->AddField("comments.which");
    $sub->AddTable("comments");
    $sub->AddJoin("left","prods","prods.id = comments.which");
    //$sub->AddOrder("comments.addedDate desc");
    $sub->AddGroup("comments.which");
    $sub->AddWhere(sprintf_esc("(prods.group1 = %d) or (prods.group2 = %d) or (prods.group3 = %d)",$this->id,$this->id,$this->id));

    $s = new BM_Query("prods");
    $s->AddField("cmts.addedDate as lastcomment");
    $s->AddField("cmts.rating as lastcommentrating");
    $s->AddJoin("left","(select comments.addedDate,comments.who,comments.which,comments.rating from (".$sub->GetQuery().") as dummy left join comments on dummy.maxDate = comments.addedDate and dummy.which = comments.which) as cmts","cmts.which=prods.id");
    $s->attach(array("cmts"=>"who"),array("users as user"=>"id"));
    $s->AddWhere(sprintf_esc("(prods.group1 = %d) or (prods.group2 = %d) or (prods.group3 = %d)",$this->id,$this->id,$this->id));

    $r = !!$_GET["reverse"];
    switch($_GET["order"])
    {
      case "type": $s->AddOrder("prods.type ".($r?"DESC":"ASC")); break;
      case "party": $s->AddOrder("prods_party.name ".($r?"DESC":"ASC")); $s->AddOrder("prods.party_year ".($r?"DESC":"ASC")); $s->AddOrder("prods.party_place ".($r?"DESC":"ASC")); break;
      case "release": $s->AddOrder("prods.releaseDate ".($r?"ASC":"DESC")); break;
      case "thumbup": $s->AddOrder("prods.voteup ".($r?"ASC":"DESC")); break;
      case "thumbpig": $s->AddOrder("prods.votepig ".($r?"ASC":"DESC")); break;
      case "thumbdown": $s->AddOrder("prods.votedown ".($r?"ASC":"DESC")); break;
      case "avg": $s->AddOrder("prods.voteavg ".($r?"ASC":"DESC")); break;
      case "views": $s->AddOrder("prods.views ".($r?"ASC":"DESC")); break;
      case "latestcomment": $s->AddOrder("lastcomment ".($r?"ASC":"DESC")); break;
      default: $s->AddOrder("prods.name ".($r?"DESC":"ASC")); break;
    }
    $this->prods = $s->perform();
    PouetCollectPlatforms($this->prods);
    PouetCollectAwards($this->prods);

    $s = new BM_Query("affiliatedboards");
    $s->attach(array("affiliatedboards"=>"board"),array("boards as board"=>"id"));
    $s->AddWhere(sprintf_esc("affiliatedboards.group=%d",$this->id));
    $this->affil = $s->perform();
  }
Example #2
0
  function PouetBoxAdminEditUser( $id )
  {
    parent::__construct();

    $this->id = (int)$id;

    $this->user = PouetUser::Spawn( $this->id );

    $this->title = "edit this user: <a href='user.php?who=".$this->user->id."'>"._html( $this->user->nickname )."</a>";
    $this->sceneID = $this->user->GetSceneIDData( false );
    $this->formifier = new Formifier();
    $this->fields = array();

    $row = SQLLib::selectRow("DESC users level");
    preg_match_all("/'([^']+)'/",$row->Type,$m);
    $this->levels = $m[1];

  }
Example #3
0
  function LoadFromDB() 
  {
    $this->board = SQLLib::SelectRow(sprintf_esc("select * from boards where id = %d",$this->id));
    if (!$this->board) return;

    $a = SQLLib::SelectRows(sprintf_esc("select * from boards_platforms where board = %d",$this->id));
    $this->platforms = array();
    foreach($a as $v) $this->platforms[] = $v->platform;

    $this->addedUser = PouetUser::Spawn($this->board->addedUser);

    $this->nfos = SQLLib::SelectRows(sprintf_esc("select * from othernfos where refid = %d",$this->id));

    $s = new BM_Query("affiliatedboards");
    $s->AddField("affiliatedboards.type");
    $s->Attach(array("affiliatedboards"=>"group"),array("groups as group"=>"id"));
    $s->AddWhere(sprintf_esc("affiliatedboards.board = %d",$this->id));
    $this->groups = $s->perform();

    $s = new BM_Query("prods");
    $s->AddWhere(sprintf_esc("prods.boardID = %d",$this->id));
    $this->bbstros = $s->perform();
  }
Example #4
0
  
  $user = PouetUser::Spawn( (int)$SceneIDuser["user"]["id"] );
  if (!$user || !$user->id)
  {
    $entry = glob(POUET_CONTENT_LOCAL."avatars/*.gif");
    $r = $entry[array_rand($entry)];
    $a = basename($r);

    $user = new PouetUser();
    $user->id = (int)$SceneIDuser["user"]["id"];
    $user->nickname = $SceneIDuser["user"]["display_name"];
    $user->avatar = $a;

    $user->Create();

    $user = PouetUser::Spawn( $user->id );
  }

  if ( $user->IsBanned() )
  {
		redirect("error.php?e=".rawurlencode("We dun like yer type 'round these parts."));
  }

  $_SESSION["user"] = $user;
  
  $currentUserSettings = SQLLib::SelectRow(sprintf_esc("select * from usersettings where id=%d",$user->id));
  if ($currentUserSettings)
    $ephemeralStorage->set( "settings:".$user->id, $currentUserSettings );

  redirect( basename( $returnURL ? $returnURL : "index.php" ) );
  
Example #5
0
  function LoadFromDB() {
    $this->party = PouetParty::spawn($_GET["which"]);
    if (!$this->party) return;

    $this->party->addeduser = PouetUser::spawn( $this->party->addedUser );
    
    if (isset($_GET["when"]))
    {
      $this->year = $_GET["when"];
    }
    else
    {
      $r = SQLLib::selectRow(sprintf_esc("select party_year from prods where party = %d order by rand() limit 1",$_GET["which"]));
      $this->year = $r->party_year;
    }

    if ($this->year < 100)
    {
      $this->year += ($this->year < 50 ? 2000 : 1900);
    }

    $this->prods = array();
    $s = new BM_Query("prods");
    $s->AddWhere( sprintf_esc("(prods.party = %d AND prods.party_year = %d) or (prodotherparty.party = %d AND prodotherparty.party_year = %d)",$this->party->id,$this->year,$this->party->id,$this->year) );

    // this is where it gets nasty; luckily we can fake it relatively elegantly: ORM won't notice if we override some of the field selections
    $s->AddJoin("left","prodotherparty",sprintf_esc("prodotherparty.prod = prods.id and (prodotherparty.party = %d AND prodotherparty.party_year = %d)",$this->party->id,$this->year));
    foreach($s->fields as &$v)
    {
      if ($v == "prods.party_compo as prods_party_compo")
      {
        $v = "COALESCE(prodotherparty.party_compo,prods.party_compo) as prods_party_compo";
      }
      if ($v == "prods.party_place as prods_party_place")
      {
        $v = "COALESCE(prodotherparty.party_place,prods.party_place) as prods_party_place";
      }
    }

    $dir = "DESC";
    if ($_GET["reverse"])
      $dir = "ASC";
    $this->sortByCompo = false;
    switch($_GET["order"])
    {
      case "type": $s->AddOrder("prods.type ".$dir); break;
      case "name": $s->AddOrder("prods.name ".$dir); break;
      case "group": $s->AddOrder("prods.group1 ".$dir); $s->AddOrder("prods.group2 ".$dir); $s->AddOrder("prods.group3 ".$dir); break;
      case "party": $s->AddOrder("prods_party.name ".$dir); $s->AddOrder("prods.party_year ".$dir); $s->AddOrder("prods.party_place ".$dir); break;
      case "thumbup": $s->AddOrder("prods.voteup ".$dir); break;
      case "thumbpig": $s->AddOrder("prods.votepig ".$dir); break;
      case "thumbdown": $s->AddOrder("prods.votedown ".$dir); break;
      case "avg": $s->AddOrder("prods.voteavg ".$dir); break;
      case "views": $s->AddOrder("prods.views ".$dir); break;
      default:
      {
        $s->AddOrder( "COALESCE(prodotherparty.party_compo,prods.party_compo)" );
        $s->AddOrder( "COALESCE(prodotherparty.party_place,prods.party_place)" );
        $this->sortByCompo = true;

        // include invitations on top
        $inv = new BM_Query("prods");
        $inv->AddWhere( sprintf_esc("(prods.invitation = %d AND prods.invitationyear = %d)",$this->party->id,$this->year,$this->party->id,$this->year) );
        $inv->AddOrder( "prods.addedDate" );
        $prods = $inv->perform();
        foreach($prods as &$v)
        {
          $v->party_compo = 1; // invit
          unset($v->placings);
        }

        $this->prods = array_merge( $this->prods, $prods );
      } break;
    }
    $prods = $s->perform();
    $this->prods = array_merge( $this->prods, $prods );
    PouetCollectPlatforms($this->prods);
    PouetCollectAwards($this->prods);
  }
Example #6
0
  function Commit($data)
  {
    if ($data["delCredit"])
    {
      SQLLib::Query("delete from credits where id=".(int)$data["delCredit"]);
      gloperator_log( "prod", (int)$this->prod->id, "prod_credits_del" );
      return array();
    }

    $a = array();
    $a["userID"] = $data["userID"];
    $a["role"] = $data["role"];
    if ($data["editCreditID"])
    {
      SQLLib::UpdateRow("credits",$a,"id=".(int)$data["editCreditID"]);
      $a["id"] = $data["editCreditID"];
      gloperator_log( "prod", (int)$this->prod->id, "prod_credits_edit", array("id"=>$a["id"]) );
    }
    else
    {
      $a["prodID"] = $this->prod->id;
      $a["id"] = SQLLib::InsertRow("credits",$a);
      gloperator_log( "prod", (int)$this->prod->id, "prod_credits_add", array("id"=>$a["id"]) );
    }
    if ($data["partial"])
    {
      $o = toObject($a);
      $o->user = PouetUser::Spawn($a["userID"]);
      $this->RenderNormalRow($o);
      $this->RenderNormalRowEnd($o);
      exit();
    }
    return array();
  }
  static function Display($itemID, $data)
  {
    $s = new BM_Query("credits");
    $s->AddField("credits.id");
    $s->AddField("credits.role");
    $s->attach(array("credits"=>"userID"),array("users as user"=>"id"));
    $s->AddWhere(sprintf_esc("credits.id = %d",$data["creditID"]));
    $s->SetLimit(1);
    $l = $s->perform();
    $row = reset($l);

    //$l = SQLLib::SelectRows(sprintf_esc("select credits.id,users.nickname,credits.role from credits left join users on users.id = credits.id where prodID = %d",$data["prod"]));
    $s = "<b>current</b>: ";
    if ($row->user)
    {
      $s .= $row->user->PrintLinkedAvatar()." ";
      $s .= $row->user->PrintLinkedName();
    }
    $s .= " - "._html($row->role);

    $s = new BM_Query("credits");
    $s->AddField("credits.id");
    $s->AddField("credits.role");
    $s->attach(array("credits"=>"userID"),array("users as user"=>"id"));
    $s->AddWhere(sprintf_esc("credits.id = %d",$data["oldUserID"]));
    $s->SetLimit(1);
    $l = $s->perform();
    $row = reset($l);

    $s = "<br/><b>old</b>: ";
    if ($row->user)
    {
      $s .= $row->user->PrintLinkedAvatar()." ";
      $s .= $row->user->PrintLinkedName();
    }
    $s .= " - "._html($row->role);

    $user = PouetUser::Spawn($data["userID"]);
    $s .= "<br/><b>new</b>: ";
    if ($user)
    {
      $s .= $user->PrintLinkedAvatar()." ";
      $s .= $user->PrintLinkedName();
    }
    $s .= " - "._html($data["userRole"]);
    return $s;
  }
Example #8
0
    "clientSecret" => SCENEID_PASS,
    "redirectURI" => POUET_ROOT_URL . "login.php",
  ) );
}

$currentUser = NULL;
if (get_login_id())
{
  $id = get_login_id();

  $host = gethostbyaddr($_SERVER["REMOTE_ADDR"]);
  if ($host!==".")
  {
    SQLLib::Query(sprintf_esc("update users set lastip='%s', lasthost='%s', lastlogin='******' where id=%d",
        $_SERVER["REMOTE_ADDR"],$host,date("Y-m-d H:i:s"),$id));
    $currentUser = PouetUser::Spawn( $id );
  }
}

if (defined("POUET_EXCEPTION_LOG"))
{
  set_exception_handler( function($ex){
    if ($f = fopen( POUET_EXCEPTION_LOG, "a" ))
    {
      fwrite( $f, str_pad("\n",60,"=") . "\n" . $ex );
      fclose($f);
    }
  } );
}

if ($currentUser && $currentUser->IsBanned())