87 changes: 87 additions & 0 deletions admin_group_edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?
include_once("bootstrap.inc.php");
include_once("include_pouet/box-modalmessage.php");
include_once("include_pouet/box-group-submit.php");

if ($currentUser && !$currentUser->CanEditItems())
{
redirect("groups.php?which=".(int)$_GET["which"]);
exit();
}

class PouetBoxAdminEditGroup extends PouetBoxSubmitGroup
{
function PouetBoxAdminEditGroup( $id )
{
parent::__construct();

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

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

$this->title = "edit this group: "._html($this->group->name);
}
function Commit($data)
{
global $groupID;

$a = array();
$a["name"] = trim($data["name"]);
$a["acronym"] = $data["acronym"];
$a["web"] = $data["website"];
$a["csdb"] = $data["csdbID"];
$a["zxdemo"] = $data["zxdemoID"];
SQLLib::UpdateRow("groups",$a,"id=".$this->id);

gloperator_log( "group", $this->id, "group_edit" );

return array();
}
function LoadFromDB()
{
parent::LoadFromDB();

$group = $this->group;

$this->fields["name"]["value"] = $group->name;
$this->fields["acronym"]["value"] = $group->acronym;
$this->fields["website"]["value"] = $group->web;
$this->fields["csdbID"]["value"] = $group->csdb;
$this->fields["zxdemoID"]["value"] = $group->zxdemo;
}
}

$form = new PouetFormProcessor();

$form->SetSuccessURL( "groups.php?which=".(int)$_GET["which"], true );

$box = new PouetBoxAdminEditGroup( $_GET["which"] );
$form->Add( "group", $box );

if ($currentUser && $currentUser->CanEditItems())
$form->Process();

$TITLE = "edit a group: "._html($box->group->name);

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

if (get_login_id())
{
$form->Display();
}
else
{
include_once("include_pouet/box-login.php");
$box = new PouetBoxLogin();
$box->Render();
}

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
80 changes: 80 additions & 0 deletions admin_party_edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?
include_once("bootstrap.inc.php");
include_once("include_pouet/box-modalmessage.php");
include_once("include_pouet/box-party-submit.php");

if ($currentUser && !$currentUser->CanEditItems())
{
redirect("party.php?which=".(int)$_GET["which"]);
exit();
}

class PouetBoxAdminEditParty extends PouetBoxSubmitParty
{
function PouetBoxAdminEditParty( $id )
{
parent::__construct();

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

$this->party = PouetParty::Spawn( $this->id );

$this->title = "edit this party: "._html( $this->party->name );
}
function Commit($data)
{
global $partyID;

$a = array();
$a["name"] = trim($data["name"]);
$a["web"] = $data["website"];
SQLLib::UpdateRow("parties",$a,"id=".$this->id);

gloperator_log( "party", $this->id, "party_edit" );

return array();
}
function LoadFromDB()
{
parent::LoadFromDB();

$this->fields["name"]["value"] = $this->party->name;
$this->fields["website"]["value"] = $this->party->web;
}
}


$form = new PouetFormProcessor();

$form->SetSuccessURL( "party.php?which=".(int)$_GET["which"], true );

$box = new PouetBoxAdminEditParty( $_GET["which"] );
$form->Add( "party", $box );

if ($currentUser && $currentUser->CanEditItems())
$form->Process();

$TITLE = "edit a party: "._html( $box->party->name );

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

if (get_login_id())
{
$form->Display();
}
else
{
include_once("include_pouet/box-login.php");
$box = new PouetBoxLogin();
$box->Render();
}

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
108 changes: 108 additions & 0 deletions admin_party_edition_edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?
include_once("bootstrap.inc.php");
include_once("include_pouet/box-modalmessage.php");
include_once("include_pouet/box-party-edition-submit.php");

if ($currentUser && !$currentUser->CanEditItems())
{
redirect("party.php?which=".(int)$_GET["which"]."&when=".(int)$_GET["when"]);
exit();
}

class PouetBoxAdminEditPartyEdition extends PouetBoxSubmitPartyEdition
{
function PouetBoxAdminEditPartyEdition( $id, $year )
{
parent::__construct();

$this->id = $id;
$this->year = $year;

$this->party = PouetParty::Spawn( $this->id );

$this->title = sprintf("edit this party: %s %04d",_html($this->party->name),$this->year);
}
function Commit($data)
{
global $partyID;

$sql = array();
$sql["download"] = $data["download"];
$sql["csdb"] = $data["csdbID"];
$sql["slengpung"] = $data["slengpungID"];
$sql["zxdemo"] = $data["zxdemoID"];
$sql["artcity"] = $data["artcity"];

$links = SQLLib::selectRow(sprintf_esc("select * from partylinks where party = %d and year = %d",$this->id,$this->year));
if ($links)
{
SQLLib::UpdateRow("partylinks",$sql,sprintf_esc("party = %d and year = %d",$this->id,$this->year));
}
else
{
$sql["party"] = $this->id;
$sql["year"] = $this->year;
SQLLib::InsertRow("partylinks",$sql);
}

if (is_uploaded_file($_FILES["results"]["tmp_name"]))
{
move_uploaded_file($_FILES["results"]["tmp_name"],get_local_partyresult_path($this->id,$this->year));
}

gloperator_log( "party", (int)$this->id, "party_edit_links", array("year"=>$this->year) );

return array();
}
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["artcity"]["value"] = $this->links->artcity;

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

$form = new PouetFormProcessor();

$form->SetSuccessURL( "party.php?which=".(int)$_GET["which"]."&amp;when=".(int)$_GET["when"], true );

$box = new PouetBoxAdminEditPartyEdition( $_GET["which"],$_GET["when"] );
$form->Add( "partyyear", $box );

if ($currentUser && $currentUser->CanEditItems())
$form->Process();

$TITLE = sprintf("edit a party edition: %s %04d",_html($box->party->name),$box->year);

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

if (get_login_id())
{
$form->Display();
}
else
{
include_once("include_pouet/box-login.php");
$box = new PouetBoxLogin();
$box->Render();
}

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
878 changes: 878 additions & 0 deletions admin_prod_edit.php

Large diffs are not rendered by default.

144 changes: 144 additions & 0 deletions admin_topic_edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?
include_once("bootstrap.inc.php");
include_once("include_pouet/box-modalmessage.php");
include_once("include_pouet/box-group-submit.php");

if ($currentUser && !$currentUser->CanEditBBS())
{
redirect("topic.php?which=".(int)$_GET["which"]);
exit();
}

class PouetBoxAdminEditTopic extends PouetBox
{
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();
}

function ValidateInput( $data )
{
$errormessage = array();
return $errormessage;
}
function Validate( $data )
{
global $groupID,$currentUser;

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

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

return array();
}
function Commit($data)
{
global $groupID;

$a = array();
$a["category"] = $data["category"];
$a["closed"] = $data["closed"]=="on";
SQLLib::UpdateRow("bbs_topics",$a,"id=".$this->topic->id);

gloperator_log( "topic", $this->topic->id, "topic_edit" );

return array();
}

function ParsePostMessage( $data )
{
global $groupID,$currentUser;

$errormessages = $this->Validate($data);
if (count($errormessages))
return $errormessages;

return $this->Commit($data);
}
function LoadFromDB()
{
global $THREAD_CATEGORIES;

$this->fields = array(
"category"=>array(
"name"=>"topic category",
"type"=>"select",
"assoc"=>true,
"fields"=>$THREAD_CATEGORIES,
"value"=>$this->topic->category,
),
"closed"=>array(
"name"=>"topic closed",
"type"=>"checkbox",
"value"=>$this->topic->closed,
),
);
foreach($_POST as $k=>$v)
if ($this->fields[$k])
$this->fields[$k]["value"] = $v;
}

function Render()
{
global $currentUser;
if (!$currentUser)
return;

if (!$currentUser->CanSubmitItems())
return;

echo "\n\n";
echo "<div class='pouettbl' id='".$this->uniqueID."'>\n";

echo " <h2>".$this->title."</h2>\n";
echo " <div class='content'>\n";
$this->formifier->RenderForm( $this->fields );
echo " </div>\n";

echo " <div class='foot'><input type='submit' value='Submit' /></div>";
echo "</div>\n";
}
};

$form = new PouetFormProcessor();

$form->SetSuccessURL( "topic.php?which=".(int)$_GET["which"], true );

$box = new PouetBoxAdminEditTopic( $_GET["which"] );
$form->Add( "topic", $box );

if ($currentUser && $currentUser->CanEditItems())
$form->Process();

$TITLE = "edit a topic: "._html($box->topic->topic);

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

if (get_login_id())
{
$form->Display();
}
else
{
include_once("include_pouet/box-login.php");
$box = new PouetBoxLogin();
$box->Render();
}

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
196 changes: 196 additions & 0 deletions admin_user_edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<?
include_once("bootstrap.inc.php");
include_once("include_pouet/box-modalmessage.php");

if ($currentUser && !$currentUser->IsAdministrator())
{
redirect("user.php?who=".(int)$_GET["who"]);
exit();
}

