Ejemplo n.º 1
0
 function LoadFromDB() {
   $s = new BM_Query("prods");
   $s->AddOrder("prods.addedDate desc");
   $s->SetLimit(POUET_CACHE_MAX);
   $this->data = $s->perform();
   PouetCollectPlatforms($this->data);
 }
Ejemplo n.º 2
0
 function LoadFromDB() {
   $s = new BM_Query("prods");
   $s->AddOrder("(prods.views/((sysdate()-prods.addedDate)/100000)+prods.views)*prods.voteavg*prods.voteup DESC");
   $s->AddWhere("prods.addedDate > DATE_SUB(NOW(), INTERVAL 30 DAY)");
   $s->SetLimit(POUET_CACHE_MAX);
   $this->data = $s->perform();
   PouetCollectPlatforms($this->data);
 }
Ejemplo n.º 3
0
 function LoadFromDB() {
   $s = new BM_Query("prods");
   $s->AddOrder("prods.rank");
   $s->AddWhere("prods.rank!=0");
   $s->SetLimit(POUET_CACHE_MAX);
   $this->data = $s->perform();
   PouetCollectPlatforms($this->data);
 }
Ejemplo n.º 4
0
  function LoadFromDB() {
    $id = SQLLib::SelectRow("SELECT prods.id as id FROM prods ORDER BY RAND() LIMIT 1")->id;
    
    $s = new BM_Query("prods");
    $s->AddWhere(sprintf_esc("prods.id = %d",$id));
    $s->SetLimit(1);
    $data = $s->perform();
    $this->data = reset($data);

    $a = array(&$this->data);
    PouetCollectPlatforms($a);
  }
Ejemplo n.º 5
0
  function LoadFromDB() {
    global $POSTS_PER_PAGE;

    $s = new SQLSelect();
    $s->AddTable("bbs_topics");
    $s->AddWhere("bbs_topics.id=".$this->id);
    $this->topic = SQLLib::SelectRow($s->GetQuery());
    if(!$this->topic) return false;

    $s = new SQLSelect();
    $s->AddField("count(*) as c");
    $s->AddTable("bbs_posts");
    $s->AddWhere("bbs_posts.topic=".$this->id);
    $this->postcount = SQLLib::SelectRow($s->GetQuery())->c;

    $s = new BM_Query();
    $s->AddTable("bbs_posts");
    $s->AddField("bbs_posts.id as id");
    $s->AddField("bbs_posts.post as post");
    $s->AddField("bbs_posts.added as added");
    $s->attach(array("bbs_posts"=>"author"),array("users as user"=>"id"));
    $s->AddWhere("bbs_posts.topic=".$this->id);
    //$s->SetLimit( $POSTS_PER_PAGE, (int)(($this->page - 1)*$POSTS_PER_PAGE) );

    $this->paginator = new PouetPaginator();
    $this->paginator->SetData( "topic.php?which=".$this->id, $this->postcount, $POSTS_PER_PAGE, $_GET["page"] );
    $this->paginator->SetLimitOnQuery( $s );

    $this->posts = $s->perform();

    $this->title = _html($this->topic->topic);
  }
Ejemplo n.º 6
0
  function LoadFromDB() {
    $s = new SQLSelect();

    $perPage = get_setting("userlistusers");
    $this->page = (int)max( 1, (int)$_GET["page"] );

    $s = new BM_Query("users");

    $dir = !$_GET["reverse"];
    switch($_GET["order"])
    {
      case "nickname": $s->AddOrder("users.nickname ".($dir?"ASC":"DESC")); break;
      case "age": $s->AddOrder("users.registerDate ".($dir?"ASC":"DESC")); break;
      case "level": $s->AddOrder("users.level ".($dir?"ASC":"DESC")); break;
      case "glops":
      default: $s->AddOrder("users.glops ".($dir?"DESC":"ASC")); break;
    }
    $s->AddOrder("users.id ".($dir?"ASC":"DESC"));

    $s->SetLimit( $perPage, (int)(($this->page-1) * $perPage) );

    //echo $s->GetQuery();

    $this->users = $s->performWithCalcRows( $this->count );

    $this->maxglops = SQLLib::SelectRow("SELECT MAX(glops) as m FROM users")->m;
  }
