Permalink
Browse files

initial commit, based on flamework trunk

  • Loading branch information...
iamcal committed Jul 21, 2011
0 parents commit 0893c886cd1ba074e21c110ad79bec322b537beb
Showing with 12,891 additions and 0 deletions.
  1. +25 −0 .htaccess
  2. +5 −0 403.php
  3. +5 −0 404.php
  4. +104 −0 auth.php
  5. +57 −0 avatar.php
  6. +38 −0 checkcookie.php
  7. +3 −0 cron/.htaccess
  8. +87 −0 css/main.css
  9. BIN images/canvas.png
  10. BIN images/stripes_bg.gif
  11. +92 −0 import.php
  12. +3 −0 include/.htaccess
  13. +186 −0 include/init.php
  14. +110 −0 include/lib_crumb.php
  15. +91 −0 include/lib_curl.php
  16. +438 −0 include/lib_db.php
  17. +126 −0 include/lib_email.php
  18. +262 −0 include/lib_error.php
  19. +163 −0 include/lib_log.php
  20. +61 −0 include/lib_login.php
  21. +384 −0 include/lib_sanitize.php
  22. +60 −0 include/lib_smarty.php
  23. +76 −0 include/lib_useragent.php
  24. +44 −0 include/lib_utf8.php
  25. +393 −0 include/smarty_2.6.26/Config_File.class.php
  26. +1,992 −0 include/smarty_2.6.26/Smarty.class.php
  27. +2,365 −0 include/smarty_2.6.26/Smarty_Compiler.class.php
  28. +157 −0 include/smarty_2.6.26/debug.tpl
  29. +67 −0 include/smarty_2.6.26/internals/core.assemble_plugin_filepath.php
  30. +43 −0 include/smarty_2.6.26/internals/core.assign_smarty_interface.php
  31. +79 −0 include/smarty_2.6.26/internals/core.create_dir_structure.php
  32. +61 −0 include/smarty_2.6.26/internals/core.display_debug_console.php
  33. +44 −0 include/smarty_2.6.26/internals/core.get_include_path.php
  34. +23 −0 include/smarty_2.6.26/internals/core.get_microtime.php
  35. +80 −0 include/smarty_2.6.26/internals/core.get_php_resource.php
  36. +59 −0 include/smarty_2.6.26/internals/core.is_secure.php
  37. +47 −0 include/smarty_2.6.26/internals/core.is_trusted.php
  38. +125 −0 include/smarty_2.6.26/internals/core.load_plugins.php
  39. +74 −0 include/smarty_2.6.26/internals/core.load_resource_plugin.php
  40. +71 −0 include/smarty_2.6.26/internals/core.process_cached_inserts.php
  41. +37 −0 include/smarty_2.6.26/internals/core.process_compiled_include.php
  42. +101 −0 include/smarty_2.6.26/internals/core.read_cache_file.php
  43. +71 −0 include/smarty_2.6.26/internals/core.rm_auto.php
  44. +54 −0 include/smarty_2.6.26/internals/core.rmdir.php
  45. +71 −0 include/smarty_2.6.26/internals/core.run_insert_handler.php
  46. +50 −0 include/smarty_2.6.26/internals/core.smarty_include_php.php
  47. +96 −0 include/smarty_2.6.26/internals/core.write_cache_file.php
  48. +91 −0 include/smarty_2.6.26/internals/core.write_compiled_include.php
  49. +35 −0 include/smarty_2.6.26/internals/core.write_compiled_resource.php
  50. +54 −0 include/smarty_2.6.26/internals/core.write_file.php
  51. +103 −0 include/smarty_2.6.26/plugins/block.textformat.php
  52. +40 −0 include/smarty_2.6.26/plugins/compiler.assign.php
  53. +40 −0 include/smarty_2.6.26/plugins/function.assign_debug_info.php
  54. +142 −0 include/smarty_2.6.26/plugins/function.config_load.php
  55. +80 −0 include/smarty_2.6.26/plugins/function.counter.php
  56. +102 −0 include/smarty_2.6.26/plugins/function.cycle.php
  57. +35 −0 include/smarty_2.6.26/plugins/function.debug.php
  58. +49 −0 include/smarty_2.6.26/plugins/function.eval.php
  59. +221 −0 include/smarty_2.6.26/plugins/function.fetch.php
  60. +143 −0 include/smarty_2.6.26/plugins/function.html_checkboxes.php
  61. +142 −0 include/smarty_2.6.26/plugins/function.html_image.php
  62. +122 −0 include/smarty_2.6.26/plugins/function.html_options.php
  63. +156 −0 include/smarty_2.6.26/plugins/function.html_radios.php
  64. +331 −0 include/smarty_2.6.26/plugins/function.html_select_date.php
  65. +194 −0 include/smarty_2.6.26/plugins/function.html_select_time.php
  66. +177 −0 include/smarty_2.6.26/plugins/function.html_table.php
  67. +165 −0 include/smarty_2.6.26/plugins/function.mailto.php
  68. +85 −0 include/smarty_2.6.26/plugins/function.math.php
  69. +119 −0 include/smarty_2.6.26/plugins/function.popup.php
  70. +40 −0 include/smarty_2.6.26/plugins/function.popup_init.php
  71. +43 −0 include/smarty_2.6.26/plugins/modifier.capitalize.php
  72. +33 −0 include/smarty_2.6.26/plugins/modifier.cat.php
  73. +32 −0 include/smarty_2.6.26/plugins/modifier.count_characters.php
  74. +29 −0 include/smarty_2.6.26/plugins/modifier.count_paragraphs.php
  75. +29 −0 include/smarty_2.6.26/plugins/modifier.count_sentences.php
  76. +33 −0 include/smarty_2.6.26/plugins/modifier.count_words.php
  77. +58 −0 include/smarty_2.6.26/plugins/modifier.date_format.php
  78. +90 −0 include/smarty_2.6.26/plugins/modifier.debug_print_var.php
  79. +32 −0 include/smarty_2.6.26/plugins/modifier.default.php
  80. +93 −0 include/smarty_2.6.26/plugins/modifier.escape.php
  81. +28 −0 include/smarty_2.6.26/plugins/modifier.indent.php
  82. +26 −0 include/smarty_2.6.26/plugins/modifier.lower.php
  83. +35 −0 include/smarty_2.6.26/plugins/modifier.nl2br.php
  84. +48 −0 include/smarty_2.6.26/plugins/modifier.regex_replace.php
  85. +30 −0 include/smarty_2.6.26/plugins/modifier.replace.php
  86. +30 −0 include/smarty_2.6.26/plugins/modifier.spacify.php
  87. +29 −0 include/smarty_2.6.26/plugins/modifier.string_format.php
  88. +33 −0 include/smarty_2.6.26/plugins/modifier.strip.php
  89. +32 −0 include/smarty_2.6.26/plugins/modifier.strip_tags.php
  90. +50 −0 include/smarty_2.6.26/plugins/modifier.truncate.php
  91. +26 −0 include/smarty_2.6.26/plugins/modifier.upper.php
  92. +29 −0 include/smarty_2.6.26/plugins/modifier.wordwrap.php
  93. +75 −0 include/smarty_2.6.26/plugins/outputfilter.trimwhitespace.php
  94. +31 −0 include/smarty_2.6.26/plugins/shared.escape_special_chars.php
  95. +46 −0 include/smarty_2.6.26/plugins/shared.make_timestamp.php
  96. +145 −0 index.php
  97. +37 −0 signout.php
  98. +3 −0 templates/.htaccess
  99. +21 −0 templates/inc_foot.txt
  100. +30 −0 templates/inc_head.txt
  101. +46 −0 templates/page_avatar.txt
  102. +5 −0 templates/page_checkcookie.txt
  103. +11 −0 templates/page_error_403.txt
  104. +11 −0 templates/page_error_404.txt
  105. +11 −0 templates/page_error_misc.txt
  106. +56 −0 templates/page_index.txt
  107. +15 −0 templates/page_index_loggedout.txt
  108. +12 −0 templates/page_signout.txt
  109. +46 −0 templates/page_top.txt
  110. +53 −0 templates/page_you.txt
  111. +3 −0 templates_c/.htaccess
  112. +62 −0 top.php
  113. +58 −0 you.php
