function import_cssrules($cssfile, $idcssfile, $idclient) { global $css_warnings, $cfg_client; if (!file_exists($cssfile)) { return '1115'; } // css-file is missing $errstatus = false; // get validator object $validate = get_validator('css_validator'); // get all lines and make a long string of it $rules_array = file($cssfile); // remove all html and c-style comments, all unneccessary whitespaces $rules = implode(' JB§BJ ', $rules_array); $rules = preg_replace('/(<\\!\\-\\-)|(\\-\\->)/', '', $rules); $rules = preg_replace('/\\n|\\r/s', '', $rules); $rules = preg_replace('/(\\/\\*.*?\\*\\/)|([^:]\\/\\/.*?JB§BJ)|\\t/s', '', $rules); $rules = preg_replace('/((\\/\\/)$)|(JB§BJ)/', '', $rules); $rules = preg_replace('/\\s{2,}/s', ' ', $rules); // // to do: // extract import-statements before rule-splitting // // split the rules-string into an array of rules, use } as split-character $rules_array = explode('}', $rules); // create for all rules an db record foreach ($rules_array as $key => $value) { // split into name and elements $cssrule = explode("{", trim($value)); $name = trim($cssrule[0]); $styles = trim($cssrule[1]); // normalize elements $styles = preg_replace('/ *?:/', ':', $styles); $styles = preg_replace('/: +/', ': ', $styles); $styles = preg_replace('/(( *?;) *)/', '; ', $styles); if (substr(trim($styles), -1) != ';') { $styles .= ';'; } // get ruletype and change rulename if neccessary $type = substr($name, 0, 1); switch ($type) { case '#': case '.': case '@': case ':': $name = substr($name, 1); break; default: $type = ''; break; } // ignore rules without names or styles - might be errors if (!$name || !$styles) { continue; } // check names and rules - mark possible errors with status 0 // jb - 04.09.2004 - addes checks for vendor-specific-css-rules // if name is vendor-specific the rule will always be okay, i.e. // vendor-specific css-rules will be ignored by the validator // CSS2.1-Spec: 4.1.2 $status = '1'; if (!$validate->cssrule_vendor_specific($name)) { if (!$validate->cssrule_name($name) || !$validate->css_elements($styles, $cfg_client["css_checking"])) { $status = '0'; $errstatus = true; } } // make db record and add rule to file, ignore errors while inserting ... // jb - 28.08.2004 - cms_addslashes hinzugefügt, wegen single quotes in CSS-Stilen $styles = cms_addslashes($styles); $id = insert_cssrule($idclient, $type, $name, '', $styles, $status, $css_warnings); if ($id) { add_cssrule_to_file($id, $idcssfile); } } // return import status return $errstatus ? '1117' : '1116'; }
function scan_files($iddirectory, $updatethumbs = 0) { global $deb, $client, $cfg_client, $cms_db; // get validator object $validate = get_validator('upload'); // scan files in directory $found_files_id = array(); $this->edit_files = array(); $currentdir = ''; $scandir = ''; // get scan dir $this->_get_scan_dir($iddirectory, $currentdir, $scandir); if (!is_dir($scandir)) { // error ... given name is no directory $this->db->delete_by_id_and_client('directory', 'iddirectory', $iddirectory, $client); } else { // do scan directory for files // set the all files in current directory to be scanned $current_iddirectory = $currentdir['iddirectory']; $sql = 'UPDATE '; $sql .= $cms_db['upl'] . ' '; $sql .= 'SET '; $sql .= ' status = (status | 0x10), '; $sql .= ' lastmodified = lastmodified '; $sql .= 'WHERE '; $sql .= ' iddirectory = ' . $current_iddirectory; $sql .= ' AND idclient = ' . $client; $sql .= ' AND (status & 0x04) = 0'; $this->db->sql = $sql; $this->db->needReturn = false; $this->db->exec_query(); // get dirs and files $handle = opendir($scandir); while (false !== ($file = readdir($handle))) { if (strpos($file, $this->thumb_ext) === false && $file != '.' && $file != '..') { // exclude thumbs and special dirs // handle files $onefile = $scandir . $file; if (is_file($onefile)) { $this->found_files++; $filetype = strtolower(substr(strrchr($file, '.'), 1)); // check if forbidden filetype $filetype_okay = empty($filetype) ? true : !strstr($this->cfg_client['upl_forbidden'], $filetype); if ($validate->filename($file) && $filetype_okay) { // not a forbidden filetype // prüfe ob file existiert: // ja: aktualisiere datensatz // nein: ermittle filetype und lege die datei an $filesize = filesize($onefile); $filetime = filemtime($onefile); $newfile = $this->get_file($file, $client, $current_iddirectory); if (empty($newfile)) { $filetype_id = $this->get_filetype_id($filetype, true); $status = $currentdir['status'] | $this->tmp_filetypedata[$filetype]['status']; $idfile = $this->insert_file((int) $client, $file, (int) $current_iddirectory, (int) $filetype_id, (int) ($status & 0xef), '', '', $filetime, $filesize); $this->edit_files[] = $idfile; // add new file to editlist } else { if ($filesize != $newfile['filesize'] || $filetime != $newfile['created'] || !empty($updatethumbs)) { if (!empty($updatethumbs)) { switch ($newfile['idfiletype']) { case 3: case 4: case 12: case 13: $filesize = -2; break; default: break; } } $this->update_file($newfile['idupl'], '', $file, '', '', 0xef & $newfile['status'], '', '', $filesize, $filetime); } $found_files_id[] = $newfile['idupl']; } } else { // jb_todo: forbidden file type ?? collect ?? // jb_todo: filename not valid ?? collect ?? $this->error_files[] = $onefile; } } } } // delete all scanned marks of found files closedir($handle); $this->db->needReturn = false; if (count($found_files_id) > 0) { $sql = 'UPDATE '; $sql .= $cms_db['upl'] . ' '; $sql .= 'SET '; $sql .= ' status = (status & 0xEF), '; $sql .= ' lastmodified = lastmodified '; $sql .= 'WHERE '; $sql .= ' idupl in (' . implode(',', $found_files_id) . ') '; $sql .= ' AND idclient = ' . $client; $this->db->sql = $sql; $this->db->exec_query(); } // delete scannfile mark of current dir $sql = 'UPDATE '; $sql .= $cms_db['directory'] . ' '; $sql .= 'SET '; $sql .= ' status = (status & 0xDF), '; $sql .= ' lastmodified = lastmodified '; $sql .= 'WHERE '; $sql .= ' iddirectory = ' . $current_iddirectory; $sql .= ' AND idclient = ' . $client; $this->db->sql = $sql; $this->db->exec_query(); } return count($found_files_id); }
public function testAnnotationRaw() { $val = get_validator(); $errors = $val->validateArray(['test' => rand(5, 99), 'foo' => 'something'], 'Class1'); $this->assertTrue(!empty($errors)); $this->assertTrue(!empty($errors['test'])); $this->assertTrue(strpos($errors['test']->getMessage(), 'invalid') > 0); $this->assertEquals(count($errors), 1); }
function upl_editdir() { global $fm, $client, $newdirname, $newdirdescription, $dirname, $dirdescription, $iddirectory, $cms_gruppenids, $cms_gruppenrechte, $cms_gruppenrechtegeerbt, $cms_gruppenrechteueberschreiben; // rechte prüfen für edit directory if (!$fm->perm->have_perm(3, 'folder', $iddirectory)) { return '1701'; } // get validator object $validate = get_validator('upload'); // check if the required values are set if (empty($newdirname)) { return '1405'; } // requirements if (!$validate->filepath($newdirname)) { return '1406'; } // bad chars in dirname // check if the new dirname can be used $rename_done = $fm->rename_directory_fs($newdirname, $iddirectory); if ($rename_done) { // so far no error conditions ... update db record // get status settings $status = 0; $tmp = $fm->tmp_directorydata[$iddirectory]; $olddirname = $tmp['dirname']; $newdir = substr($tmp['dirname'], 0, strlen($tmp['dirname']) - strlen($tmp['name']) - 1) . $newdirname . '/'; $fm->update_directory($iddirectory, $client, $newdirname, $newdir, $newdirdescription, (int) $parentid, (int) $status); $fm->change_child_dirname($olddirname, $client, $newdir); } // check if user rights have to be set if ($fm->perm->have_perm(6, 'folder', $idupl)) { $fm->perm->set_group_rights('folder', $iddirectory, $cms_gruppenids, $cms_gruppenrechte, $cms_gruppenrechtegeerbt, $cms_gruppenrechteueberschreiben, '', 4294967295.0, '0'); } return $fm->errno; }