Exemplo n.º 1
0
  function Commit($data)
  {
    SQLLib::Query(sprintf_esc("UPDATE prods SET party=null, party_year=0, party_compo=0, party_place=0 WHERE party=%d",$this->party->id));
    SQLLib::Query(sprintf_esc("UPDATE prods SET invitation=0, invitationyear=0 WHERE invitation=%d",$this->party->id));
    SQLLib::Query(sprintf_esc("DELETE FROM partiesaka WHERE party1=%d OR party1=%d",$this->party->id,$this->party->id));
    SQLLib::Query(sprintf_esc("DELETE FROM prodotherparty WHERE party=%d",$this->party->id));
    SQLLib::Query(sprintf_esc("DELETE FROM partylinks WHERE party=%d",$this->party->id));
    SQLLib::Query(sprintf_esc("DELETE FROM listitems WHERE itemid=%d AND type='party'",$this->party->id));
    SQLLib::Query(sprintf_esc("DELETE FROM parties WHERE id=%d",$this->party->id));
    
    gloperator_log( "party", (int)$this->party->id, "party_delete", get_object_vars($this->party) );

    return array();
  }
Exemplo n.º 2
0
  function LoadFromDB() {
    $this->prod = PouetProd::spawn( $this->id );
    if(!$this->prod)
      return;

    if($this->prod->latestip != $_SERVER["REMOTE_ADDR"] && CheckReferrer($_SERVER["HTTP_REFERER"]) )
    {
      SQLLib::Query(sprintf_esc("UPDATE prods SET views=views+1, latestip='%s' WHERE id=%d",$_SERVER["REMOTE_ADDR"],$this->id));
    }

    $this->linkCheck = SQLLib::SelectRow(sprintf_esc("SELECT * FROM prods_linkcheck where prodID = %d",$this->id));

    $a = array(&$this->prod);
    PouetCollectPlatforms( $a );

    if ($this->prod->boardID)
      $this->board = SQLLib::SelectRow(sprintf_esc("SELECT * FROM boards WHERE id = %d",$this->prod->boardID));

    $s = new BM_Query();
    $s->AddField("added");
    $s->AddTable("screenshots");
    $s->SetLimit(1);
    $s->attach(array("screenshots"=>"user"),array("users as user"=>"id"));
    $s->AddWhere(sprintf_esc("prod=%d",$this->id));
    list($this->screenshot) = $s->perform();

    $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",$this->id));
    $rows = $s->perform();
    foreach($rows as $row)
    {
      $this->prod->placings[] = new PouetPlacing( array("party"=>$row->party,"compo"=>$row->party_compo,"ranking"=>$row->party_place,"year"=>$row->party_year) );
    }

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

    $s = new BM_Query();
    $s->AddTable("users_cdcs");
    $s->attach(array("users_cdcs"=>"user"),array("users as user"=>"id"));
    $s->AddWhere(sprintf_esc("cdc = %d",$this->id));
    $cdcs = $s->perform();

    $this->userCDCs = array();
    foreach($cdcs as $v)
      $this->userCDCs[$v->user->id] = $v;
    $this->isPouetCDC = SQLLib::selectRow(sprintf_esc("select * from cdc where which = %d",$this->id));

    $this->awards = SQLLib::selectRows(sprintf_esc("select * from sceneorgrecommended where prodid = %d order by type, category",$this->id));

    $s = new BM_Query("credits");
    $s->AddField("credits.role");
    $s->AddWhere(sprintf("credits.prodID = %d",$this->id));
    $s->Attach(array("credits"=>"userID"),array("users as user"=>"id"));
    $s->AddOrder("credits.role");
    $this->credits = $s->perform();

    $this->downloadLinks = array();
    /*
    if ($this->prod->sceneorg)
    {
      $o = new stdClass();
      $o->type = "scene.org";
      $o->id = "sceneorgID";
      $o->link = "http://scene.org/file.php?id=".(int)$this->prod->sceneorg;
      $this->downloadLinks[] = $o;
    }
    */
    if ($this->prod->csdb)
    {
      $o = new stdClass();
      $o->type = "csdb";
      $o->id = "csdbID";
      $o->link = "http://csdb.dk/release/?id=".(int)$this->prod->csdb;
      $this->downloadLinks[] = $o;
    }
    if ($this->prod->zxdemo)
    {
      $o = new stdClass();
      $o->type = "zxdemo";
      $o->id = "zxdemoID";
      $o->link = "http://zxdemo.org/item.php?id=".(int)$this->prod->zxdemo;
      $this->downloadLinks[] = $o;
    }
    if ($this->prod->demozoo)
    {
      $o = new stdClass();
      $o->type = "demozoo";
      $o->id = "demozooID";
      $o->link = "http://demozoo.org/productions/".(int)$this->prod->demozoo."/";
      $this->downloadLinks[] = $o;
    }
    $this->downloadLinks = array_merge($this->downloadLinks,SQLLib::selectRows(sprintf_esc("select type, link from downloadlinks where prod = %d order by type",$this->id)));
    $this->screenshotPath = find_screenshot($this->prod->id);
  }