Ejemplo n.º 7
0
  function LoadFromDB()
  {
    global $currentUser;
    $ids = SQLLib::SelectRows(sprintf_esc("select prodID from watchlist where userID = %d",$currentUser->id));
    if (!count($ids)) return;
    
    $i = array();
    foreach($ids as $v) $i[] = $v->prodID;
  
    $s = new BM_Query("prods");
    $s->AddWhere( sprintf_esc("prods.id in (%s)",implode(",",$i) ) );
    $this->prods = $s->perform();

    PouetCollectPlatforms($this->prods);
  }
Ejemplo n.º 8
0
  function LoadFromDB()
  {
///    $this->nfo = SQLLib::SelectRow( sprintf_esc("select * from othernfos where id = %d", $_GET["which"] ) );

    $s = new BM_Query();
    $s->AddField("othernfos.added");
    $s->AddField("othernfos_board.name");
    $s->AddTable("othernfos");
    $s->SetLimit(1);
    $s->attach(array("othernfos"=>"adder"),array("users as user"=>"id"));
    $s->attach(array("othernfos"=>"refID"),array("boards as board"=>"id"));
    $s->AddWhere(sprintf_esc("othernfos.id=%d",$_GET["which"]));
    $s->GetQuery();
    list($this->nfo) = $s->perform();
  }
Ejemplo n.º 9
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();
  }
Ejemplo n.º 10
0
 function LoadFromDB() {
   $s = new BM_Query("parties");
   $s->AddField("count(*) as c");
   $s->AddField("prods.party_year");
   $s->AddJoin("","prods","prods.party=parties.id");
   $s->AddWhere(sprintf_esc("parties.id != %d",NO_PARTY_ID));
   //$s->AddWhere(sprintf_esc("prods.id is not null");
   $s->AddGroup("prods.party,prods.party_year");
   $s->AddOrder("prods.releaseDate desc, prods.id desc");
   $s->SetLimit(POUET_CACHE_MAX);
   $this->data = $s->perform();
   //PouetCollectPlatforms($this->data);
 }
Ejemplo n.º 11
0
  function LoadFromDB() {
    $s = new BM_Query();
    $s->AddTable("(select * from comments order by comments.addedDate desc limit 25) as c");
    $s->attach(array("c"=>"which"),array("prods as prod"=>"id"));
    $s->attach(array("c"=>"who"),array("users as user"=>"id"));
    $s->AddOrder("c.addedDate desc");
    $s->AddField("c.id as commentID");
    $s->AddField("c.rating as rating");
    $s->SetLimit(POUET_CACHE_MAX);
    $this->data = $s->perform();

    $a = array();
    foreach($this->data as $p) $a[] = &$p->prod;
    PouetCollectPlatforms($a);
  }
Ejemplo n.º 12
0
  function LoadFromDB()
  {
    $s = new BM_Query("comments");
    $s->AddField("comments.rating");
    $s->AddField("comments.addedDate");
    $s->attach(array("comments"=>"which"),array("prods as prod"=>"id"));
    $s->attach(array("comments"=>"who"),array("users as user"=>"id"));
    $s->AddOrder("comments.addedDate DESC");
    $s->AddWhere(sprintf_esc("(UNIX_TIMESTAMP()-UNIX_TIMESTAMP(comments.addedDate))<=(3600*%d)",get_setting("commentshours")));
    $this->comments = $s->perform();

    $a = array();
    foreach($this->comments as $v) $a[] = &$v->prod;
    PouetCollectPlatforms($a);
  }