@@ -0,0 +1,25 @@
+FileETag none
+Options -MultiViews
+
+php_value magic_quotes_gpc 0
+php_value register_globals 0
+php_value magic_quotes_runtime 0
+php_value track_errors 1
+php_value last_modified off
+php_value short_open_tag on
+
+php_value error_reporting 2147483639
+
+DirectoryIndex index.php
+ErrorDocument 404 /404.php
+ErrorDocument 403 /403.php
+
+RewriteEngine on
+
+RewriteRule ^auth/$ /auth.php [L]
+RewriteRule ^checkcookie/$ /checkcookie.php [L]
+RewriteRule ^signout/$ /signout.php [L]
+RewriteRule ^import/$ /import.php [L]
+RewriteRule ^you/$ /you.php [L]
+RewriteRule ^a-(\d+)/$ /avatar.php?id=$1 [L,QSA]
+RewriteRule ^top/$ /top.php [L]
@@ -0,0 +1,5 @@
+<?
+ include('include/init.php');
+
+ error_403();
+?>
@@ -0,0 +1,5 @@
+<?
+ include('include/init.php');
+
+ error_404();
+?>
104 auth.php
@@ -0,0 +1,104 @@
+<?
+ include('include/init.php');
+
+ loadlib('curl');
+
+
+ #
+ # start of process
+ #
+
+ if (!$_GET['code'] && !$_GET['error']){
+
+ $args = array(
+ 'response_type' => 'code',
+ 'client_id' => $cfg['api_client_id'],
+ 'redirect_uri' => $cfg['api_redir_url'],
+ 'scope' => 'identity',
+ );
+
+ $base_url = "{$cfg['api_url']}/oauth2/authorize";
+
+ $auth_url = build_url($base_url, $args);
+
+ header("location: $auth_url");
+ exit;
+ }
+
+ function build_url($base_url, $args, $more=array()){
+
+ foreach ($more as $k => $v){
+ $args[$k] = $v;
+ }
+
+ $pairs = array();
+ foreach ($args as $k => $v){
+ $pairs[] = urlencode($k).'='.urlencode($v);
+ }
+ return $base_url.'?'.implode('&', $pairs);
+ }
+
+
+ #
+ # oauth error
+ #
+
+ if ($_GET['error']){
+
+ error_misc(array(
+ 'ok' => 0,
+ 'error' => 'oauth_error',
+ 'msg' => $_GET['error'],
+ 'desc' => $_GET['error_description'],
+ ));
+ exit;
+ }
+
+
+ #
+ # exchange token
+ #
+
+ $args = array(
+ 'grant_type' => 'authorization_code',
+ 'code' => $_GET['code'],
+ 'client_id' => $cfg['api_client_id'],
+ 'client_secret' => $cfg['api_client_secret'],
+ 'redirect_uri' => $cfg['api_redir_url'],
+ );
+
+ $ret = curl_api_call('/oauth2/token', $args);
+
+ if (!$ret['ok']) error_misc($ret);
+
+ $oauth_token = $ret['access_token'];
+
+ login_do_login($oauth_token);
+
+
+ #
+ # good to go - fetch some player info
+ #
+
+ $ret = curl_api_call('/simple/auth.check', array(
+ 'oauth_token' => $oauth_token,
+ ));
+
+ db_insert_dupe('glitchmash_players', array(
+ 'tsid' => AddSlashes($ret['player_tsid']),
+ 'date_added' => time(),
+ 'oauth_token' => AddSlashes($oauth_token),
+ 'name' => AddSlashes($ret['player_name']),
+ ), array(
+ 'oauth_token' => AddSlashes($oauth_token),
+ 'name' => AddSlashes($ret['player_name']),
+ ));
+
+
+ #
+ # player is logged in - go and import their avatar
+ #
+
+ header("location: /checkcookie/?redir=".urlencode('/import/'));
+ exit;
+?>
@@ -0,0 +1,57 @@
+<?
+ include('include/init.php');
+
+ #
+ # fetch avatar
+ #
+
+ $id_enc = intval($_GET['id']);
+
+ $avatar = db_single(db_fetch("SELECT * FROM glitchmash_avatars WHERE id='$id_enc'"));
+
+ if (!$avatar['id']) error_404();
+
+ $avatar['details'] = unserialize($avatar['details']);
+ foreach ($avatar['details'] as $slot => $id){
+ $clothing[$id]++;
+ }
+
+
+ #
+ # fetch player
+ #
+
+ $tsid_enc = AddSlashes($avatar['player_tsid']);
+
+ $avatar['player'] = db_single(db_fetch("SELECT * FROM glitchmash_players WHERE tsid='$tsid_enc'"));
+
+
+ #
+ # fetch all clothing rows
+ #
+
+ if (count($clothing)){
+ $clothing_ids = implode(',', array_keys($clothing));
+ $clothing = array();
+
+ $ret = db_fetch("SELECT * FROM glitchmash_clothing WHERE id IN ($clothing_ids)");
+ foreach ($ret['rows'] as $row){
+
+ $clothing[$row['id']] = $row;
+ }
+
+ foreach ($avatar['details'] as $slot => $id){
+
+ $avatar['details'][$slot] = $clothing[$id];
+ }
+ }
+
+ $smarty->assign('avatar', $avatar);
+
+
+ #
+ # output
+ #
+
+ $smarty->display('page_avatar.txt');
+?>
@@ -0,0 +1,38 @@
+<?
+ #
+ # $Id$
+ #
+
+ include("include/init.php");
+
+
+ #
+ # do we have a valid cookie set?
+ #
+dumper($cfg);
+ if (!$cfg['user']['tsid']){
+
+ $GLOBALS['error']['badcookies'] = 1;
+ $smarty->display("page_checkcookie.txt");
+ exit;
+ }
+
+
+ #
+ # where shall we bounce to?
+ #
+
+ $redir = "/";
+
+ if ($alt_redir = get_str("redir")){
+ $redir = $alt_redir;
+ }
+
+
+ #
+ # go!
+ #
+
+ header("location: {$redir}");
+ exit;
+?>
@@ -0,0 +1,3 @@
+Order Allow,Deny
+Allow from none
+Deny from all
@@ -0,0 +1,87 @@
+
+body {
+ font-family: sans-serif;
+ font-size: 16px;
+ color: darkslategrey;
+ margin-top: 25px;
+ margin-left: 0;
+ margin-right: 0;
+ margin-bottom: 100px;
+ background-color: #D0E0F1;
+ background-image: url('/images/canvas.png');
+ text-align: center;
+}
+
+#main {
+ background-color: white;
+ border: 1px dotted #CCC;
+ padding: 2em;
+}
+
+.content {
+ margin: 0 auto;
+ width: 800px;
+ text-align: left;
+}
+
+#nav, #footer-left, #footer-right {
+ float: right;
+ font-size: 13px;
+ padding: 10px 25px;
+ background-color: #DEF1C0;
+ border: 1px solid #ECF7DB;
+ opacity: .85;
+
+}
+
+#nav a, #footer-left a, #footer-right a {
+ color: darkslategrey;
+}
+
+#nav {
+ margin: 0 0 25px 0;
+}
+
+#footer-left {
+ float: left;
+ margin: 25px 0 25px 0;
+}
+
+#footer-right {
+ margin: 25px 0 25px 0;
+}
+
+
+h1 {
+ margin-top: 0;
+}
+
+.admin-section {
+ background-image: url("/images/stripes_bg.gif");
+ border-top: 1px solid #BECCCC;
+ border-bottom: 1px solid #BECCCC;
+ padding: 40px;
+ position: relative;
+ text-align: left;
+}
+
+pre.admin-debug {
+ background: none repeat scroll 0 0 #000000;
+ color: #00FF00;
+ font-size: 14px;
+ margin: 0;
+ padding: 1em;
+}
+
+p.error {
+ background-color: #f99;
+}
+
+p.message {
+ background-color: #9f9;
+}
+
+p.highlight {
+ background-color: #ECF7DB;
+ padding: 4px;
+}
Binary file not shown.
Binary file not shown.
Oops, something went wrong.

0 comments on commit 0893c88

Please sign in to comment.