Пример #1
0
<?php

$response = array('valid' => false, 'message' => 'This "user" does not exist.');
if (isset($_POST['user'])) {
    $userFactory = new UserFactory(DataStorage::instance());
    $user = $userFactory->loadUser($_POST['user']);
    if ($user) {
        // User name is registered on another account
        $response = array('valid' => false, 'message' => 'This user name is already registered.');
    } else {
        // User name is available
        $response = array('valid' => true);
    }
}
echo json_encode($response);
Пример #2
0
 public static function fileBrowser($type)
 {
     $tinyMCE = new TinyMCE();
     global $smarty;
     $smarty->assign('type', $type);
     if (@(!is_null($_POST['uploadsubmit']))) {
         if (!empty($_FILES['filebrowser_uploadedfile']['name'])) {
             if ($_POST['uploadtype'] == 'image') {
                 $newFile = new Image();
                 $newFile->insert($_FILES['filebrowser_uploadedfile']);
                 $smarty->assign('type', 'image');
             } else {
                 $newFile = new DataStorage();
                 $newFile->insert($_FILES['filebrowser_uploadedfile']);
                 $newFile->save();
             }
         }
     }
     $smarty->template_dir = SITE_ROOT . '/cms/templates';
     $smarty->addJS($tinyMCE->basepath . '/tiny_mce/tiny_mce_popup.js');
     $smarty->addJS($tinyMCE->basepath . '/tiny_mce/utils/mctabs.js');
     $smarty->addCSS($tinyMCE->basepath . '/tiny_mce/themes/advanced/skins/default/dialog.css');
     $smarty->addCSS('/css/tiny_mce_filebrowser.css');
     switch ($type) {
         case 'file':
             $smarty->assign('files', DataStorage::search());
             break;
         default:
             $smarty->assign('images', DataStorage::getImagesList());
             break;
     }
     return $smarty->render('filebrowser.tpl');
 }