root/modules/branches/2.2/recordings/install.php

Revision 2474, 2.2 kB (checked in by qldrob, 7 years ago)

mkdir wasn't working, hadn't declared the variable first. D'oh!

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
1 <?php
2
3 global $amp_conf;
4 global $asterisk_conf;
5 global $db;
6 $recordings_astsnd_path = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk';
7 $recordings_astsnd_path .= "/sounds/";
8
9
10 require_once($amp_conf['AMPWEBROOT'] . '/admin/modules/recordings/functions.inc.php');
11
12 $fcc = new featurecode('recordings', 'record_save');
13 $fcc->setDescription('Save Recording');
14 $fcc->setDefault('*77');
15 $fcc->update();
16 unset($fcc);
17
18 $fcc = new featurecode('recordings', 'record_check');
19 $fcc->setDescription('Check Recording');
20 $fcc->setDefault('*99');
21 $fcc->update();
22 unset($fcc);
23
24 // Make sure table exists
25 $sql = "CREATE TABLE IF NOT EXISTS recordings ( id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, displayname VARCHAR(50) , filename BLOB, description VARCHAR(254));";
26 $result = $db->query($sql);
27 if(DB::IsError($result)) {
28         die($result->getDebugInfo());
29 }
30
31 // load up any recordings that might be in the directory
32 $recordings_directory = $recordings_astsnd_path."custom/";
33
34 if (!file_exists($recordings_directory)) {
35   mkdir ($recordings_directory);
36 }
37 if (!is_writable($recordings_directory)) {
38   print "<h2>Error</h2><br />I can not access the directory $recordings_directory. ";
39   print "Please make sure that it exists, and is writable by the web server.";
40   die;
41 }
42 $sql = "SELECT * FROM recordings where displayname = '__invalid'";
43 $results = $db->getRow($sql, DB_FETCHMODE_ASSOC);
44 if (!isset($results['filename'])) {
45   sql("INSERT INTO recordings values ('', '__invalid', 'install done', '')");
46   $dh = opendir($recordings_directory);
47   while (false !== ($file = readdir($dh))) { // http://au3.php.net/readdir
48     if ($file[0] != "." && $file != "CVS" && $file != "svn" && !is_dir("$recordings_directory/$file")) {
49       // Ignore the suffix..
50       $fname = ereg_replace('.wav', '', $file);
51       $fname = ereg_replace('.gsm', '', $fname);
52       if (recordings_get_id("custom/$fname") == null)
53         recordings_add($fname, "custom/$file");
54     }
55   }
56 }
57
58 global $db;
59
60 // Upgrade to recordings 3.0
61 // Change filename from VARCHAR(80) to BLOB
62 $sql = 'ALTER TABLE recordings CHANGE filename filename BLOB';
63 $result = $db->query($sql);
64 if(DB::IsError($result)) {
65   die($result->getDebugInfo());
66 }
67
68 ?>
Note: See TracBrowser for help on using the browser.