Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add

  • Loading branch information...
commit fe5acb4bba937ca397fc72bb1445ab47507a78bc 0 parents
@w495 authored
Showing with 17,581 additions and 0 deletions.
  1. 0  .disista_matrasy
  2. +8 −0 .gitignore
  3. 0  coder/modeller/.keep
  4. 0  coder/reader/.keep
  5. +16 −0 decoder/rest/.gitignore
  6. +30 −0 decoder/rest/Makefile
  7. 0  decoder/rest/ebin/.keep
  8. +25 −0 decoder/rest/include/common.hrl
  9. +13 −0 decoder/rest/include/db.hrl
  10. +8 −0 decoder/rest/include/web.hrl
  11. +20 −0 decoder/rest/include/web_session.hrl
  12. 0  decoder/rest/priv/.keep
  13. 0  decoder/rest/priv/sql/.keep
  14. BIN  decoder/rest/rebar
  15. +68 −0 decoder/rest/src/app/web.erl
  16. +50 −0 decoder/rest/src/app/web_app.erl
  17. +77 −0 decoder/rest/src/app/web_deps.erl
  18. +56 −0 decoder/rest/src/app/web_sup.erl
  19. +137 −0 decoder/rest/src/app/web_web.erl
  20. +48 −0 decoder/rest/src/controllers/home.erl
  21. +18 −0 decoder/rest/src/utils/config.erl
  22. +201 −0 decoder/rest/src/utils/reloader.erl
  23. +722 −0 decoder/rest/src/utils/utils.erl
  24. +23 −0 decoder/rest/src/web.app.src
  25. +28 −0 decoder/rest/start-rest.sh
  26. +16 −0 decoder/web/.gitignore
  27. +30 −0 decoder/web/Makefile
  28. 0  decoder/web/ebin/.keep
  29. +25 −0 decoder/web/include/common.hrl
  30. +104 −0 decoder/web/include/dao.hrl
  31. +13 −0 decoder/web/include/db.hrl
  32. +42 −0 decoder/web/include/web.hrl
  33. +20 −0 decoder/web/include/web_session.hrl
  34. 0  decoder/web/priv/.keep
  35. +21 −0 decoder/web/priv/etc/souces/common/Emake
  36. +11 −0 decoder/web/priv/etc/souces/common/Emake_tmpl
  37. +1 −0  decoder/web/priv/etc/souces/common/Emakefile
  38. +8 −0 decoder/web/priv/etc/souces/common/Makefile
  39. +14 −0 decoder/web/priv/etc/souces/common/include/customer.hrl
  40. +6 −0 decoder/web/priv/etc/souces/common/include/customerGroup.hrl
  41. +7 −0 decoder/web/priv/etc/souces/common/include/permission.hrl
  42. +463 −0 decoder/web/priv/etc/souces/common/src/amnesia.erl
  43. +219 −0 decoder/web/priv/etc/souces/common/src/appmgr.erl
  44. +309 −0 decoder/web/priv/etc/souces/common/src/clog.erl
  45. +45 −0 decoder/web/priv/etc/souces/common/src/config.erl
  46. +197 −0 decoder/web/priv/etc/souces/common/src/ctl.erl
  47. +47 −0 decoder/web/priv/etc/souces/common/src/db.erl
  48. +55 −0 decoder/web/priv/etc/souces/common/src/db2json.erl
  49. +295 −0 decoder/web/priv/etc/souces/common/src/flog.erl
  50. +47 −0 decoder/web/priv/etc/souces/common/src/mysql2json.erl
  51. +272 −0 decoder/web/priv/etc/souces/common/src/pgConPool.erl
  52. +65 −0 decoder/web/priv/etc/souces/common/src/reloader2.erl
  53. +52 −0 decoder/web/priv/etc/souces/common/src/smppg_api.erl
  54. +33 −0 decoder/web/priv/etc/souces/common/src/toBiz.erl
  55. +73 −0 decoder/web/priv/etc/souces/common/src/userLdapDAO.erl
  56. +722 −0 decoder/web/priv/etc/souces/common/src/utils.erl
  57. +12 −0 decoder/web/priv/etc/souces/common/src/uuid.erl
  58. +30 −0 decoder/web/priv/etc/souces/common/src/web_session_DAO.erl
  59. +157 −0 decoder/web/priv/etc/souces/depricated/src/assist_srv.erl
  60. +217 −0 decoder/web/priv/etc/souces/depricated/src/dao/dao.erl
  61. +106 −0 decoder/web/priv/etc/souces/depricated/src/dao/dao_fCustomer.erl
  62. +865 −0 decoder/web/priv/etc/souces/depricated/src/dao/dao_fDirectory.erl
  63. +30 −0 decoder/web/priv/etc/souces/depricated/src/dao/web_session_DAO.erl
  64. +49 −0 decoder/web/priv/etc/souces/depricated/src/port_util.erl
  65. +1 −0  decoder/web/priv/etc/souces/depricated/src/sys/amnesia.erl
  66. +1 −0  decoder/web/priv/etc/souces/depricated/src/sys/appmgr.erl
  67. +1 −0  decoder/web/priv/etc/souces/depricated/src/sys/pgConPool.erl
  68. +1 −0  decoder/web/priv/etc/souces/depricated/src/sys/reloader2.erl
  69. +1 −0  decoder/web/priv/etc/souces/depricated/src/util/config.erl
  70. +24 −0 decoder/web/priv/etc/souces/depricated/src/util/crpc.erl
  71. +1 −0  decoder/web/priv/etc/souces/depricated/src/util/ctl.erl
  72. +1 −0  decoder/web/priv/etc/souces/depricated/src/util/db.erl
  73. +1 −0  decoder/web/priv/etc/souces/depricated/src/util/db2json.erl
  74. +567 −0 decoder/web/priv/etc/souces/depricated/src/util/erltl.erl
  75. +104 −0 decoder/web/priv/etc/souces/depricated/src/util/mnesiaToJson.erl
  76. +51 −0 decoder/web/priv/etc/souces/depricated/src/util/norm.erl
  77. +184 −0 decoder/web/priv/etc/souces/depricated/src/util/pg2xml.erl
  78. +1 −0  decoder/web/priv/etc/souces/depricated/src/util/utils.erl
  79. +1 −0  decoder/web/priv/etc/souces/depricated/src/util/uuid.erl
  80. +11 −0 decoder/web/priv/etc/souces/depricated/support/Emake_tmpl
  81. +26 −0 decoder/web/priv/etc/souces/depricated/support/app.config.template
  82. +27 −0 decoder/web/priv/etc/souces/depricated/support/app_dev.config.template
  83. +31 −0 decoder/web/priv/etc/souces/depricated/support/ctl
  84. +28 −0 decoder/web/priv/etc/souces/depricated/support/ctl_dev
  85. +66 −0 decoder/web/priv/etc/souces/depricated/support/include.mk
  86. +27 −0 decoder/web/priv/etc/souces/depricated/support/start.sh
  87. 0  decoder/web/priv/sql/.keep
  88. +44 −0 decoder/web/priv/static/game.html
  89. +12 −0 decoder/web/priv/static/index.html
  90. BIN  decoder/web/priv/static/site-media/@favicon.ico
  91. BIN  decoder/web/priv/static/site-media/content/slide-show.png
  92. BIN  decoder/web/priv/static/site-media/content/thumb_01.jpg
  93. BIN  decoder/web/priv/static/site-media/content/thumb_02.jpg
  94. BIN  decoder/web/priv/static/site-media/content/thumb_03.jpg
  95. BIN  decoder/web/priv/static/site-media/content/thumb_04.png
  96. BIN  decoder/web/priv/static/site-media/content/thumb_05.jpg
  97. BIN  decoder/web/priv/static/site-media/content/thumb_06.jpg
  98. BIN  decoder/web/priv/static/site-media/content/thumb_armo.jpg
  99. BIN  decoder/web/priv/static/site-media/content/thumb_cosmo-filre.jpg
  100. BIN  decoder/web/priv/static/site-media/content/thumb_filre-sport.jpg
  101. BIN  decoder/web/priv/static/site-media/css/css-images/flag-01.png
  102. BIN  decoder/web/priv/static/site-media/css/css-images/flag.png
  103. BIN  decoder/web/priv/static/site-media/css/css-images/fon/background-gray-line.png
  104. BIN  decoder/web/priv/static/site-media/css/css-images/fon/bottom-banner-line.png
  105. BIN  decoder/web/priv/static/site-media/css/css-images/fon/bottom-light-blue-line.png
  106. BIN  decoder/web/priv/static/site-media/css/css-images/fon/bottom-light-gray-line.png
  107. BIN  decoder/web/priv/static/site-media/css/css-images/fon/bottom-teel-line.png
  108. BIN  decoder/web/priv/static/site-media/css/css-images/fon/doc-blue-line.png
  109. BIN  decoder/web/priv/static/site-media/css/css-images/fon/docs-blue-line.png
  110. BIN  decoder/web/priv/static/site-media/css/css-images/fon/left-gray-line.png
  111. BIN  decoder/web/priv/static/site-media/css/css-images/fon/line-bullet.png
  112. BIN  decoder/web/priv/static/site-media/css/css-images/fon/news-blue-line.png
  113. BIN  decoder/web/priv/static/site-media/css/css-images/fon/right-gray-line.png
  114. BIN  decoder/web/priv/static/site-media/css/css-images/fon/spec/top-gray-line.png
  115. BIN  decoder/web/priv/static/site-media/css/css-images/fon/top-blue-line.png
  116. BIN  decoder/web/priv/static/site-media/css/css-images/fon/top-light-blue-line.png
  117. BIN  decoder/web/priv/static/site-media/css/css-images/fon/top-logo-line.png
  118. BIN  decoder/web/priv/static/site-media/css/css-images/icons/e-mail.png
  119. BIN  decoder/web/priv/static/site-media/css/css-images/icons/home.png
  120. BIN  decoder/web/priv/static/site-media/css/css-images/icons/lens.png
  121. BIN  decoder/web/priv/static/site-media/css/css-images/icons/map.png
  122. BIN  decoder/web/priv/static/site-media/css/css-images/icons/msw.png
  123. BIN  decoder/web/priv/static/site-media/css/css-images/icons/pdf.png
  124. BIN  decoder/web/priv/static/site-media/css/css-images/icons/phone.png
  125. BIN  decoder/web/priv/static/site-media/css/css-images/icons/printer.png
  126. BIN  decoder/web/priv/static/site-media/css/css-images/icons/visually-impaired-version.png
  127. BIN  decoder/web/priv/static/site-media/css/css-images/logo-trans-black.png
  128. BIN  decoder/web/priv/static/site-media/css/css-images/logo-trans-blue.png
  129. BIN  decoder/web/priv/static/site-media/css/css-images/logo-trans-white.png
  130. BIN  decoder/web/priv/static/site-media/css/css-images/logo.png
  131. +145 −0 decoder/web/priv/static/site-media/css/css-images/styles.css
  132. BIN  decoder/web/priv/static/site-media/css/css-images/transport/air-transport-blue.png
  133. BIN  decoder/web/priv/static/site-media/css/css-images/transport/air-transport-orange.png
  134. BIN  decoder/web/priv/static/site-media/css/css-images/transport/air-transport-tr-black.png
  135. BIN  decoder/web/priv/static/site-media/css/css-images/transport/air-transport-tr-blue.png
  136. BIN  decoder/web/priv/static/site-media/css/css-images/transport/air-transport-tr-white.png
  137. BIN  decoder/web/priv/static/site-media/css/css-images/transport/surface-transport-blue.png
  138. BIN  decoder/web/priv/static/site-media/css/css-images/transport/surface-transport-orange.png
  139. BIN  decoder/web/priv/static/site-media/css/css-images/transport/surface-transport-tr-black.png
  140. BIN  decoder/web/priv/static/site-media/css/css-images/transport/surface-transport-tr-blue.png
  141. BIN  decoder/web/priv/static/site-media/css/css-images/transport/surface-transport-tr-white.png
  142. BIN  decoder/web/priv/static/site-media/css/css-images/transport/water-transport-blue.png
  143. BIN  decoder/web/priv/static/site-media/css/css-images/transport/water-transport-orange.png
  144. BIN  decoder/web/priv/static/site-media/css/css-images/transport/water-transport-tr-black.png
  145. BIN  decoder/web/priv/static/site-media/css/css-images/transport/water-transport-tr-blue.png
  146. BIN  decoder/web/priv/static/site-media/css/css-images/transport/water-transport-tr-white.png
  147. +33 −0 decoder/web/priv/static/site-media/css/normal-screen-base.css
  148. BIN  decoder/web/priv/static/site-media/favicon.ico
  149. +4 −0 decoder/web/priv/static/site-media/flash/_swfobject.js
  150. +100 −0 decoder/web/priv/static/site-media/flash/db.xml
  151. +41 −0 decoder/web/priv/static/site-media/flash/editor.html
  152. BIN  decoder/web/priv/static/site-media/flash/editor.swf
  153. BIN  decoder/web/priv/static/site-media/flash/expressInstall.swf
  154. +41 −0 decoder/web/priv/static/site-media/flash/game.html
  155. BIN  decoder/web/priv/static/site-media/flash/game.swf
  156. +28 −0 decoder/web/priv/static/site-media/flash/index.html
  157. +17 −0 decoder/web/priv/static/site-media/flash/index_dynamic.html
  158. +4 −0 decoder/web/priv/static/site-media/flash/js/swfobject.js
  159. +1 −0  decoder/web/priv/static/site-media/flash/map.txt
  160. +4 −0 decoder/web/priv/static/site-media/flash/old/crossdomain.xml
  161. +68 −0 decoder/web/priv/static/site-media/flash/old/db.xml
  162. +41 −0 decoder/web/priv/static/site-media/flash/old/editor.html
  163. BIN  decoder/web/priv/static/site-media/flash/old/editor.swf
  164. BIN  decoder/web/priv/static/site-media/flash/old/expressInstall.swf
  165. +42 −0 decoder/web/priv/static/site-media/flash/old/game.html
  166. BIN  decoder/web/priv/static/site-media/flash/old/game.swf
  167. +40 −0 decoder/web/priv/static/site-media/flash/old/index.html
  168. +4 −0 decoder/web/priv/static/site-media/flash/old/swfobject.js
  169. BIN  decoder/web/priv/static/site-media/flash/old/visuals.swf
  170. +199 −0 decoder/web/priv/static/site-media/flash/old/visuals.xml
  171. +194 −0 decoder/web/priv/static/site-media/flash/old/~visuals.xml
  172. +70 −0 decoder/web/priv/static/site-media/flash/src/expressInstall.as
  173. BIN  decoder/web/priv/static/site-media/flash/src/expressInstall.fla
  174. +777 −0 decoder/web/priv/static/site-media/flash/src/swfobject.js
  175. +4 −0 decoder/web/priv/static/site-media/flash/swfobject.js
  176. BIN  decoder/web/priv/static/site-media/flash/swfobject/expressInstall.swf
  177. +28 −0 decoder/web/priv/static/site-media/flash/swfobject/index.html
  178. +17 −0 decoder/web/priv/static/site-media/flash/swfobject/index_dynamic.html
  179. +70 −0 decoder/web/priv/static/site-media/flash/swfobject/src/expressInstall.as
  180. BIN  decoder/web/priv/static/site-media/flash/swfobject/src/expressInstall.fla
  181. +777 −0 decoder/web/priv/static/site-media/flash/swfobject/src/swfobject.js
  182. +4 −0 decoder/web/priv/static/site-media/flash/swfobject/swfobject.js
  183. BIN  decoder/web/priv/static/site-media/flash/swfobject/test.swf
  184. BIN  decoder/web/priv/static/site-media/flash/swfobject_2_2.zip
  185. BIN  decoder/web/priv/static/site-media/flash/test.swf
  186. BIN  decoder/web/priv/static/site-media/flash/visuals.swf
  187. +213 −0 decoder/web/priv/static/site-media/flash/visuals.xml
  188. +204 −0 decoder/web/priv/static/site-media/flash/visuals.xml.1
  189. BIN  decoder/web/priv/static/site-media/images/defaults/bottom-banner.png
  190. BIN  decoder/web/priv/static/site-media/images/defaults/c-user.png
  191. BIN  decoder/web/priv/static/site-media/images/defaults/expert.png
  192. BIN  decoder/web/priv/static/site-media/images/defaults/game-banner.png
  193. BIN  decoder/web/priv/static/site-media/images/defaults/news.png
  194. BIN  decoder/web/priv/static/site-media/images/defaults/right-banner.png
  195. BIN  decoder/web/priv/static/site-media/images/defaults/user.png
  196. BIN  decoder/web/priv/static/site-media/images/fade-slider/slide1.png
  197. BIN  decoder/web/priv/static/site-media/images/fade-slider/slide2.png
  198. BIN  decoder/web/priv/static/site-media/images/fade-slider/slide3.png
  199. BIN  decoder/web/priv/static/site-media/images/logo-trans-bw.png
  200. BIN  decoder/web/priv/static/site-media/images/logo-trans-white.png
  201. BIN  decoder/web/priv/static/site-media/images/logo-trans.png
  202. BIN  decoder/web/priv/static/site-media/images/logo-with-text.png
  203. BIN  decoder/web/priv/static/site-media/images/logo.png
  204. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image002.jpg
  205. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image004.jpg
  206. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image006.jpg
  207. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image008.jpg
  208. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image010.jpg
  209. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image012.jpg
  210. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image014.jpg
  211. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image016.jpg
  212. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image018.jpg
  213. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image020.jpg
  214. BIN  decoder/web/priv/static/site-media/images/manual-game-files/image022.jpg
  215. BIN  decoder/web/priv/static/site-media/images/mobile/blank.gif
  216. BIN  decoder/web/priv/static/site-media/images/mobile/home.png
  217. BIN  decoder/web/priv/static/site-media/images/mobile/logo-trans.png
  218. BIN  decoder/web/priv/static/site-media/images/mobile/menu.png
  219. BIN  decoder/web/priv/static/site-media/images/mobile/news.png
  220. +12 −0 decoder/web/priv/static/site-media/index.html
  221. +8 −0 decoder/web/priv/static/site-media/js/authorised-page.js
  222. +32 −0 decoder/web/priv/static/site-media/js/banners.js
  223. +21 −0 decoder/web/priv/static/site-media/js/common-page.js
  224. +24 −0 decoder/web/priv/static/site-media/js/game-page.js
  225. +49 −0 decoder/web/priv/static/site-media/js/game.js
  226. +17 −0 decoder/web/priv/static/site-media/js/google-search-get.js
  227. +9 −0 decoder/web/priv/static/site-media/js/google-search.js
  228. +4 −0 decoder/web/priv/static/site-media/js/jquery.min.js
  229. +9 −0 decoder/web/priv/static/site-media/js/list-page.js
  230. +63 −0 decoder/web/priv/static/site-media/js/login.js
  231. +17 −0 decoder/web/priv/static/site-media/js/mobile/google-search-get.js
  232. +51 −0 decoder/web/priv/static/site-media/js/mobile/init.js
  233. +1,037 −0 decoder/web/priv/static/site-media/js/mobile/iscroll.js
  234. +56 −0 decoder/web/priv/static/site-media/js/mobile/mini.js
  235. +110 −0 decoder/web/priv/static/site-media/js/slider.js
  236. +10 −0 decoder/web/priv/static/site-media/js/title-page.js
  237. +520 −0 decoder/web/priv/xsl/dtd/html-entities.dtd
  238. +198 −0 decoder/web/priv/xsl/dtd/html-latin-1.ent
  239. +82 −0 decoder/web/priv/xsl/dtd/html-special.ent
  240. +239 −0 decoder/web/priv/xsl/dtd/xhtml-symbol.ent
  241. +32 −0 decoder/web/priv/xsl/mobile/contacts/list.xsl
  242. +34 −0 decoder/web/priv/xsl/mobile/doc/details.xsl
  243. +50 −0 decoder/web/priv/xsl/mobile/home/index-print.xsl
  244. +50 −0 decoder/web/priv/xsl/mobile/home/index-spec.xsl
  245. +50 −0 decoder/web/priv/xsl/mobile/home/index.xsl
  246. +26 −0 decoder/web/priv/xsl/mobile/hotline/index.xsl
  247. +34 −0 decoder/web/priv/xsl/mobile/news/details.xsl
  248. +61 −0 decoder/web/priv/xsl/mobile/news/includes/news-list.xsl
  249. +31 −0 decoder/web/priv/xsl/mobile/news/list.xsl
  250. +52 −0 decoder/web/priv/xsl/mobile/regulatory/list.xsl
  251. +31 −0 decoder/web/priv/xsl/mobile/search/list.xsl
  252. +53 −0 decoder/web/priv/xsl/mobile/secure/list.xsl
  253. +125 −0 decoder/web/priv/xsl/mobile/shared/master/android.html
  254. +196 −0 decoder/web/priv/xsl/mobile/shared/master/root.xsl
  255. +1 −0  decoder/web/priv/xsl/mobile/shared/utils
  256. +1 −0  decoder/web/priv/xsl/mobile/shared/widgets
  257. +26 −0 decoder/web/priv/xsl/mobile/terms/includes/leters-list.xsl
  258. +27 −0 decoder/web/priv/xsl/mobile/terms/includes/terms-list.xsl
  259. +50 −0 decoder/web/priv/xsl/mobile/terms/list.xsl
  260. +33 −0 decoder/web/priv/xsl/mobile/transport/details.xsl
  261. +40 −0 decoder/web/priv/xsl/normal/conf/details-print.xsl
  262. +38 −0 decoder/web/priv/xsl/normal/conf/details-spec.xsl
  263. +42 −0 decoder/web/priv/xsl/normal/conf/details.xsl
  264. +28 −0 decoder/web/priv/xsl/normal/conf/includes/ask-body.xsl
  265. +64 −0 decoder/web/priv/xsl/normal/conf/includes/dirs-list.xsl
  266. +228 −0 decoder/web/priv/xsl/normal/conf/includes/doc-body.xsl
  267. +20 −0 decoder/web/priv/xsl/normal/conf/includes/docs-container-header.xsl
  268. +298 −0 decoder/web/priv/xsl/normal/conf/includes/question-body.xsl
  269. +30 −0 decoder/web/priv/xsl/normal/conf/list-print.xsl
  270. +30 −0 decoder/web/priv/xsl/normal/conf/list-spec.xsl
  271. +29 −0 decoder/web/priv/xsl/normal/conf/list.xsl
  272. +31 −0 decoder/web/priv/xsl/normal/contacts/list-print.xsl
  273. +30 −0 decoder/web/priv/xsl/normal/contacts/list-spec.xsl
  274. +30 −0 decoder/web/priv/xsl/normal/contacts/list.xsl
  275. +28 −0 decoder/web/priv/xsl/normal/doc/details-print.xsl
  276. +31 −0 decoder/web/priv/xsl/normal/doc/details-spec.xsl
  277. +43 −0 decoder/web/priv/xsl/normal/doc/details.xsl
  278. +35 −0 decoder/web/priv/xsl/normal/doc/includes/docs-container-header.xsl
  279. +116 −0 decoder/web/priv/xsl/normal/doc/includes/~doc-body.xsl
  280. +327 −0 decoder/web/priv/xsl/normal/game/details-print.xsl
  281. +327 −0 decoder/web/priv/xsl/normal/game/details-spec.xsl
  282. +331 −0 decoder/web/priv/xsl/normal/game/details.xsl
  283. +85 −0 decoder/web/priv/xsl/normal/game/index.xsl
  284. +61 −0 decoder/web/priv/xsl/normal/home/includes/news-list.xsl
  285. +75 −0 decoder/web/priv/xsl/normal/home/index-print.xsl
  286. +74 −0 decoder/web/priv/xsl/normal/home/index-spec.xsl
  287. +70 −0 decoder/web/priv/xsl/normal/home/index.xsl
  288. +92 −0 decoder/web/priv/xsl/normal/hotline/includes/xml-hotlinegen.xsl
  289. +367 −0 decoder/web/priv/xsl/normal/hotline/includes/xml-hotlinegen/hotline.xml
  290. +31 −0 decoder/web/priv/xsl/normal/hotline/index-print.xsl
  291. +29 −0 decoder/web/priv/xsl/normal/hotline/index-spec.xsl
  292. +32 −0 decoder/web/priv/xsl/normal/hotline/index.xsl
  293. +26 −0 decoder/web/priv/xsl/normal/hotline/list.xsl
  294. +33 −0 decoder/web/priv/xsl/normal/news/details-print.xsl
  295. +34 −0 decoder/web/priv/xsl/normal/news/details-spec.xsl
  296. +34 −0 decoder/web/priv/xsl/normal/news/details.xsl
  297. +112 −0 decoder/web/priv/xsl/normal/news/includes/news-list.xsl
  298. +37 −0 decoder/web/priv/xsl/normal/news/list-print.xsl
  299. +38 −0 decoder/web/priv/xsl/normal/news/list-spec.xsl
  300. +36 −0 decoder/web/priv/xsl/normal/news/list.xsl
