Subversion Repositories oidplus

Compare Revisions

No changes between revisions

Regard whitespace Rev 732 → Rev 754

/trunk/plugins/viathinksoft/adminPages/920_nostalgia/OIDplusPageAdminNostalgia.class.php
0,0 → 1,67
<?php
 
/*
* OIDplus 2.0
* Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
*
* 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.
*/
 
// ATTENTION: If you change something, please make sure that the changes
// are synchronous with OIDplusPageRaAutomatedAJAXCalls
 
if (!defined('INSIDE_OIDPLUS')) die();
 
class OIDplusPageAdminNostalgia extends OIDplusPagePluginAdmin {
 
public function gui($id, &$out, &$handled) {
if ($id === 'oidplus:nostalgia') {
$handled = true;
$out['title'] = _L('Nostalgia');
$out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
 
if (!OIDplus::authUtils()->isAdminLoggedIn()) {
$out['icon'] = 'img/error_big.png';
$out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
return;
}
 
$out['text'] = '<p>'._L('Did you ever wonder what OIDplus would look like if it had been created in the era of MS-DOS, Windows 3.11, or Windows 95? Just download the ZIP files below and have a look!').'</p>';
$out['text'] .= '<p><a href="'.OIDplus::webpath(__DIR__).'export_dos.php">'._L('Download OIDplus for DOS').'</a>, '._L('including your database (only OIDs)').'</p>';
$out['text'] .= '<p><a href="'.OIDplus::webpath(__DIR__).'export_win.php">'._L('Download OIDplus for Windows 3.11 or Windows 95').'</a>, '._L('including your database (only OIDs)').'</p>';
$out['text'] .= '<p>'._L('Please note that the download might be delayed since your OID database is exported and added to the ZIP file.').'</p>';
}
}
 
public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
 
if (file_exists(__DIR__.'/treeicon.png')) {
$tree_icon = OIDplus::webpath(__DIR__).'treeicon.png';
} else {
$tree_icon = null; // default icon (folder)
}
 
$json[] = array(
'id' => 'oidplus:nostalgia',
'icon' => $tree_icon,
'text' => _L('Nostalgia')
);
 
return true;
}
 
public function tree_search($request) {
return false;
}
}
/trunk/plugins/viathinksoft/adminPages/920_nostalgia/export_dos.php
0,0 → 1,132
<?php
 
/*
* OIDplus 2.0
* Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
*
* 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.
*/
 
header('Content-Type:text/html; charset=UTF-8');
 
require_once __DIR__ . '/../../../../includes/oidplus.inc.php';
 
set_exception_handler(array('OIDplusGui', 'html_exception_handler'));
 
OIDplus::init(true);
 
if (OIDplus::baseConfig()->getValue('DISABLE_PLUGIN_OIDplusPageAdminOIDInfoExport', false)) {
throw new OIDplusException(_L('This plugin was disabled by the system administrator!'));
}
 
$dos_ids = array();
$parent_oids = array();
$i = 0;
$dos_ids[''] = '00000000';
$parent_oids[''] = '';
 
$dos_ids[''] = str_pad($i++, 8, '0', STR_PAD_LEFT);
$res = OIDplus::db()->query("select * from ###objects where id like 'oid:%' order by ".OIDplus::db()->natOrder('id'));
while ($row = $res->fetch_object()) {
$oid = substr($row->id, strlen('oid:'));
$parent_oid = substr($row->parent, strlen('oid:'));
$dos_ids[$oid] = str_pad($i++, 8, '0', STR_PAD_LEFT);
if ($parent_oid == '') {
$parent_oids[$oid] = '';
} else {
$parent_oids[$oid] = $parent_oid;
}
}
 
$tmp_file = OIDplus::localpath().'userdata/dos_export.zip';
 
$zip = new ZipArchive();
if ($zip->open($tmp_file, ZipArchive::CREATE)!== true) {
throw new OIDplusException("cannot open <$tmp_file>");
}
 
