Esempio n. 1
0
function replace($filename, $src)
{
    $msg = my_file_get_contents($filename);
    foreach ($src as $key => $value) {
        $msg = str_replace("{{" . $key . "}}", $value, $msg);
    }
    return $msg;
}
Esempio n. 2
0
function read_queue($filename)
{
    $ids = explode("\n", my_file_get_contents($filename));
    $ids = array_filter($ids, function ($id) {
        if ($id === "") {
            return false;
        } else {
            return true;
        }
    });
    return $ids;
}
} else {
    $csv_delimiter = '\\,';
    $csv_delimiter2 = ',';
}
/// Print the header
print_header("{$site->shortname}: {$struploadcourses}", $site->fullname, "<a href=\"index.php\">{$stradministration}</a> -> {$struploadcourses}");
/// If a file has been uploaded, then process it
require_once $CFG->dirroot . '/lib/uploadlib.php';
$um = new upload_manager('coursefile', false, false, null, false, 0);
if ($um->preprocess_files()) {
    if (!isset($um->files['coursefile'])) {
        csverror('Upload Error!', 'uploadcourse.php?sesskey=' . $USER->sesskey);
    }
    $filename = $um->files['coursefile']['tmp_name'];
    // Everything to Unix Line Endings
    $text = my_file_get_contents($filename);
    $text = preg_replace('!\\r\\n?!', "\n", $text);
    if ($fp = fopen($filename, "w")) {
        fwrite($fp, $text);
        unset($text);
        // Memory!
        fclose($fp);
    } else {
        csverror('File I/O Error! (1)', 'uploadcourse.php?sesskey=' . $USER->sesskey);
    }
    if (!($fp = fopen($filename, "r"))) {
        csverror('File I/O Error! (2)', 'uploadcourse.php?sesskey=' . $USER->sesskey);
    }
    // make arrays of fields for error checking
    $defaultcategory = getdefaultcategory();
    $defaultmtime = time();
Esempio n. 4
0
function json_get_contents($filename)
{
    return json_decode(my_file_get_contents($filename), true);
}
Esempio n. 5
0
function changes_eurotlx()
{
    global $currencies;
    $changes = array();
    $html = my_file_get_contents('http://eurotlx.com/it/strumenti/valute');
    foreach ($currencies as $currency) {
        $str = substr($html, strpos($html, CHANGE_BEGIN . $currency) + 95, 10);
        $str = substr($str, strpos($str, CHANGE_END));
        $change = comma2dot($str);
        $changes[strtolower($currency) . '2eur'] = 1 / $change;
    }
    // print_r($changes);
    return $changes;
}
Esempio n. 6
0
if (!empty($imageList)) {
    echo "Found ", count($imageList), " product images, extracting...\n";
    if (!file_exists('images')) {
        if (!mkdir('images', 0777)) {
            echo "Wasn't able to create the directory 'images'! No cool pics for you :(\n";
            die;
        }
    }
    foreach ($imageList as $imageUrl) {
        // Check the image URL for a predictable filename
        if (!preg_match('@/([^/]+?\\.(gif|png|jpe?g))([#?]|$)@i', $imageUrl, $match) == 1) {
            continue;
        }
        $filename = strtolower($match[1]);
        // Download the image
        $imageData = my_file_get_contents($imageUrl);
        if (empty($imageData)) {
            continue;
        }
        echo $filename, "\n";
        file_put_contents('images/' . $filename, $imageData);
    }
    echo "\n";
}
//function that generates the link list; $hierarchy is an array with info on the links and their visible names and $level sets the level of the lists, starting at 1 (see above)
function recurse_hierarchy($hierarchy, $level)
{
    // Initialize $html_string
    $html_string = '';
    //generates each link as part of a list by pulling the url and its visible name from the $hierarchy array
    if (isset($hierarchy['url']) && isset($hierarchy['name'])) {
Esempio n. 7
0
		echoln("");
		if ($reason)
			echoln($reason);
}

$help = new flag("help");
$disable_yasm = new flag("disable-yasm");
$version = new multiargument("version", array("vs2010", "vs2012", "vs2013"));


if ($help->set) {
	usage();
	exit(0);
}

$project_name = trim(my_file_get_contents("app/project.def"));

switch ($version->value) {
	case "vs2010": $sln = new vs2010($project_name); break;
	case "vs2012": $sln = new vs2012($project_name); break;
	case "vs2013": $sln = new vs2013($project_name); break;
}

$sln->make();


/* build framework/include/asmopt.h and framework/include/asmopt_internal.h */

if ($disable_yasm->set) {
	$yasm = "";
} else {
Esempio n. 8
0
function create_sitemap_pages()
{
    global $db, $my_base_url, $my_pligg_base, $URLMethod;
    if (XmlSitemaps_use_cache) {
        $icf = "cache/sitemap-pages.xml";
        if (file_exists($icf) && ($s = stat($icf)) && time() - $s['mtime'] < XmlSitemaps_cache_ttl) {
            echo my_file_get_contents($icf);
            return true;
        }
        ob_start();
    }
    echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
    echo '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd"     xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
    $sql = "SELECT link_modified  FROM " . table_links . " WHERE link_status!='discard' ORDER BY link_modified DESC LIMIT 1";
    $res = $db->get_col($sql);
    if (isset($res[0])) {
        $path = "{$my_base_url}{$my_pligg_base}";
        create_entry(strtotime($res[0]), $path);
    }
    ///////////////// Upcoming.............
    $sql = "SELECT UNIX_TIMESTAMP(link_date)  FROM " . table_links . " WHERE link_status='queued' ORDER BY link_date DESC LIMIT 1";
    $res = $db->get_col($sql);
    if (isset($res[0])) {
        if ($URLMethod == 1) {
            $path = "{$my_base_url}{$my_pligg_base}/upcoming.php";
        } else {
            if ($URLMethod == 2) {
                $path = "{$my_base_url}{$my_pligg_base}/upcoming";
            }
        }
        create_entry($res[0], $path);
    }
    //////////////////////...........categories.................
    $sql = "SELECT category_id,category_name,category_safe_name FROM " . table_categories . " WHERE category_enabled=1 AND category_name!='new category'";
    $cat = $db->get_results($sql);
    foreach ($cat as $i) {
        $sql = "SELECT UNIX_TIMESTAMP(link_published_date),link_id FROM " . table_links . " WHERE link_category=" . $i->category_id . " AND link_status='published' ORDER BY link_published_date DESC LIMIT 1";
        $res = $db->get_col($sql);
        if (isset($res[0])) {
            $path = getmyFullurl('maincategory', urlencode($i->category_safe_name));
            create_entry($res[0], $path);
        }
    }
    ////////////////////.............upcoming categories..........
    foreach ($cat as $i) {
        $sql = "SELECT UNIX_TIMESTAMP(link_date) FROM " . table_links . " WHERE link_category=" . $i->category_id . " AND link_status='queued' ORDER BY link_date DESC LIMIT 1";
        $res = $db->get_col($sql);
        if (isset($res[0])) {
            $path = getmyFullurl('queuedcategory', urlencode($i->category_safe_name));
            create_entry($res[0], $path);
        }
    }
    if (check_for_enabled_module('extra_pages', 0.1)) {
        //.............Tips page...............
        $sql = "SELECT UNIX_TIMESTAMP(modified_date) FROM " . table_prefix . "extra_pages  WHERE type='Tip' ORDER BY modified_date DESC LIMIT 1";
        $res = $db->get_col($sql);
        if (isset($res[0])) {
            if ($URLMethod == 1) {
                $path = "{$my_base_url}{$my_pligg_base}/module.php?module=extra_pages&amp;action=show_tips";
            } else {
                if ($URLMethod == 2) {
                    $path = "{$my_base_url}{$my_pligg_base}/tips";
                }
            }
            create_entry($res[0], $path);
        }
        //.............FAQ page................
        $sql = "SELECT UNIX_TIMESTAMP(modified_date) FROM " . table_prefix . "extra_pages  WHERE type='FAQ' ORDER BY modified_date DESC LIMIT 1";
        $res = $db->get_col($sql);
        if (isset($res[0])) {
            if ($URLMethod == 1) {
                $path = "{$my_base_url}{$my_pligg_base}/module.php?module=extra_pages&amp;action=show_faq";
            } else {
                if ($URLMethod == 2) {
                    $path = "{$my_base_url}{$my_pligg_base}/faq";
                }
            }
            create_entry($res[0], $path);
        }
    }
    //close xml
    echo '</urlset>';
    if (XmlSitemaps_use_cache) {
        $ret = ob_get_contents();
        ob_end_flush();
        my_file_put_contents($icf, $ret);
    }
    return true;
}