Ejemplo n.º 13
0
  function LoadFromDB()
  {
    $this->prod = PouetProd::spawn( $_GET["which"] );

    $s = new BM_Query();
    $s->AddField("added");
    $s->AddTable("nfos");
    $s->SetLimit(1);
    $s->attach(array("nfos"=>"user"),array("users as user"=>"id"));
    $s->AddWhere(sprintf_esc("prod=%d",$this->prod->id));
    list($this->nfo) = $s->perform();
  }
Ejemplo n.º 14
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();
  }
Ejemplo n.º 15
0
  function LoadFromDB() {
    $s = new BM_Query();
    $s->AddTable("cdc");
    $s->attach(array("cdc"=>"which"),array("prods as prod"=>"id"));
    $s->AddOrder("cdc.addedDate desc");
    $s->SetLimit(1);
    list($this->data) = $s->perform();

    $a = array(&$this->data->prod);
    PouetCollectPlatforms($a);
  }
Ejemplo n.º 16
0
 function LoadFromDB() {
   global $currentUser;
   if (!$currentUser) return;
   
   $ids = SQLLib::SelectRows(sprintf_esc("select prodID from watchlist where userID = %d",$currentUser->id));
   if (!count($ids)) return;
   
   $i = array();
   foreach($ids as $v) $i[] = $v->prodID;
   
   $s = new BM_Query();
   //$s->AddTable(sprintf_esc("(select * from comments where comments.which in (%s) order by comments.addedDate desc) as c ",implode(",",$i)));
   $s->AddTable(sprintf_esc("(select *, max(comments.addedDate) as maxDate from comments where comments.which in (%s) group by comments.which) as c ",implode(",",$i)));
   $s->AddJoin("left","comments","c.maxDate = comments.addedDate and c.which = comments.which");
   $s->attach(array("comments"=>"which"),array("prods as prod"=>"id"));
   $s->attach(array("comments"=>"who"),array("users as user"=>"id"));
   //$s->AddGroup("c.which");
   $s->AddOrder("comments.addedDate desc");
   $s->AddField("comments.id as commentID");
   $s->SetLimit((int)$this->limit);
   $this->data = $s->perform();
 }
Ejemplo n.º 17
0
  function LoadFromDB()
  {
    $s = new BM_Query("users_cdcs");
    $s->attach(array("users_cdcs"=>"cdc"),array("prods as prod"=>"id"));
    $s->AddGroup("users_cdcs.cdc");
    $s->AddField("count(*) as c");
    $s->AddOrder("c desc");
    $this->cdcs = $s->perform();

    $a = array();
    foreach($this->cdcs as $v) $a[] = &$v->prod;
    PouetCollectPlatforms($a);
  }
Ejemplo n.º 18
0
  function LoadFromDB() {
    $s = new SQLSelect();

    $perPage = get_setting("prodlistprods");
    $this->page = (int)max( 1, (int)$_GET["page"] );

    $s = new BM_Query("prods");

    if (is_array($_GET["type"]))
    {
      $cond = array();
      foreach($_GET["type"] as $type)
        $cond[] = sprintf_esc("FIND_IN_SET('%s',prods.type)",$type);
      $s->AddWhere(implode(" OR ",$cond));
    }
    if (is_array($_GET["platform"]))
    {
      global $PLATFORMS;
      $platforms = array();
      foreach($_GET["platform"] as $platform)
        foreach($PLATFORMS as $k=>$v)
          if ($v["name"] == $platform)
            $platforms[] = $k;
      if ($platforms)
      {
        $s->AddJoin("LEFT","prods_platforms as pp","pp.prod = prods.id");
        $s->AddWhere(sprintf_esc("pp.platform in (%s)",implode(",",$platforms)));
      }
    }
    $dir = "DESC";
    if ($_GET["reverse"])
      $dir = "ASC";
    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;
      case "added": $s->AddOrder("prods.addedDate ".$dir); break;
    }
    $s->AddOrder("prods.releaseDate ".$dir);
    $s->AddOrder("prods.addedDate ".$dir);

    $s->SetLimit( $perPage, (int)(($this->page-1) * $perPage) );

    //echo $s->GetQuery();

    $this->prods = $s->performWithCalcRows( $this->count );
    PouetCollectPlatforms($this->prods);
    PouetCollectAwards($this->prods);
  }
