Beispiel #1
0
function printObject(Object $object, $depth = 0)
{
    $treeSymbol = '';
    $depthString = str_repeat('─', $depth);
    if ($depth > 0) {
        $treeSymbol = '├';
    }
    $name = Identifier::getShortName($object->getType());
    echo "{$treeSymbol}{$depthString}{$name} : ";
    echo $object->__toString() . PHP_EOL;
    $content = $object->getContent();
    if (is_array($content)) {
        foreach ($object as $child) {
            printObject($child, $depth + 1);
        }
    }
}
Beispiel #2
0
function printObject(Object $object, $depth = 0)
{
    $treeSymbol = '';
    $depthString = str_repeat('━', $depth);
    if ($depth > 0) {
        $treeSymbol = '┣';
    }
    $name = strtoupper(Identifier::getShortName($object->getType()));
    echo "{$treeSymbol}{$depthString}<b>{$name}</b> : ";
    echo $object->__toString() . '<br/>';
    $content = $object->getContent();
    if (is_array($content)) {
        foreach ($object as $child) {
            printObject($child, $depth + 1);
        }
    }
}
Beispiel #3
0
function printObject(Object $object, $depth = 0)
{
    $name = strtoupper(Identifier::getShortName($object->getType()));
    $treeSymbol = '';
    $depthString = str_repeat('━', $depth);
    if ($depth > 0) {
        $treeSymbol = '┣';
        $name = ' ' . $name;
    }
    echo "{$treeSymbol}{$depthString}{$name} : ";
    echo $object->__toString() . PHP_EOL;
    $content = $object->getContent();
    if ($content instanceof Object) {
        printObject($content, $depth + 1);
    } elseif (is_array($content)) {
        foreach ($object as $child) {
            printObject($child, $depth + 1);
        }
    }
}
Beispiel #4
0
function printarray($array)
{
    if (is_object($array)) {
        return printObject($array);
    }
    if (!is_array($array)) {
        return;
    }
    while (list($key, $value) = each($array)) {
        if (is_array($value)) {
            echo $key . '(array):<blockquote>';
            printarray($value);
            //recursief!!
            echo '</blockquote>';
        } elseif (is_object($value)) {
            echo $key . '(object):<blockquote>';
            printobject($value);
            echo '</blockquote>';
        } else {
            echo $key . '==>' . $value . '<br />';
        }
    }
}
Beispiel #5
0
function printarray($array)
{
    if (is_object($array)) {
        return printObject($array);
    }
    if (!is_array($array)) {
        return;
    }
    while (list($key, $value) = each($array)) {
        if (is_array($value)) {
            echo $key . "(array):<blockquote>";
            printarray($value);
            //recursief!!
            echo "</blockquote>";
        } elseif (is_object($value)) {
            echo $key . "(object):<blockquote>";
            printobject($value);
            echo "</blockquote>";
        } else {
            echo $key . "==>" . $value . "<br />";
        }
    }
}
Beispiel #6
0
function main_func($name, $department)
{
    $MAX_Classes = Department::where('code', $department->code)->first()->total_rooms;
    //Thana kawaye nashi file read yaye ta kha
    /*$inputData=CSV2Array($name);//CSV2Array is a function defined inside the file functions.php and this file returns an array
    		$i=0;
    		foreach($inputData as $temp){//this loop will unwrap the two layered array which was stored in previous variable $inputvariable by the function CSV2Array in functions.php
    			${"data".$i}=$temp;//Array ko array lai unwrap gari ra cha
    			$i++;	
    		}	
    		$courseName=$data0;
    		$start=$data1;
    		$end=$data2;
    		
    		unset($courseName[0]);//unset array na 0th item of array ta hate yana bi
    		unset($start[0]);//This chaye yanyu dhasa tho ma yata dhasa ASP algorithm le taye mau pani chau first pseudo class miss jui so tho object yu data kha
    		unset($end[0]);//THisis for the first column of the csv file chaye choya tayu pani mile maju
    
    
    		
    		$courseName=arrangeArray($courseName);//tho arrangeArray userdefined function kha... thake yo 0th item maru ta hana milaya yana bi.... ie ..A[0] delete jui hanji so A[1] ta A[0] yana bi and A[2] ta A[1] and so on
    		$start=arrangeArray($start);
    		$end=arrangeArray($end);
    		*/
    $scheduledata = Schedule::where('day', $name)->where('department_code', $department->code)->get();
    $courseName = array();
    $start = array();
    $end = array();
    foreach ($scheduledata as $schedule) {
        $courseName[count($courseName)] = $schedule->course_code;
        $start[count($start)] = $schedule->stime;
        $end[count($end)] = $schedule->etime;
        //array_push($courseName,$schedule->course_code);
        //array_push($start,$schedule->stime);
        //array_push($end,$schedule->etime);
    }
    //File read yayau pati sidhala
    //For initializing the objects.... i.e. one object for one class
    $classes = array();
    $i = 1;
    foreach ($start as $a) {
        $foo = new myClass();
        $foo->set_Data($a, $end[$i - 1], $courseName[$i - 1], $i);
        $i++;
        array_push($classes, $foo);
    }
    if (count($classes)) {
        echo "<h2>Routine for: " . $name . "</h2><br>";
        echo "The classes mentioned below are the classes that you want to arrange for <strong>" . $name . "</strong> is as below.";
        printObject($classes, 0, $name, $department->code);
        CustSort($classes);
        //Sorting accourding to the start time
        //This is the addition of A0 object at the first
        $temp = new myClass();
        $temp->set_Data(9999, 0, "A0", 0);
        array_unshift($classes, $temp);
        //array_unshift() inserts passed elements to the front of the array
        //End of the A0 object addition
        $i = 1;
        while (sizeof($classes) != 1) {
            ${"abc" . $i} = AC_Object($classes);
            //$abc.$i is the array which stores the object of the classes that is being taught in the room
            $classes = array_udiff($classes, ${"abc" . $i}, 'compare_objects');
            //This will call the functions compare_objects defined in the function functions.php so in this case the remaining classes to be arranged is ordered back
            $classes = arrangeArray($classes);
            //This will arrange the items in an array. After the removal the array will empty on certain slots for eg if array element A[7] is arranged and now it empty this gap will be arranged by this function and the new sequential function will be arranged.
            $i++;
        }
        //end of while for room.
        $i--;
        //this is fdone for counting the nof rooms required for the class rookm.
        $number_of_classes = $i;
        if ($number_of_classes <= $MAX_Classes && $number_of_classes > 0) {
            echo "You will require " . $i . " rooms for arranging this no of classes.";
        } else {
            echo "This above schedule cant be operated with existing no of classes. You will either require " . ($i - $MAX_Classes) . " additional classes or reschedule the following classes";
        }
        $a = 1;
        if ($i > $MAX_Classes) {
            while ($a <= $MAX_Classes) {
                echo "<br><strong>Room: " . $a . "</strong>";
                printObject(${"abc" . $a}, $a, $name, $department->code);
                $a++;
            }
        }
        //end of if($i>3
        if ($number_of_classes > $MAX_Classes) {
            echo "The schedule you wish to prepare cant be arranged with " . $MAX_Classes . " classes. Please try to arrange the following classes in the empty slot for this day.";
        }
        while ($a <= $i) {
            echo "<br><strong>Room: " . $a . "</strong>";
            printObject(${"abc" . $a}, $a, $name, $department->code);
            $a++;
        }
    }
    //end of if(count)
}
Beispiel #7
0
KnpsUiNLmQN3HSn9dwk9rCHulrP8LL97l//H2KSCvOvSfk1XeN7ADSyWMC6ZPBD/
7WVnQo7GgMAA0Qhz+nIIFA5AyuFEbRiff+L5EEl+Bg6R9tgx+QUt9JXxF260dkAb
iKBmPcJldl2/GEmz6RAXhMwJnN35tbdzw0LVLzsypr0CAwEAAaAsMBMGCSqGSIb3
DQEJAjEGDAR0ZXN0MBUGCSqGSIb3DQEJBzEIDAYxMjM0NTYwDQYJKoZIhvcNAQEF
BQADggEBACqZ5+3GP7QbTJAqnUloMRBJGYZl0/EyW6dAMoq7E+RiR2OlJGXgP+ga
DPv7Wa4jZiYmf2CZCWKP+WvTvcg4AQq5h7hhAN+u+s8kk0lIjYjnkKRAedGYKDUO
fPD9WowISru3RB1xyxlvgeZS6WoA6TD8REVa1UyFoNzUewvsrNVkKSHh1xk/+ePx
2Ovvrcg9pAWY4K8FvMRdFQKnEud9CAoMxqz3kszhxDW6rcr2mgFPSrKi5WNj+Scg
Tqod8xbB753JWjEbG6Hui9LIMihTX3ZJ0c2GB0buhEgz49y83X/byFHSGGSQpzxX
qXDFVov9UZ+sGy8CJ5ahII79yrfKpxY=
';
try {
    echo 'Input 1:' . PHP_EOL;
    printObject(Object::fromBinary(base64_decode($input1)));
} catch (Exception $exception) {
    echo "ERROR: " . $exception->getMessage();
}
echo PHP_EOL;
try {
    echo 'Input 2:' . PHP_EOL;
    printObject(Object::fromBinary(base64_decode($input2)));
} catch (Exception $exception) {
    echo "ERROR: " . $exception->getMessage();
}
echo PHP_EOL;
try {
    echo 'Input 3:' . PHP_EOL;
    printObject(Object::fromBinary(base64_decode($input3)));
} catch (Exception $exception) {
    echo "ERROR: " . $exception->getMessage();
}
Beispiel #8
0
JTFmp4S3WFqkszKvaxBIT+jV0XKTNDwnO+dpExwU4jZUh18CdEFkIUuQb0gFF8B7
WJFVpNdsRqZRPBz83BW1Kjo0yAmaoTrGNmG0p6Qf3K2zbk1+Jik3VZq4rvKoTi20
6RvLA2//cMNfkYPsuqvoHGe2e0GOLtIB63wJzloWROpb72ohEHsvCKullIJVSuiS
9sfTBAenHCyndgAEd4T3npTUdaiNumVEm5ilZId7LAYekJhkgFu3vlcl8blBJKjE
skVTp7JpBmdXCL/G/6H2SFjca4JMOAy3DxwlGdgneIaXazHs5nBK/BgKPIyPzZ4w
secxBTTCNgI48YezK3GDkn65cmlnkt6F6Mf0MwoDaXTuB88Jycbwb5ihKnHEJIsO
draiRBZruwMPwPIP';
$binaryData = base64_decode($base64String);
$asnObject = Object::fromBinary($binaryData);
?>

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>PHPASN1 Examples</title>
  <meta name="description" content="How to parse binary ASN.1 data with PHPASN1">
  <meta name="author" content="Friedrich Große">
