2 require_once("boot.php");
3 require_once("include/text.php");
5 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
8 * send the email and do what is needed to do on update fails
10 * @param update_id (int) number of failed update
11 * @param error_message (str) error message
13 function update_fail($update_id, $error_message){
14 //send the administrators an e-mail
15 $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
16 $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
20 // every admin could had different language
22 foreach ($adminlist as $admin) {
23 $lang = (($admin['language'])?$admin['language']:'en');
26 $preamble = deindent(t("
27 The friendica developers released update %s recently,
28 but when I tried to install it, something went terribly wrong.
29 This needs to be fixed soon and I can't do it alone. Please contact a
30 friendica developer if you can not help me on your own. My database might be invalid."));
31 $body = t("The error message is\n[pre]%s[/pre]");
32 $preamble = sprintf($preamble, $update_id);
33 $body = sprintf($body, $error_message);
36 'type' => "SYSTEM_EMAIL",
37 'to_email' => $admin['email'],
38 'preamble' => $preamble,
48 $email_tpl = get_intltext_template("update_fail_eml.tpl");
49 $email_msg = replace_macros($email_tpl, array(
50 '$sitename' => $a->config['sitename'],
51 '$siteurl' => $a->get_baseurl(),
52 '$update' => DB_UPDATE_VERSION,
53 '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
55 $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
56 require_once('include/email.php');
57 $subject = email_header_encode($subject,'UTF-8');
58 mail($a->config['admin_email'], $subject, $email_msg,
59 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
60 .'Content-type: text/plain; charset=UTF-8'."\n"
61 .'Content-transfer-encoding: 8bit');
64 logger("CRITICAL: Database structure update failed: ".$retval);
69 function table_structure($table) {
70 $structures = q("DESCRIBE `%s`", $table);
72 $indexes = q("SHOW INDEX FROM `%s`", $table);
77 if (is_array($indexes))
78 foreach ($indexes AS $index) {
79 if ($index["Index_type"] == "FULLTEXT")
82 $column = $index["Column_name"];
83 if ($index["Sub_part"] != "")
84 $column .= "(".$index["Sub_part"].")";
86 $indexdata[$index["Key_name"]][] = $column;
89 if (is_array($structures)) {
90 foreach($structures AS $field) {
91 $fielddata[$field["Field"]]["type"] = $field["Type"];
92 if ($field["Null"] == "NO")
93 $fielddata[$field["Field"]]["not null"] = true;
95 if (isset($field["Default"]))
96 $fielddata[$field["Field"]]["default"] = $field["Default"];
98 if ($field["Extra"] != "")
99 $fielddata[$field["Field"]]["extra"] = $field["Extra"];
101 if ($field["Key"] == "PRI")
102 $fielddata[$field["Field"]]["primary"] = true;
105 return(array("fields"=>$fielddata, "indexes"=>$indexdata));
108 function print_structure($database) {
109 echo "-- ------------------------------------------\n";
110 echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
111 echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
112 echo "-- ------------------------------------------\n\n\n";
113 foreach ($database AS $name => $structure) {
115 echo "-- TABLE $name\n";
117 db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
123 function update_structure($verbose, $action) {
128 logger('updating structure', LOGGER_DEBUG);
130 // Get the current structure
133 $tables = q("show tables");
135 foreach ($tables AS $table) {
136 $table = current($table);
138 $database[$table] = table_structure($table);
141 // Get the definition
142 $definition = db_definition();
145 foreach ($definition AS $name => $structure) {
147 if (!isset($database[$name])) {
148 $r = db_create_table($name, $structure["fields"], $verbose, $action);
150 $errors .= t('Errors encountered creating database tables.').$name.EOL;
152 // Drop the index if it isn't present in the definition
153 foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
154 if (!isset($structure["indexes"][$indexname])) {
155 $sql2=db_drop_index($indexname);
157 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
162 // Compare the field structure field by field
163 foreach ($structure["fields"] AS $fieldname => $parameters) {
164 if (!isset($database[$name]["fields"][$fieldname])) {
165 $sql2=db_add_table_field($fieldname, $parameters);
167 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
171 // Compare the field definition
172 $current_field_definition = implode(",",$database[$name]["fields"][$fieldname]);
173 $new_field_definition = implode(",",$parameters);
174 if ($current_field_definition != $new_field_definition) {
175 $sql2=db_modify_table_field($fieldname, $parameters);
177 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
187 foreach ($structure["indexes"] AS $indexname => $fieldnames) {
188 if (!isset($database[$name]["indexes"][$indexname])) {
189 $sql2=db_create_index($indexname, $fieldnames);
192 $sql3 = "ALTER TABLE `".$name."` ".$sql2;
208 $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
216 function db_field_command($parameters, $create = true) {
217 $fieldstruct = $parameters["type"];
219 if ($parameters["not null"])
220 $fieldstruct .= " NOT NULL";
222 if (isset($parameters["default"])){
223 if (strpos(strtolower($parameters["type"]),"int")!==false) {
224 $fieldstruct .= " DEFAULT ".$parameters["default"];
226 $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
229 if ($parameters["extra"] != "")
230 $fieldstruct .= " ".$parameters["extra"];
232 if (($parameters["primary"] != "") AND $create)
233 $fieldstruct .= " PRIMARY KEY";
235 return($fieldstruct);
238 function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
245 foreach($fields AS $fieldname => $field) {
246 $sql_rows[] = "`".dbesc($fieldname)."` ".db_field_command($field);
249 if (!is_null($indexes)) {
251 foreach ($indexes AS $indexname => $fieldnames) {
252 $sql_index = db_create_index($indexname, $fieldnames, "");
253 if (!is_null($sql_index)) $sql_rows[] = $sql_index;
257 $sql = implode(",\n\t", $sql_rows);
259 $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
270 function db_add_table_field($fieldname, $parameters) {
271 $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
275 function db_modify_table_field($fieldname, $parameters) {
276 $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
280 function db_drop_index($indexname) {
281 $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
285 function db_create_index($indexname, $fieldnames, $method="ADD") {
287 if ($indexname == "PRIMARY")
291 foreach ($fieldnames AS $fieldname) {
295 if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
296 $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
298 $names .= "`".dbesc($fieldname)."`";
301 $method = strtoupper(trim($method));
302 if ($method!="" && $method!="ADD") {
303 throw new Exception("Invalid parameter 'method' in db_create_index(): '$method'");
307 $sql = sprintf("%s INDEX `%s` (%s)", $method, dbesc($indexname), $names);
311 function db_definition() {
315 $database["addon"] = array(
317 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
318 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
319 "version" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
320 "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
321 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
322 "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
323 "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
326 "PRIMARY" => array("id"),
329 $database["attach"] = array(
331 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
332 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
333 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
334 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
335 "filetype" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
336 "filesize" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
337 "data" => array("type" => "longblob", "not null" => "1"),
338 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
339 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
340 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
341 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
342 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
343 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
346 "PRIMARY" => array("id"),
349 $database["auth_codes"] = array(
351 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
352 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
353 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
354 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
355 "scope" => array("type" => "varchar(250)", "not null" => "1", "default" => ""),
358 "PRIMARY" => array("id"),
361 $database["cache"] = array(
363 "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
364 "v" => array("type" => "text", "not null" => "1"),
365 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
368 "PRIMARY" => array("k"),
369 "updated" => array("updated"),
372 $database["challenge"] = array(
374 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
375 "challenge" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
376 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
377 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
378 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
379 "last_update" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
382 "PRIMARY" => array("id"),
385 $database["clients"] = array(
387 "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
388 "pw" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
389 "redirect_uri" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
390 "name" => array("type" => "text"),
391 "icon" => array("type" => "text"),
392 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
395 "PRIMARY" => array("client_id"),
398 $database["config"] = array(
400 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
401 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
402 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
403 "v" => array("type" => "text", "not null" => "1"),
406 "PRIMARY" => array("id"),
407 "cat_k" => array("cat(30)","k(30)"),
410 $database["contact"] = array(
412 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
413 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
414 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
415 "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
416 "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
417 "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
418 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
419 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
420 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
421 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
422 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
423 "about" => array("type" => "text", "not null" => "1"),
424 "keywords" => array("type" => "text", "not null" => "1"),
425 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
426 "attag" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
427 "photo" => array("type" => "text", "not null" => "1"),
428 "thumb" => array("type" => "text", "not null" => "1"),
429 "micro" => array("type" => "text", "not null" => "1"),
430 "site-pubkey" => array("type" => "text", "not null" => "1"),
431 "issued-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
432 "dfrn-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
433 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
434 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
435 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
436 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
437 "pubkey" => array("type" => "text", "not null" => "1"),
438 "prvkey" => array("type" => "text", "not null" => "1"),
439 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
440 "request" => array("type" => "text", "not null" => "1"),
441 "notify" => array("type" => "text", "not null" => "1"),
442 "poll" => array("type" => "text", "not null" => "1"),
443 "confirm" => array("type" => "text", "not null" => "1"),
444 "poco" => array("type" => "text", "not null" => "1"),
445 "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
446 "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
447 "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
448 "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
449 "hub-verify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
450 "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
451 "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
452 "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
453 "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
454 "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
455 "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
456 "priority" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
457 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
458 "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
459 "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
460 "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
461 "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
462 "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
463 "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
464 "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
465 "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
466 "reason" => array("type" => "text", "not null" => "1"),
467 "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
468 "info" => array("type" => "mediumtext", "not null" => "1"),
469 "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
470 "bdyear" => array("type" => "varchar(4)", "not null" => "1", "default" => ""),
471 "bd" => array("type" => "date", "not null" => "1", "default" => "0000-00-00"),
472 "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
473 "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
474 "ffi_keyword_blacklist" => array("type" => "mediumtext", "not null" => "1"),
477 "PRIMARY" => array("id"),
478 "uid" => array("uid"),
481 $database["conv"] = array(
483 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
484 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
485 "recips" => array("type" => "mediumtext", "not null" => "1"),
486 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
487 "creator" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
488 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
489 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
490 "subject" => array("type" => "mediumtext", "not null" => "1"),
493 "PRIMARY" => array("id"),
494 "uid" => array("uid"),
497 $database["deliverq"] = array(
499 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
500 "cmd" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
501 "item" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
502 "contact" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
505 "PRIMARY" => array("id"),
508 $database["dsprphotoq"] = array(
510 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
511 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
512 "msg" => array("type" => "mediumtext", "not null" => "1"),
513 "attempt" => array("type" => "tinyint(4)", "not null" => "1", "default" => "0"),
516 "PRIMARY" => array("id"),
519 $database["event"] = array(
521 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
522 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
523 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
524 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
525 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
526 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
527 "start" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
528 "finish" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
529 "summary" => array("type" => "text", "not null" => "1"),
530 "desc" => array("type" => "text", "not null" => "1"),
531 "location" => array("type" => "text", "not null" => "1"),
532 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
533 "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
534 "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
535 "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
536 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
537 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
538 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
539 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
542 "PRIMARY" => array("id"),
543 "uid" => array("uid"),
546 $database["fcontact"] = array(
548 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
549 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
550 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
551 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
552 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
553 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
554 "addr" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
555 "batch" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
556 "notify" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
557 "poll" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
558 "confirm" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
559 "priority" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
560 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
561 "alias" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
562 "pubkey" => array("type" => "text", "not null" => "1"),
563 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
566 "PRIMARY" => array("id"),
567 "addr" => array("addr"),
570 $database["ffinder"] = array(
572 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
573 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
574 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
575 "fid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
578 "PRIMARY" => array("id"),
581 $database["fserver"] = array(
583 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
584 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
585 "posturl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
586 "key" => array("type" => "text", "not null" => "1"),
589 "PRIMARY" => array("id"),
590 "server" => array("server"),
593 $database["fsuggest"] = array(
595 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
596 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
597 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
598 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
599 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
600 "request" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
601 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
602 "note" => array("type" => "text", "not null" => "1"),
603 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
606 "PRIMARY" => array("id"),
609 $database["gcign"] = array(
611 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
612 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
613 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
616 "PRIMARY" => array("id"),
617 "uid" => array("uid"),
618 "gcid" => array("gcid"),
621 $database["gcontact"] = array(
623 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
624 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
625 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
626 "nurl" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
627 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
628 "connect" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
629 "updated" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
630 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
631 "about" => array("type" => "text", "not null" => "1"),
632 "keywords" => array("type" => "text", "not null" => "1"),
633 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
634 "network" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
635 "generation" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
638 "PRIMARY" => array("id"),
639 "nurl" => array("nurl"),
642 $database["glink"] = array(
644 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
645 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
646 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
647 "gcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
648 "zcid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
649 "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
652 "PRIMARY" => array("id"),
653 "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
654 "gcid" => array("gcid"),
655 "zcid" => array("zcid"),
658 $database["group"] = array(
660 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
661 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
662 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
663 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
664 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
667 "PRIMARY" => array("id"),
668 "uid" => array("uid"),
671 $database["group_member"] = array(
673 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
674 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
675 "gid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
676 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
679 "PRIMARY" => array("id"),
680 "uid_gid_contactid" => array("uid","gid","contact-id"),
683 $database["guid"] = array(
685 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
686 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
689 "PRIMARY" => array("id"),
690 "guid" => array("guid"),
693 $database["hook"] = array(
695 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
696 "hook" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
697 "file" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
698 "function" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
699 "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
702 "PRIMARY" => array("id"),
703 "hook_file_function" => array("hook(30)","file(60)","function(30)"),
706 $database["intro"] = array(
708 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
709 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
710 "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
711 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
712 "knowyou" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
713 "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
714 "note" => array("type" => "text", "not null" => "1"),
715 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
716 "datetime" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
717 "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
718 "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
721 "PRIMARY" => array("id"),
724 $database["item"] = array(
726 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
727 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
728 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
729 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
730 "contact-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
731 "type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
732 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
733 "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
734 "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
735 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
736 "extid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
737 "thr-parent" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
738 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
739 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
740 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
741 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
742 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
743 "owner-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
744 "owner-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
745 "owner-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
746 "author-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
747 "author-link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
748 "author-avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
749 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
750 "body" => array("type" => "mediumtext", "not null" => "1"),
751 "app" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
752 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
753 "object-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
754 "object" => array("type" => "text", "not null" => "1"),
755 "target-type" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
756 "target" => array("type" => "text", "not null" => "1"),
757 "postopts" => array("type" => "text", "not null" => "1"),
758 "plink" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
759 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
760 "event-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
761 "tag" => array("type" => "mediumtext", "not null" => "1"),
762 "attach" => array("type" => "mediumtext", "not null" => "1"),
763 "inform" => array("type" => "mediumtext", "not null" => "1"),
764 "file" => array("type" => "mediumtext", "not null" => "1"),
765 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
766 "coord" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
767 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
768 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
769 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
770 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
771 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
772 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
773 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
774 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
775 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
776 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
777 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
778 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
779 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
780 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
781 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
782 "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
783 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
784 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
785 "rendered-hash" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
786 "rendered-html" => array("type" => "mediumtext", "not null" => "1"),
787 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
790 "PRIMARY" => array("id"),
791 "guid" => array("guid"),
792 "uri" => array("uri"),
793 "parent" => array("parent"),
794 "parent-uri" => array("parent-uri"),
795 "extid" => array("extid"),
796 "uid_id" => array("uid","id"),
797 "uid_created" => array("uid","created"),
798 "uid_unseen" => array("uid","unseen"),
799 "uid_network_received" => array("uid","network","received"),
800 "uid_received" => array("uid","received"),
801 "uid_network_commented" => array("uid","network","commented"),
802 "uid_commented" => array("uid","commented"),
803 "uid_title" => array("uid","title"),
804 "uid_thrparent" => array("uid","thr-parent"),
805 "uid_parenturi" => array("uid","parent-uri"),
806 "uid_contactid_created" => array("uid","contact-id","created"),
807 "wall_body" => array("wall","body(6)"),
808 "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
809 "uid_uri" => array("uid","uri"),
810 "uid_wall_created" => array("uid","wall","created"),
811 "resource-id" => array("resource-id"),
812 "uid_type" => array("uid","type"),
813 "uid_starred" => array("uid","starred"),
814 "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
815 "uid_wall_parent_created" => array("uid","wall","parent","created"),
816 "uid_type_changed" => array("uid","type","changed"),
817 "contactid_verb" => array("contact-id","verb"),
818 "deleted_changed" => array("deleted","changed"),
819 "uid_wall_changed" => array("uid","wall","changed"),
820 "uid_eventid" => array("uid","event-id"),
821 "uid_authorlink" => array("uid","author-link"),
822 "uid_ownerlink" => array("uid","owner-link"),
825 $database["item_id"] = array(
827 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
828 "iid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
829 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
830 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
831 "service" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
834 "PRIMARY" => array("id"),
835 "uid" => array("uid"),
836 "sid" => array("sid"),
837 "service" => array("service"),
838 "iid" => array("iid"),
841 $database["locks"] = array(
843 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
844 "name" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
845 "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
846 "created" => array("type" => "datetime", "default" => "0000-00-00 00:00:00"),
849 "PRIMARY" => array("id"),
852 $database["mail"] = array(
854 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
855 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
856 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
857 "from-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
858 "from-photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
859 "from-url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
860 "contact-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
861 "convid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
862 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
863 "body" => array("type" => "mediumtext", "not null" => "1"),
864 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
865 "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
866 "replied" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
867 "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
868 "uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
869 "parent-uri" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
870 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
873 "PRIMARY" => array("id"),
874 "uid" => array("uid"),
875 "guid" => array("guid"),
876 "convid" => array("convid"),
877 "reply" => array("reply"),
878 "uri" => array("uri"),
879 "parent-uri" => array("parent-uri"),
882 $database["mailacct"] = array(
884 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
885 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
886 "server" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
887 "port" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
888 "ssltype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
889 "mailbox" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
890 "user" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
891 "pass" => array("type" => "text", "not null" => "1"),
892 "reply_to" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
893 "action" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
894 "movetofolder" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
895 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
896 "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
899 "PRIMARY" => array("id"),
902 $database["manage"] = array(
904 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
905 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
906 "mid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
909 "PRIMARY" => array("id"),
910 "uid_mid" => array("uid","mid"),
913 $database["notify"] = array(
915 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
916 "hash" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
917 "type" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
918 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
919 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
920 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
921 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
922 "msg" => array("type" => "mediumtext", "not null" => "1"),
923 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
924 "link" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
925 "parent" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
926 "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
927 "verb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
928 "otype" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
931 "PRIMARY" => array("id"),
932 "uid" => array("uid"),
935 $database["notify-threads"] = array(
937 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
938 "notify-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
939 "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
940 "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
941 "receiver-uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
944 "PRIMARY" => array("id"),
945 "master-parent-item" => array("master-parent-item"),
946 "receiver-uid" => array("receiver-uid"),
949 $database["pconfig"] = array(
951 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
952 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
953 "cat" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
954 "k" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
955 "v" => array("type" => "mediumtext", "not null" => "1"),
958 "PRIMARY" => array("id"),
959 "uid_cat_k" => array("uid","cat(30)","k(30)"),
962 $database["photo"] = array(
964 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
965 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
966 "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
967 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
968 "resource-id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
969 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
970 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
971 "title" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
972 "desc" => array("type" => "text", "not null" => "1"),
973 "album" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
974 "filename" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
975 "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
976 "height" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
977 "width" => array("type" => "smallint(6)", "not null" => "1", "default" => "0"),
978 "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
979 "data" => array("type" => "mediumblob", "not null" => "1"),
980 "scale" => array("type" => "tinyint(3)", "not null" => "1", "default" => "0"),
981 "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
982 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
983 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
984 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
985 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
988 "PRIMARY" => array("id"),
989 "uid" => array("uid"),
990 "resource-id" => array("resource-id"),
991 "guid" => array("guid"),
994 $database["poll"] = array(
996 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
997 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
998 "q0" => array("type" => "mediumtext", "not null" => "1"),
999 "q1" => array("type" => "mediumtext", "not null" => "1"),
1000 "q2" => array("type" => "mediumtext", "not null" => "1"),
1001 "q3" => array("type" => "mediumtext", "not null" => "1"),
1002 "q4" => array("type" => "mediumtext", "not null" => "1"),
1003 "q5" => array("type" => "mediumtext", "not null" => "1"),
1004 "q6" => array("type" => "mediumtext", "not null" => "1"),
1005 "q7" => array("type" => "mediumtext", "not null" => "1"),
1006 "q8" => array("type" => "mediumtext", "not null" => "1"),
1007 "q9" => array("type" => "mediumtext", "not null" => "1"),
1010 "PRIMARY" => array("id"),
1011 "uid" => array("uid"),
1014 $database["poll_result"] = array(
1016 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1017 "poll_id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1018 "choice" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1021 "PRIMARY" => array("id"),
1022 "poll_id" => array("poll_id"),
1023 "choice" => array("choice"),
1026 $database["profile"] = array(
1028 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1029 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1030 "profile-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1031 "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1032 "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1033 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1034 "pdesc" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1035 "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
1036 "address" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1037 "locality" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1038 "region" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1039 "postal-code" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1040 "country-name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1041 "hometown" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1042 "gender" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1043 "marital" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1044 "with" => array("type" => "text", "not null" => "1"),
1045 "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1046 "sexual" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1047 "politic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1048 "religion" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1049 "pub_keywords" => array("type" => "text", "not null" => "1"),
1050 "prv_keywords" => array("type" => "text", "not null" => "1"),
1051 "likes" => array("type" => "text", "not null" => "1"),
1052 "dislikes" => array("type" => "text", "not null" => "1"),
1053 "about" => array("type" => "text", "not null" => "1"),
1054 "summary" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1055 "music" => array("type" => "text", "not null" => "1"),
1056 "book" => array("type" => "text", "not null" => "1"),
1057 "tv" => array("type" => "text", "not null" => "1"),
1058 "film" => array("type" => "text", "not null" => "1"),
1059 "interest" => array("type" => "text", "not null" => "1"),
1060 "romance" => array("type" => "text", "not null" => "1"),
1061 "work" => array("type" => "text", "not null" => "1"),
1062 "education" => array("type" => "text", "not null" => "1"),
1063 "contact" => array("type" => "text", "not null" => "1"),
1064 "homepage" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1065 "photo" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1066 "thumb" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1067 "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1068 "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1071 "PRIMARY" => array("id"),
1072 "hometown" => array("hometown"),
1075 $database["profile_check"] = array(
1077 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1078 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1079 "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1080 "dfrn_id" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1081 "sec" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1082 "expire" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1085 "PRIMARY" => array("id"),
1088 $database["push_subscriber"] = array(
1090 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1091 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1092 "callback_url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1093 "topic" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1094 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1095 "push" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1096 "last_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1097 "secret" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1100 "PRIMARY" => array("id"),
1103 $database["queue"] = array(
1105 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1106 "cid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1107 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1108 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1109 "last" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1110 "content" => array("type" => "mediumtext", "not null" => "1"),
1111 "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1114 "PRIMARY" => array("id"),
1115 "cid" => array("cid"),
1116 "created" => array("created"),
1117 "last" => array("last"),
1118 "network" => array("network"),
1119 "batch" => array("batch"),
1122 $database["register"] = array(
1124 "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1125 "hash" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1126 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1127 "uid" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1128 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1129 "language" => array("type" => "varchar(16)", "not null" => "1", "default" => ""),
1132 "PRIMARY" => array("id"),
1135 $database["search"] = array(
1137 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1138 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1139 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1142 "PRIMARY" => array("id"),
1143 "uid" => array("uid"),
1144 "term" => array("term"),
1147 $database["session"] = array(
1149 "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1150 "sid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1151 "data" => array("type" => "text", "not null" => "1"),
1152 "expire" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1155 "PRIMARY" => array("id"),
1156 "sid" => array("sid"),
1157 "expire" => array("expire"),
1160 $database["sign"] = array(
1162 "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1163 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1164 "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1165 "signed_text" => array("type" => "mediumtext", "not null" => "1"),
1166 "signature" => array("type" => "text", "not null" => "1"),
1167 "signer" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1170 "PRIMARY" => array("id"),
1171 "iid" => array("iid"),
1172 "retract_iid" => array("retract_iid"),
1175 $database["spam"] = array(
1177 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1178 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1179 "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1180 "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1181 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1182 "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1185 "PRIMARY" => array("id"),
1186 "uid" => array("uid"),
1187 "spam" => array("spam"),
1188 "ham" => array("ham"),
1189 "term" => array("term"),
1192 $database["term"] = array(
1194 "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1195 "oid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1196 "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1197 "type" => array("type" => "tinyint(3) unsigned", "not null" => "1", "default" => "0"),
1198 "term" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1199 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1200 "guid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1201 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1202 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1203 "global" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1204 "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1205 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1208 "PRIMARY" => array("tid"),
1209 "oid_otype_type_term" => array("oid","otype","type","term"),
1210 "uid_term_tid" => array("uid","term","tid"),
1211 "type_term" => array("type","term"),
1212 "uid_otype_type_term_global_created" => array("uid","otype","type","term","global","created"),
1213 "otype_type_term_tid" => array("otype","type","term","tid"),
1214 "guid" => array("guid"),
1217 $database["thread"] = array(
1219 "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
1220 "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
1221 "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1222 "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1223 "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1224 "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1225 "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1226 "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1227 "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1228 "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1229 "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1230 "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1231 "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1232 "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1233 "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1234 "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1235 "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1236 "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
1237 "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1238 "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1239 "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1240 "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1241 "network" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1244 "PRIMARY" => array("iid"),
1245 "created" => array("created"),
1246 "commented" => array("commented"),
1247 "uid_network_commented" => array("uid","network","commented"),
1248 "uid_network_created" => array("uid","network","created"),
1249 "uid_contactid_commented" => array("uid","contact-id","commented"),
1250 "uid_contactid_created" => array("uid","contact-id","created"),
1251 "wall_private_received" => array("wall","private","received"),
1252 "uid_created" => array("uid","created"),
1253 "uid_commented" => array("uid","commented"),
1256 $database["tokens"] = array(
1258 "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
1259 "secret" => array("type" => "text", "not null" => "1"),
1260 "client_id" => array("type" => "varchar(20)", "not null" => "1", "default" => ""),
1261 "expires" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1262 "scope" => array("type" => "varchar(200)", "not null" => "1", "default" => ""),
1263 "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1266 "PRIMARY" => array("id"),
1269 $database["unique_contacts"] = array(
1271 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1272 "url" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1273 "nick" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1274 "name" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1275 "avatar" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1276 "location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1277 "about" => array("type" => "text", "not null" => "1"),
1280 "PRIMARY" => array("id"),
1281 "url" => array("url"),
1284 $database["user"] = array(
1286 "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1287 "guid" => array("type" => "varchar(64)", "not null" => "1", "default" => ""),
1288 "username" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1289 "password" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1290 "nickname" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1291 "email" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1292 "openid" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1293 "timezone" => array("type" => "varchar(128)", "not null" => "1", "default" => ""),
1294 "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
1295 "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1296 "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1297 "default-location" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1298 "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1299 "theme" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1300 "pubkey" => array("type" => "text", "not null" => "1"),
1301 "prvkey" => array("type" => "text", "not null" => "1"),
1302 "spubkey" => array("type" => "text", "not null" => "1"),
1303 "sprvkey" => array("type" => "text", "not null" => "1"),
1304 "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1305 "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1306 "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1307 "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1308 "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
1309 "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1310 "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1311 "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
1312 "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1313 "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1314 "pwdreset" => array("type" => "varchar(255)", "not null" => "1", "default" => ""),
1315 "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
1316 "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
1317 "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1318 "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
1319 "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1320 "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
1321 "service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
1322 "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
1323 "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
1324 "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
1325 "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
1326 "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
1327 "openidserver" => array("type" => "text", "not null" => "1"),
1330 "PRIMARY" => array("uid"),
1331 "nickname" => array("nickname"),
1334 $database["userd"] = array(
1336 "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
1337 "username" => array("type" => "varchar(255)", "not null" => "1"),
1340 "PRIMARY" => array("id"),
1341 "username" => array("username"),
1350 * run from command line
1352 function dbstructure_run(&$argv, &$argc) {
1360 @include(".htconfig.php");
1361 require_once("include/dba.php");
1362 $db = new dba($db_host, $db_user, $db_pass, $db_data);
1363 unset($db_host, $db_user, $db_pass, $db_data);
1369 update_structure(true, true);
1372 print_structure(db_definition());
1379 echo $argv[0]." <command>\n";
1382 echo "update update database schema\n";
1383 echo "dumpsql dump database schema\n";
1391 if (array_search(__file__,get_included_files())===0){
1392 dbstructure_run($_SERVER["argv"],$_SERVER["argc"]);