class PouetBoxAdminEditUser extends PouetBox
{
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 Commit($data)
{
$a = array();
if (array_search($data["level"],$this->levels)!==false)
$a["level"] = $data["level"];
SQLLib::UpdateRow("users",$a,"id=".(int)$this->user->id);
}
function LoadFromDB()
{
$this->fields = array(
"name"=>array(
"name"=>"sceneID login",
"type" => "static",
"value" => $this->sceneID["login"],
),
"lastLogin"=>array(
"name"=>"last logged in",
"type" => "static",
"value" => $this->user->lastLogin . " (".dateDiffReadable(time(),$this->user->lastLogin)." ago)",
),
"lastIP"=>array(
"name"=>"last IP",
"type" => "static",
"value" => "<a href='admin_user_edit.php?ip=".rawurlencode($this->user->lastip)."'>"._html($this->user->lastip)."</a> ("._html($this->user->lasthost).") [<a href='http://www.geobytes.com/IpLocator.htm?GetLocation&amp;IpAddress="._html($this->user->lastip)."'>geoip</a>]",
),
"level"=>array(
"name"=>"level",
"type" => "select",
"value" => $this->user->level,
"fields" => $this->levels,
),
);
}
function Render()
{
global $currentUser;
if (!$currentUser)
return;

if (!$currentUser->IsAdministrator())
return;

echo "\n\n";
echo "<div class='pouettbl' id='".$this->uniqueID."'>\n";

echo " <h2>".$this->title."</h2>\n";
echo " <div class='content'>\n";
$this->formifier->RenderForm( $this->fields );
echo " </div>\n";

echo " <div class='foot'><input type='submit' value='Submit' /></div>";
echo "</div>\n";
}
}

///////////////////////////////////////////////////////////////////////////////

class PouetBoxAdminUserNicks extends PouetBox
{
function PouetBoxAdminUserNicks( $id )
{
parent::__construct();

$this->id = (int)$id;
$this->title = "previous nicks";
}
function LoadFromDB()
{
$this->nicks = SQLLib::SelectRows(sprintf_esc("select * from oldnicks where user = %d",$this->id));
}
function RenderBody()
{
echo "<ul class='boxlist'>\n";
foreach($this->nicks as $n) {
echo "<li>\n";
echo _html( $n->nick );
echo "</li>\n";
}
echo "</ul>\n";
}
}

///////////////////////////////////////////////////////////////////////////////

class PouetBoxAdminUserIPs extends PouetBox
{
function PouetBoxAdminUserIPs( $ip )
{
parent::__construct();

$this->ip = $ip;
$this->title = "users using "._html($ip);
}
function LoadFromDB()
{
$s = new BM_Query("users");
$s->AddOrder("users.glops desc");
$s->AddWhere(sprintf_esc("lastip = '%s'",$this->ip));
$this->nicks = $s->perform();
}
function RenderBody()
{
echo "<ul class='boxlist boxlisttable'>\n";
foreach($this->nicks as $p) {
echo "<li>\n";
echo "<span>\n";
echo $p->PrintLinkedAvatar()." ";
echo $p->PrintLinkedName()." ";
echo "[<a href='admin_user_edit.php?who=".(int)$p->id."'>edit</a>]";
echo "</span>\n";
echo "<span>";
echo $p->glops." glöps";
echo "</span>\n";
echo "<span>";
echo $p->level;
echo "</span>\n";
echo "</li>\n";
}
echo "</ul>\n";
}
}

$form = new PouetFormProcessor();

if (is_numeric($_GET["who"]))
{
$form->SetSuccessURL( "user.php?who=".(int)$_GET["who"]."#success", true );

$box = new PouetBoxAdminEditUser( $_GET["who"] );
$form->Add( "user", $box );
$form->Add( "userNicks", new PouetBoxAdminUserNicks( $_GET["who"] ) );
}
else if ($_GET["ip"])
{
$form->SetSuccessURL( "user.php?ip=".rawurlencode($_GET["ip"])."#success", true );

$form->Add( "userIP", new PouetBoxAdminUserIPs( $_GET["ip"] ) );
}

if ($currentUser && $currentUser->IsAdministrator())
$form->Process();

$TITLE = "edit this user: "._html( $box->user->nickname );

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

if (get_login_id())
{
$form->Display();
}
else
{
include_once("include_pouet/box-login.php");
$box = new PouetBoxLogin();
$box->Render();
}

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
10 changes: 10 additions & 0 deletions ajax_bbspost.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?
include_once("bootstrap.inc.php");

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

$sql = sprintf_esc("select * from bbs_posts where id = %d limit 1",$_POST["id"]);
$r = SQLLib::selectRow($sql);

echo json_encode($r);
?>
16 changes: 16 additions & 0 deletions ajax_boards.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?
include_once("bootstrap.inc.php");

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

$sql = "";
if ($_POST["search"])
$sql = sprintf_esc("select id, name from bbses where name like '%%%s%%' order by name limit 10",addcslashes($_POST["search"],"%_"),addcslashes($_POST["search"],"%_"));
else if ($_POST["id"])
$sql = sprintf_esc("select id, name from bbses where id = %d limit 1",$_POST["id"]);

if ($sql)
$r = SQLLib::selectRows($sql);

echo json_encode($r);
?>
16 changes: 16 additions & 0 deletions ajax_groups.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?
include_once("bootstrap.inc.php");

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

$sql = "";
if ($_POST["search"])
$sql = sprintf_esc("select id, name from groups where name like '%%%s%%' or acronym like '%%%s%%' order by name limit 10",addcslashes($_POST["search"],"%_"),addcslashes($_POST["search"],"%_"));
else if ($_POST["id"])
$sql = sprintf_esc("select id, name from groups where id = %d limit 1",$_POST["id"]);

if ($sql)
$r = SQLLib::selectRows($sql);

echo json_encode($r);
?>
16 changes: 16 additions & 0 deletions ajax_parties.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?
include_once("bootstrap.inc.php");

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

$sql = "";
if ($_POST["search"])
$sql = sprintf_esc("select id, name from parties where name like '%%%s%%' order by name limit 10",addcslashes($_POST["search"],"%_"),addcslashes($_POST["search"],"%_"));
else if ($_POST["id"])
$sql = sprintf_esc("select id, name from parties where id = %d limit 1",$_POST["id"]);

if ($sql)
$r = SQLLib::selectRows($sql);

echo json_encode($r);
?>
16 changes: 16 additions & 0 deletions ajax_prods.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?
include_once("bootstrap.inc.php");

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

$sql = "";
if ($_POST["search"])
$sql = sprintf_esc("select id, name from prods where name like '%%%s%%' order by views desc, name limit 10",addcslashes($_POST["search"],"%_"),addcslashes($_POST["search"],"%_"));
else if ($_POST["id"])
$sql = sprintf_esc("select id, name from prods where id = %d limit 1",$_POST["id"]);

if ($sql)
$r = SQLLib::selectRows($sql);

echo json_encode($r);
?>
202 changes: 202 additions & 0 deletions autocompleter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
Autocompleter = Class.create({
initialize: function(originalElement,options)
{
this.originalElement = originalElement;
this.options = Object.extend({
keyValue: true,
dropdown: false,
lockSelect: true,
},options || {});
var instance = this;

this.originalElement.hide();
var parent = $(originalElement.parentNode);

this.autoCompleteList = new Element("ul",{"class":"autocompleteList"});
this.autoCompleteList.hide();
parent.insert(this.autoCompleteList);

if (this.options.lockSelect)
{
this.finalSelection = new Element("div",{"class":"autocompleteSelection","title":"click to edit!","style":"cursor:pointer"});
this.finalSelection.hide();
parent.insert(this.finalSelection);
}

this.searchBox = new Element("input",{"class":"autocompleteSearch","style":"position:relative"});
parent.insert( this.searchBox );

if (this.options.dropdown)
{
this.dropButton = new Element("button",{"class":"autocompleteDropbutton"}).update("&#x25BC;");
this.dropButton.observe("click",function(e){
e.stop();
$$(".autocompleteList").invoke("hide");
instance.showAutocomplete("");
});
document.body.observe("click",function(e){
if ( e.findElement(".autocompleteDropbutton") != instance.dropButton
&& e.findElement(".autocompleteSearch") != instance.searchBox
&& e.findElement(".autocompleteList") != instance.autoCompleteList)
{
instance.autoCompleteList.hide();
}
});
parent.insert( this.dropButton );
}

if (this.finalSelection)
{
this.finalSelection.observe("click",function(){
instance.originalElement.value = "";
instance.finalSelection.hide();
instance.searchBox.show();
});
}
this.keyboardSelection = -1;
this.lastSearch = "";

//this.searchBox.observe("blur",function(){
// instance.autoCompleteList.hide();
//})
this.searchBox.observe("keydown",function(e){
var items = instance.autoCompleteList.select("li");
if (e.keyCode == Event.KEY_UP)
{
e.stop();
if (instance.keyboardSelection > 0)
{
instance.keyboardSelection--;
items.invoke("removeClassName","selected");
items[instance.keyboardSelection].addClassName("selected");
}
return;
}
if (e.keyCode == Event.KEY_DOWN)
{
e.stop();
if (instance.keyboardSelection < items.length - 1)
{
instance.keyboardSelection++;
items.invoke("removeClassName","selected");
items[instance.keyboardSelection].addClassName("selected");
}
return;
}
if (e.keyCode == Event.KEY_RETURN)
{
e.stop();
if (0 <= instance.keyboardSelection && instance.keyboardSelection < items.length)
{
instance.selectListItem( items[instance.keyboardSelection] );
}
return;
}
if (e.keyCode == Event.KEY_ESC)
{
e.stop();
instance.selectListItem( null );
return;
}
});
this.searchBox.observe("keyup",function(e){
if (!instance.options.keyValue)
{
instance.originalElement.value = instance.searchBox.value;
}
if (e.keyCode == Event.KEY_RETURN ||
e.keyCode == Event.KEY_ESC ||
e.keyCode == Event.KEY_UP ||
e.keyCode == Event.KEY_DOWN)
{
e.stop();
return
}
var items = instance.autoCompleteList.select("li");
if (instance.searchBox.value.length < 1)
{
instance.autoCompleteList.hide();
return;
}
if (this.lastSearch == instance.searchBox.value)
return;
this.lastSearch = instance.searchBox.value;
instance.showAutocomplete(instance.searchBox.value);
},this);

if (this.originalElement.value.length > 0)
{
new Ajax.Request(options.dataUrl,{
method: "post",
parameters: $H({"id":this.originalElement.value}).toQueryString(),
onSuccess: function(transport)
{
instance.select( transport.responseJSON[0].id, transport.responseJSON[0].name );
},
});
}
},
selectListItem: function(li)
{
this.autoCompleteList.hide();
if (li)
{
var item = li.retrieve("item");

this.select( item.id, item.name );
}
else
{
if (this.finalSelection)
this.finalSelection.hide();
this.searchBox.show();
}
},
select: function( id, name )
{
this.originalElement.value = this.options.keyValue ? id : name;
this.searchBox.value = name;
if (this.finalSelection)
{
this.finalSelection.update("<span>" + name.escapeHTML() + "</span> (click to change)");
this.finalSelection.show();
this.searchBox.hide();
}

if (this.options.onSelectItem)
this.options.onSelectItem(id);
},
showAutocomplete: function( term )
{
var instance = this;
new Ajax.Request(this.options.dataUrl,{
method: "post",
parameters: $H({"search":term}).toQueryString(),
onSuccess: function(transport)
{
instance.keyboardSelection = -1;
var results = $A( transport.responseJSON );
if (!results.length) {
instance.autoCompleteList.hide();
return;
}
instance.autoCompleteList.show();
instance.autoCompleteList.update("");

instance.autoCompleteList.setStyle({
"top" :(instance.searchBox.cumulativeOffset().top + instance.searchBox.getLayout().get("height") + 4) + "px",
"left":instance.searchBox.cumulativeOffset().left + "px",
"width":instance.searchBox.getLayout().get("width") + "px",
});
results.each(function(item){
var li = new Element("li").update(item.name.escapeHTML());
li.store("item",item);
li.observe("click",function(){
instance.selectListItem(li);
});
instance.autoCompleteList.insert(li);
});
}
});
}
});
178 changes: 178 additions & 0 deletions bbs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<?
include_once("bootstrap.inc.php");
include_once("include_pouet/box-bbs-open.php");

