Ejemplo n.º 1
0
 function test_pairs()
 {
     $cmp = new StdClass();
     $cmp->foo = 'asdf';
     DB::execute('create table test2 (foo char(12), bar char(12))');
     DB::execute('insert into test2 (foo, bar) values (?, ?)', 'one', 'joe');
     DB::execute('insert into test2 (foo, bar) values (?, ?)', 'two', 'sam');
     $res = DB::pairs('select * from test2 order by foo asc');
     $cmp = array('one' => 'joe', 'two' => 'sam');
     $this->assertEquals($cmp, $res);
 }
Ejemplo n.º 2
0
 * exposes them.
 */
function admin_head_links_sort($a, $b)
{
    if ($a['name'] == $b['name']) {
        return 0;
    }
    return $a['name'] < $b['name'] ? -1 : 1;
}
$page->layout = false;
if (!User::require_admin()) {
    return;
}
$tools = array('admin/pages' => array('handler' => 'admin/pages', 'name' => i18n_get('All Pages'), 'class' => false));
$res = glob('apps/*/conf/config.php');
$apps = DB::pairs('select * from apps');
foreach ($res as $file) {
    $app = preg_replace('/^apps\\/(.*)\\/conf\\/config\\.php$/i', '\\1', $file);
    $appconf = parse_ini_file($file, true);
    if (isset($appconf['Admin']['handler'])) {
        if (isset($appconf['Admin']['install'])) {
            $ver = $this->installed($app, $appconf['Admin']['version']);
            if ($ver === true) {
                // installed
                $tools[$appconf['Admin']['handler']] = $appconf['Admin'];
                $tools[$appconf['Admin']['handler']]['class'] = false;
            } elseif ($ver === false) {
                // not installed
                $appconf['Admin']['name'] .= ' (' . i18n_get('click to install') . ')';
                $tools[$appconf['Admin']['install']] = $appconf['Admin'];
                $tools[$appconf['Admin']['install']]['class'] = 'not-installed';
Ejemplo n.º 3
0
 /**
  * Get or set a property for the specified file.
  * Can also retrieve an array of a property for a
  * list of files if `$file` is an array.
  */
 public static function prop($file, $prop, $value = null)
 {
     if ($value !== null) {
         // takes an extra select query, but works cross-database
         $res = self::prop($file, $prop);
         if ($res === $value) {
             return $value;
         } elseif (!$res) {
             // doesn't exist yet
             if (!DB::execute('insert into filemanager_prop (file, prop, value) values (?, ?, ?)', $file, $prop, $value)) {
                 self::$error = DB::error();
                 return false;
             }
         } else {
             // already exists, update
             if (!DB::execute('update filemanager_prop set value = ? where file = ? and prop = ?', $value, $file, $prop)) {
                 self::$error = DB::error();
                 return false;
             }
         }
         return $value;
     }
     if (is_array($file)) {
         // get as a list
         $qmarks = array_fill(0, count($file), '?');
         $file[] = $prop;
         return DB::pairs('select file, value from filemanager_prop where file in(' . join(', ', $qmarks) . ') and prop = ?', $file);
     }
     // get a single value
     return DB::shift('select value from filemanager_prop where file = ? and prop = ?', $file, $prop);
 }
Ejemplo n.º 4
0
Archivo: Post.php Proyecto: R-J/elefant
	/**
	 * Get a list of tags and the number of posts they've been used on.
	 */
	public static function tags () {
		return \DB::pairs ('select tag_id, count(*) as posts from #prefix#blog_post_tag group by tag_id order by tag_id asc');
	}
Ejemplo n.º 5
0
$spectrogram_palette=query_one("SELECT Value from PumilioSettings WHERE Settings='spectrogram_palette'", $connection);

$default_qf=query_one("SELECT Value from PumilioSettings WHERE Settings='default_qf'", $connection);

$AudioPreviewFormat=query_one("SELECT Value from PumilioSettings WHERE Settings='AudioPreviewFormat'", $connection);
*/
#Get variables from db - new way
# using
# https://github.com/Xeoncross/DByte
// We need this!
require 'db/DB.php';
// Create a new PDO connection to MySQL
$pdo = new PDO("mysql:dbname={$database};host={$host}", "{$user}", "{$password}", array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8", PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
DB::$c = $pdo;
$settings = DB::pairs('SELECT `Settings`, `Value` FROM `PumilioSettings`');
extract($settings, EXTR_OVERWRITE);
#Test settings variables
if ($app_custom_name == "") {
    $app_custom_name = "Pumilio";
}
if (!isset($googlemaps_ver)) {
    $googlemaps_ver = "";
}
if ($googlemaps_ver == "") {
    if ($use_googlemaps == "3") {
        $googlemaps_ver = "3";
    }
}
if ($app_custom_text == "") {
    $app_custom_text = "Pumilio is a free and open source sound archive manager for the visualization and manipulation of sound files.";