コード例 #1
0
ファイル: box-bbs-post.php プロジェクト: neodyme60/pouet2.0
  function Validate($post)
  {
    global $currentUser;
    if (!$currentUser)
      return array("you have to be logged in!");

    if (!$currentUser->CanPostInBBS())
      return array("not allowed lol.");

    $message = trim($post["message"]);

    if (!$message)
      return array("not too meaningful, is it...");

    $topic = SQLLib::SelectRow(sprintf_esc("SELECT * FROM bbs_topics where id=%d",$this->topic));
    if (!$topic)
      return array("you sneaky bastard you >_<");
    if ($topic->closed)
      return array("closed, capisci?");

    $r = SQLLib::SelectRow(sprintf_esc("SELECT author,topic,post FROM bbs_posts WHERE topic = %d ORDER BY added DESC LIMIT 1",(int)$this->topic));

    if ($r && $r->author == get_login_id() && $r->post == $message)
      return array("ERROR! DOUBLEPOST == ROB IS JARIG!");

    return array();
  }
コード例 #2
0
ファイル: box-prod-post.php プロジェクト: neodyme60/pouet2.0
  function Validate($post)
  {
    global $currentUser;

    if (!$currentUser)
      return array("you have to be logged in!");

    if (!$currentUser->CanPostInProdComments())
      return array("not allowed lol.");

    $message = $post["comment"];
    $message = str_replace(html_entity_decode('&shy;', 0, 'UTF-8'),"",$message);
    $message = trim($message);

    if (!$message)
      return array("not too meaningful, is it...");

    $r = SQLLib::SelectRow(sprintf_esc("SELECT id FROM prods where id=%d",$this->prod));
    if (!$r)
      return array("you sneaky bastard you >_<");

    $r = SQLLib::SelectRow(sprintf_esc("SELECT comment,who,which FROM comments WHERE which = %d ORDER BY addedDate DESC LIMIT 1",$this->prod));

    if ($r && $r->who == get_login_id() && $r->comment == $message)
      return array("ERROR! DOUBLEPOST == ROB IS JARIG!");

    return array();
  }
コード例 #3
0
ファイル: prodlist.php プロジェクト: neodyme60/pouet2.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);
  }
コード例 #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);
  }
コード例 #5
0
ファイル: prod_nfo.php プロジェクト: neodyme60/pouet2.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();
  }
コード例 #6
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);
 }
コード例 #7
0
  function PouetBoxAdminEditTopic( $id )
  {
    parent::__construct();
    $this->id = (int)$id;
    $this->uniqueID = "pouetbox_edittopic";
    $this->topic = SQLLib::SelectRow(sprintf_esc("select * from bbs_topics where id = %d",$this->id));
    $this->title = "edit this topic: "._html($this->topic->topic);
    $this->formifier = new Formifier();
    $this->fields = array();

    $row = SQLLib::selectRow("DESC bbs_topics category");
    preg_match_all("/'([^']+)'/",$row->Type,$m);
    $this->categories = $m[1];
  }
コード例 #8
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();
  }
コード例 #9
0
ファイル: user_watchlist.php プロジェクト: neodyme60/pouet2.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);
  }
コード例 #10
0
ファイル: comments.php プロジェクト: neodyme60/pouet2.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);
  }
コード例 #11
0
ファイル: admin_faq.php プロジェクト: neodyme60/pouet2.0
 function LoadFromDB()
 {
   if ($this->id)
   {
     $s = new BM_Query("faq");
     $s->AddWhere(sprintf_esc("id = %d",$this->id));
     $item = $s->perform();
     $this->item = $item[0];
     
     $this->fields["category"]["value"] = $this->item->category;
     $this->fields["question"]["value"] = $this->item->question;
     $this->fields["answer"]["value"] = $this->item->answer;
     $this->fields["deprecated"]["value"] = $this->item->deprecated;
   }
 }
