function getArray($content, $startStr, $endStr, $startType, $endType) { $s = ""; $i = ""; $listStr = ""; for ($i = 0; $i <= 999; $i++) { //30为截取条件 //echo($content . "=" . instr($content, $startStr)); if (instr($content, $startStr) > 0 && instr($content, $endStr) > 0) { $s = mid($content, 1, instr($content, $endStr) + 1); //echo(" s=" . $s . "<br>"); $content = mid($content, instr($content, $endStr) + strlen($endStr), -1); $s = mid($s, instr($s, $startStr) + strlen($startStr), -1); //echo(" s2=" . $s . "<br>"); $s = substr($s, 0, strlen($s) - strlen($endStr)); if ($startType == true) { $s = $startStr . $s; } if ($endType == true) { $s = $s . $endStr; } if ($listStr != "") { $listStr = $listStr . '$Array$'; } $listStr = $listStr . $s; } else { break; } } $GetArray = $listStr; return @$GetArray; }
public function testInstr1() { $this->assertEquals(instr('abc 123', 'bc'), true); $this->assertEquals(instr('abc 123', 'cb'), false); $this->assertEquals(instr('abc', 'aa'), false); $this->assertEquals(instr('a', 'aa'), false); $this->assertEquals(instr('aa', 'a'), true); }
function strip_delims($s) { $s = str_replace(',', ' ', $s); $s = str_replace(';', ' ', $s); while (instr(' ', $s) === true) { $s = str_replace(' ', ' ', $s); } return trim($s); }
function anchor($ref, $data, $params = array()) { if (!instr($ref, 'http://')) { if (!instr($ref, '?')) { $ref = urlstr(request::mapUri($ref)); } } $params = formatParams($params); echo "<a href='{$ref}' {$params}>{$data}</a>"; }
private function checkDNS($dns) { $dns = escapeshellarg($dns); exec("nslookup {$dns}", $out); foreach ($out as $k => $m) { if (instr($m, 'NXDOMAIN')) { return false; } } return true; }
function file_list($dir, $pattern = null, $recurse = false) { $result = array(); if (is_dir($dir) && ($handle = opendir($dir))) { while (($file = readdir($handle)) !== false) { if (substr($file, 0, 1) != '.' && $file != "Thumbs.db") { if (is_dir($dir . $file)) { if ($recurse === true) { foreach (file_list($dir . $file . '/', $pattern, true) as $f => $sf) { $result[$f] = $sf; } } } else { if ($pattern == null || instr($file, $pattern)) { $result[$dir . $file] = $file; } } } } closedir($handle); } return $result; }
function OnCommand($Cmd, $x1 = null, $x2 = null, $x3 = null, $x4 = null, $x5 = null) { if ($Cmd == OPENTBS_INFO) { // Display debug information echo "<strong>OpenTBS plugin Information</strong><br>\r\n"; return $this->Debug(); } elseif ($Cmd == OPENTBS_RESET) { // Reset all mergings $this->ArchCancelModif(); $this->TbsStoreLst = array(); $TBS =& $this->TBS; $TBS->Source = ''; $TBS->OtbsCurrFile = false; if (is_string($TBS->OtbsSubFileLst)) { $f = '#' . $TBS->OtbsSubFileLst; $h = ''; $this->BeforeLoadTemplate($f, $h); } return true; } elseif ($Cmd == OPENTBS_ADDFILE || $Cmd == OPENTBS_REPLACEFILE) { // Add a new file or cancel a previous add $Name = is_null($x1) ? false : $x1; $Data = is_null($x2) ? false : $x2; $DataType = is_null($x3) ? TBSZIP_STRING : $x3; $Compress = is_null($x4) ? true : $x4; if ($Cmd == OPENTBS_ADDFILE) { return $this->FileAdd($Name, $Data, $DataType, $Compress); } else { return $this->FileReplace($Name, $Data, $DataType, $Compress); } } elseif ($Cmd == OPENTBS_DELETEFILE) { // Delete an existing file in the archive $Name = is_null($x1) ? false : $x1; $this->FileCancelModif($Name, false); // cancel added files return $this->FileReplace($Name, false); // mark the file as to be deleted } elseif ($Cmd == OPENTBS_FILEEXISTS) { return $this->FileExists($x1); } elseif ($Cmd == OPENTBS_CHART) { $ChartRef = $x1; $SeriesNameOrNum = $x2; $NewValues = is_null($x3) ? false : $x3; $NewLegend = is_null($x4) ? false : $x4; if ($this->ExtType == 'odf') { return $this->OpenDoc_ChartChangeSeries($ChartRef, $SeriesNameOrNum, $NewValues, $NewLegend); } else { return $this->OpenXML_ChartChangeSeries($ChartRef, $SeriesNameOrNum, $NewValues, $NewLegend); } } elseif ($Cmd == OPENTBS_DEBUG_INFO || $Cmd == OPENTBS_DEBUG_CHART_LIST) { if (is_null($x1)) { $x1 = true; } $this->TbsDebug_Info($x1); } elseif ($Cmd == OPENTBS_DEBUG_XML_SHOW) { $this->TBS->Show(OPENTBS_DEBUG_XML); } elseif ($Cmd == OPENTBS_DEBUG_XML_CURRENT) { $this->TbsStorePark(); $this->DebugLst = array(); foreach ($this->TbsStoreLst as $idx => $park) { $this->DebugLst[$this->TbsGetFileName($idx)] = $park['src']; } $this->TbsDebug_Merge(true, true); if (is_null($x1) || $x1) { exit; } } elseif ($Cmd == OPENTBS_FORCE_DOCTYPE) { return $this->Ext_PrepareInfo($x1); } elseif ($Cmd == OPENTBS_DELETE_ELEMENTS) { if (is_string($x1)) { $x1 = explode(',', $x1); } if (is_null($x2)) { $x2 = false; } // OnlyInner return $this->XML_DeleteElements($this->TBS->Source, $x1, $x2); } elseif ($Cmd == OPENTBS_SELECT_MAIN) { if ($this->ExtInfo !== false && isset($this->ExtInfo['main'])) { $this->TbsLoadSubFileAsTemplate($this->ExtInfo['main']); return true; } else { return false; } } elseif ($Cmd == OPENTBS_SELECT_SHEET) { // Only XLSX files have sheets in separated subfiles. if ($this->ExtEquiv === 'xlsx') { $o = $this->MsExcel_SheetGet($x1); if ($o === false) { return; } if ($o->file === false) { return $this->RaiseError("({$Cmd}) Error with sheet '{$x1}'. The corresponding XML subfile is not referenced."); } return $this->TbsLoadSubFileAsTemplate('xl/' . $o->file); } return true; } elseif ($Cmd == OPENTBS_DELETE_SHEETS || $Cmd == OPENTBS_DISPLAY_SHEETS || $Cmd == OPENTBS_DELETE_SLIDES || $Cmd == OPENTBS_DISPLAY_SLIDES) { $delete = $Cmd == OPENTBS_DELETE_SHEETS || $Cmd == OPENTBS_DELETE_SLIDES; $this->TbsSheetSlide_DeleteDisplay($x1, $x2, $delete); } elseif ($Cmd == OPENTBS_MERGE_SPECIAL_ITEMS) { if ($this->ExtEquiv != 'xlsx') { return 0; } $lst = $this->MsExcel_GetDrawingLst(); $this->TbsQuickLoad($lst); } elseif ($Cmd == OPENTBS_SELECT_SLIDE) { if ($this->ExtEquiv != 'pptx') { return false; } $this->MsPowerpoint_InitSlideLst(); $s = intval($x1) - 1; if (isset($this->OpenXmlSlideLst[$s])) { $this->TbsLoadSubFileAsTemplate($this->OpenXmlSlideLst[$s]['idx']); return true; } else { return $this->RaiseError("({$Cmd}) slide number {$x1} is not found inside the Presentation."); } } elseif ($Cmd == OPENTBS_DELETE_COMMENTS) { // Default values $MainTags = false; $CommFiles = false; $CommTags = false; $Inner = false; if ($this->ExtType == 'odf') { $MainTags = array('office:annotation', 'officeooo:annotation'); // officeooo:annotation is used in ODP Presentations } else { switch ($this->ExtEquiv) { case 'docx': $MainTags = array('w:commentRangeStart', 'w:commentRangeEnd', 'w:commentReference'); $CommFiles = array('wordprocessingml.comments+xml'); $CommTags = array('w:comment'); $Inner = true; break; case 'xlsx': $CommFiles = array('spreadsheetml.comments+xml'); $CommTags = array('comment', 'author'); break; case 'pptx': $CommFiles = array('presentationml.comments+xml'); $CommTags = array('p:cm'); break; default: return 0; } } return $this->TbsDeleteComments($MainTags, $CommFiles, $CommTags, $Inner); } elseif ($Cmd == OPENTBS_CHANGE_PICTURE) { static $img_num = 0; $code = $x1; $file = $x2; $default = is_null($x3) ? 'current' : $x3; $adjust = is_null($x4) ? 'inside' : $x4; $img_num++; $name = 'OpenTBS_Change_Picture_' . $img_num; $tag = "[{$name};ope=changepic;tagpos=inside;default={$default};adjust={$adjust}]"; $nbr = false; $TBS =& $this->TBS; $TBS->Source = str_replace($code, $tag, $TBS->Source, $nbr); // argument $nbr supported buy PHP >= 5 if ($nbr !== 0) { $TBS->MergeField($name, $file); } return $nbr; } elseif ($Cmd == OPENTBS_COUNT_SLIDES) { if ($this->ExtEquiv == 'pptx') { $this->MsPowerpoint_InitSlideLst(); return count($this->OpenXmlSlideLst); } elseif ($this->ExtEquiv == 'odp') { return substr_count($TBS->Source, '</draw:page>'); } else { return 0; } } elseif ($Cmd == OPENTBS_SEARCH_IN_SLIDES) { if ($this->ExtEquiv == 'pptx') { $option = is_null($x2) ? OPENTBS_FIRST : $x2; $returnFirstFound = ($option & TBS_ALL) != TBS_ALL; $find = $this->MsPowerpoint_SearchInSlides($x1, $returnFirstFound); if ($returnFirstFound) { $slide = $find['key']; if ($slide !== false && ($option & TBS_GO) != TBS_GO) { $this->OnCommand(OPENTBS_SELECT_SLIDE, $slide); } return $slide; } else { $res = array(); foreach ($find as $f) { $res[] = $f['key']; } return $res; } } elseif ($this->ExtEquiv == 'odp') { // Only for compatibility $p = instr($TBS->Source, $str); return $p === false ? false : 1; } else { return false; } } }
function OnCommand($Cmd, $x1 = null, $x2 = null, $x3 = null, $x4 = null, $x5 = null) { if ($Cmd == OPENTBS_INFO) { // Display debug information echo "<strong>OpenTBS plugin Information</strong><br>\r\n"; return $this->Debug(); } elseif ($Cmd == OPENTBS_DEBUG_INFO || $Cmd == OPENTBS_DEBUG_CHART_LIST) { if (is_null($x1)) { $x1 = true; } $this->TbsDebug_Info($x1); return true; } // Check that a template is loaded if ($this->ExtInfo === false) { $this->RaiseError("Cannot execute the plug-in commande because no template is loaded."); return true; } if ($Cmd == OPENTBS_RESET) { // Reset all mergings $this->ArchCancelModif(); $this->TbsStoreLst = array(); $TBS =& $this->TBS; $TBS->Source = ''; $TBS->OtbsCurrFile = false; if (is_string($TBS->OtbsSubFileLst)) { $f = '#' . $TBS->OtbsSubFileLst; $h = ''; $this->BeforeLoadTemplate($f, $h); } return true; } elseif ($Cmd == OPENTBS_SELECT_FILE) { // Raise an error is the file is not found return $this->TbsLoadSubFileAsTemplate($x1); } elseif ($Cmd == OPENTBS_ADDFILE || $Cmd == OPENTBS_REPLACEFILE) { // Add a new file or cancel a previous add $Name = is_null($x1) ? false : $x1; $Data = is_null($x2) ? false : $x2; $DataType = is_null($x3) ? TBSZIP_STRING : $x3; $Compress = is_null($x4) ? true : $x4; if ($Cmd == OPENTBS_ADDFILE) { return $this->FileAdd($Name, $Data, $DataType, $Compress); } else { return $this->FileReplace($Name, $Data, $DataType, $Compress); } } elseif ($Cmd == OPENTBS_DELETEFILE) { // Delete an existing file in the archive $Name = is_null($x1) ? false : $x1; $this->FileCancelModif($Name, false); // cancel added files return $this->FileReplace($Name, false); // mark the file as to be deleted } elseif ($Cmd == OPENTBS_FILEEXISTS) { return $this->FileExists($x1); } elseif ($Cmd == OPENTBS_CHART) { $ChartRef = $x1; $SeriesNameOrNum = $x2; $NewValues = is_null($x3) ? false : $x3; $NewLegend = is_null($x4) ? false : $x4; if ($this->ExtType == 'odf') { return $this->OpenDoc_ChartChangeSeries($ChartRef, $SeriesNameOrNum, $NewValues, $NewLegend); } else { return $this->OpenXML_ChartChangeSeries($ChartRef, $SeriesNameOrNum, $NewValues, $NewLegend); } } elseif ($Cmd == OPENTBS_CHART_INFO) { $ChartRef = $x1; $Complete = $x2; if ($this->ExtType == 'odf') { return $this->OpenDoc_ChartReadSeries($ChartRef, $Complete); } else { return $this->OpenXML_ChartReadSeries($ChartRef, $Complete); } } elseif ($Cmd == OPENTBS_DEBUG_XML_SHOW) { $this->TBS->Show(OPENTBS_DEBUG_XML); } elseif ($Cmd == OPENTBS_DEBUG_XML_CURRENT) { $this->TbsStorePark(); $this->DebugLst = array(); foreach ($this->TbsStoreLst as $idx => $park) { $this->DebugLst[$this->TbsGetFileName($idx)] = $park['src']; } $this->TbsDebug_Merge(true, true); if (is_null($x1) || $x1) { exit; } } elseif ($Cmd == OPENTBS_FORCE_DOCTYPE) { return $this->Ext_PrepareInfo($x1); } elseif ($Cmd == OPENTBS_DELETE_ELEMENTS) { if (is_string($x1)) { $x1 = explode(',', $x1); } if (is_null($x2)) { $x2 = false; } // OnlyInner return $this->XML_DeleteElements($this->TBS->Source, $x1, $x2); } elseif ($Cmd == OPENTBS_SELECT_MAIN) { if ($this->ExtInfo !== false && isset($this->ExtInfo['main'])) { $this->TbsLoadSubFileAsTemplate($this->ExtInfo['main']); return true; } else { return false; } } elseif ($Cmd == OPENTBS_SELECT_SHEET) { if ($this->ExtEquiv == 'ods') { $this->TbsLoadSubFileAsTemplate($this->ExtInfo['main']); return true; } // Only XLSX files have sheets in separated subfiles. if ($this->ExtEquiv === 'xlsx') { $o = $this->MsExcel_SheetGet($x1, $x2); if ($o === false) { return; } if ($o->file === false) { return $this->RaiseError("({$Cmd}) Error with sheet '{$x1}'. The corresponding XML subfile is not referenced."); } return $this->TbsLoadSubFileAsTemplate('xl/' . $o->file); } return false; } elseif ($Cmd == OPENTBS_DELETE_SHEETS || $Cmd == OPENTBS_DISPLAY_SHEETS || $Cmd == OPENTBS_DELETE_SLIDES || $Cmd == OPENTBS_DISPLAY_SLIDES) { $delete = $Cmd == OPENTBS_DELETE_SHEETS || $Cmd == OPENTBS_DELETE_SLIDES; $this->TbsSheetSlide_DeleteDisplay($x1, $x2, $delete); } elseif ($Cmd == OPENTBS_MERGE_SPECIAL_ITEMS) { if ($this->ExtEquiv != 'xlsx') { return 0; } $lst = $this->MsExcel_GetDrawingLst(); $this->TbsQuickLoad($lst); } elseif ($Cmd == OPENTBS_SELECT_SLIDE) { if ($this->ExtEquiv == 'odp') { $this->TbsLoadSubFileAsTemplate($this->ExtInfo['main']); return true; } if ($this->ExtEquiv != 'pptx') { return false; } $master = is_null($x2) ? false : $x2; $slide = $master ? 'slide master' : 'slide'; $RefLst = $this->MsPowerpoint_InitSlideLst($master); $s = intval($x1) - 1; if (isset($RefLst[$s])) { $this->TbsLoadSubFileAsTemplate($RefLst[$s]['idx']); return true; } else { return $this->RaiseError("({$Cmd}) {$slide} number {$x1} is not found inside the Presentation."); } } elseif ($Cmd == OPENTBS_DELETE_COMMENTS) { // Default values $MainTags = false; $CommFiles = false; $CommTags = false; $Inner = false; if ($this->ExtType == 'odf') { $MainTags = array('office:annotation', 'officeooo:annotation'); // officeooo:annotation is used in ODP Presentations } else { switch ($this->ExtEquiv) { case 'docx': $MainTags = array('w:commentRangeStart', 'w:commentRangeEnd', 'w:commentReference'); $CommFiles = array('wordprocessingml.comments+xml'); $CommTags = array('w:comment'); $Inner = true; break; case 'xlsx': $CommFiles = array('spreadsheetml.comments+xml'); $CommTags = array('comment', 'author'); break; case 'pptx': $CommFiles = array('presentationml.comments+xml'); $CommTags = array('p:cm'); break; default: return 0; } } return $this->TbsDeleteComments($MainTags, $CommFiles, $CommTags, $Inner); } elseif ($Cmd == OPENTBS_CHANGE_PICTURE) { static $UniqueId = 0; $code = $x1; $file = $x2; $prms = array('default' => 'current', 'adjust' => 'inside'); if (is_array($x3)) { $prms = array_merge($prms, $x3); } else { // Compatibility v <= 1.9.0 if (!is_null($x3)) { $prms['default'] = $x3; } if (!is_null($x4)) { $prms['adjust'] = $x4; } } $prms_flat = array(); foreach ($prms as $p => $v) { $prms_flat[] = $p . '=' . $v; } $prms_flat = implode(';', $prms_flat); $UniqueId++; $name = 'OpenTBS_Change_Picture_' . $UniqueId; $tag = "[{$name};ope=changepic;tagpos=inside;{$prms_flat}]"; $nbr = false; $TBS =& $this->TBS; $TBS->Source = str_replace($code, $tag, $TBS->Source, $nbr); // argument $nbr supported buy PHP >= 5 if ($nbr !== 0) { $TBS->MergeField($name, $file); } return $nbr; } elseif ($Cmd == OPENTBS_COUNT_SLIDES) { $master = is_null($x1) ? false : $x1; if ($this->ExtEquiv == 'pptx') { $RefLst = $this->MsPowerpoint_InitSlideLst($master); return count($RefLst); } elseif ($this->ExtEquiv == 'odp') { $idx = $this->Ext_GetMainIdx(); $txt = $this->TbsStoreGet($idx, "Command OPENTBS_COUNT_SLIDES"); return substr_count($txt, '</draw:page>'); } else { return 0; } } elseif ($Cmd == OPENTBS_COUNT_SHEETS) { if ($this->ExtEquiv == 'xlsx') { $this->MsExcel_SheetInit(); return count($this->MsExcel_Sheets); } elseif ($this->ExtEquiv == 'ods') { $idx = $this->Ext_GetMainIdx(); $txt = $this->TbsStoreGet($idx, "Command OPENTBS_COUNT_SHEETS"); return substr_count($txt, '</table:table>'); } else { return 0; } } elseif ($Cmd == OPENTBS_SEARCH_IN_SLIDES) { if ($this->ExtEquiv == 'pptx') { $option = is_null($x2) ? OPENTBS_FIRST : $x2; $returnFirstFound = ($option & OPENTBS_ALL) != OPENTBS_ALL; $find = $this->MsPowerpoint_SearchInSlides($x1, $returnFirstFound); if ($returnFirstFound) { $slide = $find['key']; if ($slide !== false && ($option & OPENTBS_GO) == OPENTBS_GO) { $this->OnCommand(OPENTBS_SELECT_SLIDE, $slide); } return $slide; } else { $res = array(); foreach ($find as $f) { $res[] = $f['key']; } return $res; } } elseif ($this->ExtEquiv == 'odp') { // Only for compatibility $p = instr($TBS->Source, $str); return $p === false ? false : 1; } else { return false; } } elseif ($Cmd == OPENTBS_SELECT_HEADER || $Cmd == OPENTBS_SELECT_FOOTER) { $file = false; switch ($this->ExtEquiv) { case 'docx': $x2 = intval($x2); // 0 by default $file = $this->MsWord_GetHeaderFooterFile($Cmd, $x1, $x2); break; case 'odt': case 'ods': case 'odp': $file = $this->ExtInfo['main']; case 'xlsx': case 'pptx': return false; break; } return $this->TbsLoadSubFileAsTemplate($file); } elseif ($Cmd == OPENTBS_GET_HEADERS_FOOTERS) { $res = array(); switch ($this->ExtEquiv) { case 'docx': $this->MsWord_InitHeaderFooter(); foreach ($this->MsWord_HeaderFooter as $info) { $res[] = $info['file']; } break; case 'odt': case 'ods': case 'odp': // Headers and footers are in the main file. // Handout headers and footers for presentations (PPTX & ODP) are not supported for now. if (isset($this->ExtInfo['main'])) { $res[] = $this->ExtInfo['main']; } case 'xlsx': $FileName = $this->CdFileLst[$this->TbsCurrIdx]; if ($this->MsExcel_SheetIsIt($FileName)) { $res[] = $FileName; } break; case 'pptx': // Headers and footers are in the selected sheet or slide. $FileName = $this->CdFileLst[$this->TbsCurrIdx]; if ($this->MsPowerpoint_SlideIsIt($FileName)) { $res[] = $FileName; } break; } return $res; } elseif ($Cmd == OPENTBS_SYSTEM_CREDIT) { $x1 = (bool) $x1; $this->TbsSystemCredits = $x1; return $x1; } elseif ($Cmd == OPENTBS_ADD_CREDIT) { return $this->Misc_EditCredits($x1, true, false, $x2); } elseif ($Cmd == OPENTBS_RELATIVE_CELLS) { $KeepRelative = (bool) $x1; if ($x2 == OPENTBS_ALL) { // Al$ sheets $this->TBS->OtbsMsExcelExplicitRef = !$KeepRelative; } else { // Current sheet if ($KeepRelative) { $this->MsExcel_KeepRelative[$this->TbsCurrIdx] = true; } else { unset($this->MsExcel_KeepRelative[$this->TbsCurrIdx]); } } return $KeepRelative; } elseif ($Cmd == OPENTBS_EDIT_ENTITY) { $AddElIfMissing = (bool) $x5; return $this->XML_ForceAtt($x1, $x2, $x3, $x4, $AddElIfMissing); } }
$nCount = 0; foreach ($splStr as $s) { $tempS = $s; $s = AspTrim($s); if ($tempS != '' && substr(phptrim($s) . ' ', 0, 1) != '#') { $nCount = $nCount + 1; //总数 if (substr($tempS, 0, 4) == ' ') { } else { $parentid = '-1'; } if (trim(LCase($tempS)) == 'end') { break; } else { if (trim($s) != '') { $title = mid($s . ' ', 1, instr($s . ' ', ' ') - 1); $lableName = getStrCut($s, 'lablename=\'', '\'', 2); $url = getStrCut($s, 'url=\'', '\'', 2); $isdisplay = getStrCut($s, 'isdisplay=\'', '\'', 2); if ($isdisplay == '') { $isdisplay = 1; } //ASPEcho('lablename', $lableName) ; if ($title != '') { connExecute('insert into ' . $DB_PREFIX . 'ListMenu (title,parentid,sortrank,lablename,isdisplay,customaurl) values(\'' . $title . '\',' . $parentid . ',' . $nCount . ',\'' . $lableName . '\',' . $isdisplay . ',\'' . $url . '\')'); if ($parentid == '-1') { $rsObj = $GLOBALS['conn']->query('select * from ' . $DB_PREFIX . 'ListMenu where title=\'' . $title . '\''); $rs = mysql_fetch_array($rsObj); if (@mysql_num_rows($rsObj) != 0) { $parentid = $rs['id']; }
public function isImage(&$dimensions = '') { if (!isset(self::$identified[$this->get('path')])) { $res = $this->cmd('identify', array('-ping', $this->get('path'))); self::$identified[$this->get('path')] = array('width' => 0, 'height' => 0); $poass = false; if (!empty($res)) { $res = str_replace($this->get('path') . ' ', '', $res); $parts = explode(' ', $res[0]); foreach ($parts as $p) { $dparts = explode('x', $p); //200x100 if (count($dparts) == 2) { if (instr($dparts[1], '+')) { $again = explode('+', $dparts[1]); //100+0+0 $dparts[1] = $again[0]; } if (ctype_digit($dparts[0]) && ctype_digit($dparts[1])) { $w = intval($dparts[0]); $h = intval($dparts[1]); self::$identified[$this->get('path')]['width'] = $w; self::$identified[$this->get('path')]['height'] = $h; //protection from oddly tall image if ($w * 3 < $h) { self::$idFailed[] = $this->get('path'); } $pass = true; break; } } } } if (!$pass) { self::$idFailed[] = $this->get('path'); } } if (isset(self::$identified[$this->get('path')])) { $dimensions = self::$identified[$this->get('path')]; } $result = in_array($this->get('path'), self::$idFailed) ? false : true; if (!$result) { //exit(json_encode(var_export($this->get('path'),true))); } return $result; }
} } return FALSE; } $usenet = fsockopen("54.209.5.48", "12345", $errno, $errstr, 3); first: while (!feof($usenet)) { $kp = fgets($usenet, 128); if (inStr("psifer text:", $kp)) { $kp = explode("psifer text: ", $kp); $kp = $kp[1]; $kp = explode("\n", $kp); $kp = $kp[0]; for ($i = 0; $i < 25; $i++) { $temp = str_rot($kp, $i) . "\n"; if (instr("the answer to this stage is", $temp)) { $temp = explode("the answer to this stage is ", $temp); $temp = $temp[1]; goto second; } } } } second: fputs($usenet, $temp); while (!feof($usenet)) { $kp = fgets($usenet, 260); if (inStr("psifer text:", $kp)) { $kp = explode("psifer text: ", $kp); $kp = $kp[1]; $possible_flag = array("easiest answer", "more answers here", "winning for the win", "tired of making up bogus answers", "not not wrong");
function isDate($timeStr) { if (instr($timeStr, "-") > 0 || instr($timeStr, "\\/") > 0 || instr($timeStr, " ") > 0) { return true; } else { return false; } }
private function run($sql, $type, $wait = true) { $return = $type == 'q1v' ? '' : array(); if ($this->isValidRead($sql)) { $con = self::getReadConnection(); self::$query_count++; $start = microtime(true); $r = $con->query($sql . ($type == 'q1v' || $type == 'q1r' ? ' LIMIT 1' : '')); if ($con->error != '') { if (instr($con->error, 'server has gone away')) { //allow a max of 3 pings within 20 seconds of each other before throwing an error if (time() - self::$lastPing > 20) { self::$pings = 0; } if (self::$pings < 3) { self::$pings++; self::$lastPing = time(); $con->ping(); return $this->run($sql, $type, $wait); } } self::dbError($con->error, $sql); } else { $method = $type != 'qryAssoc' ? 'fetch_row' : 'fetch_assoc'; while ($res = $r->{$method}()) { if (!$this->addResult($res, $return, $type)) { break; } } } $time = microtime(true) - $start; self::$query_time += $time; $this->queryList($time, $sql, 'R'); } else { $con = self::getWriteConnection(); $start = microtime(true); self::$query_count_w++; $r = $con->query($sql); $rows = $con->affected_rows; if ($con->error) { if (instr($con->error, 'server has gone away')) { //allow a max of 3 pings within 20 seconds of each other before throwing an error if (time() - self::$lastPing > 20) { self::$pings = 0; } if (self::$pings < 3) { self::$pings++; self::$lastPing = time(); $con->ping(); return $this->run($sql, $type, $wait); } } self::dbError($con->error, $sql); } if ($wait && count(self::$read_hosts) > 0) { $t = 1; if (is_int($wait)) { $t = $wait; } $this->waitForReplication($t); } $time = microtime(true) - $start; self::$query_time_w += $time; $this->queryList($time, $sql, 'W'); return $rows; } return $return; }
/** * Returns fields formatted for select and insert delimits with ` in the case of a mysql namespace collision (its happened) * @param array $fields numerically indexed field names as values * @return string */ public static function joinFields($fields) { //insert or select //nonalias field string $str_fields = ''; //mysql can throw query error due to namespace confilicts with query field names 'group' or others foreach ($fields as $f) { if (instr($f, '`')) { //already formatted $str_fields .= ",{$f}"; } else { $str_fields .= ",`{$f}`"; } } return ltrim($str_fields, ','); }
function handleSqlTop($sql) { $s = ""; $nLength = ""; $leftStr = ""; $rightStr = ""; $nRow = ""; $s = LCase($sql); $nLength = instr($s, " top "); $nSelect = instr(lcase($s), "select "); if ($nLength > 0 && $nSelect > 0) { //只允许查询有显示多少条的限制 20160408 $leftStr = mid($sql, 1, $nLength); $rightStr = mid($sql, $nLength + 5, -1); $rightStr = AspTrim($rightStr); $nRow = mid($rightStr, 1, instr($rightStr, " ")); $rightStr = mid($rightStr, instr($rightStr, " "), -1); //call echo("nRow",nRow) //call echo("leftStr",leftStr) //call echo("rightStr",rightStr) $sql = $leftStr . $rightStr . " limit " . $nRow; } $handleSqlTop = $sql; return @$handleSqlTop; }
function GeraSQL($base, $posicao, $filtro) { $anos = array(); $g = ''; $s = 'COUNT(*) AS contagem'; $w = ''; foreach ($posicao as $var => $row) { if ($var != 'frequencia') { if (instr($row['pos'], 'L') || instr($row['pos'], 'C')) { $s .= ", {$var}"; $g .= (empty($g) ? '' : ', ') . $var; if (instr($row['pos'], 'X')) { $w .= (empty($w) ? '' : ' AND ') . "(NOT ISNULL({$var}))"; } } elseif (instr($row['pos'], 'S') || instr($row['pos'], 'M')) { $s .= ", SUM({$var}) AS {$var}"; if (instr($row['pos'], 'M')) { $s .= ", COUNT({$var}) AS {$var}_count"; } } } } foreach ($filtro as $cod => $row) { if (!empty($row['tipo']) && !strcmp($row['tipo'], 'C')) { $w .= (empty($w) ? '' : ' AND ') . "({$cod} IN (" . implode(', ', $row['lista']) . "))"; } elseif (!empty($row['tipo']) && !strcmp($row['tipo'], 'L') && is_numeric($row['val'])) { $w .= (empty($w) ? '' : ' AND ') . "({$cod} {$row['op']} {$row['val']})"; } } $sw = ''; if (!empty($w)) { $sw = "WHERE {$w}"; } $sg = ''; if (!empty($g)) { $sg = "GROUP BY {$g}"; } $select = "SELECT {$s} FROM tb_{$base}_dados {$sw} {$sg}"; $sqls = "SELECT {$s} FROM tb_{$base}_dados {$sw} {$sg};\n"; #dv(2, "SQLs", $sqls); return $select; }
function GetStrCut($Content, $StartStr, $EndStr, $CutType) { $GetStrCut = ''; //Content=Replace(Replace(Content,Chr(13),""),Chr(10),"") if (instr($Content, $StartStr) > 0 && instr($Content, $EndStr) > 0) { $GetStrCut = StrCut($Content, $StartStr, $EndStr, $CutType); } return @$GetStrCut; }
public static function getBrowser($s = '') { if (!$s) { $s = $_SERVER['HTTP_USER_AGENT']; } $o = new WebBrowser(); $o->vendor = 'Unknown vendor'; $o->name = 'Unknown browser'; $o->version = 'Unknown version'; if (instr($s, 'Firefox')) { $o->vendor = 'Mozilla'; $o->name = 'Firefox'; $tok1 = 'Mozilla/5.0 ('; $p1 = strpos($s, $tok1); if ($p1 !== false) { $s1 = substr($s, $p1 + strlen($tok1)); $p2 = strpos($s1, ')'); $s2 = substr($s1, 0, $p2); // (X11; Linux x86_64; rv:6.0) // (Windows NT 6.1; WOW64; rv:9.0.1) // (X11; Ubuntu; Linux x86_64; rv:10.0) // (Macintosh; Intel Mac OS X 10.7; rv:10.0) foreach (explode(';', $s2) as $tok) { $tok = trim($tok); if (stripos($tok, 'X11') !== false || stripos($tok, 'Windows') !== false || stripos($tok, 'Macintosh') !== false) { $o->os = $tok; } else { if (stripos($tok, 'WOW64') !== false || stripos($tok, 'x86') !== false || stripos($tok, 'Mac OS') !== false) { $o->arch = $tok; } else { // echo "unknown tok: ".$tok."\n"; } } } } // XXX FIXME use a regexp $x = explode('Firefox/', $s, 2); $y = explode(' ', $x[1]); $o->version = $y[0]; } else { if (instr($s, 'Chrome')) { $o->vendor = 'Google'; $o->name = 'Chrome'; $tok1 = 'Mozilla/5.0 ('; $p1 = strpos($s, $tok1); if ($p1 !== false) { $s1 = substr($s, $p1 + strlen($tok1)); $p2 = strpos($s1, ')'); $s2 = substr($s1, 0, $p2); $x = explode('; ', $s2); // (Windows NT 6.1; WOW64) // (X11; Linux x86_64) $o->os = trim($x[0]); if (isset($x[1])) { $o->arch = trim($x[1]); } } // XXX FIXME use a regexp $x = explode('Chrome/', $s, 2); $y = explode(' ', $x[1]); $o->version = $y[0]; } else { if (instr($s, 'Safari')) { $o->vendor = 'Apple'; $o->name = 'Safari'; // Beginning from version 3.0, the version number is part of the UA string as "Version/xxx" if (instr($s, 'Version/')) { $x = explode('Version/', $s, 2); $y = explode(' ', $x[1]); $o->version = $y[0]; } else { // XXX FIXME use a regexp $x = explode('Safari/', $s, 2); $y = explode(' ', $x[1]); switch ($y[0]) { case '419.3': $o->version = '2.0.4'; break; default: $o->version = 'build ' . $y[0] . ' (unknown version)'; } } $tok1 = 'Mozilla/5.0 ('; $p1 = strpos($s, $tok1); if ($p1 !== false) { $s1 = substr($s, $p1 + strlen($tok1)); $p2 = strpos($s1, ')'); $s2 = substr($s1, 0, $p2); // (iPhone; U; CPU OS 3_2 like Mac OS X; en-us) // (iPad;U;CPU OS 3_2_2 like Mac OS X; en-us) // (Macintosh; U; Intel Mac OS X; en) // (Windows; U; Windows NT 6.1; en-US) // (Macintosh; Intel Mac OS X 10_7_3) // (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) foreach (explode(';', $s2) as $tok) { $tok = trim($tok); if ($tok == 'Windows' || $tok == 'Macintosh' || $tok == 'iPhone' || $tok == 'iPad' || $tok == 'iPod') { $o->os = $tok; } else { if (stripos($tok, 'Windows NT') !== false || stripos($tok, 'Mac OS') !== false) { $o->arch = $tok; } else { // echo "unknown tok: ".$tok."\n"; } } } } } else { if (instr($s, 'Opera')) { $o->vendor = 'Opera Software'; $o->name = 'Opera'; // Beginning from version 10.00, the version number is part of the UA string as "Version/xxx" if (instr($s, 'Version/')) { $x = explode('Version/', $s, 2); $y = explode(' ', $x[1]); $o->version = $y[0]; } else { // XXX FIXME use a regexp $x = explode('Opera/', $s, 2); $y = explode(' ', $x[1]); $o->version = $y[0]; } $x = explode(' (', $s, 2); $sub_s = $x[1]; $p1 = strpos($sub_s, ')'); $s2 = substr($sub_s, 0, $p1); // (Windows NT 5.1; U; en) // (Macintosh; Intel Mac OS X; U; en) // (X11; Linux x86_64; U; en) // (Windows NT 6.0; U; en) // (Windows NT 6.1; U; en) foreach (explode(';', $s2) as $tok) { $tok = trim($tok); if (stripos($tok, 'X11') !== false || stripos($tok, 'Windows') !== false || stripos($tok, 'Macintosh') !== false) { $o->os = $tok; } else { if (stripos($tok, 'x86') !== false || stripos($tok, 'Mac OS') !== false) { $o->arch = $tok; } else { // echo "unknown tok: ".$tok."\n"; } } } } else { if (instr($s, 'MSIE')) { // this format was used up to & including IE 10 $o->vendor = 'Microsoft'; $o->name = 'Internet Explorer'; $x = explode('MSIE ', $s, 2); $y = explode(';', $x[1]); $o->version = $y[0]; } else { if (instr($s, 'Trident/')) { // this format is used in IE 11 and forward $o->vendor = 'Microsoft'; $o->name = 'Internet Explorer'; $x = explode('rv:', $s, 2); $y = explode(')', $x[1]); $o->version = $y[0]; } } } } } } return $o; }