function PouetBoxSubmitProd() { parent::__construct(); $this->uniqueID = "pouetbox_submitprod"; $this->title = "submit a prod!"; $this->formifier = new Formifier(); $this->fields = array(); $row = SQLLib::selectRow("DESC prods type"); preg_match_all("/'([^']+)'/",$row->Type,$m); $this->types = $m[1]; global $COMPOTYPES; $this->compos = $COMPOTYPES; $this->compos[0] = ""; asort($this->compos); $this->ranks = array(0=>""); $this->ranks[97] = "disqualified"; $this->ranks[98] = "not applicable"; $this->ranks[99] = "not shown"; for ($x=1; $x<=96; $x++) $this->ranks[$x] = $x; $this->years = array(""); for ($x=date("Y"); $x>=POUET_EARLIEST_YEAR; $x--) $this->years[$x] = $x; $this->yearsFuture = array(""); for ($x=date("Y")+2; $x>=POUET_EARLIEST_YEAR; $x--) $this->yearsFuture[$x] = $x; }
function PouetBoxBBSTopicList() { parent::__construct(); $this->uniqueID = "pouetbox_bbslist"; $row = SQLLib::selectRow("DESC bbs_topics category"); preg_match_all("/'([^']+)'/",$row->Type,$m); $this->categories = $m[1]; }
function PouetBoxBBSOpen() { parent::__construct(); $this->uniqueID = "pouetbox_bbsopen"; $this->title = "open a new bbs thread"; $row = SQLLib::selectRow("DESC bbs_topics category"); preg_match_all("/'([^']+)'/",$row->Type,$m); $this->categories = $m[1]; }
function LoadFromDB() { global $currentUser; $customizerJSON = SQLLib::selectRow(sprintf_esc("select customizerJSON from usersettings where id = %d",$currentUser->id))->customizerJSON; $customizer = json_decode($customizerJSON,true); if (!$customizer["frontpage"]) { require_once("include_pouet/default_usersettings.php"); $customizer = json_decode($DEFAULT_USERSETTINGS->customizerJSON, true); } $this->boxes = $customizer["frontpage"]; }
function PouetBoxTopList() { parent::__construct(); $this->uniqueID = "pouetbox_toplist"; $this->formifier = new Formifier(); $row = SQLLib::selectRow("DESC prods type"); preg_match_all("/'([^']+)'/",$row->Type,$m); $this->types = array(); $this->types[""] = "- none - "; foreach($m[1] as $v) $this->types[$v] = $v; }
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]; }
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; }
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]; }
function PouetBoxAdminEditFAQ( $id ) { parent::__construct(); $this->uniqueID = "pouetbox_admineditfaq"; $this->title = "edit faq"; $this->id = $id; $this->formifier = new Formifier(); $row = SQLLib::selectRow("DESC faq category"); preg_match_all("/'([^']+)'/",$row->Type,$m); $this->categories = $m[1]; $this->fields = array( "category"=>array( "name"=>"category", "type"=>"select", "fields"=>$this->categories, ), "question"=>array( "name"=>"question", ), "answer"=>array( "name"=>"answer", "type"=>"textarea", ), "deprecated"=>array( "name"=>"is hidden?", "type"=>"checkbox", ), ); if ($_POST) { foreach($_POST as $k=>$v) if ($this->fields[$k]) $this->fields[$k]["value"] = $v; } }
function Load() { $row = SQLLib::selectRow("DESC prods type"); preg_match_all("/'([a-zA-Z0-9\s_\-]+)'/",$row->Type,$m); $this->types = $m[1]; }
function performWithCalcRows(&$count) { $objects = array(); $sql = $this->GetQuery(); $sql = preg_replace("/^SELECT/", "SELECT SQL_CALC_FOUND_ROWS ", $sql); $rows = SQLLib::selectRows($sql); foreach ($rows as $row) { $object = new stdClass(); $this->populate($object, $this->root, $row); foreach (get_object_vars($row) as $k => $v) { $object->{$k} = $v; } if ($this->root->class) { $class = $this->root->class; $field = $class::getPrimaryKey(); $objects[$object->{$field}] = $object; } else { $objects[] = $object; } } $row = SQLLib::selectRow("SELECT FOUND_ROWS() as f"); $count = (int) $row->f; return $objects; }
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); }
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); }
function PouetBoxAdminEditProdSceneorg( $prod ) { parent::__construct(); $this->uniqueID = "pouetbox_prodeditprodsceneorg"; $this->prod = $prod; $this->title = "scene.org recommendations"; $this->data = SQLLib::SelectRows(sprintf_esc("select * from sceneorgrecommended where prodid = %d",$this->prod->id)); $this->headers = array("type","category"); $row = SQLLib::selectRow("DESC sceneorgrecommended type"); preg_match_all("/'([^']+)'/",$row->Type,$m); $this->types = $m[1]; $row = SQLLib::selectRow("DESC sceneorgrecommended category"); preg_match_all("/'([^']+)'/",$row->Type,$m); $this->categories = $m[1]; }
<? require_once("bootstrap.inc.php"); header("Content-type: application/json; charset=utf-8"); $sql = sprintf_esc("select * from comments where id = %d limit 1",$_POST["id"]); $r = SQLLib::selectRow($sql); echo json_encode($r); ?>
static function ValidateRequest($input,&$output) { if (!SQLLib::selectRow(sprintf_esc("select * from credits where prodID = %d and id = %d",$_REQUEST["prod"],$input["creditID"]))) return array("nice try :|"); if (!$input["reason"]) return array("no deleting without a good reason !"); $output["creditID"] = $input["creditID"]; $output["reason"] = $input["reason"]; return array(); }