Exemplo n.º 3
0
  function Commit($data)
  {
    SQLLib::Query(sprintf_esc("DELETE FROM othernfos WHERE refid=%d AND type='bbs'",$this->board->id)); // TODO: cleanup files
    SQLLib::Query(sprintf_esc("DELETE FROM affiliatedboards WHERE board=%d",$this->board->id));
    SQLLib::Query(sprintf_esc("DELETE FROM boards_platforms WHERE board=%d",$this->board->id));
    SQLLib::Query(sprintf_esc("DELETE FROM boards WHERE id=%d",$this->board->id));
    
    gloperator_log( "board", (int)$this->board->id, "board_delete", get_object_vars($this->board) );

    return array();
  }
Exemplo n.º 4
0
  function Commit($data)
  {
    if ($data["delAffil"])
    {
      SQLLib::Query("delete from affiliatedprods where id=".(int)$data["delAffil"]);
      gloperator_log( "prod", (int)$this->prod->id, "prod_rel_del" );
      return array();
    }

    list($direction,$type) = explode(":",$data["type"],2);
    $a = array();
    $a["type"] = $type;
    $a["original"]   = $direction == "o" ? $this->prod->id : $data["prod"];
    $a["derivative"] = $direction == "d" ? $this->prod->id : $data["prod"];
    if ($data["editAffilID"])
    {
      SQLLib::UpdateRow("affiliatedprods",$a,"id=".(int)$data["editAffilID"]);
      $a["id"] = $data["editAffilID"];
      gloperator_log( "prod", (int)$this->prod->id, "prod_rel_edit", array("id"=>$a["id"]) );
    }
    else
    {
      $a["id"] = SQLLib::InsertRow("affiliatedprods",$a);
      gloperator_log( "prod", (int)$this->prod->id, "prod_rel_add", array("id"=>$a["id"]) );
    }
    if ($data["partial"])
    {
      $o = toObject($a);
      $o->prodOriginal   = PouetProd::Spawn($a["original"]);
      $o->prodDerivative = PouetProd::Spawn($a["derivative"]);
      $this->RenderNormalRow($o);
      $this->RenderNormalRowEnd($o);
      exit();
    }

    return array();
  }
Exemplo n.º 5
0
function pouetAdmin_recacheTopDemos()
{
  global $timer;
  
  // this needs to be made faster. a LOT faster.
  $total = array();

  // list by views
  $timer["recache_views"]["start"] = microtime_float();
  $i=0;
  $query="SELECT id,name,views FROM prods ORDER BY views DESC";
  $result = SQLLib::Query($query);
  $content = "<ol>";
  while($tmp = SQLLib::Fetch($result)) {
    $total[$tmp->id]+=$i;
    $i++;
    if ($i<=5)
      $content .= "<li><b>"._html($tmp->name)."</b> - ".$tmp->views." views</li>\n";
  }
  $content .= "</ol>";
  $content .= "<h3>".$i." prod views loaded</h3>\n";
  $timer["recache_views"]["end"] = microtime_float();

  $i=0;
  // Get the list of prod IDs ordered by the sum of their comment ratings
  $sql = new SQLSelect();
  $sql->AddField("prods.id");
  $sql->AddField("prods.name");
  $sql->AddField("SUM(comments.rating) as theSum");
  $sql->AddTable("prods");
  $sql->AddJoin("","comments","prods.id = comments.which");
  $sql->AddGroup("prods.id");
  $sql->AddOrder("SUM(comments.rating) DESC");

  $timer["recache_votes"]["start"] = microtime_float();
  $result = SQLLib::Query( $sql->GetQuery() );
  $content .= "<ol>";
  while($tmp = SQLLib::Fetch($result)) {
    $total[$tmp->id]+=$i;
    $i++;
    if ($i<=5)
      $content .= "<li><b>"._html($tmp->name)."</b> - "._html($tmp->theSum)." votes</li>\n";
  }
  $content .= "</ol>";
  $content .= "<h3>".$i." vote counts loaded</h3>\n";
  $timer["recache_votes"]["end"] = microtime_float();

  $timer["recache_sort"]["start"] = microtime_float();
  asort($total);
  $timer["recache_sort"]["end"] = microtime_float();

  $timer["recache_update"]["start"] = microtime_float();
  $i=1;
  unset($tmp);
  unset($top_demos);
  $a = array();
  while ((list ($key, $val)=each($total))) 
  {
    $a[] = array(
      "id" => $key,
      "rank" => $i,
    );
    if (count($a) == 100)
    {
      SQLLib::UpdateRowMulti("prods","id",$a);
      $a = array();
    }
    $i++;
  }
  SQLLib::UpdateRowMulti("prods","id",$a);
  $content .= "<h3>".$i." prod rankings updated</h3>\n";
  $timer["recache_update"]["end"] = microtime_float();

  @unlink('cache/pouetbox_topalltime.cache');
  @unlink('cache/pouetbox_topmonth.cache');
  return $content;
}
Exemplo n.º 6
0
 static function UpdateRowMulti( $table, $key, $tuples )
 {
   if (!count($tuples))
     return;
   if (!is_array($tuples[0]))
     throw new Exception("Has to be array!");
 
   $fields = array_keys( $tuples[0] );
 
   $sql = "UPDATE ".$table;
   $keys = array();
   foreach($fields as $field)
   {
     if ($field == $key) continue;
     foreach($tuples as $tuple)
       $cond .= sprintf_esc(" WHEN %d THEN '%s' ",$tuple[$key],$tuple[$field]);
     $sql .= " SET `".$field."` = (CASE `".$key."` ".$cond." END)";
   }
   foreach($tuples as $tuple)
     $keys[] = $tuple[$key];
   $sql .= " WHERE `".$key."` IN (".implode(",",$keys).")";
 
   //echo $sql."\n\n";
   SQLLib::Query($sql);
 }