</head>
<body>
    <p>Got <?php 
echo strlen($binaryData);
?>
 byte of binary data: </p>
    <pre><?php 
printObject($asnObject);
?>
</pre>
</body>
</html>
Beispiel #9
0
<?php

/*
 * This file is part of the PHPASN1 library.
 *
 * Copyright © Friedrich Große <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use FG\ASN1\Object;
require_once __DIR__ . '/../vendor/autoload.php';
require_once 'shared.php';
$hex = 'a02b302906092a864886f70d01090e311c301a30180603551d110411300f820d636f72766573706163652e6465';
$asn = Object::fromBinary(hex2bin($hex));
printObject($asn);
Beispiel #10
0
    // this should contain a sequence of extensions
    $certExtensions = $certExtensions->getFirstChild();
    assert($certExtensions->getType() == Identifier::SEQUENCE);
    // now check all extensions and search for the SAN
    /** @var \FG\ASN1\Object $extensionSequence */
    foreach ($certExtensions as $extensionSequence) {
        assert($extensionSequence->getType() == Identifier::SEQUENCE);
        assert($extensionSequence->getNumberofChildren() >= 2);
        $extensionSequenceChildren = $extensionSequence->getChildren();
        $objectIdentifier = $extensionSequenceChildren[0];
        /* @var ObjectIdentifier $objectIdentifier */
        assert($objectIdentifier->getType() == Identifier::OBJECT_IDENTIFIER);
        if ($objectIdentifier->getContent() == OID::CERT_EXT_SUBJECT_ALT_NAME) {
            // now we have the wanted octet string
            $octetString = $extensionSequenceChildren[1];
            /* @var OctetString $octetString */
            $octetStringBinary = $octetString->getBinaryContent();
            // At this point you may want to create the sequence from the binary value of
            // the octet string and parse its structure like we did so far.
            // However a more general approach would be to understand the format of the
            // contained SAN fields and implement them in SubjectAlternativeNames.
            $sequence = Sequence::fromBinary($octetStringBinary);
            echo 'This is the parsed content of the SAN certificate extension field so far:' . PHP_EOL;
            printObject($sequence);
            // The following does not work yet because PHPASN1 SAn does only support DNS and IP
            //SubjectAlternativeNames::fromBinary($octetStringBinary);
        }
    }
} catch (\Exception $exception) {
    echo '[ERROR] Caught exception:' . PHP_EOL . $exception->getMessage() . PHP_EOL;
}