X Tutup
shuffle($NAMES); return $new; } function getRandomNumbers($code, $count=400, $max=10000) { $retval = array(); $MT = new Mersenne_Twister($code); for($i=0; $i < $count; $i++ ) { $retval[] = $MT->getNext(1,$max); } return $retval; } function validate($sanity, $code ) { if ( strlen($code) < 1 ) return "Python code is required"; foreach($sanity as $match => $message ) { if ( $match[0] == '/' ) { if ( preg_match($match, $code) ) return $message; } else if ( $match[0] == '!' ) { if ( strpos($code,substr($match,1)) !== false ) return $message; } if (strpos($code,$match) === false ) { return $message; } } return true; } function httpsWarning($url) { if ( strpos($url, 'https://') !== 0 ) return; ?>

Note: If you get an error when you run your program that complains about CERTIFICATE_VERIFY_FAILED when you call urlopen(), make the following changes to your program:

import urllib
import json
import ssl

...

    print 'Retrieving', url
    scontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
    uh = urllib.urlopen(url, context=scontext)
    data = uh.read()
This will keep your Python code from rejecting the server's certificate.

comments as $comment) { $total = $total + $comment->count; } return $total; }
X Tutup