当前位置: 首页>>代码示例>>PHP>>正文


PHP Error::add方法代码示例

本文整理汇总了PHP中Error::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::add方法的具体用法?PHP Error::add怎么用?PHP Error::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Error的用法示例。


在下文中一共展示了Error::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateMediaOperation

 function validateMediaOperation($opType = "ADD", $mediaObject = null)
 {
     $e = new Error();
     // called automatically by the m2 functions that add media, when passed the object
     // opType allows us to distinguish between adding, editing, updating, etc... but most times
     // the same check will work for all operation types
     if ($opType == "UPDATEINFO") {
         if (!User::isAdmin()) {
             $e->add("Only an admin user may edit media areas.");
             return $e;
         }
     }
     if ($opType == "RESCAN") {
         if (!User::isAdmin()) {
             $e->add("Only an admin user may rescan media.");
             return $e;
         }
     }
     if (!$this->areaObject->isGeneralMedia()) {
         $e->add("You cannot directly move or edit an area that is not generally accessible.");
         return $e;
     } else {
         if (!User::isAdmin()) {
             $e->add("Only an admin user may modify general media.");
             return $e;
         }
     }
     // if we get this far...
     return true;
 }
开发者ID:pinecreativelabs,项目名称:audition,代码行数:30,代码来源:general_media.php