コード例 #12
0
ファイル: board_nfo.php プロジェクト: neodyme60/pouet2.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();
  }
コード例 #13
0
ファイル: groups.php プロジェクト: neodyme60/pouet2.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();
  }
コード例 #14
0
  function LoadFromDB()
  {
    parent::LoadFromDB();

    $this->links = SQLLib::selectRow(sprintf_esc("select * from partylinks where party = %d and year = %d",$this->id,$this->year));

    $this->fields["download"]["value"] = $this->links->download;
    $this->fields["csdbID"]["value"] = $this->links->csdb;
    $this->fields["slengpungID"]["value"] = $this->links->slengpung;
    //$this->fields["zxdemoID"]["value"] = $this->links->zxdemo;
    $this->fields["demozooID"]["value"] = $this->links->demozoo;
    $this->fields["artcity"]["value"] = $this->links->artcity;

    foreach($_POST as $k=>$v)
      if ($this->fields[$k])
        $this->fields[$k]["value"] = $v;
  }
コード例 #15
0
ファイル: bbs.php プロジェクト: neodyme60/pouet2.0
  function LoadFromDB() {
    $s = new SQLSelect();

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

    $s = new BM_query();
    $s->AddField("bbs_topics.id as id");
    $s->AddField("bbs_topics.lastpost as lastpost");
    $s->AddField("bbs_topics.firstpost as firstpost");
    $s->AddField("bbs_topics.topic as topic");
    $s->AddField("bbs_topics.count as count");
    $s->AddField("bbs_topics.category as category");
    $s->AddTable("bbs_topics");
    $s->attach(array("bbs_topics"=>"userfirstpost"),array("users as firstuser"=>"id"));
    $s->attach(array("bbs_topics"=>"userlastpost"),array("users as lastuser"=>"id"));


    $dir = "DESC";
    if ($_GET["reverse"])
      $dir = "ASC";

    switch($_GET["order"])
    {
      case "firstpost": $s->AddOrder("bbs_topics.firstpost ".$dir); break;
      case "userfirstpost": $s->AddOrder("bbs_topics_firstuser.nickname ".$dir); break;
      case "userlastpost": $s->AddOrder("bbs_topics_lastuser.nickname ".$dir); break;
      case "topic": $s->AddOrder("bbs_topics.topic ".$dir); break;
      case "category": $s->AddOrder("bbs_topics.category ".$dir); break;
      case "count": $s->AddOrder("bbs_topics.count ".$dir); break;
      case "lastpost":
      default: $s->AddOrder("bbs_topics.lastpost ".$dir); break;
    }
    $s->AddOrder("bbs_topics.lastpost ".$dir);
    $s->SetLimit( $perPage, (int)(($this->page - 1) * $perPage) );

    if ($_GET["category"])
      $s->AddWhere(sprintf_esc("category='%s'",$_GET["category"]));
    //echo $s->GetQuery();

    $this->topics = $s->performWithCalcRows( $this->count );
    //PouetCollectPlatforms($this->prods);

    //$this->maxtopics = SQLLib::SelectRow("SELECT MAX(views) as m FROM prods")->m;
  }
コード例 #16
0
ファイル: box-bbs-open.php プロジェクト: neodyme60/pouet2.0
  function ParsePostMessage($post)
  {
    global $currentUser;
    if (!$currentUser)
      return "you have to be logged in!";

    if (!$currentUser->CanPostInBBS())
      return "not allowed lol.";

    $message = trim($post["message"]);
    if (!$message)
      return "not too meaningful, is it...";

    $title = trim($post["topic"]);
    if (strlen($title) < 2)
      return "not too meaningful, is it...";

    $r = SQLLib::SelectRow(sprintf_esc("SELECT id FROM bbs_topics where topic='%s'",$title));
    if ($r)
      return "DOUBLEPOST == ROB IS JARIG";

  	$a = array();
  	$a["topic"] = $title;
  	$a["category"] = $post["category"];
  	$a["userfirstpost"] = $a["userlastpost"] = get_login_id();
  	$a["firstpost"] = $a["lastpost"] = date("Y-m-d H:i:s");

    $id = SQLLib::InsertRow("bbs_topics",$a);

  	$a = array();
  	$a["added"] = date("Y-m-d H:i:s");
  	$a["author"] = get_login_id();
  	$a["post"] = $message;
  	$a["topic"] = $id;

    SQLLib::InsertRow("bbs_posts",$a);

    @unlink("cache/pouetbox_latestbbs.cache");

    return "";

  }
