예제 #1
0
  function Commit($post)
  {
    $message = trim($post["message"]);

    $r = SQLLib::SelectRow("SELECT count(0) as c FROM bbs_posts WHERE topic=".$this->topic);

  	$a = array();
  	$a["userlastpost"] = get_login_id();
  	$a["lastpost"] = date("Y-m-d H:i:s");
  	$a["count"] = $r->c;

    SQLLib::UpdateRow("bbs_topics",$a,"id=".$this->topic);

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

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

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

    return array();
  }
예제 #2
0
  function LoadFromDB() {
    global $POSTS_PER_PAGE;

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

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

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

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

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

    $this->title = _html($this->topic->topic);
  }
예제 #3
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('­', 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();
  }
예제 #4
0
  function LoadFromDB() {
    $s = new SQLSelect();

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

    $s = new BM_Query("users");

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

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

    //echo $s->GetQuery();

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

    $this->maxglops = SQLLib::SelectRow("SELECT MAX(glops) as m FROM users")->m;
  }
예제 #5
0
  function CalculateGlops()
  {
    $glops = 0;
    $this->stats["prods"]       = SQLLib::SelectRow(sprintf_esc("SELECT count(0) AS c FROM prods WHERE addedUser=%d",$this->id))->c;
    $this->stats["groups"]      = SQLLib::SelectRow(sprintf_esc("SELECT count(0) AS c FROM groups WHERE addedUser=%d",$this->id))->c;
    $this->stats["parties"]     = SQLLib::SelectRow(sprintf_esc("SELECT count(0) AS c FROM parties WHERE addedUser=%d",$this->id))->c;
    $this->stats["screenshots"] = SQLLib::SelectRow(sprintf_esc("SELECT count(0) AS c FROM screenshots WHERE user=%d",$this->id))->c;
    $this->stats["nfos"]        = SQLLib::SelectRow(sprintf_esc("SELECT count(0) AS c FROM nfos WHERE user=%d",$this->id))->c;
    $this->stats["comments"]    = SQLLib::SelectRow(sprintf_esc("SELECT COUNT(DISTINCT which) AS c  FROM comments WHERE who=%d",$this->id))->c;
    $this->stats["logos"]       = SQLLib::SelectRow(sprintf_esc("SELECT COUNT(*) AS c FROM logos WHERE (author1=%d or author2=%d)",$this->id,$this->id) )->c;
    $this->stats["logosVote"]   = SQLLib::SelectRow(sprintf_esc("SELECT COUNT(*) AS c FROM logos WHERE vote_count > 0 and (author1=%d or author2=%d)",$this->id,$this->id) )->c;
    $this->stats["requestGlops"] = SQLLib::SelectRow(sprintf_esc("SELECT COUNT(*) AS c FROM modification_requests WHERE userID=%d AND approved = 1 AND requestType in ('prod_add_credit')",$this->id) )->c;
    $this->stats["topics"]      = SQLLib::SelectRow(sprintf_esc("SELECT count(0) AS c FROM bbs_topics WHERE userfirstpost=%d",$this->id))->c;
    $this->stats["posts"]       = SQLLib::SelectRow(sprintf_esc("SELECT count(0) AS c FROM bbs_posts WHERE author=%d",$this->id))->c;
    $this->stats["oneliners"]   = SQLLib::SelectRow(sprintf_esc("SELECT count(0) AS c FROM oneliner WHERE who=%d",$this->id))->c;
    if($this->udlogin)
      $this->stats["ud"] = (int)round(SQLLib::SelectRow(sprintf_esc("SELECT points FROM ud WHERE login='******'",$this->udlogin))->points / 1000);
    else
      $this->stats["ud"] = 0;

    $glops +=  2 * $this->stats["prods"];
    $glops +=  1 * $this->stats["groups"];
    $glops +=  1 * $this->stats["parties"];
    $glops +=  1 * $this->stats["screenshots"];
    $glops +=  1 * $this->stats["nfos"];
    $glops +=  1 * $this->stats["comments"];
    $glops += 20 * $this->stats["logosVote"];
    $glops +=  1 * $this->stats["ud"];
    $glops +=  1 * $this->stats["requestGlops"];
    
    return $glops;
  }