示例2: __construct

 /**
  * constructor
  * This should be called
  */
 public function __construct($id = null, $cached = true)
 {
     $sid = session_id();
     if (is_null($id)) {
         $this->reset();
         if ($cached) {
             $data = serialize($this->_state);
             $sql = 'INSERT INTO `tmp_browse` (`sid`, `data`) ' . 'VALUES(?, ?)';
             Dba::write($sql, array($sid, $data));
             $this->id = Dba::insert_id();
         } else {
             $this->id = 'nocache';
         }
         return true;
     }
     $this->id = $id;
     $sql = 'SELECT `data` FROM `tmp_browse` ' . 'WHERE `id` = ? AND `sid` = ?';
     $db_results = Dba::read($sql, array($id, $sid));
     if ($results = Dba::fetch_assoc($db_results)) {
         $this->_state = unserialize($results['data']);
         return true;
     }
     Error::add('browse', T_('Browse not found or expired, try reloading the page'));
     return false;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:29,代码来源:query.class.php

示例3: set

 /**
  * set
  *
  * This sets config values.
  */
 public static function set($name, $value, $clobber = false)
 {
     if (isset(self::$_global[$name]) && !$clobber) {
         debug_event('Config', "Tried to overwrite existing key {$name} without setting clobber", 5);
         Error::add('Config Global', sprintf(T_('Trying to clobber \'%s\' without setting clobber'), $name));
         return false;
     }
     self::$_global[$name] = $value;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:14,代码来源:ampconfig.class.php

示例4: getAVAreaObject

 function getAVAreaObject()
 {
     if ($this->av_area_id > 0) {
         $ma = MediaArea::get($this->av_area_id);
         return $ma;
     } else {
         $e = new Error();
         $e->add("An administrator has not yet registered this track for audio or videos.");
         return $e;
     }
 }
开发者ID:pinecreativelabs,项目名称:audition,代码行数:11,代码来源:release_tracks.php

示例5: debug_event

            debug_event('Login', scrub_out($username) . ' is already logged in from ' . $session_ip . ' and attempted to login from ' . $current_ip, '1');
        }
        // if logged in multiple times
    } elseif (AmpConfig::get('auto_create') && $auth['success'] && !$user->username) {
        /* This is run if we want to autocreate users who don't
           exist (useful for non-mysql auth) */
        $access = AmpConfig::get('auto_user') ? User::access_name_to_level(AmpConfig::get('auto_user')) : '5';
        $name = $auth['name'];
        $email = $auth['email'];
        $website = $auth['website'];
        /* Attempt to create the user */
        if (User::create($username, $name, $email, $website, hash('sha256', mt_rand()), $access)) {
            $user = User::get_from_username($username);
        } else {
            $auth['success'] = false;
            Error::add('general', T_('Unable to create local account'));
        }
    }
    // End if auto_create
    // This allows stealing passwords validated by external means
    // such as LDAP
    if (AmpConfig::get('auth_password_save') && $auth['success'] && isset($password)) {
        $user->update_password($password);
    }
}
/* If the authentication was a success */
if (isset($auth) && $auth['success'] && isset($user)) {
    // $auth->info are the fields specified in the config file
    //   to retrieve for each user
    Session::create($auth);
    // Not sure if it was me or php tripping out,
开发者ID:nioc,项目名称:ampache,代码行数:31,代码来源:login.php

示例6: update_360051

 /**
  * update_360051
  *
  * Copy default .htaccess configurations
  */
 public static function update_360051()
 {
     require_once AmpConfig::get('prefix') . '/lib/install.lib.php';
     if (!install_check_server_apache()) {
         debug_event('update', 'Not using Apache, update 360051 skipped.', '5');
         return true;
     }
     $htaccess_play_file = AmpConfig::get('prefix') . '/play/.htaccess';
     $htaccess_rest_file = AmpConfig::get('prefix') . '/rest/.htaccess';
     $htaccess_channel_file = AmpConfig::get('prefix') . '/channel/.htaccess';
     $ret = true;
     if (!is_readable($htaccess_play_file)) {
         $created = false;
         if (check_htaccess_play_writable()) {
             if (!install_rewrite_rules($htaccess_play_file, AmpConfig::get('raw_web_path'), false)) {
                 Error::add('general', T_('File copy error.'));
             } else {
                 $created = true;
             }
         }
         if (!$created) {
             Error::add('general', T_('Cannot copy default .htaccess file.') . ' Please copy <b>' . $htaccess_play_file . '.dist</b> to <b>' . $htaccess_play_file . '</b>.');
             $ret = false;
         }
     }
     if (!is_readable($htaccess_rest_file)) {
         $created = false;
         if (check_htaccess_rest_writable()) {
             if (!install_rewrite_rules($htaccess_rest_file, AmpConfig::get('raw_web_path'), false)) {
                 Error::add('general', T_('File copy error.'));
             } else {
                 $created = true;
             }
         }
         if (!$created) {
             Error::add('general', T_('Cannot copy default .htaccess file.') . ' Please copy <b>' . $htaccess_rest_file . '.dist</b> to <b>' . $htaccess_rest_file . '</b>.');
             $ret = false;
         }
     }
     if (!is_readable($htaccess_channel_file)) {
         $created = false;
         if (check_htaccess_channel_writable()) {
             if (!install_rewrite_rules($htaccess_channel_file, AmpConfig::get('raw_web_path'), false)) {
                 Error::add('general', T_('File copy error.'));
             } else {
                 $created = true;
             }
         }
         if (!$created) {
             Error::add('general', T_('Cannot copy default .htaccess file.') . ' Please copy <b>' . $htaccess_channel_file . '.dist</b> to <b>' . $htaccess_channel_file . '</b>.');
             $ret = false;
         }
     }
     return $ret;
 }
开发者ID:nioc,项目名称:ampache,代码行数:60,代码来源:update.class.php

示例7: switch

     switch (AmpConfig::get('auto_user')) {
         case 'admin':
             $access = '100';
             break;
         case 'user':
             $access = '25';
             break;
         case 'guest':
         default:
             $access = '5';
             break;
     }
     // auto-user level
     $new_user = User::create($username, $fullname, $email, $website, $pass1, $access, AmpConfig::get('admin_enable_required'));
     if (!$new_user) {
         Error::add('duplicate_user', T_("Error: Insert Failed"));
         require_once AmpConfig::get('prefix') . '/templates/show_user_registration.inc.php';
         break;
     }
     if (!AmpConfig::get('admin_enable_required') && !AmpConfig::get('user_no_email_confirm')) {
         $client = new User($new_user);
         $validation = md5(uniqid(rand(), true));
         $client->update_validation($validation);
         Registration::send_confirmation($username, $fullname, $email, $website, $pass1, $validation);
     }
     require_once AmpConfig::get('prefix') . '/templates/show_registration_confirmation.inc.php';
     break;
 case 'show_add_user':
 default:
     require_once AmpConfig::get('prefix') . '/templates/show_user_registration.inc.php';
     break;
开发者ID:axelsimon,项目名称:ampache,代码行数:31,代码来源:register.php

示例8: update_remote_catalog

 /**
  * update_remote_catalog
  *
  * Pulls the data from a remote catalog and adds any missing songs to the
  * database.
  */
 public function update_remote_catalog()
 {
     $songsadded = 0;
     try {
         $api = $this->createClient();
         if ($api != null) {
             // Get all liked songs
             $songs = json_decode($api->get('me/favorites'));
             if ($songs) {
                 foreach ($songs as $song) {
                     if ($song->streamable == true && $song->kind == 'track') {
                         $data = array();
                         $data['artist'] = $song->user->username;
                         $data['album'] = $data['artist'];
                         $data['title'] = $song->title;
                         $data['year'] = $song->release_year;
                         $data['mode'] = 'vbr';
                         $data['genre'] = explode(' ', $song->genre);
                         $data['comment'] = $song->description;
                         $data['file'] = $song->stream_url . '.mp3';
                         // Always stream as mp3, if evolve => $song->original_format;
                         $data['size'] = $song->original_content_size;
                         $data['time'] = intval($song->duration / 1000);
                         if ($this->check_remote_song($data)) {
                             debug_event('soundcloud_catalog', 'Skipping existing song ' . $data['file'], 5);
                         } else {
                             $data['catalog'] = $this->id;
                             debug_event('soundcloud_catalog', 'Adding song ' . $data['file'], 5, 'ampache-catalog');
                             if (!Song::insert($data)) {
                                 debug_event('soundcloud_catalog', 'Insert failed for ' . $data['file'], 1);
                                 Error::add('general', T_('Unable to Insert Song - %s'), $data['file']);
                                 Error::display('general');
                                 flush();
                             } else {
                                 $songsadded++;
                             }
                         }
                     }
                 }
                 echo "<p>" . T_('Completed updating SoundCloud catalog(s).') . " " . $songsadded . " " . T_('Songs added.') . "</p><hr />\n";
                 flush();
                 // Update the last update value
                 $this->update_last_update();
             } else {
                 echo "<p>" . T_('API Error: cannot get song list.') . "</p><hr />\n";
                 flush();
             }
         } else {
             echo "<p>" . T_('API Error: cannot connect to SoundCloud.') . "</p><hr />\n";
             flush();
         }
     } catch (Exception $ex) {
         echo "<p>" . T_('SoundCloud exception: ') . $ex->getMessage() . "</p><hr />\n";
     }
     return true;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:62,代码来源:soundcloud.catalog.php

示例9: mergeErrors

 function mergeErrors($errorArray)
 {
     $e = new Error();
     foreach ($errorArray as $_e) {
         if (db::isError($_e)) {
             $_error = $_e->_error;
             foreach ($_error as $es) {
                 $e->add($es);
             }
         }
     }
     return $e;
 }
开发者ID:pinecreativelabs,项目名称:audition,代码行数:13,代码来源:db.php

示例10: create

 /**
  * create
  *
  * This creates a new catalog entry and associate it to current instance
  */
 public static function create($data)
 {
     $name = $data['name'];
     $type = $data['type'];
     $rename_pattern = $data['rename_pattern'];
     $sort_pattern = $data['sort_pattern'];
     $insert_id = 0;
     $filename = AmpConfig::get('prefix') . '/modules/catalog/' . $type . '.catalog.php';
     $include = (require_once $filename);
     if ($include) {
         $sql = 'INSERT INTO `catalog` (`name`, `catalog_type`, ' . '`rename_pattern`, `sort_pattern`) VALUES (?, ?, ?, ?)';
         Dba::write($sql, array($name, $type, $rename_pattern, $sort_pattern));
         $insert_id = Dba::insert_id();
         if (!$insert_id) {
             Error::add('general', T_('Catalog Insert Failed check debug logs'));
             debug_event('catalog', 'Insert failed: ' . json_encode($data), 2);
             return false;
         }
         $classname = 'Catalog_' . $type;
         if (!$classname::create_type($insert_id, $data)) {
             $sql = 'DELETE FROM `catalog` WHERE `id` = ?';
             Dba::write($sql, array($insert_id));
             $insert_id = 0;
         }
     }
     return $insert_id;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:32,代码来源:catalog.class.php

示例11: update

 function update($postArray)
 {
     $db = new db();
     $e = new Error();
     if (User::isAdmin()) {
         $genreID = $db->sanitize_to_db($postArray['genreID']);
         if (!$this->isValidGenreID($postArray['genreID'])) {
             $e->add("Invalid genre specified");
         }
         $name = $db->sanitize_to_db($postArray['name']);
         if ($name == '' || $name == null) {
             $e->add("You must specify a name for your band.");
         }
         $managerName = $db->sanitize_to_db($postArray['managerName']);
         $address1 = $db->sanitize_to_db($postArray['address1']);
         $address2 = $db->sanitize_to_db($postArray['address2']);
         $city = $db->sanitize_to_db($postArray['city']);
         $stateProvince = $db->sanitize_to_db($postArray['stateProvince']);
         if ($stateProvince == "??") {
             $stateProvince = $db->sanitize_to_db($postArray['stateProvinceOther']);
         }
         $postalCode = $db->sanitize_to_db($postArray['postalCode']);
         $bio = $db->sanitize_to_db($postArray['bio']);
         $miscellaneous = $db->sanitize_to_db($postArray['miscellaneous']);
         $country = $db->sanitize_to_db($postArray['country']);
         $defaultStateProvince = $db->sanitize_to_db($postArray['defaultStateProvince']);
         if ($defaultStateProvince == "??") {
             $defaultStateProvince = $db->sanitize_to_db($postArray['defaultStateProvince']);
         }
         $defaultCountry = $db->sanitize_to_db($postArray['defaultCountry']);
         $defaultCity = $db->sanitize_to_db($postArray['defaultCity']);
         $description = $db->sanitize_to_db($postArray['description']);
         if ($e->hasErrors()) {
             return $e;
         }
         $q = "delete from Band_Information";
         $r = mysql_query($q);
         if (!$r) {
             return Error::MySQL();
         }
         $q = "insert into Band_Information (name, managerName, address1, address2, city, stateProvince, postalCode, bio, miscellaneous, country, defaultStateProvince, defaultCountry, defaultCity, genreID, description) ";
         $q .= "values ('{$name}', '{$managerName}', '{$address1}', '{$address2}', '{$city}', '{$stateProvince}', '{$postalCode}', '{$bio}', '{$miscellaneous}', '{$country}', '{$defaultStateProvince}', '{$defaultCountry}', '{$defaultCity}', '{$genreID}', '{$description}')";
         $r = mysql_query($q);
         // ping auditionrocks.com
         // aborted attempt at creating an audition directory
         /*
         include_class('xmlrpc');
         $xc = new xmlrpc_client("/ping/", "www.auditionrocks.com");
         $message = new xmlrpcmsg("audition.pingBack", array(
         		new xmlrpcval($_SERVER["HTTP_HOST"] . SITE_WEB_DIRECTORY, "string"),
         		new xmlrpcval($name, "string"),
         		new xmlrpcval($bio, "string"),
         		new xmlrpcval($genreID, "int"),
         		new xmlrpcval($city, "string"),
         		new xmlrpcval($stateProvince, "string"),
         		new xmlrpcval($postalCode, "string"),
         		new xmlrpcval($country, "string"))
         	);
         
         $response = $xc->send($message, 5, "POST");
         */
         if ($r) {
             return true;
         } else {
             return Error::create("An unexplained error occurred when trying to update your information.");
         }
     }
 }
开发者ID:pinecreativelabs,项目名称:audition,代码行数:68,代码来源:band_information.php

示例12: T_

     if (!User::check_username($username)) {
         Error::add('username', T_('Error Username already exists'));
     }
     // Check the mail for correct address formation.
     if (!Mailer::validate_address($email)) {
         Error::add('email', T_('Invalid email address'));
     }
     /* If we've got an error then show add form! */
     if (Error::occurred()) {
         require_once AmpConfig::get('prefix') . '/templates/show_add_user.inc.php';
         break;
     }
     /* Attempt to create the user */
     $user_id = User::create($username, $fullname, $email, $website, $pass1, $access, $state, $city);
     if (!$user_id) {
         Error::add('general', T_("Error: Insert Failed"));
     }
     $user = new User($user_id);
     $user->upload_avatar();
     if ($access == 5) {
         $access = T_('Guest');
     } elseif ($access == 25) {
         $access = T_('User');
     } elseif ($access == 100) {
         $access = T_('Admin');
     }
     /* HINT: %1 Username, %2 Access num */
     show_confirmation(T_('New User Added'), sprintf(T_('%1$s has been created with an access level of %2$s'), $username, $access), AmpConfig::get('web_path') . '/admin/users.php');
     break;
 case 'enable':
     $client = new User($_REQUEST['user_id']);
开发者ID:nioc,项目名称:ampache,代码行数:31,代码来源:users.php

示例13: isset

require_once 'lib/init.php';
$action = isset($_POST['action']) ? $_POST['action'] : "";
switch ($action) {
    case 'send':
        /* Check for posted email */
        $result = false;
        if (isset($_POST['email']) && $_POST['email']) {
            /* Get the email address and the current ip*/
            $email = scrub_in($_POST['email']);
            $current_ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
            $result = send_newpassword($email, $current_ip);
        }
        if ($result) {
            Error::add('general', T_('Password has been sent'));
        } else {
            Error::add('general', T_('Password has not been sent'));
        }
        require AmpConfig::get('prefix') . '/templates/show_login_form.inc.php';
        break;
    default:
        require AmpConfig::get('prefix') . '/templates/show_lostpassword_form.inc.php';
}
function send_newpassword($email, $current_ip)
{
    /* get the Client and set the new password */
    $client = User::get_from_email($email);
    if ($client && $client->email == $email) {
        $newpassword = generate_password(6);
        $client->update_password($newpassword);
        $mailer = new Mailer();
        $mailer->set_default_sender();
开发者ID:axelsimon,项目名称:ampache,代码行数:31,代码来源:lostpassword.php

示例14: install_create_account

/**
 * install_create_account
 * this creates your initial account and sets up the preferences for the -1 user and you
 */
function install_create_account($username, $password, $password2)
{
    if (!strlen($username) or !strlen($password)) {
        Error::add('general', T_('No Username/Password specified'));
        return false;
    }
    if ($password !== $password2) {
        Error::add('general', T_('Passwords do not match'));
        return false;
    }
    if (!Dba::check_database()) {
        Error::add('general', sprintf(T_('Database connection failed: %s'), Dba::error()));
        return false;
    }
    if (!Dba::check_database_inserted()) {
        Error::add('general', sprintf(T_('Database select failed: %s'), Dba::error()));
        return false;
    }
    $username = Dba::escape($username);
    $password = Dba::escape($password);
    $insert_id = User::create($username, 'Administrator', '', '', $password, '100');
    if (!$insert_id) {
        Error::add('general', sprintf(T_('Administrative user creation failed: %s'), Dba::error()));
        return false;
    }
    // Fix the system users preferences
    User::fix_preferences('-1');
    return true;
}
开发者ID:nioc,项目名称:ampache,代码行数:33,代码来源:install.lib.php

示例15: _clean_chunk

 /**
  * _clean_chunk
  * This is the clean function, its broken into
  * said chunks to try to save a little memory
  */
 private function _clean_chunk($media_type, $chunk, $chunk_size)
 {
     debug_event('clean', "Starting chunk {$chunk}", 5);
     $dead = array();
     $count = $chunk * $chunk_size;
     $sql = "SELECT `id`, `file` FROM `{$media_type}` " . "WHERE `catalog`='{$this->id}' LIMIT {$count},{$chunk_size}";
     $db_results = Dba::read($sql);
     while ($results = Dba::fetch_assoc($db_results)) {
         debug_event('clean', 'Starting work on ' . $results['file'] . '(' . $results['id'] . ')', 5);
         $count++;
         if (UI::check_ticker()) {
             $file = str_replace(array('(', ')', '\''), '', $results['file']);
             UI::update_text('clean_count_' . $this->id, $count);
             UI::update_text('clean_dir_' . $this->id, scrub_out($file));
         }
         $file_info = filesize($results['file']);
         if (!file_exists($results['file']) || $file_info < 1) {
             debug_event('clean', 'File not found or empty: ' . $results['file'], 5);
             Error::add('general', sprintf(T_('Error File Not Found or 0 Bytes: %s'), $results['file']));
             // Store it in an array we'll delete it later...
             $dead[] = $results['id'];
         } else {
             if (!Core::is_readable(Core::conv_lc_file($results['file']))) {
                 debug_event('clean', $results['file'] . ' is not readable, but does exist', 1);
             }
         }
     }
     return $dead;
 }
开发者ID:axelsimon,项目名称:ampache,代码行数:34,代码来源:local.catalog.php


注:本文中的Error::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。