/** * detects the script which should be used to * generate content from an xml file and execute it. */ function generateContentFromXml($xmlParser) { if ($xmlParser->match("/content[1]/script[1]")) { $script = $xmlParser->getData("/content[1]/script[1]"); include "scripts/{$script}.php"; return generateOutput($xmlParser); } else { return "Don't know what script to use for generating output!"; } }
for ($i = 1; $i <= $numberOfChannels; $i++) { $attributeName = 'field' . $i; $resultRow = array(); $resultRow['field'] = ucfirst($attributeName); $resultRow['channelName'] = $responseObject->channel->{$attributeName}; $resultRow['channeValue'] = $arrayObject[$attributeName]; $results[$i] = $resultRow; } //hide some fields $columnsToHide = array(); if (null !== $opts->getOption('i')) { $columnsToHide[] = 'field'; } if (null !== $opts->getOption('n')) { $columnsToHide[] = 'channelName'; } //show only a certain field $fieldId = $opts->getOption('f'); if (null !== $fieldId) { if (false === array_key_exists($fieldId, $results)) { exit(sprintf('Field with id %s does not exist' . PHP_EOL, $fieldId)); } $results = array($results[$fieldId]); } //Output the headline if (null === $opts->getOption('t')) { echo $channelName . ' ' . $dateIntervalsInSeconds . ' ago ' . PHP_EOL; } //Output the rest echo generateOutput($results, $columnsToHide);
function getUserData($userID) { global $response; global $moodooKey; $response['log'] .= 'getUserData running |'; $moodDataQuery = "SELECT ID, CONVERT(AES_DECRYPT(socialID, SHA1('" . $moodooKey . "')) USING UTF8) AS socialID, CONVERT(AES_DECRYPT(mood, SHA1('" . $moodooKey . "')) USING UTF8) AS mood, CONVERT(AES_DECRYPT(lat, SHA1('" . $moodooKey . "')) USING UTF8) AS lat, CONVERT(AES_DECRYPT(lng, SHA1('" . $moodooKey . "')) USING UTF8) AS lng, time, CONVERT(AES_DECRYPT(status, SHA1('" . $moodooKey . "')) USING UTF8) AS status, code FROM `moodoo2`.`updates` WHERE userID='" . $userID . "' ORDER BY time ASC"; //$response['log'].="moodDataQuery= ".$moodDataQuery.' |'; $moodDataResult = mysql_query($moodDataQuery); if ($moodDataResult) { $noOfUpdates = mysql_num_rows($moodDataResult); $response['log'] .= 'moodDataQuery executed, no of mood updates=' . $noOfUpdates . ' |'; if ($noOfUpdates > 0) { $response['log'] .= 'got more than one mood update, adding values to response |'; //////////CODE ADDED FROM ORIGINAL MOODOO SCRIPT $j = 0; while ($row = mysql_fetch_assoc($moodDataResult)) { $response['updates'][$j]['updateID'] = $row['ID']; $response['updates'][$j]['mood'] = $row['mood']; $response['updates'][$j]['lat'] = $row['lat']; $response['updates'][$j]['lng'] = $row['lng']; $response['updates'][$j]['time'] = $row['time']; $response['updates'][$j]['seconds'] = strtotime($row['time']); $response['updates'][$j]['status'] = $row['status']; $response['updates'][$j]['code'] = $row['code']; $j++; } if ($noOfUpdates > 0) { $latestUpdateTime = $response['updates'][$totalRows - 1]['time']; } else { $latestUpdateTime = null; } $monthstring = 'month'; $weekstring = 'week'; $daystring = 'day'; $hourstring = 'hour'; $minutestring = 'minute'; if ($latestUpdateTime != null) { $difference = time() - strtotime($latestUpdateTime); //difference in seconds between the last update and now $months = floor($difference / 2592000); // approx 1814400 seconds in an average 30 day month $weeks = floor($difference % 2592000 / 604800); //get remainder after finding months, divide those seconds by no of seconds in a week (604800) $days = floor($difference % 2592000 % 604800 / 86400); //etc $hours = floor($difference % 2592000 % 604800 % 86400 / 3600); //etc $minutes = floor($difference % 2592000 % 604800 % 86400 % 3600 / 60); // etc if ($months > 1) { $monthstring .= 's'; } if ($weeks > 1) { $weekstring .= 's'; } if ($days > 1) { $daystring .= 's'; } if ($hours > 1) { $hourstring .= 's'; } if ($minutes > 1) { $minutestring .= 's'; } if ($months > 0) { $timeSinceLastUpdate .= $months . ' ' . $monthstring . ', '; } if ($weeks > 0) { $timeSinceLastUpdate .= $weeks . ' ' . $weekstring . ', '; } if ($days > 0) { $timeSinceLastUpdate .= $days . ' ' . $daystring . ', '; } if ($hours > 0) { $timeSinceLastUpdate .= $hours . ' ' . $hourstring . ' and '; } if ($minutes > 0) { $timeSinceLastUpdate .= $minutes . ' ' . $minutestring; } if ($difference < 60) { if ($difference == 1) { $timeSinceLastUpdate = '1 second'; } else { $timeSinceLastUpdate = $difference . ' seconds'; } } if ($months > 6) { $timeSinceLastUpdate = 'more than six months'; } } else { $timeSinceLastUpdate = null; } $response['timeSinceLastUpdate'] = $timeSinceLastUpdate; $response['secondsSinceLastUpdate'] = $difference; //////////END ORIGINAL CODE } generateOutput(); } else { $response['log'] .= 'get mood data query threw an error. |'; $response['error'] .= 'error at mood data query execution!'; generateOutput(); } }
$from = $contactFirstName . ' via Moodoo Contact Form <' . $returnEmail . '>'; $to = 'Moodoo Contact Officer <*****@*****.**>'; $formSubject = filter_var($_POST['subject'], FILTER_SANITIZE_STRING); //$formSubject='Test subject from script'; $subject = 'New contact form message from moodoo.net: "' . $formSubject . '"'; $message = $_POST['contactMessage']; //filter_var($_POST['contactMessage'], FILTER_SANITIZE_STRING); $html = '<html><head/><body><p>Hello Contact Officer! ' . $contactFirstName . ' has sent the following message via the Moodoo contact form: </p><p>' . $message . '</p></body></html>'; //$text='Test text from script'; # Make the call to the client. $result = $mgClient->sendMessage("{$domain}", array('from' => $from, 'to' => $to, 'subject' => $subject, 'html' => $html)); //$result = $mgClient->get("$domain/log", array('limit' => 25, // 'skip' => 0)); $httpResponseCode = $result->http_response_code; $httpResponseBody = $result->http_response_body; # Iterate through the results and echo the message IDs. $logItems = $result->http_response_body->items; foreach ($logItems as $logItem) { $response['log'] .= "|" . $logItem->message_id . "|"; } function generateOutput() { global $response; //generate json formatted response for client-side javascript use $response['log'] .= 'encoding json|'; $print = json_encode($response); echo $print; } generateOutput(); ?>
if (!$trimmedLine || $trimmedLine == ']') { break; } $logSection .= $line; } fclose($f); // parse the log section $logSection = str_replace("\r", '', $logSection); $arrayPos = strpos($logSection, 'Array'); $curlPos = strpos($logSection, 'curl: '); if ($arrayPos !== false) { $logSection = substr($logSection, $arrayPos); $parsedParams = print_r_reverse($logSection); if (!is_array($parsedParams)) { echo 'Error: failed to parse action parameters'; exit(1); } } else { if ($curlPos !== false) { $logSection = substr($logSection, $curlPos); $parsedUrl = parse_url(trim($logSection)); $parsedParams = null; parse_str($parsedUrl['query'], $parsedParams); } else { echo 'Error: failed to parse log section (missing "Array")'; exit(1); } } // output the result generateOutput($parsedParams, $multireqMode);