function set_skin($username, $password, $skin) { $login_url = "https://minecraft.net/login"; $skin_url = "https://minecraft.net/profile/skin"; //first, login to Minecraft.net $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $login_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null"); curl_setopt($ch, CURLOPT_HEADER, true); $fields = array("username" => urlencode($username), "password" => urlencode($password)); post($ch, $fields); curl_exec($ch); //Then, load the profile page to retrieve authenticityToken curl_setopt($ch, CURLOPT_URL, $skin_url); $result = curl_exec($ch); $token = get_string_between($result, 'name="authenticityToken" value="', '">'); //finally, post the skin update $headers = array("Content-Type:multipart/form-data"); // cURL headers for file uploading $fields = array("model" => "steve", "skin" => "@{$skin}", "authenticityToken" => $token); $options = array(CURLOPT_URL => $skin_url, CURLOPT_HEADER => true, CURLOPT_POST => 1, CURLOPT_HTTPHEADER => $headers, CURLOPT_POSTFIELDS => $fields, CURLOPT_RETURNTRANSFER => true); // cURL options curl_setopt_array($ch, $options); $result = urldecode(curl_exec($ch)); curl_close($ch); if (strlen(strstr($result, "success=Your skin has been changed! It will take a couple of seconds for it to update.")) > 0) { return true; } else { return false; } }
function getCurrentGameWeekFromDOM($DOMDoc) { $finder = new DomXPath($DOMDoc); $classname = "ismH2HStandingsTable"; $gameWeeks = $finder->query("//*[contains(@class, '{$classname}')]/tbody/tr/td/a"); return get_string_between($gameWeeks->item(1)->getAttribute('href'), '/event-history/', '/'); }
function parse($txt) { $err = true; //$str = strip_tags($txt); $str = preg_replace('/\\s\\s+/', ' ', $txt); $str = trim($str); $data_size = substr_count($txt, '<tr'); $w = explode("<tr", $txt); $j = 0; for ($i = 2; $i <= $data_size; $i++) { $pos1 = strpos($w[$i], '>') + 1; $pos2 = strlen($w[$i]); $dif = $pos2 - $pos1; $txt2 = substr($w[$i], $pos1, $dif); $v = explode("</td>", $txt2); $ticker_link = get_string_between($v[1], ">", "</td>"); $ticker = get_string_between($ticker_link, "name=", "'"); $array[$j][0] = $ticker; for ($k = 1; $k < 9; $k++) { $p1 = strpos($v[$k + 1], ">"); $var = trim(substr($v[$k + 1], $p1 + 1, strlen($v[$k + 1]) - $p1)); if ($var != 'n/a' && $var != '') { $array[$j][$k] = $var; } else { $array[$j][$k] = 0; } } $j++; } return $array; }
function errorCheck() { //check for error global $return, $data_contact, $url_curl, $userpwd, $content, $to_error, $headers, $modify, $url_contacts, $entityID; $status = 'default'; $status = get_string_between($return, 'status":"', '"'); $errorMessage = get_string_between($return, 'message":"', '"'); if ($status !== "ok") { if (begins_with($errorMessage, "A duplicate record has been found")) { $modify = 'True'; //if contacts table if ($url_curl == $url_contacts) { $entityID = filter_var($errorMessage, FILTER_SANITIZE_NUMBER_INT); } $url_curl = $url_curl . '/' . $entityID; sendData(); } else { //set email variables $subject = 'Error: Hobson Radius Form'; $message = 'There has been an error on the Hobson Radious Form Submission Status: ' . $status . ' ***Modify: ' . $modify . ' ***Error: ' . $errorMessage . ' ***url:' . $url_curl . ' ***entityID:' . $entityID . ' ***error return:' . $return . ' data send:' . print_r($data_contact, true); //send email mail($to_error, $subject, $message, $headers); } } }
/** * Adds if statement logic to change output based on if statement. * * * @param mixed &$parsed * @return void */ function cond(&$parsed) { global $cssp, $browser; foreach ($parsed as $block => $css) { foreach ($parsed[$block] as $selector => $styles) { foreach ($styles as $property => $values) { if (strpos($values[0], 'cond(') !== false) { /** * Clean up variable names and Formatting. */ $condition = get_string_between($values[0], "cond(", ")"); $ifParams = explode("?", $condition); $ifResults = explode(":", $ifParams[1]); $ifCond = explode(" ", $ifParams[0]); $ifCond[0] = interp($ifCond[0]); //Convert PHP string to Values $ifCond[2] = interp($ifCond[2]); //Convert PHP string to Values $test = compare($ifCond[0], $ifCond[1], $ifCond[2]); $parsed[$block][$selector][$property] = ''; //Remove existing Cond Statement if ($test) { $parsed[$block][$selector][$property][] = $ifResults[0]; //Place True Value } else { $parsed[$block][$selector][$property][] = $ifResults[1]; //Place False Value } } } } } }
function js_compile($file, $js_replace) { $filedata = file_get_contents($file); //load file $js_includes = get_string_between($filedata, "<!--JS Compile Start-->", "<!--JS Compile Stop-->"); $script_array = js_include_parse($js_includes); return concatenate_js($script_array, dirname($file), $js_replace); }
function css_compile($file) { $filedata = file_get_contents($file); //load file $css_includes = get_string_between($filedata, "<!--CSS Compile Start-->", "<!--CSS Compile Stop-->"); $styles_array = css_include_parse($css_includes); return concatenate_css($styles_array, dirname($file)); }
function update_versions() { $jdata = json_decode(get_string_between(file_get_contents("../../../js/version.js"), "/*START*/", "/*STOP*/"), true); $jdata["build"]++; $jdata["date"] = microtime(true); $json_enc = json_encode($jdata); $json_version = "/*Auto-Generated Ajax Animator Version config (Markup Version II)*/\n/*Generated By versions.php in /server/dev/compile/*/\nAx.set_version( /*START*/\n{$json_enc}\n/*STOP*/ )\n/*End Of File*/\n"; file_put_contents("../../../js/version.js", $json_version); return $jdata["release"] . ".build" + $jdata["build"]; }
function __construct($config_path){ // extract the config name with some string magic get string between / and .php // check if only file name was provided $start = (!strpos($config_path,'/')?'':'/'); $this->config_name = get_string_between($config_path,$start,'.php'); $this->e_file = $config_path; $this->html = self::get_config(); // we're using a post variable. Obviously if you didn't want to use this class you can write your own config files $this->html .=($_POST && $_POST['Update']?self::writeConfig():NULL); // I refresh it to avoid invalid form updates conflicts inside the object if($_POST && $_POST['Update']) self::reload_form(5); }
function gen_html($input) { while (strpos($input, "<!--Remove Start-->") !== false) { $input = str_replace("<!--Remove Start-->" . get_string_between($input, "<!--Remove Start-->", "<!--Remove Stop-->") . "<!--Remove Stop-->", "", $input); } $input = str_replace("<!--Start Compile Include>", "", $input); $input = str_replace("<End Compile Include-->", "", $input); $input = str_replace("<!--COMPILIER INFO-->", "<!--" . file_get_contents("compilierinfo.txt") . "-->", $input); $input = sanitize_output($input); $input = str_replace("<!--ADS-->", file_get_contents("ads.txt"), $input); return $input; }
/** * finishValidation method * @return array * */ protected function finishValidation() { foreach ($this->fields as $field) { for ($i = 0; $i < sizeof($field['rules']); $i++) { $args = array(); $args[] = isset($_REQUEST[$field['name']]) ? $_REQUEST[$field['name']] : null; if (strpos($field['rules'][$i], '[') !== FALSE) { $cleanString = get_string_between($field['rules'][$i]); $arg = str_replace('[', '', str_replace(']', '', $cleanString)); $rule = str_replace($cleanString, '', $field['rules'][$i]); switch ($rule) { case "matchWith": $args[] = isset($_REQUEST[$arg]) ? $_REQUEST[$arg] : null; break; case "between": $betweenParts = explode(',', $arg); if (isset($betweenParts[0])) { if (preg_match('/^[0-9]*$/', $betweenParts[0])) { $args[] = $betweenParts[0]; } else { exit('between first argument must be integer'); } if (isset($betweenParts[1])) { if (preg_match('/^[0-9]*$/', $betweenParts[1])) { $args[] = $betweenParts[1]; } else { exit('between second argument must be integer'); } } else { exit('between second argument is required'); } } else { exit('between first argument is required'); } break; } $args[] = $arg; } else { $rule = $field['rules'][$i]; } $key = str_replace('[', '', str_replace(']', '', $rule)); if (!call_user_func_array($this->getValidationTypes()[$key], $args)) { $this->error[$field['label']] = $key; } } } $this->status = sizeof($this->getError()) > 0 ? 'error' : 'success'; }
function getEmailfromWeb($websiteurl) { $strarr = array('', 'contact.html', 'contact.htm', 'contact.php', 'contact', 'contactus.html', 'contactus.htm', 'contactus.php', 'contactus', 'contact_us.html', 'contact_us.htm', 'contact_us.php', 'contact_us', 'contact-us.html', 'contact-us.htm', 'contact-us.php', 'contact-us', 'about.html', 'about.htm', 'about.php', 'about', 'aboutus.html', 'aboutus.htm', 'aboutus.php', 'aboutus', 'about_us.html', 'about_us.htm', 'about_us.php', 'about_us', 'about-us.html', 'about-us.htm', 'about-us.php', 'about-us', 'feedback.html', 'feedback.htm', 'feedback.php', 'feedback'); foreach ($strarr as $str) { $url = $websiteurl . '/' . $str; $url = str_replace('//' . $str, '/' . $str, $url); $content = get_data($url); if ($content == '') { // $content = @file_get_contents($url); } if ($content != '') { //$emails = extract_emails_from($content); $emails = extract_email_address($content); if (count($emails) > 0) { $emails = array_unique($emails); return $emails; } $emails = extract_emails_from($content); if (count($emails) > 0) { $emails = array_unique($emails); return $emails; } if (strpos($content, 'mailto:') !== false) { $content = html_entity_decode($content); $emails = array(); $email_temp = get_string_between($content, 'mailto:', '>'); $emails[0] = explode(' ', $email_temp); if (count($emails) > 0 && $emails[0] != '') { return $emails; } } $emails = extract_emails_from($content); if (count($emails) > 0) { $emails = array_unique($emails); return $emails; } } else { echo $url . " Content could not be fetched.<br />"; } //sleep(rand(5,10)); } return ''; }
function errorCheck() { /*check for error Hobson returns a string after form submission. We need to parse the string to determine the error. */ global $return, $data_contact, $url_curl, $userpwd, $content, $to_error, $headers, $modify, $url_contacts, $entityID; $status = 'default'; $status = get_string_between($return, 'status":"', '"'); $errorMessage = get_string_between($return, 'message":"', '"'); //if we are ok, then there is not error and we can move on. if ($status !== "ok") { if (begins_with($errorMessage, "A duplicate record has been found")) { //The record already exists in the database, prepare to resubmit using the Modify/Put Method. $modify = 'True'; //if contacts table if ($url_curl == $url_contacts) { $entityID = filter_var($errorMessage, FILTER_SANITIZE_NUMBER_INT); } $url_curl = $url_curl . '/' . $entityID; sendData(); } else { //prepare variables for email $subject = 'Error: Hobson Radius Form'; $message = 'There has been an error on the Hobson Radious Form Submission Status: ' . $status . ' ***Modify: ' . $modify . ' ***Error: ' . $errorMessage . ' ***url:' . $url_curl . ' ***entityID:' . $entityID . ' ***error return:' . $return . ' data send:' . print_r($data_contact, true); //send email mail($to_error, $subject, $message, $headers); } } //send email mail($to_error, $subject, $message, $headers); }
function getDetails($plugin) { if ($this->request->is('ajax')) { $this->disableCache(); $this->autoRender = false; $api = json_decode(file_get_contents("http://api.bukget.org/api2/bukkit/plugin/" . $plugin), TRUE); //debug($api); //Function to get strings function get_string_between($string, $start, $end) { $string = " " . $string; $ini = strpos($string, $start); if ($ini == 0) { return ""; } $ini += strlen($start); $len = strpos($string, $end, $ini) - $ini; return substr($string, $ini, $len); } $status = $api['stage']; $categories = implode(', ', $api['categories']); $authors = implode(', ', $api['authors']); $desc = $api['description']; $data = file_get_contents($api['link']); $img = get_string_between($data, 'data-full-src="', '"'); echo <<<END <ul> <li> <b>Status</b> <p>{$status}</p> </li> <li> <b>Categories</b> <p>{$categories}</p> </li> <li> <b>Authors</b> <p>{$authors}</p> </li> <li> <b>Description</b> <p> <img src="{$img}" width="250px" /> {$desc} </p> </li> </ul>' END; } }
} //on ecrit les données dans le fichier json trace System_Daemon::info("Initialisation du fichier knxtrace.json"); makeJsonTrace($sniffed); /* Mise a jour du ficheir knxtrace.json a chaque modification d'un equipement suivi */ System_Daemon::info("Mise a jour du fichier knxtrace.json a chaque modification d'un equipement suivi et sauvegarde en base s'il doit etre historisé"); //$lastpos = 0; while (true) { // On tail le fichier de log $knxlisten = tail(PATH_LOG, $lastpos); // On r�agit d�s qu'on a un Write // Pour chaque ligne, on r�cup�re le Groupe d'Addresse et de la valeur qu'on converti $groupaddr = get_string_between($knxlisten, 'group addr: ', ' -'); $hexa = get_string_between($knxlisten, 'Hexa: ', ' -'); //on met a jour le valeur dans le tableau et on regenere le fichier json //recursive_array_search if (array_key_exists($groupaddr, $sniffed)) { $decimal = hexdec($hexa); $value = dptSelectDecode($sniffed[$groupaddr]['dpt'], $decimal); //ecriture en base si changement d'etat et bas simplement l'equipement qui redis la meme chose sur le bus //System_Daemon::notice("Old Value -> ".$groupaddr.":: ".$oldSniffedValue[$groupaddr]); //System_Daemon::notice("New Value -> ".$groupaddr.":: ".$value); if ($oldSniffedValue[$groupaddr] != $value) { //System_Daemon::notice("MAJ"); $sniffed[$groupaddr]['value'] = $value; makeJsonTrace($sniffed); //System_Daemon::notice("TRACKED::".$sniffed[$groupaddr]['is_track']); if ($sniffed[$groupaddr]['is_track'] == 1) { //Inseetion en base de données car l'eqt is_track=true
private function generateObjectProgram() { global $OUTPUT_LOG_PREFIX; $OPTB_WOC_OP = array(); $headerContent = ''; $defineContent = ''; $referContent = ''; $textContent = ''; $modificationContent = ''; $endContent = ''; $textRecordMaxLen = hexdec('1E'); $textRecord = ''; $TstartinggAdd = ''; $Tlength = 0; // max = 1E $Ttemp = ''; $perviouBlock = 0; if (max(array_column($this->OPTB_WOC, 'SECTION')) == 0) { if (max(array_column($this->OPTB_WOC, 'BLOCK')) > 0) { $moreThanOneBlock = true; $loc = array(); $block = array(); foreach ($this->OPTB_WOC as $key => $row) { $loc[$key] = $row['LOC']; $block[$key] = $row['BLOCK']; } array_multisort(array_keys($this->OPTB_WOC), SORT_ASC, $this->OPTB_WOC); } foreach ($this->OPTB_WOC as $_OPTB_WOC) { // testing... // if(!isset($_OPTB_WOC['ELOC']) || empty($_OPTB_WOC['ELOC'])) continue; // testing state not sure.. // if(!isset($_OPTB_WOC['SIZE']) || empty($_OPTB_WOC['SIZE'])) continue; if (isset($_OPTB_WOC['realLOC']) || !empty($_OPTB_WOC['realLOC'])) { $_OPTB_WOC['LOC'] = $_OPTB_WOC['realLOC']; } if (!isset($_OPTB_WOC['BLOCK']) || empty($_OPTB_WOC['BLOCK'])) { // no change } else { $perviouBlock = $_OPTB_WOC['BLOCK']; } if (!isset($_OPTB_WOC['LOC']) || empty($_OPTB_WOC['LOC'])) { continue; } else { $perviouBlock = $_OPTB_WOC['BLOCK']; } if ($_OPTB_WOC['LINE'] == 5) { $programName = $_OPTB_WOC['LABEL']; $_OPTB_WOC['recordType'] = 'E'; $startingAddress = sprintf("%06X", hexdec($_OPTB_WOC['OPERAND'])); } else { if (!empty($_OPTB_WOC['OBJECTCODE'])) { $_OPTB_WOC['recordType'] = 'T'; if ($Tlength == 0) { $TstartinggAdd = '00' . $_OPTB_WOC['LOC']; $Tlength = $_OPTB_WOC['SIZE']; $Ttemp = $_OPTB_WOC['OBJECTCODE'] . '^'; // $Ttemp = sprintf("%06X", hexdec($_OPTB_WOC['OBJECTCODE'])) . '^' ; $writed = false; //echo $Ttemp . "\n"; } else { if (isset($_OPTB_WOC['ELOC']) && isset($_OPTB_WOC['LOC'])) { if ($Tlength + hexdec($_OPTB_WOC['ELOC']) - hexdec($_OPTB_WOC['LOC']) <= $textRecordMaxLen && $_OPTB_WOC['BLOCK'] == $perviouBlock) { $Tlength += $_OPTB_WOC['SIZE']; $Ttemp .= $_OPTB_WOC['OBJECTCODE'] . '^'; // $Ttemp .= sprintf("%06X", hexdec($_OPTB_WOC['OBJECTCODE'])) . '^' ; $writed = false; //echo $Ttemp . "\n"; } else { $textContent .= 'T' . '^' . $TstartinggAdd . '^' . sprintf("%02X", $Tlength) . '^' . substr($Ttemp, 0, -1) . "\r\n"; $Tlength = 0; $TstartinggAdd = '00' . $_OPTB_WOC['LOC']; $Tlength = $_OPTB_WOC['SIZE']; $Ttemp = $_OPTB_WOC['OBJECTCODE'] . '^'; // $Ttemp = sprintf("%06X", hexdec($_OPTB_WOC['OBJECTCODE'])) . '^' ; $writed = true; } } } } else { if (!$writed) { $textContent .= 'T' . '^' . $TstartinggAdd . '^' . sprintf("%02X", $Tlength) . '^' . substr($Ttemp, 0, -1) . "\r\n"; $Tlength = 0; $TstartinggAdd = '00' . $_OPTB_WOC['LOC']; $Ttemp = $_OPTB_WOC['OBJECTCODE']; // $Ttemp = sprintf("%06X", hexdec($_OPTB_WOC['OBJECTCODE'])) . '^' ; $writed = true; } $_OPTB_WOC['recordType'] = 'SKIP'; } } if ($_OPTB_WOC['OPCODE'][0] == '+' && in_array($_OPTB_WOC['OPERAND'], array('RDREC', 'WRREC'))) { $_OPTB_WOC['recordType'] = 'M'; $modificationContent .= 'M' . '^' . sprintf("%06X", hexdec($_OPTB_WOC['LOC']) + 1) . '^' . '05' . "\r\n"; } //var_dump($Tlength); array_push($OPTB_WOC_OP, $_OPTB_WOC); } $textContent .= 'T' . '^' . $TstartinggAdd . '^' . sprintf("%02X", $Tlength) . '^' . substr($Ttemp, 0, -1) . "\r\n"; $Tlength = 0; $TstartinggAdd = '00' . $_OPTB_WOC['LOC']; $Ttemp = $_OPTB_WOC['OBJECTCODE']; // $Ttemp = sprintf("%06X", hexdec($_OPTB_WOC['OBJECTCODE'])) . '^' ; $writed = true; // first if scope fix bug-_- . don't modify dont ask dont touch if (max(array_column($this->OPTB_WOC, 'BLOCK')) > 0) { $endingAddress1 = max(array_column($this->OPTB_WOC, 'ELOC')); $endingAddress2 = max(array_column($this->OPTB_WOC, 'realLOC')); $endingAddress = $endingAddress1 > $endingAddress2 ? $endingAddress1 : $endingAddress2; } else { $endingAddress = 0; // initial only .. just bullshit.. foreach (array_reverse(array_column($this->OPTB_WOC, 'ELOC')) as $lastELOC) { if (!empty($lastELOC)) { echo "lastELOC : " . $lastELOC . "\r\n"; $endingAddress = $lastELOC; break; } } } $programLength = hexdec($endingAddress) - hexdec($startingAddress); if (empty($programName)) { $programName = 'COPY'; } $programLength = sprintf("%06X", $programLength); $headerContent = 'H' . sprintf('%-6s', $programName) . '^' . $startingAddress . '^' . $programLength; $endContent = $startingAddress; $headerRecord = $headerContent . "\r\n"; $defineRecord = $defineContent . "\r\n"; $referRecord = $referContent . "\r\n"; $textTrecord = $textContent; // contain new line dont worry $modificationRecord = $modificationContent; // contain new line dont worry $endRecord = 'E' . '^' . $endContent . "\r\n"; if (empty($headerContent)) { $headerRecord = ''; } if (empty($defineContent)) { $defineRecord = ''; } if (empty($referContent)) { $referRecord = ''; } if (empty($textContent)) { $textTrecord = ''; } if (empty($modificationContent)) { $modificationRecord = ''; } // fix lastline T^00001D^00^ problem .. delete it $fixTextTrecord = explode("\r\n", $textTrecord); //print_r($fixTextTrecord); end($fixTextTrecord); $tRecordLastIndex = key($fixTextTrecord); if (empty($fixTextTrecord[$tRecordLastIndex])) { $tRecordLastIndex = $tRecordLastIndex - 1; } if (substr($fixTextTrecord[$tRecordLastIndex], -4) == '^00^') { unset($fixTextTrecord[$tRecordLastIndex]); } $textTrecord = implode("\r\n", $fixTextTrecord); $this->objectProgramContent = $headerRecord . $defineRecord . $referRecord . $textTrecord . $modificationRecord . $endRecord; echo $this->objectProgramContent; } else { $objectProgram = array(); $countSize = 0; $tLine = 0; $previousSection = 'no_value'; $index = 0; $modificationArr = array(); $modificationSortedArr = array(); $storageTypeArr = array('RESW', 'RESB', 'BYTE', 'WORD'); print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'fuckmeOPTB.html', $this->OPTB_WOC); $startLoc = sprintf("%04X", hexdec(array_search_value($this->OPTB_WOC, 'OPCODE', 'START', 'OPERAND'))); foreach ($this->OPTB_WOC as $_OPTB) { if (!isset($_OPTB['SECTION']) || empty($_OPTB['SECTION'])) { $_OPTB['SECTION'] = 0; } if ($_OPTB['LINE'] == 5 || $_OPTB['OPCODE'] == 'START' || $_OPTB['OPCODE'] == 'CSECT') { $objectProgram[$_OPTB['SECTION']]['NAME'] = $_OPTB['LABEL']; //continue; } else { if ($_OPTB['OPCODE'] == 'EXTDEF') { $extdef = explode(',', $_OPTB['OPERAND']); //array_push($objectProgram[$_OPTB['SECTION']]['EXTDEF'], $extdef); $objectProgram[$_OPTB['SECTION']]['EXTDEF'] = $extdef; //continue; } else { if ($_OPTB['OPCODE'] == 'EXTREF') { $extref = explode(',', $_OPTB['OPERAND']); //array_push($objectProgram[$_OPTB['SECTION']]['EXTREF'], $extref); $objectProgram[$_OPTB['SECTION']]['EXTREF'] = $extref; //continue; } else { if (isset($_OPTB['OBJECTCODE']) && !empty($_OPTB['OBJECTCODE'])) { if (!isset($_OPTB_WOC)) { $_OPTB['SIZE'] = strlen($_OPTB['OBJECTCODE']) / 2; } $countSize += $_OPTB['SIZE']; if ($previousSection != $_OPTB['SECTION']) { $previousSection = $_OPTB['SECTION']; $countSize = 0; $tLine = 0; } if ($countSize >= $textRecordMaxLen || $index > 0 && $this->OPTB_WOC[$index - 1]['OPCODE'] == 'LTORG') { ++$tLine; $countSize = 0; } $objectProgram[$_OPTB['SECTION']]['TEXT'][] = array('LOC' => $_OPTB['LOC'], 'OBJECTCODE' => $_OPTB['OBJECTCODE'], 'SIZE' => strlen($_OPTB['OBJECTCODE']) / 2, 'TLINE' => $tLine, 'INDEX' => $index); //continue; } } } } ++$index; } // end foreach $previousTLINE = 'no_vlaue'; $opIndex = 0; $tIndex = 0; foreach ($objectProgram as $_objectProgram) { foreach ($_objectProgram['TEXT'] as $_TEXT) { if (!isset($objectProgram[$opIndex]['TRECORD'][$_TEXT['TLINE']])) { $objectProgram[$opIndex]['TRECORD'][$_TEXT['TLINE']]['STARTLOC'] = $_TEXT['LOC']; } if (!isset($objectProgram[$opIndex]['TRECORD'][$_TEXT['TLINE']]['LENGTH'])) { $objectProgram[$opIndex]['TRECORD'][$_TEXT['TLINE']]['LENGTH'] = 0; } $objectProgram[$opIndex]['TRECORD'][$_TEXT['TLINE']]['LENGTH'] += $_TEXT['SIZE']; } ++$opIndex; $previousTLINE = 'no_vlaue'; } // end foreach // fix some unique bug literal loc missing // only for this figure only= =.. $index = 0; $lastELOC = 'no_value'; foreach ($this->OPTB_WOC as $_OPTB) { if (isset($_OPTB['LABEL'])) { if (!empty($_OPTB['ELOC'])) { $lastELOC = $_OPTB['ELOC']; } if ($_OPTB['LABEL'] == '*') { if ($_OPTB['OPCODE'][1] == 'C') { $size = strlen(get_string_between($_OPTB['OPCODE'], "'", "'")); } else { if ($_OPTB['OPCODE'][1] == 'X') { $size = strlen(get_string_between($_OPTB['OPCODE'], "'", "'")) / 2; if ($size == 0.5) { $size = 1; } } } $this->OPTB_WOC[$index]['LOC'] = $lastELOC; $this->OPTB_WOC[$index]['SIZE'] = $size; $newELOC = hexdec($lastELOC) + $size; $this->OPTB_WOC[$index]['ELOC'] = sprintf("%04X", $newELOC); $lastELOC = $this->OPTB_WOC[$index]['ELOC']; } } ++$index; } // end foreach print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'fixedOPTB.html', $this->OPTB_WOC); $maxSection = max(array_column($this->OPTB_WOC, 'SECTION')); for ($i = 0; $i <= $maxSection; $i++) { $tmpOPTB = $this->optb_woc_filter('SECTION', $i); $maxLoc = max(array_column($tmpOPTB, 'ELOC')); //$minLoc = min(array_column($tmpOPTB, 'LOC')); $minLoc = array_column($tmpOPTB, 'LOC')[0]; $objectProgram[$i]['LENGTH'] = hexdec($maxLoc) - hexdec($minLoc); $objectProgram[$i]['LENGTH'] = sprintf('%06X', $objectProgram[$i]['LENGTH']); $objectProgram[$i]['STARTLOC'] = $minLoc; $objectProgram[$i]['ENDLOC'] = $maxLoc; } print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'objectprogramArray.html', $objectProgram); $content = ''; $delimiter = '^'; $objectProgramRes = array(); for ($index = 0; $index < count($objectProgram); $index++) { // Header record : $objectProgramRes[$index] = 'H' . $delimiter . sprintf("%-6s", $objectProgram[$index]['NAME']) . $delimiter . sprintf("%06X", hexdec($objectProgram[$index]['STARTLOC'])) . $delimiter . sprintf("%06X", hexdec($objectProgram[$index]['ENDLOC'])) . "\r\n"; // Define record : $dRecord = ''; // initial as empty string if (!empty($objectProgram[$index]['EXTDEF'])) { $dRecord = 'D'; for ($e = 0; $e < count($objectProgram[$index]['EXTDEF']); $e++) { $defineLoc = $this->define_record_search_loc($objectProgram[$index]['EXTDEF'][$e], $index); $defineSymbol = sprintf("%-6s", $objectProgram[$index]['EXTDEF'][$e]); $dRecord .= $delimiter . $defineSymbol . $delimiter . sprintf("%06X", hexdec($defineLoc)); } $objectProgramRes[$index] .= $dRecord . "\r\n"; } // end if extdef !empty // Refer record : $rRecord = ''; // initial as empty string if (!empty($objectProgram[$index]['EXTREF'])) { $rRecord = 'R'; for ($e = 0; $e < count($objectProgram[$index]['EXTREF']); $e++) { $defineSymbol = sprintf("%-6s", $objectProgram[$index]['EXTREF'][$e]); $rRecord .= $delimiter . $defineSymbol; } $objectProgramRes[$index] .= $rRecord . "\r\n"; } // end if extref !empty // Text record : $tRecord = ''; // initial as empty string $tRecordLine = NULL; if (isset($objectProgram[$index]['TEXT']) && !empty($objectProgram[$index]['TEXT'])) { for ($t = 0; $t < count($objectProgram[$index]['TRECORD']); $t++) { $startLocTmp = sprintf("%06X", hexdec($objectProgram[$index]['TRECORD'][$t]['STARTLOC'])); $lengthTmp = sprintf("%02X", $objectProgram[$index]['TRECORD'][$t]['LENGTH']); $tRecordLine[$t] = 'T' . $delimiter . $startLocTmp . $delimiter . $lengthTmp; for ($t2 = 0; $t2 < count($objectProgram[$index]['TEXT']); $t2++) { if ($objectProgram[$index]['TEXT'][$t2]['TLINE'] == $t) { $tRecordLine[$t] .= $delimiter . $objectProgram[$index]['TEXT'][$t2]['OBJECTCODE']; } else { if ($objectProgram[$index]['TEXT'][$t2]['TLINE'] < $t) { continue; } else { if ($objectProgram[$index]['TEXT'][$t2]['TLINE'] > $t) { break; } } } } // end inner for } // end for print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'tRecordLine' . $index . '.html', $tRecordLine); $tRecord = implode("\r\n", $tRecordLine); $objectProgramRes[$index] .= $tRecord . "\r\n"; } // end if text record !empty // Modification record (revised) : $mRecord = ''; if (isset($objectProgram[$index]['EXTREF']) && !empty($objectProgram[$index]['EXTREF'])) { foreach ($objectProgram[$index]['EXTREF'] as $extref) { if (!empty($this->modification_record($extref, $index))) { $modificationArr[$index][] = $this->modification_record($extref, $index); } // end if } // end forach // originating array .. foreach ($modificationArr[$index] as $_extref) { if (is_array($_extref)) { foreach ($_extref as $__extref) { $modificationSortedArr[$index][] = $__extref; } // end inner foreach } // end is_array } // end foreach // sorting array : $decloc = array(); foreach ($modificationSortedArr[$index] as $key => $row) { $decloc[$key] = $row['DECLOC']; } array_multisort($decloc, SORT_ASC, $modificationSortedArr[$index]); $mRecord = ''; foreach ($modificationSortedArr[$index] as $_extref) { $mRecord .= 'M' . $delimiter . $_extref['LOC'] . $delimiter . $_extref['SIZE'] . $delimiter . $_extref['OPERATOR'] . $_extref['SYMBOL'] . "\r\n"; } $objectProgramRes[$index] .= $mRecord; //$objectProgramRes[$index] .= $mRecord . "\r\n"; } // end if extref record !empty // End record : $eRecord = ''; if (isset($objectProgram[$index]['STARTLOC']) && !empty($objectProgram[$index]['STARTLOC'])) { $eRecord .= 'E'; if ($index == 0) { $eRecord .= $delimiter . $objectProgram[$index]['STARTLOC']; } $objectProgramRes[$index] .= $eRecord . "\r\n"; } // combine to file content ... $content .= $objectProgramRes[$index] . "\r\n\r\n\r\n"; } // end for loop echo $content; $this->objectProgramContent = $content; print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'modificationSortedArr' . $index . '.html', $modificationSortedArr); print_r_to_html(RESULT_PATH . '/' . $OUTPUT_LOG_PREFIX . 'modificationArr' . $index . '.html', $modificationArr); //create_file(RESULT_PATH.'/'.$OUTPUT_LOG_PREFIX.'object-program.txt',$content); //file_put_contents(RESULT_PATH.'/'.$OUTPUT_LOG_PREFIX.'object-program.txt',$content); //print_r($objectProgram); } // end else // exit; }
<?php $url = "http://www.registrar.ucla.edu/schedule/detselect.aspx?termsel=15F&subareasel=COM+SCI&idxcrs=0033++++"; $output = file_get_contents($url); strip_tags($output); $output = get_string_between("{$output}", 'Textbooks', 'About Us'); $output = preg_replace("/<img[^>]+\\>/i", "", $output); echo $output; function get_string_between($string, $start, $end) { $string = " " . $string; $ini = strpos($string, $start); if ($ini == 0) { return ""; } $ini += strlen($start); $len = strpos($string, $end, $ini) - $ini; return substr($string, $ini, $len); }
<?php $dealpageArray[url] = "http://livingsocial.com/deals?preferred_city=4"; $html = file_get_html($dealpageArray[url]); $dealpageArray[title] = $html->find('title', 0)->innertext; $dealpageArray[img_url] = $html->find('div.grid_5', 0)->style; $dealpageArray[img_url] = get_string_between($dealpageArray[img_url], "url(", ")"); $dealpageArray[price] = numberOnly($html->find('div.deal-price', 0)->plaintext); $dealpageArray[value] = str_replace("\$", "", $html->find('span.value-unit strong', 0)->innertext); $dealpageArray[expires] = strtotime('midnight + 5 hours'); $dealpageArray[source_id] = "4"; $dealpageArray[region_id] = "6"; $siteArray[] = $dealpageArray; echo '<pre>'; print_r($siteArray); echo '</pre>';
function getPlaylist($parameter) { //retrait du parametre u pour réduire la taille du buffer $request = $_SESSION['mac'] . " status 0 10000 playlist_id:{$parameter} tags:agl\n"; //echo "contenu requete getPlaylsit: $request"; $mySqueezeCLI = new SqueezeCLI($request); $response = $mySqueezeCLI->receiveCLI(); //echo "la reponse brut: $response \n"; $response = decodeAscii($response); $indexPlaylist = split("playlist index:", $response); array_shift($indexPlaylist); //Clear de la variable de SESSION clearPlaylist(); foreach ($indexPlaylist as $key => $value) { $id = get_string_between($indexPlaylist[$key], "id:", " title"); $title = get_string_between($indexPlaylist[$key], "title:", " artist:"); $artist = get_string_between($indexPlaylist[$key], "artist:", " genre:"); $genre = get_string_between($indexPlaylist[$key], "genre:", " album:"); $album = get_string_between($indexPlaylist[$key], "album:", " url:"); $url = substr($indexPlaylist[$key], strrpos($indexPlaylist[$key], " url:")); $url = substr($url, 5); //echo "contenu de url: $url \n"; // Attention ici est sauvegardée en session les url des titres de la current playlist, ils seront utilisés pour faire une copie de la playlist $_SESSION['currentPlaylist'][$key] = $url; echo "<ul class=\"title\" id=\"{$id}\">"; echo "<li id=\"{$title}\">{$title}</li>"; echo "<li id=\"{$artist}\">{$artist}</li>"; echo "<li id=\"{$genre}\">{$genre}</li>"; echo "<li id=\"{$album}\">{$album}</li>"; echo "<img class=\"buttonDeleteTitle\" id=\"\" src=\"1_music/view/images/player/delete.png\">"; echo "</ul>"; } }
$start_date_temp = $dates_dash_sep[0] . ' ' . $year; $start_date_temp = strtotime($start_date_temp); $start_date = date("m/d/Y", $start_date_temp); //echo $start_date; // end date $days = $total_number_night + 1; $stop_date = date('m/d/Y"', strtotime($start_date . ' +' . $total_number_night . ' day')); //print_r($dates_dash_sep); $t_name = get_string_between($email_body, 'Traveler name', 'Contact info'); $t_name = trim($t_name); $t_name_array = explode(" ", $t_name); $fname = $t_name_array[0]; $lname = $t_name_array[1]; //Guest Count //i.e 20 adults, 0 children $guest_html_line = get_string_between($email_body, 'Guests', 'Traveler name'); $guest_html_line_array = explode(" ", trim($guest_html_line)); //print_r($guest_html_line_array);exit; $guest_html_line_adults = $guest_html_line_array[0]; $guest_html_line_children = $guest_html_line_array[2]; $total_guest = $guest_html_line_adults + $guest_html_line_children; } //else arrival_flag $data['property_number'] = $property_id; $data['start_date'] = $start_date; $data['stop_date'] = $stop_date; $data['fname'] = $fname; $data['lname'] = $lname; $data['total_guest'] = $total_guest; //$grandTotal = "0"; $data['grandTotal'] = 0;
} else { if (!$conn->query("UPDATE word_cloud set date_time='" . date("Y-m-d H:i:s") . "',source_location='" . $table . "',is_fav=" . $is_fav . " WHERE tag='" . $tag . "' and user_id= " . $_SESSION['user_id'] . ";")) { echo "Failed to update"; } } } } if (isset($_POST['hashtag'])) { $keyword = $_POST['hashtag']; //$output = shell_exec("E:\PROGRA~1\R\R-3.2.2\bin\\rscript.exe WordCloud.R $keyword");//supply path to your Rscript.exe file $output = shell_exec("C:\\PROGRA~1\\R\\R-3.2.2\\bin\\rscript.exe WordCloud.R {$keyword}"); //supply path to your Rscript.exe file //echo "Result contains "; // echo "<pre>$output</pre>"; $table = get_string_between($output, "table-start", "table-end"); $filename = get_string_between($output, "filename-start", "filename-end"); $filename = substr($filename, 5, -2); //echo "<pre>$table</pre>"; //$values = explode("\n",$table); //echo "X axis = ".$values[1]." \n Y axis = ".$values[2].""; //echo $filename; insertTable($filename, $keyword); } ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- Meta, title, CSS, favicons, etc. --> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1">
$modulePage = createModuleItem($courseID, $newModuleID, $itemParams); } // Add Secondary Template $secondaryTemplateCount = $moduleSections[4]; if ($secondaryTemplateCount != "") { $pageBody = getPageBody($courseID, 'secondary-template'); // Find and replace module prefix $replacePrefix = get_string_between($pageBody, 'class="kl_mod_text">', '</span>'); // var_dump($replacePrefix); $explodedPrefix = explode(" ", $moduleTitlePrefix); $prefixText = $explodedPrefix[0]; for ($i = 1; $i <= $secondaryTemplateCount; $i++) { $pageTitle = $moduleTitlePrefix . " Secondary Page " . $i; $pageBody = str_replace('class="kl_mod_text">' . $replacePrefix . '</span>', 'class="kl_mod_text">' . $prefixText . ' </span>', $pageBody); // Find and replace module number $replaceNumber = get_string_between($pageBody, 'class="kl_mod_num">', '</span>'); // var_dump($replaceNumber); $pageBody = str_replace('class="kl_mod_num">' . $replaceNumber . '</span>', 'class="kl_mod_num">' . $moduleNumber . '.' . $i . '</span>', $pageBody); $pageParams = 'wiki_page[title]=' . $pageTitle . '&wiki_page[body]=' . urlencode($pageBody); $newPage = createPage($courseID, $pageParams); $responseData = json_decode($newPage, true); $page_url = $responseData['url']; $itemParams = 'module_item[title]=' . urlencode($pageTitle) . '&module_item[type]=Page&module_item[page_url]=' . $page_url; $modulePage = createModuleItem($courseID, $newModuleID, $itemParams); } } // Add Assignments $assignmentCount = $moduleSections[5]; for ($i = 1; $i <= $assignmentCount; $i++) { $assignmentParams = 'assignment[name]=' . $moduleTitlePrefix . ' Assignment ' . $i . '&assignment[position]=1&assignment[submission_types][]=none'; $assignmentID = createGenericAssignment($courseID, $assignmentParams);
$content = str_replace($values, $match_email, $content); } $fileicon = getFileIcon($node->field_ds_access_method[0]['value']['field_atd_file_format'][0]['value']); $img = '<a href="' . $base_url . '/access-point-download-count?url=' . $node->field_ds_access_method[0]['value']['field_atd_access_point'][0]['url'] . '&nid=' . $node->nid . '"><img alt="' . $node->field_ds_access_method[0]['value']['field_atd_file_format'][0]['value'] . '" src="' . $base_url . '/sites/all/themes/ogpl_css3/images/' . $fileicon . '"/></a>'; $download_count = db_result(db_query("Select download_count from web_download_count where nid={$node->nid}")); if ($download_count == 0) { $download_count = '<span class="download-stat"> Never Downloaded </span>'; } else { if ($download_count == 1) { $download_count = '<span class="download-stat">Downloaded ' . $download_count . ' time </span>'; } else { $download_count = '<span class="download-stat"> Downloaded ' . $download_count . ' times </span>'; } } $access_type_url = $node->field_ds_access_method[0]['value']['field_atd_access_point'][0]['url']; $search = get_string_between($content, '<div class="field-label">Access point: </div>', '</div>'); $search = '<div class="field-label">Access point: </div>' . $search; $replace = '<div class="field-label">Access point: </div> <div class="field-items"> <div class="field-item odd">' . $img . $download_count; $content = str_replace($search, $replace, $content); print $content; ?> <?php if (empty($_GET['embed']) && empty($_GET['print'])) { ?> <div id="tabs-block" class="js-disable-hide"> <ul class="list"> <li class="discuss active" title="Discuss this dataset">Discuss</li> <li class="contactOwner" title="Write to Data Controller">Write to Data Controller</li> <li class="ratings" title="Rate this dataset">Ratings</li> <li class="embed" title="Embed this dataset">Embed</li> </ul>
function get_daily_usage() { $usage_stats = @file_get_contents(return_daily_url()); if ($usage_stats === false) { get_daily_usage(); } else { return get_string_between($usage_stats, "<table>", "</table>"); } }
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); $data = curl_exec($curl); curl_close($curl); $data = preg_replace("/.*?<body.*?>/is", "", $data); $data = preg_replace("/<\\/body>.*?/is", "", $data); return true; } function get_string_between($string, $start, $end) { $string = " " . $string; $ini = strpos($string, $start); if ($ini == 0) { return ""; } $ini += strlen($start); $len = strpos($string, $end, $ini) - $ini; return substr($string, $ini, $len); } $data = $_POST['res']; $link = get_string_between($data, "id]", "["); $link = substr($link, 4, strlen($link)); $link = trim($link); require 'Mailinator.php'; $mailinator = new Mailinator("380dd5efc8a94b50821226fa62b91067"); try { print_r($mailinator->fetchMail($link)); } catch (Exception $e) { // Process the error echo "Inca nu a venit mesaj"; }
{ $string = " " . $string; $ini = strpos($string, $start); if ($ini == 0) { return ""; } $ini += strlen($start); $len = strpos($string, $end, $ini) - $ini; return substr($string, $ini, $len); } $f = array_reverse(file($login, FILE_IGNORE_NEW_LINES)); $u = false; foreach ($f as $key => $value) { $time = get_string_between($value, "[", "]"); $nrml = get_string_between($value, "]", "#bld"); $bld = get_string_between($value, "#bld", "#/bld"); // $blz = ""; // if($u) { $blz="<div class='err_log_prt_frst err_log_prt'>"; $u=false;} // else { $blz="<div class='err_log_prt_scnd err_log_prt'>"; $u=true;} $blz = "<div class='err_log_prt_scnd err_log_prt'>"; $blz .= "<div class='err_log_time'>" . $time . "</div>"; // $blz .= "<div class='err_log_body'>" . $nrml . "<br><br><b>" . $bld . "</b>" . "</div></div>"; echo $blz; } ?> </div> </div> <?php
} //////////////////////////////////////////////// $details = find_matching('Facility Details', $elem_p_arr); $access = find_matching('Access To Facility', $elem_p_arr); $shooting = find_matching('Shooting Available', $elem_p_arr); $competition = find_matching('Competition', $elem_p_arr); $services = find_matching('Services', $elem_p_arr); $hunting = find_matching('Hunting - Fishing', $elem_p_arr); $zip_code = get_string_between($fullstring_em, " ", "<", $em_ocurence[1]); $company = get_string_between($fullstring_block, "<h3>", "</h3>"); $company = mysqli_real_escape_string($dbc, $company); $street_adress = get_string_between($fullstring_em, "<em>", "</em>"); $street_adress = mysqli_real_escape_string($dbc, $street_adress); $city = get_string_between($fullstring_em, "<em>", ",", $em_ocurence[1]); $city = mysqli_real_escape_string($dbc, $city); $state = get_string_between($fullstring_em, ", ", " ", $em_ocurence[1]); $state = mysqli_real_escape_string($dbc, $state); $details = check($details); $details = mysqli_real_escape_string($dbc, $details); $access = check($access); $access = mysqli_real_escape_string($dbc, $access); $shooting = check($shooting); $shooting = mysqli_real_escape_string($dbc, $shooting); $competition = check($competition); $competition = mysqli_real_escape_string($dbc, $competition); $services = check($services); $services = mysqli_real_escape_string($dbc, $services); $hunting = check($hunting); $hunting = mysqli_real_escape_string($dbc, $hunting); $query = "INSERT INTO data_container (Company_name,NSSF_member,State,City,Street_adress,Zip_code,Email,Website,Phone_number,Fax,Facility_Details,Access_To_Facility,Shooting_Available,Competition,Services,Hunting_Fishing) values ('{$company}','{$member}','{$state}','{$city}','{$street_adress}','{$zip_code}','{$mail}','{$site}','{$main_phone}','{$fax}','{$details}','{$access}','{$shooting}','{$competition}','{$services}','{$hunting}')"; $results = mysqli_query($dbc, $query) or die('Error' . $company);
} break; default: $contactOwnerID = $coleenCoxID; break; } } elseif ($countryLength >= 1) { $contactOwnerID = $sophieMettlerGroveID; } else { $contactOwnerID = $coleenCoxID; } $fields["Contact Owner"] = $contactOwnerID; /* 4. Create createFields array per web service requirement */ $data_contact = array("createFields" => $fields, "returnFields" => array("Entity ID", "Description")); //define variables for specic curl event $content = json_encode($data_contact); $url_curl = $url_contacts; //5. send data to Hobson sendData(); if ($_POST['userRole'] !== 'Other') { $modify = 'False'; //reset to default //get entity id from return string $entityID = get_string_between($return, 'Entity ID":', '}'); $data_lifecycle = array("createFields" => array("Contact" => $entityID, "Lifecycle Role" => 'Inquirer', "Lifecycle Stage" => 'Open', "Primary Role" => 'True')); //define variables for specic curl event $content = json_encode($data_lifecycle); $url_curl = $url_lifecycles; //send data to Hobson sendData(); }
//$strings = explode(",", $_POST['flatterers']); $strings = preg_split('/(\\s|;|,)/', $_POST['flatterers']); foreach ($strings as $value) { $entry = explode(" ", trim($value)); $theemail = array_pop($entry); // removes last entry in array $theemail = strtolower(trim($theemail)); // Make lower case and trim white space $theemail = str_replace(';', '', $theemail); // from tag issues $theemail = str_replace('\\\'', '', $theemail); // from tag issues $theemail = str_replace('\'', '', $theemail); // from tag issues if (strpos($theemail, '<')) { $theemail = get_string_between($theemail, '<', '>'); } // from tag issues $thename = trim(str_replace($theemail, '', trim($value))); //if (!$thename) : $thename = 'Flatterer'; endif; // Just incase only email is used, we need a name. if (filter_var($theemail, FILTER_VALIDATE_EMAIL) && !in_array($theemail, $arrEmails)) { array_push($arrEmails, $theemail); // adds to emails array array_push($arrNames, $thename); // replaces the email with empty string and adds to the names array } } $_SESSION["flatterernames"] = $arrNames; $_SESSION["flattereremails"] = $arrEmails; } if ($_POST["redirectback"] == "1") {
function separarParametros($texto = '') { $valores = explode(",", $texto); $parametros = array(); foreach ($valores as $valor) { $clave = erase_string_spaces(get_string_before_char($valor, "[")); $valor = erase_string_spaces(get_string_between($valor, "[", "]")); $parametros[$clave] = $valor; } return $parametros; }