/*************************************************************************** Jupiter Content System @ Jupiterportal.com Copyright (C) 2005 Cosmin Flavius (highstrike@gmail.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. More Info About The Licence At http://www.gnu.org/copyleft/gpl.html ****************************************************************************/ //----------------------------------------------------------------- // Filter Acces Rightes //----------------------------------------------------------------- if(isset($is_guest) || isset($is_user)) { header("location: $PHP_SELF?i=2"); exit; } switch($a) { //----------------------------------------------------------------- // Upload emoticons //----------------------------------------------------------------- case 1: //----------------------------------------------------------------- // Define variable for easier manipulation //----------------------------------------------------------------- $uploaded_file = $_FILES['req_file']; //----------------------------------------------------------------- // Make sure the upload went smooth //----------------------------------------------------------------- switch ($uploaded_file['error']) { case 1: case 2: header("location: $PHP_SELF?n=modules/emoticons&i=27"); exit; break; case 3: header("location: $PHP_SELF?n=modules/emoticons&i=28"); exit; break; case 4: header("location: $PHP_SELF?n=modules/emoticons&i=29"); exit; break; default: if ($uploaded_file['size'] == 0) { header("location: $PHP_SELF?n=modules/emoticons&i=29"); exit; } break; } //----------------------------------------------------------------- // If avatar is uploaded //----------------------------------------------------------------- if (is_uploaded_file($uploaded_file['tmp_name'])) { //----------------------------------------------------------------- // Define allowed types of avatar and Find dimmensions //----------------------------------------------------------------- $allowed_types = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png'); list($width, $height, ,) = getimagesize($uploaded_file['tmp_name']); //----------------------------------------------------------------- // Do some checks //----------------------------------------------------------------- if (!in_array($uploaded_file['type'], $allowed_types)) { header("location: $PHP_SELF?n=modules/emoticons&i=30"); exit; } if ($width > 20){ header("location: $PHP_SELF?n=modules/emoticons&i=31"); exit; } if ($height > 20) { header("location: $PHP_SELF?n=modules/emoticons&i=32"); exit; } if ($uploaded_file['size'] > 5024) { header("location: $PHP_SELF?n=modules/emoticons&i=33"); exit; } //----------------------------------------------------------------- // Upload avatar //----------------------------------------------------------------- $temp = @move_uploaded_file($uploaded_file['tmp_name'], images.'/'.emoticons.'/'.$uploaded_file['name']); @chmod(images.'/'.emoticons.'/'.$uploaded_file['name'], 0644); //----------------------------------------------------------------- // If the upload goes bad redirect with error //----------------------------------------------------------------- if(!$temp) header("location: $PHP_SELF?n=modules/emoticons&i=28"); } //----------------------------------------------------------------- // If avatar is not uploaded show unknown error //----------------------------------------------------------------- else header("location: $PHP_SELF?n=modules/emoticons&i=34"); //----------------------------------------------------------------- // Redirect when finished //----------------------------------------------------------------- header("location: $PHP_SELF?n=modules/emoticons&i=66"); break; //----------------------------------------------------------------- // Add emoticons //----------------------------------------------------------------- case 2: //----------------------------------------------------------------- // Begin Check //----------------------------------------------------------------- if(!$code){ header("location: $PHP_SELF?n=modules/emoticons&i=70"); exit; } //----------------------------------------------------------------- // Write Log + Add the emoticon //----------------------------------------------------------------- $db->insertRow("log",array('user_id' => ''.$_SESSION['id'].'','user_user' => ''.$_SESSION['username'].'','log' => ''.$language['Logs desc3'].' emoticons the emoticon code -> \''.$code.'\'','date' => ''.time().'')); $db->insertRow("emoticons",array('code' => ''.$code.'','pic' => ''.$pic.'')); //----------------------------------------------------------------- // Add the emoticon //----------------------------------------------------------------- header("location: $PHP_SELF?n=modules/emoticons&i=67"); break; //----------------------------------------------------------------- // Delete Emoticons //----------------------------------------------------------------- case 3: //----------------------------------------------------------------- // Write Log + Delete the emoticon //----------------------------------------------------------------- $checker = $db->getLine("SELECT * FROM emoticons WHERE id = '$d'"); $db->insertRow("log",array('user_id' => ''.$_SESSION['id'].'','user_user' => ''.$_SESSION['username'].'','log' => ''.$language['Logs desc'].' emoticons the emoticon with code -> \''.$checker['code'].'\'','date' => ''.time().'')); $db->deleteRow("emoticons","id = '$d'"); //----------------------------------------------------------------- // Redirect when finished //----------------------------------------------------------------- header("location: $PHP_SELF?n=modules/emoticons&i=68"); break; //----------------------------------------------------------------- // Update Emoticons //----------------------------------------------------------------- case 4: //----------------------------------------------------------------- // Begin Check //----------------------------------------------------------------- foreach($code as $idx=>$val) if(!$code[$idx]){ header("location: $PHP_SELF?n=modules/emoticons&i=70"); exit; } foreach($pic as $idx=>$val) if(!$pic[$idx]){ header("location: $PHP_SELF?n=modules/emoticons&i=71"); exit; } //----------------------------------------------------------------- // Save the emoticons //----------------------------------------------------------------- foreach($code as $idx=>$val) $db->query("Update `emoticons` set `code` = '$val' WHERE `id` = '$idx'"); foreach($pic as $idx=>$val) $db->query("Update `emoticons` set `pic` = '$val' WHERE `id` = '$idx'"); //----------------------------------------------------------------- // Write Log //----------------------------------------------------------------- $db->insertRow("log",array('user_id' => ''.$_SESSION['id'].'','user_user' => ''.$_SESSION['username'].'','log' => ''.$language['Logs desc2'].' emoticons','date' => ''.time().'')); //----------------------------------------------------------------- // Redirect when finished //----------------------------------------------------------------- header("location: $PHP_SELF?n=modules/emoticons&i=69"); break; //----------------------------------------------------------------- // View Emoticons Form //----------------------------------------------------------------- default: //----------------------------------------------------------------- // Load Emoticons table //----------------------------------------------------------------- $emoticons_db = $db->getTable("SELECT * FROM emoticons"); if($emoticons_db != FALSE) { foreach($emoticons_db as $idx=>$emoticon) { //----------------------------------------------------------------- // Make Layout //----------------------------------------------------------------- $layout .= "
{$language['Admin name']} | ||
» {$language['Admin back']} |