public function testMerge() { $target = __DIR__ . '/AA.pdf'; @unlink($target); $m = new Merger(); $m->addFromFile(__DIR__ . '/A.pdf'); $m->addFromFile(__DIR__ . '/A.pdf', new Pages('1')); file_put_contents($target, $m->merge()); $this->assertTrue(file_exists($target), "{$target} should be created"); }
/** * {@inheritdoc} */ public function encode($subject, $salt) { if (empty($salt)) { return $subject; } try { return $this->merger->merge($subject, $salt); } catch (\DomainException $e) { throw new \DomainException($e->getMessage()); } }
/** * {@inheritdoc} */ public function encode($subject, $salt) { if (!in_array($this->algorithm, hash_algos(), true)) { throw new \DomainException(sprintf('The algorithm "%s" is not supported.', $this->algorithm)); } try { $salted = $this->merger->merge($subject, $salt); } catch (\DomainException $e) { throw new \DomainException($e->getMessage()); } $digest = hash($this->algorithm, $salted, true); for ($i = 1; $i < $this->iterations; $i++) { $digest = hash($this->algorithm, sprintf("%s%s", $digest, $salted), true); } return $this->useBase64 ? base64_encode($digest) : bin2hex($digest); }
// GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * @package tool * @subpackage mergeusers * @author Jordi Pujol-Ahulló <*****@*****.**> * @copyright 2013 Servei de Recursos Educatius (http://www.sre.urv.cat) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define("CLI_SCRIPT", true); require_once __DIR__ . '/../../../../config.php'; ini_set('display_errors', true); ini_set('error_reporting', E_ALL | E_STRICT); global $CFG; require_once $CFG->dirroot . '/lib/clilib.php'; require_once __DIR__ . '/../lib/autoload.php'; // loads current configuration $config = tool_mergeusers_config::instance(); // initializes merger tool $mut = new MergeUserTool($config); //may abort execution if database is not supported $merger = new Merger($mut); // initializes gathering instance $gatheringname = $config->gathering; $gathering = new $gatheringname(); //collects and performs user mergings $merger->merge($gathering); exit(0); // if arrived here, all ok ;-)
public function testSetGetTempDir() { $m = new Merger(); $this->assertSame(sys_get_temp_dir(), $m->getTempDir()); $newTempDir = "foobar"; $m->setTempDir($newTempDir); $this->assertSame($newTempDir, $m->getTempDir()); }
<?php require_once 'bootstrap.php'; $idsParam = isset($_REQUEST['ids']) ? $_REQUEST['ids'] : ''; $isPlain = isset($_REQUEST['plain']) && $_REQUEST['plain'] === 'false' ? false : true; $ids = array(); if ($idsParam) { $idsParam = json_decode($idsParam); } if (!empty($idsParam)) { foreach ($idsParam as $id) { $ids[] = (int) $id; } } else { die; } Merger::downloadFile($ids, $isPlain); //var_dump($ids); //header($string)