Example #1
0
/**
 * Get course details in the form of summary from moodle site. 
 * @param string $moodle_site the moodle site from where to get course categories
 * @param string $moodle_token the token of the moodle web service user 
 * @param integer $course_id the moodle course id for which to retrieve details 
 * @return string course description 
*/
function get_moodle_course_content($moodle_site, $moodle_token, $course_id)
{
    $args = array();
    $options = array(array('name' => 'sectionnumber', 'value' => 0), array('name' => 'excludemodules', 'value' => true));
    $args['body'] = array('wsfunction' => 'core_course_get_contents', 'wstoken' => "{$moodle_token}", 'moodlewsrestformat' => 'json', 'courseid' => $course_id, 'options' => $options);
    $response = wp_remote_post($moodle_site, $args);
    $content = json_decode($response['body']);
    er($content);
    $summary = "";
    if (isset($content[0]) && isset($content[0]->summary)) {
        $summary = parse_images($content[0]->summary, 'course', $course_id);
    }
    return $summary;
}
Example #2
0
}
$info_hash = bin2hex($info_hash);

 if(!file_exists($info_hash))
{
    er("Please plant the torrent file on the Network. Torrent may be dead by now.");

}
if(filesize($info_hash) == 0 && (time() - filemtime($info_hash)) >= 86400 && $_GET['left'] != 0)
{ // seeds keep the torrent going i.e. $_GET['left'] == 0 means no unlinking
    unlink($info_hash);
if(file_exists("multiseed/$info_hash"))
{
    unlink("multiseed/$info_hash");
}
er("Torrent is dead. Nobody has accessed this torrent for two days or more. ");
}

  // Peer sharing code starts here