コード例 #17
0
  function Commit($data)
  {
    global $currentUser;

    $req = SQLLib::SelectRow(sprintf_esc("select itemID,requestType,requestBlob,approved from modification_requests where id = %d",$data["requestID"]));
    if ($req->approved !== NULL)
      return array("this request was already processed");
      
    if ($data["requestDeny"])
    {
      $a = array();
      $a["gloperatorID"] = $currentUser->id;
      $a["approved"] = 0;
      $a["comment"] = $data["comment"];
      $a["approveDate"] = date("Y-m-d H:i:s");
      SQLLib::UpdateRow("modification_requests",$a,"id=".(int)$data["requestID"]);
      return array();
    }
    
    $reqData = unserialize($req->requestBlob);
    global $REQUESTTYPES;
    if ($REQUESTTYPES[$req->requestType])
    {
      $errors = $REQUESTTYPES[$req->requestType]::Process($req->itemID,$reqData);
      if ($errors) return $errors;

      gloperator_log( $REQUESTTYPES[$req->requestType]::GetItemType(), $req->itemID, $req->requestType, $reqData );
    }
    else
    {
      return array("no such request type!");
    }

    $a = array();
    $a["gloperatorID"] = $currentUser->id;
    $a["approved"] = 1;
    $a["approveDate"] = date("Y-m-d H:i:s");
    SQLLib::UpdateRow("modification_requests",$a,"id=".(int)$data["requestID"]);

    return array();
  }
コード例 #18
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();
 }
コード例 #19
0
ファイル: login.php プロジェクト: neodyme60/pouet2.0
    $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" ) );
  
}
catch(SceneID3Exception $e) 
{
	redirect("error.php?e=".rawurlencode( $e->GetMessage() ));
}

?>
コード例 #20
0
ファイル: pouet-user.php プロジェクト: neodyme60/pouet2.0
  function GetSceneIDData( $cached = true )
  {
    if ($cached)
    {
      if (time() - strtotime( $this->sceneIDLastRefresh ) < 60 * 60 * 12)
      {
        if ($this->sceneIDData)
          return unserialize( $this->sceneIDData );
      }
    }

    /*

    if ((int)$rv["returnCode"] == 10)
    {
      //if ($cached)
      return $rv["user"];
    }
    else
    {
      return NULL;
    }
    */

    global $sceneID;
    try
    {
      //if (!get_login_id())
      {
        $sceneID->GetClientCredentialsToken();
      }
      $data = $sceneID->User( $this->id );
      {
        SQLLib::UpdateRow("users",array(
          "sceneIDLastRefresh"=>date("Y-m-d H:i:s"),
          "sceneIDData"=>serialize($data["user"])
        ),sprintf_esc("id=%d",$this->id));
      }

      return $data;
    }
    catch(SceneID3Exception $e)
    {
      return die($e->getMessage());
    }
  }
コード例 #21
0
ファイル: orm.inc.php プロジェクト: neodyme60/pouet2.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);
 }
コード例 #22
0
ファイル: topic.php プロジェクト: neodyme60/pouet2.0
<?
require_once("bootstrap.inc.php");
require_once("include_pouet/box-bbs-post.php");
require_once("include_pouet/box-modalmessage.php");

$POSTS_PER_PAGE = max(1,get_setting("topicposts"));