class PouetBoxBBSTopicList extends PouetBox
{
var $id;
var $group;

function PouetBoxBBSTopicList() {
parent::__construct();
$this->uniqueID = "pouetbox_bbslist";
}

function BuildURL( $param ) {
$query = array_merge($_GET,$param);
unset( $query["reverse"] );
if($param["order"] && $_GET["order"] == $param["order"] && !$_GET["reverse"])
$query["reverse"] = 1;
return _html("bbs.php?" . http_build_query($query));
}
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 "lastpost": $s->AddOrder("bbs_topics.lastpost ".$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;
//default: $s->AddOrder("prods.date DESC"); $s->AddOrder("prods.quand DESC"); break;
}
$s->AddOrder("bbs_topics.lastpost ".$dir);
$s->SetLimit( $perPage, (int)(($this->page - 1) * $perPage) );

//echo $s->GetQuery();

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

//$this->maxtopics = SQLLib::SelectRow("SELECT MAX(views) as m FROM prods")->m;
}

function Render() {
global $THREAD_CATEGORIES;

echo "<table id='".$this->uniqueID."' class='boxtable pagedtable'>\n";
$headers = array(
"firstpost"=>"started",
"userfirstpost"=>"by",
"category"=>"category",
"topic"=>"bbs topic",
"count"=>"replies",
"lastpost"=>"last post",
"userlastpost"=>"by",
);
echo "<tr><th colspan='".count($headers)."'><h2>the oldskool pouët.net bbs</h2></th></tr>\n";
echo "<tr class='sortable'>\n";
foreach($headers as $key=>$text)
{
$out = sprintf("<th><a href='%s' class='%s%s' id='%s'>%s</a></th>\n",
$this->BuildURL(array("order"=>$key)),$_GET["order"]==$key?"selected":"",($_GET["order"]==$key && $_GET["reverse"])?" reverse":"","prodlistsort_".$key,$text);
if ($key == "type" || $key == "name") $out = str_replace("</th>","",$out);
if ($key == "platform" || $key == "name") $out = str_replace("<th>"," ",$out);
echo $out;
}
echo "</tr>\n";

foreach ($this->topics as $p) {
echo "<tr>\n";

echo " <td>";
echo $p->firstpost;
echo "</td>\n";

echo " <td>";
echo $p->firstuser->PrintLinkedAvatar()." ";
echo $p->firstuser->PrintLinkedName();
echo "</td>\n";

echo " <td>".$THREAD_CATEGORIES[$p->category]."</td>\n";

echo " <td class='topic'>";
echo "<a href='topic.php?which=".(int)$p->id."'>"._html($p->topic)."</a>";
echo "</td>\n";

echo " <td>".$p->count."</td>\n";

echo " <td title='"._html(dateDiffReadable(time(),$p->lastpost))." ago'>";
echo $p->lastpost;
echo "</td>\n";

echo " <td>";
echo $p->lastuser->PrintLinkedAvatar()." ";
echo $p->lastuser->PrintLinkedName();
echo "</td>\n";

echo "</tr>\n";
}

$perPage = get_setting("bbsbbstopics");

echo "<tr>\n";
echo "<td class='nav' colspan=".(count($headers)).">\n";

$this->page = ((int)$_GET["page"] ? $_GET["page"] : 1);
if ($this->page > 1)
echo " <div class='prevpage'><a href='".$this->BuildURL(array("page"=>($this->page - 1)))."'>previous page</a></div>\n";
if ($this->page < ($this->count / $perPage))
echo " <div class='nextpage'><a href='".$this->BuildURL(array("page"=>($this->page + 1)))."'>next page</a></div>\n";

echo " <select name='page'>\n";
for ($x=1; $x<=($this->count / $perPage) + 1; $x++)
printf(" <option value='%d'%s>%d</option>\n",$x,$x==$this->page?" selected='selected'":"",$x);
echo " </select>\n";
echo " <input type='submit' value='Submit'/>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
return $s;
}
};

///////////////////////////////////////////////////////////////////////////////

$p = new PouetBoxBBSTopicList();
$p->Load();

$q = new PouetBoxBBSOpen();
$q->Load();

$TITLE = "BBS";
if ($p->page > 1)
$TITLE .= " :: page ".(int)$p->page;


include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";
echo "<form action='bbs.php' method='get'>\n";

foreach($_GET as $k=>$v)
if ($k != "type" && $k != "platform" && $k != "page")
echo "<input type='hidden' name='"._html($k)."' value='"._html($v)."'/>\n";

if($p) $p->Render();
echo "</form>\n";

if($q) $q->Render();

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");
?>
97 changes: 97 additions & 0 deletions board_nfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?
include_once("bootstrap.inc.php");

class PouetBoxBoardNfo extends PouetBox {
function PouetBoxBoardNfo() {
parent::__construct();
$this->uniqueID = "pouetbox_boardnfo";
$this->title = "board nfo";
}

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_bbs.name");
$s->AddTable("othernfos");
$s->SetLimit(1);
$s->attach(array("othernfos"=>"adder"),array("users as user"=>"id"));
$s->attach(array("othernfos"=>"refID"),array("bbses as bbs"=>"id"));
$s->AddWhere(sprintf_esc("othernfos.id=%d",$_GET["which"]));
$s->GetQuery();
list($this->nfo) = $s->perform();
}
function RenderHeader()
{
echo "\n\n";
echo "<div class='pouettbl asciiviewer' id='".$this->uniqueID."'>\n";
echo " <h2><big>"._html($this->nfo->name)."</big>";
echo "</h2>\n";
}
function RenderBody()
{
$title = "nfo added by "._html($this->nfo->user->nickname)." on "._html($this->nfo->added);
echo "<div class='content' title='".$title."'>\n";
if ($_GET["font"]=="none")
{
echo "<pre>";
$text = file_get_contents( get_local_bbsnfo_path( $_GET["which"] ) );
$enc = mb_detect_encoding( $text, "iso-8859-1,utf-8" );
$utf8 = mb_convert_encoding( $text, "utf-8", $enc );
echo _html( $utf8 );
echo "</pre>";
}
else
printf("<img src='img_ascii.php?boardnfo=%d&amp;font=%d' alt='nfo'/>\n",$_GET["which"],$_GET["font"]);
echo "</div>\n";
}
function RenderFooter()
{
global $currentUser;

echo " <div class='content' id='fontlist'>";
$fonts = array(
"none" => "html",
"1" => "dos 80*25",
"2" => "dos 80*50",
"3" => "rez's ascii",
"4" => "amiga medres",
"5" => "amiga hires",
);
foreach($fonts as $k=>$v)
$a[] = sprintf("<a href='board_nfo.php?which=%d&amp;font=%s'>%s</a>\n",$_GET["which"],$k,$v);
echo "[ ".implode(" | \n",$a)." ]";
echo " </div>";
echo " <div class='foot'>";
if ($currentUser && $currentUser->IsGloperator())
{
//printf("[ <a class='adminlink' href='admin_prod_edit.php?which=%d#files'>update nfo</a> ]\n",$_GET["which"]);
printf("[ <a class='adminlink' href='%s'>download nfo</a> ]\n",get_local_bbsnfo_path( $_GET["which"] ));
}
printf("[ <a href='board.php?which=%d'>back to the board</a> ]\n",$_GET["which"]);
echo " </div>";
echo "</div>";
}
};

