function page() { $page = CurrentPageName(); $tpl = new templates(); $uuid = $_GET["uuid"]; $t = time(); $q = new mysql_meta(); $sql = "SELECT uuid,hostname,public_ip,hostag FROM metahosts"; $results = $q->QUERY_SQL($sql); $CLONEZ[null] = "{none}"; while ($ligne = mysql_fetch_assoc($results)) { $CLONEZ[$ligne["uuid"]] = "{$ligne["hostname"]} - {$ligne["hostag"]} - [{$ligne["public_ip"]}]"; } $def = $q->CloneSource($uuid); $html = "<div class=explain style='font-size:26px'>{artica_meta_cloning_explain}</div>\n\t\t\t<div class=form style='width:98%'>\n\t\t\t<table style='width:100%'>\n\t\t\t<tr>\n\t\t\t\t<td class=legend style='font-size:26px'>{source_server}:</td>\n\t\t\t\t<td>" . Field_array_Hash($CLONEZ, "cloneFrom-{$t}", $def, null, null, 0, "font-size:26px") . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan=2 align='right'><p> </p></td>\n\t\t\t</tr>\t\t\t\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td colspan=2 align='right'><hr>" . button("{apply}", "Save{$t}()", 32) . "</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t</div>\n<script>\n\tvar xSave{$t}=function (obj) {\n\t\tvar ID='{$_GET["ID"]}';\n\t\tvar results=obj.responseText;\n\t\tif(results.length>0){alert(results);}\t\t\n\t\tRefreshTab('meta-hosts-{$uuid}');\n\t}\t\n\n\n\tfunction Save{$t}(){\n\t\tvar XHR = new XHRConnection();\n\t \tXHR.appendData('cloneFrom',document.getElementById('cloneFrom-{$t}').value);\n\t \tXHR.appendData('uuid','{$uuid}');\n\t \tXHR.sendAndLoad('{$page}', 'POST',xSave{$t});\n\t}\n</script>\n"; echo $tpl->_ENGINE_parse_body($html); }
function CloneSource($uuid) { $filepath = "/usr/share/artica-postfix/ressources/conf/meta/hosts/{$uuid}.clone"; $q = new mysql_meta(); $source_uuid = $q->CloneSource($uuid); if ($source_uuid == null) { if (is_file($filepath)) { @unlink($filepath); } return; } $sql = "SELECT zmd5 FROM snapshots WHERE uuid='{$source_uuid}' ORDER BY zDate DESC LIMIT 0,1"; $results = $q->QUERY_SQL($sql); if (!$q->ok) { meta_admin_mysql(0, "MySQL error while building Clone source", $q->mysql_error, __FILE__, __LINE__); return; } if (mysql_num_rows($results) == 0) { @unlink($filepath); return; } while ($ligne = mysql_fetch_assoc($results)) { @file_put_contents($filepath, $ligne["zmd5"]); } @chmod($filepath, 0755); if ($GLOBALS["NOTIFY"]) { ping_host($uuid); } }