Exemple #1
0
 $preMsg = $spotnab->getRandomStr(800);
 $postMsg = $spotnab->decrypt($spotnab->encrypt($preMsg));
 if ($postMsg === false) {
     echo "Failed!\n";
 } else {
     if (!strcmp($preMsg, $postMsg)) {
         echo "Successful!\n";
     } else {
         echo "Failed!\n";
     }
 }
 printf("%s INFO - Testing small message encode/decode ...", date("Y-m-d H:i:s"));
 $before = array('server' => array('code' => 'l2g', 'title' => 'l2g newznab'), 'postdate_utc' => $spotnab->local2utc(), 'comments' => array(array('gid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', 'cid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', 'comment' => 'testing comment 1', 'username' => 'l2g', 'is_visible' => 1, 'postdate_utc' => $spotnab->local2utc(time() - 86400)), array('gid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', 'cid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', 'username' => 'l2g-hater', 'is_visible' => 1, 'comment' => 'testing comment 2', 'postdate_utc' => $spotnab->local2utc(time() - 86000))));
 $article = $spotnab->encodePost($before, Null, true);
 if ($article !== false) {
     $after = $spotnab->decodePost($article[1]);
     if ($before === $after) {
         echo "Successful!\n";
     } else {
         echo "Failed!\n";
     }
 } else {
     echo "Failed!\n";
 }
 printf("%s INFO - Testing big message encode/decode ...", date("Y-m-d H:i:s"));
 $before = array('server' => array('code' => 'l2g', 'title' => 'l2g newznab'), 'postdate_utc' => $spotnab->local2utc(), 'comments' => array());
 for ($i = 0; $i < 3000; $i++) {
     // Build large post
     $before['comments'][] = array('gid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', 'cid' => 'ABCDEFHIJKLMNOPQRSTUVWXYZ0123456', 'comment' => $refc = $spotnab->getRandomStr(rand(15, 200)), 'username' => 'bb', 'is_visible' => 1, 'postdate_utc' => $spotnab->local2utc(time() - 86400));
 }
 $article = $spotnab->encodePost($before, Null, true);