$box = new PouetBoxBoardNfo();
$box->Load();

if ($box->nfo)
$TITLE = $box->nfo->name;

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

$box->Render();

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
352 changes: 352 additions & 0 deletions boards.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,352 @@
<?
include_once("bootstrap.inc.php");

class PouetBoxBoardMain extends PouetBox
{
var $id;
var $group;

function PouetBoxBoardMain($id) {
parent::__construct();
$this->uniqueID = "pouetbox_boardmain";
$this->id = (int)$id;

}

function LoadFromDB() {
$this->board = SQLLib::SelectRow(sprintf_esc("select * from bbses where id = %d",$this->id));

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

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

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

$s = new BM_Query("affiliatedbbses");
$s->AddField("affiliatedbbses.type");
$s->Attach(array("affiliatedbbses"=>"group"),array("groups as group"=>"id"));
$s->AddWhere(sprintf_esc("affiliatedbbses.bbs = %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();
}

function Render()
{
global $currentUser,$PLATFORMS;
echo "<div id='".$this->uniqueID."' class='pouettbl'>\n";
echo "<div id='boardname'>\n";
echo sprintf("<a href='boards.php?which=%d'>%s</a>",$this->id,_html($this->board->name));

if ($currentUser && $currentUser->CanEditItems())
{
printf("<div id='adminlinks'>");
//printf("[<a href='admin_board_edit.php?which=%d' class='adminlink'>edit</a>]\n",$this->id);
printf("</div>");
}
echo "</div>\n";

echo "<div id='body'>\n";
echo " <div>\n";

echo " <table>\n";
echo " <tr>\n";
echo " <td>sysop :</td>\n";
echo " <td>"._html($this->board->sysop)."</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>number :</td>\n";
echo " <td>"._html($this->board->phonenumber)."</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>platforms :</td>\n";
echo " <td>";

echo "<ul>";
foreach($this->platforms as $t)
echo "<li><a href='prodlist.php?platform[]=".rawurlencode($PLATFORMS[$t]["name"])."'><span class='platform os_".$PLATFORMS[$t]["slug"]."'>".$PLATFORMS[$t]["name"]."</span> ".$PLATFORMS[$t]["name"]."</a></li>\n";
echo "</ul>";

echo "</td>\n";
echo " </tr>\n";

if ($this->nfos)
{
echo " <tr>\n";
echo " <td>nfos :</td>\n";
echo " <td>";

$a = array(); $i = 1;
foreach($this->nfos as $t)
$a[] = sprintf("<a href='board_nfo.php?which=%d'>%d</a>",$t->id,$i++);
echo implode($a," ");

echo "</td>\n";
echo " </tr>\n";
}
echo " </table>\n";

echo " </div>\n";
echo " <div>\n";
echo " <table>\n";
if ($this->bbstros)
{
echo " <tr>\n";
echo " <td>bbstros :</td>\n";
echo " <td>";

echo "<ul>";
foreach($this->bbstros as $p)
echo "<li>".$p->RenderLink()." by ".$p->RenderGroupsLong()."</li>\n";
echo "</ul>";

echo "</td>\n";
echo " </tr>\n";
}
if ($this->groups)
{
echo " <tr>\n";
echo " <td>affiliations :</td>\n";
echo " <td>";

echo "<ul>";
foreach($this->groups as $g)
echo "<li>".$g->group->RenderLong()." ".$g->type."</li>\n";
echo "</ul>";

echo "</td>\n";
echo " </tr>\n";
}
echo " </table>\n";
echo " </div>\n";
echo "</div>\n";

echo " <div class='foot'>added on the ".$this->board->added." by ".$this->addedUser->PrintLinkedName()." ".$this->addedUser->PrintLinkedAvatar()."</div>\n";

echo "</div>\n";
/*
echo "<table id='pouetbox_groupmain' class='boxtable pagedtable'>\n";
echo "<tr>\n";
echo "<th colspan='9' id='groupname'>\n";
echo sprintf("<a href='groups.php?which=%d'>%s",$this->id,_html($this->group->name));
if ($this->group->acronym)
echo sprintf(" [%s]",$this->group->acronym);
echo "</a>";
if ($this->group->web)
echo sprintf(" [<a href='%s'>web</a>]",_html($this->group->web));
if ($this->group->csdb)
echo sprintf(" [<a href='http://csdb.dk/group/?id=%d'>csdb</a>]",$this->group->csdb);
if ($this->group->zxdemo)
echo sprintf(" [<a href='http://zxdemo.org/author.php?id=%d'>zxdemo</a>]",$this->group->zxdemo);
printf(" [<a href='gloperator_log.php?which=%d&amp;what=group'>glöplog</a>]\n",$this->group->id);
if ($currentUser && $currentUser->CanEditItems())
{
printf("<div id='adminlinks'>");
printf("[<a href='admin_group_edit.php?which=%d' class='adminlink'>edit</a>]\n",$this->id);
printf("</div>");
}
echo "</th>\n";
echo "</tr>\n";
$headers = array(
"type"=>"type",
"name"=>"prodname",
"party"=>"release party",
"release"=>"release date",
"thumbup"=>"<img src='http://www.pouet.net/gfx/rulez.gif' alt='rulez' />",
"thumbpig"=>"<img src='http://www.pouet.net/gfx/isok.gif' alt='piggie' />",
"thumbdown"=>"<img src='http://www.pouet.net/gfx/sucks.gif' alt='sucks' />",
"avg"=>"avg",
"views"=>"popularity",
"latestcomment"=>"last comment",
);
echo "<tr class='sortable'>\n";
foreach($headers as $key=>$text)
{
$out = sprintf("<th><a href='%s' class='%s%s' id='%s'>%s</a></th>\n",
$this->BuildURL(array("order"=>$key)),$_GET["order"]==$key?"selected":"",($_GET["order"]==$key && $_GET["reverse"])?" reverse":"","sort_".$key,$text);
if ($key == "type") $out = str_replace("</th>","",$out);
if ($key == "name") $out = str_replace("<th>"," ",$out);
echo $out;
}
echo "</tr>\n";
foreach($headers as $key=>$text)
{
$out = sprintf("<th><a id='%s' href='groups.php?which=%d&amp;order=%s'>%s</a></th>\n","sort_".$key,$this->id,$key,$text);
if ($key == "type") $out = str_replace("</th>","",$out);
if ($key == "name") $out = str_replace("<th>"," ",$out);
echo $out;
}
echo "</tr>\n";
foreach ($this->prods as $p) {
echo "<tr>\n";
echo "<td>\n";
echo $p->RenderTypeIcons();
echo $p->RenderPlatformIcons();
echo "<span class='prod'>".$p->RenderLink()."</span>\n";
$groups = $p->groups;
foreach($groups as $k=>$g) if ($g->id == $this->id) unset($groups[$k]);
if ($groups)
{
$a = array();
foreach($groups as $g) $a[] = $g->RenderShort();
echo " (with ".implode(", ",$a).")";
}
echo $p->RenderAwards();
echo "</td>\n";
echo "<td>\n";
if ($p->placings)
echo $p->placings[0]->PrintResult($p->year);
echo "</td>\n";
echo "<td class='date'>".$p->RenderReleaseDate()."</td>\n";
echo "<td class='votes'>".$p->voteup."</td>\n";
echo "<td class='votes'>".$p->votepig."</td>\n";
echo "<td class='votes'>".$p->votedown."</td>\n";
$i = "isok";
if ($p->voteavg < 0) $i = "sucks";
if ($p->voteavg > 0) $i = "rulez";
echo "<td class='votes'>".sprintf("%.2f",$p->voteavg)."&nbsp;<img src='http://www.pouet.net/gfx/".$i.".gif' alt='".$i."' /></td>\n";
$pop = (int)($p->views * 100 / $this->maxviews);
echo "<td><div class='innerbar_solo' style='width: ".$pop."px'>&nbsp;<span>".$pop."%</span></div></td>\n";
if ($p->user)
echo "<td>".$p->lastcomment." ".$p->user->PrintLinkedAvatar()."</td>\n";
else
echo "<td> </td>";
echo "</tr>\n";
}
echo "<tr>\n";
echo " <td class='foot' colspan='9'>added on the ".$this->group->quand." by ".$this->group->addeduser->PrintLinkedName()." ".$this->group->addeduser->PrintLinkedAvatar()."</td>\n";
echo "</tr>\n";
echo "</table>\n";
*/
return $s;
}
};

class PouetBoxBoardList extends PouetBox
{
var $letter;
function PouetBoxBoardList($letter) {
parent::__construct();
$this->uniqueID = "pouetbox_boardlist";

$letter = substr($letter,0,1);
if (preg_match("/^[a-z]$/",$letter))
$this->letter = $letter;
else
$this->letter = "#";

$a = array();
$a[] = "<a href='boards.php?pattern=%23'>#</a>";
for($x=ord("a");$x<=ord("z");$x++)
$a[] = sprintf("<a href='boards.php?pattern=%s'>%s</a>",chr($x),chr($x));

$this->letterselect = "[ ".implode(" |\n",$a)." ]";
}

function RenderHeader()
{
echo "\n\n";
echo "<div class='pouettbl' id='".$this->uniqueID."'>\n";
echo " <div class='letterselect'>".$this->letterselect."</div>\n";
}

function RenderFooter()
{
echo " <div class='letterselect'>".$this->letterselect."</div>\n";
echo "</div>\n";
}

function Load() {
$s = new BM_query("bbses");
$s->AddField("bbses.id");
$s->AddField("bbses.name");
$s->AddField("bbses.phonenumber");
if ($this->letter=="#")
$s->AddWhere(sprintf_esc("name regexp '^[^a-z]'"));
else
$s->AddWhere(sprintf_esc("name like '%s%%'",$this->letter));
$s->AddOrder("name");
$this->boards = $s->perform();
/*
if ($this->groups)
{
$ids = array();
foreach($this->groups as $group) $ids[] = $group->id;
$idstr = implode(",",$ids);
$prods = SQLLib::selectRows(sprintf("select id,name,type,group1,group2,group3 from prods where (group1 in (%s)) or (group2 in (%s)) or (group3 in (%s))",$idstr,$idstr,$idstr));
foreach($prods as $prod)
{
if ($prod->group1) $this->prods[$prod->group1][$prod->id] = $prod;
if ($prod->group2) $this->prods[$prod->group2][$prod->id] = $prod;
if ($prod->group3) $this->prods[$prod->group3][$prod->id] = $prod;
}
}*/

}

function RenderBody() {
global $thread_categories;
echo "<table class='boxtable'>\n";
echo "<tr>\n";
echo " <th>name</th>\n";
echo " <th>countrycode</th>\n";
echo "</tr>\n";
foreach ($this->boards as $b) {
echo "<tr>\n";
echo " <td class='boardname'><a href='boards.php?which=".(int)$b->id."'>"._html($b->name)."</a></td>\n";
echo " <td>"._html($b->phonenumber)."</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
};
///////////////////////////////////////////////////////////////////////////////

$boardID = (int)$_GET["which"];

$p = null;
if (!$boardID)
{
$pattern = $_GET["pattern"] ? $_GET["pattern"] : chr(rand(ord("a"),ord("z")));
$p = new PouetBoxBoardList($pattern);
$p->Load();
$TITLE = "boards: ".$p->letter;
}
else
{
$p = new PouetBoxBoardMain($boardID);
$p->Load();
$TITLE = _html($p->board->name);
}

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";
if($p) $p->Render();
echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");
?>
57 changes: 57 additions & 0 deletions bootstrap.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?
define(POUET_ROOT_LOCAL,dirname(__FILE__));
include_once( POUET_ROOT_LOCAL . "/include_generic/sqllib.inc.php");
include_once( POUET_ROOT_LOCAL . "/include_generic/sceneid.inc.php");
include_once( POUET_ROOT_LOCAL . "/include_generic/functions.inc.php");
include_once( POUET_ROOT_LOCAL . "/include_generic/libbb.php");
include_once( POUET_ROOT_LOCAL . "/include_generic/orm.inc.php");
include_once( POUET_ROOT_LOCAL . "/include_generic/formifier.inc.php");
include_once( POUET_ROOT_LOCAL . "/include_generic/lastRSS.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/enums.inc.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-box.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-prod.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-user.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-party.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-group.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-formprocessor.php");

$lifetime = 60 * 60 * 24 * 365;
ini_set('session.cookie_lifetime', $lifetime);

session_name("POUETSESSION");
session_set_cookie_params($lifetime,POUET_ROOT_PATH);
@session_start();

$sceneID = null;
if (class_exists("SceneId"))
$sceneID = SceneId::Factory(SCENEID_USER, SCENEID_PASS, SCENEID_URL);

$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='%s' where id=%d",
$_SERVER["REMOTE_ADDR"],$host,date("Y-m-d H:i:s"),$id));
$currentUser = PouetUser::Spawn( $id );
}
}