Sorry, we could not display the entire diff because too many files (434) changed.
0  .disista_matrasy
No changes.
8 .gitignore
@@ -0,0 +1,8 @@
+*~
+*.beam
+*.bup
+*.log
+*.dump
+*.swp
+*.app
+*.so
0  coder/modeller/.keep
No changes.
0  coder/reader/.keep
No changes.
16 decoder/rest/.gitignore
@@ -0,0 +1,16 @@
+*~
+*.beam
+*.bup
+*.log
+*.dump
+*.swp
+*.app
+*.so
+*.trace
+
+*priv/data*
+*priv/logs*
+
+*stub.*
+
+deps/*
30 decoder/rest/Makefile
@@ -0,0 +1,30 @@
+# default
+
+
+CC=g++
+EC=./rebar
+EFLAGS=compile
+
+ESRC_DIR=src
+EONJ_DIR=ebin
+
+CSRC_DIR=csrc
+CONJ_DIR=cbin
+
+CSRC=$(CSRC_DIR)/libxslt_adapter.c
+COBJ=$(CONJ_DIR)/libxslt_adapter
+CFLAGS=-lxml2 -lxslt
+CINCLUDES=/usr/include/libxml2
+
+all: c_bin
+ $(EC) $(EFLAGS)
+
+c_bin:
+ $(CC) -o $(COBJ) $(CSRC) -I$(CINCLUDES) $(CFLAGS)
+
+cleanall: clean
+ rm -rf $(CONJ_DIR)/*
+
+clean:
+ rm -rf $(EONJ_DIR)/*
+
0  decoder/rest/ebin/.keep
No changes.
25 decoder/rest/include/common.hrl
@@ -0,0 +1,25 @@
+% -----------------------------------------------------------------------------
+%% common defines
+% -----------------------------------------------------------------------------
+
+-define( FMT(F,P), lists:flatten(io_lib:format(F,P)) ).
+-define( APP, web).
+-define( CFG_PROCS, [{gen_server, m_pinger},
+ {gen_event, error_logger}]
+ ).
+
+-ifdef(debug).
+-define(QOOXDOOBUILD, "source").
+-else.
+-define(QOOXDOOBUILD, "build").
+-endif.
+
+-define( INFO(P), flog:info(P) ).
+-define( ERROR(P), flog:error(P) ).
+-define( DEBUG(P), flog:debug(P) ).
+
+-define( OUT(F, P), io:format(F, P) ).
+
+
+-define(LSTHOST, config:get(lsthost, "0.0.0.0")).
+-define(LSTPORT, config:get(lstport, 8080)).
13 decoder/rest/include/db.hrl
@@ -0,0 +1,13 @@
+-include("web_session.hrl").
+
+-define(GLOBAL_TABLES,[]).
+
+-define(LOCAL_TABLES,
+ [
+ {?SESSION_TABLE_NAME, [{disc_copies, [node()]},
+ {local_content, true},
+ {record_name, web_session},
+ {attributes, record_info(fields, web_session)}]}
+ ]
+).
+
8 decoder/rest/include/web.hrl
@@ -0,0 +1,8 @@
+
+
+
+
+-define(REST_TIMEOUT, 100).
+
+-define(OUTPUT_HTML, "text/html; charset=UTF-8").
+-define(OUTPUT_TEXT, "text/plain; charset=UTF-8").
20 decoder/rest/include/web_session.hrl
@@ -0,0 +1,20 @@
+-define(SESSION_TABLE_NAME, list_to_atom(atom_to_list(node()) ++ "_session")).
+
+-record(web_session, {
+ uid,
+ login,
+ customer_id,
+ permissions=[],
+ time,
+ password_hash
+}).
+
+
+-define(AUTHCOOKIE, config:get(cookiename, "MCHS")).
+-define(SPEC, config:get(cookiename_site_varaint, "SPEC")).
+-define(VARIANT, config:get(cookiename_site_varaint, "VARIANT")).
+-define(COLOR, config:get(cookiename_site_color, "COLOR")).
+-define(EXPCOOKIE, config:get(expcookie, 18000)).
+
+
+-define(F_COOKIEOPTIONS, [{max_age, ?EXPCOOKIE}, {path, "/"}]).
0  decoder/rest/priv/.keep
No changes.
0  decoder/rest/priv/sql/.keep
No changes.
BIN  decoder/rest/rebar
Binary file not shown
68 decoder/rest/src/app/web.erl
@@ -0,0 +1,68 @@
+-module(web).
+-author('author <author@example.com>').
+
+-export([start/0, stop/0, status/0, stop_and_halt/0,
+ reload_cfg/0, reload_code/0, version/0]).
+
+-include("../include/common.hrl").
+
+ensure_started(App) ->
+ case application:start(App) of
+ ok ->
+ ok;
+ {error, {already_started, App}} ->
+ ok
+ end.
+
+start() ->
+ try
+ recover_if_needed(),
+ web_deps:ensure(),
+ ensure_started(crypto),
+ ensure_started(mnesia),
+ inets:start(),
+ %amnesia:init(),
+ application:start(?APP)
+ after
+ %% give the error loggers some time to catch up
+ timer:sleep(100)
+ end.
+
+stop() ->
+ Res = application:stop(?APP),
+ inets:stop(),
+ application:stop(mnesia),
+ application:stop(crypto),
+ Res.
+
+%% @spec stop_and_halt() -> ok
+%% @doc Stop the adm server ans shutdown node.
+stop_and_halt() ->
+ spawn(fun() ->
+ SleepTime = 1000,
+ flog:info([{?MODULE,"received stop_and_halt"}]),
+ timer:sleep(SleepTime),
+ halt(0)
+ end),
+ case catch stop() of _ -> ok end.
+
+%% @spec status() -> list
+%% @doc Return running applications and adm version
+status() ->
+ utils:status().
+
+%% @spec reload_cfg() -> term
+%% @doc Reload adm config
+reload_cfg() ->
+ utils:reload_cfg(?APP, ?CFG_PROCS).
+
+%% @spec reload_code() -> term
+%% @doc Reload adm code
+reload_code() ->
+ utils:reload_code().
+
+version() -> {0,1}.
+
+% ----------------------------------------------------------------------------
+recover_if_needed() ->
+ utils:recover_if_needed().
50 decoder/rest/src/app/web_app.erl
@@ -0,0 +1,50 @@
+-module(web_app).
+-author('author <author@example.com>').
+
+-behaviour(application).
+-export([start/2,stop/1,start_phase/3]).
+
+-include("../include/common.hrl").
+
+start(Type, _StartArgs) ->
+ erlang:register(?MODULE, self()),
+ web_deps:ensure(),
+ ok = error_logger:add_report_handler(flog, [web]),
+ web:reload_cfg(),
+ Rc = web_sup:start_link(),
+ case Type of
+ {takeover,_} -> ok;
+ _ -> start_http(10,2)
+ end,
+ Rc.
+
+start_phase(go, {takeover,FromNode}, _) ->
+% io:format("start_phase: takeover~n", []),
+ case rpc:call(FromNode, web_web, stop, []) of
+ ok -> start_http(10,2);
+ Error -> {error,{takeover,FromNode,Error}}
+ end;
+start_phase(go, _Type, _ ) ->
+ ok.
+
+
+start_http(0,_) -> {error,{start_http,eaddrinuse}};
+start_http(N,Delay) ->
+ WebConfig = [
+ {ip, config:get(lsthost, "0.0.0.0")},
+ {port, config:get(lstport, 8000)}
+ ],
+ Web = {web_web, {web_web, start, [WebConfig]}, permanent, 5000, worker, dynamic},
+ case supervisor:start_child(web_sup, Web) of
+ {ok, _Pid} -> ok;
+ {error, {eaddrinuse,_}} ->
+ timer:sleep(Delay*1000),
+ start_http(N-1,Delay)
+ end.
+
+stop(_State) ->
+ error_logger:delete_report_handler(flog),
+ ok = supervisor:terminate_child(web_sup, web_web),
+ ok = supervisor:delete_child(web_sup, web_web),
+ ok.
+
77 decoder/rest/src/app/web_deps.erl
@@ -0,0 +1,77 @@
+-module(web_deps).
+-author('author <author@example.com>').
+
+-export([ensure/0, ensure/1]).
+-export([get_base_dir/0, get_base_dir/1]).
+-export([local_path/1, local_path/2]).
+-export([deps_on_path/0, new_siblings/1]).
+
+%% @spec deps_on_path() -> [ProjNameAndVers]
+%% @doc List of project dependencies on the path.
+deps_on_path() ->
+ F = fun (X, Acc) ->
+ ProjDir = filename:dirname(X),
+ case {filename:basename(X),
+ filename:basename(filename:dirname(ProjDir))} of
+ {"ebin", "deps"} ->
+ [filename:basename(ProjDir) | Acc];
+ _ ->
+ Acc
+ end
+ end,
+ ordsets:from_list(lists:foldl(F, [], code:get_path())).
+
+%% @spec new_siblings(Module) -> [Dir]
+%% @doc Find new siblings paths relative to Module that aren't already on the
+%% code path.
+new_siblings(Module) ->
+ Existing = deps_on_path(),
+ SiblingEbin = filelib:wildcard(local_path(["deps", "*", "ebin"], Module)),
+ Siblings = [filename:dirname(X) || X <- SiblingEbin,
+ ordsets:is_element(
+ filename:basename(filename:dirname(X)),
+ Existing) =:= false],
+ lists:filter(fun filelib:is_dir/1,
+ lists:append([[filename:join([X, "ebin"]),
+ filename:join([X, "include"])] ||
+ X <- Siblings])).
+
+
+%% @spec ensure(Module) -> ok
+%% @doc Ensure that all ebin and include paths for dependencies
+%% of the application for Module are on the code path.
+ensure(Module) ->
+ code:add_paths(new_siblings(Module)),
+ code:clash(),
+ ok.
+
+%% @spec ensure() -> ok
+%% @doc Ensure that the ebin and include paths for dependencies of
+%% this application are on the code path. Equivalent to
+%% ensure(?Module).
+ensure() ->
+ ensure(?MODULE).
+
+%% @spec get_base_dir(Module) -> string()
+%% @doc Return the application directory for Module. It assumes Module is in
+%% a standard OTP layout application in the ebin or src directory.
+get_base_dir(Module) ->
+ {file, Here} = code:is_loaded(Module),
+ filename:dirname(filename:dirname(Here)).
+
+%% @spec get_base_dir() -> string()
+%% @doc Return the application directory for this application. Equivalent to
+%% get_base_dir(?MODULE).
+get_base_dir() ->
+ get_base_dir(?MODULE).
+
+%% @spec local_path([string()], Module) -> string()
+%% @doc Return an application-relative directory from Module's application.
+local_path(Components, Module) ->
+ filename:join([get_base_dir(Module) | Components]).
+
+%% @spec local_path(Components) -> string()
+%% @doc Return an application-relative directory for this application.
+%% Equivalent to local_path(Components, ?MODULE).
+local_path(Components) ->
+ local_path(Components, ?MODULE).
56 decoder/rest/src/app/web_sup.erl
@@ -0,0 +1,56 @@
+-module(web_sup).
+-author('author <author@example.com>').
+
+-behaviour(supervisor).
+
+%% External exports
+-export([start_link/0, upgrade/0]).
+
+%% supervisor callbacks
+-export([init/1]).
+
+-include("../include/common.hrl").
+
+%% @spec start_link() -> ServerRet
+%% @doc API for starting the supervisor.
+start_link() ->
+ supervisor:start_link({local, ?MODULE}, ?MODULE, []).
+
+%% @spec upgrade() -> ok
+%% @doc Add processes if necessary.
+upgrade() ->
+ {ok, {_, Specs}} = init([]),
+
+ Old = sets:from_list(
+ [Name || {Name, _, _, _} <- supervisor:which_children(?MODULE)]),
+ New = sets:from_list([Name || {Name, _, _, _, _, _} <- Specs]),
+ Kill = sets:subtract(Old, New),
+
+ sets:fold(fun (Id, ok) ->
+ supervisor:terminate_child(?MODULE, Id),
+ supervisor:delete_child(?MODULE, Id),
+ ok
+ end, ok, Kill),
+
+ [supervisor:start_child(?MODULE, Spec) || Spec <- Specs],
+ ok.
+
+%% @spec init([]) -> SupervisorTree
+%% @doc supervisor callback.
+init([]) ->
+
+ Logging = {
+ clog,
+ {clog, start_link, []},
+ permanent,
+ 1000,
+ worker,
+ [clog]
+ },
+
+
+ Processes = [
+ Logging
+ ],
+
+ {ok, {{one_for_one, 10, 10}, Processes}}.
137 decoder/rest/src/app/web_web.erl
@@ -0,0 +1,137 @@
+-module(web_web).
+-author('author <author@example.com>').
+
+-export([start/1, stop/0, loop/2]).
+-include_lib("xmerl/include/xmerl.hrl").
+-include("../include/common.hrl").
+
+
+-include("../include/web.hrl").
+
+-compile(export_all).
+
+%% External API
+
+start(Options) ->
+ {DocRoot, Options1} = get_option(docroot, Options),
+ Loop = fun (Req) ->
+ ?MODULE:loop(Req, DocRoot)
+ end,
+ mochiweb_http:start([{max, 1000000}, {name, ?MODULE}, {loop, Loop} | Options1]).
+
+stop() ->
+ io:format("~p: ~p got stop signal~n", [erlang:localtime(), ?MODULE]),
+ supervisor:terminate_child(web_sup, ?MODULE),
+ supervisor:delete_child(web_sup, ?MODULE).
+
+start_controller(Module, Action, Req) ->
+ flog:debug(?FMT("~p:~p 200 ~p REQUEST (~p) ~p:~p ~n", [?MODULE, ?LINE, Req:get(method), Req:get(path), Module, Action])),
+ Exports = Module:module_info(exports),
+ % % CALL BEFORE
+ _NReq = bac_runner(Exports, call_before, Module, Req),
+ % % CALL CONTROLLER
+ Result = Module:Action(Req),
+ % % CALL AFTER
+ {_, NResult} = bac_runner(Exports, call_after, Module, {Req, Result}),
+ Req:ok(NResult).
+
+start_controller(Module, Action, Req, Param) ->
+ flog:debug(?FMT("~p:~p 200 ~p REQUEST (~p) ~p:~p ~n", [?MODULE, ?LINE, Req:get(method), Req:get(path), Module, Action])),
+ Exports = Module:module_info(exports),
+ % % CALL BEFORE
+ _NReq = bac_runner(Exports, call_before, Module, Req),
+ % % CALL CONTROLLER
+ Result = Module:Action(Req, Param),
+ % % CALL AFTER
+ {_, NResult} = bac_runner(Exports, call_after, Module, {Req, Result}),
+ Req:ok(NResult).
+
+
+bac_runner([{M, _}|T], Method, Module, Param) ->
+ case M =:= Method of
+ true -> Module:Method(Param);
+ false -> bac_runner(T, Method, Module, Param)
+ end;
+bac_runner([], _Method, _Module, Param) ->
+ Param.
+
+
+save_start_controller(Module, Action, Req) ->
+ try
+ start_controller(Module, Action, Req)
+ catch throw:Val ->
+ process_controller_exception(throw, Val, Req)
+ end.
+
+save_start_controller(Module, Action, Req, T) ->
+ try
+ start_controller(Module, Action, Req, T)
+ catch throw:Val ->
+ process_controller_exception(throw, Val, Req)
+ end.
+
+%% ========================================================================
+%% ПРОБЛЕМЫ И ОШИБКИ
+%% ========================================================================
+
+process_controller_exception(throw, nothing_to_be_done, _Req) ->
+ [];
+
+process_controller_exception(throw, {redirect, Url, []}, Req) ->
+ flog:debug(?FMT("~p:~p 302 ~p REQUEST (~p) Redirect to ~p~n", [?MODULE, ?LINE, Req:get(method), Req:get(path), Url])),
+ Req:respond({302, [{"Location", Url}, {"Content-Type", "text/html; charset=UTF-8"}], ""});
+
+process_controller_exception(throw, not_found, Req) ->
+ flog:info(?FMT("~p:~p 404 ~p REQUEST (~p) Not Found~n", [?MODULE, ?LINE, Req:get(method), Req:get(path)])),
+ Req:not_found();
+
+%%
+%% application/json
+%%
+process_controller_exception(throw, {auth_ajax, State} , Req) ->
+ {Iserr, Val} = State,
+ case Iserr of
+ ok ->
+ V = {struct, [{<<"mess">>, null }, {"val", list_to_binary(Val)}]};
+ error ->
+ case Val of
+ {M, _N} ->
+ ErrMess = list_to_binary(M);
+ [_H | _] ->
+ ErrMess = list_to_binary(Val);
+ _ ->
+ ErrMess = <<"unknown">>
+ end,
+ V = {struct, [{<<"mess">>, ErrMess }, {"val", ErrMess}]}
+ end,
+ DataOut = mochijson2:encode(V),
+ Req:ok({"application/json", [], [DataOut]});
+
+process_controller_exception(Type, Exc, Req) ->
+ flog:error(?FMT("~p:~p Catch unknown exception (~p) on ~p request ~p ~n",[?MODULE, ?LINE, Exc, Req:get(method), Req:get(path)])),
+ Type(Exc).
+
+%% ========================================================================
+%% КОНТРОЛЛЕРЫ
+%% ========================================================================
+
+serve_request(Path, Req) ->
+ case Path of
+
+ "/decode/" ++ Source ->
+ save_start_controller(home, decode, Req, {Source , [], []});
+
+ _ ->
+ ?ERROR(?FMT("404:~s", [Path])),
+ Req:not_found()
+
+ end.
+
+loop(Req, _DocRoot) ->
+ serve_request(Req:get(path), Req).
+
+%% Internal API
+
+get_option(Option, Options) ->
+ {proplists:get_value(Option, Options), proplists:delete(Option, Options)}.
+
48 decoder/rest/src/controllers/home.erl
@@ -0,0 +1,48 @@
+%%% @file home
+%%%
+%%% Контроллеры front end
+%%%
+
+-module(home).
+-compile(export_all).
+
+-import(mochiweb_cookies, [cookie/2, cookie/3]).
+
+-include("../include/web_session.hrl").
+-include("../include/common.hrl").
+-include("../include/web.hrl").
+
+decode(Req, {Raw_source_text, _, _}) ->
+ case Req:get(method) of
+ Method when Method =:= 'GET'; Method =:= 'HEAD' ->
+ Source_text = string:strip(Raw_source_text, both, $/),
+
+ Response = Req:ok({?OUTPUT_TEXT,
+ [{"Server","disista-matrasy rest"}],
+ chunked}),
+
+ feed(Response, Source_text , 1);
+ 'POST' ->
+ Req:not_found();
+ _ ->
+ Req:respond({501, [], []})
+ end.
+
+
+feed(Response, Source_text, N) ->
+ receive
+
+ after ?REST_TIMEOUT ->
+
+ Target_text = internal_decode(Source_text),
+ Massage = lists:append(Target_text, [$\n]),
+ Response:write_chunk(Massage)
+
+ end,
+ feed(Response, Source_text, N+1).
+
+
+internal_decode(Source) ->
+ Tagret = Source,
+ Tagret.
+
18 decoder/rest/src/utils/config.erl
@@ -0,0 +1,18 @@
+
+%%
+%% Config store
+%%
+
+-module(config).
+
+-include("../include/common.hrl").
+
+
+-export([get/2]).
+
+get(Key, Default) ->
+ case catch(application:get_env(?APP, Key)) of
+ {'EXIT',_} -> Default;
+ {ok,Val} -> Val;
+ _ -> Default
+ end.
201 decoder/rest/src/utils/reloader.erl
@@ -0,0 +1,201 @@
+%% @copyright 2007 Mochi Media, Inc.
+%% @author Matthew Dempsky <matthew@mochimedia.com>
+%%
+%% @doc Erlang module for automatically reloading modified modules
+%% during development.
+
+-module(reloader).
+-author("Matthew Dempsky <matthew@mochimedia.com>").
+
+-include_lib("kernel/include/file.hrl").
+
+-behaviour(gen_server).
+-export([start/0, start_link/0, reload_code/0]).
+-export([stop/0]).
+-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
+
+-export([agressive_load_modules/0, agressive_load_modules/1]).
+
+-record(state, {last, tref}).
+
+%% @spec agressive_load_modules() -> list()
+%% @doc loads modules for app.
+agressive_load_modules() ->
+ {ok, List} = application:get_key(modules),
+ lists:map(fun(X)-> code:load_file(X) end, List).
+
+%% @spec agressive_load_modules(App) -> list()
+%% @doc loads modules for app.
+agressive_load_modules(App) ->
+ {ok, List} = application:get_key(App, modules),
+ lists:map(fun(X)-> code:load_file(X) end, List).
+
+%% External API
+
+%% @spec start() -> ServerRet
+%% @doc Start the reloader.
+start() ->
+ gen_server:start({local, ?MODULE}, ?MODULE, [], []).
+
+%% @spec start_link() -> ServerRet
+%% @doc Start the reloader.
+start_link() ->
+ gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
+
+%% @spec stop() -> ok
+%% @doc Stop the reloader.
+stop() ->
+ gen_server:call(?MODULE, stop).
+
+%% gen_server callbacks
+
+%% @spec init([]) -> {ok, State}
+%% @doc gen_server init, opens the server in an initial state.
+init([]) ->
+ {ok, TRef} = timer:send_interval(timer:seconds(1), doit),
+ {ok, #state{last = stamp(), tref = TRef}}.
+
+%% @spec handle_call(Args, From, State) -> tuple()
+%% @doc gen_server callback.
+handle_call(stop, _From, State) ->
+ {stop, shutdown, stopped, State};
+handle_call(_Req, _From, State) ->
+ {reply, {error, badrequest}, State}.
+
+%% @spec handle_cast(Cast, State) -> tuple()
+%% @doc gen_server callback.
+handle_cast(_Req, State) ->
+ {noreply, State}.
+
+%% @spec handle_info(Info, State) -> tuple()
+%% @doc gen_server callback.
+handle_info(doit, State) ->
+ Now = stamp(),
+ doit(State#state.last, Now),
+ {noreply, State#state{last = Now}};
+handle_info(_Info, State) ->
+ {noreply, State}.
+
+%% @spec terminate(Reason, State) -> ok
+%% @doc gen_server termination callback.
+terminate(_Reason, State) ->
+ {ok, cancel} = timer:cancel(State#state.tref),
+ ok.
+
+
+%% @spec code_change(_OldVsn, State, _Extra) -> State
+%% @doc gen_server code_change callback (trivial).
+code_change(_Vsn, State, _Extra) ->
+ {ok, State}.
+
+%% Internal API
+
+doit(From, To) ->
+ [case file:read_file_info(Filename) of
+ {ok, FileInfo} when FileInfo#file_info.mtime >= From,
+ FileInfo#file_info.mtime < To ->
+ reload(Module);
+ {ok, _} ->
+ unmodified;
+ {error, enoent} ->
+ %% The Erlang compiler deletes existing .beam files if
+ %% recompiling fails. Maybe it's worth spitting out a
+ %% warning here, but I'd want to limit it to just once.
+ gone;
+ {error, Reason} ->
+ io:format("Error reading ~s's file info: ~p~n",
+ [Filename, Reason]),
+ error
+ end || {Module, Filename} <- code:all_loaded(), is_list(Filename)].
+
+reload(Module) ->
+ io:format("Reloading ~p ...", [Module]),
+ code:purge(Module),
+ case code:load_file(Module) of
+ {module, Module} ->
+ io:format(" ok.~n"),
+ case erlang:function_exported(Module, test, 0) of
+ true ->
+ io:format(" - Calling ~p:test() ...", [Module]),
+ case catch Module:test() of
+ ok ->
+ io:format(" ok.~n"),
+ reload;
+ Reason ->
+ io:format(" fail: ~p.~n", [Reason]),
+ reload_but_test_failed
+ end;
+ false ->
+ reload
+ end;
+ {error, Reason} ->
+ io:format(" fail: ~p.~n", [Reason]),
+ error
+ end.
+
+
+stamp() ->
+ erlang:localtime().
+
+%% ============================================================================
+reload_code() ->
+ try
+ Reload = fun(M) ->
+ code:purge(M),
+ code:soft_purge(M),
+ {module, M} = code:load_file(M),
+ {ok,M}
+ end,
+% Modules = [M || {M,P} <- code:all_loaded(),
+% is_list(P) andalso
+% string:str(P, filename:absname(""))>0],
+ Modules = modified_modules(),
+ {ok, lists:sort([Reload(M) || M <- Modules])}
+ catch
+ Cls:Why -> {error, {Cls,Why}}
+ end.
+
+modified_modules() ->
+ [M || {M, P} <- code:all_loaded(),
+ is_list(P),
+ string:str(P, filename:absname(""))>0,
+ module_modified(M) == true].
+
+module_modified(Module) ->
+ case code:is_loaded(Module) of
+ {file, preloaded} ->
+ false;
+ {file, Path} ->
+ CompileOpts = proplists:get_value(compile, Module:module_info()),
+ CompileTime = proplists:get_value(time, CompileOpts),
+ Src = proplists:get_value(source, CompileOpts),
+ module_modified(Path, CompileTime, Src);
+ _ ->
+ false
+ end.
+
+module_modified(Path, PrevCompileTime, PrevSrc) ->
+ case find_module_file(Path) of
+ false ->
+ false;
+ ModPath ->
+ {ok, {_, [{_, CB}]}} = beam_lib:chunks(ModPath, ["CInf"]),
+ CompileOpts = binary_to_term(CB),
+ CompileTime = proplists:get_value(time, CompileOpts),
+ Src = proplists:get_value(source, CompileOpts),
+ not (CompileTime == PrevCompileTime) and (Src == PrevSrc)
+ end.
+
+find_module_file(Path) ->
+ case file:read_file_info(Path) of
+ {ok, _} ->
+ Path;
+ _ ->
+ %% may be the path was changed?
+ case code:where_is_file(filename:basename(Path)) of
+ non_existing ->
+ false;
+ NewPath ->
+ NewPath
+ end
+ end.
722 decoder/rest/src/utils/utils.erl
@@ -0,0 +1,722 @@
+%% --------------------------------------------------------------------
+%% Created: 06.02.2009
+%% Description: Utils functions
+%% --------------------------------------------------------------------
+-module(utils).
+
+-export([safety_call/2,safety_call/3,utime/0,udelta/2,make_ets/1,myFmt/3,drop_ets/1,
+ getAppParam/2, parse_args/1, pick/3, s2i/2, get_param/3,
+ swap/2, to_atom/1, to_int/1, to_list/1, whereis_phone/1,
+ ugs/0, to_integer/1, make_ets/2, recover_if_needed/0, to_float/1,
+ to_utf32/1,
+ reload_cfg/2, reload_code/0,
+ start_applications/1, stop_applications/1,
+ start_childs/2, stop_dynamic_child/2,
+ start_groups/1, stop_groups/1,
+ status/0, status/1, os_stat/1,
+ upgrade/1, do_upgrade/1,
+ unixtime_to_localDatetime/1, unixtime_to_universalDatetime/1,
+ unixtime_to_localDate/1,
+ hex_to_binary/1, to_hex/1, hex_to_list/1, setPlistVal/2, to_string/1, sformat/2,
+ getTargetId/2, moveFile/2]).
+
+-define( FMT(F,P), lists:flatten(io_lib:format(F,P)) ).
+
+
+-compile(export_all).
+%%-include("../include/db.hrl").
+
+%% --------------------------------------------------------------------
+safety_call(Info, F) ->
+ try
+ F()
+ catch
+ _:{error, Why} -> flog:error(Info ++ [{error,Why},
+ {stack,erlang:get_stacktrace()}]),
+ {error,Why};
+ _:Err -> flog:error(Info ++ [{unexpected_error,Err},
+ {stack,erlang:get_stacktrace()}]),
+ {error,Err}
+ end.
+
+%% --------------------------------------------------------------------
+safety_call(Info, F, ErrReturn) ->
+ try
+ F()
+ catch
+ _:{error, Why} -> flog:error(Info ++ [{error,Why}]), ErrReturn;
+ _:Err -> flog:error(Info ++ [{unexpected_error,Err}]), ErrReturn
+ end.
+
+%% --------------------------------------------------------------------
+% now() to seconds + microseconds
+utime() ->
+ {_M,S,Mi} = now(),
+% {_M,S,Mi} = os:timestamp(),
+ S*1000000+Mi.
+
+
+udelta({M1, S1, Mi1}, {M2, S2, Mi2}) ->
+ (M1 - M2) * 1000000000000 + (S1 - S2) * 1000000 + (Mi1 - Mi2).
+%% -----------------------------------------------------------------------------
+ugs() ->
+ calendar:datetime_to_gregorian_seconds(erlang:universaltime()).
+
+%% --------------------------------------------------------------------
+make_ets(Name) -> make_ets(Name, []).
+
+make_ets(Name, Opts) ->
+ case ets:info(Name) of
+ undefined -> ets:new(Name, [set, public, named_table|Opts]);
+ _ -> Name
+ end.
+
+drop_ets(Name) ->
+ case ets:info(Name) of
+ undefined -> ok;
+ _ -> ets:delete(Name)
+ end.
+
+%% --------------------------------------------------------------------
+myFmt([Ht|Txt], [Hp|Params], Ret) when is_list(Hp) /= true->
+ myFmt(Txt, Params, Ret ++ Ht ++ sms:to_list(Hp));
+myFmt([Ht|Txt], [Hp|Params], Ret) ->
+ myFmt(Txt, Params, Ret ++ Ht ++ Hp);
+% myFmt(Txt, Params, <<Ret/binary, Ht/binary, Hp/binary>>);
+myFmt([Ht|Txt], [], Ret) ->
+ myFmt(Txt, [], Ret ++ Ht);
+% myFmt(Txt, [], <<Ret/binary, Ht/binary>>);
+myFmt([], _X, Ret) ->
+ Ret.
+
+%% --------------------------------------------------------------------
+getAppParam(Key, Default) ->
+ case application:get_env(Key) of
+ {ok,Val} -> Val;
+ _ -> Default
+ end.
+
+%% --------------------------------------------------------------------
+parse_args(L) when is_list(L) ->
+ lists:map(fun(E) ->
+ case string:tokens(E, "=") of
+ [Name,Val] -> {string:to_lower(Name),Val};
+ _ -> {bad_arg,E}
+ end
+ end, L);
+parse_args(L) ->
+ flog:info([{?MODULE,parse_args},{bad_arg,L}]),
+ [].
+
+% -----------------------------------------------------------------------------
+pick(Key, List, Default) ->
+ case lists:keysearch(Key, 1, List) of
+ false when Default == must ->
+ {error, badarg};
+ false ->
+ Default;
+ {value, {Key, Value}} ->
+ Value;
+ {value, BadArg} ->
+ {error, {bad_type, BadArg}}
+ end.
+
+% -----------------------------------------------------------------------------
+s2i(Name, S) ->
+ case catch(list_to_integer(S)) of
+ {'EXIT', _Why} ->
+ throw({error,{bad_int_str, {Name,S}}});
+ Val -> Val
+ end.
+
+% -----------------------------------------------------------------------------
+get_param(Key, Params, Default) ->
+ case pick(Key, Params, []) of
+ [] -> Default;
+ Val -> Val
+ end.
+
+% -----------------------------------------------------------------------------
+swap([], Acc) -> lists:reverse(Acc);
+swap([B1,B2|Tail], Acc) ->
+ swap(Tail, [B1,B2|Acc]);
+swap(_, Acc) -> swap([], Acc).
+
+
+%% --------------------------------------------------------------------
+whereis_phone(Phone) when is_atom(Phone) ->
+ whereis(Phone);
+whereis_phone(Phone) when is_list(Phone) ->
+ whereis(to_atom(Phone));
+whereis_phone(Phone) when is_integer(Phone) ->
+ whereis_phone(integer_to_list(Phone)).
+
+%% --------------------------------------------------------------------
+to_integer(V) when is_list(V) ->
+ list_to_integer(V);
+to_integer(V) ->
+ V.
+
+%% --------------------------------------------------------------------
+
+to_string(V) ->
+ lists:flatten(io_lib:format("~p", [V])).
+
+%% --------------------------------------------------------------------
+
+%% sformat/2
+%% Работает так же как io:format но выводит резудьтат в строку
+sformat(Pattern, Values) ->
+ lists:flatten(io_lib:format(Pattern, Values)).
+
+%% --------------------------------------------------------------------
+to_atom(Val) when is_atom(Val) -> Val;
+to_atom(Val) when is_list(Val) ->
+ case catch(erlang:list_to_existing_atom(Val)) of
+ {'EXIT', _} -> erlang:list_to_atom(Val);
+ Atom -> Atom
+ end;
+to_atom(Val) when is_integer(Val) ->
+ to_atom(integer_to_list(Val));
+to_atom(Val) when is_binary(Val) ->
+ to_atom(binary_to_list(Val)).
+
+
+to_int(Val) when is_integer(Val) -> Val;
+to_int(Val) when is_list(Val) ->
+ case catch(erlang:list_to_integer(Val)) of
+ {'EXIT', _} -> throw({error, {to_int, bad_arg, Val}});
+ Int -> Int
+ end;
+to_int(Val) when is_atom(Val) ->
+ to_int(atom_to_list(Val));
+to_int(Val) when is_binary(Val) ->
+ case catch(list_to_integer(binary_to_list(Val))) of
+ {'EXIT', _} -> throw({error, {to_int, bad_arg, Val}});
+ Int -> Int
+ end.
+
+
+
+to_list(Val) when is_list(Val) -> Val;
+to_list(Val) when is_atom(Val) ->
+ atom_to_list(Val);
+to_list(Val) when is_integer(Val) ->
+ integer_to_list(Val);
+to_list(Val) when is_binary(Val) ->
+ binary_to_list(Val).
+
+
+to_float(Val) when is_list(Val) ->
+ case catch(erlang:list_to_float(Val)) of
+ {'EXIT', _} ->
+ case catch(erlang:list_to_integer(Val)) of
+ {'EXIT', _} -> throw({error, {to_float, bad_arg, Val}});
+ Int -> Int
+ end;
+ Float -> Float
+ end;
+to_float(Val) when is_float(Val); is_integer(Val) ->
+ Val.
+
+to_utf32(Data) -> {utf32, to_utf32_impl(Data)}.
+
+to_utf32_impl({ucs2,Sms}) when is_list(Sms) -> %% исходящие СМС
+ unicode:characters_to_list(list_to_binary(Sms), utf8);
+to_utf32_impl({ascii,Sms}) when is_list(Sms) -> %% исходящие СМС
+ Sms;
+to_utf32_impl({ucs2in,Sms}) when is_list(Sms) -> %% входящие СМС
+ unicode:characters_to_list(list_to_binary(Sms), {utf16, big});
+to_utf32_impl(Sms) when is_list(Sms) ->
+ unicode:characters_to_list(list_to_binary(Sms), utf8);
+to_utf32_impl(Sms) ->
+ ?FMT("~p",[Sms]).
+
+% -----------------------------------------------------------------------------
+recover_if_needed() ->
+ case init:get_argument(recover) of
+ {ok,[["true"]]} ->
+ MasterNodes = mnesia:system_info(db_nodes) -- [node()],
+ io:format("recover DB from nodes: ~p~n", [MasterNodes]),
+ ok = mnesia:set_master_nodes(MasterNodes);
+ {ok, [MasterNodes]} when is_list(MasterNodes) ->
+ MasterNodesAtom = lists:map(fun(NodeStr) -> utils:to_atom(NodeStr) end,
+ MasterNodes),
+ io:format("recover DB from nodes: ~p~n", [MasterNodesAtom]),
+ ok = mnesia:set_master_nodes(MasterNodesAtom),
+ ok;
+ _ -> ok
+ end.
+
+
+% -----------------------------------------------------------------------------
+reload_cfg(App, CfgProcs) ->
+ try
+ ok = config:init(),
+ CfgFile = get_config_name(),
+ Args = get_app_params(App, CfgFile),
+ config:store(Args),
+ notify_procs(cfg_reloaded, CfgProcs),
+ after_reload_cfg(),
+ [{config_file,CfgFile}|Args]
+ catch
+ _:{error, Why} ->
+ flog:error([{?MODULE,reload_cfg},{error,Why}]);
+ _:Err ->
+ flog:error([{?MODULE,reload_cfg},{error,Err}])
+ end.
+
+
+get_config_name() ->
+ case init:get_argument(config) of
+ error -> throw({error,{config,undefined}});
+ {ok,[[File]]} -> File ++ ".config"
+ end.
+
+
+get_app_params(App, File) ->
+ case file:consult(File) of
+ {ok, [L]} ->
+ proplists:get_value(App, L, []);
+ Err -> throw(Err)
+ end.
+
+notify_procs(Msg, L) ->
+ F = fun({Type,Proc}) ->
+ case whereis(Proc) of
+ Pid when is_pid(Pid) -> notify_proc(Type, Pid, Msg);
+ _ -> ok
+ end
+ end,
+ lists:foreach(F, L).
+
+notify_proc(gen_server, Pid, Msg) ->
+ gen_server:cast(Pid, Msg);
+notify_proc(gen_event, Pid, Msg) ->
+ gen_event:notify(Pid, Msg).
+
+
+after_reload_cfg() ->
+ handle_os_mon().
+
+handle_os_mon() ->
+ case config:get(os_mon, false) of
+ true ->
+ application:start(os_mon, permanent);
+ false ->
+ application:stop(os_mon)
+ end.
+
+% -----------------------------------------------------------------------------
+reload_code() ->
+ reloader2:reload_code().
+
+%%% ============================================================================
+%%% APP manage
+%%% ============================================================================
+manage_applications_s(Iterate, Do, Undo, SkipError, ErrorTag, Result, Apps) ->
+ Iterate(fun(App,Acc) ->
+ case Do(App,permanent) of
+ ok -> [{App,Result} | Acc];
+ {error, {SkipError, _}} -> Acc;
+ {error, Reason} ->
+ lists:foreach(Undo, Acc),
+ throw({error, {ErrorTag, App, Reason}})
+ end
+ end, [], Apps),
+ ok.
+
+
+manage_applications_e(Iterate, Do, Undo, SkipError, ErrorTag, Result, Apps) ->
+ Iterate(fun(App,Acc) ->
+ case Do(App) of
+ ok -> [{App,Result} | Acc];
+ {error, {SkipError, _}} -> Acc;
+ {error, Reason} ->
+ lists:foreach(Undo, Acc),
+ throw({error, {ErrorTag, App, Reason}})
+ end
+ end, [], Apps),
+ ok.
+
+
+start_applications(Apps) ->
+ manage_applications_s(fun lists:foldl/3,
+ fun application:start/2,
+ fun application:stop/1,
+ already_started,
+ cannot_start_application,
+ started,
+ Apps).
+
+stop_applications(Apps) ->
+ manage_applications_e(fun lists:foldr/3,
+ fun application:stop/1,
+ fun application:start/1,
+ not_started,
+ cannot_stop_application,
+ stopped,
+ Apps).
+
+start_childs(_Sup, []) -> ok;
+start_childs(Sup, [H|T]) ->
+ {ok,_} = supervisor:start_child(Sup, [H]),
+ start_childs(Sup, T).
+
+%% ----------------------------------------------------------------------------
+stop_dynamic_child(Sup, Id) ->
+ ok = supervisor:terminate_child(Sup, Id),
+ ok = supervisor:delete_child(Sup, Id),
+ ok.
+
+%% ----------------------------------------------------------------------------
+start_groups(both) ->
+ start_group(tracker),
+ start_group(customer);
+start_groups(Other) ->
+ start_group(Other).
+
+start_group(GateType) ->
+ GroupName = get_group_name(GateType),
+ pg2:create(GroupName),
+ case pg2:join(GroupName, self()) of
+ ok -> ok;
+ {error,Reason} -> flog:error([{?MODULE,start_group},{join_failed,Reason}])
+ end.
+
+stop_groups(both) ->
+ pg2:leave(smpp_gate_tracker, self()),
+ pg2:leave(smpp_gate_customer, self());
+stop_groups(GateType) ->
+ GroupName = get_group_name(GateType),
+ pg2:leave(GroupName, self()).
+
+get_group_name(customer) -> smpp_gate_customer;
+get_group_name(_) -> smpp_gate_tracker.
+
+%% ----------------------------------------------------------------------------
+status() ->
+ [{running_applications, application:which_applications()},
+ {db_cluster, amnesia:status()}].
+
+status(Caller) ->
+ Apps = application:which_applications(),
+ DbNodes = mnesia:system_info(db_nodes),
+ Running = lists:sort(mnesia:system_info(running_db_nodes)),
+ Stopped = lists:sort(DbNodes -- Running),
+ Memory = erlang:memory(),
+ Events = get_events_stat(),
+ {ok, fmt_status(Caller, Apps, Running, Stopped, Memory, Events)}.
+
+get_events_stat() ->
+ case ets:info(tran_stat, size) of
+ undefined -> [];
+ _ ->
+ RWS =
+ case ets:lookup(tran_stat, write_stat) of
+ [{write_stat,{WTime,Size,Time}}] ->
+ Rate = if Time > 0 -> {round(Size/Time*1000000),eps};
+ true -> {0,eps} end,
+ {WTime,Size,Time,Rate};
+ [] -> no_stat
+ end,
+ FDS = case ets:lookup(tran_stat, last_dump) of
+ [] -> no_stat;
+ [{last_dump,{Tab1,Rc1,Size1,Time1}}] ->
+ FDRate = if Time1 > 0 -> {round(Size1/Time1*1000000),eps};
+ true -> {0,eps} end,
+ {Tab1,Rc1,Size1,Time1,FDRate}
+ end,
+ BS = case ets:lookup(tran_stat, backup_stat) of
+ [] -> no_stat;
+ [{backup_stat, {Tab2, Size2, Time2}}] ->
+ BRate = if Time2 > 0 -> {round(Size2/Time2*1000000),eps};
+ true -> {0,eps} end,
+ {Tab2,Size2,Time2,BRate}
+ end,
+ [RWS, FDS, BS]
+ end.
+
+os_stat(Caller) ->
+ {_,Util,_,_} = cpu_sup:util([]),
+ Cpu = {Util,
+ [cpu_sup:avg1()/256,
+ cpu_sup:avg5()/256,
+ cpu_sup:avg15()/256]},
+ MemTot =
+ list_to_integer(
+ string:strip(
+ os:cmd("grep -i memtotal /proc/meminfo | awk '{print $2}'"),
+ right, $\n))/1024, % MB
+ Cmd = "grep -i '^active' /proc/meminfo | grep -v file | "
+ "awk 'BEGIN {mem=0} {mem+=$2} END {print mem} '",
+ MemAct =
+ list_to_integer(
+ string:strip( os:cmd(Cmd) ,
+% os:cmd("grep -i \"^active:\" /proc/meminfo | awk '{print $2}'"),
+ right, $\n))/1024, % MB
+ MemErl = memsup:get_system_memory_data(),
+ SwapTotBytes = proplists:get_value(total_swap, MemErl),
+ SwapTot = SwapTotBytes/(1024*1024), % MB
+ SwapActBytes = SwapTotBytes - proplists:get_value(free_swap, MemErl),
+ SwapAct = SwapActBytes/(1024*1024), % MB
+ Mem = {MemTot, MemAct, SwapTot, SwapAct},
+ Disk = disksup:get_disk_data(),
+ {ok, fmt_os_stat(Caller, Cpu, Mem, Disk)}.
+
+fmt_os_stat(mochi, {Util,Avg},
+ {MemTot, MemAct, SwapTot, SwapAct}, Disk) ->
+ Cpu = {struct, [{util, list_to_float(?FMT("~.2f", [Util]))},
+ {la, list_to_binary(?FMT("~.2f, ~.2f, ~.2f", Avg))}
+ ]},
+ MemUtil = case (MemAct*100)/MemTot of
+ Val when Val < 40 -> <<"low">>;
+ Val when Val < 80 -> <<"medium">>;
+ _ -> <<"high">>
+ end,
+ Mem = {struct, [{total, list_to_binary(?FMT("~.2f", [MemTot]))},
+ {active, list_to_binary(?FMT("~.2f", [MemAct]))},
+ {mem_util, MemUtil},
+ {swap_total, list_to_binary(?FMT("~.2f", [SwapTot]))},
+ {swap_active, list_to_binary(?FMT("~.2f", [SwapAct]))}
+ ]},
+ Dsk = lists:foldl(fun({Path,Alloc,Perc}, Acc) ->
+ DskAlloc =
+ list_to_binary(?FMT("~.2f", [Alloc/(1024*1024)])),
+ [[list_to_binary(Path),DskAlloc,Perc]|Acc]
+ end, [], Disk),
+ {struct, [{cpu, Cpu},{mem,Mem},{disk,lists:sort(Dsk)}]};
+fmt_os_stat(_, {Util,Avg}, {MemTot, MemAct, SwapTot, SwapAct}, Dsk) ->
+ [{cpu, [{util, Util},{la,Avg}]},
+ {mem, [{total, MemTot}, {active, MemAct},
+ {swap_total, SwapTot}, {swap_active, SwapAct}]},
+ {disk,Dsk}].
+
+
+fmt_status(mochi, Apps, Running, Stopped, Memory, EventsRaw) ->
+ F = fun({Name,Desc,Version}, Acc) ->
+ [[Name,list_to_binary(Desc),list_to_binary(Version)]|Acc]
+ end,
+ AppsNew = lists:reverse(lists:foldl(F, [], Apps)),
+ Events = case EventsRaw of
+ [] -> [];
+ _ -> fmt_events(EventsRaw)
+ end,
+ {struct, [{node,list_to_binary(utils:to_list(node()))},
+ {apps, AppsNew}, {db_on, Running},
+ {db_off, Stopped}, {mem,{struct,Memory}} | Events ]};
+fmt_status(_, Apps, Running, Stopped, Memory, Events) ->
+ [{apps, Apps},{db_on, Running},{db_off, Stopped},{mem,Memory},
+ {events,Events}].
+
+
+fmt_events([RWS, FDS, BS]) ->
+ RWSJ = fmt_ev_write(RWS),
+ FDSJ = fmt_ev_dump(FDS),
+ BSJ = fmt_ev_backup(BS),
+ [{events, {struct,[RWSJ, FDSJ, BSJ]}}].
+
+fmt_ev_write(no_stat) ->
+ Time = mk_date_str(erlang:localtime()),
+ {write, {struct, [{no_stat, Time}]}};
+fmt_ev_write({LocalTime, Size, TimeUs, {Rate,_}}) ->
+ Time = mk_date_str(LocalTime),
+ {write,
+ {struct, [{timestamp, Time},
+ {events, Size},
+ {time, list_to_binary(?FMT("~.3f ms", [TimeUs/1000]))},
+ {rate, list_to_binary(?FMT("~p events/sec", [Rate]))}
+ ]
+ }
+ }.
+
+fmt_ev_dump(no_stat) ->
+ Time = mk_date_str(erlang:localtime()),
+ {dump, {struct, [{no_stat, Time}]}};
+fmt_ev_dump({Tab,Rc,Size,TimeUs,{Rate,_}}) ->
+ {dump,
+ {struct, [{table, Tab},
+ {result, list_to_binary(?FMT("~p", [Rc]))},
+ {events, Size},
+ {time, list_to_binary(?FMT("~.3f ms", [TimeUs/1000]))},
+ {rate, list_to_binary(?FMT("~p events/sec", [Rate]))}
+ ]
+ }
+ }.
+
+fmt_ev_backup(no_stat) ->
+ Time = mk_date_str(erlang:localtime()),
+ {backup, {struct, [{no_stat, Time}]}};
+fmt_ev_backup({Tab,Size,TimeUs,{Rate,_}}) ->
+ {backup,
+ {struct, [{table, Tab},
+ {events, Size},
+ {time, list_to_binary(?FMT("~.3f ms", [TimeUs/1000]))},
+ {rate, list_to_binary(?FMT("~p events/sec", [Rate]))}
+ ]
+ }
+ }.
+
+
+mk_date_str({{Y,M,D},{H,Min,S}}) ->
+ list_to_binary(?FMT("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
+ [Y,M,D,H,Min,S])).
+
+%% ----------------------------------------------------------------------------
+%% Upgrades nodes
+%% ----------------------------------------------------------------------------
+upgrade(Nodes, Paths) when is_list(Nodes), is_list(Paths) ->
+ try
+ FileName = "up.tar.bz2",
+ ok = make_archive(FileName, Paths),
+ {ok, FileBin} = file:read_file(FileName),
+ send_upgrade(Nodes, FileBin)
+ catch
+ _:{error,Reason} -> {error,Reason};
+ _:Error -> {error,Error}
+ end.
+
+upgrade(Bin) when is_binary(Bin) ->
+ try
+ FileName = "up.tar.bz2",
+ ok = extract_archive(FileName,Bin),
+ reload_code()
+ catch
+ _:{error,Reason} -> {error,Reason};
+ _:Error -> {error,Error}
+ end.
+
+make_archive(FileName, Paths) ->
+ F = fun(Dir, Acc) ->
+ case filelib:is_dir(Dir) of
+ true -> [Dir, Acc];
+ false -> Acc
+ end
+ end,
+ Cmd =
+ case lists:foldl(F, [], Paths) of
+ [] -> throw({error,{no_pathname, Paths}});
+ L -> string:join(["tar cjf", FileName | L], " ")
+ end,
+ case os:cmd(Cmd) of
+ [] -> ok;
+ Error -> throw({error,Error})
+ end.
+
+extract_archive(FileName,Bin) ->
+ ok = file:write_file(FileName, Bin),
+ case os:cmd(?FMT("tar xmjf ~s", [FileName])) of
+ [] -> ok;
+ Error -> throw({error,Error})
+ end.
+
+send_upgrade(Nodes, Bin) ->
+ F = fun(Node, Acc) ->
+ Rc = rpc:call(Node, utils, upgrade, [Bin]),
+ [{Node,Rc} | Acc]
+ end,
+ lists:reverse(lists:foldl(F, [], Nodes)).
+
+%% ----------------------------------------------------------------------------
+%% called from ctl
+%% ----------------------------------------------------------------------------
+do_upgrade(Params) ->
+ case proplists:get_value(cookie, Params) of
+ undefined -> ok; % same cookie
+ Cookie -> erlang:set_cookie(node(), Cookie)
+ end,
+ case proplists:get_value(nodes, Params, []) of
+ [] ->
+ io:format("Upgrade failed, no nodes in config~n");
+ Nodes ->
+ Paths = case proplists:get_value(pathname, Params, []) of
+ [] -> io:format("Upgrade failed, no pathname in config~n"),
+ throw({error,no_pathname_in_config});
+ Val -> Val
+ end,
+ io:format("Upgrade nodes ~p with paths ~p ...~n", [Nodes, Paths]),
+ Res = upgrade(Nodes, Paths),
+ io:format("~p~n", [Res])
+ end.
+
+unixtime_to_localDatetime(T) ->
+ X = T div 1000,
+ calendar:now_to_local_time({X div 1000000,X rem 1000000,0}).
+
+unixtime_to_localDate(TimeInt) ->
+ {Date, _Time} = unixtime_to_localDatetime(TimeInt),
+ Date.
+
+unixtime_to_universalDatetime(T) ->
+ X = T div 1000,
+ calendar:now_to_universal_time({X div 1000000,X rem 1000000,0}).
+
+
+
+to_hex(Val) when is_list(Val) ->
+ lists:flatten([io_lib:format("~2.16.0B", [X]) || X <- Val]);
+to_hex(Val) when is_binary(Val) ->
+ to_hex(binary_to_list(Val)).
+
+
+hex_to_binary(Val) ->
+ list_to_binary(hex_to_list(Val)).
+
+
+hex_to_list([X1, X2 | T], Res) ->
+ hex_to_list(T, [erlang:list_to_integer([X1,X2], 16) | Res]);
+hex_to_list([], Res) ->
+ lists:reverse(Res).
+
+hex_to_list(Val) ->
+ hex_to_list(Val, []).
+% [erlang:list_to_integer(X, 16) || X <- Val].
+
+setPlistVal([H|T], Plist) ->
+ setPlistVal(T, setPlistVal(H, Plist));
+setPlistVal([], Plist) ->
+ Plist;
+setPlistVal({Key, Val}, Plist) ->
+ [{Key, Val} | proplists:delete(Key, Plist)].
+
+%% ----------------------------------------------------------------------------
+%% Controllers
+%% ----------------------------------------------------------------------------
+
+getTargetId(Param, Default) ->
+ case Param of
+ [] ->
+ TargetId = Default;
+ _ ->
+ TargetId = Param
+ end,
+ TargetId.
+
+moveFile(Src, Dst) ->
+ case Src =:= Dst of
+ true -> ok;
+ false ->
+ filelib:ensure_dir(Dst),
+ file:delete(Dst),
+ case file:copy(Src, Dst) of
+ {ok, _} ->
+ file:delete(Src),
+ ok;
+ ERROR ->
+ io:format("error reason: ~p~n", [ERROR]),
+ ERROR
+ end
+ end.
+
+
+iterTest(0, _) ->
+ ok;
+iterTest(X, F) ->
+ F(),
+ iterTest(X-1, F).
+
+test(Fun, X) ->
+ Start = utils:utime(),
+ iterTest(X, Fun),
+ Stop = utils:utime(),
+ io:format("Test::: ~p~n", [Stop - Start]).
23 decoder/rest/src/web.app.src
@@ -0,0 +1,23 @@
+{application, web,
+ [{description, "web"},
+ {vsn, "0.01"},
+ {modules, [
+ web,
+ web_app,
+ web_sup,
+ web_web,
+ web_deps
+ ]},
+ {registered, [erlxsl_port_controller,erlxsl_fast_logger]},
+ {mod, {web_app, []}},
+ {start_phases, [{go,[]}]},
+ {env, [
+ {driver_options,
+ [
+ {engine,"default_provider"},
+ {driver,"erlxsl"},
+ {load_path,"priv/bin"}
+ ]
+ }
+ ]},
+ {applications, [kernel, stdlib, crypto]}]}.
28 decoder/rest/start-rest.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+PATH=$PATH:/usr/local/lib/
+export PATH
+
+NODENAME="rest@localhost"
+CONFIG=rest
+
+ERL_ARGS="+K true +A 128 +P 1000000"
+
+ERL_MAX_ETS_TABLES=140000
+export ERL_MAX_ETS_TABLES
+
+echo "**************************************"
+LOCALLBINPATH=`find ./ebin -type d -printf '%h/%f '`
+OTHERBINPATH="./deps/*/ebin"
+BINPATH=${LOCALLBINPATH}${OTHERBINPATH}
+erl \
+ -pa $BINPATH \
+ -boot start_sasl \
+ -config ${CONFIG} \
+ -sname ${NODENAME} \
+ -s reloader \
+ +native \
+ -s web \
+ -mnesia dir "db" \
+ ${ERL_ARGS} \
+ "$@"
16 decoder/web/.gitignore
@@ -0,0 +1,16 @@
+*~
+*.beam
+*.bup
+*.log
+*.dump
+*.swp
+*.app
+*.so
+*.trace
+
+*priv/data*
+*priv/logs*
+
+*stub.*
+
+deps/*
30 decoder/web/Makefile
@@ -0,0 +1,30 @@
+# default
+
+
+CC=g++
+EC=./rebar
+EFLAGS=compile
+
+ESRC_DIR=src
+EONJ_DIR=ebin
+
+CSRC_DIR=csrc
+CONJ_DIR=cbin
+
+CSRC=$(CSRC_DIR)/libxslt_adapter.c
+COBJ=$(CONJ_DIR)/libxslt_adapter
+CFLAGS=-lxml2 -lxslt
+CINCLUDES=/usr/include/libxml2
+
+all: c_bin
+ $(EC) $(EFLAGS)
+
+c_bin:
+ $(CC) -o $(COBJ) $(CSRC) -I$(CINCLUDES) $(CFLAGS)
+
+cleanall: clean
+ rm -rf $(CONJ_DIR)/*
+
+clean:
+ rm -rf $(EONJ_DIR)/*
+
0  decoder/web/ebin/.keep
No changes.
25 decoder/web/include/common.hrl
@@ -0,0 +1,25 @@
+% -----------------------------------------------------------------------------
+%% common defines
+% -----------------------------------------------------------------------------
+
+-define( FMT(F,P), lists:flatten(io_lib:format(F,P)) ).
+-define( APP, web).
+-define( CFG_PROCS, [{gen_server, m_pinger},
+ {gen_event, error_logger}]
+ ).
+
+-ifdef(debug).
+-define(QOOXDOOBUILD, "source").
+-else.
+-define(QOOXDOOBUILD, "build").
+-endif.
+
+-define( INFO(P), flog:info(P) ).
+-define( ERROR(P), flog:error(P) ).
+-define( DEBUG(P), flog:debug(P) ).
+
+-define( OUT(F, P), io:format(F, P) ).
+
+
+-define(LSTHOST, config:get(lsthost, "0.0.0.0")).
+-define(LSTPORT, config:get(lstport, 8080)).
104 decoder/web/include/dao.hrl
@@ -0,0 +1,104 @@
+
+% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
+% %
+% % Возможно стоит описать селектами, но так было удобнее.
+% %
+
+%%
+%% Глобальные папки
+%%
+
+-define(KEY_ID, 1). % Новости
+-define(NEWS_ID, 2). % Новости
+-define(REG_ID, 3). % Нормативные документы
+-define(SECURE_ID, 4). % Безопасность на транпорте
+-define(CONF_ID, 5). % Конференции
+-define(TEST_ID, 6). % Тесты
+-define(TERM_ID, 7). % Термины
+
+%%
+%% ----------------------------------------
+%%
+
+-define(DT_NEWS_ID, 1).
+-define(DT_SUBDIR_ID, 2).
+-define(DT_KEY_ID, 3).
+-define(DT_ROOT_TEST_ID, 4).
+-define(DT_ROOT_TEST_SURFACE_ID, 5).