Skip to content

Instantly share code, notes, and snippets.

<?php
if (isset($_POST["PHPSESSID"])) {
session_id($_POST["PHPSESSID"]);
}
session_start();
if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) {
// Usually we'll only get an invalid upload if our PHP.INI upload sizes are smaller than the size of the file we allowed
// to be uploaded.
header("HTTP/1.1 500 File Upload Error");
<?php
session_start();
if (count($_FILES)) {
// Handle degraded form uploads here. Degraded form uploads are POSTed to index.php. SWFUpload uploads
// are POSTed to upload.php
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
def set_locale
locales = ['en-US', 'en-AU']
begin
# Try to auto-detect it
if request.headers['Accept-Language']
browser_language = request.headers['Accept-Language'].split(',')[0]
browser_language = browser_language.split('-')[0] + '-' + browser_language.split('-')[1].upcase
session[:locale] = browser_language
end
session[:locale] = params[:locale] if params[:locale]
sub create($%) {
my GCX::Runtime::Community $self = shift;
my (%params) = @_;
my $system = $params{'system'};
#short-circuit on invalid community names or invalid guid
($params{'name'} = $params{'display_name'}) =~ s/[^a-z0-9_~\-]/_/g;
return undef if(!$self->isValidName($params{'name'}, $system) ||$params{'guid'} !~ /^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/io);
#default values
#retrieve values from form for the new community
our $communityName = getInParam('name');
my $communityTitle = getInParam('title');
my $description = getInParam('description');
my $templateID = getInParam('template');
my $type = getInParam('type') || 'community';
my $parent = getInParam('parent');
my $nestingType = getInParam('nestingType');
if($parent)
We couldn’t find that file to show.
#retrieve values from form for the new community
my $communityDisplayName = getInParam('display_name');
our $communityName = getInParam('display_name');
$communityName =~ s/[^a-z0-9_~\-]/_/g;
my $communityTitle = getInParam('title');
my $description = getInParam('description');
my $templateID = getInParam('template');
my $type = getInParam('type') || 'community';
@twinge
twinge / gist:59600
Created February 6, 2009 20:47
system.script, communityCreator.js
function communityCreator_selectTemplate(tdObj) {
var input = tdObj.getElementsByTagName("input")[0];
if(!input.disabled)
input.checked = true;
}
function communityCreator_submit(form) {
var name = form.elements["display_name"].value.replace(/[^a-z0-9_~\-]/g, "_");
var url = "/report-raw/global/checkCommunityName?name="+escape(name);
importXML(url, "communityCreator_checkNameResults");
class SessionCleaner
def self.remove_stale_sessions
timeout = 360.minutes.ago
CGI::Session::ActiveRecordStore::Session.destroy_all( ['updated_at < ? ', timeout] )
Cart.destroy_all( ["user_id is null and updated_at < ?", timeout])
end
end
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ '