diff options
| author | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2026-07-12 15:51:52 +0300 |
|---|---|---|
| committer | Geo Halkiadakis <gchalkiadakis@sklavenitis.co.gr> | 2026-07-12 15:51:52 +0300 |
| commit | 02608271bb2a9f3a65ed536984d306ee14b48e34 (patch) | |
| tree | 3f23ec48a694ec014e845c4f70d9b5f1c065403c /tests/service | |
| download | kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.tar.gz kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.tar.bz2 kalassa-02608271bb2a9f3a65ed536984d306ee14b48e34.zip | |
Diffstat (limited to 'tests/service')
| -rwxr-xr-x | tests/service/entropy.php | 61 | ||||
| -rwxr-xr-x | tests/service/lorem-md.php | 71 | ||||
| -rwxr-xr-x | tests/service/mailjet.php | 56 | ||||
| -rwxr-xr-x | tests/service/memcached.php | 12 | ||||
| -rwxr-xr-x | tests/service/redis.php | 27 |
5 files changed, 227 insertions, 0 deletions
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 @@ +<html> + <head> + <title>Dev Tools</title> + </head> + <body> + <h1>Supported Crypt/Encrypt Methods</h1> + + <table width="100%"> + <tr> + <td width="50%" valign="top"> + + <h2>CIPHER Methods</h2> + <pre> +<?php +$ciphers = openssl_get_cipher_methods(); +$ciphers_and_aliases = openssl_get_cipher_methods(true); +$cipher_aliases = array_diff($ciphers_and_aliases, $ciphers); + +print_r($ciphers); + +print_r($cipher_aliases); + +?> + </pre> + </td> + + <td width="50%" valign="top"> + + <h2>DIGER Methods</h2> + <pre> +<?php +$digests = openssl_get_md_methods(); +$digests_and_aliases = openssl_get_md_methods(true); +$digests_aliases = array_diff($digests_and_aliases, $digests); + +print_r($digests); + +print_r($digests_aliases); +?> + + </pre> + + <h2>HASH Algorythms</h2> + <pre> + <?php print_r( hash_algos() ); ?> + </pre> + + <h2>Random</h2> + <pre> +random_bytes() +32Bytes: <?=bin2hex(random_bytes(32))?> + </pre> + + + </td> + + </tr> + </table> + + </body> +</html> 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 @@ +<?php + +use Registry; + +define("LIMIT", 50); // number of random records to make + +function lorem_md() { + // create curl resource + $ch = curl_init(); + + // set url + curl_setopt($ch, CURLOPT_URL, "https://jaspervdj.be/lorem-markdownum/markdown.txt"); + + //return the transfer as a string + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + // $output contains the output string + $output = curl_exec($ch); + + + $title = substr($output, 2, strpos( $output, "\n" )-1); + $body = trim(substr($output, strpos( $output, "\n" )+1)); + $intro = str_replace("\n", " ", (substr($body, 3, strpos( $body, "\n" )-2) . $title)); + + + + // close curl resource to free up system resources + curl_close($ch); + + return [ + 'title' => $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 100755 index 0000000..8e97715 --- /dev/null +++ b/tests/service/mailjet.php @@ -0,0 +1,56 @@ +<?php + +$envelope = [ + 'email' => 'piipiis@gmail.com', + 'name' => 'Test User', + 'subject' => 'Some Subject', + 'body' => "Ευχαριστούμε,<br> + για την εγγραφή σας στο <b>Classroom</b>.<br> + <br> + <i>Καλή συνέχεια!</i>." +]; + + +$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 '<pre>'; + print_r($response); + echo "\n\nstatus: ". $response->Messages[0]->Status; + if ($response->Messages[0]->Status == 'success') echo "\n\nSuccess = true"; +echo '</pre>';
\ 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 @@ +<?php +$mc = new Memcached(); +$mc->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 @@ +<?php + +$data = [ + 'test' => ['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 |
