private static function show($error_message, $hidden_message) { $error_view_path = getcwd() . "/system/Pages/error.php"; if (file_exists($error_view_path)) { include $error_view_path; } else { Error::display('VIEW_NOT_FOUND'); } }
public function form($id = 0) { $data = array(); if ($id > 0) { $memoir = $this->memoir->get(array('id' => $id, 'user_id' => $this->user['id'])); if ($memoir) { $this->_render('Memoir/form', array('memoir' => $memoir)); } else { Error::display('NOT_FOUND'); } } else { $this->_render('Memoir/form', $data); } }
/** * Read lines from file * * @param $name * @param mixed|string $code * @return mixed */ public function read($name, $code = LANGUAGE_CODE) { /** lang file */ $file = APPPATH . "Language" . DIRECTORY_SEPARATOR . "{$code}" . DIRECTORY_SEPARATOR . "{$name}.php"; /** check if is readable */ if (is_readable($file)) { /** require file */ return include $file; } else { /** display error */ echo Error::display("Could not load language file '{$code}/{$name}.php'"); die; } }
public function model($model) { $model_path = MODELS_PATH . ucfirst($model) . ".php"; if (file_exists($model_path)) { /* If the model exists, the model will be included and instantiated. * That instance is passed into a new property of a the caller class. * The property name will be the same as model name. */ include_once $model_path; $this->caller->{$model} = new $model(); } else { Error::display('MODEL_NOT_FOUND', "The model '" . ucfirst($model) . "' was not found!"); } }
/** * Get lang for views. * * @param string $value this is "word" value from language file * @param string $name name of file with language * @param string $code optional, language code * * @return string */ public static function show($value, $name, $code = LANGUAGE_CODE) { /** lang file */ $fileLanguage = DIR_LANGUAGE . $path . '/' . $cod . '.php'; /** check if is readable */ if (is_readable($fileLanguage)) { /** require file */ $array = (include $fileLanguage); } else { /** display error */ echo Error::display("Could not load language file '{$code}/{$name}.php'"); die; } if (!empty($array[$value])) { return $array[$value]; } else { return $value; } }
public static function initialize() { $valid = false; /* Get the king instance to parse the url to controller, method and parameters. */ $king = self::getInstance(); /* Validate the if the controller class based in the url exists. * If exists, then we include that controller class. */ $controller_class = ucfirst($king->getController()) . "Controller"; $controller_path = CONTROLLERS_PATH . $controller_class . ".php"; if (file_exists($controller_path)) { include_once $controller_path; /* Initialise the controller class. */ $class = new $controller_class(); /* Check if the method exist in the controller class and has the required parameters. * If it exists, then we call that method and pass the parameters. */ $method = $king->getMethod() ? $king->getMethod() : "index"; if (method_exists($class, $method)) { $classMethod = new ReflectionMethod($class, $method); if (sizeof($king->getParameters()) >= $classMethod->getNumberOfRequiredParameters()) { /* Call the Shield class and then checks if the request is secure. */ if (Shield::protect()) { $valid = true; call_user_func_array(array($class, $method), $king->getParameters()); } else { Error::display('UNDER_ATTACK'); } } } } /* Return an error if its an invalid path. */ if (!$valid) { Error::display('NOT_FOUND', "Something is WRONG in the Castle class, the path or controller was not found."); } }
/** * clean catalog procedure * * Removes local songs that no longer exist. */ public function clean_catalog_proc() { if (!Core::is_readable($this->path)) { // First sanity check; no point in proceeding with an unreadable // catalog root. debug_event('catalog', 'Catalog path:' . $this->path . ' unreadable, clean failed', 1); Error::add('general', T_('Catalog Root unreadable, stopping clean')); Error::display('general'); return 0; } $dead_total = 0; $stats = self::get_stats($this->id); foreach (array('video', 'song') as $media_type) { $total = $stats[$media_type . 's']; // UGLY if ($total == 0) { continue; } $chunks = floor($total / 10000); $dead = array(); foreach (range(0, $chunks) as $chunk) { $dead = array_merge($dead, $this->_clean_chunk($media_type, $chunk, 10000)); } $dead_count = count($dead); // The AlmightyOatmeal sanity check // Never remove everything; it might be a dead mount if ($dead_count >= $total) { debug_event('catalog', 'All files would be removed. Doing nothing.', 1); Error::add('general', T_('All files would be removed. Doing nothing')); continue; } if ($dead_count) { $dead_total += $dead_count; $sql = "DELETE FROM `{$media_type}` WHERE `id` IN " . '(' . implode(',', $dead) . ')'; $db_results = Dba::write($sql); } } return $dead_total; }
/** * update_remote_catalog * * Pulls the data from a remote catalog and adds any missing songs to the * database. */ public function update_remote_catalog($type = 0) { set_time_limit(0); $remote_handle = $this->connect(); if (!$remote_handle) { return false; } // Get the song count, etc. $remote_catalog_info = $remote_handle->info(); // Tell 'em what we've found, Johnny! printf(T_('%u remote catalog(s) found (%u songs)'), $remote_catalog_info['catalogs'], $remote_catalog_info['songs']); flush(); // Hardcoded for now $step = 500; $current = 0; $total = $remote_catalog_info['songs']; while ($total > $current) { $start = $current; $current += $step; try { $songs = $remote_handle->send_command('songs', array('offset' => $start, 'limit' => $step)); } catch (Exception $e) { Error::add('general', $e->getMessage()); Error::display('general'); flush(); } // Iterate over the songs we retrieved and insert them foreach ($songs as $data) { if ($this->check_remote_song($data['song'])) { debug_event('remote_catalog', 'Skipping existing song ' . $data['song']['url'], 5); } else { $data['song']['catalog'] = $this->id; $data['song']['file'] = preg_replace('/ssid=.*?&/', '', $data['song']['url']); if (!Song::insert($data['song'])) { debug_event('remote_catalog', 'Insert failed for ' . $data['song']['self']['id'], 1); Error::add('general', T_('Unable to Insert Song - %s'), $data['song']['title']); Error::display('general'); flush(); } } } } // end while echo "<p>" . T_('Completed updating remote catalog(s).') . "</p><hr />\n"; flush(); // Update the last update value $this->update_last_update(); return true; }
/** * 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; }
/** * update_remote_catalog * * Pulls the data from a remote catalog and adds any missing songs to the * database. */ public function update_remote_catalog() { $subsonic = $this->createClient(); $songsadded = 0; // Get all artists $artists = $subsonic->getIndexes(); if ($artists['success']) { foreach ($artists['data']['indexes']['index'] as $index) { foreach ($index['artist'] as $artist) { // Get albums for artist $albums = $subsonic->getMusicDirectory(array('id' => $artist['id'])); if ($albums['success']) { foreach ($albums['data']['directory']['child'] as $album) { if (is_array($album)) { $songs = $subsonic->getMusicDirectory(array('id' => $album['id'])); if ($songs['success']) { foreach ($songs['data']['directory']['child'] as $song) { if (is_array($song)) { $data = array(); $data['artist'] = html_entity_decode($song['artist']); $data['album'] = html_entity_decode($song['album']); $data['title'] = html_entity_decode($song['title']); $data['bitrate'] = $song['bitRate'] * 1000; $data['size'] = $song['size']; $data['time'] = $song['duration']; $data['track'] = $song['track']; $data['disk'] = $song['discNumber']; $data['mode'] = 'vbr'; $data['genre'] = explode(' ', html_entity_decode($song['genre'])); $data['file'] = $this->uri . '/rest/stream.view?id=' . $song['id'] . '&filename=' . urlencode($song['path']); if ($this->check_remote_song($data)) { debug_event('subsonic_catalog', 'Skipping existing song ' . $data['path'], 5); } else { $data['catalog'] = $this->id; debug_event('subsonic_catalog', 'Adding song ' . $song['path'], 5, 'ampache-catalog'); if (!Song::insert($data)) { debug_event('subsonic_catalog', 'Insert failed for ' . $song['path'], 1); Error::add('general', T_('Unable to Insert Song - %s'), $song['path']); Error::display('general'); flush(); } else { $songsadded++; } } } } } else { echo "<p>" . T_('Song Error.') . ": " . $songs['error'] . "</p><hr />\n"; flush(); } } } } else { echo "<p>" . T_('Album Error.') . ": " . $albums['error'] . "</p><hr />\n"; flush(); } } } echo "<p>" . T_('Completed updating Subsonic catalog(s).') . " " . $songsadded . " " . T_('Songs added.') . "</p><hr />\n"; flush(); // Update the last update value $this->update_last_update(); } else { echo "<p>" . T_('Artist Error.') . ": " . $artists['error'] . "</p><hr />\n"; flush(); } return true; }
<?php use helpers\form, core\error; ?> <?php echo Error::display($error); ?> <div class="loginPage"> <h5>To register, please login or <a href="/createAccount/"><strong>create an account</strong></a></h5> <?php echo Form::open(array('method' => 'post', 'class' => 'form-group')); ?> <h3>Login</h3> <label for="usernameInput">Pawprint: <?php echo Form::input(array('name' => 'username', 'id' => 'username', 'class' => 'form-control', 'placeholder' => 'Pawprint')); ?> </label> <label for="passwordInput">Password: <?php echo Form::input(array('name' => 'password', 'id' => 'password', 'type' => 'password', 'class' => 'form-control', 'placeholder' => 'Password')); ?> </label> <br /> <br /> <?php echo Form::input(array('type' => 'submit', 'name' => 'submit', 'value' => 'Login', 'class' => 'btn btn-default btn-primary'));
</ul> </div> <?php Error::display('general'); ?> <h2><?php echo T_('Generate Config File'); ?> </h2> <h3><?php echo T_('Database connection'); ?> </h3> <?php Error::display('config'); ?> <form method="post" action="<?php echo $web_path . "/install.php?action=create_config"; ?> " enctype="multipart/form-data" > <div class="form-group"> <label for="web_path" class="col-sm-4 control-label"><?php echo T_('Web Path'); ?> </label> <div class="col-sm-8"> <input type="text" class="form-control" id="web_path" name="web_path" value="<?php echo scrub_out($web_path_guess); ?> ">
<div class="tweet-container"> <h2>Mais que se passe-t-il ?</h2> <div class="tweet"></div> </div> <div id="footer"> <p class="copyright">© 2009 - 2012 HABBOBETA, Nous ne sommes pas lié ou autorisé par Sulake Corporation Oy. HABBO est une marque déposée de Sulake Corporation Oy dans l'Union Européenne, les Etats-Unis, le Japon, la république populaire de Chine et autres juridictions. Tous droits réservés.</p> </div> <br/> <center> <?php echo $Error->display('AuthFalse'); ?> <div id="connexion" style="display:block;"> <form accept="" method="post"> <input type="text" name="username"/> <input type="password" name="password"/> <input type="submit" name="submit" value="Se connecter"/> </form> </div><br/> <div id="fb-root"></div> <script type="text/javascript"> window.fbAsyncInit = function() { FB.init({appId: '<?php echo $config->fb_appid;
$json['c'] = 'Le captcha n\'est pas bon'; $Error->set('captcha', 'vide'); } } else { $Error->set('captcha', 'vide'); $json['c'] = 'Le captcha n\'est pas bon'; } if (!$Error->ErrorPresent()) { $password = hashMe($_POST['password']); $UserDB = new Db('users'); $data = array('username' => safe($_POST['pseudo'], 'SQL'), 'password' => safe($password), 'mail' => safe($_POST['email'], 'SQL'), 'rank' => safe($config->rank_default, 'SQL'), 'motto' => safe($config->motto_default, 'SQL'), 'credits' => safe($config->credit_default, 'SQL'), 'activity_points' => safe($config->activitypoints_default, 'SQL'), 'account_created' => FullDate('hc'), 'ip_reg' => safe($_SERVER['REMOTE_ADDR'], 'HTML'), 'last_online' => time()); $UserDB->save($data); $uid = $db->getLastID(); $salt = hashMe(uniqid()); $Auth->setSaltUsers($uid); $d = date('Y-m-d'); $req = $db->query('UPDATE habbophp_stats SET inscrits=inscrits+1 WHERE date="' . safe($d, 'SQL') . '"'); if ($req) { $username = safe($_POST['pseudo'], 'SQL'); $password = safe($_POST['password'], 'SQL'); session_destroy(); session_start(); if ($Auth->connexion(array('username' => $username, 'password' => $password))) { $json['fini'] = 'yep'; $json['Auth'] = $Auth->getSaltUsers($uid); } } } $json['pseudo'] = $Error->display('pseudo'); $json['email'] = $Error->display('email'); echo json_encode($json);
public function delete($table, $option = array()) { $this->table = $table; $this->_setupFilter($option); $result['success'] = false; if (sizeof($this->filter) > 0) { try { $this->init(); if ($this->_setupQuery('DELETE')) { $result['query'] = $this->query; $stmt = $this->db->prepare($this->query); if ($stmt->execute($this->values)) { $result['success'] = true; } } $this->_clearDbClassProperties(); } catch (PDOException $e) { Error::display('PDO_ERROR', $e->getMessage()); } } return $result; }
echo T_('Confirm Password'); ?> :</label> <input type='password' name='password_2' id='password_2' /> </div> <br /> <div class="registerInformation"> <span><?php echo T_('* Required fields'); ?> </span> </div> <?php if (AmpConfig::get('captcha_public_reg')) { echo captcha::form("→ "); Error::display('captcha'); } ?> <div class="registerButtons"> <input type="hidden" name="action" value="add_user" /> <input type='submit' name='submit_registration' id='submit_registration' value='<?php echo T_('Register User'); ?> ' /> </div> </form> <?php UI::show_footer();
$smarty->compile_check = true; $smarty->force_compile = false; $smarty->debugging = false; $smarty->cache_dir = '../cache'; $smarty->caching = false; $smarty->left_delimiter = '<%'; $smarty->right_delimiter = '%>'; // Metabase include_once 'metabase_database.php'; include_once 'metabase_interface.php'; global $gDatasource; global $gDatabase2; $gDatasource = array('Type' => 'mysql', 'Host' => $mysqlhost, 'User' => $mysqluser, 'Password' => $mysqlpassword, 'IncludePath' => $metabasepath, 'Persistent' => true, 'Options' => array('UseTransactions' => 1, 'DefaultTableType' => "INNODB")); $error = MetabaseSetupDatabase($gDatasource, &$gDatabase2); if ($error != '') { $errorhandler->display('SQL', 'default.inc.php', $error); die; } else { // select database MetabaseSetDatabase($gDatabase2, $systemtable); } function setHotelDB() { global $errorhandler, $gDatasource, $gDatabase, $request; global $tbl_timetracker; $hoteltable = $request->GetVar('schema', 'session'); $error = MetabaseSetupDatabase($gDatasource, &$gDatabase); if ($error != '') { $errorhandler->display('SQL', 'default.inc.php', $error); die; } else {
exit; } // If an error hasn't occured if (!Error::occurred()) { $catalog_id = Catalog::create($_POST); if (!$catalog_id) { require AmpConfig::get('prefix') . '/templates/show_add_catalog.inc.php'; break; } $catalog = Catalog::create_from_id($catalog_id); // Run our initial add $catalog->add_to_catalog($_POST); UI::show_box_top(T_('Catalog Created'), 'box box_catalog_created'); echo "<h2>" . T_('Catalog Created') . "</h2>"; Error::display('general'); Error::display('catalog_add'); UI::show_box_bottom(); show_confirmation('', '', AmpConfig::get('web_path') . '/admin/catalog.php'); } else { require AmpConfig::get('prefix') . '/templates/show_add_catalog.inc.php'; } break; case 'clear_stats': if (AmpConfig::get('demo_mode')) { UI::access_denied(); break; } Stats::clear(); $url = AmpConfig::get('web_path') . '/admin/catalog.php'; $title = T_('Catalog statistics cleared'); $body = '';
/** * run_update * This function actually updates the db. * it goes through versions and finds the ones * that need to be run. Checking to make sure * the function exists first. */ public static function run_update() { /* Nuke All Active session before we start the mojo */ $sql = "TRUNCATE session"; Dba::write($sql); // Prevent the script from timing out, which could be bad set_time_limit(0); $current_version = self::get_version(); // Run a check to make sure that they don't try to upgrade from a version that // won't work. if ($current_version < '340002') { echo "<p align=\"center\">Database version too old, please upgrade to <a href=\"http://ampache.org/downloads/ampache-3.3.3.5.tar.gz\">Ampache-3.3.3.5</a> first</p>"; return false; } $methods = get_class_methods('Update'); if (!is_array(self::$versions)) { self::$versions = self::populate_version(); } foreach (self::$versions as $version) { // If it's newer than our current version let's see if a function // exists and run the bugger. if ($version['version'] > $current_version) { $update_function = "update_" . $version['version']; if (in_array($update_function, $methods)) { $success = call_user_func(array('Update', $update_function)); // If the update fails drop out if ($success) { self::set_version('db_version', $version['version']); } else { Error::display('update'); return false; } } } } // end foreach version // Once we've run all of the updates let's re-sync the character set as // the user can change this between updates and cause mis-matches on any // new tables. Dba::reset_db_charset(); // Let's also clean up the preferences unconditionally User::rebuild_all_preferences(); }
Error::display('stream_type'); ?> </td> </tr> <tr> <td><?php echo T_('Bitrate'); ?> </td> <td> <input type="text" name="bitrate" value="<?php echo scrub_out($_REQUEST['bitrate'] ?: '128'); ?> " /> <?php Error::display('bitrate'); ?> </td> </tr> </table> <div class="formValidation"> <?php echo Core::form_register('add_channel'); ?> <input class="button" type="submit" value="<?php echo T_('Create'); ?> " /> </div> </form> <?php
Error::display('site_url'); ?> </td> </tr> <tr> <td><?php echo T_('Stream URL'); ?> </td> <td> <input type="text" name="url" value="<?php echo scrub_out($_REQUEST['url']); ?> " /> <?php Error::display('url'); ?> </td> </tr> <tr> <td><?php echo T_('Codec'); ?> </td> <td> <input type="text" name="codec" value="<?php echo scrub_out($_REQUEST['codec']); ?> " /> </td> </tr>
Error::display('subject'); ?> </td> </tr> <tr> <td><?php echo T_('Message'); ?> </td> <td> <textarea name="message" cols="64" rows="10"><?php echo scrub_out($_REQUEST['message']); ?> </textarea> <?php Error::display('message'); ?> </td> </tr> </table> <div class="formValidation"> <?php echo Core::form_register('add_pvmsg'); ?> <input class="button" type="submit" value="<?php echo T_('Send'); ?> " /> </div> </form> <script type="text/javascript">
echo scrub_out($client->city); ?> " /> </td> </tr> <?php } ?> <tr> <td><?php echo T_('New Password'); ?> :</td> <td> <?php Error::display('password'); ?> <input type="password" name="password1" id="password1" /> </td> </tr> <tr> <td><?php echo T_('Confirm Password'); ?> :</td> <td> <input type="password" name="password2" id="password2" /> </td> </tr> <tr> <td>
Error::display('secret'); ?> </td> </tr> <tr> <td><?php echo T_('Max Counter'); ?> </td> <td> <input type="text" name="max_counter" value="<?php echo scrub_out($_REQUEST['max_counter'] ?: '0'); ?> " /> <?php Error::display('max_counter'); ?> </td> </tr> <tr> <td><?php echo T_('Expire Days'); ?> </td> <td> <input type="text" name="expire" value="<?php echo scrub_out($_REQUEST['expire'] ?: AmpConfig::get('share_expire')); ?> " /> </td> </tr>
<input type="text" name="start" value="<?php if ($action == 'show_add_current') { echo scrub_out($_SERVER['REMOTE_ADDR']); } else { echo scrub_out($_REQUEST['start']); } ?> " /> </td> <td> <?php echo T_('End'); ?> : <?php Error::display('end'); ?> <input type="text" name="end" value="<?php if ($action == 'show_add_current') { echo scrub_out($_SERVER['REMOTE_ADDR']); } else { echo scrub_out($_REQUEST['end']); } ?> " /> </td> </tr> </table> <div class="formValidation"> <?php echo Core::form_register('add_acl');
Error::display('email'); ?> </td> </tr> <tr> <td><?php echo T_('Website'); ?> </td> <td> <input type="text" name="website" value="<?php echo scrub_out($_REQUEST['website']); ?> " /> <?php Error::display('website'); ?> </td> </tr> </table> <div class="formValidation"> <?php echo Core::form_register('add_label'); ?> <input class="button" type="submit" value="<?php echo T_('Add'); ?> " /> </div> </form> <?php
echo T_('Ampache Update'); ?> </h1> </div> <div class="well"> <p><?php printf(T_('This page handles all database updates to Ampache starting with <strong>3.3.3.5</strong>. According to your database your current version is: <strong>%s</strong>.'), Update::format_version($version)); ?> </p> <p><?php echo T_('The following updates need to be performed'); ?> </p> </div> <?php Error::display('general'); ?> <div class="content"> <?php Update::display_update(); ?> </div> <?php if (Update::need_update()) { ?> <form method="post" enctype="multipart/form-data" action="<?php echo AmpConfig::get('web_path'); ?> /update.php?action=update"> <button type="submit" class="btn btn-warning" name="update"><?php echo T_('Update Now!');
/** * Add the song to the DB * @param array $song * @return integer */ protected function insertSong($song) { $inserted = Song::insert($song); if ($inserted) { debug_event('beets_catalog', 'Adding song ' . $song['file'], 5, 'ampache-catalog'); } else { debug_event('beets_catalog', 'Insert failed for ' . $song['file'], 1); Error::add('general', T_('Unable to Insert Song - %s'), $song['file']); Error::display('general'); } flush(); return $inserted; }