if (isset($_POST) && $logged_in) { //retrieve the $_POST variables $filename_orig = rawurldecode($_POST['file_orig']); $filename = rawurldecode($_POST['file']); $title = rawurldecode($_POST['title']); if ($title == "") { $title = $filename_orig; } $file_path = $CONF['upload_dir'] . $filename; $thumbnail_path = $CONF['upload_dir'] . 'thumbnails/75_75_' . $filename; $file_db = $db->select('uploads', "filename=? LIMIT 1", array($filename)); $temp_path = sys_get_temp_dir() . "\\" . $filename; if (file_exists($file_path) && $file_db) { if ($file_db['hash'] != "") { $crypt = new Cryptography(); $result = $crypt->Decrypt($CONF['key'], $file_db['hash'], $file_path, $temp_path, $file_db['cipher']); $file_path = $temp_path; } $file_type = $file_db['type']; $pattern = "/^(image)\\/(.*)\$/"; if (preg_match($pattern, $file_type)) { $resizeObj = new resize($file_path); // *** 2) Resize image (options: exact, portrait, landscape, auto, crop) $resizeObj->resizeImage(75, 75, 'landscape'); $resizeObj->saveImage($thumbnail_path, 70); $data = array("user_id" => $user->id, "title" => $title, "src" => $filename, "thumb" => $thumbnail_path, "date_added" => date("Y-m-d H:i:s", time())); $row_id = $db->insert($data, 'walls'); $data = array("table_name" => 'walls', "row_id" => $row_id, "user_id" => $user->id, "points" => 1); $db->insert($data, 'votes'); echo "true"; } else {
<?php //GET route $app->get('/', function () use($app) { $options = array(); $options['appPage'] = array("title" => "RedMars", "description" => "A bootstrap for your PHP development", "keywords" => "RedMars, PHP, RedSlim, Slim, RedBean PHP, Twig, Twitter Bootstrap, jQuery", "author" => "Elvis Salaris elvis@mars1982.com"); $options['pmenu'] = array(array('desc' => 'Slim', 'url' => 'http://www.slimframework.com/'), array('desc' => 'Redbean', 'url' => 'http://redbeanphp.com/'), array('desc' => 'Twig', 'url' => 'http://twig.sensiolabs.org/'), array('desc' => 'Twitter Bootstrap', 'url' => 'http://getbootstrap.com/')); $options['smenu'] = array(array('desc' => 'GitHub Repository', 'url' => 'https://github.com/vanting/RedSlim'), array('desc' => 'Composer/Packagist', 'url' => 'https://packagist.org/packages/redslim/redslim'), array('desc' => 'Pagoda Box App Cafe', 'url' => 'https://pagodabox.com/cafe/vanting/redslim')); $options['test'] = $app->redmars['cryptoKey']; $app->view()->appendData($options); $app->render('demo.html.twig'); })->name('home'); $app->post('/encrypt/', function () use($app) { $word = $app->request()->post('word'); $crypto = new Cryptography(); $crypto->SetCryptoKey($app->redmars['cryptoKey']); echo $crypto->Encrypt($word, "qwertqwertqwertqwertqwertqwert12"); }); $app->post('/decrypt/', function () use($app) { $word = $app->request()->post('word'); $crypto = new Cryptography(); $crypto->SetCryptoKey($app->redmars['cryptoKey']); echo $crypto->Decrypt($word, "qwertqwertqwertqwertqwertqwert12"); });