Esempio n. 1
0
 /**
  * create
  * This is a static function that takes a key'd array for input
  * and if everything is good creates the object.
  */
 public static function create(array $data)
 {
     // Make sure we've got a name
     if (!strlen($data['name'])) {
         Error::add('name', T_('Name Required'));
     }
     $allowed_array = array('https', 'http', 'mms', 'mmsh', 'mmsu', 'mmst', 'rtsp', 'rtmp');
     $elements = explode(":", $data['url']);
     if (!in_array($elements['0'], $allowed_array)) {
         Error::add('url', T_('Invalid URL must be http:// or https://'));
     }
     // Make sure it's a real catalog
     $catalog = Catalog::create_from_id($data['catalog']);
     if (!$catalog->name) {
         Error::add('catalog', T_('Invalid Catalog'));
     }
     if (Error::occurred()) {
         return false;
     }
     // If we've made it this far everything must be ok... I hope
     $sql = "INSERT INTO `live_stream` (`name`,`site_url`,`url`,`catalog`,`codec`) " . "VALUES (?, ?, ?, ?, ?)";
     $db_results = Dba::write($sql, array($data['name'], $data['site_url'], $data['url'], $catalog->id, $data['codec']));
     return $db_results;
 }
Esempio n. 2
0
 }
 // Check the mail for correct address formation.
 if (!Mailer::validate_address($email)) {
     Error::add('email', T_('Invalid email address'));
 }
 if (!$pass1) {
     Error::add('password', T_("You must enter a password"));
 }
 if ($pass1 != $pass2) {
     Error::add('password', T_("Your passwords do not match"));
 }
 if (!User::check_username($username)) {
     Error::add('duplicate_user', T_("Error Username already exists"));
 }
 // If we've hit an error anywhere up there break!
 if (Error::occurred()) {
     require_once AmpConfig::get('prefix') . '/templates/show_user_registration.inc.php';
     break;
 }
 /* Attempt to create the new user */
 $access = '5';
 switch (AmpConfig::get('auto_user')) {
     case 'admin':
         $access = '100';
         break;
     case 'user':
         $access = '25';
         break;
     case 'guest':
     default:
         $access = '5';
Esempio n. 3
0
 /**
  * update
  * This function is an all encompasing update function that
  * calls the mini ones does all the error checking and all that
  * good stuff
  */
 public function update(array $data)
 {
     if (empty($data['username'])) {
         Error::add('username', T_('Error Username Required'));
     }
     if ($data['password1'] != $data['password2'] and !empty($data['password1'])) {
         Error::add('password', T_("Error Passwords don't match"));
     }
     if (Error::occurred()) {
         return false;
     }
     if (!isset($data['fullname_public'])) {
         $data['fullname_public'] = false;
     }
     foreach ($data as $name => $value) {
         if ($name == 'password1') {
             $name = 'password';
         } else {
             $value = scrub_in($value);
         }
         switch ($name) {
             case 'password':
             case 'access':
             case 'email':
             case 'username':
             case 'fullname':
             case 'fullname_public':
             case 'website':
             case 'state':
             case 'city':
                 if ($this->{$name} != $value) {
                     $function = 'update_' . $name;
                     $this->{$function}($value);
                 }
                 break;
             case 'clear_stats':
                 Stats::clear($this->id);
                 break;
             default:
                 // Rien a faire
                 break;
         }
     }
     return $this->id;
 }
Esempio n. 4
0
     if (!Error::occurred()) {
         $url = AmpConfig::get('web_path') . '/admin/access.php';
         show_confirmation(T_('Added'), T_('Your new Access Control List(s) have been created'), $url);
     } else {
         $action = 'show_add_' . $_POST['type'];
         require_once AmpConfig::get('prefix') . '/templates/show_add_access.inc.php';
     }
     break;
 case 'update_record':
     if (!Core::form_verify('edit_acl')) {
         UI::access_denied();
         exit;
     }
     $access = new Access($_REQUEST['access_id']);
     $access->update($_POST);
     if (!Error::occurred()) {
         show_confirmation(T_('Updated'), T_('Access List Entry updated'), AmpConfig::get('web_path') . '/admin/access.php');
     } else {
         $access->format();
         require_once AmpConfig::get('prefix') . '/templates/show_edit_access.inc.php';
     }
     break;
 case 'show_add_current':
 case 'show_add_rpc':
 case 'show_add_local':
 case 'show_add_advanced':
     $action = $_REQUEST['action'];
     require_once AmpConfig::get('prefix') . '/templates/show_add_access.inc.php';
     break;
 case 'show_edit_record':
     $access = new Access($_REQUEST['access_id']);
Esempio n. 5
0
 public static function create(array $data)
 {
     $subject = trim(strip_tags($data['subject']));
     $message = trim(strip_tags($data['message']));
     if (empty($subject)) {
         Error::add('subject', T_('Error: Subject Required'));
     }
     $to_user = User::get_from_username($data['to_user']);
     if (!$to_user->id) {
         Error::add('to_user', T_('Error: Unknown user'));
     }
     if (!Error::occurred()) {
         $from_user = $data['from_user'] ?: $GLOBALS['user']->id;
         $creation_date = $data['creation_date'] ?: time();
         $is_read = $data['is_read'] ?: 0;
         $sql = "INSERT INTO `user_pvmsg` (`subject`, `message`, `from_user`, `to_user`, `creation_date`, `is_read`) " . "VALUES (?, ?, ?, ?, ?, ?)";
         if (Dba::write($sql, array($subject, $message, $from_user, $to_user->id, $creation_date, $is_read))) {
             $insert_id = Dba::insert_id();
             // Never send email in case of user impersonation
             if (!isset($data['from_user']) && $insert_id) {
                 if (Preference::get_by_user($to_user->id, 'notify_email')) {
                     if (!empty($to_user->email)) {
                         $mailer = new Mailer();
                         $mailer->set_default_sender();
                         $mailer->recipient = $to_user->email;
                         $mailer->recipient_name = $to_user->fullname;
                         $mailer->subject = "[" . T_('Private Message') . "] " . $subject;
                         $mailer->message = sprintf(T_("You just received a new private message from %s.\n\n\n        ----------------------\n        %s\n        ----------------------\n\n        %s\n        "), $GLOBALS['user']->fullname, $message, AmpConfig::get('web_path') . "/pvmsg.php?action=show&pvmsg_id=" . $insert_id);
                         $mailer->send();
                     }
                 }
             }
             return $insert_id;
         }
     }
     return false;
 }