예제 #6
0
 function LoadFromDB() {
   $a = array("prods", "groups", "parties", "boards", "users", "comments");
   foreach($this->fields as $v) {
     $field = $v == "users" ? "registerDate" : "addedDate";
     $this->data[$v."_all"] = SQLLib::SelectRow("SELECT count(0) as c FROM ".$v)->c;
     $this->data[$v."_24h"] = SQLLib::SelectRow("SELECT count(0) as c FROM ".$v." WHERE (UNIX_TIMESTAMP()-UNIX_TIMESTAMP(".$field."))<=3600*24")->c;
   }
 }
예제 #7
0
  function PouetBoxAdminEditBoard( $id )
  {
    parent::__construct();

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

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

    $this->title = "edit this board: <a href='boards.php?which=".$this->id."'>"._html( $this->board->name )."</a>";
  }
예제 #8
0
  function Load( $cached = false ) {
    $s = new SQLSelect();
    $s->AddTable("buttons");
    $s->AddOrder("rand()");
    $s->AddWhere("dead = 0");
    $s->SetLimit("1");
    $this->data = SQLLib::SelectRow($s->GetQuery());

    $this->title = $this->data->type;
  }
예제 #9
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);
  }
예제 #10
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];
  }
  function Validate($post)
  {
    global $currentUser;
    $message = trim($post["message"]);

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

    if (strstr($message,"tinybrain") !== false)
      return array("</spam>");

    $r = SQLLib::SelectRow("SELECT who FROM oneliner ORDER BY addedDate DESC LIMIT 1");

    if ($r->who == $currentUser->id)
      return array("ERROR! DOUBLEPOST == ROB IS JARIG!");
  }
예제 #12
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 "";

  }
  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();
  }
예제 #14
0
  function LoadFromDB() 
  {
    $this->board = SQLLib::SelectRow(sprintf_esc("select * from boards where id = %d",$this->id));
    if (!$this->board) return;

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

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

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

    $s = new BM_Query("affiliatedboards");
    $s->AddField("affiliatedboards.type");
    $s->Attach(array("affiliatedboards"=>"group"),array("groups as group"=>"id"));
    $s->AddWhere(sprintf_esc("affiliatedboards.board = %d",$this->id));
    $this->groups = $s->perform();

    $s = new BM_Query("prods");
    $s->AddWhere(sprintf_esc("prods.boardID = %d",$this->id));
    $this->bbstros = $s->perform();
  }
예제 #15
0
 function RenderBody() {
   if (!get_login_id())
   {
     echo "<div class='content loggedout'>\n";
     printf( "<a href='login.php?return=%s'>login via SceneID</a>",_html(rootRelativePath()) );
     echo "</div>\n";
   } else {
     global $currentUser;
     echo "<div class='content loggedin'>\n";
     echo "you are logged in as<br/>\n";
     echo $currentUser->PrintLinkedAvatar()." ";
     echo $currentUser->PrintLinkedName();
     echo "</div>\n";
     if ($currentUser->IsGloperator())
     {
       $req = SQLLib::SelectRow("select count(*) as c from modification_requests where approved is null")->c;
       if ($req)
       {
         echo "<div class='content notifications'>\n";
         echo "[ <a href='admin_modification_requests.php' class='adminlink'>";
         echo $req;
         if ($req==1)
           echo " request waiting!";
         else
           echo " requests waiting!";
         echo "</a> ]";
         echo "</div>\n";
       }
     }
     echo "<div class='foot'>\n";
     echo "<a href='account.php'>account</a> ::\n";
     echo "<a href='customizer.php'>cust&ouml;omizer</a> ::\n";
     echo "<a href='logout.php'>logout</a>\n";
     echo "</div>";
   }
 }
예제 #16
0
  function Commit($data)
  {
    global $currentUser;
    global $currentUserSettings;
    global $ephemeralStorage;
    
    require_once("include_pouet/default_usersettings.php");
    $a = get_object_vars( $DEFAULT_USERSETTINGS );

    if (SQLLib::SelectRow(sprintf_esc("select id from usersettings where id=%d",(int)$currentUser->id)))
      SQLLib::UpdateRow("usersettings",$a,"id=".(int)$currentUser->id);
    else
      SQLLib::InsertRow("usersettings",array_merge(array("id"=>(int)$currentUser->id),$a) );
    $currentUserSettings = $DEFAULT_USERSETTINGS;
    $ephemeralStorage->set( "settings:".$currentUser->id, $currentUserSettings );

    return array();
  }