Ejemplo n.º 19
0
 static function spawn($id)
 {
     $query = new BM_Query(static::getTable());
     $query->addExtendedFields();
     $query->AddWhere(sprintf_esc("%s.%s = %d", static::getTable(), static::getPrimaryKey(), (int) $id));
     $query->SetLimit(1);
     $rows = $query->perform();
     return reset($rows);
 }
Ejemplo n.º 20
0
 function LoadFromDB()
 {
   $s = new BM_Query("faq");
   $s->AddOrder("category, id");
   $this->items = $s->perform();
 }
Ejemplo n.º 21
0
  function LoadFromDB() {
    $s = new BM_Query();
    $s->AddField("comments.id as id");
    $s->AddField("comments.comment as comment");
    $s->AddField("comments.rating as rating");
    $s->AddField("comments.addedDate as addedDate");
    $s->attach(array("comments"=>"who"),array("users as user"=>"id"));
    $s->AddTable("comments");
    $s->AddOrder("comments.addedDate");
    $s->AddWhere("comments.which=".$this->id);
    $perPage = get_setting("prodcomments");
    if ($perPage != -1)
    {
      $sc = new SQLSelect();
      $sc->AddField("count(*) as c");
      $sc->AddWhere("comments.which=".$this->id);
      $sc->AddTable("comments");

      $commentCount = SQLLib::SelectRow($sc->GetQuery())->c;

      $this->paginator->SetData( "prod.php?which=".$this->id, $commentCount, $perPage, $_GET["page"] );
      $this->paginator->SetLimitOnQuery( $s );
      /*
      $this->commentCount =

      $this->numPages = (int)ceil($this->commentCount / $this->perPage);
      if (!isset($_GET["page"]))
        $this->page = $this->numPages;
      else
        $this->page = (int)$_GET["page"];

      $this->page = (int)max( $this->page, 1 );
      $this->page = (int)min( $this->page, $this->numPages );

      if ($this->numPages > 1)
        $s->SetLimit( $this->perPage, (int)(($this->page-1) * $this->perPage) );
      */
    }
    $r = $s->perform();
    $this->data = $r;
  }
Ejemplo n.º 22
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);
  }