if ($currentUser && $currentUser->IsBanned())
{
$_SESSION = $currentUser = NULL;
}

$_SESSION["keepalive"] = str_pad("",rand(1,10),"x") . rand(1,10000);

$timer["page"]["start"] = microtime_float();

if (!$_SESSION["settings"])
{
include_once("include_pouet/default_usersettings.php");
$_SESSION["settings"] = $DEFAULT_USERSETTINGS;
}
?>
57 changes: 57 additions & 0 deletions buttons.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?
include_once("bootstrap.inc.php");

class PouetBoxButtons extends PouetBox {
function PouetBoxButtons() {
parent::__construct();
$this->uniqueID = "pouetbox_buttons";
}

function LoadFromDB()
{
$this->buttons = SQLLib::SelectRows("select * from buttons where dead = 0 order by type, rand()");
}
function Render()
{
echo "\n\n";
echo "<div class='pouettbl' id='".$this->uniqueID."'>\n";
$type = "";
foreach($this->buttons as $b)
{
if ($type != $b->type)
{
if($type)
{
echo "</ul>\n";
echo "</div>\n";
}
echo "<h2>"._html($b->type)."</h2>\n";
echo "<div class='content'>\n";
echo "<ul>\n";
$type = $b->type;
}
echo " <li><a href='"._html($b->url)."'><img src='".POUET_CONTENT_URL."/gfx/buttons/".$b->img."' title='"._html($b->alt)."' alt='"._html($b->alt)."'/></a></li>\n";
}
echo "</ul>\n";
echo "</div>\n";
echo "</div>\n";
}
};

$TITLE = "we like !";

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

$box = new PouetBoxButtons();
$box->Load();
$box->Render();

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
124 changes: 124 additions & 0 deletions cdc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?
include_once("bootstrap.inc.php");