예제 #17
0
  static function GetFields($data,&$fields,&$js)
  {
    if ($data["creditID"])
    {
      $l = SQLLib::SelectRow(sprintf_esc("select * from credits where id = %d",$data["creditID"]));
      $fields = array(
        "creditID" => array(
          "type"=>"hidden",
          "value"=>(int)$data["creditID"],
        ),
        "oldUserID" => array(
          "type"=>"hidden",
          "value"=>(int)$l->userID,
        ),
        "oldUserRole" => array(
          "type"=>"hidden",
          "value"=>$l->role,
        ),
        "userID" => array(
          "name"=>"user",
          "type"=>"text",
          "value"=>$l->userID,
        ),
        "userRole" => array(
          "name"=>"user's role",
          "value"=>$l->role,
          "info"=>"Please separate roles with commas, e.g. 'Code, graphics, music'",
        ),
        "finalStep" => array(
          "type"=>"hidden",
          "value"=>1,
        ),
      );

      $js  = "document.observe('dom:loaded',function(){";
      $js .= "  new Autocompleter($('userID'), {\n";
      $js .= "    'dataUrl':'./ajax_users.php',\n";
      $js .= "    'processRow': function(item) {\n";
      $js .= "      return \"<img class='avatar' src='".POUET_CONTENT_URL."avatars/\" + item.avatar.escapeHTML() + \"'/> \" + item.name.escapeHTML() + \" <span class='glops'>\"+item.glops+\" glöps</span>\";\n";
      $js .= "    }\n";
      $js .= "  });\n";
      $js .= "});\n";
    }
    else
    {
      $s = new BM_Query("credits");
      $s->AddField("credits.id");
      $s->AddField("credits.role");
      $s->attach(array("credits"=>"userID"),array("users as user"=>"id"));
      $s->AddWhere(sprintf_esc("prodID = %d",$data["prod"]));
      $l = $s->perform();
      foreach($l as $v)
        $links[$v->id] = sprintf("%s [%s]",$v->user->nickname,$v->role);
      if (!$links)
        return "this prod has no credits to change !";
      $fields = array(
        "creditID" => array(
          "name"=>"select credit you want to edit",
          "type"=>"select",
          "fields"=>$links,
          "assoc"=>true,
        ),
      );
    }
  }
예제 #18
0
 static function UpdateOrInsertRow($table,$o,$where) 
 {
   if (SQLLib::SelectRow(sprintf("SELECT * FROM %s WHERE %s",$table,$where)))
     return SQLLib::UpdateRow($table,$o,$where);
   else
     return SQLLib::InsertRow($table,$o);
 }
예제 #19
0
파일: prod.php 프로젝트: neodyme60/pouet2.0
  function LoadFromDB() {
    $s = new BM_Query();
    $s->AddField("comments.id as id");
    $s->AddField("comments.comment as comment");
    $s->AddField("comments.rating as rating");
    $s->AddField("comments.addedDate as addedDate");
    $s->attach(array("comments"=>"who"),array("users as user"=>"id"));
    $s->AddTable("comments");
    $s->AddOrder("comments.addedDate");
    $s->AddWhere("comments.which=".$this->id);
    $perPage = get_setting("prodcomments");
    if ($perPage != -1)
    {
      $sc = new SQLSelect();
      $sc->AddField("count(*) as c");
      $sc->AddWhere("comments.which=".$this->id);
      $sc->AddTable("comments");

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

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

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

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

      if ($this->numPages > 1)
        $s->SetLimit( $this->perPage, (int)(($this->page-1) * $this->perPage) );
      */
    }
    $r = $s->perform();
    $this->data = $r;
  }
예제 #20
0
    $a["user"] = $currentUser->id;
    $a["vote"] = $vote;
    SQLLib::InsertRow("logos_votes",$a);
  }

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

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

    if ($logo)
    {
      $box = new PouetBoxLogoVote($logo);
      $box->Render();
    }
    else
    {
      $box = new PouetBoxLogoLama();
      $box->Render();
    }
    exit();
  }
}
예제 #21
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() ));
}

?>
예제 #22
0
function calculate_popularity( $views )
{
  global $MAX_PROD_VIEWS;
  if (!$MAX_PROD_VIEWS)
    $MAX_PROD_VIEWS = SQLLib::SelectRow("SELECT MAX(views) as m FROM prods")->m;
  
  return $views * 100.0 / $MAX_PROD_VIEWS;
}