if ($_GET["post"]) // setting-independent post lookup
{
  $topicID = SQLLib::SelectRow(sprintf_esc("select topic from bbs_posts where id = %d",$_GET["post"]))->topic;
  if ($topicID)
  {
    $inner = sprintf_esc("select id, @rowID:=@rowID+1 as rowID from bbs_posts, (SELECT @rowID:=0) as init where topic = %d",$topicID);
    $row = SQLLib::SelectRow(sprintf_esc("select * from (".$inner.") as t where id = %d",$_GET["post"]));

    redirect(sprintf("topic.php?which=%d&page=%d#c%d",$topicID,(int)(($row->rowID - 1) / $POSTS_PER_PAGE) + 1,$_GET["post"]));
    exit();
  }
}

class PouetBoxBBSView extends PouetBox {
  var $topic;
  var $posts;
  var $id;
  var $page;
  var $postcount;
  function PouetBoxBBSView($id) {
    parent::__construct();
    $this->uniqueID = "pouetbox_bbsview";
    $this->title = "comments";
    $this->id = (int)$id;
コード例 #23
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();
  }
コード例 #24
0
ファイル: party.php プロジェクト: neodyme60/pouet2.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);
  }
コード例 #25
0
ファイル: prod.php プロジェクト: neodyme60/pouet2.0
  function RenderAverage() {
    $p = "isok";
    if ($this->prod->voteavg < 0) $p = "sucks";
    if ($this->prod->voteavg > 0) $p = "rulez";
    echo "<ul id='avgstats'>";
    echo "<li><img src='".POUET_CONTENT_URL."gfx/".$p.".gif' alt='".$p."' />&nbsp;".sprintf("%.2f",$this->prod->voteavg)."</li>\n";
    $cdcs = count($this->userCDCs);
    if ($this->isPouetCDC) $cdcs++;
    if ($cdcs)
    {
      echo "<li><img src='".POUET_CONTENT_URL."gfx/titles/coupdecoeur.gif' alt='cdcs' />&nbsp;".$cdcs."</li>\n";
    }
    
    global $currentUser;
    if ($currentUser)
    {
      echo "<li>";
      echo "<form action='prod.php?which=".$this->prod->id."' method='post' id='watchlistFrm'>";
      $csrf = new CSRFProtect();
      $csrf->PrintToken();
      
      $row = SQLLib::SelectRow(sprintf_esc("select * from watchlist where prodID = %d and userID = %d",$this->prod->id,$currentUser->id));
      if ($row)
      {
        echo "<input type='hidden' name='wlAction' value='removeFromWatchlist'>";
        echo "<input type='submit' value='remove from watchlist' class='remove'/>";
      }
      else
      {
        echo "<input type='hidden' name='wlAction' value='addToWatchlist'>";
        echo "<input type='submit' value='add to watchlist' class='add'/>";
      }
      echo "</form>";
?>
<script type="text/javascript">
<!--
document.observe("dom:loaded",function(){
  $("watchlistFrm").observe("submit",function(e){
    e.stop();
    var opt = Form.serializeElements( $("watchlistFrm").select("input"), {hash:true} );
    opt["partial"] = true;
    new Ajax.Request( $("watchlistFrm").action, {
      method: "post",
      parameters: opt,
      onSuccess: function(transport) {
        if (transport.responseText.length)
        {
          fireSuccessOverlay( opt["wlAction"] == "addToWatchlist" ? "added to watchlist !" : "removed from watchlist !" );
          $("watchlistFrm").update( transport.responseText );
        }
        else
        {
          fireErrorOverlay();
        }
      }
    });
  });
});
//-->
</script>
<?
      echo "</li>\n";
    }
    
    echo "</ul>";
    printf("<div id='alltimerank'>alltime top: %s</div>",$this->prod->rank ? "#".(int)$this->prod->rank : "n/a");
  }
