private static function _set_meta($data, $id) { $sourcefile = $id . ".meta"; if (file_exists($sourcefile)) { $data = sys_build_meta(file_get_contents($sourcefile), $data); } $drop = array("filedata", "folder", "created", "lastmodified", "handler", "mfolder", "dsize", "id"); $data = sys_build_meta_str($data, array_diff(array_keys($data), $drop)); if ($data == "") { @unlink($sourcefile); } else { file_put_contents($sourcefile, $data, LOCK_EX); } }
static function select($path, $fields, $where, $order, $limit, $vars, $mfolder) { if ($fields == array("*")) { $fields = array("id", "folder"); } $rows = array(); $entries = self::_select_xml($path, $mfolder); foreach ($entries as $entry) { $ext = modify::getfileext($entry->title); $row = array(); foreach ($fields as $field) { switch ($field) { case "filedata": case "id": $row[$field] = basename($entry->id); break; case "folder": $row[$field] = $path; break; case "filedata_show": case "filename": case "searchcontent": $row[$field] = (string) $entry->title; break; case "fileext": $row[$field] = $ext; break; case "created": $row[$field] = strtotime($entry->published); break; case "lastmodified": $row[$field] = strtotime($entry->updated); break; case "lastmodifiedby": $row[$field] = (string) $entry->author->name; break; case "filesize": $row[$field] = (int) $entry->gd_quotaBytesUsed; break; default: $row[$field] = ""; break; } } $row["_lastmodified"] = strtotime($entry->updated); $row["_url"] = (string) $entry->content["src"]; $row["_filename"] = (string) $entry->title; $meta = sys_build_meta($entry->docs_description, array()); if (empty($meta)) { $meta["description"] = (string) $entry->docs_description; } $row = array_merge($row, $meta); if (sys_select_where($row, $where, $vars)) { $rows[] = $row; } } $rows = sys_select($rows, $order, $limit, $fields); if (count($rows) > 0 and in_array("filedata", $fields)) { foreach ($rows as $key => $row) { $filename = sys_cache_get_file("gdocs", $row["id"] . $row["_lastmodified"], "--" . modify::basename($row["_filename"]), true); if (!file_exists($filename) and (!isset($row["filesize"]) or $row["filesize"] < GDOCS_PREVIEW_LIMIT)) { $fout = fopen($filename, "wb"); $fin = fopen($row["_url"], "rb", false, self::_get_context($mfolder)); if (is_resource($fin) and is_resource($fout)) { while (!feof($fin)) { fwrite($fout, fread($fin, 8192)); } fclose($fin); fclose($fout); } } $rows[$key]["filedata"] = $filename; } } return $rows; }
private static function _set_meta($data, $id, $mfolder, $ntlm) { $w = new Java("jcifs.smb.SmbFile", "smb://" . $id, $ntlm); $lastmodified = $w->getLastModified() / 1000; $sourcefile = sys_cache_get_file("cifs", $id . $lastmodified, "--" . modify::basename($id . ".meta"), true); if (file_exists($sourcefile)) { $data = sys_build_meta(file_get_contents($sourcefile), $data); } $drop = array("filedata", "folder", "created", "lastmodified", "handler", "mfolder", "dsize", "id"); $data = sys_build_meta_str($data, array_diff(array_keys($data), $drop)); if ($data == "") { $w = new Java("jcifs.smb.SmbFile", "smb://" . $id . ".meta", $ntlm); if ($w->exists()) { $w->delete(); } } else { file_put_contents($sourcefile, $data, LOCK_EX); $in = new Java("java.io.FileInputStream", modify::realfilename($sourcefile, false)); $w = new Java("jcifs.smb.SmbFile", "smb://" . $id . ".meta", $ntlm); $w->load($in); } }