From 059e0d95d0c28bc5060e87e146eaf7411f51bf90 Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Thu, 27 Apr 2023 03:47:30 +0300 Subject: skeleton commit; based on an anom project --- tests/service/entropy.php | 61 ++++++++++++++++++++++++++++++++++++++ tests/service/lorem-md.php | 71 +++++++++++++++++++++++++++++++++++++++++++++ tests/service/mailjet.php | 56 +++++++++++++++++++++++++++++++++++ tests/service/memcached.php | 12 ++++++++ tests/service/redis.php | 27 +++++++++++++++++ 5 files changed, 227 insertions(+) create mode 100755 tests/service/entropy.php create mode 100755 tests/service/lorem-md.php create mode 100644 tests/service/mailjet.php create mode 100755 tests/service/memcached.php create mode 100755 tests/service/redis.php (limited to 'tests/service') diff --git a/tests/service/entropy.php b/tests/service/entropy.php new file mode 100755 index 0000000..6401ffd --- /dev/null +++ b/tests/service/entropy.php @@ -0,0 +1,61 @@ + + + Dev Tools + + +

Supported Crypt/Encrypt Methods

+ + + + + + + + +
+ +

CIPHER Methods

+
	
+
+		
+
+ +

DIGER Methods

+
	
+
+
+		
+ +

HASH Algorythms

+
+			
+		
+ +

Random

+
+random_bytes()
+32Bytes: 
+        
+ + +
+ + + diff --git a/tests/service/lorem-md.php b/tests/service/lorem-md.php new file mode 100755 index 0000000..c7b8d0f --- /dev/null +++ b/tests/service/lorem-md.php @@ -0,0 +1,71 @@ + $title, + 'intro' => $intro, + 'body' => $body + ]; + +} + +$rand_content = lorem_md(); + + +for ($i=0; $i < LIMIT ; $i++) { + + $rand_content = lorem_md(); + + $id = Registry::use('database')->query( + "INSERT INTO lesson (title, course_id, intro, `body`, `status`) + VALUES (:title, :courseid, :intro, :body, :status)", + [ + ':title' => $rand_content['title'], + ':courseid' => rand(3,11), + ':intro' => $rand_content['intro'], + ':body' => $rand_content['body'], + 'status' => rand(0,1) + ] + )->lastInsertID(); + + Registry::use('database')->runQuery( + "INSERT INTO lesson_privilege (lesson_id, privilege_id) + VALUES (:lesson_id, :privilege_id)", + [ + ':lesson_id' => $id, + ':privilege_id' => rand(1,2) + ] + ); + +} + + +?> + +done! \ No newline at end of file diff --git a/tests/service/mailjet.php b/tests/service/mailjet.php new file mode 100644 index 0000000..8e97715 --- /dev/null +++ b/tests/service/mailjet.php @@ -0,0 +1,56 @@ + 'piipiis@gmail.com', + 'name' => 'Test User', + 'subject' => 'Some Subject', + 'body' => "Ευχαριστούμε,
+ για την εγγραφή σας στο Classroom.
+
+ Καλή συνέχεια!." +]; + + +$body = [ + 'Messages' => [ + [ + 'From' => [ + 'Email' => REPLY_TO_EMAIL, + 'Name' => MAIL_FROM_NAME + ], + 'To' => [ + [ + 'Email' => $envelope['email'], + 'Name' => $envelope['name'] + ] + ], + 'Subject' => $envelope['subject'], + 'HTMLPart' => $envelope['body'] + ] + ] +]; + +$ch = curl_init(); + +curl_setopt($ch, CURLOPT_URL, "https://api.mailjet.com/v3.1/send"); +curl_setopt($ch, CURLOPT_POST, 1); +curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json') +); +curl_setopt( + $ch, + CURLOPT_USERPWD, + MAIL_PASSWORD +); +$server_output = curl_exec($ch); +curl_close ($ch); + +$response = json_decode($server_output); + +echo '
';
+    print_r($response);
+    echo "\n\nstatus: ". $response->Messages[0]->Status;
+    if ($response->Messages[0]->Status == 'success') echo "\n\nSuccess = true";
+echo '
'; \ No newline at end of file diff --git a/tests/service/memcached.php b/tests/service/memcached.php new file mode 100755 index 0000000..c925488 --- /dev/null +++ b/tests/service/memcached.php @@ -0,0 +1,12 @@ +addServer("mymemcached", 11211); +$mc->add("key1", "value1"); +$mc->add("key2", "value2"); +$mc->add("key3", "value3"); + +echo "key1 : " . $mc->get("key1") . "\n"; +echo "key2 : " . $mc->get("key2") . "\n"; +echo "key3 : " . $mc->get("key3") . "\n"; + +die(); \ No newline at end of file diff --git a/tests/service/redis.php b/tests/service/redis.php new file mode 100755 index 0000000..d9b7778 --- /dev/null +++ b/tests/service/redis.php @@ -0,0 +1,27 @@ + ['Redis', 'is', 'working'], + 'redis' => '!!' +]; + +try { + + $redis = new \Predis\Client([ + 'host' => 'redis' + ]); + + foreach($data as $key => $value) { + echo $key .' '; + $redis->set( $key, serialize($value), 'EX', 60 ); + } + echo "...\n\n"; + +} catch (Exception $e) { + echo 'Caught exception: ', $e->getMessage(), "\n"; +} + +$test = unserialize($redis->get('test')); +$redis = unserialize($redis->get('redis')); + +echo implode(' ', $test) . $redis; \ No newline at end of file -- cgit v1.2.3