Example #1
0
 function generateContent()
 {
     if (isset($_GET['ip'])) {
         Framework::$autoLoader->importFolder(dirname($this->paths['utils']) . '/classes');
         $geoip = new GeoIP();
         $result = $geoip->getCountry(value($_GET['ip']));
         if ($result) {
             return Alert::success('<h4>Maxmind GeoIP</h4>IP: <b>' . $_GET['ip'] . '</b> is located in <b>' . $result['country'] . '</b> (' . $result['code'] . ')');
         } else {
             return Alert::error('<h4>Maxmind GeoIP</h4>IP: <b>' . $_GET['ip'] . '</b> is not found in the country database.');
         }
     } else {
         return new Form(array('method' => 'get', 'fields' => array(new Input(array('name' => 'ip', 'placeholder' => 'IP address')), new Input(array('type' => 'submit', 'value' => 'Lookup', 'class' => 'btn btn-primary'))), 'class' => 'input-append'));
     }
 }
Example #2
0
 public function postChangePassword(Request $request)
 {
     if (!\Auth::validate(['email' => \Auth::user()->email, 'password' => $request->input('old_password')])) {
         \Alert::error(trans('auth.wrong_password'))->flash();
         return redirect()->back();
     }
     // validation
     $validator = \Validator::make($request->all(), ['old_password' => 'required', 'new_password' => 'required|confirmed|min:6']);
     if ($validator->fails()) {
         // The given data did not pass validation
         return redirect()->back()->withInput()->withErrors($validator->errors());
     }
     // change the password
     $user = User::findOrFail(\Auth::user()->id);
     $user->password = $request->input('new_password');
     $user->save();
     // set a success/error message
     \Alert::success(trans('auth.password_updated'))->flash();
     // redirect to the change password page
     return redirect()->back();
 }
 public function save($savePath = "", $mode = 0)
 {
     // Set the save mode
     $this->saveMode = $mode;
     // Attempt to validate the image
     if (!$this->validateMime()) {
         return false;
     }
     // Make sure the path is valid
     if (!$this->validatePath($savePath)) {
         return false;
     }
     // Make sure the filename is valid
     if (!$this->handleFilename()) {
         return false;
     }
     // Save the file to the designated location
     if (!move_uploaded_file($this->tempPath, $this->saveDirectory . '/' . $this->filename . '.' . $this->extension)) {
         Alert::error("Upload Error", "There was an error uploading this file. Please try again.", 4);
         return false;
     }
     return true;
 }
    ?>
</label>
                        <input type="text" name="answer" class="form-control">
                        <br>
                        <?php 
    CryptCaptcha::draw();
    ?>
                        </div>
                        <?php 
}
?>
                        <br>
                        <?php 
if (count($errors) > 0) {
    foreach ($errors as $error) {
        Alert::error($error);
    }
}
?>
                        <div class="form-group">
                            <input type="submit" name="reset_password_submit" class="btn btn-primary" value="<?php 
echo __('Send New Password', 'users');
?>
" />
                        </div>
                    </form>
                </div>
            </div>

        </div>
?>
</a></li>
                </ul>
              </li>
            </ul>
          </div>
      </div>
    </nav>

    <div class="container">

        <?php 
// Monstra Notifications
Notification::get('success') and Alert::success(Notification::get('success'));
Notification::get('warning') and Alert::warning(Notification::get('warning'));
Notification::get('error') and Alert::error(Notification::get('error'));
?>

        <div id="update-monstra"></div>
        <div><?php 
Action::run('admin_pre_template');
?>
</div>
        <div>
            <?php 
