/** * Output ColorizeIt data for a given revision in XML format. * * @param int $id Attachment id. * @return Symfony\Component\HttpFoundation\Response */ public function colorizeit_data($id) { if (!strlen($this->ext_config->colorizeit) || !$this->check_auth()) { return $this->error('ERROR_NO_ATTACHMENT'); } try { $this->load($id); } catch (\Exception $e) { return $this->error($e->getMessage()); } if (!$this->contrib->has_colorizeit()) { return $this->error('CLR_ERROR_NOSAMPLE'); } if (!empty($this->revision->revision_clr_options)) { $options = unserialize($this->revision->revision_clr_options); } else { $colorizeit_helper = new colorizeit_helper(); try { $options = $colorizeit_helper->generate_options($this->attachment->get_filepath(), $this->ext_config->__get('contrib_temp_path')); } catch (\Exception $e) { return $this->error($e->getMessage()); } $colorizeit_helper->submit_options($options, $this->revision->revision_id, $this->db); } return new Response($this->get_xml_output($options), 200); }
/** * Sync attachments */ public function attachments($mode, $attachment_id = false) { switch ($mode) { case 'hash': $sql = 'SELECT * FROM ' . $this->attachments_table . ($attachment_id !== false ? 'WHERE attachment_id = ' . (int) $attachment_id : ''); $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $this->attachment->__set_array($row); $file = $this->attachment->get_filepath(); if (file_exists($file)) { $md5 = md5_file($file); if ($md5 != $row['hash']) { $sql = 'UPDATE ' . $this->attachments_table . ' SET hash = "' . $this->db->sql_escape($md5) . '" WHERE attachment_id = ' . $row['attachment_id']; $this->db->sql_query($sql); } } } $this->db->sql_freeresult($result); break; } }
/** * Set package location and temp path. */ protected function set_package_paths() { $this->package->set_temp_path($this->ext_config->__get('contrib_temp_path'), true)->set_source($this->attachment->get_filepath()); }
/** * @{inheritDoc} */ public function upload_check(attachment $attachment) { $package = new package(); $package->set_source($attachment->get_filepath())->set_temp_path($this->ext_config->__get('contrib_temp_path'), true)->extract(); $license_location = $package->find_directory(array('files' => array('required' => 'license.txt'))); $package->cleanup(); if ($license_location !== null && substr_count($license_location, '/') < 2) { return array(); } return array($this->user->lang('LICENSE_FILE_MISSING')); }
/** * Load revision package. */ protected function load_package() { $this->package = new \phpbb\titania\entity\package(); $this->package->set_source($this->attachment->get_filepath())->set_temp_path($this->ext_config->__get('contrib_temp_path'), true); }