Multiple options for decoding cached url's - php

I have a script that needs to pull data from different cached URLs.
Right now $url = 'http://example.com/search.php?user=abc&part='.$part;
I need the portion of the script below modified to search multiple MD5 encrypted url's
i.e.
$url = 'http://example.com/search.php?user=abc&part='.$part;
$url = 'http://example.com/search.php?user=xyz&part='.$part;
$url = 'http://example.com/search.php?user=123&part='.$part;
If more than 1 value is returned than return the one with the newest date.
$xid needs to be the current setting for $url
Original code.
function get_cache_file($url) {
$xid = md5($url);
$gendir = CACHE_ROOT . substr($xid, 0, 1) . '/'. substr($xid, 1, 2);
if(!is_dir($gendir)) {
mkdir($gendir, 0777, true);
}
return $gendir . '/' . $xid;
}

Found an answer to the problem.
function get_cache_file($part)
{
$users = array('user1', 'user2', 'user3');
$file = '';
$time = 0;
foreach ($users as $user) {
$url = 'http://example.com/search.php?user=' . $user . '&part=' . $part;
$xid = md5($url);
$gendir = CACHE_ROOT . substr($xid, 0, 1) . '/' . substr($xid, 1, 2);
if (is_dir($gendir) && is_file($gendir . '/' . $xid)) {
if ($time < filemtime($file)) {
$time = filemtime($file);
$file = $gendir . '/' . $xid;
}
}
}

Related

I have a 500 error with preg_match syntax

I'm dealing with this php script, which when executed on the host gives a 500 error, apparently the line where the preg_match is is the one that contains the error...
this file is going to be executed as a cron to validate.
<?php
$encoded = wordwrap($encoded, 80, "\xa", true);
$license_file = $dir . "/modules/addons/Kayako/license.php";
if ($key != $sellKey) {
die("Invalid "license . php" file!");
}
function getWhmcsDomain() {
if (!empty($_SERVER["SERVER_NAME"])) {
return $_SERVER["SERVER_NAME"];
}
}
$license["checkdate"] = date("Ymd");
$keyName = $modleName . "_licensekey";
$dir = __DIR__;
$encoded = strrev($encoded);
$license["status"] = "Active";
$sellKey = "ModulesGarden_Kayako_54M02934WH301844E_HackbyRicRey";
$license["checktoken"] = $checkToken;
$key_data = WHMCS\Database\Capsule::table("tblconfiguration")->where("setting", "kayako_localkey")->first();
$license = array("licensekey" => $key, "validdomain" => getWhmcsDomain(), "validip" => getIp(), "validdirectory" => $dir . "/modules/addons/Kayako," . $dir . "/modules/addons," . $dir . "/modules/addons/Kayako," . $dir . "/modules/addons/Kayako," . $dir . "/modules/addons," . $dir . "," . $dir . "/modules");
$secret = "659c08a59bbb484f3b40591";
include_once "init.php";
function getIp() {
return isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : $_SERVER["LOCAL_ADDR"];
}
if (!$key_data) {
WHMCS\Database\Capsule::table("tblconfiguration")->insert(array("setting" => "kayako_localkey", "value" => ''));
}
$checkToken = time() . md5(rand(1000000000, 0) . $key);
$modleName = "kayako";
$encoded = $encoded . md5($encoded . $secret);
$encoded = serialize($license);
preg_match("/kayako_licensekey\s?=\s?"([A - Za - z0 - 9_] +) "/", $content, $matches);
$encoded = md5($license["checkdate"] . $secret) . $encoded;
$key = $matches[1];
$encoded = base64_encode($encoded);
if (file_exists($license_file)) {
$content = file_get_contents($license_file);
} else {
echo "Please Upload "license . php" File Inside: " . $dir . "/modules/addons/Kayako/";
}
$content = '';
try {
WHMCS\Database\Capsule::table("tblconfiguration")->where("setting", "kayako_localkey")->update(array("value" => $encoded));
echo "Done!";
}
catch(\Throwable $e) {
echo "There is an issue, contact.";
} ?>
You have extra double quotes in the regular expression. You also have extra spaces inside the [] in the regexp. You can replace that character class with \w, which matches alphanumerics and underscore.
preg_match('/kayako_licensekey\s?=\s?(\w+)/', $content, $matches);
Another problem: You use a number of variables before you assign them:
$modleName
$checkToken
$key
$sellKey
$dir
Did you post the code out of order?

Object of type mysqli_result error in old vBulletin product

I am trying to update an old vBulletin product and it keeps throwing an error for me.
Cannot use object of type mysqli_result as array in C:\wamp\www\mem_payment.php on line 124
Line 124:
$vbma->setCustomerNumber(unserialize($purchase['info']), $product['pur_group'], false, $userinfo);
Line 102 - 130
$purchase = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX .
"ma_purchases WHERE id = '" . $id . "'");
$order = unserialize($purchase['order']);
if ($order[0] !== $vbulletin->GPC['business'])
{
$status_code = '503 Service Unavailable';
// Paypal likes to get told its message has been received
if (SAPI_NAME == 'cgi' or SAPI_NAME == 'cgi-fcgi')
{
header('Status: ' . $status_code);
}
else
{
header('HTTP/1.1 ' . $status_code);
}
}
unset($order[0]);
if ($purchase and !in_array($order[1], array('renew', 'upgrade')))
{
$product = $vbulletin->db->query_read("SELECT pur_group FROM " . TABLE_PREFIX .
"ma_products WHERE id = '" . $order[1] . "'");
$userinfo = fetch_userinfo($purchase['userid']);
$vbma->setCustomerNumber(unserialize($purchase['info']), $product['pur_group'], false,
$userinfo);
$rand = rand($vbulletin->options['memarea_numstart'], $vbulletin->options['memarea_numend']);
$licnum = substr(md5($prodid . rand(0, 20000) . $rand . $rand), 0, rand(10, $vbulletin->
options['memarea_custnumleng']));
$licensedm = datamanager_init('License', $vbulletin, ERRTYPE_ARRAY);
$licensedm->setr('userid', $userinfo['userid']);
I have been reading numerous questions regarding this error stating to essentially:
define your query
query your query
then associate the query
IE:
$query = "SELECT 1";
$result = $mysqli->query($query);
$followingdata = $result->fetch_assoc()
Almost all of the answers are along those lines, although I am failing to see where this needs to be done.
I'm not sure if it has anything to do with the function, but I will add that as well:
function setCustomerNumber($ma_info, $usergroup = '', $usevb = true, $userinfo = '')
{
if ($usevb == false)
{
$this->vbulletin->userinfo = &$userinfo;
}
$fcust = $this->fields['custnum'];
$fpass = $this->fields['mpassword'];
$finfo = $this->fields['info'];
$userdm = datamanager_init('User', $this->vbulletin, ERRTYPE_ARRAY);
$userinfo = fetch_userinfo($this->vbulletin->userinfo['userid']);
$userdm->set_existing($userinfo);
if (!$this->vbulletin->userinfo["$fcust"] and !$this->vbulletin->userinfo["$fpass"])
{
$rand = rand($this->vbulletin->options['memarea_numstart'], $this->vbulletin->
options['memarea_numend']);
$num = $this->vbulletin->options['custnum_prefix'] . substr(md5($rand), 0, $this->
vbulletin->options['memarea_custnumleng'] - strlen($this->vbulletin->options['custnum_prefix']));
$userdm->set($fcust, $num);
$pass = substr(md5(time() . $num . $rand . rand(0, 2000)), 0, $this->vbulletin->
options['memarea_custnumleng']);
$userdm->set($fpass, $pass);
$this->sendCustomerInfo($this->vbulletin->userinfo['userid'], $this->vbulletin->
userinfo['username'], $this->vbulletin->userinfo['email'], $num, $pass);
}
if ($usergroup or $usergroup !== '' or $usergroup !== '0')
{
if ($usergroup != $this->vbulletin->userinfo['usergroupid'])
{
$ma_info['oldgroup'] = $this->vbulletin->userinfo['usergroupid'];
$userdm->set('usergroupid', $usergroup);
}
}
if ($ma_info)
{
$ma_info = serialize($ma_info);
$userdm->set($finfo, $ma_info);
}
$userdm->pre_save();
if (count($userdm->errors) == 0)
{
$userdm->save();
return true;
}
else
{
var_dump($userdm->errors);
return false;
}
}
Why am I getting this error? In your answer could you please explain to me what needs to be changed.
query_read returns mysqli_result&, you need convert it to an array first.
$query_result = $vbulletin->db->query_read(...);
$product = $query_result->fetch_assoc();

php convert absolute URL containing relative paths in absolute url without relative path

I have a simple strange problem but I can not find a function to do this after many search.
I have an URL like http://example.com/folder/folder2/../image/test.jpg and I would like a function which return the correct absolute link:
http://example.com/folder/image/test.jpg
A function with only one param, the url (and not base dir or relative dir like in examples I found)
If you can help me, thanks.
Perhaps a starting point:
<?php
function unrelatify($url)
{
$parts = parse_url($url);
$path = $parts['path'] ?? '';
$hierarchy = explode('/', $path);
while(($key = array_search('..', $hierarchy)) !== false) {
if($key-1 > 0)
unset($hierarchy[$key-1]);
unset($hierarchy[$key]);
$hierarchy = array_values($hierarchy);
}
$new_path = implode('/', $hierarchy);
return str_replace($path, $new_path, $url);
}
echo unrelatify('http://example.com/../folder/../folder2/../image/test.jpg#foo?bar=baz');
Output:
http://example.com/image/test.jpg#foo?bar=baz
You may want to see how browsers and other web clients de-relativify (urls).
thanks to everyone for your answers.
here are a recap and some other ways i've tested
<?php
function unrelatify($url) {
$parts = parse_url($url);
$path = $parts['path'];
$hierarchy = explode('/', $path);
while (($key = array_search('..', $hierarchy)) !== false) {
if ($key - 1 > 0)
unset($hierarchy[$key - 1]);
unset($hierarchy[$key]);
$hierarchy = array_values($hierarchy);
}
$new_path = implode('/', $hierarchy);
return str_replace($path, $new_path, $url);
}
function normalizePath($path) {
do {
$path = preg_replace(
array('#//|/\./#', '#/([^/.]+)/\.\./#'), '/', $path, -1, $count
);
} while ($count > 0);
return str_replace('../', '', $path);
}
function processUrl($url) {
$parsedUrl = parse_url($url);
$path = $parsedUrl['path'];
$pathSegments = explode("/", $path);
$iterator = 0;
$removedElements = 0;
foreach ($pathSegments as $segment) {
if ($segment == "..") {
if ($iterator - $removedElements - 1 < 0) {
return false;
}
unset($pathSegments[$iterator - $removedElements - 1]);
unset($pathSegments[$iterator]);
$removedElements += 2;
}
$iterator++;
}
$parsedUrl['path'] = implode("/", $pathSegments);
$newUrl = $parsedUrl['scheme'] . '://' . $parsedUrl['host'] . "/" . $parsedUrl['path'];
return $newUrl;
}
function path_normalize($path) {
$path = str_replace('\\', '/', $path);
$blocks = preg_split('#/#', $path, null, PREG_SPLIT_NO_EMPTY);
$res = array();
while (list($k, $block) = each($blocks)) {
switch ($block) {
case '.':
if ($k == 0)
$res = explode('/', path_normalize(getcwd()));
break;
case '..';
if (!$res)
return false;
array_pop($res);
break;
default:
$res[] = $block;
break;
}
}
$r = implode('/', $res);
return $r;
}
echo 'path_normalize<br />';
$url = 'http://www.example.com/modules/newsletters/../../images/homeslider-images/test-5.jpg';
echo $url . ' === > ' . path_normalize($url);
echo '<hr />';
$url = 'http://www.example.com/../../images/homeslider-images/test-5.jpg';
echo $url . ' === > ' . path_normalize($url);
echo '<hr />normalizePath<br />';
$url = 'http://www.example.com/modules/newsletters/../../images/homeslider-images/test-5.jpg';
echo $url . ' === > ' . normalizePath($url);
echo '<hr />';
$url = 'http://www.example.com/../../images/homeslider-images/test-5.jpg';
echo $url . ' === > ' . normalizePath($url);
echo '<hr />unrelatify<br />';
$url = 'http://www.example.com/modules/newsletters/../../images/homeslider-images/test-5.jpg';
echo $url . ' === > ' . unrelatify($url);
echo '<hr />';
$url = 'http://www.example.com/../../images/homeslider-images/test-5.jpg';
echo $url . ' === > ' . unrelatify($url);
echo '<hr />processUrl<br />';
$url = 'http://www.example.com/modules/newsletters/../../images/homeslider-images/test-5.jpg';
echo $url . ' === > ' . processUrl($url);
echo '<hr />';
$url = 'http://www.example.com/../../images/homeslider-images/test-5.jpg';
echo $url . ' === > ' . processUrl($url);
?>

How do I separate and style hit counter digits with php methods?

I am using this PHP code to get and display the number of visitors to my site (hit counter).
Currently it is set up to display that number in a single block, i.e. - I would like to display each digit in its own html tag in order to style each number differently.
I have experimented with explode, and substr on the $allHits var, but am not getting good results.
Any Ideas?
<?
/*----------------------------
-------- ++ simPHP ++ --------
A simple PHP hit counter.
Description:
simPHP counts both regular and unique views on multiple
webpages. The stats can be displayed on any PHP-enabled
webpage. You MUST have read/write permissions on files.
Script by Ajay: ajay#scyberia.org
http://scyberia.org
----------------------------*/
/*----------CONFIG----------*/
// NOTE: If you change any config after using simphp,
// remove the old files.
// Relative URL of text file that holds hit info:
$lf_name = "hits.txt";
// Save new log file each month
// 0 = No
// 1 = Yes
$monthly = 1;
// Path to store old files:
// Default for June, 2012:
// oldfiles/6-12.txt
$monthly_path = "oldfiles";
// Count unique hits or all hits:
// 0 = All hits
// 1 = Unique hits
// 2 = Both
$type = 2;
// Text to display
// before all hits.
$beforeAllText = "Site Visitors: ";
// Before unique hits.
$beforeUniqueText = "Unique Visits: ";
// Display hits on this page:
// 0 = No
// 1 = Yes
$display = 1;
// Only change this if you are recording both values.
// Separator for unique and all hits display - use HTML tags! (line break is default)
$separator = "<br \>";
// Default would output:
// Visits: 10
// Unique Visits: 10
/*--------------------------*/
/*--------BEGIN CODE--------*/
$log_file = dirname(__FILE__) . '/' . $lf_name;
//Check for "?display=true" in URL.
if ($_GET['display'] == "true") {
//Show include() info.
die("<pre><? include(\"" . dirname(__FILE__) . '/' . basename(__FILE__) . "\"); ?></pre>");
} else {
//Visit or IP.
$uIP = $_SERVER['REMOTE_ADDR'];
//Check for "hits.txt" file.
if (file_exists($log_file)) {
//Check if today is first day of month
if (date('j') == 10) {
//Ensure that monthly dir exists
if (!file_exists($monthly_path)) {
mkdir($monthly_path);
}
//Check if prev month log file exists already
$prev_name = $monthly_path . '/' . date("n-Y", strtotime("-1 month"));
if (!file_exists($prev_name)) {
//If not, move/rename current file
copy($log_file, $prev_name);
//Create new $toWrite based on CONFIG
//Write file according to CONFIG above.
if ($type == 0) {
$toWrite = "1";
$info = $beforeAllText . "1";
} else if ($type == 1) {
$toWrite = "1;" . $uIP . ",";
$info = $beforeUniqueText . "1";
} else if ($type == 2) {
$toWrite = "1;1;" . $uIP . ",";
$info = $beforeAllText . "1" . $separator . $beforeUniqueText . "1";
}
goto write_logfile;
}
}
//Get contents of "hits.txt" file.
$log = file_get_contents($log_file);
//Get type from CONFIG above.
if ($type == 0) {
//Create info to write to log file and info to show.
$toWrite = intval($log) + 1;
$info = $beforeAllText . $toWrite;
} else if ($type == 1) {
//Separate log file into hits and IPs.
$hits = reset(explode(";", $log));
$IPs = end(explode(";", $log));
$IPArray = explode(",", $IPs);
//Check for visitor IP in list of IPs.
if (array_search($uIP, $IPArray, true) === false) {
//If doesnt' exist increase hits and include IP.
$hits = intval($hits) + 1;
$toWrite = $hits . ";" . $IPs . $uIP . ",";
} else {
//Otherwise nothing.
$toWrite = $log;
}
//Info to show.
$info = $beforeUniqueText . $hits;
} else if ($type == 2) {
//Position of separators.
$c1Pos = strpos($log, ";");
$c2Pos = strrpos($log, ";");
//Separate log file into regular hits, unique hits, and IPs.
$pieces = explode(";", $log);
$allHits = $pieces[0];
$uniqueHits = $pieces[1];
$IPs = $pieces[2];
$IPArray = explode(",", $IPs);
//Increase regular hits.
$allHits = intval($allHits) + 1;
//Search for visitor IP in list of IPs.
if (array_search($uIP, $IPArray, true) === false) {
//Increase ONLY unique hits and append IP.
$uniqueHits = intval($uniqueHits) + 1;
$toWrite = $allHits . ";" . $uniqueHits . ";" . $IPs . $uIP . ",";
} else {
//Else just include regular hits.
$toWrite = $allHits . ";" . $uniqueHits . ";" . $IPs;
}
//Info to show.
$info = $beforeAllText . $allHits . $separator . $beforeUniqueText . $uniqueHits;
}
} else {
//If "hits.txt" doesn't exist, create it.
$fp = fopen($log_file ,"w");
fclose($fp);
//Write file according to CONFIG above.
if ($type == 0) {
$toWrite = "1";
$info = $beforeAllText . "1";
} else if ($type == 1) {
$toWrite = "1;" . $uIP . ",";
$info = $beforeUniqueText . "1";
} else if ($type == 2) {
$toWrite = "1;1;" . $uIP . ",";
$info = $beforeAllText . "1" . $separator . $beforeUniqueText . "1";
}
}
write_logfile:
//Put $toWrite in log file
file_put_contents($log_file, $toWrite);
//Display info if is set in CONFIG.
if ($display == 1) {
}
}
Would using a foreach loop work, like this:
$array_allHits = explode(" ",$allHits);
foreach ($array_allHits as $display_digits) {
echo $display_digits[0];
}
You could use a for-loop.
for ($i = 0; $i < strlen((string) $allHits); $i++) {
echo '<span>' . $allHits[$i] . '</span>';
}
The above code will output <span>{number}</span> for every digit in the hit count.
It will loop through every character in the string, similar as to how array indexes are treated.
$totalHits = 125655;
foreach(str_split((string)$totalHits) as $key => $val) {
echo "<span class='position_{$key}'>{$val}</span>";
}
Add styles in you css as below:
.position_0 {
color: red;
}
.position_1 {
color: blue;
}
.position_2 {
color: yellow;
}

Change php script with variables from working in http to working in shell

I use a script from here to generate my sitemaps.
I can call it with the browser with http://www.example.com/sitemap.php?update=pages and its working fine.
I need to call it as shell script so that I can automate it with the windows task scheduler. But the script needs to be changed to get the variables ?update=pages. But I don't manage to change it correctly.
Could anybody help me so that I can execute the script from command line with
...\php C:\path\to\script\sitemap.php update=pages. It would also be fine for me to hardcode the variables into the script since I wont change them anyway.
define("BASE_URL", "http://www.example.com/");
define ('BASE_URI', $_SERVER['DOCUMENT_ROOT'] . '/');
class Sitemap {
private $compress;
private $page = 'index';
private $index = 1;
private $count = 1;
private $urls = array();
public function __construct ($compress=true) {
ini_set('memory_limit', '75M'); // 50M required per tests
$this->compress = ($compress) ? '.gz' : '';
}
public function page ($name) {
$this->save();
$this->page = $name;
$this->index = 1;
}
public function url ($url, $lastmod='', $changefreq='', $priority='') {
$url = htmlspecialchars(BASE_URL . 'xx' . $url);
$lastmod = (!empty($lastmod)) ? date('Y-m-d', strtotime($lastmod)) : false;
$changefreq = (!empty($changefreq) && in_array(strtolower($changefreq), array('always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'))) ? strtolower($changefreq) : false;
$priority = (!empty($priority) && is_numeric($priority) && abs($priority) <= 1) ? round(abs($priority), 1) : false;
if (!$lastmod && !$changefreq && !$priority) {
$this->urls[] = $url;
} else {
$url = array('loc'=>$url);
if ($lastmod !== false) $url['lastmod'] = $lastmod;
if ($changefreq !== false) $url['changefreq'] = $changefreq;
if ($priority !== false) $url['priority'] = ($priority < 1) ? $priority : '1.0';
$this->urls[] = $url;
}
if ($this->count == 50000) {
$this->save();
} else {
$this->count++;
}
}
public function close() {
$this->save();
}
private function save () {
if (empty($this->urls)) return;
$file = "sitemaps/xx-sitemap-{$this->page}-{$this->index}.xml{$this->compress}";
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
foreach ($this->urls as $url) {
$xml .= ' <url>' . "\n";
if (is_array($url)) {
foreach ($url as $key => $value) $xml .= " <{$key}>{$value}</{$key}>\n";
} else {
$xml .= " <loc>{$url}</loc>\n";
}
$xml .= ' </url>' . "\n";
}
$xml .= '</urlset>' . "\n";
$this->urls = array();
if (!empty($this->compress)) $xml = gzencode($xml, 9);
$fp = fopen(BASE_URI . $file, 'wb');
fwrite($fp, $xml);
fclose($fp);
$this->index++;
$this->count = 1;
$num = $this->index; // should have already been incremented
while (file_exists(BASE_URI . "xxb-sitemap-{$this->page}-{$num}.xml{$this->compress}")) {
unlink(BASE_URI . "xxc-sitemap-{$this->page}-{$num}.xml{$this->compress}");
$num++;
}
$this->index($file);
}
private function index ($file) {
$sitemaps = array();
$index = "sitemaps/xx-sitemap-index.xml{$this->compress}";
if (file_exists(BASE_URI . $index)) {
$xml = (!empty($this->compress)) ? gzfile(BASE_URI . $index) : file(BASE_URI . $index);
$tags = $this->xml_tag(implode('', $xml), array('sitemap'));
foreach ($tags as $xml) {
$loc = str_replace(BASE_URL, '', $this->xml_tag($xml, 'loc'));
$lastmod = $this->xml_tag($xml, 'lastmod');
$lastmod = ($lastmod) ? date('Y-m-d', strtotime($lastmod)) : date('Y-m-d');
if (file_exists(BASE_URI . $loc)) $sitemaps[$loc] = $lastmod;
}
}
$sitemaps[$file] = date('Y-m-d');
$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$xml .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
foreach ($sitemaps as $loc => $lastmod) {
$xml .= ' <sitemap>' . "\n";
$xml .= ' <loc>' . BASE_URL . $loc . '</loc>' . "\n";
$xml .= ' <lastmod>' . $lastmod . '</lastmod>' . "\n";
$xml .= ' </sitemap>' . "\n";
}
$xml .= '</sitemapindex>' . "\n";
if (!empty($this->compress)) $xml = gzencode($xml, 9);
$fp = fopen(BASE_URI . $index, 'wb');
fwrite($fp, $xml);
fclose($fp);
}
private function xml_tag ($xml, $tag, &$end='') {
if (is_array($tag)) {
$tags = array();
while ($value = $this->xml_tag($xml, $tag[0], $end)) {
$tags[] = $value;
$xml = substr($xml, $end);
}
return $tags;
}
$pos = strpos($xml, "<{$tag}>");
if ($pos === false) return false;
$start = strpos($xml, '>', $pos) + 1;
$length = strpos($xml, "</{$tag}>", $start) - $start;
$end = strpos($xml, '>', $start + $length) + 1;
return ($end !== false) ? substr($xml, $start, $length) : false;
}
public function __destruct () {
$this->save();
}
}
// start part 2
$sitemap = new Sitemap;
if (get('pages')) {
$sitemap->page('pages');
$result = mysql_query("SELECT uri FROM app_uri");
while (list($url, $created) = mysql_fetch_row($result)) {
$sitemap->url($url, $created, 'monthly');
}
}
$sitemap->close();
unset ($sitemap);
function get ($name) {
return (isset($_GET['update']) && strpos($_GET['update'], $name) !== false) ? true : false;
}
?>
I could install wget (it's available for windows as well) and then call the url via localhost in the task scheduler script:
wget.exe "http://localhost/path/to/script.php?pages=test"
This way you wouldn't have to rewrite the php script.
Otherwise, if the script is meant for shell usage only, then pass variables via command line:
php yourscript.php variable1 variable2 ...
In the php script you can than access those variables using the $argv variable:
$variable1 = $argv[1];
$variable2 = $argv[2];
have a look on:
How to pass GET variables to php file with Shell?
which already answered the same question :).

Categories