if ($plugin_admin_area) {
    if (is_callable(ucfirst(Plugin::$plugins[$area]['id']) . 'Admin::main')) {
        call_user_func(ucfirst(Plugin::$plugins[$area]['id']) . 'Admin::main');
    } else {
        echo '<div class="message-error">' . __('Plugin main admin function does not exist', 'system') . '</div>';
    }
 /**
  * Complete teh Academy creation process
  * @param $id
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function complete($id)
 {
     $academy = Academy::find($id);
     if ($academy && $academy->images) {
         \Alert::success('Great !! Academy Created Successfully');
         return redirect(route('academies.index'));
     } else {
         \Alert::error('Error !!', 'Please Add Images to Complete');
         return redirect()->back();
     }
 }
Example #7
0
                    exit;
                } else {
                    Alert::error("Automatic Update", "Issue with Automatic Update: attempt to backup config.php failed. The engine does not have proper permissions to rename the file. You may need to perform a manual update instead.", 5);
                }
            }
            // If you manually updated the configuration files
            if (isset($_POST['manual-submit'])) {
                Alert::saveSuccess("Config Updated", "You performed a manual update.");
                header("Location: /install/setup-database");
                exit;
            }
        } else {
            if (API_Connect::$alert != "") {
                Alert::error("API Issue", API_Connect::$alert);
            } else {
                Alert::error("API Connection", "Unable to connect to the Site Registration API. Please try again shortly.", 4);
            }
        }
    }
}
// Run Global Script
require PARENT_APP_PATH . "/includes/install_global.php";
// Display the Header
require HEADER_PATH;
echo '
<form class="uniform" action="/install/config-app" method="post">' . Form::prepare("install-app-config");
if ($buildApp == "") {
    // Display the Page
    echo Alert::display() . '
	
	<h1>Installation: Application Configuration</h1>
<?php

// Make sure an appropriate environment is being used
switch (ENVIRONMENT) {
    case "local":
    case "development":
    case "staging":
    case "production":
        break;
    default:
        Alert::error("Improper Environment", "You must set the ENVIRONMENT value properly.");
}
// If the server configuration are acceptable
if (Validate::pass()) {
    // Check if the form was submitted (to continue to the next page)
    if (Form::submitted("install-server-config")) {
        header("Location: /install/config-site");
        exit;
    }
    Alert::success("Server Config", "Your server is properly configured!");
}
// Installation Header
require dirname(ROUTE_SECOND_PATH) . "/includes/install_header.php";
// Run Global Script
require dirname(ROUTE_SECOND_PATH) . "/includes/install_global.php";
// Display the Header
require HEADER_PATH;
echo '
<form class="uniform" action="/install/config-server" method="post">' . Form::prepare("install-server-config");
echo '
<h3>Update Your Server Configurations:</h3>
<?php

// Make sure the user has named the site
if (!defined("SITE_HANDLE")) {
    Alert::error("Invalid Site Name", "You must provide a valid Site Name.");
} else {
    if (!defined("DATABASE_NAME")) {
        Alert::error("Improper DB Name", "You must provide a valid Database Name.");
    }
}
// Make sure that there is a valid application path
if (!defined("APP_PATH")) {
    Alert::error("Improper App Path", "You must set a valid application or application path.");
} else {
    if (!Dir::exists(APP_PATH)) {
        Alert::error("Invalid App Path", "You must set a valid application or application path.");
    }
}
// If the server configuration are acceptable
if (Validate::pass()) {
    // Check if the form was submitted (to continue to the next page)
    if (Form::submitted("install-site-config")) {
        header("Location: /install/config-database");
        exit;
    }
    Alert::success("Site Config", "Your site configurations are valid!");
}
// Installation Header
require dirname(ROUTE_SECOND_PATH) . "/includes/install_header.php";
// Run Global Script
require dirname(ROUTE_SECOND_PATH) . "/includes/install_global.php";
Example #10
0
 public static function sendAttachment($emailTo, $subject, $message, $filePath, $filename, $emailFrom = "")
 {
     // Determine the Email being sent from
     if (!$emailFrom) {
         $emailFrom = "admin@" . BASE_DOMAIN . URL_SUFFIX;
     }
     // Handle Email Recipients
     if (is_array($emailTo)) {
         foreach ($emailTo as $next) {
             if (!Email::isValid($next)) {
                 Alert::error("Email", "Illegal email used, cannot send email.", 3);
                 return false;
             }
         }
         $emailTo = implode(", ", $emailTo);
     } else {
         if (!Email::isValid($emailTo)) {
             Alert::error("Email", "Illegal email used, cannot send email.", 3);
             return false;
         }
     }
     // $filePath should include path and filename
     $filename = basename($filename);
     $file_size = filesize($filePath);
     $content = chunk_split(base64_encode(file_get_contents($filePath)));
     $uid = md5(uniqid(time()));
     // Designed to prevent email injection, although we should run stricter validation if we're going to allow
     // other people to insert emails into the email.
     $emailFrom = str_replace(array("\r", "\n"), '', $emailFrom);
     // Prepare header
     $header = "From: " . $emailFrom . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed; boundary=\"" . $uid . "\"\r\n\r\n" . "This is a multi-part message in MIME format.\r\n" . "--" . $uid . "\r\n" . "Content-type:text/plain; charset=iso-8859-1\r\n" . "Content-Transfer-Encoding: 7bit\r\n\r\n" . $message . "\r\n\r\n" . "--" . $uid . "\r\n" . "Content-Type: application/octet-stream; name=\"" . $filename . "\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-Disposition: attachment; filename=\"" . $filename . "\"\r\n\r\n" . $content . "\r\n\r\n" . "--" . $uid . "--";
     // Record this email in the database
     $primeRecipient = is_array($emailTo) ? $emailTo[0] : $emailTo;
     $details = array("recipients" => $emailTo, "sender" => $emailFrom, "file" => $filename);
     Database::query("INSERT INTO log_email (recipient, subject, message, details, date_sent) VALUES (?, ?, ?, ?, ?)", array($primeRecipient, $subject, $message, json_encode($details), time()));
     // Localhost Versions, just edit email.html with the message
     if (ENVIRONMENT == "local") {
         return File::write(APP_PATH . "/email.html", "To: " . $emailTo . "\nFrom: " . $emailFrom . "\nSubject: " . $subject . "\nAttachment: " . $filename . "\n\n" . $message);
     }
     // Send the email
     if (!mail($emailTo, $subject, "", $header)) {
         Alert::error("Email", "Email was not sent properly.", 4);
         return false;
     }
     return true;
 }
Example #11
0
<?php

/*
|--------------------------------------------------------------------------
| Application HTML Macros
|--------------------------------------------------------------------------
|
| Here is where you can register your HTML macros.
|
*/
// Show validation errors wrapped in bootstrap style
HTML::macro('validationErrors', function () {
    $errors = Session::get('errors');
    if ($errors) {
        return Alert::error('<strong>The following errors occurred</strong>' . HTML::ul($errors->all(':message')));
    }
});
// Show "Create" button for a resource
HTML::macro('resourceCreate', function ($resourceName, $buttonValue) {
    if (Authority::can('create', $resourceName)) {
        return Button::link(URL::route($resourceName . '.create'), $buttonValue);
    }
});
// Show "Edit" button for a specific resource
HTML::macro('resourceUpdate', function ($resourceName, $resourceItem, $buttonValue) {
    $resourceItemId = is_object($resourceItem) ? $resourceItem->id : $resourceItem;
    if (Authority::can('update', $resourceName, $resourceItem)) {
        return Button::link(URL::route($resourceName . '.edit', array($resourceName => $resourceItemId)), $buttonValue);
    }
});
// Show "Delete" button for a specific resource
}
// Check if the standard user is properly configured after POST values were used
if (Database::initialize($dbName)) {
    Alert::success("DB User", "The database user has access to the `" . $dbName . "` database!");
} else {
    Alert::error("DB User", "The `" . $dbName . "` database does not exist, or the user does not have access to it.");
    $userAccess = false;
}
// Check if the admin user is properly configured after POST values were used
if (Database::initRoot($dbName)) {
    Alert::success("DB Admin", "The administrative database user has access to the `" . $dbName . "` database!");
} else {
    if ($userAccess) {
        Alert::error("DB Admin", "The `" . $dbName . "` database exists, but you do not have administrative privileges.");
    } else {
        Alert::error("DB Admin", "The `" . $dbName . "` database does not exist, or you do not have administrative privileges.");
    }
}
// If everything is successful:
if (Validate::pass()) {
    // Check if the form was submitted (to continue to the next page)
    if (Form::submitted("install-db-connect")) {
        header("Location: /install/classes-core");
        exit;
    }
}
// Run Global Script
require dirname(ROUTE_SECOND_PATH) . "/includes/install_global.php";
// Display the Header
require HEADER_PATH;
echo Alert::display();
 /**
  * Main function
  */
 public static function main()
 {
     // Array of forbidden types
     $forbidden_types = array('html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'php', 'phtml', 'php3', 'php4', 'php5', 'phps', 'shtml', 'jhtml', 'pl', 'py', 'cgi', 'sh', 'ksh', 'bsh', 'c', 'htaccess', 'htpasswd', 'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl', 'empty');
     // Array of image types
     $image_types = array('jpg', 'png', 'bmp', 'gif', 'tif');
     // Get Site url
     $site_url = Option::get('siteurl');
     // Init vars
     if (Request::get('path')) {
         $path = Request::get('path');
     } else {
         $path = 'uploads/';
     }
     // Add slash if not exists
     if (substr($path, -1, 1) != '/') {
         $path .= '/';
         Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
     }
     // Upload corectly!
     if ($path == 'uploads' || $path == 'uploads//') {
         $path = 'uploads/';
         Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
     }
     // Only 'uploads' folder!
     if (strpos($path, 'uploads') === false) {
         $path = 'uploads/';
         Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
     }
     // Set default path value if path is empty
     if ($path == '') {
         $path = 'uploads/';
         Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
     }
     $files_path = ROOT . DS . 'public' . DS . $path;
     $current = explode('/', $path);
     // Delete file
     // -------------------------------------
     if (Request::get('id') == 'filesmanager' && Request::get('delete_file')) {
         if (Security::check(Request::get('token'))) {
             File::delete($files_path . Request::get('delete_file'));
             if (!is_file($files_path . Request::get('delete_file'))) {
                 Notification::set('success', __('File was deleted', 'filesmanager'));
             } else {
                 Notification::set('error', __('File was not deleted', 'filesmanager'));
             }
             Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Delete dir
     // -------------------------------------
     if (Request::get('id') == 'filesmanager' && Request::get('delete_dir')) {
         if (Security::check(Request::get('token'))) {
             Dir::delete($files_path . Request::get('delete_dir'));
             if (!is_dir($files_path . Request::get('delete_dir'))) {
                 Notification::set('success', __('Directory was deleted', 'filesmanager'));
             } else {
                 Notification::set('error', __('Directory was not deleted', 'filesmanager'));
             }
             Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Rename file/dir
     // -------------------------------------
     if (Request::post('rename_type')) {
         if (Security::check(Request::post('csrf'))) {
             $rename_type = Request::post('rename_type');
             $rename_from = Request::post('rename_from');
             $rename_to = Request::post('rename_to');
             if (empty($rename_to)) {
                 Notification::set('error', __('Can not be empty', 'filesmanager'));
                 Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
             }
             $ext = $rename_type === 'file' ? '.' . File::ext($rename_from) : '';
             $rename_to = $files_path . Security::safeName($rename_to, null, false) . $ext;
             if (is_dir($rename_to)) {
                 Notification::set('error', __('Directory exists', 'filesmanager'));
                 Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
             }
             if (is_file($rename_to)) {
                 Notification::set('error', __('File exists', 'filesmanager'));
                 Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
             }
             $success = rename($files_path . $rename_from, $rename_to);
             if ($success) {
                 Notification::set('success', __('Renamed successfully', 'filesmanager'));
             } else {
                 Notification::set('error', __('Failure', 'filesmanager'));
             }
             Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Upload file
     // -------------------------------------
     if (Request::post('upload_file')) {
         if (Security::check(Request::post('csrf'))) {
             $error = false;
             if ($_FILES['file']) {
                 if (!in_array(File::ext($_FILES['file']['name']), $forbidden_types)) {
                     $filepath = $files_path . Security::safeName(basename($_FILES['file']['name'], File::ext($_FILES['file']['name'])), null, false) . '.' . File::ext($_FILES['file']['name']);
                     $uploaded = move_uploaded_file($_FILES['file']['tmp_name'], $filepath);
                     if ($uploaded !== false && is_file($filepath)) {
                         Notification::set('success', __('File was uploaded', 'filesmanager'));
                     } else {
                         $error = 'File was not uploaded';
                     }
                 } else {
                     $error = 'Forbidden file type';
                 }
             } else {
                 $error = 'File was not uploaded';
             }
             if ($error) {
                 Notification::set('error', __($error, 'filesmanager'));
             }
             if (Request::post('dragndrop')) {
                 Request::shutdown();
             } else {
                 Request::redirect($site_url . '/admin/index.php?id=filesmanager&path=' . $path);
             }
         } else {
             die('Request was denied because it contained an invalid security token. Please refresh the page and try again.');
         }
     }
     // Create Directory
     // -------------------------------------
     if (Request::post('directory_name')) {
         if (Security::check(Request::post('csrf'))) {
             $abs_path = $files_path . Security::safeName(Request::post('directory_name'), null, false);
             $error = false;
             if (!is_dir($abs_path)) {
                 try {
                     mkdir($abs_path);
                 } catch (Exception $e) {
                     $error = true;
                 }
             } else {
                 $error = true;
             }
             if ($error) {
                 Alert::error(__('Directory was not created', 'filesmanager'));
             } else {
                 Alert::success(__('Directory was created', 'filesmanager'));
             }
         }
     }
     // Get information about current path
     $_list = FilesmanagerAdmin::fdir($files_path);
     $files_list = array();
     // Get files
     if (isset($_list['files'])) {
         foreach ($_list['files'] as $files) {
             $files_list[] = $files;
         }
     }
     $dir_list = array();
     // Get dirs
     if (isset($_list['dirs'])) {
         foreach ($_list['dirs'] as $dirs) {
             if (strpos($dirs, '.') === false && strpos($dirs, '..') === false) {
                 $dir_list[] = $dirs;
             }
         }
     }
     // Display view
     View::factory('box/filesmanager/views/backend/index')->assign('path', $path)->assign('current', $current)->assign('files_list', $files_list)->assign('dir_list', $dir_list)->assign('forbidden_types', $forbidden_types)->assign('image_types', $image_types)->assign('site_url', $site_url)->assign('upload_max_filesize', FilesmanagerAdmin::uploadSize())->assign('files_path', $files_path)->assign('fileuploader', array('uploadUrl' => $site_url . '/admin/index.php?id=filesmanager&path=' . $path, 'csrf' => Security::token(), 'errorMsg' => __('Upload server error', 'filesmanager')))->display();
 }
// Installation Header
require PARENT_APP_PATH . "/includes/install_header.php";
// Run the Form
if (Form::submitted("install-connect-handle")) {
    // Check if all of the input you sent is valid:
    $_POST['handle'] = str_replace("@", "", $_POST['handle']);
    Validate::variable("UniFaction Handle", $_POST['handle'], 1, 22);
    if (Validate::pass()) {
        // Make sure the handle is registered
        if ($response = API_Connect::call(URL::unifaction_com() . "/api/UserRegistered", $_POST['handle'])) {
            Cookie_Server::set("admin-handle", $_POST['handle'], "", 3);
            Alert::saveSuccess("Admin Chosen", "You have designated @" . $_POST['handle'] . " as the admin of your site.");
            header("Location: /install/config-app");
            exit;
        } else {
            Alert::error("Handle Invalid", "That user handle does not exist on UniFaction.");
        }
    }
} else {
    $_POST['handle'] = isset($_POST['handle']) ? Sanitize::variable($_POST['handle']) : "";
}
// Run Global Script
require PARENT_APP_PATH . "/includes/install_global.php";
// Display the Header
require HEADER_PATH;
echo '
<form class="uniform" action="/install/connect-handle" method="post">' . Form::prepare("install-connect-handle");
// Display the Page
echo '
<h1>Installation: Site Admin</h1>
Example #15
0
            <div class="row-fluid">
                <div class="span12 center login-header">
                    <center>{{ HTML::image("assets/img/logo2.png")  }}</center>
                    
                    <h2>{{ trans('messages.welcomeadmin') }}</h2>
                </div><!--/span-->
            </div><!--/row-->
            <br><br><br><br>
            <div class="row-fluid">
                <div class="well span5 center login-box">
                    <div class="alert alert-info">
                        {{ trans('messages.pleaselogin') }}
                    </div>
                    <?php 
if (!is_null(Session::get('status_error'))) {
    echo Alert::error(Session::get('status_error'));
}
?>
                     @if ($errors->has('login'))
                        <div class="alert alert-error">{{ $errors->first('login', ':message') }}</div>
                     @endif
                     <div class="response-login"></div>
                    {{ Former::horizontal_open('admin/login','post',array('class'=>'ajax', 'data-replace' => '.response-login')) }}
                    {{Former::text('username', 'messages.username')->prepend('<i class="icon-fam-user"></i>')->placeholder(('Username'))->autofocus()->required(); }}
                    {{Former::text('password', 'messages.password')->prepend('<i class="icon-fam-key"></i>')->placeholder(('Password'))->type('password')->required();}}
                    {{Form::submit(trans('messages.login'), array('class' => 'btn btn-primary'));}}
                    {{Former::close();}}
                </div><!--/span-->
            </div><!--/row-->
        </div><!--/fluid-row-->
    </div><!--/.fluid-container-->
Example #16
0
 public function handleFilename()
 {
     // Check if the extension used is allowed
     if (!in_array($this->toExtension, $this->allowedExtensions)) {
         Alert::error("Illegal Extension", "That file extension is not allowed.", 8);
         $this->valid = false;
         return false;
     }
     // If the image is provided a unique name (disregards original name)
     if ($this->saveMode == self::MODE_UNIQUE) {
         $saltLen = 4;
         while ($saltLen++ < 11 && $saltLen <= $this->maxFilenameLength) {
             $miscSalt = Security_Hash::random($saltLen, 62);
             if (!File::exists($this->saveDirectory . '/' . $miscSalt . '.' . $this->toExtension)) {
                 $this->filename = $miscSalt;
                 return true;
             }
         }
         Alert::error("File Name", "Ending due to naming availability being overly exhausted.");
         $this->valid = false;
         return false;
     }
     // Check if a file of the same name has been uploaded
     if (File::exists($this->saveDirectory . '/' . $this->filename . '.' . $this->toExtension)) {
         // Switch activity based on the image's save mode
         switch ($this->saveMode) {
             // If the image is to be overwritten
             case self::MODE_OVERWRITE:
                 if (strlen($this->filename) > $this->maxFilenameLength) {
                     Alert::error("File Name Length", "The length of the image's filename has exceeded allowance.", 1);
                     $this->valid = false;
                     return false;
                 }
                 return true;
                 // If the image will be renamed if a naming conflict is caught
             // If the image will be renamed if a naming conflict is caught
             case self::MODE_RENAME:
                 $saltLen = 3;
                 while (true) {
                     $miscSalt = Security_Hash::random($saltLen, 62);
                     if (!File::exists($this->saveDirectory . '/' . substr($this->filename, $this->maxFilenameLength - $saltLen - 1) . '-' . $miscSalt . '.' . $this->toExtension)) {
                         $this->filename .= substr($this->filename, $this->maxFilenameLength - $saltLen - 1) . '-' . $miscSalt;
                         return true;
                     }
                     if ($saltLen++ > 7) {
                         Alert::error("File Name", "Ending due to file's naming convention being too highly consumed.");
                         $this->valid = false;
                         return false;
                     }
                 }
                 return true;
                 // If the image is to be named AS-IS, no changes allowed
             // If the image is to be named AS-IS, no changes allowed
             case self::MODE_STANDARD:
             default:
                 Alert::error("File Name", "A file already exists with that name.");
                 $this->valid = false;
                 return false;
         }
     }
     // Check if the filename is too long
     if (strlen($this->filename) > $this->maxFilenameLength) {
         Alert::error("File Name Length", "The length of the filename has exceeded allowance.", 1);
         $this->valid = false;
         return false;
     }
     return true;
 }
Example #17
0
 public function save($file, $quality = 90)
 {
     // Allow Transparency
     imagesavealpha($this->resource, true);
     // If the save file is valid
     if (!IsSanitized::filepath($file)) {
         Alert::error("Image Path", "The image path is invalid.", 7);
         return false;
     }
     $saveInfo = pathinfo($file);
     if (!isset($saveInfo['basename']) or !isset($saveInfo['dirname']) or !isset($saveInfo['extension'])) {
         Alert::error("Image Path", "The image path is not functioning properly.", 6);
         return false;
     }
     // Make sure the directory exists
     if (!Dir::create($saveInfo['dirname'])) {
         Alert::error("Image Directory", "The image directory cannot be created. Please check permissions.", 4);
         return false;
     }
     // Save the file
     switch ($saveInfo['extension']) {
         case "jpg":
         case "jpeg":
             return imagejpeg($this->resource, $file, $quality);
         case "png":
             return imagepng($this->resource, $file);
         case "gif":
             return imagegif($this->resource, $file);
     }
     return false;
 }
Example #18
0
 /**
  * @param $values
  * @param null $template
  * @param bool $no_matter
  * @return array|bool|mixed
  */
 public static function getShow($values, $template = null, $no_matter = false)
 {
     if (!is_array($values)) {
         $values = array($values);
     }
     if (!$template && count($values) == 1) {
         return is_array($values[0]) ? $values[0][0] ? $values[0][0] : (is_array($values[0][1]) ? $values[0][1][0] ? $values[0][1][0] : $values[0][1][1] : $values[0][1]) : $values[0];
     } elseif (!$template && count($values) > 1) {
         return Alert::error('Для данного использования необходим шаблон');
     }
     $access = true;
     $replacements = array();
     foreach ($values as $v => $key) {
         if (!$key && !$no_matter) {
             $access = false;
         } else {
             $setKey = $v != "" ? $v : "a" . $v;
             if (is_array($key) && !USE_TWIG) {
                 if ($key[0] != '') {
                     $replacements[$setKey] = $key[0];
                 } else {
                     $replacements[$setKey] = $key[1];
                 }
             } else {
                 $replacements[$setKey] = $key;
             }
         }
     }
     if ($access) {
         if (USE_TWIG) {
             global $twig;
             return $twig->render($template, $replacements);
         } else {
             return preg_replace_callback('/:\\w+/', function ($matches) use(&$replacements) {
                 return array_shift($replacements);
             }, $template);
         }
     } else {
         return false;
     }
 }
 public static function verifySchemaColumn($columnRules, $valueToSet, $column)
 {
     // Prepare Values
     $columnTitle = ucwords(str_replace("_", " ", $column));
     $strLen = strlen($valueToSet);
     // Each schema column's first element is a type.
     // Based on which type the column is, we'll modify the behavior.
     switch ($columnRules[0]) {
         ### Strings and Text ###
         case "string":
         case "text":
             // Identify all string-related form variables
             $minLength = isset($columnRules[1]) ? (int) $columnRules[1] : 0;
             $maxLength = (isset($columnRules[2]) and $columnRules[2]) ? (int) $columnRules[2] : ($columnRules[0] == "text" ? null : 250);
             // Make sure the data submitted is within the allowed character lengths
             if ($strLen < $minLength) {
                 return Alert::error($columnTitle . ' Length', $columnTitle . " must be at least " . $minLength . " characters.");
             } else {
                 if ($maxLength !== null and $strLen > $maxLength) {
                     return Alert::error($columnTitle . ' Length', $columnTitle . " cannot exceed " . $maxLength . " characters.");
                 }
             }
             // If there is a sanitize method, run the appropriate checks
             if ($sanitizeMethod = isset($columnRules[3]) ? $columnRules[3] : '') {
                 $extraChars = isset($columnRules[4]) ? $columnRules[4] : '';
                 if (!call_user_func(["IsSanitized", $sanitizeMethod], $valueToSet, $extraChars)) {
                     return Alert::error($columnTitle . ' Invalid', $columnTitle . " contains illegal characters.");
                 }
             }
             return true;
             ### Integers ###
         ### Integers ###
         case "tinyint":
             // 256
         // 256
         case "smallint":
             // 65k
         // 65k
         case "mediumint":
         case "int":
         case "bigint":
             // Identify all string-related form variables
             $minRange = isset($columnRules[1]) ? (int) $columnRules[1] : null;
             $maxRange = isset($columnRules[2]) ? (int) $columnRules[2] : null;
             $maxLength = self::getLengthOfNumberType($columnRules[0], $minRange, $maxRange);
             // Make sure the value is between the minimum and maximum ranges allowed
             if ($valueToSet < $minRange) {
                 return Alert::error($columnTitle . ' Range', $columnTitle . " cannot be less than " . $minRange . ".");
             } else {
                 if ($maxLength !== null and $strLen > $maxLength) {
                     return Alert::error($columnTitle . ' Range', $columnTitle . " cannot be greater than " . $maxRange . " characters.");
                 }
             }
             return true;
             ### Floats ###
         ### Floats ###
         case "float":
         case "double":
             // Identify all string-related form variables
             $minRange = isset($columnRules[1]) ? (double) $columnRules[1] : null;
             $maxRange = isset($columnRules[2]) ? (double) $columnRules[2] : null;
             $maxLength = self::getLengthOfNumberType($columnRules[0], $minRange, $maxRange);
             // Make sure the value is between the minimum and maximum ranges allowed
             if ($valueToSet < $minRange) {
                 return Alert::error($columnTitle . ' Range', $columnTitle . " cannot be less than " . $minRange . ".");
             } else {
                 if ($maxLength !== null and $strLen > $maxLength) {
                     return Alert::error($columnTitle . ' Range', $columnTitle . " cannot be greater than " . $maxRange . " characters.");
                 }
             }
             return true;
             ### Booleans ###
         ### Booleans ###
         case "bool":
         case "boolean":
             // Make sure the value is a boolean
             if ($valueToSet !== 0 or $valueToSet !== 1) {
                 return Alert::error($columnTitle . ' Boolean', $columnTitle . " must be a boolean value (0 or 1).");
             }
             return true;
             ### Enumerators ###
         ### Enumerators ###
         case "enum-number":
             // Get the available list of enumerators
             // These will have a numeric counter associated with each value
             $enums = array_slice($columnRules, 1);
             if ($valueToSet < 0 or $valueToSet > count($enums)) {
                 return Alert::error($columnTitle . ' Enumerator', $columnTitle . " must be selected from the available options.");
             }
             return true;
         case "enum-string":
             // Get the available list of enumerators
             $enums = array_slice($columnRules, 1);
             if (!in_array($valueToSet, $enums)) {
                 return Alert::error($columnTitle . ' Enumerator', $columnTitle . " must be selected from the available options.");
             }
             return true;
     }
     // If we reach this point, something was wrong with the column rules formatting.
     return false;
 }
Example #20
0
 public static function confirmation($name, $bool)
 {
     if (!$bool) {
         Alert::error($name, "You must confirm " . $name);
     }
 }
 public function validate()
 {
     // Check if the uploaded file is actually an image
     if (!in_array($this->mimeType, $this->allowedMimes)) {
         Alert::error("Image Type", "You may not upload that type of image.", 8);
     }
     // Check the file size of the image
     if ($this->filesize <= 0 or $this->filesize > $this->maxFileSize) {
         Alert::error("Image File Size", "The file size must be smaller than " . $this->maxFileSize . " bytes.", 3);
     }
     // Check the minimum and maximum width of the image
     if ($this->minWidth == $this->maxWidth and $this->width != $this->minWidth) {
         Alert::error("Image Width", "The image must be " . $this->minWidth . " pixels in width.");
     } else {
         if ($this->width < $this->minWidth) {
             Alert::error("Image Width", "The image must be " . $this->minWidth . " pixels or greater in width.");
         } else {
             if ($this->width > $this->maxWidth) {
                 Alert::error("Image Width", "The image must be " . $this->maxWidth . " pixels or less in width.");
             }
         }
     }
     // Check the minimum and maximum height of the image
     if ($this->minHeight == $this->maxHeight and $this->height != $this->minHeight) {
         Alert::error("Image Height", "The image must be " . $this->minHeight . " pixels in height.");
     } else {
         if ($this->height < $this->minHeight) {
             Alert::error("Image Height", "The image must be " . $this->minHeight . " pixels or greater in height.");
         } else {
             if ($this->height > $this->maxHeight) {
                 Alert::error("Image Height", "The image must be " . $this->maxHeight . " pixels or less in height.");
             }
         }
     }
     // Set invalid if there are any errors
     if (Alert::hasErrors()) {
         $this->valid = false;
         return false;
     }
     return true;
 }
Example #22
0
        // Create the account
        if ($uniID) {
            $pass = Database::query("INSERT INTO users_handles (handle, uni_id) VALUES (?, ?)", array($_POST['handle'], $uniID));
            if (Database::endTransaction($pass)) {
                // Create the ProfilePic for this Account
                $packet = array("uni_id" => $uniID, "title" => $_POST['display_name']);
                $response = API_Connect::to("profile_picture", "SetDefaultPic", $packet);
                // Reset Values
                $_POST['handle'] = "";
                $_POST['display_name'] = "";
                $_POST['email'] = "";
                $_POST['password'] = "";
            }
        } else {
            Database::endTransaction(false);
            Alert::error("Process Error", "An error has occurred while processing this registration.", 1);
        }
    }
} else {
    $_POST['email'] = isset($_POST['email']) ? Sanitize::email($_POST['email']) : "";
    $_POST['password'] = isset($_POST['password']) ? Sanitize::safeword($_POST['password']) : "";
    $_POST['handle'] = isset($_POST['handle']) ? Sanitize::variable($_POST['handle']) : "";
    $_POST['display_name'] = isset($_POST['display_name']) ? Sanitize::safeword($_POST['display_name'], ' ') : "";
}
// Run Header
require SYS_PATH . "/controller/includes/admin_header.php";
// Display the Editing Form
echo '
<h3>Add a New User</h3>
<form class="uniform" action="/admin/AppAccount/Add User" method="post">' . Form::prepare("add-user-uni6") . '