Exemplo n.º 7
0
 static function Process($itemID, $reqData)
 {
   $a = array();
   $a["download"] = $reqData["downloadLink"];
   SQLLib::UpdateRow("prods",$a,"id=".(int)$itemID);
   
   SQLLib::Query(sprintf_esc("delete from prods_linkcheck where prodID = %d",$itemID));
   
   return array();
 }
Exemplo n.º 8
0
  if ($_POST["submit"] == "rulez") $vote = 1;
  if ($_POST["submit"] == "sucks") $vote = -1;

  $csrf = new CSRFProtect();
  if ($vote && $csrf->ValidateToken())
  {
    SQLLib::Query(sprintf_esc("delete from logos_votes where logo = %d and user = %d",$_POST["logoID"],$currentUser->id));

    $a = array();
    $a["logo"] = (int)$_POST["logoID"];
    $a["user"] = $currentUser->id;
    $a["vote"] = $vote;
    SQLLib::InsertRow("logos_votes",$a);
  }

  SQLLib::Query(sprintf_esc("update logos set vote_count = (select sum(vote) from logos_votes where logo = %d) where id = %d",(int)$_POST["logoID"],(int)$_POST["logoID"]));

  // ajax
  if ($_POST["partial"]==1)
  {
    $s = clone $sel;
    $visibleLogos = $_POST["visibleLogos"];
    foreach($visibleLogos as $k=>$v) $visibleLogos[$k] = (int)$v;
    $s->AddWhere(sprintf_esc("logos.id not in (%s)",implode(",",$visibleLogos)));
    $s->SetLimit(1);
    $logo = SQLLib::SelectRow($s->GetQuery());

    if ($logo)
    {
      $box = new PouetBoxLogoVote($logo);
      $box->Render();
Exemplo n.º 9
0
  function Commit($data)
  {
    SQLLib::Query(sprintf_esc("UPDATE prods SET group1=NULL WHERE group1=%d",$this->group->id));
    SQLLib::Query(sprintf_esc("UPDATE prods SET group2=NULL WHERE group2=%d",$this->group->id));
    SQLLib::Query(sprintf_esc("UPDATE prods SET group3=NULL WHERE group3=%d",$this->group->id));
    SQLLib::Query(sprintf_esc("DELETE FROM groupsaka WHERE group1=%d OR group2=%d",$this->group->id,$this->group->id));
    SQLLib::Query(sprintf_esc("DELETE FROM affiliatedboards WHERE `group`=%d",$this->group->id));
    SQLLib::Query(sprintf_esc("DELETE FROM listitems WHERE itemid=%d AND type='group'",$this->group->id));
    SQLLib::Query(sprintf_esc("DELETE FROM groups WHERE id=%d",$this->group->id));
    
    gloperator_log( "group", (int)$this->group->id, "group_delete", get_object_vars($this->group) );

    return array();
  }
Exemplo n.º 10
0
  $sceneID = new SceneID3( array(
    "clientID" => SCENEID_USER,
    "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);
    }
  } );
}