function php_grep($q, $path) { global $count; global $checkMd5BeforeReplacing; $ret = ''; $fp = opendir($path); while ($f = readdir($fp)) { $count++; if ($count > 1000000) { echo "Hit File Limit\n"; break; } if (preg_match('/^\\.+$/', $f)) { continue; } // ignore files that start with periods $file_full_path = $path . DIRECTORY_SEPARATOR . $f; if (is_dir($file_full_path)) { php_grep($q, $file_full_path); } else { if ($f == 'infusionsoft.pem') { if (stristr(file_get_contents($file_full_path), $q)) { $file_contents = file_get_contents($file_full_path); $file_contents_no_spaces_or_line_breaks = preg_replace('/[\\t\\s\\r\\n]+/', '', $file_contents); //echo $file_contents_no_spaces_or_line_breaks . "\n"; $md5 = md5($file_contents_no_spaces_or_line_breaks); echo "Found {$q} in: {$file_full_path} - {$md5}\n"; if (!$checkMd5BeforeReplacing || $md5 == '4817bc7a603ac87f7f60200775076314') { echo " Updating File: {$file_full_path}\n"; file_put_contents($file_full_path, file_get_contents('infusionsoft.pem')); } else { echo " Md5 doesn't match, so we're skipping this file.\n"; } flush(); } else { echo "Nothing Found In: {$file_full_path}\n"; flush(); } } } } }
protected function installMetaView() { $this->log("Install Module View metadata."); $module = $this->name; $modulePath = MODULE_PATH . "/{$module}"; global $g_MetaFiles; $g_MetaFiles = array(); php_grep("<EasyView", $modulePath); if (empty($g_MetaFiles)) { return; } $db = $this->DBConnection(); $sql = "DELETE FROM meta_view WHERE module='{$module}'"; try { //BizSystem::log(LOG_DEBUG, "DATAOBJ", $sql); $db->query($sql); } catch (Exception $e) { $this->errors = $e->getMessage(); //BizSystem::log(LOG_DEBUG, "DATAOBJ", $this->errors." $sql"); return false; } foreach ($g_MetaFiles as $metaFile) { $metaName = str_replace('/', '.', str_replace(array(MODULE_PATH . '/', '.xml'), '', $metaFile)); // load do $xml = simplexml_load_file($metaFile); // write mod info in module table $name = $xml['Name']; $class = $xml['Class']; $template = $xml['TemplateFile']; $data = addslashes(file_get_contents($metaFile)); unset($refs); $refs = array(); if (!isset($xml->FormReferences) || !isset($xml->FormReferences->Reference)) { continue; } if ($xml->FormReferences->Reference) { foreach ($xml->FormReferences->Reference as $ref) { $refs[] = $ref['Name']; } } $refStr = implode(',', $refs); $sql = "INSERT INTO meta_view (`name`,`module`,`class`,`template`,`data`,`forms`) \r\n\t \t\t\tVALUES ('{$metaName}','{$module}','{$class}','{$template}','{$data}','{$refStr}');"; try { //BizSystem::log(LOG_DEBUG, "DATAOBJ", $sql); $db->query($sql); } catch (Exception $e) { $this->errors = $e->getMessage(); //BizSystem::log(LOG_DEBUG, "DATAOBJ", $this->errors." $sql"); return false; } } }
function php_grep($q, $path) { global $g_MetaFiles; $fp = opendir($path); while ($f = readdir($fp)) { if (preg_match("#^\\.+\$#", $f)) { continue; } // ignore symbolic links $file_full_path = $path . '/' . $f; if (is_dir($file_full_path)) { php_grep($q, $file_full_path); } else { $path_parts = pathinfo($f); if ($path_parts['extension'] != 'xml') { continue; } // consider only xml files //echo file_get_contents($file_full_path); exit; $content = file_get_contents($file_full_path); $match = 1; foreach ($q as $_q) { if (!stristr($content, $_q)) { $match = 0; break; } } if ($match) { $g_MetaFiles[] = $file_full_path; } } } }
function php_grep($path, $ext) { global $black_folders; $return = array(); $fp = opendir($path); while ($f = readdir($fp)) { if (preg_match("#^\\.+\$#", $f)) { continue; } // ignore symbolic links if (in_array($f, $black_folders)) { continue; } // open source projects or system files $file_full_path = $path . $f; $path_parts = pathinfo($file_full_path); if (is_dir($file_full_path)) { $return = array_merge($return, php_grep($file_full_path . '/', $ext)); } else { if (isset($path_parts['extension']) && in_array($path_parts['extension'], $ext)) { $file = file_get_contents($file_full_path); $count = preg_match_all("/[=\"' ]?icon-([a-z0-9\\-]*)/", $file, $matches); //echo $file_full_path; //print_r($matches); if ($count) { $return = array_merge($return, $matches[1]); } } else { } } } return $return; }
protected function forms() { $metaFileInfo = $this->getFormObj()->GetMetaFileInfo(); $modulePath = $metaFileInfo['modules_path']; $modulePath = substr($modulePath, 0, strlen($modulePath) - 1); global $g_MetaFiles; php_grep("<EasyForm", $modulePath); for ($i = 0; $i < count($g_MetaFiles); $i++) { $g_MetaFiles[$i] = str_replace('/', '.', str_replace(array($modulePath . '/', '.xml'), '', $g_MetaFiles[$i])); $list[$i]['val'] = $g_MetaFiles[$i]; $list[$i]['txt'] = $g_MetaFiles[$i]; } return $list; }