<?php auto_set_params(array('commit', 'query')); set_title("Tag Implications"); create_page_params(); if (Request::$params->commit == "Search Aliases") { redirect_to("tag_alias#index", array('query' => Request::$params->query)); } if (Request::$params->query) { $name = "%" . Request::$params->query . "%"; $implications = TagImplication::find_all(array('calc_rows', 'order' => "is_pending DESC, (SELECT name FROM tags WHERE id = tag_implications.predicate_id), (SELECT name FROM tags WHERE id = tag_implications.consequent_id)", 'per_page' => 20, 'conditions' => array("predicate_id IN (SELECT id FROM tags WHERE name LIKE ?) OR consequent_id IN (SELECT id FROM tags WHERE name LIKE ?)", $name, $name), 'page' => Request::$params->page)); } else { $implications = TagImplication::find_all(array('calc_rows', 'order' => "is_pending DESC, (SELECT name FROM tags WHERE id = tag_implications.predicate_id), (SELECT name FROM tags WHERE id = tag_implications.consequent_id)", 'per_page' => 20, 'page' => Request::$params->page)); } calc_pages(); respond_to_list("implications");
<?php required_params('implications', 'commit'); auto_set_params('reason'); $ids = array_keys(Request::$params->implications); switch (Request::$params->commit) { case "Delete": $can_delete = true; # Dunno where 'creator_id' comes from. foreach ($ids as $x) { $ti = TagImplication::find($x); // $can_delete = ($ti->is_pending && $ti->creator_id == User::$current->id); $tis[] = $ti; } if (User::is('>=40') && $can_delete) { foreach ($tis as $ti) { $ti->destroy_and_notify(User::$current, Request::$params->reason); } notice("Tag implications deleted"); redirect_to("#index"); } else { access_denied(); } break; case "Approve": if (User::is('>=40')) { foreach ($ids as $x) { if (CONFIG::enable_asynchronous_tasks) { // JobTask.create(:task_type => "approve_tag_implication", :status => "pending", :data => {"id" => x, "updater_id" => @current_user.id, "updater_ip_addr" => request.remote_ip}) } else { $ti = TagImplication::find($x);
<?php set_title(CONFIG::app_name . " Forum"); create_page_params(); auto_set_params(array('query', 'parent_id')); if (isset(request::$params->parent_id)) { $forum_posts = ForumPost::find_all(array('order' => "is_sticky desc, updated_at DESC", 'per_page' => 100, 'conditions' => array("parent_id = ?", request::$params->parent_id), 'page' => request::$params->page)); } else { $forum_posts = ForumPost::find_all(array('order' => "is_sticky desc, updated_at DESC", 'per_page' => 30, 'conditions' => array("parent_id IS NULL"), 'page' => request::$params->page)); } calc_pages(); respond_to_list($forum_posts);
<?php required_params('post'); if (User::is('<=20') && Post::count(array('conditions' => array("user_id = ? AND created_at > ? ", User::$current->id, gmd_math('sub', '1D')))) >= CONFIG::member_post_limit) { respond_to_error("Daily limit exceeded", "#error", array('status' => 421)); } auto_set_params(array('md5')); $status = User::is('>=30') ? 'active' : 'pending'; Request::$params->post = array_merge(Request::$params->post, array('updater_user_id' => User::$current->id, 'updater_ip_addr' => Request::$remote_ip, 'user_id' => User::$current->id, 'ip_addr' => Request::$remote_ip, 'status' => $status, 'tempfile_path' => $_FILES['post']['tmp_name']['file'], 'tempfile_name' => $_FILES['post']['name']['file'], 'is_upload' => true)); $post = Post::create(Request::$params->post); if ($post->record_errors->blank()) { if (Request::$params->md5 && $post->md5 != strtolower(Request::$params->md5)) { $post->destroy(); respond_to_error("MD5 mismatch", '#error', array('status' => 420)); } else { $api_data = array('post_id' => $post->id, 'location' => url_for('post#show', array('id' => $post->id))); if (CONFIG::dupe_check_on_upload && $post->is_image() && empty($post->parent_id)) { // if (Request::$format == "xml" || Request::$format == "json") { // $options = array('services' => SimilarImages::get_services('local'), 'type' => 'post', 'source' => $post); // $res = SimilarImages::similar_images($options); // if (!empty($res['posts'])) { // $post->tags .= " possible_duplicate"; // $post->save(); // $api_data['has_similar_hits'] = true; // } // } $api_data['similar_location'] = url_for('post#similar', array('id' => $post->id, 'initial' => 1)); respond_to_success("Post uploaded", array('#similar', array('id' => $post->id, 'initial' => 1)), array('api' => $api_data)); } else { respond_to_success("Post uploaded", array('#show', array('id' => $post->id, 'tag_title' => $post->tag_title())), array('api' => $api_data)); }
<?php set_title("Notes"); create_page_params(); auto_set_params('post_id'); if (!empty(Request::$params->post_id)) { $posts = Post::find_all(array('order' => "last_noted_at DESC", 'conditions' => array("id = ?", Request::$params->post_id), 'per_page' => 100, 'page' => $page)); } else { $posts = Post::find_all(array('order' => "last_noted_at DESC", 'conditions' => "last_noted_at IS NOT NULL", 'per_page' => 16, 'page' => $page)); } // $posts = Post.paginate :order => "last_noted_at DESC", :conditions => "last_noted_at IS NOT NULL", :per_page => 16, :page => params[:page] // respond_to do |fmt| // fmt.html // fmt.xml {render :xml => @posts.map {|x| x.notes}.flatten.to_xml(:root => "notes")} // fmt.json {render :json => @posts.map {|x| x.notes}.flatten.to_json} // end calc_pages();
<?php auto_set_params(array('tags', 'url', 'parent', 'rating', 'ref')); set_title('Upload'); $deleted_posts = 0; // $deleted_posts = FlaggedPostDetail.new_deleted_posts(@current_user) # if params[:url] # @post = Post.find(:first, :conditions => ["source = ?", params[:url]]) # end // if @post.nil? // @post = Post.new // end
<?php auto_set_params('url'); set_title("Login");
<?php required_params('post_id'); auto_set_params('pool_id'); if (Request::$post) { if (!Request::$params->pool_id) { return; } // $pool = new Pool('find', Request::$params->pool_id); $pool = Pool::find(Request::$params->pool_id); $_SESSION['last_pool_id'] = $pool->id; if (isset(Request::$params->pool) && !empty(Request::$params->pool['sequence'])) { $sequence = Request::$params->pool['sequence']; } else { $sequence = null; } try { $pool->add_post(Request::$params->post_id, array('sequence' => $sequence, 'user' => User::$current->id)); respond_to_success('Post added', array('post#show', 'id' => Request::$params->post_id)); } catch (Exception $e) { if ($e->getMessage() == 'Post already exists') { respond_to_error($e->getMessage(), array('post#show', array('id' => Request::$params->post_id)), array('status' => 423)); } elseif ($e->getMessage() == 'Access Denied') { access_denied(); } else { respond_to_error($e->getMessage(), array('post#show', array('id' => Request::$params->post_id))); } } } else { if (User::$current->is_anonymous) { $pools = Pool::find_all(array('order' => "name", 'conditions' => "is_active = TRUE AND is_public = TRUE"));
<?php set_title("Comments"); auto_set_params(array('page' => 1)); create_page_params(array('limit' => 10)); if (Request::$format == "json" || Request::$format == "xml") { $comments = Comment::find_all(array_merge(Comment::generate_sql(Request::$params), array('per_page' => 25, 'page' => Request::$params->page, 'order' => 'id DESC'))); // Comment.paginate(Comment.generate_sql(params).merge(:per_page => 25, :page => params[:page], :order => "id DESC")) respond_to_list($comments); } else { $posts = Post::find_all(array('calc_rows', 'order' => 'last_commented_at DESC', 'conditions' => 'last_commented_at IS NOT NULL', 'per_page' => 10, 'page' => Request::$params->page)); // Post.paginate :order => "last_commented_at DESC", :conditions => "last_commented_at IS NOT NULL", :per_page => 10, :page => params[:page] // vde($posts); $comments = array(); foreach ($posts as $post) { $comments[] = $post->recent_comments(); } // @posts.each { |post| comments.push(*post.recent_comments) } // exit; // newest_comment = comments.max {|a,b| a.created_at <=> b.created_at } // if !@current_user.is_anonymous? && newest_comment && @current_user.last_comment_read_at < newest_comment.created_at // @current_user.update_attribute(:last_comment_read_at, newest_comment.created_at) // end // $posts = $posts.select {|x| x.can_be_seen_by?(@current_user, {:show_deleted => true})} $i = 0; foreach ($posts as &$x) { if (!$x->can_be_seen_by(User::$current, array('show_deleted' => true))) { unset($posts->{$i}); } unset($x); $i++;
<?php set_title("Moderation queue"); auto_set_params('commit', 'reason', 'reason2'); if (Request::$post) { $posts = array(); if (!empty(Request::$params->ids)) { foreach (array_keys(Request::$params->ids) as $post_id) { $post = Post::find($post_id); if (Request::$params->commit == "Approve") { $post->approve(User::$current->id); } elseif (Request::$params->commit == "Delete") { $post->destroy_with_reason(Request::$params->reason ? Request::$params->reason : Request::$params->reason2, User::$current); # Include post data for the parent: deleted posts aren't counted as children, so # their has_children attribute may change. if (!empty($post->parent_id)) { $posts[] = $post->get_parent(); } } $post->reload(); $posts[] = $post; } } $posts = array_unique($posts); if (Request::$format == "json" || Request::$format == "xml") { $api_data = Post::batch_api_data($posts); } else { $api_data = array(); } if (Request::$params->commit == "Approve") { respond_to_success("Post approved", "#moderate", array('api' => $api_data));
<?php auto_set_params(array('forum_post' => array())); $forum_post = ForumPost::create(array_merge(request::$params->forum_post, array('creator_id' => user::$current->id))); if ($forum_post->record_errors->blank()) { if (empty(request::$params->forum_post['parent_id'])) { notice("Forum topic created"); redirect_to("#show", array('id' => $forum_post->root_id)); } else { notice("Response posted"); redirect_to("#show", array('id' => $forum_post->root_id, 'page' => ceil($forum_post->root->response_count / 30))); } } else { render_error($forum_post); }
<?php auto_set_params(array('name', 'order', 'type' => 'any')); create_page_params(); set_title("Tags"); if (!empty(Request::$params->limit) && Request::$params->limit == 0) { $limit = null; } elseif (!empty(Request::$params->limit) && ctype_digit(Request::$params->limit)) { $limit = (int) Request::$params->limit; } else { $limit = 50; } $order = 'name'; if (!empty(Request::$params->order)) { if (Request::$params->order == 'count') { $order = 'post_count desc'; } elseif (Request::$params->order == 'date') { $order = 'id desc'; } } $conds = array('true'); $cond_params = array(); if (!empty(Request::$params->name)) { $conds[] = 'name LIKE ?'; $cond_params[] = '%' . str_replace('*', '%', Request::$params->name) . '%'; } if (ctype_digit(Request::$params->type)) { Request::$params->type = (int) Request::$params->type; $conds[] = 'tag_type = ?'; $cond_params[] = Request::$params->type; }
<?php auto_set_params(array('type', 'parent_id')); $forum_post = ForumPost::blank(); if (request::$params->parent_id) { $forum_post->parent_id = request::$params->parent_id; } if (request::$params->type == "alias") { $forum_post->title = "Tag Alias: "; $forum_post->body = "Aliasing ___ to ___.\n\nReason: "; } elseif (request::$params->type == "impl") { $forum_post->title = "Tag Implication: "; $forum_post->body = "Implicating ___ to ___.\n\nReason: "; }