function processSignup() { Debugger::debug('processing signup'); $signup = new Signup(); $response = $signup->createAccount($_POST['first'], $_POST['last'], $_POST['username'], $_POST['password'], $_POST['email']); return 'user/signup1'; }
public function resize($image, $newWidth, $targetName) { if (!file_exists(PUBLIC_ROOT . $image)) { $image = '/assets/images/not-found.gif'; } $imgInfo = getimagesize(PUBLIC_ROOT . $image); $oldWidth = $imgInfo[0]; $oldHeight = $imgInfo[1]; $changeRatio = $oldWidth / $newWidth; $newHeight = round($oldHeight / $changeRatio); $newImage = imagecreatetruecolor($newWidth, $newHeight); $source = $this->load(PUBLIC_ROOT . $image); if ($this->imageType == IMAGETYPE_PNG) { imagealphablending($newImage, false); imagesavealpha($newImage, true); $transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 127); imagefilledrectangle($newImage, 0, 0, $newWidth, $newHeight, $transparent); } imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $newWidth, $newHeight, $oldWidth, $oldHeight); header('Content-Type: image/jpeg'); imagejpeg($newImage, $targetName, 100); Debugger::debug($targetName, 'TARGET'); //$this->save($targetName); $this->image = $newImage; imagedestroy($newImage); }
public function createKey($image, $width) { Debugger::debug($image, 'FILENAME for key'); Debugger::debug($width, 'Width'); $key = md5('not the craftiest salt' . $image . $width); Debugger::debug($key, 'KEY'); return $key; }
public function seedEmail(User $user) { Debugger::debug('Seeding email'); $userEmail = new Email(); $userEmail->set('user_id', $user->get('id')); $userEmail->set('email', $this->faker->freeEmail); $userEmail->set('primary', 1); $userEmail->save(); }
public function crop($x, $y, $width, $height, $filename) { $cropArray = array('x' => $x, 'y' => $y, 'width' => $width, 'height' => $height); Debugger::debug($cropArray); $thumb_im = imagecrop($this->image, $cropArray); //$filename = PUBLIC_ROOT . $filename; if ($this->imageType == IMAGETYPE_JPEG) { imagejpeg($thumb_im, $filename, 100); } elseif ($this->imageType == IMAGETYPE_GIF) { imagegif($thumb_im, $filename); } elseif ($this->imageType == IMAGETYPE_PNG) { imagepng($thumb_im, $filename); } chmod($filename, 0777); }
public static function loader($className) { if (strstr($className, 'Faker\\Provider')) { return false; } $filename = "/App/" . str_replace('\\', '/', $className) . ".php"; if (file_exists(SITE_ROOT . $filename)) { require_once SITE_ROOT . $filename; if (class_exists($className)) { return TRUE; } } else { Debugger::debug('Class ' . SITE_ROOT . $filename . ' not found'); } return FALSE; }
public function seed($count = 2) { Debugger::debug('seeding users'); $genders = ['male', 'female']; $this->flushTables(); $this->flushImages('profile-pics'); for ($i = 0; $i < $count; $i++) { $gender = array_rand($genders); $user = new User($gender); $userModel = $user->seedUser(); Debugger::debug('pre email'); $userEmail = new UserEmail(); Debugger::debug('email created'); $userEmail->seedEmail($userModel); Debugger::debug('email seeded'); $userImages = new UserImages($gender); $userImages->seedImage($userModel); $userProfile = new UserProfile($gender); $userProfile->seed($userModel); } }
public function seedThumbnail(Image $image, $imageDir, User $user) { dump($image); $filename = explode('.', $image->filename)[0]; $filenameThumb = $filename . '-thumb.jpg'; Debugger::debug('creating thumbnail'); Debugger::debug($filenameThumb, '$filenameThumb'); dump('creating thumbnail - ' . $filenameThumb); // thumbnail $imageX = getimagesize(PUBLIC_ROOT . $image->filename)[0]; $imageY = getimagesize(PUBLIC_ROOT . $image->filename)[1]; if ($imageX < $imageY) { $width = $imageX; $x = 0; $y = $imageY / 2 - $width / 2; } else { $width = $imageY; $y = 0; $x = $imageX / 2 - $width / 2; } $image->crop($x, $y, $width, $width, $filenameThumb); return $imageDir . $filenameThumb; }
<?php require_once "../bootstrap.php"; use Lib\Utils\Debugger; use Lib\ImageTools\Image; $pathBits = explode('/', $_GET['img']); dump($_GET); $image = array_pop($pathBits); $imgBits = explode('_', $image); dump($pathBits); $pathBits[2] = 'original'; $sizeBit = array_pop($imgBits); $details = explode('.', $sizeBit); $width = $details[0]; $ext = $details[1]; $imgName = 'assets/' . implode('/', $pathBits) . '/' . implode('_', $imgBits) . '.' . $ext; //dump($imgName); $imageResizer = new Image(PUBLIC_ROOT . $imgName); $testKey = $imageResizer->createKey($imgBits[0] . '.jpg', $width); //Debugger::debug($testKey); if ($testKey != $_GET['key']) { Debugger::debug('BAD KEY'); } else { Debugger::debug('resizing'); $imageResizer->resize($imgName, $width, PUBLIC_ROOT . 'assets/' . $_GET['img']); } $imageResizer->output();
define("PUBLIC_ROOT", SITE_ROOT . '/public_html/'); define("APP_DIR", SITE_ROOT . '/App'); define("TEMPLATE_DIR", APP_DIR . '/Views'); set_include_path(get_include_path() . PATH_SEPARATOR . realpath(SITE_ROOT . "/App/")); /* SESSION expiry - 30 days */ ini_set('session.gc_maxlifetime', 60 * 60 * 24 * 30); session_start(); require __DIR__ . '/vendor/autoload.php'; require 'autoload.php'; if (IS_LIVE) { $configFile = 'Configs/live.php'; } else { $configFile = 'Configs/dev.php'; } require $configFile; Debugger::debug('Running in ' . (IS_LIVE ? 'live' : 'dev') . ' mode'); // convert to static class if (class_exists('Memcached')) { $memc = new Lib\Caching\Memc($settings->memc_server, $settings->memc_port); } $db = new Lib\DB\Mysql(); $db->setvar('dbHost', $settings->dbHost); $db->setvar('dbName', $settings->dbName); $db->setvar('dbUser', $settings->dbUser); $db->setvar('dbPass', $settings->dbPass); if (!defined("REST")) { $smarty = new Smarty(); $smarty->addPluginsDir(APP_DIR . '/SmartyPlugins/'); $smarty->setTemplateDir(TEMPLATE_DIR); $smarty->setCompileDir(TEMPLATE_DIR . '/templates_c/'); $smarty->setConfigDir(TEMPLATE_DIR . '/configs/');