$squarePath = $varDir . '/square/' . substr($fileName, 0, -strlen($ext)) . 'png'; log('processing ' . $fileName, 1); if (imageUptodate($origPath, $squarePath)) { log(' image up to date', 2); continue; } if (!createSquare($origPath, $ext, $squarePath, $maxSize)) { continue; } if ($fileName == 'default.png') { $md5 = $sha256 = 'default'; } else { if ($fileName == 'mm.png') { $md5 = $sha256 = 'mm'; } else { list($md5, $sha256) = getHashes($fileName); } } log(' creating sizes for ' . $fileName, 2); log(' md5: ' . $md5, 3); log(' sha256: ' . $sha256, 3); $imgSquare = imagecreatefrompng($squarePath); foreach ($sizes as $size) { log(' size ' . $size, 3); $sizePathMd5 = $varDir . '/' . $size . '/' . $md5 . '.png'; $sizePathSha256 = $varDir . '/' . $size . '/' . $sha256 . '.png'; $imgSize = imagecreatetruecolor($size, $size); imagealphablending($imgSize, false); imagefilledrectangle($imgSize, 0, 0, $size - 1, $size - 1, imagecolorallocatealpha($imgSize, 0, 0, 0, 127)); imagecopyresampled($imgSize, $imgSquare, 0, 0, 0, 0, $size, $size, $maxSize, $maxSize); imagesavealpha($imgSize, true);
writeLog('Wait Timeout before change ***** ' . $tb['@@wait_timeout']); $query = "set wait_timeout=28800"; $db->query($query); $result = $db->query($que); $ta = $db->fetchByAssoc($result); writeLog('Wait Timeout after change ***** ' . $ta['@@wait_timeout']); } /////////////////////////////////////////////////////////////////////////////// //// RUN SILENT UPGRADE ob_start(); /////////////////////////////////////////////////////////////////////////////// //// HANDLE CUSTOMIZATIONS // temporarily disable Shadow ini_set('shadow.enabled', 0); $old_files = getHashes($old_template); $new_files = getHashes($template); $moved = 0; $backup_dir = "{$instance_path}/cache/backups_" . date('Y_m_d_H_i_s'); mkdir_recursive($backup_dir); // find all files that are customized for current template $custom_files = findAllFiles($instance_path, array(), false, "", array("./cache", "./custom")); foreach ($custom_files as $custom_file) { if ($custom_file == 'config.php' || $custom_file == 'config_override.php') { continue; } if (isset($old_files[$custom_file]) && isset($new_files[$custom_file]) && $old_files[$custom_file] != $new_files[$custom_file] && $new_files[$custom_file] != md5_file($custom_file)) { // file was updated by upgrade writeLog("File {$custom_file} updated, moving customized version out"); } elseif (isset($old_files[$custom_file]) && !isset($new_files[$custom_file])) { // file was deleted writeLog("File {$custom_file} was deleted in updated version, moving customized version out");
<?php namespace surrogator; require '../vendor/autoload.php'; $cfgFile = __DIR__ . '/../data/surrogator.config.php'; if (!file_exists($cfgFile)) { $cfgFile = '/etc/surrogator.config.php'; if (!file_exists($cfgFile)) { err(500, "Configuration file does not exist.", "Copy data/surrogator.config.php.dist to data/surrogator.config.php"); exit(2); } } require $cfgFile; require __DIR__ . '/shib_attr.php'; $mail = strtolower($shib_mail); list($md5, $sha256) = getHashes($mail); shell_exec('rm -r ' . $varDir . '*/' . $md5 . '.*'); shell_exec('rm -r ' . $varDir . '*/' . $sha256 . '.*'); shell_exec('rm ' . $varDir . 'square/' . $mail . '.*'); shell_exec('rm ' . $rawDir . $mail . '.*'); shell_exec('git -C ' . $rawDir . ' checkout -- ' . $mail . '.*'); shell_exec('php ' . __DIR__ . '/../surrogator.php '); $results = array('status' => 'ok'); echo json_encode($results); function getHashes($emailAddress) { return array(md5($emailAddress), hash('sha256', $emailAddress)); }