Ejemplo n.º 23
0
  function LoadFromDB()
  {
    global $PLATFORMS;
    $plat = array();
    $plat[""] = "- none -";
	  foreach($PLATFORMS as $k=>$v) $plat[$k] = $v["name"];
	  uasort($plat,"strcasecmp");

    $this->fields = array(
      "type"=>array(
        "name"=>"type",
        "type"=>"select",
        //"multiple"=>true,
        "assoc"=>true,
        "fields"=>$this->types,
        "info"=>" ",
        //"required"=>true,
      ),
      "platform"=>array(
        "name"=>"platform",
        "type"=>"select",
        //"multiple"=>true,
        "assoc"=>true,
        "fields"=>$plat,
        "info"=>" ",
        //"required"=>true,
      ),
      "days"=>array(
        "name"=>"days to go back",
        "type"=>"number",
        "value"=>0,
        "info"=>"0 means alltime",
      ),
      "limit"=>array(
        "name"=>"number of prods",
        "type"=>"number",
        "value"=>10,
        "max"=>50,
      ),
    );


    if ($_GET)
    {
      foreach($_GET as $k=>$v)
        if ($this->fields[$k])
          $this->fields[$k]["value"] = $v;
    }

    $s = new BM_Query("prods");
    if ($_GET["days"])
    {
      $s->AddOrder("(prods.views/((NOW()-prods.addedDate)/100000)+prods.views)*prods.voteavg*prods.voteup DESC");
      $s->AddWhere(sprintf_esc("prods.addedDate > DATE_SUB(NOW(),INTERVAL %d DAY)",$_GET["days"]));
    }
    else if ($_GET["dateFrom"] || $_GET["dateTo"])
    {
      $s->AddOrder("(prods.views/((NOW()-prods.addedDate)/100000)+prods.views)*prods.voteavg*prods.voteup DESC");
      if ($_GET["dateFrom"])
        $s->AddWhere(sprintf_esc("prods.addedDate >= '%s'",$_GET["dateFrom"]));
      if ($_GET["dateTo"])
        $s->AddWhere(sprintf_esc("prods.addedDate <= '%s'",$_GET["dateTo"]));
    }
    else
    {
      $s->AddOrder("prods.rank");
      $s->AddWhere("prods.rank > 0");
    }
    if ($_GET["type"])
    {
      $s->AddWhere(sprintf_esc("FIND_IN_SET('%s',prods.type)>0",$_GET["type"]));
    }
    if ($_GET["platform"])
    {
      $s->AddJoin("","prods_platforms",sprintf_esc("prods_platforms.prod = prods.id AND prods_platforms.platform=%d",$_GET["platform"]));
    }
    $limit = (int)($_GET["limit"] ? $_GET["limit"] : 10);
    $limit = min($limit,50);
    $limit = max($limit,10);
    $s->SetLimit($limit);
    $this->prods = $s->perform();
  }
Ejemplo n.º 24
0
<?
require_once("../bootstrap.inc.php");
require_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-rss.php");

$limit = $_GET["howmany"] ? $_GET["howmany"] : 10;
$limit = min($limit,25);
$limit = max($limit,5);

$s = new BM_Query("comments");
$s->AddField("comments.id");
$s->AddField("comments.addedDate");
$s->AddField("comments.comment");
$s->AddField("comments.rating");
$s->attach(array("comments"=>"which"),array("prods as prod"=>"id"));
$s->attach(array("comments"=>"who"),array("users as user"=>"id"));
$s->AddWhere(sprintf_esc("comments.which = %d",$_GET["prod"]));
$s->AddOrder("comments.addedDate DESC");
$s->SetLimit($limit);
$data = $s->perform();

$first = reset($data);
$rss = new PouetRSS(array(
  "title"=>"pouët.net - prod comments for ".$first->prod->name,
  "link"=>$first->prod->GetLink(),
));

