Permalink
Browse files

Add some UI

  • Loading branch information...
HugoHeneault committed Jan 19, 2016
1 parent dc7c1fb commit f1e890fe335dfe187097deb4c61a41031fe21a1f
Showing with 489 additions and 2 deletions.
  1. +34 −0 app.js
  2. +66 −0 index.php
  3. +3 −2 rew.phps
  4. +386 −0 style.css
View
34 app.js
@@ -0,0 +1,34 @@
var textarea;
var results;
var loader;
function convertRules() {
if ($(this).data('oldVal') == $(this).val()) {
return;
}
var rules = $(this).val();
if (rules != '') {
loader.addClass('visible');
$.ajax({
type: 'POST',
data: {rules: rules}
}).done(function (result) {
loader.removeClass('visible');
results.val(result);
})
} else {
results.val('');
}
$(this).data('oldVal', $(this).val());
}
$(function () {
textarea = $('#apache').find('textarea');
results = $('#nginx').find('textarea');
loader = $('#loader');
textarea.on('propertychange change click keyup input paste', convertRules).data('oldVal', textarea.val());
});
View
@@ -0,0 +1,66 @@
<?php
if (!empty($_POST['rules'])) {
error_reporting(E_ALL & ~E_NOTICE);
require_once 'rew.phps';
$RC = new rewriteConf($_POST['rules']);
$RC->parseContent();
$RC->writeConfig();
exit($RC->confOk);
}
?><!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Rule convertor, convert apache htaccess rewrite rules to nginx rewrite rules automatically</title>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,100' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Apache2Nginx rules converter</h1>
<i>attention: not so much beta, but check twice before using!</i>
</header>
<section>
<article id="apache">
<h2>Apache Rewrite Rules</h2>
<textarea placeholder="Paste your rules here"></textarea>
</article>
<div id="loader">
<div class="loader-inner pacman">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
<article id="nginx">
<h2>Nginx converted Rules</h2>
<textarea placeholder="The magic will appears there"></textarea>
</article>
</section>
<aside>
<p>
<strong>Will you make the codes public?</strong>
Please check <a href="https://github.com/mow/apache2nginx">https://github.com/mow/apache2nginx</a> also you can contact from: anil(at)saog.net
</p>
<p>
<strong>Donations?</strong>
Yes I accept donations. Please use my paypal account: pp(at)saog.net
</p>
<p>
<strong>Does it supports xxx?</strong>
This page has woozy codes, I dont know try it yourself and see. Backreferances, most of the variables and a
few flags are supported.There are tons of fancy hacks for catching rewrite behavior of apache. As you see, it
highly uses variables for deciding to rewriting and there must be many much errors/unmatched directives.
</p>
</aside>
<footer>
A converter by Mow - UI by <a href="http://ownweb.fr">OwnWeb</a>
</footer>
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="app.js"></script>
</body>
</html>
View
@@ -1,10 +1,10 @@
<?php
class rewriteConf {
/*
function __construct($htContent){
$this->htContent = $htContent;
}
*/
function parseLine($line){
list($cmd,$regex,$rew,$flags) = explode(" ",$line);
if(!empty($flags)){
@@ -18,6 +18,7 @@ class rewriteConf {
$lines = explode("\n",$this->htContent);
$i = 0;
foreach($lines as $line){
$line = trim($line);
if($line[0] != '#' && !empty($line[0])){
if(strpos($line,"RewriteCond") !== false){
if(!isset($k))$k = 0;
Oops, something went wrong.

0 comments on commit f1e890f

Please sign in to comment.