if(file_exists("multiseed/$info_hash") && filesize($info_hash) != 0)
{   // checks to see if multiseed file is present
    $data = @file_get_contents("multiseed/$info_hash");  // reads data from multiseed file
    $data2 = explode(":",$data, 2); // $data2[0] is the timestamp
if((time() - (int)$data2[0]) >= 900)
{  // every 15 mins
// THIS CODE REMOVES DYING PEERS
    $time = intval((time() % 7680) / 60);
    $handle = fopen($info_hash, "rb+");
    flock($handle, LOCK_EX);
    $x = fread($handle, filesize($info_hash));
    $no_peers = intval(strlen($x) / 7);
Example #3
0
        fclose($handle);
        return $o;
}


if($_GET['info_hash'])
{
        echo 'd5:filesd';
        $info_hash = $_GET['info_hash'];
        if(strlen($info_hash) != 20)
        {
                $info_hash = stripcslashes($_GET['info_hash']);
        }
        if(strlen($info_hash) != 20)
        {
                er('Invalid info_hash');
        }
        $info_hash = bin2hex($info_hash);
        if(file_exists($info_hash))
	{
	if(filesize($info_hash) == 0)
	{
		if((time() - filemtime($info_hash)) >= 86400)
			{ // 1 day of inactivity
				unlink($info_hash);
				if(file_exists("multiseed/$info_hash"))
          {
            unlink("multiseed/$info_hash");
          }
			// keep this hidden
			// 1 days inactive if
Example #4
0
        <?php 
}
?>

        <div class="form-row">
            <label for="domain">Base domain - Common Name (CN)</label>
            <input type="text" autofocus="autofocus" required="required" name="domain" id="domain" pattern="[a-z0-9.-]+\.[a-z]{2,63}" title="Domain name" placeholder="example.com" value="<?php 
echo isset($_GET['domain']) ? er($_GET['domain']) : '';
?>
" />
        </div>

        <div class="form-row">
            <label for="san">Other domains - Subject Alternative Names (SAN)</label>
            <textarea name="san" id="san" placeholder="www.example.com"><?php 
echo isset($_GET['san']) ? er(implode("\n", explode(',', $_GET['san']))) : '';
?>
</textarea>
            <span class="help">(domain name per line)</span>
        </div>

        <div class="form-row">
            <button class="btn-new" type="submit">Issue new cert!</button>
        </div>

    </form>
</div>

<script>
    var sanInput = document.getElementById('san');
    var domainInput = document.getElementById('domain');
Example #5
0
        ?>
        <div class="card">
            <h3>Last log</h3>
            <pre><code><?php 
        foreach (explode("\n", $certificate->getLastLog()) as $line) {
            if (preg_match('~ERROR:~', $line)) {
                echo '<strong>';
                echo findLinks(er($line));
                echo "</strong>\n";
            } else {
                if (preg_match('~DEBUG:~', $line)) {
                    echo '<span style="color: gray;">';
                    echo findLinks(er($line));
                    echo "</span>\n";
                } else {
                    echo er($line);
                    echo "\n";
                }
            }
        }
        ?>
</code></pre>
        </div>
    <?php 
    }
    ?>

    <div class="card">
        <h3>Issued certificate details</h3>
        <p><em>certificate was not yet issued, please wait...</em></p>
    </div>
Example #6
0
    $info_hash = bin2hex($info_hash);
    $qstring = "";
    // the other query strings are not going to be used
    if (isset($_GET['left'])) {
        $qstring .= "&left=" . $_GET['left'];
    }
    if (isset($_GET['event'])) {
        $qstring .= "&event=" . $_GET['event'];
    }
    if (isset($_GET['numwant'])) {
        $qstring .= "&numwant=" . $_GET['numwant'];
    }
    if (isset($_GET['ip'])) {
        $qstring .= "&ip=" . $_GET['ip'];
    }
    include "common.php";
    $db = mysql_connect($dbhost, $dbuname, $dbpasswd);
    mysql_select_db($dbname, $db);
    $query = sprintf("SELECT trackers.url FROM trackers, hashes WHERE hashes.trackerid = trackers.trackerid AND hashes.infohash = %s LIMIT 1", quote_smart(pack("H*", $info_hash)));
    $qresult = mysql_query($query);
    $result = @mysql_fetch_row($qresult);
    mysql_close($db);
    if (isset($result[0])) {
        $url = $result[0] . "?" . "compact=1&" . "port=" . $_GET['port'] . "&info_hash=" . urlencode(pack("H*", $info_hash)) . $qstring;
        header("Location: {$url}", TRUE, 302);
    } else {
        er('No tracker could be allocated to your torrent. It may have expired.');
    }
} else {
    er('Your client does not support the compact tracker protocol. Please upgrade to the latest version.');
}
 public function endReviewPOST()
 {
     // getting last id
     $last_protocol = end($this->protocol_repository->findAll());
     $protocol_id = $last_protocol->getId();
     $client = $this->client;
     $route = $client->getContain - er()->get('router')->generate('protocol_end_review', array("protocol_id" => $protocol_id), false);
     file_put_contents("/tmp/photo.jpg", "test");
     $file = tempnam(sys_get_temp_dir(), 'upl');
     // create file
     imagepng(imagecreatetruecolor(10, 10), $file);
     // create and write image/png to it
     $image = new UploadedFile($file, 'new_image.png');
     $post_data = array("draft-opinion" => "A", "final-decision" => $file);
     $client->request('POST', $route, $post_data);
     $this->assertEquals(301, $client->getResponse()->getStatusCode());
 }
Example #8
0
        // for some reason it returns zero encoded as a string
        if ($row["Rows"] == "0") {
            if (mysql_date_parser($row["Update_time"]) <= time() - 86400) {
                // 86400 seconds in a day so therefore if the torrent has had no requests for a day it expires
                mysql_query('DROP TABLE IF EXISTS ' . $row["Name"]);
                $query = sprintf('DELETE FROM `multiseed` WHERE info_hash = %s ', quote_smart($binfo_hash));
                mysql_query($query);
                mysql_close();
                er('The torrent is dead. Nobody has accessed this torrent for two days or more.');
            }
        }
    }
    $found = True;
}
if (!$found) {
    er('Please plant the torrent file on the network. The torrent may have expired.');
}
// This bit is for multiseeding (peer sharing)
$query = sprintf('SELECT `url`, UNIX_TIMESTAMP(timestamp) FROM multiseed WHERE info_hash = %s ', quote_smart($binfo_hash));
$result = mysql_query($query);
// the @ is to shut it up just in case table multiseed does not exist
$row = @mysql_fetch_row($result);
// If an array is not returned then the data is useless
if (is_array($row)) {
    if (time() - (int) $row[1] >= 900) {
        // run cleanup
        $query = sprintf('DELETE FROM `%s` WHERE UNIX_TIMESTAMP(timestamp) <= %s ', mysql_real_escape_string($info_hash), time() - 2400);
        $result = mysql_query($query);
        // if it has changed to zero peers don't bother
        $query = sprintf('SELECT COUNT(*) FROM `%s`', mysql_real_escape_string($info_hash));
        $result = mysql_query($query);
Example #9
0
            $stracker .= "?pull=" . urlencode(pack("H*", $info_hash));
            $fp = fopen($stracker, "rb");
            $stream = "";
            if ($fp) {
                while (!feof($fp)) {
                    $stream .= @fread($fp, 128);
                }
            }
            fclose($fp);
            $returned = BDecode($stream);
            if ($returned == FALSE) {
                continue;
            }
            shuffle($returned);
            $status = 1;
            $tracker = $returned[0];
            break;
        }
        if ($status == 0) {
            er('No tracker can be found for the torrent');
        }
        // this block is executed if a tracker is (miraculously) found
        $handle = fopen("/hashes/{$info_hash}", "w");
        fwrite($handle, $tracker);
        fclose($handle);
        $url = $tracker . "?" . "info_hash=" . urlencode(pack("H*", $info_hash));
        header("Location: {$url}", TRUE, 302);
    }
} else {
    er('Please include an info-hash to save bandwidth');
}
Example #10
0
    }
    $url = $_GET["url"];
    if (!ping($url)) {
        er('Other tracker not alive. Please Try Again');
    }
    // or else plant as usual
    $handle = fopen($info_hash, "w");
    fclose($handle);
    $handle2 = fopen("multiseed/{$info_hash}", "w");
    $times = time() . ":" . $url;
    fwrite($handle2, $times);
    fclose($handle2);
    die("7:SUCCESS");
}
if (isset($_GET["plant"])) {
    // a one tracker plant
    $info_hash = $_GET['plant'];
    if (strlen($info_hash) != 20) {
        $info_hash = stripcslashes($_GET['plant']);
    }
    if (strlen($info_hash) != 20) {
        er('Invalid info_hash');
    }
    $info_hash = bin2hex($info_hash);
    if (file_exists($info_hash)) {
        er('Torrent File already planted');
    }
    $handle = fopen($info_hash, "w");
    fclose($handle);
    die("25:File successfully planted");
}
Example #11
0
    }
    if (substr($_GET['url'], 0, 7) != 'http://' && substr_count($stracker, '/announce') != 1) {
        mysql_close();
        er('The URL of the other tracker is not correct. Make sure http:// and /announce are included.');
    }
    $url = $_GET['url'];
    if (!ping($url)) {
        mysql_close();
        er('Other tracker not alive. Please Try Again');
    }
    // creation of the table goes AFTER the ping
    // it is true to say that there is a LOT of pinging involved but it IS important
    $query = sprintf('CREATE TABLE `%s` (`ip_and_port` TINYBLOB NOT NULL, `seed_or_peer` TINYINT NOT NULL, `timestamp` TIMESTAMP NOT NULL , UNIQUE (ip_and_port(6))) ', mysql_real_escape_string($info_hash));
    mysql_query($query);
    $query = sprintf('INSERT INTO `multiseed` VALUES ( %s , %s ,  NOW())', quote_smart(pack('H*', $info_hash)), quote_smart($url));
    mysql_query($query);
    if (mysql_errno() == 1146) {
        // create the table
        // i've decided to have the info_hash in binary to save a bit of space
        mysql_query('CREATE TABLE `multiseed` (`info_hash` TINYBLOB NOT NULL, `url` TEXT NOT NULL, `timestamp` TIMESTAMP NOT NULL , UNIQUE (info_hash(20))) ');
        mysql_query($query);
        die('7:SUCCESS');
    } elseif (mysql_errno()) {
        mysql_close();
        er('There was a database error: ' . mysql_error());
        // I doubt a mysql error is any use to the user but anyway
    } else {
        mysql_close();
        die('7:SUCCESS');
    }
}
Example #12
0
    }
    mysql_close();
    die('ee');
}
if ($wholescrape) {
    $o = 'd5:filesd';
    // SHOW TABLES LIKE does not seem to work on some versions of MYSQL
    $db = mysql_connect($dbhost, $dbuname, $dbpasswd);
    mysql_select_db($dbname, $db);
    $result = mysql_query("SHOW TABLE STATUS LIKE '________________________________________'");
    while ($row = mysql_fetch_array($result)) {
        // there should be no other reason to have a 40 byte table name
        if ($row["Rows"] == "0") {
            if (mysql_date_parser($row["Update_time"]) <= time() - 86400) {
                mysql_query('DROP TABLE IF EXISTS ' . $row["Name"]);
                $query = sprintf("DELETE FROM `multiseed` WHERE info_hash = '%s' ", mysql_real_escape_string(pack('H*', $row["Name"])));
                @mysql_query($query);
                // it might not be a multiseed torrent
            } else {
                $o .= getstat($row["Name"]);
            }
        } else {
            $o .= getstat($row["Name"]);
        }
    }
    mysql_close();
    $o .= 'ee';
    die($o);
} else {
    er('Please specify an info_hash.');
}