$votes = array( -1 => "sucks", 0 => "isok", 1 => "rulez" );
foreach($data as $item)
{
  $rss->AddItem(array(
    "title"     => $item->user->nickname,
Ejemplo n.º 25
0
<?
require_once("../bootstrap.inc.php");
require_once( POUET_ROOT_LOCAL . "/include_pouet_index/box-index-latestadded.php");
require_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-rss.php");

$limit = $_GET["howmany"] ? $_GET["howmany"] : 10;
$limit = min($limit,25);
$limit = max($limit,5);

$s = new BM_Query("prods");
$s->AddOrder("prods.addedDate DESC");
$s->attach("addedUser",array("users as user"=>"id"));
$s->SetLimit($limit);

if ($_GET["type"])
{
  $s->AddWhere(sprintf_esc("FIND_IN_SET('%s',prods.type)",$_GET["type"]));
}
if ($_GET["platform"])
{
  $platformID = -1;
  foreach($PLATFORMS as $k=>$v)
    if ($v["name"] == $_GET["platform"])
      $platformID = $k;
  if ($platformID != -1)
  {
    $s->AddJoin("LEFT","prods_platforms as pp","pp.prod = prods.id");
    $s->AddWhere(sprintf_esc("pp.platform = %d",$platformID));
  }
}
Ejemplo n.º 26
0
<?
$timer["html"]["start"] = microtime_float();
require_once("header.bare.php");

echo "<header>\n";
echo "  <h1>pouët.net</h1>\n";

if (get_setting("logos"))
{
  $timer["logo"]["start"] = microtime_float();
  $s = new BM_Query();
  $s->AddTable("logos");
  $s->AddField("logos.file as file");
  $s->attach(array("logos"=>"author1"),array("users as u1"=>"id"));
  $s->attach(array("logos"=>"author2"),array("users as u2"=>"id"));
  $s->AddOrder("rand()");
  $s->AddWhere("logos.vote_count>0");
  $s->SetLimit("1");
  list($logo) = $s->perform();

  if ($logo)
  {
    $credit = $logo->u1->PrintLinkedName();
    if ($logo->u2)
      $credit .= " and " . $logo->u2->PrintLinkedName();
  }
  $timer["logo"]["end"] = microtime_float();


  $random_quotes = Array (
    'send your logos to <a href="submit_logo.php">us</a> and be a popstar !',
Ejemplo n.º 27
0
 function LoadFromDB()
 {
   $s = new BM_Query("users");
   $s->AddOrder("users.glops desc");
   $s->AddWhere(sprintf_esc("lastip = '%s'",$this->ip));
   $this->nicks = $s->perform();
 }
Ejemplo n.º 28
0
if (!$prod)
  die($xml->AsXML());

$xml->addAttribute("standard","1.1");
$xml->addAttribute("version","1");
$xml->addAttribute("author","*****@*****.**");
$xml->addAttribute("mode","partial");

$xml->addChild("demo");
$xml->demo->addAttribute("pouet_id",_html($prod->id));
$xml->demo->addChild("name",_html($prod->name));

foreach($prod->types as $v)
  $xml->demo->addChild("category",ucfirst(_html($v)))->addAttribute("type",_html($v));

$s = new BM_Query();
$s->AddField("prodotherparty.party_compo");
$s->AddField("prodotherparty.party_place");
$s->AddField("prodotherparty.party_year");
$s->AddTable("prodotherparty");
$s->attach(array("prodotherparty"=>"party"),array("parties as party"=>"id"));
$s->AddWhere(sprintf_esc("prod=%d",$prod->id));
$rows = $s->perform();
foreach($rows as $row)
{
  $prod->placings[] = new PouetPlacing( array("party"=>$row->party,"compo"=>$row->party_compo,"ranking"=>$row->party_place,"year"=>$row->party_year) );
}

global $COMPOTYPES;
foreach($prod->placings as $p)
{
 function LoadFromDB()
 {
   $s = new BM_Query("modification_requests");
   $s->AddField("modification_requests.id");
   $s->AddField("modification_requests.requestType");
   $s->AddField("modification_requests.itemID");
   $s->AddField("modification_requests.itemType");
   $s->AddField("modification_requests.requestBlob");
   $s->AddField("modification_requests.requestDate");
   $s->Attach(array("modification_requests"=>"userID"),array("users as user"=>"id"));
   $s->Attach(array("modification_requests"=>"itemID"),array("prods as prod"=>"id"));
   $s->AddWhere("approved is null");
   $s->AddOrder("requestDate desc");
   $this->requests = $s->perform();
 }
Ejemplo n.º 30
0
  function PouetBoxAdminEditProdAffil( $prod )
  {
    parent::__construct();

    $this->uniqueID = "pouetbox_prodeditprodaffil";
    $this->prod = $prod;
    $this->title = "related prods";

    $this->headers = array("relation","prod");

    $s = new BM_Query();
    $s->AddField("affiliatedprods.id");
    $s->AddField("affiliatedprods.type");
    $s->AddTable("affiliatedprods");
    $s->attach(array("affiliatedprods"=>"original"),array("prods as prodOriginal"=>"id"));
    $s->attach(array("affiliatedprods"=>"derivative"),array("prods as prodDerivative"=>"id"));
    $s->AddWhere(sprintf_esc("original=%d or derivative=%d",$this->prod->id,$this->prod->id));
    $this->data = $s->perform();
  }