foreach ($dos_ids as $oid => $dos_id) {
$cont = '';
 
$cont .= "VERS2022\r\n";
 
$cont .= "SELF$dos_id$oid\r\n";
 
$parent_oid = $parent_oids[$oid];
$parent_id = $dos_ids[$parent_oid];
$cont .= "SUPR$parent_id$parent_oid\r\n";
 
foreach ($parent_oids as $child_oid => $parent_oid) {
if ($child_oid == '') continue;
if ($parent_oid == $oid) {
$child_id = $dos_ids[$child_oid];
$cont .= "CHLD$child_id$child_oid\r\n";
}
}
 
$res = OIDplus::db()->query("select * from ###asn1id where oid = 'oid:$oid'");
while ($row = $res->fetch_object()) {
$asn1 = $row->name;
$cont .= "ASN1$asn1\r\n";
}
 
$res = OIDplus::db()->query("select * from ###iri where oid = 'oid:$oid'");
while ($row = $res->fetch_object()) {
$iri = $row->name;
$cont .= "UNIL$iri\r\n";
}
 
if ($oid == '') {
// TODO: Split in single parent OIDs
$cont .= "DESCHere, you can find the root OIDs.\r\n";
} else {
$res = OIDplus::db()->query("select * from ###objects where id = 'oid:$oid';");
$row = $res->fetch_object();
$desc = trim(trim(strip_tags($row->description)));
$desc = str_replace("\r", "", $desc);
$desc = str_replace("\n", " ", $desc);
$desc_ary1 = explode("\r\n", wordwrap($desc, 80/*TREEVIEW_WIDTH*/, "\r\n", true));
$desc_ary2 = explode("\r\n", wordwrap($row->title, 80/*TREEVIEW_WIDTH*/, "\r\n", true));
if (implode('',$desc_ary1) == '') $desc_ary1 = array();
if (implode('',$desc_ary2) == '') $desc_ary2 = array();
$desc_ary = array_merge($desc_ary1, $desc_ary2);
foreach ($desc_ary as $line_idx => $line) {
if ($line_idx >= 10/*DESCEDIT_LINES*/) break;
$cont .= "DESC$line\r\n";
}
}
 
//echo "****$dos_id.OID\r\n";
//echo "$cont\r\n";
 
$zip->addFromString("$dos_id.OID", $cont);
}
 
$exe_url = 'https://github.com/danielmarschall/oidplus_dos/raw/master/OIDPLUS.EXE';
$exe = @file_get_contents($exe_url);
if ($exe == '') {
throw new OIDplusException(_L("Cannot download the binary file from GitHub (%1)", $exe_url));
}
$zip->addFromString('OIDPLUS.EXE', $exe);
 
$zip->close();
 
if (!headers_sent()) {
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename=oidplus_dos.zip');
readfile($tmp_file);
}
 
unlink($tmp_file);
 
OIDplus::invoke_shutdown();
/trunk/plugins/viathinksoft/adminPages/920_nostalgia/export_win.php
0,0 → 1,149
<?php
 
/*
* OIDplus 2.0
* Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
*
* 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.
*/
 
header('Content-Type:text/html; charset=UTF-8');
 
require_once __DIR__ . '/../../../../includes/oidplus.inc.php';
 
set_exception_handler(array('OIDplusGui', 'html_exception_handler'));
 
ob_start(); // allow cookie headers to be sent
 
OIDplus::init(true);
 
if (OIDplus::baseConfig()->getValue('DISABLE_PLUGIN_OIDplusPageAdminOIDInfoExport', false)) {
throw new OIDplusException(_L('This plugin was disabled by the system administrator!'));
}
 
$dos_ids = array();
$parent_oids = array();
$i = 0;
$dos_ids[''] = '00000000';
$parent_oids[''] = '';
 
$dos_ids[''] = str_pad($i++, 8, '0', STR_PAD_LEFT);
$res = OIDplus::db()->query("select * from ###objects where id like 'oid:%' order by ".OIDplus::db()->natOrder('id'));
while ($row = $res->fetch_object()) {
$oid = substr($row->id, strlen('oid:'));
$parent_oid = substr($row->parent, strlen('oid:'));
$dos_ids[$oid] = str_pad($i++, 8, '0', STR_PAD_LEFT);
if ($parent_oid == '') {
$parent_oids[$oid] = '';
} else {
$parent_oids[$oid] = $parent_oid;
}
}
 
$tmp_file = OIDplus::localpath().'userdata/windows_export.zip';
 
$zip = new ZipArchive();
if ($zip->open($tmp_file, ZipArchive::CREATE)!== true) {
throw new OIDplusException("cannot open <$tmp_file>");
}
 