class PouetBoxCDCModerator extends PouetBox {
function PouetBoxCDCModerator() {
parent::__construct();
$this->uniqueID = "pouetbox_cdcmoderator";
$this->title = "moderators' coup de coeur history";
}

function LoadFromDB()
{
$s = new BM_Query("cdc");
$s->AddField("cdc.quand");
$s->attach(array("cdc"=>"which"),array("prods as prod"=>"id"));
$s->AddOrder("cdc.quand desc");
$this->cdcs = $s->perform();

$a = array();
foreach($this->cdcs as $v) $a[] = &$v->prod;
PouetCollectPlatforms($a);
}

function RenderBody()
{
echo "\n\n";
echo "<table class='boxtable'>\n";
$lastYear = 0;
$lastCategory = "";
foreach ($this->cdcs as $row)
{
$p = $row->prod;
echo "<tr>\n";
echo "<td>\n";
echo $p->RenderTypeIcons();
echo $p->RenderPlatformIcons();
echo "<span class='prod'>".$p->RenderLink()."</span>\n";
echo "</td>\n";

echo "<td>\n";
echo $p->RenderGroupsShortProdlist();
echo "</td>\n";

echo "<td>\n";
echo $row->quand;
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
};

class PouetBoxCDCUser extends PouetBox {
function PouetBoxCDCUser() {
parent::__construct();
$this->uniqueID = "pouetbox_cdcuser";
$this->title = "users' coup de coeur toplist";
}

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);
}

function RenderBody()
{
echo "\n\n";
echo "<table class='boxtable'>\n";
$lastYear = 0;
$lastCategory = "";
foreach ($this->cdcs as $row)
{
$p = $row->prod;
echo "<tr>\n";
echo "<td>\n";
echo $p->RenderTypeIcons();
echo $p->RenderPlatformIcons();
echo "<span class='prod'>".$p->RenderLink()."</span>\n";
echo "</td>\n";

echo "<td>\n";
echo $p->RenderGroupsShortProdlist();
echo "</td>\n";

echo "<td>\n";
echo $row->c;
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
};


$TITLE = "coup de coeur";

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

$box = new PouetBoxCDCModerator();
$box->Load();
$box->Render();

$box = new PouetBoxCDCUser();
$box->Load();
$box->Render();

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
97 changes: 97 additions & 0 deletions comments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?
include_once("bootstrap.inc.php");

class PouetBoxLatestComments extends PouetBox {
function PouetBoxLatestComments() {
parent::__construct();
$this->uniqueID = "pouetbox_latestcomments";
$this->title = "latest comments in the last 24 hours";
}

function LoadFromDB()
{
$s = new BM_Query("comments");
$s->AddField("comments.rating");
$s->AddField("comments.quand");
$s->attach(array("comments"=>"which"),array("prods as prod"=>"id"));
$s->attach(array("comments"=>"who"),array("users as user"=>"id"));
$s->AddOrder("comments.quand DESC");
$s->AddWhere(sprintf_esc("(UNIX_TIMESTAMP()-UNIX_TIMESTAMP(comments.quand))<=(3600*%d)",get_setting("commentshours")));
$this->comments = $s->perform();

$a = array();
foreach($this->comments as $v) $a[] = &$v->prod;
PouetCollectPlatforms($a);
}

function RenderBody()
{
echo "\n\n";
echo "<table class='boxtable'>\n";
echo "<tr>\n";
echo " <th><img src='".POUET_CONTENT_URL."gfx/rulez.gif'/></th>\n";
echo " <th>name</th>\n";
echo " <th>group</th>\n";
echo " <th>platform</th>\n";
echo " <th>time</th>\n";
echo " <th>user</th>\n";
echo "</tr>\n";

foreach ($this->comments as $row)
{
$p = $row->prod;
echo "<tr>\n";


$rating = $row->rating>0 ? "rulez" : ($row->rating<0 ? "sucks" : "isok");

echo "<td>\n";
echo "<img src='".POUET_CONTENT_URL."gfx/".$rating.".gif'/>";
echo "</td>\n";

echo "<td>\n";
// echo "<img src='".POUET_CONTENT_URL."gfx/sceneorg/".$row->type.".gif' alt='".$row->type."'/>&nbsp;";
//echo $p->RenderTypeIcons();
echo "<span class='prod'>".$p->RenderLink()."</span>\n";
echo "</td>\n";

echo "<td>\n";
echo $p->RenderGroupsShortProdlist();
echo "</td>\n";

echo "<td>\n";
echo $p->RenderPlatformIcons();
echo "</td>\n";

echo "<td class='date'>\n";
echo dateDiffReadable( time(), $row->quand)." ago";
echo "</td>\n";

echo "<td>\n";
echo $row->user->PrintLinkedAvatar()." ";
echo $row->user->PrintLinkedName()." ";
echo "</td>\n";

echo "</tr>\n";
}
echo "</table>\n";
}
};

$TITLE = "latest comments";

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

$box = new PouetBoxLatestComments();
$box->Load();
$box->Render();

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
24 changes: 24 additions & 0 deletions error.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?
include_once("bootstrap.inc.php");
include_once("include_pouet/box-modalmessage.php");
include_once("include_pouet/box-index-oneliner-latest.php");
include_once("include_pouet/box-bbs-post.php");
include_once("include_pouet/box-prod-post.php");

$errormessage = "";

////////////////////////////////////////////////////////////

$message = new PouetBoxModalMessage(false,true);
$message->classes[] = "errorbox";
$message->title = "An error has occured:";
$message->message = $_GET["e"];

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo $message->Render();

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");
?>
31 changes: 31 additions & 0 deletions export/last-prod-comments.rss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?
include_once("../bootstrap.inc.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-rss.php");

$s = new BM_Query("comments");
$s->AddField("comments.id");
$s->AddField("comments.quand");
$s->AddField("comments.comment");
$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.quand DESC");
$s->SetLimit("20");
$data = $s->perform();

$rss = new PouetRSS();

foreach($data as $item)
{
$rss->AddItem(array(
"title" => $item->user->nickname,
"description" => $item->comment,
"link" => POUET_ROOT_URL . "prod.php?which=" . $item->prod->id,
"pubDate" => date("r",strtotime($item->quand)),
"guid" => $item->id,
));
}

$rss->Render();

?>
22 changes: 22 additions & 0 deletions export/lastbbsposts.rss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?
include_once("../bootstrap.inc.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/box-index-bbs-latest.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-rss.php");

$p = new PouetBoxLatestBBS();
$p->Load(true);

$rss = new PouetRSS();

foreach($p->data as $item)
{
$rss->AddItem(array(
"title" => $item->topic,
"link" => POUET_ROOT_URL . "topic.php?which=" . $item->id,
"pubDate" => date("r",strtotime($item->lastpost)),
));
}

$rss->Render();

?>
23 changes: 23 additions & 0 deletions export/lastprodsadded.rss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?
include_once("../bootstrap.inc.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/box-index-latestadded.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-rss.php");

$p = new PouetBoxLatestAdded();
$p->Load(true);

$rss = new PouetRSS();

foreach($p->data as $item)
{
$rss->AddItem(array(
"title" => $item->name,
"link" => POUET_ROOT_URL . "prod.php?which=" . $item->id,
"pubDate" => date("r",strtotime($item->quand)),
"enclosure" => find_screenshot($item->id),
));
}

$rss->Render();

?>
23 changes: 23 additions & 0 deletions export/lastprodsreleased.rss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?
include_once("../bootstrap.inc.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/box-index-latestreleased.php");
include_once( POUET_ROOT_LOCAL . "/include_pouet/pouet-rss.php");

$p = new PouetBoxLatestReleased();
$p->Load(true);

$rss = new PouetRSS();

foreach($p->data as $item)
{
$rss->AddItem(array(
"title" => $item->name,
"link" => POUET_ROOT_URL . "prod.php?which=" . $item->id,
"pubDate" => date("r",strtotime($item->quand)),
"enclosure" => find_screenshot($item->id),
));
}

$rss->Render();

?>
87 changes: 87 additions & 0 deletions export/prod.xnfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?
include_once("../bootstrap.inc.php");

header("Content-type: application/xml; charset=utf-8");
//header("Content-type: text/plain; charset=utf-8");

$xml = new SimpleXMLElement("<"."?xml version='1.0' encoding='UTF-8'?"."><xnfo/>");

$prod = PouetProd::Spawn( $_GET["which"] );

$a = array(&$prod);
PouetCollectPlatforms( $a );

if (!$prod)
die($xml->AsXML());

$xml->addAttribute("standard","1.1");
$xml->addAttribute("version","1");
$xml->addAttribute("author","webmaster@pouet.net");
$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.partycompo");
$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->partycompo,"ranking"=>$row->party_place,"year"=>$row->party_year) );
}

foreach($prod->placings as $p)
{
$release = $xml->demo->addChild("release");
$release->addChild("party",$p->party->name)->addAttribute("url",$p->party->web);
$release->addChild("date",$p->year);
$release->addChild("rank",$p->ranking);
$release->addChild("compo",$p->compo);
}
/*
<release><party url="http://www.ambience.nl">Ambience</party><date>2000-03-15</date><rank>9</rank><compo>pc demo</compo></release>
*/

$xml->demo->addChild("releaseDate",substr($prod->date,0,10));

