aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/vobject/bin
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/vobject/bin')
-rwxr-xr-xvendor/sabre/vobject/bin/bench.php12
-rwxr-xr-xvendor/sabre/vobject/bin/generateicalendardata.php91
-rwxr-xr-xvendor/sabre/vobject/bin/vobjectvalidate.php139
3 files changed, 242 insertions, 0 deletions
diff --git a/vendor/sabre/vobject/bin/bench.php b/vendor/sabre/vobject/bin/bench.php
new file mode 100755
index 000000000..b949c8ea4
--- /dev/null
+++ b/vendor/sabre/vobject/bin/bench.php
@@ -0,0 +1,12 @@
+#!/usr/bin/env php
+<?php
+
+include __DIR__ . '/../vendor/autoload.php';
+
+$data = stream_get_contents(STDIN);
+
+$start = microtime(true);
+
+$lol = Sabre\VObject\Reader::read($data);
+
+echo "time: " . (microtime(true)-$start) . "\n";
diff --git a/vendor/sabre/vobject/bin/generateicalendardata.php b/vendor/sabre/vobject/bin/generateicalendardata.php
new file mode 100755
index 000000000..92c8c106d
--- /dev/null
+++ b/vendor/sabre/vobject/bin/generateicalendardata.php
@@ -0,0 +1,91 @@
+#!/usr/bin/env php
+<?php
+
+use Sabre\VObject;
+
+if ($argc<2) {
+ $cmd = $argv[0];
+ fwrite(STDERR, <<<HI
+Fruux test data generator
+
+This script generates a lot of test data. This is used for profiling and stuff.
+Currently it just generates events in a single calendar.
+
+The iCalendar output goes to stdout. Other messages to stderr.
+
+{$cmd} [events]
+
+
+HI
+ );
+ die();
+}
+
+$events = 100;
+
+if (isset($argv[1])) $events = (int)$argv[1];
+
+include __DIR__ . '/../vendor/autoload.php';
+
+fwrite(STDERR, "Generating " . $events . " events\n");
+
+$currentDate = new DateTime('-' . round($events/2) . ' days');
+
+$calendar = VObject\Component::create('VCALENDAR');
+$calendar->version = '2.0';
+$calendar->calscale = 'GREGORIAN';
+
+$ii=0;
+
+while($ii < $events) {
+
+ $ii++;
+
+ $event = VObject\Component::create('VEVENT');
+ $event->DTSTART = 'bla';
+ $event->SUMMARY = 'Event #' . $ii;
+ $event->UID = md5(microtime(true));
+
+ $doctorRandom = mt_rand(1,1000);
+
+ switch($doctorRandom) {
+ // All-day event
+ case 1 :
+ $event->DTEND = 'bla';
+ $dtStart = clone $currentDate;
+ $dtEnd = clone $currentDate;
+ $dtEnd->modify('+' . mt_rand(1,3) . ' days');
+ $event->DTSTART->setDateTime($dtStart, VObject\Property\DateTime::DATE);
+ $event->DTEND->setDateTime($dtEnd, VObject\Property\DateTime::DATE);
+ break;
+ case 2 :
+ $event->RRULE = 'FREQ=DAILY;COUNT=' . mt_rand(1,10);
+ // No break intentional
+ default :
+ $dtStart = clone $currentDate;
+ $dtStart->setTime(mt_rand(1,23), mt_rand(0,59), mt_rand(0,59));
+ $event->DTSTART->setDateTime($dtStart, VObject\Property\DateTime::UTC);
+ $event->DURATION = 'PT'.mt_rand(1,3).'H';
+ break;
+
+ }
+
+ $calendar->add($event);
+ $currentDate->modify('+ ' . mt_rand(0,3) . ' days');
+
+}
+fwrite(STDERR, "Validating\n");
+
+$result = $calendar->validate();
+if ($result) {
+ fwrite(STDERR, "Errors!\n");
+ fwrite(STDERR, print_r($result,true));
+ die(-1);
+}
+
+fwrite(STDERR, "Serializing this beast\n");
+
+echo $calendar->serialize();
+
+fwrite(STDERR, "done.\n");
+
diff --git a/vendor/sabre/vobject/bin/vobjectvalidate.php b/vendor/sabre/vobject/bin/vobjectvalidate.php
new file mode 100755
index 000000000..e0b2a479f
--- /dev/null
+++ b/vendor/sabre/vobject/bin/vobjectvalidate.php
@@ -0,0 +1,139 @@
+#!/usr/bin/env php
+<?php
+
+namespace Sabre\VObject;
+
+// This sucks.. we have to try to find the composer autoloader. But chances
+// are, we can't find it this way. So we'll do our bestest
+$paths = array(
+ __DIR__ . '/../vendor/autoload.php', // In case vobject is cloned directly
+ __DIR__ . '/../../../autoload.php', // In case vobject is a composer dependency.
+);
+
+foreach($paths as $path) {
+ if (file_exists($path)) {
+ include $path;
+ break;
+ }
+}
+
+if (!class_exists('Sabre\\VObject\\Version')) {
+ fwrite(STDERR, "Composer autoloader could not be properly loaded.\n");
+ die(1);
+}
+
+fwrite(STDERR, "SabreTooth VObject validator " . Version::VERSION . "\n");
+
+
+$repair = false;
+$posArgs = array();
+
+// Argument parsing:
+foreach($argv as $k=>$v) {
+
+ if ($k===0) {
+ continue;
+ }
+ if (substr($v,0,2)==='--') {
+ switch($v) {
+ case '--repair' :
+ $repair = true;
+ break;
+ default :
+ throw new InvalidArgumentException('Unknown option: ' . $v);
+ break;
+ }
+ continue;
+ }
+ $posArgs[] = $v;
+
+}
+
+function help() {
+
+ global $argv;
+
+ fwrite(STDERR, <<<HELP
+Usage instructions:
+
+ {$argv[0]} [--repair] inputfile [outputfile]
+
+ inputfile Input .vcf or .ics file.
+ outputfile Output .vcf or .ics file. This is only used with --repair.
+ --repair Attempt to automatically repair broken files.
+
+For both the output- and inputfile "-" can be specified, to use STDIN and STDOUT
+respectively.
+
+All other output from this script is sent to STDERR.
+
+https://github.com/fruux/sabre-vobject
+
+HELP
+);
+
+}
+
+if (count($posArgs) < 1) {
+ help();
+ die();
+}
+
+if ($posArgs[0]!=='-') {
+ $input = fopen($posArgs[0],'r');
+} else {
+ $input = STDIN;
+}
+
+if (isset($posArgs[1]) && $posArgs[1]!=='-') {
+ $output = fopen($posArgs[1],'w');
+} else {
+ $output = STDOUT;
+}
+
+// This is a bit of a hack to easily support multiple objects in a single file.
+$inputStr = "BEGIN:X-SABRE-WRAPPER\r\n" . stream_get_contents($input);
+
+$inputStr = rtrim($inputStr, "\r\n") . "\r\nEND:X-SABRE-WRAPPER\r\n";
+
+// Now the actual work.
+$vObj = Reader::read($inputStr);
+
+$objects = $vObj->children();
+
+foreach($objects as $child) {
+
+ switch($child->name) {
+ case 'VCALENDAR' :
+ fwrite(STDERR, "iCalendar: " . (string)$child->VERSION . "\n");
+ break;
+ case 'VCARD' :
+ fwrite(STDERR, "vCard: " . (string)$child->VERSION . "\n");
+ break;
+ default :
+ fwrite(STDERR, "This was an unknown object, but it did parse. It's likely that validation will give you unexpected results.\n");
+ break;
+ }
+
+ $options = 0;
+ if ($repair) $options |= Node::REPAIR;
+
+ $warnings = $child->validate($options);
+
+ if (!count($warnings)) {
+ fwrite(STDERR, "[GOOD NEWS] No warnings!\n");
+ } else {
+ foreach($warnings as $warn) {
+
+ fwrite(STDERR, $warn['message'] . "\n");
+
+ }
+
+ }
+
+ if ($repair) {
+ fwrite($output, $child->serialize());
+ }
+
+}
+