/trunk/classic.php |
---|
92,7 → 92,7 |
$smarty->assign('linux',$linux); |
$smarty->assign('version',$distvers); |
$smarty->assign('result',$result); |
$smarty->assign('antversion',$antversion); |
$smarty->assign('antversion',$antversion." • <a href='./modern.php'>Современный интерфейс</a>"); |
$smarty->display('classic.tpl'); |
/trunk/modern.php |
---|
27,40 → 27,85 |
$query->fetchInto($antv, DB_FETCHMODE_ASSOC); |
$antversion = $antv["optvalue"]; |
$scripts = " |
(function($){ |
// очищаем select |
$.fn.clearSelect = function() { |
return this.each(function(){ |
if(this.tagName=='SELECT') { |
this.options.length = 0; |
$(this).attr('disabled','disabled'); |
} |
}); |
} |
// заполняем select |
$.fn.fillSelect = function(dataArray) { |
return this.clearSelect().each(function(){ |
if(this.tagName=='SELECT') { |
var currentSelect = this; |
$.each(dataArray,function(index,data){ |
var option = new Option(data.text,data.value); |
if($.support.cssFloat) { |
currentSelect.add(option,null); |
} else { |
currentSelect.add(option); |
} |
}); |
} |
}); |
} |
})(jQuery); |
</script> |
<script type='text/javascript'> |
$(document).ready(function(){ |
// выбор дистрибутива |
function adjustDistro(){ |
var distroValue = $('#distro').val(); |
var tmpSelect = $('#distver'); |
if(distroValue.length == 0) { |
tmpSelect.attr('disabled','disabled'); |
tmpSelect.clearSelect(); |
adjustReps(); |
$('#replist').css('display','none'); |
} else { |
$.getJSON('m-process.php',{d:distroValue,status:1},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); adjustReps(); }); |
$('#replist').css('display','none'); |
} |
}; |
// Выбор версии дистрибутива |
function adjustReps(){ |
var distroValue = $('#distro').val(); |
var versionValue = $('#distver').val(); |
if (distroValue != 0 && versionValue != 0) { |
$.get('m-process.php',{d:distroValue,v:versionValue,status:2},function(data){ $('#replist').css('display','block'); $('#replist').html(data); },'html'); |
} |
} |
$scripts = ' |
$(document).ready(function() { |
var options = { |
target: "#modern", |
success: showResponse |
}; |
$("#distro").ajaxForm(options); |
}); |
$('#distro').change(adjustDistro); |
$('#distver').change(adjustReps); |
function showResponse(responseText, statusText) { |
//$("#modern").replaceAll(responseText); |
} |
'; |
}); |
"; |
$linux = "<p><input type='hidden' name='step' value='1' /></p>"; |
$query =& $db->query("SELECT * FROM distribution"); |
while ($query->fetchInto($data, DB_FETCHMODE_ASSOC)) { |
$linux .= "<p><input type='radio' name='d' value='".$data["dist_id"]."' />".stripslashes($data["distname"])."</p>\n"; |
$linux .= "<option value='".$data["dist_id"]."'>".stripslashes($data["distname"])."</option>\n"; |
} |
$modern = "<div id='ant'><div id='modern'>"; |
$modern .= "<h2>Генератор sources.list</h2>"; |
$modern .= "<div class='border'>"; |
$modern .= "<label>Дистрибутив</label><br />"; |
$modern .= "<select id='distro'>\n<option value=''>Выбрать дистрибутив</option>\n"; |
$modern .= $linux."</select>"; |
$modern .= "</div><div class='border'>"; |
$modern .= "<label>Версия дистрибутива</label><br />"; |
$modern .= "<select id='distver' disabled='disabled'>\n"; |
$modern .= "</select></div>"; |
$modern .= "<pre id='replist'></pre></div>"; |
$modern .= "<h2>Выбор дистрибутива</h2>"; |
$modern .= "<form action='./m-process.php' method='post' id='distro'>"; |
$modern .= $linux; |
$modern .= "<p><input type='submit' value=' Выбрать дистрибутив '></p>"; |
$modern .= "</form>"; |
$modern .= "</div></div>"; |
$smarty->assign('modern',$modern); |
$smarty->assign('scripts',$scripts); |
$smarty->assign('antversion',$antversion); |
$smarty->assign('antversion',$antversion." • <a href='./classic.php'>Классический интерфейс</a>"); |
$smarty->display('modern.tpl'); |
/trunk/css/ant.css |
---|
1,42 → 1,50 |
body { |
background: #fff url(../img/bg.gif) top left repeat; |
} |
#ant { |
font: 12pt/20pt Georgia; |
} |
#ant input { |
margin: 0 5px 0 15px; |
font: 12pt Georgia; |
} |
#ant p { |
margin: 0; |
} |
#footer { |
margin: 5px 0; |
padding: 5px 0; |
border-top: 1px solid #a9a9a9; |
font: 10pt Georgia; |
color: #a9a9a9; |
} |
#footer a { |
color: #a9a9a9; |
text-decoration: none; |
} |
pre { |
font: 12pt Arial; |
border: 1px solid #000; |
margin: 10px 0; |
padding: 10px; |
background-color: #dcdcdc; |
} |
#sourceslist { |
font-family: Arial; |
padding: 1px 3px; |
} |
body { |
background: #fff url(../img/bg.gif) top left repeat; |
} |
#ant { |
font: 12pt/20pt Georgia; |
} |
#ant input { |
margin: 0 5px 0 15px; |
font: 12pt Georgia; |
} |
#ant p { |
margin: 0; |
} |
#footer { |
margin: 5px 0; |
padding: 5px 0; |
border-top: 1px solid #a9a9a9; |
font: 10pt Georgia; |
color: #a9a9a9; |
} |
#footer a { |
color: #a9a9a9; |
text-decoration: none; |
} |
pre { |
font: 12pt Arial; |
border: 1px solid #000; |
margin: 10px 0; |
padding: 10px; |
background-color: #dcdcdc; |
} |
pre#replist { |
display: none; |
} |
#sourceslist { |
font-family: Arial; |
padding: 1px 3px; |
} |
img { |
border:0; |
} |
/trunk/index.php |
---|
2,7 → 2,7 |
/** |
* Project: Ant: sources.list generator |
* File: index.php |
* File: modern.php |
* |
* This application is free software; you can redistribute it and/or |
* modify it under the terms of the GNU Lesser General Public |
22,78 → 22,91 |
include "lib/init.php"; |
$status = abs(intval($_GET["step"])); |
$dist = abs(intval($_GET["d"])); |
$vers = abs(intval($_GET["v"])); |
$query =& $db->query("SELECT * FROM settings WHERE opt LIKE 'version'"); |
$query->fetchInto($antv, DB_FETCHMODE_ASSOC); |
$antversion = $antv["optvalue"]; |
$scripts = " |
(function($){ |
// очищаем select |
$.fn.clearSelect = function() { |
return this.each(function(){ |
if(this.tagName=='SELECT') { |
this.options.length = 0; |
$(this).attr('disabled','disabled'); |
} |
}); |
} |
// заполняем select |
$.fn.fillSelect = function(dataArray) { |
return this.clearSelect().each(function(){ |
if(this.tagName=='SELECT') { |
var currentSelect = this; |
$.each(dataArray,function(index,data){ |
var option = new Option(data.text,data.value); |
if($.support.cssFloat) { |
currentSelect.add(option,null); |
} else { |
currentSelect.add(option); |
} |
}); |
} |
}); |
} |
})(jQuery); |
</script> |
<script type='text/javascript'> |
$(document).ready(function(){ |
// выбор дистрибутива |
function adjustDistro(){ |
var distroValue = $('#distro').val(); |
var tmpSelect = $('#distver'); |
if(distroValue.length == 0) { |
tmpSelect.attr('disabled','disabled'); |
tmpSelect.clearSelect(); |
adjustReps(); |
$('#replist').css('display','none'); |
} else { |
$.getJSON('m-process.php',{d:distroValue,status:1},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); adjustReps(); }); |
$('#replist').css('display','none'); |
} |
}; |
// Выбор версии дистрибутива |
function adjustReps(){ |
var distroValue = $('#distro').val(); |
var versionValue = $('#distver').val(); |
if (distroValue != 0 && versionValue != 0) { |
$.get('m-process.php',{d:distroValue,v:versionValue,status:2},function(data){ $('#replist').css('display','block'); $('#replist').html(data); },'html'); |
} |
} |
$('#distro').change(adjustDistro); |
$('#distver').change(adjustReps); |
}); |
"; |
$query =& $db->query("SELECT * FROM distribution"); |
while ($query->fetchInto($data, DB_FETCHMODE_ASSOC)) { |
$linux .= "<p><input type='radio' name='d' value='".$data["dist_id"]."' />".stripslashes($data["distname"])."</p>\n"; |
$linux .= "<option value='".$data["dist_id"]."'>".stripslashes($data["distname"])."</option>\n"; |
} |
if (!isset($status)) { $status = 0; }; |
$modern .= "<h2>Генератор sources.list</h2>"; |
$modern .= "<div class='border'>"; |
$modern .= "<label>Дистрибутив</label><br />"; |
$modern .= "<select id='distro'>\n<option value=''>Выбрать дистрибутив</option>\n"; |
$modern .= $linux."</select>"; |
$modern .= "</div><div class='border'>"; |
$modern .= "<label>Версия дистрибутива</label><br />"; |
$modern .= "<select id='distver' disabled='disabled'>\n"; |
$modern .= "</select></div>"; |
$modern .= "<pre id='replist'></pre></div>"; |
if (isset($dist)) { |
$query =& $db->query("SELECT * FROM version v JOIN distribution d ON d.dist_id=v.dist_id WHERE v.dist_id='$dist'"); |
$distvers = "<p><input type='hidden' name='d' value='".$dist."' /></p>\n"; |
while ($query->fetchInto($version, DB_FETCHMODE_ASSOC)) { |
if ($version["vname"]!="") { |
$distname = "“".stripslashes($version["vname"])."”"; |
} else { |
$distname = ""; |
} |
$distvers .= "<p><input type='radio' name='v' value='".$version["version_id"]."' />".stripslashes($version["distname"])." ".stripslashes($version["version"])." ".$distname."</p>\n"; |
} |
} |
$smarty->assign('modern',$modern); |
$smarty->assign('scripts',$scripts); |
$smarty->assign('antversion',$antversion." • <a href='./classic.php'>Классический интерфейс</a>"); |
if (isset($vers)) { |
$query =& $db->query("SELECT * FROM settings"); |
$settings = array(); |
while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) { |
$settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]); |
}; |
$query =& $db->query("SELECT * FROM version v JOIN distribution d ON d.dist_id=v.dist_id JOIN dtype p ON d.disttype=p.type_id WHERE v.dist_id='$dist' AND v.version_id='$vers'"); |
$query->fetchInto($infodist, DB_FETCHMODE_ASSOC); |
$distname = ""; |
if ($infodist["vname"]!="") { |
$distname = "“".stripslashes($infodist["vname"])."”"; |
} |
$info = "<h2>Доступные репозитории для <em>".stripslashes($infodist["distname"])." ".stripslashes($infodist["version"])." ".$distname."</em></h2>"; |
$query =& $db->query("SELECT * FROM repository r JOIN ver2rep v ON r.rep_id=v.rep_id JOIN version v2 ON v.ver_id=v2.version_id JOIN scheme s ON s.scheme_id=r.scheme_id WHERE v.ver_id='$vers' ORDER BY r.rtype_id, r.scheme_id ASC"); |
$result = "<p>Скопируйте эти строки в файл <span id='sourceslist'>/etc/apt/sources.list</span>:</p><pre>"; |
while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) { |
$repscheme = stripslashes($resinfo["scheme"]); |
$querysect =& $db->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE |
r.rep_id='$resinfo[rep_id]'"); |
$sections = ""; |
while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) { |
$sections .= stripslashes($section["sectname"])." "; |
} |
$smarty->display('modern.tpl'); |
$repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme); |
$repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme); |
$repscheme = str_replace("{URL}",$settings["url"],$repscheme); |
$repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme); |
$repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme); |
$repscheme = str_replace("{SECT}",$sections,$repscheme); |
$result .= $repscheme."\n"; |
} |
$result .= "</pre>"; |
$result = $info.$result; |
} |
$smarty->assign('status',$status); |
$smarty->assign('linux',$linux); |
$smarty->assign('version',$distvers); |
$smarty->assign('result',$result); |
$smarty->assign('antversion',$antversion); |
$smarty->display('index.tpl'); |
?> |
/trunk/m-process.php |
---|
22,74 → 22,58 |
include "lib/init.php"; |
$status = abs(intval($_POST["step"])); |
$dist = abs(intval($_POST["d"])); |
$vers = abs(intval($_POST["v"])); |
$dist = abs(intval($_GET["d"])); |
$vers = abs(intval($_GET["v"])); |
$status = abs(intval($_GET["status"])); |
if (!isset($status)) { $status = 0; } |
header('Content-Type: text/html; charset=utf-8'); |
//if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { |
if (isset($dist)) { |
$query =& $db->query("SELECT * FROM version v JOIN distribution d ON d.dist_id=v.dist_id WHERE v.dist_id='$dist'"); |
$distvers = "<h2>Выбор версии дистрибутива</h2>\n"; |
$distvers .= "<form action='./m-process.php' method='post' id='distro' >\n"; |
$distvers .= "<p><input type='hidden' name='step' value='2' /><input type='hidden' name='d' value='".$dist."' /></p>\n"; |
while ($query->fetchInto($version, DB_FETCHMODE_ASSOC)) { |
if ($version["vname"]!="") { |
$distname = "“".stripslashes($version["vname"])."”"; |
} else { |
$distname = ""; |
} |
$distvers .= "<p><input type='radio' name='v' value='".$version["version_id"]."' />".stripslashes($version["distname"])." ".stripslashes($version["version"])." ".$distname."</p>\n"; |
switch($status) { |
case '1': |
$result = '[{value:"",text:"Выбрать версию дистрибутива"}'; |
$query =& $db->query("SELECT * FROM version v JOIN distribution d ON d.dist_id=v.dist_id WHERE v.dist_id='$dist'"); |
while ($query->fetchInto($version, DB_FETCHMODE_ASSOC)) { |
if ($version["vname"]!="") { |
$distname = stripslashes($version["vname"]); |
} else { |
$distname = ""; |
} |
$result .= ',{value:"'.$version["version_id"].'",text:"'.stripslashes($version["version"]).' '.$distname.'"}'; |
} |
$result .= ']'; |
break; |
case '2': |
$query =& $db->query("SELECT * FROM settings"); |
$settings = array(); |
while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) { |
$settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]); |
}; |
$query =& $db->query("SELECT * FROM version v JOIN distribution d ON d.dist_id=v.dist_id JOIN dtype p ON d.disttype=p.type_id WHERE v.dist_id='$dist' AND v.version_id='$vers'"); |
$query->fetchInto($infodist, DB_FETCHMODE_ASSOC); |
$query =& $db->query("SELECT * FROM repository r JOIN ver2rep v ON r.rep_id=v.rep_id JOIN version v2 ON v.ver_id=v2.version_id JOIN scheme s ON s.scheme_id=r.scheme_id WHERE v.ver_id='$vers' ORDER BY r.rtype_id, r.scheme_id ASC"); |
while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) { |
$repscheme = stripslashes($resinfo["scheme"]); |
$querysect =& $db->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE |
r.rep_id='$resinfo[rep_id]'"); |
$sections = ""; |
while ($querysect->fetchInto($section,DB_FETCHMODE_ASSOC)) { |
$sections .= stripslashes($section["sectname"])." "; |
} |
$repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme); |
$repscheme = str_replace("{PROTO}",$settings["proto"],$repscheme); |
$repscheme = str_replace("{URL}",$settings["url"],$repscheme); |
$repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme); |
$repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme); |
$repscheme = str_replace("{SECT}",$sections,$repscheme); |
$result .= $repscheme."\n"; |
} |
break; |
} |
$distvers .= "<p><input type='submit' value='Выбрать версию' /></p>"; |
$distvers .= "</form>"; |
} |
print $result; |
//} |
if (isset($vers)) { |
$query =& $db->query("SELECT * FROM settings"); |
$settings = array(); |
while ($query->fetchInto($setting, DB_FETCHMODE_ASSOC)) { |
$settings[stripslashes($setting["opt"])] = stripslashes($setting["optvalue"]); |
} |
$query =& $db->query("SELECT * FROM version v JOIN distribution d ON d.dist_id=v.dist_id JOIN dtype p ON d.disttype=p.type_id WHERE v.dist_id='$dist' AND v.version_id='$vers'"); |
$query->fetchInto($infodist, DB_FETCHMODE_ASSOC); |
$distname = ""; |
if ($infodist["vname"]!="") { |
$distname = "“".stripslashes($infodist["vname"])."”"; |
} |
$info = "<h2>Доступные репозитории для <em>".stripslashes($infodist["distname"])." ".stripslashes($infodist["version"])." ".$distname."</em></h2>"; |
$query =& $db->query("SELECT * FROM repository r JOIN ver2rep v ON r.rep_id=v.ver_id JOIN version v2 ON v.ver_id=v2.version_id JOIN scheme s ON s.scheme_id=r.scheme_id WHERE v.ver_id='$vers' ORDER BY r.rtype_id, r.scheme_id ASC"); |
$result = "<p>Скопируйте эти строки в файл <span id='sourceslist'>/etc/apt/sources.list</span>:</p><pre>"; |
while ($query->fetchInto($resinfo, DB_FETCHMODE_ASSOC)) { |
$repscheme = stripslashes($resinfo["scheme"]); |
$querysect =& $db->query("SELECT * FROM section s JOIN sect2rep r ON s.sect_id=r.sect_id WHERE r.rep_id='$resinfo[rep_id]'"); |
$sections = ""; |
while ($querysect->fetchInto($section, DB_FETCHMODE_ASSOC)) { |
$sections .= stripslashes($section["sectname"])." "; |
} |
$repscheme = str_replace("{TYPE}",stripslashes($infodist["type"]),$repscheme); |
$repscheme = str_replace("{PROTO}",$setting["proto"],$repscheme); |
$repscheme = str_replace("{URL}",$setting["url"],$repscheme); |
$repscheme = str_replace("{REP}",stripslashes($resinfo["repname"]),$repscheme); |
$repscheme = str_replace("{DIST}",stripslashes($infodist["vcodename"]),$repscheme); |
$repscheme = str_replace("{SECT}",$sections,$repscheme); |
$result .= $repscheme."\n"; |
} |
$result .= "</pre>"; |
$result = $info.$result; |
} |
switch ($status) { |
case '1': |
print $distvers; |
break; |
case '2': |
print $result; |
break; |
} |
?> |
/trunk/templates/header.js.tpl |
---|
8,7 → 8,7 |
<link rel="stylesheet" type="text/css" href="./css/ant.css" /> |
<script type="text/javascript" src="./js/jquery.js"></script> |
<script type="text/javascript"> |
// Your code goes here |
{$scripts} |
</script> |
</head> |
<body> |