if (count($prod->groups))
{
$xml->demo->addChild("authors");
foreach($prod->groups as $v)
$xml->demo->authors->addChild("groups",_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",$PLATFORMS[$v]["name"])->addAttribute("type",$PLATFORMS[$v]["slug"]);

$xml->demo->addChild("download");
$xml->demo->download->addChild("url",$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",$v->link)->addAttribute("type",$v->type);


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

$dom = dom_import_simplexml($xml)->ownerDocument;
$dom->formatOutput = true;
echo $dom->saveXML();

?>
69 changes: 69 additions & 0 deletions faq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?
include_once("bootstrap.inc.php");

class PouetBoxFAQ extends PouetBox {
function PouetBoxFAQ() {
parent::__construct();
$this->uniqueID = "pouetbox_faq";
$this->title = "the always incomplete pouët.net faq";
}

function LoadFromDB()
{
$this->entries = SQLLib::SelectRows("select * from faq order by category, id");
}

function RenderBody()
{
echo "<div class='content'>\n";
$lastType = "";
foreach($this->entries as $e)
{
if ($lastType != $e->category)
{
if ($lastType)
echo "</ul>\n";
echo "<h3>"._html($e->category)."</h3>";
$lastType = $e->category;
echo "<ul>\n";
}
echo "<li><a href='#faq"._html($e->id)."'>".$e->question."</a></li>";
}
echo "</ul>\n";
echo "</div>\n";

$lastType = "";
foreach($this->entries as $e)
{
if ($lastType != $e->category)
{
if ($lastType)
echo "</dl>\n";
echo "<h2>:: "._html($e->category)."</h2>";
$lastType = $e->category;
echo "<dl>\n";
}
echo "<dt id='faq"._html($e->id)."'>:: "._html($e->category)." :: ".$e->question."</dt>";
echo "<dd>".$e->answer."</dd>";
}
echo "</dl>\n";
}
};

$TITLE = "faq";

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

$box = new PouetBoxFAQ();
$box->Load();
$box->Render();

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
78 changes: 78 additions & 0 deletions gloperator_log.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?
include_once("bootstrap.inc.php");

class PouetBoxGloperatorLog extends PouetBox {
function PouetBoxGloperatorLog() {
parent::__construct();
$this->uniqueID = "pouetbox_gloperatorlog";
$this->title = "edits for this "._html($_GET["what"]).":";
}

function LoadFromDB()
{
$q = new BM_Query();
$q->AddField("gloperator_log.*");
$q->AddTable("gloperator_log");
$q->AddWhere(sprintf_esc("itemType = '%s'",$_GET["what"]));
$q->AddWhere(sprintf_esc("itemID = %d",$_GET["which"]));
$q->attach(array("gloperator_log"=>"gloperatorID"),array("users as gloperator"=>"id"));
$q->AddOrder("date desc");

$this->logs = $q->perform();
}
function RenderBody() {
global $THREAD_CATEGORIES;
echo "<table class='boxtable'>\n";
$n = 0;
echo "<tr>\n";
echo " <th>date</th>\n";
echo " <th>glöperator</th>\n";
echo " <th>action</th>\n";
echo " <th>more info</th>\n";
echo "</tr>\n";
foreach ($this->logs as $r) {
echo "<tr>\n";
echo " <td>"._html($r->date)."</td>\n";
echo " <td>".$r->gloperator->PrintLinkedAvatar()." ".$r->gloperator->PrintLinkedname()."</td>\n";
echo " <td>"._html($r->action)."</td>\n";
echo " <td>";
switch($r->action)
{
default:
{
echo "&nbsp;\n";
} break;
}
echo "</td>";
echo "</tr>\n";
}
echo "</table>\n";
echo "<div class='foot'>";
switch ($_GET["what"])
{
case "prod": printf("<a href='prod.php?which=%d'>back to the prod</a>",$_GET["which"]); break;
case "group": printf("<a href='groups.php?which=%d'>back to the group</a>",$_GET["which"]); break;
case "topic": printf("<a href='topic.php?which=%d'>back to the topic</a>",$_GET["which"]); break;
case "party": printf("<a href='party.php?which=%d'>back to the party</a>",$_GET["which"]); break;
}
echo "</div>\n";
}
};

$TITLE = "glöperator log";

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";

$box = new PouetBoxGloperatorLog();
$box->Load();
$box->Render();

echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");

?>
302 changes: 302 additions & 0 deletions groups.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
<?
include_once("bootstrap.inc.php");

class PouetBoxGroupMain extends PouetBox
{
var $id;
var $group;

function PouetBoxGroupMain($id) {
parent::__construct();
$this->uniqueID = "pouetbox_groupmain";
$this->id = (int)$id;
}

function BuildURL( $param ) {
$query = array_merge($_GET,$param);
unset( $query["reverse"] );
if($param["order"] && $_GET["order"] == $param["order"] && !$_GET["reverse"])
$query["reverse"] = 1;
return _html("groups.php?" . http_build_query($query));
}
function LoadFromDB() {
$s = new SQLSelect();

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

// not to boast or anything, but this is fucking beautiful.

$sub = new SQLSelect();
$sub->AddField("comments.quand");
$sub->AddField("comments.who");
$sub->AddField("comments.which");
$sub->AddTable("comments");
$sub->AddJoin("left","prods","prods.id = comments.which");
$sub->AddOrder("comments.quand desc");
$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.quand as lastcomment");
$s->AddJoin("left","(select quand,who,which from (".$sub->GetQuery().") as dummy group by 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));

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

switch($_GET["order"])
{
case "type": $s->AddOrder("prods.type ".$dir); break;
case "party": $s->AddOrder("prods_party.name ".$dir); $s->AddOrder("prods.party_year ".$dir); $s->AddOrder("prods.party_place ".$dir); break;
case "release": $s->AddOrder("prods.date ".$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 "latestcomment": $s->AddOrder("lastcomment ".$dir); break;
default: $s->AddOrder("prods.name ".$dir); break;
}
$this->prods = $s->perform();
PouetCollectPlatforms($this->prods);
PouetCollectAwards($this->prods);

$this->maxviews = SQLLib::SelectRow("SELECT MAX(views) as m FROM prods")->m;
}

function Render()
{
global $currentUser;

echo "<table id='pouetbox_groupmain' class='boxtable pagedtable'>\n";
echo "<tr>\n";
echo "<th colspan='9' id='groupname'>\n";
echo sprintf("<a href='groups.php?which=%d'>%s",$this->id,_html($this->group->name));
if ($this->group->acronym)
echo sprintf(" [%s]",$this->group->acronym);
echo "</a>";
if ($this->group->web)
echo sprintf(" [<a href='%s'>web</a>]",_html($this->group->web));
if ($this->group->csdb)
echo sprintf(" [<a href='http://csdb.dk/group/?id=%d'>csdb</a>]",$this->group->csdb);
if ($this->group->zxdemo)
echo sprintf(" [<a href='http://zxdemo.org/author.php?id=%d'>zxdemo</a>]",$this->group->zxdemo);

printf(" [<a href='gloperator_log.php?which=%d&amp;what=group'>glöplog</a>]\n",$this->group->id);

if ($currentUser && $currentUser->CanEditItems())
{
printf("<div id='adminlinks'>");
printf("[<a href='admin_group_edit.php?which=%d' class='adminlink'>edit</a>]\n",$this->id);
printf("</div>");
}

echo "</th>\n";
echo "</tr>\n";

$headers = array(
"type"=>"type",
"name"=>"prodname",
"party"=>"release party",
"release"=>"release date",
"thumbup"=>"<img src='http://www.pouet.net/gfx/rulez.gif' alt='rulez' />",
"thumbpig"=>"<img src='http://www.pouet.net/gfx/isok.gif' alt='piggie' />",
"thumbdown"=>"<img src='http://www.pouet.net/gfx/sucks.gif' alt='sucks' />",
"avg"=>"avg",
"views"=>"popularity",
"latestcomment"=>"last comment",
);

echo "<tr class='sortable'>\n";
foreach($headers as $key=>$text)
{
$out = sprintf("<th><a href='%s' class='%s%s' id='%s'>%s</a></th>\n",
$this->BuildURL(array("order"=>$key)),$_GET["order"]==$key?"selected":"",($_GET["order"]==$key && $_GET["reverse"])?" reverse":"","sort_".$key,$text);
if ($key == "type") $out = str_replace("</th>","",$out);
if ($key == "name") $out = str_replace("<th>"," ",$out);
echo $out;
}
echo "</tr>\n";

/*
foreach($headers as $key=>$text)
{
$out = sprintf("<th><a id='%s' href='groups.php?which=%d&amp;order=%s'>%s</a></th>\n","sort_".$key,$this->id,$key,$text);
if ($key == "type") $out = str_replace("</th>","",$out);
if ($key == "name") $out = str_replace("<th>"," ",$out);
echo $out;
}
echo "</tr>\n";
*/

foreach ($this->prods as $p) {
echo "<tr>\n";

echo "<td>\n";
echo $p->RenderTypeIcons();
echo $p->RenderPlatformIcons();
echo "<span class='prod'>".$p->RenderLink()."</span>\n";
$groups = $p->groups;
foreach($groups as $k=>$g) if ($g->id == $this->id) unset($groups[$k]);
if ($groups)
{
$a = array();
foreach($groups as $g) $a[] = $g->RenderShort();
echo " (with ".implode(", ",$a).")";
}
echo $p->RenderAwards();
echo "</td>\n";

echo "<td>\n";
if ($p->placings)
echo $p->placings[0]->PrintResult($p->year);
echo "</td>\n";

echo "<td class='date'>".$p->RenderReleaseDate()."</td>\n";

echo "<td class='votes'>".$p->voteup."</td>\n";
echo "<td class='votes'>".$p->votepig."</td>\n";
echo "<td class='votes'>".$p->votedown."</td>\n";

$i = "isok";
if ($p->voteavg < 0) $i = "sucks";
if ($p->voteavg > 0) $i = "rulez";
echo "<td class='votes'>".sprintf("%.2f",$p->voteavg)."&nbsp;<img src='http://www.pouet.net/gfx/".$i.".gif' alt='".$i."' /></td>\n";

$pop = (int)($p->views * 100 / $this->maxviews);
echo "<td><div class='innerbar_solo' style='width: ".$pop."px'>&nbsp;<span>".$pop."%</span></div></td>\n";

if ($p->user)
echo "<td>".$p->lastcomment." ".$p->user->PrintLinkedAvatar()."</td>\n";
else
echo "<td> </td>";

echo "</tr>\n";
}
echo "<tr>\n";
echo " <td class='foot' colspan='9'>added on the ".$this->group->quand." by ".$this->group->addeduser->PrintLinkedName()." ".$this->group->addeduser->PrintLinkedAvatar()."</td>\n";
echo "</tr>\n";
echo "</table>\n";
return $s;
}
};

class PouetBoxGroupList extends PouetBox
{
var $letter;
function PouetBoxGroupList($letter) {
parent::__construct();
$this->uniqueID = "pouetbox_grouplist";

$letter = substr($letter,0,1);
if (preg_match("/^[a-z]$/",$letter))
$this->letter = $letter;
else
$this->letter = "#";

$a = array();
$a[] = "<a href='groups.php?pattern=%23'>#</a>";
for($x=ord("a");$x<=ord("z");$x++)
$a[] = sprintf("<a href='groups.php?pattern=%s'>%s</a>",chr($x),chr($x));

$this->letterselect = "[ ".implode(" |\n",$a)." ]";
}

function RenderHeader()
{
echo "\n\n";
echo "<div class='pouettbl' id='".$this->uniqueID."'>\n";
echo " <div class='letterselect'>".$this->letterselect."</div>\n";
}

function RenderFooter()
{
echo " <div class='letterselect'>".$this->letterselect."</div>\n";
echo "</div>\n";
}

function Load() {
$s = new BM_query("groups");
if ($this->letter=="#")
$s->AddWhere(sprintf("name regexp '^[^a-z]'"));
else
$s->AddWhere(sprintf("name like '%s%%'",$this->letter));
$s->AddOrder("name");
$this->groups = $s->perform();
if ($this->groups)
{
$ids = array();
foreach($this->groups as $group) $ids[] = $group->id;

$idstr = implode(",",$ids);

$prods = SQLLib::selectRows(sprintf("select id,name,type,group1,group2,group3 from prods where (group1 in (%s)) or (group2 in (%s)) or (group3 in (%s))",$idstr,$idstr,$idstr));
foreach($prods as $prod)
{
if ($prod->group1) $this->prods[$prod->group1][$prod->id] = $prod;
if ($prod->group2) $this->prods[$prod->group2][$prod->id] = $prod;
if ($prod->group3) $this->prods[$prod->group3][$prod->id] = $prod;
}
}

}

function RenderBody() {
global $thread_categories;
echo "<table class='boxtable'>\n";
echo "<tr>\n";
echo " <th>groups</th>\n";
echo " <th>prods</th>\n";
echo "</tr>\n";
foreach ($this->groups as $r) {
echo "<tr>\n";
echo " <td class='groupname'>".$r->RenderFull()."</td>\n";
echo " <td>\n";
if ($this->prods[$r->id])
{
echo " <ul>\n";
$prod = new PouetProd();
foreach($this->prods[$r->id] as $p)
{
foreach(get_object_vars($p) as $k=>$v) $prod->$k = $v;
$prod->types = explode(",",$prod->type);
echo "<li>".$prod->RenderTypeIcons().$prod->RenderLink()."</li>";
}
echo " </ul>\n";
}
echo " </td>\n";
echo "</tr>\n";
}
echo "</table>\n";
}
};
///////////////////////////////////////////////////////////////////////////////

$groupID = (int)$_GET["which"];

$p = null;
if (!$groupID)
{
$pattern = $_GET["pattern"] ? $_GET["pattern"] : chr(rand(ord("a"),ord("z")));
$p = new PouetBoxGroupList($pattern);
$p->Load();
$TITLE = "groups: ".$p->letter;
}
else
{
$p = new PouetBoxGroupMain($groupID);
$p->Load();
$TITLE = $p->group->name;
}

include("include_pouet/header.php");
include("include_pouet/menu.inc.php");

echo "<div id='content'>\n";
if($p) $p->Render();
echo "</div>\n";

include("include_pouet/menu.inc.php");
include("include_pouet/footer.php");
?>
144 changes: 144 additions & 0 deletions img_ascii.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?
include_once("include_generic/functions.inc.php");

$ts=microtime();

/*
if(!isset($s)) $s=4;
if(!isset($r1)) $r1=0xff;
if(!isset($g1)) $g1=0xff;
if(!isset($b1)) $b1=0xff;
if(!isset($r2)) $r2=0x44;
if(!isset($g2)) $g2=0x66;
if(!isset($b2)) $b2=0x88;
*/
$s=4;
$r1=0xff;
$g1=0xff;
$b1=0xff;
$r2=0x44;
$g2=0x66;
$b2=0x88;

$r3=$r2-32;
$g3=$g2-32;
$b3=$b2-32;
if($r3<0) $r3=0;
if($g3<0) $g3=0;
if($b3<0) $b3=0;

$path = "";
if ($_GET["nfo"])
{
$path = get_local_nfo_path($_GET["nfo"]);
}
elseif ($_GET["results"])
{
$path = get_local_partyresult_path($_GET["results"],$_GET["year"]);
}
elseif ($_GET["boardnfo"])
{
$path = get_local_bbsnfo_path($_GET["boardnfo"]);
}

if(!$path || !file_exists($path))
{
$txt=array(
"ÚÄÄÄÄÄÄÄÄÄ¿ ",
"³WRONG URL³ ",
"ÀÄÄÄÄÄÄÄÄÄÙ ");
$s=0;
$f=2;
}
else
{
$wrap = 100;
$txtLong = file($path);
$txt = array();
foreach($txtLong as $k=>$v)
{
if (strlen($v) > $wrap)
{
$txt = array_merge($txt, preg_split("/\n/",chunk_split($v, $wrap)));
}
else
{
$txt[] = $v;
}
}
}
//foreach($txt as &$v) $v = wordwrap($v,100,"\n",1);

$f = (int)$_GET["font"];
if(!file_exists("gfx/fnt".$f.".png")) $f=1;

$txt[count($txt)-1].=chr(13).chr(10);
$fnt=imagecreatefrompng("gfx/fnt".(int)$f.".png");
$c_w=imagesx($fnt)/16;
$c_h=imagesy($fnt)/16;
$fc1=imagecolorexact($fnt,0,0,0);
$fc2=imagecolorexact($fnt,160,160,160);
imagecolortransparent($fnt,$fc1);

$nbr=count($txt);
$max=0;

for($i=0;$i<$nbr;$i++)
{
$len=strlen(rtrim($txt[$i]));
if($len>$max) $max=$len;
}
$i_w=$max*$c_w+$s;
$i_h=$nbr*$c_h+$s+10;

$im=imagecreate($i_w,$i_h);
$c1=imagecolorallocate($im,$r2,$g2,$b2);
$c2=imagecolorallocate($im,$r3,$g3,$b3);
imagefill($im,0,0,$c1);
//imagecolortransparent($im,$c1);
imagefilledrectangle($im,0,$i_h-9,$i_w,$i_h,$c2);

for($i=0;$i<$nbr;$i++)
{
$len=strlen($txt[$i]);
for($j=0;$j<$len+1;$j++)
{
$chr=ord($txt[$i]{$j});
if($chr==9) $chr=32;
$x=$chr%16*$c_w;
$y=($chr-$chr%16)/16*$c_h;
imagecolorset($fnt,$fc2,$r3,$g3,$b3);
imagecopymerge($im,$fnt,$j*$c_w+$s,$i*$c_h+$s,$x,$y,$c_w,$c_h,100);
imagecolorset($fnt,$fc2,$r1,$g1,$b1);
imagecopymerge($im,$fnt,$j*$c_w,$i*$c_h,$x,$y,$c_w,$c_h,100);
}
}

function write($txt,$a,$b,$br,$bg,$bb)
{
global $im;
$fnt=imagecreatefrompng("gfx/font.png");
$c_w=imagesx($fnt)/16;
$c_h=imagesy($fnt)/16;
$f1=imagecolorexact($fnt,0,0,0);
$f2=imagecolorexact($fnt,80,80,80);
$f3=imagecolorexact($fnt,160,160,160);
imagecolortransparent($fnt,$f1);
imagecolorset($fnt,$f2,($br+255)/2,($bg+255)/2,($bb+255)/2);
imagecolorset($fnt,$f3,255,255,255);
for($i=0;$i<strlen($txt);$i++)
{
$chr=ord($txt{$i});
$x=$chr%16*$c_w;
$y=($chr-$chr%16)/16*$c_h;
imagecopy($im,$fnt,$a+$c,$b,$x,$y,$c_w,$c_h);
$c+=$c_w; if($c>imagesx($im)-$a) { $b+=$c_h; $c=0; }
}
}

$te=microtime()-$ts;// list($s,$ms)=explode(".",$te); $t=$s.".".substr($ms,0,3);
write("generated by pouet lobstergod REZ! (".($te)."s)",1,$i_h-7,$r3,$g3,$b3);

header("Content-type: image/png");
imagepng($im);
?>
114 changes: 114 additions & 0 deletions include_generic/formifier.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?
class Formifier {
function RenderForm( $fields )
{
echo " <div class='formifier'>\n";
foreach($fields as $k=>$v)
{
if ($v["type"]=="hidden")
{
echo " <input type='hidden' name='".$k."' id='".$k."' value='".$v["value"]."'/>\n";
continue;
}
echo " <div class='row' id='row_".$k."'>\n";
echo " <label for='".$k."'>"._html($v["name"]?$v["name"]:$k).":</label>\n";
switch ($v["type"])
{
case "static":
echo " <div class='static' id='".$k."'>".($v["fields"]?$v["fields"][$v["value"]]:$v["value"])."</div>\n";
break;
case "statichidden":
echo " <div class='static' id='".$k."'>".($v["fields"]?$v["fields"][$v["value"]]:$v["value"])."</div>\n";
echo " <input type='hidden' name='".$k."' id='".$k."' value='".$v["value"]."'/>\n";
break;
case "date":
if ($v["value"])
{
list($year,$month,) = sscanf($v["value"],"%d-%d-%d");
}
echo " <div class='formdate'>\n";
echo " <select name='".$k."_month' id='".$k."_month'/>\n";
echo " <option></option>\n";
for($x=1; $x<=12; $x++)
echo " <option value='".$x."'".($month==$x?" selected='selected'":"").">".date("F",mktime(0,0,0,$x,15))."</option>\n";
echo " </select>\n";
echo " <select name='".$k."_year' id='".$k."_year'/>\n";
echo " <option></option>\n";
for($x=date("Y"); $x>=POUET_EARLIEST_YEAR; $x--)
echo " <option".($year==$x?" selected='selected'":"").">".$x."</option>\n";
echo " </select>\n";
echo " </div>\n";
break;
case "avatar":
echo " <div id='avatarlist'>\n";
echo " <select name='".$k."' id='".$k."'/>\n";
global $avatars;
if (!$v["value"])
$v["value"] = basename( $avatars[ array_rand($avatars) ] );
foreach($avatars as $path)
{
$f = basename($path);
echo " <option".($v["value"]==$f?" selected='selected'":"").">".$f."</option>\n";
}
echo " </select>\n";
echo " </div>\n";
break;
case "select":
echo " <select name='".$k.($v["multiple"]?"[]":"")."' id='".$k."'".($v["multiple"]?" multiple='multiple'":"")."/>\n";
foreach($v["fields"] as $k=>$f)
{
$sel = "";
if ($v["value"])
{
$match = $v["assoc"] ? $k : $f;
if ($v["multiple"])
$sel = (array_search($v["assoc"]?$match:$f,$v["value"])!==false?" selected='selected'":"");
else
$sel = ($v["value"]==$match?" selected='selected'":"");
}
if ($v["assoc"])
{
echo " <option value='"._html($k)."' ".$sel.">"._html($f)."</option>\n";
}
else
{
echo " <option".$sel.">"._html($f)."</option>\n";
}
}
echo " </select>\n";
break;
case "password":
echo " <input type='password' name='".$k."' id='".$k."' value='"."'/>\n";
break;
case "checkbox":
echo " <input type='checkbox' name='".$k."' id='".$k."' ".($v["value"]?" checked='checked'":"")."/>\n";
break;
case "file":
echo " <input type='file' name='".$k."' id='".$k."'".($v["accept"]?" accept='"._html($v["accept"])."'":"")."/>\n";
break;
case "captcha":
echo " <div>\n";
echo recaptcha_get_html(CAPTCHA_PUBLICKEY);
echo " </div>\n";
break;
case "number":
echo " <input type='number' min='"._html((int)$v["min"])."' max='"._html((int)$v["max"])."' name='".$k."' id='".$k."' value='"._html($v["value"])."'/>\n";
break;
case "url":
echo " <input type='url' name='".$k."' id='".$k."' value='"._html($v["value"])."'/>\n";
break;
case "email":
echo " <input type='email' name='".$k."' id='".$k."' value='"._html($v["value"])."'/>\n";
break;
default:
echo " <input name='".$k."' id='".$k."' value='"._html($v["value"])."'/>\n";
break;
}
if ($v["info"])
echo " <span>"._html($v["info"]).($v["required"]?" [<span class='req'>req</span>]":"")."</span>\n";
echo " </div>\n";
}
echo " </div>\n";
}
};
?>
Loading