コード例 #26
0
ファイル: prod.xnfo.php プロジェクト: neodyme60/pouet2.0
if (count($prod->groups))
{
  $xml->demo->addChild("authors");
  foreach($prod->groups as $v)
    $xml->demo->authors->addChild("group",_html($v->name))->addAttribute("pouet_id",$v->id);
}

$xml->demo->addChild("support");
$xml->demo->support->addChild("configuration");
foreach($prod->platforms as $v)
  $xml->demo->support->configuration->addChild("platform",_html($v["name"]))->addAttribute("type",_html($v["slug"]));

$xml->demo->addChild("download");
$xml->demo->download->addChild("url",_html($prod->download))->addAttribute("type","download");

$downloads = SQLLib::SelectRows(sprintf_esc("select * from downloadlinks where prod = %d",$prod->id));
foreach($downloads as $v)
  $xml->demo->download->addChild("url",_html($v->link))->addAttribute("type",$v->type);


$shot = find_screenshot($prod->id);
if ($shot)
{
  $xml->demo->addChild("screenshot");
  $xml->demo->screenshot->addChild("url",_html(POUET_CONTENT_URL.$shot));
}

$dom = dom_import_simplexml($xml)->ownerDocument;
$dom->formatOutput = true;
echo $dom->saveXML();
コード例 #27
0
ファイル: search_suggest.php プロジェクト: neodyme60/pouet2.0
<?
require_once("bootstrap.inc.php");

$r = SQLLib::selectRows(sprintf_esc("select name,type,party_year from prods where name like '%%%s%%' order by views desc limit 10",_like($_GET["what"])));
$res[0] = $_GET["what"];
foreach($r as $o)
{
  $res[1][] = $o->name;
  $res[2][] = $o->type.($o->party_year?", ".$o->party_year:"");
}
header("Content-type: application/json; charset=utf-8");
echo json_encode($res);
?>
コード例 #28
0
<?
require_once("bootstrap.inc.php");

header("Content-type: application/json; charset=utf-8");

$sql = new SQLSelect();
$sql->AddField("party_compo");
$sql->AddTable("prods");
$sql->AddGroup("party_compo");
$sql->AddWhere(sprintf_esc("party=%d",$_GET["party"]));
$sql->AddWhere(sprintf_esc("party_year=%d",$_GET["year"]));

$r = SQLLib::selectRows( $sql->GetQuery() );

echo json_encode( array("compos"=>array_map(function($i){ return (int)$i->party_compo; },$r)) );
?>
コード例 #29
0
ファイル: ajax_users.php プロジェクト: neodyme60/pouet2.0
<?
require_once("bootstrap.inc.php");

header("Content-type: application/json; charset=utf-8");

$sql = new SQLSelect();
$sql->AddField("id");
$sql->AddField("nickname as name");
$sql->AddField("avatar");
$sql->AddField("glops");
$sql->AddTable("users");

$r = array();
if ($_POST["search"])
{
  $sql->AddWhere(sprintf_esc("nickname like '%%%s%%'",_like($_POST["search"])));
  $sql->AddOrder(sprintf_esc("if(nickname='%s',1,2), nickname, lastLogin DESC",$_POST["search"]));
  $sql->SetLimit(10);
  $r = SQLLib::selectRows( $sql->GetQuery() );
}
else if ($_POST["id"])
{
  $sql->AddWhere(sprintf_esc("id = %d",$_POST["id"]));
  $sql->SetLimit(1);
  $r = SQLLib::selectRows( $sql->GetQuery() );
}
echo json_encode($r);
?>
コード例 #30
0
$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));
  }
}

$data = $s->perform();
PouetCollectPlatforms($data);

$rss = new PouetRSS();

foreach($data as $item)
{
  $rss->AddItem(array(
    "title"       => $item->name . ($item->groups ? " by ".$item->RenderGroupsPlain() : ""),
    "pouet:title" => $item->name,
    "pouet:group" => array_map(function($i){ return $i->name; },$item->groups),
    "pouet:party" => array_map(function($i){ return trim($i->party->name." ".$i->year); },$item->placings),