Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1344 lines
60 KiB

  1. <?php
  2. require_once("boot.php");
  3. require_once("include/text.php");
  4. define('NEW_UPDATE_ROUTINE_VERSION', 1170);
  5. /*
  6. * send the email and do what is needed to do on update fails
  7. *
  8. * @param update_id (int) number of failed update
  9. * @param error_message (str) error message
  10. */
  11. function update_fail($update_id, $error_message){
  12. //send the administrators an e-mail
  13. $admin_mail_list = "'".implode("','", array_map(dbesc, explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
  14. $adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
  15. $admin_mail_list
  16. );
  17. // every admin could had different language
  18. foreach ($adminlist as $admin) {
  19. $lang = (($admin['language'])?$admin['language']:'en');
  20. push_lang($lang);
  21. $preamble = deindent(t("
  22. The friendica developers released update %s recently,
  23. but when I tried to install it, something went terribly wrong.
  24. This needs to be fixed soon and I can't do it alone. Please contact a
  25. friendica developer if you can not help me on your own. My database might be invalid."));
  26. $body = t("The error message is\n[pre]%s[/pre]");
  27. $preamble = sprintf($preamble, $update_id);
  28. $body = sprintf($body, $error_message);
  29. notification(array(
  30. 'type' => "SYSTEM_EMAIL",
  31. 'to_email' => $admin['email'],
  32. 'preamble' => $preamble,
  33. 'body' => $body,
  34. 'language' => $lang,
  35. ));
  36. }
  37. /*
  38. $email_tpl = get_intltext_template("update_fail_eml.tpl");
  39. $email_msg = replace_macros($email_tpl, array(
  40. '$sitename' => $a->config['sitename'],
  41. '$siteurl' => $a->get_baseurl(),
  42. '$update' => DB_UPDATE_VERSION,
  43. '$error' => sprintf(t('Update %s failed. See error logs.'), DB_UPDATE_VERSION)
  44. ));
  45. $subject=sprintf(t('Update Error at %s'), $a->get_baseurl());
  46. require_once('include/email.php');
  47. $subject = email_header_encode($subject,'UTF-8');
  48. mail($a->config['admin_email'], $subject, $email_msg,
  49. 'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME']."\n"
  50. .'Content-type: text/plain; charset=UTF-8'."\n"
  51. .'Content-transfer-encoding: 8bit');
  52. */
  53. //try the logger
  54. logger("CRITICAL: Database structure update failed: ".$retval);
  55. break;
  56. }
  57. function table_structure($table) {
  58. $structures = q("DESCRIBE `%s`", $table);
  59. $indexes = q("SHOW INDEX FROM `%s`", $table);
  60. $fielddata = array();
  61. $indexdata = array();
  62. if (is_array($indexes))
  63. foreach ($indexes AS $index) {
  64. if ($index["Index_type"] == "FULLTEXT")
  65. continue;
  66. $column = $index["Column_name"];
  67. if ($index["Sub_part"] != "")
  68. $column .= "(".$index["Sub_part"].")";
  69. $indexdata[$index["Key_name"]][] = $column;
  70. }
  71. if (is_array($structures)) {
  72. foreach($structures AS $field) {
  73. $fielddata[$field["Field"]]["type"] = $field["Type"];
  74. if ($field["Null"] == "NO")
  75. $fielddata[$field["Field"]]["not null"] = true;
  76. if ($field["Default"] != "")
  77. $fielddata[$field["Field"]]["default"] = $field["Default"];
  78. if ($field["Extra"] != "")
  79. $fielddata[$field["Field"]]["extra"] = $field["Extra"];
  80. if ($field["Key"] == "PRI")
  81. $fielddata[$field["Field"]]["primary"] = true;
  82. }
  83. }
  84. return(array("fields"=>$fielddata, "indexes"=>$indexdata));
  85. }
  86. function print_structure($database) {
  87. foreach ($database AS $name => $structure) {
  88. echo "\t".'$database["'.$name."\"] = array(\n";
  89. echo "\t\t\t".'"fields" => array('."\n";
  90. foreach ($structure["fields"] AS $fieldname => $parameters) {
  91. echo "\t\t\t\t\t".'"'.$fieldname.'" => array(';
  92. $data = "";
  93. foreach ($parameters AS $name => $value) {
  94. if ($data != "")
  95. $data .= ", ";
  96. $data .= '"'.$name.'" => "'.$value.'"';
  97. }
  98. echo $data."),\n";
  99. }
  100. echo "\t\t\t\t\t),\n";
  101. echo "\t\t\t".'"indexes" => array('."\n";
  102. foreach ($structure["indexes"] AS $indexname => $fieldnames) {
  103. echo "\t\t\t\t\t".'"'.$indexname.'" => array("'.implode($fieldnames, '","').'"'."),\n";
  104. }
  105. echo "\t\t\t\t\t)\n";
  106. echo "\t\t\t);\n";
  107. }
  108. }
  109. function update_structure($verbose, $action) {
  110. global $a, $db;
  111. $errors = false;
  112. logger('updating structure', LOGGER_DEBUG);
  113. // Get the current structure
  114. $database = array();
  115. $tables = q("show tables");
  116. foreach ($tables AS $table) {
  117. $table = current($table);
  118. $database[$table] = table_structure($table);
  119. }
  120. // Get the definition
  121. $definition = db_definition();
  122. // Compare it
  123. foreach ($definition AS $name => $structure) {
  124. $sql3="";
  125. if (!isset($database[$name])) {
  126. $r = db_create_table($name, $structure["fields"], $verbose, $action);
  127. if(false === $r)
  128. $errors .= t('Errors encountered creating database tables.').$name.EOL;
  129. } else {
  130. // Drop the index if it isn't present in the definition
  131. foreach ($database[$name]["indexes"] AS $indexname => $fieldnames)
  132. if (!isset($structure["indexes"][$indexname])) {
  133. $sql2=db_drop_index($indexname);
  134. if ($sql3 == "")
  135. $sql3 = "ALTER TABLE `".$name."` ".$sql2;
  136. else
  137. $sql3 .= ", ".$sql2;
  138. }
  139. // Compare the field structure field by field
  140. foreach ($structure["fields"] AS $fieldname => $parameters) {
  141. if (!isset($database[$name]["fields"][$fieldname])) {
  142. $sql2=db_add_table_field($fieldname, $parameters);
  143. if ($sql3 == "")
  144. $sql3 = "ALTER TABLE `".$name."` ".$sql2;
  145. else
  146. $sql3 .= ", ".$sql2;
  147. } else {
  148. // Compare the field definition
  149. $current_field_definition = implode($database[$name]["fields"][$fieldname]);
  150. $new_field_definition = implode($parameters);
  151. if ($current_field_definition != $new_field_definition) {
  152. $sql2=db_modify_table_field($fieldname, $parameters);
  153. if ($sql3 == "")
  154. $sql3 = "ALTER TABLE `".$name."` ".$sql2;
  155. else
  156. $sql3 .= ", ".$sql2;
  157. }
  158. }
  159. }
  160. }
  161. // Create the index
  162. foreach ($structure["indexes"] AS $indexname => $fieldnames) {
  163. if (!isset($database[$name]["indexes"][$indexname])) {
  164. $sql2=db_create_index($indexname, $fieldnames);
  165. if ($sql2 != "") {
  166. if ($sql3 == "")
  167. $sql3 = "ALTER TABLE `".$name."` ".$sql2;
  168. else
  169. $sql3 .= ", ".$sql2;
  170. }
  171. }
  172. }
  173. if ($sql3 != "") {
  174. $sql3 .= ";";
  175. if ($verbose)
  176. echo $sql3."\n";
  177. if ($action) {
  178. $r = @$db->q($sql3);
  179. if(false === $r)
  180. $errors .= t('Errors encountered performing database changes.').$sql3.EOL;
  181. }
  182. }
  183. }
  184. return $errors;
  185. }
  186. function db_field_command($parameters, $create = true) {
  187. $fieldstruct = $parameters["type"];
  188. if ($parameters["not null"])
  189. $fieldstruct .= " NOT NULL";
  190. if ($parameters["default"] != "")
  191. $fieldstruct .= " DEFAULT '".$parameters["default"]."'";
  192. if ($parameters["extra"] != "")
  193. $fieldstruct .= " ".$parameters["extra"];
  194. if (($parameters["primary"] != "") AND $create)
  195. $fieldstruct .= " PRIMARY KEY";
  196. return($fieldstruct);
  197. }
  198. function db_create_table($name, $fields, $verbose, $action) {
  199. global $a, $db;
  200. $r = true;
  201. $sql = "";
  202. foreach($fields AS $fieldname => $field) {
  203. if ($sql != "")
  204. $sql .= ",\n";
  205. $sql .= "`".dbesc($fieldname)."` ".db_field_command($field);
  206. }
  207. $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n", dbesc($name)).$sql."\n) DEFAULT CHARSET=utf8";
  208. if ($verbose)
  209. echo $sql.";\n";
  210. if ($action)
  211. $r = @$db->q($sql);
  212. return $r;
  213. }
  214. function db_add_table_field($fieldname, $parameters) {
  215. $sql = sprintf("ADD `%s` %s", dbesc($fieldname), db_field_command($parameters));
  216. return($sql);
  217. }
  218. function db_modify_table_field($fieldname, $parameters) {
  219. $sql = sprintf("MODIFY `%s` %s", dbesc($fieldname), db_field_command($parameters, false));
  220. return($sql);
  221. }
  222. function db_drop_index($indexname) {
  223. $sql = sprintf("DROP INDEX `%s`", dbesc($indexname));
  224. return($sql);
  225. }
  226. function db_create_index($indexname, $fieldnames) {
  227. if ($indexname == "PRIMARY")
  228. return;
  229. $names = "";
  230. foreach ($fieldnames AS $fieldname) {
  231. if ($names != "")
  232. $names .= ",";
  233. if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches))
  234. $names .= "`".dbesc($matches[1])."`(".intval($matches[2]).")";
  235. else
  236. $names .= "`".dbesc($fieldname)."`";
  237. }
  238. $sql = sprintf("ADD INDEX `%s` (%s)", dbesc($indexname), $names);
  239. return($sql);
  240. }
  241. function db_definition() {
  242. $database = array();
  243. $database["addon"] = array(
  244. "fields" => array(
  245. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  246. "name" => array("type" => "varchar(255)", "not null" => "1"),
  247. "version" => array("type" => "varchar(255)", "not null" => "1"),
  248. "installed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  249. "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  250. "timestamp" => array("type" => "bigint(20)", "not null" => "1", "default" => "0"),
  251. "plugin_admin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  252. ),
  253. "indexes" => array(
  254. "PRIMARY" => array("id"),
  255. )
  256. );
  257. $database["attach"] = array(
  258. "fields" => array(
  259. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  260. "uid" => array("type" => "int(11)", "not null" => "1"),
  261. "hash" => array("type" => "varchar(64)", "not null" => "1"),
  262. "filename" => array("type" => "varchar(255)", "not null" => "1"),
  263. "filetype" => array("type" => "varchar(64)", "not null" => "1"),
  264. "filesize" => array("type" => "int(11)", "not null" => "1"),
  265. "data" => array("type" => "longblob", "not null" => "1"),
  266. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  267. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  268. "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
  269. "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
  270. "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
  271. "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
  272. ),
  273. "indexes" => array(
  274. "PRIMARY" => array("id"),
  275. )
  276. );
  277. $database["auth_codes"] = array(
  278. "fields" => array(
  279. "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
  280. "client_id" => array("type" => "varchar(20)", "not null" => "1"),
  281. "redirect_uri" => array("type" => "varchar(200)", "not null" => "1"),
  282. "expires" => array("type" => "int(11)", "not null" => "1"),
  283. "scope" => array("type" => "varchar(250)", "not null" => "1"),
  284. ),
  285. "indexes" => array(
  286. "PRIMARY" => array("id"),
  287. )
  288. );
  289. $database["cache"] = array(
  290. "fields" => array(
  291. "k" => array("type" => "varchar(255)", "not null" => "1", "primary" => "1"),
  292. "v" => array("type" => "text", "not null" => "1"),
  293. "updated" => array("type" => "datetime", "not null" => "1"),
  294. ),
  295. "indexes" => array(
  296. "PRIMARY" => array("k"),
  297. "updated" => array("updated"),
  298. )
  299. );
  300. $database["challenge"] = array(
  301. "fields" => array(
  302. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  303. "challenge" => array("type" => "varchar(255)", "not null" => "1"),
  304. "dfrn-id" => array("type" => "varchar(255)", "not null" => "1"),
  305. "expire" => array("type" => "int(11)", "not null" => "1"),
  306. "type" => array("type" => "varchar(255)", "not null" => "1"),
  307. "last_update" => array("type" => "varchar(255)", "not null" => "1"),
  308. ),
  309. "indexes" => array(
  310. "PRIMARY" => array("id"),
  311. )
  312. );
  313. $database["clients"] = array(
  314. "fields" => array(
  315. "client_id" => array("type" => "varchar(20)", "not null" => "1", "primary" => "1"),
  316. "pw" => array("type" => "varchar(20)", "not null" => "1"),
  317. "redirect_uri" => array("type" => "varchar(200)", "not null" => "1"),
  318. "name" => array("type" => "text"),
  319. "icon" => array("type" => "text"),
  320. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  321. ),
  322. "indexes" => array(
  323. "PRIMARY" => array("client_id"),
  324. )
  325. );
  326. $database["config"] = array(
  327. "fields" => array(
  328. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  329. "cat" => array("type" => "varchar(255)", "not null" => "1"),
  330. "k" => array("type" => "varchar(255)", "not null" => "1"),
  331. "v" => array("type" => "text", "not null" => "1"),
  332. ),
  333. "indexes" => array(
  334. "PRIMARY" => array("id"),
  335. "cat_k" => array("cat(30)","k(30)"),
  336. )
  337. );
  338. $database["contact"] = array(
  339. "fields" => array(
  340. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  341. "uid" => array("type" => "int(11)", "not null" => "1"),
  342. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  343. "self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  344. "remote_self" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  345. "rel" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  346. "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  347. "network" => array("type" => "varchar(255)", "not null" => "1"),
  348. "name" => array("type" => "varchar(255)", "not null" => "1"),
  349. "nick" => array("type" => "varchar(255)", "not null" => "1"),
  350. "attag" => array("type" => "varchar(255)", "not null" => "1"),
  351. "photo" => array("type" => "text", "not null" => "1"),
  352. "thumb" => array("type" => "text", "not null" => "1"),
  353. "micro" => array("type" => "text", "not null" => "1"),
  354. "site-pubkey" => array("type" => "text", "not null" => "1"),
  355. "issued-id" => array("type" => "varchar(255)", "not null" => "1"),
  356. "dfrn-id" => array("type" => "varchar(255)", "not null" => "1"),
  357. "url" => array("type" => "varchar(255)", "not null" => "1"),
  358. "nurl" => array("type" => "varchar(255)", "not null" => "1"),
  359. "addr" => array("type" => "varchar(255)", "not null" => "1"),
  360. "alias" => array("type" => "varchar(255)", "not null" => "1"),
  361. "pubkey" => array("type" => "text", "not null" => "1"),
  362. "prvkey" => array("type" => "text", "not null" => "1"),
  363. "batch" => array("type" => "varchar(255)", "not null" => "1"),
  364. "request" => array("type" => "text", "not null" => "1"),
  365. "notify" => array("type" => "text", "not null" => "1"),
  366. "poll" => array("type" => "text", "not null" => "1"),
  367. "confirm" => array("type" => "text", "not null" => "1"),
  368. "poco" => array("type" => "text", "not null" => "1"),
  369. "aes_allow" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  370. "ret-aes" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  371. "usehub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  372. "subhub" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  373. "hub-verify" => array("type" => "varchar(255)", "not null" => "1"),
  374. "last-update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  375. "success_update" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  376. "name-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  377. "uri-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  378. "avatar-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  379. "term-date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  380. "priority" => array("type" => "tinyint(3)", "not null" => "1"),
  381. "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  382. "readonly" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  383. "writable" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  384. "forum" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  385. "prv" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  386. "hidden" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  387. "archive" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  388. "pending" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  389. "rating" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  390. "reason" => array("type" => "text", "not null" => "1"),
  391. "closeness" => array("type" => "tinyint(2)", "not null" => "1", "default" => "99"),
  392. "info" => array("type" => "mediumtext", "not null" => "1"),
  393. "profile-id" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  394. "bdyear" => array("type" => "varchar(4)", "not null" => "1"),
  395. "bd" => array("type" => "date", "not null" => "1"),
  396. "notify_new_posts" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  397. "fetch_further_information" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  398. ),
  399. "indexes" => array(
  400. "PRIMARY" => array("id"),
  401. "uid" => array("uid"),
  402. )
  403. );
  404. $database["conv"] = array(
  405. "fields" => array(
  406. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  407. "guid" => array("type" => "varchar(64)", "not null" => "1"),
  408. "recips" => array("type" => "mediumtext", "not null" => "1"),
  409. "uid" => array("type" => "int(11)", "not null" => "1"),
  410. "creator" => array("type" => "varchar(255)", "not null" => "1"),
  411. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  412. "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  413. "subject" => array("type" => "mediumtext", "not null" => "1"),
  414. ),
  415. "indexes" => array(
  416. "PRIMARY" => array("id"),
  417. "uid" => array("uid"),
  418. )
  419. );
  420. $database["deliverq"] = array(
  421. "fields" => array(
  422. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  423. "cmd" => array("type" => "varchar(32)", "not null" => "1"),
  424. "item" => array("type" => "int(11)", "not null" => "1"),
  425. "contact" => array("type" => "int(11)", "not null" => "1"),
  426. ),
  427. "indexes" => array(
  428. "PRIMARY" => array("id"),
  429. )
  430. );
  431. $database["dsprphotoq"] = array(
  432. "fields" => array(
  433. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  434. "uid" => array("type" => "int(11)", "not null" => "1"),
  435. "msg" => array("type" => "mediumtext", "not null" => "1"),
  436. "attempt" => array("type" => "tinyint(4)", "not null" => "1"),
  437. ),
  438. "indexes" => array(
  439. "PRIMARY" => array("id"),
  440. )
  441. );
  442. $database["event"] = array(
  443. "fields" => array(
  444. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  445. "uid" => array("type" => "int(11)", "not null" => "1"),
  446. "cid" => array("type" => "int(11)", "not null" => "1"),
  447. "uri" => array("type" => "varchar(255)", "not null" => "1"),
  448. "created" => array("type" => "datetime", "not null" => "1"),
  449. "edited" => array("type" => "datetime", "not null" => "1"),
  450. "start" => array("type" => "datetime", "not null" => "1"),
  451. "finish" => array("type" => "datetime", "not null" => "1"),
  452. "summary" => array("type" => "text", "not null" => "1"),
  453. "desc" => array("type" => "text", "not null" => "1"),
  454. "location" => array("type" => "text", "not null" => "1"),
  455. "type" => array("type" => "varchar(255)", "not null" => "1"),
  456. "nofinish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  457. "adjust" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  458. "ignore" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  459. "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
  460. "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
  461. "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
  462. "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
  463. ),
  464. "indexes" => array(
  465. "PRIMARY" => array("id"),
  466. "uid" => array("uid"),
  467. )
  468. );
  469. $database["fcontact"] = array(
  470. "fields" => array(
  471. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  472. "url" => array("type" => "varchar(255)", "not null" => "1"),
  473. "name" => array("type" => "varchar(255)", "not null" => "1"),
  474. "photo" => array("type" => "varchar(255)", "not null" => "1"),
  475. "request" => array("type" => "varchar(255)", "not null" => "1"),
  476. "nick" => array("type" => "varchar(255)", "not null" => "1"),
  477. "addr" => array("type" => "varchar(255)", "not null" => "1"),
  478. "batch" => array("type" => "varchar(255)", "not null" => "1"),
  479. "notify" => array("type" => "varchar(255)", "not null" => "1"),
  480. "poll" => array("type" => "varchar(255)", "not null" => "1"),
  481. "confirm" => array("type" => "varchar(255)", "not null" => "1"),
  482. "priority" => array("type" => "tinyint(1)", "not null" => "1"),
  483. "network" => array("type" => "varchar(32)", "not null" => "1"),
  484. "alias" => array("type" => "varchar(255)", "not null" => "1"),
  485. "pubkey" => array("type" => "text", "not null" => "1"),
  486. "updated" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  487. ),
  488. "indexes" => array(
  489. "PRIMARY" => array("id"),
  490. "addr" => array("addr"),
  491. )
  492. );
  493. $database["ffinder"] = array(
  494. "fields" => array(
  495. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  496. "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
  497. "cid" => array("type" => "int(10) unsigned", "not null" => "1"),
  498. "fid" => array("type" => "int(10) unsigned", "not null" => "1"),
  499. ),
  500. "indexes" => array(
  501. "PRIMARY" => array("id"),
  502. )
  503. );
  504. $database["fserver"] = array(
  505. "fields" => array(
  506. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  507. "server" => array("type" => "varchar(255)", "not null" => "1"),
  508. "posturl" => array("type" => "varchar(255)", "not null" => "1"),
  509. "key" => array("type" => "text", "not null" => "1"),
  510. ),
  511. "indexes" => array(
  512. "PRIMARY" => array("id"),
  513. "server" => array("server"),
  514. )
  515. );
  516. $database["fsuggest"] = array(
  517. "fields" => array(
  518. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  519. "uid" => array("type" => "int(11)", "not null" => "1"),
  520. "cid" => array("type" => "int(11)", "not null" => "1"),
  521. "name" => array("type" => "varchar(255)", "not null" => "1"),
  522. "url" => array("type" => "varchar(255)", "not null" => "1"),
  523. "request" => array("type" => "varchar(255)", "not null" => "1"),
  524. "photo" => array("type" => "varchar(255)", "not null" => "1"),
  525. "note" => array("type" => "text", "not null" => "1"),
  526. "created" => array("type" => "datetime", "not null" => "1"),
  527. ),
  528. "indexes" => array(
  529. "PRIMARY" => array("id"),
  530. )
  531. );
  532. $database["gcign"] = array(
  533. "fields" => array(
  534. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  535. "uid" => array("type" => "int(11)", "not null" => "1"),
  536. "gcid" => array("type" => "int(11)", "not null" => "1"),
  537. ),
  538. "indexes" => array(
  539. "PRIMARY" => array("id"),
  540. "uid" => array("uid"),
  541. "gcid" => array("gcid"),
  542. )
  543. );
  544. $database["gcontact"] = array(
  545. "fields" => array(
  546. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  547. "name" => array("type" => "varchar(255)", "not null" => "1"),
  548. "url" => array("type" => "varchar(255)", "not null" => "1"),
  549. "nurl" => array("type" => "varchar(255)", "not null" => "1"),
  550. "photo" => array("type" => "varchar(255)", "not null" => "1"),
  551. "connect" => array("type" => "varchar(255)", "not null" => "1"),
  552. ),
  553. "indexes" => array(
  554. "PRIMARY" => array("id"),
  555. "nurl" => array("nurl"),
  556. )
  557. );
  558. $database["glink"] = array(
  559. "fields" => array(
  560. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  561. "cid" => array("type" => "int(11)", "not null" => "1"),
  562. "uid" => array("type" => "int(11)", "not null" => "1"),
  563. "gcid" => array("type" => "int(11)", "not null" => "1"),
  564. "zcid" => array("type" => "int(11)", "not null" => "1"),
  565. "updated" => array("type" => "datetime", "not null" => "1"),
  566. ),
  567. "indexes" => array(
  568. "PRIMARY" => array("id"),
  569. "cid_uid_gcid_zcid" => array("cid","uid","gcid","zcid"),
  570. "gcid" => array("gcid"),
  571. "zcid" => array("zcid"),
  572. )
  573. );
  574. $database["group"] = array(
  575. "fields" => array(
  576. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  577. "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
  578. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  579. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  580. "name" => array("type" => "varchar(255)", "not null" => "1"),
  581. ),
  582. "indexes" => array(
  583. "PRIMARY" => array("id"),
  584. "uid" => array("uid"),
  585. )
  586. );
  587. $database["group_member"] = array(
  588. "fields" => array(
  589. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  590. "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
  591. "gid" => array("type" => "int(10) unsigned", "not null" => "1"),
  592. "contact-id" => array("type" => "int(10) unsigned", "not null" => "1"),
  593. ),
  594. "indexes" => array(
  595. "PRIMARY" => array("id"),
  596. "uid_gid_contactid" => array("uid","gid","contact-id"),
  597. )
  598. );
  599. $database["guid"] = array(
  600. "fields" => array(
  601. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  602. "guid" => array("type" => "varchar(255)", "not null" => "1"),
  603. ),
  604. "indexes" => array(
  605. "PRIMARY" => array("id"),
  606. "guid" => array("guid"),
  607. )
  608. );
  609. $database["hook"] = array(
  610. "fields" => array(
  611. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  612. "hook" => array("type" => "varchar(255)", "not null" => "1"),
  613. "file" => array("type" => "varchar(255)", "not null" => "1"),
  614. "function" => array("type" => "varchar(255)", "not null" => "1"),
  615. "priority" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  616. ),
  617. "indexes" => array(
  618. "PRIMARY" => array("id"),
  619. "hook_file_function" => array("hook(30)","file(60)","function(30)"),
  620. )
  621. );
  622. $database["intro"] = array(
  623. "fields" => array(
  624. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  625. "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
  626. "fid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  627. "contact-id" => array("type" => "int(11)", "not null" => "1"),
  628. "knowyou" => array("type" => "tinyint(1)", "not null" => "1"),
  629. "duplex" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  630. "note" => array("type" => "text", "not null" => "1"),
  631. "hash" => array("type" => "varchar(255)", "not null" => "1"),
  632. "datetime" => array("type" => "datetime", "not null" => "1"),
  633. "blocked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  634. "ignore" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  635. ),
  636. "indexes" => array(
  637. "PRIMARY" => array("id"),
  638. )
  639. );
  640. $database["item"] = array(
  641. "fields" => array(
  642. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  643. "guid" => array("type" => "varchar(255)", "not null" => "1"),
  644. "uri" => array("type" => "varchar(255)", "not null" => "1"),
  645. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  646. "contact-id" => array("type" => "int(11)", "not null" => "1"),
  647. "type" => array("type" => "varchar(255)", "not null" => "1"),
  648. "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  649. "gravity" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  650. "parent" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  651. "parent-uri" => array("type" => "varchar(255)", "not null" => "1"),
  652. "extid" => array("type" => "varchar(255)", "not null" => "1"),
  653. "thr-parent" => array("type" => "varchar(255)", "not null" => "1"),
  654. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  655. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  656. "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  657. "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  658. "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  659. "owner-name" => array("type" => "varchar(255)", "not null" => "1"),
  660. "owner-link" => array("type" => "varchar(255)", "not null" => "1"),
  661. "owner-avatar" => array("type" => "varchar(255)", "not null" => "1"),
  662. "author-name" => array("type" => "varchar(255)", "not null" => "1"),
  663. "author-link" => array("type" => "varchar(255)", "not null" => "1"),
  664. "author-avatar" => array("type" => "varchar(255)", "not null" => "1"),
  665. "title" => array("type" => "varchar(255)", "not null" => "1"),
  666. "body" => array("type" => "mediumtext", "not null" => "1"),
  667. "app" => array("type" => "varchar(255)", "not null" => "1"),
  668. "verb" => array("type" => "varchar(255)", "not null" => "1"),
  669. "object-type" => array("type" => "varchar(255)", "not null" => "1"),
  670. "object" => array("type" => "text", "not null" => "1"),
  671. "target-type" => array("type" => "varchar(255)", "not null" => "1"),
  672. "target" => array("type" => "text", "not null" => "1"),
  673. "postopts" => array("type" => "text", "not null" => "1"),
  674. "plink" => array("type" => "varchar(255)", "not null" => "1"),
  675. "resource-id" => array("type" => "varchar(255)", "not null" => "1"),
  676. "event-id" => array("type" => "int(11)", "not null" => "1"),
  677. "tag" => array("type" => "mediumtext", "not null" => "1"),
  678. "attach" => array("type" => "mediumtext", "not null" => "1"),
  679. "inform" => array("type" => "mediumtext", "not null" => "1"),
  680. "file" => array("type" => "mediumtext", "not null" => "1"),
  681. "location" => array("type" => "varchar(255)", "not null" => "1"),
  682. "coord" => array("type" => "varchar(255)", "not null" => "1"),
  683. "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
  684. "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
  685. "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
  686. "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
  687. "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  688. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  689. "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  690. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  691. "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  692. "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  693. "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  694. "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  695. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  696. "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  697. "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  698. "last-child" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "1"),
  699. "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  700. "network" => array("type" => "varchar(32)", "not null" => "1"),
  701. ),
  702. "indexes" => array(
  703. "PRIMARY" => array("id"),
  704. "guid" => array("guid"),
  705. "uri" => array("uri"),
  706. "parent" => array("parent"),
  707. "parent-uri" => array("parent-uri"),
  708. "extid" => array("extid"),
  709. "uid_id" => array("uid","id"),
  710. "uid_created" => array("uid","created"),
  711. "uid_unseen" => array("uid","unseen"),
  712. "uid_network_received" => array("uid","network","received"),
  713. "uid_received" => array("uid","received"),
  714. "uid_network_commented" => array("uid","network","commented"),
  715. "uid_commented" => array("uid","commented"),
  716. "uid_title" => array("uid","title"),
  717. "uid_thrparent" => array("uid","thr-parent"),
  718. "uid_parenturi" => array("uid","parent-uri"),
  719. "uid_contactid_created" => array("uid","contact-id","created"),
  720. "wall_body" => array("wall","body(6)"),
  721. "uid_visible_moderated_created" => array("uid","visible","moderated","created"),
  722. "uid_uri" => array("uid","uri"),
  723. "uid_wall_created" => array("uid","wall","created"),
  724. "resource-id" => array("resource-id"),
  725. "uid_type" => array("uid","type"),
  726. "uid_starred" => array("uid","starred"),
  727. "contactid_allowcid_allowpid_denycid_denygid" => array("contact-id","allow_cid(10)","allow_gid(10)","deny_cid(10)","deny_gid(10)"),
  728. "uid_wall_parent_created" => array("uid","wall","parent","created"),
  729. "uid_type_changed" => array("uid","type","changed"),
  730. "contactid_verb" => array("contact-id","verb"),
  731. "deleted_changed" => array("deleted","changed"),
  732. "uid_wall_changed" => array("uid","wall","changed"),
  733. "uid_eventid" => array("uid","event-id"),
  734. "uid_authorlink" => array("uid","author-link"),
  735. "uid_ownerlink" => array("uid","owner-link"),
  736. )
  737. );
  738. $database["item_id"] = array(
  739. "fields" => array(
  740. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  741. "iid" => array("type" => "int(11)", "not null" => "1"),
  742. "uid" => array("type" => "int(11)", "not null" => "1"),
  743. "sid" => array("type" => "varchar(255)", "not null" => "1"),
  744. "service" => array("type" => "varchar(255)", "not null" => "1"),
  745. ),
  746. "indexes" => array(
  747. "PRIMARY" => array("id"),
  748. "uid" => array("uid"),
  749. "sid" => array("sid"),
  750. "service" => array("service"),
  751. "iid" => array("iid"),
  752. )
  753. );
  754. $database["locks"] = array(
  755. "fields" => array(
  756. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  757. "name" => array("type" => "varchar(128)", "not null" => "1"),
  758. "locked" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  759. ),
  760. "indexes" => array(
  761. "PRIMARY" => array("id"),
  762. )
  763. );
  764. $database["mail"] = array(
  765. "fields" => array(
  766. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  767. "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
  768. "guid" => array("type" => "varchar(64)", "not null" => "1"),
  769. "from-name" => array("type" => "varchar(255)", "not null" => "1"),
  770. "from-photo" => array("type" => "varchar(255)", "not null" => "1"),
  771. "from-url" => array("type" => "varchar(255)", "not null" => "1"),
  772. "contact-id" => array("type" => "varchar(255)", "not null" => "1"),
  773. "convid" => array("type" => "int(11) unsigned", "not null" => "1"),
  774. "title" => array("type" => "varchar(255)", "not null" => "1"),
  775. "body" => array("type" => "mediumtext", "not null" => "1"),
  776. "seen" => array("type" => "tinyint(1)", "not null" => "1"),
  777. "reply" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  778. "replied" => array("type" => "tinyint(1)", "not null" => "1"),
  779. "unknown" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  780. "uri" => array("type" => "varchar(255)", "not null" => "1"),
  781. "parent-uri" => array("type" => "varchar(255)", "not null" => "1"),
  782. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  783. ),
  784. "indexes" => array(
  785. "PRIMARY" => array("id"),
  786. "uid" => array("uid"),
  787. "guid" => array("guid"),
  788. "convid" => array("convid"),
  789. "reply" => array("reply"),
  790. "uri" => array("uri"),
  791. "parent-uri" => array("parent-uri"),
  792. )
  793. );
  794. $database["mailacct"] = array(
  795. "fields" => array(
  796. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  797. "uid" => array("type" => "int(11)", "not null" => "1"),
  798. "server" => array("type" => "varchar(255)", "not null" => "1"),
  799. "port" => array("type" => "int(11)", "not null" => "1"),
  800. "ssltype" => array("type" => "varchar(16)", "not null" => "1"),
  801. "mailbox" => array("type" => "varchar(255)", "not null" => "1"),
  802. "user" => array("type" => "varchar(255)", "not null" => "1"),
  803. "pass" => array("type" => "text", "not null" => "1"),
  804. "reply_to" => array("type" => "varchar(255)", "not null" => "1"),
  805. "action" => array("type" => "int(11)", "not null" => "1"),
  806. "movetofolder" => array("type" => "varchar(255)", "not null" => "1"),
  807. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  808. "last_check" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  809. ),
  810. "indexes" => array(
  811. "PRIMARY" => array("id"),
  812. )
  813. );
  814. $database["manage"] = array(
  815. "fields" => array(
  816. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  817. "uid" => array("type" => "int(11)", "not null" => "1"),
  818. "mid" => array("type" => "int(11)", "not null" => "1"),
  819. ),
  820. "indexes" => array(
  821. "PRIMARY" => array("id"),
  822. "uid_mid" => array("uid","mid"),
  823. )
  824. );
  825. $database["notify"] = array(
  826. "fields" => array(
  827. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  828. "hash" => array("type" => "varchar(64)", "not null" => "1"),
  829. "type" => array("type" => "int(11)", "not null" => "1"),
  830. "name" => array("type" => "varchar(255)", "not null" => "1"),
  831. "url" => array("type" => "varchar(255)", "not null" => "1"),
  832. "photo" => array("type" => "varchar(255)", "not null" => "1"),
  833. "date" => array("type" => "datetime", "not null" => "1"),
  834. "msg" => array("type" => "mediumtext", "not null" => "1"),
  835. "uid" => array("type" => "int(11)", "not null" => "1"),
  836. "link" => array("type" => "varchar(255)", "not null" => "1"),
  837. "parent" => array("type" => "int(11)", "not null" => "1"),
  838. "seen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  839. "verb" => array("type" => "varchar(255)", "not null" => "1"),
  840. "otype" => array("type" => "varchar(16)", "not null" => "1"),
  841. ),
  842. "indexes" => array(
  843. "PRIMARY" => array("id"),
  844. "uid" => array("uid"),
  845. )
  846. );
  847. $database["notify-threads"] = array(
  848. "fields" => array(
  849. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  850. "notify-id" => array("type" => "int(11)", "not null" => "1"),
  851. "master-parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  852. "parent-item" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  853. "receiver-uid" => array("type" => "int(11)", "not null" => "1"),
  854. ),
  855. "indexes" => array(
  856. "PRIMARY" => array("id"),
  857. "master-parent-item" => array("master-parent-item"),
  858. "receiver-uid" => array("receiver-uid"),
  859. )
  860. );
  861. $database["pconfig"] = array(
  862. "fields" => array(
  863. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  864. "uid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  865. "cat" => array("type" => "varchar(255)", "not null" => "1"),
  866. "k" => array("type" => "varchar(255)", "not null" => "1"),
  867. "v" => array("type" => "mediumtext", "not null" => "1"),
  868. ),
  869. "indexes" => array(
  870. "PRIMARY" => array("id"),
  871. "uid_cat_k" => array("uid","cat(30)","k(30)"),
  872. )
  873. );
  874. $database["photo"] = array(
  875. "fields" => array(
  876. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  877. "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
  878. "contact-id" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  879. "guid" => array("type" => "varchar(64)", "not null" => "1"),
  880. "resource-id" => array("type" => "varchar(255)", "not null" => "1"),
  881. "created" => array("type" => "datetime", "not null" => "1"),
  882. "edited" => array("type" => "datetime", "not null" => "1"),
  883. "title" => array("type" => "varchar(255)", "not null" => "1"),
  884. "desc" => array("type" => "text", "not null" => "1"),
  885. "album" => array("type" => "varchar(255)", "not null" => "1"),
  886. "filename" => array("type" => "varchar(255)", "not null" => "1"),
  887. "type" => array("type" => "varchar(128)", "not null" => "1", "default" => "image/jpeg"),
  888. "height" => array("type" => "smallint(6)", "not null" => "1"),
  889. "width" => array("type" => "smallint(6)", "not null" => "1"),
  890. "datasize" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  891. "data" => array("type" => "mediumblob", "not null" => "1"),
  892. "scale" => array("type" => "tinyint(3)", "not null" => "1"),
  893. "profile" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  894. "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
  895. "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
  896. "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
  897. "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
  898. ),
  899. "indexes" => array(
  900. "PRIMARY" => array("id"),
  901. "uid" => array("uid"),
  902. "resource-id" => array("resource-id"),
  903. "guid" => array("guid"),
  904. )
  905. );
  906. $database["poll"] = array(
  907. "fields" => array(
  908. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  909. "uid" => array("type" => "int(11)", "not null" => "1"),
  910. "q0" => array("type" => "mediumtext", "not null" => "1"),
  911. "q1" => array("type" => "mediumtext", "not null" => "1"),
  912. "q2" => array("type" => "mediumtext", "not null" => "1"),
  913. "q3" => array("type" => "mediumtext", "not null" => "1"),
  914. "q4" => array("type" => "mediumtext", "not null" => "1"),
  915. "q5" => array("type" => "mediumtext", "not null" => "1"),
  916. "q6" => array("type" => "mediumtext", "not null" => "1"),
  917. "q7" => array("type" => "mediumtext", "not null" => "1"),
  918. "q8" => array("type" => "mediumtext", "not null" => "1"),
  919. "q9" => array("type" => "mediumtext", "not null" => "1"),
  920. ),
  921. "indexes" => array(
  922. "PRIMARY" => array("id"),
  923. "uid" => array("uid"),
  924. )
  925. );
  926. $database["poll_result"] = array(
  927. "fields" => array(
  928. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  929. "poll_id" => array("type" => "int(11)", "not null" => "1"),
  930. "choice" => array("type" => "int(11)", "not null" => "1"),
  931. ),
  932. "indexes" => array(
  933. "PRIMARY" => array("id"),
  934. "poll_id" => array("poll_id"),
  935. "choice" => array("choice"),
  936. )
  937. );
  938. $database["profile"] = array(
  939. "fields" => array(
  940. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  941. "uid" => array("type" => "int(11)", "not null" => "1"),
  942. "profile-name" => array("type" => "varchar(255)", "not null" => "1"),
  943. "is-default" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  944. "hide-friends" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  945. "name" => array("type" => "varchar(255)", "not null" => "1"),
  946. "pdesc" => array("type" => "varchar(255)", "not null" => "1"),
  947. "dob" => array("type" => "varchar(32)", "not null" => "1", "default" => "0000-00-00"),
  948. "address" => array("type" => "varchar(255)", "not null" => "1"),
  949. "locality" => array("type" => "varchar(255)", "not null" => "1"),
  950. "region" => array("type" => "varchar(255)", "not null" => "1"),
  951. "postal-code" => array("type" => "varchar(32)", "not null" => "1"),
  952. "country-name" => array("type" => "varchar(255)", "not null" => "1"),
  953. "hometown" => array("type" => "varchar(255)", "not null" => "1"),
  954. "gender" => array("type" => "varchar(32)", "not null" => "1"),
  955. "marital" => array("type" => "varchar(255)", "not null" => "1"),
  956. "with" => array("type" => "text", "not null" => "1"),
  957. "howlong" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  958. "sexual" => array("type" => "varchar(255)", "not null" => "1"),
  959. "politic" => array("type" => "varchar(255)", "not null" => "1"),
  960. "religion" => array("type" => "varchar(255)", "not null" => "1"),
  961. "pub_keywords" => array("type" => "text", "not null" => "1"),
  962. "prv_keywords" => array("type" => "text", "not null" => "1"),
  963. "likes" => array("type" => "text", "not null" => "1"),
  964. "dislikes" => array("type" => "text", "not null" => "1"),
  965. "about" => array("type" => "text", "not null" => "1"),
  966. "summary" => array("type" => "varchar(255)", "not null" => "1"),
  967. "music" => array("type" => "text", "not null" => "1"),
  968. "book" => array("type" => "text", "not null" => "1"),
  969. "tv" => array("type" => "text", "not null" => "1"),
  970. "film" => array("type" => "text", "not null" => "1"),
  971. "interest" => array("type" => "text", "not null" => "1"),
  972. "romance" => array("type" => "text", "not null" => "1"),
  973. "work" => array("type" => "text", "not null" => "1"),
  974. "education" => array("type" => "text", "not null" => "1"),
  975. "contact" => array("type" => "text", "not null" => "1"),
  976. "homepage" => array("type" => "varchar(255)", "not null" => "1"),
  977. "photo" => array("type" => "varchar(255)", "not null" => "1"),
  978. "thumb" => array("type" => "varchar(255)", "not null" => "1"),
  979. "publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  980. "net-publish" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  981. ),
  982. "indexes" => array(
  983. "PRIMARY" => array("id"),
  984. "hometown" => array("hometown"),
  985. )
  986. );
  987. $database["profile_check"] = array(
  988. "fields" => array(
  989. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  990. "uid" => array("type" => "int(10) unsigned", "not null" => "1"),
  991. "cid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  992. "dfrn_id" => array("type" => "varchar(255)", "not null" => "1"),
  993. "sec" => array("type" => "varchar(255)", "not null" => "1"),
  994. "expire" => array("type" => "int(11)", "not null" => "1"),
  995. ),
  996. "indexes" => array(
  997. "PRIMARY" => array("id"),
  998. )
  999. );
  1000. $database["push_subscriber"] = array(
  1001. "fields" => array(
  1002. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1003. "uid" => array("type" => "int(11)", "not null" => "1"),
  1004. "callback_url" => array("type" => "varchar(255)", "not null" => "1"),
  1005. "topic" => array("type" => "varchar(255)", "not null" => "1"),
  1006. "nickname" => array("type" => "varchar(255)", "not null" => "1"),
  1007. "push" => array("type" => "int(11)", "not null" => "1"),
  1008. "last_update" => array("type" => "datetime", "not null" => "1"),
  1009. "secret" => array("type" => "varchar(255)", "not null" => "1"),
  1010. ),
  1011. "indexes" => array(
  1012. "PRIMARY" => array("id"),
  1013. )
  1014. );
  1015. $database["queue"] = array(
  1016. "fields" => array(
  1017. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1018. "cid" => array("type" => "int(11)", "not null" => "1"),
  1019. "network" => array("type" => "varchar(32)", "not null" => "1"),
  1020. "created" => array("type" => "datetime", "not null" => "1"),
  1021. "last" => array("type" => "datetime", "not null" => "1"),
  1022. "content" => array("type" => "mediumtext", "not null" => "1"),
  1023. "batch" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1024. ),
  1025. "indexes" => array(
  1026. "PRIMARY" => array("id"),
  1027. "cid" => array("cid"),
  1028. "created" => array("created"),
  1029. "last" => array("last"),
  1030. "network" => array("network"),
  1031. "batch" => array("batch"),
  1032. )
  1033. );
  1034. $database["register"] = array(
  1035. "fields" => array(
  1036. "id" => array("type" => "int(11) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1037. "hash" => array("type" => "varchar(255)", "not null" => "1"),
  1038. "created" => array("type" => "datetime", "not null" => "1"),
  1039. "uid" => array("type" => "int(11) unsigned", "not null" => "1"),
  1040. "password" => array("type" => "varchar(255)", "not null" => "1"),
  1041. "language" => array("type" => "varchar(16)", "not null" => "1"),
  1042. ),
  1043. "indexes" => array(
  1044. "PRIMARY" => array("id"),
  1045. )
  1046. );
  1047. $database["search"] = array(
  1048. "fields" => array(
  1049. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1050. "uid" => array("type" => "int(11)", "not null" => "1"),
  1051. "term" => array("type" => "varchar(255)", "not null" => "1"),
  1052. ),
  1053. "indexes" => array(
  1054. "PRIMARY" => array("id"),
  1055. "uid" => array("uid"),
  1056. "term" => array("term"),
  1057. )
  1058. );
  1059. $database["session"] = array(
  1060. "fields" => array(
  1061. "id" => array("type" => "bigint(20) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1062. "sid" => array("type" => "varchar(255)", "not null" => "1"),
  1063. "data" => array("type" => "text", "not null" => "1"),
  1064. "expire" => array("type" => "int(10) unsigned", "not null" => "1"),
  1065. ),
  1066. "indexes" => array(
  1067. "PRIMARY" => array("id"),
  1068. "sid" => array("sid"),
  1069. "expire" => array("expire"),
  1070. )
  1071. );
  1072. $database["sign"] = array(
  1073. "fields" => array(
  1074. "id" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1075. "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1076. "retract_iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1077. "signed_text" => array("type" => "mediumtext", "not null" => "1"),
  1078. "signature" => array("type" => "text", "not null" => "1"),
  1079. "signer" => array("type" => "varchar(255)", "not null" => "1"),
  1080. ),
  1081. "indexes" => array(
  1082. "PRIMARY" => array("id"),
  1083. "iid" => array("iid"),
  1084. "retract_iid" => array("retract_iid"),
  1085. )
  1086. );
  1087. $database["spam"] = array(
  1088. "fields" => array(
  1089. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1090. "uid" => array("type" => "int(11)", "not null" => "1"),
  1091. "spam" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1092. "ham" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1093. "term" => array("type" => "varchar(255)", "not null" => "1"),
  1094. "date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1095. ),
  1096. "indexes" => array(
  1097. "PRIMARY" => array("id"),
  1098. "uid" => array("uid"),
  1099. "spam" => array("spam"),
  1100. "ham" => array("ham"),
  1101. "term" => array("term"),
  1102. )
  1103. );
  1104. $database["term"] = array(
  1105. "fields" => array(
  1106. "tid" => array("type" => "int(10) unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1107. "oid" => array("type" => "int(10) unsigned", "not null" => "1"),
  1108. "otype" => array("type" => "tinyint(3) unsigned", "not null" => "1"),
  1109. "type" => array("type" => "tinyint(3) unsigned", "not null" => "1"),
  1110. "term" => array("type" => "varchar(255)", "not null" => "1"),
  1111. "url" => array("type" => "varchar(255)", "not null" => "1"),
  1112. "aid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1113. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1114. ),
  1115. "indexes" => array(
  1116. "PRIMARY" => array("tid"),
  1117. "oid_otype_type_term" => array("oid","otype","type","term"),
  1118. "uid_term_tid" => array("uid","term","tid"),
  1119. "type_term" => array("type","term"),
  1120. "uid_otype_type_term_tid" => array("uid","otype","type","term","tid"),
  1121. "otype_type_term_tid" => array("otype","type","term","tid"),
  1122. )
  1123. );
  1124. $database["thread"] = array(
  1125. "fields" => array(
  1126. "iid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0", "primary" => "1"),
  1127. "uid" => array("type" => "int(10) unsigned", "not null" => "1", "default" => "0"),
  1128. "contact-id" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1129. "created" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1130. "edited" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1131. "commented" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1132. "received" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1133. "changed" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1134. "wall" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1135. "private" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1136. "pubmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1137. "moderated" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1138. "visible" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1139. "spam" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1140. "starred" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1141. "ignored" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1142. "bookmark" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1143. "unseen" => array("type" => "tinyint(1)", "not null" => "1", "default" => "1"),
  1144. "deleted" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1145. "origin" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1146. "forum_mode" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1147. "mention" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1148. "network" => array("type" => "varchar(32)", "not null" => "1"),
  1149. ),
  1150. "indexes" => array(
  1151. "PRIMARY" => array("iid"),
  1152. "created" => array("created"),
  1153. "commented" => array("commented"),
  1154. "uid_network_commented" => array("uid","network","commented"),
  1155. "uid_network_created" => array("uid","network","created"),
  1156. "uid_contactid_commented" => array("uid","contact-id","commented"),
  1157. "uid_contactid_created" => array("uid","contact-id","created"),
  1158. "wall_private_received" => array("wall","private","received"),
  1159. "uid_created" => array("uid","created"),
  1160. "uid_commented" => array("uid","commented"),
  1161. )
  1162. );
  1163. $database["tokens"] = array(
  1164. "fields" => array(
  1165. "id" => array("type" => "varchar(40)", "not null" => "1", "primary" => "1"),
  1166. "secret" => array("type" => "text", "not null" => "1"),
  1167. "client_id" => array("type" => "varchar(20)", "not null" => "1"),
  1168. "expires" => array("type" => "int(11)", "not null" => "1"),
  1169. "scope" => array("type" => "varchar(200)", "not null" => "1"),
  1170. "uid" => array("type" => "int(11)", "not null" => "1"),
  1171. ),
  1172. "indexes" => array(
  1173. "PRIMARY" => array("id"),
  1174. )
  1175. );
  1176. $database["unique_contacts"] = array(
  1177. "fields" => array(
  1178. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1179. "url" => array("type" => "varchar(255)", "not null" => "1"),
  1180. "nick" => array("type" => "varchar(255)", "not null" => "1"),
  1181. "name" => array("type" => "varchar(255)", "not null" => "1"),
  1182. "avatar" => array("type" => "varchar(255)", "not null" => "1"),
  1183. ),
  1184. "indexes" => array(
  1185. "PRIMARY" => array("id"),
  1186. "url" => array("url"),
  1187. )
  1188. );
  1189. $database["user"] = array(
  1190. "fields" => array(
  1191. "uid" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1192. "guid" => array("type" => "varchar(64)", "not null" => "1"),
  1193. "username" => array("type" => "varchar(255)", "not null" => "1"),
  1194. "password" => array("type" => "varchar(255)", "not null" => "1"),
  1195. "nickname" => array("type" => "varchar(255)", "not null" => "1"),
  1196. "email" => array("type" => "varchar(255)", "not null" => "1"),
  1197. "openid" => array("type" => "varchar(255)", "not null" => "1"),
  1198. "timezone" => array("type" => "varchar(128)", "not null" => "1"),
  1199. "language" => array("type" => "varchar(32)", "not null" => "1", "default" => "en"),
  1200. "register_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1201. "login_date" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1202. "default-location" => array("type" => "varchar(255)", "not null" => "1"),
  1203. "allow_location" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1204. "theme" => array("type" => "varchar(255)", "not null" => "1"),
  1205. "pubkey" => array("type" => "text", "not null" => "1"),
  1206. "prvkey" => array("type" => "text", "not null" => "1"),
  1207. "spubkey" => array("type" => "text", "not null" => "1"),
  1208. "sprvkey" => array("type" => "text", "not null" => "1"),
  1209. "verified" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1210. "blocked" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1211. "blockwall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1212. "hidewall" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1213. "blocktags" => array("type" => "tinyint(1) unsigned", "not null" => "1", "default" => "0"),
  1214. "unkmail" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1215. "cntunkmail" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
  1216. "notify-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "65535"),
  1217. "page-flags" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1218. "prvnets" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1219. "pwdreset" => array("type" => "varchar(255)", "not null" => "1"),
  1220. "maxreq" => array("type" => "int(11)", "not null" => "1", "default" => "10"),
  1221. "expire" => array("type" => "int(11) unsigned", "not null" => "1", "default" => "0"),
  1222. "account_removed" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1223. "account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
  1224. "account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1225. "expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => "0000-00-00 00:00:00"),
  1226. "service_class" => array("type" => "varchar(32)", "not null" => "1"),
  1227. "def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
  1228. "allow_cid" => array("type" => "mediumtext", "not null" => "1"),
  1229. "allow_gid" => array("type" => "mediumtext", "not null" => "1"),
  1230. "deny_cid" => array("type" => "mediumtext", "not null" => "1"),
  1231. "deny_gid" => array("type" => "mediumtext", "not null" => "1"),
  1232. "openidserver" => array("type" => "text", "not null" => "1"),
  1233. ),
  1234. "indexes" => array(
  1235. "PRIMARY" => array("uid"),
  1236. "nickname" => array("nickname"),
  1237. )
  1238. );
  1239. $database["userd"] = array(
  1240. "fields" => array(
  1241. "id" => array("type" => "int(11)", "not null" => "1", "extra" => "auto_increment", "primary" => "1"),
  1242. "username" => array("type" => "varchar(255)", "not null" => "1"),
  1243. ),
  1244. "indexes" => array(
  1245. "PRIMARY" => array("id"),
  1246. "username" => array("username"),
  1247. )
  1248. );
  1249. return($database);
  1250. }
  1251. /*
  1252. * run from command line
  1253. */
  1254. function dbstructure_run(&$argv, &$argc) {
  1255. global $a, $db;
  1256. if(is_null($a)){
  1257. $a = new App;
  1258. }
  1259. if(is_null($db)) {
  1260. @include(".htconfig.php");
  1261. require_once("include/dba.php");
  1262. $db = new dba($db_host, $db_user, $db_pass, $db_data);
  1263. unset($db_host, $db_user, $db_pass, $db_data);
  1264. }
  1265. update_structure(true, true);
  1266. }
  1267. if (array_search(__file__,get_included_files())===0){
  1268. dbstructure_run($argv,$argc);
  1269. killme();
  1270. }