public function compareDirectory($directory_shablon, $directory2) { $directory1 = $directory_shablon; /* array( name = str files = array path = array ) */ $Compare = new Compare(); $name = $Compare->String($directory1['name'], $directory2['name']); if ($name >= 99.0) { $files = $Compare->Array_percent($directory1['files'], $directory2['files']); print_r($files); echo ' ->'; if ($files >= 85.0) { $level = $Compare->comparePath($directory1['path'], $directory2['path']); if (!empty($level)) { $path1 = array_reverse($directory1['path']); $path2 = array_reverse($directory2['path']); $slice = $Compare->compareArraySlice($path1, $path2); $this->CMS_base = $slice[1]; $this->CMS_level = $level; return true; } else { return false; } } else { return false; } } else { return false; } }
/** * Compares two database schemas and returns array of pairs. * <p> * Pair is the two element array: * - First element with index "0" is the object from the source collection. * - Second element with index "1" is the object from $targetList. * - if pair element is null when no such element found (by name) in the collection. * * @param Schema $source Source schema. * @param Schema $target Target schema. * * @return array */ public static function diff(Schema $source, Schema $target) { $compare = new Compare(); $compare->compareSequences($source, $target); $compare->compareProcedures($source, $target); $compare->compareTables($source, $target); return $compare->difference; }
public function postUpload($unique) { //disable php timeout and db query log DB::disableQueryLog(); set_time_limit(0); $compare = Compare::where('unique', $unique)->first(); if (!$compare || !Session::get('owner')) { return Redirect::to('compare/notfound'); } $file = Input::file('csv'); $data_set = array(); $config = new LexerConfig(); $config->setDelimiter("\t"); $lexer = new Lexer($config); //setup the interpreter $interpreter = new Interpreter(); $interpreter->unstrict(); $interpreter->addObserver(function (array $row) use(&$data_set) { $data_set[] = $row[0]; }); //parse it! $lexer->parse($file, $interpreter); //loop through the data foreach ($data_set as $data_item) { $data = new Data(); $data->compare_id = $unique; $data->owner_id = Session::get('owner'); $data->hash = md5($data_item); $data->save(); } return Redirect::back(); }
/** * Get a property * * @param string $name * @throws \InvalidArgumentException * @return integer */ public function __get($name) { if (array_key_exists($name, $this->properties)) { if (in_array($name, ['W3C', 'ymd', 'iso'])) { return (string) $this->format($this->properties[$name]); } return (int) $this->format($this->properties[$name]); } switch ($name) { case 'is': return Compare::start($this); case 'diff': return Diff::start($this); } throw new \InvalidArgumentException(); }
{ $path1 = array_reverse($path_shablon); $path2 = array_reverse($path2); $result = 0; foreach ($path2 as $k => $v) { if ($this->String($v, $path1[$k]) == 100) { $result++; } else { break; } } if (count($path1) == $result) { return $result; } else { return false; } /* сравнивать необходимо по отдельным папкам, до последней директории в шаблоне системы, структура системы должна полностью совпадать! Совпадением считается соответстствие структуре шаблона!!! */ //бля! } } $Compare = new Compare(); $array1 = array(0 => 'rur', 1 => 'er', 2 => 'qwerty', 3 => 'qwerty', 4 => 'ffr'); $array2 = array(0 => 'rur', 1 => 'fgrf', 2 => 'er', 3 => 'qwerty', 4 => 'df'); echo $Compare->Array_percent($array1, $array2) . ' <br>'; $arr1 = array('published', 'SC', 'html', 'scripts'); $arr2 = array('published', 'SC', 'html', 'scripts', 'functions', 'core_functions'); print_r($Compare->compareArraySlice($arr1, $arr2));
/** * Remove values from the beginning of an array using comparison * * @param array $arr The source array * @param mixed $match Values matching this value will be removed * @param boolean $strict Whether or not to use strict comparison * @return array */ public static function shiftValues(array $arr, $match = false, bool $strict = false) : array { $func = Compare::getMethod($strict); $len = count($arr); while ($len > 0 && call_user_func($func, reset($arr), $match)) { array_shift($arr); $len--; } return $arr; }
function del() { $count = Compare::delCompare($_POST['id']); print $count; die; }