--- .arcconfig	(revision 0)
+++ .arcconfig	(working copy)
@@ -0,0 +1,7 @@
+{
+  "project_id": "infoarena",
+  "lint_engine": "InfoarenaLintEngine",
+  "phutil_libraries": {
+    "lint": "lint/"
+  }
+}
Index: .gitignore
new file mode 100644
===================================================================
--- .gitignore	(revision 0)
+++ .gitignore	(working copy)
@@ -0,0 +1,21 @@
+config.php
+eval/config.php
+
+hphp/config.hdf
+nginx.conf
+apache.conf
+www/.htaccess
+
+common/lcs
+jrun/jrun
+
+attach/*
+cache/
+smf/attachments/*
+scripts/newsletter-logs/
+www/static/images/avatar/
+www/static/images/latex/
+www/static/images/tmp/
+
+arcanist/
+libphutil/
Index: Makefile
===================================================================
--- Makefile	(revision 1175)
+++ Makefile	(working copy)
@@ -1,4 +1,4 @@
-.PHONY: hphp-build clean-cache clean-hphp clean
+.PHONY: hphp-build clean-cache clean-hphp clean lint
 
 hphp-build:
 	mkdir -p hphp/build/
@@ -16,3 +16,19 @@ clean-sessions:
 	find /var/infoarena/sessions/ -name sess_\* -exec rm {} +
 
 clean: clean-cache clean-hphp clean-sessions
+
+arcanist:
+	git clone git://github.com/facebook/arcanist.git
+
+libphutil:
+	git clone git://github.com/facebook/libphutil.git
+	libphutil/scripts/build_xhpast.sh
+
+lint: arcanist libphutil
+	arcanist/bin/arc lint --apply-patches
+
+lint-all: arcanist libphutil
+	arcanist/bin/arc lint --apply-patches --lintall
+
+lint-repo: arcanist libphutil
+	find . -name \*.php | xargs arcanist/bin/arc lint --lintall --never-apply-patches
Index: lint/.phutil_module_cache
new file mode 100644
===================================================================
--- lint/.phutil_module_cache	(revision 0)
+++ lint/.phutil_module_cache	(working copy)
@@ -0,0 +1 @@
+{"engine":{"signature":"7b7a87c3ecd8e8ce6ec2d3b80138244c","spec":{"declares":{"class":{"InfoarenaLintEngine":"InfoarenaLintEngine.php:953"},"interface":[],"function":[],"source":{"InfoarenaLintEngine.php":true}},"requires":{"class":{"ArcanistLintEngine":["InfoarenaLintEngine.php:981"],"ArcanistPhutilModuleLinter":["InfoarenaLintEngine.php:1359"],"ArcanistGeneratedLinter":["InfoarenaLintEngine.php:1984"],"ArcanistNoLintLinter":["InfoarenaLintEngine.php:2081"],"ArcanistTextLinter":["InfoarenaLintEngine.php:2170","InfoarenaLintEngine.php:2495","InfoarenaLintEngine.php:2350","InfoarenaLintEngine.php:2680","InfoarenaLintEngine.php:2871"],"ArcanistSpellingLinter":["InfoarenaLintEngine.php:3050"],"ArcanistFilenameLinter":["InfoarenaLintEngine.php:4100"],"ArcanistXHPASTLinter":["InfoarenaLintEngine.php:4279","InfoarenaLintEngine.php:4337","InfoarenaLintEngine.php:4513","InfoarenaLintEngine.php:4629","InfoarenaLintEngine.php:4746","InfoarenaLintEngine.php:4863"],"ArcanistApacheLicenseLinter":["InfoarenaLintEngine.php:5611"],"ArcanistLintSeverity":["InfoarenaLintEngine.php:2406","InfoarenaLintEngine.php:2736","InfoarenaLintEngine.php:2925","InfoarenaLintEngine.php:4572","InfoarenaLintEngine.php:4689","InfoarenaLintEngine.php:4806","InfoarenaLintEngine.php:4922"]},"interface":[],"function":[],"source":{"InfoarenaLintEngine.php":["__init__.php:687"]},"module":{"arcanist:lint\/engine\/base":["__init__.php:104"],"arcanist:lint\/linter\/apachelicense":["__init__.php:159"],"arcanist:lint\/linter\/filename":["__init__.php:223"],"arcanist:lint\/linter\/generated":["__init__.php:282"],"arcanist:lint\/linter\/nolint":["__init__.php:342"],"arcanist:lint\/linter\/phutilmodule":["__init__.php:399"],"arcanist:lint\/linter\/spelling":["__init__.php:462"],"arcanist:lint\/linter\/text":["__init__.php:521"],"arcanist:lint\/linter\/xhpast":["__init__.php:576"],"arcanist:lint\/severity":["__init__.php:633"]}},"chain":{"class":{"InfoarenaLintEngine":"ArcanistLintEngine"}},"messages":[]}}}
\ No newline at end of file
Index: lint/__phutil_library_init__.php
new file mode 100644
===================================================================
--- lint/__phutil_library_init__.php	(revision 0)
+++ lint/__phutil_library_init__.php	(working copy)
@@ -0,0 +1,3 @@
+<?php
+
+phutil_register_library('lint', __FILE__);
Index: lint/__phutil_library_map__.php
new file mode 100644
===================================================================
--- lint/__phutil_library_map__.php	(revision 0)
+++ lint/__phutil_library_map__.php	(working copy)
@@ -0,0 +1,23 @@
+<?php
+
+/**
+ * This file is automatically generated. Use 'phutil_mapper.php' to rebuild it.
+ * @generated
+ */
+
+phutil_register_library_map(array(
+  'class' =>
+  array(
+    'InfoarenaLintEngine' => 'engine',
+  ),
+  'function' =>
+  array(
+  ),
+  'requires_class' =>
+  array(
+    'InfoarenaLintEngine' => 'ArcanistLintEngine',
+  ),
+  'requires_interface' =>
+  array(
+  ),
+));
Index: lint/engine/InfoarenaLintEngine.php
new file mode 100644
===================================================================
--- lint/engine/InfoarenaLintEngine.php	(revision 0)
+++ lint/engine/InfoarenaLintEngine.php	(working copy)
@@ -0,0 +1,176 @@
+<?php
+
+/*
+ * Copyright 2012 Bogdan-Cristian Tătăroiu
+ * Copyright 2012 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Infoarena's lint engine based on the PhutilLintEngine in Arcanist.
+ * The PhutilLintEngine was altered so that certain currently unfixable tests
+ * are disabled. The engine will ignore any external libraries we use, which
+ * are unfortunately quite spread out.
+ *
+ * @group linter
+ */
+final class InfoarenaLintEngine extends ArcanistLintEngine {
+
+    public function buildLinters() {
+        $linters = array();
+
+        $paths = $this->getPaths();
+
+        // This needs to go first so that changes to generated files cause
+        // module linting. This linter also operates on removed files, because
+        // removing a file changes the static properties of a module.
+        $module_linter = new ArcanistPhutilModuleLinter();
+        $linters[] = $module_linter;
+        foreach ($paths as $path) {
+            $module_linter->addPath($path);
+        }
+
+        // Remaining lint engines operate on file contents and ignore removed
+        // files.
+        foreach ($paths as $key => $path) {
+            if (!$this->pathExists($path)) {
+                unset($paths[$key]);
+                continue;
+            }
+            // Don't run lint on third-party or junk stuff.
+            if ($this->isExternalLibrary($path)) {
+                unset($paths[$key]);
+            }
+        }
+
+        $generated_linter = new ArcanistGeneratedLinter();
+        $linters[] = $generated_linter;
+
+        $nolint_linter = new ArcanistNoLintLinter();
+        $linters[] = $nolint_linter;
+
+        $text_linter = new ArcanistTextLinter();
+        $text_linter->setCustomSeverityMap(
+            array(
+                // Disable character set linting which warns on Romanian chars
+                ArcanistTextLinter::LINT_BAD_CHARSET
+                => ArcanistLintSeverity::SEVERITY_DISABLED,
+            ));
+        $view_text_linter = new ArcanistTextLinter();
+        $view_text_linter->setCustomSeverityMap(
+            array(
+                // Disable character set linting which warns on Romanian chars
+                ArcanistTextLinter::LINT_BAD_CHARSET
+                => ArcanistLintSeverity::SEVERITY_DISABLED,
+                // Views are allowed to have more than 80 characters per line
+                ArcanistTextLinter::LINT_LINE_WRAP
+                => ArcanistLintSeverity::SEVERITY_DISABLED,
+            ));
+
+        $linters[] = $text_linter;
+
+        $spelling_linter = new ArcanistSpellingLinter();
+        $linters[] = $spelling_linter;
+        foreach ($paths as $path) {
+            $is_text = false;
+            if (preg_match('/\.(php|css|js|hpp|cpp|l|y)$/', $path)) {
+                $is_text = true;
+            }
+            if ($is_text) {
+                $generated_linter->addPath($path);
+                $generated_linter->addData($path, $this->loadData($path));
+
+                $nolint_linter->addPath($path);
+                $nolint_linter->addData($path, $this->loadData($path));
+
+                if ($this->isViewFile($path)) {
+                    $view_text_linter->addPath($path);
+                    $view_text_linter->addData($path, $this->loadData($path));
+                } else {
+                    $text_linter->addPath($path);
+                    $text_linter->addData($path, $this->loadData($path));
+                }
+
+                $spelling_linter->addPath($path);
+                $spelling_linter->addData($path, $this->loadData($path));
+            }
+        }
+
+        $name_linter = new ArcanistFilenameLinter();
+        $linters[] = $name_linter;
+        foreach ($paths as $path) {
+            $name_linter->addPath($path);
+        }
+
+        $xhpast_linter = new ArcanistXHPASTLinter();
+        $view_xhpast_linter = new ArcanistXHPASTLinter();
+        $view_xhpast_linter->setCustomSeverityMap(
+            array(
+                // FIXME: Remove once code is fully ported to XHP
+                ArcanistXHPASTLinter::LINT_PHP_OPEN_TAG
+                => ArcanistLintSeverity::SEVERITY_DISABLED,
+                ArcanistXHPASTLinter::LINT_PHP_CLOSE_TAG
+                => ArcanistLintSeverity::SEVERITY_DISABLED,
+                ArcanistXHPASTLinter::LINT_PHP_SHORT_TAG
+                => ArcanistLintSeverity::SEVERITY_DISABLED,
+                ArcanistXHPASTLinter::LINT_PHP_ECHO_TAG
+                => ArcanistLintSeverity::SEVERITY_DISABLED,
+            ));
+        $linters[] = $xhpast_linter;
+        $linters[] = $view_xhpast_linter;
+        foreach ($paths as $path) {
+            if (!preg_match('/\.php$/', $path)) {
+                continue;
+            }
+
+            if ($this->isViewFile($path)) {
+                $view_xhpast_linter->addPath($path);
+                $view_xhpast_linter->addData($path, $this->loadData($path));
+            } else {
+                $xhpast_linter->addPath($path);
+                $xhpast_linter->addData($path, $this->loadData($path));
+            }
+        }
+
+        $license_linter = new ArcanistApacheLicenseLinter();
+        $linters[] = $license_linter;
+        foreach ($paths as $path) {
+            if (preg_match('/\.(php|cpp|hpp|l|y)$/', $path)) {
+                if (!preg_match('@^externals/@', $path)) {
+                    $license_linter->addPath($path);
+                    $license_linter->addData($path, $this->loadData($path));
+                }
+            }
+        }
+
+        return $linters;
+    }
+
+    private function isExternalLibrary($path) {
+        $to_skip = array('@^arcanist/@', '@^libphutil/@',
+                         '@^common/external_libs/@', '@^www/php-ofc-library/@',
+                         '@^smf/@', '@^junk/@');
+        foreach ($to_skip as $skip) {
+            if (preg_match($skip, $path)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private function isViewFile($path) {
+        return preg_match('@^www/views/@', $path);
+    }
+
+}
Index: lint/engine/__init__.php
new file mode 100644
===================================================================
--- lint/engine/__init__.php	(revision 0)
+++ lint/engine/__init__.php	(working copy)
@@ -0,0 +1,21 @@
+<?php
+/**
+ * This file is automatically generated. Lint this module to rebuild it.
+ * @generated
+ */
+
+
+
+phutil_require_module('arcanist', 'lint/engine/base');
+phutil_require_module('arcanist', 'lint/linter/apachelicense');
+phutil_require_module('arcanist', 'lint/linter/filename');
+phutil_require_module('arcanist', 'lint/linter/generated');
+phutil_require_module('arcanist', 'lint/linter/nolint');
+phutil_require_module('arcanist', 'lint/linter/phutilmodule');
+phutil_require_module('arcanist', 'lint/linter/spelling');
+phutil_require_module('arcanist', 'lint/linter/text');
+phutil_require_module('arcanist', 'lint/linter/xhpast');
+phutil_require_module('arcanist', 'lint/severity');
+
+
+phutil_require_source('InfoarenaLintEngine.php');
