PageRenderTime 49ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/strawberry/1.1.2/convert/02x/index.php

http://goodgirl.googlecode.com/
PHP | 348 lines | 274 code | 69 blank | 5 comment | 43 complexity | aeadda61c9114daead27e4e42e11cb41 MD5 | raw file
  1. <?php
  2. /**
  3. * @package Private
  4. * @access private
  5. */
  6. $that = '-'; // ??? ???????? ?????? ? ?????
  7. #-------------------------------------------------------------------------------
  8. include '../../head.php';
  9. if (!$is_logged_in){
  10. exit(t('?? ?? ?????!'));
  11. }
  12. $abort = @ignore_user_abort(1);
  13. $path = realpath('.');
  14. if (!ini_get('safe_mode')){
  15. @set_time_limit(0);
  16. }
  17. function check_writable(){
  18. global $path;
  19. $handle = opendir($path);
  20. while ($file = readdir($handle)){
  21. if (substr($file, -3) == 'tmp'){
  22. if (is_file($file)){
  23. echo '<li><font color="'.(is_writable($file) ? 'green' : 'red').'">'.$file.'</font><br />';
  24. }
  25. }
  26. }
  27. }
  28. function not_null($file){
  29. global $path;
  30. if (file_exists($path.'/'.$file.'.tmp')){
  31. if (filesize($path.'/'.$file.'.tmp')){
  32. return true;
  33. } else {
  34. return false;
  35. }
  36. } else {
  37. return false;
  38. }
  39. }
  40. function write_and_go($file, $text = 'ok'){
  41. global $PHP_SELF, $path;
  42. @chmod($path.'/'.$file, 0777);
  43. @file_write($path.'/'.$file.'.tmp', $text);
  44. @header('Location: '.$PHP_SELF);
  45. }
  46. if (not_null('news')){
  47. foreach (file($path.'/news.tmp') as $fo){
  48. $fo_arr = explode('|', $fo);
  49. $post_id[$fo_arr[0]] = $fo_arr[1];
  50. }
  51. }
  52. if ($fp = file($path.'/data/counter.txt')){
  53. foreach ($fp as $fo){
  54. $fo_arr = explode('|', $fo);
  55. $counter[$fo_arr[0]] = $fo_arr[1];
  56. }
  57. }
  58. if ($_GET['action'] == 'users'){
  59. $fp = file($path.'/data/users.db.php');
  60. foreach ($fp as $fo){
  61. $fo_arr = explode('|', $fo);
  62. if (!$sql->update(array(
  63. 'table' => 'users',
  64. 'where' => array("username = $fo_arr[2]"),
  65. 'values' => array(
  66. 'date' => $fo_arr[0],
  67. 'usergroup' => $fo_arr[1],
  68. 'name' => $fo_arr[4],
  69. 'mail' => $fo_arr[5],
  70. 'publications' => $fo_arr[6],
  71. 'hide_mail' => $fo_arr[7],
  72. 'avatar' => $fo_arr[8],
  73. 'last_visit' => $fo_arr[9],
  74. 'homepage' => $fo_arr[10],
  75. 'icq' => $fo_arr[11],
  76. 'location' => $fo_arr[12],
  77. 'about' => $fo_arr[13],
  78. 'lj_username' => $fo_arr[14]
  79. )
  80. )) and $fo_arr[2]){
  81. $sql->insert(array(
  82. 'table' => 'users',
  83. 'values' => array(
  84. 'date' => $fo_arr[0],
  85. 'usergroup' => $fo_arr[1],
  86. 'username' => $fo_arr[2],
  87. 'password' => md5($fo_arr[3]),
  88. 'name' => $fo_arr[4],
  89. 'mail' => $fo_arr[5],
  90. 'publications' => $fo_arr[6],
  91. 'hide_mail' => $fo_arr[7],
  92. 'avatar' => $fo_arr[8],
  93. 'last_visit' => $fo_arr[9],
  94. 'homepage' => $fo_arr[10],
  95. 'icq' => $fo_arr[11],
  96. 'location' => $fo_arr[12],
  97. 'about' => $fo_arr[13],
  98. 'lj_username' => $fo_arr[14]
  99. )
  100. ));
  101. }
  102. }
  103. write_and_go('users');
  104. }
  105. if ($_GET['action'] == 'categories'){
  106. $fp = file($path.'/data/category.db.php');
  107. foreach ($fp as $fo){
  108. $fo_arr = explode('|', $fo);
  109. $sql->insert(array(
  110. 'table' => 'categories',
  111. 'values' => array(
  112. 'id' => $fo_arr[0],
  113. 'name' => $fo_arr[1],
  114. 'icon' => $fo_arr[2],
  115. 'url' => ($fo_arr[3] ? $fo_arr[3] : totranslit($fo_arr[1], $that)),
  116. 'parent' => $fo_arr[4]
  117. )
  118. ));
  119. }
  120. write_and_go('categories');
  121. }
  122. if ($_GET['action'] == 'news'){
  123. $news_arr[] = $path.'/data/news.txt';
  124. $fdir = opendir($path.'/data/archives');
  125. while ($file = readdir($fdir)){
  126. $file_arr = explode('.', $file);
  127. if (is_numeric($file_arr[0]) and $file_arr[1] == 'news'){
  128. $news_arr[] = $path.'/data/archives/'.$file;
  129. }
  130. }
  131. foreach ($news_arr as $file){
  132. foreach (file($file) as $fo){
  133. $all_news_arr[] = $fo;
  134. }
  135. }
  136. sort($all_news_arr);
  137. for ($i = 0; $i < sizeof($all_news_arr); $i++){
  138. $fo_arr = explode('|', $all_news_arr[$i]);
  139. $sql->insert(array(
  140. 'table' => 'news',
  141. 'values' => array(
  142. 'date' => $fo_arr[0],
  143. 'author' => $fo_arr[1],
  144. 'title' => $fo_arr[2],
  145. 'short' => strlen($fo_arr[3]),
  146. 'full' => ($fo_arr[4] ? strlen($fo_arr[4]) : 0),
  147. 'avatar' => $fo_arr[5],
  148. 'views' => $counter[$fo_arr[0]],
  149. 'category' => $fo_arr[6],
  150. 'url' => ($fo_arr[7] ? namespace($fo_arr[7]) : namespace(totranslit($fo_arr[2], $that)))
  151. )
  152. ));
  153. if ($config['database'] == 'txtsql'){
  154. $last_insert_id = ($sql->last_insert_id('news', '', 'id') + $i);
  155. } else {
  156. $last_insert_id = $sql->last_insert_id('news', '', 'id');
  157. }
  158. $write .= $fo_arr[0].'|'.$last_insert_id."\r\n";
  159. $sql->insert(array(
  160. 'table' => 'story',
  161. 'values' => array(
  162. 'post_id' => $last_insert_id,
  163. 'short' => $fo_arr[3],
  164. 'full' => $fo_arr[4]
  165. )
  166. ));
  167. }
  168. write_and_go('news', $write);
  169. }
  170. if ($_GET['action'] == 'comments'){
  171. $comm_arr[] = $path.'/data/comments.txt';
  172. $fdir = opendir($path.'/data/archives');
  173. while ($file = readdir($fdir)){
  174. $file_arr = explode('.', $file);
  175. if (is_numeric($file_arr[0]) and $file_arr[1] == 'comments'){
  176. $comm_arr[] = $path.'/data/archives/'.$file;
  177. }
  178. }
  179. foreach ($comm_arr as $file){
  180. foreach (file($file) as $fo){
  181. $all_comm_arr[] = $fo;
  182. }
  183. }
  184. sort($all_comm_arr);
  185. foreach ($all_comm_arr as $comment_line){
  186. $comment_arr_1 = explode('|>|', $comment_line);
  187. $comment_arr_2 = explode('||', $comment_arr_1[1]);
  188. foreach ($comment_arr_2 as $fo){
  189. $fo_arr = explode('|', $fo);
  190. if ($fo_arr[2] and $post_id[$comment_arr_1[0]]){
  191. $sql->insert(array(
  192. 'table' => 'comments',
  193. 'values' => array(
  194. 'date' => $fo_arr[0],
  195. 'author' => $fo_arr[1],
  196. 'mail' => $fo_arr[2],
  197. 'ip' => $fo_arr[3],
  198. 'comment' => $fo_arr[4],
  199. 'reply' => $fo_arr[5],
  200. 'post_id' => $post_id[$comment_arr_1[0]],
  201. )
  202. ));
  203. $sql->update(array(
  204. 'table' => 'news',
  205. 'where' => array('id = '.$post_id[$comment_arr_1[0]]),
  206. 'values' => array('comments' => count($comment_arr_2) - 1)
  207. ));
  208. }
  209. }
  210. }
  211. write_and_go('comments');
  212. }
  213. if ($_GET['action'] == 'xfields'){
  214. function xz($id){
  215. global $post_id, $repl1;
  216. $repl1 = str_replace("\r\n", '', $post_id[$id]);
  217. return $repl1;
  218. }
  219. $file1 = file($path.'/data/plugins/xfields-data.php');
  220. $file2 = file($path.'/data/xfieldsdata.txt');
  221. $file3 = file_read($path.'/data/xfields.txt');
  222. foreach ($file1 as $fo1){
  223. $replace1_tmp = preg_replace('/([0-9]{10})/ie', "xz('\\1')", $fo1);
  224. if ($repl1){
  225. $replace1 .= $replace1_tmp;
  226. }
  227. }
  228. foreach ($file2 as $fo2){
  229. $fo_arr2 = explode('|>|', $fo2);
  230. if ($replace2_tmp = str_replace("\r\n", '', $post_id[$fo_arr2[0]])){
  231. $replace2 .= $replace2_tmp.'|>|'.$fo_arr2[1];
  232. }
  233. }
  234. file_write($cutepath.'/data/xfields-data.php', "<?php\r\n\$array = array (\r\n".$replace1);
  235. file_write($cutepath.'/data/xfields-data.txt', $replace2);
  236. file_write($cutepath.'/data/xfields.txt', $file3);
  237. write_and_go('xfields');
  238. }
  239. ?>
  240. <b><?=t('???????? ????'); ?></b>
  241. <?=check_writable(); ?>
  242. <b><?=t('?????????'); ?></b>
  243. <?
  244. if (!not_null('users')){
  245. ?>
  246. <li><a href="<?=$PHP_SELF; ?>?action=users"><?=t('?????????????'); ?>*</a>
  247. <?
  248. }
  249. if (!not_null('categories')){
  250. ?>
  251. <li><a href="<?=$PHP_SELF; ?>?action=categories"><?=t('?????????'); ?></a>
  252. <?
  253. }
  254. if (!not_null('news')){
  255. ?>
  256. <li><a href="<?=$PHP_SELF; ?>?action=news"><?=t('???????'); ?></a>
  257. <?
  258. }
  259. if (not_null('news')){
  260. if (!not_null('comments')){
  261. ?>
  262. <li><a href="<?=$PHP_SELF; ?>?action=comments"><?=t('???????????'); ?></a>
  263. <?
  264. }
  265. if (!not_null('xfields')){
  266. ?>
  267. <li><a href="<?=$PHP_SELF; ?>?action=xfields"><?=t('?????????????? ???? (XFields)'); ?></a>
  268. <?
  269. }
  270. } else {
  271. ?>
  272. <li><?=t('???????????'); ?>**
  273. <li><?=t('?????????????? ???? (XFields)'); ?>**
  274. <?
  275. }
  276. ?>
  277. <p>* <?=t('? ???, ??? ???? (?? ?????? ???????) ??? ????? ?????????? ?? ?????? ????, ????? ???????'); ?>
  278. <p>** <?=t('??????? ????? ???????????? ???? ????????'); ?>
  279. <p><?=t('?????? ????????? ??? ??????????? ???. ???????? ??? ?? ???????, ???? ???? ???????????, ?? ????????????? ???? ?? ????????? ???????, ??? ??? ?????????? ?????, ? ????????? ???? ?? ?????? ???.'); ?>