$cont = '';
 
foreach ($dos_ids as $oid => $dos_id) {
$cont .= "[OID:$oid]\r\n";
 
$i = 1;
foreach ($parent_oids as $child_oid => $parent_oid) {
if ($child_oid == '') continue;
if ($parent_oid == $oid) {
$cont .= "delegate$i=OID:$child_oid\r\n";
$i++;
}
}
$cont .= "delegates=".($i-1)."\n";
 
if ($oid != '') {
$res = OIDplus::db()->query("select * from ###asn1id where oid = 'oid:$oid'");
$asnids = array();
while ($row = $res->fetch_object()) {
$asn1 = $row->name;
$asnids[] = $asn1;
}
$asnids = implode(',', $asnids);
if ($asnids != '') $cont .= "asn1id=$asnids\r\n";
 
/*
$res = OIDplus::db()->query("select * from ###iri where oid = 'oid:$oid'");
$iris = array();
while ($row = $res->fetch_object()) {
$iri = $row->name;
$iris[] = $iri;
}
$iris = implode(',', $iris);
if ($iris != '') $cont .= "iri=$iris\r\n";
*/
 
$res = OIDplus::db()->query("select * from ###objects where id = 'oid:$oid';");
$row = $res->fetch_object();
 
if ($row->title != '') $cont .= "description=".$row->title."\r\n";
 
if ($row->updated != '') $cont .= "updatedate=".explode(' ',$row->updated)[0]."\r\n";
if ($row->created != '') $cont .= "createdate=".explode(' ',$row->created)[0]."\r\n";
 
$desc = $row->description;
$desc = strip_tags($desc);
$desc = trim($desc);
if ($desc != '') {
$cont .= "information=$dos_id.TXT\r\n";
$zip->addFromString("DB//$dos_id.TXT", $desc);
}
}
}
 
//echo '<pre>'.$cont.'</pre>';
//die();
 
$settings = array();
$settings[] = '[SETTINGS]';
$settings[] = 'DATA=DB\\';
$zip->addFromString("OIDPLUS.INI", implode("\r\n",$settings)."\r\n");
 
 
$zip->addFromString('DB//OID.INI', $cont);
 
$exe_url = 'https://github.com/danielmarschall/oidplus_win95/raw/master/OIDPLUS.exe';
$exe = @file_get_contents($exe_url);
if ($exe == '') {
throw new OIDplusException(_L("Cannot download the binary file from GitHub (%1)", $exe_url));
}
$zip->addFromString('OIDPLS32.EXE', $exe);
 
$exe_url = 'https://github.com/danielmarschall/oidplus_win311/raw/master/OIDPLUS.exe';
$exe = @file_get_contents($exe_url);
if ($exe == '') {
throw new OIDplusException(_L("Cannot download the binary file from GitHub (%1)", $exe_url));
}
$zip->addFromString('OIDPLS16.EXE', $exe);
 
$zip->close();
 
if (!headers_sent()) {
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename=oidplus_windows.zip');
readfile($tmp_file);
}
 
unlink($tmp_file);
 
OIDplus::invoke_shutdown();
/trunk/plugins/viathinksoft/adminPages/920_nostalgia/icon_big.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/plugins/viathinksoft/adminPages/920_nostalgia/index.html
--- 920_nostalgia/manifest.xml (nonexistent)
+++ 920_nostalgia/manifest.xml (revision 754)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
+<manifest
+ xmlns="urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:oid:1.3.6.1.4.1.37476.2.5.2.5.2.1 https://oidplus.viathinksoft.com/oidplus/plugins/manifest_plugin_page.xsd">
+
+ <type>OIDplusPagePluginAdmin</type>
+
+ <info>
+ <name>Nostalgia</name>
+ <author>ViaThinkSoft</author>
+ <version />
+ <descriptionHTML />
+ <oid>1.3.6.1.4.1.37476.2.5.2.4.3.920</oid>
+ </info>
+
+ <php>
+ <mainclass>OIDplusPageAdminNostalgia</mainclass>
+ </php>
+
+ <css>
+ </css>
+
+ <js>
+ </js>
+
+</manifest>
/trunk/plugins/viathinksoft/adminPages/920_nostalgia/treeicon.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property