From 02306ccc470732837bbb602796876186a6b7e43a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Nov 2008 14:50:40 -0800 Subject: [PATCH] Initial Commit of AgileBill Open Source --- LICENSE | 315 ++ admin.php | 26 + ajax.php | 49 + config.inc.php | 64 + cookie.index.php | 103 + htaccess_index.php | 266 + includes/adodb/adodb-csvlib.inc.php | 317 ++ includes/adodb/adodb-datadict.inc.php | 1001 ++++ includes/adodb/adodb-error.inc.php | 258 + includes/adodb/adodb-errorhandler.inc.php | 79 + includes/adodb/adodb-errorpear.inc.php | 88 + includes/adodb/adodb-exceptions.inc.php | 82 + includes/adodb/adodb-iterator.inc.php | 30 + includes/adodb/adodb-lib.inc.php | 1180 +++++ includes/adodb/adodb-pager.inc.php | 290 ++ includes/adodb/adodb-pear.inc.php | 374 ++ includes/adodb/adodb-perf.inc.php | 1089 ++++ includes/adodb/adodb-php4.inc.php | 16 + includes/adodb/adodb-time.inc.php | 1426 +++++ includes/adodb/adodb-xmlschema.inc.php | 2223 ++++++++ includes/adodb/adodb-xmlschema03.inc.php | 2404 +++++++++ includes/adodb/adodb.inc.php | 4376 ++++++++++++++++ .../adodb/datadict/datadict-access.inc.php | 95 + includes/adodb/datadict/datadict-db2.inc.php | 143 + .../adodb/datadict/datadict-firebird.inc.php | 151 + .../adodb/datadict/datadict-generic.inc.php | 125 + .../adodb/datadict/datadict-ibase.inc.php | 67 + .../adodb/datadict/datadict-informix.inc.php | 80 + .../adodb/datadict/datadict-mssql.inc.php | 282 + .../datadict/datadict-mssqlnative.inc.php | 282 + .../adodb/datadict/datadict-mysql.inc.php | 181 + includes/adodb/datadict/datadict-oci8.inc.php | 291 ++ .../adodb/datadict/datadict-postgres.inc.php | 447 ++ .../datadict/datadict-postgres.inc.php.bak | 441 ++ .../adodb/datadict/datadict-sapdb.inc.php | 121 + .../adodb/datadict/datadict-sybase.inc.php | 228 + includes/adodb/drivers/adodb-access.inc.php | 87 + includes/adodb/drivers/adodb-ado.inc.php | 644 +++ includes/adodb/drivers/adodb-ado5.inc.php | 678 +++ .../adodb/drivers/adodb-ado_access.inc.php | 55 + .../adodb/drivers/adodb-ado_mssql.inc.php | 154 + .../adodb/drivers/adodb-borland_ibase.inc.php | 92 + includes/adodb/drivers/adodb-csv.inc.php | 207 + includes/adodb/drivers/adodb-db2.inc.php | 828 +++ includes/adodb/drivers/adodb-fbsql.inc.php | 266 + includes/adodb/drivers/adodb-firebird.inc.php | 77 + includes/adodb/drivers/adodb-ibase.inc.php | 887 ++++ includes/adodb/drivers/adodb-informix.inc.php | 40 + .../adodb/drivers/adodb-informix72.inc.php | 475 ++ includes/adodb/drivers/adodb-ldap.inc.php | 419 ++ includes/adodb/drivers/adodb-mssql.inc.php | 1054 ++++ includes/adodb/drivers/adodb-mssql_n.inc.php | 171 + .../adodb/drivers/adodb-mssqlnative.inc.php | 902 ++++ includes/adodb/drivers/adodb-mssqlpo.inc.php | 62 + includes/adodb/drivers/adodb-mysql.inc.php | 791 +++ includes/adodb/drivers/adodb-mysqli.inc.php | 1184 +++++ includes/adodb/drivers/adodb-mysqlpo.inc.php | 138 + includes/adodb/drivers/adodb-mysqlt.inc.php | 155 + includes/adodb/drivers/adodb-netezza.inc.php | 170 + includes/adodb/drivers/adodb-oci8.inc.php | 1574 ++++++ includes/adodb/drivers/adodb-oci8.old.inc.php | 1532 ++++++ includes/adodb/drivers/adodb-oci805.inc.php | 59 + includes/adodb/drivers/adodb-oci8po.inc.php | 218 + includes/adodb/drivers/adodb-odbc.inc.php | 738 +++ includes/adodb/drivers/adodb-odbc_db2.inc.php | 368 ++ .../adodb/drivers/adodb-odbc_mssql.inc.php | 306 ++ .../adodb/drivers/adodb-odbc_oracle.inc.php | 115 + includes/adodb/drivers/adodb-odbtp.inc.php | 793 +++ .../adodb/drivers/adodb-odbtp_unicode.inc.php | 39 + includes/adodb/drivers/adodb-oracle.inc.php | 338 ++ includes/adodb/drivers/adodb-pdo.inc.php | 580 +++ .../adodb/drivers/adodb-pdo_mssql.inc.php | 61 + .../adodb/drivers/adodb-pdo_mysql.inc.php | 182 + includes/adodb/drivers/adodb-pdo_oci.inc.php | 93 + .../adodb/drivers/adodb-pdo_pgsql.inc.php | 230 + .../adodb/drivers/adodb-pdo_sqlite.inc.php | 268 + includes/adodb/drivers/adodb-postgres.inc.php | 14 + .../adodb/drivers/adodb-postgres64.inc.php | 1065 ++++ .../adodb/drivers/adodb-postgres7.inc.php | 313 ++ .../adodb/drivers/adodb-postgres8.inc.php | 12 + includes/adodb/drivers/adodb-proxy.inc.php | 33 + includes/adodb/drivers/adodb-sapdb.inc.php | 184 + .../adodb/drivers/adodb-sqlanywhere.inc.php | 169 + includes/adodb/drivers/adodb-sqlite.inc.php | 398 ++ includes/adodb/drivers/adodb-sqlitepo.inc.php | 62 + includes/adodb/drivers/adodb-sybase.inc.php | 418 ++ .../adodb/drivers/adodb-sybase_ase.inc.php | 119 + includes/adodb/drivers/adodb-vfp.inc.php | 107 + includes/adodb/lang/adodb-ar.inc.php | 33 + includes/adodb/lang/adodb-bg.inc.php | 37 + includes/adodb/lang/adodb-bgutf8.inc.php | 37 + includes/adodb/lang/adodb-ca.inc.php | 34 + includes/adodb/lang/adodb-cn.inc.php | 35 + includes/adodb/lang/adodb-cz.inc.php | 40 + includes/adodb/lang/adodb-da.inc.php | 33 + includes/adodb/lang/adodb-de.inc.php | 33 + includes/adodb/lang/adodb-en.inc.php | 33 + includes/adodb/lang/adodb-es.inc.php | 33 + includes/adodb/lang/adodb-esperanto.inc.php | 35 + includes/adodb/lang/adodb-fa.inc.php | 35 + includes/adodb/lang/adodb-fr.inc.php | 33 + includes/adodb/lang/adodb-hu.inc.php | 34 + includes/adodb/lang/adodb-it.inc.php | 34 + includes/adodb/lang/adodb-nl.inc.php | 33 + includes/adodb/lang/adodb-pl.inc.php | 35 + includes/adodb/lang/adodb-pt-br.inc.php | 35 + includes/adodb/lang/adodb-ro.inc.php | 35 + includes/adodb/lang/adodb-ru1251.inc.php | 35 + includes/adodb/lang/adodb-sv.inc.php | 33 + includes/adodb/lang/adodb-uk1251.inc.php | 35 + includes/adodb/lang/adodb_th.inc.php | 33 + includes/adodb/license.txt | 182 + includes/adodb/pear/Auth/Container/ADOdb.php | 413 ++ includes/adodb/pear/readme.Auth.txt | 20 + includes/adodb/pivottable.inc.php | 187 + includes/adodb/readme.txt | 62 + includes/adodb/rsfilter.inc.php | 61 + includes/adodb/server.php | 100 + includes/adodb/toexport.inc.php | 134 + includes/aptree/apytmenu.js | 13 + includes/aptree/img/blank.gif | Bin 0 -> 43 bytes includes/aptree/img/collapsebtn.gif | Bin 0 -> 91 bytes includes/aptree/img/collapsebtn2.gif | Bin 0 -> 273 bytes includes/aptree/img/cpoint.gif | Bin 0 -> 53 bytes includes/aptree/img/expandbtn.gif | Bin 0 -> 97 bytes includes/aptree/img/expandbtn2.gif | Bin 0 -> 274 bytes includes/aptree/img/hpoint.gif | Bin 0 -> 47 bytes includes/aptree/img/icons/contacts.gif | Bin 0 -> 260 bytes includes/aptree/img/icons/email.gif | Bin 0 -> 278 bytes includes/aptree/img/icons/folder1.gif | Bin 0 -> 379 bytes includes/aptree/img/icons/folder2.gif | Bin 0 -> 363 bytes includes/aptree/img/icons/help1.gif | Bin 0 -> 211 bytes includes/aptree/img/icons/help2.gif | Bin 0 -> 211 bytes includes/aptree/img/icons/info.gif | Bin 0 -> 283 bytes includes/aptree/img/icons/list.gif | Bin 0 -> 263 bytes includes/aptree/img/icons/paper.gif | Bin 0 -> 250 bytes includes/aptree/img/icons/search.gif | Bin 0 -> 291 bytes includes/aptree/img/icons/support.gif | Bin 0 -> 264 bytes includes/aptree/img/movepic.gif | Bin 0 -> 43 bytes includes/aptree/img/pointcorner.gif | Bin 0 -> 47 bytes includes/aptree/img/topborder.gif | Bin 0 -> 106 bytes includes/aptree/img/vpoint.gif | Bin 0 -> 45 bytes includes/aptree/img/xpcollapse1.gif | Bin 0 -> 1300 bytes includes/aptree/img/xpcollapse2.gif | Bin 0 -> 1300 bytes includes/aptree/img/xpcollapse3.gif | Bin 0 -> 1290 bytes includes/aptree/img/xpcollapse4.gif | Bin 0 -> 1290 bytes includes/aptree/img/xpexpand1.gif | Bin 0 -> 1295 bytes includes/aptree/img/xpexpand2.gif | Bin 0 -> 1295 bytes includes/aptree/img/xpexpand3.gif | Bin 0 -> 1295 bytes includes/aptree/img/xpexpand4.gif | Bin 0 -> 1295 bytes includes/aptree/img/xpicon1.gif | Bin 0 -> 1637 bytes includes/aptree/img/xptitle.gif | Bin 0 -> 1319 bytes includes/aptree/img/xptitle2.gif | Bin 0 -> 1286 bytes includes/aptree/img/xptitleleft.gif | Bin 0 -> 52 bytes includes/aptree/img/xpvertline.gif | Bin 0 -> 600 bytes includes/aptree/tmenu1.js | 172 + includes/aptree/tstyles.css | 50 + includes/aptree/txpmenu-item-visibility.js | 106 + includes/aptree/txpmenu1.js | 104 + includes/aptree/txpmenu3.js | 98 + includes/cron/cron.inc.php | 221 + includes/cron/lgpl.txt | 504 ++ includes/files/.htaccess | 7 + includes/files/reports/.htaccess | 5 + includes/files/tracking.txt | 0 includes/javascript/MIT-LICENSE | 20 + includes/javascript/controls.js | 265 + includes/javascript/dragdrop.js | 476 ++ includes/javascript/effects.js | 570 ++ includes/javascript/prototype.js | 1027 ++++ includes/jscalendar/README.txt | 31 + includes/jscalendar/calendar-blue.css | 224 + .../jscalendar/calendar-setup_stripped.js | 20 + includes/jscalendar/calendar_stripped.js | 11 + includes/jscalendar/img.gif | Bin 0 -> 145 bytes includes/jscalendar/lang/calendar-cs-win.js | 34 + includes/jscalendar/lang/calendar-english.js | 114 + includes/jscalendar/lang/calendar-french.js | 45 + includes/jscalendar/lang/calendar-german.js | 54 + includes/jscalendar/lang/calendar-italian.js | 45 + includes/jscalendar/lang/calendar-russian.js | 45 + includes/jscalendar/lang/calendar-spanish.js | 45 + includes/jscalendar/menuarrow.gif | Bin 0 -> 68 bytes includes/overlib/mini/overlib_anchor_mini.js | 146 + .../overlib/mini/overlib_crossframe_mini.js | 44 + .../overlib/mini/overlib_cssstyle_mini.js | 44 + .../overlib/mini/overlib_exclusive_mini.js | 33 + .../overlib/mini/overlib_followscroll_mini.js | 64 + .../overlib/mini/overlib_hideform_mini.js | 39 + includes/overlib/mini/overlib_mini.js | 337 ++ includes/overlib/mini/overlib_shadow_mini.js | 55 + includes/overlib/overlib.js | 1336 +++++ includes/overlib/overlib_anchor.js | 437 ++ includes/overlib/overlib_crossframe.js | 125 + includes/overlib/overlib_cssstyle.js | 180 + includes/overlib/overlib_exclusive.js | 122 + includes/overlib/overlib_followscroll.js | 265 + includes/overlib/overlib_hideform.js | 133 + includes/overlib/overlib_shadow.js | 250 + includes/pdf/LICENSE | 202 + includes/pdf/decoders/ascii85.php | 97 + includes/pdf/decoders/lzw.php | 151 + includes/pdf/font/courier.php | 7 + includes/pdf/font/helvetica.php | 15 + includes/pdf/font/helveticab.php | 15 + includes/pdf/font/helveticabi.php | 15 + includes/pdf/font/helveticai.php | 15 + includes/pdf/font/symbol.php | 15 + includes/pdf/font/times.php | 15 + includes/pdf/font/timesb.php | 15 + includes/pdf/font/timesbi.php | 15 + includes/pdf/font/timesi.php | 15 + includes/pdf/font/zapfdingbats.php | 15 + includes/pdf/fpdf.php | 1648 ++++++ includes/pdf/fpdf_tpl.php | 446 ++ includes/pdf/fpdi.php | 413 ++ includes/pdf/fpdi_pdf_parser.php | 482 ++ includes/pdf/invoice.pdf | Bin 0 -> 85815 bytes includes/pdf/invoice1.pdf | Bin 0 -> 8651 bytes includes/pdf/invoice2.pdf | Bin 0 -> 8650 bytes includes/pdf/invoice_backup.pdf | Bin 0 -> 35038 bytes includes/pdf/invoice_base.inc.php | 254 + includes/pdf/pdf_context.php | 78 + includes/pdf/pdf_invoice_overview.inc.php | 278 + .../pdf/pdf_invoice_voip-detailed.inc.php | 406 ++ includes/pdf/pdf_invoice_voip.inc.php | 321 ++ includes/pdf/pdf_parser.php | 634 +++ includes/pdf/wrapper_functions.php | 88 + includes/pear/Compat.php | 133 + includes/pear/Compat/Components.php | 71 + includes/pear/Compat/Constant/E_STRICT.php | 35 + includes/pear/Compat/Constant/FILE.php | 51 + includes/pear/Compat/Constant/PHP_EOL.php | 49 + includes/pear/Compat/Constant/STD.php | 43 + includes/pear/Compat/Constant/T.php | 72 + includes/pear/Compat/Constant/UPLOAD_ERR.php | 51 + .../pear/Compat/Function/array_combine.php | 71 + .../pear/Compat/Function/array_diff_assoc.php | 75 + .../pear/Compat/Function/array_diff_key.php | 66 + .../Compat/Function/array_diff_uassoc.php | 83 + .../pear/Compat/Function/array_diff_ukey.php | 79 + .../Compat/Function/array_intersect_assoc.php | 69 + .../Compat/Function/array_intersect_key.php | 67 + .../Function/array_intersect_uassoc.php | 90 + .../Compat/Function/array_intersect_ukey.php | 79 + includes/pear/Compat/Function/array_udiff.php | 83 + .../Compat/Function/array_udiff_assoc.php | 85 + .../Compat/Function/array_udiff_uassoc.php | 82 + .../pear/Compat/Function/array_uintersect.php | 82 + .../Function/array_uintersect_assoc.php | 81 + .../Function/array_uintersect_uassoc.php | 97 + .../Compat/Function/array_walk_recursive.php | 68 + includes/pear/Compat/Function/clone.php | 56 + .../pear/Compat/Function/convert_uudecode.php | 79 + .../pear/Compat/Function/convert_uuencode.php | 79 + .../Compat/Function/debug_print_backtrace.php | 67 + .../Compat/Function/file_get_contents.php | 57 + .../Compat/Function/file_put_contents.php | 104 + includes/pear/Compat/Function/fprintf.php | 54 + includes/pear/Compat/Function/get_headers.php | 77 + .../pear/Compat/Function/get_include_path.php | 39 + .../Compat/Function/html_entity_decode.php | 72 + .../pear/Compat/Function/http_build_query.php | 99 + .../Function/image_type_to_mime_type.php | 147 + .../pear/Compat/Function/ob_get_clean.php | 46 + .../pear/Compat/Function/ob_get_flush.php | 46 + .../Compat/Function/php_strip_whitespace.php | 86 + .../Compat/Function/restore_include_path.php | 37 + includes/pear/Compat/Function/scandir.php | 69 + .../pear/Compat/Function/set_include_path.php | 37 + .../pear/Compat/Function/str_ireplace.php | 113 + includes/pear/Compat/Function/str_shuffle.php | 53 + includes/pear/Compat/Function/str_split.php | 52 + .../pear/Compat/Function/str_word_count.php | 68 + includes/pear/Compat/Function/stripos.php | 73 + includes/pear/Compat/Function/strpbrk.php | 63 + includes/pear/Compat/Function/strripos.php | 82 + .../pear/Compat/Function/substr_compare.php | 74 + includes/pear/Image/Canvas.php | 709 +++ includes/pear/Image/Canvas/Color.php | 182 + includes/pear/Image/Canvas/Fonts/README | 12 + includes/pear/Image/Canvas/Fonts/fontmap.txt | 25 + includes/pear/Image/Canvas/GD.php | 1632 ++++++ includes/pear/Image/Canvas/GD/JPG.php | 119 + includes/pear/Image/Canvas/GD/PNG.php | 125 + includes/pear/Image/Canvas/ImageMap.php | 354 ++ includes/pear/Image/Canvas/PDF.php | 1007 ++++ includes/pear/Image/Canvas/SVG.php | 885 ++++ includes/pear/Image/Canvas/Tool.php | 217 + includes/pear/Image/Canvas/WithMap.php | 278 + includes/pear/Image/Color.php | 719 +++ includes/pear/Image/Graph.php | 853 +++ includes/pear/Image/Graph/Axis.php | 1643 ++++++ includes/pear/Image/Graph/Axis/Category.php | 426 ++ .../pear/Image/Graph/Axis/Logarithmic.php | 175 + .../pear/Image/Graph/Axis/Marker/Area.php | 156 + .../pear/Image/Graph/Axis/Marker/Line.php | 124 + includes/pear/Image/Graph/Axis/Radar.php | 204 + includes/pear/Image/Graph/Common.php | 308 ++ includes/pear/Image/Graph/Config.php | 30 + includes/pear/Image/Graph/Constants.php | 225 + .../pear/Image/Graph/DataPreprocessor.php | 74 + .../Image/Graph/DataPreprocessor/Array.php | 103 + .../Image/Graph/DataPreprocessor/Currency.php | 66 + .../Image/Graph/DataPreprocessor/Date.php | 90 + .../Graph/DataPreprocessor/Formatted.php | 90 + .../Image/Graph/DataPreprocessor/Function.php | 92 + .../Graph/DataPreprocessor/NumberText.php | 89 + .../Graph/DataPreprocessor/RomanNumerals.php | 79 + .../Graph/DataPreprocessor/Sequential.php | 67 + includes/pear/Image/Graph/DataSelector.php | 67 + .../Graph/DataSelector/EveryNthPoint.php | 97 + .../pear/Image/Graph/DataSelector/NoZeros.php | 68 + .../pear/Image/Graph/DataSelector/Values.php | 90 + includes/pear/Image/Graph/Dataset.php | 483 ++ .../pear/Image/Graph/Dataset/Function.php | 147 + includes/pear/Image/Graph/Dataset/Random.php | 77 + .../pear/Image/Graph/Dataset/Sequential.php | 114 + includes/pear/Image/Graph/Dataset/Trivial.php | 260 + .../Image/Graph/Dataset/VectorFunction.php | 185 + includes/pear/Image/Graph/Element.php | 727 +++ includes/pear/Image/Graph/Figure/Circle.php | 64 + includes/pear/Image/Graph/Figure/Ellipse.php | 97 + includes/pear/Image/Graph/Figure/Polygon.php | 94 + .../pear/Image/Graph/Figure/Rectangle.php | 96 + includes/pear/Image/Graph/Fill.php | 63 + includes/pear/Image/Graph/Fill/Array.php | 137 + includes/pear/Image/Graph/Fill/Gradient.php | 149 + includes/pear/Image/Graph/Fill/Image.php | 97 + includes/pear/Image/Graph/Font.php | 158 + includes/pear/Image/Graph/Grid.php | 175 + includes/pear/Image/Graph/Grid/Bars.php | 117 + includes/pear/Image/Graph/Grid/Lines.php | 114 + includes/pear/Image/Graph/Grid/Polar.php | 111 + .../Image/Graph/Images/Icons/pinpoint.png | Bin 0 -> 452 bytes .../Image/Graph/Images/Icons/pinpointr.png | Bin 0 -> 437 bytes includes/pear/Image/Graph/Images/Maps/README | 17 + includes/pear/Image/Graph/Layout.php | 219 + .../pear/Image/Graph/Layout/Horizontal.php | 186 + includes/pear/Image/Graph/Layout/Matrix.php | 201 + includes/pear/Image/Graph/Layout/Vertical.php | 108 + includes/pear/Image/Graph/Legend.php | 385 ++ includes/pear/Image/Graph/Line/Array.php | 129 + includes/pear/Image/Graph/Line/Dashed.php | 76 + includes/pear/Image/Graph/Line/Dotted.php | 67 + includes/pear/Image/Graph/Line/Formatted.php | 90 + includes/pear/Image/Graph/Line/Solid.php | 105 + includes/pear/Image/Graph/Logo.php | 153 + includes/pear/Image/Graph/Marker.php | 123 + includes/pear/Image/Graph/Marker/Array.php | 105 + includes/pear/Image/Graph/Marker/Asterisk.php | 109 + includes/pear/Image/Graph/Marker/Average.php | 91 + includes/pear/Image/Graph/Marker/Box.php | 76 + includes/pear/Image/Graph/Marker/Bubble.php | 91 + includes/pear/Image/Graph/Marker/Circle.php | 96 + includes/pear/Image/Graph/Marker/Cross.php | 114 + includes/pear/Image/Graph/Marker/Diamond.php | 73 + includes/pear/Image/Graph/Marker/Icon.php | 133 + includes/pear/Image/Graph/Marker/Pinpoint.php | 65 + includes/pear/Image/Graph/Marker/Plus.php | 98 + includes/pear/Image/Graph/Marker/Pointing.php | 140 + .../Image/Graph/Marker/Pointing/Angular.php | 105 + .../Image/Graph/Marker/Pointing/Radial.php | 91 + .../Image/Graph/Marker/ReversePinpoint.php | 65 + includes/pear/Image/Graph/Marker/Star.php | 88 + includes/pear/Image/Graph/Marker/Triangle.php | 75 + includes/pear/Image/Graph/Marker/Value.php | 214 + includes/pear/Image/Graph/Plot.php | 818 +++ includes/pear/Image/Graph/Plot/Area.php | 188 + includes/pear/Image/Graph/Plot/Band.php | 198 + includes/pear/Image/Graph/Plot/Bar.php | 302 ++ includes/pear/Image/Graph/Plot/BoxWhisker.php | 294 ++ .../pear/Image/Graph/Plot/CandleStick.php | 247 + includes/pear/Image/Graph/Plot/Dot.php | 95 + includes/pear/Image/Graph/Plot/Fit/Line.php | 116 + includes/pear/Image/Graph/Plot/Impulse.php | 203 + includes/pear/Image/Graph/Plot/Line.php | 164 + includes/pear/Image/Graph/Plot/Odo.php | 717 +++ includes/pear/Image/Graph/Plot/Pie.php | 481 ++ includes/pear/Image/Graph/Plot/Radar.php | 116 + .../pear/Image/Graph/Plot/Smoothed/Area.php | 142 + .../pear/Image/Graph/Plot/Smoothed/Bezier.php | 173 + .../pear/Image/Graph/Plot/Smoothed/Line.php | 164 + .../pear/Image/Graph/Plot/Smoothed/Radar.php | 140 + includes/pear/Image/Graph/Plot/Step.php | 198 + includes/pear/Image/Graph/Plotarea.php | 1143 ++++ .../pear/Image/Graph/Plotarea/Element.php | 87 + includes/pear/Image/Graph/Plotarea/Map.php | 304 ++ includes/pear/Image/Graph/Plotarea/Radar.php | 243 + includes/pear/Image/Graph/Simple.php | 121 + includes/pear/Image/Graph/Title.php | 194 + includes/pear/Image/Graph/Tool.php | 291 ++ includes/pear/Image/docs/ChangeLog | 48 + includes/pear/Image/docs/LICENSE | 344 ++ includes/pear/Image/docs/README | 41 + includes/pear/Image/docs/colors.txt | 142 + .../pear/Image/docs/examples/antialias.php | 104 + .../Image/docs/examples/axis_direction.php | 54 + includes/pear/Image/docs/examples/canvas.php | 61 + .../examples/category_axis_explanation.php | 84 + .../pear/Image/docs/examples/color_chart.php | 51 + .../pear/Image/docs/examples/customize.php | 116 + .../pear/Image/docs/examples/data/colors.txt | 140 + .../Image/docs/examples/datapreprocessor.php | 99 + .../docs/examples/double_category_axis.php | 100 + .../Image/docs/examples/driver_filepdf.php | 53 + .../pear/Image/docs/examples/driver_pdf.php | 198 + .../Image/docs/examples/driver_png_svg.php | 72 + .../pear/Image/docs/examples/driver_swf01.php | 57 + .../pear/Image/docs/examples/driver_swf02.php | 197 + .../pear/Image/docs/examples/driver_swf03.php | 53 + .../Image/docs/examples/frontpage_sample.php | 313 ++ .../docs/examples/gradient_fill_area.php | 80 + .../pear/Image/docs/examples/gradient_pie.php | 106 + .../Image/docs/examples/gradient_step.php | 77 + .../pear/Image/docs/examples/horizontal.php | 127 + .../Image/docs/examples/html_image_map.php | 108 + .../pear/Image/docs/examples/image_fill.php | 85 + .../pear/Image/docs/examples/imagemap.png | Bin 0 -> 8737 bytes .../docs/examples/images/audi-tt-coupe.jpg | Bin 0 -> 93601 bytes .../pear/Image/docs/examples/images/audi.png | Bin 0 -> 1738 bytes .../pear/Image/docs/examples/images/bmw.png | Bin 0 -> 1684 bytes .../pear/Image/docs/examples/images/coins.png | Bin 0 -> 2327 bytes .../Image/docs/examples/images/mercedes.png | Bin 0 -> 2431 bytes .../Image/docs/examples/images/modify.jpg | Bin 0 -> 87978 bytes .../Image/docs/examples/images/mountain.jpg | Bin 0 -> 22009 bytes .../Image/docs/examples/images/porsche.png | Bin 0 -> 1949 bytes includes/pear/Image/docs/examples/index.html | 1 + .../Image/docs/examples/layout_matrix.php | 49 + .../pear/Image/docs/examples/line_break.php | 78 + .../pear/Image/docs/examples/log_axis.php | 104 + .../docs/examples/log_axis_intersect.php | 106 + .../pear/Image/docs/examples/logo_graph.php | 194 + .../Image/docs/examples/manual_labels.php | 42 + includes/pear/Image/docs/examples/misc01.php | 197 + includes/pear/Image/docs/examples/misc02.php | 117 + includes/pear/Image/docs/examples/misc03.php | 78 + includes/pear/Image/docs/examples/misc04.php | 35 + includes/pear/Image/docs/examples/misc05.php | 146 + includes/pear/Image/docs/examples/misc06.php | 132 + .../Image/docs/examples/multiple_plots.php | 82 + .../Image/docs/examples/negative_values.php | 72 + .../pear/Image/docs/examples/pear-icon.png | Bin 0 -> 927 bytes .../pear/Image/docs/examples/plot_all.php | 231 + .../docs/examples/plot_all_horizontal.php | 247 + .../examples/plot_all_horizontal_invert.php | 250 + .../pear/Image/docs/examples/plot_area.php | 57 + .../Image/docs/examples/plot_area_smooth.php | 55 + .../Image/docs/examples/plot_area_stack.php | 64 + .../pear/Image/docs/examples/plot_band.php | 62 + .../pear/Image/docs/examples/plot_bar.php | 55 + .../docs/examples/plot_bar_horizontal.php | 80 + .../Image/docs/examples/plot_bar_multiple.php | 72 + .../Image/docs/examples/plot_bar_stacked.php | 73 + .../docs/examples/plot_bar_stacked100pct.php | 83 + .../examples/plot_bar_stacked_horizontal.php | 79 + .../examples/plot_bar_stacked_negative.php | 74 + .../Image/docs/examples/plot_boxwhisker.php | 64 + .../Image/docs/examples/plot_candlestick.php | 84 + .../pear/Image/docs/examples/plot_impulse.php | 51 + .../docs/examples/plot_impulse_stacked.php | 66 + .../pear/Image/docs/examples/plot_line.php | 55 + .../Image/docs/examples/plot_line_smooth.php | 51 + .../pear/Image/docs/examples/plot_map.php | 75 + .../pear/Image/docs/examples/plot_odo.php | 121 + .../pear/Image/docs/examples/plot_pie.php | 58 + .../Image/docs/examples/plot_pie_rotate.php | 80 + .../pear/Image/docs/examples/plot_radar.php | 82 + .../Image/docs/examples/plot_radar_smooth.php | 78 + .../pear/Image/docs/examples/plot_scatter.php | 65 + .../docs/examples/plot_scatter_linefit.php | 60 + .../pear/Image/docs/examples/plot_step.php | 60 + .../Image/docs/examples/secondary_axis.php | 85 + includes/pear/Image/docs/examples/simple.php | 28 + .../pear/Image/docs/examples/simple_graph.php | 40 + .../Image/docs/examples/small_pie_plot.php | 53 + .../Image/docs/examples/vector_function.php | 62 + includes/pear/Image/tests/README | 12 + includes/pear/Image/tests/axis/category.php | 87 + .../pear/Image/tests/axis/intersection.php | 82 + .../axis/intersection_secondary_axis.php | 89 + includes/pear/Image/tests/axis/inversion.php | 89 + .../pear/Image/tests/axis/labelinterval.php | 99 + .../pear/Image/tests/axis/logarithmic.php | 84 + includes/pear/Image/tests/canvas_body.php | 326 ++ includes/pear/Image/tests/freetype.php | 70 + includes/pear/Image/tests/gd.php | 75 + includes/pear/Image/tests/gradients.php | 87 + includes/pear/Image/tests/imagemap.php | 180 + includes/pear/Image/tests/jpg.php | 39 + includes/pear/Image/tests/lineends.php | 85 + includes/pear/Image/tests/pdf.php | 39 + includes/pear/Image/tests/pear-icon.png | Bin 0 -> 927 bytes includes/pear/Image/tests/plot/area.php | 79 + includes/pear/Image/tests/plot/bar.php | 79 + .../pear/Image/tests/plot/horizontal/area.php | 92 + .../pear/Image/tests/plot/horizontal/bar.php | 92 + .../Image/tests/plot/horizontal/impulse.php | 91 + .../pear/Image/tests/plot/horizontal/line.php | 91 + .../pear/Image/tests/plot/horizontal/step.php | 92 + includes/pear/Image/tests/plot/impulse.php | 78 + includes/pear/Image/tests/plot/line.php | 78 + includes/pear/Image/tests/plot/step.php | 79 + includes/pear/Image/tests/png.php | 39 + includes/pear/Image/tests/svg.php | 39 + includes/pear/Image/tests/text.php | 109 + includes/pear/OS/Guess.php | 343 ++ includes/pear/PEAR.php | 1095 ++++ includes/pear/PEAR/Autoloader.php | 223 + includes/pear/PEAR/Builder.php | 455 ++ includes/pear/PEAR/ChannelFile.php | 1601 ++++++ includes/pear/PEAR/ChannelFile/Parser.php | 73 + includes/pear/PEAR/Command.php | 407 ++ includes/pear/PEAR/Command/Auth.php | 180 + includes/pear/PEAR/Command/Auth.xml | 25 + includes/pear/PEAR/Command/Build.php | 104 + includes/pear/PEAR/Command/Build.xml | 10 + includes/pear/PEAR/Command/Channels.php | 770 +++ includes/pear/PEAR/Command/Channels.xml | 93 + includes/pear/PEAR/Command/Common.php | 277 + includes/pear/PEAR/Command/Config.php | 401 ++ includes/pear/PEAR/Command/Config.xml | 92 + includes/pear/PEAR/Command/Install.php | 748 +++ includes/pear/PEAR/Command/Install.xml | 254 + includes/pear/PEAR/Command/Mirror.php | 147 + includes/pear/PEAR/Command/Mirror.xml | 18 + includes/pear/PEAR/Command/Package.php | 1133 ++++ includes/pear/PEAR/Command/Package.xml | 194 + includes/pear/PEAR/Command/Pickle.php | 376 ++ includes/pear/PEAR/Command/Pickle.xml | 40 + includes/pear/PEAR/Command/Registry.php | 997 ++++ includes/pear/PEAR/Command/Registry.xml | 54 + includes/pear/PEAR/Command/Remote.php | 649 +++ includes/pear/PEAR/Command/Remote.xml | 92 + includes/pear/PEAR/Command/Test.php | 257 + includes/pear/PEAR/Command/Test.xml | 36 + includes/pear/PEAR/Common.php | 1129 ++++ includes/pear/PEAR/Config.php | 2054 ++++++++ includes/pear/PEAR/Dependency.php | 495 ++ includes/pear/PEAR/Dependency2.php | 1195 +++++ includes/pear/PEAR/DependencyDB.php | 655 +++ includes/pear/PEAR/Downloader.php | 1465 ++++++ includes/pear/PEAR/Downloader/Package.php | 1678 ++++++ includes/pear/PEAR/ErrorStack.php | 970 ++++ includes/pear/PEAR/Exception.php | 376 ++ includes/pear/PEAR/Frontend.php | 142 + includes/pear/PEAR/Frontend/CLI.php | 737 +++ includes/pear/PEAR/Installer.php | 1556 ++++++ includes/pear/PEAR/Installer/Role.php | 248 + includes/pear/PEAR/Installer/Role/Common.php | 180 + includes/pear/PEAR/Installer/Role/Data.php | 34 + includes/pear/PEAR/Installer/Role/Data.xml | 13 + includes/pear/PEAR/Installer/Role/Doc.php | 34 + includes/pear/PEAR/Installer/Role/Doc.xml | 13 + includes/pear/PEAR/Installer/Role/Ext.php | 34 + includes/pear/PEAR/Installer/Role/Ext.xml | 11 + includes/pear/PEAR/Installer/Role/Php.php | 34 + includes/pear/PEAR/Installer/Role/Php.xml | 13 + includes/pear/PEAR/Installer/Role/Script.php | 34 + includes/pear/PEAR/Installer/Role/Script.xml | 13 + includes/pear/PEAR/Installer/Role/Src.php | 40 + includes/pear/PEAR/Installer/Role/Src.xml | 11 + includes/pear/PEAR/Installer/Role/Test.php | 34 + includes/pear/PEAR/Installer/Role/Test.xml | 13 + includes/pear/PEAR/PackageFile.php | 436 ++ .../pear/PEAR/PackageFile/Generator/v1.php | 1267 +++++ .../pear/PEAR/PackageFile/Generator/v2.php | 1539 ++++++ includes/pear/PEAR/PackageFile/Parser/v1.php | 461 ++ includes/pear/PEAR/PackageFile/Parser/v2.php | 115 + includes/pear/PEAR/PackageFile/v1.php | 1596 ++++++ includes/pear/PEAR/PackageFile/v2.php | 1985 +++++++ .../pear/PEAR/PackageFile/v2/Validator.php | 1976 +++++++ includes/pear/PEAR/PackageFile/v2/rw.php | 1557 ++++++ includes/pear/PEAR/Packager.php | 202 + includes/pear/PEAR/REST.php | 380 ++ includes/pear/PEAR/REST/10.php | 624 +++ includes/pear/PEAR/REST/11.php | 206 + includes/pear/PEAR/Registry.php | 2131 ++++++++ includes/pear/PEAR/Remote.php | 519 ++ includes/pear/PEAR/RunTest.php | 389 ++ includes/pear/PEAR/Task/Common.php | 208 + includes/pear/PEAR/Task/Postinstallscript.php | 325 ++ .../pear/PEAR/Task/Postinstallscript/rw.php | 176 + includes/pear/PEAR/Task/Replace.php | 182 + includes/pear/PEAR/Task/Replace/rw.php | 67 + includes/pear/PEAR/Task/Unixeol.php | 83 + includes/pear/PEAR/Task/Unixeol/rw.php | 62 + includes/pear/PEAR/Task/Windowseol.php | 83 + includes/pear/PEAR/Task/Windowseol/rw.php | 62 + includes/pear/PEAR/Validate.php | 624 +++ includes/pear/PEAR/Validator/PECL.php | 52 + includes/pear/PEAR/XMLParser.php | 261 + includes/pear/System.php | 582 +++ includes/pear/XML/Parser.php | 685 +++ includes/pear/XML/Parser/Simple.php | 297 ++ includes/pear/scripts/pear.bat | 115 + includes/pear/scripts/pear.sh | 28 + includes/pear/scripts/pearcmd.php | 423 ++ includes/pear/scripts/peardev.bat | 229 + includes/pear/scripts/peardev.sh | 28 + includes/pear/scripts/pecl.bat | 115 + includes/pear/scripts/pecl.sh | 28 + includes/pear/scripts/peclcmd.php | 45 + includes/phplayers/PHPLIB.php | 562 ++ includes/phplayers/layersmenu-common.inc.php | 955 ++++ includes/phplayers/layerstreemenu-hidden.css | 5 + includes/phplayers/layerstreemenu.css | 76 + .../libjs/layersmenu-browser_detection.js | 33 + .../phplayers/libjs/layersmenu-footer.ijs | 11 + .../phplayers/libjs/layersmenu-header.ijs | 57 + .../phplayers/libjs/layersmenu-library.js | 248 + .../phplayers/libjs/layersmenu-see-through.js | 65 + includes/phplayers/libjs/layersmenu.js | 316 ++ .../phplayers/libjs/layerstreemenu-cookies.js | 70 + includes/phplayers/libjs/layerstreemenu.ijs | 52 + includes/phplayers/menuimages/Thumbs.db | Bin 0 -> 67584 bytes .../menuimages/kde_tree_collapse.png | Bin 0 -> 178 bytes .../menuimages/kde_tree_collapse_corner.png | Bin 0 -> 177 bytes .../kde_tree_collapse_corner_first.png | Bin 0 -> 172 bytes .../menuimages/kde_tree_collapse_first.png | Bin 0 -> 176 bytes .../phplayers/menuimages/kde_tree_corner.png | Bin 0 -> 159 bytes .../phplayers/menuimages/kde_tree_expand.png | Bin 0 -> 183 bytes .../menuimages/kde_tree_expand_corner.png | Bin 0 -> 182 bytes .../kde_tree_expand_corner_first.png | Bin 0 -> 177 bytes .../menuimages/kde_tree_expand_first.png | Bin 0 -> 181 bytes .../menuimages/kde_tree_folder_closed.png | Bin 0 -> 665 bytes .../menuimages/kde_tree_folder_open.png | Bin 0 -> 653 bytes .../phplayers/menuimages/kde_tree_leaf.png | Bin 0 -> 829 bytes .../phplayers/menuimages/kde_tree_space.png | Bin 0 -> 150 bytes .../phplayers/menuimages/kde_tree_split.png | Bin 0 -> 159 bytes .../menuimages/kde_tree_split_first.png | Bin 0 -> 159 bytes .../menuimages/kde_tree_vertline.png | Bin 0 -> 155 bytes includes/phplayers/treemenu.inc.php | 352 ++ includes/phpmailer/LICENSE.txt | 504 ++ includes/phpmailer/class.phpmailer.php | 1497 ++++++ includes/phpmailer/class.smtp.php | 1039 ++++ includes/smarty/Config_File.class.php | 389 ++ includes/smarty/Smarty.class.php | 1944 +++++++ includes/smarty/Smarty_Compiler.class.php | 2313 +++++++++ includes/smarty/debug.tpl | 64 + .../core.assemble_plugin_filepath.php | 67 + .../core.assign_smarty_interface.php | 43 + .../internals/core.create_dir_structure.php | 79 + .../internals/core.display_debug_console.php | 61 + .../internals/core.get_include_path.php | 44 + .../smarty/internals/core.get_microtime.php | 23 + .../internals/core.get_php_resource.php | 80 + includes/smarty/internals/core.is_secure.php | 59 + includes/smarty/internals/core.is_trusted.php | 47 + .../smarty/internals/core.load_plugins.php | 125 + .../internals/core.load_resource_plugin.php | 74 + .../internals/core.process_cached_inserts.php | 71 + .../core.process_compiled_include.php | 37 + .../smarty/internals/core.read_cache_file.php | 101 + includes/smarty/internals/core.rm_auto.php | 71 + includes/smarty/internals/core.rmdir.php | 54 + .../internals/core.run_insert_handler.php | 71 + .../internals/core.smarty_include_php.php | 50 + .../internals/core.write_cache_file.php | 96 + .../internals/core.write_compiled_include.php | 91 + .../core.write_compiled_resource.php | 35 + includes/smarty/internals/core.write_file.php | 54 + includes/smarty/plugins/block.account.php | 20 + includes/smarty/plugins/block.group.php | 38 + includes/smarty/plugins/block.htmlarea.php | 55 + includes/smarty/plugins/block.is_auth.php | 23 + .../smarty/plugins/block.is_auth_method.php | 25 + includes/smarty/plugins/block.panel.php | 39 + includes/smarty/plugins/block.textformat.php | 103 + includes/smarty/plugins/block.translate.php | 38 + includes/smarty/plugins/compiler.assign.php | 40 + .../smarty/plugins/function.ab_version.php | 19 + includes/smarty/plugins/function.assign.php | 30 + .../plugins/function.assign_debug_info.php | 40 + includes/smarty/plugins/function.block.php | 29 + .../smarty/plugins/function.config_load.php | 142 + includes/smarty/plugins/function.counter.php | 80 + includes/smarty/plugins/function.cycle.php | 102 + includes/smarty/plugins/function.date.php | 16 + .../smarty/plugins/function.date_time.php | 18 + .../smarty/plugins/function.db_lookup.php | 33 + includes/smarty/plugins/function.debug.php | 35 + includes/smarty/plugins/function.eval.php | 49 + includes/smarty/plugins/function.exe.php | 22 + includes/smarty/plugins/function.fetch.php | 221 + includes/smarty/plugins/function.graph.php | 41 + .../smarty/plugins/function.grid_bool.php | 20 + .../plugins/function.grid_column_heading.php | 31 + .../plugins/function.grid_column_refine.php | 26 + .../smarty/plugins/function.grid_paginate.php | 22 + .../smarty/plugins/function.html_bool.php | 28 + .../smarty/plugins/function.html_button.php | 58 + .../plugins/function.html_checkboxes.php | 143 + .../smarty/plugins/function.html_date.php | 28 + .../smarty/plugins/function.html_image.php | 142 + .../smarty/plugins/function.html_link.php | 77 + .../smarty/plugins/function.html_menu.php | 41 + .../plugins/function.html_menu_files.php | 80 + .../plugins/function.html_menu_multi.php | 51 + .../function.html_menu_product_host.php | 41 + ...unction.html_menu_product_subscription.php | 42 + .../function.html_menu_search_expr.php | 63 + .../smarty/plugins/function.html_menu_sub.php | 96 + .../smarty/plugins/function.html_options.php | 122 + .../smarty/plugins/function.html_radios.php | 156 + .../plugins/function.html_select_account.php | 49 + .../function.html_select_affiliate.php | 56 + .../plugins/function.html_select_date.php | 323 ++ .../plugins/function.html_select_time.php | 194 + .../smarty/plugins/function.html_table.php | 137 + .../smarty/plugins/function.html_textarea.php | 39 + .../smarty/plugins/function.input_text.php | 21 + includes/smarty/plugins/function.mailto.php | 163 + includes/smarty/plugins/function.math.php | 84 + includes/smarty/plugins/function.plugin.php | 70 + includes/smarty/plugins/function.popup.php | 119 + .../smarty/plugins/function.popup_init.php | 40 + .../smarty/plugins/function.style_hide.php | 17 + includes/smarty/plugins/function.voip_did.php | 29 + .../smarty/plugins/function.voip_did_id.php | 38 + includes/smarty/plugins/modifier.bool.php | 10 + .../smarty/plugins/modifier.capitalize.php | 43 + includes/smarty/plugins/modifier.cat.php | 33 + .../plugins/modifier.count_characters.php | 32 + .../plugins/modifier.count_paragraphs.php | 29 + .../plugins/modifier.count_sentences.php | 29 + .../smarty/plugins/modifier.count_words.php | 33 + includes/smarty/plugins/modifier.date.php | 7 + .../smarty/plugins/modifier.date_format.php | 49 + .../plugins/modifier.debug_print_var.php | 57 + includes/smarty/plugins/modifier.default.php | 32 + includes/smarty/plugins/modifier.escape.php | 93 + includes/smarty/plugins/modifier.indent.php | 28 + .../smarty/plugins/modifier.linkalize.php | 28 + includes/smarty/plugins/modifier.lower.php | 26 + includes/smarty/plugins/modifier.markdown.php | 1989 +++++++ includes/smarty/plugins/modifier.nl2br.php | 35 + .../smarty/plugins/modifier.regex_replace.php | 34 + includes/smarty/plugins/modifier.replace.php | 30 + .../smarty/plugins/modifier.smartypants.php | 854 +++ includes/smarty/plugins/modifier.spacify.php | 30 + .../smarty/plugins/modifier.string_format.php | 29 + includes/smarty/plugins/modifier.strip.php | 33 + .../smarty/plugins/modifier.strip_tags.php | 32 + includes/smarty/plugins/modifier.textile.php | 4089 +++++++++++++++ includes/smarty/plugins/modifier.truncate.php | 50 + includes/smarty/plugins/modifier.upper.php | 26 + includes/smarty/plugins/modifier.wordwrap.php | 29 + .../plugins/outputfilter.trimwhitespace.php | 75 + includes/smarty/plugins/postfilter.lang.php | 37 + .../plugins/shared.escape_special_chars.php | 31 + .../smarty/plugins/shared.make_timestamp.php | 46 + includes/tinymce/jscripts/tiny_mce/blank.htm | 10 + .../tinymce/jscripts/tiny_mce/langs/ar.js | 39 + .../tinymce/jscripts/tiny_mce/langs/cs.js | 38 + .../tinymce/jscripts/tiny_mce/langs/da.js | 38 + .../tinymce/jscripts/tiny_mce/langs/de.js | 38 + .../tinymce/jscripts/tiny_mce/langs/el.js | 38 + .../tinymce/jscripts/tiny_mce/langs/en.js | 38 + .../tinymce/jscripts/tiny_mce/langs/es.js | 38 + .../tinymce/jscripts/tiny_mce/langs/fa.js | 43 + .../tinymce/jscripts/tiny_mce/langs/fi.js | 38 + .../tinymce/jscripts/tiny_mce/langs/fr.js | 38 + .../tinymce/jscripts/tiny_mce/langs/fr_ca.js | 38 + .../tinymce/jscripts/tiny_mce/langs/hu.js | 39 + .../tinymce/jscripts/tiny_mce/langs/it.js | 38 + .../tinymce/jscripts/tiny_mce/langs/ja.js | 38 + .../tinymce/jscripts/tiny_mce/langs/ko.js | 37 + .../tinymce/jscripts/tiny_mce/langs/nl.js | 38 + .../tinymce/jscripts/tiny_mce/langs/no.js | 37 + .../tinymce/jscripts/tiny_mce/langs/pl.js | 38 + .../tinymce/jscripts/tiny_mce/langs/pt.js | 41 + .../jscripts/tiny_mce/langs/readme.txt | 2 + .../tinymce/jscripts/tiny_mce/langs/ru.js | 40 + .../tinymce/jscripts/tiny_mce/langs/sv.js | 40 + .../tinymce/jscripts/tiny_mce/langs/th.js | 37 + .../tinymce/jscripts/tiny_mce/langs/zh_cn.js | 38 + .../tiny_mce/plugins/advhr/editor_plugin.js | 2 + .../plugins/advhr/editor_plugin_src.js | 58 + .../tiny_mce/plugins/advhr/images/advhr.gif | Bin 0 -> 209 bytes .../tiny_mce/plugins/advhr/langs/cs.js | 6 + .../tiny_mce/plugins/advhr/langs/de.js | 6 + .../tiny_mce/plugins/advhr/langs/en.js | 6 + .../tiny_mce/plugins/advhr/langs/fa.js | 11 + .../tiny_mce/plugins/advhr/langs/fr.js | 6 + .../tiny_mce/plugins/advhr/langs/fr_ca.js | 6 + .../tiny_mce/plugins/advhr/langs/sv.js | 6 + .../tiny_mce/plugins/advhr/langs/zh_cn.js | 6 + .../tiny_mce/plugins/advhr/readme.txt | 20 + .../jscripts/tiny_mce/plugins/advhr/rule.htm | 108 + .../plugins/advimage/editor_plugin.js | 2 + .../plugins/advimage/editor_plugin_src.js | 28 + .../tiny_mce/plugins/advimage/image.htm | 315 ++ .../tiny_mce/plugins/advimage/langs/cs.js | 6 + .../tiny_mce/plugins/advimage/langs/de.js | 6 + .../tiny_mce/plugins/advimage/langs/en.js | 6 + .../tiny_mce/plugins/advimage/langs/fa.js | 11 + .../tiny_mce/plugins/advimage/langs/fa_ca.js | 6 + .../tiny_mce/plugins/advimage/langs/fr.js | 6 + .../tiny_mce/plugins/advimage/langs/ko.js | 6 + .../tiny_mce/plugins/advimage/langs/sv.js | 6 + .../tiny_mce/plugins/advimage/langs/zh_cn.js | 6 + .../tiny_mce/plugins/advimage/readme.txt | 19 + .../tiny_mce/plugins/advlink/editor_plugin.js | 2 + .../plugins/advlink/editor_plugin_src.js | 18 + .../tiny_mce/plugins/advlink/langs/cs.js | 20 + .../tiny_mce/plugins/advlink/langs/de.js | 20 + .../tiny_mce/plugins/advlink/langs/en.js | 20 + .../tiny_mce/plugins/advlink/langs/fa.js | 25 + .../tiny_mce/plugins/advlink/langs/fr.js | 20 + .../tiny_mce/plugins/advlink/langs/fr_ca.js | 20 + .../tiny_mce/plugins/advlink/langs/ko.js | 19 + .../tiny_mce/plugins/advlink/langs/sv.js | 20 + .../tiny_mce/plugins/advlink/langs/zh_cn.js | 20 + .../tiny_mce/plugins/advlink/link.htm | 421 ++ .../tiny_mce/plugins/advlink/readme.txt | 19 + .../plugins/emotions/editor_plugin.js | 2 + .../plugins/emotions/editor_plugin_src.js | 36 + .../tiny_mce/plugins/emotions/emotions.htm | 45 + .../plugins/emotions/images/emotions.gif | Bin 0 -> 1127 bytes .../plugins/emotions/images/readme.txt | 2 + .../plugins/emotions/images/smiley-cool.gif | Bin 0 -> 1135 bytes .../plugins/emotions/images/smiley-cry.gif | Bin 0 -> 1127 bytes .../emotions/images/smiley-embarassed.gif | Bin 0 -> 1134 bytes .../emotions/images/smiley-foot-in-mouth.gif | Bin 0 -> 1120 bytes .../plugins/emotions/images/smiley-frown.gif | Bin 0 -> 1116 bytes .../emotions/images/smiley-innocent.gif | Bin 0 -> 1139 bytes .../plugins/emotions/images/smiley-kiss.gif | Bin 0 -> 1129 bytes .../emotions/images/smiley-laughing.gif | Bin 0 -> 1122 bytes .../emotions/images/smiley-money-mouth.gif | Bin 0 -> 1112 bytes .../plugins/emotions/images/smiley-sealed.gif | Bin 0 -> 1110 bytes .../plugins/emotions/images/smiley-smile.gif | Bin 0 -> 1116 bytes .../emotions/images/smiley-surprised.gif | Bin 0 -> 1122 bytes .../emotions/images/smiley-tongue-out.gif | Bin 0 -> 1112 bytes .../emotions/images/smiley-undecided.gif | Bin 0 -> 1117 bytes .../plugins/emotions/images/smiley-wink.gif | Bin 0 -> 1124 bytes .../plugins/emotions/images/smiley-yell.gif | Bin 0 -> 1132 bytes .../tiny_mce/plugins/emotions/langs/cs.js | 4 + .../tiny_mce/plugins/emotions/langs/de.js | 6 + .../tiny_mce/plugins/emotions/langs/el.js | 5 + .../tiny_mce/plugins/emotions/langs/en.js | 5 + .../tiny_mce/plugins/emotions/langs/fa.js | 10 + .../tiny_mce/plugins/emotions/langs/fr.js | 5 + .../tiny_mce/plugins/emotions/langs/fr_ca.js | 5 + .../tiny_mce/plugins/emotions/langs/it.js | 5 + .../tiny_mce/plugins/emotions/langs/ko.js | 5 + .../tiny_mce/plugins/emotions/langs/sv.js | 4 + .../tiny_mce/plugins/emotions/langs/zh_cn.js | 5 + .../tiny_mce/plugins/emotions/readme.txt | 20 + .../tiny_mce/plugins/flash/editor_plugin.js | 2 + .../plugins/flash/editor_plugin_src.js | 213 + .../jscripts/tiny_mce/plugins/flash/flash.htm | 169 + .../tiny_mce/plugins/flash/images/flash.gif | Bin 0 -> 664 bytes .../tiny_mce/plugins/flash/langs/cs.js | 5 + .../tiny_mce/plugins/flash/langs/de.js | 6 + .../tiny_mce/plugins/flash/langs/en.js | 6 + .../tiny_mce/plugins/flash/langs/fa.js | 10 + .../tiny_mce/plugins/flash/langs/fr.js | 6 + .../tiny_mce/plugins/flash/langs/fr_ca.js | 5 + .../tiny_mce/plugins/flash/langs/sv.js | 6 + .../tiny_mce/plugins/flash/langs/zh_cn.js | 6 + .../tiny_mce/plugins/flash/readme.txt | 48 + .../tiny_mce/plugins/iespell/editor_plugin.js | 2 + .../plugins/iespell/editor_plugin_src.js | 37 + .../plugins/iespell/images/iespell.gif | Bin 0 -> 151 bytes .../tiny_mce/plugins/iespell/langs/cs.js | 4 + .../tiny_mce/plugins/iespell/langs/de.js | 4 + .../tiny_mce/plugins/iespell/langs/el.js | 4 + .../tiny_mce/plugins/iespell/langs/en.js | 4 + .../tiny_mce/plugins/iespell/langs/fr.js | 4 + .../tiny_mce/plugins/iespell/langs/fr_ca.js | 4 + .../tiny_mce/plugins/iespell/langs/it.js | 4 + .../tiny_mce/plugins/iespell/langs/ko.js | 4 + .../tiny_mce/plugins/iespell/langs/sv.js | 4 + .../tiny_mce/plugins/iespell/langs/zh_cn.js | 4 + .../tiny_mce/plugins/iespell/readme.txt | 20 + .../plugins/insertdatetime/editor_plugin.js | 2 + .../insertdatetime/editor_plugin_src.js | 66 + .../insertdatetime/images/insertdate.gif | Bin 0 -> 1031 bytes .../insertdatetime/images/inserttime.gif | Bin 0 -> 958 bytes .../plugins/insertdatetime/langs/cs.js | 4 + .../plugins/insertdatetime/langs/de.js | 4 + .../plugins/insertdatetime/langs/el.js | 4 + .../plugins/insertdatetime/langs/en.js | 4 + .../plugins/insertdatetime/langs/fa.js | 9 + .../plugins/insertdatetime/langs/fr.js | 4 + .../plugins/insertdatetime/langs/fr_ca.js | 4 + .../plugins/insertdatetime/langs/it.js | 4 + .../plugins/insertdatetime/langs/ko.js | 4 + .../plugins/insertdatetime/langs/sv.js | 4 + .../plugins/insertdatetime/langs/zh_cn.js | 4 + .../plugins/insertdatetime/readme.txt | 35 + .../tiny_mce/plugins/preview/editor_plugin.js | 2 + .../plugins/preview/editor_plugin_src.js | 61 + .../tiny_mce/plugins/preview/example.html | 14 + .../plugins/preview/images/preview.gif | Bin 0 -> 1024 bytes .../tiny_mce/plugins/preview/langs/cs.js | 3 + .../tiny_mce/plugins/preview/langs/de.js | 3 + .../tiny_mce/plugins/preview/langs/el.js | 3 + .../tiny_mce/plugins/preview/langs/en.js | 3 + .../tiny_mce/plugins/preview/langs/fa.js | 8 + .../tiny_mce/plugins/preview/langs/fr.js | 3 + .../tiny_mce/plugins/preview/langs/fr_ca.js | 3 + .../tiny_mce/plugins/preview/langs/it.js | 3 + .../tiny_mce/plugins/preview/langs/ko.js | 3 + .../tiny_mce/plugins/preview/langs/pt.js | 3 + .../tiny_mce/plugins/preview/langs/sv.js | 3 + .../tiny_mce/plugins/preview/langs/zh_cn.js | 3 + .../tiny_mce/plugins/preview/readme.txt | 23 + .../tiny_mce/plugins/print/editor_plugin.js | 2 + .../plugins/print/editor_plugin_src.js | 26 + .../tiny_mce/plugins/print/images/print.gif | Bin 0 -> 1013 bytes .../tiny_mce/plugins/print/langs/de.js | 3 + .../tiny_mce/plugins/print/langs/en.js | 3 + .../tiny_mce/plugins/print/langs/fa.js | 8 + .../tiny_mce/plugins/print/langs/fr.js | 3 + .../tiny_mce/plugins/print/langs/fr_ca.js | 3 + .../tiny_mce/plugins/print/langs/sv.js | 3 + .../tiny_mce/plugins/print/langs/zh_cn.js | 3 + .../tiny_mce/plugins/print/readme.txt | 17 + .../jscripts/tiny_mce/plugins/readme.txt | 1 + .../tiny_mce/plugins/save/editor_plugin.js | 2 + .../plugins/save/editor_plugin_src.js | 43 + .../tiny_mce/plugins/save/images/save.gif | Bin 0 -> 1001 bytes .../tiny_mce/plugins/save/langs/cs.js | 3 + .../tiny_mce/plugins/save/langs/de.js | 3 + .../tiny_mce/plugins/save/langs/en.js | 3 + .../tiny_mce/plugins/save/langs/fa.js | 8 + .../tiny_mce/plugins/save/langs/fr.js | 3 + .../tiny_mce/plugins/save/langs/fr_ca.js | 3 + .../tiny_mce/plugins/save/langs/zh_cn.js | 3 + .../jscripts/tiny_mce/plugins/save/readme.txt | 19 + .../plugins/searchreplace/editor_plugin.js | 2 + .../searchreplace/editor_plugin_src.js | 166 + .../plugins/searchreplace/images/replace.gif | Bin 0 -> 152 bytes .../plugins/searchreplace/images/search.gif | Bin 0 -> 990 bytes .../plugins/searchreplace/langs/de.js | 19 + .../plugins/searchreplace/langs/en.js | 19 + .../plugins/searchreplace/langs/fa.js | 24 + .../plugins/searchreplace/langs/fr.js | 19 + .../plugins/searchreplace/langs/fr_ca.js | 20 + .../plugins/searchreplace/langs/sv.js | 19 + .../plugins/searchreplace/langs/zh_cn.js | 19 + .../tiny_mce/plugins/searchreplace/readme.txt | 18 + .../plugins/searchreplace/replace.htm | 90 + .../tiny_mce/plugins/searchreplace/search.htm | 76 + .../jscripts/tiny_mce/plugins/table/cell.htm | 120 + .../tiny_mce/plugins/table/editor_plugin.js | 2 + .../plugins/table/editor_plugin_src.js | 472 ++ .../tiny_mce/plugins/table/images/buttons.gif | Bin 0 -> 1367 bytes .../tiny_mce/plugins/table/images/table.gif | Bin 0 -> 1018 bytes .../plugins/table/images/table_cell_props.gif | Bin 0 -> 369 bytes .../plugins/table/images/table_delete_col.gif | Bin 0 -> 929 bytes .../plugins/table/images/table_delete_row.gif | Bin 0 -> 942 bytes .../table/images/table_insert_col_after.gif | Bin 0 -> 936 bytes .../table/images/table_insert_col_before.gif | Bin 0 -> 935 bytes .../table/images/table_insert_row_after.gif | Bin 0 -> 928 bytes .../table/images/table_insert_row_before.gif | Bin 0 -> 928 bytes .../plugins/table/images/table_row_props.gif | Bin 0 -> 367 bytes .../tiny_mce/plugins/table/langs/ar.js | 30 + .../tiny_mce/plugins/table/langs/cs.js | 30 + .../tiny_mce/plugins/table/langs/da.js | 30 + .../tiny_mce/plugins/table/langs/de.js | 30 + .../tiny_mce/plugins/table/langs/el.js | 30 + .../tiny_mce/plugins/table/langs/en.js | 30 + .../tiny_mce/plugins/table/langs/es.js | 30 + .../tiny_mce/plugins/table/langs/fa.js | 34 + .../tiny_mce/plugins/table/langs/fi.js | 30 + .../tiny_mce/plugins/table/langs/fr.js | 30 + .../tiny_mce/plugins/table/langs/fr_ca.js | 30 + .../tiny_mce/plugins/table/langs/hu.js | 30 + .../tiny_mce/plugins/table/langs/it.js | 30 + .../tiny_mce/plugins/table/langs/ja.js | 30 + .../tiny_mce/plugins/table/langs/ko.js | 30 + .../tiny_mce/plugins/table/langs/nl.js | 30 + .../tiny_mce/plugins/table/langs/no.js | 30 + .../tiny_mce/plugins/table/langs/pl.js | 30 + .../tiny_mce/plugins/table/langs/pt.js | 30 + .../tiny_mce/plugins/table/langs/readme.txt | 4 + .../tiny_mce/plugins/table/langs/sv.js | 30 + .../tiny_mce/plugins/table/langs/tw.js | 30 + .../tiny_mce/plugins/table/langs/zh_cn.js | 30 + .../tiny_mce/plugins/table/readme.txt | 43 + .../jscripts/tiny_mce/plugins/table/row.htm | 118 + .../jscripts/tiny_mce/plugins/table/table.htm | 137 + .../tiny_mce/plugins/zoom/editor_plugin.js | 7 + .../plugins/zoom/editor_plugin_src.js | 38 + .../tiny_mce/plugins/zoom/langs/fa.js | 8 + .../tiny_mce/plugins/zoom/langs/fr_ca.js | 3 + .../jscripts/tiny_mce/plugins/zoom/readme.txt | 22 + .../tiny_mce/themes/advanced/anchor.htm | 46 + .../tiny_mce/themes/advanced/charmap.htm | 382 ++ .../tiny_mce/themes/advanced/color_picker.htm | 272 + .../themes/advanced/docs/en/about.htm | 32 + .../advanced/docs/en/common_buttons.htm | 163 + .../docs/en/images/insert_anchor_window.gif | Bin 0 -> 5189 bytes .../docs/en/images/insert_image_window.gif | Bin 0 -> 7195 bytes .../docs/en/images/insert_link_window.gif | Bin 0 -> 5658 bytes .../docs/en/images/insert_table_window.gif | Bin 0 -> 7094 bytes .../themes/advanced/docs/en/index.htm | 27 + .../advanced/docs/en/insert_anchor_button.htm | 33 + .../advanced/docs/en/insert_image_button.htm | 66 + .../advanced/docs/en/insert_link_button.htm | 34 + .../advanced/docs/en/insert_table_button.htm | 72 + .../themes/advanced/docs/en/style.css | 28 + .../themes/advanced/docs/images/table.gif | Bin 0 -> 1018 bytes .../advanced/docs/images/table_delete_col.gif | Bin 0 -> 929 bytes .../advanced/docs/images/table_delete_row.gif | Bin 0 -> 942 bytes .../docs/images/table_insert_col_after.gif | Bin 0 -> 936 bytes .../docs/images/table_insert_col_before.gif | Bin 0 -> 935 bytes .../docs/images/table_insert_row_after.gif | Bin 0 -> 928 bytes .../docs/images/table_insert_row_before.gif | Bin 0 -> 928 bytes .../themes/advanced/editor_content.css | 23 + .../tiny_mce/themes/advanced/editor_popup.css | 117 + .../themes/advanced/editor_template.js | 23 + .../themes/advanced/editor_template_src.js | 738 +++ .../tiny_mce/themes/advanced/editor_ui.css | 147 + .../tiny_mce/themes/advanced/image.htm | 175 + .../themes/advanced/images/anchor.gif | Bin 0 -> 943 bytes .../themes/advanced/images/backcolor.gif | Bin 0 -> 943 bytes .../tiny_mce/themes/advanced/images/bold.gif | Bin 0 -> 864 bytes .../themes/advanced/images/bold_de_se.gif | Bin 0 -> 79 bytes .../themes/advanced/images/bold_fr.gif | Bin 0 -> 78 bytes .../themes/advanced/images/bold_ru.gif | Bin 0 -> 77 bytes .../themes/advanced/images/browse.gif | Bin 0 -> 113 bytes .../themes/advanced/images/bullist.gif | Bin 0 -> 883 bytes .../themes/advanced/images/buttons.gif | Bin 0 -> 3889 bytes .../themes/advanced/images/center.gif | Bin 0 -> 855 bytes .../themes/advanced/images/charmap.gif | Bin 0 -> 958 bytes .../themes/advanced/images/cleanup.gif | Bin 0 -> 977 bytes .../tiny_mce/themes/advanced/images/code.gif | Bin 0 -> 110 bytes .../tiny_mce/themes/advanced/images/copy.gif | Bin 0 -> 987 bytes .../themes/advanced/images/custom_1.gif | Bin 0 -> 854 bytes .../tiny_mce/themes/advanced/images/cut.gif | Bin 0 -> 358 bytes .../themes/advanced/images/forecolor.gif | Bin 0 -> 981 bytes .../tiny_mce/themes/advanced/images/full.gif | Bin 0 -> 856 bytes .../tiny_mce/themes/advanced/images/help.gif | Bin 0 -> 1027 bytes .../tiny_mce/themes/advanced/images/hr.gif | Bin 0 -> 844 bytes .../tiny_mce/themes/advanced/images/image.gif | Bin 0 -> 194 bytes .../themes/advanced/images/indent.gif | Bin 0 -> 890 bytes .../themes/advanced/images/italic.gif | Bin 0 -> 860 bytes .../themes/advanced/images/italic_de_se.gif | Bin 0 -> 81 bytes .../themes/advanced/images/italic_ru.gif | Bin 0 -> 78 bytes .../tiny_mce/themes/advanced/images/left.gif | Bin 0 -> 856 bytes .../tiny_mce/themes/advanced/images/link.gif | Bin 0 -> 545 bytes .../themes/advanced/images/numlist.gif | Bin 0 -> 889 bytes .../themes/advanced/images/outdent.gif | Bin 0 -> 887 bytes .../tiny_mce/themes/advanced/images/paste.gif | Bin 0 -> 1022 bytes .../tiny_mce/themes/advanced/images/redo.gif | Bin 0 -> 942 bytes .../themes/advanced/images/removeformat.gif | Bin 0 -> 152 bytes .../tiny_mce/themes/advanced/images/right.gif | Bin 0 -> 855 bytes .../themes/advanced/images/spacer.gif | Bin 0 -> 43 bytes .../themes/advanced/images/strikethrough.gif | Bin 0 -> 873 bytes .../tiny_mce/themes/advanced/images/sub.gif | Bin 0 -> 900 bytes .../tiny_mce/themes/advanced/images/sup.gif | Bin 0 -> 906 bytes .../tiny_mce/themes/advanced/images/table.gif | Bin 0 -> 1018 bytes .../advanced/images/table_delete_col.gif | Bin 0 -> 929 bytes .../advanced/images/table_delete_row.gif | Bin 0 -> 942 bytes .../images/table_insert_col_after.gif | Bin 0 -> 936 bytes .../images/table_insert_col_before.gif | Bin 0 -> 935 bytes .../images/table_insert_row_after.gif | Bin 0 -> 928 bytes .../images/table_insert_row_before.gif | Bin 0 -> 928 bytes .../themes/advanced/images/underline.gif | Bin 0 -> 872 bytes .../themes/advanced/images/underline_fr.gif | Bin 0 -> 125 bytes .../themes/advanced/images/underline_ru.gif | Bin 0 -> 77 bytes .../tiny_mce/themes/advanced/images/undo.gif | Bin 0 -> 945 bytes .../themes/advanced/images/unlink.gif | Bin 0 -> 561 bytes .../themes/advanced/images/visualaid.gif | Bin 0 -> 1006 bytes .../tiny_mce/themes/advanced/langs/en.js | 57 + .../tiny_mce/themes/advanced/link.htm | 115 + .../themes/advanced/source_editor.htm | 90 + .../tinymce/jscripts/tiny_mce/tiny_mce.js | 9 + .../jscripts/tiny_mce/tiny_mce_popup.js | 56 + .../tinymce/jscripts/tiny_mce/tiny_mce_src.js | 4231 +++++++++++++++ includes/tinymce/lgpl.txt | 437 ++ index.php | 104 + install/config.inc | 64 + install/install.inc | 402 ++ install/install_db_core.inc | 486 ++ install/step1.php | 60 + install/step2.php | 51 + install/step3.php | 24 + install/template.inc | 71 + language/account/english_account.xml | 141 + .../account_admin/english_account_admin.xml | 151 + .../english_account_billing.xml | 65 + .../account_memo/english_account_memo.xml | 23 + language/affiliate/english_affiliate.xml | 90 + .../english_affiliate_commission.xml | 42 + .../english_affiliate_template.xml | 34 + language/asset/english_asset.xml | 32 + .../asset_invoice/english_asset_invoice.xml | 10 + language/asset_pool/english_asset_pool.xml | 17 + language/backup/english_backup.xml | 48 + .../blocked_email/english_blocked_email.xml | 20 + language/blocked_ip/english_blocked_ip.xml | 20 + language/campaign/english_campaign.xml | 65 + language/cart/english_cart.xml | 59 + language/charge/english_charge.xml | 27 + language/checkout/english_checkout.xml | 114 + language/core/english_core.xml | 183 + language/country/english_country.xml | 26 + language/currency/english_currency.xml | 24 + language/db_mapping/english_db_mapping.xml | 33 + language/discount/english_discount.xml | 45 + language/email_log/english_email_log.xml | 25 + language/email_queue/english_email_queue.xml | 34 + .../email_template/english_email_template.xml | 27 + .../english_email_template_translate.xml | 19 + language/faq/english_faq.xml | 47 + .../faq_category/english_faq_category.xml | 24 + .../faq_translate/english_faq_translate.xml | 35 + language/file/english_file.xml | 52 + .../file_category/english_file_category.xml | 27 + language/group/english_group.xml | 48 + .../english_host_provision_plugin.xml | 113 + .../english_host_registrar_plugin.xml | 63 + language/host_server/english_host_server.xml | 35 + language/host_tld/english_host_tld.xml | 74 + .../english_host_whois_plugin.xml | 7 + language/htaccess/english_htaccess.xml | 32 + .../htaccess_dir/english_htaccess_dir.xml | 46 + .../english_htaccess_exclude.xml | 15 + language/import/english_import.xml | 36 + language/invoice/english_invoice.xml | 146 + .../english_invoice_commission.xml | 4 + .../invoice_item/english_invoice_item.xml | 17 + .../invoice_memo/english_invoice_memo.xml | 29 + language/license/english_license.xml | 31 + language/log_error/english_log_error.xml | 19 + language/login_log/english_login_log.xml | 18 + language/module/english_module.xml | 65 + .../module_method/english_module_method.xml | 26 + language/net_term/english_net_term.xml | 21 + language/newsletter/english_newsletter.xml | 67 + .../english_newsletter_subscriber.xml | 22 + language/product/english_product.xml | 116 + .../product_attr/english_product_attr.xml | 22 + language/product_cat/english_product_cat.xml | 30 + .../english_product_cat_translate.xml | 17 + language/product_img/english_product_img.xml | 18 + .../english_product_translate.xml | 19 + language/radius/english_radius.xml | 47 + language/realestate/english_realestate.xml | 32 + language/report/english_report.xml | 35 + language/service/english_service.xml | 106 + .../service_memo/english_service_memo.xml | 23 + language/session/english_session.xml | 27 + language/setup/english_setup.xml | 106 + language/setup_email/english_setup_email.xml | 33 + .../setup_invoice/english_setup_invoice.xml | 59 + language/staff/english_staff.xml | 41 + .../english_staff_department.xml | 17 + language/static_page/english_static_page.xml | 32 + .../english_static_page_category.xml | 19 + .../english_static_page_translate.xml | 26 + .../english_static_relation.xml | 22 + language/static_var/english_static_var.xml | 49 + language/task/english_task.xml | 31 + language/task_log/english_task_log.xml | 19 + language/tax/english_tax.xml | 21 + .../temporary_data/english_temporary_data.xml | 4 + language/ticket/english_ticket.xml | 100 + .../english_ticket_department.xml | 21 + .../ticket_message/english_ticket_message.xml | 19 + language/voip/english_voip.xml | 76 + .../voip_blacklist/english_voip_blacklist.xml | 16 + language/voip_cdr/english_voip_cdr.xml | 33 + language/voip_did/english_voip_did.xml | 50 + .../english_voip_did_plugin.xml | 28 + language/voip_fax/english_voip_fax.xml | 25 + language/voip_pool/english_voip_pool.xml | 25 + .../voip_prepaid/english_voip_prepaid.xml | 25 + language/voip_rate/english_voip_rate.xml | 42 + .../voip_rate_prod/english_voip_rate_prod.xml | 11 + language/voip_vm/english_voip_vm.xml | 28 + modules/account/account.inc.php | 1335 +++++ modules/account/account_construct.xml | 193 + modules/account/account_install.xml | 14 + modules/account/account_install_data.xml | 33 + modules/account/account_xmlrpc.php | 155 + modules/account/auth.inc.php | 38 + modules/account_admin/account_admin.inc.php | 2651 ++++++++++ .../account_admin/account_admin_construct.xml | 180 + .../account_admin/account_admin_install.xml | 77 + .../account_billing/account_billing.inc.php | 411 ++ .../account_billing_construct.xml | 158 + .../account_billing_install.xml | 34 + modules/account_billing/auth.inc.php | 30 + .../account_group/account_group_construct.xml | 55 + .../account_group/account_group_install.xml | 11 + .../account_group_install_data.xml | 44 + modules/account_memo/account_memo.inc.php | 125 + .../account_memo/account_memo_construct.xml | 63 + modules/account_memo/account_memo_install.xml | 33 + .../account_message/account_message.inc.php | 54 + .../account_message_construct.xml | 35 + .../account_message_install.xml | 17 + .../account_message_install_data.xml | 13 + modules/account_message/auth.inc.php | 25 + .../account_password_history.inc.php | 104 + .../account_password_history_construct.xml | 37 + .../account_password_history_install.xml | 12 + modules/affiliate/affiliate.inc.php | 1806 +++++++ modules/affiliate/affiliate_construct.xml | 104 + modules/affiliate/affiliate_install.xml | 49 + modules/affiliate/auth.inc.php | 28 + .../affiliate_commission.inc.php | 531 ++ .../affiliate_commission_construct.xml | 66 + .../affiliate_commission_install.xml | 41 + .../affiliate_template.inc.php | 125 + .../affiliate_template_construct.xml | 85 + .../affiliate_template_install.xml | 35 + .../affiliate_template_install_data.xml | 21 + modules/asset/asset.inc.php | 182 + modules/asset/asset_construct.xml | 64 + modules/asset/asset_install.xml | 47 + modules/asset/generator.php | 49 + modules/asset_invoice/asset_invoice.inc.php | 209 + .../asset_invoice/asset_invoice_construct.xml | 21 + .../asset_invoice/asset_invoice_install.xml | 27 + modules/asset_invoice/auth.inc.php | 27 + modules/asset_pool/asset_pool.inc.php | 91 + modules/asset_pool/asset_pool_construct.xml | 33 + modules/asset_pool/asset_pool_install.xml | 38 + modules/blocked_email/blocked_email.inc.php | 146 + .../blocked_email/blocked_email_construct.xml | 59 + .../blocked_email/blocked_email_install.xml | 42 + modules/blocked_ip/blocked_ip.inc.php | 146 + modules/blocked_ip/blocked_ip_construct.xml | 57 + modules/blocked_ip/blocked_ip_install.xml | 42 + modules/campaign/auth.inc.php | 27 + modules/campaign/campaign.inc.php | 701 +++ modules/campaign/campaign_construct.xml | 233 + modules/campaign/campaign_install.xml | 60 + modules/campaign/index.php | 97 + modules/cart/auth.inc.php | 29 + modules/cart/cart.inc.php | 717 +++ modules/cart/cart_construct.xml | 107 + modules/cart/cart_install.xml | 23 + modules/charge/charge.inc.php | 1115 ++++ modules/charge/charge_construct.xml | 88 + modules/charge/charge_install.xml | 62 + modules/charge/xmlrpc.php | 84 + modules/checkout/auth.inc.php | 9 + .../checkout/base_checkout_plugin.class.php | 430 ++ modules/checkout/checkout.inc.php | 905 ++++ modules/checkout/checkout_admin.inc.php | 64 + modules/checkout/checkout_construct.xml | 140 + modules/checkout/checkout_install.xml | 45 + modules/checkout/checkout_install_data.xml | 956 ++++ modules/core/auth.inc.php | 286 + modules/core/auth_generate_admin_menu.inc.php | 174 + modules/core/calendar.inc.php | 194 + modules/core/core.inc.php | 444 ++ modules/core/crypt.inc.php | 251 + modules/core/database.inc.php | 262 + modules/core/database_add.inc.php | 216 + modules/core/database_delete.inc.php | 69 + modules/core/database_join_fields.inc.php | 94 + modules/core/database_mass_delete.inc.php | 141 + modules/core/database_search.inc.php | 316 ++ modules/core/database_search_form.inc.php | 69 + modules/core/database_search_show.inc.php | 252 + modules/core/database_update.inc.php | 226 + modules/core/database_view.inc.php | 170 + modules/core/easyadmin.inc.php | 345 ++ modules/core/email.inc.php | 249 + modules/core/email_piping.inc.php | 270 + modules/core/export.inc.php | 1213 +++++ modules/core/file_extensions.inc.php | 66 + modules/core/fpdf.inc.php | 219 + modules/core/ftp.inc.php | 171 + modules/core/graph.inc.php | 405 ++ modules/core/helm.inc.php | 219 + modules/core/import.inc.php | 345 ++ modules/core/list.inc.php | 423 ++ modules/core/list_calendar.inc.php | 71 + modules/core/list_card_type_menu.inc.php | 65 + modules/core/list_check.inc.php | 81 + modules/core/list_currency.inc.php | 72 + modules/core/list_menu_files.inc.php | 79 + modules/core/list_menu_multi.inc.php | 67 + modules/core/list_menu_theme.inc.php | 85 + modules/core/list_radio.inc.php | 57 + modules/core/list_select_groups.inc.php | 180 + modules/core/list_setup_default_date.inc.php | 82 + modules/core/login.inc.php | 357 ++ modules/core/method.inc.php | 193 + modules/core/method_ajax.inc.php | 84 + modules/core/post.inc.php | 67 + modules/core/search.inc.php | 653 +++ modules/core/service_domain.inc.php | 83 + modules/core/service_group.inc.php | 268 + modules/core/session.inc.php | 413 ++ modules/core/setup.inc.php | 169 + modules/core/sort_array.inc.php | 89 + modules/core/ssl.inc.php | 186 + modules/core/static_var.inc.php | 1448 ++++++ modules/core/theme.inc.php | 180 + modules/core/translate.inc.php | 96 + modules/core/trigger.inc.php | 58 + modules/core/validate.inc.php | 757 +++ modules/core/vars.inc.php | 95 + modules/core/version.inc.php | 76 + modules/core/weblog.inc.php | 226 + modules/core/webmin.inc.php | 228 + modules/core/xml.inc.php | 271 + modules/country/country.inc.php | 126 + modules/country/country_construct.xml | 65 + modules/country/country_install.xml | 37 + modules/country/country_install_data.xml | 1681 ++++++ modules/currency/currency.inc.php | 128 + modules/currency/currency_construct.xml | 68 + modules/currency/currency_install.xml | 36 + modules/currency/currency_install_data.xml | 128 + modules/db_mapping/db_mapping.inc.php | 2079 ++++++++ modules/db_mapping/db_mapping_construct.xml | 90 + modules/db_mapping/db_mapping_install.xml | 35 + modules/discount/auth.inc.php | 10 + modules/discount/discount.inc.php | 480 ++ modules/discount/discount_construct.xml | 120 + modules/discount/discount_install.xml | 39 + modules/email_log/auth.inc.php | 7 + modules/email_log/email_log.inc.php | 118 + modules/email_log/email_log_construct.xml | 55 + modules/email_log/email_log_install.xml | 34 + modules/email_queue/email_queue.inc.php | 189 + modules/email_queue/email_queue_construct.xml | 78 + modules/email_queue/email_queue_install.xml | 22 + modules/email_template/email_template.inc.php | 527 ++ .../email_template_construct.xml | 74 + .../email_template/email_template_install.xml | 35 + .../email_template_install_data.xml | 611 +++ .../email_template_translate.inc.php | 125 + .../email_template_translate_construct.xml | 64 + .../email_template_translate_install.xml | 34 + .../email_template_translate_install_data.xml | 2969 +++++++++++ modules/faq/auth.inc.php | 12 + modules/faq/faq.inc.php | 318 ++ modules/faq/faq_construct.xml | 78 + modules/faq/faq_install.xml | 49 + modules/faq_category/auth.inc.php | 9 + modules/faq_category/faq_category.inc.php | 208 + .../faq_category/faq_category_construct.xml | 69 + modules/faq_category/faq_category_install.xml | 41 + modules/faq_translate/faq_translate.inc.php | 127 + .../faq_translate/faq_translate_construct.xml | 77 + .../faq_translate/faq_translate_install.xml | 34 + modules/file/auth.inc.php | 11 + modules/file/file.inc.php | 492 ++ modules/file/file_construct.xml | 100 + modules/file/file_install.xml | 50 + modules/file/file_install_data.xml | 3 + modules/file_category/file_category.inc.php | 123 + .../file_category/file_category_construct.xml | 71 + .../file_category/file_category_install.xml | 44 + .../file_category_install_data.xml | 26 + modules/group/group.inc.php | 329 ++ modules/group/group_construct.xml | 72 + modules/group/group_install.xml | 40 + modules/group/group_install_data.xml | 51 + .../group_method/group_method_construct.xml | 60 + modules/group_method/group_method_install.xml | 29 + .../host_registrar_plugin.inc.php | 239 + .../host_registrar_plugin_construct.xml | 59 + .../host_registrar_plugin_install.xml | 35 + .../host_registrar_plugin_install_data.xml | 14 + modules/host_server/host_server.inc.php | 311 ++ modules/host_server/host_server_construct.xml | 96 + modules/host_server/host_server_install.xml | 40 + modules/host_tld/auth.inc.php | 8 + modules/host_tld/host_tld.inc.php | 416 ++ modules/host_tld/host_tld_construct.xml | 84 + modules/host_tld/host_tld_install.xml | 37 + modules/host_tld/host_tld_install_data.xml | 48 + modules/htaccess/auth.inc.php | 10 + modules/htaccess/htaccess.inc.php | 362 ++ modules/htaccess/htaccess_construct.xml | 70 + modules/htaccess/htaccess_install.xml | 37 + modules/htaccess/mod_auth_remote.inc.php | 103 + modules/htaccess_dir/htaccess_dir.inc.php | 472 ++ .../htaccess_dir/htaccess_dir_construct.xml | 114 + modules/htaccess_dir/htaccess_dir_install.xml | 33 + .../htaccess_exclude/htaccess_exclude.inc.php | 126 + .../htaccess_exclude_construct.xml | 49 + .../htaccess_exclude_install.xml | 36 + .../htaccess_exclude_install_data.xml | 153 + modules/import/import.inc.php | 301 ++ modules/import/import_construct.xml | 65 + modules/import/import_install.xml | 43 + modules/invoice/advance_notice.php | 109 + modules/invoice/auth.inc.php | 13 + modules/invoice/invoice.inc.php | 4376 ++++++++++++++++ modules/invoice/invoice_construct.xml | 182 + modules/invoice/invoice_fpdf.inc.php | 393 ++ modules/invoice/invoice_install.xml | 65 + modules/invoice/receipt_print.php | 93 + .../invoice_commission.inc.php | 47 + .../invoice_commission_construct.xml | 60 + .../invoice_commission_install.xml | 12 + modules/invoice_item/invoice_item.inc.php | 126 + .../invoice_item/invoice_item_construct.xml | 130 + modules/invoice_item/invoice_item_install.xml | 12 + .../invoice_item_discount.inc.php | 5 + .../invoice_item_discount_construct.xml | 45 + .../invoice_item_discount_install.xml | 13 + .../invoice_item_tax/invoice_item_tax.inc.php | 5 + .../invoice_item_tax_construct.xml | 45 + .../invoice_item_tax_install.xml | 13 + modules/invoice_memo/invoice_memo.inc.php | 126 + .../invoice_memo/invoice_memo_construct.xml | 63 + modules/invoice_memo/invoice_memo_install.xml | 35 + modules/log_error/log_error.inc.php | 167 + modules/log_error/log_error_construct.xml | 55 + modules/log_error/log_error_install.xml | 37 + modules/login_lock/login_lock_construct.xml | 49 + modules/login_lock/login_lock_install.xml | 11 + modules/login_log/login_log.inc.php | 169 + modules/login_log/login_log_construct.xml | 56 + modules/login_log/login_log_install.xml | 32 + modules/login_share/login_share.inc.php | 148 + modules/login_share/login_share_construct.xml | 46 + modules/login_share/login_share_install.xml | 12 + modules/module/dev.inc.php | 1441 ++++++ modules/module/module.inc.php | 1524 ++++++ modules/module/module_construct.xml | 79 + modules/module/module_install.xml | 63 + modules/module_method/module_method.inc.php | 366 ++ .../module_method/module_method_construct.xml | 66 + .../module_method/module_method_install.xml | 40 + modules/net_term/net_term.inc.php | 245 + modules/net_term/net_term_construct.xml | 70 + modules/net_term/net_term_install.xml | 37 + modules/newsletter/auth.inc.php | 14 + modules/newsletter/newsletter.inc.php | 912 ++++ modules/newsletter/newsletter_construct.xml | 60 + modules/newsletter/newsletter_install.xml | 48 + .../newsletter/newsletter_install_data.xml | 15 + modules/newsletter_subscriber/auth.inc.php | 9 + .../newsletter_subscriber.inc.php | 726 +++ .../newsletter_subscriber_construct.xml | 65 + .../newsletter_subscriber_install.xml | 54 + modules/product/auth.inc.php | 9 + modules/product/base_product_plugin.inc.php | 128 + modules/product/product.inc.php | 720 +++ modules/product/product_construct.xml | 204 + modules/product/product_install.xml | 45 + modules/product/product_install_data.xml | 26 + modules/product_attr/product_attr.inc.php | 125 + .../product_attr/product_attr_construct.xml | 80 + modules/product_attr/product_attr_install.xml | 30 + modules/product_cat/product_cat.inc.php | 612 +++ modules/product_cat/product_cat_construct.xml | 77 + modules/product_cat/product_cat_install.xml | 40 + .../product_cat/product_cat_install_data.xml | 18 + .../product_cat_translate.inc.php | 126 + .../product_cat_translate_construct.xml | 57 + .../product_cat_translate_install.xml | 32 + .../product_cat_translate_install_data.xml | 32 + modules/product_img/product_img.inc.php | 195 + modules/product_img/product_img_construct.xml | 53 + modules/product_img/product_img_install.xml | 30 + .../product_translate.inc.php | 125 + .../product_translate_construct.xml | 69 + .../product_translate_install.xml | 30 + .../product_translate_install_data.xml | 16 + modules/radius/auth.inc.php | 7 + modules/radius/radius.inc.php | 418 ++ modules/radius/radius_construct.xml | 113 + modules/radius/radius_install.xml | 74 + modules/radius_service/radius_service.inc.php | 5 + .../radius_service_construct.xml | 33 + .../radius_service/radius_service_install.xml | 15 + modules/report/class.Level.php | 1060 ++++ modules/report/class.Report.php | 681 +++ modules/report/class.ReportParser.php | 420 ++ modules/report/report.inc.php | 310 ++ modules/report/report_construct.xml | 63 + modules/report/report_install.xml | 27 + modules/report/test.php | 56 + modules/search/search_construct.xml | 65 + modules/search/search_install.xml | 11 + modules/search/search_install_data.xml | 58 + modules/search_saved/search_saved_install.xml | 11 + modules/service/auth.inc.php | 16 + modules/service/service.inc.php | 1892 +++++++ modules/service/service_construct.xml | 214 + modules/service/service_install.xml | 60 + modules/service_memo/service_memo.inc.php | 125 + .../service_memo/service_memo_construct.xml | 63 + modules/service_memo/service_memo_install.xml | 33 + modules/session/session.inc.php | 144 + modules/session/session_construct.xml | 95 + modules/session/session_install.xml | 35 + .../session_auth_cache.inc.php | 9 + .../session_auth_cache_construct.xml | 54 + .../session_auth_cache_install.xml | 11 + modules/setup/setup.inc.php | 152 + modules/setup/setup_construct.xml | 266 + modules/setup/setup_install.xml | 31 + modules/setup/setup_install_data.xml | 64 + modules/setup_email/setup_email.inc.php | 125 + modules/setup_email/setup_email_construct.xml | 95 + modules/setup_email/setup_email_install.xml | 36 + .../setup_email/setup_email_install_data.xml | 16 + modules/setup_invoice/setup_invoice.inc.php | 71 + .../setup_invoice/setup_invoice_construct.xml | 84 + .../setup_invoice/setup_invoice_install.xml | 26 + .../setup_invoice_install_data.xml | 22 + modules/staff/auth.inc.php | 10 + modules/staff/staff.inc.php | 374 ++ modules/staff/staff_construct.xml | 69 + modules/staff/staff_install.xml | 38 + modules/staff/staff_install_data.xml | 16 + .../staff_department/staff_department.inc.php | 125 + .../staff_department_construct.xml | 54 + .../staff_department_install.xml | 33 + .../staff_department_install_data.xml | 14 + modules/static_page/auth.inc.php | 12 + modules/static_page/static_page.inc.php | 423 ++ modules/static_page/static_page_construct.xml | 82 + modules/static_page/static_page_install.xml | 43 + modules/static_page_category/auth.inc.php | 9 + .../static_page_category.inc.php | 199 + .../static_page_category_construct.xml | 68 + .../static_page_category_install.xml | 36 + .../static_page_category_install_data.xml | 15 + .../static_page_translate.inc.php | 125 + .../static_page_translate_construct.xml | 78 + .../static_page_translate_install.xml | 29 + .../static_relation/static_relation.inc.php | 128 + .../static_relation_construct.xml | 70 + .../static_relation_install.xml | 31 + modules/static_var/static_var.inc.php | 132 + modules/static_var/static_var_construct.xml | 64 + modules/static_var/static_var_install.xml | 36 + .../static_var/static_var_install_data.xml | 60 + .../static_var_record.inc.php | 47 + .../static_var_record_construct.xml | 54 + .../static_var_record_install.xml | 11 + modules/task/task.inc.php | 307 ++ modules/task/task_construct.xml | 108 + modules/task/task_install.xml | 36 + modules/task/task_install_data.xml | 292 ++ modules/task_log/task_log.inc.php | 126 + modules/task_log/task_log_construct.xml | 56 + modules/task_log/task_log_install.xml | 32 + modules/tax/tax.inc.php | 174 + modules/tax/tax_construct.xml | 82 + modules/tax/tax_install.xml | 40 + modules/temporary_data/temporary_data.inc.php | 47 + .../temporary_data_construct.xml | 53 + .../temporary_data/temporary_data_install.xml | 11 + modules/ticket/auth.inc.php | 15 + modules/ticket/ticket.inc.php | 2711 ++++++++++ modules/ticket/ticket_construct.xml | 98 + modules/ticket/ticket_install.xml | 62 + modules/ticket_attachment/auth.inc.php | 6 + .../ticket_attachment.inc.php | 56 + .../ticket_attachment_construct.xml | 43 + .../ticket_attachment_install.xml | 11 + .../ticket_department.inc.php | 126 + .../ticket_department_construct.xml | 74 + .../ticket_department_install.xml | 36 + .../ticket_department_install_data.xml | 28 + modules/ticket_message/ticket_message.inc.php | 166 + .../ticket_message_construct.xml | 46 + .../ticket_message/ticket_message_install.xml | 30 + .../ticket_message_install_data.xml | 153 + modules/voip/auth.inc.php | 12 + modules/voip/base_voip_plugin.inc.php | 179 + modules/voip/memory_report.inc.php | 134 + modules/voip/voip.inc.php | 2142 ++++++++ modules/voip/voip_construct.xml | 55 + modules/voip/voip_install.xml | 19 + modules/voip_blacklist/auth.inc.php | 12 + modules/voip_blacklist/voip_blacklist.inc.php | 215 + .../voip_blacklist_construct.xml | 43 + .../voip_blacklist/voip_blacklist_install.xml | 42 + modules/voip_cdr/auth.inc.php | 6 + modules/voip_cdr/voip_cdr.inc.php | 174 + modules/voip_cdr/voip_cdr_construct.xml | 106 + modules/voip_cdr/voip_cdr_install.xml | 55 + modules/voip_did/voip_did.inc.php | 264 + modules/voip_did/voip_did_construct.xml | 125 + modules/voip_did/voip_did_install.xml | 62 + .../voip_did_plugin/voip_did_plugin.inc.php | 266 + .../voip_did_plugin_construct.xml | 47 + .../voip_did_plugin_install.xml | 42 + .../voip_did_plugin_install_data.xml | 34 + modules/voip_fax/auth.inc.php | 12 + modules/voip_fax/voip_fax.inc.php | 192 + modules/voip_fax/voip_fax_construct.xml | 68 + modules/voip_fax/voip_fax_install.xml | 37 + modules/voip_fax_data/voip_fax_data.inc.php | 6 + .../voip_fax_data/voip_fax_data_construct.xml | 29 + .../voip_fax_data/voip_fax_data_install.xml | 15 + modules/voip_iax/voip_iax.inc.php | 5 + modules/voip_iax/voip_iax_construct.xml | 34 + modules/voip_iax/voip_iax_install.xml | 15 + .../voip_in_network/voip_in_network.inc.php | 6 + .../voip_in_network_construct.xml | 26 + .../voip_in_network_install.xml | 15 + .../voip_local_lookup.inc.php | 5 + .../voip_local_lookup_construct.xml | 32 + .../voip_local_lookup_install.xml | 15 + modules/voip_pool/voip_pool.inc.php | 266 + modules/voip_pool/voip_pool_construct.xml | 68 + modules/voip_pool/voip_pool_install.xml | 54 + modules/voip_prepaid/auth.inc.php | 6 + modules/voip_prepaid/voip_prepaid.inc.php | 517 ++ .../voip_prepaid/voip_prepaid_construct.xml | 79 + modules/voip_prepaid/voip_prepaid_install.xml | 65 + modules/voip_rate/voip_rate.inc.php | 215 + modules/voip_rate/voip_rate_construct.xml | 75 + modules/voip_rate/voip_rate_install.xml | 46 + modules/voip_rate_prod/voip_rate_prod.inc.php | 133 + .../voip_rate_prod_construct.xml | 42 + .../voip_rate_prod/voip_rate_prod_install.xml | 31 + modules/voip_sip/voip_sip.inc.php | 5 + modules/voip_sip/voip_sip_construct.xml | 34 + modules/voip_sip/voip_sip_install.xml | 15 + modules/voip_vm/auth.inc.php | 11 + modules/voip_vm/voip_vm.inc.php | 252 + modules/voip_vm/voip_vm_construct.xml | 59 + modules/voip_vm/voip_vm_install.xml | 42 + ms_task.bat | 10 + nix_task.sh | 8 + plugins/affiliate/ACCOUNT_DISCOUNT.php | 96 + plugins/affiliate/MAIL_CHECK.php | 108 + plugins/affiliate/MONEYBOOKERS.php | 88 + plugins/affiliate/PAYPAL.php | 89 + plugins/checkout/2CHECKOUT.php | 177 + plugins/checkout/2CHECKOUT_V2.php | 190 + plugins/checkout/ACHCOMMERCE.php | 172 + plugins/checkout/ANYPAY.php | 85 + plugins/checkout/AUTHORIZE_NET.php | 178 + plugins/checkout/BLUEPAY.php | 142 + plugins/checkout/CLASS_ECHO/LICENSE.txt | 259 + plugins/checkout/CLASS_ECHO/README.txt | 199 + plugins/checkout/CLASS_ECHO/WHATSNEW.txt | 50 + plugins/checkout/CLASS_ECHO/echophp.class | 989 ++++ plugins/checkout/CLASS_LINKPOINT/LEULA_v3.pdf | Bin 0 -> 35059 bytes plugins/checkout/CLASS_LINKPOINT/lphp.php | 774 +++ plugins/checkout/CLASS_MONERIS/mpgClasses.php | 744 +++ plugins/checkout/CLASS_SKIPJACK/skipjack.php | 502 ++ plugins/checkout/COMMERCEPAYMENTWINDOW.php | 146 + plugins/checkout/CROWNE_GOLD.php | 162 + plugins/checkout/CYBERSOURCE.php | 274 + plugins/checkout/DPILINK.php | 129 + plugins/checkout/ECHO.php | 155 + plugins/checkout/ECX_QUICKCOMMERCE.php | 179 + plugins/checkout/EFT_MANUAL.php | 81 + plugins/checkout/EFT_SECURE.php | 128 + plugins/checkout/EGOLD.php | 175 + plugins/checkout/EPDQ.php | 231 + plugins/checkout/EPROCESSING_NETWORK.php | 178 + plugins/checkout/EWAY.php | 141 + plugins/checkout/FREE.php | 65 + plugins/checkout/GOEMERCHANT.php | 167 + plugins/checkout/GOLDMONEY.php | 175 + plugins/checkout/IBILL.php | 141 + plugins/checkout/IKOBO.php | 170 + plugins/checkout/INTERNETSECURE.php | 173 + plugins/checkout/LINKPOINT.php | 125 + plugins/checkout/MANUAL.php | 80 + plugins/checkout/MONERIS_ESELECT.php | 195 + plugins/checkout/MONEYBOOKERS.php | 161 + plugins/checkout/MONEYBOOKERS_RECURRING.php | 225 + plugins/checkout/NETBILLING.php | 136 + plugins/checkout/NETPAYMENTS.php | 158 + plugins/checkout/NOCHEXS.php | 174 + plugins/checkout/OPTIMALPAYMENTS.php | 189 + plugins/checkout/PAYBYCHECK_BASIC.php | 86 + plugins/checkout/PAYFUSE.php | 195 + plugins/checkout/PAYMATE.php | 147 + plugins/checkout/PAYPAL.php | 180 + plugins/checkout/PAYPAL_RECURRING.php | 308 ++ plugins/checkout/PAYSWISS.php | 91 + plugins/checkout/PAYSWISS_RECURRING.php | 115 + plugins/checkout/PAYSYSTEMS_CHECK.php | 148 + plugins/checkout/PAYSYSTEMS_CHECK_RECUR.php | 187 + plugins/checkout/PAYSYSTEMS_PRO.php | 150 + plugins/checkout/PAYSYSTEMS_RECURRING.php | 184 + plugins/checkout/PLANETPAYMENT.php | 182 + plugins/checkout/PLUGNPAY.php | 142 + plugins/checkout/PROTX.php | 150 + plugins/checkout/PSIGATE.php | 124 + plugins/checkout/REMIT_BANK_WIRE.php | 66 + plugins/checkout/REMIT_CHECK.php | 66 + plugins/checkout/RTWARE.php | 180 + plugins/checkout/SECPAY.php | 149 + plugins/checkout/SKIPJACK.php | 141 + plugins/checkout/STORMPAY.php | 160 + plugins/checkout/STORMPAY_RECURRING.php | 194 + plugins/checkout/SUREPAY.php | 144 + plugins/checkout/SWREG_ADVANCED.php | 208 + plugins/checkout/SWREG_INTERMEDIATE.php | 84 + plugins/checkout/TRUSTCOMMERCE.php | 151 + plugins/checkout/USA_EPAY.php | 609 +++ plugins/checkout/VERISIGN_PFPRO.php | 137 + plugins/checkout/WORLDPAY.php | 164 + plugins/checkout/WORLDPAY_FUTUREPAY.php | 241 + plugins/db_mapping/Apache_mod_auth_mysql.php | 380 ++ .../Apache_mod_auth_mysql_group.php | 380 ++ plugins/db_mapping/Drupal_431.php | 299 ++ plugins/db_mapping/Expression_Engine_1_1.php | 341 ++ plugins/db_mapping/FlySpray_95.php | 349 ++ plugins/db_mapping/GeekLog_138.php | 277 + plugins/db_mapping/HiveMail_122.php | 360 ++ .../db_mapping/Invision_Power_Board_13.php | 853 +++ plugins/db_mapping/Invision_Power_Board_2.php | 479 ++ plugins/db_mapping/Mambo_4O14.php | 322 ++ plugins/db_mapping/Mambo_4_5.php | 468 ++ plugins/db_mapping/Mantis_18rc1.php | 321 ++ plugins/db_mapping/PostNuke_726.php | 316 ++ plugins/db_mapping/SMF_101.php | 603 +++ plugins/db_mapping/SMF_102.php | 483 ++ plugins/db_mapping/SendStudio_2004.php | 396 ++ plugins/db_mapping/Support_Logic_111.php | 571 ++ plugins/db_mapping/WowBB_162.php | 350 ++ plugins/db_mapping/XMB_Forums_19.php | 299 ++ plugins/db_mapping/Xaraya_914.php | 349 ++ plugins/db_mapping/Xoops_2.php | 318 ++ plugins/db_mapping/YabbSe_151.php | 295 ++ plugins/db_mapping/miniBB_17.php | 284 + plugins/db_mapping/osCommerce_22.php | 303 ++ plugins/db_mapping/osCommerce_22/notes.txt | 4 + .../osCommerce_22/password_funcs.php | 39 + plugins/db_mapping/pMachine_Pro_21.php | 286 + plugins/db_mapping/phorum_345.php | 304 ++ plugins/db_mapping/phpBB_2O6.php | 334 ++ plugins/db_mapping/phpNuke_69.php | 286 + plugins/db_mapping/punBB_101.php | 322 ++ plugins/db_mapping/vBulletin_229.php | 313 ++ plugins/db_mapping/vBulletin_3.php | 532 ++ plugins/db_mapping/xcart_gold_351.php | 306 ++ plugins/discount/test.php | 51 + plugins/import/Amember_2_3_6.php | 805 +++ plugins/import/DreamAccount.php | 1351 +++++ plugins/import/HostAdmin.php | 1285 +++++ plugins/import/ModernBill.php | 1348 +++++ plugins/import/WHM_AutoPilot.php | 790 +++ plugins/import/WhoisCart.php | 1196 +++++ plugins/product/ASSET.php | 95 + plugins/product/EXAMPLE.php | 91 + plugins/product/PREPAID.php | 154 + plugins/product/RADIUS.php | 99 + plugins/product/VOIP.php | 949 ++++ plugins/provision/DIRECTADMIN_1_23.php | 302 ++ plugins/provision/EASYADMIN.php | 297 ++ plugins/provision/ENSIM_LINUX_3.php | 287 ++ plugins/provision/ENSIM_LINUX_3_5.php | 445 ++ plugins/provision/ENSIM_LINUX_PLAN_3_5.php | 307 ++ plugins/provision/ENSIM_WINDOWS_3.php | 468 ++ plugins/provision/ENSIM_WINDOWS_3_5.php | 445 ++ plugins/provision/HEARTINTERNET.php | 216 + plugins/provision/HELM_3_1.php | 219 + plugins/provision/HOSTOPIA.php | 268 + plugins/provision/INTERWORX_CP_1_8.php | 168 + plugins/provision/MANUAL.php | 202 + plugins/provision/PLESK_LINUX_6.php | 470 ++ plugins/provision/PLESK_LINUX_7.php | 482 ++ plugins/provision/PLESK_RELOADED_7_5.php | 938 ++++ plugins/provision/PLESK_WINDOWS_6_5.php | 473 ++ plugins/provision/PLESK_WINDOWS_7.php | 483 ++ plugins/provision/PSA_RESELL_7_5.php | 762 +++ plugins/provision/RAQ_550.php | 329 ++ plugins/provision/WEBMIN.php | 270 + plugins/provision/WEBMIN_PRO.php | 307 ++ plugins/provision/WHM.php | 269 + plugins/provision/_rrad/RRAD.php | 259 + .../provision/_rrad/RRADCommonIncludes.php | 16 + plugins/provision/_rrad/RRADCoreIncludes.php | 14 + plugins/provision/_rrad/hAdminInfo.php | 28 + plugins/provision/_rrad/hAdminService.php | 34 + plugins/provision/_rrad/hAuthCommand.php | 27 + plugins/provision/_rrad/hCloseCommand.php | 11 + plugins/provision/_rrad/hCommand.php | 25 + plugins/provision/_rrad/hContactInfo.php | 31 + .../provision/_rrad/hConvenienceService.php | 85 + plugins/provision/_rrad/hDomain.php | 17 + plugins/provision/_rrad/hInfo.php | 66 + plugins/provision/_rrad/hInfoService.php | 73 + plugins/provision/_rrad/hMailService.php | 10 + plugins/provision/_rrad/hService.php | 11 + plugins/provision/_rrad/hServiceInfo.php | 10 + plugins/provision/_rrad/hUsageInfo.php | 29 + plugins/provision/_rrad/hWebService.php | 82 + plugins/registrar/BULKREGISTER.php | 240 + plugins/registrar/DIRECTI.php | 150 + plugins/registrar/ENOM.php | 155 + plugins/registrar/GODADDY.php | 41 + plugins/registrar/MANUAL.php | 163 + plugins/registrar/MELBOURNEIT.php | 1148 +++++ plugins/registrar/NOMINET.php | 194 + plugins/registrar/ONLINENIC.php | 364 ++ plugins/registrar/OPENSRS.php | 290 ++ plugins/registrar/PLANETDOMAIN.php | 265 + plugins/registrar/TOTALREGISTRATIONS.php | 257 + plugins/registrar/_NAMES4EVER.php | 172 + plugins/registrar/_directi/config.php | 13 + plugins/registrar/_directi/customer.class.php | 243 + .../registrar/_directi/domcontact.class.php | 266 + plugins/registrar/_directi/domorder.class.php | 676 +++ .../registrar/_directi/domuscontact.class.php | 82 + plugins/registrar/_directi/fund.class.php | 107 + plugins/registrar/_directi/nusoap.php | 4583 +++++++++++++++++ plugins/registrar/_directi/register.php | 79 + plugins/registrar/_directi/response.class.php | 188 + plugins/registrar/_directi/wsdl/customer.wsdl | 406 ++ plugins/registrar/_directi/wsdl/domain.wsdl | 971 ++++ .../_directi/wsdl/domaincontact.wsdl | 433 ++ .../_directi/wsdl/domainuscontact.wsdl | 75 + plugins/registrar/_directi/wsdl/fund.wsdl | 151 + plugins/registrar/_opensrs-php/LICENSE.txt | 504 ++ plugins/registrar/_opensrs-php/OPS.php | 667 +++ .../registrar/_opensrs-php/country_codes.php | 278 + .../registrar/_opensrs-php/openSRS_base.php | 1009 ++++ plugins/registrar/_opensrs-php/ops.dtd | 55 + plugins/registrar/_opensrs-php/test.php | 67 + plugins/registrar/_opensrs-php/test.xml | 26 + plugins/voip_did/DEFAULT.php | 67 + plugins/voip_did/DIDX.php | 329 ++ plugins/voip_did/MAGRATHEA.php | 242 + plugins/whois/DEFAULT.php | 88 + plugins/whois/SUBDOMAIN.php | 56 + plugins/whois/WHOIS_CO_ZA.php | 69 + reports/account_admin/customers.xml | 48 + reports/account_admin/customers_domain.xml | 37 + reports/account_admin/customers_grouped.xml | 54 + reports/account_admin/industry.xml | 58 + reports/account_admin/new_customers.xml | 38 + reports/account_admin/preferences.xml | 125 + reports/account_admin/region_breakdown.xml | 114 + reports/account_admin/regions_all.xml | 89 + reports/account_admin/registrations.xml | 175 + reports/account_billing/card_type.xml | 130 + reports/account_billing/expire_dates.xml | 19 + .../affiliate/affiliate_report_monthly.xml | 70 + reports/cancellations/cancellations.xml | 122 + reports/checkout/revenue.xml | 85 + reports/discount/discount_report.xml | 60 + reports/group/account_group_year.xml | 29 + reports/group/service_group.xml | 29 + reports/host_server/server_services.xml | 41 + reports/host_server/tld_services.xml | 121 + reports/invoice/sales_report.xml | 187 + reports/invoice/sku_monthly.xml | 88 + reports/invoice/sku_yearly.xml | 78 + reports/service/service_customer_sku.xml | 64 + reports/service/service_recurr.xml | 80 + reports/service/service_sku.xml | 41 + reports/tax/tax_report.xml | 154 + reports/ticket/department.xml | 37 + reports/ticket/staff.xml | 37 + reports/ticket/ticket_volume.xml | 158 + task.php | 47 + test.php | 514 ++ themes/default.user_theme | 0 themes/default/IEFrameWarningBypass.htm | 5 + themes/default/blocks/account/account.tpl | 262 + themes/default/blocks/account/add.tpl | 317 ++ themes/default/blocks/account/login.tpl | 107 + .../default/blocks/account/login_cookie.tpl | 40 + .../default/blocks/account/login_htaccess.tpl | 40 + themes/default/blocks/account/login_small.tpl | 61 + themes/default/blocks/account/password.tpl | 73 + .../default/blocks/account/password_reset.tpl | 90 + themes/default/blocks/account/sub_account.tpl | 29 + .../blocks/account/sub_account_add.tpl | 280 + .../blocks/account/sub_account_view.tpl | 3 + themes/default/blocks/account/verify.tpl | 157 + themes/default/blocks/account/view.tpl | 369 ++ themes/default/blocks/account_admin/add.tpl | 457 ++ .../blocks/account_admin/iframe_mail_one.tpl | 102 + .../blocks/account_admin/mail_multi.tpl | 96 + .../default/blocks/account_admin/mail_one.tpl | 96 + themes/default/blocks/account_admin/merge.tpl | 55 + .../blocks/account_admin/search_form.tpl | 567 ++ .../blocks/account_admin/search_show.tpl | 155 + themes/default/blocks/account_admin/view.tpl | 1042 ++++ themes/default/blocks/account_billing/add.tpl | 228 + .../blocks/account_billing/search_form.tpl | 89 + .../blocks/account_billing/search_show.tpl | 112 + .../account_billing/user_search_show.tpl | 83 + .../blocks/account_billing/user_view.tpl | 299 ++ .../default/blocks/account_billing/view.tpl | 265 + themes/default/blocks/account_memo/add.tpl | 60 + .../blocks/account_memo/search_show.tpl | 140 + themes/default/blocks/account_memo/view.tpl | 143 + themes/default/blocks/affiliate/add.tpl | 59 + themes/default/blocks/affiliate/affiliate.tpl | 19 + .../default/blocks/affiliate/mail_multi.tpl | 94 + .../blocks/affiliate/new_tier_iframe.tpl | 62 + .../affiliate/plugin_ACCOUNT_DISCOUNT.tpl | 1 + .../blocks/affiliate/plugin_EBULLION.tpl | 13 + .../blocks/affiliate/plugin_MAIL_CHECK.tpl | 63 + .../blocks/affiliate/plugin_MONEYBOOKERS.tpl | 13 + .../blocks/affiliate/plugin_PAYPAL.tpl | 13 + .../blocks/affiliate/recurr_tier_iframe.tpl | 63 + .../default/blocks/affiliate/search_form.tpl | 149 + .../default/blocks/affiliate/search_show.tpl | 158 + themes/default/blocks/affiliate/user_add.tpl | 212 + .../blocks/affiliate/user_new_tier_iframe.tpl | 62 + .../affiliate/user_recurr_tier_iframe.tpl | 62 + themes/default/blocks/affiliate/user_view.tpl | 429 ++ themes/default/blocks/affiliate/view.tpl | 631 +++ .../blocks/affiliate_commission/add.tpl | 63 + .../affiliate_commission/search_form.tpl | 108 + .../affiliate_commission/search_show.tpl | 125 + .../blocks/affiliate_commission/view.tpl | 225 + .../default/blocks/affiliate_template/add.tpl | 234 + .../blocks/affiliate_template/search_show.tpl | 129 + .../blocks/affiliate_template/view.tpl | 494 ++ themes/default/blocks/asset/add.tpl | 67 + themes/default/blocks/asset/import.tpl | 66 + themes/default/blocks/asset/search_form.tpl | 126 + themes/default/blocks/asset/search_show.tpl | 119 + themes/default/blocks/asset/view.tpl | 158 + themes/default/blocks/asset_invoice/ajax.js | 35 + .../default/blocks/asset_invoice/invoice.tpl | 60 + themes/default/blocks/asset_invoice/main.tpl | 16 + themes/default/blocks/asset_pool/add.tpl | 50 + .../default/blocks/asset_pool/search_show.tpl | 95 + themes/default/blocks/asset_pool/view.tpl | 100 + themes/default/blocks/backup/add.tpl | 166 + .../default/blocks/backup/backup_module.tpl | 36 + themes/default/blocks/backup/search_show.tpl | 101 + themes/default/blocks/backup/view.tpl | 176 + themes/default/blocks/blocked_email/add.tpl | 64 + .../blocks/blocked_email/search_form.tpl | 100 + .../blocks/blocked_email/search_show.tpl | 94 + themes/default/blocks/blocked_email/view.tpl | 127 + themes/default/blocks/blocked_ip/add.tpl | 63 + .../default/blocks/blocked_ip/search_form.tpl | 100 + .../default/blocks/blocked_ip/search_show.tpl | 94 + themes/default/blocks/blocked_ip/view.tpl | 118 + themes/default/blocks/campaign/add.tpl | 312 ++ themes/default/blocks/campaign/affiliate.tpl | 415 ++ themes/default/blocks/campaign/click.tpl | 5 + themes/default/blocks/campaign/display.tpl | 5 + .../default/blocks/campaign/search_form.tpl | 148 + .../default/blocks/campaign/search_show.tpl | 184 + themes/default/blocks/campaign/view.tpl | 1253 +++++ themes/default/blocks/cart/ad_hoc.tpl | 160 + .../default/blocks/cart/admin_changeqty.tpl | 17 + themes/default/blocks/cart/admin_view.tpl | 543 ++ themes/default/blocks/cart/cart.tpl | 466 ++ themes/default/blocks/cart/changeqty.tpl | 17 + themes/default/blocks/charge/add.tpl | 153 + themes/default/blocks/charge/search_form.tpl | 187 + themes/default/blocks/charge/search_show.tpl | 142 + themes/default/blocks/charge/view.tpl | 208 + themes/default/blocks/checkout/add.tpl | 352 ++ .../blocks/checkout/admin_checkout.tpl | 652 +++ themes/default/blocks/checkout/ajax.js | 56 + themes/default/blocks/checkout/ccv_help.tpl | 33 + themes/default/blocks/checkout/checkout.tpl | 689 +++ .../blocks/checkout/checkoutoption.tpl | 7 + .../default/blocks/checkout/search_show.tpl | 111 + themes/default/blocks/checkout/view.tpl | 398 ++ .../blocks/checkout_plugin/credit_card.tpl | 2 + .../checkout_plugin/credit_card_avs.tpl | 214 + .../default/blocks/checkout_plugin/echeck.tpl | 168 + .../checkout_plugin/list_credit_card.tpl | 17 + .../checkout_plugin/plugin_cfg_2CHECKOUT.tpl | 40 + .../plugin_cfg_2CHECKOUT_V2.tpl | 40 + .../plugin_cfg_ACHCOMMERCE.tpl | 58 + .../checkout_plugin/plugin_cfg_ANYPAY.tpl | 34 + .../plugin_cfg_AUTHORIZE_NET.tpl | 128 + .../checkout_plugin/plugin_cfg_BLUEPAY.tpl | 127 + .../plugin_cfg_COMMERCEPAYMENTWINDOW.tpl | 10 + .../plugin_cfg_CROWNE_GOLD.tpl | 53 + .../plugin_cfg_CYBERSOURCE.tpl | 129 + .../checkout_plugin/plugin_cfg_DPILINK.tpl | 128 + .../checkout_plugin/plugin_cfg_EBULLION.tpl | 44 + .../checkout_plugin/plugin_cfg_ECHO.tpl | 128 + .../plugin_cfg_ECX_QUICKCOMMERCE.tpl | 128 + .../checkout_plugin/plugin_cfg_EFT_MANUAL.tpl | 2 + .../checkout_plugin/plugin_cfg_EFT_SECURE.tpl | 96 + .../checkout_plugin/plugin_cfg_EGOLD.tpl | 52 + .../checkout_plugin/plugin_cfg_EPDQ.tpl | 28 + .../plugin_cfg_EPROCESSING_NETWORK.tpl | 128 + .../checkout_plugin/plugin_cfg_EWAY.tpl | 111 + .../checkout_plugin/plugin_cfg_FREE.tpl | 1 + .../plugin_cfg_GOEMERCHANT.tpl | 96 + .../checkout_plugin/plugin_cfg_GOLDMONEY.tpl | 34 + .../checkout_plugin/plugin_cfg_IBILL.tpl | 117 + .../checkout_plugin/plugin_cfg_IKOBO.tpl | 40 + .../plugin_cfg_INTERNETSECURE.tpl | 101 + .../checkout_plugin/plugin_cfg_LINKPOINT.tpl | 117 + .../checkout_plugin/plugin_cfg_MANUAL.tpl | 40 + .../plugin_cfg_MONERIS_ESELECT.tpl | 128 + .../plugin_cfg_MONEYBOOKERS.tpl | 40 + .../plugin_cfg_MONEYBOOKERS_RECURRING.tpl | 40 + .../checkout_plugin/plugin_cfg_NETBILLING.tpl | 117 + .../plugin_cfg_NETPAYMENTS.tpl | 34 + .../checkout_plugin/plugin_cfg_NOCHEXS.tpl | 34 + .../plugin_cfg_OPTIMALPAYMENTS.tpl | 123 + .../plugin_cfg_PAYBYCHECK_BASIC.tpl | 34 + .../checkout_plugin/plugin_cfg_PAYFUSE.tpl | 121 + .../checkout_plugin/plugin_cfg_PAYMATE.tpl | 13 + .../checkout_plugin/plugin_cfg_PAYPAL.tpl | 34 + .../plugin_cfg_PAYPAL_RECURRING.tpl | 34 + .../checkout_plugin/plugin_cfg_PAYSWISS.tpl | 13 + .../plugin_cfg_PAYSWISS_RECURRING.tpl | 13 + .../plugin_cfg_PAYSYSTEMS_CHECK.tpl | 34 + .../plugin_cfg_PAYSYSTEMS_CHECK_RECUR.tpl | 34 + .../plugin_cfg_PAYSYSTEMS_PRO.tpl | 34 + .../plugin_cfg_PAYSYSTEMS_RECURRING.tpl | 34 + .../plugin_cfg_PLANETPAYMENT.tpl | 128 + .../checkout_plugin/plugin_cfg_PLUGNPAY.tpl | 117 + .../checkout_plugin/plugin_cfg_PROTX.tpl | 111 + .../checkout_plugin/plugin_cfg_PSIGATE.tpl | 111 + .../plugin_cfg_REMIT_BANK_WIRE.tpl | 16 + .../plugin_cfg_REMIT_CHECK.tpl | 16 + .../checkout_plugin/plugin_cfg_SECPAY.tpl | 111 + .../checkout_plugin/plugin_cfg_SKIPJACK.tpl | 111 + .../checkout_plugin/plugin_cfg_STORMPAY.tpl | 40 + .../plugin_cfg_STORMPAY_RECURRING.tpl | 36 + .../checkout_plugin/plugin_cfg_SUREPAY.tpl | 117 + .../plugin_cfg_SWREG_ADVANCED.tpl | 111 + .../plugin_cfg_SWREG_INTERMEDIATE.tpl | 34 + .../plugin_cfg_TRUSTCOMMERCE.tpl | 137 + .../checkout_plugin/plugin_cfg_USA_EPAY.tpl | 111 + .../plugin_cfg_VERISIGN_PFPRO.tpl | 134 + .../checkout_plugin/plugin_cfg_WORLDPAY.tpl | 34 + .../plugin_cfg_WORLDPAY_FUTUREPAY.tpl | 34 + .../blocks/checkout_plugin/plugin_inv_.tpl | 1 + .../checkout_plugin/plugin_inv_2CHECKOUT.tpl | 1 + .../plugin_inv_2CHECKOUT_V2.tpl | 1 + .../plugin_inv_ACHCOMMERCE.tpl | 2 + .../checkout_plugin/plugin_inv_ANYPAY.tpl | 1 + .../plugin_inv_AUTHORIZE_NET.tpl | 2 + .../checkout_plugin/plugin_inv_BLUEPAY.tpl | 2 + .../plugin_inv_COMMERCEPAYMENTWINDOW.tpl | 1 + .../plugin_inv_CROWNE_GOLD.tpl | 1 + .../plugin_inv_CYBERSOURCE.tpl | 2 + .../checkout_plugin/plugin_inv_DPILINK.tpl | 2 + .../checkout_plugin/plugin_inv_EBULLION.tpl | 1 + .../checkout_plugin/plugin_inv_ECHO.tpl | 2 + .../plugin_inv_ECX_QUICKCOMMERCE.tpl | 2 + .../checkout_plugin/plugin_inv_EFT_MANUAL.tpl | 2 + .../checkout_plugin/plugin_inv_EFT_SECURE.tpl | 2 + .../checkout_plugin/plugin_inv_EGOLD.tpl | 1 + .../checkout_plugin/plugin_inv_EPDQ.tpl | 1 + .../plugin_inv_EPROCESSING_NETWORK.tpl | 17 + .../checkout_plugin/plugin_inv_EWAY.tpl | 2 + .../checkout_plugin/plugin_inv_FREE.tpl | 1 + .../plugin_inv_GOEMERCHANT.tpl | 2 + .../checkout_plugin/plugin_inv_GOLDMONEY.tpl | 1 + .../checkout_plugin/plugin_inv_IBILL.tpl | 2 + .../checkout_plugin/plugin_inv_IKOBO.tpl | 1 + .../plugin_inv_INTERNETSECURE.tpl | 2 + .../checkout_plugin/plugin_inv_LINKPOINT.tpl | 2 + .../checkout_plugin/plugin_inv_MANUAL.tpl | 2 + .../plugin_inv_MONERIS_ESELECT.tpl | 2 + .../plugin_inv_MONEYBOOKERS.tpl | 1 + .../plugin_inv_MONEYBOOKERS_RECURRING.tpl | 1 + .../checkout_plugin/plugin_inv_NETBILLING.tpl | 2 + .../plugin_inv_NETPAYMENTS.tpl | 2 + .../checkout_plugin/plugin_inv_NOCHEXS.tpl | 1 + .../plugin_inv_OPTIMALPAYMENTS.tpl | 2 + .../plugin_inv_PAYBYCHECK_BASIC.tpl | 1 + .../checkout_plugin/plugin_inv_PAYFUSE.tpl | 2 + .../checkout_plugin/plugin_inv_PAYMATE.tpl | 1 + .../checkout_plugin/plugin_inv_PAYPAL.tpl | 1 + .../plugin_inv_PAYPAL_RECURRING.tpl | 12 + .../checkout_plugin/plugin_inv_PAYSWISS.tpl | 1 + .../plugin_inv_PAYSWISS_RECURRING.tpl | 1 + .../plugin_inv_PAYSYSTEMS_CHECK.tpl | 1 + .../plugin_inv_PAYSYSTEMS_CHECK_RECUR.tpl | 1 + .../plugin_inv_PAYSYSTEMS_PRO.tpl | 1 + .../plugin_inv_PAYSYSTEMS_RECURRING.tpl | 1 + .../plugin_inv_PLANETPAYMENT.tpl | 2 + .../checkout_plugin/plugin_inv_PLUGNPAY.tpl | 2 + .../checkout_plugin/plugin_inv_PROTX.tpl | 2 + .../checkout_plugin/plugin_inv_PSIGATE.tpl | 2 + .../plugin_inv_REMIT_BANK_WIRE.tpl | 1 + .../plugin_inv_REMIT_CHECK.tpl | 1 + .../checkout_plugin/plugin_inv_RTWARE.tpl | 2 + .../checkout_plugin/plugin_inv_SECPAY.tpl | 2 + .../checkout_plugin/plugin_inv_SKIPJACK.tpl | 2 + .../checkout_plugin/plugin_inv_STORMPAY.tpl | 1 + .../plugin_inv_STORMPAY_RECURRING.tpl | 1 + .../checkout_plugin/plugin_inv_SUREPAY.tpl | 2 + .../plugin_inv_SWREG_ADVANCED.tpl | 2 + .../plugin_inv_SWREG_INTERMEDIATE.tpl | 1 + .../plugin_inv_TRUSTCOMMERCE.tpl | 1 + .../checkout_plugin/plugin_inv_USA_EPAY.tpl | 2 + .../plugin_inv_VERISIGN_PFPRO.tpl | 2 + .../checkout_plugin/plugin_inv_WORLDPAY.tpl | 1 + .../plugin_inv_WORLDPAY_FUTUREPAY.tpl | 1 + .../checkout_plugin/plugin_ord_2CHECKOUT.tpl | 2 + .../plugin_ord_2CHECKOUT_V2.tpl | 2 + .../plugin_ord_ACHCOMMERCE.tpl | 2 + .../checkout_plugin/plugin_ord_ANYPAY.tpl | 2 + .../plugin_ord_AUTHORIZE_NET.tpl | 2 + .../checkout_plugin/plugin_ord_BLUEPAY.tpl | 2 + .../plugin_ord_COMMERCEPAYMENTWINDOW.tpl | 2 + .../plugin_ord_CROWNE_GOLD.tpl | 2 + .../plugin_ord_CYBERSOURCE.tpl | 2 + .../checkout_plugin/plugin_ord_DPILINK.tpl | 2 + .../checkout_plugin/plugin_ord_EBULLION.tpl | 2 + .../checkout_plugin/plugin_ord_ECHO.tpl | 2 + .../plugin_ord_ECX_QUICKCOMMERCE.tpl | 2 + .../checkout_plugin/plugin_ord_EFT_MANUAL.tpl | 2 + .../checkout_plugin/plugin_ord_EFT_SECURE.tpl | 2 + .../checkout_plugin/plugin_ord_EGOLD.tpl | 2 + .../checkout_plugin/plugin_ord_EPDQ.tpl | 2 + .../plugin_ord_EPROCESSING_NETWORK.tpl | 2 + .../checkout_plugin/plugin_ord_EWAY.tpl | 2 + .../checkout_plugin/plugin_ord_FREE.tpl | 2 + .../plugin_ord_GOEMERCHANT.tpl | 2 + .../checkout_plugin/plugin_ord_GOLDMONEY.tpl | 2 + .../checkout_plugin/plugin_ord_IBILL.tpl | 2 + .../checkout_plugin/plugin_ord_IKOBO.tpl | 2 + .../plugin_ord_INTERNETSECURE.tpl | 2 + .../checkout_plugin/plugin_ord_LINKPOINT.tpl | 2 + .../checkout_plugin/plugin_ord_MANUAL.tpl | 2 + .../plugin_ord_MANUAL_ALERT.tpl | 48 + .../plugin_ord_MONERIS_ESELECT.tpl | 2 + .../plugin_ord_MONEYBOOKERS.tpl | 2 + .../plugin_ord_MONEYBOOKERS_RECURRING.tpl | 2 + .../checkout_plugin/plugin_ord_NETBILLING.tpl | 2 + .../plugin_ord_NETPAYMENTS.tpl | 2 + .../checkout_plugin/plugin_ord_NOCHEXS.tpl | 2 + .../plugin_ord_OPTIMALPAYMENTS.tpl | 2 + .../plugin_ord_PAYBYCHECK_BASIC.tpl | 2 + .../checkout_plugin/plugin_ord_PAYFUSE.tpl | 2 + .../checkout_plugin/plugin_ord_PAYMATE.tpl | 2 + .../checkout_plugin/plugin_ord_PAYPAL.tpl | 2 + .../plugin_ord_PAYPAL_RECURRING.tpl | 2 + .../checkout_plugin/plugin_ord_PAYSWISS.tpl | 2 + .../plugin_ord_PAYSWISS_RECURRING.tpl | 2 + .../plugin_ord_PAYSYSTEMS_CHECK.tpl | 2 + .../plugin_ord_PAYSYSTEMS_CHECK_RECUR.tpl | 2 + .../plugin_ord_PAYSYSTEMS_PRO.tpl | 2 + .../plugin_ord_PAYSYSTEMS_RECURRING.tpl | 2 + .../plugin_ord_PLANETPAYMENT.tpl | 2 + .../checkout_plugin/plugin_ord_PLUGNPAY.tpl | 2 + .../checkout_plugin/plugin_ord_PROTX.tpl | 2 + .../checkout_plugin/plugin_ord_PSIGATE.tpl | 2 + .../plugin_ord_REMIT_BANK_WIRE.tpl | 2 + .../plugin_ord_REMIT_BANK_WIRE_ALERT.tpl | 60 + .../plugin_ord_REMIT_CHECK.tpl | 2 + .../plugin_ord_REMIT_CHECK_ALERT.tpl | 60 + .../checkout_plugin/plugin_ord_RTWARE.tpl | 2 + .../checkout_plugin/plugin_ord_SECPAY.tpl | 2 + .../checkout_plugin/plugin_ord_SKIPJACK.tpl | 2 + .../checkout_plugin/plugin_ord_STORMPAY.tpl | 2 + .../plugin_ord_STORMPAY_RECURRING.tpl | 2 + .../checkout_plugin/plugin_ord_SUREPAY.tpl | 2 + .../plugin_ord_SWREG_ADVANCED.tpl | 0 .../plugin_ord_SWREG_INTERMEDIATE.tpl | 2 + .../plugin_ord_TRUSTCOMMERCE.tpl | 2 + .../checkout_plugin/plugin_ord_USA_EPAY.tpl | 2 + .../plugin_ord_VERISIGN_PFPRO.tpl | 2 + .../checkout_plugin/plugin_ord_WORLDPAY.tpl | 2 + .../plugin_ord_WORLDPAY_FUTUREPAY.tpl | 2 + .../blocks/checkout_plugin/third_party.tpl | 35 + .../checkout_plugin/third_party_noconf.tpl | 36 + themes/default/blocks/core/admin.tpl | 448 ++ themes/default/blocks/core/alert.tpl | 37 + themes/default/blocks/core/alert_fields.tpl | 31 + themes/default/blocks/core/blank.tpl | 1 + themes/default/blocks/core/bottom_print.tpl | 18 + themes/default/blocks/core/debug.tpl | 34 + themes/default/blocks/core/error.tpl | 44 + themes/default/blocks/core/export_search.tpl | 119 + .../blocks/core/export_search_display.tpl | 4 + .../blocks/core/export_search_download.tpl | 4 + themes/default/blocks/core/graph.tpl | 1 + themes/default/blocks/core/graphview.tpl | 1 + themes/default/blocks/core/group.tpl | 3 + themes/default/blocks/core/htmlarea.tpl | 3 + themes/default/blocks/core/import.tpl | 87 + themes/default/blocks/core/import2.tpl | 64 + themes/default/blocks/core/import2_new.tpl | 71 + themes/default/blocks/core/import_new.tpl | 56 + themes/default/blocks/core/invalid_page.tpl | 1 + themes/default/blocks/core/language.tpl | 6 + themes/default/blocks/core/logout.tpl | 18 + themes/default/blocks/core/method_error.tpl | 7 + .../default/blocks/core/popup_list_search.tpl | 53 + .../default/blocks/core/recent_searches.tpl | 40 + themes/default/blocks/core/save_search.tpl | 61 + .../default/blocks/core/save_search_done.tpl | 19 + themes/default/blocks/core/saved_searches.tpl | 40 + themes/default/blocks/core/search.tpl | 98 + themes/default/blocks/core/search_iframe.tpl | 59 + themes/default/blocks/core/sess_renew.tpl | 22 + themes/default/blocks/core/sess_timeout.tpl | 51 + themes/default/blocks/core/test.tpl | 1 + themes/default/blocks/core/top_clean.tpl | 46 + themes/default/blocks/core/url.tpl | 1 + themes/default/blocks/core/user_search.tpl | 95 + themes/default/blocks/country/add.tpl | 92 + themes/default/blocks/country/main.tpl | 26 + themes/default/blocks/country/search_show.tpl | 125 + themes/default/blocks/country/view.tpl | 147 + themes/default/blocks/currency/add.tpl | 93 + themes/default/blocks/currency/main.tpl | 26 + .../default/blocks/currency/search_show.tpl | 114 + themes/default/blocks/currency/view.tpl | 201 + themes/default/blocks/db_mapping/add.tpl | 117 + .../blocks/db_mapping/group_map_db-status.tpl | 44 + .../blocks/db_mapping/group_map_db.tpl | 18 + .../blocks/db_mapping/group_map_status.tpl | 38 + themes/default/blocks/db_mapping/main.tpl | 27 + .../default/blocks/db_mapping/search_show.tpl | 95 + themes/default/blocks/db_mapping/view.tpl | 199 + themes/default/blocks/discount/add.tpl | 349 ++ .../default/blocks/discount/search_form.tpl | 168 + .../default/blocks/discount/search_show.tpl | 140 + .../blocks/discount/user_search_show.tpl | 103 + themes/default/blocks/discount/view.tpl | 405 ++ .../default/blocks/email_log/search_form.tpl | 123 + .../default/blocks/email_log/search_show.tpl | 105 + themes/default/blocks/email_log/user_list.tpl | 50 + themes/default/blocks/email_log/user_view.tpl | 47 + themes/default/blocks/email_log/view.tpl | 111 + themes/default/blocks/email_queue/add.tpl | 141 + .../blocks/email_queue/search_form.tpl | 108 + .../blocks/email_queue/search_show.tpl | 119 + themes/default/blocks/email_queue/view.tpl | 191 + themes/default/blocks/email_template/add.tpl | 119 + .../blocks/email_template/search_show.tpl | 117 + themes/default/blocks/email_template/view.tpl | 210 + .../blocks/email_template_translate/add.tpl | 165 + .../email_template_translate/search_show.tpl | 120 + .../blocks/email_template_translate/view.tpl | 203 + themes/default/blocks/faq/add.tpl | 95 + themes/default/blocks/faq/faq.tpl | 100 + themes/default/blocks/faq/menu.tpl | 30 + themes/default/blocks/faq/search_form.tpl | 122 + themes/default/blocks/faq/search_show.tpl | 109 + themes/default/blocks/faq/view.tpl | 216 + themes/default/blocks/faq_category/add.tpl | 91 + .../blocks/faq_category/faq_category.tpl | 37 + .../blocks/faq_category/search_show.tpl | 119 + themes/default/blocks/faq_category/view.tpl | 154 + themes/default/blocks/faq_translate/add.tpl | 95 + .../blocks/faq_translate/search_show.tpl | 120 + themes/default/blocks/faq_translate/view.tpl | 136 + themes/default/blocks/file/add.tpl | 163 + themes/default/blocks/file/download.tpl | 5 + themes/default/blocks/file/file.tpl | 39 + themes/default/blocks/file/file_list.tpl | 19 + themes/default/blocks/file/list.tpl | 72 + themes/default/blocks/file/menu.tpl | 32 + themes/default/blocks/file/search_form.tpl | 139 + themes/default/blocks/file/search_show.tpl | 115 + themes/default/blocks/file/view.tpl | 218 + themes/default/blocks/file_category/add.tpl | 102 + .../blocks/file_category/search_form.tpl | 98 + .../blocks/file_category/search_show.tpl | 107 + themes/default/blocks/file_category/view.tpl | 153 + themes/default/blocks/group/add.tpl | 121 + themes/default/blocks/group/search_show.tpl | 65 + themes/default/blocks/group/view.tpl | 217 + .../plugin_cfg_DIRECTADMIN_1_23.tpl | 43 + .../plugin_cfg_EASYADMIN.tpl | 33 + .../plugin_cfg_ENSIM_LINUX_3.tpl | 45 + .../plugin_cfg_ENSIM_LINUX_3_5.tpl | 45 + .../plugin_cfg_ENSIM_LINUX_PLAN_3_5.tpl | 45 + .../plugin_cfg_ENSIM_WINDOWS_3.tpl | 60 + .../plugin_cfg_ENSIM_WINDOWS_3_5.tpl | 60 + .../plugin_cfg_HEARTINTERNET.tpl | 11 + .../plugin_cfg_HELM_3_1.tpl | 34 + .../plugin_cfg_HOSTOPIA.tpl | 17 + .../plugin_cfg_MANUAL.tpl | 15 + .../plugin_cfg_PLESK_LINUX_6.tpl | 44 + .../plugin_cfg_PLESK_LINUX_7.tpl | 44 + .../plugin_cfg_PLESK_RELOADED_7_5.tpl | 33 + .../plugin_cfg_PLESK_WINDOWS_6_5.tpl | 53 + .../plugin_cfg_PLESK_WINDOWS_7.tpl | 53 + .../plugin_cfg_PSA_RESELL_7_5.tpl | 42 + .../plugin_cfg_RAQ_4.tpl | 58 + .../plugin_cfg_RAQ_550.tpl | 45 + .../plugin_cfg_WEBMIN.tpl | 38 + .../plugin_cfg_WEBMIN_PRO.tpl | 46 + .../host_provision_plugin/plugin_cfg_WHM.tpl | 38 + .../plugin_prod_DIRECTADMIN_1_23.tpl | 15 + .../plugin_prod_EASYADMIN.tpl | 112 + .../plugin_prod_ENSIM_LINUX_3.tpl | 49 + .../plugin_prod_ENSIM_LINUX_3_5.tpl | 457 ++ .../plugin_prod_ENSIM_LINUX_PLAN_3_5.tpl | 9 + .../plugin_prod_ENSIM_WINDOWS_3.tpl | 377 ++ .../plugin_prod_ENSIM_WINDOWS_3_5.tpl | 419 ++ .../plugin_prod_HEARTINTERNET.tpl | 9 + .../plugin_prod_HELM_3_1.tpl | 21 + .../plugin_prod_HOSTOPIA.tpl | 16 + .../plugin_prod_MANUAL.tpl | 251 + .../plugin_prod_PLESK_LINUX_6.tpl | 364 ++ .../plugin_prod_PLESK_LINUX_7.tpl | 419 ++ .../plugin_prod_PLESK_RELOADED_7_5.tpl | 311 ++ .../plugin_prod_PLESK_WINDOWS_6_5.tpl | 375 ++ .../plugin_prod_PLESK_WINDOWS_7.tpl | 419 ++ .../plugin_prod_PSA_RESELL_7_5.tpl | 311 ++ .../plugin_prod_RAQ_550.tpl | 62 + .../plugin_prod_WEBMIN.tpl | 92 + .../plugin_prod_WEBMIN_PRO.tpl | 56 + .../host_provision_plugin/plugin_prod_WHM.tpl | 15 + .../blocks/host_registrar_plugin/add.tpl | 73 + .../blocks/host_registrar_plugin/main.tpl | 27 + .../plugin_cfg_BULKREGISTER.tpl | 99 + .../plugin_cfg_DIRECTI.tpl | 95 + .../host_registrar_plugin/plugin_cfg_ENOM.tpl | 83 + .../plugin_cfg_GODADDY.tpl | 89 + .../plugin_cfg_MANUAL.tpl | 87 + .../plugin_cfg_MELBOURNEIT.tpl | 99 + .../plugin_cfg_NAMES4EVER.tpl | 87 + .../plugin_cfg_NOMINET.tpl | 79 + .../plugin_cfg_ONLINENIC.tpl | 75 + .../plugin_cfg_OPENSRS.tpl | 99 + .../plugin_cfg_PLANETDOMAIN.tpl | 77 + .../plugin_cfg_TOTALREGISTRATIONS.tpl | 79 + .../host_registrar_plugin/search_show.tpl | 98 + .../blocks/host_registrar_plugin/view.tpl | 113 + themes/default/blocks/host_server/add.tpl | 179 + .../blocks/host_server/search_show.tpl | 140 + themes/default/blocks/host_server/view.tpl | 260 + themes/default/blocks/host_tld/add.tpl | 116 + .../default/blocks/host_tld/admin_search.tpl | 105 + .../blocks/host_tld/admin_search_transfer.tpl | 92 + themes/default/blocks/host_tld/ajax.js | 69 + .../blocks/host_tld/iframe_ns_transfer.tpl | 26 + .../blocks/host_tld/iframe_register.tpl | 71 + .../blocks/host_tld/iframe_transfer.tpl | 71 + themes/default/blocks/host_tld/search.tpl | 123 + .../default/blocks/host_tld/search_mass.tpl | 73 + .../default/blocks/host_tld/search_show.tpl | 129 + .../blocks/host_tld/search_transfer.tpl | 91 + themes/default/blocks/host_tld/suggest.tpl | 291 ++ themes/default/blocks/host_tld/view.tpl | 735 +++ .../host_whois_plugin/plugin_cfg_DEFAULT.tpl | 25 + .../plugin_cfg_SUBDOMAIN.tpl | 1 + .../plugin_cfg_WHOIS_CO_ZA.tpl | 1 + themes/default/blocks/htaccess/add.tpl | 81 + themes/default/blocks/htaccess/htaccess.tpl | 38 + themes/default/blocks/htaccess/list.tpl | 27 + .../default/blocks/htaccess/search_show.tpl | 107 + themes/default/blocks/htaccess/view.tpl | 223 + themes/default/blocks/htaccess_dir/add.tpl | 129 + .../blocks/htaccess_dir/search_show.tpl | 119 + themes/default/blocks/htaccess_dir/view.tpl | 222 + .../default/blocks/htaccess_exclude/add.tpl | 59 + .../default/blocks/htaccess_exclude/main.tpl | 27 + .../blocks/htaccess_exclude/search_form.tpl | 80 + .../blocks/htaccess_exclude/search_show.tpl | 103 + .../default/blocks/htaccess_exclude/view.tpl | 114 + themes/default/blocks/import/add.tpl | 104 + themes/default/blocks/import/import.tpl | 91 + themes/default/blocks/import/search_show.tpl | 76 + themes/default/blocks/import/view.tpl | 154 + themes/default/blocks/invoice/add.tpl | 182 + .../blocks/invoice/checkout_multiple.tpl | 38 + .../default/blocks/invoice/checkoutoption.tpl | 7 + .../blocks/invoice/checkoutoptions.tpl | 63 + themes/default/blocks/invoice/invoice.tpl | 73 + themes/default/blocks/invoice/pdf.tpl | 1 + themes/default/blocks/invoice/reconcile.tpl | 72 + themes/default/blocks/invoice/refund.tpl | 72 + themes/default/blocks/invoice/search_form.tpl | 296 ++ themes/default/blocks/invoice/search_show.tpl | 148 + themes/default/blocks/invoice/thankyou.tpl | 48 + themes/default/blocks/invoice/user_list.tpl | 160 + .../blocks/invoice/user_search_show.tpl | 160 + themes/default/blocks/invoice/user_view.tpl | 686 +++ themes/default/blocks/invoice/view.tpl | 1231 +++++ .../default/blocks/invoice_commission/add.tpl | 77 + .../blocks/invoice_commission/main.tpl | 27 + .../blocks/invoice_commission/search_form.tpl | 98 + .../blocks/invoice_commission/search_show.tpl | 119 + .../blocks/invoice_commission/view.tpl | 127 + themes/default/blocks/invoice_item/add.tpl | 131 + themes/default/blocks/invoice_item/main.tpl | 27 + .../blocks/invoice_item/search_form.tpl | 152 + .../blocks/invoice_item/search_show.tpl | 167 + themes/default/blocks/invoice_item/view.tpl | 181 + themes/default/blocks/invoice_memo/add.tpl | 60 + .../blocks/invoice_memo/search_show.tpl | 140 + themes/default/blocks/invoice_memo/view.tpl | 153 + .../default/blocks/log_error/search_form.tpl | 130 + .../default/blocks/log_error/search_show.tpl | 114 + themes/default/blocks/log_error/view.tpl | 146 + themes/default/blocks/login_log/map.tpl | 3 + .../default/blocks/login_log/search_form.tpl | 114 + .../default/blocks/login_log/search_show.tpl | 119 + themes/default/blocks/login_log/whois.tpl | 3 + themes/default/blocks/module/add.tpl | 121 + themes/default/blocks/module/dev_add.tpl | 174 + themes/default/blocks/module/dev_add1.tpl | 455 ++ themes/default/blocks/module/install.tpl | 64 + themes/default/blocks/module/install_2.tpl | 64 + themes/default/blocks/module/main.tpl | 27 + .../default/blocks/module/remote_update.tpl | 138 + themes/default/blocks/module/search_show.tpl | 121 + themes/default/blocks/module/translate.tpl | 47 + themes/default/blocks/module/upgrade.tpl | 235 + themes/default/blocks/module/view.tpl | 247 + themes/default/blocks/module_method/add.tpl | 94 + .../blocks/module_method/search_show.tpl | 136 + themes/default/blocks/module_method/view.tpl | 149 + .../blocks/module_method/view_methods.tpl | 135 + themes/default/blocks/net_term/add.tpl | 150 + .../default/blocks/net_term/search_show.tpl | 127 + themes/default/blocks/net_term/view.tpl | 191 + themes/default/blocks/newsletter/add.tpl | 134 + themes/default/blocks/newsletter/menu.tpl | 40 + .../default/blocks/newsletter/newsletter.tpl | 148 + themes/default/blocks/newsletter/popup.tpl | 8 + .../default/blocks/newsletter/search_form.tpl | 106 + .../default/blocks/newsletter/search_show.tpl | 117 + themes/default/blocks/newsletter/send.tpl | 158 + .../blocks/newsletter/subscribe_confirm.tpl | 4 + .../default/blocks/newsletter/unsubscribe.tpl | 49 + themes/default/blocks/newsletter/view.tpl | 214 + .../blocks/newsletter_subscriber/add.tpl | 107 + .../newsletter_subscriber/search_form.tpl | 158 + .../newsletter_subscriber/search_show.tpl | 151 + .../blocks/newsletter_subscriber/view.tpl | 171 + themes/default/blocks/product/add.tpl | 201 + .../default/blocks/product/admin_details.tpl | 495 ++ themes/default/blocks/product/cat.tpl | 51 + themes/default/blocks/product/details.tpl | 577 +++ .../default/blocks/product/details_wizard.tpl | 549 ++ .../blocks/product/iframe_associations.tpl | 197 + .../default/blocks/product/iframe_clone.tpl | 42 + .../blocks/product/iframe_discounts.tpl | 80 + .../default/blocks/product/iframe_hosting.tpl | 148 + .../default/blocks/product/iframe_plugins.tpl | 83 + .../blocks/product/iframe_price_onetime.tpl | 101 + .../blocks/product/iframe_price_recurring.tpl | 345 ++ themes/default/blocks/product/search_form.tpl | 137 + themes/default/blocks/product/search_show.tpl | 148 + themes/default/blocks/product/view.tpl | 538 ++ themes/default/blocks/product_attr/add.tpl | 182 + .../blocks/product_attr/search_show.tpl | 94 + themes/default/blocks/product_attr/view.tpl | 216 + themes/default/blocks/product_cat/add.tpl | 178 + themes/default/blocks/product_cat/menu.tpl | 73 + .../blocks/product_cat/search_show.tpl | 101 + .../blocks/product_cat/t_Multi Column.tpl | 188 + .../blocks/product_cat/t_Paged Listing.tpl | 182 + .../default/blocks/product_cat/t_Wizard.tpl | 144 + themes/default/blocks/product_cat/view.tpl | 288 ++ .../blocks/product_cat_translate/add.tpl | 122 + .../product_cat_translate/search_show.tpl | 111 + .../blocks/product_cat_translate/view.tpl | 157 + themes/default/blocks/product_img/add.tpl | 61 + .../blocks/product_img/search_show.tpl | 105 + themes/default/blocks/product_img/view.tpl | 62 + .../product_plugin/plugin_order_PREPAID.tpl | 259 + .../plugin_order_TICKET_INCIDENT.tpl | 28 + .../product_plugin/plugin_order_VOIP.tpl | 154 + .../product_plugin/plugin_prod_ASSET.tpl | 44 + .../product_plugin/plugin_prod_EXAMPLE.tpl | 23 + .../product_plugin/plugin_prod_PREPAID.tpl | 32 + .../product_plugin/plugin_prod_RADIUS.tpl | 83 + .../plugin_prod_TICKET_INCIDENT.tpl | 25 + .../product_plugin/plugin_prod_VOIP.tpl | 247 + .../default/blocks/product_translate/add.tpl | 78 + .../default/blocks/product_translate/edit.tpl | 125 + .../blocks/product_translate/search_show.tpl | 81 + .../default/blocks/product_translate/view.tpl | 136 + themes/default/blocks/radius/add.tpl | 214 + themes/default/blocks/radius/search_form.tpl | 178 + themes/default/blocks/radius/search_show.tpl | 129 + themes/default/blocks/radius/user.tpl | 141 + themes/default/blocks/radius/view.tpl | 261 + themes/default/blocks/realestate/add.tpl | 276 + .../default/blocks/realestate/search_form.tpl | 286 + .../default/blocks/realestate/search_show.tpl | 118 + themes/default/blocks/realestate/view.tpl | 119 + themes/default/blocks/report/add.tpl | 65 + themes/default/blocks/report/generate.tpl | 153 + themes/default/blocks/report/main.tpl | 55 + themes/default/blocks/report/output.tpl | 9 + themes/default/blocks/report/search_form.tpl | 98 + themes/default/blocks/report/search_show.tpl | 119 + themes/default/blocks/report/view.tpl | 127 + themes/default/blocks/service/add.tpl | 759 +++ .../blocks/service/iframe_search_show.tpl | 99 + themes/default/blocks/service/modify.tpl | 413 ++ themes/default/blocks/service/none.tpl | 2 + themes/default/blocks/service/search_form.tpl | 454 ++ themes/default/blocks/service/search_show.tpl | 169 + themes/default/blocks/service/user_modify.tpl | 409 ++ .../blocks/service/user_search_show.tpl | 131 + themes/default/blocks/service/user_view.tpl | 620 +++ themes/default/blocks/service/view.tpl | 1079 ++++ themes/default/blocks/service_memo/add.tpl | 60 + .../blocks/service_memo/search_show.tpl | 140 + themes/default/blocks/service_memo/view.tpl | 143 + themes/default/blocks/session/search_form.tpl | 183 + themes/default/blocks/session/search_show.tpl | 135 + themes/default/blocks/session/view.tpl | 215 + themes/default/blocks/setup/_php_info.tpl | 4 + themes/default/blocks/setup/search_show.tpl | 108 + themes/default/blocks/setup/view.tpl | 754 +++ themes/default/blocks/setup_email/add.tpl | 226 + .../blocks/setup_email/search_show.tpl | 129 + themes/default/blocks/setup_email/view.tpl | 281 + .../blocks/setup_invoice/search_show.tpl | 101 + themes/default/blocks/setup_invoice/view.tpl | 189 + themes/default/blocks/staff/add.tpl | 107 + themes/default/blocks/staff/search_form.tpl | 126 + themes/default/blocks/staff/search_show.tpl | 135 + themes/default/blocks/staff/staff.tpl | 145 + themes/default/blocks/staff/view.tpl | 194 + .../default/blocks/staff_department/add.tpl | 77 + .../blocks/staff_department/search_form.tpl | 98 + .../blocks/staff_department/search_show.tpl | 111 + .../default/blocks/staff_department/view.tpl | 131 + themes/default/blocks/static_page/add.tpl | 121 + themes/default/blocks/static_page/list.tpl | 36 + themes/default/blocks/static_page/menu.tpl | 30 + .../blocks/static_page/search_form.tpl | 131 + .../blocks/static_page/search_show.tpl | 114 + themes/default/blocks/static_page/show.tpl | 34 + themes/default/blocks/static_page/view.tpl | 208 + .../blocks/static_page_category/add.tpl | 91 + .../blocks/static_page_category/main.tpl | 27 + .../static_page_category/search_form.tpl | 62 + .../static_page_category/search_show.tpl | 119 + .../blocks/static_page_category/view.tpl | 154 + .../blocks/static_page_translate/add.tpl | 132 + .../static_page_translate/search_show.tpl | 120 + .../blocks/static_page_translate/view.tpl | 192 + themes/default/blocks/static_relation/add.tpl | 104 + .../blocks/static_relation/search_show.tpl | 113 + .../default/blocks/static_relation/view.tpl | 155 + themes/default/blocks/static_var/add.tpl | 235 + .../default/blocks/static_var/search_show.tpl | 130 + themes/default/blocks/static_var/view.tpl | 329 ++ themes/default/blocks/task/add.tpl | 182 + themes/default/blocks/task/main.tpl | 27 + themes/default/blocks/task/search_form.tpl | 161 + themes/default/blocks/task/search_show.tpl | 119 + themes/default/blocks/task/view.tpl | 244 + themes/default/blocks/tax/add.tpl | 109 + themes/default/blocks/tax/main.tpl | 27 + themes/default/blocks/tax/search_form.tpl | 98 + themes/default/blocks/tax/search_show.tpl | 119 + themes/default/blocks/tax/view.tpl | 158 + themes/default/blocks/ticket/add.tpl | 139 + themes/default/blocks/ticket/auth.tpl | 112 + themes/default/blocks/ticket/main.tpl | 2 + themes/default/blocks/ticket/overview.tpl | 104 + themes/default/blocks/ticket/search_form.tpl | 222 + themes/default/blocks/ticket/search_quick.tpl | 169 + .../blocks/ticket/search_quick_show.tpl | 32 + themes/default/blocks/ticket/search_show.tpl | 140 + themes/default/blocks/ticket/ticket.tpl | 185 + themes/default/blocks/ticket/user.tpl | 51 + themes/default/blocks/ticket/user_add.tpl | 142 + themes/default/blocks/ticket/user_view.tpl | 330 ++ themes/default/blocks/ticket/view.tpl | 580 +++ themes/default/blocks/ticket/view_quick.tpl | 20 + .../default/blocks/ticket_department/add.tpl | 113 + .../blocks/ticket_department/search_show.tpl | 108 + .../default/blocks/ticket_department/view.tpl | 199 + themes/default/blocks/voip/activity.tpl | 118 + themes/default/blocks/voip/call.tpl | 56 + themes/default/blocks/voip/config.tpl | 132 + themes/default/blocks/voip/features.tpl | 142 + themes/default/blocks/voip/memory_report.tpl | 6 + themes/default/blocks/voip/menu.tpl | 6 + themes/default/blocks/voip/overview.tpl | 126 + themes/default/blocks/voip_blacklist/add.tpl | 83 + .../blocks/voip_blacklist/search_form.tpl | 96 + .../blocks/voip_blacklist/search_show.tpl | 111 + .../blocks/voip_blacklist/user_add.tpl | 74 + .../voip_blacklist/user_search_show.tpl | 91 + .../blocks/voip_blacklist/user_view.tpl | 115 + themes/default/blocks/voip_blacklist/view.tpl | 133 + .../default/blocks/voip_cdr/search_form.tpl | 250 + .../default/blocks/voip_cdr/search_show.tpl | 143 + themes/default/blocks/voip_cdr/view.tpl | 279 + themes/default/blocks/voip_did/add.tpl | 276 + .../default/blocks/voip_did/search_form.tpl | 286 + .../default/blocks/voip_did/search_show.tpl | 134 + themes/default/blocks/voip_did/view.tpl | 412 ++ themes/default/blocks/voip_did_plugin/add.tpl | 75 + .../blocks/voip_did_plugin/config_DEFAULT.tpl | 10 + .../blocks/voip_did_plugin/config_DIDX.tpl | 35 + .../voip_did_plugin/config_MAGRATHEA.tpl | 38 + .../blocks/voip_did_plugin/search_show.tpl | 103 + .../default/blocks/voip_did_plugin/view.tpl | 123 + .../default/blocks/voip_fax/search_form.tpl | 169 + .../default/blocks/voip_fax/search_show.tpl | 119 + .../blocks/voip_fax/user_search_show.tpl | 100 + themes/default/blocks/voip_pool/add.tpl | 3 + themes/default/blocks/voip_pool/import.tpl | 67 + .../default/blocks/voip_pool/search_form.tpl | 89 + .../default/blocks/voip_pool/search_show.tpl | 104 + themes/default/blocks/voip_pool/view.tpl | 118 + themes/default/blocks/voip_prepaid/add.tpl | 89 + .../default/blocks/voip_prepaid/add_batch.tpl | 84 + .../blocks/voip_prepaid/search_form.tpl | 117 + .../blocks/voip_prepaid/search_show.tpl | 129 + themes/default/blocks/voip_prepaid/view.tpl | 138 + themes/default/blocks/voip_rate/add.tpl | 229 + themes/default/blocks/voip_rate/products.tpl | 64 + .../default/blocks/voip_rate/search_form.tpl | 164 + .../default/blocks/voip_rate/search_show.tpl | 119 + themes/default/blocks/voip_rate/view.tpl | 275 + themes/default/blocks/voip_rate_prod/add.tpl | 50 + .../blocks/voip_rate_prod/search_show.tpl | 106 + themes/default/blocks/voip_rate_prod/view.tpl | 108 + themes/default/blocks/voip_vm/add.tpl | 113 + themes/default/blocks/voip_vm/search_form.tpl | 124 + themes/default/blocks/voip_vm/search_show.tpl | 119 + themes/default/blocks/voip_vm/user.tpl | 75 + themes/default/blocks/voip_vm/view.tpl | 162 + themes/default/iframe.css | 231 + themes/default/images/CCV_help_amex.gif | Bin 0 -> 18550 bytes themes/default/images/CCV_help_visa_mc.gif | Bin 0 -> 13293 bytes themes/default/images/currency/AUD.gif | Bin 0 -> 620 bytes themes/default/images/currency/CAD.gif | Bin 0 -> 366 bytes themes/default/images/currency/CHF.gif | Bin 0 -> 333 bytes themes/default/images/currency/DKK.gif | Bin 0 -> 217 bytes themes/default/images/currency/EUR.gif | Bin 0 -> 313 bytes themes/default/images/currency/GBP.gif | Bin 0 -> 673 bytes themes/default/images/currency/HKD.gif | Bin 0 -> 337 bytes themes/default/images/currency/JPY.gif | Bin 0 -> 202 bytes themes/default/images/currency/MXN.gif | Bin 0 -> 1462 bytes themes/default/images/currency/MYR.gif | Bin 0 -> 1109 bytes themes/default/images/currency/NOK.gif | Bin 0 -> 359 bytes themes/default/images/currency/NZD.gif | Bin 0 -> 609 bytes themes/default/images/currency/RUR.gif | Bin 0 -> 144 bytes themes/default/images/currency/SEK.gif | Bin 0 -> 343 bytes themes/default/images/currency/USD.gif | Bin 0 -> 96 bytes themes/default/images/currency/ZAR.gif | Bin 0 -> 584 bytes themes/default/images/db_asc.gif | Bin 0 -> 70 bytes themes/default/images/db_desc.gif | Bin 0 -> 70 bytes themes/default/images/htaccess_error.gif | Bin 0 -> 1543 bytes themes/default/images/icons/about_16.gif | Bin 0 -> 1053 bytes themes/default/images/icons/add_16.gif | Bin 0 -> 588 bytes themes/default/images/icons/cal_16.gif | Bin 0 -> 371 bytes themes/default/images/icons/calc_16.gif | Bin 0 -> 619 bytes themes/default/images/icons/cancl_16.gif | Bin 0 -> 599 bytes themes/default/images/icons/cart_16.gif | Bin 0 -> 636 bytes themes/default/images/icons/close_16.gif | Bin 0 -> 1048 bytes themes/default/images/icons/del_16.gif | Bin 0 -> 235 bytes themes/default/images/icons/edit_16.gif | Bin 0 -> 608 bytes themes/default/images/icons/exp_16.gif | Bin 0 -> 604 bytes themes/default/images/icons/flag_16.gif | Bin 0 -> 540 bytes themes/default/images/icons/go_16.gif | Bin 0 -> 372 bytes themes/default/images/icons/group_16.gif | Bin 0 -> 1076 bytes themes/default/images/icons/help_16.gif | Bin 0 -> 1082 bytes themes/default/images/icons/image_16.gif | Bin 0 -> 586 bytes themes/default/images/icons/lock_16.gif | Bin 0 -> 378 bytes themes/default/images/icons/mail_16.gif | Bin 0 -> 368 bytes themes/default/images/icons/mail_32.gif | Bin 0 -> 1416 bytes themes/default/images/icons/print_16.gif | Bin 0 -> 630 bytes themes/default/images/icons/remov_16.gif | Bin 0 -> 312 bytes themes/default/images/icons/srch_16.gif | Bin 0 -> 591 bytes themes/default/images/icons/stop_16.gif | Bin 0 -> 607 bytes themes/default/images/icons/trash_16.gif | Bin 0 -> 661 bytes themes/default/images/icons/ulock_16.gif | Bin 0 -> 373 bytes themes/default/images/icons/user_16.gif | Bin 0 -> 599 bytes themes/default/images/icons/zoomi_16.gif | Bin 0 -> 625 bytes themes/default/images/invisible.gif | Bin 0 -> 43 bytes themes/default/images/invoice_logo.jpg | Bin 0 -> 5055 bytes themes/default/images/logo.gif | Bin 0 -> 5213 bytes themes/default/left.tpl | 158 + themes/default/search.js | 352 ++ themes/default/style.css | 187 + themes/default/template.tpl | 102 + themes/default/top.js | 139 + themes/default/user_search.js | 352 ++ themes/default_admin.admin_theme | 0 themes/default_admin/IEFrameWarningBypass.htm | 5 + themes/default_admin/blocks/core/admin.tpl | 230 + .../default_admin/blocks/core/cornerFrame.tpl | 3 + themes/default_admin/blocks/core/debug.tpl | 34 + .../blocks/core/invalid_page.tpl | 1 + .../blocks/core/leftFrameBlue.tpl | 252 + .../default_admin/blocks/core/top_clean.tpl | 62 + .../default_admin/blocks/core/top_frame.tpl | 58 + themes/default_admin/iframe.css | 145 + themes/default_admin/images/corner_back.gif | Bin 0 -> 3385 bytes themes/default_admin/images/currency/AUD.gif | Bin 0 -> 620 bytes themes/default_admin/images/currency/CAD.gif | Bin 0 -> 366 bytes themes/default_admin/images/currency/CHF.gif | Bin 0 -> 333 bytes themes/default_admin/images/currency/DKK.gif | Bin 0 -> 217 bytes themes/default_admin/images/currency/EUR.gif | Bin 0 -> 313 bytes themes/default_admin/images/currency/GBP.gif | Bin 0 -> 673 bytes themes/default_admin/images/currency/HKD.gif | Bin 0 -> 337 bytes themes/default_admin/images/currency/JPY.gif | Bin 0 -> 202 bytes themes/default_admin/images/currency/MXN.gif | Bin 0 -> 1462 bytes themes/default_admin/images/currency/MYR.gif | Bin 0 -> 1109 bytes themes/default_admin/images/currency/NOK.gif | Bin 0 -> 359 bytes themes/default_admin/images/currency/NZD.gif | Bin 0 -> 609 bytes themes/default_admin/images/currency/RUR.gif | Bin 0 -> 144 bytes themes/default_admin/images/currency/SEK.gif | Bin 0 -> 343 bytes themes/default_admin/images/currency/USD.gif | Bin 0 -> 96 bytes themes/default_admin/images/currency/ZAR.gif | Bin 0 -> 584 bytes themes/default_admin/images/db_asc.gif | Bin 0 -> 70 bytes themes/default_admin/images/db_desc.gif | Bin 0 -> 70 bytes .../default_admin/images/htaccess_error.gif | Bin 0 -> 1543 bytes .../default_admin/images/icons/about_16.gif | Bin 0 -> 1053 bytes .../default_admin/images/icons/about_24.gif | Bin 0 -> 1316 bytes .../default_admin/images/icons/about_32.gif | Bin 0 -> 1663 bytes themes/default_admin/images/icons/add_16.gif | Bin 0 -> 588 bytes themes/default_admin/images/icons/add_24.gif | Bin 0 -> 1135 bytes themes/default_admin/images/icons/add_32.gif | Bin 0 -> 1382 bytes .../default_admin/images/icons/addbk_16.gif | Bin 0 -> 373 bytes .../default_admin/images/icons/addbk_24.gif | Bin 0 -> 737 bytes .../default_admin/images/icons/addbk_32.gif | Bin 0 -> 1286 bytes .../default_admin/images/icons/adfav_16.gif | Bin 0 -> 1031 bytes .../default_admin/images/icons/adfav_24.gif | Bin 0 -> 1297 bytes .../default_admin/images/icons/adfav_32.gif | Bin 0 -> 1593 bytes themes/default_admin/images/icons/apps_16.gif | Bin 0 -> 1046 bytes themes/default_admin/images/icons/apps_24.gif | Bin 0 -> 1342 bytes themes/default_admin/images/icons/apps_32.gif | Bin 0 -> 1666 bytes themes/default_admin/images/icons/back_16.gif | Bin 0 -> 595 bytes themes/default_admin/images/icons/back_24.gif | Bin 0 -> 1116 bytes themes/default_admin/images/icons/back_32.gif | Bin 0 -> 1312 bytes themes/default_admin/images/icons/cal_16.gif | Bin 0 -> 371 bytes themes/default_admin/images/icons/cal_24.gif | Bin 0 -> 758 bytes themes/default_admin/images/icons/cal_32.gif | Bin 0 -> 1412 bytes themes/default_admin/images/icons/calc_16.gif | Bin 0 -> 619 bytes themes/default_admin/images/icons/calc_24.gif | Bin 0 -> 772 bytes themes/default_admin/images/icons/calc_32.gif | Bin 0 -> 1475 bytes .../default_admin/images/icons/cancl_16.gif | Bin 0 -> 599 bytes .../default_admin/images/icons/cancl_24.gif | Bin 0 -> 1212 bytes .../default_admin/images/icons/cancl_32.gif | Bin 0 -> 1402 bytes themes/default_admin/images/icons/cart_16.gif | Bin 0 -> 636 bytes themes/default_admin/images/icons/cart_24.gif | Bin 0 -> 1352 bytes themes/default_admin/images/icons/cart_32.gif | Bin 0 -> 1616 bytes themes/default_admin/images/icons/cd_16.gif | Bin 0 -> 664 bytes themes/default_admin/images/icons/cd_24.gif | Bin 0 -> 1397 bytes themes/default_admin/images/icons/cd_32.gif | Bin 0 -> 1777 bytes .../default_admin/images/icons/chart_16.gif | Bin 0 -> 646 bytes .../default_admin/images/icons/chart_24.gif | Bin 0 -> 1267 bytes .../default_admin/images/icons/chart_32.gif | Bin 0 -> 1603 bytes .../default_admin/images/icons/close_16.gif | Bin 0 -> 1048 bytes .../default_admin/images/icons/close_24.gif | Bin 0 -> 1276 bytes .../default_admin/images/icons/close_32.gif | Bin 0 -> 1646 bytes .../default_admin/images/icons/confg_16.gif | Bin 0 -> 625 bytes .../default_admin/images/icons/confg_24.gif | Bin 0 -> 1219 bytes .../default_admin/images/icons/confg_32.gif | Bin 0 -> 1492 bytes themes/default_admin/images/icons/copy_16.gif | Bin 0 -> 648 bytes themes/default_admin/images/icons/copy_24.gif | Bin 0 -> 1259 bytes themes/default_admin/images/icons/copy_32.gif | Bin 0 -> 1567 bytes themes/default_admin/images/icons/cut_16.gif | Bin 0 -> 628 bytes themes/default_admin/images/icons/cut_24.gif | Bin 0 -> 1265 bytes themes/default_admin/images/icons/cut_32.gif | Bin 0 -> 1512 bytes themes/default_admin/images/icons/del_16.gif | Bin 0 -> 235 bytes themes/default_admin/images/icons/del_24.gif | Bin 0 -> 1314 bytes themes/default_admin/images/icons/del_32.gif | Bin 0 -> 1558 bytes themes/default_admin/images/icons/docs_16.gif | Bin 0 -> 601 bytes themes/default_admin/images/icons/docs_24.gif | Bin 0 -> 1236 bytes themes/default_admin/images/icons/docs_32.gif | Bin 0 -> 1570 bytes themes/default_admin/images/icons/down_16.gif | Bin 0 -> 589 bytes themes/default_admin/images/icons/down_24.gif | Bin 0 -> 1124 bytes themes/default_admin/images/icons/down_32.gif | Bin 0 -> 1310 bytes themes/default_admin/images/icons/edit_16.gif | Bin 0 -> 608 bytes themes/default_admin/images/icons/edit_24.gif | Bin 0 -> 1242 bytes themes/default_admin/images/icons/edit_32.gif | Bin 0 -> 1547 bytes themes/default_admin/images/icons/exp_16.gif | Bin 0 -> 604 bytes themes/default_admin/images/icons/exp_24.gif | Bin 0 -> 1240 bytes themes/default_admin/images/icons/exp_32.gif | Bin 0 -> 1541 bytes .../default_admin/images/icons/fastf_16.gif | Bin 0 -> 345 bytes .../default_admin/images/icons/fastf_24.gif | Bin 0 -> 686 bytes .../default_admin/images/icons/fastf_32.gif | Bin 0 -> 1227 bytes themes/default_admin/images/icons/favs_16.gif | Bin 0 -> 1028 bytes themes/default_admin/images/icons/favs_24.gif | Bin 0 -> 1312 bytes themes/default_admin/images/icons/favs_32.gif | Bin 0 -> 1566 bytes themes/default_admin/images/icons/fax_16.gif | Bin 0 -> 617 bytes themes/default_admin/images/icons/fax_24.gif | Bin 0 -> 1236 bytes themes/default_admin/images/icons/fax_32.gif | Bin 0 -> 1438 bytes themes/default_admin/images/icons/flag_16.gif | Bin 0 -> 540 bytes themes/default_admin/images/icons/flag_24.gif | Bin 0 -> 1097 bytes themes/default_admin/images/icons/flag_32.gif | Bin 0 -> 1338 bytes .../default_admin/images/icons/foldr_16.gif | Bin 0 -> 1025 bytes .../default_admin/images/icons/foldr_24.gif | Bin 0 -> 1310 bytes .../default_admin/images/icons/foldr_32.gif | Bin 0 -> 1583 bytes .../default_admin/images/icons/forwd_16.gif | Bin 0 -> 597 bytes .../default_admin/images/icons/forwd_24.gif | Bin 0 -> 1117 bytes .../default_admin/images/icons/forwd_32.gif | Bin 0 -> 1307 bytes .../default_admin/images/icons/games_16.gif | Bin 0 -> 384 bytes .../default_admin/images/icons/games_24.gif | Bin 0 -> 779 bytes .../default_admin/images/icons/games_32.gif | Bin 0 -> 1478 bytes themes/default_admin/images/icons/go_16.gif | Bin 0 -> 372 bytes themes/default_admin/images/icons/go_24.gif | Bin 0 -> 1207 bytes themes/default_admin/images/icons/go_32.gif | Bin 0 -> 1462 bytes .../default_admin/images/icons/group_16.gif | Bin 0 -> 1076 bytes .../default_admin/images/icons/group_24.gif | Bin 0 -> 1356 bytes .../default_admin/images/icons/group_32.gif | Bin 0 -> 1627 bytes themes/default_admin/images/icons/hd_16.gif | Bin 0 -> 644 bytes themes/default_admin/images/icons/hd_24.gif | Bin 0 -> 1292 bytes themes/default_admin/images/icons/hd_32.gif | Bin 0 -> 1568 bytes themes/default_admin/images/icons/help_16.gif | Bin 0 -> 1082 bytes themes/default_admin/images/icons/help_24.gif | Bin 0 -> 1418 bytes themes/default_admin/images/icons/help_32.gif | Bin 0 -> 1614 bytes themes/default_admin/images/icons/hist_16.gif | Bin 0 -> 1032 bytes themes/default_admin/images/icons/hist_24.gif | Bin 0 -> 1350 bytes themes/default_admin/images/icons/hist_32.gif | Bin 0 -> 1681 bytes themes/default_admin/images/icons/home_16.gif | Bin 0 -> 380 bytes themes/default_admin/images/icons/home_24.gif | Bin 0 -> 325 bytes themes/default_admin/images/icons/home_32.gif | Bin 0 -> 1311 bytes .../default_admin/images/icons/image_16.gif | Bin 0 -> 586 bytes .../default_admin/images/icons/image_24.gif | Bin 0 -> 1176 bytes .../default_admin/images/icons/image_32.gif | Bin 0 -> 1485 bytes themes/default_admin/images/icons/impt_16.gif | Bin 0 -> 1026 bytes themes/default_admin/images/icons/impt_24.gif | Bin 0 -> 1301 bytes themes/default_admin/images/icons/impt_32.gif | Bin 0 -> 1562 bytes .../default_admin/images/icons/lgicn_16.gif | Bin 0 -> 1065 bytes .../default_admin/images/icons/lgicn_24.gif | Bin 0 -> 1330 bytes .../default_admin/images/icons/lgicn_32.gif | Bin 0 -> 1755 bytes themes/default_admin/images/icons/lock_16.gif | Bin 0 -> 378 bytes themes/default_admin/images/icons/lock_24.gif | Bin 0 -> 704 bytes themes/default_admin/images/icons/lock_32.gif | Bin 0 -> 1375 bytes themes/default_admin/images/icons/mail_16.gif | Bin 0 -> 368 bytes themes/default_admin/images/icons/mail_24.gif | Bin 0 -> 731 bytes themes/default_admin/images/icons/mail_32.gif | Bin 0 -> 1416 bytes themes/default_admin/images/icons/move_16.gif | Bin 0 -> 1048 bytes themes/default_admin/images/icons/move_24.gif | Bin 0 -> 1222 bytes themes/default_admin/images/icons/move_32.gif | Bin 0 -> 1553 bytes .../default_admin/images/icons/music_16.gif | Bin 0 -> 613 bytes .../default_admin/images/icons/music_24.gif | Bin 0 -> 1235 bytes .../default_admin/images/icons/music_32.gif | Bin 0 -> 1296 bytes themes/default_admin/images/icons/new_16.gif | Bin 0 -> 1062 bytes themes/default_admin/images/icons/new_24.gif | Bin 0 -> 1348 bytes themes/default_admin/images/icons/new_32.gif | Bin 0 -> 1678 bytes .../default_admin/images/icons/notep_16.gif | Bin 0 -> 630 bytes .../default_admin/images/icons/notep_24.gif | Bin 0 -> 1231 bytes .../default_admin/images/icons/notep_32.gif | Bin 0 -> 1565 bytes .../default_admin/images/icons/ntwrk_16.gif | Bin 0 -> 1049 bytes .../default_admin/images/icons/ntwrk_24.gif | Bin 0 -> 1312 bytes .../default_admin/images/icons/ntwrk_32.gif | Bin 0 -> 1568 bytes themes/default_admin/images/icons/open_16.gif | Bin 0 -> 625 bytes themes/default_admin/images/icons/open_24.gif | Bin 0 -> 1317 bytes themes/default_admin/images/icons/open_32.gif | Bin 0 -> 1593 bytes .../default_admin/images/icons/opnbr_16.gif | Bin 0 -> 625 bytes .../default_admin/images/icons/opnbr_24.gif | Bin 0 -> 1226 bytes .../default_admin/images/icons/opnbr_32.gif | Bin 0 -> 1422 bytes themes/default_admin/images/icons/opts_16.gif | Bin 0 -> 609 bytes themes/default_admin/images/icons/opts_24.gif | Bin 0 -> 752 bytes themes/default_admin/images/icons/opts_32.gif | Bin 0 -> 848 bytes .../default_admin/images/icons/paint_16.gif | Bin 0 -> 605 bytes .../default_admin/images/icons/paint_24.gif | Bin 0 -> 1216 bytes .../default_admin/images/icons/paint_32.gif | Bin 0 -> 1381 bytes .../default_admin/images/icons/paste_16.gif | Bin 0 -> 1060 bytes .../default_admin/images/icons/paste_24.gif | Bin 0 -> 1340 bytes .../default_admin/images/icons/paste_32.gif | Bin 0 -> 1626 bytes .../default_admin/images/icons/pause_16.gif | Bin 0 -> 369 bytes .../default_admin/images/icons/pause_24.gif | Bin 0 -> 708 bytes .../default_admin/images/icons/pause_32.gif | Bin 0 -> 1352 bytes .../default_admin/images/icons/phone_16.gif | Bin 0 -> 377 bytes .../default_admin/images/icons/phone_24.gif | Bin 0 -> 1141 bytes .../default_admin/images/icons/phone_32.gif | Bin 0 -> 1255 bytes .../default_admin/images/icons/picts_16.gif | Bin 0 -> 596 bytes .../default_admin/images/icons/picts_24.gif | Bin 0 -> 1242 bytes .../default_admin/images/icons/picts_32.gif | Bin 0 -> 1579 bytes themes/default_admin/images/icons/play_16.gif | Bin 0 -> 1023 bytes themes/default_admin/images/icons/play_24.gif | Bin 0 -> 1281 bytes themes/default_admin/images/icons/play_32.gif | Bin 0 -> 1550 bytes .../default_admin/images/icons/prefs_16.gif | Bin 0 -> 1048 bytes .../default_admin/images/icons/prefs_24.gif | Bin 0 -> 1307 bytes .../default_admin/images/icons/prefs_32.gif | Bin 0 -> 1696 bytes .../default_admin/images/icons/print_16.gif | Bin 0 -> 630 bytes .../default_admin/images/icons/print_24.gif | Bin 0 -> 1320 bytes .../default_admin/images/icons/print_32.gif | Bin 0 -> 1468 bytes .../default_admin/images/icons/prtpv_16.gif | Bin 0 -> 1051 bytes .../default_admin/images/icons/prtpv_24.gif | Bin 0 -> 1353 bytes .../default_admin/images/icons/prtpv_32.gif | Bin 0 -> 1616 bytes themes/default_admin/images/icons/redo_16.gif | Bin 0 -> 598 bytes themes/default_admin/images/icons/redo_24.gif | Bin 0 -> 705 bytes themes/default_admin/images/icons/redo_32.gif | Bin 0 -> 1301 bytes themes/default_admin/images/icons/ref_16.gif | Bin 0 -> 618 bytes themes/default_admin/images/icons/ref_24.gif | Bin 0 -> 820 bytes themes/default_admin/images/icons/ref_32.gif | Bin 0 -> 1112 bytes .../default_admin/images/icons/remov_16.gif | Bin 0 -> 312 bytes .../default_admin/images/icons/remov_24.gif | Bin 0 -> 596 bytes .../default_admin/images/icons/remov_32.gif | Bin 0 -> 710 bytes .../default_admin/images/icons/rewnd_16.gif | Bin 0 -> 352 bytes .../default_admin/images/icons/rewnd_24.gif | Bin 0 -> 687 bytes .../default_admin/images/icons/rewnd_32.gif | Bin 0 -> 1236 bytes .../default_admin/images/icons/savas_16.gif | Bin 0 -> 1058 bytes .../default_admin/images/icons/savas_24.gif | Bin 0 -> 1333 bytes .../default_admin/images/icons/savas_32.gif | Bin 0 -> 1627 bytes themes/default_admin/images/icons/save_16.gif | Bin 0 -> 1057 bytes themes/default_admin/images/icons/save_24.gif | Bin 0 -> 1336 bytes themes/default_admin/images/icons/save_32.gif | Bin 0 -> 1638 bytes .../default_admin/images/icons/sinfo_16.gif | Bin 0 -> 361 bytes .../default_admin/images/icons/sinfo_24.gif | Bin 0 -> 718 bytes .../default_admin/images/icons/sinfo_32.gif | Bin 0 -> 829 bytes .../default_admin/images/icons/skipb_16.gif | Bin 0 -> 1040 bytes .../default_admin/images/icons/skipb_24.gif | Bin 0 -> 1194 bytes .../default_admin/images/icons/skipb_32.gif | Bin 0 -> 1407 bytes .../default_admin/images/icons/skipf_16.gif | Bin 0 -> 1039 bytes .../default_admin/images/icons/skipf_24.gif | Bin 0 -> 1194 bytes .../default_admin/images/icons/skipf_32.gif | Bin 0 -> 1407 bytes .../default_admin/images/icons/smicn_16.gif | Bin 0 -> 646 bytes .../default_admin/images/icons/smicn_24.gif | Bin 0 -> 1245 bytes .../default_admin/images/icons/smicn_32.gif | Bin 0 -> 1528 bytes .../default_admin/images/icons/splay_16.gif | Bin 0 -> 589 bytes .../default_admin/images/icons/splay_24.gif | Bin 0 -> 749 bytes .../default_admin/images/icons/splay_32.gif | Bin 0 -> 1441 bytes themes/default_admin/images/icons/srch_16.gif | Bin 0 -> 591 bytes themes/default_admin/images/icons/srch_24.gif | Bin 0 -> 1147 bytes themes/default_admin/images/icons/srch_32.gif | Bin 0 -> 1330 bytes themes/default_admin/images/icons/stop_16.gif | Bin 0 -> 607 bytes themes/default_admin/images/icons/stop_24.gif | Bin 0 -> 1269 bytes themes/default_admin/images/icons/stop_32.gif | Bin 0 -> 1316 bytes .../default_admin/images/icons/timer_16.gif | Bin 0 -> 1064 bytes .../default_admin/images/icons/timer_24.gif | Bin 0 -> 1410 bytes .../default_admin/images/icons/timer_32.gif | Bin 0 -> 1728 bytes .../default_admin/images/icons/tools_16.gif | Bin 0 -> 569 bytes .../default_admin/images/icons/tools_24.gif | Bin 0 -> 1086 bytes .../default_admin/images/icons/tools_32.gif | Bin 0 -> 1280 bytes .../default_admin/images/icons/trash_16.gif | Bin 0 -> 661 bytes .../default_admin/images/icons/trash_24.gif | Bin 0 -> 1343 bytes .../default_admin/images/icons/trash_32.gif | Bin 0 -> 1785 bytes .../default_admin/images/icons/ulock_16.gif | Bin 0 -> 373 bytes .../default_admin/images/icons/ulock_24.gif | Bin 0 -> 704 bytes .../default_admin/images/icons/ulock_32.gif | Bin 0 -> 1388 bytes themes/default_admin/images/icons/undo_16.gif | Bin 0 -> 598 bytes themes/default_admin/images/icons/undo_24.gif | Bin 0 -> 703 bytes themes/default_admin/images/icons/undo_32.gif | Bin 0 -> 1304 bytes themes/default_admin/images/icons/up_16.gif | Bin 0 -> 605 bytes themes/default_admin/images/icons/up_24.gif | Bin 0 -> 1159 bytes themes/default_admin/images/icons/up_32.gif | Bin 0 -> 1386 bytes themes/default_admin/images/icons/user_16.gif | Bin 0 -> 599 bytes themes/default_admin/images/icons/user_24.gif | Bin 0 -> 1197 bytes themes/default_admin/images/icons/user_32.gif | Bin 0 -> 1425 bytes themes/default_admin/images/icons/web_16.gif | Bin 0 -> 1050 bytes themes/default_admin/images/icons/web_24.gif | Bin 0 -> 1311 bytes themes/default_admin/images/icons/web_32.gif | Bin 0 -> 1611 bytes themes/default_admin/images/icons/wiz_16.gif | Bin 0 -> 1044 bytes themes/default_admin/images/icons/wiz_24.gif | Bin 0 -> 1290 bytes themes/default_admin/images/icons/wiz_32.gif | Bin 0 -> 1386 bytes .../default_admin/images/icons/zoomi_16.gif | Bin 0 -> 625 bytes .../default_admin/images/icons/zoomi_24.gif | Bin 0 -> 1201 bytes .../default_admin/images/icons/zoomi_32.gif | Bin 0 -> 1391 bytes .../default_admin/images/icons/zoomo_16.gif | Bin 0 -> 619 bytes .../default_admin/images/icons/zoomo_24.gif | Bin 0 -> 1186 bytes .../default_admin/images/icons/zoomo_32.gif | Bin 0 -> 1368 bytes themes/default_admin/images/invisible.gif | Bin 0 -> 43 bytes themes/default_admin/images/logo.gif | Bin 0 -> 2720 bytes themes/default_admin/report_style.css | 131 + themes/default_admin/search.js | 368 ++ themes/default_admin/style.css | 168 + themes/default_admin/template.tpl | 20 + themes/default_admin/top.js | 138 + themes/default_admin/view.js | 64 + 2954 files changed, 410976 insertions(+) create mode 100644 LICENSE create mode 100644 admin.php create mode 100644 ajax.php create mode 100644 config.inc.php create mode 100644 cookie.index.php create mode 100644 htaccess_index.php create mode 100644 includes/adodb/adodb-csvlib.inc.php create mode 100644 includes/adodb/adodb-datadict.inc.php create mode 100644 includes/adodb/adodb-error.inc.php create mode 100644 includes/adodb/adodb-errorhandler.inc.php create mode 100644 includes/adodb/adodb-errorpear.inc.php create mode 100644 includes/adodb/adodb-exceptions.inc.php create mode 100644 includes/adodb/adodb-iterator.inc.php create mode 100644 includes/adodb/adodb-lib.inc.php create mode 100644 includes/adodb/adodb-pager.inc.php create mode 100644 includes/adodb/adodb-pear.inc.php create mode 100644 includes/adodb/adodb-perf.inc.php create mode 100644 includes/adodb/adodb-php4.inc.php create mode 100644 includes/adodb/adodb-time.inc.php create mode 100644 includes/adodb/adodb-xmlschema.inc.php create mode 100644 includes/adodb/adodb-xmlschema03.inc.php create mode 100644 includes/adodb/adodb.inc.php create mode 100644 includes/adodb/datadict/datadict-access.inc.php create mode 100644 includes/adodb/datadict/datadict-db2.inc.php create mode 100644 includes/adodb/datadict/datadict-firebird.inc.php create mode 100644 includes/adodb/datadict/datadict-generic.inc.php create mode 100644 includes/adodb/datadict/datadict-ibase.inc.php create mode 100644 includes/adodb/datadict/datadict-informix.inc.php create mode 100644 includes/adodb/datadict/datadict-mssql.inc.php create mode 100644 includes/adodb/datadict/datadict-mssqlnative.inc.php create mode 100644 includes/adodb/datadict/datadict-mysql.inc.php create mode 100644 includes/adodb/datadict/datadict-oci8.inc.php create mode 100644 includes/adodb/datadict/datadict-postgres.inc.php create mode 100644 includes/adodb/datadict/datadict-postgres.inc.php.bak create mode 100644 includes/adodb/datadict/datadict-sapdb.inc.php create mode 100644 includes/adodb/datadict/datadict-sybase.inc.php create mode 100644 includes/adodb/drivers/adodb-access.inc.php create mode 100644 includes/adodb/drivers/adodb-ado.inc.php create mode 100644 includes/adodb/drivers/adodb-ado5.inc.php create mode 100644 includes/adodb/drivers/adodb-ado_access.inc.php create mode 100644 includes/adodb/drivers/adodb-ado_mssql.inc.php create mode 100644 includes/adodb/drivers/adodb-borland_ibase.inc.php create mode 100644 includes/adodb/drivers/adodb-csv.inc.php create mode 100644 includes/adodb/drivers/adodb-db2.inc.php create mode 100644 includes/adodb/drivers/adodb-fbsql.inc.php create mode 100644 includes/adodb/drivers/adodb-firebird.inc.php create mode 100644 includes/adodb/drivers/adodb-ibase.inc.php create mode 100644 includes/adodb/drivers/adodb-informix.inc.php create mode 100644 includes/adodb/drivers/adodb-informix72.inc.php create mode 100644 includes/adodb/drivers/adodb-ldap.inc.php create mode 100644 includes/adodb/drivers/adodb-mssql.inc.php create mode 100644 includes/adodb/drivers/adodb-mssql_n.inc.php create mode 100644 includes/adodb/drivers/adodb-mssqlnative.inc.php create mode 100644 includes/adodb/drivers/adodb-mssqlpo.inc.php create mode 100644 includes/adodb/drivers/adodb-mysql.inc.php create mode 100644 includes/adodb/drivers/adodb-mysqli.inc.php create mode 100644 includes/adodb/drivers/adodb-mysqlpo.inc.php create mode 100644 includes/adodb/drivers/adodb-mysqlt.inc.php create mode 100644 includes/adodb/drivers/adodb-netezza.inc.php create mode 100644 includes/adodb/drivers/adodb-oci8.inc.php create mode 100644 includes/adodb/drivers/adodb-oci8.old.inc.php create mode 100644 includes/adodb/drivers/adodb-oci805.inc.php create mode 100644 includes/adodb/drivers/adodb-oci8po.inc.php create mode 100644 includes/adodb/drivers/adodb-odbc.inc.php create mode 100644 includes/adodb/drivers/adodb-odbc_db2.inc.php create mode 100644 includes/adodb/drivers/adodb-odbc_mssql.inc.php create mode 100644 includes/adodb/drivers/adodb-odbc_oracle.inc.php create mode 100644 includes/adodb/drivers/adodb-odbtp.inc.php create mode 100644 includes/adodb/drivers/adodb-odbtp_unicode.inc.php create mode 100644 includes/adodb/drivers/adodb-oracle.inc.php create mode 100644 includes/adodb/drivers/adodb-pdo.inc.php create mode 100644 includes/adodb/drivers/adodb-pdo_mssql.inc.php create mode 100644 includes/adodb/drivers/adodb-pdo_mysql.inc.php create mode 100644 includes/adodb/drivers/adodb-pdo_oci.inc.php create mode 100644 includes/adodb/drivers/adodb-pdo_pgsql.inc.php create mode 100644 includes/adodb/drivers/adodb-pdo_sqlite.inc.php create mode 100644 includes/adodb/drivers/adodb-postgres.inc.php create mode 100644 includes/adodb/drivers/adodb-postgres64.inc.php create mode 100644 includes/adodb/drivers/adodb-postgres7.inc.php create mode 100644 includes/adodb/drivers/adodb-postgres8.inc.php create mode 100644 includes/adodb/drivers/adodb-proxy.inc.php create mode 100644 includes/adodb/drivers/adodb-sapdb.inc.php create mode 100644 includes/adodb/drivers/adodb-sqlanywhere.inc.php create mode 100644 includes/adodb/drivers/adodb-sqlite.inc.php create mode 100644 includes/adodb/drivers/adodb-sqlitepo.inc.php create mode 100644 includes/adodb/drivers/adodb-sybase.inc.php create mode 100644 includes/adodb/drivers/adodb-sybase_ase.inc.php create mode 100644 includes/adodb/drivers/adodb-vfp.inc.php create mode 100644 includes/adodb/lang/adodb-ar.inc.php create mode 100644 includes/adodb/lang/adodb-bg.inc.php create mode 100644 includes/adodb/lang/adodb-bgutf8.inc.php create mode 100644 includes/adodb/lang/adodb-ca.inc.php create mode 100644 includes/adodb/lang/adodb-cn.inc.php create mode 100644 includes/adodb/lang/adodb-cz.inc.php create mode 100644 includes/adodb/lang/adodb-da.inc.php create mode 100644 includes/adodb/lang/adodb-de.inc.php create mode 100644 includes/adodb/lang/adodb-en.inc.php create mode 100644 includes/adodb/lang/adodb-es.inc.php create mode 100644 includes/adodb/lang/adodb-esperanto.inc.php create mode 100644 includes/adodb/lang/adodb-fa.inc.php create mode 100644 includes/adodb/lang/adodb-fr.inc.php create mode 100644 includes/adodb/lang/adodb-hu.inc.php create mode 100644 includes/adodb/lang/adodb-it.inc.php create mode 100644 includes/adodb/lang/adodb-nl.inc.php create mode 100644 includes/adodb/lang/adodb-pl.inc.php create mode 100644 includes/adodb/lang/adodb-pt-br.inc.php create mode 100644 includes/adodb/lang/adodb-ro.inc.php create mode 100644 includes/adodb/lang/adodb-ru1251.inc.php create mode 100644 includes/adodb/lang/adodb-sv.inc.php create mode 100644 includes/adodb/lang/adodb-uk1251.inc.php create mode 100644 includes/adodb/lang/adodb_th.inc.php create mode 100644 includes/adodb/license.txt create mode 100644 includes/adodb/pear/Auth/Container/ADOdb.php create mode 100644 includes/adodb/pear/readme.Auth.txt create mode 100644 includes/adodb/pivottable.inc.php create mode 100644 includes/adodb/readme.txt create mode 100644 includes/adodb/rsfilter.inc.php create mode 100644 includes/adodb/server.php create mode 100644 includes/adodb/toexport.inc.php create mode 100644 includes/aptree/apytmenu.js create mode 100644 includes/aptree/img/blank.gif create mode 100644 includes/aptree/img/collapsebtn.gif create mode 100644 includes/aptree/img/collapsebtn2.gif create mode 100644 includes/aptree/img/cpoint.gif create mode 100644 includes/aptree/img/expandbtn.gif create mode 100644 includes/aptree/img/expandbtn2.gif create mode 100644 includes/aptree/img/hpoint.gif create mode 100644 includes/aptree/img/icons/contacts.gif create mode 100644 includes/aptree/img/icons/email.gif create mode 100644 includes/aptree/img/icons/folder1.gif create mode 100644 includes/aptree/img/icons/folder2.gif create mode 100644 includes/aptree/img/icons/help1.gif create mode 100644 includes/aptree/img/icons/help2.gif create mode 100644 includes/aptree/img/icons/info.gif create mode 100644 includes/aptree/img/icons/list.gif create mode 100644 includes/aptree/img/icons/paper.gif create mode 100644 includes/aptree/img/icons/search.gif create mode 100644 includes/aptree/img/icons/support.gif create mode 100644 includes/aptree/img/movepic.gif create mode 100644 includes/aptree/img/pointcorner.gif create mode 100644 includes/aptree/img/topborder.gif create mode 100644 includes/aptree/img/vpoint.gif create mode 100644 includes/aptree/img/xpcollapse1.gif create mode 100644 includes/aptree/img/xpcollapse2.gif create mode 100644 includes/aptree/img/xpcollapse3.gif create mode 100644 includes/aptree/img/xpcollapse4.gif create mode 100644 includes/aptree/img/xpexpand1.gif create mode 100644 includes/aptree/img/xpexpand2.gif create mode 100644 includes/aptree/img/xpexpand3.gif create mode 100644 includes/aptree/img/xpexpand4.gif create mode 100644 includes/aptree/img/xpicon1.gif create mode 100644 includes/aptree/img/xptitle.gif create mode 100644 includes/aptree/img/xptitle2.gif create mode 100644 includes/aptree/img/xptitleleft.gif create mode 100644 includes/aptree/img/xpvertline.gif create mode 100644 includes/aptree/tmenu1.js create mode 100644 includes/aptree/tstyles.css create mode 100644 includes/aptree/txpmenu-item-visibility.js create mode 100644 includes/aptree/txpmenu1.js create mode 100644 includes/aptree/txpmenu3.js create mode 100644 includes/cron/cron.inc.php create mode 100644 includes/cron/lgpl.txt create mode 100644 includes/files/.htaccess create mode 100644 includes/files/reports/.htaccess create mode 100644 includes/files/tracking.txt create mode 100644 includes/javascript/MIT-LICENSE create mode 100644 includes/javascript/controls.js create mode 100644 includes/javascript/dragdrop.js create mode 100644 includes/javascript/effects.js create mode 100644 includes/javascript/prototype.js create mode 100644 includes/jscalendar/README.txt create mode 100644 includes/jscalendar/calendar-blue.css create mode 100644 includes/jscalendar/calendar-setup_stripped.js create mode 100644 includes/jscalendar/calendar_stripped.js create mode 100644 includes/jscalendar/img.gif create mode 100644 includes/jscalendar/lang/calendar-cs-win.js create mode 100644 includes/jscalendar/lang/calendar-english.js create mode 100644 includes/jscalendar/lang/calendar-french.js create mode 100644 includes/jscalendar/lang/calendar-german.js create mode 100644 includes/jscalendar/lang/calendar-italian.js create mode 100644 includes/jscalendar/lang/calendar-russian.js create mode 100644 includes/jscalendar/lang/calendar-spanish.js create mode 100644 includes/jscalendar/menuarrow.gif create mode 100644 includes/overlib/mini/overlib_anchor_mini.js create mode 100644 includes/overlib/mini/overlib_crossframe_mini.js create mode 100644 includes/overlib/mini/overlib_cssstyle_mini.js create mode 100644 includes/overlib/mini/overlib_exclusive_mini.js create mode 100644 includes/overlib/mini/overlib_followscroll_mini.js create mode 100644 includes/overlib/mini/overlib_hideform_mini.js create mode 100644 includes/overlib/mini/overlib_mini.js create mode 100644 includes/overlib/mini/overlib_shadow_mini.js create mode 100644 includes/overlib/overlib.js create mode 100644 includes/overlib/overlib_anchor.js create mode 100644 includes/overlib/overlib_crossframe.js create mode 100644 includes/overlib/overlib_cssstyle.js create mode 100644 includes/overlib/overlib_exclusive.js create mode 100644 includes/overlib/overlib_followscroll.js create mode 100644 includes/overlib/overlib_hideform.js create mode 100644 includes/overlib/overlib_shadow.js create mode 100644 includes/pdf/LICENSE create mode 100644 includes/pdf/decoders/ascii85.php create mode 100644 includes/pdf/decoders/lzw.php create mode 100644 includes/pdf/font/courier.php create mode 100644 includes/pdf/font/helvetica.php create mode 100644 includes/pdf/font/helveticab.php create mode 100644 includes/pdf/font/helveticabi.php create mode 100644 includes/pdf/font/helveticai.php create mode 100644 includes/pdf/font/symbol.php create mode 100644 includes/pdf/font/times.php create mode 100644 includes/pdf/font/timesb.php create mode 100644 includes/pdf/font/timesbi.php create mode 100644 includes/pdf/font/timesi.php create mode 100644 includes/pdf/font/zapfdingbats.php create mode 100644 includes/pdf/fpdf.php create mode 100644 includes/pdf/fpdf_tpl.php create mode 100644 includes/pdf/fpdi.php create mode 100644 includes/pdf/fpdi_pdf_parser.php create mode 100644 includes/pdf/invoice.pdf create mode 100644 includes/pdf/invoice1.pdf create mode 100644 includes/pdf/invoice2.pdf create mode 100644 includes/pdf/invoice_backup.pdf create mode 100644 includes/pdf/invoice_base.inc.php create mode 100644 includes/pdf/pdf_context.php create mode 100644 includes/pdf/pdf_invoice_overview.inc.php create mode 100644 includes/pdf/pdf_invoice_voip-detailed.inc.php create mode 100644 includes/pdf/pdf_invoice_voip.inc.php create mode 100644 includes/pdf/pdf_parser.php create mode 100644 includes/pdf/wrapper_functions.php create mode 100644 includes/pear/Compat.php create mode 100644 includes/pear/Compat/Components.php create mode 100644 includes/pear/Compat/Constant/E_STRICT.php create mode 100644 includes/pear/Compat/Constant/FILE.php create mode 100644 includes/pear/Compat/Constant/PHP_EOL.php create mode 100644 includes/pear/Compat/Constant/STD.php create mode 100644 includes/pear/Compat/Constant/T.php create mode 100644 includes/pear/Compat/Constant/UPLOAD_ERR.php create mode 100644 includes/pear/Compat/Function/array_combine.php create mode 100644 includes/pear/Compat/Function/array_diff_assoc.php create mode 100644 includes/pear/Compat/Function/array_diff_key.php create mode 100644 includes/pear/Compat/Function/array_diff_uassoc.php create mode 100644 includes/pear/Compat/Function/array_diff_ukey.php create mode 100644 includes/pear/Compat/Function/array_intersect_assoc.php create mode 100644 includes/pear/Compat/Function/array_intersect_key.php create mode 100644 includes/pear/Compat/Function/array_intersect_uassoc.php create mode 100644 includes/pear/Compat/Function/array_intersect_ukey.php create mode 100644 includes/pear/Compat/Function/array_udiff.php create mode 100644 includes/pear/Compat/Function/array_udiff_assoc.php create mode 100644 includes/pear/Compat/Function/array_udiff_uassoc.php create mode 100644 includes/pear/Compat/Function/array_uintersect.php create mode 100644 includes/pear/Compat/Function/array_uintersect_assoc.php create mode 100644 includes/pear/Compat/Function/array_uintersect_uassoc.php create mode 100644 includes/pear/Compat/Function/array_walk_recursive.php create mode 100644 includes/pear/Compat/Function/clone.php create mode 100644 includes/pear/Compat/Function/convert_uudecode.php create mode 100644 includes/pear/Compat/Function/convert_uuencode.php create mode 100644 includes/pear/Compat/Function/debug_print_backtrace.php create mode 100644 includes/pear/Compat/Function/file_get_contents.php create mode 100644 includes/pear/Compat/Function/file_put_contents.php create mode 100644 includes/pear/Compat/Function/fprintf.php create mode 100644 includes/pear/Compat/Function/get_headers.php create mode 100644 includes/pear/Compat/Function/get_include_path.php create mode 100644 includes/pear/Compat/Function/html_entity_decode.php create mode 100644 includes/pear/Compat/Function/http_build_query.php create mode 100644 includes/pear/Compat/Function/image_type_to_mime_type.php create mode 100644 includes/pear/Compat/Function/ob_get_clean.php create mode 100644 includes/pear/Compat/Function/ob_get_flush.php create mode 100644 includes/pear/Compat/Function/php_strip_whitespace.php create mode 100644 includes/pear/Compat/Function/restore_include_path.php create mode 100644 includes/pear/Compat/Function/scandir.php create mode 100644 includes/pear/Compat/Function/set_include_path.php create mode 100644 includes/pear/Compat/Function/str_ireplace.php create mode 100644 includes/pear/Compat/Function/str_shuffle.php create mode 100644 includes/pear/Compat/Function/str_split.php create mode 100644 includes/pear/Compat/Function/str_word_count.php create mode 100644 includes/pear/Compat/Function/stripos.php create mode 100644 includes/pear/Compat/Function/strpbrk.php create mode 100644 includes/pear/Compat/Function/strripos.php create mode 100644 includes/pear/Compat/Function/substr_compare.php create mode 100644 includes/pear/Image/Canvas.php create mode 100644 includes/pear/Image/Canvas/Color.php create mode 100644 includes/pear/Image/Canvas/Fonts/README create mode 100644 includes/pear/Image/Canvas/Fonts/fontmap.txt create mode 100644 includes/pear/Image/Canvas/GD.php create mode 100644 includes/pear/Image/Canvas/GD/JPG.php create mode 100644 includes/pear/Image/Canvas/GD/PNG.php create mode 100644 includes/pear/Image/Canvas/ImageMap.php create mode 100644 includes/pear/Image/Canvas/PDF.php create mode 100644 includes/pear/Image/Canvas/SVG.php create mode 100644 includes/pear/Image/Canvas/Tool.php create mode 100644 includes/pear/Image/Canvas/WithMap.php create mode 100644 includes/pear/Image/Color.php create mode 100644 includes/pear/Image/Graph.php create mode 100644 includes/pear/Image/Graph/Axis.php create mode 100644 includes/pear/Image/Graph/Axis/Category.php create mode 100644 includes/pear/Image/Graph/Axis/Logarithmic.php create mode 100644 includes/pear/Image/Graph/Axis/Marker/Area.php create mode 100644 includes/pear/Image/Graph/Axis/Marker/Line.php create mode 100644 includes/pear/Image/Graph/Axis/Radar.php create mode 100644 includes/pear/Image/Graph/Common.php create mode 100644 includes/pear/Image/Graph/Config.php create mode 100644 includes/pear/Image/Graph/Constants.php create mode 100644 includes/pear/Image/Graph/DataPreprocessor.php create mode 100644 includes/pear/Image/Graph/DataPreprocessor/Array.php create mode 100644 includes/pear/Image/Graph/DataPreprocessor/Currency.php create mode 100644 includes/pear/Image/Graph/DataPreprocessor/Date.php create mode 100644 includes/pear/Image/Graph/DataPreprocessor/Formatted.php create mode 100644 includes/pear/Image/Graph/DataPreprocessor/Function.php create mode 100644 includes/pear/Image/Graph/DataPreprocessor/NumberText.php create mode 100644 includes/pear/Image/Graph/DataPreprocessor/RomanNumerals.php create mode 100644 includes/pear/Image/Graph/DataPreprocessor/Sequential.php create mode 100644 includes/pear/Image/Graph/DataSelector.php create mode 100644 includes/pear/Image/Graph/DataSelector/EveryNthPoint.php create mode 100644 includes/pear/Image/Graph/DataSelector/NoZeros.php create mode 100644 includes/pear/Image/Graph/DataSelector/Values.php create mode 100644 includes/pear/Image/Graph/Dataset.php create mode 100644 includes/pear/Image/Graph/Dataset/Function.php create mode 100644 includes/pear/Image/Graph/Dataset/Random.php create mode 100644 includes/pear/Image/Graph/Dataset/Sequential.php create mode 100644 includes/pear/Image/Graph/Dataset/Trivial.php create mode 100644 includes/pear/Image/Graph/Dataset/VectorFunction.php create mode 100644 includes/pear/Image/Graph/Element.php create mode 100644 includes/pear/Image/Graph/Figure/Circle.php create mode 100644 includes/pear/Image/Graph/Figure/Ellipse.php create mode 100644 includes/pear/Image/Graph/Figure/Polygon.php create mode 100644 includes/pear/Image/Graph/Figure/Rectangle.php create mode 100644 includes/pear/Image/Graph/Fill.php create mode 100644 includes/pear/Image/Graph/Fill/Array.php create mode 100644 includes/pear/Image/Graph/Fill/Gradient.php create mode 100644 includes/pear/Image/Graph/Fill/Image.php create mode 100644 includes/pear/Image/Graph/Font.php create mode 100644 includes/pear/Image/Graph/Grid.php create mode 100644 includes/pear/Image/Graph/Grid/Bars.php create mode 100644 includes/pear/Image/Graph/Grid/Lines.php create mode 100644 includes/pear/Image/Graph/Grid/Polar.php create mode 100644 includes/pear/Image/Graph/Images/Icons/pinpoint.png create mode 100644 includes/pear/Image/Graph/Images/Icons/pinpointr.png create mode 100644 includes/pear/Image/Graph/Images/Maps/README create mode 100644 includes/pear/Image/Graph/Layout.php create mode 100644 includes/pear/Image/Graph/Layout/Horizontal.php create mode 100644 includes/pear/Image/Graph/Layout/Matrix.php create mode 100644 includes/pear/Image/Graph/Layout/Vertical.php create mode 100644 includes/pear/Image/Graph/Legend.php create mode 100644 includes/pear/Image/Graph/Line/Array.php create mode 100644 includes/pear/Image/Graph/Line/Dashed.php create mode 100644 includes/pear/Image/Graph/Line/Dotted.php create mode 100644 includes/pear/Image/Graph/Line/Formatted.php create mode 100644 includes/pear/Image/Graph/Line/Solid.php create mode 100644 includes/pear/Image/Graph/Logo.php create mode 100644 includes/pear/Image/Graph/Marker.php create mode 100644 includes/pear/Image/Graph/Marker/Array.php create mode 100644 includes/pear/Image/Graph/Marker/Asterisk.php create mode 100644 includes/pear/Image/Graph/Marker/Average.php create mode 100644 includes/pear/Image/Graph/Marker/Box.php create mode 100644 includes/pear/Image/Graph/Marker/Bubble.php create mode 100644 includes/pear/Image/Graph/Marker/Circle.php create mode 100644 includes/pear/Image/Graph/Marker/Cross.php create mode 100644 includes/pear/Image/Graph/Marker/Diamond.php create mode 100644 includes/pear/Image/Graph/Marker/Icon.php create mode 100644 includes/pear/Image/Graph/Marker/Pinpoint.php create mode 100644 includes/pear/Image/Graph/Marker/Plus.php create mode 100644 includes/pear/Image/Graph/Marker/Pointing.php create mode 100644 includes/pear/Image/Graph/Marker/Pointing/Angular.php create mode 100644 includes/pear/Image/Graph/Marker/Pointing/Radial.php create mode 100644 includes/pear/Image/Graph/Marker/ReversePinpoint.php create mode 100644 includes/pear/Image/Graph/Marker/Star.php create mode 100644 includes/pear/Image/Graph/Marker/Triangle.php create mode 100644 includes/pear/Image/Graph/Marker/Value.php create mode 100644 includes/pear/Image/Graph/Plot.php create mode 100644 includes/pear/Image/Graph/Plot/Area.php create mode 100644 includes/pear/Image/Graph/Plot/Band.php create mode 100644 includes/pear/Image/Graph/Plot/Bar.php create mode 100644 includes/pear/Image/Graph/Plot/BoxWhisker.php create mode 100644 includes/pear/Image/Graph/Plot/CandleStick.php create mode 100644 includes/pear/Image/Graph/Plot/Dot.php create mode 100644 includes/pear/Image/Graph/Plot/Fit/Line.php create mode 100644 includes/pear/Image/Graph/Plot/Impulse.php create mode 100644 includes/pear/Image/Graph/Plot/Line.php create mode 100644 includes/pear/Image/Graph/Plot/Odo.php create mode 100644 includes/pear/Image/Graph/Plot/Pie.php create mode 100644 includes/pear/Image/Graph/Plot/Radar.php create mode 100644 includes/pear/Image/Graph/Plot/Smoothed/Area.php create mode 100644 includes/pear/Image/Graph/Plot/Smoothed/Bezier.php create mode 100644 includes/pear/Image/Graph/Plot/Smoothed/Line.php create mode 100644 includes/pear/Image/Graph/Plot/Smoothed/Radar.php create mode 100644 includes/pear/Image/Graph/Plot/Step.php create mode 100644 includes/pear/Image/Graph/Plotarea.php create mode 100644 includes/pear/Image/Graph/Plotarea/Element.php create mode 100644 includes/pear/Image/Graph/Plotarea/Map.php create mode 100644 includes/pear/Image/Graph/Plotarea/Radar.php create mode 100644 includes/pear/Image/Graph/Simple.php create mode 100644 includes/pear/Image/Graph/Title.php create mode 100644 includes/pear/Image/Graph/Tool.php create mode 100644 includes/pear/Image/docs/ChangeLog create mode 100644 includes/pear/Image/docs/LICENSE create mode 100644 includes/pear/Image/docs/README create mode 100644 includes/pear/Image/docs/colors.txt create mode 100644 includes/pear/Image/docs/examples/antialias.php create mode 100644 includes/pear/Image/docs/examples/axis_direction.php create mode 100644 includes/pear/Image/docs/examples/canvas.php create mode 100644 includes/pear/Image/docs/examples/category_axis_explanation.php create mode 100644 includes/pear/Image/docs/examples/color_chart.php create mode 100644 includes/pear/Image/docs/examples/customize.php create mode 100644 includes/pear/Image/docs/examples/data/colors.txt create mode 100644 includes/pear/Image/docs/examples/datapreprocessor.php create mode 100644 includes/pear/Image/docs/examples/double_category_axis.php create mode 100644 includes/pear/Image/docs/examples/driver_filepdf.php create mode 100644 includes/pear/Image/docs/examples/driver_pdf.php create mode 100644 includes/pear/Image/docs/examples/driver_png_svg.php create mode 100644 includes/pear/Image/docs/examples/driver_swf01.php create mode 100644 includes/pear/Image/docs/examples/driver_swf02.php create mode 100644 includes/pear/Image/docs/examples/driver_swf03.php create mode 100644 includes/pear/Image/docs/examples/frontpage_sample.php create mode 100644 includes/pear/Image/docs/examples/gradient_fill_area.php create mode 100644 includes/pear/Image/docs/examples/gradient_pie.php create mode 100644 includes/pear/Image/docs/examples/gradient_step.php create mode 100644 includes/pear/Image/docs/examples/horizontal.php create mode 100644 includes/pear/Image/docs/examples/html_image_map.php create mode 100644 includes/pear/Image/docs/examples/image_fill.php create mode 100644 includes/pear/Image/docs/examples/imagemap.png create mode 100644 includes/pear/Image/docs/examples/images/audi-tt-coupe.jpg create mode 100644 includes/pear/Image/docs/examples/images/audi.png create mode 100644 includes/pear/Image/docs/examples/images/bmw.png create mode 100644 includes/pear/Image/docs/examples/images/coins.png create mode 100644 includes/pear/Image/docs/examples/images/mercedes.png create mode 100644 includes/pear/Image/docs/examples/images/modify.jpg create mode 100644 includes/pear/Image/docs/examples/images/mountain.jpg create mode 100644 includes/pear/Image/docs/examples/images/porsche.png create mode 100644 includes/pear/Image/docs/examples/index.html create mode 100644 includes/pear/Image/docs/examples/layout_matrix.php create mode 100644 includes/pear/Image/docs/examples/line_break.php create mode 100644 includes/pear/Image/docs/examples/log_axis.php create mode 100644 includes/pear/Image/docs/examples/log_axis_intersect.php create mode 100644 includes/pear/Image/docs/examples/logo_graph.php create mode 100644 includes/pear/Image/docs/examples/manual_labels.php create mode 100644 includes/pear/Image/docs/examples/misc01.php create mode 100644 includes/pear/Image/docs/examples/misc02.php create mode 100644 includes/pear/Image/docs/examples/misc03.php create mode 100644 includes/pear/Image/docs/examples/misc04.php create mode 100644 includes/pear/Image/docs/examples/misc05.php create mode 100644 includes/pear/Image/docs/examples/misc06.php create mode 100644 includes/pear/Image/docs/examples/multiple_plots.php create mode 100644 includes/pear/Image/docs/examples/negative_values.php create mode 100644 includes/pear/Image/docs/examples/pear-icon.png create mode 100644 includes/pear/Image/docs/examples/plot_all.php create mode 100644 includes/pear/Image/docs/examples/plot_all_horizontal.php create mode 100644 includes/pear/Image/docs/examples/plot_all_horizontal_invert.php create mode 100644 includes/pear/Image/docs/examples/plot_area.php create mode 100644 includes/pear/Image/docs/examples/plot_area_smooth.php create mode 100644 includes/pear/Image/docs/examples/plot_area_stack.php create mode 100644 includes/pear/Image/docs/examples/plot_band.php create mode 100644 includes/pear/Image/docs/examples/plot_bar.php create mode 100644 includes/pear/Image/docs/examples/plot_bar_horizontal.php create mode 100644 includes/pear/Image/docs/examples/plot_bar_multiple.php create mode 100644 includes/pear/Image/docs/examples/plot_bar_stacked.php create mode 100644 includes/pear/Image/docs/examples/plot_bar_stacked100pct.php create mode 100644 includes/pear/Image/docs/examples/plot_bar_stacked_horizontal.php create mode 100644 includes/pear/Image/docs/examples/plot_bar_stacked_negative.php create mode 100644 includes/pear/Image/docs/examples/plot_boxwhisker.php create mode 100644 includes/pear/Image/docs/examples/plot_candlestick.php create mode 100644 includes/pear/Image/docs/examples/plot_impulse.php create mode 100644 includes/pear/Image/docs/examples/plot_impulse_stacked.php create mode 100644 includes/pear/Image/docs/examples/plot_line.php create mode 100644 includes/pear/Image/docs/examples/plot_line_smooth.php create mode 100644 includes/pear/Image/docs/examples/plot_map.php create mode 100644 includes/pear/Image/docs/examples/plot_odo.php create mode 100644 includes/pear/Image/docs/examples/plot_pie.php create mode 100644 includes/pear/Image/docs/examples/plot_pie_rotate.php create mode 100644 includes/pear/Image/docs/examples/plot_radar.php create mode 100644 includes/pear/Image/docs/examples/plot_radar_smooth.php create mode 100644 includes/pear/Image/docs/examples/plot_scatter.php create mode 100644 includes/pear/Image/docs/examples/plot_scatter_linefit.php create mode 100644 includes/pear/Image/docs/examples/plot_step.php create mode 100644 includes/pear/Image/docs/examples/secondary_axis.php create mode 100644 includes/pear/Image/docs/examples/simple.php create mode 100644 includes/pear/Image/docs/examples/simple_graph.php create mode 100644 includes/pear/Image/docs/examples/small_pie_plot.php create mode 100644 includes/pear/Image/docs/examples/vector_function.php create mode 100644 includes/pear/Image/tests/README create mode 100644 includes/pear/Image/tests/axis/category.php create mode 100644 includes/pear/Image/tests/axis/intersection.php create mode 100644 includes/pear/Image/tests/axis/intersection_secondary_axis.php create mode 100644 includes/pear/Image/tests/axis/inversion.php create mode 100644 includes/pear/Image/tests/axis/labelinterval.php create mode 100644 includes/pear/Image/tests/axis/logarithmic.php create mode 100644 includes/pear/Image/tests/canvas_body.php create mode 100644 includes/pear/Image/tests/freetype.php create mode 100644 includes/pear/Image/tests/gd.php create mode 100644 includes/pear/Image/tests/gradients.php create mode 100644 includes/pear/Image/tests/imagemap.php create mode 100644 includes/pear/Image/tests/jpg.php create mode 100644 includes/pear/Image/tests/lineends.php create mode 100644 includes/pear/Image/tests/pdf.php create mode 100644 includes/pear/Image/tests/pear-icon.png create mode 100644 includes/pear/Image/tests/plot/area.php create mode 100644 includes/pear/Image/tests/plot/bar.php create mode 100644 includes/pear/Image/tests/plot/horizontal/area.php create mode 100644 includes/pear/Image/tests/plot/horizontal/bar.php create mode 100644 includes/pear/Image/tests/plot/horizontal/impulse.php create mode 100644 includes/pear/Image/tests/plot/horizontal/line.php create mode 100644 includes/pear/Image/tests/plot/horizontal/step.php create mode 100644 includes/pear/Image/tests/plot/impulse.php create mode 100644 includes/pear/Image/tests/plot/line.php create mode 100644 includes/pear/Image/tests/plot/step.php create mode 100644 includes/pear/Image/tests/png.php create mode 100644 includes/pear/Image/tests/svg.php create mode 100644 includes/pear/Image/tests/text.php create mode 100644 includes/pear/OS/Guess.php create mode 100644 includes/pear/PEAR.php create mode 100644 includes/pear/PEAR/Autoloader.php create mode 100644 includes/pear/PEAR/Builder.php create mode 100644 includes/pear/PEAR/ChannelFile.php create mode 100644 includes/pear/PEAR/ChannelFile/Parser.php create mode 100644 includes/pear/PEAR/Command.php create mode 100644 includes/pear/PEAR/Command/Auth.php create mode 100644 includes/pear/PEAR/Command/Auth.xml create mode 100644 includes/pear/PEAR/Command/Build.php create mode 100644 includes/pear/PEAR/Command/Build.xml create mode 100644 includes/pear/PEAR/Command/Channels.php create mode 100644 includes/pear/PEAR/Command/Channels.xml create mode 100644 includes/pear/PEAR/Command/Common.php create mode 100644 includes/pear/PEAR/Command/Config.php create mode 100644 includes/pear/PEAR/Command/Config.xml create mode 100644 includes/pear/PEAR/Command/Install.php create mode 100644 includes/pear/PEAR/Command/Install.xml create mode 100644 includes/pear/PEAR/Command/Mirror.php create mode 100644 includes/pear/PEAR/Command/Mirror.xml create mode 100644 includes/pear/PEAR/Command/Package.php create mode 100644 includes/pear/PEAR/Command/Package.xml create mode 100644 includes/pear/PEAR/Command/Pickle.php create mode 100644 includes/pear/PEAR/Command/Pickle.xml create mode 100644 includes/pear/PEAR/Command/Registry.php create mode 100644 includes/pear/PEAR/Command/Registry.xml create mode 100644 includes/pear/PEAR/Command/Remote.php create mode 100644 includes/pear/PEAR/Command/Remote.xml create mode 100644 includes/pear/PEAR/Command/Test.php create mode 100644 includes/pear/PEAR/Command/Test.xml create mode 100644 includes/pear/PEAR/Common.php create mode 100644 includes/pear/PEAR/Config.php create mode 100644 includes/pear/PEAR/Dependency.php create mode 100644 includes/pear/PEAR/Dependency2.php create mode 100644 includes/pear/PEAR/DependencyDB.php create mode 100644 includes/pear/PEAR/Downloader.php create mode 100644 includes/pear/PEAR/Downloader/Package.php create mode 100644 includes/pear/PEAR/ErrorStack.php create mode 100644 includes/pear/PEAR/Exception.php create mode 100644 includes/pear/PEAR/Frontend.php create mode 100644 includes/pear/PEAR/Frontend/CLI.php create mode 100644 includes/pear/PEAR/Installer.php create mode 100644 includes/pear/PEAR/Installer/Role.php create mode 100644 includes/pear/PEAR/Installer/Role/Common.php create mode 100644 includes/pear/PEAR/Installer/Role/Data.php create mode 100644 includes/pear/PEAR/Installer/Role/Data.xml create mode 100644 includes/pear/PEAR/Installer/Role/Doc.php create mode 100644 includes/pear/PEAR/Installer/Role/Doc.xml create mode 100644 includes/pear/PEAR/Installer/Role/Ext.php create mode 100644 includes/pear/PEAR/Installer/Role/Ext.xml create mode 100644 includes/pear/PEAR/Installer/Role/Php.php create mode 100644 includes/pear/PEAR/Installer/Role/Php.xml create mode 100644 includes/pear/PEAR/Installer/Role/Script.php create mode 100644 includes/pear/PEAR/Installer/Role/Script.xml create mode 100644 includes/pear/PEAR/Installer/Role/Src.php create mode 100644 includes/pear/PEAR/Installer/Role/Src.xml create mode 100644 includes/pear/PEAR/Installer/Role/Test.php create mode 100644 includes/pear/PEAR/Installer/Role/Test.xml create mode 100644 includes/pear/PEAR/PackageFile.php create mode 100644 includes/pear/PEAR/PackageFile/Generator/v1.php create mode 100644 includes/pear/PEAR/PackageFile/Generator/v2.php create mode 100644 includes/pear/PEAR/PackageFile/Parser/v1.php create mode 100644 includes/pear/PEAR/PackageFile/Parser/v2.php create mode 100644 includes/pear/PEAR/PackageFile/v1.php create mode 100644 includes/pear/PEAR/PackageFile/v2.php create mode 100644 includes/pear/PEAR/PackageFile/v2/Validator.php create mode 100644 includes/pear/PEAR/PackageFile/v2/rw.php create mode 100644 includes/pear/PEAR/Packager.php create mode 100644 includes/pear/PEAR/REST.php create mode 100644 includes/pear/PEAR/REST/10.php create mode 100644 includes/pear/PEAR/REST/11.php create mode 100644 includes/pear/PEAR/Registry.php create mode 100644 includes/pear/PEAR/Remote.php create mode 100644 includes/pear/PEAR/RunTest.php create mode 100644 includes/pear/PEAR/Task/Common.php create mode 100644 includes/pear/PEAR/Task/Postinstallscript.php create mode 100644 includes/pear/PEAR/Task/Postinstallscript/rw.php create mode 100644 includes/pear/PEAR/Task/Replace.php create mode 100644 includes/pear/PEAR/Task/Replace/rw.php create mode 100644 includes/pear/PEAR/Task/Unixeol.php create mode 100644 includes/pear/PEAR/Task/Unixeol/rw.php create mode 100644 includes/pear/PEAR/Task/Windowseol.php create mode 100644 includes/pear/PEAR/Task/Windowseol/rw.php create mode 100644 includes/pear/PEAR/Validate.php create mode 100644 includes/pear/PEAR/Validator/PECL.php create mode 100644 includes/pear/PEAR/XMLParser.php create mode 100644 includes/pear/System.php create mode 100644 includes/pear/XML/Parser.php create mode 100644 includes/pear/XML/Parser/Simple.php create mode 100644 includes/pear/scripts/pear.bat create mode 100644 includes/pear/scripts/pear.sh create mode 100644 includes/pear/scripts/pearcmd.php create mode 100644 includes/pear/scripts/peardev.bat create mode 100644 includes/pear/scripts/peardev.sh create mode 100644 includes/pear/scripts/pecl.bat create mode 100644 includes/pear/scripts/pecl.sh create mode 100644 includes/pear/scripts/peclcmd.php create mode 100644 includes/phplayers/PHPLIB.php create mode 100644 includes/phplayers/layersmenu-common.inc.php create mode 100644 includes/phplayers/layerstreemenu-hidden.css create mode 100644 includes/phplayers/layerstreemenu.css create mode 100644 includes/phplayers/libjs/layersmenu-browser_detection.js create mode 100644 includes/phplayers/libjs/layersmenu-footer.ijs create mode 100644 includes/phplayers/libjs/layersmenu-header.ijs create mode 100644 includes/phplayers/libjs/layersmenu-library.js create mode 100644 includes/phplayers/libjs/layersmenu-see-through.js create mode 100644 includes/phplayers/libjs/layersmenu.js create mode 100644 includes/phplayers/libjs/layerstreemenu-cookies.js create mode 100644 includes/phplayers/libjs/layerstreemenu.ijs create mode 100644 includes/phplayers/menuimages/Thumbs.db create mode 100644 includes/phplayers/menuimages/kde_tree_collapse.png create mode 100644 includes/phplayers/menuimages/kde_tree_collapse_corner.png create mode 100644 includes/phplayers/menuimages/kde_tree_collapse_corner_first.png create mode 100644 includes/phplayers/menuimages/kde_tree_collapse_first.png create mode 100644 includes/phplayers/menuimages/kde_tree_corner.png create mode 100644 includes/phplayers/menuimages/kde_tree_expand.png create mode 100644 includes/phplayers/menuimages/kde_tree_expand_corner.png create mode 100644 includes/phplayers/menuimages/kde_tree_expand_corner_first.png create mode 100644 includes/phplayers/menuimages/kde_tree_expand_first.png create mode 100644 includes/phplayers/menuimages/kde_tree_folder_closed.png create mode 100644 includes/phplayers/menuimages/kde_tree_folder_open.png create mode 100644 includes/phplayers/menuimages/kde_tree_leaf.png create mode 100644 includes/phplayers/menuimages/kde_tree_space.png create mode 100644 includes/phplayers/menuimages/kde_tree_split.png create mode 100644 includes/phplayers/menuimages/kde_tree_split_first.png create mode 100644 includes/phplayers/menuimages/kde_tree_vertline.png create mode 100644 includes/phplayers/treemenu.inc.php create mode 100644 includes/phpmailer/LICENSE.txt create mode 100644 includes/phpmailer/class.phpmailer.php create mode 100644 includes/phpmailer/class.smtp.php create mode 100644 includes/smarty/Config_File.class.php create mode 100644 includes/smarty/Smarty.class.php create mode 100644 includes/smarty/Smarty_Compiler.class.php create mode 100644 includes/smarty/debug.tpl create mode 100644 includes/smarty/internals/core.assemble_plugin_filepath.php create mode 100644 includes/smarty/internals/core.assign_smarty_interface.php create mode 100644 includes/smarty/internals/core.create_dir_structure.php create mode 100644 includes/smarty/internals/core.display_debug_console.php create mode 100644 includes/smarty/internals/core.get_include_path.php create mode 100644 includes/smarty/internals/core.get_microtime.php create mode 100644 includes/smarty/internals/core.get_php_resource.php create mode 100644 includes/smarty/internals/core.is_secure.php create mode 100644 includes/smarty/internals/core.is_trusted.php create mode 100644 includes/smarty/internals/core.load_plugins.php create mode 100644 includes/smarty/internals/core.load_resource_plugin.php create mode 100644 includes/smarty/internals/core.process_cached_inserts.php create mode 100644 includes/smarty/internals/core.process_compiled_include.php create mode 100644 includes/smarty/internals/core.read_cache_file.php create mode 100644 includes/smarty/internals/core.rm_auto.php create mode 100644 includes/smarty/internals/core.rmdir.php create mode 100644 includes/smarty/internals/core.run_insert_handler.php create mode 100644 includes/smarty/internals/core.smarty_include_php.php create mode 100644 includes/smarty/internals/core.write_cache_file.php create mode 100644 includes/smarty/internals/core.write_compiled_include.php create mode 100644 includes/smarty/internals/core.write_compiled_resource.php create mode 100644 includes/smarty/internals/core.write_file.php create mode 100644 includes/smarty/plugins/block.account.php create mode 100644 includes/smarty/plugins/block.group.php create mode 100644 includes/smarty/plugins/block.htmlarea.php create mode 100644 includes/smarty/plugins/block.is_auth.php create mode 100644 includes/smarty/plugins/block.is_auth_method.php create mode 100644 includes/smarty/plugins/block.panel.php create mode 100644 includes/smarty/plugins/block.textformat.php create mode 100644 includes/smarty/plugins/block.translate.php create mode 100644 includes/smarty/plugins/compiler.assign.php create mode 100644 includes/smarty/plugins/function.ab_version.php create mode 100644 includes/smarty/plugins/function.assign.php create mode 100644 includes/smarty/plugins/function.assign_debug_info.php create mode 100644 includes/smarty/plugins/function.block.php create mode 100644 includes/smarty/plugins/function.config_load.php create mode 100644 includes/smarty/plugins/function.counter.php create mode 100644 includes/smarty/plugins/function.cycle.php create mode 100644 includes/smarty/plugins/function.date.php create mode 100644 includes/smarty/plugins/function.date_time.php create mode 100644 includes/smarty/plugins/function.db_lookup.php create mode 100644 includes/smarty/plugins/function.debug.php create mode 100644 includes/smarty/plugins/function.eval.php create mode 100644 includes/smarty/plugins/function.exe.php create mode 100644 includes/smarty/plugins/function.fetch.php create mode 100644 includes/smarty/plugins/function.graph.php create mode 100644 includes/smarty/plugins/function.grid_bool.php create mode 100644 includes/smarty/plugins/function.grid_column_heading.php create mode 100644 includes/smarty/plugins/function.grid_column_refine.php create mode 100644 includes/smarty/plugins/function.grid_paginate.php create mode 100644 includes/smarty/plugins/function.html_bool.php create mode 100644 includes/smarty/plugins/function.html_button.php create mode 100644 includes/smarty/plugins/function.html_checkboxes.php create mode 100644 includes/smarty/plugins/function.html_date.php create mode 100644 includes/smarty/plugins/function.html_image.php create mode 100644 includes/smarty/plugins/function.html_link.php create mode 100644 includes/smarty/plugins/function.html_menu.php create mode 100644 includes/smarty/plugins/function.html_menu_files.php create mode 100644 includes/smarty/plugins/function.html_menu_multi.php create mode 100644 includes/smarty/plugins/function.html_menu_product_host.php create mode 100644 includes/smarty/plugins/function.html_menu_product_subscription.php create mode 100644 includes/smarty/plugins/function.html_menu_search_expr.php create mode 100644 includes/smarty/plugins/function.html_menu_sub.php create mode 100644 includes/smarty/plugins/function.html_options.php create mode 100644 includes/smarty/plugins/function.html_radios.php create mode 100644 includes/smarty/plugins/function.html_select_account.php create mode 100644 includes/smarty/plugins/function.html_select_affiliate.php create mode 100644 includes/smarty/plugins/function.html_select_date.php create mode 100644 includes/smarty/plugins/function.html_select_time.php create mode 100644 includes/smarty/plugins/function.html_table.php create mode 100644 includes/smarty/plugins/function.html_textarea.php create mode 100644 includes/smarty/plugins/function.input_text.php create mode 100644 includes/smarty/plugins/function.mailto.php create mode 100644 includes/smarty/plugins/function.math.php create mode 100644 includes/smarty/plugins/function.plugin.php create mode 100644 includes/smarty/plugins/function.popup.php create mode 100644 includes/smarty/plugins/function.popup_init.php create mode 100644 includes/smarty/plugins/function.style_hide.php create mode 100644 includes/smarty/plugins/function.voip_did.php create mode 100644 includes/smarty/plugins/function.voip_did_id.php create mode 100644 includes/smarty/plugins/modifier.bool.php create mode 100644 includes/smarty/plugins/modifier.capitalize.php create mode 100644 includes/smarty/plugins/modifier.cat.php create mode 100644 includes/smarty/plugins/modifier.count_characters.php create mode 100644 includes/smarty/plugins/modifier.count_paragraphs.php create mode 100644 includes/smarty/plugins/modifier.count_sentences.php create mode 100644 includes/smarty/plugins/modifier.count_words.php create mode 100644 includes/smarty/plugins/modifier.date.php create mode 100644 includes/smarty/plugins/modifier.date_format.php create mode 100644 includes/smarty/plugins/modifier.debug_print_var.php create mode 100644 includes/smarty/plugins/modifier.default.php create mode 100644 includes/smarty/plugins/modifier.escape.php create mode 100644 includes/smarty/plugins/modifier.indent.php create mode 100644 includes/smarty/plugins/modifier.linkalize.php create mode 100644 includes/smarty/plugins/modifier.lower.php create mode 100644 includes/smarty/plugins/modifier.markdown.php create mode 100644 includes/smarty/plugins/modifier.nl2br.php create mode 100644 includes/smarty/plugins/modifier.regex_replace.php create mode 100644 includes/smarty/plugins/modifier.replace.php create mode 100644 includes/smarty/plugins/modifier.smartypants.php create mode 100644 includes/smarty/plugins/modifier.spacify.php create mode 100644 includes/smarty/plugins/modifier.string_format.php create mode 100644 includes/smarty/plugins/modifier.strip.php create mode 100644 includes/smarty/plugins/modifier.strip_tags.php create mode 100644 includes/smarty/plugins/modifier.textile.php create mode 100644 includes/smarty/plugins/modifier.truncate.php create mode 100644 includes/smarty/plugins/modifier.upper.php create mode 100644 includes/smarty/plugins/modifier.wordwrap.php create mode 100644 includes/smarty/plugins/outputfilter.trimwhitespace.php create mode 100644 includes/smarty/plugins/postfilter.lang.php create mode 100644 includes/smarty/plugins/shared.escape_special_chars.php create mode 100644 includes/smarty/plugins/shared.make_timestamp.php create mode 100644 includes/tinymce/jscripts/tiny_mce/blank.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/ar.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/da.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/el.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/es.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/fi.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/hu.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/it.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/ja.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/ko.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/nl.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/no.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/pl.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/pt.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/ru.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/th.js create mode 100644 includes/tinymce/jscripts/tiny_mce/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/images/advhr.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advhr/rule.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/image.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fa_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/ko.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advimage/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/ko.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/link.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/advlink/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/emotions.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/emotions.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-cool.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-cry.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-embarassed.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-foot-in-mouth.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-frown.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-innocent.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-kiss.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-laughing.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-money-mouth.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-sealed.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-smile.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-surprised.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-tongue-out.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-undecided.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-wink.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-yell.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/el.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/it.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/ko.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/emotions/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/flash.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/images/flash.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/flash/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/images/iespell.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/el.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/it.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/ko.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/iespell/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/images/insertdate.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/images/inserttime.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/el.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/it.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/ko.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/example.html create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/images/preview.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/el.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/it.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/ko.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/pt.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/preview/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/images/print.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/print/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/images/save.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/save/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/images/replace.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/images/search.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/replace.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/search.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/cell.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/images/buttons.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/images/table.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_cell_props.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_delete_col.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_delete_row.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_insert_col_after.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_insert_col_before.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_insert_row_after.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_insert_row_before.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_row_props.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/ar.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/cs.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/da.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/de.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/el.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/es.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/fi.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/fr.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/hu.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/it.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/ja.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/ko.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/nl.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/no.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/pl.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/pt.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/sv.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/tw.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/langs/zh_cn.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/row.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/table/table.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/zoom/editor_plugin.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/zoom/editor_plugin_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/zoom/langs/fa.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/zoom/langs/fr_ca.js create mode 100644 includes/tinymce/jscripts/tiny_mce/plugins/zoom/readme.txt create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/anchor.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/charmap.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/color_picker.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/about.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/common_buttons.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/images/insert_anchor_window.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/images/insert_image_window.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/images/insert_link_window.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/images/insert_table_window.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/index.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_anchor_button.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_image_button.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_link_button.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_table_button.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/style.css create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_delete_col.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_delete_row.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_insert_col_after.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_insert_col_before.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_insert_row_after.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_insert_row_before.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_content.css create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_popup.css create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_template.js create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_template_src.js create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_ui.css create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/image.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/anchor.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/backcolor.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bold.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bold_de_se.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bold_fr.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bold_ru.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/browse.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bullist.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/buttons.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/center.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/charmap.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/cleanup.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/code.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/copy.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/custom_1.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/cut.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/forecolor.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/full.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/help.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/hr.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/image.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/indent.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/italic.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/italic_de_se.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/italic_ru.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/left.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/link.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/numlist.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/outdent.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/paste.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/redo.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/removeformat.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/right.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/spacer.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/strikethrough.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/sub.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/sup.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_delete_col.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_delete_row.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_insert_col_after.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_insert_col_before.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_insert_row_after.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_insert_row_before.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/underline.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/underline_fr.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/underline_ru.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/undo.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/unlink.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/images/visualaid.gif create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/langs/en.js create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/link.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/themes/advanced/source_editor.htm create mode 100644 includes/tinymce/jscripts/tiny_mce/tiny_mce.js create mode 100644 includes/tinymce/jscripts/tiny_mce/tiny_mce_popup.js create mode 100644 includes/tinymce/jscripts/tiny_mce/tiny_mce_src.js create mode 100644 includes/tinymce/lgpl.txt create mode 100644 index.php create mode 100644 install/config.inc create mode 100644 install/install.inc create mode 100644 install/install_db_core.inc create mode 100644 install/step1.php create mode 100644 install/step2.php create mode 100644 install/step3.php create mode 100644 install/template.inc create mode 100644 language/account/english_account.xml create mode 100644 language/account_admin/english_account_admin.xml create mode 100644 language/account_billing/english_account_billing.xml create mode 100644 language/account_memo/english_account_memo.xml create mode 100644 language/affiliate/english_affiliate.xml create mode 100644 language/affiliate_commission/english_affiliate_commission.xml create mode 100644 language/affiliate_template/english_affiliate_template.xml create mode 100644 language/asset/english_asset.xml create mode 100644 language/asset_invoice/english_asset_invoice.xml create mode 100644 language/asset_pool/english_asset_pool.xml create mode 100644 language/backup/english_backup.xml create mode 100644 language/blocked_email/english_blocked_email.xml create mode 100644 language/blocked_ip/english_blocked_ip.xml create mode 100644 language/campaign/english_campaign.xml create mode 100644 language/cart/english_cart.xml create mode 100644 language/charge/english_charge.xml create mode 100644 language/checkout/english_checkout.xml create mode 100644 language/core/english_core.xml create mode 100644 language/country/english_country.xml create mode 100644 language/currency/english_currency.xml create mode 100644 language/db_mapping/english_db_mapping.xml create mode 100644 language/discount/english_discount.xml create mode 100644 language/email_log/english_email_log.xml create mode 100644 language/email_queue/english_email_queue.xml create mode 100644 language/email_template/english_email_template.xml create mode 100644 language/email_template_translate/english_email_template_translate.xml create mode 100644 language/faq/english_faq.xml create mode 100644 language/faq_category/english_faq_category.xml create mode 100644 language/faq_translate/english_faq_translate.xml create mode 100644 language/file/english_file.xml create mode 100644 language/file_category/english_file_category.xml create mode 100644 language/group/english_group.xml create mode 100644 language/host_provision_plugin/english_host_provision_plugin.xml create mode 100644 language/host_registrar_plugin/english_host_registrar_plugin.xml create mode 100644 language/host_server/english_host_server.xml create mode 100644 language/host_tld/english_host_tld.xml create mode 100644 language/host_whois_plugin/english_host_whois_plugin.xml create mode 100644 language/htaccess/english_htaccess.xml create mode 100644 language/htaccess_dir/english_htaccess_dir.xml create mode 100644 language/htaccess_exclude/english_htaccess_exclude.xml create mode 100644 language/import/english_import.xml create mode 100644 language/invoice/english_invoice.xml create mode 100644 language/invoice_commission/english_invoice_commission.xml create mode 100644 language/invoice_item/english_invoice_item.xml create mode 100644 language/invoice_memo/english_invoice_memo.xml create mode 100644 language/license/english_license.xml create mode 100644 language/log_error/english_log_error.xml create mode 100644 language/login_log/english_login_log.xml create mode 100644 language/module/english_module.xml create mode 100644 language/module_method/english_module_method.xml create mode 100644 language/net_term/english_net_term.xml create mode 100644 language/newsletter/english_newsletter.xml create mode 100644 language/newsletter_subscriber/english_newsletter_subscriber.xml create mode 100644 language/product/english_product.xml create mode 100644 language/product_attr/english_product_attr.xml create mode 100644 language/product_cat/english_product_cat.xml create mode 100644 language/product_cat_translate/english_product_cat_translate.xml create mode 100644 language/product_img/english_product_img.xml create mode 100644 language/product_translate/english_product_translate.xml create mode 100644 language/radius/english_radius.xml create mode 100644 language/realestate/english_realestate.xml create mode 100644 language/report/english_report.xml create mode 100644 language/service/english_service.xml create mode 100644 language/service_memo/english_service_memo.xml create mode 100644 language/session/english_session.xml create mode 100644 language/setup/english_setup.xml create mode 100644 language/setup_email/english_setup_email.xml create mode 100644 language/setup_invoice/english_setup_invoice.xml create mode 100644 language/staff/english_staff.xml create mode 100644 language/staff_department/english_staff_department.xml create mode 100644 language/static_page/english_static_page.xml create mode 100644 language/static_page_category/english_static_page_category.xml create mode 100644 language/static_page_translate/english_static_page_translate.xml create mode 100644 language/static_relation/english_static_relation.xml create mode 100644 language/static_var/english_static_var.xml create mode 100644 language/task/english_task.xml create mode 100644 language/task_log/english_task_log.xml create mode 100644 language/tax/english_tax.xml create mode 100644 language/temporary_data/english_temporary_data.xml create mode 100644 language/ticket/english_ticket.xml create mode 100644 language/ticket_department/english_ticket_department.xml create mode 100644 language/ticket_message/english_ticket_message.xml create mode 100644 language/voip/english_voip.xml create mode 100644 language/voip_blacklist/english_voip_blacklist.xml create mode 100644 language/voip_cdr/english_voip_cdr.xml create mode 100644 language/voip_did/english_voip_did.xml create mode 100644 language/voip_did_plugin/english_voip_did_plugin.xml create mode 100644 language/voip_fax/english_voip_fax.xml create mode 100644 language/voip_pool/english_voip_pool.xml create mode 100644 language/voip_prepaid/english_voip_prepaid.xml create mode 100644 language/voip_rate/english_voip_rate.xml create mode 100644 language/voip_rate_prod/english_voip_rate_prod.xml create mode 100644 language/voip_vm/english_voip_vm.xml create mode 100644 modules/account/account.inc.php create mode 100644 modules/account/account_construct.xml create mode 100644 modules/account/account_install.xml create mode 100644 modules/account/account_install_data.xml create mode 100644 modules/account/account_xmlrpc.php create mode 100644 modules/account/auth.inc.php create mode 100644 modules/account_admin/account_admin.inc.php create mode 100644 modules/account_admin/account_admin_construct.xml create mode 100644 modules/account_admin/account_admin_install.xml create mode 100644 modules/account_billing/account_billing.inc.php create mode 100644 modules/account_billing/account_billing_construct.xml create mode 100644 modules/account_billing/account_billing_install.xml create mode 100644 modules/account_billing/auth.inc.php create mode 100644 modules/account_group/account_group_construct.xml create mode 100644 modules/account_group/account_group_install.xml create mode 100644 modules/account_group/account_group_install_data.xml create mode 100644 modules/account_memo/account_memo.inc.php create mode 100644 modules/account_memo/account_memo_construct.xml create mode 100644 modules/account_memo/account_memo_install.xml create mode 100644 modules/account_message/account_message.inc.php create mode 100644 modules/account_message/account_message_construct.xml create mode 100644 modules/account_message/account_message_install.xml create mode 100644 modules/account_message/account_message_install_data.xml create mode 100644 modules/account_message/auth.inc.php create mode 100644 modules/account_password_history/account_password_history.inc.php create mode 100644 modules/account_password_history/account_password_history_construct.xml create mode 100644 modules/account_password_history/account_password_history_install.xml create mode 100644 modules/affiliate/affiliate.inc.php create mode 100644 modules/affiliate/affiliate_construct.xml create mode 100644 modules/affiliate/affiliate_install.xml create mode 100644 modules/affiliate/auth.inc.php create mode 100644 modules/affiliate_commission/affiliate_commission.inc.php create mode 100644 modules/affiliate_commission/affiliate_commission_construct.xml create mode 100644 modules/affiliate_commission/affiliate_commission_install.xml create mode 100644 modules/affiliate_template/affiliate_template.inc.php create mode 100644 modules/affiliate_template/affiliate_template_construct.xml create mode 100644 modules/affiliate_template/affiliate_template_install.xml create mode 100644 modules/affiliate_template/affiliate_template_install_data.xml create mode 100644 modules/asset/asset.inc.php create mode 100644 modules/asset/asset_construct.xml create mode 100644 modules/asset/asset_install.xml create mode 100644 modules/asset/generator.php create mode 100644 modules/asset_invoice/asset_invoice.inc.php create mode 100644 modules/asset_invoice/asset_invoice_construct.xml create mode 100644 modules/asset_invoice/asset_invoice_install.xml create mode 100644 modules/asset_invoice/auth.inc.php create mode 100644 modules/asset_pool/asset_pool.inc.php create mode 100644 modules/asset_pool/asset_pool_construct.xml create mode 100644 modules/asset_pool/asset_pool_install.xml create mode 100644 modules/blocked_email/blocked_email.inc.php create mode 100644 modules/blocked_email/blocked_email_construct.xml create mode 100644 modules/blocked_email/blocked_email_install.xml create mode 100644 modules/blocked_ip/blocked_ip.inc.php create mode 100644 modules/blocked_ip/blocked_ip_construct.xml create mode 100644 modules/blocked_ip/blocked_ip_install.xml create mode 100644 modules/campaign/auth.inc.php create mode 100644 modules/campaign/campaign.inc.php create mode 100644 modules/campaign/campaign_construct.xml create mode 100644 modules/campaign/campaign_install.xml create mode 100644 modules/campaign/index.php create mode 100644 modules/cart/auth.inc.php create mode 100644 modules/cart/cart.inc.php create mode 100644 modules/cart/cart_construct.xml create mode 100644 modules/cart/cart_install.xml create mode 100644 modules/charge/charge.inc.php create mode 100644 modules/charge/charge_construct.xml create mode 100644 modules/charge/charge_install.xml create mode 100644 modules/charge/xmlrpc.php create mode 100644 modules/checkout/auth.inc.php create mode 100644 modules/checkout/base_checkout_plugin.class.php create mode 100644 modules/checkout/checkout.inc.php create mode 100644 modules/checkout/checkout_admin.inc.php create mode 100644 modules/checkout/checkout_construct.xml create mode 100644 modules/checkout/checkout_install.xml create mode 100644 modules/checkout/checkout_install_data.xml create mode 100644 modules/core/auth.inc.php create mode 100644 modules/core/auth_generate_admin_menu.inc.php create mode 100644 modules/core/calendar.inc.php create mode 100644 modules/core/core.inc.php create mode 100644 modules/core/crypt.inc.php create mode 100644 modules/core/database.inc.php create mode 100644 modules/core/database_add.inc.php create mode 100644 modules/core/database_delete.inc.php create mode 100644 modules/core/database_join_fields.inc.php create mode 100644 modules/core/database_mass_delete.inc.php create mode 100644 modules/core/database_search.inc.php create mode 100644 modules/core/database_search_form.inc.php create mode 100644 modules/core/database_search_show.inc.php create mode 100644 modules/core/database_update.inc.php create mode 100644 modules/core/database_view.inc.php create mode 100644 modules/core/easyadmin.inc.php create mode 100644 modules/core/email.inc.php create mode 100644 modules/core/email_piping.inc.php create mode 100644 modules/core/export.inc.php create mode 100644 modules/core/file_extensions.inc.php create mode 100644 modules/core/fpdf.inc.php create mode 100644 modules/core/ftp.inc.php create mode 100644 modules/core/graph.inc.php create mode 100644 modules/core/helm.inc.php create mode 100644 modules/core/import.inc.php create mode 100644 modules/core/list.inc.php create mode 100644 modules/core/list_calendar.inc.php create mode 100644 modules/core/list_card_type_menu.inc.php create mode 100644 modules/core/list_check.inc.php create mode 100644 modules/core/list_currency.inc.php create mode 100644 modules/core/list_menu_files.inc.php create mode 100644 modules/core/list_menu_multi.inc.php create mode 100644 modules/core/list_menu_theme.inc.php create mode 100644 modules/core/list_radio.inc.php create mode 100644 modules/core/list_select_groups.inc.php create mode 100644 modules/core/list_setup_default_date.inc.php create mode 100644 modules/core/login.inc.php create mode 100644 modules/core/method.inc.php create mode 100644 modules/core/method_ajax.inc.php create mode 100644 modules/core/post.inc.php create mode 100644 modules/core/search.inc.php create mode 100644 modules/core/service_domain.inc.php create mode 100644 modules/core/service_group.inc.php create mode 100644 modules/core/session.inc.php create mode 100644 modules/core/setup.inc.php create mode 100644 modules/core/sort_array.inc.php create mode 100644 modules/core/ssl.inc.php create mode 100644 modules/core/static_var.inc.php create mode 100644 modules/core/theme.inc.php create mode 100644 modules/core/translate.inc.php create mode 100644 modules/core/trigger.inc.php create mode 100644 modules/core/validate.inc.php create mode 100644 modules/core/vars.inc.php create mode 100644 modules/core/version.inc.php create mode 100644 modules/core/weblog.inc.php create mode 100644 modules/core/webmin.inc.php create mode 100644 modules/core/xml.inc.php create mode 100644 modules/country/country.inc.php create mode 100644 modules/country/country_construct.xml create mode 100644 modules/country/country_install.xml create mode 100644 modules/country/country_install_data.xml create mode 100644 modules/currency/currency.inc.php create mode 100644 modules/currency/currency_construct.xml create mode 100644 modules/currency/currency_install.xml create mode 100644 modules/currency/currency_install_data.xml create mode 100644 modules/db_mapping/db_mapping.inc.php create mode 100644 modules/db_mapping/db_mapping_construct.xml create mode 100644 modules/db_mapping/db_mapping_install.xml create mode 100644 modules/discount/auth.inc.php create mode 100644 modules/discount/discount.inc.php create mode 100644 modules/discount/discount_construct.xml create mode 100644 modules/discount/discount_install.xml create mode 100644 modules/email_log/auth.inc.php create mode 100644 modules/email_log/email_log.inc.php create mode 100644 modules/email_log/email_log_construct.xml create mode 100644 modules/email_log/email_log_install.xml create mode 100644 modules/email_queue/email_queue.inc.php create mode 100644 modules/email_queue/email_queue_construct.xml create mode 100644 modules/email_queue/email_queue_install.xml create mode 100644 modules/email_template/email_template.inc.php create mode 100644 modules/email_template/email_template_construct.xml create mode 100644 modules/email_template/email_template_install.xml create mode 100644 modules/email_template/email_template_install_data.xml create mode 100644 modules/email_template_translate/email_template_translate.inc.php create mode 100644 modules/email_template_translate/email_template_translate_construct.xml create mode 100644 modules/email_template_translate/email_template_translate_install.xml create mode 100644 modules/email_template_translate/email_template_translate_install_data.xml create mode 100644 modules/faq/auth.inc.php create mode 100644 modules/faq/faq.inc.php create mode 100644 modules/faq/faq_construct.xml create mode 100644 modules/faq/faq_install.xml create mode 100644 modules/faq_category/auth.inc.php create mode 100644 modules/faq_category/faq_category.inc.php create mode 100644 modules/faq_category/faq_category_construct.xml create mode 100644 modules/faq_category/faq_category_install.xml create mode 100644 modules/faq_translate/faq_translate.inc.php create mode 100644 modules/faq_translate/faq_translate_construct.xml create mode 100644 modules/faq_translate/faq_translate_install.xml create mode 100644 modules/file/auth.inc.php create mode 100644 modules/file/file.inc.php create mode 100644 modules/file/file_construct.xml create mode 100644 modules/file/file_install.xml create mode 100644 modules/file/file_install_data.xml create mode 100644 modules/file_category/file_category.inc.php create mode 100644 modules/file_category/file_category_construct.xml create mode 100644 modules/file_category/file_category_install.xml create mode 100644 modules/file_category/file_category_install_data.xml create mode 100644 modules/group/group.inc.php create mode 100644 modules/group/group_construct.xml create mode 100644 modules/group/group_install.xml create mode 100644 modules/group/group_install_data.xml create mode 100644 modules/group_method/group_method_construct.xml create mode 100644 modules/group_method/group_method_install.xml create mode 100644 modules/host_registrar_plugin/host_registrar_plugin.inc.php create mode 100644 modules/host_registrar_plugin/host_registrar_plugin_construct.xml create mode 100644 modules/host_registrar_plugin/host_registrar_plugin_install.xml create mode 100644 modules/host_registrar_plugin/host_registrar_plugin_install_data.xml create mode 100644 modules/host_server/host_server.inc.php create mode 100644 modules/host_server/host_server_construct.xml create mode 100644 modules/host_server/host_server_install.xml create mode 100644 modules/host_tld/auth.inc.php create mode 100644 modules/host_tld/host_tld.inc.php create mode 100644 modules/host_tld/host_tld_construct.xml create mode 100644 modules/host_tld/host_tld_install.xml create mode 100644 modules/host_tld/host_tld_install_data.xml create mode 100644 modules/htaccess/auth.inc.php create mode 100644 modules/htaccess/htaccess.inc.php create mode 100644 modules/htaccess/htaccess_construct.xml create mode 100644 modules/htaccess/htaccess_install.xml create mode 100644 modules/htaccess/mod_auth_remote.inc.php create mode 100644 modules/htaccess_dir/htaccess_dir.inc.php create mode 100644 modules/htaccess_dir/htaccess_dir_construct.xml create mode 100644 modules/htaccess_dir/htaccess_dir_install.xml create mode 100644 modules/htaccess_exclude/htaccess_exclude.inc.php create mode 100644 modules/htaccess_exclude/htaccess_exclude_construct.xml create mode 100644 modules/htaccess_exclude/htaccess_exclude_install.xml create mode 100644 modules/htaccess_exclude/htaccess_exclude_install_data.xml create mode 100644 modules/import/import.inc.php create mode 100644 modules/import/import_construct.xml create mode 100644 modules/import/import_install.xml create mode 100644 modules/invoice/advance_notice.php create mode 100644 modules/invoice/auth.inc.php create mode 100644 modules/invoice/invoice.inc.php create mode 100644 modules/invoice/invoice_construct.xml create mode 100644 modules/invoice/invoice_fpdf.inc.php create mode 100644 modules/invoice/invoice_install.xml create mode 100644 modules/invoice/receipt_print.php create mode 100644 modules/invoice_commission/invoice_commission.inc.php create mode 100644 modules/invoice_commission/invoice_commission_construct.xml create mode 100644 modules/invoice_commission/invoice_commission_install.xml create mode 100644 modules/invoice_item/invoice_item.inc.php create mode 100644 modules/invoice_item/invoice_item_construct.xml create mode 100644 modules/invoice_item/invoice_item_install.xml create mode 100644 modules/invoice_item_discount/invoice_item_discount.inc.php create mode 100644 modules/invoice_item_discount/invoice_item_discount_construct.xml create mode 100644 modules/invoice_item_discount/invoice_item_discount_install.xml create mode 100644 modules/invoice_item_tax/invoice_item_tax.inc.php create mode 100644 modules/invoice_item_tax/invoice_item_tax_construct.xml create mode 100644 modules/invoice_item_tax/invoice_item_tax_install.xml create mode 100644 modules/invoice_memo/invoice_memo.inc.php create mode 100644 modules/invoice_memo/invoice_memo_construct.xml create mode 100644 modules/invoice_memo/invoice_memo_install.xml create mode 100644 modules/log_error/log_error.inc.php create mode 100644 modules/log_error/log_error_construct.xml create mode 100644 modules/log_error/log_error_install.xml create mode 100644 modules/login_lock/login_lock_construct.xml create mode 100644 modules/login_lock/login_lock_install.xml create mode 100644 modules/login_log/login_log.inc.php create mode 100644 modules/login_log/login_log_construct.xml create mode 100644 modules/login_log/login_log_install.xml create mode 100644 modules/login_share/login_share.inc.php create mode 100644 modules/login_share/login_share_construct.xml create mode 100644 modules/login_share/login_share_install.xml create mode 100644 modules/module/dev.inc.php create mode 100644 modules/module/module.inc.php create mode 100644 modules/module/module_construct.xml create mode 100644 modules/module/module_install.xml create mode 100644 modules/module_method/module_method.inc.php create mode 100644 modules/module_method/module_method_construct.xml create mode 100644 modules/module_method/module_method_install.xml create mode 100644 modules/net_term/net_term.inc.php create mode 100644 modules/net_term/net_term_construct.xml create mode 100644 modules/net_term/net_term_install.xml create mode 100644 modules/newsletter/auth.inc.php create mode 100644 modules/newsletter/newsletter.inc.php create mode 100644 modules/newsletter/newsletter_construct.xml create mode 100644 modules/newsletter/newsletter_install.xml create mode 100644 modules/newsletter/newsletter_install_data.xml create mode 100644 modules/newsletter_subscriber/auth.inc.php create mode 100644 modules/newsletter_subscriber/newsletter_subscriber.inc.php create mode 100644 modules/newsletter_subscriber/newsletter_subscriber_construct.xml create mode 100644 modules/newsletter_subscriber/newsletter_subscriber_install.xml create mode 100644 modules/product/auth.inc.php create mode 100644 modules/product/base_product_plugin.inc.php create mode 100644 modules/product/product.inc.php create mode 100644 modules/product/product_construct.xml create mode 100644 modules/product/product_install.xml create mode 100644 modules/product/product_install_data.xml create mode 100644 modules/product_attr/product_attr.inc.php create mode 100644 modules/product_attr/product_attr_construct.xml create mode 100644 modules/product_attr/product_attr_install.xml create mode 100644 modules/product_cat/product_cat.inc.php create mode 100644 modules/product_cat/product_cat_construct.xml create mode 100644 modules/product_cat/product_cat_install.xml create mode 100644 modules/product_cat/product_cat_install_data.xml create mode 100644 modules/product_cat_translate/product_cat_translate.inc.php create mode 100644 modules/product_cat_translate/product_cat_translate_construct.xml create mode 100644 modules/product_cat_translate/product_cat_translate_install.xml create mode 100644 modules/product_cat_translate/product_cat_translate_install_data.xml create mode 100644 modules/product_img/product_img.inc.php create mode 100644 modules/product_img/product_img_construct.xml create mode 100644 modules/product_img/product_img_install.xml create mode 100644 modules/product_translate/product_translate.inc.php create mode 100644 modules/product_translate/product_translate_construct.xml create mode 100644 modules/product_translate/product_translate_install.xml create mode 100644 modules/product_translate/product_translate_install_data.xml create mode 100644 modules/radius/auth.inc.php create mode 100644 modules/radius/radius.inc.php create mode 100644 modules/radius/radius_construct.xml create mode 100644 modules/radius/radius_install.xml create mode 100644 modules/radius_service/radius_service.inc.php create mode 100644 modules/radius_service/radius_service_construct.xml create mode 100644 modules/radius_service/radius_service_install.xml create mode 100644 modules/report/class.Level.php create mode 100644 modules/report/class.Report.php create mode 100644 modules/report/class.ReportParser.php create mode 100644 modules/report/report.inc.php create mode 100644 modules/report/report_construct.xml create mode 100644 modules/report/report_install.xml create mode 100644 modules/report/test.php create mode 100644 modules/search/search_construct.xml create mode 100644 modules/search/search_install.xml create mode 100644 modules/search/search_install_data.xml create mode 100644 modules/search_saved/search_saved_install.xml create mode 100644 modules/service/auth.inc.php create mode 100644 modules/service/service.inc.php create mode 100644 modules/service/service_construct.xml create mode 100644 modules/service/service_install.xml create mode 100644 modules/service_memo/service_memo.inc.php create mode 100644 modules/service_memo/service_memo_construct.xml create mode 100644 modules/service_memo/service_memo_install.xml create mode 100644 modules/session/session.inc.php create mode 100644 modules/session/session_construct.xml create mode 100644 modules/session/session_install.xml create mode 100644 modules/session_auth_cache/session_auth_cache.inc.php create mode 100644 modules/session_auth_cache/session_auth_cache_construct.xml create mode 100644 modules/session_auth_cache/session_auth_cache_install.xml create mode 100644 modules/setup/setup.inc.php create mode 100644 modules/setup/setup_construct.xml create mode 100644 modules/setup/setup_install.xml create mode 100644 modules/setup/setup_install_data.xml create mode 100644 modules/setup_email/setup_email.inc.php create mode 100644 modules/setup_email/setup_email_construct.xml create mode 100644 modules/setup_email/setup_email_install.xml create mode 100644 modules/setup_email/setup_email_install_data.xml create mode 100644 modules/setup_invoice/setup_invoice.inc.php create mode 100644 modules/setup_invoice/setup_invoice_construct.xml create mode 100644 modules/setup_invoice/setup_invoice_install.xml create mode 100644 modules/setup_invoice/setup_invoice_install_data.xml create mode 100644 modules/staff/auth.inc.php create mode 100644 modules/staff/staff.inc.php create mode 100644 modules/staff/staff_construct.xml create mode 100644 modules/staff/staff_install.xml create mode 100644 modules/staff/staff_install_data.xml create mode 100644 modules/staff_department/staff_department.inc.php create mode 100644 modules/staff_department/staff_department_construct.xml create mode 100644 modules/staff_department/staff_department_install.xml create mode 100644 modules/staff_department/staff_department_install_data.xml create mode 100644 modules/static_page/auth.inc.php create mode 100644 modules/static_page/static_page.inc.php create mode 100644 modules/static_page/static_page_construct.xml create mode 100644 modules/static_page/static_page_install.xml create mode 100644 modules/static_page_category/auth.inc.php create mode 100644 modules/static_page_category/static_page_category.inc.php create mode 100644 modules/static_page_category/static_page_category_construct.xml create mode 100644 modules/static_page_category/static_page_category_install.xml create mode 100644 modules/static_page_category/static_page_category_install_data.xml create mode 100644 modules/static_page_translate/static_page_translate.inc.php create mode 100644 modules/static_page_translate/static_page_translate_construct.xml create mode 100644 modules/static_page_translate/static_page_translate_install.xml create mode 100644 modules/static_relation/static_relation.inc.php create mode 100644 modules/static_relation/static_relation_construct.xml create mode 100644 modules/static_relation/static_relation_install.xml create mode 100644 modules/static_var/static_var.inc.php create mode 100644 modules/static_var/static_var_construct.xml create mode 100644 modules/static_var/static_var_install.xml create mode 100644 modules/static_var/static_var_install_data.xml create mode 100644 modules/static_var_record/static_var_record.inc.php create mode 100644 modules/static_var_record/static_var_record_construct.xml create mode 100644 modules/static_var_record/static_var_record_install.xml create mode 100644 modules/task/task.inc.php create mode 100644 modules/task/task_construct.xml create mode 100644 modules/task/task_install.xml create mode 100644 modules/task/task_install_data.xml create mode 100644 modules/task_log/task_log.inc.php create mode 100644 modules/task_log/task_log_construct.xml create mode 100644 modules/task_log/task_log_install.xml create mode 100644 modules/tax/tax.inc.php create mode 100644 modules/tax/tax_construct.xml create mode 100644 modules/tax/tax_install.xml create mode 100644 modules/temporary_data/temporary_data.inc.php create mode 100644 modules/temporary_data/temporary_data_construct.xml create mode 100644 modules/temporary_data/temporary_data_install.xml create mode 100644 modules/ticket/auth.inc.php create mode 100644 modules/ticket/ticket.inc.php create mode 100644 modules/ticket/ticket_construct.xml create mode 100644 modules/ticket/ticket_install.xml create mode 100644 modules/ticket_attachment/auth.inc.php create mode 100644 modules/ticket_attachment/ticket_attachment.inc.php create mode 100644 modules/ticket_attachment/ticket_attachment_construct.xml create mode 100644 modules/ticket_attachment/ticket_attachment_install.xml create mode 100644 modules/ticket_department/ticket_department.inc.php create mode 100644 modules/ticket_department/ticket_department_construct.xml create mode 100644 modules/ticket_department/ticket_department_install.xml create mode 100644 modules/ticket_department/ticket_department_install_data.xml create mode 100644 modules/ticket_message/ticket_message.inc.php create mode 100644 modules/ticket_message/ticket_message_construct.xml create mode 100644 modules/ticket_message/ticket_message_install.xml create mode 100644 modules/ticket_message/ticket_message_install_data.xml create mode 100644 modules/voip/auth.inc.php create mode 100644 modules/voip/base_voip_plugin.inc.php create mode 100644 modules/voip/memory_report.inc.php create mode 100644 modules/voip/voip.inc.php create mode 100644 modules/voip/voip_construct.xml create mode 100644 modules/voip/voip_install.xml create mode 100644 modules/voip_blacklist/auth.inc.php create mode 100644 modules/voip_blacklist/voip_blacklist.inc.php create mode 100644 modules/voip_blacklist/voip_blacklist_construct.xml create mode 100644 modules/voip_blacklist/voip_blacklist_install.xml create mode 100644 modules/voip_cdr/auth.inc.php create mode 100644 modules/voip_cdr/voip_cdr.inc.php create mode 100644 modules/voip_cdr/voip_cdr_construct.xml create mode 100644 modules/voip_cdr/voip_cdr_install.xml create mode 100644 modules/voip_did/voip_did.inc.php create mode 100644 modules/voip_did/voip_did_construct.xml create mode 100644 modules/voip_did/voip_did_install.xml create mode 100644 modules/voip_did_plugin/voip_did_plugin.inc.php create mode 100644 modules/voip_did_plugin/voip_did_plugin_construct.xml create mode 100644 modules/voip_did_plugin/voip_did_plugin_install.xml create mode 100644 modules/voip_did_plugin/voip_did_plugin_install_data.xml create mode 100644 modules/voip_fax/auth.inc.php create mode 100644 modules/voip_fax/voip_fax.inc.php create mode 100644 modules/voip_fax/voip_fax_construct.xml create mode 100644 modules/voip_fax/voip_fax_install.xml create mode 100644 modules/voip_fax_data/voip_fax_data.inc.php create mode 100644 modules/voip_fax_data/voip_fax_data_construct.xml create mode 100644 modules/voip_fax_data/voip_fax_data_install.xml create mode 100644 modules/voip_iax/voip_iax.inc.php create mode 100644 modules/voip_iax/voip_iax_construct.xml create mode 100644 modules/voip_iax/voip_iax_install.xml create mode 100644 modules/voip_in_network/voip_in_network.inc.php create mode 100644 modules/voip_in_network/voip_in_network_construct.xml create mode 100644 modules/voip_in_network/voip_in_network_install.xml create mode 100644 modules/voip_local_lookup/voip_local_lookup.inc.php create mode 100644 modules/voip_local_lookup/voip_local_lookup_construct.xml create mode 100644 modules/voip_local_lookup/voip_local_lookup_install.xml create mode 100644 modules/voip_pool/voip_pool.inc.php create mode 100644 modules/voip_pool/voip_pool_construct.xml create mode 100644 modules/voip_pool/voip_pool_install.xml create mode 100644 modules/voip_prepaid/auth.inc.php create mode 100644 modules/voip_prepaid/voip_prepaid.inc.php create mode 100644 modules/voip_prepaid/voip_prepaid_construct.xml create mode 100644 modules/voip_prepaid/voip_prepaid_install.xml create mode 100644 modules/voip_rate/voip_rate.inc.php create mode 100644 modules/voip_rate/voip_rate_construct.xml create mode 100644 modules/voip_rate/voip_rate_install.xml create mode 100644 modules/voip_rate_prod/voip_rate_prod.inc.php create mode 100644 modules/voip_rate_prod/voip_rate_prod_construct.xml create mode 100644 modules/voip_rate_prod/voip_rate_prod_install.xml create mode 100644 modules/voip_sip/voip_sip.inc.php create mode 100644 modules/voip_sip/voip_sip_construct.xml create mode 100644 modules/voip_sip/voip_sip_install.xml create mode 100644 modules/voip_vm/auth.inc.php create mode 100644 modules/voip_vm/voip_vm.inc.php create mode 100644 modules/voip_vm/voip_vm_construct.xml create mode 100644 modules/voip_vm/voip_vm_install.xml create mode 100644 ms_task.bat create mode 100644 nix_task.sh create mode 100644 plugins/affiliate/ACCOUNT_DISCOUNT.php create mode 100644 plugins/affiliate/MAIL_CHECK.php create mode 100644 plugins/affiliate/MONEYBOOKERS.php create mode 100644 plugins/affiliate/PAYPAL.php create mode 100644 plugins/checkout/2CHECKOUT.php create mode 100644 plugins/checkout/2CHECKOUT_V2.php create mode 100644 plugins/checkout/ACHCOMMERCE.php create mode 100644 plugins/checkout/ANYPAY.php create mode 100644 plugins/checkout/AUTHORIZE_NET.php create mode 100644 plugins/checkout/BLUEPAY.php create mode 100644 plugins/checkout/CLASS_ECHO/LICENSE.txt create mode 100644 plugins/checkout/CLASS_ECHO/README.txt create mode 100644 plugins/checkout/CLASS_ECHO/WHATSNEW.txt create mode 100644 plugins/checkout/CLASS_ECHO/echophp.class create mode 100644 plugins/checkout/CLASS_LINKPOINT/LEULA_v3.pdf create mode 100644 plugins/checkout/CLASS_LINKPOINT/lphp.php create mode 100644 plugins/checkout/CLASS_MONERIS/mpgClasses.php create mode 100644 plugins/checkout/CLASS_SKIPJACK/skipjack.php create mode 100644 plugins/checkout/COMMERCEPAYMENTWINDOW.php create mode 100644 plugins/checkout/CROWNE_GOLD.php create mode 100644 plugins/checkout/CYBERSOURCE.php create mode 100644 plugins/checkout/DPILINK.php create mode 100644 plugins/checkout/ECHO.php create mode 100644 plugins/checkout/ECX_QUICKCOMMERCE.php create mode 100644 plugins/checkout/EFT_MANUAL.php create mode 100644 plugins/checkout/EFT_SECURE.php create mode 100644 plugins/checkout/EGOLD.php create mode 100644 plugins/checkout/EPDQ.php create mode 100644 plugins/checkout/EPROCESSING_NETWORK.php create mode 100644 plugins/checkout/EWAY.php create mode 100644 plugins/checkout/FREE.php create mode 100644 plugins/checkout/GOEMERCHANT.php create mode 100644 plugins/checkout/GOLDMONEY.php create mode 100644 plugins/checkout/IBILL.php create mode 100644 plugins/checkout/IKOBO.php create mode 100644 plugins/checkout/INTERNETSECURE.php create mode 100644 plugins/checkout/LINKPOINT.php create mode 100644 plugins/checkout/MANUAL.php create mode 100644 plugins/checkout/MONERIS_ESELECT.php create mode 100644 plugins/checkout/MONEYBOOKERS.php create mode 100644 plugins/checkout/MONEYBOOKERS_RECURRING.php create mode 100644 plugins/checkout/NETBILLING.php create mode 100644 plugins/checkout/NETPAYMENTS.php create mode 100644 plugins/checkout/NOCHEXS.php create mode 100644 plugins/checkout/OPTIMALPAYMENTS.php create mode 100644 plugins/checkout/PAYBYCHECK_BASIC.php create mode 100644 plugins/checkout/PAYFUSE.php create mode 100644 plugins/checkout/PAYMATE.php create mode 100644 plugins/checkout/PAYPAL.php create mode 100644 plugins/checkout/PAYPAL_RECURRING.php create mode 100644 plugins/checkout/PAYSWISS.php create mode 100644 plugins/checkout/PAYSWISS_RECURRING.php create mode 100644 plugins/checkout/PAYSYSTEMS_CHECK.php create mode 100644 plugins/checkout/PAYSYSTEMS_CHECK_RECUR.php create mode 100644 plugins/checkout/PAYSYSTEMS_PRO.php create mode 100644 plugins/checkout/PAYSYSTEMS_RECURRING.php create mode 100644 plugins/checkout/PLANETPAYMENT.php create mode 100644 plugins/checkout/PLUGNPAY.php create mode 100644 plugins/checkout/PROTX.php create mode 100644 plugins/checkout/PSIGATE.php create mode 100644 plugins/checkout/REMIT_BANK_WIRE.php create mode 100644 plugins/checkout/REMIT_CHECK.php create mode 100644 plugins/checkout/RTWARE.php create mode 100644 plugins/checkout/SECPAY.php create mode 100644 plugins/checkout/SKIPJACK.php create mode 100644 plugins/checkout/STORMPAY.php create mode 100644 plugins/checkout/STORMPAY_RECURRING.php create mode 100644 plugins/checkout/SUREPAY.php create mode 100644 plugins/checkout/SWREG_ADVANCED.php create mode 100644 plugins/checkout/SWREG_INTERMEDIATE.php create mode 100644 plugins/checkout/TRUSTCOMMERCE.php create mode 100644 plugins/checkout/USA_EPAY.php create mode 100644 plugins/checkout/VERISIGN_PFPRO.php create mode 100644 plugins/checkout/WORLDPAY.php create mode 100644 plugins/checkout/WORLDPAY_FUTUREPAY.php create mode 100644 plugins/db_mapping/Apache_mod_auth_mysql.php create mode 100644 plugins/db_mapping/Apache_mod_auth_mysql_group.php create mode 100644 plugins/db_mapping/Drupal_431.php create mode 100644 plugins/db_mapping/Expression_Engine_1_1.php create mode 100644 plugins/db_mapping/FlySpray_95.php create mode 100644 plugins/db_mapping/GeekLog_138.php create mode 100644 plugins/db_mapping/HiveMail_122.php create mode 100644 plugins/db_mapping/Invision_Power_Board_13.php create mode 100644 plugins/db_mapping/Invision_Power_Board_2.php create mode 100644 plugins/db_mapping/Mambo_4O14.php create mode 100644 plugins/db_mapping/Mambo_4_5.php create mode 100644 plugins/db_mapping/Mantis_18rc1.php create mode 100644 plugins/db_mapping/PostNuke_726.php create mode 100644 plugins/db_mapping/SMF_101.php create mode 100644 plugins/db_mapping/SMF_102.php create mode 100644 plugins/db_mapping/SendStudio_2004.php create mode 100644 plugins/db_mapping/Support_Logic_111.php create mode 100644 plugins/db_mapping/WowBB_162.php create mode 100644 plugins/db_mapping/XMB_Forums_19.php create mode 100644 plugins/db_mapping/Xaraya_914.php create mode 100644 plugins/db_mapping/Xoops_2.php create mode 100644 plugins/db_mapping/YabbSe_151.php create mode 100644 plugins/db_mapping/miniBB_17.php create mode 100644 plugins/db_mapping/osCommerce_22.php create mode 100644 plugins/db_mapping/osCommerce_22/notes.txt create mode 100644 plugins/db_mapping/osCommerce_22/password_funcs.php create mode 100644 plugins/db_mapping/pMachine_Pro_21.php create mode 100644 plugins/db_mapping/phorum_345.php create mode 100644 plugins/db_mapping/phpBB_2O6.php create mode 100644 plugins/db_mapping/phpNuke_69.php create mode 100644 plugins/db_mapping/punBB_101.php create mode 100644 plugins/db_mapping/vBulletin_229.php create mode 100644 plugins/db_mapping/vBulletin_3.php create mode 100644 plugins/db_mapping/xcart_gold_351.php create mode 100644 plugins/discount/test.php create mode 100644 plugins/import/Amember_2_3_6.php create mode 100644 plugins/import/DreamAccount.php create mode 100644 plugins/import/HostAdmin.php create mode 100644 plugins/import/ModernBill.php create mode 100644 plugins/import/WHM_AutoPilot.php create mode 100644 plugins/import/WhoisCart.php create mode 100644 plugins/product/ASSET.php create mode 100644 plugins/product/EXAMPLE.php create mode 100644 plugins/product/PREPAID.php create mode 100644 plugins/product/RADIUS.php create mode 100644 plugins/product/VOIP.php create mode 100644 plugins/provision/DIRECTADMIN_1_23.php create mode 100644 plugins/provision/EASYADMIN.php create mode 100644 plugins/provision/ENSIM_LINUX_3.php create mode 100644 plugins/provision/ENSIM_LINUX_3_5.php create mode 100644 plugins/provision/ENSIM_LINUX_PLAN_3_5.php create mode 100644 plugins/provision/ENSIM_WINDOWS_3.php create mode 100644 plugins/provision/ENSIM_WINDOWS_3_5.php create mode 100644 plugins/provision/HEARTINTERNET.php create mode 100644 plugins/provision/HELM_3_1.php create mode 100644 plugins/provision/HOSTOPIA.php create mode 100644 plugins/provision/INTERWORX_CP_1_8.php create mode 100644 plugins/provision/MANUAL.php create mode 100644 plugins/provision/PLESK_LINUX_6.php create mode 100644 plugins/provision/PLESK_LINUX_7.php create mode 100644 plugins/provision/PLESK_RELOADED_7_5.php create mode 100644 plugins/provision/PLESK_WINDOWS_6_5.php create mode 100644 plugins/provision/PLESK_WINDOWS_7.php create mode 100644 plugins/provision/PSA_RESELL_7_5.php create mode 100644 plugins/provision/RAQ_550.php create mode 100644 plugins/provision/WEBMIN.php create mode 100644 plugins/provision/WEBMIN_PRO.php create mode 100644 plugins/provision/WHM.php create mode 100644 plugins/provision/_rrad/RRAD.php create mode 100644 plugins/provision/_rrad/RRADCommonIncludes.php create mode 100644 plugins/provision/_rrad/RRADCoreIncludes.php create mode 100644 plugins/provision/_rrad/hAdminInfo.php create mode 100644 plugins/provision/_rrad/hAdminService.php create mode 100644 plugins/provision/_rrad/hAuthCommand.php create mode 100644 plugins/provision/_rrad/hCloseCommand.php create mode 100644 plugins/provision/_rrad/hCommand.php create mode 100644 plugins/provision/_rrad/hContactInfo.php create mode 100644 plugins/provision/_rrad/hConvenienceService.php create mode 100644 plugins/provision/_rrad/hDomain.php create mode 100644 plugins/provision/_rrad/hInfo.php create mode 100644 plugins/provision/_rrad/hInfoService.php create mode 100644 plugins/provision/_rrad/hMailService.php create mode 100644 plugins/provision/_rrad/hService.php create mode 100644 plugins/provision/_rrad/hServiceInfo.php create mode 100644 plugins/provision/_rrad/hUsageInfo.php create mode 100644 plugins/provision/_rrad/hWebService.php create mode 100644 plugins/registrar/BULKREGISTER.php create mode 100644 plugins/registrar/DIRECTI.php create mode 100644 plugins/registrar/ENOM.php create mode 100644 plugins/registrar/GODADDY.php create mode 100644 plugins/registrar/MANUAL.php create mode 100644 plugins/registrar/MELBOURNEIT.php create mode 100644 plugins/registrar/NOMINET.php create mode 100644 plugins/registrar/ONLINENIC.php create mode 100644 plugins/registrar/OPENSRS.php create mode 100644 plugins/registrar/PLANETDOMAIN.php create mode 100644 plugins/registrar/TOTALREGISTRATIONS.php create mode 100644 plugins/registrar/_NAMES4EVER.php create mode 100644 plugins/registrar/_directi/config.php create mode 100644 plugins/registrar/_directi/customer.class.php create mode 100644 plugins/registrar/_directi/domcontact.class.php create mode 100644 plugins/registrar/_directi/domorder.class.php create mode 100644 plugins/registrar/_directi/domuscontact.class.php create mode 100644 plugins/registrar/_directi/fund.class.php create mode 100644 plugins/registrar/_directi/nusoap.php create mode 100644 plugins/registrar/_directi/register.php create mode 100644 plugins/registrar/_directi/response.class.php create mode 100644 plugins/registrar/_directi/wsdl/customer.wsdl create mode 100644 plugins/registrar/_directi/wsdl/domain.wsdl create mode 100644 plugins/registrar/_directi/wsdl/domaincontact.wsdl create mode 100644 plugins/registrar/_directi/wsdl/domainuscontact.wsdl create mode 100644 plugins/registrar/_directi/wsdl/fund.wsdl create mode 100644 plugins/registrar/_opensrs-php/LICENSE.txt create mode 100644 plugins/registrar/_opensrs-php/OPS.php create mode 100644 plugins/registrar/_opensrs-php/country_codes.php create mode 100644 plugins/registrar/_opensrs-php/openSRS_base.php create mode 100644 plugins/registrar/_opensrs-php/ops.dtd create mode 100644 plugins/registrar/_opensrs-php/test.php create mode 100644 plugins/registrar/_opensrs-php/test.xml create mode 100644 plugins/voip_did/DEFAULT.php create mode 100644 plugins/voip_did/DIDX.php create mode 100644 plugins/voip_did/MAGRATHEA.php create mode 100644 plugins/whois/DEFAULT.php create mode 100644 plugins/whois/SUBDOMAIN.php create mode 100644 plugins/whois/WHOIS_CO_ZA.php create mode 100644 reports/account_admin/customers.xml create mode 100644 reports/account_admin/customers_domain.xml create mode 100644 reports/account_admin/customers_grouped.xml create mode 100644 reports/account_admin/industry.xml create mode 100644 reports/account_admin/new_customers.xml create mode 100644 reports/account_admin/preferences.xml create mode 100644 reports/account_admin/region_breakdown.xml create mode 100644 reports/account_admin/regions_all.xml create mode 100644 reports/account_admin/registrations.xml create mode 100644 reports/account_billing/card_type.xml create mode 100644 reports/account_billing/expire_dates.xml create mode 100644 reports/affiliate/affiliate_report_monthly.xml create mode 100644 reports/cancellations/cancellations.xml create mode 100644 reports/checkout/revenue.xml create mode 100644 reports/discount/discount_report.xml create mode 100644 reports/group/account_group_year.xml create mode 100644 reports/group/service_group.xml create mode 100644 reports/host_server/server_services.xml create mode 100644 reports/host_server/tld_services.xml create mode 100644 reports/invoice/sales_report.xml create mode 100644 reports/invoice/sku_monthly.xml create mode 100644 reports/invoice/sku_yearly.xml create mode 100644 reports/service/service_customer_sku.xml create mode 100644 reports/service/service_recurr.xml create mode 100644 reports/service/service_sku.xml create mode 100644 reports/tax/tax_report.xml create mode 100644 reports/ticket/department.xml create mode 100644 reports/ticket/staff.xml create mode 100644 reports/ticket/ticket_volume.xml create mode 100644 task.php create mode 100644 test.php create mode 100644 themes/default.user_theme create mode 100644 themes/default/IEFrameWarningBypass.htm create mode 100644 themes/default/blocks/account/account.tpl create mode 100644 themes/default/blocks/account/add.tpl create mode 100644 themes/default/blocks/account/login.tpl create mode 100644 themes/default/blocks/account/login_cookie.tpl create mode 100644 themes/default/blocks/account/login_htaccess.tpl create mode 100644 themes/default/blocks/account/login_small.tpl create mode 100644 themes/default/blocks/account/password.tpl create mode 100644 themes/default/blocks/account/password_reset.tpl create mode 100644 themes/default/blocks/account/sub_account.tpl create mode 100644 themes/default/blocks/account/sub_account_add.tpl create mode 100644 themes/default/blocks/account/sub_account_view.tpl create mode 100644 themes/default/blocks/account/verify.tpl create mode 100644 themes/default/blocks/account/view.tpl create mode 100644 themes/default/blocks/account_admin/add.tpl create mode 100644 themes/default/blocks/account_admin/iframe_mail_one.tpl create mode 100644 themes/default/blocks/account_admin/mail_multi.tpl create mode 100644 themes/default/blocks/account_admin/mail_one.tpl create mode 100644 themes/default/blocks/account_admin/merge.tpl create mode 100644 themes/default/blocks/account_admin/search_form.tpl create mode 100644 themes/default/blocks/account_admin/search_show.tpl create mode 100644 themes/default/blocks/account_admin/view.tpl create mode 100644 themes/default/blocks/account_billing/add.tpl create mode 100644 themes/default/blocks/account_billing/search_form.tpl create mode 100644 themes/default/blocks/account_billing/search_show.tpl create mode 100644 themes/default/blocks/account_billing/user_search_show.tpl create mode 100644 themes/default/blocks/account_billing/user_view.tpl create mode 100644 themes/default/blocks/account_billing/view.tpl create mode 100644 themes/default/blocks/account_memo/add.tpl create mode 100644 themes/default/blocks/account_memo/search_show.tpl create mode 100644 themes/default/blocks/account_memo/view.tpl create mode 100644 themes/default/blocks/affiliate/add.tpl create mode 100644 themes/default/blocks/affiliate/affiliate.tpl create mode 100644 themes/default/blocks/affiliate/mail_multi.tpl create mode 100644 themes/default/blocks/affiliate/new_tier_iframe.tpl create mode 100644 themes/default/blocks/affiliate/plugin_ACCOUNT_DISCOUNT.tpl create mode 100644 themes/default/blocks/affiliate/plugin_EBULLION.tpl create mode 100644 themes/default/blocks/affiliate/plugin_MAIL_CHECK.tpl create mode 100644 themes/default/blocks/affiliate/plugin_MONEYBOOKERS.tpl create mode 100644 themes/default/blocks/affiliate/plugin_PAYPAL.tpl create mode 100644 themes/default/blocks/affiliate/recurr_tier_iframe.tpl create mode 100644 themes/default/blocks/affiliate/search_form.tpl create mode 100644 themes/default/blocks/affiliate/search_show.tpl create mode 100644 themes/default/blocks/affiliate/user_add.tpl create mode 100644 themes/default/blocks/affiliate/user_new_tier_iframe.tpl create mode 100644 themes/default/blocks/affiliate/user_recurr_tier_iframe.tpl create mode 100644 themes/default/blocks/affiliate/user_view.tpl create mode 100644 themes/default/blocks/affiliate/view.tpl create mode 100644 themes/default/blocks/affiliate_commission/add.tpl create mode 100644 themes/default/blocks/affiliate_commission/search_form.tpl create mode 100644 themes/default/blocks/affiliate_commission/search_show.tpl create mode 100644 themes/default/blocks/affiliate_commission/view.tpl create mode 100644 themes/default/blocks/affiliate_template/add.tpl create mode 100644 themes/default/blocks/affiliate_template/search_show.tpl create mode 100644 themes/default/blocks/affiliate_template/view.tpl create mode 100644 themes/default/blocks/asset/add.tpl create mode 100644 themes/default/blocks/asset/import.tpl create mode 100644 themes/default/blocks/asset/search_form.tpl create mode 100644 themes/default/blocks/asset/search_show.tpl create mode 100644 themes/default/blocks/asset/view.tpl create mode 100644 themes/default/blocks/asset_invoice/ajax.js create mode 100644 themes/default/blocks/asset_invoice/invoice.tpl create mode 100644 themes/default/blocks/asset_invoice/main.tpl create mode 100644 themes/default/blocks/asset_pool/add.tpl create mode 100644 themes/default/blocks/asset_pool/search_show.tpl create mode 100644 themes/default/blocks/asset_pool/view.tpl create mode 100644 themes/default/blocks/backup/add.tpl create mode 100644 themes/default/blocks/backup/backup_module.tpl create mode 100644 themes/default/blocks/backup/search_show.tpl create mode 100644 themes/default/blocks/backup/view.tpl create mode 100644 themes/default/blocks/blocked_email/add.tpl create mode 100644 themes/default/blocks/blocked_email/search_form.tpl create mode 100644 themes/default/blocks/blocked_email/search_show.tpl create mode 100644 themes/default/blocks/blocked_email/view.tpl create mode 100644 themes/default/blocks/blocked_ip/add.tpl create mode 100644 themes/default/blocks/blocked_ip/search_form.tpl create mode 100644 themes/default/blocks/blocked_ip/search_show.tpl create mode 100644 themes/default/blocks/blocked_ip/view.tpl create mode 100644 themes/default/blocks/campaign/add.tpl create mode 100644 themes/default/blocks/campaign/affiliate.tpl create mode 100644 themes/default/blocks/campaign/click.tpl create mode 100644 themes/default/blocks/campaign/display.tpl create mode 100644 themes/default/blocks/campaign/search_form.tpl create mode 100644 themes/default/blocks/campaign/search_show.tpl create mode 100644 themes/default/blocks/campaign/view.tpl create mode 100644 themes/default/blocks/cart/ad_hoc.tpl create mode 100644 themes/default/blocks/cart/admin_changeqty.tpl create mode 100644 themes/default/blocks/cart/admin_view.tpl create mode 100644 themes/default/blocks/cart/cart.tpl create mode 100644 themes/default/blocks/cart/changeqty.tpl create mode 100644 themes/default/blocks/charge/add.tpl create mode 100644 themes/default/blocks/charge/search_form.tpl create mode 100644 themes/default/blocks/charge/search_show.tpl create mode 100644 themes/default/blocks/charge/view.tpl create mode 100644 themes/default/blocks/checkout/add.tpl create mode 100644 themes/default/blocks/checkout/admin_checkout.tpl create mode 100644 themes/default/blocks/checkout/ajax.js create mode 100644 themes/default/blocks/checkout/ccv_help.tpl create mode 100644 themes/default/blocks/checkout/checkout.tpl create mode 100644 themes/default/blocks/checkout/checkoutoption.tpl create mode 100644 themes/default/blocks/checkout/search_show.tpl create mode 100644 themes/default/blocks/checkout/view.tpl create mode 100644 themes/default/blocks/checkout_plugin/credit_card.tpl create mode 100644 themes/default/blocks/checkout_plugin/credit_card_avs.tpl create mode 100644 themes/default/blocks/checkout_plugin/echeck.tpl create mode 100644 themes/default/blocks/checkout_plugin/list_credit_card.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_2CHECKOUT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_2CHECKOUT_V2.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_ACHCOMMERCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_ANYPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_AUTHORIZE_NET.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_BLUEPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_COMMERCEPAYMENTWINDOW.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_CROWNE_GOLD.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_CYBERSOURCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_DPILINK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_EBULLION.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_ECHO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_ECX_QUICKCOMMERCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_EFT_MANUAL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_EFT_SECURE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_EGOLD.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_EPDQ.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_EPROCESSING_NETWORK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_EWAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_FREE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_GOEMERCHANT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_GOLDMONEY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_IBILL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_IKOBO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_INTERNETSECURE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_LINKPOINT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_MANUAL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_MONERIS_ESELECT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_MONEYBOOKERS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_MONEYBOOKERS_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_NETBILLING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_NETPAYMENTS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_NOCHEXS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_OPTIMALPAYMENTS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYBYCHECK_BASIC.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYFUSE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYMATE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYPAL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYPAL_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYSWISS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYSWISS_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYSYSTEMS_CHECK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYSYSTEMS_CHECK_RECUR.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYSYSTEMS_PRO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PAYSYSTEMS_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PLANETPAYMENT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PLUGNPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PROTX.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_PSIGATE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_REMIT_BANK_WIRE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_REMIT_CHECK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_SECPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_SKIPJACK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_STORMPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_STORMPAY_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_SUREPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_SWREG_ADVANCED.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_SWREG_INTERMEDIATE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_TRUSTCOMMERCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_USA_EPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_VERISIGN_PFPRO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_WORLDPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_cfg_WORLDPAY_FUTUREPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_2CHECKOUT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_2CHECKOUT_V2.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_ACHCOMMERCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_ANYPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_AUTHORIZE_NET.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_BLUEPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_COMMERCEPAYMENTWINDOW.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_CROWNE_GOLD.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_CYBERSOURCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_DPILINK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_EBULLION.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_ECHO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_ECX_QUICKCOMMERCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_EFT_MANUAL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_EFT_SECURE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_EGOLD.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_EPDQ.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_EPROCESSING_NETWORK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_EWAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_FREE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_GOEMERCHANT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_GOLDMONEY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_IBILL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_IKOBO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_INTERNETSECURE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_LINKPOINT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_MANUAL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_MONERIS_ESELECT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_MONEYBOOKERS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_MONEYBOOKERS_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_NETBILLING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_NETPAYMENTS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_NOCHEXS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_OPTIMALPAYMENTS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYBYCHECK_BASIC.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYFUSE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYMATE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYPAL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYPAL_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYSWISS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYSWISS_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYSYSTEMS_CHECK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYSYSTEMS_CHECK_RECUR.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYSYSTEMS_PRO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PAYSYSTEMS_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PLANETPAYMENT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PLUGNPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PROTX.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_PSIGATE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_REMIT_BANK_WIRE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_REMIT_CHECK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_RTWARE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_SECPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_SKIPJACK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_STORMPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_STORMPAY_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_SUREPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_SWREG_ADVANCED.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_SWREG_INTERMEDIATE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_TRUSTCOMMERCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_USA_EPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_VERISIGN_PFPRO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_WORLDPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_inv_WORLDPAY_FUTUREPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_2CHECKOUT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_2CHECKOUT_V2.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_ACHCOMMERCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_ANYPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_AUTHORIZE_NET.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_BLUEPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_COMMERCEPAYMENTWINDOW.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_CROWNE_GOLD.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_CYBERSOURCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_DPILINK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_EBULLION.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_ECHO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_ECX_QUICKCOMMERCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_EFT_MANUAL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_EFT_SECURE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_EGOLD.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_EPDQ.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_EPROCESSING_NETWORK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_EWAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_FREE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_GOEMERCHANT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_GOLDMONEY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_IBILL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_IKOBO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_INTERNETSECURE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_LINKPOINT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_MANUAL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_MANUAL_ALERT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_MONERIS_ESELECT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_MONEYBOOKERS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_MONEYBOOKERS_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_NETBILLING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_NETPAYMENTS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_NOCHEXS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_OPTIMALPAYMENTS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYBYCHECK_BASIC.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYFUSE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYMATE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYPAL.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYPAL_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYSWISS.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYSWISS_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYSYSTEMS_CHECK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYSYSTEMS_CHECK_RECUR.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYSYSTEMS_PRO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PAYSYSTEMS_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PLANETPAYMENT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PLUGNPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PROTX.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_PSIGATE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_REMIT_BANK_WIRE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_REMIT_BANK_WIRE_ALERT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_REMIT_CHECK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_REMIT_CHECK_ALERT.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_RTWARE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_SECPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_SKIPJACK.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_STORMPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_STORMPAY_RECURRING.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_SUREPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_SWREG_ADVANCED.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_SWREG_INTERMEDIATE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_TRUSTCOMMERCE.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_USA_EPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_VERISIGN_PFPRO.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_WORLDPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/plugin_ord_WORLDPAY_FUTUREPAY.tpl create mode 100644 themes/default/blocks/checkout_plugin/third_party.tpl create mode 100644 themes/default/blocks/checkout_plugin/third_party_noconf.tpl create mode 100644 themes/default/blocks/core/admin.tpl create mode 100644 themes/default/blocks/core/alert.tpl create mode 100644 themes/default/blocks/core/alert_fields.tpl create mode 100644 themes/default/blocks/core/blank.tpl create mode 100644 themes/default/blocks/core/bottom_print.tpl create mode 100644 themes/default/blocks/core/debug.tpl create mode 100644 themes/default/blocks/core/error.tpl create mode 100644 themes/default/blocks/core/export_search.tpl create mode 100644 themes/default/blocks/core/export_search_display.tpl create mode 100644 themes/default/blocks/core/export_search_download.tpl create mode 100644 themes/default/blocks/core/graph.tpl create mode 100644 themes/default/blocks/core/graphview.tpl create mode 100644 themes/default/blocks/core/group.tpl create mode 100644 themes/default/blocks/core/htmlarea.tpl create mode 100644 themes/default/blocks/core/import.tpl create mode 100644 themes/default/blocks/core/import2.tpl create mode 100644 themes/default/blocks/core/import2_new.tpl create mode 100644 themes/default/blocks/core/import_new.tpl create mode 100644 themes/default/blocks/core/invalid_page.tpl create mode 100644 themes/default/blocks/core/language.tpl create mode 100644 themes/default/blocks/core/logout.tpl create mode 100644 themes/default/blocks/core/method_error.tpl create mode 100644 themes/default/blocks/core/popup_list_search.tpl create mode 100644 themes/default/blocks/core/recent_searches.tpl create mode 100644 themes/default/blocks/core/save_search.tpl create mode 100644 themes/default/blocks/core/save_search_done.tpl create mode 100644 themes/default/blocks/core/saved_searches.tpl create mode 100644 themes/default/blocks/core/search.tpl create mode 100644 themes/default/blocks/core/search_iframe.tpl create mode 100644 themes/default/blocks/core/sess_renew.tpl create mode 100644 themes/default/blocks/core/sess_timeout.tpl create mode 100644 themes/default/blocks/core/test.tpl create mode 100644 themes/default/blocks/core/top_clean.tpl create mode 100644 themes/default/blocks/core/url.tpl create mode 100644 themes/default/blocks/core/user_search.tpl create mode 100644 themes/default/blocks/country/add.tpl create mode 100644 themes/default/blocks/country/main.tpl create mode 100644 themes/default/blocks/country/search_show.tpl create mode 100644 themes/default/blocks/country/view.tpl create mode 100644 themes/default/blocks/currency/add.tpl create mode 100644 themes/default/blocks/currency/main.tpl create mode 100644 themes/default/blocks/currency/search_show.tpl create mode 100644 themes/default/blocks/currency/view.tpl create mode 100644 themes/default/blocks/db_mapping/add.tpl create mode 100644 themes/default/blocks/db_mapping/group_map_db-status.tpl create mode 100644 themes/default/blocks/db_mapping/group_map_db.tpl create mode 100644 themes/default/blocks/db_mapping/group_map_status.tpl create mode 100644 themes/default/blocks/db_mapping/main.tpl create mode 100644 themes/default/blocks/db_mapping/search_show.tpl create mode 100644 themes/default/blocks/db_mapping/view.tpl create mode 100644 themes/default/blocks/discount/add.tpl create mode 100644 themes/default/blocks/discount/search_form.tpl create mode 100644 themes/default/blocks/discount/search_show.tpl create mode 100644 themes/default/blocks/discount/user_search_show.tpl create mode 100644 themes/default/blocks/discount/view.tpl create mode 100644 themes/default/blocks/email_log/search_form.tpl create mode 100644 themes/default/blocks/email_log/search_show.tpl create mode 100644 themes/default/blocks/email_log/user_list.tpl create mode 100644 themes/default/blocks/email_log/user_view.tpl create mode 100644 themes/default/blocks/email_log/view.tpl create mode 100644 themes/default/blocks/email_queue/add.tpl create mode 100644 themes/default/blocks/email_queue/search_form.tpl create mode 100644 themes/default/blocks/email_queue/search_show.tpl create mode 100644 themes/default/blocks/email_queue/view.tpl create mode 100644 themes/default/blocks/email_template/add.tpl create mode 100644 themes/default/blocks/email_template/search_show.tpl create mode 100644 themes/default/blocks/email_template/view.tpl create mode 100644 themes/default/blocks/email_template_translate/add.tpl create mode 100644 themes/default/blocks/email_template_translate/search_show.tpl create mode 100644 themes/default/blocks/email_template_translate/view.tpl create mode 100644 themes/default/blocks/faq/add.tpl create mode 100644 themes/default/blocks/faq/faq.tpl create mode 100644 themes/default/blocks/faq/menu.tpl create mode 100644 themes/default/blocks/faq/search_form.tpl create mode 100644 themes/default/blocks/faq/search_show.tpl create mode 100644 themes/default/blocks/faq/view.tpl create mode 100644 themes/default/blocks/faq_category/add.tpl create mode 100644 themes/default/blocks/faq_category/faq_category.tpl create mode 100644 themes/default/blocks/faq_category/search_show.tpl create mode 100644 themes/default/blocks/faq_category/view.tpl create mode 100644 themes/default/blocks/faq_translate/add.tpl create mode 100644 themes/default/blocks/faq_translate/search_show.tpl create mode 100644 themes/default/blocks/faq_translate/view.tpl create mode 100644 themes/default/blocks/file/add.tpl create mode 100644 themes/default/blocks/file/download.tpl create mode 100644 themes/default/blocks/file/file.tpl create mode 100644 themes/default/blocks/file/file_list.tpl create mode 100644 themes/default/blocks/file/list.tpl create mode 100644 themes/default/blocks/file/menu.tpl create mode 100644 themes/default/blocks/file/search_form.tpl create mode 100644 themes/default/blocks/file/search_show.tpl create mode 100644 themes/default/blocks/file/view.tpl create mode 100644 themes/default/blocks/file_category/add.tpl create mode 100644 themes/default/blocks/file_category/search_form.tpl create mode 100644 themes/default/blocks/file_category/search_show.tpl create mode 100644 themes/default/blocks/file_category/view.tpl create mode 100644 themes/default/blocks/group/add.tpl create mode 100644 themes/default/blocks/group/search_show.tpl create mode 100644 themes/default/blocks/group/view.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_DIRECTADMIN_1_23.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_EASYADMIN.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_ENSIM_LINUX_3.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_ENSIM_LINUX_3_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_ENSIM_LINUX_PLAN_3_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_ENSIM_WINDOWS_3.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_ENSIM_WINDOWS_3_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_HEARTINTERNET.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_HELM_3_1.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_HOSTOPIA.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_MANUAL.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_PLESK_LINUX_6.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_PLESK_LINUX_7.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_PLESK_RELOADED_7_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_PLESK_WINDOWS_6_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_PLESK_WINDOWS_7.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_PSA_RESELL_7_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_RAQ_4.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_RAQ_550.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_WEBMIN.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_WEBMIN_PRO.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_cfg_WHM.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_DIRECTADMIN_1_23.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_EASYADMIN.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_ENSIM_LINUX_3.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_ENSIM_LINUX_3_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_ENSIM_LINUX_PLAN_3_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_ENSIM_WINDOWS_3.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_ENSIM_WINDOWS_3_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_HEARTINTERNET.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_HELM_3_1.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_HOSTOPIA.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_MANUAL.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_PLESK_LINUX_6.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_PLESK_LINUX_7.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_PLESK_RELOADED_7_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_PLESK_WINDOWS_6_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_PLESK_WINDOWS_7.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_PSA_RESELL_7_5.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_RAQ_550.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_WEBMIN.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_WEBMIN_PRO.tpl create mode 100644 themes/default/blocks/host_provision_plugin/plugin_prod_WHM.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/add.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/main.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_BULKREGISTER.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_DIRECTI.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_ENOM.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_GODADDY.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_MANUAL.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_MELBOURNEIT.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_NAMES4EVER.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_NOMINET.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_ONLINENIC.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_OPENSRS.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_PLANETDOMAIN.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/plugin_cfg_TOTALREGISTRATIONS.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/search_show.tpl create mode 100644 themes/default/blocks/host_registrar_plugin/view.tpl create mode 100644 themes/default/blocks/host_server/add.tpl create mode 100644 themes/default/blocks/host_server/search_show.tpl create mode 100644 themes/default/blocks/host_server/view.tpl create mode 100644 themes/default/blocks/host_tld/add.tpl create mode 100644 themes/default/blocks/host_tld/admin_search.tpl create mode 100644 themes/default/blocks/host_tld/admin_search_transfer.tpl create mode 100644 themes/default/blocks/host_tld/ajax.js create mode 100644 themes/default/blocks/host_tld/iframe_ns_transfer.tpl create mode 100644 themes/default/blocks/host_tld/iframe_register.tpl create mode 100644 themes/default/blocks/host_tld/iframe_transfer.tpl create mode 100644 themes/default/blocks/host_tld/search.tpl create mode 100644 themes/default/blocks/host_tld/search_mass.tpl create mode 100644 themes/default/blocks/host_tld/search_show.tpl create mode 100644 themes/default/blocks/host_tld/search_transfer.tpl create mode 100644 themes/default/blocks/host_tld/suggest.tpl create mode 100644 themes/default/blocks/host_tld/view.tpl create mode 100644 themes/default/blocks/host_whois_plugin/plugin_cfg_DEFAULT.tpl create mode 100644 themes/default/blocks/host_whois_plugin/plugin_cfg_SUBDOMAIN.tpl create mode 100644 themes/default/blocks/host_whois_plugin/plugin_cfg_WHOIS_CO_ZA.tpl create mode 100644 themes/default/blocks/htaccess/add.tpl create mode 100644 themes/default/blocks/htaccess/htaccess.tpl create mode 100644 themes/default/blocks/htaccess/list.tpl create mode 100644 themes/default/blocks/htaccess/search_show.tpl create mode 100644 themes/default/blocks/htaccess/view.tpl create mode 100644 themes/default/blocks/htaccess_dir/add.tpl create mode 100644 themes/default/blocks/htaccess_dir/search_show.tpl create mode 100644 themes/default/blocks/htaccess_dir/view.tpl create mode 100644 themes/default/blocks/htaccess_exclude/add.tpl create mode 100644 themes/default/blocks/htaccess_exclude/main.tpl create mode 100644 themes/default/blocks/htaccess_exclude/search_form.tpl create mode 100644 themes/default/blocks/htaccess_exclude/search_show.tpl create mode 100644 themes/default/blocks/htaccess_exclude/view.tpl create mode 100644 themes/default/blocks/import/add.tpl create mode 100644 themes/default/blocks/import/import.tpl create mode 100644 themes/default/blocks/import/search_show.tpl create mode 100644 themes/default/blocks/import/view.tpl create mode 100644 themes/default/blocks/invoice/add.tpl create mode 100644 themes/default/blocks/invoice/checkout_multiple.tpl create mode 100644 themes/default/blocks/invoice/checkoutoption.tpl create mode 100644 themes/default/blocks/invoice/checkoutoptions.tpl create mode 100644 themes/default/blocks/invoice/invoice.tpl create mode 100644 themes/default/blocks/invoice/pdf.tpl create mode 100644 themes/default/blocks/invoice/reconcile.tpl create mode 100644 themes/default/blocks/invoice/refund.tpl create mode 100644 themes/default/blocks/invoice/search_form.tpl create mode 100644 themes/default/blocks/invoice/search_show.tpl create mode 100644 themes/default/blocks/invoice/thankyou.tpl create mode 100644 themes/default/blocks/invoice/user_list.tpl create mode 100644 themes/default/blocks/invoice/user_search_show.tpl create mode 100644 themes/default/blocks/invoice/user_view.tpl create mode 100644 themes/default/blocks/invoice/view.tpl create mode 100644 themes/default/blocks/invoice_commission/add.tpl create mode 100644 themes/default/blocks/invoice_commission/main.tpl create mode 100644 themes/default/blocks/invoice_commission/search_form.tpl create mode 100644 themes/default/blocks/invoice_commission/search_show.tpl create mode 100644 themes/default/blocks/invoice_commission/view.tpl create mode 100644 themes/default/blocks/invoice_item/add.tpl create mode 100644 themes/default/blocks/invoice_item/main.tpl create mode 100644 themes/default/blocks/invoice_item/search_form.tpl create mode 100644 themes/default/blocks/invoice_item/search_show.tpl create mode 100644 themes/default/blocks/invoice_item/view.tpl create mode 100644 themes/default/blocks/invoice_memo/add.tpl create mode 100644 themes/default/blocks/invoice_memo/search_show.tpl create mode 100644 themes/default/blocks/invoice_memo/view.tpl create mode 100644 themes/default/blocks/log_error/search_form.tpl create mode 100644 themes/default/blocks/log_error/search_show.tpl create mode 100644 themes/default/blocks/log_error/view.tpl create mode 100644 themes/default/blocks/login_log/map.tpl create mode 100644 themes/default/blocks/login_log/search_form.tpl create mode 100644 themes/default/blocks/login_log/search_show.tpl create mode 100644 themes/default/blocks/login_log/whois.tpl create mode 100644 themes/default/blocks/module/add.tpl create mode 100644 themes/default/blocks/module/dev_add.tpl create mode 100644 themes/default/blocks/module/dev_add1.tpl create mode 100644 themes/default/blocks/module/install.tpl create mode 100644 themes/default/blocks/module/install_2.tpl create mode 100644 themes/default/blocks/module/main.tpl create mode 100644 themes/default/blocks/module/remote_update.tpl create mode 100644 themes/default/blocks/module/search_show.tpl create mode 100644 themes/default/blocks/module/translate.tpl create mode 100644 themes/default/blocks/module/upgrade.tpl create mode 100644 themes/default/blocks/module/view.tpl create mode 100644 themes/default/blocks/module_method/add.tpl create mode 100644 themes/default/blocks/module_method/search_show.tpl create mode 100644 themes/default/blocks/module_method/view.tpl create mode 100644 themes/default/blocks/module_method/view_methods.tpl create mode 100644 themes/default/blocks/net_term/add.tpl create mode 100644 themes/default/blocks/net_term/search_show.tpl create mode 100644 themes/default/blocks/net_term/view.tpl create mode 100644 themes/default/blocks/newsletter/add.tpl create mode 100644 themes/default/blocks/newsletter/menu.tpl create mode 100644 themes/default/blocks/newsletter/newsletter.tpl create mode 100644 themes/default/blocks/newsletter/popup.tpl create mode 100644 themes/default/blocks/newsletter/search_form.tpl create mode 100644 themes/default/blocks/newsletter/search_show.tpl create mode 100644 themes/default/blocks/newsletter/send.tpl create mode 100644 themes/default/blocks/newsletter/subscribe_confirm.tpl create mode 100644 themes/default/blocks/newsletter/unsubscribe.tpl create mode 100644 themes/default/blocks/newsletter/view.tpl create mode 100644 themes/default/blocks/newsletter_subscriber/add.tpl create mode 100644 themes/default/blocks/newsletter_subscriber/search_form.tpl create mode 100644 themes/default/blocks/newsletter_subscriber/search_show.tpl create mode 100644 themes/default/blocks/newsletter_subscriber/view.tpl create mode 100644 themes/default/blocks/product/add.tpl create mode 100644 themes/default/blocks/product/admin_details.tpl create mode 100644 themes/default/blocks/product/cat.tpl create mode 100644 themes/default/blocks/product/details.tpl create mode 100644 themes/default/blocks/product/details_wizard.tpl create mode 100644 themes/default/blocks/product/iframe_associations.tpl create mode 100644 themes/default/blocks/product/iframe_clone.tpl create mode 100644 themes/default/blocks/product/iframe_discounts.tpl create mode 100644 themes/default/blocks/product/iframe_hosting.tpl create mode 100644 themes/default/blocks/product/iframe_plugins.tpl create mode 100644 themes/default/blocks/product/iframe_price_onetime.tpl create mode 100644 themes/default/blocks/product/iframe_price_recurring.tpl create mode 100644 themes/default/blocks/product/search_form.tpl create mode 100644 themes/default/blocks/product/search_show.tpl create mode 100644 themes/default/blocks/product/view.tpl create mode 100644 themes/default/blocks/product_attr/add.tpl create mode 100644 themes/default/blocks/product_attr/search_show.tpl create mode 100644 themes/default/blocks/product_attr/view.tpl create mode 100644 themes/default/blocks/product_cat/add.tpl create mode 100644 themes/default/blocks/product_cat/menu.tpl create mode 100644 themes/default/blocks/product_cat/search_show.tpl create mode 100644 themes/default/blocks/product_cat/t_Multi Column.tpl create mode 100644 themes/default/blocks/product_cat/t_Paged Listing.tpl create mode 100644 themes/default/blocks/product_cat/t_Wizard.tpl create mode 100644 themes/default/blocks/product_cat/view.tpl create mode 100644 themes/default/blocks/product_cat_translate/add.tpl create mode 100644 themes/default/blocks/product_cat_translate/search_show.tpl create mode 100644 themes/default/blocks/product_cat_translate/view.tpl create mode 100644 themes/default/blocks/product_img/add.tpl create mode 100644 themes/default/blocks/product_img/search_show.tpl create mode 100644 themes/default/blocks/product_img/view.tpl create mode 100644 themes/default/blocks/product_plugin/plugin_order_PREPAID.tpl create mode 100644 themes/default/blocks/product_plugin/plugin_order_TICKET_INCIDENT.tpl create mode 100644 themes/default/blocks/product_plugin/plugin_order_VOIP.tpl create mode 100644 themes/default/blocks/product_plugin/plugin_prod_ASSET.tpl create mode 100644 themes/default/blocks/product_plugin/plugin_prod_EXAMPLE.tpl create mode 100644 themes/default/blocks/product_plugin/plugin_prod_PREPAID.tpl create mode 100644 themes/default/blocks/product_plugin/plugin_prod_RADIUS.tpl create mode 100644 themes/default/blocks/product_plugin/plugin_prod_TICKET_INCIDENT.tpl create mode 100644 themes/default/blocks/product_plugin/plugin_prod_VOIP.tpl create mode 100644 themes/default/blocks/product_translate/add.tpl create mode 100644 themes/default/blocks/product_translate/edit.tpl create mode 100644 themes/default/blocks/product_translate/search_show.tpl create mode 100644 themes/default/blocks/product_translate/view.tpl create mode 100644 themes/default/blocks/radius/add.tpl create mode 100644 themes/default/blocks/radius/search_form.tpl create mode 100644 themes/default/blocks/radius/search_show.tpl create mode 100644 themes/default/blocks/radius/user.tpl create mode 100644 themes/default/blocks/radius/view.tpl create mode 100644 themes/default/blocks/realestate/add.tpl create mode 100644 themes/default/blocks/realestate/search_form.tpl create mode 100644 themes/default/blocks/realestate/search_show.tpl create mode 100644 themes/default/blocks/realestate/view.tpl create mode 100644 themes/default/blocks/report/add.tpl create mode 100644 themes/default/blocks/report/generate.tpl create mode 100644 themes/default/blocks/report/main.tpl create mode 100644 themes/default/blocks/report/output.tpl create mode 100644 themes/default/blocks/report/search_form.tpl create mode 100644 themes/default/blocks/report/search_show.tpl create mode 100644 themes/default/blocks/report/view.tpl create mode 100644 themes/default/blocks/service/add.tpl create mode 100644 themes/default/blocks/service/iframe_search_show.tpl create mode 100644 themes/default/blocks/service/modify.tpl create mode 100644 themes/default/blocks/service/none.tpl create mode 100644 themes/default/blocks/service/search_form.tpl create mode 100644 themes/default/blocks/service/search_show.tpl create mode 100644 themes/default/blocks/service/user_modify.tpl create mode 100644 themes/default/blocks/service/user_search_show.tpl create mode 100644 themes/default/blocks/service/user_view.tpl create mode 100644 themes/default/blocks/service/view.tpl create mode 100644 themes/default/blocks/service_memo/add.tpl create mode 100644 themes/default/blocks/service_memo/search_show.tpl create mode 100644 themes/default/blocks/service_memo/view.tpl create mode 100644 themes/default/blocks/session/search_form.tpl create mode 100644 themes/default/blocks/session/search_show.tpl create mode 100644 themes/default/blocks/session/view.tpl create mode 100644 themes/default/blocks/setup/_php_info.tpl create mode 100644 themes/default/blocks/setup/search_show.tpl create mode 100644 themes/default/blocks/setup/view.tpl create mode 100644 themes/default/blocks/setup_email/add.tpl create mode 100644 themes/default/blocks/setup_email/search_show.tpl create mode 100644 themes/default/blocks/setup_email/view.tpl create mode 100644 themes/default/blocks/setup_invoice/search_show.tpl create mode 100644 themes/default/blocks/setup_invoice/view.tpl create mode 100644 themes/default/blocks/staff/add.tpl create mode 100644 themes/default/blocks/staff/search_form.tpl create mode 100644 themes/default/blocks/staff/search_show.tpl create mode 100644 themes/default/blocks/staff/staff.tpl create mode 100644 themes/default/blocks/staff/view.tpl create mode 100644 themes/default/blocks/staff_department/add.tpl create mode 100644 themes/default/blocks/staff_department/search_form.tpl create mode 100644 themes/default/blocks/staff_department/search_show.tpl create mode 100644 themes/default/blocks/staff_department/view.tpl create mode 100644 themes/default/blocks/static_page/add.tpl create mode 100644 themes/default/blocks/static_page/list.tpl create mode 100644 themes/default/blocks/static_page/menu.tpl create mode 100644 themes/default/blocks/static_page/search_form.tpl create mode 100644 themes/default/blocks/static_page/search_show.tpl create mode 100644 themes/default/blocks/static_page/show.tpl create mode 100644 themes/default/blocks/static_page/view.tpl create mode 100644 themes/default/blocks/static_page_category/add.tpl create mode 100644 themes/default/blocks/static_page_category/main.tpl create mode 100644 themes/default/blocks/static_page_category/search_form.tpl create mode 100644 themes/default/blocks/static_page_category/search_show.tpl create mode 100644 themes/default/blocks/static_page_category/view.tpl create mode 100644 themes/default/blocks/static_page_translate/add.tpl create mode 100644 themes/default/blocks/static_page_translate/search_show.tpl create mode 100644 themes/default/blocks/static_page_translate/view.tpl create mode 100644 themes/default/blocks/static_relation/add.tpl create mode 100644 themes/default/blocks/static_relation/search_show.tpl create mode 100644 themes/default/blocks/static_relation/view.tpl create mode 100644 themes/default/blocks/static_var/add.tpl create mode 100644 themes/default/blocks/static_var/search_show.tpl create mode 100644 themes/default/blocks/static_var/view.tpl create mode 100644 themes/default/blocks/task/add.tpl create mode 100644 themes/default/blocks/task/main.tpl create mode 100644 themes/default/blocks/task/search_form.tpl create mode 100644 themes/default/blocks/task/search_show.tpl create mode 100644 themes/default/blocks/task/view.tpl create mode 100644 themes/default/blocks/tax/add.tpl create mode 100644 themes/default/blocks/tax/main.tpl create mode 100644 themes/default/blocks/tax/search_form.tpl create mode 100644 themes/default/blocks/tax/search_show.tpl create mode 100644 themes/default/blocks/tax/view.tpl create mode 100644 themes/default/blocks/ticket/add.tpl create mode 100644 themes/default/blocks/ticket/auth.tpl create mode 100644 themes/default/blocks/ticket/main.tpl create mode 100644 themes/default/blocks/ticket/overview.tpl create mode 100644 themes/default/blocks/ticket/search_form.tpl create mode 100644 themes/default/blocks/ticket/search_quick.tpl create mode 100644 themes/default/blocks/ticket/search_quick_show.tpl create mode 100644 themes/default/blocks/ticket/search_show.tpl create mode 100644 themes/default/blocks/ticket/ticket.tpl create mode 100644 themes/default/blocks/ticket/user.tpl create mode 100644 themes/default/blocks/ticket/user_add.tpl create mode 100644 themes/default/blocks/ticket/user_view.tpl create mode 100644 themes/default/blocks/ticket/view.tpl create mode 100644 themes/default/blocks/ticket/view_quick.tpl create mode 100644 themes/default/blocks/ticket_department/add.tpl create mode 100644 themes/default/blocks/ticket_department/search_show.tpl create mode 100644 themes/default/blocks/ticket_department/view.tpl create mode 100644 themes/default/blocks/voip/activity.tpl create mode 100644 themes/default/blocks/voip/call.tpl create mode 100644 themes/default/blocks/voip/config.tpl create mode 100644 themes/default/blocks/voip/features.tpl create mode 100644 themes/default/blocks/voip/memory_report.tpl create mode 100644 themes/default/blocks/voip/menu.tpl create mode 100644 themes/default/blocks/voip/overview.tpl create mode 100644 themes/default/blocks/voip_blacklist/add.tpl create mode 100644 themes/default/blocks/voip_blacklist/search_form.tpl create mode 100644 themes/default/blocks/voip_blacklist/search_show.tpl create mode 100644 themes/default/blocks/voip_blacklist/user_add.tpl create mode 100644 themes/default/blocks/voip_blacklist/user_search_show.tpl create mode 100644 themes/default/blocks/voip_blacklist/user_view.tpl create mode 100644 themes/default/blocks/voip_blacklist/view.tpl create mode 100644 themes/default/blocks/voip_cdr/search_form.tpl create mode 100644 themes/default/blocks/voip_cdr/search_show.tpl create mode 100644 themes/default/blocks/voip_cdr/view.tpl create mode 100644 themes/default/blocks/voip_did/add.tpl create mode 100644 themes/default/blocks/voip_did/search_form.tpl create mode 100644 themes/default/blocks/voip_did/search_show.tpl create mode 100644 themes/default/blocks/voip_did/view.tpl create mode 100644 themes/default/blocks/voip_did_plugin/add.tpl create mode 100644 themes/default/blocks/voip_did_plugin/config_DEFAULT.tpl create mode 100644 themes/default/blocks/voip_did_plugin/config_DIDX.tpl create mode 100644 themes/default/blocks/voip_did_plugin/config_MAGRATHEA.tpl create mode 100644 themes/default/blocks/voip_did_plugin/search_show.tpl create mode 100644 themes/default/blocks/voip_did_plugin/view.tpl create mode 100644 themes/default/blocks/voip_fax/search_form.tpl create mode 100644 themes/default/blocks/voip_fax/search_show.tpl create mode 100644 themes/default/blocks/voip_fax/user_search_show.tpl create mode 100644 themes/default/blocks/voip_pool/add.tpl create mode 100644 themes/default/blocks/voip_pool/import.tpl create mode 100644 themes/default/blocks/voip_pool/search_form.tpl create mode 100644 themes/default/blocks/voip_pool/search_show.tpl create mode 100644 themes/default/blocks/voip_pool/view.tpl create mode 100644 themes/default/blocks/voip_prepaid/add.tpl create mode 100644 themes/default/blocks/voip_prepaid/add_batch.tpl create mode 100644 themes/default/blocks/voip_prepaid/search_form.tpl create mode 100644 themes/default/blocks/voip_prepaid/search_show.tpl create mode 100644 themes/default/blocks/voip_prepaid/view.tpl create mode 100644 themes/default/blocks/voip_rate/add.tpl create mode 100644 themes/default/blocks/voip_rate/products.tpl create mode 100644 themes/default/blocks/voip_rate/search_form.tpl create mode 100644 themes/default/blocks/voip_rate/search_show.tpl create mode 100644 themes/default/blocks/voip_rate/view.tpl create mode 100644 themes/default/blocks/voip_rate_prod/add.tpl create mode 100644 themes/default/blocks/voip_rate_prod/search_show.tpl create mode 100644 themes/default/blocks/voip_rate_prod/view.tpl create mode 100644 themes/default/blocks/voip_vm/add.tpl create mode 100644 themes/default/blocks/voip_vm/search_form.tpl create mode 100644 themes/default/blocks/voip_vm/search_show.tpl create mode 100644 themes/default/blocks/voip_vm/user.tpl create mode 100644 themes/default/blocks/voip_vm/view.tpl create mode 100644 themes/default/iframe.css create mode 100644 themes/default/images/CCV_help_amex.gif create mode 100644 themes/default/images/CCV_help_visa_mc.gif create mode 100644 themes/default/images/currency/AUD.gif create mode 100644 themes/default/images/currency/CAD.gif create mode 100644 themes/default/images/currency/CHF.gif create mode 100644 themes/default/images/currency/DKK.gif create mode 100644 themes/default/images/currency/EUR.gif create mode 100644 themes/default/images/currency/GBP.gif create mode 100644 themes/default/images/currency/HKD.gif create mode 100644 themes/default/images/currency/JPY.gif create mode 100644 themes/default/images/currency/MXN.gif create mode 100644 themes/default/images/currency/MYR.gif create mode 100644 themes/default/images/currency/NOK.gif create mode 100644 themes/default/images/currency/NZD.gif create mode 100644 themes/default/images/currency/RUR.gif create mode 100644 themes/default/images/currency/SEK.gif create mode 100644 themes/default/images/currency/USD.gif create mode 100644 themes/default/images/currency/ZAR.gif create mode 100644 themes/default/images/db_asc.gif create mode 100644 themes/default/images/db_desc.gif create mode 100644 themes/default/images/htaccess_error.gif create mode 100644 themes/default/images/icons/about_16.gif create mode 100644 themes/default/images/icons/add_16.gif create mode 100644 themes/default/images/icons/cal_16.gif create mode 100644 themes/default/images/icons/calc_16.gif create mode 100644 themes/default/images/icons/cancl_16.gif create mode 100644 themes/default/images/icons/cart_16.gif create mode 100644 themes/default/images/icons/close_16.gif create mode 100644 themes/default/images/icons/del_16.gif create mode 100644 themes/default/images/icons/edit_16.gif create mode 100644 themes/default/images/icons/exp_16.gif create mode 100644 themes/default/images/icons/flag_16.gif create mode 100644 themes/default/images/icons/go_16.gif create mode 100644 themes/default/images/icons/group_16.gif create mode 100644 themes/default/images/icons/help_16.gif create mode 100644 themes/default/images/icons/image_16.gif create mode 100644 themes/default/images/icons/lock_16.gif create mode 100644 themes/default/images/icons/mail_16.gif create mode 100644 themes/default/images/icons/mail_32.gif create mode 100644 themes/default/images/icons/print_16.gif create mode 100644 themes/default/images/icons/remov_16.gif create mode 100644 themes/default/images/icons/srch_16.gif create mode 100644 themes/default/images/icons/stop_16.gif create mode 100644 themes/default/images/icons/trash_16.gif create mode 100644 themes/default/images/icons/ulock_16.gif create mode 100644 themes/default/images/icons/user_16.gif create mode 100644 themes/default/images/icons/zoomi_16.gif create mode 100644 themes/default/images/invisible.gif create mode 100644 themes/default/images/invoice_logo.jpg create mode 100644 themes/default/images/logo.gif create mode 100644 themes/default/left.tpl create mode 100644 themes/default/search.js create mode 100644 themes/default/style.css create mode 100644 themes/default/template.tpl create mode 100644 themes/default/top.js create mode 100644 themes/default/user_search.js create mode 100644 themes/default_admin.admin_theme create mode 100644 themes/default_admin/IEFrameWarningBypass.htm create mode 100644 themes/default_admin/blocks/core/admin.tpl create mode 100644 themes/default_admin/blocks/core/cornerFrame.tpl create mode 100644 themes/default_admin/blocks/core/debug.tpl create mode 100644 themes/default_admin/blocks/core/invalid_page.tpl create mode 100644 themes/default_admin/blocks/core/leftFrameBlue.tpl create mode 100644 themes/default_admin/blocks/core/top_clean.tpl create mode 100644 themes/default_admin/blocks/core/top_frame.tpl create mode 100644 themes/default_admin/iframe.css create mode 100644 themes/default_admin/images/corner_back.gif create mode 100644 themes/default_admin/images/currency/AUD.gif create mode 100644 themes/default_admin/images/currency/CAD.gif create mode 100644 themes/default_admin/images/currency/CHF.gif create mode 100644 themes/default_admin/images/currency/DKK.gif create mode 100644 themes/default_admin/images/currency/EUR.gif create mode 100644 themes/default_admin/images/currency/GBP.gif create mode 100644 themes/default_admin/images/currency/HKD.gif create mode 100644 themes/default_admin/images/currency/JPY.gif create mode 100644 themes/default_admin/images/currency/MXN.gif create mode 100644 themes/default_admin/images/currency/MYR.gif create mode 100644 themes/default_admin/images/currency/NOK.gif create mode 100644 themes/default_admin/images/currency/NZD.gif create mode 100644 themes/default_admin/images/currency/RUR.gif create mode 100644 themes/default_admin/images/currency/SEK.gif create mode 100644 themes/default_admin/images/currency/USD.gif create mode 100644 themes/default_admin/images/currency/ZAR.gif create mode 100644 themes/default_admin/images/db_asc.gif create mode 100644 themes/default_admin/images/db_desc.gif create mode 100644 themes/default_admin/images/htaccess_error.gif create mode 100644 themes/default_admin/images/icons/about_16.gif create mode 100644 themes/default_admin/images/icons/about_24.gif create mode 100644 themes/default_admin/images/icons/about_32.gif create mode 100644 themes/default_admin/images/icons/add_16.gif create mode 100644 themes/default_admin/images/icons/add_24.gif create mode 100644 themes/default_admin/images/icons/add_32.gif create mode 100644 themes/default_admin/images/icons/addbk_16.gif create mode 100644 themes/default_admin/images/icons/addbk_24.gif create mode 100644 themes/default_admin/images/icons/addbk_32.gif create mode 100644 themes/default_admin/images/icons/adfav_16.gif create mode 100644 themes/default_admin/images/icons/adfav_24.gif create mode 100644 themes/default_admin/images/icons/adfav_32.gif create mode 100644 themes/default_admin/images/icons/apps_16.gif create mode 100644 themes/default_admin/images/icons/apps_24.gif create mode 100644 themes/default_admin/images/icons/apps_32.gif create mode 100644 themes/default_admin/images/icons/back_16.gif create mode 100644 themes/default_admin/images/icons/back_24.gif create mode 100644 themes/default_admin/images/icons/back_32.gif create mode 100644 themes/default_admin/images/icons/cal_16.gif create mode 100644 themes/default_admin/images/icons/cal_24.gif create mode 100644 themes/default_admin/images/icons/cal_32.gif create mode 100644 themes/default_admin/images/icons/calc_16.gif create mode 100644 themes/default_admin/images/icons/calc_24.gif create mode 100644 themes/default_admin/images/icons/calc_32.gif create mode 100644 themes/default_admin/images/icons/cancl_16.gif create mode 100644 themes/default_admin/images/icons/cancl_24.gif create mode 100644 themes/default_admin/images/icons/cancl_32.gif create mode 100644 themes/default_admin/images/icons/cart_16.gif create mode 100644 themes/default_admin/images/icons/cart_24.gif create mode 100644 themes/default_admin/images/icons/cart_32.gif create mode 100644 themes/default_admin/images/icons/cd_16.gif create mode 100644 themes/default_admin/images/icons/cd_24.gif create mode 100644 themes/default_admin/images/icons/cd_32.gif create mode 100644 themes/default_admin/images/icons/chart_16.gif create mode 100644 themes/default_admin/images/icons/chart_24.gif create mode 100644 themes/default_admin/images/icons/chart_32.gif create mode 100644 themes/default_admin/images/icons/close_16.gif create mode 100644 themes/default_admin/images/icons/close_24.gif create mode 100644 themes/default_admin/images/icons/close_32.gif create mode 100644 themes/default_admin/images/icons/confg_16.gif create mode 100644 themes/default_admin/images/icons/confg_24.gif create mode 100644 themes/default_admin/images/icons/confg_32.gif create mode 100644 themes/default_admin/images/icons/copy_16.gif create mode 100644 themes/default_admin/images/icons/copy_24.gif create mode 100644 themes/default_admin/images/icons/copy_32.gif create mode 100644 themes/default_admin/images/icons/cut_16.gif create mode 100644 themes/default_admin/images/icons/cut_24.gif create mode 100644 themes/default_admin/images/icons/cut_32.gif create mode 100644 themes/default_admin/images/icons/del_16.gif create mode 100644 themes/default_admin/images/icons/del_24.gif create mode 100644 themes/default_admin/images/icons/del_32.gif create mode 100644 themes/default_admin/images/icons/docs_16.gif create mode 100644 themes/default_admin/images/icons/docs_24.gif create mode 100644 themes/default_admin/images/icons/docs_32.gif create mode 100644 themes/default_admin/images/icons/down_16.gif create mode 100644 themes/default_admin/images/icons/down_24.gif create mode 100644 themes/default_admin/images/icons/down_32.gif create mode 100644 themes/default_admin/images/icons/edit_16.gif create mode 100644 themes/default_admin/images/icons/edit_24.gif create mode 100644 themes/default_admin/images/icons/edit_32.gif create mode 100644 themes/default_admin/images/icons/exp_16.gif create mode 100644 themes/default_admin/images/icons/exp_24.gif create mode 100644 themes/default_admin/images/icons/exp_32.gif create mode 100644 themes/default_admin/images/icons/fastf_16.gif create mode 100644 themes/default_admin/images/icons/fastf_24.gif create mode 100644 themes/default_admin/images/icons/fastf_32.gif create mode 100644 themes/default_admin/images/icons/favs_16.gif create mode 100644 themes/default_admin/images/icons/favs_24.gif create mode 100644 themes/default_admin/images/icons/favs_32.gif create mode 100644 themes/default_admin/images/icons/fax_16.gif create mode 100644 themes/default_admin/images/icons/fax_24.gif create mode 100644 themes/default_admin/images/icons/fax_32.gif create mode 100644 themes/default_admin/images/icons/flag_16.gif create mode 100644 themes/default_admin/images/icons/flag_24.gif create mode 100644 themes/default_admin/images/icons/flag_32.gif create mode 100644 themes/default_admin/images/icons/foldr_16.gif create mode 100644 themes/default_admin/images/icons/foldr_24.gif create mode 100644 themes/default_admin/images/icons/foldr_32.gif create mode 100644 themes/default_admin/images/icons/forwd_16.gif create mode 100644 themes/default_admin/images/icons/forwd_24.gif create mode 100644 themes/default_admin/images/icons/forwd_32.gif create mode 100644 themes/default_admin/images/icons/games_16.gif create mode 100644 themes/default_admin/images/icons/games_24.gif create mode 100644 themes/default_admin/images/icons/games_32.gif create mode 100644 themes/default_admin/images/icons/go_16.gif create mode 100644 themes/default_admin/images/icons/go_24.gif create mode 100644 themes/default_admin/images/icons/go_32.gif create mode 100644 themes/default_admin/images/icons/group_16.gif create mode 100644 themes/default_admin/images/icons/group_24.gif create mode 100644 themes/default_admin/images/icons/group_32.gif create mode 100644 themes/default_admin/images/icons/hd_16.gif create mode 100644 themes/default_admin/images/icons/hd_24.gif create mode 100644 themes/default_admin/images/icons/hd_32.gif create mode 100644 themes/default_admin/images/icons/help_16.gif create mode 100644 themes/default_admin/images/icons/help_24.gif create mode 100644 themes/default_admin/images/icons/help_32.gif create mode 100644 themes/default_admin/images/icons/hist_16.gif create mode 100644 themes/default_admin/images/icons/hist_24.gif create mode 100644 themes/default_admin/images/icons/hist_32.gif create mode 100644 themes/default_admin/images/icons/home_16.gif create mode 100644 themes/default_admin/images/icons/home_24.gif create mode 100644 themes/default_admin/images/icons/home_32.gif create mode 100644 themes/default_admin/images/icons/image_16.gif create mode 100644 themes/default_admin/images/icons/image_24.gif create mode 100644 themes/default_admin/images/icons/image_32.gif create mode 100644 themes/default_admin/images/icons/impt_16.gif create mode 100644 themes/default_admin/images/icons/impt_24.gif create mode 100644 themes/default_admin/images/icons/impt_32.gif create mode 100644 themes/default_admin/images/icons/lgicn_16.gif create mode 100644 themes/default_admin/images/icons/lgicn_24.gif create mode 100644 themes/default_admin/images/icons/lgicn_32.gif create mode 100644 themes/default_admin/images/icons/lock_16.gif create mode 100644 themes/default_admin/images/icons/lock_24.gif create mode 100644 themes/default_admin/images/icons/lock_32.gif create mode 100644 themes/default_admin/images/icons/mail_16.gif create mode 100644 themes/default_admin/images/icons/mail_24.gif create mode 100644 themes/default_admin/images/icons/mail_32.gif create mode 100644 themes/default_admin/images/icons/move_16.gif create mode 100644 themes/default_admin/images/icons/move_24.gif create mode 100644 themes/default_admin/images/icons/move_32.gif create mode 100644 themes/default_admin/images/icons/music_16.gif create mode 100644 themes/default_admin/images/icons/music_24.gif create mode 100644 themes/default_admin/images/icons/music_32.gif create mode 100644 themes/default_admin/images/icons/new_16.gif create mode 100644 themes/default_admin/images/icons/new_24.gif create mode 100644 themes/default_admin/images/icons/new_32.gif create mode 100644 themes/default_admin/images/icons/notep_16.gif create mode 100644 themes/default_admin/images/icons/notep_24.gif create mode 100644 themes/default_admin/images/icons/notep_32.gif create mode 100644 themes/default_admin/images/icons/ntwrk_16.gif create mode 100644 themes/default_admin/images/icons/ntwrk_24.gif create mode 100644 themes/default_admin/images/icons/ntwrk_32.gif create mode 100644 themes/default_admin/images/icons/open_16.gif create mode 100644 themes/default_admin/images/icons/open_24.gif create mode 100644 themes/default_admin/images/icons/open_32.gif create mode 100644 themes/default_admin/images/icons/opnbr_16.gif create mode 100644 themes/default_admin/images/icons/opnbr_24.gif create mode 100644 themes/default_admin/images/icons/opnbr_32.gif create mode 100644 themes/default_admin/images/icons/opts_16.gif create mode 100644 themes/default_admin/images/icons/opts_24.gif create mode 100644 themes/default_admin/images/icons/opts_32.gif create mode 100644 themes/default_admin/images/icons/paint_16.gif create mode 100644 themes/default_admin/images/icons/paint_24.gif create mode 100644 themes/default_admin/images/icons/paint_32.gif create mode 100644 themes/default_admin/images/icons/paste_16.gif create mode 100644 themes/default_admin/images/icons/paste_24.gif create mode 100644 themes/default_admin/images/icons/paste_32.gif create mode 100644 themes/default_admin/images/icons/pause_16.gif create mode 100644 themes/default_admin/images/icons/pause_24.gif create mode 100644 themes/default_admin/images/icons/pause_32.gif create mode 100644 themes/default_admin/images/icons/phone_16.gif create mode 100644 themes/default_admin/images/icons/phone_24.gif create mode 100644 themes/default_admin/images/icons/phone_32.gif create mode 100644 themes/default_admin/images/icons/picts_16.gif create mode 100644 themes/default_admin/images/icons/picts_24.gif create mode 100644 themes/default_admin/images/icons/picts_32.gif create mode 100644 themes/default_admin/images/icons/play_16.gif create mode 100644 themes/default_admin/images/icons/play_24.gif create mode 100644 themes/default_admin/images/icons/play_32.gif create mode 100644 themes/default_admin/images/icons/prefs_16.gif create mode 100644 themes/default_admin/images/icons/prefs_24.gif create mode 100644 themes/default_admin/images/icons/prefs_32.gif create mode 100644 themes/default_admin/images/icons/print_16.gif create mode 100644 themes/default_admin/images/icons/print_24.gif create mode 100644 themes/default_admin/images/icons/print_32.gif create mode 100644 themes/default_admin/images/icons/prtpv_16.gif create mode 100644 themes/default_admin/images/icons/prtpv_24.gif create mode 100644 themes/default_admin/images/icons/prtpv_32.gif create mode 100644 themes/default_admin/images/icons/redo_16.gif create mode 100644 themes/default_admin/images/icons/redo_24.gif create mode 100644 themes/default_admin/images/icons/redo_32.gif create mode 100644 themes/default_admin/images/icons/ref_16.gif create mode 100644 themes/default_admin/images/icons/ref_24.gif create mode 100644 themes/default_admin/images/icons/ref_32.gif create mode 100644 themes/default_admin/images/icons/remov_16.gif create mode 100644 themes/default_admin/images/icons/remov_24.gif create mode 100644 themes/default_admin/images/icons/remov_32.gif create mode 100644 themes/default_admin/images/icons/rewnd_16.gif create mode 100644 themes/default_admin/images/icons/rewnd_24.gif create mode 100644 themes/default_admin/images/icons/rewnd_32.gif create mode 100644 themes/default_admin/images/icons/savas_16.gif create mode 100644 themes/default_admin/images/icons/savas_24.gif create mode 100644 themes/default_admin/images/icons/savas_32.gif create mode 100644 themes/default_admin/images/icons/save_16.gif create mode 100644 themes/default_admin/images/icons/save_24.gif create mode 100644 themes/default_admin/images/icons/save_32.gif create mode 100644 themes/default_admin/images/icons/sinfo_16.gif create mode 100644 themes/default_admin/images/icons/sinfo_24.gif create mode 100644 themes/default_admin/images/icons/sinfo_32.gif create mode 100644 themes/default_admin/images/icons/skipb_16.gif create mode 100644 themes/default_admin/images/icons/skipb_24.gif create mode 100644 themes/default_admin/images/icons/skipb_32.gif create mode 100644 themes/default_admin/images/icons/skipf_16.gif create mode 100644 themes/default_admin/images/icons/skipf_24.gif create mode 100644 themes/default_admin/images/icons/skipf_32.gif create mode 100644 themes/default_admin/images/icons/smicn_16.gif create mode 100644 themes/default_admin/images/icons/smicn_24.gif create mode 100644 themes/default_admin/images/icons/smicn_32.gif create mode 100644 themes/default_admin/images/icons/splay_16.gif create mode 100644 themes/default_admin/images/icons/splay_24.gif create mode 100644 themes/default_admin/images/icons/splay_32.gif create mode 100644 themes/default_admin/images/icons/srch_16.gif create mode 100644 themes/default_admin/images/icons/srch_24.gif create mode 100644 themes/default_admin/images/icons/srch_32.gif create mode 100644 themes/default_admin/images/icons/stop_16.gif create mode 100644 themes/default_admin/images/icons/stop_24.gif create mode 100644 themes/default_admin/images/icons/stop_32.gif create mode 100644 themes/default_admin/images/icons/timer_16.gif create mode 100644 themes/default_admin/images/icons/timer_24.gif create mode 100644 themes/default_admin/images/icons/timer_32.gif create mode 100644 themes/default_admin/images/icons/tools_16.gif create mode 100644 themes/default_admin/images/icons/tools_24.gif create mode 100644 themes/default_admin/images/icons/tools_32.gif create mode 100644 themes/default_admin/images/icons/trash_16.gif create mode 100644 themes/default_admin/images/icons/trash_24.gif create mode 100644 themes/default_admin/images/icons/trash_32.gif create mode 100644 themes/default_admin/images/icons/ulock_16.gif create mode 100644 themes/default_admin/images/icons/ulock_24.gif create mode 100644 themes/default_admin/images/icons/ulock_32.gif create mode 100644 themes/default_admin/images/icons/undo_16.gif create mode 100644 themes/default_admin/images/icons/undo_24.gif create mode 100644 themes/default_admin/images/icons/undo_32.gif create mode 100644 themes/default_admin/images/icons/up_16.gif create mode 100644 themes/default_admin/images/icons/up_24.gif create mode 100644 themes/default_admin/images/icons/up_32.gif create mode 100644 themes/default_admin/images/icons/user_16.gif create mode 100644 themes/default_admin/images/icons/user_24.gif create mode 100644 themes/default_admin/images/icons/user_32.gif create mode 100644 themes/default_admin/images/icons/web_16.gif create mode 100644 themes/default_admin/images/icons/web_24.gif create mode 100644 themes/default_admin/images/icons/web_32.gif create mode 100644 themes/default_admin/images/icons/wiz_16.gif create mode 100644 themes/default_admin/images/icons/wiz_24.gif create mode 100644 themes/default_admin/images/icons/wiz_32.gif create mode 100644 themes/default_admin/images/icons/zoomi_16.gif create mode 100644 themes/default_admin/images/icons/zoomi_24.gif create mode 100644 themes/default_admin/images/icons/zoomi_32.gif create mode 100644 themes/default_admin/images/icons/zoomo_16.gif create mode 100644 themes/default_admin/images/icons/zoomo_24.gif create mode 100644 themes/default_admin/images/icons/zoomo_32.gif create mode 100644 themes/default_admin/images/invisible.gif create mode 100644 themes/default_admin/images/logo.gif create mode 100644 themes/default_admin/report_style.css create mode 100644 themes/default_admin/search.js create mode 100644 themes/default_admin/style.css create mode 100644 themes/default_admin/template.tpl create mode 100644 themes/default_admin/top.js create mode 100644 themes/default_admin/view.js diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..e3d9a581 --- /dev/null +++ b/LICENSE @@ -0,0 +1,315 @@ +OPEN AGILEBILL LICENSE V1.4 + +1.0 DEFINITIONS + +1.1 "Commercial Use" means distribution or otherwise making the +Original Code available to a third party. + +1.2 "Contributor Version" means the combination of the Original +Code, and the Modifications made by that particular Contributor. + +1.3 "Electronic Distribution Mechanism" means a mechanism generally +accepted in the software development community for the electronic transfer +of data. + +1.4 "Executable" means Original Code in any form other than Source +Code. + +1.5 "Initial Developer" means the individual or entity identified +as the Initial Developer in the Source Code notice required by Exhibit +A. + +1.6 "Larger Work" means a work which combines Original Code or +portions thereof with code not governed by the terms of this License. + +1.7 "License" means this document. + +1.8 "Licensable" means having the right to grant, to the maximum +extent possible, whether at the time of the initial grant or subsequently +acquired, any and all of the rights conveyed herein. + +1.9 "Modifications" means any addition to or deletion from the +substance or structure of either the Original Code or any previous +Modifications. + +A Modification is: + + A. Any addition to or deletion from the contents of a file containing + Original Code or previous Modifications. + + B. Any new file that contains any part of the Original + Code or previous Modifications. + +1.10 "Original Code" means Source Code of computer software code +which is described in the Source Code notice required by Exhibit A as Original +Code. + +1.11 "Patent Claims" means any patent claim(s), now owned or +hereafter acquired, including without limitation, method, process, and +apparatus claims, in any patent Licensable by grantor. + +1.12 "Source Code" means the preferred form of the Original Code +for making modifications to it, including all modules it contains, plus +any associated interface definition files, or scripts used to control +compilation and installation of an Executable. + +1.13 "Standards" means the standards identified in Exhibit B. + +1.14 "You" (or "Your") means an individual or a legal entity +exercising rights under, and complying with all of the terms of, this License +or a future version of this License issued under Section 6.1. For legal +entities, "You" includes any entity which controls, is controlled by, +or is under common control with You. For purposes of this definition, "control" +means (a) the power, direct or indirect, to cause the direction or management +of such entity, whether by contract or otherwise, or (b) ownership of more +than fifty percent (50%) of the outstanding shares or beneficial ownership +of such entity. + +2.0 SOURCE CODE LICENSE + +2.1 The Initial Developer Grant + +The Initial Developer hereby grants You a world-wide, royalty-free, +non-exclusive license, subject to third party intellectual property +claims: + + (a) under intellectual property rights (other than patent or + trademark) Licensable by Initial Developer to use, reproduce, modify, display, + perform, sublicense and distribute the Original Code (or portions thereof) + with or without Modifications, and/or as part of a Larger Work; and + + (b) under Patents Claims infringed by the making, using or selling + of Original Code, to make, have made, use, practice, sell, and offer for + sale, and/or otherwise dispose of the Original Code (or portions thereof). + + (c) the licenses granted in this Section 2.1(a) and (b) are effective + on the date Initial Developer first distributes Original Code under the + terms of this License. + + (d) Notwithstanding Section + 2.1(b) above, no patent license is granted: 1) for code that You delete from + the Original Code; 2) separate from the Original Code; or 3) for infringements + caused by: i) the modification of the Original Code or ii) the combination of + the Original Code with other software or devices, including but not limited to + Modifications. + +3.0 DISTRIBUTION OBLIGATIONS + +3.1 Application of License. + +The Source Code version of Original Code may be distributed only under +the terms of this License or a future version of this License released +under Section 6.1, and You must include a copy of this License with every +copy of the Source Code You distribute. You may not offer or impose any +terms on any Source Code version that alters or restricts the applicable +version of this License or the recipients' rights hereunder. Your license +for shipment of the Contributor Version is conditioned upon Your full compliance +with this Section. The Modifications which You create must comply with +all requirements set out by the Standards body in effect one hundred twenty +(120) days before You ship the Contributor Version. In the event that the +Modifications do not meet such requirements, You agree to publish either +(i) any deviation from the Standards protocol resulting from implementation +of Your Modifications and a reference implementation of Your Modifications +or (ii) Your Modifications in Source Code form, and to make any such deviation +and reference implementation or Modifications available to all third parties +under the same terms as this license on a royalty free basis within thirty +(30) days of Your first customer shipment of Your Modifications. + +3.2 Required Notices. + +You must duplicate the notice in Exhibit A in each file of the +Source Code. If it is not possible to put such notice in a particular Source +Code file due to its structure, then You must include such notice in a +location (such as a relevant directory) where a user would be likely to +look for such a notice. If You created one or more Modification(s) You +may add Your name as a Contributor to the notice described in Exhibit +A. You must also duplicate this License in any documentation for the +Source Code where You describe recipients' rights or ownership rights relating +to Initial Code. You may choose to offer, and to charge a fee for, warranty, +support, indemnity or liability obligations to one or more recipients of +Your version of the Code. However, You may do so only on Your own behalf, +and not on behalf of the Initial Developer. You must make it absolutely +clear than any such warranty, support, indemnity or liability obligation +is offered by You alone, and You hereby agree to indemnify the Initial +Developer for any liability incurred by the Initial Developer as a result +of warranty, support, indemnity or liability terms You offer. + +The copyright notices and links must remain visible and functional in each +HTML of every installed copy of the Code, in this format: + +Billing Software Powered by AgileBill. +Copyright 2004-2008 Agileco, LLC + +These notices and links cannot be removed, disabled, or caused to be hidden or obscured +from view from by modifying any part of the Source Code. The font size for the +notices may not be modified to a font size smaller than 10pt. The font color, +background colors, or any other attributes of the font text, background, or links may not be +modified in any way that renders them illegible, invisble, or unreadable to the +human eye, or causes the links to point to any URL other than shown in the format +above. No attributes may be added to the A HREF tags. + + +3.3 Distribution of Original Code. + +You may distribute Original Code only in Source form (not Executable), +and You must include a notice stating that the Source Code version of the +Original Code is available under the terms of this License. The notice +must be conspicuously included in any notice in an distributed versions, +related documentation or collateral in which You describe +recipients' rights relating to the Original Code. You may distribute the +Source versions of Your version of the Code or ownership +rights under a license of Your choice, which may contain terms different +from this License, provided that You are in compliance with the terms of +this License. If You distribute the Source versions under +a different license You must make it absolutely clear that any terms which +differ from this License are offered by You alone, not by the Initial Developer. + +You hereby agree to indemnify the Initial Developer for any liability incurred +by the Initial Developer as a result of any such terms You offer. + +3.4 Larger Works. + +You may create a Larger Work by combining Original Code with other +code not governed by the terms of this License and distribute the Larger +Work as a single product. In such a case, You must make sure the requirements +of this License are fulfilled for the Original Code. + +4.0 INABILITY TO COMPLY DUE TO STATUTE OR REGULATION + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Original Code due to statute, +judicial order, or regulation then You must: (a) comply with the terms +of this License to the maximum extent possible; and (b) describe the limitations +and the code they affect. Such description must be included in the LEGAL +file described in Section 3.2 and must be included with all distributions +of the Source Code. Except to the extent prohibited by statute or regulation, +such description must be sufficiently detailed for a recipient of ordinary +skill to be able to understand it. + +5.0 APPLICATION OF THIS LICENSE + +This License applies to code to which the Initial Developer has attached +the notice in Exhibit A and to related Modifications as set out in Section +3.1. + +6.0 VERSIONS OF THE LICENSE + +6.1 New Versions. + +Agileco may publish revised and/or new versions of the License from time +to time. Each version will be given a distinguishing version number. + +6.2 Effect of New Versions. + +Once Original Code has been published under a particular version of +the License, You may always continue to use it under the terms of that +version. You may also choose to use such Original Code under the terms +of any subsequent version of the License published by Agile. No one other +than Agileco has the right to modify the terms applicable to Original Code. + +7.0 DISCLAIMER OF WARRANTY + +ORIGINAL CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT +LIMITATION, +WARRANTIES THAT THE ORIGINAL CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT +FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY +AND PERFORMANCE OF THE ORIGINAL CODE IS WITH YOU. SHOULD ANY ORIGINAL CODE +PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER) ASSUME +THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER +OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY +ORIGINAL CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +8.0 TERMINATION + +8.1 This License and the rights granted hereunder will terminate +automatically if You fail to comply with terms herein and fail to cure +such breach within 30 days of becoming aware of the breach. All sublicenses +to the Original Code which are properly granted shall survive any termination +of this License. Provisions which, by their nature, must remain in effect +beyond the termination of this License shall survive. + +8.2 In the event of termination under Section 8.1 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or any distributor hereunder prior to +termination shall survive termination. + +9.0 LIMIT OF LIABILITY + +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING +NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, +ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF ORIGINAL CODE, OR ANY SUPPLIER +OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, +INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT +LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE +OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN +IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. +THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR +PERSONAL INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE +LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION +OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION +AND LIMITATION MAY NOT APPLY TO YOU. + +10.0 U.S. GOVERNMENT END USERS + +U.S. Government: If this Software is being acquired by or on behalf +of the U.S. Government or by a U.S. Government prime contractor or subcontractor +(at any tier), then the Government's rights in the Software and accompanying +documentation shall be only as set forth in this license; this is in accordance +with 48 C.F.R. 227.7201 through 227.7202-4 (for Department of Defense (DoD) +acquisitions) and with 48 C.F.R. 2.101 and 12.212 (for non-DoD acquisitions). + +11.0 MISCELLANEOUS + +This License represents the complete agreement concerning subject matter +hereof. If any provision of this License is held to be unenforceable, such +provision shall be reformed only to the extent necessary to make it enforceable. + +This License shall be governed by South Carolina law provisions (except to +the extent applicable law, if any, provides otherwise), excluding its +conflict-of-law +provisions. With respect to disputes in which at least one party is a citizen +of, or an entity chartered or registered to do business in the United States +of America, any litigation relating to this License shall be subject to +the jurisdiction of the Federal Courts of South Carolina, +with venue lying in Greenville, South Carolina, with the losing party +responsible for costs, including without limitation, court costs and reasonable +attorneys' fees and expenses. The application of the United Nations Convention +on Contracts for the International Sale of Goods is expressly excluded. +Any law or regulation which provides that the language of a contract shall +be construed against the drafter shall not apply to this License. + +EXHIBIT A - Open AgileBill License + +"The contents of this file are subject to the Open AgileBill License v1.4 (the "License"); +You may not use this file except in compliance with the License. You may obtain +a copy of the License at http://www.agileco.com/agilebill/license1-4.txt + +Software distributed under the License is distributed on +an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either +express or implied. See the License for the specific +language governing rights and limitations under the License. + +The Original Code is ______________________________________. + +The Initial Developer of the Original Code is: +Agileco, LLC + +Portions created by: _______________________________________ + +are Copyright (C): _______________________________________ + +All Rights Reserved. + +Contributor(s): _______________________________________ + + + +EXHIBIT B - Standards + +The Standard is defined as the following: + +OpenOffice.org XML File Format Specification, located at http://xml.openoffice.org + +OpenOffice.org Application Programming Interface Specification, located +at http://api.openoffice.org \ No newline at end of file diff --git a/admin.php b/admin.php new file mode 100644 index 00000000..40a50940 --- /dev/null +++ b/admin.php @@ -0,0 +1,26 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +if(!isset($_POST["default_admin"]) && !isset($_POST["default_admin"])) +{ + DEFINE('ADMIN_FORCE', true); +} +include_once('index.php'); +?> \ No newline at end of file diff --git a/ajax.php b/ajax.php new file mode 100644 index 00000000..0abcd892 --- /dev/null +++ b/ajax.php @@ -0,0 +1,49 @@ + + * @package AgileBill + * @version 1.4.93 + */ + + +ob_start(); +define('AJAX', 1); +require_once('config.inc.php'); +require_once('modules/core/vars.inc.php'); +$C_vars = new CORE_vars; +$VAR = $C_vars->f; +require_once('includes/adodb/adodb.inc.php'); +require_once('modules/core/auth.inc.php'); +require_once('modules/core/database.inc.php'); +require_once('modules/core/method_ajax.inc.php'); +require_once('modules/core/session.inc.php'); +require_once('modules/core/setup.inc.php'); +$C_debug = new CORE_debugger; +$C_setup = new CORE_setup; +$C_sess = new CORE_session; +$C_sess->session_constant(); +$C_method = new CORE_method; +if ((isset($VAR['_login'])) && (isset($VAR['_username'])) && (isset($VAR['_password']))) { + require_once(PATH_CORE . 'login.inc.php'); + $C_login = new CORE_login_handler(); + $C_login->login($VAR); +} +$C_sess->session_constant_log(); +$C_auth = new CORE_auth (false); +$C_method->do_all(); +ob_end_flush(); + +?> \ No newline at end of file diff --git a/config.inc.php b/config.inc.php new file mode 100644 index 00000000..bbbe3443 --- /dev/null +++ b/config.inc.php @@ -0,0 +1,64 @@ + '_news', 'p' => 'newsletter:newsletter' ), + Array ( 's' => '_affiliate', 'p' => 'affiliate:affiliate' ), + Array ( 's' => '_contact', 'p' => 'staff:staff' ), + Array ( 's' => '_ticket', 'p' => 'ticket:ticket' ), + Array ( 's' => '_account', 'p' => 'account:account' ), + Array ( 's' => '_products', 'p' => 'product:cat' ), + Array ( 's' => '_product', 'p' => 'product:details' ), + Array ( 's' => '_cart', 'p' => 'cart:cart' ), + Array ( 's' => '_checkout', 'p' => 'checkout:checkout' ), + Array ( 's' => '_static', 'p' => 'static_page:show' ) + ); +?> \ No newline at end of file diff --git a/cookie.index.php b/cookie.index.php new file mode 100644 index 00000000..72e77915 --- /dev/null +++ b/cookie.index.php @@ -0,0 +1,103 @@ +f; + + # initialize the site setup + $C_setup = new CORE_setup; + + # initialize the session handler + $C_sess = new CORE_session; + + # define the other session variables as constants + $C_sess->session_constant(); + + # update the session constants + $C_sess->session_constant_log(); + + # initialze the authentication handler + $force = false; + $C_auth = new CORE_auth ($force); + + ############################################################################ + # Verify the User's Access + $authorized = false; + if(defined("SESS_LOGGED") && SESS_LOGGED == "1" && agile_check_auth ( _HTACCESS_ID ) ) + $authorized = true; + + ############################################################################ + ## forward to login page: + if ( !$authorized ) + { + header("Location: ".URL."?_page=account:login_cookie&_htaccess_id=" . _HTACCESS_ID. "&_next_page="._RETURN_URL); + exit(); + } + + + ### Reset the 's' var + if(isset($_POST_s)) + { + $_POST['s'] = $_POST_s; + } + else if (isset($_GET_s)) + { + $_GET['s'] = $_GET_s; + } + + + ############################## + ## Check Authentication ## + ############################## + function agile_check_auth($id) + { + ### Check if user is a member of one of the authorized groups: + $db = &DB(); + $sql = 'SELECT status,group_avail FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + status = ' . $db->qstr('1') . ' AND + id = ' . $db->qstr($id); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + global $C_auth; + @$arr = unserialize($result->fields['group_avail']); + for($i=0; $iauth_group_by_id($arr[$i])) + { + return true; + } + } + } + return false; + } + + ob_end_flush(); +?> \ No newline at end of file diff --git a/htaccess_index.php b/htaccess_index.php new file mode 100644 index 00000000..dee70bae --- /dev/null +++ b/htaccess_index.php @@ -0,0 +1,266 @@ + 'jpg', 'type' => 'image/jpeg', 'disposition' => 'inline'), + Array ('name' => 'jpeg', 'type' => 'image/jpeg', 'disposition' => 'inline'), + Array ('name' => 'jpe', 'type' => 'image/jpeg', 'disposition' => 'inline'), + Array ('name' => 'gif', 'type' => 'image/gif', 'disposition' => 'inline'), + Array ('name' => 'bmp', 'type' => 'image/bmp', 'disposition' => 'inline'), + Array ('name' => 'tif', 'type' => 'image/tif', 'disposition' => 'inline'), + Array ('name' => 'png', 'type' => 'image/png', 'disposition' => 'inline'), + Array ('name' => 'wbmp', 'type' => 'image/vnd.wap.wbmp', 'disposition' => 'inline'), + + Array ('name' => 'pdf', 'type' => 'application/pdf', 'disposition' => 'inline'), + Array ('name' => 'exe', 'type' => 'application/octet-stream', 'disposition'=> 'attatchment'), + Array ('name' => 'zip', 'type' => 'application/x-zip', 'disposition' => 'attatchment'), + Array ('name' => 'gzip', 'type' => 'application/gzip', 'disposition' => 'attatchment'), + Array ('name' => 'tgz', 'type' => 'application/tgz', 'disposition' => 'attatchment'), + Array ('name' => 'gz', 'type' => 'application/gz', 'disposition' => 'attatchment'), + Array ('name' => 'doc', 'type' => 'application/ms-word', 'disposition' => 'inline'), + Array ('name' => 'xls', 'type' => 'application/ms-excel', 'disposition' => 'inline'), + Array ('name' => 'csv', 'type' => 'application/ms-excel', 'disposition' => 'inline'), + Array ('name' => 'swf', 'type' => 'application/x-shockwave-flash', 'disposition' => 'inline'), + + Array ('name' => 'txt', 'type' => 'text/plain', 'disposition' => 'inline'), + Array ('name' => 'text', 'type' => 'text/plain', 'disposition' => 'inline'), + Array ('name' => 'rtf', 'type' => 'text/richtext', 'disposition' => 'inline'), + Array ('name' => 'xml', 'type' => 'text/xml', 'disposition' => 'inline'), + Array ('name' => 'css', 'type' => 'text/css', 'disposition' => 'inline'), + Array ('name' => 'js', 'type' => 'text/plain', 'disposition' => 'inline'), + Array ('name' => 'wml', 'type' => 'text/vnd.wap.wml', 'disposition' => 'inline'), + + Array ('name' => 'avi', 'type' => 'video/avi', 'disposition' => 'attatchment'), + Array ('name' => 'mpg', 'type' => 'video/mpeg', 'disposition' => 'attatchment'), + Array ('name' => 'mpeg', 'type' => 'video/mpeg', 'disposition' => 'attatchment'), + Array ('name' => 'mpe', 'type' => 'video/mpeg', 'disposition' => 'attatchment'), + Array ('name' => 'wmv', 'type' => 'video/x-ms-wmv', 'disposition' => 'attatchment'), + Array ('name' => 'asf', 'type' => 'video/x-ms-asf', 'disposition' => 'attatchment') + ); + + # Load the config file: + require_once('config.inc.php'); + + # Require the needed files... + require_once(PATH_ADODB . 'adodb.inc.php'); + require_once(PATH_CORE . 'auth.inc.php'); + require_once(PATH_CORE . 'database.inc.php'); + require_once(PATH_CORE . 'method.inc.php'); + require_once(PATH_CORE . 'session.inc.php'); + require_once(PATH_CORE . 'translate.inc.php'); + require_once(PATH_CORE . 'setup.inc.php'); + require_once(PATH_CORE . 'vars.inc.php'); + require_once(PATH_CORE . 'xml.inc.php'); + + ## Path to the error file + define ( 'ERROR_GIF', PATH_THEMES.DEF_THEME_N.'/images/htaccess_error.gif' ); + + # start the debugger + $C_debug = new CORE_debugger; + + # initialize the GET/POST vars + $C_vars = new CORE_vars; + $VAR = $C_vars->f; + + # initialize the site setup + $C_setup = new CORE_setup; + + # initialize the session handler + $C_sess = new CORE_session; + + # define the other session variables as constants + $C_sess->session_constant(); + + # initialize the translation handler + $C_translate = new CORE_translate; + + # update the session constants + $C_sess->session_constant_log(); + + # initialze the authentication handler + $force = false; + $C_auth = new CORE_auth ($force); + + ######################################################################## + # Verify the User's Access + $authorized = false; + if(defined("SESS_LOGGED")) + if(SESS_LOGGED == "1" && check_auth($VAR['_HTACCESS_ID'])) + $authorized = true; + + ############################################################################ + ## If this was a GET: + if ( isset($REQUEST_URI ) ) + { + $ARRAY = explode ( '?', $REQUEST_URI); + $REQUEST_URI = $ARRAY[0] ; + } + + ## Define global system vars... + if(!isset($DOCUMENT_ROOT)) $DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"]; + if(!isset($REQUEST_URI)) $REQUEST_URI = $_SERVER["REQUEST_URI"]; + if(!isset($SCRIPT_FILENAME)) $SCRIPT_FILENAME = $_SERVER["SCRIPT_FILENAME"]; + + + ############################################################################ + ### Check if File Exists: + if (file_exists($DOCUMENT_ROOT.$REQUEST_URI) && + ($SCRIPT_FILENAME != $DOCUMENT_ROOT.$REQUEST_URI) && + ($REQUEST_URI != "/") && + (!ereg( '[////]{2,}$', $REQUEST_URI ) ) ) + { + + $url = $REQUEST_URI; + + ######################################################################## + # Check Passthu File Types: + + for ($i=0; $i
PAGE NOT FOUND
"; + exit(); + } + } else { + ## forward to login page: + header("Location: ".URL."?_page=account:login_htaccess&_htaccess_id=" . $VAR['_HTACCESS_ID'] . '&_htaccess_dir_id=' . $VAR['_HTACCESS_DIR_ID']); + exit(); + } + + + ######################################################################## + # Filetype not defined, force download: + + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Disposition: attachment; filename=".@basename($DOCUMENT_ROOT.$url).";"); + header("Content-Transfer-Encoding: binary"); + header("Content-Length: ".@filesize($DOCUMENT_ROOT.$url)); + @readfile("$DOCUMENT_ROOT.$url"); + exit(); + + + ############################## + ## Check Authentication ## + ############################## + function check_auth($id) + { + ### Check if user is a member of one of the authorized groups: + $db = &DB(); + $sql = 'SELECT status,group_avail FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + status = ' . $db->qstr('1') . ' AND + id = ' . $db->qstr($id); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) { + global $C_auth; + @$arr = unserialize($result->fields['group_avail']); + for($i=0; $iauth_group_by_id($arr[$i])) + return true; + } + return false; + } + + ob_end_flush(); +?> \ No newline at end of file diff --git a/includes/adodb/adodb-csvlib.inc.php b/includes/adodb/adodb-csvlib.inc.php new file mode 100644 index 00000000..86d9af84 --- /dev/null +++ b/includes/adodb/adodb-csvlib.inc.php @@ -0,0 +1,317 @@ +FieldCount() : 0; + + if ($sql) $sql = urlencode($sql); + // metadata setup + + if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete + if (is_object($conn)) { + $sql .= ','.$conn->Affected_Rows(); + $sql .= ','.$conn->Insert_ID(); + } else + $sql .= ',,'; + + $text = "====-1,0,$sql\n"; + return $text; + } + $tt = ($rs->timeCreated) ? $rs->timeCreated : time(); + + ## changed format from ====0 to ====1 + $line = "====1,$tt,$sql\n"; + + if ($rs->databaseType == 'array') { + $rows = $rs->_array; + } else { + $rows = array(); + while (!$rs->EOF) { + $rows[] = $rs->fields; + $rs->MoveNext(); + } + } + + for($i=0; $i < $max; $i++) { + $o = $rs->FetchField($i); + $flds[] = $o; + } + + $savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode; + $class = $rs->connection->arrayClass; + $rs2 = new $class(); + $rs2->sql = $rs->sql; + $rs2->oldProvider = $rs->dataProvider; + $rs2->InitArrayFields($rows,$flds); + $rs2->fetchMode = $savefetch; + return $line.serialize($rs2); + } + + +/** +* Open CSV file and convert it into Data. +* +* @param url file/ftp/http url +* @param err returns the error message +* @param timeout dispose if recordset has been alive for $timeout secs +* +* @return recordset, or false if error occured. If no +* error occurred in sql INSERT/UPDATE/DELETE, +* empty recordset is returned +*/ + function csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array') + { + $false = false; + $err = false; + $fp = @fopen($url,'rb'); + if (!$fp) { + $err = $url.' file/URL not found'; + return $false; + } + @flock($fp, LOCK_SH); + $arr = array(); + $ttl = 0; + + if ($meta = fgetcsv($fp, 32000, ",")) { + // check if error message + if (strncmp($meta[0],'****',4) === 0) { + $err = trim(substr($meta[0],4,1024)); + fclose($fp); + return $false; + } + // check for meta data + // $meta[0] is -1 means return an empty recordset + // $meta[1] contains a time + + if (strncmp($meta[0], '====',4) === 0) { + + if ($meta[0] == "====-1") { + if (sizeof($meta) < 5) { + $err = "Corrupt first line for format -1"; + fclose($fp); + return $false; + } + fclose($fp); + + if ($timeout > 0) { + $err = " Illegal Timeout $timeout "; + return $false; + } + + $rs = new $rsclass($val=true); + $rs->fields = array(); + $rs->timeCreated = $meta[1]; + $rs->EOF = true; + $rs->_numOfFields = 0; + $rs->sql = urldecode($meta[2]); + $rs->affectedrows = (integer)$meta[3]; + $rs->insertid = $meta[4]; + return $rs; + } + # Under high volume loads, we want only 1 thread/process to _write_file + # so that we don't have 50 processes queueing to write the same data. + # We use probabilistic timeout, ahead of time. + # + # -4 sec before timeout, give processes 1/32 chance of timing out + # -2 sec before timeout, give processes 1/16 chance of timing out + # -1 sec after timeout give processes 1/4 chance of timing out + # +0 sec after timeout, give processes 100% chance of timing out + if (sizeof($meta) > 1) { + if($timeout >0){ + $tdiff = (integer)( $meta[1]+$timeout - time()); + if ($tdiff <= 2) { + switch($tdiff) { + case 4: + case 3: + if ((rand() & 31) == 0) { + fclose($fp); + $err = "Timeout 3"; + return $false; + } + break; + case 2: + if ((rand() & 15) == 0) { + fclose($fp); + $err = "Timeout 2"; + return $false; + } + break; + case 1: + if ((rand() & 3) == 0) { + fclose($fp); + $err = "Timeout 1"; + return $false; + } + break; + default: + fclose($fp); + $err = "Timeout 0"; + return $false; + } // switch + + } // if check flush cache + }// (timeout>0) + $ttl = $meta[1]; + } + //================================================ + // new cache format - use serialize extensively... + if ($meta[0] === '====1') { + // slurp in the data + $MAXSIZE = 128000; + + $text = fread($fp,$MAXSIZE); + if (strlen($text)) { + while ($txt = fread($fp,$MAXSIZE)) { + $text .= $txt; + } + } + fclose($fp); + $rs = unserialize($text); + if (is_object($rs)) $rs->timeCreated = $ttl; + else { + $err = "Unable to unserialize recordset"; + //echo htmlspecialchars($text),' !--END--!

'; + } + return $rs; + } + + $meta = false; + $meta = fgetcsv($fp, 32000, ","); + if (!$meta) { + fclose($fp); + $err = "Unexpected EOF 1"; + return $false; + } + } + + // Get Column definitions + $flds = array(); + foreach($meta as $o) { + $o2 = explode(':',$o); + if (sizeof($o2)!=3) { + $arr[] = $meta; + $flds = false; + break; + } + $fld = new ADOFieldObject(); + $fld->name = urldecode($o2[0]); + $fld->type = $o2[1]; + $fld->max_length = $o2[2]; + $flds[] = $fld; + } + } else { + fclose($fp); + $err = "Recordset had unexpected EOF 2"; + return $false; + } + + // slurp in the data + $MAXSIZE = 128000; + + $text = ''; + while ($txt = fread($fp,$MAXSIZE)) { + $text .= $txt; + } + + fclose($fp); + @$arr = unserialize($text); + //var_dump($arr); + if (!is_array($arr)) { + $err = "Recordset had unexpected EOF (in serialized recordset)"; + if (get_magic_quotes_runtime()) $err .= ". Magic Quotes Runtime should be disabled!"; + return $false; + } + $rs = new $rsclass(); + $rs->timeCreated = $ttl; + $rs->InitArrayFields($arr,$flds); + return $rs; + } + + + /** + * Save a file $filename and its $contents (normally for caching) with file locking + * Returns true if ok, false if fopen/fwrite error, 0 if rename error (eg. file is locked) + */ + function adodb_write_file($filename, $contents,$debug=false) + { + # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows + # So to simulate locking, we assume that rename is an atomic operation. + # First we delete $filename, then we create a $tempfile write to it and + # rename to the desired $filename. If the rename works, then we successfully + # modified the file exclusively. + # What a stupid need - having to simulate locking. + # Risks: + # 1. $tempfile name is not unique -- very very low + # 2. unlink($filename) fails -- ok, rename will fail + # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs + # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated + if (strncmp(PHP_OS,'WIN',3) === 0) { + // skip the decimal place + $mtime = substr(str_replace(' ','_',microtime()),2); + // getmypid() actually returns 0 on Win98 - never mind! + $tmpname = $filename.uniqid($mtime).getmypid(); + if (!($fd = @fopen($tmpname,'w'))) return false; + if (fwrite($fd,$contents)) $ok = true; + else $ok = false; + fclose($fd); + + if ($ok) { + @chmod($tmpname,0644); + // the tricky moment + @unlink($filename); + if (!@rename($tmpname,$filename)) { + unlink($tmpname); + $ok = 0; + } + if (!$ok) { + if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed')); + } + } + return $ok; + } + if (!($fd = @fopen($filename, 'a'))) return false; + if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) { + if (fwrite( $fd, $contents )) $ok = true; + else $ok = false; + fclose($fd); + @chmod($filename,0644); + }else { + fclose($fd); + if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename
\n"); + $ok = false; + } + + return $ok; + } +?> \ No newline at end of file diff --git a/includes/adodb/adodb-datadict.inc.php b/includes/adodb/adodb-datadict.inc.php new file mode 100644 index 00000000..88b1f83d --- /dev/null +++ b/includes/adodb/adodb-datadict.inc.php @@ -0,0 +1,1001 @@ +$str

"; +$a= Lens_ParseArgs($str); +print "
";
+print_r($a);
+print "
"; +} + + +if (!function_exists('ctype_alnum')) { + function ctype_alnum($text) { + return preg_match('/^[a-z0-9]*$/i', $text); + } +} + +//Lens_ParseTest(); + +/** + Parse arguments, treat "text" (text) and 'text' as quotation marks. + To escape, use "" or '' or )) + + Will read in "abc def" sans quotes, as: abc def + Same with 'abc def'. + However if `abc def`, then will read in as `abc def` + + @param endstmtchar Character that indicates end of statement + @param tokenchars Include the following characters in tokens apart from A-Z and 0-9 + @returns 2 dimensional array containing parsed tokens. +*/ +function Lens_ParseArgs($args,$endstmtchar=',',$tokenchars='_.-') +{ + $pos = 0; + $intoken = false; + $stmtno = 0; + $endquote = false; + $tokens = array(); + $tokens[$stmtno] = array(); + $max = strlen($args); + $quoted = false; + $tokarr = array(); + + while ($pos < $max) { + $ch = substr($args,$pos,1); + switch($ch) { + case ' ': + case "\t": + case "\n": + case "\r": + if (!$quoted) { + if ($intoken) { + $intoken = false; + $tokens[$stmtno][] = implode('',$tokarr); + } + break; + } + + $tokarr[] = $ch; + break; + + case '`': + if ($intoken) $tokarr[] = $ch; + case '(': + case ')': + case '"': + case "'": + + if ($intoken) { + if (empty($endquote)) { + $tokens[$stmtno][] = implode('',$tokarr); + if ($ch == '(') $endquote = ')'; + else $endquote = $ch; + $quoted = true; + $intoken = true; + $tokarr = array(); + } else if ($endquote == $ch) { + $ch2 = substr($args,$pos+1,1); + if ($ch2 == $endquote) { + $pos += 1; + $tokarr[] = $ch2; + } else { + $quoted = false; + $intoken = false; + $tokens[$stmtno][] = implode('',$tokarr); + $endquote = ''; + } + } else + $tokarr[] = $ch; + + }else { + + if ($ch == '(') $endquote = ')'; + else $endquote = $ch; + $quoted = true; + $intoken = true; + $tokarr = array(); + if ($ch == '`') $tokarr[] = '`'; + } + break; + + default: + + if (!$intoken) { + if ($ch == $endstmtchar) { + $stmtno += 1; + $tokens[$stmtno] = array(); + break; + } + + $intoken = true; + $quoted = false; + $endquote = false; + $tokarr = array(); + + } + + if ($quoted) $tokarr[] = $ch; + else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) $tokarr[] = $ch; + else { + if ($ch == $endstmtchar) { + $tokens[$stmtno][] = implode('',$tokarr); + $stmtno += 1; + $tokens[$stmtno] = array(); + $intoken = false; + $tokarr = array(); + break; + } + $tokens[$stmtno][] = implode('',$tokarr); + $tokens[$stmtno][] = $ch; + $intoken = false; + } + } + $pos += 1; + } + if ($intoken) $tokens[$stmtno][] = implode('',$tokarr); + + return $tokens; +} + + +class ADODB_DataDict { + var $connection; + var $debug = false; + var $dropTable = 'DROP TABLE %s'; + var $renameTable = 'RENAME TABLE %s TO %s'; + var $dropIndex = 'DROP INDEX %s'; + var $addCol = ' ADD'; + var $alterCol = ' ALTER COLUMN'; + var $dropCol = ' DROP COLUMN'; + var $renameColumn = 'ALTER TABLE %s RENAME COLUMN %s TO %s'; // table, old-column, new-column, column-definitions (not used by default) + var $nameRegex = '\w'; + var $nameRegexBrackets = 'a-zA-Z0-9_\(\)'; + var $schema = false; + var $serverInfo = array(); + var $autoIncrement = false; + var $dataProvider; + var $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME'); // for changetablesql + var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob + /// in other words, we use a text area for editting. + + function GetCommentSQL($table,$col) + { + return false; + } + + function SetCommentSQL($table,$col,$cmt) + { + return false; + } + + function MetaTables() + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaTables(); + } + + function MetaColumns($tab, $upper=true, $schema=false) + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaColumns($this->TableName($tab), $upper, $schema); + } + + function MetaPrimaryKeys($tab,$owner=false,$intkey=false) + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaPrimaryKeys($this->TableName($tab), $owner, $intkey); + } + + function MetaIndexes($table, $primary = false, $owner = false) + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaIndexes($this->TableName($table), $primary, $owner); + } + + function MetaType($t,$len=-1,$fieldobj=false) + { + static $typeMap = array( + 'VARCHAR' => 'C', + 'VARCHAR2' => 'C', + 'CHAR' => 'C', + 'C' => 'C', + 'STRING' => 'C', + 'NCHAR' => 'C', + 'NVARCHAR' => 'C', + 'VARYING' => 'C', + 'BPCHAR' => 'C', + 'CHARACTER' => 'C', + 'INTERVAL' => 'C', # Postgres + 'MACADDR' => 'C', # postgres + 'VAR_STRING' => 'C', # mysql + ## + 'LONGCHAR' => 'X', + 'TEXT' => 'X', + 'NTEXT' => 'X', + 'M' => 'X', + 'X' => 'X', + 'CLOB' => 'X', + 'NCLOB' => 'X', + 'LVARCHAR' => 'X', + ## + 'BLOB' => 'B', + 'IMAGE' => 'B', + 'BINARY' => 'B', + 'VARBINARY' => 'B', + 'LONGBINARY' => 'B', + 'B' => 'B', + ## + 'YEAR' => 'D', // mysql + 'DATE' => 'D', + 'D' => 'D', + ## + 'UNIQUEIDENTIFIER' => 'C', # MS SQL Server + ## + 'TIME' => 'T', + 'TIMESTAMP' => 'T', + 'DATETIME' => 'T', + 'TIMESTAMPTZ' => 'T', + 'SMALLDATETIME' => 'T', + 'T' => 'T', + 'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql + ## + 'BOOL' => 'L', + 'BOOLEAN' => 'L', + 'BIT' => 'L', + 'L' => 'L', + ## + 'COUNTER' => 'R', + 'R' => 'R', + 'SERIAL' => 'R', // ifx + 'INT IDENTITY' => 'R', + ## + 'INT' => 'I', + 'INT2' => 'I', + 'INT4' => 'I', + 'INT8' => 'I', + 'INTEGER' => 'I', + 'INTEGER UNSIGNED' => 'I', + 'SHORT' => 'I', + 'TINYINT' => 'I', + 'SMALLINT' => 'I', + 'I' => 'I', + ## + 'LONG' => 'N', // interbase is numeric, oci8 is blob + 'BIGINT' => 'N', // this is bigger than PHP 32-bit integers + 'DECIMAL' => 'N', + 'DEC' => 'N', + 'REAL' => 'N', + 'DOUBLE' => 'N', + 'DOUBLE PRECISION' => 'N', + 'SMALLFLOAT' => 'N', + 'FLOAT' => 'N', + 'NUMBER' => 'N', + 'NUM' => 'N', + 'NUMERIC' => 'N', + 'MONEY' => 'N', + + ## informix 9.2 + 'SQLINT' => 'I', + 'SQLSERIAL' => 'I', + 'SQLSMINT' => 'I', + 'SQLSMFLOAT' => 'N', + 'SQLFLOAT' => 'N', + 'SQLMONEY' => 'N', + 'SQLDECIMAL' => 'N', + 'SQLDATE' => 'D', + 'SQLVCHAR' => 'C', + 'SQLCHAR' => 'C', + 'SQLDTIME' => 'T', + 'SQLINTERVAL' => 'N', + 'SQLBYTES' => 'B', + 'SQLTEXT' => 'X', + ## informix 10 + "SQLINT8" => 'I8', + "SQLSERIAL8" => 'I8', + "SQLNCHAR" => 'C', + "SQLNVCHAR" => 'C', + "SQLLVARCHAR" => 'X', + "SQLBOOL" => 'L' + ); + + if (!$this->connection->IsConnected()) { + $t = strtoupper($t); + if (isset($typeMap[$t])) return $typeMap[$t]; + return 'N'; + } + return $this->connection->MetaType($t,$len,$fieldobj); + } + + function NameQuote($name = NULL,$allowBrackets=false) + { + if (!is_string($name)) { + return FALSE; + } + + $name = trim($name); + + if ( !is_object($this->connection) ) { + return $name; + } + + $quote = $this->connection->nameQuote; + + // if name is of the form `name`, quote it + if ( preg_match('/^`(.+)`$/', $name, $matches) ) { + return $quote . $matches[1] . $quote; + } + + // if name contains special characters, quote it + $regex = ($allowBrackets) ? $this->nameRegexBrackets : $this->nameRegex; + + if ( !preg_match('/^[' . $regex . ']+$/', $name) ) { + return $quote . $name . $quote; + } + + return $name; + } + + function TableName($name) + { + if ( $this->schema ) { + return $this->NameQuote($this->schema) .'.'. $this->NameQuote($name); + } + return $this->NameQuote($name); + } + + // Executes the sql array returned by GetTableSQL and GetIndexSQL + function ExecuteSQLArray($sql, $continueOnError = true) + { + $rez = 2; + $conn = $this->connection; + $saved = $conn->debug; + foreach($sql as $line) { + + if ($this->debug) $conn->debug = true; + $ok = $conn->Execute($line); + $conn->debug = $saved; + if (!$ok) { + if ($this->debug) ADOConnection::outp($conn->ErrorMsg()); + if (!$continueOnError) return 0; + $rez = 1; + } + } + return $rez; + } + + /** + Returns the actual type given a character code. + + C: varchar + X: CLOB (character large object) or largest varchar size if CLOB is not supported + C2: Multibyte varchar + X2: Multibyte CLOB + + B: BLOB (binary large object) + + D: Date + T: Date-time + L: Integer field suitable for storing booleans (0 or 1) + I: Integer + F: Floating point number + N: Numeric or decimal number + */ + + function ActualType($meta) + { + return $meta; + } + + function CreateDatabase($dbname,$options=false) + { + $options = $this->_Options($options); + $sql = array(); + + $s = 'CREATE DATABASE ' . $this->NameQuote($dbname); + if (isset($options[$this->upperName])) + $s .= ' '.$options[$this->upperName]; + + $sql[] = $s; + return $sql; + } + + /* + Generates the SQL to create index. Returns an array of sql strings. + */ + function CreateIndexSQL($idxname, $tabname, $flds, $idxoptions = false) + { + if (!is_array($flds)) { + $flds = explode(',',$flds); + } + + foreach($flds as $key => $fld) { + # some indexes can use partial fields, eg. index first 32 chars of "name" with NAME(32) + $flds[$key] = $this->NameQuote($fld,$allowBrackets=true); + } + + return $this->_IndexSQL($this->NameQuote($idxname), $this->TableName($tabname), $flds, $this->_Options($idxoptions)); + } + + function DropIndexSQL ($idxname, $tabname = NULL) + { + return array(sprintf($this->dropIndex, $this->NameQuote($idxname), $this->TableName($tabname))); + } + + function SetSchema($schema) + { + $this->schema = $schema; + } + + function AddColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); + $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' '; + foreach($lines as $v) { + $sql[] = $alter . $v; + } + if (is_array($idxs)) { + foreach($idxs as $idx => $idxdef) { + $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']); + $sql = array_merge($sql, $sql_idxs); + } + } + return $sql; + } + + /** + * Change the definition of one column + * + * As some DBM's can't do that on there own, you need to supply the complete defintion of the new table, + * to allow, recreating the table and copying the content over to the new table + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default '' + * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); + $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' '; + foreach($lines as $v) { + $sql[] = $alter . $v; + } + if (is_array($idxs)) { + foreach($idxs as $idx => $idxdef) { + $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']); + $sql = array_merge($sql, $sql_idxs); + } + + } + return $sql; + } + + /** + * Rename one column + * + * Some DBM's can only do this together with changeing the type of the column (even if that stays the same, eg. mysql) + * @param string $tabname table-name + * @param string $oldcolumn column-name to be renamed + * @param string $newcolumn new column-name + * @param string $flds='' complete column-defintion-string like for AddColumnSQL, only used by mysql atm., default='' + * @return array with SQL strings + */ + function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='') + { + $tabname = $this->TableName ($tabname); + if ($flds) { + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); + list(,$first) = each($lines); + list(,$column_def) = split("[\t ]+",$first,2); + } + return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def)); + } + + /** + * Drop one column + * + * Some DBM's can't do that on there own, you need to supply the complete defintion of the new table, + * to allow, recreating the table and copying the content over to the new table + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default '' + * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + $tabname = $this->TableName ($tabname); + if (!is_array($flds)) $flds = explode(',',$flds); + $sql = array(); + $alter = 'ALTER TABLE ' . $tabname . $this->dropCol . ' '; + foreach($flds as $v) { + $sql[] = $alter . $this->NameQuote($v); + } + return $sql; + } + + function DropTableSQL($tabname) + { + return array (sprintf($this->dropTable, $this->TableName($tabname))); + } + + function RenameTableSQL($tabname,$newname) + { + return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname))); + } + + /** + Generate the SQL to create table. Returns an array of sql strings. + */ + function CreateTableSQL($tabname, $flds, $tableoptions=array()) + { + list($lines,$pkey,$idxs) = $this->_GenFields($flds, true); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); + + $taboptions = $this->_Options($tableoptions); + $tabname = $this->TableName ($tabname); + $sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions); + + // ggiunta - 2006/10/12 - KLUDGE: + // if we are on autoincrement, and table options includes REPLACE, the + // autoincrement sequence has already been dropped on table creation sql, so + // we avoid passing REPLACE to trigger creation code. This prevents + // creating sql that double-drops the sequence + if ($this->autoIncrement && isset($taboptions['REPLACE'])) + unset($taboptions['REPLACE']); + $tsql = $this->_Triggers($tabname,$taboptions); + foreach($tsql as $s) $sql[] = $s; + + if (is_array($idxs)) { + foreach($idxs as $idx => $idxdef) { + $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']); + $sql = array_merge($sql, $sql_idxs); + } + } + + return $sql; + } + + function _GenFields($flds,$widespacing=false) + { + if (is_string($flds)) { + $padding = ' '; + $txt = $flds.$padding; + $flds = array(); + $flds0 = Lens_ParseArgs($txt,','); + $hasparam = false; + foreach($flds0 as $f0) { + $f1 = array(); + foreach($f0 as $token) { + switch (strtoupper($token)) { + case 'INDEX': + $f1['INDEX'] = ''; + // fall through intentionally + case 'CONSTRAINT': + case 'DEFAULT': + $hasparam = $token; + break; + default: + if ($hasparam) $f1[$hasparam] = $token; + else $f1[] = $token; + $hasparam = false; + break; + } + } + // 'index' token without a name means single column index: name it after column + if (array_key_exists('INDEX', $f1) && $f1['INDEX'] == '') { + $f1['INDEX'] = isset($f0['NAME']) ? $f0['NAME'] : $f0[0]; + // check if column name used to create an index name was quoted + if (($f1['INDEX'][0] == '"' || $f1['INDEX'][0] == "'" || $f1['INDEX'][0] == "`") && + ($f1['INDEX'][0] == substr($f1['INDEX'], -1))) { + $f1['INDEX'] = $f1['INDEX'][0].'idx_'.substr($f1['INDEX'], 1, -1).$f1['INDEX'][0]; + } + else + $f1['INDEX'] = 'idx_'.$f1['INDEX']; + } + // reset it, so we don't get next field 1st token as INDEX... + $hasparam = false; + + $flds[] = $f1; + + } + } + $this->autoIncrement = false; + $lines = array(); + $pkey = array(); + $idxs = array(); + foreach($flds as $fld) { + $fld = _array_change_key_case($fld); + + $fname = false; + $fdefault = false; + $fautoinc = false; + $ftype = false; + $fsize = false; + $fprec = false; + $fprimary = false; + $fnoquote = false; + $fdefts = false; + $fdefdate = false; + $fconstraint = false; + $fnotnull = false; + $funsigned = false; + $findex = ''; + $funiqueindex = false; + + //----------------- + // Parse attributes + foreach($fld as $attr => $v) { + if ($attr == 2 && is_numeric($v)) $attr = 'SIZE'; + else if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) $attr = strtoupper($v); + + switch($attr) { + case '0': + case 'NAME': $fname = $v; break; + case '1': + case 'TYPE': $ty = $v; $ftype = $this->ActualType(strtoupper($v)); break; + + case 'SIZE': + $dotat = strpos($v,'.'); if ($dotat === false) $dotat = strpos($v,','); + if ($dotat === false) $fsize = $v; + else { + $fsize = substr($v,0,$dotat); + $fprec = substr($v,$dotat+1); + } + break; + case 'UNSIGNED': $funsigned = true; break; + case 'AUTOINCREMENT': + case 'AUTO': $fautoinc = true; $fnotnull = true; break; + case 'KEY': + // a primary key col can be non unique in itself (if key spans many cols...) + case 'PRIMARY': $fprimary = $v; $fnotnull = true; /*$funiqueindex = true;*/ break; + case 'DEF': + case 'DEFAULT': $fdefault = $v; break; + case 'NOTNULL': $fnotnull = $v; break; + case 'NOQUOTE': $fnoquote = $v; break; + case 'DEFDATE': $fdefdate = $v; break; + case 'DEFTIMESTAMP': $fdefts = $v; break; + case 'CONSTRAINT': $fconstraint = $v; break; + // let INDEX keyword create a 'very standard' index on column + case 'INDEX': $findex = $v; break; + case 'UNIQUE': $funiqueindex = true; break; + } //switch + } // foreach $fld + + //-------------------- + // VALIDATE FIELD INFO + if (!strlen($fname)) { + if ($this->debug) ADOConnection::outp("Undefined NAME"); + return false; + } + + $fid = strtoupper(preg_replace('/^`(.+)`$/', '$1', $fname)); + $fname = $this->NameQuote($fname); + + if (!strlen($ftype)) { + if ($this->debug) ADOConnection::outp("Undefined TYPE for field '$fname'"); + return false; + } else { + $ftype = strtoupper($ftype); + } + + $ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec); + + if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls + + if ($fprimary) $pkey[] = $fname; + + // some databases do not allow blobs to have defaults + if ($ty == 'X') $fdefault = false; + + // build list of indexes + if ($findex != '') { + if (array_key_exists($findex, $idxs)) { + $idxs[$findex]['cols'][] = ($fname); + if (in_array('UNIQUE', $idxs[$findex]['opts']) != $funiqueindex) { + if ($this->debug) ADOConnection::outp("Index $findex defined once UNIQUE and once not"); + } + if ($funiqueindex && !in_array('UNIQUE', $idxs[$findex]['opts'])) + $idxs[$findex]['opts'][] = 'UNIQUE'; + } + else + { + $idxs[$findex] = array(); + $idxs[$findex]['cols'] = array($fname); + if ($funiqueindex) + $idxs[$findex]['opts'] = array('UNIQUE'); + else + $idxs[$findex]['opts'] = array(); + } + } + + //-------------------- + // CONSTRUCT FIELD SQL + if ($fdefts) { + if (substr($this->connection->databaseType,0,5) == 'mysql') { + $ftype = 'TIMESTAMP'; + } else { + $fdefault = $this->connection->sysTimeStamp; + } + } else if ($fdefdate) { + if (substr($this->connection->databaseType,0,5) == 'mysql') { + $ftype = 'TIMESTAMP'; + } else { + $fdefault = $this->connection->sysDate; + } + } else if ($fdefault !== false && !$fnoquote) { + if ($ty == 'C' or $ty == 'X' or + ( substr($fdefault,0,1) != "'" && !is_numeric($fdefault))) { + + if (($ty == 'D' || $ty == 'T') && strtolower($fdefault) != 'null') { + // convert default date into database-aware code + if ($ty == 'T') + { + $fdefault = $this->connection->DBTimeStamp($fdefault); + } + else + { + $fdefault = $this->connection->DBDate($fdefault); + } + } + else + if (strlen($fdefault) != 1 && substr($fdefault,0,1) == ' ' && substr($fdefault,strlen($fdefault)-1) == ' ') + $fdefault = trim($fdefault); + else if (strtolower($fdefault) != 'null') + $fdefault = $this->connection->qstr($fdefault); + } + } + $suffix = $this->_CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned); + + // add index creation + if ($widespacing) $fname = str_pad($fname,24); + + // check for field names appearing twice + if (array_key_exists($fid, $lines)) { + ADOConnection::outp("Field '$fname' defined twice"); + } + + $lines[$fid] = $fname.' '.$ftype.$suffix; + + if ($fautoinc) $this->autoIncrement = true; + } // foreach $flds + + return array($lines,$pkey,$idxs); + } + + /** + GENERATE THE SIZE PART OF THE DATATYPE + $ftype is the actual type + $ty is the type defined originally in the DDL + */ + function _GetSize($ftype, $ty, $fsize, $fprec) + { + if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) { + $ftype .= "(".$fsize; + if (strlen($fprec)) $ftype .= ",".$fprec; + $ftype .= ')'; + } + return $ftype; + } + + + // return string must begin with space + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) + { + $suffix = ''; + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + function _IndexSQL($idxname, $tabname, $flds, $idxoptions) + { + $sql = array(); + + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { + $sql[] = sprintf ($this->dropIndex, $idxname); + if ( isset($idxoptions['DROP']) ) + return $sql; + } + + if ( empty ($flds) ) { + return $sql; + } + + $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : ''; + + $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' '; + + if ( isset($idxoptions[$this->upperName]) ) + $s .= $idxoptions[$this->upperName]; + + if ( is_array($flds) ) + $flds = implode(', ',$flds); + $s .= '(' . $flds . ')'; + $sql[] = $s; + + return $sql; + } + + function _DropAutoIncrement($tabname) + { + return false; + } + + function _TableSQL($tabname,$lines,$pkey,$tableoptions) + { + $sql = array(); + + if (isset($tableoptions['REPLACE']) || isset ($tableoptions['DROP'])) { + $sql[] = sprintf($this->dropTable,$tabname); + if ($this->autoIncrement) { + $sInc = $this->_DropAutoIncrement($tabname); + if ($sInc) $sql[] = $sInc; + } + if ( isset ($tableoptions['DROP']) ) { + return $sql; + } + } + $s = "CREATE TABLE $tabname (\n"; + $s .= implode(",\n", $lines); + if (sizeof($pkey)>0) { + $s .= ",\n PRIMARY KEY ("; + $s .= implode(", ",$pkey).")"; + } + if (isset($tableoptions['CONSTRAINTS'])) + $s .= "\n".$tableoptions['CONSTRAINTS']; + + if (isset($tableoptions[$this->upperName.'_CONSTRAINTS'])) + $s .= "\n".$tableoptions[$this->upperName.'_CONSTRAINTS']; + + $s .= "\n)"; + if (isset($tableoptions[$this->upperName])) $s .= $tableoptions[$this->upperName]; + $sql[] = $s; + + return $sql; + } + + /** + GENERATE TRIGGERS IF NEEDED + used when table has auto-incrementing field that is emulated using triggers + */ + function _Triggers($tabname,$taboptions) + { + return array(); + } + + /** + Sanitize options, so that array elements with no keys are promoted to keys + */ + function _Options($opts) + { + if (!is_array($opts)) return array(); + $newopts = array(); + foreach($opts as $k => $v) { + if (is_numeric($k)) $newopts[strtoupper($v)] = $v; + else $newopts[strtoupper($k)] = $v; + } + return $newopts; + } + + /** + "Florian Buzin [ easywe ]" + + This function changes/adds new fields to your table. You don't + have to know if the col is new or not. It will check on its own. + */ + function ChangeTableSQL($tablename, $flds, $tableoptions = false) + { + global $ADODB_FETCH_MODE; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + if ($this->connection->fetchMode !== false) $savem = $this->connection->SetFetchMode(false); + + // check table exists + $save_handler = $this->connection->raiseErrorFn; + $this->connection->raiseErrorFn = ''; + $cols = $this->MetaColumns($tablename); + $this->connection->raiseErrorFn = $save_handler; + + if (isset($savem)) $this->connection->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + if ( empty($cols)) { + return $this->CreateTableSQL($tablename, $flds, $tableoptions); + } + + if (is_array($flds)) { + // Cycle through the update fields, comparing + // existing fields to fields to update. + // if the Metatype and size is exactly the + // same, ignore - by Mark Newham + $holdflds = array(); + foreach($flds as $k=>$v) { + if ( isset($cols[$k]) && is_object($cols[$k]) ) { + // If already not allowing nulls, then don't change + $obj = $cols[$k]; + if (isset($obj->not_null) && $obj->not_null) + $v = str_replace('NOT NULL','',$v); + + $c = $cols[$k]; + $ml = $c->max_length; + $mt = $this->MetaType($c->type,$ml); + if ($ml == -1) $ml = ''; + if ($mt == 'X') $ml = $v['SIZE']; + if (($mt != $v['TYPE']) || $ml != $v['SIZE']) { + $holdflds[$k] = $v; + } + } else { + $holdflds[$k] = $v; + } + } + $flds = $holdflds; + } + + + // already exists, alter table instead + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); + $alter = 'ALTER TABLE ' . $this->TableName($tablename); + $sql = array(); + + foreach ( $lines as $id => $v ) { + if ( isset($cols[$id]) && is_object($cols[$id]) ) { + + $flds = Lens_ParseArgs($v,','); + + // We are trying to change the size of the field, if not allowed, simply ignore the request. + // $flds[1] holds the type, $flds[2] holds the size -postnuke addition + if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4) + && (isset($flds[0][2]) && is_numeric($flds[0][2]))) { + if ($this->debug) ADOConnection::outp(sprintf("

%s cannot be changed to %s currently

", $flds[0][0], $flds[0][1])); + #echo "

$this->alterCol cannot be changed to $flds currently

"; + continue; + } + $sql[] = $alter . $this->alterCol . ' ' . $v; + } else { + $sql[] = $alter . $this->addCol . ' ' . $v; + } + } + + return $sql; + } +} // class +?> \ No newline at end of file diff --git a/includes/adodb/adodb-error.inc.php b/includes/adodb/adodb-error.inc.php new file mode 100644 index 00000000..ba1cd2ac --- /dev/null +++ b/includes/adodb/adodb-error.inc.php @@ -0,0 +1,258 @@ + DB_ERROR_NOSUCHTABLE, + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/i' => DB_ERROR_ALREADY_EXISTS, + '/divide by zero$/i' => DB_ERROR_DIVZERO, + '/pg_atoi: error in .*: can\'t parse /i' => DB_ERROR_INVALID_NUMBER, + '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/i' => DB_ERROR_NOSUCHFIELD, + '/parser: parse error at or near \"/i' => DB_ERROR_SYNTAX, + '/referential integrity violation/i' => DB_ERROR_CONSTRAINT, + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/i' + => DB_ERROR_ALREADY_EXISTS + ); + reset($error_regexps); + while (list($regexp,$code) = each($error_regexps)) { + if (preg_match($regexp, $errormsg)) { + return $code; + } + } + // Fall back to DB_ERROR if there was no mapping. + return DB_ERROR; +} + +function adodb_error_odbc() +{ +static $MAP = array( + '01004' => DB_ERROR_TRUNCATED, + '07001' => DB_ERROR_MISMATCH, + '21S01' => DB_ERROR_MISMATCH, + '21S02' => DB_ERROR_MISMATCH, + '22003' => DB_ERROR_INVALID_NUMBER, + '22008' => DB_ERROR_INVALID_DATE, + '22012' => DB_ERROR_DIVZERO, + '23000' => DB_ERROR_CONSTRAINT, + '24000' => DB_ERROR_INVALID, + '34000' => DB_ERROR_INVALID, + '37000' => DB_ERROR_SYNTAX, + '42000' => DB_ERROR_SYNTAX, + 'IM001' => DB_ERROR_UNSUPPORTED, + 'S0000' => DB_ERROR_NOSUCHTABLE, + 'S0001' => DB_ERROR_NOT_FOUND, + 'S0002' => DB_ERROR_NOSUCHTABLE, + 'S0011' => DB_ERROR_ALREADY_EXISTS, + 'S0012' => DB_ERROR_NOT_FOUND, + 'S0021' => DB_ERROR_ALREADY_EXISTS, + 'S0022' => DB_ERROR_NOT_FOUND, + 'S1000' => DB_ERROR_NOSUCHTABLE, + 'S1009' => DB_ERROR_INVALID, + 'S1090' => DB_ERROR_INVALID, + 'S1C00' => DB_ERROR_NOT_CAPABLE + ); + return $MAP; +} + +function adodb_error_ibase() +{ +static $MAP = array( + -104 => DB_ERROR_SYNTAX, + -150 => DB_ERROR_ACCESS_VIOLATION, + -151 => DB_ERROR_ACCESS_VIOLATION, + -155 => DB_ERROR_NOSUCHTABLE, + -157 => DB_ERROR_NOSUCHFIELD, + -158 => DB_ERROR_VALUE_COUNT_ON_ROW, + -170 => DB_ERROR_MISMATCH, + -171 => DB_ERROR_MISMATCH, + -172 => DB_ERROR_INVALID, + -204 => DB_ERROR_INVALID, + -205 => DB_ERROR_NOSUCHFIELD, + -206 => DB_ERROR_NOSUCHFIELD, + -208 => DB_ERROR_INVALID, + -219 => DB_ERROR_NOSUCHTABLE, + -297 => DB_ERROR_CONSTRAINT, + -530 => DB_ERROR_CONSTRAINT, + -803 => DB_ERROR_CONSTRAINT, + -551 => DB_ERROR_ACCESS_VIOLATION, + -552 => DB_ERROR_ACCESS_VIOLATION, + -922 => DB_ERROR_NOSUCHDB, + -923 => DB_ERROR_CONNECT_FAILED, + -924 => DB_ERROR_CONNECT_FAILED + ); + + return $MAP; +} + +function adodb_error_ifx() +{ +static $MAP = array( + '-201' => DB_ERROR_SYNTAX, + '-206' => DB_ERROR_NOSUCHTABLE, + '-217' => DB_ERROR_NOSUCHFIELD, + '-329' => DB_ERROR_NODBSELECTED, + '-1204' => DB_ERROR_INVALID_DATE, + '-1205' => DB_ERROR_INVALID_DATE, + '-1206' => DB_ERROR_INVALID_DATE, + '-1209' => DB_ERROR_INVALID_DATE, + '-1210' => DB_ERROR_INVALID_DATE, + '-1212' => DB_ERROR_INVALID_DATE + ); + + return $MAP; +} + +function adodb_error_oci8() +{ +static $MAP = array( + 1 => DB_ERROR_ALREADY_EXISTS, + 900 => DB_ERROR_SYNTAX, + 904 => DB_ERROR_NOSUCHFIELD, + 923 => DB_ERROR_SYNTAX, + 942 => DB_ERROR_NOSUCHTABLE, + 955 => DB_ERROR_ALREADY_EXISTS, + 1476 => DB_ERROR_DIVZERO, + 1722 => DB_ERROR_INVALID_NUMBER, + 2289 => DB_ERROR_NOSUCHTABLE, + 2291 => DB_ERROR_CONSTRAINT, + 2449 => DB_ERROR_CONSTRAINT + ); + + return $MAP; +} + +function adodb_error_mssql() +{ +static $MAP = array( + 208 => DB_ERROR_NOSUCHTABLE, + 2601 => DB_ERROR_ALREADY_EXISTS + ); + + return $MAP; +} + +function adodb_error_sqlite() +{ +static $MAP = array( + 1 => DB_ERROR_SYNTAX + ); + + return $MAP; +} + +function adodb_error_mysql() +{ +static $MAP = array( + 1004 => DB_ERROR_CANNOT_CREATE, + 1005 => DB_ERROR_CANNOT_CREATE, + 1006 => DB_ERROR_CANNOT_CREATE, + 1007 => DB_ERROR_ALREADY_EXISTS, + 1008 => DB_ERROR_CANNOT_DROP, + 1045 => DB_ERROR_ACCESS_VIOLATION, + 1046 => DB_ERROR_NODBSELECTED, + 1049 => DB_ERROR_NOSUCHDB, + 1050 => DB_ERROR_ALREADY_EXISTS, + 1051 => DB_ERROR_NOSUCHTABLE, + 1054 => DB_ERROR_NOSUCHFIELD, + 1062 => DB_ERROR_ALREADY_EXISTS, + 1064 => DB_ERROR_SYNTAX, + 1100 => DB_ERROR_NOT_LOCKED, + 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, + 1146 => DB_ERROR_NOSUCHTABLE, + 1048 => DB_ERROR_CONSTRAINT, + 2002 => DB_ERROR_CONNECT_FAILED, + 2005 => DB_ERROR_CONNECT_FAILED + ); + + return $MAP; +} +?> \ No newline at end of file diff --git a/includes/adodb/adodb-errorhandler.inc.php b/includes/adodb/adodb-errorhandler.inc.php new file mode 100644 index 00000000..ad8f3b4f --- /dev/null +++ b/includes/adodb/adodb-errorhandler.inc.php @@ -0,0 +1,79 @@ +$s

"; + trigger_error($s,ADODB_ERROR_HANDLER_TYPE); +} +?> diff --git a/includes/adodb/adodb-errorpear.inc.php b/includes/adodb/adodb-errorpear.inc.php new file mode 100644 index 00000000..10f98cd1 --- /dev/null +++ b/includes/adodb/adodb-errorpear.inc.php @@ -0,0 +1,88 @@ +!$s

"; +} + +/** +* Returns last PEAR_Error object. This error might be for an error that +* occured several sql statements ago. +*/ +function ADODB_PEAR_Error() +{ +global $ADODB_Last_PEAR_Error; + + return $ADODB_Last_PEAR_Error; +} + +?> \ No newline at end of file diff --git a/includes/adodb/adodb-exceptions.inc.php b/includes/adodb/adodb-exceptions.inc.php new file mode 100644 index 00000000..a2a81553 --- /dev/null +++ b/includes/adodb/adodb-exceptions.inc.php @@ -0,0 +1,82 @@ +sql = $p1; + $this->params = $p2; + $s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n"; + break; + + case 'PCONNECT': + case 'CONNECT': + $user = $thisConnection->user; + $s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)\n"; + break; + default: + $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n"; + break; + } + + $this->dbms = $dbms; + if ($thisConnection) { + $this->host = $thisConnection->host; + $this->database = $thisConnection->database; + } + $this->fn = $fn; + $this->msg = $errmsg; + + if (!is_numeric($errno)) $errno = -1; + parent::__construct($s,$errno); + } +} + +/** +* Default Error Handler. This will be called with the following params +* +* @param $dbms the RDBMS you are connecting to +* @param $fn the name of the calling function (in uppercase) +* @param $errno the native error number from the database +* @param $errmsg the native error msg from the database +* @param $p1 $fn specific parameter - see below +* @param $P2 $fn specific parameter - see below +*/ + +function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection) +{ +global $ADODB_EXCEPTION; + + if (error_reporting() == 0) return; // obey @ protocol + if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION; + else $errfn = 'ADODB_EXCEPTION'; + throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection); +} + + +?> \ No newline at end of file diff --git a/includes/adodb/adodb-iterator.inc.php b/includes/adodb/adodb-iterator.inc.php new file mode 100644 index 00000000..ae239257 --- /dev/null +++ b/includes/adodb/adodb-iterator.inc.php @@ -0,0 +1,30 @@ +Execute("select * from adoxyz"); + foreach($rs as $k => $v) { + echo $k; print_r($v); echo "
"; + } + + + Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2 + + + Moved to adodb.inc.php to improve performance. + */ + + + + + +?> \ No newline at end of file diff --git a/includes/adodb/adodb-lib.inc.php b/includes/adodb/adodb-lib.inc.php new file mode 100644 index 00000000..835ccd59 --- /dev/null +++ b/includes/adodb/adodb-lib.inc.php @@ -0,0 +1,1180 @@ + sizeof($array)) $max = sizeof($array); + else $max = $probe; + + + for ($j=0;$j < $max; $j++) { + $row = $array[$j]; + if (!$row) break; + $i = -1; + foreach($row as $v) { + $i += 1; + + if (isset($types[$i]) && $types[$i]=='C') continue; + + //print " ($i ".$types[$i]. "$v) "; + $v = trim($v); + + if (!preg_match('/^[+-]{0,1}[0-9\.]+$/',$v)) { + $types[$i] = 'C'; // once C, always C + + continue; + } + if ($j == 0) { + // If empty string, we presume is character + // test for integer for 1st row only + // after that it is up to testing other rows to prove + // that it is not an integer + if (strlen($v) == 0) $types[$i] = 'C'; + if (strpos($v,'.') !== false) $types[$i] = 'N'; + else $types[$i] = 'I'; + continue; + } + + if (strpos($v,'.') !== false) $types[$i] = 'N'; + + } + } + +} + +function adodb_transpose(&$arr, &$newarr, &$hdr, &$fobjs) +{ + $oldX = sizeof(reset($arr)); + $oldY = sizeof($arr); + + if ($hdr) { + $startx = 1; + $hdr = array('Fields'); + for ($y = 0; $y < $oldY; $y++) { + $hdr[] = $arr[$y][0]; + } + } else + $startx = 0; + + for ($x = $startx; $x < $oldX; $x++) { + if ($fobjs) { + $o = $fobjs[$x]; + $newarr[] = array($o->name); + } else + $newarr[] = array(); + + for ($y = 0; $y < $oldY; $y++) { + $newarr[$x-$startx][] = $arr[$y][$x]; + } + } +} + +// Force key to upper. +// See also http://www.php.net/manual/en/function.array-change-key-case.php +function _array_change_key_case($an_array) +{ + if (is_array($an_array)) { + $new_array = array(); + foreach($an_array as $key=>$value) + $new_array[strtoupper($key)] = $value; + + return $new_array; + } + + return $an_array; +} + +function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc) +{ + if (count($fieldArray) == 0) return 0; + $first = true; + $uSet = ''; + + if (!is_array($keyCol)) { + $keyCol = array($keyCol); + } + foreach($fieldArray as $k => $v) { + if ($v === null) { + $v = 'NULL'; + $fieldArray[$k] = $v; + } else if ($autoQuote && !is_numeric($v) /*and strncmp($v,"'",1) !== 0 -- sql injection risk*/ and strcasecmp($v,$zthis->null2null)!=0) { + $v = $zthis->qstr($v); + $fieldArray[$k] = $v; + } + if (in_array($k,$keyCol)) continue; // skip UPDATE if is key + + if ($first) { + $first = false; + $uSet = "$k=$v"; + } else + $uSet .= ",$k=$v"; + } + + $where = false; + foreach ($keyCol as $v) { + if (isset($fieldArray[$v])) { + if ($where) $where .= ' and '.$v.'='.$fieldArray[$v]; + else $where = $v.'='.$fieldArray[$v]; + } + } + + if ($uSet && $where) { + $update = "UPDATE $table SET $uSet WHERE $where"; + + $rs = $zthis->Execute($update); + + + if ($rs) { + if ($zthis->poorAffectedRows) { + /* + The Select count(*) wipes out any errors that the update would have returned. + http://phplens.com/lens/lensforum/msgs.php?id=5696 + */ + if ($zthis->ErrorNo()<>0) return 0; + + # affected_rows == 0 if update field values identical to old values + # for mysql - which is silly. + + $cnt = $zthis->GetOne("select count(*) from $table where $where"); + if ($cnt > 0) return 1; // record already exists + } else { + if (($zthis->Affected_Rows()>0)) return 1; + } + } else + return 0; + } + + // print "

Error=".$this->ErrorNo().'

'; + $first = true; + foreach($fieldArray as $k => $v) { + if ($has_autoinc && in_array($k,$keyCol)) continue; // skip autoinc col + + if ($first) { + $first = false; + $iCols = "$k"; + $iVals = "$v"; + } else { + $iCols .= ",$k"; + $iVals .= ",$v"; + } + } + $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)"; + $rs = $zthis->Execute($insert); + return ($rs) ? 2 : 0; +} + +// Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM +function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false, + $size=0, $selectAttr='',$compareFields0=true) +{ + $hasvalue = false; + + if ($multiple or is_array($defstr)) { + if ($size==0) $size=5; + $attr = ' multiple size="'.$size.'"'; + if (!strpos($name,'[]')) $name .= '[]'; + } else if ($size) $attr = ' size="'.$size.'"'; + else $attr =''; + + $s = '\n"; +} + +// Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM +function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false, + $size=0, $selectAttr='',$compareFields0=true) +{ + $hasvalue = false; + + if ($multiple or is_array($defstr)) { + if ($size==0) $size=5; + $attr = ' multiple size="'.$size.'"'; + if (!strpos($name,'[]')) $name .= '[]'; + } else if ($size) $attr = ' size="'.$size.'"'; + else $attr =''; + + $s = '\n"; +} + + +/* + Count the number of records this sql statement will return by using + query rewriting heuristics... + + Does not work with UNIONs, except with postgresql and oracle. + + Usage: + + $conn->Connect(...); + $cnt = _adodb_getcount($conn, $sql); + +*/ +function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0) +{ + $qryRecs = 0; + + if (!empty($zthis->_nestedSQL) || preg_match("/^\s*SELECT\s+DISTINCT/is", $sql) || + preg_match('/\s+GROUP\s+BY\s+/is',$sql) || + preg_match('/\s+UNION\s+/is',$sql)) { + + $rewritesql = adodb_strip_order_by($sql); + + // ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias + // but this is only supported by oracle and postgresql... + if ($zthis->dataProvider == 'oci8') { + // Allow Oracle hints to be used for query optimization, Chris Wrye + if (preg_match('#/\\*+.*?\\*\\/#', $sql, $hint)) { + $rewritesql = "SELECT ".$hint[0]." COUNT(*) FROM (".$rewritesql.")"; + } else + $rewritesql = "SELECT COUNT(*) FROM (".$rewritesql.")"; + + } else if (strncmp($zthis->databaseType,'postgres',8) == 0 || strncmp($zthis->databaseType,'mysql',5) == 0) { + $rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _ADODB_ALIAS_"; + } else { + $rewritesql = "SELECT COUNT(*) FROM ($rewritesql)"; + } + } else { + // now replace SELECT ... FROM with SELECT COUNT(*) FROM + $rewritesql = preg_replace( + '/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ',$sql); + // fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails + // with mssql, access and postgresql. Also a good speedup optimization - skips sorting! + // also see http://phplens.com/lens/lensforum/msgs.php?id=12752 + $rewritesql = adodb_strip_order_by($rewritesql); + } + + if (isset($rewritesql) && $rewritesql != $sql) { + if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0]; + + if ($secs2cache) { + // we only use half the time of secs2cache because the count can quickly + // become inaccurate if new records are added + $qryRecs = $zthis->CacheGetOne($secs2cache/2,$rewritesql,$inputarr); + + } else { + $qryRecs = $zthis->GetOne($rewritesql,$inputarr); + } + if ($qryRecs !== false) return $qryRecs; + } + //-------------------------------------------- + // query rewrite failed - so try slower way... + + + // strip off unneeded ORDER BY if no UNION + if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql; + else $rewritesql = $rewritesql = adodb_strip_order_by($sql); + + if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0]; + + $rstest = $zthis->Execute($rewritesql,$inputarr); + if (!$rstest) $rstest = $zthis->Execute($sql,$inputarr); + + if ($rstest) { + $qryRecs = $rstest->RecordCount(); + if ($qryRecs == -1) { + global $ADODB_EXTENSION; + // some databases will return -1 on MoveLast() - change to MoveNext() + if ($ADODB_EXTENSION) { + while(!$rstest->EOF) { + adodb_movenext($rstest); + } + } else { + while(!$rstest->EOF) { + $rstest->MoveNext(); + } + } + $qryRecs = $rstest->_currentRow; + } + $rstest->Close(); + if ($qryRecs == -1) return 0; + } + return $qryRecs; +} + +/* + Code originally from "Cornel G" + + This code might not work with SQL that has UNION in it + + Also if you are using CachePageExecute(), there is a strong possibility that + data will get out of synch. use CachePageExecute() only with tables that + rarely change. +*/ +function _adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page, + $inputarr=false, $secs2cache=0) +{ + $atfirstpage = false; + $atlastpage = false; + $lastpageno=1; + + // If an invalid nrows is supplied, + // we assume a default value of 10 rows per page + if (!isset($nrows) || $nrows <= 0) $nrows = 10; + + $qryRecs = false; //count records for no offset + + $qryRecs = _adodb_getcount($zthis,$sql,$inputarr,$secs2cache); + $lastpageno = (int) ceil($qryRecs / $nrows); + $zthis->_maxRecordCount = $qryRecs; + + + + // ***** Here we check whether $page is the last page or + // whether we are trying to retrieve + // a page number greater than the last page number. + if ($page >= $lastpageno) { + $page = $lastpageno; + $atlastpage = true; + } + + // If page number <= 1, then we are at the first page + if (empty($page) || $page <= 1) { + $page = 1; + $atfirstpage = true; + } + + // We get the data we want + $offset = $nrows * ($page-1); + if ($secs2cache > 0) + $rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); + else + $rsreturn = $zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); + + + // Before returning the RecordSet, we set the pagination properties we need + if ($rsreturn) { + $rsreturn->_maxRecordCount = $qryRecs; + $rsreturn->rowsPerPage = $nrows; + $rsreturn->AbsolutePage($page); + $rsreturn->AtFirstPage($atfirstpage); + $rsreturn->AtLastPage($atlastpage); + $rsreturn->LastPageNo($lastpageno); + } + return $rsreturn; +} + +// Iván Oliva version +function _adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) +{ + + $atfirstpage = false; + $atlastpage = false; + + if (!isset($page) || $page <= 1) { // If page number <= 1, then we are at the first page + $page = 1; + $atfirstpage = true; + } + if ($nrows <= 0) $nrows = 10; // If an invalid nrows is supplied, we assume a default value of 10 rows per page + + // ***** Here we check whether $page is the last page or whether we are trying to retrieve a page number greater than + // the last page number. + $pagecounter = $page + 1; + $pagecounteroffset = ($pagecounter * $nrows) - $nrows; + if ($secs2cache>0) $rstest = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); + else $rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); + if ($rstest) { + while ($rstest && $rstest->EOF && $pagecounter>0) { + $atlastpage = true; + $pagecounter--; + $pagecounteroffset = $nrows * ($pagecounter - 1); + $rstest->Close(); + if ($secs2cache>0) $rstest = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); + else $rstest = $zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); + } + if ($rstest) $rstest->Close(); + } + if ($atlastpage) { // If we are at the last page or beyond it, we are going to retrieve it + $page = $pagecounter; + if ($page == 1) $atfirstpage = true; // We have to do this again in case the last page is the same as the first + //... page, that is, the recordset has only 1 page. + } + + // We get the data we want + $offset = $nrows * ($page-1); + if ($secs2cache > 0) $rsreturn = $zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); + else $rsreturn = $zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); + + // Before returning the RecordSet, we set the pagination properties we need + if ($rsreturn) { + $rsreturn->rowsPerPage = $nrows; + $rsreturn->AbsolutePage($page); + $rsreturn->AtFirstPage($atfirstpage); + $rsreturn->AtLastPage($atlastpage); + } + return $rsreturn; +} + +function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=2) +{ + global $ADODB_QUOTE_FIELDNAMES; + + if (!$rs) { + printf(ADODB_BAD_RS,'GetUpdateSQL'); + return false; + } + + $fieldUpdatedCount = 0; + $arrFields = _array_change_key_case($arrFields); + + $hasnumeric = isset($rs->fields[0]); + $setFields = ''; + + // Loop through all of the fields in the recordset + for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) { + // Get the field from the recordset + $field = $rs->FetchField($i); + + // If the recordset field is one + // of the fields passed in then process. + $upperfname = strtoupper($field->name); + if (adodb_key_exists($upperfname,$arrFields,$force)) { + + // If the existing field value in the recordset + // is different from the value passed in then + // go ahead and append the field name and new value to + // the update query. + + if ($hasnumeric) $val = $rs->fields[$i]; + else if (isset($rs->fields[$upperfname])) $val = $rs->fields[$upperfname]; + else if (isset($rs->fields[$field->name])) $val = $rs->fields[$field->name]; + else if (isset($rs->fields[strtolower($upperfname)])) $val = $rs->fields[strtolower($upperfname)]; + else $val = ''; + + + if ($forceUpdate || strcmp($val, $arrFields[$upperfname])) { + // Set the counter for the number of fields that will be updated. + $fieldUpdatedCount++; + + // Based on the datatype of the field + // Format the value properly for the database + $type = $rs->MetaType($field->type); + + + if ($type == 'null') { + $type = 'C'; + } + + if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) + $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote; + else + $fnameq = $upperfname; + + + // is_null requires php 4.0.4 + //********************************************************// + if (is_null($arrFields[$upperfname]) + || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0) + || $arrFields[$upperfname] === $zthis->null2null + ) + { + switch ($force) { + + //case 0: + // //Ignore empty values. This is allready handled in "adodb_key_exists" function. + //break; + + case 1: + //Set null + $setFields .= $field->name . " = null, "; + break; + + case 2: + //Set empty + $arrFields[$upperfname] = ""; + $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,$arrFields, $magicq); + break; + default: + case 3: + //Set the value that was given in array, so you can give both null and empty values + if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) { + $setFields .= $field->name . " = null, "; + } else { + $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,$arrFields, $magicq); + } + break; + } + //********************************************************// + } else { + //we do this so each driver can customize the sql for + //DB specific column types. + //Oracle needs BLOB types to be handled with a returning clause + //postgres has special needs as well + $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq, + $arrFields, $magicq); + } + } + } + } + + // If there were any modified fields then build the rest of the update query. + if ($fieldUpdatedCount > 0 || $forceUpdate) { + // Get the table name from the existing query. + if (!empty($rs->tableName)) $tableName = $rs->tableName; + else { + preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName); + $tableName = $tableName[1]; + } + // Get the full where clause excluding the word "WHERE" from + // the existing query. + preg_match('/\sWHERE\s(.*)/is', $rs->sql, $whereClause); + + $discard = false; + // not a good hack, improvements? + if ($whereClause) { + #var_dump($whereClause); + if (preg_match('/\s(ORDER\s.*)/is', $whereClause[1], $discard)); + else if (preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard)); + else if (preg_match('/\s(FOR UPDATE.*)/is', $whereClause[1], $discard)); + else preg_match('/\s.*(\) WHERE .*)/is', $whereClause[1], $discard); # see http://sourceforge.net/tracker/index.php?func=detail&aid=1379638&group_id=42718&atid=433976 + } else + $whereClause = array(false,false); + + if ($discard) + $whereClause[1] = substr($whereClause[1], 0, strlen($whereClause[1]) - strlen($discard[1])); + + $sql = 'UPDATE '.$tableName.' SET '.substr($setFields, 0, -2); + if (strlen($whereClause[1]) > 0) + $sql .= ' WHERE '.$whereClause[1]; + + return $sql; + + } else { + return false; + } +} + +function adodb_key_exists($key, &$arr,$force=2) +{ + if ($force<=0) { + // the following is the old behaviour where null or empty fields are ignored + return (!empty($arr[$key])) || (isset($arr[$key]) && strlen($arr[$key])>0); + } + + if (isset($arr[$key])) return true; + ## null check below + if (ADODB_PHPVER >= 0x4010) return array_key_exists($key,$arr); + return false; +} + +/** + * There is a special case of this function for the oci8 driver. + * The proper way to handle an insert w/ a blob in oracle requires + * a returning clause with bind variables and a descriptor blob. + * + * + */ +function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2) +{ +static $cacheRS = false; +static $cacheSig = 0; +static $cacheCols; + global $ADODB_QUOTE_FIELDNAMES; + + $tableName = ''; + $values = ''; + $fields = ''; + $recordSet = null; + $arrFields = _array_change_key_case($arrFields); + $fieldInsertedCount = 0; + + if (is_string($rs)) { + //ok we have a table name + //try and get the column info ourself. + $tableName = $rs; + + //we need an object for the recordSet + //because we have to call MetaType. + //php can't do a $rsclass::MetaType() + $rsclass = $zthis->rsPrefix.$zthis->databaseType; + $recordSet = new $rsclass(-1,$zthis->fetchMode); + $recordSet->connection = $zthis; + + if (is_string($cacheRS) && $cacheRS == $rs) { + $columns = $cacheCols; + } else { + $columns = $zthis->MetaColumns( $tableName ); + $cacheRS = $tableName; + $cacheCols = $columns; + } + } else if (is_subclass_of($rs, 'adorecordset')) { + if (isset($rs->insertSig) && is_integer($cacheRS) && $cacheRS == $rs->insertSig) { + $columns = $cacheCols; + } else { + for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) + $columns[] = $rs->FetchField($i); + $cacheRS = $cacheSig; + $cacheCols = $columns; + $rs->insertSig = $cacheSig++; + } + $recordSet = $rs; + + } else { + printf(ADODB_BAD_RS,'GetInsertSQL'); + return false; + } + + // Loop through all of the fields in the recordset + foreach( $columns as $field ) { + $upperfname = strtoupper($field->name); + if (adodb_key_exists($upperfname,$arrFields,$force)) { + $bad = false; + if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) + $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote; + else + $fnameq = $upperfname; + + $type = $recordSet->MetaType($field->type); + + /********************************************************/ + if (is_null($arrFields[$upperfname]) + || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0) + || $arrFields[$upperfname] === $zthis->null2null + ) + { + switch ($force) { + + case 0: // we must always set null if missing + $bad = true; + break; + + case 1: + $values .= "null, "; + break; + + case 2: + //Set empty + $arrFields[$upperfname] = ""; + $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq,$arrFields, $magicq); + break; + + default: + case 3: + //Set the value that was given in array, so you can give both null and empty values + if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) { + $values .= "null, "; + } else { + $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq); + } + break; + } // switch + + /*********************************************************/ + } else { + //we do this so each driver can customize the sql for + //DB specific column types. + //Oracle needs BLOB types to be handled with a returning clause + //postgres has special needs as well + $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, + $arrFields, $magicq); + } + + if ($bad) continue; + // Set the counter for the number of fields that will be inserted. + $fieldInsertedCount++; + + + // Get the name of the fields to insert + $fields .= $fnameq . ", "; + } + } + + + // If there were any inserted fields then build the rest of the insert query. + if ($fieldInsertedCount <= 0) return false; + + // Get the table name from the existing query. + if (!$tableName) { + if (!empty($rs->tableName)) $tableName = $rs->tableName; + else if (preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName)) + $tableName = $tableName[1]; + else + return false; + } + + // Strip off the comma and space on the end of both the fields + // and their values. + $fields = substr($fields, 0, -2); + $values = substr($values, 0, -2); + + // Append the fields and their values to the insert query. + return 'INSERT INTO '.$tableName.' ( '.$fields.' ) VALUES ( '.$values.' )'; +} + + +/** + * This private method is used to help construct + * the update/sql which is generated by GetInsertSQL and GetUpdateSQL. + * It handles the string construction of 1 column -> sql string based on + * the column type. We want to do 'safe' handling of BLOBs + * + * @param string the type of sql we are trying to create + * 'I' or 'U'. + * @param string column data type from the db::MetaType() method + * @param string the column name + * @param array the column value + * + * @return string + * + */ +function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $fnameq, $arrFields, $magicq) +{ + $sql = ''; + + // Based on the datatype of the field + // Format the value properly for the database + switch($type) { + case 'B': + //in order to handle Blobs correctly, we need + //to do some magic for Oracle + + //we need to create a new descriptor to handle + //this properly + if (!empty($zthis->hasReturningInto)) { + if ($action == 'I') { + $sql = 'empty_blob(), '; + } else { + $sql = $fnameq. '=empty_blob(), '; + } + //add the variable to the returning clause array + //so the user can build this later in + //case they want to add more to it + $zthis->_returningArray[$fname] = ':xx'.$fname.'xx'; + } else if (empty($arrFields[$fname])){ + if ($action == 'I') { + $sql = 'empty_blob(), '; + } else { + $sql = $fnameq. '=empty_blob(), '; + } + } else { + //this is to maintain compatibility + //with older adodb versions. + $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false); + } + break; + + case "X": + //we need to do some more magic here for long variables + //to handle these correctly in oracle. + + //create a safe bind var name + //to avoid conflicts w/ dupes. + if (!empty($zthis->hasReturningInto)) { + if ($action == 'I') { + $sql = ':xx'.$fname.'xx, '; + } else { + $sql = $fnameq.'=:xx'.$fname.'xx, '; + } + //add the variable to the returning clause array + //so the user can build this later in + //case they want to add more to it + $zthis->_returningArray[$fname] = ':xx'.$fname.'xx'; + } else { + //this is to maintain compatibility + //with older adodb versions. + $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false); + } + break; + + default: + $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false); + break; + } + + return $sql; +} + +function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq, $recurse=true) +{ + + if ($recurse) { + switch($zthis->dataProvider) { + case 'postgres': + if ($type == 'L') $type = 'C'; + break; + case 'oci8': + return _adodb_column_sql_oci8($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq); + + } + } + + switch($type) { + case "C": + case "X": + case 'B': + $val = $zthis->qstr($arrFields[$fname],$magicq); + break; + + case "D": + $val = $zthis->DBDate($arrFields[$fname]); + break; + + case "T": + $val = $zthis->DBTimeStamp($arrFields[$fname]); + break; + + case "N": + $val = $arrFields[$fname]; + if (!is_numeric($val)) $val = str_replace(',', '.', (float)$val); + break; + + case "I": + case "R": + $val = $arrFields[$fname]; + if (!is_numeric($val)) $val = (integer) $val; + break; + + default: + $val = str_replace(array("'"," ","("),"",$arrFields[$fname]); // basic sql injection defence + if (empty($val)) $val = '0'; + break; + } + + if ($action == 'I') return $val . ", "; + + + return $fnameq . "=" . $val . ", "; + +} + + + +function _adodb_debug_execute(&$zthis, $sql, $inputarr) +{ + $ss = ''; + if ($inputarr) { + foreach($inputarr as $kk=>$vv) { + if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...'; + if (is_null($vv)) $ss .= "($kk=>null) "; + else $ss .= "($kk=>'$vv') "; + } + $ss = "[ $ss ]"; + } + $sqlTxt = is_array($sql) ? $sql[0] : $sql; + /*str_replace(', ','##1#__^LF',is_array($sql) ? $sql[0] : $sql); + $sqlTxt = str_replace(',',', ',$sqlTxt); + $sqlTxt = str_replace('##1#__^LF', ', ' ,$sqlTxt); + */ + // check if running from browser or command-line + $inBrowser = isset($_SERVER['HTTP_USER_AGENT']); + + $dbt = $zthis->databaseType; + if (isset($zthis->dsnType)) $dbt .= '-'.$zthis->dsnType; + if ($inBrowser) { + if ($ss) { + $ss = ''.htmlspecialchars($ss).''; + } + if ($zthis->debug === -1) + ADOConnection::outp( "
\n($dbt): ".htmlspecialchars($sqlTxt)."   $ss\n
\n",false); + else + ADOConnection::outp( "


\n($dbt): ".htmlspecialchars($sqlTxt)."   $ss\n
\n",false); + } else { + ADOConnection::outp("-----\n($dbt): ".$sqlTxt."\n-----\n",false); + } + + $qID = $zthis->_query($sql,$inputarr); + + /* + Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql + because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion + */ + if ($zthis->databaseType == 'mssql') { + // ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6 + if($emsg = $zthis->ErrorMsg()) { + if ($err = $zthis->ErrorNo()) ADOConnection::outp($err.': '.$emsg); + } + } else if (!$qID) { + ADOConnection::outp($zthis->ErrorNo() .': '. $zthis->ErrorMsg()); + } + + if ($zthis->debug === 99) _adodb_backtrace(true,9999,2); + return $qID; +} + +# pretty print the debug_backtrace function +function _adodb_backtrace($printOrArr=true,$levels=9999,$skippy=0,$ishtml=null) +{ + if (!function_exists('debug_backtrace')) return ''; + + if ($ishtml === null) $html = (isset($_SERVER['HTTP_USER_AGENT'])); + else $html = $ishtml; + + $fmt = ($html) ? " %% line %4d, file: %s" : "%% line %4d, file: %s"; + + $MAXSTRLEN = 128; + + $s = ($html) ? '
' : '';
+	
+	if (is_array($printOrArr)) $traceArr = $printOrArr;
+	else $traceArr = debug_backtrace();
+	array_shift($traceArr);
+	array_shift($traceArr);
+	$tabs = sizeof($traceArr)-2;
+	
+	foreach ($traceArr as $arr) {
+		if ($skippy) {$skippy -= 1; continue;}
+		$levels -= 1;
+		if ($levels < 0) break;
+		
+		$args = array();
+		for ($i=0; $i < $tabs; $i++) $s .=  ($html) ? '   ' : "\t";
+		$tabs -= 1;
+		if ($html) $s .= '';
+		if (isset($arr['class'])) $s .= $arr['class'].'.';
+		if (isset($arr['args']))
+		 foreach($arr['args'] as $v) {
+			if (is_null($v)) $args[] = 'null';
+			else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
+			else if (is_object($v)) $args[] = 'Object:'.get_class($v);
+			else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
+			else {
+				$v = (string) @$v;
+				$str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
+				if (strlen($v) > $MAXSTRLEN) $str .= '...';
+				$args[] = $str;
+			}
+		}
+		$s .= $arr['function'].'('.implode(', ',$args).')';
+		
+		
+		$s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));
+			
+		$s .= "\n";
+	}	
+	if ($html) $s .= '
'; + if ($printOrArr) print $s; + + return $s; +} +/* +function _adodb_find_from($sql) +{ + + $sql = str_replace(array("\n","\r"), ' ', $sql); + $charCount = strlen($sql); + + $inString = false; + $quote = ''; + $parentheseCount = 0; + $prevChars = ''; + $nextChars = ''; + + + for($i = 0; $i < $charCount; $i++) { + + $char = substr($sql,$i,1); + $prevChars = substr($sql,0,$i); + $nextChars = substr($sql,$i+1); + + if((($char == "'" || $char == '"' || $char == '`') && substr($prevChars,-1,1) != '\\') && $inString === false) { + $quote = $char; + $inString = true; + } + + elseif((($char == "'" || $char == '"' || $char == '`') && substr($prevChars,-1,1) != '\\') && $inString === true && $quote == $char) { + $quote = ""; + $inString = false; + } + + elseif($char == "(" && $inString === false) + $parentheseCount++; + + elseif($char == ")" && $inString === false && $parentheseCount > 0) + $parentheseCount--; + + elseif($parentheseCount <= 0 && $inString === false && $char == " " && strtoupper(substr($prevChars,-5,5)) == " FROM") + return $i; + + } +} +*/ + +?> \ No newline at end of file diff --git a/includes/adodb/adodb-pager.inc.php b/includes/adodb/adodb-pager.inc.php new file mode 100644 index 00000000..db25880d --- /dev/null +++ b/includes/adodb/adodb-pager.inc.php @@ -0,0 +1,290 @@ + implemented Render_PageLinks(). + + Please note, this class is entirely unsupported, + and no free support requests except for bug reports + will be entertained by the author. + +*/ +class ADODB_Pager { + var $id; // unique id for pager (defaults to 'adodb') + var $db; // ADODB connection object + var $sql; // sql used + var $rs; // recordset generated + var $curr_page; // current page number before Render() called, calculated in constructor + var $rows; // number of rows per page + var $linksPerPage=10; // number of links per page in navigation bar + var $showPageLinks; + + var $gridAttributes = 'width=100% border=1 bgcolor=white'; + + // Localize text strings here + var $first = '|<'; + var $prev = '<<'; + var $next = '>>'; + var $last = '>|'; + var $moreLinks = '...'; + var $startLinks = '...'; + var $gridHeader = false; + var $htmlSpecialChars = true; + var $page = 'Page'; + var $linkSelectedColor = 'red'; + var $cache = 0; #secs to cache with CachePageExecute() + + //---------------------------------------------- + // constructor + // + // $db adodb connection object + // $sql sql statement + // $id optional id to identify which pager, + // if you have multiple on 1 page. + // $id should be only be [a-z0-9]* + // + function ADODB_Pager(&$db,$sql,$id = 'adodb', $showPageLinks = false) + { + global $PHP_SELF; + + $curr_page = $id.'_curr_page'; + if (empty($PHP_SELF)) $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF']); // htmlspecialchars() to prevent XSS attacks + + $this->sql = $sql; + $this->id = $id; + $this->db = $db; + $this->showPageLinks = $showPageLinks; + + $next_page = $id.'_next_page'; + + if (isset($_GET[$next_page])) { + $_SESSION[$curr_page] = (integer) $_GET[$next_page]; + } + if (empty($_SESSION[$curr_page])) $_SESSION[$curr_page] = 1; ## at first page + + $this->curr_page = $_SESSION[$curr_page]; + + } + + //--------------------------- + // Display link to first page + function Render_First($anchor=true) + { + global $PHP_SELF; + if ($anchor) { + ?> + first;?>   + first   "; + } + } + + //-------------------------- + // Display link to next page + function render_next($anchor=true) + { + global $PHP_SELF; + + if ($anchor) { + ?> + next;?>   + next   "; + } + } + + //------------------ + // Link to last page + // + // for better performance with large recordsets, you can set + // $this->db->pageExecuteCountRows = false, which disables + // last page counting. + function render_last($anchor=true) + { + global $PHP_SELF; + + if (!$this->db->pageExecuteCountRows) return; + + if ($anchor) { + ?> + last;?>   + last   "; + } + } + + //--------------------------------------------------- + // original code by "Pablo Costa" + function render_pagelinks() + { + global $PHP_SELF; + $pages = $this->rs->LastPageNo(); + $linksperpage = $this->linksPerPage ? $this->linksPerPage : $pages; + for($i=1; $i <= $pages; $i+=$linksperpage) + { + if($this->rs->AbsolutePage() >= $i) + { + $start = $i; + } + } + $numbers = ''; + $end = $start+$linksperpage-1; + $link = $this->id . "_next_page"; + if($end > $pages) $end = $pages; + + + if ($this->startLinks && $start > 1) { + $pos = $start - 1; + $numbers .= "$this->startLinks "; + } + + for($i=$start; $i <= $end; $i++) { + if ($this->rs->AbsolutePage() == $i) + $numbers .= "linkSelectedColor>$i "; + else + $numbers .= "$i "; + + } + if ($this->moreLinks && $end < $pages) + $numbers .= "$this->moreLinks "; + print $numbers . '   '; + } + // Link to previous page + function render_prev($anchor=true) + { + global $PHP_SELF; + if ($anchor) { + ?> + prev;?>   + prev   "; + } + } + + //-------------------------------------------------------- + // Simply rendering of grid. You should override this for + // better control over the format of the grid + // + // We use output buffering to keep code clean and readable. + function RenderGrid() + { + global $gSQLBlockRows; // used by rs2html to indicate how many rows to display + include_once(ADODB_DIR.'/tohtml.inc.php'); + ob_start(); + $gSQLBlockRows = $this->rows; + rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars); + $s = ob_get_contents(); + ob_end_clean(); + return $s; + } + + //------------------------------------------------------- + // Navigation bar + // + // we use output buffering to keep the code easy to read. + function RenderNav() + { + ob_start(); + if (!$this->rs->AtFirstPage()) { + $this->Render_First(); + $this->Render_Prev(); + } else { + $this->Render_First(false); + $this->Render_Prev(false); + } + if ($this->showPageLinks){ + $this->Render_PageLinks(); + } + if (!$this->rs->AtLastPage()) { + $this->Render_Next(); + $this->Render_Last(); + } else { + $this->Render_Next(false); + $this->Render_Last(false); + } + $s = ob_get_contents(); + ob_end_clean(); + return $s; + } + + //------------------- + // This is the footer + function RenderPageCount() + { + if (!$this->db->pageExecuteCountRows) return ''; + $lastPage = $this->rs->LastPageNo(); + if ($lastPage == -1) $lastPage = 1; // check for empty rs. + if ($this->curr_page > $lastPage) $this->curr_page = 1; + return "$this->page ".$this->curr_page."/".$lastPage.""; + } + + //----------------------------------- + // Call this class to draw everything. + function Render($rows=10) + { + global $ADODB_COUNTRECS; + + $this->rows = $rows; + + if ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL; + + $savec = $ADODB_COUNTRECS; + if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true; + if ($this->cache) + $rs = $this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page); + else + $rs = $this->db->PageExecute($this->sql,$rows,$this->curr_page); + $ADODB_COUNTRECS = $savec; + + $this->rs = $rs; + if (!$rs) { + print "

Query failed: $this->sql

"; + return; + } + + if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) + $header = $this->RenderNav(); + else + $header = " "; + + $grid = $this->RenderGrid(); + $footer = $this->RenderPageCount(); + + $this->RenderLayout($header,$grid,$footer); + + $rs->Close(); + $this->rs = false; + } + + //------------------------------------------------------ + // override this to control overall layout and formating + function RenderLayout($header,$grid,$footer,$attributes='border=1 bgcolor=beige') + { + echo "
", + $header, + "
", + $grid, + "
", + $footer, + "
"; + } +} + + +?> \ No newline at end of file diff --git a/includes/adodb/adodb-pear.inc.php b/includes/adodb/adodb-pear.inc.php new file mode 100644 index 00000000..8dc4460c --- /dev/null +++ b/includes/adodb/adodb-pear.inc.php @@ -0,0 +1,374 @@ + | + * and Tomas V.V.Cox . Portions (c)1997-2002 The PHP Group. + */ + + /* + We support: + + DB_Common + --------- + query - returns PEAR_Error on error + limitQuery - return PEAR_Error on error + prepare - does not return PEAR_Error on error + execute - does not return PEAR_Error on error + setFetchMode - supports ASSOC and ORDERED + errorNative + quote + nextID + disconnect + + getOne + getAssoc + getRow + getCol + getAll + + DB_Result + --------- + numRows - returns -1 if not supported + numCols + fetchInto - does not support passing of fetchmode + fetchRows - does not support passing of fetchmode + free + */ + +define('ADODB_PEAR',dirname(__FILE__)); +include_once "PEAR.php"; +include_once ADODB_PEAR."/adodb-errorpear.inc.php"; +include_once ADODB_PEAR."/adodb.inc.php"; + +if (!defined('DB_OK')) { +define("DB_OK", 1); +define("DB_ERROR",-1); + +// autoExecute constants +define('DB_AUTOQUERY_INSERT', 1); +define('DB_AUTOQUERY_UPDATE', 2); + +/** + * This is a special constant that tells DB the user hasn't specified + * any particular get mode, so the default should be used. + */ + +define('DB_FETCHMODE_DEFAULT', 0); + +/** + * Column data indexed by numbers, ordered from 0 and up + */ + +define('DB_FETCHMODE_ORDERED', 1); + +/** + * Column data indexed by column names + */ + +define('DB_FETCHMODE_ASSOC', 2); + +/* for compatibility */ + +define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED); +define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC); + +/** + * these are constants for the tableInfo-function + * they are bitwised or'ed. so if there are more constants to be defined + * in the future, adjust DB_TABLEINFO_FULL accordingly + */ + +define('DB_TABLEINFO_ORDER', 1); +define('DB_TABLEINFO_ORDERTABLE', 2); +define('DB_TABLEINFO_FULL', 3); +} + +/** + * The main "DB" class is simply a container class with some static + * methods for creating DB objects as well as some utility functions + * common to all parts of DB. + * + */ + +class DB +{ + /** + * Create a new DB object for the specified database type + * + * @param $type string database type, for example "mysql" + * + * @return object a newly created DB object, or a DB error code on + * error + */ + + function factory($type) + { + include_once(ADODB_DIR."/drivers/adodb-$type.inc.php"); + $obj = NewADOConnection($type); + if (!is_object($obj)) $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); + return $obj; + } + + /** + * Create a new DB object and connect to the specified database + * + * @param $dsn mixed "data source name", see the DB::parseDSN + * method for a description of the dsn format. Can also be + * specified as an array of the format returned by DB::parseDSN. + * + * @param $options mixed if boolean (or scalar), tells whether + * this connection should be persistent (for backends that support + * this). This parameter can also be an array of options, see + * DB_common::setOption for more information on connection + * options. + * + * @return object a newly created DB connection object, or a DB + * error object on error + * + * @see DB::parseDSN + * @see DB::isError + */ + function connect($dsn, $options = false) + { + if (is_array($dsn)) { + $dsninfo = $dsn; + } else { + $dsninfo = DB::parseDSN($dsn); + } + switch ($dsninfo["phptype"]) { + case 'pgsql': $type = 'postgres7'; break; + case 'ifx': $type = 'informix9'; break; + default: $type = $dsninfo["phptype"]; break; + } + + if (is_array($options) && isset($options["debug"]) && + $options["debug"] >= 2) { + // expose php errors with sufficient debug level + @include_once("adodb-$type.inc.php"); + } else { + @include_once("adodb-$type.inc.php"); + } + + @$obj = NewADOConnection($type); + if (!is_object($obj)) { + $obj = new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); + return $obj; + } + if (is_array($options)) { + foreach($options as $k => $v) { + switch(strtolower($k)) { + case 'persist': + case 'persistent': $persist = $v; break; + #ibase + case 'dialect': $obj->dialect = $v; break; + case 'charset': $obj->charset = $v; break; + case 'buffers': $obj->buffers = $v; break; + #ado + case 'charpage': $obj->charPage = $v; break; + #mysql + case 'clientflags': $obj->clientFlags = $v; break; + } + } + } else { + $persist = false; + } + + if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket']; + else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port']; + + if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); + else $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); + + if (!$ok) $obj = ADODB_PEAR_Error(); + return $obj; + } + + /** + * Return the DB API version + * + * @return int the DB API version number + */ + function apiVersion() + { + return 2; + } + + /** + * Tell whether a result code from a DB method is an error + * + * @param $value int result code + * + * @return bool whether $value is an error + */ + function isError($value) + { + if (!is_object($value)) return false; + $class = strtolower(get_class($value)); + return $class == 'pear_error' || is_subclass_of($value, 'pear_error') || + $class == 'db_error' || is_subclass_of($value, 'db_error'); + } + + + /** + * Tell whether a result code from a DB method is a warning. + * Warnings differ from errors in that they are generated by DB, + * and are not fatal. + * + * @param $value mixed result value + * + * @return bool whether $value is a warning + */ + function isWarning($value) + { + return false; + /* + return is_object($value) && + (get_class( $value ) == "db_warning" || + is_subclass_of($value, "db_warning"));*/ + } + + /** + * Parse a data source name + * + * @param $dsn string Data Source Name to be parsed + * + * @return array an associative array with the following keys: + * + * phptype: Database backend used in PHP (mysql, odbc etc.) + * dbsyntax: Database used with regards to SQL syntax etc. + * protocol: Communication protocol to use (tcp, unix etc.) + * hostspec: Host specification (hostname[:port]) + * database: Database to use on the DBMS server + * username: User name for login + * password: Password for login + * + * The format of the supplied DSN is in its fullest form: + * + * phptype(dbsyntax)://username:password@protocol+hostspec/database + * + * Most variations are allowed: + * + * phptype://username:password@protocol+hostspec:110//usr/db_file.db + * phptype://username:password@hostspec/database_name + * phptype://username:password@hostspec + * phptype://username@hostspec + * phptype://hostspec/database + * phptype://hostspec + * phptype(dbsyntax) + * phptype + * + * @author Tomas V.V.Cox + */ + function parseDSN($dsn) + { + if (is_array($dsn)) { + return $dsn; + } + + $parsed = array( + 'phptype' => false, + 'dbsyntax' => false, + 'protocol' => false, + 'hostspec' => false, + 'database' => false, + 'username' => false, + 'password' => false + ); + + // Find phptype and dbsyntax + if (($pos = strpos($dsn, '://')) !== false) { + $str = substr($dsn, 0, $pos); + $dsn = substr($dsn, $pos + 3); + } else { + $str = $dsn; + $dsn = NULL; + } + + // Get phptype and dbsyntax + // $str => phptype(dbsyntax) + if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { + $parsed['phptype'] = $arr[1]; + $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; + } else { + $parsed['phptype'] = $str; + $parsed['dbsyntax'] = $str; + } + + if (empty($dsn)) { + return $parsed; + } + + // Get (if found): username and password + // $dsn => username:password@protocol+hostspec/database + if (($at = strpos($dsn,'@')) !== false) { + $str = substr($dsn, 0, $at); + $dsn = substr($dsn, $at + 1); + if (($pos = strpos($str, ':')) !== false) { + $parsed['username'] = urldecode(substr($str, 0, $pos)); + $parsed['password'] = urldecode(substr($str, $pos + 1)); + } else { + $parsed['username'] = urldecode($str); + } + } + + // Find protocol and hostspec + // $dsn => protocol+hostspec/database + if (($pos=strpos($dsn, '/')) !== false) { + $str = substr($dsn, 0, $pos); + $dsn = substr($dsn, $pos + 1); + } else { + $str = $dsn; + $dsn = NULL; + } + + // Get protocol + hostspec + // $str => protocol+hostspec + if (($pos=strpos($str, '+')) !== false) { + $parsed['protocol'] = substr($str, 0, $pos); + $parsed['hostspec'] = urldecode(substr($str, $pos + 1)); + } else { + $parsed['hostspec'] = urldecode($str); + } + + // Get dabase if any + // $dsn => database + if (!empty($dsn)) { + $parsed['database'] = $dsn; + } + + return $parsed; + } + + /** + * Load a PHP database extension if it is not loaded already. + * + * @access public + * + * @param $name the base name of the extension (without the .so or + * .dll suffix) + * + * @return bool true if the extension was already or successfully + * loaded, false if it could not be loaded + */ + function assertExtension($name) + { + if (!extension_loaded($name)) { + $dlext = (strncmp(PHP_OS,'WIN',3) === 0) ? '.dll' : '.so'; + @dl($name . $dlext); + } + if (!extension_loaded($name)) { + return false; + } + return true; + } +} + +?> \ No newline at end of file diff --git a/includes/adodb/adodb-perf.inc.php b/includes/adodb/adodb-perf.inc.php new file mode 100644 index 00000000..39fdf2ed --- /dev/null +++ b/includes/adodb/adodb-perf.inc.php @@ -0,0 +1,1089 @@ += minimum number of secs to run + + +// returns in K the memory of current process, or 0 if not known +function adodb_getmem() +{ + if (function_exists('memory_get_usage')) + return (integer) ((memory_get_usage()+512)/1024); + + $pid = getmypid(); + + if ( strncmp(strtoupper(PHP_OS),'WIN',3)==0) { + $output = array(); + + exec('tasklist /FI "PID eq ' . $pid. '" /FO LIST', $output); + return substr($output[5], strpos($output[5], ':') + 1); + } + + /* Hopefully UNIX */ + exec("ps --pid $pid --no-headers -o%mem,size", $output); + if (sizeof($output) == 0) return 0; + + $memarr = explode(' ',$output[0]); + if (sizeof($memarr)>=2) return (integer) $memarr[1]; + + return 0; +} + +// avoids localization problems where , is used instead of . +function adodb_round($n,$prec) +{ + return number_format($n, $prec, '.', ''); +} + +/* return microtime value as a float */ +function adodb_microtime() +{ + $t = microtime(); + $t = explode(' ',$t); + return (float)$t[1]+ (float)$t[0]; +} + +/* sql code timing */ +function adodb_log_sql(&$connx,$sql,$inputarr) +{ + $perf_table = adodb_perf::table(); + $connx->fnExecute = false; + $t0 = microtime(); + $rs = $connx->Execute($sql,$inputarr); + $t1 = microtime(); + + if (!empty($connx->_logsql) && (empty($connx->_logsqlErrors) || !$rs)) { + global $ADODB_LOG_CONN; + + if (!empty($ADODB_LOG_CONN)) { + $conn = $ADODB_LOG_CONN; + if ($conn->databaseType != $connx->databaseType) + $prefix = '/*dbx='.$connx->databaseType .'*/ '; + else + $prefix = ''; + } else { + $conn = $connx; + $prefix = ''; + } + + $conn->_logsql = false; // disable logsql error simulation + $dbT = $conn->databaseType; + + $a0 = split(' ',$t0); + $a0 = (float)$a0[1]+(float)$a0[0]; + + $a1 = split(' ',$t1); + $a1 = (float)$a1[1]+(float)$a1[0]; + + $time = $a1 - $a0; + + if (!$rs) { + $errM = $connx->ErrorMsg(); + $errN = $connx->ErrorNo(); + $conn->lastInsID = 0; + $tracer = substr('ERROR: '.htmlspecialchars($errM),0,250); + } else { + $tracer = ''; + $errM = ''; + $errN = 0; + $dbg = $conn->debug; + $conn->debug = false; + if (!is_object($rs) || $rs->dataProvider == 'empty') + $conn->_affected = $conn->affected_rows(true); + $conn->lastInsID = @$conn->Insert_ID(); + $conn->debug = $dbg; + } + if (isset($_SERVER['HTTP_HOST'])) { + $tracer .= '
'.$_SERVER['HTTP_HOST']; + if (isset($_SERVER['PHP_SELF'])) $tracer .= htmlspecialchars($_SERVER['PHP_SELF']); + } else + if (isset($_SERVER['PHP_SELF'])) $tracer .= '
'.htmlspecialchars($_SERVER['PHP_SELF']); + //$tracer .= (string) adodb_backtrace(false); + + $tracer = (string) substr($tracer,0,500); + + if (is_array($inputarr)) { + if (is_array(reset($inputarr))) $params = 'Array sizeof='.sizeof($inputarr); + else { + // Quote string parameters so we can see them in the + // performance stats. This helps spot disabled indexes. + $xar_params = $inputarr; + foreach ($xar_params as $xar_param_key => $xar_param) { + if (gettype($xar_param) == 'string') + $xar_params[$xar_param_key] = '"' . $xar_param . '"'; + } + $params = implode(', ', $xar_params); + if (strlen($params) >= 3000) $params = substr($params, 0, 3000); + } + } else { + $params = ''; + } + + if (is_array($sql)) $sql = $sql[0]; + if ($prefix) $sql = $prefix.$sql; + $arr = array('b'=>strlen($sql).'.'.crc32($sql), + 'c'=>substr($sql,0,3900), 'd'=>$params,'e'=>$tracer,'f'=>adodb_round($time,6)); + //var_dump($arr); + $saved = $conn->debug; + $conn->debug = 0; + + $d = $conn->sysTimeStamp; + if (empty($d)) $d = date("'Y-m-d H:i:s'"); + if ($conn->dataProvider == 'oci8' && $dbT != 'oci8po') { + $isql = "insert into $perf_table values($d,:b,:c,:d,:e,:f)"; + } else if ($dbT == 'odbc_mssql' || $dbT == 'informix' || strncmp($dbT,'odbtp',4)==0) { + $timer = $arr['f']; + if ($dbT == 'informix') $sql2 = substr($sql2,0,230); + + $sql1 = $conn->qstr($arr['b']); + $sql2 = $conn->qstr($arr['c']); + $params = $conn->qstr($arr['d']); + $tracer = $conn->qstr($arr['e']); + + $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values($d,$sql1,$sql2,$params,$tracer,$timer)"; + if ($dbT == 'informix') $isql = str_replace(chr(10),' ',$isql); + $arr = false; + } else { + if ($dbT == 'db2') $arr['f'] = (float) $arr['f']; + $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values( $d,?,?,?,?,?)"; + } + + global $ADODB_PERF_MIN; + if ($errN != 0 || $time >= $ADODB_PERF_MIN) { + $ok = $conn->Execute($isql,$arr); + } else + $ok = true; + + $conn->debug = $saved; + + if ($ok) { + $conn->_logsql = true; + } else { + $err2 = $conn->ErrorMsg(); + $conn->_logsql = true; // enable logsql error simulation + $perf = NewPerfMonitor($conn); + if ($perf) { + if ($perf->CreateLogTable()) $ok = $conn->Execute($isql,$arr); + } else { + $ok = $conn->Execute("create table $perf_table ( + created varchar(50), + sql0 varchar(250), + sql1 varchar(4000), + params varchar(3000), + tracer varchar(500), + timer decimal(16,6))"); + } + if (!$ok) { + ADOConnection::outp( "

LOGSQL Insert Failed: $isql
$err2

"); + $conn->_logsql = false; + } + } + $connx->_errorMsg = $errM; + $connx->_errorCode = $errN; + } + $connx->fnExecute = 'adodb_log_sql'; + return $rs; +} + + +/* +The settings data structure is an associative array that database parameter per element. + +Each database parameter element in the array is itself an array consisting of: + +0: category code, used to group related db parameters +1: either + a. sql string to retrieve value, eg. "select value from v\$parameter where name='db_block_size'", + b. array holding sql string and field to look for, e.g. array('show variables','table_cache'), + c. a string prefixed by =, then a PHP method of the class is invoked, + e.g. to invoke $this->GetIndexValue(), set this array element to '=GetIndexValue', +2: description of the database parameter +*/ + +class adodb_perf { + var $conn; + var $color = '#F0F0F0'; + var $table = ''; + var $titles = ''; + var $warnRatio = 90; + var $tablesSQL = false; + var $cliFormat = "%32s => %s \r\n"; + var $sql1 = 'sql1'; // used for casting sql1 to text for mssql + var $explain = true; + var $helpurl = "LogSQL help"; + var $createTableSQL = false; + var $maxLength = 2000; + + // Sets the tablename to be used + static function table($newtable = false) + { + static $_table; + + if (!empty($newtable)) $_table = $newtable; + if (empty($_table)) $_table = 'adodb_logsql'; + return $_table; + } + + // returns array with info to calculate CPU Load + function _CPULoad() + { +/* + +cpu 524152 2662 2515228 336057010 +cpu0 264339 1408 1257951 168025827 +cpu1 259813 1254 1257277 168031181 +page 622307 25475680 +swap 24 1891 +intr 890153570 868093576 6 0 4 4 0 6 1 2 0 0 0 124 0 8098760 2 13961053 0 0 0 0 0 0 0 0 0 0 0 0 0 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +disk_io: (3,0):(3144904,54369,610378,3090535,50936192) (3,1):(3630212,54097,633016,3576115,50951320) +ctxt 66155838 +btime 1062315585 +processes 69293 + +*/ + // Algorithm is taken from + // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/example__obtaining_raw_performance_data.asp + if (strncmp(PHP_OS,'WIN',3)==0) { + if (PHP_VERSION == '5.0.0') return false; + if (PHP_VERSION == '5.0.1') return false; + if (PHP_VERSION == '5.0.2') return false; + if (PHP_VERSION == '5.0.3') return false; + if (PHP_VERSION == '4.3.10') return false; # see http://bugs.php.net/bug.php?id=31737 + + @$c = new COM("WinMgmts:{impersonationLevel=impersonate}!Win32_PerfRawData_PerfOS_Processor.Name='_Total'"); + if (!$c) return false; + + $info[0] = $c->PercentProcessorTime; + $info[1] = 0; + $info[2] = 0; + $info[3] = $c->TimeStamp_Sys100NS; + //print_r($info); + return $info; + } + + // Algorithm - Steve Blinch (BlitzAffe Online, http://www.blitzaffe.com) + $statfile = '/proc/stat'; + if (!file_exists($statfile)) return false; + + $fd = fopen($statfile,"r"); + if (!$fd) return false; + + $statinfo = explode("\n",fgets($fd, 1024)); + fclose($fd); + foreach($statinfo as $line) { + $info = explode(" ",$line); + if($info[0]=="cpu") { + array_shift($info); // pop off "cpu" + if(!$info[0]) array_shift($info); // pop off blank space (if any) + return $info; + } + } + + return false; + + } + + /* NOT IMPLEMENTED */ + function MemInfo() + { + /* + + total: used: free: shared: buffers: cached: +Mem: 1055289344 917299200 137990144 0 165437440 599773184 +Swap: 2146775040 11055104 2135719936 +MemTotal: 1030556 kB +MemFree: 134756 kB +MemShared: 0 kB +Buffers: 161560 kB +Cached: 581384 kB +SwapCached: 4332 kB +Active: 494468 kB +Inact_dirty: 322856 kB +Inact_clean: 24256 kB +Inact_target: 168316 kB +HighTotal: 131064 kB +HighFree: 1024 kB +LowTotal: 899492 kB +LowFree: 133732 kB +SwapTotal: 2096460 kB +SwapFree: 2085664 kB +Committed_AS: 348732 kB + */ + } + + + /* + Remember that this is client load, not db server load! + */ + var $_lastLoad; + function CPULoad() + { + $info = $this->_CPULoad(); + if (!$info) return false; + + if (empty($this->_lastLoad)) { + sleep(1); + $this->_lastLoad = $info; + $info = $this->_CPULoad(); + } + + $last = $this->_lastLoad; + $this->_lastLoad = $info; + + $d_user = $info[0] - $last[0]; + $d_nice = $info[1] - $last[1]; + $d_system = $info[2] - $last[2]; + $d_idle = $info[3] - $last[3]; + + //printf("Delta - User: %f Nice: %f System: %f Idle: %f
",$d_user,$d_nice,$d_system,$d_idle); + + if (strncmp(PHP_OS,'WIN',3)==0) { + if ($d_idle < 1) $d_idle = 1; + return 100*(1-$d_user/$d_idle); + }else { + $total=$d_user+$d_nice+$d_system+$d_idle; + if ($total<1) $total=1; + return 100*($d_user+$d_nice+$d_system)/$total; + } + } + + function Tracer($sql) + { + $perf_table = adodb_perf::table(); + $saveE = $this->conn->fnExecute; + $this->conn->fnExecute = false; + + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); + + $sqlq = $this->conn->qstr($sql); + $arr = $this->conn->GetArray( +"select count(*),tracer + from $perf_table where sql1=$sqlq + group by tracer + order by 1 desc"); + $s = ''; + if ($arr) { + $s .= '

Scripts Affected

'; + foreach($arr as $k) { + $s .= sprintf("%4d",$k[0]).'   '.strip_tags($k[1]).'
'; + } + } + + if (isset($savem)) $this->conn->SetFetchMode($savem); + $ADODB_CACHE_MODE = $save; + $this->conn->fnExecute = $saveE; + return $s; + } + + /* + Explain Plan for $sql. + If only a snippet of the $sql is passed in, then $partial will hold the crc32 of the + actual sql. + */ + function Explain($sql,$partial=false) + { + return false; + } + + function InvalidSQL($numsql = 10) + { + + if (isset($_GET['sql'])) return; + $s = '

Invalid SQL

'; + $saveE = $this->conn->fnExecute; + $this->conn->fnExecute = false; + $perf_table = adodb_perf::table(); + $rs = $this->conn->SelectLimit("select distinct count(*),sql1,tracer as error_msg from $perf_table where tracer like 'ERROR:%' group by sql1,tracer order by 1 desc",$numsql);//,$numsql); + $this->conn->fnExecute = $saveE; + if ($rs) { + $s .= rs2html($rs,false,false,false,false); + } else + return "

$this->helpurl. ".$this->conn->ErrorMsg()."

"; + + return $s; + } + + + /* + This script identifies the longest running SQL + */ + function _SuspiciousSQL($numsql = 10) + { + global $ADODB_FETCH_MODE; + + $perf_table = adodb_perf::table(); + $saveE = $this->conn->fnExecute; + $this->conn->fnExecute = false; + + if (isset($_GET['exps']) && isset($_GET['sql'])) { + $partial = !empty($_GET['part']); + echo "".$this->Explain($_GET['sql'],$partial)."\n"; + } + + if (isset($_GET['sql'])) return; + $sql1 = $this->sql1; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); + //$this->conn->debug=1; + $rs = $this->conn->SelectLimit( + "select avg(timer) as avg_timer,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer + from $perf_table + where {$this->conn->upperCase}({$this->conn->substr}(sql0,1,5)) not in ('DROP ','INSER','COMMI','CREAT') + and (tracer is null or tracer not like 'ERROR:%') + group by sql1 + order by 1 desc",$numsql); + if (isset($savem)) $this->conn->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + $this->conn->fnExecute = $saveE; + + if (!$rs) return "

$this->helpurl. ".$this->conn->ErrorMsg()."

"; + $s = "

Suspicious SQL

+The following SQL have high average execution times
+
ParameterValueDescription
\n"; + $max = $this->maxLength; + while (!$rs->EOF) { + $sql = $rs->fields[1]; + $raw = urlencode($sql); + if (strlen($raw)>$max-100) { + $sql2 = substr($sql,0,$max-500); + $raw = urlencode($sql2).'&part='.crc32($sql); + } + $prefix = ""; + $suffix = ""; + if ($this->explain == false || strlen($prefix)>$max) { + $suffix = ' ... String too long for GET parameter: '.strlen($prefix).''; + $prefix = ''; + } + $s .= ""; + $rs->MoveNext(); + } + return $s."
Avg TimeCountSQLMaxMin
".adodb_round($rs->fields[0],6)."".$rs->fields[2]."".$prefix.htmlspecialchars($sql).$suffix."". + "".$rs->fields[3]."".$rs->fields[4]."
"; + + } + + function CheckMemory() + { + return ''; + } + + + function SuspiciousSQL($numsql=10) + { + return adodb_perf::_SuspiciousSQL($numsql); + } + + function ExpensiveSQL($numsql=10) + { + return adodb_perf::_ExpensiveSQL($numsql); + } + + + /* + This reports the percentage of load on the instance due to the most + expensive few SQL statements. Tuning these statements can often + make huge improvements in overall system performance. + */ + function _ExpensiveSQL($numsql = 10) + { + global $ADODB_FETCH_MODE; + + $perf_table = adodb_perf::table(); + $saveE = $this->conn->fnExecute; + $this->conn->fnExecute = false; + + if (isset($_GET['expe']) && isset($_GET['sql'])) { + $partial = !empty($_GET['part']); + echo "".$this->Explain($_GET['sql'],$partial)."\n"; + } + + if (isset($_GET['sql'])) return; + + $sql1 = $this->sql1; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); + + $rs = $this->conn->SelectLimit( + "select sum(timer) as total,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer + from $perf_table + where {$this->conn->upperCase}({$this->conn->substr}(sql0,1,5)) not in ('DROP ','INSER','COMMI','CREAT') + and (tracer is null or tracer not like 'ERROR:%') + group by sql1 + having count(*)>1 + order by 1 desc",$numsql); + if (isset($savem)) $this->conn->SetFetchMode($savem); + $this->conn->fnExecute = $saveE; + $ADODB_FETCH_MODE = $save; + if (!$rs) return "

$this->helpurl. ".$this->conn->ErrorMsg()."

"; + $s = "

Expensive SQL

+Tuning the following SQL could reduce the server load substantially
+\n"; + $max = $this->maxLength; + while (!$rs->EOF) { + $sql = $rs->fields[1]; + $raw = urlencode($sql); + if (strlen($raw)>$max-100) { + $sql2 = substr($sql,0,$max-500); + $raw = urlencode($sql2).'&part='.crc32($sql); + } + $prefix = ""; + $suffix = ""; + if($this->explain == false || strlen($prefix>$max)) { + $prefix = ''; + $suffix = ''; + } + $s .= ""; + $rs->MoveNext(); + } + return $s."
LoadCountSQLMaxMin
".adodb_round($rs->fields[0],6)."".$rs->fields[2]."".$prefix.htmlspecialchars($sql).$suffix."". + "".$rs->fields[3]."".$rs->fields[4]."
"; + } + + /* + Raw function to return parameter value from $settings. + */ + function DBParameter($param) + { + if (empty($this->settings[$param])) return false; + $sql = $this->settings[$param][1]; + return $this->_DBParameter($sql); + } + + /* + Raw function returning array of poll paramters + */ + function PollParameters() + { + $arr[0] = (float)$this->DBParameter('data cache hit ratio'); + $arr[1] = (float)$this->DBParameter('data reads'); + $arr[2] = (float)$this->DBParameter('data writes'); + $arr[3] = (integer) $this->DBParameter('current connections'); + return $arr; + } + + /* + Low-level Get Database Parameter + */ + function _DBParameter($sql) + { + $savelog = $this->conn->LogSQL(false); + if (is_array($sql)) { + global $ADODB_FETCH_MODE; + + $sql1 = $sql[0]; + $key = $sql[1]; + if (sizeof($sql)>2) $pos = $sql[2]; + else $pos = 1; + if (sizeof($sql)>3) $coef = $sql[3]; + else $coef = false; + $ret = false; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); + + $rs = $this->conn->Execute($sql1); + + if (isset($savem)) $this->conn->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + if ($rs) { + while (!$rs->EOF) { + $keyf = reset($rs->fields); + if (trim($keyf) == $key) { + $ret = $rs->fields[$pos]; + if ($coef) $ret *= $coef; + break; + } + $rs->MoveNext(); + } + $rs->Close(); + } + $this->conn->LogSQL($savelog); + return $ret; + } else { + if (strncmp($sql,'=',1) == 0) { + $fn = substr($sql,1); + return $this->$fn(); + } + $sql = str_replace('$DATABASE',$this->conn->database,$sql); + $ret = $this->conn->GetOne($sql); + $this->conn->LogSQL($savelog); + + return $ret; + } + } + + /* + Warn if cache ratio falls below threshold. Displayed in "Description" column. + */ + function WarnCacheRatio($val) + { + if ($val < $this->warnRatio) + return 'Cache ratio should be at least '.$this->warnRatio.'%'; + else return ''; + } + + function clearsql() + { + $perf_table = adodb_perf::table(); + $this->conn->Execute("delete from $perf_table where created<".$this->conn->sysTimeStamp); + } + /***********************************************************************************************/ + // HIGH LEVEL UI FUNCTIONS + /***********************************************************************************************/ + + + function UI($pollsecs=5) + { + global $ADODB_LOG_CONN; + + $perf_table = adodb_perf::table(); + $conn = $this->conn; + + $app = $conn->host; + if ($conn->host && $conn->database) $app .= ', db='; + $app .= $conn->database; + + if ($app) $app .= ', '; + $savelog = $this->conn->LogSQL(false); + $info = $conn->ServerInfo(); + if (isset($_GET['clearsql'])) { + $this->clearsql(); + } + $this->conn->LogSQL($savelog); + + // magic quotes + + if (isset($_GET['sql']) && get_magic_quotes_gpc()) { + $_GET['sql'] = $_GET['sql'] = str_replace(array("\\'",'\"'),array("'",'"'),$_GET['sql']); + } + + if (!isset($_SESSION['ADODB_PERF_SQL'])) $nsql = $_SESSION['ADODB_PERF_SQL'] = 10; + else $nsql = $_SESSION['ADODB_PERF_SQL']; + + $app .= $info['description']; + + + if (isset($_GET['do'])) $do = $_GET['do']; + else if (isset($_POST['do'])) $do = $_POST['do']; + else if (isset($_GET['sql'])) $do = 'viewsql'; + else $do = 'stats'; + + if (isset($_GET['nsql'])) { + if ($_GET['nsql'] > 0) $nsql = $_SESSION['ADODB_PERF_SQL'] = (integer) $_GET['nsql']; + } + echo "ADOdb Performance Monitor on $app"; + if ($do == 'viewsql') $form = "
# SQL:
"; + else $form = " "; + + $allowsql = !defined('ADODB_PERF_NO_RUN_SQL'); + global $ADODB_PERF_MIN; + $app .= " (Min sql timing \$ADODB_PERF_MIN=$ADODB_PERF_MIN secs)"; + + if (empty($_GET['hidem'])) + echo "
+ ADOdb Performance Monitor for $app
+ Performance Stats   View SQL +   View Tables   Poll Stats", + $allowsql ? '   Run SQL' : '', + "$form", + "
"; + + + switch ($do) { + default: + case 'stats': + if (empty($ADODB_LOG_CONN)) + echo "

  Clear SQL Log
"; + echo $this->HealthCheck(); + //$this->conn->debug=1; + echo $this->CheckMemory(); + break; + case 'poll': + $self = htmlspecialchars($_SERVER['PHP_SELF']); + echo ""; + break; + case 'poll2': + echo "

";
+			$this->Poll($pollsecs);
+			break;
+		
+		case 'dosql':
+			if (!$allowsql) break;
+			
+			$this->DoSQLForm();
+			break;
+		case 'viewsql':
+			if (empty($_GET['hidem']))
+				echo "  Clear SQL Log
"; + echo($this->SuspiciousSQL($nsql)); + echo($this->ExpensiveSQL($nsql)); + echo($this->InvalidSQL($nsql)); + break; + case 'tables': + echo $this->Tables(); break; + } + global $ADODB_vers; + echo "

$ADODB_vers Sponsored by phpLens
"; + } + + /* + Runs in infinite loop, returning real-time statistics + */ + function Poll($secs=5) + { + $this->conn->fnExecute = false; + //$this->conn->debug=1; + if ($secs <= 1) $secs = 1; + echo "Accumulating statistics, every $secs seconds...\n";flush(); + $arro = $this->PollParameters(); + $cnt = 0; + set_time_limit(0); + sleep($secs); + while (1) { + + $arr = $this->PollParameters(); + + $hits = sprintf('%2.2f',$arr[0]); + $reads = sprintf('%12.4f',($arr[1]-$arro[1])/$secs); + $writes = sprintf('%12.4f',($arr[2]-$arro[2])/$secs); + $sess = sprintf('%5d',$arr[3]); + + $load = $this->CPULoad(); + if ($load !== false) { + $oslabel = 'WS-CPU%'; + $osval = sprintf(" %2.1f ",(float) $load); + }else { + $oslabel = ''; + $osval = ''; + } + if ($cnt % 10 == 0) echo " Time ".$oslabel." Hit% Sess Reads/s Writes/s\n"; + $cnt += 1; + echo date('H:i:s').' '.$osval."$hits $sess $reads $writes\n"; + flush(); + + if (connection_aborted()) return; + + sleep($secs); + $arro = $arr; + } + } + + /* + Returns basic health check in a command line interface + */ + function HealthCheckCLI() + { + return $this->HealthCheck(true); + } + + + /* + Returns basic health check as HTML + */ + function HealthCheck($cli=false) + { + $saveE = $this->conn->fnExecute; + $this->conn->fnExecute = false; + if ($cli) $html = ''; + else $html = $this->table.'

'.$this->conn->databaseType.'

'.$this->titles; + + $oldc = false; + $bgc = ''; + foreach($this->settings as $name => $arr) { + if ($arr === false) break; + + if (!is_string($name)) { + if ($cli) $html .= " -- $arr -- \n"; + else $html .= "color>$arr  "; + continue; + } + + if (!is_array($arr)) break; + $category = $arr[0]; + $how = $arr[1]; + if (sizeof($arr)>2) $desc = $arr[2]; + else $desc = '   '; + + + if ($category == 'HIDE') continue; + + $val = $this->_DBParameter($how); + + if ($desc && strncmp($desc,"=",1) === 0) { + $fn = substr($desc,1); + $desc = $this->$fn($val); + } + + if ($val === false) { + $m = $this->conn->ErrorMsg(); + $val = "Error: $m"; + } else { + if (is_numeric($val) && $val >= 256*1024) { + if ($val % (1024*1024) == 0) { + $val /= (1024*1024); + $val .= 'M'; + } else if ($val % 1024 == 0) { + $val /= 1024; + $val .= 'K'; + } + //$val = htmlspecialchars($val); + } + } + if ($category != $oldc) { + $oldc = $category; + //$bgc = ($bgc == ' bgcolor='.$this->color) ? ' bgcolor=white' : ' bgcolor='.$this->color; + } + if (strlen($desc)==0) $desc = ' '; + if (strlen($val)==0) $val = ' '; + if ($cli) { + $html .= str_replace(' ','',sprintf($this->cliFormat,strip_tags($name),strip_tags($val),strip_tags($desc))); + + }else { + $html .= "".$name.''.$val.''.$desc."\n"; + } + } + + if (!$cli) $html .= "\n"; + $this->conn->fnExecute = $saveE; + + return $html; + } + + function Tables($orderby='1') + { + if (!$this->tablesSQL) return false; + + $savelog = $this->conn->LogSQL(false); + $rs = $this->conn->Execute($this->tablesSQL.' order by '.$orderby); + $this->conn->LogSQL($savelog); + $html = rs2html($rs,false,false,false,false); + return $html; + } + + + function CreateLogTable() + { + if (!$this->createTableSQL) return false; + + $table = $this->table(); + $sql = str_replace('adodb_logsql',$table,$this->createTableSQL); + $savelog = $this->conn->LogSQL(false); + $ok = $this->conn->Execute($sql); + $this->conn->LogSQL($savelog); + return ($ok) ? true : false; + } + + function DoSQLForm() + { + + + $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF']); + $sql = isset($_REQUEST['sql']) ? $_REQUEST['sql'] : ''; + + if (isset($_SESSION['phplens_sqlrows'])) $rows = $_SESSION['phplens_sqlrows']; + else $rows = 3; + + if (isset($_REQUEST['SMALLER'])) { + $rows /= 2; + if ($rows < 3) $rows = 3; + $_SESSION['phplens_sqlrows'] = $rows; + } + if (isset($_REQUEST['BIGGER'])) { + $rows *= 2; + $_SESSION['phplens_sqlrows'] = $rows; + } + +?> + +
+ + + + + + +
Form size: + + +
+
+
+ +undomq(trim($sql)); + if (substr($sql,strlen($sql)-1) === ';') { + $print = true; + $sqla = $this->SplitSQL($sql); + } else { + $print = false; + $sqla = array($sql); + } + foreach($sqla as $sqls) { + + if (!$sqls) continue; + + if ($print) { + print "

".htmlspecialchars($sqls)."

"; + flush(); + } + $savelog = $this->conn->LogSQL(false); + $rs = $this->conn->Execute($sqls); + $this->conn->LogSQL($savelog); + if ($rs && is_object($rs) && !$rs->EOF) { + rs2html($rs); + while ($rs->NextRecordSet()) { + print "
 
"; + rs2html($rs); + } + } else { + $e1 = (integer) $this->conn->ErrorNo(); + $e2 = $this->conn->ErrorMsg(); + if (($e1) || ($e2)) { + if (empty($e1)) $e1 = '-1'; // postgresql fix + print '   '.$e1.': '.$e2; + } else { + print "

No Recordset returned

"; + } + } + } // foreach + } + + function SplitSQL($sql) + { + $arr = explode(';',$sql); + return $arr; + } + + function undomq($m) + { + if (get_magic_quotes_gpc()) { + // undo the damage + $m = str_replace('\\\\','\\',$m); + $m = str_replace('\"','"',$m); + $m = str_replace('\\\'','\'',$m); + } + return $m; +} + + + /************************************************************************/ + + /** + * Reorganise multiple table-indices/statistics/.. + * OptimizeMode could be given by last Parameter + * + * @example + *
+     *          optimizeTables( 'tableA');
+     *      
+ *
+     *          optimizeTables( 'tableA', 'tableB', 'tableC');
+     *      
+ *
+     *          optimizeTables( 'tableA', 'tableB', ADODB_OPT_LOW);
+     *      
+ * + * @param string table name of the table to optimize + * @param int mode optimization-mode + * ADODB_OPT_HIGH for full optimization + * ADODB_OPT_LOW for CPU-less optimization + * Default is LOW ADODB_OPT_LOW + * @author Markus Staab + * @return Returns true on success and false on error + */ + function OptimizeTables() + { + $args = func_get_args(); + $numArgs = func_num_args(); + + if ( $numArgs == 0) return false; + + $mode = ADODB_OPT_LOW; + $lastArg = $args[ $numArgs - 1]; + if ( !is_string($lastArg)) { + $mode = $lastArg; + unset( $args[ $numArgs - 1]); + } + + foreach( $args as $table) { + $this->optimizeTable( $table, $mode); + } + } + + /** + * Reorganise the table-indices/statistics/.. depending on the given mode. + * Default Implementation throws an error. + * + * @param string table name of the table to optimize + * @param int mode optimization-mode + * ADODB_OPT_HIGH for full optimization + * ADODB_OPT_LOW for CPU-less optimization + * Default is LOW ADODB_OPT_LOW + * @author Markus Staab + * @return Returns true on success and false on error + */ + function OptimizeTable( $table, $mode = ADODB_OPT_LOW) + { + ADOConnection::outp( sprintf( "

%s: '%s' not implemented for driver '%s'

", __CLASS__, __FUNCTION__, $this->conn->databaseType)); + return false; + } + + /** + * Reorganise current database. + * Default implementation loops over all MetaTables() and + * optimize each using optmizeTable() + * + * @author Markus Staab + * @return Returns true on success and false on error + */ + function optimizeDatabase() + { + $conn = $this->conn; + if ( !$conn) return false; + + $tables = $conn->MetaTables( 'TABLES'); + if ( !$tables ) return false; + + foreach( $tables as $table) { + if ( !$this->optimizeTable( $table)) { + return false; + } + } + + return true; + } + // end hack +} + +?> \ No newline at end of file diff --git a/includes/adodb/adodb-php4.inc.php b/includes/adodb/adodb-php4.inc.php new file mode 100644 index 00000000..1b4796b9 --- /dev/null +++ b/includes/adodb/adodb-php4.inc.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/includes/adodb/adodb-time.inc.php b/includes/adodb/adodb-time.inc.php new file mode 100644 index 00000000..06374216 --- /dev/null +++ b/includes/adodb/adodb-time.inc.php @@ -0,0 +1,1426 @@ + 4 digit year conversion. The maximum is billions of years in the +future, but this is a theoretical limit as the computation of that year +would take too long with the current implementation of adodb_mktime(). + +This library replaces native functions as follows: + +
	
+	getdate()  with  adodb_getdate()
+	date()     with  adodb_date() 
+	gmdate()   with  adodb_gmdate()
+	mktime()   with  adodb_mktime()
+	gmmktime() with  adodb_gmmktime()
+	strftime() with  adodb_strftime()
+	strftime() with  adodb_gmstrftime()
+
+ +The parameters are identical, except that adodb_date() accepts a subset +of date()'s field formats. Mktime() will convert from local time to GMT, +and date() will convert from GMT to local time, but daylight savings is +not handled currently. + +This library is independant of the rest of ADOdb, and can be used +as standalone code. + +PERFORMANCE + +For high speed, this library uses the native date functions where +possible, and only switches to PHP code when the dates fall outside +the 32-bit signed integer range. + +GREGORIAN CORRECTION + +Pope Gregory shortened October of A.D. 1582 by ten days. Thursday, +October 4, 1582 (Julian) was followed immediately by Friday, October 15, +1582 (Gregorian). + +Since 0.06, we handle this correctly, so: + +adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582) + == 24 * 3600 (1 day) + +============================================================================= + +COPYRIGHT + +(c) 2003-2005 John Lim and released under BSD-style license except for code by +jackbbs, which includes adodb_mktime, adodb_get_gmt_diff, adodb_is_leap_year +and originally found at http://www.php.net/manual/en/function.mktime.php + +============================================================================= + +BUG REPORTS + +These should be posted to the ADOdb forums at + + http://phplens.com/lens/lensforum/topics.php?id=4 + +============================================================================= + +FUNCTION DESCRIPTIONS + + +** FUNCTION adodb_getdate($date=false) + +Returns an array containing date information, as getdate(), but supports +dates greater than 1901 to 2038. The local date/time format is derived from a +heuristic the first time adodb_getdate is called. + + +** FUNCTION adodb_date($fmt, $timestamp = false) + +Convert a timestamp to a formatted local date. If $timestamp is not defined, the +current timestamp is used. Unlike the function date(), it supports dates +outside the 1901 to 2038 range. + +The format fields that adodb_date supports: + +
+	a - "am" or "pm" 
+	A - "AM" or "PM" 
+	d - day of the month, 2 digits with leading zeros; i.e. "01" to "31" 
+	D - day of the week, textual, 3 letters; e.g. "Fri" 
+	F - month, textual, long; e.g. "January" 
+	g - hour, 12-hour format without leading zeros; i.e. "1" to "12" 
+	G - hour, 24-hour format without leading zeros; i.e. "0" to "23" 
+	h - hour, 12-hour format; i.e. "01" to "12" 
+	H - hour, 24-hour format; i.e. "00" to "23" 
+	i - minutes; i.e. "00" to "59" 
+	j - day of the month without leading zeros; i.e. "1" to "31" 
+	l (lowercase 'L') - day of the week, textual, long; e.g. "Friday"  
+	L - boolean for whether it is a leap year; i.e. "0" or "1" 
+	m - month; i.e. "01" to "12" 
+	M - month, textual, 3 letters; e.g. "Jan" 
+	n - month without leading zeros; i.e. "1" to "12" 
+	O - Difference to Greenwich time in hours; e.g. "+0200" 
+	Q - Quarter, as in 1, 2, 3, 4 
+	r - RFC 2822 formatted date; e.g. "Thu, 21 Dec 2000 16:01:07 +0200" 
+	s - seconds; i.e. "00" to "59" 
+	S - English ordinal suffix for the day of the month, 2 characters; 
+	   			i.e. "st", "nd", "rd" or "th" 
+	t - number of days in the given month; i.e. "28" to "31"
+	T - Timezone setting of this machine; e.g. "EST" or "MDT" 
+	U - seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)  
+	w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday) 
+	Y - year, 4 digits; e.g. "1999" 
+	y - year, 2 digits; e.g. "99" 
+	z - day of the year; i.e. "0" to "365" 
+	Z - timezone offset in seconds (i.e. "-43200" to "43200"). 
+	   			The offset for timezones west of UTC is always negative, 
+				and for those east of UTC is always positive. 
+
+ +Unsupported: +
+	B - Swatch Internet time 
+	I (capital i) - "1" if Daylight Savings Time, "0" otherwise.
+	W - ISO-8601 week number of year, weeks starting on Monday 
+
+
+ + +** FUNCTION adodb_date2($fmt, $isoDateString = false) +Same as adodb_date, but 2nd parameter accepts iso date, eg. + + adodb_date2('d-M-Y H:i','2003-12-25 13:01:34'); + + +** FUNCTION adodb_gmdate($fmt, $timestamp = false) + +Convert a timestamp to a formatted GMT date. If $timestamp is not defined, the +current timestamp is used. Unlike the function date(), it supports dates +outside the 1901 to 2038 range. + + +** FUNCTION adodb_mktime($hr, $min, $sec[, $month, $day, $year]) + +Converts a local date to a unix timestamp. Unlike the function mktime(), it supports +dates outside the 1901 to 2038 range. All parameters are optional. + + +** FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year]) + +Converts a gmt date to a unix timestamp. Unlike the function gmmktime(), it supports +dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters +are currently compulsory. + +** FUNCTION adodb_gmstrftime($fmt, $timestamp = false) +Convert a timestamp to a formatted GMT date. + +** FUNCTION adodb_strftime($fmt, $timestamp = false) + +Convert a timestamp to a formatted local date. Internally converts $fmt into +adodb_date format, then echo result. + +For best results, you can define the local date format yourself. Define a global +variable $ADODB_DATE_LOCALE which is an array, 1st element is date format using +adodb_date syntax, and 2nd element is the time format, also in adodb_date syntax. + + eg. $ADODB_DATE_LOCALE = array('d/m/Y','H:i:s'); + + Supported format codes: + +
+	%a - abbreviated weekday name according to the current locale 
+	%A - full weekday name according to the current locale 
+	%b - abbreviated month name according to the current locale 
+	%B - full month name according to the current locale 
+	%c - preferred date and time representation for the current locale 
+	%d - day of the month as a decimal number (range 01 to 31) 
+	%D - same as %m/%d/%y 
+	%e - day of the month as a decimal number, a single digit is preceded by a space (range ' 1' to '31') 
+	%h - same as %b
+	%H - hour as a decimal number using a 24-hour clock (range 00 to 23) 
+	%I - hour as a decimal number using a 12-hour clock (range 01 to 12) 
+	%m - month as a decimal number (range 01 to 12) 
+	%M - minute as a decimal number 
+	%n - newline character 
+	%p - either `am' or `pm' according to the given time value, or the corresponding strings for the current locale 
+	%r - time in a.m. and p.m. notation 
+	%R - time in 24 hour notation 
+	%S - second as a decimal number 
+	%t - tab character 
+	%T - current time, equal to %H:%M:%S 
+	%x - preferred date representation for the current locale without the time 
+	%X - preferred time representation for the current locale without the date 
+	%y - year as a decimal number without a century (range 00 to 99) 
+	%Y - year as a decimal number including the century 
+	%Z - time zone or name or abbreviation 
+	%% - a literal `%' character 
+
+ + Unsupported codes: +
+	%C - century number (the year divided by 100 and truncated to an integer, range 00 to 99) 
+	%g - like %G, but without the century. 
+	%G - The 4-digit year corresponding to the ISO week number (see %V). 
+	     This has the same format and value as %Y, except that if the ISO week number belongs 
+		 to the previous or next year, that year is used instead. 
+	%j - day of the year as a decimal number (range 001 to 366) 
+	%u - weekday as a decimal number [1,7], with 1 representing Monday 
+	%U - week number of the current year as a decimal number, starting 
+	    with the first Sunday as the first day of the first week 
+	%V - The ISO 8601:1988 week number of the current year as a decimal number, 
+	     range 01 to 53, where week 1 is the first week that has at least 4 days in the 
+		 current year, and with Monday as the first day of the week. (Use %G or %g for 
+		 the year component that corresponds to the week number for the specified timestamp.) 
+	%w - day of the week as a decimal, Sunday being 0 
+	%W - week number of the current year as a decimal number, starting with the 
+	     first Monday as the first day of the first week 
+
+ +============================================================================= + +NOTES + +Useful url for generating test timestamps: + http://www.4webhelp.net/us/timestamp.php + +Possible future optimizations include + +a. Using an algorithm similar to Plauger's in "The Standard C Library" +(page 428, xttotm.c _Ttotm() function). Plauger's algorithm will not +work outside 32-bit signed range, so i decided not to implement it. + +b. Implement daylight savings, which looks awfully complicated, see + http://webexhibits.org/daylightsaving/ + + +CHANGELOG + +- 11 Feb 2008 0.33 +* Bug in 0.32 fix for hour handling. Fixed. + +- 1 Feb 2008 0.32 +* Now adodb_mktime(0,0,0,12+$m,20,2040) works properly. + +- 10 Jan 2008 0.31 +* Now adodb_mktime(0,0,0,24,1,2037) works correctly. + +- 15 July 2007 0.30 +Added PHP 5.2.0 compatability fixes. + * gmtime behaviour for 1970 has changed. We use the actual date if it is between 1970 to 2038 to get the + * timezone, otherwise we use the current year as the baseline to retrieve the timezone. + * Also the timezone's in php 5.2.* support historical data better, eg. if timezone today was +8, but + in 1970 it was +7:30, then php 5.2 return +7:30, while this library will use +8. + * + +- 19 March 2006 0.24 +Changed strftime() locale detection, because some locales prepend the day of week to the date when %c is used. + +- 10 Feb 2006 0.23 +PHP5 compat: when we detect PHP5, the RFC2822 format for gmt 0000hrs is changed from -0000 to +0000. + In PHP4, we will still use -0000 for 100% compat with PHP4. + +- 08 Sept 2005 0.22 +In adodb_date2(), $is_gmt not supported properly. Fixed. + +- 18 July 2005 0.21 +In PHP 4.3.11, the 'r' format has changed. Leading 0 in day is added. Changed for compat. +Added support for negative months in adodb_mktime(). + +- 24 Feb 2005 0.20 +Added limited strftime/gmstrftime support. x10 improvement in performance of adodb_date(). + +- 21 Dec 2004 0.17 +In adodb_getdate(), the timestamp was accidentally converted to gmt when $is_gmt is false. +Also adodb_mktime(0,0,0) did not work properly. Both fixed thx Mauro. + +- 17 Nov 2004 0.16 +Removed intval typecast in adodb_mktime() for secs, allowing: + adodb_mktime(0,0,0 + 2236672153,1,1,1934); +Suggested by Ryan. + +- 18 July 2004 0.15 +All params in adodb_mktime were formerly compulsory. Now only the hour, min, secs is compulsory. +This brings it more in line with mktime (still not identical). + +- 23 June 2004 0.14 + +Allow you to define your own daylights savings function, adodb_daylight_sv. +If the function is defined (somewhere in an include), then you can correct for daylights savings. + +In this example, we apply daylights savings in June or July, adding one hour. This is extremely +unrealistic as it does not take into account time-zone, geographic location, current year. + +function adodb_daylight_sv(&$arr, $is_gmt) +{ + if ($is_gmt) return; + $m = $arr['mon']; + if ($m == 6 || $m == 7) $arr['hours'] += 1; +} + +This is only called by adodb_date() and not by adodb_mktime(). + +The format of $arr is +Array ( + [seconds] => 0 + [minutes] => 0 + [hours] => 0 + [mday] => 1 # day of month, eg 1st day of the month + [mon] => 2 # month (eg. Feb) + [year] => 2102 + [yday] => 31 # days in current year + [leap] => # true if leap year + [ndays] => 28 # no of days in current month + ) + + +- 28 Apr 2004 0.13 +Fixed adodb_date to properly support $is_gmt. Thx to Dimitar Angelov. + +- 20 Mar 2004 0.12 +Fixed month calculation error in adodb_date. 2102-June-01 appeared as 2102-May-32. + +- 26 Oct 2003 0.11 +Because of daylight savings problems (some systems apply daylight savings to +January!!!), changed adodb_get_gmt_diff() to ignore daylight savings. + +- 9 Aug 2003 0.10 +Fixed bug with dates after 2038. +See http://phplens.com/lens/lensforum/msgs.php?id=6980 + +- 1 July 2003 0.09 +Added support for Q (Quarter). +Added adodb_date2(), which accepts ISO date in 2nd param + +- 3 March 2003 0.08 +Added support for 'S' adodb_date() format char. Added constant ADODB_ALLOW_NEGATIVE_TS +if you want PHP to handle negative timestamps between 1901 to 1969. + +- 27 Feb 2003 0.07 +All negative numbers handled by adodb now because of RH 7.3+ problems. +See http://bugs.php.net/bug.php?id=20048&edit=2 + +- 4 Feb 2003 0.06 +Fixed a typo, 1852 changed to 1582! This means that pre-1852 dates +are now correctly handled. + +- 29 Jan 2003 0.05 + +Leap year checking differs under Julian calendar (pre 1582). Also +leap year code optimized by checking for most common case first. + +We also handle month overflow correctly in mktime (eg month set to 13). + +Day overflow for less than one month's days is supported. + +- 28 Jan 2003 0.04 + +Gregorian correction handled. In PHP5, we might throw an error if +mktime uses invalid dates around 5-14 Oct 1582. Released with ADOdb 3.10. +Added limbo 5-14 Oct 1582 check, when we set to 15 Oct 1582. + +- 27 Jan 2003 0.03 + +Fixed some more month problems due to gmt issues. Added constant ADODB_DATE_VERSION. +Fixed calculation of days since start of year for <1970. + +- 27 Jan 2003 0.02 + +Changed _adodb_getdate() to inline leap year checking for better performance. +Fixed problem with time-zones west of GMT +0000. + +- 24 Jan 2003 0.01 + +First implementation. +*/ + + +/* Initialization */ + +/* + Version Number +*/ +define('ADODB_DATE_VERSION',0.33); + +$ADODB_DATETIME_CLASS = (PHP_VERSION >= 5.2); + +/* + This code was originally for windows. But apparently this problem happens + also with Linux, RH 7.3 and later! + + glibc-2.2.5-34 and greater has been changed to return -1 for dates < + 1970. This used to work. The problem exists with RedHat 7.3 and 8.0 + echo (mktime(0, 0, 0, 1, 1, 1960)); // prints -1 + + References: + http://bugs.php.net/bug.php?id=20048&edit=2 + http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html +*/ + +if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1); + +function adodb_date_test_date($y1,$m,$d=13) +{ + $h = round(rand()% 24); + $t = adodb_mktime($h,0,0,$m,$d,$y1); + $rez = adodb_date('Y-n-j H:i:s',$t); + if ($h == 0) $h = '00'; + else if ($h < 10) $h = '0'.$h; + if ("$y1-$m-$d $h:00:00" != $rez) { + print "$y1 error, expected=$y1-$m-$d $h:00:00, adodb=$rez
"; + return false; + } + return true; +} + +function adodb_date_test_strftime($fmt) +{ + $s1 = strftime($fmt); + $s2 = adodb_strftime($fmt); + + if ($s1 == $s2) return true; + + echo "error for $fmt, strftime=$s1, adodb=$s2
"; + return false; +} + +/** + Test Suite +*/ +function adodb_date_test() +{ + + for ($m=-24; $m<=24; $m++) + echo "$m :",adodb_date('d-m-Y',adodb_mktime(0,0,0,1+$m,20,2040)),"
"; + + error_reporting(E_ALL); + print "

Testing adodb_date and adodb_mktime. version=".ADODB_DATE_VERSION.' PHP='.PHP_VERSION."

"; + @set_time_limit(0); + $fail = false; + + // This flag disables calling of PHP native functions, so we can properly test the code + if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1); + + $t = time(); + + + $fmt = 'Y-m-d H:i:s'; + echo '
';
+	echo 'adodb: ',adodb_date($fmt,$t),'
'; + echo 'php : ',date($fmt,$t),'
'; + echo '
'; + + adodb_date_test_strftime('%Y %m %x %X'); + adodb_date_test_strftime("%A %d %B %Y"); + adodb_date_test_strftime("%H %M S"); + + $t = adodb_mktime(0,0,0); + if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0,0,0).'
'; + + $t = adodb_mktime(0,0,0,6,1,2102); + if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).'
'; + + $t = adodb_mktime(0,0,0,2,1,2102); + if (!(adodb_date('Y-m-d',$t) == '2102-02-01')) print 'Error in '.adodb_date('Y-m-d',$t).'
'; + + + print "

Testing gregorian <=> julian conversion

"; + $t = adodb_mktime(0,0,0,10,11,1492); + //http://www.holidayorigins.com/html/columbus_day.html - Friday check + if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11')) print 'Error in Columbus landing
'; + + $t = adodb_mktime(0,0,0,2,29,1500); + if (!(adodb_date('Y-m-d',$t) == '1500-02-29')) print 'Error in julian leap years
'; + + $t = adodb_mktime(0,0,0,2,29,1700); + if (!(adodb_date('Y-m-d',$t) == '1700-03-01')) print 'Error in gregorian leap years
'; + + print adodb_mktime(0,0,0,10,4,1582).' '; + print adodb_mktime(0,0,0,10,15,1582); + $diff = (adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582)); + if ($diff != 3600*24) print " Error in gregorian correction = ".($diff/3600/24)." days
"; + + print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? 'Fri' : 'Error')."
"; + print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? 'Thu' : 'Error')."
"; + + print "

Testing overflow

"; + + $t = adodb_mktime(0,0,0,3,33,1965); + if (!(adodb_date('Y-m-d',$t) == '1965-04-02')) print 'Error in day overflow 1
'; + $t = adodb_mktime(0,0,0,4,33,1971); + if (!(adodb_date('Y-m-d',$t) == '1971-05-03')) print 'Error in day overflow 2
'; + $t = adodb_mktime(0,0,0,1,60,1965); + if (!(adodb_date('Y-m-d',$t) == '1965-03-01')) print 'Error in day overflow 3 '.adodb_date('Y-m-d',$t).'
'; + $t = adodb_mktime(0,0,0,12,32,1965); + if (!(adodb_date('Y-m-d',$t) == '1966-01-01')) print 'Error in day overflow 4 '.adodb_date('Y-m-d',$t).'
'; + $t = adodb_mktime(0,0,0,12,63,1965); + if (!(adodb_date('Y-m-d',$t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).'
'; + $t = adodb_mktime(0,0,0,13,3,1965); + if (!(adodb_date('Y-m-d',$t) == '1966-01-03')) print 'Error in mth overflow 1
'; + + print "Testing 2-digit => 4-digit year conversion

"; + if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000
"; + if (adodb_year_digit_check(10) != 2010) print "Err 2-digit 2010
"; + if (adodb_year_digit_check(20) != 2020) print "Err 2-digit 2020
"; + if (adodb_year_digit_check(30) != 2030) print "Err 2-digit 2030
"; + if (adodb_year_digit_check(40) != 1940) print "Err 2-digit 1940
"; + if (adodb_year_digit_check(50) != 1950) print "Err 2-digit 1950
"; + if (adodb_year_digit_check(90) != 1990) print "Err 2-digit 1990
"; + + // Test string formating + print "

Testing date formating

"; + + $fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C2822 r s t U w y Y z Z 2003'; + $s1 = date($fmt,0); + $s2 = adodb_date($fmt,0); + if ($s1 != $s2) { + print " date() 0 failed
$s1
$s2
"; + } + flush(); + for ($i=100; --$i > 0; ) { + + $ts = 3600.0*((rand()%60000)+(rand()%60000))+(rand()%60000); + $s1 = date($fmt,$ts); + $s2 = adodb_date($fmt,$ts); + //print "$s1
$s2

"; + $pos = strcmp($s1,$s2); + + if (($s1) != ($s2)) { + for ($j=0,$k=strlen($s1); $j < $k; $j++) { + if ($s1[$j] != $s2[$j]) { + print substr($s1,$j).' '; + break; + } + } + print "Error date(): $ts

 
+  \"$s1\" (date len=".strlen($s1).")
+  \"$s2\" (adodb_date len=".strlen($s2).")

"; + $fail = true; + } + + $a1 = getdate($ts); + $a2 = adodb_getdate($ts); + $rez = array_diff($a1,$a2); + if (sizeof($rez)>0) { + print "Error getdate() $ts
"; + print_r($a1); + print "
"; + print_r($a2); + print "

"; + $fail = true; + } + } + + // Test generation of dates outside 1901-2038 + print "

Testing random dates between 100 and 4000

"; + adodb_date_test_date(100,1); + for ($i=100; --$i >= 0;) { + $y1 = 100+rand(0,1970-100); + $m = rand(1,12); + adodb_date_test_date($y1,$m); + + $y1 = 3000-rand(0,3000-1970); + adodb_date_test_date($y1,$m); + } + print '

'; + $start = 1960+rand(0,10); + $yrs = 12; + $i = 365.25*86400*($start-1970); + $offset = 36000+rand(10000,60000); + $max = 365*$yrs*86400; + $lastyear = 0; + + // we generate a timestamp, convert it to a date, and convert it back to a timestamp + // and check if the roundtrip broke the original timestamp value. + print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: "; + $cnt = 0; + for ($max += $i; $i < $max; $i += $offset) { + $ret = adodb_date('m,d,Y,H,i,s',$i); + $arr = explode(',',$ret); + if ($lastyear != $arr[2]) { + $lastyear = $arr[2]; + print " $lastyear "; + flush(); + } + $newi = adodb_mktime($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]); + if ($i != $newi) { + print "Error at $i, adodb_mktime returned $newi ($ret)"; + $fail = true; + break; + } + $cnt += 1; + } + echo "Tested $cnt dates
"; + if (!$fail) print "

Passed !

"; + else print "

Failed :-(

"; +} + +/** + Returns day of week, 0 = Sunday,... 6=Saturday. + Algorithm from PEAR::Date_Calc +*/ +function adodb_dow($year, $month, $day) +{ +/* +Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and +proclaimed that from that time onwards 3 days would be dropped from the calendar +every 400 years. + +Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). +*/ + if ($year <= 1582) { + if ($year < 1582 || + ($year == 1582 && ($month < 10 || ($month == 10 && $day < 15)))) $greg_correction = 3; + else + $greg_correction = 0; + } else + $greg_correction = 0; + + if($month > 2) + $month -= 2; + else { + $month += 10; + $year--; + } + + $day = floor((13 * $month - 1) / 5) + + $day + ($year % 100) + + floor(($year % 100) / 4) + + floor(($year / 100) / 4) - 2 * + floor($year / 100) + 77 + $greg_correction; + + return $day - 7 * floor($day / 7); +} + + +/** + Checks for leap year, returns true if it is. No 2-digit year check. Also + handles julian calendar correctly. +*/ +function _adodb_is_leap_year($year) +{ + if ($year % 4 != 0) return false; + + if ($year % 400 == 0) { + return true; + // if gregorian calendar (>1582), century not-divisible by 400 is not leap + } else if ($year > 1582 && $year % 100 == 0 ) { + return false; + } + + return true; +} + + +/** + checks for leap year, returns true if it is. Has 2-digit year check +*/ +function adodb_is_leap_year($year) +{ + return _adodb_is_leap_year(adodb_year_digit_check($year)); +} + +/** + Fix 2-digit years. Works for any century. + Assumes that if 2-digit is more than 30 years in future, then previous century. +*/ +function adodb_year_digit_check($y) +{ + if ($y < 100) { + + $yr = (integer) date("Y"); + $century = (integer) ($yr /100); + + if ($yr%100 > 50) { + $c1 = $century + 1; + $c0 = $century; + } else { + $c1 = $century; + $c0 = $century - 1; + } + $c1 *= 100; + // if 2-digit year is less than 30 years in future, set it to this century + // otherwise if more than 30 years in future, then we set 2-digit year to the prev century. + if (($y + $c1) < $yr+30) $y = $y + $c1; + else $y = $y + $c0*100; + } + return $y; +} + +function adodb_get_gmt_diff_ts($ts) +{ + if (0 <= $ts && $ts <= 0x7FFFFFFF) { // check if number in 32-bit signed range) { + $arr = getdate($ts); + $y = $arr['year']; + $m = $arr['mon']; + $d = $arr['mday']; + return adodb_get_gmt_diff($y,$m,$d); + } else { + return adodb_get_gmt_diff(false,false,false); + } + +} + +/** + get local time zone offset from GMT. Does not handle historical timezones before 1970. +*/ +function adodb_get_gmt_diff($y,$m,$d) +{ +static $TZ,$tzo; +global $ADODB_DATETIME_CLASS; + + if (!defined('ADODB_TEST_DATES')) $y = false; + else if ($y < 1970 || $y >= 2038) $y = false; + + if ($ADODB_DATETIME_CLASS && $y !== false) { + $dt = new DateTime(); + $dt->setISODate($y,$m,$d); + if (empty($tzo)) { + $tzo = new DateTimeZone(date_default_timezone_get()); + # $tzt = timezone_transitions_get( $tzo ); + } + return -$tzo->getOffset($dt); + } else { + if (isset($TZ)) return $TZ; + $y = date('Y'); + $TZ = mktime(0,0,0,12,2,$y,0) - gmmktime(0,0,0,12,2,$y,0); + } + + return $TZ; +} + +/** + Returns an array with date info. +*/ +function adodb_getdate($d=false,$fast=false) +{ + if ($d === false) return getdate(); + if (!defined('ADODB_TEST_DATES')) { + if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range + if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer + return @getdate($d); + } + } + return _adodb_getdate($d); +} + +/* +// generate $YRS table for _adodb_getdate() +function adodb_date_gentable($out=true) +{ + + for ($i=1970; $i >= 1600; $i-=10) { + $s = adodb_gmmktime(0,0,0,1,1,$i); + echo "$i => $s,
"; + } +} +adodb_date_gentable(); + +for ($i=1970; $i > 1500; $i--) { + +echo "
$i "; + adodb_date_test_date($i,1,1); +} + +*/ + + +$_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); +$_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); + +function adodb_validdate($y,$m,$d) +{ +global $_month_table_normal,$_month_table_leaf; + + if (_adodb_is_leap_year($y)) $marr = $_month_table_leaf; + else $marr = $_month_table_normal; + + if ($m > 12 || $m < 1) return false; + + if ($d > 31 || $d < 1) return false; + + if ($marr[$m] < $d) return false; + + if ($y < 1000 && $y > 3000) return false; + + return true; +} + +/** + Low-level function that returns the getdate() array. We have a special + $fast flag, which if set to true, will return fewer array values, + and is much faster as it does not calculate dow, etc. +*/ +function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) +{ +static $YRS; +global $_month_table_normal,$_month_table_leaf; + + $d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff_ts($origd)); + $_day_power = 86400; + $_hour_power = 3600; + $_min_power = 60; + + if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction + + $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); + $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); + + $d366 = $_day_power * 366; + $d365 = $_day_power * 365; + + if ($d < 0) { + + if (empty($YRS)) $YRS = array( + 1970 => 0, + 1960 => -315619200, + 1950 => -631152000, + 1940 => -946771200, + 1930 => -1262304000, + 1920 => -1577923200, + 1910 => -1893456000, + 1900 => -2208988800, + 1890 => -2524521600, + 1880 => -2840140800, + 1870 => -3155673600, + 1860 => -3471292800, + 1850 => -3786825600, + 1840 => -4102444800, + 1830 => -4417977600, + 1820 => -4733596800, + 1810 => -5049129600, + 1800 => -5364662400, + 1790 => -5680195200, + 1780 => -5995814400, + 1770 => -6311347200, + 1760 => -6626966400, + 1750 => -6942499200, + 1740 => -7258118400, + 1730 => -7573651200, + 1720 => -7889270400, + 1710 => -8204803200, + 1700 => -8520336000, + 1690 => -8835868800, + 1680 => -9151488000, + 1670 => -9467020800, + 1660 => -9782640000, + 1650 => -10098172800, + 1640 => -10413792000, + 1630 => -10729324800, + 1620 => -11044944000, + 1610 => -11360476800, + 1600 => -11676096000); + + if ($is_gmt) $origd = $d; + // The valid range of a 32bit signed timestamp is typically from + // Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT + // + + # old algorithm iterates through all years. new algorithm does it in + # 10 year blocks + + /* + # old algo + for ($a = 1970 ; --$a >= 0;) { + $lastd = $d; + + if ($leaf = _adodb_is_leap_year($a)) $d += $d366; + else $d += $d365; + + if ($d >= 0) { + $year = $a; + break; + } + } + */ + + $lastsecs = 0; + $lastyear = 1970; + foreach($YRS as $year => $secs) { + if ($d >= $secs) { + $a = $lastyear; + break; + } + $lastsecs = $secs; + $lastyear = $year; + } + + $d -= $lastsecs; + if (!isset($a)) $a = $lastyear; + + //echo ' yr=',$a,' ', $d,'.'; + + for (; --$a >= 0;) { + $lastd = $d; + + if ($leaf = _adodb_is_leap_year($a)) $d += $d366; + else $d += $d365; + + if ($d >= 0) { + $year = $a; + break; + } + } + /**/ + + $secsInYear = 86400 * ($leaf ? 366 : 365) + $lastd; + + $d = $lastd; + $mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal; + for ($a = 13 ; --$a > 0;) { + $lastd = $d; + $d += $mtab[$a] * $_day_power; + if ($d >= 0) { + $month = $a; + $ndays = $mtab[$a]; + break; + } + } + + $d = $lastd; + $day = $ndays + ceil(($d+1) / ($_day_power)); + + $d += ($ndays - $day+1)* $_day_power; + $hour = floor($d/$_hour_power); + + } else { + for ($a = 1970 ;; $a++) { + $lastd = $d; + + if ($leaf = _adodb_is_leap_year($a)) $d -= $d366; + else $d -= $d365; + if ($d < 0) { + $year = $a; + break; + } + } + $secsInYear = $lastd; + $d = $lastd; + $mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal; + for ($a = 1 ; $a <= 12; $a++) { + $lastd = $d; + $d -= $mtab[$a] * $_day_power; + if ($d < 0) { + $month = $a; + $ndays = $mtab[$a]; + break; + } + } + $d = $lastd; + $day = ceil(($d+1) / $_day_power); + $d = $d - ($day-1) * $_day_power; + $hour = floor($d /$_hour_power); + } + + $d -= $hour * $_hour_power; + $min = floor($d/$_min_power); + $secs = $d - $min * $_min_power; + if ($fast) { + return array( + 'seconds' => $secs, + 'minutes' => $min, + 'hours' => $hour, + 'mday' => $day, + 'mon' => $month, + 'year' => $year, + 'yday' => floor($secsInYear/$_day_power), + 'leap' => $leaf, + 'ndays' => $ndays + ); + } + + + $dow = adodb_dow($year,$month,$day); + + return array( + 'seconds' => $secs, + 'minutes' => $min, + 'hours' => $hour, + 'mday' => $day, + 'wday' => $dow, + 'mon' => $month, + 'year' => $year, + 'yday' => floor($secsInYear/$_day_power), + 'weekday' => gmdate('l',$_day_power*(3+$dow)), + 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)), + 0 => $origd + ); +} +/* + if ($isphp5) + $dates .= sprintf('%s%04d',($gmt<=0)?'+':'-',abs($gmt)/36); + else + $dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); + break;*/ +function adodb_tz_offset($gmt,$isphp5) +{ + $zhrs = abs($gmt)/3600; + $hrs = floor($zhrs); + if ($isphp5) + return sprintf('%s%02d%02d',($gmt<=0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); + else + return sprintf('%s%02d%02d',($gmt<0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); +} + + +function adodb_gmdate($fmt,$d=false) +{ + return adodb_date($fmt,$d,true); +} + +// accepts unix timestamp and iso date format in $d +function adodb_date2($fmt, $d=false, $is_gmt=false) +{ + if ($d !== false) { + if (!preg_match( + "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", + ($d), $rr)) return adodb_date($fmt,false,$is_gmt); + + if ($rr[1] <= 100 && $rr[2]<= 1) return adodb_date($fmt,false,$is_gmt); + + // h-m-s-MM-DD-YY + if (!isset($rr[5])) $d = adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1],false,$is_gmt); + else $d = @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1],false,$is_gmt); + } + + return adodb_date($fmt,$d,$is_gmt); +} + + +/** + Return formatted date based on timestamp $d +*/ +function adodb_date($fmt,$d=false,$is_gmt=false) +{ +static $daylight; +global $ADODB_DATETIME_CLASS; + + if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt); + if (!defined('ADODB_TEST_DATES')) { + if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range + if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer + return ($is_gmt)? @gmdate($fmt,$d): @date($fmt,$d); + + } + } + $_day_power = 86400; + + $arr = _adodb_getdate($d,true,$is_gmt); + + if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv'); + if ($daylight) adodb_daylight_sv($arr, $is_gmt); + + $year = $arr['year']; + $month = $arr['mon']; + $day = $arr['mday']; + $hour = $arr['hours']; + $min = $arr['minutes']; + $secs = $arr['seconds']; + + $max = strlen($fmt); + $dates = ''; + + $isphp5 = PHP_VERSION >= 5; + + /* + at this point, we have the following integer vars to manipulate: + $year, $month, $day, $hour, $min, $secs + */ + for ($i=0; $i < $max; $i++) { + switch($fmt[$i]) { + case 'T': + if ($ADODB_DATETIME_CLASS) { + $dt = new DateTime(); + $dt->SetDate($year,$month,$day); + $dates .= $dt->Format('T'); + } else + $dates .= date('T'); + break; + // YEAR + case 'L': $dates .= $arr['leap'] ? '1' : '0'; break; + case 'r': // Thu, 21 Dec 2000 16:01:07 +0200 + + // 4.3.11 uses '04 Jun 2004' + // 4.3.8 uses ' 4 Jun 2004' + $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', ' + . ($day<10?'0'.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' '; + + if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour; + + if ($min < 10) $dates .= ':0'.$min; else $dates .= ':'.$min; + + if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs; + + $gmt = adodb_get_gmt_diff($year,$month,$day); + + $dates .= ' '.adodb_tz_offset($gmt,$isphp5); + break; + + case 'Y': $dates .= $year; break; + case 'y': $dates .= substr($year,strlen($year)-2,2); break; + // MONTH + case 'm': if ($month<10) $dates .= '0'.$month; else $dates .= $month; break; + case 'Q': $dates .= ($month+3)>>2; break; + case 'n': $dates .= $month; break; + case 'M': $dates .= date('M',mktime(0,0,0,$month,2,1971)); break; + case 'F': $dates .= date('F',mktime(0,0,0,$month,2,1971)); break; + // DAY + case 't': $dates .= $arr['ndays']; break; + case 'z': $dates .= $arr['yday']; break; + case 'w': $dates .= adodb_dow($year,$month,$day); break; + case 'l': $dates .= gmdate('l',$_day_power*(3+adodb_dow($year,$month,$day))); break; + case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break; + case 'j': $dates .= $day; break; + case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break; + case 'S': + $d10 = $day % 10; + if ($d10 == 1) $dates .= 'st'; + else if ($d10 == 2 && $day != 12) $dates .= 'nd'; + else if ($d10 == 3) $dates .= 'rd'; + else $dates .= 'th'; + break; + + // HOUR + case 'Z': + $dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff($year,$month,$day); break; + case 'O': + $gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff($year,$month,$day); + + $dates .= adodb_tz_offset($gmt,$isphp5); + break; + + case 'H': + if ($hour < 10) $dates .= '0'.$hour; + else $dates .= $hour; + break; + case 'h': + if ($hour > 12) $hh = $hour - 12; + else { + if ($hour == 0) $hh = '12'; + else $hh = $hour; + } + + if ($hh < 10) $dates .= '0'.$hh; + else $dates .= $hh; + break; + + case 'G': + $dates .= $hour; + break; + + case 'g': + if ($hour > 12) $hh = $hour - 12; + else { + if ($hour == 0) $hh = '12'; + else $hh = $hour; + } + $dates .= $hh; + break; + // MINUTES + case 'i': if ($min < 10) $dates .= '0'.$min; else $dates .= $min; break; + // SECONDS + case 'U': $dates .= $d; break; + case 's': if ($secs < 10) $dates .= '0'.$secs; else $dates .= $secs; break; + // AM/PM + // Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM + case 'a': + if ($hour>=12) $dates .= 'pm'; + else $dates .= 'am'; + break; + case 'A': + if ($hour>=12) $dates .= 'PM'; + else $dates .= 'AM'; + break; + default: + $dates .= $fmt[$i]; break; + // ESCAPE + case "\\": + $i++; + if ($i < $max) $dates .= $fmt[$i]; + break; + } + } + return $dates; +} + +/** + Returns a timestamp given a GMT/UTC time. + Note that $is_dst is not implemented and is ignored. +*/ +function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false) +{ + return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true); +} + +/** + Return a timestamp given a local time. Originally by jackbbs. + Note that $is_dst is not implemented and is ignored. + + Not a very fast algorithm - O(n) operation. Could be optimized to O(1). +*/ +function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false) +{ + if (!defined('ADODB_TEST_DATES')) { + + if ($mon === false) { + return $is_gmt? @gmmktime($hr,$min,$sec): @mktime($hr,$min,$sec); + } + + // for windows, we don't check 1970 because with timezone differences, + // 1 Jan 1970 could generate negative timestamp, which is illegal + $usephpfns = (1971 < $year && $year < 2038 + || !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038) + ); + + + if ($usephpfns && ($year + $mon/12+$day/365.25+$hr/(24*365.25) >= 2038)) $usephpfns = false; + + if ($usephpfns) { + return $is_gmt ? + @gmmktime($hr,$min,$sec,$mon,$day,$year): + @mktime($hr,$min,$sec,$mon,$day,$year); + } + } + + $gmt_different = ($is_gmt) ? 0 : adodb_get_gmt_diff($year,$mon,$day); + + /* + # disabled because some people place large values in $sec. + # however we need it for $mon because we use an array... + $hr = intval($hr); + $min = intval($min); + $sec = intval($sec); + */ + $mon = intval($mon); + $day = intval($day); + $year = intval($year); + + + $year = adodb_year_digit_check($year); + + if ($mon > 12) { + $y = floor(($mon-1)/ 12); + $year += $y; + $mon -= $y*12; + } else if ($mon < 1) { + $y = ceil((1-$mon) / 12); + $year -= $y; + $mon += $y*12; + } + + $_day_power = 86400; + $_hour_power = 3600; + $_min_power = 60; + + $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); + $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); + + $_total_date = 0; + if ($year >= 1970) { + for ($a = 1970 ; $a <= $year; $a++) { + $leaf = _adodb_is_leap_year($a); + if ($leaf == true) { + $loop_table = $_month_table_leaf; + $_add_date = 366; + } else { + $loop_table = $_month_table_normal; + $_add_date = 365; + } + if ($a < $year) { + $_total_date += $_add_date; + } else { + for($b=1;$b<$mon;$b++) { + $_total_date += $loop_table[$b]; + } + } + } + $_total_date +=$day-1; + $ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different; + + } else { + for ($a = 1969 ; $a >= $year; $a--) { + $leaf = _adodb_is_leap_year($a); + if ($leaf == true) { + $loop_table = $_month_table_leaf; + $_add_date = 366; + } else { + $loop_table = $_month_table_normal; + $_add_date = 365; + } + if ($a > $year) { $_total_date += $_add_date; + } else { + for($b=12;$b>$mon;$b--) { + $_total_date += $loop_table[$b]; + } + } + } + $_total_date += $loop_table[$mon] - $day; + + $_day_time = $hr * $_hour_power + $min * $_min_power + $sec; + $_day_time = $_day_power - $_day_time; + $ret = -( $_total_date * $_day_power + $_day_time - $gmt_different); + if ($ret < -12220185600) $ret += 10*86400; // if earlier than 5 Oct 1582 - gregorian correction + else if ($ret < -12219321600) $ret = -12219321600; // if in limbo, reset to 15 Oct 1582. + } + //print " dmy=$day/$mon/$year $hr:$min:$sec => " .$ret; + return $ret; +} + +function adodb_gmstrftime($fmt, $ts=false) +{ + return adodb_strftime($fmt,$ts,true); +} + +// hack - convert to adodb_date +function adodb_strftime($fmt, $ts=false,$is_gmt=false) +{ +global $ADODB_DATE_LOCALE; + + if (!defined('ADODB_TEST_DATES')) { + if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range + if (!defined('ADODB_NO_NEGATIVE_TS') || $ts >= 0) // if windows, must be +ve integer + return ($is_gmt)? @gmstrftime($fmt,$ts): @strftime($fmt,$ts); + + } + } + + if (empty($ADODB_DATE_LOCALE)) { + /* + $tstr = strtoupper(gmstrftime('%c',31366800)); // 30 Dec 1970, 1 am + $sep = substr($tstr,2,1); + $hasAM = strrpos($tstr,'M') !== false; + */ + # see http://phplens.com/lens/lensforum/msgs.php?id=14865 for reasoning, and changelog for version 0.24 + $dstr = gmstrftime('%x',31366800); // 30 Dec 1970, 1 am + $sep = substr($dstr,2,1); + $tstr = strtoupper(gmstrftime('%X',31366800)); // 30 Dec 1970, 1 am + $hasAM = strrpos($tstr,'M') !== false; + + $ADODB_DATE_LOCALE = array(); + $ADODB_DATE_LOCALE[] = strncmp($tstr,'30',2) == 0 ? 'd'.$sep.'m'.$sep.'y' : 'm'.$sep.'d'.$sep.'y'; + $ADODB_DATE_LOCALE[] = ($hasAM) ? 'h:i:s a' : 'H:i:s'; + + } + $inpct = false; + $fmtdate = ''; + for ($i=0,$max = strlen($fmt); $i < $max; $i++) { + $ch = $fmt[$i]; + if ($ch == '%') { + if ($inpct) { + $fmtdate .= '%'; + $inpct = false; + } else + $inpct = true; + } else if ($inpct) { + + $inpct = false; + switch($ch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'E': + case 'O': + /* ignore format modifiers */ + $inpct = true; + break; + + case 'a': $fmtdate .= 'D'; break; + case 'A': $fmtdate .= 'l'; break; + case 'h': + case 'b': $fmtdate .= 'M'; break; + case 'B': $fmtdate .= 'F'; break; + case 'c': $fmtdate .= $ADODB_DATE_LOCALE[0].$ADODB_DATE_LOCALE[1]; break; + case 'C': $fmtdate .= '\C?'; break; // century + case 'd': $fmtdate .= 'd'; break; + case 'D': $fmtdate .= 'm/d/y'; break; + case 'e': $fmtdate .= 'j'; break; + case 'g': $fmtdate .= '\g?'; break; //? + case 'G': $fmtdate .= '\G?'; break; //? + case 'H': $fmtdate .= 'H'; break; + case 'I': $fmtdate .= 'h'; break; + case 'j': $fmtdate .= '?z'; $parsej = true; break; // wrong as j=1-based, z=0-basd + case 'm': $fmtdate .= 'm'; break; + case 'M': $fmtdate .= 'i'; break; + case 'n': $fmtdate .= "\n"; break; + case 'p': $fmtdate .= 'a'; break; + case 'r': $fmtdate .= 'h:i:s a'; break; + case 'R': $fmtdate .= 'H:i:s'; break; + case 'S': $fmtdate .= 's'; break; + case 't': $fmtdate .= "\t"; break; + case 'T': $fmtdate .= 'H:i:s'; break; + case 'u': $fmtdate .= '?u'; $parseu = true; break; // wrong strftime=1-based, date=0-based + case 'U': $fmtdate .= '?U'; $parseU = true; break;// wrong strftime=1-based, date=0-based + case 'x': $fmtdate .= $ADODB_DATE_LOCALE[0]; break; + case 'X': $fmtdate .= $ADODB_DATE_LOCALE[1]; break; + case 'w': $fmtdate .= '?w'; $parseu = true; break; // wrong strftime=1-based, date=0-based + case 'W': $fmtdate .= '?W'; $parseU = true; break;// wrong strftime=1-based, date=0-based + case 'y': $fmtdate .= 'y'; break; + case 'Y': $fmtdate .= 'Y'; break; + case 'Z': $fmtdate .= 'T'; break; + } + } else if (('A' <= ($ch) && ($ch) <= 'Z' ) || ('a' <= ($ch) && ($ch) <= 'z' )) + $fmtdate .= "\\".$ch; + else + $fmtdate .= $ch; + } + //echo "fmt=",$fmtdate,"
"; + if ($ts === false) $ts = time(); + $ret = adodb_date($fmtdate, $ts, $is_gmt); + return $ret; +} + + +?> \ No newline at end of file diff --git a/includes/adodb/adodb-xmlschema.inc.php b/includes/adodb/adodb-xmlschema.inc.php new file mode 100644 index 00000000..b2f0ddc5 --- /dev/null +++ b/includes/adodb/adodb-xmlschema.inc.php @@ -0,0 +1,2223 @@ +parent = $parent; + } + + /** + * XML Callback to process start elements + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + + } + + /** + * XML Callback to process CDATA elements + * + * @access private + */ + function _tag_cdata( &$parser, $cdata ) { + + } + + /** + * XML Callback to process end elements + * + * @access private + */ + function _tag_close( &$parser, $tag ) { + + } + + function create() { + return array(); + } + + /** + * Destroys the object + */ + function destroy() { + unset( $this ); + } + + /** + * Checks whether the specified RDBMS is supported by the current + * database object or its ranking ancestor. + * + * @param string $platform RDBMS platform name (from ADODB platform list). + * @return boolean TRUE if RDBMS is supported; otherwise returns FALSE. + */ + function supportedPlatform( $platform = NULL ) { + return is_object( $this->parent ) ? $this->parent->supportedPlatform( $platform ) : TRUE; + } + + /** + * Returns the prefix set by the ranking ancestor of the database object. + * + * @param string $name Prefix string. + * @return string Prefix. + */ + function prefix( $name = '' ) { + return is_object( $this->parent ) ? $this->parent->prefix( $name ) : $name; + } + + /** + * Extracts a field ID from the specified field. + * + * @param string $field Field. + * @return string Field ID. + */ + function FieldID( $field ) { + return strtoupper( preg_replace( '/^`(.+)`$/', '$1', $field ) ); + } +} + +/** +* Creates a table object in ADOdb's datadict format +* +* This class stores information about a database table. As charactaristics +* of the table are loaded from the external source, methods and properties +* of this class are used to build up the table description in ADOdb's +* datadict format. +* +* @package axmls +* @access private +*/ +class dbTable extends dbObject { + + /** + * @var string Table name + */ + var $name; + + /** + * @var array Field specifier: Meta-information about each field + */ + var $fields = array(); + + /** + * @var array List of table indexes. + */ + var $indexes = array(); + + /** + * @var array Table options: Table-level options + */ + var $opts = array(); + + /** + * @var string Field index: Keeps track of which field is currently being processed + */ + var $current_field; + + /** + * @var boolean Mark table for destruction + * @access private + */ + var $drop_table; + + /** + * @var boolean Mark field for destruction (not yet implemented) + * @access private + */ + var $drop_field = array(); + + /** + * Iniitializes a new table object. + * + * @param string $prefix DB Object prefix + * @param array $attributes Array of table attributes. + */ + function dbTable( &$parent, $attributes = NULL ) { + $this->parent = $parent; + $this->name = $this->prefix($attributes['NAME']); + } + + /** + * XML Callback to process start elements. Elements currently + * processed are: INDEX, DROP, FIELD, KEY, NOTNULL, AUTOINCREMENT & DEFAULT. + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + $this->currentElement = strtoupper( $tag ); + + switch( $this->currentElement ) { + case 'INDEX': + if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) { + xml_set_object( $parser, $this->addIndex( $attributes ) ); + } + break; + case 'DATA': + if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) { + xml_set_object( $parser, $this->addData( $attributes ) ); + } + break; + case 'DROP': + $this->drop(); + break; + case 'FIELD': + // Add a field + $fieldName = $attributes['NAME']; + $fieldType = $attributes['TYPE']; + $fieldSize = isset( $attributes['SIZE'] ) ? $attributes['SIZE'] : NULL; + $fieldOpts = isset( $attributes['OPTS'] ) ? $attributes['OPTS'] : NULL; + + $this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts ); + break; + case 'KEY': + case 'NOTNULL': + case 'AUTOINCREMENT': + // Add a field option + $this->addFieldOpt( $this->current_field, $this->currentElement ); + break; + case 'DEFAULT': + // Add a field option to the table object + + // Work around ADOdb datadict issue that misinterprets empty strings. + if( $attributes['VALUE'] == '' ) { + $attributes['VALUE'] = " '' "; + } + + $this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] ); + break; + case 'DEFDATE': + case 'DEFTIMESTAMP': + // Add a field option to the table object + $this->addFieldOpt( $this->current_field, $this->currentElement ); + break; + default: + // print_r( array( $tag, $attributes ) ); + } + } + + /** + * XML Callback to process CDATA elements + * + * @access private + */ + function _tag_cdata( &$parser, $cdata ) { + switch( $this->currentElement ) { + // Table constraint + case 'CONSTRAINT': + if( isset( $this->current_field ) ) { + $this->addFieldOpt( $this->current_field, $this->currentElement, $cdata ); + } else { + $this->addTableOpt( $cdata ); + } + break; + // Table option + case 'OPT': + $this->addTableOpt( $cdata ); + break; + default: + + } + } + + /** + * XML Callback to process end elements + * + * @access private + */ + function _tag_close( &$parser, $tag ) { + $this->currentElement = ''; + + switch( strtoupper( $tag ) ) { + case 'TABLE': + $this->parent->addSQL( $this->create( $this->parent ) ); + xml_set_object( $parser, $this->parent ); + $this->destroy(); + break; + case 'FIELD': + unset($this->current_field); + break; + + } + } + + /** + * Adds an index to a table object + * + * @param array $attributes Index attributes + * @return object dbIndex object + */ + function addIndex( $attributes ) { + $name = strtoupper( $attributes['NAME'] ); + $this->indexes[$name] = new dbIndex( $this, $attributes ); + return $this->indexes[$name]; + } + + /** + * Adds data to a table object + * + * @param array $attributes Data attributes + * @return object dbData object + */ + function addData( $attributes ) { + if( !isset( $this->data ) ) { + $this->data = new dbData( $this, $attributes ); + } + return $this->data; + } + + /** + * Adds a field to a table object + * + * $name is the name of the table to which the field should be added. + * $type is an ADODB datadict field type. The following field types + * are supported as of ADODB 3.40: + * - C: varchar + * - X: CLOB (character large object) or largest varchar size + * if CLOB is not supported + * - C2: Multibyte varchar + * - X2: Multibyte CLOB + * - B: BLOB (binary large object) + * - D: Date (some databases do not support this, and we return a datetime type) + * - T: Datetime or Timestamp + * - L: Integer field suitable for storing booleans (0 or 1) + * - I: Integer (mapped to I4) + * - I1: 1-byte integer + * - I2: 2-byte integer + * - I4: 4-byte integer + * - I8: 8-byte integer + * - F: Floating point number + * - N: Numeric or decimal number + * + * @param string $name Name of the table to which the field will be added. + * @param string $type ADODB datadict field type. + * @param string $size Field size + * @param array $opts Field options array + * @return array Field specifier array + */ + function addField( $name, $type, $size = NULL, $opts = NULL ) { + $field_id = $this->FieldID( $name ); + + // Set the field index so we know where we are + $this->current_field = $field_id; + + // Set the field name (required) + $this->fields[$field_id]['NAME'] = $name; + + // Set the field type (required) + $this->fields[$field_id]['TYPE'] = $type; + + // Set the field size (optional) + if( isset( $size ) ) { + $this->fields[$field_id]['SIZE'] = $size; + } + + // Set the field options + if( isset( $opts ) ) { + $this->fields[$field_id]['OPTS'][] = $opts; + } + } + + /** + * Adds a field option to the current field specifier + * + * This method adds a field option allowed by the ADOdb datadict + * and appends it to the given field. + * + * @param string $field Field name + * @param string $opt ADOdb field option + * @param mixed $value Field option value + * @return array Field specifier array + */ + function addFieldOpt( $field, $opt, $value = NULL ) { + if( !isset( $value ) ) { + $this->fields[$this->FieldID( $field )]['OPTS'][] = $opt; + // Add the option and value + } else { + $this->fields[$this->FieldID( $field )]['OPTS'][] = array( $opt => $value ); + } + } + + /** + * Adds an option to the table + * + * This method takes a comma-separated list of table-level options + * and appends them to the table object. + * + * @param string $opt Table option + * @return array Options + */ + function addTableOpt( $opt ) { + if(isset($this->currentPlatform)) { + $this->opts[$this->parent->db->databaseType] = $opt; + } + return $this->opts; + } + + + /** + * Generates the SQL that will create the table in the database + * + * @param object $xmls adoSchema object + * @return array Array containing table creation SQL + */ + function create( &$xmls ) { + $sql = array(); + + // drop any existing indexes + if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) ) { + foreach( $legacy_indexes as $index => $index_details ) { + $sql[] = $xmls->dict->DropIndexSQL( $index, $this->name ); + } + } + + // remove fields to be dropped from table object + foreach( $this->drop_field as $field ) { + unset( $this->fields[$field] ); + } + + // if table exists + if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) ) { + // drop table + if( $this->drop_table ) { + $sql[] = $xmls->dict->DropTableSQL( $this->name ); + + return $sql; + } + + // drop any existing fields not in schema + foreach( $legacy_fields as $field_id => $field ) { + if( !isset( $this->fields[$field_id] ) ) { + $sql[] = $xmls->dict->DropColumnSQL( $this->name, '`'.$field->name.'`' ); + } + } + // if table doesn't exist + } else { + if( $this->drop_table ) { + return $sql; + } + + $legacy_fields = array(); + } + + // Loop through the field specifier array, building the associative array for the field options + $fldarray = array(); + + foreach( $this->fields as $field_id => $finfo ) { + // Set an empty size if it isn't supplied + if( !isset( $finfo['SIZE'] ) ) { + $finfo['SIZE'] = ''; + } + + // Initialize the field array with the type and size + $fldarray[$field_id] = array( + 'NAME' => $finfo['NAME'], + 'TYPE' => $finfo['TYPE'], + 'SIZE' => $finfo['SIZE'] + ); + + // Loop through the options array and add the field options. + if( isset( $finfo['OPTS'] ) ) { + foreach( $finfo['OPTS'] as $opt ) { + // Option has an argument. + if( is_array( $opt ) ) { + $key = key( $opt ); + $value = $opt[key( $opt )]; + @$fldarray[$field_id][$key] .= $value; + // Option doesn't have arguments + } else { + $fldarray[$field_id][$opt] = $opt; + } + } + } + } + + if( empty( $legacy_fields ) ) { + // Create the new table + $sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts ); + logMsg( end( $sql ), 'Generated CreateTableSQL' ); + } else { + // Upgrade an existing table + logMsg( "Upgrading {$this->name} using '{$xmls->upgrade}'" ); + switch( $xmls->upgrade ) { + // Use ChangeTableSQL + case 'ALTER': + logMsg( 'Generated ChangeTableSQL (ALTERing table)' ); + $sql[] = $xmls->dict->ChangeTableSQL( $this->name, $fldarray, $this->opts ); + break; + case 'REPLACE': + logMsg( 'Doing upgrade REPLACE (testing)' ); + $sql[] = $xmls->dict->DropTableSQL( $this->name ); + $sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts ); + break; + // ignore table + default: + return array(); + } + } + + foreach( $this->indexes as $index ) { + $sql[] = $index->create( $xmls ); + } + + if( isset( $this->data ) ) { + $sql[] = $this->data->create( $xmls ); + } + + return $sql; + } + + /** + * Marks a field or table for destruction + */ + function drop() { + if( isset( $this->current_field ) ) { + // Drop the current field + logMsg( "Dropping field '{$this->current_field}' from table '{$this->name}'" ); + // $this->drop_field[$this->current_field] = $xmls->dict->DropColumnSQL( $this->name, $this->current_field ); + $this->drop_field[$this->current_field] = $this->current_field; + } else { + // Drop the current table + logMsg( "Dropping table '{$this->name}'" ); + // $this->drop_table = $xmls->dict->DropTableSQL( $this->name ); + $this->drop_table = TRUE; + } + } +} + +/** +* Creates an index object in ADOdb's datadict format +* +* This class stores information about a database index. As charactaristics +* of the index are loaded from the external source, methods and properties +* of this class are used to build up the index description in ADOdb's +* datadict format. +* +* @package axmls +* @access private +*/ +class dbIndex extends dbObject { + + /** + * @var string Index name + */ + var $name; + + /** + * @var array Index options: Index-level options + */ + var $opts = array(); + + /** + * @var array Indexed fields: Table columns included in this index + */ + var $columns = array(); + + /** + * @var boolean Mark index for destruction + * @access private + */ + var $drop = FALSE; + + /** + * Initializes the new dbIndex object. + * + * @param object $parent Parent object + * @param array $attributes Attributes + * + * @internal + */ + function dbIndex( &$parent, $attributes = NULL ) { + $this->parent = $parent; + + $this->name = $this->prefix ($attributes['NAME']); + } + + /** + * XML Callback to process start elements + * + * Processes XML opening tags. + * Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH. + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + $this->currentElement = strtoupper( $tag ); + + switch( $this->currentElement ) { + case 'DROP': + $this->drop(); + break; + case 'CLUSTERED': + case 'BITMAP': + case 'UNIQUE': + case 'FULLTEXT': + case 'HASH': + // Add index Option + $this->addIndexOpt( $this->currentElement ); + break; + default: + // print_r( array( $tag, $attributes ) ); + } + } + + /** + * XML Callback to process CDATA elements + * + * Processes XML cdata. + * + * @access private + */ + function _tag_cdata( &$parser, $cdata ) { + switch( $this->currentElement ) { + // Index field name + case 'COL': + $this->addField( $cdata ); + break; + default: + + } + } + + /** + * XML Callback to process end elements + * + * @access private + */ + function _tag_close( &$parser, $tag ) { + $this->currentElement = ''; + + switch( strtoupper( $tag ) ) { + case 'INDEX': + xml_set_object( $parser, $this->parent ); + break; + } + } + + /** + * Adds a field to the index + * + * @param string $name Field name + * @return string Field list + */ + function addField( $name ) { + $this->columns[$this->FieldID( $name )] = $name; + + // Return the field list + return $this->columns; + } + + /** + * Adds options to the index + * + * @param string $opt Comma-separated list of index options. + * @return string Option list + */ + function addIndexOpt( $opt ) { + $this->opts[] = $opt; + + // Return the options list + return $this->opts; + } + + /** + * Generates the SQL that will create the index in the database + * + * @param object $xmls adoSchema object + * @return array Array containing index creation SQL + */ + function create( &$xmls ) { + if( $this->drop ) { + return NULL; + } + + // eliminate any columns that aren't in the table + foreach( $this->columns as $id => $col ) { + if( !isset( $this->parent->fields[$id] ) ) { + unset( $this->columns[$id] ); + } + } + + return $xmls->dict->CreateIndexSQL( $this->name, $this->parent->name, $this->columns, $this->opts ); + } + + /** + * Marks an index for destruction + */ + function drop() { + $this->drop = TRUE; + } +} + +/** +* Creates a data object in ADOdb's datadict format +* +* This class stores information about table data. +* +* @package axmls +* @access private +*/ +class dbData extends dbObject { + + var $data = array(); + + var $row; + + /** + * Initializes the new dbIndex object. + * + * @param object $parent Parent object + * @param array $attributes Attributes + * + * @internal + */ + function dbData( &$parent, $attributes = NULL ) { + $this->parent = $parent; + } + + /** + * XML Callback to process start elements + * + * Processes XML opening tags. + * Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH. + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + $this->currentElement = strtoupper( $tag ); + + switch( $this->currentElement ) { + case 'ROW': + $this->row = count( $this->data ); + $this->data[$this->row] = array(); + break; + case 'F': + $this->addField($attributes); + default: + // print_r( array( $tag, $attributes ) ); + } + } + + /** + * XML Callback to process CDATA elements + * + * Processes XML cdata. + * + * @access private + */ + function _tag_cdata( &$parser, $cdata ) { + switch( $this->currentElement ) { + // Index field name + case 'F': + $this->addData( $cdata ); + break; + default: + + } + } + + /** + * XML Callback to process end elements + * + * @access private + */ + function _tag_close( &$parser, $tag ) { + $this->currentElement = ''; + + switch( strtoupper( $tag ) ) { + case 'DATA': + xml_set_object( $parser, $this->parent ); + break; + } + } + + /** + * Adds a field to the index + * + * @param string $name Field name + * @return string Field list + */ + function addField( $attributes ) { + if( isset( $attributes['NAME'] ) ) { + $name = $attributes['NAME']; + } else { + $name = count($this->data[$this->row]); + } + + // Set the field index so we know where we are + $this->current_field = $this->FieldID( $name ); + } + + /** + * Adds options to the index + * + * @param string $opt Comma-separated list of index options. + * @return string Option list + */ + function addData( $cdata ) { + if( !isset( $this->data[$this->row] ) ) { + $this->data[$this->row] = array(); + } + + if( !isset( $this->data[$this->row][$this->current_field] ) ) { + $this->data[$this->row][$this->current_field] = ''; + } + + $this->data[$this->row][$this->current_field] .= $cdata; + } + + /** + * Generates the SQL that will create the index in the database + * + * @param object $xmls adoSchema object + * @return array Array containing index creation SQL + */ + function create( &$xmls ) { + $table = $xmls->dict->TableName($this->parent->name); + $table_field_count = count($this->parent->fields); + $sql = array(); + + // eliminate any columns that aren't in the table + foreach( $this->data as $row ) { + $table_fields = $this->parent->fields; + $fields = array(); + + foreach( $row as $field_id => $field_data ) { + if( !array_key_exists( $field_id, $table_fields ) ) { + if( is_numeric( $field_id ) ) { + $field_id = reset( array_keys( $table_fields ) ); + } else { + continue; + } + } + + $name = $table_fields[$field_id]['NAME']; + + switch( $table_fields[$field_id]['TYPE'] ) { + case 'C': + case 'C2': + case 'X': + case 'X2': + $fields[$name] = $xmls->db->qstr( $field_data ); + break; + case 'I': + case 'I1': + case 'I2': + case 'I4': + case 'I8': + $fields[$name] = intval($field_data); + break; + default: + $fields[$name] = $field_data; + } + + unset($table_fields[$field_id]); + } + + // check that at least 1 column is specified + if( empty( $fields ) ) { + continue; + } + + // check that no required columns are missing + if( count( $fields ) < $table_field_count ) { + foreach( $table_fields as $field ) { + if (isset( $field['OPTS'] )) + if( ( in_array( 'NOTNULL', $field['OPTS'] ) || in_array( 'KEY', $field['OPTS'] ) ) && !in_array( 'AUTOINCREMENT', $field['OPTS'] ) ) { + continue(2); + } + } + } + + $sql[] = 'INSERT INTO '. $table .' ('. implode( ',', array_keys( $fields ) ) .') VALUES ('. implode( ',', $fields ) .')'; + } + + return $sql; + } +} + +/** +* Creates the SQL to execute a list of provided SQL queries +* +* @package axmls +* @access private +*/ +class dbQuerySet extends dbObject { + + /** + * @var array List of SQL queries + */ + var $queries = array(); + + /** + * @var string String used to build of a query line by line + */ + var $query; + + /** + * @var string Query prefix key + */ + var $prefixKey = ''; + + /** + * @var boolean Auto prefix enable (TRUE) + */ + var $prefixMethod = 'AUTO'; + + /** + * Initializes the query set. + * + * @param object $parent Parent object + * @param array $attributes Attributes + */ + function dbQuerySet( &$parent, $attributes = NULL ) { + $this->parent = $parent; + + // Overrides the manual prefix key + if( isset( $attributes['KEY'] ) ) { + $this->prefixKey = $attributes['KEY']; + } + + $prefixMethod = isset( $attributes['PREFIXMETHOD'] ) ? strtoupper( trim( $attributes['PREFIXMETHOD'] ) ) : ''; + + // Enables or disables automatic prefix prepending + switch( $prefixMethod ) { + case 'AUTO': + $this->prefixMethod = 'AUTO'; + break; + case 'MANUAL': + $this->prefixMethod = 'MANUAL'; + break; + case 'NONE': + $this->prefixMethod = 'NONE'; + break; + } + } + + /** + * XML Callback to process start elements. Elements currently + * processed are: QUERY. + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + $this->currentElement = strtoupper( $tag ); + + switch( $this->currentElement ) { + case 'QUERY': + // Create a new query in a SQL queryset. + // Ignore this query set if a platform is specified and it's different than the + // current connection platform. + if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) { + $this->newQuery(); + } else { + $this->discardQuery(); + } + break; + default: + // print_r( array( $tag, $attributes ) ); + } + } + + /** + * XML Callback to process CDATA elements + */ + function _tag_cdata( &$parser, $cdata ) { + switch( $this->currentElement ) { + // Line of queryset SQL data + case 'QUERY': + $this->buildQuery( $cdata ); + break; + default: + + } + } + + /** + * XML Callback to process end elements + * + * @access private + */ + function _tag_close( &$parser, $tag ) { + $this->currentElement = ''; + + switch( strtoupper( $tag ) ) { + case 'QUERY': + // Add the finished query to the open query set. + $this->addQuery(); + break; + case 'SQL': + $this->parent->addSQL( $this->create( $this->parent ) ); + xml_set_object( $parser, $this->parent ); + $this->destroy(); + break; + default: + + } + } + + /** + * Re-initializes the query. + * + * @return boolean TRUE + */ + function newQuery() { + $this->query = ''; + + return TRUE; + } + + /** + * Discards the existing query. + * + * @return boolean TRUE + */ + function discardQuery() { + unset( $this->query ); + + return TRUE; + } + + /** + * Appends a line to a query that is being built line by line + * + * @param string $data Line of SQL data or NULL to initialize a new query + * @return string SQL query string. + */ + function buildQuery( $sql = NULL ) { + if( !isset( $this->query ) OR empty( $sql ) ) { + return FALSE; + } + + $this->query .= $sql; + + return $this->query; + } + + /** + * Adds a completed query to the query list + * + * @return string SQL of added query + */ + function addQuery() { + if( !isset( $this->query ) ) { + return FALSE; + } + + $this->queries[] = $return = trim($this->query); + + unset( $this->query ); + + return $return; + } + + /** + * Creates and returns the current query set + * + * @param object $xmls adoSchema object + * @return array Query set + */ + function create( &$xmls ) { + foreach( $this->queries as $id => $query ) { + switch( $this->prefixMethod ) { + case 'AUTO': + // Enable auto prefix replacement + + // Process object prefix. + // Evaluate SQL statements to prepend prefix to objects + $query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix ); + $query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix ); + $query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix ); + + // SELECT statements aren't working yet + #$data = preg_replace( '/(?ias)(^\s*SELECT\s+.*\s+FROM)\s+(\W\s*,?\s*)+((?i)\s+WHERE.*$)/', "\1 $prefix\2 \3", $data ); + + case 'MANUAL': + // If prefixKey is set and has a value then we use it to override the default constant XMLS_PREFIX. + // If prefixKey is not set, we use the default constant XMLS_PREFIX + if( isset( $this->prefixKey ) AND( $this->prefixKey !== '' ) ) { + // Enable prefix override + $query = str_replace( $this->prefixKey, $xmls->objectPrefix, $query ); + } else { + // Use default replacement + $query = str_replace( XMLS_PREFIX , $xmls->objectPrefix, $query ); + } + } + + $this->queries[$id] = trim( $query ); + } + + // Return the query set array + return $this->queries; + } + + /** + * Rebuilds the query with the prefix attached to any objects + * + * @param string $regex Regex used to add prefix + * @param string $query SQL query string + * @param string $prefix Prefix to be appended to tables, indices, etc. + * @return string Prefixed SQL query string. + */ + function prefixQuery( $regex, $query, $prefix = NULL ) { + if( !isset( $prefix ) ) { + return $query; + } + + if( preg_match( $regex, $query, $match ) ) { + $preamble = $match[1]; + $postamble = $match[5]; + $objectList = explode( ',', $match[3] ); + // $prefix = $prefix . '_'; + + $prefixedList = ''; + + foreach( $objectList as $object ) { + if( $prefixedList !== '' ) { + $prefixedList .= ', '; + } + + $prefixedList .= $prefix . trim( $object ); + } + + $query = $preamble . ' ' . $prefixedList . ' ' . $postamble; + } + + return $query; + } +} + +/** +* Loads and parses an XML file, creating an array of "ready-to-run" SQL statements +* +* This class is used to load and parse the XML file, to create an array of SQL statements +* that can be used to build a database, and to build the database using the SQL array. +* +* @tutorial getting_started.pkg +* +* @author Richard Tango-Lowy & Dan Cech +* @version $Revision: 1.12 $ +* +* @package axmls +*/ +class adoSchema { + + /** + * @var array Array containing SQL queries to generate all objects + * @access private + */ + var $sqlArray; + + /** + * @var object ADOdb connection object + * @access private + */ + var $db; + + /** + * @var object ADOdb Data Dictionary + * @access private + */ + var $dict; + + /** + * @var string Current XML element + * @access private + */ + var $currentElement = ''; + + /** + * @var string If set (to 'ALTER' or 'REPLACE'), upgrade an existing database + * @access private + */ + var $upgrade = ''; + + /** + * @var string Optional object prefix + * @access private + */ + var $objectPrefix = ''; + + /** + * @var long Original Magic Quotes Runtime value + * @access private + */ + var $mgq; + + /** + * @var long System debug + * @access private + */ + var $debug; + + /** + * @var string Regular expression to find schema version + * @access private + */ + var $versionRegex = '//'; + + /** + * @var string Current schema version + * @access private + */ + var $schemaVersion; + + /** + * @var int Success of last Schema execution + */ + var $success; + + /** + * @var bool Execute SQL inline as it is generated + */ + var $executeInline; + + /** + * @var bool Continue SQL execution if errors occur + */ + var $continueOnError; + + /** + * Creates an adoSchema object + * + * Creating an adoSchema object is the first step in processing an XML schema. + * The only parameter is an ADOdb database connection object, which must already + * have been created. + * + * @param object $db ADOdb database connection object. + */ + function adoSchema( &$db ) { + // Initialize the environment + $this->mgq = get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + + $this->db = $db; + $this->debug = $this->db->debug; + $this->dict = NewDataDictionary( $this->db ); + $this->sqlArray = array(); + $this->schemaVersion = XMLS_SCHEMA_VERSION; + $this->executeInline( XMLS_EXECUTE_INLINE ); + $this->continueOnError( XMLS_CONTINUE_ON_ERROR ); + $this->setUpgradeMethod(); + } + + /** + * Sets the method to be used for upgrading an existing database + * + * Use this method to specify how existing database objects should be upgraded. + * The method option can be set to ALTER, REPLACE, BEST, or NONE. ALTER attempts to + * alter each database object directly, REPLACE attempts to rebuild each object + * from scratch, BEST attempts to determine the best upgrade method for each + * object, and NONE disables upgrading. + * + * This method is not yet used by AXMLS, but exists for backward compatibility. + * The ALTER method is automatically assumed when the adoSchema object is + * instantiated; other upgrade methods are not currently supported. + * + * @param string $method Upgrade method (ALTER|REPLACE|BEST|NONE) + * @returns string Upgrade method used + */ + function SetUpgradeMethod( $method = '' ) { + if( !is_string( $method ) ) { + return FALSE; + } + + $method = strtoupper( $method ); + + // Handle the upgrade methods + switch( $method ) { + case 'ALTER': + $this->upgrade = $method; + break; + case 'REPLACE': + $this->upgrade = $method; + break; + case 'BEST': + $this->upgrade = 'ALTER'; + break; + case 'NONE': + $this->upgrade = 'NONE'; + break; + default: + // Use default if no legitimate method is passed. + $this->upgrade = XMLS_DEFAULT_UPGRADE_METHOD; + } + + return $this->upgrade; + } + + /** + * Enables/disables inline SQL execution. + * + * Call this method to enable or disable inline execution of the schema. If the mode is set to TRUE (inline execution), + * AXMLS applies the SQL to the database immediately as each schema entity is parsed. If the mode + * is set to FALSE (post execution), AXMLS parses the entire schema and you will need to call adoSchema::ExecuteSchema() + * to apply the schema to the database. + * + * @param bool $mode execute + * @return bool current execution mode + * + * @see ParseSchema(), ExecuteSchema() + */ + function ExecuteInline( $mode = NULL ) { + if( is_bool( $mode ) ) { + $this->executeInline = $mode; + } + + return $this->executeInline; + } + + /** + * Enables/disables SQL continue on error. + * + * Call this method to enable or disable continuation of SQL execution if an error occurs. + * If the mode is set to TRUE (continue), AXMLS will continue to apply SQL to the database, even if an error occurs. + * If the mode is set to FALSE (halt), AXMLS will halt execution of generated sql if an error occurs, though parsing + * of the schema will continue. + * + * @param bool $mode execute + * @return bool current continueOnError mode + * + * @see addSQL(), ExecuteSchema() + */ + function ContinueOnError( $mode = NULL ) { + if( is_bool( $mode ) ) { + $this->continueOnError = $mode; + } + + return $this->continueOnError; + } + + /** + * Loads an XML schema from a file and converts it to SQL. + * + * Call this method to load the specified schema (see the DTD for the proper format) from + * the filesystem and generate the SQL necessary to create the database described. + * @see ParseSchemaString() + * + * @param string $file Name of XML schema file. + * @param bool $returnSchema Return schema rather than parsing. + * @return array Array of SQL queries, ready to execute + */ + function ParseSchema( $filename, $returnSchema = FALSE ) { + return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema ); + } + + /** + * Loads an XML schema from a file and converts it to SQL. + * + * Call this method to load the specified schema from a file (see the DTD for the proper format) + * and generate the SQL necessary to create the database described by the schema. + * + * @param string $file Name of XML schema file. + * @param bool $returnSchema Return schema rather than parsing. + * @return array Array of SQL queries, ready to execute. + * + * @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString() + * @see ParseSchema(), ParseSchemaString() + */ + function ParseSchemaFile( $filename, $returnSchema = FALSE ) { + // Open the file + if( !($fp = fopen( $filename, 'r' )) ) { + // die( 'Unable to open file' ); + return FALSE; + } + + // do version detection here + if( $this->SchemaFileVersion( $filename ) != $this->schemaVersion ) { + return FALSE; + } + + if ( $returnSchema ) + { + $xmlstring = ''; + while( $data = fread( $fp, 100000 ) ) { + $xmlstring .= $data; + } + return $xmlstring; + } + + $this->success = 2; + + $xmlParser = $this->create_parser(); + + // Process the file + while( $data = fread( $fp, 4096 ) ) { + if( !xml_parse( $xmlParser, $data, feof( $fp ) ) ) { + die( sprintf( + "XML error: %s at line %d", + xml_error_string( xml_get_error_code( $xmlParser) ), + xml_get_current_line_number( $xmlParser) + ) ); + } + } + + xml_parser_free( $xmlParser ); + + return $this->sqlArray; + } + + /** + * Converts an XML schema string to SQL. + * + * Call this method to parse a string containing an XML schema (see the DTD for the proper format) + * and generate the SQL necessary to create the database described by the schema. + * @see ParseSchema() + * + * @param string $xmlstring XML schema string. + * @param bool $returnSchema Return schema rather than parsing. + * @return array Array of SQL queries, ready to execute. + */ + function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) { + if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) { + return FALSE; + } + + // do version detection here + if( $this->SchemaStringVersion( $xmlstring ) != $this->schemaVersion ) { + return FALSE; + } + + if ( $returnSchema ) + { + return $xmlstring; + } + + $this->success = 2; + + $xmlParser = $this->create_parser(); + + if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) { + die( sprintf( + "XML error: %s at line %d", + xml_error_string( xml_get_error_code( $xmlParser) ), + xml_get_current_line_number( $xmlParser) + ) ); + } + + xml_parser_free( $xmlParser ); + + return $this->sqlArray; + } + + /** + * Loads an XML schema from a file and converts it to uninstallation SQL. + * + * Call this method to load the specified schema (see the DTD for the proper format) from + * the filesystem and generate the SQL necessary to remove the database described. + * @see RemoveSchemaString() + * + * @param string $file Name of XML schema file. + * @param bool $returnSchema Return schema rather than parsing. + * @return array Array of SQL queries, ready to execute + */ + function RemoveSchema( $filename, $returnSchema = FALSE ) { + return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema ); + } + + /** + * Converts an XML schema string to uninstallation SQL. + * + * Call this method to parse a string containing an XML schema (see the DTD for the proper format) + * and generate the SQL necessary to uninstall the database described by the schema. + * @see RemoveSchema() + * + * @param string $schema XML schema string. + * @param bool $returnSchema Return schema rather than parsing. + * @return array Array of SQL queries, ready to execute. + */ + function RemoveSchemaString( $schema, $returnSchema = FALSE ) { + + // grab current version + if( !( $version = $this->SchemaStringVersion( $schema ) ) ) { + return FALSE; + } + + return $this->ParseSchemaString( $this->TransformSchema( $schema, 'remove-' . $version), $returnSchema ); + } + + /** + * Applies the current XML schema to the database (post execution). + * + * Call this method to apply the current schema (generally created by calling + * ParseSchema() or ParseSchemaString() ) to the database (creating the tables, indexes, + * and executing other SQL specified in the schema) after parsing. + * @see ParseSchema(), ParseSchemaString(), ExecuteInline() + * + * @param array $sqlArray Array of SQL statements that will be applied rather than + * the current schema. + * @param boolean $continueOnErr Continue to apply the schema even if an error occurs. + * @returns integer 0 if failure, 1 if errors, 2 if successful. + */ + function ExecuteSchema( $sqlArray = NULL, $continueOnErr = NULL ) { + if( !is_bool( $continueOnErr ) ) { + $continueOnErr = $this->ContinueOnError(); + } + + if( !isset( $sqlArray ) ) { + $sqlArray = $this->sqlArray; + } + + if( !is_array( $sqlArray ) ) { + $this->success = 0; + } else { + $this->success = $this->dict->ExecuteSQLArray( $sqlArray, $continueOnErr ); + } + + return $this->success; + } + + /** + * Returns the current SQL array. + * + * Call this method to fetch the array of SQL queries resulting from + * ParseSchema() or ParseSchemaString(). + * + * @param string $format Format: HTML, TEXT, or NONE (PHP array) + * @return array Array of SQL statements or FALSE if an error occurs + */ + function PrintSQL( $format = 'NONE' ) { + $sqlArray = null; + return $this->getSQL( $format, $sqlArray ); + } + + /** + * Saves the current SQL array to the local filesystem as a list of SQL queries. + * + * Call this method to save the array of SQL queries (generally resulting from a + * parsed XML schema) to the filesystem. + * + * @param string $filename Path and name where the file should be saved. + * @return boolean TRUE if save is successful, else FALSE. + */ + function SaveSQL( $filename = './schema.sql' ) { + + if( !isset( $sqlArray ) ) { + $sqlArray = $this->sqlArray; + } + if( !isset( $sqlArray ) ) { + return FALSE; + } + + $fp = fopen( $filename, "w" ); + + foreach( $sqlArray as $key => $query ) { + fwrite( $fp, $query . ";\n" ); + } + fclose( $fp ); + } + + /** + * Create an xml parser + * + * @return object PHP XML parser object + * + * @access private + */ + function create_parser() { + // Create the parser + $xmlParser = xml_parser_create(); + xml_set_object( $xmlParser, $this ); + + // Initialize the XML callback functions + xml_set_element_handler( $xmlParser, '_tag_open', '_tag_close' ); + xml_set_character_data_handler( $xmlParser, '_tag_cdata' ); + + return $xmlParser; + } + + /** + * XML Callback to process start elements + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + switch( strtoupper( $tag ) ) { + case 'TABLE': + $this->obj = new dbTable( $this, $attributes ); + xml_set_object( $parser, $this->obj ); + break; + case 'SQL': + if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) { + $this->obj = new dbQuerySet( $this, $attributes ); + xml_set_object( $parser, $this->obj ); + } + break; + default: + // print_r( array( $tag, $attributes ) ); + } + + } + + /** + * XML Callback to process CDATA elements + * + * @access private + */ + function _tag_cdata( &$parser, $cdata ) { + } + + /** + * XML Callback to process end elements + * + * @access private + * @internal + */ + function _tag_close( &$parser, $tag ) { + + } + + /** + * Converts an XML schema string to the specified DTD version. + * + * Call this method to convert a string containing an XML schema to a different AXMLS + * DTD version. For instance, to convert a schema created for an pre-1.0 version for + * AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version + * parameter is specified, the schema will be converted to the current DTD version. + * If the newFile parameter is provided, the converted schema will be written to the specified + * file. + * @see ConvertSchemaFile() + * + * @param string $schema String containing XML schema that will be converted. + * @param string $newVersion DTD version to convert to. + * @param string $newFile File name of (converted) output file. + * @return string Converted XML schema or FALSE if an error occurs. + */ + function ConvertSchemaString( $schema, $newVersion = NULL, $newFile = NULL ) { + + // grab current version + if( !( $version = $this->SchemaStringVersion( $schema ) ) ) { + return FALSE; + } + + if( !isset ($newVersion) ) { + $newVersion = $this->schemaVersion; + } + + if( $version == $newVersion ) { + $result = $schema; + } else { + $result = $this->TransformSchema( $schema, 'convert-' . $version . '-' . $newVersion); + } + + if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) { + fwrite( $fp, $result ); + fclose( $fp ); + } + + return $result; + } + + // compat for pre-4.3 - jlim + function _file_get_contents($path) + { + if (function_exists('file_get_contents')) return file_get_contents($path); + return join('',file($path)); + } + + /** + * Converts an XML schema file to the specified DTD version. + * + * Call this method to convert the specified XML schema file to a different AXMLS + * DTD version. For instance, to convert a schema created for an pre-1.0 version for + * AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version + * parameter is specified, the schema will be converted to the current DTD version. + * If the newFile parameter is provided, the converted schema will be written to the specified + * file. + * @see ConvertSchemaString() + * + * @param string $filename Name of XML schema file that will be converted. + * @param string $newVersion DTD version to convert to. + * @param string $newFile File name of (converted) output file. + * @return string Converted XML schema or FALSE if an error occurs. + */ + function ConvertSchemaFile( $filename, $newVersion = NULL, $newFile = NULL ) { + + // grab current version + if( !( $version = $this->SchemaFileVersion( $filename ) ) ) { + return FALSE; + } + + if( !isset ($newVersion) ) { + $newVersion = $this->schemaVersion; + } + + if( $version == $newVersion ) { + $result = _file_get_contents( $filename ); + + // remove unicode BOM if present + if( substr( $result, 0, 3 ) == sprintf( '%c%c%c', 239, 187, 191 ) ) { + $result = substr( $result, 3 ); + } + } else { + $result = $this->TransformSchema( $filename, 'convert-' . $version . '-' . $newVersion, 'file' ); + } + + if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) { + fwrite( $fp, $result ); + fclose( $fp ); + } + + return $result; + } + + function TransformSchema( $schema, $xsl, $schematype='string' ) + { + // Fail if XSLT extension is not available + if( ! function_exists( 'xslt_create' ) ) { + return FALSE; + } + + $xsl_file = dirname( __FILE__ ) . '/xsl/' . $xsl . '.xsl'; + + // look for xsl + if( !is_readable( $xsl_file ) ) { + return FALSE; + } + + switch( $schematype ) + { + case 'file': + if( !is_readable( $schema ) ) { + return FALSE; + } + + $schema = _file_get_contents( $schema ); + break; + case 'string': + default: + if( !is_string( $schema ) ) { + return FALSE; + } + } + + $arguments = array ( + '/_xml' => $schema, + '/_xsl' => _file_get_contents( $xsl_file ) + ); + + // create an XSLT processor + $xh = xslt_create (); + + // set error handler + xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler')); + + // process the schema + $result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); + + xslt_free ($xh); + + return $result; + } + + /** + * Processes XSLT transformation errors + * + * @param object $parser XML parser object + * @param integer $errno Error number + * @param integer $level Error level + * @param array $fields Error information fields + * + * @access private + */ + function xslt_error_handler( $parser, $errno, $level, $fields ) { + if( is_array( $fields ) ) { + $msg = array( + 'Message Type' => ucfirst( $fields['msgtype'] ), + 'Message Code' => $fields['code'], + 'Message' => $fields['msg'], + 'Error Number' => $errno, + 'Level' => $level + ); + + switch( $fields['URI'] ) { + case 'arg:/_xml': + $msg['Input'] = 'XML'; + break; + case 'arg:/_xsl': + $msg['Input'] = 'XSL'; + break; + default: + $msg['Input'] = $fields['URI']; + } + + $msg['Line'] = $fields['line']; + } else { + $msg = array( + 'Message Type' => 'Error', + 'Error Number' => $errno, + 'Level' => $level, + 'Fields' => var_export( $fields, TRUE ) + ); + } + + $error_details = $msg['Message Type'] . ' in XSLT Transformation' . "\n" + . '' . "\n"; + + foreach( $msg as $label => $details ) { + $error_details .= '' . "\n"; + } + + $error_details .= '
' . $label . ': ' . htmlentities( $details ) . '
'; + + trigger_error( $error_details, E_USER_ERROR ); + } + + /** + * Returns the AXMLS Schema Version of the requested XML schema file. + * + * Call this method to obtain the AXMLS DTD version of the requested XML schema file. + * @see SchemaStringVersion() + * + * @param string $filename AXMLS schema file + * @return string Schema version number or FALSE on error + */ + function SchemaFileVersion( $filename ) { + // Open the file + if( !($fp = fopen( $filename, 'r' )) ) { + // die( 'Unable to open file' ); + return FALSE; + } + + // Process the file + while( $data = fread( $fp, 4096 ) ) { + if( preg_match( $this->versionRegex, $data, $matches ) ) { + return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION; + } + } + + return FALSE; + } + + /** + * Returns the AXMLS Schema Version of the provided XML schema string. + * + * Call this method to obtain the AXMLS DTD version of the provided XML schema string. + * @see SchemaFileVersion() + * + * @param string $xmlstring XML schema string + * @return string Schema version number or FALSE on error + */ + function SchemaStringVersion( $xmlstring ) { + if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) { + return FALSE; + } + + if( preg_match( $this->versionRegex, $xmlstring, $matches ) ) { + return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION; + } + + return FALSE; + } + + /** + * Extracts an XML schema from an existing database. + * + * Call this method to create an XML schema string from an existing database. + * If the data parameter is set to TRUE, AXMLS will include the data from the database + * in the schema. + * + * @param boolean $data Include data in schema dump + * @return string Generated XML schema + */ + function ExtractSchema( $data = FALSE ) { + $old_mode = $this->db->SetFetchMode( ADODB_FETCH_NUM ); + + $schema = '' . "\n" + . '' . "\n"; + + if( is_array( $tables = $this->db->MetaTables( 'TABLES' ) ) ) { + foreach( $tables as $table ) { + $schema .= ' ' . "\n"; + + // grab details from database + $rs = $this->db->Execute( 'SELECT * FROM ' . $table . ' WHERE 1=1' ); + $fields = $this->db->MetaColumns( $table ); + $indexes = $this->db->MetaIndexes( $table ); + + if( is_array( $fields ) ) { + foreach( $fields as $details ) { + $extra = ''; + $content = array(); + + if( $details->max_length > 0 ) { + $extra .= ' size="' . $details->max_length . '"'; + } + + if( $details->primary_key ) { + $content[] = ''; + } elseif( $details->not_null ) { + $content[] = ''; + } + + if( $details->has_default ) { + $content[] = ''; + } + + if( $details->auto_increment ) { + $content[] = ''; + } + + // this stops the creation of 'R' columns, + // AUTOINCREMENT is used to create auto columns + $details->primary_key = 0; + $type = $rs->MetaType( $details ); + + $schema .= ' '; + + if( !empty( $content ) ) { + $schema .= "\n " . implode( "\n ", $content ) . "\n "; + } + + $schema .= '' . "\n"; + } + } + + if( is_array( $indexes ) ) { + foreach( $indexes as $index => $details ) { + $schema .= ' ' . "\n"; + + if( $details['unique'] ) { + $schema .= ' ' . "\n"; + } + + foreach( $details['columns'] as $column ) { + $schema .= ' ' . $column . '' . "\n"; + } + + $schema .= ' ' . "\n"; + } + } + + if( $data ) { + $rs = $this->db->Execute( 'SELECT * FROM ' . $table ); + + if( is_object( $rs ) ) { + $schema .= ' ' . "\n"; + + while( $row = $rs->FetchRow() ) { + foreach( $row as $key => $val ) { + $row[$key] = htmlentities($val); + } + + $schema .= ' ' . implode( '', $row ) . '' . "\n"; + } + + $schema .= ' ' . "\n"; + } + } + + $schema .= '
' . "\n"; + } + } + + $this->db->SetFetchMode( $old_mode ); + + $schema .= '
'; + return $schema; + } + + /** + * Sets a prefix for database objects + * + * Call this method to set a standard prefix that will be prepended to all database tables + * and indices when the schema is parsed. Calling setPrefix with no arguments clears the prefix. + * + * @param string $prefix Prefix that will be prepended. + * @param boolean $underscore If TRUE, automatically append an underscore character to the prefix. + * @return boolean TRUE if successful, else FALSE + */ + function SetPrefix( $prefix = '', $underscore = TRUE ) { + switch( TRUE ) { + // clear prefix + case empty( $prefix ): + logMsg( 'Cleared prefix' ); + $this->objectPrefix = ''; + return TRUE; + // prefix too long + case strlen( $prefix ) > XMLS_PREFIX_MAXLEN: + // prefix contains invalid characters + case !preg_match( '/^[a-z][a-z0-9_]+$/i', $prefix ): + logMsg( 'Invalid prefix: ' . $prefix ); + return FALSE; + } + + if( $underscore AND substr( $prefix, -1 ) != '_' ) { + $prefix .= '_'; + } + + // prefix valid + logMsg( 'Set prefix: ' . $prefix ); + $this->objectPrefix = $prefix; + return TRUE; + } + + /** + * Returns an object name with the current prefix prepended. + * + * @param string $name Name + * @return string Prefixed name + * + * @access private + */ + function prefix( $name = '' ) { + // if prefix is set + if( !empty( $this->objectPrefix ) ) { + // Prepend the object prefix to the table name + // prepend after quote if used + return preg_replace( '/^(`?)(.+)$/', '$1' . $this->objectPrefix . '$2', $name ); + } + + // No prefix set. Use name provided. + return $name; + } + + /** + * Checks if element references a specific platform + * + * @param string $platform Requested platform + * @returns boolean TRUE if platform check succeeds + * + * @access private + */ + function supportedPlatform( $platform = NULL ) { + $regex = '/^(\w*\|)*' . $this->db->databaseType . '(\|\w*)*$/'; + + if( !isset( $platform ) OR preg_match( $regex, $platform ) ) { + logMsg( "Platform $platform is supported" ); + return TRUE; + } else { + logMsg( "Platform $platform is NOT supported" ); + return FALSE; + } + } + + /** + * Clears the array of generated SQL. + * + * @access private + */ + function clearSQL() { + $this->sqlArray = array(); + } + + /** + * Adds SQL into the SQL array. + * + * @param mixed $sql SQL to Add + * @return boolean TRUE if successful, else FALSE. + * + * @access private + */ + function addSQL( $sql = NULL ) { + if( is_array( $sql ) ) { + foreach( $sql as $line ) { + $this->addSQL( $line ); + } + + return TRUE; + } + + if( is_string( $sql ) ) { + $this->sqlArray[] = $sql; + + // if executeInline is enabled, and either no errors have occurred or continueOnError is enabled, execute SQL. + if( $this->ExecuteInline() && ( $this->success == 2 || $this->ContinueOnError() ) ) { + $saved = $this->db->debug; + $this->db->debug = $this->debug; + $ok = $this->db->Execute( $sql ); + $this->db->debug = $saved; + + if( !$ok ) { + if( $this->debug ) { + ADOConnection::outp( $this->db->ErrorMsg() ); + } + + $this->success = 1; + } + } + + return TRUE; + } + + return FALSE; + } + + /** + * Gets the SQL array in the specified format. + * + * @param string $format Format + * @return mixed SQL + * + * @access private + */ + function getSQL( $format = NULL, $sqlArray = NULL ) { + if( !is_array( $sqlArray ) ) { + $sqlArray = $this->sqlArray; + } + + if( !is_array( $sqlArray ) ) { + return FALSE; + } + + switch( strtolower( $format ) ) { + case 'string': + case 'text': + return !empty( $sqlArray ) ? implode( ";\n\n", $sqlArray ) . ';' : ''; + case'html': + return !empty( $sqlArray ) ? nl2br( htmlentities( implode( ";\n\n", $sqlArray ) . ';' ) ) : ''; + } + + return $this->sqlArray; + } + + /** + * Destroys an adoSchema object. + * + * Call this method to clean up after an adoSchema object that is no longer in use. + * @deprecated adoSchema now cleans up automatically. + */ + function Destroy() { + set_magic_quotes_runtime( $this->mgq ); + unset( $this ); + } +} + +/** +* Message logging function +* +* @access private +*/ +function logMsg( $msg, $title = NULL, $force = FALSE ) { + if( XMLS_DEBUG or $force ) { + echo '
';
+		
+		if( isset( $title ) ) {
+			echo '

' . htmlentities( $title ) . '

'; + } + + if( is_object( $this ) ) { + echo '[' . get_class( $this ) . '] '; + } + + print_r( $msg ); + + echo '
'; + } +} +?> \ No newline at end of file diff --git a/includes/adodb/adodb-xmlschema03.inc.php b/includes/adodb/adodb-xmlschema03.inc.php new file mode 100644 index 00000000..83984a68 --- /dev/null +++ b/includes/adodb/adodb-xmlschema03.inc.php @@ -0,0 +1,2404 @@ +parent = $parent; + } + + /** + * XML Callback to process start elements + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + + } + + /** + * XML Callback to process CDATA elements + * + * @access private + */ + function _tag_cdata( &$parser, $cdata ) { + + } + + /** + * XML Callback to process end elements + * + * @access private + */ + function _tag_close( &$parser, $tag ) { + + } + + function create() { + return array(); + } + + /** + * Destroys the object + */ + function destroy() { + unset( $this ); + } + + /** + * Checks whether the specified RDBMS is supported by the current + * database object or its ranking ancestor. + * + * @param string $platform RDBMS platform name (from ADODB platform list). + * @return boolean TRUE if RDBMS is supported; otherwise returns FALSE. + */ + function supportedPlatform( $platform = NULL ) { + return is_object( $this->parent ) ? $this->parent->supportedPlatform( $platform ) : TRUE; + } + + /** + * Returns the prefix set by the ranking ancestor of the database object. + * + * @param string $name Prefix string. + * @return string Prefix. + */ + function prefix( $name = '' ) { + return is_object( $this->parent ) ? $this->parent->prefix( $name ) : $name; + } + + /** + * Extracts a field ID from the specified field. + * + * @param string $field Field. + * @return string Field ID. + */ + function FieldID( $field ) { + return strtoupper( preg_replace( '/^`(.+)`$/', '$1', $field ) ); + } +} + +/** +* Creates a table object in ADOdb's datadict format +* +* This class stores information about a database table. As charactaristics +* of the table are loaded from the external source, methods and properties +* of this class are used to build up the table description in ADOdb's +* datadict format. +* +* @package axmls +* @access private +*/ +class dbTable extends dbObject { + + /** + * @var string Table name + */ + var $name; + + /** + * @var array Field specifier: Meta-information about each field + */ + var $fields = array(); + + /** + * @var array List of table indexes. + */ + var $indexes = array(); + + /** + * @var array Table options: Table-level options + */ + var $opts = array(); + + /** + * @var string Field index: Keeps track of which field is currently being processed + */ + var $current_field; + + /** + * @var boolean Mark table for destruction + * @access private + */ + var $drop_table; + + /** + * @var boolean Mark field for destruction (not yet implemented) + * @access private + */ + var $drop_field = array(); + + /** + * @var array Platform-specific options + * @access private + */ + var $currentPlatform = true; + + + /** + * Iniitializes a new table object. + * + * @param string $prefix DB Object prefix + * @param array $attributes Array of table attributes. + */ + function dbTable( &$parent, $attributes = NULL ) { + $this->parent = $parent; + $this->name = $this->prefix($attributes['NAME']); + } + + /** + * XML Callback to process start elements. Elements currently + * processed are: INDEX, DROP, FIELD, KEY, NOTNULL, AUTOINCREMENT & DEFAULT. + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + $this->currentElement = strtoupper( $tag ); + + switch( $this->currentElement ) { + case 'INDEX': + if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) { + xml_set_object( $parser, $this->addIndex( $attributes ) ); + } + break; + case 'DATA': + if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) { + xml_set_object( $parser, $this->addData( $attributes ) ); + } + break; + case 'DROP': + $this->drop(); + break; + case 'FIELD': + // Add a field + $fieldName = $attributes['NAME']; + $fieldType = $attributes['TYPE']; + $fieldSize = isset( $attributes['SIZE'] ) ? $attributes['SIZE'] : NULL; + $fieldOpts = !empty( $attributes['OPTS'] ) ? $attributes['OPTS'] : NULL; + + $this->addField( $fieldName, $fieldType, $fieldSize, $fieldOpts ); + break; + case 'KEY': + case 'NOTNULL': + case 'AUTOINCREMENT': + case 'DEFDATE': + case 'DEFTIMESTAMP': + case 'UNSIGNED': + // Add a field option + $this->addFieldOpt( $this->current_field, $this->currentElement ); + break; + case 'DEFAULT': + // Add a field option to the table object + + // Work around ADOdb datadict issue that misinterprets empty strings. + if( $attributes['VALUE'] == '' ) { + $attributes['VALUE'] = " '' "; + } + + $this->addFieldOpt( $this->current_field, $this->currentElement, $attributes['VALUE'] ); + break; + case 'OPT': + case 'CONSTRAINT': + // Accept platform-specific options + $this->currentPlatform = ( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ); + break; + default: + // print_r( array( $tag, $attributes ) ); + } + } + + /** + * XML Callback to process CDATA elements + * + * @access private + */ + function _tag_cdata( &$parser, $cdata ) { + switch( $this->currentElement ) { + // Table/field constraint + case 'CONSTRAINT': + if( isset( $this->current_field ) ) { + $this->addFieldOpt( $this->current_field, $this->currentElement, $cdata ); + } else { + $this->addTableOpt( $cdata ); + } + break; + // Table/field option + case 'OPT': + if( isset( $this->current_field ) ) { + $this->addFieldOpt( $this->current_field, $cdata ); + } else { + $this->addTableOpt( $cdata ); + } + break; + default: + + } + } + + /** + * XML Callback to process end elements + * + * @access private + */ + function _tag_close( &$parser, $tag ) { + $this->currentElement = ''; + + switch( strtoupper( $tag ) ) { + case 'TABLE': + $this->parent->addSQL( $this->create( $this->parent ) ); + xml_set_object( $parser, $this->parent ); + $this->destroy(); + break; + case 'FIELD': + unset($this->current_field); + break; + case 'OPT': + case 'CONSTRAINT': + $this->currentPlatform = true; + break; + default: + + } + } + + /** + * Adds an index to a table object + * + * @param array $attributes Index attributes + * @return object dbIndex object + */ + function addIndex( $attributes ) { + $name = strtoupper( $attributes['NAME'] ); + $this->indexes[$name] = new dbIndex( $this, $attributes ); + return $this->indexes[$name]; + } + + /** + * Adds data to a table object + * + * @param array $attributes Data attributes + * @return object dbData object + */ + function addData( $attributes ) { + if( !isset( $this->data ) ) { + $this->data = new dbData( $this, $attributes ); + } + return $this->data; + } + + /** + * Adds a field to a table object + * + * $name is the name of the table to which the field should be added. + * $type is an ADODB datadict field type. The following field types + * are supported as of ADODB 3.40: + * - C: varchar + * - X: CLOB (character large object) or largest varchar size + * if CLOB is not supported + * - C2: Multibyte varchar + * - X2: Multibyte CLOB + * - B: BLOB (binary large object) + * - D: Date (some databases do not support this, and we return a datetime type) + * - T: Datetime or Timestamp + * - L: Integer field suitable for storing booleans (0 or 1) + * - I: Integer (mapped to I4) + * - I1: 1-byte integer + * - I2: 2-byte integer + * - I4: 4-byte integer + * - I8: 8-byte integer + * - F: Floating point number + * - N: Numeric or decimal number + * + * @param string $name Name of the table to which the field will be added. + * @param string $type ADODB datadict field type. + * @param string $size Field size + * @param array $opts Field options array + * @return array Field specifier array + */ + function addField( $name, $type, $size = NULL, $opts = NULL ) { + $field_id = $this->FieldID( $name ); + + // Set the field index so we know where we are + $this->current_field = $field_id; + + // Set the field name (required) + $this->fields[$field_id]['NAME'] = $name; + + // Set the field type (required) + $this->fields[$field_id]['TYPE'] = $type; + + // Set the field size (optional) + if( isset( $size ) ) { + $this->fields[$field_id]['SIZE'] = $size; + } + + // Set the field options + if( isset( $opts ) ) { + $this->fields[$field_id]['OPTS'] = array($opts); + } else { + $this->fields[$field_id]['OPTS'] = array(); + } + } + + /** + * Adds a field option to the current field specifier + * + * This method adds a field option allowed by the ADOdb datadict + * and appends it to the given field. + * + * @param string $field Field name + * @param string $opt ADOdb field option + * @param mixed $value Field option value + * @return array Field specifier array + */ + function addFieldOpt( $field, $opt, $value = NULL ) { + if( $this->currentPlatform ) { + if( !isset( $value ) ) { + $this->fields[$this->FieldID( $field )]['OPTS'][] = $opt; + // Add the option and value + } else { + $this->fields[$this->FieldID( $field )]['OPTS'][] = array( $opt => $value ); + } + } + } + + /** + * Adds an option to the table + * + * This method takes a comma-separated list of table-level options + * and appends them to the table object. + * + * @param string $opt Table option + * @return array Options + */ + function addTableOpt( $opt ) { + if(isset($this->currentPlatform)) { + $this->opts[$this->parent->db->databaseType] = $opt; + } + return $this->opts; + } + + + /** + * Generates the SQL that will create the table in the database + * + * @param object $xmls adoSchema object + * @return array Array containing table creation SQL + */ + function create( &$xmls ) { + $sql = array(); + + // drop any existing indexes + if( is_array( $legacy_indexes = $xmls->dict->MetaIndexes( $this->name ) ) ) { + foreach( $legacy_indexes as $index => $index_details ) { + $sql[] = $xmls->dict->DropIndexSQL( $index, $this->name ); + } + } + + // remove fields to be dropped from table object + foreach( $this->drop_field as $field ) { + unset( $this->fields[$field] ); + } + + // if table exists + if( is_array( $legacy_fields = $xmls->dict->MetaColumns( $this->name ) ) ) { + // drop table + if( $this->drop_table ) { + $sql[] = $xmls->dict->DropTableSQL( $this->name ); + + return $sql; + } + + // drop any existing fields not in schema + foreach( $legacy_fields as $field_id => $field ) { + if( !isset( $this->fields[$field_id] ) ) { + $sql[] = $xmls->dict->DropColumnSQL( $this->name, $field->name ); + } + } + // if table doesn't exist + } else { + if( $this->drop_table ) { + return $sql; + } + + $legacy_fields = array(); + } + + // Loop through the field specifier array, building the associative array for the field options + $fldarray = array(); + + foreach( $this->fields as $field_id => $finfo ) { + // Set an empty size if it isn't supplied + if( !isset( $finfo['SIZE'] ) ) { + $finfo['SIZE'] = ''; + } + + // Initialize the field array with the type and size + $fldarray[$field_id] = array( + 'NAME' => $finfo['NAME'], + 'TYPE' => $finfo['TYPE'], + 'SIZE' => $finfo['SIZE'] + ); + + // Loop through the options array and add the field options. + if( isset( $finfo['OPTS'] ) ) { + foreach( $finfo['OPTS'] as $opt ) { + // Option has an argument. + if( is_array( $opt ) ) { + $key = key( $opt ); + $value = $opt[key( $opt )]; + @$fldarray[$field_id][$key] .= $value; + // Option doesn't have arguments + } else { + $fldarray[$field_id][$opt] = $opt; + } + } + } + } + + if( empty( $legacy_fields ) ) { + // Create the new table + $sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts ); + logMsg( end( $sql ), 'Generated CreateTableSQL' ); + } else { + // Upgrade an existing table + logMsg( "Upgrading {$this->name} using '{$xmls->upgrade}'" ); + switch( $xmls->upgrade ) { + // Use ChangeTableSQL + case 'ALTER': + logMsg( 'Generated ChangeTableSQL (ALTERing table)' ); + $sql[] = $xmls->dict->ChangeTableSQL( $this->name, $fldarray, $this->opts ); + break; + case 'REPLACE': + logMsg( 'Doing upgrade REPLACE (testing)' ); + $sql[] = $xmls->dict->DropTableSQL( $this->name ); + $sql[] = $xmls->dict->CreateTableSQL( $this->name, $fldarray, $this->opts ); + break; + // ignore table + default: + return array(); + } + } + + foreach( $this->indexes as $index ) { + $sql[] = $index->create( $xmls ); + } + + if( isset( $this->data ) ) { + $sql[] = $this->data->create( $xmls ); + } + + return $sql; + } + + /** + * Marks a field or table for destruction + */ + function drop() { + if( isset( $this->current_field ) ) { + // Drop the current field + logMsg( "Dropping field '{$this->current_field}' from table '{$this->name}'" ); + // $this->drop_field[$this->current_field] = $xmls->dict->DropColumnSQL( $this->name, $this->current_field ); + $this->drop_field[$this->current_field] = $this->current_field; + } else { + // Drop the current table + logMsg( "Dropping table '{$this->name}'" ); + // $this->drop_table = $xmls->dict->DropTableSQL( $this->name ); + $this->drop_table = TRUE; + } + } +} + +/** +* Creates an index object in ADOdb's datadict format +* +* This class stores information about a database index. As charactaristics +* of the index are loaded from the external source, methods and properties +* of this class are used to build up the index description in ADOdb's +* datadict format. +* +* @package axmls +* @access private +*/ +class dbIndex extends dbObject { + + /** + * @var string Index name + */ + var $name; + + /** + * @var array Index options: Index-level options + */ + var $opts = array(); + + /** + * @var array Indexed fields: Table columns included in this index + */ + var $columns = array(); + + /** + * @var boolean Mark index for destruction + * @access private + */ + var $drop = FALSE; + + /** + * Initializes the new dbIndex object. + * + * @param object $parent Parent object + * @param array $attributes Attributes + * + * @internal + */ + function dbIndex( &$parent, $attributes = NULL ) { + $this->parent = $parent; + + $this->name = $this->prefix ($attributes['NAME']); + } + + /** + * XML Callback to process start elements + * + * Processes XML opening tags. + * Elements currently processed are: DROP, CLUSTERED, BITMAP, UNIQUE, FULLTEXT & HASH. + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + $this->currentElement = strtoupper( $tag ); + + switch( $this->currentElement ) { + case 'DROP': + $this->drop(); + break; + case 'CLUSTERED': + case 'BITMAP': + case 'UNIQUE': + case 'FULLTEXT': + case 'HASH': + // Add index Option + $this->addIndexOpt( $this->currentElement ); + break; + default: + // print_r( array( $tag, $attributes ) ); + } + } + + /** + * XML Callback to process CDATA elements + * + * Processes XML cdata. + * + * @access private + */ + function _tag_cdata( &$parser, $cdata ) { + switch( $this->currentElement ) { + // Index field name + case 'COL': + $this->addField( $cdata ); + break; + default: + + } + } + + /** + * XML Callback to process end elements + * + * @access private + */ + function _tag_close( &$parser, $tag ) { + $this->currentElement = ''; + + switch( strtoupper( $tag ) ) { + case 'INDEX': + xml_set_object( $parser, $this->parent ); + break; + } + } + + /** + * Adds a field to the index + * + * @param string $name Field name + * @return string Field list + */ + function addField( $name ) { + $this->columns[$this->FieldID( $name )] = $name; + + // Return the field list + return $this->columns; + } + + /** + * Adds options to the index + * + * @param string $opt Comma-separated list of index options. + * @return string Option list + */ + function addIndexOpt( $opt ) { + $this->opts[] = $opt; + + // Return the options list + return $this->opts; + } + + /** + * Generates the SQL that will create the index in the database + * + * @param object $xmls adoSchema object + * @return array Array containing index creation SQL + */ + function create( &$xmls ) { + if( $this->drop ) { + return NULL; + } + + // eliminate any columns that aren't in the table + foreach( $this->columns as $id => $col ) { + if( !isset( $this->parent->fields[$id] ) ) { + unset( $this->columns[$id] ); + } + } + + return $xmls->dict->CreateIndexSQL( $this->name, $this->parent->name, $this->columns, $this->opts ); + } + + /** + * Marks an index for destruction + */ + function drop() { + $this->drop = TRUE; + } +} + +/** +* Creates a data object in ADOdb's datadict format +* +* This class stores information about table data, and is called +* when we need to load field data into a table. +* +* @package axmls +* @access private +*/ +class dbData extends dbObject { + + var $data = array(); + + var $row; + + /** + * Initializes the new dbData object. + * + * @param object $parent Parent object + * @param array $attributes Attributes + * + * @internal + */ + function dbData( &$parent, $attributes = NULL ) { + $this->parent = $parent; + } + + /** + * XML Callback to process start elements + * + * Processes XML opening tags. + * Elements currently processed are: ROW and F (field). + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + $this->currentElement = strtoupper( $tag ); + + switch( $this->currentElement ) { + case 'ROW': + $this->row = count( $this->data ); + $this->data[$this->row] = array(); + break; + case 'F': + $this->addField($attributes); + default: + // print_r( array( $tag, $attributes ) ); + } + } + + /** + * XML Callback to process CDATA elements + * + * Processes XML cdata. + * + * @access private + */ + function _tag_cdata( &$parser, $cdata ) { + switch( $this->currentElement ) { + // Index field name + case 'F': + $this->addData( $cdata ); + break; + default: + + } + } + + /** + * XML Callback to process end elements + * + * @access private + */ + function _tag_close( &$parser, $tag ) { + $this->currentElement = ''; + + switch( strtoupper( $tag ) ) { + case 'DATA': + xml_set_object( $parser, $this->parent ); + break; + } + } + + /** + * Adds a field to the insert + * + * @param string $name Field name + * @return string Field list + */ + function addField( $attributes ) { + // check we're in a valid row + if( !isset( $this->row ) || !isset( $this->data[$this->row] ) ) { + return; + } + + // Set the field index so we know where we are + if( isset( $attributes['NAME'] ) ) { + $this->current_field = $this->FieldID( $attributes['NAME'] ); + } else { + $this->current_field = count( $this->data[$this->row] ); + } + + // initialise data + if( !isset( $this->data[$this->row][$this->current_field] ) ) { + $this->data[$this->row][$this->current_field] = ''; + } + } + + /** + * Adds options to the index + * + * @param string $opt Comma-separated list of index options. + * @return string Option list + */ + function addData( $cdata ) { + // check we're in a valid field + if ( isset( $this->data[$this->row][$this->current_field] ) ) { + // add data to field + $this->data[$this->row][$this->current_field] .= $cdata; + } + } + + /** + * Generates the SQL that will add/update the data in the database + * + * @param object $xmls adoSchema object + * @return array Array containing index creation SQL + */ + function create( &$xmls ) { + $table = $xmls->dict->TableName($this->parent->name); + $table_field_count = count($this->parent->fields); + $tables = $xmls->db->MetaTables(); + $sql = array(); + + $ukeys = $xmls->db->MetaPrimaryKeys( $table ); + if( !empty( $this->parent->indexes ) and !empty( $ukeys ) ) { + foreach( $this->parent->indexes as $indexObj ) { + if( !in_array( $indexObj->name, $ukeys ) ) $ukeys[] = $indexObj->name; + } + } + + // eliminate any columns that aren't in the table + foreach( $this->data as $row ) { + $table_fields = $this->parent->fields; + $fields = array(); + $rawfields = array(); // Need to keep some of the unprocessed data on hand. + + foreach( $row as $field_id => $field_data ) { + if( !array_key_exists( $field_id, $table_fields ) ) { + if( is_numeric( $field_id ) ) { + $field_id = reset( array_keys( $table_fields ) ); + } else { + continue; + } + } + + $name = $table_fields[$field_id]['NAME']; + + switch( $table_fields[$field_id]['TYPE'] ) { + case 'I': + case 'I1': + case 'I2': + case 'I4': + case 'I8': + $fields[$name] = intval($field_data); + break; + case 'C': + case 'C2': + case 'X': + case 'X2': + default: + $fields[$name] = $xmls->db->qstr( $field_data ); + $rawfields[$name] = $field_data; + } + + unset($table_fields[$field_id]); + + } + + // check that at least 1 column is specified + if( empty( $fields ) ) { + continue; + } + + // check that no required columns are missing + if( count( $fields ) < $table_field_count ) { + foreach( $table_fields as $field ) { + if( isset( $field['OPTS'] ) and ( in_array( 'NOTNULL', $field['OPTS'] ) || in_array( 'KEY', $field['OPTS'] ) ) && !in_array( 'AUTOINCREMENT', $field['OPTS'] ) ) { + continue(2); + } + } + } + + // The rest of this method deals with updating existing data records. + + if( !in_array( $table, $tables ) or ( $mode = $xmls->existingData() ) == XMLS_MODE_INSERT ) { + // Table doesn't yet exist, so it's safe to insert. + logMsg( "$table doesn't exist, inserting or mode is INSERT" ); + $sql[] = 'INSERT INTO '. $table .' ('. implode( ',', array_keys( $fields ) ) .') VALUES ('. implode( ',', $fields ) .')'; + continue; + } + + // Prepare to test for potential violations. Get primary keys and unique indexes + $mfields = array_merge( $fields, $rawfields ); + $keyFields = array_intersect( $ukeys, array_keys( $mfields ) ); + + if( empty( $ukeys ) or count( $keyFields ) == 0 ) { + // No unique keys in schema, so safe to insert + logMsg( "Either schema or data has no unique keys, so safe to insert" ); + $sql[] = 'INSERT INTO '. $table .' ('. implode( ',', array_keys( $fields ) ) .') VALUES ('. implode( ',', $fields ) .')'; + continue; + } + + // Select record containing matching unique keys. + $where = ''; + foreach( $ukeys as $key ) { + if( isset( $mfields[$key] ) and $mfields[$key] ) { + if( $where ) $where .= ' AND '; + $where .= $key . ' = ' . $xmls->db->qstr( $mfields[$key] ); + } + } + $records = $xmls->db->Execute( 'SELECT * FROM ' . $table . ' WHERE ' . $where ); + switch( $records->RecordCount() ) { + case 0: + // No matching record, so safe to insert. + logMsg( "No matching records. Inserting new row with unique data" ); + $sql[] = $xmls->db->GetInsertSQL( $records, $mfields ); + break; + case 1: + // Exactly one matching record, so we can update if the mode permits. + logMsg( "One matching record..." ); + if( $mode == XMLS_MODE_UPDATE ) { + logMsg( "...Updating existing row from unique data" ); + $sql[] = $xmls->db->GetUpdateSQL( $records, $mfields ); + } + break; + default: + // More than one matching record; the result is ambiguous, so we must ignore the row. + logMsg( "More than one matching record. Ignoring row." ); + } + } + return $sql; + } +} + +/** +* Creates the SQL to execute a list of provided SQL queries +* +* @package axmls +* @access private +*/ +class dbQuerySet extends dbObject { + + /** + * @var array List of SQL queries + */ + var $queries = array(); + + /** + * @var string String used to build of a query line by line + */ + var $query; + + /** + * @var string Query prefix key + */ + var $prefixKey = ''; + + /** + * @var boolean Auto prefix enable (TRUE) + */ + var $prefixMethod = 'AUTO'; + + /** + * Initializes the query set. + * + * @param object $parent Parent object + * @param array $attributes Attributes + */ + function dbQuerySet( &$parent, $attributes = NULL ) { + $this->parent = $parent; + + // Overrides the manual prefix key + if( isset( $attributes['KEY'] ) ) { + $this->prefixKey = $attributes['KEY']; + } + + $prefixMethod = isset( $attributes['PREFIXMETHOD'] ) ? strtoupper( trim( $attributes['PREFIXMETHOD'] ) ) : ''; + + // Enables or disables automatic prefix prepending + switch( $prefixMethod ) { + case 'AUTO': + $this->prefixMethod = 'AUTO'; + break; + case 'MANUAL': + $this->prefixMethod = 'MANUAL'; + break; + case 'NONE': + $this->prefixMethod = 'NONE'; + break; + } + } + + /** + * XML Callback to process start elements. Elements currently + * processed are: QUERY. + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + $this->currentElement = strtoupper( $tag ); + + switch( $this->currentElement ) { + case 'QUERY': + // Create a new query in a SQL queryset. + // Ignore this query set if a platform is specified and it's different than the + // current connection platform. + if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) { + $this->newQuery(); + } else { + $this->discardQuery(); + } + break; + default: + // print_r( array( $tag, $attributes ) ); + } + } + + /** + * XML Callback to process CDATA elements + */ + function _tag_cdata( &$parser, $cdata ) { + switch( $this->currentElement ) { + // Line of queryset SQL data + case 'QUERY': + $this->buildQuery( $cdata ); + break; + default: + + } + } + + /** + * XML Callback to process end elements + * + * @access private + */ + function _tag_close( &$parser, $tag ) { + $this->currentElement = ''; + + switch( strtoupper( $tag ) ) { + case 'QUERY': + // Add the finished query to the open query set. + $this->addQuery(); + break; + case 'SQL': + $this->parent->addSQL( $this->create( $this->parent ) ); + xml_set_object( $parser, $this->parent ); + $this->destroy(); + break; + default: + + } + } + + /** + * Re-initializes the query. + * + * @return boolean TRUE + */ + function newQuery() { + $this->query = ''; + + return TRUE; + } + + /** + * Discards the existing query. + * + * @return boolean TRUE + */ + function discardQuery() { + unset( $this->query ); + + return TRUE; + } + + /** + * Appends a line to a query that is being built line by line + * + * @param string $data Line of SQL data or NULL to initialize a new query + * @return string SQL query string. + */ + function buildQuery( $sql = NULL ) { + if( !isset( $this->query ) OR empty( $sql ) ) { + return FALSE; + } + + $this->query .= $sql; + + return $this->query; + } + + /** + * Adds a completed query to the query list + * + * @return string SQL of added query + */ + function addQuery() { + if( !isset( $this->query ) ) { + return FALSE; + } + + $this->queries[] = $return = trim($this->query); + + unset( $this->query ); + + return $return; + } + + /** + * Creates and returns the current query set + * + * @param object $xmls adoSchema object + * @return array Query set + */ + function create( &$xmls ) { + foreach( $this->queries as $id => $query ) { + switch( $this->prefixMethod ) { + case 'AUTO': + // Enable auto prefix replacement + + // Process object prefix. + // Evaluate SQL statements to prepend prefix to objects + $query = $this->prefixQuery( '/^\s*((?is)INSERT\s+(INTO\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix ); + $query = $this->prefixQuery( '/^\s*((?is)UPDATE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix ); + $query = $this->prefixQuery( '/^\s*((?is)DELETE\s+(FROM\s+)?)((\w+\s*,?\s*)+)(\s.*$)/', $query, $xmls->objectPrefix ); + + // SELECT statements aren't working yet + #$data = preg_replace( '/(?ias)(^\s*SELECT\s+.*\s+FROM)\s+(\W\s*,?\s*)+((?i)\s+WHERE.*$)/', "\1 $prefix\2 \3", $data ); + + case 'MANUAL': + // If prefixKey is set and has a value then we use it to override the default constant XMLS_PREFIX. + // If prefixKey is not set, we use the default constant XMLS_PREFIX + if( isset( $this->prefixKey ) AND( $this->prefixKey !== '' ) ) { + // Enable prefix override + $query = str_replace( $this->prefixKey, $xmls->objectPrefix, $query ); + } else { + // Use default replacement + $query = str_replace( XMLS_PREFIX , $xmls->objectPrefix, $query ); + } + } + + $this->queries[$id] = trim( $query ); + } + + // Return the query set array + return $this->queries; + } + + /** + * Rebuilds the query with the prefix attached to any objects + * + * @param string $regex Regex used to add prefix + * @param string $query SQL query string + * @param string $prefix Prefix to be appended to tables, indices, etc. + * @return string Prefixed SQL query string. + */ + function prefixQuery( $regex, $query, $prefix = NULL ) { + if( !isset( $prefix ) ) { + return $query; + } + + if( preg_match( $regex, $query, $match ) ) { + $preamble = $match[1]; + $postamble = $match[5]; + $objectList = explode( ',', $match[3] ); + // $prefix = $prefix . '_'; + + $prefixedList = ''; + + foreach( $objectList as $object ) { + if( $prefixedList !== '' ) { + $prefixedList .= ', '; + } + + $prefixedList .= $prefix . trim( $object ); + } + + $query = $preamble . ' ' . $prefixedList . ' ' . $postamble; + } + + return $query; + } +} + +/** +* Loads and parses an XML file, creating an array of "ready-to-run" SQL statements +* +* This class is used to load and parse the XML file, to create an array of SQL statements +* that can be used to build a database, and to build the database using the SQL array. +* +* @tutorial getting_started.pkg +* +* @author Richard Tango-Lowy & Dan Cech +* @version $Revision: 1.62 $ +* +* @package axmls +*/ +class adoSchema { + + /** + * @var array Array containing SQL queries to generate all objects + * @access private + */ + var $sqlArray; + + /** + * @var object ADOdb connection object + * @access private + */ + var $db; + + /** + * @var object ADOdb Data Dictionary + * @access private + */ + var $dict; + + /** + * @var string Current XML element + * @access private + */ + var $currentElement = ''; + + /** + * @var string If set (to 'ALTER' or 'REPLACE'), upgrade an existing database + * @access private + */ + var $upgrade = ''; + + /** + * @var string Optional object prefix + * @access private + */ + var $objectPrefix = ''; + + /** + * @var long Original Magic Quotes Runtime value + * @access private + */ + var $mgq; + + /** + * @var long System debug + * @access private + */ + var $debug; + + /** + * @var string Regular expression to find schema version + * @access private + */ + var $versionRegex = '//'; + + /** + * @var string Current schema version + * @access private + */ + var $schemaVersion; + + /** + * @var int Success of last Schema execution + */ + var $success; + + /** + * @var bool Execute SQL inline as it is generated + */ + var $executeInline; + + /** + * @var bool Continue SQL execution if errors occur + */ + var $continueOnError; + + /** + * @var int How to handle existing data rows (insert, update, or ignore) + */ + var $existingData; + + /** + * Creates an adoSchema object + * + * Creating an adoSchema object is the first step in processing an XML schema. + * The only parameter is an ADOdb database connection object, which must already + * have been created. + * + * @param object $db ADOdb database connection object. + */ + function adoSchema( &$db ) { + // Initialize the environment + $this->mgq = get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + + $this->db = $db; + $this->debug = $this->db->debug; + $this->dict = NewDataDictionary( $this->db ); + $this->sqlArray = array(); + $this->schemaVersion = XMLS_SCHEMA_VERSION; + $this->executeInline( XMLS_EXECUTE_INLINE ); + $this->continueOnError( XMLS_CONTINUE_ON_ERROR ); + $this->existingData( XMLS_EXISTING_DATA ); + $this->setUpgradeMethod(); + } + + /** + * Sets the method to be used for upgrading an existing database + * + * Use this method to specify how existing database objects should be upgraded. + * The method option can be set to ALTER, REPLACE, BEST, or NONE. ALTER attempts to + * alter each database object directly, REPLACE attempts to rebuild each object + * from scratch, BEST attempts to determine the best upgrade method for each + * object, and NONE disables upgrading. + * + * This method is not yet used by AXMLS, but exists for backward compatibility. + * The ALTER method is automatically assumed when the adoSchema object is + * instantiated; other upgrade methods are not currently supported. + * + * @param string $method Upgrade method (ALTER|REPLACE|BEST|NONE) + * @returns string Upgrade method used + */ + function SetUpgradeMethod( $method = '' ) { + if( !is_string( $method ) ) { + return FALSE; + } + + $method = strtoupper( $method ); + + // Handle the upgrade methods + switch( $method ) { + case 'ALTER': + $this->upgrade = $method; + break; + case 'REPLACE': + $this->upgrade = $method; + break; + case 'BEST': + $this->upgrade = 'ALTER'; + break; + case 'NONE': + $this->upgrade = 'NONE'; + break; + default: + // Use default if no legitimate method is passed. + $this->upgrade = XMLS_DEFAULT_UPGRADE_METHOD; + } + + return $this->upgrade; + } + + /** + * Specifies how to handle existing data row when there is a unique key conflict. + * + * The existingData setting specifies how the parser should handle existing rows + * when a unique key violation occurs during the insert. This can happen when inserting + * data into an existing table with one or more primary keys or unique indexes. + * The existingData method takes one of three options: XMLS_MODE_INSERT attempts + * to always insert the data as a new row. In the event of a unique key violation, + * the database will generate an error. XMLS_MODE_UPDATE attempts to update the + * any existing rows with the new data based upon primary or unique key fields in + * the schema. If the data row in the schema specifies no unique fields, the row + * data will be inserted as a new row. XMLS_MODE_IGNORE specifies that any data rows + * that would result in a unique key violation be ignored; no inserts or updates will + * take place. For backward compatibility, the default setting is XMLS_MODE_INSERT, + * but XMLS_MODE_UPDATE will generally be the most appropriate setting. + * + * @param int $mode XMLS_MODE_INSERT, XMLS_MODE_UPDATE, or XMLS_MODE_IGNORE + * @return int current mode + */ + function ExistingData( $mode = NULL ) { + if( is_int( $mode ) ) { + switch( $mode ) { + case XMLS_MODE_UPDATE: + $mode = XMLS_MODE_UPDATE; + break; + case XMLS_MODE_IGNORE: + $mode = XMLS_MODE_IGNORE; + break; + case XMLS_MODE_INSERT: + $mode = XMLS_MODE_INSERT; + break; + default: + $mode = XMLS_EXISITNG_DATA; + break; + } + $this->existingData = $mode; + } + + return $this->existingData; + } + + /** + * Enables/disables inline SQL execution. + * + * Call this method to enable or disable inline execution of the schema. If the mode is set to TRUE (inline execution), + * AXMLS applies the SQL to the database immediately as each schema entity is parsed. If the mode + * is set to FALSE (post execution), AXMLS parses the entire schema and you will need to call adoSchema::ExecuteSchema() + * to apply the schema to the database. + * + * @param bool $mode execute + * @return bool current execution mode + * + * @see ParseSchema(), ExecuteSchema() + */ + function ExecuteInline( $mode = NULL ) { + if( is_bool( $mode ) ) { + $this->executeInline = $mode; + } + + return $this->executeInline; + } + + /** + * Enables/disables SQL continue on error. + * + * Call this method to enable or disable continuation of SQL execution if an error occurs. + * If the mode is set to TRUE (continue), AXMLS will continue to apply SQL to the database, even if an error occurs. + * If the mode is set to FALSE (halt), AXMLS will halt execution of generated sql if an error occurs, though parsing + * of the schema will continue. + * + * @param bool $mode execute + * @return bool current continueOnError mode + * + * @see addSQL(), ExecuteSchema() + */ + function ContinueOnError( $mode = NULL ) { + if( is_bool( $mode ) ) { + $this->continueOnError = $mode; + } + + return $this->continueOnError; + } + + /** + * Loads an XML schema from a file and converts it to SQL. + * + * Call this method to load the specified schema (see the DTD for the proper format) from + * the filesystem and generate the SQL necessary to create the database + * described. This method automatically converts the schema to the latest + * axmls schema version. + * @see ParseSchemaString() + * + * @param string $file Name of XML schema file. + * @param bool $returnSchema Return schema rather than parsing. + * @return array Array of SQL queries, ready to execute + */ + function ParseSchema( $filename, $returnSchema = FALSE ) { + return $this->ParseSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema ); + } + + /** + * Loads an XML schema from a file and converts it to SQL. + * + * Call this method to load the specified schema directly from a file (see + * the DTD for the proper format) and generate the SQL necessary to create + * the database described by the schema. Use this method when you are dealing + * with large schema files. Otherwise, ParseSchema() is faster. + * This method does not automatically convert the schema to the latest axmls + * schema version. You must convert the schema manually using either the + * ConvertSchemaFile() or ConvertSchemaString() method. + * @see ParseSchema() + * @see ConvertSchemaFile() + * @see ConvertSchemaString() + * + * @param string $file Name of XML schema file. + * @param bool $returnSchema Return schema rather than parsing. + * @return array Array of SQL queries, ready to execute. + * + * @deprecated Replaced by adoSchema::ParseSchema() and adoSchema::ParseSchemaString() + * @see ParseSchema(), ParseSchemaString() + */ + function ParseSchemaFile( $filename, $returnSchema = FALSE ) { + // Open the file + if( !($fp = fopen( $filename, 'r' )) ) { + logMsg( 'Unable to open file' ); + return FALSE; + } + + // do version detection here + if( $this->SchemaFileVersion( $filename ) != $this->schemaVersion ) { + logMsg( 'Invalid Schema Version' ); + return FALSE; + } + + if( $returnSchema ) { + $xmlstring = ''; + while( $data = fread( $fp, 4096 ) ) { + $xmlstring .= $data . "\n"; + } + return $xmlstring; + } + + $this->success = 2; + + $xmlParser = $this->create_parser(); + + // Process the file + while( $data = fread( $fp, 4096 ) ) { + if( !xml_parse( $xmlParser, $data, feof( $fp ) ) ) { + die( sprintf( + "XML error: %s at line %d", + xml_error_string( xml_get_error_code( $xmlParser) ), + xml_get_current_line_number( $xmlParser) + ) ); + } + } + + xml_parser_free( $xmlParser ); + + return $this->sqlArray; + } + + /** + * Converts an XML schema string to SQL. + * + * Call this method to parse a string containing an XML schema (see the DTD for the proper format) + * and generate the SQL necessary to create the database described by the schema. + * @see ParseSchema() + * + * @param string $xmlstring XML schema string. + * @param bool $returnSchema Return schema rather than parsing. + * @return array Array of SQL queries, ready to execute. + */ + function ParseSchemaString( $xmlstring, $returnSchema = FALSE ) { + if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) { + logMsg( 'Empty or Invalid Schema' ); + return FALSE; + } + + // do version detection here + if( $this->SchemaStringVersion( $xmlstring ) != $this->schemaVersion ) { + logMsg( 'Invalid Schema Version' ); + return FALSE; + } + + if( $returnSchema ) { + return $xmlstring; + } + + $this->success = 2; + + $xmlParser = $this->create_parser(); + + if( !xml_parse( $xmlParser, $xmlstring, TRUE ) ) { + die( sprintf( + "XML error: %s at line %d", + xml_error_string( xml_get_error_code( $xmlParser) ), + xml_get_current_line_number( $xmlParser) + ) ); + } + + xml_parser_free( $xmlParser ); + + return $this->sqlArray; + } + + /** + * Loads an XML schema from a file and converts it to uninstallation SQL. + * + * Call this method to load the specified schema (see the DTD for the proper format) from + * the filesystem and generate the SQL necessary to remove the database described. + * @see RemoveSchemaString() + * + * @param string $file Name of XML schema file. + * @param bool $returnSchema Return schema rather than parsing. + * @return array Array of SQL queries, ready to execute + */ + function RemoveSchema( $filename, $returnSchema = FALSE ) { + return $this->RemoveSchemaString( $this->ConvertSchemaFile( $filename ), $returnSchema ); + } + + /** + * Converts an XML schema string to uninstallation SQL. + * + * Call this method to parse a string containing an XML schema (see the DTD for the proper format) + * and generate the SQL necessary to uninstall the database described by the schema. + * @see RemoveSchema() + * + * @param string $schema XML schema string. + * @param bool $returnSchema Return schema rather than parsing. + * @return array Array of SQL queries, ready to execute. + */ + function RemoveSchemaString( $schema, $returnSchema = FALSE ) { + + // grab current version + if( !( $version = $this->SchemaStringVersion( $schema ) ) ) { + return FALSE; + } + + return $this->ParseSchemaString( $this->TransformSchema( $schema, 'remove-' . $version), $returnSchema ); + } + + /** + * Applies the current XML schema to the database (post execution). + * + * Call this method to apply the current schema (generally created by calling + * ParseSchema() or ParseSchemaString() ) to the database (creating the tables, indexes, + * and executing other SQL specified in the schema) after parsing. + * @see ParseSchema(), ParseSchemaString(), ExecuteInline() + * + * @param array $sqlArray Array of SQL statements that will be applied rather than + * the current schema. + * @param boolean $continueOnErr Continue to apply the schema even if an error occurs. + * @returns integer 0 if failure, 1 if errors, 2 if successful. + */ + function ExecuteSchema( $sqlArray = NULL, $continueOnErr = NULL ) { + if( !is_bool( $continueOnErr ) ) { + $continueOnErr = $this->ContinueOnError(); + } + + if( !isset( $sqlArray ) ) { + $sqlArray = $this->sqlArray; + } + + if( !is_array( $sqlArray ) ) { + $this->success = 0; + } else { + $this->success = $this->dict->ExecuteSQLArray( $sqlArray, $continueOnErr ); + } + + return $this->success; + } + + /** + * Returns the current SQL array. + * + * Call this method to fetch the array of SQL queries resulting from + * ParseSchema() or ParseSchemaString(). + * + * @param string $format Format: HTML, TEXT, or NONE (PHP array) + * @return array Array of SQL statements or FALSE if an error occurs + */ + function PrintSQL( $format = 'NONE' ) { + $sqlArray = null; + return $this->getSQL( $format, $sqlArray ); + } + + /** + * Saves the current SQL array to the local filesystem as a list of SQL queries. + * + * Call this method to save the array of SQL queries (generally resulting from a + * parsed XML schema) to the filesystem. + * + * @param string $filename Path and name where the file should be saved. + * @return boolean TRUE if save is successful, else FALSE. + */ + function SaveSQL( $filename = './schema.sql' ) { + + if( !isset( $sqlArray ) ) { + $sqlArray = $this->sqlArray; + } + if( !isset( $sqlArray ) ) { + return FALSE; + } + + $fp = fopen( $filename, "w" ); + + foreach( $sqlArray as $key => $query ) { + fwrite( $fp, $query . ";\n" ); + } + fclose( $fp ); + } + + /** + * Create an xml parser + * + * @return object PHP XML parser object + * + * @access private + */ + function create_parser() { + // Create the parser + $xmlParser = xml_parser_create(); + xml_set_object( $xmlParser, $this ); + + // Initialize the XML callback functions + xml_set_element_handler( $xmlParser, '_tag_open', '_tag_close' ); + xml_set_character_data_handler( $xmlParser, '_tag_cdata' ); + + return $xmlParser; + } + + /** + * XML Callback to process start elements + * + * @access private + */ + function _tag_open( &$parser, $tag, $attributes ) { + switch( strtoupper( $tag ) ) { + case 'TABLE': + if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) { + $this->obj = new dbTable( $this, $attributes ); + xml_set_object( $parser, $this->obj ); + } + break; + case 'SQL': + if( !isset( $attributes['PLATFORM'] ) OR $this->supportedPlatform( $attributes['PLATFORM'] ) ) { + $this->obj = new dbQuerySet( $this, $attributes ); + xml_set_object( $parser, $this->obj ); + } + break; + default: + // print_r( array( $tag, $attributes ) ); + } + + } + + /** + * XML Callback to process CDATA elements + * + * @access private + */ + function _tag_cdata( &$parser, $cdata ) { + } + + /** + * XML Callback to process end elements + * + * @access private + * @internal + */ + function _tag_close( &$parser, $tag ) { + + } + + /** + * Converts an XML schema string to the specified DTD version. + * + * Call this method to convert a string containing an XML schema to a different AXMLS + * DTD version. For instance, to convert a schema created for an pre-1.0 version for + * AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version + * parameter is specified, the schema will be converted to the current DTD version. + * If the newFile parameter is provided, the converted schema will be written to the specified + * file. + * @see ConvertSchemaFile() + * + * @param string $schema String containing XML schema that will be converted. + * @param string $newVersion DTD version to convert to. + * @param string $newFile File name of (converted) output file. + * @return string Converted XML schema or FALSE if an error occurs. + */ + function ConvertSchemaString( $schema, $newVersion = NULL, $newFile = NULL ) { + + // grab current version + if( !( $version = $this->SchemaStringVersion( $schema ) ) ) { + return FALSE; + } + + if( !isset ($newVersion) ) { + $newVersion = $this->schemaVersion; + } + + if( $version == $newVersion ) { + $result = $schema; + } else { + $result = $this->TransformSchema( $schema, 'convert-' . $version . '-' . $newVersion); + } + + if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) { + fwrite( $fp, $result ); + fclose( $fp ); + } + + return $result; + } + + /* + // compat for pre-4.3 - jlim + function _file_get_contents($path) + { + if (function_exists('file_get_contents')) return file_get_contents($path); + return join('',file($path)); + }*/ + + /** + * Converts an XML schema file to the specified DTD version. + * + * Call this method to convert the specified XML schema file to a different AXMLS + * DTD version. For instance, to convert a schema created for an pre-1.0 version for + * AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version + * parameter is specified, the schema will be converted to the current DTD version. + * If the newFile parameter is provided, the converted schema will be written to the specified + * file. + * @see ConvertSchemaString() + * + * @param string $filename Name of XML schema file that will be converted. + * @param string $newVersion DTD version to convert to. + * @param string $newFile File name of (converted) output file. + * @return string Converted XML schema or FALSE if an error occurs. + */ + function ConvertSchemaFile( $filename, $newVersion = NULL, $newFile = NULL ) { + + // grab current version + if( !( $version = $this->SchemaFileVersion( $filename ) ) ) { + return FALSE; + } + + if( !isset ($newVersion) ) { + $newVersion = $this->schemaVersion; + } + + if( $version == $newVersion ) { + $result = _file_get_contents( $filename ); + + // remove unicode BOM if present + if( substr( $result, 0, 3 ) == sprintf( '%c%c%c', 239, 187, 191 ) ) { + $result = substr( $result, 3 ); + } + } else { + $result = $this->TransformSchema( $filename, 'convert-' . $version . '-' . $newVersion, 'file' ); + } + + if( is_string( $result ) AND is_string( $newFile ) AND ( $fp = fopen( $newFile, 'w' ) ) ) { + fwrite( $fp, $result ); + fclose( $fp ); + } + + return $result; + } + + function TransformSchema( $schema, $xsl, $schematype='string' ) + { + // Fail if XSLT extension is not available + if( ! function_exists( 'xslt_create' ) ) { + return FALSE; + } + + $xsl_file = dirname( __FILE__ ) . '/xsl/' . $xsl . '.xsl'; + + // look for xsl + if( !is_readable( $xsl_file ) ) { + return FALSE; + } + + switch( $schematype ) + { + case 'file': + if( !is_readable( $schema ) ) { + return FALSE; + } + + $schema = _file_get_contents( $schema ); + break; + case 'string': + default: + if( !is_string( $schema ) ) { + return FALSE; + } + } + + $arguments = array ( + '/_xml' => $schema, + '/_xsl' => _file_get_contents( $xsl_file ) + ); + + // create an XSLT processor + $xh = xslt_create (); + + // set error handler + xslt_set_error_handler ($xh, array (&$this, 'xslt_error_handler')); + + // process the schema + $result = xslt_process ($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments); + + xslt_free ($xh); + + return $result; + } + + /** + * Processes XSLT transformation errors + * + * @param object $parser XML parser object + * @param integer $errno Error number + * @param integer $level Error level + * @param array $fields Error information fields + * + * @access private + */ + function xslt_error_handler( $parser, $errno, $level, $fields ) { + if( is_array( $fields ) ) { + $msg = array( + 'Message Type' => ucfirst( $fields['msgtype'] ), + 'Message Code' => $fields['code'], + 'Message' => $fields['msg'], + 'Error Number' => $errno, + 'Level' => $level + ); + + switch( $fields['URI'] ) { + case 'arg:/_xml': + $msg['Input'] = 'XML'; + break; + case 'arg:/_xsl': + $msg['Input'] = 'XSL'; + break; + default: + $msg['Input'] = $fields['URI']; + } + + $msg['Line'] = $fields['line']; + } else { + $msg = array( + 'Message Type' => 'Error', + 'Error Number' => $errno, + 'Level' => $level, + 'Fields' => var_export( $fields, TRUE ) + ); + } + + $error_details = $msg['Message Type'] . ' in XSLT Transformation' . "\n" + . '' . "\n"; + + foreach( $msg as $label => $details ) { + $error_details .= '' . "\n"; + } + + $error_details .= '
' . $label . ': ' . htmlentities( $details ) . '
'; + + trigger_error( $error_details, E_USER_ERROR ); + } + + /** + * Returns the AXMLS Schema Version of the requested XML schema file. + * + * Call this method to obtain the AXMLS DTD version of the requested XML schema file. + * @see SchemaStringVersion() + * + * @param string $filename AXMLS schema file + * @return string Schema version number or FALSE on error + */ + function SchemaFileVersion( $filename ) { + // Open the file + if( !($fp = fopen( $filename, 'r' )) ) { + // die( 'Unable to open file' ); + return FALSE; + } + + // Process the file + while( $data = fread( $fp, 4096 ) ) { + if( preg_match( $this->versionRegex, $data, $matches ) ) { + return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION; + } + } + + return FALSE; + } + + /** + * Returns the AXMLS Schema Version of the provided XML schema string. + * + * Call this method to obtain the AXMLS DTD version of the provided XML schema string. + * @see SchemaFileVersion() + * + * @param string $xmlstring XML schema string + * @return string Schema version number or FALSE on error + */ + function SchemaStringVersion( $xmlstring ) { + if( !is_string( $xmlstring ) OR empty( $xmlstring ) ) { + return FALSE; + } + + if( preg_match( $this->versionRegex, $xmlstring, $matches ) ) { + return !empty( $matches[2] ) ? $matches[2] : XMLS_DEFAULT_SCHEMA_VERSION; + } + + return FALSE; + } + + /** + * Extracts an XML schema from an existing database. + * + * Call this method to create an XML schema string from an existing database. + * If the data parameter is set to TRUE, AXMLS will include the data from the database + * in the schema. + * + * @param boolean $data Include data in schema dump + * @indent string indentation to use + * @prefix string extract only tables with given prefix + * @stripprefix strip prefix string when storing in XML schema + * @return string Generated XML schema + */ + function ExtractSchema( $data = FALSE, $indent = ' ', $prefix = '' , $stripprefix=false) { + $old_mode = $this->db->SetFetchMode( ADODB_FETCH_NUM ); + + $schema = '' . "\n" + . '' . "\n"; + + if( is_array( $tables = $this->db->MetaTables( 'TABLES' , ($prefix) ? $prefix.'%' : '') ) ) { + foreach( $tables as $table ) { + if ($stripprefix) $table = str_replace(str_replace('\\_', '_', $pfx ), '', $table); + $schema .= $indent . '' . "\n"; + + // grab details from database + $rs = $this->db->Execute( 'SELECT * FROM ' . $table . ' WHERE -1' ); + $fields = $this->db->MetaColumns( $table ); + $indexes = $this->db->MetaIndexes( $table ); + + if( is_array( $fields ) ) { + foreach( $fields as $details ) { + $extra = ''; + $content = array(); + + if( isset($details->max_length) && $details->max_length > 0 ) { + $extra .= ' size="' . $details->max_length . '"'; + } + + if( isset($details->primary_key) && $details->primary_key ) { + $content[] = ''; + } elseif( isset($details->not_null) && $details->not_null ) { + $content[] = ''; + } + + if( isset($details->has_default) && $details->has_default ) { + $content[] = ''; + } + + if( isset($details->auto_increment) && $details->auto_increment ) { + $content[] = ''; + } + + if( isset($details->unsigned) && $details->unsigned ) { + $content[] = ''; + } + + // this stops the creation of 'R' columns, + // AUTOINCREMENT is used to create auto columns + $details->primary_key = 0; + $type = $rs->MetaType( $details ); + + $schema .= str_repeat( $indent, 2 ) . '' . "\n"; + } else { + $schema .= "/>\n"; + } + } + } + + if( is_array( $indexes ) ) { + foreach( $indexes as $index => $details ) { + $schema .= str_repeat( $indent, 2 ) . '' . "\n"; + + if( $details['unique'] ) { + $schema .= str_repeat( $indent, 3 ) . '' . "\n"; + } + + foreach( $details['columns'] as $column ) { + $schema .= str_repeat( $indent, 3 ) . '' . htmlentities( $column ) . '' . "\n"; + } + + $schema .= str_repeat( $indent, 2 ) . '' . "\n"; + } + } + + if( $data ) { + $rs = $this->db->Execute( 'SELECT * FROM ' . $table ); + + if( is_object( $rs ) && !$rs->EOF ) { + $schema .= str_repeat( $indent, 2 ) . "\n"; + + while( $row = $rs->FetchRow() ) { + foreach( $row as $key => $val ) { + if ( $val != htmlentities( $val ) ) { + $row[$key] = ''; + } + } + + $schema .= str_repeat( $indent, 3 ) . '' . implode( '', $row ) . "\n"; + } + + $schema .= str_repeat( $indent, 2 ) . "\n"; + } + } + + $schema .= $indent . "
\n"; + } + } + + $this->db->SetFetchMode( $old_mode ); + + $schema .= '
'; + return $schema; + } + + /** + * Sets a prefix for database objects + * + * Call this method to set a standard prefix that will be prepended to all database tables + * and indices when the schema is parsed. Calling setPrefix with no arguments clears the prefix. + * + * @param string $prefix Prefix that will be prepended. + * @param boolean $underscore If TRUE, automatically append an underscore character to the prefix. + * @return boolean TRUE if successful, else FALSE + */ + function SetPrefix( $prefix = '', $underscore = TRUE ) { + switch( TRUE ) { + // clear prefix + case empty( $prefix ): + logMsg( 'Cleared prefix' ); + $this->objectPrefix = ''; + return TRUE; + // prefix too long + case strlen( $prefix ) > XMLS_PREFIX_MAXLEN: + // prefix contains invalid characters + case !preg_match( '/^[a-z][a-z0-9_]+$/i', $prefix ): + logMsg( 'Invalid prefix: ' . $prefix ); + return FALSE; + } + + if( $underscore AND substr( $prefix, -1 ) != '_' ) { + $prefix .= '_'; + } + + // prefix valid + logMsg( 'Set prefix: ' . $prefix ); + $this->objectPrefix = $prefix; + return TRUE; + } + + /** + * Returns an object name with the current prefix prepended. + * + * @param string $name Name + * @return string Prefixed name + * + * @access private + */ + function prefix( $name = '' ) { + // if prefix is set + if( !empty( $this->objectPrefix ) ) { + // Prepend the object prefix to the table name + // prepend after quote if used + return preg_replace( '/^(`?)(.+)$/', '$1' . $this->objectPrefix . '$2', $name ); + } + + // No prefix set. Use name provided. + return $name; + } + + /** + * Checks if element references a specific platform + * + * @param string $platform Requested platform + * @returns boolean TRUE if platform check succeeds + * + * @access private + */ + function supportedPlatform( $platform = NULL ) { + if( !empty( $platform ) ) { + $regex = '/(^|\|)' . $this->db->databaseType . '(\||$)/i'; + + if( preg_match( '/^- /', $platform ) ) { + if (preg_match ( $regex, substr( $platform, 2 ) ) ) { + logMsg( 'Platform ' . $platform . ' is NOT supported' ); + return FALSE; + } + } else { + if( !preg_match ( $regex, $platform ) ) { + logMsg( 'Platform ' . $platform . ' is NOT supported' ); + return FALSE; + } + } + } + + logMsg( 'Platform ' . $platform . ' is supported' ); + return TRUE; + } + + /** + * Clears the array of generated SQL. + * + * @access private + */ + function clearSQL() { + $this->sqlArray = array(); + } + + /** + * Adds SQL into the SQL array. + * + * @param mixed $sql SQL to Add + * @return boolean TRUE if successful, else FALSE. + * + * @access private + */ + function addSQL( $sql = NULL ) { + if( is_array( $sql ) ) { + foreach( $sql as $line ) { + $this->addSQL( $line ); + } + + return TRUE; + } + + if( is_string( $sql ) ) { + $this->sqlArray[] = $sql; + + // if executeInline is enabled, and either no errors have occurred or continueOnError is enabled, execute SQL. + if( $this->ExecuteInline() && ( $this->success == 2 || $this->ContinueOnError() ) ) { + $saved = $this->db->debug; + $this->db->debug = $this->debug; + $ok = $this->db->Execute( $sql ); + $this->db->debug = $saved; + + if( !$ok ) { + if( $this->debug ) { + ADOConnection::outp( $this->db->ErrorMsg() ); + } + + $this->success = 1; + } + } + + return TRUE; + } + + return FALSE; + } + + /** + * Gets the SQL array in the specified format. + * + * @param string $format Format + * @return mixed SQL + * + * @access private + */ + function getSQL( $format = NULL, $sqlArray = NULL ) { + if( !is_array( $sqlArray ) ) { + $sqlArray = $this->sqlArray; + } + + if( !is_array( $sqlArray ) ) { + return FALSE; + } + + switch( strtolower( $format ) ) { + case 'string': + case 'text': + return !empty( $sqlArray ) ? implode( ";\n\n", $sqlArray ) . ';' : ''; + case'html': + return !empty( $sqlArray ) ? nl2br( htmlentities( implode( ";\n\n", $sqlArray ) . ';' ) ) : ''; + } + + return $this->sqlArray; + } + + /** + * Destroys an adoSchema object. + * + * Call this method to clean up after an adoSchema object that is no longer in use. + * @deprecated adoSchema now cleans up automatically. + */ + function Destroy() { + set_magic_quotes_runtime( $this->mgq ); + unset( $this ); + } +} + +/** +* Message logging function +* +* @access private +*/ +function logMsg( $msg, $title = NULL, $force = FALSE ) { + if( XMLS_DEBUG or $force ) { + echo '
';
+		
+		if( isset( $title ) ) {
+			echo '

' . htmlentities( $title ) . '

'; + } + + if( @is_object( $this ) ) { + echo '[' . get_class( $this ) . '] '; + } + + print_r( $msg ); + + echo '
'; + } +} +?> \ No newline at end of file diff --git a/includes/adodb/adodb.inc.php b/includes/adodb/adodb.inc.php new file mode 100644 index 00000000..57d92004 --- /dev/null +++ b/includes/adodb/adodb.inc.php @@ -0,0 +1,4376 @@ +fields is available on EOF + $ADODB_FETCH_MODE, // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default... + $ADODB_GETONE_EOF, + $ADODB_QUOTE_FIELDNAMES; // Allows you to force quotes (backticks) around field names in queries generated by getinsertsql and getupdatesql. + + //============================================================================================== + // GLOBAL SETUP + //============================================================================================== + + $ADODB_EXTENSION = defined('ADODB_EXTENSION'); + + //********************************************************// + /* + Controls $ADODB_FORCE_TYPE mode. Default is ADODB_FORCE_VALUE (3). + Used in GetUpdateSql and GetInsertSql functions. Thx to Niko, nuko#mbnet.fi + + 0 = ignore empty fields. All empty fields in array are ignored. + 1 = force null. All empty, php null and string 'null' fields are changed to sql NULL values. + 2 = force empty. All empty, php null and string 'null' fields are changed to sql empty '' or 0 values. + 3 = force value. Value is left as it is. Php null and string 'null' are set to sql NULL values and empty fields '' are set to empty '' sql values. + */ + define('ADODB_FORCE_IGNORE',0); + define('ADODB_FORCE_NULL',1); + define('ADODB_FORCE_EMPTY',2); + define('ADODB_FORCE_VALUE',3); + //********************************************************// + + + if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) { + + define('ADODB_BAD_RS','

Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;

'); + + // allow [ ] @ ` " and . in table names + define('ADODB_TABLE_REGEX','([]0-9a-z_\:\"\`\.\@\[-]*)'); + + // prefetching used by oracle + if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10); + + + /* + Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native case-names. + This currently works only with mssql, odbc, oci8po and ibase derived drivers. + + 0 = assoc lowercase field names. $rs->fields['orderid'] + 1 = assoc uppercase field names. $rs->fields['ORDERID'] + 2 = use native-case field names. $rs->fields['OrderID'] + */ + + define('ADODB_FETCH_DEFAULT',0); + define('ADODB_FETCH_NUM',1); + define('ADODB_FETCH_ASSOC',2); + define('ADODB_FETCH_BOTH',3); + + if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100); + + // PHP's version scheme makes converting to numbers difficult - workaround + $_adodb_ver = (float) PHP_VERSION; + if ($_adodb_ver >= 5.2) { + define('ADODB_PHPVER',0x5200); + } else if ($_adodb_ver >= 5.0) { + define('ADODB_PHPVER',0x5000); + } else + die("PHP5 or later required. You are running ".PHP_VERSION); + } + + + //if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2); + + + /** + Accepts $src and $dest arrays, replacing string $data + */ + function ADODB_str_replace($src, $dest, $data) + { + if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data); + + $s = reset($src); + $d = reset($dest); + while ($s !== false) { + $data = str_replace($s,$d,$data); + $s = next($src); + $d = next($dest); + } + return $data; + } + + function ADODB_Setup() + { + GLOBAL + $ADODB_vers, // database version + $ADODB_COUNTRECS, // count number of records returned - slows down query + $ADODB_CACHE_DIR, // directory to cache recordsets + $ADODB_FETCH_MODE, + $ADODB_CACHE, + $ADODB_CACHE_CLASS, + $ADODB_FORCE_TYPE, + $ADODB_GETONE_EOF, + $ADODB_QUOTE_FIELDNAMES; + + $ADODB_CACHE_CLASS = 'ADODB_Cache_File'; + $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT; + $ADODB_FORCE_TYPE = ADODB_FORCE_VALUE; + $ADODB_GETONE_EOF = null; + + if (!isset($ADODB_CACHE_DIR)) { + $ADODB_CACHE_DIR = '/tmp'; //(isset($_ENV['TMP'])) ? $_ENV['TMP'] : '/tmp'; + } else { + // do not accept url based paths, eg. http:/ or ftp:/ + if (strpos($ADODB_CACHE_DIR,'://') !== false) + die("Illegal path http:// or ftp://"); + } + + + // Initialize random number generator for randomizing cache flushes + // -- note Since PHP 4.2.0, the seed becomes optional and defaults to a random value if omitted. + srand(((double)microtime())*1000000); + + /** + * ADODB version as a string. + */ + $ADODB_vers = 'V5.06 16 Oct 2008 (c) 2000-2008 John Lim (jlim#natsoft.com). All rights reserved. Released BSD & LGPL.'; + + /** + * Determines whether recordset->RecordCount() is used. + * Set to false for highest performance -- RecordCount() will always return -1 then + * for databases that provide "virtual" recordcounts... + */ + if (!isset($ADODB_COUNTRECS)) $ADODB_COUNTRECS = true; + } + + + //============================================================================================== + // CHANGE NOTHING BELOW UNLESS YOU ARE DESIGNING ADODB + //============================================================================================== + + ADODB_Setup(); + + //============================================================================================== + // CLASS ADOFieldObject + //============================================================================================== + /** + * Helper class for FetchFields -- holds info on a column + */ + class ADOFieldObject { + var $name = ''; + var $max_length=0; + var $type=""; +/* + // additional fields by dannym... (danny_milo@yahoo.com) + var $not_null = false; + // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^ + // so we can as well make not_null standard (leaving it at "false" does not harm anyways) + + var $has_default = false; // this one I have done only in mysql and postgres for now ... + // others to come (dannym) + var $default_value; // default, if any, and supported. Check has_default first. +*/ + } + + // for transaction handling + + function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) + { + //print "Errorno ($fn errno=$errno m=$errmsg) "; + $thisConnection->_transOK = false; + if ($thisConnection->_oldRaiseFn) { + $fn = $thisConnection->_oldRaiseFn; + $fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection); + } + } + + //------------------ + // class for caching + class ADODB_Cache_File { + + var $createdir = true; // requires creation of temp dirs + + function ADODB_Cache_File() + { + global $ADODB_INCLUDED_CSV; + if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php'); + } + + // write serialised recordset to cache item/file + function writecache($filename, $contents, $debug, $secs2cache) + { + return adodb_write_file($filename, $contents,$debug); + } + + // load serialised recordset and unserialise it + function &readcache($filename, &$err, $secs2cache, $rsClass) + { + $rs = csv2rs($filename,$err,$secs2cache,$rsClass); + return $rs; + } + + // flush all items in cache + function flushall($debug=false) + { + global $ADODB_CACHE_DIR; + + $rez = false; + + if (strlen($ADODB_CACHE_DIR) > 1) { + $rez = $this->_dirFlush($ADODB_CACHE_DIR); + if ($debug) DOConnection::outp( "flushall: $dir
\n". $rez."
"); + } + return $rez; + } + + // flush one file in cache + function flushcache($f, $debug=false) + { + if (!@unlink($f)) { + if ($debug) ADOConnection::outp( "flushcache: failed for $f"); + } + } + + function getdirname($hash) + { + global $ADODB_CACHE_DIR; + if (!isset($this->notSafeMode)) $this->notSafeMode = !ini_get('safe_mode'); + return ($this->notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($hash,0,2) : $ADODB_CACHE_DIR; + } + + // create temp directories + function createdir($hash, $debug) + { + $dir = $this->getdirname($hash); + if ($this->notSafeMode && !file_exists($dir)) { + $oldu = umask(0); + if (!@mkdir($dir,0771)) if(!is_dir($dir) && $debug) ADOConnection::outp("Cannot create $dir"); + umask($oldu); + } + + return $dir; + } + + /** + * Private function to erase all of the files and subdirectories in a directory. + * + * Just specify the directory, and tell it if you want to delete the directory or just clear it out. + * Note: $kill_top_level is used internally in the function to flush subdirectories. + */ + function _dirFlush($dir, $kill_top_level = false) + { + if(!$dh = @opendir($dir)) return; + + while (($obj = readdir($dh))) { + if($obj=='.' || $obj=='..') continue; + $f = $dir.'/'.$obj; + + if (strpos($obj,'.cache')) @unlink($f); + if (is_dir($f)) $this->_dirFlush($f, true); + } + if ($kill_top_level === true) @rmdir($dir); + return true; + } + } + + //============================================================================================== + // CLASS ADOConnection + //============================================================================================== + + /** + * Connection object. For connecting to databases, and executing queries. + */ + class ADOConnection { + // + // PUBLIC VARS + // + var $dataProvider = 'native'; + var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql + var $database = ''; /// Name of database to be used. + var $host = ''; /// The hostname of the database server + var $user = ''; /// The username which is used to connect to the database server. + var $password = ''; /// Password for the username. For security, we no longer store it. + var $debug = false; /// if set to true will output sql statements + var $maxblobsize = 262144; /// maximum size of blobs or large text fields (262144 = 256K)-- some db's die otherwise like foxpro + var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase + var $substr = 'substr'; /// substring operator + var $length = 'length'; /// string length ofperator + var $random = 'rand()'; /// random function + var $upperCase = 'upper'; /// uppercase function + var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database + var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /// used by DBTimeStamp as the default timestamp fmt. + var $true = '1'; /// string that represents TRUE for a database + var $false = '0'; /// string that represents FALSE for a database + var $replaceQuote = "\\'"; /// string to use to replace quotes + var $nameQuote = '"'; /// string to use to quote identifiers and names + var $charSet=false; /// character set to use - only for interbase, postgres and oci8 + var $metaDatabasesSQL = ''; + var $metaTablesSQL = ''; + var $uniqueOrderBy = false; /// All order by columns have to be unique + var $emptyDate = ' '; + var $emptyTimeStamp = ' '; + var $lastInsID = false; + //-- + var $hasInsertID = false; /// supports autoincrement ID? + var $hasAffectedRows = false; /// supports affected rows for update/delete? + var $hasTop = false; /// support mssql/access SELECT TOP 10 * FROM TABLE + var $hasLimit = false; /// support pgsql/mysql SELECT * FROM TABLE LIMIT 10 + var $readOnly = false; /// this is a readonly database - used by phpLens + var $hasMoveFirst = false; /// has ability to run MoveFirst(), scrolling backwards + var $hasGenID = false; /// can generate sequences using GenID(); + var $hasTransactions = true; /// has transactions + //-- + var $genID = 0; /// sequence id used by GenID(); + var $raiseErrorFn = false; /// error function to call + var $isoDates = false; /// accepts dates in ISO format + var $cacheSecs = 3600; /// cache for 1 hour + + // memcache + var $memCache = false; /// should we use memCache instead of caching in files + var $memCacheHost; /// memCache host + var $memCachePort = 11211; /// memCache port + var $memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib) + + var $sysDate = false; /// name of function that returns the current date + var $sysTimeStamp = false; /// name of function that returns the current timestamp + var $arrayClass = 'ADORecordSet_array'; /// name of class used to generate array recordsets, which are pre-downloaded recordsets + + var $noNullStrings = false; /// oracle specific stuff - if true ensures that '' is converted to ' ' + var $numCacheHits = 0; + var $numCacheMisses = 0; + var $pageExecuteCountRows = true; + var $uniqueSort = false; /// indicates that all fields in order by must be unique + var $leftOuter = false; /// operator to use for left outer join in WHERE clause + var $rightOuter = false; /// operator to use for right outer join in WHERE clause + var $ansiOuter = false; /// whether ansi outer join syntax supported + var $autoRollback = false; // autoRollback on PConnect(). + var $poorAffectedRows = false; // affectedRows not working or unreliable + + var $fnExecute = false; + var $fnCacheExecute = false; + var $blobEncodeType = false; // false=not required, 'I'=encode to integer, 'C'=encode to char + var $rsPrefix = "ADORecordSet_"; + + var $autoCommit = true; /// do not modify this yourself - actually private + var $transOff = 0; /// temporarily disable transactions + var $transCnt = 0; /// count of nested transactions + + var $fetchMode=false; + + var $null2null = 'null'; // in autoexecute/getinsertsql/getupdatesql, this value will be converted to a null + // + // PRIVATE VARS + // + var $_oldRaiseFn = false; + var $_transOK = null; + var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. + var $_errorMsg = false; /// A variable which was used to keep the returned last error message. The value will + /// then returned by the errorMsg() function + var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8 + var $_queryID = false; /// This variable keeps the last created result link identifier + + var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection. */ + var $_bindInputArray = false; /// set to true if ADOConnection.Execute() permits binding of array parameters. + var $_evalAll = false; + var $_affected = false; + var $_logsql = false; + var $_transmode = ''; // transaction mode + + + + /** + * Constructor + */ + function ADOConnection() + { + die('Virtual Class -- cannot instantiate'); + } + + static function Version() + { + global $ADODB_vers; + + return (float) substr($ADODB_vers,1); + } + + /** + Get server version info... + + @returns An array with 2 elements: $arr['string'] is the description string, + and $arr[version] is the version (also a string). + */ + function ServerInfo() + { + return array('description' => '', 'version' => ''); + } + + function IsConnected() + { + return !empty($this->_connectionID); + } + + function _findvers($str) + { + if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return $arr[1]; + else return ''; + } + + /** + * All error messages go through this bottleneck function. + * You can define your own handler by defining the function name in ADODB_OUTP. + */ + static function outp($msg,$newline=true) + { + global $ADODB_FLUSH,$ADODB_OUTP; + + if (defined('ADODB_OUTP')) { + $fn = ADODB_OUTP; + $fn($msg,$newline); + return; + } else if (isset($ADODB_OUTP)) { + $fn = $ADODB_OUTP; + $fn($msg,$newline); + return; + } + + if ($newline) $msg .= "
\n"; + + if (isset($_SERVER['HTTP_USER_AGENT']) || !$newline) echo $msg; + else echo strip_tags($msg); + + + if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan + + } + + function Time() + { + $rs = $this->_Execute("select $this->sysTimeStamp"); + if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); + + return false; + } + + /** + * Connect to database + * + * @param [argHostname] Host to connect to + * @param [argUsername] Userid to login + * @param [argPassword] Associated password + * @param [argDatabaseName] database + * @param [forceNew] force new connection + * + * @return true or false + */ + function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false) + { + if ($argHostname != "") $this->host = $argHostname; + if ($argUsername != "") $this->user = $argUsername; + if ($argPassword != "") $this->password = $argPassword; // not stored for security reasons + if ($argDatabaseName != "") $this->database = $argDatabaseName; + + $this->_isPersistentConnection = false; + + global $ADODB_CACHE; + if (empty($ADODB_CACHE)) $this->_CreateCache(); + + if ($forceNew) { + if ($rez=$this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; + } else { + if ($rez=$this->_connect($this->host, $this->user, $this->password, $this->database)) return true; + } + if (isset($rez)) { + $err = $this->ErrorMsg(); + if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; + $ret = false; + } else { + $err = "Missing extension for ".$this->dataProvider; + $ret = 0; + } + if ($fn = $this->raiseErrorFn) + $fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); + + + $this->_connectionID = false; + if ($this->debug) ADOConnection::outp( $this->host.': '.$err); + return $ret; + } + + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName); + } + + + /** + * Always force a new connection to database - currently only works with oracle + * + * @param [argHostname] Host to connect to + * @param [argUsername] Userid to login + * @param [argPassword] Associated password + * @param [argDatabaseName] database + * + * @return true or false + */ + function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") + { + return $this->Connect($argHostname, $argUsername, $argPassword, $argDatabaseName, true); + } + + /** + * Establish persistent connect to database + * + * @param [argHostname] Host to connect to + * @param [argUsername] Userid to login + * @param [argPassword] Associated password + * @param [argDatabaseName] database + * + * @return return true or false + */ + function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") + { + + if (defined('ADODB_NEVER_PERSIST')) + return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName); + + if ($argHostname != "") $this->host = $argHostname; + if ($argUsername != "") $this->user = $argUsername; + if ($argPassword != "") $this->password = $argPassword; + if ($argDatabaseName != "") $this->database = $argDatabaseName; + + $this->_isPersistentConnection = true; + + global $ADODB_CACHE; + if (empty($ADODB_CACHE)) $this->_CreateCache(); + + if ($rez = $this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; + if (isset($rez)) { + $err = $this->ErrorMsg(); + if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; + $ret = false; + } else { + $err = "Missing extension for ".$this->dataProvider; + $ret = 0; + } + if ($fn = $this->raiseErrorFn) { + $fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); + } + + $this->_connectionID = false; + if ($this->debug) ADOConnection::outp( $this->host.': '.$err); + return $ret; + } + + function outp_throw($msg,$src='WARN',$sql='') + { + if (defined('ADODB_ERROR_HANDLER') && ADODB_ERROR_HANDLER == 'adodb_throw') { + adodb_throw($this->databaseType,$src,-9999,$msg,$sql,false,$this); + return; + } + ADOConnection::outp($msg); + } + + // create cache class. Code is backward compat with old memcache implementation + function _CreateCache() + { + global $ADODB_CACHE, $ADODB_CACHE_CLASS; + + if ($this->memCache) { + global $ADODB_INCLUDED_MEMCACHE; + + if (empty($ADODB_INCLUDED_MEMCACHE)) include(ADODB_DIR.'/adodb-memcache.lib.inc.php'); + $ADODB_CACHE = new ADODB_Cache_MemCache($this); + } else + $ADODB_CACHE = new $ADODB_CACHE_CLASS($this); + + } + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysDate; + return $col; // child class implement + } + + /** + * Should prepare the sql statement and return the stmt resource. + * For databases that do not support this, we return the $sql. To ensure + * compatibility with databases that do not support prepare: + * + * $stmt = $db->Prepare("insert into table (id, name) values (?,?)"); + * $db->Execute($stmt,array(1,'Jill')) or die('insert failed'); + * $db->Execute($stmt,array(2,'Joe')) or die('insert failed'); + * + * @param sql SQL to send to database + * + * @return return FALSE, or the prepared statement, or the original sql if + * if the database does not support prepare. + * + */ + function Prepare($sql) + { + return $sql; + } + + /** + * Some databases, eg. mssql require a different function for preparing + * stored procedures. So we cannot use Prepare(). + * + * Should prepare the stored procedure and return the stmt resource. + * For databases that do not support this, we return the $sql. To ensure + * compatibility with databases that do not support prepare: + * + * @param sql SQL to send to database + * + * @return return FALSE, or the prepared statement, or the original sql if + * if the database does not support prepare. + * + */ + function PrepareSP($sql,$param=true) + { + return $this->Prepare($sql,$param); + } + + /** + * PEAR DB Compat + */ + function Quote($s) + { + return $this->qstr($s,false); + } + + /** + Requested by "Karsten Dambekalns" + */ + function QMagic($s) + { + return $this->qstr($s,get_magic_quotes_gpc()); + } + + function q(&$s) + { + #if (!empty($this->qNull)) if ($s == 'null') return $s; + $s = $this->qstr($s,false); + } + + /** + * PEAR DB Compat - do not use internally. + */ + function ErrorNative() + { + return $this->ErrorNo(); + } + + + /** + * PEAR DB Compat - do not use internally. + */ + function nextId($seq_name) + { + return $this->GenID($seq_name); + } + + /** + * Lock a row, will escalate and lock the table if row locking not supported + * will normally free the lock at the end of the transaction + * + * @param $table name of table to lock + * @param $where where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock + */ + function RowLock($table,$where) + { + return false; + } + + function CommitLock($table) + { + return $this->CommitTrans(); + } + + function RollbackLock($table) + { + return $this->RollbackTrans(); + } + + /** + * PEAR DB Compat - do not use internally. + * + * The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical + * for easy porting :-) + * + * @param mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM + * @returns The previous fetch mode + */ + function SetFetchMode($mode) + { + $old = $this->fetchMode; + $this->fetchMode = $mode; + + if ($old === false) { + global $ADODB_FETCH_MODE; + return $ADODB_FETCH_MODE; + } + return $old; + } + + + /** + * PEAR DB Compat - do not use internally. + */ + function Query($sql, $inputarr=false) + { + $rs = $this->Execute($sql, $inputarr); + if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error(); + return $rs; + } + + + /** + * PEAR DB Compat - do not use internally + */ + function LimitQuery($sql, $offset, $count, $params=false) + { + $rs = $this->SelectLimit($sql, $count, $offset, $params); + if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error(); + return $rs; + } + + + /** + * PEAR DB Compat - do not use internally + */ + function Disconnect() + { + return $this->Close(); + } + + /* + Returns placeholder for parameter, eg. + $DB->Param('a') + + will return ':a' for Oracle, and '?' for most other databases... + + For databases that require positioned params, eg $1, $2, $3 for postgresql, + pass in Param(false) before setting the first parameter. + */ + function Param($name,$type='C') + { + return '?'; + } + + /* + InParameter and OutParameter are self-documenting versions of Parameter(). + */ + function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) + { + return $this->Parameter($stmt,$var,$name,false,$maxLen,$type); + } + + /* + */ + function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) + { + return $this->Parameter($stmt,$var,$name,true,$maxLen,$type); + + } + + + /* + Usage in oracle + $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); + $db->Parameter($stmt,$id,'myid'); + $db->Parameter($stmt,$group,'group',64); + $db->Execute(); + + @param $stmt Statement returned by Prepare() or PrepareSP(). + @param $var PHP variable to bind to + @param $name Name of stored procedure variable name to bind to. + @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. + @param [$maxLen] Holds an maximum length of the variable. + @param [$type] The data type of $var. Legal values depend on driver. + + */ + function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) + { + return false; + } + + + function IgnoreErrors($saveErrs=false) + { + if (!$saveErrs) { + $saveErrs = array($this->raiseErrorFn,$this->_transOK); + $this->raiseErrorFn = false; + return $saveErrs; + } else { + $this->raiseErrorFn = $saveErrs[0]; + $this->_transOK = $saveErrs[1]; + } + } + + /** + Improved method of initiating a transaction. Used together with CompleteTrans(). + Advantages include: + + a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans. + Only the outermost block is treated as a transaction.
+ b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.
+ c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block + are disabled, making it backward compatible. + */ + function StartTrans($errfn = 'ADODB_TransMonitor') + { + if ($this->transOff > 0) { + $this->transOff += 1; + return; + } + + $this->_oldRaiseFn = $this->raiseErrorFn; + $this->raiseErrorFn = $errfn; + $this->_transOK = true; + + if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans"); + $this->BeginTrans(); + $this->transOff = 1; + } + + + /** + Used together with StartTrans() to end a transaction. Monitors connection + for sql errors, and will commit or rollback as appropriate. + + @autoComplete if true, monitor sql errors and commit and rollback as appropriate, + and if set to false force rollback even if no SQL error detected. + @returns true on commit, false on rollback. + */ + function CompleteTrans($autoComplete = true) + { + if ($this->transOff > 1) { + $this->transOff -= 1; + return true; + } + $this->raiseErrorFn = $this->_oldRaiseFn; + + $this->transOff = 0; + if ($this->_transOK && $autoComplete) { + if (!$this->CommitTrans()) { + $this->_transOK = false; + if ($this->debug) ADOConnection::outp("Smart Commit failed"); + } else + if ($this->debug) ADOConnection::outp("Smart Commit occurred"); + } else { + $this->_transOK = false; + $this->RollbackTrans(); + if ($this->debug) ADOCOnnection::outp("Smart Rollback occurred"); + } + + return $this->_transOK; + } + + /* + At the end of a StartTrans/CompleteTrans block, perform a rollback. + */ + function FailTrans() + { + if ($this->debug) + if ($this->transOff == 0) { + ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans"); + } else { + ADOConnection::outp("FailTrans was called"); + adodb_backtrace(); + } + $this->_transOK = false; + } + + /** + Check if transaction has failed, only for Smart Transactions. + */ + function HasFailedTrans() + { + if ($this->transOff > 0) return $this->_transOK == false; + return false; + } + + /** + * Execute SQL + * + * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) + * @param [inputarr] holds the input data to bind to. Null elements will be set to null. + * @return RecordSet or false + */ + function Execute($sql,$inputarr=false) + { + if ($this->fnExecute) { + $fn = $this->fnExecute; + $ret = $fn($this,$sql,$inputarr); + if (isset($ret)) return $ret; + } + if ($inputarr) { + if (!is_array($inputarr)) $inputarr = array($inputarr); + + $element0 = reset($inputarr); + # is_object check because oci8 descriptors can be passed in + $array_2d = is_array($element0) && !is_object(reset($element0)); + //remove extra memory copy of input -mikefedyk + unset($element0); + + if (!is_array($sql) && !$this->_bindInputArray) { + $sqlarr = explode('?',$sql); + + if (!$array_2d) $inputarr = array($inputarr); + foreach($inputarr as $arr) { + $sql = ''; $i = 0; + //Use each() instead of foreach to reduce memory usage -mikefedyk + while(list(, $v) = each($arr)) { + $sql .= $sqlarr[$i]; + // from Ron Baldwin + // Only quote string types + $typ = gettype($v); + if ($typ == 'string') + //New memory copy of input created here -mikefedyk + $sql .= $this->qstr($v); + else if ($typ == 'double') + $sql .= str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1 + else if ($typ == 'boolean') + $sql .= $v ? $this->true : $this->false; + else if ($typ == 'object') { + if (method_exists($v, '__toString')) $sql .= $this->qstr($v->__toString()); + else $sql .= $this->qstr((string) $v); + } else if ($v === null) + $sql .= 'NULL'; + else + $sql .= $v; + $i += 1; + } + if (isset($sqlarr[$i])) { + $sql .= $sqlarr[$i]; + if ($i+1 != sizeof($sqlarr)) $this->outp_throw( "Input Array does not match ?: ".htmlspecialchars($sql),'Execute'); + } else if ($i != sizeof($sqlarr)) + $this->outp_throw( "Input array does not match ?: ".htmlspecialchars($sql),'Execute'); + + $ret = $this->_Execute($sql); + if (!$ret) return $ret; + } + } else { + if ($array_2d) { + if (is_string($sql)) + $stmt = $this->Prepare($sql); + else + $stmt = $sql; + + foreach($inputarr as $arr) { + $ret = $this->_Execute($stmt,$arr); + if (!$ret) return $ret; + } + } else { + $ret = $this->_Execute($sql,$inputarr); + } + } + } else { + $ret = $this->_Execute($sql,false); + } + + return $ret; + } + + + function _Execute($sql,$inputarr=false) + { + if ($this->debug) { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + $this->_queryID = _adodb_debug_execute($this, $sql,$inputarr); + } else { + $this->_queryID = @$this->_query($sql,$inputarr); + } + + /************************ + // OK, query executed + *************************/ + + if ($this->_queryID === false) { // error handling if query fails + if ($this->debug == 99) adodb_backtrace(true,5); + $fn = $this->raiseErrorFn; + if ($fn) { + $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this); + } + $false = false; + return $false; + } + + if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead + $rsclass = $this->rsPrefix.'empty'; + $rs = (class_exists($rsclass)) ? new $rsclass(): new ADORecordSet_empty(); + + return $rs; + } + + // return real recordset from select statement + $rsclass = $this->rsPrefix.$this->databaseType; + $rs = new $rsclass($this->_queryID,$this->fetchMode); + $rs->connection = $this; // Pablo suggestion + $rs->Init(); + if (is_array($sql)) $rs->sql = $sql[0]; + else $rs->sql = $sql; + if ($rs->_numOfRows <= 0) { + global $ADODB_COUNTRECS; + if ($ADODB_COUNTRECS) { + if (!$rs->EOF) { + $rs = $this->_rs2rs($rs,-1,-1,!is_array($sql)); + $rs->_queryID = $this->_queryID; + } else + $rs->_numOfRows = 0; + } + } + return $rs; + } + + function CreateSequence($seqname='adodbseq',$startID=1) + { + if (empty($this->_genSeqSQL)) return false; + return $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID)); + } + + function DropSequence($seqname='adodbseq') + { + if (empty($this->_dropSeqSQL)) return false; + return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); + } + + /** + * Generates a sequence id and stores it in $this->genID; + * GenID is only available if $this->hasGenID = true; + * + * @param seqname name of sequence to use + * @param startID if sequence does not exist, start at this ID + * @return 0 if not supported, otherwise a sequence id + */ + function GenID($seqname='adodbseq',$startID=1) + { + if (!$this->hasGenID) { + return 0; // formerly returns false pre 1.60 + } + + $getnext = sprintf($this->_genIDSQL,$seqname); + + $holdtransOK = $this->_transOK; + + $save_handler = $this->raiseErrorFn; + $this->raiseErrorFn = ''; + @($rs = $this->Execute($getnext)); + $this->raiseErrorFn = $save_handler; + + if (!$rs) { + $this->_transOK = $holdtransOK; //if the status was ok before reset + $createseq = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID)); + $rs = $this->Execute($getnext); + } + if ($rs && !$rs->EOF) $this->genID = reset($rs->fields); + else $this->genID = 0; // false + + if ($rs) $rs->Close(); + + return $this->genID; + } + + /** + * @param $table string name of the table, not needed by all databases (eg. mysql), default '' + * @param $column string name of the column, not needed by all databases (eg. mysql), default '' + * @return the last inserted ID. Not all databases support this. + */ + function Insert_ID($table='',$column='') + { + if ($this->_logsql && $this->lastInsID) return $this->lastInsID; + if ($this->hasInsertID) return $this->_insertid($table,$column); + if ($this->debug) { + ADOConnection::outp( '

Insert_ID error

'); + adodb_backtrace(); + } + return false; + } + + + /** + * Portable Insert ID. Pablo Roca + * + * @return the last inserted ID. All databases support this. But aware possible + * problems in multiuser environments. Heavy test this before deploying. + */ + function PO_Insert_ID($table="", $id="") + { + if ($this->hasInsertID){ + return $this->Insert_ID($table,$id); + } else { + return $this->GetOne("SELECT MAX($id) FROM $table"); + } + } + + /** + * @return # rows affected by UPDATE/DELETE + */ + function Affected_Rows() + { + if ($this->hasAffectedRows) { + if ($this->fnExecute === 'adodb_log_sql') { + if ($this->_logsql && $this->_affected !== false) return $this->_affected; + } + $val = $this->_affectedrows(); + return ($val < 0) ? false : $val; + } + + if ($this->debug) ADOConnection::outp( '

Affected_Rows error

',false); + return false; + } + + + /** + * @return the last error message + */ + function ErrorMsg() + { + if ($this->_errorMsg) return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg; + else return ''; + } + + + /** + * @return the last error number. Normally 0 means no error. + */ + function ErrorNo() + { + return ($this->_errorMsg) ? -1 : 0; + } + + function MetaError($err=false) + { + include_once(ADODB_DIR."/adodb-error.inc.php"); + if ($err === false) $err = $this->ErrorNo(); + return adodb_error($this->dataProvider,$this->databaseType,$err); + } + + function MetaErrorMsg($errno) + { + include_once(ADODB_DIR."/adodb-error.inc.php"); + return adodb_errormsg($errno); + } + + /** + * @returns an array with the primary key columns in it. + */ + function MetaPrimaryKeys($table, $owner=false) + { + // owner not used in base class - see oci8 + $p = array(); + $objs = $this->MetaColumns($table); + if ($objs) { + foreach($objs as $v) { + if (!empty($v->primary_key)) + $p[] = $v->name; + } + } + if (sizeof($p)) return $p; + if (function_exists('ADODB_VIEW_PRIMARYKEYS')) + return ADODB_VIEW_PRIMARYKEYS($this->databaseType, $this->database, $table, $owner); + return false; + } + + /** + * @returns assoc array where keys are tables, and values are foreign keys + */ + function MetaForeignKeys($table, $owner=false, $upper=false) + { + return false; + } + /** + * Choose a database to connect to. Many databases do not support this. + * + * @param dbName is the name of the database to select + * @return true or false + */ + function SelectDB($dbName) + {return false;} + + + /** + * Will select, getting rows from $offset (1-based), for $nrows. + * This simulates the MySQL "select * from table limit $offset,$nrows" , and + * the PostgreSQL "select * from table limit $nrows offset $offset". Note that + * MySQL and PostgreSQL parameter ordering is the opposite of the other. + * eg. + * SelectLimit('select * from table',3); will return rows 1 to 3 (1-based) + * SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based) + * + * Uses SELECT TOP for Microsoft databases (when $this->hasTop is set) + * BUG: Currently SelectLimit fails with $sql with LIMIT or TOP clause already set + * + * @param sql + * @param [offset] is the row to start calculations from (1-based) + * @param [nrows] is the number of rows to get + * @param [inputarr] array of bind variables + * @param [secs2cache] is a private parameter only used by jlim + * @return the recordset ($rs->databaseType == 'array') + */ + function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) + { + if ($this->hasTop && $nrows > 0) { + // suggested by Reinhard Balling. Access requires top after distinct + // Informix requires first before distinct - F Riosa + $ismssql = (strpos($this->databaseType,'mssql') !== false); + if ($ismssql) $isaccess = false; + else $isaccess = (strpos($this->databaseType,'access') !== false); + + if ($offset <= 0) { + + // access includes ties in result + if ($isaccess) { + $sql = preg_replace( + '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql); + + if ($secs2cache != 0) { + $ret = $this->CacheExecute($secs2cache, $sql,$inputarr); + } else { + $ret = $this->Execute($sql,$inputarr); + } + return $ret; // PHP5 fix + } else if ($ismssql){ + $sql = preg_replace( + '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql); + } else { + $sql = preg_replace( + '/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql); + } + } else { + $nn = $nrows + $offset; + if ($isaccess || $ismssql) { + $sql = preg_replace( + '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql); + } else { + $sql = preg_replace( + '/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql); + } + } + } + + // if $offset>0, we want to skip rows, and $ADODB_COUNTRECS is set, we buffer rows + // 0 to offset-1 which will be discarded anyway. So we disable $ADODB_COUNTRECS. + global $ADODB_COUNTRECS; + + $savec = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + + + if ($secs2cache != 0) $rs = $this->CacheExecute($secs2cache,$sql,$inputarr); + else $rs = $this->Execute($sql,$inputarr); + + $ADODB_COUNTRECS = $savec; + if ($rs && !$rs->EOF) { + $rs = $this->_rs2rs($rs,$nrows,$offset); + } + //print_r($rs); + return $rs; + } + + /** + * Create serializable recordset. Breaks rs link to connection. + * + * @param rs the recordset to serialize + */ + function SerializableRS(&$rs) + { + $rs2 = $this->_rs2rs($rs); + $ignore = false; + $rs2->connection = $ignore; + + return $rs2; + } + + /** + * Convert database recordset to an array recordset + * input recordset's cursor should be at beginning, and + * old $rs will be closed. + * + * @param rs the recordset to copy + * @param [nrows] number of rows to retrieve (optional) + * @param [offset] offset by number of rows (optional) + * @return the new recordset + */ + function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true) + { + if (! $rs) { + $false = false; + return $false; + } + $dbtype = $rs->databaseType; + if (!$dbtype) { + $rs = $rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ? + return $rs; + } + if (($dbtype == 'array' || $dbtype == 'csv') && $nrows == -1 && $offset == -1) { + $rs->MoveFirst(); + $rs = $rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1-- why ? + return $rs; + } + $flds = array(); + for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) { + $flds[] = $rs->FetchField($i); + } + + $arr = $rs->GetArrayLimit($nrows,$offset); + //print_r($arr); + if ($close) $rs->Close(); + + $arrayClass = $this->arrayClass; + + $rs2 = new $arrayClass(); + $rs2->connection = $this; + $rs2->sql = $rs->sql; + $rs2->dataProvider = $this->dataProvider; + $rs2->InitArrayFields($arr,$flds); + $rs2->fetchMode = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode; + return $rs2; + } + + /* + * Return all rows. Compat with PEAR DB + */ + function GetAll($sql, $inputarr=false) + { + $arr = $this->GetArray($sql,$inputarr); + return $arr; + } + + function GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false) + { + $rs = $this->Execute($sql, $inputarr); + if (!$rs) { + $false = false; + return $false; + } + $arr = $rs->GetAssoc($force_array,$first2cols); + return $arr; + } + + function CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false) + { + if (!is_numeric($secs2cache)) { + $first2cols = $force_array; + $force_array = $inputarr; + } + $rs = $this->CacheExecute($secs2cache, $sql, $inputarr); + if (!$rs) { + $false = false; + return $false; + } + $arr = $rs->GetAssoc($force_array,$first2cols); + return $arr; + } + + /** + * Return first element of first row of sql statement. Recordset is disposed + * for you. + * + * @param sql SQL statement + * @param [inputarr] input bind array + */ + function GetOne($sql,$inputarr=false) + { + global $ADODB_COUNTRECS,$ADODB_GETONE_EOF; + $crecs = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + + $ret = false; + $rs = $this->Execute($sql,$inputarr); + if ($rs) { + if ($rs->EOF) $ret = $ADODB_GETONE_EOF; + else $ret = reset($rs->fields); + + $rs->Close(); + } + $ADODB_COUNTRECS = $crecs; + return $ret; + } + + // $where should include 'WHERE fld=value' + function GetMedian($table, $field,$where = '') + { + $total = $this->GetOne("select count(*) from $table $where"); + if (!$total) return false; + + $midrow = (integer) ($total/2); + $rs = $this->SelectLimit("select $field from $table $where order by 1",1,$midrow); + if ($rs && !$rs->EOF) return reset($rs->fields); + return false; + } + + + function CacheGetOne($secs2cache,$sql=false,$inputarr=false) + { + global $ADODB_GETONE_EOF; + $ret = false; + $rs = $this->CacheExecute($secs2cache,$sql,$inputarr); + if ($rs) { + if ($rs->EOF) $ret = $ADODB_GETONE_EOF; + else $ret = reset($rs->fields); + $rs->Close(); + } + + return $ret; + } + + function GetCol($sql, $inputarr = false, $trim = false) + { + + $rs = $this->Execute($sql, $inputarr); + if ($rs) { + $rv = array(); + if ($trim) { + while (!$rs->EOF) { + $rv[] = trim(reset($rs->fields)); + $rs->MoveNext(); + } + } else { + while (!$rs->EOF) { + $rv[] = reset($rs->fields); + $rs->MoveNext(); + } + } + $rs->Close(); + } else + $rv = false; + return $rv; + } + + function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false) + { + $rs = $this->CacheExecute($secs, $sql, $inputarr); + if ($rs) { + $rv = array(); + if ($trim) { + while (!$rs->EOF) { + $rv[] = trim(reset($rs->fields)); + $rs->MoveNext(); + } + } else { + while (!$rs->EOF) { + $rv[] = reset($rs->fields); + $rs->MoveNext(); + } + } + $rs->Close(); + } else + $rv = false; + + return $rv; + } + + function Transpose(&$rs,$addfieldnames=true) + { + $rs2 = $this->_rs2rs($rs); + $false = false; + if (!$rs2) return $false; + + $rs2->_transpose($addfieldnames); + return $rs2; + } + + /* + Calculate the offset of a date for a particular database and generate + appropriate SQL. Useful for calculating future/past dates and storing + in a database. + + If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour. + */ + function OffsetDate($dayFraction,$date=false) + { + if (!$date) $date = $this->sysDate; + return '('.$date.'+'.$dayFraction.')'; + } + + + /** + * + * @param sql SQL statement + * @param [inputarr] input bind array + */ + function GetArray($sql,$inputarr=false) + { + global $ADODB_COUNTRECS; + + $savec = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + $rs = $this->Execute($sql,$inputarr); + $ADODB_COUNTRECS = $savec; + if (!$rs) + if (defined('ADODB_PEAR')) { + $cls = ADODB_PEAR_Error(); + return $cls; + } else { + $false = false; + return $false; + } + $arr = $rs->GetArray(); + $rs->Close(); + return $arr; + } + + function CacheGetAll($secs2cache,$sql=false,$inputarr=false) + { + $arr = $this->CacheGetArray($secs2cache,$sql,$inputarr); + return $arr; + } + + function CacheGetArray($secs2cache,$sql=false,$inputarr=false) + { + global $ADODB_COUNTRECS; + + $savec = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + $rs = $this->CacheExecute($secs2cache,$sql,$inputarr); + $ADODB_COUNTRECS = $savec; + + if (!$rs) + if (defined('ADODB_PEAR')) { + $cls = ADODB_PEAR_Error(); + return $cls; + } else { + $false = false; + return $false; + } + $arr = $rs->GetArray(); + $rs->Close(); + return $arr; + } + + function GetRandRow($sql, $arr= false) + { + $rezarr = $this->GetAll($sql, $arr); + $sz = sizeof($rezarr); + return $rezarr[abs(rand()) % $sz]; + } + + /** + * Return one row of sql statement. Recordset is disposed for you. + * + * @param sql SQL statement + * @param [inputarr] input bind array + */ + function GetRow($sql,$inputarr=false) + { + global $ADODB_COUNTRECS; + $crecs = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + + $rs = $this->Execute($sql,$inputarr); + + $ADODB_COUNTRECS = $crecs; + if ($rs) { + if (!$rs->EOF) $arr = $rs->fields; + else $arr = array(); + $rs->Close(); + return $arr; + } + + $false = false; + return $false; + } + + function CacheGetRow($secs2cache,$sql=false,$inputarr=false) + { + $rs = $this->CacheExecute($secs2cache,$sql,$inputarr); + if ($rs) { + if (!$rs->EOF) $arr = $rs->fields; + else $arr = array(); + + $rs->Close(); + return $arr; + } + $false = false; + return $false; + } + + /** + * Insert or replace a single record. Note: this is not the same as MySQL's replace. + * ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL. + * Also note that no table locking is done currently, so it is possible that the + * record be inserted twice by two programs... + * + * $this->Replace('products', array('prodname' =>"'Nails'","price" => 3.99), 'prodname'); + * + * $table table name + * $fieldArray associative array of data (you must quote strings yourself). + * $keyCol the primary key field name or if compound key, array of field names + * autoQuote set to true to use a hueristic to quote strings. Works with nulls and numbers + * but does not work with dates nor SQL functions. + * has_autoinc the primary key is an auto-inc field, so skip in insert. + * + * Currently blob replace not supported + * + * returns 0 = fail, 1 = update, 2 = insert + */ + + function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false) + { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + + return _adodb_replace($this, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc); + } + + + /** + * Will select, getting rows from $offset (1-based), for $nrows. + * This simulates the MySQL "select * from table limit $offset,$nrows" , and + * the PostgreSQL "select * from table limit $nrows offset $offset". Note that + * MySQL and PostgreSQL parameter ordering is the opposite of the other. + * eg. + * CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based) + * CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based) + * + * BUG: Currently CacheSelectLimit fails with $sql with LIMIT or TOP clause already set + * + * @param [secs2cache] seconds to cache data, set to 0 to force query. This is optional + * @param sql + * @param [offset] is the row to start calculations from (1-based) + * @param [nrows] is the number of rows to get + * @param [inputarr] array of bind variables + * @return the recordset ($rs->databaseType == 'array') + */ + function CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false) + { + if (!is_numeric($secs2cache)) { + if ($sql === false) $sql = -1; + if ($offset == -1) $offset = false; + // sql, nrows, offset,inputarr + $rs = $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$this->cacheSecs); + } else { + if ($sql === false) $this->outp_throw("Warning: \$sql missing from CacheSelectLimit()",'CacheSelectLimit'); + $rs = $this->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + } + return $rs; + } + + + /** + * Flush cached recordsets that match a particular $sql statement. + * If $sql == false, then we purge all files in the cache. + */ + + /** + * Flush cached recordsets that match a particular $sql statement. + * If $sql == false, then we purge all files in the cache. + */ + function CacheFlush($sql=false,$inputarr=false) + { + global $ADODB_CACHE_DIR, $ADODB_CACHE; + + if (!$sql) { + $ADODB_CACHE->flushall($this->debug); + return; + } + + $f = $this->_gencachename($sql.serialize($inputarr),false); + return $ADODB_CACHE->flushcache($f, $this->debug); + } + + + /** + * Private function to generate filename for caching. + * Filename is generated based on: + * + * - sql statement + * - database type (oci8, ibase, ifx, etc) + * - database name + * - userid + * - setFetchMode (adodb 4.23) + * + * When not in safe mode, we create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR). + * Assuming that we can have 50,000 files per directory with good performance, + * then we can scale to 12.8 million unique cached recordsets. Wow! + */ + function _gencachename($sql,$createdir) + { + global $ADODB_CACHE, $ADODB_CACHE_DIR; + + if ($this->fetchMode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } else { + $mode = $this->fetchMode; + } + $m = md5($sql.$this->databaseType.$this->database.$this->user.$mode); + if (!$ADODB_CACHE->createdir) return $m; + if (!$createdir) $dir = $ADODB_CACHE->getdirname($m); + else $dir = $ADODB_CACHE->createdir($m, $this->debug); + + return $dir.'/adodb_'.$m.'.cache'; + } + + + /** + * Execute SQL, caching recordsets. + * + * @param [secs2cache] seconds to cache data, set to 0 to force query. + * This is an optional parameter. + * @param sql SQL statement to execute + * @param [inputarr] holds the input data to bind to + * @return RecordSet or false + */ + function CacheExecute($secs2cache,$sql=false,$inputarr=false) + { + global $ADODB_CACHE; + + if (!is_numeric($secs2cache)) { + $inputarr = $sql; + $sql = $secs2cache; + $secs2cache = $this->cacheSecs; + } + + if (is_array($sql)) { + $sqlparam = $sql; + $sql = $sql[0]; + } else + $sqlparam = $sql; + + + $md5file = $this->_gencachename($sql.serialize($inputarr),true); + $err = ''; + + if ($secs2cache > 0){ + $rs = &$ADODB_CACHE->readcache($md5file,$err,$secs2cache,$this->arrayClass); + $this->numCacheHits += 1; + } else { + $err='Timeout 1'; + $rs = false; + $this->numCacheMisses += 1; + } + + if (!$rs) { + // no cached rs found + if ($this->debug) { + if (get_magic_quotes_runtime() && !$this->memCache) { + ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :("); + } + if ($this->debug !== -1) ADOConnection::outp( " $md5file cache failure: $err (see sql below)"); + } + + $rs = $this->Execute($sqlparam,$inputarr); + + if ($rs) { + + $eof = $rs->EOF; + $rs = $this->_rs2rs($rs); // read entire recordset into memory immediately + $rs->timeCreated = time(); // used by caching + $txt = _rs2serialize($rs,false,$sql); // serialize + + $ok = $ADODB_CACHE->writecache($md5file,$txt,$this->debug, $secs2cache); + if (!$ok) { + if ($ok === false) { + $em = 'Cache write error'; + $en = -32000; + + if ($fn = $this->raiseErrorFn) { + $fn($this->databaseType,'CacheExecute', $en, $em, $md5file,$sql,$this); + } + } else { + $em = 'Cache file locked warning'; + $en = -32001; + // do not call error handling for just a warning + } + + if ($this->debug) ADOConnection::outp( " ".$em); + } + if ($rs->EOF && !$eof) { + $rs->MoveFirst(); + //$rs = csv2rs($md5file,$err); + $rs->connection = $this; // Pablo suggestion + } + + } else if (!$this->memCache) + $ADODB_CACHE->flushcache($md5file); + } else { + $this->_errorMsg = ''; + $this->_errorCode = 0; + + if ($this->fnCacheExecute) { + $fn = $this->fnCacheExecute; + $fn($this, $secs2cache, $sql, $inputarr); + } + // ok, set cached object found + $rs->connection = $this; // Pablo suggestion + if ($this->debug){ + if ($this->debug == 99) adodb_backtrace(); + $inBrowser = isset($_SERVER['HTTP_USER_AGENT']); + $ttl = $rs->timeCreated + $secs2cache - time(); + $s = is_array($sql) ? $sql[0] : $sql; + if ($inBrowser) $s = ''.htmlspecialchars($s).''; + + ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]"); + } + } + return $rs; + } + + + /* + Similar to PEAR DB's autoExecute(), except that + $mode can be 'INSERT' or 'UPDATE' or DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE + If $mode == 'UPDATE', then $where is compulsory as a safety measure. + + $forceUpdate means that even if the data has not changed, perform update. + */ + function AutoExecute($table, $fields_values, $mode = 'INSERT', $where = FALSE, $forceUpdate=true, $magicq=false) + { + $false = false; + $sql = 'SELECT * FROM '.$table; + if ($where!==FALSE) $sql .= ' WHERE '.$where; + else if ($mode == 'UPDATE' || $mode == 2 /* DB_AUTOQUERY_UPDATE */) { + $this->outp_throw('AutoExecute: Illegal mode=UPDATE with empty WHERE clause','AutoExecute'); + return $false; + } + + $rs = $this->SelectLimit($sql,1); + if (!$rs) return $false; // table does not exist + $rs->tableName = $table; + + switch((string) $mode) { + case 'UPDATE': + case '2': + $sql = $this->GetUpdateSQL($rs, $fields_values, $forceUpdate, $magicq); + break; + case 'INSERT': + case '1': + $sql = $this->GetInsertSQL($rs, $fields_values, $magicq); + break; + default: + $this->outp_throw("AutoExecute: Unknown mode=$mode",'AutoExecute'); + return $false; + } + $ret = false; + if ($sql) $ret = $this->Execute($sql); + if ($ret) $ret = true; + return $ret; + } + + + /** + * Generates an Update Query based on an existing recordset. + * $arrFields is an associative array of fields with the value + * that should be assigned. + * + * Note: This function should only be used on a recordset + * that is run against a single table and sql should only + * be a simple select stmt with no groupby/orderby/limit + * + * "Jonathan Younger" + */ + function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=null) + { + global $ADODB_INCLUDED_LIB; + + //********************************************************// + //This is here to maintain compatibility + //with older adodb versions. Sets force type to force nulls if $forcenulls is set. + if (!isset($force)) { + global $ADODB_FORCE_TYPE; + $force = $ADODB_FORCE_TYPE; + } + //********************************************************// + + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$force); + } + + /** + * Generates an Insert Query based on an existing recordset. + * $arrFields is an associative array of fields with the value + * that should be assigned. + * + * Note: This function should only be used on a recordset + * that is run against a single table. + */ + function GetInsertSQL(&$rs, $arrFields,$magicq=false,$force=null) + { + global $ADODB_INCLUDED_LIB; + if (!isset($force)) { + global $ADODB_FORCE_TYPE; + $force = $ADODB_FORCE_TYPE; + + } + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$force); + } + + + /** + * Update a blob column, given a where clause. There are more sophisticated + * blob handling functions that we could have implemented, but all require + * a very complex API. Instead we have chosen something that is extremely + * simple to understand and use. + * + * Note: $blobtype supports 'BLOB' and 'CLOB', default is BLOB of course. + * + * Usage to update a $blobvalue which has a primary key blob_id=1 into a + * field blobtable.blobcolumn: + * + * UpdateBlob('blobtable', 'blobcolumn', $blobvalue, 'blob_id=1'); + * + * Insert example: + * + * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); + * $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); + */ + + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false; + } + + /** + * Usage: + * UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1'); + * + * $blobtype supports 'BLOB' and 'CLOB' + * + * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); + * $conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1'); + */ + function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') + { + $fd = fopen($path,'rb'); + if ($fd === false) return false; + $val = fread($fd,filesize($path)); + fclose($fd); + return $this->UpdateBlob($table,$column,$val,$where,$blobtype); + } + + function BlobDecode($blob) + { + return $blob; + } + + function BlobEncode($blob) + { + return $blob; + } + + function SetCharSet($charset) + { + return false; + } + + function IfNull( $field, $ifNull ) + { + return " CASE WHEN $field is null THEN $ifNull ELSE $field END "; + } + + function LogSQL($enable=true) + { + include_once(ADODB_DIR.'/adodb-perf.inc.php'); + + if ($enable) $this->fnExecute = 'adodb_log_sql'; + else $this->fnExecute = false; + + $old = $this->_logsql; + $this->_logsql = $enable; + if ($enable && !$old) $this->_affected = false; + return $old; + } + + function GetCharSet() + { + return false; + } + + /** + * Usage: + * UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB'); + * + * $conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)'); + * $conn->UpdateClob('clobtable','clobcol',$clob,'id=1'); + */ + function UpdateClob($table,$column,$val,$where) + { + return $this->UpdateBlob($table,$column,$val,$where,'CLOB'); + } + + // not the fastest implementation - quick and dirty - jlim + // for best performance, use the actual $rs->MetaType(). + function MetaType($t,$len=-1,$fieldobj=false) + { + + if (empty($this->_metars)) { + $rsclass = $this->rsPrefix.$this->databaseType; + $this->_metars = new $rsclass(false,$this->fetchMode); + $this->_metars->connection = $this; + } + return $this->_metars->MetaType($t,$len,$fieldobj); + } + + + /** + * Change the SQL connection locale to a specified locale. + * This is used to get the date formats written depending on the client locale. + */ + function SetDateLocale($locale = 'En') + { + $this->locale = $locale; + switch (strtoupper($locale)) + { + case 'EN': + $this->fmtDate="'Y-m-d'"; + $this->fmtTimeStamp = "'Y-m-d H:i:s'"; + break; + + case 'US': + $this->fmtDate = "'m-d-Y'"; + $this->fmtTimeStamp = "'m-d-Y H:i:s'"; + break; + + case 'PT_BR': + case 'NL': + case 'FR': + case 'RO': + case 'IT': + $this->fmtDate="'d-m-Y'"; + $this->fmtTimeStamp = "'d-m-Y H:i:s'"; + break; + + case 'GE': + $this->fmtDate="'d.m.Y'"; + $this->fmtTimeStamp = "'d.m.Y H:i:s'"; + break; + + default: + $this->fmtDate="'Y-m-d'"; + $this->fmtTimeStamp = "'Y-m-d H:i:s'"; + break; + } + } + + /** + * GetActiveRecordsClass Performs an 'ALL' query + * + * @param mixed $class This string represents the class of the current active record + * @param mixed $table Table used by the active record object + * @param mixed $whereOrderBy Where, order, by clauses + * @param mixed $bindarr + * @param mixed $primkeyArr + * @param array $extra Query extras: limit, offset... + * @param mixed $relations Associative array: table's foreign name, "hasMany", "belongsTo" + * @access public + * @return void + */ + function GetActiveRecordsClass( + $class, $table,$whereOrderBy=false,$bindarr=false, $primkeyArr=false, + $extra=array(), + $relations=array()) + { + global $_ADODB_ACTIVE_DBS; + ## reduce overhead of adodb.inc.php -- moved to adodb-active-record.inc.php + ## if adodb-active-recordx is loaded -- should be no issue as they will probably use Find() + if (!isset($_ADODB_ACTIVE_DBS))include_once(ADODB_DIR.'/adodb-active-record.inc.php'); + return adodb_GetActiveRecordsClass($this, $class, $table, $whereOrderBy, $bindarr, $primkeyArr, $extra, $relations); + } + + function GetActiveRecords($table,$where=false,$bindarr=false,$primkeyArr=false) + { + $arr = $this->GetActiveRecordsClass('ADODB_Active_Record', $table, $where, $bindarr, $primkeyArr); + return $arr; + } + + /** + * Close Connection + */ + function Close() + { + $rez = $this->_close(); + $this->_connectionID = false; + return $rez; + } + + /** + * Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans(). + * + * @return true if succeeded or false if database does not support transactions + */ + function BeginTrans() + { + if ($this->debug) ADOConnection::outp("BeginTrans: Transactions not supported for this driver"); + return false; + } + + /* set transaction mode */ + function SetTransactionMode( $transaction_mode ) + { + $transaction_mode = $this->MetaTransaction($transaction_mode, $this->dataProvider); + $this->_transmode = $transaction_mode; + } +/* +http://msdn2.microsoft.com/en-US/ms173763.aspx +http://dev.mysql.com/doc/refman/5.0/en/innodb-transaction-isolation.html +http://www.postgresql.org/docs/8.1/interactive/sql-set-transaction.html +http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_10005.htm +*/ + function MetaTransaction($mode,$db) + { + $mode = strtoupper($mode); + $mode = str_replace('ISOLATION LEVEL ','',$mode); + + switch($mode) { + + case 'READ UNCOMMITTED': + switch($db) { + case 'oci8': + case 'oracle': + return 'ISOLATION LEVEL READ COMMITTED'; + default: + return 'ISOLATION LEVEL READ UNCOMMITTED'; + } + break; + + case 'READ COMMITTED': + return 'ISOLATION LEVEL READ COMMITTED'; + break; + + case 'REPEATABLE READ': + switch($db) { + case 'oci8': + case 'oracle': + return 'ISOLATION LEVEL SERIALIZABLE'; + default: + return 'ISOLATION LEVEL REPEATABLE READ'; + } + break; + + case 'SERIALIZABLE': + return 'ISOLATION LEVEL SERIALIZABLE'; + break; + + default: + return $mode; + } + } + + /** + * If database does not support transactions, always return true as data always commited + * + * @param $ok set to false to rollback transaction, true to commit + * + * @return true/false. + */ + function CommitTrans($ok=true) + { return true;} + + + /** + * If database does not support transactions, rollbacks always fail, so return false + * + * @return true/false. + */ + function RollbackTrans() + { return false;} + + + /** + * return the databases that the driver can connect to. + * Some databases will return an empty array. + * + * @return an array of database names. + */ + function MetaDatabases() + { + global $ADODB_FETCH_MODE; + + if ($this->metaDatabasesSQL) { + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + $arr = $this->GetCol($this->metaDatabasesSQL); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + return $arr; + } + + return false; + } + + + /** + * @param ttype can either be 'VIEW' or 'TABLE' or false. + * If false, both views and tables are returned. + * "VIEW" returns only views + * "TABLE" returns only tables + * @param showSchema returns the schema/user with the table name, eg. USER.TABLE + * @param mask is the input mask - only supported by oci8 and postgresql + * + * @return array of tables for current database. + */ + function MetaTables($ttype=false,$showSchema=false,$mask=false) + { + global $ADODB_FETCH_MODE; + + + $false = false; + if ($mask) { + return $false; + } + if ($this->metaTablesSQL) { + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + $rs = $this->Execute($this->metaTablesSQL); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + if ($rs === false) return $false; + $arr = $rs->GetArray(); + $arr2 = array(); + + if ($hast = ($ttype && isset($arr[0][1]))) { + $showt = strncmp($ttype,'T',1); + } + + for ($i=0; $i < sizeof($arr); $i++) { + if ($hast) { + if ($showt == 0) { + if (strncmp($arr[$i][1],'T',1) == 0) $arr2[] = trim($arr[$i][0]); + } else { + if (strncmp($arr[$i][1],'V',1) == 0) $arr2[] = trim($arr[$i][0]); + } + } else + $arr2[] = trim($arr[$i][0]); + } + $rs->Close(); + return $arr2; + } + return $false; + } + + + function _findschema(&$table,&$schema) + { + if (!$schema && ($at = strpos($table,'.')) !== false) { + $schema = substr($table,0,$at); + $table = substr($table,$at+1); + } + } + + /** + * List columns in a database as an array of ADOFieldObjects. + * See top of file for definition of object. + * + * @param $table table name to query + * @param $normalize makes table name case-insensitive (required by some databases) + * @schema is optional database schema to use - not supported by all databases. + * + * @return array of ADOFieldObjects for current table. + */ + function MetaColumns($table,$normalize=true) + { + global $ADODB_FETCH_MODE; + + $false = false; + + if (!empty($this->metaColumnsSQL)) { + + $schema = false; + $this->_findschema($table,$schema); + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + $rs = $this->Execute(sprintf($this->metaColumnsSQL,($normalize)?strtoupper($table):$table)); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + if ($rs === false || $rs->EOF) return $false; + + $retarr = array(); + while (!$rs->EOF) { //print_r($rs->fields); + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $fld->type = $rs->fields[1]; + if (isset($rs->fields[3]) && $rs->fields[3]) { + if ($rs->fields[3]>0) $fld->max_length = $rs->fields[3]; + $fld->scale = $rs->fields[4]; + if ($fld->scale>0) $fld->max_length += 1; + } else + $fld->max_length = $rs->fields[2]; + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + else $retarr[strtoupper($fld->name)] = $fld; + $rs->MoveNext(); + } + $rs->Close(); + return $retarr; + } + return $false; + } + + /** + * List indexes on a table as an array. + * @param table table name to query + * @param primary true to only show primary keys. Not actually used for most databases + * + * @return array of indexes on current table. Each element represents an index, and is itself an associative array. + + Array ( + [name_of_index] => Array + ( + [unique] => true or false + [columns] => Array + ( + [0] => firstname + [1] => lastname + ) + ) + */ + function MetaIndexes($table, $primary = false, $owner = false) + { + $false = false; + return $false; + } + + /** + * List columns names in a table as an array. + * @param table table name to query + * + * @return array of column names for current table. + */ + function MetaColumnNames($table, $numIndexes=false,$useattnum=false /* only for postgres */) + { + $objarr = $this->MetaColumns($table); + if (!is_array($objarr)) { + $false = false; + return $false; + } + $arr = array(); + if ($numIndexes) { + $i = 0; + if ($useattnum) { + foreach($objarr as $v) + $arr[$v->attnum] = $v->name; + + } else + foreach($objarr as $v) $arr[$i++] = $v->name; + } else + foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name; + + return $arr; + } + + /** + * Different SQL databases used different methods to combine strings together. + * This function provides a wrapper. + * + * param s variable number of string parameters + * + * Usage: $db->Concat($str1,$str2); + * + * @return concatenated string + */ + function Concat() + { + $arr = func_get_args(); + return implode($this->concat_operator, $arr); + } + + + /** + * Converts a date "d" to a string that the database can understand. + * + * @param d a date in Unix date time format. + * + * @return date string in database date format + */ + function DBDate($d, $isfld=false) + { + if (empty($d) && $d !== 0) return 'null'; + if ($isfld) return $d; + + if (is_string($d) && !is_numeric($d)) { + if ($d === 'null' || strncmp($d,"'",1) === 0) return $d; + if ($this->isoDates) return "'$d'"; + $d = ADOConnection::UnixDate($d); + } + + return adodb_date($this->fmtDate,$d); + } + + function BindDate($d) + { + $d = $this->DBDate($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + function BindTimeStamp($d) + { + $d = $this->DBTimeStamp($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + + /** + * Converts a timestamp "ts" to a string that the database can understand. + * + * @param ts a timestamp in Unix date time format. + * + * @return timestamp string in database timestamp format + */ + function DBTimeStamp($ts,$isfld=false) + { + if (empty($ts) && $ts !== 0) return 'null'; + if ($isfld) return $ts; + + # strlen(14) allows YYYYMMDDHHMMSS format + if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14)) + return adodb_date($this->fmtTimeStamp,$ts); + + if ($ts === 'null') return $ts; + if ($this->isoDates && strlen($ts) !== 14) return "'$ts'"; + + $ts = ADOConnection::UnixTimeStamp($ts); + return adodb_date($this->fmtTimeStamp,$ts); + } + + /** + * Also in ADORecordSet. + * @param $v is a date string in YYYY-MM-DD format + * + * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format + */ + static function UnixDate($v) + { + if (is_object($v)) { + // odbtp support + //( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 ) + return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year); + } + + if (is_numeric($v) && strlen($v) !== 8) return $v; + if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", + ($v), $rr)) return false; + + if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; + // h-m-s-MM-DD-YY + return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); + } + + + /** + * Also in ADORecordSet. + * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format + * + * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format + */ + static function UnixTimeStamp($v) + { + if (is_object($v)) { + // odbtp support + //( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 ) + return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year); + } + + if (!preg_match( + "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", + ($v), $rr)) return false; + + if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0; + + // h-m-s-MM-DD-YY + if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); + return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); + } + + /** + * Also in ADORecordSet. + * + * Format database date based on user defined format. + * + * @param v is the character date in YYYY-MM-DD format, returned by database + * @param fmt is the format to apply to it, using date() + * + * @return a date formated as user desires + */ + + function UserDate($v,$fmt='Y-m-d',$gmt=false) + { + $tt = $this->UnixDate($v); + + // $tt == -1 if pre TIMESTAMP_FIRST_YEAR + if (($tt === false || $tt == -1) && $v != false) return $v; + else if ($tt == 0) return $this->emptyDate; + else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR + } + + return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt); + + } + + /** + * + * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format + * @param fmt is the format to apply to it, using date() + * + * @return a timestamp formated as user desires + */ + function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false) + { + if (!isset($v)) return $this->emptyTimeStamp; + # strlen(14) allows YYYYMMDDHHMMSS format + if (is_numeric($v) && strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v); + $tt = $this->UnixTimeStamp($v); + // $tt == -1 if pre TIMESTAMP_FIRST_YEAR + if (($tt === false || $tt == -1) && $v != false) return $v; + if ($tt == 0) return $this->emptyTimeStamp; + return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt); + } + + function escape($s,$magic_quotes=false) + { + return $this->addq($s,$magic_quotes); + } + + /** + * Quotes a string, without prefixing nor appending quotes. + */ + function addq($s,$magic_quotes=false) + { + if (!$magic_quotes) { + + if ($this->replaceQuote[0] == '\\'){ + // only since php 4.0.5 + $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); + //$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s)); + } + return str_replace("'",$this->replaceQuote,$s); + } + + // undo magic quotes for " + $s = str_replace('\\"','"',$s); + + if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything + return $s; + else {// change \' to '' for sybase/mssql + $s = str_replace('\\\\','\\',$s); + return str_replace("\\'",$this->replaceQuote,$s); + } + } + + /** + * Correctly quotes a string so that all strings are escaped. We prefix and append + * to the string single-quotes. + * An example is $db->qstr("Don't bother",magic_quotes_runtime()); + * + * @param s the string to quote + * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). + * This undoes the stupidity of magic quotes for GPC. + * + * @return quoted string to be sent back to database + */ + function qstr($s,$magic_quotes=false) + { + if (!$magic_quotes) { + + if ($this->replaceQuote[0] == '\\'){ + // only since php 4.0.5 + $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); + //$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s)); + } + return "'".str_replace("'",$this->replaceQuote,$s)."'"; + } + + // undo magic quotes for " + $s = str_replace('\\"','"',$s); + + if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything + return "'$s'"; + else {// change \' to '' for sybase/mssql + $s = str_replace('\\\\','\\',$s); + return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; + } + } + + + /** + * Will select the supplied $page number from a recordset, given that it is paginated in pages of + * $nrows rows per page. It also saves two boolean values saying if the given page is the first + * and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination. + * + * See readme.htm#ex8 for an example of usage. + * + * @param sql + * @param nrows is the number of rows per page to get + * @param page is the page number to get (1-based) + * @param [inputarr] array of bind variables + * @param [secs2cache] is a private parameter only used by jlim + * @return the recordset ($rs->databaseType == 'array') + * + * NOTE: phpLens uses a different algorithm and does not use PageExecute(). + * + */ + function PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0) + { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + if ($this->pageExecuteCountRows) $rs = _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache); + else $rs = _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache); + return $rs; + } + + + /** + * Will select the supplied $page number from a recordset, given that it is paginated in pages of + * $nrows rows per page. It also saves two boolean values saying if the given page is the first + * and/or last one of the recordset. Added by Iván Oliva to provide recordset pagination. + * + * @param secs2cache seconds to cache data, set to 0 to force query + * @param sql + * @param nrows is the number of rows per page to get + * @param page is the page number to get (1-based) + * @param [inputarr] array of bind variables + * @return the recordset ($rs->databaseType == 'array') + */ + function CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false) + { + /*switch($this->dataProvider) { + case 'postgres': + case 'mysql': + break; + default: $secs2cache = 0; break; + }*/ + $rs = $this->PageExecute($sql,$nrows,$page,$inputarr,$secs2cache); + return $rs; + } + +} // end class ADOConnection + + + + //============================================================================================== + // CLASS ADOFetchObj + //============================================================================================== + + /** + * Internal placeholder for record objects. Used by ADORecordSet->FetchObj(). + */ + class ADOFetchObj { + }; + + //============================================================================================== + // CLASS ADORecordSet_empty + //============================================================================================== + + class ADODB_Iterator_empty implements Iterator { + + private $rs; + + function __construct($rs) + { + $this->rs = $rs; + } + function rewind() + { + } + + function valid() + { + return !$this->rs->EOF; + } + + function key() + { + return false; + } + + function current() + { + return false; + } + + function next() + { + } + + function __call($func, $params) + { + return call_user_func_array(array($this->rs, $func), $params); + } + + function hasMore() + { + return false; + } + + } + + + /** + * Lightweight recordset when there are no records to be returned + */ + class ADORecordSet_empty implements IteratorAggregate + { + var $dataProvider = 'empty'; + var $databaseType = false; + var $EOF = true; + var $_numOfRows = 0; + var $fields = false; + var $connection = false; + function RowCount() {return 0;} + function RecordCount() {return 0;} + function PO_RecordCount(){return 0;} + function Close(){return true;} + function FetchRow() {return false;} + function FieldCount(){ return 0;} + function Init() {} + function getIterator() {return new ADODB_Iterator_empty($this);} + } + + //============================================================================================== + // DATE AND TIME FUNCTIONS + //============================================================================================== + if (!defined('ADODB_DATE_VERSION')) include(ADODB_DIR.'/adodb-time.inc.php'); + + //============================================================================================== + // CLASS ADORecordSet + //============================================================================================== + + class ADODB_Iterator implements Iterator { + + private $rs; + + function __construct($rs) + { + $this->rs = $rs; + } + function rewind() + { + $this->rs->MoveFirst(); + } + + function valid() + { + return !$this->rs->EOF; + } + + function key() + { + return $this->rs->_currentRow; + } + + function current() + { + return $this->rs->fields; + } + + function next() + { + $this->rs->MoveNext(); + } + + function __call($func, $params) + { + return call_user_func_array(array($this->rs, $func), $params); + } + + + function hasMore() + { + return !$this->rs->EOF; + } + + } + + + + /** + * RecordSet class that represents the dataset returned by the database. + * To keep memory overhead low, this class holds only the current row in memory. + * No prefetching of data is done, so the RecordCount() can return -1 ( which + * means recordcount not known). + */ + class ADORecordSet implements IteratorAggregate { + /* + * public variables + */ + var $dataProvider = "native"; + var $fields = false; /// holds the current row data + var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob + /// in other words, we use a text area for editing. + var $canSeek = false; /// indicates that seek is supported + var $sql; /// sql text + var $EOF = false; /// Indicates that the current record position is after the last record in a Recordset object. + + var $emptyTimeStamp = ' '; /// what to display when $time==0 + var $emptyDate = ' '; /// what to display when $time==0 + var $debug = false; + var $timeCreated=0; /// datetime in Unix format rs created -- for cached recordsets + + var $bind = false; /// used by Fields() to hold array - should be private? + var $fetchMode; /// default fetch mode + var $connection = false; /// the parent connection + /* + * private variables + */ + var $_numOfRows = -1; /** number of rows, or -1 */ + var $_numOfFields = -1; /** number of fields in recordset */ + var $_queryID = -1; /** This variable keeps the result link identifier. */ + var $_currentRow = -1; /** This variable keeps the current row in the Recordset. */ + var $_closed = false; /** has recordset been closed */ + var $_inited = false; /** Init() should only be called once */ + var $_obj; /** Used by FetchObj */ + var $_names; /** Used by FetchObj */ + + var $_currentPage = -1; /** Added by Iván Oliva to implement recordset pagination */ + var $_atFirstPage = false; /** Added by Iván Oliva to implement recordset pagination */ + var $_atLastPage = false; /** Added by Iván Oliva to implement recordset pagination */ + var $_lastPageNo = -1; + var $_maxRecordCount = 0; + var $datetime = false; + + /** + * Constructor + * + * @param queryID this is the queryID returned by ADOConnection->_query() + * + */ + function ADORecordSet($queryID) + { + $this->_queryID = $queryID; + } + + function getIterator() + { + return new ADODB_Iterator($this); + } + + /* this is experimental - i don't really know what to return... */ + function __toString() + { + include_once(ADODB_DIR.'/toexport.inc.php'); + return _adodb_export($this,',',',',false,true); + } + + + function Init() + { + if ($this->_inited) return; + $this->_inited = true; + if ($this->_queryID) @$this->_initrs(); + else { + $this->_numOfRows = 0; + $this->_numOfFields = 0; + } + if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) { + + $this->_currentRow = 0; + if ($this->EOF = ($this->_fetch() === false)) { + $this->_numOfRows = 0; // _numOfRows could be -1 + } + } else { + $this->EOF = true; + } + } + + + /** + * Generate a SELECT tag string from a recordset, and return the string. + * If the recordset has 2 cols, we treat the 1st col as the containing + * the text to display to the user, and 2nd col as the return value. Default + * strings are compared with the FIRST column. + * + * @param name name of SELECT tag + * @param [defstr] the value to hilite. Use an array for multiple hilites for listbox. + * @param [blank1stItem] true to leave the 1st item in list empty + * @param [multiple] true for listbox, false for popup + * @param [size] #rows to show for listbox. not used by popup + * @param [selectAttr] additional attributes to defined for SELECT tag. + * useful for holding javascript onChange='...' handlers. + & @param [compareFields0] when we have 2 cols in recordset, we compare the defstr with + * column 0 (1st col) if this is true. This is not documented. + * + * @return HTML + * + * changes by glen.davies@cce.ac.nz to support multiple hilited items + */ + function GetMenu($name,$defstr='',$blank1stItem=true,$multiple=false, + $size=0, $selectAttr='',$compareFields0=true) + { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple, + $size, $selectAttr,$compareFields0); + } + + + + /** + * Generate a SELECT tag string from a recordset, and return the string. + * If the recordset has 2 cols, we treat the 1st col as the containing + * the text to display to the user, and 2nd col as the return value. Default + * strings are compared with the SECOND column. + * + */ + function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='') + { + return $this->GetMenu($name,$defstr,$blank1stItem,$multiple, + $size, $selectAttr,false); + } + + /* + Grouped Menu + */ + function GetMenu3($name,$defstr='',$blank1stItem=true,$multiple=false, + $size=0, $selectAttr='') + { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + return _adodb_getmenu_gp($this, $name,$defstr,$blank1stItem,$multiple, + $size, $selectAttr,false); + } + + /** + * return recordset as a 2-dimensional array. + * + * @param [nRows] is the number of rows to return. -1 means every row. + * + * @return an array indexed by the rows (0-based) from the recordset + */ + function GetArray($nRows = -1) + { + global $ADODB_EXTENSION; if ($ADODB_EXTENSION) { + $results = adodb_getall($this,$nRows); + return $results; + } + $results = array(); + $cnt = 0; + while (!$this->EOF && $nRows != $cnt) { + $results[] = $this->fields; + $this->MoveNext(); + $cnt++; + } + return $results; + } + + function GetAll($nRows = -1) + { + $arr = $this->GetArray($nRows); + return $arr; + } + + /* + * Some databases allow multiple recordsets to be returned. This function + * will return true if there is a next recordset, or false if no more. + */ + function NextRecordSet() + { + return false; + } + + /** + * return recordset as a 2-dimensional array. + * Helper function for ADOConnection->SelectLimit() + * + * @param offset is the row to start calculations from (1-based) + * @param [nrows] is the number of rows to return + * + * @return an array indexed by the rows (0-based) from the recordset + */ + function GetArrayLimit($nrows,$offset=-1) + { + if ($offset <= 0) { + $arr = $this->GetArray($nrows); + return $arr; + } + + $this->Move($offset); + + $results = array(); + $cnt = 0; + while (!$this->EOF && $nrows != $cnt) { + $results[$cnt++] = $this->fields; + $this->MoveNext(); + } + + return $results; + } + + + /** + * Synonym for GetArray() for compatibility with ADO. + * + * @param [nRows] is the number of rows to return. -1 means every row. + * + * @return an array indexed by the rows (0-based) from the recordset + */ + function GetRows($nRows = -1) + { + $arr = $this->GetArray($nRows); + return $arr; + } + + /** + * return whole recordset as a 2-dimensional associative array if there are more than 2 columns. + * The first column is treated as the key and is not included in the array. + * If there is only 2 columns, it will return a 1 dimensional array of key-value pairs unless + * $force_array == true. + * + * @param [force_array] has only meaning if we have 2 data columns. If false, a 1 dimensional + * array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing, + * read the source. + * + * @param [first2cols] means if there are more than 2 cols, ignore the remaining cols and + * instead of returning array[col0] => array(remaining cols), return array[col0] => col1 + * + * @return an associative array indexed by the first column of the array, + * or false if the data has less than 2 cols. + */ + function GetAssoc($force_array = false, $first2cols = false) + { + global $ADODB_EXTENSION; + + $cols = $this->_numOfFields; + if ($cols < 2) { + $false = false; + return $false; + } + $numIndex = isset($this->fields[0]); + $results = array(); + + if (!$first2cols && ($cols > 2 || $force_array)) { + if ($ADODB_EXTENSION) { + if ($numIndex) { + while (!$this->EOF) { + $results[trim($this->fields[0])] = array_slice($this->fields, 1); + adodb_movenext($this); + } + } else { + while (!$this->EOF) { + // Fix for array_slice re-numbering numeric associative keys + $keys = array_slice(array_keys($this->fields), 1); + $sliced_array = array(); + + foreach($keys as $key) { + $sliced_array[$key] = $this->fields[$key]; + } + + $results[trim(reset($this->fields))] = $sliced_array; + adodb_movenext($this); + } + } + } else { + if ($numIndex) { + while (!$this->EOF) { + $results[trim($this->fields[0])] = array_slice($this->fields, 1); + $this->MoveNext(); + } + } else { + while (!$this->EOF) { + // Fix for array_slice re-numbering numeric associative keys + $keys = array_slice(array_keys($this->fields), 1); + $sliced_array = array(); + + foreach($keys as $key) { + $sliced_array[$key] = $this->fields[$key]; + } + + $results[trim(reset($this->fields))] = $sliced_array; + $this->MoveNext(); + } + } + } + } else { + if ($ADODB_EXTENSION) { + // return scalar values + if ($numIndex) { + while (!$this->EOF) { + // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string + $results[trim(($this->fields[0]))] = $this->fields[1]; + adodb_movenext($this); + } + } else { + while (!$this->EOF) { + // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string + $v1 = trim(reset($this->fields)); + $v2 = ''.next($this->fields); + $results[$v1] = $v2; + adodb_movenext($this); + } + } + } else { + if ($numIndex) { + while (!$this->EOF) { + // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string + $results[trim(($this->fields[0]))] = $this->fields[1]; + $this->MoveNext(); + } + } else { + while (!$this->EOF) { + // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string + $v1 = trim(reset($this->fields)); + $v2 = ''.next($this->fields); + $results[$v1] = $v2; + $this->MoveNext(); + } + } + } + } + + $ref = $results; # workaround accelerator incompat with PHP 4.4 :( + return $ref; + } + + + /** + * + * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format + * @param fmt is the format to apply to it, using date() + * + * @return a timestamp formated as user desires + */ + function UserTimeStamp($v,$fmt='Y-m-d H:i:s') + { + if (is_numeric($v) && strlen($v)<14) return adodb_date($fmt,$v); + $tt = $this->UnixTimeStamp($v); + // $tt == -1 if pre TIMESTAMP_FIRST_YEAR + if (($tt === false || $tt == -1) && $v != false) return $v; + if ($tt === 0) return $this->emptyTimeStamp; + return adodb_date($fmt,$tt); + } + + + /** + * @param v is the character date in YYYY-MM-DD format, returned by database + * @param fmt is the format to apply to it, using date() + * + * @return a date formated as user desires + */ + function UserDate($v,$fmt='Y-m-d') + { + $tt = $this->UnixDate($v); + // $tt == -1 if pre TIMESTAMP_FIRST_YEAR + if (($tt === false || $tt == -1) && $v != false) return $v; + else if ($tt == 0) return $this->emptyDate; + else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR + } + return adodb_date($fmt,$tt); + } + + + /** + * @param $v is a date string in YYYY-MM-DD format + * + * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format + */ + static function UnixDate($v) + { + return ADOConnection::UnixDate($v); + } + + + /** + * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format + * + * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format + */ + static function UnixTimeStamp($v) + { + return ADOConnection::UnixTimeStamp($v); + } + + + /** + * PEAR DB Compat - do not use internally + */ + function Free() + { + return $this->Close(); + } + + + /** + * PEAR DB compat, number of rows + */ + function NumRows() + { + return $this->_numOfRows; + } + + + /** + * PEAR DB compat, number of cols + */ + function NumCols() + { + return $this->_numOfFields; + } + + /** + * Fetch a row, returning false if no more rows. + * This is PEAR DB compat mode. + * + * @return false or array containing the current record + */ + function FetchRow() + { + if ($this->EOF) { + $false = false; + return $false; + } + $arr = $this->fields; + $this->_currentRow++; + if (!$this->_fetch()) $this->EOF = true; + return $arr; + } + + + /** + * Fetch a row, returning PEAR_Error if no more rows. + * This is PEAR DB compat mode. + * + * @return DB_OK or error object + */ + function FetchInto(&$arr) + { + if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false; + $arr = $this->fields; + $this->MoveNext(); + return 1; // DB_OK + } + + + /** + * Move to the first row in the recordset. Many databases do NOT support this. + * + * @return true or false + */ + function MoveFirst() + { + if ($this->_currentRow == 0) return true; + return $this->Move(0); + } + + + /** + * Move to the last row in the recordset. + * + * @return true or false + */ + function MoveLast() + { + if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows-1); + if ($this->EOF) return false; + while (!$this->EOF) { + $f = $this->fields; + $this->MoveNext(); + } + $this->fields = $f; + $this->EOF = false; + return true; + } + + + /** + * Move to next record in the recordset. + * + * @return true if there still rows available, or false if there are no more rows (EOF). + */ + function MoveNext() + { + if (!$this->EOF) { + $this->_currentRow++; + if ($this->_fetch()) return true; + } + $this->EOF = true; + /* -- tested error handling when scrolling cursor -- seems useless. + $conn = $this->connection; + if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) { + $fn = $conn->raiseErrorFn; + $fn($conn->databaseType,'MOVENEXT',$errno,$conn->ErrorMsg().' ('.$this->sql.')',$conn->host,$conn->database); + } + */ + return false; + } + + + /** + * Random access to a specific row in the recordset. Some databases do not support + * access to previous rows in the databases (no scrolling backwards). + * + * @param rowNumber is the row to move to (0-based) + * + * @return true if there still rows available, or false if there are no more rows (EOF). + */ + function Move($rowNumber = 0) + { + $this->EOF = false; + if ($rowNumber == $this->_currentRow) return true; + if ($rowNumber >= $this->_numOfRows) + if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2; + + if ($this->canSeek) { + + if ($this->_seek($rowNumber)) { + $this->_currentRow = $rowNumber; + if ($this->_fetch()) { + return true; + } + } else { + $this->EOF = true; + return false; + } + } else { + if ($rowNumber < $this->_currentRow) return false; + global $ADODB_EXTENSION; + if ($ADODB_EXTENSION) { + while (!$this->EOF && $this->_currentRow < $rowNumber) { + adodb_movenext($this); + } + } else { + + while (! $this->EOF && $this->_currentRow < $rowNumber) { + $this->_currentRow++; + + if (!$this->_fetch()) $this->EOF = true; + } + } + return !($this->EOF); + } + + $this->fields = false; + $this->EOF = true; + return false; + } + + + /** + * Get the value of a field in the current row by column name. + * Will not work if ADODB_FETCH_MODE is set to ADODB_FETCH_NUM. + * + * @param colname is the field to access + * + * @return the value of $colname column + */ + function Fields($colname) + { + return $this->fields[$colname]; + } + + function GetAssocKeys($upper=true) + { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + if ($upper === 2) $this->bind[$o->name] = $i; + else $this->bind[($upper) ? strtoupper($o->name) : strtolower($o->name)] = $i; + } + } + + /** + * Use associative array to get fields array for databases that do not support + * associative arrays. Submitted by Paolo S. Asioli paolo.asioli#libero.it + * + * If you don't want uppercase cols, set $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC + * before you execute your SQL statement, and access $rs->fields['col'] directly. + * + * $upper 0 = lowercase, 1 = uppercase, 2 = whatever is returned by FetchField + */ + function GetRowAssoc($upper=1) + { + $record = array(); + // if (!$this->fields) return $record; + + if (!$this->bind) { + $this->GetAssocKeys($upper); + } + + foreach($this->bind as $k => $v) { + $record[$k] = $this->fields[$v]; + } + + return $record; + } + + + /** + * Clean up recordset + * + * @return true or false + */ + function Close() + { + // free connection object - this seems to globally free the object + // and not merely the reference, so don't do this... + // $this->connection = false; + if (!$this->_closed) { + $this->_closed = true; + return $this->_close(); + } else + return true; + } + + /** + * synonyms RecordCount and RowCount + * + * @return the number of rows or -1 if this is not supported + */ + function RecordCount() {return $this->_numOfRows;} + + + /* + * If we are using PageExecute(), this will return the maximum possible rows + * that can be returned when paging a recordset. + */ + function MaxRecordCount() + { + return ($this->_maxRecordCount) ? $this->_maxRecordCount : $this->RecordCount(); + } + + /** + * synonyms RecordCount and RowCount + * + * @return the number of rows or -1 if this is not supported + */ + function RowCount() {return $this->_numOfRows;} + + + /** + * Portable RecordCount. Pablo Roca + * + * @return the number of records from a previous SELECT. All databases support this. + * + * But aware possible problems in multiuser environments. For better speed the table + * must be indexed by the condition. Heavy test this before deploying. + */ + function PO_RecordCount($table="", $condition="") { + + $lnumrows = $this->_numOfRows; + // the database doesn't support native recordcount, so we do a workaround + if ($lnumrows == -1 && $this->connection) { + IF ($table) { + if ($condition) $condition = " WHERE " . $condition; + $resultrows = $this->connection->Execute("SELECT COUNT(*) FROM $table $condition"); + if ($resultrows) $lnumrows = reset($resultrows->fields); + } + } + return $lnumrows; + } + + + /** + * @return the current row in the recordset. If at EOF, will return the last row. 0-based. + */ + function CurrentRow() {return $this->_currentRow;} + + /** + * synonym for CurrentRow -- for ADO compat + * + * @return the current row in the recordset. If at EOF, will return the last row. 0-based. + */ + function AbsolutePosition() {return $this->_currentRow;} + + /** + * @return the number of columns in the recordset. Some databases will set this to 0 + * if no records are returned, others will return the number of columns in the query. + */ + function FieldCount() {return $this->_numOfFields;} + + + /** + * Get the ADOFieldObject of a specific column. + * + * @param fieldoffset is the column position to access(0-based). + * + * @return the ADOFieldObject for that column, or false. + */ + function FetchField($fieldoffset = -1) + { + // must be defined by child class + + $false = false; + return $false; + } + + /** + * Get the ADOFieldObjects of all columns in an array. + * + */ + function FieldTypesArray() + { + $arr = array(); + for ($i=0, $max=$this->_numOfFields; $i < $max; $i++) + $arr[] = $this->FetchField($i); + return $arr; + } + + /** + * Return the fields array of the current row as an object for convenience. + * The default case is lowercase field names. + * + * @return the object with the properties set to the fields of the current row + */ + function FetchObj() + { + $o = $this->FetchObject(false); + return $o; + } + + /** + * Return the fields array of the current row as an object for convenience. + * The default case is uppercase. + * + * @param $isupper to set the object property names to uppercase + * + * @return the object with the properties set to the fields of the current row + */ + function FetchObject($isupper=true) + { + if (empty($this->_obj)) { + $this->_obj = new ADOFetchObj(); + $this->_names = array(); + for ($i=0; $i <$this->_numOfFields; $i++) { + $f = $this->FetchField($i); + $this->_names[] = $f->name; + } + } + $i = 0; + if (PHP_VERSION >= 5) $o = clone($this->_obj); + else $o = $this->_obj; + + for ($i=0; $i <$this->_numOfFields; $i++) { + $name = $this->_names[$i]; + if ($isupper) $n = strtoupper($name); + else $n = $name; + + $o->$n = $this->Fields($name); + } + return $o; + } + + /** + * Return the fields array of the current row as an object for convenience. + * The default is lower-case field names. + * + * @return the object with the properties set to the fields of the current row, + * or false if EOF + * + * Fixed bug reported by tim@orotech.net + */ + function FetchNextObj() + { + $o = $this->FetchNextObject(false); + return $o; + } + + + /** + * Return the fields array of the current row as an object for convenience. + * The default is upper case field names. + * + * @param $isupper to set the object property names to uppercase + * + * @return the object with the properties set to the fields of the current row, + * or false if EOF + * + * Fixed bug reported by tim@orotech.net + */ + function FetchNextObject($isupper=true) + { + $o = false; + if ($this->_numOfRows != 0 && !$this->EOF) { + $o = $this->FetchObject($isupper); + $this->_currentRow++; + if ($this->_fetch()) return $o; + } + $this->EOF = true; + return $o; + } + + /** + * Get the metatype of the column. This is used for formatting. This is because + * many databases use different names for the same type, so we transform the original + * type to our standardised version which uses 1 character codes: + * + * @param t is the type passed in. Normally is ADOFieldObject->type. + * @param len is the maximum length of that field. This is because we treat character + * fields bigger than a certain size as a 'B' (blob). + * @param fieldobj is the field object returned by the database driver. Can hold + * additional info (eg. primary_key for mysql). + * + * @return the general type of the data: + * C for character < 250 chars + * X for teXt (>= 250 chars) + * B for Binary + * N for numeric or floating point + * D for date + * T for timestamp + * L for logical/Boolean + * I for integer + * R for autoincrement counter/integer + * + * + */ + function MetaType($t,$len=-1,$fieldobj=false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + // changed in 2.32 to hashing instead of switch stmt for speed... + static $typeMap = array( + 'VARCHAR' => 'C', + 'VARCHAR2' => 'C', + 'CHAR' => 'C', + 'C' => 'C', + 'STRING' => 'C', + 'NCHAR' => 'C', + 'NVARCHAR' => 'C', + 'VARYING' => 'C', + 'BPCHAR' => 'C', + 'CHARACTER' => 'C', + 'INTERVAL' => 'C', # Postgres + 'MACADDR' => 'C', # postgres + 'VAR_STRING' => 'C', # mysql + ## + 'LONGCHAR' => 'X', + 'TEXT' => 'X', + 'NTEXT' => 'X', + 'M' => 'X', + 'X' => 'X', + 'CLOB' => 'X', + 'NCLOB' => 'X', + 'LVARCHAR' => 'X', + ## + 'BLOB' => 'B', + 'IMAGE' => 'B', + 'BINARY' => 'B', + 'VARBINARY' => 'B', + 'LONGBINARY' => 'B', + 'B' => 'B', + ## + 'YEAR' => 'D', // mysql + 'DATE' => 'D', + 'D' => 'D', + ## + 'UNIQUEIDENTIFIER' => 'C', # MS SQL Server + ## + 'SMALLDATETIME' => 'T', + 'TIME' => 'T', + 'TIMESTAMP' => 'T', + 'DATETIME' => 'T', + 'TIMESTAMPTZ' => 'T', + 'T' => 'T', + 'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql + ## + 'BOOL' => 'L', + 'BOOLEAN' => 'L', + 'BIT' => 'L', + 'L' => 'L', + ## + 'COUNTER' => 'R', + 'R' => 'R', + 'SERIAL' => 'R', // ifx + 'INT IDENTITY' => 'R', + ## + 'INT' => 'I', + 'INT2' => 'I', + 'INT4' => 'I', + 'INT8' => 'I', + 'INTEGER' => 'I', + 'INTEGER UNSIGNED' => 'I', + 'SHORT' => 'I', + 'TINYINT' => 'I', + 'SMALLINT' => 'I', + 'I' => 'I', + ## + 'LONG' => 'N', // interbase is numeric, oci8 is blob + 'BIGINT' => 'N', // this is bigger than PHP 32-bit integers + 'DECIMAL' => 'N', + 'DEC' => 'N', + 'REAL' => 'N', + 'DOUBLE' => 'N', + 'DOUBLE PRECISION' => 'N', + 'SMALLFLOAT' => 'N', + 'FLOAT' => 'N', + 'NUMBER' => 'N', + 'NUM' => 'N', + 'NUMERIC' => 'N', + 'MONEY' => 'N', + + ## informix 9.2 + 'SQLINT' => 'I', + 'SQLSERIAL' => 'I', + 'SQLSMINT' => 'I', + 'SQLSMFLOAT' => 'N', + 'SQLFLOAT' => 'N', + 'SQLMONEY' => 'N', + 'SQLDECIMAL' => 'N', + 'SQLDATE' => 'D', + 'SQLVCHAR' => 'C', + 'SQLCHAR' => 'C', + 'SQLDTIME' => 'T', + 'SQLINTERVAL' => 'N', + 'SQLBYTES' => 'B', + 'SQLTEXT' => 'X', + ## informix 10 + "SQLINT8" => 'I8', + "SQLSERIAL8" => 'I8', + "SQLNCHAR" => 'C', + "SQLNVCHAR" => 'C', + "SQLLVARCHAR" => 'X', + "SQLBOOL" => 'L' + ); + + $tmap = false; + $t = strtoupper($t); + $tmap = (isset($typeMap[$t])) ? $typeMap[$t] : 'N'; + switch ($tmap) { + case 'C': + + // is the char field is too long, return as text field... + if ($this->blobSize >= 0) { + if ($len > $this->blobSize) return 'X'; + } else if ($len > 250) { + return 'X'; + } + return 'C'; + + case 'I': + if (!empty($fieldobj->primary_key)) return 'R'; + return 'I'; + + case false: + return 'N'; + + case 'B': + if (isset($fieldobj->binary)) + return ($fieldobj->binary) ? 'B' : 'X'; + return 'B'; + + case 'D': + if (!empty($this->connection) && !empty($this->connection->datetime)) return 'T'; + return 'D'; + + default: + if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B'; + return $tmap; + } + } + + + function _close() {} + + /** + * set/returns the current recordset page when paginating + */ + function AbsolutePage($page=-1) + { + if ($page != -1) $this->_currentPage = $page; + return $this->_currentPage; + } + + /** + * set/returns the status of the atFirstPage flag when paginating + */ + function AtFirstPage($status=false) + { + if ($status != false) $this->_atFirstPage = $status; + return $this->_atFirstPage; + } + + function LastPageNo($page = false) + { + if ($page != false) $this->_lastPageNo = $page; + return $this->_lastPageNo; + } + + /** + * set/returns the status of the atLastPage flag when paginating + */ + function AtLastPage($status=false) + { + if ($status != false) $this->_atLastPage = $status; + return $this->_atLastPage; + } + +} // end class ADORecordSet + + //============================================================================================== + // CLASS ADORecordSet_array + //============================================================================================== + + /** + * This class encapsulates the concept of a recordset created in memory + * as an array. This is useful for the creation of cached recordsets. + * + * Note that the constructor is different from the standard ADORecordSet + */ + + class ADORecordSet_array extends ADORecordSet + { + var $databaseType = 'array'; + + var $_array; // holds the 2-dimensional data array + var $_types; // the array of types of each column (C B I L M) + var $_colnames; // names of each column in array + var $_skiprow1; // skip 1st row because it holds column names + var $_fieldobjects; // holds array of field objects + var $canSeek = true; + var $affectedrows = false; + var $insertid = false; + var $sql = ''; + var $compat = false; + /** + * Constructor + * + */ + function ADORecordSet_array($fakeid=1) + { + global $ADODB_FETCH_MODE,$ADODB_COMPAT_FETCH; + + // fetch() on EOF does not delete $this->fields + $this->compat = !empty($ADODB_COMPAT_FETCH); + $this->ADORecordSet($fakeid); // fake queryID + $this->fetchMode = $ADODB_FETCH_MODE; + } + + function _transpose($addfieldnames=true) + { + global $ADODB_INCLUDED_LIB; + + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + $hdr = true; + + $fobjs = $addfieldnames ? $this->_fieldobjects : false; + adodb_transpose($this->_array, $newarr, $hdr, $fobjs); + //adodb_pr($newarr); + + $this->_skiprow1 = false; + $this->_array = $newarr; + $this->_colnames = $hdr; + + adodb_probetypes($newarr,$this->_types); + + $this->_fieldobjects = array(); + + foreach($hdr as $k => $name) { + $f = new ADOFieldObject(); + $f->name = $name; + $f->type = $this->_types[$k]; + $f->max_length = -1; + $this->_fieldobjects[] = $f; + } + $this->fields = reset($this->_array); + + $this->_initrs(); + + } + + /** + * Setup the array. + * + * @param array is a 2-dimensional array holding the data. + * The first row should hold the column names + * unless paramter $colnames is used. + * @param typearr holds an array of types. These are the same types + * used in MetaTypes (C,B,L,I,N). + * @param [colnames] array of column names. If set, then the first row of + * $array should not hold the column names. + */ + function InitArray($array,$typearr,$colnames=false) + { + $this->_array = $array; + $this->_types = $typearr; + if ($colnames) { + $this->_skiprow1 = false; + $this->_colnames = $colnames; + } else { + $this->_skiprow1 = true; + $this->_colnames = $array[0]; + } + $this->Init(); + } + /** + * Setup the Array and datatype file objects + * + * @param array is a 2-dimensional array holding the data. + * The first row should hold the column names + * unless paramter $colnames is used. + * @param fieldarr holds an array of ADOFieldObject's. + */ + function InitArrayFields(&$array,&$fieldarr) + { + $this->_array = $array; + $this->_skiprow1= false; + if ($fieldarr) { + $this->_fieldobjects = $fieldarr; + } + $this->Init(); + } + + function GetArray($nRows=-1) + { + if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) { + return $this->_array; + } else { + $arr = ADORecordSet::GetArray($nRows); + return $arr; + } + } + + function _initrs() + { + $this->_numOfRows = sizeof($this->_array); + if ($this->_skiprow1) $this->_numOfRows -= 1; + + $this->_numOfFields =(isset($this->_fieldobjects)) ? + sizeof($this->_fieldobjects):sizeof($this->_types); + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + $mode = isset($this->adodbFetchMode) ? $this->adodbFetchMode : $this->fetchMode; + + if ($mode & ADODB_FETCH_ASSOC) { + if (!isset($this->fields[$colname]) && !is_null($this->fields[$colname])) $colname = strtolower($colname); + return $this->fields[$colname]; + } + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + function FetchField($fieldOffset = -1) + { + if (isset($this->_fieldobjects)) { + return $this->_fieldobjects[$fieldOffset]; + } + $o = new ADOFieldObject(); + $o->name = $this->_colnames[$fieldOffset]; + $o->type = $this->_types[$fieldOffset]; + $o->max_length = -1; // length not known + + return $o; + } + + function _seek($row) + { + if (sizeof($this->_array) && 0 <= $row && $row < $this->_numOfRows) { + $this->_currentRow = $row; + if ($this->_skiprow1) $row += 1; + $this->fields = $this->_array[$row]; + return true; + } + return false; + } + + function MoveNext() + { + if (!$this->EOF) { + $this->_currentRow++; + + $pos = $this->_currentRow; + + if ($this->_numOfRows <= $pos) { + if (!$this->compat) $this->fields = false; + } else { + if ($this->_skiprow1) $pos += 1; + $this->fields = $this->_array[$pos]; + return true; + } + $this->EOF = true; + } + + return false; + } + + function _fetch() + { + $pos = $this->_currentRow; + + if ($this->_numOfRows <= $pos) { + if (!$this->compat) $this->fields = false; + return false; + } + if ($this->_skiprow1) $pos += 1; + $this->fields = $this->_array[$pos]; + return true; + } + + function _close() + { + return true; + } + + } // ADORecordSet_array + + //============================================================================================== + // HELPER FUNCTIONS + //============================================================================================== + + /** + * Synonym for ADOLoadCode. Private function. Do not use. + * + * @deprecated + */ + function ADOLoadDB($dbType) + { + return ADOLoadCode($dbType); + } + + /** + * Load the code for a specific database driver. Private function. Do not use. + */ + function ADOLoadCode($dbType) + { + global $ADODB_LASTDB; + + if (!$dbType) return false; + $db = strtolower($dbType); + switch ($db) { + case 'ado': + if (PHP_VERSION >= 5) $db = 'ado5'; + $class = 'ado'; + break; + case 'ifx': + case 'maxsql': $class = $db = 'mysqlt'; break; + case 'postgres': + case 'postgres8': + case 'pgsql': $class = $db = 'postgres7'; break; + default: + $class = $db; break; + } + + $file = ADODB_DIR."/drivers/adodb-".$db.".inc.php"; + @include_once($file); + $ADODB_LASTDB = $class; + if (class_exists("ADODB_" . $class)) return $class; + + //ADOConnection::outp(adodb_pr(get_declared_classes(),true)); + if (!file_exists($file)) ADOConnection::outp("Missing file: $file"); + else ADOConnection::outp("Syntax error in file: $file"); + return false; + } + + /** + * synonym for ADONewConnection for people like me who cannot remember the correct name + */ + function NewADOConnection($db='') + { + $tmp = ADONewConnection($db); + return $tmp; + } + + /** + * Instantiate a new Connection class for a specific database driver. + * + * @param [db] is the database Connection object to create. If undefined, + * use the last database driver that was loaded by ADOLoadCode(). + * + * @return the freshly created instance of the Connection class. + */ + function ADONewConnection($db='') + { + GLOBAL $ADODB_NEWCONNECTION, $ADODB_LASTDB; + + if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2); + $errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false; + $false = false; + if (($at = strpos($db,'://')) !== FALSE) { + $origdsn = $db; + $fakedsn = 'fake'.substr($origdsn,$at); + if (($at2 = strpos($origdsn,'@/')) !== FALSE) { + // special handling of oracle, which might not have host + $fakedsn = str_replace('@/','@adodb-fakehost/',$fakedsn); + } + $dsna = @parse_url($fakedsn); + if (!$dsna) { + return $false; + } + $dsna['scheme'] = substr($origdsn,0,$at); + if ($at2 !== FALSE) { + $dsna['host'] = ''; + } + + if (strncmp($origdsn,'pdo',3) == 0) { + $sch = explode('_',$dsna['scheme']); + if (sizeof($sch)>1) { + $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : ''; + $dsna['host'] = rawurlencode($sch[1].':host='.rawurldecode($dsna['host'])); + $dsna['scheme'] = 'pdo'; + } + } + + $db = @$dsna['scheme']; + if (!$db) return $false; + $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : ''; + $dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : ''; + $dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : ''; + $dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : ''; # strip off initial / + + if (isset($dsna['query'])) { + $opt1 = explode('&',$dsna['query']); + foreach($opt1 as $k => $v) { + $arr = explode('=',$v); + $opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1; + } + } else $opt = array(); + } + /* + * phptype: Database backend used in PHP (mysql, odbc etc.) + * dbsyntax: Database used with regards to SQL syntax etc. + * protocol: Communication protocol to use (tcp, unix etc.) + * hostspec: Host specification (hostname[:port]) + * database: Database to use on the DBMS server + * username: User name for login + * password: Password for login + */ + if (!empty($ADODB_NEWCONNECTION)) { + $obj = $ADODB_NEWCONNECTION($db); + + } + + if(empty($obj)) { + + if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = ''; + if (empty($db)) $db = $ADODB_LASTDB; + + if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db); + + if (!$db) { + if (isset($origdsn)) $db = $origdsn; + if ($errorfn) { + // raise an error + $ignore = false; + $errorfn('ADONewConnection', 'ADONewConnection', -998, + "could not load the database driver for '$db'", + $db,false,$ignore); + } else + ADOConnection::outp( "

ADONewConnection: Unable to load database driver '$db'

",false); + + return $false; + } + + $cls = 'ADODB_'.$db; + if (!class_exists($cls)) { + adodb_backtrace(); + return $false; + } + + $obj = new $cls(); + } + + # constructor should not fail + if ($obj) { + if ($errorfn) $obj->raiseErrorFn = $errorfn; + if (isset($dsna)) { + if (isset($dsna['port'])) $obj->port = $dsna['port']; + foreach($opt as $k => $v) { + switch(strtolower($k)) { + case 'new': + $nconnect = true; $persist = true; break; + case 'persist': + case 'persistent': $persist = $v; break; + case 'debug': $obj->debug = (integer) $v; break; + #ibase + case 'role': $obj->role = $v; break; + case 'dialect': $obj->dialect = (integer) $v; break; + case 'charset': $obj->charset = $v; $obj->charSet=$v; break; + case 'buffers': $obj->buffers = $v; break; + case 'fetchmode': $obj->SetFetchMode($v); break; + #ado + case 'charpage': $obj->charPage = $v; break; + #mysql, mysqli + case 'clientflags': $obj->clientFlags = $v; break; + #mysql, mysqli, postgres + case 'port': $obj->port = $v; break; + #mysqli + case 'socket': $obj->socket = $v; break; + #oci8 + case 'nls_date_format': $obj->NLS_DATE_FORMAT = $v; break; + } + } + if (empty($persist)) + $ok = $obj->Connect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']); + else if (empty($nconnect)) + $ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']); + else + $ok = $obj->NConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']); + + if (!$ok) return $false; + } + } + return $obj; + } + + + + // $perf == true means called by NewPerfMonitor(), otherwise for data dictionary + function _adodb_getdriver($provider,$drivername,$perf=false) + { + switch ($provider) { + case 'odbtp': if (strncmp('odbtp_',$drivername,6)==0) return substr($drivername,6); + case 'odbc' : if (strncmp('odbc_',$drivername,5)==0) return substr($drivername,5); + case 'ado' : if (strncmp('ado_',$drivername,4)==0) return substr($drivername,4); + case 'native': break; + default: + return $provider; + } + + switch($drivername) { + case 'mysqlt': + case 'mysqli': + $drivername='mysql'; + break; + case 'postgres7': + case 'postgres8': + $drivername = 'postgres'; + break; + case 'firebird15': $drivername = 'firebird'; break; + case 'oracle': $drivername = 'oci8'; break; + case 'access': if ($perf) $drivername = ''; break; + case 'db2' : break; + case 'sapdb' : break; + default: + $drivername = 'generic'; + break; + } + return $drivername; + } + + function NewPerfMonitor(&$conn) + { + $false = false; + $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true); + if (!$drivername || $drivername == 'generic') return $false; + include_once(ADODB_DIR.'/adodb-perf.inc.php'); + @include_once(ADODB_DIR."/perf/perf-$drivername.inc.php"); + $class = "Perf_$drivername"; + if (!class_exists($class)) return $false; + $perf = new $class($conn); + + return $perf; + } + + function NewDataDictionary(&$conn,$drivername=false) + { + $false = false; + if (!$drivername) $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType); + + include_once(ADODB_DIR.'/adodb-lib.inc.php'); + include_once(ADODB_DIR.'/adodb-datadict.inc.php'); + $path = ADODB_DIR."/datadict/datadict-$drivername.inc.php"; + + if (!file_exists($path)) { + ADOConnection::outp("Dictionary driver '$path' not available"); + return $false; + } + include_once($path); + $class = "ADODB2_$drivername"; + $dict = new $class(); + $dict->dataProvider = $conn->dataProvider; + $dict->connection = $conn; + $dict->upperName = strtoupper($drivername); + $dict->quote = $conn->nameQuote; + if (!empty($conn->_connectionID)) + $dict->serverInfo = $conn->ServerInfo(); + + return $dict; + } + + + + /* + Perform a print_r, with pre tags for better formatting. + */ + function adodb_pr($var,$as_string=false) + { + if ($as_string) ob_start(); + + if (isset($_SERVER['HTTP_USER_AGENT'])) { + echo "
\n";print_r($var);echo "
\n"; + } else + print_r($var); + + if ($as_string) { + $s = ob_get_contents(); + ob_end_clean(); + return $s; + } + } + + /* + Perform a stack-crawl and pretty print it. + + @param printOrArr Pass in a boolean to indicate print, or an $exception->trace array (assumes that print is true then). + @param levels Number of levels to display + */ + function adodb_backtrace($printOrArr=true,$levels=9999,$ishtml=null) + { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + return _adodb_backtrace($printOrArr,$levels,0,$ishtml); + } + + +} +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-access.inc.php b/includes/adodb/datadict/datadict-access.inc.php new file mode 100644 index 00000000..9007c769 --- /dev/null +++ b/includes/adodb/datadict/datadict-access.inc.php @@ -0,0 +1,95 @@ +debug) ADOConnection::outp("Warning: Access does not supported DEFAULT values (field $fname)"); + } + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + function CreateDatabase($dbname,$options=false) + { + return array(); + } + + + function SetSchema($schema) + { + } + + function AlterColumnSQL($tabname, $flds) + { + if ($this->debug) ADOConnection::outp("AlterColumnSQL not supported"); + return array(); + } + + + function DropColumnSQL($tabname, $flds) + { + if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); + return array(); + } + +} + + +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-db2.inc.php b/includes/adodb/datadict/datadict-db2.inc.php new file mode 100644 index 00000000..bb7886ee --- /dev/null +++ b/includes/adodb/datadict/datadict-db2.inc.php @@ -0,0 +1,143 @@ +debug) ADOConnection::outp("AlterColumnSQL not supported"); + return array(); + } + + + function DropColumnSQL($tabname, $flds) + { + if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); + return array(); + } + + + function ChangeTableSQL($tablename, $flds, $tableoptions = false) + { + + /** + Allow basic table changes to DB2 databases + DB2 will fatally reject changes to non character columns + + */ + + $validTypes = array("CHAR","VARC"); + $invalidTypes = array("BIGI","BLOB","CLOB","DATE", "DECI","DOUB", "INTE", "REAL","SMAL", "TIME"); + // check table exists + $cols = $this->MetaColumns($tablename); + if ( empty($cols)) { + return $this->CreateTableSQL($tablename, $flds, $tableoptions); + } + + // already exists, alter table instead + list($lines,$pkey) = $this->_GenFields($flds); + $alter = 'ALTER TABLE ' . $this->TableName($tablename); + $sql = array(); + + foreach ( $lines as $id => $v ) { + if ( isset($cols[$id]) && is_object($cols[$id]) ) { + /** + If the first field of $v is the fieldname, and + the second is the field type/size, we assume its an + attempt to modify the column size, so check that it is allowed + $v can have an indeterminate number of blanks between the + fields, so account for that too + */ + $vargs = explode(' ' , $v); + // assume that $vargs[0] is the field name. + $i=0; + // Find the next non-blank value; + for ($i=1;$ialterCol . ' ' . $v; + } else { + $sql[] = $alter . $this->addCol . ' ' . $v; + } + } + + return $sql; + } + +} + + +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-firebird.inc.php b/includes/adodb/datadict/datadict-firebird.inc.php new file mode 100644 index 00000000..c5df6cd8 --- /dev/null +++ b/includes/adodb/datadict/datadict-firebird.inc.php @@ -0,0 +1,151 @@ +connection) ) { + return $name; + } + + $quote = $this->connection->nameQuote; + + // if name is of the form `name`, quote it + if ( preg_match('/^`(.+)`$/', $name, $matches) ) { + return $quote . $matches[1] . $quote; + } + + // if name contains special characters, quote it + if ( !preg_match('/^[' . $this->nameRegex . ']+$/', $name) ) { + return $quote . $name . $quote; + } + + return $quote . $name . $quote; + } + + function CreateDatabase($dbname, $options=false) + { + $options = $this->_Options($options); + $sql = array(); + + $sql[] = "DECLARE EXTERNAL FUNCTION LOWER CSTRING(80) RETURNS CSTRING(80) FREE_IT ENTRY_POINT 'IB_UDF_lower' MODULE_NAME 'ib_udf'"; + + return $sql; + } + + function _DropAutoIncrement($t) + { + if (strpos($t,'.') !== false) { + $tarr = explode('.',$t); + return 'DROP GENERATOR '.$tarr[0].'."gen_'.$tarr[1].'"'; + } + return 'DROP GENERATOR "GEN_'.$t; + } + + + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) + { + $suffix = ''; + + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fautoinc) $this->seqField = $fname; + if ($fconstraint) $suffix .= ' '.$fconstraint; + + return $suffix; + } + +/* +CREATE or replace TRIGGER jaddress_insert +before insert on jaddress +for each row +begin +IF ( NEW."seqField" IS NULL OR NEW."seqField" = 0 ) THEN + NEW."seqField" = GEN_ID("GEN_tabname", 1); +end; +*/ + function _Triggers($tabname,$tableoptions) + { + if (!$this->seqField) return array(); + + $tab1 = preg_replace( '/"/', '', $tabname ); + if ($this->schema) { + $t = strpos($tab1,'.'); + if ($t !== false) $tab = substr($tab1,$t+1); + else $tab = $tab1; + $seqField = $this->seqField; + $seqname = $this->schema.'.'.$this->seqPrefix.$tab; + $trigname = $this->schema.'.trig_'.$this->seqPrefix.$tab; + } else { + $seqField = $this->seqField; + $seqname = $this->seqPrefix.$tab1; + $trigname = 'trig_'.$seqname; + } + if (isset($tableoptions['REPLACE'])) + { $sql[] = "DROP GENERATOR \"$seqname\""; + $sql[] = "CREATE GENERATOR \"$seqname\""; + $sql[] = "ALTER TRIGGER \"$trigname\" BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END"; + } + else + { $sql[] = "CREATE GENERATOR \"$seqname\""; + $sql[] = "CREATE TRIGGER \"$trigname\" FOR $tabname BEFORE INSERT OR UPDATE AS BEGIN IF ( NEW.$seqField IS NULL OR NEW.$seqField = 0 ) THEN NEW.$seqField = GEN_ID(\"$seqname\", 1); END"; + } + + $this->seqField = false; + return $sql; + } + +} + + +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-generic.inc.php b/includes/adodb/datadict/datadict-generic.inc.php new file mode 100644 index 00000000..f3222f27 --- /dev/null +++ b/includes/adodb/datadict/datadict-generic.inc.php @@ -0,0 +1,125 @@ +debug) ADOConnection::outp("AlterColumnSQL not supported"); + return array(); + } + + + function DropColumnSQL($tabname, $flds) + { + if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); + return array(); + } + +} + +/* +//db2 + function ActualType($meta) + { + switch($meta) { + case 'C': return 'VARCHAR'; + case 'X': return 'VARCHAR'; + + case 'C2': return 'VARCHAR'; // up to 32K + case 'X2': return 'VARCHAR'; + + case 'B': return 'BLOB'; + + case 'D': return 'DATE'; + case 'T': return 'TIMESTAMP'; + + case 'L': return 'SMALLINT'; + case 'I': return 'INTEGER'; + case 'I1': return 'SMALLINT'; + case 'I2': return 'SMALLINT'; + case 'I4': return 'INTEGER'; + case 'I8': return 'BIGINT'; + + case 'F': return 'DOUBLE'; + case 'N': return 'DECIMAL'; + default: + return $meta; + } + } + +// ifx +function ActualType($meta) + { + switch($meta) { + case 'C': return 'VARCHAR';// 255 + case 'X': return 'TEXT'; + + case 'C2': return 'NVARCHAR'; + case 'X2': return 'TEXT'; + + case 'B': return 'BLOB'; + + case 'D': return 'DATE'; + case 'T': return 'DATETIME'; + + case 'L': return 'SMALLINT'; + case 'I': return 'INTEGER'; + case 'I1': return 'SMALLINT'; + case 'I2': return 'SMALLINT'; + case 'I4': return 'INTEGER'; + case 'I8': return 'DECIMAL(20)'; + + case 'F': return 'FLOAT'; + case 'N': return 'DECIMAL'; + default: + return $meta; + } + } +*/ +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-ibase.inc.php b/includes/adodb/datadict/datadict-ibase.inc.php new file mode 100644 index 00000000..a1c2c017 --- /dev/null +++ b/includes/adodb/datadict/datadict-ibase.inc.php @@ -0,0 +1,67 @@ +debug) ADOConnection::outp("AlterColumnSQL not supported"); + return array(); + } + + + function DropColumnSQL($tabname, $flds) + { + if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); + return array(); + } + +} + + +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-informix.inc.php b/includes/adodb/datadict/datadict-informix.inc.php new file mode 100644 index 00000000..1c6f78bb --- /dev/null +++ b/includes/adodb/datadict/datadict-informix.inc.php @@ -0,0 +1,80 @@ +debug) ADOConnection::outp("AlterColumnSQL not supported"); + return array(); + } + + + function DropColumnSQL($tabname, $flds) + { + if ($this->debug) ADOConnection::outp("DropColumnSQL not supported"); + return array(); + } + + // return string must begin with space + function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint) + { + if ($fautoinc) { + $ftype = 'SERIAL'; + return ''; + } + $suffix = ''; + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + +} + +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-mssql.inc.php b/includes/adodb/datadict/datadict-mssql.inc.php new file mode 100644 index 00000000..2081bf77 --- /dev/null +++ b/includes/adodb/datadict/datadict-mssql.inc.php @@ -0,0 +1,282 @@ +type; + $len = $fieldobj->max_length; + } + + $len = -1; // mysql max_length is not accurate + switch (strtoupper($t)) { + case 'R': + case 'INT': + case 'INTEGER': return 'I'; + case 'BIT': + case 'TINYINT': return 'I1'; + case 'SMALLINT': return 'I2'; + case 'BIGINT': return 'I8'; + case 'SMALLDATETIME': return 'T'; + case 'REAL': + case 'FLOAT': return 'F'; + default: return parent::MetaType($t,$len,$fieldobj); + } + } + + function ActualType($meta) + { + switch(strtoupper($meta)) { + + case 'C': return 'VARCHAR'; + case 'XL': return (isset($this)) ? $this->typeXL : 'TEXT'; + case 'X': return (isset($this)) ? $this->typeX : 'TEXT'; ## could be varchar(8000), but we want compat with oracle + case 'C2': return 'NVARCHAR'; + case 'X2': return 'NTEXT'; + + case 'B': return 'IMAGE'; + + case 'D': return 'DATETIME'; + case 'T': return 'DATETIME'; + case 'L': return 'BIT'; + + case 'R': + case 'I': return 'INT'; + case 'I1': return 'TINYINT'; + case 'I2': return 'SMALLINT'; + case 'I4': return 'INT'; + case 'I8': return 'BIGINT'; + + case 'F': return 'REAL'; + case 'N': return 'NUMERIC'; + default: + return $meta; + } + } + + + function AddColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $f = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $s = "ALTER TABLE $tabname $this->addCol"; + foreach($lines as $v) { + $f[] = "\n $v"; + } + $s .= implode(', ',$f); + $sql[] = $s; + return $sql; + } + + /* + function AlterColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + foreach($lines as $v) { + $sql[] = "ALTER TABLE $tabname $this->alterCol $v"; + } + + return $sql; + } + */ + + function DropColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + if (!is_array($flds)) + $flds = explode(',',$flds); + $f = array(); + $s = 'ALTER TABLE ' . $tabname; + foreach($flds as $v) { + $f[] = "\n$this->dropCol ".$this->NameQuote($v); + } + $s .= implode(', ',$f); + $sql[] = $s; + return $sql; + } + + // return string must begin with space + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint) + { + $suffix = ''; + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fautoinc) $suffix .= ' IDENTITY(1,1)'; + if ($fnotnull) $suffix .= ' NOT NULL'; + else if ($suffix == '') $suffix .= ' NULL'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + /* +CREATE TABLE + [ database_name.[ owner ] . | owner. ] table_name + ( { < column_definition > + | column_name AS computed_column_expression + | < table_constraint > ::= [ CONSTRAINT constraint_name ] } + + | [ { PRIMARY KEY | UNIQUE } [ ,...n ] + ) + +[ ON { filegroup | DEFAULT } ] +[ TEXTIMAGE_ON { filegroup | DEFAULT } ] + +< column_definition > ::= { column_name data_type } + [ COLLATE < collation_name > ] + [ [ DEFAULT constant_expression ] + | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ] + ] + [ ROWGUIDCOL] + [ < column_constraint > ] [ ...n ] + +< column_constraint > ::= [ CONSTRAINT constraint_name ] + { [ NULL | NOT NULL ] + | [ { PRIMARY KEY | UNIQUE } + [ CLUSTERED | NONCLUSTERED ] + [ WITH FILLFACTOR = fillfactor ] + [ON {filegroup | DEFAULT} ] ] + ] + | [ [ FOREIGN KEY ] + REFERENCES ref_table [ ( ref_column ) ] + [ ON DELETE { CASCADE | NO ACTION } ] + [ ON UPDATE { CASCADE | NO ACTION } ] + [ NOT FOR REPLICATION ] + ] + | CHECK [ NOT FOR REPLICATION ] + ( logical_expression ) + } + +< table_constraint > ::= [ CONSTRAINT constraint_name ] + { [ { PRIMARY KEY | UNIQUE } + [ CLUSTERED | NONCLUSTERED ] + { ( column [ ASC | DESC ] [ ,...n ] ) } + [ WITH FILLFACTOR = fillfactor ] + [ ON { filegroup | DEFAULT } ] + ] + | FOREIGN KEY + [ ( column [ ,...n ] ) ] + REFERENCES ref_table [ ( ref_column [ ,...n ] ) ] + [ ON DELETE { CASCADE | NO ACTION } ] + [ ON UPDATE { CASCADE | NO ACTION } ] + [ NOT FOR REPLICATION ] + | CHECK [ NOT FOR REPLICATION ] + ( search_conditions ) + } + + + */ + + /* + CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name + ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) + [ WITH < index_option > [ ,...n] ] + [ ON filegroup ] + < index_option > :: = + { PAD_INDEX | + FILLFACTOR = fillfactor | + IGNORE_DUP_KEY | + DROP_EXISTING | + STATISTICS_NORECOMPUTE | + SORT_IN_TEMPDB + } +*/ + function _IndexSQL($idxname, $tabname, $flds, $idxoptions) + { + $sql = array(); + + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { + $sql[] = sprintf ($this->dropIndex, $idxname, $tabname); + if ( isset($idxoptions['DROP']) ) + return $sql; + } + + if ( empty ($flds) ) { + return $sql; + } + + $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : ''; + $clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : ''; + + if ( is_array($flds) ) + $flds = implode(', ',$flds); + $s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')'; + + if ( isset($idxoptions[$this->upperName]) ) + $s .= $idxoptions[$this->upperName]; + + + $sql[] = $s; + + return $sql; + } + + + function _GetSize($ftype, $ty, $fsize, $fprec) + { + switch ($ftype) { + case 'INT': + case 'SMALLINT': + case 'TINYINT': + case 'BIGINT': + return $ftype; + } + if ($ty == 'T') return $ftype; + return parent::_GetSize($ftype, $ty, $fsize, $fprec); + + } +} +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-mssqlnative.inc.php b/includes/adodb/datadict/datadict-mssqlnative.inc.php new file mode 100644 index 00000000..603f30e5 --- /dev/null +++ b/includes/adodb/datadict/datadict-mssqlnative.inc.php @@ -0,0 +1,282 @@ +type; + $len = $fieldobj->max_length; + } + + $len = -1; // mysql max_length is not accurate + switch (strtoupper($t)) { + case 'R': + case 'INT': + case 'INTEGER': return 'I'; + case 'BIT': + case 'TINYINT': return 'I1'; + case 'SMALLINT': return 'I2'; + case 'BIGINT': return 'I8'; + + case 'REAL': + case 'FLOAT': return 'F'; + default: return parent::MetaType($t,$len,$fieldobj); + } + } + + function ActualType($meta) + { + switch(strtoupper($meta)) { + + case 'C': return 'VARCHAR'; + case 'XL': return (isset($this)) ? $this->typeXL : 'TEXT'; + case 'X': return (isset($this)) ? $this->typeX : 'TEXT'; ## could be varchar(8000), but we want compat with oracle + case 'C2': return 'NVARCHAR'; + case 'X2': return 'NTEXT'; + + case 'B': return 'IMAGE'; + + case 'D': return 'DATETIME'; + case 'T': return 'DATETIME'; + case 'L': return 'BIT'; + + case 'R': + case 'I': return 'INT'; + case 'I1': return 'TINYINT'; + case 'I2': return 'SMALLINT'; + case 'I4': return 'INT'; + case 'I8': return 'BIGINT'; + + case 'F': return 'REAL'; + case 'N': return 'NUMERIC'; + default: + return $meta; + } + } + + + function AddColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $f = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $s = "ALTER TABLE $tabname $this->addCol"; + foreach($lines as $v) { + $f[] = "\n $v"; + } + $s .= implode(', ',$f); + $sql[] = $s; + return $sql; + } + + /* + function AlterColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + foreach($lines as $v) { + $sql[] = "ALTER TABLE $tabname $this->alterCol $v"; + } + + return $sql; + } + */ + + function DropColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + if (!is_array($flds)) + $flds = explode(',',$flds); + $f = array(); + $s = 'ALTER TABLE ' . $tabname; + foreach($flds as $v) { + $f[] = "\n$this->dropCol ".$this->NameQuote($v); + } + $s .= implode(', ',$f); + $sql[] = $s; + return $sql; + } + + // return string must begin with space + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint) + { + $suffix = ''; + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fautoinc) $suffix .= ' IDENTITY(1,1)'; + if ($fnotnull) $suffix .= ' NOT NULL'; + else if ($suffix == '') $suffix .= ' NULL'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + /* +CREATE TABLE + [ database_name.[ owner ] . | owner. ] table_name + ( { < column_definition > + | column_name AS computed_column_expression + | < table_constraint > ::= [ CONSTRAINT constraint_name ] } + + | [ { PRIMARY KEY | UNIQUE } [ ,...n ] + ) + +[ ON { filegroup | DEFAULT } ] +[ TEXTIMAGE_ON { filegroup | DEFAULT } ] + +< column_definition > ::= { column_name data_type } + [ COLLATE < collation_name > ] + [ [ DEFAULT constant_expression ] + | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ] + ] + [ ROWGUIDCOL] + [ < column_constraint > ] [ ...n ] + +< column_constraint > ::= [ CONSTRAINT constraint_name ] + { [ NULL | NOT NULL ] + | [ { PRIMARY KEY | UNIQUE } + [ CLUSTERED | NONCLUSTERED ] + [ WITH FILLFACTOR = fillfactor ] + [ON {filegroup | DEFAULT} ] ] + ] + | [ [ FOREIGN KEY ] + REFERENCES ref_table [ ( ref_column ) ] + [ ON DELETE { CASCADE | NO ACTION } ] + [ ON UPDATE { CASCADE | NO ACTION } ] + [ NOT FOR REPLICATION ] + ] + | CHECK [ NOT FOR REPLICATION ] + ( logical_expression ) + } + +< table_constraint > ::= [ CONSTRAINT constraint_name ] + { [ { PRIMARY KEY | UNIQUE } + [ CLUSTERED | NONCLUSTERED ] + { ( column [ ASC | DESC ] [ ,...n ] ) } + [ WITH FILLFACTOR = fillfactor ] + [ ON { filegroup | DEFAULT } ] + ] + | FOREIGN KEY + [ ( column [ ,...n ] ) ] + REFERENCES ref_table [ ( ref_column [ ,...n ] ) ] + [ ON DELETE { CASCADE | NO ACTION } ] + [ ON UPDATE { CASCADE | NO ACTION } ] + [ NOT FOR REPLICATION ] + | CHECK [ NOT FOR REPLICATION ] + ( search_conditions ) + } + + + */ + + /* + CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name + ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) + [ WITH < index_option > [ ,...n] ] + [ ON filegroup ] + < index_option > :: = + { PAD_INDEX | + FILLFACTOR = fillfactor | + IGNORE_DUP_KEY | + DROP_EXISTING | + STATISTICS_NORECOMPUTE | + SORT_IN_TEMPDB + } +*/ + function _IndexSQL($idxname, $tabname, $flds, $idxoptions) + { + $sql = array(); + + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { + $sql[] = sprintf ($this->dropIndex, $idxname, $tabname); + if ( isset($idxoptions['DROP']) ) + return $sql; + } + + if ( empty ($flds) ) { + return $sql; + } + + $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : ''; + $clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : ''; + + if ( is_array($flds) ) + $flds = implode(', ',$flds); + $s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')'; + + if ( isset($idxoptions[$this->upperName]) ) + $s .= $idxoptions[$this->upperName]; + + + $sql[] = $s; + + return $sql; + } + + + function _GetSize($ftype, $ty, $fsize, $fprec) + { + switch ($ftype) { + case 'INT': + case 'SMALLINT': + case 'TINYINT': + case 'BIGINT': + return $ftype; + } + if ($ty == 'T') return $ftype; + return parent::_GetSize($ftype, $ty, $fsize, $fprec); + + } +} +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-mysql.inc.php b/includes/adodb/datadict/datadict-mysql.inc.php new file mode 100644 index 00000000..4b9e0df1 --- /dev/null +++ b/includes/adodb/datadict/datadict-mysql.inc.php @@ -0,0 +1,181 @@ +type; + $len = $fieldobj->max_length; + } + $is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->auto_increment; + + $len = -1; // mysql max_length is not accurate + switch (strtoupper($t)) { + case 'STRING': + case 'CHAR': + case 'VARCHAR': + case 'TINYBLOB': + case 'TINYTEXT': + case 'ENUM': + case 'SET': + if ($len <= $this->blobSize) return 'C'; + + case 'TEXT': + case 'LONGTEXT': + case 'MEDIUMTEXT': + return 'X'; + + // php_mysql extension always returns 'blob' even if 'text' + // so we have to check whether binary... + case 'IMAGE': + case 'LONGBLOB': + case 'BLOB': + case 'MEDIUMBLOB': + return !empty($fieldobj->binary) ? 'B' : 'X'; + + case 'YEAR': + case 'DATE': return 'D'; + + case 'TIME': + case 'DATETIME': + case 'TIMESTAMP': return 'T'; + + case 'FLOAT': + case 'DOUBLE': + return 'F'; + + case 'INT': + case 'INTEGER': return $is_serial ? 'R' : 'I'; + case 'TINYINT': return $is_serial ? 'R' : 'I1'; + case 'SMALLINT': return $is_serial ? 'R' : 'I2'; + case 'MEDIUMINT': return $is_serial ? 'R' : 'I4'; + case 'BIGINT': return $is_serial ? 'R' : 'I8'; + default: return 'N'; + } + } + + function ActualType($meta) + { + switch(strtoupper($meta)) { + case 'C': return 'VARCHAR'; + case 'XL':return 'LONGTEXT'; + case 'X': return 'TEXT'; + + case 'C2': return 'VARCHAR'; + case 'X2': return 'LONGTEXT'; + + case 'B': return 'LONGBLOB'; + + case 'D': return 'DATE'; + case 'T': return 'DATETIME'; + case 'L': return 'TINYINT'; + + case 'R': + case 'I4': + case 'I': return 'INTEGER'; + case 'I1': return 'TINYINT'; + case 'I2': return 'SMALLINT'; + case 'I8': return 'BIGINT'; + + case 'F': return 'DOUBLE'; + case 'N': return 'NUMERIC'; + default: + return $meta; + } + } + + // return string must begin with space + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) + { + $suffix = ''; + if ($funsigned) $suffix .= ' UNSIGNED'; + if ($fnotnull) $suffix .= ' NOT NULL'; + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fautoinc) $suffix .= ' AUTO_INCREMENT'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + /* + CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)] + [table_options] [select_statement] + create_definition: + col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] + [PRIMARY KEY] [reference_definition] + or PRIMARY KEY (index_col_name,...) + or KEY [index_name] (index_col_name,...) + or INDEX [index_name] (index_col_name,...) + or UNIQUE [INDEX] [index_name] (index_col_name,...) + or FULLTEXT [INDEX] [index_name] (index_col_name,...) + or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...) + [reference_definition] + or CHECK (expr) + */ + + /* + CREATE [UNIQUE|FULLTEXT] INDEX index_name + ON tbl_name (col_name[(length)],... ) + */ + + function _IndexSQL($idxname, $tabname, $flds, $idxoptions) + { + $sql = array(); + + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { + if ($this->alterTableAddIndex) $sql[] = "ALTER TABLE $tabname DROP INDEX $idxname"; + else $sql[] = sprintf($this->dropIndex, $idxname, $tabname); + + if ( isset($idxoptions['DROP']) ) + return $sql; + } + + if ( empty ($flds) ) { + return $sql; + } + + if (isset($idxoptions['FULLTEXT'])) { + $unique = ' FULLTEXT'; + } elseif (isset($idxoptions['UNIQUE'])) { + $unique = ' UNIQUE'; + } else { + $unique = ''; + } + + if ( is_array($flds) ) $flds = implode(', ',$flds); + + if ($this->alterTableAddIndex) $s = "ALTER TABLE $tabname ADD $unique INDEX $idxname "; + else $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname; + + $s .= ' (' . $flds . ')'; + + if ( isset($idxoptions[$this->upperName]) ) + $s .= $idxoptions[$this->upperName]; + + $sql[] = $s; + + return $sql; + } +} +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-oci8.inc.php b/includes/adodb/datadict/datadict-oci8.inc.php new file mode 100644 index 00000000..b48e8546 --- /dev/null +++ b/includes/adodb/datadict/datadict-oci8.inc.php @@ -0,0 +1,291 @@ +type; + $len = $fieldobj->max_length; + } + switch (strtoupper($t)) { + case 'VARCHAR': + case 'VARCHAR2': + case 'CHAR': + case 'VARBINARY': + case 'BINARY': + if (isset($this) && $len <= $this->blobSize) return 'C'; + return 'X'; + + case 'NCHAR': + case 'NVARCHAR2': + case 'NVARCHAR': + if (isset($this) && $len <= $this->blobSize) return 'C2'; + return 'X2'; + + case 'NCLOB': + case 'CLOB': + return 'XL'; + + case 'LONG RAW': + case 'LONG VARBINARY': + case 'BLOB': + return 'B'; + + case 'DATE': + return 'T'; + + case 'INT': + case 'SMALLINT': + case 'INTEGER': + return 'I'; + + default: + return 'N'; + } + } + + function ActualType($meta) + { + switch($meta) { + case 'C': return 'VARCHAR'; + case 'X': return $this->typeX; + case 'XL': return $this->typeXL; + + case 'C2': return 'NVARCHAR2'; + case 'X2': return 'NVARCHAR2(4000)'; + + case 'B': return 'BLOB'; + + case 'D': + case 'T': return 'DATE'; + case 'L': return 'NUMBER(1)'; + case 'I1': return 'NUMBER(3)'; + case 'I2': return 'NUMBER(5)'; + case 'I': + case 'I4': return 'NUMBER(10)'; + + case 'I8': return 'NUMBER(20)'; + case 'F': return 'NUMBER'; + case 'N': return 'NUMBER'; + case 'R': return 'NUMBER(20)'; + default: + return $meta; + } + } + + function CreateDatabase($dbname, $options=false) + { + $options = $this->_Options($options); + $password = isset($options['PASSWORD']) ? $options['PASSWORD'] : 'tiger'; + $tablespace = isset($options["TABLESPACE"]) ? " DEFAULT TABLESPACE ".$options["TABLESPACE"] : ''; + $sql[] = "CREATE USER ".$dbname." IDENTIFIED BY ".$password.$tablespace; + $sql[] = "GRANT CREATE SESSION, CREATE TABLE,UNLIMITED TABLESPACE,CREATE SEQUENCE TO $dbname"; + + return $sql; + } + + function AddColumnSQL($tabname, $flds) + { + $f = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $s = "ALTER TABLE $tabname ADD ("; + foreach($lines as $v) { + $f[] = "\n $v"; + } + + $s .= implode(', ',$f).')'; + $sql[] = $s; + return $sql; + } + + function AlterColumnSQL($tabname, $flds) + { + $f = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $s = "ALTER TABLE $tabname MODIFY("; + foreach($lines as $v) { + $f[] = "\n $v"; + } + $s .= implode(', ',$f).')'; + $sql[] = $s; + return $sql; + } + + function DropColumnSQL($tabname, $flds) + { + if (!is_array($flds)) $flds = explode(',',$flds); + foreach ($flds as $k => $v) $flds[$k] = $this->NameQuote($v); + + $sql = array(); + $s = "ALTER TABLE $tabname DROP("; + $s .= implode(', ',$flds).') CASCADE CONSTRAINTS'; + $sql[] = $s; + return $sql; + } + + function _DropAutoIncrement($t) + { + if (strpos($t,'.') !== false) { + $tarr = explode('.',$t); + return "drop sequence ".$tarr[0].".seq_".$tarr[1]; + } + return "drop sequence seq_".$t; + } + + // return string must begin with space + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) + { + $suffix = ''; + + if ($fdefault == "''" && $fnotnull) {// this is null in oracle + $fnotnull = false; + if ($this->debug) ADOConnection::outp("NOT NULL and DEFAULT='' illegal in Oracle"); + } + + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fnotnull) $suffix .= ' NOT NULL'; + + if ($fautoinc) $this->seqField = $fname; + if ($fconstraint) $suffix .= ' '.$fconstraint; + + return $suffix; + } + +/* +CREATE or replace TRIGGER jaddress_insert +before insert on jaddress +for each row +begin +select seqaddress.nextval into :new.A_ID from dual; +end; +*/ + function _Triggers($tabname,$tableoptions) + { + if (!$this->seqField) return array(); + + if ($this->schema) { + $t = strpos($tabname,'.'); + if ($t !== false) $tab = substr($tabname,$t+1); + else $tab = $tabname; + $seqname = $this->schema.'.'.$this->seqPrefix.$tab; + $trigname = $this->schema.'.'.$this->trigPrefix.$this->seqPrefix.$tab; + } else { + $seqname = $this->seqPrefix.$tabname; + $trigname = $this->trigPrefix.$seqname; + } + + if (strlen($seqname) > 30) { + $seqname = $this->seqPrefix.uniqid(''); + } // end if + if (strlen($trigname) > 30) { + $trigname = $this->trigPrefix.uniqid(''); + } // end if + + if (isset($tableoptions['REPLACE'])) $sql[] = "DROP SEQUENCE $seqname"; + $seqCache = ''; + if (isset($tableoptions['SEQUENCE_CACHE'])){$seqCache = $tableoptions['SEQUENCE_CACHE'];} + $seqIncr = ''; + if (isset($tableoptions['SEQUENCE_INCREMENT'])){$seqIncr = ' INCREMENT BY '.$tableoptions['SEQUENCE_INCREMENT'];} + $seqStart = ''; + if (isset($tableoptions['SEQUENCE_START'])){$seqIncr = ' START WITH '.$tableoptions['SEQUENCE_START'];} + $sql[] = "CREATE SEQUENCE $seqname $seqStart $seqIncr $seqCache"; + $sql[] = "CREATE OR REPLACE TRIGGER $trigname BEFORE insert ON $tabname FOR EACH ROW WHEN (NEW.$this->seqField IS NULL OR NEW.$this->seqField = 0) BEGIN select $seqname.nextval into :new.$this->seqField from dual; END;"; + + $this->seqField = false; + return $sql; + } + + /* + CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)] + [table_options] [select_statement] + create_definition: + col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] + [PRIMARY KEY] [reference_definition] + or PRIMARY KEY (index_col_name,...) + or KEY [index_name] (index_col_name,...) + or INDEX [index_name] (index_col_name,...) + or UNIQUE [INDEX] [index_name] (index_col_name,...) + or FULLTEXT [INDEX] [index_name] (index_col_name,...) + or [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...) + [reference_definition] + or CHECK (expr) + */ + + + + function _IndexSQL($idxname, $tabname, $flds,$idxoptions) + { + $sql = array(); + + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { + $sql[] = sprintf ($this->dropIndex, $idxname, $tabname); + if ( isset($idxoptions['DROP']) ) + return $sql; + } + + if ( empty ($flds) ) { + return $sql; + } + + if (isset($idxoptions['BITMAP'])) { + $unique = ' BITMAP'; + } elseif (isset($idxoptions['UNIQUE'])) { + $unique = ' UNIQUE'; + } else { + $unique = ''; + } + + if ( is_array($flds) ) + $flds = implode(', ',$flds); + $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')'; + + if ( isset($idxoptions[$this->upperName]) ) + $s .= $idxoptions[$this->upperName]; + + if (isset($idxoptions['oci8'])) + $s .= $idxoptions['oci8']; + + + $sql[] = $s; + + return $sql; + } + + function GetCommentSQL($table,$col) + { + $table = $this->connection->qstr($table); + $col = $this->connection->qstr($col); + return "select comments from USER_COL_COMMENTS where TABLE_NAME=$table and COLUMN_NAME=$col"; + } + + function SetCommentSQL($table,$col,$cmt) + { + $cmt = $this->connection->qstr($cmt); + return "COMMENT ON COLUMN $table.$col IS $cmt"; + } +} +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-postgres.inc.php b/includes/adodb/datadict/datadict-postgres.inc.php new file mode 100644 index 00000000..eb76566e --- /dev/null +++ b/includes/adodb/datadict/datadict-postgres.inc.php @@ -0,0 +1,447 @@ +type; + $len = $fieldobj->max_length; + } + $is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->unique && + $fieldobj->has_default && substr($fieldobj->default_value,0,8) == 'nextval('; + + switch (strtoupper($t)) { + case 'INTERVAL': + case 'CHAR': + case 'CHARACTER': + case 'VARCHAR': + case 'NAME': + case 'BPCHAR': + if ($len <= $this->blobSize) return 'C'; + + case 'TEXT': + return 'X'; + + case 'IMAGE': // user defined type + case 'BLOB': // user defined type + case 'BIT': // This is a bit string, not a single bit, so don't return 'L' + case 'VARBIT': + case 'BYTEA': + return 'B'; + + case 'BOOL': + case 'BOOLEAN': + return 'L'; + + case 'DATE': + return 'D'; + + case 'TIME': + case 'DATETIME': + case 'TIMESTAMP': + case 'TIMESTAMPTZ': + return 'T'; + + case 'INTEGER': return !$is_serial ? 'I' : 'R'; + case 'SMALLINT': + case 'INT2': return !$is_serial ? 'I2' : 'R'; + case 'INT4': return !$is_serial ? 'I4' : 'R'; + case 'BIGINT': + case 'INT8': return !$is_serial ? 'I8' : 'R'; + + case 'OID': + case 'SERIAL': + return 'R'; + + case 'FLOAT4': + case 'FLOAT8': + case 'DOUBLE PRECISION': + case 'REAL': + return 'F'; + + default: + return 'N'; + } + } + + function ActualType($meta) + { + switch($meta) { + case 'C': return 'VARCHAR'; + case 'XL': + case 'X': return 'TEXT'; + + case 'C2': return 'VARCHAR'; + case 'X2': return 'TEXT'; + + case 'B': return 'BYTEA'; + + case 'D': return 'DATE'; + case 'T': return 'TIMESTAMP'; + + case 'L': return 'BOOLEAN'; + case 'I': return 'INTEGER'; + case 'I1': return 'SMALLINT'; + case 'I2': return 'INT2'; + case 'I4': return 'INT4'; + case 'I8': return 'INT8'; + + case 'F': return 'FLOAT8'; + case 'N': return 'NUMERIC'; + default: + return $meta; + } + } + + /** + * Adding a new Column + * + * reimplementation of the default function as postgres does NOT allow to set the default in the same statement + * + * @param string $tabname table-name + * @param string $flds column-names and types for the changed columns + * @return array with SQL strings + */ + function AddColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' '; + foreach($lines as $v) { + if (($not_null = preg_match('/NOT NULL/i',$v))) { + $v = preg_replace('/NOT NULL/i','',$v); + } + if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) { + list(,$colname,$default) = $matches; + $sql[] = $alter . str_replace('DEFAULT '.$default,'',$v); + $sql[] = 'UPDATE '.$tabname.' SET '.$colname.'='.$default; + $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default; + } else { + $sql[] = $alter . $v; + } + if ($not_null) { + list($colname) = explode(' ',$v); + $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL'; + } + } + return $sql; + } + + + function DropIndexSQL ($idxname, $tabname = NULL) + { + return array(sprintf($this->dropIndex, $this->TableName($idxname), $this->TableName($tabname))); + } + + /** + * Change the definition of one column + * + * Postgres can't do that on it's own, you need to supply the complete defintion of the new table, + * to allow, recreating the table and copying the content over to the new table + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds complete defintion of the new table, eg. for postgres, default '' + * @param array/ $tableoptions options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + /* + function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + if (!$tableflds) { + if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL"); + return array(); + } + return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions); + }*/ + + function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + // Check if alter single column datatype available - works with 8.0+ + $has_alter_column = 8.0 <= (float) @$this->serverInfo['version']; + + if ($has_alter_column) { + $tabname = $this->TableName($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' '; + foreach($lines as $v) { + if ($not_null = preg_match('/NOT NULL/i',$v)) { + $v = preg_replace('/NOT NULL/i','',$v); + } + // this next block doesn't work - there is no way that I can see to + // explicitly ask a column to be null using $flds + else if ($set_null = preg_match('/NULL/i',$v)) { + // if they didn't specify not null, see if they explicitely asked for null + $v = preg_replace('/\sNULL/i','',$v); + } + + if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) { + list(,$colname,$default) = $matches; + $v = preg_replace('/^' . preg_quote($colname) . '\s/', '', $v); + $sql[] = $alter . $colname . ' TYPE ' . str_replace('DEFAULT '.$default,'',$v); + $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default; + } + else { + // drop default? + preg_match ('/^\s*(\S+)\s+(.*)$/',$v,$matches); + list (,$colname,$rest) = $matches; + $sql[] = $alter . $colname . ' TYPE ' . $rest; + } + + list($colname) = explode(' ',$v); + if ($not_null) { + // this does not error out if the column is already not null + $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL'; + } + if ($set_null) { + // this does not error out if the column is already null + $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' DROP NOT NULL'; + } + } + return $sql; + } + + // does not have alter column + if (!$tableflds) { + if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL"); + return array(); + } + return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions); + } + + /** + * Drop one column + * + * Postgres < 7.3 can't do that on it's own, you need to supply the complete defintion of the new table, + * to allow, recreating the table and copying the content over to the new table + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds complete defintion of the new table, eg. for postgres, default '' + * @param array/ $tableoptions options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + $has_drop_column = 7.3 <= (float) @$this->serverInfo['version']; + if (!$has_drop_column && !$tableflds) { + if ($this->debug) ADOConnection::outp("DropColumnSQL needs complete table-definiton for PostgreSQL < 7.3"); + return array(); + } + if ($has_drop_column) { + return ADODB_DataDict::DropColumnSQL($tabname, $flds); + } + return $this->_recreate_copy_table($tabname,$flds,$tableflds,$tableoptions); + } + + /** + * Save the content into a temp. table, drop and recreate the original table and copy the content back in + * + * We also take care to set the values of the sequenz and recreate the indexes. + * All this is done in a transaction, to not loose the content of the table, if something went wrong! + * @internal + * @param string $tabname table-name + * @param string $dropflds column-names to drop + * @param string $tableflds complete defintion of the new table, eg. for postgres + * @param array/string $tableoptions options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + function _recreate_copy_table($tabname,$dropflds,$tableflds,$tableoptions='') + { + if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds); + $copyflds = array(); + foreach($this->MetaColumns($tabname) as $fld) { + if (!$dropflds || !in_array($fld->name,$dropflds)) { + // we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one + if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) && + in_array($fld->type,array('varchar','char','text','bytea'))) { + $copyflds[] = "to_number($fld->name,'S9999999999999D99')"; + } else { + $copyflds[] = $fld->name; + } + // identify the sequence name and the fld its on + if ($fld->primary_key && $fld->has_default && + preg_match("/nextval\('([^']+)'::text\)/",$fld->default_value,$matches)) { + $seq_name = $matches[1]; + $seq_fld = $fld->name; + } + } + } + $copyflds = implode(', ',$copyflds); + + $tempname = $tabname.'_tmp'; + $aSql[] = 'BEGIN'; // we use a transaction, to make sure not to loose the content of the table + $aSql[] = "SELECT * INTO TEMPORARY TABLE $tempname FROM $tabname"; + $aSql = array_merge($aSql,$this->DropTableSQL($tabname)); + $aSql = array_merge($aSql,$this->CreateTableSQL($tabname,$tableflds,$tableoptions)); + $aSql[] = "INSERT INTO $tabname SELECT $copyflds FROM $tempname"; + if ($seq_name && $seq_fld) { // if we have a sequence we need to set it again + $seq_name = $tabname.'_'.$seq_fld.'_seq'; // has to be the name of the new implicit sequence + $aSql[] = "SELECT setval('$seq_name',MAX($seq_fld)) FROM $tabname"; + } + $aSql[] = "DROP TABLE $tempname"; + // recreate the indexes, if they not contain one of the droped columns + foreach($this->MetaIndexes($tabname) as $idx_name => $idx_data) + { + if (substr($idx_name,-5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds,$idx_data['columns'])))) { + $aSql = array_merge($aSql,$this->CreateIndexSQL($idx_name,$tabname,$idx_data['columns'], + $idx_data['unique'] ? array('UNIQUE') : False)); + } + } + $aSql[] = 'COMMIT'; + return $aSql; + } + + function DropTableSQL($tabname) + { + $sql = ADODB_DataDict::DropTableSQL($tabname); + + $drop_seq = $this->_DropAutoIncrement($tabname); + if ($drop_seq) $sql[] = $drop_seq; + + return $sql; + } + + // return string must begin with space + function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint) + { + if ($fautoinc) { + $ftype = 'SERIAL'; + return ''; + } + $suffix = ''; + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + // search for a sequece for the given table (asumes the seqence-name contains the table-name!) + // if yes return sql to drop it + // this is still necessary if postgres < 7.3 or the SERIAL was created on an earlier version!!! + function _DropAutoIncrement($tabname) + { + $tabname = $this->connection->quote('%'.$tabname.'%'); + + $seq = $this->connection->GetOne("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE $tabname AND relkind='S'"); + + // check if a tables depends on the sequenz and it therefor cant and dont need to be droped separatly + if (!$seq || $this->connection->GetOne("SELECT relname FROM pg_class JOIN pg_depend ON pg_class.relfilenode=pg_depend.objid WHERE relname='$seq' AND relkind='S' AND deptype='i'")) { + return False; + } + return "DROP SEQUENCE ".$seq; + } + + function RenameTableSQL($tabname,$newname) + { + if (!empty($this->schema)) { + $rename_from = $this->TableName($tabname); + $schema_save = $this->schema; + $this->schema = false; + $rename_to = $this->TableName($newname); + $this->schema = $schema_save; + return array (sprintf($this->renameTable, $rename_from, $rename_to)); + } + + return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname))); + } + + /* + CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name ( + { column_name data_type [ DEFAULT default_expr ] [ column_constraint [, ... ] ] + | table_constraint } [, ... ] + ) + [ INHERITS ( parent_table [, ... ] ) ] + [ WITH OIDS | WITHOUT OIDS ] + where column_constraint is: + [ CONSTRAINT constraint_name ] + { NOT NULL | NULL | UNIQUE | PRIMARY KEY | + CHECK (expression) | + REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL ] + [ ON DELETE action ] [ ON UPDATE action ] } + [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] + and table_constraint is: + [ CONSTRAINT constraint_name ] + { UNIQUE ( column_name [, ... ] ) | + PRIMARY KEY ( column_name [, ... ] ) | + CHECK ( expression ) | + FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ] + [ MATCH FULL | MATCH PARTIAL ] [ ON DELETE action ] [ ON UPDATE action ] } + [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] + */ + + + /* + CREATE [ UNIQUE ] INDEX index_name ON table +[ USING acc_method ] ( column [ ops_name ] [, ...] ) +[ WHERE predicate ] +CREATE [ UNIQUE ] INDEX index_name ON table +[ USING acc_method ] ( func_name( column [, ... ]) [ ops_name ] ) +[ WHERE predicate ] + */ + function _IndexSQL($idxname, $tabname, $flds, $idxoptions) + { + $sql = array(); + + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { + $sql[] = sprintf ($this->dropIndex, $idxname, $tabname); + if ( isset($idxoptions['DROP']) ) + return $sql; + } + + if ( empty ($flds) ) { + return $sql; + } + + $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : ''; + + $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' '; + + if (isset($idxoptions['HASH'])) + $s .= 'USING HASH '; + + if ( isset($idxoptions[$this->upperName]) ) + $s .= $idxoptions[$this->upperName]; + + if ( is_array($flds) ) + $flds = implode(', ',$flds); + $s .= '(' . $flds . ')'; + $sql[] = $s; + + return $sql; + } + + function _GetSize($ftype, $ty, $fsize, $fprec) + { + if (strlen($fsize) && $ty != 'X' && $ty != 'B' && $ty != 'I' && strpos($ftype,'(') === false) { + $ftype .= "(".$fsize; + if (strlen($fprec)) $ftype .= ",".$fprec; + $ftype .= ')'; + } + return $ftype; + } +} +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-postgres.inc.php.bak b/includes/adodb/datadict/datadict-postgres.inc.php.bak new file mode 100644 index 00000000..ce63858a --- /dev/null +++ b/includes/adodb/datadict/datadict-postgres.inc.php.bak @@ -0,0 +1,441 @@ +type; + $len = $fieldobj->max_length; + } + $is_serial = is_object($fieldobj) && $fieldobj->primary_key && $fieldobj->unique && + $fieldobj->has_default && substr($fieldobj->default_value,0,8) == 'nextval('; + + switch (strtoupper($t)) { + case 'INTERVAL': + case 'CHAR': + case 'CHARACTER': + case 'VARCHAR': + case 'NAME': + case 'BPCHAR': + if ($len <= $this->blobSize) return 'C'; + + case 'TEXT': + return 'X'; + + case 'IMAGE': // user defined type + case 'BLOB': // user defined type + case 'BIT': // This is a bit string, not a single bit, so don't return 'L' + case 'VARBIT': + case 'BYTEA': + return 'B'; + + case 'BOOL': + case 'BOOLEAN': + return 'L'; + + case 'DATE': + return 'D'; + + case 'TIME': + case 'DATETIME': + case 'TIMESTAMP': + case 'TIMESTAMPTZ': + return 'T'; + + case 'INTEGER': return !$is_serial ? 'I' : 'R'; + case 'SMALLINT': + case 'INT2': return !$is_serial ? 'I2' : 'R'; + case 'INT4': return !$is_serial ? 'I4' : 'R'; + case 'BIGINT': + case 'INT8': return !$is_serial ? 'I8' : 'R'; + + case 'OID': + case 'SERIAL': + return 'R'; + + case 'FLOAT4': + case 'FLOAT8': + case 'DOUBLE PRECISION': + case 'REAL': + return 'F'; + + default: + return 'N'; + } + } + + function ActualType($meta) + { + switch($meta) { + case 'C': return 'VARCHAR'; + case 'XL': + case 'X': return 'TEXT'; + + case 'C2': return 'VARCHAR'; + case 'X2': return 'TEXT'; + + case 'B': return 'BYTEA'; + + case 'D': return 'DATE'; + case 'T': return 'TIMESTAMP'; + + case 'L': return 'BOOLEAN'; + case 'I': return 'INTEGER'; + case 'I1': return 'SMALLINT'; + case 'I2': return 'INT2'; + case 'I4': return 'INT4'; + case 'I8': return 'INT8'; + + case 'F': return 'FLOAT8'; + case 'N': return 'NUMERIC'; + default: + return $meta; + } + } + + /** + * Adding a new Column + * + * reimplementation of the default function as postgres does NOT allow to set the default in the same statement + * + * @param string $tabname table-name + * @param string $flds column-names and types for the changed columns + * @return array with SQL strings + */ + function AddColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' '; + foreach($lines as $v) { + if (($not_null = preg_match('/NOT NULL/i',$v))) { + $v = preg_replace('/NOT NULL/i','',$v); + } + if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) { + list(,$colname,$default) = $matches; + $sql[] = $alter . str_replace('DEFAULT '.$default,'',$v); + $sql[] = 'UPDATE '.$tabname.' SET '.$colname.'='.$default; + $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default; + } else { + $sql[] = $alter . $v; + } + if ($not_null) { + list($colname) = explode(' ',$v); + $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL'; + } + } + return $sql; + } + + /** + * Change the definition of one column + * + * Postgres can't do that on it's own, you need to supply the complete defintion of the new table, + * to allow, recreating the table and copying the content over to the new table + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds complete defintion of the new table, eg. for postgres, default '' + * @param array/ $tableoptions options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + /* + function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + if (!$tableflds) { + if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL"); + return array(); + } + return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions); + }*/ + + function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + // Check if alter single column datatype available - works with 8.0+ + $has_alter_column = 8.0 <= (float) @$this->serverInfo['version']; + + if ($has_alter_column) { + $tabname = $this->TableName($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' '; + foreach($lines as $v) { + if ($not_null = preg_match('/NOT NULL/i',$v)) { + $v = preg_replace('/NOT NULL/i','',$v); + } + // this next block doesn't work - there is no way that I can see to + // explicitly ask a column to be null using $flds + else if ($set_null = preg_match('/NULL/i',$v)) { + // if they didn't specify not null, see if they explicitely asked for null + $v = preg_replace('/\sNULL/i','',$v); + } + + if (preg_match('/^([^ ]+) .*DEFAULT ([^ ]+)/',$v,$matches)) { + list(,$colname,$default) = $matches; + $v = preg_replace('/^' . preg_quote($colname) . '\s/', '', $v); + $sql[] = $alter . $colname . ' TYPE ' . str_replace('DEFAULT '.$default,'',$v); + $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET DEFAULT ' . $default; + } + else { + // drop default? + preg_match ('/^\s*(\S+)\s+(.*)$/',$v,$matches); + list (,$colname,$rest) = $matches; + $sql[] = $alter . $colname . ' TYPE ' . $rest; + } + + list($colname) = explode(' ',$v); + if ($not_null) { + // this does not error out if the column is already not null + $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' SET NOT NULL'; + } + if ($set_null) { + // this does not error out if the column is already null + $sql[] = 'ALTER TABLE '.$tabname.' ALTER COLUMN '.$colname.' DROP NOT NULL'; + } + } + return $sql; + } + + // does not have alter column + if (!$tableflds) { + if ($this->debug) ADOConnection::outp("AlterColumnSQL needs a complete table-definiton for PostgreSQL"); + return array(); + } + return $this->_recreate_copy_table($tabname,False,$tableflds,$tableoptions); + } + + /** + * Drop one column + * + * Postgres < 7.3 can't do that on it's own, you need to supply the complete defintion of the new table, + * to allow, recreating the table and copying the content over to the new table + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds complete defintion of the new table, eg. for postgres, default '' + * @param array/ $tableoptions options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + $has_drop_column = 7.3 <= (float) @$this->serverInfo['version']; + if (!$has_drop_column && !$tableflds) { + if ($this->debug) ADOConnection::outp("DropColumnSQL needs complete table-definiton for PostgreSQL < 7.3"); + return array(); + } + if ($has_drop_column) { + return ADODB_DataDict::DropColumnSQL($tabname, $flds); + } + return $this->_recreate_copy_table($tabname,$flds,$tableflds,$tableoptions); + } + + /** + * Save the content into a temp. table, drop and recreate the original table and copy the content back in + * + * We also take care to set the values of the sequenz and recreate the indexes. + * All this is done in a transaction, to not loose the content of the table, if something went wrong! + * @internal + * @param string $tabname table-name + * @param string $dropflds column-names to drop + * @param string $tableflds complete defintion of the new table, eg. for postgres + * @param array/string $tableoptions options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + function _recreate_copy_table($tabname,$dropflds,$tableflds,$tableoptions='') + { + if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds); + $copyflds = array(); + foreach($this->MetaColumns($tabname) as $fld) { + if (!$dropflds || !in_array($fld->name,$dropflds)) { + // we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one + if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) && + in_array($fld->type,array('varchar','char','text','bytea'))) { + $copyflds[] = "to_number($fld->name,'S9999999999999D99')"; + } else { + $copyflds[] = $fld->name; + } + // identify the sequence name and the fld its on + if ($fld->primary_key && $fld->has_default && + preg_match("/nextval\('([^']+)'::text\)/",$fld->default_value,$matches)) { + $seq_name = $matches[1]; + $seq_fld = $fld->name; + } + } + } + $copyflds = implode(', ',$copyflds); + + $tempname = $tabname.'_tmp'; + $aSql[] = 'BEGIN'; // we use a transaction, to make sure not to loose the content of the table + $aSql[] = "SELECT * INTO TEMPORARY TABLE $tempname FROM $tabname"; + $aSql = array_merge($aSql,$this->DropTableSQL($tabname)); + $aSql = array_merge($aSql,$this->CreateTableSQL($tabname,$tableflds,$tableoptions)); + $aSql[] = "INSERT INTO $tabname SELECT $copyflds FROM $tempname"; + if ($seq_name && $seq_fld) { // if we have a sequence we need to set it again + $seq_name = $tabname.'_'.$seq_fld.'_seq'; // has to be the name of the new implicit sequence + $aSql[] = "SELECT setval('$seq_name',MAX($seq_fld)) FROM $tabname"; + } + $aSql[] = "DROP TABLE $tempname"; + // recreate the indexes, if they not contain one of the droped columns + foreach($this->MetaIndexes($tabname) as $idx_name => $idx_data) + { + if (substr($idx_name,-5) != '_pkey' && (!$dropflds || !count(array_intersect($dropflds,$idx_data['columns'])))) { + $aSql = array_merge($aSql,$this->CreateIndexSQL($idx_name,$tabname,$idx_data['columns'], + $idx_data['unique'] ? array('UNIQUE') : False)); + } + } + $aSql[] = 'COMMIT'; + return $aSql; + } + + function DropTableSQL($tabname) + { + $sql = ADODB_DataDict::DropTableSQL($tabname); + + $drop_seq = $this->_DropAutoIncrement($tabname); + if ($drop_seq) $sql[] = $drop_seq; + + return $sql; + } + + // return string must begin with space + function _CreateSuffix($fname, &$ftype, $fnotnull,$fdefault,$fautoinc,$fconstraint) + { + if ($fautoinc) { + $ftype = 'SERIAL'; + return ''; + } + $suffix = ''; + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + // search for a sequece for the given table (asumes the seqence-name contains the table-name!) + // if yes return sql to drop it + // this is still necessary if postgres < 7.3 or the SERIAL was created on an earlier version!!! + function _DropAutoIncrement($tabname) + { + $tabname = $this->connection->quote('%'.$tabname.'%'); + + $seq = $this->connection->GetOne("SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE $tabname AND relkind='S'"); + + // check if a tables depends on the sequenz and it therefor cant and dont need to be droped separatly + if (!$seq || $this->connection->GetOne("SELECT relname FROM pg_class JOIN pg_depend ON pg_class.relfilenode=pg_depend.objid WHERE relname='$seq' AND relkind='S' AND deptype='i'")) { + return False; + } + return "DROP SEQUENCE ".$seq; + } + + function RenameTableSQL($tabname,$newname) + { + if (!empty($this->schema)) { + $rename_from = $this->TableName($tabname); + $schema_save = $this->schema; + $this->schema = false; + $rename_to = $this->TableName($newname); + $this->schema = $schema_save; + return array (sprintf($this->renameTable, $rename_from, $rename_to)); + } + + return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname))); + } + + /* + CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name ( + { column_name data_type [ DEFAULT default_expr ] [ column_constraint [, ... ] ] + | table_constraint } [, ... ] + ) + [ INHERITS ( parent_table [, ... ] ) ] + [ WITH OIDS | WITHOUT OIDS ] + where column_constraint is: + [ CONSTRAINT constraint_name ] + { NOT NULL | NULL | UNIQUE | PRIMARY KEY | + CHECK (expression) | + REFERENCES reftable [ ( refcolumn ) ] [ MATCH FULL | MATCH PARTIAL ] + [ ON DELETE action ] [ ON UPDATE action ] } + [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] + and table_constraint is: + [ CONSTRAINT constraint_name ] + { UNIQUE ( column_name [, ... ] ) | + PRIMARY KEY ( column_name [, ... ] ) | + CHECK ( expression ) | + FOREIGN KEY ( column_name [, ... ] ) REFERENCES reftable [ ( refcolumn [, ... ] ) ] + [ MATCH FULL | MATCH PARTIAL ] [ ON DELETE action ] [ ON UPDATE action ] } + [ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ] + */ + + + /* + CREATE [ UNIQUE ] INDEX index_name ON table +[ USING acc_method ] ( column [ ops_name ] [, ...] ) +[ WHERE predicate ] +CREATE [ UNIQUE ] INDEX index_name ON table +[ USING acc_method ] ( func_name( column [, ... ]) [ ops_name ] ) +[ WHERE predicate ] + */ + function _IndexSQL($idxname, $tabname, $flds, $idxoptions) + { + $sql = array(); + + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { + $sql[] = sprintf ($this->dropIndex, $idxname, $tabname); + if ( isset($idxoptions['DROP']) ) + return $sql; + } + + if ( empty ($flds) ) { + return $sql; + } + + $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : ''; + + $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' '; + + if (isset($idxoptions['HASH'])) + $s .= 'USING HASH '; + + if ( isset($idxoptions[$this->upperName]) ) + $s .= $idxoptions[$this->upperName]; + + if ( is_array($flds) ) + $flds = implode(', ',$flds); + $s .= '(' . $flds . ')'; + $sql[] = $s; + + return $sql; + } + + function _GetSize($ftype, $ty, $fsize, $fprec) + { + if (strlen($fsize) && $ty != 'X' && $ty != 'B' && $ty != 'I' && strpos($ftype,'(') === false) { + $ftype .= "(".$fsize; + if (strlen($fprec)) $ftype .= ",".$fprec; + $ftype .= ')'; + } + return $ftype; + } +} +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-sapdb.inc.php b/includes/adodb/datadict/datadict-sapdb.inc.php new file mode 100644 index 00000000..d9006296 --- /dev/null +++ b/includes/adodb/datadict/datadict-sapdb.inc.php @@ -0,0 +1,121 @@ +type; + $len = $fieldobj->max_length; + } + static $maxdb_type2adodb = array( + 'VARCHAR' => 'C', + 'CHARACTER' => 'C', + 'LONG' => 'X', // no way to differ between 'X' and 'B' :-( + 'DATE' => 'D', + 'TIMESTAMP' => 'T', + 'BOOLEAN' => 'L', + 'INTEGER' => 'I4', + 'SMALLINT' => 'I2', + 'FLOAT' => 'F', + 'FIXED' => 'N', + ); + $type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C'; + + // convert integer-types simulated with fixed back to integer + if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) { + $type = $len == 20 ? 'I8' : 'I1'; + } + if ($fieldobj->auto_increment) $type = 'R'; + + return $type; + } + + // return string must begin with space + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) + { + $suffix = ''; + if ($funsigned) $suffix .= ' UNSIGNED'; + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fautoinc) $suffix .= ' DEFAULT SERIAL'; + elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + function AddColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' ); + } + + function AlterColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' ); + } + + function DropColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + if (!is_array($flds)) $flds = explode(',',$flds); + foreach($flds as $k => $v) { + $flds[$k] = $this->NameQuote($v); + } + return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' ); + } +} + +?> \ No newline at end of file diff --git a/includes/adodb/datadict/datadict-sybase.inc.php b/includes/adodb/datadict/datadict-sybase.inc.php new file mode 100644 index 00000000..5d6f5629 --- /dev/null +++ b/includes/adodb/datadict/datadict-sybase.inc.php @@ -0,0 +1,228 @@ +type; + $len = $fieldobj->max_length; + } + + $len = -1; // mysql max_length is not accurate + switch (strtoupper($t)) { + + case 'INT': + case 'INTEGER': return 'I'; + case 'BIT': + case 'TINYINT': return 'I1'; + case 'SMALLINT': return 'I2'; + case 'BIGINT': return 'I8'; + + case 'REAL': + case 'FLOAT': return 'F'; + default: return parent::MetaType($t,$len,$fieldobj); + } + } + + function ActualType($meta) + { + switch(strtoupper($meta)) { + case 'C': return 'VARCHAR'; + case 'XL': + case 'X': return 'TEXT'; + + case 'C2': return 'NVARCHAR'; + case 'X2': return 'NTEXT'; + + case 'B': return 'IMAGE'; + + case 'D': return 'DATETIME'; + case 'T': return 'DATETIME'; + case 'L': return 'BIT'; + + case 'I': return 'INT'; + case 'I1': return 'TINYINT'; + case 'I2': return 'SMALLINT'; + case 'I4': return 'INT'; + case 'I8': return 'BIGINT'; + + case 'F': return 'REAL'; + case 'N': return 'NUMERIC'; + default: + return $meta; + } + } + + + function AddColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $f = array(); + list($lines,$pkey) = $this->_GenFields($flds); + $s = "ALTER TABLE $tabname $this->addCol"; + foreach($lines as $v) { + $f[] = "\n $v"; + } + $s .= implode(', ',$f); + $sql[] = $s; + return $sql; + } + + function AlterColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey) = $this->_GenFields($flds); + foreach($lines as $v) { + $sql[] = "ALTER TABLE $tabname $this->alterCol $v"; + } + + return $sql; + } + + function DropColumnSQL($tabname, $flds) + { + $tabname = $this->TableName($tabname); + if (!is_array($flds)) $flds = explode(',',$flds); + $f = array(); + $s = "ALTER TABLE $tabname"; + foreach($flds as $v) { + $f[] = "\n$this->dropCol ".$this->NameQuote($v); + } + $s .= implode(', ',$f); + $sql[] = $s; + return $sql; + } + + // return string must begin with space + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint) + { + $suffix = ''; + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fautoinc) $suffix .= ' DEFAULT AUTOINCREMENT'; + if ($fnotnull) $suffix .= ' NOT NULL'; + else if ($suffix == '') $suffix .= ' NULL'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + /* +CREATE TABLE + [ database_name.[ owner ] . | owner. ] table_name + ( { < column_definition > + | column_name AS computed_column_expression + | < table_constraint > ::= [ CONSTRAINT constraint_name ] } + + | [ { PRIMARY KEY | UNIQUE } [ ,...n ] + ) + +[ ON { filegroup | DEFAULT } ] +[ TEXTIMAGE_ON { filegroup | DEFAULT } ] + +< column_definition > ::= { column_name data_type } + [ COLLATE < collation_name > ] + [ [ DEFAULT constant_expression ] + | [ IDENTITY [ ( seed , increment ) [ NOT FOR REPLICATION ] ] ] + ] + [ ROWGUIDCOL] + [ < column_constraint > ] [ ...n ] + +< column_constraint > ::= [ CONSTRAINT constraint_name ] + { [ NULL | NOT NULL ] + | [ { PRIMARY KEY | UNIQUE } + [ CLUSTERED | NONCLUSTERED ] + [ WITH FILLFACTOR = fillfactor ] + [ON {filegroup | DEFAULT} ] ] + ] + | [ [ FOREIGN KEY ] + REFERENCES ref_table [ ( ref_column ) ] + [ ON DELETE { CASCADE | NO ACTION } ] + [ ON UPDATE { CASCADE | NO ACTION } ] + [ NOT FOR REPLICATION ] + ] + | CHECK [ NOT FOR REPLICATION ] + ( logical_expression ) + } + +< table_constraint > ::= [ CONSTRAINT constraint_name ] + { [ { PRIMARY KEY | UNIQUE } + [ CLUSTERED | NONCLUSTERED ] + { ( column [ ASC | DESC ] [ ,...n ] ) } + [ WITH FILLFACTOR = fillfactor ] + [ ON { filegroup | DEFAULT } ] + ] + | FOREIGN KEY + [ ( column [ ,...n ] ) ] + REFERENCES ref_table [ ( ref_column [ ,...n ] ) ] + [ ON DELETE { CASCADE | NO ACTION } ] + [ ON UPDATE { CASCADE | NO ACTION } ] + [ NOT FOR REPLICATION ] + | CHECK [ NOT FOR REPLICATION ] + ( search_conditions ) + } + + + */ + + /* + CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name + ON { table | view } ( column [ ASC | DESC ] [ ,...n ] ) + [ WITH < index_option > [ ,...n] ] + [ ON filegroup ] + < index_option > :: = + { PAD_INDEX | + FILLFACTOR = fillfactor | + IGNORE_DUP_KEY | + DROP_EXISTING | + STATISTICS_NORECOMPUTE | + SORT_IN_TEMPDB + } +*/ + function _IndexSQL($idxname, $tabname, $flds, $idxoptions) + { + $sql = array(); + + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { + $sql[] = sprintf ($this->dropIndex, $idxname, $tabname); + if ( isset($idxoptions['DROP']) ) + return $sql; + } + + if ( empty ($flds) ) { + return $sql; + } + + $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : ''; + $clustered = isset($idxoptions['CLUSTERED']) ? ' CLUSTERED' : ''; + + if ( is_array($flds) ) + $flds = implode(', ',$flds); + $s = 'CREATE' . $unique . $clustered . ' INDEX ' . $idxname . ' ON ' . $tabname . ' (' . $flds . ')'; + + if ( isset($idxoptions[$this->upperName]) ) + $s .= $idxoptions[$this->upperName]; + + $sql[] = $s; + + return $sql; + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-access.inc.php b/includes/adodb/drivers/adodb-access.inc.php new file mode 100644 index 00000000..59a6fa9e --- /dev/null +++ b/includes/adodb/drivers/adodb-access.inc.php @@ -0,0 +1,87 @@ +ADODB_odbc(); + } + + function Time() + { + return time(); + } + + function BeginTrans() { return false;} + + function IfNull( $field, $ifNull ) + { + return " IIF(IsNull($field), $ifNull, $field) "; // if Access + } +/* + function MetaTables() + { + global $ADODB_FETCH_MODE; + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $qid = odbc_tables($this->_connectionID); + $rs = new ADORecordSet_odbc($qid); + $ADODB_FETCH_MODE = $savem; + if (!$rs) return false; + + $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; + + $arr = $rs->GetArray(); + //print_pre($arr); + $arr2 = array(); + for ($i=0; $i < sizeof($arr); $i++) { + if ($arr[$i][2] && $arr[$i][3] != 'SYSTEM TABLE') + $arr2[] = $arr[$i][2]; + } + return $arr2; + }*/ +} + + +class ADORecordSet_access extends ADORecordSet_odbc { + + var $databaseType = "access"; + + function ADORecordSet_access($id,$mode=false) + { + return $this->ADORecordSet_odbc($id,$mode); + } +}// class +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-ado.inc.php b/includes/adodb/drivers/adodb-ado.inc.php new file mode 100644 index 00000000..75ea4c3a --- /dev/null +++ b/includes/adodb/drivers/adodb-ado.inc.php @@ -0,0 +1,644 @@ +_affectedRows = new VARIANT; + } + + function ServerInfo() + { + if (!empty($this->_connectionID)) $desc = $this->_connectionID->provider; + return array('description' => $desc, 'version' => ''); + } + + function _affectedrows() + { + if (PHP_VERSION >= 5) return $this->_affectedRows; + + return $this->_affectedRows->value; + } + + // you can also pass a connection string like this: + // + // $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB'); + function _connect($argHostname, $argUsername, $argPassword, $argProvider= 'MSDASQL') + { + $u = 'UID'; + $p = 'PWD'; + + if (!empty($this->charPage)) + $dbc = new COM('ADODB.Connection',null,$this->charPage); + else + $dbc = new COM('ADODB.Connection'); + + if (! $dbc) return false; + + /* special support if provider is mssql or access */ + if ($argProvider=='mssql') { + $u = 'User Id'; //User parameter name for OLEDB + $p = 'Password'; + $argProvider = "SQLOLEDB"; // SQL Server Provider + + // not yet + //if ($argDatabasename) $argHostname .= ";Initial Catalog=$argDatabasename"; + + //use trusted conection for SQL if username not specified + if (!$argUsername) $argHostname .= ";Trusted_Connection=Yes"; + } else if ($argProvider=='access') + $argProvider = "Microsoft.Jet.OLEDB.4.0"; // Microsoft Jet Provider + + if ($argProvider) $dbc->Provider = $argProvider; + + if ($argUsername) $argHostname .= ";$u=$argUsername"; + if ($argPassword)$argHostname .= ";$p=$argPassword"; + + if ($this->debug) ADOConnection::outp( "Host=".$argHostname."
\n version=$dbc->version"); + // @ added below for php 4.0.1 and earlier + @$dbc->Open((string) $argHostname); + + $this->_connectionID = $dbc; + + $dbc->CursorLocation = $this->_cursor_location; + return $dbc->State > 0; + } + + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argProvider='MSDASQL') + { + return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider); + } + +/* + adSchemaCatalogs = 1, + adSchemaCharacterSets = 2, + adSchemaCollations = 3, + adSchemaColumns = 4, + adSchemaCheckConstraints = 5, + adSchemaConstraintColumnUsage = 6, + adSchemaConstraintTableUsage = 7, + adSchemaKeyColumnUsage = 8, + adSchemaReferentialContraints = 9, + adSchemaTableConstraints = 10, + adSchemaColumnsDomainUsage = 11, + adSchemaIndexes = 12, + adSchemaColumnPrivileges = 13, + adSchemaTablePrivileges = 14, + adSchemaUsagePrivileges = 15, + adSchemaProcedures = 16, + adSchemaSchemata = 17, + adSchemaSQLLanguages = 18, + adSchemaStatistics = 19, + adSchemaTables = 20, + adSchemaTranslations = 21, + adSchemaProviderTypes = 22, + adSchemaViews = 23, + adSchemaViewColumnUsage = 24, + adSchemaViewTableUsage = 25, + adSchemaProcedureParameters = 26, + adSchemaForeignKeys = 27, + adSchemaPrimaryKeys = 28, + adSchemaProcedureColumns = 29, + adSchemaDBInfoKeywords = 30, + adSchemaDBInfoLiterals = 31, + adSchemaCubes = 32, + adSchemaDimensions = 33, + adSchemaHierarchies = 34, + adSchemaLevels = 35, + adSchemaMeasures = 36, + adSchemaProperties = 37, + adSchemaMembers = 38 + +*/ + + function MetaTables() + { + $arr= array(); + $dbc = $this->_connectionID; + + $adors=@$dbc->OpenSchema(20);//tables + if ($adors){ + $f = $adors->Fields(2);//table/view name + $t = $adors->Fields(3);//table type + while (!$adors->EOF){ + $tt=substr($t->value,0,6); + if ($tt!='SYSTEM' && $tt !='ACCESS') + $arr[]=$f->value; + //print $f->value . ' ' . $t->value.'
'; + $adors->MoveNext(); + } + $adors->Close(); + } + + return $arr; + } + + function MetaColumns($table) + { + $table = strtoupper($table); + $arr = array(); + $dbc = $this->_connectionID; + + $adors=@$dbc->OpenSchema(4);//tables + + if ($adors){ + $t = $adors->Fields(2);//table/view name + while (!$adors->EOF){ + + + if (strtoupper($t->Value) == $table) { + + $fld = new ADOFieldObject(); + $c = $adors->Fields(3); + $fld->name = $c->Value; + $fld->type = 'CHAR'; // cannot discover type in ADO! + $fld->max_length = -1; + $arr[strtoupper($fld->name)]=$fld; + } + + $adors->MoveNext(); + } + $adors->Close(); + } + $false = false; + return empty($arr) ? $false : $arr; + } + + + + + /* returns queryID or false */ + function _query($sql,$inputarr=false) + { + + $dbc = $this->_connectionID; + $false = false; + + // return rs + if ($inputarr) { + + if (!empty($this->charPage)) + $oCmd = new COM('ADODB.Command',null,$this->charPage); + else + $oCmd = new COM('ADODB.Command'); + $oCmd->ActiveConnection = $dbc; + $oCmd->CommandText = $sql; + $oCmd->CommandType = 1; + + foreach($inputarr as $val) { + // name, type, direction 1 = input, len, + $this->adoParameterType = 130; + $p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val); + //print $p->Type.' '.$p->value; + $oCmd->Parameters->Append($p); + } + $p = false; + $rs = $oCmd->Execute(); + $e = $dbc->Errors; + if ($dbc->Errors->Count > 0) return $false; + return $rs; + } + + $rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option); + + if ($dbc->Errors->Count > 0) return $false; + if (! $rs) return $false; + + if ($rs->State == 0) { + $true = true; + return $true; // 0 = adStateClosed means no records returned + } + return $rs; + } + + + function BeginTrans() + { + if ($this->transOff) return true; + + if (isset($this->_thisTransactions)) + if (!$this->_thisTransactions) return false; + else { + $o = $this->_connectionID->Properties("Transaction DDL"); + $this->_thisTransactions = $o ? true : false; + if (!$o) return false; + } + @$this->_connectionID->BeginTrans(); + $this->transCnt += 1; + return true; + } + + function CommitTrans($ok=true) + { + if (!$ok) return $this->RollbackTrans(); + if ($this->transOff) return true; + + @$this->_connectionID->CommitTrans(); + if ($this->transCnt) @$this->transCnt -= 1; + return true; + } + function RollbackTrans() { + if ($this->transOff) return true; + @$this->_connectionID->RollbackTrans(); + if ($this->transCnt) @$this->transCnt -= 1; + return true; + } + + /* Returns: the last error message from previous database operation */ + + function ErrorMsg() + { + if (!$this->_connectionID) return "No connection established"; + $errc = $this->_connectionID->Errors; + if (!$errc) return "No Errors object found"; + if ($errc->Count == 0) return ''; + $err = $errc->Item($errc->Count-1); + return $err->Description; + } + + function ErrorNo() + { + $errc = $this->_connectionID->Errors; + if ($errc->Count == 0) return 0; + $err = $errc->Item($errc->Count-1); + return $err->NativeError; + } + + // returns true or false + function _close() + { + if ($this->_connectionID) $this->_connectionID->Close(); + $this->_connectionID = false; + return true; + } + + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordSet_ado extends ADORecordSet { + + var $bind = false; + var $databaseType = "ado"; + var $dataProvider = "ado"; + var $_tarr = false; // caches the types + var $_flds; // and field objects + var $canSeek = true; + var $hideErrors = true; + + function ADORecordSet_ado($id,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + $this->fetchMode = $mode; + return $this->ADORecordSet($id,$mode); + } + + + // returns the field object + function FetchField($fieldOffset = -1) { + $off=$fieldOffset+1; // offsets begin at 1 + + $o= new ADOFieldObject(); + $rs = $this->_queryID; + $f = $rs->Fields($fieldOffset); + $o->name = $f->Name; + $t = $f->Type; + $o->type = $this->MetaType($t); + $o->max_length = $f->DefinedSize; + $o->ado_type = $t; + + //print "off=$off name=$o->name type=$o->type len=$o->max_length
"; + return $o; + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + + function _initrs() + { + $rs = $this->_queryID; + $this->_numOfRows = $rs->RecordCount; + + $f = $rs->Fields; + $this->_numOfFields = $f->Count; + } + + + // should only be used to move forward as we normally use forward-only cursors + function _seek($row) + { + $rs = $this->_queryID; + // absoluteposition doesn't work -- my maths is wrong ? + // $rs->AbsolutePosition->$row-2; + // return true; + if ($this->_currentRow > $row) return false; + @$rs->Move((integer)$row - $this->_currentRow-1); //adBookmarkFirst + return true; + } + +/* + OLEDB types + + enum DBTYPEENUM + { DBTYPE_EMPTY = 0, + DBTYPE_NULL = 1, + DBTYPE_I2 = 2, + DBTYPE_I4 = 3, + DBTYPE_R4 = 4, + DBTYPE_R8 = 5, + DBTYPE_CY = 6, + DBTYPE_DATE = 7, + DBTYPE_BSTR = 8, + DBTYPE_IDISPATCH = 9, + DBTYPE_ERROR = 10, + DBTYPE_BOOL = 11, + DBTYPE_VARIANT = 12, + DBTYPE_IUNKNOWN = 13, + DBTYPE_DECIMAL = 14, + DBTYPE_UI1 = 17, + DBTYPE_ARRAY = 0x2000, + DBTYPE_BYREF = 0x4000, + DBTYPE_I1 = 16, + DBTYPE_UI2 = 18, + DBTYPE_UI4 = 19, + DBTYPE_I8 = 20, + DBTYPE_UI8 = 21, + DBTYPE_GUID = 72, + DBTYPE_VECTOR = 0x1000, + DBTYPE_RESERVED = 0x8000, + DBTYPE_BYTES = 128, + DBTYPE_STR = 129, + DBTYPE_WSTR = 130, + DBTYPE_NUMERIC = 131, + DBTYPE_UDT = 132, + DBTYPE_DBDATE = 133, + DBTYPE_DBTIME = 134, + DBTYPE_DBTIMESTAMP = 135 + + ADO Types + + adEmpty = 0, + adTinyInt = 16, + adSmallInt = 2, + adInteger = 3, + adBigInt = 20, + adUnsignedTinyInt = 17, + adUnsignedSmallInt = 18, + adUnsignedInt = 19, + adUnsignedBigInt = 21, + adSingle = 4, + adDouble = 5, + adCurrency = 6, + adDecimal = 14, + adNumeric = 131, + adBoolean = 11, + adError = 10, + adUserDefined = 132, + adVariant = 12, + adIDispatch = 9, + adIUnknown = 13, + adGUID = 72, + adDate = 7, + adDBDate = 133, + adDBTime = 134, + adDBTimeStamp = 135, + adBSTR = 8, + adChar = 129, + adVarChar = 200, + adLongVarChar = 201, + adWChar = 130, + adVarWChar = 202, + adLongVarWChar = 203, + adBinary = 128, + adVarBinary = 204, + adLongVarBinary = 205, + adChapter = 136, + adFileTime = 64, + adDBFileTime = 137, + adPropVariant = 138, + adVarNumeric = 139 +*/ + function MetaType($t,$len=-1,$fieldobj=false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + + if (!is_numeric($t)) return $t; + + switch ($t) { + case 0: + case 12: // variant + case 8: // bstr + case 129: //char + case 130: //wc + case 200: // varc + case 202:// varWC + case 128: // bin + case 204: // varBin + case 72: // guid + if ($len <= $this->blobSize) return 'C'; + + case 201: + case 203: + return 'X'; + case 128: + case 204: + case 205: + return 'B'; + case 7: + case 133: return 'D'; + + case 134: + case 135: return 'T'; + + case 11: return 'L'; + + case 16:// adTinyInt = 16, + case 2://adSmallInt = 2, + case 3://adInteger = 3, + case 4://adBigInt = 20, + case 17://adUnsignedTinyInt = 17, + case 18://adUnsignedSmallInt = 18, + case 19://adUnsignedInt = 19, + case 20://adUnsignedBigInt = 21, + return 'I'; + default: return 'N'; + } + } + + // time stamp not supported yet + function _fetch() + { + $rs = $this->_queryID; + if (!$rs or $rs->EOF) { + $this->fields = false; + return false; + } + $this->fields = array(); + + if (!$this->_tarr) { + $tarr = array(); + $flds = array(); + for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) { + $f = $rs->Fields($i); + $flds[] = $f; + $tarr[] = $f->Type; + } + // bind types and flds only once + $this->_tarr = $tarr; + $this->_flds = $flds; + } + $t = reset($this->_tarr); + $f = reset($this->_flds); + + if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null + for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) { + //echo "

",$t,' ';var_dump($f->value); echo '

'; + switch($t) { + case 135: // timestamp + if (!strlen((string)$f->value)) $this->fields[] = false; + else { + if (!is_numeric($f->value)) # $val = variant_date_to_timestamp($f->value); + // VT_DATE stores dates as (float) fractional days since 1899/12/30 00:00:00 + $val=(float) variant_cast($f->value,VT_R8)*3600*24-2209161600; + else + $val = $f->value; + $this->fields[] = adodb_date('Y-m-d H:i:s',$val); + } + break; + case 133:// A date value (yyyymmdd) + if ($val = $f->value) { + $this->fields[] = substr($val,0,4).'-'.substr($val,4,2).'-'.substr($val,6,2); + } else + $this->fields[] = false; + break; + case 7: // adDate + if (!strlen((string)$f->value)) $this->fields[] = false; + else { + if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value); + else $val = $f->value; + + if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val); + else $this->fields[] = adodb_date('Y-m-d H:i:s',$val); + } + break; + case 1: // null + $this->fields[] = false; + break; + case 6: // currency is not supported properly; + ADOConnection::outp( ''.$f->Name.': currency type not supported by PHP'); + $this->fields[] = (float) $f->value; + break; + case 11: //BIT; + $val = ""; + if(is_bool($f->value)) { + if($f->value==true) $val = 1; + else $val = 0; + } + if(is_null($f->value)) $val = null; + + $this->fields[] = $val; + break; + default: + $this->fields[] = $f->value; + break; + } + //print " $f->value $t, "; + $f = next($this->_flds); + $t = next($this->_tarr); + } // for + if ($this->hideErrors) error_reporting($olde); + @$rs->MoveNext(); // @ needed for some versions of PHP! + + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); + } + return true; + } + + function NextRecordSet() + { + $rs = $this->_queryID; + $this->_queryID = $rs->NextRecordSet(); + //$this->_queryID = $this->_QueryId->NextRecordSet(); + if ($this->_queryID == null) return false; + + $this->_currentRow = -1; + $this->_currentPage = -1; + $this->bind = false; + $this->fields = false; + $this->_flds = false; + $this->_tarr = false; + + $this->_inited = false; + $this->Init(); + return true; + } + + function _close() { + $this->_flds = false; + @$this->_queryID->Close();// by Pete Dishman (peterd@telephonetics.co.uk) + $this->_queryID = false; + } + +} + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-ado5.inc.php b/includes/adodb/drivers/adodb-ado5.inc.php new file mode 100644 index 00000000..9c11b767 --- /dev/null +++ b/includes/adodb/drivers/adodb-ado5.inc.php @@ -0,0 +1,678 @@ +_affectedRows = new VARIANT; + } + + function ServerInfo() + { + if (!empty($this->_connectionID)) $desc = $this->_connectionID->provider; + return array('description' => $desc, 'version' => ''); + } + + function _affectedrows() + { + if (PHP_VERSION >= 5) return $this->_affectedRows; + + return $this->_affectedRows->value; + } + + // you can also pass a connection string like this: + // + // $DB->Connect('USER ID=sa;PASSWORD=pwd;SERVER=mangrove;DATABASE=ai',false,false,'SQLOLEDB'); + function _connect($argHostname, $argUsername, $argPassword,$argDBorProvider, $argProvider= '') + { + // two modes + // - if $argProvider is empty, we assume that $argDBorProvider holds provider -- this is for backward compat + // - if $argProvider is not empty, then $argDBorProvider holds db + + + if ($argProvider) { + $argDatabasename = $argDBorProvider; + } else { + $argDatabasename = ''; + if ($argDBorProvider) $argProvider = $argDBorProvider; + else $argProvider = 'MSDASQL'; + } + + + try { + $u = 'UID'; + $p = 'PWD'; + + if (!empty($this->charPage)) + $dbc = new COM('ADODB.Connection',null,$this->charPage); + else + $dbc = new COM('ADODB.Connection'); + + if (! $dbc) return false; + + /* special support if provider is mssql or access */ + if ($argProvider=='mssql') { + $u = 'User Id'; //User parameter name for OLEDB + $p = 'Password'; + $argProvider = "SQLOLEDB"; // SQL Server Provider + + // not yet + //if ($argDatabasename) $argHostname .= ";Initial Catalog=$argDatabasename"; + + //use trusted conection for SQL if username not specified + if (!$argUsername) $argHostname .= ";Trusted_Connection=Yes"; + } else if ($argProvider=='access') + $argProvider = "Microsoft.Jet.OLEDB.4.0"; // Microsoft Jet Provider + + if ($argProvider) $dbc->Provider = $argProvider; + + if ($argProvider) $argHostname = "PROVIDER=$argProvider;DRIVER={SQL Server};SERVER=$argHostname"; + + + if ($argDatabasename) $argHostname .= ";DATABASE=$argDatabasename"; + if ($argUsername) $argHostname .= ";$u=$argUsername"; + if ($argPassword)$argHostname .= ";$p=$argPassword"; + + if ($this->debug) ADOConnection::outp( "Host=".$argHostname."
\n version=$dbc->version"); + // @ added below for php 4.0.1 and earlier + @$dbc->Open((string) $argHostname); + + $this->_connectionID = $dbc; + + $dbc->CursorLocation = $this->_cursor_location; + return $dbc->State > 0; + } catch (exception $e) { + } + + return false; + } + + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argProvider='MSDASQL') + { + return $this->_connect($argHostname,$argUsername,$argPassword,$argProvider); + } + +/* + adSchemaCatalogs = 1, + adSchemaCharacterSets = 2, + adSchemaCollations = 3, + adSchemaColumns = 4, + adSchemaCheckConstraints = 5, + adSchemaConstraintColumnUsage = 6, + adSchemaConstraintTableUsage = 7, + adSchemaKeyColumnUsage = 8, + adSchemaReferentialContraints = 9, + adSchemaTableConstraints = 10, + adSchemaColumnsDomainUsage = 11, + adSchemaIndexes = 12, + adSchemaColumnPrivileges = 13, + adSchemaTablePrivileges = 14, + adSchemaUsagePrivileges = 15, + adSchemaProcedures = 16, + adSchemaSchemata = 17, + adSchemaSQLLanguages = 18, + adSchemaStatistics = 19, + adSchemaTables = 20, + adSchemaTranslations = 21, + adSchemaProviderTypes = 22, + adSchemaViews = 23, + adSchemaViewColumnUsage = 24, + adSchemaViewTableUsage = 25, + adSchemaProcedureParameters = 26, + adSchemaForeignKeys = 27, + adSchemaPrimaryKeys = 28, + adSchemaProcedureColumns = 29, + adSchemaDBInfoKeywords = 30, + adSchemaDBInfoLiterals = 31, + adSchemaCubes = 32, + adSchemaDimensions = 33, + adSchemaHierarchies = 34, + adSchemaLevels = 35, + adSchemaMeasures = 36, + adSchemaProperties = 37, + adSchemaMembers = 38 + +*/ + + function MetaTables() + { + $arr= array(); + $dbc = $this->_connectionID; + + $adors=@$dbc->OpenSchema(20);//tables + if ($adors){ + $f = $adors->Fields(2);//table/view name + $t = $adors->Fields(3);//table type + while (!$adors->EOF){ + $tt=substr($t->value,0,6); + if ($tt!='SYSTEM' && $tt !='ACCESS') + $arr[]=$f->value; + //print $f->value . ' ' . $t->value.'
'; + $adors->MoveNext(); + } + $adors->Close(); + } + + return $arr; + } + + function MetaColumns($table) + { + $table = strtoupper($table); + $arr= array(); + $dbc = $this->_connectionID; + + $adors=@$dbc->OpenSchema(4);//tables + + if ($adors){ + $t = $adors->Fields(2);//table/view name + while (!$adors->EOF){ + + + if (strtoupper($t->Value) == $table) { + + $fld = new ADOFieldObject(); + $c = $adors->Fields(3); + $fld->name = $c->Value; + $fld->type = 'CHAR'; // cannot discover type in ADO! + $fld->max_length = -1; + $arr[strtoupper($fld->name)]=$fld; + } + + $adors->MoveNext(); + } + $adors->Close(); + } + + return $arr; + } + + /* returns queryID or false */ + function _query($sql,$inputarr=false) + { + try { // In PHP5, all COM errors are exceptions, so to maintain old behaviour... + + $dbc = $this->_connectionID; + + // return rs + + $false = false; + + if ($inputarr) { + + if (!empty($this->charPage)) + $oCmd = new COM('ADODB.Command',null,$this->charPage); + else + $oCmd = new COM('ADODB.Command'); + $oCmd->ActiveConnection = $dbc; + $oCmd->CommandText = $sql; + $oCmd->CommandType = 1; + + foreach($inputarr as $val) { + // name, type, direction 1 = input, len, + $this->adoParameterType = 130; + $p = $oCmd->CreateParameter('name',$this->adoParameterType,1,strlen($val),$val); + //print $p->Type.' '.$p->value; + $oCmd->Parameters->Append($p); + } + $p = false; + $rs = $oCmd->Execute(); + $e = $dbc->Errors; + if ($dbc->Errors->Count > 0) return $false; + return $rs; + } + + $rs = @$dbc->Execute($sql,$this->_affectedRows, $this->_execute_option); + + if ($dbc->Errors->Count > 0) return $false; + if (! $rs) return $false; + + if ($rs->State == 0) { + $true = true; + return $true; // 0 = adStateClosed means no records returned + } + return $rs; + + } catch (exception $e) { + + } + return $false; + } + + + function BeginTrans() + { + if ($this->transOff) return true; + + if (isset($this->_thisTransactions)) + if (!$this->_thisTransactions) return false; + else { + $o = $this->_connectionID->Properties("Transaction DDL"); + $this->_thisTransactions = $o ? true : false; + if (!$o) return false; + } + @$this->_connectionID->BeginTrans(); + $this->transCnt += 1; + return true; + } + function CommitTrans($ok=true) + { + if (!$ok) return $this->RollbackTrans(); + if ($this->transOff) return true; + + @$this->_connectionID->CommitTrans(); + if ($this->transCnt) @$this->transCnt -= 1; + return true; + } + function RollbackTrans() { + if ($this->transOff) return true; + @$this->_connectionID->RollbackTrans(); + if ($this->transCnt) @$this->transCnt -= 1; + return true; + } + + /* Returns: the last error message from previous database operation */ + + function ErrorMsg() + { + if (!$this->_connectionID) return "No connection established"; + $errmsg = ''; + + try { + $errc = $this->_connectionID->Errors; + if (!$errc) return "No Errors object found"; + if ($errc->Count == 0) return ''; + $err = $errc->Item($errc->Count-1); + $errmsg = $err->Description; + }catch(exception $e) { + } + return $errmsg; + } + + function ErrorNo() + { + $errc = $this->_connectionID->Errors; + if ($errc->Count == 0) return 0; + $err = $errc->Item($errc->Count-1); + return $err->NativeError; + } + + // returns true or false + function _close() + { + if ($this->_connectionID) $this->_connectionID->Close(); + $this->_connectionID = false; + return true; + } + + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordSet_ado extends ADORecordSet { + + var $bind = false; + var $databaseType = "ado"; + var $dataProvider = "ado"; + var $_tarr = false; // caches the types + var $_flds; // and field objects + var $canSeek = true; + var $hideErrors = true; + + function ADORecordSet_ado($id,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + $this->fetchMode = $mode; + return $this->ADORecordSet($id,$mode); + } + + + // returns the field object + function FetchField($fieldOffset = -1) { + $off=$fieldOffset+1; // offsets begin at 1 + + $o= new ADOFieldObject(); + $rs = $this->_queryID; + $f = $rs->Fields($fieldOffset); + $o->name = $f->Name; + $t = $f->Type; + $o->type = $this->MetaType($t); + $o->max_length = $f->DefinedSize; + $o->ado_type = $t; + + + //print "off=$off name=$o->name type=$o->type len=$o->max_length
"; + return $o; + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + + function _initrs() + { + $rs = $this->_queryID; + $this->_numOfRows = $rs->RecordCount; + + $f = $rs->Fields; + $this->_numOfFields = $f->Count; + } + + + // should only be used to move forward as we normally use forward-only cursors + function _seek($row) + { + $rs = $this->_queryID; + // absoluteposition doesn't work -- my maths is wrong ? + // $rs->AbsolutePosition->$row-2; + // return true; + if ($this->_currentRow > $row) return false; + @$rs->Move((integer)$row - $this->_currentRow-1); //adBookmarkFirst + return true; + } + +/* + OLEDB types + + enum DBTYPEENUM + { DBTYPE_EMPTY = 0, + DBTYPE_NULL = 1, + DBTYPE_I2 = 2, + DBTYPE_I4 = 3, + DBTYPE_R4 = 4, + DBTYPE_R8 = 5, + DBTYPE_CY = 6, + DBTYPE_DATE = 7, + DBTYPE_BSTR = 8, + DBTYPE_IDISPATCH = 9, + DBTYPE_ERROR = 10, + DBTYPE_BOOL = 11, + DBTYPE_VARIANT = 12, + DBTYPE_IUNKNOWN = 13, + DBTYPE_DECIMAL = 14, + DBTYPE_UI1 = 17, + DBTYPE_ARRAY = 0x2000, + DBTYPE_BYREF = 0x4000, + DBTYPE_I1 = 16, + DBTYPE_UI2 = 18, + DBTYPE_UI4 = 19, + DBTYPE_I8 = 20, + DBTYPE_UI8 = 21, + DBTYPE_GUID = 72, + DBTYPE_VECTOR = 0x1000, + DBTYPE_RESERVED = 0x8000, + DBTYPE_BYTES = 128, + DBTYPE_STR = 129, + DBTYPE_WSTR = 130, + DBTYPE_NUMERIC = 131, + DBTYPE_UDT = 132, + DBTYPE_DBDATE = 133, + DBTYPE_DBTIME = 134, + DBTYPE_DBTIMESTAMP = 135 + + ADO Types + + adEmpty = 0, + adTinyInt = 16, + adSmallInt = 2, + adInteger = 3, + adBigInt = 20, + adUnsignedTinyInt = 17, + adUnsignedSmallInt = 18, + adUnsignedInt = 19, + adUnsignedBigInt = 21, + adSingle = 4, + adDouble = 5, + adCurrency = 6, + adDecimal = 14, + adNumeric = 131, + adBoolean = 11, + adError = 10, + adUserDefined = 132, + adVariant = 12, + adIDispatch = 9, + adIUnknown = 13, + adGUID = 72, + adDate = 7, + adDBDate = 133, + adDBTime = 134, + adDBTimeStamp = 135, + adBSTR = 8, + adChar = 129, + adVarChar = 200, + adLongVarChar = 201, + adWChar = 130, + adVarWChar = 202, + adLongVarWChar = 203, + adBinary = 128, + adVarBinary = 204, + adLongVarBinary = 205, + adChapter = 136, + adFileTime = 64, + adDBFileTime = 137, + adPropVariant = 138, + adVarNumeric = 139 +*/ + function MetaType($t,$len=-1,$fieldobj=false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + + if (!is_numeric($t)) return $t; + + switch ($t) { + case 0: + case 12: // variant + case 8: // bstr + case 129: //char + case 130: //wc + case 200: // varc + case 202:// varWC + case 128: // bin + case 204: // varBin + case 72: // guid + if ($len <= $this->blobSize) return 'C'; + + case 201: + case 203: + return 'X'; + case 128: + case 204: + case 205: + return 'B'; + case 7: + case 133: return 'D'; + + case 134: + case 135: return 'T'; + + case 11: return 'L'; + + case 16:// adTinyInt = 16, + case 2://adSmallInt = 2, + case 3://adInteger = 3, + case 4://adBigInt = 20, + case 17://adUnsignedTinyInt = 17, + case 18://adUnsignedSmallInt = 18, + case 19://adUnsignedInt = 19, + case 20://adUnsignedBigInt = 21, + return 'I'; + default: return 'N'; + } + } + + // time stamp not supported yet + function _fetch() + { + $rs = $this->_queryID; + if (!$rs or $rs->EOF) { + $this->fields = false; + return false; + } + $this->fields = array(); + + if (!$this->_tarr) { + $tarr = array(); + $flds = array(); + for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) { + $f = $rs->Fields($i); + $flds[] = $f; + $tarr[] = $f->Type; + } + // bind types and flds only once + $this->_tarr = $tarr; + $this->_flds = $flds; + } + $t = reset($this->_tarr); + $f = reset($this->_flds); + + if ($this->hideErrors) $olde = error_reporting(E_ERROR|E_CORE_ERROR);// sometimes $f->value be null + for ($i=0,$max = $this->_numOfFields; $i < $max; $i++) { + //echo "

",$t,' ';var_dump($f->value); echo '

'; + switch($t) { + case 135: // timestamp + if (!strlen((string)$f->value)) $this->fields[] = false; + else { + if (!is_numeric($f->value)) # $val = variant_date_to_timestamp($f->value); + // VT_DATE stores dates as (float) fractional days since 1899/12/30 00:00:00 + $val= (float) variant_cast($f->value,VT_R8)*3600*24-2209161600; + else + $val = $f->value; + $this->fields[] = adodb_date('Y-m-d H:i:s',$val); + } + break; + case 133:// A date value (yyyymmdd) + if ($val = $f->value) { + $this->fields[] = substr($val,0,4).'-'.substr($val,4,2).'-'.substr($val,6,2); + } else + $this->fields[] = false; + break; + case 7: // adDate + if (!strlen((string)$f->value)) $this->fields[] = false; + else { + if (!is_numeric($f->value)) $val = variant_date_to_timestamp($f->value); + else $val = $f->value; + + if (($val % 86400) == 0) $this->fields[] = adodb_date('Y-m-d',$val); + else $this->fields[] = adodb_date('Y-m-d H:i:s',$val); + } + break; + case 1: // null + $this->fields[] = false; + break; + case 6: // currency is not supported properly; + ADOConnection::outp( ''.$f->Name.': currency type not supported by PHP'); + $this->fields[] = (float) $f->value; + break; + case 11: //BIT; + $val = ""; + if(is_bool($f->value)) { + if($f->value==true) $val = 1; + else $val = 0; + } + if(is_null($f->value)) $val = null; + + $this->fields[] = $val; + break; + default: + $this->fields[] = $f->value; + break; + } + //print " $f->value $t, "; + $f = next($this->_flds); + $t = next($this->_tarr); + } // for + if ($this->hideErrors) error_reporting($olde); + @$rs->MoveNext(); // @ needed for some versions of PHP! + + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); + } + return true; + } + + function NextRecordSet() + { + $rs = $this->_queryID; + $this->_queryID = $rs->NextRecordSet(); + //$this->_queryID = $this->_QueryId->NextRecordSet(); + if ($this->_queryID == null) return false; + + $this->_currentRow = -1; + $this->_currentPage = -1; + $this->bind = false; + $this->fields = false; + $this->_flds = false; + $this->_tarr = false; + + $this->_inited = false; + $this->Init(); + return true; + } + + function _close() { + $this->_flds = false; + @$this->_queryID->Close();// by Pete Dishman (peterd@telephonetics.co.uk) + $this->_queryID = false; + } + +} + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-ado_access.inc.php b/includes/adodb/drivers/adodb-ado_access.inc.php new file mode 100644 index 00000000..1b4045f9 --- /dev/null +++ b/includes/adodb/drivers/adodb-ado_access.inc.php @@ -0,0 +1,55 @@ += 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php"); + else include(ADODB_DIR."/drivers/adodb-ado.inc.php"); +} + +class ADODB_ado_access extends ADODB_ado { + var $databaseType = 'ado_access'; + var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE + var $fmtDate = "#Y-m-d#"; + var $fmtTimeStamp = "#Y-m-d h:i:sA#";// note no comma + var $sysDate = "FORMAT(NOW,'yyyy-mm-dd')"; + var $sysTimeStamp = 'NOW'; + var $hasTransactions = false; + var $upperCase = 'ucase'; + + function ADODB_ado_access() + { + $this->ADODB_ado(); + } + + function BeginTrans() { return false;} + + function CommitTrans() { return false;} + + function RollbackTrans() { return false;} + +} + + +class ADORecordSet_ado_access extends ADORecordSet_ado { + + var $databaseType = "ado_access"; + + function ADORecordSet_ado_access($id,$mode=false) + { + return $this->ADORecordSet_ado($id,$mode); + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-ado_mssql.inc.php b/includes/adodb/drivers/adodb-ado_mssql.inc.php new file mode 100644 index 00000000..089bc001 --- /dev/null +++ b/includes/adodb/drivers/adodb-ado_mssql.inc.php @@ -0,0 +1,154 @@ += 5) include(ADODB_DIR."/drivers/adodb-ado5.inc.php"); + else include(ADODB_DIR."/drivers/adodb-ado.inc.php"); +} + + +class ADODB_ado_mssql extends ADODB_ado { + var $databaseType = 'ado_mssql'; + var $hasTop = 'top'; + var $hasInsertID = true; + var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; + var $sysTimeStamp = 'GetDate()'; + var $leftOuter = '*='; + var $rightOuter = '=*'; + var $ansiOuter = true; // for mssql7 or later + var $substr = "substring"; + var $length = 'len'; + var $_dropSeqSQL = "drop table %s"; + + //var $_inTransaction = 1; // always open recordsets, so no transaction problems. + + function ADODB_ado_mssql() + { + $this->ADODB_ado(); + } + + function _insertid() + { + return $this->GetOne('select SCOPE_IDENTITY()'); + } + + function _affectedrows() + { + return $this->GetOne('select @@rowcount'); + } + + function SetTransactionMode( $transaction_mode ) + { + $this->_transmode = $transaction_mode; + if (empty($transaction_mode)) { + $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); + return; + } + if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; + $this->Execute("SET TRANSACTION ".$transaction_mode); + } + + function qstr($s,$magic_quotes=false) + { + $s = ADOConnection::qstr($s, $magic_quotes); + return str_replace("\0", "\\\\000", $s); + } + + function MetaColumns($table) + { + $table = strtoupper($table); + $arr= array(); + $dbc = $this->_connectionID; + + $osoptions = array(); + $osoptions[0] = null; + $osoptions[1] = null; + $osoptions[2] = $table; + $osoptions[3] = null; + + $adors=@$dbc->OpenSchema(4, $osoptions);//tables + + if ($adors){ + while (!$adors->EOF){ + $fld = new ADOFieldObject(); + $c = $adors->Fields(3); + $fld->name = $c->Value; + $fld->type = 'CHAR'; // cannot discover type in ADO! + $fld->max_length = -1; + $arr[strtoupper($fld->name)]=$fld; + + $adors->MoveNext(); + } + $adors->Close(); + } + $false = false; + return empty($arr) ? $false : $arr; + } + + function CreateSequence($seq='adodbseq',$start=1) + { + + $this->Execute('BEGIN TRANSACTION adodbseq'); + $start -= 1; + $this->Execute("create table $seq (id float(53))"); + $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); + if (!$ok) { + $this->Execute('ROLLBACK TRANSACTION adodbseq'); + return false; + } + $this->Execute('COMMIT TRANSACTION adodbseq'); + return true; + } + + function GenID($seq='adodbseq',$start=1) + { + //$this->debug=1; + $this->Execute('BEGIN TRANSACTION adodbseq'); + $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1"); + if (!$ok) { + $this->Execute("create table $seq (id float(53))"); + $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); + if (!$ok) { + $this->Execute('ROLLBACK TRANSACTION adodbseq'); + return false; + } + $this->Execute('COMMIT TRANSACTION adodbseq'); + return $start; + } + $num = $this->GetOne("select id from $seq"); + $this->Execute('COMMIT TRANSACTION adodbseq'); + return $num; + + // in old implementation, pre 1.90, we returned GUID... + //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'"); + } + + } // end class + + class ADORecordSet_ado_mssql extends ADORecordSet_ado { + + var $databaseType = 'ado_mssql'; + + function ADORecordSet_ado_mssql($id,$mode=false) + { + return $this->ADORecordSet_ado($id,$mode); + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-borland_ibase.inc.php b/includes/adodb/drivers/adodb-borland_ibase.inc.php new file mode 100644 index 00000000..3d0c6e72 --- /dev/null +++ b/includes/adodb/drivers/adodb-borland_ibase.inc.php @@ -0,0 +1,92 @@ +ADODB_ibase(); + } + + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + $this->autoCommit = false; + $this->_transactionID = ibase_trans($this->ibasetrans, $this->_connectionID); + return $this->_transactionID; + } + + function ServerInfo() + { + $arr['dialect'] = $this->dialect; + switch($arr['dialect']) { + case '': + case '1': $s = 'Interbase 6.5, Dialect 1'; break; + case '2': $s = 'Interbase 6.5, Dialect 2'; break; + default: + case '3': $s = 'Interbase 6.5, Dialect 3'; break; + } + $arr['version'] = '6.5'; + $arr['description'] = $s; + return $arr; + } + + // Note that Interbase 6.5 uses ROWS instead - don't you love forking wars! + // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows + // SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2 + // Firebird uses + // SELECT FIRST 5 SKIP 2 col1, col2 FROM TABLE + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + { + if ($nrows > 0) { + if ($offset <= 0) $str = " ROWS $nrows "; + else { + $a = $offset+1; + $b = $offset+$nrows; + $str = " ROWS $a TO $b"; + } + } else { + // ok, skip + $a = $offset + 1; + $str = " ROWS $a TO 999999999"; // 999 million + } + $sql .= $str; + + return ($secs2cache) ? + $this->CacheExecute($secs2cache,$sql,$inputarr) + : + $this->Execute($sql,$inputarr); + } + +}; + + +class ADORecordSet_borland_ibase extends ADORecordSet_ibase { + + var $databaseType = "borland_ibase"; + + function ADORecordSet_borland_ibase($id,$mode=false) + { + $this->ADORecordSet_ibase($id,$mode); + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-csv.inc.php b/includes/adodb/drivers/adodb-csv.inc.php new file mode 100644 index 00000000..41652273 --- /dev/null +++ b/includes/adodb/drivers/adodb-csv.inc.php @@ -0,0 +1,207 @@ +_insertid; + } + + function _affectedrows() + { + return $this->_affectedrows; + } + + function MetaDatabases() + { + return false; + } + + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (strtolower(substr($argHostname,0,7)) !== 'http://') return false; + $this->_url = $argHostname; + return true; + } + + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (strtolower(substr($argHostname,0,7)) !== 'http://') return false; + $this->_url = $argHostname; + return true; + } + + function MetaColumns($table) + { + return false; + } + + + // parameters use PostgreSQL convention, not MySQL + function SelectLimit($sql,$nrows=-1,$offset=-1) + { + global $ADODB_FETCH_MODE; + + $url = $this->_url.'?sql='.urlencode($sql)."&nrows=$nrows&fetch=". + (($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE). + "&offset=$offset"; + $err = false; + $rs = csv2rs($url,$err,false); + + if ($this->debug) print "$url
$err
"; + + $at = strpos($err,'::::'); + if ($at === false) { + $this->_errorMsg = $err; + $this->_errorNo = (integer)$err; + } else { + $this->_errorMsg = substr($err,$at+4,1024); + $this->_errorNo = -9999; + } + if ($this->_errorNo) + if ($fn = $this->raiseErrorFn) { + $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,''); + } + + if (is_object($rs)) { + + $rs->databaseType='csv'; + $rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE; + $rs->connection = $this; + } + return $rs; + } + + // returns queryID or false + function _Execute($sql,$inputarr=false) + { + global $ADODB_FETCH_MODE; + + if (!$this->_bindInputArray && $inputarr) { + $sqlarr = explode('?',$sql); + $sql = ''; + $i = 0; + foreach($inputarr as $v) { + + $sql .= $sqlarr[$i]; + if (gettype($v) == 'string') + $sql .= $this->qstr($v); + else if ($v === null) + $sql .= 'NULL'; + else + $sql .= $v; + $i += 1; + + } + $sql .= $sqlarr[$i]; + if ($i+1 != sizeof($sqlarr)) + print "Input Array does not match ?: ".htmlspecialchars($sql); + $inputarr = false; + } + + $url = $this->_url.'?sql='.urlencode($sql)."&fetch=". + (($this->fetchMode !== false)?$this->fetchMode : $ADODB_FETCH_MODE); + $err = false; + + + $rs = csv2rs($url,$err,false); + if ($this->debug) print urldecode($url)."
$err
"; + $at = strpos($err,'::::'); + if ($at === false) { + $this->_errorMsg = $err; + $this->_errorNo = (integer)$err; + } else { + $this->_errorMsg = substr($err,$at+4,1024); + $this->_errorNo = -9999; + } + + if ($this->_errorNo) + if ($fn = $this->raiseErrorFn) { + $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr); + } + if (is_object($rs)) { + $rs->fetchMode = ($this->fetchMode !== false) ? $this->fetchMode : $ADODB_FETCH_MODE; + + $this->_affectedrows = $rs->affectedrows; + $this->_insertid = $rs->insertid; + $rs->databaseType='csv'; + $rs->connection = $this; + } + return $rs; + } + + /* Returns: the last error message from previous database operation */ + function ErrorMsg() + { + return $this->_errorMsg; + } + + /* Returns: the last error number from previous database operation */ + function ErrorNo() + { + return $this->_errorNo; + } + + // returns true or false + function _close() + { + return true; + } +} // class + +class ADORecordset_csv extends ADORecordset { + function ADORecordset_csv($id,$mode=false) + { + $this->ADORecordset($id,$mode); + } + + function _close() + { + return true; + } +} + +} // define + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-db2.inc.php b/includes/adodb/drivers/adodb-db2.inc.php new file mode 100644 index 00000000..7691be88 --- /dev/null +++ b/includes/adodb/drivers/adodb-db2.inc.php @@ -0,0 +1,828 @@ +_haserrorfunctions = ADODB_PHPVER >= 0x4050; + } + + // returns true or false + function _connect($argDSN, $argUsername, $argPassword, $argDatabasename) + { + global $php_errormsg; + + if (!function_exists('db2_connect')) { + ADOConnection::outp("Warning: The old ODBC based DB2 driver has been renamed 'odbc_db2'. This ADOdb driver calls PHP's native db2 extension."); + return null; + } + // This needs to be set before the connect(). + // Replaces the odbc_binmode() call that was in Execute() + ini_set('ibm_db2.binmode', $this->binmode); + + if ($argDatabasename) { + $this->_connectionID = db2_connect($argDatabasename,$argUsername,$argPassword); + } else { + $this->_connectionID = db2_connect($argDSN,$argUsername,$argPassword); + } + if (isset($php_errormsg)) $php_errormsg = ''; + + // For db2_connect(), there is an optional 4th arg. If present, it must be + // an array of valid options. So far, we don't use them. + + $this->_errorMsg = @db2_conn_errormsg(); + + if (isset($this->connectStmt)) $this->Execute($this->connectStmt); + + return $this->_connectionID != false; + } + + // returns true or false + function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) + { + global $php_errormsg; + + if (!function_exists('db2_connect')) return null; + + // This needs to be set before the connect(). + // Replaces the odbc_binmode() call that was in Execute() + ini_set('ibm_db2.binmode', $this->binmode); + + if (isset($php_errormsg)) $php_errormsg = ''; + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + + if ($argDatabasename) { + $this->_connectionID = db2_pconnect($argDatabasename,$argUsername,$argPassword); + } else { + $this->_connectionID = db2_pconnect($argDSN,$argUsername,$argPassword); + } + if (isset($php_errormsg)) $php_errormsg = ''; + + $this->_errorMsg = @db2_conn_errormsg(); + if ($this->_connectionID && $this->autoRollback) @db2_rollback($this->_connectionID); + if (isset($this->connectStmt)) $this->Execute($this->connectStmt); + + return $this->_connectionID != false; + } + + // format and return date string in database timestamp format + function DBTimeStamp($ts) + { + if (empty($ts) && $ts !== 0) return 'null'; + if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts); + return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'YYYY-MM-DD HH24:MI:SS')"; + } + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + // use right() and replace() ? + if (!$col) $col = $this->sysDate; + + /* use TO_CHAR() if $fmt is TO_CHAR() allowed fmt */ + if ($fmt== 'Y-m-d H:i:s') + return 'TO_CHAR('.$col.", 'YYYY-MM-DD HH24:MI:SS')"; + + $s = ''; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + if ($s) $s .= $this->concat_operator; + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + if ($len==1) return "year($col)"; + $s .= "char(year($col))"; + break; + case 'M': + if ($len==1) return "monthname($col)"; + $s .= "substr(monthname($col),1,3)"; + break; + case 'm': + if ($len==1) return "month($col)"; + $s .= "right(digits(month($col)),2)"; + break; + case 'D': + case 'd': + if ($len==1) return "day($col)"; + $s .= "right(digits(day($col)),2)"; + break; + case 'H': + case 'h': + if ($len==1) return "hour($col)"; + if ($col != $this->sysDate) $s .= "right(digits(hour($col)),2)"; + else $s .= "''"; + break; + case 'i': + case 'I': + if ($len==1) return "minute($col)"; + if ($col != $this->sysDate) + $s .= "right(digits(minute($col)),2)"; + else $s .= "''"; + break; + case 'S': + case 's': + if ($len==1) return "second($col)"; + if ($col != $this->sysDate) + $s .= "right(digits(second($col)),2)"; + else $s .= "''"; + break; + default: + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + $s .= $this->qstr($ch); + } + } + return $s; + } + + + function ServerInfo() + { + + if (!empty($this->host) && ADODB_PHPVER >= 0x4300) { + $dsn = strtoupper($this->host); + $first = true; + $found = false; + + if (!function_exists('db2_data_source')) return false; + + while(true) { + + $rez = @db2_data_source($this->_connectionID, + $first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT); + $first = false; + if (!is_array($rez)) break; + if (strtoupper($rez['server']) == $dsn) { + $found = true; + break; + } + } + if (!$found) return ADOConnection::ServerInfo(); + if (!isset($rez['version'])) $rez['version'] = ''; + return $rez; + } else { + return ADOConnection::ServerInfo(); + } + } + + + function CreateSequence($seqname='adodbseq',$start=1) + { + if (empty($this->_genSeqSQL)) return false; + $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$start)); + if (!$ok) return false; + return true; + } + + function DropSequence($seqname) + { + if (empty($this->_dropSeqSQL)) return false; + return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); + } + + /* + This algorithm is not very efficient, but works even if table locking + is not available. + + Will return false if unable to generate an ID after $MAXLOOPS attempts. + */ + function GenID($seq='adodbseq',$start=1) + { + // if you have to modify the parameter below, your database is overloaded, + // or you need to implement generation of id's yourself! + $num = $this->GetOne("VALUES NEXTVAL FOR $seq"); + return $num; + } + + + function ErrorMsg() + { + if ($this->_haserrorfunctions) { + if ($this->_errorMsg !== false) return $this->_errorMsg; + if (empty($this->_connectionID)) return @db2_conn_errormsg(); + return @db2_conn_errormsg($this->_connectionID); + } else return ADOConnection::ErrorMsg(); + } + + function ErrorNo() + { + + if ($this->_haserrorfunctions) { + if ($this->_errorCode !== false) { + // bug in 4.0.6, error number can be corrupted string (should be 6 digits) + return (strlen($this->_errorCode)<=2) ? 0 : $this->_errorCode; + } + + if (empty($this->_connectionID)) $e = @db2_conn_error(); + else $e = @db2_conn_error($this->_connectionID); + + // bug in 4.0.6, error number can be corrupted string (should be 6 digits) + // so we check and patch + if (strlen($e)<=2) return 0; + return $e; + } else return ADOConnection::ErrorNo(); + } + + + + function BeginTrans() + { + if (!$this->hasTransactions) return false; + if ($this->transOff) return true; + $this->transCnt += 1; + $this->_autocommit = false; + return db2_autocommit($this->_connectionID,false); + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + if ($this->transCnt) $this->transCnt -= 1; + $this->_autocommit = true; + $ret = db2_commit($this->_connectionID); + db2_autocommit($this->_connectionID,true); + return $ret; + } + + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $this->_autocommit = true; + $ret = db2_rollback($this->_connectionID); + db2_autocommit($this->_connectionID,true); + return $ret; + } + + function MetaPrimaryKeys($table) + { + global $ADODB_FETCH_MODE; + + if ($this->uCaseTables) $table = strtoupper($table); + $schema = ''; + $this->_findschema($table,$schema); + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $qid = @db2_primarykeys($this->_connectionID,'',$schema,$table); + + if (!$qid) { + $ADODB_FETCH_MODE = $savem; + return false; + } + $rs = new ADORecordSet_db2($qid); + $ADODB_FETCH_MODE = $savem; + + if (!$rs) return false; + + $arr = $rs->GetArray(); + $rs->Close(); + $arr2 = array(); + for ($i=0; $i < sizeof($arr); $i++) { + if ($arr[$i][3]) $arr2[] = $arr[$i][3]; + } + return $arr2; + } + + function MetaForeignKeys($table, $owner = FALSE, $upper = FALSE, $asociative = FALSE ) + { + global $ADODB_FETCH_MODE; + + if ($this->uCaseTables) $table = strtoupper($table); + $schema = ''; + $this->_findschema($table,$schema); + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $qid = @db2_foreign_keys($this->_connectionID,'',$schema,$table); + if (!$qid) { + $ADODB_FETCH_MODE = $savem; + return false; + } + $rs = new ADORecordSet_db2($qid); + + $ADODB_FETCH_MODE = $savem; + /* + $rs->fields indices + 0 PKTABLE_CAT + 1 PKTABLE_SCHEM + 2 PKTABLE_NAME + 3 PKCOLUMN_NAME + 4 FKTABLE_CAT + 5 FKTABLE_SCHEM + 6 FKTABLE_NAME + 7 FKCOLUMN_NAME + */ + if (!$rs) return false; + + $foreign_keys = array(); + while (!$rs->EOF) { + if (strtoupper(trim($rs->fields[2])) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) { + if (!is_array($foreign_keys[$rs->fields[5].'.'.$rs->fields[6]])) + $foreign_keys[$rs->fields[5].'.'.$rs->fields[6]] = array(); + $foreign_keys[$rs->fields[5].'.'.$rs->fields[6]][$rs->fields[7]] = $rs->fields[3]; + } + $rs->MoveNext(); + } + + $rs->Close(); + return $foreign_key; + } + + + function MetaTables($ttype=false,$schema=false) + { + global $ADODB_FETCH_MODE; + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $qid = db2_tables($this->_connectionID); + + $rs = new ADORecordSet_db2($qid); + + $ADODB_FETCH_MODE = $savem; + if (!$rs) { + $false = false; + return $false; + } + + $arr = $rs->GetArray(); + + $rs->Close(); + $arr2 = array(); + + if ($ttype) { + $isview = strncmp($ttype,'V',1) === 0; + } + for ($i=0; $i < sizeof($arr); $i++) { + if (!$arr[$i][2]) continue; + $type = $arr[$i][3]; + $schemaval = ($schema) ? $arr[$i][1].'.' : ''; + if ($ttype) { + if ($isview) { + if (strncmp($type,'V',1) === 0) $arr2[] = $schemaval.$arr[$i][2]; + } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $schemaval.$arr[$i][2]; + } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $schemaval.$arr[$i][2]; + } + return $arr2; + } + +/* +See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/db2/htm/db2datetime_data_type_changes.asp +/ SQL data type codes / +#define SQL_UNKNOWN_TYPE 0 +#define SQL_CHAR 1 +#define SQL_NUMERIC 2 +#define SQL_DECIMAL 3 +#define SQL_INTEGER 4 +#define SQL_SMALLINT 5 +#define SQL_FLOAT 6 +#define SQL_REAL 7 +#define SQL_DOUBLE 8 +#if (DB2VER >= 0x0300) +#define SQL_DATETIME 9 +#endif +#define SQL_VARCHAR 12 + + +/ One-parameter shortcuts for date/time data types / +#if (DB2VER >= 0x0300) +#define SQL_TYPE_DATE 91 +#define SQL_TYPE_TIME 92 +#define SQL_TYPE_TIMESTAMP 93 + +#define SQL_UNICODE (-95) +#define SQL_UNICODE_VARCHAR (-96) +#define SQL_UNICODE_LONGVARCHAR (-97) +*/ + function DB2Types($t) + { + switch ((integer)$t) { + case 1: + case 12: + case 0: + case -95: + case -96: + return 'C'; + case -97: + case -1: //text + return 'X'; + case -4: //image + return 'B'; + + case 9: + case 91: + return 'D'; + + case 10: + case 11: + case 92: + case 93: + return 'T'; + + case 4: + case 5: + case -6: + return 'I'; + + case -11: // uniqidentifier + return 'R'; + case -7: //bit + return 'L'; + + default: + return 'N'; + } + } + + function MetaColumns($table) + { + global $ADODB_FETCH_MODE; + + $false = false; + if ($this->uCaseTables) $table = strtoupper($table); + $schema = ''; + $this->_findschema($table,$schema); + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + $colname = "%"; + $qid = db2_columns($this->_connectionID, "", $schema, $table, $colname); + if (empty($qid)) return $false; + + $rs = new ADORecordSet_db2($qid); + $ADODB_FETCH_MODE = $savem; + + if (!$rs) return $false; + $rs->_fetch(); + + $retarr = array(); + + /* + $rs->fields indices + 0 TABLE_QUALIFIER + 1 TABLE_SCHEM + 2 TABLE_NAME + 3 COLUMN_NAME + 4 DATA_TYPE + 5 TYPE_NAME + 6 PRECISION + 7 LENGTH + 8 SCALE + 9 RADIX + 10 NULLABLE + 11 REMARKS + */ + while (!$rs->EOF) { + if (strtoupper(trim($rs->fields[2])) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) { + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[3]; + $fld->type = $this->DB2Types($rs->fields[4]); + + // ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp + // access uses precision to store length for char/varchar + if ($fld->type == 'C' or $fld->type == 'X') { + if ($rs->fields[4] <= -95) // UNICODE + $fld->max_length = $rs->fields[7]/2; + else + $fld->max_length = $rs->fields[7]; + } else + $fld->max_length = $rs->fields[7]; + $fld->not_null = !empty($rs->fields[10]); + $fld->scale = $rs->fields[8]; + $fld->primary_key = false; + $retarr[strtoupper($fld->name)] = $fld; + } else if (sizeof($retarr)>0) + break; + $rs->MoveNext(); + } + $rs->Close(); + if (empty($retarr)) $retarr = false; + + $qid = db2_primary_keys($this->_connectionID, "", $schema, $table); + if (empty($qid)) return $false; + + $rs = new ADORecordSet_db2($qid); + $ADODB_FETCH_MODE = $savem; + + if (!$rs) return $retarr; + $rs->_fetch(); + + /* + $rs->fields indices + 0 TABLE_CAT + 1 TABLE_SCHEM + 2 TABLE_NAME + 3 COLUMN_NAME + 4 KEY_SEQ + 5 PK_NAME + */ + while (!$rs->EOF) { + if (strtoupper(trim($rs->fields[2])) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) { + $retarr[strtoupper($rs->fields[3])]->primary_key = true; + } else if (sizeof($retarr)>0) + break; + $rs->MoveNext(); + } + $rs->Close(); + + if (empty($retarr)) $retarr = false; + return $retarr; + } + + function Prepare($sql) + { + if (! $this->_bindInputArray) return $sql; // no binding + $stmt = db2_prepare($this->_connectionID,$sql); + if (!$stmt) { + // we don't know whether db2 driver is parsing prepared stmts, so just return sql + return $sql; + } + return array($sql,$stmt,false); + } + + /* returns queryID or false */ + function _query($sql,$inputarr=false) + { + GLOBAL $php_errormsg; + if (isset($php_errormsg)) $php_errormsg = ''; + $this->_error = ''; + + if ($inputarr) { + if (is_array($sql)) { + $stmtid = $sql[1]; + } else { + $stmtid = db2_prepare($this->_connectionID,$sql); + + if ($stmtid == false) { + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + return false; + } + } + + if (! db2_execute($stmtid,$inputarr)) { + if ($this->_haserrorfunctions) { + $this->_errorMsg = db2_stmt_errormsg(); + $this->_errorCode = db2_stmt_error(); + } + return false; + } + + } else if (is_array($sql)) { + $stmtid = $sql[1]; + if (!db2_execute($stmtid)) { + if ($this->_haserrorfunctions) { + $this->_errorMsg = db2_stmt_errormsg(); + $this->_errorCode = db2_stmt_error(); + } + return false; + } + } else + $stmtid = @db2_exec($this->_connectionID,$sql); + + $this->_lastAffectedRows = 0; + if ($stmtid) { + if (@db2_num_fields($stmtid) == 0) { + $this->_lastAffectedRows = db2_num_rows($stmtid); + $stmtid = true; + } else { + $this->_lastAffectedRows = 0; + } + + if ($this->_haserrorfunctions) { + $this->_errorMsg = ''; + $this->_errorCode = 0; + } else + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + } else { + if ($this->_haserrorfunctions) { + $this->_errorMsg = db2_stmt_errormsg(); + $this->_errorCode = db2_stmt_error(); + } else + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + + } + return $stmtid; + } + + /* + Insert a null into the blob field of the table first. + Then use UpdateBlob to store the blob. + + Usage: + + $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); + $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); + */ + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false; + } + + // returns true or false + function _close() + { + $ret = @db2_close($this->_connectionID); + $this->_connectionID = false; + return $ret; + } + + function _affectedrows() + { + return $this->_lastAffectedRows; + } + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordSet_db2 extends ADORecordSet { + + var $bind = false; + var $databaseType = "db2"; + var $dataProvider = "db2"; + var $useFetchArray; + + function ADORecordSet_db2($id,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + $this->fetchMode = $mode; + + $this->_queryID = $id; + } + + + // returns the field object + function FetchField($offset = -1) + { + $o= new ADOFieldObject(); + $o->name = @db2_field_name($this->_queryID,$offset); + $o->type = @db2_field_type($this->_queryID,$offset); + $o->max_length = db2_field_width($this->_queryID,$offset); + if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name); + else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name); + return $o; + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + + function _initrs() + { + global $ADODB_COUNTRECS; + $this->_numOfRows = ($ADODB_COUNTRECS) ? @db2_num_rows($this->_queryID) : -1; + $this->_numOfFields = @db2_num_fields($this->_queryID); + // some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0 + if ($this->_numOfRows == 0) $this->_numOfRows = -1; + } + + function _seek($row) + { + return false; + } + + // speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated + function GetArrayLimit($nrows,$offset=-1) + { + if ($offset <= 0) { + $rs = $this->GetArray($nrows); + return $rs; + } + $savem = $this->fetchMode; + $this->fetchMode = ADODB_FETCH_NUM; + $this->Move($offset); + $this->fetchMode = $savem; + + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); + } + + $results = array(); + $cnt = 0; + while (!$this->EOF && $nrows != $cnt) { + $results[$cnt++] = $this->fields; + $this->MoveNext(); + } + + return $results; + } + + + function MoveNext() + { + if ($this->_numOfRows != 0 && !$this->EOF) { + $this->_currentRow++; + + $this->fields = @db2_fetch_array($this->_queryID); + if ($this->fields) { + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); + } + return true; + } + } + $this->fields = false; + $this->EOF = true; + return false; + } + + function _fetch() + { + + $this->fields = db2_fetch_array($this->_queryID); + if ($this->fields) { + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); + } + return true; + } + $this->fields = false; + return false; + } + + function _close() + { + return @db2_free_result($this->_queryID); + } + +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-fbsql.inc.php b/includes/adodb/drivers/adodb-fbsql.inc.php new file mode 100644 index 00000000..d2f11dbe --- /dev/null +++ b/includes/adodb/drivers/adodb-fbsql.inc.php @@ -0,0 +1,266 @@ +. + Set tabs to 8. +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +if (! defined("_ADODB_FBSQL_LAYER")) { + define("_ADODB_FBSQL_LAYER", 1 ); + +class ADODB_fbsql extends ADOConnection { + var $databaseType = 'fbsql'; + var $hasInsertID = true; + var $hasAffectedRows = true; + var $metaTablesSQL = "SHOW TABLES"; + var $metaColumnsSQL = "SHOW COLUMNS FROM %s"; + var $fmtTimeStamp = "'Y-m-d H:i:s'"; + var $hasLimit = false; + + function ADODB_fbsql() + { + } + + function _insertid() + { + return fbsql_insert_id($this->_connectionID); + } + + function _affectedrows() + { + return fbsql_affected_rows($this->_connectionID); + } + + function MetaDatabases() + { + $qid = fbsql_list_dbs($this->_connectionID); + $arr = array(); + $i = 0; + $max = fbsql_num_rows($qid); + while ($i < $max) { + $arr[] = fbsql_tablename($qid,$i); + $i += 1; + } + return $arr; + } + + // returns concatenated string + function Concat() + { + $s = ""; + $arr = func_get_args(); + $first = true; + + $s = implode(',',$arr); + if (sizeof($arr) > 0) return "CONCAT($s)"; + else return ''; + } + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + $this->_connectionID = fbsql_connect($argHostname,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + $this->_connectionID = fbsql_pconnect($argHostname,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + + function MetaColumns($table) + { + if ($this->metaColumnsSQL) { + + $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); + + if ($rs === false) return false; + + $retarr = array(); + while (!$rs->EOF){ + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $fld->type = $rs->fields[1]; + + // split type into type(length): + if (preg_match("/^(.+)\((\d+)\)$/", $fld->type, $query_array)) { + $fld->type = $query_array[1]; + $fld->max_length = $query_array[2]; + } else { + $fld->max_length = -1; + } + $fld->not_null = ($rs->fields[2] != 'YES'); + $fld->primary_key = ($rs->fields[3] == 'PRI'); + $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false); + $fld->binary = (strpos($fld->type,'blob') !== false); + + $retarr[strtoupper($fld->name)] = $fld; + $rs->MoveNext(); + } + $rs->Close(); + return $retarr; + } + return false; + } + + // returns true or false + function SelectDB($dbName) + { + $this->database = $dbName; + if ($this->_connectionID) { + return @fbsql_select_db($dbName,$this->_connectionID); + } + else return false; + } + + + // returns queryID or false + function _query($sql,$inputarr) + { + return fbsql_query("$sql;",$this->_connectionID); + } + + /* Returns: the last error message from previous database operation */ + function ErrorMsg() + { + $this->_errorMsg = @fbsql_error($this->_connectionID); + return $this->_errorMsg; + } + + /* Returns: the last error number from previous database operation */ + function ErrorNo() + { + return @fbsql_errno($this->_connectionID); + } + + // returns true or false + function _close() + { + return @fbsql_close($this->_connectionID); + } + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordSet_fbsql extends ADORecordSet{ + + var $databaseType = "fbsql"; + var $canSeek = true; + + function ADORecordSet_fbsql($queryID,$mode=false) + { + if (!$mode) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) { + case ADODB_FETCH_NUM: $this->fetchMode = FBSQL_NUM; break; + case ADODB_FETCH_ASSOC: $this->fetchMode = FBSQL_ASSOC; break; + case ADODB_FETCH_BOTH: + default: + $this->fetchMode = FBSQL_BOTH; break; + } + return $this->ADORecordSet($queryID); + } + + function _initrs() + { + GLOBAL $ADODB_COUNTRECS; + $this->_numOfRows = ($ADODB_COUNTRECS) ? @fbsql_num_rows($this->_queryID):-1; + $this->_numOfFields = @fbsql_num_fields($this->_queryID); + } + + + + function FetchField($fieldOffset = -1) { + if ($fieldOffset != -1) { + $o = @fbsql_fetch_field($this->_queryID, $fieldOffset); + //$o->max_length = -1; // fbsql returns the max length less spaces -- so it is unrealiable + $f = @fbsql_field_flags($this->_queryID,$fieldOffset); + $o->binary = (strpos($f,'binary')!== false); + } + else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */ + $o = @fbsql_fetch_field($this->_queryID);// fbsql returns the max length less spaces -- so it is unrealiable + //$o->max_length = -1; + } + + return $o; + } + + function _seek($row) + { + return @fbsql_data_seek($this->_queryID,$row); + } + + function _fetch($ignore_fields=false) + { + $this->fields = @fbsql_fetch_array($this->_queryID,$this->fetchMode); + return ($this->fields == true); + } + + function _close() { + return @fbsql_free_result($this->_queryID); + } + + function MetaType($t,$len=-1,$fieldobj=false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + $len = -1; // fbsql max_length is not accurate + switch (strtoupper($t)) { + case 'CHARACTER': + case 'CHARACTER VARYING': + case 'BLOB': + case 'CLOB': + case 'BIT': + case 'BIT VARYING': + if ($len <= $this->blobSize) return 'C'; + + // so we have to check whether binary... + case 'IMAGE': + case 'LONGBLOB': + case 'BLOB': + case 'MEDIUMBLOB': + return !empty($fieldobj->binary) ? 'B' : 'X'; + + case 'DATE': return 'D'; + + case 'TIME': + case 'TIME WITH TIME ZONE': + case 'TIMESTAMP': + case 'TIMESTAMP WITH TIME ZONE': return 'T'; + + case 'PRIMARY_KEY': + return 'R'; + case 'INTEGER': + case 'SMALLINT': + case 'BOOLEAN': + + if (!empty($fieldobj->primary_key)) return 'R'; + else return 'I'; + + default: return 'N'; + } + } + +} //class +} // defined +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-firebird.inc.php b/includes/adodb/drivers/adodb-firebird.inc.php new file mode 100644 index 00000000..281f0caa --- /dev/null +++ b/includes/adodb/drivers/adodb-firebird.inc.php @@ -0,0 +1,77 @@ +ADODB_ibase(); + } + + function ServerInfo() + { + $arr['dialect'] = $this->dialect; + switch($arr['dialect']) { + case '': + case '1': $s = 'Firebird Dialect 1'; break; + case '2': $s = 'Firebird Dialect 2'; break; + default: + case '3': $s = 'Firebird Dialect 3'; break; + } + $arr['version'] = ADOConnection::_findvers($s); + $arr['description'] = $s; + return $arr; + } + + // Note that Interbase 6.5 uses this ROWS instead - don't you love forking wars! + // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows + // SELECT col1, col2 FROM TABLE ORDER BY col1 ROWS 3 TO 7 -- first 5 skip 2 + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false, $secs=0) + { + $nrows = (integer) $nrows; + $offset = (integer) $offset; + $str = 'SELECT '; + if ($nrows >= 0) $str .= "FIRST $nrows "; + $str .=($offset>=0) ? "SKIP $offset " : ''; + + $sql = preg_replace('/^[ \t]*select/i',$str,$sql); + if ($secs) + $rs = $this->CacheExecute($secs,$sql,$inputarr); + else + $rs = $this->Execute($sql,$inputarr); + + return $rs; + } + + +}; + + +class ADORecordSet_firebird extends ADORecordSet_ibase { + + var $databaseType = "firebird"; + + function ADORecordSet_firebird($id,$mode=false) + { + $this->ADORecordSet_ibase($id,$mode); + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-ibase.inc.php b/includes/adodb/drivers/adodb-ibase.inc.php new file mode 100644 index 00000000..8efebc63 --- /dev/null +++ b/includes/adodb/drivers/adodb-ibase.inc.php @@ -0,0 +1,887 @@ + + changed transaction handling and added experimental blob stuff + + Docs to interbase at the website + http://www.synectics.co.za/php3/tutorial/IB_PHP3_API.html + + To use gen_id(), see + http://www.volny.cz/iprenosil/interbase/ip_ib_code.htm#_code_creategen + + $rs = $conn->Execute('select gen_id(adodb,1) from rdb$database'); + $id = $rs->fields[0]; + $conn->Execute("insert into table (id, col1,...) values ($id, $val1,...)"); +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +class ADODB_ibase extends ADOConnection { + var $databaseType = "ibase"; + var $dataProvider = "ibase"; + var $replaceQuote = "''"; // string to use to replace quotes + var $ibase_datefmt = '%Y-%m-%d'; // For hours,mins,secs change to '%Y-%m-%d %H:%M:%S'; + var $fmtDate = "'Y-m-d'"; + var $ibase_timestampfmt = "%Y-%m-%d %H:%M:%S"; + var $ibase_timefmt = "%H:%M:%S"; + var $fmtTimeStamp = "'Y-m-d, H:i:s'"; + var $concat_operator='||'; + var $_transactionID; + var $metaTablesSQL = "select rdb\$relation_name from rdb\$relations where rdb\$relation_name not like 'RDB\$%'"; + //OPN STUFF start + var $metaColumnsSQL = "select a.rdb\$field_name, a.rdb\$null_flag, a.rdb\$default_source, b.rdb\$field_length, b.rdb\$field_scale, b.rdb\$field_sub_type, b.rdb\$field_precision, b.rdb\$field_type from rdb\$relation_fields a, rdb\$fields b where a.rdb\$field_source = b.rdb\$field_name and a.rdb\$relation_name = '%s' order by a.rdb\$field_position asc"; + //OPN STUFF end + var $ibasetrans; + var $hasGenID = true; + var $_bindInputArray = true; + var $buffers = 0; + var $dialect = 1; + var $sysDate = "cast('TODAY' as timestamp)"; + var $sysTimeStamp = "CURRENT_TIMESTAMP"; //"cast('NOW' as timestamp)"; + var $ansiOuter = true; + var $hasAffectedRows = false; + var $poorAffectedRows = true; + var $blobEncodeType = 'C'; + var $role = false; + + function ADODB_ibase() + { + if (defined('IBASE_DEFAULT')) $this->ibasetrans = IBASE_DEFAULT; + } + + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$persist=false) + { + if (!function_exists('ibase_pconnect')) return null; + if ($argDatabasename) $argHostname .= ':'.$argDatabasename; + $fn = ($persist) ? 'ibase_pconnect':'ibase_connect'; + if ($this->role) + $this->_connectionID = $fn($argHostname,$argUsername,$argPassword, + $this->charSet,$this->buffers,$this->dialect,$this->role); + else + $this->_connectionID = $fn($argHostname,$argUsername,$argPassword, + $this->charSet,$this->buffers,$this->dialect); + + if ($this->dialect != 1) { // http://www.ibphoenix.com/ibp_60_del_id_ds.html + $this->replaceQuote = "''"; + } + if ($this->_connectionID === false) { + $this->_handleerror(); + return false; + } + + // PHP5 change. + if (function_exists('ibase_timefmt')) { + ibase_timefmt($this->ibase_datefmt,IBASE_DATE ); + if ($this->dialect == 1) ibase_timefmt($this->ibase_datefmt,IBASE_TIMESTAMP ); + else ibase_timefmt($this->ibase_timestampfmt,IBASE_TIMESTAMP ); + ibase_timefmt($this->ibase_timefmt,IBASE_TIME ); + + } else { + ini_set("ibase.timestampformat", $this->ibase_timestampfmt); + ini_set("ibase.dateformat", $this->ibase_datefmt); + ini_set("ibase.timeformat", $this->ibase_timefmt); + } + return true; + } + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,true); + } + + + function MetaPrimaryKeys($table,$owner_notused=false,$internalKey=false) + { + if ($internalKey) return array('RDB$DB_KEY'); + + $table = strtoupper($table); + + $sql = 'SELECT S.RDB$FIELD_NAME AFIELDNAME + FROM RDB$INDICES I JOIN RDB$INDEX_SEGMENTS S ON I.RDB$INDEX_NAME=S.RDB$INDEX_NAME + WHERE I.RDB$RELATION_NAME=\''.$table.'\' and I.RDB$INDEX_NAME like \'RDB$PRIMARY%\' + ORDER BY I.RDB$INDEX_NAME,S.RDB$FIELD_POSITION'; + + $a = $this->GetCol($sql,false,true); + if ($a && sizeof($a)>0) return $a; + return false; + } + + function ServerInfo() + { + $arr['dialect'] = $this->dialect; + switch($arr['dialect']) { + case '': + case '1': $s = 'Interbase 5.5 or earlier'; break; + case '2': $s = 'Interbase 5.6'; break; + default: + case '3': $s = 'Interbase 6.0'; break; + } + $arr['version'] = ADOConnection::_findvers($s); + $arr['description'] = $s; + return $arr; + } + + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + $this->autoCommit = false; + $this->_transactionID = $this->_connectionID;//ibase_trans($this->ibasetrans, $this->_connectionID); + return $this->_transactionID; + } + + function CommitTrans($ok=true) + { + if (!$ok) return $this->RollbackTrans(); + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $ret = false; + $this->autoCommit = true; + if ($this->_transactionID) { + //print ' commit '; + $ret = ibase_commit($this->_transactionID); + } + $this->_transactionID = false; + return $ret; + } + + // there are some compat problems with ADODB_COUNTRECS=false and $this->_logsql currently. + // it appears that ibase extension cannot support multiple concurrent queryid's + function _Execute($sql,$inputarr=false) + { + global $ADODB_COUNTRECS; + + if ($this->_logsql) { + $savecrecs = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = true; // force countrecs + $ret = ADOConnection::_Execute($sql,$inputarr); + $ADODB_COUNTRECS = $savecrecs; + } else { + $ret = ADOConnection::_Execute($sql,$inputarr); + } + return $ret; + } + + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $ret = false; + $this->autoCommit = true; + if ($this->_transactionID) + $ret = ibase_rollback($this->_transactionID); + $this->_transactionID = false; + + return $ret; + } + + function MetaIndexes ($table, $primary = FALSE, $owner=false) + { + // save old fetch mode + global $ADODB_FETCH_MODE; + $false = false; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + $table = strtoupper($table); + $sql = "SELECT * FROM RDB\$INDICES WHERE RDB\$RELATION_NAME = '".$table."'"; + if (!$primary) { + $sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$%'"; + } else { + $sql .= " AND RDB\$INDEX_NAME NOT LIKE 'RDB\$FOREIGN%'"; + } + // get index details + $rs = $this->Execute($sql); + if (!is_object($rs)) { + // restore fetchmode + if (isset($savem)) { + $this->SetFetchMode($savem); + } + $ADODB_FETCH_MODE = $save; + return $false; + } + + $indexes = array(); + while ($row = $rs->FetchRow()) { + $index = $row[0]; + if (!isset($indexes[$index])) { + if (is_null($row[3])) {$row[3] = 0;} + $indexes[$index] = array( + 'unique' => ($row[3] == 1), + 'columns' => array() + ); + } + $sql = "SELECT * FROM RDB\$INDEX_SEGMENTS WHERE RDB\$INDEX_NAME = '".$index."' ORDER BY RDB\$FIELD_POSITION ASC"; + $rs1 = $this->Execute($sql); + while ($row1 = $rs1->FetchRow()) { + $indexes[$index]['columns'][$row1[2]] = $row1[1]; + } + } + // restore fetchmode + if (isset($savem)) { + $this->SetFetchMode($savem); + } + $ADODB_FETCH_MODE = $save; + + return $indexes; + } + + + // See http://community.borland.com/article/0,1410,25844,00.html + function RowLock($tables,$where,$col) + { + if ($this->autoCommit) $this->BeginTrans(); + $this->Execute("UPDATE $table SET $col=$col WHERE $where "); // is this correct - jlim? + return 1; + } + + + function CreateSequence($seqname,$startID=1) + { + $ok = $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" )); + if (!$ok) return false; + return $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';'); + } + + function DropSequence($seqname) + { + $seqname = strtoupper($seqname); + $this->Execute("delete from RDB\$GENERATORS where RDB\$GENERATOR_NAME='$seqname'"); + } + + function GenID($seqname='adodbseq',$startID=1) + { + $getnext = ("SELECT Gen_ID($seqname,1) FROM RDB\$DATABASE"); + $rs = @$this->Execute($getnext); + if (!$rs) { + $this->Execute(("INSERT INTO RDB\$GENERATORS (RDB\$GENERATOR_NAME) VALUES (UPPER('$seqname'))" )); + $this->Execute("SET GENERATOR $seqname TO ".($startID-1).';'); + $rs = $this->Execute($getnext); + } + if ($rs && !$rs->EOF) $this->genID = (integer) reset($rs->fields); + else $this->genID = 0; // false + + if ($rs) $rs->Close(); + + return $this->genID; + } + + function SelectDB($dbName) + { + return false; + } + + function _handleerror() + { + $this->_errorMsg = ibase_errmsg(); + } + + function ErrorNo() + { + if (preg_match('/error code = ([\-0-9]*)/i', $this->_errorMsg,$arr)) return (integer) $arr[1]; + else return 0; + } + + function ErrorMsg() + { + return $this->_errorMsg; + } + + function Prepare($sql) + { + $stmt = ibase_prepare($this->_connectionID,$sql); + if (!$stmt) return false; + return array($sql,$stmt); + } + + // returns query ID if successful, otherwise false + // there have been reports of problems with nested queries - the code is probably not re-entrant? + function _query($sql,$iarr=false) + { + + if (!$this->autoCommit && $this->_transactionID) { + $conn = $this->_transactionID; + $docommit = false; + } else { + $conn = $this->_connectionID; + $docommit = true; + } + if (is_array($sql)) { + $fn = 'ibase_execute'; + $sql = $sql[1]; + if (is_array($iarr)) { + if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4 + if ( !isset($iarr[0]) ) $iarr[0] = ''; // PHP5 compat hack + $fnarr = array_merge( array($sql) , $iarr); + $ret = call_user_func_array($fn,$fnarr); + } else { + switch(sizeof($iarr)) { + case 1: $ret = $fn($sql,$iarr[0]); break; + case 2: $ret = $fn($sql,$iarr[0],$iarr[1]); break; + case 3: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2]); break; + case 4: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break; + case 5: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break; + case 6: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break; + case 7: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break; + default: ADOConnection::outp( "Too many parameters to ibase query $sql"); + case 8: $ret = $fn($sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break; + } + } + } else $ret = $fn($sql); + } else { + $fn = 'ibase_query'; + + if (is_array($iarr)) { + if (ADODB_PHPVER >= 0x4050) { // actually 4.0.4 + if (sizeof($iarr) == 0) $iarr[0] = ''; // PHP5 compat hack + $fnarr = array_merge( array($conn,$sql) , $iarr); + $ret = call_user_func_array($fn,$fnarr); + } else { + switch(sizeof($iarr)) { + case 1: $ret = $fn($conn,$sql,$iarr[0]); break; + case 2: $ret = $fn($conn,$sql,$iarr[0],$iarr[1]); break; + case 3: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2]); break; + case 4: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3]); break; + case 5: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4]); break; + case 6: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5]); break; + case 7: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6]); break; + default: ADOConnection::outp( "Too many parameters to ibase query $sql"); + case 8: $ret = $fn($conn,$sql,$iarr[0],$iarr[1],$iarr[2],$iarr[3],$iarr[4],$iarr[5],$iarr[6],$iarr[7]); break; + } + } + } else $ret = $fn($conn,$sql); + } + if ($docommit && $ret === true) ibase_commit($this->_connectionID); + + $this->_handleerror(); + return $ret; + } + + // returns true or false + function _close() + { + if (!$this->autoCommit) @ibase_rollback($this->_connectionID); + return @ibase_close($this->_connectionID); + } + + //OPN STUFF start + function _ConvertFieldType(&$fld, $ftype, $flen, $fscale, $fsubtype, $fprecision, $dialect3) + { + $fscale = abs($fscale); + $fld->max_length = $flen; + $fld->scale = null; + switch($ftype){ + case 7: + case 8: + if ($dialect3) { + switch($fsubtype){ + case 0: + $fld->type = ($ftype == 7 ? 'smallint' : 'integer'); + break; + case 1: + $fld->type = 'numeric'; + $fld->max_length = $fprecision; + $fld->scale = $fscale; + break; + case 2: + $fld->type = 'decimal'; + $fld->max_length = $fprecision; + $fld->scale = $fscale; + break; + } // switch + } else { + if ($fscale !=0) { + $fld->type = 'decimal'; + $fld->scale = $fscale; + $fld->max_length = ($ftype == 7 ? 4 : 9); + } else { + $fld->type = ($ftype == 7 ? 'smallint' : 'integer'); + } + } + break; + case 16: + if ($dialect3) { + switch($fsubtype){ + case 0: + $fld->type = 'decimal'; + $fld->max_length = 18; + $fld->scale = 0; + break; + case 1: + $fld->type = 'numeric'; + $fld->max_length = $fprecision; + $fld->scale = $fscale; + break; + case 2: + $fld->type = 'decimal'; + $fld->max_length = $fprecision; + $fld->scale = $fscale; + break; + } // switch + } + break; + case 10: + $fld->type = 'float'; + break; + case 14: + $fld->type = 'char'; + break; + case 27: + if ($fscale !=0) { + $fld->type = 'decimal'; + $fld->max_length = 15; + $fld->scale = 5; + } else { + $fld->type = 'double'; + } + break; + case 35: + if ($dialect3) { + $fld->type = 'timestamp'; + } else { + $fld->type = 'date'; + } + break; + case 12: + $fld->type = 'date'; + break; + case 13: + $fld->type = 'time'; + break; + case 37: + $fld->type = 'varchar'; + break; + case 40: + $fld->type = 'cstring'; + break; + case 261: + $fld->type = 'blob'; + $fld->max_length = -1; + break; + } // switch + } + //OPN STUFF end + // returns array of ADOFieldObjects for current table + function MetaColumns($table) + { + global $ADODB_FETCH_MODE; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); + + $ADODB_FETCH_MODE = $save; + $false = false; + if ($rs === false) { + return $false; + } + + $retarr = array(); + //OPN STUFF start + $dialect3 = ($this->dialect==3 ? true : false); + //OPN STUFF end + while (!$rs->EOF) { //print_r($rs->fields); + $fld = new ADOFieldObject(); + $fld->name = trim($rs->fields[0]); + //OPN STUFF start + $this->_ConvertFieldType($fld, $rs->fields[7], $rs->fields[3], $rs->fields[4], $rs->fields[5], $rs->fields[6], $dialect3); + if (isset($rs->fields[1]) && $rs->fields[1]) { + $fld->not_null = true; + } + if (isset($rs->fields[2])) { + + $fld->has_default = true; + $d = substr($rs->fields[2],strlen('default ')); + switch ($fld->type) + { + case 'smallint': + case 'integer': $fld->default_value = (int) $d; break; + case 'char': + case 'blob': + case 'text': + case 'varchar': $fld->default_value = (string) substr($d,1,strlen($d)-2); break; + case 'double': + case 'float': $fld->default_value = (float) $d; break; + default: $fld->default_value = $d; break; + } + // case 35:$tt = 'TIMESTAMP'; break; + } + if ((isset($rs->fields[5])) && ($fld->type == 'blob')) { + $fld->sub_type = $rs->fields[5]; + } else { + $fld->sub_type = null; + } + //OPN STUFF end + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + else $retarr[strtoupper($fld->name)] = $fld; + + $rs->MoveNext(); + } + $rs->Close(); + if ( empty($retarr)) return $false; + else return $retarr; + } + + function BlobEncode( $blob ) + { + $blobid = ibase_blob_create( $this->_connectionID); + ibase_blob_add( $blobid, $blob ); + return ibase_blob_close( $blobid ); + } + + // since we auto-decode all blob's since 2.42, + // BlobDecode should not do any transforms + function BlobDecode($blob) + { + return $blob; + } + + + + + // old blobdecode function + // still used to auto-decode all blob's + function _BlobDecode_old( $blob ) + { + $blobid = ibase_blob_open($this->_connectionID, $blob ); + $realblob = ibase_blob_get( $blobid,$this->maxblobsize); // 2nd param is max size of blob -- Kevin Boillet + while($string = ibase_blob_get($blobid, 8192)){ + $realblob .= $string; + } + ibase_blob_close( $blobid ); + + return( $realblob ); + } + + function _BlobDecode( $blob ) + { + if (ADODB_PHPVER >= 0x5000) { + $blob_data = ibase_blob_info($this->_connectionID, $blob ); + $blobid = ibase_blob_open($this->_connectionID, $blob ); + } else { + + $blob_data = ibase_blob_info( $blob ); + $blobid = ibase_blob_open( $blob ); + } + + if( $blob_data[0] > $this->maxblobsize ) { + + $realblob = ibase_blob_get($blobid, $this->maxblobsize); + + while($string = ibase_blob_get($blobid, 8192)){ + $realblob .= $string; + } + } else { + $realblob = ibase_blob_get($blobid, $blob_data[0]); + } + + ibase_blob_close( $blobid ); + return( $realblob ); + } + + function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') + { + $fd = fopen($path,'rb'); + if ($fd === false) return false; + $blob_id = ibase_blob_create($this->_connectionID); + + /* fill with data */ + + while ($val = fread($fd,32768)){ + ibase_blob_add($blob_id, $val); + } + + /* close and get $blob_id_str for inserting into table */ + $blob_id_str = ibase_blob_close($blob_id); + + fclose($fd); + return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; + } + + /* + Insert a null into the blob field of the table first. + Then use UpdateBlob to store the blob. + + Usage: + + $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); + $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); + */ + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + $blob_id = ibase_blob_create($this->_connectionID); + + // ibase_blob_add($blob_id, $val); + + // replacement that solves the problem by which only the first modulus 64K / + // of $val are stored at the blob field //////////////////////////////////// + // Thx Abel Berenstein aberenstein#afip.gov.ar + $len = strlen($val); + $chunk_size = 32768; + $tail_size = $len % $chunk_size; + $n_chunks = ($len - $tail_size) / $chunk_size; + + for ($n = 0; $n < $n_chunks; $n++) { + $start = $n * $chunk_size; + $data = substr($val, $start, $chunk_size); + ibase_blob_add($blob_id, $data); + } + + if ($tail_size) { + $start = $n_chunks * $chunk_size; + $data = substr($val, $start, $tail_size); + ibase_blob_add($blob_id, $data); + } + // end replacement ///////////////////////////////////////////////////////// + + $blob_id_str = ibase_blob_close($blob_id); + + return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; + + } + + + function OldUpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + $blob_id = ibase_blob_create($this->_connectionID); + ibase_blob_add($blob_id, $val); + $blob_id_str = ibase_blob_close($blob_id); + return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blob_id_str)) != false; + } + + // Format date column in sql string given an input format that understands Y M D + // Only since Interbase 6.0 - uses EXTRACT + // problem - does not zero-fill the day and month yet + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysDate; + $s = ''; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + if ($s) $s .= '||'; + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + $s .= "extract(year from $col)"; + break; + case 'M': + case 'm': + $s .= "extract(month from $col)"; + break; + case 'Q': + case 'q': + $s .= "cast(((extract(month from $col)+2) / 3) as integer)"; + break; + case 'D': + case 'd': + $s .= "(extract(day from $col))"; + break; + case 'H': + case 'h': + $s .= "(extract(hour from $col))"; + break; + case 'I': + case 'i': + $s .= "(extract(minute from $col))"; + break; + case 'S': + case 's': + $s .= "CAST((extract(second from $col)) AS INTEGER)"; + break; + + default: + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + $s .= $this->qstr($ch); + break; + } + } + return $s; + } +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_ibase extends ADORecordSet +{ + + var $databaseType = "ibase"; + var $bind=false; + var $_cacheType; + + function ADORecordset_ibase($id,$mode=false) + { + global $ADODB_FETCH_MODE; + + $this->fetchMode = ($mode === false) ? $ADODB_FETCH_MODE : $mode; + $this->ADORecordSet($id); + } + + /* Returns: an object containing field information. + Get column information in the Recordset object. fetchField() can be used in order to obtain information about + fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by + fetchField() is retrieved. */ + + function FetchField($fieldOffset = -1) + { + $fld = new ADOFieldObject; + $ibf = ibase_field_info($this->_queryID,$fieldOffset); + switch (ADODB_ASSOC_CASE) { + case 2: // the default + $fld->name = ($ibf['alias']); + if (empty($fld->name)) $fld->name = ($ibf['name']); + break; + case 0: + $fld->name = strtoupper($ibf['alias']); + if (empty($fld->name)) $fld->name = strtoupper($ibf['name']); + break; + case 1: + $fld->name = strtolower($ibf['alias']); + if (empty($fld->name)) $fld->name = strtolower($ibf['name']); + break; + } + + $fld->type = $ibf['type']; + $fld->max_length = $ibf['length']; + + /* This needs to be populated from the metadata */ + $fld->not_null = false; + $fld->has_default = false; + $fld->default_value = 'null'; + return $fld; + } + + function _initrs() + { + $this->_numOfRows = -1; + $this->_numOfFields = @ibase_num_fields($this->_queryID); + + // cache types for blob decode check + for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { + $f1 = $this->FetchField($i); + $this->_cacheType[] = $f1->type; + } + } + + function _seek($row) + { + return false; + } + + function _fetch() + { + $f = @ibase_fetch_row($this->_queryID); + if ($f === false) { + $this->fields = false; + return false; + } + // OPN stuff start - optimized + // fix missing nulls and decode blobs automatically + + global $ADODB_ANSI_PADDING_OFF; + //$ADODB_ANSI_PADDING_OFF=1; + $rtrim = !empty($ADODB_ANSI_PADDING_OFF); + + for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { + if ($this->_cacheType[$i]=="BLOB") { + if (isset($f[$i])) { + $f[$i] = $this->connection->_BlobDecode($f[$i]); + } else { + $f[$i] = null; + } + } else { + if (!isset($f[$i])) { + $f[$i] = null; + } else if ($rtrim && is_string($f[$i])) { + $f[$i] = rtrim($f[$i]); + } + } + } + // OPN stuff end + + $this->fields = $f; + if ($this->fetchMode == ADODB_FETCH_ASSOC) { + $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); + } else if ($this->fetchMode == ADODB_FETCH_BOTH) { + $this->fields = array_merge($this->fields,$this->GetRowAssoc(ADODB_ASSOC_CASE)); + } + return true; + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + + } + + + function _close() + { + return @ibase_free_result($this->_queryID); + } + + function MetaType($t,$len=-1,$fieldobj=false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + switch (strtoupper($t)) { + case 'CHAR': + return 'C'; + + case 'TEXT': + case 'VARCHAR': + case 'VARYING': + if ($len <= $this->blobSize) return 'C'; + return 'X'; + case 'BLOB': + return 'B'; + + case 'TIMESTAMP': + case 'DATE': return 'D'; + case 'TIME': return 'T'; + //case 'T': return 'T'; + + //case 'L': return 'L'; + case 'INT': + case 'SHORT': + case 'INTEGER': return 'I'; + default: return 'N'; + } + } + +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-informix.inc.php b/includes/adodb/drivers/adodb-informix.inc.php new file mode 100644 index 00000000..69c9cd1e --- /dev/null +++ b/includes/adodb/drivers/adodb-informix.inc.php @@ -0,0 +1,40 @@ +ADORecordset_informix72($id,$mode); + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-informix72.inc.php b/includes/adodb/drivers/adodb-informix72.inc.php new file mode 100644 index 00000000..78869514 --- /dev/null +++ b/includes/adodb/drivers/adodb-informix72.inc.php @@ -0,0 +1,475 @@ + + +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +if (!defined('IFX_SCROLL')) define('IFX_SCROLL',1); + +class ADODB_informix72 extends ADOConnection { + var $databaseType = "informix72"; + var $dataProvider = "informix"; + var $replaceQuote = "''"; // string to use to replace quotes + var $fmtDate = "'Y-m-d'"; + var $fmtTimeStamp = "'Y-m-d H:i:s'"; + var $hasInsertID = true; + var $hasAffectedRows = true; + var $substr = 'substr'; + var $metaTablesSQL="select tabname,tabtype from systables where tabtype in ('T','V') and owner!='informix'"; //Don't get informix tables and pseudo-tables + + + var $metaColumnsSQL = + "select c.colname, c.coltype, c.collength, d.default,c.colno + from syscolumns c, systables t,outer sysdefaults d + where c.tabid=t.tabid and d.tabid=t.tabid and d.colno=c.colno + and tabname='%s' order by c.colno"; + + var $metaPrimaryKeySQL = + "select part1,part2,part3,part4,part5,part6,part7,part8 from + systables t,sysconstraints s,sysindexes i where t.tabname='%s' + and s.tabid=t.tabid and s.constrtype='P' + and i.idxname=s.idxname"; + + var $concat_operator = '||'; + + var $lastQuery = false; + var $has_insertid = true; + + var $_autocommit = true; + var $_bindInputArray = true; // set to true if ADOConnection.Execute() permits binding of array parameters. + var $sysDate = 'TODAY'; + var $sysTimeStamp = 'CURRENT'; + var $cursorType = IFX_SCROLL; // IFX_SCROLL or IFX_HOLD or 0 + + function ADODB_informix72() + { + // alternatively, use older method: + //putenv("DBDATE=Y4MD-"); + + // force ISO date format + putenv('GL_DATE=%Y-%m-%d'); + + if (function_exists('ifx_byteasvarchar')) { + ifx_byteasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content. + ifx_textasvarchar(1); // Mode "0" will return a blob id, and mode "1" will return a varchar with text content. + ifx_blobinfile_mode(0); // Mode "0" means save Byte-Blobs in memory, and mode "1" means save Byte-Blobs in a file. + } + } + + function ServerInfo() + { + if (isset($this->version)) return $this->version; + + $arr['description'] = $this->GetOne("select DBINFO('version','full') from systables where tabid = 1"); + $arr['version'] = $this->GetOne("select DBINFO('version','major') || DBINFO('version','minor') from systables where tabid = 1"); + $this->version = $arr; + return $arr; + } + + + + function _insertid() + { + $sqlca =ifx_getsqlca($this->lastQuery); + return @$sqlca["sqlerrd1"]; + } + + function _affectedrows() + { + if ($this->lastQuery) { + return @ifx_affected_rows ($this->lastQuery); + } + return 0; + } + + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + $this->Execute('BEGIN'); + $this->_autocommit = false; + return true; + } + + function CommitTrans($ok=true) + { + if (!$ok) return $this->RollbackTrans(); + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $this->Execute('COMMIT'); + $this->_autocommit = true; + return true; + } + + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $this->Execute('ROLLBACK'); + $this->_autocommit = true; + return true; + } + + function RowLock($tables,$where,$flds='1 as ignore') + { + if ($this->_autocommit) $this->BeginTrans(); + return $this->GetOne("select $flds from $tables where $where for update"); + } + + /* Returns: the last error message from previous database operation + Note: This function is NOT available for Microsoft SQL Server. */ + + function ErrorMsg() + { + if (!empty($this->_logsql)) return $this->_errorMsg; + $this->_errorMsg = ifx_errormsg(); + return $this->_errorMsg; + } + + function ErrorNo() + { + preg_match("/.*SQLCODE=([^\]]*)/",ifx_error(),$parse); + if (is_array($parse) && isset($parse[1])) return (int)$parse[1]; + return 0; + } + + + function MetaColumns($table) + { + global $ADODB_FETCH_MODE; + + $false = false; + if (!empty($this->metaColumnsSQL)) { + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + if ($rs === false) return $false; + $rspkey = $this->Execute(sprintf($this->metaPrimaryKeySQL,$table)); //Added to get primary key colno items + + $retarr = array(); + while (!$rs->EOF) { //print_r($rs->fields); + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; +/* //!eos. + $rs->fields[1] is not the correct adodb type + $rs->fields[2] is not correct max_length, because can include not-null bit + + $fld->type = $rs->fields[1]; + $fld->primary_key=$rspkey->fields && array_search($rs->fields[4],$rspkey->fields); //Added to set primary key flag + $fld->max_length = $rs->fields[2];*/ + $pr=ifx_props($rs->fields[1],$rs->fields[2]); //!eos + $fld->type = $pr[0] ;//!eos + $fld->primary_key=$rspkey->fields && array_search($rs->fields[4],$rspkey->fields); + $fld->max_length = $pr[1]; //!eos + $fld->precision = $pr[2] ;//!eos + $fld->not_null = $pr[3]=="N"; //!eos + + if (trim($rs->fields[3]) != "AAAAAA 0") { + $fld->has_default = 1; + $fld->default_value = $rs->fields[3]; + } else { + $fld->has_default = 0; + } + + $retarr[strtolower($fld->name)] = $fld; + $rs->MoveNext(); + } + + $rs->Close(); + $rspkey->Close(); //!eos + return $retarr; + } + + return $false; + } + + function xMetaColumns($table) + { + return ADOConnection::MetaColumns($table,false); + } + + function MetaForeignKeys($table, $owner=false, $upper=false) //!Eos + { + $sql = " + select tr.tabname,updrule,delrule, + i.part1 o1,i2.part1 d1,i.part2 o2,i2.part2 d2,i.part3 o3,i2.part3 d3,i.part4 o4,i2.part4 d4, + i.part5 o5,i2.part5 d5,i.part6 o6,i2.part6 d6,i.part7 o7,i2.part7 d7,i.part8 o8,i2.part8 d8 + from systables t,sysconstraints s,sysindexes i, + sysreferences r,systables tr,sysconstraints s2,sysindexes i2 + where t.tabname='$table' + and s.tabid=t.tabid and s.constrtype='R' and r.constrid=s.constrid + and i.idxname=s.idxname and tr.tabid=r.ptabid + and s2.constrid=r.primary and i2.idxname=s2.idxname"; + + $rs = $this->Execute($sql); + if (!$rs || $rs->EOF) return false; + $arr = $rs->GetArray(); + $a = array(); + foreach($arr as $v) { + $coldest=$this->metaColumnNames($v["tabname"]); + $colorig=$this->metaColumnNames($table); + $colnames=array(); + for($i=1;$i<=8 && $v["o$i"] ;$i++) { + $colnames[]=$coldest[$v["d$i"]-1]."=".$colorig[$v["o$i"]-1]; + } + if($upper) + $a[strtoupper($v["tabname"])] = $colnames; + else + $a[$v["tabname"]] = $colnames; + } + return $a; + } + + function UpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB') + { + $type = ($blobtype == 'TEXT') ? 1 : 0; + $blobid = ifx_create_blob($type,0,$val); + return $this->Execute("UPDATE $table SET $column=(?) WHERE $where",array($blobid)); + } + + function BlobDecode($blobid) + { + return function_exists('ifx_byteasvarchar') ? $blobid : @ifx_get_blob($blobid); + } + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!function_exists('ifx_connect')) return null; + + $dbs = $argDatabasename . "@" . $argHostname; + if ($argHostname) putenv("INFORMIXSERVER=$argHostname"); + putenv("INFORMIXSERVER=".trim($argHostname)); + $this->_connectionID = ifx_connect($dbs,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + #if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!function_exists('ifx_connect')) return null; + + $dbs = $argDatabasename . "@" . $argHostname; + putenv("INFORMIXSERVER=".trim($argHostname)); + $this->_connectionID = ifx_pconnect($dbs,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + #if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } +/* + // ifx_do does not accept bind parameters - weird ??? + function Prepare($sql) + { + $stmt = ifx_prepare($sql); + if (!$stmt) return $sql; + else return array($sql,$stmt); + } +*/ + // returns query ID if successful, otherwise false + function _query($sql,$inputarr) + { + global $ADODB_COUNTRECS; + + // String parameters have to be converted using ifx_create_char + if ($inputarr) { + foreach($inputarr as $v) { + if (gettype($v) == 'string') { + $tab[] = ifx_create_char($v); + } + else { + $tab[] = $v; + } + } + } + + // In case of select statement, we use a scroll cursor in order + // to be able to call "move", or "movefirst" statements + if (!$ADODB_COUNTRECS && preg_match("/^\s*select/is", $sql)) { + if ($inputarr) { + $this->lastQuery = ifx_query($sql,$this->_connectionID, $this->cursorType, $tab); + } + else { + $this->lastQuery = ifx_query($sql,$this->_connectionID, $this->cursorType); + } + } + else { + if ($inputarr) { + $this->lastQuery = ifx_query($sql,$this->_connectionID, $tab); + } + else { + $this->lastQuery = ifx_query($sql,$this->_connectionID); + } + } + + // Following line have been commented because autocommit mode is + // not supported by informix SE 7.2 + + //if ($this->_autocommit) ifx_query('COMMIT',$this->_connectionID); + + return $this->lastQuery; + } + + // returns true or false + function _close() + { + $this->lastQuery = false; + return ifx_close($this->_connectionID); + } +} + + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_informix72 extends ADORecordSet { + + var $databaseType = "informix72"; + var $canSeek = true; + var $_fieldprops = false; + + function ADORecordset_informix72($id,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + $this->fetchMode = $mode; + return $this->ADORecordSet($id); + } + + + + /* Returns: an object containing field information. + Get column information in the Recordset object. fetchField() can be used in order to obtain information about + fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by + fetchField() is retrieved. */ + function FetchField($fieldOffset = -1) + { + if (empty($this->_fieldprops)) { + $fp = ifx_fieldproperties($this->_queryID); + foreach($fp as $k => $v) { + $o = new ADOFieldObject; + $o->name = $k; + $arr = split(';',$v); //"SQLTYPE;length;precision;scale;ISNULLABLE" + $o->type = $arr[0]; + $o->max_length = $arr[1]; + $this->_fieldprops[] = $o; + $o->not_null = $arr[4]=="N"; + } + } + $ret = $this->_fieldprops[$fieldOffset]; + return $ret; + } + + function _initrs() + { + $this->_numOfRows = -1; // ifx_affected_rows not reliable, only returns estimate -- ($ADODB_COUNTRECS)? ifx_affected_rows($this->_queryID):-1; + $this->_numOfFields = ifx_num_fields($this->_queryID); + } + + function _seek($row) + { + return @ifx_fetch_row($this->_queryID, (int) $row); + } + + function MoveLast() + { + $this->fields = @ifx_fetch_row($this->_queryID, "LAST"); + if ($this->fields) $this->EOF = false; + $this->_currentRow = -1; + + if ($this->fetchMode == ADODB_FETCH_NUM) { + foreach($this->fields as $v) { + $arr[] = $v; + } + $this->fields = $arr; + } + + return true; + } + + function MoveFirst() + { + $this->fields = @ifx_fetch_row($this->_queryID, "FIRST"); + if ($this->fields) $this->EOF = false; + $this->_currentRow = 0; + + if ($this->fetchMode == ADODB_FETCH_NUM) { + foreach($this->fields as $v) { + $arr[] = $v; + } + $this->fields = $arr; + } + + return true; + } + + function _fetch($ignore_fields=false) + { + + $this->fields = @ifx_fetch_row($this->_queryID); + + if (!is_array($this->fields)) return false; + + if ($this->fetchMode == ADODB_FETCH_NUM) { + foreach($this->fields as $v) { + $arr[] = $v; + } + $this->fields = $arr; + } + return true; + } + + /* close() only needs to be called if you are worried about using too much memory while your script + is running. All associated result memory for the specified result identifier will automatically be freed. */ + function _close() + { + return ifx_free_result($this->_queryID); + } + +} +/** !Eos +* Auxiliar function to Parse coltype,collength. Used by Metacolumns +* return: array ($mtype,$length,$precision,$nullable) (similar to ifx_fieldpropierties) +*/ +function ifx_props($coltype,$collength){ + $itype=fmod($coltype+1,256); + $nullable=floor(($coltype+1) /256) ?"N":"Y"; + $mtype=substr(" CIIFFNNDN TBXCC ",$itype,1); + switch ($itype){ + case 2: + $length=4; + case 6: + case 9: + case 14: + $length=floor($collength/256); + $precision=fmod($collength,256); + break; + default: + $precision=0; + $length=$collength; + } + return array($mtype,$length,$precision,$nullable); +} + + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-ldap.inc.php b/includes/adodb/drivers/adodb-ldap.inc.php new file mode 100644 index 00000000..b0237e3c --- /dev/null +++ b/includes/adodb/drivers/adodb-ldap.inc.php @@ -0,0 +1,419 @@ +port); + + if ( strstr( $host, ':' ) ) { + $conn_info = split( ':', $host ); + } + + $this->_connectionID = @ldap_connect( $conn_info[0], $conn_info[1] ); + if (!$this->_connectionID) { + $e = 'Could not connect to ' . $conn_info[0]; + $this->_errorMsg = $e; + if ($this->debug) ADOConnection::outp($e); + return false; + } + if( count( $LDAP_CONNECT_OPTIONS ) > 0 ) { + $this->_inject_bind_options( $LDAP_CONNECT_OPTIONS ); + } + + if ($username) { + $bind = @ldap_bind( $this->_connectionID, $username, $password ); + } else { + $username = 'anonymous'; + $bind = @ldap_bind( $this->_connectionID ); + } + + if (!$bind) { + $e = sprintf($this->_bind_errmsg,ldap_error($this->_connectionID)); + $this->_errorMsg = $e; + if ($this->debug) ADOConnection::outp($e); + return false; + } + $this->_errorMsg = ''; + $this->database = $ldapbase; + return $this->_connectionID; + } + +/* + Valid Domain Values for LDAP Options: + + LDAP_OPT_DEREF (integer) + LDAP_OPT_SIZELIMIT (integer) + LDAP_OPT_TIMELIMIT (integer) + LDAP_OPT_PROTOCOL_VERSION (integer) + LDAP_OPT_ERROR_NUMBER (integer) + LDAP_OPT_REFERRALS (boolean) + LDAP_OPT_RESTART (boolean) + LDAP_OPT_HOST_NAME (string) + LDAP_OPT_ERROR_STRING (string) + LDAP_OPT_MATCHED_DN (string) + LDAP_OPT_SERVER_CONTROLS (array) + LDAP_OPT_CLIENT_CONTROLS (array) + + Make sure to set this BEFORE calling Connect() + + Example: + + $LDAP_CONNECT_OPTIONS = Array( + Array ( + "OPTION_NAME"=>LDAP_OPT_DEREF, + "OPTION_VALUE"=>2 + ), + Array ( + "OPTION_NAME"=>LDAP_OPT_SIZELIMIT, + "OPTION_VALUE"=>100 + ), + Array ( + "OPTION_NAME"=>LDAP_OPT_TIMELIMIT, + "OPTION_VALUE"=>30 + ), + Array ( + "OPTION_NAME"=>LDAP_OPT_PROTOCOL_VERSION, + "OPTION_VALUE"=>3 + ), + Array ( + "OPTION_NAME"=>LDAP_OPT_ERROR_NUMBER, + "OPTION_VALUE"=>13 + ), + Array ( + "OPTION_NAME"=>LDAP_OPT_REFERRALS, + "OPTION_VALUE"=>FALSE + ), + Array ( + "OPTION_NAME"=>LDAP_OPT_RESTART, + "OPTION_VALUE"=>FALSE + ) + ); +*/ + + function _inject_bind_options( $options ) { + foreach( $options as $option ) { + ldap_set_option( $this->_connectionID, $option["OPTION_NAME"], $option["OPTION_VALUE"] ) + or die( "Unable to set server option: " . $option["OPTION_NAME"] ); + } + } + + /* returns _queryID or false */ + function _query($sql,$inputarr) + { + $rs = @ldap_search( $this->_connectionID, $this->database, $sql ); + $this->_errorMsg = ($rs) ? '' : 'Search error on '.$sql.': '.ldap_error($this->_connectionID); + return $rs; + } + + function ErrorMsg() + { + return $this->_errorMsg; + } + + function ErrorNo() + { + return @ldap_errno($this->_connectionID); + } + + /* closes the LDAP connection */ + function _close() + { + @ldap_close( $this->_connectionID ); + $this->_connectionID = false; + } + + function SelectDB($db) { + $this->database = $db; + return true; + } // SelectDB + + function ServerInfo() + { + if( !empty( $this->version ) ) return $this->version; + $version = array(); + /* + Determines how aliases are handled during search. + LDAP_DEREF_NEVER (0x00) + LDAP_DEREF_SEARCHING (0x01) + LDAP_DEREF_FINDING (0x02) + LDAP_DEREF_ALWAYS (0x03) + The LDAP_DEREF_SEARCHING value means aliases are dereferenced during the search but + not when locating the base object of the search. The LDAP_DEREF_FINDING value means + aliases are dereferenced when locating the base object but not during the search. + Default: LDAP_DEREF_NEVER + */ + ldap_get_option( $this->_connectionID, LDAP_OPT_DEREF, $version['LDAP_OPT_DEREF'] ) ; + switch ( $version['LDAP_OPT_DEREF'] ) { + case 0: + $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_NEVER'; + case 1: + $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_SEARCHING'; + case 2: + $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_FINDING'; + case 3: + $version['LDAP_OPT_DEREF'] = 'LDAP_DEREF_ALWAYS'; + } + + /* + A limit on the number of entries to return from a search. + LDAP_NO_LIMIT (0) means no limit. + Default: LDAP_NO_LIMIT + */ + ldap_get_option( $this->_connectionID, LDAP_OPT_SIZELIMIT, $version['LDAP_OPT_SIZELIMIT'] ); + if ( $version['LDAP_OPT_SIZELIMIT'] == 0 ) { + $version['LDAP_OPT_SIZELIMIT'] = 'LDAP_NO_LIMIT'; + } + + /* + A limit on the number of seconds to spend on a search. + LDAP_NO_LIMIT (0) means no limit. + Default: LDAP_NO_LIMIT + */ + ldap_get_option( $this->_connectionID, LDAP_OPT_TIMELIMIT, $version['LDAP_OPT_TIMELIMIT'] ); + if ( $version['LDAP_OPT_TIMELIMIT'] == 0 ) { + $version['LDAP_OPT_TIMELIMIT'] = 'LDAP_NO_LIMIT'; + } + + /* + Determines whether the LDAP library automatically follows referrals returned by LDAP servers or not. + LDAP_OPT_ON + LDAP_OPT_OFF + Default: ON + */ + ldap_get_option( $this->_connectionID, LDAP_OPT_REFERRALS, $version['LDAP_OPT_REFERRALS'] ); + if ( $version['LDAP_OPT_REFERRALS'] == 0 ) { + $version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_OFF'; + } else { + $version['LDAP_OPT_REFERRALS'] = 'LDAP_OPT_ON'; + + } + /* + Determines whether LDAP I/O operations are automatically restarted if they abort prematurely. + LDAP_OPT_ON + LDAP_OPT_OFF + Default: OFF + */ + ldap_get_option( $this->_connectionID, LDAP_OPT_RESTART, $version['LDAP_OPT_RESTART'] ); + if ( $version['LDAP_OPT_RESTART'] == 0 ) { + $version['LDAP_OPT_RESTART'] = 'LDAP_OPT_OFF'; + } else { + $version['LDAP_OPT_RESTART'] = 'LDAP_OPT_ON'; + + } + /* + This option indicates the version of the LDAP protocol used when communicating with the primary LDAP server. + LDAP_VERSION2 (2) + LDAP_VERSION3 (3) + Default: LDAP_VERSION2 (2) + */ + ldap_get_option( $this->_connectionID, LDAP_OPT_PROTOCOL_VERSION, $version['LDAP_OPT_PROTOCOL_VERSION'] ); + if ( $version['LDAP_OPT_PROTOCOL_VERSION'] == 2 ) { + $version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION2'; + } else { + $version['LDAP_OPT_PROTOCOL_VERSION'] = 'LDAP_VERSION3'; + + } + /* The host name (or list of hosts) for the primary LDAP server. */ + ldap_get_option( $this->_connectionID, LDAP_OPT_HOST_NAME, $version['LDAP_OPT_HOST_NAME'] ); + ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_NUMBER, $version['LDAP_OPT_ERROR_NUMBER'] ); + ldap_get_option( $this->_connectionID, LDAP_OPT_ERROR_STRING, $version['LDAP_OPT_ERROR_STRING'] ); + ldap_get_option( $this->_connectionID, LDAP_OPT_MATCHED_DN, $version['LDAP_OPT_MATCHED_DN'] ); + + return $this->version = $version; + + } +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordSet_ldap extends ADORecordSet{ + + var $databaseType = "ldap"; + var $canSeek = false; + var $_entryID; /* keeps track of the entry resource identifier */ + + function ADORecordSet_ldap($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_NUM: + $this->fetchMode = LDAP_NUM; + break; + case ADODB_FETCH_ASSOC: + $this->fetchMode = LDAP_ASSOC; + break; + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: + $this->fetchMode = LDAP_BOTH; + break; + } + + $this->ADORecordSet($queryID); + } + + function _initrs() + { + /* + This could be teaked to respect the $COUNTRECS directive from ADODB + It's currently being used in the _fetch() function and the + GetAssoc() function + */ + $this->_numOfRows = ldap_count_entries( $this->connection->_connectionID, $this->_queryID ); + + } + + /* + Return whole recordset as a multi-dimensional associative array + */ + function GetAssoc($force_array = false, $first2cols = false) + { + $records = $this->_numOfRows; + $results = array(); + for ( $i=0; $i < $records; $i++ ) { + foreach ( $this->fields as $k=>$v ) { + if ( is_array( $v ) ) { + if ( $v['count'] == 1 ) { + $results[$i][$k] = $v[0]; + } else { + array_shift( $v ); + $results[$i][$k] = $v; + } + } + } + } + + return $results; + } + + function GetRowAssoc() + { + $results = array(); + foreach ( $this->fields as $k=>$v ) { + if ( is_array( $v ) ) { + if ( $v['count'] == 1 ) { + $results[$k] = $v[0]; + } else { + array_shift( $v ); + $results[$k] = $v; + } + } + } + + return $results; + } + + function GetRowNums() + { + $results = array(); + foreach ( $this->fields as $k=>$v ) { + static $i = 0; + if (is_array( $v )) { + if ( $v['count'] == 1 ) { + $results[$i] = $v[0]; + } else { + array_shift( $v ); + $results[$i] = $v; + } + $i++; + } + } + return $results; + } + + function _fetch() + { + if ( $this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0 ) + return false; + + if ( $this->_currentRow == 0 ) { + $this->_entryID = ldap_first_entry( $this->connection->_connectionID, $this->_queryID ); + } else { + $this->_entryID = ldap_next_entry( $this->connection->_connectionID, $this->_entryID ); + } + + $this->fields = ldap_get_attributes( $this->connection->_connectionID, $this->_entryID ); + $this->_numOfFields = $this->fields['count']; + switch ( $this->fetchMode ) { + + case LDAP_ASSOC: + $this->fields = $this->GetRowAssoc(); + break; + + case LDAP_NUM: + $this->fields = array_merge($this->GetRowNums(),$this->GetRowAssoc()); + break; + + case LDAP_BOTH: + default: + $this->fields = $this->GetRowNums(); + break; + } + return ( is_array( $this->fields ) ); + } + + function _close() { + @ldap_free_result( $this->_queryID ); + $this->_queryID = false; + } + +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-mssql.inc.php b/includes/adodb/drivers/adodb-mssql.inc.php new file mode 100644 index 00000000..fd951f43 --- /dev/null +++ b/includes/adodb/drivers/adodb-mssql.inc.php @@ -0,0 +1,1054 @@ += 0x4300) { +// docs say 4.2.0, but testing shows only since 4.3.0 does it work! + ini_set('mssql.datetimeconvert',0); +} else { +global $ADODB_mssql_mths; // array, months must be upper-case + + + $ADODB_mssql_date_order = 'mdy'; + $ADODB_mssql_mths = array( + 'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6, + 'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12); +} + +//--------------------------------------------------------------------------- +// Call this to autoset $ADODB_mssql_date_order at the beginning of your code, +// just after you connect to the database. Supports mdy and dmy only. +// Not required for PHP 4.2.0 and above. +function AutoDetect_MSSQL_Date_Order($conn) +{ +global $ADODB_mssql_date_order; + $adate = $conn->GetOne('select getdate()'); + if ($adate) { + $anum = (int) $adate; + if ($anum > 0) { + if ($anum > 31) { + //ADOConnection::outp( "MSSQL: YYYY-MM-DD date format not supported currently"); + } else + $ADODB_mssql_date_order = 'dmy'; + } else + $ADODB_mssql_date_order = 'mdy'; + } +} + +class ADODB_mssql extends ADOConnection { + var $databaseType = "mssql"; + var $dataProvider = "mssql"; + var $replaceQuote = "''"; // string to use to replace quotes + var $fmtDate = "'Y-m-d'"; + var $fmtTimeStamp = "'Y-m-d H:i:s'"; + var $hasInsertID = true; + var $substr = "substring"; + var $length = 'len'; + var $hasAffectedRows = true; + var $metaDatabasesSQL = "select name from sysdatabases where name <> 'master'"; + var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))"; + var $metaColumnsSQL = # xtype==61 is datetime +"select c.name,t.name,c.length, + (case when c.xusertype=61 then 0 else c.xprec end), + (case when c.xusertype=61 then 0 else c.xscale end) + from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'"; + var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE + var $hasGenID = true; + var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; + var $sysTimeStamp = 'GetDate()'; + var $_has_mssql_init; + var $maxParameterLen = 4000; + var $arrayClass = 'ADORecordSet_array_mssql'; + var $uniqueSort = true; + var $leftOuter = '*='; + var $rightOuter = '=*'; + var $ansiOuter = true; // for mssql7 or later + var $poorAffectedRows = true; + var $identitySQL = 'select SCOPE_IDENTITY()'; // 'select SCOPE_IDENTITY'; # for mssql 2000 + var $uniqueOrderBy = true; + var $_bindInputArray = true; + + function ADODB_mssql() + { + $this->_has_mssql_init = (strnatcmp(PHP_VERSION,'4.1.0')>=0); + } + + function ServerInfo() + { + global $ADODB_FETCH_MODE; + + + if ($this->fetchMode === false) { + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + } else + $savem = $this->SetFetchMode(ADODB_FETCH_NUM); + + if (0) { + $stmt = $this->PrepareSP('sp_server_info'); + $val = 2; + $this->Parameter($stmt,$val,'attribute_id'); + $row = $this->GetRow($stmt); + } + + $row = $this->GetRow("execute sp_server_info 2"); + + + if ($this->fetchMode === false) { + $ADODB_FETCH_MODE = $savem; + } else + $this->SetFetchMode($savem); + + $arr['description'] = $row[2]; + $arr['version'] = ADOConnection::_findvers($arr['description']); + return $arr; + } + + function IfNull( $field, $ifNull ) + { + return " ISNULL($field, $ifNull) "; // if MS SQL Server + } + + function _insertid() + { + // SCOPE_IDENTITY() + // Returns the last IDENTITY value inserted into an IDENTITY column in + // the same scope. A scope is a module -- a stored procedure, trigger, + // function, or batch. Thus, two statements are in the same scope if + // they are in the same stored procedure, function, or batch. + if ($this->lastInsID !== false) { + return $this->lastInsID; // InsID from sp_executesql call + } else { + return $this->GetOne($this->identitySQL); + } + } + + function _affectedrows() + { + return $this->GetOne('select @@rowcount'); + } + + var $_dropSeqSQL = "drop table %s"; + + function CreateSequence($seq='adodbseq',$start=1) + { + + $this->Execute('BEGIN TRANSACTION adodbseq'); + $start -= 1; + $this->Execute("create table $seq (id float(53))"); + $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); + if (!$ok) { + $this->Execute('ROLLBACK TRANSACTION adodbseq'); + return false; + } + $this->Execute('COMMIT TRANSACTION adodbseq'); + return true; + } + + function GenID($seq='adodbseq',$start=1) + { + //$this->debug=1; + $this->Execute('BEGIN TRANSACTION adodbseq'); + $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1"); + if (!$ok) { + $this->Execute("create table $seq (id float(53))"); + $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); + if (!$ok) { + $this->Execute('ROLLBACK TRANSACTION adodbseq'); + return false; + } + $this->Execute('COMMIT TRANSACTION adodbseq'); + return $start; + } + $num = $this->GetOne("select id from $seq"); + $this->Execute('COMMIT TRANSACTION adodbseq'); + return $num; + + // in old implementation, pre 1.90, we returned GUID... + //return $this->GetOne("SELECT CONVERT(varchar(255), NEWID()) AS 'Char'"); + } + + + function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) + { + if ($nrows > 0 && $offset <= 0) { + $sql = preg_replace( + '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop." $nrows ",$sql); + $rs = $this->Execute($sql,$inputarr); + } else + $rs = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + + return $rs; + } + + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysTimeStamp; + $s = ''; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + if ($s) $s .= '+'; + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + $s .= "datename(yyyy,$col)"; + break; + case 'M': + $s .= "convert(char(3),$col,0)"; + break; + case 'm': + $s .= "replace(str(month($col),2),' ','0')"; + break; + case 'Q': + case 'q': + $s .= "datename(quarter,$col)"; + break; + case 'D': + case 'd': + $s .= "replace(str(day($col),2),' ','0')"; + break; + case 'h': + $s .= "substring(convert(char(14),$col,0),13,2)"; + break; + + case 'H': + $s .= "replace(str(datepart(hh,$col),2),' ','0')"; + break; + + case 'i': + $s .= "replace(str(datepart(mi,$col),2),' ','0')"; + break; + case 's': + $s .= "replace(str(datepart(ss,$col),2),' ','0')"; + break; + case 'a': + case 'A': + $s .= "substring(convert(char(19),$col,0),18,2)"; + break; + + default: + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + $s .= $this->qstr($ch); + break; + } + } + return $s; + } + + + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + $this->Execute('BEGIN TRAN'); + return true; + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + if ($this->transCnt) $this->transCnt -= 1; + $this->Execute('COMMIT TRAN'); + return true; + } + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $this->Execute('ROLLBACK TRAN'); + return true; + } + + function SetTransactionMode( $transaction_mode ) + { + $this->_transmode = $transaction_mode; + if (empty($transaction_mode)) { + $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); + return; + } + if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; + $this->Execute("SET TRANSACTION ".$transaction_mode); + } + + /* + Usage: + + $this->BeginTrans(); + $this->RowLock('table1,table2','table1.id=33 and table2.id=table1.id'); # lock row 33 for both tables + + # some operation on both tables table1 and table2 + + $this->CommitTrans(); + + See http://www.swynk.com/friends/achigrik/SQL70Locks.asp + */ + function RowLock($tables,$where,$flds='top 1 null as ignore') + { + if (!$this->transCnt) $this->BeginTrans(); + return $this->GetOne("select $flds from $tables with (ROWLOCK,HOLDLOCK) where $where"); + } + + + function MetaIndexes($table,$primary=false) + { + $table = $this->qstr($table); + + $sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno, + CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK, + CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique + FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id + INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid + INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid + WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND O.Name LIKE $table + ORDER BY O.name, I.Name, K.keyno"; + + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + + $rs = $this->Execute($sql); + if (isset($savem)) { + $this->SetFetchMode($savem); + } + $ADODB_FETCH_MODE = $save; + + if (!is_object($rs)) { + return FALSE; + } + + $indexes = array(); + while ($row = $rs->FetchRow()) { + if ($primary && !$row[5]) continue; + + $indexes[$row[0]]['unique'] = $row[6]; + $indexes[$row[0]]['columns'][] = $row[1]; + } + return $indexes; + } + + function MetaForeignKeys($table, $owner=false, $upper=false) + { + global $ADODB_FETCH_MODE; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $table = $this->qstr(strtoupper($table)); + + $sql = +"select object_name(constid) as constraint_name, + col_name(fkeyid, fkey) as column_name, + object_name(rkeyid) as referenced_table_name, + col_name(rkeyid, rkey) as referenced_column_name +from sysforeignkeys +where upper(object_name(fkeyid)) = $table +order by constraint_name, referenced_table_name, keyno"; + + $constraints = $this->GetArray($sql); + + $ADODB_FETCH_MODE = $save; + + $arr = false; + foreach($constraints as $constr) { + //print_r($constr); + $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; + } + if (!$arr) return false; + + $arr2 = false; + + foreach($arr as $k => $v) { + foreach($v as $a => $b) { + if ($upper) $a = strtoupper($a); + $arr2[$a] = $b; + } + } + return $arr2; + } + + //From: Fernando Moreira + function MetaDatabases() + { + if(@mssql_select_db("master")) { + $qry=$this->metaDatabasesSQL; + if($rs=@mssql_query($qry,$this->_connectionID)){ + $tmpAr=$ar=array(); + while($tmpAr=@mssql_fetch_row($rs)) + $ar[]=$tmpAr[0]; + @mssql_select_db($this->database); + if(sizeof($ar)) + return($ar); + else + return(false); + } else { + @mssql_select_db($this->database); + return(false); + } + } + return(false); + } + + // "Stein-Aksel Basma" + // tested with MSSQL 2000 + function MetaPrimaryKeys($table) + { + global $ADODB_FETCH_MODE; + + $schema = ''; + $this->_findschema($table,$schema); + if (!$schema) $schema = $this->database; + if ($schema) $schema = "and k.table_catalog like '$schema%'"; + + $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k, + information_schema.table_constraints tc + where tc.constraint_name = k.constraint_name and tc.constraint_type = + 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position "; + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $a = $this->GetCol($sql); + $ADODB_FETCH_MODE = $savem; + + if ($a && sizeof($a)>0) return $a; + $false = false; + return $false; + } + + + function MetaTables($ttype=false,$showSchema=false,$mask=false) + { + if ($mask) { + $save = $this->metaTablesSQL; + $mask = $this->qstr(($mask)); + $this->metaTablesSQL .= " AND name like $mask"; + } + $ret = ADOConnection::MetaTables($ttype,$showSchema); + + if ($mask) { + $this->metaTablesSQL = $save; + } + return $ret; + } + + function SelectDB($dbName) + { + $this->database = $dbName; + $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions + if ($this->_connectionID) { + return @mssql_select_db($dbName); + } + else return false; + } + + function ErrorMsg() + { + if (empty($this->_errorMsg)){ + $this->_errorMsg = mssql_get_last_message(); + } + return $this->_errorMsg; + } + + function ErrorNo() + { + if ($this->_logsql && $this->_errorCode !== false) return $this->_errorCode; + if (empty($this->_errorMsg)) { + $this->_errorMsg = mssql_get_last_message(); + } + $id = @mssql_query("select @@ERROR",$this->_connectionID); + if (!$id) return false; + $arr = mssql_fetch_array($id); + @mssql_free_result($id); + if (is_array($arr)) return $arr[0]; + else return -1; + } + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!function_exists('mssql_pconnect')) return null; + $this->_connectionID = mssql_connect($argHostname,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + + + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!function_exists('mssql_pconnect')) return null; + $this->_connectionID = mssql_pconnect($argHostname,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + + // persistent connections can forget to rollback on crash, so we do it here. + if ($this->autoRollback) { + $cnt = $this->GetOne('select @@TRANCOUNT'); + while (--$cnt >= 0) $this->Execute('ROLLBACK TRAN'); + } + if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + + function Prepare($sql) + { + $sqlarr = explode('?',$sql); + if (sizeof($sqlarr) <= 1) return $sql; + $sql2 = $sqlarr[0]; + for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) { + $sql2 .= '@P'.($i-1) . $sqlarr[$i]; + } + return array($sql,$this->qstr($sql2),$max,$sql2); + } + + function PrepareSP($sql) + { + if (!$this->_has_mssql_init) { + ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0"); + return $sql; + } + $stmt = mssql_init($sql,$this->_connectionID); + if (!$stmt) return $sql; + return array($sql,$stmt); + } + + // returns concatenated string + // MSSQL requires integers to be cast as strings + // automatically cast every datatype to VARCHAR(255) + // @author David Rogers (introspectshun) + function Concat() + { + $s = ""; + $arr = func_get_args(); + + // Split single record on commas, if possible + if (sizeof($arr) == 1) { + foreach ($arr as $arg) { + $args = explode(',', $arg); + } + $arr = $args; + } + + array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";')); + $s = implode('+',$arr); + if (sizeof($arr) > 0) return "$s"; + + return ''; + } + + /* + Usage: + $stmt = $db->PrepareSP('SP_RUNSOMETHING'); -- takes 2 params, @myid and @group + + # note that the parameter does not have @ in front! + $db->Parameter($stmt,$id,'myid'); + $db->Parameter($stmt,$group,'group',false,64); + $db->Execute($stmt); + + @param $stmt Statement returned by Prepare() or PrepareSP(). + @param $var PHP variable to bind to. Can set to null (for isNull support). + @param $name Name of stored procedure variable name to bind to. + @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. + @param [$maxLen] Holds an maximum length of the variable. + @param [$type] The data type of $var. Legal values depend on driver. + + See mssql_bind documentation at php.net. + */ + function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=4000, $type=false) + { + if (!$this->_has_mssql_init) { + ADOConnection::outp( "Parameter: mssql_bind only available since PHP 4.1.0"); + return false; + } + + $isNull = is_null($var); // php 4.0.4 and above... + + if ($type === false) + switch(gettype($var)) { + default: + case 'string': $type = SQLVARCHAR; break; + case 'double': $type = SQLFLT8; break; + case 'integer': $type = SQLINT4; break; + case 'boolean': $type = SQLINT1; break; # SQLBIT not supported in 4.1.0 + } + + if ($this->debug) { + $prefix = ($isOutput) ? 'Out' : 'In'; + $ztype = (empty($type)) ? 'false' : $type; + ADOConnection::outp( "{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);"); + } + /* + See http://phplens.com/lens/lensforum/msgs.php?id=7231 + + RETVAL is HARD CODED into php_mssql extension: + The return value (a long integer value) is treated like a special OUTPUT parameter, + called "RETVAL" (without the @). See the example at mssql_execute to + see how it works. - type: one of this new supported PHP constants. + SQLTEXT, SQLVARCHAR,SQLCHAR, SQLINT1,SQLINT2, SQLINT4, SQLBIT,SQLFLT8 + */ + if ($name !== 'RETVAL') $name = '@'.$name; + return mssql_bind($stmt[1], $name, $var, $type, $isOutput, $isNull, $maxLen); + } + + /* + Unfortunately, it appears that mssql cannot handle varbinary > 255 chars + So all your blobs must be of type "image". + + Remember to set in php.ini the following... + + ; Valid range 0 - 2147483647. Default = 4096. + mssql.textlimit = 0 ; zero to pass through + + ; Valid range 0 - 2147483647. Default = 4096. + mssql.textsize = 0 ; zero to pass through + */ + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + + if (strtoupper($blobtype) == 'CLOB') { + $sql = "UPDATE $table SET $column='" . $val . "' WHERE $where"; + return $this->Execute($sql) != false; + } + $sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where"; + return $this->Execute($sql) != false; + } + + // returns query ID if successful, otherwise false + function _query($sql,$inputarr) + { + $this->_errorMsg = false; + if (is_array($inputarr)) { + + # bind input params with sp_executesql: + # see http://www.quest-pipelines.com/newsletter-v3/0402_F.htm + # works only with sql server 7 and newer + $getIdentity = false; + if (!is_array($sql) && preg_match('/^\\s*insert/i', $sql)) { + $getIdentity = true; + $sql .= (preg_match('/;\\s*$/i', $sql) ? ' ' : '; ') . $this->identitySQL; + } + if (!is_array($sql)) $sql = $this->Prepare($sql); + $params = ''; + $decl = ''; + $i = 0; + foreach($inputarr as $v) { + if ($decl) { + $decl .= ', '; + $params .= ', '; + } + if (is_string($v)) { + $len = strlen($v); + if ($len == 0) $len = 1; + + if ($len > 4000 ) { + // NVARCHAR is max 4000 chars. Let's use NTEXT + $decl .= "@P$i NTEXT"; + } else { + $decl .= "@P$i NVARCHAR($len)"; + } + + $params .= "@P$i=N". (strncmp($v,"'",1)==0? $v : $this->qstr($v)); + } else if (is_integer($v)) { + $decl .= "@P$i INT"; + $params .= "@P$i=".$v; + } else if (is_float($v)) { + $decl .= "@P$i FLOAT"; + $params .= "@P$i=".$v; + } else if (is_bool($v)) { + $decl .= "@P$i INT"; # Used INT just in case BIT in not supported on the user's MSSQL version. It will cast appropriately. + $params .= "@P$i=".(($v)?'1':'0'); # True == 1 in MSSQL BIT fields and acceptable for storing logical true in an int field + } else { + $decl .= "@P$i CHAR"; # Used char because a type is required even when the value is to be NULL. + $params .= "@P$i=NULL"; + } + $i += 1; + } + $decl = $this->qstr($decl); + if ($this->debug) ADOConnection::outp("sp_executesql N{$sql[1]},N$decl,$params"); + $rez = mssql_query("sp_executesql N{$sql[1]},N$decl,$params", $this->_connectionID); + if ($getIdentity) { + $arr = @mssql_fetch_row($rez); + $this->lastInsID = isset($arr[0]) ? $arr[0] : false; + @mssql_data_seek($rez, 0); + } + + } else if (is_array($sql)) { + # PrepareSP() + $rez = mssql_execute($sql[1]); + $this->lastInsID = false; + + } else { + $rez = mssql_query($sql,$this->_connectionID); + $this->lastInsID = false; + } + return $rez; + } + + // returns true or false + function _close() + { + if ($this->transCnt) $this->RollbackTrans(); + $rez = @mssql_close($this->_connectionID); + $this->_connectionID = false; + return $rez; + } + + // mssql uses a default date like Dec 30 2000 12:00AM + static function UnixDate($v) + { + return ADORecordSet_array_mssql::UnixDate($v); + } + + static function UnixTimeStamp($v) + { + return ADORecordSet_array_mssql::UnixTimeStamp($v); + } +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_mssql extends ADORecordSet { + + var $databaseType = "mssql"; + var $canSeek = true; + var $hasFetchAssoc; // see http://phplens.com/lens/lensforum/msgs.php?id=6083 + // _mths works only in non-localised system + + function ADORecordset_mssql($id,$mode=false) + { + // freedts check... + $this->hasFetchAssoc = function_exists('mssql_fetch_assoc'); + + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + + } + $this->fetchMode = $mode; + return $this->ADORecordSet($id,$mode); + } + + + function _initrs() + { + GLOBAL $ADODB_COUNTRECS; + $this->_numOfRows = ($ADODB_COUNTRECS)? @mssql_num_rows($this->_queryID):-1; + $this->_numOfFields = @mssql_num_fields($this->_queryID); + } + + + //Contributed by "Sven Axelsson" + // get next resultset - requires PHP 4.0.5 or later + function NextRecordSet() + { + if (!mssql_next_result($this->_queryID)) return false; + $this->_inited = false; + $this->bind = false; + $this->_currentRow = -1; + $this->Init(); + return true; + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + if ($this->fetchMode != ADODB_FETCH_NUM) return $this->fields[$colname]; + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + /* Returns: an object containing field information. + Get column information in the Recordset object. fetchField() can be used in order to obtain information about + fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by + fetchField() is retrieved. */ + + function FetchField($fieldOffset = -1) + { + if ($fieldOffset != -1) { + $f = @mssql_fetch_field($this->_queryID, $fieldOffset); + } + else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */ + $f = @mssql_fetch_field($this->_queryID); + } + $false = false; + if (empty($f)) return $false; + return $f; + } + + function _seek($row) + { + return @mssql_data_seek($this->_queryID, $row); + } + + // speedup + function MoveNext() + { + if ($this->EOF) return false; + + $this->_currentRow++; + + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + if ($this->fetchMode & ADODB_FETCH_NUM) { + //ADODB_FETCH_BOTH mode + $this->fields = @mssql_fetch_array($this->_queryID); + } + else { + if ($this->hasFetchAssoc) {// only for PHP 4.2.0 or later + $this->fields = @mssql_fetch_assoc($this->_queryID); + } else { + $flds = @mssql_fetch_array($this->_queryID); + if (is_array($flds)) { + $fassoc = array(); + foreach($flds as $k => $v) { + if (is_numeric($k)) continue; + $fassoc[$k] = $v; + } + $this->fields = $fassoc; + } else + $this->fields = false; + } + } + + if (is_array($this->fields)) { + if (ADODB_ASSOC_CASE == 0) { + foreach($this->fields as $k=>$v) { + $this->fields[strtolower($k)] = $v; + } + } else if (ADODB_ASSOC_CASE == 1) { + foreach($this->fields as $k=>$v) { + $this->fields[strtoupper($k)] = $v; + } + } + } + } else { + $this->fields = @mssql_fetch_row($this->_queryID); + } + if ($this->fields) return true; + $this->EOF = true; + + return false; + } + + + // INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4 + // also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot! + function _fetch($ignore_fields=false) + { + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + if ($this->fetchMode & ADODB_FETCH_NUM) { + //ADODB_FETCH_BOTH mode + $this->fields = @mssql_fetch_array($this->_queryID); + } else { + if ($this->hasFetchAssoc) // only for PHP 4.2.0 or later + $this->fields = @mssql_fetch_assoc($this->_queryID); + else { + $this->fields = @mssql_fetch_array($this->_queryID); + if (@is_array($$this->fields)) { + $fassoc = array(); + foreach($$this->fields as $k => $v) { + if (is_integer($k)) continue; + $fassoc[$k] = $v; + } + $this->fields = $fassoc; + } + } + } + + if (!$this->fields) { + } else if (ADODB_ASSOC_CASE == 0) { + foreach($this->fields as $k=>$v) { + $this->fields[strtolower($k)] = $v; + } + } else if (ADODB_ASSOC_CASE == 1) { + foreach($this->fields as $k=>$v) { + $this->fields[strtoupper($k)] = $v; + } + } + } else { + $this->fields = @mssql_fetch_row($this->_queryID); + } + return $this->fields; + } + + /* close() only needs to be called if you are worried about using too much memory while your script + is running. All associated result memory for the specified result identifier will automatically be freed. */ + + function _close() + { + $rez = mssql_free_result($this->_queryID); + $this->_queryID = false; + return $rez; + } + // mssql uses a default date like Dec 30 2000 12:00AM + static function UnixDate($v) + { + return ADORecordSet_array_mssql::UnixDate($v); + } + + static function UnixTimeStamp($v) + { + return ADORecordSet_array_mssql::UnixTimeStamp($v); + } + +} + + +class ADORecordSet_array_mssql extends ADORecordSet_array { + function ADORecordSet_array_mssql($id=-1,$mode=false) + { + $this->ADORecordSet_array($id,$mode); + } + + // mssql uses a default date like Dec 30 2000 12:00AM + static function UnixDate($v) + { + + if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v); + + global $ADODB_mssql_mths,$ADODB_mssql_date_order; + + //Dec 30 2000 12:00AM + if ($ADODB_mssql_date_order == 'dmy') { + if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) { + return parent::UnixDate($v); + } + if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; + + $theday = $rr[1]; + $themth = substr(strtoupper($rr[2]),0,3); + } else { + if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr)) { + return parent::UnixDate($v); + } + if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; + + $theday = $rr[2]; + $themth = substr(strtoupper($rr[1]),0,3); + } + $themth = $ADODB_mssql_mths[$themth]; + if ($themth <= 0) return false; + // h-m-s-MM-DD-YY + return mktime(0,0,0,$themth,$theday,$rr[3]); + } + + static function UnixTimeStamp($v) + { + + if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v); + + global $ADODB_mssql_mths,$ADODB_mssql_date_order; + + //Dec 30 2000 12:00AM + if ($ADODB_mssql_date_order == 'dmy') { + if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|" + ,$v, $rr)) return parent::UnixTimeStamp($v); + if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; + + $theday = $rr[1]; + $themth = substr(strtoupper($rr[2]),0,3); + } else { + if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|" + ,$v, $rr)) return parent::UnixTimeStamp($v); + if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; + + $theday = $rr[2]; + $themth = substr(strtoupper($rr[1]),0,3); + } + + $themth = $ADODB_mssql_mths[$themth]; + if ($themth <= 0) return false; + + switch (strtoupper($rr[6])) { + case 'P': + if ($rr[4]<12) $rr[4] += 12; + break; + case 'A': + if ($rr[4]==12) $rr[4] = 0; + break; + default: + break; + } + // h-m-s-MM-DD-YY + return mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]); + } +} + +/* +Code Example 1: + +select object_name(constid) as constraint_name, + object_name(fkeyid) as table_name, + col_name(fkeyid, fkey) as column_name, + object_name(rkeyid) as referenced_table_name, + col_name(rkeyid, rkey) as referenced_column_name +from sysforeignkeys +where object_name(fkeyid) = x +order by constraint_name, table_name, referenced_table_name, keyno + +Code Example 2: +select constraint_name, + column_name, + ordinal_position +from information_schema.key_column_usage +where constraint_catalog = db_name() +and table_name = x +order by constraint_name, ordinal_position + +http://www.databasejournal.com/scripts/article.php/1440551 +*/ + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-mssql_n.inc.php b/includes/adodb/drivers/adodb-mssql_n.inc.php new file mode 100644 index 00000000..38082982 --- /dev/null +++ b/includes/adodb/drivers/adodb-mssql_n.inc.php @@ -0,0 +1,171 @@ +_appendN($sql); + return ADODB_mssql::_query($sql,$inputarr); + } + + /** + * This function will intercept all the literals used in the SQL, prepending the "N" char to them + * in order to allow mssql to store properly data sent in the correct UCS-2 encoding (by freeTDS + * and ODBTP) keeping SQL compatibility at ADOdb level (instead of hacking every project to add + * the "N" notation when working against MSSQL. + * + * Note that this hack only must be used if ALL the char-based columns in your DB are of type nchar, + * nvarchar and ntext + */ + function _appendN($sql) { + + $result = $sql; + + /// Check we have some single quote in the query. Exit ok. + if (strpos($sql, SINGLEQUOTE) === false) { + return $sql; + } + + /// Check we haven't an odd number of single quotes (this can cause problems below + /// and should be considered one wrong SQL). Exit with debug info. + if ((substr_count($sql, SINGLEQUOTE) & 1)) { + if ($this->debug) { + ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Wrong number of quotes (odd)"); + } + return $sql; + } + + /// Check we haven't any backslash + single quote combination. It should mean wrong + /// backslashes use (bad magic_quotes_sybase?). Exit with debug info. + $regexp = '/(\\\\' . SINGLEQUOTE . '[^' . SINGLEQUOTE . '])/'; + if (preg_match($regexp, $sql)) { + if ($this->debug) { + ADOConnection::outp("{$this->databaseType} internal transformation: not converted. Found bad use of backslash + single quote"); + } + return $sql; + } + + /// Remove pairs of single-quotes + $pairs = array(); + $regexp = '/(' . SINGLEQUOTE . SINGLEQUOTE . ')/'; + preg_match_all($regexp, $result, $list_of_pairs); + if ($list_of_pairs) { + foreach (array_unique($list_of_pairs[0]) as $key=>$value) { + $pairs['<@#@#@PAIR-'.$key.'@#@#@>'] = $value; + } + if (!empty($pairs)) { + $result = str_replace($pairs, array_keys($pairs), $result); + } + } + + /// Remove the rest of literals present in the query + $literals = array(); + $regexp = '/(N?' . SINGLEQUOTE . '.*?' . SINGLEQUOTE . ')/is'; + preg_match_all($regexp, $result, $list_of_literals); + if ($list_of_literals) { + foreach (array_unique($list_of_literals[0]) as $key=>$value) { + $literals['<#@#@#LITERAL-'.$key.'#@#@#>'] = $value; + } + if (!empty($literals)) { + $result = str_replace($literals, array_keys($literals), $result); + } + } + + + /// Analyse literals to prepend the N char to them if their contents aren't numeric + if (!empty($literals)) { + foreach ($literals as $key=>$value) { + if (!is_numeric(trim($value, SINGLEQUOTE))) { + /// Non numeric string, prepend our dear N + $literals[$key] = 'N' . trim($value, 'N'); //Trimming potentially existing previous "N" + } + } + } + + /// Re-apply literals to the text + if (!empty($literals)) { + $result = str_replace(array_keys($literals), $literals, $result); + } + + /// Any pairs followed by N' must be switched to N' followed by those pairs + /// (or strings beginning with single quotes will fail) + $result = preg_replace("/((<@#@#@PAIR-(\d+)@#@#@>)+)N'/", "N'$1", $result); + + /// Re-apply pairs of single-quotes to the text + if (!empty($pairs)) { + $result = str_replace(array_keys($pairs), $pairs, $result); + } + + /// Print transformation if debug = on + if ($result != $sql && $this->debug) { + ADOConnection::outp("{$this->databaseType} internal transformation:
{$sql}
to
{$result}"); + } + + return $result; + } +} + +class ADORecordset_mssql_n extends ADORecordset_mssql { + var $databaseType = "mssql_n"; + function ADORecordset_mssql_n($id,$mode=false) + { + $this->ADORecordset_mssql($id,$mode); + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-mssqlnative.inc.php b/includes/adodb/drivers/adodb-mssqlnative.inc.php new file mode 100644 index 00000000..f1f91f1d --- /dev/null +++ b/includes/adodb/drivers/adodb-mssqlnative.inc.php @@ -0,0 +1,902 @@ += 0x4300) { +// docs say 4.2.0, but testing shows only since 4.3.0 does it work! + ini_set('mssql.datetimeconvert',0); +} else { + global $ADODB_mssql_mths; // array, months must be upper-case + $ADODB_mssql_date_order = 'mdy'; + $ADODB_mssql_mths = array( + 'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6, + 'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12); +} + +//--------------------------------------------------------------------------- +// Call this to autoset $ADODB_mssql_date_order at the beginning of your code, +// just after you connect to the database. Supports mdy and dmy only. +// Not required for PHP 4.2.0 and above. +function AutoDetect_MSSQL_Date_Order($conn) +{ + global $ADODB_mssql_date_order; + $adate = $conn->GetOne('select getdate()'); + if ($adate) { + $anum = (int) $adate; + if ($anum > 0) { + if ($anum > 31) { + //ADOConnection::outp( "MSSQL: YYYY-MM-DD date format not supported currently"); + } else + $ADODB_mssql_date_order = 'dmy'; + } else + $ADODB_mssql_date_order = 'mdy'; + } +} + +class ADODB_mssqlnative extends ADOConnection { + var $databaseType = "mssqlnative"; + var $dataProvider = "mssqlnative"; + var $replaceQuote = "''"; // string to use to replace quotes + var $fmtDate = "'Y-m-d'"; + var $fmtTimeStamp = "'Y-m-d H:i:s'"; + var $hasInsertID = true; + var $substr = "substring"; + var $length = 'len'; + var $hasAffectedRows = true; + var $poorAffectedRows = false; + var $metaDatabasesSQL = "select name from sys.sysdatabases where name <> 'master'"; + var $metaTablesSQL="select name,case when type='U' then 'T' else 'V' end from sysobjects where (type='U' or type='V') and (name not in ('sysallocations','syscolumns','syscomments','sysdepends','sysfilegroups','sysfiles','sysfiles1','sysforeignkeys','sysfulltextcatalogs','sysindexes','sysindexkeys','sysmembers','sysobjects','syspermissions','sysprotects','sysreferences','systypes','sysusers','sysalternates','sysconstraints','syssegments','REFERENTIAL_CONSTRAINTS','CHECK_CONSTRAINTS','CONSTRAINT_TABLE_USAGE','CONSTRAINT_COLUMN_USAGE','VIEWS','VIEW_TABLE_USAGE','VIEW_COLUMN_USAGE','SCHEMATA','TABLES','TABLE_CONSTRAINTS','TABLE_PRIVILEGES','COLUMNS','COLUMN_DOMAIN_USAGE','COLUMN_PRIVILEGES','DOMAINS','DOMAIN_CONSTRAINTS','KEY_COLUMN_USAGE','dtproperties'))"; + var $metaColumnsSQL = # xtype==61 is datetime + "select c.name,t.name,c.length, + (case when c.xusertype=61 then 0 else c.xprec end), + (case when c.xusertype=61 then 0 else c.xscale end) + from syscolumns c join systypes t on t.xusertype=c.xusertype join sysobjects o on o.id=c.id where o.name='%s'"; + var $hasTop = 'top'; // support mssql SELECT TOP 10 * FROM TABLE + var $hasGenID = true; + var $sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; + var $sysTimeStamp = 'GetDate()'; + var $maxParameterLen = 4000; + var $arrayClass = 'ADORecordSet_array_mssqlnative'; + var $uniqueSort = true; + var $leftOuter = '*='; + var $rightOuter = '=*'; + var $ansiOuter = true; // for mssql7 or later + var $identitySQL = 'select SCOPE_IDENTITY()'; // 'select SCOPE_IDENTITY'; # for mssql 2000 + var $uniqueOrderBy = true; + var $_bindInputArray = true; + var $_dropSeqSQL = "drop table %s"; + + function ADODB_mssqlnative() + { + if ($this->debug) { + error_log("
");
+            sqlsrv_set_error_handling( SQLSRV_ERRORS_LOG_ALL );
+            sqlsrv_log_set_severity( SQLSRV_LOG_SEVERITY_ALL );
+            sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
+            sqlsrv_configure('warnings_return_as_errors', 0);
+        } else {
+            sqlsrv_set_error_handling(0);
+            sqlsrv_log_set_severity(0);
+            sqlsrv_log_set_subsystems(SQLSRV_LOG_SYSTEM_ALL);
+            sqlsrv_configure('warnings_return_as_errors', 0);
+        }
+	}
+
+	function ServerInfo()
+	{
+    	global $ADODB_FETCH_MODE;
+		if ($this->fetchMode === false) {
+			$savem = $ADODB_FETCH_MODE;
+			$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+		} else 
+			$savem = $this->SetFetchMode(ADODB_FETCH_NUM);
+		$arrServerInfo = sqlsrv_server_info($this->_connectionID);
+		$arr['description'] = $arrServerInfo['SQLServerName'].' connected to '.$arrServerInfo['CurrentDatabase'];
+		$arr['version'] = $arrServerInfo['SQLServerVersion'];//ADOConnection::_findvers($arr['description']);
+		return $arr;
+	}
+	
+	function IfNull( $field, $ifNull ) 
+	{
+		return " ISNULL($field, $ifNull) "; // if MS SQL Server
+	}
+	
+	function _insertid()
+	{
+	// SCOPE_IDENTITY()
+	// Returns the last IDENTITY value inserted into an IDENTITY column in 
+	// the same scope. A scope is a module -- a stored procedure, trigger, 
+	// function, or batch. Thus, two statements are in the same scope if 
+	// they are in the same stored procedure, function, or batch.
+		return $this->GetOne($this->identitySQL);
+	}
+
+	function _affectedrows()
+	{
+        return sqlsrv_rows_affected($this->_queryID);
+	}
+	
+	function CreateSequence($seq='adodbseq',$start=1)
+	{
+		if($this->debug) error_log("
CreateSequence($seq,$start)"); + sqlsrv_begin_transaction($this->_connectionID); + $start -= 1; + $this->Execute("create table $seq (id int)");//was float(53) + $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); + if (!$ok) { + if($this->debug) error_log("
Error: ROLLBACK"); + sqlsrv_rollback($this->_connectionID); + return false; + } + sqlsrv_commit($this->_connectionID); + return true; + } + + function GenID($seq='adodbseq',$start=1) + { + if($this->debug) error_log("
GenID($seq,$start)"); + sqlsrv_begin_transaction($this->_connectionID); + $ok = $this->Execute("update $seq with (tablock,holdlock) set id = id + 1"); + if (!$ok) { + $this->Execute("create table $seq (id int)"); + $ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)"); + if (!$ok) { + if($this->debug) error_log("
Error: ROLLBACK"); + sqlsrv_rollback($this->_connectionID); + return false; + } + sqlsrv_commit($this->_connectionID); + return $start; + } + $num = $this->GetOne("select id from $seq"); + sqlsrv_commit($this->_connectionID); + if($this->debug) error_log(" Returning: $num"); + return $num; + } + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysTimeStamp; + $s = ''; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + if ($s) $s .= '+'; + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + $s .= "datename(yyyy,$col)"; + break; + case 'M': + $s .= "convert(char(3),$col,0)"; + break; + case 'm': + $s .= "replace(str(month($col),2),' ','0')"; + break; + case 'Q': + case 'q': + $s .= "datename(quarter,$col)"; + break; + case 'D': + case 'd': + $s .= "replace(str(day($col),2),' ','0')"; + break; + case 'h': + $s .= "substring(convert(char(14),$col,0),13,2)"; + break; + + case 'H': + $s .= "replace(str(datepart(hh,$col),2),' ','0')"; + break; + + case 'i': + $s .= "replace(str(datepart(mi,$col),2),' ','0')"; + break; + case 's': + $s .= "replace(str(datepart(ss,$col),2),' ','0')"; + break; + case 'a': + case 'A': + $s .= "substring(convert(char(19),$col,0),18,2)"; + break; + + default: + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + $s .= $this->qstr($ch); + break; + } + } + return $s; + } + + + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + if ($this->debug) error_log('
begin transaction'); + sqlsrv_begin_transaction($this->_connectionID); + return true; + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if ($this->debug) error_log('
commit transaction'); + if (!$ok) return $this->RollbackTrans(); + if ($this->transCnt) $this->transCnt -= 1; + sqlsrv_commit($this->_connectionID); + return true; + } + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->debug) error_log('
rollback transaction'); + if ($this->transCnt) $this->transCnt -= 1; + sqlsrv_rollback($this->_connectionID); + return true; + } + + function SetTransactionMode( $transaction_mode ) + { + $this->_transmode = $transaction_mode; + if (empty($transaction_mode)) { + $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); + return; + } + if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; + $this->Execute("SET TRANSACTION ".$transaction_mode); + } + + /* + Usage: + + $this->BeginTrans(); + $this->RowLock('table1,table2','table1.id=33 and table2.id=table1.id'); # lock row 33 for both tables + + # some operation on both tables table1 and table2 + + $this->CommitTrans(); + + See http://www.swynk.com/friends/achigrik/SQL70Locks.asp + */ + function RowLock($tables,$where,$flds='top 1 null as ignore') + { + if (!$this->transCnt) $this->BeginTrans(); + return $this->GetOne("select $flds from $tables with (ROWLOCK,HOLDLOCK) where $where"); + } + + function SelectDB($dbName) + { + $this->database = $dbName; + $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions + if ($this->_connectionID) { + $rs = $this->Execute('USE '.$dbName); + if($rs) { + return true; + } else return false; + } + else return false; + } + + function ErrorMsg() + { + $retErrors = sqlsrv_errors(SQLSRV_ERR_ALL); + if($retErrors != null) { + foreach($retErrors as $arrError) { + $this->_errorMsg .= "SQLState: ".$arrError[ 'SQLSTATE']."\n"; + $this->_errorMsg .= "Error Code: ".$arrError[ 'code']."\n"; + $this->_errorMsg .= "Message: ".$arrError[ 'message']."\n"; + } + } else { + $this->_errorMsg = "No errors found"; + } + return $this->_errorMsg; + } + + function ErrorNo() + { + if ($this->_logsql && $this->_errorCode !== false) return $this->_errorCode; + $err = sqlsrv_errors(SQLSRV_ERR_ALL); + if($err[0]) return $err[0]['code']; + else return -1; + } + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!function_exists('sqlsrv_connect')) return null; + $connectionInfo = array("Database"=>$argDatabasename,'UID'=>$argUsername,'PWD'=>$argPassword); + if ($this->debug) error_log("
connecting... hostname: $argHostname params: ".var_export($connectionInfo,true)); + //if ($this->debug) error_log("
_connectionID before: ".serialize($this->_connectionID)); + if(!($this->_connectionID = sqlsrv_connect($argHostname,$connectionInfo))) { + if ($this->debug) error_log( "
errors: ".print_r( sqlsrv_errors(), true)); + return false; + } + //if ($this->debug) error_log(" _connectionID after: ".serialize($this->_connectionID)); + //if ($this->debug) error_log("
defined functions:
".var_export(get_defined_functions(),true)."
"); + return true; + } + + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + //return null;//not implemented. NOTE: Persistent connections have no effect if PHP is used as a CGI program. (FastCGI!) + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename); + } + + function Prepare($sql) + { + $stmt = sqlsrv_prepare( $this->_connectionID, $sql); + if (!$stmt) return $sql; + return array($sql,$stmt); + } + + // returns concatenated string + // MSSQL requires integers to be cast as strings + // automatically cast every datatype to VARCHAR(255) + // @author David Rogers (introspectshun) + function Concat() + { + $s = ""; + $arr = func_get_args(); + + // Split single record on commas, if possible + if (sizeof($arr) == 1) { + foreach ($arr as $arg) { + $args = explode(',', $arg); + } + $arr = $args; + } + + array_walk($arr, create_function('&$v', '$v = "CAST(" . $v . " AS VARCHAR(255))";')); + $s = implode('+',$arr); + if (sizeof($arr) > 0) return "$s"; + + return ''; + } + + /* + Unfortunately, it appears that mssql cannot handle varbinary > 255 chars + So all your blobs must be of type "image". + + Remember to set in php.ini the following... + + ; Valid range 0 - 2147483647. Default = 4096. + mssql.textlimit = 0 ; zero to pass through + + ; Valid range 0 - 2147483647. Default = 4096. + mssql.textsize = 0 ; zero to pass through + */ + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + + if (strtoupper($blobtype) == 'CLOB') { + $sql = "UPDATE $table SET $column='" . $val . "' WHERE $where"; + return $this->Execute($sql) != false; + } + $sql = "UPDATE $table SET $column=0x".bin2hex($val)." WHERE $where"; + return $this->Execute($sql) != false; + } + + // returns query ID if successful, otherwise false + function _query($sql,$inputarr) + { + $this->_errorMsg = false; + if (is_array($inputarr)) { + $rez = sqlsrv_query($this->_connectionID,$sql,$inputarr); + } else if (is_array($sql)) { + $rez = sqlsrv_query($this->_connectionID,$sql[1],$inputarr); + } else { + $rez = sqlsrv_query($this->_connectionID,$sql); + } + if ($this->debug) error_log("
running query: ".var_export($sql,true)."
input array: ".var_export($inputarr,true)."
result: ".var_export($rez,true));//"
connection: ".serialize($this->_connectionID) + //fix for returning true on anything besides select statements + if (is_array($sql)) $sql = $sql[1]; + $sql = ltrim($sql); + if(stripos($sql, 'SELECT') !== 0 && $rez !== false) { + if ($this->debug) error_log(" isn't a select query, returning boolean true"); + return true; + } + //end fix + if(!$rez) $rez = false; + return $rez; + } + + // returns true or false + function _close() + { + if ($this->transCnt) $this->RollbackTrans(); + $rez = @sqlsrv_close($this->_connectionID); + $this->_connectionID = false; + return $rez; + } + + // mssql uses a default date like Dec 30 2000 12:00AM + function UnixDate($v) + { + return ADORecordSet_array_mssql::UnixDate($v); + } + + function UnixTimeStamp($v) + { + return ADORecordSet_array_mssql::UnixTimeStamp($v); + } + + function &MetaIndexes($table,$primary=false) + { + $table = $this->qstr($table); + + $sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno, + CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK, + CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique + FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id + INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid + INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid + WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND O.Name LIKE $table + ORDER BY O.name, I.Name, K.keyno"; + + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + + $rs = $this->Execute($sql); + if (isset($savem)) { + $this->SetFetchMode($savem); + } + $ADODB_FETCH_MODE = $save; + + if (!is_object($rs)) { + return FALSE; + } + + $indexes = array(); + while ($row = $rs->FetchRow()) { + if (!$primary && $row[5]) continue; + + $indexes[$row[0]]['unique'] = $row[6]; + $indexes[$row[0]]['columns'][] = $row[1]; + } + return $indexes; + } + + function MetaForeignKeys($table, $owner=false, $upper=false) + { + global $ADODB_FETCH_MODE; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $table = $this->qstr(strtoupper($table)); + + $sql = + "select object_name(constid) as constraint_name, + col_name(fkeyid, fkey) as column_name, + object_name(rkeyid) as referenced_table_name, + col_name(rkeyid, rkey) as referenced_column_name + from sysforeignkeys + where upper(object_name(fkeyid)) = $table + order by constraint_name, referenced_table_name, keyno"; + + $constraints =& $this->GetArray($sql); + + $ADODB_FETCH_MODE = $save; + + $arr = false; + foreach($constraints as $constr) { + //print_r($constr); + $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; + } + if (!$arr) return false; + + $arr2 = false; + + foreach($arr as $k => $v) { + foreach($v as $a => $b) { + if ($upper) $a = strtoupper($a); + $arr2[$a] = $b; + } + } + return $arr2; + } + + //From: Fernando Moreira + function MetaDatabases() + { + $this->SelectDB("master"); + $rs =& $this->Execute($this->metaDatabasesSQL); + $rows = $rs->GetRows(); + $ret = array(); + for($i=0;$iSelectDB($this->database); + if($ret) + return $ret; + else + return false; + } + + // "Stein-Aksel Basma" + // tested with MSSQL 2000 + function &MetaPrimaryKeys($table) + { + global $ADODB_FETCH_MODE; + + $schema = ''; + $this->_findschema($table,$schema); + if (!$schema) $schema = $this->database; + if ($schema) $schema = "and k.table_catalog like '$schema%'"; + + $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k, + information_schema.table_constraints tc + where tc.constraint_name = k.constraint_name and tc.constraint_type = + 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position "; + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $a = $this->GetCol($sql); + $ADODB_FETCH_MODE = $savem; + + if ($a && sizeof($a)>0) return $a; + $false = false; + return $false; + } + + + function &MetaTables($ttype=false,$showSchema=false,$mask=false) + { + if ($mask) { + $save = $this->metaTablesSQL; + $mask = $this->qstr(($mask)); + $this->metaTablesSQL .= " AND name like $mask"; + } + $ret =& ADOConnection::MetaTables($ttype,$showSchema); + + if ($mask) { + $this->metaTablesSQL = $save; + } + return $ret; + } +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_mssqlnative extends ADORecordSet { + + var $databaseType = "mssqlnative"; + var $canSeek = false; + var $fieldOffset = 0; + // _mths works only in non-localised system + + function ADORecordset_mssqlnative($id,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + + } + $this->fetchMode = $mode; + return $this->ADORecordSet($id,$mode); + } + + + function _initrs() + { + global $ADODB_COUNTRECS; + if ($this->connection->debug) error_log("(before) ADODB_COUNTRECS: {$ADODB_COUNTRECS} _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}"); + /*$retRowsAff = sqlsrv_rows_affected($this->_queryID);//"If you need to determine the number of rows a query will return before retrieving the actual results, appending a SELECT COUNT ... query would let you get that information, and then a call to next_result would move you to the "real" results." + error_log("rowsaff: ".serialize($retRowsAff)); + $this->_numOfRows = ($ADODB_COUNTRECS)? $retRowsAff:-1;*/ + $this->_numOfRows = -1;//not supported + $fieldmeta = sqlsrv_field_metadata($this->_queryID); + $this->_numOfFields = ($fieldmeta)? count($fieldmeta):-1; + if ($this->connection->debug) error_log("(after) _numOfRows: {$this->_numOfRows} _numOfFields: {$this->_numOfFields}"); + } + + + //Contributed by "Sven Axelsson" + // get next resultset - requires PHP 4.0.5 or later + function NextRecordSet() + { + if (!sqlsrv_next_result($this->_queryID)) return false; + $this->_inited = false; + $this->bind = false; + $this->_currentRow = -1; + $this->Init(); + return true; + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + if ($this->fetchMode != ADODB_FETCH_NUM) return $this->fields[$colname]; + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + /* Returns: an object containing field information. + Get column information in the Recordset object. fetchField() can be used in order to obtain information about + fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by + fetchField() is retrieved. */ + + function &FetchField($fieldOffset = -1) + { + if ($this->connection->debug) error_log("
fetchfield: $fieldOffset, fetch array:
".print_r($this->fields,true)."
backtrace: ".adodb_backtrace(false)); + if ($fieldOffset != -1) $this->fieldOffset = $fieldOffset; + $arrKeys = array_keys($this->fields); + if(array_key_exists($this->fieldOffset,$arrKeys) && !array_key_exists($arrKeys[$this->fieldOffset],$this->fields)) { + $f = false; + } else { + $f = $this->fields[ $arrKeys[$this->fieldOffset] ]; + if($fieldOffset == -1) $this->fieldOffset++; + } + + if (empty($f)) { + $f = false;//PHP Notice: Only variable references should be returned by reference + } + return $f; + } + + function _seek($row) + { + return false;//There is no support for cursors in the driver at this time. All data is returned via forward-only streams. + } + + // speedup + function MoveNext() + { + if ($this->connection->debug) error_log("movenext()"); + //if ($this->connection->debug) error_log("eof (beginning): ".$this->EOF); + if ($this->EOF) return false; + + $this->_currentRow++; + if ($this->connection->debug) error_log("_currentRow: ".$this->_currentRow); + + if ($this->_fetch()) return true; + $this->EOF = true; + //if ($this->connection->debug) error_log("eof (end): ".$this->EOF); + + return false; + } + + + // INSERT UPDATE DELETE returns false even if no error occurs in 4.0.4 + // also the date format has been changed from YYYY-mm-dd to dd MMM YYYY in 4.0.4. Idiot! + function _fetch($ignore_fields=false) + { + if ($this->connection->debug) error_log("_fetch()"); + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + if ($this->fetchMode & ADODB_FETCH_NUM) { + if ($this->connection->debug) error_log("fetch mode: both"); + $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_BOTH); + } else { + if ($this->connection->debug) error_log("fetch mode: assoc"); + $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_ASSOC); + } + + if (ADODB_ASSOC_CASE == 0) { + foreach($this->fields as $k=>$v) { + $this->fields[strtolower($k)] = $v; + } + } else if (ADODB_ASSOC_CASE == 1) { + foreach($this->fields as $k=>$v) { + $this->fields[strtoupper($k)] = $v; + } + } + } else { + if ($this->connection->debug) error_log("fetch mode: num"); + $this->fields = @sqlsrv_fetch_array($this->_queryID,SQLSRV_FETCH_NUMERIC); + } + if(is_array($this->fields) && array_key_exists(1,$this->fields) && !array_key_exists(0,$this->fields)) {//fix fetch numeric keys since they're not 0 based + $arrFixed = array(); + foreach($this->fields as $key=>$value) { + if(is_numeric($key)) { + $arrFixed[$key-1] = $value; + } else { + $arrFixed[$key] = $value; + } + } + //if($this->connection->debug) error_log("
fixing non 0 based return array, old: ".print_r($this->fields,true)." new: ".print_r($arrFixed,true)); + $this->fields = $arrFixed; + } + if(is_array($this->fields)) { + foreach($this->fields as $key=>$value) { + if (is_object($value) && method_exists($value, 'format')) {//is DateTime object + $this->fields[$key] = $value->format("Y-m-d\TH:i:s\Z"); + } + } + } + if($this->fields === null) $this->fields = false; + if ($this->connection->debug) error_log("
after _fetch, fields:
".print_r($this->fields,true)." backtrace: ".adodb_backtrace(false));
+		return $this->fields;
+	}
+	
+    /*	close() only needs to be called if you are worried about using too much memory while your script
+		is running. All associated result memory for the specified result identifier will automatically be freed.	*/
+	function _close() 
+	{
+		$rez = sqlsrv_free_stmt($this->_queryID);	
+		$this->_queryID = false;
+		return $rez;
+	}
+
+	// mssql uses a default date like Dec 30 2000 12:00AM
+	function UnixDate($v)
+	{
+		return ADORecordSet_array_mssqlnative::UnixDate($v);
+	}
+	
+	function UnixTimeStamp($v)
+	{
+		return ADORecordSet_array_mssqlnative::UnixTimeStamp($v);
+	}
+}
+
+
+class ADORecordSet_array_mssqlnative extends ADORecordSet_array {
+	function ADORecordSet_array_mssqlnative($id=-1,$mode=false) 
+	{
+		$this->ADORecordSet_array($id,$mode);
+	}
+	
+		// mssql uses a default date like Dec 30 2000 12:00AM
+	function UnixDate($v)
+	{
+	
+		if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixDate($v);
+		
+    	global $ADODB_mssql_mths,$ADODB_mssql_date_order;
+	
+		//Dec 30 2000 12:00AM 
+		if ($ADODB_mssql_date_order == 'dmy') {
+			if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
+				return parent::UnixDate($v);
+			}
+			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
+			
+			$theday = $rr[1];
+			$themth =  substr(strtoupper($rr[2]),0,3);
+		} else {
+			if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})|" ,$v, $rr)) {
+				return parent::UnixDate($v);
+			}
+			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
+			
+			$theday = $rr[2];
+			$themth = substr(strtoupper($rr[1]),0,3);
+		}
+		$themth = $ADODB_mssql_mths[$themth];
+		if ($themth <= 0) return false;
+		// h-m-s-MM-DD-YY
+		return  mktime(0,0,0,$themth,$theday,$rr[3]);
+	}
+	
+	function UnixTimeStamp($v)
+	{
+	
+		if (is_numeric(substr($v,0,1)) && ADODB_PHPVER >= 0x4200) return parent::UnixTimeStamp($v);
+		
+	    global $ADODB_mssql_mths,$ADODB_mssql_date_order;
+	
+		//Dec 30 2000 12:00AM
+		 if ($ADODB_mssql_date_order == 'dmy') {
+			 if (!preg_match( "|^([0-9]{1,2})[-/\. ]+([A-Za-z]{3})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
+			,$v, $rr)) return parent::UnixTimeStamp($v);
+			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
+		
+			$theday = $rr[1];
+			$themth =  substr(strtoupper($rr[2]),0,3);
+		} else {
+			if (!preg_match( "|^([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})|"
+			,$v, $rr)) return parent::UnixTimeStamp($v);
+			if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;
+		
+			$theday = $rr[2];
+			$themth = substr(strtoupper($rr[1]),0,3);
+		}
+		
+		$themth = $ADODB_mssql_mths[$themth];
+		if ($themth <= 0) return false;
+		
+		switch (strtoupper($rr[6])) {
+		case 'P':
+			if ($rr[4]<12) $rr[4] += 12;
+			break;
+		case 'A':
+			if ($rr[4]==12) $rr[4] = 0;
+			break;
+		default:
+			break;
+		}
+		// h-m-s-MM-DD-YY
+		return  mktime($rr[4],$rr[5],0,$themth,$theday,$rr[3]);
+	}
+}
+
+/*
+Code Example 1:
+
+select 	object_name(constid) as constraint_name,
+       	object_name(fkeyid) as table_name, 
+        col_name(fkeyid, fkey) as column_name,
+	object_name(rkeyid) as referenced_table_name,
+   	col_name(rkeyid, rkey) as referenced_column_name
+from sysforeignkeys
+where object_name(fkeyid) = x
+order by constraint_name, table_name, referenced_table_name,  keyno
+
+Code Example 2:
+select 	constraint_name,
+	column_name,
+	ordinal_position
+from information_schema.key_column_usage
+where constraint_catalog = db_name()
+and table_name = x
+order by constraint_name, ordinal_position
+
+http://www.databasejournal.com/scripts/article.php/1440551
+*/
+
+?>
\ No newline at end of file
diff --git a/includes/adodb/drivers/adodb-mssqlpo.inc.php b/includes/adodb/drivers/adodb-mssqlpo.inc.php
new file mode 100644
index 00000000..dccb18c2
--- /dev/null
+++ b/includes/adodb/drivers/adodb-mssqlpo.inc.php
@@ -0,0 +1,62 @@
+_has_mssql_init) {
+			ADOConnection::outp( "PrepareSP: mssql_init only available since PHP 4.1.0");
+			return $sql;
+		}
+		if (is_string($sql)) $sql = str_replace('||','+',$sql);
+		$stmt = mssql_init($sql,$this->_connectionID);
+		if (!$stmt)  return $sql;
+		return array($sql,$stmt);
+	}
+	
+	function _query($sql,$inputarr)
+	{
+		if (is_string($sql)) $sql = str_replace('||','+',$sql);
+		return ADODB_mssql::_query($sql,$inputarr);
+	}
+}
+
+class ADORecordset_mssqlpo extends ADORecordset_mssql {
+	var $databaseType = "mssqlpo";
+	function ADORecordset_mssqlpo($id,$mode=false)
+	{
+		$this->ADORecordset_mssql($id,$mode);
+	}
+}
+?>
\ No newline at end of file
diff --git a/includes/adodb/drivers/adodb-mysql.inc.php b/includes/adodb/drivers/adodb-mysql.inc.php
new file mode 100644
index 00000000..268e91c3
--- /dev/null
+++ b/includes/adodb/drivers/adodb-mysql.inc.php
@@ -0,0 +1,791 @@
+rsPrefix .= 'ext_';
+	}
+	
+	function ServerInfo()
+	{
+		$arr['description'] = ADOConnection::GetOne("select version()");
+		$arr['version'] = ADOConnection::_findvers($arr['description']);
+		return $arr;
+	}
+	
+	function IfNull( $field, $ifNull ) 
+	{
+		return " IFNULL($field, $ifNull) "; // if MySQL
+	}
+	
+	
+	function MetaTables($ttype=false,$showSchema=false,$mask=false) 
+	{	
+		$save = $this->metaTablesSQL;
+		if ($showSchema && is_string($showSchema)) {
+			$this->metaTablesSQL .= " from $showSchema";
+		}
+		
+		if ($mask) {
+			$mask = $this->qstr($mask);
+			$this->metaTablesSQL .= " like $mask";
+		}
+		$ret = ADOConnection::MetaTables($ttype,$showSchema);
+		
+		$this->metaTablesSQL = $save;
+		return $ret;
+	}
+	
+	
+	function MetaIndexes ($table, $primary = FALSE, $owner=false)
+	{
+        // save old fetch mode
+        global $ADODB_FETCH_MODE;
+        
+		$false = false;
+        $save = $ADODB_FETCH_MODE;
+        $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+        if ($this->fetchMode !== FALSE) {
+               $savem = $this->SetFetchMode(FALSE);
+        }
+        
+        // get index details
+        $rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table));
+        
+        // restore fetchmode
+        if (isset($savem)) {
+                $this->SetFetchMode($savem);
+        }
+        $ADODB_FETCH_MODE = $save;
+        
+        if (!is_object($rs)) {
+                return $false;
+        }
+        
+        $indexes = array ();
+        
+        // parse index data into array
+        while ($row = $rs->FetchRow()) {
+                if ($primary == FALSE AND $row[2] == 'PRIMARY') {
+                        continue;
+                }
+                
+                if (!isset($indexes[$row[2]])) {
+                        $indexes[$row[2]] = array(
+                                'unique' => ($row[1] == 0),
+                                'columns' => array()
+                        );
+                }
+                
+                $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
+        }
+        
+        // sort columns by order in the index
+        foreach ( array_keys ($indexes) as $index )
+        {
+                ksort ($indexes[$index]['columns']);
+        }
+        
+        return $indexes;
+	}
+
+	
+	// if magic quotes disabled, use mysql_real_escape_string()
+	function qstr($s,$magic_quotes=false)
+	{
+		if (is_null($s)) return 'NULL';
+		if (!$magic_quotes) {
+		
+			if (ADODB_PHPVER >= 0x4300) {
+				if (is_resource($this->_connectionID))
+					return "'".mysql_real_escape_string($s,$this->_connectionID)."'";
+			}
+			if ($this->replaceQuote[0] == '\\'){
+				$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
+			}
+			return  "'".str_replace("'",$this->replaceQuote,$s)."'"; 
+		}
+		
+		// undo magic quotes for "
+		$s = str_replace('\\"','"',$s);
+		return "'$s'";
+	}
+	
+	function _insertid()
+	{
+		return ADOConnection::GetOne('SELECT LAST_INSERT_ID()');
+		//return mysql_insert_id($this->_connectionID);
+	}
+	
+	function GetOne($sql,$inputarr=false)
+	{
+		if ($this->compat323 == false && strncasecmp($sql,'sele',4) == 0) {
+			$rs = $this->SelectLimit($sql,1,-1,$inputarr);
+			if ($rs) {
+				$rs->Close();
+				if ($rs->EOF) return false;
+				return reset($rs->fields);
+			}
+		} else {
+			return ADOConnection::GetOne($sql,$inputarr);
+		}
+		return false;
+	}
+	
+	function BeginTrans()
+	{
+		if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver");
+	}
+	
+	function _affectedrows()
+	{
+			return mysql_affected_rows($this->_connectionID);
+	}
+  
+ 	 // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
+	// Reference on Last_Insert_ID on the recommended way to simulate sequences
+ 	var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
+	var $_genSeqSQL = "create table %s (id int not null)";
+	var $_genSeqCountSQL = "select count(*) from %s";
+	var $_genSeq2SQL = "insert into %s values (%s)";
+	var $_dropSeqSQL = "drop table %s";
+	
+	function CreateSequence($seqname='adodbseq',$startID=1)
+	{
+		if (empty($this->_genSeqSQL)) return false;
+		$u = strtoupper($seqname);
+		
+		$ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
+		if (!$ok) return false;
+		return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
+	}
+	
+
+	function GenID($seqname='adodbseq',$startID=1)
+	{
+		// post-nuke sets hasGenID to false
+		if (!$this->hasGenID) return false;
+		
+		$savelog = $this->_logsql;
+		$this->_logsql = false;
+		$getnext = sprintf($this->_genIDSQL,$seqname);
+		$holdtransOK = $this->_transOK; // save the current status
+		$rs = @$this->Execute($getnext);
+		if (!$rs) {
+			if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset
+			$u = strtoupper($seqname);
+			$this->Execute(sprintf($this->_genSeqSQL,$seqname));
+			$cnt = $this->GetOne(sprintf($this->_genSeqCountSQL,$seqname));
+			if (!$cnt) $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
+			$rs = $this->Execute($getnext);
+		}
+		
+		if ($rs) {
+			$this->genID = mysql_insert_id($this->_connectionID);
+			$rs->Close();
+		} else
+			$this->genID = 0;
+		
+		$this->_logsql = $savelog;
+		return $this->genID;
+	}
+	
+  	function MetaDatabases()
+	{
+		$qid = mysql_list_dbs($this->_connectionID);
+		$arr = array();
+		$i = 0;
+		$max = mysql_num_rows($qid);
+		while ($i < $max) {
+			$db = mysql_tablename($qid,$i);
+			if ($db != 'mysql') $arr[] = $db;
+			$i += 1;
+		}
+		return $arr;
+	}
+	
+		
+	// Format date column in sql string given an input format that understands Y M D
+	function SQLDate($fmt, $col=false)
+	{	
+		if (!$col) $col = $this->sysTimeStamp;
+		$s = 'DATE_FORMAT('.$col.",'";
+		$concat = false;
+		$len = strlen($fmt);
+		for ($i=0; $i < $len; $i++) {
+			$ch = $fmt[$i];
+			switch($ch) {
+				
+			default:
+				if ($ch == '\\') {
+					$i++;
+					$ch = substr($fmt,$i,1);
+				}
+				/** FALL THROUGH */
+			case '-':
+			case '/':
+				$s .= $ch;
+				break;
+				
+			case 'Y':
+			case 'y':
+				$s .= '%Y';
+				break;
+			case 'M':
+				$s .= '%b';
+				break;
+				
+			case 'm':
+				$s .= '%m';
+				break;
+			case 'D':
+			case 'd':
+				$s .= '%d';
+				break;
+			
+			case 'Q':
+			case 'q':
+				$s .= "'),Quarter($col)";
+				
+				if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
+				else $s .= ",('";
+				$concat = true;
+				break;
+			
+			case 'H': 
+				$s .= '%H';
+				break;
+				
+			case 'h':
+				$s .= '%I';
+				break;
+				
+			case 'i':
+				$s .= '%i';
+				break;
+				
+			case 's':
+				$s .= '%s';
+				break;
+				
+			case 'a':
+			case 'A':
+				$s .= '%p';
+				break;
+				
+			case 'w':
+				$s .= '%w';
+				break;
+				
+			 case 'W':
+				$s .= '%U';
+				break;
+				
+			case 'l':
+				$s .= '%W';
+				break;
+			}
+		}
+		$s.="')";
+		if ($concat) $s = "CONCAT($s)";
+		return $s;
+	}
+	
+
+	// returns concatenated string
+	// much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator
+	function Concat()
+	{
+		$s = "";
+		$arr = func_get_args();
+		
+		// suggestion by andrew005@mnogo.ru
+		$s = implode(',',$arr); 
+		if (strlen($s) > 0) return "CONCAT($s)";
+		else return '';
+	}
+	
+	function OffsetDate($dayFraction,$date=false)
+	{		
+		if (!$date) $date = $this->sysDate;
+		
+		$fraction = $dayFraction * 24 * 3600;
+		return $date . ' + INTERVAL ' .	 $fraction.' SECOND';
+		
+//		return "from_unixtime(unix_timestamp($date)+$fraction)";
+	}
+	
+	// returns true or false
+	function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
+	{
+		if (!empty($this->port)) $argHostname .= ":".$this->port;
+		
+		if (ADODB_PHPVER >= 0x4300)
+			$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
+												$this->forceNewConnect,$this->clientFlags);
+		else if (ADODB_PHPVER >= 0x4200)
+			$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword,
+												$this->forceNewConnect);
+		else
+			$this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword);
+	
+		if ($this->_connectionID === false) return false;
+		if ($argDatabasename) return $this->SelectDB($argDatabasename);
+		return true;	
+	}
+	
+	// returns true or false
+	function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+	{
+		if (!empty($this->port)) $argHostname .= ":".$this->port;
+		
+		if (ADODB_PHPVER >= 0x4300)
+			$this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword,$this->clientFlags);
+		else
+			$this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword);
+		if ($this->_connectionID === false) return false;
+		if ($this->autoRollback) $this->RollbackTrans();
+		if ($argDatabasename) return $this->SelectDB($argDatabasename);
+		return true;	
+	}
+	
+	function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+	{
+		$this->forceNewConnect = true;
+		return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
+	}
+	
+ 	function MetaColumns($table) 
+	{
+		$this->_findschema($table,$schema);
+		if ($schema) {
+			$dbName = $this->database;
+			$this->SelectDB($schema);
+		}
+		global $ADODB_FETCH_MODE;
+		$save = $ADODB_FETCH_MODE;
+		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+		
+		if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false);
+		$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+		
+		if ($schema) {
+			$this->SelectDB($dbName);
+		}
+		
+		if (isset($savem)) $this->SetFetchMode($savem);
+		$ADODB_FETCH_MODE = $save;
+		if (!is_object($rs)) {
+			$false = false;
+			return $false;
+		}
+			
+		$retarr = array();
+		while (!$rs->EOF){
+			$fld = new ADOFieldObject();
+			$fld->name = $rs->fields[0];
+			$type = $rs->fields[1];
+			
+			// split type into type(length):
+			$fld->scale = null;
+			if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
+				$fld->type = $query_array[1];
+				$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+				$fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
+			} elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
+				$fld->type = $query_array[1];
+				$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+			} elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
+				$fld->type = $query_array[1];
+				$arr = explode(",",$query_array[2]);
+				$fld->enums = $arr;
+				$zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6
+				$fld->max_length = ($zlen > 0) ? $zlen : 1;
+			} else {
+				$fld->type = $type;
+				$fld->max_length = -1;
+			}
+			$fld->not_null = ($rs->fields[2] != 'YES');
+			$fld->primary_key = ($rs->fields[3] == 'PRI');
+			$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
+			$fld->binary = (strpos($type,'blob') !== false || strpos($type,'binary') !== false);
+			$fld->unsigned = (strpos($type,'unsigned') !== false);
+			$fld->zerofill = (strpos($type,'zerofill') !== false);
+
+			if (!$fld->binary) {
+				$d = $rs->fields[4];
+				if ($d != '' && $d != 'NULL') {
+					$fld->has_default = true;
+					$fld->default_value = $d;
+				} else {
+					$fld->has_default = false;
+				}
+			}
+			
+			if ($save == ADODB_FETCH_NUM) {
+				$retarr[] = $fld;
+			} else {
+				$retarr[strtoupper($fld->name)] = $fld;
+			}
+				$rs->MoveNext();
+			}
+		
+			$rs->Close();
+			return $retarr;	
+	}
+		
+	// returns true or false
+	function SelectDB($dbName) 
+	{
+		$this->database = $dbName;
+		$this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
+		if ($this->_connectionID) {
+			return @mysql_select_db($dbName,$this->_connectionID);		
+		}
+		else return false;	
+	}
+	
+	// parameters use PostgreSQL convention, not MySQL
+	function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0)
+	{
+		$offsetStr =($offset>=0) ? ((integer)$offset)."," : '';
+		// jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220
+		if ($nrows < 0) $nrows = '18446744073709551615'; 
+		
+		if ($secs)
+			$rs = $this->CacheExecute($secs,$sql." LIMIT $offsetStr".((integer)$nrows),$inputarr);
+		else
+			$rs = $this->Execute($sql." LIMIT $offsetStr".((integer)$nrows),$inputarr);
+		return $rs;
+	}
+	
+	// returns queryID or false
+	function _query($sql,$inputarr)
+	{
+	//global $ADODB_COUNTRECS;
+		//if($ADODB_COUNTRECS) 
+		return mysql_query($sql,$this->_connectionID);
+		//else return @mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6
+	}
+
+	/*	Returns: the last error message from previous database operation	*/	
+	function ErrorMsg() 
+	{
+	
+		if ($this->_logsql) return $this->_errorMsg;
+		if (empty($this->_connectionID)) $this->_errorMsg = @mysql_error();
+		else $this->_errorMsg = @mysql_error($this->_connectionID);
+		return $this->_errorMsg;
+	}
+	
+	/*	Returns: the last error number from previous database operation	*/	
+	function ErrorNo() 
+	{
+		if ($this->_logsql) return $this->_errorCode;
+		if (empty($this->_connectionID))  return @mysql_errno();
+		else return @mysql_errno($this->_connectionID);
+	}
+	
+	// returns true or false
+	function _close()
+	{
+		@mysql_close($this->_connectionID);
+		$this->_connectionID = false;
+	}
+
+	
+	/*
+	* Maximum size of C field
+	*/
+	function CharMax()
+	{
+		return 255; 
+	}
+	
+	/*
+	* Maximum size of X field
+	*/
+	function TextMax()
+	{
+		return 4294967295; 
+	}
+	
+	// "Innox - Juan Carlos Gonzalez" 
+	function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE )
+     {
+	 global $ADODB_FETCH_MODE;
+		if ($ADODB_FETCH_MODE == ADODB_FETCH_ASSOC || $this->fetchMode == ADODB_FETCH_ASSOC) $associative = true;
+
+         if ( !empty($owner) ) {
+            $table = "$owner.$table";
+         }
+         $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
+		 if ($associative) {
+		 	$create_sql = isset($a_create_table["Create Table"]) ? $a_create_table["Create Table"] : $a_create_table["Create View"];
+         } else $create_sql  = $a_create_table[1];
+
+         $matches = array();
+
+         if (!preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches)) return false;
+	     $foreign_keys = array();	 	 
+         $num_keys = count($matches[0]);
+         for ( $i = 0;  $i < $num_keys;  $i ++ ) {
+             $my_field  = explode('`, `', $matches[1][$i]);
+             $ref_table = $matches[2][$i];
+             $ref_field = explode('`, `', $matches[3][$i]);
+
+             if ( $upper ) {
+                 $ref_table = strtoupper($ref_table);
+             }
+
+             $foreign_keys[$ref_table] = array();
+             $num_fields = count($my_field);
+             for ( $j = 0;  $j < $num_fields;  $j ++ ) {
+                 if ( $associative ) {
+                     $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
+                 } else {
+                     $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}";
+                 }
+             }
+         }
+         
+         return  $foreign_keys;
+     }
+	 
+	
+}
+	
+/*--------------------------------------------------------------------------------------
+	 Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+
+class ADORecordSet_mysql extends ADORecordSet{	
+	
+	var $databaseType = "mysql";
+	var $canSeek = true;
+	
+	function ADORecordSet_mysql($queryID,$mode=false) 
+	{
+		if ($mode === false) { 
+			global $ADODB_FETCH_MODE;
+			$mode = $ADODB_FETCH_MODE;
+		}
+		switch ($mode)
+		{
+		case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
+		case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
+		case ADODB_FETCH_DEFAULT:
+		case ADODB_FETCH_BOTH:
+		default:
+			$this->fetchMode = MYSQL_BOTH; break;
+		}
+		$this->adodbFetchMode = $mode;
+		$this->ADORecordSet($queryID);	
+	}
+	
+	function _initrs()
+	{
+	//GLOBAL $ADODB_COUNTRECS;
+	//	$this->_numOfRows = ($ADODB_COUNTRECS) ? @mysql_num_rows($this->_queryID):-1;
+		$this->_numOfRows = @mysql_num_rows($this->_queryID);
+		$this->_numOfFields = @mysql_num_fields($this->_queryID);
+	}
+	
+	function FetchField($fieldOffset = -1) 
+	{	
+		if ($fieldOffset != -1) {
+			$o = @mysql_fetch_field($this->_queryID, $fieldOffset);
+			$f = @mysql_field_flags($this->_queryID,$fieldOffset);
+			if ($o) $o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich#att.com)
+			//$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
+			if ($o) $o->binary = (strpos($f,'binary')!== false);
+		}
+		else if ($fieldOffset == -1) {	/*	The $fieldOffset argument is not provided thus its -1 	*/
+			$o = @mysql_fetch_field($this->_queryID);
+			if ($o) $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich#att.com)
+		//$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable
+		}
+			
+		return $o;
+	}
+
+	function GetRowAssoc($upper=true)
+	{
+		if ($this->fetchMode == MYSQL_ASSOC && !$upper) $row = $this->fields;
+		else $row = ADORecordSet::GetRowAssoc($upper);
+		return $row;
+	}
+	
+	/* Use associative array to get fields array */
+	function Fields($colname)
+	{	
+		// added @ by "Michael William Miller" 
+		if ($this->fetchMode != MYSQL_NUM) return @$this->fields[$colname];
+		
+		if (!$this->bind) {
+			$this->bind = array();
+			for ($i=0; $i < $this->_numOfFields; $i++) {
+				$o = $this->FetchField($i);
+				$this->bind[strtoupper($o->name)] = $i;
+			}
+		}
+		 return $this->fields[$this->bind[strtoupper($colname)]];
+	}
+	
+	function _seek($row)
+	{
+		if ($this->_numOfRows == 0) return false;
+		return @mysql_data_seek($this->_queryID,$row);
+	}
+	
+	function MoveNext()
+	{
+		//return adodb_movenext($this);
+		//if (defined('ADODB_EXTENSION')) return adodb_movenext($this);
+		if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) {
+			$this->_currentRow += 1;
+			return true;
+		}
+		if (!$this->EOF) {
+			$this->_currentRow += 1;
+			$this->EOF = true;
+		}
+		return false;
+	}
+	
+	function _fetch()
+	{
+		$this->fields =  @mysql_fetch_array($this->_queryID,$this->fetchMode);
+		return is_array($this->fields);
+	}
+	
+	function _close() {
+		@mysql_free_result($this->_queryID);	
+		$this->_queryID = false;	
+	}
+	
+	function MetaType($t,$len=-1,$fieldobj=false)
+	{
+		if (is_object($t)) {
+			$fieldobj = $t;
+			$t = $fieldobj->type;
+			$len = $fieldobj->max_length;
+		}
+		
+		$len = -1; // mysql max_length is not accurate
+		switch (strtoupper($t)) {
+		case 'STRING': 
+		case 'CHAR':
+		case 'VARCHAR': 
+		case 'TINYBLOB': 
+		case 'TINYTEXT': 
+		case 'ENUM': 
+		case 'SET': 
+			if ($len <= $this->blobSize) return 'C';
+			
+		case 'TEXT':
+		case 'LONGTEXT': 
+		case 'MEDIUMTEXT':
+			return 'X';
+			
+		// php_mysql extension always returns 'blob' even if 'text'
+		// so we have to check whether binary...
+		case 'IMAGE':
+		case 'LONGBLOB': 
+		case 'BLOB':
+		case 'MEDIUMBLOB':
+		case 'BINARY':
+			return !empty($fieldobj->binary) ? 'B' : 'X';
+			
+		case 'YEAR':
+		case 'DATE': return 'D';
+		
+		case 'TIME':
+		case 'DATETIME':
+		case 'TIMESTAMP': return 'T';
+		
+		case 'INT': 
+		case 'INTEGER':
+		case 'BIGINT':
+		case 'TINYINT':
+		case 'MEDIUMINT':
+		case 'SMALLINT': 
+			
+			if (!empty($fieldobj->primary_key)) return 'R';
+			else return 'I';
+		
+		default: return 'N';
+		}
+	}
+
+}
+
+class ADORecordSet_ext_mysql extends ADORecordSet_mysql {	
+	function ADORecordSet_ext_mysql($queryID,$mode=false) 
+	{
+		if ($mode === false) { 
+			global $ADODB_FETCH_MODE;
+			$mode = $ADODB_FETCH_MODE;
+		}
+		switch ($mode)
+		{
+		case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break;
+		case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break;
+		case ADODB_FETCH_DEFAULT:
+		case ADODB_FETCH_BOTH:
+		default:
+		$this->fetchMode = MYSQL_BOTH; break;
+		}
+		$this->adodbFetchMode = $mode;
+		$this->ADORecordSet($queryID);
+	}
+	
+	function MoveNext()
+	{
+		return @adodb_movenext($this);
+	}
+}
+
+
+}
+?>
\ No newline at end of file
diff --git a/includes/adodb/drivers/adodb-mysqli.inc.php b/includes/adodb/drivers/adodb-mysqli.inc.php
new file mode 100644
index 00000000..be3f4e7a
--- /dev/null
+++ b/includes/adodb/drivers/adodb-mysqli.inc.php
@@ -0,0 +1,1184 @@
+_transmode  = $transaction_mode;
+		if (empty($transaction_mode)) {
+			$this->Execute('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ');
+			return;
+		}
+		if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode;
+		$this->Execute("SET SESSION TRANSACTION ".$transaction_mode);
+	}
+
+	// returns true or false
+	// To add: parameter int $port,
+	//         parameter string $socket
+	function _connect($argHostname = NULL, 
+			  $argUsername = NULL, 
+			  $argPassword = NULL, 
+			  $argDatabasename = NULL, $persist=false)
+	  {
+	  	 if(!extension_loaded("mysqli")) {
+			return null;
+		 }
+	    $this->_connectionID = @mysqli_init();
+	    
+	    if (is_null($this->_connectionID)) {
+	      // mysqli_init only fails if insufficient memory
+	      if ($this->debug) 
+				ADOConnection::outp("mysqli_init() failed : "  . $this->ErrorMsg());
+	      return false;
+	    }
+		/*
+		I suggest a simple fix which would enable adodb and mysqli driver to
+		read connection options from the standard mysql configuration file
+		/etc/my.cnf - "Bastien Duclaux" 
+		*/
+		foreach($this->optionFlags as $arr) {	
+			mysqli_options($this->_connectionID,$arr[0],$arr[1]);
+		}
+
+		#if (!empty($this->port)) $argHostname .= ":".$this->port;
+		$ok = mysqli_real_connect($this->_connectionID,
+ 				    $argHostname,
+ 				    $argUsername,
+ 				    $argPassword,
+ 				    $argDatabasename,
+					$this->port,
+					$this->socket,
+					$this->clientFlags);
+ 	     
+		if ($ok) {
+	 		if ($argDatabasename)  return $this->SelectDB($argDatabasename);
+ 			return true;
+ 	   } else {
+			if ($this->debug) 
+		  		ADOConnection::outp("Could't connect : "  . $this->ErrorMsg());
+			$this->_connectionID = null;
+			return false;
+	   }
+	}
+	
+	// returns true or false
+	// How to force a persistent connection
+	function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+	{
+		return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, true);
+
+	}
+	
+	// When is this used? Close old connection first?
+	// In _connect(), check $this->forceNewConnect? 
+	function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename)
+	  {
+	    $this->forceNewConnect = true;
+	    return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename);
+	  }
+	
+	function IfNull( $field, $ifNull ) 
+	{
+		return " IFNULL($field, $ifNull) "; // if MySQL
+	}
+	
+	// do not use $ADODB_COUNTRECS
+	function GetOne($sql,$inputarr=false)
+	{
+		$ret = false;
+		$rs = $this->Execute($sql,$inputarr);
+		if ($rs) {	
+			if (!$rs->EOF) $ret = reset($rs->fields);
+			$rs->Close();
+		}
+		return $ret;
+	}
+	
+	function ServerInfo()
+	{
+		$arr['description'] = $this->GetOne("select version()");
+		$arr['version'] = ADOConnection::_findvers($arr['description']);
+		return $arr;
+	}
+	
+	
+	function BeginTrans()
+	{	  
+		if ($this->transOff) return true;
+		$this->transCnt += 1;
+		
+		//$this->Execute('SET AUTOCOMMIT=0');
+		mysqli_autocommit($this->_connectionID, false);
+		$this->Execute('BEGIN');
+		return true;
+	}
+	
+	function CommitTrans($ok=true) 
+	{
+		if ($this->transOff) return true; 
+		if (!$ok) return $this->RollbackTrans();
+		
+		if ($this->transCnt) $this->transCnt -= 1;
+		$this->Execute('COMMIT');
+		
+		//$this->Execute('SET AUTOCOMMIT=1');
+		mysqli_autocommit($this->_connectionID, true);
+		return true;
+	}
+	
+	function RollbackTrans()
+	{
+		if ($this->transOff) return true;
+		if ($this->transCnt) $this->transCnt -= 1;
+		$this->Execute('ROLLBACK');
+		//$this->Execute('SET AUTOCOMMIT=1');
+		mysqli_autocommit($this->_connectionID, true);
+		return true;
+	}
+	
+	function RowLock($tables,$where='',$flds='1 as adodb_ignore') 
+	{
+		if ($this->transCnt==0) $this->BeginTrans();
+		if ($where) $where = ' where '.$where;
+		$rs = $this->Execute("select $flds from $tables $where for update");
+		return !empty($rs); 
+	}
+	
+	// if magic quotes disabled, use mysql_real_escape_string()
+	// From readme.htm:
+	// Quotes a string to be sent to the database. The $magic_quotes_enabled
+	// parameter may look funny, but the idea is if you are quoting a 
+	// string extracted from a POST/GET variable, then 
+	// pass get_magic_quotes_gpc() as the second parameter. This will 
+	// ensure that the variable is not quoted twice, once by qstr and once 
+	// by the magic_quotes_gpc.
+	//
+	//Eg. $s = $db->qstr(_GET['name'],get_magic_quotes_gpc());
+	function qstr($s, $magic_quotes = false)
+	{
+		if (is_null($s)) return 'NULL';
+		if (!$magic_quotes) {
+	    	if (PHP_VERSION >= 5)
+	      		return "'" . mysqli_real_escape_string($this->_connectionID, $s) . "'";   
+	    
+		if ($this->replaceQuote[0] == '\\')
+			$s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s);
+	    return  "'".str_replace("'",$this->replaceQuote,$s)."'"; 
+	  }
+	  // undo magic quotes for "
+	  $s = str_replace('\\"','"',$s);
+	  return "'$s'";
+	}
+	
+	function _insertid()
+	{
+	  $result = @mysqli_insert_id($this->_connectionID);
+	  if ($result == -1){
+	      if ($this->debug) ADOConnection::outp("mysqli_insert_id() failed : "  . $this->ErrorMsg());
+	  }
+	  return $result;
+	}
+	
+	// Only works for INSERT, UPDATE and DELETE query's
+	function _affectedrows()
+	{
+	  $result =  @mysqli_affected_rows($this->_connectionID);
+	  if ($result == -1) {
+	      if ($this->debug) ADOConnection::outp("mysqli_affected_rows() failed : "  . $this->ErrorMsg());
+	  }
+	  return $result;
+	}
+  
+ 	// See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
+	// Reference on Last_Insert_ID on the recommended way to simulate sequences
+ 	var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);";
+	var $_genSeqSQL = "create table %s (id int not null)";
+	var $_genSeqCountSQL = "select count(*) from %s";
+	var $_genSeq2SQL = "insert into %s values (%s)";
+	var $_dropSeqSQL = "drop table %s";
+	
+	function CreateSequence($seqname='adodbseq',$startID=1)
+	{
+		if (empty($this->_genSeqSQL)) return false;
+		$u = strtoupper($seqname);
+		
+		$ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname));
+		if (!$ok) return false;
+		return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
+	}
+	
+	function GenID($seqname='adodbseq',$startID=1)
+	{
+		// post-nuke sets hasGenID to false
+		if (!$this->hasGenID) return false;
+		
+		$getnext = sprintf($this->_genIDSQL,$seqname);
+		$holdtransOK = $this->_transOK; // save the current status
+		$rs = @$this->Execute($getnext);
+		if (!$rs) {
+			if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset
+			$u = strtoupper($seqname);
+			$this->Execute(sprintf($this->_genSeqSQL,$seqname));
+			$cnt = $this->GetOne(sprintf($this->_genSeqCountSQL,$seqname));
+			if (!$cnt) $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1));
+			$rs = $this->Execute($getnext);
+		}
+		
+		if ($rs) {
+			$this->genID = mysqli_insert_id($this->_connectionID);
+			$rs->Close();
+		} else
+			$this->genID = 0;
+			
+		return $this->genID;
+	}
+	
+  	function MetaDatabases()
+	{
+		$query = "SHOW DATABASES";
+		$ret = $this->Execute($query);
+		if ($ret && is_object($ret)){
+		   $arr = array();
+			while (!$ret->EOF){
+				$db = $ret->Fields('Database');
+				if ($db != 'mysql') $arr[] = $db;
+				$ret->MoveNext();
+			}
+   		   return $arr;
+		}
+        return $ret;
+	}
+
+	  
+	function MetaIndexes ($table, $primary = FALSE)
+	{
+		// save old fetch mode
+		global $ADODB_FETCH_MODE;
+		
+		$false = false;
+		$save = $ADODB_FETCH_MODE;
+		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+		if ($this->fetchMode !== FALSE) {
+		       $savem = $this->SetFetchMode(FALSE);
+		}
+		
+		// get index details
+		$rs = $this->Execute(sprintf('SHOW INDEXES FROM %s',$table));
+		
+		// restore fetchmode
+		if (isset($savem)) {
+		        $this->SetFetchMode($savem);
+		}
+		$ADODB_FETCH_MODE = $save;
+		
+		if (!is_object($rs)) {
+		        return $false;
+		}
+		
+		$indexes = array ();
+		
+		// parse index data into array
+		while ($row = $rs->FetchRow()) {
+		        if ($primary == FALSE AND $row[2] == 'PRIMARY') {
+		                continue;
+		        }
+		        
+		        if (!isset($indexes[$row[2]])) {
+		                $indexes[$row[2]] = array(
+		                        'unique' => ($row[1] == 0),
+		                        'columns' => array()
+		                );
+		        }
+		        
+		        $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4];
+		}
+		
+		// sort columns by order in the index
+		foreach ( array_keys ($indexes) as $index )
+		{
+		        ksort ($indexes[$index]['columns']);
+		}
+		
+		return $indexes;
+	}
+
+	
+	// Format date column in sql string given an input format that understands Y M D
+	function SQLDate($fmt, $col=false)
+	{	
+		if (!$col) $col = $this->sysTimeStamp;
+		$s = 'DATE_FORMAT('.$col.",'";
+		$concat = false;
+		$len = strlen($fmt);
+		for ($i=0; $i < $len; $i++) {
+			$ch = $fmt[$i];
+			switch($ch) {
+			case 'Y':
+			case 'y':
+				$s .= '%Y';
+				break;
+			case 'Q':
+			case 'q':
+				$s .= "'),Quarter($col)";
+				
+				if ($len > $i+1) $s .= ",DATE_FORMAT($col,'";
+				else $s .= ",('";
+				$concat = true;
+				break;
+			case 'M':
+				$s .= '%b';
+				break;
+				
+			case 'm':
+				$s .= '%m';
+				break;
+			case 'D':
+			case 'd':
+				$s .= '%d';
+				break;
+			
+			case 'H': 
+				$s .= '%H';
+				break;
+				
+			case 'h':
+				$s .= '%I';
+				break;
+				
+			case 'i':
+				$s .= '%i';
+				break;
+				
+			case 's':
+				$s .= '%s';
+				break;
+				
+			case 'a':
+			case 'A':
+				$s .= '%p';
+				break;
+			
+			case 'w':
+				$s .= '%w';
+				break;
+				
+			case 'l':
+				$s .= '%W';
+				break;
+				
+			default:
+				
+				if ($ch == '\\') {
+					$i++;
+					$ch = substr($fmt,$i,1);
+				}
+				$s .= $ch;
+				break;
+			}
+		}
+		$s.="')";
+		if ($concat) $s = "CONCAT($s)";
+		return $s;
+	}
+	
+	// returns concatenated string
+	// much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator
+	function Concat()
+	{
+		$s = "";
+		$arr = func_get_args();
+		
+		// suggestion by andrew005@mnogo.ru
+		$s = implode(',',$arr); 
+		if (strlen($s) > 0) return "CONCAT($s)";
+		else return '';
+	}
+	
+	// dayFraction is a day in floating point
+	function OffsetDate($dayFraction,$date=false)
+	{		
+		if (!$date) $date = $this->sysDate;
+		
+		$fraction = $dayFraction * 24 * 3600;
+		return $date . ' + INTERVAL ' .	 $fraction.' SECOND';
+		
+//		return "from_unixtime(unix_timestamp($date)+$fraction)";
+	}
+	
+	function MetaTables($ttype=false,$showSchema=false,$mask=false) 
+	{	
+		$save = $this->metaTablesSQL;
+		if ($showSchema && is_string($showSchema)) {
+			$this->metaTablesSQL .= " from $showSchema";
+		}
+		
+		if ($mask) {
+			$mask = $this->qstr($mask);
+			$this->metaTablesSQL .= " like $mask";
+		}
+		$ret = ADOConnection::MetaTables($ttype,$showSchema);
+		
+		$this->metaTablesSQL = $save;
+		return $ret;
+	}
+	
+	// "Innox - Juan Carlos Gonzalez" 
+	function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE )
+	{
+	 global $ADODB_FETCH_MODE;
+		
+		if ($ADODB_FETCH_MODE == ADODB_FETCH_ASSOC || $this->fetchMode == ADODB_FETCH_ASSOC) $associative = true;
+		
+	    if ( !empty($owner) ) {
+	       $table = "$owner.$table";
+	    }
+	    $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table));
+		if ($associative) {
+			$create_sql = isset($a_create_table["Create Table"]) ? $a_create_table["Create Table"] : $a_create_table["Create View"];
+	    } else $create_sql  = $a_create_table[1];
+	
+	    $matches = array();
+	
+	    if (!preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches)) return false;
+	 	$foreign_keys = array();	 	 
+	    $num_keys = count($matches[0]);
+	    for ( $i = 0;  $i < $num_keys;  $i ++ ) {
+	        $my_field  = explode('`, `', $matches[1][$i]);
+	        $ref_table = $matches[2][$i];
+	        $ref_field = explode('`, `', $matches[3][$i]);
+	
+	        if ( $upper ) {
+	            $ref_table = strtoupper($ref_table);
+	        }
+	
+	        $foreign_keys[$ref_table] = array();
+	        $num_fields               = count($my_field);
+	        for ( $j = 0;  $j < $num_fields;  $j ++ ) {
+	            if ( $associative ) {
+	                $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j];
+	            } else {
+	                $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}";
+	            }
+	        }
+	    }
+	    
+	    return  $foreign_keys;
+	}
+	
+ 	function MetaColumns($table) 
+	{
+		$false = false;
+		if (!$this->metaColumnsSQL)
+			return $false;
+		
+		global $ADODB_FETCH_MODE;
+		$save = $ADODB_FETCH_MODE;
+		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
+		if ($this->fetchMode !== false)
+			$savem = $this->SetFetchMode(false);
+		$rs = $this->Execute(sprintf($this->metaColumnsSQL,$table));
+		if (isset($savem)) $this->SetFetchMode($savem);
+		$ADODB_FETCH_MODE = $save;
+		if (!is_object($rs))
+			return $false;
+		
+		$retarr = array();
+		while (!$rs->EOF) {
+			$fld = new ADOFieldObject();
+			$fld->name = $rs->fields[0];
+			$type = $rs->fields[1];
+			
+			// split type into type(length):
+			$fld->scale = null;
+			if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) {
+				$fld->type = $query_array[1];
+				$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+				$fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1;
+			} elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) {
+				$fld->type = $query_array[1];
+				$fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1;
+			} elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) {
+				$fld->type = $query_array[1];
+				$arr = explode(",",$query_array[2]);
+				$fld->enums = $arr;
+				$zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6
+				$fld->max_length = ($zlen > 0) ? $zlen : 1;
+			} else {
+				$fld->type = $type;
+				$fld->max_length = -1;
+			}
+			$fld->not_null = ($rs->fields[2] != 'YES');
+			$fld->primary_key = ($rs->fields[3] == 'PRI');
+			$fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false);
+			$fld->binary = (strpos($type,'blob') !== false);
+			$fld->unsigned = (strpos($type,'unsigned') !== false);
+			$fld->zerofill = (strpos($type,'zerofill') !== false);
+
+			if (!$fld->binary) {
+				$d = $rs->fields[4];
+				if ($d != '' && $d != 'NULL') {
+					$fld->has_default = true;
+					$fld->default_value = $d;
+				} else {
+					$fld->has_default = false;
+				}
+			}
+			
+			if ($save == ADODB_FETCH_NUM) {
+				$retarr[] = $fld;
+			} else {
+				$retarr[strtoupper($fld->name)] = $fld;
+			}
+			$rs->MoveNext();
+		}
+		
+		$rs->Close();
+		return $retarr;
+	}
+		
+	// returns true or false
+	function SelectDB($dbName) 
+	{
+//	    $this->_connectionID = $this->mysqli_resolve_link($this->_connectionID);
+	    $this->database = $dbName;
+		$this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions
+		
+	    if ($this->_connectionID) {
+        	$result = @mysqli_select_db($this->_connectionID, $dbName);
+			if (!$result) {
+		    	ADOConnection::outp("Select of database " . $dbName . " failed. " . $this->ErrorMsg());
+			}
+			return $result;		
+		}
+	    return false;	
+	}
+	
+	// parameters use PostgreSQL convention, not MySQL
+	function SelectLimit($sql,
+			      $nrows = -1,
+			      $offset = -1,
+			      $inputarr = false, 
+			      $secs = 0)
+	{
+		$offsetStr = ($offset >= 0) ? "$offset," : '';
+		if ($nrows < 0) $nrows = '18446744073709551615';
+		
+		if ($secs)
+			$rs = $this->CacheExecute($secs, $sql . " LIMIT $offsetStr$nrows" , $inputarr );
+		else
+			$rs = $this->Execute($sql . " LIMIT $offsetStr$nrows" , $inputarr );
+			
+		return $rs;
+	}
+	
+	
+	function Prepare($sql)
+	{
+		return $sql;
+		$stmt = $this->_connectionID->prepare($sql);
+		if (!$stmt) {
+			echo $this->ErrorMsg();
+			return $sql;
+		}
+		return array($sql,$stmt);
+	}
+	
+	
+	// returns queryID or false
+	function _query($sql, $inputarr)
+	{
+	global $ADODB_COUNTRECS;
+		// Move to the next recordset, or return false if there is none. In a stored proc
+		// call, mysqli_next_result returns true for the last "recordset", but mysqli_store_result
+		// returns false. I think this is because the last "recordset" is actually just the
+		// return value of the stored proc (ie the number of rows affected).
+		// Commented out for reasons of performance. You should retrieve every recordset yourself.
+		//	if (!mysqli_next_result($this->connection->_connectionID))	return false;
+	
+		if (is_array($sql)) {
+		
+			// Prepare() not supported because mysqli_stmt_execute does not return a recordset, but
+			// returns as bound variables.
+		
+			$stmt = $sql[1];
+			$a = '';
+			foreach($inputarr as $k => $v) {
+				if (is_string($v)) $a .= 's';
+				else if (is_integer($v)) $a .= 'i'; 
+				else $a .= 'd';
+			}
+			
+			$fnarr = array_merge( array($stmt,$a) , $inputarr);
+			$ret = call_user_func_array('mysqli_stmt_bind_param',$fnarr);
+			$ret = mysqli_stmt_execute($stmt);
+			return $ret;
+		}
+		
+		/*
+		if (!$mysql_res =  mysqli_query($this->_connectionID, $sql, ($ADODB_COUNTRECS) ? MYSQLI_STORE_RESULT : MYSQLI_USE_RESULT)) {
+		    if ($this->debug) ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg());
+		    return false;
+		}
+		
+		return $mysql_res;
+		*/
+		
+		if( $rs = mysqli_multi_query($this->_connectionID, $sql.';') )//Contributed by "Geisel Sierote" 
+		{
+			$rs = ($ADODB_COUNTRECS) ? @mysqli_store_result( $this->_connectionID ) : @mysqli_use_result( $this->_connectionID );
+			return $rs ? $rs : true; // mysqli_more_results( $this->_connectionID )
+		} else {
+			if($this->debug)
+			ADOConnection::outp("Query: " . $sql . " failed. " . $this->ErrorMsg());
+			return false;
+		}
+	}
+
+	/*	Returns: the last error message from previous database operation	*/	
+	function ErrorMsg() 
+	  {
+	    if (empty($this->_connectionID)) 
+	      $this->_errorMsg = @mysqli_connect_error();
+	    else 
+	      $this->_errorMsg = @mysqli_error($this->_connectionID);
+	    return $this->_errorMsg;
+	  }
+	
+	/*	Returns: the last error number from previous database operation	*/	
+	function ErrorNo() 
+	  {
+	    if (empty($this->_connectionID))  
+	      return @mysqli_connect_errno();
+	    else 
+	      return @mysqli_errno($this->_connectionID);
+	  }
+	
+	// returns true or false
+	function _close()
+	  {
+	    @mysqli_close($this->_connectionID);
+	    $this->_connectionID = false;
+	  }
+
+	/*
+	* Maximum size of C field
+	*/
+	function CharMax()
+	{
+		return 255; 
+	}
+	
+	/*
+	* Maximum size of X field
+	*/
+	function TextMax()
+	{
+	  return 4294967295; 
+	}
+
+
+
+	// this is a set of functions for managing client encoding - very important if the encodings
+	// of your database and your output target (i.e. HTML) don't match
+	// for instance, you may have UTF8 database and server it on-site as latin1 etc.
+	// GetCharSet - get the name of the character set the client is using now
+	// Under Windows, the functions should work with MySQL 4.1.11 and above, the set of charsets supported
+	// depends on compile flags of mysql distribution 
+
+  function GetCharSet()
+  {
+    //we will use ADO's builtin property charSet
+    if (!method_exists($this->_connectionID,'character_set_name'))
+    	return false;
+    	
+    $this->charSet = @$this->_connectionID->character_set_name();
+    if (!$this->charSet) {
+      return false;
+    } else {
+      return $this->charSet;
+    }
+  }
+
+  // SetCharSet - switch the client encoding
+  function SetCharSet($charset_name)
+  {
+    if (!method_exists($this->_connectionID,'set_charset'))
+    	return false;
+
+    if ($this->charSet !== $charset_name) {
+      $if = @$this->_connectionID->set_charset($charset_name);
+      if ($if == "0" & $this->GetCharSet() == $charset_name) {
+        return true;
+      } else return false;
+    } else return true;
+  }
+
+
+
+
+}
+ 
+/*--------------------------------------------------------------------------------------
+	 Class Name: Recordset
+--------------------------------------------------------------------------------------*/
+
+class ADORecordSet_mysqli extends ADORecordSet{	
+	
+	var $databaseType = "mysqli";
+	var $canSeek = true;
+	
+	function ADORecordSet_mysqli($queryID, $mode = false) 
+	{
+	  if ($mode === false) 
+	   { 
+	      global $ADODB_FETCH_MODE;
+	      $mode = $ADODB_FETCH_MODE;
+	   }
+	   
+	  switch ($mode)
+	    {
+	    case ADODB_FETCH_NUM: 
+	      $this->fetchMode = MYSQLI_NUM; 
+	      break;
+	    case ADODB_FETCH_ASSOC:
+	      $this->fetchMode = MYSQLI_ASSOC; 
+	      break;
+	    case ADODB_FETCH_DEFAULT:
+	    case ADODB_FETCH_BOTH:
+	    default:
+	      $this->fetchMode = MYSQLI_BOTH; 
+	      break;
+	    }
+	  $this->adodbFetchMode = $mode;
+	  $this->ADORecordSet($queryID);	
+	}
+	
+	function _initrs()
+	{
+	global $ADODB_COUNTRECS;
+	
+		$this->_numOfRows = $ADODB_COUNTRECS ? @mysqli_num_rows($this->_queryID) : -1;
+		$this->_numOfFields = @mysqli_num_fields($this->_queryID);
+	}
+	
+/*
+1      = MYSQLI_NOT_NULL_FLAG
+2      = MYSQLI_PRI_KEY_FLAG
+4      = MYSQLI_UNIQUE_KEY_FLAG
+8      = MYSQLI_MULTIPLE_KEY_FLAG
+16     = MYSQLI_BLOB_FLAG
+32     = MYSQLI_UNSIGNED_FLAG
+64     = MYSQLI_ZEROFILL_FLAG
+128    = MYSQLI_BINARY_FLAG
+256    = MYSQLI_ENUM_FLAG
+512    = MYSQLI_AUTO_INCREMENT_FLAG
+1024   = MYSQLI_TIMESTAMP_FLAG
+2048   = MYSQLI_SET_FLAG
+32768  = MYSQLI_NUM_FLAG
+16384  = MYSQLI_PART_KEY_FLAG
+32768  = MYSQLI_GROUP_FLAG
+65536  = MYSQLI_UNIQUE_FLAG
+131072 = MYSQLI_BINCMP_FLAG
+*/
+
+	function FetchField($fieldOffset = -1) 
+	{	
+		$fieldnr = $fieldOffset;
+		if ($fieldOffset != -1) {
+		  $fieldOffset = @mysqli_field_seek($this->_queryID, $fieldnr);
+		}
+		$o = @mysqli_fetch_field($this->_queryID);
+		if (!$o) return false;
+		/* Properties of an ADOFieldObject as set by MetaColumns */
+		$o->primary_key = $o->flags & MYSQLI_PRI_KEY_FLAG;
+		$o->not_null = $o->flags & MYSQLI_NOT_NULL_FLAG;
+		$o->auto_increment = $o->flags & MYSQLI_AUTO_INCREMENT_FLAG;
+		$o->binary = $o->flags & MYSQLI_BINARY_FLAG;
+		// $o->blob = $o->flags & MYSQLI_BLOB_FLAG; /* not returned by MetaColumns */
+		$o->unsigned = $o->flags & MYSQLI_UNSIGNED_FLAG;
+
+		return $o;
+	}
+
+	function GetRowAssoc($upper = true)
+	{
+		if ($this->fetchMode == MYSQLI_ASSOC && !$upper) 
+		  return $this->fields;
+		$row = ADORecordSet::GetRowAssoc($upper);
+		return $row;
+	}
+	
+	/* Use associative array to get fields array */
+	function Fields($colname)
+	{	
+	  if ($this->fetchMode != MYSQLI_NUM) 
+	    return @$this->fields[$colname];
+		
+	  if (!$this->bind) {
+	    $this->bind = array();
+	    for ($i = 0; $i < $this->_numOfFields; $i++) {
+	      $o = $this->FetchField($i);
+	      $this->bind[strtoupper($o->name)] = $i;
+	    }
+	  }
+	  return $this->fields[$this->bind[strtoupper($colname)]];
+	}
+	
+	function _seek($row)
+	{
+	  if ($this->_numOfRows == 0) 
+	    return false;
+
+	  if ($row < 0)
+	    return false;
+
+	  mysqli_data_seek($this->_queryID, $row);
+	  $this->EOF = false;
+	  return true;
+	}
+		
+		
+	function NextRecordSet()
+	{
+	global $ADODB_COUNTRECS;
+	
+		mysqli_free_result($this->_queryID);
+		$this->_queryID = -1;
+		// Move to the next recordset, or return false if there is none. In a stored proc
+		// call, mysqli_next_result returns true for the last "recordset", but mysqli_store_result
+		// returns false. I think this is because the last "recordset" is actually just the
+		// return value of the stored proc (ie the number of rows affected).
+		if(!mysqli_next_result($this->connection->_connectionID)) {
+		return false;
+		}
+		// CD: There is no $this->_connectionID variable, at least in the ADO version I'm using
+		$this->_queryID = ($ADODB_COUNTRECS) ? @mysqli_store_result( $this->connection->_connectionID )
+						: @mysqli_use_result( $this->connection->_connectionID );
+		if(!$this->_queryID) {
+			return false;
+		}
+		$this->_inited = false;
+		$this->bind = false;
+		$this->_currentRow = -1;
+		$this->Init();
+		return true;
+	}
+
+	// 10% speedup to move MoveNext to child class
+	// This is the only implementation that works now (23-10-2003).
+	// Other functions return no or the wrong results.
+	function MoveNext() 
+	{
+		if ($this->EOF) return false;
+		$this->_currentRow++;
+		$this->fields = @mysqli_fetch_array($this->_queryID,$this->fetchMode);
+		
+		if (is_array($this->fields)) return true;
+		$this->EOF = true;
+		return false;
+	}	
+	
+	function _fetch()
+	{
+		$this->fields = mysqli_fetch_array($this->_queryID,$this->fetchMode);  
+	  	return is_array($this->fields);
+	}
+	
+	function _close() 
+	{
+		mysqli_free_result($this->_queryID); 
+	  	$this->_queryID = false;	
+	}
+	
+/*
+
+0 = MYSQLI_TYPE_DECIMAL
+1 = MYSQLI_TYPE_CHAR
+1 = MYSQLI_TYPE_TINY
+2 = MYSQLI_TYPE_SHORT
+3 = MYSQLI_TYPE_LONG
+4 = MYSQLI_TYPE_FLOAT
+5 = MYSQLI_TYPE_DOUBLE
+6 = MYSQLI_TYPE_NULL
+7 = MYSQLI_TYPE_TIMESTAMP
+8 = MYSQLI_TYPE_LONGLONG
+9 = MYSQLI_TYPE_INT24
+10 = MYSQLI_TYPE_DATE
+11 = MYSQLI_TYPE_TIME
+12 = MYSQLI_TYPE_DATETIME
+13 = MYSQLI_TYPE_YEAR
+14 = MYSQLI_TYPE_NEWDATE
+247 = MYSQLI_TYPE_ENUM
+248 = MYSQLI_TYPE_SET
+249 = MYSQLI_TYPE_TINY_BLOB
+250 = MYSQLI_TYPE_MEDIUM_BLOB
+251 = MYSQLI_TYPE_LONG_BLOB
+252 = MYSQLI_TYPE_BLOB
+253 = MYSQLI_TYPE_VAR_STRING
+254 = MYSQLI_TYPE_STRING
+255 = MYSQLI_TYPE_GEOMETRY
+*/
+
+	function MetaType($t, $len = -1, $fieldobj = false)
+	{
+		if (is_object($t)) {
+		    $fieldobj = $t;
+		    $t = $fieldobj->type;
+		    $len = $fieldobj->max_length;
+		}
+		
+		
+		 $len = -1; // mysql max_length is not accurate
+		 switch (strtoupper($t)) {
+		 case 'STRING': 
+		 case 'CHAR':
+		 case 'VARCHAR': 
+		 case 'TINYBLOB': 
+		 case 'TINYTEXT': 
+		 case 'ENUM': 
+		 case 'SET': 
+		
+		case MYSQLI_TYPE_TINY_BLOB :
+		#case MYSQLI_TYPE_CHAR :
+		case MYSQLI_TYPE_STRING :
+		case MYSQLI_TYPE_ENUM :
+		case MYSQLI_TYPE_SET :
+		case 253 :
+		   if ($len <= $this->blobSize) return 'C';
+		   
+		case 'TEXT':
+		case 'LONGTEXT': 
+		case 'MEDIUMTEXT':
+		   return 'X';
+		
+		
+		   // php_mysql extension always returns 'blob' even if 'text'
+		   // so we have to check whether binary...
+		case 'IMAGE':
+		case 'LONGBLOB': 
+		case 'BLOB':
+		case 'MEDIUMBLOB':
+		
+		case MYSQLI_TYPE_BLOB :
+		case MYSQLI_TYPE_LONG_BLOB :
+		case MYSQLI_TYPE_MEDIUM_BLOB :
+		
+		   return !empty($fieldobj->binary) ? 'B' : 'X';
+		case 'YEAR':
+		case 'DATE': 
+		case MYSQLI_TYPE_DATE :
+		case MYSQLI_TYPE_YEAR :
+		
+		   return 'D';
+		
+		case 'TIME':
+		case 'DATETIME':
+		case 'TIMESTAMP':
+		
+		case MYSQLI_TYPE_DATETIME :
+		case MYSQLI_TYPE_NEWDATE :
+		case MYSQLI_TYPE_TIME :
+		case MYSQLI_TYPE_TIMESTAMP :
+		
+			return 'T';
+		
+		case 'INT': 
+		case 'INTEGER':
+		case 'BIGINT':
+		case 'TINYINT':
+		case 'MEDIUMINT':
+		case 'SMALLINT': 
+		
+		case MYSQLI_TYPE_INT24 :
+		case MYSQLI_TYPE_LONG :
+		case MYSQLI_TYPE_LONGLONG :
+		case MYSQLI_TYPE_SHORT :
+		case MYSQLI_TYPE_TINY :
+		
+		   if (!empty($fieldobj->primary_key)) return 'R';
+		   
+		   return 'I';
+		
+		
+		   // Added floating-point types
+		   // Maybe not necessery.
+		 case 'FLOAT':
+		 case 'DOUBLE':
+		   //		case 'DOUBLE PRECISION':
+		 case 'DECIMAL':
+		 case 'DEC':
+		 case 'FIXED':
+		 default:
+		 	//if (!is_numeric($t)) echo "

--- Error in type matching $t -----

"; + return 'N'; + } + } // function + + +} // rs class + +} + +class ADORecordSet_array_mysqli extends ADORecordSet_array { + + function ADORecordSet_array_mysqli($id=-1,$mode=false) + { + $this->ADORecordSet_array($id,$mode); + } + + function MetaType($t, $len = -1, $fieldobj = false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + + + $len = -1; // mysql max_length is not accurate + switch (strtoupper($t)) { + case 'STRING': + case 'CHAR': + case 'VARCHAR': + case 'TINYBLOB': + case 'TINYTEXT': + case 'ENUM': + case 'SET': + + case MYSQLI_TYPE_TINY_BLOB : + #case MYSQLI_TYPE_CHAR : + case MYSQLI_TYPE_STRING : + case MYSQLI_TYPE_ENUM : + case MYSQLI_TYPE_SET : + case 253 : + if ($len <= $this->blobSize) return 'C'; + + case 'TEXT': + case 'LONGTEXT': + case 'MEDIUMTEXT': + return 'X'; + + + // php_mysql extension always returns 'blob' even if 'text' + // so we have to check whether binary... + case 'IMAGE': + case 'LONGBLOB': + case 'BLOB': + case 'MEDIUMBLOB': + + case MYSQLI_TYPE_BLOB : + case MYSQLI_TYPE_LONG_BLOB : + case MYSQLI_TYPE_MEDIUM_BLOB : + + return !empty($fieldobj->binary) ? 'B' : 'X'; + case 'YEAR': + case 'DATE': + case MYSQLI_TYPE_DATE : + case MYSQLI_TYPE_YEAR : + + return 'D'; + + case 'TIME': + case 'DATETIME': + case 'TIMESTAMP': + + case MYSQLI_TYPE_DATETIME : + case MYSQLI_TYPE_NEWDATE : + case MYSQLI_TYPE_TIME : + case MYSQLI_TYPE_TIMESTAMP : + + return 'T'; + + case 'INT': + case 'INTEGER': + case 'BIGINT': + case 'TINYINT': + case 'MEDIUMINT': + case 'SMALLINT': + + case MYSQLI_TYPE_INT24 : + case MYSQLI_TYPE_LONG : + case MYSQLI_TYPE_LONGLONG : + case MYSQLI_TYPE_SHORT : + case MYSQLI_TYPE_TINY : + + if (!empty($fieldobj->primary_key)) return 'R'; + + return 'I'; + + + // Added floating-point types + // Maybe not necessery. + case 'FLOAT': + case 'DOUBLE': + // case 'DOUBLE PRECISION': + case 'DECIMAL': + case 'DEC': + case 'FIXED': + default: + //if (!is_numeric($t)) echo "

--- Error in type matching $t -----

"; + return 'N'; + } + } // function + +} + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-mysqlpo.inc.php b/includes/adodb/drivers/adodb-mysqlpo.inc.php new file mode 100644 index 00000000..3e0acbcf --- /dev/null +++ b/includes/adodb/drivers/adodb-mysqlpo.inc.php @@ -0,0 +1,138 @@ + + + Requires mysql client. Works on Windows and Unix. +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php"); + + +class ADODB_mysqlt extends ADODB_mysql { + var $databaseType = 'mysqlt'; + var $ansiOuter = true; // for Version 3.23.17 or later + var $hasTransactions = true; + var $autoRollback = true; // apparently mysql does not autorollback properly + + function ADODB_mysqlt() + { + global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_'; + } + + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + $this->Execute('SET AUTOCOMMIT=0'); + $this->Execute('BEGIN'); + return true; + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + + if ($this->transCnt) $this->transCnt -= 1; + $this->Execute('COMMIT'); + $this->Execute('SET AUTOCOMMIT=1'); + return true; + } + + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $this->Execute('ROLLBACK'); + $this->Execute('SET AUTOCOMMIT=1'); + return true; + } + + function RowLock($tables,$where='',$flds='1 as adodb_ignore') + { + if ($this->transCnt==0) $this->BeginTrans(); + if ($where) $where = ' where '.$where; + $rs = $this->Execute("select $flds from $tables $where for update"); + return !empty($rs); + } + +} + +class ADORecordSet_mysqlt extends ADORecordSet_mysql{ + var $databaseType = "mysqlt"; + + function ADORecordSet_mysqlt($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + + switch ($mode) + { + case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; + case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; + + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: $this->fetchMode = MYSQL_BOTH; break; + } + + $this->adodbFetchMode = $mode; + $this->ADORecordSet($queryID); + } + + function MoveNext() + { + if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) { + $this->_currentRow += 1; + return true; + } + if (!$this->EOF) { + $this->_currentRow += 1; + $this->EOF = true; + } + return false; + } +} + +class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt { + + function ADORecordSet_ext_mysqlt($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; + case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; + + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: + $this->fetchMode = MYSQL_BOTH; break; + } + $this->adodbFetchMode = $mode; + $this->ADORecordSet($queryID); + } + + function MoveNext() + { + return adodb_movenext($this); + } +} + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-mysqlt.inc.php b/includes/adodb/drivers/adodb-mysqlt.inc.php new file mode 100644 index 00000000..3cc809c5 --- /dev/null +++ b/includes/adodb/drivers/adodb-mysqlt.inc.php @@ -0,0 +1,155 @@ + + + Requires mysql client. Works on Windows and Unix. +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +include_once(ADODB_DIR."/drivers/adodb-mysql.inc.php"); + + +class ADODB_mysqlt extends ADODB_mysql { + var $databaseType = 'mysqlt'; + var $ansiOuter = true; // for Version 3.23.17 or later + var $hasTransactions = true; + var $autoRollback = true; // apparently mysql does not autorollback properly + + function ADODB_mysqlt() + { + global $ADODB_EXTENSION; if ($ADODB_EXTENSION) $this->rsPrefix .= 'ext_'; + } + + /* set transaction mode + + SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL +{ READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE } + + */ + function SetTransactionMode( $transaction_mode ) + { + $this->_transmode = $transaction_mode; + if (empty($transaction_mode)) { + $this->Execute('SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ'); + return; + } + if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; + $this->Execute("SET SESSION TRANSACTION ".$transaction_mode); + } + + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + $this->Execute('SET AUTOCOMMIT=0'); + $this->Execute('BEGIN'); + return true; + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + + if ($this->transCnt) $this->transCnt -= 1; + $this->Execute('COMMIT'); + $this->Execute('SET AUTOCOMMIT=1'); + return true; + } + + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $this->Execute('ROLLBACK'); + $this->Execute('SET AUTOCOMMIT=1'); + return true; + } + + function RowLock($tables,$where='',$flds='1 as adodb_ignore') + { + if ($this->transCnt==0) $this->BeginTrans(); + if ($where) $where = ' where '.$where; + $rs = $this->Execute("select $flds from $tables $where for update"); + return !empty($rs); + } + +} + +class ADORecordSet_mysqlt extends ADORecordSet_mysql{ + var $databaseType = "mysqlt"; + + function ADORecordSet_mysqlt($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + + switch ($mode) + { + case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; + case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; + + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: $this->fetchMode = MYSQL_BOTH; break; + } + + $this->adodbFetchMode = $mode; + $this->ADORecordSet($queryID); + } + + function MoveNext() + { + if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) { + $this->_currentRow += 1; + return true; + } + if (!$this->EOF) { + $this->_currentRow += 1; + $this->EOF = true; + } + return false; + } +} + +class ADORecordSet_ext_mysqlt extends ADORecordSet_mysqlt { + + function ADORecordSet_ext_mysqlt($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; + case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; + + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: + $this->fetchMode = MYSQL_BOTH; break; + } + $this->adodbFetchMode = $mode; + $this->ADORecordSet($queryID); + } + + function MoveNext() + { + return adodb_movenext($this); + } +} + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-netezza.inc.php b/includes/adodb/drivers/adodb-netezza.inc.php new file mode 100644 index 00000000..cde287e1 --- /dev/null +++ b/includes/adodb/drivers/adodb-netezza.inc.php @@ -0,0 +1,170 @@ + 0 ORDER BY attnum"; + var $metaColumnsSQL1 = "SELECT attname, atttype FROM _v_relation_column_def WHERE name = '%s' AND attnum > 0 ORDER BY attnum"; + // netezza doesn't have keys. it does have distributions, so maybe this is + // something that can be pulled from the system tables + var $metaKeySQL = ""; + var $hasAffectedRows = true; + var $hasLimit = true; + var $true = 't'; // string that represents TRUE for a database + var $false = 'f'; // string that represents FALSE for a database + var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database + var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt. + var $ansiOuter = true; + var $autoRollback = true; // apparently pgsql does not autorollback properly before 4.3.4 + // http://bugs.php.net/bug.php?id=25404 + + + function ADODB_netezza() + { + + } + + function MetaColumns($table,$upper=true) + { + + // Changed this function to support Netezza which has no concept of keys + // could posisbly work on other things from the system table later. + + global $ADODB_FETCH_MODE; + + $table = strtolower($table); + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table)); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + if ($rs === false) return false; + + $retarr = array(); + while (!$rs->EOF) { + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + + // since we're returning type and length as one string, + // split them out here. + + if ($first = strstr($rs->fields[1], "(")) { + $fld->max_length = trim($first, "()"); + } else { + $fld->max_length = -1; + } + + if ($first = strpos($rs->fields[1], "(")) { + $fld->type = substr($rs->fields[1], 0, $first); + } else { + $fld->type = $rs->fields[1]; + } + + switch ($fld->type) { + case "byteint": + case "boolean": + $fld->max_length = 1; + break; + case "smallint": + $fld->max_length = 2; + break; + case "integer": + case "numeric": + case "date": + $fld->max_length = 4; + break; + case "bigint": + case "time": + case "timestamp": + $fld->max_length = 8; + break; + case "timetz": + case "time with time zone": + $fld->max_length = 12; + break; + } + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + else $retarr[($upper) ? strtoupper($fld->name) : $fld->name] = $fld; + + $rs->MoveNext(); + } + $rs->Close(); + return $retarr; + + } + + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordSet_netezza extends ADORecordSet_postgres64 +{ + var $databaseType = "netezza"; + var $canSeek = true; + + function ADORecordSet_netezza($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break; + case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break; + + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: $this->fetchMode = PGSQL_BOTH; break; + } + $this->adodbFetchMode = $mode; + $this->ADORecordSet($queryID); + } + + // _initrs modified to disable blob handling + function _initrs() + { + global $ADODB_COUNTRECS; + $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($this->_queryID):-1; + $this->_numOfFields = @pg_numfields($this->_queryID); + } + +} +?> diff --git a/includes/adodb/drivers/adodb-oci8.inc.php b/includes/adodb/drivers/adodb-oci8.inc.php new file mode 100644 index 00000000..42804e11 --- /dev/null +++ b/includes/adodb/drivers/adodb-oci8.inc.php @@ -0,0 +1,1574 @@ + + + 13 Nov 2000 jlim - removed all ora_* references. +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +/* +NLS_Date_Format +Allows you to use a date format other than the Oracle Lite default. When a literal +character string appears where a date value is expected, the Oracle Lite database +tests the string to see if it matches the formats of Oracle, SQL-92, or the value +specified for this parameter in the POLITE.INI file. Setting this parameter also +defines the default format used in the TO_CHAR or TO_DATE functions when no +other format string is supplied. + +For Oracle the default is dd-mon-yy or dd-mon-yyyy, and for SQL-92 the default is +yy-mm-dd or yyyy-mm-dd. + +Using 'RR' in the format forces two-digit years less than or equal to 49 to be +interpreted as years in the 21st century (2000–2049), and years over 50 as years in +the 20th century (1950–1999). Setting the RR format as the default for all two-digit +year entries allows you to become year-2000 compliant. For example: +NLS_DATE_FORMAT='RR-MM-DD' + +You can also modify the date format using the ALTER SESSION command. +*/ + +# define the LOB descriptor type for the given type +# returns false if no LOB descriptor +function oci_lob_desc($type) { + switch ($type) { + case OCI_B_BFILE: $result = OCI_D_FILE; break; + case OCI_B_CFILEE: $result = OCI_D_FILE; break; + case OCI_B_CLOB: $result = OCI_D_LOB; break; + case OCI_B_BLOB: $result = OCI_D_LOB; break; + case OCI_B_ROWID: $result = OCI_D_ROWID; break; + default: $result = false; break; + } + return $result; +} + +class ADODB_oci8 extends ADOConnection { + var $databaseType = 'oci8'; + var $dataProvider = 'oci8'; + var $replaceQuote = "''"; // string to use to replace quotes + var $concat_operator='||'; + var $sysDate = "TRUNC(SYSDATE)"; + var $sysTimeStamp = 'SYSDATE'; + var $metaDatabasesSQL = "SELECT USERNAME FROM ALL_USERS WHERE USERNAME NOT IN ('SYS','SYSTEM','DBSNMP','OUTLN') ORDER BY 1"; + var $_stmt; + var $_commit = OCI_COMMIT_ON_SUCCESS; + var $_initdate = true; // init date to YYYY-MM-DD + var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW') and table_name not like 'BIN\$%'"; // bin$ tables are recycle bin tables + var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net + var $_bindInputArray = true; + var $hasGenID = true; + var $_genIDSQL = "SELECT (%s.nextval) FROM DUAL"; + var $_genSeqSQL = "CREATE SEQUENCE %s START WITH %s"; + var $_dropSeqSQL = "DROP SEQUENCE %s"; + var $hasAffectedRows = true; + var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)"; + var $noNullStrings = false; + var $connectSID = false; + var $_bind = false; + var $_nestedSQL = true; + var $_hasOCIFetchStatement = false; + var $_getarray = false; // currently not working + var $leftOuter = ''; // oracle wierdness, $col = $value (+) for LEFT OUTER, $col (+)= $value for RIGHT OUTER + var $session_sharing_force_blob = false; // alter session on updateblob if set to true + var $firstrows = true; // enable first rows optimization on SelectLimit() + var $selectOffsetAlg1 = 100; // when to use 1st algorithm of selectlimit. + var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS' + var $dateformat = 'YYYY-MM-DD'; // DBDate format + var $useDBDateFormatForTextInput=false; + var $datetime = false; // MetaType('DATE') returns 'D' (datetime==false) or 'T' (datetime == true) + var $_refLOBs = array(); + + // var $ansiOuter = true; // if oracle9 + + function ADODB_oci8() + { + $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200; + if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_'; + } + + /* function MetaColumns($table) added by smondino@users.sourceforge.net*/ + function MetaColumns($table) + { + global $ADODB_FETCH_MODE; + + $false = false; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); + + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + if (!$rs) { + return $false; + } + $retarr = array(); + while (!$rs->EOF) { //print_r($rs->fields); + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $fld->type = $rs->fields[1]; + $fld->max_length = $rs->fields[2]; + $fld->scale = $rs->fields[3]; + if ($rs->fields[1] == 'NUMBER') { + if ($rs->fields[3] == 0) $fld->type = 'INT'; + $fld->max_length = $rs->fields[4]; + } + $fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0); + $fld->binary = (strpos($fld->type,'BLOB') !== false); + $fld->default_value = $rs->fields[6]; + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + else $retarr[strtoupper($fld->name)] = $fld; + $rs->MoveNext(); + } + $rs->Close(); + if (empty($retarr)) + return $false; + else + return $retarr; + } + + function Time() + { + $rs = $this->Execute("select TO_CHAR($this->sysTimeStamp,'YYYY-MM-DD HH24:MI:SS') from dual"); + if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); + + return false; + } + +/* + + Multiple modes of connection are supported: + + a. Local Database + $conn->Connect(false,'scott','tiger'); + + b. From tnsnames.ora + $conn->Connect(false,'scott','tiger',$tnsname); + $conn->Connect($tnsname,'scott','tiger'); + + c. Server + service name + $conn->Connect($serveraddress,'scott,'tiger',$service_name); + + d. Server + SID + $conn->connectSID = true; + $conn->Connect($serveraddress,'scott,'tiger',$SID); + + +Example TNSName: +--------------- +NATSOFT.DOMAIN = + (DESCRIPTION = + (ADDRESS_LIST = + (ADDRESS = (PROTOCOL = TCP)(HOST = kermit)(PORT = 1523)) + ) + (CONNECT_DATA = + (SERVICE_NAME = natsoft.domain) + ) + ) + + There are 3 connection modes, 0 = non-persistent, 1 = persistent, 2 = force new connection + +*/ + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$mode=0) + { + if (!function_exists('OCIPLogon')) return null; + + + $this->_errorMsg = false; + $this->_errorCode = false; + + if($argHostname) { // added by Jorma Tuomainen + if (empty($argDatabasename)) $argDatabasename = $argHostname; + else { + if(strpos($argHostname,":")) { + $argHostinfo=explode(":",$argHostname); + $argHostname=$argHostinfo[0]; + $argHostport=$argHostinfo[1]; + } else { + $argHostport = empty($this->port)? "1521" : $this->port; + } + + if (strncmp($argDatabasename,'SID=',4) == 0) { + $argDatabasename = substr($argDatabasename,4); + $this->connectSID = true; + } + + if ($this->connectSID) { + $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname + .")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))"; + } else + $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname + .")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))"; + } + } + + //if ($argHostname) print "

Connect: 1st argument should be left blank for $this->databaseType

"; + if ($mode==1) { + $this->_connectionID = ($this->charSet) ? + OCIPLogon($argUsername,$argPassword, $argDatabasename,$this->charSet) + : + OCIPLogon($argUsername,$argPassword, $argDatabasename) + ; + if ($this->_connectionID && $this->autoRollback) OCIrollback($this->_connectionID); + } else if ($mode==2) { + $this->_connectionID = ($this->charSet) ? + OCINLogon($argUsername,$argPassword, $argDatabasename,$this->charSet) + : + OCINLogon($argUsername,$argPassword, $argDatabasename); + + } else { + $this->_connectionID = ($this->charSet) ? + OCILogon($argUsername,$argPassword, $argDatabasename,$this->charSet) + : + OCILogon($argUsername,$argPassword, $argDatabasename); + } + if (!$this->_connectionID) return false; + if ($this->_initdate) { + $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'"); + } + + // looks like: + // Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option JServer Release 8.1.7.0.0 - Production + // $vers = OCIServerVersion($this->_connectionID); + // if (strpos($vers,'8i') !== false) $this->ansiOuter = true; + return true; + } + + function ServerInfo() + { + $arr['compat'] = $this->GetOne('select value from sys.database_compatible_level'); + $arr['description'] = @OCIServerVersion($this->_connectionID); + $arr['version'] = ADOConnection::_findvers($arr['description']); + return $arr; + } + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,1); + } + + // returns true or false + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,2); + } + + function _affectedrows() + { + if (is_resource($this->_stmt)) return @OCIRowCount($this->_stmt); + return 0; + } + + function IfNull( $field, $ifNull ) + { + return " NVL($field, $ifNull) "; // if Oracle + } + + // format and return date string in database date format + function DBDate($d,$isfld=false) + { + if (empty($d) && $d !== 0) return 'null'; + if ($isfld) return 'TO_DATE('.$d.",'".$this->dateformat."')"; + if (is_string($d)) $d = ADORecordSet::UnixDate($d); + return "TO_DATE(".adodb_date($this->fmtDate,$d).",'".$this->dateformat."')"; + } + + function BindDate($d) + { + $d = ADOConnection::DBDate($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + function BindTimeStamp($d) + { + $d = ADOConnection::DBTimeStamp($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + // format and return date string in database timestamp format + function DBTimeStamp($ts,$isfld=false) + { + if (empty($ts) && $ts !== 0) return 'null'; + if ($isfld) return 'TO_DATE('.$ts.",'RRRR-MM-DD, HH24:MI:SS')"; + if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts); + return 'TO_DATE('.adodb_date("'Y-m-d H:i:s'",$ts).",'RRRR-MM-DD, HH24:MI:SS')"; + } + + function RowLock($tables,$where,$flds='1 as ignore') + { + if ($this->autoCommit) $this->BeginTrans(); + return $this->GetOne("select $flds from $tables where $where for update"); + } + + function MetaTables($ttype=false,$showSchema=false,$mask=false) + { + if ($mask) { + $save = $this->metaTablesSQL; + $mask = $this->qstr(strtoupper($mask)); + $this->metaTablesSQL .= " AND upper(table_name) like $mask"; + } + $ret = ADOConnection::MetaTables($ttype,$showSchema); + + if ($mask) { + $this->metaTablesSQL = $save; + } + return $ret; + } + + // Mark Newnham + function MetaIndexes ($table, $primary = FALSE, $owner=false) + { + // save old fetch mode + global $ADODB_FETCH_MODE; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + + // get index details + $table = strtoupper($table); + + // get Primary index + $primary_key = ''; + + $false = false; + $rs = $this->Execute(sprintf("SELECT * FROM ALL_CONSTRAINTS WHERE UPPER(TABLE_NAME)='%s' AND CONSTRAINT_TYPE='P'",$table)); + if ($row = $rs->FetchRow()) + $primary_key = $row[1]; //constraint_name + + if ($primary==TRUE && $primary_key=='') { + if (isset($savem)) + $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + return $false; //There is no primary key + } + + $rs = $this->Execute(sprintf("SELECT ALL_INDEXES.INDEX_NAME, ALL_INDEXES.UNIQUENESS, ALL_IND_COLUMNS.COLUMN_POSITION, ALL_IND_COLUMNS.COLUMN_NAME FROM ALL_INDEXES,ALL_IND_COLUMNS WHERE UPPER(ALL_INDEXES.TABLE_NAME)='%s' AND ALL_IND_COLUMNS.INDEX_NAME=ALL_INDEXES.INDEX_NAME",$table)); + + + if (!is_object($rs)) { + if (isset($savem)) + $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + return $false; + } + + $indexes = array (); + // parse index data into array + + while ($row = $rs->FetchRow()) { + if ($primary && $row[0] != $primary_key) continue; + if (!isset($indexes[$row[0]])) { + $indexes[$row[0]] = array( + 'unique' => ($row[1] == 'UNIQUE'), + 'columns' => array() + ); + } + $indexes[$row[0]]['columns'][$row[2] - 1] = $row[3]; + } + + // sort columns by order in the index + foreach ( array_keys ($indexes) as $index ) { + ksort ($indexes[$index]['columns']); + } + + if (isset($savem)) { + $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + } + return $indexes; + } + + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + $this->autoCommit = false; + $this->_commit = OCI_DEFAULT; + + if ($this->_transmode) $this->Execute("SET TRANSACTION ".$this->_transmode); + return true; + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + + if ($this->transCnt) $this->transCnt -= 1; + $ret = OCIcommit($this->_connectionID); + $this->_commit = OCI_COMMIT_ON_SUCCESS; + $this->autoCommit = true; + return $ret; + } + + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $ret = OCIrollback($this->_connectionID); + $this->_commit = OCI_COMMIT_ON_SUCCESS; + $this->autoCommit = true; + return $ret; + } + + + function SelectDB($dbName) + { + return false; + } + + function ErrorMsg() + { + if ($this->_errorMsg !== false) return $this->_errorMsg; + + if (is_resource($this->_stmt)) $arr = @OCIError($this->_stmt); + if (empty($arr)) { + if (is_resource($this->_connectionID)) $arr = @OCIError($this->_connectionID); + else $arr = @OCIError(); + if ($arr === false) return ''; + } + $this->_errorMsg = $arr['message']; + $this->_errorCode = $arr['code']; + return $this->_errorMsg; + } + + function ErrorNo() + { + if ($this->_errorCode !== false) return $this->_errorCode; + + if (is_resource($this->_stmt)) $arr = @OCIError($this->_stmt); + if (empty($arr)) { + $arr = @OCIError($this->_connectionID); + if ($arr == false) $arr = @OCIError(); + if ($arr == false) return ''; + } + + $this->_errorMsg = $arr['message']; + $this->_errorCode = $arr['code']; + + return $arr['code']; + } + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysTimeStamp; + $s = 'TO_CHAR('.$col.",'"; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + $s .= 'YYYY'; + break; + case 'Q': + case 'q': + $s .= 'Q'; + break; + + case 'M': + $s .= 'Mon'; + break; + + case 'm': + $s .= 'MM'; + break; + case 'D': + case 'd': + $s .= 'DD'; + break; + + case 'H': + $s.= 'HH24'; + break; + + case 'h': + $s .= 'HH'; + break; + + case 'i': + $s .= 'MI'; + break; + + case 's': + $s .= 'SS'; + break; + + case 'a': + case 'A': + $s .= 'AM'; + break; + + case 'w': + $s .= 'D'; + break; + + case 'l': + $s .= 'DAY'; + break; + + case 'W': + $s .= 'WW'; + break; + + default: + // handle escape characters... + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + if (strpos('-/.:;, ',$ch) !== false) $s .= $ch; + else $s .= '"'.$ch.'"'; + + } + } + return $s. "')"; + } + + function GetRandRow($sql, $arr = false) + { + $sql = "SELECT * FROM ($sql ORDER BY dbms_random.value) WHERE rownum = 1"; + + return $this->GetRow($sql,$arr); + } + + /* + This algorithm makes use of + + a. FIRST_ROWS hint + The FIRST_ROWS hint explicitly chooses the approach to optimize response time, + that is, minimum resource usage to return the first row. Results will be returned + as soon as they are identified. + + b. Uses rownum tricks to obtain only the required rows from a given offset. + As this uses complicated sql statements, we only use this if the $offset >= 100. + This idea by Tomas V V Cox. + + This implementation does not appear to work with oracle 8.0.5 or earlier. Comment + out this function then, and the slower SelectLimit() in the base class will be used. + */ + function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) + { + // seems that oracle only supports 1 hint comment in 8i + if ($this->firstrows) { + if (strpos($sql,'/*+') !== false) + $sql = str_replace('/*+ ','/*+FIRST_ROWS ',$sql); + else + $sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql); + } + + if ($offset < $this->selectOffsetAlg1 && 0 < $nrows && $nrows < 1000) { + if ($nrows > 0) { + if ($offset > 0) $nrows += $offset; + //$inputarr['adodb_rownum'] = $nrows; + if ($this->databaseType == 'oci8po') { + $sql = "select * from (".$sql.") where rownum <= ?"; + } else { + $sql = "select * from (".$sql.") where rownum <= :adodb_offset"; + } + $inputarr['adodb_offset'] = $nrows; + $nrows = -1; + } + // note that $nrows = 0 still has to work ==> no rows returned + + $rs = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + return $rs; + + } else { + // Algorithm by Tomas V V Cox, from PEAR DB oci8.php + + // Let Oracle return the name of the columns + $q_fields = "SELECT * FROM (".$sql.") WHERE NULL = NULL"; + + $false = false; + if (! $stmt_arr = $this->Prepare($q_fields)) { + return $false; + } + $stmt = $stmt_arr[1]; + + if (is_array($inputarr)) { + foreach($inputarr as $k => $v) { + if (is_array($v)) { + if (sizeof($v) == 2) // suggested by g.giunta@libero. + OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1]); + else + OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]); + } else { + $len = -1; + if ($v === ' ') $len = 1; + if (isset($bindarr)) { // is prepared sql, so no need to ocibindbyname again + $bindarr[$k] = $v; + } else { // dynamic sql, so rebind every time + OCIBindByName($stmt,":$k",$inputarr[$k],$len); + + } + } + } + } + + if (!OCIExecute($stmt, OCI_DEFAULT)) { + OCIFreeStatement($stmt); + return $false; + } + + $ncols = OCINumCols($stmt); + for ( $i = 1; $i <= $ncols; $i++ ) { + $cols[] = '"'.OCIColumnName($stmt, $i).'"'; + } + $result = false; + + OCIFreeStatement($stmt); + $fields = implode(',', $cols); + if ($nrows <= 0) $nrows = 999999999999; + else $nrows += $offset; + $offset += 1; // in Oracle rownum starts at 1 + + if ($this->databaseType == 'oci8po') { + $sql = "SELECT $fields FROM". + "(SELECT rownum as adodb_rownum, $fields FROM". + " ($sql) WHERE rownum <= ?". + ") WHERE adodb_rownum >= ?"; + } else { + $sql = "SELECT $fields FROM". + "(SELECT rownum as adodb_rownum, $fields FROM". + " ($sql) WHERE rownum <= :adodb_nrows". + ") WHERE adodb_rownum >= :adodb_offset"; + } + $inputarr['adodb_nrows'] = $nrows; + $inputarr['adodb_offset'] = $offset; + + if ($secs2cache>0) $rs = $this->CacheExecute($secs2cache, $sql,$inputarr); + else $rs = $this->Execute($sql,$inputarr); + return $rs; + } + + } + + /** + * Usage: + * Store BLOBs and CLOBs + * + * Example: to store $var in a blob + * + * $conn->Execute('insert into TABLE (id,ablob) values(12,empty_blob())'); + * $conn->UpdateBlob('TABLE', 'ablob', $varHoldingBlob, 'ID=12', 'BLOB'); + * + * $blobtype supports 'BLOB' and 'CLOB', but you need to change to 'empty_clob()'. + * + * to get length of LOB: + * select DBMS_LOB.GETLENGTH(ablob) from TABLE + * + * If you are using CURSOR_SHARING = force, it appears this will case a segfault + * under oracle 8.1.7.0. Run: + * $db->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT'); + * before UpdateBlob() then... + */ + + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + + //if (strlen($val) < 4000) return $this->Execute("UPDATE $table SET $column=:blob WHERE $where",array('blob'=>$val)) != false; + + switch(strtoupper($blobtype)) { + default: ADOConnection::outp("UpdateBlob: Unknown blobtype=$blobtype"); return false; + case 'BLOB': $type = OCI_B_BLOB; break; + case 'CLOB': $type = OCI_B_CLOB; break; + } + + if ($this->databaseType == 'oci8po') + $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO ?"; + else + $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO :blob"; + + $desc = OCINewDescriptor($this->_connectionID, OCI_D_LOB); + $arr['blob'] = array($desc,-1,$type); + if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT'); + $commit = $this->autoCommit; + if ($commit) $this->BeginTrans(); + $rs = $this->_Execute($sql,$arr); + if ($rez = !empty($rs)) $desc->save($val); + $desc->free(); + if ($commit) $this->CommitTrans(); + if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=FORCE'); + + if ($rez) $rs->Close(); + return $rez; + } + + /** + * Usage: store file pointed to by $var in a blob + */ + function UpdateBlobFile($table,$column,$val,$where,$blobtype='BLOB') + { + switch(strtoupper($blobtype)) { + default: ADOConnection::outp( "UpdateBlob: Unknown blobtype=$blobtype"); return false; + case 'BLOB': $type = OCI_B_BLOB; break; + case 'CLOB': $type = OCI_B_CLOB; break; + } + + if ($this->databaseType == 'oci8po') + $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO ?"; + else + $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO :blob"; + + $desc = OCINewDescriptor($this->_connectionID, OCI_D_LOB); + $arr['blob'] = array($desc,-1,$type); + + $this->BeginTrans(); + $rs = ADODB_oci8::Execute($sql,$arr); + if ($rez = !empty($rs)) $desc->savefile($val); + $desc->free(); + $this->CommitTrans(); + + if ($rez) $rs->Close(); + return $rez; + } + + /** + * Execute SQL + * + * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) + * @param [inputarr] holds the input data to bind to. Null elements will be set to null. + * @return RecordSet or false + */ + function Execute($sql,$inputarr=false) + { + if ($this->fnExecute) { + $fn = $this->fnExecute; + $ret = $fn($this,$sql,$inputarr); + if (isset($ret)) return $ret; + } + if ($inputarr) { + #if (!is_array($inputarr)) $inputarr = array($inputarr); + + $element0 = reset($inputarr); + + if (!$this->_bindInputArray) { + # is_object check because oci8 descriptors can be passed in + if (is_array($element0) && !is_object(reset($element0))) { + if (is_string($sql)) + $stmt = $this->Prepare($sql); + else + $stmt = $sql; + + foreach($inputarr as $arr) { + $ret = $this->_Execute($stmt,$arr); + if (!$ret) return $ret; + } + } else { + $sqlarr = explode(':',$sql); + $sql = ''; + $lastnomatch = -2; + #var_dump($sqlarr);echo "
";var_dump($inputarr);echo"
"; + foreach($sqlarr as $k => $str) { + if ($k == 0) { $sql = $str; continue; } + // we need $lastnomatch because of the following datetime, + // eg. '10:10:01', which causes code to think that there is bind param :10 and :1 + $ok = preg_match('/^([0-9]*)/', $str, $arr); + + if (!$ok) $sql .= $str; + else { + $at = $arr[1]; + if (isset($inputarr[$at]) || is_null($inputarr[$at])) { + if ((strlen($at) == strlen($str) && $k < sizeof($arr)-1)) { + $sql .= ':'.$str; + $lastnomatch = $k; + } else if ($lastnomatch == $k-1) { + $sql .= ':'.$str; + } else { + if (is_null($inputarr[$at])) $sql .= 'null'; + else $sql .= $this->qstr($inputarr[$at]); + $sql .= substr($str, strlen($at)); + } + } else { + $sql .= ':'.$str; + } + + } + } + $inputarr = false; + } + } + $ret = $this->_Execute($sql,$inputarr); + + + } else { + $ret = $this->_Execute($sql,false); + } + + return $ret; + } + + /* + Example of usage: + + $stmt = $this->Prepare('insert into emp (empno, ename) values (:empno, :ename)'); + */ + function Prepare($sql,$cursor=false) + { + static $BINDNUM = 0; + + $stmt = OCIParse($this->_connectionID,$sql); + + if (!$stmt) { + $this->_errorMsg = false; + $this->_errorCode = false; + $arr = @OCIError($this->_connectionID); + if ($arr === false) return false; + + $this->_errorMsg = $arr['message']; + $this->_errorCode = $arr['code']; + return false; + } + + $BINDNUM += 1; + + $sttype = @OCIStatementType($stmt); + if ($sttype == 'BEGIN' || $sttype == 'DECLARE') { + return array($sql,$stmt,0,$BINDNUM, ($cursor) ? OCINewCursor($this->_connectionID) : false); + } + return array($sql,$stmt,0,$BINDNUM); + } + + /* + Call an oracle stored procedure and returns a cursor variable as a recordset. + Concept by Robert Tuttle robert@ud.com + + Example: + Note: we return a cursor variable in :RS2 + $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS2); END;",'RS2'); + + $rs = $db->ExecuteCursor( + "BEGIN :RS2 = adodb.getdata(:VAR1); END;", + 'RS2', + array('VAR1' => 'Mr Bean')); + + */ + function ExecuteCursor($sql,$cursorName='rs',$params=false) + { + if (is_array($sql)) $stmt = $sql; + else $stmt = ADODB_oci8::Prepare($sql,true); # true to allocate OCINewCursor + + if (is_array($stmt) && sizeof($stmt) >= 5) { + $hasref = true; + $ignoreCur = false; + $this->Parameter($stmt, $ignoreCur, $cursorName, false, -1, OCI_B_CURSOR); + if ($params) { + foreach($params as $k => $v) { + $this->Parameter($stmt,$params[$k], $k); + } + } + } else + $hasref = false; + + $rs = $this->Execute($stmt); + if ($rs) { + if ($rs->databaseType == 'array') OCIFreeCursor($stmt[4]); + else if ($hasref) $rs->_refcursor = $stmt[4]; + } + return $rs; + } + + /* + Bind a variable -- very, very fast for executing repeated statements in oracle. + Better than using + for ($i = 0; $i < $max; $i++) { + $p1 = ?; $p2 = ?; $p3 = ?; + $this->Execute("insert into table (col0, col1, col2) values (:0, :1, :2)", + array($p1,$p2,$p3)); + } + + Usage: + $stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:0, :1, :2)"); + $DB->Bind($stmt, $p1); + $DB->Bind($stmt, $p2); + $DB->Bind($stmt, $p3); + for ($i = 0; $i < $max; $i++) { + $p1 = ?; $p2 = ?; $p3 = ?; + $DB->Execute($stmt); + } + + Some timings: + ** Test table has 3 cols, and 1 index. Test to insert 1000 records + Time 0.6081s (1644.60 inserts/sec) with direct OCIParse/OCIExecute + Time 0.6341s (1577.16 inserts/sec) with ADOdb Prepare/Bind/Execute + Time 1.5533s ( 643.77 inserts/sec) with pure SQL using Execute + + Now if PHP only had batch/bulk updating like Java or PL/SQL... + + Note that the order of parameters differs from OCIBindByName, + because we default the names to :0, :1, :2 + */ + function Bind(&$stmt,&$var,$size=4000,$type=false,$name=false,$isOutput=false) + { + + if (!is_array($stmt)) return false; + + if (($type == OCI_B_CURSOR) && sizeof($stmt) >= 5) { + return OCIBindByName($stmt[1],":".$name,$stmt[4],$size,$type); + } + + if ($name == false) { + if ($type !== false) $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size,$type); + else $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size); // +1 byte for null terminator + $stmt[2] += 1; + } else if (oci_lob_desc($type)) { + if ($this->debug) { + ADOConnection::outp("Bind: name = $name"); + } + //we have to create a new Descriptor here + $numlob = count($this->_refLOBs); + $this->_refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type)); + $this->_refLOBs[$numlob]['TYPE'] = $isOutput; + + $tmp = $this->_refLOBs[$numlob]['LOB']; + $rez = OCIBindByName($stmt[1], ":".$name, $tmp, -1, $type); + if ($this->debug) { + ADOConnection::outp("Bind: descriptor has been allocated, var (".$name.") binded"); + } + + // if type is input then write data to lob now + if ($isOutput == false) { + $var = $this->BlobEncode($var); + $tmp->WriteTemporary($var); + $this->_refLOBs[$numlob]['VAR'] = &$var; + if ($this->debug) { + ADOConnection::outp("Bind: LOB has been written to temp"); + } + } else { + $this->_refLOBs[$numlob]['VAR'] = $var; + } + $rez = $tmp; + } else { + if ($this->debug) + ADOConnection::outp("Bind: name = $name"); + + if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type); + else $rez = OCIBindByName($stmt[1],":".$name,$var,$size); // +1 byte for null terminator + } + + return $rez; + } + + function Param($name,$type=false) + { + return ':'.$name; + } + + /* + Usage: + $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); + $db->Parameter($stmt,$id,'myid'); + $db->Parameter($stmt,$group,'group'); + $db->Execute($stmt); + + @param $stmt Statement returned by Prepare() or PrepareSP(). + @param $var PHP variable to bind to + @param $name Name of stored procedure variable name to bind to. + @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. + @param [$maxLen] Holds an maximum length of the variable. + @param [$type] The data type of $var. Legal values depend on driver. + + See OCIBindByName documentation at php.net. + */ + function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) + { + if ($this->debug) { + $prefix = ($isOutput) ? 'Out' : 'In'; + $ztype = (empty($type)) ? 'false' : $type; + ADOConnection::outp( "{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);"); + } + return $this->Bind($stmt,$var,$maxLen,$type,$name,$isOutput); + } + + /* + returns query ID if successful, otherwise false + this version supports: + + 1. $db->execute('select * from table'); + + 2. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)'); + $db->execute($prepared_statement, array(1,2,3)); + + 3. $db->execute('insert into table (a,b,c) values (:a,:b,:c)',array('a'=>1,'b'=>2,'c'=>3)); + + 4. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)'); + $db->bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3); + $db->execute($stmt); + */ + function _query($sql,$inputarr) + { + if (is_array($sql)) { // is prepared sql + $stmt = $sql[1]; + + // we try to bind to permanent array, so that OCIBindByName is persistent + // and carried out once only - note that max array element size is 4000 chars + if (is_array($inputarr)) { + $bindpos = $sql[3]; + if (isset($this->_bind[$bindpos])) { + // all tied up already + $bindarr = $this->_bind[$bindpos]; + } else { + // one statement to bind them all + $bindarr = array(); + foreach($inputarr as $k => $v) { + $bindarr[$k] = $v; + OCIBindByName($stmt,":$k",$bindarr[$k],is_string($v) && strlen($v)>4000 ? -1 : 4000); + } + $this->_bind[$bindpos] = $bindarr; + } + } + } else { + $stmt=OCIParse($this->_connectionID,$sql); + } + + $this->_stmt = $stmt; + if (!$stmt) return false; + + if (defined('ADODB_PREFETCH_ROWS')) @OCISetPrefetch($stmt,ADODB_PREFETCH_ROWS); + + if (is_array($inputarr)) { + foreach($inputarr as $k => $v) { + if (is_array($v)) { + if (sizeof($v) == 2) // suggested by g.giunta@libero. + OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1]); + else + OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]); + + if ($this->debug==99) { + if (is_object($v[0])) + echo "name=:$k",' len='.$v[1],' type='.$v[2],'
'; + else + echo "name=:$k",' var='.$inputarr[$k][0],' len='.$v[1],' type='.$v[2],'
'; + + } + } else { + $len = -1; + if ($v === ' ') $len = 1; + if (isset($bindarr)) { // is prepared sql, so no need to ocibindbyname again + $bindarr[$k] = $v; + } else { // dynamic sql, so rebind every time + OCIBindByName($stmt,":$k",$inputarr[$k],$len); + } + } + } + } + + $this->_errorMsg = false; + $this->_errorCode = false; + if (OCIExecute($stmt,$this->_commit)) { +//OCIInternalDebug(1); + if (count($this -> _refLOBs) > 0) { + + foreach ($this -> _refLOBs as $key => $value) { + if ($this -> _refLOBs[$key]['TYPE'] == true) { + $tmp = $this -> _refLOBs[$key]['LOB'] -> load(); + if ($this -> debug) { + ADOConnection::outp("OUT LOB: LOB has been loaded.
"); + } + //$_GLOBALS[$this -> _refLOBs[$key]['VAR']] = $tmp; + $this -> _refLOBs[$key]['VAR'] = $tmp; + } else { + $this->_refLOBs[$key]['LOB']->save($this->_refLOBs[$key]['VAR']); + $this -> _refLOBs[$key]['LOB']->free(); + unset($this -> _refLOBs[$key]); + if ($this->debug) { + ADOConnection::outp("IN LOB: LOB has been saved.
"); + } + } + } + } + + switch (@OCIStatementType($stmt)) { + case "SELECT": + return $stmt; + + case 'DECLARE': + case "BEGIN": + if (is_array($sql) && !empty($sql[4])) { + $cursor = $sql[4]; + if (is_resource($cursor)) { + $ok = OCIExecute($cursor); + return $cursor; + } + return $stmt; + } else { + if (is_resource($stmt)) { + OCIFreeStatement($stmt); + return true; + } + return $stmt; + } + break; + default : + // ociclose -- no because it could be used in a LOB? + return true; + } + } + return false; + } + + // returns true or false + function _close() + { + if (!$this->_connectionID) return; + + if (!$this->autoCommit) OCIRollback($this->_connectionID); + if (count($this->_refLOBs) > 0) { + foreach ($this ->_refLOBs as $key => $value) { + $this->_refLOBs[$key]['LOB']->free(); + unset($this->_refLOBs[$key]); + } + } + OCILogoff($this->_connectionID); + + $this->_stmt = false; + $this->_connectionID = false; + } + + function MetaPrimaryKeys($table, $owner=false,$internalKey=false) + { + if ($internalKey) return array('ROWID'); + + // tested with oracle 8.1.7 + $table = strtoupper($table); + if ($owner) { + $owner_clause = "AND ((a.OWNER = b.OWNER) AND (a.OWNER = UPPER('$owner')))"; + $ptab = 'ALL_'; + } else { + $owner_clause = ''; + $ptab = 'USER_'; + } + $sql = " +SELECT /*+ RULE */ distinct b.column_name + FROM {$ptab}CONSTRAINTS a + , {$ptab}CONS_COLUMNS b + WHERE ( UPPER(b.table_name) = ('$table')) + AND (UPPER(a.table_name) = ('$table') and a.constraint_type = 'P') + $owner_clause + AND (a.constraint_name = b.constraint_name)"; + + $rs = $this->Execute($sql); + if ($rs && !$rs->EOF) { + $arr = $rs->GetArray(); + $a = array(); + foreach($arr as $v) { + $a[] = reset($v); + } + return $a; + } + else return false; + } + + // http://gis.mit.edu/classes/11.521/sqlnotes/referential_integrity.html + function MetaForeignKeys($table, $owner=false) + { + global $ADODB_FETCH_MODE; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $table = $this->qstr(strtoupper($table)); + if (!$owner) { + $owner = $this->user; + $tabp = 'user_'; + } else + $tabp = 'all_'; + + $owner = ' and owner='.$this->qstr(strtoupper($owner)); + + $sql = +"select constraint_name,r_owner,r_constraint_name + from {$tabp}constraints + where constraint_type = 'R' and table_name = $table $owner"; + + $constraints = $this->GetArray($sql); + $arr = false; + foreach($constraints as $constr) { + $cons = $this->qstr($constr[0]); + $rowner = $this->qstr($constr[1]); + $rcons = $this->qstr($constr[2]); + $cols = $this->GetArray("select column_name from {$tabp}cons_columns where constraint_name=$cons $owner order by position"); + $tabcol = $this->GetArray("select table_name,column_name from {$tabp}cons_columns where owner=$rowner and constraint_name=$rcons order by position"); + + if ($cols && $tabcol) + for ($i=0, $max=sizeof($cols); $i < $max; $i++) { + $arr[$tabcol[$i][0]] = $cols[$i][0].'='.$tabcol[$i][1]; + } + } + $ADODB_FETCH_MODE = $save; + + return $arr; + } + + + function CharMax() + { + return 4000; + } + + function TextMax() + { + return 4000; + } + + /** + * Quotes a string. + * An example is $db->qstr("Don't bother",magic_quotes_runtime()); + * + * @param s the string to quote + * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). + * This undoes the stupidity of magic quotes for GPC. + * + * @return quoted string to be sent back to database + */ + function qstr($s,$magic_quotes=false) + { + //$nofixquotes=false; + + if ($this->noNullStrings && strlen($s)==0)$s = ' '; + if (!$magic_quotes) { + if ($this->replaceQuote[0] == '\\'){ + $s = str_replace('\\','\\\\',$s); + } + return "'".str_replace("'",$this->replaceQuote,$s)."'"; + } + + // undo magic quotes for " + $s = str_replace('\\"','"',$s); + + $s = str_replace('\\\\','\\',$s); + return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; + + } + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_oci8 extends ADORecordSet { + + var $databaseType = 'oci8'; + var $bind=false; + var $_fieldobjs; + + //var $_arr = false; + + function ADORecordset_oci8($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + case ADODB_FETCH_NUM: + default: + $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + } + + $this->adodbFetchMode = $mode; + $this->_queryID = $queryID; + } + + + function Init() + { + if ($this->_inited) return; + + $this->_inited = true; + if ($this->_queryID) { + + $this->_currentRow = 0; + @$this->_initrs(); + $this->EOF = !$this->_fetch(); + + /* + // based on idea by Gaetano Giunta to detect unusual oracle errors + // see http://phplens.com/lens/lensforum/msgs.php?id=6771 + $err = OCIError($this->_queryID); + if ($err && $this->connection->debug) ADOConnection::outp($err); + */ + + if (!is_array($this->fields)) { + $this->_numOfRows = 0; + $this->fields = array(); + } + } else { + $this->fields = array(); + $this->_numOfRows = 0; + $this->_numOfFields = 0; + $this->EOF = true; + } + } + + function _initrs() + { + $this->_numOfRows = -1; + $this->_numOfFields = OCInumcols($this->_queryID); + if ($this->_numOfFields>0) { + $this->_fieldobjs = array(); + $max = $this->_numOfFields; + for ($i=0;$i<$max; $i++) $this->_fieldobjs[] = $this->_FetchField($i); + } + } + + /* Returns: an object containing field information. + Get column information in the Recordset object. fetchField() can be used in order to obtain information about + fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by + fetchField() is retrieved. */ + + function _FetchField($fieldOffset = -1) + { + $fld = new ADOFieldObject; + $fieldOffset += 1; + $fld->name =OCIcolumnname($this->_queryID, $fieldOffset); + $fld->type = OCIcolumntype($this->_queryID, $fieldOffset); + $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset); + switch($fld->type) { + case 'NUMBER': + $p = OCIColumnPrecision($this->_queryID, $fieldOffset); + $sc = OCIColumnScale($this->_queryID, $fieldOffset); + if ($p != 0 && $sc == 0) $fld->type = 'INT'; + break; + + case 'CLOB': + case 'NCLOB': + case 'BLOB': + $fld->max_length = -1; + break; + } + return $fld; + } + + /* For some reason, OCIcolumnname fails when called after _initrs() so we cache it */ + function FetchField($fieldOffset = -1) + { + return $this->_fieldobjs[$fieldOffset]; + } + + + /* + // 10% speedup to move MoveNext to child class + function _MoveNext() + { + //global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return @adodb_movenext($this); + + if ($this->EOF) return false; + + $this->_currentRow++; + if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) + return true; + $this->EOF = true; + + return false; + } */ + + + function MoveNext() + { + if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { + $this->_currentRow += 1; + return true; + } + if (!$this->EOF) { + $this->_currentRow += 1; + $this->EOF = true; + } + return false; + } + + /* + # does not work as first record is retrieved in _initrs(), so is not included in GetArray() + function GetArray($nRows = -1) + { + global $ADODB_OCI8_GETARRAY; + + if (true || !empty($ADODB_OCI8_GETARRAY)) { + # does not support $ADODB_ANSI_PADDING_OFF + + //OCI_RETURN_NULLS and OCI_RETURN_LOBS is set by OCIfetchstatement + switch($this->adodbFetchMode) { + case ADODB_FETCH_NUM: + + $ncols = @OCIfetchstatement($this->_queryID, $results, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW+OCI_NUM); + $results = array_merge(array($this->fields),$results); + return $results; + + case ADODB_FETCH_ASSOC: + if (ADODB_ASSOC_CASE != 2 || $this->databaseType != 'oci8') break; + + $ncols = @OCIfetchstatement($this->_queryID, $assoc, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW); + $results = array_merge(array($this->fields),$assoc); + return $results; + + default: + break; + } + } + + $results = ADORecordSet::GetArray($nRows); + return $results; + + } */ + + /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */ + function GetArrayLimit($nrows,$offset=-1) + { + if ($offset <= 0) { + $arr = $this->GetArray($nrows); + return $arr; + } + $arr = array(); + for ($i=1; $i < $offset; $i++) + if (!@OCIFetch($this->_queryID)) return $arr; + + if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) return $arr;; + $results = array(); + $cnt = 0; + while (!$this->EOF && $nrows != $cnt) { + $results[$cnt++] = $this->fields; + $this->MoveNext(); + } + + return $results; + } + + + /* Use associative array to get fields array */ + function Fields($colname) + { + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + + + function _seek($row) + { + return false; + } + + function _fetch() + { + return @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode); + } + + /* close() only needs to be called if you are worried about using too much memory while your script + is running. All associated result memory for the specified result identifier will automatically be freed. */ + + function _close() + { + if ($this->connection->_stmt === $this->_queryID) $this->connection->_stmt = false; + if (!empty($this->_refcursor)) { + OCIFreeCursor($this->_refcursor); + $this->_refcursor = false; + } + @OCIFreeStatement($this->_queryID); + $this->_queryID = false; + + } + + function MetaType($t,$len=-1) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + switch (strtoupper($t)) { + case 'VARCHAR': + case 'VARCHAR2': + case 'CHAR': + case 'VARBINARY': + case 'BINARY': + case 'NCHAR': + case 'NVARCHAR': + case 'NVARCHAR2': + if (isset($this) && $len <= $this->blobSize) return 'C'; + + case 'NCLOB': + case 'LONG': + case 'LONG VARCHAR': + case 'CLOB': + return 'X'; + + case 'LONG RAW': + case 'LONG VARBINARY': + case 'BLOB': + return 'B'; + + case 'DATE': + return ($this->connection->datetime) ? 'T' : 'D'; + + + case 'TIMESTAMP': return 'T'; + + case 'INT': + case 'SMALLINT': + case 'INTEGER': + return 'I'; + + default: return 'N'; + } + } +} + +class ADORecordSet_ext_oci8 extends ADORecordSet_oci8 { + function ADORecordSet_ext_oci8($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + case ADODB_FETCH_NUM: + default: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + } + $this->adodbFetchMode = $mode; + $this->_queryID = $queryID; + } + + function MoveNext() + { + return adodb_movenext($this); + } +} +?> diff --git a/includes/adodb/drivers/adodb-oci8.old.inc.php b/includes/adodb/drivers/adodb-oci8.old.inc.php new file mode 100644 index 00000000..6e63c2a3 --- /dev/null +++ b/includes/adodb/drivers/adodb-oci8.old.inc.php @@ -0,0 +1,1532 @@ + + + 13 Nov 2000 jlim - removed all ora_* references. +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +/* +NLS_Date_Format +Allows you to use a date format other than the Oracle Lite default. When a literal +character string appears where a date value is expected, the Oracle Lite database +tests the string to see if it matches the formats of Oracle, SQL-92, or the value +specified for this parameter in the POLITE.INI file. Setting this parameter also +defines the default format used in the TO_CHAR or TO_DATE functions when no +other format string is supplied. + +For Oracle the default is dd-mon-yy or dd-mon-yyyy, and for SQL-92 the default is +yy-mm-dd or yyyy-mm-dd. + +Using 'RR' in the format forces two-digit years less than or equal to 49 to be +interpreted as years in the 21st century (2000–2049), and years over 50 as years in +the 20th century (1950–1999). Setting the RR format as the default for all two-digit +year entries allows you to become year-2000 compliant. For example: +NLS_DATE_FORMAT='RR-MM-DD' + +You can also modify the date format using the ALTER SESSION command. +*/ + +# define the LOB descriptor type for the given type +# returns false if no LOB descriptor +function oci_lob_desc($type) { + switch ($type) { + case OCI_B_BFILE: $result = OCI_D_FILE; break; + case OCI_B_CFILEE: $result = OCI_D_FILE; break; + case OCI_B_CLOB: $result = OCI_D_LOB; break; + case OCI_B_BLOB: $result = OCI_D_LOB; break; + case OCI_B_ROWID: $result = OCI_D_ROWID; break; + default: $result = false; break; + } + return $result; +} + +class ADODB_oci8 extends ADOConnection { + var $databaseType = 'oci8'; + var $dataProvider = 'oci8'; + var $replaceQuote = "''"; // string to use to replace quotes + var $concat_operator='||'; + var $sysDate = "TRUNC(SYSDATE)"; + var $sysTimeStamp = 'SYSDATE'; + var $metaDatabasesSQL = "SELECT USERNAME FROM ALL_USERS WHERE USERNAME NOT IN ('SYS','SYSTEM','DBSNMP','OUTLN') ORDER BY 1"; + var $_stmt; + var $_commit = OCI_COMMIT_ON_SUCCESS; + var $_initdate = true; // init date to YYYY-MM-DD + var $metaTablesSQL = "select table_name,table_type from cat where table_type in ('TABLE','VIEW') and table_name not like 'BIN\$%'"; // bin$ tables are recycle bin tables + var $metaColumnsSQL = "select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net + var $_bindInputArray = true; + var $hasGenID = true; + var $_genIDSQL = "SELECT (%s.nextval) FROM DUAL"; + var $_genSeqSQL = "CREATE SEQUENCE %s START WITH %s"; + var $_dropSeqSQL = "DROP SEQUENCE %s"; + var $hasAffectedRows = true; + var $random = "abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)"; + var $noNullStrings = false; + var $connectSID = false; + var $_bind = false; + var $_nestedSQL = true; + var $_hasOCIFetchStatement = false; + var $_getarray = false; // currently not working + var $leftOuter = ''; // oracle wierdness, $col = $value (+) for LEFT OUTER, $col (+)= $value for RIGHT OUTER + var $session_sharing_force_blob = false; // alter session on updateblob if set to true + var $firstrows = true; // enable first rows optimization on SelectLimit() + var $selectOffsetAlg1 = 100; // when to use 1st algorithm of selectlimit. + var $NLS_DATE_FORMAT = 'YYYY-MM-DD'; // To include time, use 'RRRR-MM-DD HH24:MI:SS' + var $dateformat = 'YYYY-MM-DD'; // DBDate format + var $useDBDateFormatForTextInput=false; + var $datetime = false; // MetaType('DATE') returns 'D' (datetime==false) or 'T' (datetime == true) + var $_refLOBs = array(); + + // var $ansiOuter = true; // if oracle9 + + function ADODB_oci8() + { + $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200; + if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_'; + } + + /* function MetaColumns($table) added by smondino@users.sourceforge.net*/ + function MetaColumns($table) + { + global $ADODB_FETCH_MODE; + + $false = false; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); + + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + if (!$rs) { + return $false; + } + $retarr = array(); + while (!$rs->EOF) { //print_r($rs->fields); + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $fld->type = $rs->fields[1]; + $fld->max_length = $rs->fields[2]; + $fld->scale = $rs->fields[3]; + if ($rs->fields[1] == 'NUMBER') { + if ($rs->fields[3] == 0) $fld->type = 'INT'; + $fld->max_length = $rs->fields[4]; + } + $fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0); + $fld->binary = (strpos($fld->type,'BLOB') !== false); + $fld->default_value = $rs->fields[6]; + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + else $retarr[strtoupper($fld->name)] = $fld; + $rs->MoveNext(); + } + $rs->Close(); + if (empty($retarr)) + return $false; + else + return $retarr; + } + + function Time() + { + $rs = $this->Execute("select TO_CHAR($this->sysTimeStamp,'YYYY-MM-DD HH24:MI:SS') from dual"); + if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); + + return false; + } + +/* + + Multiple modes of connection are supported: + + a. Local Database + $conn->Connect(false,'scott','tiger'); + + b. From tnsnames.ora + $conn->Connect(false,'scott','tiger',$tnsname); + $conn->Connect($tnsname,'scott','tiger'); + + c. Server + service name + $conn->Connect($serveraddress,'scott,'tiger',$service_name); + + d. Server + SID + $conn->connectSID = true; + $conn->Connect($serveraddress,'scott,'tiger',$SID); + + +Example TNSName: +--------------- +NATSOFT.DOMAIN = + (DESCRIPTION = + (ADDRESS_LIST = + (ADDRESS = (PROTOCOL = TCP)(HOST = kermit)(PORT = 1523)) + ) + (CONNECT_DATA = + (SERVICE_NAME = natsoft.domain) + ) + ) + + There are 3 connection modes, 0 = non-persistent, 1 = persistent, 2 = force new connection + +*/ + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$mode=0) + { + if (!function_exists('OCIPLogon')) return null; + + + $this->_errorMsg = false; + $this->_errorCode = false; + + if($argHostname) { // added by Jorma Tuomainen + if (empty($argDatabasename)) $argDatabasename = $argHostname; + else { + if(strpos($argHostname,":")) { + $argHostinfo=explode(":",$argHostname); + $argHostname=$argHostinfo[0]; + $argHostport=$argHostinfo[1]; + } else { + $argHostport = empty($this->port)? "1521" : $this->port; + } + + if ($this->connectSID) { + $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname + .")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))"; + } else + $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname + .")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))"; + } + } + + //if ($argHostname) print "

Connect: 1st argument should be left blank for $this->databaseType

"; + if ($mode==1) { + $this->_connectionID = ($this->charSet) ? + OCIPLogon($argUsername,$argPassword, $argDatabasename,$this->charSet) + : + OCIPLogon($argUsername,$argPassword, $argDatabasename) + ; + if ($this->_connectionID && $this->autoRollback) OCIrollback($this->_connectionID); + } else if ($mode==2) { + $this->_connectionID = ($this->charSet) ? + OCINLogon($argUsername,$argPassword, $argDatabasename,$this->charSet) + : + OCINLogon($argUsername,$argPassword, $argDatabasename); + + } else { + $this->_connectionID = ($this->charSet) ? + OCILogon($argUsername,$argPassword, $argDatabasename,$this->charSet) + : + OCILogon($argUsername,$argPassword, $argDatabasename); + } + if (!$this->_connectionID) return false; + if ($this->_initdate) { + $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'"); + } + + // looks like: + // Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option JServer Release 8.1.7.0.0 - Production + // $vers = OCIServerVersion($this->_connectionID); + // if (strpos($vers,'8i') !== false) $this->ansiOuter = true; + return true; + } + + function ServerInfo() + { + $arr['compat'] = $this->GetOne('select value from sys.database_compatible_level'); + $arr['description'] = @OCIServerVersion($this->_connectionID); + $arr['version'] = ADOConnection::_findvers($arr['description']); + return $arr; + } + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,1); + } + + // returns true or false + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename,2); + } + + function _affectedrows() + { + if (is_resource($this->_stmt)) return @OCIRowCount($this->_stmt); + return 0; + } + + function IfNull( $field, $ifNull ) + { + return " NVL($field, $ifNull) "; // if Oracle + } + + // format and return date string in database date format + function DBDate($d) + { + if (empty($d) && $d !== 0) return 'null'; + + if (is_string($d)) $d = ADORecordSet::UnixDate($d); + return "TO_DATE(".adodb_date($this->fmtDate,$d).",'".$this->dateformat."')"; + } + + function BindDate($d) + { + $d = ADOConnection::DBDate($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + function BindTimeStamp($d) + { + $d = ADOConnection::DBTimeStamp($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + // format and return date string in database timestamp format + function DBTimeStamp($ts) + { + if (empty($ts) && $ts !== 0) return 'null'; + if (is_string($ts)) $ts = ADORecordSet::UnixTimeStamp($ts); + return 'TO_DATE('.adodb_date("'Y-m-d H:i:s'",$ts).",'RRRR-MM-DD, HH24:MI:SS')"; + } + + function RowLock($tables,$where,$flds='1 as ignore') + { + if ($this->autoCommit) $this->BeginTrans(); + return $this->GetOne("select $flds from $tables where $where for update"); + } + + function MetaTables($ttype=false,$showSchema=false,$mask=false) + { + if ($mask) { + $save = $this->metaTablesSQL; + $mask = $this->qstr(strtoupper($mask)); + $this->metaTablesSQL .= " AND upper(table_name) like $mask"; + } + $ret = ADOConnection::MetaTables($ttype,$showSchema); + + if ($mask) { + $this->metaTablesSQL = $save; + } + return $ret; + } + + // Mark Newnham + function MetaIndexes ($table, $primary = FALSE, $owner=false) + { + // save old fetch mode + global $ADODB_FETCH_MODE; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + + // get index details + $table = strtoupper($table); + + // get Primary index + $primary_key = ''; + + $false = false; + $rs = $this->Execute(sprintf("SELECT * FROM ALL_CONSTRAINTS WHERE UPPER(TABLE_NAME)='%s' AND CONSTRAINT_TYPE='P'",$table)); + if ($row = $rs->FetchRow()) + $primary_key = $row[1]; //constraint_name + + if ($primary==TRUE && $primary_key=='') { + if (isset($savem)) + $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + return $false; //There is no primary key + } + + $rs = $this->Execute(sprintf("SELECT ALL_INDEXES.INDEX_NAME, ALL_INDEXES.UNIQUENESS, ALL_IND_COLUMNS.COLUMN_POSITION, ALL_IND_COLUMNS.COLUMN_NAME FROM ALL_INDEXES,ALL_IND_COLUMNS WHERE UPPER(ALL_INDEXES.TABLE_NAME)='%s' AND ALL_IND_COLUMNS.INDEX_NAME=ALL_INDEXES.INDEX_NAME",$table)); + + + if (!is_object($rs)) { + if (isset($savem)) + $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + return $false; + } + + $indexes = array (); + // parse index data into array + + while ($row = $rs->FetchRow()) { + if ($primary && $row[0] != $primary_key) continue; + if (!isset($indexes[$row[0]])) { + $indexes[$row[0]] = array( + 'unique' => ($row[1] == 'UNIQUE'), + 'columns' => array() + ); + } + $indexes[$row[0]]['columns'][$row[2] - 1] = $row[3]; + } + + // sort columns by order in the index + foreach ( array_keys ($indexes) as $index ) { + ksort ($indexes[$index]['columns']); + } + + if (isset($savem)) { + $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + } + return $indexes; + } + + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + $this->autoCommit = false; + $this->_commit = OCI_DEFAULT; + + if ($this->_transmode) $this->Execute("SET TRANSACTION ".$this->_transmode); + return true; + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + + if ($this->transCnt) $this->transCnt -= 1; + $ret = OCIcommit($this->_connectionID); + $this->_commit = OCI_COMMIT_ON_SUCCESS; + $this->autoCommit = true; + return $ret; + } + + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $ret = OCIrollback($this->_connectionID); + $this->_commit = OCI_COMMIT_ON_SUCCESS; + $this->autoCommit = true; + return $ret; + } + + + function SelectDB($dbName) + { + return false; + } + + function ErrorMsg() + { + if ($this->_errorMsg !== false) return $this->_errorMsg; + + if (is_resource($this->_stmt)) $arr = @OCIError($this->_stmt); + if (empty($arr)) { + if (is_resource($this->_connectionID)) $arr = @OCIError($this->_connectionID); + else $arr = @OCIError(); + if ($arr === false) return ''; + } + $this->_errorMsg = $arr['message']; + $this->_errorCode = $arr['code']; + return $this->_errorMsg; + } + + function ErrorNo() + { + if ($this->_errorCode !== false) return $this->_errorCode; + + if (is_resource($this->_stmt)) $arr = @OCIError($this->_stmt); + if (empty($arr)) { + $arr = @OCIError($this->_connectionID); + if ($arr == false) $arr = @OCIError(); + if ($arr == false) return ''; + } + + $this->_errorMsg = $arr['message']; + $this->_errorCode = $arr['code']; + + return $arr['code']; + } + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysTimeStamp; + $s = 'TO_CHAR('.$col.",'"; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + $s .= 'YYYY'; + break; + case 'Q': + case 'q': + $s .= 'Q'; + break; + + case 'M': + $s .= 'Mon'; + break; + + case 'm': + $s .= 'MM'; + break; + case 'D': + case 'd': + $s .= 'DD'; + break; + + case 'H': + $s.= 'HH24'; + break; + + case 'h': + $s .= 'HH'; + break; + + case 'i': + $s .= 'MI'; + break; + + case 's': + $s .= 'SS'; + break; + + case 'a': + case 'A': + $s .= 'AM'; + break; + + case 'w': + $s .= 'D'; + break; + + case 'l': + $s .= 'DAY'; + break; + + case 'W': + $s .= 'WW'; + break; + + default: + // handle escape characters... + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + if (strpos('-/.:;, ',$ch) !== false) $s .= $ch; + else $s .= '"'.$ch.'"'; + + } + } + return $s. "')"; + } + + function GetRandRow($sql, $arr = false) + { + $sql = "SELECT * FROM ($sql ORDER BY dbms_random.value) WHERE rownum = 1"; + + return $this->GetRow($sql,$arr); + } + + /* + This algorithm makes use of + + a. FIRST_ROWS hint + The FIRST_ROWS hint explicitly chooses the approach to optimize response time, + that is, minimum resource usage to return the first row. Results will be returned + as soon as they are identified. + + b. Uses rownum tricks to obtain only the required rows from a given offset. + As this uses complicated sql statements, we only use this if the $offset >= 100. + This idea by Tomas V V Cox. + + This implementation does not appear to work with oracle 8.0.5 or earlier. Comment + out this function then, and the slower SelectLimit() in the base class will be used. + */ + function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) + { + // seems that oracle only supports 1 hint comment in 8i + if ($this->firstrows) { + if (strpos($sql,'/*+') !== false) + $sql = str_replace('/*+ ','/*+FIRST_ROWS ',$sql); + else + $sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql); + } + + if ($offset < $this->selectOffsetAlg1 && 0 < $nrows && $nrows < 1000) { + if ($nrows > 0) { + if ($offset > 0) $nrows += $offset; + //$inputarr['adodb_rownum'] = $nrows; + if ($this->databaseType == 'oci8po') { + $sql = "select * from (".$sql.") where rownum <= ?"; + } else { + $sql = "select * from (".$sql.") where rownum <= :adodb_offset"; + } + $inputarr['adodb_offset'] = $nrows; + $nrows = -1; + } + // note that $nrows = 0 still has to work ==> no rows returned + + $rs = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + return $rs; + + } else { + // Algorithm by Tomas V V Cox, from PEAR DB oci8.php + + // Let Oracle return the name of the columns + $q_fields = "SELECT * FROM (".$sql.") WHERE NULL = NULL"; + + $false = false; + if (! $stmt_arr = $this->Prepare($q_fields)) { + return $false; + } + $stmt = $stmt_arr[1]; + + if (is_array($inputarr)) { + foreach($inputarr as $k => $v) { + if (is_array($v)) { + if (sizeof($v) == 2) // suggested by g.giunta@libero. + OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1]); + else + OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]); + } else { + $len = -1; + if ($v === ' ') $len = 1; + if (isset($bindarr)) { // is prepared sql, so no need to ocibindbyname again + $bindarr[$k] = $v; + } else { // dynamic sql, so rebind every time + OCIBindByName($stmt,":$k",$inputarr[$k],$len); + } + } + } + } + + if (!OCIExecute($stmt, OCI_DEFAULT)) { + OCIFreeStatement($stmt); + return $false; + } + + $ncols = OCINumCols($stmt); + for ( $i = 1; $i <= $ncols; $i++ ) { + $cols[] = '"'.OCIColumnName($stmt, $i).'"'; + } + $result = false; + + OCIFreeStatement($stmt); + $fields = implode(',', $cols); + $nrows += $offset; + $offset += 1; // in Oracle rownum starts at 1 + + if ($this->databaseType == 'oci8po') { + $sql = "SELECT $fields FROM". + "(SELECT rownum as adodb_rownum, $fields FROM". + " ($sql) WHERE rownum <= ?". + ") WHERE adodb_rownum >= ?"; + } else { + $sql = "SELECT $fields FROM". + "(SELECT rownum as adodb_rownum, $fields FROM". + " ($sql) WHERE rownum <= :adodb_nrows". + ") WHERE adodb_rownum >= :adodb_offset"; + } + $inputarr['adodb_nrows'] = $nrows; + $inputarr['adodb_offset'] = $offset; + + if ($secs2cache>0) $rs = $this->CacheExecute($secs2cache, $sql,$inputarr); + else $rs = $this->Execute($sql,$inputarr); + return $rs; + } + + } + + /** + * Usage: + * Store BLOBs and CLOBs + * + * Example: to store $var in a blob + * + * $conn->Execute('insert into TABLE (id,ablob) values(12,empty_blob())'); + * $conn->UpdateBlob('TABLE', 'ablob', $varHoldingBlob, 'ID=12', 'BLOB'); + * + * $blobtype supports 'BLOB' and 'CLOB', but you need to change to 'empty_clob()'. + * + * to get length of LOB: + * select DBMS_LOB.GETLENGTH(ablob) from TABLE + * + * If you are using CURSOR_SHARING = force, it appears this will case a segfault + * under oracle 8.1.7.0. Run: + * $db->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT'); + * before UpdateBlob() then... + */ + + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + + //if (strlen($val) < 4000) return $this->Execute("UPDATE $table SET $column=:blob WHERE $where",array('blob'=>$val)) != false; + + switch(strtoupper($blobtype)) { + default: ADOConnection::outp("UpdateBlob: Unknown blobtype=$blobtype"); return false; + case 'BLOB': $type = OCI_B_BLOB; break; + case 'CLOB': $type = OCI_B_CLOB; break; + } + + if ($this->databaseType == 'oci8po') + $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO ?"; + else + $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO :blob"; + + $desc = OCINewDescriptor($this->_connectionID, OCI_D_LOB); + $arr['blob'] = array($desc,-1,$type); + if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=EXACT'); + $commit = $this->autoCommit; + if ($commit) $this->BeginTrans(); + $rs = $this->_Execute($sql,$arr); + if ($rez = !empty($rs)) $desc->save($val); + $desc->free(); + if ($commit) $this->CommitTrans(); + if ($this->session_sharing_force_blob) $this->Execute('ALTER SESSION SET CURSOR_SHARING=FORCE'); + + if ($rez) $rs->Close(); + return $rez; + } + + /** + * Usage: store file pointed to by $var in a blob + */ + function UpdateBlobFile($table,$column,$val,$where,$blobtype='BLOB') + { + switch(strtoupper($blobtype)) { + default: ADOConnection::outp( "UpdateBlob: Unknown blobtype=$blobtype"); return false; + case 'BLOB': $type = OCI_B_BLOB; break; + case 'CLOB': $type = OCI_B_CLOB; break; + } + + if ($this->databaseType == 'oci8po') + $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO ?"; + else + $sql = "UPDATE $table set $column=EMPTY_{$blobtype}() WHERE $where RETURNING $column INTO :blob"; + + $desc = OCINewDescriptor($this->_connectionID, OCI_D_LOB); + $arr['blob'] = array($desc,-1,$type); + + $this->BeginTrans(); + $rs = ADODB_oci8::Execute($sql,$arr); + if ($rez = !empty($rs)) $desc->savefile($val); + $desc->free(); + $this->CommitTrans(); + + if ($rez) $rs->Close(); + return $rez; + } + + /** + * Execute SQL + * + * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) + * @param [inputarr] holds the input data to bind to. Null elements will be set to null. + * @return RecordSet or false + */ + function Execute($sql,$inputarr=false) + { + if ($this->fnExecute) { + $fn = $this->fnExecute; + $ret = $fn($this,$sql,$inputarr); + if (isset($ret)) return $ret; + } + if ($inputarr) { + #if (!is_array($inputarr)) $inputarr = array($inputarr); + + $element0 = reset($inputarr); + + # is_object check because oci8 descriptors can be passed in + if (is_array($element0) && !is_object(reset($element0))) { + if (is_string($sql)) + $stmt = $this->Prepare($sql); + else + $stmt = $sql; + + foreach($inputarr as $arr) { + $ret = $this->_Execute($stmt,$arr); + if (!$ret) return $ret; + } + } else { + $ret = $this->_Execute($sql,$inputarr); + } + + } else { + $ret = $this->_Execute($sql,false); + } + + return $ret; + } + + /* + Example of usage: + + $stmt = $this->Prepare('insert into emp (empno, ename) values (:empno, :ename)'); + */ + function Prepare($sql,$cursor=false) + { + static $BINDNUM = 0; + + $stmt = OCIParse($this->_connectionID,$sql); + + if (!$stmt) { + $this->_errorMsg = false; + $this->_errorCode = false; + $arr = @OCIError($this->_connectionID); + if ($arr === false) return false; + + $this->_errorMsg = $arr['message']; + $this->_errorCode = $arr['code']; + return false; + } + + $BINDNUM += 1; + + $sttype = @OCIStatementType($stmt); + if ($sttype == 'BEGIN' || $sttype == 'DECLARE') { + return array($sql,$stmt,0,$BINDNUM, ($cursor) ? OCINewCursor($this->_connectionID) : false); + } + return array($sql,$stmt,0,$BINDNUM); + } + + /* + Call an oracle stored procedure and returns a cursor variable as a recordset. + Concept by Robert Tuttle robert@ud.com + + Example: + Note: we return a cursor variable in :RS2 + $rs = $db->ExecuteCursor("BEGIN adodb.open_tab(:RS2); END;",'RS2'); + + $rs = $db->ExecuteCursor( + "BEGIN :RS2 = adodb.getdata(:VAR1); END;", + 'RS2', + array('VAR1' => 'Mr Bean')); + + */ + function ExecuteCursor($sql,$cursorName='rs',$params=false) + { + if (is_array($sql)) $stmt = $sql; + else $stmt = ADODB_oci8::Prepare($sql,true); # true to allocate OCINewCursor + + if (is_array($stmt) && sizeof($stmt) >= 5) { + $hasref = true; + $ignoreCur = false; + $this->Parameter($stmt, $ignoreCur, $cursorName, false, -1, OCI_B_CURSOR); + if ($params) { + foreach($params as $k => $v) { + $this->Parameter($stmt,$params[$k], $k); + } + } + } else + $hasref = false; + + $rs = $this->Execute($stmt); + if ($rs) { + if ($rs->databaseType == 'array') OCIFreeCursor($stmt[4]); + else if ($hasref) $rs->_refcursor = $stmt[4]; + } + return $rs; + } + + /* + Bind a variable -- very, very fast for executing repeated statements in oracle. + Better than using + for ($i = 0; $i < $max; $i++) { + $p1 = ?; $p2 = ?; $p3 = ?; + $this->Execute("insert into table (col0, col1, col2) values (:0, :1, :2)", + array($p1,$p2,$p3)); + } + + Usage: + $stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:0, :1, :2)"); + $DB->Bind($stmt, $p1); + $DB->Bind($stmt, $p2); + $DB->Bind($stmt, $p3); + for ($i = 0; $i < $max; $i++) { + $p1 = ?; $p2 = ?; $p3 = ?; + $DB->Execute($stmt); + } + + Some timings: + ** Test table has 3 cols, and 1 index. Test to insert 1000 records + Time 0.6081s (1644.60 inserts/sec) with direct OCIParse/OCIExecute + Time 0.6341s (1577.16 inserts/sec) with ADOdb Prepare/Bind/Execute + Time 1.5533s ( 643.77 inserts/sec) with pure SQL using Execute + + Now if PHP only had batch/bulk updating like Java or PL/SQL... + + Note that the order of parameters differs from OCIBindByName, + because we default the names to :0, :1, :2 + */ + function Bind(&$stmt,&$var,$size=4000,$type=false,$name=false,$isOutput=false) + { + + if (!is_array($stmt)) return false; + + if (($type == OCI_B_CURSOR) && sizeof($stmt) >= 5) { + return OCIBindByName($stmt[1],":".$name,$stmt[4],$size,$type); + } + + if ($name == false) { + if ($type !== false) $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size,$type); + else $rez = OCIBindByName($stmt[1],":".$stmt[2],$var,$size); // +1 byte for null terminator + $stmt[2] += 1; + } else if (oci_lob_desc($type)) { + if ($this->debug) { + ADOConnection::outp("Bind: name = $name"); + } + //we have to create a new Descriptor here + $numlob = count($this->_refLOBs); + $this->_refLOBs[$numlob]['LOB'] = OCINewDescriptor($this->_connectionID, oci_lob_desc($type)); + $this->_refLOBs[$numlob]['TYPE'] = $isOutput; + + $tmp = $this->_refLOBs[$numlob]['LOB']; + $rez = OCIBindByName($stmt[1], ":".$name, $tmp, -1, $type); + if ($this->debug) { + ADOConnection::outp("Bind: descriptor has been allocated, var (".$name.") binded"); + } + + // if type is input then write data to lob now + if ($isOutput == false) { + $var = $this->BlobEncode($var); + $tmp->WriteTemporary($var); + $this->_refLOBs[$numlob]['VAR'] = $var; + if ($this->debug) { + ADOConnection::outp("Bind: LOB has been written to temp"); + } + } else { + $this->_refLOBs[$numlob]['VAR'] = $var; + } + $rez = $tmp; + } else { + if ($this->debug) + ADOConnection::outp("Bind: name = $name"); + + if ($type !== false) $rez = OCIBindByName($stmt[1],":".$name,$var,$size,$type); + else $rez = OCIBindByName($stmt[1],":".$name,$var,$size); // +1 byte for null terminator + } + + return $rez; + } + + function Param($name,$type=false) + { + return ':'.$name; + } + + /* + Usage: + $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); + $db->Parameter($stmt,$id,'myid'); + $db->Parameter($stmt,$group,'group'); + $db->Execute($stmt); + + @param $stmt Statement returned by Prepare() or PrepareSP(). + @param $var PHP variable to bind to + @param $name Name of stored procedure variable name to bind to. + @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. + @param [$maxLen] Holds an maximum length of the variable. + @param [$type] The data type of $var. Legal values depend on driver. + + See OCIBindByName documentation at php.net. + */ + function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) + { + if ($this->debug) { + $prefix = ($isOutput) ? 'Out' : 'In'; + $ztype = (empty($type)) ? 'false' : $type; + ADOConnection::outp( "{$prefix}Parameter(\$stmt, \$php_var='$var', \$name='$name', \$maxLen=$maxLen, \$type=$ztype);"); + } + return $this->Bind($stmt,$var,$maxLen,$type,$name,$isOutput); + } + + /* + returns query ID if successful, otherwise false + this version supports: + + 1. $db->execute('select * from table'); + + 2. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)'); + $db->execute($prepared_statement, array(1,2,3)); + + 3. $db->execute('insert into table (a,b,c) values (:a,:b,:c)',array('a'=>1,'b'=>2,'c'=>3)); + + 4. $db->prepare('insert into table (a,b,c) values (:0,:1,:2)'); + $db->bind($stmt,1); $db->bind($stmt,2); $db->bind($stmt,3); + $db->execute($stmt); + */ + function _query($sql,$inputarr) + { + if (is_array($sql)) { // is prepared sql + $stmt = $sql[1]; + + // we try to bind to permanent array, so that OCIBindByName is persistent + // and carried out once only - note that max array element size is 4000 chars + if (is_array($inputarr)) { + $bindpos = $sql[3]; + if (isset($this->_bind[$bindpos])) { + // all tied up already + $bindarr = $this->_bind[$bindpos]; + } else { + // one statement to bind them all + $bindarr = array(); + foreach($inputarr as $k => $v) { + $bindarr[$k] = $v; + OCIBindByName($stmt,":$k",$bindarr[$k],is_string($v) && strlen($v)>4000 ? -1 : 4000); + } + $this->_bind[$bindpos] = $bindarr; + } + } + } else { + $stmt=OCIParse($this->_connectionID,$sql); + } + + $this->_stmt = $stmt; + if (!$stmt) return false; + + if (defined('ADODB_PREFETCH_ROWS')) @OCISetPrefetch($stmt,ADODB_PREFETCH_ROWS); + + if (is_array($inputarr)) { + foreach($inputarr as $k => $v) { + if (is_array($v)) { + if (sizeof($v) == 2) // suggested by g.giunta@libero. + OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1]); + else + OCIBindByName($stmt,":$k",$inputarr[$k][0],$v[1],$v[2]); + + if ($this->debug==99) { + if (is_object($v[0])) + echo "name=:$k",' len='.$v[1],' type='.$v[2],'
'; + else + echo "name=:$k",' var='.$inputarr[$k][0],' len='.$v[1],' type='.$v[2],'
'; + + } + } else { + $len = -1; + if ($v === ' ') $len = 1; + if (isset($bindarr)) { // is prepared sql, so no need to ocibindbyname again + $bindarr[$k] = $v; + } else { // dynamic sql, so rebind every time + OCIBindByName($stmt,":$k",$inputarr[$k],$len); + } + } + } + } + + $this->_errorMsg = false; + $this->_errorCode = false; + if (OCIExecute($stmt,$this->_commit)) { +//OCIInternalDebug(1); + if (count($this -> _refLOBs) > 0) { + + foreach ($this -> _refLOBs as $key => $value) { + if ($this -> _refLOBs[$key]['TYPE'] == true) { + $tmp = $this -> _refLOBs[$key]['LOB'] -> load(); + if ($this -> debug) { + ADOConnection::outp("OUT LOB: LOB has been loaded.
"); + } + //$_GLOBALS[$this -> _refLOBs[$key]['VAR']] = $tmp; + $this -> _refLOBs[$key]['VAR'] = $tmp; + } else { + $this->_refLOBs[$key]['LOB']->save($this->_refLOBs[$key]['VAR']); + $this -> _refLOBs[$key]['LOB']->free(); + unset($this -> _refLOBs[$key]); + if ($this->debug) { + ADOConnection::outp("IN LOB: LOB has been saved.
"); + } + } + } + } + + switch (@OCIStatementType($stmt)) { + case "SELECT": + return $stmt; + + case 'DECLARE': + case "BEGIN": + if (is_array($sql) && !empty($sql[4])) { + $cursor = $sql[4]; + if (is_resource($cursor)) { + $ok = OCIExecute($cursor); + return $cursor; + } + return $stmt; + } else { + if (is_resource($stmt)) { + OCIFreeStatement($stmt); + return true; + } + return $stmt; + } + break; + default : + // ociclose -- no because it could be used in a LOB? + return true; + } + } + return false; + } + + // returns true or false + function _close() + { + if (!$this->_connectionID) return; + + if (!$this->autoCommit) OCIRollback($this->_connectionID); + if (count($this->_refLOBs) > 0) { + foreach ($this ->_refLOBs as $key => $value) { + $this->_refLOBs[$key]['LOB']->free(); + unset($this->_refLOBs[$key]); + } + } + OCILogoff($this->_connectionID); + + $this->_stmt = false; + $this->_connectionID = false; + } + + function MetaPrimaryKeys($table, $owner=false,$internalKey=false) + { + if ($internalKey) return array('ROWID'); + + // tested with oracle 8.1.7 + $table = strtoupper($table); + if ($owner) { + $owner_clause = "AND ((a.OWNER = b.OWNER) AND (a.OWNER = UPPER('$owner')))"; + $ptab = 'ALL_'; + } else { + $owner_clause = ''; + $ptab = 'USER_'; + } + $sql = " +SELECT /*+ RULE */ distinct b.column_name + FROM {$ptab}CONSTRAINTS a + , {$ptab}CONS_COLUMNS b + WHERE ( UPPER(b.table_name) = ('$table')) + AND (UPPER(a.table_name) = ('$table') and a.constraint_type = 'P') + $owner_clause + AND (a.constraint_name = b.constraint_name)"; + + $rs = $this->Execute($sql); + if ($rs && !$rs->EOF) { + $arr = $rs->GetArray(); + $a = array(); + foreach($arr as $v) { + $a[] = reset($v); + } + return $a; + } + else return false; + } + + // http://gis.mit.edu/classes/11.521/sqlnotes/referential_integrity.html + function MetaForeignKeys($table, $owner=false) + { + global $ADODB_FETCH_MODE; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $table = $this->qstr(strtoupper($table)); + if (!$owner) { + $owner = $this->user; + $tabp = 'user_'; + } else + $tabp = 'all_'; + + $owner = ' and owner='.$this->qstr(strtoupper($owner)); + + $sql = +"select constraint_name,r_owner,r_constraint_name + from {$tabp}constraints + where constraint_type = 'R' and table_name = $table $owner"; + + $constraints = $this->GetArray($sql); + $arr = false; + foreach($constraints as $constr) { + $cons = $this->qstr($constr[0]); + $rowner = $this->qstr($constr[1]); + $rcons = $this->qstr($constr[2]); + $cols = $this->GetArray("select column_name from {$tabp}cons_columns where constraint_name=$cons $owner order by position"); + $tabcol = $this->GetArray("select table_name,column_name from {$tabp}cons_columns where owner=$rowner and constraint_name=$rcons order by position"); + + if ($cols && $tabcol) + for ($i=0, $max=sizeof($cols); $i < $max; $i++) { + $arr[$tabcol[$i][0]] = $cols[$i][0].'='.$tabcol[$i][1]; + } + } + $ADODB_FETCH_MODE = $save; + + return $arr; + } + + + function CharMax() + { + return 4000; + } + + function TextMax() + { + return 4000; + } + + /** + * Quotes a string. + * An example is $db->qstr("Don't bother",magic_quotes_runtime()); + * + * @param s the string to quote + * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). + * This undoes the stupidity of magic quotes for GPC. + * + * @return quoted string to be sent back to database + */ + function qstr($s,$magic_quotes=false) + { + //$nofixquotes=false; + + if ($this->noNullStrings && strlen($s)==0)$s = ' '; + if (!$magic_quotes) { + if ($this->replaceQuote[0] == '\\'){ + $s = str_replace('\\','\\\\',$s); + } + return "'".str_replace("'",$this->replaceQuote,$s)."'"; + } + + // undo magic quotes for " + $s = str_replace('\\"','"',$s); + + $s = str_replace('\\\\','\\',$s); + return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; + + } + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_oci8 extends ADORecordSet { + + var $databaseType = 'oci8'; + var $bind=false; + var $_fieldobjs; + + //var $_arr = false; + + function ADORecordset_oci8($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + case ADODB_FETCH_NUM: + default: + $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + } + + $this->adodbFetchMode = $mode; + $this->_queryID = $queryID; + } + + + function Init() + { + if ($this->_inited) return; + + $this->_inited = true; + if ($this->_queryID) { + + $this->_currentRow = 0; + @$this->_initrs(); + $this->EOF = !$this->_fetch(); + + /* + // based on idea by Gaetano Giunta to detect unusual oracle errors + // see http://phplens.com/lens/lensforum/msgs.php?id=6771 + $err = OCIError($this->_queryID); + if ($err && $this->connection->debug) ADOConnection::outp($err); + */ + + if (!is_array($this->fields)) { + $this->_numOfRows = 0; + $this->fields = array(); + } + } else { + $this->fields = array(); + $this->_numOfRows = 0; + $this->_numOfFields = 0; + $this->EOF = true; + } + } + + function _initrs() + { + $this->_numOfRows = -1; + $this->_numOfFields = OCInumcols($this->_queryID); + if ($this->_numOfFields>0) { + $this->_fieldobjs = array(); + $max = $this->_numOfFields; + for ($i=0;$i<$max; $i++) $this->_fieldobjs[] = $this->_FetchField($i); + } + } + + /* Returns: an object containing field information. + Get column information in the Recordset object. fetchField() can be used in order to obtain information about + fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by + fetchField() is retrieved. */ + + function _FetchField($fieldOffset = -1) + { + $fld = new ADOFieldObject; + $fieldOffset += 1; + $fld->name =OCIcolumnname($this->_queryID, $fieldOffset); + $fld->type = OCIcolumntype($this->_queryID, $fieldOffset); + $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset); + switch($fld->type) { + case 'NUMBER': + $p = OCIColumnPrecision($this->_queryID, $fieldOffset); + $sc = OCIColumnScale($this->_queryID, $fieldOffset); + if ($p != 0 && $sc == 0) $fld->type = 'INT'; + break; + + case 'CLOB': + case 'NCLOB': + case 'BLOB': + $fld->max_length = -1; + break; + } + return $fld; + } + + /* For some reason, OCIcolumnname fails when called after _initrs() so we cache it */ + function FetchField($fieldOffset = -1) + { + return $this->_fieldobjs[$fieldOffset]; + } + + + /* + // 10% speedup to move MoveNext to child class + function _MoveNext() + { + //global $ADODB_EXTENSION;if ($ADODB_EXTENSION) return @adodb_movenext($this); + + if ($this->EOF) return false; + + $this->_currentRow++; + if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) + return true; + $this->EOF = true; + + return false; + } */ + + + function MoveNext() + { + if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { + $this->_currentRow += 1; + return true; + } + if (!$this->EOF) { + $this->_currentRow += 1; + $this->EOF = true; + } + return false; + } + + /* + # does not work as first record is retrieved in _initrs(), so is not included in GetArray() + function GetArray($nRows = -1) + { + global $ADODB_OCI8_GETARRAY; + + if (true || !empty($ADODB_OCI8_GETARRAY)) { + # does not support $ADODB_ANSI_PADDING_OFF + + //OCI_RETURN_NULLS and OCI_RETURN_LOBS is set by OCIfetchstatement + switch($this->adodbFetchMode) { + case ADODB_FETCH_NUM: + + $ncols = @OCIfetchstatement($this->_queryID, $results, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW+OCI_NUM); + $results = array_merge(array($this->fields),$results); + return $results; + + case ADODB_FETCH_ASSOC: + if (ADODB_ASSOC_CASE != 2 || $this->databaseType != 'oci8') break; + + $ncols = @OCIfetchstatement($this->_queryID, $assoc, 0, $nRows, OCI_FETCHSTATEMENT_BY_ROW); + $results = array_merge(array($this->fields),$assoc); + return $results; + + default: + break; + } + } + + $results = ADORecordSet::GetArray($nRows); + return $results; + + } */ + + /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */ + function GetArrayLimit($nrows,$offset=-1) + { + if ($offset <= 0) { + $arr = $this->GetArray($nrows); + return $arr; + } + $arr = array(); + for ($i=1; $i < $offset; $i++) + if (!@OCIFetch($this->_queryID)) return $arr; + + if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) return $arr;; + $results = array(); + $cnt = 0; + while (!$this->EOF && $nrows != $cnt) { + $results[$cnt++] = $this->fields; + $this->MoveNext(); + } + + return $results; + } + + + /* Use associative array to get fields array */ + function Fields($colname) + { + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + + + function _seek($row) + { + return false; + } + + function _fetch() + { + return @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode); + } + + /* close() only needs to be called if you are worried about using too much memory while your script + is running. All associated result memory for the specified result identifier will automatically be freed. */ + + function _close() + { + if ($this->connection->_stmt === $this->_queryID) $this->connection->_stmt = false; + if (!empty($this->_refcursor)) { + OCIFreeCursor($this->_refcursor); + $this->_refcursor = false; + } + @OCIFreeStatement($this->_queryID); + $this->_queryID = false; + + } + + function MetaType($t,$len=-1) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + switch (strtoupper($t)) { + case 'VARCHAR': + case 'VARCHAR2': + case 'CHAR': + case 'VARBINARY': + case 'BINARY': + case 'NCHAR': + case 'NVARCHAR': + case 'NVARCHAR2': + if (isset($this) && $len <= $this->blobSize) return 'C'; + + case 'NCLOB': + case 'LONG': + case 'LONG VARCHAR': + case 'CLOB': + return 'X'; + + case 'LONG RAW': + case 'LONG VARBINARY': + case 'BLOB': + return 'B'; + + case 'DATE': + return ($this->connection->datetime) ? 'T' : 'D'; + + + case 'TIMESTAMP': return 'T'; + + case 'INT': + case 'SMALLINT': + case 'INTEGER': + return 'I'; + + default: return 'N'; + } + } +} + +class ADORecordSet_ext_oci8 extends ADORecordSet_oci8 { + function ADORecordSet_ext_oci8($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_ASSOC:$this->fetchMode = OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH:$this->fetchMode = OCI_NUM+OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + case ADODB_FETCH_NUM: + default: $this->fetchMode = OCI_NUM+OCI_RETURN_NULLS+OCI_RETURN_LOBS; break; + } + $this->adodbFetchMode = $mode; + $this->_queryID = $queryID; + } + + function MoveNext() + { + return adodb_movenext($this); + } +} +?> diff --git a/includes/adodb/drivers/adodb-oci805.inc.php b/includes/adodb/drivers/adodb-oci805.inc.php new file mode 100644 index 00000000..3498f750 --- /dev/null +++ b/includes/adodb/drivers/adodb-oci805.inc.php @@ -0,0 +1,59 @@ +ADODB_oci8(); + } + + function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) + { + // seems that oracle only supports 1 hint comment in 8i + if (strpos($sql,'/*+') !== false) + $sql = str_replace('/*+ ','/*+FIRST_ROWS ',$sql); + else + $sql = preg_replace('/^[ \t\n]*select/i','SELECT /*+FIRST_ROWS*/',$sql); + + /* + The following is only available from 8.1.5 because order by in inline views not + available before then... + http://www.jlcomp.demon.co.uk/faq/top_sql.html + if ($nrows > 0) { + if ($offset > 0) $nrows += $offset; + $sql = "select * from ($sql) where rownum <= $nrows"; + $nrows = -1; + } + */ + + return ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + } +} + +class ADORecordset_oci805 extends ADORecordset_oci8 { + var $databaseType = "oci805"; + function ADORecordset_oci805($id,$mode=false) + { + $this->ADORecordset_oci8($id,$mode); + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-oci8po.inc.php b/includes/adodb/drivers/adodb-oci8po.inc.php new file mode 100644 index 00000000..89246908 --- /dev/null +++ b/includes/adodb/drivers/adodb-oci8po.inc.php @@ -0,0 +1,218 @@ + + + Should some emulation of RecordCount() be implemented? + +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +include_once(ADODB_DIR.'/drivers/adodb-oci8.inc.php'); + +class ADODB_oci8po extends ADODB_oci8 { + var $databaseType = 'oci8po'; + var $dataProvider = 'oci8'; + var $metaColumnsSQL = "select lower(cname),coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname='%s' order by colno"; //changed by smondino@users.sourceforge. net + var $metaTablesSQL = "select lower(table_name),table_type from cat where table_type in ('TABLE','VIEW')"; + + function ADODB_oci8po() + { + $this->_hasOCIFetchStatement = ADODB_PHPVER >= 0x4200; + # oci8po does not support adodb extension: adodb_movenext() + } + + function Param($name) + { + return '?'; + } + + function Prepare($sql,$cursor=false) + { + $sqlarr = explode('?',$sql); + $sql = $sqlarr[0]; + for ($i = 1, $max = sizeof($sqlarr); $i < $max; $i++) { + $sql .= ':'.($i-1) . $sqlarr[$i]; + } + return ADODB_oci8::Prepare($sql,$cursor); + } + + // emulate handling of parameters ? ?, replacing with :bind0 :bind1 + function _query($sql,$inputarr) + { + if (is_array($inputarr)) { + $i = 0; + if (is_array($sql)) { + foreach($inputarr as $v) { + $arr['bind'.$i++] = $v; + } + } else { + $sqlarr = explode('?',$sql); + $sql = $sqlarr[0]; + foreach($inputarr as $k => $v) { + $sql .= ":$k" . $sqlarr[++$i]; + } + } + } + return ADODB_oci8::_query($sql,$inputarr); + } +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_oci8po extends ADORecordset_oci8 { + + var $databaseType = 'oci8po'; + + function ADORecordset_oci8po($queryID,$mode=false) + { + $this->ADORecordset_oci8($queryID,$mode); + } + + function Fields($colname) + { + if ($this->fetchMode & OCI_ASSOC) return $this->fields[$colname]; + + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + // lowercase field names... + function _FetchField($fieldOffset = -1) + { + $fld = new ADOFieldObject; + $fieldOffset += 1; + $fld->name = OCIcolumnname($this->_queryID, $fieldOffset); + if (ADODB_ASSOC_CASE == 0) $fld->name = strtolower($fld->name); + $fld->type = OCIcolumntype($this->_queryID, $fieldOffset); + $fld->max_length = OCIcolumnsize($this->_queryID, $fieldOffset); + if ($fld->type == 'NUMBER') { + //$p = OCIColumnPrecision($this->_queryID, $fieldOffset); + $sc = OCIColumnScale($this->_queryID, $fieldOffset); + if ($sc == 0) $fld->type = 'INT'; + } + return $fld; + } + /* + function MoveNext() + { + if (@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { + $this->_currentRow += 1; + return true; + } + if (!$this->EOF) { + $this->_currentRow += 1; + $this->EOF = true; + } + return false; + }*/ + + // 10% speedup to move MoveNext to child class + function MoveNext() + { + if(@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { + global $ADODB_ANSI_PADDING_OFF; + $this->_currentRow++; + + if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); + if (!empty($ADODB_ANSI_PADDING_OFF)) { + foreach($this->fields as $k => $v) { + if (is_string($v)) $this->fields[$k] = rtrim($v); + } + } + return true; + } + if (!$this->EOF) { + $this->EOF = true; + $this->_currentRow++; + } + return false; + } + + /* Optimize SelectLimit() by using OCIFetch() instead of OCIFetchInto() */ + function GetArrayLimit($nrows,$offset=-1) + { + if ($offset <= 0) { + $arr = $this->GetArray($nrows); + return $arr; + } + for ($i=1; $i < $offset; $i++) + if (!@OCIFetch($this->_queryID)) { + $arr = array(); + return $arr; + } + if (!@OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode)) { + $arr = array(); + return $arr; + } + if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); + $results = array(); + $cnt = 0; + while (!$this->EOF && $nrows != $cnt) { + $results[$cnt++] = $this->fields; + $this->MoveNext(); + } + + return $results; + } + + // Create associative array + function _updatefields() + { + if (ADODB_ASSOC_CASE == 2) return; // native + + $arr = array(); + $lowercase = (ADODB_ASSOC_CASE == 0); + + foreach($this->fields as $k => $v) { + if (is_integer($k)) $arr[$k] = $v; + else { + if ($lowercase) + $arr[strtolower($k)] = $v; + else + $arr[strtoupper($k)] = $v; + } + } + $this->fields = $arr; + } + + function _fetch() + { + $ret = @OCIfetchinto($this->_queryID,$this->fields,$this->fetchMode); + if ($ret) { + global $ADODB_ANSI_PADDING_OFF; + + if ($this->fetchMode & OCI_ASSOC) $this->_updatefields(); + if (!empty($ADODB_ANSI_PADDING_OFF)) { + foreach($this->fields as $k => $v) { + if (is_string($v)) $this->fields[$k] = rtrim($v); + } + } + } + return $ret; + } + +} + + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-odbc.inc.php b/includes/adodb/drivers/adodb-odbc.inc.php new file mode 100644 index 00000000..fc198a6c --- /dev/null +++ b/includes/adodb/drivers/adodb-odbc.inc.php @@ -0,0 +1,738 @@ +_haserrorfunctions = ADODB_PHPVER >= 0x4050; + $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200; + } + + // returns true or false + function _connect($argDSN, $argUsername, $argPassword, $argDatabasename) + { + global $php_errormsg; + + if (!function_exists('odbc_connect')) return null; + + if ($this->debug && $argDatabasename && $this->databaseType != 'vfp') { + ADOConnection::outp("For odbc Connect(), $argDatabasename is not used. Place dsn in 1st parameter."); + } + if (isset($php_errormsg)) $php_errormsg = ''; + if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword); + else $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,$this->curmode); + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + if (isset($this->connectStmt)) $this->Execute($this->connectStmt); + + return $this->_connectionID != false; + } + + // returns true or false + function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) + { + global $php_errormsg; + + if (!function_exists('odbc_connect')) return null; + + if (isset($php_errormsg)) $php_errormsg = ''; + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + if ($this->debug && $argDatabasename) { + ADOConnection::outp("For odbc PConnect(), $argDatabasename is not used. Place dsn in 1st parameter."); + } + // print "dsn=$argDSN u=$argUsername p=$argPassword
"; flush(); + if ($this->curmode === false) $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword); + else $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,$this->curmode); + + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + if ($this->_connectionID && $this->autoRollback) @odbc_rollback($this->_connectionID); + if (isset($this->connectStmt)) $this->Execute($this->connectStmt); + + return $this->_connectionID != false; + } + + + function ServerInfo() + { + + if (!empty($this->host) && ADODB_PHPVER >= 0x4300) { + $dsn = strtoupper($this->host); + $first = true; + $found = false; + + if (!function_exists('odbc_data_source')) return false; + + while(true) { + + $rez = @odbc_data_source($this->_connectionID, + $first ? SQL_FETCH_FIRST : SQL_FETCH_NEXT); + $first = false; + if (!is_array($rez)) break; + if (strtoupper($rez['server']) == $dsn) { + $found = true; + break; + } + } + if (!$found) return ADOConnection::ServerInfo(); + if (!isset($rez['version'])) $rez['version'] = ''; + return $rez; + } else { + return ADOConnection::ServerInfo(); + } + } + + + function CreateSequence($seqname='adodbseq',$start=1) + { + if (empty($this->_genSeqSQL)) return false; + $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); + if (!$ok) return false; + $start -= 1; + return $this->Execute("insert into $seqname values($start)"); + } + + var $_dropSeqSQL = 'drop table %s'; + function DropSequence($seqname) + { + if (empty($this->_dropSeqSQL)) return false; + return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); + } + + /* + This algorithm is not very efficient, but works even if table locking + is not available. + + Will return false if unable to generate an ID after $MAXLOOPS attempts. + */ + function GenID($seq='adodbseq',$start=1) + { + // if you have to modify the parameter below, your database is overloaded, + // or you need to implement generation of id's yourself! + $MAXLOOPS = 100; + //$this->debug=1; + while (--$MAXLOOPS>=0) { + $num = $this->GetOne("select id from $seq"); + if ($num === false) { + $this->Execute(sprintf($this->_genSeqSQL ,$seq)); + $start -= 1; + $num = '0'; + $ok = $this->Execute("insert into $seq values($start)"); + if (!$ok) return false; + } + $this->Execute("update $seq set id=id+1 where id=$num"); + + if ($this->affected_rows() > 0) { + $num += 1; + $this->genID = $num; + return $num; + } + } + if ($fn = $this->raiseErrorFn) { + $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num); + } + return false; + } + + + function ErrorMsg() + { + if ($this->_haserrorfunctions) { + if ($this->_errorMsg !== false) return $this->_errorMsg; + if (empty($this->_connectionID)) return @odbc_errormsg(); + return @odbc_errormsg($this->_connectionID); + } else return ADOConnection::ErrorMsg(); + } + + function ErrorNo() + { + + if ($this->_haserrorfunctions) { + if ($this->_errorCode !== false) { + // bug in 4.0.6, error number can be corrupted string (should be 6 digits) + return (strlen($this->_errorCode)<=2) ? 0 : $this->_errorCode; + } + + if (empty($this->_connectionID)) $e = @odbc_error(); + else $e = @odbc_error($this->_connectionID); + + // bug in 4.0.6, error number can be corrupted string (should be 6 digits) + // so we check and patch + if (strlen($e)<=2) return 0; + return $e; + } else return ADOConnection::ErrorNo(); + } + + + + function BeginTrans() + { + if (!$this->hasTransactions) return false; + if ($this->transOff) return true; + $this->transCnt += 1; + $this->_autocommit = false; + return odbc_autocommit($this->_connectionID,false); + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + if ($this->transCnt) $this->transCnt -= 1; + $this->_autocommit = true; + $ret = odbc_commit($this->_connectionID); + odbc_autocommit($this->_connectionID,true); + return $ret; + } + + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $this->_autocommit = true; + $ret = odbc_rollback($this->_connectionID); + odbc_autocommit($this->_connectionID,true); + return $ret; + } + + function MetaPrimaryKeys($table) + { + global $ADODB_FETCH_MODE; + + if ($this->uCaseTables) $table = strtoupper($table); + $schema = ''; + $this->_findschema($table,$schema); + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $qid = @odbc_primarykeys($this->_connectionID,'',$schema,$table); + + if (!$qid) { + $ADODB_FETCH_MODE = $savem; + return false; + } + $rs = new ADORecordSet_odbc($qid); + $ADODB_FETCH_MODE = $savem; + + if (!$rs) return false; + $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; + + $arr = $rs->GetArray(); + $rs->Close(); + //print_r($arr); + $arr2 = array(); + for ($i=0; $i < sizeof($arr); $i++) { + if ($arr[$i][3]) $arr2[] = $arr[$i][3]; + } + return $arr2; + } + + + + function MetaTables($ttype=false) + { + global $ADODB_FETCH_MODE; + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $qid = odbc_tables($this->_connectionID); + + $rs = new ADORecordSet_odbc($qid); + + $ADODB_FETCH_MODE = $savem; + if (!$rs) { + $false = false; + return $false; + } + $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; + + $arr = $rs->GetArray(); + //print_r($arr); + + $rs->Close(); + $arr2 = array(); + + if ($ttype) { + $isview = strncmp($ttype,'V',1) === 0; + } + for ($i=0; $i < sizeof($arr); $i++) { + if (!$arr[$i][2]) continue; + $type = $arr[$i][3]; + if ($ttype) { + if ($isview) { + if (strncmp($type,'V',1) === 0) $arr2[] = $arr[$i][2]; + } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2]; + } else if (strncmp($type,'SYS',3) !== 0) $arr2[] = $arr[$i][2]; + } + return $arr2; + } + +/* +See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcdatetime_data_type_changes.asp +/ SQL data type codes / +#define SQL_UNKNOWN_TYPE 0 +#define SQL_CHAR 1 +#define SQL_NUMERIC 2 +#define SQL_DECIMAL 3 +#define SQL_INTEGER 4 +#define SQL_SMALLINT 5 +#define SQL_FLOAT 6 +#define SQL_REAL 7 +#define SQL_DOUBLE 8 +#if (ODBCVER >= 0x0300) +#define SQL_DATETIME 9 +#endif +#define SQL_VARCHAR 12 + + +/ One-parameter shortcuts for date/time data types / +#if (ODBCVER >= 0x0300) +#define SQL_TYPE_DATE 91 +#define SQL_TYPE_TIME 92 +#define SQL_TYPE_TIMESTAMP 93 + +#define SQL_UNICODE (-95) +#define SQL_UNICODE_VARCHAR (-96) +#define SQL_UNICODE_LONGVARCHAR (-97) +*/ + function ODBCTypes($t) + { + switch ((integer)$t) { + case 1: + case 12: + case 0: + case -95: + case -96: + return 'C'; + case -97: + case -1: //text + return 'X'; + case -4: //image + return 'B'; + + case 9: + case 91: + return 'D'; + + case 10: + case 11: + case 92: + case 93: + return 'T'; + + case 4: + case 5: + case -6: + return 'I'; + + case -11: // uniqidentifier + return 'R'; + case -7: //bit + return 'L'; + + default: + return 'N'; + } + } + + function MetaColumns($table) + { + global $ADODB_FETCH_MODE; + + $false = false; + if ($this->uCaseTables) $table = strtoupper($table); + $schema = ''; + $this->_findschema($table,$schema); + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + /*if (false) { // after testing, confirmed that the following does not work becoz of a bug + $qid2 = odbc_tables($this->_connectionID); + $rs = new ADORecordSet_odbc($qid2); + $ADODB_FETCH_MODE = $savem; + if (!$rs) return false; + $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; + $rs->_fetch(); + + while (!$rs->EOF) { + if ($table == strtoupper($rs->fields[2])) { + $q = $rs->fields[0]; + $o = $rs->fields[1]; + break; + } + $rs->MoveNext(); + } + $rs->Close(); + + $qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%'); + } */ + + switch ($this->databaseType) { + case 'access': + case 'vfp': + $qid = odbc_columns($this->_connectionID);#,'%','',strtoupper($table),'%'); + break; + + + case 'db2': + $colname = "%"; + $qid = odbc_columns($this->_connectionID, "", $schema, $table, $colname); + break; + + default: + $qid = @odbc_columns($this->_connectionID,'%','%',strtoupper($table),'%'); + if (empty($qid)) $qid = odbc_columns($this->_connectionID); + break; + } + if (empty($qid)) return $false; + + $rs = new ADORecordSet_odbc($qid); + $ADODB_FETCH_MODE = $savem; + + if (!$rs) return $false; + $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; + $rs->_fetch(); + + $retarr = array(); + + /* + $rs->fields indices + 0 TABLE_QUALIFIER + 1 TABLE_SCHEM + 2 TABLE_NAME + 3 COLUMN_NAME + 4 DATA_TYPE + 5 TYPE_NAME + 6 PRECISION + 7 LENGTH + 8 SCALE + 9 RADIX + 10 NULLABLE + 11 REMARKS + */ + while (!$rs->EOF) { + // adodb_pr($rs->fields); + if (strtoupper(trim($rs->fields[2])) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) { + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[3]; + $fld->type = $this->ODBCTypes($rs->fields[4]); + + // ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp + // access uses precision to store length for char/varchar + if ($fld->type == 'C' or $fld->type == 'X') { + if ($this->databaseType == 'access') + $fld->max_length = $rs->fields[6]; + else if ($rs->fields[4] <= -95) // UNICODE + $fld->max_length = $rs->fields[7]/2; + else + $fld->max_length = $rs->fields[7]; + } else + $fld->max_length = $rs->fields[7]; + $fld->not_null = !empty($rs->fields[10]); + $fld->scale = $rs->fields[8]; + $retarr[strtoupper($fld->name)] = $fld; + } else if (sizeof($retarr)>0) + break; + $rs->MoveNext(); + } + $rs->Close(); //-- crashes 4.03pl1 -- why? + + if (empty($retarr)) $retarr = false; + return $retarr; + } + + function Prepare($sql) + { + if (! $this->_bindInputArray) return $sql; // no binding + $stmt = odbc_prepare($this->_connectionID,$sql); + if (!$stmt) { + // we don't know whether odbc driver is parsing prepared stmts, so just return sql + return $sql; + } + return array($sql,$stmt,false); + } + + /* returns queryID or false */ + function _query($sql,$inputarr=false) + { + GLOBAL $php_errormsg; + if (isset($php_errormsg)) $php_errormsg = ''; + $this->_error = ''; + + if ($inputarr) { + if (is_array($sql)) { + $stmtid = $sql[1]; + } else { + $stmtid = odbc_prepare($this->_connectionID,$sql); + + if ($stmtid == false) { + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + return false; + } + } + + if (! odbc_execute($stmtid,$inputarr)) { + //@odbc_free_result($stmtid); + if ($this->_haserrorfunctions) { + $this->_errorMsg = odbc_errormsg(); + $this->_errorCode = odbc_error(); + } + return false; + } + + } else if (is_array($sql)) { + $stmtid = $sql[1]; + if (!odbc_execute($stmtid)) { + //@odbc_free_result($stmtid); + if ($this->_haserrorfunctions) { + $this->_errorMsg = odbc_errormsg(); + $this->_errorCode = odbc_error(); + } + return false; + } + } else + $stmtid = odbc_exec($this->_connectionID,$sql); + + $this->_lastAffectedRows = 0; + if ($stmtid) { + if (@odbc_num_fields($stmtid) == 0) { + $this->_lastAffectedRows = odbc_num_rows($stmtid); + $stmtid = true; + } else { + $this->_lastAffectedRows = 0; + odbc_binmode($stmtid,$this->binmode); + odbc_longreadlen($stmtid,$this->maxblobsize); + } + + if ($this->_haserrorfunctions) { + $this->_errorMsg = ''; + $this->_errorCode = 0; + } else + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + } else { + if ($this->_haserrorfunctions) { + $this->_errorMsg = odbc_errormsg(); + $this->_errorCode = odbc_error(); + } else + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : ''; + } + return $stmtid; + } + + /* + Insert a null into the blob field of the table first. + Then use UpdateBlob to store the blob. + + Usage: + + $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); + $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); + */ + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false; + } + + // returns true or false + function _close() + { + $ret = @odbc_close($this->_connectionID); + $this->_connectionID = false; + return $ret; + } + + function _affectedrows() + { + return $this->_lastAffectedRows; + } + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordSet_odbc extends ADORecordSet { + + var $bind = false; + var $databaseType = "odbc"; + var $dataProvider = "odbc"; + var $useFetchArray; + var $_has_stupid_odbc_fetch_api_change; + + function ADORecordSet_odbc($id,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + $this->fetchMode = $mode; + + $this->_queryID = $id; + + // the following is required for mysql odbc driver in 4.3.1 -- why? + $this->EOF = false; + $this->_currentRow = -1; + //$this->ADORecordSet($id); + } + + + // returns the field object + function FetchField($fieldOffset = -1) + { + + $off=$fieldOffset+1; // offsets begin at 1 + + $o= new ADOFieldObject(); + $o->name = @odbc_field_name($this->_queryID,$off); + $o->type = @odbc_field_type($this->_queryID,$off); + $o->max_length = @odbc_field_len($this->_queryID,$off); + if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name); + else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name); + return $o; + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + + function _initrs() + { + global $ADODB_COUNTRECS; + $this->_numOfRows = ($ADODB_COUNTRECS) ? @odbc_num_rows($this->_queryID) : -1; + $this->_numOfFields = @odbc_num_fields($this->_queryID); + // some silly drivers such as db2 as/400 and intersystems cache return _numOfRows = 0 + if ($this->_numOfRows == 0) $this->_numOfRows = -1; + //$this->useFetchArray = $this->connection->useFetchArray; + $this->_has_stupid_odbc_fetch_api_change = ADODB_PHPVER >= 0x4200; + } + + function _seek($row) + { + return false; + } + + // speed up SelectLimit() by switching to ADODB_FETCH_NUM as ADODB_FETCH_ASSOC is emulated + function GetArrayLimit($nrows,$offset=-1) + { + if ($offset <= 0) { + $rs = $this->GetArray($nrows); + return $rs; + } + $savem = $this->fetchMode; + $this->fetchMode = ADODB_FETCH_NUM; + $this->Move($offset); + $this->fetchMode = $savem; + + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); + } + + $results = array(); + $cnt = 0; + while (!$this->EOF && $nrows != $cnt) { + $results[$cnt++] = $this->fields; + $this->MoveNext(); + } + + return $results; + } + + + function MoveNext() + { + if ($this->_numOfRows != 0 && !$this->EOF) { + $this->_currentRow++; + + if ($this->_has_stupid_odbc_fetch_api_change) + $rez = @odbc_fetch_into($this->_queryID,$this->fields); + else { + $row = 0; + $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields); + } + if ($rez) { + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); + } + return true; + } + } + $this->fields = false; + $this->EOF = true; + return false; + } + + function _fetch() + { + + if ($this->_has_stupid_odbc_fetch_api_change) + $rez = @odbc_fetch_into($this->_queryID,$this->fields); + else { + $row = 0; + $rez = @odbc_fetch_into($this->_queryID,$row,$this->fields); + } + if ($rez) { + if ($this->fetchMode & ADODB_FETCH_ASSOC) { + $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); + } + return true; + } + $this->fields = false; + return false; + } + + function _close() + { + return @odbc_free_result($this->_queryID); + } + +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-odbc_db2.inc.php b/includes/adodb/drivers/adodb-odbc_db2.inc.php new file mode 100644 index 00000000..6e5b2889 --- /dev/null +++ b/includes/adodb/drivers/adodb-odbc_db2.inc.php @@ -0,0 +1,368 @@ +curMode = SQL_CUR_USE_ODBC; +$db->Connect($dsn, $userid, $pwd); + + + +USING CLI INTERFACE +=================== + +I have had reports that the $host and $database params have to be reversed in +Connect() when using the CLI interface. From Halmai Csongor csongor.halmai#nexum.hu: + +> The symptom is that if I change the database engine from postgres or any other to DB2 then the following +> connection command becomes wrong despite being described this version to be correct in the docs. +> +> $connection_object->Connect( $DATABASE_HOST, $DATABASE_AUTH_USER_NAME, $DATABASE_AUTH_PASSWORD, $DATABASE_NAME ) +> +> In case of DB2 I had to swap the first and last arguments in order to connect properly. + + +System Error 5 +============== +IF you get a System Error 5 when trying to Connect/Load, it could be a permission problem. Give the user connecting +to DB2 full rights to the DB2 SQLLIB directory, and place the user in the DBUSERS group. +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +if (!defined('_ADODB_ODBC_LAYER')) { + include(ADODB_DIR."/drivers/adodb-odbc.inc.php"); +} +if (!defined('ADODB_ODBC_DB2')){ +define('ADODB_ODBC_DB2',1); + +class ADODB_ODBC_DB2 extends ADODB_odbc { + var $databaseType = "db2"; + var $concat_operator = '||'; + var $sysTime = 'CURRENT TIME'; + var $sysDate = 'CURRENT DATE'; + var $sysTimeStamp = 'CURRENT TIMESTAMP'; + // The complete string representation of a timestamp has the form + // yyyy-mm-dd-hh.mm.ss.nnnnnn. + var $fmtTimeStamp = "'Y-m-d-H.i.s'"; + var $ansiOuter = true; + var $identitySQL = 'values IDENTITY_VAL_LOCAL()'; + var $_bindInputArray = true; + var $hasInsertID = true; + var $rsPrefix = 'ADORecordset_odbc_'; + + function ADODB_DB2() + { + if (strncmp(PHP_OS,'WIN',3) === 0) $this->curmode = SQL_CUR_USE_ODBC; + $this->ADODB_odbc(); + } + + function IfNull( $field, $ifNull ) + { + return " COALESCE($field, $ifNull) "; // if DB2 UDB + } + + function ServerInfo() + { + //odbc_setoption($this->_connectionID,1,101 /*SQL_ATTR_ACCESS_MODE*/, 1 /*SQL_MODE_READ_ONLY*/); + $vers = $this->GetOne('select versionnumber from sysibm.sysversions'); + //odbc_setoption($this->_connectionID,1,101, 0 /*SQL_MODE_READ_WRITE*/); + return array('description'=>'DB2 ODBC driver', 'version'=>$vers); + } + + function _insertid() + { + return $this->GetOne($this->identitySQL); + } + + function RowLock($tables,$where,$flds='1 as ignore') + { + if ($this->_autocommit) $this->BeginTrans(); + return $this->GetOne("select $flds from $tables where $where for update"); + } + + function MetaTables($ttype=false,$showSchema=false, $qtable="%", $qschema="%") + { + global $ADODB_FETCH_MODE; + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $qid = odbc_tables($this->_connectionID, "", $qschema, $qtable, ""); + + $rs = new ADORecordSet_odbc($qid); + + $ADODB_FETCH_MODE = $savem; + if (!$rs) { + $false = false; + return $false; + } + $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change; + + $arr = $rs->GetArray(); + //print_r($arr); + + $rs->Close(); + $arr2 = array(); + + if ($ttype) { + $isview = strncmp($ttype,'V',1) === 0; + } + for ($i=0; $i < sizeof($arr); $i++) { + + if (!$arr[$i][2]) continue; + if (strncmp($arr[$i][1],'SYS',3) === 0) continue; + + $type = $arr[$i][3]; + + if ($showSchema) $arr[$i][2] = $arr[$i][1].'.'.$arr[$i][2]; + + if ($ttype) { + if ($isview) { + if (strncmp($type,'V',1) === 0) $arr2[] = $arr[$i][2]; + } else if (strncmp($type,'T',1) === 0) $arr2[] = $arr[$i][2]; + } else if (strncmp($type,'S',1) !== 0) $arr2[] = $arr[$i][2]; + } + return $arr2; + } + + function MetaIndexes ($table, $primary = FALSE, $owner=false) + { + // save old fetch mode + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + $false = false; + // get index details + $table = strtoupper($table); + $SQL="SELECT NAME, UNIQUERULE, COLNAMES FROM SYSIBM.SYSINDEXES WHERE TBNAME='$table'"; + if ($primary) + $SQL.= " AND UNIQUERULE='P'"; + $rs = $this->Execute($SQL); + if (!is_object($rs)) { + if (isset($savem)) + $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + return $false; + } + $indexes = array (); + // parse index data into array + while ($row = $rs->FetchRow()) { + $indexes[$row[0]] = array( + 'unique' => ($row[1] == 'U' || $row[1] == 'P'), + 'columns' => array() + ); + $cols = ltrim($row[2],'+'); + $indexes[$row[0]]['columns'] = explode('+', $cols); + } + if (isset($savem)) { + $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + } + return $indexes; + } + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + // use right() and replace() ? + if (!$col) $col = $this->sysDate; + $s = ''; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + if ($s) $s .= '||'; + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + $s .= "char(year($col))"; + break; + case 'M': + $s .= "substr(monthname($col),1,3)"; + break; + case 'm': + $s .= "right(digits(month($col)),2)"; + break; + case 'D': + case 'd': + $s .= "right(digits(day($col)),2)"; + break; + case 'H': + case 'h': + if ($col != $this->sysDate) $s .= "right(digits(hour($col)),2)"; + else $s .= "''"; + break; + case 'i': + case 'I': + if ($col != $this->sysDate) + $s .= "right(digits(minute($col)),2)"; + else $s .= "''"; + break; + case 'S': + case 's': + if ($col != $this->sysDate) + $s .= "right(digits(second($col)),2)"; + else $s .= "''"; + break; + default: + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + $s .= $this->qstr($ch); + } + } + return $s; + } + + + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputArr=false) + { + $nrows = (integer) $nrows; + if ($offset <= 0) { + // could also use " OPTIMIZE FOR $nrows ROWS " + if ($nrows >= 0) $sql .= " FETCH FIRST $nrows ROWS ONLY "; + $rs = $this->Execute($sql,$inputArr); + } else { + if ($offset > 0 && $nrows < 0); + else { + $nrows += $offset; + $sql .= " FETCH FIRST $nrows ROWS ONLY "; + } + $rs = ADOConnection::SelectLimit($sql,-1,$offset,$inputArr); + } + + return $rs; + } + +}; + + +class ADORecordSet_odbc_db2 extends ADORecordSet_odbc { + + var $databaseType = "db2"; + + function ADORecordSet_db2($id,$mode=false) + { + $this->ADORecordSet_odbc($id,$mode); + } + + function MetaType($t,$len=-1,$fieldobj=false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + + switch (strtoupper($t)) { + case 'VARCHAR': + case 'CHAR': + case 'CHARACTER': + case 'C': + if ($len <= $this->blobSize) return 'C'; + + case 'LONGCHAR': + case 'TEXT': + case 'CLOB': + case 'DBCLOB': // double-byte + case 'X': + return 'X'; + + case 'BLOB': + case 'GRAPHIC': + case 'VARGRAPHIC': + return 'B'; + + case 'DATE': + case 'D': + return 'D'; + + case 'TIME': + case 'TIMESTAMP': + case 'T': + return 'T'; + + //case 'BOOLEAN': + //case 'BIT': + // return 'L'; + + //case 'COUNTER': + // return 'R'; + + case 'INT': + case 'INTEGER': + case 'BIGINT': + case 'SMALLINT': + case 'I': + return 'I'; + + default: return 'N'; + } + } +} + +} //define +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-odbc_mssql.inc.php b/includes/adodb/drivers/adodb-odbc_mssql.inc.php new file mode 100644 index 00000000..71e13c78 --- /dev/null +++ b/includes/adodb/drivers/adodb-odbc_mssql.inc.php @@ -0,0 +1,306 @@ +ADODB_odbc(); + //$this->curmode = SQL_CUR_USE_ODBC; + } + + // crashes php... + function ServerInfo() + { + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $row = $this->GetRow("execute sp_server_info 2"); + $ADODB_FETCH_MODE = $save; + if (!is_array($row)) return false; + $arr['description'] = $row[2]; + $arr['version'] = ADOConnection::_findvers($arr['description']); + return $arr; + } + + function IfNull( $field, $ifNull ) + { + return " ISNULL($field, $ifNull) "; // if MS SQL Server + } + + function _insertid() + { + // SCOPE_IDENTITY() + // Returns the last IDENTITY value inserted into an IDENTITY column in + // the same scope. A scope is a module -- a stored procedure, trigger, + // function, or batch. Thus, two statements are in the same scope if + // they are in the same stored procedure, function, or batch. + return $this->GetOne($this->identitySQL); + } + + + function MetaForeignKeys($table, $owner=false, $upper=false) + { + global $ADODB_FETCH_MODE; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $table = $this->qstr(strtoupper($table)); + + $sql = +"select object_name(constid) as constraint_name, + col_name(fkeyid, fkey) as column_name, + object_name(rkeyid) as referenced_table_name, + col_name(rkeyid, rkey) as referenced_column_name +from sysforeignkeys +where upper(object_name(fkeyid)) = $table +order by constraint_name, referenced_table_name, keyno"; + + $constraints = $this->GetArray($sql); + + $ADODB_FETCH_MODE = $save; + + $arr = false; + foreach($constraints as $constr) { + //print_r($constr); + $arr[$constr[0]][$constr[2]][] = $constr[1].'='.$constr[3]; + } + if (!$arr) return false; + + $arr2 = false; + + foreach($arr as $k => $v) { + foreach($v as $a => $b) { + if ($upper) $a = strtoupper($a); + $arr2[$a] = $b; + } + } + return $arr2; + } + + function MetaTables($ttype=false,$showSchema=false,$mask=false) + { + if ($mask) {$this->debug=1; + $save = $this->metaTablesSQL; + $mask = $this->qstr($mask); + $this->metaTablesSQL .= " AND name like $mask"; + } + $ret = ADOConnection::MetaTables($ttype,$showSchema); + + if ($mask) { + $this->metaTablesSQL = $save; + } + return $ret; + } + + function MetaColumns($table) + { + $arr = ADOConnection::MetaColumns($table); + return $arr; + } + + + function MetaIndexes($table,$primary=false) + { + $table = $this->qstr($table); + + $sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno, + CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK, + CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique + FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id + INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid + INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid + WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND O.Name LIKE $table + ORDER BY O.name, I.Name, K.keyno"; + + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + + $rs = $this->Execute($sql); + if (isset($savem)) { + $this->SetFetchMode($savem); + } + $ADODB_FETCH_MODE = $save; + + if (!is_object($rs)) { + return FALSE; + } + + $indexes = array(); + while ($row = $rs->FetchRow()) { + if (!$primary && $row[5]) continue; + + $indexes[$row[0]]['unique'] = $row[6]; + $indexes[$row[0]]['columns'][] = $row[1]; + } + return $indexes; + } + + function _query($sql,$inputarr) + { + if (is_string($sql)) $sql = str_replace('||','+',$sql); + return ADODB_odbc::_query($sql,$inputarr); + } + + function SetTransactionMode( $transaction_mode ) + { + $this->_transmode = $transaction_mode; + if (empty($transaction_mode)) { + $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); + return; + } + if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; + $this->Execute("SET TRANSACTION ".$transaction_mode); + } + + // "Stein-Aksel Basma" + // tested with MSSQL 2000 + function MetaPrimaryKeys($table) + { + global $ADODB_FETCH_MODE; + + $schema = ''; + $this->_findschema($table,$schema); + //if (!$schema) $schema = $this->database; + if ($schema) $schema = "and k.table_catalog like '$schema%'"; + + $sql = "select distinct k.column_name,ordinal_position from information_schema.key_column_usage k, + information_schema.table_constraints tc + where tc.constraint_name = k.constraint_name and tc.constraint_type = + 'PRIMARY KEY' and k.table_name = '$table' $schema order by ordinal_position "; + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $a = $this->GetCol($sql); + $ADODB_FETCH_MODE = $savem; + + if ($a && sizeof($a)>0) return $a; + $false = false; + return $false; + } + + function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) + { + if ($nrows > 0 && $offset <= 0) { + $sql = preg_replace( + '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop." $nrows ",$sql); + $rs = $this->Execute($sql,$inputarr); + } else + $rs = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + + return $rs; + } + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysTimeStamp; + $s = ''; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + if ($s) $s .= '+'; + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + $s .= "datename(yyyy,$col)"; + break; + case 'M': + $s .= "convert(char(3),$col,0)"; + break; + case 'm': + $s .= "replace(str(month($col),2),' ','0')"; + break; + case 'Q': + case 'q': + $s .= "datename(quarter,$col)"; + break; + case 'D': + case 'd': + $s .= "replace(str(day($col),2),' ','0')"; + break; + case 'h': + $s .= "substring(convert(char(14),$col,0),13,2)"; + break; + + case 'H': + $s .= "replace(str(datepart(hh,$col),2),' ','0')"; + break; + + case 'i': + $s .= "replace(str(datepart(mi,$col),2),' ','0')"; + break; + case 's': + $s .= "replace(str(datepart(ss,$col),2),' ','0')"; + break; + case 'a': + case 'A': + $s .= "substring(convert(char(19),$col,0),18,2)"; + break; + + default: + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + $s .= $this->qstr($ch); + break; + } + } + return $s; + } + +} + +class ADORecordSet_odbc_mssql extends ADORecordSet_odbc { + + var $databaseType = 'odbc_mssql'; + + function ADORecordSet_odbc_mssql($id,$mode=false) + { + return $this->ADORecordSet_odbc($id,$mode); + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-odbc_oracle.inc.php b/includes/adodb/drivers/adodb-odbc_oracle.inc.php new file mode 100644 index 00000000..de2349f7 --- /dev/null +++ b/includes/adodb/drivers/adodb-odbc_oracle.inc.php @@ -0,0 +1,115 @@ +ADODB_odbc(); + } + + function MetaTables() + { + $false = false; + $rs = $this->Execute($this->metaTablesSQL); + if ($rs === false) return $false; + $arr = $rs->GetArray(); + $arr2 = array(); + for ($i=0; $i < sizeof($arr); $i++) { + $arr2[] = $arr[$i][0]; + } + $rs->Close(); + return $arr2; + } + + function MetaColumns($table) + { + global $ADODB_FETCH_MODE; + + $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); + if ($rs === false) { + $false = false; + return $false; + } + $retarr = array(); + while (!$rs->EOF) { //print_r($rs->fields); + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $fld->type = $rs->fields[1]; + $fld->max_length = $rs->fields[2]; + + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + else $retarr[strtoupper($fld->name)] = $fld; + + $rs->MoveNext(); + } + $rs->Close(); + return $retarr; + } + + // returns true or false + function _connect($argDSN, $argUsername, $argPassword, $argDatabasename) + { + global $php_errormsg; + + $php_errormsg = ''; + $this->_connectionID = odbc_connect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC ); + $this->_errorMsg = $php_errormsg; + + $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"); + //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); + return $this->_connectionID != false; + } + // returns true or false + function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) + { + global $php_errormsg; + $php_errormsg = ''; + $this->_connectionID = odbc_pconnect($argDSN,$argUsername,$argPassword,SQL_CUR_USE_ODBC ); + $this->_errorMsg = $php_errormsg; + + $this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'"); + //if ($this->_connectionID) odbc_autocommit($this->_connectionID,true); + return $this->_connectionID != false; + } +} + +class ADORecordSet_odbc_oracle extends ADORecordSet_odbc { + + var $databaseType = 'odbc_oracle'; + + function ADORecordSet_odbc_oracle($id,$mode=false) + { + return $this->ADORecordSet_odbc($id,$mode); + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-odbtp.inc.php b/includes/adodb/drivers/adodb-odbtp.inc.php new file mode 100644 index 00000000..b4b6ed0b --- /dev/null +++ b/includes/adodb/drivers/adodb-odbtp.inc.php @@ -0,0 +1,793 @@ + + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +define("_ADODB_ODBTP_LAYER", 2 ); + +class ADODB_odbtp extends ADOConnection{ + var $databaseType = "odbtp"; + var $dataProvider = "odbtp"; + var $fmtDate = "'Y-m-d'"; + var $fmtTimeStamp = "'Y-m-d, h:i:sA'"; + var $replaceQuote = "''"; // string to use to replace quotes + var $odbc_driver = 0; + var $hasAffectedRows = true; + var $hasInsertID = false; + var $hasGenID = true; + var $hasMoveFirst = true; + + var $_genSeqSQL = "create table %s (seq_name char(30) not null unique , seq_value integer not null)"; + var $_dropSeqSQL = "delete from adodb_seq where seq_name = '%s'"; + var $_bindInputArray = false; + var $_useUnicodeSQL = false; + var $_canPrepareSP = false; + var $_dontPoolDBC = true; + + function ADODB_odbtp() + { + } + + function ServerInfo() + { + return array('description' => @odbtp_get_attr( ODB_ATTR_DBMSNAME, $this->_connectionID), + 'version' => @odbtp_get_attr( ODB_ATTR_DBMSVER, $this->_connectionID)); + } + + function ErrorMsg() + { + if (empty($this->_connectionID)) return @odbtp_last_error(); + return @odbtp_last_error($this->_connectionID); + } + + function ErrorNo() + { + if (empty($this->_connectionID)) return @odbtp_last_error_state(); + return @odbtp_last_error_state($this->_connectionID); + } + + function _insertid() + { + // SCOPE_IDENTITY() + // Returns the last IDENTITY value inserted into an IDENTITY column in + // the same scope. A scope is a module -- a stored procedure, trigger, + // function, or batch. Thus, two statements are in the same scope if + // they are in the same stored procedure, function, or batch. + return $this->GetOne($this->identitySQL); + } + + function _affectedrows() + { + if ($this->_queryID) { + return @odbtp_affected_rows ($this->_queryID); + } else + return 0; + } + + function CreateSequence($seqname='adodbseq',$start=1) + { + //verify existence + $num = $this->GetOne("select seq_value from adodb_seq"); + $seqtab='adodb_seq'; + if( $this->odbc_driver == ODB_DRIVER_FOXPRO ) { + $path = @odbtp_get_attr( ODB_ATTR_DATABASENAME, $this->_connectionID ); + //if using vfp dbc file + if( !strcasecmp(strrchr($path, '.'), '.dbc') ) + $path = substr($path,0,strrpos($path,'\/')); + $seqtab = $path . '/' . $seqtab; + } + if($num == false) { + if (empty($this->_genSeqSQL)) return false; + $ok = $this->Execute(sprintf($this->_genSeqSQL ,$seqtab)); + } + $num = $this->GetOne("select seq_value from adodb_seq where seq_name='$seqname'"); + if ($num) { + return false; + } + $start -= 1; + return $this->Execute("insert into adodb_seq values('$seqname',$start)"); + } + + function DropSequence($seqname) + { + if (empty($this->_dropSeqSQL)) return false; + return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); + } + + function GenID($seq='adodbseq',$start=1) + { + $seqtab='adodb_seq'; + if( $this->odbc_driver == ODB_DRIVER_FOXPRO) { + $path = @odbtp_get_attr( ODB_ATTR_DATABASENAME, $this->_connectionID ); + //if using vfp dbc file + if( !strcasecmp(strrchr($path, '.'), '.dbc') ) + $path = substr($path,0,strrpos($path,'\/')); + $seqtab = $path . '/' . $seqtab; + } + $MAXLOOPS = 100; + while (--$MAXLOOPS>=0) { + $num = $this->GetOne("select seq_value from adodb_seq where seq_name='$seq'"); + if ($num === false) { + //verify if abodb_seq table exist + $ok = $this->GetOne("select seq_value from adodb_seq "); + if(!$ok) { + //creating the sequence table adodb_seq + $this->Execute(sprintf($this->_genSeqSQL ,$seqtab)); + } + $start -= 1; + $num = '0'; + $ok = $this->Execute("insert into adodb_seq values('$seq',$start)"); + if (!$ok) return false; + } + $ok = $this->Execute("update adodb_seq set seq_value=seq_value+1 where seq_name='$seq'"); + if($ok) { + $num += 1; + $this->genID = $num; + return $num; + } + } + if ($fn = $this->raiseErrorFn) { + $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num); + } + return false; + } + + //example for $UserOrDSN + //for visual fox : DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBF;SOURCEDB=c:\YourDbfFileDir;EXCLUSIVE=NO; + //for visual fox dbc: DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=DBC;SOURCEDB=c:\YourDbcFileDir\mydb.dbc;EXCLUSIVE=NO; + //for access : DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\path_to_access_db\base_test.mdb;UID=root;PWD=; + //for mssql : DRIVER={SQL Server};SERVER=myserver;UID=myuid;PWD=mypwd;DATABASE=OdbtpTest; + //if uid & pwd can be separate + function _connect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='') + { + $this->_connectionID = odbtp_connect($HostOrInterface,$UserOrDSN,$argPassword,$argDatabase); + if ($this->_connectionID === false) { + $this->_errorMsg = $this->ErrorMsg() ; + return false; + } + + odbtp_convert_datetime($this->_connectionID,true); + + if ($this->_dontPoolDBC) { + if (function_exists('odbtp_dont_pool_dbc')) + @odbtp_dont_pool_dbc($this->_connectionID); + } + else { + $this->_dontPoolDBC = true; + } + $this->odbc_driver = @odbtp_get_attr(ODB_ATTR_DRIVER, $this->_connectionID); + $dbms = strtolower(@odbtp_get_attr(ODB_ATTR_DBMSNAME, $this->_connectionID)); + $this->odbc_name = $dbms; + + // Account for inconsistent DBMS names + if( $this->odbc_driver == ODB_DRIVER_ORACLE ) + $dbms = 'oracle'; + else if( $this->odbc_driver == ODB_DRIVER_SYBASE ) + $dbms = 'sybase'; + + // Set DBMS specific attributes + switch( $dbms ) { + case 'microsoft sql server': + $this->databaseType = 'odbtp_mssql'; + $this->fmtDate = "'Y-m-d'"; + $this->fmtTimeStamp = "'Y-m-d h:i:sA'"; + $this->sysDate = 'convert(datetime,convert(char,GetDate(),102),102)'; + $this->sysTimeStamp = 'GetDate()'; + $this->ansiOuter = true; + $this->leftOuter = '*='; + $this->rightOuter = '=*'; + $this->hasTop = 'top'; + $this->hasInsertID = true; + $this->hasTransactions = true; + $this->_bindInputArray = true; + $this->_canSelectDb = true; + $this->substr = "substring"; + $this->length = 'len'; + $this->identitySQL = 'select SCOPE_IDENTITY()'; + $this->metaDatabasesSQL = "select name from master..sysdatabases where name <> 'master'"; + $this->_canPrepareSP = true; + break; + case 'access': + $this->databaseType = 'odbtp_access'; + $this->fmtDate = "#Y-m-d#"; + $this->fmtTimeStamp = "#Y-m-d h:i:sA#"; + $this->sysDate = "FORMAT(NOW,'yyyy-mm-dd')"; + $this->sysTimeStamp = 'NOW'; + $this->hasTop = 'top'; + $this->hasTransactions = false; + $this->_canPrepareSP = true; // For MS Access only. + break; + case 'visual foxpro': + $this->databaseType = 'odbtp_vfp'; + $this->fmtDate = "{^Y-m-d}"; + $this->fmtTimeStamp = "{^Y-m-d, h:i:sA}"; + $this->sysDate = 'date()'; + $this->sysTimeStamp = 'datetime()'; + $this->ansiOuter = true; + $this->hasTop = 'top'; + $this->hasTransactions = false; + $this->replaceQuote = "'+chr(39)+'"; + $this->true = '.T.'; + $this->false = '.F.'; + + break; + case 'oracle': + $this->databaseType = 'odbtp_oci8'; + $this->fmtDate = "'Y-m-d 00:00:00'"; + $this->fmtTimeStamp = "'Y-m-d h:i:sA'"; + $this->sysDate = 'TRUNC(SYSDATE)'; + $this->sysTimeStamp = 'SYSDATE'; + $this->hasTransactions = true; + $this->_bindInputArray = true; + $this->concat_operator = '||'; + break; + case 'sybase': + $this->databaseType = 'odbtp_sybase'; + $this->fmtDate = "'Y-m-d'"; + $this->fmtTimeStamp = "'Y-m-d H:i:s'"; + $this->sysDate = 'GetDate()'; + $this->sysTimeStamp = 'GetDate()'; + $this->leftOuter = '*='; + $this->rightOuter = '=*'; + $this->hasInsertID = true; + $this->hasTransactions = true; + $this->identitySQL = 'select SCOPE_IDENTITY()'; + break; + default: + $this->databaseType = 'odbtp'; + if( @odbtp_get_attr(ODB_ATTR_TXNCAPABLE, $this->_connectionID) ) + $this->hasTransactions = true; + else + $this->hasTransactions = false; + } + @odbtp_set_attr(ODB_ATTR_FULLCOLINFO, TRUE, $this->_connectionID ); + + if ($this->_useUnicodeSQL ) + @odbtp_set_attr(ODB_ATTR_UNICODESQL, TRUE, $this->_connectionID); + + return true; + } + + function _pconnect($HostOrInterface, $UserOrDSN='', $argPassword='', $argDatabase='') + { + $this->_dontPoolDBC = false; + return $this->_connect($HostOrInterface, $UserOrDSN, $argPassword, $argDatabase); + } + + function SelectDB($dbName) + { + if (!@odbtp_select_db($dbName, $this->_connectionID)) { + return false; + } + $this->database = $dbName; + $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions + return true; + } + + function MetaTables($ttype='',$showSchema=false,$mask=false) + { + global $ADODB_FETCH_MODE; + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savefm = $this->SetFetchMode(false); + + $arr = $this->GetArray("||SQLTables||||$ttype"); + + if (isset($savefm)) $this->SetFetchMode($savefm); + $ADODB_FETCH_MODE = $savem; + + $arr2 = array(); + for ($i=0; $i < sizeof($arr); $i++) { + if ($arr[$i][3] == 'SYSTEM TABLE' ) continue; + if ($arr[$i][2]) + $arr2[] = $showSchema && $arr[$i][1]? $arr[$i][1].'.'.$arr[$i][2] : $arr[$i][2]; + } + return $arr2; + } + + function MetaColumns($table,$upper=true) + { + global $ADODB_FETCH_MODE; + + $schema = false; + $this->_findschema($table,$schema); + if ($upper) $table = strtoupper($table); + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savefm = $this->SetFetchMode(false); + + $rs = $this->Execute( "||SQLColumns||$schema|$table" ); + + if (isset($savefm)) $this->SetFetchMode($savefm); + $ADODB_FETCH_MODE = $savem; + + if (!$rs || $rs->EOF) { + $false = false; + return $false; + } + $retarr = array(); + while (!$rs->EOF) { + //print_r($rs->fields); + if (strtoupper($rs->fields[2]) == $table) { + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[3]; + $fld->type = $rs->fields[5]; + $fld->max_length = $rs->fields[6]; + $fld->not_null = !empty($rs->fields[9]); + $fld->scale = $rs->fields[7]; + if (isset($rs->fields[12])) // vfp does not have field 12 + if (!is_null($rs->fields[12])) { + $fld->has_default = true; + $fld->default_value = $rs->fields[12]; + } + $retarr[strtoupper($fld->name)] = $fld; + } else if (!empty($retarr)) + break; + $rs->MoveNext(); + } + $rs->Close(); + + return $retarr; + } + + function MetaPrimaryKeys($table, $owner='') + { + global $ADODB_FETCH_MODE; + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $arr = $this->GetArray("||SQLPrimaryKeys||$owner|$table"); + $ADODB_FETCH_MODE = $savem; + + //print_r($arr); + $arr2 = array(); + for ($i=0; $i < sizeof($arr); $i++) { + if ($arr[$i][3]) $arr2[] = $arr[$i][3]; + } + return $arr2; + } + + function MetaForeignKeys($table, $owner='', $upper=false) + { + global $ADODB_FETCH_MODE; + + $savem = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + $constraints = $this->GetArray("||SQLForeignKeys|||||$owner|$table"); + $ADODB_FETCH_MODE = $savem; + + $arr = false; + foreach($constraints as $constr) { + //print_r($constr); + $arr[$constr[11]][$constr[2]][] = $constr[7].'='.$constr[3]; + } + if (!$arr) { + $false = false; + return $false; + } + + $arr2 = array(); + + foreach($arr as $k => $v) { + foreach($v as $a => $b) { + if ($upper) $a = strtoupper($a); + $arr2[$a] = $b; + } + } + return $arr2; + } + + function BeginTrans() + { + if (!$this->hasTransactions) return false; + if ($this->transOff) return true; + $this->transCnt += 1; + $this->autoCommit = false; + if (defined('ODB_TXN_DEFAULT')) + $txn = ODB_TXN_DEFAULT; + else + $txn = ODB_TXN_READUNCOMMITTED; + $rs = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS,$txn,$this->_connectionID); + if(!$rs) return false; + return true; + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + if ($this->transCnt) $this->transCnt -= 1; + $this->autoCommit = true; + if( ($ret = @odbtp_commit($this->_connectionID)) ) + $ret = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS, ODB_TXN_NONE, $this->_connectionID);//set transaction off + return $ret; + } + + function RollbackTrans() + { + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $this->autoCommit = true; + if( ($ret = @odbtp_rollback($this->_connectionID)) ) + $ret = @odbtp_set_attr(ODB_ATTR_TRANSACTIONS, ODB_TXN_NONE, $this->_connectionID);//set transaction off + return $ret; + } + + function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) + { + // TOP requires ORDER BY for Visual FoxPro + if( $this->odbc_driver == ODB_DRIVER_FOXPRO ) { + if (!preg_match('/ORDER[ \t\r\n]+BY/is',$sql)) $sql .= ' ORDER BY 1'; + } + $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + return $ret; + } + + function Prepare($sql) + { + if (! $this->_bindInputArray) return $sql; // no binding + $stmt = @odbtp_prepare($sql,$this->_connectionID); + if (!$stmt) { + // print "Prepare Error for ($sql) ".$this->ErrorMsg()."
"; + return $sql; + } + return array($sql,$stmt,false); + } + + function PrepareSP($sql) + { + if (!$this->_canPrepareSP) return $sql; // Can't prepare procedures + + $stmt = @odbtp_prepare_proc($sql,$this->_connectionID); + if (!$stmt) return false; + return array($sql,$stmt); + } + + /* + Usage: + $stmt = $db->PrepareSP('SP_RUNSOMETHING'); -- takes 2 params, @myid and @group + + # note that the parameter does not have @ in front! + $db->Parameter($stmt,$id,'myid'); + $db->Parameter($stmt,$group,'group',false,64); + $db->Parameter($stmt,$group,'photo',false,100000,ODB_BINARY); + $db->Execute($stmt); + + @param $stmt Statement returned by Prepare() or PrepareSP(). + @param $var PHP variable to bind to. Can set to null (for isNull support). + @param $name Name of stored procedure variable name to bind to. + @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in odbtp. + @param [$maxLen] Holds an maximum length of the variable. + @param [$type] The data type of $var. Legal values depend on driver. + + See odbtp_attach_param documentation at http://odbtp.sourceforge.net. + */ + function Parameter(&$stmt, &$var, $name, $isOutput=false, $maxLen=0, $type=0) + { + if ( $this->odbc_driver == ODB_DRIVER_JET ) { + $name = '['.$name.']'; + if( !$type && $this->_useUnicodeSQL + && @odbtp_param_bindtype($stmt[1], $name) == ODB_CHAR ) + { + $type = ODB_WCHAR; + } + } + else { + $name = '@'.$name; + } + return @odbtp_attach_param($stmt[1], $name, $var, $type, $maxLen); + } + + /* + Insert a null into the blob field of the table first. + Then use UpdateBlob to store the blob. + + Usage: + + $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); + $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); + */ + + function UpdateBlob($table,$column,$val,$where,$blobtype='image') + { + $sql = "UPDATE $table SET $column = ? WHERE $where"; + if( !($stmt = @odbtp_prepare($sql, $this->_connectionID)) ) + return false; + if( !@odbtp_input( $stmt, 1, ODB_BINARY, 1000000, $blobtype ) ) + return false; + if( !@odbtp_set( $stmt, 1, $val ) ) + return false; + return @odbtp_execute( $stmt ) != false; + } + + function MetaIndexes($table,$primary=false) + { + switch ( $this->odbc_driver) { + case ODB_DRIVER_MSSQL: + return $this->MetaIndexes_mssql($table, $primary); + default: + return array(); + } + } + + function MetaIndexes_mssql($table,$primary=false) + { + $table = strtolower($this->qstr($table)); + + $sql = "SELECT i.name AS ind_name, C.name AS col_name, USER_NAME(O.uid) AS Owner, c.colid, k.Keyno, + CASE WHEN I.indid BETWEEN 1 AND 254 AND (I.status & 2048 = 2048 OR I.Status = 16402 AND O.XType = 'V') THEN 1 ELSE 0 END AS IsPK, + CASE WHEN I.status & 2 = 2 THEN 1 ELSE 0 END AS IsUnique + FROM dbo.sysobjects o INNER JOIN dbo.sysindexes I ON o.id = i.id + INNER JOIN dbo.sysindexkeys K ON I.id = K.id AND I.Indid = K.Indid + INNER JOIN dbo.syscolumns c ON K.id = C.id AND K.colid = C.Colid + WHERE LEFT(i.name, 8) <> '_WA_Sys_' AND o.status >= 0 AND lower(O.Name) = $table + ORDER BY O.name, I.Name, K.keyno"; + + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + + $rs = $this->Execute($sql); + if (isset($savem)) { + $this->SetFetchMode($savem); + } + $ADODB_FETCH_MODE = $save; + + if (!is_object($rs)) { + return FALSE; + } + + $indexes = array(); + while ($row = $rs->FetchRow()) { + if ($primary && !$row[5]) continue; + + $indexes[$row[0]]['unique'] = $row[6]; + $indexes[$row[0]]['columns'][] = $row[1]; + } + return $indexes; + } + + function IfNull( $field, $ifNull ) + { + switch( $this->odbc_driver ) { + case ODB_DRIVER_MSSQL: + return " ISNULL($field, $ifNull) "; + case ODB_DRIVER_JET: + return " IIF(IsNull($field), $ifNull, $field) "; + } + return " CASE WHEN $field is null THEN $ifNull ELSE $field END "; + } + + function _query($sql,$inputarr=false) + { + global $php_errormsg; + + if ($inputarr) { + if (is_array($sql)) { + $stmtid = $sql[1]; + } else { + $stmtid = @odbtp_prepare($sql,$this->_connectionID); + if ($stmtid == false) { + $this->_errorMsg = $php_errormsg; + return false; + } + } + $num_params = @odbtp_num_params( $stmtid ); + for( $param = 1; $param <= $num_params; $param++ ) { + @odbtp_input( $stmtid, $param ); + @odbtp_set( $stmtid, $param, $inputarr[$param-1] ); + } + if (!@odbtp_execute($stmtid) ) { + return false; + } + } else if (is_array($sql)) { + $stmtid = $sql[1]; + if (!@odbtp_execute($stmtid)) { + return false; + } + } else { + $stmtid = odbtp_query($sql,$this->_connectionID); + } + $this->_lastAffectedRows = 0; + if ($stmtid) { + $this->_lastAffectedRows = @odbtp_affected_rows($stmtid); + } + return $stmtid; + } + + function _close() + { + $ret = @odbtp_close($this->_connectionID); + $this->_connectionID = false; + return $ret; + } +} + +class ADORecordSet_odbtp extends ADORecordSet { + + var $databaseType = 'odbtp'; + var $canSeek = true; + + function ADORecordSet_odbtp($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + $this->fetchMode = $mode; + $this->ADORecordSet($queryID); + } + + function _initrs() + { + $this->_numOfFields = @odbtp_num_fields($this->_queryID); + if (!($this->_numOfRows = @odbtp_num_rows($this->_queryID))) + $this->_numOfRows = -1; + + if (!$this->connection->_useUnicodeSQL) return; + + if ($this->connection->odbc_driver == ODB_DRIVER_JET) { + if (!@odbtp_get_attr(ODB_ATTR_MAPCHARTOWCHAR, + $this->connection->_connectionID)) + { + for ($f = 0; $f < $this->_numOfFields; $f++) { + if (@odbtp_field_bindtype($this->_queryID, $f) == ODB_CHAR) + @odbtp_bind_field($this->_queryID, $f, ODB_WCHAR); + } + } + } + } + + function FetchField($fieldOffset = 0) + { + $off=$fieldOffset; // offsets begin at 0 + $o= new ADOFieldObject(); + $o->name = @odbtp_field_name($this->_queryID,$off); + $o->type = @odbtp_field_type($this->_queryID,$off); + $o->max_length = @odbtp_field_length($this->_queryID,$off); + if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name); + else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name); + return $o; + } + + function _seek($row) + { + return @odbtp_data_seek($this->_queryID, $row); + } + + function fields($colname) + { + if ($this->fetchMode & ADODB_FETCH_ASSOC) return $this->fields[$colname]; + + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $name = @odbtp_field_name( $this->_queryID, $i ); + $this->bind[strtoupper($name)] = $i; + } + } + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + function _fetch_odbtp($type=0) + { + switch ($this->fetchMode) { + case ADODB_FETCH_NUM: + $this->fields = @odbtp_fetch_row($this->_queryID, $type); + break; + case ADODB_FETCH_ASSOC: + $this->fields = @odbtp_fetch_assoc($this->_queryID, $type); + break; + default: + $this->fields = @odbtp_fetch_array($this->_queryID, $type); + } + if ($this->databaseType = 'odbtp_vfp') { + if ($this->fields) + foreach($this->fields as $k => $v) { + if (strncmp($v,'1899-12-30',10) == 0) $this->fields[$k] = ''; + } + } + return is_array($this->fields); + } + + function _fetch() + { + return $this->_fetch_odbtp(); + } + + function MoveFirst() + { + if (!$this->_fetch_odbtp(ODB_FETCH_FIRST)) return false; + $this->EOF = false; + $this->_currentRow = 0; + return true; + } + + function MoveLast() + { + if (!$this->_fetch_odbtp(ODB_FETCH_LAST)) return false; + $this->EOF = false; + $this->_currentRow = $this->_numOfRows - 1; + return true; + } + + function NextRecordSet() + { + if (!@odbtp_next_result($this->_queryID)) return false; + $this->_inited = false; + $this->bind = false; + $this->_currentRow = -1; + $this->Init(); + return true; + } + + function _close() + { + return @odbtp_free_query($this->_queryID); + } +} + +class ADORecordSet_odbtp_mssql extends ADORecordSet_odbtp { + + var $databaseType = 'odbtp_mssql'; + + function ADORecordSet_odbtp_mssql($id,$mode=false) + { + return $this->ADORecordSet_odbtp($id,$mode); + } +} + +class ADORecordSet_odbtp_access extends ADORecordSet_odbtp { + + var $databaseType = 'odbtp_access'; + + function ADORecordSet_odbtp_access($id,$mode=false) + { + return $this->ADORecordSet_odbtp($id,$mode); + } +} + +class ADORecordSet_odbtp_vfp extends ADORecordSet_odbtp { + + var $databaseType = 'odbtp_vfp'; + + function ADORecordSet_odbtp_vfp($id,$mode=false) + { + return $this->ADORecordSet_odbtp($id,$mode); + } +} + +class ADORecordSet_odbtp_oci8 extends ADORecordSet_odbtp { + + var $databaseType = 'odbtp_oci8'; + + function ADORecordSet_odbtp_oci8($id,$mode=false) + { + return $this->ADORecordSet_odbtp($id,$mode); + } +} + +class ADORecordSet_odbtp_sybase extends ADORecordSet_odbtp { + + var $databaseType = 'odbtp_sybase'; + + function ADORecordSet_odbtp_sybase($id,$mode=false) + { + return $this->ADORecordSet_odbtp($id,$mode); + } +} +?> diff --git a/includes/adodb/drivers/adodb-odbtp_unicode.inc.php b/includes/adodb/drivers/adodb-odbtp_unicode.inc.php new file mode 100644 index 00000000..bee5b995 --- /dev/null +++ b/includes/adodb/drivers/adodb-odbtp_unicode.inc.php @@ -0,0 +1,39 @@ + + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +/* + Because the ODBTP server sends and reads UNICODE text data using UTF-8 + encoding, the following HTML meta tag must be included within the HTML + head section of every HTML form and script page: + + + + Also, all SQL query strings must be submitted as UTF-8 encoded text. +*/ + +if (!defined('_ADODB_ODBTP_LAYER')) { + include(ADODB_DIR."/drivers/adodb-odbtp.inc.php"); +} + +class ADODB_odbtp_unicode extends ADODB_odbtp { + var $databaseType = 'odbtp'; + var $_useUnicodeSQL = true; + + function ADODB_odbtp_unicode() + { + $this->ADODB_odbtp(); + } +} +?> diff --git a/includes/adodb/drivers/adodb-oracle.inc.php b/includes/adodb/drivers/adodb-oracle.inc.php new file mode 100644 index 00000000..142b91ea --- /dev/null +++ b/includes/adodb/drivers/adodb-oracle.inc.php @@ -0,0 +1,338 @@ +fmtDate,$d).",'YYYY-MM-DD')"; + } + + // format and return date string in database timestamp format + function DBTimeStamp($ts) + { + + if (is_string($ts)) $d = ADORecordSet::UnixTimeStamp($ts); + return 'TO_DATE('.adodb_date($this->fmtTimeStamp,$ts).",'RRRR-MM-DD, HH:MI:SS AM')"; + } + + + function BindDate($d) + { + $d = ADOConnection::DBDate($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + function BindTimeStamp($d) + { + $d = ADOConnection::DBTimeStamp($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + + + function BeginTrans() + { + $this->autoCommit = false; + ora_commitoff($this->_connectionID); + return true; + } + + + function CommitTrans($ok=true) + { + if (!$ok) return $this->RollbackTrans(); + $ret = ora_commit($this->_connectionID); + ora_commiton($this->_connectionID); + return $ret; + } + + + function RollbackTrans() + { + $ret = ora_rollback($this->_connectionID); + ora_commiton($this->_connectionID); + return $ret; + } + + + /* there seems to be a bug in the oracle extension -- always returns ORA-00000 - no error */ + function ErrorMsg() + { + if ($this->_errorMsg !== false) return $this->_errorMsg; + + if (is_resource($this->_curs)) $this->_errorMsg = @ora_error($this->_curs); + if (empty($this->_errorMsg)) $this->_errorMsg = @ora_error($this->_connectionID); + return $this->_errorMsg; + } + + + function ErrorNo() + { + if ($this->_errorCode !== false) return $this->_errorCode; + + if (is_resource($this->_curs)) $this->_errorCode = @ora_errorcode($this->_curs); + if (empty($this->_errorCode)) $this->_errorCode = @ora_errorcode($this->_connectionID); + return $this->_errorCode; + } + + + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename, $mode=0) + { + if (!function_exists('ora_plogon')) return null; + + // Reset error messages before connecting + $this->_errorMsg = false; + $this->_errorCode = false; + + // G. Giunta 2003/08/13 - This looks danegrously suspicious: why should we want to set + // the oracle home to the host name of remote DB? +// if ($argHostname) putenv("ORACLE_HOME=$argHostname"); + + if($argHostname) { // code copied from version submitted for oci8 by Jorma Tuomainen + if (empty($argDatabasename)) $argDatabasename = $argHostname; + else { + if(strpos($argHostname,":")) { + $argHostinfo=explode(":",$argHostname); + $argHostname=$argHostinfo[0]; + $argHostport=$argHostinfo[1]; + } else { + $argHostport="1521"; + } + + + if ($this->connectSID) { + $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname + .")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))"; + } else + $argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname + .")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))"; + } + + } + + if ($argDatabasename) $argUsername .= "@$argDatabasename"; + + //if ($argHostname) print "

Connect: 1st argument should be left blank for $this->databaseType

"; + if ($mode == 1) + $this->_connectionID = ora_plogon($argUsername,$argPassword); + else + $this->_connectionID = ora_logon($argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($this->autoCommit) ora_commiton($this->_connectionID); + if ($this->_initdate) { + $rs = $this->_query("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD'"); + if ($rs) ora_close($rs); + } + + return true; + } + + + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename, 1); + } + + + // returns query ID if successful, otherwise false + function _query($sql,$inputarr=false) + { + // Reset error messages before executing + $this->_errorMsg = false; + $this->_errorCode = false; + + $curs = ora_open($this->_connectionID); + + if ($curs === false) return false; + $this->_curs = $curs; + if (!ora_parse($curs,$sql)) return false; + if (ora_exec($curs)) return $curs; + // before we close the cursor, we have to store the error message + // that we can obtain ONLY from the cursor (and not from the connection) + $this->_errorCode = @ora_errorcode($curs); + $this->_errorMsg = @ora_error($curs); + // + @ora_close($curs); + return false; + } + + + // returns true or false + function _close() + { + return @ora_logoff($this->_connectionID); + } + + + +} + + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_oracle extends ADORecordSet { + + var $databaseType = "oracle"; + var $bind = false; + + function ADORecordset_oracle($queryID,$mode=false) + { + + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + $this->fetchMode = $mode; + + $this->_queryID = $queryID; + + $this->_inited = true; + $this->fields = array(); + if ($queryID) { + $this->_currentRow = 0; + $this->EOF = !$this->_fetch(); + @$this->_initrs(); + } else { + $this->_numOfRows = 0; + $this->_numOfFields = 0; + $this->EOF = true; + } + + return $this->_queryID; + } + + + + /* Returns: an object containing field information. + Get column information in the Recordset object. fetchField() can be used in order to obtain information about + fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by + fetchField() is retrieved. */ + + function FetchField($fieldOffset = -1) + { + $fld = new ADOFieldObject; + $fld->name = ora_columnname($this->_queryID, $fieldOffset); + $fld->type = ora_columntype($this->_queryID, $fieldOffset); + $fld->max_length = ora_columnsize($this->_queryID, $fieldOffset); + return $fld; + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + function _initrs() + { + $this->_numOfRows = -1; + $this->_numOfFields = @ora_numcols($this->_queryID); + } + + + function _seek($row) + { + return false; + } + + function _fetch($ignore_fields=false) { +// should remove call by reference, but ora_fetch_into requires it in 4.0.3pl1 + if ($this->fetchMode & ADODB_FETCH_ASSOC) + return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS|ORA_FETCHINTO_ASSOC); + else + return @ora_fetch_into($this->_queryID,&$this->fields,ORA_FETCHINTO_NULLS); + } + + /* close() only needs to be called if you are worried about using too much memory while your script + is running. All associated result memory for the specified result identifier will automatically be freed. */ + + function _close() +{ + return @ora_close($this->_queryID); + } + + function MetaType($t,$len=-1) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + + switch (strtoupper($t)) { + case 'VARCHAR': + case 'VARCHAR2': + case 'CHAR': + case 'VARBINARY': + case 'BINARY': + if ($len <= $this->blobSize) return 'C'; + case 'LONG': + case 'LONG VARCHAR': + case 'CLOB': + return 'X'; + case 'LONG RAW': + case 'LONG VARBINARY': + case 'BLOB': + return 'B'; + + case 'DATE': return 'D'; + + //case 'T': return 'T'; + + case 'BIT': return 'L'; + case 'INT': + case 'SMALLINT': + case 'INTEGER': return 'I'; + default: return 'N'; + } + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-pdo.inc.php b/includes/adodb/drivers/adodb-pdo.inc.php new file mode 100644 index 00000000..6ca93dc5 --- /dev/null +++ b/includes/adodb/drivers/adodb-pdo.inc.php @@ -0,0 +1,580 @@ +_driver; + $this->fmtDate = $d->fmtDate; + $this->fmtTimeStamp = $d->fmtTimeStamp; + $this->replaceQuote = $d->replaceQuote; + $this->sysDate = $d->sysDate; + $this->sysTimeStamp = $d->sysTimeStamp; + $this->random = $d->random; + $this->concat_operator = $d->concat_operator; + $this->nameQuote = $d->nameQuote; + + $this->hasGenID = $d->hasGenID; + $this->_genIDSQL = $d->_genIDSQL; + $this->_genSeqSQL = $d->_genSeqSQL; + $this->_dropSeqSQL = $d->_dropSeqSQL; + + $d->_init($this); + } + + function Time() + { + if (!empty($this->_driver->_hasdual)) $sql = "select $this->sysTimeStamp from dual"; + else $sql = "select $this->sysTimeStamp"; + + $rs = $this->_Execute($sql); + if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); + + return false; + } + + // returns true or false + function _connect($argDSN, $argUsername, $argPassword, $argDatabasename, $persist=false) + { + $at = strpos($argDSN,':'); + $this->dsnType = substr($argDSN,0,$at); + + if ($argDatabasename) { + $argDSN .= ';dbname='.$argDatabasename; + } + try { + $this->_connectionID = new PDO($argDSN, $argUsername, $argPassword); + } catch (Exception $e) { + $this->_connectionID = false; + $this->_errorno = -1; + //var_dump($e); + $this->_errormsg = 'Connection attempt failed: '.$e->getMessage(); + return false; + } + + if ($this->_connectionID) { + switch(ADODB_ASSOC_CASE){ + case 0: $m = PDO::CASE_LOWER; break; + case 1: $m = PDO::CASE_UPPER; break; + default: + case 2: $m = PDO::CASE_NATURAL; break; + } + + //$this->_connectionID->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_SILENT ); + $this->_connectionID->setAttribute(PDO::ATTR_CASE,$m); + + $class = 'ADODB_pdo_'.$this->dsnType; + //$this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true); + switch($this->dsnType) { + case 'oci': + case 'mysql': + case 'pgsql': + case 'mssql': + include_once(ADODB_DIR.'/drivers/adodb-pdo_'.$this->dsnType.'.inc.php'); + break; + } + if (class_exists($class)) + $this->_driver = new $class(); + else + $this->_driver = new ADODB_pdo_base(); + + $this->_driver->_connectionID = $this->_connectionID; + $this->_UpdatePDO(); + return true; + } + $this->_driver = new ADODB_pdo_base(); + return false; + } + + function Concat() + { + $args = func_get_args(); + if(method_exists($this->_driver, 'Concat')) + return call_user_func_array(array($this->_driver, 'Concat'), $args); + + return call_user_func_array(array($this,'parent::Concat'), $args); + } + + // returns true or false + function _pconnect($argDSN, $argUsername, $argPassword, $argDatabasename) + { + return $this->_connect($argDSN, $argUsername, $argPassword, $argDatabasename, true); + } + + /*------------------------------------------------------------------------------*/ + + + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + { + $save = $this->_driver->fetchMode; + $this->_driver->fetchMode = $this->fetchMode; + $this->_driver->debug = $this->debug; + $ret = $this->_driver->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + $this->_driver->fetchMode = $save; + return $ret; + } + + + function ServerInfo() + { + return $this->_driver->ServerInfo(); + } + + function MetaTables($ttype=false,$showSchema=false,$mask=false) + { + return $this->_driver->MetaTables($ttype,$showSchema,$mask); + } + + function MetaColumns($table,$normalize=true) + { + return $this->_driver->MetaColumns($table,$normalize); + } + + function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) + { + $obj = $stmt[1]; + if ($type) $obj->bindParam($name,$var,$type,$maxLen); + else $obj->bindParam($name, $var); + } + + + function ErrorMsg() + { + if ($this->_errormsg !== false) return $this->_errormsg; + if (!empty($this->_stmt)) $arr = $this->_stmt->errorInfo(); + else if (!empty($this->_connectionID)) $arr = $this->_connectionID->errorInfo(); + else return 'No Connection Established'; + + + if ($arr) { + if (sizeof($arr)<2) return ''; + if ((integer)$arr[1]) return $arr[2]; + else return ''; + } else return '-1'; + } + + + function ErrorNo() + { + if ($this->_errorno !== false) return $this->_errorno; + if (!empty($this->_stmt)) $err = $this->_stmt->errorCode(); + else if (!empty($this->_connectionID)) { + $arr = $this->_connectionID->errorInfo(); + if (isset($arr[0])) $err = $arr[0]; + else $err = -1; + } else + return 0; + + if ($err == '00000') return 0; // allows empty check + return $err; + } + + function BeginTrans() + { + if (!$this->hasTransactions) return false; + if ($this->transOff) return true; + $this->transCnt += 1; + $this->_autocommit = false; + $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,false); + return $this->_connectionID->beginTransaction(); + } + + function CommitTrans($ok=true) + { + if (!$this->hasTransactions) return false; + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + if ($this->transCnt) $this->transCnt -= 1; + $this->_autocommit = true; + + $ret = $this->_connectionID->commit(); + $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true); + return $ret; + } + + function RollbackTrans() + { + if (!$this->hasTransactions) return false; + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $this->_autocommit = true; + + $ret = $this->_connectionID->rollback(); + $this->_connectionID->setAttribute(PDO::ATTR_AUTOCOMMIT,true); + return $ret; + } + + function Prepare($sql) + { + $this->_stmt = $this->_connectionID->prepare($sql); + if ($this->_stmt) return array($sql,$this->_stmt); + + return false; + } + + function PrepareStmt($sql) + { + $stmt = $this->_connectionID->prepare($sql); + if (!$stmt) return false; + $obj = new ADOPDOStatement($stmt,$this); + return $obj; + } + + + /* returns queryID or false */ + function _query($sql,$inputarr=false) + { + if (is_array($sql)) { + $stmt = $sql[1]; + } else { + $stmt = $this->_connectionID->prepare($sql); + } + #adodb_backtrace(); + #var_dump($this->_bindInputArray); + if ($stmt) { + $this->_driver->debug = $this->debug; + if ($inputarr) $ok = $stmt->execute($inputarr); + else $ok = $stmt->execute(); + } + + + $this->_errormsg = false; + $this->_errorno = false; + + if ($ok) { + $this->_stmt = $stmt; + return $stmt; + } + + if ($stmt) { + + $arr = $stmt->errorinfo(); + if ((integer)$arr[1]) { + $this->_errormsg = $arr[2]; + $this->_errorno = $arr[1]; + } + + } else { + $this->_errormsg = false; + $this->_errorno = false; + } + return false; + } + + // returns true or false + function _close() + { + $this->_stmt = false; + return true; + } + + function _affectedrows() + { + return ($this->_stmt) ? $this->_stmt->rowCount() : 0; + } + + function _insertid() + { + return ($this->_connectionID) ? $this->_connectionID->lastInsertId() : 0; + } +} + +class ADODB_pdo_base extends ADODB_pdo { + + var $sysDate = "'?'"; + var $sysTimeStamp = "'?'"; + + + function _init($parentDriver) + { + $parentDriver->_bindInputArray = true; + #$parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); + } + + function ServerInfo() + { + return ADOConnection::ServerInfo(); + } + + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + { + $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + return $ret; + } + + function MetaTables() + { + return false; + } + + function MetaColumns() + { + return false; + } +} + +class ADOPDOStatement { + + var $databaseType = "pdo"; + var $dataProvider = "pdo"; + var $_stmt; + var $_connectionID; + + function ADOPDOStatement($stmt,$connection) + { + $this->_stmt = $stmt; + $this->_connectionID = $connection; + } + + function Execute($inputArr=false) + { + $savestmt = $this->_connectionID->_stmt; + $rs = $this->_connectionID->Execute(array(false,$this->_stmt),$inputArr); + $this->_connectionID->_stmt = $savestmt; + return $rs; + } + + function InParameter(&$var,$name,$maxLen=4000,$type=false) + { + + if ($type) $this->_stmt->bindParam($name,$var,$type,$maxLen); + else $this->_stmt->bindParam($name, $var); + } + + function Affected_Rows() + { + return ($this->_stmt) ? $this->_stmt->rowCount() : 0; + } + + function ErrorMsg() + { + if ($this->_stmt) $arr = $this->_stmt->errorInfo(); + else $arr = $this->_connectionID->errorInfo(); + + if (is_array($arr)) { + if ((integer) $arr[0] && isset($arr[2])) return $arr[2]; + else return ''; + } else return '-1'; + } + + function NumCols() + { + return ($this->_stmt) ? $this->_stmt->columnCount() : 0; + } + + function ErrorNo() + { + if ($this->_stmt) return $this->_stmt->errorCode(); + else return $this->_connectionID->errorInfo(); + } +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordSet_pdo extends ADORecordSet { + + var $bind = false; + var $databaseType = "pdo"; + var $dataProvider = "pdo"; + + function ADORecordSet_pdo($id,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + $this->adodbFetchMode = $mode; + switch($mode) { + case ADODB_FETCH_NUM: $mode = PDO::FETCH_NUM; break; + case ADODB_FETCH_ASSOC: $mode = PDO::FETCH_ASSOC; break; + + case ADODB_FETCH_BOTH: + default: $mode = PDO::FETCH_BOTH; break; + } + $this->fetchMode = $mode; + + $this->_queryID = $id; + $this->ADORecordSet($id); + } + + + function Init() + { + if ($this->_inited) return; + $this->_inited = true; + if ($this->_queryID) @$this->_initrs(); + else { + $this->_numOfRows = 0; + $this->_numOfFields = 0; + } + if ($this->_numOfRows != 0 && $this->_currentRow == -1) { + $this->_currentRow = 0; + if ($this->EOF = ($this->_fetch() === false)) { + $this->_numOfRows = 0; // _numOfRows could be -1 + } + } else { + $this->EOF = true; + } + } + + function _initrs() + { + global $ADODB_COUNTRECS; + + $this->_numOfRows = ($ADODB_COUNTRECS) ? @$this->_queryID->rowCount() : -1; + if (!$this->_numOfRows) $this->_numOfRows = -1; + $this->_numOfFields = $this->_queryID->columnCount(); + } + + // returns the field object + function FetchField($fieldOffset = -1) + { + $off=$fieldOffset+1; // offsets begin at 1 + + $o= new ADOFieldObject(); + $arr = @$this->_queryID->getColumnMeta($fieldOffset); + if (!$arr) { + $o->name = 'bad getColumnMeta()'; + $o->max_length = -1; + $o->type = 'VARCHAR'; + $o->precision = 0; + # $false = false; + return $o; + } + //adodb_pr($arr); + $o->name = $arr['name']; + if (isset($arr['native_type']) && $arr['native_type'] <> "null") $o->type = $arr['native_type']; + else $o->type = adodb_pdo_type($arr['pdo_type']); + $o->max_length = $arr['len']; + $o->precision = $arr['precision']; + + if (ADODB_ASSOC_CASE == 0) $o->name = strtolower($o->name); + else if (ADODB_ASSOC_CASE == 1) $o->name = strtoupper($o->name); + return $o; + } + + function _seek($row) + { + return false; + } + + function _fetch() + { + if (!$this->_queryID) return false; + + $this->fields = $this->_queryID->fetch($this->fetchMode); + return !empty($this->fields); + } + + function _close() + { + $this->_queryID = false; + } + + function Fields($colname) + { + if ($this->adodbFetchMode != ADODB_FETCH_NUM) return @$this->fields[$colname]; + + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + return $this->fields[$this->bind[strtoupper($colname)]]; + } + +} + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-pdo_mssql.inc.php b/includes/adodb/drivers/adodb-pdo_mssql.inc.php new file mode 100644 index 00000000..7ecc5cf1 --- /dev/null +++ b/includes/adodb/drivers/adodb-pdo_mssql.inc.php @@ -0,0 +1,61 @@ +hasTransactions = false; ## <<< BUG IN PDO mssql driver + $parentDriver->_bindInputArray = false; + $parentDriver->hasInsertID = true; + } + + function ServerInfo() + { + return ADOConnection::ServerInfo(); + } + + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + { + $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + return $ret; + } + + function SetTransactionMode( $transaction_mode ) + { + $this->_transmode = $transaction_mode; + if (empty($transaction_mode)) { + $this->Execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED'); + return; + } + if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; + $this->Execute("SET TRANSACTION ".$transaction_mode); + } + + function MetaTables() + { + return false; + } + + function MetaColumns() + { + return false; + } + +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-pdo_mysql.inc.php b/includes/adodb/drivers/adodb-pdo_mysql.inc.php new file mode 100644 index 00000000..5263b133 --- /dev/null +++ b/includes/adodb/drivers/adodb-pdo_mysql.inc.php @@ -0,0 +1,182 @@ +hasTransactions = false; + #$parentDriver->_bindInputArray = false; + $parentDriver->hasInsertID = true; + $parentDriver->_connectionID->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true); + } + + // dayFraction is a day in floating point + function OffsetDate($dayFraction,$date=false) + { + if (!$date) $date = $this->sysDate; + + $fraction = $dayFraction * 24 * 3600; + return $date . ' + INTERVAL ' . $fraction.' SECOND'; + +// return "from_unixtime(unix_timestamp($date)+$fraction)"; + } + + function Concat() + { + $s = ""; + $arr = func_get_args(); + + // suggestion by andrew005#mnogo.ru + $s = implode(',',$arr); + if (strlen($s) > 0) return "CONCAT($s)"; return ''; + } + + function ServerInfo() + { + $arr['description'] = ADOConnection::GetOne("select version()"); + $arr['version'] = ADOConnection::_findvers($arr['description']); + return $arr; + } + + function MetaTables($ttype=false,$showSchema=false,$mask=false) + { + $save = $this->metaTablesSQL; + if ($showSchema && is_string($showSchema)) { + $this->metaTablesSQL .= " from $showSchema"; + } + + if ($mask) { + $mask = $this->qstr($mask); + $this->metaTablesSQL .= " like $mask"; + } + $ret = ADOConnection::MetaTables($ttype,$showSchema); + + $this->metaTablesSQL = $save; + return $ret; + } + + function SetTransactionMode( $transaction_mode ) + { + $this->_transmode = $transaction_mode; + if (empty($transaction_mode)) { + $this->Execute('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ'); + return; + } + if (!stristr($transaction_mode,'isolation')) $transaction_mode = 'ISOLATION LEVEL '.$transaction_mode; + $this->Execute("SET SESSION TRANSACTION ".$transaction_mode); + } + + function MetaColumns($table) + { + $this->_findschema($table,$schema); + if ($schema) { + $dbName = $this->database; + $this->SelectDB($schema); + } + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); + + if ($schema) { + $this->SelectDB($dbName); + } + + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + if (!is_object($rs)) { + $false = false; + return $false; + } + + $retarr = array(); + while (!$rs->EOF){ + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $type = $rs->fields[1]; + + // split type into type(length): + $fld->scale = null; + if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) { + $fld->type = $query_array[1]; + $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; + $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1; + } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) { + $fld->type = $query_array[1]; + $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; + } elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) { + $fld->type = $query_array[1]; + $arr = explode(",",$query_array[2]); + $fld->enums = $arr; + $zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6 + $fld->max_length = ($zlen > 0) ? $zlen : 1; + } else { + $fld->type = $type; + $fld->max_length = -1; + } + $fld->not_null = ($rs->fields[2] != 'YES'); + $fld->primary_key = ($rs->fields[3] == 'PRI'); + $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false); + $fld->binary = (strpos($type,'blob') !== false); + $fld->unsigned = (strpos($type,'unsigned') !== false); + + if (!$fld->binary) { + $d = $rs->fields[4]; + if ($d != '' && $d != 'NULL') { + $fld->has_default = true; + $fld->default_value = $d; + } else { + $fld->has_default = false; + } + } + + if ($save == ADODB_FETCH_NUM) { + $retarr[] = $fld; + } else { + $retarr[strtoupper($fld->name)] = $fld; + } + $rs->MoveNext(); + } + + $rs->Close(); + return $retarr; + } + + + // parameters use PostgreSQL convention, not MySQL + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0) + { + $offsetStr =($offset>=0) ? "$offset," : ''; + // jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220 + if ($nrows < 0) $nrows = '18446744073709551615'; + + if ($secs) + $rs = $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr); + else + $rs = $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr); + return $rs; + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-pdo_oci.inc.php b/includes/adodb/drivers/adodb-pdo_oci.inc.php new file mode 100644 index 00000000..837c3b13 --- /dev/null +++ b/includes/adodb/drivers/adodb-pdo_oci.inc.php @@ -0,0 +1,93 @@ +_bindInputArray = true; + $parentDriver->_nestedSQL = true; + if ($this->_initdate) { + $parentDriver->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'"); + } + } + + function MetaTables($ttype=false,$showSchema=false,$mask=false) + { + if ($mask) { + $save = $this->metaTablesSQL; + $mask = $this->qstr(strtoupper($mask)); + $this->metaTablesSQL .= " AND table_name like $mask"; + } + $ret = ADOConnection::MetaTables($ttype,$showSchema); + + if ($mask) { + $this->metaTablesSQL = $save; + } + return $ret; + } + + function MetaColumns($table) + { + global $ADODB_FETCH_MODE; + + $false = false; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + $rs = $this->Execute(sprintf($this->metaColumnsSQL,strtoupper($table))); + + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + if (!$rs) { + return $false; + } + $retarr = array(); + while (!$rs->EOF) { //print_r($rs->fields); + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $fld->type = $rs->fields[1]; + $fld->max_length = $rs->fields[2]; + $fld->scale = $rs->fields[3]; + if ($rs->fields[1] == 'NUMBER' && $rs->fields[3] == 0) { + $fld->type ='INT'; + $fld->max_length = $rs->fields[4]; + } + $fld->not_null = (strncmp($rs->fields[5], 'NOT',3) === 0); + $fld->binary = (strpos($fld->type,'BLOB') !== false); + $fld->default_value = $rs->fields[6]; + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + else $retarr[strtoupper($fld->name)] = $fld; + $rs->MoveNext(); + } + $rs->Close(); + if (empty($retarr)) + return $false; + else + return $retarr; + } +} + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-pdo_pgsql.inc.php b/includes/adodb/drivers/adodb-pdo_pgsql.inc.php new file mode 100644 index 00000000..ee626503 --- /dev/null +++ b/includes/adodb/drivers/adodb-pdo_pgsql.inc.php @@ -0,0 +1,230 @@ + 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum"; + + // used when schema defined + var $metaColumnsSQL1 = "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum +FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n +WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) + and c.relnamespace=n.oid and n.nspname='%s' + and a.attname not like '....%%' AND a.attnum > 0 + AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum"; + + // get primary key etc -- from Freek Dijkstra + var $metaKeySQL = "SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key + FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = '%s'"; + + var $hasAffectedRows = true; + var $hasLimit = false; // set to true for pgsql 7 only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10 + // below suggested by Freek Dijkstra + var $true = 't'; // string that represents TRUE for a database + var $false = 'f'; // string that represents FALSE for a database + var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database + var $fmtTimeStamp = "'Y-m-d G:i:s'"; // used by DBTimeStamp as the default timestamp fmt. + var $hasMoveFirst = true; + var $hasGenID = true; + var $_genIDSQL = "SELECT NEXTVAL('%s')"; + var $_genSeqSQL = "CREATE SEQUENCE %s START %s"; + var $_dropSeqSQL = "DROP SEQUENCE %s"; + var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum"; + var $random = 'random()'; /// random function + var $concat_operator='||'; + + function _init($parentDriver) + { + + $parentDriver->hasTransactions = false; ## <<< BUG IN PDO pgsql driver + $parentDriver->hasInsertID = true; + $parentDriver->_nestedSQL = true; + } + + function ServerInfo() + { + $arr['description'] = ADOConnection::GetOne("select version()"); + $arr['version'] = ADOConnection::_findvers($arr['description']); + return $arr; + } + + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + { + $offsetStr = ($offset >= 0) ? " OFFSET $offset" : ''; + $limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ''; + if ($secs2cache) + $rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr); + else + $rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr); + + return $rs; + } + + function MetaTables($ttype=false,$showSchema=false,$mask=false) + { + $info = $this->ServerInfo(); + if ($info['version'] >= 7.3) { + $this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' + and schemaname not in ( 'pg_catalog','information_schema') + union + select viewname,'V' from pg_views where viewname not like 'pg\_%' and schemaname not in ( 'pg_catalog','information_schema') "; + } + if ($mask) { + $save = $this->metaTablesSQL; + $mask = $this->qstr(strtolower($mask)); + if ($info['version']>=7.3) + $this->metaTablesSQL = " +select tablename,'T' from pg_tables where tablename like $mask and schemaname not in ( 'pg_catalog','information_schema') + union +select viewname,'V' from pg_views where viewname like $mask and schemaname not in ( 'pg_catalog','information_schema') "; + else + $this->metaTablesSQL = " +select tablename,'T' from pg_tables where tablename like $mask + union +select viewname,'V' from pg_views where viewname like $mask"; + } + $ret = ADOConnection::MetaTables($ttype,$showSchema); + + if ($mask) { + $this->metaTablesSQL = $save; + } + return $ret; + } + + function MetaColumns($table,$normalize=true) + { + global $ADODB_FETCH_MODE; + + $schema = false; + $this->_findschema($table,$schema); + + if ($normalize) $table = strtolower($table); + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + if ($schema) $rs = $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema)); + else $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table)); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + if ($rs === false) { + $false = false; + return $false; + } + if (!empty($this->metaKeySQL)) { + // If we want the primary keys, we have to issue a separate query + // Of course, a modified version of the metaColumnsSQL query using a + // LEFT JOIN would have been much more elegant, but postgres does + // not support OUTER JOINS. So here is the clumsy way. + + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + + $rskey = $this->Execute(sprintf($this->metaKeySQL,($table))); + // fetch all result in once for performance. + $keys = $rskey->GetArray(); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + $rskey->Close(); + unset($rskey); + } + + $rsdefa = array(); + if (!empty($this->metaDefaultsSQL)) { + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $sql = sprintf($this->metaDefaultsSQL, ($table)); + $rsdef = $this->Execute($sql); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + if ($rsdef) { + while (!$rsdef->EOF) { + $num = $rsdef->fields['num']; + $s = $rsdef->fields['def']; + if (strpos($s,'::')===false && substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */ + $s = substr($s, 1); + $s = substr($s, 0, strlen($s) - 1); + } + + $rsdefa[$num] = $s; + $rsdef->MoveNext(); + } + } else { + ADOConnection::outp( "==> SQL => " . $sql); + } + unset($rsdef); + } + + $retarr = array(); + while (!$rs->EOF) { + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $fld->type = $rs->fields[1]; + $fld->max_length = $rs->fields[2]; + if ($fld->max_length <= 0) $fld->max_length = $rs->fields[3]-4; + if ($fld->max_length <= 0) $fld->max_length = -1; + if ($fld->type == 'numeric') { + $fld->scale = $fld->max_length & 0xFFFF; + $fld->max_length >>= 16; + } + // dannym + // 5 hasdefault; 6 num-of-column + $fld->has_default = ($rs->fields[5] == 't'); + if ($fld->has_default) { + $fld->default_value = $rsdefa[$rs->fields[6]]; + } + + //Freek + if ($rs->fields[4] == $this->true) { + $fld->not_null = true; + } + + // Freek + if (is_array($keys)) { + foreach($keys as $key) { + if ($fld->name == $key['column_name'] AND $key['primary_key'] == $this->true) + $fld->primary_key = true; + if ($fld->name == $key['column_name'] AND $key['unique_key'] == $this->true) + $fld->unique = true; // What name is more compatible? + } + } + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld; + + $rs->MoveNext(); + } + $rs->Close(); + if (empty($retarr)) { + $false = false; + return $false; + } else return $retarr; + + } + +} + +?> diff --git a/includes/adodb/drivers/adodb-pdo_sqlite.inc.php b/includes/adodb/drivers/adodb-pdo_sqlite.inc.php new file mode 100644 index 00000000..a5a1c03a --- /dev/null +++ b/includes/adodb/drivers/adodb-pdo_sqlite.inc.php @@ -0,0 +1,268 @@ +_bindInputArray = true; + } + + function _query($sql,$inputarr=false) { + if(strtolower(substr($sql,0,5)) != 'alter') { + return parent::_query($sql,$inputarr); + } else { + if(!$this->sqliteDropColumn($sql)) + return parent::_query($sql,$inputarr); + else + return true; + } + } + + function _connect($argDSN, $argUsername, $argPassword, $argDatabasename, $persist=false) { + return parent::_connect($argDatabasename,'','','',$persist); + } + + function sqliteDropColumn($sql) { + $queryparts = preg_split("/[\s]+/",$sql,10,PREG_SPLIT_NO_EMPTY); + if(count($queryparts) == 6) { + $table = $queryparts[2]; + $temp_table = $table.'_Temp'; + $removeColumn = $queryparts[5]; + $removeColumn = str_replace(';','',$removeColumn); + if(strtolower($queryparts[1]) != 'table' || + strtolower($queryparts[3]) != 'drop' || + strtolower($queryparts[4]) != 'column') { + return false; + } else { + // RENAME TABLE to TABLE_Temp + // CREATE new table without dropped column + // INSERT RECORDS from old table to new + // DROP Temp table + $meta = $this->MetaColumns($table); + $fields = Array(); + $fieldNames = Array(); + foreach($meta as $col) { + if($col->name != $removeColumn) { + $colText = $col->name; + if(!empty($col->type)) + $colText .= ' '.$col->type; + if($col->not_null) + $colText .= ' NOT NULL'; + if(!empty($col->default_value)) + $colText .= ' DEFAULT '.$col->default_value.''; + + $fieldNames[] = $col->name; + $fields[] = $colText; + } + } + $fieldList = implode(',',$fields); + $fieldNameList = implode(',',$fieldNames); + + $this->BeginTrans(); + $sql = "SELECT sql FROM sqlite_master WHERE type = 'index' AND tbl_name = '$table'"; + $result = $this->Execute($sql); + while(list($index) = $result->FetchRow()) { + $indexes[] = $index; + } + + $renameTempSql = 'ALTER TABLE '.$table.' RENAME TO '.$temp_table.';'; + $createTableSql = 'CREATE TABLE '.$table.'('.$fieldList.');'; + $copyTableContentsSql = 'INSERT INTO '.$table.' SELECT '.$fieldNameList.' FROM '.$temp_table.';'; + $removeTableSql = 'DROP TABLE '.$temp_table.';'; + $vacuumSql = 'VACUUM '.$table.';'; + + // Do the steps to drop the column by renaming and creating new table + $ok = $this->Execute($renameTempSql); + if($ok) $ok = $this->Execute($createTableSql); + if($ok) $ok = $this->Execute($copyTableContentsSql); + + $this->CommitTrans($ok); + + if($ok) $ok = $this->Execute($removeTableSql); + if($ok) $ok = $this->Execute($vacuumSql); + + // Recreate the indexes on the new table from the old + foreach($indexes as $indexSQL) { + $listStart = strpos($indexSQL,'(')+1; + $listEnd = strpos($indexSQL,')'); + $indexList = substr($indexSQL,$listStart,$listEnd-$listStart); + $indexList = explode(',',$indexList); + $newIndexList = Array(); + foreach($indexList as $listItem) { + $listItem = trim($listItem); + if($listItem != $removeColumn) { + $newIndexList[] = $listItem; + } + } + $indexSQL = substr($indexSQL,0,$listStart-1); + $indexSQL .= '('.implode(',',$newIndexList).');'; + $this->Execute($indexSQL); + } + return $ok; + } + } + return false; + } + + function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0) { + $offsetStr =($offset>=0) ? "$offset," : ''; + if ($secs) + $rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr$nrows",$inputarr); + else + $rs =& $this->Execute($sql." LIMIT $offsetStr$nrows",$inputarr); + return $rs; + } + + function GenID($seq='adodbseq',$start=1) { + // if you have to modify the parameter below, your database is overloaded, + // or you need to implement generation of id's yourself! + $MAXLOOPS = 100; + //$this->debug=1; + while (--$MAXLOOPS>=0) { + @($num = array_pop($this->GetCol("select id from $seq"))); + if ($num === false || !is_numeric($num)) { + @$this->Execute(sprintf($this->_genSeqSQL ,$seq)); + $start -= 1; + $num = '0'; + $cnt = $this->GetOne(sprintf($this->_genSeqCountSQL,$seq)); + if (!$cnt) { + $ok = $this->Execute(sprintf($this->_genSeq2SQL,$seq,$start)); + } + if (!$ok) return false; + } + $this->Execute("update $seq set id=id+1"); + + if ($this->affected_rows() > 0) { + $num += 1; + $this->genID = intval($num); + return intval($num); + } + } + if ($fn = $this->raiseErrorFn) { + $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num); + } + return false; + } + + function BeginTrans() + { + if (!$this->hasTransactions) return false; + if ($this->transOff) return true; + if($this->transCnt < 1) { + $this->transCnt += 1; + $this->_autocommit = false; + return $this->_connectionID->beginTransaction(); + } + } + + function CommitTrans($ok=true) + { + if (!$this->hasTransactions) return false; + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + if ($this->transCnt) $this->transCnt -= 1; + $this->_autocommit = true; + + if($this->transCnt == 0) + $ret = $this->_connectionID->commit(); + return $ret; + } + + function RollbackTrans() + { + if (!$this->hasTransactions) return false; + if ($this->transOff) return true; + if ($this->transCnt) $this->transCnt -= 1; + $this->_autocommit = true; + + $ret = $this->_connectionID->rollback(); + return $ret; + } + + function CreateSequence($seqname='adodbseq',$start=1) { + if (empty($this->_genSeqSQL)) return false; + $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); + if (!$ok) return false; + $start -= 1; + return $this->Execute("insert into $seqname values($start)"); + } + + function DropSequence($seqname) { + if (empty($this->_dropSeqSQL)) return false; + return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); + } + + // mark newnham + function &MetaColumns($tab) + { + global $ADODB_FETCH_MODE; + $false = false; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + $rs = $this->Execute("PRAGMA table_info('$tab')"); + if (isset($savem)) $this->SetFetchMode($savem); + if (!$rs) { + $ADODB_FETCH_MODE = $save; + return $false; + } + $arr = array(); + while ($r = $rs->FetchRow()) { + $type = explode('(',$r['type']); + $size = ''; + if (sizeof($type)==2) + $size = trim($type[1],')'); + $fn = strtoupper($r['name']); + $fld = new ADOFieldObject; + $fld->name = $r['name']; + $fld->type = $type[0]; + $fld->max_length = $size; + $fld->not_null = $r['notnull']; + $fld->primary_key = $r['pk']; + $fld->default_value = $r['dflt_value']; + $fld->scale = 0; + if ($save == ADODB_FETCH_NUM) $arr[] = $fld; + else $arr[strtoupper($fld->name)] = $fld; + } + $rs->Close(); + $ADODB_FETCH_MODE = $save; + return $arr; + } + + function MetaTables($ttype=false,$showSchema=false,$mask=false) { + return $this->GetCol($this->metaTablesSQL); + } + + function __sleep() { + unset($this->_connectionID); + return( array_keys( get_object_vars( $this ) ) ); + } +} + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-postgres.inc.php b/includes/adodb/drivers/adodb-postgres.inc.php new file mode 100644 index 00000000..3cb996eb --- /dev/null +++ b/includes/adodb/drivers/adodb-postgres.inc.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-postgres64.inc.php b/includes/adodb/drivers/adodb-postgres64.inc.php new file mode 100644 index 00000000..5b9d1068 --- /dev/null +++ b/includes/adodb/drivers/adodb-postgres64.inc.php @@ -0,0 +1,1065 @@ + + jlim - changed concat operator to || and data types to MetaType to match documented pgsql types + see http://www.postgresql.org/devel-corner/docs/postgres/datatype.htm + 22 Nov 2000 jlim - added changes to FetchField() and MetaTables() contributed by "raser" + 27 Nov 2000 jlim - added changes to _connect/_pconnect from ideas by "Lennie" + 15 Dec 2000 jlim - added changes suggested by Additional code changes by "Eric G. Werk" egw@netguide.dk. + 31 Jan 2002 jlim - finally installed postgresql. testing + 01 Mar 2001 jlim - Freek Dijkstra changes, also support for text type + + See http://www.varlena.com/varlena/GeneralBits/47.php + + -- What indexes are on my table? + select * from pg_indexes where tablename = 'tablename'; + + -- What triggers are on my table? + select c.relname as "Table", t.tgname as "Trigger Name", + t.tgconstrname as "Constraint Name", t.tgenabled as "Enabled", + t.tgisconstraint as "Is Constraint", cc.relname as "Referenced Table", + p.proname as "Function Name" + from pg_trigger t, pg_class c, pg_class cc, pg_proc p + where t.tgfoid = p.oid and t.tgrelid = c.oid + and t.tgconstrrelid = cc.oid + and c.relname = 'tablename'; + + -- What constraints are on my table? + select r.relname as "Table", c.conname as "Constraint Name", + contype as "Constraint Type", conkey as "Key Columns", + confkey as "Foreign Columns", consrc as "Source" + from pg_class r, pg_constraint c + where r.oid = c.conrelid + and relname = 'tablename'; + +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +function adodb_addslashes($s) +{ + $len = strlen($s); + if ($len == 0) return "''"; + if (strncmp($s,"'",1) === 0 && substr($s,$len-1) == "'") return $s; // already quoted + + return "'".addslashes($s)."'"; +} + +class ADODB_postgres64 extends ADOConnection{ + var $databaseType = 'postgres64'; + var $dataProvider = 'postgres'; + var $hasInsertID = true; + var $_resultid = false; + var $concat_operator='||'; + var $metaDatabasesSQL = "select datname from pg_database where datname not in ('template0','template1') order by 1"; + var $metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' + and tablename not in ('sql_features', 'sql_implementation_info', 'sql_languages', + 'sql_packages', 'sql_sizing', 'sql_sizing_profiles') + union + select viewname,'V' from pg_views where viewname not like 'pg\_%'"; + //"select tablename from pg_tables where tablename not like 'pg_%' order by 1"; + var $isoDates = true; // accepts dates in ISO format + var $sysDate = "CURRENT_DATE"; + var $sysTimeStamp = "CURRENT_TIMESTAMP"; + var $blobEncodeType = 'C'; + var $metaColumnsSQL = "SELECT a.attname,t.typname,a.attlen,a.atttypmod,a.attnotnull,a.atthasdef,a.attnum + FROM pg_class c, pg_attribute a,pg_type t + WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) and a.attname not like '....%%' +AND a.attnum > 0 AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum"; + + // used when schema defined + var $metaColumnsSQL1 = "SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull, a.atthasdef, a.attnum +FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n +WHERE relkind in ('r','v') AND (c.relname='%s' or c.relname = lower('%s')) + and c.relnamespace=n.oid and n.nspname='%s' + and a.attname not like '....%%' AND a.attnum > 0 + AND a.atttypid = t.oid AND a.attrelid = c.oid ORDER BY a.attnum"; + + // get primary key etc -- from Freek Dijkstra + var $metaKeySQL = "SELECT ic.relname AS index_name, a.attname AS column_name,i.indisunique AS unique_key, i.indisprimary AS primary_key + FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a WHERE bc.oid = i.indrelid AND ic.oid = i.indexrelid AND (i.indkey[0] = a.attnum OR i.indkey[1] = a.attnum OR i.indkey[2] = a.attnum OR i.indkey[3] = a.attnum OR i.indkey[4] = a.attnum OR i.indkey[5] = a.attnum OR i.indkey[6] = a.attnum OR i.indkey[7] = a.attnum) AND a.attrelid = bc.oid AND bc.relname = '%s'"; + + var $hasAffectedRows = true; + var $hasLimit = false; // set to true for pgsql 7 only. support pgsql/mysql SELECT * FROM TABLE LIMIT 10 + // below suggested by Freek Dijkstra + var $true = 'TRUE'; // string that represents TRUE for a database + var $false = 'FALSE'; // string that represents FALSE for a database + var $fmtDate = "'Y-m-d'"; // used by DBDate() as the default date format used by the database + var $fmtTimeStamp = "'Y-m-d H:i:s'"; // used by DBTimeStamp as the default timestamp fmt. + var $hasMoveFirst = true; + var $hasGenID = true; + var $_genIDSQL = "SELECT NEXTVAL('%s')"; + var $_genSeqSQL = "CREATE SEQUENCE %s START %s"; + var $_dropSeqSQL = "DROP SEQUENCE %s"; + var $metaDefaultsSQL = "SELECT d.adnum as num, d.adsrc as def from pg_attrdef d, pg_class c where d.adrelid=c.oid and c.relname='%s' order by d.adnum"; + var $random = 'random()'; /// random function + var $autoRollback = true; // apparently pgsql does not autorollback properly before php 4.3.4 + // http://bugs.php.net/bug.php?id=25404 + + var $_bindInputArray = false; // requires postgresql 7.3+ and ability to modify database + var $disableBlobs = false; // set to true to disable blob checking, resulting in 2-5% improvement in performance. + + // The last (fmtTimeStamp is not entirely correct: + // PostgreSQL also has support for time zones, + // and writes these time in this format: "2001-03-01 18:59:26+02". + // There is no code for the "+02" time zone information, so I just left that out. + // I'm not familiar enough with both ADODB as well as Postgres + // to know what the concequences are. The other values are correct (wheren't in 0.94) + // -- Freek Dijkstra + + function ADODB_postgres64() + { + // changes the metaColumnsSQL, adds columns: attnum[6] + } + + function ServerInfo() + { + if (isset($this->version)) return $this->version; + + $arr['description'] = $this->GetOne("select version()"); + $arr['version'] = ADOConnection::_findvers($arr['description']); + $this->version = $arr; + return $arr; + } + + function IfNull( $field, $ifNull ) + { + return " coalesce($field, $ifNull) "; + } + + // get the last id - never tested + function pg_insert_id($tablename,$fieldname) + { + $result=pg_exec($this->_connectionID, "SELECT last_value FROM ${tablename}_${fieldname}_seq"); + if ($result) { + $arr = @pg_fetch_row($result,0); + pg_freeresult($result); + if (isset($arr[0])) return $arr[0]; + } + return false; + } + +/* Warning from http://www.php.net/manual/function.pg-getlastoid.php: +Using a OID as a unique identifier is not generally wise. +Unless you are very careful, you might end up with a tuple having +a different OID if a database must be reloaded. */ + function _insertid($table,$column) + { + if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false; + $oid = pg_getlastoid($this->_resultid); + // to really return the id, we need the table and column-name, else we can only return the oid != id + return empty($table) || empty($column) ? $oid : $this->GetOne("SELECT $column FROM $table WHERE oid=".(int)$oid); + } + +// I get this error with PHP before 4.0.6 - jlim +// Warning: This compilation does not support pg_cmdtuples() in adodb-postgres.inc.php on line 44 + function _affectedrows() + { + if (!is_resource($this->_resultid) || get_resource_type($this->_resultid) !== 'pgsql result') return false; + return pg_cmdtuples($this->_resultid); + } + + + // returns true/false + function BeginTrans() + { + if ($this->transOff) return true; + $this->transCnt += 1; + return @pg_Exec($this->_connectionID, "begin ".$this->_transmode); + } + + function RowLock($tables,$where,$flds='1 as ignore') + { + if (!$this->transCnt) $this->BeginTrans(); + return $this->GetOne("select $flds from $tables where $where for update"); + } + + // returns true/false. + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + + $this->transCnt -= 1; + return @pg_Exec($this->_connectionID, "commit"); + } + + // returns true/false + function RollbackTrans() + { + if ($this->transOff) return true; + $this->transCnt -= 1; + return @pg_Exec($this->_connectionID, "rollback"); + } + + function MetaTables($ttype=false,$showSchema=false,$mask=false) + { + $info = $this->ServerInfo(); + if ($info['version'] >= 7.3) { + $this->metaTablesSQL = "select tablename,'T' from pg_tables where tablename not like 'pg\_%' + and schemaname not in ( 'pg_catalog','information_schema') + union + select viewname,'V' from pg_views where viewname not like 'pg\_%' and schemaname not in ( 'pg_catalog','information_schema') "; + } + if ($mask) { + $save = $this->metaTablesSQL; + $mask = $this->qstr(strtolower($mask)); + if ($info['version']>=7.3) + $this->metaTablesSQL = " +select tablename,'T' from pg_tables where tablename like $mask and schemaname not in ( 'pg_catalog','information_schema') + union +select viewname,'V' from pg_views where viewname like $mask and schemaname not in ( 'pg_catalog','information_schema') "; + else + $this->metaTablesSQL = " +select tablename,'T' from pg_tables where tablename like $mask + union +select viewname,'V' from pg_views where viewname like $mask"; + } + $ret = ADOConnection::MetaTables($ttype,$showSchema); + + if ($mask) { + $this->metaTablesSQL = $save; + } + return $ret; + } + + + // if magic quotes disabled, use pg_escape_string() + function qstr($s,$magic_quotes=false) + { + if (!$magic_quotes) { + if (ADODB_PHPVER >= 0x5200) { + return "'".pg_escape_string($this->_connectionID,$s)."'"; + } + if (ADODB_PHPVER >= 0x4200) { + return "'".pg_escape_string($s)."'"; + } + if ($this->replaceQuote[0] == '\\'){ + $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\\000"),$s); + } + return "'".str_replace("'",$this->replaceQuote,$s)."'"; + } + + // undo magic quotes for " + $s = str_replace('\\"','"',$s); + return "'$s'"; + } + + + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysTimeStamp; + $s = 'TO_CHAR('.$col.",'"; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + $s .= 'YYYY'; + break; + case 'Q': + case 'q': + $s .= 'Q'; + break; + + case 'M': + $s .= 'Mon'; + break; + + case 'm': + $s .= 'MM'; + break; + case 'D': + case 'd': + $s .= 'DD'; + break; + + case 'H': + $s.= 'HH24'; + break; + + case 'h': + $s .= 'HH'; + break; + + case 'i': + $s .= 'MI'; + break; + + case 's': + $s .= 'SS'; + break; + + case 'a': + case 'A': + $s .= 'AM'; + break; + + case 'w': + $s .= 'D'; + break; + + case 'l': + $s .= 'DAY'; + break; + + case 'W': + $s .= 'WW'; + break; + + default: + // handle escape characters... + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + if (strpos('-/.:;, ',$ch) !== false) $s .= $ch; + else $s .= '"'.$ch.'"'; + + } + } + return $s. "')"; + } + + + + /* + * Load a Large Object from a file + * - the procedure stores the object id in the table and imports the object using + * postgres proprietary blob handling routines + * + * contributed by Mattia Rossi mattia@technologist.com + * modified for safe mode by juraj chlebec + */ + function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') + { + pg_exec ($this->_connectionID, "begin"); + + $fd = fopen($path,'r'); + $contents = fread($fd,filesize($path)); + fclose($fd); + + $oid = pg_lo_create($this->_connectionID); + $handle = pg_lo_open($this->_connectionID, $oid, 'w'); + pg_lo_write($handle, $contents); + pg_lo_close($handle); + + // $oid = pg_lo_import ($path); + pg_exec($this->_connectionID, "commit"); + $rs = ADOConnection::UpdateBlob($table,$column,$oid,$where,$blobtype); + $rez = !empty($rs); + return $rez; + } + + /* + * Deletes/Unlinks a Blob from the database, otherwise it + * will be left behind + * + * Returns TRUE on success or FALSE on failure. + * + * contributed by Todd Rogers todd#windfox.net + */ + function BlobDelete( $blob ) + { + pg_exec ($this->_connectionID, "begin"); + $result = @pg_lo_unlink($blob); + pg_exec ($this->_connectionID, "commit"); + return( $result ); + } + + /* + Hueristic - not guaranteed to work. + */ + function GuessOID($oid) + { + if (strlen($oid)>16) return false; + return is_numeric($oid); + } + + /* + * If an OID is detected, then we use pg_lo_* to open the oid file and read the + * real blob from the db using the oid supplied as a parameter. If you are storing + * blobs using bytea, we autodetect and process it so this function is not needed. + * + * contributed by Mattia Rossi mattia@technologist.com + * + * see http://www.postgresql.org/idocs/index.php?largeobjects.html + * + * Since adodb 4.54, this returns the blob, instead of sending it to stdout. Also + * added maxsize parameter, which defaults to $db->maxblobsize if not defined. + */ + function BlobDecode($blob,$maxsize=false,$hastrans=true) + { + if (!$this->GuessOID($blob)) return $blob; + + if ($hastrans) @pg_exec($this->_connectionID,"begin"); + $fd = @pg_lo_open($this->_connectionID,$blob,"r"); + if ($fd === false) { + if ($hastrans) @pg_exec($this->_connectionID,"commit"); + return $blob; + } + if (!$maxsize) $maxsize = $this->maxblobsize; + $realblob = @pg_loread($fd,$maxsize); + @pg_loclose($fd); + if ($hastrans) @pg_exec($this->_connectionID,"commit"); + return $realblob; + } + + /* + See http://www.postgresql.org/idocs/index.php?datatype-binary.html + + NOTE: SQL string literals (input strings) must be preceded with two backslashes + due to the fact that they must pass through two parsers in the PostgreSQL + backend. + */ + function BlobEncode($blob) + { + if (ADODB_PHPVER >= 0x5200) return pg_escape_bytea($this->_connectionID, $blob); + if (ADODB_PHPVER >= 0x4200) return pg_escape_bytea($blob); + + /*92=backslash, 0=null, 39=single-quote*/ + $badch = array(chr(92),chr(0),chr(39)); # \ null ' + $fixch = array('\\\\134','\\\\000','\\\\047'); + return adodb_str_replace($badch,$fixch,$blob); + + // note that there is a pg_escape_bytea function only for php 4.2.0 or later + } + + // assumes bytea for blob, and varchar for clob + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + + if ($blobtype == 'CLOB') { + return $this->Execute("UPDATE $table SET $column=" . $this->qstr($val) . " WHERE $where"); + } + // do not use bind params which uses qstr(), as blobencode() already quotes data + return $this->Execute("UPDATE $table SET $column='".$this->BlobEncode($val)."'::bytea WHERE $where"); + } + + function OffsetDate($dayFraction,$date=false) + { + if (!$date) $date = $this->sysDate; + else if (strncmp($date,"'",1) == 0) { + $len = strlen($date); + if (10 <= $len && $len <= 12) $date = 'date '.$date; + else $date = 'timestamp '.$date; + } + return "($date+interval'$dayFraction days')"; + } + + + // for schema support, pass in the $table param "$schema.$tabname". + // converts field names to lowercase, $upper is ignored + // see http://phplens.com/lens/lensforum/msgs.php?id=14018 for more info + function MetaColumns($table,$normalize=true) + { + global $ADODB_FETCH_MODE; + + $schema = false; + $false = false; + $this->_findschema($table,$schema); + + if ($normalize) $table = strtolower($table); + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + if ($schema) $rs = $this->Execute(sprintf($this->metaColumnsSQL1,$table,$table,$schema)); + else $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table,$table)); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + if ($rs === false) { + return $false; + } + if (!empty($this->metaKeySQL)) { + // If we want the primary keys, we have to issue a separate query + // Of course, a modified version of the metaColumnsSQL query using a + // LEFT JOIN would have been much more elegant, but postgres does + // not support OUTER JOINS. So here is the clumsy way. + + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + + $rskey = $this->Execute(sprintf($this->metaKeySQL,($table))); + // fetch all result in once for performance. + $keys = $rskey->GetArray(); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + $rskey->Close(); + unset($rskey); + } + + $rsdefa = array(); + if (!empty($this->metaDefaultsSQL)) { + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $sql = sprintf($this->metaDefaultsSQL, ($table)); + $rsdef = $this->Execute($sql); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + if ($rsdef) { + while (!$rsdef->EOF) { + $num = $rsdef->fields['num']; + $s = $rsdef->fields['def']; + if (strpos($s,'::')===false && substr($s, 0, 1) == "'") { /* quoted strings hack... for now... fixme */ + $s = substr($s, 1); + $s = substr($s, 0, strlen($s) - 1); + } + + $rsdefa[$num] = $s; + $rsdef->MoveNext(); + } + } else { + ADOConnection::outp( "==> SQL => " . $sql); + } + unset($rsdef); + } + + $retarr = array(); + while (!$rs->EOF) { + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $fld->type = $rs->fields[1]; + $fld->max_length = $rs->fields[2]; + $fld->attnum = $rs->fields[6]; + + if ($fld->max_length <= 0) $fld->max_length = $rs->fields[3]-4; + if ($fld->max_length <= 0) $fld->max_length = -1; + if ($fld->type == 'numeric') { + $fld->scale = $fld->max_length & 0xFFFF; + $fld->max_length >>= 16; + } + // dannym + // 5 hasdefault; 6 num-of-column + $fld->has_default = ($rs->fields[5] == 't'); + if ($fld->has_default) { + $fld->default_value = $rsdefa[$rs->fields[6]]; + } + + //Freek + $fld->not_null = $rs->fields[4] == 't'; + + + // Freek + if (is_array($keys)) { + foreach($keys as $key) { + if ($fld->name == $key['column_name'] AND $key['primary_key'] == 't') + $fld->primary_key = true; + if ($fld->name == $key['column_name'] AND $key['unique_key'] == 't') + $fld->unique = true; // What name is more compatible? + } + } + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + else $retarr[($normalize) ? strtoupper($fld->name) : $fld->name] = $fld; + + $rs->MoveNext(); + } + $rs->Close(); + if (empty($retarr)) + return $false; + else + return $retarr; + + } + + function MetaIndexes ($table, $primary = FALSE) + { + global $ADODB_FETCH_MODE; + + $schema = false; + $this->_findschema($table,$schema); + + if ($schema) { // requires pgsql 7.3+ - pg_namespace used. + $sql = ' +SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns" +FROM pg_catalog.pg_class c +JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid +JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid + ,pg_namespace n +WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\')) and c.relnamespace=c2.relnamespace and c.relnamespace=n.oid and n.nspname=\'%s\''; + } else { + $sql = ' +SELECT c.relname as "Name", i.indisunique as "Unique", i.indkey as "Columns" +FROM pg_catalog.pg_class c +JOIN pg_catalog.pg_index i ON i.indexrelid=c.oid +JOIN pg_catalog.pg_class c2 ON c2.oid=i.indrelid +WHERE (c2.relname=\'%s\' or c2.relname=lower(\'%s\'))'; + } + + if ($primary == FALSE) { + $sql .= ' AND i.indisprimary=false;'; + } + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + + $rs = $this->Execute(sprintf($sql,$table,$table,$schema)); + if (isset($savem)) { + $this->SetFetchMode($savem); + } + $ADODB_FETCH_MODE = $save; + + if (!is_object($rs)) { + $false = false; + return $false; + } + + $col_names = $this->MetaColumnNames($table,true,true); + //3rd param is use attnum, + // see http://sourceforge.net/tracker/index.php?func=detail&aid=1451245&group_id=42718&atid=433976 + $indexes = array(); + while ($row = $rs->FetchRow()) { + $columns = array(); + foreach (explode(' ', $row[2]) as $col) { + $columns[] = $col_names[$col]; + } + + $indexes[$row[0]] = array( + 'unique' => ($row[1] == 't'), + 'columns' => $columns + ); + } + return $indexes; + } + + // returns true or false + // + // examples: + // $db->Connect("host=host1 user=user1 password=secret port=4341"); + // $db->Connect('host1','user1','secret'); + function _connect($str,$user='',$pwd='',$db='',$ctype=0) + { + + if (!function_exists('pg_connect')) return null; + + $this->_errorMsg = false; + + if ($user || $pwd || $db) { + $user = adodb_addslashes($user); + $pwd = adodb_addslashes($pwd); + if (strlen($db) == 0) $db = 'template1'; + $db = adodb_addslashes($db); + if ($str) { + $host = split(":", $str); + if ($host[0]) $str = "host=".adodb_addslashes($host[0]); + else $str = ''; + if (isset($host[1])) $str .= " port=$host[1]"; + else if (!empty($this->port)) $str .= " port=".$this->port; + } + if ($user) $str .= " user=".$user; + if ($pwd) $str .= " password=".$pwd; + if ($db) $str .= " dbname=".$db; + } + + //if ($user) $linea = "user=$user host=$linea password=$pwd dbname=$db port=5432"; + + if ($ctype === 1) { // persistent + $this->_connectionID = pg_pconnect($str); + } else { + if ($ctype === -1) { // nconnect, we trick pgsql ext by changing the connection str + static $ncnt; + + if (empty($ncnt)) $ncnt = 1; + else $ncnt += 1; + + $str .= str_repeat(' ',$ncnt); + } + $this->_connectionID = pg_connect($str); + } + if ($this->_connectionID === false) return false; + $this->Execute("set datestyle='ISO'"); + + $info = $this->ServerInfo(); + $this->pgVersion = (float) substr($info['version'],0,3); + if ($this->pgVersion >= 7.1) { // good till version 999 + $this->_nestedSQL = true; + } + return true; + } + + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName,-1); + } + + // returns true or false + // + // examples: + // $db->PConnect("host=host1 user=user1 password=secret port=4341"); + // $db->PConnect('host1','user1','secret'); + function _pconnect($str,$user='',$pwd='',$db='') + { + return $this->_connect($str,$user,$pwd,$db,1); + } + + + // returns queryID or false + function _query($sql,$inputarr) + { + $this->_errorMsg = false; + if ($inputarr) { + /* + It appears that PREPARE/EXECUTE is slower for many queries. + + For query executed 1000 times: + "select id,firstname,lastname from adoxyz + where firstname not like ? and lastname not like ? and id = ?" + + with plan = 1.51861286163 secs + no plan = 1.26903700829 secs + + + + */ + $plan = 'P'.md5($sql); + + $execp = ''; + foreach($inputarr as $v) { + if ($execp) $execp .= ','; + if (is_string($v)) { + if (strncmp($v,"'",1) !== 0) $execp .= $this->qstr($v); + } else { + $execp .= $v; + } + } + + if ($execp) $exsql = "EXECUTE $plan ($execp)"; + else $exsql = "EXECUTE $plan"; + + + $rez = @pg_exec($this->_connectionID,$exsql); + if (!$rez) { + # Perhaps plan does not exist? Prepare/compile plan. + $params = ''; + foreach($inputarr as $v) { + if ($params) $params .= ','; + if (is_string($v)) { + $params .= 'VARCHAR'; + } else if (is_integer($v)) { + $params .= 'INTEGER'; + } else { + $params .= "REAL"; + } + } + $sqlarr = explode('?',$sql); + //print_r($sqlarr); + $sql = ''; + $i = 1; + foreach($sqlarr as $v) { + $sql .= $v.' $'.$i; + $i++; + } + $s = "PREPARE $plan ($params) AS ".substr($sql,0,strlen($sql)-2); + //adodb_pr($s); + $rez = pg_exec($this->_connectionID,$s); + //echo $this->ErrorMsg(); + } + if ($rez) + $rez = pg_exec($this->_connectionID,$exsql); + } else { + //adodb_backtrace(); + $rez = pg_exec($this->_connectionID,$sql); + } + // check if no data returned, then no need to create real recordset + if ($rez && pg_numfields($rez) <= 0) { + if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') { + pg_freeresult($this->_resultid); + } + $this->_resultid = $rez; + return true; + } + + return $rez; + } + + function _errconnect() + { + if (defined('DB_ERROR_CONNECT_FAILED')) return DB_ERROR_CONNECT_FAILED; + else return 'Database connection failed'; + } + + /* Returns: the last error message from previous database operation */ + function ErrorMsg() + { + if ($this->_errorMsg !== false) return $this->_errorMsg; + if (ADODB_PHPVER >= 0x4300) { + if (!empty($this->_resultid)) { + $this->_errorMsg = @pg_result_error($this->_resultid); + if ($this->_errorMsg) return $this->_errorMsg; + } + + if (!empty($this->_connectionID)) { + $this->_errorMsg = @pg_last_error($this->_connectionID); + } else $this->_errorMsg = $this->_errconnect(); + } else { + if (empty($this->_connectionID)) $this->_errconnect(); + else $this->_errorMsg = @pg_errormessage($this->_connectionID); + } + return $this->_errorMsg; + } + + function ErrorNo() + { + $e = $this->ErrorMsg(); + if (strlen($e)) { + return ADOConnection::MetaError($e); + } + return 0; + } + + // returns true or false + function _close() + { + if ($this->transCnt) $this->RollbackTrans(); + if ($this->_resultid) { + @pg_freeresult($this->_resultid); + $this->_resultid = false; + } + @pg_close($this->_connectionID); + $this->_connectionID = false; + return true; + } + + + /* + * Maximum size of C field + */ + function CharMax() + { + return 1000000000; // should be 1 Gb? + } + + /* + * Maximum size of X field + */ + function TextMax() + { + return 1000000000; // should be 1 Gb? + } + + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordSet_postgres64 extends ADORecordSet{ + var $_blobArr; + var $databaseType = "postgres64"; + var $canSeek = true; + function ADORecordSet_postgres64($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_NUM: $this->fetchMode = PGSQL_NUM; break; + case ADODB_FETCH_ASSOC:$this->fetchMode = PGSQL_ASSOC; break; + + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: $this->fetchMode = PGSQL_BOTH; break; + } + $this->adodbFetchMode = $mode; + $this->ADORecordSet($queryID); + } + + function GetRowAssoc($upper=true) + { + if ($this->fetchMode == PGSQL_ASSOC && !$upper) return $this->fields; + $row = ADORecordSet::GetRowAssoc($upper); + return $row; + } + + function _initrs() + { + global $ADODB_COUNTRECS; + $qid = $this->_queryID; + $this->_numOfRows = ($ADODB_COUNTRECS)? @pg_numrows($qid):-1; + $this->_numOfFields = @pg_numfields($qid); + + // cache types for blob decode check + // apparently pg_fieldtype actually performs an sql query on the database to get the type. + if (empty($this->connection->noBlobs)) + for ($i=0, $max = $this->_numOfFields; $i < $max; $i++) { + if (pg_fieldtype($qid,$i) == 'bytea') { + $this->_blobArr[$i] = pg_fieldname($qid,$i); + } + } + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + if ($this->fetchMode != PGSQL_NUM) return @$this->fields[$colname]; + + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + function FetchField($off = 0) + { + // offsets begin at 0 + + $o= new ADOFieldObject(); + $o->name = @pg_fieldname($this->_queryID,$off); + $o->type = @pg_fieldtype($this->_queryID,$off); + $o->max_length = @pg_fieldsize($this->_queryID,$off); + return $o; + } + + function _seek($row) + { + return @pg_fetch_row($this->_queryID,$row); + } + + function _decode($blob) + { + if ($blob === NULL) return NULL; + eval('$realblob="'.adodb_str_replace(array('"','$'),array('\"','\$'),$blob).'";'); + return $realblob; + } + + function _fixblobs() + { + if ($this->fetchMode == PGSQL_NUM || $this->fetchMode == PGSQL_BOTH) { + foreach($this->_blobArr as $k => $v) { + $this->fields[$k] = ADORecordSet_postgres64::_decode($this->fields[$k]); + } + } + if ($this->fetchMode == PGSQL_ASSOC || $this->fetchMode == PGSQL_BOTH) { + foreach($this->_blobArr as $k => $v) { + $this->fields[$v] = ADORecordSet_postgres64::_decode($this->fields[$v]); + } + } + } + + // 10% speedup to move MoveNext to child class + function MoveNext() + { + if (!$this->EOF) { + $this->_currentRow++; + if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) { + $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); + if (is_array($this->fields) && $this->fields) { + if (isset($this->_blobArr)) $this->_fixblobs(); + return true; + } + } + $this->fields = false; + $this->EOF = true; + } + return false; + } + + function _fetch() + { + + if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0) + return false; + + $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); + + if ($this->fields && isset($this->_blobArr)) $this->_fixblobs(); + + return (is_array($this->fields)); + } + + function _close() + { + return @pg_freeresult($this->_queryID); + } + + function MetaType($t,$len=-1,$fieldobj=false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + switch (strtoupper($t)) { + case 'MONEY': // stupid, postgres expects money to be a string + case 'INTERVAL': + case 'CHAR': + case 'CHARACTER': + case 'VARCHAR': + case 'NAME': + case 'BPCHAR': + case '_VARCHAR': + case 'INET': + case 'MACADDR': + if ($len <= $this->blobSize) return 'C'; + + case 'TEXT': + return 'X'; + + case 'IMAGE': // user defined type + case 'BLOB': // user defined type + case 'BIT': // This is a bit string, not a single bit, so don't return 'L' + case 'VARBIT': + case 'BYTEA': + return 'B'; + + case 'BOOL': + case 'BOOLEAN': + return 'L'; + + case 'DATE': + return 'D'; + + + case 'TIMESTAMP WITHOUT TIME ZONE': + case 'TIME': + case 'DATETIME': + case 'TIMESTAMP': + case 'TIMESTAMPTZ': + return 'T'; + + case 'SMALLINT': + case 'BIGINT': + case 'INTEGER': + case 'INT8': + case 'INT4': + case 'INT2': + if (isset($fieldobj) && + empty($fieldobj->primary_key) && empty($fieldobj->unique)) return 'I'; + + case 'OID': + case 'SERIAL': + return 'R'; + + default: + return 'N'; + } + } + +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-postgres7.inc.php b/includes/adodb/drivers/adodb-postgres7.inc.php new file mode 100644 index 00000000..ef5ce882 --- /dev/null +++ b/includes/adodb/drivers/adodb-postgres7.inc.php @@ -0,0 +1,313 @@ +ADODB_postgres64(); + if (ADODB_ASSOC_CASE !== 2) { + $this->rsPrefix .= 'assoc_'; + } + $this->_bindInputArray = PHP_VERSION >= 5.1; + } + + + // the following should be compat with postgresql 7.2, + // which makes obsolete the LIMIT limit,offset syntax + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + { + $offsetStr = ($offset >= 0) ? " OFFSET ".((integer)$offset) : ''; + $limitStr = ($nrows >= 0) ? " LIMIT ".((integer)$nrows) : ''; + if ($secs2cache) + $rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr); + else + $rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr); + + return $rs; + } + /* + function Prepare($sql) + { + $info = $this->ServerInfo(); + if ($info['version']>=7.3) { + return array($sql,false); + } + return $sql; + } + */ + + /* + I discovered that the MetaForeignKeys method no longer worked for Postgres 8.3. + I went ahead and modified it to work for both 8.2 and 8.3. + Please feel free to include this change in your next release of adodb. + William Kolodny [William.Kolodny#gt-t.net] + */ + function MetaForeignKeys($table, $owner=false, $upper=false) + { + $sql=" + SELECT fum.ftblname AS lookup_table, split_part(fum.rf, ')'::text, 1) AS lookup_field, + fum.ltable AS dep_table, split_part(fum.lf, ')'::text, 1) AS dep_field + FROM ( + SELECT fee.ltable, fee.ftblname, fee.consrc, split_part(fee.consrc,'('::text, 2) AS lf, + split_part(fee.consrc, '('::text, 3) AS rf + FROM ( + SELECT foo.relname AS ltable, foo.ftblname, + pg_get_constraintdef(foo.oid) AS consrc + FROM ( + SELECT c.oid, c.conname AS name, t.relname, ft.relname AS ftblname + FROM pg_constraint c + JOIN pg_class t ON (t.oid = c.conrelid) + JOIN pg_class ft ON (ft.oid = c.confrelid) + JOIN pg_namespace nft ON (nft.oid = ft.relnamespace) + LEFT JOIN pg_description ds ON (ds.objoid = c.oid) + JOIN pg_namespace n ON (n.oid = t.relnamespace) + WHERE c.contype = 'f'::\"char\" + ORDER BY t.relname, n.nspname, c.conname, c.oid + ) foo + ) fee) fum + WHERE fum.ltable='".strtolower($table)."' + ORDER BY fum.ftblname, fum.ltable, split_part(fum.lf, ')'::text, 1) + "; + $rs = $this->Execute($sql); + + if (!$rs || $rs->EOF) return false; + + $a = array(); + while (!$rs->EOF) { + if ($upper) { + $a[strtoupper($rs->Fields('lookup_table'))][] = strtoupper(ereg_replace('"','',$rs->Fields('dep_field').'='.$rs->Fields('lookup_field'))); + } else { + $a[$rs->Fields('lookup_table')][] = ereg_replace('"','',$rs->Fields('dep_field').'='.$rs->Fields('lookup_field')); + } + adodb_movenext($rs); + } + + return $a; + + } + + // from Edward Jaramilla, improved version - works on pg 7.4 + function _old_MetaForeignKeys($table, $owner=false, $upper=false) + { + $sql = 'SELECT t.tgargs as args + FROM + pg_trigger t,pg_class c,pg_proc p + WHERE + t.tgenabled AND + t.tgrelid = c.oid AND + t.tgfoid = p.oid AND + p.proname = \'RI_FKey_check_ins\' AND + c.relname = \''.strtolower($table).'\' + ORDER BY + t.tgrelid'; + + $rs = $this->Execute($sql); + + if (!$rs || $rs->EOF) return false; + + $arr = $rs->GetArray(); + $a = array(); + foreach($arr as $v) { + $data = explode(chr(0), $v['args']); + $size = count($data)-1; //-1 because the last node is empty + for($i = 4; $i < $size; $i++) { + if ($upper) + $a[strtoupper($data[2])][] = strtoupper($data[$i].'='.$data[++$i]); + else + $a[$data[2]][] = $data[$i].'='.$data[++$i]; + } + } + return $a; + } + + function _query($sql,$inputarr) + { + if (! $this->_bindInputArray) { + // We don't have native support for parameterized queries, so let's emulate it at the parent + return ADODB_postgres64::_query($sql, $inputarr); + } + $this->_errorMsg = false; + // -- added Cristiano da Cunha Duarte + if ($inputarr) { + $sqlarr = explode('?',trim($sql)); + $sql = ''; + $i = 1; + $last = sizeof($sqlarr)-1; + foreach($sqlarr as $v) { + if ($last < $i) $sql .= $v; + else $sql .= $v.' $'.$i; + $i++; + } + + $rez = pg_query_params($this->_connectionID,$sql, $inputarr); + } else { + $rez = pg_query($this->_connectionID,$sql); + } + // check if no data returned, then no need to create real recordset + if ($rez && pg_numfields($rez) <= 0) { + if (is_resource($this->_resultid) && get_resource_type($this->_resultid) === 'pgsql result') { + pg_freeresult($this->_resultid); + } + $this->_resultid = $rez; + return true; + } + return $rez; + } + + // this is a set of functions for managing client encoding - very important if the encodings + // of your database and your output target (i.e. HTML) don't match + //for instance, you may have UNICODE database and server it on-site as WIN1251 etc. + // GetCharSet - get the name of the character set the client is using now + // the functions should work with Postgres 7.0 and above, the set of charsets supported + // depends on compile flags of postgres distribution - if no charsets were compiled into the server + // it will return 'SQL_ANSI' always + function GetCharSet() + { + //we will use ADO's builtin property charSet + $this->charSet = @pg_client_encoding($this->_connectionID); + if (!$this->charSet) { + return false; + } else { + return $this->charSet; + } + } + + // SetCharSet - switch the client encoding + function SetCharSet($charset_name) + { + $this->GetCharSet(); + if ($this->charSet !== $charset_name) { + $if = pg_set_client_encoding($this->_connectionID, $charset_name); + if ($if == "0" & $this->GetCharSet() == $charset_name) { + return true; + } else return false; + } else return true; + } + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordSet_postgres7 extends ADORecordSet_postgres64{ + + var $databaseType = "postgres7"; + + + function ADORecordSet_postgres7($queryID,$mode=false) + { + $this->ADORecordSet_postgres64($queryID,$mode); + } + + // 10% speedup to move MoveNext to child class + function MoveNext() + { + if (!$this->EOF) { + $this->_currentRow++; + if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) { + $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); + + if (is_array($this->fields)) { + if ($this->fields && isset($this->_blobArr)) $this->_fixblobs(); + return true; + } + } + $this->fields = false; + $this->EOF = true; + } + return false; + } + +} + +class ADORecordSet_assoc_postgres7 extends ADORecordSet_postgres64{ + + var $databaseType = "postgres7"; + + + function ADORecordSet_assoc_postgres7($queryID,$mode=false) + { + $this->ADORecordSet_postgres64($queryID,$mode); + } + + function _fetch() + { + if ($this->_currentRow >= $this->_numOfRows && $this->_numOfRows >= 0) + return false; + + $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); + + if ($this->fields) { + if (isset($this->_blobArr)) $this->_fixblobs(); + $this->_updatefields(); + } + + return (is_array($this->fields)); + } + + // Create associative array + function _updatefields() + { + if (ADODB_ASSOC_CASE == 2) return; // native + + $arr = array(); + $lowercase = (ADODB_ASSOC_CASE == 0); + + foreach($this->fields as $k => $v) { + if (is_integer($k)) $arr[$k] = $v; + else { + if ($lowercase) + $arr[strtolower($k)] = $v; + else + $arr[strtoupper($k)] = $v; + } + } + $this->fields = $arr; + } + + function MoveNext() + { + if (!$this->EOF) { + $this->_currentRow++; + if ($this->_numOfRows < 0 || $this->_numOfRows > $this->_currentRow) { + $this->fields = @pg_fetch_array($this->_queryID,$this->_currentRow,$this->fetchMode); + + if (is_array($this->fields)) { + if ($this->fields) { + if (isset($this->_blobArr)) $this->_fixblobs(); + + $this->_updatefields(); + } + return true; + } + } + + + $this->fields = false; + $this->EOF = true; + } + return false; + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-postgres8.inc.php b/includes/adodb/drivers/adodb-postgres8.inc.php new file mode 100644 index 00000000..dbb75117 --- /dev/null +++ b/includes/adodb/drivers/adodb-postgres8.inc.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-proxy.inc.php b/includes/adodb/drivers/adodb-proxy.inc.php new file mode 100644 index 00000000..c0714ca2 --- /dev/null +++ b/includes/adodb/drivers/adodb-proxy.inc.php @@ -0,0 +1,33 @@ +ADORecordset($id,$mode); + } + }; +} // define + +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-sapdb.inc.php b/includes/adodb/drivers/adodb-sapdb.inc.php new file mode 100644 index 00000000..74fc251a --- /dev/null +++ b/includes/adodb/drivers/adodb-sapdb.inc.php @@ -0,0 +1,184 @@ +curmode = SQL_CUR_USE_ODBC; + $this->ADODB_odbc(); + } + + function ServerInfo() + { + $info = ADODB_odbc::ServerInfo(); + if (!$info['version'] && preg_match('/([0-9.]+)/',$info['description'],$matches)) { + $info['version'] = $matches[1]; + } + return $info; + } + + function MetaPrimaryKeys($table) + { + $table = $this->Quote(strtoupper($table)); + + return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"); + } + + function MetaIndexes ($table, $primary = FALSE) + { + $table = $this->Quote(strtoupper($table)); + + $sql = "SELECT INDEXNAME,TYPE,COLUMNNAME FROM INDEXCOLUMNS ". + " WHERE TABLENAME=$table". + " ORDER BY INDEXNAME,COLUMNNO"; + + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + + $rs = $this->Execute($sql); + if (isset($savem)) { + $this->SetFetchMode($savem); + } + $ADODB_FETCH_MODE = $save; + + if (!is_object($rs)) { + return FALSE; + } + + $indexes = array(); + while ($row = $rs->FetchRow()) { + $indexes[$row[0]]['unique'] = $row[1] == 'UNIQUE'; + $indexes[$row[0]]['columns'][] = $row[2]; + } + if ($primary) { + $indexes['SYSPRIMARYKEYINDEX'] = array( + 'unique' => True, // by definition + 'columns' => $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table AND mode='KEY' ORDER BY pos"), + ); + } + return $indexes; + } + + function MetaColumns ($table) + { + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + $table = $this->Quote(strtoupper($table)); + + $retarr = array(); + foreach($this->GetAll("SELECT COLUMNNAME,DATATYPE,LEN,DEC,NULLABLE,MODE,\"DEFAULT\",CASE WHEN \"DEFAULT\" IS NULL THEN 0 ELSE 1 END AS HAS_DEFAULT FROM COLUMNS WHERE tablename=$table ORDER BY pos") as $column) + { + $fld = new ADOFieldObject(); + $fld->name = $column[0]; + $fld->type = $column[1]; + $fld->max_length = $fld->type == 'LONG' ? 2147483647 : $column[2]; + $fld->scale = $column[3]; + $fld->not_null = $column[4] == 'NO'; + $fld->primary_key = $column[5] == 'KEY'; + if ($fld->has_default = $column[7]) { + if ($fld->primary_key && $column[6] == 'DEFAULT SERIAL (1)') { + $fld->auto_increment = true; + $fld->has_default = false; + } else { + $fld->default_value = $column[6]; + switch($fld->type) { + case 'VARCHAR': + case 'CHARACTER': + case 'LONG': + $fld->default_value = $column[6]; + break; + default: + $fld->default_value = trim($column[6]); + break; + } + } + } + $retarr[$fld->name] = $fld; + } + if (isset($savem)) { + $this->SetFetchMode($savem); + } + $ADODB_FETCH_MODE = $save; + + return $retarr; + } + + function MetaColumnNames($table) + { + $table = $this->Quote(strtoupper($table)); + + return $this->GetCol("SELECT columnname FROM COLUMNS WHERE tablename=$table ORDER BY pos"); + } + + // unlike it seems, this depends on the db-session and works in a multiuser environment + function _insertid($table,$column) + { + return empty($table) ? False : $this->GetOne("SELECT $table.CURRVAL FROM DUAL"); + } + + /* + SelectLimit implementation problems: + + The following will return random 10 rows as order by performed after "WHERE rowno<10" + which is not ideal... + + select * from table where rowno < 10 order by 1 + + This means that we have to use the adoconnection base class SelectLimit when + there is an "order by". + + See http://listserv.sap.com/pipermail/sapdb.general/2002-January/010405.html + */ + +}; + + +class ADORecordSet_sapdb extends ADORecordSet_odbc { + + var $databaseType = "sapdb"; + + function ADORecordSet_sapdb($id,$mode=false) + { + $this->ADORecordSet_odbc($id,$mode); + } +} + +} //define +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-sqlanywhere.inc.php b/includes/adodb/drivers/adodb-sqlanywhere.inc.php new file mode 100644 index 00000000..71037010 --- /dev/null +++ b/includes/adodb/drivers/adodb-sqlanywhere.inc.php @@ -0,0 +1,169 @@ +create_blobvar($blobVarName); + + b) load blob var from file. $filename must be complete path + + $dbcon->load_blobvar_from_file($blobVarName, $filename); + + c) Use the $blobVarName in SQL insert or update statement in the values + clause: + + $recordSet = $dbconn->Execute('INSERT INTO tabname (idcol, blobcol) ' + . + 'VALUES (\'test\', ' . $blobVarName . ')'); + + instead of loading blob from a file, you can also load from + an unformatted (raw) blob variable: + $dbcon->load_blobvar_from_var($blobVarName, $varName); + + d) drop blob variable on db server to free up resources: + $dbconn->drop_blobvar($blobVarName); + + Sybase_SQLAnywhere data driver. Requires ODBC. + +*/ + +// security - hide paths +if (!defined('ADODB_DIR')) die(); + +if (!defined('_ADODB_ODBC_LAYER')) { + include(ADODB_DIR."/drivers/adodb-odbc.inc.php"); +} + +if (!defined('ADODB_SYBASE_SQLANYWHERE')){ + + define('ADODB_SYBASE_SQLANYWHERE',1); + + class ADODB_sqlanywhere extends ADODB_odbc { + var $databaseType = "sqlanywhere"; + var $hasInsertID = true; + + function ADODB_sqlanywhere() + { + $this->ADODB_odbc(); + } + + function _insertid() { + return $this->GetOne('select @@identity'); + } + + function create_blobvar($blobVarName) { + $this->Execute("create variable $blobVarName long binary"); + return; + } + + function drop_blobvar($blobVarName) { + $this->Execute("drop variable $blobVarName"); + return; + } + + function load_blobvar_from_file($blobVarName, $filename) { + $chunk_size = 1000; + + $fd = fopen ($filename, "rb"); + + $integer_chunks = (integer)filesize($filename) / $chunk_size; + $modulus = filesize($filename) % $chunk_size; + if ($modulus != 0){ + $integer_chunks += 1; + } + + for($loop=1;$loop<=$integer_chunks;$loop++){ + $contents = fread ($fd, $chunk_size); + $contents = bin2hex($contents); + + $hexstring = ''; + + for($loop2=0;$loop2qstr($hexstring); + + $this->Execute("set $blobVarName = $blobVarName || " . $hexstring); + } + + fclose ($fd); + return; + } + + function load_blobvar_from_var($blobVarName, &$varName) { + $chunk_size = 1000; + + $integer_chunks = (integer)strlen($varName) / $chunk_size; + $modulus = strlen($varName) % $chunk_size; + if ($modulus != 0){ + $integer_chunks += 1; + } + + for($loop=1;$loop<=$integer_chunks;$loop++){ + $contents = substr ($varName, (($loop - 1) * $chunk_size), $chunk_size); + $contents = bin2hex($contents); + + $hexstring = ''; + + for($loop2=0;$loop2qstr($hexstring); + + $this->Execute("set $blobVarName = $blobVarName || " . $hexstring); + } + + return; + } + + /* + Insert a null into the blob field of the table first. + Then use UpdateBlob to store the blob. + + Usage: + + $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); + $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); + */ + function UpdateBlob($table,$column,&$val,$where,$blobtype='BLOB') + { + $blobVarName = 'hold_blob'; + $this->create_blobvar($blobVarName); + $this->load_blobvar_from_var($blobVarName, $val); + $this->Execute("UPDATE $table SET $column=$blobVarName WHERE $where"); + $this->drop_blobvar($blobVarName); + return true; + } + }; //class + + class ADORecordSet_sqlanywhere extends ADORecordSet_odbc { + + var $databaseType = "sqlanywhere"; + + function ADORecordSet_sqlanywhere($id,$mode=false) + { + $this->ADORecordSet_odbc($id,$mode); + } + + + }; //class + + +} //define +?> diff --git a/includes/adodb/drivers/adodb-sqlite.inc.php b/includes/adodb/drivers/adodb-sqlite.inc.php new file mode 100644 index 00000000..eec75b1a --- /dev/null +++ b/includes/adodb/drivers/adodb-sqlite.inc.php @@ -0,0 +1,398 @@ +fmtDate)."'"; + case 'sysTimeStamp' : return "'".date($this->sysTimeStamp)."'"; + } + }*/ + + function ServerInfo() + { + $arr['version'] = sqlite_libversion(); + $arr['description'] = 'SQLite '; + $arr['encoding'] = sqlite_libencoding(); + return $arr; + } + + function BeginTrans() + { + if ($this->transOff) return true; + $ret = $this->Execute("BEGIN TRANSACTION"); + $this->transCnt += 1; + return true; + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + if (!$ok) return $this->RollbackTrans(); + $ret = $this->Execute("COMMIT"); + if ($this->transCnt>0)$this->transCnt -= 1; + return !empty($ret); + } + + function RollbackTrans() + { + if ($this->transOff) return true; + $ret = $this->Execute("ROLLBACK"); + if ($this->transCnt>0)$this->transCnt -= 1; + return !empty($ret); + } + + // mark newnham + function MetaColumns($tab) + { + global $ADODB_FETCH_MODE; + $false = false; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + $rs = $this->Execute("PRAGMA table_info('$tab')"); + if (isset($savem)) $this->SetFetchMode($savem); + if (!$rs) { + $ADODB_FETCH_MODE = $save; + return $false; + } + $arr = array(); + while ($r = $rs->FetchRow()) { + $type = explode('(',$r['type']); + $size = ''; + if (sizeof($type)==2) + $size = trim($type[1],')'); + $fn = strtoupper($r['name']); + $fld = new ADOFieldObject; + $fld->name = $r['name']; + $fld->type = $type[0]; + $fld->max_length = $size; + $fld->not_null = $r['notnull']; + $fld->default_value = $r['dflt_value']; + $fld->scale = 0; + if ($save == ADODB_FETCH_NUM) $arr[] = $fld; + else $arr[strtoupper($fld->name)] = $fld; + } + $rs->Close(); + $ADODB_FETCH_MODE = $save; + return $arr; + } + + function _init($parentDriver) + { + + $parentDriver->hasTransactions = false; + $parentDriver->hasInsertID = true; + } + + function _insertid() + { + return sqlite_last_insert_rowid($this->_connectionID); + } + + function _affectedrows() + { + return sqlite_changes($this->_connectionID); + } + + function ErrorMsg() + { + if ($this->_logsql) return $this->_errorMsg; + return ($this->_errorNo) ? sqlite_error_string($this->_errorNo) : ''; + } + + function ErrorNo() + { + return $this->_errorNo; + } + + function SQLDate($fmt, $col=false) + { + $fmt = $this->qstr($fmt); + return ($col) ? "adodb_date2($fmt,$col)" : "adodb_date($fmt)"; + } + + + function _createFunctions() + { + @sqlite_create_function($this->_connectionID, 'adodb_date', 'adodb_date', 1); + @sqlite_create_function($this->_connectionID, 'adodb_date2', 'adodb_date2', 2); + } + + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!function_exists('sqlite_open')) return null; + if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename; + + $this->_connectionID = sqlite_open($argHostname); + if ($this->_connectionID === false) return false; + $this->_createFunctions(); + return true; + } + + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!function_exists('sqlite_open')) return null; + if (empty($argHostname) && $argDatabasename) $argHostname = $argDatabasename; + + $this->_connectionID = sqlite_popen($argHostname); + if ($this->_connectionID === false) return false; + $this->_createFunctions(); + return true; + } + + // returns query ID if successful, otherwise false + function _query($sql,$inputarr=false) + { + $rez = sqlite_query($sql,$this->_connectionID); + if (!$rez) { + $this->_errorNo = sqlite_last_error($this->_connectionID); + } + + return $rez; + } + + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + { + $offsetStr = ($offset >= 0) ? " OFFSET $offset" : ''; + $limitStr = ($nrows >= 0) ? " LIMIT $nrows" : ($offset >= 0 ? ' LIMIT 999999999' : ''); + if ($secs2cache) + $rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr); + else + $rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr); + + return $rs; + } + + /* + This algorithm is not very efficient, but works even if table locking + is not available. + + Will return false if unable to generate an ID after $MAXLOOPS attempts. + */ + var $_genSeqSQL = "create table %s (id integer)"; + + function GenID($seq='adodbseq',$start=1) + { + // if you have to modify the parameter below, your database is overloaded, + // or you need to implement generation of id's yourself! + $MAXLOOPS = 100; + //$this->debug=1; + while (--$MAXLOOPS>=0) { + @($num = $this->GetOne("select id from $seq")); + if ($num === false) { + $this->Execute(sprintf($this->_genSeqSQL ,$seq)); + $start -= 1; + $num = '0'; + $ok = $this->Execute("insert into $seq values($start)"); + if (!$ok) return false; + } + $this->Execute("update $seq set id=id+1 where id=$num"); + + if ($this->affected_rows() > 0) { + $num += 1; + $this->genID = $num; + return $num; + } + } + if ($fn = $this->raiseErrorFn) { + $fn($this->databaseType,'GENID',-32000,"Unable to generate unique id after $MAXLOOPS attempts",$seq,$num); + } + return false; + } + + function CreateSequence($seqname='adodbseq',$start=1) + { + if (empty($this->_genSeqSQL)) return false; + $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); + if (!$ok) return false; + $start -= 1; + return $this->Execute("insert into $seqname values($start)"); + } + + var $_dropSeqSQL = 'drop table %s'; + function DropSequence($seqname) + { + if (empty($this->_dropSeqSQL)) return false; + return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); + } + + // returns true or false + function _close() + { + return @sqlite_close($this->_connectionID); + } + + function MetaIndexes($table, $primary = FALSE, $owner=false) + { + $false = false; + // save old fetch mode + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + $SQL=sprintf("SELECT name,sql FROM sqlite_master WHERE type='index' AND tbl_name='%s'", strtolower($table)); + $rs = $this->Execute($SQL); + if (!is_object($rs)) { + if (isset($savem)) + $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + return $false; + } + + $indexes = array (); + while ($row = $rs->FetchRow()) { + if ($primary && preg_match("/primary/i",$row[1]) == 0) continue; + if (!isset($indexes[$row[0]])) { + + $indexes[$row[0]] = array( + 'unique' => preg_match("/unique/i",$row[1]), + 'columns' => array()); + } + /** + * There must be a more elegant way of doing this, + * the index elements appear in the SQL statement + * in cols[1] between parentheses + * e.g CREATE UNIQUE INDEX ware_0 ON warehouse (org,warehouse) + */ + $cols = explode("(",$row[1]); + $cols = explode(")",$cols[1]); + array_pop($cols); + $indexes[$row[0]]['columns'] = $cols; + } + if (isset($savem)) { + $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + } + return $indexes; + } + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_sqlite extends ADORecordSet { + + var $databaseType = "sqlite"; + var $bind = false; + + function ADORecordset_sqlite($queryID,$mode=false) + { + + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch($mode) { + case ADODB_FETCH_NUM: $this->fetchMode = SQLITE_NUM; break; + case ADODB_FETCH_ASSOC: $this->fetchMode = SQLITE_ASSOC; break; + default: $this->fetchMode = SQLITE_BOTH; break; + } + $this->adodbFetchMode = $mode; + + $this->_queryID = $queryID; + + $this->_inited = true; + $this->fields = array(); + if ($queryID) { + $this->_currentRow = 0; + $this->EOF = !$this->_fetch(); + @$this->_initrs(); + } else { + $this->_numOfRows = 0; + $this->_numOfFields = 0; + $this->EOF = true; + } + + return $this->_queryID; + } + + + function FetchField($fieldOffset = -1) + { + $fld = new ADOFieldObject; + $fld->name = sqlite_field_name($this->_queryID, $fieldOffset); + $fld->type = 'VARCHAR'; + $fld->max_length = -1; + return $fld; + } + + function _initrs() + { + $this->_numOfRows = @sqlite_num_rows($this->_queryID); + $this->_numOfFields = @sqlite_num_fields($this->_queryID); + } + + function Fields($colname) + { + if ($this->fetchMode != SQLITE_NUM) return $this->fields[$colname]; + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + function _seek($row) + { + return sqlite_seek($this->_queryID, $row); + } + + function _fetch($ignore_fields=false) + { + $this->fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode); + return !empty($this->fields); + } + + function _close() + { + } + +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-sqlitepo.inc.php b/includes/adodb/drivers/adodb-sqlitepo.inc.php new file mode 100644 index 00000000..82e159cd --- /dev/null +++ b/includes/adodb/drivers/adodb-sqlitepo.inc.php @@ -0,0 +1,62 @@ +ADODB_sqlite(); + } +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + +class ADORecordset_sqlitepo extends ADORecordset_sqlite { + + var $databaseType = 'sqlitepo'; + + function ADORecordset_sqlitepo($queryID,$mode=false) + { + $this->ADORecordset_sqlite($queryID,$mode); + } + + // Modified to strip table names from returned fields + function _fetch($ignore_fields=false) + { + $this->fields = array(); + $fields = @sqlite_fetch_array($this->_queryID,$this->fetchMode); + if(is_array($fields)) + foreach($fields as $n => $v) + { + if(($p = strpos($n, ".")) !== false) + $n = substr($n, $p+1); + $this->fields[$n] = $v; + } + + return !empty($this->fields); + } +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-sybase.inc.php b/includes/adodb/drivers/adodb-sybase.inc.php new file mode 100644 index 00000000..9c00d026 --- /dev/null +++ b/includes/adodb/drivers/adodb-sybase.inc.php @@ -0,0 +1,418 @@ +GetOne('select @@identity'); + } + // might require begintrans -- committrans + function _affectedrows() + { + return $this->GetOne('select @@rowcount'); + } + + + function BeginTrans() + { + + if ($this->transOff) return true; + $this->transCnt += 1; + + $this->Execute('BEGIN TRAN'); + return true; + } + + function CommitTrans($ok=true) + { + if ($this->transOff) return true; + + if (!$ok) return $this->RollbackTrans(); + + $this->transCnt -= 1; + $this->Execute('COMMIT TRAN'); + return true; + } + + function RollbackTrans() + { + if ($this->transOff) return true; + $this->transCnt -= 1; + $this->Execute('ROLLBACK TRAN'); + return true; + } + + // http://www.isug.com/Sybase_FAQ/ASE/section6.1.html#6.1.4 + function RowLock($tables,$where,$flds='top 1 null as ignore') + { + if (!$this->_hastrans) $this->BeginTrans(); + $tables = str_replace(',',' HOLDLOCK,',$tables); + return $this->GetOne("select $flds from $tables HOLDLOCK where $where"); + + } + + function SelectDB($dbName) + { + $this->database = $dbName; + $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions + if ($this->_connectionID) { + return @sybase_select_db($dbName); + } + else return false; + } + + /* Returns: the last error message from previous database operation + Note: This function is NOT available for Microsoft SQL Server. */ + + + function ErrorMsg() + { + if ($this->_logsql) return $this->_errorMsg; + if (function_exists('sybase_get_last_message')) + $this->_errorMsg = sybase_get_last_message(); + else + $this->_errorMsg = isset($php_errormsg) ? $php_errormsg : 'SYBASE error messages not supported on this platform'; + return $this->_errorMsg; + } + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!function_exists('sybase_connect')) return null; + + $this->_connectionID = sybase_connect($argHostname,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!function_exists('sybase_connect')) return null; + + $this->_connectionID = sybase_pconnect($argHostname,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + + // returns query ID if successful, otherwise false + function _query($sql,$inputarr) + { + global $ADODB_COUNTRECS; + + if ($ADODB_COUNTRECS == false && ADODB_PHPVER >= 0x4300) + return sybase_unbuffered_query($sql,$this->_connectionID); + else + return sybase_query($sql,$this->_connectionID); + } + + // See http://www.isug.com/Sybase_FAQ/ASE/section6.2.html#6.2.12 + function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0) + { + if ($secs2cache > 0) {// we do not cache rowcount, so we have to load entire recordset + $rs = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + return $rs; + } + + $nrows = (integer) $nrows; + $offset = (integer) $offset; + + $cnt = ($nrows >= 0) ? $nrows : 999999999; + if ($offset > 0 && $cnt) $cnt += $offset; + + $this->Execute("set rowcount $cnt"); + $rs = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,0); + $this->Execute("set rowcount 0"); + + return $rs; + } + + // returns true or false + function _close() + { + return @sybase_close($this->_connectionID); + } + + static function UnixDate($v) + { + return ADORecordSet_array_sybase::UnixDate($v); + } + + static function UnixTimeStamp($v) + { + return ADORecordSet_array_sybase::UnixTimeStamp($v); + } + + + + # Added 2003-10-05 by Chris Phillipson + # Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=16756?target=%25N%15_12018_START_RESTART_N%25 + # to convert similar Microsoft SQL*Server (mssql) API into Sybase compatible version + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysTimeStamp; + $s = ''; + + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + if ($s) $s .= '+'; + $ch = $fmt[$i]; + switch($ch) { + case 'Y': + case 'y': + $s .= "datename(yy,$col)"; + break; + case 'M': + $s .= "convert(char(3),$col,0)"; + break; + case 'm': + $s .= "str_replace(str(month($col),2),' ','0')"; + break; + case 'Q': + case 'q': + $s .= "datename(qq,$col)"; + break; + case 'D': + case 'd': + $s .= "str_replace(str(datepart(dd,$col),2),' ','0')"; + break; + case 'h': + $s .= "substring(convert(char(14),$col,0),13,2)"; + break; + + case 'H': + $s .= "str_replace(str(datepart(hh,$col),2),' ','0')"; + break; + + case 'i': + $s .= "str_replace(str(datepart(mi,$col),2),' ','0')"; + break; + case 's': + $s .= "str_replace(str(datepart(ss,$col),2),' ','0')"; + break; + case 'a': + case 'A': + $s .= "substring(convert(char(19),$col,0),18,2)"; + break; + + default: + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + $s .= $this->qstr($ch); + break; + } + } + return $s; + } + + # Added 2003-10-07 by Chris Phillipson + # Used ASA SQL Reference Manual -- http://sybooks.sybase.com/onlinebooks/group-aw/awg0800e/dbrfen8/@ebt-link;pt=5981;uf=0?target=0;window=new;showtoc=true;book=dbrfen8 + # to convert similar Microsoft SQL*Server (mssql) API into Sybase compatible version + function MetaPrimaryKeys($table) + { + $sql = "SELECT c.column_name " . + "FROM syscolumn c, systable t " . + "WHERE t.table_name='$table' AND c.table_id=t.table_id " . + "AND t.table_type='BASE' " . + "AND c.pkey = 'Y' " . + "ORDER BY c.column_id"; + + $a = $this->GetCol($sql); + if ($a && sizeof($a)>0) return $a; + return false; + } +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ +global $ADODB_sybase_mths; +$ADODB_sybase_mths = array( + 'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6, + 'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12); + +class ADORecordset_sybase extends ADORecordSet { + + var $databaseType = "sybase"; + var $canSeek = true; + // _mths works only in non-localised system + var $_mths = array('JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12); + + function ADORecordset_sybase($id,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + if (!$mode) $this->fetchMode = ADODB_FETCH_ASSOC; + else $this->fetchMode = $mode; + $this->ADORecordSet($id,$mode); + } + + /* Returns: an object containing field information. + Get column information in the Recordset object. fetchField() can be used in order to obtain information about + fields in a certain query result. If the field offset isn't specified, the next field that wasn't yet retrieved by + fetchField() is retrieved. */ + function FetchField($fieldOffset = -1) + { + if ($fieldOffset != -1) { + $o = @sybase_fetch_field($this->_queryID, $fieldOffset); + } + else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */ + $o = @sybase_fetch_field($this->_queryID); + } + // older versions of PHP did not support type, only numeric + if ($o && !isset($o->type)) $o->type = ($o->numeric) ? 'float' : 'varchar'; + return $o; + } + + function _initrs() + { + global $ADODB_COUNTRECS; + $this->_numOfRows = ($ADODB_COUNTRECS)? @sybase_num_rows($this->_queryID):-1; + $this->_numOfFields = @sybase_num_fields($this->_queryID); + } + + function _seek($row) + { + return @sybase_data_seek($this->_queryID, $row); + } + + function _fetch($ignore_fields=false) + { + if ($this->fetchMode == ADODB_FETCH_NUM) { + $this->fields = @sybase_fetch_row($this->_queryID); + } else if ($this->fetchMode == ADODB_FETCH_ASSOC) { + $this->fields = @sybase_fetch_row($this->_queryID); + if (is_array($this->fields)) { + $this->fields = $this->GetRowAssoc(ADODB_ASSOC_CASE); + return true; + } + return false; + } else { + $this->fields = @sybase_fetch_array($this->_queryID); + } + if ( is_array($this->fields)) { + return true; + } + + return false; + } + + /* close() only needs to be called if you are worried about using too much memory while your script + is running. All associated result memory for the specified result identifier will automatically be freed. */ + function _close() { + return @sybase_free_result($this->_queryID); + } + + // sybase/mssql uses a default date like Dec 30 2000 12:00AM + static function UnixDate($v) + { + return ADORecordSet_array_sybase::UnixDate($v); + } + + static function UnixTimeStamp($v) + { + return ADORecordSet_array_sybase::UnixTimeStamp($v); + } +} + +class ADORecordSet_array_sybase extends ADORecordSet_array { + function ADORecordSet_array_sybase($id=-1) + { + $this->ADORecordSet_array($id); + } + + // sybase/mssql uses a default date like Dec 30 2000 12:00AM + static function UnixDate($v) + { + global $ADODB_sybase_mths; + + //Dec 30 2000 12:00AM + if (!ereg( "([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})" + ,$v, $rr)) return parent::UnixDate($v); + + if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; + + $themth = substr(strtoupper($rr[1]),0,3); + $themth = $ADODB_sybase_mths[$themth]; + if ($themth <= 0) return false; + // h-m-s-MM-DD-YY + return mktime(0,0,0,$themth,$rr[2],$rr[3]); + } + + static function UnixTimeStamp($v) + { + global $ADODB_sybase_mths; + //11.02.2001 Toni Tunkkari toni.tunkkari@finebyte.com + //Changed [0-9] to [0-9 ] in day conversion + if (!ereg( "([A-Za-z]{3})[-/\. ]([0-9 ]{1,2})[-/\. ]([0-9]{4}) +([0-9]{1,2}):([0-9]{1,2}) *([apAP]{0,1})" + ,$v, $rr)) return parent::UnixTimeStamp($v); + if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0; + + $themth = substr(strtoupper($rr[1]),0,3); + $themth = $ADODB_sybase_mths[$themth]; + if ($themth <= 0) return false; + + switch (strtoupper($rr[6])) { + case 'P': + if ($rr[4]<12) $rr[4] += 12; + break; + case 'A': + if ($rr[4]==12) $rr[4] = 0; + break; + default: + break; + } + // h-m-s-MM-DD-YY + return mktime($rr[4],$rr[5],0,$themth,$rr[2],$rr[3]); + } +} +?> diff --git a/includes/adodb/drivers/adodb-sybase_ase.inc.php b/includes/adodb/drivers/adodb-sybase_ase.inc.php new file mode 100644 index 00000000..e3c5dfc1 --- /dev/null +++ b/includes/adodb/drivers/adodb-sybase_ase.inc.php @@ -0,0 +1,119 @@ +metaTablesSQL) { + // complicated state saving by the need for backward compat + + if ($ttype == 'VIEWS'){ + $sql = str_replace('U', 'V', $this->metaTablesSQL); + }elseif (false === $ttype){ + $sql = str_replace('U',"U' OR type='V", $this->metaTablesSQL); + }else{ // TABLES OR ANY OTHER + $sql = $this->metaTablesSQL; + } + $rs = $this->Execute($sql); + + if ($rs === false || !method_exists($rs, 'GetArray')){ + return $false; + } + $arr = $rs->GetArray(); + + $arr2 = array(); + foreach($arr as $key=>$value){ + $arr2[] = trim($value['name']); + } + return $arr2; + } + return $false; + } + + function MetaDatabases() + { + $arr = array(); + if ($this->metaDatabasesSQL!='') { + $rs = $this->Execute($this->metaDatabasesSQL); + if ($rs && !$rs->EOF){ + while (!$rs->EOF){ + $arr[] = $rs->Fields('name'); + $rs->MoveNext(); + } + return $arr; + } + } + return false; + } + + // fix a bug which prevent the metaColumns query to be executed for Sybase ASE + function MetaColumns($table,$upper=false) + { + $false = false; + if (!empty($this->metaColumnsSQL)) { + + $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); + if ($rs === false) return $false; + + $retarr = array(); + while (!$rs->EOF) { + $fld = new ADOFieldObject(); + $fld->name = $rs->Fields('field_name'); + $fld->type = $rs->Fields('type'); + $fld->max_length = $rs->Fields('width'); + $retarr[strtoupper($fld->name)] = $fld; + $rs->MoveNext(); + } + $rs->Close(); + return $retarr; + } + return $false; + } + + function getProcedureList($schema) + { + return false; + } + + function ErrorMsg() + { + if (!function_exists('sybase_connect')){ + return 'Your PHP doesn\'t contain the Sybase connection module!'; + } + return parent::ErrorMsg(); + } +} + +class adorecordset_sybase_ase extends ADORecordset_sybase { +var $databaseType = "sybase_ase"; +function ADORecordset_sybase_ase($id,$mode=false) + { + $this->ADORecordSet_sybase($id,$mode); + } + +} +?> \ No newline at end of file diff --git a/includes/adodb/drivers/adodb-vfp.inc.php b/includes/adodb/drivers/adodb-vfp.inc.php new file mode 100644 index 00000000..01ec7b82 --- /dev/null +++ b/includes/adodb/drivers/adodb-vfp.inc.php @@ -0,0 +1,107 @@ +ADODB_odbc(); + } + + function Time() + { + return time(); + } + + function BeginTrans() { return false;} + + // quote string to be sent back to database + function qstr($s,$nofixquotes=false) + { + if (!$nofixquotes) return "'".str_replace("\r\n","'+chr(13)+'",str_replace("'",$this->replaceQuote,$s))."'"; + return "'".$s."'"; + } + + + // TOP requires ORDER BY for VFP + function SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) + { + $this->hasTop = preg_match('/ORDER[ \t\r\n]+BY/is',$sql) ? 'top' : false; + $ret = ADOConnection::SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + return $ret; + } + + + +}; + + +class ADORecordSet_vfp extends ADORecordSet_odbc { + + var $databaseType = "vfp"; + + + function ADORecordSet_vfp($id,$mode=false) + { + return $this->ADORecordSet_odbc($id,$mode); + } + + function MetaType($t,$len=-1) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + switch (strtoupper($t)) { + case 'C': + if ($len <= $this->blobSize) return 'C'; + case 'M': + return 'X'; + + case 'D': return 'D'; + + case 'T': return 'T'; + + case 'L': return 'L'; + + case 'I': return 'I'; + + default: return 'N'; + } + } +} + +} //define +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-ar.inc.php b/includes/adodb/lang/adodb-ar.inc.php new file mode 100644 index 00000000..4b750952 --- /dev/null +++ b/includes/adodb/lang/adodb-ar.inc.php @@ -0,0 +1,33 @@ + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'ar', + DB_ERROR => 'ÎØà ÛíÑ ãÍÏÏ', + DB_ERROR_ALREADY_EXISTS => 'ãæÌæÏ ãÓÈÞÇ', + DB_ERROR_CANNOT_CREATE => 'áÇ íãßä ÅäÔÇÁ', + DB_ERROR_CANNOT_DELETE => 'áÇ íãßä ÍÐÝ', + DB_ERROR_CANNOT_DROP => 'áÇ íãßä ÍÐÝ', + DB_ERROR_CONSTRAINT => 'ÚãáíÉ ÅÏÎÇá ããäæÚÉ', + DB_ERROR_DIVZERO => 'ÚãáíÉ ÇáÊÞÓíã Úáì ÕÝÑ', + DB_ERROR_INVALID => 'ÛíÑ ÕÍíÍ', + DB_ERROR_INVALID_DATE => 'ÕíÛÉ æÞÊ Ãæ ÊÇÑíÎ ÛíÑ ÕÍíÍÉ', + DB_ERROR_INVALID_NUMBER => 'ÕíÛÉ ÑÞã ÛíÑ ÕÍíÍÉ', + DB_ERROR_MISMATCH => 'ÛíÑ ãÊØÇÈÞ', + DB_ERROR_NODBSELECTED => 'áã íÊã ÅÎÊíÇÑ ÞÇÚÏÉ ÇáÈíÇäÇÊ ÈÚÏ', + DB_ERROR_NOSUCHFIELD => 'áíÓ åäÇáß ÍÞá ÈåÐÇ ÇáÇÓã', + DB_ERROR_NOSUCHTABLE => 'áíÓ åäÇáß ÌÏæá ÈåÐÇ ÇáÇÓã', + DB_ERROR_NOT_CAPABLE => 'ÞÇÚÏÉ ÇáÈíÇäÇÊ ÇáãÑÊÈØ ÈåÇ ÛíÑ ÞÇÏÑÉ', + DB_ERROR_NOT_FOUND => 'áã íÊã ÅíÌÇÏå', + DB_ERROR_NOT_LOCKED => 'ÛíÑ ãÞÝæá', + DB_ERROR_SYNTAX => 'ÎØà Ýí ÇáÕíÛÉ', + DB_ERROR_UNSUPPORTED => 'ÛíÑ ãÏÚæã', + DB_ERROR_VALUE_COUNT_ON_ROW => 'ÚÏÏ ÇáÞíã Ýí ÇáÓÌá', + DB_ERROR_INVALID_DSN => 'DSN ÛíÑ ÕÍíÍ', + DB_ERROR_CONNECT_FAILED => 'ÝÔá ÚãáíÉ ÇáÅÊÕÇá', + 0 => 'áíÓ åäÇáß ÃÎØÇÁ', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'ÇáÈíÇäÇÊ ÇáãÒæÏÉ ÛíÑ ßÇÝíÉ', + DB_ERROR_EXTENSION_NOT_FOUND=> 'áã íÊã ÅíÌÇÏ ÇáÅÖÇÝÉ ÇáãÊÚáÞÉ', + DB_ERROR_NOSUCHDB => 'áíÓ åäÇáß ÞÇÚÏÉ ÈíÇäÇÊ ÈåÐÇ ÇáÇÓã', + DB_ERROR_ACCESS_VIOLATION => 'ÓãÇÍíÇÊ ÛíÑ ßÇÝíÉ' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-bg.inc.php b/includes/adodb/lang/adodb-bg.inc.php new file mode 100644 index 00000000..ee307c13 --- /dev/null +++ b/includes/adodb/lang/adodb-bg.inc.php @@ -0,0 +1,37 @@ + +*/ + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'bg', + DB_ERROR => 'íåèçâåñòíà ãðåøêà', + DB_ERROR_ALREADY_EXISTS => 'âå÷å ñúùåñòâóâà', + DB_ERROR_CANNOT_CREATE => 'íå ìîæå äà áúäå ñúçäàäåíà', + DB_ERROR_CANNOT_DELETE => 'íå ìîæå äà áúäå èçòðèòà', + DB_ERROR_CANNOT_DROP => 'íå ìîæå äà áúäå óíèùîæåíà', + DB_ERROR_CONSTRAINT => 'íàðóøåíî óñëîâèå', + DB_ERROR_DIVZERO => 'äåëåíèå íà íóëà', + DB_ERROR_INVALID => 'íåïðàâèëíî', + DB_ERROR_INVALID_DATE => 'íåêîðåêòíà äàòà èëè ÷àñ', + DB_ERROR_INVALID_NUMBER => 'íåâàëèäåí íîìåð', + DB_ERROR_MISMATCH => 'ïîãðåøíà óïîòðåáà', + DB_ERROR_NODBSELECTED => 'íå å èçáðàíà áàçà äàííè', + DB_ERROR_NOSUCHFIELD => 'íåñúùåñòâóâàùî ïîëå', + DB_ERROR_NOSUCHTABLE => 'íåñúùåñòâóâàùà òàáëèöà', + DB_ERROR_NOT_CAPABLE => 'DB backend not capable', + DB_ERROR_NOT_FOUND => 'íå å íàìåðåíà', + DB_ERROR_NOT_LOCKED => 'íå å çàêëþ÷åíà', + DB_ERROR_SYNTAX => 'ãðåøåí ñèíòàêñèñ', + DB_ERROR_UNSUPPORTED => 'íå ñå ïîääúðæà', + DB_ERROR_VALUE_COUNT_ON_ROW => 'íåêîðåêòåí áðîé êîëîíè â ðåäà', + DB_ERROR_INVALID_DSN => 'íåâàëèäåí DSN', + DB_ERROR_CONNECT_FAILED => 'âðúçêàòà íå ìîæå äà áúäå îñúùåñòâåíà', + 0 => 'íÿìà ãðåøêè', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'ïðåäîñòàâåíèòå äàííè ñà íåäîñòàòú÷íè', + DB_ERROR_EXTENSION_NOT_FOUND=> 'ðàçøèðåíèåòî íå å íàìåðåíî', + DB_ERROR_NOSUCHDB => 'íåñúùåñòâóâàùà áàçà äàííè', + DB_ERROR_ACCESS_VIOLATION => 'íÿìàòå äîñòàòú÷íî ïðàâà' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-bgutf8.inc.php b/includes/adodb/lang/adodb-bgutf8.inc.php new file mode 100644 index 00000000..5281ed53 --- /dev/null +++ b/includes/adodb/lang/adodb-bgutf8.inc.php @@ -0,0 +1,37 @@ + +*/ + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'bgutf8', + DB_ERROR => 'неизвеÑтна грешка', + DB_ERROR_ALREADY_EXISTS => 'вече ÑъщеÑтвува', + DB_ERROR_CANNOT_CREATE => 'не може да бъде Ñъздадена', + DB_ERROR_CANNOT_DELETE => 'не може да бъде изтрита', + DB_ERROR_CANNOT_DROP => 'не може да бъде унищожена', + DB_ERROR_CONSTRAINT => 'нарушено уÑловие', + DB_ERROR_DIVZERO => 'деление на нула', + DB_ERROR_INVALID => 'неправилно', + DB_ERROR_INVALID_DATE => 'некоректна дата или чаÑ', + DB_ERROR_INVALID_NUMBER => 'невалиден номер', + DB_ERROR_MISMATCH => 'погрешна употреба', + DB_ERROR_NODBSELECTED => 'не е избрана база данни', + DB_ERROR_NOSUCHFIELD => 'неÑъщеÑтвуващо поле', + DB_ERROR_NOSUCHTABLE => 'неÑъщеÑтвуваща таблица', + DB_ERROR_NOT_CAPABLE => 'DB backend not capable', + DB_ERROR_NOT_FOUND => 'не е намерена', + DB_ERROR_NOT_LOCKED => 'не е заключена', + DB_ERROR_SYNTAX => 'грешен ÑинтакÑиÑ', + DB_ERROR_UNSUPPORTED => 'не Ñе поддържа', + DB_ERROR_VALUE_COUNT_ON_ROW => 'некоректен брой колони в реда', + DB_ERROR_INVALID_DSN => 'невалиден DSN', + DB_ERROR_CONNECT_FAILED => 'връзката не може да бъде оÑъщеÑтвена', + 0 => 'нÑма грешки', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'предоÑтавените данни Ñа недоÑтатъчни', + DB_ERROR_EXTENSION_NOT_FOUND=> 'разширението не е намерено', + DB_ERROR_NOSUCHDB => 'неÑъщеÑтвуваща база данни', + DB_ERROR_ACCESS_VIOLATION => 'нÑмате доÑтатъчно права' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-ca.inc.php b/includes/adodb/lang/adodb-ca.inc.php new file mode 100644 index 00000000..3640ebd0 --- /dev/null +++ b/includes/adodb/lang/adodb-ca.inc.php @@ -0,0 +1,34 @@ + 'ca', + DB_ERROR => 'error desconegut', + DB_ERROR_ALREADY_EXISTS => 'ja existeix', + DB_ERROR_CANNOT_CREATE => 'no es pot crear', + DB_ERROR_CANNOT_DELETE => 'no es pot esborrar', + DB_ERROR_CANNOT_DROP => 'no es pot eliminar', + DB_ERROR_CONSTRAINT => 'violació de constraint', + DB_ERROR_DIVZERO => 'divisió per zero', + DB_ERROR_INVALID => 'no és vàlid', + DB_ERROR_INVALID_DATE => 'la data o l\'hora no són vàlides', + DB_ERROR_INVALID_NUMBER => 'el nombre no és vàlid', + DB_ERROR_MISMATCH => 'no hi ha coincidència', + DB_ERROR_NODBSELECTED => 'cap base de dades seleccionada', + DB_ERROR_NOSUCHFIELD => 'camp inexistent', + DB_ERROR_NOSUCHTABLE => 'taula inexistent', + DB_ERROR_NOT_CAPABLE => 'l\'execució secundària de DB no pot', + DB_ERROR_NOT_FOUND => 'no trobat', + DB_ERROR_NOT_LOCKED => 'no blocat', + DB_ERROR_SYNTAX => 'error de sintaxi', + DB_ERROR_UNSUPPORTED => 'no suportat', + DB_ERROR_VALUE_COUNT_ON_ROW => 'el nombre de columnes no coincideix amb el nombre de valors en la fila', + DB_ERROR_INVALID_DSN => 'el DSN no és vàlid', + DB_ERROR_CONNECT_FAILED => 'connexió fallida', + 0 => 'cap error', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'les dades subministrades són insuficients', + DB_ERROR_EXTENSION_NOT_FOUND=> 'extensió no trobada', + DB_ERROR_NOSUCHDB => 'base de dades inexistent', + DB_ERROR_ACCESS_VIOLATION => 'permisos insuficients' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-cn.inc.php b/includes/adodb/lang/adodb-cn.inc.php new file mode 100644 index 00000000..44d5f490 --- /dev/null +++ b/includes/adodb/lang/adodb-cn.inc.php @@ -0,0 +1,35 @@ + 'cn', + DB_ERROR => 'δ֪´íÎó', + DB_ERROR_ALREADY_EXISTS => 'ÒѾ­´æÔÚ', + DB_ERROR_CANNOT_CREATE => '²»ÄÜ´´½¨', + DB_ERROR_CANNOT_DELETE => '²»ÄÜɾ³ý', + DB_ERROR_CANNOT_DROP => '²»ÄܶªÆú', + DB_ERROR_CONSTRAINT => 'Ô¼ÊøÏÞÖÆ', + DB_ERROR_DIVZERO => '±»0³ý', + DB_ERROR_INVALID => 'ÎÞЧ', + DB_ERROR_INVALID_DATE => 'ÎÞЧµÄÈÕÆÚ»òÕßʱ¼ä', + DB_ERROR_INVALID_NUMBER => 'ÎÞЧµÄÊý×Ö', + DB_ERROR_MISMATCH => '²»Æ¥Åä', + DB_ERROR_NODBSELECTED => 'ûÓÐÊý¾Ý¿â±»Ñ¡Ôñ', + DB_ERROR_NOSUCHFIELD => 'ûÓÐÏàÓ¦µÄ×Ö¶Î', + DB_ERROR_NOSUCHTABLE => 'ûÓÐÏàÓ¦µÄ±í', + DB_ERROR_NOT_CAPABLE => 'Êý¾Ý¿âºǫ́²»¼æÈÝ', + DB_ERROR_NOT_FOUND => 'ûÓз¢ÏÖ', + DB_ERROR_NOT_LOCKED => 'ûÓб»Ëø¶¨', + DB_ERROR_SYNTAX => 'Óï·¨´íÎó', + DB_ERROR_UNSUPPORTED => '²»Ö§³Ö', + DB_ERROR_VALUE_COUNT_ON_ROW => 'ÔÚÐÐÉÏÀÛ¼ÆÖµ', + DB_ERROR_INVALID_DSN => 'ÎÞЧµÄÊý¾ÝÔ´ (DSN)', + DB_ERROR_CONNECT_FAILED => 'Á¬½Óʧ°Ü', + 0 => 'ûÓдíÎó', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'ÌṩµÄÊý¾Ý²»ÄÜ·ûºÏÒªÇó', + DB_ERROR_EXTENSION_NOT_FOUND=> 'À©Õ¹Ã»Óб»·¢ÏÖ', + DB_ERROR_NOSUCHDB => 'ûÓÐÏàÓ¦µÄÊý¾Ý¿â', + DB_ERROR_ACCESS_VIOLATION => 'ûÓкÏÊʵÄȨÏÞ' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-cz.inc.php b/includes/adodb/lang/adodb-cz.inc.php new file mode 100644 index 00000000..1f5c08a9 --- /dev/null +++ b/includes/adodb/lang/adodb-cz.inc.php @@ -0,0 +1,40 @@ + + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'cz', + DB_ERROR => 'neznámá chyba', + DB_ERROR_ALREADY_EXISTS => 'ji? existuje', + DB_ERROR_CANNOT_CREATE => 'nelze vytvo?it', + DB_ERROR_CANNOT_DELETE => 'nelze smazat', + DB_ERROR_CANNOT_DROP => 'nelze odstranit', + DB_ERROR_CONSTRAINT => 'poru?ení omezující podmínky', + DB_ERROR_DIVZERO => 'd?lení nulou', + DB_ERROR_INVALID => 'neplatné', + DB_ERROR_INVALID_DATE => 'neplatné datum nebo ?as', + DB_ERROR_INVALID_NUMBER => 'neplatné ?íslo', + DB_ERROR_MISMATCH => 'nesouhlasí', + DB_ERROR_NODBSELECTED => '?ádná databáze není vybrána', + DB_ERROR_NOSUCHFIELD => 'pole nenalezeno', + DB_ERROR_NOSUCHTABLE => 'tabulka nenalezena', + DB_ERROR_NOT_CAPABLE => 'nepodporováno', + DB_ERROR_NOT_FOUND => 'nenalezeno', + DB_ERROR_NOT_LOCKED => 'nezam?eno', + DB_ERROR_SYNTAX => 'syntaktická chyba', + DB_ERROR_UNSUPPORTED => 'nepodporováno', + DB_ERROR_VALUE_COUNT_ON_ROW => '', + DB_ERROR_INVALID_DSN => 'neplatné DSN', + DB_ERROR_CONNECT_FAILED => 'p?ipojení selhalo', + 0 => 'bez chyb', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'málo zdrojových dat', + DB_ERROR_EXTENSION_NOT_FOUND=> 'roz?í?ení nenalezeno', + DB_ERROR_NOSUCHDB => 'databáze neexistuje', + DB_ERROR_ACCESS_VIOLATION => 'nedostate?ná práva' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-da.inc.php b/includes/adodb/lang/adodb-da.inc.php new file mode 100644 index 00000000..ca0e72d6 --- /dev/null +++ b/includes/adodb/lang/adodb-da.inc.php @@ -0,0 +1,33 @@ + 'da', + DB_ERROR => 'ukendt fejl', + DB_ERROR_ALREADY_EXISTS => 'eksisterer allerede', + DB_ERROR_CANNOT_CREATE => 'kan ikke oprette', + DB_ERROR_CANNOT_DELETE => 'kan ikke slette', + DB_ERROR_CANNOT_DROP => 'kan ikke droppe', + DB_ERROR_CONSTRAINT => 'begrænsning krænket', + DB_ERROR_DIVZERO => 'division med nul', + DB_ERROR_INVALID => 'ugyldig', + DB_ERROR_INVALID_DATE => 'ugyldig dato eller klokkeslet', + DB_ERROR_INVALID_NUMBER => 'ugyldigt tal', + DB_ERROR_MISMATCH => 'mismatch', + DB_ERROR_NODBSELECTED => 'ingen database valgt', + DB_ERROR_NOSUCHFIELD => 'felt findes ikke', + DB_ERROR_NOSUCHTABLE => 'tabel findes ikke', + DB_ERROR_NOT_CAPABLE => 'DB backend opgav', + DB_ERROR_NOT_FOUND => 'ikke fundet', + DB_ERROR_NOT_LOCKED => 'ikke låst', + DB_ERROR_SYNTAX => 'syntaksfejl', + DB_ERROR_UNSUPPORTED => 'ikke understøttet', + DB_ERROR_VALUE_COUNT_ON_ROW => 'resulterende antal felter svarer ikke til forespørgslens antal felter', + DB_ERROR_INVALID_DSN => 'ugyldig DSN', + DB_ERROR_CONNECT_FAILED => 'tilslutning mislykkedes', + 0 => 'ingen fejl', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'utilstrækkelige data angivet', + DB_ERROR_EXTENSION_NOT_FOUND=> 'udvidelse ikke fundet', + DB_ERROR_NOSUCHDB => 'database ikke fundet', + DB_ERROR_ACCESS_VIOLATION => 'utilstrækkelige rettigheder' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-de.inc.php b/includes/adodb/lang/adodb-de.inc.php new file mode 100644 index 00000000..44c57e9f --- /dev/null +++ b/includes/adodb/lang/adodb-de.inc.php @@ -0,0 +1,33 @@ + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'de', + DB_ERROR => 'Unbekannter Fehler', + DB_ERROR_ALREADY_EXISTS => 'existiert bereits', + DB_ERROR_CANNOT_CREATE => 'kann nicht erstellen', + DB_ERROR_CANNOT_DELETE => 'kann nicht löschen', + DB_ERROR_CANNOT_DROP => 'Tabelle oder Index konnte nicht gelöscht werden', + DB_ERROR_CONSTRAINT => 'Constraint Verletzung', + DB_ERROR_DIVZERO => 'Division durch Null', + DB_ERROR_INVALID => 'ung¨ltig', + DB_ERROR_INVALID_DATE => 'ung¨ltiges Datum oder Zeit', + DB_ERROR_INVALID_NUMBER => 'ung¨ltige Zahl', + DB_ERROR_MISMATCH => 'Unverträglichkeit', + DB_ERROR_NODBSELECTED => 'keine Dantebank ausgewählt', + DB_ERROR_NOSUCHFIELD => 'Feld nicht vorhanden', + DB_ERROR_NOSUCHTABLE => 'Tabelle nicht vorhanden', + DB_ERROR_NOT_CAPABLE => 'Funktion nicht installiert', + DB_ERROR_NOT_FOUND => 'nicht gefunden', + DB_ERROR_NOT_LOCKED => 'nicht gesperrt', + DB_ERROR_SYNTAX => 'Syntaxfehler', + DB_ERROR_UNSUPPORTED => 'nicht Unterst¨tzt', + DB_ERROR_VALUE_COUNT_ON_ROW => 'Anzahl der zur¨ckgelieferten Felder entspricht nicht der Anzahl der Felder in der Abfrage', + DB_ERROR_INVALID_DSN => 'ung¨ltiger DSN', + DB_ERROR_CONNECT_FAILED => 'Verbindung konnte nicht hergestellt werden', + 0 => 'kein Fehler', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'Nicht gen¨gend Daten geliefert', + DB_ERROR_EXTENSION_NOT_FOUND=> 'erweiterung nicht gefunden', + DB_ERROR_NOSUCHDB => 'keine Datenbank', + DB_ERROR_ACCESS_VIOLATION => 'ungen¨gende Rechte' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-en.inc.php b/includes/adodb/lang/adodb-en.inc.php new file mode 100644 index 00000000..6895995e --- /dev/null +++ b/includes/adodb/lang/adodb-en.inc.php @@ -0,0 +1,33 @@ + 'en', + DB_ERROR => 'unknown error', + DB_ERROR_ALREADY_EXISTS => 'already exists', + DB_ERROR_CANNOT_CREATE => 'can not create', + DB_ERROR_CANNOT_DELETE => 'can not delete', + DB_ERROR_CANNOT_DROP => 'can not drop', + DB_ERROR_CONSTRAINT => 'constraint violation', + DB_ERROR_DIVZERO => 'division by zero', + DB_ERROR_INVALID => 'invalid', + DB_ERROR_INVALID_DATE => 'invalid date or time', + DB_ERROR_INVALID_NUMBER => 'invalid number', + DB_ERROR_MISMATCH => 'mismatch', + DB_ERROR_NODBSELECTED => 'no database selected', + DB_ERROR_NOSUCHFIELD => 'no such field', + DB_ERROR_NOSUCHTABLE => 'no such table', + DB_ERROR_NOT_CAPABLE => 'DB backend not capable', + DB_ERROR_NOT_FOUND => 'not found', + DB_ERROR_NOT_LOCKED => 'not locked', + DB_ERROR_SYNTAX => 'syntax error', + DB_ERROR_UNSUPPORTED => 'not supported', + DB_ERROR_VALUE_COUNT_ON_ROW => 'value count on row', + DB_ERROR_INVALID_DSN => 'invalid DSN', + DB_ERROR_CONNECT_FAILED => 'connect failed', + 0 => 'no error', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'insufficient data supplied', + DB_ERROR_EXTENSION_NOT_FOUND=> 'extension not found', + DB_ERROR_NOSUCHDB => 'no such database', + DB_ERROR_ACCESS_VIOLATION => 'insufficient permissions' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-es.inc.php b/includes/adodb/lang/adodb-es.inc.php new file mode 100644 index 00000000..1e0afbb4 --- /dev/null +++ b/includes/adodb/lang/adodb-es.inc.php @@ -0,0 +1,33 @@ + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'es', + DB_ERROR => 'error desconocido', + DB_ERROR_ALREADY_EXISTS => 'ya existe', + DB_ERROR_CANNOT_CREATE => 'imposible crear', + DB_ERROR_CANNOT_DELETE => 'imposible borrar', + DB_ERROR_CANNOT_DROP => 'imposible hacer drop', + DB_ERROR_CONSTRAINT => 'violacion de constraint', + DB_ERROR_DIVZERO => 'division por cero', + DB_ERROR_INVALID => 'invalido', + DB_ERROR_INVALID_DATE => 'fecha u hora invalida', + DB_ERROR_INVALID_NUMBER => 'numero invalido', + DB_ERROR_MISMATCH => 'error', + DB_ERROR_NODBSELECTED => 'no hay base de datos seleccionada', + DB_ERROR_NOSUCHFIELD => 'campo invalido', + DB_ERROR_NOSUCHTABLE => 'tabla no existe', + DB_ERROR_NOT_CAPABLE => 'capacidad invalida para esta DB', + DB_ERROR_NOT_FOUND => 'no encontrado', + DB_ERROR_NOT_LOCKED => 'no bloqueado', + DB_ERROR_SYNTAX => 'error de sintaxis', + DB_ERROR_UNSUPPORTED => 'no soportado', + DB_ERROR_VALUE_COUNT_ON_ROW => 'la cantidad de columnas no corresponden a la cantidad de valores', + DB_ERROR_INVALID_DSN => 'DSN invalido', + DB_ERROR_CONNECT_FAILED => 'fallo la conexion', + 0 => 'sin error', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'insuficientes datos', + DB_ERROR_EXTENSION_NOT_FOUND=> 'extension no encontrada', + DB_ERROR_NOSUCHDB => 'base de datos no encontrada', + DB_ERROR_ACCESS_VIOLATION => 'permisos insuficientes' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-esperanto.inc.php b/includes/adodb/lang/adodb-esperanto.inc.php new file mode 100644 index 00000000..16ca00e2 --- /dev/null +++ b/includes/adodb/lang/adodb-esperanto.inc.php @@ -0,0 +1,35 @@ + 'eo', + DB_ERROR => 'nekonata eraro', + DB_ERROR_ALREADY_EXISTS => 'jam ekzistas', + DB_ERROR_CANNOT_CREATE => 'maleblas krei', + DB_ERROR_CANNOT_DELETE => 'maleblas elimini', + DB_ERROR_CANNOT_DROP => 'maleblas elimini (drop)', + DB_ERROR_CONSTRAINT => 'rompo de kondicxoj de provo', + DB_ERROR_DIVZERO => 'divido per 0 (nul)', + DB_ERROR_INVALID => 'malregule', + DB_ERROR_INVALID_DATE => 'malregula dato kaj tempo', + DB_ERROR_INVALID_NUMBER => 'malregula nombro', + DB_ERROR_MISMATCH => 'eraro', + DB_ERROR_NODBSELECTED => 'datumbazo ne elektita', + DB_ERROR_NOSUCHFIELD => 'ne ekzistas kampo', + DB_ERROR_NOSUCHTABLE => 'ne ekzistas tabelo', + DB_ERROR_NOT_CAPABLE => 'DBMS ne povas', + DB_ERROR_NOT_FOUND => 'ne trovita', + DB_ERROR_NOT_LOCKED => 'ne blokita', + DB_ERROR_SYNTAX => 'sintaksa eraro', + DB_ERROR_UNSUPPORTED => 'ne apogata', + DB_ERROR_VALUE_COUNT_ON_ROW => 'nombrilo de valoroj en linio', + DB_ERROR_INVALID_DSN => 'malregula DSN-o', + DB_ERROR_CONNECT_FAILED => 'konekto malsukcesa', + 0 => 'cxio bone', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'ne suficxe da datumo', + DB_ERROR_EXTENSION_NOT_FOUND=> 'etendo ne trovita', + DB_ERROR_NOSUCHDB => 'datumbazo ne ekzistas', + DB_ERROR_ACCESS_VIOLATION => 'ne suficxe da rajto por atingo' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-fa.inc.php b/includes/adodb/lang/adodb-fa.inc.php new file mode 100644 index 00000000..a58a21cc --- /dev/null +++ b/includes/adodb/lang/adodb-fa.inc.php @@ -0,0 +1,35 @@ + */ + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'fa', + DB_ERROR => 'خطای ناشناخته', + DB_ERROR_ALREADY_EXISTS => 'وجود دارد', + DB_ERROR_CANNOT_CREATE => 'امکان create وجود ندارد', + DB_ERROR_CANNOT_DELETE => 'امکان حذ٠وجود ندارد', + DB_ERROR_CANNOT_DROP => 'امکان drop وجود ندارد', + DB_ERROR_CONSTRAINT => 'نقض شرط', + DB_ERROR_DIVZERO => 'تقسیم بر صÙر', + DB_ERROR_INVALID => 'نامعتبر', + DB_ERROR_INVALID_DATE => 'زمان یا تاریخ نامعتبر', + DB_ERROR_INVALID_NUMBER => 'عدد نامعتبر', + DB_ERROR_MISMATCH => 'عدم مطابقت', + DB_ERROR_NODBSELECTED => 'بانک اطلاعاتی انتخاب نشده است', + DB_ERROR_NOSUCHFIELD => 'چنین ستونی وجود ندارد', + DB_ERROR_NOSUCHTABLE => 'چنین جدولی وجود ندارد', + DB_ERROR_NOT_CAPABLE => 'backend بانک اطلاعاتی قادر نیست', + DB_ERROR_NOT_FOUND => 'پیدا نشد', + DB_ERROR_NOT_LOCKED => 'Ù‚ÙÙ„ نشده', + DB_ERROR_SYNTAX => 'خطای دستوری', + DB_ERROR_UNSUPPORTED => 'پشتیبانی نمی شود', + DB_ERROR_VALUE_COUNT_ON_ROW => 'شمارش مقادیر روی ردیÙ', + DB_ERROR_INVALID_DSN => 'DSN نامعتبر', + DB_ERROR_CONNECT_FAILED => 'ارتباط برقرار نشد', + 0 => 'بدون خطا', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'داده ناکاÙÛŒ است', + DB_ERROR_EXTENSION_NOT_FOUND=> 'extension پیدا نشد', + DB_ERROR_NOSUCHDB => 'چنین بانک اطلاعاتی وجود ندارد', + DB_ERROR_ACCESS_VIOLATION => 'حق دسترسی ناکاÙÛŒ' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-fr.inc.php b/includes/adodb/lang/adodb-fr.inc.php new file mode 100644 index 00000000..11127cd6 --- /dev/null +++ b/includes/adodb/lang/adodb-fr.inc.php @@ -0,0 +1,33 @@ + 'fr', + DB_ERROR => 'erreur inconnue', + DB_ERROR_ALREADY_EXISTS => 'existe déjà', + DB_ERROR_CANNOT_CREATE => 'crétion impossible', + DB_ERROR_CANNOT_DELETE => 'effacement impossible', + DB_ERROR_CANNOT_DROP => 'suppression impossible', + DB_ERROR_CONSTRAINT => 'violation de contrainte', + DB_ERROR_DIVZERO => 'division par zéro', + DB_ERROR_INVALID => 'invalide', + DB_ERROR_INVALID_DATE => 'date ou heure invalide', + DB_ERROR_INVALID_NUMBER => 'nombre invalide', + DB_ERROR_MISMATCH => 'erreur de concordance', + DB_ERROR_NODBSELECTED => 'pas de base de donnéessélectionnée', + DB_ERROR_NOSUCHFIELD => 'nom de colonne invalide', + DB_ERROR_NOSUCHTABLE => 'table ou vue inexistante', + DB_ERROR_NOT_CAPABLE => 'fonction optionnelle non installée', + DB_ERROR_NOT_FOUND => 'pas trouvé', + DB_ERROR_NOT_LOCKED => 'non verrouillé', + DB_ERROR_SYNTAX => 'erreur de syntaxe', + DB_ERROR_UNSUPPORTED => 'non supporté', + DB_ERROR_VALUE_COUNT_ON_ROW => 'valeur insérée trop grande pour colonne', + DB_ERROR_INVALID_DSN => 'DSN invalide', + DB_ERROR_CONNECT_FAILED => 'échec à la connexion', + 0 => "pas d'erreur", // DB_OK + DB_ERROR_NEED_MORE_DATA => 'données fournies insuffisantes', + DB_ERROR_EXTENSION_NOT_FOUND=> 'extension non trouvée', + DB_ERROR_NOSUCHDB => 'base de données inconnue', + DB_ERROR_ACCESS_VIOLATION => 'droits insuffisants' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-hu.inc.php b/includes/adodb/lang/adodb-hu.inc.php new file mode 100644 index 00000000..d6f0ef82 --- /dev/null +++ b/includes/adodb/lang/adodb-hu.inc.php @@ -0,0 +1,34 @@ + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'hu', + DB_ERROR => 'ismeretlen hiba', + DB_ERROR_ALREADY_EXISTS => 'már létezik', + DB_ERROR_CANNOT_CREATE => 'nem sikerült létrehozni', + DB_ERROR_CANNOT_DELETE => 'nem sikerült törölni', + DB_ERROR_CANNOT_DROP => 'nem sikerült eldobni', + DB_ERROR_CONSTRAINT => 'szabályok megszegése', + DB_ERROR_DIVZERO => 'osztás nullával', + DB_ERROR_INVALID => 'érvénytelen', + DB_ERROR_INVALID_DATE => 'érvénytelen dátum vagy idõ', + DB_ERROR_INVALID_NUMBER => 'érvénytelen szám', + DB_ERROR_MISMATCH => 'nem megfelelõ', + DB_ERROR_NODBSELECTED => 'nincs kiválasztott adatbázis', + DB_ERROR_NOSUCHFIELD => 'nincs ilyen mezõ', + DB_ERROR_NOSUCHTABLE => 'nincs ilyen tábla', + DB_ERROR_NOT_CAPABLE => 'DB backend nem támogatja', + DB_ERROR_NOT_FOUND => 'nem található', + DB_ERROR_NOT_LOCKED => 'nincs lezárva', + DB_ERROR_SYNTAX => 'szintaktikai hiba', + DB_ERROR_UNSUPPORTED => 'nem támogatott', + DB_ERROR_VALUE_COUNT_ON_ROW => 'soron végzett érték számlálás', + DB_ERROR_INVALID_DSN => 'hibás DSN', + DB_ERROR_CONNECT_FAILED => 'sikertelen csatlakozás', + 0 => 'nincs hiba', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'túl kevés az adat', + DB_ERROR_EXTENSION_NOT_FOUND=> 'bõvítmény nem található', + DB_ERROR_NOSUCHDB => 'nincs ilyen adatbázis', + DB_ERROR_ACCESS_VIOLATION => 'nincs jogosultság' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-it.inc.php b/includes/adodb/lang/adodb-it.inc.php new file mode 100644 index 00000000..ac5cc5a7 --- /dev/null +++ b/includes/adodb/lang/adodb-it.inc.php @@ -0,0 +1,34 @@ + 'it', + DB_ERROR => 'errore sconosciuto', + DB_ERROR_ALREADY_EXISTS => 'esiste già', + DB_ERROR_CANNOT_CREATE => 'non posso creare', + DB_ERROR_CANNOT_DELETE => 'non posso cancellare', + DB_ERROR_CANNOT_DROP => 'non posso eliminare', + DB_ERROR_CONSTRAINT => 'violazione constraint', + DB_ERROR_DIVZERO => 'divisione per zero', + DB_ERROR_INVALID => 'non valido', + DB_ERROR_INVALID_DATE => 'data od ora non valida', + DB_ERROR_INVALID_NUMBER => 'numero non valido', + DB_ERROR_MISMATCH => 'diversi', + DB_ERROR_NODBSELECTED => 'nessun database selezionato', + DB_ERROR_NOSUCHFIELD => 'nessun campo trovato', + DB_ERROR_NOSUCHTABLE => 'nessuna tabella trovata', + DB_ERROR_NOT_CAPABLE => 'DB backend non abilitato', + DB_ERROR_NOT_FOUND => 'non trovato', + DB_ERROR_NOT_LOCKED => 'non bloccato', + DB_ERROR_SYNTAX => 'errore di sintassi', + DB_ERROR_UNSUPPORTED => 'non supportato', + DB_ERROR_VALUE_COUNT_ON_ROW => 'valore inserito troppo grande per una colonna', + DB_ERROR_INVALID_DSN => 'DSN non valido', + DB_ERROR_CONNECT_FAILED => 'connessione fallita', + 0 => 'nessun errore', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'dati inseriti insufficienti', + DB_ERROR_EXTENSION_NOT_FOUND=> 'estensione non trovata', + DB_ERROR_NOSUCHDB => 'database non trovato', + DB_ERROR_ACCESS_VIOLATION => 'permessi insufficienti' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-nl.inc.php b/includes/adodb/lang/adodb-nl.inc.php new file mode 100644 index 00000000..abe77b52 --- /dev/null +++ b/includes/adodb/lang/adodb-nl.inc.php @@ -0,0 +1,33 @@ + 'nl', + DB_ERROR => 'onbekende fout', + DB_ERROR_ALREADY_EXISTS => 'bestaat al', + DB_ERROR_CANNOT_CREATE => 'kan niet aanmaken', + DB_ERROR_CANNOT_DELETE => 'kan niet wissen', + DB_ERROR_CANNOT_DROP => 'kan niet verwijderen', + DB_ERROR_CONSTRAINT => 'constraint overtreding', + DB_ERROR_DIVZERO => 'poging tot delen door nul', + DB_ERROR_INVALID => 'ongeldig', + DB_ERROR_INVALID_DATE => 'ongeldige datum of tijd', + DB_ERROR_INVALID_NUMBER => 'ongeldig nummer', + DB_ERROR_MISMATCH => 'is incorrect', + DB_ERROR_NODBSELECTED => 'geen database geselecteerd', + DB_ERROR_NOSUCHFIELD => 'onbekend veld', + DB_ERROR_NOSUCHTABLE => 'onbekende tabel', + DB_ERROR_NOT_CAPABLE => 'database systeem is niet tot uitvoer in staat', + DB_ERROR_NOT_FOUND => 'niet gevonden', + DB_ERROR_NOT_LOCKED => 'niet vergrendeld', + DB_ERROR_SYNTAX => 'syntaxis fout', + DB_ERROR_UNSUPPORTED => 'niet ondersteund', + DB_ERROR_VALUE_COUNT_ON_ROW => 'waarde telling op rij', + DB_ERROR_INVALID_DSN => 'ongeldige DSN', + DB_ERROR_CONNECT_FAILED => 'connectie mislukt', + 0 => 'geen fout', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'onvoldoende data gegeven', + DB_ERROR_EXTENSION_NOT_FOUND=> 'extensie niet gevonden', + DB_ERROR_NOSUCHDB => 'onbekende database', + DB_ERROR_ACCESS_VIOLATION => 'onvoldoende rechten' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-pl.inc.php b/includes/adodb/lang/adodb-pl.inc.php new file mode 100644 index 00000000..9d9e3906 --- /dev/null +++ b/includes/adodb/lang/adodb-pl.inc.php @@ -0,0 +1,35 @@ + + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'pl', + DB_ERROR => 'niezidentyfikowany b³±d', + DB_ERROR_ALREADY_EXISTS => 'ju¿ istniej±', + DB_ERROR_CANNOT_CREATE => 'nie mo¿na stworzyæ', + DB_ERROR_CANNOT_DELETE => 'nie mo¿na usun±æ', + DB_ERROR_CANNOT_DROP => 'nie mo¿na porzuciæ', + DB_ERROR_CONSTRAINT => 'pogwa³cenie uprawnieñ', + DB_ERROR_DIVZERO => 'dzielenie przez zero', + DB_ERROR_INVALID => 'b³êdny', + DB_ERROR_INVALID_DATE => 'b³êdna godzina lub data', + DB_ERROR_INVALID_NUMBER => 'b³êdny numer', + DB_ERROR_MISMATCH => 'niedopasowanie', + DB_ERROR_NODBSELECTED => 'baza danych nie zosta³a wybrana', + DB_ERROR_NOSUCHFIELD => 'nie znaleziono pola', + DB_ERROR_NOSUCHTABLE => 'nie znaleziono tabeli', + DB_ERROR_NOT_CAPABLE => 'nie zdolny', + DB_ERROR_NOT_FOUND => 'nie znaleziono', + DB_ERROR_NOT_LOCKED => 'nie zakmniêty', + DB_ERROR_SYNTAX => 'b³±d sk³adni', + DB_ERROR_UNSUPPORTED => 'nie obs³uguje', + DB_ERROR_VALUE_COUNT_ON_ROW => 'warto¶æ liczona w szeregu', + DB_ERROR_INVALID_DSN => 'b³êdny DSN', + DB_ERROR_CONNECT_FAILED => 'po³±czenie nie zosta³o zrealizowane', + 0 => 'brak b³êdów', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'niedostateczna ilo¶æ informacji', + DB_ERROR_EXTENSION_NOT_FOUND=> 'nie znaleziono rozszerzenia', + DB_ERROR_NOSUCHDB => 'nie znaleziono bazy', + DB_ERROR_ACCESS_VIOLATION => 'niedostateczne uprawnienia' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-pt-br.inc.php b/includes/adodb/lang/adodb-pt-br.inc.php new file mode 100644 index 00000000..cd28f7e5 --- /dev/null +++ b/includes/adodb/lang/adodb-pt-br.inc.php @@ -0,0 +1,35 @@ + 'pt-br', + DB_ERROR => 'erro desconhecido', + DB_ERROR_ALREADY_EXISTS => 'já existe', + DB_ERROR_CANNOT_CREATE => 'impossível criar', + DB_ERROR_CANNOT_DELETE => 'impossível excluír', + DB_ERROR_CANNOT_DROP => 'impossível remover', + DB_ERROR_CONSTRAINT => 'violação do confinamente', + DB_ERROR_DIVZERO => 'divisão por zero', + DB_ERROR_INVALID => 'inválido', + DB_ERROR_INVALID_DATE => 'data ou hora inválida', + DB_ERROR_INVALID_NUMBER => 'número inválido', + DB_ERROR_MISMATCH => 'erro', + DB_ERROR_NODBSELECTED => 'nenhum banco de dados selecionado', + DB_ERROR_NOSUCHFIELD => 'campo inválido', + DB_ERROR_NOSUCHTABLE => 'tabela inexistente', + DB_ERROR_NOT_CAPABLE => 'capacidade inválida para este BD', + DB_ERROR_NOT_FOUND => 'não encontrado', + DB_ERROR_NOT_LOCKED => 'não bloqueado', + DB_ERROR_SYNTAX => 'erro de sintaxe', + DB_ERROR_UNSUPPORTED => +'não suportado', + DB_ERROR_VALUE_COUNT_ON_ROW => 'a quantidade de colunas não corresponde ao de valores', + DB_ERROR_INVALID_DSN => 'DSN inválido', + DB_ERROR_CONNECT_FAILED => 'falha na conexão', + 0 => 'sem erro', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'dados insuficientes', + DB_ERROR_EXTENSION_NOT_FOUND=> 'extensão não encontrada', + DB_ERROR_NOSUCHDB => 'banco de dados não encontrado', + DB_ERROR_ACCESS_VIOLATION => 'permissão insuficiente' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-ro.inc.php b/includes/adodb/lang/adodb-ro.inc.php new file mode 100644 index 00000000..bcd7d132 --- /dev/null +++ b/includes/adodb/lang/adodb-ro.inc.php @@ -0,0 +1,35 @@ + */ + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'ro', + DB_ERROR => 'eroare necunoscuta', + DB_ERROR_ALREADY_EXISTS => 'deja exista', + DB_ERROR_CANNOT_CREATE => 'nu se poate creea', + DB_ERROR_CANNOT_DELETE => 'nu se poate sterge', + DB_ERROR_CANNOT_DROP => 'nu se poate executa drop', + DB_ERROR_CONSTRAINT => 'violare de constrain', + DB_ERROR_DIVZERO => 'se divide la zero', + DB_ERROR_INVALID => 'invalid', + DB_ERROR_INVALID_DATE => 'data sau timp invalide', + DB_ERROR_INVALID_NUMBER => 'numar invalid', + DB_ERROR_MISMATCH => 'nepotrivire-mismatch', + DB_ERROR_NODBSELECTED => 'nu exista baza de date selectata', + DB_ERROR_NOSUCHFIELD => 'camp inexistent', + DB_ERROR_NOSUCHTABLE => 'tabela inexistenta', + DB_ERROR_NOT_CAPABLE => 'functie optionala neinstalata', + DB_ERROR_NOT_FOUND => 'negasit', + DB_ERROR_NOT_LOCKED => 'neblocat', + DB_ERROR_SYNTAX => 'eroare de sintaxa', + DB_ERROR_UNSUPPORTED => 'nu e suportat', + DB_ERROR_VALUE_COUNT_ON_ROW => 'valoare prea mare pentru coloana', + DB_ERROR_INVALID_DSN => 'DSN invalid', + DB_ERROR_CONNECT_FAILED => 'conectare esuata', + 0 => 'fara eroare', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'data introduse insuficiente', + DB_ERROR_EXTENSION_NOT_FOUND=> 'extensie negasita', + DB_ERROR_NOSUCHDB => 'nu exista baza de date', + DB_ERROR_ACCESS_VIOLATION => 'permisiuni insuficiente' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-ru1251.inc.php b/includes/adodb/lang/adodb-ru1251.inc.php new file mode 100644 index 00000000..e273f427 --- /dev/null +++ b/includes/adodb/lang/adodb-ru1251.inc.php @@ -0,0 +1,35 @@ + 'ru1251', + DB_ERROR => 'íåèçâåñòíàÿ îøèáêà', + DB_ERROR_ALREADY_EXISTS => 'óæå ñóùåñòâóåò', + DB_ERROR_CANNOT_CREATE => 'íåâîçìîæíî ñîçäàòü', + DB_ERROR_CANNOT_DELETE => 'íåâîçìîæíî óäàëèòü', + DB_ERROR_CANNOT_DROP => 'íåâîçìîæíî óäàëèòü (drop)', + DB_ERROR_CONSTRAINT => 'íàðóøåíèå óñëîâèé ïðîâåðêè', + DB_ERROR_DIVZERO => 'äåëåíèå íà 0', + DB_ERROR_INVALID => 'íåïðàâèëüíî', + DB_ERROR_INVALID_DATE => 'íåêîððåêòíàÿ äàòà èëè âðåìÿ', + DB_ERROR_INVALID_NUMBER => 'íåêîððåêòíîå ÷èñëî', + DB_ERROR_MISMATCH => 'îøèáêà', + DB_ERROR_NODBSELECTED => 'ÁÄ íå âûáðàíà', + DB_ERROR_NOSUCHFIELD => 'íå ñóùåñòâóåò ïîëå', + DB_ERROR_NOSUCHTABLE => 'íå ñóùåñòâóåò òàáëèöà', + DB_ERROR_NOT_CAPABLE => 'ÑÓÁÄ íå â ñîñòîÿíèè', + DB_ERROR_NOT_FOUND => 'íå íàéäåíî', + DB_ERROR_NOT_LOCKED => 'íå çàáëîêèðîâàíî', + DB_ERROR_SYNTAX => 'ñèíòàêñè÷åñêàÿ îøèáêà', + DB_ERROR_UNSUPPORTED => 'íå ïîääåðæèâàåòñÿ', + DB_ERROR_VALUE_COUNT_ON_ROW => 'ñ÷åò÷èê çíà÷åíèé â ñòðîêå', + DB_ERROR_INVALID_DSN => 'íåïðàâèëüíàÿ DSN', + DB_ERROR_CONNECT_FAILED => 'ñîåäèíåíèå íåóñïåøíî', + 0 => 'íåò îøèáêè', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'ïðåäîñòàâëåíî íåäîñòàòî÷íî äàííûõ', + DB_ERROR_EXTENSION_NOT_FOUND=> 'ðàñøèðåíèå íå íàéäåíî', + DB_ERROR_NOSUCHDB => 'íå ñóùåñòâóåò ÁÄ', + DB_ERROR_ACCESS_VIOLATION => 'íåäîñòàòî÷íî ïðàâ äîñòóïà' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-sv.inc.php b/includes/adodb/lang/adodb-sv.inc.php new file mode 100644 index 00000000..64a5b4bb --- /dev/null +++ b/includes/adodb/lang/adodb-sv.inc.php @@ -0,0 +1,33 @@ + 'en', + DB_ERROR => 'Okänt fel', + DB_ERROR_ALREADY_EXISTS => 'finns redan', + DB_ERROR_CANNOT_CREATE => 'kan inte skapa', + DB_ERROR_CANNOT_DELETE => 'kan inte ta bort', + DB_ERROR_CANNOT_DROP => 'kan inte släppa', + DB_ERROR_CONSTRAINT => 'begränsning kränkt', + DB_ERROR_DIVZERO => 'division med noll', + DB_ERROR_INVALID => 'ogiltig', + DB_ERROR_INVALID_DATE => 'ogiltigt datum eller tid', + DB_ERROR_INVALID_NUMBER => 'ogiltigt tal', + DB_ERROR_MISMATCH => 'felaktig matchning', + DB_ERROR_NODBSELECTED => 'ingen databas vald', + DB_ERROR_NOSUCHFIELD => 'inget sådant fält', + DB_ERROR_NOSUCHTABLE => 'ingen sådan tabell', + DB_ERROR_NOT_CAPABLE => 'DB backend klarar det inte', + DB_ERROR_NOT_FOUND => 'finns inte', + DB_ERROR_NOT_LOCKED => 'inte låst', + DB_ERROR_SYNTAX => 'syntaxfel', + DB_ERROR_UNSUPPORTED => 'stöds ej', + DB_ERROR_VALUE_COUNT_ON_ROW => 'värde räknat på rad', + DB_ERROR_INVALID_DSN => 'ogiltig DSN', + DB_ERROR_CONNECT_FAILED => 'anslutning misslyckades', + 0 => 'inget fel', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'otillräckligt med data angivet', + DB_ERROR_EXTENSION_NOT_FOUND=> 'utökning hittades ej', + DB_ERROR_NOSUCHDB => 'ingen sådan databas', + DB_ERROR_ACCESS_VIOLATION => 'otillräckliga rättigheter' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb-uk1251.inc.php b/includes/adodb/lang/adodb-uk1251.inc.php new file mode 100644 index 00000000..675016d1 --- /dev/null +++ b/includes/adodb/lang/adodb-uk1251.inc.php @@ -0,0 +1,35 @@ + 'uk1251', + DB_ERROR => 'íåâ³äîìà ïîìèëêà', + DB_ERROR_ALREADY_EXISTS => 'âæå ³ñíóº', + DB_ERROR_CANNOT_CREATE => 'íåìîæëèâî ñòâîðèòè', + DB_ERROR_CANNOT_DELETE => 'íåìîæëèâî âèäàëèòè', + DB_ERROR_CANNOT_DROP => 'íåìîæëèâî çíèùèòè (drop)', + DB_ERROR_CONSTRAINT => 'ïîðóøåííÿ óìîâ ïåðåâ³ðêè', + DB_ERROR_DIVZERO => 'ä³ëåííÿ íà 0', + DB_ERROR_INVALID => 'íåïðàâèëüíî', + DB_ERROR_INVALID_DATE => 'íåïðàâèëüíà äàòà ÷è ÷àñ', + DB_ERROR_INVALID_NUMBER => 'íåïðàâèëüíå ÷èñëî', + DB_ERROR_MISMATCH => 'ïîìèëêà', + DB_ERROR_NODBSELECTED => 'íå âèáðàíî ÁÄ', + DB_ERROR_NOSUCHFIELD => 'íå ³ñíóº ïîëå', + DB_ERROR_NOSUCHTABLE => 'íå ³ñíóº òàáëèöÿ', + DB_ERROR_NOT_CAPABLE => 'ÑÓÁÄ íå â ñòàí³', + DB_ERROR_NOT_FOUND => 'íå çíàéäåíî', + DB_ERROR_NOT_LOCKED => 'íå çàáëîêîâàíî', + DB_ERROR_SYNTAX => 'ñèíòàêñè÷íà ïîìèëêà', + DB_ERROR_UNSUPPORTED => 'íå ï³äòðèìóºòüñÿ', + DB_ERROR_VALUE_COUNT_ON_ROW => 'ðàõ³âíèê çíà÷åíü â ñòð³÷ö³', + DB_ERROR_INVALID_DSN => 'íåïðàâèëüíà DSN', + DB_ERROR_CONNECT_FAILED => 'ç\'ºäíàííÿ íåóñï³øíå', + 0 => 'âñå ãàðàçä', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'íàäàíî íåäîñòàòíüî äàíèõ', + DB_ERROR_EXTENSION_NOT_FOUND=> 'ðîçøèðåííÿ íå çíàéäåíî', + DB_ERROR_NOSUCHDB => 'íå ³ñíóº ÁÄ', + DB_ERROR_ACCESS_VIOLATION => 'íåäîñòàòíüî ïðàâ äîñòóïà' +); +?> \ No newline at end of file diff --git a/includes/adodb/lang/adodb_th.inc.php b/includes/adodb/lang/adodb_th.inc.php new file mode 100644 index 00000000..3fdd9970 --- /dev/null +++ b/includes/adodb/lang/adodb_th.inc.php @@ -0,0 +1,33 @@ + +$ADODB_LANG_ARRAY = array ( + 'LANG' => 'th', + DB_ERROR => 'error ไม่รู้สาเหตุ', + DB_ERROR_ALREADY_EXISTS => 'มีà¹?ล้ว', + DB_ERROR_CANNOT_CREATE => 'สร้างไม่ได้', + DB_ERROR_CANNOT_DELETE => 'ลบไม่ได้', + DB_ERROR_CANNOT_DROP => 'drop ไม่ได้', + DB_ERROR_CONSTRAINT => 'constraint violation', + DB_ERROR_DIVZERO => 'หาà¸?ด้วยสูà¸?', + DB_ERROR_INVALID => 'ไม่ valid', + DB_ERROR_INVALID_DATE => 'วันที่ เวลา ไม่ valid', + DB_ERROR_INVALID_NUMBER => 'เลขไม่ valid', + DB_ERROR_MISMATCH => 'mismatch', + DB_ERROR_NODBSELECTED => 'ไม่ได้เลือà¸?à¸?านข้อมูล', + DB_ERROR_NOSUCHFIELD => 'ไม่มีฟีลด์นี้', + DB_ERROR_NOSUCHTABLE => 'ไม่มีตารางนี้', + DB_ERROR_NOT_CAPABLE => 'DB backend not capable', + DB_ERROR_NOT_FOUND => 'ไม่พบ', + DB_ERROR_NOT_LOCKED => 'ไม่ได้ล๊อà¸?', + DB_ERROR_SYNTAX => 'ผิด syntax', + DB_ERROR_UNSUPPORTED => 'ไม่ support', + DB_ERROR_VALUE_COUNT_ON_ROW => 'value count on row', + DB_ERROR_INVALID_DSN => 'invalid DSN', + DB_ERROR_CONNECT_FAILED => 'ไม่สามารถ connect', + 0 => 'no error', // DB_OK + DB_ERROR_NEED_MORE_DATA => 'ข้อมูลไม่เพียงพอ', + DB_ERROR_EXTENSION_NOT_FOUND=> 'ไม่พบ extension', + DB_ERROR_NOSUCHDB => 'ไม่มีข้อมูลนี้', + DB_ERROR_ACCESS_VIOLATION => 'permissions ไม่พอ' +); +?> \ No newline at end of file diff --git a/includes/adodb/license.txt b/includes/adodb/license.txt new file mode 100644 index 00000000..9821fcb7 --- /dev/null +++ b/includes/adodb/license.txt @@ -0,0 +1,182 @@ +ADOdb is dual licensed using BSD and LGPL. + +In plain English, you do not need to distribute your application in source code form, nor do you need to distribute ADOdb source code, provided you follow the rest of terms of the BSD license. + +For more info about ADOdb, visit http://adodb.sourceforge.net/ + +BSD Style-License +================= + +Copyright (c) 2000, 2001, 2002, 2003, 2004 John Lim +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list +of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list +of conditions and the following disclaimer in the documentation and/or other materials +provided with the distribution. + +Neither the name of the John Lim nor the names of its contributors may be used to +endorse or promote products derived from this software without specific prior written +permission. + +DISCLAIMER: +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +JOHN LIM OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +========================================================== +GNU LESSER GENERAL PUBLIC LICENSE +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + +Preamble +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. + +The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. + + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + +a) The modified work must itself be a software library. +b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. +c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. +d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. +(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. + +However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: + + +a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) +b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. +c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. +d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. +e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. +For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: + + +a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. +b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. +8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/includes/adodb/pear/Auth/Container/ADOdb.php b/includes/adodb/pear/Auth/Container/ADOdb.php new file mode 100644 index 00000000..37d7d074 --- /dev/null +++ b/includes/adodb/pear/Auth/Container/ADOdb.php @@ -0,0 +1,413 @@ + +// | Richard Tango-Lowy | +// +----------------------------------------------------------------------+ +// +// $Id: ADOdb.php,v 1.3 2005/05/18 06:58:47 jlim Exp $ +// + +require_once 'Auth/Container.php'; +require_once 'adodb.inc.php'; +require_once 'adodb-pear.inc.php'; +require_once 'adodb-errorpear.inc.php'; + +/** + * Storage driver for fetching login data from a database using ADOdb-PHP. + * + * This storage driver can use all databases which are supported + * by the ADBdb DB abstraction layer to fetch login data. + * See http://php.weblogs.com/adodb for information on ADOdb. + * NOTE: The ADOdb directory MUST be in your PHP include_path! + * + * @author Richard Tango-Lowy + * @package Auth + * @version $Revision: 1.3 $ + */ +class Auth_Container_ADOdb extends Auth_Container +{ + + /** + * Additional options for the storage container + * @var array + */ + var $options = array(); + + /** + * DB object + * @var object + */ + var $db = null; + var $dsn = ''; + + /** + * User that is currently selected from the DB. + * @var string + */ + var $activeUser = ''; + + // {{{ Constructor + + /** + * Constructor of the container class + * + * Initate connection to the database via PEAR::ADOdb + * + * @param string Connection data or DB object + * @return object Returns an error object if something went wrong + */ + function Auth_Container_ADOdb($dsn) + { + $this->_setDefaults(); + + if (is_array($dsn)) { + $this->_parseOptions($dsn); + + if (empty($this->options['dsn'])) { + PEAR::raiseError('No connection parameters specified!'); + } + } else { + // Extract db_type from dsn string. + $this->options['dsn'] = $dsn; + } + } + + // }}} + // {{{ _connect() + + /** + * Connect to database by using the given DSN string + * + * @access private + * @param string DSN string + * @return mixed Object on error, otherwise bool + */ + function _connect($dsn) + { + if (is_string($dsn) || is_array($dsn)) { + if(!$this->db) { + $this->db = ADONewConnection($dsn); + if( $err = ADODB_Pear_error() ) { + return PEAR::raiseError($err); + } + } + + } else { + return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__, + 41, + PEAR_ERROR_RETURN, + null, + null + ); + } + + if(!$this->db) { + return PEAR::raiseError(ADODB_Pear_error()); + } else { + return true; + } + } + + // }}} + // {{{ _prepare() + + /** + * Prepare database connection + * + * This function checks if we have already opened a connection to + * the database. If that's not the case, a new connection is opened. + * + * @access private + * @return mixed True or a DB error object. + */ + function _prepare() + { + if(!$this->db) { + $res = $this->_connect($this->options['dsn']); + } + return true; + } + + // }}} + // {{{ query() + + /** + * Prepare query to the database + * + * This function checks if we have already opened a connection to + * the database. If that's not the case, a new connection is opened. + * After that the query is passed to the database. + * + * @access public + * @param string Query string + * @return mixed a DB_result object or DB_OK on success, a DB + * or PEAR error on failure + */ + function query($query) + { + $err = $this->_prepare(); + if ($err !== true) { + return $err; + } + return $this->db->query($query); + } + + // }}} + // {{{ _setDefaults() + + /** + * Set some default options + * + * @access private + * @return void + */ + function _setDefaults() + { + $this->options['db_type'] = 'mysql'; + $this->options['table'] = 'auth'; + $this->options['usernamecol'] = 'username'; + $this->options['passwordcol'] = 'password'; + $this->options['dsn'] = ''; + $this->options['db_fields'] = ''; + $this->options['cryptType'] = 'md5'; + } + + // }}} + // {{{ _parseOptions() + + /** + * Parse options passed to the container class + * + * @access private + * @param array + */ + function _parseOptions($array) + { + foreach ($array as $key => $value) { + if (isset($this->options[$key])) { + $this->options[$key] = $value; + } + } + + /* Include additional fields if they exist */ + if(!empty($this->options['db_fields'])){ + if(is_array($this->options['db_fields'])){ + $this->options['db_fields'] = join($this->options['db_fields'], ', '); + } + $this->options['db_fields'] = ', '.$this->options['db_fields']; + } + } + + // }}} + // {{{ fetchData() + + /** + * Get user information from database + * + * This function uses the given username to fetch + * the corresponding login data from the database + * table. If an account that matches the passed username + * and password is found, the function returns true. + * Otherwise it returns false. + * + * @param string Username + * @param string Password + * @return mixed Error object or boolean + */ + function fetchData($username, $password) + { + // Prepare for a database query + $err = $this->_prepare(); + if ($err !== true) { + return PEAR::raiseError($err->getMessage(), $err->getCode()); + } + + // Find if db_fields contains a *, i so assume all col are selected + if(strstr($this->options['db_fields'], '*')){ + $sql_from = "*"; + } + else{ + $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields']; + } + + $query = "SELECT ".$sql_from. + " FROM ".$this->options['table']. + " WHERE ".$this->options['usernamecol']." = " . $this->db->Quote($username); + + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + $rset = $this->db->Execute( $query ); + $res = $rset->fetchRow(); + + if (DB::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->getCode()); + } + if (!is_array($res)) { + $this->activeUser = ''; + return false; + } + if ($this->verifyPassword(trim($password, "\r\n"), + trim($res[$this->options['passwordcol']], "\r\n"), + $this->options['cryptType'])) { + // Store additional field values in the session + foreach ($res as $key => $value) { + if ($key == $this->options['passwordcol'] || + $key == $this->options['usernamecol']) { + continue; + } + // Use reference to the auth object if exists + // This is because the auth session variable can change so a static call to setAuthData does not make sence + if(is_object($this->_auth_obj)){ + $this->_auth_obj->setAuthData($key, $value); + } else { + Auth::setAuthData($key, $value); + } + } + + return true; + } + + $this->activeUser = $res[$this->options['usernamecol']]; + return false; + } + + // }}} + // {{{ listUsers() + + function listUsers() + { + $err = $this->_prepare(); + if ($err !== true) { + return PEAR::raiseError($err->getMessage(), $err->getCode()); + } + + $retVal = array(); + + // Find if db_fileds contains a *, i so assume all col are selected + if(strstr($this->options['db_fields'], '*')){ + $sql_from = "*"; + } + else{ + $sql_from = $this->options['usernamecol'] . ", ".$this->options['passwordcol'].$this->options['db_fields']; + } + + $query = sprintf("SELECT %s FROM %s", + $sql_from, + $this->options['table'] + ); + $res = $this->db->getAll($query, null, DB_FETCHMODE_ASSOC); + + if (DB::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->getCode()); + } else { + foreach ($res as $user) { + $user['username'] = $user[$this->options['usernamecol']]; + $retVal[] = $user; + } + } + return $retVal; + } + + // }}} + // {{{ addUser() + + /** + * Add user to the storage container + * + * @access public + * @param string Username + * @param string Password + * @param mixed Additional information that are stored in the DB + * + * @return mixed True on success, otherwise error object + */ + function addUser($username, $password, $additional = "") + { + if (function_exists($this->options['cryptType'])) { + $cryptFunction = $this->options['cryptType']; + } else { + $cryptFunction = 'md5'; + } + + $additional_key = ''; + $additional_value = ''; + + if (is_array($additional)) { + foreach ($additional as $key => $value) { + $additional_key .= ', ' . $key; + $additional_value .= ", '" . $value . "'"; + } + } + + $query = sprintf("INSERT INTO %s (%s, %s%s) VALUES ('%s', '%s'%s)", + $this->options['table'], + $this->options['usernamecol'], + $this->options['passwordcol'], + $additional_key, + $username, + $cryptFunction($password), + $additional_value + ); + + $res = $this->query($query); + + if (DB::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->getCode()); + } else { + return true; + } + } + + // }}} + // {{{ removeUser() + + /** + * Remove user from the storage container + * + * @access public + * @param string Username + * + * @return mixed True on success, otherwise error object + */ + function removeUser($username) + { + $query = sprintf("DELETE FROM %s WHERE %s = '%s'", + $this->options['table'], + $this->options['usernamecol'], + $username + ); + + $res = $this->query($query); + + if (DB::isError($res)) { + return PEAR::raiseError($res->getMessage(), $res->getCode()); + } else { + return true; + } + } + + // }}} +} + +function showDbg( $string ) { + print " +-- $string

"; +} +function dump( $var, $str, $vardump = false ) { + print "

$str

";
+	( !$vardump ) ? ( print_r( $var )) : ( var_dump( $var ));
+	print "
"; +} +?> diff --git a/includes/adodb/pear/readme.Auth.txt b/includes/adodb/pear/readme.Auth.txt new file mode 100644 index 00000000..b6b0c157 --- /dev/null +++ b/includes/adodb/pear/readme.Auth.txt @@ -0,0 +1,20 @@ +From: Rich Tango-Lowy (richtl#arscognita.com) +Date: Sat, May 29, 2004 11:20 am + +OK, I hacked out an ADOdb container for PEAR-Auth. The error handling's +a bit of a mess, but all the methods work. + +Copy ADOdb.php to your pear/Auth/Container/ directory. + +Use the ADOdb container exactly as you would the DB +container, but specify 'ADOdb' instead of 'DB': + +$dsn = "mysql://myuser:mypass@localhost/authdb"; +$a = new Auth("ADOdb", $dsn, "loginFunction"); + + +------------------- + +John Lim adds: + +See http://pear.php.net/manual/en/package.authentication.php diff --git a/includes/adodb/pivottable.inc.php b/includes/adodb/pivottable.inc.php new file mode 100644 index 00000000..622c5266 --- /dev/null +++ b/includes/adodb/pivottable.inc.php @@ -0,0 +1,187 @@ +databaseType,'access') !== false; + // note - vfp 6 still doesn' work even with IIF enabled || $db->databaseType == 'vfp'; + + //$hidecnt = false; + + if ($where) $where = "\nWHERE $where"; + if (!is_array($colfield)) $colarr = $db->GetCol("select distinct $colfield from $tables $where order by 1"); + if (!$aggfield) $hidecnt = false; + + $sel = "$rowfields, "; + if (is_array($colfield)) { + foreach ($colfield as $k => $v) { + $k = trim($k); + if (!$hidecnt) { + $sel .= $iif ? + "\n\t$aggfn(IIF($v,1,0)) AS \"$k\", " + : + "\n\t$aggfn(CASE WHEN $v THEN 1 ELSE 0 END) AS \"$k\", "; + } + if ($aggfield) { + $sel .= $iif ? + "\n\t$aggfn(IIF($v,$aggfield,0)) AS \"$sumlabel$k\", " + : + "\n\t$aggfn(CASE WHEN $v THEN $aggfield ELSE 0 END) AS \"$sumlabel$k\", "; + } + } + } else { + foreach ($colarr as $v) { + if (!is_numeric($v)) $vq = $db->qstr($v); + else $vq = $v; + $v = trim($v); + if (strlen($v) == 0 ) $v = 'null'; + if (!$hidecnt) { + $sel .= $iif ? + "\n\t$aggfn(IIF($colfield=$vq,1,0)) AS \"$v\", " + : + "\n\t$aggfn(CASE WHEN $colfield=$vq THEN 1 ELSE 0 END) AS \"$v\", "; + } + if ($aggfield) { + if ($hidecnt) $label = $v; + else $label = "{$v}_$aggfield"; + $sel .= $iif ? + "\n\t$aggfn(IIF($colfield=$vq,$aggfield,0)) AS \"$label\", " + : + "\n\t$aggfn(CASE WHEN $colfield=$vq THEN $aggfield ELSE 0 END) AS \"$label\", "; + } + } + } + if ($aggfield && $aggfield != '1'){ + $agg = "$aggfn($aggfield)"; + $sel .= "\n\t$agg as \"$sumlabel$aggfield\", "; + } + + if ($showcount) + $sel .= "\n\tSUM(1) as Total"; + else + $sel = substr($sel,0,strlen($sel)-2); + + + // Strip aliases + $rowfields = preg_replace('/ AS (\w+)/i', '', $rowfields); + + $sql = "SELECT $sel \nFROM $tables $where \nGROUP BY $rowfields"; + + return $sql; + } + +/* EXAMPLES USING MS NORTHWIND DATABASE */ +if (0) { + +# example1 +# +# Query the main "product" table +# Set the rows to CompanyName and QuantityPerUnit +# and the columns to the Categories +# and define the joins to link to lookup tables +# "categories" and "suppliers" +# + + $sql = PivotTableSQL( + $gDB, # adodb connection + 'products p ,categories c ,suppliers s', # tables + 'CompanyName,QuantityPerUnit', # row fields + 'CategoryName', # column fields + 'p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID' # joins/where +); + print "
$sql";
+ $rs = $gDB->Execute($sql);
+ rs2html($rs);
+ 
+/*
+Generated SQL:
+
+SELECT CompanyName,QuantityPerUnit, 
+	SUM(CASE WHEN CategoryName='Beverages' THEN 1 ELSE 0 END) AS "Beverages", 
+	SUM(CASE WHEN CategoryName='Condiments' THEN 1 ELSE 0 END) AS "Condiments", 
+	SUM(CASE WHEN CategoryName='Confections' THEN 1 ELSE 0 END) AS "Confections", 
+	SUM(CASE WHEN CategoryName='Dairy Products' THEN 1 ELSE 0 END) AS "Dairy Products", 
+	SUM(CASE WHEN CategoryName='Grains/Cereals' THEN 1 ELSE 0 END) AS "Grains/Cereals", 
+	SUM(CASE WHEN CategoryName='Meat/Poultry' THEN 1 ELSE 0 END) AS "Meat/Poultry", 
+	SUM(CASE WHEN CategoryName='Produce' THEN 1 ELSE 0 END) AS "Produce", 
+	SUM(CASE WHEN CategoryName='Seafood' THEN 1 ELSE 0 END) AS "Seafood", 
+	SUM(1) as Total 
+FROM products p ,categories c ,suppliers s  WHERE p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID 
+GROUP BY CompanyName,QuantityPerUnit
+*/
+//=====================================================================
+
+# example2
+#
+# Query the main "product" table
+# Set the rows to CompanyName and QuantityPerUnit
+# and the columns to the UnitsInStock for diiferent ranges
+# and define the joins to link to lookup tables 
+# "categories" and "suppliers"
+#
+ $sql = PivotTableSQL(
+ 	$gDB,										# adodb connection
+ 	'products p ,categories c ,suppliers s',	# tables
+	'CompanyName,QuantityPerUnit',				# row fields
+												# column ranges
+array(										
+' 0 ' => 'UnitsInStock <= 0',
+"1 to 5" => '0 < UnitsInStock and UnitsInStock <= 5',
+"6 to 10" => '5 < UnitsInStock and UnitsInStock <= 10',
+"11 to 15"  => '10 < UnitsInStock and UnitsInStock <= 15',
+"16+" =>'15 < UnitsInStock'
+),
+	' p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID', # joins/where
+	'UnitsInStock', 							# sum this field
+	'Sum'										# sum label prefix
+);
+ print "
$sql";
+ $rs = $gDB->Execute($sql);
+ rs2html($rs);
+ /*
+ Generated SQL:
+ 
+SELECT CompanyName,QuantityPerUnit, 
+	SUM(CASE WHEN UnitsInStock <= 0 THEN UnitsInStock ELSE 0 END) AS "Sum  0 ", 
+	SUM(CASE WHEN 0 < UnitsInStock and UnitsInStock <= 5 THEN UnitsInStock ELSE 0 END) AS "Sum 1 to 5", 
+	SUM(CASE WHEN 5 < UnitsInStock and UnitsInStock <= 10 THEN UnitsInStock ELSE 0 END) AS "Sum 6 to 10", 
+	SUM(CASE WHEN 10 < UnitsInStock and UnitsInStock <= 15 THEN UnitsInStock ELSE 0 END) AS "Sum 11 to 15", 
+	SUM(CASE WHEN 15 < UnitsInStock THEN UnitsInStock ELSE 0 END) AS "Sum 16+",
+	SUM(UnitsInStock) AS "Sum UnitsInStock", 
+	SUM(1) as Total 
+FROM products p ,categories c ,suppliers s  WHERE  p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID 
+GROUP BY CompanyName,QuantityPerUnit
+ */
+}
+?>
\ No newline at end of file
diff --git a/includes/adodb/readme.txt b/includes/adodb/readme.txt
new file mode 100644
index 00000000..009b94c5
--- /dev/null
+++ b/includes/adodb/readme.txt
@@ -0,0 +1,62 @@
+>> ADODB Library for PHP4
+
+(c) 2000-2004 John Lim (jlim@natsoft.com.my)
+
+Released under both BSD and GNU Lesser GPL library license. 
+This means you can use it in proprietary products.
+ 
+ 
+>> Introduction
+
+PHP's database access functions are not standardised. This creates a 
+need for a database class library to hide the differences between the 
+different databases (encapsulate the differences) so we can easily 
+switch databases.
+
+We currently support MySQL, Interbase, Sybase, PostgreSQL, Oracle, 
+Microsoft SQL server,  Foxpro ODBC, Access ODBC, Informix, DB2,
+Sybase SQL Anywhere, generic ODBC and Microsoft's ADO. 
+
+We hope more people will contribute drivers to support other databases.
+
+
+>> Documentation and Examples
+
+Refer to the adodb/docs directory for full documentation and examples. 
+There is also a  tutorial tute.htm that contrasts ADODB code with 
+mysql code.
+
+
+>>> Files
+Adodb.inc.php is the main file. You need to include only this file.
+
+Adodb-*.inc.php are the database specific driver code.
+
+Test.php contains a list of test commands to exercise the class library.
+
+Adodb-session.php is the PHP4 session handling code.
+
+Testdatabases.inc.php contains the list of databases to apply the tests on.
+
+Benchmark.php is a simple benchmark to test the throughput of a simple SELECT 
+statement for databases described in testdatabases.inc.php. The benchmark
+tables are created in test.php.
+
+readme.htm is the main documentation.
+
+tute.htm is the tutorial.
+
+
+>> More Info
+
+For more information, including installation see readme.htm
+or visit
+           http://adodb.sourceforge.net/
+
+
+>> Feature Requests and Bug Reports
+
+Email to jlim@natsoft.com.my 
+
+
+ 
\ No newline at end of file
diff --git a/includes/adodb/rsfilter.inc.php b/includes/adodb/rsfilter.inc.php
new file mode 100644
index 00000000..c5a54ce8
--- /dev/null
+++ b/includes/adodb/rsfilter.inc.php
@@ -0,0 +1,61 @@
+ $v) {
+			$arr[$k] = ucwords($v);
+		}
+	}
+	$rs = RSFilter($rs,'do_ucwords');
+ */
+function RSFilter($rs,$fn)
+{
+	if ($rs->databaseType != 'array') {
+		if (!$rs->connection) return false;
+		
+		$rs = $rs->connection->_rs2rs($rs);
+	}
+	$rows = $rs->RecordCount();
+	for ($i=0; $i < $rows; $i++) {
+		if (is_array ($fn)) {
+        	$obj = $fn[0];
+        	$method = $fn[1];
+        	$obj->$method ($rs->_array[$i],$rs);
+      } else {
+			$fn($rs->_array[$i],$rs);
+      }
+	  
+	}
+	if (!$rs->EOF) {
+		$rs->_currentRow = 0;
+		$rs->fields = $rs->_array[0];
+	}
+	
+	return $rs;
+}
+?>
\ No newline at end of file
diff --git a/includes/adodb/server.php b/includes/adodb/server.php
new file mode 100644
index 00000000..f79a289f
--- /dev/null
+++ b/includes/adodb/server.php
@@ -0,0 +1,100 @@
+Connect($host,$uid,$pwd,$database)) err($conn->ErrorNo(). $sep . $conn->ErrorMsg());
+$sql = undomq($_REQUEST['sql']);
+
+if (isset($_REQUEST['fetch']))
+	$ADODB_FETCH_MODE = $_REQUEST['fetch'];
+	
+if (isset($_REQUEST['nrows'])) {
+	$nrows = $_REQUEST['nrows'];
+	$offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : -1;
+	$rs = $conn->SelectLimit($sql,$nrows,$offset);
+} else 
+	$rs = $conn->Execute($sql);
+if ($rs){ 
+	//$rs->timeToLive = 1;
+	echo _rs2serialize($rs,$conn,$sql);
+	$rs->Close();
+} else
+	err($conn->ErrorNo(). $sep .$conn->ErrorMsg());
+
+?>
\ No newline at end of file
diff --git a/includes/adodb/toexport.inc.php b/includes/adodb/toexport.inc.php
new file mode 100644
index 00000000..4df0c5a6
--- /dev/null
+++ b/includes/adodb/toexport.inc.php
@@ -0,0 +1,134 @@
+FieldTypesArray();
+		reset($fieldTypes);
+		$i = 0;
+		while(list(,$o) = each($fieldTypes)) {
+		
+			$v = ($o) ? $o->name : 'Field'.($i++);
+			if ($escquote) $v = str_replace($quote,$escquotequote,$v);
+			$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
+			$elements[] = $v;
+			
+		}
+		$s .= implode($sep, $elements).$NEWLINE;
+	}
+	$hasNumIndex = isset($rs->fields[0]);
+	
+	$line = 0;
+	$max = $rs->FieldCount();
+	
+	while (!$rs->EOF) {
+		$elements = array();
+		$i = 0;
+		
+		if ($hasNumIndex) {
+			for ($j=0; $j < $max; $j++) {
+				$v = $rs->fields[$j];
+				if (!is_object($v)) $v = trim($v);
+				else $v = 'Object';
+				if ($escquote) $v = str_replace($quote,$escquotequote,$v);
+				$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
+				
+				if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote";
+				else $elements[] = $v;
+			}
+		} else { // ASSOCIATIVE ARRAY
+			foreach($rs->fields as $v) {
+				if ($escquote) $v = str_replace($quote,$escquotequote,trim($v));
+				$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
+				
+				if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote";
+				else $elements[] = $v;
+			}
+		}
+		$s .= implode($sep, $elements).$NEWLINE;
+		$rs->MoveNext();
+		$line += 1;
+		if ($fp && ($line % $BUFLINES) == 0) {
+			if ($fp === true) echo $s;
+			else fwrite($fp,$s);
+			$s = '';
+		}
+	}
+	
+	if ($fp) {
+		if ($fp === true) echo $s;
+		else fwrite($fp,$s);
+		$s = '';
+	}
+	
+	return $s;
+}
+?>
\ No newline at end of file
diff --git a/includes/aptree/apytmenu.js b/includes/aptree/apytmenu.js
new file mode 100644
index 00000000..792fb799
--- /dev/null
+++ b/includes/aptree/apytmenu.js
@@ -0,0 +1,13 @@
+//******************************************************************************
+//     Apycom DHTML Tree Menu 1.34
+//       www.dhtml-menu.com
+//    (c) Apycom Software, 2004
+//         www.apycom.com
+//******************************************************************************
+
+//////////////////////////////////////////////
+// Obfuscated by Javascript Obfuscator 2.19 //
+// http://javascript-source.com             //
+//////////////////////////////////////////////
+
+var I1Il=0,l1II1=0,ll1l1=0,isNS4=0,Il1l=0,llll1=0,IIII1=0,I1I=0,I1lI1=0,lIlI1=0,I1l1=0,I1II1="",lI=0,llI1=0,l1=[],II11=false,Il1I1,lI1I1,I1ll,lIll,III1=false,Il11=[],lI1I=[],lll=false,l1l1=false,Ill1=0,l1ll=null,lI11="",l111l=1000,II1I=[],II1l=[],l11l;I1l1I();function I1l1I(){var l1II=navigator.userAgent,III1l=navigator.appName,IlI1l=navigator.appVersion;lIlI1=IlI1l.indexOf("Mac")>=0;I1lI1=document.getElementById?1:0;var l1l1l=(parseInt(navigator.productSub)>=20020000)&&(navigator.vendor.indexOf("Apple Computer")!=-1);if(l1l1l&&navigator.product=="Gecko"){ll1l1=1;I1I=6;return;};if(l1II.indexOf("Opera")>=0){Il1l=1;I1I=parseFloat(l1II.substring(l1II.indexOf("Opera")+6,l1II.length));}else if(III1l.toLowerCase()=="netscape"){if(l1II.indexOf("rv:")!=-1&&l1II.indexOf("Gecko")!=-1&&l1II.indexOf("Netscape")==-1){IIII1=1;I1I=parseFloat(l1II.substring(l1II.indexOf("rv:")+3,l1II.length));}else{ll1l1=1;if(l1II.indexOf("Gecko")!=-1&&l1II.indexOf("Netscape")>l1II.indexOf("Gecko")){if(l1II.indexOf("Netscape6")>-1)I1I=parseFloat(l1II.substring(l1II.indexOf("Netscape")+10,l1II.length));else if(l1II.indexOf("Netscape")>-1)I1I=parseFloat(l1II.substring(l1II.indexOf("Netscape")+9,l1II.length));}else I1I=parseFloat(IlI1l);};}else if(document.all?1:0){I1Il=1;I1I=parseFloat(l1II.substring(l1II.indexOf("MSIE ")+5,l1II.length));};isNS4=ll1l1&&I1I<6;l1II1=I1Il&&I1I>=5;llll1=Il1l&&I1I>=7;I1l1=I1Il||llll1;};function II1ll(){var lII1l=I1l1?l11l.scrollLeft:pageXOffset,llI1l=I1l1?l11l.scrollTop:pageYOffset;return[lII1l,llI1l]};function l1lll(l1lI1){with(l1lI1)return[(isNS4)?left:parseInt(style.left),(isNS4)?top:parseInt(style.top)];};function IlIll(l1lI1,Ill1l,I1l1l){with(l1lI1){if(isNS4){left=Ill1l;top=I1l1l;}else{style.left=Ill1l;style.top=I1l1l;};};};function IlI1I(){if(II11)return;for(var lII1=0;lII1-1&&IIIl<0)IIIl=-1;else if(IIIl>0&&IIIl<1)IIIl=1;if(IlII>-1&&IlII<0)IlII=-1;else if(IlII>0&&IlII<1)IlII=1;};IlIll(llII1,IlI[0]+((IlI[0]!=l1I1l)?IIIl:0),IlI[1]+((IlI[1]!=IIl1l)?IlII:0));};};};if(I1Il||Il1l){document.onselectstart=function(){return(II11?false:true);};};var oldResize=null;function lIl1I(){document.location.href=document.location.href;if(oldResize)oldResize();return true;};if(isNS4){if(typeof(onresize)!="undefined")oldResize=onresize;onresize=lIl1I;};var lIl1=null;function l1Ill(I1I1l){with(I1I1l)return[(I1Il||Il1l)?clientX:pageX,(I1Il||Il1l)?clientY:pageY];};function lll1I(event){if(II11&&Ill1){var IlI1=l1Ill(event),I1l=(I1l1?II1ll():[0,0]),IIIl1=IlI1[0]-Il1I1+I1l[0],IlIl1=IlI1[1]-lI1I1+I1l[1];I1ll.style.left=(IIIl1>=0)?IIIl1:0;I1ll.style.top=(IlIl1>=0)?IlIl1:0;};return true;};function lI1Il(){if(document.attachEvent)document.attachEvent("onmousemove",lll1I);else{lIl1=document.onmousemove;document.onmousemove=function(I1I1l){lll1I(I1I1l);if(lIl1)lIl1();return true;};};};function III1I(lI11l,lII11){if(isNS4||II11)return;I1ll=l11ll("apy_t"+lII11+"div");lIll=l1[lII11];var IlI1=l1Ill(lI11l),IlI=l1lll(I1ll),I1l=I1l1?II1ll():[0,0];Il1I1=IlI1[0]-IlI[0]+I1l[0];lI1I1=IlI1[1]-IlI[1]+I1l[1];II11=true;};function ll1lI(){var I1l=II1ll(),IlI=l1lll(I1ll);lIll.left=IlI[0]-I1l[0];lIll.top=IlI[1]-I1l[1];II11=false;};function apy_tload(){l11l=(document.compatMode=="CSS1Compat")?document.documentElement:document.body;if(!(Il1l&&I1I<6))for(var lII1=0;lII1=0;l111--)with(ll[l111]){llll=Illll(Il,IIl,ll[l111+1].llll,ll[l111+1].Il);};};};};function apy_tmenuInit(){if(!lI)l1l1I();var lllI1;llIll();l1[lI]={ll:[],id:"apy_t"+lI,left:tleft,top:ttop,floating:tfloatable,moving:tmoveable,abspos:tabsolute,iterations:(tfloatIterations<=0)?6:tfloatIterations,width:tmenuWidth?tmenuWidth:"200px",height:tmenuHeight,Il11I:tmenuBorderWidth,lI11I:tmenuBorderStyle,l111I:tmenuBorderColor,IlIIl:tmenuBackColor,IllIl:tmenuBackImage,moveImage:tmoveImage,moveImageH:tmoveImageHeight,IIlIl:texpandBtnAlign,lIIIl:ticonAlign,XPStyle:tXPStyle,ll11:(II1l[lI]?II1l[lI]:""),Ill:(l1l1?II1I[lI]:[])};var I1II=l1[lI],I1,I111l="",llI11,IIl=0,lIlI,IllI,I1lI,ll1I1,l11I1,l1Il="",lIl11=[tfontStyle,tfontStyle],lll11=[tfontColor[0],ll1ll(tfontColor[1],"")],l1l11=[tfontDecoration[0],ll1ll(tfontDecoration[1],"")],IIlI1=[titemBackColor[0],ll1ll(titemBackColor[1],"")],IllI1=[texpandBtn[0],ll1ll(texpandBtn[1],""),ll1ll(texpandBtn[2],"")],l1I,l1I,lllIl,I1lIl,lIlIl,lII,itemVisible='visible',expnd;for(var l111=0;(l1110)tmenuItems[l111][0]=substring(llI11,length);};if(llI11>IIl)IIl=llI11;llI1=I1II.ll.length;lII=ll1ll(tmenuItems[l111][7],"");IIIIl=(lII)?parseInt(lII):-1;IllI=I11ll("tfontStyle",IIIIl,lIl11);lIlI=I11ll("tfontColor",IIIIl,lll11);I1lI=I11ll("tfontDecoration",IIIIl,l1l11);ll1I1=I11ll("titemBackColor",IIIIl,IIlI1);l11I1=I11ll("texpandBtn",IIIIl,IllI1);l1Il=ll1ll(tmenuItems[l111][6],"_self");if(l1Il=="_self"&&titemTarget)l1Il=titemTarget;if(tXPStyle){l1I=tXPExpandBtn;l1I=tXPExpandBtn;lllIl=tXPTitleBackColor;I1lIl=tXPTitleLeft;lIlIl=tXPTitleBackImg;var lII=ll1ll(tmenuItems[l111][8],"");if(lII){IIIIl=parseInt(lII);l1I=Il1ll('tXPExpandBtn',IIIIl,tXPExpandBtn);lllIl=Il1ll('tXPTitleBackColor',IIIIl,tXPTitleBackColor);I1lIl=Il1ll('tXPTitleLeft',IIIIl,tXPTitleLeft);lIlIl=Il1ll('tXPTitleBackImg',IIIIl,tXPTitleBackImg);};};I1II.ll[llI1]={Il:llI11,llll:"",id:I1II.id+"i"+llI1,IIIl:tlevelDX,hasChild:false,I1l11:ll1ll(tmenuItems[l111][0],""),l1I1:ll1ll(tmenuItems[l111][1],""),IIII:l1Il,lIII1:ll1ll(tmenuItems[l111][5],""),align:titemAlign,lll1l:"middle",cursor:titemCursor,lIIl:lIlI,font:IllI,llIl:I1lI,IlIIl:ll1I1,IllIl:[titemBackImage[0],ll1ll(titemBackImage[1],"")],ll11l:["",""],lIl:[ll1ll(tmenuItems[l111][2],""),ll1ll(tmenuItems[l111][3],""),ll1ll(tmenuItems[l111][4],"")],I1IIl:ticonWidth,I111I:ticonHeight,Il1:l11I1,I111:l1I,llIIl:lllIl,ll11I:I1lIl,l1IIl:lIlIl,visible:itemVisible};if(!I1II.ll[llI1].lIl[0])I1II.ll[llI1].lIl[0]=tblankImage;};with(l1[lI]){for(var l111=0;l111";else{lI11+="
";};lI11+="";if(moving){lI11+="";};lI11+="";else l1111+="";};return l1111;};function lllll(){var l1111="";l1111+=(l1[lI].IIlIl=="left")?IIIll():"";l1111+="";};return l1111;};function lI1ll(IIl11){return"";};function Il1Il(){var l1111="";with(I1){if(!I1l11)return;l1111+="";};return l1111;};var show=false;for(var I1I1=0;I1I1";lI11+="
";lI11+="
";};var I1,Illl,II1,llI,expnd,lll1=isNS4||(Il1l&&I1I<7),III=texpanded,II111="",IIll="";if(tpoints)I1Ill(IIl);function IIIll(){var l1111="";with(I1){for(var II11l=Il;II11l>=0;II11l--)if(tpoints&&II11l!=Il)l1111+=((llll.charAt(Il-II11l-1)=="1")?"":"")+"":tpointsImage+"' style='background-repeat: repeat-y'>"):">");if(expnd){l1111+="":" onMouseDown='IIlll(this,"+llI+",2)' onMouseOver='IIlll(this,"+llI+",1)' onMouseOut='IIlll(this,"+llI+",0)' onMouseUp='javascript:tcurBtn=true' >";}else l1111+="";var Il11l=((lll1&&lIl[2]&&expnd)||III)?(lIl[2]?lIl[2]:lIl[0]):lIl[0];l1111+="":"")+"";l1111+="";l1111+=((isNS4&&l1I1)?""+I1l11+"":I1l11)+"";}else{Illl=(I1.visible=="visible"&&(show||lll1||I1.Il<=1||III))?"":"none";if(!I1.Il){lI11+="
";lI11+="";lI11+="";};lI11+="";}else{lI11+="background-color:"+I1.IlIIl[0]+"' ";lI11+="onMouseOver='I11Il(this,"+llI+",1)' onMouseOut='I11Il(this,"+llI+",0)' onClick='lI1lI("+llI+")'>";};lI11+="";if(tXPStyle)with(l1[lI]){if(I1I1+1==ll.length||(I1.Il>0&&ll[I1I1+1].Il==0)){lI11+="
";};lI11+="";with(l1[lI])expnd=ll[I1I1].hasChild;if(!tXPStyle){with(l1[lI]){lI11+=(IIlIl=="left")?lllll()+lI1ll(1):"";lI11+=(lIIIl=="left")?lIlll()+lI1ll(0):"";lI11+=Il1Il();lI11+=(lIIIl=="right")?lI1ll(0)+lIlll():"";lI11+=(IIlIl=="right")?lI1ll(1)+lllll():"";lI11+=(I1.Il)?lI1ll(0):"";};}else{with(I1){IIll=(isNS4&&l1I1)?"":"";IIll+=""+I1l11+"";IIll+=(isNS4&&l1I1)?"":"";};if(!I1.Il){II111=(isNS4&&!tXPTitleTopBackColor)?"":"BGCOLOR="+tXPTitleTopBackColor;with(I1){if(I1.lIl[0]!=tblankImage){lI11+="";lI11+="";}else{lI11+="";lI11+="";lI11+="";};};}else with(l1[lI]){lI11+="";lI11+=lllll()+lI1ll()+lIlll()+lI1ll();lI11+="";};};lI11+="
";lI11+="";lI11+="";lI11+="";lI11+="
";lI11+=IIll;lI11+="
";lI11+=IIll;lI11+="
"+IIll;lI11+="
";lI11+="
";lI11+="
";};};};if(isNS4)lI11+="
";else lI11+="
";document.write(lI11);lI11="";var ttl=false;if(!texpanded||l1[lI].ll11){for(var l111=0;l111I11l1){var Il111=IlII1/tXPIterations;Il111=(Il111<1)?1:Il111;var I1111=IlII1-Il111;I1111=(I1111III11)?III11:I1111;I11.style.height=I1111;}else{window.clearInterval(Il11[l11]);Il11[l11]=null;};};function ll1Il(II,l11){var I1=l1[II].ll[l11],l1ll1=I1.id,Il1=l11ll(l1ll1+"btn"),I11=l11ll(l1ll1+"divXP"),ll111=l11ll(l1ll1+"titleXP"),Il1=l11ll(l1ll1+"btn");if(Il11[l11]>0)return;if(Il1.name){Il1.name="";I11.style.height=I11.offsetHeight;lI1I[l11]=I11.offsetHeight;I11.style.overflow="hidden";if(!lll){Il11[l11]=window.setInterval("I1I1I('"+I11.id+"',"+(ll111.offsetHeight+(37-tXPBtnHeight))+","+l11+")",5);if(Il1&&I1.I111[1])Il1.src=I1.I111[1];}else{I11.style.height=(ll111.offsetHeight+(37-tXPBtnHeight));if(Il1&&I1.I111[0])Il1.src=I1.I111[0];lll=false;};}else{Il1.name="1";Il11[l11]=window.setInterval("l11lI('"+I11.id+"',"+l11+")",10);if(I1.I111[3])Il1.src=I1.I111[3];};if(tsaveState)lIIll();};function I1lll(IIll1,lI1l1,ll1){with(IIll1){with(lI1l1){color=(lIIl[ll1])?lIIl[ll1]:color;font=(font[ll1])?font[ll1]:font;textDecoration=(llIl[ll1])?llIl[ll1]:textDecoration;};};};function lII1I(lllI,II,l11,ll1){var I1=l1[II].ll[l11],lIIl1=l11ll(lllI.id+"font"),IlI11=l11ll(lllI.id+"btn");with(I1){I1lll(I1,lIIl1.style,ll1);if(!IlI11.name){if(I111[ll1])IlI11.src=I111[ll1];}else if(I111[ll1+2])IlI11.src=I111[ll1+2];};};function lI1lI(II,l11){if(III1){III1=false;return;};var I1=l1[II].ll[l11];if(texpandItemClick&&I1.hasChild){IIlll(l11ll(I1.id+"btn"),II,l11,2);III1=false;};with(I1){if(l1I1){if(l1I1.toLowerCase().indexOf("javascript:")==0)eval(l1I1.substring(11,l1I1.length));else if(!IIII||IIII=="_self")location.href=l1I1;else open(l1I1,IIII);};};};function I11Il(lllI,II,l11,ll1){var I1=l1[II].ll[l11],lIIl1=l11ll(lllI.id+"font"),llIl1=l11ll(lllI.id+"td");with(I1){if(IlIIl[ll1])llIl1.style.backgroundColor=IlIIl[ll1];if(IllIl[ll1])llIl1.style.backgroundImage="url("+IllIl[ll1]+")";I1lll(I1,lIIl1.style,ll1);llII=l11ll(lllI.id+"icon");if(llII&&!llII.name)llII.src=(lIl[ll1])?lIl[ll1]:llII.src;};};function Ill1I(II,l11,Illl){III1=true;var I1=l1[II].ll[l11],IIlI,ll1I,l11I,Il1;if(l1[II].XPStyle){var I11;for(lII1=l11;!I11;lII1--)I11=l11ll("apy_t"+II+"i"+lII1+"divXP");I11.style.height=I11.offsetHeight;};if(l11+1==l1[II].ll.length)return;with(l1[II]){if(Illl!="none"){for(var lII1=l11+1;lII1=1;lII1++){ll1I=ll[lII1];Il1=l11ll("apy_t"+II+"i"+lII1+"btn");if(Il1){Il1.name="";Il1.src=(ll1I.Il1[0])?ll1I.Il1[0]:Il1.src;l11I=l11ll("apy_t"+II+"i"+lII1+"icon");if(l11I){l11I.name="";l11I.src=(ll1I.lIl[0])?ll1I.lIl[0]:l11I.src;};};if(XPStyle){IIlI=l11ll("apy_t"+II+"i"+lII1+"td");I11.style.height=I11.offsetHeight-IIlI.offsetHeight;};l11ll("apy_t"+II+"i"+lII1).style.display=Illl;};if(!lll)I11Il(l11ll("apy_t"+II+"i"+l11),II,l11,1);else lll=false;};};function IIlll(Il1,II,l11,ll1){var I1=l1[II].ll[l11];if(!Il1.name)Il1.src=(I1.Il1[ll1])?I1.Il1[ll1]:Il1.src;if(ll1==2){if(Il1.name)ll1=1;lIl=l11ll(I1.id+"icon");if(lIl){lIl.name=(!Il1.name)?"1":"";lIl.src=(I1.lIl[ll1])?I1.lIl[ll1]:lIl.src;};Il1.src=(I1.Il1[ll1])?I1.Il1[ll1]:Il1.src;Il1.name=(Il1.name)?"":"1";Ill1I(II,l11,(Il1.name?"":"none"));};if(tsaveState)lIIll();};function Il1ll(lI1l,I11I,ll1l){var l1l=[],lI111=tXPStyles[I11I];for(var lII1=0;lI111[lII1].indexOf(lI1l)<0&&lII1^G@+`uu~_8Garvc2)*!0IGct|0M-u(XU^QANUuU|TT?c%XJH_qR`ed+Ooo5%L8yL9Hj?Q3Ul zTt0bl$MOT)mmS`<>imh_Paobov}48p|Nj|i26R9sgZ#q4W_Exf!Gndv`9w;_4hsu$ wjuQqG4J1T*&lf1XD${m$a(s{wVRV??Re5HD&EXTQTW%Iu9aAzCU}3NZ0Qwhhc>n+a literal 0 HcmV?d00001 diff --git a/includes/aptree/img/cpoint.gif b/includes/aptree/img/cpoint.gif new file mode 100644 index 0000000000000000000000000000000000000000..497e867697eee8558b15097d5ce536a43bb732c7 GIT binary patch literal 53 zcmZ?wbhEHb-oxE}+giC9 FtO0^l4x|78 literal 0 HcmV?d00001 diff --git a/includes/aptree/img/expandbtn.gif b/includes/aptree/img/expandbtn.gif new file mode 100644 index 0000000000000000000000000000000000000000..9289c84f5ee0732df0a775350f2f04d779aafbaa GIT binary patch literal 97 zcmZ?wbhEHb6krfwn8?8J|NsB``g$K9A0R{VCkrD312cmT0}z1Z8JLXb^sij~fZvg6 yVU)IDuilf*mWLku&hw}{rncp6nqBg8K1GAWw(GuB|NsAIpfS(^nGf;{1Dp8)h6E254*L^N(sx+MIB*|Hp5YfakDU!Y`bnlm%Z5^CiZ8$w~T?H`=wjEs$ulCJXOov^acm800B*748J(EtDc z@bU84JL7ptI)(2M#`%lo;S9hNDOWIH;ghpog0Ro(d36M8eVFg9Bt1eR;?hG>|Uhbf|ITI>6xsu)03s$t^k499YnxK@S-g z5_Cur;=+av8aQm=p@9X46*!3G@UTLI3>H2B(2ybI$dMforUcL-W(ScC4{q2n^JdMK z2s>!l$x~%bq8e~^*oonSN}@ZLLdDSZDO0FSsZvm>fhtj|V4H4T85Zn?3ls(r5Ww{U cRkR<}3K;OAu0RbI;Gqs{~uKUzmh*QopDwM)0`}pc{ywg z@;DY3axX3BT~Q{mx>9&ujo5}diOr4DTN-7yHpy;pk>Am(u&Z5ZPp8V>F4g@#>IZr? z4)tptouqqwivG!IhNov3pP6ZLd4ctvl`hXV`@P>2{^MxE|1;_T|NlRJ{P@rFfYgHg#K1P=z)c;NUlk#m z3yUP3ECc6+6=~)$tz!sz7PQbqNlQ^fL1X%Szm9Cv-#i?1chod*^idI-y8MFUZ%z#! zJy|xzi1u(b25tixbp-~-Ns}k3GH@A6tIIMl&znC_g@MyhQeBFHb=B%s$_yNa;_6}y yY}>YPQ(|B@(25fj;OFDz;pXDxU^mj&)YUhr)cXSdR8LR;X^oMW& literal 0 HcmV?d00001 diff --git a/includes/aptree/img/icons/folder2.gif b/includes/aptree/img/icons/folder2.gif new file mode 100644 index 0000000000000000000000000000000000000000..a8826afdbfa1348315433fe18c4adaeb68111b47 GIT binary patch literal 363 zcmZ?wbhEHb6kypL7C9Sr#YxMp^>4}_RrM( ze?8~XX6JjGoS*Lt{(H6H{VwOF#k~KINB_Ux^8feu|Ns9VJ9cdI=FKZtuAD!A{Ok>4d85$xV}LRG1^07?ha!bcAI18CiP! zdgVA2J0!UoIA_e{5={b literal 0 HcmV?d00001 diff --git a/includes/aptree/img/icons/help1.gif b/includes/aptree/img/icons/help1.gif new file mode 100644 index 0000000000000000000000000000000000000000..fd09b3f066fab5d4c91801f17fd4bdfafb3aea02 GIT binary patch literal 211 zcmZ?wbhEHb6krfw*v!D->+8Q})8*4wzD!5_*knj zIr+5ADqt*^(Y=t<>D)9?<4%`3Q^SE9vRoHt1aA?sn9uC;@#bpLGPffPr($&k&!;C% z{HG++aOZ|(jhF~es&e{yvBPOXj657{0m-b9+*M8798Ap26-ot?Y;4@R+}w-|c9KH# L7R?tHWUvMRl>1K7 literal 0 HcmV?d00001 diff --git a/includes/aptree/img/icons/help2.gif b/includes/aptree/img/icons/help2.gif new file mode 100644 index 0000000000000000000000000000000000000000..dd98b9915eb606cc3a6ee16687622d7244d43f61 GIT binary patch literal 211 zcmZ?wbhEHb6krfw*v!DN`OMA*=a*l4bIo>&eb>@1Uq9dT7tjCs`^R;iZPW4615bC} z|8n!)hd2NK|7QRL#h)yU3=F&sIv^g%36M8eVFg9Bt1eR;?hG>|Uhbf|ITI>6xsu)03s$tt$Nk%w1VGsZi0K@6M8eVFg9Bt1eR;?hG>|Uhbf|ITI>6xsu)03s$t8YEzVnzgBfvtw0)1&cug NhO{ve%9SfHAOO?zaS8wc literal 0 HcmV?d00001 diff --git a/includes/aptree/img/icons/paper.gif b/includes/aptree/img/icons/paper.gif new file mode 100644 index 0000000000000000000000000000000000000000..53e260f6e538d4714f1ede1906f3ebcfae2602fb GIT binary patch literal 250 zcmV6M8eVFg9Bt1eR;?hG>|Uhbf|ITI>6xsu)03s$t2vZl(A zH#_>=5Rzv?3OkEp2nqn{Po+yaIwcA<>QSmdmultsz@R}2U^xOHK(?$|vH$`C00Kc~ Ar2qf` literal 0 HcmV?d00001 diff --git a/includes/aptree/img/icons/search.gif b/includes/aptree/img/icons/search.gif new file mode 100644 index 0000000000000000000000000000000000000000..81c3760aef70f27e57e01a7404a775b358275a48 GIT binary patch literal 291 zcmV+;0o?vaNk%w1VGsZi0K@fakDU!Y`bnlm%Z5^CiZ8$w~T?H`=wjEs$ulCJXOov^acm800B*748J(EtDc z@bU84A{1Bj2;_e2r2Tyg$yt&Xh;cQWy_N=W74##;X;R; z9XiPTSd-<;3nGJF@IaL3%M2QVa=^e8WX6|4J8baCfoKB<4N6wXuywre zlKX2feY*Ji&+CsLrCKH2x4GS(rTpnY^6sr`tt~A6|NqZ`7byN@VPs$sWzYes0@=yH z+Nz+`w zfi-e6U2Tlri`Eq+sFoMZTB99|xb;D~a}ZI!q?%F#DfVsER)-%(4rtD1OEE%||3(tWkW yy9`J`2gC;HWnhsH@QBQkmAE~-{pWqfF7HUKj8$qmuayjZ&J-uyc9`eRU=0A8VIZ*p literal 0 HcmV?d00001 diff --git a/includes/aptree/img/vpoint.gif b/includes/aptree/img/vpoint.gif new file mode 100644 index 0000000000000000000000000000000000000000..4f7296611321e091b41533303ca1d7f5dd1a3d61 GIT binary patch literal 45 xcmZ?wbhEHb-GYox}V2@d1U-k}3GAwO_Wg?ey3W&GtX+p8LZ+_nvd_Pj^?vPC5fx zhgyevi9%s(?AbhPHqU|+xN$X39N&rMS+UhtEYE@$A$SoCfL;Lf00K84aN+n4T#X%9 zZ6k;S1QCn}eR!b{4|?&S2M@Y|8YjSa5^E9SQY!QlM1BJ3BM5y2&`SV4q$OVj6U8u5 z=+BiR6bQlco!Qk^KokJPFd*^+LLUzF-~=vgjSVjj;A;bTF^pd-ksyR6A@mSy14K!H zAoc?S3rT_yYkefKiwq&TQeU1tm#8A77>)j>w?yZMBr5ew+2Jf~8Pg$dPN28b3 zkF(k$EPZ6BeuCW=+0lxyv;kHt%+>~W=|kmuq+A!^c1~7ygt^DYxt-&chEQb(!ZC!n zM}y#rNNrz4+CMHm^%ydatA-{k3<&3Fh}S!DpeMrbkAlW1csg2hDkA6`mkv(L&iw)n zJ(Zt}s!TEY;N&55{E%tt@P%mI&{OH)6Y1cj?A(<6^QnWT8I@_~;Q6TX{8YU;uDKZ3 z49Dxgn$}#LX}A<`7>+evo^2eSX}%O|{yNq)Jl%RF-gr6Q^p3HXk@+Jdvn^L=wWIUe z(K+qdT-(^ZZgfsJHmAS7&~am-eQeHfbK%(SXUA?W8g4IkezW-YKcN19YbpFkzQMP-H7()V^-dot-n_^iCgz6$$e`|9$cL|e}a2Cel0TE;SB09>fKyKmJ- zVuxDuDugZnAopZy@rhgkReG04T4uXoq~vdU_sE%w2^spufu!9Z79EaR&d$SMW-eEdO5<8MxSpZ5wf>WN zool9@xm*3h5+|HtKBoWLFF(oo!7q5wWbHmtP1%6!yhraHNdKtN^boSbPbxPqQ71cbD7SwJl`Pt>iZVz*0XYXD|#0%zr9p1b3K! zkT3(rzTaGr%ME`yAJ$J)U#VNRhRy1~asO=Uwfp9m3$JRUk9_IR;_mJglLl+dN-a{c zk5;M6(s1d5QybDKm~V}RW(AtPW_?-Mk#&_>z{y;h(FUbZX%MIA=ACBt>MHg2y`S$Z2t41<$$Ln?mP!&hVwQxT!$o^jD72wvYX`(-%K0SB@vFk1ed-z9M2_zL${7WG1GmyU;5?8PKY>Z<+_u2`Pf# k(aBq)mVJ^eP%)HxA%|uy+qzE}W+y7YU&X^>FsLp60>e-zGXMYp literal 0 HcmV?d00001 diff --git a/includes/aptree/img/xpcollapse2.gif b/includes/aptree/img/xpcollapse2.gif new file mode 100644 index 0000000000000000000000000000000000000000..8912fb1f788fb89cd5d5eecdf0d3454f382665b1 GIT binary patch literal 1300 zcmcIjYfn=L0Bv1)C?JT#=$7fEy?yX#FCwfUV!>8{7N3Rowx#8^)Hbz95ekJWA|L`{ zz*lD{PDL@kmN=Y=iCfb5^Y*rAQIrl^UON4Awq;aM1hA0xrvaA2swdDJHWG(t5EV%D)5qoUJ~RX2|OgoO@dsMC0~e;MF?5o zO_!il7{&AKsTF2G=mSIuAoKzP4*_x!_zrxfg(&h7t9(QeLR=~lqogGvaFMHgWU-GV z@&bGlMU0ZGJQR^514h#&o=llP6Gk(oXu8-*mHDYPC{>1Ji0!l`A@xwDu1twJOCHEl z_^H(vQ0fL{Zm`A;N?o*SD-E_%tIZ&6qg7jIumyyzSyEe;%$i-}+$6Pamby!HU^m>+5n6dn%dt6hwSU_q_3u+CF>$j#D? zGn<1iNt2J$Hc{3(#yL99X&W!o2g+Jewm!f) z;)hNIt9pWx-f_vvr*Pl6VsN5VkFt*hxLwcocLsUAA*e3|oeEW+4Dx%%B?D8^v%kZG zFJ)PV^nFmccrIcS(XbTL#t_);?PLNYKRJv%8oH+jG?tuRaPr#z zP(<~^l={+i?d3@AP*`(irfz7u{&Kkf$FOE-s_|;%o^P@4N<{OS;fCS4!^1NT*JiXg z=Cn6vwIj35BXdnRW}8N4bvNf*Z_T%i%<6B?AHDnP=$!@q-G#QF78Vy5G5b;)3~rE^6d*!T!5W%l6!LZH5* zXVpe>t5W?TfG_zfy*obtL^_`)xzD96vy5J6cVrKpAMGw*b8Giy@w&GQef?dABnnEG zsxD>hKKALgyCKF;RQb??f9M^=P50O zf0J)=jNs|fiZ`YR=`-dhjP#9x1Cd_Vu8D)hvY_$uP;h%;#LeJSy| z3f7Tw<-P<$BLC!u1S;-lPmZw$%UZL(c+8e^jhW3(UYXPk$I(FeRPOD2^{mz9%A(k` zClfO)+)7tdwWCZ$KZo_3f~qsMLi$O-4jOz2bZnw7ZooDjP%s##Fzrj z@t6mtdGe@)Bn$(S7Ta#ZMl-G+k6Is|Ut6>yXkvU370+NqCn(#oE5Ga4DvCDELD;A` m{-4;`Eg{ohaSBv37=JMhG#78(D;Q%%%YRwL#p7_8E&l;IKqY?w literal 0 HcmV?d00001 diff --git a/includes/aptree/img/xpcollapse3.gif b/includes/aptree/img/xpcollapse3.gif new file mode 100644 index 0000000000000000000000000000000000000000..35e728e0e89f963d9b60b75b66750af9509fe1d0 GIT binary patch literal 1290 zcmcIj`BM`I7+oP?DyTq0+av||cm!CI+Tm8yjb9@XM>w5%-^s7W-x{HMdf^kSY6pj!bOzUH&nI&+rMT2aSqnl&t=9s%VC`UBF z;#*mKi%|MZ4!w}72KD`Jongc}Fm8AFMm-S*Xzk)y+2ZF+zKzMZfX?cpni5i_AdahcZtRA5u} zh2=Uwg2uGQQPl1obOlE|kxrqDA#gqs53?0sQ08f8+u3ptD04G-4zAM6mb;$_pNo-@ zL>KPShQvrvqzMS1aR%3>G{&X6up}vJ0%{YX>c>^axT-&{G+>Ipm_!@wK?0D8fKWo6 zjAV$(^%1!~45I{O!XZ;!WlSm|#6oJ!1dQS^npC1nLquyO5euO)j9IUE+~W zp%YY$F=cM1bQF|(STZ*s^0O5lQ10fb$3fY!!WdWf$3+^S5FUrk$;>!x#t|#gYft(n z*AgywWXz9EOilr79=d(lh&SpF6TT4c4Pe12NlZ+|@X0`w^o8+Ij10!eC_Wh{UrxMC zkdsqWiRqV92|P)XcljTH{}YQQC^G=S36#7xdHoXr^%b!D;i^roZI8D8MPGUrgL8_i zq>JhFUDU#gCd#(_jgPu>KDn4x{CQEs@qHV%D%R~st{-lh*P7i_Te7ivu6pO+Rma<9 zi<*8;Tef%aez4fByP3DMNps*}N_zRn+uLYmjhn9TTYPw+=0?Y^IdkWKeXd}2-TL%5 z7W|pl($Mf8z3}b#skAM`t){Hfn|U4OKR#~HFXkD)s9U)ywYX_sJeM4u(IP{r*Je9= zD>GL8lzI58Z?B|ZsIOmg{>?-wuyS{KLz(dkYP*qgulU+K{?Y;aFOnvLtT4$-(@((hL=DU^c^ztpar^V!bY<&3j;<@wyP zQ#AU$s^c?L*OjDRU16#?QInTlxP9}2lZ;b$>GuyswX?Q0(kkb!ZSGD@Inq|9Ej?3z z%DMDWW96k~La8x5t7cYqM#-_U@|m=j+0_q<>M{>NS-g=0TS|Z6ZTPjYkz%sc{`1xe zP0=N4Ikd1^S=PL;8OzDsbNP=4+4SG3%hPhN7N(@-o-fI%uB-C$ca+^eJ=8ky&av#@ VYR-HI?x@UIfwk^9mqr0r{|iHt_GthB literal 0 HcmV?d00001 diff --git a/includes/aptree/img/xpcollapse4.gif b/includes/aptree/img/xpcollapse4.gif new file mode 100644 index 0000000000000000000000000000000000000000..a22c68dd41d17299236dfb66839ae804f7f30212 GIT binary patch literal 1290 zcmcIj`BM`I7>y7x6;z-_L8ucI+M2>xP%G7Hm8yjb9@W9=Xj>23@tSt5=;(}AXzPfm zBhyjGYU@$$R4^bWn>!)N=Ge_aNZ8GVK@*OIkUQDzE=ZuU|3lwT-+MoN@6EjL`>c9% z#Yg+|DftwFLP;d1r>3S8iK$LD8VJTA-C#IEw6m;FSZ21+!4VH|#EvemrHgCs;-Xw} zKU-jB3oIhpa}atdQwx01mQ* z_GbcHH{=n3F1E-Hi0ulEQ>AnDq8@)R{)FdX@&}ka2N(2+Ab&f@D$_@$x^TBPB!&Zk zbg+}(uQ0^q`mhA{wXqSE5tC{I5_k;ii>pl-jNr=Nhy)rHt33k6kk(9SP+YF_KNH$i zyS_`Q$6EKRyXi|wPjS-!d)LICQ8HW)JMlqE!BGdWw zR#I;xbrwQv#x-ahMq)j$DXulgHE0a#ix})=kB#Wj{))_g(fN+7K3w& zs$`29j9s+CiYDr|{Ed&haz4G7Rs2O!!|{C^wkp=`*Iqx|GOsneskUTe^IY}Lzp9S6 z$rm;KoVIN5-u*zaTYo!mXOrf@!Ibp!PqyEpmo;v>zHjm2{+b)@yXMTD|Mj_oHFfLL z-&pWRUQ0v6`;5Z3KcLaK5O!LH1i@AAEb`raPkDAH_NpLK}N`;zgnf<>hsZ1|;i)tt|F&R)(udmqf_ zjh>=29#kElnY!-1)T=9z6(?%)vJ1CwUT~6m>OSM)p{Q=wwnlp8+_lYJsVPTpmFY^) z)Sq%LecV`iX_-i7O3$j9m7P&?Y_xnPy=8XwqoTUZ15g%!_`sIZANU)7Eo`JBmfC;b zI-x1LL@S3DRx8Vz7dB%#nR_n({wSMqleRo9_iABETJHIhoa(wNuV6>n-P41u^X?tX X{;lTBcfgLyjFnjHj&o^L%9?)xY617t literal 0 HcmV?d00001 diff --git a/includes/aptree/img/xpexpand1.gif b/includes/aptree/img/xpexpand1.gif new file mode 100644 index 0000000000000000000000000000000000000000..58cd3c436b99ba5dda6edf3d58a4ba8d16cddaab GIT binary patch literal 1295 zcmcIj>sQhT0EGr>`6z96Dz`exI}tD^p_!pUKA?w%zz>i&Vuqn9N|I$-OD!k0q)b~c zZIyLS?d){6vz^969zXc;0}4BqOhMGO&OYqR&T3zp?SI%k_rpE+o^$V~TVA<`QK;B} z*ns#Ofxz$`**se|&x#egv3w_1;KcB3m>L^~XT^(Qycog(AP(^0gl?SBg%wO<`3`K2 zogncO#1J0v;zeFO0OA1;9&qFMPMp9=tc8iosmMnV`v`!SAo3CbkN|i{%f1*QN+6=h zmm`BI3K%1BX4lwoVn0p-;lw_i$cqI$SfLBUx8o&#e61fZf$+;EQkbwTL>^+TpD6Vc zBtD$bN|M6FS}#fBA}in=nKxGz$W_3(N;pUArl z+5kmvrzt_23Z$t)n$km+JE#f=MQ)=hCaH2eRbi(o9C^ygJe4C~?cS!G{6YiftDFTI zSAoV^s0-0GE_$7-s4>LQx{CGB3+vrQ4esIw_s%1p5}jvPBe<*4Q>F)Z>p@nNm)-2G zXz^9H`ZxxN(*|+dp?yaG{^R~?6MWDF3%Y`WQvskWSaK{}r1LOa!o`j561}(ND9AQW zvD(8dV|b78CA&SmyA@^`{H#`pZSa>HgB3=&qRr1eIbGEe;&x7PPfk^tf>j+b#}wqA z2moipwY_0k-<0g!3q}8w);wKlf;lIGyfZHk^@Ig|5uiT;oR9F&g@wISvcXy9rC$~1 z*Q!eqttF}&oIWxfJ7SqRdNm?9zm^TYk_}EPFU_dFo~g6UX)SYgLlMo;Ov7+YHxkp0 z#u~28>PF@oug4lkqfIyF^`mpm*Q3qfM4LuuTW`knH)2g68Ev_}aP0Pc%dL6C*n(j! zZWxcZk1w>1#oNZ?#=DCh_ZE+j$4&PaJ12hYe6VDiSUUM=>BE0O{QubU9)(08W)b9% zQy)KpNcw=t46bJ!=(hD_Fo@7aRgWVb^Yihw73Ktc&#FRN>kmjJs~?5K2AjKk)3*>i z>UHmen2L=#U#1kD%@I;%k9njO_V4a+y7NabKWN*#?%w|E(hc#Y{tIU;Ye+CdSv5l5 zf9jt%U`t})?qLWn{)^Fld!X{A68ZK};=U~U(Wv#}0(2!~rJ7U{GeCh&h4uCm?=$Xl zhiLF>Y>r653|l^63=#3 z|B+tWY20{t@L8*%7QG5DuV!8DEy@CEqHBg0{oEpdV)H`C-JNXFVfr(ZC|b5@Z+%%R zb~U$rb1DV(q`zQTjbyLeSQeVhyv5AtWTc_CE0U=+1&4nBVKaN}-ulv{t)c08HY&|Z zk9E;L&GY8_-yG!R{zSf$LK03!t>`dFKafnJnOCg8ASqjk8)jrDtWGR$I-U5W@Vy$H zx(2~SY)$I2A`_T5PopsQhT0EGr>zDk>&tgVjnPK2MCgl2{YsX-45fgd1m#2JRBC`p!S54D{1kTPwR z(^j*cQ*EcSo$WLp^8WDy8#YU(;A^ez!#-?hwJ*;8h~0BP+;i_a_kOyi<$LM*@^nNx z;vWP8!?R~{t(ja4R^Y<&99X^s!?j{6tr)HaFM{zR2nTv_pc^M};RH@Be;muRV=HY0 zv7aD<@Sqnj^x{De9(3bD7mnw^@g2k}n7EP(eFTw@0D1{RF9GxrKsRZ{7ePcZL=^h6 zq%cJeWB88DN-Iv}$B7}F$cGbpv7j3(aAJ5iyx5Pg^5ex2ex*bL6IO)KO|0@0C4Pd~ zhZ9&x5|~)!C5fG6Ih-Z+W-9~PayVN7XGvTXWq_iBDN2YeaZp!;!b?%Ov!&J?budR0 zpvY{1!UHHhfXV|X+*FyJDz{T)RzN;ZmD#9r8z8smD8_S?_FR=~n__&s+LNnv)iWd^vc+0QvOwXb!8(>BRDHM!3i+}8@TjX}=I z0C+A`)fJL1y+=#ynfyA6EBI*A7IrgHi2J zwD#tVc5t@tRae_3}sTK}Gr#^HtI!*h*y=ky~B z`jL74=zPoQLi5Oc^XRPJ0UGhZF0{Ofk03_7gTi5h4IN!6 z8N}8a?b{%xY-85>#Da5K0;=>8m$b_Eo*Vsq!hOqZhq4DtchQRj>pR?nAf@rHhBQyO?{(oc9A!>WnseAkzlUJ^rXd6G%Vx( zn!`!hHJs8dNfgv$Z{C0k$y&d$WMVw+E;E;%nvB{ZPoM(wi?jz18(8c1*A&NXeLgkE zLM2;h(RSd&ocQhV>%;8q?}4uqNrLf+1s(Fx4kb_k)2a=Z#3ie71N6+8HL->DXJQ}c zzf+-;)*={)t#R!ZWDMiZ8T97J;)de*kcII9I+4MMNvdf_ChxeErzzeR0+Hwh!Jo*u honcFbBn?!V60dCqtR=gOg%hk8^*1S83<`zV`5yrP9Vh?* literal 0 HcmV?d00001 diff --git a/includes/aptree/img/xpexpand3.gif b/includes/aptree/img/xpexpand3.gif new file mode 100644 index 0000000000000000000000000000000000000000..f1876f838dcd3c0b9c52d88c6687790f9be6ba1c GIT binary patch literal 1295 zcmcIj`%hB`7`-YeqRzr51Ba$M{K1NGU>IyVr%VwQ6sB=oW(<$Gs4-C|OSViiy3GyT z$cWht%I2Jp4X`|HZ{IC__uk$X=;QWji!GFv()Z)uTWZ18{SP}oedqk}os*pJJ9wz3 z>Ye5ypa>uUU}53K;^K>ig~cHT8Vq5OdMXkn2I%I;bR&ajX9^rlfqjH!8ethnSSU+i zV{pw3u8A*xDutej6^?PeN27I{ZF5$;f5sc7f#xBWnJJv4b1ihP8RT1-0*gRu7b~BQ z${k9zOQV}{ID^jVu+N{E3ncm(<{{405w3lZWd()KC%nvHW{al>StdH)E`ohr=@gx3 zeZsYjLSC-a#o${(fmNn*D%7qC)Efw4kJ)w_$3bJ;SyC?_3JfsKVogk>j*KE<0UQKH zQ$rk^Y&3D2UK zh)6X71dXe8GpN<)aE097=pf%k<2i?g(@dEUlz97@R;JVoN<1`Y=9VXU9L>W;PR2m3{9#`lvg&vb@6S9f8NF5qQf{=lLP(qoB zq>W3*qtfvRj1rImhYXlPmr=rqDXB6NFp9%yMv2L_QMEaVmaqb9k(XOEX0H@Ic_Diwj`RVZ!+MTiQq(PNa!Bq zJ3-kjUE-mOXF#c!A@Ojb08{1#r5=uQ4wOvGbeLR^2~>VQJO>*ynQ_>NBW7aEn(@u7 zC0w59Y#=e8N&~wedHe~tFBXUp{xI$fCPJ|!F`tg(sbDPWkKo~WG89k7@D!GOKL30n znM$V@7N4gV@C?b^<$nPFPi&gcS^@x0p!B85%bx&pUH~6GdiOwgPv6l$C|j>4;QW$W z@n#C;L{4!PHS1W>{=Sj?4}K(V`LLwza?`$}vOUenujg(Qbmvj)OZRuIRUW@zd%0h- ziTZ8!j#Hl`;^pMNi5B%D+`JAopw}BI{tbP6TwKsO1+`D|` z`riw0w6$%c6mNJdhkS(SrINPaDI6&O{BeKL7LIYS_dfOJ-k(yr=@_8+_zVJ9FBXV< zuNSnX3-vsta80hN+&XREBoBn zf6GjHyZOUElhR#nSI#WqG`E_r7v#HXmHWu#)O_Vd+YmEgYgn~%*m1h)1VAE-<1qNB zak_E833J?Qsj89;iYm`cUV3$`!qB1HOFCN&eL{IqMbFA=ZTqgiGXL=L`kl0^_oPK^ zH;YX9tM>AWWqV4ObyXOuuGAIg6*ttZ|Dum|kMiJbOr3kIom{>4y^fJ(OV9U|skeW1 zmgU^q*IwPZgD=)CCpF~ett!1RTfTzaxuNr6$;s6%5Q*b%IkNpCXW#e5?O6s>{Xef= zQI&M<UX2$;&!6b|mswe|qEg!#v8ZoSoV0x{8-(uluGn|Io?Wd2VCb-7lxQ3;w*2 WceC!=XJBLXs)|H+DN{s6g=t(CjR8#NBPQx($(CqFx4D5E z88Mqd*_`vS0hWjD?YpJ#-rL&(ecV26v4zr7`hMI8wT0FF4?917=lt-Ulbr9{f1tMd zz2*{92?-~WGMR<>`GrhoevpZT!YHVjjK=VOhUE#v#N<0zLMKb;7-pM?*`{GO!WP<@ zJPVU&7D%4Sz~>UBbIjn?>O2ZhHqkZUU947_b z@~k7Ek0*081vWrvldD}yje8vN1;gkQj)Ts1(m4*c%qIYY{Va<_8y9P$BXC3rg#hv7 zAlEJ*OGvd*5ftcS8kM@F7!HY`S5*qz9V)HxQVUI61AaK+9t|8GBOYR4xzCMAd^{o6gh${IXv9GTS7jsV z60)(FY%B^PIB3K`BdXMAl?ZGm)FvE4FbK&iafL3Xu@JBsSDP@%n1qm|QWukG0$K~9 zwGtXL4x2DFfzw_W?35S2YVrr{sE6VL*lIfB>3>OxesBWWrzzK5EPQX4m3w zZ)_%*oJ*y>fuzSD4@U7o1oMZI^wEWIoWSSO2`m+g6M-leNf6-#5yw&}@nY^phDfE; znfVv#43;I?yZjHN{}UVLau$(DE>ihRlb1h1%3C0P`uP2QUERG${-AEYmV^q+>LeSf z)Z=-j)wGva4!@r)tS=3cPJ6yiEeYNV?gSsny(han4 zbGMy3)eLO%YVQ^wqp4fYEM8jqQA0PSqHW)=O&ibK>woJ%{>tjtPhWpy=ZW1*m#_W3 z_-1SC7Ha9bxAQ26@E#g@>)qo1$}gVum2Bdg26`UQZtealm7k82l-9H3P|bXiq~}Ia zYr5FLhl^L`tIPJ^tH0B;rG(#ovGzjnAdTPk<}c{&RkqHm+SKKDf4HG&vYp|azxub_ zT=0Ql=x1`evo&#c5x4oI`9@KphrVMEg_4@vamhZ&3fdc1EFW^7ZaPjPQzQupc-%PE zxYvw2@3&M}O9#Z9vlEwJ9j!99>vxmSm4cs9A67GRa?Z4VcX&tP!DFko)34o^m2f<4 z3iYqLE6bMbdTU8%mGPac^~D9H4Yg~(>}B7lK0FuK@3*8l(tzVyG zyEgZ>)pTqVNc2m|4fzEt$}i4TE~9j;>v&XlVr2_R=6YHVZN0?Z^L=Ssj?sMhpVzLc z%R2HZ!Sx3e747TWlZ7i!-n{dufO0QUd@|NsAH0000ti2yZ)Yz`209w3Jl8GkM?c`Gn|4j76{ zP?cI>ky&7lS74ZDaI1}$nR`q6fvTiue`j@{{H_WE^^`J@9*;Y z05qB-G*vxMa(b4`fSJs`%jEz$p8z(T1~-rjK%)&df)z=r7($CDS+N{8V>xEFV}rbK zl+$R4#8q&iW`nmWG)Q22s8VEwPF{RUS8tN6+1ldq0WER?D{TTgk^vx54LgVsI)D>5 zbu(tVI%u~&ZM#5kyA>lk7bZR!COtGpWqG9NAt*GAso5wlIMUtk07RRA7L0Z6a`KbZkMl>s}H0Xvfc zIgkN5j{!N40X2jHG=c#zcmXhX0WWp|C}RRVl>$1E14_38Nwot=vI9u414pj|MyvuV zX9OKX3_y(#P_Yd^j14}C3L{DjBuWb-NDm@DOMuKwfXo>tI$Mj;8YMNp(d~MHivUiv z08O(1OR)eTO#(!p2voNVSGf*Vwh~*rFKxmxZo(WrX%#I_ZJE|5FFMB8@A&)w09CsH zQn&z7w*XA3C271FLv|WOcNsx)Oo!1QGfZ`(+yGz209?WVJ%9i-Zv|Yt23WCMoa81w zRytI0j=Jf&*ZJb`{{Upl0Ak1hV8#Yirx9kn7jViMcG4t!)GLD5N0s9{c(p89hBaxP zOO@YKn&Cu$xlfA5CO=pzLR){i^`XxDq|yGV)c>f_`K#0XrOWcK*Z;8C|EbLIw%h-+ z*7~{J|GVA)z25(xw$H`l|Hj=l{~^|J3RK+U)=3^8e}d|MmL+q@|`PddD`3 z*^kQqXMvf(;Q!q2|Lpev3>P3{tLSyW|9iy$mb=+pZG75onRfy zT_&0k3;+NBA^8LW00930EC2ui03QG#000R80RIUbNO0g07&2zmP)DOh!G{G8Cah5| zpFVr|?#YAq?uA2${|?TeQLfy@jP&G%!=-JN%T>HQxB&UDT)lNE-G$ROi&d*utbz(< z#mfi_n)cAi`q}D}(@#vDQX=GpQqiLz<7s=!_0v=*L0s4fRL!bUn(1GPOeun>KFVM1~V54mVs)LJS^U_^`DH zH@s16!dOk5E?`na5i=&rWha_B8?I|@LI4NUrZsVdXH6FYRj5!AAV4^`QiNi6rd>@z zfF;wUInks?0GKIMq(J%d1&ZrZg<{YDMl2x!gXqvOWy(VaOq4NdP*8}Fq08|?NdSz$ zs|rGZ3(`RIOe5=&;e{86oB{zq{TM*TeIV?YSOEwG_>40I>e0m|n0O+H1pf5nPa4M! z@_}cG+4g{d&UC|wE3a^Z$}zvFgN*_SR3OK3gnYo9Dxx(IfFu_RLrW~Ebd$_4zR&`T z5s&PU!vHFP_rW(B9I$|B(-5G*h4W-XOf<>>f@gq969I%1Oxy(o6yzo literal 0 HcmV?d00001 diff --git a/includes/aptree/img/xptitle.gif b/includes/aptree/img/xptitle.gif new file mode 100644 index 0000000000000000000000000000000000000000..962b5af8b2b57d68299794c31ecdb2f2790c8640 GIT binary patch literal 1319 zcmb_b`A^da6#w?1r6;8aJ!t8T81JJeS8sZkmX;o<0Yu$YA|cac#w_Y+p+JQqH?153 zg4}Xg5l|>{D9e@%4Q`21*)o%v#hAFcpIrGL_VUTg`@EOD_j=XX&gDKFiO4!;% zVUli$q#sH$j3pVzk_@9sh7q!Hf^3=~8^_6}ak6oYVxFX!?omt=RLeBg60>76*%|?h zsv+W9h`0t4D@1;%BmkAvLd7+4()u`QU7YkroFot@4ZzZaFljw3y&fj5gQeHOGj75& z8sM1?@bn-&BN(6A6ra@;pV=6nc@vSB8--Y(25XR-hr04W0aj3aNj8%0d#LlI;4G1d%fe#S+ z0D%_}dO;#TNLU3DRe^++AWY zR2qOvYhfAn!2cI}cUJBE0ucWN=$1eHd)Om5_w!6CfxMs4Z~k551%DbO?y(IOFP48g zn>2Q8@#?>aHMLtU2TnA4-TD0+G{M)ewm`q_`Y|l8#xlyM(rkTta_afD!rjm+0$)2^ z802Ws^z5^MbsWMiNiQy{qTYWCvx%m_PjA*2eTP9aIJ<|ocy zY$SbtF;?vH@xT1})@!63IlVmK-#%>#XP19`$KLz{*Q3Eml>@J@Dqv_f1U2Ol6mSdJ6?na>$a|rr>C_9s5B4L0@{Y3Y(5`URVQgC0>*vTzqnn3O`<(CI z)*P5eb2rGx%MNKMMUCCJXr=FqR_Wh;wrW{dcptUg1{G%!(&#!!glWFbRUq~aye6VW zP&VoNDM|1-P{6=>0h_%DAkw5KLxRmKYXM=q_$YZ7p{=-Da=EX^x^J$GjNZRMoKz>R z6u-~F6n+OSD_vu{E89|Fj$H^r>=w~2=(29@R>oYM&IAEr%rTLm;?!hOW6CbT z$b^9ohB3qeI#EANMTy1_a|$9^!n&2wwcUEZU*BHe-?hH`?7!eS$&)AN%X!Z8>P8k9w0V%#4PAch^dWZuyZk5+A^tFq#7H=b z=ZrvW1ak&%-oz7bVHwPuc;p_g0NpBbi)OHB=JZzh$O80MV6ed@D=^xj!3InYXtV>f z3#~Yz*#)g0WN|~g7didd;X`&WbOo@}j~qVe31W8uc|+I}L_wAWBG?~Bp(qKmIGUhr zoJ3+cmZZ@HNpduiA_%7;qFNI-&ucIP9WTQImYvY#0A@E@;g9kns|VVB$hNu#`6I*^ z#@-MLu*4t1;TQ=;aSG5RM;v|>jFJG0BXJVuJx|eClCTL9iQ@!E<0%4An&Y!0X@n_2 zGzBTdl+ZLL6cIkjH07H|N}2!bKMrhPovi)>BT6%>^#Y-pK5B~U3c_1 z$F!nUb;34U(tcApBz{{z#j@(Z&SxJJvo#9?3Q={}{WIFCp3Lzbuht#U=>GG;Cy#yj zedn*es&)B=FMip2<=V-ig@U$my`sNNbumxX@rArgppup-#V|6{S;$*pYLcWbXA(RT5>$_`0YL*{Ym;}y#6XFGqLLGdd$ QHEYC8Qg%$5k-_Zx7wsvH{r~^~ literal 0 HcmV?d00001 diff --git a/includes/aptree/img/xptitleleft.gif b/includes/aptree/img/xptitleleft.gif new file mode 100644 index 0000000000000000000000000000000000000000..d727c0255ce24e7465d04a12f78a42ecf66c2a4a GIT binary patch literal 52 zcmZ?wbhEHbWMPnGXkcLY4+e@qSr{1@7#VaJfB+=Jz{Kst(0=+Y|Kd4YHZd_+0|1(U B4>AA% literal 0 HcmV?d00001 diff --git a/includes/aptree/img/xpvertline.gif b/includes/aptree/img/xpvertline.gif new file mode 100644 index 0000000000000000000000000000000000000000..6000f7f0c85bb07bf33efe25a2e9395a03b94b4c GIT binary patch literal 600 zcmZ?wbhEHbWMn8}e8#{~Jmq2Ow8y2>AD2vhR5I;R$<&8s)1Q>hcv3p;QN^rh*sW>mS3Q0XiU;fZ~FIeQ!fxQ*%peTYE=mS9ecuUw^mH zBp<)2)27ex^>v>UFmIm!LVu4XUS6InRyeHoUhD1TxY2pD^;T?|$K z%AyrHFiTUA9zNA01y!V`H7B}GML8R@rjvL9q6KZ^-T zNr{UKOGt=_@bYSLta)(YU~@CSkVcOHV^dQ*zqp5u!^eikZXOAa8#@dejx%sLDJeK4 aG@P8Q5zMD?U=u^bbc5tmb0m!g7_0$4vGddb literal 0 HcmV?d00001 diff --git a/includes/aptree/tmenu1.js b/includes/aptree/tmenu1.js new file mode 100644 index 00000000..555d36ce --- /dev/null +++ b/includes/aptree/tmenu1.js @@ -0,0 +1,172 @@ +//****************************************************************************** +// ------ Apycom.com Tree-menu Data -------------------------------------------- +//****************************************************************************** +var tblankImage = "img/blank.gif"; +var tfontStyle = "normal 8pt Tahoma"; +var tfontColor = ["#000000","#000088"]; +var tfontDecoration = ["none","underline"]; + +var titemBackColor = ["#CCCCCC","#CCCCCC"]; +var titemAlign = "left"; +var titemBackImage = ["",""]; +var titemCursor = "default"; +var titemHeight = 20; + +var tmenuBackImage = ""; +var tmenuBackColor = ""; +var tmenuBorderColor = "#FFFFFF"; +var tmenuBorderStyle = "dotted"; +var tmenuBorderWidth = 1; +var tmenuWidth = ""; +var tmenuHeight = ""; + +var titemTarget = "_blank"; +var ticonWidth = 16; +var ticonHeight = 16; +var ticonAlign = "left"; + +var texpandBtn =["img/expandbtn2.gif","img/expandbtn2.gif","img/collapsebtn2.gif"]; +var texpandBtnW = 9; +var texpandBtnH = 9; +var texpandBtnAlign = "left"; + +var tpoints = 1; +var tpointsImage = "img/vpoint.gif"; +var tpointsVImage = "img/hpoint.gif"; +var tpointsCImage = "img/cpoint.gif"; + +var tmoveable = 0; +var tmoveImage = "img/movepic.gif"; +var tabsolute = 0; +var tleft = 20; +var ttop = 120; + +var tfloatable = 0; +var tfloatIterations = 6; + +// XP-Style Parameters +var tXPStyle = 0; +var tXPIterations = 0; // expand/collapse speed +var tXPTitleTopBackColor = ""; +var tXPTitleBackColor = ""; +var tXPTitleLeft = ""; +var tXPExpandBtn = []; +var tXPBtnHeight = 0; +var tXPTitleBackImg = ""; + +var tstyles = +[ + +]; + +var tmenuItems = +[ + ["Item 1", "testlink.htm", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 4", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 4", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 4", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 4", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|||SubItem 1","", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 5", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 4", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 6", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 1", "testlink.htm", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 4", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 4", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 4", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 4", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|||SubItem 1","", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 5", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["|SubItem 4", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 1", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 2", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["||SubItem 3", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], + ["Item 6", "", "img/icons/folder1.gif","img/icons/folder1.gif","img/icons/folder2.gif"], +]; + + diff --git a/includes/aptree/tstyles.css b/includes/aptree/tstyles.css new file mode 100644 index 00000000..adf4213d --- /dev/null +++ b/includes/aptree/tstyles.css @@ -0,0 +1,50 @@ +.TreeMenuTitle {color: #888888; font: 18px Arial; font-weight: 600} + +.XPBlueTopBack {background-color: #6375D6} +.XPBlueMainBack {background-color: #6375D6; background-image: url(img/xpback.gif); background-repeat: no-repeat} +.XPBlueMenuBack {background-color: #7AA1E6; color: #FFFFFF; font: 10px Arial; font-weight: bold;} +.XPBlueHorLine {background-color: #C5DFFF} +.XPBlueExTitle {color: #D6DFF5; font: 16px Arial; font-weight: bold;} +.XPBlueText {color: #FFFFFF; font: 11px Verdana; background-image: url();} +.XPBlueTitle {color: #D6DFF5; font: 20px Arial; font-weight: bold; background-image: url();} + +.Text {color: #222222; font: 11px Verdana; background-image: url();} +.MainBack {background-color: #FFFFFF; color: #222222; font: 10px Arial; font-weight: bold} +.MenuBack {background-color: #CCCCCC; color: #FFFFFF; font: 10px Arial; font-weight: bold} +.TopBack {background-color: #FFFFFF} +.ExTitle {color: #999999; font: 16px Arial; font-weight: bold} + +.ParamTitle {color: #222222; font: 16px Arial; font-weight: bold} +.ParamBack {background-color: #FFFFFF; font: 11px Verdana; font: 11px Verdana;} +.ParamTbl {color: #333333; font: 11px Verdana; font: 11px Verdana;} +.ParamTblTitle {background-color: #CEE9F2; color: #444444; font: 11px Verdana; font-weight: bold;} +.ParamTblCell {background-color: #ECF7F9; font: 11px Verdana; color: #222222;} + + +.StyleNameW {color: #FFFFFF; font: 11px MS Sans Serif; font-weight: bold} +.StyleNameB {color: #000000; font: 11px MS Sans Serif; font-weight: bold} + +A.White:link {font: 11px Verdana; color: #B5EDFF; text-decoration: none;} +A.White:hover {font: 11px Verdana; color: #FFFFFF; text-decoration: underline;} +A.White:visited {font: 11px Verdana; color: #D3CCFF; text-decoration: none;} +A.White:visited:hover {font: 11px Verdana; color: #FFFFFF; text-decoration: underline;} + +A.Dark:link {font: 11px Verdana; color: #3333DD; text-decoration: none;} +A.Dark:hover {font: 11px Verdana; color: #5555FF; text-decoration: underline;} +A.Dark:visited {font: 11px Verdana; color: #5555CC; text-decoration: none;} +A.Dark:visited:hover {font: 11px Verdana; color: #5555FF; text-decoration: underline;} + +A.Black:link {font: 11px Verdana; color: #FFFFFF; text-decoration: none;} +A.Black:hover {font: 11px Verdana; color: #FFFFFF; text-decoration: underline;} +A.Black:visited {font: 11px Verdana; color: #F3F3F3; text-decoration: none;} +A.Black:visited:hover {font: 11px Verdana; color: #FFFFFF; text-decoration: underline;} + +A.MenuLink:link {font: 10px Arial; color: #FFFFFF; text-decoration: none; font-weight: bold;} +A.MenuLink:hover {font: 10px Arial; color: #FFFFFF; text-decoration: none; font-weight: bold;} +A.MenuLink:visited {font: 10px Arial; color: #FFFFFF; text-decoration: none; font-weight: bold;} + +.MenuTable {border-width: 0;} +.MenuItem {border-width: 1; background-color: #628FE2; border-style: solid; border-color: #A0C0FF; color: #FFFFFF} +.MenuItemOver {border-width: 1; background-color: #285BA5; border-style: solid; border-color: #FFFFFF; color: #000000; cursor: hand} + + \ No newline at end of file diff --git a/includes/aptree/txpmenu-item-visibility.js b/includes/aptree/txpmenu-item-visibility.js new file mode 100644 index 00000000..c14133b9 --- /dev/null +++ b/includes/aptree/txpmenu-item-visibility.js @@ -0,0 +1,106 @@ +//****************************************************************************** +// ------ Apycom.com Tree-menu Data -------------------------------------------- +//****************************************************************************** +var tlevelDX = 10; + +var tblankImage = "img/blank.gif"; +var tfontStyle = "normal 8pt Tahoma"; +var tfontColor = ["#3F3D3D","#7E7C7C"]; +var tfontDecoration = ["none","underline"]; + +var titemBackColor = ["#F0F1F5","#F0F1F5"]; +var titemAlign = "left"; +var titemBackImage = ["",""]; +var titemCursor = "hand"; +var titemHeight = 22; + +var tmenuBackImage = ""; +var tmenuBackColor = ""; +var tmenuBorderColor = "#FFFFFF"; +var tmenuBorderStyle = "solid"; +var tmenuBorderWidth = 0; +var tmenuWidth = 230; +var tmenuHeight = 500; + +var titemTarget = "_blank"; +var ticonWidth = 16; +var ticonHeight = 16; +var ticonAlign = "center"; + +var texpanded = 1; +var texpandBtn =["img/expandbtn2.gif","img/expandbtn2.gif","img/collapsebtn2.gif"]; +var texpandBtnW = 9; +var texpandBtnH = 9; +var texpandBtnAlign = "left" + +var tpoints = 0; +var tpointsImage = ""; +var tpointsVImage = ""; +var tpointsCImage = ""; + +var tmoveable = 1; +var tmoveImage = "img/movepic.gif"; +var tmoveImageHeight = 12; +var tabsolute = 1; +var tleft = 20; +var ttop = 120; + +var tfloatable = 0; +var tfloatIterations = 6; + +// XP-Style Parameters +var tXPStyle = 1; +var tXPIterations = 5; // expand/collapse speed +var tXPTitleTopBackColor = ""; +var tXPTitleBackColor = "#57C34A"; +var tXPTitleLeft = "img/xptitleleft_green.gif"; +var tXPExpandBtn = ["img/xpexpand1_green.gif","img/xpexpand1_green.gif","img/xpcollapse1_green.gif","img/xpcollapse1_green.gif"]; +var tXPBtnHeight = 25; +var tXPTitleBackImg = "img/xptitle_green.gif"; + +var tstyles = +[ + ["tfontStyle=bold 8pt Tahoma","tfontColor=#FFFFFF,#D2FCD5", + "tfontDecoration=none,none"], + ["tfontStyle=bold 8pt Tahoma","tfontColor=#3F3D3D,#659669", + "tfontDecoration=none,none"], + ["tfontDecoration=none,none"], + ["tfontStyle=bold 8pt Tahoma","tfontColor=#444444,#5555FF"], +]; + +var tXPStyles = +[ + ["tXPTitleBackColor=#DEF3DB", + "tXPExpandBtn=img/xpexpand2_green.gif,img/xpexpand2_green.gif,img/xpcollapse2_green.gif,img/xpcollapse2_green.gif", "tXPTitleBackImg=img/xptitle2_green.gif"] +]; + +var tmenuItems = +[ + ["1st submenu", "", "img/xpicon_green.gif","","", "Main Page",,"0"], + ["|This menu has 7 items.
3rd and 6th are hidden.", "", "img/icons/info.gif"], + ["|Item 1", "testlink.htm", "img/icons/support.gif"], + ["|Item 2", "testlink.htm", "img/icons/support.gif"], + ["#|Item 3", "testlink.htm", "img/icons/support.gif"], + ["|Item 4", "testlink.htm", "img/icons/support.gif"], + ["|Item 5", "testlink.htm", "img/icons/support.gif"], + ["#|Item 6", "testlink.htm", "img/icons/support.gif"], + ["|Item 7", "testlink.htm", "img/icons/support.gif"], + + ["#2nd submenu", "", "", "","","",,"1","0"], + ["|This is the second submenu.
Also you can hide even a submenu title like here."], + + ["3rd submenu", "", "img/xpicon_green.gif","","", "Main Page",,"0"], + ["|This submenu has 3 levels.
But 3rd level items are hidden.", "", "img/icons/info.gif"], + ["|1st level item", "testlink.htm", "img/icons/support.gif"], + ["||2nd level item", "testlink.htm", "img/icons/support.gif"], + ["#||| 3rd level item 1", "testlink.htm", "img/icons/support.gif"], + ["#||| 3rd level item 2", "testlink.htm", "img/icons/support.gif"], + ["|1st level item", "testlink.htm", "img/icons/support.gif"], + ["||2nd level item", "testlink.htm", "img/icons/support.gif"], + ["#||| 3rd level item 1", "testlink.htm", "img/icons/support.gif"], + ["#||| 3rd level item 2", "testlink.htm", "img/icons/support.gif"], + ["#||| 3rd level item 3", "testlink.htm", "img/icons/support.gif"], + ["#||| 3rd level item 4", "testlink.htm", "img/icons/support.gif"], +]; + +apy_tmenuInit(); diff --git a/includes/aptree/txpmenu1.js b/includes/aptree/txpmenu1.js new file mode 100644 index 00000000..a6f346f5 --- /dev/null +++ b/includes/aptree/txpmenu1.js @@ -0,0 +1,104 @@ +var tabsolute = 1; +var tLeft = 10; +var tTop = 10; + +//****************************************************************************** +// ------ Apycom.com Tree-menu Data -------------------------------------------- +//****************************************************************************** +var tblankImage = "includes/aptree/img/blank.gif"; +var tmenuWidth = 230; +var tmenuHeight = 400; + +var tabsolute = 1; +var tleft = 20; +var ttop = 120; + +var tfloatable = 1; +var tfloatIterations = 6; +var tmoveable = 0; +var tmoveImage = "includes/aptree/img/movepic.gif"; +var tmoveImageHeight = 12; + +var tfontStyle = "normal 8pt Tahoma"; +var tfontColor = ["#215DC6","#428EFF"]; +var tfontDecoration = ["none","underline"]; + +var titemBackColor = ["#D6DFF7","#D6DFF7"]; +var titemAlign = "left"; +var titemBackImage = ["",""]; +var titemCursor = "hand"; +var titemHeight = 22; + +var titemTarget = "_blank"; +var ticonWidth = 16; +var ticonHeight = 16; +var ticonAlign = "left"; + +var tmenuBackImage = ""; +var tmenuBackColor = ""; +var tmenuBorderColor = "#FFFFFF"; +var tmenuBorderStyle = "solid"; +var tmenuBorderWidth = 0; + +var texpandBtn =["includes/aptree/img/expandbtn2.gif","includes/aptree/img/expandbtn2.gif","includes/aptree/img/collapsebtn2.gif"]; +var texpandBtnW = 9; +var texpandBtnH = 9; +var texpandBtnAlign = "left" + +var texpanded = 1; + +var tpoints = 0; +var tpointsImage = ""; +var tpointsVImage = ""; +var tpointsCImage = ""; + +// XP-Style Parameters +var tXPStyle = 1; +var tXPIterations = 5; // expand/collapse speed +var tXPTitleTopBackColor = ""; +var tXPTitleBackColor = "#265BCC"; +var tXPTitleLeft = "img/xptitleleft.gif"; +var tXPExpandBtn = ["img/xpexpand1.gif","img/xpexpand2.gif","img/xpcollapse1.gif","img/xpcollapse2.gif"]; +var tXPBtnHeight = 25; +var tXPTitleBackImg = "img/xptitle.gif"; + +var tstyles = +[ + ["tfontStyle=bold 8pt Tahoma","titemBackColor=#265BCC,#265BCC","tfontColor=#FFFFFF,#428EFF", "tfontDecoration=none,none"], + ["tfontStyle=bold 8pt Tahoma","titemBackColor=#265BCC,#265BCC","tfontColor=#215DC6,#428EFF", "tfontDecoration=none,none"], + ["tfontDecoration=none,none"], + ["tfontStyle=bold 8pt Tahoma","tfontColor=#444444,#5555FF"], +]; + +var tXPStyles = +[ + ["tXPTitleBackColor=#D0DAF8", "tXPExpandBtn=img/xpexpand3.gif,img/xpexpand4.gif,img/xpcollapse3.gif,img/xpcollapse4.gif", "tXPTitleBackImg=img/xptitle2.gif"] +]; + +var tmenuItems = +[ + ["XP-style Title with Icon", "", "img/xpicon1.gif","","", "Main Page",,"0"], + ["|Information", "testlink.htm", "img/icons/info.gif", "", "", "Information","_blank"], + ["|Support", "", "img/icons/support.gif", "", "", "Support",, "2"], + ["||Contacts", "mailto:support@apycom.com", "img/icons/contacts.gif", "", "", "Contacts"], + ["||E-mail", "mailto:support@apycom.com", "img/icons/email.gif", "", "", "E-mail"], + + ["|Help", "", "img/icons/help1.gif", "img/icons/help1.gif", "img/icons/help2.gif", "Help",,"2"], + ["||Glossary", "testlink.htm", "img/icons/paper.gif", "", "", "Glossary"], + ["||Index", "testlink.htm", "img/icons/paper.gif", "", "", "Index"], + ["|| ", + "", "img/icons/search.gif", "", "", "Search",,"2"], + + ["||Contents: ", + "", "img/icons/list.gif", "", "", "Contents",,"2"], + + ["XP-style Title without Icon", "", "", "","","Download software",,"1","0"], + ["|Item without icon", "testlink.htm", ,,, "Item 1 Hint"], + ["|Item with individual style", "", ,,, "Item 2 Hint",,"3"], + ["||SubItem 1", "testlink.htm", "img/icons/help1.gif", "","", "SubItem 1 Hint"], + ["||SubItem 2", "testlink.htm", "img/icons/help1.gif", "","", "SubItem 1 Hint"], + ["|||SubItem 2_1", "testlink.htm", ,,, "SubItem 1_2 Hint"], + +]; + +apy_tmenuInit(); diff --git a/includes/aptree/txpmenu3.js b/includes/aptree/txpmenu3.js new file mode 100644 index 00000000..a976580a --- /dev/null +++ b/includes/aptree/txpmenu3.js @@ -0,0 +1,98 @@ +//****************************************************************************** +// ------ Apycom.com Tree-menu Data -------------------------------------------- +//****************************************************************************** +var tblankImage = "img/blank.gif"; +var tfontStyle = "normal 8pt Tahoma"; +var tfontColor = ["#3F3D3D","#7E7C7C"]; +var tfontDecoration = ["none","underline"]; + +var titemBackColor = ["#F6F6EC","#F6F6EC"]; +var titemAlign = "left"; +var titemBackImage = ["",""]; +var titemCursor = "hand"; +var titemHeight = 22; + +var tmenuBackImage = ""; +var tmenuBackColor = ""; +var tmenuBorderColor = "#FFFFFF"; +var tmenuBorderStyle = "solid"; +var tmenuBorderWidth = 0; +var tmenuWidth = 230; +var tmenuHeight = 400; + +var titemTarget = "_blank"; +var ticonWidth = 16; +var ticonHeight = 16; +var ticonAlign = "left"; + +var texpandBtn =["img/expandbtn2.gif","img/expandbtn2.gif","img/collapsebtn2.gif"]; +var texpandBtnW = 9; +var texpandBtnH = 9; +var texpandBtnAlign = "left" + +var texpanded = 0; + +var tpoints = 0; +var tpointsImage = ""; +var tpointsVImage = ""; +var tpointsCImage = ""; + +var tabsolute = 1; +var tmoveable = 0; +var tmoveImage = "img/movepic.gif"; +var tleft = 20; +var ttop = 120; + +var tfloatable = 1; +var tfloatIterations = 6; + +// XP-Style Parameters +var tXPStyle = 1; +var tXPIterations = 10; // expand/collapse speed +var tXPTitleTopBackColor = ""; +var tXPTitleBackColor = "#94A664"; +var tXPTitleLeft = "img/xptitleleft_o.gif"; +var tXPExpandBtn = ["img/xpexpand1_o.gif","img/xpexpand2_o.gif","img/xpcollapse1_o.gif","img/xpcollapse2_o.gif"]; +var tXPBtnHeight = 23; +var tXPTitleBackImg = "img/xptitle_o.gif"; + +var tstyles = +[ + ["tfontStyle=bold 8pt Tahoma","tfontColor=#FFFFFF,#E0E7B8", + "tfontDecoration=none,none"], + ["tfontStyle=bold 8pt Tahoma","tfontColor=#56662D,#72921D", + "tfontDecoration=none,none"], + ["tfontDecoration=none,none"], + ["tfontStyle=bold 8pt Tahoma","tfontColor=#444444,#5555FF"], +]; + +var tXPStyles = +[ + ["tXPTitleBackColor=#E2E9BC", + "tXPExpandBtn=img/xpexpand3_o.gif,img/xpexpand4_o.gif,img/xpcollapse3_o.gif,img/xpcollapse4_o.gif", "tXPTitleBackImg=img/xptitle2_o.gif"] +]; + +var tmenuItems = +[ + ["+XP-style Title with Icon", "", "img/xpicon1_o.gif", "", "", "Main Page",,"0"], + ["|Information", "testlink.htm", "img/icons/info.gif", "", "", "Information","_blank"], + ["|Support", "", "img/icons/support.gif", "", "", "Support",, "2"], + ["||Contacts", "mailto:support@apycom.com", "img/icons/contacts.gif", "", "", "Contacts"], + ["||E-mail", "mailto:support@apycom.com", "img/icons/email.gif", "", "", "E-mail"], + + ["|Help", "", "img/icons/help1.gif", "img/icons/help1.gif", "img/icons/help2.gif", "Help",,"2"], + ["||Glossary", "testlink.htm", "img/icons/paper.gif", "", "", "Glossary"], + ["||Index", "testlink.htm", "img/icons/paper.gif", "", "", "Index"], + ["|| ", "", "img/icons/search.gif", "", "", "Search",,"2"], + + ["||Contents: ", "", "img/icons/list.gif", "", "", "Contents",,"2"], + + ["+XP-style Title without Icon", "", "", "", "", "Download software",,"1","0"], + ["|Item without icon", "testlink.htm", "", "", "", "Item 1 Hint"], + ["|Item with individual style", "", "", "", "", "Item 2 Hint",,"3"], + ["||SubItem 1", "testlink.htm", "img/icons/help1.gif", "", "", "SubItem 1 Hint"], + ["||SubItem 2", "testlink.htm", "img/icons/help1.gif", "", "", "SubItem 1 Hint"], + ["|||SubItem 2_1", "testlink.htm", "", "", "", "SubItem 1_2 Hint"], + +]; + diff --git a/includes/cron/cron.inc.php b/includes/cron/cron.inc.php new file mode 100644 index 00000000..dd425f1e --- /dev/null +++ b/includes/cron/cron.inc.php @@ -0,0 +1,221 @@ + ** +** Project home..: http://klaus_p.pieper.bei.t-online.de/ ** +** Filename......: class.cron.inc ** +** Copyright(C)..: 2002 Klaus P. Pieper ** +** Last changed..: 12 August 2002 ** +** License.......: GNU Lesser General Public License (see below) ** +** ** +** This library is free software; you can redistribute it and/or ** +** modify it under the terms of the GNU Lesser General Public ** +** License as published by the Free Software Foundation; either ** +** version 2.1 of the License, or (at your option) any later version. ** +** ** +** This library is distributed in the hope that it will be useful, ** +** but WITHOUT ANY WARRANTY; without even the implied warranty of ** +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** +** Lesser General Public License for more details. ** + ** +** You should have received a copy of the GNU Lesser General Public ** +** License along with this library; if not, write to the Free Software ** +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ** +*******************************************************************************/ + +/******************************************************************************* +** Version history: +** 0.2.7: 08-Aug-2002: yet another minor bug fix in the decision logic +** 0.2.7: 08-Aug-2002: another minor bug fix in the decision logic +** 0.2.6: 29-Jul-2002: minor bug fix in the decision logic +** 0.2.5: 26-Jul-2002: decision logic in procedure due completely +** re-written, carry over principle omitted +** 0.2.4: 25-Jul-2002: more minor bug in carry over procedure +** 0.2.3: 25-Jul-2002: minor bug fixes, +** - specifying weekdays +** - carry over flag added +** - arCFOffset added for the carry over function +** 0.2.2: 18-Jul-2002: added FALSE return for $tLast == NULL +** 0.2.1: 15-Jul-2002: first published version +*******************************************************************************/ + +class cron { + + // this is the heart of the class + // $tLast: last time at which the command was completed + // $tNow: the reference time, usually the current time stamp + // $sSpec: the specifier in the usual crontab format + // returns TRUE if a timestamp exists between $tLast and $tNow + // fulfilling the $sSpec criteria. + // returns FALSE otherwise + + function due($tLast, $tNow, $sSpec) + { + + // this array describes the classic crontab format + // for internal use the elements are listed in reverse order + $arSeg = array("wday", "mon", + "mday", "hours", + "minutes"); + // alternate crontab format includes year + // this format is internally not (yet) supported!!! + /* $arSeg = array("year", "wday", + "mon", "mday", + "hours", "minutes"); + */ + + // this array contains the offset in case for the carry over status + // see below for the determination of the carry over status + $arPeriod = array("wday" => 7, + "mon" => 12, + "mday" => + array(31, 28, 31, 30, 31, 30, + 31, 31, 30, 31, 30, 31), + "hours" => 24, + "minutes" => 60); + + $arTime = array("wday" => 604800, // 7 * 24 * 60 * 60 + "mon" => 31536000, // 365 * 24 * 60 * 60 + "mday" => + array(31 * 86400, // 31 * 24 * 60 * 60 + 28 * 86400, + 31 * 86400, + 30 * 86400, + 31 * 86400, + 30 * 86400, + 31 * 86400, + 31 * 86400, + 30 * 86400, + 31 * 86400, + 30 * 86400, + 31 * 86400), + "hours" => 86400, // 24 * 60 * 60 + "minutes" => 3600); // 60 * 60 + + + $iSeg = 0; // segment index + $iCmpVal = 0; // compare value + + // these lines added in 0.2.5 + $bStatus = FALSE; // procedure status + $iPFaktor = 0; // period factor + $iTFaktor = 0; // time factor + + if ($tNow == NULL) $tNow = time(); + // this line added in version 0.2.2 + if ($tLast == NULL) return FALSE; + + // convert strings to time + if (is_string($tLast)) $tLast = strtotime($tLast); + if (is_string($tNow)) $tNow = strtotime($tNow); + + if ($tNow < $tLast) return FALSE; + + // convert time variables to arrays + $arLast = getdate($tLast); + $arNow = getdate($tNow); + $arSpec = array_reverse(explode(" ", $sSpec)); + + // walk through segments of crontab specifier + for ($iSeg = 0; $iSeg < count($arSeg); $iSeg ++) { + // obtain segment key + $sSeg = $arSeg[$iSeg]; + // does specifier segment contain '*'? + if (strstr($arSpec[$iSeg], "*") != FALSE) { + // week days need special treatment + if ($sSeg == "wday") $iCmpVal = $arLast[$sSeg]; + // use same segment of time reference + else $iCmpVal = $arNow[$sSeg]; + // specifier segment contains specific criteria + } else { + // get reference value + $iCmpVal = cron::_nextLowerVal($arSpec[$iSeg], $arNow[$sSeg]); + } /* endif */ + + // this section completely changed in 0.2.5 + // obtain period factor + $iPFactor = $arPeriod[$sSeg]; + // numbers of days per month are always different ... + if ($sSeg == "mday") + @$iPFactor = $iPFactor[$arLast["mon"]]; + + // obtain period time factor + $iTFactor = $arTime[$sSeg]; + // numbers of days per month are always different ... + if ($sSeg == "mday") + @$iTFactor = $iTFactor[$arLast["mon"]]; + + // this is the decisive part of the function: + if ($arLast[$sSeg] < $iCmpVal && + $iCmpVal <= $arNow[$sSeg]) + { $bStatus = TRUE; } + + if (strstr($arSpec[$iSeg], "*") == FALSE) { + // next two lines changed in 0.2.7 + if ((($bStatus == TRUE && $arNow[$sSeg] == $arLast[$sSeg]) || + $arNow[$sSeg] < $arLast[$sSeg]) && + $arLast[$sSeg] < $iCmpVal + $iPFactor && + $iCmpVal + $iPFactor <= $arNow[$sSeg] + $iPFactor && + $iCmpVal >= 0) + { $bStatus = TRUE; } + else if ($tNow > $tLast + $iTFactor) + { $bStatus = TRUE; } + // note that this condition causes a premature return: + else if ($arLast[$sSeg] > $iCmpVal) + { return FALSE; } + else if ($iCmpVal < $arNow[$sSeg] && $iCmpVal == $arLast[$sSeg] ) + { return FALSE; } + } /* endif */ + // end of section + + } /* endfor */ + + return $bStatus; + } + + // this function determines the highest number specified in the + // crontab segment but smaller than the reference + // $sSpec: segment of crontab specifier + // $iRef: the reference number + // returns the number as described above, -1 if no number was found + function _nextLowerVal($sSpec, $iRef) + { + $arSpec1 = explode(",", $sSpec); // divide segment into details + $arInt = array(); // array of potential integers + $arSpec2 = array(); // array of details if + // specified as range + $i = 0; + $sEl = ""; + + // walk through list of details + foreach($arSpec1 as $sEl) { + // specified as range? + if(strchr($sEl, "-") != FALSE) { + // split again + $arSpec2 = explode("-", $sEl); + // add all numbers within range to list of integers + for ($i = $arSpec2[0]; $i <= $arSpec2[1]; $i ++) + array_push($arInt, $i); + } else { // not a range, add directly to list of integers + array_push($arInt, $sEl); + } /* endif */ + } /* endfor */ + + // sort reverse, highest number is now 1st element + rsort($arInt); + // walk backwards through list + foreach($arInt as $iEl) { + // if element is smaller than reference, return element + if ($iEl <= $iRef) return $iEl; + } /* endfor */ + + // no element found + return -1; + } + +} /* end of class definition */ + +?> \ No newline at end of file diff --git a/includes/cron/lgpl.txt b/includes/cron/lgpl.txt new file mode 100644 index 00000000..b1e3f5a2 --- /dev/null +++ b/includes/cron/lgpl.txt @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/includes/files/.htaccess b/includes/files/.htaccess new file mode 100644 index 00000000..4bce4876 --- /dev/null +++ b/includes/files/.htaccess @@ -0,0 +1,7 @@ + + order deny,allow + deny from all + allow from localhost + allow from 127.0.0.1 + satisfy any + diff --git a/includes/files/reports/.htaccess b/includes/files/reports/.htaccess new file mode 100644 index 00000000..558d8ef9 --- /dev/null +++ b/includes/files/reports/.htaccess @@ -0,0 +1,5 @@ + + order deny,allow + allow from all + satisfy any + \ No newline at end of file diff --git a/includes/files/tracking.txt b/includes/files/tracking.txt new file mode 100644 index 00000000..e69de29b diff --git a/includes/javascript/MIT-LICENSE b/includes/javascript/MIT-LICENSE new file mode 100644 index 00000000..36af55c2 --- /dev/null +++ b/includes/javascript/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/includes/javascript/controls.js b/includes/javascript/controls.js new file mode 100644 index 00000000..664b62a0 --- /dev/null +++ b/includes/javascript/controls.js @@ -0,0 +1,265 @@ +// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +Element.collectTextNodesIgnoreClass = function(element, ignoreclass1, ignoreclass2) { + var children = $(element).childNodes; + var text = ""; + + var classtest1 = new RegExp("^([^ ]+ )*" + ignoreclass1+ "( [^ ]+)*$","i"); // agileco mod + var classtest2 = new RegExp("^([^ ]+ )*" + ignoreclass2+ "( [^ ]+)*$","i"); // agileco add + + for (var i = 0; i < children.length; i++) { + if(children[i].nodeType==3) { + text+=children[i].nodeValue; + } else { + if((!children[i].className.match(classtest1)) && (!children[i].className.match(classtest2)) && children[i].hasChildNodes()) // agileco mod + text += Element.collectTextNodesIgnoreClass(children[i], ignoreclass1, ignoreclass2); + } + } + return text; +} + +Ajax.Autocompleter = Class.create(); +Ajax.Autocompleter.prototype = (new Ajax.Base()).extend({ + initialize: function(element, update, url, options) { + this.element = $(element); + this.hidden = element+'_hidden'; //agileco add + this.update = $(update); + this.has_focus = false; + this.changed = false; + this.active = false; + this.index = 0; + this.entry_count = 0; + this.url = url; + + this.setOptions(options); + this.options.asynchronous = true; + this.options.onComplete = this.onComplete.bind(this) + this.options.frequency = this.options.frequency || 0.4; + this.options.min_chars = this.options.min_chars || 1; + this.options.method = 'post'; + + this.options.onShow = this.options.onShow || + function(element, update){ + if(!update.style.position || update.style.position=='absolute') { + update.style.position = 'absolute'; + var offsets = Position.cumulativeOffset(element); + update.style.left = offsets[0] + 'px'; + update.style.top = (offsets[1] + element.offsetHeight) + 'px'; + update.style.width = element.offsetWidth + 'px'; + } + new Effect.Appear(update,{duration:0.3}); + }; + this.options.onHide = this.options.onHide || + function(element, update){ new Effect.Fade(update,{duration:0.3}) }; + + + if(this.options.indicator) + this.indicator = $(this.options.indicator); + + this.observer = null; + + Element.hide(this.update); + + Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this)); + Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this)); + }, + + show: function() { + if(this.update.style.display=='none') this.options.onShow(this.element, this.update); + if(!this.iefix && (navigator.appVersion.indexOf('MSIE')>0) && this.update.style.position=='absolute') { + new Insertion.After(this.update, + ''); + this.iefix = $(this.update.id+'_iefix'); + } + if(this.iefix) { + Position.clone(this.update, this.iefix); + this.iefix.style.zIndex = 1; + this.update.style.zIndex = 2; + Element.show(this.iefix); + } + }, + + hide: function() { + if(this.update.style.display=='') this.options.onHide(this.element, this.update); + if(this.iefix) Element.hide(this.iefix); + }, + + startIndicator: function() { + if(this.indicator) Element.show(this.indicator); + }, + + stopIndicator: function() { + if(this.indicator) Element.hide(this.indicator); + }, + + onObserverEvent: function() { + this.changed = false; + if(this.element.value.length>=this.options.min_chars) { + this.startIndicator(); + this.options.parameters = this.options.callback ? + this.options.callback(this.element, Form.Element.getValue(this.element)) : + Form.Element.serialize(this.element); + new Ajax.Request(this.url, this.options); + } else { + this.active = false; + this.hide(); + } + }, + + addObservers: function(element) { + Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this)); + Event.observe(element, "click", this.onClick.bindAsEventListener(this)); + }, + + onComplete: function(request) { + if(!this.changed && this.has_focus) { + this.update.innerHTML = request.responseText; + Element.cleanWhitespace(this.update); + Element.cleanWhitespace(this.update.firstChild); + + if(this.update.firstChild && this.update.firstChild.childNodes) { + this.entry_count = + this.update.firstChild.childNodes.length; + for (var i = 0; i < this.entry_count; i++) { + entry = this.get_entry(i); + entry.autocompleteIndex = i; + this.addObservers(entry); + } + } else { + this.entry_count = 0; + } + + this.stopIndicator(); + + this.index = 0; + this.render(); + } + }, + + onKeyPress: function(event) { + if(this.active) + switch(event.keyCode) { + case Event.KEY_TAB: + case Event.KEY_RETURN: + this.select_entry(); + Event.stop(event); + case Event.KEY_ESC: + this.hide(); + this.active = false; + return; + case Event.KEY_LEFT: + case Event.KEY_RIGHT: + return; + case Event.KEY_UP: + this.mark_previous(); + this.render(); + if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); + return; + case Event.KEY_DOWN: + this.mark_next(); + this.render(); + if(navigator.appVersion.indexOf('AppleWebKit')>0) Event.stop(event); + return; + } + else + if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN) + return; + + this.changed = true; + this.has_focus = true; + + if(this.observer) clearTimeout(this.observer); + this.observer = + setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000); + }, + + onHover: function(event) { + var element = Event.findElement(event, 'LI'); + if(this.index != element.autocompleteIndex) + { + this.index = element.autocompleteIndex; + this.render(); + } + Event.stop(event); + }, + + onClick: function(event) { + var element = Event.findElement(event, 'LI'); + this.index = element.autocompleteIndex; + this.select_entry(); + Event.stop(event); + }, + + onBlur: function(event) { + // needed to make click events working + setTimeout(this.hide.bind(this), 250); + this.has_focus = false; + this.active = false; + }, + + render: function() { + if(this.entry_count > 0) { + for (var i = 0; i < this.entry_count; i++) + this.index==i ? + Element.addClassName(this.get_entry(i),"selected") : + Element.removeClassName(this.get_entry(i),"selected"); + + if(this.has_focus) { + if(this.get_current_entry().scrollIntoView) + this.get_current_entry().scrollIntoView(false); + + this.show(); + this.active = true; + } + } else this.hide(); + }, + + mark_previous: function() { + if(this.index > 0) this.index-- + else this.index = this.entry_count-1; + }, + + mark_next: function() { + if(this.index < this.entry_count-1) this.index++ + else this.index = 0; + }, + + get_entry: function(index) { + return this.update.firstChild.childNodes[index]; + }, + + get_current_entry: function() { + return this.get_entry(this.index); + }, + + select_entry: function() { //agileco + this.active = false; + value = Element.collectTextNodesIgnoreClass(this.get_current_entry(), 'informal', 'index').unescapeHTML(); // agileco mod + this.element.value = value; + this.element.focus(); + id = Element.collectTextNodesIgnoreClass(this.get_current_entry(), 'name', 'informal' ).unescapeHTML(); // agileco add + document.getElementById(this.hidden).value = id; // agileco add + } +}); \ No newline at end of file diff --git a/includes/javascript/dragdrop.js b/includes/javascript/dragdrop.js new file mode 100644 index 00000000..20432a3c --- /dev/null +++ b/includes/javascript/dragdrop.js @@ -0,0 +1,476 @@ +// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// +// Element.Class part Copyright (c) 2005 by Rick Olson +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Element.Class = { + // Element.toggleClass(element, className) toggles the class being on/off + // Element.toggleClass(element, className1, className2) toggles between both classes, + // defaulting to className1 if neither exist + toggle: function(element, className) { + if(Element.Class.has(element, className)) { + Element.Class.remove(element, className); + if(arguments.length == 3) Element.Class.add(element, arguments[2]); + } else { + Element.Class.add(element, className); + if(arguments.length == 3) Element.Class.remove(element, arguments[2]); + } + }, + + // gets space-delimited classnames of an element as an array + get: function(element) { + element = $(element); + return element.className.split(' '); + }, + + // functions adapted from original functions by Gavin Kistner + remove: function(element) { + element = $(element); + var regEx; + for(var i = 1; i < arguments.length; i++) { + regEx = new RegExp("^" + arguments[i] + "\\b\\s*|\\s*\\b" + arguments[i] + "\\b", 'g'); + element.className = element.className.replace(regEx, '') + } + }, + + add: function(element) { + element = $(element); + for(var i = 1; i < arguments.length; i++) { + Element.Class.remove(element, arguments[i]); + element.className += (element.className.length > 0 ? ' ' : '') + arguments[i]; + } + }, + + // returns true if all given classes exist in said element + has: function(element) { + element = $(element); + if(!element || !element.className) return false; + var regEx; + for(var i = 1; i < arguments.length; i++) { + regEx = new RegExp("\\b" + arguments[i] + "\\b"); + if(!regEx.test(element.className)) return false; + } + return true; + }, + + // expects arrays of strings and/or strings as optional paramters + // Element.Class.has_any(element, ['classA','classB','classC'], 'classD') + has_any: function(element) { + element = $(element); + if(!element || !element.className) return false; + var regEx; + for(var i = 1; i < arguments.length; i++) { + if((typeof arguments[i] == 'object') && + (arguments[i].constructor == Array)) { + for(var j = 0; j < arguments[i].length; j++) { + regEx = new RegExp("\\b" + arguments[i][j] + "\\b"); + if(regEx.test(element.className)) return true; + } + } else { + regEx = new RegExp("\\b" + arguments[i] + "\\b"); + if(regEx.test(element.className)) return true; + } + } + return false; + }, + + childrenWith: function(element, className) { + var children = $(element).getElementsByTagName('*'); + var elements = new Array(); + + for (var i = 0; i < children.length; i++) { + if (Element.Class.has(children[i], className)) { + elements.push(children[i]); + break; + } + } + + return elements; + } +} + +/*--------------------------------------------------------------------------*/ + +var Droppables = { + drops: false, + + add: function(element) { + var element = $(element); + var options = { + greedy: true, + hoverclass: null + }.extend(arguments[1] || {}); + + // cache containers + if(options.containment) { + options._containers = new Array(); + var containment = options.containment; + if((typeof containment == 'object') && + (containment.constructor == Array)) { + for(var i=0; i0) window.scrollBy(0,0); + + Event.stop(event); + } + } +} + +/*--------------------------------------------------------------------------*/ + +SortableObserver = Class.create(); +SortableObserver.prototype = { + initialize: function(element, observer) { + this.element = $(element); + this.observer = observer; + this.lastValue = Sortable.serialize(this.element); + }, + onStart: function() { + this.lastValue = Sortable.serialize(this.element); + }, + onEnd: function() { + if(this.lastValue != Sortable.serialize(this.element)) + this.observer(this.element) + } +} + +Sortable = { + create: function(element) { + var element = $(element); + var options = { + tag: 'li', // assumes li children, override with tag: 'tagname' + overlap: 'vertical', // one of 'vertical', 'horizontal' + constraint: 'vertical', // one of 'vertical', 'horizontal', false + containment: element, // also takes array of elements (or id's); or false + handle: false, // or a CSS class + only: false, + hoverclass: null, + onChange: function() {}, + onUpdate: function() {} + }.extend(arguments[1] || {}); + element.sortable = options; + + // build options for the draggables + var options_for_draggable = { + revert: true, + constraint: options.constraint, + handle: handle }; + if(options.starteffect) + options_for_draggable.starteffect = options.starteffect; + if(options.reverteffect) + options_for_draggable.reverteffect = options.reverteffect; + if(options.endeffect) + options_for_draggable.endeffect = options.endeffect; + if(options.zindex) + options_for_draggable.zindex = options.zindex; + + // build options for the droppables + var options_for_droppable = { + overlap: options.overlap, + containment: options.containment, + hoverclass: options.hoverclass, + onHover: function(element, dropon, overlap) { + if(overlap>0.5) { + if(dropon.previousSibling != element) { + var oldParentNode = element.parentNode; + element.style.visibility = "hidden"; // fix gecko rendering + dropon.parentNode.insertBefore(element, dropon); + if(dropon.parentNode!=oldParentNode && oldParentNode.sortable) + oldParentNode.sortable.onChange(element); + if(dropon.parentNode.sortable) + dropon.parentNode.sortable.onChange(element); + } + } else { + var nextElement = dropon.nextSibling || null; + if(nextElement != element) { + var oldParentNode = element.parentNode; + element.style.visibility = "hidden"; // fix gecko rendering + dropon.parentNode.insertBefore(element, nextElement); + if(dropon.parentNode!=oldParentNode && oldParentNode.sortable) + oldParentNode.sortable.onChange(element); + if(dropon.parentNode.sortable) + dropon.parentNode.sortable.onChange(element); + } + } + } + } + + // fix for gecko engine + Element.cleanWhitespace(element); + + // for onupdate + Draggables.addObserver(new SortableObserver(element, options.onUpdate)); + + // make it so + var elements = element.childNodes; + for (var i = 0; i < elements.length; i++) + if(elements[i].tagName && elements[i].tagName==options.tag.toUpperCase() && + (!options.only || (Element.Class.has(elements[i], options.only)))) { + + // handles are per-draggable + var handle = options.handle ? + Element.Class.childrenWith(elements[i], options.handle)[0] : elements[i]; + + new Draggable(elements[i], options_for_draggable.extend({ handle: handle })); + Droppables.add(elements[i], options_for_droppable); + } + + }, + serialize: function(element) { + var element = $(element); + var options = { + tag: element.sortable.tag, + only: element.sortable.only, + name: element.id + }.extend(arguments[1] || {}); + + var items = $(element).childNodes; + var queryComponents = new Array(); + + for(var i=0; i= this.finishOn) { + this.render(this.options.to); + if(this.finish) this.finish(); + if(this.options.afterFinish) this.options.afterFinish(this); + return; + } + pos = (timePos - this.startOn) / (this.finishOn - this.startOn); + frame = Math.round(pos * this.options.fps * this.options.duration); + if(frame > this.currentFrame) { + this.render(pos); + this.currentFrame = frame; + } + this.timeout = setTimeout(this.loop.bind(this), 10); + }, + render: function(pos) { + if(this.options.transition) pos = this.options.transition(pos); + pos = pos * (this.options.to-this.options.from); + pos += this.options.from; + if(this.options.beforeUpdate) this.options.beforeUpdate(this); + if(this.update) this.update(pos); + if(this.options.afterUpdate) this.options.afterUpdate(this); + }, + cancel: function() { + if(this.timeout) clearTimeout(this.timeout); + } +} + +Effect.Parallel = Class.create(); + Effect.Parallel.prototype = (new Effect.Base()).extend({ + initialize: function(effects) { + this.effects = effects || []; + this.start(arguments[1]); + }, + update: function(position) { + for (var i = 0; i < this.effects.length; i++) + this.effects[i].render(position); + }, + finish: function(position) { + for (var i = 0; i < this.effects.length; i++) + if(this.effects[i].finish) this.effects[i].finish(position); + } + }); + +// Internet Explorer caveat: works only on elements the have +// a 'layout', meaning having a given width or height. +// There is no way to safely set this automatically. +Effect.Opacity = Class.create(); +Effect.Opacity.prototype = (new Effect.Base()).extend({ + initialize: function(element) { + this.element = $(element); + options = { + from: 0.0, + to: 1.0 + }.extend(arguments[1] || {}); + this.start(options); + }, + update: function(position) { + this.setOpacity(position); + }, + setOpacity: function(opacity) { + opacity = (opacity == 1) ? 0.99999 : opacity; + this.element.style.opacity = opacity; + this.element.style.filter = "alpha(opacity:"+opacity*100+")"; + } +}); + +Effect.MoveBy = Class.create(); + Effect.MoveBy.prototype = (new Effect.Base()).extend({ + initialize: function(element, toTop, toLeft) { + this.element = $(element); + this.originalTop = parseFloat(this.element.style.top || '0'); + this.originalLeft = parseFloat(this.element.style.left || '0'); + this.toTop = toTop; + this.toLeft = toLeft; + if(this.element.style.position == "") + this.element.style.position = "relative"; + this.start(arguments[3]); + }, + update: function(position) { + topd = this.toTop * position + this.originalTop; + leftd = this.toLeft * position + this.originalLeft; + this.setPosition(topd, leftd); + }, + setPosition: function(topd, leftd) { + this.element.style.top = topd + "px"; + this.element.style.left = leftd + "px"; + } +}); + +Effect.Scale = Class.create(); +Effect.Scale.prototype = (new Effect.Base()).extend({ + initialize: function(element, percent) { + this.element = $(element) + options = { + scaleX: true, + scaleY: true, + scaleContent: true, + scaleFromCenter: false, + scaleMode: 'box', // 'box' or 'contents' or {} with provided values + scaleFrom: 100.0 + }.extend(arguments[2] || {}); + this.originalTop = this.element.offsetTop; + this.originalLeft = this.element.offsetLeft; + if (this.element.style.fontSize=="") this.sizeEm = 1.0; + if (this.element.style.fontSize && this.element.style.fontSize.indexOf("em")>0) + this.sizeEm = parseFloat(this.element.style.fontSize); + this.factor = (percent/100.0) - (options.scaleFrom/100.0); + if(options.scaleMode=='box') { + this.originalHeight = this.element.clientHeight; + this.originalWidth = this.element.clientWidth; + } else + if(options.scaleMode=='contents') { + this.originalHeight = this.element.scrollHeight; + this.originalWidth = this.element.scrollWidth; + } else { + this.originalHeight = options.scaleMode.originalHeight; + this.originalWidth = options.scaleMode.originalWidth; + } + this.start(options); + }, + + update: function(position) { + currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); + if(this.options.scaleContent && this.sizeEm) + this.element.style.fontSize = this.sizeEm*currentScale + "em"; + this.setDimensions( + this.originalWidth * currentScale, + this.originalHeight * currentScale); + }, + + setDimensions: function(width, height) { + if(this.options.scaleX) this.element.style.width = width + 'px'; + if(this.options.scaleY) this.element.style.height = height + 'px'; + if(this.options.scaleFromCenter) { + topd = (height - this.originalHeight)/2; + leftd = (width - this.originalWidth)/2; + if(this.element.style.position=='absolute') { + if(this.options.scaleY) this.element.style.top = this.originalTop-topd + "px"; + if(this.options.scaleX) this.element.style.left = this.originalLeft-leftd + "px"; + } else { + if(this.options.scaleY) this.element.style.top = -topd + "px"; + if(this.options.scaleX) this.element.style.left = -leftd + "px"; + } + } + } +}); + +Effect.Highlight = Class.create(); +Effect.Highlight.prototype = (new Effect.Base()).extend({ + initialize: function(element) { + this.element = $(element); + + // try to parse current background color as default for endcolor + // browser stores this as: "rgb(255, 255, 255)", convert to "#ffffff" format + var endcolor = "#ffffff"; + var current = this.element.style.backgroundColor; + if(current && current.slice(0,4) == "rgb(") { + endcolor = "#"; + var cols = current.slice(4,current.length-1).split(','); + var i=0; do { endcolor += parseInt(cols[i]).toColorPart() } while (++i<3); } + + var options = { + startcolor: "#ffff99", + endcolor: endcolor + }.extend(arguments[1] || {}); + + // init color calculations + this.colors_base = [ + parseInt(options.startcolor.slice(1,3),16), + parseInt(options.startcolor.slice(3,5),16), + parseInt(options.startcolor.slice(5),16) ]; + this.colors_delta = [ + parseInt(options.endcolor.slice(1,3),16)-this.colors_base[0], + parseInt(options.endcolor.slice(3,5),16)-this.colors_base[1], + parseInt(options.endcolor.slice(5),16)-this.colors_base[2] ]; + + this.start(options); + }, + update: function(position) { + var colors = [ + Math.round(this.colors_base[0]+(this.colors_delta[0]*position)), + Math.round(this.colors_base[1]+(this.colors_delta[1]*position)), + Math.round(this.colors_base[2]+(this.colors_delta[2]*position)) ]; + this.element.style.backgroundColor = "#" + + colors[0].toColorPart() + colors[1].toColorPart() + colors[2].toColorPart(); + } +}); + + +/* ------------- prepackaged effects ------------- */ + +Effect.Fade = function(element) { + options = { + from: 1.0, + to: 0.0, + afterFinish: function(effect) + { Element.hide(effect.element); + effect.setOpacity(1); } + }.extend(arguments[1] || {}); + new Effect.Opacity(element,options); +} + +Effect.Appear = function(element) { + options = { + from: 0.0, + to: 1.0, + beforeStart: function(effect) + { effect.setOpacity(0); + Element.show(effect.element); }, + afterUpdate: function(effect) + { Element.show(effect.element); } + }.extend(arguments[1] || {}); + new Effect.Opacity(element,options); +} + +Effect.Puff = function(element) { + new Effect.Parallel( + [ new Effect.Scale(element, 200, { sync: true, scaleFromCenter: true }), + new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0 } ) ], + { duration: 1.0, + afterUpdate: function(effect) + { effect.effects[0].element.style.position = 'absolute'; }, + afterFinish: function(effect) + { Element.hide(effect.effects[0].element); } + } + ); +} + +Effect.BlindUp = function(element) { + $(element)._overflow = $(element).style.overflow || 'visible'; + $(element).style.overflow = 'hidden'; + new Effect.Scale(element, 0, + { scaleContent: false, + scaleX: false, + afterFinish: function(effect) + { + Element.hide(effect.element); + effect.element.style.overflow = effect.element._overflow; + } + }.extend(arguments[1] || {}) + ); +} + +Effect.BlindDown = function(element) { + $(element).style.height = '0px'; + $(element)._overflow = $(element).style.overflow || 'visible'; + $(element).style.overflow = 'hidden'; + Element.show(element); + new Effect.Scale(element, 100, + { scaleContent: false, + scaleX: false, + scaleMode: 'contents', + scaleFrom: 0, + afterFinish: function(effect) { + effect.element.style.overflow = effect.element._overflow; + } + }.extend(arguments[1] || {}) + ); +} + +Effect.SwitchOff = function(element) { + new Effect.Appear(element, + { duration: 0.4, + transition: Effect.Transitions.flicker, + afterFinish: function(effect) + { effect.element.style.overflow = 'hidden'; + new Effect.Scale(effect.element, 1, + { duration: 0.3, scaleFromCenter: true, + scaleX: false, scaleContent: false, + afterUpdate: function(effect) { + if(effect.element.style.position=="") + effect.element.style.position = 'relative'; }, + afterFinish: function(effect) { Element.hide(effect.element); } + } ) + } + } ) +} + +Effect.DropOut = function(element) { + new Effect.Parallel( + [ new Effect.MoveBy(element, 100, 0, { sync: true }), + new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0 } ) ], + { duration: 0.5, + afterFinish: function(effect) + { Element.hide(effect.effects[0].element); } + }); +} + +Effect.Shake = function(element) { + new Effect.MoveBy(element, 0, 20, + { duration: 0.05, afterFinish: function(effect) { + new Effect.MoveBy(effect.element, 0, -40, + { duration: 0.1, afterFinish: function(effect) { + new Effect.MoveBy(effect.element, 0, 40, + { duration: 0.1, afterFinish: function(effect) { + new Effect.MoveBy(effect.element, 0, -40, + { duration: 0.1, afterFinish: function(effect) { + new Effect.MoveBy(effect.element, 0, 40, + { duration: 0.1, afterFinish: function(effect) { + new Effect.MoveBy(effect.element, 0, -20, + { duration: 0.05, afterFinish: function(effect) { + }}) }}) }}) }}) }}) }}); +} + +Effect.SlideDown = function(element) { + $(element)._overflow = $(element).style.overflow || 'visible'; + $(element).style.height = '0px'; + $(element).style.overflow = 'hidden'; + $(element).firstChild.style.position = 'relative'; + Element.show(element); + new Effect.Scale(element, 100, + { scaleContent: false, + scaleX: false, + scaleMode: 'contents', + scaleFrom: 0, + afterUpdate: function(effect) + { effect.element.firstChild.style.bottom = + (effect.originalHeight - effect.element.clientHeight) + 'px'; }, + afterFinish: function(effect) + { effect.element.style.overflow = effect.element._overflow; } + }.extend(arguments[1] || {}) + ); +} + +Effect.SlideUp = function(element) { + $(element)._overflow = $(element).style.overflow || 'visible'; + $(element).style.overflow = 'hidden'; + $(element).firstChild.style.position = 'relative'; + Element.show(element); + new Effect.Scale(element, 0, + { scaleContent: false, + scaleX: false, + afterUpdate: function(effect) + { effect.element.firstChild.style.bottom = + (effect.originalHeight - effect.element.clientHeight) + 'px'; }, + afterFinish: function(effect) + { + Element.hide(effect.element); + effect.element.style.overflow = effect.element._overflow; + } + }.extend(arguments[1] || {}) + ); +} + +Effect.Squish = function(element) { + new Effect.Scale(element, 0, + { afterFinish: function(effect) { Element.hide(effect.element); } }); +} + +Effect.Grow = function(element) { + element = $(element); + var options = arguments[1] || {}; + + var originalWidth = element.clientWidth; + var originalHeight = element.clientHeight; + element.style.overflow = 'hidden'; + Element.show(element); + + var direction = options.direction || 'center'; + var moveTransition = options.moveTransition || Effect.Transitions.sinoidal; + var scaleTransition = options.scaleTransition || Effect.Transitions.sinoidal; + var opacityTransition = options.opacityTransition || Effect.Transitions.full; + + var initialMoveX, initialMoveY; + var moveX, moveY; + + switch (direction) { + case 'top-left': + initialMoveX = initialMoveY = moveX = moveY = 0; + break; + case 'top-right': + initialMoveX = originalWidth; + initialMoveY = moveY = 0; + moveX = -originalWidth; + break; + case 'bottom-left': + initialMoveX = moveX = 0; + initialMoveY = originalHeight; + moveY = -originalHeight; + break; + case 'bottom-right': + initialMoveX = originalWidth; + initialMoveY = originalHeight; + moveX = -originalWidth; + moveY = -originalHeight; + break; + case 'center': + initialMoveX = originalWidth / 2; + initialMoveY = originalHeight / 2; + moveX = -originalWidth / 2; + moveY = -originalHeight / 2; + break; + } + + new Effect.MoveBy(element, initialMoveY, initialMoveX, { + duration: 0.01, + beforeUpdate: function(effect) { $(element).style.height = '0px'; }, + afterFinish: function(effect) { + new Effect.Parallel( + [ new Effect.Opacity(element, { sync: true, to: 1.0, from: 0.0, transition: opacityTransition }), + new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: moveTransition }), + new Effect.Scale(element, 100, { + scaleMode: { originalHeight: originalHeight, originalWidth: originalWidth }, + sync: true, scaleFrom: 0, scaleTo: 100, transition: scaleTransition })], + options); } + }); +} + +Effect.Shrink = function(element) { + element = $(element); + var options = arguments[1] || {}; + + var originalWidth = element.clientWidth; + var originalHeight = element.clientHeight; + element.style.overflow = 'hidden'; + Element.show(element); + + var direction = options.direction || 'center'; + var moveTransition = options.moveTransition || Effect.Transitions.sinoidal; + var scaleTransition = options.scaleTransition || Effect.Transitions.sinoidal; + var opacityTransition = options.opacityTransition || Effect.Transitions.none; + + var moveX, moveY; + + switch (direction) { + case 'top-left': + moveX = moveY = 0; + break; + case 'top-right': + moveX = originalWidth; + moveY = 0; + break; + case 'bottom-left': + moveX = 0; + moveY = originalHeight; + break; + case 'bottom-right': + moveX = originalWidth; + moveY = originalHeight; + break; + case 'center': + moveX = originalWidth / 2; + moveY = originalHeight / 2; + break; + } + + new Effect.Parallel( + [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: opacityTransition }), + new Effect.Scale(element, 0, { sync: true, transition: moveTransition }), + new Effect.MoveBy(element, moveY, moveX, { sync: true, transition: scaleTransition }) ], + options); +} + +Effect.Pulsate = function(element) { + var options = arguments[1] || {}; + var transition = options.transition || Effect.Transitions.sinoidal; + var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) }; + reverser.bind(transition); + new Effect.Opacity(element, + { duration: 3.0, + afterFinish: function(effect) { Element.show(effect.element); } + }.extend(options).extend({transition: reverser})); +} + +Effect.Fold = function(element) { + $(element).style.overflow = 'hidden'; + new Effect.Scale(element, 5, { + scaleContent: false, + scaleTo: 100, + scaleX: false, + afterFinish: function(effect) { + new Effect.Scale(element, 1, { + scaleContent: false, + scaleTo: 0, + scaleY: false, + afterFinish: function(effect) { Element.hide(effect.element) } }); + }}.extend(arguments[1] || {})); +} + +// old: new Effect.ContentZoom(element, percent) +// new: Element.setContentZoom(element, percent) + +Element.setContentZoom = function(element, percent) { + var element = $(element); + element.style.fontSize = (percent/100) + "em"; + if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); +} diff --git a/includes/javascript/prototype.js b/includes/javascript/prototype.js new file mode 100644 index 00000000..54d22c75 --- /dev/null +++ b/includes/javascript/prototype.js @@ -0,0 +1,1027 @@ +/* Prototype JavaScript framework, version 1.3.0 + * (c) 2005 Sam Stephenson + * + * THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff + * against the source tree, available from the Prototype darcs repository. + * + * Prototype is freely distributable under the terms of an MIT-style license. + * + * For details, see the Prototype web site: http://prototype.conio.net/ + * +/*--------------------------------------------------------------------------*/ + +var Prototype = { + Version: '1.3.0', + emptyFunction: function() {} +} + +var Class = { + create: function() { + return function() { + this.initialize.apply(this, arguments); + } + } +} + +var Abstract = new Object(); + +Object.extend = function(destination, source) { + for (property in source) { + destination[property] = source[property]; + } + return destination; +} + +Object.prototype.extend = function(object) { + return Object.extend.apply(this, [this, object]); +} + +Function.prototype.bind = function(object) { + var __method = this; + return function() { + __method.apply(object, arguments); + } +} + +Function.prototype.bindAsEventListener = function(object) { + var __method = this; + return function(event) { + __method.call(object, event || window.event); + } +} + +Number.prototype.toColorPart = function() { + var digits = this.toString(16); + if (this < 16) return '0' + digits; + return digits; +} + +var Try = { + these: function() { + var returnValue; + + for (var i = 0; i < arguments.length; i++) { + var lambda = arguments[i]; + try { + returnValue = lambda(); + break; + } catch (e) {} + } + + return returnValue; + } +} + +/*--------------------------------------------------------------------------*/ + +var PeriodicalExecuter = Class.create(); +PeriodicalExecuter.prototype = { + initialize: function(callback, frequency) { + this.callback = callback; + this.frequency = frequency; + this.currentlyExecuting = false; + + this.registerCallback(); + }, + + registerCallback: function() { + setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); + }, + + onTimerEvent: function() { + if (!this.currentlyExecuting) { + try { + this.currentlyExecuting = true; + this.callback(); + } finally { + this.currentlyExecuting = false; + } + } + } +} + +/*--------------------------------------------------------------------------*/ + +function $() { + var elements = new Array(); + + for (var i = 0; i < arguments.length; i++) { + var element = arguments[i]; + if (typeof element == 'string') + element = document.getElementById(element); + + if (arguments.length == 1) + return element; + + elements.push(element); + } + + return elements; +} + +if (!Array.prototype.push) { + Array.prototype.push = function() { + var startLength = this.length; + for (var i = 0; i < arguments.length; i++) + this[startLength + i] = arguments[i]; + return this.length; + } +} + +if (!Function.prototype.apply) { + // Based on code from http://www.youngpup.net/ + Function.prototype.apply = function(object, parameters) { + var parameterStrings = new Array(); + if (!object) object = window; + if (!parameters) parameters = new Array(); + + for (var i = 0; i < parameters.length; i++) + parameterStrings[i] = 'parameters[' + i + ']'; + + object.__apply__ = this; + var result = eval('object.__apply__(' + + parameterStrings[i].join(', ') + ')'); + object.__apply__ = null; + + return result; + } +} + +String.prototype.extend({ + stripTags: function() { + return this.replace(/<\/?[^>]+>/gi, ''); + }, + + escapeHTML: function() { + var div = document.createElement('div'); + var text = document.createTextNode(this); + div.appendChild(text); + return div.innerHTML; + }, + + unescapeHTML: function() { + var div = document.createElement('div'); + div.innerHTML = this.stripTags(); + return div.childNodes[0].nodeValue; + } +}); + +var Ajax = { + getTransport: function() { + return Try.these( + function() {return new ActiveXObject('Msxml2.XMLHTTP')}, + function() {return new ActiveXObject('Microsoft.XMLHTTP')}, + function() {return new XMLHttpRequest()} + ) || false; + } +} + +Ajax.Base = function() {}; +Ajax.Base.prototype = { + setOptions: function(options) { + this.options = { + method: 'post', + asynchronous: true, + parameters: '' + }.extend(options || {}); + }, + + responseIsSuccess: function() { + return this.transport.status == undefined + || this.transport.status == 0 + || (this.transport.status >= 200 && this.transport.status < 300); + }, + + responseIsFailure: function() { + return !this.responseIsSuccess(); + } +} + +Ajax.Request = Class.create(); +Ajax.Request.Events = + ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; + +Ajax.Request.prototype = (new Ajax.Base()).extend({ + initialize: function(url, options) { + this.transport = Ajax.getTransport(); + this.setOptions(options); + this.request(url); + }, + + request: function(url) { + var parameters = this.options.parameters || ''; + if (parameters.length > 0) parameters += '&_='; + + try { + if (this.options.method == 'get') + url += '?' + parameters; + + this.transport.open(this.options.method, url, + this.options.asynchronous); + + if (this.options.asynchronous) { + this.transport.onreadystatechange = this.onStateChange.bind(this); + setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); + } + + this.setRequestHeaders(); + + var body = this.options.postBody ? this.options.postBody : parameters; + this.transport.send(this.options.method == 'post' ? body : null); + + } catch (e) { + } + }, + + setRequestHeaders: function() { + var requestHeaders = + ['X-Requested-With', 'XMLHttpRequest', + 'X-Prototype-Version', Prototype.Version]; + + if (this.options.method == 'post') { + requestHeaders.push('Content-type', + 'application/x-www-form-urlencoded'); + + /* Force "Connection: close" for Mozilla browsers to work around + * a bug where XMLHttpReqeuest sends an incorrect Content-length + * header. See Mozilla Bugzilla #246651. + */ + if (this.transport.overrideMimeType) + requestHeaders.push('Connection', 'close'); + } + + if (this.options.requestHeaders) + requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); + + for (var i = 0; i < requestHeaders.length; i += 2) + this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); + }, + + onStateChange: function() { + var readyState = this.transport.readyState; + if (readyState != 1) + this.respondToReadyState(this.transport.readyState); + }, + + respondToReadyState: function(readyState) { + var event = Ajax.Request.Events[readyState]; + + if (event == 'Complete' && this.responseIsFailure()) + (this.options['on' + this.transport.status] + || this.options.onFailure + || Prototype.emptyFunction)(this.transport); + + (this.options['on' + event] || Prototype.emptyFunction)(this.transport); + } +}); + +Ajax.Updater = Class.create(); +Ajax.Updater.ScriptFragment = '(?:)((\n|.)*?)(?:<\/script>)'; + +Ajax.Updater.prototype.extend(Ajax.Request.prototype).extend({ + initialize: function(container, url, options) { + this.containers = { + success: container.success ? $(container.success) : $(container), + failure: container.failure ? $(container.failure) : + (container.success ? null : $(container)) + } + + this.transport = Ajax.getTransport(); + this.setOptions(options); + + var onComplete = this.options.onComplete || Prototype.emptyFunction; + this.options.onComplete = (function() { + this.updateContent(); + onComplete(this.transport); + }).bind(this); + + this.request(url); + }, + + updateContent: function() { + var receiver = this.responseIsSuccess() ? + this.containers.success : this.containers.failure; + + var match = new RegExp(Ajax.Updater.ScriptFragment, 'img'); + var response = this.transport.responseText.replace(match, ''); + var scripts = this.transport.responseText.match(match); + + if (receiver) { + if (this.options.insertion) { + new this.options.insertion(receiver, response); + } else { + receiver.innerHTML = response; + } + } + + if (this.responseIsSuccess()) { + if (this.onComplete) + setTimeout((function() {this.onComplete( + this.transport)}).bind(this), 10); + } + + if (this.options.evalScripts && scripts) { + match = new RegExp(Ajax.Updater.ScriptFragment, 'im'); + setTimeout((function() { + for (var i = 0; i < scripts.length; i++) + eval(scripts[i].match(match)[1]); + }).bind(this), 10); + } + } +}); + +Ajax.PeriodicalUpdater = Class.create(); +Ajax.PeriodicalUpdater.prototype = (new Ajax.Base()).extend({ + initialize: function(container, url, options) { + this.setOptions(options); + this.onComplete = this.options.onComplete; + + this.frequency = (this.options.frequency || 2); + this.decay = 1; + + this.updater = {}; + this.container = container; + this.url = url; + + this.start(); + }, + + start: function() { + this.options.onComplete = this.updateComplete.bind(this); + this.onTimerEvent(); + }, + + stop: function() { + this.updater.onComplete = undefined; + clearTimeout(this.timer); + (this.onComplete || Ajax.emptyFunction).apply(this, arguments); + }, + + updateComplete: function(request) { + if (this.options.decay) { + this.decay = (request.responseText == this.lastText ? + this.decay * this.options.decay : 1); + + this.lastText = request.responseText; + } + this.timer = setTimeout(this.onTimerEvent.bind(this), + this.decay * this.frequency * 1000); + }, + + onTimerEvent: function() { + this.updater = new Ajax.Updater(this.container, this.url, this.options); + } +}); + +document.getElementsByClassName = function(className) { + var children = document.getElementsByTagName('*') || document.all; + var elements = new Array(); + + for (var i = 0; i < children.length; i++) { + var child = children[i]; + var classNames = child.className.split(' '); + for (var j = 0; j < classNames.length; j++) { + if (classNames[j] == className) { + elements.push(child); + break; + } + } + } + + return elements; +} + +/*--------------------------------------------------------------------------*/ + +if (!window.Element) { + var Element = new Object(); +} + +Object.extend(Element, { + toggle: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = + (element.style.display == 'none' ? '' : 'none'); + } + }, + + hide: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = 'none'; + } + }, + + show: function() { + for (var i = 0; i < arguments.length; i++) { + var element = $(arguments[i]); + element.style.display = ''; + } + }, + + remove: function(element) { + element = $(element); + element.parentNode.removeChild(element); + }, + + getHeight: function(element) { + element = $(element); + return element.offsetHeight; + }, + + hasClassName: function(element, className) { + element = $(element); + if (!element) + return; + var a = element.className.split(' '); + for (var i = 0; i < a.length; i++) { + if (a[i] == className) + return true; + } + return false; + }, + + addClassName: function(element, className) { + element = $(element); + Element.removeClassName(element, className); + element.className += ' ' + className; + }, + + removeClassName: function(element, className) { + element = $(element); + if (!element) + return; + var newClassName = ''; + var a = element.className.split(' '); + for (var i = 0; i < a.length; i++) { + if (a[i] != className) { + if (i > 0) + newClassName += ' '; + newClassName += a[i]; + } + } + element.className = newClassName; + }, + + // removes whitespace-only text node children + cleanWhitespace: function(element) { + var element = $(element); + for (var i = 0; i < element.childNodes.length; i++) { + var node = element.childNodes[i]; + if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) + Element.remove(node); + } + } +}); + +var Toggle = new Object(); +Toggle.display = Element.toggle; + +/*--------------------------------------------------------------------------*/ + +Abstract.Insertion = function(adjacency) { + this.adjacency = adjacency; +} + +Abstract.Insertion.prototype = { + initialize: function(element, content) { + this.element = $(element); + this.content = content; + + if (this.adjacency && this.element.insertAdjacentHTML) { + this.element.insertAdjacentHTML(this.adjacency, this.content); + } else { + this.range = this.element.ownerDocument.createRange(); + if (this.initializeRange) this.initializeRange(); + this.fragment = this.range.createContextualFragment(this.content); + this.insertContent(); + } + } +} + +var Insertion = new Object(); + +Insertion.Before = Class.create(); +Insertion.Before.prototype = (new Abstract.Insertion('beforeBegin')).extend({ + initializeRange: function() { + this.range.setStartBefore(this.element); + }, + + insertContent: function() { + this.element.parentNode.insertBefore(this.fragment, this.element); + } +}); + +Insertion.Top = Class.create(); +Insertion.Top.prototype = (new Abstract.Insertion('afterBegin')).extend({ + initializeRange: function() { + this.range.selectNodeContents(this.element); + this.range.collapse(true); + }, + + insertContent: function() { + this.element.insertBefore(this.fragment, this.element.firstChild); + } +}); + +Insertion.Bottom = Class.create(); +Insertion.Bottom.prototype = (new Abstract.Insertion('beforeEnd')).extend({ + initializeRange: function() { + this.range.selectNodeContents(this.element); + this.range.collapse(this.element); + }, + + insertContent: function() { + this.element.appendChild(this.fragment); + } +}); + +Insertion.After = Class.create(); +Insertion.After.prototype = (new Abstract.Insertion('afterEnd')).extend({ + initializeRange: function() { + this.range.setStartAfter(this.element); + }, + + insertContent: function() { + this.element.parentNode.insertBefore(this.fragment, + this.element.nextSibling); + } +}); + +var Field = { + clear: function() { + for (var i = 0; i < arguments.length; i++) + $(arguments[i]).value = ''; + }, + + focus: function(element) { + $(element).focus(); + }, + + present: function() { + for (var i = 0; i < arguments.length; i++) + if ($(arguments[i]).value == '') return false; + return true; + }, + + select: function(element) { + $(element).select(); + }, + + activate: function(element) { + $(element).focus(); + $(element).select(); + } +} + +/*--------------------------------------------------------------------------*/ + +var Form = { + serialize: function(form) { + var elements = Form.getElements($(form)); + var queryComponents = new Array(); + + for (var i = 0; i < elements.length; i++) { + var queryComponent = Form.Element.serialize(elements[i]); + if (queryComponent) + queryComponents.push(queryComponent); + } + + return queryComponents.join('&'); + }, + + getElements: function(form) { + var form = $(form); + var elements = new Array(); + + for (tagName in Form.Element.Serializers) { + var tagElements = form.getElementsByTagName(tagName); + for (var j = 0; j < tagElements.length; j++) + elements.push(tagElements[j]); + } + return elements; + }, + + getInputs: function(form, typeName, name) { + var form = $(form); + var inputs = form.getElementsByTagName('input'); + + if (!typeName && !name) + return inputs; + + var matchingInputs = new Array(); + for (var i = 0; i < inputs.length; i++) { + var input = inputs[i]; + if ((typeName && input.type != typeName) || + (name && input.name != name)) + continue; + matchingInputs.push(input); + } + + return matchingInputs; + }, + + disable: function(form) { + var elements = Form.getElements(form); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + element.blur(); + element.disabled = 'true'; + } + }, + + enable: function(form) { + var elements = Form.getElements(form); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + element.disabled = ''; + } + }, + + focusFirstElement: function(form) { + var form = $(form); + var elements = Form.getElements(form); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + if (element.type != 'hidden' && !element.disabled) { + Field.activate(element); + break; + } + } + }, + + reset: function(form) { + $(form).reset(); + } +} + +Form.Element = { + serialize: function(element) { + var element = $(element); + var method = element.tagName.toLowerCase(); + var parameter = Form.Element.Serializers[method](element); + + if (parameter) + return encodeURIComponent(parameter[0]) + '=' + + encodeURIComponent(parameter[1]); + }, + + getValue: function(element) { + var element = $(element); + var method = element.tagName.toLowerCase(); + var parameter = Form.Element.Serializers[method](element); + + if (parameter) + return parameter[1]; + } +} + +Form.Element.Serializers = { + input: function(element) { + switch (element.type.toLowerCase()) { + case 'submit': + case 'hidden': + case 'password': + case 'text': + return Form.Element.Serializers.textarea(element); + case 'checkbox': + case 'radio': + return Form.Element.Serializers.inputSelector(element); + } + return false; + }, + + inputSelector: function(element) { + if (element.checked) + return [element.name, element.value]; + }, + + textarea: function(element) { + return [element.name, element.value]; + }, + + select: function(element) { + var value = ''; + if (element.type == 'select-one') { + var index = element.selectedIndex; + if (index >= 0) + value = element.options[index].value || element.options[index].text; + } else { + value = new Array(); + for (var i = 0; i < element.length; i++) { + var opt = element.options[i]; + if (opt.selected) + value.push(opt.value || opt.text); + } + } + return [element.name, value]; + } +} + +/*--------------------------------------------------------------------------*/ + +var $F = Form.Element.getValue; + +/*--------------------------------------------------------------------------*/ + +Abstract.TimedObserver = function() {} +Abstract.TimedObserver.prototype = { + initialize: function(element, frequency, callback) { + this.frequency = frequency; + this.element = $(element); + this.callback = callback; + + this.lastValue = this.getValue(); + this.registerCallback(); + }, + + registerCallback: function() { + setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); + }, + + onTimerEvent: function() { + var value = this.getValue(); + if (this.lastValue != value) { + this.callback(this.element, value); + this.lastValue = value; + } + } +} + +Form.Element.Observer = Class.create(); +Form.Element.Observer.prototype = (new Abstract.TimedObserver()).extend({ + getValue: function() { + return Form.Element.getValue(this.element); + } +}); + +Form.Observer = Class.create(); +Form.Observer.prototype = (new Abstract.TimedObserver()).extend({ + getValue: function() { + return Form.serialize(this.element); + } +}); + +/*--------------------------------------------------------------------------*/ + +Abstract.EventObserver = function() {} +Abstract.EventObserver.prototype = { + initialize: function(element, callback) { + this.element = $(element); + this.callback = callback; + + this.lastValue = this.getValue(); + if (this.element.tagName.toLowerCase() == 'form') + this.registerFormCallbacks(); + else + this.registerCallback(this.element); + }, + + onElementEvent: function() { + var value = this.getValue(); + if (this.lastValue != value) { + this.callback(this.element, value); + this.lastValue = value; + } + }, + + registerFormCallbacks: function() { + var elements = Form.getElements(this.element); + for (var i = 0; i < elements.length; i++) + this.registerCallback(elements[i]); + }, + + registerCallback: function(element) { + if (element.type) { + switch (element.type.toLowerCase()) { + case 'checkbox': + case 'radio': + element.target = this; + element.prev_onclick = element.onclick || Prototype.emptyFunction; + element.onclick = function() { + this.prev_onclick(); + this.target.onElementEvent(); + } + break; + case 'password': + case 'text': + case 'textarea': + case 'select-one': + case 'select-multiple': + element.target = this; + element.prev_onchange = element.onchange || Prototype.emptyFunction; + element.onchange = function() { + this.prev_onchange(); + this.target.onElementEvent(); + } + break; + } + } + } +} + +Form.Element.EventObserver = Class.create(); +Form.Element.EventObserver.prototype = (new Abstract.EventObserver()).extend({ + getValue: function() { + return Form.Element.getValue(this.element); + } +}); + +Form.EventObserver = Class.create(); +Form.EventObserver.prototype = (new Abstract.EventObserver()).extend({ + getValue: function() { + return Form.serialize(this.element); + } +}); + + +if (!window.Event) { + var Event = new Object(); +} + +Object.extend(Event, { + KEY_BACKSPACE: 8, + KEY_TAB: 9, + KEY_RETURN: 13, + KEY_ESC: 27, + KEY_LEFT: 37, + KEY_UP: 38, + KEY_RIGHT: 39, + KEY_DOWN: 40, + KEY_DELETE: 46, + + element: function(event) { + return event.target || event.srcElement; + }, + + isLeftClick: function(event) { + return (((event.which) && (event.which == 1)) || + ((event.button) && (event.button == 1))); + }, + + pointerX: function(event) { + return event.pageX || (event.clientX + + (document.documentElement.scrollLeft || document.body.scrollLeft)); + }, + + pointerY: function(event) { + return event.pageY || (event.clientY + + (document.documentElement.scrollTop || document.body.scrollTop)); + }, + + stop: function(event) { + if (event.preventDefault) { + event.preventDefault(); + event.stopPropagation(); + } else { + event.returnValue = false; + } + }, + + // find the first node with the given tagName, starting from the + // node the event was triggered on; traverses the DOM upwards + findElement: function(event, tagName) { + var element = Event.element(event); + while (element.parentNode && (!element.tagName || + (element.tagName.toUpperCase() != tagName.toUpperCase()))) + element = element.parentNode; + return element; + }, + + observe: function(element, name, observer, useCapture) { + var element = $(element); + useCapture = useCapture || false; + + if (name == 'keypress') { + if (navigator.appVersion.indexOf('AppleWebKit') > 0) { + element.addEventListener('keydown', observer, useCapture); + return; + } + if (element.addEventListener) { + element.addEventListener('keypress', observer, useCapture); + } else if (element.attachEvent) { + element.attachEvent('onkeydown', observer); + } + } else { + if (element.addEventListener) { + element.addEventListener(name, observer, useCapture); + } else if (element.attachEvent) { + element.attachEvent('on' + name, observer); + } + } + }, + + stopObserving: function(element, name, observer, useCapture) { + var element = $(element); + useCapture = useCapture || false; + + if (name == 'keypress') { + if (navigator.appVersion.indexOf('AppleWebKit') > 0) { + element.removeEventListener('keydown', observer, useCapture); + return; + } + if (element.removeEventListener) { + element.removeEventListener('keypress', observer, useCapture); + } else if (element.detachEvent) { + element.detachEvent('onkeydown', observer); + } + } else { + if (element.removeEventListener) { + element.removeEventListener(name, observer, useCapture); + } else if (element.detachEvent) { + element.detachEvent('on' + name, observer); + } + } + } +}); + +var Position = { + + // set to true if needed, warning: firefox performance problems + // NOT neeeded for page scrolling, only if draggable contained in + // scrollable elements + includeScrollOffsets: false, + + // must be called before calling withinIncludingScrolloffset, every time the + // page is scrolled + prepare: function() { + this.deltaX = window.pageXOffset + || document.documentElement.scrollLeft + || document.body.scrollLeft + || 0; + this.deltaY = window.pageYOffset + || document.documentElement.scrollTop + || document.body.scrollTop + || 0; + }, + + realOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.scrollTop || 0; + valueL += element.scrollLeft || 0; + element = element.parentNode; + } while (element); + return [valueL, valueT]; + }, + + cumulativeOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + element = element.offsetParent; + } while (element); + return [valueL, valueT]; + }, + + // caches x/y coordinate pair to use with overlap + within: function(element, x, y) { + if (this.includeScrollOffsets) + return this.withinIncludingScrolloffsets(element, x, y); + this.xcomp = x; + this.ycomp = y; + this.offset = this.cumulativeOffset(element); + + return (y >= this.offset[1] && + y < this.offset[1] + element.offsetHeight && + x >= this.offset[0] && + x < this.offset[0] + element.offsetWidth); + }, + + withinIncludingScrolloffsets: function(element, x, y) { + var offsetcache = this.realOffset(element); + + this.xcomp = x + offsetcache[0] - this.deltaX; + this.ycomp = y + offsetcache[1] - this.deltaY; + this.offset = this.cumulativeOffset(element); + + return (this.ycomp >= this.offset[1] && + this.ycomp < this.offset[1] + element.offsetHeight && + this.xcomp >= this.offset[0] && + this.xcomp < this.offset[0] + element.offsetWidth); + }, + + // within must be called directly before + overlap: function(mode, element) { + if (!mode) return 0; + if (mode == 'vertical') + return ((this.offset[1] + element.offsetHeight) - this.ycomp) / + element.offsetHeight; + if (mode == 'horizontal') + return ((this.offset[0] + element.offsetWidth) - this.xcomp) / + element.offsetWidth; + }, + + clone: function(source, target) { + source = $(source); + target = $(target); + target.style.position = 'absolute'; + var offsets = this.cumulativeOffset(source); + target.style.top = offsets[1] + 'px'; + target.style.left = offsets[0] + 'px'; + target.style.width = source.offsetWidth + 'px'; + target.style.height = source.offsetHeight + 'px'; + } +} \ No newline at end of file diff --git a/includes/jscalendar/README.txt b/includes/jscalendar/README.txt new file mode 100644 index 00000000..3b924f7d --- /dev/null +++ b/includes/jscalendar/README.txt @@ -0,0 +1,31 @@ +The DHTML Calendar +------------------- + + Author: Mihai Bazon, + http://dynarch.com/mishoo/ + + This program is free software published under the + terms of the GNU General Public License. + + For the entire license text please refer to + http://www.gnu.org/licenses/lgpl.html + +Contents +--------- + + calendar.js -- the main program file + lang/*.js -- internalization files + *.css -- color themes + cal.html -- example usage file + doc/ -- documentation, in PDF and HTML + simple-1.html -- quick setup examples [popup calendars] + simple-2.html -- quick setup example for flat calendar + +Homepage +--------- + + For details and latest versions please refer to calendar + homepage, located on my website: + + http://dynarch.com/mishoo/calendar.epl + diff --git a/includes/jscalendar/calendar-blue.css b/includes/jscalendar/calendar-blue.css new file mode 100644 index 00000000..b8ec5041 --- /dev/null +++ b/includes/jscalendar/calendar-blue.css @@ -0,0 +1,224 @@ +/* The main calendar widget. DIV containing a table. */ + +div.calendar { position: relative; } + +.calendar, .calendar table { + border: 1px solid #556; + font-size: 11px; + color: #000; + cursor: default; + background: #eef; + font-family: tahoma,verdana,sans-serif; +} + +/* Header part -- contains navigation buttons and day names. */ + +.calendar .button { /* "<<", "<", ">", ">>" buttons have this class */ + text-align: center; /* They are the navigation buttons */ + padding: 2px; /* Make the buttons seem like they're pressing */ +} + +.calendar .nav { + background: #778 url(menuarrow.gif) no-repeat 100% 100%; +} + +.calendar thead .title { /* This holds the current "month, year" */ + font-weight: bold; /* Pressing it will take you to the current date */ + text-align: center; + background: #fff; + color: #000; + padding: 2px; +} + +.calendar thead .headrow { /* Row containing navigation buttons */ + background: #778; + color: #fff; +} + +.calendar thead .daynames { /* Row containing the day names */ + background: #bdf; +} + +.calendar thead .name { /* Cells containing the day names */ + border-bottom: 1px solid #556; + padding: 2px; + text-align: center; + color: #000; +} + +.calendar thead .weekend { /* How a weekend day name shows in header */ + color: #a66; +} + +.calendar thead .hilite { /* How do the buttons in header appear when hover */ + background-color: #aaf; + color: #000; + border: 1px solid #04f; + padding: 1px; +} + +.calendar thead .active { /* Active (pressed) buttons in header */ + background-color: #77c; + padding: 2px 0px 0px 2px; +} + +/* The body part -- contains all the days in month. */ + +.calendar tbody .day { /* Cells containing month days dates */ + width: 2em; + color: #456; + text-align: right; + padding: 2px 4px 2px 2px; +} + +.calendar table .wn { + padding: 2px 3px 2px 2px; + border-right: 1px solid #000; + background: #bdf; +} + +.calendar tbody .rowhilite td { + background: #def; +} + +.calendar tbody .rowhilite td.wn { + background: #eef; +} + +.calendar tbody td.hilite { /* Hovered cells */ + background: #def; + padding: 1px 3px 1px 1px; + border: 1px solid #bbb; +} + +.calendar tbody td.active { /* Active (pressed) cells */ + background: #cde; + padding: 2px 2px 0px 2px; +} + +.calendar tbody td.selected { /* Cell showing today date */ + font-weight: bold; + border: 1px solid #000; + padding: 1px 3px 1px 1px; + background: #fff; + color: #000; +} + +.calendar tbody td.weekend { /* Cells showing weekend days */ + color: #a66; +} + +.calendar tbody td.today { /* Cell showing selected date */ + font-weight: bold; + color: #00f; +} + +.calendar tbody .disabled { color: #999; } + +.calendar tbody .emptycell { /* Empty cells (the best is to hide them) */ + visibility: hidden; +} + +.calendar tbody .emptyrow { /* Empty row (some months need less than 6 rows) */ + display: none; +} + +/* The footer part -- status bar and "Close" button */ + +.calendar tfoot .footrow { /* The in footer (only one right now) */ + text-align: center; + background: #556; + color: #fff; +} + +.calendar tfoot .ttip { /* Tooltip (status bar) cell */ + background: #fff; + color: #445; + border-top: 1px solid #556; + padding: 1px; +} + +.calendar tfoot .hilite { /* Hover style for buttons in footer */ + background: #aaf; + border: 1px solid #04f; + color: #000; + padding: 1px; +} + +.calendar tfoot .active { /* Active (pressed) style for buttons in footer */ + background: #77c; + padding: 2px 0px 0px 2px; +} + +/* Combo boxes (menus that display months/years for direct selection) */ + +.combo { + position: absolute; + display: none; + top: 0px; + left: 0px; + width: 4em; + cursor: default; + border: 1px solid #655; + background: #def; + color: #000; + font-size: smaller; +} + +.combo .label, +.combo .label-IEfix { + text-align: center; + padding: 1px; +} + +.combo .label-IEfix { + width: 4em; +} + +.combo .hilite { + background: #acf; +} + +.combo .active { + border-top: 1px solid #46a; + border-bottom: 1px solid #46a; + background: #eef; + font-weight: bold; +} + +.calendar td.time { + border-top: 1px solid #000; + padding: 1px 0px; + text-align: center; + background-color: #f4f0e8; +} + +.calendar td.time .hour, +.calendar td.time .minute, +.calendar td.time .ampm { + padding: 0px 3px 0px 4px; + border: 1px solid #889; + font-weight: bold; + background-color: #fff; +} + +.calendar td.time .ampm { + text-align: center; +} + +.calendar td.time .colon { + padding: 0px 2px 0px 3px; + font-weight: bold; +} + +.calendar td.time span.hilite { + border-color: #000; + background-color: #667; + color: #fff; +} + +.calendar td.time span.active { + border-color: #f00; + background-color: #000; + color: #0f0; +} diff --git a/includes/jscalendar/calendar-setup_stripped.js b/includes/jscalendar/calendar-setup_stripped.js new file mode 100644 index 00000000..d2006209 --- /dev/null +++ b/includes/jscalendar/calendar-setup_stripped.js @@ -0,0 +1,20 @@ +/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/ + * --------------------------------------------------------------------------- + * + * The DHTML Calendar + * + * Details and latest version at: + * http://dynarch.com/mishoo/calendar.epl + * + * This script is distributed under the GNU General Public License. + * + * This file defines helper functions for setting up the calendar. They are + * intended to help non-programmers get a working calendar on their site + * quickly. This script should not be seen as part of the calendar. It just + * shows you what one can do with the calendar, while in the same time + * providing a quick and simple method for setting it up. If you need + * exhaustive customization of the calendar creation process feel free to + * modify this code to suit your needs (this is recommended and much better + * than modifying calendar.js itself). + */ + Calendar.setup=function(params){function param_default(pname,def){if(typeof params[pname]=="undefined"){params[pname]=def;}};param_default("inputField",null);param_default("displayArea",null);param_default("button",null);param_default("eventName","click");param_default("ifFormat","%Y/%m/%d");param_default("daFormat","%Y/%m/%d");param_default("singleClick",true);param_default("disableFunc",null);param_default("dateStatusFunc",params["disableFunc"]);param_default("mondayFirst",true);param_default("align","Bl");param_default("range",[1900,2999]);param_default("weekNumbers",true);param_default("flat",null);param_default("flatCallback",null);param_default("onSelect",null);param_default("onClose",null);param_default("onUpdate",null);param_default("date",null);param_default("showsTime",false);param_default("timeFormat","24");var tmp=["inputField","displayArea","button"];for(var i in tmp){if(typeof params[tmp[i]]=="string"){params[tmp[i]]=document.getElementById(params[tmp[i]]);}}if(!(params.flat||params.inputField||params.displayArea||params.button)){alert("Calendar.setup:\n Nothing to setup (no fields found). Please check your code");return false;}function onSelect(cal){if(cal.params.flat){if(typeof cal.params.flatCallback=="function"){cal.params.flatCallback(cal);}else{alert("No flatCallback given -- doing nothing.");}return false;}if(cal.params.inputField){cal.params.inputField.value=cal.date.print(cal.params.ifFormat);}if(cal.params.displayArea){cal.params.displayArea.innerHTML=cal.date.print(cal.params.daFormat);}if(cal.params.singleClick&&cal.dateClicked){cal.callCloseHandler();}if(typeof cal.params.onUpdate=="function"){cal.params.onUpdate(cal);}};if(params.flat!=null){params.flat=document.getElementById(params.flat);if(!params.flat){alert("Calendar.setup:\n Flat specified but can't find parent.");return false;}var cal=new Calendar(params.mondayFirst,params.date,params.onSelect||onSelect);cal.showsTime=params.showsTime;cal.time24=(params.timeFormat=="24");cal.params=params;cal.weekNumbers=params.weekNumbers;cal.setRange(params.range[0],params.range[1]);cal.setDateStatusHandler(params.dateStatusFunc);cal.create(params.flat);cal.show();return false;}var triggerEl=params.button||params.displayArea||params.inputField;triggerEl["on"+params.eventName]=function(){var dateEl=params.inputField||params.displayArea;var dateFmt=params.inputField?params.ifFormat:params.daFormat;var mustCreate=false;var cal=window.calendar;if(!window.calendar){window.calendar=cal=new Calendar(params.mondayFirst,params.date,params.onSelect||onSelect,params.onClose||function(cal){cal.hide();});cal.showsTime=params.showsTime;cal.time24=(params.timeFormat=="24");cal.weekNumbers=params.weekNumbers;mustCreate=true;}else{cal.hide();}cal.setRange(params.range[0],params.range[1]);cal.params=params;cal.setDateStatusHandler(params.dateStatusFunc);cal.setDateFormat(dateFmt);if(mustCreate)cal.create();cal.parseDate(dateEl.value||dateEl.innerHTML);cal.refresh();cal.showAtElement(params.displayArea||params.inputField,params.align);return false;};}; \ No newline at end of file diff --git a/includes/jscalendar/calendar_stripped.js b/includes/jscalendar/calendar_stripped.js new file mode 100644 index 00000000..d3b2fdda --- /dev/null +++ b/includes/jscalendar/calendar_stripped.js @@ -0,0 +1,11 @@ +/* Copyright Mihai Bazon, 2002, 2003 | http://dynarch.com/mishoo/ + * ------------------------------------------------------------------ + * + * The DHTML Calendar, version 0.9.4 "Your favorite time" + * + * Details and latest version at: + * http://dynarch.com/mishoo/calendar.epl + * + * This script is distributed under the GNU General Public License. + */ + Calendar=function(mondayFirst,dateStr,onSelected,onClose){this.activeDiv=null;this.currentDateEl=null;this.getDateStatus=null;this.timeout=null;this.onSelected=onSelected||null;this.onClose=onClose||null;this.dragging=false;this.hidden=false;this.minYear=1970;this.maxYear=2050;this.dateFormat=Calendar._TT["DEF_DATE_FORMAT"];this.ttDateFormat=Calendar._TT["TT_DATE_FORMAT"];this.isPopup=true;this.weekNumbers=true;this.mondayFirst=mondayFirst;this.dateStr=dateStr;this.ar_days=null;this.showsTime=false;this.time24=true;this.table=null;this.element=null;this.tbody=null;this.firstdayname=null;this.monthsCombo=null;this.yearsCombo=null;this.hilitedMonth=null;this.activeMonth=null;this.hilitedYear=null;this.activeYear=null;this.dateClicked=false;if(typeof Calendar._SDN=="undefined"){if(typeof Calendar._SDN_len=="undefined")Calendar._SDN_len=3;var ar=new Array();for(var i=8;i>0;){ar[--i]=Calendar._DN[i].substr(0,Calendar._SDN_len);}Calendar._SDN=ar;if(typeof Calendar._SMN_len=="undefined")Calendar._SMN_len=3;ar=new Array();for(var i=12;i>0;){ar[--i]=Calendar._MN[i].substr(0,Calendar._SMN_len);}Calendar._SMN=ar;}};Calendar._C=null;Calendar.is_ie=(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent));Calendar.is_opera=/opera/i.test(navigator.userAgent);Calendar.is_khtml=/Konqueror|Safari|KHTML/i.test(navigator.userAgent);Calendar.getAbsolutePos=function(el){var r={x:el.offsetLeft,y:el.offsetTop};if(el.offsetParent){var tmp=Calendar.getAbsolutePos(el.offsetParent);r.x+=tmp.x;r.y+=tmp.y;}return r;};Calendar.isRelated=function(el,evt){var related=evt.relatedTarget;if(!related){var type=evt.type;if(type=="mouseover"){related=evt.fromElement;}else if(type=="mouseout"){related=evt.toElement;}}while(related){if(related==el){return true;}related=related.parentNode;}return false;};Calendar.removeClass=function(el,className){if(!(el&&el.className)){return;}var cls=el.className.split(" ");var ar=new Array();for(var i=cls.length;i>0;){if(cls[--i]!=className){ar[ar.length]=cls[i];}}el.className=ar.join(" ");};Calendar.addClass=function(el,className){Calendar.removeClass(el,className);el.className+=" "+className;};Calendar.getElement=function(ev){if(Calendar.is_ie){return window.event.srcElement;}else{return ev.currentTarget;}};Calendar.getTargetElement=function(ev){if(Calendar.is_ie){return window.event.srcElement;}else{return ev.target;}};Calendar.stopEvent=function(ev){ev||(ev=window.event);if(Calendar.is_ie){ev.cancelBubble=true;ev.returnValue=false;}else{ev.preventDefault();ev.stopPropagation();}return false;};Calendar.addEvent=function(el,evname,func){if(el.attachEvent){el.attachEvent("on"+evname,func);}else if(el.addEventListener){el.addEventListener(evname,func,true);}else{el["on"+evname]=func;}};Calendar.removeEvent=function(el,evname,func){if(el.detachEvent){el.detachEvent("on"+evname,func);}else if(el.removeEventListener){el.removeEventListener(evname,func,true);}else{el["on"+evname]=null;}};Calendar.createElement=function(type,parent){var el=null;if(document.createElementNS){el=document.createElementNS("http://www.w3.org/1999/xhtml",type);}else{el=document.createElement(type);}if(typeof parent!="undefined"){parent.appendChild(el);}return el;};Calendar._add_evs=function(el){with(Calendar){addEvent(el,"mouseover",dayMouseOver);addEvent(el,"mousedown",dayMouseDown);addEvent(el,"mouseout",dayMouseOut);if(is_ie){addEvent(el,"dblclick",dayMouseDblClick);el.setAttribute("unselectable",true);}}};Calendar.findMonth=function(el){if(typeof el.month!="undefined"){return el;}else if(typeof el.parentNode.month!="undefined"){return el.parentNode;}return null;};Calendar.findYear=function(el){if(typeof el.year!="undefined"){return el;}else if(typeof el.parentNode.year!="undefined"){return el.parentNode;}return null;};Calendar.showMonthsCombo=function(){var cal=Calendar._C;if(!cal){return false;}var cal=cal;var cd=cal.activeDiv;var mc=cal.monthsCombo;if(cal.hilitedMonth){Calendar.removeClass(cal.hilitedMonth,"hilite");}if(cal.activeMonth){Calendar.removeClass(cal.activeMonth,"active");}var mon=cal.monthsCombo.getElementsByTagName("div")[cal.date.getMonth()];Calendar.addClass(mon,"active");cal.activeMonth=mon;var s=mc.style;s.display="block";if(cd.navtype<0)s.left=cd.offsetLeft+"px";else s.left=(cd.offsetLeft+cd.offsetWidth-mc.offsetWidth)+"px";s.top=(cd.offsetTop+cd.offsetHeight)+"px";};Calendar.showYearsCombo=function(fwd){var cal=Calendar._C;if(!cal){return false;}var cal=cal;var cd=cal.activeDiv;var yc=cal.yearsCombo;if(cal.hilitedYear){Calendar.removeClass(cal.hilitedYear,"hilite");}if(cal.activeYear){Calendar.removeClass(cal.activeYear,"active");}cal.activeYear=null;var Y=cal.date.getFullYear()+(fwd?1:-1);var yr=yc.firstChild;var show=false;for(var i=12;i>0;--i){if(Y>=cal.minYear&&Y<=cal.maxYear){yr.firstChild.data=Y;yr.year=Y;yr.style.display="block";show=true;}else{yr.style.display="none";}yr=yr.nextSibling;Y+=fwd?2:-2;}if(show){var s=yc.style;s.display="block";if(cd.navtype<0)s.left=cd.offsetLeft+"px";else s.left=(cd.offsetLeft+cd.offsetWidth-yc.offsetWidth)+"px";s.top=(cd.offsetTop+cd.offsetHeight)+"px";}};Calendar.tableMouseUp=function(ev){var cal=Calendar._C;if(!cal){return false;}if(cal.timeout){clearTimeout(cal.timeout);}var el=cal.activeDiv;if(!el){return false;}var target=Calendar.getTargetElement(ev);ev||(ev=window.event);Calendar.removeClass(el,"active");if(target==el||target.parentNode==el){Calendar.cellClick(el,ev);}var mon=Calendar.findMonth(target);var date=null;if(mon){date=new Date(cal.date);if(mon.month!=date.getMonth()){date.setMonth(mon.month);cal.setDate(date);cal.dateClicked=false;cal.callHandler();}}else{var year=Calendar.findYear(target);if(year){date=new Date(cal.date);if(year.year!=date.getFullYear()){date.setFullYear(year.year);cal.setDate(date);cal.dateClicked=false;cal.callHandler();}}}with(Calendar){removeEvent(document,"mouseup",tableMouseUp);removeEvent(document,"mouseover",tableMouseOver);removeEvent(document,"mousemove",tableMouseOver);cal._hideCombos();_C=null;return stopEvent(ev);}};Calendar.tableMouseOver=function(ev){var cal=Calendar._C;if(!cal){return;}var el=cal.activeDiv;var target=Calendar.getTargetElement(ev);if(target==el||target.parentNode==el){Calendar.addClass(el,"hilite active");Calendar.addClass(el.parentNode,"rowhilite");}else{if(typeof el.navtype=="undefined"||(el.navtype!=50&&(el.navtype==0||Math.abs(el.navtype)>2)))Calendar.removeClass(el,"active");Calendar.removeClass(el,"hilite");Calendar.removeClass(el.parentNode,"rowhilite");}ev||(ev=window.event);if(el.navtype==50&&target!=el){var pos=Calendar.getAbsolutePos(el);var w=el.offsetWidth;var x=ev.clientX;var dx;var decrease=true;if(x>pos.x+w){dx=x-pos.x-w;decrease=false;}else dx=pos.x-x;if(dx<0)dx=0;var range=el._range;var current=el._current;var count=Math.floor(dx/10)%range.length;for(var i=range.length;--i>=0;)if(range[i]==current)break;while(count-->0)if(decrease){if(!(--i in range))i=range.length-1;}else if(!(++i in range))i=0;var newval=range[i];el.firstChild.data=newval;cal.onUpdateTime();}var mon=Calendar.findMonth(target);if(mon){if(mon.month!=cal.date.getMonth()){if(cal.hilitedMonth){Calendar.removeClass(cal.hilitedMonth,"hilite");}Calendar.addClass(mon,"hilite");cal.hilitedMonth=mon;}else if(cal.hilitedMonth){Calendar.removeClass(cal.hilitedMonth,"hilite");}}else{if(cal.hilitedMonth){Calendar.removeClass(cal.hilitedMonth,"hilite");}var year=Calendar.findYear(target);if(year){if(year.year!=cal.date.getFullYear()){if(cal.hilitedYear){Calendar.removeClass(cal.hilitedYear,"hilite");}Calendar.addClass(year,"hilite");cal.hilitedYear=year;}else if(cal.hilitedYear){Calendar.removeClass(cal.hilitedYear,"hilite");}}else if(cal.hilitedYear){Calendar.removeClass(cal.hilitedYear,"hilite");}}return Calendar.stopEvent(ev);};Calendar.tableMouseDown=function(ev){if(Calendar.getTargetElement(ev)==Calendar.getElement(ev)){return Calendar.stopEvent(ev);}};Calendar.calDragIt=function(ev){var cal=Calendar._C;if(!(cal&&cal.dragging)){return false;}var posX;var posY;if(Calendar.is_ie){posY=window.event.clientY+document.body.scrollTop;posX=window.event.clientX+document.body.scrollLeft;}else{posX=ev.pageX;posY=ev.pageY;}cal.hideShowCovered();var st=cal.element.style;st.left=(posX-cal.xOffs)+"px";st.top=(posY-cal.yOffs)+"px";return Calendar.stopEvent(ev);};Calendar.calDragEnd=function(ev){var cal=Calendar._C;if(!cal){return false;}cal.dragging=false;with(Calendar){removeEvent(document,"mousemove",calDragIt);removeEvent(document,"mouseover",stopEvent);removeEvent(document,"mouseup",calDragEnd);tableMouseUp(ev);}cal.hideShowCovered();};Calendar.dayMouseDown=function(ev){var el=Calendar.getElement(ev);if(el.disabled){return false;}var cal=el.calendar;cal.activeDiv=el;Calendar._C=cal;if(el.navtype!=300)with(Calendar){if(el.navtype==50)el._current=el.firstChild.data;addClass(el,"hilite active");addEvent(document,"mouseover",tableMouseOver);addEvent(document,"mousemove",tableMouseOver);addEvent(document,"mouseup",tableMouseUp);}else if(cal.isPopup){cal._dragStart(ev);}if(el.navtype==-1||el.navtype==1){if(cal.timeout)clearTimeout(cal.timeout);cal.timeout=setTimeout("Calendar.showMonthsCombo()",250);}else if(el.navtype==-2||el.navtype==2){if(cal.timeout)clearTimeout(cal.timeout);cal.timeout=setTimeout((el.navtype>0)?"Calendar.showYearsCombo(true)":"Calendar.showYearsCombo(false)",250);}else{cal.timeout=null;}return Calendar.stopEvent(ev);};Calendar.dayMouseDblClick=function(ev){Calendar.cellClick(Calendar.getElement(ev),ev||window.event);if(Calendar.is_ie){document.selection.empty();}};Calendar.dayMouseOver=function(ev){var el=Calendar.getElement(ev);if(Calendar.isRelated(el,ev)||Calendar._C||el.disabled){return false;}if(el.ttip){if(el.ttip.substr(0,1)=="_"){var date=null;with(el.calendar.date){date=new Date(getFullYear(),getMonth(),el.caldate);}el.ttip=date.print(el.calendar.ttDateFormat)+el.ttip.substr(1);}el.calendar.tooltips.firstChild.data=el.ttip;}if(el.navtype!=300){Calendar.addClass(el,"hilite");if(el.caldate){Calendar.addClass(el.parentNode,"rowhilite");}}return Calendar.stopEvent(ev);};Calendar.dayMouseOut=function(ev){with(Calendar){var el=getElement(ev);if(isRelated(el,ev)||_C||el.disabled){return false;}removeClass(el,"hilite");if(el.caldate){removeClass(el.parentNode,"rowhilite");}el.calendar.tooltips.firstChild.data=_TT["SEL_DATE"];return stopEvent(ev);}};Calendar.cellClick=function(el,ev){var cal=el.calendar;var closing=false;var newdate=false;var date=null;if(typeof el.navtype=="undefined"){Calendar.removeClass(cal.currentDateEl,"selected");Calendar.addClass(el,"selected");closing=(cal.currentDateEl==el);if(!closing){cal.currentDateEl=el;}cal.date.setDate(el.caldate);date=cal.date;newdate=true;cal.dateClicked=true;}else{if(el.navtype==200){Calendar.removeClass(el,"hilite");cal.callCloseHandler();return;}date=(el.navtype==0)?new Date():new Date(cal.date);cal.dateClicked=false;var year=date.getFullYear();var mon=date.getMonth();function setMonth(m){var day=date.getDate();var max=date.getMonthDays(m);if(day>max){date.setDate(max);}date.setMonth(m);};switch(el.navtype){case 400:Calendar.removeClass(el,"hilite");var text=Calendar._TT["ABOUT"];if(typeof text!="undefined"){text+=cal.showsTime?Calendar._TT["ABOUT_TIME"]:"";}else{text="Help and about box text is not translated into this language.\n"+"If you know this language and you feel generous please update\n"+"the corresponding file in \"lang\" subdir to match calendar-en.js\n"+"and send it back to to get it into the distribution ;-)\n\n"+"Thank you!\n"+"http://dynarch.com/mishoo/calendar.epl\n";}alert(text);return;case-2:if(year>cal.minYear){date.setFullYear(year-1);}break;case-1:if(mon>0){setMonth(mon-1);}else if(year-->cal.minYear){date.setFullYear(year);setMonth(11);}break;case 1:if(mon<11){setMonth(mon+1);}else if(year=0;)if(range[i]==current)break;if(ev&&ev.shiftKey){if(!(--i in range))i=range.length-1;}else if(!(++i in range))i=0;var newval=range[i];el.firstChild.data=newval;cal.onUpdateTime();return;case 0:if((typeof cal.getDateStatus=="function")&&cal.getDateStatus(date,date.getFullYear(),date.getMonth(),date.getDate())){return false;}break;}if(!date.equalsTo(cal.date)){cal.setDate(date);newdate=true;}}if(newdate){cal.callHandler();}if(closing){Calendar.removeClass(el,"hilite");cal.callCloseHandler();}};Calendar.prototype.create=function(_par){var parent=null;if(!_par){parent=document.getElementsByTagName("body")[0];this.isPopup=true;}else{parent=_par;this.isPopup=false;}this.date=this.dateStr?new Date(this.dateStr):new Date();var table=Calendar.createElement("table");this.table=table;table.cellSpacing=0;table.cellPadding=0;table.calendar=this;Calendar.addEvent(table,"mousedown",Calendar.tableMouseDown);var div=Calendar.createElement("div");this.element=div;div.className="calendar";if(this.isPopup){div.style.position="absolute";div.style.display="none";}div.appendChild(table);var thead=Calendar.createElement("thead",table);var cell=null;var row=null;var cal=this;var hh=function(text,cs,navtype){cell=Calendar.createElement("td",row);cell.colSpan=cs;cell.className="button";if(navtype!=0&&Math.abs(navtype)<=2)cell.className+=" nav";Calendar._add_evs(cell);cell.calendar=cal;cell.navtype=navtype;if(text.substr(0,1)!="&"){cell.appendChild(document.createTextNode(text));}else{cell.innerHTML=text;}return cell;};row=Calendar.createElement("tr",thead);var title_length=6;(this.isPopup)&&--title_length;(this.weekNumbers)&&++title_length;hh("?",1,400).ttip=Calendar._TT["INFO"];this.title=hh("",title_length,300);this.title.className="title";if(this.isPopup){this.title.ttip=Calendar._TT["DRAG_TO_MOVE"];this.title.style.cursor="move";hh("×",1,200).ttip=Calendar._TT["CLOSE"];}row=Calendar.createElement("tr",thead);row.className="headrow";this._nav_py=hh("«",1,-2);this._nav_py.ttip=Calendar._TT["PREV_YEAR"];this._nav_pm=hh("‹",1,-1);this._nav_pm.ttip=Calendar._TT["PREV_MONTH"];this._nav_now=hh(Calendar._TT["TODAY"],this.weekNumbers?4:3,0);this._nav_now.ttip=Calendar._TT["GO_TODAY"];this._nav_nm=hh("›",1,1);this._nav_nm.ttip=Calendar._TT["NEXT_MONTH"];this._nav_ny=hh("»",1,2);this._nav_ny.ttip=Calendar._TT["NEXT_YEAR"];row=Calendar.createElement("tr",thead);row.className="daynames";if(this.weekNumbers){cell=Calendar.createElement("td",row);cell.className="name wn";cell.appendChild(document.createTextNode(Calendar._TT["WK"]));}for(var i=7;i>0;--i){cell=Calendar.createElement("td",row);cell.appendChild(document.createTextNode(""));if(!i){cell.navtype=100;cell.calendar=this;Calendar._add_evs(cell);}}this.firstdayname=(this.weekNumbers)?row.firstChild.nextSibling:row.firstChild;this._displayWeekdays();var tbody=Calendar.createElement("tbody",table);this.tbody=tbody;for(i=6;i>0;--i){row=Calendar.createElement("tr",tbody);if(this.weekNumbers){cell=Calendar.createElement("td",row);cell.appendChild(document.createTextNode(""));}for(var j=7;j>0;--j){cell=Calendar.createElement("td",row);cell.appendChild(document.createTextNode(""));cell.calendar=this;Calendar._add_evs(cell);}}if(this.showsTime){row=Calendar.createElement("tr",tbody);row.className="time";cell=Calendar.createElement("td",row);cell.className="time";cell.colSpan=2;cell.innerHTML=" ";cell=Calendar.createElement("td",row);cell.className="time";cell.colSpan=this.weekNumbers?4:3;(function(){function makeTimePart(className,init,range_start,range_end){var part=Calendar.createElement("span",cell);part.className=className;part.appendChild(document.createTextNode(init));part.calendar=cal;part.ttip=Calendar._TT["TIME_PART"];part.navtype=50;part._range=[];if(typeof range_start!="number")part._range=range_start;else{for(var i=range_start;i<=range_end;++i){var txt;if(i<10&&range_end>=10)txt='0'+i;else txt=''+i;part._range[part._range.length]=txt;}}Calendar._add_evs(part);return part;};var hrs=cal.date.getHours();var mins=cal.date.getMinutes();var t12=!cal.time24;var pm=(hrs>12);if(t12&&pm)hrs-=12;var H=makeTimePart("hour",hrs,t12?1:0,t12?12:23);var span=Calendar.createElement("span",cell);span.appendChild(document.createTextNode(":"));span.className="colon";var M=makeTimePart("minute",mins,0,59);var AP=null;cell=Calendar.createElement("td",row);cell.className="time";cell.colSpan=2;if(t12)AP=makeTimePart("ampm",pm?"pm":"am",["am","pm"]);else cell.innerHTML=" ";cal.onSetTime=function(){var hrs=this.date.getHours();var mins=this.date.getMinutes();var pm=(hrs>12);if(pm&&t12)hrs-=12;H.firstChild.data=(hrs<10)?("0"+hrs):hrs;M.firstChild.data=(mins<10)?("0"+mins):mins;if(t12)AP.firstChild.data=pm?"pm":"am";};cal.onUpdateTime=function(){var date=this.date;var h=parseInt(H.firstChild.data,10);if(t12){if(/pm/i.test(AP.firstChild.data)&&h<12)h+=12;else if(/am/i.test(AP.firstChild.data)&&h==12)h=0;}var d=date.getDate();var m=date.getMonth();var y=date.getFullYear();date.setHours(h);date.setMinutes(parseInt(M.firstChild.data,10));date.setFullYear(y);date.setMonth(m);date.setDate(d);this.dateClicked=false;this.callHandler();};})();}else{this.onSetTime=this.onUpdateTime=function(){};}var tfoot=Calendar.createElement("tfoot",table);row=Calendar.createElement("tr",tfoot);row.className="footrow";cell=hh(Calendar._TT["SEL_DATE"],this.weekNumbers?8:7,300);cell.className="ttip";if(this.isPopup){cell.ttip=Calendar._TT["DRAG_TO_MOVE"];cell.style.cursor="move";}this.tooltips=cell;div=Calendar.createElement("div",this.element);this.monthsCombo=div;div.className="combo";for(i=0;i0;--i){var yr=Calendar.createElement("div");yr.className=Calendar.is_ie?"label-IEfix":"label";yr.appendChild(document.createTextNode(""));div.appendChild(yr);}this._init(this.mondayFirst,this.date);parent.appendChild(this.element);};Calendar._keyEvent=function(ev){if(!window.calendar){return false;}(Calendar.is_ie)&&(ev=window.event);var cal=window.calendar;var act=(Calendar.is_ie||ev.type=="keypress");if(ev.ctrlKey){switch(ev.keyCode){case 37:act&&Calendar.cellClick(cal._nav_pm);break;case 38:act&&Calendar.cellClick(cal._nav_py);break;case 39:act&&Calendar.cellClick(cal._nav_nm);break;case 40:act&&Calendar.cellClick(cal._nav_ny);break;default:return false;}}else switch(ev.keyCode){case 32:Calendar.cellClick(cal._nav_now);break;case 27:act&&cal.hide();break;case 37:case 38:case 39:case 40:if(act){var date=cal.date.getDate()-1;var el=cal.currentDateEl;var ne=null;var prev=(ev.keyCode==37)||(ev.keyCode==38);switch(ev.keyCode){case 37:(--date>=0)&&(ne=cal.ar_days[date]);break;case 38:date-=7;(date>=0)&&(ne=cal.ar_days[date]);break;case 39:(++datethis.maxYear){year=this.maxYear;date.setFullYear(year);}this.mondayFirst=mondayFirst;this.date=new Date(date);var month=date.getMonth();var mday=date.getDate();var no_days=date.getMonthDays();date.setDate(1);var wday=date.getDay();var MON=mondayFirst?1:0;var SAT=mondayFirst?5:6;var SUN=mondayFirst?6:0;if(mondayFirst){wday=(wday>0)?(wday-1):6;}var iday=1;var row=this.tbody.firstChild;var MN=Calendar._SMN[month];var hasToday=((today.getFullYear()==year)&&(today.getMonth()==month));var todayDate=today.getDate();var week_number=date.getWeekNumber();var ar_days=new Array();for(var i=0;i<6;++i){if(iday>no_days){row.className="emptyrow";row=row.nextSibling;continue;}var cell=row.firstChild;if(this.weekNumbers){cell.className="day wn";cell.firstChild.data=week_number;cell=cell.nextSibling;}++week_number;row.className="daysrow";for(var j=0;j<7;++j){cell.className="day";if((!i&&jno_days){cell.innerHTML=" ";cell.disabled=true;cell=cell.nextSibling;continue;}cell.disabled=false;cell.firstChild.data=iday;if(typeof this.getDateStatus=="function"){date.setDate(iday);var status=this.getDateStatus(date,year,month,iday);if(status===true){cell.className+=" disabled";cell.disabled=true;}else{if(/disabled/i.test(status))cell.disabled=true;cell.className+=" "+status;}}if(!cell.disabled){ar_days[ar_days.length]=cell;cell.caldate=iday;cell.ttip="_";if(iday==mday){cell.className+=" selected";this.currentDateEl=cell;}if(hasToday&&(iday==todayDate)){cell.className+=" today";cell.ttip+=Calendar._TT["PART_TODAY"];}if(wday==SAT||wday==SUN){cell.className+=" weekend";}}++iday;((++wday)^ 7)||(wday=0);cell=cell.nextSibling;}row=row.nextSibling;}this.ar_days=ar_days;this.title.firstChild.data=Calendar._MN[month]+", "+year;this.onSetTime();};Calendar.prototype.setDate=function(date){if(!date.equalsTo(this.date)){this._init(this.mondayFirst,date);}};Calendar.prototype.refresh=function(){this._init(this.mondayFirst,this.date);};Calendar.prototype.setMondayFirst=function(mondayFirst){this._init(mondayFirst,this.date);this._displayWeekdays();};Calendar.prototype.setDateStatusHandler=Calendar.prototype.setDisabledHandler=function(unaryFunction){this.getDateStatus=unaryFunction;};Calendar.prototype.setRange=function(a,z){this.minYear=a;this.maxYear=z;};Calendar.prototype.callHandler=function(){if(this.onSelected){this.onSelected(this,this.date.print(this.dateFormat));}};Calendar.prototype.callCloseHandler=function(){if(this.onClose){this.onClose(this);}this.hideShowCovered();};Calendar.prototype.destroy=function(){var el=this.element.parentNode;el.removeChild(this.element);Calendar._C=null;window.calendar=null;};Calendar.prototype.reparent=function(new_parent){var el=this.element;el.parentNode.removeChild(el);new_parent.appendChild(el);};Calendar._checkCalendar=function(ev){if(!window.calendar){return false;}var el=Calendar.is_ie?Calendar.getElement(ev):Calendar.getTargetElement(ev);for(;el!=null&&el!=calendar.element;el=el.parentNode);if(el==null){window.calendar.callCloseHandler();return Calendar.stopEvent(ev);}};Calendar.prototype.show=function(){var rows=this.table.getElementsByTagName("tr");for(var i=rows.length;i>0;){var row=rows[--i];Calendar.removeClass(row,"rowhilite");var cells=row.getElementsByTagName("td");for(var j=cells.length;j>0;){var cell=cells[--j];Calendar.removeClass(cell,"hilite");Calendar.removeClass(cell,"active");}}this.element.style.display="block";this.hidden=false;if(this.isPopup){window.calendar=this;Calendar.addEvent(document,"keydown",Calendar._keyEvent);Calendar.addEvent(document,"keypress",Calendar._keyEvent);Calendar.addEvent(document,"mousedown",Calendar._checkCalendar);}this.hideShowCovered();};Calendar.prototype.hide=function(){if(this.isPopup){Calendar.removeEvent(document,"keydown",Calendar._keyEvent);Calendar.removeEvent(document,"keypress",Calendar._keyEvent);Calendar.removeEvent(document,"mousedown",Calendar._checkCalendar);}this.element.style.display="none";this.hidden=true;this.hideShowCovered();};Calendar.prototype.showAt=function(x,y){var s=this.element.style;s.left=x+"px";s.top=y+"px";this.show();};Calendar.prototype.showAtElement=function(el,opts){var self=this;var p=Calendar.getAbsolutePos(el);if(!opts||typeof opts!="string"){this.showAt(p.x,p.y+el.offsetHeight);return true;}this.element.style.display="block";Calendar.continuation_for_the_fucking_khtml_browser=function(){var w=self.element.offsetWidth;var h=self.element.offsetHeight;self.element.style.display="none";var valign=opts.substr(0,1);var halign="l";if(opts.length>1){halign=opts.substr(1,1);}switch(valign){case "T":p.y-=h;break;case "B":p.y+=el.offsetHeight;break;case "C":p.y+=(el.offsetHeight-h)/2;break;case "t":p.y+=el.offsetHeight-h;break;case "b":break;}switch(halign){case "L":p.x-=w;break;case "R":p.x+=el.offsetWidth;break;case "C":p.x+=(el.offsetWidth-w)/2;break;case "r":p.x+=el.offsetWidth-w;break;case "l":break;}self.showAt(p.x,p.y);};if(Calendar.is_khtml)setTimeout("Calendar.continuation_for_the_fucking_khtml_browser()",10);else Calendar.continuation_for_the_fucking_khtml_browser();};Calendar.prototype.setDateFormat=function(str){this.dateFormat=str;};Calendar.prototype.setTtDateFormat=function(str){this.ttDateFormat=str;};Calendar.prototype.parseDate=function(str,fmt){var y=0;var m=-1;var d=0;var a=str.split(/\W+/);if(!fmt){fmt=this.dateFormat;}var b=[];fmt.replace(/(%.)/g,function(str,par){return b[b.length]=par;});var i=0,j=0;var hr=0;var min=0;for(i=0;i29)?1900:2000);}if(b[i]=="%b"||b[i]=="%B"){for(j=0;j<12;++j){if(Calendar._MN[j].substr(0,a[i].length).toLowerCase()==a[i].toLowerCase()){m=j;break;}}}else if(/%[HIkl]/.test(b[i])){hr=parseInt(a[i],10);}else if(/%[pP]/.test(b[i])){if(/pm/i.test(a[i])&&hr<12)hr+=12;}else if(b[i]=="%M"){min=parseInt(a[i],10);}}if(y!=0&&m!=-1&&d!=0){this.setDate(new Date(y,m,d,hr,min,0));return;}y=0;m=-1;d=0;for(i=0;i31&&y==0){y=parseInt(a[i],10);(y<100)&&(y+=(y>29)?1900:2000);}else if(d==0){d=a[i];}}if(y==0){var today=new Date();y=today.getFullYear();}if(m!=-1&&d!=0){this.setDate(new Date(y,m,d,hr,min,0));}};Calendar.prototype.hideShowCovered=function(){var self=this;Calendar.continuation_for_the_fucking_khtml_browser=function(){function getVisib(obj){var value=obj.style.visibility;if(!value){if(document.defaultView&&typeof(document.defaultView.getComputedStyle)=="function"){if(!Calendar.is_khtml)value=document.defaultView. getComputedStyle(obj,"").getPropertyValue("visibility");else value='';}else if(obj.currentStyle){value=obj.currentStyle.visibility;}else value='';}return value;};var tags=new Array("applet","iframe","select");var el=self.element;var p=Calendar.getAbsolutePos(el);var EX1=p.x;var EX2=el.offsetWidth+EX1;var EY1=p.y;var EY2=el.offsetHeight+EY1;for(var k=tags.length;k>0;){var ar=document.getElementsByTagName(tags[--k]);var cc=null;for(var i=ar.length;i>0;){cc=ar[--i];p=Calendar.getAbsolutePos(cc);var CX1=p.x;var CX2=cc.offsetWidth+CX1;var CY1=p.y;var CY2=cc.offsetHeight+CY1;if(self.hidden||(CX1>EX2)||(CX2EY2)||(CY24)&&(day-=4)||(day+=3);return Math.round(((time/Date.DAY)+day)/7);};Date.prototype.equalsTo=function(date){return((this.getFullYear()==date.getFullYear())&&(this.getMonth()==date.getMonth())&&(this.getDate()==date.getDate())&&(this.getHours()==date.getHours())&&(this.getMinutes()==date.getMinutes()));};Date.prototype.print=function(str){var m=this.getMonth();var d=this.getDate();var y=this.getFullYear();var wn=this.getWeekNumber();var w=this.getDay();var s={};var hr=this.getHours();var pm=(hr>=12);var ir=(pm)?(hr-12):hr;var dy=this.getDayOfYear();if(ir==0)ir=12;var min=this.getMinutes();var sec=this.getSeconds();s["%a"]=Calendar._SDN[w];s["%A"]=Calendar._DN[w];s["%b"]=Calendar._SMN[m];s["%B"]=Calendar._MN[m];s["%C"]=1+Math.floor(y/100);s["%d"]=(d<10)?("0"+d):d;s["%e"]=d;s["%H"]=(hr<10)?("0"+hr):hr;s["%I"]=(ir<10)?("0"+ir):ir;s["%j"]=(dy<100)?((dy<10)?("00"+dy):("0"+dy)):dy;s["%k"]=hr;s["%l"]=ir;s["%m"]=(m<9)?("0"+(1+m)):(1+m);s["%M"]=(min<10)?("0"+min):min;s["%n"]="\n";s["%p"]=pm?"PM":"AM";s["%P"]=pm?"pm":"am";s["%s"]=Math.floor(this.getTime()/1000);s["%S"]=(sec<10)?("0"+sec):sec;s["%t"]="\t";s["%U"]=s["%W"]=s["%V"]=(wn<10)?("0"+wn):wn;s["%u"]=w+1;s["%w"]=w;s["%y"]=(''+y).substr(2,2);s["%Y"]=y;s["%%"]="%";var re=Date._msh_formatRegexp;if(typeof re=="undefined"){var tmp="";for(var i in s)tmp+=tmp?("|"+i):i;Date._msh_formatRegexp=re=new RegExp("("+tmp+")",'g');}return str.replace(re,function(match,par){return s[par];});};window.calendar=null; \ No newline at end of file diff --git a/includes/jscalendar/img.gif b/includes/jscalendar/img.gif new file mode 100644 index 0000000000000000000000000000000000000000..e15a4a4445482677100bdebe0c8b5d621c14f438 GIT binary patch literal 145 zcmZ?wbhEHb6k-r!Sj5J_z|e5uzySv1ng9R)KXc{`kPl=4NyVQmj0_BH3_3tIP^Az9 z19Mo$t~>8ky_gRetG4r`;<20bf&ea313?Kh<{UyJ%Ls@}L6JL%-jsWo{X3=Gx)=N>w3 literal 0 HcmV?d00001 diff --git a/includes/jscalendar/lang/calendar-cs-win.js b/includes/jscalendar/lang/calendar-cs-win.js new file mode 100644 index 00000000..b34213f5 --- /dev/null +++ b/includes/jscalendar/lang/calendar-cs-win.js @@ -0,0 +1,34 @@ +/* + calendar-cs-win.js + language: Czech + encoding: windows-1250 + author: Lubos Jerabek (xnet@seznam.cz) +*/ + +// ** I18N +Calendar._DN = new Array('Nedìle','Pondìlí','Úterý','Støeda','Ètvrtek','Pátek','Sobota','Nedìle'); +Calendar._DN3 = new Array('Ne','Po','Út','St','Èt','Pá','So','Ne'); +Calendar._MN = new Array('Leden','Únor','Bøezen','Duben','Kvìten','Èerven','Èervenec','Srpen','Záøí','Øíjen','Listopad','Prosinec'); +Calendar._MN3 = new Array('Led','Úno','Bøe','Dub','Kvì','Èrv','Èvc','Srp','Záø','Øíj','Lis','Pro'); + +// tooltips +Calendar._TT = {}; +Calendar._TT["TOGGLE"] = "Zmìna prvního dne v týdnu"; +Calendar._TT["PREV_YEAR"] = "Pøedchozí rok (pøidrž pro menu)"; +Calendar._TT["PREV_MONTH"] = "Pøedchozí mìsíc (pøidrž pro menu)"; +Calendar._TT["GO_TODAY"] = "Dnešní datum"; +Calendar._TT["NEXT_MONTH"] = "Další mìsíc (pøidrž pro menu)"; +Calendar._TT["NEXT_YEAR"] = "Další rok (pøidrž pro menu)"; +Calendar._TT["SEL_DATE"] = "Vyber datum"; +Calendar._TT["DRAG_TO_MOVE"] = "Chy a táhni, pro pøesun"; +Calendar._TT["PART_TODAY"] = " (dnes)"; +Calendar._TT["MON_FIRST"] = "Ukaž jako první Pondìlí"; +Calendar._TT["SUN_FIRST"] = "Ukaž jako první Nedìli"; +Calendar._TT["CLOSE"] = "Zavøít"; +Calendar._TT["TODAY"] = "Dnes"; + +// date formats +Calendar._TT["DEF_DATE_FORMAT"] = "d.m.yy"; +Calendar._TT["TT_DATE_FORMAT"] = "DD, 5.MM y"; + +Calendar._TT["WK"] = "wk"; diff --git a/includes/jscalendar/lang/calendar-english.js b/includes/jscalendar/lang/calendar-english.js new file mode 100644 index 00000000..e9291e1b --- /dev/null +++ b/includes/jscalendar/lang/calendar-english.js @@ -0,0 +1,114 @@ +// ** I18N + +// Calendar EN language +// Author: Mihai Bazon, +// Encoding: any +// Distributed under the same terms as the calendar itself. + +// For translators: please use UTF-8 if possible. We strongly believe that +// Unicode is the answer to a real internationalized world. Also please +// include your contact information in the header, as can be seen above. + +// full day names +Calendar._DN = new Array +("Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + "Sunday"); + +// Please note that the following array of short day names (and the same goes +// for short month names, _SMN) isn't absolutely necessary. We give it here +// for exemplification on how one can customize the short day names, but if +// they are simply the first N letters of the full name you can simply say: +// +// Calendar._SDN_len = N; // short day name length +// Calendar._SMN_len = N; // short month name length +// +// If N = 3 then this is not needed either since we assume a value of 3 if not +// present, to be compatible with translation files that were written before +// this feature. + +// short day names +Calendar._SDN = new Array +("Sun", + "Mon", + "Tue", + "Wed", + "Thu", + "Fri", + "Sat", + "Sun"); + +// full month names +Calendar._MN = new Array +("January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December"); + +// short month names +Calendar._SMN = new Array +("Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec"); + +// tooltips +Calendar._TT = {}; +Calendar._TT["INFO"] = "About the calendar"; + +Calendar._TT["ABOUT"] = +"DHTML Date/Time Selector\n" + +"(c) dynarch.com 2002-2003\n" + // don't translate this this ;-) +"For latest version visit: http://dynarch.com/mishoo/calendar.epl\n" + +"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." + +"\n\n" + +"Date selection:\n" + +"- Use the \xab, \xbb buttons to select year\n" + +"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" + +"- Hold mouse button on any of the above buttons for faster selection."; +Calendar._TT["ABOUT_TIME"] = "\n\n" + +"Time selection:\n" + +"- Click on any of the time parts to increase it\n" + +"- or Shift-click to decrease it\n" + +"- or click and drag for faster selection."; + +Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)"; +Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)"; +Calendar._TT["GO_TODAY"] = "Go Today"; +Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)"; +Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)"; +Calendar._TT["SEL_DATE"] = "Select date"; +Calendar._TT["DRAG_TO_MOVE"] = "Drag to move"; +Calendar._TT["PART_TODAY"] = " (today)"; +Calendar._TT["MON_FIRST"] = "Display Monday first"; +Calendar._TT["SUN_FIRST"] = "Display Sunday first"; +Calendar._TT["CLOSE"] = "Close"; +Calendar._TT["TODAY"] = "Today"; +Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value"; + +// date formats +Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d"; +Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e"; + +Calendar._TT["WK"] = "wk"; diff --git a/includes/jscalendar/lang/calendar-french.js b/includes/jscalendar/lang/calendar-french.js new file mode 100644 index 00000000..aa15d504 --- /dev/null +++ b/includes/jscalendar/lang/calendar-french.js @@ -0,0 +1,45 @@ +// ** I18N +Calendar._DN = new Array +("Dimanche", + "Lundi", + "Mardi", + "Mercredi", + "Jeudi", + "Vendredi", + "Samedi", + "Dimanche"); +Calendar._MN = new Array +("Janvier", + "Février", + "Mars", + "Avril", + "Mai", + "Juin", + "Juillet", + "Août", + "Septembre", + "Octobre", + "Novembre", + "Décembre"); + +// tooltips +Calendar._TT = {}; +Calendar._TT["TOGGLE"] = "Changer le premier jour de la semaine"; +Calendar._TT["PREV_YEAR"] = "Année préc. (maintenir pour menu)"; +Calendar._TT["PREV_MONTH"] = "Mois préc. (maintenir pour menu)"; +Calendar._TT["GO_TODAY"] = "Atteindre date du jour"; +Calendar._TT["NEXT_MONTH"] = "Mois suiv. (maintenir pour menu)"; +Calendar._TT["NEXT_YEAR"] = "Année suiv. (maintenir pour menu)"; +Calendar._TT["SEL_DATE"] = "Choisir une date"; +Calendar._TT["DRAG_TO_MOVE"] = "Déplacer"; +Calendar._TT["PART_TODAY"] = " (Aujourd'hui)"; +Calendar._TT["MON_FIRST"] = "Commencer par lundi"; +Calendar._TT["SUN_FIRST"] = "Commencer par dimanche"; +Calendar._TT["CLOSE"] = "Fermer"; +Calendar._TT["TODAY"] = "Aujourd'hui"; + +// date formats +Calendar._TT["DEF_DATE_FORMAT"] = "y-mm-dd"; +Calendar._TT["TT_DATE_FORMAT"] = "D, M d"; + +Calendar._TT["WK"] = "wk"; diff --git a/includes/jscalendar/lang/calendar-german.js b/includes/jscalendar/lang/calendar-german.js new file mode 100644 index 00000000..4fecb148 --- /dev/null +++ b/includes/jscalendar/lang/calendar-german.js @@ -0,0 +1,54 @@ +// Author: Hartwig Weinkauf h_weinkauf@gmx.de +// Feel free to use / redistribute under the GNU LGPL. +// ** I18N + +// full day names +Calendar._DN = new Array +("Sonntag", + "Montag", + "Dienstag", + "Mittwoch", + "Donnerstag", + "Freitag", + "Samstag", + "Sonntag"); + +// short day names only use 2 letters instead of 3 +Calendar._SDN_len = 2; + +// full month names +Calendar._MN = new Array +("Januar", + "Februar", + "Maerz", + "April", + "Mai", + "Juni", + "Juli", + "August", + "September", + "Oktober", + "November", + "Dezember"); + +// tooltips +Calendar._TT = {}; +Calendar._TT["TOGGLE"] = "Ersten Tag der Woche waehlen"; +Calendar._TT["PREV_YEAR"] = "Vorheriges Jahr (gedrueckt halten fuer Auswahlmenue)"; +Calendar._TT["PREV_MONTH"] = "Vorheriger Monat (gedrueckt halten fuer Auswahlmenue)"; +Calendar._TT["GO_TODAY"] = "Gehe zum heutigen Datum"; +Calendar._TT["NEXT_MONTH"] = "Folgender Monat (gedrueckt halten fuer Auswahlmenue)"; +Calendar._TT["NEXT_YEAR"] = "Folgendes Jahr (gedrueckt halten fuer Auswahlmenue)"; +Calendar._TT["SEL_DATE"] = "Datum auswaehlen"; +Calendar._TT["DRAG_TO_MOVE"] = "Klicken und gedrueckt halten um zu verschieben"; +Calendar._TT["PART_TODAY"] = " (heute)"; +Calendar._TT["MON_FIRST"] = "Wochenanzeige mit Montag beginnen"; +Calendar._TT["SUN_FIRST"] = "Wochenanzeige mit Sonntag beginnen"; +Calendar._TT["CLOSE"] = "Schliessen"; +Calendar._TT["TODAY"] = "Heute"; + +// date formats +Calendar._TT["DEF_DATE_FORMAT"] = "dd-mm-y"; +Calendar._TT["TT_DATE_FORMAT"] = "DD, d MM"; + +Calendar._TT["WK"] = "KW"; diff --git a/includes/jscalendar/lang/calendar-italian.js b/includes/jscalendar/lang/calendar-italian.js new file mode 100644 index 00000000..05a37cd0 --- /dev/null +++ b/includes/jscalendar/lang/calendar-italian.js @@ -0,0 +1,45 @@ +// ** I18N +Calendar._DN = new Array +("Domenica", + "Lunedì", + "Martedì", + "Mercoledì", + "Giovedì", + "Venerdì", + "Sabato", + "Domenica"); +Calendar._MN = new Array +("Gennaio", + "Febbraio", + "Marzo", + "Aprile", + "Maggio", + "Giugno", + "Luglio", + "Agosto", + "Settembre", + "Ottobre", + "Novembre", + "Dicembre"); + +// tooltips +Calendar._TT = {}; +Calendar._TT["TOGGLE"] = "Modifica il primo giorno della settimana"; +Calendar._TT["PREV_YEAR"] = "Anno prec. (tieni premuto per menu)"; +Calendar._TT["PREV_MONTH"] = "Mese prec. (tieni premuto per menu)"; +Calendar._TT["GO_TODAY"] = "Vai a oggi"; +Calendar._TT["NEXT_MONTH"] = "Mese succ. (tieni premuto per menu)"; +Calendar._TT["NEXT_YEAR"] = "Anno succ. (tieni premuto per menu)"; +Calendar._TT["SEL_DATE"] = "Seleziona data"; +Calendar._TT["DRAG_TO_MOVE"] = "Trascina per spostare"; +Calendar._TT["PART_TODAY"] = " (oggi)"; +Calendar._TT["MON_FIRST"] = "Parti da lunedì"; +Calendar._TT["SUN_FIRST"] = "Parti da domenica"; +Calendar._TT["CLOSE"] = "Chiudi"; +Calendar._TT["TODAY"] = "Oggi"; + +// date formats +Calendar._TT["DEF_DATE_FORMAT"] = "y-mm-dd"; +Calendar._TT["TT_DATE_FORMAT"] = "D, M d"; + +Calendar._TT["WK"] = "wk"; diff --git a/includes/jscalendar/lang/calendar-russian.js b/includes/jscalendar/lang/calendar-russian.js new file mode 100644 index 00000000..459cec57 --- /dev/null +++ b/includes/jscalendar/lang/calendar-russian.js @@ -0,0 +1,45 @@ +// ** I18N +Calendar._DN = new Array +("Âîñêðåñåíüå", + "Ïîíåäåëüíèê", + "Âòîðíèê", + "Ñðåäà", + "×åòâåðã", + "Ïÿòíèöà", + "Ñóááîòà", + "Âîñêðåñåíüå"); +Calendar._MN = new Array +("ßíâàðü", + "Ôåâðàëü", + "Ìàðò", + "Àïðåëü", + "Ìàé", + "Èþíü", + "Èþëü", + "Àâãóñò", + "Ñåíòÿáðü", + "Îêòÿáðü", + "Íîÿáðü", + "Äåêàáðü"); + +// tooltips +Calendar._TT = {}; +Calendar._TT["TOGGLE"] = "Ñìåíèòü äåíü íà÷àëà íåäåëè (ÏÍ/ÂÑ)"; +Calendar._TT["PREV_YEAR"] = "Ïðåä. ãîä (óäåðæèâàòü äëÿ ìåíþ)"; +Calendar._TT["PREV_MONTH"] = "Ïðåä. ìåñÿö (óäåðæèâàòü äëÿ ìåíþ)"; +Calendar._TT["GO_TODAY"] = "Íà ñåãîäíÿ"; +Calendar._TT["NEXT_MONTH"] = "Ñëåä. ìåñÿö (óäåðæèâàòü äëÿ ìåíþ)"; +Calendar._TT["NEXT_YEAR"] = "Ñëåä. ãîä (óäåðæèâàòü äëÿ ìåíþ)"; +Calendar._TT["SEL_DATE"] = "Âûáðàòü äàòó"; +Calendar._TT["DRAG_TO_MOVE"] = "Ïåðåòàùèòü"; +Calendar._TT["PART_TODAY"] = " (ñåãîäíÿ)"; +Calendar._TT["MON_FIRST"] = "Ïîêàçàòü ïîíåäåëüíèê ïåðâûì"; +Calendar._TT["SUN_FIRST"] = "Ïîêàçàòü âîñêðåñåíüå ïåðâûì"; +Calendar._TT["CLOSE"] = "Çàêðûòü"; +Calendar._TT["TODAY"] = "Ñåãîäíÿ"; + +// date formats +Calendar._TT["DEF_DATE_FORMAT"] = "y-mm-dd"; +Calendar._TT["TT_DATE_FORMAT"] = "D, M d"; + +Calendar._TT["WK"] = "íåä"; diff --git a/includes/jscalendar/lang/calendar-spanish.js b/includes/jscalendar/lang/calendar-spanish.js new file mode 100644 index 00000000..14a356d3 --- /dev/null +++ b/includes/jscalendar/lang/calendar-spanish.js @@ -0,0 +1,45 @@ +// ** I18N +Calendar._DN = new Array +("Domingo", + "Lunes", + "Martes", + "Miercoles", + "Jueves", + "Viernes", + "Sabado", + "Domingo"); +Calendar._MN = new Array +("Enero", + "Febrero", + "Marzo", + "Abril", + "Mayo", + "Junio", + "Julio", + "Augosto", + "Septiembre", + "Octubrer", + "Noviembre", + "Diciembre"); + +// tooltips +Calendar._TT = {}; +Calendar._TT["TOGGLE"] = "Primer dia de la semana"; +Calendar._TT["PREV_YEAR"] = "Año anterior (Presione para menu)"; +Calendar._TT["PREV_MONTH"] = "Mes Anterior (Presione para menu)"; +Calendar._TT["GO_TODAY"] = "Ir a Hoy"; +Calendar._TT["NEXT_MONTH"] = "Mes Siguiente (Presione para menu)"; +Calendar._TT["NEXT_YEAR"] = "Año Siguiente (Presione para menu)"; +Calendar._TT["SEL_DATE"] = "Seleccione fecha"; +Calendar._TT["DRAG_TO_MOVE"] = "Arrastre y mueva"; +Calendar._TT["PART_TODAY"] = " (Hoy)"; +Calendar._TT["MON_FIRST"] = "Lunes Primero"; +Calendar._TT["SUN_FIRST"] = "Domingo Primero"; +Calendar._TT["CLOSE"] = "Cerrar"; +Calendar._TT["TODAY"] = "Hoy"; + +// date formats +Calendar._TT["DEF_DATE_FORMAT"] = "dd-mm-yy"; +Calendar._TT["TT_DATE_FORMAT"] = "D, d M"; + +Calendar._TT["WK"] = "Smn"; diff --git a/includes/jscalendar/menuarrow.gif b/includes/jscalendar/menuarrow.gif new file mode 100644 index 0000000000000000000000000000000000000000..ed2dee0e6368d201bf5d32833884c7c1da6c7424 GIT binary patch literal 68 zcmZ?wbhEHbWM^Py_{hZ2(9rPi-LwDy|1&T!DE?$&WME)o&;ha;K=KSsqAVN&i(DE6 VRJ~d>0vEY-3aNTcS;53$4FHxP5xxKb literal 0 HcmV?d00001 diff --git a/includes/overlib/mini/overlib_anchor_mini.js b/includes/overlib/mini/overlib_anchor_mini.js new file mode 100644 index 00000000..69c3059d --- /dev/null +++ b/includes/overlib/mini/overlib_anchor_mini.js @@ -0,0 +1,146 @@ +//\///// +//\ overLIB Anchor Plugin +//\ This file requires overLIB 4.00 or later. +//\ +//\ overLIB 4.05 - You may not remove or change this notice. +//\ Copyright Erik Bosrup 1998-2004. All rights reserved. +//\ Contributors are listed on the homepage. +//\ See http://www.bosrup.com/web/overlib/ for details. +//\///// +if (typeof olInfo=='undefined'||olInfo.simpleversion<400) alert('overLIB 4.00 or later is required for the Anchor Plugin.');registerCommands('anchor,anchorx,anchory,noanchorwarn,anchoralign'); +if (typeof ol_anchor=='undefined') var ol_anchor='';if (typeof ol_anchorx=='undefined') var ol_anchorx=0;if (typeof ol_anchory=='undefined') var ol_anchory=0;if (typeof ol_noanchorwarn=='undefined') var ol_noanchorwarn=1;if (typeof ol_anchoralign=='undefined') var ol_anchoralign='UL'; +var o3_anchor="";var o3_anchorx=0;var o3_anchory=0;var o3_noanchorwarn=1;var o3_anchoralign='UL';var mrkObj, rmrkPosition; +function setAnchorVariables() {o3_anchor=ol_anchor;o3_anchorx=ol_anchorx;o3_anchory=ol_anchory;o3_noanchorwarn=ol_noanchorwarn;o3_anchoralign=ol_anchoralign;mrkObj=null;} +function parseAnchorExtras(pf,i,ar) {var v, k=i; +if (k-1||o3_relx!=null) { +placeX=(o3_relx!=null?( o3_relx<0?winoffset+o3_relx+iwidth-parsedWidth-widthFix:winoffset+o3_relx):o3_fixx);} else { +if (o3_hauto==1) {if ((o3_x-winoffset)>(iwidth/2)) {o3_hpos=LEFT;} else {o3_hpos=RIGHT;} +} +if (o3_hpos==CENTER) {placeX=o3_x+o3_offsetx-(parsedWidth/2); +if (placeX(winoffset+iwidth-widthFix)) {placeX=iwidth+winoffset-parsedWidth-widthFix;if (placeX<0) placeX=0;} +} +if (o3_hpos==LEFT) {placeX=o3_x-o3_offsetx-parsedWidth;if (placeX1) {var snapping=placeX % o3_snapx; +if (o3_hpos==LEFT) {placeX=placeX-(o3_snapx+snapping);} else { +placeX=placeX+(o3_snapx-snapping);} +if (placeX-1||o3_rely!=null) { +placeY=(o3_rely!=null?(o3_rely<0?scrolloffset+o3_rely+iheight-parsedHeight:scrolloffset+o3_rely):o3_fixy);} else { +if (o3_vauto==1) {if ((o3_y-scrolloffset)>(iheight/2)) {o3_vpos=ABOVE;} else {o3_vpos=BELOW;} +} +if (o3_vpos==ABOVE) {if (o3_aboveheight==0) o3_aboveheight=parsedHeight; +placeY=o3_y-(o3_aboveheight+o3_offsety);if (placeY1) {var snapping=placeY % o3_snapy; +if (o3_aboveheight>0&&o3_vpos==ABOVE) {placeY=placeY-(o3_snapy+snapping);} else {placeY=placeY+(o3_snapy-snapping);} +if (placeY1) {mkObj=mlyr[0] +offsets[0]+=mlyr[0].x+mlyr[1].pageX +offsets[1]+=mlyr[0].y+mlyr[1].pageY +} else {if(mlyr.toString().indexOf('Image')!=-1||mlyr.toString().indexOf('Anchor')!=-1){offsets[0]+=mlyr.x +offsets[1]+=mlyr.y +} else {offsets[0]+=mlyr.pageX +offsets[1]+=mlyr.pageY +} +} +} else {offsets[0]+=pageLocation(mlyr, 'Left') +offsets[1]+=pageLocation(mlyr, 'Top') +} +of=getAnchorOffsets(mkObj) +if (typeof o3_dragimg!='undefined'&& o3_dragimg) {olImgLeft=offsets[0];olImgTop=offsets[1];} +offsets[0]+=of[0] +offsets[1]+=of[1] +if (typeof o3_dragimg!='undefined'&& o3_dragimg) {olImgRight=offsets[0];olImgBottom=offsets[1];return;} +return offsets;} +function getAnchorOffsets(mkObj){var fx=fy=0, mp, puc, mkAry, sx=sy=0, w=o3_anchoralign +var mW=mH=pW=pH=0 +var off=[0, 0] +mkAry=w.split(','); +if (mkAry.length<3) {mp=mkAry[0].toUpperCase();puc=(mkAry.length==1)?mp:mkAry[1].toUpperCase();} else if (mkAry.length==3) {if (!isNaN(mkAry[0])) {mp=mkAry.slice(0, 2);puc=mkAry[2].toUpperCase();} else {mp=mkAry[0].toUpperCase();puc=mkAry.slice(1);} +} else {mp=mkAry.slice(0, 2);puc=mkAry.slice(2);} +var shdwPresent=typeof o3_shadow!='undefined'&& o3_shadow +if (shdwPresent) {sx=Math.abs(o3_shadowx);sy=Math.abs(o3_shadowy);} +pW=(shdwPresent?parseInt(o3_width):(olNs4?over.clip.width:over.offsetWidth)) +pH=(shdwPresent?parseInt(o3_aboveheight):(olNs4?over.clip.height:over.offsetHeight)) +if (olOp&& o3_wrap) {pW=(shdwPresent?parseInt(o3_width):(olNs4?over.clip.width:over.offsetWidth)) +pH=(shdwPresent?parseInt(o3_aboveheight):(olNs4?over.clip.height:over.offsetHeight)) +} +if (!olOp&& mkObj.toString().indexOf('Image')!=-1){mW=mkObj.width +mH=mkObj.height +} else if (!olOp&& mkObj.toString().indexOf('Anchor')!=-1) {mp='UL' +} else {mW=(olNs4)?mkObj.clip.width:mkObj.offsetWidth +mH=(olNs4)?mkObj.clip.height:mkObj.offsetHeight +} +if (!isNaN(mp)||typeof mp=='object') {if (typeof mp=='object') {fx=parseFloat(mp[0]);fy=parseFloat(mp[1]);} else +fx=fy=parseFloat(mp);off=[Math.round(fx*mW), Math.round(fy*mH)];} else {if (mp=='UR') off=[mW, 0] +else if (mp=='LL') off=[0, mH] +else if (mp=='LR') off=[mW, mH] +} +if (typeof o3_dragimg!='undefined'&& o3_dragimg) return off;else {if (!isNaN(puc)||typeof puc=='object' ) {if (typeof puc=='object') {fx=parseFloat(puc[0]);fy=parseFloat(puc[1]);} else +fx=fy=parseFloat(puc);off[0]-=Math.round(fx*(pW-sx));off[1]-=Math.round(fy*(pH-sy));} else {if (puc=='UR') {off[0]-=(pW-sx);off[1]-=sy +} else if (puc=='LL') {off[0]-=sx;off[1]-=(pH-sy) +} else if (puc=='LR') {off[0]-=(pW-sx);off[1]-=(pH-sy) +} +} +return off +} +} +function pageLocation(o, t){var x=0 +while(o.offsetParent){x+=o['offset'+t] +o=o.offsetParent +} +x+=o['offset'+t] +return x +} +function getRefById(l, d){var r="", j +d=(d||document) +if (d.all) return d.all[l] +else if (d.getElementById) return d.getElementById(l) +else if (d.layers&& d.layers.length>0) {if (d.layers[l]) return d.layers[l] +for (j=0; j0) {for (j=0; j0) return r +else if (r) return [r, d.layers[j]] +} +} +return null +} +registerHook("placeLayer", anchorPlaceLayer, FREPLACE);registerRunTimeFunction(setAnchorVariables);registerCmdLineFunction(parseAnchorExtras);registerPostParseFunction(checkAnchorObject);registerHook("createPopup", anchorPreface, FAFTER); diff --git a/includes/overlib/mini/overlib_crossframe_mini.js b/includes/overlib/mini/overlib_crossframe_mini.js new file mode 100644 index 00000000..a4dd8752 --- /dev/null +++ b/includes/overlib/mini/overlib_crossframe_mini.js @@ -0,0 +1,44 @@ +//\///// +//\ overLIB Crossframe Support Plugin +//\ This file requires overLIB 4.00 or later. +//\ +//\ overLIB 4.05 - You may not remove or change this notice. +//\ Copyright Erik Bosrup 1998-2004. All rights reserved. +//\ Contributors are listed on the homepage. +//\ See http://www.bosrup.com/web/overlib/ for details. +//\///// +if (typeof olInfo=='undefined'||olInfo.simpleversion<400) alert('overLIB 4.00 or later is required for the Cross Frame Support Plugin.');registerCommands('frame'); +function parseFrameExtras(pf,i,ar) {var k=i,v; +if (k0) {retVal=frmDepth(thisFrame[i],ofrm);if (retVal=='') continue;} else if (thisFrame[i]!=ofrm) continue;retVal='['+i+']'+retVal;break;} +return retVal;} +function getFrmRef(srcFrm,tgetFrm) {var rtnVal='' +if (tgetFrm!=srcFrm) {var tFrm=frmDepth(top.frames,tgetFrm) +var sFrm=frmDepth(top.frames,srcFrm) +if (sFrm.length==tFrm.length) {l=tFrm.lastIndexOf('[') +if (l) {while ( sFrm.substring(0,l)!=tFrm.substring(0,l) ) +l=tFrm.lastIndexOf('[',l-1) +tFrm=tFrm.substr(l) +sFrm=sFrm.substr(l) +} +} +var cnt=0, p='',str=tFrm +while ((k=str.lastIndexOf('['))!=-1) {cnt++ +str=str.substring(0,k) +} +for (var i=0; i
'+text+'
';set_background(""); +return txt;} +function ol_content_caption_cssstyle(text, title, close) {var nameId;closing="";closeevent="onMouseOver"; +if (o3_closeclick==1) closeevent=(o3_closetitle?"title='"+o3_closetitle+"'":"")+" onClick"; +if (o3_capicon!="") {nameId=' hspace=\"5\"'+' align=\"middle\" alt=\"\"';if (typeof o3_dragimg!='undefined'&&o3_dragimg) nameId=' hspace=\"5\"'+' name=\"'+o3_dragimg+'\" id=\"'+o3_dragimg+'\" align=\"middle\" alt=\"Drag Enabled\" title=\"Drag Enabled\"';o3_capicon='';} +if (close!="") {closing=''+close+'';} +txt='
'+closing+'
'+o3_capicon+title+'
'+text+'
';set_background(""); +return txt;} +function ol_content_background_cssstyle(text, picture, hasfullhtml) {if (hasfullhtml) {txt=text;} else {var pU, hU, wU;pU=(o3_padunit=='%'?'%':'');hU=(o3_heightunit=='%'?'%':'');wU=(o3_widthunit=='%'?'%':'');txt='
'+text+'
';} +set_background(picture); +return txt;} +registerRunTimeFunction(setCSSStyleVariables);registerCmdLineFunction(parseCSSStyleExtras);registerHook("ol_content_simple", ol_content_simple_cssstyle, FALTERNATE, CSSSTYLE);registerHook("ol_content_caption", ol_content_caption_cssstyle, FALTERNATE, CSSSTYLE);registerHook("ol_content_background", ol_content_background_cssstyle, FALTERNATE, CSSSTYLE); \ No newline at end of file diff --git a/includes/overlib/mini/overlib_exclusive_mini.js b/includes/overlib/mini/overlib_exclusive_mini.js new file mode 100644 index 00000000..96b534c5 --- /dev/null +++ b/includes/overlib/mini/overlib_exclusive_mini.js @@ -0,0 +1,33 @@ +//\///// +//\ overLIB Exclusive Plugin +//\ This file requires overLIB 4.00 or later. +//\ +//\ overLIB 4.05 - You may not remove or change this notice. +//\ Copyright Erik Bosrup 1998-2004. All rights reserved. +//\ Contributors are listed on the homepage. +//\ See http://www.bosrup.com/web/overlib/ for details. +//\///// +if (typeof olInfo=='undefined'||olInfo.simpleversion<400) alert('overLIB 4.00 or later is required for the Debug Plugin.');registerCommands('exclusive,exclusivestatus,exclusiveoverride');var olOverrideIsSet; +if (typeof ol_exclusive=='undefined') var ol_exclusive=0;if (typeof ol_exclusivestatus=='undefined') var ol_exclusivestatus='Please close open popup first.'; +var o3_exclusive=0;var o3_exclusivestatus=''; +function setExclusiveVariables() {o3_exclusive=ol_exclusive;o3_exclusivestatus=ol_exclusivestatus;} +function parseExclusiveExtras(pf,i,ar) {var k=i,v; +olOverrideIsSet=false; +if (k-1||o3_relx!=null) { +placeX=(o3_relx!=null?( o3_relx<0?winoffset+o3_relx+iwidth-parsedWidth-widthFix:winoffset+o3_relx):o3_fixx);} else { +if (o3_hauto==1) {if ((o3_x-winoffset)>(iwidth/2)) {o3_hpos=LEFT;} else {o3_hpos=RIGHT;} +} +if (o3_hpos==CENTER) {placeX=o3_x+o3_offsetx-(parsedWidth/2); +if (placeX(winoffset+iwidth-widthFix)) {placeX=iwidth+winoffset-parsedWidth-widthFix;if (placeX<0) placeX=0;} +} +if (o3_hpos==LEFT) {placeX=o3_x-o3_offsetx-parsedWidth;if (placeX1) {var snapping=placeX % o3_snapx; +if (o3_hpos==LEFT) {placeX=placeX-(o3_snapx+snapping);} else { +placeX=placeX+(o3_snapx-snapping);} +if (placeX-1||o3_rely!=null) { +placeY=(o3_rely!=null?(o3_rely<0?scrolloffset+o3_rely+iheight-parsedHeight:scrolloffset+o3_rely):o3_fixy);} else { +if (o3_vauto==1) {if ((o3_y-scrolloffset)>(iheight/2)) {o3_vpos=ABOVE;} else {o3_vpos=BELOW;} +} +if (o3_vpos==ABOVE) {if (o3_aboveheight==0) o3_aboveheight=parsedHeight; +placeY=o3_y-(o3_aboveheight+o3_offsety);if (placeY1) {var snapping=placeY % o3_snapy; +if (o3_aboveheight>0&&o3_vpos==ABOVE) {placeY=placeY-(o3_snapy+snapping);} else {placeY=placeY+(o3_snapy-snapping);} +if (placeY'+content+'';layerWrite(txt);} +function bckDropSrc(width, height, Z) {return '';} +function hideSelectBox() {if(olNs4||olOp||olIe55) return;var px, py, pw, ph, sx, sw, sy, sh, selEl, v; +if(olIe4) v=0;else {v=navigator.userAgent.match(/Gecko\/(\d{8})/i);if(!v) return;v=parseInt(v[1]);} +if (v<20030624) {px=parseInt(over.style.left);py=parseInt(over.style.top);pw=o3_width;ph=(o3_aboveheight?parseInt(o3_aboveheight):over.offsetHeight);selEl=(olIe4)?o3_frame.document.all.tags("SELECT"):o3_frame.document.getElementsByTagName("SELECT");for (var i=0; i(sx+sw)||(py+ph)(sy+sh)) continue;selEl[i].isHidden=1;selEl[i].style.visibility='hidden';} +} +} +function showSelectBox() {if(olNs4||olOp||olIe55) return;var selEl, v; +if(olIe4) v=0;else {v=navigator.userAgent.match(/Gecko\/(\d{8})/i);if(!v) return;v=parseInt(v[1]);} +if(v<20030624) {selEl=(olIe4)?o3_frame.document.all.tags("SELECT"):o3_frame.document.getElementsByTagName("SELECT");for (var i=0; i\n\n');} +f=capExtent.onmousemove.toString().match(/function[ ]+(\w*)\(/);if (f&&f[1]!='annoymous') capExtent.onmousemove=olMouseMove;} +registerHook("createPopup",generatePopUp,FAFTER);registerHook("hideObject",showSelectBox,FAFTER);olHideForm=1; \ No newline at end of file diff --git a/includes/overlib/mini/overlib_mini.js b/includes/overlib/mini/overlib_mini.js new file mode 100644 index 00000000..6afb273b --- /dev/null +++ b/includes/overlib/mini/overlib_mini.js @@ -0,0 +1,337 @@ +//\///// +//\ overLIB 4.06 - You may not remove or change this notice. +//\ Copyright Erik Bosrup 1998-2004. All rights reserved. +//\ +//\ Contributors are listed on the homepage. +//\ This file might be old, always check for the latest version at: +//\ http://www.bosrup.com/web/overlib/ +//\ +//\ Please read the license agreement (available through the link above) +//\ before using overLIB. Direct any licensing questions to erik@bosrup.com. +//\ +//\ Do not sell this as your own work or remove this copyright notice. +//\ For full details on copying or changing this script please read the +//\ license agreement at the link above. Please give credit on sites that +//\ use overLIB and submit changes of the script so other people can use +//\ them as well. +//\///// +//\ THIS IS A VERY MODIFIED VERSION. DO NOT EDIT OR PUBLISH. GET THE ORIGINAL! +var olLoaded=0;var pmStart=10000000; var pmUpper=10001000; var pmCount=pmStart+1; var pms=new Array(); var olInfo=new Info('4.06', 1);var FREPLACE=0; var FBEFORE=1; var FAFTER=2; var FALTERNATE=3;var olHideForm=0;registerCommands('donothing,inarray,caparray,sticky,background,noclose,caption,left,right,center,offsetx,offsety,fgcolor,bgcolor,textcolor,capcolor,closecolor,width,border,cellpad,status,autostatus,autostatuscap,height,closetext,snapx,snapy,fixx,fixy,relx,rely,fgbackground,bgbackground,padx,pady,fullhtml,above,below,capicon,textfont,captionfont,closefont,textsize,captionsize,closesize,timeout,function,delay,hauto,vauto,closeclick,wrap,followmouse,mouseoff,closetitle,cssoff,compatmode,cssclass,fgclass,bgclass,textfontclass,captionfontclass,closefontclass'); +if (typeof ol_fgcolor=='undefined') var ol_fgcolor="#CCCCFF";if (typeof ol_bgcolor=='undefined') var ol_bgcolor="#333399";if (typeof ol_textcolor=='undefined') var ol_textcolor="#000000";if (typeof ol_capcolor=='undefined') var ol_capcolor="#FFFFFF";if (typeof ol_closecolor=='undefined') var ol_closecolor="#9999FF";if (typeof ol_textfont=='undefined') var ol_textfont="Verdana,Arial,Helvetica";if (typeof ol_captionfont=='undefined') var ol_captionfont="Verdana,Arial,Helvetica";if (typeof ol_closefont=='undefined') var ol_closefont="Verdana,Arial,Helvetica";if (typeof ol_textsize=='undefined') var ol_textsize="1";if (typeof ol_captionsize=='undefined') var ol_captionsize="1";if (typeof ol_closesize=='undefined') var ol_closesize="1";if (typeof ol_width=='undefined') var ol_width="200";if (typeof ol_border=='undefined') var ol_border="1";if (typeof ol_cellpad=='undefined') var ol_cellpad=2;if (typeof ol_offsetx=='undefined') var ol_offsetx=10;if (typeof ol_offsety=='undefined') var ol_offsety=10;if (typeof ol_text=='undefined') var ol_text="Default Text";if (typeof ol_cap=='undefined') var ol_cap="";if (typeof ol_sticky=='undefined') var ol_sticky=0;if (typeof ol_background=='undefined') var ol_background="";if (typeof ol_close=='undefined') var ol_close="Close";if (typeof ol_hpos=='undefined') var ol_hpos=RIGHT;if (typeof ol_status=='undefined') var ol_status="";if (typeof ol_autostatus=='undefined') var ol_autostatus=0;if (typeof ol_height=='undefined') var ol_height=-1;if (typeof ol_snapx=='undefined') var ol_snapx=0;if (typeof ol_snapy=='undefined') var ol_snapy=0;if (typeof ol_fixx=='undefined') var ol_fixx=-1;if (typeof ol_fixy=='undefined') var ol_fixy=-1;if (typeof ol_relx=='undefined') var ol_relx=null;if (typeof ol_rely=='undefined') var ol_rely=null;if (typeof ol_fgbackground=='undefined') var ol_fgbackground="";if (typeof ol_bgbackground=='undefined') var ol_bgbackground="";if (typeof ol_padxl=='undefined') var ol_padxl=1;if (typeof ol_padxr=='undefined') var ol_padxr=1;if (typeof ol_padyt=='undefined') var ol_padyt=1;if (typeof ol_padyb=='undefined') var ol_padyb=1;if (typeof ol_fullhtml=='undefined') var ol_fullhtml=0;if (typeof ol_vpos=='undefined') var ol_vpos=BELOW;if (typeof ol_aboveheight=='undefined') var ol_aboveheight=0;if (typeof ol_capicon=='undefined') var ol_capicon="";if (typeof ol_frame=='undefined') var ol_frame=self;if (typeof ol_timeout=='undefined') var ol_timeout=0;if (typeof ol_function=='undefined') var ol_function=null;if (typeof ol_delay=='undefined') var ol_delay=0;if (typeof ol_hauto=='undefined') var ol_hauto=0;if (typeof ol_vauto=='undefined') var ol_vauto=0;if (typeof ol_closeclick=='undefined') var ol_closeclick=0;if (typeof ol_wrap=='undefined') var ol_wrap=0;if (typeof ol_followmouse=='undefined') var ol_followmouse=1;if (typeof ol_mouseoff=='undefined') var ol_mouseoff=0;if (typeof ol_closetitle=='undefined') var ol_closetitle='Close';if (typeof ol_compatmode=='undefined') var ol_compatmode=0;if (typeof ol_css=='undefined') var ol_css=CSSOFF;if (typeof ol_fgclass=='undefined') var ol_fgclass="";if (typeof ol_bgclass=='undefined') var ol_bgclass="";if (typeof ol_textfontclass=='undefined') var ol_textfontclass="";if (typeof ol_captionfontclass=='undefined') var ol_captionfontclass="";if (typeof ol_closefontclass=='undefined') var ol_closefontclass=""; +if (typeof ol_texts=='undefined') var ol_texts=new Array("Text 0", "Text 1");if (typeof ol_caps=='undefined') var ol_caps=new Array("Caption 0", "Caption 1"); +var o3_text="";var o3_cap="";var o3_sticky=0;var o3_background="";var o3_close="Close";var o3_hpos=RIGHT;var o3_offsetx=2;var o3_offsety=2;var o3_fgcolor="";var o3_bgcolor="";var o3_textcolor="";var o3_capcolor="";var o3_closecolor="";var o3_width=100;var o3_border=1;var o3_cellpad=2;var o3_status="";var o3_autostatus=0;var o3_height=-1;var o3_snapx=0;var o3_snapy=0;var o3_fixx=-1;var o3_fixy=-1;var o3_relx=null;var o3_rely=null;var o3_fgbackground="";var o3_bgbackground="";var o3_padxl=0;var o3_padxr=0;var o3_padyt=0;var o3_padyb=0;var o3_fullhtml=0;var o3_vpos=BELOW;var o3_aboveheight=0;var o3_capicon="";var o3_textfont="Verdana,Arial,Helvetica";var o3_captionfont="Verdana,Arial,Helvetica";var o3_closefont="Verdana,Arial,Helvetica";var o3_textsize="1";var o3_captionsize="1";var o3_closesize="1";var o3_frame=self;var o3_timeout=0;var o3_timerid=0;var o3_allowmove=0;var o3_function=null;var o3_delay=0;var o3_delayid=0;var o3_hauto=0;var o3_vauto=0;var o3_closeclick=0;var o3_wrap=0;var o3_followmouse=1;var o3_mouseoff=0;var o3_closetitle='';var o3_compatmode=0;var o3_css=CSSOFF;var o3_fgclass="";var o3_bgclass="";var o3_textfontclass="";var o3_captionfontclass="";var o3_closefontclass=""; +var o3_x=0;var o3_y=0;var o3_showingsticky=0;var o3_removecounter=0; +var over=null;var fnRef, hoveringSwitch=false; +var isMac=(navigator.userAgent.indexOf("Mac")!=-1);var olOp=(navigator.userAgent.toLowerCase().indexOf('opera')>-1&&document.createTextNode);var olNs4=(navigator.appName=='Netscape'&&parseInt(navigator.appVersion)==4);var olNs6=(document.getElementById)?true:false;var olIe4=(document.all)?true:false;var olIe5=false;var olIe55=false;var docRoot='document.body'; +if (olNs4) {var oW=window.innerWidth;var oH=window.innerHeight;window.onresize=function() { if (oW!=window.innerWidth||oH!=window.innerHeight) location.reload(); } +} +if (olIe4) {var agent=navigator.userAgent;if (/MSIE/.test(agent)) {var versNum=parseFloat(agent.match(/MSIE (\d\.\d+)\.*/)[1]);if (versNum>=5){olIe5=true;olIe55=(versNum>=5.5&&!olOp)?true:false;if (olNs6) olNs6=false;} +} +if (olNs6) olIe4=false;} +if (document.compatMode&&document.compatMode=='CSS1Compat') {docRoot=((olIe4&&!olOp)?'document.documentElement':docRoot);} +if(window.addEventListener) window.addEventListener("load",OLonLoad_handler,false);else if (window.attachEvent) window.attachEvent("onload",OLonLoad_handler); +var olCheckMouseCapture=true;if ((olNs4||olNs6||olIe4)) {olMouseCapture();} else {overlib=no_overlib;nd=no_overlib;ver3fix=true;} +function overlib() {if (!olLoaded||isExclusive(overlib.arguments)) return true;if (olCheckMouseCapture) olMouseCapture();if (over) cClick(); +o3_text=ol_text;o3_cap=ol_cap;o3_sticky=ol_sticky;o3_background=ol_background;o3_close=ol_close;o3_hpos=ol_hpos;o3_offsetx=ol_offsetx;o3_offsety=ol_offsety;o3_fgcolor=ol_fgcolor;o3_bgcolor=ol_bgcolor;o3_textcolor=ol_textcolor;o3_capcolor=ol_capcolor;o3_closecolor=ol_closecolor;o3_width=ol_width;o3_border=ol_border;o3_cellpad=ol_cellpad;o3_status=ol_status;o3_autostatus=ol_autostatus;o3_height=ol_height;o3_snapx=ol_snapx;o3_snapy=ol_snapy;o3_fixx=ol_fixx;o3_fixy=ol_fixy;o3_relx=ol_relx;o3_rely=ol_rely;o3_fgbackground=ol_fgbackground;o3_bgbackground=ol_bgbackground;o3_padxl=ol_padxl;o3_padxr=ol_padxr;o3_padyt=ol_padyt;o3_padyb=ol_padyb;o3_fullhtml=ol_fullhtml;o3_vpos=ol_vpos;o3_aboveheight=ol_aboveheight;o3_capicon=ol_capicon;o3_textfont=ol_textfont;o3_captionfont=ol_captionfont;o3_closefont=ol_closefont;o3_textsize=ol_textsize;o3_captionsize=ol_captionsize;o3_closesize=ol_closesize;o3_timeout=ol_timeout;o3_function=ol_function;o3_delay=ol_delay;o3_hauto=ol_hauto;o3_vauto=ol_vauto;o3_closeclick=ol_closeclick;o3_wrap=ol_wrap;o3_followmouse=ol_followmouse;o3_mouseoff=ol_mouseoff;o3_closetitle=ol_closetitle;o3_css=ol_css;o3_compatmode=ol_compatmode;o3_fgclass=ol_fgclass;o3_bgclass=ol_bgclass;o3_textfontclass=ol_textfontclass;o3_captionfontclass=ol_captionfontclass;o3_closefontclass=ol_closefontclass; +setRunTimeVariables(); +fnRef=''; +o3_frame=ol_frame; +if (olNs4) {over=o3_frame.document.layers['overDiv'];} else if (document.all) {over=o3_frame.document.all['overDiv'];} else if (document.getElementById) {over=o3_frame.document.getElementById("overDiv");} +parseTokens('o3_', overlib.arguments);if (!postParseChecks()) return false; +if (o3_delay==0) {return runHook("olMain", FREPLACE);} else {o3_delayid=setTimeout("runHook('olMain', FREPLACE)", o3_delay);return false;} +} +function nd(time) {if (olLoaded&&!isExclusive()) {if (time&&!o3_delay) {if (o3_timerid>0) clearTimeout(o3_timerid); +o3_timerid=setTimeout("cClick()",(o3_timeout=time));} +if (o3_removecounter>=1) { o3_showingsticky=0 }; +if (o3_showingsticky==0) {o3_allowmove=0;if (over!=null&&o3_timerid==0) runHook("hideObject", FREPLACE, over);} else {o3_removecounter++;} +} +return true;} +function cClick() {if (olLoaded) {runHook("hideObject", FREPLACE, over);o3_showingsticky=0;} +return false;} +function overlib_pagedefaults() {parseTokens('ol_', overlib_pagedefaults.arguments);} +function olMain() {var layerhtml, styleType;runHook("olMain", FBEFORE); +if (o3_background!=""||o3_fullhtml) { +layerhtml=runHook('ol_content_background', FALTERNATE, o3_css, o3_text, o3_background, o3_fullhtml);} else { +styleType=(pms[o3_css-1-pmStart]=="cssoff"||pms[o3_css-1-pmStart]=="cssclass"); +if (o3_fgbackground!="") o3_fgbackground="background=\""+o3_fgbackground+"\"";if (o3_bgbackground!="") o3_bgbackground=(styleType?"background=\""+o3_bgbackground+"\"":o3_bgbackground); +if (o3_fgcolor!="") o3_fgcolor=(styleType?"bgcolor=\""+o3_fgcolor+"\"":o3_fgcolor);if (o3_bgcolor!="") o3_bgcolor=(styleType?"bgcolor=\""+o3_bgcolor+"\"":o3_bgcolor); +if (o3_height>0) o3_height=(styleType?"height=\""+o3_height+"\"":o3_height);else o3_height=""; +if (o3_cap=="") { +layerhtml=runHook('ol_content_simple', FALTERNATE, o3_css, o3_text);} else { +if (o3_sticky) { +layerhtml=runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, o3_close);} else { +layerhtml=runHook('ol_content_caption', FALTERNATE, o3_css, o3_text, o3_cap, "");} +} +} +if (o3_sticky) {if (o3_timerid>0) {clearTimeout(o3_timerid);o3_timerid=0;} +o3_showingsticky=1;o3_removecounter=0;} +if (!runHook("createPopup", FREPLACE, layerhtml)) return false; +if (o3_autostatus>0) {o3_status=o3_text;if (o3_autostatus>1) o3_status=o3_cap;} +o3_allowmove=0; +if (o3_timeout>0) {if (o3_timerid>0) clearTimeout(o3_timerid);o3_timerid=setTimeout("cClick()", o3_timeout);} +runHook("disp", FREPLACE, o3_status);runHook("olMain", FAFTER); +return (olOp&&event&&event.type=='mouseover'&&!o3_status)?'':(o3_status!='');} +function ol_content_simple(text) {txt='
':'>')+(o3_textfontclass?'':wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass?'':wrapStr(1,o3_textsize))+'
'; +set_background("");return txt;} +function ol_content_caption(text,title,close) {var nameId;closing="";closeevent="onmouseover";if (o3_closeclick==1) closeevent=(o3_closetitle?"title='"+o3_closetitle+"'":"")+" onclick";if (o3_capicon!="") {nameId=' hspace=\"5\"'+' align=\"middle\" alt=\"\"';if (typeof o3_dragimg!='undefined'&&o3_dragimg) nameId=' hspace=\"5\"'+' name=\"'+o3_dragimg+'\" id=\"'+o3_dragimg+'\" align=\"middle\" alt=\"Drag Enabled\" title=\"Drag Enabled\"';o3_capicon='';} +if (close!="") +closing=''+(o3_closefontclass?'':wrapStr(0,o3_closesize,'close'))+close+(o3_closefontclass?'':wrapStr(1,o3_closesize,'close'))+'';txt='
':'>')+(o3_captionfontclass?'':''+wrapStr(0,o3_captionsize,'caption'))+o3_capicon+title+(o3_captionfontclass?'':wrapStr(1,o3_captionsize)+'')+''+closing+'
' :'>')+(o3_textfontclass?'':wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass?'':wrapStr(1,o3_textsize))+'
'; +set_background("");return txt;} +function ol_content_background(text,picture,hasfullhtml) {if (hasfullhtml) {txt=text;} else {txt='
'+(o3_textfontclass?'':wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass?'':wrapStr(1,o3_textsize))+'
';} +set_background(picture);return txt;} +function set_background(pic) {if (pic=="") {if (olNs4) {over.background.src=null;} else if (over.style) {over.style.backgroundImage="none";} +} else {if (olNs4) {over.background.src=pic;} else if (over.style) {over.style.backgroundImage="url("+pic+")";} +} +} +var olShowId=-1; +function disp(statustext) {runHook("disp", FBEFORE); +if (o3_allowmove==0) {runHook("placeLayer", FREPLACE);(olNs6&&olShowId<0)?olShowId=setTimeout("runHook('showObject', FREPLACE, over)", 1):runHook("showObject", FREPLACE, over);o3_allowmove=(o3_sticky||o3_followmouse==0)?0:1;} +runHook("disp", FAFTER); +if (statustext!="") self.status=statustext;} +function createPopup(lyrContent){runHook("createPopup", FBEFORE); +if (o3_wrap&&!(olNs4||olOp)) {if (olIe4) {over.style.pixelWidth=0;} else if (olNs6) {repositionTo(over, 0,-over.offsetHeight);} +} +layerWrite(lyrContent); +if (o3_wrap) o3_width=(olNs4?over.clip.width:over.offsetWidth); +runHook("createPopup", FAFTER, lyrContent); +return true;} +function placeLayer() {var placeX, placeY, widthFix=0; +if (eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientWidth=='number'")&&eval('o3_frame.'+docRoot+'.clientWidth')) {iwidth=eval('o3_frame.'+docRoot+'.clientWidth');} else if (typeof(o3_frame.innerWidth)=='number') {widthFix=Math.ceil(1.2*(o3_frame.outerWidth-o3_frame.innerWidth));iwidth=o3_frame.innerWidth;} +winoffset=(olIe4)?eval('o3_frame.'+docRoot+'.scrollLeft'):o3_frame.pageXOffset;var parsedWidth=parseInt(o3_width); +if (o3_fixx>-1||o3_relx!=null) { +placeX=(o3_relx!=null?( o3_relx<0?winoffset+o3_relx+iwidth-parsedWidth-widthFix:winoffset+o3_relx):o3_fixx);} else { +if (o3_hauto==1) {if ((o3_x-winoffset)>(iwidth/2)) {o3_hpos=LEFT;} else {o3_hpos=RIGHT;} +} +if (o3_hpos==CENTER) {placeX=o3_x+o3_offsetx-(parsedWidth/2); +if (placeX(winoffset+iwidth-widthFix)) {placeX=iwidth+winoffset-parsedWidth-widthFix;if (placeX<0) placeX=0;} +} +if (o3_hpos==LEFT) {placeX=o3_x-o3_offsetx-parsedWidth;if (placeX1) {var snapping=placeX % o3_snapx; +if (o3_hpos==LEFT) {placeX=placeX-(o3_snapx+snapping);} else { +placeX=placeX+(o3_snapx-snapping);} +if (placeX-1||o3_rely!=null) { +placeY=(o3_rely!=null?(o3_rely<0?scrolloffset+o3_rely+iheight-parsedHeight:scrolloffset+o3_rely):o3_fixy);} else { +if (o3_vauto==1) {if ((o3_y-scrolloffset)>(iheight/2)) {o3_vpos=ABOVE;} else {o3_vpos=BELOW;} +} +if (o3_vpos==ABOVE) {if (o3_aboveheight==0) o3_aboveheight=parsedHeight; +placeY=o3_y-(o3_aboveheight+o3_offsety);if (placeY1) {var snapping=placeY % o3_snapy; +if (o3_aboveheight>0&&o3_vpos==ABOVE) {placeY=placeY-(o3_snapy+snapping);} else {placeY=placeY+(o3_snapy-snapping);} +if (placeYpmStart&&ar[i]=pmCount||ar[i]==DONOTHING) { continue; } +if (ar[i]==INARRAY) { fnMark=0; eval(pf+'text=ol_texts['+ar[++i]+'].toString()'); continue; } +if (ar[i]==CAPARRAY) { eval(pf+'cap=ol_caps['+ar[++i]+'].toString()'); continue; } +if (ar[i]==STICKY) { if (pf!='ol_') eval(pf+'sticky=1'); continue; } +if (ar[i]==BACKGROUND) { eval(pf+'background="'+ar[++i]+'"'); continue; } +if (ar[i]==NOCLOSE) { if (pf!='ol_') opt_NOCLOSE(); continue; } +if (ar[i]==CAPTION) { eval(pf+"cap='"+escSglQuote(ar[++i])+"'"); continue; } +if (ar[i]==CENTER||ar[i]==LEFT||ar[i]==RIGHT) { eval(pf+'hpos='+ar[i]); continue; } +if (ar[i]==OFFSETX) { eval(pf+'offsetx='+ar[++i]); continue; } +if (ar[i]==OFFSETY) { eval(pf+'offsety='+ar[++i]); continue; } +if (ar[i]==FGCOLOR) { eval(pf+'fgcolor="'+ar[++i]+'"'); continue; } +if (ar[i]==BGCOLOR) { eval(pf+'bgcolor="'+ar[++i]+'"'); continue; } +if (ar[i]==TEXTCOLOR) { eval(pf+'textcolor="'+ar[++i]+'"'); continue; } +if (ar[i]==CAPCOLOR) { eval(pf+'capcolor="'+ar[++i]+'"'); continue; } +if (ar[i]==CLOSECOLOR) { eval(pf+'closecolor="'+ar[++i]+'"'); continue; } +if (ar[i]==WIDTH) { eval(pf+'width='+ar[++i]); continue; } +if (ar[i]==BORDER) { eval(pf+'border='+ar[++i]); continue; } +if (ar[i]==CELLPAD) { i=opt_MULTIPLEARGS(++i,ar,(pf+'cellpad')); continue; } +if (ar[i]==STATUS) { eval(pf+"status='"+escSglQuote(ar[++i])+"'"); continue; } +if (ar[i]==AUTOSTATUS) { eval(pf+'autostatus=('+pf+'autostatus==1)?0:1'); continue; } +if (ar[i]==AUTOSTATUSCAP) { eval(pf+'autostatus=('+pf+'autostatus==2)?0:2'); continue; } +if (ar[i]==HEIGHT) { eval(pf+'height='+pf+'aboveheight='+ar[++i]); continue; } +if (ar[i]==CLOSETEXT) { eval(pf+"close='"+escSglQuote(ar[++i])+"'"); continue; } +if (ar[i]==SNAPX) { eval(pf+'snapx='+ar[++i]); continue; } +if (ar[i]==SNAPY) { eval(pf+'snapy='+ar[++i]); continue; } +if (ar[i]==FIXX) { eval(pf+'fixx='+ar[++i]); continue; } +if (ar[i]==FIXY) { eval(pf+'fixy='+ar[++i]); continue; } +if (ar[i]==RELX) { eval(pf+'relx='+ar[++i]); continue; } +if (ar[i]==RELY) { eval(pf+'rely='+ar[++i]); continue; } +if (ar[i]==FGBACKGROUND) { eval(pf+'fgbackground="'+ar[++i]+'"'); continue; } +if (ar[i]==BGBACKGROUND) { eval(pf+'bgbackground="'+ar[++i]+'"'); continue; } +if (ar[i]==PADX) { eval(pf+'padxl='+ar[++i]); eval(pf+'padxr='+ar[++i]); continue; } +if (ar[i]==PADY) { eval(pf+'padyt='+ar[++i]); eval(pf+'padyb='+ar[++i]); continue; } +if (ar[i]==FULLHTML) { if (pf!='ol_') eval(pf+'fullhtml=1'); continue; } +if (ar[i]==BELOW||ar[i]==ABOVE) { eval(pf+'vpos='+ar[i]); continue; } +if (ar[i]==CAPICON) { eval(pf+'capicon="'+ar[++i]+'"'); continue; } +if (ar[i]==TEXTFONT) { eval(pf+"textfont='"+escSglQuote(ar[++i])+"'"); continue; } +if (ar[i]==CAPTIONFONT) { eval(pf+"captionfont='"+escSglQuote(ar[++i])+"'"); continue; } +if (ar[i]==CLOSEFONT) { eval(pf+"closefont='"+escSglQuote(ar[++i])+"'"); continue; } +if (ar[i]==TEXTSIZE) { eval(pf+'textsize="'+ar[++i]+'"'); continue; } +if (ar[i]==CAPTIONSIZE) { eval(pf+'captionsize="'+ar[++i]+'"'); continue; } +if (ar[i]==CLOSESIZE) { eval(pf+'closesize="'+ar[++i]+'"'); continue; } +if (ar[i]==TIMEOUT) { eval(pf+'timeout='+ar[++i]); continue; } +if (ar[i]==FUNCTION) { if (pf=='ol_') { if (typeof ar[i+1]!='number') { v=ar[++i]; ol_function=(typeof v=='function'?v:null); }} else {fnMark=0; v=null; if (typeof ar[i+1]!='number') v=ar[++i]; opt_FUNCTION(v); } continue; } +if (ar[i]==DELAY) { eval(pf+'delay='+ar[++i]); continue; } +if (ar[i]==HAUTO) { eval(pf+'hauto=('+pf+'hauto==0)?1:0'); continue; } +if (ar[i]==VAUTO) { eval(pf+'vauto=('+pf+'vauto==0)?1:0'); continue; } +if (ar[i]==CLOSECLICK) { eval(pf+'closeclick=('+pf+'closeclick==0)?1:0'); continue; } +if (ar[i]==WRAP) { eval(pf+'wrap=('+pf+'wrap==0)?1:0'); continue; } +if (ar[i]==FOLLOWMOUSE) { eval(pf+'followmouse=('+pf+'followmouse==1)?0:1'); continue; } +if (ar[i]==MOUSEOFF) { eval(pf+'mouseoff=('+pf+'mouseoff==0)?1:0'); continue; } +if (ar[i]==CLOSETITLE) { eval(pf+"closetitle='"+escSglQuote(ar[++i])+"'"); continue; } +if (ar[i]==CSSOFF||ar[i]==CSSCLASS) { eval(pf+'css='+ar[i]); continue; } +if (ar[i]==COMPATMODE) { eval(pf+'compatmode=('+pf+'compatmode==0)?1:0'); continue; } +if (ar[i]==FGCLASS) { eval(pf+'fgclass="'+ar[++i]+'"'); continue; } +if (ar[i]==BGCLASS) { eval(pf+'bgclass="'+ar[++i]+'"'); continue; } +if (ar[i]==TEXTFONTCLASS) { eval(pf+'textfontclass="'+ar[++i]+'"'); continue; } +if (ar[i]==CAPTIONFONTCLASS) { eval(pf+'captionfontclass="'+ar[++i]+'"'); continue; } +if (ar[i]==CLOSEFONTCLASS) { eval(pf+'closefontclass="'+ar[++i]+'"'); continue; } +i=parseCmdLine(pf, i, ar);} +} +if (fnMark&&o3_function) o3_text=o3_function(); +if ((pf=='o3_')&&o3_wrap) {o3_width=0; +if (olOp||(olIe4&&isMac)) {var tReg=/<.*\n*>/ig;if (!tReg.test(o3_text)) o3_text=o3_text.replace(/[ ]+/g, ' ');if (!tReg.test(o3_cap))o3_cap=o3_cap.replace(/[ ]+/g, ' ');} +} +if ((pf=='o3_')&&o3_sticky) {if (!o3_close&&(o3_frame!=ol_frame)) o3_close=ol_close;if (o3_mouseoff&&(o3_frame==ol_frame)) opt_NOCLOSE(' ');} +} +function layerWrite(txt) {txt+="\n";if (olNs4) {var lyr=o3_frame.document.overDiv.document +lyr.write(txt) +lyr.close() +} else if (typeof over.innerHTML!='undefined') {if (olIe5&&isMac) over.innerHTML='';over.innerHTML=txt;} else {range=o3_frame.document.createRange();range.setStartAfter(over);domfrag=range.createContextualFragment(txt); +while (over.hasChildNodes()) {over.removeChild(over.lastChild);} +over.appendChild(domfrag);} +} +function showObject(obj) {runHook("showObject", FBEFORE); +var theObj=(olNs4?obj:obj.style);theObj.visibility='visible'; +runHook("showObject", FAFTER);} +function hideObject(obj) {runHook("hideObject", FBEFORE); +var theObj=(olNs4?obj:obj.style);if (olNs6&&olShowId>0) { clearTimeout(olShowId); olShowId=0; } +theObj.visibility='hidden'; +if (o3_timerid>0) clearTimeout(o3_timerid);if (o3_delayid>0) clearTimeout(o3_delayid); +o3_timerid=0;o3_delayid=0;self.status=""; +if (over.onmouseout||over.onmouseover) {if (olNs4) over.releaseEvents(Event.MOUSEOUT||Event.MOUSEOVER);over.onmouseout=over.onmouseover=null;} +runHook("hideObject", FAFTER);} +function repositionTo(obj, xL, yL) {var theObj=(olNs4?obj:obj.style);theObj.left=xL+(!olNs4?'px':0);theObj.top=yL+(!olNs4?'px':0);} +function cursorOff() {var left=parseInt(over.style.left);var top=parseInt(over.style.top);var right=left+(over.offsetWidth>=parseInt(o3_width)?over.offsetWidth:parseInt(o3_width));var bottom=top+(over.offsetHeight>=o3_aboveheight?over.offsetHeight:o3_aboveheight); +if (o3_xright||o3_ybottom) return true; +return false;} +function opt_FUNCTION(callme) {o3_text=(callme?(typeof callme=='string'?(/.+\(.*\)/.test(callme)?eval(callme):callme):callme()):(o3_function?o3_function():'No Function')); +return 0;} +function opt_NOCLOSE(unused) {if (!unused) o3_close=""; +if (olNs4) {over.captureEvents(Event.MOUSEOUT||Event.MOUSEOVER);over.onmouseover=function () { if (o3_timerid>0) { clearTimeout(o3_timerid); o3_timerid=0; } } +over.onmouseout=cClick;} else {over.onmouseover=function () {hoveringSwitch=true; if (o3_timerid>0) { clearTimeout(o3_timerid); o3_timerid=0; } } +} +return 0;} +function opt_MULTIPLEARGS(i, args, parameter) {var k=i, l, re, pV, str=''; +for(k=i; kpmStart) break;} +if(k>=args.length) l=str.length-1;else {re=eval('/,'+args[k]+'/');l=str.search(re);} +k--;str=str.substring(0, l);pV=(olNs4&&/cellpad/i.test(parameter))?str.split(',')[0]:str;eval(parameter+'="'+pV+'"'); +return k;} +function nbspCleanup() {if (o3_wrap&&(olOp||(olIe4&&isMac))) {o3_text=o3_text.replace(/\ /g, ' ');o3_cap=o3_cap.replace(/\ /g, ' ');} +} +function escSglQuote(str) {return str.toString().replace(/'/g,"\\'");} +function OLonLoad_handler(e) {var re=/\w+\(.*\)[;\s]+/g, olre=/overlib\(|nd\(|cClick\(/, fn, l, i; +if(!olLoaded) olLoaded=1; +if(window.removeEventListener&&e.eventPhase==3) window.removeEventListener("load",OLonLoad_handler,false);else if(window.detachEvent) {window.detachEvent("onload",OLonLoad_handler);var fN=document.body.getAttribute('onload');if (fN) {fN=fN.toString().match(re);if (fN&&fN.length) {for (i=0; i':''):'
';else {fontStr='o3_'+whichString+'font';fontColor='o3_'+((whichString=='caption')? 'cap':whichString)+'color';return (hasDims&&!olNs4)?(isClose?'':'
'):'';} +} +function quoteMultiNameFonts(theFont) {var v, pM=theFont.split(',');for (var i=0; i-1) {i=j;break;} +} +} +return i;} +function postParseChecks(){if (typeof postParse!='undefined'&&postParse.length) {for (var k=0; k-1) hookPt.alt[pms[CSSOFF-1-pmStart]]=fnRef; +} else if (hookType==FBEFORE||hookType==FAFTER) {var hookPt=(hookType==1?hookPt.before:hookPt.after); +if (typeof fnRef=='object') {hookPt=hookPt.concat(fnRef);} else {hookPt[hookPt.length++]=fnRef;} +if (optPm) hookPt=reOrder(hookPt, fnRef, optPm); +} else if (hookType==FALTERNATE) {if (last=='number') hookPt.alt[pms[optPm-1-pmStart]]=fnRef;} +return;} +} +function registerRunTimeFunction(fn) {if (isFunction(fn)) {if (typeof runTime=='undefined') runTime=new Array();if (typeof fn=='object') {runTime=runTime.concat(fn);} else {runTime[runTime.length++]=fn;} +} +} +function registerCmdLineFunction(fn){if (isFunction(fn)) {if (typeof cmdLine=='undefined') cmdLine=new Array();if (typeof fn=='object') {cmdLine=cmdLine.concat(fn);} else {cmdLine[cmdLine.length++]=fn;} +} +} +function registerPostParseFunction(fn){if (isFunction(fn)) {if (typeof postParse=='undefined') postParse=new Array();if (typeof fn=='object') {postParse=postParse.concat(fn);} else {postParse[postParse.length++]=fn;} +} +} +function runHook(fnHookTo, hookType) {var l=hookPts[fnHookTo], optPm, arS, ar=runHook.arguments; +if (hookType==FREPLACE) {arS=argToString(ar, 2); +if (typeof l=='undefined'||!(l=l.ovload)) return eval(fnHookTo+'('+arS+')');else return eval('l('+arS+')'); +} else if (hookType==FBEFORE||hookType==FAFTER) {if (typeof l=='undefined') return;l=(hookType==1?l.before:l.after); +if (!l.length) return; +arS=argToString(ar, 2);for (var k=0; kjS) {for (var k=jS; k0) {posStr[0]=' left:0; top: '+Y+'px';posStr[1]=' left:0; top:0';} +} else if (o3_shadowy==0) {if (o3_shadowx<0) {posStr[0]=' left:0; top: 0';posStr[1]=' left: '+X+'px';} else if (o3_shadowx>0) {posStr[0]=' left: '+X+'px; top: 0';posStr[1]=' left:0; top:0';} +} else if (o3_shadowx>0) {if (o3_shadowy>0) {posStr[0]=' left:'+X+'px; top:'+Y+'px';posStr[1]=' left:0; top:0';} else if (o3_shadowy<0) {posStr[0]=' left:'+X+'px; top:0';posStr[1]=' left:0; top: '+Y+'px';} +} else if (o3_shadowx<0) {if (o3_shadowy>0) {posStr[0]=' left:0; top:'+Y+'px';posStr[1]=' left:'+X+'px; top:0';} else if (o3_shadowy<0) {posStr[0]=' left:0; top:0';posStr[1]=' left:'+X+'px; top:'+Y+'px';} +} +txt=(olNs4)?'
':((olIe55&&olHideForm)?bckDropSrc(wd+X,ht+Y,zIdx++):'')+'
'+content+'
';} else {txt+=bS+'">
'+content+'
';} +layerWrite(txt); +if (olNs4&&bkSet) {dpObj=over.document.layers['backdrop'];if (typeof dpObj=='undefined') return; +puObj=over.document.layers['PUContent'];wd=puObj.clip.width;ht=puObj.clip.height;aPos=posStr[0].split(';'); +dpObj.clip.width=wd;dpObj.clip.height=ht;dpObj.left=parseInt(aPos[0].split(':')[1]);dpObj.top=parseInt(aPos[1].split(':')[1]); +dpObj.bgColor=(bkSet==1)?null:o3_shadowcolor;dpObj.background.src=(bkSet==2)?null:o3_shadowimage;dpObj.zIndex=0; +aPos=posStr[1].split(';');puObj.left=parseInt(aPos[0].split(':')[1]);puObj.top=parseInt(aPos[1].split(':')[1]);puObj.zIndex=1; +} else {puObj=(olIe4?o3_frame.document.all['PUContent']:o3_frame.document.getElementById('PUContent'));dpObj=(olIe4?o3_frame.document.all['backdrop']:o3_frame.document.getElementById('backdrop'));ht=puObj.offsetHeight;dpObj.style.height=ht+'px'; +if (o3_shadowopacity) {var op=o3_shadowopacity;op=(op<=100?op:100); +if (olIe4&&!isMac) {dpObj.style.filter='Beta(Opacity='+op+')';dpObj.filters.Beta.enabled=true;} else {if (typeof(dpObj.style.MozOpacity)=='string') dpObj.style.MozOpacity=op/100;} +} +} +o3_width=wd+X;o3_aboveheight=ht+Y;} +function cleanUpShadowEffects() {if (olNs4) return;else {var dpObj=(olIe4?o3_frame.document.all['backdrop']:o3_frame.document.getElementById('backdrop'));if (olIe4&&!isMac&&dpObj.filters.Beta) dpObj.filters.Beta.enabled=false;else if (typeof(dpObj.style.MozOpacity)=='string') dpObj.style.MozOpacity=1.0;} +} +function shadowAdjust() {if (!olNs4) return;var fac=ol_shadowadjust;if (olNs4) {document.write(' + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + +
{$lang_insert_advhr_desc}
{$lang_insert_advhr_width}: + + +
{$lang_insert_advhr_size}:
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/editor_plugin.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/editor_plugin.js new file mode 100644 index 00000000..3b491dc1 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/editor_plugin.js @@ -0,0 +1,2 @@ +/* Import plugin specific language pack */ + tinyMCE.importPluginLanguagePack('advimage','en,de,sv,zh_cn,cs,fa,fr_ca,fr');function TinyMCE_advimage_getInsertImageTemplate(){var template=new Array();template['file']='../../plugins/advimage/image.htm';template['width']=380;template['height']=380;template['width']+=tinyMCE.getLang('lang_insert_image_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_image_delta_height',0);return template;}function TinyMCE_advimage_handleEvent(editor_id,body,doc){alert(editor_id+","+body.innerHTML);} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/editor_plugin_src.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/editor_plugin_src.js new file mode 100644 index 00000000..afe15f8e --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/editor_plugin_src.js @@ -0,0 +1,28 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('advimage', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr'); + +/** + * Insert image template function. + */ +function TinyMCE_advimage_getInsertImageTemplate() { + var template = new Array(); + + template['file'] = '../../plugins/advimage/image.htm'; + template['width'] = 380; + template['height'] = 380; + + // Language specific width and height addons + template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0); + template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0); + + return template; +} + +/** + * Setup content function. + */ +function TinyMCE_advimage_handleEvent(editor_id, body, doc) { + // Convert all links to absolute + + alert(editor_id + "," + body.innerHTML); +} diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/image.htm b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/image.htm new file mode 100644 index 00000000..01247197 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/image.htm @@ -0,0 +1,315 @@ + + + + +{$lang_insert_image_title} + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{$lang_insert_image_title}
{$lang_insert_image_src}: + + + + +
{$lang_insert_image_alt}:
{$lang_insert_image_alt2}:
{$lang_insert_image_dimensions}: + x + px +
{$lang_insert_image_border}:
{$lang_insert_image_align}: +
{$lang_insert_image_vspace}:
{$lang_insert_image_hspace}:
{$lang_insert_image_mouseover}:
{$lang_insert_image_mouseout}:
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/cs.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/cs.js new file mode 100644 index 00000000..1310fd39 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/cs.js @@ -0,0 +1,6 @@ +// UK lang variables + +tinyMCELang['lang_insert_image_alt2'] = 'Název obrázku'; +tinyMCELang['lang_insert_image_onmousemove'] = 'Alternativní obrázek' +tinyMCELang['lang_insert_image_mouseover'] = 'pøi najetí myši'; +tinyMCELang['lang_insert_image_mouseout'] = 'pøi odjetí myši'; \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/de.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/de.js new file mode 100644 index 00000000..71650a1c --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/de.js @@ -0,0 +1,6 @@ +// DE lang variables + +tinyMCELang['lang_insert_image_alt2'] = 'Titel des Bildes'; +tinyMCELang['lang_insert_image_onmousemove'] = 'Alternatives Bild' +tinyMCELang['lang_insert_image_mouseover'] = 'für Maus darüber'; +tinyMCELang['lang_insert_image_mouseout'] = 'für Maus ausserhalb'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/en.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/en.js new file mode 100644 index 00000000..37c58a15 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/en.js @@ -0,0 +1,6 @@ +// UK lang variables + +tinyMCELang['lang_insert_image_alt2'] = 'Image title'; +tinyMCELang['lang_insert_image_onmousemove'] = 'Alternative image' +tinyMCELang['lang_insert_image_mouseover'] = 'for mouse over'; +tinyMCELang['lang_insert_image_mouseout'] = 'for mouse out'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fa.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fa.js new file mode 100644 index 00000000..31a4ac1d --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fa.js @@ -0,0 +1,11 @@ +// IR lang variables +// Persian (Farsi) language pack (for IRAN) +// By: Morteza Zafari +// Lost@LostLord.com +// http://www.LostLord.com + +tinyMCELang['lang_dir'] = 'rtl'; +tinyMCELang['lang_insert_image_alt2'] = 'عنوان عکس'; +tinyMCELang['lang_insert_image_onmousemove'] = 'عکس جایگزین' +tinyMCELang['lang_insert_image_mouseover'] = 'عکس جایگزین هنگام ورود نشانگر ماوس'; +tinyMCELang['lang_insert_image_mouseout'] = 'عکس جایگزین هنگام خروج نشانگر ماوس'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fa_ca.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fa_ca.js new file mode 100644 index 00000000..f8f0c436 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fa_ca.js @@ -0,0 +1,6 @@ +// CA_FR lang variables + +tinyMCELang['lang_insert_image_alt2'] = 'Titre de l\'image'; +tinyMCELang['lang_insert_image_onmousemove'] = 'Image alternative'; +tinyMCELang['lang_insert_image_mouseover'] = 'pour le «mouse over»'; +tinyMCELang['lang_insert_image_mouseout'] = 'pour le «mouse out»'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fr.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fr.js new file mode 100644 index 00000000..e7293012 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/fr.js @@ -0,0 +1,6 @@ +// French lang variables by Laurent Dran + +tinyMCELang['lang_insert_image_alt2'] = 'Titre de l\'image'; +tinyMCELang['lang_insert_image_onmousemove'] = 'Image alternative' +tinyMCELang['lang_insert_image_mouseover'] = 'Pour la souris au dessus'; +tinyMCELang['lang_insert_image_mouseout'] = 'Pour la souris en dehors'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/ko.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/ko.js new file mode 100644 index 00000000..aaf0809d --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/ko.js @@ -0,0 +1,6 @@ +// KO lang variables + +tinyMCELang['lang_insert_image_alt2'] = '±×¸² Á¦¸ñ'; +tinyMCELang['lang_insert_image_onmousemove'] = '´ëü À̹ÌÁö' +tinyMCELang['lang_insert_image_mouseover'] = '¸¶¿ì½º¸¦ ¿Ã·ÈÀ» ¶§'; +tinyMCELang['lang_insert_image_mouseout'] = '¸¶¿ì½º¸¦ ³»·ÈÀ» ¶§'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/sv.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/sv.js new file mode 100644 index 00000000..8f4084f0 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/sv.js @@ -0,0 +1,6 @@ +// SE lang variables + +tinyMCELang['lang_insert_image_alt2'] = 'Bildens titel'; +tinyMCELang['lang_insert_image_onmousemove'] = 'Alternativ bild' +tinyMCELang['lang_insert_image_mouseover'] = 'när pekaren är över'; +tinyMCELang['lang_insert_image_mouseout'] = 'när pekaren är utanför'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/zh_cn.js b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/zh_cn.js new file mode 100644 index 00000000..f7dbe4b5 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/langs/zh_cn.js @@ -0,0 +1,6 @@ +// Simplified Chinese lang variables contributed by cube316 (cube316@etang.com) + +tinyMCELang['lang_insert_image_alt2'] = 'ͼƬ±êÌâ'; +tinyMCELang['lang_insert_image_onmousemove'] = 'Ìæ´úͼÏñ' +tinyMCELang['lang_insert_image_mouseover'] = 'Êó±êÒÆÉÏʱ'; +tinyMCELang['lang_insert_image_mouseout'] = 'Êó±êÒÆ¿ªÊ±'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advimage/readme.txt b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/readme.txt new file mode 100644 index 00000000..56309511 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advimage/readme.txt @@ -0,0 +1,19 @@ + Advimage plugin for TinyMCE +----------------------------- + +About: + This is a more advanced image dialog mostly based on code contributed by Michael Keck. + This one supports mouseover/out image swapping. + +Installation instructions: + * Copy the advimage directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins). + * Add plugin to TinyMCE plugin option list example: plugins : "advimage". + * Add this "a[name|href|target|title|onclick]" to extended_valid_elements option. + +Initialization example: + tinyMCE.init({ + theme : "advanced", + mode : "textareas", + plugins : "preview", + extended_valid_elements : "a[name|href|target|title|onclick]" + }); diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/editor_plugin.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/editor_plugin.js new file mode 100644 index 00000000..5b8b484f --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/editor_plugin.js @@ -0,0 +1,2 @@ +/* Import plugin specific language pack */ + tinyMCE.importPluginLanguagePack('advlink','en,de,sv,zh_cn,cs,fa,fr_ca,fr');function TinyMCE_advlink_getInsertLinkTemplate(){var template=new Array();template['file']='../../plugins/advlink/link.htm';template['width']=440;template['height']=420;template['width']+=tinyMCE.getLang('lang_insert_link_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_link_delta_height',0);return template;} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/editor_plugin_src.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/editor_plugin_src.js new file mode 100644 index 00000000..2df50724 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/editor_plugin_src.js @@ -0,0 +1,18 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('advlink', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr'); + +/** + * Insert link template function. + */ +function TinyMCE_advlink_getInsertLinkTemplate() { + var template = new Array(); + template['file'] = '../../plugins/advlink/link.htm'; + template['width'] = 440; + template['height'] = 420; + + // Language specific width and height addons + template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0); + template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0); + + return template; +} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/cs.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/cs.js new file mode 100644 index 00000000..5277d260 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/cs.js @@ -0,0 +1,20 @@ +// CZ lang variables + +tinyMCELang['lang_insert_link_target_same'] = 'Otevøít ve stejném oknì/rámu'; +tinyMCELang['lang_insert_link_target_parent'] = 'Otevøít v rodièovském oknì/rámu'; +tinyMCELang['lang_insert_link_target_top'] = 'Otevøít v nejvyšším rámu (pøepíše všechny rámy)'; +tinyMCELang['lang_insert_link_target_blank'] = 'Otevøít v novém oknì'; +tinyMCELang['lang_insert_link_target_named'] = 'Otevøít v oknì'; +tinyMCELang['lang_insert_link_popup'] = 'JS-Popup'; +tinyMCELang['lang_insert_link_popup_url'] = 'Popup URL'; +tinyMCELang['lang_insert_link_popup_name'] = 'Název okna'; +tinyMCELang['lang_insert_link_popup_return'] = 'insert \'return false\''; +tinyMCELang['lang_insert_link_popup_scrollbars'] = 'Ukázat posuvníky'; +tinyMCELang['lang_insert_link_popup_statusbar'] = 'Ukázat stavový øádek'; +tinyMCELang['lang_insert_link_popup_toolbar'] = 'Ukázat ovl. lištu'; +tinyMCELang['lang_insert_link_popup_menubar'] = 'Ukázat menu'; +tinyMCELang['lang_insert_link_popup_location'] = 'Ukázat lištu umístìní'; +tinyMCELang['lang_insert_link_popup_resizable'] = 'Promìnná velikost okna'; +tinyMCELang['lang_insert_link_popup_size'] = 'Velikost'; +tinyMCELang['lang_insert_link_popup_position'] = 'Umístìní (X/Y)'; +tinyMCELang['lang_insert_link_popup_missingtarget'] = 'Vložte název cíle nebo vyberte jinou volbu.'; \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/de.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/de.js new file mode 100644 index 00000000..48263d1d --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/de.js @@ -0,0 +1,20 @@ +// DE lang variables + +tinyMCELang['lang_insert_link_target_same'] = 'Im selben Frame öffnen'; +tinyMCELang['lang_insert_link_target_parent'] = 'Im darüber liegenden Frame öffnen'; +tinyMCELang['lang_insert_link_target_top']= 'Im obersten Frame öffnen'; +tinyMCELang['lang_insert_link_target_blank']= 'In einem neuen Fenster öffnen'; +tinyMCELang['lang_insert_link_target_named']= 'Öffnen im Fenster/Frame'; +tinyMCELang['lang_insert_link_popup'] = 'JS-Popup'; +tinyMCELang['lang_insert_link_popup_url'] = 'Popup URL'; +tinyMCELang['lang_insert_link_popup_name']= 'Fenstername'; +tinyMCELang['lang_insert_link_popup_return']= 'mit \'return false\''; +tinyMCELang['lang_insert_link_popup_scrollbars']= 'Scrollbars anzeigen'; +tinyMCELang['lang_insert_link_popup_statusbar'] = 'Statusbar anzeigen'; +tinyMCELang['lang_insert_link_popup_toolbar'] = 'Toolbars anzeigen'; +tinyMCELang['lang_insert_link_popup_menubar'] = 'Menu anzeigen'; +tinyMCELang['lang_insert_link_popup_location']= 'Adresszeile anzeigen'; +tinyMCELang['lang_insert_link_popup_resizable'] = 'Größe änderbar'; +tinyMCELang['lang_insert_link_popup_size']= 'Größe'; +tinyMCELang['lang_insert_link_popup_position']= 'Position (X/Y)'; +tinyMCELang['lang_insert_link_popup_missingtarget'] = 'Bitte geben Sie einen Namen für das Ziel an oder wählen Sie eine andere Option.'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/en.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/en.js new file mode 100644 index 00000000..a3a658b1 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/en.js @@ -0,0 +1,20 @@ +// UK lang variables + +tinyMCELang['lang_insert_link_target_same'] = 'Open in this window / frame'; +tinyMCELang['lang_insert_link_target_parent'] = 'Open in parent window / frame'; +tinyMCELang['lang_insert_link_target_top'] = 'Open in top frame (replaces all frames)'; +tinyMCELang['lang_insert_link_target_blank'] = 'Open in new window'; +tinyMCELang['lang_insert_link_target_named'] = 'Open in the window'; +tinyMCELang['lang_insert_link_popup'] = 'JS-Popup'; +tinyMCELang['lang_insert_link_popup_url'] = 'Popup URL'; +tinyMCELang['lang_insert_link_popup_name'] = 'Window name'; +tinyMCELang['lang_insert_link_popup_return'] = 'insert \'return false\''; +tinyMCELang['lang_insert_link_popup_scrollbars'] = 'Show scrollbars'; +tinyMCELang['lang_insert_link_popup_statusbar'] = 'Show statusbar'; +tinyMCELang['lang_insert_link_popup_toolbar'] = 'Show toolbars'; +tinyMCELang['lang_insert_link_popup_menubar'] = 'Show menubar'; +tinyMCELang['lang_insert_link_popup_location'] = 'Show locationbar'; +tinyMCELang['lang_insert_link_popup_resizable'] = 'Make window resizable'; +tinyMCELang['lang_insert_link_popup_size'] = 'Size'; +tinyMCELang['lang_insert_link_popup_position'] = 'Position (X/Y)'; +tinyMCELang['lang_insert_link_popup_missingtarget'] = 'Please insert a name for the target or choose another option.'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fa.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fa.js new file mode 100644 index 00000000..1fc83a0f --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fa.js @@ -0,0 +1,25 @@ +// IR lang variables +// Persian (Farsi) language pack (for IRAN) +// By: Morteza Zafari +// Lost@LostLord.com +// http://www.LostLord.com + +tinyMCELang['lang_dir'] = 'rtl'; +tinyMCELang['lang_insert_link_target_same'] = 'در همین صÙحه / Ùریم باز Ú©Ù†'; +tinyMCELang['lang_insert_link_target_parent'] = 'در صÙحه / Ùریم اصلی باز Ú©Ù†'; +tinyMCELang['lang_insert_link_target_top'] = 'در Ùریم اصلی باز Ú©Ù† (همه Ùریمها نادیده گرÙته میشود)'; +tinyMCELang['lang_insert_link_target_blank'] = 'در صÙحه جدید باز Ú©Ù†'; +tinyMCELang['lang_insert_link_target_named'] = 'در پنجره باز Ú©Ù†'; +tinyMCELang['lang_insert_link_popup'] = 'JS-Popup'; +tinyMCELang['lang_insert_link_popup_url'] = 'URL پنجره'; +tinyMCELang['lang_insert_link_popup_name'] = 'نام پنجره'; +tinyMCELang['lang_insert_link_popup_return'] = 'اÙزودن \'return false\''; +tinyMCELang['lang_insert_link_popup_scrollbars'] = 'نمایش scrollbars'; +tinyMCELang['lang_insert_link_popup_statusbar'] = 'نمایش statusbar'; +tinyMCELang['lang_insert_link_popup_toolbar'] = 'نمایش toolbars'; +tinyMCELang['lang_insert_link_popup_menubar'] = 'نمایش menubar'; +tinyMCELang['lang_insert_link_popup_location'] = 'نمایش locationbar'; +tinyMCELang['lang_insert_link_popup_resizable'] = 'قابل تغییر اندازه باشد'; +tinyMCELang['lang_insert_link_popup_size'] = 'اندازه'; +tinyMCELang['lang_insert_link_popup_position'] = 'موقعیت (X/Y)'; +tinyMCELang['lang_insert_link_popup_missingtarget'] = 'لطÙا یک نام برای مقصد انتخاب کنید در غیر این صورت گزینه دیگری را انتخاب نمایید.'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fr.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fr.js new file mode 100644 index 00000000..129c1541 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fr.js @@ -0,0 +1,20 @@ +// French lang variables by Laurent Dran + +tinyMCELang['lang_insert_link_target_same'] = 'Ouvre dans la fenętre / Cadre(frame)'; +tinyMCELang['lang_insert_link_target_parent'] = 'Ouvre dans fenętre parente / Cadres(frame)'; +tinyMCELang['lang_insert_link_target_top'] = 'Ouvre dans le Top frame (remplace toutes les cadres(frames))'; +tinyMCELang['lang_insert_link_target_blank'] = 'Ouvre dans la fenętre'; +tinyMCELang['lang_insert_link_target_named'] = 'Ouvre dans la fenętre'; +tinyMCELang['lang_insert_link_popup'] = 'JS-Popup'; +tinyMCELang['lang_insert_link_popup_url'] = 'URL de la Popup'; +tinyMCELang['lang_insert_link_popup_name'] = 'Nom de la fenętre'; +tinyMCELang['lang_insert_link_popup_return'] = 'Insert \'return false\''; +tinyMCELang['lang_insert_link_popup_scrollbars'] = 'Montrer la barre de défilement '; +tinyMCELang['lang_insert_link_popup_statusbar'] = 'Montrer la barre d\'état'; +tinyMCELang['lang_insert_link_popup_toolbar'] = 'Montrer la barre d\'outils'; +tinyMCELang['lang_insert_link_popup_menubar'] = 'Montrer la barre du menu'; +tinyMCELang['lang_insert_link_popup_location'] = 'Montre la barre d\'adresse'; +tinyMCELang['lang_insert_link_popup_resizable'] = 'Fabriquer une fenętre redimensionnable'; +tinyMCELang['lang_insert_link_popup_size'] = 'Taille'; +tinyMCELang['lang_insert_link_popup_position'] = 'Position (X/Y)'; +tinyMCELang['lang_insert_link_popup_missingtarget'] = 'Veuillez insérer un nom pour la cible ou choisissez une autre option.'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fr_ca.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fr_ca.js new file mode 100644 index 00000000..99631b32 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/fr_ca.js @@ -0,0 +1,20 @@ +// CA_FR lang variables + +tinyMCELang['lang_insert_link_target_same'] = 'Ouvrir dans la même fenêtre'; +tinyMCELang['lang_insert_link_target_parent'] = 'Ouvrir dans la fenêtre parent'; +tinyMCELang['lang_insert_link_target_top'] = 'Ouvrir dans le cadre supérieur'; +tinyMCELang['lang_insert_link_target_blank'] = 'Ouvrir dans une nouvelle fenêtre'; +tinyMCELang['lang_insert_link_target_named'] = 'Ouvrir à la destination'; +tinyMCELang['lang_insert_link_popup'] = 'JS-Popup'; +tinyMCELang['lang_insert_link_popup_url'] = 'URL du popup'; +tinyMCELang['lang_insert_link_popup_name'] = 'Nom de la fenêtre'; +tinyMCELang['lang_insert_link_popup_return'] = 'Insérer le script \'return false\''; +tinyMCELang['lang_insert_link_popup_scrollbars'] = 'Barres de défilement'; +tinyMCELang['lang_insert_link_popup_statusbar'] = 'Barre de statut'; +tinyMCELang['lang_insert_link_popup_toolbar'] = 'Barres d\'outils'; +tinyMCELang['lang_insert_link_popup_menubar'] = 'Barre de menu'; +tinyMCELang['lang_insert_link_popup_location'] = 'Barre d\'adresse'; +tinyMCELang['lang_insert_link_popup_resizable'] = 'Fenêtre redimensionnable'; +tinyMCELang['lang_insert_link_popup_size'] = 'Dimensions'; +tinyMCELang['lang_insert_link_popup_position'] = 'Position (X/Y)'; +tinyMCELang['lang_insert_link_popup_missingtarget'] = 'S.v.p., entrer un nom de destination ou choisir une autre option.'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/ko.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/ko.js new file mode 100644 index 00000000..14b051a5 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/ko.js @@ -0,0 +1,19 @@ +// KO lang variables + +tinyMCELang['lang_insert_link_target_same'] = '°°Àº â¿¡¼­ ¸µÅ©/ÇÁ·¹ÀÓ ¿­±â'; +tinyMCELang['lang_insert_link_target_parent'] = 'ºÎ¸ð â¿¡¼­ ¸µÅ©/ÇÁ·¹ÀÓ ¿­±â'; +tinyMCELang['lang_insert_link_target_top'] = 'TOP ÇÁ·¹ÀÓ¿¡¼­ ¿­±â (¸ðµç ÇÁ·¹ÀÓÀ» ´ëü)'; +tinyMCELang['lang_insert_link_target_blank'] = '»õ â¿¡¼­ ¿­±â'; +tinyMCELang['lang_insert_link_target_named'] = '»õ â¿¡¼­ ¿­±â'; +tinyMCELang['lang_insert_link_popup'] = 'JS-Popup'; +tinyMCELang['lang_insert_link_popup_url'] = 'Æ˾÷ URL'; +tinyMCELang['lang_insert_link_popup_name'] = 'â À̸§'; +tinyMCELang['lang_insert_link_popup_return'] = '\'return false\' ³Ö±â'; +tinyMCELang['lang_insert_link_popup_scrollbars'] = '½ºÅ©·Ñ¹Ù¸¦ º¸¿©ÁÜ'; +tinyMCELang['lang_insert_link_popup_statusbar'] = '»óÅÂâÀ» º¸¿©ÁÜ'; +tinyMCELang['lang_insert_link_popup_toolbar'] = 'Åø¹Ù¸¦ º¸¿©ÁÜ'; +tinyMCELang['lang_insert_link_popup_menubar'] = '¸Þ´º¹Ù¸¦ º¸¿©ÁÜ'; +tinyMCELang['lang_insert_link_popup_location'] = 'À§Ä¡ Ç¥½ÃÁÙÀ» º¸¿©ÁÜ'; +tinyMCELang['lang_insert_link_popup_resizable'] = 'Å©±â Á¶Àý °¡´ÉÇÑ À©µµ¿ì »ý¼º'; +tinyMCELang['lang_insert_link_popup_size'] = 'Å©±â'; +tinyMCELang['lang_insert_link_popup_position'] = 'À§Ä¡ (X/Y)'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/sv.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/sv.js new file mode 100644 index 00000000..d17f4e45 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/sv.js @@ -0,0 +1,20 @@ +// SE lang variables + +tinyMCELang['lang_insert_link_target_same'] = 'Öppna i samma fönster / ram'; +tinyMCELang['lang_insert_link_target_parent'] = 'Öppna i underliggande fönster / ram'; +tinyMCELang['lang_insert_link_target_top'] = 'Öppna i topp ramen (ersätter alla ramar)'; +tinyMCELang['lang_insert_link_target_blank'] = 'Öppna i ett nytt fönster'; +tinyMCELang['lang_insert_link_target_named'] = 'Öppna i ett specifikt fönster'; +tinyMCELang['lang_insert_link_popup'] = 'JS-Popup'; +tinyMCELang['lang_insert_link_popup_url'] = 'Popup URL'; +tinyMCELang['lang_insert_link_popup_name'] = 'Fönstrets namn'; +tinyMCELang['lang_insert_link_popup_return'] = 'Sättin \'return false\''; +tinyMCELang['lang_insert_link_popup_scrollbars'] = 'Visa scrollbars'; +tinyMCELang['lang_insert_link_popup_statusbar'] = 'Visa statusbar'; +tinyMCELang['lang_insert_link_popup_toolbar'] = 'Visa toolbars'; +tinyMCELang['lang_insert_link_popup_menubar'] = 'Visa menubar'; +tinyMCELang['lang_insert_link_popup_location'] = 'Visa locationbar'; +tinyMCELang['lang_insert_link_popup_resizable'] = 'Gör fönstret skalbart'; +tinyMCELang['lang_insert_link_popup_size'] = 'Storlek'; +tinyMCELang['lang_insert_link_popup_position'] = 'Position (X/Y)'; +tinyMCELang['lang_insert_link_popup_missingtarget'] = 'Var god skriv ett namn för målet eller välj ett annat val.'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/zh_cn.js b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/zh_cn.js new file mode 100644 index 00000000..84c27bea --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/langs/zh_cn.js @@ -0,0 +1,20 @@ +// Simplified Chinese lang variables contributed by cube316 (cube316@etang.com) + +tinyMCELang['lang_insert_link_target_same'] = 'ÔÚ±¾´°¿Ú/¿ò¼ÜÖдò¿ª'; +tinyMCELang['lang_insert_link_target_parent'] = 'ÔÚ¸¸´°¿Ú/¿ò¼ÜÖдò¿ª'; +tinyMCELang['lang_insert_link_target_top'] = 'ÔÚ¸ù¿ò¼ÜÖдò¿ª£¨Ìæ»»ËùÓпò¼Ü£©'; +tinyMCELang['lang_insert_link_target_blank'] = 'ÔÚд°¿ÚÖдò¿ª'; +tinyMCELang['lang_insert_link_target_named'] = 'ÔÚ´Ë´°¿ÚÖдò¿ª'; +tinyMCELang['lang_insert_link_popup'] = 'JS-Popup'; +tinyMCELang['lang_insert_link_popup_url'] = 'µ¯³ö´°¿ÚµØÖ·'; +tinyMCELang['lang_insert_link_popup_name'] = '´°¿ÚÃû³Æ'; +tinyMCELang['lang_insert_link_popup_return'] = '²åÈë \'return false\''; +tinyMCELang['lang_insert_link_popup_scrollbars'] = 'ÏÔʾ¹ö¶¯Ìõ'; +tinyMCELang['lang_insert_link_popup_statusbar'] = 'ÏÔʾ״̬À¸'; +tinyMCELang['lang_insert_link_popup_toolbar'] = 'ÏÔʾ¹¤¾ßÀ¸'; +tinyMCELang['lang_insert_link_popup_menubar'] = 'ÏÔʾ²Ëµ¥À¸'; +tinyMCELang['lang_insert_link_popup_location'] = 'ÏÔʾµØÖ·À¸'; +tinyMCELang['lang_insert_link_popup_resizable'] = '¿ÉÖض¨Òå´°¿Ú´óС'; +tinyMCELang['lang_insert_link_popup_size'] = '³ß´ç'; +tinyMCELang['lang_insert_link_popup_position'] = 'λÖÃ(X/Y)'; +tinyMCELang['lang_insert_link_popup_missingtarget'] = 'Çë²åÈëÄ¿±êÃû³Æ»òÕßÑ¡ÔñÁíÍâµÄÑ¡Ïî¡£'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/link.htm b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/link.htm new file mode 100644 index 00000000..ba0f76c6 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/link.htm @@ -0,0 +1,421 @@ + + + + +{$lang_insert_link_title} + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
{$lang_insert_link_title}
{$lang_insert_link_url}: + + + + +
{$lang_theme_insert_link_titlefield}:
{$lang_insert_link_target}: + + + + + + + + + + + + + + + + + + + + + +
 ({$lang_insert_link_target_same})
 ({$lang_insert_link_target_parent})
 ({$lang_insert_link_target_top})
 ({$lang_insert_link_target_blank})
+ + + + + + +
 
+
+ + + + + + + + + + + + + + + + + +
{$lang_insert_link_popup_url}: 
{$lang_insert_link_popup_name}: 
{$lang_insert_link_popup_size}:  + x + px +
{$lang_insert_link_popup_position}:  + / + (c /c = center) +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
  
 
   
 
+
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/advlink/readme.txt b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/readme.txt new file mode 100644 index 00000000..ab554efc --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/advlink/readme.txt @@ -0,0 +1,19 @@ + Advlink plugin for TinyMCE +----------------------------- + +About: + This is a more advanced link dialog mostly based on code contributed by Michael Keck. + This one supports popup windows and targets. + +Installation instructions: + * Copy the advlink directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins). + * Add plugin to TinyMCE plugin option list example: plugins : "advlink". + * Add this "a[name|href|target|title|onclick]" to extended_valid_elements option. + +Initialization example: + tinyMCE.init({ + theme : "advanced", + mode : "textareas", + plugins : "advlink", + extended_valid_elements : "a[name|href|target|title|onclick]" + }); diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/editor_plugin.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/editor_plugin.js new file mode 100644 index 00000000..14b41636 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/editor_plugin.js @@ -0,0 +1,2 @@ +/* Import plugin specific language pack */ + tinyMCE.importPluginLanguagePack('emotions','en,sv,zh_cn,cs,fa,fr_ca,fr,de');function TinyMCE_emotions_getControlHTML(control_name){switch(control_name){case "emotions":return '';}return "";}function TinyMCE_emotions_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mceEmotion":var template=new Array();template['file']='../../plugins/emotions/emotions.htm';template['width']=150;template['height']=180;tinyMCE.openWindow(template,{editor_id:editor_id});return true;}return false;} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/editor_plugin_src.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/editor_plugin_src.js new file mode 100644 index 00000000..da8e5c42 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/editor_plugin_src.js @@ -0,0 +1,36 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('emotions', 'en,sv,zh_cn,cs,fa,fr_ca,fr,de'); + +/** + * Returns the HTML contents of the emotions control. + */ +function TinyMCE_emotions_getControlHTML(control_name) { + switch (control_name) { + case "emotions": + return ''; + } + + return ""; +} + +/** + * Executes the mceEmotion command. + */ +function TinyMCE_emotions_execCommand(editor_id, element, command, user_interface, value) { + // Handle commands + switch (command) { + case "mceEmotion": + var template = new Array(); + + template['file'] = '../../plugins/emotions/emotions.htm'; // Relative to theme + template['width'] = 150; + template['height'] = 180; + + tinyMCE.openWindow(template, {editor_id : editor_id}); + + return true; + } + + // Pass to next handler in chain + return false; +} diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/emotions.htm b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/emotions.htm new file mode 100644 index 00000000..32411c8b --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/emotions.htm @@ -0,0 +1,45 @@ + + +{$lang_insert_emotions_title} + + + + +
+
{$lang_insert_emotions_title}:

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/emotions.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/emotions.gif new file mode 100644 index 0000000000000000000000000000000000000000..d34f0e0bf3f630c74260f4e122daed5836f1b4d5 GIT binary patch literal 1127 zcmZ?wbhEHb6k!ly_}<6x>({TpfB*itE%^7V`M+Og->&n$d-v|oM+;SMhEJb9ef|3N z*L{)S55@oec1aHu{P)-N?-!>>xA*^jBK7?F^Lv+#KYn<9V5R8)Z}t~1T-Y{?>+dVo zBP+$HRdes#K5O%I`Dhouzn?9x?-Bg-$<^I}*u8Ze?w1gk^lI{>)YpmJZm={mbwZ z+p|7@{`~FRx6dD!tjj`BL8>h=2L0ckhDkx4U8o zR{QRlBYo%Umc8@k-ab@)bC&nOYXAMK{r~>W-!WTY+bo`cZ#Dn_GvB-1ecuZA&mW^| zlR1CCRoc7U<=12RkME71p8*Dr?%iwK&+k|Men;rQ8sB{@JziZ9{&qv~+&-m~2j~C$ zYyRab?~flp{{R2aFbb$00*XIb7#SG)7<51egYpCe$A1P{P8p943l26hGMHptS|ZrM zz|P6kk#Oj6r?8xl3xmMLiA}0HlQa|^ojirayhUWz97uNVmDCDY5Ma3Y7@M3Zmzh?{ zFEN2&XY{3>m_X)54;g@*!88)pl-*G%st!s#Ra%6mT+uLaO@C~5o_>B_IMxWDwZOW z*udIY$WkpKGBI&s_bmqDPd_#+badj;3`+92kZ_oN9%s~cJC}tMHIB3D1}?g>b3(E} zuX+}{(ZPhJtgJEy2@e)rIK;)K#;$q6ncZrK!BG*t7Z)7)wOm;kMBUa1xCm%VII_CS LrbYxfFjxZs)j^Bq literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/readme.txt b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/readme.txt new file mode 100644 index 00000000..cc2cf3fe --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/readme.txt @@ -0,0 +1,2 @@ +These emotions where taken from Mozilla Thunderbird. +I hope they don't get angry if I use them here after all this is a open source project aswell. diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-cool.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-cool.gif new file mode 100644 index 0000000000000000000000000000000000000000..1e2c1d62bb7161241af27cbc4e19784193f1a3e9 GIT binary patch literal 1135 zcmZ?wbhEHb6k-r!_x9>KeJ?_ND-@a=QJ z&wC=@zJ2@qMC#z0z&*>o-n@D9_m!%&wDio{{{Np)8pWZkB)fCI-r3C}AK!RA zfByW}dyk73&+OYi>)j~`wiK79D^_t;0b_g}bh;r}=L&C}&iY|mQV&3Ny!@xOni z2bLNAerI)fx!TWHHvj*IiVCss+@_(cD{f*Stf(lYt*Ne{pz!Y9ySGoBOG``lEa852 zOZM#9vnLNN;N@nychy!&LFU{(r57(=NK5jbJUIW>egPLJ!TU!9_N{Ptb&-2;g!j== z-dC?)i3zi4YisN4@gxRu?Oo}^&%;`q%(-;QqP@#qn3R}CMM?db-_LJ7(z3HNNQ@QVyWD;2Ov$^q^k2RRc`DKu`PB$*A-siH0<;^ZS+SD@6nS#KgpeXLj&DdzyIin3|?C$DZZBa&mG% ze*F0V|3AY}28usf7#SE2FzA3h0m>5$9RC>_IYlfO4(PM-)GoNoVotE@8t(X+IkmFY}+Kw`0xi2j@o2Zp} zv&q9#)H#o@P%-t@#i^D}S|J4~o}shC8Yb{qEn0YHW;l1mObds`LyW>bVhbj@xF6Qn z5;rK=;Naa*%$TfGaG+q}$@Prd8)|+CE_CeT6b>@+>G<&Y@Cs3$`mHwvT^)N(Wvvoc zEnIM|Pt2XQYJuV-S3XhIDGQwV^gA4y+4)!-8o2qtBs4JE+B{%lQqN>zU}0$yaOP1I NU~qI}W@TZp1^{6gs0082 literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-cry.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-cry.gif new file mode 100644 index 0000000000000000000000000000000000000000..e0dcf8a8fcdf4da63a860bc46f02f8b92ea4213a GIT binary patch literal 1127 zcmZ?wbhEHb6k-r!_&$r_@87?A-5-Aa`ZedshfkkA{rzhG?%lhuU%$S2^JeFKy?@W7 z|9rH#d-v|Y-%&S?8lKuB|M#=S|NjYZ-@d(j$yAk#Vc+&y(ThKPer2+Eh1ijm;*AC3 zM{j=EHjC@g?fr+BtL68(0a z@8FuiU|a5=UrcS3n0`MLKYjZ2-&d+n-~L?P&A4Z|*X83n|G(LP{t)%&xzfisUVnb& zynh+KX$t4FJBIIH8qL}B^6=rq-#!PN*q-(OU*X)XSH6Bu`uO4X|G%L>U)da3W;EmQ z|9}5V|NVBk`QqQcl^)w>@!Y+({pDS!Z*LuT&XJtmsZbcsap&rmfA6#otoEP2q~_mW z)32}0w(Uyz{LEsOwd4hrCKZ7Z!2#3P~RRIM(P6mSw3mq6`!xqdiWIo!($0WmL zqtMdcEbBe(O~C=@6O8R{LMa+aN?bxJMLr@YCmc9&z`IJFCSk3Lrjv%LdQlq@hlOIfX7b#OuT9dJ6#e^@v13CWh6X2 z%+AfL>twJqv9qC3Jy#|3WV8Fkg;pXOGEOPSCyFx*9r$wd0h_Oco>s_@pOaHBw7E}K zk*E+(Xpr<-5xiVZz@e9sDgBYd376g5ayh2V5!hjJ>=1*Devm`a!$n?Q;udTX8YP?z zoeZjdM;KIIc+YZ8Ns`eNY+!MgbeVL)O^k!|=c{kg-E$?i%moM0A zV6qLPy9zZy5}bIgE#~{=0d(iosjS?KNwXxJ202h(<$0c6ANN1(_wo1fclVP>#llxl zB?HMo_!bb0#SjER9~K0IL8Pnjna_tb9~LBvf91OjNd8uid0-s8s{S^j^XZftCLyas zKEQ{K2Ua|ufZvay^?!`>Q1ra5hlXtCgq$gpmNaBN_wKc{;Kpf(Dcja78~cVj*zr>Q zN!5ty$i5xm`fBCe+#Ir$dT(?u8p%PH>2U*uju&IW{H@va&DH9usj0YMh=fm?o5A6p zYQ)X@{wlFgOM3jk8ePkCI;R~*T4bKGu&{tk^W)L8E|=>lF9G$jV3SmHhJvhp2%Af0 zt(mP&%)vHB)R4EiD)^+95*_4^w34?v4+cWfPW_Xd- z@g?(z%Z%V`N$g3+mH|>U&|q_Ea7}=iBm*}R*B|FBJA_RQbo3c}*)E8g@`to3S_RYE zC7v10z^dg&uXdYw?{)h2<|OGuT-HkQmeW2XSidy zcW)#T!7vQ?pZ^v}kK#c9xCL;Y>*r4Z1PqW8$-4o#dwZf7ByjKOA)vT+gnQb3NtFdK zNQ@;Wk;Gt?FF`G1HbAkvZdxw8n4FS*<1&1`V4DM$wZGNI)O3HHDy`<6%yr`K?<)uK ztQNbpB=hAW<#f`xQAN(Wh*M448!t2yJ|69@N|IFIsbt~Ao>xw(cj9q)o!LO<4a(BS7v5zT;M_#bb_yp?*$99$*SQHK?x&VBSHLvt z&Ah=ShaAlP;8!yD(aKCB4ll;bbj%6DV*X|okH@~Mp~(s@(R0f`DMaa=_s^Bry(v#_ z`A80R8Wecq>kZ6e@Vm@1;ui+3I-&s%-z4qo0i?Q1MH&N+?-q92FDMh}%9=)!#I0@= kZF{3$p1|YWfp!QO+;J%l)PZCX7lwD1)v28j2m-JD3q51Hn*aa+ literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-foot-in-mouth.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-foot-in-mouth.gif new file mode 100644 index 0000000000000000000000000000000000000000..b3e47cc3f80f4d62bc37dafb892df4671e0dd2cc GIT binary patch literal 1120 zcmZ?wbhEHb6k-r!_`Z_i*RNlHzncI1W%l>)UsY~~AGZa+e*OCC)2Dau-rYEA_~)a= ziS1bzE?oHkKjGsWuMj)#j~`xdo5l6!&6~Gx-yU2OcyN`}`2#w4FPTQW@$Ff_bMfMt zKR-kM{WX35{Q2k4pWO{OK7WY%_U+r|>GJ>nmHvKbrOL(d_lwiv!-ub(&^x?b?Z8UW zy(`2vP2tQ47X0_yW#@doQ(NR8-QNH7rqS+I(Rc6O-M4+#ty{PL{L0z0-0Q$HqtmBP zukL2NbWru*@2Ddy#sB{^|9(g4z-s^BZJhWhTBkzs zfBqOXvt51fe7QfLbPL1TZyuJ}HjC%nA^i{U680{4|8_?t#glDzr^fmH%J**s%&6s_ zTqFGGuE&nq0{1TJpFBAK#~q>K2=>wx;aLrQe?MCsSmV2ErN-7J>fde%-o3W{{0`|< zFSajNd3P`1OY#xizuN!bJFOq@%>7K+4{UYbyWC~x9LaCj`F{NP@&EsSh7k`Gf3h$# zFsx+I0fhu8PcU%&X9(sLv0z|WC7>9 z+*~3yQxhM#vG_6vr0%?+?9d=4v8U0ZXe z1BsWW+Ga8ozDm*Hl5*!zi)j4p+$*54T*=#R>dI3yI62;Z_$j=y;W?A!wiFBDb}ngq z4!$W>A(>|Ho=4k!S(@0VPhRe`fLH6o0;vm(ocvac_chGC z)EXq{=3OE3>VUx1Hkq^qH*7gwUHoVJ_X<6|P!O_!oy}OQqVU3k#%4#+G=mQhE->^; jSuELbh)eT905h+8CQAd0*^7choK`m!9Nm~%Ss1JV`4_4B literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-frown.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-frown.gif new file mode 100644 index 0000000000000000000000000000000000000000..9335e9945eac8c26129830121ab7e53077c4eeb1 GIT binary patch literal 1116 zcmeH``A<@D0KmWKtAJ2=#HE=>Mjok=9Uf^}q7a**o2_QIZdTS-w$;|LR+e_*rkksc zERbAgHnVanEAbH>UMs9DhhS1I7Xb#y6Cb?yT7N{p_4xxnKYX^2WJ`W}#(p+ngINW@ zFbwym;W$oU>+tX4PN&oB^#)w&ZnxWS<@?5A)XdY~2|c(C-j)e@ewWzo_Nl2UUAL0( zi#;CChS(sI+(+PR$6l?nykATBOR{2ukXG)<$ncyktKl>w;LgK6=}#JHF1yTPvFINb z`JI_<*D3GyLj8kq+$Ka()Mzw5Z;@eNIKB6I*tGQPc%PwV`Sj22Z*?gzTlr;@c{|0S z`0VZzWgO&Q>d?>-iEcC)3|dtRL7WI+M@XXb*@K zlgZTIU2&iY9(oiq@nLmfuGsbaSC^7roXzmMiyRJzL_|eBg@c_@$io85r|#KFzTdGF zX)Acw7mJR;y89BOO+IU8dt4>C9+|AFCjVG{TWEH4OK)$-8fdVn3q-s2s|f=vt+2o0!1UCPr2cyihx=Lf3R^Z;QBB z6&Y|R_uOU@0TF89X&b|ytHOI*Bt4Cb(a)hipN}L-@SlHEAZ8At0H6R#fAxQ#08|o$ z(Kzt{(QsGrC@fJ&Qw~@q<78B7q*nzXg1)9h4Aq2fJU5I)mtLh@EiU9P>c{?OoL!c6{FO5)++#+Xi_Li47M zd+N~YE3yl@rBH2=@nwEBeVsDCFh?R+2T_5GX06iCUm&eZA48D5E19QQNlJs2R?l3> zrph}egX`lWup~Ciy6{>;B2}ttFQwDPupq^zzNp|vo~&VHY%&;R{3S~i^k!tUlpYtG sv_oKBR?XsZBEq9%nyMB2mHoylXjx-33|R4xbD7z8H3Wr)a9CjdA8k*7IRF3v literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-innocent.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-innocent.gif new file mode 100644 index 0000000000000000000000000000000000000000..cdb72568da7b2a56cbb2f13d2c5cd3464aedc5e2 GIT binary patch literal 1139 zcmdVZ{Zo<$0KoAFR9-|h2!RJWIW_TRn)o*J+6!GcUrNK9ot>UL@@iXccWK(SwXGRv zT5aA;o$h=|G)t6L!f9cmLVzzr8>mf3;!9YRA}Zu#^763yGxqrlzQ24^(mvatbb<&F zfo&yVUm&^OS*BSm7RM6BYPH(!cG&(QG~;VFn{6ApdcA&U7WY6oO`Ly@DON11$mT#;4X5&eI3D z`?Yv!9QfV=LY@l9P#HO%C8_&gau{;=8CFq!br zP-|byKG@0H(Bb8xjHXLyap4|uCDpN$Z8tLhst29csO?3HLAF=@dxjG_>ad^r_YQUG zF>~y(;KCWocc;m{*Q20Wg02;WT?tPHgWPbUeo`{nnYthXm11ytBvet)lQz*I16fjo zosw}3s&?2CF{Wtgugp4mj4)iE_vK-ftTyi3eB!<0;J%wtqI01x*V%!Nl&`bU*Dlg$ z#^W{p(b8r=*p)b3br@a?hvrBVBF5iC!52=G#dUbK5Vth+$=i3H5!`M!@IMr|J<}|yx5VG@8l%e1bnog zf5255AD0#pNy!W^QZJQxfIigG!a}~XC88aJ{~_*527yyYJ{W5p!|vv#-Bbk<*;CaY z_s*HSYF=icGQoylX+2Cf>)=m!-~18sRkbI!+Wf{^T|sW_(52~k73ox%&L3ba;XnSF_Oh(H&2_{rHl1-3`|6V#J>RW54a}BG-fnH zt&uq>lDx)Hl+4?V~W$9s-JVZuDGav8rN zk>$skRMah&$LAjO+Xbr8Q@0TJK@uO|0~B1r5u!P}6u2O1HxfgRk3WLlJ-u-m72YmT cpc9U8`Ftc;B}cNl9@}T zhnK7EoUixj_WrkT-~Rn==g*%XSSh+~ z7T33L-+n(7Kd{Wm&w^{qGL=(XIo$Q|FUVnb&{QDhs`t<3$ckh1voV0GP%AcPhzwV11TqSko zxb=k#7ykbZT{cx|_p0byw{BfJsQUAj&EM~_o2GF7|7L&plIg#Hr61pT{d*?;@3+h9 zZpP1_KmYyW^!{b|=IQcBR*LV-lKggCX!~5gKc94W%#prxb<6%XzFp!H_b%%1UG9Eh zweQY3l7Tkd`#bnHYKi`ODSu$K|DSLEJ7x=fxypO;;QZ2Lk?(gU&+Sv%Hj8KPa+huq zp}&9gPaayZXTH?GcUl_~#P_ZAcyDTYSylD+Oxf=b#2?O;|NJp(x48KE{mOqnYWSIR zJzFMlV2$s;zvlNY=>Gd-@coX^@3%_-|CxWgD>h%7_gt08j=B6BR7LmBmvh!;|NSc~ zEl42Ro%h=f!Ou4(f7}r|l`H)FXUP85{!bSQ+`YE_t+DaHx0+|<Y`2YVu!zjQT0*XIb7#SGmGw6U+f${_c$A1QUP7w`;26a9e8%6YhS&%)C2i7R8fj)cQT!<2RbMeDX34TlFXk$P^VEI4i3)K_Eb@MPo^)(s<6op7VJ3O%;{$&grg^6_ z4lG>6EaOw8bGGx6BP$It;WXaQ4evX(%{0GI6rX+J89E;>>!5!I6i1&4xovh7JLTJ*5}}7zIqWTwvmL N2$^uvfsv8H8UWc8p%VZA literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-laughing.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-laughing.gif new file mode 100644 index 0000000000000000000000000000000000000000..09a9ec7e4f5dab31b43717366d6236fc760f8610 GIT binary patch literal 1122 zcmZ?wbhEHb6k-r!_&%TE*RNlH|Ni~=%k1x0^KaMrK7IQ1_3PI^A1&U!d-v~m)Pa?v zpFe;8_U+q|mEt#!8Xj0?bnmk9=MPcmPaZjZ`0(4eZ|`0*J+VFO=#j&xw#Z*SX0UA* z*M$og{{43O_t!KdRPgla(?4I?lqQQ@yLkHR=cNDt6GCix(gOwGym@o??%kepuV@#( z=g*)2|5w;io_6u#nOnDR{r?;K@x$xgtD-L*RQ><||F_QpH!hz)w@+`+a<5HOIRE?% z`TITg*L#nTZ@l(xpLKAR)Su6GhnK6Z?q=LPUH<*c@ISwDcFxy(bbJ5bFHU<`i2Z(N zQl1FQY#P3rjZ&V28Dx#wpDKfX8Gzd@lnlV`_V{%P$M3nsTbzajtf zvi!MyO8ZuNe7h@_?!#6T=k?-=;f}>R_ikM~vyOZJ8o58;{I6X+d+(zD+lQ)OuJWGW zuUr}*alGF&DJitWrwJ~IRgCme2KY&YyNk=WSG&LLn^){~K-a?HWM*I+}& zq=#)nsyPPG*ujs`bs z3R-Xo2pl?mYg@LZ%Z(6*gQ5;~RwW9Pm!DeXl>9}eXt9O>6IY1L(Tz*ogd30dD_)dL zdCtSi61Zf_$wNzzP8QKzuqA=Ty-(4QgRA7=;g|dpoKtgd2&gn(m~AlQmdJ-G9*upb z(eGjwI6gik<2AEHW5*NC16-cQ2`-N&yR~qb#K|3;aWS3M*C>mx-HbPm8vgt3^5bfByXNmj2yKrhmVhA6Y5> z;F`g*DazYsac!P1-&HAfVtdxd53m3KEBy1(;{D6;nccD%FP>@Hmi6ns$KAVk1Fg9K z{L0z4eb&J>fwykm`uWP{-|wiu-(ydoK7C-B(evle0~;(a9aP;kh4b$hr^AO2U$}5V zM1gPpqp4lxQs2IP`}eQ(z)I1#Z{MEUBLC?2{x@&l99ZqYf3^RCHNIWt!soZj|9EGy zcezVuh}p@5^LNaVzI$!EnXAm7Z~h;z3jca3zi)%Z$wLd;ve^216&BA7Slq_(@{(xH z%H&V4T>kwv|NS$>yUetDMe^SHa^LQVeEt}9XpOF=zuvbSg8No_6hxUiX)y1Y%U@q7 zdvKN1_PKm_u5S7N&s^75eAxm`$1t^O%R5?XB6c|+G z?G#uU3^pu0z~CHJk#OLEbGIU+3|9!lBR6It`??7k1?TTs{69kx#c8hByd0a41 zJmTQt-qO)=K(X;Wi;Pl-KoZL&6^1;kH3u#}Zs-zJp0(=0#zlvP876#7XxPYjkex$v zSKV0#W@kYU?mr;~4h;^REaJEJ?R~JIX)-I@uNNZL7sagN4}7@U_?&Tq)&zzN9x2Qd=6I-QU9k{6$tNP+kzvr1lEgO0XktZx>4F2w zmlkOo`$&jpII>SOoyc`UU!ap$QC3Vw%j2NZr2qeQmK02KV-$GU#AEqHp_$ty#U#Li G!5RR#xPA-( literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-sealed.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-sealed.gif new file mode 100644 index 0000000000000000000000000000000000000000..76002b2f0142d086e7fa3a6a367554f63d4d946c GIT binary patch literal 1110 zcmZ?wbhEHb6k-r!_&$~4@87@wewqFKYX0ljuXE?mzkB!Y>({TJK7D%g_T7h%pWeQG zw|Tn!=MPbD-@g6#*Yv~3&j;58e*6CY@N%_p-@g6(?Q(Fh^_w?u{(f=#_pkKK8Q-9i2>)-FFXg9t!tE}7&IOcV6Zkocmx|{L$ zJFCy1Ki@cNxNR2K)DF+d?NS#no>|nx`RS3>zLg&LF6!@J?Z164--2$=*_|2-`*=RS zOZfNKe8R+uJLgE=xw>WVa+k$@T=y>M9$4-F`D6CUgY!#Mgg0$adh_nx=Z{evR>^Oh z#WP{zr1R&`7lyOnzY%cvjzM}L&yLvw-yev7c$aW#C;x%fzMo#X>{_XDV5{@rzxkh^ zS^W9t|Ms5ckDotlYHC+Z=K6M5?AslYg%dP(%;o>_Eq8ve`iD=SzFg%!u*UcNxeLEu z%CDKm_4`-Wp7~Nc=18wuB>v^O#g89Ay*2CSi!EEWEY*u`X1n^)U9NlQ%l-Zta`MoE ztxMGRt#H44ZTqH8n;zZ_+`HWU+qdsOe*Ad;{Q3X?{~1OB1tFmLlZBCiVJd?T$P7@P zVBq-Apv@`5k#JxMr?46?gTaP{2N)F8Q*q%)FPo+dpU*0#LvAcO93m{@eGZd&1-sQ47hK`sSZdC)>xH62t$?b+L=D3^ zB2QSBzJG9dzA;Bph(f=Uz0Zyn6BM0U#ntL;9zDF!z{PK@GDSl%v5j3+J=3ItRi$Uc QK{n+H365^etSk)H0N%2f?EnA( literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-smile.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-smile.gif new file mode 100644 index 0000000000000000000000000000000000000000..8cf2b5daf3e5e3321fbb9d6eeadd9cf60a575fea GIT binary patch literal 1116 zcmZ?wbhEHb6k-r!_}<6x>({TpfB*itE%^7V`M+Og->&n$d-v|oM+;SMhEJb9ef|3N z*L{)S55@oec1aHu{P)-N?-!>>xA*^jBK7?F^Lv+#KYn<9V5R8)Z}t~1T-Y{?>+dVo zBP+$HRdes#K5O%I`Dhouzn?9x?-Bg-$<^I}*u8Ze?w1gk^lI{>)YpmJZm={mbwZ z+p|7@{`~FRx6dD!tjj`BL8>h=2L0ckhDkx4U8o zR{QRlBYo%Umc8@k-ab@)bC&nOYXAMK{r~>W-!WTY+bo`cZ#Dn_GvB-1ecuZA&mW^| zlR1CCRoc7U<=12RkME71p8*Dr?%iwK&+k|Men;rQ8sB{@JziZ9{&qv~+&-m~2j~C$ zYyRab?~flp{{R2aFbb$00*XIb7#SG)7<51egYpCe$A1P{P7w(PhsA2XQj8o18x}e+ z2>Mi56dr2sJ-USC11z(X+UV3UBRg$~2SV*yQWT{$h*; z&L7bE_t*69CDT72Eu!7{LhQKz{f_!}o$voQ`!{diT)1%I?c2A1KU-Y9c;?ovTbB;1 ze*XOV-eu#>)8!xC-ml8V@b`<;wpm>Jw$Hk8)bRH^tG};QKYn<9V5R86HG$88;3V(r zZpMGVUG}aJdwSDo(-cm31CBqxat<$7`|~s8|KHG4Tjc-!D?PYM>h9gUAK!TWd9Ji` zzTTeYUZ+o=&IlI#_Br6dGNWrJ^!`4P`u{)S@ZrO|S4E%Lo^@oUxEeQuDmTOD4^jXA z7#vvbe{Pq;%y#u3cZBw>^muieck2@M`Mv5PmTU)B``)>_CCZ-l?q(#qM3u zP4!~iIY&~9pCQ?U{pc>&FV8K0e9OIhSjkq2xiFml(<7_*7x>ZxdA7~sd3(?D(<_&g zhZcNzm+<>n*6Ry`pFc)@erECcWA^X2O21yp|9UJxyHn%Ha^CH8`TqSi-@n@b|3CA+ z%iT*;gb%Fo-7#BW#~kTDpL7>a(D?f||L(QzJLdA=zY*Y}%Y1&n^7jYg4{rwUoiC>& z$hd2zhL!;1-sLXm_9^XK;ch9Mb$nT#aClAg)u+@3{Y@R>g z{NJ4A{qf_+|Ns9PMgiUsQ2fcl$iOh4K?kG?lqVQC{xjHfibyatsIzj}Fmf1dSm?kY z7f=$haS<~YKZ6XHPr{R<9L{Dr8d4t*c`&uBmB}1rI@T#=TxPP>a?{}>4*qpn9fB&V ze4IjwQoa*|o%@&jGp=drU_9hHft63jrj$|1jl+r2CNxu^k%3X3e^1j_sfCQf{%pH6 z5)~a7SR``qZ%bXsGJ%mLlkI8Zfd%|hR-LB`7M6H&FSF;+c~H1H{p1{Tt#c(^i=3KT zyykF4Iv8;JEdaXpPU4f);1^7#*L0i`9!y-y&72hf^TWe{H;m%j91I_5Uhb5%;**&$ zMWs{up;g+PgvXi=T^>>yQv^P-atdiVd0n`0K%LduU!uXm{+D5*kC>6K+8+lNmcxOK z(pn-r4=Ns?plE4vM)-*@lcef|3N&qs@2_eDN^`lQOu@b9Rpy0MyTz@{f{`+hC=FOYU)8#*Zh`Mm$!qsC2 z-#!QY{cJI#mV5WA=)bR2zkU05>7eQdDXEJW&-{F4^Z#Grzkj8Fe&sBcl>GJH;I zf4`%StQ5}(75wuvXaE|vc!zWj89X@>c(e3?zzc}4HEcpAK)q$0wE0k3}fBt;qsA04V-@!G3rO6^+ zKPUb9=D&cOYmq z*Zkf^{kIQQzdsQF_{Qt^&yXF8in~=*_O0~z6&&*WSJqW4t9>in_bzw;_fG4;YTuo6 zB=@iO-!ot8{C?&C|IF`Q&<$p1xMF4XxUsm3}>z|8_%g#~kTzcg6mE(tUnL z@K+Z^fnf@R4#*f#o?zhk z&!EXEVxe$AMLxMQeo|xWw8e?$rIv$CIUv zuaUj^)Si<;F9MewpP($8wCFiwqgl1c&xuEN7NP{1U9-ERYW8_<>oT#3DEg4;b6yMCewr~CzV%t2&x-gDVXHO7$LySZ2#wg N1CLmWNq_@`H2|>$hIIe{ literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-undecided.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-undecided.gif new file mode 100644 index 0000000000000000000000000000000000000000..2aec732fbfdf8df32f6e527f8e61ab91ae0cbbbf GIT binary patch literal 1117 zcmZ?wbhEHb6k-r!_&%NC*RNlH|Ni~`&g$DT)1%I&6_uG-@g6x(c;&8kAJ_TZX7lI`Z?*_w{JPILU-@p z{qxE7?-!@NE5r^TKK%b*;lAy&{ymd^|1!M2RO7rYW4CKY#xJKjF`>oPYmHPoF-0aFx{G@3D_=@83CJZ}+O`dzX#3&Eop|N_Fpi zxqBCM|NhP2FCInw9%D|;9+pWCOjw419WS@h30{~vdR zD&jf*{W19T%4P3z_l4~|)|wngR|_0kA-Hpn zYLq>&#`oVlt*x^KB0cz1f(1W+jM}%-LsN|D-(U0huZ#|?_C2vy;P+dlBrn!)Hw3>w z5dZa9e%}iByVtgVc&g^C$I?+I_3f_M$%FG>Ju&=tM`YV9o?kEJ_blLjagyi2YX3d+ zrGEd)x^s1lvjNw=i~9BX;@ju){r_jaf3^SjJ3`;C^Zoeoyf zoR2cKn|7_)VbIdVEiTd)6A`%Nn1gqYM9mF_18!F5q}2nGN}-U3Cw&dEHU>J90L|MDtU7qdy`S9z`RhJ{noX{+eyboSUGtN7cxKX znPT7mt;KWliU|rvzCs=yM?8eYZKh~>&WrK%pQbJ(q|>$7jl1zY%es)0%^eK$^}K{M z3_ibTY`k91aJF;P)9yxg?Sfi11|CsMw57E_}O;y zNW}RVY?<`-52@&&g$K}cb`6e`ug?j z->>HX{+j;zXz}lv^r!z%ru~+q3>WS2}$7@ZZlC zKVRAW`IYnUx697?di%D|+Oyp2|G&aZ2URazxbXgE`2WA5D|@*Aevdu7S>*2ByWc(s z99$)}dsXzNDV(QIpZ@s9>)-FFzpqp;UOaPfP2lQo#y>wpHcyxT^U3www{Lq_i2eU& z|M^4I^XJb$fBw8}7LS2A^S+fHAKw^z8gX7dX0Ug;`=5^*pFc+Z`R2c8qw4;R>LIo~ zJ7x4RIvHah^`L)TMzh25`gbIFtApY{K;QxQ-cdu>VF_-_|1>L`2oc6EwKd{>O+g-8q zhqYhbGd{4!_vIOZ-#sljQfbFoTnmC1rlsm87At}JX|m?&ygl*1w6 zd#g>}ES^KrLx7`)i&@aFz#yUFa61QE$c@HH48anDt^p1Yf)-RTnhOMo2r9A#GpKc? zT;X`c*v`srVZ*Xgv6)M_ZAQxs#|=xIJ(bw`lr%3go@^0V%ryJVgN=(1_4CQrh1@up r>?YjK_2dH+kAliX77l|w6ApVyF&Z$j*)5sS#4ph^;i3a0BZD;n=Khyf literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-yell.gif b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/images/smiley-yell.gif new file mode 100644 index 0000000000000000000000000000000000000000..7719bc43d3e92ee5f6024eee94d8dade3df1e6a1 GIT binary patch literal 1132 zcmdVZ{WF^f0KoC*G1i1M5)x_E(0JLo^Ad_YvT|s|%hg0{vw2(Au`9DJy7NQ#nqb$4 z_Gs(YRrR9Q5n;!bdKu!0pk6ELbtXBbU7CrvL_(hAd9v%DvG0HI`Qe+G%z>glbpc#} zLm7agD1smi3b?bgqu1+=Mq?-yTp11BZ70snP0QQTtw`}m3(c|y84Z^Vds&KRfA##C z?mEYfzlR1TZVH70*|Yq`je=ZiL9~E z!(9EJL`1_v*60>d#aD}zL(QTHkZ zR(+5KDKhM5`Qrf_#{9MFd&?p;Jqphb`Kab1Lft?cRTamuOZ~npy27EO0~hP0p}I6 zUkaa$lpXW+46NDriT^O<6M&WcksxL9?%U^H>n`(gb9VS<;NbQ_T&DO8EAJusk>qKk zPg;ybn*fiOdlVGKxo>I{>r*lzhpVwwupnCyQ~2UlQmyNS-}!j(iFBe3JRuplb+JN3 zvCln^#x*>mp5XK|2-h8+&UljYq&#rA@)((P^TNj`W4$x{WA5jqO6MDY{v$F67oAlu zifvDShgT7h&k=m1DG!#v=1FJ*8aHR0?D(ntaBeK{ F-hb;s-?#t( literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/cs.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/cs.js new file mode 100644 index 00000000..0fadf38e --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/cs.js @@ -0,0 +1,4 @@ +// UK lang variables + +tinyMCELang['lang_insert_emotions_title'] = 'Vložit emotikon'; +tinyMCELang['lang_emotions_desc'] = 'Emotikony'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/de.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/de.js new file mode 100644 index 00000000..fcec1317 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/de.js @@ -0,0 +1,6 @@ +// DE lang variables + + +tinyMCELang['lang_insert_emotions_title'] = 'Emotion einfügen'; +tinyMCELang['lang_emotions_desc'] = 'Emotion'; + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/el.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/el.js new file mode 100644 index 00000000..91ed1b18 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/el.js @@ -0,0 +1,5 @@ +// Greek lang variables by Jacaranda Bill + +tinyMCELang['lang_insert_emotions_title'] = 'ÅéóáãùãÞ åíüò åéêïíéäßïõ emoticon'; +tinyMCELang['lang_emotions_desc'] = 'Åéêïíßäéá emoticons'; + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/en.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/en.js new file mode 100644 index 00000000..2e350084 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/en.js @@ -0,0 +1,5 @@ +// UK lang variables + +tinyMCELang['lang_insert_emotions_title'] = 'Insert emotion'; +tinyMCELang['lang_emotions_desc'] = 'Emotions'; + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fa.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fa.js new file mode 100644 index 00000000..2deb3396 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fa.js @@ -0,0 +1,10 @@ +// IR lang variables +// Persian (Farsi) language pack (for IRAN) +// By: Morteza Zafari +// Lost@LostLord.com +// http://www.LostLord.com + +tinyMCELang['lang_dir'] = 'rtl'; +tinyMCELang['lang_insert_emotions_title'] = 'اÙزودن Ø´Ú©Ù„Ú©'; +tinyMCELang['lang_emotions_desc'] = 'شکلکها'; + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fr.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fr.js new file mode 100644 index 00000000..5dedb617 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fr.js @@ -0,0 +1,5 @@ +// French lang variables by Laurent Dran + +tinyMCELang['lang_insert_emotions_title'] = 'Insèrer un émoticon'; +tinyMCELang['lang_emotions_desc'] = 'Émoticons'; + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fr_ca.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fr_ca.js new file mode 100644 index 00000000..9836513a --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/fr_ca.js @@ -0,0 +1,5 @@ +// CAN_FR lang variables + +tinyMCELang['lang_insert_emotions_title'] = 'Insérer un émoticon'; +tinyMCELang['lang_emotions_desc'] = 'Émoticons'; + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/it.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/it.js new file mode 100644 index 00000000..55365162 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/it.js @@ -0,0 +1,5 @@ +//IT lang variables + +tinyMCELang['lang_insert_emotions_title'] = 'Inserisci una emoticon'; +tinyMCELang['lang_emotions_desc'] = 'Emoticon'; + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/ko.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/ko.js new file mode 100644 index 00000000..d48edc34 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/ko.js @@ -0,0 +1,5 @@ +// KO lang variables + +tinyMCELang['lang_insert_emotions_title'] = 'À̸ðƼÄÜ ³Ö±â'; +tinyMCELang['lang_emotions_desc'] = 'À̸ðƼÄÜ'; + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/sv.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/sv.js new file mode 100644 index 00000000..7507a586 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/sv.js @@ -0,0 +1,4 @@ +// SE lang variables + +tinyMCELang['lang_insert_emotions_title'] = 'Klistain kännsla'; +tinyMCELang['lang_emotions_desc'] = 'Kännslor'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/zh_cn.js b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/zh_cn.js new file mode 100644 index 00000000..ab36dd08 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/langs/zh_cn.js @@ -0,0 +1,5 @@ +// Simplified Chinese lang variables contributed by cube316 (cube316@etang.com) + +tinyMCELang['lang_insert_emotions_title'] = '²åÈë±íÇé'; +tinyMCELang['lang_emotions_desc'] = '±íÇé'; + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/emotions/readme.txt b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/readme.txt new file mode 100644 index 00000000..71d5f4d7 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/emotions/readme.txt @@ -0,0 +1,20 @@ + Emotions plugin for TinyMCE +------------------------------ + +Installation instructions: + * Copy the emotions directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins). + * Add plugin to TinyMCE plugin option list example: plugins : "emotions". + * Add the emotions button name to button list, example: theme_advanced_buttons3_add : "emotions". + +Initialization example: + tinyMCE.init({ + theme : "advanced", + mode : "textareas", + plugins : "emotions", + theme_advanced_buttons3_add : "emotions" + }); + +Copyright notice: + These emotions where taken from Mozilla Thunderbird. + I hope they don't get angry if I use them here after all this is a open source project + aswell and I realy love their product. diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/flash/editor_plugin.js b/includes/tinymce/jscripts/tiny_mce/plugins/flash/editor_plugin.js new file mode 100644 index 00000000..392ab08b --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/flash/editor_plugin.js @@ -0,0 +1,2 @@ +/* Import plugin specific language pack */ + tinyMCE.importPluginLanguagePack('flash','en,de,sv,zh_cn,cs,fa,fr_ca,fr');function TinyMCE_flash_getControlHTML(control_name){switch(control_name){case "flash":return '';}return "";}function TinyMCE_flash_parseAttributes(attribute_string){var attributeName="";var attributeValue="";var withInName;var withInValue;var attributes=new Array();var whiteSpaceRegExp=new RegExp('^[ \n\r\t]+','g');if(attribute_string==null||attribute_string.length<2)return null;withInName=withInValue=false;for(var i=0;i','gi'),'');content=content.replace(new RegExp('<[ ]*object','gi'),'','gi'),'');while((startPos=content.indexOf('',startPos);var attribs=TinyMCE_flash_parseAttributes(content.substring(startPos+6,endPos));embedList[embedList.length]=attribs;}var index=0;while((startPos=content.indexOf('',startPos);endPos=content.indexOf('/>',endPos);if(endPos==-1){endPos=content.indexOf('',endPos);endPos+=8;}else endPos+=2;if(index>=embedList.length)break;var attribs=embedList[index];var contentAfter=content.substring(endPos+1);content=content.substring(0,startPos);content+=''+content.substring(endPos+1);content+=contentAfter;index++;startPos++;}break;case "get_from_editor":var startPos=0;while((startPos=content.indexOf('',startPos);var attribs=TinyMCE_flash_parseAttributes(content.substring(startPos+4,endPos));if(attribs['name']!="mce_plugin_flash")break;endPos+=2;var embedHTML='';embedHTML+='';embedHTML+='';embedHTML+='';embedHTML+='';embedHTML+='';content=content.substring(0,startPos)+embedHTML+content.substring(endPos+1);startPos++;}break;}return content;}function TinyMCE_flash_handleNodeChange(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";}tinyMCE.switchClassSticky(editor_id+'_flash','mceButtonNormal');if(node==null)return;do{if(node.nodeName.toLowerCase()=="img"&&getAttrib(node,'name').indexOf('mce_plugin_flash')==0)tinyMCE.switchClassSticky(editor_id+'_flash','mceButtonSelected');}while((node=node.parentNode));return true;} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/flash/editor_plugin_src.js b/includes/tinymce/jscripts/tiny_mce/plugins/flash/editor_plugin_src.js new file mode 100644 index 00000000..deeb2de9 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/flash/editor_plugin_src.js @@ -0,0 +1,213 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('flash', 'en,de,sv,zh_cn,cs,fa,fr_ca,fr'); + +function TinyMCE_flash_getControlHTML(control_name) { + switch (control_name) { + case "flash": + return ''; + } + + return ""; +} + +function TinyMCE_flash_parseAttributes(attribute_string) { + var attributeName = ""; + var attributeValue = ""; + var withInName; + var withInValue; + var attributes = new Array(); + var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g'); + + if (attribute_string == null || attribute_string.length < 2) + return null; + + withInName = withInValue = false; + + for (var i=0; i','gi'),''); + content = content.replace(new RegExp('<[ ]*object','gi'),'','gi'),''); + + // Parse all embed tags + while ((startPos = content.indexOf('', startPos); + var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 6, endPos)); + embedList[embedList.length] = attribs; + } + + // Parse all object tags and replace them with images from the embed data + var index = 0; + while ((startPos = content.indexOf('', startPos); + + // Find end of embed + endPos = content.indexOf('/>', endPos); + if (endPos == -1) { + endPos = content.indexOf('', endPos); + endPos += 8; + } else + endPos += 2; + + if (index >= embedList.length) + break; + + var attribs = embedList[index]; + + // Insert image + var contentAfter = content.substring(endPos+1); + content = content.substring(0, startPos); + content += '' + content.substring(endPos+1); + content += contentAfter; + index++; + + startPos++; + } + break; + + case "get_from_editor": + // Parse all img tags and replace them with object+embed + var startPos = 0; + while ((startPos = content.indexOf('', startPos); + var attribs = TinyMCE_flash_parseAttributes(content.substring(startPos + 4, endPos)); + + // Is not flash + if (attribs['name'] != "mce_plugin_flash") + break; + + endPos += 2; + + var embedHTML = ''; + + // Insert object + embed + embedHTML += ''; + embedHTML += ''; + embedHTML += ''; + embedHTML += ''; + embedHTML += ''; + +/* + + + + + + + +*/ + + content = content.substring(0, startPos) + embedHTML + content.substring(endPos+1); + + startPos++; + } + break; + } + + // Pass through to next handler in chain + return content; +} + +function TinyMCE_flash_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { + function getAttrib(elm, name) { + return elm.getAttribute(name) ? elm.getAttribute(name) : ""; + } + + tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonNormal'); + + if (node == null) + return; + + do { + if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'name').indexOf('mce_plugin_flash') == 0) + tinyMCE.switchClassSticky(editor_id + '_flash', 'mceButtonSelected'); + } while ((node = node.parentNode)); + + return true; +} diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/flash/flash.htm b/includes/tinymce/jscripts/tiny_mce/plugins/flash/flash.htm new file mode 100644 index 00000000..6864d569 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/flash/flash.htm @@ -0,0 +1,169 @@ + + + + +{$lang_insert_flash} + + + + + + +
+ + + + + + + + + + + + + + + +
{$lang_insert_flash}

+ + + + + + + + + + + +
{$lang_insert_flash_file}: + + + + + +
+
{$lang_insert_flash_size}: + +  x  + +

+ +
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/flash/images/flash.gif b/includes/tinymce/jscripts/tiny_mce/plugins/flash/images/flash.gif new file mode 100644 index 0000000000000000000000000000000000000000..4950e673cfe090074b13328ad31d548186b891bd GIT binary patch literal 664 zcmV;J0%!e4Nk%w1VH5xq0QLX?|NsB~{{H>_{rLI%_V@Vq_xbhp_4M`k^z`)d^78TX z_VM!d@bdKW@$v8R^zZTW@9*#K?(XdF@$2pI?Ck95>+a|4@#pLC=;-L>=$j{ix&D6)u*Tl@$#?05p%hJNj z)xpTryT;PF#nigO$+o}Ev%t}|yTGu!#i_W;sT0EgOG56l5c;EX@HYyf0Al_k86C1XL*TZ zcZpnik5p)T6I_BIQE>%HZ45wT7C2T1I$Q%gUIsZ_1vXd(H(CWXSOhdy1T$0wFj53D zQUotg1T9SiEJy(-N&o-=000000000000000000000000000000A^8LW000I6EC2ui z02BZe000N|fChqtgoTEOh=~RlOj%=NSxgs-3N%q#Q%FctT2V9#hYmntOFt+iBr{7* zVL%RsH(@v>84?dRc6MY#VK;>qQad9P1p*9cW@Kb0KT;NiN?t4#0{{R}YGha@CM{k{ zgjPNt3jyZ3WkxwEDMMC-U@{v7)';return "";}function TinyMCE_iespell_execCommand(editor_id,element,command,user_interface,value){if(command=="mceIESpell"){try{var ieSpell=new ActiveXObject("ieSpell.ieSpellExtension");ieSpell.CheckDocumentNode(tinyMCE.getInstanceById(editor_id).contentDocument.documentElement);}catch(e){if(e.number==-2146827859){if(confirm(tinyMCE.getLang("lang_iespell_download","",true)))window.open('http://www.iespell.com/download.php','ieSpellDownload','');}else alert("Error Loading ieSpell: Exception "+e.number);}return true;}return false;} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/editor_plugin_src.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/editor_plugin_src.js new file mode 100644 index 00000000..7b184f8f --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/editor_plugin_src.js @@ -0,0 +1,37 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('iespell', 'cs,el,en,fr_ca,it,ko,sv,zh_cn,fr,de'); + +/** + * Returns the HTML contents of the iespell control. + */ +function TinyMCE_iespell_getControlHTML(control_name) { + // Is it the iespell control and is the brower MSIE. + if (control_name == "iespell" && tinyMCE.isMSIE) + return ''; + + return ""; +} + +/** + * Executes the mceIESpell command. + */ +function TinyMCE_iespell_execCommand(editor_id, element, command, user_interface, value) { + // Handle ieSpellCommand + if (command == "mceIESpell") { + try { + var ieSpell = new ActiveXObject("ieSpell.ieSpellExtension"); + ieSpell.CheckDocumentNode(tinyMCE.getInstanceById(editor_id).contentDocument.documentElement); + } catch (e) { + if (e.number == -2146827859) { + if (confirm(tinyMCE.getLang("lang_iespell_download", "", true))) + window.open('http://www.iespell.com/download.php', 'ieSpellDownload', ''); + } else + alert("Error Loading ieSpell: Exception " + e.number); + } + + return true; + } + + // Pass to next handler in chain + return false; +} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/images/iespell.gif b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/images/iespell.gif new file mode 100644 index 0000000000000000000000000000000000000000..46c0c4a66a49c81d695ebc0ffb12aa991489d4db GIT binary patch literal 151 zcmZ?wbhEHb6k!ly*vtR||NsB@^<8F=@gSh#!GsMT3<@6HzH!ml*B2-bmPa8Jf3h$# zFmN*HfJ8xNFtE57ob+71*W&eA-ANq=t&&ANot<^F4Ax|Lbx!TzN_ToK{_1$=^>xaU lLcOv}js`HM@vQfp^7)rwv;Lt_BL$Idlk_Y0^fEA50|3CZG!y^; literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/cs.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/cs.js new file mode 100644 index 00000000..06e8c515 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/cs.js @@ -0,0 +1,4 @@ +// UK lang variables + +tinyMCELang['lang_iespell_desc'] = 'Spustit kontrolu pravopisu'; +tinyMCELang['lang_iespell_download'] = "ieSpell nedetekován. Kliknìte na OK a otevøete stahovací stránku." \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/de.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/de.js new file mode 100644 index 00000000..4b1417b4 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/de.js @@ -0,0 +1,4 @@ +// DE lang variables by Tobias Heer + +tinyMCELang['lang_iespell_desc'] = 'Rechtschreibprüfung'; +tinyMCELang['lang_iespell_download'] = "ieSpell nicht gefunden. Klicken Sie OK um auf die Download Seite zu gelangen." diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/el.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/el.js new file mode 100644 index 00000000..83ac3b83 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/el.js @@ -0,0 +1,4 @@ +// Greek lang variables by Jacaranda Bill + +tinyMCELang['lang_iespell_desc'] = 'Ïñèïãñáöéêüò Ýëåã÷ïò'; +tinyMCELang['lang_iespell_download'] = "Ôï ðñüãñáììá ieSpell äåí âñÝèçêå. ÐáôÞóôå OK ãéá íá ìåôáâåßôå óôçí éóôïóåëßäá ëÞøçò ôïõ ðñïãñÜììáôïò." diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/en.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/en.js new file mode 100644 index 00000000..d4fe21c6 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/en.js @@ -0,0 +1,4 @@ +// UK lang variables + +tinyMCELang['lang_iespell_desc'] = 'Run spell checking'; +tinyMCELang['lang_iespell_download'] = "ieSpell not detected. Click OK to go to download page." diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/fr.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/fr.js new file mode 100644 index 00000000..ae0f273a --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/fr.js @@ -0,0 +1,4 @@ +// French lang variables by Laurent Dran + +tinyMCELang['lang_iespell_desc'] = 'Executer le vérificateur d\'orthographe'; +tinyMCELang['lang_iespell_download'] = "ieSpell n\'a pas été trouvé. Cliquez sur OK pour aller au site de téléchargement." diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/fr_ca.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/fr_ca.js new file mode 100644 index 00000000..2cef91be --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/fr_ca.js @@ -0,0 +1,4 @@ +// CAN_FR lang variables + +tinyMCELang['lang_iespell_desc'] = 'Executer le vérificateur d\'orthographe'; +tinyMCELang['lang_iespell_download'] = "ieSpell n\'a pas été trouvé. Cliquez sur OK pour aller au site de téléchargement."; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/it.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/it.js new file mode 100644 index 00000000..711ac6d9 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/it.js @@ -0,0 +1,4 @@ +// IT lang variables + +tinyMCELang['lang_iespell_desc'] = 'Avvia il controllo ortografico'; +tinyMCELang['lang_iespell_download'] = "ieSpell non trovato. Clicca OK per andare alla pagina di download." diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/ko.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/ko.js new file mode 100644 index 00000000..c66f4de8 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/ko.js @@ -0,0 +1,4 @@ +// KO lang variables + +tinyMCELang['lang_iespell_desc'] = '¸ÂÃã¹ý °Ë»ç ½ÇÇà'; +tinyMCELang['lang_iespell_download'] = "ieSpellÀ» ãÀ» ¼ö ¾ø½À´Ï´Ù. OK¸¦ ´©¸£¸é ´Ù¿î·Îµå ÆäÀÌÁö·Î À̵¿ÇÕ´Ï´Ù." diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/sv.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/sv.js new file mode 100644 index 00000000..f77b39ff --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/sv.js @@ -0,0 +1,4 @@ +// SE lang variables + +tinyMCELang['lang_iespell_desc'] = 'Kör rättstavningskontroll'; +tinyMCELang['lang_iespell_download'] = "ieSpell verkar inte vara installerad. Klicka OK för att ladda hem." diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/zh_cn.js b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/zh_cn.js new file mode 100644 index 00000000..41401203 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/langs/zh_cn.js @@ -0,0 +1,4 @@ +// Simplified Chinese lang variables contributed by cube316 (cube316@etang.com) + +tinyMCELang['lang_iespell_desc'] = 'ÔËÐÐƴд¼ì²é'; +tinyMCELang['lang_iespell_download'] = "δ¼ì²âµ½ieSpellƴд¼ì²é£¬µã»÷ OK Ç°ÍùÏÂÔØÒ³Ãæ¡£" diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/iespell/readme.txt b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/readme.txt new file mode 100644 index 00000000..d87b47e6 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/iespell/readme.txt @@ -0,0 +1,20 @@ + ieSpell plugin for TinyMCE +---------------------------- + +Installation instructions: + * Copy the iespell directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins). + * Add plugin to TinyMCE plugin option list example: plugins : "iespell". + * Add the iespell button name to button list, example: theme_advanced_buttons3_add : "iespell". + +Initialization example: + tinyMCE.init({ + theme : "advanced", + mode : "textareas", + plugins : "iespell", + theme_advanced_buttons3_add : "iespell" + }); + +Requirements: + The end user will need MSIE on Windows with the ieSpell installed. This can be downloaded + from http://www.iespell.com/download.php. Notice on other browsers than MSIE the spellchecking + button will not be visible. diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin.js new file mode 100644 index 00000000..49b883a6 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/editor_plugin.js @@ -0,0 +1,2 @@ +/* Import plugin specific language pack */ + tinyMCE.importPluginLanguagePack('insertdatetime','cs,el,en,fr_ca,it,ko,sv,zh_cn,fa,fr,de');function TinyMCE_insertdatetime_getControlHTML(control_name){switch(control_name){case "insertdate":return '';case "inserttime":return '';}return "";}function TinyMCE_insertdatetime_execCommand(editor_id,element,command,user_interface,value){function addZeros(value,len){value=""+value;if(value.length'; + + case "inserttime": + return ''; + } + + return ""; +} + +/** + * Executes the mceInsertDate command. + */ +function TinyMCE_insertdatetime_execCommand(editor_id, element, command, user_interface, value) { + /* Adds zeros infront of value */ + function addZeros(value, len) { + value = "" + value; + + if (value.length < len) { + for (var i=0; i<(len-value.length); i++) + value = "0" + value; + } + + return value; + } + + /* Returns the date object in the specified format */ + function getDateTime(date, format) { + format = tinyMCE.regexpReplace(format, "%D", "%m/%d/%y"); + format = tinyMCE.regexpReplace(format, "%r", "%I:%M:%S %p"); + format = tinyMCE.regexpReplace(format, "%Y", "" + date.getFullYear()); + format = tinyMCE.regexpReplace(format, "%y", "" + date.getYear()); + format = tinyMCE.regexpReplace(format, "%m", addZeros(date.getMonth()+1, 2)); + format = tinyMCE.regexpReplace(format, "%d", addZeros(date.getDate(), 2)); + format = tinyMCE.regexpReplace(format, "%H", "" + addZeros(date.getHours(), 2)); + format = tinyMCE.regexpReplace(format, "%M", "" + addZeros(date.getMinutes(), 2)); + format = tinyMCE.regexpReplace(format, "%S", "" + addZeros(date.getSeconds(), 2)); + format = tinyMCE.regexpReplace(format, "%I", "" + (date.getHours() < 12 ? (date.getHours()+1) : 24-date.getHours())); + format = tinyMCE.regexpReplace(format, "%p", "" + (date.getHours() < 12 ? "AM" : "PM")); + format = tinyMCE.regexpReplace(format, "%%", "%"); + + return format; + } + + // Handle commands + switch (command) { + case "mceInsertDate": + tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_dateFormat", "%Y-%m-%d"))); + return true; + + case "mceInsertTime": + tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_timeFormat", "%H:%M:%S"))); + return true; + } + + // Pass to next handler in chain + return false; +} diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/images/insertdate.gif b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/images/insertdate.gif new file mode 100644 index 0000000000000000000000000000000000000000..5002f8746349bc868efbc06491232dfa97d3c109 GIT binary patch literal 1031 zcmZ?wbhEHb6k!lyXlDQc0S*BLAkZ){uy8Q&NN@lGkAQ%Pgn$Gv$N-WB2?YfO6$J(f z7Ys5kI21f^sCW?2@F1Y$K>`p>c#tsTL&1y(1weAahlYv%!HNS5HUQCu1v@Tm0HOmI799A$;lhUlI}U)sg##ym=)r*t z4-VY;aN)v(3par1!-WU`9{|CN{|`R=|M23&2O#<5|9>F*{~zp+QDQU%NDcwTpDfG_ z3{DI>Af2E*!NBo^p_N0%W5a@j%^bp7HW7;+atKQ3giKISbUGxY8#Tkgv8knvM_eIB z=c9nL^CSV)pe+^wt`ihYni8&@xTx$gkvVve3c~?K7cOBfw+aV=qrGg*DLYzz2Dwd; z*X9zi5p-d1V6|#4d2pbSkw;!*2_KK(lfw+`ZkZ(s2OJ!jL=rixHaIdca<6in^Nph* z`8elBCR>(DMh1qPdmPPV9!z|^{*Hn}*pC^~&8!>@ashKV7$Z8`CAGsA2*|XwGO=hB tU3s9hz2P-eld|-TLZ)_Z{<++Be7xnG+3#=`?w5O4weaI(HfAOUYXDDa&Tjw! literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/images/inserttime.gif b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/images/inserttime.gif new file mode 100644 index 0000000000000000000000000000000000000000..eb76a832d4af92c335a27f1d30094cde8b763cc1 GIT binary patch literal 958 zcmZ?wbhEHb6k!lyXlDQc1B(DFrwA+02!ntE2af<(pM;?J?AWB@goK31jJAM^4e9x< z2?Y%qbyJJVnv1G?%UY)-bX+LtI8ZR-Lcxp&4Gj|-yJodbo_a5AS^yr2I7Zx1&zu~}x4JZC@xbXkLjsph|95{UV$mx^k4ji~};KYT~ zXD?j4a_#!{8wYOuzwqGygBKqjy!ij%!~YK;@c+Y)|NnvL|9`OOMv2i7z!w6FKUtU= z7(5wtK#D+lf`MZ;!(3ogmQgH Vp#uXWM}duu&yEd=jf{*8)&Tr^#vK3v literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/cs.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/cs.js new file mode 100644 index 00000000..3cdd3c5f --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/cs.js @@ -0,0 +1,4 @@ +// UK lang variables + +tinyMCELang['lang_insertdate_desc'] = 'Vložit datum'; +tinyMCELang['lang_inserttime_desc'] = 'Vložit èas'; \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/de.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/de.js new file mode 100644 index 00000000..033ae643 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/de.js @@ -0,0 +1,4 @@ +// DE lang variables + +tinyMCELang['lang_insertdate_desc'] = 'Datum einfügen'; +tinyMCELang['lang_inserttime_desc'] = 'Zeit einfügen'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/el.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/el.js new file mode 100644 index 00000000..46039f16 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/el.js @@ -0,0 +1,4 @@ +// Greek lang variables by Jacaranda Bill + +tinyMCELang['lang_insertdate_desc'] = 'ÅéóáãùãÞ çìåñïìçíßáò'; +tinyMCELang['lang_inserttime_desc'] = 'ÅéóáãùãÞ þñáò'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/en.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/en.js new file mode 100644 index 00000000..34abd9ea --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/en.js @@ -0,0 +1,4 @@ +// UK lang variables + +tinyMCELang['lang_insertdate_desc'] = 'Insert date'; +tinyMCELang['lang_inserttime_desc'] = 'Insert time'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fa.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fa.js new file mode 100644 index 00000000..720ed6c6 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fa.js @@ -0,0 +1,9 @@ +// IR lang variables +// Persian (Farsi) language pack (for IRAN) +// By: Morteza Zafari +// Lost@LostLord.com +// http://www.LostLord.com + +tinyMCELang['lang_dir'] = 'rtl'; +tinyMCELang['lang_insertdate_desc'] = 'اÙزودن تاریخ'; +tinyMCELang['lang_inserttime_desc'] = 'اÙزودن زمان'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fr.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fr.js new file mode 100644 index 00000000..8bce0175 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fr.js @@ -0,0 +1,4 @@ +// French lang variables by Laurent Dran + +tinyMCELang['lang_insertdate_desc'] = 'Insèrer la date'; +tinyMCELang['lang_inserttime_desc'] = 'Insèrer l\'heure'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fr_ca.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fr_ca.js new file mode 100644 index 00000000..4df3045c --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/fr_ca.js @@ -0,0 +1,4 @@ +// CAN_FR lang variables + +tinyMCELang['lang_insertdate_desc'] = 'Insérer la date'; +tinyMCELang['lang_inserttime_desc'] = 'Insérer l\'heure'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/it.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/it.js new file mode 100644 index 00000000..cdac505a --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/it.js @@ -0,0 +1,4 @@ +// IT lang variables + +tinyMCELang['lang_insertdate_desc'] = 'Inserisci data'; +tinyMCELang['lang_inserttime_desc'] = 'Inserisci ora'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/ko.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/ko.js new file mode 100644 index 00000000..410f49d1 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/ko.js @@ -0,0 +1,4 @@ +// KO lang variables + +tinyMCELang['lang_insertdate_desc'] = '³¯Â¥ ³Ö±â'; +tinyMCELang['lang_inserttime_desc'] = '½Ã°£ ³Ö±â'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/sv.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/sv.js new file mode 100644 index 00000000..a205c7f6 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/sv.js @@ -0,0 +1,4 @@ +// SE lang variables + +tinyMCELang['lang_insertdate_desc'] = 'Klistra in datum'; +tinyMCELang['lang_inserttime_desc'] = 'Klistra in tid'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/zh_cn.js b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/zh_cn.js new file mode 100644 index 00000000..dc52a850 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/langs/zh_cn.js @@ -0,0 +1,4 @@ +// Simplified Chinese lang variables contributed by cube316 (cube316@etang.com) + +tinyMCELang['lang_insertdate_desc'] = '²åÈ뵱ǰÈÕÆÚ'; +tinyMCELang['lang_inserttime_desc'] = '²åÈ뵱ǰʱ¼ä'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/readme.txt b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/readme.txt new file mode 100644 index 00000000..b2f7e6d6 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/insertdatetime/readme.txt @@ -0,0 +1,35 @@ + InsertDateTime plugin for TinyMCE +----------------------------------- + +Installation instructions: + * Copy the insertdatetime directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins). + * Add plugin to TinyMCE plugin option list example: plugins : "insertdatetime". + * Add the insertdate or inserttime button name to button list, example: theme_advanced_buttons3_add : "insertdate,inserttime". + +Initialization example: + tinyMCE.init({ + theme : "advanced", + mode : "textareas", + plugins : "insertdatetime", + theme_advanced_buttons3_add : "insertdate,inserttime", + plugin_insertdate_dateFormat : "%Y-%m-%d", + plugin_insertdate_timeFormat : "%H:%M:%S" + }); + +Configuration: + plugin_insertdate_dateFormat - Format that the date is output as. Defaults to: "%Y-%m-%d". + Replacement variables: + %y - year as a decimal number without a century (range 00 to 99) + %Y - year as a decimal number including the century + %d - day of the month as a decimal number (range 01 to 31) + %m - month as a decimal number (range 01 to 12) + %D - same as %m/%d/%y + %r - time in a.m. and p.m. notation + %H - hour as a decimal number using a 24-hour clock (range 00 to 23) + %I - hour as a decimal number using a 12-hour clock (range 01 to 12) + %M - minute as a decimal number (range 00-59) + %S - second as a decimal number (range 00-59) + %p - either `am' or `pm' according to the given time value + %% - a literal `%' character + + plugin_insertdate_timeFormat - Format that the time is output as. Defaults to: "%H:%M:%S". diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/editor_plugin.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/editor_plugin.js new file mode 100644 index 00000000..5e896ebe --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/editor_plugin.js @@ -0,0 +1,2 @@ +/* Import plugin specific language pack */ + tinyMCE.importPluginLanguagePack('preview','cs,de,el,en,fr_ca,it,ko,pt,sv,zh_cn,fa,fr');function TinyMCE_preview_getControlHTML(control_name){switch(control_name){case "preview":return '';}return "";}function TinyMCE_preview_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mcePreview":var previewPage=tinyMCE.getParam("plugin_preview_pageurl",null);var previewWidth=tinyMCE.getParam("plugin_preview_width","550");var previewHeight=tinyMCE.getParam("plugin_preview_height","600");if(previewPage){var template=new Array();template['file']=previewPage;template['width']=previewWidth;template['height']=previewHeight;tinyMCE.openWindow(template,{editor_id:editor_id,resizable:"yes",scrollbars:"yes",content:tinyMCE.getContent(),content_css:tinyMCE.getParam("content_css")});}else{var win=window.open("","mcePreview","menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width="+previewWidth+",height="+previewHeight);var html="";html+='';html+='';html+='';html+=''+tinyMCE.getLang('lang_preview_desc')+'';html+='';html+='';html+='';html+='';html+=tinyMCE.getContent();html+='';html+='';win.document.write(html);win.document.close();}return true;}return false;} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/editor_plugin_src.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/editor_plugin_src.js new file mode 100644 index 00000000..d1c4a612 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/editor_plugin_src.js @@ -0,0 +1,61 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('preview', 'cs,de,el,en,fr_ca,it,ko,pt,sv,zh_cn,fa,fr'); + +/** + * Returns the HTML contents of the preview control. + */ +function TinyMCE_preview_getControlHTML(control_name) { + switch (control_name) { + case "preview": + return ''; + } + + return ""; +} + +/** + * Executes the mcePreview command. + */ +function TinyMCE_preview_execCommand(editor_id, element, command, user_interface, value) { + // Handle commands + switch (command) { + case "mcePreview": + var previewPage = tinyMCE.getParam("plugin_preview_pageurl", null); + var previewWidth = tinyMCE.getParam("plugin_preview_width", "550"); + var previewHeight = tinyMCE.getParam("plugin_preview_height", "600"); + + // Use a custom preview page + if (previewPage) { + var template = new Array(); + + template['file'] = previewPage; + template['width'] = previewWidth; + template['height'] = previewHeight; + + tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "yes", content : tinyMCE.getContent(), content_css : tinyMCE.getParam("content_css")}); + } else { + var win = window.open("", "mcePreview", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width=" + previewWidth + ",height=" + previewHeight); + var html = ""; + + html += ''; + html += ''; + html += ''; + html += '' + tinyMCE.getLang('lang_preview_desc') + ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += tinyMCE.getContent(); + html += ''; + html += ''; + + win.document.write(html); + win.document.close(); + } + + return true; + } + + // Pass to next handler in chain + return false; +} diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/example.html b/includes/tinymce/jscripts/tiny_mce/plugins/preview/example.html new file mode 100644 index 00000000..15ed4713 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/example.html @@ -0,0 +1,14 @@ + + + + +Example of a custom preview page + + + + +Editor contents:
+{$content} + + + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/images/preview.gif b/includes/tinymce/jscripts/tiny_mce/plugins/preview/images/preview.gif new file mode 100644 index 0000000000000000000000000000000000000000..4e7900c3192d4eecbd603575b813791536928f42 GIT binary patch literal 1024 zcmeH`!D|yi6o)q^Xc_})YAZ;Bq#=h0C5$D9L@(P`G}6l=A`yg6f?^a8bIifRq%Ca@ z)lNdtr57iOq(MYRQQQ^}n`kt)N~eMlw1qKx=yB_*#lyPkpCNvH?;U=(_k(xg;`vxS zH7E^A^HL9xfHDZc1b_-a3Q&@YtUx)5U{XOD1wxp$AtMYk7$S_a7-#^fGT^ez zkV27CM}QE72_i(H0;(M51*Af5W7y#Y$$D0%1Tg}ciZ}*Bl?9azrkHJr^JH$Jh{*ve zSt>omD#dkz877vL63W=}((1EEkE>-`XOvMZc+JWyFKer>mfx^4sq55|S#qjzrs+)M zm=i3lj5A#@Zs?lcey8acZELvR=FPS5&9$w!>s!3dzjeOq9fNlS?--&Zdh8ft#}tNX z^e~M*!`L%TOVd24?f?208W`Sp*d^(vG}1e!_Y;zHTiS5?6O1-yoSxCE8tN+suMD`Z zr)!nguYjW|pbKbuX8q@CZ&_}#d{z>~ICr1_ZqvbwvdPBCh%cFq|G6>g zJ$&c$Layt0?*&sYqJ@5YzTq2MC!5{$hhlKRT>`t+K-V|%U?l##(wKGxFFg(H&Wd}b ix+j2Xc`SD#z?t*f@A8N`A>H5BXFP7FboMVqlNY)G literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/cs.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/cs.js new file mode 100644 index 00000000..cf994670 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/cs.js @@ -0,0 +1,3 @@ +// UK lang variables + +tinyMCELang['lang_preview_desc'] = 'Náhled'; \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/de.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/de.js new file mode 100644 index 00000000..edef732b --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/de.js @@ -0,0 +1,3 @@ +// DE lang variables by Tobias Heer + +tinyMCELang['lang_preview_desc'] = 'Vorschau'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/el.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/el.js new file mode 100644 index 00000000..cd4db965 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/el.js @@ -0,0 +1,3 @@ +// Greek lang variables by Jacaranda Bill + +tinyMCELang['lang_preview_desc'] = 'Ðñïåðéóêüðçóç éóôïóåëßäáò'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/en.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/en.js new file mode 100644 index 00000000..bd7172a6 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/en.js @@ -0,0 +1,3 @@ +// UK lang variables + +tinyMCELang['lang_preview_desc'] = 'Preview'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fa.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fa.js new file mode 100644 index 00000000..c2e05187 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fa.js @@ -0,0 +1,8 @@ +// IR lang variables +// Persian (Farsi) language pack (for IRAN) +// By: Morteza Zafari +// Lost@LostLord.com +// http://www.LostLord.com + +tinyMCELang['lang_dir'] = 'rtl'; +tinyMCELang['lang_preview_desc'] = 'پیش نمایش'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fr.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fr.js new file mode 100644 index 00000000..e0c1f820 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fr.js @@ -0,0 +1,3 @@ +// French lang variables by Laurent Dran + +tinyMCELang['lang_preview_desc'] = 'Prévisualisation'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fr_ca.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fr_ca.js new file mode 100644 index 00000000..70922526 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/fr_ca.js @@ -0,0 +1,3 @@ +// CAN_FR lang variables + +tinyMCELang['lang_preview_desc'] = 'Prévisualisation'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/it.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/it.js new file mode 100644 index 00000000..1e1320df --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/it.js @@ -0,0 +1,3 @@ +// IT lang variables + +tinyMCELang['lang_preview_desc'] = 'Anteprima'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/ko.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/ko.js new file mode 100644 index 00000000..fd0d86cd --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/ko.js @@ -0,0 +1,3 @@ +// KO lang variables + +tinyMCELang['lang_preview_desc'] = '¹Ì¸®º¸±â'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/pt.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/pt.js new file mode 100644 index 00000000..a260d84e --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/pt.js @@ -0,0 +1,3 @@ +// UK lang variables + +tinyMCELang['lang_preview_desc'] = 'Pré-visualização'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/sv.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/sv.js new file mode 100644 index 00000000..5e3c46e6 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/sv.js @@ -0,0 +1,3 @@ +// SE lang variables + +tinyMCELang['lang_preview_desc'] = 'Förhandsgranska'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/zh_cn.js b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/zh_cn.js new file mode 100644 index 00000000..2c7e99ce --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/langs/zh_cn.js @@ -0,0 +1,3 @@ +// Simplified Chinese lang variables contributed by cube316 (cube316@etang.com) + +tinyMCELang['lang_preview_desc'] = 'Ô¤ÀÀ'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/preview/readme.txt b/includes/tinymce/jscripts/tiny_mce/plugins/preview/readme.txt new file mode 100644 index 00000000..a8acc993 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/preview/readme.txt @@ -0,0 +1,23 @@ + Preview plugin for TinyMCE +----------------------------------- + +Installation instructions: + * Copy the preview directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins). + * Add plugin to TinyMCE plugin option list example: plugins : "preview". + * Add the preview button name to button list, example: theme_advanced_buttons3_add : "preview". + +Initialization example: + tinyMCE.init({ + theme : "advanced", + mode : "textareas", + plugins : "preview", + theme_advanced_buttons3_add : "preview", + plugin_preview_width : "500", + plugin_preview_height : "600" + }); + +Configuration: + plugin_preview_width - Preview window width. Defaults to 550. + plugin_preview_height - Preview window height. Defaults to 600. + plugin_preview_pageurl - Custom preview page URL relative from theme + use "../../plugins/preview/example.html" for a example. diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/editor_plugin.js b/includes/tinymce/jscripts/tiny_mce/plugins/print/editor_plugin.js new file mode 100644 index 00000000..8311d6fa --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/print/editor_plugin.js @@ -0,0 +1,2 @@ +/* Import theme specific language pack */ + tinyMCE.importPluginLanguagePack('print','en,sv,zh_cn,fa,fr_ca,fr,de');function TinyMCE_print_getControlHTML(control_name){switch(control_name){case "print":return '';}return "";}function TinyMCE_print_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mcePrint":tinyMCE.getInstanceById(editor_id).contentWindow.print();return true;}return false;} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/editor_plugin_src.js b/includes/tinymce/jscripts/tiny_mce/plugins/print/editor_plugin_src.js new file mode 100644 index 00000000..ebc84fea --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/print/editor_plugin_src.js @@ -0,0 +1,26 @@ +/* Import theme specific language pack */ +tinyMCE.importPluginLanguagePack('print', 'en,sv,zh_cn,fa,fr_ca,fr,de'); + +function TinyMCE_print_getControlHTML(control_name) { + switch (control_name) { + case "print": + return ''; + } + + return ""; +} + +/** + * Executes the search/replace commands. + */ +function TinyMCE_print_execCommand(editor_id, element, command, user_interface, value) { + // Handle commands + switch (command) { + case "mcePrint": + tinyMCE.getInstanceById(editor_id).contentWindow.print(); + return true; + } + + // Pass to next handler in chain + return false; +} diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/images/print.gif b/includes/tinymce/jscripts/tiny_mce/plugins/print/images/print.gif new file mode 100644 index 0000000000000000000000000000000000000000..1172f4db8ba0ed5826f859a9f702b2364b26d2f6 GIT binary patch literal 1013 zcmZ?wbhEHb6k!lyXlDQc1CIoUfC7hzf&d^&0HTI~jE2aJwuFp^go1|j^45fc2?-Sw z7#1)H{AVa=m{8ELprB*HhW`u=9Sd4}7dK2;&@f>`>y%9mGd4_`wP?bO4O8Z9>RGsL z!h#Je*6!M{eb0mi2NtY2uwVlaUD&YUz=j}L@Zs>0gNKiuICT8< z;gjc1o<4El#D&XO?_Iuj|Mu-WckkajaN@y%3l9$5_;BIEgNqj*T(|*5A1*xj@BoNj z0MY*kA3i+z@c#n{{QvOd|9>F*{~zqFQDQU%2#0{;PZnkd26qM>kWx^dVBomK(9a>` zv0=f%W)5Mkm;r8R3(~D z9PM^#Zifdt2cqM|t!627}i8pPQmWegHZ4=^zHF|%AauwmQV K+g!{{4AuY;^xhEw literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/de.js b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/de.js new file mode 100644 index 00000000..c4175fde --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/de.js @@ -0,0 +1,3 @@ +// DE lang variables + +tinyMCELang['lang_print_desc'] = 'Drucken'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/en.js b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/en.js new file mode 100644 index 00000000..7c9e2335 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/en.js @@ -0,0 +1,3 @@ +// UK lang variables + +tinyMCELang['lang_print_desc'] = 'Print'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fa.js b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fa.js new file mode 100644 index 00000000..53deb6f9 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fa.js @@ -0,0 +1,8 @@ +// IR lang variables +// Persian (Farsi) language pack (for IRAN) +// By: Morteza Zafari +// Lost@LostLord.com +// http://www.LostLord.com + +tinyMCELang['lang_dir'] = 'rtl'; +tinyMCELang['lang_print_desc'] = 'چاپ'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fr.js b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fr.js new file mode 100644 index 00000000..33c33c80 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fr.js @@ -0,0 +1,3 @@ +// French lang variables by Laurent Dran + +tinyMCELang['lang_print_desc'] = 'Imprimer'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fr_ca.js b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fr_ca.js new file mode 100644 index 00000000..58b5068c --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/fr_ca.js @@ -0,0 +1,3 @@ +// CA_FR lang variables + +tinyMCELang['lang_print_desc'] = 'Imprimer'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/sv.js b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/sv.js new file mode 100644 index 00000000..c041266d --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/sv.js @@ -0,0 +1,3 @@ +// SE lang variables + +tinyMCELang['lang_print_desc'] = 'Skrivut'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/zh_cn.js b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/zh_cn.js new file mode 100644 index 00000000..72957fb0 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/print/langs/zh_cn.js @@ -0,0 +1,3 @@ +// Simplified Chinese lang variables contributed by cube316 (cube316@etang.com) + +tinyMCELang['lang_print_desc'] = '´òÓ¡'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/print/readme.txt b/includes/tinymce/jscripts/tiny_mce/plugins/print/readme.txt new file mode 100644 index 00000000..28169c53 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/print/readme.txt @@ -0,0 +1,17 @@ + Print plugin for TinyMCE +----------------------------- + +About: + This plugin adds a print button to TinyMCE. + +Installation instructions: + * Copy the print directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins). + * Add plugin to TinyMCE plugin option list example: plugins : "print". + +Initialization example: + tinyMCE.init({ + theme : "advanced", + mode : "textareas", + plugins : "print", + theme_advanced_buttons1_add : "print", + }); diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/readme.txt b/includes/tinymce/jscripts/tiny_mce/plugins/readme.txt new file mode 100644 index 00000000..9192b26a --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/readme.txt @@ -0,0 +1 @@ +This is the location you place TinyMCE plugins. diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/save/editor_plugin.js b/includes/tinymce/jscripts/tiny_mce/plugins/save/editor_plugin.js new file mode 100644 index 00000000..1a0dee94 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/save/editor_plugin.js @@ -0,0 +1,2 @@ +/* Import plugin specific language pack */ + tinyMCE.importPluginLanguagePack('save','en,zh_cn,cs,fa,fr_ca,fr,de');function TinyMCE_save_getControlHTML(control_name){switch(control_name){case "save":return '';}return "";}function TinyMCE_save_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mceSave":var formObj=tinyMCE.selectedInstance.formElement.form;if(formObj){tinyMCE.triggerSave();for(var i=0;i'; + } + return ""; +} + +/** + * Executes the save command. + */ +function TinyMCE_save_execCommand(editor_id, element, command, user_interface, value) { + // Handle commands + switch (command) { + case "mceSave": + var formObj = tinyMCE.selectedInstance.formElement.form; + + if (formObj) { + tinyMCE.triggerSave(); + + // Disable all UI form elements that TinyMCE created + for (var i=0; ia@5x3*IY|NQy)=kLFR!2eM&8Uh0o0>H$t z_>+a1f#E-c4k#yp@&p6NF^2z~G9DWi9Bk$g)^gEUw2(tU!LDG&iNt2tW?t(JH%?4E z+QliNksz{g<6?JFULFqv4ks4&$=V?cG&V3Yc?(Kg9dk)+T6VTczM$w%<{}nGZhOum zfy6}Ri$bbQAq5EqnwL3+r9?Cw9A34shDtZRxUg{1Q7&PH2HhQuN$ng3592&eD>NS5 zmZHpHk?_ccjg3d-MymBR=N4wEfCU#E92gr9vY1cNRZwv05LA&9xY2W90XvV7LPyz# U1jnY!9Beu';case "replace":return '';}return "";}function TinyMCE_searchreplace_execCommand(editor_id,element,command,user_interface,value){function defValue(key,default_value){value[key]=typeof(value[key])=="undefined"?default_value:value[key];}function replaceSel(search_str,str){if(!tinyMCE.isMSIE){var sel=instance.contentWindow.getSelection();var rng=sel.getRangeAt(0);}else{var rng=instance.contentWindow.document.selection.createRange();}if(!tinyMCE.isMSIE){var doc=instance.contentWindow.document;if(str.indexOf(search_str)==-1){rng.deleteContents();rng.insertNode(rng.createContextualFragment(str));rng.collapse(false);}else{doc.execCommand("insertimage",false,"#mce_temp_url#");var elm=tinyMCE.getElementByAttributeValue(doc.body,"img","src","#mce_temp_url#");elm.parentNode.replaceChild(doc.createTextNode(str),elm);}}else{if(rng.item)rng.item(0).outerHTML=str;else rng.pasteHTML(str);}}var instance=tinyMCE.getInstanceById(editor_id);if(!value)value=new Array();defValue("editor_id",editor_id);defValue("searchstring","");defValue("replacestring",null);defValue("replacemode","none");defValue("casesensitive",false);defValue("backwards",false);defValue("wrap",false);defValue("wholeword",false);switch(command){case "mceResetSearch":tinyMCE.lastSearchRng=null;return true;case "mceSearch":if(user_interface){var template=new Array();if(value['replacestring']!=null){template['file']='../../plugins/searchreplace/replace.htm';template['width']=310;template['height']=180;}else{template['file']='../../plugins/searchreplace/search.htm';template['width']=280;template['height']=180;}tinyMCE.openWindow(template,value);}else{var win=tinyMCE.getInstanceById(editor_id).contentWindow;var doc=tinyMCE.getInstanceById(editor_id).contentWindow.document;if(value['replacemode']=="current"){replaceSel(value['string'],value['replacestring']);value['replacemode']="none";tinyMCE.execInstanceCommand(editor_id,'mceSearch',user_interface,value,false);return true;}if(tinyMCE.isMSIE){var rng=tinyMCE.lastSearchRng?tinyMCE.lastSearchRng:doc.selection.createRange();var flags=0;if(value['wholeword'])flags=flags|2;if(value['casesensitive'])flags=flags|4;if(value['replacemode']=="all"){while(rng.findText(value['string'],value['backwards']?-1:1,flags)){rng.scrollIntoView();rng.select();rng.collapse(false);replaceSel(value['string'],value['replacestring']);}alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));return true;}if(rng.findText(value['string'],value['backwards']?-1:1,flags)){rng.scrollIntoView();rng.select();rng.collapse(value['backwards']);tinyMCE.lastSearchRng=rng;}else alert(tinyMCE.getLang('lang_searchreplace_notfound'));}else{if(value['replacemode']=="all"){while(win.find(value['string'],value['casesensitive'],value['backwards'],value['wrap'],value['wholeword'],false,false))replaceSel(value['string'],value['replacestring']);alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));return true;}if(!win.find(value['string'],value['casesensitive'],value['backwards'],value['wrap'],value['wholeword'],false,false))alert(tinyMCE.getLang('lang_searchreplace_notfound'));}}return true;case "mceSearchReplace":value['replacestring']="";tinyMCE.execInstanceCommand(editor_id,'mceSearch',user_interface,value,false);return true;}return false;}function TinyMCE_searchreplace_handleNodeChange(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){return true;} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/editor_plugin_src.js b/includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/editor_plugin_src.js new file mode 100644 index 00000000..41e71e06 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/editor_plugin_src.js @@ -0,0 +1,166 @@ +/* Import theme specific language pack */ +tinyMCE.importPluginLanguagePack('searchreplace', 'en,sv,zh_cn,fa,fr_ca,fr,de'); + +function TinyMCE_searchreplace_getControlHTML(control_name) { + switch (control_name) { + case "search": + return ''; + + case "replace": + return ''; + } + + return ""; +} + +/** + * Executes the search/replace commands. + */ +function TinyMCE_searchreplace_execCommand(editor_id, element, command, user_interface, value) { + function defValue(key, default_value) { + value[key] = typeof(value[key]) == "undefined" ? default_value : value[key]; + } + + function replaceSel(search_str, str) { + // Get current selection + if (!tinyMCE.isMSIE) { + var sel = instance.contentWindow.getSelection(); + var rng = sel.getRangeAt(0); + } else { + var rng = instance.contentWindow.document.selection.createRange(); + } + + // Replace current one + if (!tinyMCE.isMSIE) { + var doc = instance.contentWindow.document; + + // This way works when the replace doesn't contain the search string + if (str.indexOf(search_str) == -1) { + rng.deleteContents(); + rng.insertNode(rng.createContextualFragment(str)); + rng.collapse(false); + } else { + // Insert content ugly way! Needed to move selection to after replace item + doc.execCommand("insertimage", false, "#mce_temp_url#"); + var elm = tinyMCE.getElementByAttributeValue(doc.body, "img", "src", "#mce_temp_url#"); + elm.parentNode.replaceChild(doc.createTextNode(str), elm); + } + } else { + if (rng.item) + rng.item(0).outerHTML = str; + else + rng.pasteHTML(str); + } + } + + var instance = tinyMCE.getInstanceById(editor_id); + + if (!value) + value = new Array(); + + // Setup defualt values + defValue("editor_id", editor_id); + defValue("searchstring", ""); + defValue("replacestring", null); + defValue("replacemode", "none"); + defValue("casesensitive", false); + defValue("backwards", false); + defValue("wrap", false); + defValue("wholeword", false); + + // Handle commands + switch (command) { + case "mceResetSearch": + tinyMCE.lastSearchRng = null; + return true; + + case "mceSearch": + if (user_interface) { + // Open search dialog + var template = new Array(); + + if (value['replacestring'] != null) { + template['file'] = '../../plugins/searchreplace/replace.htm'; // Relative to theme + template['width'] = 310; + template['height'] = 180; + } else { + template['file'] = '../../plugins/searchreplace/search.htm'; // Relative to theme + template['width'] = 280; + template['height'] = 180; + } + + tinyMCE.openWindow(template, value); + } else { + var win = tinyMCE.getInstanceById(editor_id).contentWindow; + var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document; + + // Handle replace current + if (value['replacemode'] == "current") { + replaceSel(value['string'], value['replacestring']); + + // Search next one + value['replacemode'] = "none"; + tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); + + return true; + } + + if (tinyMCE.isMSIE) { + var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange(); + var flags = 0; + + if (value['wholeword']) + flags = flags | 2; + + if (value['casesensitive']) + flags = flags | 4; + + // Handle replace all mode + if (value['replacemode'] == "all") { + while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { + rng.scrollIntoView(); + rng.select(); + rng.collapse(false); + replaceSel(value['string'], value['replacestring']); + } + + alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); + return true; + } + + if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) { + rng.scrollIntoView(); + rng.select(); + rng.collapse(value['backwards']); + tinyMCE.lastSearchRng = rng; + } else + alert(tinyMCE.getLang('lang_searchreplace_notfound')); + } else { + if (value['replacemode'] == "all") { + while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) + replaceSel(value['string'], value['replacestring']); + + alert(tinyMCE.getLang('lang_searchreplace_allreplaced')); + return true; + } + + if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) + alert(tinyMCE.getLang('lang_searchreplace_notfound')); + } + } + return true; + + case "mceSearchReplace": + value['replacestring'] = ""; + + tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false); + return true; + } + + // Pass to next handler in chain + return false; +} + +function TinyMCE_searchreplace_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { + return true; +} diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/images/replace.gif b/includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/images/replace.gif new file mode 100644 index 0000000000000000000000000000000000000000..e62354b0f0154c8cfb0184723ac94fb9a5ddaa94 GIT binary patch literal 152 zcmZ?wbhEHb6k!ly*vtR||Ns9t$as)2;lqRtA8y~cxNO-nUteFKAXpNeQ2fcl$iTqC zpaYTsnZdx~Dsa+s^1|T`(K*NFyQ`Q}q=cAwmE;K7Cy4-Oo^b^u6T0HO~EZhW|K4q>gB z6CWOM3yHCvk_b#x + + + +{$lang_searchreplace_replace_title} + + + + +
+ + + + + + + + + + + + + + + +
{$lang_searchreplace_findwhat}: 
{$lang_searchreplace_replacewith}: 
+ + + + + + + +
{$lang_searchreplace_direction}: {$lang_searchreplace_up}{$lang_searchreplace_down}
+ + + + +
{$lang_searchreplace_case}
+ + + + + + + +
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/search.htm b/includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/search.htm new file mode 100644 index 00000000..ba6f19c2 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/searchreplace/search.htm @@ -0,0 +1,76 @@ + + + + +{$lang_searchreplace_search_title} + + + + +
+ + + + + + + + + + +
{$lang_searchreplace_findwhat}: 
+ + + + + + + +
{$lang_searchreplace_direction}: {$lang_searchreplace_up}{$lang_searchreplace_down}
+ + + + +
{$lang_searchreplace_case}
+ + + + + +
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/cell.htm b/includes/tinymce/jscripts/tiny_mce/plugins/table/cell.htm new file mode 100644 index 00000000..1a1ab8ad --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/table/cell.htm @@ -0,0 +1,120 @@ + + + + +{$lang_table_cell_title} + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
{$lang_table_cell_title}
{$lang_insert_table_align}:{$lang_insert_table_class}:
{$lang_insert_table_valign}:  
{$lang_insert_table_width}:{$lang_insert_table_height}:
  
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/editor_plugin.js b/includes/tinymce/jscripts/tiny_mce/plugins/table/editor_plugin.js new file mode 100644 index 00000000..68c0b3db --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/table/editor_plugin.js @@ -0,0 +1,2 @@ +/* Import plugin specific language pack */ + tinyMCE.importPluginLanguagePack('table','en,ar,cs,da,de,el,es,fi,fr_ca,hu,it,ja,ko,nl,no,pl,pt,sv,tw,zh_cn,fr,de');function TinyMCE_table_getControlHTML(control_name){var controls=new Array(['table','table.gif','{$lang_table_desc}','mceInsertTable',true],['delete_col','table_delete_col.gif','{$lang_table_delete_col_desc}','mceTableDeleteCol'],['delete_row','table_delete_row.gif','{$lang_table_delete_row_desc}','mceTableDeleteRow'],['col_after','table_insert_col_after.gif','{$lang_table_insert_col_after_desc}','mceTableInsertColAfter'],['col_before','table_insert_col_before.gif','{$lang_table_insert_col_before_desc}','mceTableInsertColBefore'],['row_after','table_insert_row_after.gif','{$lang_table_insert_row_after_desc}','mceTableInsertRowAfter'],['row_before','table_insert_row_before.gif','{$lang_table_insert_row_before_desc}','mceTableInsertRowBefore'],['row_props','table_row_props.gif','{$lang_table_row_desc}','mceTableRowProps',true],['cell_props','table_cell_props.gif','{$lang_table_cell_desc}','mceTableCellProps',true]);for(var i=0;i';else if(but[0]==control_name)return '';}if(control_name=="tablecontrols"){var html="";html+=tinyMCE.getControlHTML("table");html+=tinyMCE.getControlHTML("separator");html+=tinyMCE.getControlHTML("row_props");html+=tinyMCE.getControlHTML("cell_props");html+=tinyMCE.getControlHTML("separator");html+=tinyMCE.getControlHTML("row_before");html+=tinyMCE.getControlHTML("row_after");html+=tinyMCE.getControlHTML("delete_row");html+=tinyMCE.getControlHTML("separator");html+=tinyMCE.getControlHTML("col_before");html+=tinyMCE.getControlHTML("col_after");html+=tinyMCE.getControlHTML("delete_col");return html;}return "";}function TinyMCE_table_execCommand(editor_id,element,command,user_interface,value){function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";}var inst=tinyMCE.getInstanceById(editor_id);var focusElm=inst.getFocusElement();var tdElm=tinyMCE.getParentElement(focusElm,"td");var trElm=tinyMCE.getParentElement(focusElm,"tr");switch(command){case "mceTableRowProps":if(trElm==null)return true;if(user_interface){var template=new Array();template['file']='../../plugins/table/row.htm';template['width']=340;template['height']=220;tinyMCE.openWindow(template,{editor_id:inst.editorId,align:getAttrib(trElm,'align'),valign:getAttrib(trElm,'valign'),height:getAttrib(trElm,'height'),className:getAttrib(trElm,'className')});}else{trElm.setAttribute('align',value['align']);trElm.setAttribute('vAlign',value['valign']);trElm.setAttribute('height',value['height']);trElm.setAttribute('class',value['className']);trElm.setAttribute('className',value['className']);}return true;case "mceTableCellProps":if(tdElm==null)return true;if(user_interface){var template=new Array();template['file']='../../plugins/table/cell.htm';template['width']=340;template['height']=220;tinyMCE.openWindow(template,{editor_id:inst.editorId,align:getAttrib(tdElm,'align'),valign:getAttrib(tdElm,'valign'),width:getAttrib(tdElm,'width'),height:getAttrib(tdElm,'height'),className:getAttrib(tdElm,'className')});}else{tdElm.setAttribute('align',value['align']);tdElm.setAttribute('vAlign',value['valign']);tdElm.setAttribute('width',value['width']);tdElm.setAttribute('height',value['height']);tdElm.setAttribute('class',value['className']);tdElm.setAttribute('className',value['className']);}return true;case "mceInsertTable":if(user_interface){var cols=2,rows=2,border=0,cellpadding="",cellspacing="",align="",width="",height="",action="insert",className="";tinyMCE.tableElement=tinyMCE.getParentElement(inst.getFocusElement(),"table");if(tinyMCE.tableElement){var rowsAr=tinyMCE.tableElement.rows;var cols=0;for(var i=0;icols)cols=rowsAr[i].cells.length;cols=cols;rows=rowsAr.length;border=tinyMCE.getAttrib(tinyMCE.tableElement,'border',border);cellpadding=tinyMCE.getAttrib(tinyMCE.tableElement,'cellpadding',"");cellspacing=tinyMCE.getAttrib(tinyMCE.tableElement,'cellspacing',"");width=tinyMCE.getAttrib(tinyMCE.tableElement,'width',width);height=tinyMCE.getAttrib(tinyMCE.tableElement,'height',height);align=tinyMCE.getAttrib(tinyMCE.tableElement,'align',align);className=tinyMCE.getAttrib(tinyMCE.tableElement,tinyMCE.isMSIE?'className':"class","");if(tinyMCE.isMSIE){width=tinyMCE.tableElement.style.pixelWidth==0?tinyMCE.tableElement.getAttribute("width"):tinyMCE.tableElement.style.pixelWidth;height=tinyMCE.tableElement.style.pixelHeight==0?tinyMCE.tableElement.getAttribute("height"):tinyMCE.tableElement.style.pixelHeight;}action="update";}var template=new Array();template['file']='../../plugins/table/table.htm';template['width']=340;template['height']=220;template['width']+=tinyMCE.getLang('lang_insert_table_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_table_delta_height',0);tinyMCE.openWindow(template,{editor_id:inst.editorId,cols:cols,rows:rows,border:border,cellpadding:cellpadding,cellspacing:cellspacing,align:align,width:width,height:height,action:action,className:className});}else{var html='';var cols=2,rows=2,border=0,cellpadding=-1,cellspacing=-1,align,width,height,className;if(typeof(value)=='object'){cols=value['cols'];rows=value['rows'];border=value['border']!=""?value['border']:0;cellpadding=value['cellpadding']!=""?value['cellpadding']:-1;cellspacing=value['cellspacing']!=""?value['cellspacing']:-1;align=value['align'];width=value['width'];height=value['height'];className=value['className'];}if(tinyMCE.tableElement){tinyMCE.setAttrib(tinyMCE.tableElement,'cellPadding',cellpadding);tinyMCE.setAttrib(tinyMCE.tableElement,'cellSpacing',cellspacing);tinyMCE.setAttrib(tinyMCE.tableElement,'border',border);tinyMCE.setAttrib(tinyMCE.tableElement,'width',width);tinyMCE.setAttrib(tinyMCE.tableElement,'height',height);tinyMCE.setAttrib(tinyMCE.tableElement,'align',align,true);tinyMCE.setAttrib(tinyMCE.tableElement,tinyMCE.isMSIE?'className':"class",className,true);if(tinyMCE.isMSIE){tinyMCE.tableElement.style.pixelWidth=(width==null||width=="")?0:width;tinyMCE.tableElement.style.pixelHeight=(height==null||height=="")?0:height;}tinyMCE.handleVisualAid(tinyMCE.tableElement,false,inst.visualAid);tinyMCE.tableElement.outerHTML=tinyMCE.tableElement.outerHTML;tinyMCE.triggerNodeChange();return true;}html+='";for(var x=0;x';else html+='";}html+="";}html+="
';html+=" 
";inst.execCommand('mceInsertContent',false,html);}return true;case "mceTableInsertRowBefore":case "mceTableInsertRowAfter":case "mceTableDeleteRow":case "mceTableInsertColBefore":case "mceTableInsertColAfter":case "mceTableDeleteCol":var trElement=tinyMCE.getParentElement(inst.getFocusElement(),"tr");var tdElement=tinyMCE.getParentElement(inst.getFocusElement(),"td");var tableElement=tinyMCE.getParentElement(inst.getFocusElement(),"table");if(!tableElement)return true;var doc=inst.contentWindow.document;var tableBorder=tableElement.getAttribute("border");var visualAidStyle=inst.visualAid?tinyMCE.settings['visual_table_style']:"";if(tableElement.firstChild&&tableElement.firstChild.nodeName.toLowerCase()=="tbody")tableElement=tableElement.firstChild;if(tableElement&&trElement){switch(command){case "mceTableInsertRowBefore":var numcells=trElement.cells.length;var rowCount=0;var tmpTR=trElement;while(tmpTR){if(tmpTR.nodeName.toLowerCase()=="tr")rowCount++;tmpTR=tmpTR.previousSibling;}var r=tableElement.insertRow(rowCount==0?1:rowCount-1);for(var i=0;inumCols)numCols=tableElement.rows[y].cells.length;}if(numCols<=1){if(tinyMCE.isGecko)inst.selectNode(selElm);tableElement.parentNode.removeChild(tableElement);tinyMCE.triggerNodeChange();return true;}for(var y=0;y0)selElm=tableElement.rows[0].cells[index-1];if(tinyMCE.isGecko)inst.selectNode(selElm);break;}tinyMCE.triggerNodeChange();}return true;}return false;}function TinyMCE_table_handleNodeChange(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){tinyMCE.switchClassSticky(editor_id+'_table','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_row_props','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_cell_props','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_row_before','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_row_after','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_delete_row','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_col_before','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_col_after','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_delete_col','mceButtonDisabled',true);if(tinyMCE.getParentElement(node,"tr"))tinyMCE.switchClassSticky(editor_id+'_row_props','mceButtonSelected',false);if(tinyMCE.getParentElement(node,"td")){tinyMCE.switchClassSticky(editor_id+'_cell_props','mceButtonSelected',false);tinyMCE.switchClassSticky(editor_id+'_row_before','mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_row_after','mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_delete_row','mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_col_before','mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_col_after','mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_delete_col','mceButtonNormal',false);}if(tinyMCE.getParentElement(node,"table"))tinyMCE.switchClassSticky(editor_id+'_table','mceButtonSelected');} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/editor_plugin_src.js b/includes/tinymce/jscripts/tiny_mce/plugins/table/editor_plugin_src.js new file mode 100644 index 00000000..ef74e180 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/table/editor_plugin_src.js @@ -0,0 +1,472 @@ +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('table', 'en,ar,cs,da,de,el,es,fi,fr_ca,hu,it,ja,ko,nl,no,pl,pt,sv,tw,zh_cn,fr,de'); + +/** + * Returns the HTML contents of the table control. + */ +function TinyMCE_table_getControlHTML(control_name) { + var controls = new Array( + ['table', 'table.gif', '{$lang_table_desc}', 'mceInsertTable', true], + ['delete_col', 'table_delete_col.gif', '{$lang_table_delete_col_desc}', 'mceTableDeleteCol'], + ['delete_row', 'table_delete_row.gif', '{$lang_table_delete_row_desc}', 'mceTableDeleteRow'], + ['col_after', 'table_insert_col_after.gif', '{$lang_table_insert_col_after_desc}', 'mceTableInsertColAfter'], + ['col_before', 'table_insert_col_before.gif', '{$lang_table_insert_col_before_desc}', 'mceTableInsertColBefore'], + ['row_after', 'table_insert_row_after.gif', '{$lang_table_insert_row_after_desc}', 'mceTableInsertRowAfter'], + ['row_before', 'table_insert_row_before.gif', '{$lang_table_insert_row_before_desc}', 'mceTableInsertRowBefore'], + ['row_props', 'table_row_props.gif', '{$lang_table_row_desc}', 'mceTableRowProps', true], + ['cell_props', 'table_cell_props.gif', '{$lang_table_cell_desc}', 'mceTableCellProps', true]); + + // Render table control + for (var i=0; i'; + else + if (but[0] == control_name) + return ''; + } + + // Special tablecontrols + if (control_name == "tablecontrols") { + var html = ""; + + html += tinyMCE.getControlHTML("table"); + html += tinyMCE.getControlHTML("separator"); + html += tinyMCE.getControlHTML("row_props"); + html += tinyMCE.getControlHTML("cell_props"); + html += tinyMCE.getControlHTML("separator"); + html += tinyMCE.getControlHTML("row_before"); + html += tinyMCE.getControlHTML("row_after"); + html += tinyMCE.getControlHTML("delete_row"); + html += tinyMCE.getControlHTML("separator"); + html += tinyMCE.getControlHTML("col_before"); + html += tinyMCE.getControlHTML("col_after"); + html += tinyMCE.getControlHTML("delete_col"); + + return html; + } + + return ""; +} + +/** + * Executes the table commands. + */ +function TinyMCE_table_execCommand(editor_id, element, command, user_interface, value) { + function getAttrib(elm, name) { + return elm.getAttribute(name) ? elm.getAttribute(name) : ""; + } + + var inst = tinyMCE.getInstanceById(editor_id); + var focusElm = inst.getFocusElement(); + var tdElm = tinyMCE.getParentElement(focusElm, "td"); + var trElm = tinyMCE.getParentElement(focusElm, "tr"); + + // Handle commands + switch (command) { + case "mceTableRowProps": + if (trElm == null) + return true; + + if (user_interface) { + // Setup template + var template = new Array(); + + template['file'] = '../../plugins/table/row.htm'; + template['width'] = 340; + template['height'] = 220; + + // Open window + tinyMCE.openWindow(template, {editor_id : inst.editorId, align : getAttrib(trElm, 'align'), valign : getAttrib(trElm, 'valign'), height : getAttrib(trElm, 'height'), className : getAttrib(trElm, 'className')}); + } else { + trElm.setAttribute('align', value['align']); + trElm.setAttribute('vAlign', value['valign']); + trElm.setAttribute('height', value['height']); + trElm.setAttribute('class', value['className']); + trElm.setAttribute('className', value['className']); + } + + return true; + + case "mceTableCellProps": + if (tdElm == null) + return true; + + if (user_interface) { + // Setup template + var template = new Array(); + + template['file'] = '../../plugins/table/cell.htm'; + template['width'] = 340; + template['height'] = 220; + + // Open window + tinyMCE.openWindow(template, {editor_id : inst.editorId, align : getAttrib(tdElm, 'align'), valign : getAttrib(tdElm, 'valign'), width : getAttrib(tdElm, 'width'), height : getAttrib(tdElm, 'height'), className : getAttrib(tdElm, 'className')}); + } else { + tdElm.setAttribute('align', value['align']); + tdElm.setAttribute('vAlign', value['valign']); + tdElm.setAttribute('width', value['width']); + tdElm.setAttribute('height', value['height']); + tdElm.setAttribute('class', value['className']); + tdElm.setAttribute('className', value['className']); + } + + return true; + + case "mceInsertTable": + if (user_interface) { + var cols = 2, rows = 2, border = 0, cellpadding = "", cellspacing = "", align = "", width = "", height = "", action = "insert", className = ""; + + tinyMCE.tableElement = tinyMCE.getParentElement(inst.getFocusElement(), "table"); + + if (tinyMCE.tableElement) { + var rowsAr = tinyMCE.tableElement.rows; + var cols = 0; + for (var i=0; i cols) + cols = rowsAr[i].cells.length; + + cols = cols; + rows = rowsAr.length; + + border = tinyMCE.getAttrib(tinyMCE.tableElement, 'border', border); + cellpadding = tinyMCE.getAttrib(tinyMCE.tableElement, 'cellpadding', ""); + cellspacing = tinyMCE.getAttrib(tinyMCE.tableElement, 'cellspacing', ""); + width = tinyMCE.getAttrib(tinyMCE.tableElement, 'width', width); + height = tinyMCE.getAttrib(tinyMCE.tableElement, 'height', height); + align = tinyMCE.getAttrib(tinyMCE.tableElement, 'align', align); + className = tinyMCE.getAttrib(tinyMCE.tableElement, tinyMCE.isMSIE ? 'className' : "class", ""); + + if (tinyMCE.isMSIE) { + width = tinyMCE.tableElement.style.pixelWidth == 0 ? tinyMCE.tableElement.getAttribute("width") : tinyMCE.tableElement.style.pixelWidth; + height = tinyMCE.tableElement.style.pixelHeight == 0 ? tinyMCE.tableElement.getAttribute("height") : tinyMCE.tableElement.style.pixelHeight; + } + + action = "update"; + } + + // Setup template + var template = new Array(); + + template['file'] = '../../plugins/table/table.htm'; + template['width'] = 340; + template['height'] = 220; + + // Language specific width and height addons + template['width'] += tinyMCE.getLang('lang_insert_table_delta_width', 0); + template['height'] += tinyMCE.getLang('lang_insert_table_delta_height', 0); + + // Open window + tinyMCE.openWindow(template, {editor_id : inst.editorId, cols : cols, rows : rows, border : border, cellpadding : cellpadding, cellspacing : cellspacing, align : align, width : width, height : height, action : action, className : className}); + } else { + var html = ''; + var cols = 2, rows = 2, border = 0, cellpadding = -1, cellspacing = -1, align, width, height, className; + + if (typeof(value) == 'object') { + cols = value['cols']; + rows = value['rows']; + border = value['border'] != "" ? value['border'] : 0; + cellpadding = value['cellpadding'] != "" ? value['cellpadding'] : -1; + cellspacing = value['cellspacing'] != "" ? value['cellspacing'] : -1; + align = value['align']; + width = value['width']; + height = value['height']; + className = value['className']; + } + + // Update table + if (tinyMCE.tableElement) { + tinyMCE.setAttrib(tinyMCE.tableElement, 'cellPadding', cellpadding); + tinyMCE.setAttrib(tinyMCE.tableElement, 'cellSpacing', cellspacing); + tinyMCE.setAttrib(tinyMCE.tableElement, 'border', border); + tinyMCE.setAttrib(tinyMCE.tableElement, 'width', width); + tinyMCE.setAttrib(tinyMCE.tableElement, 'height', height); + tinyMCE.setAttrib(tinyMCE.tableElement, 'align', align, true); + tinyMCE.setAttrib(tinyMCE.tableElement, tinyMCE.isMSIE ? 'className' : "class", className, true); + + if (tinyMCE.isMSIE) { + tinyMCE.tableElement.style.pixelWidth = (width == null || width == "") ? 0 : width; + tinyMCE.tableElement.style.pixelHeight = (height == null || height == "") ? 0 : height; + } + + tinyMCE.handleVisualAid(tinyMCE.tableElement, false, inst.visualAid); + + // Fix for stange MSIE align bug + tinyMCE.tableElement.outerHTML = tinyMCE.tableElement.outerHTML; + + //inst.contentWindow.dispatchEvent(createEvent("click")); + + tinyMCE.triggerNodeChange(); + return true; + } + + // Create new table + html += ''; + else + html += '"; + } + html += ""; + } + + html += "
'; + + html += " 
"; + + inst.execCommand('mceInsertContent', false, html); + } + + return true; + + case "mceTableInsertRowBefore": + case "mceTableInsertRowAfter": + case "mceTableDeleteRow": + case "mceTableInsertColBefore": + case "mceTableInsertColAfter": + case "mceTableDeleteCol": + var trElement = tinyMCE.getParentElement(inst.getFocusElement(), "tr"); + var tdElement = tinyMCE.getParentElement(inst.getFocusElement(), "td"); + var tableElement = tinyMCE.getParentElement(inst.getFocusElement(), "table"); + + // No table just return (invalid command) + if (!tableElement) + return true; + + var doc = inst.contentWindow.document; + var tableBorder = tableElement.getAttribute("border"); + var visualAidStyle = inst.visualAid ? tinyMCE.settings['visual_table_style'] : ""; + + // Table has a tbody use that reference + if (tableElement.firstChild && tableElement.firstChild.nodeName.toLowerCase() == "tbody") + tableElement = tableElement.firstChild; + + if (tableElement && trElement) { + switch (command) { + case "mceTableInsertRowBefore": + var numcells = trElement.cells.length; + var rowCount = 0; + var tmpTR = trElement; + + // Count rows + while (tmpTR) { + if (tmpTR.nodeName.toLowerCase() == "tr") + rowCount++; + + tmpTR = tmpTR.previousSibling; + } + + var r = tableElement.insertRow(rowCount == 0 ? 1 : rowCount-1); + for (var i=0; i numCols) + numCols = tableElement.rows[y].cells.length; + } + + // Remove whole table + if (numCols <= 1) { + if (tinyMCE.isGecko) + inst.selectNode(selElm); + + tableElement.parentNode.removeChild(tableElement); + tinyMCE.triggerNodeChange(); + return true; + } + + // Remove columns + for (var y=0; y 0) + selElm = tableElement.rows[0].cells[index-1]; + + if (tinyMCE.isGecko) + inst.selectNode(selElm); + break; + } + + tinyMCE.triggerNodeChange(); + } + + return true; + } + + // Pass to next handler in chain + return false; +} + +function TinyMCE_table_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { + // Reset table controls + tinyMCE.switchClassSticky(editor_id + '_table', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_row_props', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_cell_props', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_row_before', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_row_after', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_delete_row', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_col_before', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_col_after', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_delete_col', 'mceButtonDisabled', true); + + // Within a tr element + if (tinyMCE.getParentElement(node, "tr")) + tinyMCE.switchClassSticky(editor_id + '_row_props', 'mceButtonSelected', false); + + // Within a td element + if (tinyMCE.getParentElement(node, "td")) { + tinyMCE.switchClassSticky(editor_id + '_cell_props', 'mceButtonSelected', false); + tinyMCE.switchClassSticky(editor_id + '_row_before', 'mceButtonNormal', false); + tinyMCE.switchClassSticky(editor_id + '_row_after', 'mceButtonNormal', false); + tinyMCE.switchClassSticky(editor_id + '_delete_row', 'mceButtonNormal', false); + tinyMCE.switchClassSticky(editor_id + '_col_before', 'mceButtonNormal', false); + tinyMCE.switchClassSticky(editor_id + '_col_after', 'mceButtonNormal', false); + tinyMCE.switchClassSticky(editor_id + '_delete_col', 'mceButtonNormal', false); + } + + // Within table + if (tinyMCE.getParentElement(node, "table")) + tinyMCE.switchClassSticky(editor_id + '_table', 'mceButtonSelected'); +} diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/images/buttons.gif b/includes/tinymce/jscripts/tiny_mce/plugins/table/images/buttons.gif new file mode 100644 index 0000000000000000000000000000000000000000..7a7d93bcaa8c5b560c09e701dd6fd1a43de68d1d GIT binary patch literal 1367 zcmaKpYf}>k6oxk>n3x6#F|{a&hFcL8(nbYDAR!SWRc2AEh!lc4Hdw4%rAkFQOA;Vl z3M+y}=;(@|Q7kTnYE;ApMKT)eqEijlaTY-Y<+4ST1ki2l59s^hd^+zlXP&cqO>9_r zS~DO7`hkz39kI~}f}$vfVK|Nx1VNG{MNu?ir4b{A6Eu{Cz2DqB!oJ;6mF$aoWckiF;QZrN}33PYFL$pU<8F2ag_sMA|M#StrU!)2 z3F{HWfMO;bHxq=_aXU@fXw-y*i6E?pr=}+Db{l3?5x9yZAPfa562VOfjzOdu!VDme z!JRiRKkDkh5U{_Gv_9x0%s4eb{xdpEjSP(rzn-+)?6!$_Z^z$`zp`uG!oO~aWQtu8OW zKwnr?T=Gk48FIM%NJZt*V}|2Z26aZp&g!c0IbMO1ywi1OOWmXS{3yRuO-)-ezTK74 zd@MXTXkoqf`i-_Sr83gs<`x+f9)8V`yxBcHW4BJBS@zhnJ^`JeRM(AGusH_RKfh!~Ira;0y-aOQwLIF7Q7Q z*j2QoHBeddxetFekYs7ADdt_m+nlr4agq)MH6t;!tMvUi2P}}L^8_mr#Aw0Z7rh)7 z=f^?+m}m>LEoZj>c&w99mu@z+I=jPOaR9WlDtj1jpE-NzuTtKcZMcjJr*!xDXu0dv zK39hyDdQvF_HkTOW4UcB!;tPeuDVKmPE$z#lphzw-Ls)s$$OrBLo}umLB1qMovK$)oRl&oNM zL_v>pGsp4dsvwhU>0X4Xh+Wac9CC=o!gvw&;JEQG@DJ$6$B*y9ySxux{Y-6ku9*Wl z&;cV^mgTqzF2D-Ju^=LJ*5Me*7UC50Cy+D9dr10NaI7en0;v!yiHT1LWt4Ho80`td zH0fy?J20##7#A#vDOn&n7d(iA=0Y-IcxbrPf)f!?@szE;c^>s&MB!_#s1QkQn7rM&uZWEuIkdp$R4&n$wy)0vxLV{8?)r-!}Ci)!@%sw>s|waN)*>2QU6N zEcoCMP_W>@|A2&s1si~>{x_`nFk#1k1CN9a7d}i_abN*Z@r@4?7Hn9s;lPFi7Y92d!QX$4k!Dftb{ s+*UF&ajfNL-yko!+*y)Snu9~?=u$Dsy_-eOoIQ8e_u{3?u8s`W0Qez_!2kdN literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_delete_col.gif b/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_delete_col.gif new file mode 100644 index 0000000000000000000000000000000000000000..0b2f0fb61293b95d119f620c15e12cd3a3e3bb0e GIT binary patch literal 929 zcmZ?wbhEHb6k!lyXlDQc1CIoUhysI*2L=TX0x}vB3MM!dJSb?G5YX@-VFD0+C|K~J zp<_Zr$ASqH7EGA2V8Vh83l?l>Sn!}>!G{SeK1|r~VZn+68+II6u;asm10Ob=_wF-@g9v?#;*dZ@+%|{O#+PpFh6;{Q2Y8&mX^k|N8U$_y7O@!A=+@ zMnhm=LO}5+3o`?QHiHhxdQhHV;HYB==aBK(u;5@bhp<-6i46*DqFMnSA1*XHGjymj z$?Op*WNGP=)SJbz@M1!Xh>C;FgAEIv8ibYXrszl~ z&MaaYDh9g*7@JwyXK1-BXgI*Il2h;pPeZ6;LmS)vCRL5HH(U%EXSsA%Z__>8z+epk DI%10H literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_delete_row.gif b/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_delete_row.gif new file mode 100644 index 0000000000000000000000000000000000000000..1997065fb2b447f498ab7fda4b7e21dcbb25dc81 GIT binary patch literal 942 zcmZ?wbhEHb6k!lyXlDQc1CIoUh=PEGhJcKQgo1{IiU|b`3j#VmBuw~FFylkPf)5Q7 z7Bo!QFk!}m2{SfKSg@gC#fJ$SK1|s0VZn+63pO0su;ai2Ap5|F4JUx;|A7nt58U{F z;lck0FaAIH@c#o4{rLYMi2nZv+crv!hQJ^S0mYvz%nS@F3_2h;f${_cM>m5fhm6OD z1qYisgtcN$Ojy9mEvgi>fT8hWN4JEt$%Yw%N7~tCoGZROc*x+)p`mC~@Svg5n~l@8 z>cxRXXEq)or2`@y3m*9JNg2eP*va6?$lx(i=t)DOQwuAXkirbBgarR4#!XpwwGCZQ}j-u$i5iXM38c!-9o(cUMTVu`pNz0PJ9X!TQ3xphWMO7tP+`ykxe1gf7&uxPJUL`M zHY_;U%pokNQs8*7k%5a_=z@SE(i5MkXeC zPNt5?0yW=8hN62%Dla%PGcz-pWCS=goN5wqs`((G@bc1P7WEc}kBSW;s{+{lBo>-5 iu&xUgtrHbga%dGy+03=YpedVyC-?NbIlm1R7_0$Wk9qk3 literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_insert_col_before.gif b/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_insert_col_before.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d1ff37afea7bb2e67952400e00184aa275d6764 GIT binary patch literal 935 zcmZ?wbhEHb6k!lyXlDQc1CNA&goc2OhJ=EKgo+6T6%!mP9uzc82Q3xphWMO7tP+`ykxe1gf7&uxOJUL`M zHY_;U%)u+PW5EN5h88YU7mp7DN{(zYMmj4p0u!3~q*V&u{5arzY@(RFO-4h5!|^7D zIH?}ZVugm;rn%2dUMy&AWMq^w(NJJWb>vXAtKet|SsBK;hMu<;?0m9#Rd5 h!d40F?cxwzaHwNr1Z$MUMpFj1Z7JoaTqOh;tN|1Me9r&? literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_insert_row_after.gif b/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_insert_row_after.gif new file mode 100644 index 0000000000000000000000000000000000000000..c3aa15f93a9d50777ca3a3b2309fc807ceabc57a GIT binary patch literal 928 zcmZ?wbhEHb6k!lyXlDQc1CNA&goc2OhJ=EKgo+6T6%!mP9uzc82Q3xphWMO7tP+`ykxe1gf7&vMfJUL`M zHY_;U%)uMAz#x%{g`JbTZ-#`DOLGT{dj|*Oqh`h)X6?Ek4-y$X8X1FD*?2NJv$hH7 z&6{JfXpzqZDa$&I13@aDj5?v~Qf7WQ*v!VmA#i}h;Q=$htVPBS0l|h)240Jt69SHm a!Hpb79uX5BFnBXLF$=_=o|fvsU=08}a&%e% literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_insert_row_before.gif b/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_insert_row_before.gif new file mode 100644 index 0000000000000000000000000000000000000000..c3271e54937cb8dbfb435ee8bc2d02157cff1448 GIT binary patch literal 928 zcmZ?wbhEHb6k!lyXlDQc1CNA&goc2OhJ=EKgo+6T6%!mP9uzc82Q3xphWMO7tP+`ykxe1gf7&vMfJUL`M zHY_;U%pt55lkwqTGaC=w17?0%i;Nu$1RC5Kcr9{H2skpjHgXtwL`-~0*X=}WE7QHI{4WtnErk^c$i_Har&nt0T0z!7V6jbF?3B; b3|uVFrNMjfN;AWXK;{oIr@tjQFjxZsoSk_C literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_row_props.gif b/includes/tinymce/jscripts/tiny_mce/plugins/table/images/table_row_props.gif new file mode 100644 index 0000000000000000000000000000000000000000..a53cdd8bf6b04c1090d9c545963647ad4b6e37d3 GIT binary patch literal 367 zcmZ?wbhEHb6k!lyxXJ(m|AFAg{{sguT)6Py!-xM9R(x2n;=qO-7Y>|waN)*>2QU6N zEcoCMP_W>@|A2&s1si~>{x_`nFk#1k1CN9a7d}i_abN*Z@r@4?7Hn9s;lPFi7Yz24J qXJq17&CR}!RdT7bB&Re7ht%Q4Vv@Tzikv!q=Ctqm3m07-8LR + + + +{$lang_table_row_title} + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
{$lang_table_row_title}
{$lang_insert_table_align}:{$lang_insert_table_class}:
{$lang_insert_table_valign}:{$lang_insert_table_height}:
    
  
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/table/table.htm b/includes/tinymce/jscripts/tiny_mce/plugins/table/table.htm new file mode 100644 index 00000000..c78fca8e --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/table/table.htm @@ -0,0 +1,137 @@ + + + + +{$lang_insert_table_title} + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{$lang_insert_table_title}
{$lang_insert_table_cols}:{$lang_insert_table_rows}:
{$lang_insert_table_cellpadding}:{$lang_insert_table_cellspacing}:
{$lang_insert_table_align}:{$lang_insert_table_border}:
{$lang_insert_table_width}:{$lang_insert_table_height}:
{$lang_insert_table_class}: +   
  
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/zoom/editor_plugin.js b/includes/tinymce/jscripts/tiny_mce/plugins/zoom/editor_plugin.js new file mode 100644 index 00000000..f4ffe03a --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/zoom/editor_plugin.js @@ -0,0 +1,7 @@ +/* Import plugin specific language pack */ + function TinyMCE_zoom_getControlHTML(control_name){if(!tinyMCE.isMSIE||tinyMCE.isMSIE5_0)return "";switch(control_name){case "zoom":return '';}return "";}function TinyMCE_zoom_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mceZoom":tinyMCE.getInstanceById(editor_id).contentDocument.body.style.zoom=value;tinyMCE.getInstanceById(editor_id).contentDocument.body.style.mozZoom=value;return true;}return false;} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/zoom/editor_plugin_src.js b/includes/tinymce/jscripts/tiny_mce/plugins/zoom/editor_plugin_src.js new file mode 100644 index 00000000..8131b602 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/zoom/editor_plugin_src.js @@ -0,0 +1,38 @@ +/* Import plugin specific language pack */ +//tinyMCE.importPluginLanguagePack('zoom', 'en,sv,pt,fr_ca,fr,de'); + +/** + * Returns the HTML contents of the zoom control. + */ +function TinyMCE_zoom_getControlHTML(control_name) { + if (!tinyMCE.isMSIE || tinyMCE.isMSIE5_0) + return ""; + + switch (control_name) { + case "zoom": + return ''; + } + + return ""; +} + +/** + * Executes the mceZoom command. + */ +function TinyMCE_zoom_execCommand(editor_id, element, command, user_interface, value) { + // Handle commands + switch (command) { + case "mceZoom": + tinyMCE.getInstanceById(editor_id).contentDocument.body.style.zoom = value; + tinyMCE.getInstanceById(editor_id).contentDocument.body.style.mozZoom = value; + return true; + } + + // Pass to next handler in chain + return false; +} diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/zoom/langs/fa.js b/includes/tinymce/jscripts/tiny_mce/plugins/zoom/langs/fa.js new file mode 100644 index 00000000..b22b8781 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/zoom/langs/fa.js @@ -0,0 +1,8 @@ +// IR lang variables +// Persian (Farsi) language pack (for IRAN) +// By: Morteza Zafari +// Lost@LostLord.com +// http://www.LostLord.com + +tinyMCELang['lang_dir'] = 'rtl'; +tinyMCELang['lang_zoom_prefix'] = 'بزرگنمایی'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/zoom/langs/fr_ca.js b/includes/tinymce/jscripts/tiny_mce/plugins/zoom/langs/fr_ca.js new file mode 100644 index 00000000..a1dc964f --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/zoom/langs/fr_ca.js @@ -0,0 +1,3 @@ +// CA_FR lang variables + +tinyMCELang['lang_zoom_prefix'] = 'Zoom'; diff --git a/includes/tinymce/jscripts/tiny_mce/plugins/zoom/readme.txt b/includes/tinymce/jscripts/tiny_mce/plugins/zoom/readme.txt new file mode 100644 index 00000000..469a292e --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/plugins/zoom/readme.txt @@ -0,0 +1,22 @@ + Zoom plugin for TinyMCE +-------------------------- + +About: + Adds a zoom drop list in MSIE5.5+, this plugin was mostly created to + show how to add custom droplists as plugins. + +Installation instructions: + * Copy the zoom directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins). + * Add plugin to TinyMCE plugin option list example: plugins : "zoom". + * Add the preview button name to button list, example: theme_advanced_buttons3_add : "zoom". + +Initialization example: + tinyMCE.init({ + theme : "advanced", + mode : "textareas", + plugins : "preview", + theme_advanced_buttons3_add : "zoom" + }); + +Requirement: + This plugin requires MSIE on Mozilla the button will not be visible. diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/anchor.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/anchor.htm new file mode 100644 index 00000000..60c73706 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/anchor.htm @@ -0,0 +1,46 @@ + + +{$lang_insert_anchor_title} + + + + +
+ + + + +
+ + + + + + + + + + + +
{$lang_insert_anchor_title}
{$lang_insert_anchor_name}:
+
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/charmap.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/charmap.htm new file mode 100644 index 00000000..8cd213c6 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/charmap.htm @@ -0,0 +1,382 @@ + + + + +{$lang_theme_charmap_title} + + + + + + + + + + + + + + + + +
{$lang_theme_charmap_title}
+ + + + + + + + + +
 
 
+
+ + + + + + + + + + + + + + + + +
HTML-Code
 
 
NUM-Code
 
+
+ + + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/color_picker.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/color_picker.htm new file mode 100644 index 00000000..55a8acdb --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/color_picker.htm @@ -0,0 +1,272 @@ + + +{$lang_theme_colorpicker_title} + + + + +
+ +
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/about.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/about.htm new file mode 100644 index 00000000..7348dd52 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/about.htm @@ -0,0 +1,32 @@ + + + +About TinyMCE + + + + + + + + + + + +
+
+TinyMCE is a small WYSIWYG editor control for web browsers such as MSIE or Mozilla +that enables you to edit HTML contents in a more user friendly way. It has common +features that are found in most word processors and should not be difficult to +use.
+
+
+ + + + + + +
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/common_buttons.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/common_buttons.htm new file mode 100644 index 00000000..ea8c6c27 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/common_buttons.htm @@ -0,0 +1,163 @@ + + + +Common buttons + + + + + + + + + + + +
+
+Below is a short description about each button. +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bold text style.
Italic text style.
Underline text style.
Strikethrough text style.
Align left.
Align center.
Align right.
Align full.
Unordered list/bullet list.
Ordered list/numbered list
Outdent/decrease indentation.
Indent/incread indentation.
Undo the last operation.
Redo the last operation.
Insert a new link, read more about this function in the Insert + link section.
Unlinks the current selection/removes all selected links.
Insert a new anchor, read more about this function in the Insert anchor section.
Insert a new image, read more about this function in the Insert + image section.
Cleanup code/Removes unwanted formating. This function is useful when + you copy contents from for example a office product.
Shows this help window.
Opens HTML source code editor.
Inserts a new 2x2 table at the current location.
Adds a row above the current one.
Adds a row under the current one.
Removes the row.
Adds a column before the current one.
Adds a column after the current one.
Removes the current column.
Inserts a new horizontal ruler
Removes formatting from the selection.
Makes the selection to be subscript.
Makes the selection to be superscripted.
+
+
+ + + + + + + + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/images/insert_anchor_window.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/images/insert_anchor_window.gif new file mode 100644 index 0000000000000000000000000000000000000000..5b5f528dd57cae8e062919a66b0ff7fcf8f3bc42 GIT binary patch literal 5189 zcmV-L6uRq2Nk%w1VM+mu0QUd@H&l@lEO0qilOsNVFindaHh4i^nHDj05GrpUI(!r_ za}OzQrpoXNBx(yKYi5SIC`5!jS(O+wc1dTTm%8JFrP7M5*m|4FS$M8BQjd0*$5mBT z=;+h``|#@O>def{hpE;xP>o@MwWZ1MmAK&!C~YJ_fOC|^AUu7Ow%}WOucF57OlzZ* zw&0}4?rx62QE;bCYowvX>r85*c$vv8NQW{`j8k!_FH4CuP>z71&z->NKwX$paj0pE zye&zHq{#21$L&sRq?EVen7rhKrqiFo>V2NfQE#UjHF%J+-E@`3GEa?lmc|`9dpK2* zrOEF^Vw{Vv*__V48cJ%W#pxN@<~n zsMJnvrBH9C0A|c`lfyqtRHdBxl zFm#Qu+mEu`CPIROqtR4yshGRuX^FcMEpd*p+f{U`Cqjd5kGv^Gg(pLU88mmC!01S3 zpJ<4>VuH3?day-fos6#9fTGZuyya?&y^pcnB|w2?g}6OhmVBMeXNS5IE^=vtn#p8@xFtb?7czBwoy$gJoo$W3h^p6Mf3qq^g%B%mTzjybzvr605p*>rcFHDMBd9Qt+&3AWqElP-Sk;0I( z-5xo6E=q}UlEZhH$d{pUziytuto-k+j}!kHAxMsSGA;4JT}sxZ;L}hHsC- zGc(Nb@$mp=nVFfH004k9Gc%x*O#}o4z`(%&%$Wc)nKNe0UteD{=KnxIK!AXN)X>NP z00960|M2kcA^8LV00000EC2ui07?Oi000R80Qm_VNU)&6g9sBUT*$DY!-o(fN}Ncs zqQ#3CGZNIt&!5MSAVZ2ANwTELlPFWFT*BcR3xlMp%jWXM1X0Dva~1XRJ|EJ6fX z)6SqV!^1$9EM216ilWLFAvnuSO_(4J%%B-8Vh9n#Mavi@FnZiDrzz5>J8v9`1BU@a zH5I9dDOzM_%CTTq_=rHIY>gaUu^v4CpmpjNCm*h!;VJa%#fx(5AbrW!t&E-%OQffv2Za)dSExbcS$tRR!gBo$Op1T)Zt(FO>~0JDV!7T_YqD$Q8p$t#yA zp$$269Fjr{Ly(ZpHxy8?2@$Or1Bf8Sl(NGfMi{|H95OUw$O=KY00a~xFreg;Og8D{ zlTbz(B|k>##MCwFWT~Z=PC+FVRaRl86<1z?B^Fs`p`{jEZowrNU3TH67hiq>CKzFc zA*L8(jzK0FWtL&48E2k>CK_p`p{5#ZuE8c7ZMNa28*jb=CmeCcA*UR3&Os*~b=G00 z9e3V=Cmwm`p{E{u?!hM?efHu1ryqa*0Vp7W1|p~+gAPI{A%zxVs3C_Qf+!-1CZeb! zi!Q<_BaJrVs3VU)0x2YsMj|QYw%m3LC6zfLwbV5vy|aN*PenCVRaa%TRaakyHC9rnq8@FUB}yjW_1FV~;-uIb@MXCdt4``k<|(+6;hu)Rq2p zAotuIywkzC4W#=eyJEioTc*5d*1IOYZtfeWzjOwCC&79i+^52THasZAhEANQ#f)bB zD94h1T&c*Imb@v-o~|6K%cRD9D$T0i+^Wv7_B<=lwho=E(Yz-8E7QV0U98l|R=q6N z&Tbv8*VKl6E!oxStrnem=UubTI^ zsV|)V$oX%b0(+FF!F(qCC&Pk1T&TpP@ra@>)+miZs$-J^nWaXSDU)$3WuIc1s9sho znW3s?tHN11J`y`w{j63(!&T9Cg*0C+Em%$?R@9C~HDz6`Sz3cu*QNzFYmF^iW{ciJ zpeK-h`0$56?4kAloF}~@VozL3fk*ec*MV`gqXQp!$2HF70FZ#GU1NfmndX%yd$GkM zg@d2`5@)AG*v}(4@JRmrw6H)qj8G9f6b}T5IgB}KW0CS0r9vhgk2KH`9>IV|N(ZWz zjS6O_npvuB#;O;1L_QvgmCry@I}v(>guPN4u$ne3s2OW&O7Mu)m=zKkO6zOY5*xP4 zM!h0N4~VeT$@GZGkAC!nAhs0Z^{Rx#2EZc}eqaYX@?5R8Ss^Ewx

E zb&Y)F7a}SDyZv}1XtyHTC6AWL-J!6Pzhhx2{V~cGc_fBhJ7w~0xXR|~P$4{|(n$6p z%OPGgm$kg5F5AY-q@V*H@~DURIxx&)dcXr5_<%A!GL?{w2_#_w$yq#N1%EgJByX~2 zzd%x_ko*9RAbDILKysOo6bdAB1j)rfA{&o@!5`~XpvXXS2apKTAJ75G6g+YTe{2UN zG6M;EK;oW{?DHcY)WAP!5E27{gh3#YkVnGc4-kZ;SRg48NM88RXL;mC9zmt@Zpcbn zVl-_%yl7;>)yjd`5~L$NqEfC=k8vz5_se)9_fTf{^k*~cq9oR`Kdp` z=#M!6d1Nmhfq+K@b4Gup(I0Ds93?#R1dnXSBN6b39O>whD0t*G9+?10vii9`Y62vH z^v73K;1Sb-LW>Y1 zL<$}ekw+HVP!g2#u!2bJL{-VW99Hj@lGP|>9V-ybX11ga*oQps;aRyo(F5(^08C{% zKAM`=AE@<*YCi%Nk-*j;)12-5YI_%v=++;+^~X_t>rJJGq`3Y#u0N9NkL8-P3(b8l z9HMJg1PTEp?JSN*k`u^5b{AA+)lPWjFkXNURN#Iy2OgmeagB=w)!!a&@u{UVn(!AL3Cfn8m!_x4PG#{`gOPy)fVU-q(bC zy-=Jj@ZSJ~Qj~Wt?AG?ISc*0n&t1@_1+F5g$z3AL?cAwdI;^x}KTaY4)~1bmwL`_m|vrHaD`+P1rme)*p!V z#|}JV1dqtTBNcUUg%6Era0!~;9j&Z|L8@;IH-H@tn8!Ta!S;cRmc+~S$camIYLE%^IryI@q2=d9nY9?67`htS}!HTFLv7 znz1$K^MUImKjL#VALt`^1xeAxef0mXqR!g*NYg(;1Oz9R>Q=}4yJ^YwuFD&iKMXsC z5mI(VD}^28GA2x6`gUci>xz9t-xdSMJ~rhG1^$2&HYr|4JQZwDuil^k8z=WaIbLp2 zb~GU8^r+QKseE*ulBWbwhe!*uj*%LK9na!QyATphR|G|Lo76ih^hv?vLd=pi&k|9{ zQ$q~)XTx_88PyRaQE1h(OUAcZFU5S!*L>sie0+00S_C-j<3)rM7um-zW28+2<9&@2 zT;eA={u4)*Q!(gQK$`=3>;yXRcQWx8L8o&_6|_2wltHiaD*NX%v;t7JGeQAqLIapW zo&-ECRA35dJTug857=1#0DN8uJzofX9ueEGo z<32%kIN3x$i*rBVr&MhugX0816mw4LmxE5WgYNf7J_tdkV@MSLq&kX(L9UZCNVs$T z7f`o@Ndm|_QkYPnBs?#4g{IViea2YLqYtQ^oa;aJP>s}e70Cw=PmFUk5h7nO;L|Yp*PJGeIq!B(qw&M zq=JaUf_wOVj-x-y_(sfVem3}w>9l^rhH{~!Db^@|LHLOFbbm%jiQd>xOIS(&hdU*t zN#*D}=XiitSUjWHj_wA5^4OB{ctk`IlQKDzG+C22d6V(~7A|DClRVjzKKYYC8I(df zltfvSMtPJ-nUqQylpS>xI1!6b8I@8wl~h@kR(X|JnUz|(m0a1CUip<^xr$Dyllt%v zW_gxqnU-p~mTcLUZuypQ8JBW7mvmW|c6pb0nU{LGmwbtrV>y<68JL1On1orFhIyEX znV5a~mmQ^;j`^678JUtfnUo2aj0rB4nVFionVi{~oOziz;hCa2nxt8prumkjS(c}{ znylHHu9=vr`I@pho3vS*ZW)`lnVY(~o27}Hy!o5J8Jv#ko5ER~#(A7~Nu0>JoXpvr zW~rRc8J*I}o6tF()_I+-S)JIqo!se}+S#4p8J>~<`JLifp5{rI7gSkqFmRa3L2qiX`sC) zq6uoFGCHF&N~1YSp_k>OKMJHE`l3SWqc^IeyUC(Ps-sMLq%GQ{FKVJLI;2zzrB&*d z7;2>y>ZDo9r9FzIw5g;`>ZN0UnF?yvp zI;A^`qc)nRy=SIu`lM^Br-CY{e@dreYNx9IiKkPFrh{6h3<{@-8mDM_sAjsPmYSxD zx~TNosC1d9kgBJKI;npeqnOI6smi7qx~Y-csj?}ieQKqqDylGgsXgkZeA=e7dZxXa zr?v{Kp2|yidYW@8tjNliVk()(nyk)xmdpCA(n^}qI<40FnT&d^+B&Rcxvkz>r=R+* z;(D6ZIbjWOx~}d@nd$nj@=BNS%A8AiulSm;`ns=2S(o*?oE&8n0z0q- zTd)Re6Z_z=?HZo}d$11sun-%u2&=H+DxVE2u^5}N8oRLxORo!?n2G9|7rU_}Te2og z6CFF3(HgQAYMUc_vM?L7GP_X}ORS*(I+v}Avo1TcJlnG}o3e7btU0TrwYsN%>Y@qy zp+!ryt-7=`>Xt9-vr;>?4hyt#DXUwWv`?$GTdTE5tEyi+qFwv7Vau{+8MRcKwrV>Q zR%@9bd!Rd-wKyubblav`YqVo4w_njt9ce|E-OS!1~x0c(M|B9Tao4T+| zwX3VFgsYyf8@ss6v$MOFt$Uoeo4de!vb(F6y=$EOdc4S+yvm!DHQTN8`n<4NyU;tm zd|ABIJH6I>z0aGy+AFWz+r94p`n}+*uHrks=32hyE3QhqykVHWh{?V_*}Q;Bm%n?k z!|T3yS-%o{zi7F>!i&F#slO4+ztAeZk!!L948U_Kz!00j|7pN%$-o2azzPhP5=;~Q zKoSn@zanv2Hj%+JTfu^Px*j~RAS@Ca48f*L5+{to8Z5#iToNbT!Y&-bDyzb3iMBIb z!XClHKI{)%hr%!%m^#eDw)7E)1`;Lw!!{hWIGmP6+`~vL#Y#NIKn%h({1Fs9#49`! zSsW5rY{e}+!&EH99*enh8O1g1#Zb(`MtsC@498>q#$Vip^820( zY{z9x!(j}@Y%IrgyqA6dOU8Lz$a-AGhTOzg`^0D&wM#6jI~mKx>de=RzSNAQ)_lzzn$6lQpxoTe{`t+|%%9>s&i7f) z<}9D+oX+sM&g{IN?)=W@8PD=up7dPL14_yG{H*u9&)nJ1{_LRo9MHlF&;&i527S=c zna~Q|oDAL2%lXg{eVh_K(ZyNO79E@zozcI!(Hxzmc8ZfCJ<=py(k6YA`Wd_`z0xdQ zurPVjFdfq}J<~KIos(1o%{ZOYI=$08-P1f7mOvfULOs+(UDQT>)JScW0RaFzRjCd| literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/images/insert_image_window.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/images/insert_image_window.gif new file mode 100644 index 0000000000000000000000000000000000000000..cdc617eab3be256173af047822671023c41d53c7 GIT binary patch literal 7195 zcmV+$9OUCiNk%w1VO{|t0rvm^RdcFdezQ_>s9bxoL0*{>EO9wjk}5`qKU|j#Cu}xT zkSE)a6mvnrpoXNBx;DN)=Frh zNoSx7C2M<}%VvhTS$M8>mc|}AdlxcwLt&dYRFM}mcbB^3I#-jJyX0()z9&P2g{Rb! zwBA)!Rp{u`|NHRj>gvqQ%q>ZXWret1e6bZUb4FyIrpfSWiM&f`qH2n~Ym2=-T9sgc zv_)c^MPr>EH+V8njgYe4gr(CkOp9)gz@x|Rd78J6@ZHKAVFHDLM zDsO$C%|~UPM`fRIkinb3=SXIsHBpaPcC8O8Z=%NSaFN1(pUyNmeX@b0(TlCvCP9LNq|uz=~tBtU?8naNFTq#!(fcbLeE ztk{dK*Xy0U6E1QkL4kv$(u}X#UVXB0lEXMvk~~?Jf1%GcQjarGj(MBP zdYj6dzUE_twwk@>L0_41k-~3~!CHB*qQ&ffwfn5tWNi=8Z~%Ub*y%m$8wXzQE;bchq{EO(|31wK3kSRU6?UW zj51D)bCkr8v)w;km`iG+iLBRXh`KXo`fZKBP;RDBZ>EW>*Oa&6DMf`UMunBQ;f98W zGc(Nb@$mp=nVFfH004k9GcyDP1i-++s+neHnVEp*=Ksu@UteENP z00960|M2kcA^8LV00000EC2ui0A2wh0RRa90Qm_VNU)&6g9sBUT*$DY!-o(fN}Ncs zqQ#3CGh)2J&!5MSAVZ2ANwTELlPFWFT*6>ZyuEVJbXO|4oAN|cagzyJyq z3}(&hF$x<31m3a{;KeHw2@;ro09kTl44E?=IBeLU<69?Bk^=^k zZb|07_~sj?nK>oJ)HNi%e*F0dpnwD#h@gTDItZbJ6k3R(h8%hbqKG7# zh@y%tx(K6;G}?%xjy(GR2&9li8i}NmOgagrlvG-YrIuW-bb;fIt8@XE{34a6KQLsj zISlW>FmMJ1$C)sl4BzRno)Py+F`yR@sZyo%S`ctbep#1KyV``_d+P&qXH3v)2Q10FQzf_OL(bZ|PDoD^24 zhUE!je45ywEG8&_5NczG@|Z^!C9+193{ohY)XFU7vP{K{Q#AY3%|xZMQuPc~KwH(& zTxGOaC5={0yVcYGbS1U)e8g(O${Mk_cC4={OKi<58??|it+iRpZP|(&x9Ik*yNOG0 z<*I^5&;_`44bEMLi&x_4#W)Q3Zz25?$Uf#sM>@)JfNxX?010>|e=P+b3REBr#L*5I z$lx8<7+42Dg0ML)%uaZE*q$V|7LTy5gCB$)q7E@ak2t_1wR4O|QkXlIUFv0;l3Ax} z1}dD5YGkuG?IXs+EqAsA#PravsWGy5=S%Dv5q>~;~V?Y4}#G1 zj+E;oQ{Ykmk4LbB9rnOOA=?pyLn?BS{*d749%(^Irfy=E2s8#Uc!3NK>XCzmWMLoy3rNi35efJs2p|d6L^B4GLxto3o&?DWM;Ve@ ze57R{(NsuQ0}|oA(uO(!NgzOCOMfT_BvbH68vIcmkk|?&;sJ>;hY1p_>C_+j2?>Be zVjz(JFvuew@COz`vNn)d^CR0*sy~?Okr;Vo2qD=KI6+b*kC?$9O9DxhJhBFVU^Ren z+^U(@xm|u?S0MBxYgr5E$7|d}9PS9D0^#}sxzaVEUhv3OJW>FUG|VGo@kj$e0$6`s z(jSBJh+aHG1&;)#lm7UmKSFs0#`>c&9?6VHPRRg|^uQyh@dyDt;u?>flz6f11W0J< zkIo9fBe?_#2t0xvkJP{;zw}6XJn{sa;?%V&*r^db(jSlbG;AJ8kVlXJlHK~FLLPB~ zM>yn>qxu7z!u?1Siu;D+dIU!v5o1(6A|#JU0VGlIh?6|R1(00Vjav1eR}Hdec^X9j zyyMkp2d+VnZ-`@oFeqdU+VO(8&J}`njjuoE>yP?=S+xmMAuwXsN?uK)4tr;gNA6 zXl!GD81uEU^+%8W@#6xCgvkCln@5oB4<(1h$xvSE`anXXE9)W4W8`uQyzE>hiKNW_ zK&SrDEI>7Lx6NP;E1dU8UZvoJ9wrcnIOZ`AcA%HN?gcb_d_DoFzgJ>$x0`7!5nR{ra6s<2$x{O9s!MoF^m8WbGVf>1Tk;?fkRi97}oy(NU=X; zRcjX~0=2s4wLggI>zw8owmTL!8+^=6WBVhD$X51|+mPfXn-8hMmG-x&ja+|V*&kZA zg0{Ksk9LXKoYc)<8@YRscCOhdU;Qpw#mjDeW*{Hz2!g%keebyX`Mq`>biWJDFn|ku zPXzBT>->SSg!==8lBTq!70h4coSDG?T>(s1|vcMRK$BYMxaJpp|)= z=Mme1YpL}St5r20;abR)dOkJ{A5mK%5p=OPbV+6k&t?t4g?k{Od%V|lAE8`PwF=BN zeB=}o$ftE#Rej9oeA@L+@Z??6r$+Kd{w@Hc;G9wdlxARdev^%KuLLFyntTaQzBYDP?DnZjyJj6V^1VqsDOGHFHzJf$J zwnWCFOx*)T&lEmXG)?7$MQ{^b>eEHsxhVrgK4)q&gcEg;SVG7v(WmNIP2SQ7WW66xKT+QBojR zhM46uXsAQVlS@A2JiR1D(i2R*QZ>L*hg)-p-19`v1U^$FP2_V$*b<28!$nOcF4o33 zh$ug1L{9djM#-m6I#`bVV~#qAN9g!Yn23FvCh&?McxEIQl*ICczjp&h!}7IG+C22d6PK*nUgljB|52-`Q(mDkw`8u zltfvS2W2oxc#jR$g!`C^twV*H5qwj+yI>4h%jJ6j2Py6BLU=Zg|amcl4gaEOt|XgxO9 zkv)}%&nQ&lQ$=$Lh)_0&*_fAy7(Zn+PJU@sfZ0Zb8JvVkUPV!y#(A8`nVibGoE6bW z>-e0|8J*HOozz*K)_I-SnVs6Xo!r@--ua#D_*F>%ffGGhp5}R;=$W4Cxt{FVp6>ac z@EM=-IiK`dpY%DN{elz!u%GEgtf%U#ty-+0+N{Z{tjVgW#p<80x~#J5tk{aIy85eVYOB3kt;$NR z*E+7J%B!k6uHhQ1=?bgWYOU7#pWv#l^17|uI;P%wuIp;7^NOzc+MmvvuK+8r;u^5p z8m|Vcul1Uy_ZqOrdalfut`Hls%u2BQI;3l&Y}@o2?-Wtq}{Y#yYJ6`>Z$X zum$_ANV~IZ8mu^~qx71iQ|q+$3bjGHqg5ND8f&$4im6^3wowYUVq3OKO15U3wnK`x zYTLFu%C>GBw=)X2a$C16O1E~Kws2-pxsp4%lv}wru@8+)UQxTUkZZY~`?;VSx|f@|&Y874+qt5fx~jXntc$sh>bOpe zx~x09v|GD0;kpIdvs)XXMN72)s-v=NyTUuX#M@P*o1dm@pa|Qcy-TyMs%8KNu*++r(p$ago4%HNy#s2i&^x~H`n>Y{t?>)J zT`RuttD@(tzWm$2H*vfcI;`(YzrG8<$C|6*d#&MHqx4*b9=JS1H8Qje89W+upF)Sd%vfw%C>B~th}G049gX)!1F7nsC>)9Tobwc z4~E>!1B}T9%ca3Q%+3rG#XQK=TBgnX%+|aT(d^0^D#Tt|&DZ?RCXvmWo4gzA&ER~_ zAtBDC`?%=b&M~3R$jhLI%%|q;&gTrz0j!|&th|eC%9?D?0FBL(OwQWNyi;1w0d39r zOu{Anz1=Ic%Sy`8TCNYR!uk862%XT*ywF=r$-n&3`D?-!Y`-Lp%rctM8ZFEmJ;@n7 z%a|O}B~8jP?aQP89HWqY(>R^e+Bwhy4AS-6yfO{aG(FT8jmUTEt;@{45be@M8__~* z(lu?=aw^UJEY&MZ)vs*TJB!s?ZMIz9)nfbAVC}VHJ=RWJ)@FUx+ML#KjMi*juWtR; zzZ%y=tkZU#o&Lb5bluJN+1Gyk*EylrYdx#|lhT%W5P_Yid)=jlozjzd5@#aV+GQWJg1G_67;kZ{qVq-?Sq-E*n>UIF;2yDJ-;sO(>sdY_Fb&{4cp=M;Q7tp)Qj8A2jF?l+?&nMAKl*U zz1jxu&o(XJ!foH#ZQ}X8-w&R?$xVF&vE1n0+#ap7LoLe(KE5`N<0AgTBp%_}?c>8e z-rcR;w|&?ze%=Bu;~Dzfd~Mh|VdQrd;B>0Q+}x(0ozU(Cok%|A174|D9?Miq1o{)*M7X%a&D<~Ugwf}=XegOdcNn3+UI_bsDK{mhC1kk zE~tk8e&~Lh=um372XAO+_sit^+~}%qpsa4UJzLa*TI&U>>vDVRB`w|9io#D#-NLTauzsPu-rJWx z>vikv9e%7LG;!zEvyiT(Sd+l!P>_N@T1P;|O8|^xN(#($Q+TOO#{^1HP%Flk| zP>rJ3?$rHx?rLku8Vv2w?b6BY?UoGO<*w}Xp0=F6qyg`r1z)xUucQahp9>$h37@15 zzwD#i>ZqQukWTC1dFpJg=w$rx9M7_%{_*G@@**$rBwz9ffAT2r@G8IZo8Iy+ztu4R zAM+dQ@iZ@{HczA%@8>x`q!HiMJujp`uhl{CqeE}igM92#dh}9#%nPdYQOfj2?d!)5 z^|C(kfll?_OXDfb!a;q|<&Nj}4(%fS^%ZON(Hr)4p6(%j!3oaHYA@$(FYeC`)3uEC zJn!n$9n#8d-DuCiaWB_J-=k8G$b-+Lg-^(bzu!D%|JKPm?Wo4kcRDXu_K}k1l1JaNkp?QKe3$DzxcUtXUf-wTMycSFmBl zjwMTw>&CKa)vjgRc5By+aNW+OTh}hrvtIA+<=fXUMYu};4klc($8 zktNT3JlXPP%x^ae&fM8E=E|Q%k6s*_^vW zy&9UYLGvP1kiPy9G;BilDzwnB@e10o!wwf@5kv@8{ENizOgxdW6d#O{zw>zPF+m*=Q$Itk71mN^ zy^Gdeqq{Y(TwM)z)Lwn93s_kD5!O>;A2l|m`;K*XrDT0mB8KA z+*q|8@h5Q6t<_xt#RYX*YEMECrEdMn*I5MJ%~oBu)`M5y?d;8$;A{7NmZ3>~YS-Rx z>y4P;iNgh$Fo9`H7-D_#<#^yy8!ngQj=yd9-jY*J>EDaf%DCKaA6B{FidP*x;*WM%d)67hXtYZ)>D_ z#;|J*S+jswc;caSse){XT|9<@Q*MEQh`=9Cp00vNi10-Mp4R}BV dCQyM3WMBgw_&^9oP=XVrUgvqQ%pf~`GER(^x#BTSjC7R6H&c*sk;0_uapX^FdrsMTzZzF~p25iD?w zuG&s*rAB0(f1%Hy#Os^B=S5J6Mz?KY&18n5D_@hpE+`!s%6X zsueJEXo$NUIC_w?-6%waKwg>W3FB0hf~ zJA43U%$dC9a+Ac9w%{s8g&{nBhN#q@!Rb9(l~Hh~X^Fg0Z>CXir;f1OjgSIhEi&S%}BR_v1I($D|mlra1CP9K)d9NZpeu}Kvfuqn#XP}F&*>{-8i>=sp zm&YbTf?RyDf}_!Zq0eD}v_4yxcbLa?mBl?{p+D~nzm%HPezUGj! z-6=(cUVXBZx8Wo}fe|ZkaFD@Udaqo2uz#S=e4WgGpUr!n%WaLnkFwmHzvr60<|##m zZ;-(_RgpJTkyCQ1ZH~WSfV5tIvJNP1P;RCgHF$uc&{J`!n7ibh!03&z+j*MFl(*m| zL4kOh$#IgxElG%Egttv=q%BH_PHd!icXu8+dxWObFH4CwQ;>3!!%J$SFHDM&v)*co zyosyVk+j}rg}5F%dx@;qGiLfsYNKL;wQ7sKM`fOcrqc{2Y&%($JXw{7hK6E-wkt=5 z@$vC9Gt2;HnVFfH004k9GcyDP1fY{mz`(%&%$b1Z<^at905h3pnVCR9K!AXN)X>NP z00960|M2kcA^8LV00000EC2ui07?O$000R80Qm_VNU)&6g9sBUT*$DY!-o(fN}Ncs zqQ#3CGZNIt&!5MSAVZ2ANwTELlPFWFT*oN9pa20v zqgJ3?T|$D&7neZ2G_4S)t`L=G-R#W&QJ??_3O3rt{ZTQCmzFBHSe002jf|WToh(?W z#Ay-}Wydto01dLhGDQ}#yaGce!a#z_Cl5R@O*ws_kpd44FtE)xk5D2>3!)hF1{}1Q zB1AUa_)!KjsT>hP2u+Ye%ov2&Qi=?<6k|miJq!{@41joH!XA1ou)q!oB&p<*Og8D{ zlTbp*k5M`?6-_!=W|^f^P)S9VRaj}ol~-ViMV47;sl}FCaLGlNU3lrmmtTMhMwnrU zDaM#%kV!_FWteHknP;GhMw)4;sm7XXu*pW7ZMf;in{U7gN1SoUDaV|1&`C#~b=Yag zop<1gN1l1;smGps@X1G?efa7B$De-y3P_-V2r9^+gAhtcp@kS~$f1WIib$e~D5}V! zi!jPaqm4M~$fJ)y3Q44qNJgpcw%j^7Wll&f6%9%6T(HzrQB76VRatG-)mLGSRn}Q) zt<~0Bam`iNU3u-**I$7RR@h;QE!Nm$kxf?FWtnZ(*=M1RR@!N)t=8IWvCUT7ZMp5% z+i$@QSKM*QE!W(0(M?y~b=hs#-FM-QSKfK)t=Har@y%D?efjOz-+uuPSm1#PF4*9M z5l&d)g&A(x;fEoPSmKE(uGr#>G0s@yjXCbv%yPuB4CIWvir5lHVR>r9T_Q zE%yfRY+!Cu=z6(snC_DQ8Sk0&s(Ejl`oh`ooB-Q7aGnP9ned+s3;J-O5+hpiq8K~6 zaikto8uFziYkG30Dudecs4$y4bE-D8n)9nX%ldPzLgQNWu1Nd3bg)hn8}+eND|>ab zT0`6Qv|w91cD6b(gj4ei;Z$}*(j(AzmEyv^ff!=QeL+0nOsR67sQ2Oz$d_ywFsyAb12{ zZUO`R;^Z$n1*U!;xq(L-mp^|Ic$!GnwT9i_YsYK1c4s|B1+jnj>A42l2z0UD3g@p2af$sIt_M}P1JBuene7W{D>kem!8 z)B%ZhKBCW$oT{JxSWigg0}}jz#6KQsfInyu5?z6$lOJJPL;dkkkBrD8LI_EVP6?75 zdBh6-z^L+Y2umF{52OVF=`9PAOOl@Sh)Rh@J;1TVCC-!sHNB}nq~Z~)c!UKW$)ZQb z;t>b`fMlp(kIOjZb}}KSH?1_5F|eEh;lpv0gph?BiHdrBK@&Qe>4)Va`nf1JQ7e?d1OBxVFF0_>W>3? z1O^^)kVh2ik53NvBP}p291!af6?x=^6!i#=JR$>-NcM)WBw|9I$3qQI$(BO&uxCG; z(gf^d9?l?b+@9D0c5r~EHpLrGTWf&Vg5)bAv8_L>>5ts*)-ECeu0MoJT;n2Fe^K>^ zbNvC`kEGKyAYo^0JW?Az`q8_U6032m*K%MlrSME{8;4K(3Q-Ki7)UD ze1HQS^q@yOz~PS5rdGzQ&8a_J>kqB)bhdy4>RPUuuOH{2w`B~jH;2pA%Wduz zo(qyEQ&-A*w6a&R92_l&*B|5chjY*x<}tIkt?xZ^T+=MyD$sY5ZuW-<;VkF=X5qg9 z&fP)G2L}$HDize5_Wg} z@m+t6jLYOjnMaV&Y=5k`z0pRqnyt-dY>(i+mdxvb=KSqChr3tf4pzAn?2p6x1KsLo zx4ZpOVR-Y%BQfxZ2|PksTy}QE9RBdVLA=osla$|XOG-NuAP;%CaKuVG#5T+i@8 zz7F<|($a@yuPjG>*>9z^V_eCkDNW_x%<+BcihV=h76ZpVeEFkr@hfBh;sl1L`#JS- z3p3}SAm(e6Give&lvF%F$G}034uXd~-ODOyW(?jelCaZ3mP9)tq)E6_Lcbzdy`w^- z1a&TiHK=4fG{j1iC4BWJ5G4^(%2z}}1X|)UQ`0wn)F(daa(#SrK3W7g>$4`_2YzIP zICVmP1fwVC=O^jcKa)d8kT*c@r$-zkf1a~If+RW*WJsnXD*G2R{iiDb_c|O@NwWh& znRGiOlr#y*J1GQFQ{!jL0)fRdL-BTK8Z|`6SBB4HhQ}9TXh=&PSYn~&0dN?HayWN+ zV?`&JMSr6{T{JlE19*osKLK+mGl*R17e@|5C^~34JeWBK^n;!Mqdm?XAn zi_DjHp>+Yi_=~{kizEn5*oT67SWVrBO@7Et<0puWBTj`FIfux8B^P;&_$ZF}NAx#@ zlW0%*hlH3IZJP*C0SJW!RXZZINuzj$DD+ULNJ_%PEUO5HhUSW|)Ghd!kKW>jP0^3% zVtspKK6pq?+{c2-xJ}|0gU)Dvj$?y{xPAb%gVj|)*vL8BD1?$&PxyC)mzX;I#5$1V zgq}EnQg~46h=2yRfLaKT4@f*Rq)PQzf!U&uG^vkAL=-sxnUgxXlRVjzKDlAwvW7xA zltfvSMtPJ-nUqSoluX%_PWhBj8I?#0Vn=}!xpmSkC$ zW_gygSd~Gk5C71XZuypQ8JBW7mvmW|c6pb0nU{LGmwefme)*Sx8JL1On1893YDt)g znV5>Xn2gz&j`^67NtlKSVv$*ymU)?&nVFionRhvv-@=)o8JeOwnxr|Jo{1BsnVPD( znylHHc6pj?>6)@Ro3vS*kO`Z%nVY(~o4i?r6u722Y1`Jpfh zmo=KA$+@C?8KK1YmK!>vJSw8ZN1;U8Sw8xs4ceneI-)=tq)dvVDjJ~txtLB0p(JXd zCTgWd`l2nGrCxfaGCHGR`lKd$qfi>0I;xjdnx$e&rZS49Z#t${>ZVU>qjLJCW_qT; znWhffrE;pJVv3}3YNtmksB}7~C3>fdnx}gI%A0(OmuniPY}%%jTBnwJsFO;mU&^G6 z+NintsCOBugo>yTYN8+V z+ZwLq%9!I?uIMV6-k`L7Uru^5}N8tV@do0t^4qo8TA8#}TjTe30H zv4}~rk}9Dm>Z48SvU@4ACOfka#x^vo<@lL|d{rJD4hK zqc0n@VH&hd3$&>UvvVo4MO(F2ORz^Pm`Mw>UHY?4>$Iu*qhLF>a7ndSd$wqMvIzT2 zQ<|778?|8iwNV?kU@NzDX|`#bw|aXLSsR#J3$$HJw7pBYrGN{yyh^!oJE3)%xQx5GXxq1d`LVXCxtu$?MeDhR*{|Ozx}>|hG;6y0$+ilc zx~x09R_nTb3A(kZue!UtyxY4_>9~g(ufltoxI4VYYn`Zjyvm!h$-BJH`?<~gywWSL z(L24?`#k;-X+P&WY+pXa1n!a1U=6k;9>kq(dpW|tjX!*YI8^7{9zhBuA z>not`dp5MYzXkgcIdQ*jo4WeTzXS}h9f1;50>H8BozGLi4onkA!BO@*vDsUl4g9eE zfD#!Dup7*}9V`tyGXneJd6+tOu<0BvxVxjmm8={i^6xg!Z7^8 zEzH8X1jb>U!ye(qV_d{#JQ8Ls!(Ug#UtGp#9K&b)#%=t@ZfwI#yv88W#&EpEXlxQs zd=ODg!c#276-uU)`?Qq*>z7$HJuxKjI|yuj%7mQF#(J3q{mBnp(jpPa9evG6Tf&y< ztCcy@WNgwh?Gdy8G?X6w!yxUixIEK5T@qcX(pt;X(zy>mS=2^-)DWT1AI;C>+0#xf zunHW$QZ1L`JJr-$)m9CySe@0#y476$s$TuojT+WseWqkx);Kz^=u1mqz1C|O)kAEw zZ9TNM%a>{`*Icc-7+crWTgZf|*9FVh&kNWPE7*B?*CcD$%S+fCOcILSnL@3XW((0V zfy0k|yqZhdGhx|qt-`_F*dI05pAE`2!P)y9yq-jJRjI0ecJ51+iG0hr+m=KjLgv;-s0`v?7hjr{odfc)TpiA zi7nl&tKEai*aDl}!YkknOW;%;*?DQ;0E^)8%HV+w;DQO^HR0gxO5p=*;cuzdZrwv| z-Qi^@;b{H5XFcN1s^BKht|gx01iIoZ{+}-X;{6%pGLD}#UgPt5<2W9lI=GC_d#~UFB8|)>xk9V=bjf{pDaD=3+kP z6A_?KedcJMw>L@VY~JQ>{^mbv6d*q5bYACne&@YQzk0sseBS4N{^x-H=K%o#JO8ab AEdT%j literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/images/insert_table_window.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/images/insert_table_window.gif new file mode 100644 index 0000000000000000000000000000000000000000..6a032c5ae8dfcf3fad7ed65c814c2b1a1e88d25d GIT binary patch literal 7094 zcmV;n8%g9xNk%w1VN?O-0QUd@N@$@~bE+9McR5y*3@2N{Jyn zeikuw6fSZjKY$xHc@ivfG*FHYDQ-YOK&Hy@3M6WhwcmA?#tS8DW`?gwvu%*-f6gm#z5j??}Me%O>3j0#_dOCo?w8qP;RDqo635d$`C4Vh^p5%QjdkF(+?_dPj01A zaHmjjriiN6aFD_vJbj?U>VBWiZ;-(vJ%5F#)HPC%A3A(@n8-zAootN00A|dYyyYG` zdtrgKqQ>o=!RTFlu`5T0kh9%#lf-h8!(@cFpv3E>$nHN}m@i9;BR+qApw3rztYd?> zn7rhXv)(>immD{FqsQ)@!00wpkS0QcR&}hQ#q2Olid}uOUVXAycC95rf)y}xfuhis zx#B@ynU1jAjIP>^ui9yeyG&}M7czBAX`+Ip(N%P-mAK(nb*q7+(3QC2BtU^BL4iPC znJPwwI8~92uiJv7(Pf3WTzjyZz2=Lp*?*zWZH>Qbio9rux?+O1OlqP=WS*YF=|EkW z6E1QQEO2Lsx@d^ILSULfUz$c^ohn9#fTGV|f3u6O*%2#ngr(AlsnvMVVj1AhDc_gM`fRHkHIlbi!e=# z@$vC9Gt2;HnVFfH004k9Gc&-zz@U>&1OxNP z00960|M2kcA^8LV00000EC2ui08|0x000R80Qm_VNU)&6g9sBUT*$DY!-o(fN}Ncs zqQ#3CGdh&O&!5MSAVZ2ANwTELlPFWFT*Vbi~gsQuhB}k4XV6cb@(_)7c836)(3dKlJ zByu4_V54?}l{7n#AVmqr?8+P(vz872+B0nx1`N7n?b1{vmIx7VV8Ox>E*%;&*1YM- z!{f;h3l^-fLK{6O<4hJ>lu*J8*^F~WAVji@mK;wlPMig_*7+e_BK?kk~ zgGnZ-T*5*%+~8424HZ;igE-%SGD;;GWPl7IaWvCP65W84NFC4EGJ_d>G|>nhRUp#G z5K_1>!IV^1Y2}qzW~rr?{1~MZQ`eXy=9ptT1(j4(S%sBWTzLhSSY(-nmRfAN1(#fO z*@c&0eE9{KV1yZlm|~1M2AO1(S%#TroOuSCXr!5jnrf`M2AgcO*@l~Ly!i&4aKssh zoN~-L2c2}(S%;l=+<6C{c;uP?hn{-uxd)$o^x21>e*F0dpnwD#h@gTDItZbJ6k3R( zh8%hbqKG7#h@y%tx(K6;G}?%xjy(DZq>w}!iKLQDItiteTc)e-x>$CZ6H-fEL()4V zDD_lS1WZ-cRatG-)mLGSRn}Q)t<~0Bam`iNU3u-**I$7RR@h;QE!Nm$kxf?FWtnZ( z*=M1RR@!N)t=8IWvCUT7ZMp5%+i$@QSKM*QE!W(0(M?y~b=hs#-FM-QSKfK)t=Har z@y%D?efjOz-+uuPSm1#PF4*9M5l&d)g&A(x;fEoPSmKE(uGr#>G0s@yjXCbv%yPF4^RhQBJv%1bgfMt&#*&x_cCu{+M9+;U>IeLcJ8+i{`#-`s-%EaS}}D!FMXG zXTyC$4CuszT5M>>iE_;7$B&9EX~~tMjOogoy6kDpq0&t1&8OT!rH!P3slZ zfHk#YS04VS*IA;~Mq407&$urhc^vU~n4PoYvxz11d~`9$}ycJQA@$ zQH)R%^oS5Vvav;B@G~A!9S2wA!ApVAA0p(`%RVJDQF$bVk?=?eJhHP@`OH;8ixtsm zb+lW}$0PUgh|_!pk{&Y8BhJ&BvbxqRut95V(_(=~td+KqaPMv3lAE~dRxZ4uD}4$< zpBB5=MV+`Wef{VML9+S9zd=mM)B_G|WCse|7)Lq!qkoXIV*n|q#{%{- za|yJ|M;!M5kwStlf)hLxBNf%LMnTdalAIJJ{qeyNvP_e+GodFvQmT)js+7EYVJd+) z!&VXxmSm8n4gutmU{Q@&xIC6FhbTQ?9?^Qj^an9zOHnq3;n zKCB5wXmXPuM|GDs-<6aLz+)cxu%AELaSwE&00k#VK|4K?uaNW$BwzuFSv=wZe}Dia z3Cm{#K(Yvs1O_A&3yBgG`H?PoBr_gC9Y{(8l7)UmHVy>|2{~Ci8GwWlAQ`1UssoZJ zc;pKH01rrH1(NoFFBW>S^yb-#U#=ni}Xij?uv@MIx3PIM2$yuP)Uzm zaswX8jYl>~yA%2&03ZpaKNNcdkC+l9H1NoHJc0p_u+k&&@dyq;DpJmR)*}e=$O}?R z1dmY2BU1oLYW)Esk95EzC-O*4XKDju$~F$P^~jJsGDYz@^NQ-rVo-fcR3HyzxWpx6 zQuZ;Ad??p&Y(xP&PJmUd?vJa|^#^tRVcm~>MI_wy2c7Pju<+_LFCOU&A=7(+^|n|4 zg8rB*d?(pkHgnYD~1t^y!Gjj zfxAuN62yHksw%gT3U2 zvz+7GNRK=c&+I;eyDhQb{`%v;^_Jbe3#;!^DVV|jcC0^K(%$;Io))g+EfO%hH``o2BLdNA%8V27P3- zAPM}%2k&B6q`Dd(N&H7LaN`_<#7L5-yya2;^2}>5XPY^^X7jq~YlWzWSIvE5hBco8QV@a9v zP+~_|CsZ?Lmpd$EO1%R^suVmlAKhxI2pIJ2A9M z!c#*^6N$&;D?(^XmIy@8vr9y@i7ypQN|ZgIcuY|AJ-6j!wk84gc#rs)kNUWe_&6o} z$d3mYKgTr!1X+*a8JJ{56ogrrhIyEX znV5<>5#QvBj`^678JUtfnUqo2VI@?}8Kmkej->o4nbZzWJNL8Jxm7oWxn2#(A8`nVibGoXpvr z&iS0s$(y!mo6%XF)_I-SnVs6Xo!r@-&^et%<(=aHIiBQMp5}R;=vkcL=`QKnp6>ac z@EM=-`48)foAY^}_?e&jxu3sTpAx{I02-hII-uR@p9FfK2%4Y@8k`2Ypbq+=5UQUI z8leD7d8WRZrEaRG#mT0+8K!b7rWabJb=sVC z3a4Dkr@|Gdd^)FrDx7(`r*=A`cZr=ft;Pze z&>ErAnylRVt=M|4S_-bus;%A1thMT^;o7d_8m*$ro}{X%>6)zc`mSr*oAb)9%c`rT z8nBwGtMy8tWXi0$TB)VVsQYTGojS1Xda4N9r>V-R59_T7o1j%no_V^RA=|Mw`my6V zve=2TBrBsPyRt6pvG;19FFUgv+OjnNd$ap#vpBo6^Qp5u`?K!pvp_qv<|(v9d$itZ zv`D+O*{QTl`?S&NvHrzLuC_L3$*ZHyV+NJ~=w!(F{3(B!v z`w@%#w_2;WaXP2K$+!2}wfz9OlB=M83Za_Ixq~~oWF)i0iLmhcs+QZQYMQ!-o4VC0 zx0^e`JcolCZ*YqrEmu&b-O+4{M~JG=lJyCE^Vw40#bYP_wxuF?yv z?a8*x>k@=(on(r*$2+~m>%F@FtFPIKw%3cjjjOxhyROl@uhk0@<=Yb3Tb+1{yxj}E zxEsFzioVXNxNUpB_=~?1YrE&kzjI5vjS0Mf8mO?FvHvT*&`Ye*skxcgy9lbl5No-) ztH0$b!I5jeNlUpfD!3l}v?2_@27H?c+@dAS67kEkE4&gd{GA}I!ZzU#F^sb>tP(dY zq%+K-SZlRE{K3C#wM5*WTU*3Pe55^`#7vyGL)^qrter<3#Z)}SR1C#de8o(h#afKS zT-?P({Ka4lwPFmQK}^C_d&1Otwl%!NG@HXI;l>`i#3%~KHvzwUO(5c8I!N~D>xR;E%#|g^E zsmVg6$M{;g8ce^*iOAPU$|AwZ?`gc;E6TeI$-XPes0^@;TD-68u#`%?&%40C>B=Di z%k7D}yX?IhyR6LYtiCM3y-Ca*;`Oy#B z%Wlfc1O2JDi_(t&>d_W0#nxP%w5-#`$ty(4YXuk);xRGXpOUKz1B3_)^7c> za2?kxJJ)pGv33ogSi9E(=nr=-omVZQqDh;Ct&bg%q*?v8Pt3=BQ^PLt5IKR^Rjs{& z9ir&t*e#)jejM3GI@O9@)FIs1n7tB55oCwm*^@25m3_IOE7~oQO)K%f9#Ps@c-r#G z)ZFRWIK9}p4ACc>$*w)YCL!Cy?Gfcm+dswG*6GQ;t=EtX+Z6oSU2Vzf46?xOzM@MK z#9b1zd)!_B*m=s$(-h6n^BKCv9o@SP+6?{Bmg>5f>aa2m(8_t)=bhb=E8HE-yxr{& z!mShE{cGVJorVm%&YZ#Pi`&U*-u#W;L_OWX>(Kwp-Wk8e*kXVIxWl4&D0AyvU6ZM83B!E#~e$;Nq#cc5dd< zy~aiV9-tRK+9$>j6yx!|!{OiC@#=<`AOq z>`%Jv%)X?~{_IH_?Yqm@ReQA7e(j*H-aee^AT6Z`UCik{>om;h-~OcGKF#A!>E%A! z=kBEGKF;gD$B91W@)_^&yrN^Syyiadr%c{qKGE@s?+HDi7W|tR%gW?Q@b8|R^PIl3 ztkUVp@C17BL5e@dj`2CeE-Z|I*$`@sm#P>+SLOEYK4F zui_*xpyKM}U_Rc7T=S~V?J(}~68`bd-R~toyz(9N`##@1PuZ*9@dPd99X;|yZ}U@* z$VhMRxxMtN-Sj{I^!MDV2A$+nAD|YGaTkI9e@*=Pww45_8ZFF z?GNQ&!dt*`8rzpmS3`L zpZPP3`J5l4p8xqR8u}|w_@+OZuinI@ui}N>`m%ZIzRvh2is`jp!;lU8j=%X4O8d26 z6Phi^oo=A|^&FIrV z;;Fy*f`83#p19h75?Q|8(GL^f4}if>?97k#xC`I6TjAsR{N3NUN01>!jwC6PA-{dmi3kk}EO=1iPJ%oO4&+%hC{cw$eF7zT(&0{n5L5cQS=H)QtXZw9q}Xt!NSZY* zLY+y|pjNawldk=V)UDB;Onb7W>-1?|w)+|Atgcx9wY< zLg6MA>KLKjrx8)=UEJC8=aGTEN+`MWFxh{m$DTzDT4Q6&kt_Qg>NalwQQEPaHq;z( zs%zlEL5toj+&DD6z< zPI^6c?%?Im_b0*ref;^+zvr*LeShQjiEcmw3pDUR1f!!0Kn9QduR+)7lW@ZBAhgi6 z2QSocLk>ISD?<-M6mdinEdsGb6jM}Dy%Se-@kJQ_YB5F{YqZg%(FD73M;?2;Xht7{ z6tYAhhcxoY3yaLiJSLlT@<}MiLvqTiqO|f#EXfN=NsRWPP`-Vr6w@Xzznm~kkhr|4 zOf#E9b4)mqYg58E0n2eTk=UFwwmReV^R+$a>ysljEz&bkx(5CKbJ0T)P3XIU6xFEE ze;SSJOGy2ZbkR61RVvf@GTjs-N<9U&J5f1R)ljx1Yctg}?<|fn?>?Q4Hn{|X>bp@_ zozhhAaFy#)Vrx^VR}*E;4yRgeo6K3Fo<#^*UyTHouF0Nt)!2lnEwx!=B@>saZI7*% zQE(q6_b6_6wXNGNm32=}%Gl+$w(rV?_gp_c4Hw#f+kMR3SU1y=UUjpL_SU5$BbZ+} z{Vn!3fQg0b-D%@B7*ARqb&Ohwdz9GYq`Z|kPm&W2IpUO+GkN1#5pH?km8l$g=14W3 zDrRPJrnzP$Z^rrMotO0}OQewo+UBI2PFm-#cwTyHRVk&D`syLA#(HZWwdVS38odU4 z>=nf(`)m@;MtkiJ)n@x`3*Cl$?*8Pa`|kAY#(QrEPv-mY4Y5mbaKZ~W{BXn*SA22C z8+ZJ1$Q_c^XUZ$L{Bq1QcNFHxJNNu^&_fq}bkZSD$!XM6SABKXTX+3+*khM{_AB+X g{dU}Q*L`>1d-wf!;DZ-_c;bsU{&?h*&o3YVJCt#L`Tzg` literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/index.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/index.htm new file mode 100644 index 00000000..b7e06f28 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/index.htm @@ -0,0 +1,27 @@ + + + +Help Index + + + + + + + + + +


+
+Click the links below to go to the different help sections. + +
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_anchor_button.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_anchor_button.htm new file mode 100644 index 00000000..1a58b641 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_anchor_button.htm @@ -0,0 +1,33 @@ + + + +Insert anchor button + + + + + + + + + + + +
+
+This button opens a new window with the insert/edit anchor function.
+
+
+
+There are one field in this window, this is where you enter the name of you anchor point. Remember the anchor name needs to be unique.
+
+
+ + + + + + +
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_image_button.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_image_button.htm new file mode 100644 index 00000000..d3f24fba --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_image_button.htm @@ -0,0 +1,66 @@ + + + +Insert image button + + + + + + + + + + + +
+
+The insert image button opens the window shown below.
+
+
+
+You simply enter a URL to the image you want to link to and enter a image description, +this is then displayed as an alternative text descripton of the image on the page.
+
+Field descriptions:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Image URL URL/path to the image.
Image description Alternative description of image contents.
DimentionsImage width/height.
AlignmentImage alignment, useful when wrapping text around images.
BorderBorder thickness.
VSpaceVertical space, useful when wrapping text around images.
HSpaceHorizontal space, useful when wrapping text around images.
+
+
+ + + + + + +
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_link_button.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_link_button.htm new file mode 100644 index 00000000..2cf40c07 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_link_button.htm @@ -0,0 +1,34 @@ + + + +Insert link button + + + + + + + + + + + +
+
+This button opens a new window with the insert/edit link function.
+
+
+
+There are two fields in this window the first one "Link URL" is the +URL of the link. The target enables you to select how the link is to be opened.
+
+
+ + + + + + +
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_table_button.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_table_button.htm new file mode 100644 index 00000000..f490789c --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/insert_table_button.htm @@ -0,0 +1,72 @@ + + + +Insert table button + + + + + + + + + + + +
+
+The insert table button opens the window shown below. This action enables you to create tables.
+
+
+
+Field descriptions:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ColumnsNumber of columns in the table.
RowsNumber of rows in the new table.
CellpaddingCellpadding of the table .
CellspacingCellspacing of the table .
AlignmentTable alignment .
BorderBorder thinkness of table.
WidthWidth in pixels of table .
HeightHeight in pixels of table.
ClassStyle or CSS class of table.
+
+
+
+ + + + + + +
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/style.css b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/style.css new file mode 100644 index 00000000..975bc5a3 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/en/style.css @@ -0,0 +1,28 @@ +body { background-color: #FFFFFF; } +body, td, .content { font-family: Verdana, Arial, helvetica, sans-serif; font-size: 12px; } +.title { font-family: Verdana, Arial, helvetica, sans-serif; font-size: 16px; font-weight: bold; } +.subtitle { font-size: 12px; font-weight: bold; } + +.toc_ul, .toc_li { margin-left: 8 px; line-height: 16px; } +.step_ol, .step_li { margin-left: 11 px; line-height: 16px; } +img { border: #000000 solid 1px; } + +a:visited { color: #666666; text-decoration: underline; } +a:active { color: #666666; text-decoration: underline; } +a:hover { color: #666666; text-decoration: underline; } +a { color: #666666; text-decoration: underline; } + +.pageheader { border: #E0E0E0 solid 1px; } +.pagefooter { border: #E0E0E0 solid 1px; } +.sample { background-color: #FFFFFF; border: #000000 solid 1px; } +.samplecontent { font-size: 10px; } + +.code { background-color: #FFFFFF; border: #000000 solid 1px; } +.codecontent { font-size: 10px; } +.codecontent a:visited { color: #666666; text-decoration: none; font-weight: bold } +.codecontent a:active { color: #666666; text-decoration: none; font-weight: bold } +.codecontent a:hover { color: #666666; text-decoration: none; font-weight: bold } +.codecontent a { color: #666666; text-decoration: none; font-weight: bold } + +hr { height: 1px; } + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table.gif new file mode 100644 index 0000000000000000000000000000000000000000..f8a00544a9980d38c44d5fe8e9a8457be8339834 GIT binary patch literal 1018 zcmeH`!D|yi6vijCX;K?;HK|5XNfs0Yg$)+cs)rOqvff5dHHc2Uv)oRl&oNM zL_v>pGsp4dsvwhU>0X4Xh+Wac9CC=o!gvw&;JEQG@DJ$6$B*y9ySxux{Y-6ku9*Wl z&;cV^mgTqzF2D-Ju^=LJ*5Me*7UC50Cy+D9dr10NaI7en0;v!yiHT1LWt4Ho80`td zH0fy?J20##7#A#vDOn&n7d(iA=0Y-IcxbrPf)f!?@szE;c^>s&MB!_#s1QkQn7rM&uZWEuIkdp$R4&n$wy)0vxLV{8?)r-!}Ci)!@%sw>sSn!}>!G{SeK1|r~VZn+68+II6u;asm10Ob=_wF-@g9v?#;*dZ@+%|{O#+PpFh6;{Q2Y8&mX^k|N8U$_y7O@!A=+@ zMnhm=LO}5+3o`?QHiHhxdQhHV;HYB==aBK(u;5@bhp<-6i46*DqFMnSA1*XHGjymj z$?Op*WNGP=)SJbz@M1!Xh>C;FgAEIv8ibYXrszl~ z&MaaYDh9g*7@JwyXK1-BXgI*Il2h;pPeZ6;LmS)vCRL5HH(U%EXSsA%Z__>8z+epk DI%10H literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_delete_row.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_delete_row.gif new file mode 100644 index 0000000000000000000000000000000000000000..1997065fb2b447f498ab7fda4b7e21dcbb25dc81 GIT binary patch literal 942 zcmZ?wbhEHb6k!lyXlDQc1CIoUh=PEGhJcKQgo1{IiU|b`3j#VmBuw~FFylkPf)5Q7 z7Bo!QFk!}m2{SfKSg@gC#fJ$SK1|s0VZn+63pO0su;ai2Ap5|F4JUx;|A7nt58U{F z;lck0FaAIH@c#o4{rLYMi2nZv+crv!hQJ^S0mYvz%nS@F3_2h;f${_cM>m5fhm6OD z1qYisgtcN$Ojy9mEvgi>fT8hWN4JEt$%Yw%N7~tCoGZROc*x+)p`mC~@Svg5n~l@8 z>cxRXXEq)or2`@y3m*9JNg2eP*va6?$lx(i=t)DOQwuAXkirbBgarR4#!XpwwGCZQ}j-u$i5iXM38c!-9o(cUMTVu`pNz0PJ9X!TQ3xphWMO7tP+`ykxe1gf7&uxPJUL`M zHY_;U%pokNQs8*7k%5a_=z@SE(i5MkXeC zPNt5?0yW=8hN62%Dla%PGcz-pWCS=goN5wqs`((G@bc1P7WEc}kBSW;s{+{lBo>-5 iu&xUgtrHbga%dGy+03=YpedVyC-?NbIlm1R7_0$Wk9qk3 literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_insert_col_before.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_insert_col_before.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d1ff37afea7bb2e67952400e00184aa275d6764 GIT binary patch literal 935 zcmZ?wbhEHb6k!lyXlDQc1CNA&goc2OhJ=EKgo+6T6%!mP9uzc82Q3xphWMO7tP+`ykxe1gf7&uxOJUL`M zHY_;U%)u+PW5EN5h88YU7mp7DN{(zYMmj4p0u!3~q*V&u{5arzY@(RFO-4h5!|^7D zIH?}ZVugm;rn%2dUMy&AWMq^w(NJJWb>vXAtKet|SsBK;hMu<;?0m9#Rd5 h!d40F?cxwzaHwNr1Z$MUMpFj1Z7JoaTqOh;tN|1Me9r&? literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_insert_row_after.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_insert_row_after.gif new file mode 100644 index 0000000000000000000000000000000000000000..c3aa15f93a9d50777ca3a3b2309fc807ceabc57a GIT binary patch literal 928 zcmZ?wbhEHb6k!lyXlDQc1CNA&goc2OhJ=EKgo+6T6%!mP9uzc82Q3xphWMO7tP+`ykxe1gf7&vMfJUL`M zHY_;U%)uMAz#x%{g`JbTZ-#`DOLGT{dj|*Oqh`h)X6?Ek4-y$X8X1FD*?2NJv$hH7 z&6{JfXpzqZDa$&I13@aDj5?v~Qf7WQ*v!VmA#i}h;Q=$htVPBS0l|h)240Jt69SHm a!Hpb79uX5BFnBXLF$=_=o|fvsU=08}a&%e% literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_insert_row_before.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/docs/images/table_insert_row_before.gif new file mode 100644 index 0000000000000000000000000000000000000000..c3271e54937cb8dbfb435ee8bc2d02157cff1448 GIT binary patch literal 928 zcmZ?wbhEHb6k!lyXlDQc1CNA&goc2OhJ=EKgo+6T6%!mP9uzc82Q3xphWMO7tP+`ykxe1gf7&vMfJUL`M zHY_;U%pt55lkwqTGaC=w17?0%i;Nu$1RC5Kcr9{H2skpjHgXtwL`-~0*X=}WE7QHI{4WtnErk^c$i_Har&nt0T0z!7V6jbF?3B; b3|uVFrNMjfN;AWXK;{oIr@tjQFjxZsoSk_C literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_content.css b/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_content.css new file mode 100644 index 00000000..45540f56 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_content.css @@ -0,0 +1,23 @@ +body { + background-color: #FFFFFF; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + scrollbar-3dlight-color: #F0F0EE; + scrollbar-arrow-color: #676662; + scrollbar-base-color: #F0F0EE; + scrollbar-darkshadow-color: #DDDDDD; + scrollbar-face-color: #E0E0DD; + scrollbar-highlight-color: #F0F0EE; + scrollbar-shadow-color: #F0F0EE; + scrollbar-track-color: #F5F5F5; +} + +td { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; +} + +pre { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; +} diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_popup.css b/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_popup.css new file mode 100644 index 00000000..be47f7fc --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_popup.css @@ -0,0 +1,117 @@ +body { + background-color: #F0F0EE; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; + scrollbar-3dlight-color: #F0F0EE; + scrollbar-arrow-color: #676662; + scrollbar-base-color: #F0F0EE; + scrollbar-darkshadow-color: #DDDDDD; + scrollbar-face-color: #E0E0DD; + scrollbar-highlight-color: #F0F0EE; + scrollbar-shadow-color: #F0F0EE; + scrollbar-track-color: #F5F5F5; +} + +td { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; +} + +input { + background: #FFFFFF; + border: 1px solid #cccccc; +} + +td, input, select, textarea { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; +} + +input, select, textarea { + border: 1px solid #808080; +} + +.input_noborder { + border: 0px solid #808080; +} + +#insert { + font-weight: bold; +} + +#cancel { + font-weight: bold; +} + +.title { + font-size: 12px; + font-weight: bold; +} + +table.charmap { + border-style: solid; + border-width: 1px; + border-color: #AAAAAA; +} + +td.charmap, td.charmapOver { + color: #000000; + border-color: #AAAAAA; + border-style: solid; + border-width: 1px; + text-align: center; + font-size: 12px; +} + +td.charmapOver { + background-color: #CCCCCC; + cursor: arrow; +} + +a.charmap { + color: #000000; + text-decoration: none +} + +.wordWrapCode { + vertical-align: middle; + border: 1px none #000000; + background-color: transparent; +} + +input.radio { + border: 1px none #000000; + background-color: transparent; + vertical-align: middle; +} + +input.checkbox { + border: 1px none #000000; + background-color: transparent; + vertical-align: middle; +} + +.mceButtonNormal, .mceButtonOver, .mceButtonDown, .mceSeparator, .mceButtonDisabled, .mceButtonSelected { + margin-left: 1px; +} + +.mceButtonNormal { + border-top: 1px solid; + border-left: 1px solid; + border-bottom: 1px solid; + border-right: 1px solid; + border-color: #F0F0EE; + cursor: arrow; +} + +.mceButtonOver { + border: 1px solid #0A246A; + cursor: arrow; + background-color: #B6BDD2; +} + +.mceButtonDown { + cursor: arrow; + border: 1px solid #0A246A; + background-color: #8592B5; +} diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_template.js b/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_template.js new file mode 100644 index 00000000..8026ff0a --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_template.js @@ -0,0 +1,23 @@ +/* Import theme specific language pack */ + tinyMCE.importThemeLanguagePack();var TinyMCE_advanced_autoImportCSSClasses=true;var TinyMCE_advanced_foreColor="#000000";var TinyMCE_advanced_anchorName="";var TinyMCE_advanced_buttons=[['bold','{$lang_bold_img}','{$lang_bold_desc}','Bold'],['italic','{$lang_italic_img}','{$lang_italic_desc}','Italic'],['underline','{$lang_underline_img}','{$lang_underline_desc}','Underline'],['strikethrough','strikethrough.gif','{$lang_striketrough_desc}','Strikethrough'],['justifyleft','left.gif','{$lang_justifyleft_desc}','JustifyLeft'],['justifycenter','center.gif','{$lang_justifycenter_desc}','JustifyCenter'],['justifyright','right.gif','{$lang_justifyright_desc}','JustifyRight'],['justifyfull','full.gif','{$lang_justifyfull_desc}','JustifyFull'],['bullist','bullist.gif','{$lang_bullist_desc}','InsertUnorderedList'],['numlist','numlist.gif','{$lang_numlist_desc}','InsertOrderedList'],['outdent','outdent.gif','{$lang_outdent_desc}','Outdent'],['indent','indent.gif','{$lang_indent_desc}','Indent'],['cut','cut.gif','{$lang_cut_desc}','Cut'],['copy','copy.gif','{$lang_copy_desc}','Copy'],['paste','paste.gif','{$lang_paste_desc}','Paste'],['undo','undo.gif','{$lang_undo_desc}','Undo'],['redo','redo.gif','{$lang_redo_desc}','Redo'],['link','link.gif','{$lang_link_desc}','mceLink',true],['unlink','unlink.gif','{$lang_unlink_desc}','unlink'],['image','image.gif','{$lang_image_desc}','mceImage',true],['cleanup','cleanup.gif','{$lang_cleanup_desc}','mceCleanup'],['help','help.gif','{$lang_help_desc}','mceHelp'],['code','code.gif','{$lang_theme_code_desc}','mceCodeEditor'],['hr','hr.gif','{$lang_theme_hr_desc}','inserthorizontalrule'],['removeformat','removeformat.gif','{$lang_theme_removeformat_desc}','removeformat'],['sub','sub.gif','{$lang_theme_sub_desc}','subscript'],['sup','sup.gif','{$lang_theme_sup_desc}','superscript'],['forecolor','forecolor.gif','{$lang_theme_forecolor_desc}','mceForeColor',true],['backcolor','backcolor.gif','{$lang_theme_backcolor_desc}','mceBackColor',true],['charmap','charmap.gif','{$lang_theme_charmap_desc}','mceCharMap'],['visualaid','visualaid.gif','{$lang_theme_visualaid_desc}','mceToggleVisualAid'],['anchor','anchor.gif','{$lang_theme_anchor_desc}','mceInsertAnchor']];function TinyMCE_advanced_getControlHTML(button_name){var buttonTileMap=new Array('anchor.gif','backcolor.gif','bullist.gif','center.gif','charmap.gif','cleanup.gif','code.gif','copy.gif','custom_1.gif','cut.gif','forecolor.gif','full.gif','help.gif','hr.gif','image.gif','indent.gif','left.gif','link.gif','numlist.gif','outdent.gif','paste.gif','redo.gif','removeformat.gif','right.gif','strikethrough.gif','sub.gif','sup.gif','undo.gif','unlink.gif','visualaid.gif');for(var i=0;i';}return '';}}switch(button_name){case "formatselect":var html='';return html;case "styleselect":return '';case "fontselect":return '';case "fontsizeselect":return '';case "|":case "separator":return '';case "spacer":return '';case "rowseparator":return '
';}return "";}function TinyMCE_advanced_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mceForeColor":var template=new Array();var inputColor=TinyMCE_advanced_foreColor;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=210;template['height']=200;tinyMCE.openWindow(template,{editor_id:editor_id,command:"forecolor",input_color:inputColor});return true;case "mceBackColor":var template=new Array();var inputColor=TinyMCE_advanced_foreColor;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=210;template['height']=200;tinyMCE.openWindow(template,{editor_id:editor_id,command:"HiliteColor",input_color:inputColor});return true;case "mceCodeEditor":var template=new Array();template['file']='source_editor.htm';template['width']=tinyMCE.getParam("theme_advanced_source_editor_width",500);template['height']=tinyMCE.getParam("theme_advanced_source_editor_height",400);tinyMCE.openWindow(template,{editor_id:editor_id,resizable:"yes",scrollbars:"no"});return true;case "mceCharMap":var template=new Array();template['file']='charmap.htm';template['width']=550;template['height']=280;tinyMCE.openWindow(template,{editor_id:editor_id});return true;case "mceInsertAnchor":var template=new Array();template['file']='anchor.htm';template['width']=320;template['height']=130;tinyMCE.openWindow(template,{editor_id:editor_id,name:TinyMCE_advanced_anchorName,action:(TinyMCE_advanced_anchorName==""?"insert":"update")});return true;}return false;}function TinyMCE_advanced_getEditorTemplate(settings){function removeFromArray(in_array,remove_array){var outArray=new Array();for(var i=0;i0){toolbarHTML+="
";deltaHeight-=23;}var buttonNamesRow2=tinyMCE.getParam("theme_advanced_buttons2","bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",true,',');buttonNamesRow2=removeFromArray(buttonNamesRow2,tinyMCE.getParam("theme_advanced_disable","",true,','));buttonNamesRow2=addToArray(buttonNamesRow2,tinyMCE.getParam("theme_advanced_buttons2_add","",true,','));buttonNamesRow2=addToArray(tinyMCE.getParam("theme_advanced_buttons2_add_before","",true,','),buttonNamesRow2);for(var i=0;i0){toolbarHTML+="
";deltaHeight-=23;}var buttonNamesRow3=tinyMCE.getParam("theme_advanced_buttons3","hr,removeformat,visualaid,separator,sub,sup,separator,charmap",true,',');buttonNamesRow3=removeFromArray(buttonNamesRow3,tinyMCE.getParam("theme_advanced_disable","",true,','));buttonNamesRow3=addToArray(buttonNamesRow3,tinyMCE.getParam("theme_advanced_buttons3_add","",true,','));buttonNamesRow3=addToArray(tinyMCE.getParam("theme_advanced_buttons3_add_before","",true,','),buttonNamesRow3);for(var i=0;i0)deltaHeight-=20;template['html']='';if(toolbarLocation=="top")template['html']+='';if(pathLocation=="top"){template['html']+='';deltaHeight-=23;}template['html']+='';if(toolbarLocation=="bottom")template['html']+='';if(pathLocation=="bottom"){template['html']+='';deltaHeight-=23;}template['html']+='
'+toolbarHTML+'
'+pathHTML+'
\ + \ +
'+toolbarHTML+'
'+pathHTML+'
';break;case "RowLayout":template['html']='';var containers=tinyMCE.getParam("theme_advanced_containers","",true,",");var defaultContainerCSS=tinyMCE.getParam("theme_advanced_containers_default_class","container");var defaultContainerAlign=tinyMCE.getParam("theme_advanced_containers_default_align","center");for(var i=0;i';}else if(containers[i]=="mceElementpath"){var pathClass="mcePath";if(i==containers.length-1)pathClass="mcePathBottom";else if(i==0)pathClass="mcePathTop";else deltaHeight-=2;template['html']+='';deltaHeight-=22;}else{var curContainer=tinyMCE.getParam("theme_advanced_container_"+containers[i],"",true,',');var curContainerHTML="";var curAlign=tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align",defaultContainerAlign);var curCSS=tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class",defaultContainerCSS);for(var j=0;j0){curContainerHTML+="
";deltaHeight-=23;}template['html']+='
';}}template['html']+='
\ + \ +
'+pathHTML+'
'+curContainerHTML+'
';break;case "BorderLayout":break;case "CustomLayout":var customLayout=tinyMCE.getParam("theme_advanced_custom_layout","");if(customLayout!=""&&eval("typeof("+customLayout+")")!="undefined")template=eval(customLayout+"(template);");break;default:alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!');break;}var styleSelectHTML='';if(settings['theme_advanced_styles']){var stylesAr=settings['theme_advanced_styles'].split(';');for(var i=0;i'+key+'';}TinyMCE_advanced_autoImportCSSClasses=false;}template['html']=tinyMCE.replaceVar(template['html'],'style_select_options',styleSelectHTML);template['delta_width']=0;template['delta_height']=deltaHeight;return template;}function TinyMCE_advanced_getInsertLinkTemplate(){var template=new Array();template['file']='link.htm';template['width']=320;template['height']=170;template['width']+=tinyMCE.getLang('lang_insert_link_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_link_delta_height',0);return template;}function TinyMCE_advanced_getInsertImageTemplate(){var template=new Array();template['file']='image.htm?src={$src}';template['width']=340;template['height']=280;template['width']+=tinyMCE.getLang('lang_insert_image_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_image_delta_height',0);return template;}function TinyMCE_advanced_handleNodeChange(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){function selectByValue(select_elm,value){if(select_elm){for(var i=0;i=0;i--){var nodeName=path[i].nodeName.toLowerCase();var nodeData="";if(nodeName=="b")nodeName="strong";if(nodeName=="i")nodeName="em";if(getAttrib(path[i],'id')!="")nodeData+="id: "+path[i].getAttribute('id')+" ";if(getAttrib(path[i],'class')!="")nodeData+="class: "+path[i].getAttribute('class')+" ";if(getAttrib(path[i],'className')!="")nodeData+="class: "+path[i].getAttribute('className')+" ";if(getAttrib(path[i],'src')!="")nodeData+="src: "+path[i].getAttribute('src')+" ";if(getAttrib(path[i],'href')!="")nodeData+="href: "+path[i].getAttribute('href')+" ";if(nodeName=="img"&&getAttrib(path[i],'name')=="mce_plugin_flash"){nodeName="flash";nodeData="";}if(tinyMCE.isMSIE)html+=''+nodeName+'';else html+=''+nodeName+'';if(i>0)html+=" » ";}pathElm.innerHTML=html+" ";}var colorElm=tinyMCE.getParentElement(node,"font","color");if(colorElm)TinyMCE_advanced_foreColor=""+colorElm.color.toUpperCase();tinyMCE.switchClassSticky(editor_id+'_justifyleft','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyright','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyfull','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bold','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_italic','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_underline','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_strikethrough','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bullist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_numlist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sub','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sup','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_link','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_unlink','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_image','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_hr','mceButtonNormal');var anchorName=tinyMCE.getParentElement(node,"a","name");TinyMCE_advanced_anchorName="";if(anchorName){TinyMCE_advanced_anchorName=anchorName.getAttribute("name");tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonSelected');}var anchorLink=tinyMCE.getParentElement(node,"a","href");if(anchorLink||any_selection){tinyMCE.switchClassSticky(editor_id+'_link',anchorLink?'mceButtonSelected':'mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_unlink',anchorLink?'mceButtonSelected':'mceButtonNormal',false);}tinyMCE.switchClassSticky(editor_id+'_visualaid',visual_aid?'mceButtonSelected':'mceButtonNormal',false);if(undo_levels!=-1){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonDisabled',true);}if(tinyMCE.getParentElement(node,"li,blockquote"))tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonNormal',false);if(undo_index!=-1&&(undo_index0))tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonNormal',false);if(undo_index!=-1&&(undo_index>0&&undo_levels>0))tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonNormal',false);var selectElm=document.getElementById(editor_id+"_styleSelect");if(selectElm){TinyMCE_advanced_setupCSSClasses(editor_id);classNode=node;breakOut=false;var index=0;do{if(classNode&&classNode.className){for(var i=0;i");}else selectByValue(selectElm,"

");}var selectElm=document.getElementById(editor_id+"_fontNameSelect");if(selectElm){var elm=tinyMCE.getParentElement(node,"font","face");if(elm)selectByValue(selectElm,elm.getAttribute("face"));else selectByValue(selectElm,"");}var selectElm=document.getElementById(editor_id+"_fontSizeSelect");if(selectElm){var elm=tinyMCE.getParentElement(node,"font","size");if(elm&&getAttrib(elm,"size")!="")selectByValue(selectElm,elm.getAttribute("size"));else selectByValue(selectElm,"0");}alignNode=node;breakOut=false;do{if(!alignNode.getAttribute||!alignNode.getAttribute('align'))continue;switch(alignNode.getAttribute('align').toLowerCase()){case "left":tinyMCE.switchClassSticky(editor_id+'_justifyleft','mceButtonSelected');breakOut=true;break;case "right":tinyMCE.switchClassSticky(editor_id+'_justifyright','mceButtonSelected');breakOut=true;break;case "middle":case "center":tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonSelected');breakOut=true;break;case "justify":tinyMCE.switchClassSticky(editor_id+'_justifyfull','mceButtonSelected');breakOut=true;break;}}while(!breakOut&&(alignNode=alignNode.parentNode));do{switch(node.nodeName.toLowerCase()){case "b":case "strong":tinyMCE.switchClassSticky(editor_id+'_bold','mceButtonSelected');break;case "i":case "em":tinyMCE.switchClassSticky(editor_id+'_italic','mceButtonSelected');break;case "u":tinyMCE.switchClassSticky(editor_id+'_underline','mceButtonSelected');break;case "strike":tinyMCE.switchClassSticky(editor_id+'_strikethrough','mceButtonSelected');break;case "ul":tinyMCE.switchClassSticky(editor_id+'_bullist','mceButtonSelected');break;case "ol":tinyMCE.switchClassSticky(editor_id+'_numlist','mceButtonSelected');break;case "sub":tinyMCE.switchClassSticky(editor_id+'_sub','mceButtonSelected');break;case "sup":tinyMCE.switchClassSticky(editor_id+'_sup','mceButtonSelected');break;case "hr":tinyMCE.switchClassSticky(editor_id+'_hr','mceButtonSelected');break;case "img":if(getAttrib(node,'name').indexOf('mce_')!=0)tinyMCE.switchClassSticky(editor_id+'_image','mceButtonSelected');break;}}while((node=node.parentNode));}function TinyMCE_advanced_setupCSSClasses(editor_id){if(!TinyMCE_advanced_autoImportCSSClasses)return;var selectElm=document.getElementById(editor_id+'_styleSelect');if(selectElm&&selectElm.getAttribute('cssImported')!='true'){var csses=tinyMCE.getCSSClasses(editor_id);if(csses&&selectElm){for(var i=0;i0)selectElm.setAttribute('cssImported','true');}} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_template_src.js b/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_template_src.js new file mode 100644 index 00000000..c9a66b2e --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_template_src.js @@ -0,0 +1,738 @@ +/* Import theme specific language pack */ +tinyMCE.importThemeLanguagePack(); + +// Variable declarations +var TinyMCE_advanced_autoImportCSSClasses = true; +var TinyMCE_advanced_foreColor = "#000000"; +var TinyMCE_advanced_anchorName = ""; +var TinyMCE_advanced_buttons = [ + // Control id, button img, button title, command, user_interface, value + ['bold', '{$lang_bold_img}', '{$lang_bold_desc}', 'Bold'], + ['italic', '{$lang_italic_img}', '{$lang_italic_desc}', 'Italic'], + ['underline', '{$lang_underline_img}', '{$lang_underline_desc}', 'Underline'], + ['strikethrough', 'strikethrough.gif', '{$lang_striketrough_desc}', 'Strikethrough'], + ['justifyleft', 'left.gif', '{$lang_justifyleft_desc}', 'JustifyLeft'], + ['justifycenter', 'center.gif', '{$lang_justifycenter_desc}', 'JustifyCenter'], + ['justifyright', 'right.gif', '{$lang_justifyright_desc}', 'JustifyRight'], + ['justifyfull', 'full.gif', '{$lang_justifyfull_desc}', 'JustifyFull'], + ['bullist', 'bullist.gif', '{$lang_bullist_desc}', 'InsertUnorderedList'], + ['numlist', 'numlist.gif', '{$lang_numlist_desc}', 'InsertOrderedList'], + ['outdent', 'outdent.gif', '{$lang_outdent_desc}', 'Outdent'], + ['indent', 'indent.gif', '{$lang_indent_desc}', 'Indent'], + ['cut', 'cut.gif', '{$lang_cut_desc}', 'Cut'], + ['copy', 'copy.gif', '{$lang_copy_desc}', 'Copy'], + ['paste', 'paste.gif', '{$lang_paste_desc}', 'Paste'], + ['undo', 'undo.gif', '{$lang_undo_desc}', 'Undo'], + ['redo', 'redo.gif', '{$lang_redo_desc}', 'Redo'], + ['link', 'link.gif', '{$lang_link_desc}', 'mceLink', true], + ['unlink', 'unlink.gif', '{$lang_unlink_desc}', 'unlink'], + ['image', 'image.gif', '{$lang_image_desc}', 'mceImage', true], + ['cleanup', 'cleanup.gif', '{$lang_cleanup_desc}', 'mceCleanup'], + ['help', 'help.gif', '{$lang_help_desc}', 'mceHelp'], + ['code', 'code.gif', '{$lang_theme_code_desc}', 'mceCodeEditor'], + ['hr', 'hr.gif', '{$lang_theme_hr_desc}', 'inserthorizontalrule'], + ['removeformat', 'removeformat.gif', '{$lang_theme_removeformat_desc}', 'removeformat'], + ['sub', 'sub.gif', '{$lang_theme_sub_desc}', 'subscript'], + ['sup', 'sup.gif', '{$lang_theme_sup_desc}', 'superscript'], + ['forecolor', 'forecolor.gif', '{$lang_theme_forecolor_desc}', 'mceForeColor', true], + ['backcolor', 'backcolor.gif', '{$lang_theme_backcolor_desc}', 'mceBackColor', true], + ['charmap', 'charmap.gif', '{$lang_theme_charmap_desc}', 'mceCharMap'], + ['visualaid', 'visualaid.gif', '{$lang_theme_visualaid_desc}', 'mceToggleVisualAid'], + ['anchor', 'anchor.gif', '{$lang_theme_anchor_desc}', 'mceInsertAnchor'] + ]; + + +/** + * Returns HTML code for the specificed control. + */ +function TinyMCE_advanced_getControlHTML(button_name) { + var buttonTileMap = new Array('anchor.gif','backcolor.gif','bullist.gif','center.gif','charmap.gif','cleanup.gif','code.gif','copy.gif','custom_1.gif','cut.gif','forecolor.gif','full.gif','help.gif','hr.gif','image.gif','indent.gif','left.gif','link.gif','numlist.gif','outdent.gif','paste.gif','redo.gif','removeformat.gif','right.gif','strikethrough.gif','sub.gif','sup.gif','undo.gif','unlink.gif','visualaid.gif'); + + // Lookup button in button list + for (var i=0; i'; + } + + // Old style + return ''; + } + } + + // Custom controlls other than buttons + switch (button_name) { + case "formatselect": + var html = ''; + + return html; + + + case "styleselect": + return ''; + + case "fontselect": + return ''; + + case "fontsizeselect": + return ''; + + case "|": + case "separator": + return ''; + + case "spacer": + return ''; + + case "rowseparator": + return '
'; + } + + return ""; +} + +/** + * Theme specific exec command handeling. + */ +function TinyMCE_advanced_execCommand(editor_id, element, command, user_interface, value) { + switch (command) { + case "mceForeColor": + var template = new Array(); + var inputColor = TinyMCE_advanced_foreColor; + + if (!inputColor) + inputColor = "#000000"; + + template['file'] = 'color_picker.htm'; + template['width'] = 210; + template['height'] = 200; + + tinyMCE.openWindow(template, {editor_id : editor_id, command : "forecolor", input_color : inputColor}); + return true; + + case "mceBackColor": + var template = new Array(); + var inputColor = TinyMCE_advanced_foreColor; + + if (!inputColor) + inputColor = "#000000"; + + template['file'] = 'color_picker.htm'; + template['width'] = 210; + template['height'] = 200; + + tinyMCE.openWindow(template, {editor_id : editor_id, command : "HiliteColor", input_color : inputColor}); + return true; + + case "mceCodeEditor": + var template = new Array(); + + template['file'] = 'source_editor.htm'; + template['width'] = tinyMCE.getParam("theme_advanced_source_editor_width", 500); + template['height'] = tinyMCE.getParam("theme_advanced_source_editor_height", 400); + + tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no"}); + return true; + + case "mceCharMap": + var template = new Array(); + + template['file'] = 'charmap.htm'; + template['width'] = 550; + template['height'] = 280; + + tinyMCE.openWindow(template, {editor_id : editor_id}); + return true; + + case "mceInsertAnchor": + var template = new Array(); + + template['file'] = 'anchor.htm'; + template['width'] = 320; + template['height'] = 130; + + tinyMCE.openWindow(template, {editor_id : editor_id, name : TinyMCE_advanced_anchorName, action : (TinyMCE_advanced_anchorName == "" ? "insert" : "update")}); + return true; + } + + // Default behavior + return false; +} + +/** + * Editor instance template function. + */ +function TinyMCE_advanced_getEditorTemplate(settings) { + function removeFromArray(in_array, remove_array) { + var outArray = new Array(); + for (var i=0; i + //########################################################################################################### + + var pathHTML = '{$lang_theme_path}:  '; + var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout"); + + switch(layoutManager) { + case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)... + var toolbarHTML = ""; + var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom"); + var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center"); + var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none"); + + // Render row 1 + var buttonNamesRow1 = tinyMCE.getParam("theme_advanced_buttons1", "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect", true, ','); + buttonNamesRow1 = removeFromArray(buttonNamesRow1, tinyMCE.getParam("theme_advanced_disable", "", true, ',')); + buttonNamesRow1 = addToArray(buttonNamesRow1, tinyMCE.getParam("theme_advanced_buttons1_add", "", true, ',')); + buttonNamesRow1 = addToArray(tinyMCE.getParam("theme_advanced_buttons1_add_before", "", true, ','), buttonNamesRow1); + for (var i=0; i 0) { + toolbarHTML += "
"; + deltaHeight -= 23; + } + + // Render row 2 + var buttonNamesRow2 = tinyMCE.getParam("theme_advanced_buttons2", "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code", true, ','); + buttonNamesRow2 = removeFromArray(buttonNamesRow2, tinyMCE.getParam("theme_advanced_disable", "", true, ',')); + buttonNamesRow2 = addToArray(buttonNamesRow2, tinyMCE.getParam("theme_advanced_buttons2_add", "", true, ',')); + buttonNamesRow2 = addToArray(tinyMCE.getParam("theme_advanced_buttons2_add_before", "", true, ','), buttonNamesRow2); + for (var i=0; i 0) { + toolbarHTML += "
"; + deltaHeight -= 23; + } + + // Render row 3 + var buttonNamesRow3 = tinyMCE.getParam("theme_advanced_buttons3", "hr,removeformat,visualaid,separator,sub,sup,separator,charmap", true, ','); + buttonNamesRow3 = removeFromArray(buttonNamesRow3, tinyMCE.getParam("theme_advanced_disable", "", true, ',')); + buttonNamesRow3 = addToArray(buttonNamesRow3, tinyMCE.getParam("theme_advanced_buttons3_add", "", true, ',')); + buttonNamesRow3 = addToArray(tinyMCE.getParam("theme_advanced_buttons3_add_before", "", true, ','), buttonNamesRow3); + for (var i=0; i 0) + deltaHeight -= 20; + + // Setup template html + template['html'] = ''; + + if (toolbarLocation == "top") + template['html'] += ''; + + if (pathLocation == "top") { + template['html'] += ''; + deltaHeight -= 23; + } + + /* template['html'] += '';*/ + template['html'] += ''; + + if (toolbarLocation == "bottom") + template['html'] += ''; + + if (pathLocation == "bottom") { + template['html'] += ''; + deltaHeight -= 23; + } + + template['html'] += '
' + toolbarHTML + '
' + pathHTML + '
\ + \ +
\ + \ +
' + toolbarHTML + '
' + pathHTML + '
'; + break; + + case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom. + template['html'] = ''; + + var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ","); + var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container"); + var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center"); + + //Render Containers: + for(var i = 0; i < containers.length; i++) + { + if(containers[i] == "mceEditor") //Exceptions for mceEditor and ... + { + template['html'] += ''; + } + else if(containers[i] == "mceElementpath") // ... mceElementpath: + { + var pathClass = "mcePath"; + + if (i == containers.length-1) + pathClass = "mcePathBottom"; + else if (i == 0) + pathClass = "mcePathTop"; + else + deltaHeight-=2; + + template['html'] += ''; + deltaHeight -= 22; + } + else //Render normal Container: + { + var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ','); + var curContainerHTML = ""; + var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign); + var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS); + + for (var j=0; j 0) { + curContainerHTML += "
"; + deltaHeight -= 23; + } + + template['html'] += '
'; + } + } + + template['html'] += '
\ + \ +
' + pathHTML + '
' + curContainerHTML + '
'; + break; + case "BorderLayout" : //will be like java.awt.BorderLayout of SUN Java... + // Not implemented yet... + break; + case "CustomLayout" : //User defined layout callback... + var customLayout = tinyMCE.getParam("theme_advanced_custom_layout",""); + if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") + template = eval(customLayout + "(template);"); + break; + default: + alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!'); + break; + } + + //########################################################################################################### + // + //########################################################################################################### + + // Setup style select options + var styleSelectHTML = ''; + if (settings['theme_advanced_styles']) { + var stylesAr = settings['theme_advanced_styles'].split(';'); + for (var i=0; i' + key + ''; + } + + TinyMCE_advanced_autoImportCSSClasses = false; + } + + template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML); + template['delta_width'] = 0; + template['delta_height'] = deltaHeight; + + return template; +} + +/** + * Insert link template function. + */ +function TinyMCE_advanced_getInsertLinkTemplate() { + var template = new Array(); + + template['file'] = 'link.htm'; + template['width'] = 320; + template['height'] = 170; + + // Language specific width and height addons + template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0); + template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0); + + return template; +} + +/** + * Insert image template function. + */ +function TinyMCE_advanced_getInsertImageTemplate() { + var template = new Array(); + + template['file'] = 'image.htm?src={$src}'; + template['width'] = 340; + template['height'] = 280; + + // Language specific width and height addons + template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0); + template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0); + + return template; +} + +/** + * Node change handler. + */ +function TinyMCE_advanced_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { + function selectByValue(select_elm, value) { + if (select_elm) { + for (var i=0; i=0; i--) { + var nodeName = path[i].nodeName.toLowerCase(); + var nodeData = ""; + + if (nodeName == "b") + nodeName = "strong"; + + if (nodeName == "i") + nodeName = "em"; + + if (getAttrib(path[i], 'id') != "") + nodeData += "id: " + path[i].getAttribute('id') + " "; + + if (getAttrib(path[i], 'class') != "") + nodeData += "class: " + path[i].getAttribute('class') + " "; + + if (getAttrib(path[i], 'className') != "") + nodeData += "class: " + path[i].getAttribute('className') + " "; + + if (getAttrib(path[i], 'src') != "") + nodeData += "src: " + path[i].getAttribute('src') + " "; + + if (getAttrib(path[i], 'href') != "") + nodeData += "href: " + path[i].getAttribute('href') + " "; + + if (nodeName == "img" && getAttrib(path[i], 'name') == "mce_plugin_flash") { + nodeName = "flash"; + nodeData = ""; + } + + if (tinyMCE.isMSIE) + html += '' + nodeName + ''; + else + html += '' + nodeName + ''; + + if (i > 0) + html += " » "; + } + + pathElm.innerHTML = html + " "; + } + + // Get element color + var colorElm = tinyMCE.getParentElement(node, "font", "color"); + if (colorElm) + TinyMCE_advanced_foreColor = "" + colorElm.color.toUpperCase(); + + // Reset old states + tinyMCE.switchClassSticky(editor_id + '_justifyleft', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_justifyright', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_justifycenter', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_justifyfull', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_bold', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_italic', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_underline', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_strikethrough', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_bullist', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_numlist', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_sub', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_sup', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_anchor', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_link', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_unlink', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_outdent', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_image', 'mceButtonNormal'); + tinyMCE.switchClassSticky(editor_id + '_hr', 'mceButtonNormal'); + + // Get anchor name + var anchorName = tinyMCE.getParentElement(node, "a", "name"); + TinyMCE_advanced_anchorName = ""; + if (anchorName) { + TinyMCE_advanced_anchorName = anchorName.getAttribute("name"); + tinyMCE.switchClassSticky(editor_id + '_anchor', 'mceButtonSelected'); + } + + // Get link + var anchorLink = tinyMCE.getParentElement(node, "a", "href"); + if (anchorLink || any_selection) { + tinyMCE.switchClassSticky(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal', false); + tinyMCE.switchClassSticky(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal', false); + } + + // Handle visual aid + tinyMCE.switchClassSticky(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal', false); + + if (undo_levels != -1) { + tinyMCE.switchClassSticky(editor_id + '_undo', 'mceButtonDisabled', true); + tinyMCE.switchClassSticky(editor_id + '_redo', 'mceButtonDisabled', true); + } + + // Within li, blockquote + if (tinyMCE.getParentElement(node, "li,blockquote")) + tinyMCE.switchClassSticky(editor_id + '_outdent', 'mceButtonNormal', false); + + // Has redo levels + if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0)) + tinyMCE.switchClassSticky(editor_id + '_redo', 'mceButtonNormal', false); + + // Has undo levels + if (undo_index != -1 && (undo_index > 0 && undo_levels > 0)) + tinyMCE.switchClassSticky(editor_id + '_undo', 'mceButtonNormal', false); + + // Select class in select box + var selectElm = document.getElementById(editor_id + "_styleSelect"); + if (selectElm) { + TinyMCE_advanced_setupCSSClasses(editor_id); + + classNode = node; + breakOut = false; + var index = 0; + + do { + if (classNode && classNode.className) { + for (var i=0; i"); + } else + selectByValue(selectElm, "

"); + } + + // Select fontselect + var selectElm = document.getElementById(editor_id + "_fontNameSelect"); + if (selectElm) { + var elm = tinyMCE.getParentElement(node, "font", "face"); + if (elm) + selectByValue(selectElm, elm.getAttribute("face")); + else + selectByValue(selectElm, ""); + } + + // Select fontsize + var selectElm = document.getElementById(editor_id + "_fontSizeSelect"); + if (selectElm) { + var elm = tinyMCE.getParentElement(node, "font", "size"); + if (elm && getAttrib(elm, "size") != "") + selectByValue(selectElm, elm.getAttribute("size")); + else + selectByValue(selectElm, "0"); + } + + // Handle align attributes + alignNode = node; + breakOut = false; + do { + if (!alignNode.getAttribute || !alignNode.getAttribute('align')) + continue; + + switch (alignNode.getAttribute('align').toLowerCase()) { + case "left": + tinyMCE.switchClassSticky(editor_id + '_justifyleft', 'mceButtonSelected'); + breakOut = true; + break; + + case "right": + tinyMCE.switchClassSticky(editor_id + '_justifyright', 'mceButtonSelected'); + breakOut = true; + break; + + case "middle": + case "center": + tinyMCE.switchClassSticky(editor_id + '_justifycenter', 'mceButtonSelected'); + breakOut = true; + break; + + case "justify": + tinyMCE.switchClassSticky(editor_id + '_justifyfull', 'mceButtonSelected'); + breakOut = true; + break; + } + } while (!breakOut && (alignNode = alignNode.parentNode)); + + // Handle elements + do { + switch (node.nodeName.toLowerCase()) { + case "b": + case "strong": + tinyMCE.switchClassSticky(editor_id + '_bold', 'mceButtonSelected'); + break; + + case "i": + case "em": + tinyMCE.switchClassSticky(editor_id + '_italic', 'mceButtonSelected'); + break; + + case "u": + tinyMCE.switchClassSticky(editor_id + '_underline', 'mceButtonSelected'); + break; + + case "strike": + tinyMCE.switchClassSticky(editor_id + '_strikethrough', 'mceButtonSelected'); + break; + + case "ul": + tinyMCE.switchClassSticky(editor_id + '_bullist', 'mceButtonSelected'); + break; + + case "ol": + tinyMCE.switchClassSticky(editor_id + '_numlist', 'mceButtonSelected'); + break; + + case "sub": + tinyMCE.switchClassSticky(editor_id + '_sub', 'mceButtonSelected'); + break; + + case "sup": + tinyMCE.switchClassSticky(editor_id + '_sup', 'mceButtonSelected'); + break; + + case "hr": + tinyMCE.switchClassSticky(editor_id + '_hr', 'mceButtonSelected'); + break; + + case "img": + if (getAttrib(node, 'name').indexOf('mce_') != 0) + tinyMCE.switchClassSticky(editor_id + '_image', 'mceButtonSelected'); + break; + } + } while ((node = node.parentNode)); +} + +// This function auto imports CSS classes into the class selection droplist +function TinyMCE_advanced_setupCSSClasses(editor_id) { + if (!TinyMCE_advanced_autoImportCSSClasses) + return; + + var selectElm = document.getElementById(editor_id + '_styleSelect'); + + if (selectElm && selectElm.getAttribute('cssImported') != 'true') { + var csses = tinyMCE.getCSSClasses(editor_id); + if (csses && selectElm) { + for (var i=0; i 0) + selectElm.setAttribute('cssImported', 'true'); + } +} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_ui.css b/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_ui.css new file mode 100644 index 00000000..18fbc4ad --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/editor_ui.css @@ -0,0 +1,147 @@ +.mceButtonNormal, .mceButtonOver, .mceButtonDown, .mceSeparator, .mceButtonDisabled, .mceButtonSelected { + margin-top: 1px; + margin-left: 1px; +} + +.mceButtonNormal { + border-top: 1px solid; + border-left: 1px solid; + border-bottom: 1px solid; + border-right: 1px solid; + border-color: #F0F0EE; + cursor: arrow; +} + +.mceButtonOver { +/* border-top: 1px solid buttonhighlight; + border-left: 1px solid buttonhighlight; + border-bottom: 1px solid buttonshadow; + border-right: 1px solid buttonshadow;*/ + border: 1px solid #0A246A; + cursor: arrow; + background-color: #B6BDD2; +} + +.mceButtonDown { +/* border-bottom: 1px solid buttonhighlight; + border-right: 1px solid buttonhighlight; + border-top: 1px solid buttonshadow; + border-left: 1px solid buttonshadow;*/ + cursor: arrow; + border: 1px solid #0A246A; + background-color: #8592B5; +} + +.mceButtonSelected { + border: 1px solid; + border-color: #C0C0BB; + cursor: arrow; +} + +.mceButtonDisabled { + filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); + -moz-opacity:0.3; + opacity: 0.3; + border-top: 1px solid; + border-left: 1px solid; + border-bottom: 1px solid; + border-right: 1px solid; + border-color: #F0F0EE; + cursor: arrow; +} + +.mceSeparator { + border-top: 1px solid buttonhighlight; + border-left: 1px solid buttonhighlight; + border-bottom: 1px solid buttonshadow; + border-right: 1px solid buttonshadow; + margin-right: 2px; + margin-left: 2px; +} + +.mceSeparatorLine { + margin:2px; + margin-left: 4px; + background-color: #F0F0EE; + border-top: 1px solid buttonshadow; + border-left: 1px solid buttonshadow; + border-bottom: 1px solid buttonhighlight; + border-right: 1px solid buttonhighlight; + width: 0px; + height: 15px; +} + +.mceSelectList { + font-family: "MS Sans Serif"; + font-size: 7pt; + font-weight: normal; + margin-top: 3px; + padding: 0px; + display: inline; + vertical-align: top; + background-color: #F0F0EE +} + +.mceLabel, .mceLabelDisabled { + font-family: "MS Sans Serif"; + font-size: 9pt; +} + +.mceLabel { + color: #000000; +} + +.mceLabelDisabled { + cursor: text; + color: #999999; +} + +.mceEditor { + background: #F0F0EE; + border: 1px solid #cccccc; +} + +.mceEditorArea { + font-family: "MS Sans Serif"; + background: #FFFFFF; +} + +.mceToolbarTop, .mceToolbarBottom { + background: #F0F0EE; +} + +.mceToolbarTop { + border-bottom: 1px solid #cccccc; +} + +.mceToolbarBottom { + border-top: 1px solid #cccccc; +} + +.mcePathTop, .mcePathBottom, .mcePath { + font-family: "MS Sans Serif"; + font-size: 9pt; + padding: 2px; +} + +.mcePathTop { + border-bottom: 1px solid #cccccc; +} + +.mcePathBottom { + border-top: 1px solid #cccccc; +} + +.mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover { + text-decoration: none; + font-family: "MS Sans Serif"; + font-size: 9pt; +} + +.mcePathItem:hover { + text-decoration: underline; +} + +.mcePath { + border-bottom: 1px solid #cccccc; +} \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/image.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/image.htm new file mode 100644 index 00000000..b0064fc0 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/image.htm @@ -0,0 +1,175 @@ + + +{$lang_insert_image_title} + + + + + +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{$lang_insert_image_title}
{$lang_insert_image_src}: + + + + +
{$lang_insert_image_alt}:
{$lang_insert_image_align}:
{$lang_insert_image_dimensions}: + x +
{$lang_insert_image_border}:
{$lang_insert_image_vspace}:
{$lang_insert_image_hspace}:
+
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/anchor.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/anchor.gif new file mode 100644 index 0000000000000000000000000000000000000000..ae7b2f39599479d0f43adc553d39059498a1d4e4 GIT binary patch literal 943 zcmZ?wbhEHb6k!lyXlDQc1%m_yiv$CQ0t1f%E6+0LfHME6S_6*;g8(3!;1JN@5YgZn zF~u`sN_1*#OipV+!i2c2i2)f4BJvjp6f8(6*pN^GL8y84Ai13>-ZS#T+so8x|aF<`CA3u_$0>ljPwnvS@U6Jklth){;;VxS)$e(8XYn zV}VmkhYCkngu@1wL%eEiQ62^YM_F3L^)?7(Fg6~L5|5DEvVlq2w^5T#;Y>oJ3y-vT z&9(~<7BCzV=hce&;gHzC!p_1{;=#ep#K^?VvP6`jX<;`z8ZA%I|HcV(pSTLht!HR$l8v+g-0HT5i4+1q&J)W*nF~^UQ<= z2NrC&u;Ijp3pW}LoLF$-#DWhG8vcLSaOTXJ0~a0~xbWe_j|1=DzyJULKiCPQ#ApZ% zOb96cWMO7t&}Ps9Sr5t+3>-ZS;T$p^8x|aF<`CA3IkDlP6OVu*S4W4VqAQQEGS{66 z4;>vjnOHmyNEAKk;^ng`NO1VjL zCpIi}W)M(z%8>|6INB<%uXV;kaPg5oImQTd02Z Z;=Q4=W(@*2r{2+6_Ky4bCm(SJYXFy%8g2jp literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bold_fr.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bold_fr.gif new file mode 100644 index 0000000000000000000000000000000000000000..7782282838436ab0e31947ec16760295fa0bd6c0 GIT binary patch literal 78 zcmZ?wbhEHb6k!lyXkcJCaNqy~1B2pE7Dgb&paUX6G7e0tE&VGca(SoE5w@yYb2R2y dd8Oiq(r2B^mWS!(e$R~f*|oLnxd$VIH2@Wf8BPEI literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bold_ru.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bold_ru.gif new file mode 100644 index 0000000000000000000000000000000000000000..c9e89b27e548815114e78462553c6e0016aeddc0 GIT binary patch literal 77 zcmZ?wbhEHb6k!lyXkcXU_4U1dV4AuZOG#Ksx literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/browse.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/browse.gif new file mode 100644 index 0000000000000000000000000000000000000000..590f2de43f0db8d6ff7d0be42228f9266b29da8d GIT binary patch literal 113 zcmZ?wbhEHb6k!lzn8?g9o0C(|rRYBxDE?$&WME)s&|v@qkURsE)13a5r=|E8^Js8b zKVG{toUv_@hwL;4h9s}Lj8*&Ir1h0WNImEIwB=qiYx>TEFU_>xB^?a&6>B~^#bfrS N$(b43?=Ue~0{~lFDy9Gc literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bullist.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/bullist.gif new file mode 100644 index 0000000000000000000000000000000000000000..12d0ec2299b415c1f1f8caeccbe6d36469314ebe GIT binary patch literal 883 zcmZ?wbhEHb6k!lyXlDQc1%mKc{sH9)295v*MGhH{4GRu7a|mn2 zoY?SynVDZo$Rxm_!GS@-ILYRPg9B5ig0oRh!h%MRE-}T7D-{zO8CaB(Ps!{^IKVWK XnS*7=j-thmtc-kTWV}ie9T=w=+z9vr{Fg?fNvHrcfCg`h z7dMDi<0|!xTC=2)v`Pl#LraUAm1PZ+Ar=%qA$#$qPe!Y*4FCX3Bi(IQJrwS`LkM6cV~Fpt`6s*Hav+Lba>c*PfgWLMYB|G8z|y8sAYp|f~#$}?~gRL zD1;4Car+CYT(z>Q!AGme8LP>~6VyXxu^CNKM+Ntve!Bn5==+&9d&aWeUKxSRcHJ%7 zaZF0*Ye-bqfr8Jp6xqr0dHQ)-cHLt1sTzKRO5CT3O=4fW{X%dV;U1(m$g zy1LsB`uY|4AH>$dSGT2%lOp(d5Bjbg746(0{esGOZvpK@^{L{nxXkJ#wpjG@C!Vmk zS@!hCe=*+ibGL3(HzA_NCBE4&wI`+e^Zu;1bJvHic6^GA&l0w) z64Eb}-+tck_+3ZehvCVU;n&mM{UbMO@4S5d9!0&oyX-TG#yVI$c);vnIU#_*TmkS+DY`{28xtXz=BG>l1^{sq*vUPbWDyN^3i6CA~7`zdW`dT%s{`>3N{6EWw zI5*lSH7zgI!=q!ucIm%wsWlpDXXn3r0TqB)F5Yk$aCLL3957Z*Gc_7ODy6B_OgtWv zN}25cA=kc1Z;FDH{k)}5x1P(Z)f2qm$8!6cBV}!D^|R1F29B#n?<)Gc)DO&PRMI70 z;&3@qe3M^&HGgcV?@@DQ#<9@vT&#~ol9L%niVF*bH>y5NPTXp^+2FE)1puq7tINyF zYPDLSP&73)K@jxs`GjR8>|X+a(|;2FGXa4ANd z(9|vIt-QIW_afe(XBpg5+gEBIbt|T?rS4g|^KxBIaBKbZ+;3lv!#6!kK@tsbz97gmH^<5x4y_u;i9F7Ey=v*1ji@Y0vy5TTkRPsj)>0eg z@oBZ*me{ z>YIQ5qxbev+QN{_h${lqz<;(5quG3Ty5G+`TD-Glfmy%85l%KmWA{sVMR?Em zuFoN-biO;%Ff%-R%&9ie%nLkX5p-fELS}4{%#@kk9ErE~mrspc+;DZbnq^$2MUMw0 z;!cC$gNjbY4uwJ%aQy2O4!{6cCPVEXBpNAfo|Hj5ap6c&fc=$^o!A3C!Rw0w+F0ut zh4-yBCiLhMNqGsiyRVM?XWIJdv{~lDz_t&S3m5!|beEoM6klVk5sw1PJ!Bx8)7$A$qs$IXSwnnIb4>%raU?-b;?mrEFEvJ9kbHkUXL>nFiS; zFiA4MzZRn|!v9ukKCrlZ($cY;^6tl@@s7MS>IS!`lL5QX!Q`;*01}V_fPDz{;(ewBMV*p%-{fL?o!!ndE z=0xgq_cuTIq>pN127^to;FTeTzGb&u&&>YFUhi*~^a9wzQiLN#Z*5p*m8L1}{q;vp z7nS0G)R55F6op{{NR-UgcU$*F@+M;#yPaGB8UjE7PC6{7mgF#jO8#JjY{o7e$ zE`_qwaKX$+34{JobL{AZ*e44;_C@op@3nT}9lhYTj6vQW%L%X|r+f1)n%17Jx9|j} zxjC4FWQTQ;FSX>2)JNFUqG6EDW3Gf82nBHo@c2jBTKbXtr?@p1ua$w`nwf};(MBxz zJo_4XGDACiN_LX=)`G%_BO)1OQvqF8kRxP2^R=~j#h`AQh6+h?9!ckFNM;VK1&4c`|+qSd}oNkq^Z@iUC~~u z%%FoAVDgTy<+von?VH&bSg%C5`5KnA5x{NTi+U*yA1;Z12-<2mlEHi? z@RitQnIM2=9lu`hf$6Nc!AkPX;1fpo3&O|L*d40!ot&-k_#KRBJaV4nx;TM%Xqeg% z>ZbExISwOo0`I~3aGaS+rvM&coJ8h&bTjcupoknV)v&XZ@p>r1>ygOlO(&6boBgcr z@3i7g&llUGZB$Z<$6)qu<8F)J!0Ny@S@9Vq0-6_+DNJ&toe!3`t89||IyiUJooeg} z(ue_3hTP(SEQ-sbV$1L$TlM{e3aWp%1(>=q_EE$lkc|5}9%R2djq;?+K==8=v*cj& zUzmA-!~tN8)ZmYTw{cHtzI+K0xU~eggo}%4kl(t;XLFrv>Ck*Tj2P$6#&Lh=@6KUc zCeC*|;$^ugp!z1NaRXV)FyDO!rZXA^0<1=-ZNCP4&-mAUHF7mL){h`6YFTc-&y8{_ zMd&vN*x~7_=j=-NyV?`^F|#53bWPPLP{HD$$go0(k>M&-0Y!JIXIJ(SA}VSFw@yDz zctYrJ0e;u%r_~~C4=4#~ThC4PVdmse{cw2FZc4vQ51+)oq=NE&r?Eo<=LmfG&O{?j z%GlA5{-!BQ{=hrid^b`ydhX{$!3+s_gDmy5Q2TUZrYf0#GWf% zwc#0s`+{=9a2lu4Wa=>({vx8xgiw^+X)r+JW{dCZY0H`~#A0*pmz?DO(-tBUh}KKt z8y}DMH?Oxqn0-$DAH0zx!VujvV`|K!{PR7lw;jxGkVe_4P;O&9(IG1Y=jFsLc!*8cx?vTA|z2%y5CV(*}3nAwtlvy3BR4cO4Qr`c1TK z%RK;khk~d=Z1HLaUBQiD5OFWpv&^7VpGn(i#U~5SPpPy+`EqyH!(B2J%`4H_iVmwm*Xy{tc$whZ0pKG`r~WbFSC%kj8G^f9AWW7m2Xn}Mi9S0 zN>_Y=ZORftsa%95Yh#dC=S0lG14m5E`Tlm~W_S=14;Fi|%@q7x5}1i!il$l_%JR03 zPuLVde&&YRTR2o9Dg|JCQdTT+bn&-|CpU^sOpW zuImQ?%EJ|{gQd?;-&;5q$T5m<|489|zCTn;H12(wrQvG@e89}P?8yl%3ZXfE^l-caugId6Q_)FZ+8P|86KUw`;V{iYH03g2cE2~$hLv;qd& z1Tb9sqkeY6DL?p5d>APR=Q!*N4xaz~#o%wvMl4y0ERkY=n8Fm_r&t*!CW;GOX-Tm( zWNt?GIx4E98k%JudN0-AR0D;GQM@ar$CnJ+glJ0^3{Ot+k;2xK;5rlf^W@AoB=&m2 z4<(*w68LcP66Bu=T~fzYelbYqgJFEIDHAdjVji+Ell2%wT5h8K=6k<^BDMCt3`7DR z>||n&)ne^X8@^7)`oP2MGy?55F3gk!Wh!A-e8hwC!p~6AR(r$kD$G7{+1EjxzJ?+&j*|%? z5T`jmDfM;7iua=p<$!JyfLWmvSH$o?#<2q`AI6!>NwYrh!Qkz2s2j{uuL|Fj9ncmt zgBiep1$mtvF9!;sElNa63zXJk`Za%}4OZK*0B)3Mbbi7eDS#KWq_aPypDIDE4=&jp zfwop^ote;|Q}44CXlnvILz!1kv#*%Qbbn^)Fi1Kz5T@?tRfp4BM-vRs0|pN}u03jm zg84|v8QdurdUGSx$PA&*tqFkxRTH@7sA8et_17KO-@dy3Zuz>( YtZGunM1~7!-9j&9Ku>L uCpIWFv}so=tE$;n5v@(<=#UXg8k zAUpNFdCUF4)=M$HS7LjwxXpSS*ZLrI%KO;WZ-bWo%AInve(tsG+3(AizpGgCv}EI( zhSoEU)6aHIyD_!<xa~}2e0FSj*uu!jU=0BCE7-39 literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/cleanup.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/cleanup.gif new file mode 100644 index 0000000000000000000000000000000000000000..87b8f87a2f4445bb1ffff657c5b6d5c9b947df24 GIT binary patch literal 977 zcmeH`L2DC10ENeFf=R6lYQR#0q#6+2`F0?^-yqZ56wYj5riB(j705< zVyCe!YXljiLO^P#O&b$wVQK^f*gCwVz_&4<9@p#ww;GKvb4p__+D;+lIH4d7 zq6DHiL<~r<#L3{ zVnPVJZvS27zx@*n^fjFl0D~adY1{b(aK8jax38a)<)nMt-a(yrb#EW&ktco)-FCXW zUSzF?^X5H|EC-%tB319cJwxaScYN90d+hAx8&{u~Bq`Yan-3(TQ^Dw|_)nB!8+|z`(|!15yD}%fM`$ zvFpx1gHxWX_wL}_+HUS5A;r2`^7#URglIjdIqP(P7wuShZQacGYZO)%oR;W6v7{)| Ihk?Nw0PoW%qyPW_ literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/copy.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/copy.gif new file mode 100644 index 0000000000000000000000000000000000000000..f0b51871e24fb0b0a427be5a3929549431439a84 GIT binary patch literal 987 zcmeH`ziSg=9LC?6kh`|prkEk9Ay?>7+721o($El7g?eu15{}a0q7EHz=-{CA?GN!R zDSZWpj<2}fBD~`v9lpVUSGDvjT8vQP6%{i$yko`TZPGu%xep(n@!{ct=hp3o*-|}A zvg8Trsc3svm0DG1*VxwDJjxx4UVuJBe-}L_{oO9g=aO;3LZDpI zP*EXSD49@9Xcj3R0vBCSM93q_BP9U$T3`0|k2xqFYXMS#60s7f-yIx6jPDQd zOF+5*`4^yqw#K%^wnC|7N1aKl6Ro>weOCY6&KLOq1xEg+l7w6*lf8)ECx{u5Rr8uH zcyq(NJiZh&Z!0@$Z<55zdVeAJ=%J_9N1iq+laY;g>tN#J!z- zsYY8AHs^;b&PrVUo{IY>2A_{DH;tiu$q!U>?aj7n4Ccn%HRDcyX6pXWXB+9@Rchi7 z)Nd{{1}a56K%NLLEG0Wf|HzNUE8~@n+X3U->r3T}wTK$Q+d|pR31_~ROq-dU#b5kB KXM6AT>24D1{-9vc=M zY~~QwiaD`i;o)`xWiJ^8hXaSZ#1xZyA_9|-F*522@mNk=;xbt{cvXm`0E0CE2~igA literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/cut.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/cut.gif new file mode 100644 index 0000000000000000000000000000000000000000..6a969e55bd55d5e878a7ea7c7389f24df84bc924 GIT binary patch literal 358 zcmZ?wbhEHb6k!lyxN60a)wD6TV(o-!3(lN6eC5K41*`V%+Ix86($$-{Y-RM>$mqCC zBW^vT({i)44Y4&F8NJr8T(f@Cf?WamtJiKh5L>nW@S*+F=C7CYoK@B^fzfSsYEkEg z?T70+=PX&ZHNB*RF>;?q;G)uoi5jU}Iw#Ic%x_@~-^1v#a{AomlV-1Bv|F5z*D`8Iv8#2$;{X5uGoS*+ zpDc_F3|0&}AYqW77}%N}<`#J9NcEpkVF_}PndIb>kh%*Xi@|me}vhvFt^98V}F$kGh z@h}SUvw5;|u`nuGDKM~cv3d$ia`OPK*5u|C_GA&^Wprlb6=7*TcKpOiM+R#EaBGJ* literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/forecolor.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/forecolor.gif new file mode 100644 index 0000000000000000000000000000000000000000..560b40e2695ab66c2312ef2f6fb84b79c0c877cf GIT binary patch literal 981 zcmeH`O-~bH6ov1URtGUwkr0axlu-4WI< zu(%jLg*H`#D=_q9rdD(Y1TF2%JJa@^&Reb&-T4=|i+dI)CpYIwZeM?||Mr6#sDTOi zI|3j8VtF0O+jutkMGwaG*{D7%X>(Ds5G9LIV|kN^Qhq*Rib;Jbt}RLAy=*Lh&51uS zBJYPb>`+_}C&))xi+nS}5`IV(*OJEPRAF5)VoG6CH8#H6F_pzsOsGY9yCm;na+f93 zOxZ)_7w)9(?KJ+}$DItOvzW=EqLqG|m?4+||frHJrIN`uyIoaOvhCY=Lli-o19Ca%J2p vaBu;{t%g7duCxupRAAiYzQ_(DzOl~7r|KL{Lrrr;oqTocVd{;~3+;aZ-O2j* literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/full.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/full.gif new file mode 100644 index 0000000000000000000000000000000000000000..5a78c630675cbb1f7027a11cbbb19a6090daba26 GIT binary patch literal 856 zcmZ?wbhEHb6k!lyXlED&qaiS&LqPE-3o`=)BZCeo6hL``fy0!6nM1~7!-9j&9Ku>L wCpIWFvS<$*F5=IYCbgBlgia8mS;J{!F0C7th00000 literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/help.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/help.gif new file mode 100644 index 0000000000000000000000000000000000000000..a5d67714bc9becca85232849b8b3cf24bddba494 GIT binary patch literal 1027 zcmZ?wbhEHb6k!lyXlDQc0gnv=0UOLCyDXx66e57^0|EgT1R^dd1RPL^0HOy92_F

OYT29% z2@^gfO!!|g;X}a;Ao^dw=yLgz2NUPan>2UXq*eQO?A_C_;6nTIt8Hs8PFj0l(%R#b z*Bx(I@t|SF|NhO7CaiccVa10D8~!ibb#~FNiwkyNU9|Vcf*lW*?0&Fd$A<+w{;xT9 zbM3KPdk!7ickIOGqn8#O_`l)AgAE5hY&Zc#{|}wJa_rKrYqxG3IPu`jjR)s$Jw9;Z z!+{I`58U|h;KhdrAAsop2N3xG;m3a<00-VEF|d!pfx>f8vWp(T46` z;}8RjlOAnu!baL#Bz%O}c-W*eHXJ!n^z6`7EjylF7RpDMxReE?PB;WRwa(;Wb6;S{ z`0yYzyMcvTKto%DqdL kCpIiR+%BN(HRpst!_jUDW2OZsHZDHiui#w7!@*z;0CG_jN&o-= literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/image.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/image.gif new file mode 100644 index 0000000000000000000000000000000000000000..36109de73c7e54428c194da374db4f19fec7f61a GIT binary patch literal 194 zcmZ?wbhEHb6k!ly*v!Q+$3pADg9paO#xrNmR83}>b53;5xi1Ve8PaAl{09RDRG|2i zg^_`Qi$Mn@3^Id(B|qS#=jy#bmYv#4Q?pI*p?bZf4}wuZF{77A-PoE+3|-pFfbP)NAju!pljG~x9eYlg<-JldC77_7r5 f{>fl-My`~!@aq=WMO6iW(6IPA3%A6fg_wj zlS9U1!-9j&9Ku>L76J^1+c_CMN-Q=ma_Qif)R=JL!lNTi!a@oe0*y__`gwv2mKHE`lo$G!K;8!B2?h>J26he^ zj|~eBHggDT#hlo%(7B00$*smhVG%zmfg!{2D b7vIYJUmKs@=zXM?o5*?mlh5@MMh0sD=}{cF literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/italic_ru.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/italic_ru.gif new file mode 100644 index 0000000000000000000000000000000000000000..5c2f7fec2748d16db2da76bcb933e2f581c9f4cc GIT binary patch literal 78 zcmZ?wbhEHb6k!lyXkcXU_4U1d@| g-;s5$kL wCpIWFvpyBZ3(cKF-9?V<3rgqY@;KZ5_@87K3dCt-&=hpQLZ(cqB z_Vsf{S?~Qj*OzQPw(ro%o&{SUy!i0)`I8Sn{%boV9k}sf_R6DY&Yb!G|G#@k!GawZ zo;|t$?#;^$2OeCw@nOP(1Km?s+`D$|`}_CVt@93?crb6xuJ7N!Z`g6+!h`=o$;F$t z?iSDp*m2-^@1kwdSuGDf{LiiITd?86r1`5GW^8Z?%sP4D+SDb7jvT+RWb?(s>i%Wx zwz);;UwH6g<@U>ymhSlQ|NpENTQ6U`KYPQG4JRH~#%{P0cN>ZS5VMUEMvsef`aj?qa&CZj7Gn zVge32ZH~4!62i_b-U}Bm)oNuI6yRWWk}{OFFwt}|v}`q#5D|Bku-DfRH4qmNR&0X1HvvY{w_B*J`S(E~jG5Y9w&)0V{KxxdN-ChZQ6LYe}9L6TW@_@$=X3u0{rH E042uB(f|Me literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/numlist.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/numlist.gif new file mode 100644 index 0000000000000000000000000000000000000000..7ff907be758dcd41788aa864749a5f7ce4135d83 GIT binary patch literal 889 zcmZ?wbhEHb6k!lyXlDQcgMbEufC&x}K(xRi0f;s@WB}2DfPw=76&C^;9<#pEg;4hCxgAlE{= literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/outdent.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/outdent.gif new file mode 100644 index 0000000000000000000000000000000000000000..53e89a77f471fe02d405d9fa6c0f4f48e67ffffd GIT binary patch literal 887 zcmZ?wbhEHb6k!lyXlDQcgMbMR5fg%PCOIT5a7fq?P;nuk0f-(1bUY~QJDJe&p=;XS zuKCBNY<@gtPamxHZD0im!sN>#cN9P#l_srObpflu{uB& literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/paste.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/paste.gif new file mode 100644 index 0000000000000000000000000000000000000000..a676604cf68baab73af5ce50cc4a6934c447bd4b GIT binary patch literal 1022 zcmeH`O>0v@6ow~hG`Cf2QY(p=>W#WEZIO$(h#!kdikgbbXhDipn1VvU3R89Au46+@ zx)4SbNkPiAP{?w0p_L-cjR?2kVpeiN(Gh|KTsX_RiW7f^`0((;*&H}8ob%)7@+YSU z!62xDF3@vf-b2uXmJ)&pqe+5G5F>~uA?b=p84_$0Axu%3V#4qPMkuG)W5lHdQGy@M z-R9I~6tfy;l&~5Rb;KFwb)pzhb!$TLgyujufU$~%S+}}IdM1D-Kt>@QU?Z^!hzYS# zHtiltYn(E{>Vk2>8Rd1#ITM`PK{Oa|NG_yUS3)W&s0yr1hg65mgw$v&Gi@vHw7D_7 zV{D3!5i(FR&{Am?8l{bH8%t-aWBFUm|M>SC$o`J?0B{40c2Dj81aLls4JT6)+^;x$ zhNr@{Qu5%=4Y1@i7oQ&4btW`4QG1p{MYxGu#f9`pCKEe;tFLXh zBJUUCyECK0jr#t9iDhr)%4)7RiMC~0-*1jTPUY^mz!EoNc=-*`;Se%E^iJ* z=KY}y*9Dr6##7niJbnm2z{36$KUTfju{+O4uJxynLdxU&hOfRz7YaMRx~FPwm87`3 s7p+{*&#d)5$&TeyU$pB}Fd$}@-@U!pbRu_uej0lD=GV7aPZXT~1EP=l`~Uy| literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/redo.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/redo.gif new file mode 100644 index 0000000000000000000000000000000000000000..26a146bdaf3bff7c5366806ff64685cb9a9e291f GIT binary patch literal 942 zcmZ?wbhEHb6k!lyXlDQc1&;{^0TV2vXBh-6Fo*!64OR(D3=%e2rEj***lbYnz&(1F zL&k=nf~6sK+cGOwI%FL1EI;H>a3Q|_cx2s0hl&SYbr0ei_eQq8kL-OP(C{Ik<3mpG z!=%Y?Gp4>znDC)s#)pE1Z_AgwFIezl`s%Z7OWyaaf7c5{8{W;{`F_HV536?HUAgz( zqP_2y?0&y;@4J=z-tRbgare<{E04ZkbM(#TL+`g9d$IlK`|T&5Z94UK$H^zVPP{mD z`q6>Y&kme>a{SVZQ{V__6h5*SSp!k!8nSsHHK?kH0lqVQCx*1wIWIQ%3IM~b~ ztQB)YAW=Zpput2WL)nc>MBV2{LdWBytgO5$H4-14AF#BTScp_KC^9k$D3x95Xb3pk z%E;s`qwt{7g@eUZ-$KHInTbLh&aHBLf2m zgAPanWQGHatH4Rm)mtC1taW4z*XUCT;&D}6b1!^f^0r*|ijy%HZcR;>Xi;cj*OuyE je}04Op|dfH>FS|7o-PaUdBy%kK=;&Ac27N51_o;YROd96 literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/right.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/right.gif new file mode 100644 index 0000000000000000000000000000000000000000..88bfaf2542714e3e477e6accefde445e2e18a860 GIT binary patch literal 855 zcmZ?wbhEHb6k!lyXlED&qaiS&LqPE-3o`=)BZCeo6hL``fy0D>nM1~7!-9j&9Ku>L uCpIWFvaOo5kkGsR6pzPYmZ>z@A8Mwr4f?DvZn3YBf4AuY|n-yCC literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/spacer.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/spacer.gif new file mode 100644 index 0000000000000000000000000000000000000000..fc2560981ee1caca400e225e48d282106f907f2d GIT binary patch literal 43 ucmZ?wbhEHbWMp7uXkcLY|NlP&1B2pE7Df>utpmhBaYhCPCMFj~25SJyItL8^ literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/strikethrough.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/strikethrough.gif new file mode 100644 index 0000000000000000000000000000000000000000..ce7b65304e85e57d803d69ad14a8f1e19389a5ef GIT binary patch literal 873 zcmZ?wbhEHb6k!lyXlED&qaiS&LqPE-3o`=)BZCeo6hL``fy0e~nM1~7!-9j&9Ku>L zCpIiR+|J6#!Qv43$fb*2mu-W_#Ki}@gq^eg?D)9oc)w`yDi+UxWcP`ZhU;Wb2rW80 O+oJf@ok{}*25SImDA+u352i-1z@WyU19A;0PcU#K zGWc@Hcx+g3u$ee6)z3=D@^XDF(=2s8#TFz_A+u352i|<1Z?vtF&Y8`90H0zS(q6ZG#GS1 z?f~Tp299)wKn@v?4GRu7a|mn2oY?Ttfm6`MLdE0IL6=5VxgLid3XJTHihL{%j0+i= zTco)pUOZUHz`(_8Ea70l;J_-(r+y`*fJxn1K#%dpmz5uw85tz>I9hiGFfi~k>2mD# P*t+WK>Ii){76xkoFRNeL literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table.gif new file mode 100644 index 0000000000000000000000000000000000000000..f8a00544a9980d38c44d5fe8e9a8457be8339834 GIT binary patch literal 1018 zcmeH`!D|yi6vijCX;K?;HK|5XNfs0Yg$)+cs)rOqvff5dHHc2Uv)oRl&oNM zL_v>pGsp4dsvwhU>0X4Xh+Wac9CC=o!gvw&;JEQG@DJ$6$B*y9ySxux{Y-6ku9*Wl z&;cV^mgTqzF2D-Ju^=LJ*5Me*7UC50Cy+D9dr10NaI7en0;v!yiHT1LWt4Ho80`td zH0fy?J20##7#A#vDOn&n7d(iA=0Y-IcxbrPf)f!?@szE;c^>s&MB!_#s1QkQn7rM&uZWEuIkdp$R4&n$wy)0vxLV{8?)r-!}Ci)!@%sw>sSn!}>!G{SeK1|r~VZn+68+II6u;asm10Ob=_wF-@g9v?#;*dZ@+%|{O#+PpFh6;{Q2Y8&mX^k|N8U$_y7O@!A=+@ zMnhm=LO}5+3o`?QHiHhxdQhHV;HYB==aBK(u;5@bhp<-6i46*DqFMnSA1*XHGjymj z$?Op*WNGP=)SJbz@M1!Xh>C;FgAEIv8ibYXrszl~ z&MaaYDh9g*7@JwyXK1-BXgI*Il2h;pPeZ6;LmS)vCRL5HH(U%EXSsA%Z__>8z+epk DI%10H literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_delete_row.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_delete_row.gif new file mode 100644 index 0000000000000000000000000000000000000000..1997065fb2b447f498ab7fda4b7e21dcbb25dc81 GIT binary patch literal 942 zcmZ?wbhEHb6k!lyXlDQc1CIoUh=PEGhJcKQgo1{IiU|b`3j#VmBuw~FFylkPf)5Q7 z7Bo!QFk!}m2{SfKSg@gC#fJ$SK1|s0VZn+63pO0su;ai2Ap5|F4JUx;|A7nt58U{F z;lck0FaAIH@c#o4{rLYMi2nZv+crv!hQJ^S0mYvz%nS@F3_2h;f${_cM>m5fhm6OD z1qYisgtcN$Ojy9mEvgi>fT8hWN4JEt$%Yw%N7~tCoGZROc*x+)p`mC~@Svg5n~l@8 z>cxRXXEq)or2`@y3m*9JNg2eP*va6?$lx(i=t)DOQwuAXkirbBgarR4#!XpwwGCZQ}j-u$i5iXM38c!-9o(cUMTVu`pNz0PJ9X!TQ3xphWMO7tP+`ykxe1gf7&uxPJUL`M zHY_;U%pokNQs8*7k%5a_=z@SE(i5MkXeC zPNt5?0yW=8hN62%Dla%PGcz-pWCS=goN5wqs`((G@bc1P7WEc}kBSW;s{+{lBo>-5 iu&xUgtrHbga%dGy+03=YpedVyC-?NbIlm1R7_0$Wk9qk3 literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_insert_col_before.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_insert_col_before.gif new file mode 100644 index 0000000000000000000000000000000000000000..5d1ff37afea7bb2e67952400e00184aa275d6764 GIT binary patch literal 935 zcmZ?wbhEHb6k!lyXlDQc1CNA&goc2OhJ=EKgo+6T6%!mP9uzc82Q3xphWMO7tP+`ykxe1gf7&uxOJUL`M zHY_;U%)u+PW5EN5h88YU7mp7DN{(zYMmj4p0u!3~q*V&u{5arzY@(RFO-4h5!|^7D zIH?}ZVugm;rn%2dUMy&AWMq^w(NJJWb>vXAtKet|SsBK;hMu<;?0m9#Rd5 h!d40F?cxwzaHwNr1Z$MUMpFj1Z7JoaTqOh;tN|1Me9r&? literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_insert_row_after.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_insert_row_after.gif new file mode 100644 index 0000000000000000000000000000000000000000..c3aa15f93a9d50777ca3a3b2309fc807ceabc57a GIT binary patch literal 928 zcmZ?wbhEHb6k!lyXlDQc1CNA&goc2OhJ=EKgo+6T6%!mP9uzc82Q3xphWMO7tP+`ykxe1gf7&vMfJUL`M zHY_;U%)uMAz#x%{g`JbTZ-#`DOLGT{dj|*Oqh`h)X6?Ek4-y$X8X1FD*?2NJv$hH7 z&6{JfXpzqZDa$&I13@aDj5?v~Qf7WQ*v!VmA#i}h;Q=$htVPBS0l|h)240Jt69SHm a!Hpb79uX5BFnBXLF$=_=o|fvsU=08}a&%e% literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_insert_row_before.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/table_insert_row_before.gif new file mode 100644 index 0000000000000000000000000000000000000000..c3271e54937cb8dbfb435ee8bc2d02157cff1448 GIT binary patch literal 928 zcmZ?wbhEHb6k!lyXlDQc1CNA&goc2OhJ=EKgo+6T6%!mP9uzc82Q3xphWMO7tP+`ykxe1gf7&vMfJUL`M zHY_;U%pt55lkwqTGaC=w17?0%i;Nu$1RC5Kcr9{H2skpjHgXtwL`-~0*X=}WE7QHI{4WtnErk^c$i_Har&nt0T0z!7V6jbF?3B; b3|uVFrNMjfN;AWXK;{oIr@tjQFjxZsoSk_C literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/underline.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/underline.gif new file mode 100644 index 0000000000000000000000000000000000000000..d6b8afdabd9b6a8eae84df6c7427d2dc3eba592d GIT binary patch literal 872 zcmZ?wbhEHb6k!lyXlDR{>gsARJxYv*z=#V0#h)z93=B*RIv}5e@&p5iD+4QsjK_ur z2b(#BwPH?uP-tjpU~%Z#@!_FEH;#u+G?QQ1HMZVSz)!28WCdp>^9bD_1#W z9B?QAq6=|#M*}J@MAThysCeL2_aLrmZ$QI?$hHRo4IctJJ|s+dkTLar!h{b6GaeMo z_)xImL;tGFGuNJLSn;8E!}|#kz2AK7?e?SZH=lmL?c|#)*REc= zcK7o2`{%DdKYiuh>6>rCo){%YLx7wRQ2fcl%)sEtpaaqj$`cG6eGJVUG9DWi9Bk$g z)`~e1peP`&U-TzKVo58fkdn)u4HFAm4oIt+Sa<{^FmcOpIA6GssN~GdCL$tpz<^n? zolnk0!GXc)K?A3%K-!KC2M;qzFiSGHMjSlQ$|qT)vULN~LKb!&4h{~53GB=~rW#x! liiyn;jr;~n1a334wsE8>f{lbk0FP}g8@Z*1AO8JBZ2V4TPjvT)boz>E_VC#h&A2w~>{r~^} zcW+)kdvgEYwQCPveE9zU{iUl{4&3-KZ_Td4>V5-{f`ozz0RL8z#>2v34FK-Fw;KQe literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/visualaid.gif b/includes/tinymce/jscripts/tiny_mce/themes/advanced/images/visualaid.gif new file mode 100644 index 0000000000000000000000000000000000000000..188b3487adccadc6bb87790ababd89c3f77ac906 GIT binary patch literal 1006 zcmZ?wbhEHb6k!lyXlDQc1CNA&j0pi53jzujBvdR&Xjo9tu%V!1L&1a%4L~#lhz?9x zaA3lU0}UHKOaP)C9~P`QuwcW11v`M`g#|k|3CnC$S5%y0`v|6#h)z9 z3=FyqIv|Tdd4hrCG($9pjK_ur2b(#BwPH?8Na$!+aL70@;o%`xE@3r~2@eh^a*OfW zb){@fYV8uyU=m>YIPsvzB(=b0F*h9!vas_>nIvp*aAaa(=UE{$c%a#~LRYWm%E`;>0nDsi0u0%SIVS};0~WjpSa5`cBSCvh z%*PFx?Yyk-9;sS1rktPecv(onz=7cgr>f|JF9`=+IyqQeYAP7QnojPJdlA=WkYJqN WB*e5L?(DA8!`C+?3-fR=SOWle^sxB= literal 0 HcmV?d00001 diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/langs/en.js b/includes/tinymce/jscripts/tiny_mce/themes/advanced/langs/en.js new file mode 100644 index 00000000..32cf5ca8 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/langs/en.js @@ -0,0 +1,57 @@ +// UK lang variables + +tinyMCELang['lang_theme_style_select'] = 'Styles'; +tinyMCELang['lang_theme_code_desc'] = 'Edit HTML Source'; +tinyMCELang['lang_theme_code_title'] = 'HTML Source Editor'; +tinyMCELang['lang_theme_code_wordwrap'] = 'Word wrap'; +tinyMCELang['lang_theme_sub_desc'] = 'Subscript'; +tinyMCELang['lang_theme_sup_desc'] = 'Superscript'; +tinyMCELang['lang_theme_hr_desc'] = 'Insert horizontal ruler'; +tinyMCELang['lang_theme_removeformat_desc'] = 'Remove formatting'; +tinyMCELang['lang_theme_custom1_desc'] = 'Your custom description here'; +tinyMCELang['lang_insert_image_border'] = 'Border'; +tinyMCELang['lang_insert_image_dimensions'] = 'Dimensions'; +tinyMCELang['lang_insert_image_vspace'] = 'VSpace'; +tinyMCELang['lang_insert_image_hspace'] = 'HSpace'; +tinyMCELang['lang_insert_image_align'] = 'Alignment'; +tinyMCELang['lang_insert_image_align_default'] = 'Default'; +tinyMCELang['lang_insert_image_align_baseline'] = 'Baseline'; +tinyMCELang['lang_insert_image_align_top'] = 'Top'; +tinyMCELang['lang_insert_image_align_middle'] = 'Middle'; +tinyMCELang['lang_insert_image_align_bottom'] = 'Bottom'; +tinyMCELang['lang_insert_image_align_texttop'] = 'TextTop'; +tinyMCELang['lang_insert_image_align_absmiddle'] = 'Absolute Middle'; +tinyMCELang['lang_insert_image_align_absbottom'] = 'Absolute Bottom'; +tinyMCELang['lang_insert_image_align_left'] = 'Left'; +tinyMCELang['lang_insert_image_align_right'] = 'Right'; +tinyMCELang['lang_theme_font_size'] = 'Font size'; +tinyMCELang['lang_theme_fontdefault'] = 'Default'; +tinyMCELang['lang_theme_paragraph'] = 'Paragraph'; +tinyMCELang['lang_theme_div'] = 'Div'; +tinyMCELang['lang_theme_address'] = 'Address'; +tinyMCELang['lang_theme_pre'] = 'Preformatted'; +tinyMCELang['lang_theme_h1'] = 'Heading 1'; +tinyMCELang['lang_theme_h2'] = 'Heading 2'; +tinyMCELang['lang_theme_h3'] = 'Heading 3'; +tinyMCELang['lang_theme_h4'] = 'Heading 4'; +tinyMCELang['lang_theme_h5'] = 'Heading 5'; +tinyMCELang['lang_theme_h6'] = 'Heading 6'; +tinyMCELang['lang_theme_colorpicker_title'] = 'Select a color'; +tinyMCELang['lang_theme_colorpicker_apply'] = 'Apply'; +tinyMCELang['lang_theme_forecolor_desc'] = 'Select text color'; +tinyMCELang['lang_theme_backcolor_desc'] = 'Select background color'; +tinyMCELang['lang_theme_charmap_title'] = 'Select custom character'; +tinyMCELang['lang_theme_charmap_desc'] = 'Insert custom character'; +tinyMCELang['lang_theme_visualaid_desc'] = 'Toggle guidelines/invisible elements'; +tinyMCELang['lang_insert_anchor_title'] = 'Insert/edit anchor'; +tinyMCELang['lang_insert_anchor_name'] = 'Anchor name'; +tinyMCELang['lang_theme_anchor_desc'] = 'Insert/edit anchor'; +tinyMCELang['lang_theme_insert_link_titlefield'] = 'Title'; +tinyMCELang['lang_theme_clipboard_msg'] = 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?'; +tinyMCELang['lang_theme_path'] = 'Path'; +tinyMCELang['lang_cut_desc'] = 'Cut'; +tinyMCELang['lang_copy_desc'] = 'Copy'; +tinyMCELang['lang_paste_desc'] = 'Paste'; +tinyMCELang['lang_link_list'] = 'Link list'; +tinyMCELang['lang_image_list'] = 'Image list'; +tinyMCELang['lang_browse'] = 'Browse'; diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/link.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/link.htm new file mode 100644 index 00000000..e95bf17d --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/link.htm @@ -0,0 +1,115 @@ + + +{$lang_insert_link_title} + + + + + +

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
{$lang_insert_link_title}
{$lang_insert_link_url}: + + + + +
{$lang_insert_link_target}:
{$lang_theme_insert_link_titlefield}:
+
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/themes/advanced/source_editor.htm b/includes/tinymce/jscripts/tiny_mce/themes/advanced/source_editor.htm new file mode 100644 index 00000000..1dd2eb16 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/themes/advanced/source_editor.htm @@ -0,0 +1,90 @@ + + + + +{$lang_theme_code_title} + + + + + +
+ + + + + + + + + + + +
{$lang_theme_code_title}
+ +
+
+ + diff --git a/includes/tinymce/jscripts/tiny_mce/tiny_mce.js b/includes/tinymce/jscripts/tiny_mce/tiny_mce.js new file mode 100644 index 00000000..b2b01c03 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/tiny_mce.js @@ -0,0 +1,9 @@ +/** + * $RCSfile: tiny_mce.js,v $ + * $Revision: 1.1 $ + * $Date: 2005/03/06 06:22:26 $ + * + * @author Moxiecode + * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved. + */ + function TinyMCE(){this.instances=new Array();this.stickyClassesLookup=new Array();this.windowArgs=new Array();this.isMSIE=(navigator.appName=="Microsoft Internet Explorer");this.isMSIE5=this.isMSIE&&(navigator.userAgent.indexOf('MSIE 5')!=-1);this.isMSIE5_0=this.isMSIE&&(navigator.userAgent.indexOf('MSIE 5.0')!=-1);this.isGecko=navigator.userAgent.indexOf('Gecko')!=-1;this.idCounter=0;this.init=TinyMCE_init;this.addMCEControl=TinyMCE_addMCEControl;this.triggerSave=TinyMCE_triggerSave;this._convertOnClick=TinyMCE__convertOnClick;this.resetForm=TinyMCE_resetForm;this.execCommand=TinyMCE_execCommand;this.execInstanceCommand=TinyMCE_execInstanceCommand;this._createIFrame=TinyMCE__createIFrame;this.handleEvent=TinyMCE_handleEvent;this.setupContent=TinyMCE_setupContent;this.switchClass=TinyMCE_switchClass;this.restoreAndSwitchClass=TinyMCE_restoreAndSwitchClass;this.switchClassSticky=TinyMCE_switchClassSticky;this.restoreClass=TinyMCE_restoreClass;this.setClassLock=TinyMCE_setClassLock;this.addEvent=TinyMCE_addEvent;this.onLoad=TinyMCE_onLoad;this.removeMCEControl=TinyMCE_removeMCEControl;this._initCleanup=TinyMCE__initCleanup;this._cleanupHTML=TinyMCE__cleanupHTML;this._cleanupAttribute=TinyMCE__cleanupAttribute;this._fixInlineStyles=TinyMCE__fixInlineStyles;this._cleanupElementName=TinyMCE__cleanupElementName;this._verifyClass=TinyMCE__verifyClass;this.cleanupNode=TinyMCE_cleanupNode;this.convertStringToXML=TinyMCE_convertStringToXML;this.insertLink=TinyMCE_insertLink;this.insertImage=TinyMCE_insertImage;this.getElementByAttributeValue=TinyMCE_getElementByAttributeValue;this.getElementsByAttributeValue=TinyMCE_getElementsByAttributeValue;this.isBlockElement=TinyMCE_isBlockElement;this.getParentBlockElement=TinyMCE_getParentBlockElement;this.getNodeTree=TinyMCE_getNodeTree;this.getParentElement=TinyMCE_getParentElement;this.getParam=TinyMCE_getParam;this.getLang=TinyMCE_getLang;this.replaceVar=TinyMCE_replaceVar;this.replaceVars=TinyMCE_replaceVars;this.triggerNodeChange=TinyMCE_triggerNodeChange;this.parseURL=TinyMCE_parseURL;this.convertAbsoluteURLToRelativeURL=TinyMCE_convertAbsoluteURLToRelativeURL;this.convertRelativeToAbsoluteURL=TinyMCE_convertRelativeToAbsoluteURL;this.updateContent=TinyMCE_updateContent;this._customCleanup=TinyMCE__customCleanup;this.getContent=TinyMCE_getContent;this.setContent=TinyMCE_setContent;this.importThemeLanguagePack=TinyMCE_importThemeLanguagePack;this.importPluginLanguagePack=TinyMCE_importPluginLanguagePack;this.applyTemplate=TinyMCE_applyTemplate;this.openWindow=TinyMCE_openWindow;this.handleVisualAid=TinyMCE_handleVisualAid;this.setAttrib=TinyMCE_setAttrib;this.getAttrib=TinyMCE_getAttrib;this._getThemeFunction=TinyMCE__getThemeFunction;this._themeExecCommand=TinyMCE__themeExecCommand;this.getControlHTML=TinyMCE_getControlHTML;this._setHTML=TinyMCE__setHTML;this._getElementById=TinyMCE__getElementById;this.getInstanceById=TinyMCE_getInstanceById;this.getEditorId=TinyMCE_getEditorId;this.queryInstanceCommandValue=TinyMCE_queryInstanceCommandValue;this.queryInstanceCommandState=TinyMCE_queryInstanceCommandState;this.getWindowArg=TinyMCE_getWindowArg;this.setWindowArg=TinyMCE_setWindowArg;this.getCSSClasses=TinyMCE_getCSSClasses;this.regexpReplace=TinyMCE_regexpReplace;this.cleanupEventStr=TinyMCE_cleanupEventStr;this.getAbsPosition=TinyMCE_getAbsPosition;this.openFileBrowser=TinyMCE_openFileBrowser;}function TinyMCE_init(settings){var theme,srcMode;this.settings=settings;function defParam(key,def_val){settings[key]=tinyMCE.getParam(key,def_val);}if(typeof(document.execCommand)=='undefined')return;if(!tinyMCE.baseURL){var elements=document.getElementsByTagName('script');for(var i=0;i');document.write('');document.write('');var themePlugins=tinyMCE.getParam('plugins','',true,',');if(this.settings['plugins']!=''){for(var i=0;i');}}function TinyMCE_confirmAdd(e){var elm=tinyMCE.isMSIE?event.srcElement:e.target;var elementId=elm.name?elm.name:elm.id;if(!targetElement.getAttribute('mce_noask')&&confirm(tinyMCELang['lang_edit_confirm']))tinyMCE.addMCEControl(elm,elementId);else targetElement.setAttribute('mce_noask','true');}function TinyMCE_updateContent(form_element_name){var formElement=document.getElementById(form_element_name);for(var n in tinyMCE.instances){var inst=tinyMCE.instances[n];if(inst.formElement==formElement){var doc=inst.getDoc();tinyMCE._setHTML(doc,inst.formElement.value);if(!tinyMCE.isMSIE)doc.body.innerHTML=tinyMCE._cleanupHTML(doc,this.settings,doc.body,inst.visualAid);}}}function TinyMCE_addMCEControl(replace_element,form_element_name,target_document){var id="mce_editor_"+tinyMCE.idCounter++;var inst=new TinyMCEControl(tinyMCE.settings);inst.editorId=id;this.instances[id]=inst;inst.onAdd(replace_element,form_element_name,target_document);}function TinyMCE_triggerSave(skip_cleanup,skip_callback){for(var n in tinyMCE.instances){var inst=tinyMCE.instances[n];tinyMCE.settings['preformatted']=false;if(typeof(skip_cleanup)=="undefined")skip_cleanup=false;if(typeof(skip_callback)=="undefined")skip_callback=false;tinyMCE._setHTML(inst.getDoc(),inst.getBody().innerHTML);var htm=skip_cleanup?inst.getBody().innerHTML:tinyMCE._cleanupHTML(inst.getDoc(),this.settings,inst.getBody(),this.visualAid,true);if(tinyMCE.settings["encoding"]=="xml"||tinyMCE.settings["encoding"]=="html")htm=tinyMCE.convertStringToXML(htm);if(!skip_callback&&tinyMCE.settings['save_callback']!="")var content=eval(tinyMCE.settings['save_callback']+"(inst.formTargetElementId,htm,inst.getBody());");if((typeof(content)!="undefined")&&content!=null)htm=content;htm=tinyMCE.regexpReplace(htm,"(","(","gi");htm=tinyMCE.regexpReplace(htm,")",")","gi");htm=tinyMCE.regexpReplace(htm,";",";","gi");htm=tinyMCE.regexpReplace(htm,""",""","gi");htm=tinyMCE.regexpReplace(htm,"^","^","gi");inst.formElement.value=htm;}}function TinyMCE__convertOnClick(node){if(tinyMCE.isMSIE5)return;var elms=node.getElementsByTagName("a");for(var i=0;i","gi");content=tinyMCE.regexpReplace(content,"\r","
","gi");content=tinyMCE.regexpReplace(content,"\n","
","gi");}content=tinyMCE._customCleanup("insert_to_editor",content);if(tinyMCE.isMSIE){var styleSheet=document.frames[editor_id].document.createStyleSheet(inst.settings['content_css']);window.setInterval('try{tinyMCE.getCSSClasses(document.frames["'+editor_id+'"].document, "'+editor_id+'");}catch(e){}',500);if(tinyMCE.settings["force_br_newlines"])document.frames[editor_id].document.styleSheets[0].addRule("p","margin: 0px;");var patchFunc=function(){var event=document.frames[editor_id].event;event.target=document.frames[editor_id].document;TinyMCE_handleEvent(event);};var body=document.frames[editor_id].document.body;body.onbeforepaste=patchFunc;body.onbeforecut=patchFunc;body.onpaste=patchFunc;body.editorId=editor_id;}else{var cssImporter=doc.createElement("link");cssImporter.rel="stylesheet";cssImporter.href=inst.settings['content_css'];if(headArr=doc.getElementsByTagName("head"));headArr[0].appendChild(cssImporter);}if(!tinyMCE.isMSIE){var contentElement=inst.getDoc().createElement("body");var doc=inst.getDoc();contentElement.innerHTML=content;if(tinyMCE.settings['force_p_newlines'])content=content.replace(new RegExp('<>','g'),"");if(tinyMCE.settings['cleanup_on_startup'])inst.getBody().innerHTML=tinyMCE._cleanupHTML(doc,this.settings,contentElement);else{content=tinyMCE.regexpReplace(content,"","
","gi");content=tinyMCE.regexpReplace(content,"","","gi");inst.getBody().innerHTML=contentElement.innerHTML;}inst.convertAllRelativeURLs();}else{if(tinyMCE.settings['cleanup_on_startup']){tinyMCE._setHTML(inst.getDoc(),content);eval('try {inst.getBody().innerHTML = tinyMCE._cleanupHTML(inst.contentDocument, this.settings, inst.getBody());} catch(e) {}');}else inst.getBody().innerHTML=content;}tinyMCE._convertOnClick(inst.getBody());var parentElm=document.getElementById(inst.editorId+'_parent');if(parentElm.lastChild.nodeName.toLowerCase()=="input")inst.formElement=parentElm.lastChild;else inst.formElement=parentElm.nextSibling;tinyMCE.handleVisualAid(inst.getBody(),true,tinyMCE.settings['visual']);inst.executeCallback('setupcontent_callback','_setupContent',0,editor_id,inst.getBody(),inst.getDoc());if(!tinyMCE.isMSIE)TinyMCE_addEventHandlers(editor_id);tinyMCE.selectedInstance=inst;inst.selectNode(inst.getBody(),true,true);tinyMCE.triggerNodeChange(false);}function TinyMCE_handleEvent(e){switch(e.type){case "submit":var formObj=tinyMCE.isMSIE?window.event.srcElement:e.target;for(var i=0;i");rng.collapse(false);rng.select();tinyMCE.triggerNodeChange(false);return false;}}if(e.keyCode==8||e.keyCode==46){tinyMCE.selectedElement=e.target;tinyMCE.linkElement=tinyMCE.getParentElement(e.target,"a");tinyMCE.imgElement=tinyMCE.getParentElement(e.target,"img");tinyMCE.triggerNodeChange(false);}return false;break;case "keyup":case "keydown":if(e.target.editorId)tinyMCE.selectedInstance=tinyMCE.instances[e.target.editorId];else return;if(tinyMCE.isGecko&&tinyMCE.settings['force_p_newlines']&&(e.keyCode==8||e.keyCode==46)&&!e.shiftKey){if(tinyMCE.selectedInstance._handleBackSpace(e.type)){e.preventDefault();return false;}}tinyMCE.selectedElement=null;tinyMCE.selectedNode=null;var elm=tinyMCE.selectedInstance.getFocusElement();tinyMCE.linkElement=tinyMCE.getParentElement(elm,"a");tinyMCE.imgElement=tinyMCE.getParentElement(elm,"img");tinyMCE.selectedElement=elm;if(tinyMCE.isGecko&&e.type=="keyup"&&e.keyCode==9)tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(),true,tinyMCE.settings['visual']);if(tinyMCE.isGecko&&tinyMCE.settings['document_base_url']!=""+document.location.href&&e.type=="keyup"&&e.ctrlKey&&e.keyCode==86)tinyMCE.selectedInstance.fixBrokenURLs();if(tinyMCE.isMSIE&&tinyMCE.settings['custom_undo_redo']){var keys=new Array(13,45,36,35,33,34,37,38,39,40);var posKey=false;for(var i=0;i18&&e.keyCode!=255)){tinyMCE.selectedInstance.execCommand("mceAddUndoLevel");tinyMCE.selectedInstance.typing=true;tinyMCE.triggerNodeChange(false);}if(posKey&&e.type=="keyup")tinyMCE.triggerNodeChange(false);var ctrlKeys=new Array(66,73,85,86,88);var keys=new Array(8,46);for(var i=0;i0){for(var i=0;i ";if(tinyMCE.isMSIE&&elementName=="script")return "<"+elementName+elementAttribs+">"+node.text+"";if(node.hasChildNodes()){if(elementName=="p"&&tinyMCE.cleanup_force_br_newlines)output+="";else output+="<"+elementName+elementAttribs+">";for(var i=0;i
";else output+="";}else{if(elementName=="a")output+="<"+elementName+elementAttribs+">";else{output+="<"+elementName+elementAttribs+" />";}}return output;case 3:if(node.parentNode.nodeName.toLowerCase()=="script")return node.nodeValue;return this.convertStringToXML(node.nodeValue);case 8:return "";default:return "[UNKNOWN NODETYPE "+node.nodeType+"]";}}function TinyMCE_convertStringToXML(html_data){var output="";for(var i=0;i','','gi');var html=this.cleanupNode(element);if(tinyMCE.settings['debug'])alert("Cleanup process executed in: "+(new Date().getTime()-startTime)+" ms.");html=tinyMCE.regexpReplace(html,'


','
');html=tinyMCE.regexpReplace(html,'

 


 

','
');if(!tinyMCE.isMSIE)html=html.replace(new RegExp('','g'),"");if(tinyMCE.settings['apply_source_formatting']){html=html.replace(new RegExp('<(p|div)([^>]*)>','g'),"\n<$1$2>\n");html=html.replace(new RegExp('<\/(p|div)([^>]*)>','g'),"\n\n");html=html.replace(new RegExp('
','g'),"
\n");}if(tinyMCE.settings['force_br_newlines']){var re=new RegExp('

 

','g');html=html.replace(re,"
");}if(tinyMCE.settings['force_p_newlines']){var re=new RegExp('<>','g');html=html.replace(re,"");}if(html=="
"||html=="

 

")html="";html=tinyMCE._customCleanup(on_save?"get_from_editor":"insert_to_editor",html);if(tinyMCE.settings["preformatted"])return "
"+html+"
";return html;}function TinyMCE_insertLink(href,target,title,onclick){function setAttrib(element,name,value){if(value!=null&&value!="")element.setAttribute(name,value);else element.removeAttribute(name);}this.execCommand("mceAddUndoLevel");if(this.selectedInstance&&this.selectedElement&&this.selectedElement.nodeName.toLowerCase()=="img"){var doc=this.selectedInstance.getDoc();var linkElement=doc.createElement("a");href=eval(tinyMCE.settings['urlconvertor_callback']+"(href, linkElement);");setAttrib(linkElement,'href',href);setAttrib(linkElement,'target',target);setAttrib(linkElement,'title',title);setAttrib(linkElement,'mce_onclick',onclick);linkElement.appendChild(this.selectedElement.cloneNode(true));this.selectedElement.parentNode.replaceChild(linkElement,this.selectedElement);return;}if(!this.linkElement&&this.selectedInstance){this.selectedInstance.contentDocument.execCommand("createlink",false,"#mce_temp_url#");tinyMCE.linkElement=this.getElementByAttributeValue(this.selectedInstance.contentDocument.body,"a","href","#mce_temp_url#");var elementArray=this.getElementsByAttributeValue(this.selectedInstance.contentDocument.body,"a","href","#mce_temp_url#");for(var i=0;i=strTok2.length){for(var i=0;i=strTok2.length||strTok1[i]!=strTok2[i]){breakPoint=i+1;break;}}}if(strTok1.length=strTok1.length||strTok1[i]!=strTok2[i]){breakPoint=i+1;break;}}}if(breakPoint==1)return url_to_relative;for(var i=0;i<(strTok1.length-(breakPoint-1));i++)outputString+="../";for(var i=breakPoint-1;i=0;i--){if(baseURLParts[i].length==0)continue;newBaseURLParts[newBaseURLParts.length]=baseURLParts[i];}baseURLParts=newBaseURLParts.reverse();var newRelURLParts=new Array();var numBack=0;for(var i=relURLParts.length-1;i>=0;i--){if(relURLParts[i].length==0||relURLParts[i]==".")continue;if(relURLParts[i]=='..'){numBack++;continue;}if(numBack>0){numBack--;continue;}newRelURLParts[newRelURLParts.length]=relURLParts[i];}relURLParts=newRelURLParts.reverse();var len=baseURLParts.length-numBack;var absPath=(len<=0?"":"/")+baseURLParts.slice(0,len).join('/')+"/"+relURLParts.join('/');var start="",end="";if(baseURL['protocol'])start+=baseURL['protocol']+"://";if(baseURL['host'])start+=baseURL['host'];if(baseURL['port'])start+=":"+baseURL['port'];if(relURL['query'])end+="?"+relURL['query'];if(relURL['anchor'])end+="#"+relURL['anchor'];return start+absPath+end;}function TinyMCE_getParam(name,default_value,strip_whitespace,split_chr){var value=(typeof(this.settings[name])=="undefined")?default_value:this.settings[name];if(value=="true"||value=="false")return(value=="true");if(strip_whitespace)value=tinyMCE.regexpReplace(value,"[ \t\r\n]","");if(typeof(split_chr)!="undefined"&&split_chr!=null){value=value.split(split_chr);var outArray=new Array();for(var i=0;i0);if(tinyMCE.settings['custom_undo_redo']){undoIndex=inst.undoIndex;undoLevels=inst.undoLevels.length;}inst.executeCallback('handleNodeChangeCallback','_handleNodeChange',0,editorId,elm,undoIndex,undoLevels,inst.visualAid,anySelection);}}if(this.selectedInstance&&(typeof(focus)=="undefined"||focus))this.selectedInstance.contentWindow.focus();}function TinyMCE__customCleanup(type,content){var customCleanup=tinyMCE.settings['cleanup_callback'];if(customCleanup!=""&&eval("typeof("+customCleanup+")")!="undefined")content=eval(customCleanup+"(type, content);");var plugins=tinyMCE.getParam('plugins','',true,',');for(var i=0;i');}function TinyMCE_importPluginLanguagePack(name,valid_languages){var lang="en";valid_languages=valid_languages.split(',');for(var i=0;i');}function TinyMCE_applyTemplate(html,args){html=tinyMCE.replaceVar(html,"themeurl",tinyMCE.themeURL);if(typeof(args)!="undefined")html=tinyMCE.replaceVars(html,args);html=tinyMCE.replaceVars(html,tinyMCE.settings);html=tinyMCE.replaceVars(html,tinyMCELang);return html;}function TinyMCE_openWindow(template,args){var html,width,height,x,y,resizable,scrollbars,url;args['mce_template_file']=template['file'];tinyMCE.windowArgs=args;html=template['html'];if(!(width=template['width']))width=320;if(!(height=template['height']))height=200;if(tinyMCE.isMSIE)height+=30;x=parseInt(screen.width/2.0)-(width/2.0);y=parseInt(screen.height/2.0)-(height/2.0);resizable=(args&&args['resizable'])?args['resizable']:"no";scrollbars=(args&&args['scrollbars'])?args['scrollbars']:"no";url=tinyMCE.baseURL+"/themes/"+tinyMCE.getParam("theme")+"/"+template['file'];for(var name in args)url=tinyMCE.replaceVar(url,name,escape(args[name]));if(html){html=tinyMCE.replaceVar(html,"css",this.settings['popups_css']);html=tinyMCE.applyTemplate(html,args);var win=window.open("","mcePopup","top="+y+",left="+x+",scrollbars="+scrollbars+",dialog=yes,minimizable="+resizable+",modal=yes,width="+width+",height="+height+",resizable="+resizable);win.document.write(html);win.document.close();win.resizeTo(width,height);win.focus();}else{if(tinyMCE.isMSIE&&resizable!='yes'){var features="resizable:"+resizable+";scroll:"+scrollbars+";status:yes;center:yes;help:no;dialogWidth:"+width+"px;dialogHeight:"+height+"px;";window.showModalDialog(url,window,features);}else{var win=window.open(url,"mcePopup","top="+y+",left="+x+",scrollbars="+scrollbars+",dialog=yes,minimizable="+resizable+",modal=yes,width="+width+",height="+height+",resizable="+resizable);eval('try { win.resizeTo(width, height); } catch(e) { }');win.focus();}}}function TinyMCE_handleVisualAid(element,deep,state){function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";}var tableElement=null;switch(element.nodeName.toLowerCase()){case "table":var cssText=element.getAttribute("border")==0?tinyMCE.settings['visual_table_style']:"";var attribValue=getAttrib(element,"width");if(attribValue=="")attribValue=element.clientWidth;element.setAttribute("width",attribValue);var attribValue=getAttrib(element,"height");if(attribValue=="")attribValue=element.clientHeight;element.setAttribute("height",attribValue);element.style.cssText=state?cssText:"";for(var y=0;y

','g');html_content=html_content.replace(re,"
");}doc.body.innerHTML=html_content;if(tinyMCE.isMSIE&&tinyMCE.settings['fix_content_duplication']){var paras=doc.getElementsByTagName("P");for(var i=0;i<\/o:p>","
");html=tinyMCE.regexpReplace(html," <\/o:p>","");html=tinyMCE.regexpReplace(html,"","");html=tinyMCE.regexpReplace(html,"

<\/p>","");html=tinyMCE.regexpReplace(html,"

<\/p>\r\n

<\/p>","");html=tinyMCE.regexpReplace(html,"

 <\/p>","
");html=tinyMCE.regexpReplace(html,"

\s*(

\s*)?","

");html=tinyMCE.regexpReplace(html,"<\/p>\s*(<\/p>\s*)?","

");}doc.body.innerHTML=html;}}function TinyMCE__getElementById(element_id){var elm=document.getElementById(element_id);if(!elm){for(var j=0;j0){var csses=null;eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(0).rules : doc.styleSheets[0].cssRules;} catch(e) {}");if(!csses)return null;for(var i=0;i0)tinyMCE.cssClasses=output;return output;}function TinyMCE_regexpReplace(in_str,reg_exp,replace_str,opts){if(typeof(opts)=="undefined")opts='g';var re=new RegExp(reg_exp,opts);return in_str.replace(re,replace_str);}function TinyMCE_cleanupEventStr(str){str=""+str;str=str.replace('function anonymous()\n{\n','');str=str.replace('\n}','');return str;}function TinyMCE_getAbsPosition(node){var x=0,y=0;var pos=new Object();var parentNode=node;while(parentNode){x+=parentNode.offsetLeft;y+=parentNode.offsetTop;parentNode=parentNode.offsetParent;}pos.absLeft=x;pos.absTop=y;return pos;}function TinyMCE_openFileBrowser(field_name,url,type,win){var cb=tinyMCE.getParam("file_browser_callback");this.setWindowArg("window",win);if(eval('typeof('+cb+')')=="undefined")alert("Callback function: "+cb+" could not be found.");else eval(cb+"(field_name, url, type, win);");}function TinyMCE_getControlHTML(control_name){var themePlugins=tinyMCE.getParam('plugins','',true,',');var templateFunction;for(var i=themePlugins.length;i>=0;i--){templateFunction='TinyMCE_'+themePlugins[i]+"_getControlHTML";if(eval("typeof("+templateFunction+")")!='undefined'){var html=eval(templateFunction+"('"+control_name+"');");if(html!="")return tinyMCE.replaceVar(html,"pluginurl",tinyMCE.baseURL+"/plugins/"+themePlugins[i]);}}return eval('TinyMCE_'+tinyMCE.settings['theme']+"_getControlHTML"+"('"+control_name+"');");}function TinyMCE__themeExecCommand(editor_id,element,command,user_interface,value){var themePlugins=tinyMCE.getParam('plugins','',true,',');var templateFunction;for(var i=themePlugins.length;i>=0;i--){templateFunction='TinyMCE_'+themePlugins[i]+"_execCommand";if(eval("typeof("+templateFunction+")")!='undefined'){if(eval(templateFunction+"(editor_id, element, command, user_interface, value);"))return true;}}templateFunction='TinyMCE_'+tinyMCE.settings['theme']+"_execCommand";if(eval("typeof("+templateFunction+")")!='undefined')return eval(templateFunction+"(editor_id, element, command, user_interface, value);");return false;}function TinyMCE__getThemeFunction(suffix,skip_plugins){if(skip_plugins)return 'TinyMCE_'+tinyMCE.settings['theme']+suffix;var themePlugins=tinyMCE.getParam('plugins','',true,',');var templateFunction;for(var i=themePlugins.length;i>=0;i--){templateFunction='TinyMCE_'+themePlugins[i]+suffix;if(eval("typeof("+templateFunction+")")!='undefined')return templateFunction;}return 'TinyMCE_'+tinyMCE.settings['theme']+suffix;}function TinyMCEControl(settings){this.undoLevels=new Array();this.undoIndex=0;this.settings=settings;this.settings['theme']=tinyMCE.getParam("theme","default");this.settings['width']=tinyMCE.getParam("width",-1);this.settings['height']=tinyMCE.getParam("height",-1);this.executeCallback=TinyMCEControl_executeCallback;this.fixBrokenURLs=TinyMCEControl_fixBrokenURLs;this.convertAllRelativeURLs=TinyMCEControl_convertAllRelativeURLs;this.execCommand=TinyMCEControl_execCommand;this.queryCommandValue=TinyMCEControl_queryCommandValue;this.queryCommandState=TinyMCEControl_queryCommandState;this.onAdd=TinyMCEControl_onAdd;this.getFocusElement=TinyMCEControl_getFocusElement;this.autoResetDesignMode=TinyMCEControl_autoResetDesignMode;this._insertPara=TinyMCEControl__insertPara;this._insertSpace=TinyMCEControl__insertSpace;this._handleBackSpace=TinyMCEControl__handleBackSpace;this.selectNode=TinyMCEControl_selectNode;this.getBody=TinyMCEControl_getBody;this.getDoc=TinyMCEControl_getDoc;this.getWin=TinyMCEControl_getWin;this.getSel=TinyMCEControl_getSel;this.getRng=TinyMCEControl_getRng;}function TinyMCEControl_executeCallback(param,suffix,mode){function isFunc(func_name){if(func_name==null||func_name=="")return false;return eval("typeof("+func_name+")")!="undefined";}function exec(func_name,args){var str=func_name+'(';for(var i=3;i0)rng.selectNodeContents(nodes[0]);else rng.selectNodeContents(node);}else rng.selectNode(node);if(collapse){if(!to_start&&node.nodeType==3){rng.setStart(node,node.nodeValue.length);rng.setEnd(node,node.nodeValue.length);}else rng.collapse(to_start);}sel.removeAllRanges();sel.addRange(rng);}var pos=tinyMCE.getAbsPosition(node);var doc=this.getDoc();var scrollX=doc.body.scrollLeft+doc.documentElement.scrollLeft;var scrollY=doc.body.scrollTop+doc.documentElement.scrollTop;var height=tinyMCE.isMSIE?document.getElementById(this.editorId).style.pixelHeight:parseInt(this.targetElement.style.height);if(!tinyMCE.settings['auto_resize']&&!(node.absTop>scrollY&&node.absTop<(scrollY-25+height)))this.contentWindow.scrollTo(pos.absLeft,pos.absTop-height+25);tinyMCE.selectedElement=null;if(node.nodeType==1)tinyMCE.selectedElement=node;}function TinyMCEControl_getBody(){return this.getDoc().body;}function TinyMCEControl_getDoc(){return this.contentWindow.document;}function TinyMCEControl_getWin(){return this.contentWindow;}function TinyMCEControl_getSel(){if(tinyMCE.isMSIE)return this.getDoc().selection;return this.contentWindow.getSelection();}function TinyMCEControl_getRng(){var sel=this.getSel();if(sel==null)return null;if(tinyMCE.isMSIE)return sel.createRange();return this.getSel().getRangeAt(0);}function TinyMCEControl__insertPara(){function getNodeText(node){var nodes=tinyMCE.getNodeTree(node,new Array(),3);var text="";for(var i=0;i")paraBefore.innerHTML=" ";if(getNodeText(paraAfter)==""||paraAfter.innerHTML=="
")paraAfter.innerHTML=" ";rngBefore.deleteContents();rng.deleteContents();paraAfter.normalize();rng.insertNode(paraAfter);paraBefore.normalize();rngBefore.insertNode(paraBefore);}else{body.innerHTML="

 

 

";paraAfter=body.childNodes[1];}this.selectNode(paraAfter,true,true);return true;}rngBefore.setStartBefore(startChop);rngBefore.setEnd(startNode,startOffset);paraBefore.appendChild(rngBefore.cloneContents());rngAfter.setEndAfter(endChop);rngAfter.setStart(endNode,endOffset);paraAfter.appendChild(rngAfter.cloneContents());if(getNodeText(paraBefore)==""||paraBefore.innerHTML=="
")paraBefore.innerHTML=" ";if(getNodeText(paraAfter)==""||paraAfter.innerHTML=="
")paraAfter.innerHTML=" ";var rng=doc.createRange();if(!startChop.previousSibling&&startChop.parentNode.nodeName.toLowerCase()=='p')rng.setStartBefore(startChop.parentNode);else{if(rngBefore.startContainer.nodeName.toLowerCase()=='p'&&rngBefore.startOffset==0)rng.setStartBefore(rngBefore.startContainer);else rng.setStart(rngBefore.startContainer,rngBefore.startOffset);}if(!endChop.nextSibling&&endChop.parentNode.nodeName.toLowerCase()=='p')rng.setEndAfter(endChop.parentNode);else rng.setEnd(rngAfter.endContainer,rngAfter.endOffset);rng.deleteContents();rng.insertNode(paraAfter);rng.insertNode(paraBefore);paraAfter.normalize();paraBefore.normalize();this.selectNode(paraAfter,true,true);return true;}function TinyMCEControl__handleBackSpace(evt_type){var doc=this.getDoc();var sel=this.contentWindow.getSelection();if(sel==null)return false;var rng=sel.getRangeAt(0);var node=rng.startContainer;var elm=node.nodeType==3?node.parentNode:node;if(node==null)return;if(elm&&elm.nodeName==""){var para=doc.createElement("p");while(elm.firstChild)para.appendChild(elm.firstChild);elm.parentNode.insertBefore(para,elm);elm.parentNode.removeChild(elm);var rng=rng.cloneRange();rng.setStartBefore(node.nextSibling);rng.setEndAfter(node.nextSibling);rng.extractContents();this.selectNode(node.nextSibling,true,true);}var para=tinyMCE.getParentBlockElement(node);if(para!=null&¶.nodeName.toLowerCase()=='p'&&evt_type=="keypress"){var htm=para.innerHTML;var block=tinyMCE.getParentBlockElement(node);if(htm==""||htm==" "||block.nodeName.toLowerCase()=="li"){var prevElm=para.previousSibling;while(prevElm!=null&&prevElm.nodeType!=1)prevElm=prevElm.previousSibling;if(prevElm==null)return false;var nodes=tinyMCE.getNodeTree(prevElm,new Array(),3);var lastTextNode=nodes.length==0?null:nodes[nodes.length-1];if(lastTextNode!=null)this.selectNode(lastTextNode,true,false,false);para.parentNode.removeChild(para);return true;}}return false;}function TinyMCEControl__insertSpace(){return true;}function TinyMCEControl_autoResetDesignMode(){if(!tinyMCE.isMSIE&&tinyMCE.settings['auto_reset_designmode']){var sel=this.contentWindow.getSelection();if(!sel||!sel.rangeCount||sel.rangeCount==0)eval('try { this.getDoc().designMode = "On"; } catch(e) {}');}}function TinyMCEControl_execCommand(command,user_interface,value){function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";}if(!tinyMCE.isMSIE&&!this.useCSS){this.getDoc().execCommand("useCSS",false,true);this.useCSS=true;}this.contentDocument=this.getDoc();if(tinyMCE._themeExecCommand(this.editorId,this.contentDocument.body,command,user_interface,value))return;if(command!="mceAddUndoLevel"&&command!="Undo"&&command!="Redo"&&command!="mceImage"&&command!="mceLink"&&command!="mceToggleVisualAid"&&(command!="mceInsertTable"&&!user_interface))this.execCommand("mceAddUndoLevel");if(this.getFocusElement()&&this.getFocusElement().nodeName.toLowerCase()=="img"){var align=this.getFocusElement().getAttribute('align');switch(command){case "JustifyLeft":if(align=='left')this.getFocusElement().removeAttribute('align');else this.getFocusElement().setAttribute('align','left');tinyMCE.triggerNodeChange();return;case "JustifyCenter":if(align=='middle')this.getFocusElement().removeAttribute('align');else this.getFocusElement().setAttribute('align','middle');tinyMCE.triggerNodeChange();return;case "JustifyRight":if(align=='right')this.getFocusElement().removeAttribute('align');else this.getFocusElement().setAttribute('align','right');tinyMCE.triggerNodeChange();return;}}if(tinyMCE.settings['force_br_newlines']){var doc=this.getDoc();var alignValue="";if(doc.selection.type!="Control"){switch(command){case "JustifyLeft":alignValue="left";break;case "JustifyCenter":alignValue="center";break;case "JustifyFull":alignValue="justify";break;case "JustifyRight":alignValue="right";break;}if(alignValue!=""){var rng=doc.selection.createRange();if((divElm=tinyMCE.getParentElement(rng.parentElement(),"div"))!=null)divElm.setAttribute("align",alignValue);else if(rng.pasteHTML&&rng.htmlText.length>0)rng.pasteHTML('
'+rng.htmlText+"
");tinyMCE.triggerNodeChange();return;}}}switch(command){case "mceSelectNode":this.selectNode(value);tinyMCE.triggerNodeChange();tinyMCE.selectedNode=value;break;case "mceSelectNodeDepth":var parentNode=this.getFocusElement();for(var i=0;parentNode;i++){if(parentNode.nodeName.toLowerCase()=="body")break;if(parentNode.nodeName.toLowerCase()=="#text"){i--;parentNode=parentNode.parentNode;continue;}if(i==value){this.selectNode(parentNode,false);tinyMCE.triggerNodeChange();tinyMCE.selectedNode=parentNode;return;}parentNode=parentNode.parentNode;}break;case "HiliteColor":if(tinyMCE.isGecko){this.contentDocument.execCommand("useCSS",false,false);this.contentDocument.execCommand('hilitecolor',false,value);this.contentDocument.execCommand("useCSS",false,true);}else this.contentDocument.execCommand('backcolor',false,value);break;case "Cut":case "Copy":case "Paste":var cmdFailed=false;eval('try {this.contentDocument.execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}');if(tinyMCE.isGecko&&cmdFailed){if(confirm(tinyMCE.getLang('lang_clipboard_msg')))window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html','mceExternal');return;}else tinyMCE.triggerNodeChange();break;case "mceLink":var selectedText="";if(tinyMCE.isMSIE){var doc=this.getDoc();var rng=doc.selection.createRange();selectedText=rng.text;}else selectedText=this.contentWindow.getSelection().toString();if(!tinyMCE.linkElement){if((tinyMCE.selectedElement.nodeName.toLowerCase()!="img")&&(selectedText.length<=0))return;}var href="",target="",title="",onclick="",action="insert";if(tinyMCE.selectedElement.nodeName.toLowerCase()=="a")tinyMCE.linkElement=tinyMCE.selectedElement;if(tinyMCE.linkElement!=null&&getAttrib(tinyMCE.linkElement,'href')=="")tinyMCE.linkElement=null;if(tinyMCE.linkElement){href=getAttrib(tinyMCE.linkElement,'href');target=getAttrib(tinyMCE.linkElement,'target');title=getAttrib(tinyMCE.linkElement,'title');onclick=getAttrib(tinyMCE.linkElement,'mce_onclick');if(onclick=="")onclick=getAttrib(tinyMCE.linkElement,'onclick');onclick=tinyMCE.cleanupEventStr(onclick);mceRealHref=getAttrib(tinyMCE.linkElement,'mce_real_href');if(mceRealHref!="")href=mceRealHref;href=eval(tinyMCE.settings['urlconvertor_callback']+"(href, tinyMCE.linkElement, true);");action="update";}if(this.settings['insertlink_callback']){var returnVal=eval(this.settings['insertlink_callback']+"(href, target, title, onclick, action);");if(returnVal&&returnVal['href'])tinyMCE.insertLink(returnVal['href'],returnVal['target'],returnVal['title'],returnVal['onclick']);}else{tinyMCE.openWindow(this.insertLinkTemplate,{href:href,target:target,title:title,onclick:onclick,action:action});}break;case "mceImage":var src="",alt="",border="",hspace="",vspace="",width="",height="",align="";var title="",onmouseover="",onmouseout="",action="insert";if(tinyMCE.selectedElement!=null&&tinyMCE.selectedElement.nodeName.toLowerCase()=="img")tinyMCE.imgElement=tinyMCE.selectedElement;if(tinyMCE.imgElement){var imgName=getAttrib(tinyMCE.imgElement,'name');if(imgName.substring(0,4)=='mce_')return;src=getAttrib(tinyMCE.imgElement,'src');alt=getAttrib(tinyMCE.imgElement,'alt');if(alt=="")alt=getAttrib(tinyMCE.imgElement,'title');border=getAttrib(tinyMCE.imgElement,'border');hspace=getAttrib(tinyMCE.imgElement,'hspace');vspace=getAttrib(tinyMCE.imgElement,'vspace');width=getAttrib(tinyMCE.imgElement,'width');height=getAttrib(tinyMCE.imgElement,'height');align=getAttrib(tinyMCE.imgElement,'align');onmouseover=getAttrib(tinyMCE.imgElement,'onmouseover');onmouseout=getAttrib(tinyMCE.imgElement,'onmouseout');title=getAttrib(tinyMCE.imgElement,'title');onmouseover=tinyMCE.cleanupEventStr(onmouseover);onmouseout=tinyMCE.cleanupEventStr(onmouseout);mceRealSrc=getAttrib(tinyMCE.imgElement,'mce_real_src');if(mceRealSrc!="")src=mceRealSrc;src=eval(tinyMCE.settings['urlconvertor_callback']+"(src, tinyMCE.imgElement, true);");action="update";}if(this.settings['insertimage_callback']){var returnVal=eval(this.settings['insertimage_callback']+"(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);");if(returnVal&&returnVal['src'])tinyMCE.insertImage(returnVal['src'],returnVal['alt'],returnVal['border'],returnVal['hspace'],returnVal['vspace'],returnVal['width'],returnVal['height'],returnVal['align'],returnVal['title'],returnVal['onmouseover'],returnVal['onmouseout']);}else tinyMCE.openWindow(this.insertImageTemplate,{src:src,alt:alt,border:border,hspace:hspace,vspace:vspace,width:width,height:height,align:align,title:title,onmouseover:onmouseover,onmouseout:onmouseout,action:action});break;case "mceCleanupWord":if(tinyMCE.isMSIE){var html=this.contentDocument.body.createTextRange().htmlText;if(html.indexOf('="mso')!=-1){tinyMCE._setHTML(this.contentDocument,this.contentDocument.body.innerHTML);html=tinyMCE._cleanupHTML(this.contentDocument,this.settings,this.contentDocument.body,this.visualAid);}this.contentDocument.body.innerHTML=html;}break;case "mceCleanup":tinyMCE._setHTML(this.contentDocument,this.contentDocument.body.innerHTML);this.contentDocument.body.innerHTML=tinyMCE._cleanupHTML(this.contentDocument,this.settings,this.contentDocument.body,this.visualAid);tinyMCE.triggerNodeChange();break;case "mceAnchor":if(!user_interface){var aElm=tinyMCE.getParentElement(this.getFocusElement(),"a","name");if(aElm){if(value==null||value==""){if(tinyMCE.isMSIE){aElm.outerHTML=aElm.innerHTML;}else{var rng=aElm.ownerDocument.createRange();rng.setStartBefore(aElm);rng.setEndAfter(aElm);rng.deleteContents();rng.insertNode(rng.createContextualFragment(aElm.innerHTML));}}else aElm.setAttribute('name',value);}else{this.contentDocument.execCommand("fontname",false,"#mce_temp_font#");var elementArray=tinyMCE.getElementsByAttributeValue(this.contentDocument.body,"font","face","#mce_temp_font#");for(var x=0;x0){value=tinyMCE.replaceVar(value,"selection",selectedText);tinyMCE.execCommand('mceInsertContent',false,value);}tinyMCE.triggerNodeChange();break;case "mceSetAttribute":if(typeof(value)=='object'){var targetElms=(typeof(value['targets'])=="undefined")?"p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address":value['targets'];var targetNode=tinyMCE.getParentElement(this.getFocusElement(),targetElms);if(targetNode){targetNode.setAttribute(value['name'],value['value']);tinyMCE.triggerNodeChange();}}break;case "mceSetCSSClass":var selectedText=false;if(tinyMCE.isMSIE){var doc=this.getDoc();var rng=doc.selection.createRange();selectedText=(rng.text&&rng.text.length>0);}else selectedText=(this.contentWindow.getSelection().toString().length>0);if(tinyMCE.selectedNode)tinyMCE.selectedElement=tinyMCE.selectedNode;if(selectedText&&!tinyMCE.selectedNode){this.contentDocument.execCommand("removeformat",false,null);this.contentDocument.execCommand("fontname",false,"#mce_temp_font#");var elementArray=tinyMCE.getElementsByAttributeValue(this.contentDocument.body,"font","face","#mce_temp_font#");for(var x=0;xcustomUndoLevels){for(var i=0;i0){this.undoIndex--;this.getBody().innerHTML=this.undoLevels[this.undoIndex];}tinyMCE.triggerNodeChange();}else this.contentDocument.execCommand(command,user_interface,value);break;case "Redo":if(tinyMCE.settings['custom_undo_redo']){if(this.undoIndex<(this.undoLevels.length-1)){this.undoIndex++;this.getBody().innerHTML=this.undoLevels[this.undoIndex];}tinyMCE.triggerNodeChange();}else this.contentDocument.execCommand(command,user_interface,value);break;case "mceToggleVisualAid":this.visualAid=!this.visualAid;tinyMCE.handleVisualAid(this.getBody(),true,this.visualAid);tinyMCE.triggerNodeChange();break;default:this.contentDocument.execCommand(command,user_interface,value);tinyMCE.triggerNodeChange();}}function TinyMCEControl_queryCommandValue(command){return this.getDoc().queryCommandValue(command);}function TinyMCEControl_queryCommandState(command){return this.getDoc().queryCommandState(command);}function TinyMCEControl_onAdd(replace_element,form_element_name,target_document){var targetDoc=target_document?target_document:document;this.targetDoc=targetDoc;tinyMCE.themeURL=tinyMCE.baseURL+"/themes/"+this.settings['theme'];this.settings['themeurl']=tinyMCE.themeURL;if(!replace_element){alert("Error: Could not find the target element.");return false;}var templateFunction=tinyMCE._getThemeFunction('_getInsertLinkTemplate');if(eval("typeof("+templateFunction+")")!='undefined')this.insertLinkTemplate=eval(templateFunction+'(this.settings);');var templateFunction=tinyMCE._getThemeFunction('_getInsertImageTemplate');if(eval("typeof("+templateFunction+")")!='undefined')this.insertImageTemplate=eval(templateFunction+'(this.settings);');var templateFunction=tinyMCE._getThemeFunction('_getEditorTemplate');if(eval("typeof("+templateFunction+")")=='undefined'){alert("Error: Could not find the template function: "+templateFunction);return false;}var editorTemplate=eval(templateFunction+'(this.settings, this.editorId);');var deltaWidth=editorTemplate['delta_width']?editorTemplate['delta_width']:0;var deltaHeight=editorTemplate['delta_height']?editorTemplate['delta_height']:0;var html=''+editorTemplate['html'];var templateFunction=tinyMCE._getThemeFunction('_handleNodeChange',true);if(eval("typeof("+templateFunction+")")!='undefined')this.settings['handleNodeChangeCallback']=templateFunction;html=tinyMCE.replaceVar(html,"editor_id",this.editorId);html=tinyMCE.replaceVar(html,"default_document",tinyMCE.baseURL+"/blank.htm");this.settings['default_document']=tinyMCE.baseURL+"/blank.htm";this.settings['old_width']=this.settings['width'];this.settings['old_height']=this.settings['height'];if(this.settings['width']==-1)this.settings['width']=replace_element.offsetWidth;if(this.settings['height']==-1)this.settings['height']=replace_element.offsetHeight;if(replace_element.offsetWidth==0)this.settings['width']=320;if(replace_element.offsetHeight==0)this.settings['height']=240;this.settings['area_width']=this.settings['width'];this.settings['area_height']=this.settings['height'];this.settings['area_width']+=deltaWidth;this.settings['area_height']+=deltaHeight;if((""+this.settings['width']).indexOf('%')!=-1)this.settings['area_width']="100%";if((""+this.settings['height']).indexOf('%')!=-1)this.settings['area_height']="100%";if((""+replace_element.style.width).indexOf('%')!=-1){this.settings['width']=replace_element.style.width;this.settings['area_width']="100%";}if((""+replace_element.style.height).indexOf('%')!=-1){this.settings['height']=replace_element.style.height;this.settings['area_height']="100%";}html=tinyMCE.applyTemplate(html);this.settings['width']=this.settings['old_width'];this.settings['height']=this.settings['old_height'];this.visualAid=this.settings['visual'];this.formTargetElementId=form_element_name;if(replace_element.nodeName.toLowerCase()=="textarea")this.startContent=replace_element.value;else this.startContent=replace_element.innerHTML;if(replace_element.nodeName.toLowerCase()!="textarea"){this.oldTargetElement=replace_element.cloneNode(true);if(tinyMCE.settings['debug'])html+='';else html+='';html+='';if(!tinyMCE.isMSIE){var rng=replace_element.ownerDocument.createRange();rng.setStartBefore(replace_element);var fragment=rng.createContextualFragment(html);replace_element.parentNode.replaceChild(fragment,replace_element);}else replace_element.outerHTML=html;}else{html+='
';this.oldTargetElement=replace_element;if(!tinyMCE.settings['debug'])this.oldTargetElement.style.display="none";if(!tinyMCE.isMSIE){var rng=replace_element.ownerDocument.createRange();rng.setStartBefore(replace_element);var fragment=rng.createContextualFragment(html);replace_element.parentNode.insertBefore(fragment,replace_element);}else replace_element.insertAdjacentHTML("beforeBegin",html);}var dynamicIFrame=false;var tElm=targetDoc.getElementById(this.editorId);if(!tinyMCE.isMSIE){if(tElm&&tElm.nodeName.toLowerCase()=="span"){tElm=tinyMCE._createIFrame(tElm);dynamicIFrame=true;}this.targetElement=tElm;this.iframeElement=tElm;this.contentDocument=tElm.contentDocument;this.contentWindow=tElm.contentWindow;}else{if(tElm&&tElm.nodeName.toLowerCase()=="span")tElm=tinyMCE._createIFrame(tElm);else tElm=targetDoc.frames[this.editorId];this.targetElement=tElm;this.iframeElement=targetDoc.getElementById(this.editorId);this.contentDocument=tElm.window.document;this.contentWindow=tElm.window;this.contentDocument.designMode="on";}var doc=this.contentDocument;if(dynamicIFrame){var html=""+''+''+''+''+'blank_page'+''+''+''+''+'';try{this.getDoc().designMode="on";doc.open();doc.write(html);doc.close();}catch(e){this.getDoc().location.href=tinyMCE.baseURL+"/blank.htm";}}if(tinyMCE.isMSIE)window.setTimeout("TinyMCE_addEventHandlers('"+this.editorId+"');",1);tinyMCE.setupContent(this.editorId);return true;}function TinyMCEControl_getFocusElement(){if(tinyMCE.isMSIE){var doc=this.getDoc();var rng=doc.selection.createRange();var elm=rng.item?rng.item(0):rng.parentElement();}else{var sel=this.contentWindow.getSelection();var elm=(sel&&sel.anchorNode)?sel.anchorNode:null;if(tinyMCE.selectedElement!=null&&tinyMCE.selectedElement.nodeName.toLowerCase()=="img")elm=tinyMCE.selectedElement;}return elm;}var tinyMCE=new TinyMCE();var tinyMCELang=new Array(); \ No newline at end of file diff --git a/includes/tinymce/jscripts/tiny_mce/tiny_mce_popup.js b/includes/tinymce/jscripts/tiny_mce/tiny_mce_popup.js new file mode 100644 index 00000000..9a347367 --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/tiny_mce_popup.js @@ -0,0 +1,56 @@ +// Get tinyMCE window +var win = window.opener ? window.opener : window.dialogArguments; + +var tinyMCE = null; +var tinyMCELang = null; + +// Use top window if not defined +if (!win) + win = top; + +var tinyMCE = win.tinyMCE; +var tinyMCELang = win.tinyMCELang; + +if (!tinyMCE) + alert("tinyMCE object reference not found from popup."); + +// Setup window openerer +window.opener = win; + +// Setup title +var re = new RegExp('{|\\\$|}', 'g'); +var title = document.title.replace(re, ""); +if (typeof tinyMCELang[title] != "undefined") { + var divElm = document.createElement("div"); + divElm.innerHTML = tinyMCELang[title]; + document.title = divElm.innerHTML; +} + +// Setup dir +if (tinyMCELang['lang_dir']) + document.dir = tinyMCELang['lang_dir']; + +function TinyMCEPlugin_onLoad() { + if (tinyMCE.getWindowArg('mce_replacevariables', true)) + document.body.innerHTML = tinyMCE.applyTemplate(document.body.innerHTML, tinyMCE.windowArgs); + + // Auto resize window + if (tinyMCE.getWindowArg('mce_windowresize', true)) { + var width = tinyMCE.isMSIE ? document.body.offsetWidth : window.innerWidth; + var height = tinyMCE.isMSIE ? document.body.offsetHeight : window.innerHeight; + var dx = document.body.scrollWidth - width; + var dy = document.body.scrollHeight - height; + + if (tinyMCE.isMSIE) { + window.dialogWidth = (parseInt(window.dialogWidth) + dx) + "px"; + window.dialogHeight = (parseInt(window.dialogHeight) + dy + 3) + "px"; + } else + window.resizeBy(dx + 15, dy + 15); + } +} + +// Add onload trigger +tinyMCE.addEvent(window, "load", TinyMCEPlugin_onLoad); + +// Output Popup CSS class +document.write(''); diff --git a/includes/tinymce/jscripts/tiny_mce/tiny_mce_src.js b/includes/tinymce/jscripts/tiny_mce/tiny_mce_src.js new file mode 100644 index 00000000..5cd0176f --- /dev/null +++ b/includes/tinymce/jscripts/tiny_mce/tiny_mce_src.js @@ -0,0 +1,4231 @@ +/** + * $RCSfile: tiny_mce_src.js,v $ + * $Revision: 1.1 $ + * $Date: 2005/03/06 06:22:26 $ + * + * @author Moxiecode + * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved. + */ + +function TinyMCE() { + this.instances = new Array(); + this.stickyClassesLookup = new Array(); + this.windowArgs = new Array(); + + // Browser check + this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); + this.isMSIE5 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5') != -1); + this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1); + this.isGecko = navigator.userAgent.indexOf('Gecko') != -1; + + // TinyMCE editor id instance counter + this.idCounter = 0; + + // Editor functions + this.init = TinyMCE_init; + this.addMCEControl = TinyMCE_addMCEControl; + this.triggerSave = TinyMCE_triggerSave; + this._convertOnClick = TinyMCE__convertOnClick; + this.resetForm = TinyMCE_resetForm; + this.execCommand = TinyMCE_execCommand; + this.execInstanceCommand = TinyMCE_execInstanceCommand; + this._createIFrame = TinyMCE__createIFrame; + this.handleEvent = TinyMCE_handleEvent; + this.setupContent = TinyMCE_setupContent; + this.switchClass = TinyMCE_switchClass; + this.restoreAndSwitchClass = TinyMCE_restoreAndSwitchClass; + this.switchClassSticky = TinyMCE_switchClassSticky; + this.restoreClass = TinyMCE_restoreClass; + this.setClassLock = TinyMCE_setClassLock; + this.addEvent = TinyMCE_addEvent; + this.onLoad = TinyMCE_onLoad; + this.removeMCEControl = TinyMCE_removeMCEControl; + this._initCleanup = TinyMCE__initCleanup; + this._cleanupHTML = TinyMCE__cleanupHTML; + this._cleanupAttribute = TinyMCE__cleanupAttribute; + this._fixInlineStyles = TinyMCE__fixInlineStyles; + this._cleanupElementName = TinyMCE__cleanupElementName; + this._verifyClass = TinyMCE__verifyClass; + this.cleanupNode = TinyMCE_cleanupNode; + this.convertStringToXML = TinyMCE_convertStringToXML; + this.insertLink = TinyMCE_insertLink; + this.insertImage = TinyMCE_insertImage; + this.getElementByAttributeValue = TinyMCE_getElementByAttributeValue; + this.getElementsByAttributeValue = TinyMCE_getElementsByAttributeValue; + this.isBlockElement = TinyMCE_isBlockElement; + this.getParentBlockElement = TinyMCE_getParentBlockElement; + this.getNodeTree = TinyMCE_getNodeTree; + this.getParentElement = TinyMCE_getParentElement; + this.getParam = TinyMCE_getParam; + this.getLang = TinyMCE_getLang; + this.replaceVar = TinyMCE_replaceVar; + this.replaceVars = TinyMCE_replaceVars; + this.triggerNodeChange = TinyMCE_triggerNodeChange; + this.parseURL = TinyMCE_parseURL; + this.convertAbsoluteURLToRelativeURL = TinyMCE_convertAbsoluteURLToRelativeURL; + this.convertRelativeToAbsoluteURL = TinyMCE_convertRelativeToAbsoluteURL; + this.updateContent = TinyMCE_updateContent; + this._customCleanup = TinyMCE__customCleanup; + this.getContent = TinyMCE_getContent; + this.setContent = TinyMCE_setContent; + this.importThemeLanguagePack = TinyMCE_importThemeLanguagePack; + this.importPluginLanguagePack = TinyMCE_importPluginLanguagePack; + this.applyTemplate = TinyMCE_applyTemplate; + this.openWindow = TinyMCE_openWindow; + this.handleVisualAid = TinyMCE_handleVisualAid; + this.setAttrib = TinyMCE_setAttrib; + this.getAttrib = TinyMCE_getAttrib; + this._getThemeFunction = TinyMCE__getThemeFunction; + this._themeExecCommand = TinyMCE__themeExecCommand; + this.getControlHTML = TinyMCE_getControlHTML; + this._setHTML = TinyMCE__setHTML; + this._getElementById = TinyMCE__getElementById; + this.getInstanceById = TinyMCE_getInstanceById; + this.getEditorId = TinyMCE_getEditorId; + this.queryInstanceCommandValue = TinyMCE_queryInstanceCommandValue; + this.queryInstanceCommandState = TinyMCE_queryInstanceCommandState; + this.getWindowArg = TinyMCE_getWindowArg; + this.setWindowArg = TinyMCE_setWindowArg; + this.getCSSClasses = TinyMCE_getCSSClasses; + this.regexpReplace = TinyMCE_regexpReplace; + this.cleanupEventStr = TinyMCE_cleanupEventStr; + this.getAbsPosition = TinyMCE_getAbsPosition; + this.openFileBrowser = TinyMCE_openFileBrowser; +} + +function TinyMCE_init(settings) { + var theme, srcMode; + + this.settings = settings; + + function defParam(key, def_val) { + settings[key] = tinyMCE.getParam(key, def_val); + } + + // Check if valid browser has execcommand support + if (typeof(document.execCommand) == 'undefined') + return; + + // Get script base path + if (!tinyMCE.baseURL) { + var elements = document.getElementsByTagName('script'); + + for (var i=0; i'); + document.write(''); + document.write(''); + + // Add theme plugins + var themePlugins = tinyMCE.getParam('plugins', '', true, ','); + if (this.settings['plugins'] != '') { + for (var i=0; i'); + } +} + +function TinyMCE_confirmAdd(e) { + var elm = tinyMCE.isMSIE ? event.srcElement : e.target; + var elementId = elm.name ? elm.name : elm.id; + + if (!targetElement.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm'])) + tinyMCE.addMCEControl(elm, elementId); + else + targetElement.setAttribute('mce_noask', 'true'); +} + +function TinyMCE_updateContent(form_element_name) { + // Find MCE instance linked to given form element and copy it's value + var formElement = document.getElementById(form_element_name); + for (var n in tinyMCE.instances) { + var inst = tinyMCE.instances[n]; + if (inst.formElement == formElement) { + var doc = inst.getDoc(); + + tinyMCE._setHTML(doc, inst.formElement.value); + + if (!tinyMCE.isMSIE) + doc.body.innerHTML = tinyMCE._cleanupHTML(doc, this.settings, doc.body, inst.visualAid); + } + } +} + +function TinyMCE_addMCEControl(replace_element, form_element_name, target_document) { + var id = "mce_editor_" + tinyMCE.idCounter++; + var inst = new TinyMCEControl(tinyMCE.settings); + + inst.editorId = id; + this.instances[id] = inst; + + inst.onAdd(replace_element, form_element_name, target_document); +} + +function TinyMCE_triggerSave(skip_cleanup, skip_callback) { + // Cleanup and set all form fields + for (var n in tinyMCE.instances) { + var inst = tinyMCE.instances[n]; + tinyMCE.settings['preformatted'] = false; + + // Default to false + if (typeof(skip_cleanup) == "undefined") + skip_cleanup = false; + + // Default to false + if (typeof(skip_callback) == "undefined") + skip_callback = false; + + tinyMCE._setHTML(inst.getDoc(), inst.getBody().innerHTML); + + var htm = skip_cleanup ? inst.getBody().innerHTML : tinyMCE._cleanupHTML(inst.getDoc(), this.settings, inst.getBody(), this.visualAid, true); + + //var htm = tinyMCE._cleanupHTML(inst.getDoc(), tinyMCE.settings, inst.getBody(), false, true); + + if (tinyMCE.settings["encoding"] == "xml" || tinyMCE.settings["encoding"] == "html") + htm = tinyMCE.convertStringToXML(htm); + + if (!skip_callback && tinyMCE.settings['save_callback'] != "") + var content = eval(tinyMCE.settings['save_callback'] + "(inst.formTargetElementId,htm,inst.getBody());"); + + // Use callback content if available + if ((typeof(content) != "undefined") && content != null) + htm = content; + + // Replace some weird entities (Bug: #1056343) + htm = tinyMCE.regexpReplace(htm, "(", "(", "gi"); + htm = tinyMCE.regexpReplace(htm, ")", ")", "gi"); + htm = tinyMCE.regexpReplace(htm, ";", ";", "gi"); + htm = tinyMCE.regexpReplace(htm, """, """, "gi"); + htm = tinyMCE.regexpReplace(htm, "^", "^", "gi"); + + inst.formElement.value = htm; + } +} + +function TinyMCE__convertOnClick(node) { + // Skip on MSIE < 6+ + if (tinyMCE.isMSIE5) + return; + + // Convert all onclick to mce_onclick + var elms = node.getElementsByTagName("a"); + for (var i=0; i", "gi"); + content = tinyMCE.regexpReplace(content, "\r", "
", "gi"); + content = tinyMCE.regexpReplace(content, "\n", "
", "gi"); + } + + // Call custom cleanup code + content = tinyMCE._customCleanup("insert_to_editor", content); + + if (tinyMCE.isMSIE) { + var styleSheet = document.frames[editor_id].document.createStyleSheet(inst.settings['content_css']); + + // Ugly!!! + window.setInterval('try{tinyMCE.getCSSClasses(document.frames["' + editor_id + '"].document, "' + editor_id + '");}catch(e){}', 500); + + if (tinyMCE.settings["force_br_newlines"]) + document.frames[editor_id].document.styleSheets[0].addRule("p", "margin: 0px;"); + + var patchFunc = function() { + var event = document.frames[editor_id].event; + event.target = document.frames[editor_id].document; + + TinyMCE_handleEvent(event); + }; + + var body = document.frames[editor_id].document.body; + + body.onbeforepaste = patchFunc; + body.onbeforecut = patchFunc; + body.onpaste = patchFunc; + body.editorId = editor_id; + } else { + // Import editor css + var cssImporter = doc.createElement("link"); + cssImporter.rel = "stylesheet"; + cssImporter.href = inst.settings['content_css']; + if (headArr = doc.getElementsByTagName("head")); + headArr[0].appendChild(cssImporter); + } + + // Fix for bug #958637 + if (!tinyMCE.isMSIE) { + var contentElement = inst.getDoc().createElement("body"); + var doc = inst.getDoc(); + + contentElement.innerHTML = content; + + // Remove weridness! + if (tinyMCE.settings['force_p_newlines']) + content = content.replace(new RegExp('<>', 'g'), ""); + + if (tinyMCE.settings['cleanup_on_startup']) + inst.getBody().innerHTML = tinyMCE._cleanupHTML(doc, this.settings, contentElement); + else { + // Convert all strong/em to b/i + content = tinyMCE.regexpReplace(content, "", "", "gi"); + content = tinyMCE.regexpReplace(content, "", "", "gi"); + inst.getBody().innerHTML = contentElement.innerHTML; + } + + inst.convertAllRelativeURLs(); + } else { + if (tinyMCE.settings['cleanup_on_startup']) { + tinyMCE._setHTML(inst.getDoc(), content); + // Produces permission denied error in MSIE 5.5 + eval('try {inst.getBody().innerHTML = tinyMCE._cleanupHTML(inst.contentDocument, this.settings, inst.getBody());} catch(e) {}'); + } else + inst.getBody().innerHTML = content; + } + + tinyMCE._convertOnClick(inst.getBody()); + + // Fix for bug #957681 + //inst.getDoc().designMode = inst.getDoc().designMode; + + // Setup element references + var parentElm = document.getElementById(inst.editorId + '_parent'); + if (parentElm.lastChild.nodeName.toLowerCase() == "input") + inst.formElement = parentElm.lastChild; + else + inst.formElement = parentElm.nextSibling; + + tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual']); + inst.executeCallback('setupcontent_callback', '_setupContent', 0, editor_id, inst.getBody(), inst.getDoc()); + + // Re-add design mode on mozilla + if (!tinyMCE.isMSIE) + TinyMCE_addEventHandlers(editor_id); + + // Trigger node change + tinyMCE.selectedInstance = inst; + inst.selectNode(inst.getBody(), true, true); + tinyMCE.triggerNodeChange(false); +} + +function TinyMCE_handleEvent(e) { + //window.status = e.type + " " + e.target.nodeName + " " + (e.relatedTarget ? e.relatedTarget.nodeName : ""); + + switch (e.type) { + case "submit": + var formObj = tinyMCE.isMSIE ? window.event.srcElement : e.target; + + // Disable all UI form elements that TinyMCE created + for (var i=0; i"); + rng.collapse(false); + rng.select(); + + tinyMCE.triggerNodeChange(false); + return false; + } + } + + // Backspace or delete + if (e.keyCode == 8 || e.keyCode == 46) { + tinyMCE.selectedElement = e.target; + tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a"); + tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img"); + tinyMCE.triggerNodeChange(false); + } + + return false; + break; + + case "keyup": + case "keydown": + if (e.target.editorId) + tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId]; + else + return; + + // Handle backspace + if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) { + // Insert P element instead of BR + if (tinyMCE.selectedInstance._handleBackSpace(e.type)) { + // Cancel event + e.preventDefault(); + return false; + } + } + + tinyMCE.selectedElement = null; + tinyMCE.selectedNode = null; + var elm = tinyMCE.selectedInstance.getFocusElement(); + tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a"); + tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img"); + tinyMCE.selectedElement = elm; + + // Update visualaids on tabs + if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9) + tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual']); + + // Run image/link fix on Gecko if diffrent document base on paste + if (tinyMCE.isGecko && tinyMCE.settings['document_base_url'] != "" + document.location.href && e.type == "keyup" && e.ctrlKey && e.keyCode == 86) + tinyMCE.selectedInstance.fixBrokenURLs(); + + // Insert space instead of   +/* if (e.type == "keydown" && e.keyCode == 32) { + if (tinyMCE.selectedInstance._insertSpace()) { + // Cancel event + e.returnValue = false; + e.cancelBubble = true; + return false; + } + }*/ + + // MSIE custom key handling + if (tinyMCE.isMSIE && tinyMCE.settings['custom_undo_redo']) { + // Check if it's a position key press + var keys = new Array(13,45,36,35,33,34,37,38,39,40); + var posKey = false; + for (var i=0; i 18 && e.keyCode != 255)) { + tinyMCE.selectedInstance.execCommand("mceAddUndoLevel"); + tinyMCE.selectedInstance.typing = true; + tinyMCE.triggerNodeChange(false); + } + + if (posKey && e.type == "keyup") + tinyMCE.triggerNodeChange(false); + + var ctrlKeys = new Array(66,73,85,86,88); // B/I/U/V/X + var keys = new Array(8,46); // Backspace,Delete + for (var i=0; i 0) { + for (var i=0; i "; + + // Is MSIE script element + if (tinyMCE.isMSIE && elementName == "script") + return "<" + elementName + elementAttribs + ">" + node.text + ""; + + // Clean up children + if (node.hasChildNodes()) { + // Force BR + if (elementName == "p" && tinyMCE.cleanup_force_br_newlines) + output += ""; + else + output += "<" + elementName + elementAttribs + ">"; + + for (var i=0; i"; + } else { + // Allways leave anchor elements open + if (elementName == "a") + output += "<" + elementName + elementAttribs + ">"; + else { + // No children + output += "<" + elementName + elementAttribs + " />"; + } + } + + return output; + + case 3: // Text + // Do not convert script elements + if (node.parentNode.nodeName.toLowerCase() == "script") + return node.nodeValue; + + return this.convertStringToXML(node.nodeValue); + + case 8: // Comment + return ""; + + default: // Unknown + return "[UNKNOWN NODETYPE " + node.nodeType + "]"; + } +} + +function TinyMCE_convertStringToXML(html_data) { + var output = ""; + + for (var i=0; i', '', 'gi'); + + var html = this.cleanupNode(element); + + if (tinyMCE.settings['debug']) + alert("Cleanup process executed in: " + (new Date().getTime()-startTime) + " ms."); + + // Remove pesky HR paragraphs + html = tinyMCE.regexpReplace(html, '


', '
'); + html = tinyMCE.regexpReplace(html, '

 


 

', '
'); + + // Remove some mozilla crap + if (!tinyMCE.isMSIE) + html = html.replace(new RegExp('', 'g'), ""); + + if (tinyMCE.settings['apply_source_formatting']) { + html = html.replace(new RegExp('<(p|div)([^>]*)>', 'g'), "\n<$1$2>\n"); + html = html.replace(new RegExp('<\/(p|div)([^>]*)>', 'g'), "\n\n"); + html = html.replace(new RegExp('
', 'g'), "
\n"); + } + + if (tinyMCE.settings['force_br_newlines']) { + var re = new RegExp('

 

', 'g'); + html = html.replace(re, "
"); + } + + if (tinyMCE.settings['force_p_newlines']) { + // Remove weridness! + var re = new RegExp('<>', 'g'); + html = html.replace(re, ""); + } + + // Emtpy node, return empty + if (html == "
" || html == "

 

") + html = ""; + + // Call custom cleanup code + html = tinyMCE._customCleanup(on_save ? "get_from_editor" : "insert_to_editor", html); + + if (tinyMCE.settings["preformatted"]) + return "
" + html + "
"; + + return html; +} + +function TinyMCE_insertLink(href, target, title, onclick) { + function setAttrib(element, name, value) { + if (value != null && value != "") + element.setAttribute(name, value); + else + element.removeAttribute(name); + } + + this.execCommand("mceAddUndoLevel"); + + if (this.selectedInstance && this.selectedElement && this.selectedElement.nodeName.toLowerCase() == "img") { + var doc = this.selectedInstance.getDoc(); + + var linkElement = doc.createElement("a"); + + href = eval(tinyMCE.settings['urlconvertor_callback'] + "(href, linkElement);"); + setAttrib(linkElement, 'href', href); + setAttrib(linkElement, 'target', target); + setAttrib(linkElement, 'title', title); + setAttrib(linkElement, 'mce_onclick', onclick); + + linkElement.appendChild(this.selectedElement.cloneNode(true)); + + this.selectedElement.parentNode.replaceChild(linkElement, this.selectedElement); + + return; + } + + if (!this.linkElement && this.selectedInstance) { + this.selectedInstance.contentDocument.execCommand("createlink", false, "#mce_temp_url#"); + tinyMCE.linkElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", "#mce_temp_url#"); + + var elementArray = this.getElementsByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", "#mce_temp_url#"); + + for (var i=0; i= strTok2.length) { + for (var i=0; i= strTok2.length || strTok1[i] != strTok2[i]) { + breakPoint = i + 1; + break; + } + } + } + + if (strTok1.length < strTok2.length) { + for (var i=0; i= strTok1.length || strTok1[i] != strTok2[i]) { + breakPoint = i + 1; + break; + } + } + } + + if (breakPoint == 1) + return url_to_relative; + + for (var i=0; i<(strTok1.length-(breakPoint-1)); i++) + outputString += "../"; + + for (var i=breakPoint-1; i=0; i--) { + if (baseURLParts[i].length == 0) + continue; + + newBaseURLParts[newBaseURLParts.length] = baseURLParts[i]; + } + baseURLParts = newBaseURLParts.reverse(); + + // Merge relURLParts chunks + var newRelURLParts = new Array(); + var numBack = 0; + for (var i=relURLParts.length-1; i>=0; i--) { + if (relURLParts[i].length == 0 || relURLParts[i] == ".") + continue; + + if (relURLParts[i] == '..') { + numBack++; + continue; + } + + if (numBack > 0) { + numBack--; + continue; + } + + newRelURLParts[newRelURLParts.length] = relURLParts[i]; + } + + relURLParts = newRelURLParts.reverse(); + + // Remove end from absolute path + var len = baseURLParts.length-numBack; + var absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/'); + var start = "", end = ""; + + // Build start part + if (baseURL['protocol']) + start += baseURL['protocol'] + "://"; + + if (baseURL['host']) + start += baseURL['host']; + + if (baseURL['port']) + start += ":" + baseURL['port']; + + // Build end part + if (relURL['query']) + end += "?" + relURL['query']; + + if (relURL['anchor']) + end += "#" + relURL['anchor']; + + return start + absPath + end; +} + +function TinyMCE_getParam(name, default_value, strip_whitespace, split_chr) { + var value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name]; + + // Fix bool values + if (value == "true" || value == "false") + return (value == "true"); + + if (strip_whitespace) + value = tinyMCE.regexpReplace(value, "[ \t\r\n]", ""); + + if (typeof(split_chr) != "undefined" && split_chr != null) { + value = value.split(split_chr); + var outArray = new Array(); + + for (var i=0; i 0); + + if (tinyMCE.settings['custom_undo_redo']) { + undoIndex = inst.undoIndex; + undoLevels = inst.undoLevels.length; + } + + inst.executeCallback('handleNodeChangeCallback', '_handleNodeChange', 0, editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection); + } + } + + if (this.selectedInstance && (typeof(focus) == "undefined" || focus)) + this.selectedInstance.contentWindow.focus(); +} + +function TinyMCE__customCleanup(type, content) { + // Call custom cleanup + var customCleanup = tinyMCE.settings['cleanup_callback']; + if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined") + content = eval(customCleanup + "(type, content);"); + + // Trigger plugin cleanups + var plugins = tinyMCE.getParam('plugins', '', true, ','); + for (var i=0; i'); +} + +function TinyMCE_importPluginLanguagePack(name, valid_languages) { + var lang = "en"; + + valid_languages = valid_languages.split(','); + for (var i=0; i'); +} + +/** + * Adds themeurl, settings and lang to HTML code. + */ +function TinyMCE_applyTemplate(html, args) { + html = tinyMCE.replaceVar(html, "themeurl", tinyMCE.themeURL); + + if (typeof(args) != "undefined") + html = tinyMCE.replaceVars(html, args); + + html = tinyMCE.replaceVars(html, tinyMCE.settings); + html = tinyMCE.replaceVars(html, tinyMCELang); + + return html; +} + +function TinyMCE_openWindow(template, args) { + var html, width, height, x, y, resizable, scrollbars, url; + + args['mce_template_file'] = template['file']; + tinyMCE.windowArgs = args; + + html = template['html']; + if (!(width = template['width'])) + width = 320; + + if (!(height = template['height'])) + height = 200; + + // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!! + if (tinyMCE.isMSIE) + height += 30; + + x = parseInt(screen.width / 2.0) - (width / 2.0); + y = parseInt(screen.height / 2.0) - (height / 2.0); + + resizable = (args && args['resizable']) ? args['resizable'] : "no"; + scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no"; + url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file']; + + // Replace all args as variables in URL + for (var name in args) + url = tinyMCE.replaceVar(url, name, escape(args[name])); + + if (html) { + html = tinyMCE.replaceVar(html, "css", this.settings['popups_css']); + html = tinyMCE.applyTemplate(html, args); + + var win = window.open("", "mcePopup", "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable); + win.document.write(html); + win.document.close(); + win.resizeTo(width, height); + win.focus(); + } else { + if (tinyMCE.isMSIE && resizable != 'yes') { + var features = "resizable:" + resizable + + ";scroll:" + + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" + + width + "px;dialogHeight:" + height + "px;"; + + window.showModalDialog(url, window, features); + } else { + var win = window.open(url, "mcePopup", "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable); + eval('try { win.resizeTo(width, height); } catch(e) { }'); + win.focus(); + } + } +} + +function TinyMCE_handleVisualAid(element, deep, state) { + function getAttrib(elm, name) { + return elm.getAttribute(name) ? elm.getAttribute(name) : ""; + } + + var tableElement = null; + + switch (element.nodeName.toLowerCase()) { + case "table": + var cssText = element.getAttribute("border") == 0 ? tinyMCE.settings['visual_table_style'] : ""; + + // Fix width + var attribValue = getAttrib(element, "width"); + if (attribValue == "") + attribValue = element.clientWidth; + element.setAttribute("width", attribValue); + + // Fix height + var attribValue = getAttrib(element, "height"); + if (attribValue == "") + attribValue = element.clientHeight; + element.setAttribute("height", attribValue); + + element.style.cssText = state ? cssText : ""; + + for (var y=0; y'; + return; + } + + break;*/ + } + + if (deep && element.hasChildNodes()) { + for (var i=0; i

breaks runtime? + if (tinyMCE.isMSIE) { + var re = new RegExp('


', 'g'); + html_content = html_content.replace(re, "
"); + } + + doc.body.innerHTML = html_content; + + // Content duplication bug fix + if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) { + // Remove P elements in P elements + var paras = doc.getElementsByTagName("P"); + for (var i=0; i<\/o:p>", "
"); + html = tinyMCE.regexpReplace(html, " <\/o:p>", ""); + html = tinyMCE.regexpReplace(html, "", ""); + html = tinyMCE.regexpReplace(html, "

<\/p>", ""); + html = tinyMCE.regexpReplace(html, "

<\/p>\r\n

<\/p>", ""); + html = tinyMCE.regexpReplace(html, "

 <\/p>", "
"); + html = tinyMCE.regexpReplace(html, "

\s*(

\s*)?", "

"); + html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "

"); + } + + // Always set the htmlText output + doc.body.innerHTML = html; + } +} + +function TinyMCE__getElementById(element_id) { + var elm = document.getElementById(element_id); + if (!elm) { + // Check for element in forms + for (var j=0; j 0) { + var csses = null; + + // Just ignore any errors + eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(0).rules : doc.styleSheets[0].cssRules;} catch(e) {}"); + if (!csses) + return null; + + for (var i=0; i 0) + tinyMCE.cssClasses = output; + + return output; +} + +function TinyMCE_regexpReplace(in_str, reg_exp, replace_str, opts) { + if (typeof(opts) == "undefined") + opts = 'g'; + + var re = new RegExp(reg_exp, opts); + return in_str.replace(re, replace_str); +} + +function TinyMCE_cleanupEventStr(str) { + str = "" + str; + str = str.replace('function anonymous()\n{\n', ''); + str = str.replace('\n}', ''); + + return str; +} + +function TinyMCE_getAbsPosition(node) { + var x = 0, y = 0; + var pos = new Object(); + + var parentNode = node; + while (parentNode) { + x += parentNode.offsetLeft; + y += parentNode.offsetTop; + + parentNode = parentNode.offsetParent; + } + + pos.absLeft = x; + pos.absTop = y; + + return pos; +} + +function TinyMCE_openFileBrowser(field_name, url, type, win) { + var cb = tinyMCE.getParam("file_browser_callback"); + + this.setWindowArg("window", win); + + // Call to external callback + if(eval('typeof('+cb+')') == "undefined") + alert("Callback function: " + cb + " could not be found."); + else + eval(cb + "(field_name, url, type, win);"); +} + +function TinyMCE_getControlHTML(control_name) { + var themePlugins = tinyMCE.getParam('plugins', '', true, ','); + var templateFunction; + + // Is it defined in any plugins + for (var i=themePlugins.length; i>=0; i--) { + templateFunction = 'TinyMCE_' + themePlugins[i] + "_getControlHTML"; + if (eval("typeof(" + templateFunction + ")") != 'undefined') { + var html = eval(templateFunction + "('" + control_name + "');"); + if (html != "") + return tinyMCE.replaceVar(html, "pluginurl", tinyMCE.baseURL + "/plugins/" + themePlugins[i]); + } + } + + return eval('TinyMCE_' + tinyMCE.settings['theme'] + "_getControlHTML" + "('" + control_name + "');"); +} + +function TinyMCE__themeExecCommand(editor_id, element, command, user_interface, value) { + var themePlugins = tinyMCE.getParam('plugins', '', true, ','); + var templateFunction; + + // Is it defined in any plugins + for (var i=themePlugins.length; i>=0; i--) { + templateFunction = 'TinyMCE_' + themePlugins[i] + "_execCommand"; + if (eval("typeof(" + templateFunction + ")") != 'undefined') { + if (eval(templateFunction + "(editor_id, element, command, user_interface, value);")) + return true; + } + } + + // Theme funtion + templateFunction = 'TinyMCE_' + tinyMCE.settings['theme'] + "_execCommand"; + if (eval("typeof(" + templateFunction + ")") != 'undefined') + return eval(templateFunction + "(editor_id, element, command, user_interface, value);"); + + // Pass to normal + return false; +} + +function TinyMCE__getThemeFunction(suffix, skip_plugins) { + if (skip_plugins) + return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix; + + var themePlugins = tinyMCE.getParam('plugins', '', true, ','); + var templateFunction; + + // Is it defined in any plugins + for (var i=themePlugins.length; i>=0; i--) { + templateFunction = 'TinyMCE_' + themePlugins[i] + suffix; + if (eval("typeof(" + templateFunction + ")") != 'undefined') + return templateFunction; + } + + return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix; +} + +// TinyMCEControl +function TinyMCEControl(settings) { + // Undo levels + this.undoLevels = new Array(); + this.undoIndex = 0; + + // Default settings + this.settings = settings; + this.settings['theme'] = tinyMCE.getParam("theme", "default"); + this.settings['width'] = tinyMCE.getParam("width", -1); + this.settings['height'] = tinyMCE.getParam("height", -1); + + // Functions + this.executeCallback = TinyMCEControl_executeCallback; + this.fixBrokenURLs = TinyMCEControl_fixBrokenURLs; + this.convertAllRelativeURLs = TinyMCEControl_convertAllRelativeURLs; + this.execCommand = TinyMCEControl_execCommand; + this.queryCommandValue = TinyMCEControl_queryCommandValue; + this.queryCommandState = TinyMCEControl_queryCommandState; + this.onAdd = TinyMCEControl_onAdd; + this.getFocusElement = TinyMCEControl_getFocusElement; + this.autoResetDesignMode = TinyMCEControl_autoResetDesignMode; + this._insertPara = TinyMCEControl__insertPara; + this._insertSpace = TinyMCEControl__insertSpace; + this._handleBackSpace = TinyMCEControl__handleBackSpace; + this.selectNode = TinyMCEControl_selectNode; + this.getBody = TinyMCEControl_getBody; + this.getDoc = TinyMCEControl_getDoc; + this.getWin = TinyMCEControl_getWin; + this.getSel = TinyMCEControl_getSel; + this.getRng = TinyMCEControl_getRng; +} + +function TinyMCEControl_executeCallback(param, suffix, mode) { + function isFunc(func_name) { + if (func_name == null || func_name == "") + return false; + + return eval("typeof(" + func_name + ")") != "undefined"; + } + + function exec(func_name, args) { + var str = func_name + '('; + + // Add all arguments + for (var i=3; i 0) + rng.selectNodeContents(nodes[0]); + else + rng.selectNodeContents(node); + } else + rng.selectNode(node); + + if (collapse) { + // Special treatment of textnode collapse + if (!to_start && node.nodeType == 3) { + rng.setStart(node, node.nodeValue.length); + rng.setEnd(node, node.nodeValue.length); + } else + rng.collapse(to_start); + } + + sel.removeAllRanges(); + sel.addRange(rng); + } + + // Scroll to node position + var pos = tinyMCE.getAbsPosition(node); + var doc = this.getDoc(); + var scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft; + var scrollY = doc.body.scrollTop + doc.documentElement.scrollTop; + var height = tinyMCE.isMSIE ? document.getElementById(this.editorId).style.pixelHeight : parseInt(this.targetElement.style.height); + + // Only scroll if out of visible area + if (!tinyMCE.settings['auto_resize'] && !(node.absTop > scrollY && node.absTop < (scrollY - 25 + height))) + this.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25); + + // Set selected element + tinyMCE.selectedElement = null; + if (node.nodeType == 1) + tinyMCE.selectedElement = node; +} + +function TinyMCEControl_getBody() { + return this.getDoc().body; +} + +function TinyMCEControl_getDoc() { + return this.contentWindow.document; +} + +function TinyMCEControl_getWin() { + return this.contentWindow; +} + +function TinyMCEControl_getSel() { + if (tinyMCE.isMSIE) + return this.getDoc().selection; + + return this.contentWindow.getSelection(); +} + +function TinyMCEControl_getRng() { + var sel = this.getSel(); + if (sel == null) + return null; + + if (tinyMCE.isMSIE) + return sel.createRange(); + + return this.getSel().getRangeAt(0); +} + +function TinyMCEControl__insertPara() { + function getNodeText(node) { + var nodes = tinyMCE.getNodeTree(node, new Array(), 3); + var text = ""; + + for (var i=0; i") + paraBefore.innerHTML = " "; + + // Check if it's a empty paragraph + if (getNodeText(paraAfter) == "" || paraAfter.innerHTML == "
") + paraAfter.innerHTML = " "; + + // Delete old contents + rngBefore.deleteContents(); + rng.deleteContents(); + + // Insert new paragraphs + paraAfter.normalize(); + rng.insertNode(paraAfter); + paraBefore.normalize(); + rngBefore.insertNode(paraBefore); + } else { + body.innerHTML = "

 

 

"; + paraAfter = body.childNodes[1]; + } + + this.selectNode(paraAfter, true, true); + + //showHTML(this.getBody().innerHTML); + + return true; + } + + // Place first part within new paragraph + rngBefore.setStartBefore(startChop); + rngBefore.setEnd(startNode, startOffset); + paraBefore.appendChild(rngBefore.cloneContents()); + + // Place secound part within new paragraph + rngAfter.setEndAfter(endChop); + rngAfter.setStart(endNode, endOffset); + paraAfter.appendChild(rngAfter.cloneContents()); + + // Check if it's a empty paragraph + if (getNodeText(paraBefore) == "" || paraBefore.innerHTML == "
") + paraBefore.innerHTML = " "; + + // Check if it's a empty paragraph + if (getNodeText(paraAfter) == "" || paraAfter.innerHTML == "
") + paraAfter.innerHTML = " "; + + // Create a range around everything + var rng = doc.createRange(); + + if (!startChop.previousSibling && startChop.parentNode.nodeName.toLowerCase() == 'p') + rng.setStartBefore(startChop.parentNode); + else { + if (rngBefore.startContainer.nodeName.toLowerCase() == 'p' && rngBefore.startOffset == 0) + rng.setStartBefore(rngBefore.startContainer); + else + rng.setStart(rngBefore.startContainer, rngBefore.startOffset); + } + + if (!endChop.nextSibling && endChop.parentNode.nodeName.toLowerCase() == 'p') + rng.setEndAfter(endChop.parentNode); + else + rng.setEnd(rngAfter.endContainer, rngAfter.endOffset); + + // Delete all contents and insert new paragraphs + rng.deleteContents(); + rng.insertNode(paraAfter); + rng.insertNode(paraBefore); + + paraAfter.normalize(); + paraBefore.normalize(); + + this.selectNode(paraAfter, true, true); + //showHTML(this.getBody().innerHTML); + + return true; +} + +function TinyMCEControl__handleBackSpace(evt_type) { + var doc = this.getDoc(); + var sel = this.contentWindow.getSelection(); + if (sel == null) + return false; + + var rng = sel.getRangeAt(0); + var node = rng.startContainer; + var elm = node.nodeType == 3 ? node.parentNode : node; + + if (node == null) + return; + + // Empty node, wrap contents in paragraph + if (elm && elm.nodeName == "") { + var para = doc.createElement("p"); + + while (elm.firstChild) + para.appendChild(elm.firstChild); + + elm.parentNode.insertBefore(para, elm); + elm.parentNode.removeChild(elm); + + var rng = rng.cloneRange(); + rng.setStartBefore(node.nextSibling); + rng.setEndAfter(node.nextSibling); + rng.extractContents(); + + this.selectNode(node.nextSibling, true, true); + } + + // Remove empty paragraphs + var para = tinyMCE.getParentBlockElement(node); + if (para != null && para.nodeName.toLowerCase() == 'p' && evt_type == "keypress") { + var htm = para.innerHTML; + var block = tinyMCE.getParentBlockElement(node); + + // Empty node, we do the killing!! + if (htm == "" || htm == " " || block.nodeName.toLowerCase() == "li") { + var prevElm = para.previousSibling; + + while (prevElm != null && prevElm.nodeType != 1) + prevElm = prevElm.previousSibling; + + if (prevElm == null) + return false; + + // Get previous elements last text node + var nodes = tinyMCE.getNodeTree(prevElm, new Array(), 3); + var lastTextNode = nodes.length == 0 ? null : nodes[nodes.length-1]; + + // Select the last text node and move curstor to end + if (lastTextNode != null) + this.selectNode(lastTextNode, true, false, false); + + // Remove the empty paragrapsh + para.parentNode.removeChild(para); + + //debug("within p element" + para.innerHTML); + //showHTML(this.getBody().innerHTML); + return true; + } + } + + // Remove BR elements +/* while (node != null && (node = node.nextSibling) != null) { + if (node.nodeName.toLowerCase() == 'br') + node.parentNode.removeChild(node); + else if (node.nodeType == 1) // Break at other element + break; + }*/ + + //showHTML(this.getBody().innerHTML); + + return false; +} + +function TinyMCEControl__insertSpace() { + return true; +} + +function TinyMCEControl_autoResetDesignMode() { + // Add fix for tab/style.display none/block problems in Gecko + if (!tinyMCE.isMSIE && tinyMCE.settings['auto_reset_designmode']) { + var sel = this.contentWindow.getSelection(); + + // Weird, wheres that cursor selection? + if (!sel || !sel.rangeCount || sel.rangeCount == 0) + eval('try { this.getDoc().designMode = "On"; } catch(e) {}'); + } +} + +function TinyMCEControl_execCommand(command, user_interface, value) { + function getAttrib(elm, name) { + return elm.getAttribute(name) ? elm.getAttribute(name) : ""; + } + + // Mozilla issue + if (!tinyMCE.isMSIE && !this.useCSS) { + this.getDoc().execCommand("useCSS", false, true); + this.useCSS = true; + } + + //alert("command: " + command + ", user_interface: " + user_interface + ", value: " + value); + this.contentDocument = this.getDoc(); // <-- Strange!! + + // Call theme execcommand + if (tinyMCE._themeExecCommand(this.editorId, this.contentDocument.body, command, user_interface, value)) + return; + + // Add undo level of operation + if (command != "mceAddUndoLevel" && command != "Undo" && command != "Redo" && command != "mceImage" && command != "mceLink" && command != "mceToggleVisualAid" && (command != "mceInsertTable" && !user_interface)) + this.execCommand("mceAddUndoLevel"); + + // Fix align on images + if (this.getFocusElement() && this.getFocusElement().nodeName.toLowerCase() == "img") { + var align = this.getFocusElement().getAttribute('align'); + + switch (command) { + case "JustifyLeft": + if (align == 'left') + this.getFocusElement().removeAttribute('align'); + else + this.getFocusElement().setAttribute('align', 'left'); + + tinyMCE.triggerNodeChange(); + return; + + case "JustifyCenter": + if (align == 'middle') + this.getFocusElement().removeAttribute('align'); + else + this.getFocusElement().setAttribute('align', 'middle'); + + tinyMCE.triggerNodeChange(); + return; + + case "JustifyRight": + if (align == 'right') + this.getFocusElement().removeAttribute('align'); + else + this.getFocusElement().setAttribute('align', 'right'); + + tinyMCE.triggerNodeChange(); + return; + } + } + + if (tinyMCE.settings['force_br_newlines']) { + var doc = this.getDoc(); + var alignValue = ""; + + if (doc.selection.type != "Control") { + switch (command) { + case "JustifyLeft": + alignValue = "left"; + break; + + case "JustifyCenter": + alignValue = "center"; + break; + + case "JustifyFull": + alignValue = "justify"; + break; + + case "JustifyRight": + alignValue = "right"; + break; + } + + if (alignValue != "") { + var rng = doc.selection.createRange(); + + if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null) + divElm.setAttribute("align", alignValue); + else if (rng.pasteHTML && rng.htmlText.length > 0) + rng.pasteHTML('
' + rng.htmlText + "
"); + + tinyMCE.triggerNodeChange(); + return; + } + } + } + + switch (command) { + case "mceSelectNode": + this.selectNode(value); + tinyMCE.triggerNodeChange(); + tinyMCE.selectedNode = value; + break; + + case "mceSelectNodeDepth": + var parentNode = this.getFocusElement(); + for (var i=0; parentNode; i++) { + if (parentNode.nodeName.toLowerCase() == "body") + break; + + if (parentNode.nodeName.toLowerCase() == "#text") { + i--; + parentNode = parentNode.parentNode; + continue; + } + + if (i == value) { + this.selectNode(parentNode, false); + tinyMCE.triggerNodeChange(); + tinyMCE.selectedNode = parentNode; + return; + } + + parentNode = parentNode.parentNode; + } + + break; + + case "HiliteColor": + if (tinyMCE.isGecko) { + this.contentDocument.execCommand("useCSS", false, false); + this.contentDocument.execCommand('hilitecolor', false, value); + this.contentDocument.execCommand("useCSS", false, true); + } else + this.contentDocument.execCommand('backcolor', false, value); + break; + + case "Cut": + case "Copy": + case "Paste": + var cmdFailed = false; + + // Try executing command + eval('try {this.contentDocument.execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}'); + + // Alert error in gecko if command failed + if (tinyMCE.isGecko && cmdFailed) { + // Confirm more info + if (confirm(tinyMCE.getLang('lang_clipboard_msg'))) + window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal'); + + return; + } else + tinyMCE.triggerNodeChange(); + break; + + case "mceLink": + var selectedText = ""; + + if (tinyMCE.isMSIE) { + var doc = this.getDoc(); + var rng = doc.selection.createRange(); + selectedText = rng.text; + } else + selectedText = this.contentWindow.getSelection().toString(); + + if (!tinyMCE.linkElement) { + if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0)) + return; + } + + var href = "", target = "", title = "", onclick = "", action = "insert"; + + if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a") + tinyMCE.linkElement = tinyMCE.selectedElement; + + // Is anchor not a link + if (tinyMCE.linkElement != null && getAttrib(tinyMCE.linkElement, 'href') == "") + tinyMCE.linkElement = null; + + if (tinyMCE.linkElement) { + href = getAttrib(tinyMCE.linkElement, 'href'); + target = getAttrib(tinyMCE.linkElement, 'target'); + title = getAttrib(tinyMCE.linkElement, 'title'); + onclick = getAttrib(tinyMCE.linkElement, 'mce_onclick'); + + // Try old onclick to if copy/pasted content + if (onclick == "") + onclick = getAttrib(tinyMCE.linkElement, 'onclick'); + + onclick = tinyMCE.cleanupEventStr(onclick); + + // Fix for drag-drop/copy paste bug in Mozilla + mceRealHref = getAttrib(tinyMCE.linkElement, 'mce_real_href'); + if (mceRealHref != "") + href = mceRealHref; + + href = eval(tinyMCE.settings['urlconvertor_callback'] + "(href, tinyMCE.linkElement, true);"); + action = "update"; + } + + if (this.settings['insertlink_callback']) { + var returnVal = eval(this.settings['insertlink_callback'] + "(href, target, title, onclick, action);"); + if (returnVal && returnVal['href']) + tinyMCE.insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick']); + } else { + tinyMCE.openWindow(this.insertLinkTemplate, {href : href, target : target, title : title, onclick : onclick, action : action}); + } + break; + + case "mceImage": + var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = ""; + var title = "", onmouseover = "", onmouseout = "", action = "insert"; + + if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") + tinyMCE.imgElement = tinyMCE.selectedElement; + + if (tinyMCE.imgElement) { + // Is it a internal MCE visual aid image, then skip this one. + var imgName = getAttrib(tinyMCE.imgElement, 'name'); + if (imgName.substring(0, 4)=='mce_') + return; + + src = getAttrib(tinyMCE.imgElement, 'src'); + alt = getAttrib(tinyMCE.imgElement, 'alt'); + + // Try polling out the title + if (alt == "") + alt = getAttrib(tinyMCE.imgElement, 'title'); + + border = getAttrib(tinyMCE.imgElement, 'border'); + hspace = getAttrib(tinyMCE.imgElement, 'hspace'); + vspace = getAttrib(tinyMCE.imgElement, 'vspace'); + width = getAttrib(tinyMCE.imgElement, 'width'); + height = getAttrib(tinyMCE.imgElement, 'height'); + align = getAttrib(tinyMCE.imgElement, 'align'); + onmouseover = getAttrib(tinyMCE.imgElement, 'onmouseover'); + onmouseout = getAttrib(tinyMCE.imgElement, 'onmouseout'); + title = getAttrib(tinyMCE.imgElement, 'title'); + + onmouseover = tinyMCE.cleanupEventStr(onmouseover); + onmouseout = tinyMCE.cleanupEventStr(onmouseout); + + // Fix for drag-drop/copy paste bug in Mozilla + mceRealSrc = getAttrib(tinyMCE.imgElement, 'mce_real_src'); + if (mceRealSrc != "") + src = mceRealSrc; + + src = eval(tinyMCE.settings['urlconvertor_callback'] + "(src, tinyMCE.imgElement, true);"); + action = "update"; + } + + if (this.settings['insertimage_callback']) { + var returnVal = eval(this.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);"); + if (returnVal && returnVal['src']) + tinyMCE.insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']); + } else + tinyMCE.openWindow(this.insertImageTemplate, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action}); + break; + + case "mceCleanupWord": + if (tinyMCE.isMSIE) { + var html = this.contentDocument.body.createTextRange().htmlText; + + if (html.indexOf('="mso') != -1) { + tinyMCE._setHTML(this.contentDocument, this.contentDocument.body.innerHTML); + html = tinyMCE._cleanupHTML(this.contentDocument, this.settings, this.contentDocument.body, this.visualAid); + } + + this.contentDocument.body.innerHTML = html; + } + break; + + case "mceCleanup": + tinyMCE._setHTML(this.contentDocument, this.contentDocument.body.innerHTML); + this.contentDocument.body.innerHTML = tinyMCE._cleanupHTML(this.contentDocument, this.settings, this.contentDocument.body, this.visualAid); + tinyMCE.triggerNodeChange(); + break; + + case "mceAnchor": + if (!user_interface) { + var aElm = tinyMCE.getParentElement(this.getFocusElement(), "a", "name"); + if (aElm) { + if (value == null || value == "") { + if (tinyMCE.isMSIE) { + aElm.outerHTML = aElm.innerHTML; + } else { + var rng = aElm.ownerDocument.createRange(); + rng.setStartBefore(aElm); + rng.setEndAfter(aElm); + rng.deleteContents(); + rng.insertNode(rng.createContextualFragment(aElm.innerHTML)); + } + } else + aElm.setAttribute('name', value); + } else { + this.contentDocument.execCommand("fontname", false, "#mce_temp_font#"); + var elementArray = tinyMCE.getElementsByAttributeValue(this.contentDocument.body, "font", "face", "#mce_temp_font#"); + for (var x=0; x 0) { + value = tinyMCE.replaceVar(value, "selection", selectedText); + tinyMCE.execCommand('mceInsertContent',false,value); + } + + tinyMCE.triggerNodeChange(); + break; + + case "mceSetAttribute": + if (typeof(value) == 'object') { + var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets']; + var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms); + + if (targetNode) { + targetNode.setAttribute(value['name'], value['value']); + tinyMCE.triggerNodeChange(); + } + } + break; + + case "mceSetCSSClass": + var selectedText = false; + + if (tinyMCE.isMSIE) { + var doc = this.getDoc(); + var rng = doc.selection.createRange(); + selectedText = (rng.text && rng.text.length > 0); + } else + selectedText = (this.contentWindow.getSelection().toString().length > 0); + + // Use selectedNode instead if defined + if (tinyMCE.selectedNode) + tinyMCE.selectedElement = tinyMCE.selectedNode; + + if (selectedText && !tinyMCE.selectedNode) { + this.contentDocument.execCommand("removeformat", false, null); + this.contentDocument.execCommand("fontname", false, "#mce_temp_font#"); + var elementArray = tinyMCE.getElementsByAttributeValue(this.contentDocument.body, "font", "face", "#mce_temp_font#"); +/* this.contentDocument.execCommand("createlink", false, "#mce_temp_url#"); + var elementArray = tinyMCE.getElementsByAttributeValue(this.contentDocument.body, "a", "href", "#mce_temp_url#"); +*/ + // Change them all + for (var x=0; x customUndoLevels) { + for (var i=0; i 0) { + this.undoIndex--; + this.getBody().innerHTML = this.undoLevels[this.undoIndex]; + } + + //window.status = "Undo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex; + tinyMCE.triggerNodeChange(); + } else + this.contentDocument.execCommand(command, user_interface, value); + break; + + case "Redo": + if (tinyMCE.settings['custom_undo_redo']) { + if (this.undoIndex < (this.undoLevels.length-1)) { + this.undoIndex++; + this.getBody().innerHTML = this.undoLevels[this.undoIndex]; + //window.status = "Redo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex; + } + + tinyMCE.triggerNodeChange(); + } else + this.contentDocument.execCommand(command, user_interface, value); + break; + + case "mceToggleVisualAid": + this.visualAid = !this.visualAid; + tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid); + tinyMCE.triggerNodeChange(); + break; +/* + case "removeformat": + //this.contentDocument.execCommand('FormatBlock', user_interface, ''); + var doc = this.getDoc(); + var rng = doc.selection.createRange(); + var elm = rng.item ? rng.item(0) : rng.parentElement(); + + html = "" + rng.text + "<" + elm.nodeName + ">"; + + this.contentDocument.execCommand('FontName', user_interface, '#mce_temp_name#'); + var html = this.contentDocument.innerHTML; + html.replace('' + editorTemplate['html']; + + var templateFunction = tinyMCE._getThemeFunction('_handleNodeChange', true); + if (eval("typeof(" + templateFunction + ")") != 'undefined') + this.settings['handleNodeChangeCallback'] = templateFunction; + + html = tinyMCE.replaceVar(html, "editor_id", this.editorId); + html = tinyMCE.replaceVar(html, "default_document", tinyMCE.baseURL + "/blank.htm"); + this.settings['default_document'] = tinyMCE.baseURL + "/blank.htm"; + + this.settings['old_width'] = this.settings['width']; + this.settings['old_height'] = this.settings['height']; + + // Set default width, height + if (this.settings['width'] == -1) + this.settings['width'] = replace_element.offsetWidth; + + if (this.settings['height'] == -1) + this.settings['height'] = replace_element.offsetHeight; + + // If no width/height then default to 320x240, better than nothing + if (replace_element.offsetWidth == 0) + this.settings['width'] = 320; + + if (replace_element.offsetHeight == 0) + this.settings['height'] = 240; + + this.settings['area_width'] = this.settings['width']; + this.settings['area_height'] = this.settings['height']; + this.settings['area_width'] += deltaWidth; + this.settings['area_height'] += deltaHeight; + + // Special % handling + if (("" + this.settings['width']).indexOf('%') != -1) + this.settings['area_width'] = "100%"; + + if (("" + this.settings['height']).indexOf('%') != -1) + this.settings['area_height'] = "100%"; + + if (("" + replace_element.style.width).indexOf('%') != -1) { + this.settings['width'] = replace_element.style.width; + this.settings['area_width'] = "100%"; + } + + if (("" + replace_element.style.height).indexOf('%') != -1) { + this.settings['height'] = replace_element.style.height; + this.settings['area_height'] = "100%"; + } + + html = tinyMCE.applyTemplate(html); + + this.settings['width'] = this.settings['old_width']; + this.settings['height'] = this.settings['old_height']; + + this.visualAid = this.settings['visual']; + this.formTargetElementId = form_element_name; + + // Get replace_element contents + if (replace_element.nodeName.toLowerCase() == "textarea") + this.startContent = replace_element.value; + else + this.startContent = replace_element.innerHTML; + + // If not text area + if (replace_element.nodeName.toLowerCase() != "textarea") { + this.oldTargetElement = replace_element.cloneNode(true); + + // Debug mode + if (tinyMCE.settings['debug']) + html += ''; + else + html += ''; + + html += ''; + + // Output HTML and set editable + if (!tinyMCE.isMSIE) { + var rng = replace_element.ownerDocument.createRange(); + rng.setStartBefore(replace_element); + + var fragment = rng.createContextualFragment(html); + replace_element.parentNode.replaceChild(fragment, replace_element); + } else + replace_element.outerHTML = html; + } else { + html += ''; + + // Just hide the textarea element + this.oldTargetElement = replace_element; + + if (!tinyMCE.settings['debug']) + this.oldTargetElement.style.display = "none"; + + // Output HTML and set editable + if (!tinyMCE.isMSIE) { + var rng = replace_element.ownerDocument.createRange(); + rng.setStartBefore(replace_element); + + var fragment = rng.createContextualFragment(html); + replace_element.parentNode.insertBefore(fragment, replace_element); + } else + replace_element.insertAdjacentHTML("beforeBegin", html); + } + + // Setup iframe + var dynamicIFrame = false; + var tElm = targetDoc.getElementById(this.editorId); + + if (!tinyMCE.isMSIE) { + if (tElm && tElm.nodeName.toLowerCase() == "span") { + tElm = tinyMCE._createIFrame(tElm); + dynamicIFrame = true; + } + + this.targetElement = tElm; + this.iframeElement = tElm; + this.contentDocument = tElm.contentDocument; + this.contentWindow = tElm.contentWindow; + + //this.getDoc().designMode = "on"; + } else { + if (tElm && tElm.nodeName.toLowerCase() == "span") + tElm = tinyMCE._createIFrame(tElm); + else + tElm = targetDoc.frames[this.editorId]; + + this.targetElement = tElm; + this.iframeElement = targetDoc.getElementById(this.editorId); + this.contentDocument = tElm.window.document; + this.contentWindow = tElm.window; + this.contentDocument.designMode = "on"; + } + + // Setup base HTML + var doc = this.contentDocument; + if (dynamicIFrame) { + var html = "" + + '' + + '' + + '' + + '' + + 'blank_page' + + '' + + '' + + '' + + '' + + ''; + + try { + this.getDoc().designMode = "on"; + doc.open(); + doc.write(html); + doc.close(); + } catch (e) { + // Failed Mozilla 1.3 + this.getDoc().location.href = tinyMCE.baseURL + "/blank.htm"; + } + } + + // This timeout is needed in MSIE 5.5 for some odd reason + // it seems that the document.frames isn't initialized yet? + if (tinyMCE.isMSIE) + window.setTimeout("TinyMCE_addEventHandlers('" + this.editorId + "');", 1); + + //window.setTimeout("tinyMCE.setupContent('" + this.editorId + "');", (tinyMCE.isMSIE ? 1 : 1000)); + tinyMCE.setupContent(this.editorId); + + return true; +} + +function TinyMCEControl_getFocusElement() { + if (tinyMCE.isMSIE) { + var doc = this.getDoc(); + var rng = doc.selection.createRange(); + var elm = rng.item ? rng.item(0) : rng.parentElement(); + } else { + var sel = this.contentWindow.getSelection(); + var elm = (sel && sel.anchorNode) ? sel.anchorNode : null; + + if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") + elm = tinyMCE.selectedElement; + } + + return elm; +} + +// Global instances +var tinyMCE = new TinyMCE(); +var tinyMCELang = new Array(); diff --git a/includes/tinymce/lgpl.txt b/includes/tinymce/lgpl.txt new file mode 100644 index 00000000..6a61e91b --- /dev/null +++ b/includes/tinymce/lgpl.txt @@ -0,0 +1,437 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. +. + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. +. + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. +. + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. +. + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. +. + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. +. + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. +. + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. +. + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/index.php b/index.php new file mode 100644 index 00000000..966d293d --- /dev/null +++ b/index.php @@ -0,0 +1,104 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +ob_start(); + +require_once('config.inc.php'); +require_once('modules/core/vars.inc.php'); +$C_vars = new CORE_vars; +$VAR = $C_vars->f; + +if(!defined('PATH_AGILE')) { + if(is_file('install/install.inc')) + require_once('install/install.inc'); + exit; +} + +require_once('includes/adodb/adodb.inc.php'); +require_once('includes/smarty/Smarty.class.php'); +require_once(PATH_CORE.'auth.inc.php'); +require_once(PATH_CORE.'database.inc.php'); +require_once(PATH_CORE.'list.inc.php'); +require_once(PATH_CORE.'method.inc.php'); +require_once(PATH_CORE.'session.inc.php'); +require_once(PATH_CORE.'theme.inc.php'); +require_once(PATH_CORE.'translate.inc.php'); +require_once(PATH_CORE.'setup.inc.php'); +require_once(PATH_CORE.'xml.inc.php'); + +$C_debug = new CORE_debugger; +$C_setup = new CORE_setup; +$C_sess = new CORE_session; +$C_sess->session_constant(); +$C_translate= new CORE_translate; +$C_method = new CORE_method; + +if ((isset($VAR['_login'])) && (isset($VAR['_username'])) && (isset($VAR['_password']))) { + require_once(PATH_CORE . 'login.inc.php'); + $C_login = new CORE_login_handler(); + $C_login->login($VAR); +} elseif (isset($VAR['_logout'])) { + require_once(PATH_CORE . 'login.inc.php'); + $C_login = new CORE_login_handler(); + $C_login->logout($VAR); +} + +$C_sess->session_constant_log(); + +$force = false; +$C_auth = new CORE_auth ($force); + +$smarty = new Smarty; +$C_list = new CORE_list; +$C_block = new CORE_block; + +for($i=0;$irun_all(); + exit; +} + +$C_method->do_all(); + +if(isset($C_auth2) && $C_auth2 != false && defined("FORCE_SESS_ACCOUNT")) { + $smarty->assign("SESS_LOGGED", FORCE_SESS_LOGGED); + $smarty->assign("SESS_ACCOUNT", FORCE_SESS_ACCOUNT); +} else { + $smarty->assign("SESS_LOGGED", SESS_LOGGED); + $smarty->assign("SESS_ACCOUNT", SESS_ACCOUNT); +} + +$smarty->assign_by_ref("method", $C_method); +$smarty->assign_by_ref("list", $C_list); +$smarty->assign_by_ref("block", $C_block); +$smarty->assign_by_ref("alert", $C_debug->alert); +$smarty->assign("VAR", $VAR); +$smarty->assign("SESS", SESS); +$smarty->assign("SSL_URL", SSL_URL); +$smarty->assign("URL", URL); +$C_theme = new CORE_theme; + +ob_end_flush(); +?> diff --git a/install/config.inc b/install/config.inc new file mode 100644 index 00000000..8e664db1 --- /dev/null +++ b/install/config.inc @@ -0,0 +1,64 @@ + '_news', 'p' => 'newsletter:newsletter' ), + Array ( 's' => '_affiliate', 'p' => 'affiliate:affiliate' ), + Array ( 's' => '_contact', 'p' => 'staff:staff' ), + Array ( 's' => '_ticket', 'p' => 'ticket:ticket' ), + Array ( 's' => '_account', 'p' => 'account:account' ), + Array ( 's' => '_products', 'p' => 'product:cat' ), + Array ( 's' => '_product', 'p' => 'product:details' ), + Array ( 's' => '_cart', 'p' => 'cart:cart' ), + Array ( 's' => '_checkout', 'p' => 'checkout:checkout' ), + Array ( 's' => '_static', 'p' => 'static_page:show' ) + ); +?> \ No newline at end of file diff --git a/install/install.inc b/install/install.inc new file mode 100644 index 00000000..e84f6074 --- /dev/null +++ b/install/install.inc @@ -0,0 +1,402 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +global $VAR, $_SERVER, $HTTP_SERVER_VARS; + +# get the file path +if (is_file($_SERVER["PATH_TRANSLATED"])) { + $path = $_SERVER["PATH_TRANSLATED"]; +} elseif (is_file($HTTP_SERVER_VARS["SCRIPT_FILENAME"])) { + $path = $HTTP_SERVER_VARS["SCRIPT_FILENAME"]; +} else { + $path = PATH_AGILE; +} +$path = eregi_replace('index.php', '', $path); +$path = eregi_replace("[\\\\]", '/', $path); + +# Get the current IP & Domain +if(isset($_SERVER)) { + $site_domain = @$_SERVER['HTTP_HOST']; + $site_ip = @$_SERVER['SERVER_ADDR']; +} else { + $server = getallheaders(); + $site_domain = $server['Host']; + $site_ip = false; +} + +# req writable files/paths +$_FILES = Array ( Array('file', 'config.inc.php'), + Array('dir', 'includes/smarty/templates/'), + Array('dir', 'includes/files/'), + Array('dir', 'includes/images/') ); + +# Modules to skip over (duplicate tables) +$_SKIP_MODULES = Array ( 'account_admin' ); + +# Core modules needed +$_CORE_MODULES = Array ( 'module', 'module_method', 'group_method'); + +# Base modules needed +$_BASE_MODULES = Array ( 'setup', + 'account', + 'account_memo', + 'account_admin', + 'account_group', + 'account_billing', + 'backup', + 'blocked_email', + 'blocked_ip', + 'cart', + 'country', + 'currency', + 'checkout', + 'discount', + 'email_template', + 'email_template_translate', + 'group', + 'group_method', + 'invoice', + 'invoice_commission', + 'invoice_item', + 'invoice_item_tax', + 'invoice_item_discount', + 'invoice_memo', + 'invoice_setup', + 'login_lock', + 'login_log', + 'log_error', + 'module', + 'module_method', + 'newsletter', + 'net_term', + 'newsletter_subscriber', + 'product', + 'product_attr', + 'product_cat', + 'product_cat_translate', + 'product_img', + 'product_translate', + 'search', + 'search_saved', + 'session', + 'session_auth_cache', + 'setup_email', + 'setup_invoice', + 'service', + 'service_memo', + 'staff', + 'staff_department', + 'static_relation', + 'static_var', + 'static_var_record', + 'tax', + 'task', + 'temporary_data' + ); + +# optional modules to check for +$_CHK_MODULES = Array ( 'affiliate' => Array ('affiliate', 'affiliate_commission', 'affiliate_template'), + 'asset' => Array ('asset', 'asset_pool'), + 'campaign' => Array ('campaign'), + 'charge' => Array ('charge'), + 'db_mapping' => Array ('db_mapping'), + 'email_queue' => Array ('email_queue'), + 'file' => Array ('file', 'file_category'), + 'faq' => Array ('faq', 'faq_category', 'faq_translate'), + 'htaccess' => Array ('htaccess', 'htaccess_dir', 'htaccess_exclude'), + 'host_server' => Array ('host_server', 'host_registrar_plugin', 'host_tld'), + 'import' => Array ('import'), + 'login_share' => Array ('login_share'), + 'report' => Array ('report'), + 'radius' => Array ('radius','radius_service'), + 'static_page' => Array ('static_page', 'static_page_category','static_page_translate'), + 'ticket' => Array ('ticket', 'ticket_department', 'ticket_message','ticket_attachment'), + 'voip' => Array ('voip', 'voip_cdr', 'voip_did', 'voip_did_plugin', 'voip_fax','voip_fax_data', 'voip_in_network','voip_local_lookup','voip_pool','voip_rate','voip_rate_prod', 'voip_sip','voip_iax','voip_vm'), + 'voip_prepaid' => Array ('voip_prepaid') ); + + +# description of optional modules +$_MODULE_DESC = Array ( 'affiliate' => 'Affiliate Module: manage affiliates and commissions.', + 'asset' => 'Asset Management Module: manage asset assignment status.', + 'campaign' => 'Campaign Module: manage and track advertising campaigns.', + 'charge' => 'Charge Module: manage incremental billing for accounts and services.', + 'db_mapping' => 'DB Mapping Module: sync your users to 3rd party databases, such as forums, CMS, etc.', + 'email_queue' => 'E-mail Queue: Store e-mails in a queue before sending to improve the speed of the user/admin interface.', + 'file' => 'File Module: upload files that users can download based on their groups.', + 'faq' => 'FAQ Module: manage a Frequently Asked Questions list and enables canned responses in the ticket module.', + 'htaccess' => 'Htaccess Module: protect php files and/or entire directories with htaccess based on groups and sell access.', + 'import' => 'Import Module: manage custom imports from other programs.', + 'host_server' => 'Hosting Module: sell webhosting services, domains, and automate server provisioning and domain registration.', + 'login_share' => 'Login Sharing: automatically detect and ban password sharing.', + 'report' => 'Report Module: report generation for account, invoice, and other data.', + 'radius' => 'Radius Module: provisioning control over Radius authentication data.', + 'static_page' => 'Static Page Module: create and manage static pages on your site from your admin area.', + 'ticket' => 'Ticket Module: support ticket management.', + 'voip' => 'VoIP Module: the core VoIP specific AgileVoice functionality.', + 'voip_prepaid' => 'VoIP Prepaid Module: the added VoIP Prepaid AgileVoice functionality.' ); + + +# define the default group to add all methods to +$VAR["module_group"] = Array('1001'); + + +# action handler +if (!empty($VAR['do'])) +{ + $do = $VAR['do']; + switch ($VAR['do']) + { + # check file permissions: + case 'step1': + $files = test_files ($_FILES); + $s_file = 'step1.php'; + break; + + # write the new config vars + case 'step2': + $files = write_config($VAR); + $s_file = 'step2.php'; + + # get the license code + $filename = "License.txt"; + if(is_file($filename)) { + $handle = fopen($filename, "r"); + $license_agreement = fread($handle, filesize($filename)); + fclose($handle); + } + + # check for available optional modules + $i=0; + if ($files === true) { + while (list($n,$v) = each($_CHK_MODULES)) + { + if(is_dir('modules/'. $n )) { + $modules[$i]['name'] = $n; + $modules[$i]['desc'] = $_MODULE_DESC[$n]; + $i++; + } + } + } + break; + + # test the database connection & select the modules to install + case 'step3': + $database = test_connection (); + $s_file = 'step3.php'; + if($database === true) { + require_once('install/install_db_core.inc'); + + $dbinst = new install_db; + $dbinst->core_modules = $_CORE_MODULES; + $dbinst->skip_modules = $_SKIP_MODULES; + + # create core tables + for($i=0; $iinstall_sql_tbl($_CORE_MODULES[$i]); + + # create base modules + for($i=0; $iinstall_sql($_BASE_MODULES[$i]); + + # insert the data + $dbinst->add_data($_BASE_MODULES); + + # check for user-defined modules + if(is_array(@$VAR['modules'])) { + for($i=0; $iinstall_sql($arr[$ii]); + $dbinst->add_data($arr); + } + } + } + + # insert license key and code into setup table + $fields=Array('license_key'=> @$VAR['license_key'], 'license_code'=> @$VAR['license_code']); + $db->Execute(sqlUpdate($db,"setup",$fields,"site_id=".DEFAULT_SITE)); + } + break; + + # select the database connection + case 'step4': + $s_file = 'step4.php'; + break; + } +} +else +{ + $do = 'step1'; + $files = test_files ($_FILES); + $s_file = 'step1.php'; +} + +# Load the template +include('install/template.inc'); + + + + +######################################################################################### +# Write the new config file +######################################################################################### +function write_config ($VAR) +{ + # get the config template + if ($file = fopen('install/config.inc', 'r')) + { + $data = ''; + while (!feof($file)) + $data .= fgetc($file); + fclose($file); + + # replace the user vars + $data = ereg_replace('%%PATH_AGILE%%', @$VAR['path_agile'], $data); + $data = ereg_replace('%%AGILE_DB_TYPE%%', @$VAR['db_type'], $data); + $data = ereg_replace('%%AGILE_DB_HOST%%', @$VAR['db_host'], $data); + $data = ereg_replace('%%AGILE_DB_DATABASE%%', @$VAR['db_database'], $data); + $data = ereg_replace('%%AGILE_DB_USERNAME%%', @$VAR['db_username'], $data); + $data = ereg_replace('%%AGILE_DB_PASSWORD%%', @$VAR['db_password'], $data); + $data = ereg_replace('%%AGILE_DB_PREFIX%%', @$VAR['db_prefix'], $data); + + if(!defined("DEFAULT_SITE")) define("DEFAULT_SITE", 1); + $data = str_replace('%%AGILE_DEFAULT_SITE%%', DEFAULT_SITE, $data); + + # write the new config file + if ($file = fopen('config.inc.php', 'w')) { + fputs($file, $data); + return true; + } else { + return false; + } + } else { + return false; + } +} + + + + +######################################################################################### +# Check file/directory permissions +######################################################################################### +function test_files ($_arr_perm) +{ + # check each file/dir + $_perm_err = false; + for($i=0; $i". $_arr_perm[$i][1] . "` must be set set to writable. [ERROR-1]"; + } + } + else + { + if (!is_dir($_arr_perm[$i][1]) || !is_writable($_arr_perm[$i][1])) { + $_perm_err .= "

Directory Permission Problem Detected:
". + "The directory `". $_arr_perm[$i][1] . "` must be set set to writable. [ERROR-2]"; + } + } + } + if(empty($_perm_err)) + return true; + else + return $_perm_err; +} + + +######################################################################################### +# Check database connection +######################################################################################### +function test_connection() +{ + if(AGILE_DB_PREFIX=="") { + return "

Database Configration Problem Detected:
". + "You must return to Step 1 of the installation process and enter a database prefix."; + } + + # Attempt to connect to the database + $db = &DB(); + $err = @$db->ErrorMsg(); + if(!empty($err) ) + { + if (eregi('No Database Selected', $err) || eregi('Unknown database', $err)) + { + # attempt to create the database + $result = $db->Execute('CREATE DATABASE '.AGILE_DB_DATABASE); + if($result === false) + return "

Database Problem Detected:
". + "The database named `".AGILE_DB_DATABASE."` does not exist on `".AGILE_DB_HOST."`, ". + "and the user/pass provided does not have permission to create it. [ERROR-3]"; + else + $result = true; + } + elseif (eregi('Access denied', $err)) + { + return "

Database Problem Detected:
". + "The database `".AGILE_DB_DATABASE."` cannot be accessed with the user user/pass provided. [ERROR-4]"; + } + else + { + return "

Database Problem Detected:
". + $err. " [ERROR-5]"; + } + } + + # drop table + # $db->Execute('DROP TABLE '. AGILE_DB_DATABASE); + + if(defined('DEFAULT_SITE') && DEFAULT_SITE == 1) + { + # attempt table creation: + $db = &DB(); + $dict = NewDataDictionary($db); + $flds = "col1 C(32), col2 C(32)"; + $sqlarray = $dict->CreateTableSQL('1st_delete_this', $flds); + $result = $db->Execute($sqlarray[0]); + if ($result === false) { + echo $db->ErrorMsg(); + return "

Database Problem Detected:
". + "You do not have the correct access to the database; unable to create tables. [ERROR-6]"; + } + + # attempt index creation: + $db = &DB(); + $idxflds = 'co11, col2'; + $sqlarray = $dict->CreateIndexSQL('id', '1st_delete_this', $idxflds); + $dict->ExecuteSQLArray($sqlarray); + if ($result === false) { + return "

Database Problem Detected:
". + "You do not have the correct access to the database; unable to create indexes. [ERROR-7]"; + } + + # database tests passed: + $db->Execute('DROP TABLE 1st_delete_this'); + } + + + return true; +} +?> \ No newline at end of file diff --git a/install/install_db_core.inc b/install/install_db_core.inc new file mode 100644 index 00000000..bbdde61e --- /dev/null +++ b/install/install_db_core.inc @@ -0,0 +1,486 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +############################################## +# DB installation class +############################################## +class install_db +{ + + ############################################## + ## insert the default data + ############################################## + function add_data ( $arr ) + { + $db = &DB(); + for($i=0; $iinstall_sql_data($arr[$i]); + + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . '' . $arr[$i] . '_id'; + $result = $db->Execute($sql); + if($result == true && $result->fields["id"] <= "0") + { + $sql = 'INSERT INTO ' . AGILE_DB_PREFIX . '' . $arr[$i] . '_id SET id = 1'; + $db->Execute($sql); + } + } + } + + + ############################################## + ## INSTALL DEFAULT DATA ## + ############################################## + function install_sql_data($module) + { + # check the file: + $f = PATH_MODULES . '' . $module . '/' . $module . '_install_data.xml'; + + if(is_file($f)) + { + # open the XML backup file: + $C_xml = new CORE_xml; + $backup = $C_xml->xml_to_array($f); + $db = &DB(); + $arr = $backup['install']; + + # loop through each table in this array + if(is_array($arr) ) + { + while (list ($table,$records) = each ($arr)) + { + $runsql = false; + $sqls = 'INSERT INTO '.AGILE_DB_PREFIX.'' . $table . ' SET '; + + if (is_array($records) ) + { + # loop through each of the fields for this module + $sql = ''; + $sqlcount = 0; + while (list ($fld,$val) = each ($records)) + { + if (is_array($val)) + { + # loop through each of the fields for this module + $sql = ''; + $sqlcount = 0; + while (list ($fld2,$val2) = each ($val)) + { + if ($sqlcount != 0) $sql .= ', '; + $sql .= $fld2 .' = '.$db->qstr($val2); + $sqlcount++; + } + ## echo '
' . $sqls. ' ' . $sql; + $sql = ereg_replace("site_id = '1',", "site_id = ".DEFAULT_SITE.",",$sql); + $result = $db->Execute($sqls. ' ' . $sql); + + } + else + { + if ($sqlcount != 0) $sql .= ', '; + $sql .= $fld .' = '.$db->qstr($val); + $sqlcount++; + $runsql = true; + } + } + + if ($runsql) + { + $sql = ereg_replace("site_id = '1',", "site_id = ".DEFAULT_SITE.",",$sql); + #echo '
' . $sqls. ' ' . $sql; + $result = $db->Execute($sqls. ' ' . $sql); + if($result === false) + @$this->error .= "
". $sqls. ' ' . $sql; + } + } + } + } + } + } + + + + + ############################################## + ## INSTALL TABLES, FIELDS, & MODULES ## + ############################################## + function install_sql($module) + { + global $VAR; + + @$this->tables_created .= "
Created Table `$module`"; + + ########################################### + ### Load the install XML file... + $C_xml = new CORE_xml; + $xml_install = PATH_MODULES . "" . $module . "/" . $module . "_install.xml"; + $install = $C_xml->xml_to_array($xml_install); + + ########################################### + ### Load the construct XML file... + $C_xml = new CORE_xml; + $xml_construct = PATH_MODULES . "" . $module . "/" . $module . "_construct.xml"; + $construct = $C_xml->xml_to_array($xml_construct); + + + ### Check that this Module has any db installation required... + if(isset($construct["construct"]["table"])) + { + ### Create the module DB table + $table = $construct["construct"]["table"]; + + ### Create the module DB fields + $arr_field = $construct["construct"]["field"]; + + ### Loop through the fields to build the list: + $index_flds = ''; + while (list ($key, $value) = each($arr_field)) + { + $field = $key; + $t_s = $arr_field["$key"]["type"]; + + if(ereg('[(]',$t_s)) + { + $ts = split('[(]',$t_s); + $type = $ts[0]; + $size = ereg_replace('[)]', '', $ts[1]); + $flds[] = Array($field, $type, $size); + } + else + { + $flds[] = Array($field, $t_s); + } + } + + + ### Check that the tables for this module have not been created already: + $install_db = true; + for($i=0; $icore_modules); $i++) + { + if ($module == $this->core_modules[$i]) + $install_db = false; + } + for($i=0; $iskip_modules); $i++) + { + if ($module == $this->skip_modules[$i]) + $install_db = false; + } + + ### Check that this is not a site_id creation: + if(defined('DEFAULT_SITE') && DEFAULT_SITE > 1) $install_db = false; + + if ($install_db) + { + ### Create the table & colums using the ADODB Data Dictionary functions: + $db = &DB(); + $dict = NewDataDictionary($db); + $table_options = array('mysql' => 'TYPE=MyISAM'); + $sqlarray = $dict->CreateTableSQL(AGILE_DB_PREFIX.''.$table, $flds, $table_options); + $result = $db->Execute($sqlarray[0]); + if ($result === false) + { + echo "

" . $sqlarray[0]; + echo "
Error (install_sql-1): ". $db->ErrorMsg(); + @$this->error .= "
Error: ". $db->ErrorMsg(); + } + + # create site_id index: + $dbres = $db->Execute("CREATE UNIQUE INDEX IDS on ".AGILE_DB_PREFIX."$table (site_id, id)"); + if ($dbres === false) + { + echo "

" . $sqlarray[0]; + echo "
Error (install_sql-2): ". $db->ErrorMsg(); + @$this->error .= "
Error: ". $db->ErrorMsg(); + } + + # Create custom indexes + if(@$new_indexes = $construct["construct"]["index"]) + { + while (list ($index, $fields) = each($new_indexes)) + { + if(!empty($index) && !empty($fields)) + { + # create index + $dict = NewDataDictionary($db); + + if(eregi("fulltext", $index) && AGILE_DB_TYPE == 'mysql') + $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX.$table, $fields, array('FULLTEXT')); + else + $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX.$table, $fields); + + $dbres = $db->Execute($sqlarray[0]); + if ($dbres === false) + { + echo "

" . $sqlarray[0]; + echo "
Error (install_sql-3): ". $db->ErrorMsg(); + @$this->error .= "
Error: ". $db->ErrorMsg(); + } + } + } + } + + ### Create the starting auto-increment table + $db->GenID(AGILE_DB_PREFIX . $table . '_id'); + $db->Execute('DELETE FROM ' . AGILE_DB_PREFIX . $table . '_id'); + } + } + + ################################################################## + ### Get the module properties: + + if(@$install["install"]["module_properties"]["menu_display"] == '0') + $menu_display = '0'; + else if(@$install["install"]["module_properties"]["menu_display"] != '1') + $menu_display = '0'; + else + $menu_display = '1'; + + if(isset($install["install"]["module_properties"]["notes"])) + $notes = $install["install"]["module_properties"]["notes"]; + else + $notes = ''; + + ################################################################### + ### Get the parent module... + + $db = &DB(); + $module_id = $db->GenID(AGILE_DB_PREFIX . "" . 'module_id'); + if(isset($install["install"]["module_properties"]["parent"])) + { + $q = 'SELECT id FROM '.AGILE_DB_PREFIX.'module WHERE + site_id = '.$db->qstr(DEFAULT_SITE).' AND + name = '.$db->qstr($install["install"]["module_properties"]["parent"]); + $result = $db->Execute($q); + + # Error checking + if ($result === false) + { + @$this->error .= "
Error: ". $db->ErrorMsg(); + #return false; + } + + if($result->fields["id"] == '') + $parent_id = $module_id; + else + $parent_id = $result->fields["id"]; + + } + else + { + $parent_id = $module_id; + } + + + + ################################################################## + ### Create the module record, & get the module ID + ### get the ID of the parent, and create it as child if needed... + ### else the record is a child of itself... + + $q = 'INSERT INTO '.AGILE_DB_PREFIX.'module SET + id = ' .$db->qstr($module_id).', + site_id = ' .$db->qstr(DEFAULT_SITE).', + name = ' .$db->qstr($install["install"]["module_properties"]["name"]).', + parent_id = ' .$db->qstr($parent_id).', + notes = ' .$db->qstr($notes).', + status = ' .$db->qstr('1').', + date_orig = ' .$db->qstr(time()).', + date_last = ' .$db->qstr(time()).', + menu_display = '.$db->qstr($menu_display); + $result = $db->Execute($q); + + ################################################################### + ### Create the module_method records, and get the ID for each one + + $methods = $install["install"]["sql_inserts"]["module_method"]; + if (gettype($methods) == 'array') + { + while (list ($key, $value) = each($methods)) + { + $name = $key; + $method_id = $db->GenID(AGILE_DB_PREFIX . "" . 'module_method_id'); + + if(isset($methods[$key]["notes"])) + $notes = $methods[$key]["notes"]; + else + $notes = ''; + + if(isset($methods[$key]["page"])) + $page = $methods[$key]["page"]; + else + $page = ''; + + if(isset($methods[$key]["menu_display"])) + $menu_display = '1'; + else + $menu_display = '0'; + + $q = 'INSERT INTO '.AGILE_DB_PREFIX .'module_method SET + id = '.$db->qstr($method_id).', + site_id = '.$db->qstr(DEFAULT_SITE).', + name = '.$db->qstr($name).', + module_id = '.$db->qstr($module_id).', + notes = '.$db->qstr($notes).', + page = '.$db->qstr($page).', + menu_display = '.$db->qstr($menu_display); + + $result = $db->Execute($q); + + # Error checking + if ($result === false) + { + @$this->error .= "
Error: ". $db->ErrorMsg(); + #return false; + } + + + ############################################################### + ### Create the group_method records, with the ID from each + ### of the above methods... + ### Get the groups to add to (FROM THE install.tpl form!) + + for($i=0; $iGenID(AGILE_DB_PREFIX . 'group_method_id'); + $q = 'INSERT INTO '.AGILE_DB_PREFIX .'group_method SET + id = '.$db->qstr($group_method_id).', + site_id = '.$db->qstr(DEFAULT_SITE).', + method_id = '.$db->qstr($method_id).', + module_id = '.$db->qstr($module_id).', + group_id = '.$db->qstr($VAR["module_group"][$i]); + + $result = $db->Execute($q); + + # Error checking + if ($result === false) + { + @$this->error .= "
Error: ". $db->ErrorMsg(); + #return false; + } + } + } + } + + # all done! + return true; + } + + + + + + + ############################################## + ## INSTALL TABLES & FIELDS ONLY ## + ############################################## + function install_sql_tbl($module) + { + ########################################### + ### Load the install XML file... + $C_xml = new CORE_xml; + $xml_install = PATH_MODULES . "" . $module . "/" . $module . "_install.xml"; + $install = $C_xml->xml_to_array($xml_install); + + ########################################### + ### Load the construct XML file... + $C_xml = new CORE_xml; + $xml_construct = PATH_MODULES . "" . $module . "/" . $module . "_construct.xml"; + $construct = $C_xml->xml_to_array($xml_construct); + + + ### Check that this Module has any db installation required... + if(isset($construct["construct"]["table"])) + { + ### Create the module DB table + $table = $construct["construct"]["table"]; + + ### Create the module DB fields + $arr_field = $construct["construct"]["field"]; + + ### Loop through the fields to build the list: + while (list ($key, $value) = each($arr_field)) + { + $field = $key; + $t_s = $arr_field["$key"]["type"]; + + + if(ereg('[(]',$t_s)) + { + $ts = split('[(]',$t_s); + $type = $ts[0]; + $size = ereg_replace('[)]', '', $ts[1]); + $flds[] = Array($field, $type, $size); + } + else + { + $flds[] = Array($field, $t_s); + } + } + + # Check this is not a multi site id install + if( DEFAULT_SITE == 1) + { + ### Create the table & colums using the ADODB Data Dictionary functions: + $db = &DB(); + $dict = NewDataDictionary($db); + $table_options = array('mysql' => 'TYPE=MyISAM'); + $sqlarray = $dict->CreateTableSQL(AGILE_DB_PREFIX.''.$table, $flds, $table_options); + $result = $db->Execute($sqlarray[0]); + if ($result === false) + { + echo "

". $sql[0]; + echo "
5 Error: ". $db->ErrorMsg(); + @$this->error .= "
Error (install_sql_tbl-1): ". $db->ErrorMsg(); + #return false; + } + + # Create unique index on site_id,id (mysql specific) + $db->Execute("CREATE UNIQUE INDEX IDS on ".AGILE_DB_PREFIX."$table (site_id, id)"); + + # Create custom indexes + if(@$new_indexes = $construct["construct"]["index"]) + { + while (list ($index, $fields) = each($new_indexes)) + { + if(!empty($index) && !empty($fields)) + { + # create index + $dict = NewDataDictionary($db); + + if(eregi("fulltext", $index) && AGILE_DB_TYPE == 'mysql') + $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX.$table, $fields, array('FULLTEXT')); + else + $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX.$table, $fields); + + $dbres = $db->Execute($sqlarray[0]); + if ($dbres === false) + { + echo "

" . $sqlarray[0]; + echo "
Error (install_sql-3): ". $db->ErrorMsg(); + @$this->error .= "
Error: ". $db->ErrorMsg(); + } + } + } + } + } + } + } +} +?> \ No newline at end of file diff --git a/install/step1.php b/install/step1.php new file mode 100644 index 00000000..aac394df --- /dev/null +++ b/install/step1.php @@ -0,0 +1,60 @@ + +

Step 1: Checking file permissions... + +done!
+
+

+Please check the path and database settings below:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Base Path:
Database Type:
Database Host:
Database Name:
Database Username:
Database Password:
Database Prefix ">
  +
+
+

+ + failed!
+
+ To Resolve This Issue:
+Please access the files/directories listed above and change their permissions to be writable. Then refresh this page in your browser.
+
+On Linux based systems, you can use an FTP program to change the CHMOD settings to '777', or you can use the chmod command from the command line.
+
+On Windows based systems, you should check that the file/directory is not set to "Read-only."
+ +

diff --git a/install/step2.php b/install/step2.php new file mode 100644 index 00000000..565ed5cb --- /dev/null +++ b/install/step2.php @@ -0,0 +1,51 @@ +

Step 2: + Writing new configuration settings... + + + done!

+ + + +Please select any optional modules you wish to install

+ + + + + + + + +
+ +   + +
+

+ + + + + + + + + + + failed! + +

+


+
+ To Resolve This Issue:
+ Please access the files/directories listed above and change their permissions + to be writable. Then refresh this page in your browser.
+
+ On Linux based systems, you can use an FTP program to change the CHMOD settings + to '777', or you can use the chmod command from the command line.
+
+ On Windows based systems, you should check that the file/directory is not set + to "Read-only," and the web user has full access to the files.
+
+ + +

diff --git a/install/step3.php b/install/step3.php new file mode 100644 index 00000000..dc2c5364 --- /dev/null +++ b/install/step3.php @@ -0,0 +1,24 @@ + +

Step 3: Installing modules and associated tables... + +done!
+
+The installation installation is now complete, you can login with the following account:
+
+ Admin Acccount: admin/admin
+
+Please CLICK HERE to edit your site settings. This is required, you will need to edit your site URL, or your installation may not work!
+
+ tables_created; ?> errors; ?>
+
+ + failed!
+
+ To Resolve This Issue:
+[ERROR-3] The user you specified must have adequate permission to create the database in question, or you must manually create the database yourself. Most web hosts either offer a feature to create new databases in your hosting control panel, or will create the database for you if you request that they do so. When resolved, start the installation process over.

+

[ERROR-4] The user you specified is not authorized for the database you have specified, please double check with your host. When resolved, start the installation process over.

+

[ERROR-5] Other database error, paste the error generated and contact your hosting company for them to resolve the problem. When resolved, start the installation process over.

+

[ERROR-6] The user you specified is not authorized to create new tables in the database, please update your database permissions to include this priviledge, or contact your hosting company to do so if you do not know how. Then refesh this page or start the installation process over.

+

[ERROR-7] The user you specified is not authorized to create indexes on tables in the database, please update your database permissions to include this priviledge, or contact your hosting company to do so if you do not know how. Then refesh this page or start the installation process over.
+ +

diff --git a/install/template.inc b/install/template.inc new file mode 100644 index 00000000..8e371b2a --- /dev/null +++ b/install/template.inc @@ -0,0 +1,71 @@ + + +AgileCo Product Installer + + + + +
+ + + + + + + + + + + + + + + + +
+ +
 
+ +
+ + + + + + + +
+
Copyright 2004- Agileco, LLC.
+
+ + diff --git a/language/account/english_account.xml b/language/account/english_account.xml new file mode 100644 index 00000000..35291834 --- /dev/null +++ b/language/account/english_account.xml @@ -0,0 +1,141 @@ + + + account_admin + + + Register for Account + Update Account Details + My Account Details + Retrieve Lost Password + Reset Your Password + Resend Verification Email + Enter Verification Code + Manage Sub-Accounts + Add Sub-Account + + + My Account + Register for Account + My Account Details + + + Creation Date + Date of Last Update + Expiration Date + Parent Account + Language + Country + Affiliate + Reseller + Currency + Theme + Username + Password + Enter New Password + Confirm Password + Update Username Requested + Update Password Requested + Username/Password Update Key + Secret Question + Secret Answer + Child Accounts Inherit Parent's Groups? + Account Notes + Account Active? + First Name + Middle Name + Last Name + Title/Suffix + E-mail Address + HTML E-mail OK? + Address + Address 2 + City + State/Province + Zip/Postal + Company + + + IP Address + Mr. + Ms. + Mrs. + Miss + Dr. + Prof + + The new password you provided was not entered the same in the confirm field, please try again. + + + Your password has been changed to the new password you submitted. + + + If you have forgotten your password, we can issue you a temporary access code + via email that will allow you to change your password. To start this process, + please enter either your e-mail address or username to begin. Please do not enter + both, simply providing one or the other will do just fine. + + You must provide either your e-mail address or username in order to retrieve your password + You have already submitted the password reset request for this account within the past %limit% seconds, please wait to try again + Sorry, we cannot find any matching accounts for the criteria you submitted, please double check your information and try again + + Thank you, we have sent an email to your email address on file with a link for changing your password. + The link is valid for 15 minutes only, so be sure to check your email right away. + + + The link you followed has either expired, or been malformed by your email reader. + If you suspect that it did not copy correctly from your email reader, please paste the + entire link from your email reader to the address bar in your browser. + Otherwise, you can restart your password reset request by clicking the link below: + + Your password has been updated successfully! + + Please enter the new password for your account below. + + You must enter a new password + + Thank you for registering, your account has been successfully registered and + you have been logged in. + +
+ If you do not receive the verification email shortly, you can click + the "Verify Account" link to request that we resend the verification + email.]]> +
+ + If you are having trouble with the verification code, or never received the verification email, + you can use this form to request that we resend the verification email to you. + Please enter either your username or email address, not both. + + + Thank you, your account is now validated and you can login! + + + Oops, there was a problem with the url you followed, please enter the verification + code from your email in the box below + + Verification Code + + Please enter the verification code from the email you recieved below. If you + have not recieved the verification email, or are having trouble, you can use + the form below to request that the verification email be resent. + + + You must enter either your username or e-mail address in order for the + verification e-mail to be resent. + + + Your account is already active... you can login now. + + Newsletters + Manage Billing Details + Manage Account Details + Manage Discounts + Manage Affiliate Details + Manage Newsletters +
\ No newline at end of file diff --git a/language/account_admin/english_account_admin.xml b/language/account_admin/english_account_admin.xml new file mode 100644 index 00000000..8e7a9942 --- /dev/null +++ b/language/account_admin/english_account_admin.xml @@ -0,0 +1,151 @@ + + + account_admin + + + Add Account + Update Account + Delete Account + View Account + Search Accounts + List All Accounts + Import Accounts + Send E-mail + + + Accounts + Add + List + Search + List All Accounts + Import Accounts + Send E-mail + + + Acount ID + Site ID + Creation Date + Date of Last Update + Expiration Date + Parent Account + Language + Country + Affiliate + Campaign + Reseller + Currency + Theme + Username + Password + Update Username Requested + Update Password Requested + Username/Password Update Key + Secret Question + Secret Answer + Child Accounts Inherit Parent's Groups? + Account Notes + Account Active? + First Name + Middle Name + Last Name + Title/Suffix + E-mail Address + HTML E-mail OK? + Street Address + Street Address 2 + City + State/Province + Zip/Postal Code + Company + Default Invoice Delivery Method + Show itemized detail pages + Invoice Grace Period (days) + Invoice Advance Generation (days) + Max Child Accounts + + + Statistics + + + Mr. + Ms. + Mrs. + Miss. + Dr. + Prof + The user has been added, and the account has been set as active. + The user has been added, and the account has been set as inactive. + The user has been e-mailed the password reset link and instructions + The user has been e-mailed the account verification link and instructions + Resend user verification e-mail + Send user password reset link + New Accounts Created: %%count%% + From Account + To Account + Subject + Message + High Priority? + The e-mail was sent to the specified account(s) + Send to all search results + The specified account does not exist! + Account Member of Group + Account Non-member of Group + Top User Sales + Leave blank to allow the system auto-generate + Send user welcome email? + + Account Overview + + Account Settings + Custom Fields + Notes + Click here to restore account overview... + Last Activity + Invoice Overview + Service Overview + + + Become User + Merge User Accounts + Send E-mail to User + Resend Verification E-mail + Password Reminder + Suspend User Login + Unsuspend User Login + Refresh View + + + Memos + Login Logs + Sessions + Invoices + Services + Billing Details + Discounts + Tickets + Affiliate Details + Sub-Accounts + Parent Account + + + Memo + Invoice + Service + Billing Details + Discount + Ticket + Affiliate + Sub-Account + + Merge Account +
+ This action will delete the selected account and associate all its + invoices, services, logs, and other records with the current account. +

+ Warning: This action cannot be undone! + ]]>
+ An error occurred - unable to merge the selected accounts + The selected accounts have been merged! +
\ No newline at end of file diff --git a/language/account_billing/english_account_billing.xml b/language/account_billing/english_account_billing.xml new file mode 100644 index 00000000..3ebf0079 --- /dev/null +++ b/language/account_billing/english_account_billing.xml @@ -0,0 +1,65 @@ + + + billing_account + + + Add Billing Details + Edit Billing Details + Modify Billing Details + Search By Billing Details + + + Billing Records + Add + Search + + + Account + Checkout Plugin + Nickname + Account Type + Card Number + Last 4 Digits of Current Account + Expires (month) + Expires (year) + Issued (month) + Issued (year) + + Check Type + Routing No. + Account No. + Check Number + SSN + Drivers License No. + Date of Birth + + First Name + Last Name + Primary Address + Secondary Address + City + State/Province + Zip/Postal + Country + Phone No. + E-mail + Company + + + + + This module contains the encrypted billing records. + + + + Missing required data, please check the form and try again + Expiration date invalid/expired, please check the form and try again + Invalid credit card details submitted, please check the form and try again + Current card on file + Change card number to + Can not remove a card that is already in use + Credit card has been removed + + New Routing Number + New Bank Account Number + \ No newline at end of file diff --git a/language/account_memo/english_account_memo.xml b/language/account_memo/english_account_memo.xml new file mode 100644 index 00000000..f2fc97a8 --- /dev/null +++ b/language/account_memo/english_account_memo.xml @@ -0,0 +1,23 @@ + + + account_memo + + Add Memo + View Memo + Search Memos + + Account Memos + Add Memo + View Memos + Search Memos + + Date + Staff/Admin + Account + Memo Type + Memo + Misc + + System + Staff/Admin Memo + diff --git a/language/affiliate/english_affiliate.xml b/language/affiliate/english_affiliate.xml new file mode 100644 index 00000000..09ffd55c --- /dev/null +++ b/language/affiliate/english_affiliate.xml @@ -0,0 +1,90 @@ + + + affiliate + + + Add New Affiliate + Affiliate Details + Search Affiliates + Affiliate Registration Form + Affiliate Statistics + + + + Affiliates + Add + List + Search + Statistics + + + Affiliate ID + Creation Date + Date of Last Change + Active? + Account + Available Campaigns + Commission Payout Type + Referring Affiliate + Maximum Tiers + Minimum Commission Required + Commission Type for New Charges + Commissions for New Charges + Commission Type for Recurring Charges + Commissions for Recurring Charges + Maximum Recurring Periods Commission Paid + Commission Payout Details + + + + This module controls the various affiliate accounts and settings, commissions, etc. + + + + Thank you for your interest in our affiliate program. Please read our commission rates and Payout options + below before proceeding. + + + Thank you for registering for an affiliate account. At this time your account has been + added and you may start referring new customers at once! + + + Thank you for your application for an affiliate account with us. We have recieved your + request and will notify you at once when it has been approved. + + + + You must specify an account, please go back and fix this. + The affiliate template you specified is not valid, please go back and fix this. + The account you specified already has an affiliate account! + The specified affiliate account no longer exists or you do not have permission to update it. + + No Commission + Fixed Rate Commission + Percentage Based Commission + Affiliate Template + + + PayPal E-mail + MoneyBookers E-mail + E-Bullion Account Number + + Make Commission Checks Payable To + Address + City + State/Province + Zip/Postal Code + Contact E-mail + + Sessions Referred + Accounts Referred + Invoices Referred + Commissions Paid + Invoices Outstanding + + Get HTML Code + New Affiliates + Top Affiliate Sales + Tier Number + + \ No newline at end of file diff --git a/language/affiliate_commission/english_affiliate_commission.xml b/language/affiliate_commission/english_affiliate_commission.xml new file mode 100644 index 00000000..86ed13c5 --- /dev/null +++ b/language/affiliate_commission/english_affiliate_commission.xml @@ -0,0 +1,42 @@ + + + affiliate + + + Generate Affiliate Commissions + Search Affiliate Commissions + Export Affiliate Commissions + + + Commissions + Generate Commissions + Search Commissions + + + Creation Date + Commission Period, Starting Date + Commission Period, End Date + Total Commissions + Notes (for Admin) + Notes (for Affiliate) + Commissions Paid? + + + + This module stores the affiliate commissions paid. + + + + Commission(s) + Run commission payment tool + Nothing to do... + No more commissions left to generate, please click submit to export the commission data... + There are no commissions to be generated for the selected date range. + + + + + diff --git a/language/affiliate_template/english_affiliate_template.xml b/language/affiliate_template/english_affiliate_template.xml new file mode 100644 index 00000000..784786f6 --- /dev/null +++ b/language/affiliate_template/english_affiliate_template.xml @@ -0,0 +1,34 @@ + + + affiliate_template + + + Add an Affiliate Template + View All Affiliate Templates + + + Configuration + Add + List + + + Commission Payout Type + Available Campaigns + Active? + Name + Notes + Maximum Tiers + Minimum Commission Required + Commission Type for New Charges + Commissions for New Charges + Commission Type for Recurring Charges + Commissions for Recurring Charges + Maximum Recurring Periods Commission Paid + + + + This module controls the default affiliate settings. + + + + diff --git a/language/asset/english_asset.xml b/language/asset/english_asset.xml new file mode 100644 index 00000000..a6d7f2e1 --- /dev/null +++ b/language/asset/english_asset.xml @@ -0,0 +1,32 @@ + + + Add + View + Search + Import Assets + + Assets + Add + List + Search + Import + + ID + Date Added + Last Modified + Assigned + Service ID + Pool ID + Asset + Misc Notes + + File to Import + Select the Asset Pool to place the imported assets in. + + Select a file to import below. + The file must contain a single asset per line. Optional: a second column with a value for the 'misc' field. + Example line in import file: 'asset,misc text' + Duplicates will not be imported. + + + \ No newline at end of file diff --git a/language/asset_invoice/english_asset_invoice.xml b/language/asset_invoice/english_asset_invoice.xml new file mode 100644 index 00000000..7f282a10 --- /dev/null +++ b/language/asset_invoice/english_asset_invoice.xml @@ -0,0 +1,10 @@ + + + Add New Asset Pool + View Asset Pool + + Asset Invoice Assignment + Assign Now + List + + \ No newline at end of file diff --git a/language/asset_pool/english_asset_pool.xml b/language/asset_pool/english_asset_pool.xml new file mode 100644 index 00000000..7de996d4 --- /dev/null +++ b/language/asset_pool/english_asset_pool.xml @@ -0,0 +1,17 @@ + + + Add New Asset Pool + + + Vew Asset Pool + + Asset Pools + Add + + + List + + ID + + Pool Name + \ No newline at end of file diff --git a/language/backup/english_backup.xml b/language/backup/english_backup.xml new file mode 100644 index 00000000..725a6aad --- /dev/null +++ b/language/backup/english_backup.xml @@ -0,0 +1,48 @@ + + + backup + + + Backup Database + Restore Database + Manual Backup + + + Backup + Backup + Restore + + + Creation Date + Scheduled Deletion Date + Notes + Modules to backup + File Name + + + + This module enables you to create backups of the database for later restoration. + + + + + If you have previously downloaded a backup, and it has been since been deleted, + you can use the manual backup feature to put it back in the restore list + so it can be used. You must upload it (via FTP or another method) to your + /includes/files/ directory, and then enter the name of the file below once + you have uploaded it. + Example: backup_10.xml + + You must enter the filename, please go back and correct this. + The filename you entered does not exist or is not writable, please correct this and try again. + Download Backup File + Restore + + If you choose to restore this backup, all you current data in the modules in this backup + WILL BE LOST, and all data and settings will be as they were at the time that this + backup was made. If you are sure you wish to continue, press the button below. + + Currently backing up %%mod%% + Database Backup Complete! + Database Restore Complete! + diff --git a/language/blocked_email/english_blocked_email.xml b/language/blocked_email/english_blocked_email.xml new file mode 100644 index 00000000..0e696874 --- /dev/null +++ b/language/blocked_email/english_blocked_email.xml @@ -0,0 +1,20 @@ + + + blocked_email + + Add Blocked Email + Update Blocked Email + View Blocked Emails + Search Blocked Emails + + Blocked Domains + Add + List + Search + + Creation Date + Date of Last Update + Email or Domain + Notes + + diff --git a/language/blocked_ip/english_blocked_ip.xml b/language/blocked_ip/english_blocked_ip.xml new file mode 100644 index 00000000..5b9b26ea --- /dev/null +++ b/language/blocked_ip/english_blocked_ip.xml @@ -0,0 +1,20 @@ + + + blocked_ip + + Add a Blocked IP + Update a Blocked IP + View Blocked IPs + Search Blocked IPs + + Blocked IPs + Add + List + Search + + Creation Date + Date of Last Update + IP Address or Subnet + Notes + + diff --git a/language/campaign/english_campaign.xml b/language/campaign/english_campaign.xml new file mode 100644 index 00000000..c5be966a --- /dev/null +++ b/language/campaign/english_campaign.xml @@ -0,0 +1,65 @@ + + + campaign + + Add Campaign + View Campaigns + Search Campaigns + + Campaigns + Add + List + Search + + Creation Date + Last Update + Start Date + Expire Date + Active? + Campaign + Campaign Description + Cost for Campaign + Target Conversion Rate + Campaign Destination Url (blank for home page) + + Select up to four banners, Flash, or HTML files to rotate through for this campaign. + Example: enter 10 for 10 percent + Advertisement One + Advertisement Two + Advertisement Three + Advertisement Four + Advertisement Five + Advertisement Six + Advertisement Seven + Advertisement Eight + Advertisement Nine + Advertisement Ten + Advertisement Eleven + Advertisement Twelve + Impressions + Clicks + Cost + CTR + Delete this file from rotation + Insert the random code below into your html file(s) where you would like the + advertisements to be displayed. All the advertisements for this campaign will be randomly + cycled... If you want to force a specfic advertisement, use the code below the advertisement + above in your html instead. + Invoices Referred + Revenue Generated + Average Cost Per Conversion + Average Sale Amount + Return on Investment (ROI) + Accounts Referred + Avg. CPI (Cost Per Impression) + Avg CPC (Cost Per Click) + Impression to Buy Ratio + Click to Buy Ratio + Impr. + Avg. CPC + Avg. CPI + Cost/Conv. + ROI + Avg. Sale + Revenue + diff --git a/language/cart/english_cart.xml b/language/cart/english_cart.xml new file mode 100644 index 00000000..a86f85e0 --- /dev/null +++ b/language/cart/english_cart.xml @@ -0,0 +1,59 @@ + + + cart + + The product you have attempted to add to the cart is not available at this time. + The product requires associated product(s) in order to be purchased. If you have + already purchased the associated products, please login so the required products can be + verified against your account. + The selected product requires other associated product(s) in order to be purchased. + %%items%%]]> + %%items%%]]> + The product you have attempted to add to the cart cannot be added, as it is already in the cart. + Quantity + For your existing domain + This is an IP based hosting plan, IP address to be assigned. + Domain Term + Domain registration for hosting plan + Domain transfer for hosting plan + New domain registration + Domain Transfer + Renew Domain + Park Domain + Pricing Structure + One-time Charge + Recurring Membership/Subscription + Trial for Membership/Subscription + Setup + Weekly Billing Schedule + Monthly Billing Schedule + Quarterly Billing Schedule + Semi-annual Billing Schedule + Annual Billing Schedule + Two-year Billing Schedule + Three-year Billing Schedule + Please Select Your Preferred Payment Option + Create Invoice Now + Manual Discount + Your cart is empty, please select one or more products to continue... + Base Price + Setup Price + Sub-total + Discount + Total + To edit or remove items, click here. + Click here for an itemized list of items in this purchase. + Click here to hide itemized list. + + Sorry, no online payment option has been defined for this order type. + Please contact customer service for ordering details. + + Ad Hoc Item + SKU + Item Name + Item Price + Taxable? + Attributes (up to 10) + The SKU, Item Name, and Item Price must all be entered, please go back and correct. + Upgrade for Service ID %%service%% + diff --git a/language/charge/english_charge.xml b/language/charge/english_charge.xml new file mode 100644 index 00000000..7892d4df --- /dev/null +++ b/language/charge/english_charge.xml @@ -0,0 +1,27 @@ + + + charge + + Add Charge + View/Edit Charge + View/Edit Charge + Search Charges + + Charges + Add + List + Search + Import + + Creation Date + Invoiced? + Sweep Type + Account + Product SKU + Service + Amount + Quantity + Taxable + Attributes + + diff --git a/language/checkout/english_checkout.xml b/language/checkout/english_checkout.xml new file mode 100644 index 00000000..e07a6403 --- /dev/null +++ b/language/checkout/english_checkout.xml @@ -0,0 +1,114 @@ + + + checkout + + Add A Checkout Option + View Checkout Option + + Checkout Plugins + Add + List + + Name + Description + Active? + Checkout Plugin + Plugin Configuration + Allow Recurring Charges? + Allow One-time Charges? + Allow Trials? + Minimum Purchase Amount Allowed + Maximum Purchase Amount Allowed + Maximum Failed Order Attempts Allowed + Require Manual Approval of all new Purchases? + Require Manual Approval af all Automatically Generated Invoices for Recurring Services? + Manual Approval Required for Countries + Manual Approval Required for Groups + Manual Approval Required for any new Purchase Greater Than + Manual Approval Required for Currencies + Default Checkout Option for Currencies + Default Checkout Option for Countries + Default Checkout Option for Groups + Default Checkout Option for Amounts Greater Than + Currencies Supported + Special Instructions to E-mail User + Require one of the following groups to access this checkout option + Excluded orders that include any of the following products from accessing this checkout option + Checkout Graphic URL + + + The discount code was entered incorrectly or is not valid. + Enter Discount Code + Purchase Totals + Enter Referrer Code + click here to redirect.]]> + Thank you! We will now finalize your purchase and forward you to the secure payment area. + Please select your preferred payment option above when you are ready to continue. + This checkout option is currently disabled, please select another. + Processing Mode + Test Mode + Live Mode + Sorry, the selected payment processor does not support the currency you have selected. Please change your currency to %%currency%%, or try another payment option. + Sorry, this payment processor can not handle pro-rated subscriptions - please select another payment option. + Address (street) matches, Zip does not + AVS Error + No match on street or zip + AVS not applicable to this transaction + Retry - system unavailable or timed out + Service not supported by issuer + Address information unavailable + 9 digit zip matches, address does not + Exact AVS match + Address and 5 digit zip match + 5 digit zip match, no street match + Please enter your billing details below + Please select a billing record on file to use + Credit Card No. + Card Type + Visa + Mastercard + Amex + Discover + Delta + Solo + Switch + JCB + Diners Club + Carte Blanche + enRoute + eCheck + Expiration Date + Expiration Month + Expiration Year + Process Order + Security No. ? + FOR VISA/MASTER CARD HOLDERS + For your safety and security, we require that you enter your card's + verification number. The verification number is a 3-digit number printed on the back of your + card. It appears after and to the right of your card number + FOR AMERICAN EXPRESS CARD HOLDERS + For your safety and security, we require that you enter your card's verification + number. The American Express verification number is a small 4-digit number printed on the + front of your card on the right hand side. + Thank you, your billing details have been stored for manual review and + verification of funds. Once we have reviewed and successfully debited the account provided, we + will update the invoice status. In the meanwhile, your invoice will be continue to be + displayed as due, you can ignore this unless we contact you stating otherwise. + Thank you, invoice billing status will be displayed as due until reciept and + verification of your funds. In the meanwhile, your invoice will be continue to be displayed + as due, you can ignore this unless we contact you stating otherwise. + The credit card details entered are invalid! + The expiration details entered are invalid! + Enter a new billing details + Missing required billing details + Check Number + Check Type + Business + Personal + Routing No. + Account No. + Date of Birth + Driver's License No. + SSN + Phone No. + diff --git a/language/core/english_core.xml b/language/core/english_core.xml new file mode 100644 index 00000000..36c7078a --- /dev/null +++ b/language/core/english_core.xml @@ -0,0 +1,183 @@ + + + Close + Support Tickets + Contact Us + Verify your account here: + Verify Account + Logout + Login + Cart + Checkout + Update Account + Administration + Newsletters + Reset password + Site Content + Account Login + Our Products + Account Options + My Invoices +
Site Options
+ Username + Password + Authorized Groups + Back + Refresh + Home + Register + Yes + No + None + Cancel + Submit + View + Add + Search + List + Help + + Clear + Delete + Processing... + Hide + Close + Save + Edit + Select All + Deselect All + Range Select + View / Edit + Export + Error + Alert + FREE + Currency Options + Overview + Day(s) + Week(s) + Month(s) + Year(s) + Jan + Feb + Mar + Apr + May + Jun + Jul + Aug + Sep + Oct + Nov + Dec + You must enter both your username and password. + You must be logged in to access this area. + The username or password you have provided does not match our records. + The username you provided does not exist in our database. + The password you provided is incorrect. + You have exceeded the allowed login attempts, your account has been temporarily locked. + Your account is currently inactive. + You have been successfully logged in. + Stay logged in + Your session has been renewed and will remain active. + Your session is set to expire in 60 seconds. + Register for a client account + Last successful login was on %date% from %ip% + You have been logged out. + Your session has expired, and you have been logged out. + Print this page now? + Session Timout Alert + If this page does not automaticaly refresh within a few seconds, please click below to continue. + Click here to continue + Are you sure you wish to delete this record? + %%module%% record Id %%id%% has been deleted. + The %%module_name%% record(s) you specified have been deleted. + The required %%module_name%% module does not exist. + Your account is not authorized for the %%module_name%% module. + The required %%module_name%% method does not exist. + %%module_name%% method is not a valid method. + The minimum length of this field is %%min_length%% characters. + The maximum length of this field is %%max_length%% characters. + The email address you have provided is invalid. + The date you have provided is invalid. + The address you have provided is invalid. + The zip code you have provided is invalid. + The phone number you have provided is invalid. eg: 123-456-7890 + The fax number you have provided is invalid. eg: 123-456-7890 + The credit card number you have provided is invalid. + The check account number you have provided is invalid. + This field can contain only numeric characters. + This field can contain only numbers with up to one decimal. + This field can contain only alphanumeric characters + This field cannot contain numeric characters. + This field is required and cannot be left blank. + The value you have entered is already in use, please try again. + Sorry, we are presently not accepting new registrations from your area + Sorry, we cannot accept new registrations from the e-mail address you provided + Sorry, the domain you specified is invalid and cannot be licensed. + Sorry, the IP address you specified is invalid and cannot be licensed. + Sorry, the value you entered is not valid. + Must include both numbers and letters, cannot be your initials, and cannot include your first or last name, your username, or your email. + Export Format + Comma Separated Value + Excel + Adobe Acrobat + Tab Separated Value + Extensible Markup Language + Export Pages + All Pages + Current Pages + Export To + Display in browser + Download to local computer + Email to user/list + Save to public area + Your Recent Searches + Your Saved Searches + Save Search + Your search has been saved. + Enter a nickname for this search: + No results for your search were found. + Your search has been completed sucessfully. + Results per page + Order results by + "%" for partial match + Export these search results to XML, PDF, Excel, Comma or Tab Separated Values. + View a printer friendly page with these search results. + Save this search for later retrieval. + Create a new search. + %%results%% record was found. + %%results%% records were found. + Authorized Groups + Authorized Methods + Execution Timing + General Debug Details + Execution Time + Session ID + Total SQL Queries + Reset your lost password here: + Manage your newsletters here: + Enter e-mail to subscribe: + Accounts + Campaigns + Database Mapping + Email Templates + Files + User Groups + Modules + Htaccess Groups + Newsletters + Site Configuration + Newsletter Subscribers + Static Pages + Tickets + Web Logs + Import + + + Affiliates + + Login Logs + Sessions + Domain Names +
diff --git a/language/country/english_country.xml b/language/country/english_country.xml new file mode 100644 index 00000000..b9623610 --- /dev/null +++ b/language/country/english_country.xml @@ -0,0 +1,26 @@ + + + + + Countries + Add + List + Search + List + + + Add Country + Update Country + View Countries + Search Countries + + + ID + Site ID + Country Name + Description + Notes + Two Digit Country Code + Three Digit Country Code + + diff --git a/language/currency/english_currency.xml b/language/currency/english_currency.xml new file mode 100644 index 00000000..0b4b1b58 --- /dev/null +++ b/language/currency/english_currency.xml @@ -0,0 +1,24 @@ + + + currency + + Add Currency + Update Currency + View Currencies + Search Currencies + + Currencies + Add + List + + ID + Site ID + Currency Name + Accepted? + Currency Conversion Rates <br><br> Click + the currency flag icon to get the latest currency exchange rates from XE.com + Notes + Symbol + Three Digit Currency Code + + diff --git a/language/db_mapping/english_db_mapping.xml b/language/db_mapping/english_db_mapping.xml new file mode 100644 index 00000000..eaf789ed --- /dev/null +++ b/language/db_mapping/english_db_mapping.xml @@ -0,0 +1,33 @@ + + + db_mapping + + Install Database Map + Manage Database Map + + Database Mapping + Configure + + Name + Notes + Active? + Type + Database Name + Database Host + Database Username + Database Password + Session Cookie Name + Group Mapping + Map File + Database Field Prefix + + Install + View/Edit + No local groups found, please add some! + No remote groups found, please add some! + No group mapping for this database map available + Unable to open database map plugin file! + Exported %%count_exp%% account(s) to the remote database + Updated %%count_upd%% account(s) in the remote database + Imported %%count_imp%% account(s) from the remote database + diff --git a/language/discount/english_discount.xml b/language/discount/english_discount.xml new file mode 100644 index 00000000..c5c2b2db --- /dev/null +++ b/language/discount/english_discount.xml @@ -0,0 +1,45 @@ + + + discount + + Add Discount + View All Discounts + Search Discounts + + Discounts + Add + List + Search + + Creation Date + Start Date + Expiration Date + Active? + Coupon Code + Notes + Maximum Uses per Account (blank for unlimited) + Uses Allowed Globally (blank for unlimited) + Available only to account + Available only to product(s) + Available only to group(s) + Available only to TLD(s) + Valid for new orders? + Type of Discount for new orders + Discount rate for new orders + Maximum discount for new orders + Minimum order total required + Valid for recurring charges? + Discount type for recurring charges + Discount rate for recurring charges + Maximum discount for recurring charges + Minimum recurring charge amount for discount to apply + + Percentage of Total + Flat Rate + + + Settings for Recurring Charges + Invoice Count + Revenue + Customer Savings + diff --git a/language/email_log/english_email_log.xml b/language/email_log/english_email_log.xml new file mode 100644 index 00000000..c97b8ea0 --- /dev/null +++ b/language/email_log/english_email_log.xml @@ -0,0 +1,25 @@ + + + + + Email Log + List + Search + E-mail Logs + E-mail Log Detail + + + Email Logs + List + Search + + + Date + Account + E-mail + Subject + Message + HTML + Urgent + User userread? + \ No newline at end of file diff --git a/language/email_queue/english_email_queue.xml b/language/email_queue/english_email_queue.xml new file mode 100644 index 00000000..e458bec4 --- /dev/null +++ b/language/email_queue/english_email_queue.xml @@ -0,0 +1,34 @@ + + + email_queue + + + + + + + + + + Email Queue + + + + + + + + + + Creation Date + Last Update + E-mail Sent? + Account + Email Template + SQL 1 + SQL 2 + SQL 3 + SQL 4 + SQL 5 + VARS + \ No newline at end of file diff --git a/language/email_template/english_email_template.xml b/language/email_template/english_email_template.xml new file mode 100644 index 00000000..837577b4 --- /dev/null +++ b/language/email_template/english_email_template.xml @@ -0,0 +1,27 @@ + + + email_template + + Add Email Template + + + View Email Templates + + + Email Templates + Add + List + + Email Setup to Use + Template Name + Enabled? + High Priority? + Available Shortcuts + Notes + Custom SQL 1 + Custom SQL 2 + Custom SQL 3 + + View Translations for this email template + Add Translation for this email template + diff --git a/language/email_template_translate/english_email_template_translate.xml b/language/email_template_translate/english_email_template_translate.xml new file mode 100644 index 00000000..8484f3d4 --- /dev/null +++ b/language/email_template_translate/english_email_template_translate.xml @@ -0,0 +1,19 @@ + + + email_template_translate + + Add Email Template Translation + View Email Template Translations + Search Email Template Translations + + Translations + Add + List + Search + + Email Template + Language + Template Subject + Text Message + HTML Message + diff --git a/language/faq/english_faq.xml b/language/faq/english_faq.xml new file mode 100644 index 00000000..3078ebe0 --- /dev/null +++ b/language/faq/english_faq.xml @@ -0,0 +1,47 @@ + + + faq + + + Add Page + View Pages + Search Pages + + + FAQs + Add + List + Search + + + Show in Category + Creation Date + Date of Last Update + Expiration Date + Active? + Name + Start Date + Display Sort Order + + + + Questions + Answers + FAQ Categories + Preview page + + Go up + Add a translations for this FAQ + + Sorry, no FAQs were found in this category, or your account is not authorized for this category. + + + Sorry, the requested page was not found, or you do not have the required level of authorization to view it. + + + No matches... + Submit at least a 4 character search... + + + + diff --git a/language/faq_category/english_faq_category.xml b/language/faq_category/english_faq_category.xml new file mode 100644 index 00000000..21a38365 --- /dev/null +++ b/language/faq_category/english_faq_category.xml @@ -0,0 +1,24 @@ + + + faq_category + + + Add FAQ Category + View FAQ Categories + + + Categories + Add + List + + + Sort Order + Date of Creation + Groups that can access this category + Name of Category + Category Description + Active? + + + Categories + diff --git a/language/faq_translate/english_faq_translate.xml b/language/faq_translate/english_faq_translate.xml new file mode 100644 index 00000000..92e4be70 --- /dev/null +++ b/language/faq_translate/english_faq_translate.xml @@ -0,0 +1,35 @@ + + + faq_translate + + + Add Translation + View Translations + Search Translations + + + Translation Administration + Add Translation + View Translations + Search Translations + + + + + Date of Creation + + FAQ + Translation Language + Answer + Question + + + + This module allows you to view/edit/add translations into other languages for your Frequently Asked questions (and their answers).<br><br>Add Translation: add a new FAQ translation<br><br>View Translations: view all existing FAQ translations<br><br>Search Translations: search all existing FAQ translations + + + + View all translations for this FAQ + Return to main page view + + diff --git a/language/file/english_file.xml b/language/file/english_file.xml new file mode 100644 index 00000000..5dc0f79b --- /dev/null +++ b/language/file/english_file.xml @@ -0,0 +1,52 @@ + + + file + + + Add File + View Files + Search Files + + + Files + Add + List + Search + + + Groups that can access this file + Select a file to upload + Creation Date + Last Update + Start Date + Expire Date + Display In Category + File Type + File Size (KB) + File Name + Description + Active? + File location + Sort Order + + + + This module allows you to manage your downloadable files and permissions. + + + + Test file download + Download file... + Sorry, there are no files in this category that you are authorized to view + + Upload File + File URL + File Path + + Cannot open remote file! + Cannot read local file! + Could not save uploaded file! + + Files Available for Download + ...more + diff --git a/language/file_category/english_file_category.xml b/language/file_category/english_file_category.xml new file mode 100644 index 00000000..217da20d --- /dev/null +++ b/language/file_category/english_file_category.xml @@ -0,0 +1,27 @@ + + + file_category + + + Add Category + View Categories + + + File Categories + Add + View + + + Creation Date + Category Name + Description + Active? + Available to Groups + Sort Order + + + + This module allows you to manage the categories for your downloadable files. + + + diff --git a/language/group/english_group.xml b/language/group/english_group.xml new file mode 100644 index 00000000..b3fda7d3 --- /dev/null +++ b/language/group/english_group.xml @@ -0,0 +1,48 @@ + + + group + + Add New Group + Update Group + View Groups + Search Groups + + Groups + Add + List + Search + + Date of Creation + Date of Activation + Date of Expiration + Name + Notes + Active + Allow Alternate Pricing? + Parent Group + +
+ For example, if a particular group is authorized for the Account Administration methods, any account + authorized for that group can access the Account Administration features. +

+ The group configuration is very flexible. For example, a group can have access to only some of the + methods in a specific module. So, group(s) can be define for employees that allow them to + view and search for accounts, but not to delete or edit them. +

+ The group hierarchy also allows for up to three levels of groups, so a parent group can be defined, + and each unlimited child groups can be defined under that parent group. Those 2nd tier child groups can then have children of their + own. The advantage of this system is that the child group(s) always inherit all it's parents + permissions, and then you can add additional permissions to the child. This makes it + possible to very quickly create a group that has all the permissions of an existing group, + plus a few changes. +

+ The group hierarchy is show above this help dialogue. + ]]>
+ + Select a module + Group Layout Visualization + Update Group to Method Relationships +
\ No newline at end of file diff --git a/language/host_provision_plugin/english_host_provision_plugin.xml b/language/host_provision_plugin/english_host_provision_plugin.xml new file mode 100644 index 00000000..3e59db79 --- /dev/null +++ b/language/host_provision_plugin/english_host_provision_plugin.xml @@ -0,0 +1,113 @@ + + + + Service + Enabled? + Options + Notes + Name of Associated Plan on Server - Required! + + Bandwidth Threshold, in bytes + Bandwidth Rollover Day of Month + Backup Manager + File Manager + Analog Stats + Hosting Type + Disk Space Quota + Telnet + SSH + Imap + Bind + Anonymous FTP + OpenSSL + SSI + Weblogs + Vacation Autoresponders + Majordomo + Squirrel Mail + Frontpage + Mivamerchant + Maximum number of users + ODBC + ColdFusion + Perl + PHP + MySQL + Urchin + MS FTP Service + CGI + SSL + w3svc Service + Allow Anonymous FTP logins? + Enable IIS Logging? + Maximum FTP connections + Allow Unlimited FTP connections? + Enable Bandwidth Quota? + Enable CPU Quota? + w3svc service maximum connections + Allow Unlimited w3svc connections? + Server Size + Enable Winmail service? + Allow user forwards? + Enable autoresponders + Drive where data will be stored + Color scheme to use + Mailscanner + Scan Incoming + Scan Outgoing + Scripts Manager + ASP Manager + Rotate Logs + Allow Backup + Tomcat 4 + Allow Subdomains + Sendmail + ProFTPd + Max Subdomains + Apache Jail (high security) + Spam Filter + Webalizer + Development Environment + + Enter the name of the WHM plan to grant this user + + Hosting Type + Available disk space + Limit Mailboxes + Mailbox quota limit + Limit Redirects + Limit mail groups + Limit Mail autoresponders + Limit web users + Limit databases + Available bandwidth per month + Months to keep traffic stats + Rotate logs by size + Maximum number of log files + SSI Support + DNS on? + Allow WWW redirect + Hosting + Frontpage support + Frontpage authorization + Frontpage SSL support + CGI + Perl + ASP + Error docs supported + Compress the logfiles + Allow scripting + WebMail + SSL + Available shells + Hard disk quota (0 is unlimited) + Available disk space + Mail service + Mailbox quota + Python + Webalizer + Available mail autoresponders + Available Subdomains + Available mailing lists + Available web applications + diff --git a/language/host_registrar_plugin/english_host_registrar_plugin.xml b/language/host_registrar_plugin/english_host_registrar_plugin.xml new file mode 100644 index 00000000..e62f8449 --- /dev/null +++ b/language/host_registrar_plugin/english_host_registrar_plugin.xml @@ -0,0 +1,63 @@ + + + host_registrar_plugin + + Install Plugin + Manage Registrar Plugins + + Registrar Plugins + Configure + + Active? + Registrar Nickname + File Name + + + This module controls the settings for the registrar plugins + + Install Plugin + View / Edit Plugin + Show Debug Details? + Primary NameServer + Secondary NameServer + Primary NameServer IP + Secondary NameServer IP + + TotalRegistration Partner Number + TotalRegistration Password + + OpenSRS Username + Test Key + Live Key + Live Mode? + + Nominet Tag + E-mail to Forward to for PGP Encryption + + MelbourneIT Username + MelbourneIT Password + E-mail to forward requests to for PGP encryption + Live Mode? + + Enom Username + Enom Password + Live Mode? + + E-mail to notify of new registrations + E-mail to notify of renewals + E-mail to notify of transfers + E-mail to notify of renewals + + BulkRegister Username + BulkRegister Password + E-mail to forward requests to for PGP encryption + Live Mode? + + Directi Username + Directi Password + Live Mode? + + GoDaddy Username + GoDaddy Password + Live Mode? + diff --git a/language/host_server/english_host_server.xml b/language/host_server/english_host_server.xml new file mode 100644 index 00000000..e44194c3 --- /dev/null +++ b/language/host_server/english_host_server.xml @@ -0,0 +1,35 @@ + + + host_server + + Add New Server + View Server + + Hosting Setup + Add Server + List Servers + + Active? + Show Debug Results? + Server Nickname + Server Notes + Email Template + Provisioning Plugin + + Maximum Accounts + Next Server (when this one is full) + Allow Name Based Accounts? + IP For Name Based Accounts + Allow IP Based Accounts? + IP List (separate w/new line) + Security Keycode + + FTP Method (recommended) + HTTP Method + Connection Mode + Host Name + File Path + Remote Username + Remote Password + Email to notify for required changes + diff --git a/language/host_tld/english_host_tld.xml b/language/host_tld/english_host_tld.xml new file mode 100644 index 00000000..fb26d7ed --- /dev/null +++ b/language/host_tld/english_host_tld.xml @@ -0,0 +1,74 @@ + + + host_tld + + Add New TLD + View All TLDs + + TLD Setup + Add + List + + Accepted? + Extension Name + Taxable + Whois Plugin + + Registrar Plugin + + Auto Search? + Default Registration Length (years) + Group Pricing Schedule + + Offer domain parking for this TLD? + Offer 1 year purchase options for this TLD? + Offer 2 year purchase options for this TLD? + Offer 3 year purchase options for this TLD? + Offer 4 year purchase options for this TLD? + Offer 5 year purchase options for this TLD? + Offer 6 year purchase options for this TLD? + Offer 7 year purchase options for this TLD? + Offer 8 year purchase options for this TLD? + Offer 9 year purchase options for this TLD? + Offer 10 year purchase options for this TLD? + Please enter the domain name and extension below + Please enter the name and select an extension below + Please enter the desired domain name and select an extension above + Checking domain availibility, please hold.... + The specified domain is invalid or not available, please try another... + Congratulations! The domain is available, you can purchase this hosting plan now. + Congratulations! The domain is available, you can purchase it now. + Checking if domain can be transferred, please hold.... + The specified domain is invalid, unregistered, or unsupported by our + registrar, please try another domain or select the "update nameserver" option above + instead... + Congratulations! The domain can be transferred to our registrar, you may now + purchase this hosting plan. + Congratulations! The domain can be transferred to our registrar, you may now + continue the transfer. + Complete Domain Transfer + Register this domain name + Park this domain name + Register or Park a new domain + Transfer an existing domain + Available! + Reserved + Searching... + Continue with Purchase + Show More Domain Suggestions + Suggest Domains + Please make your selection(s) from the list above then press continue + Bulk Domain Registration Form + Bulk Domain Registration Form +
+ Example: +

+ domain123.com
+ domain345.net
+ domain456.org
+ ]]>
+ The TLD %%tld%% is not accepted and the domain %%domain%% has been removed. + The domain %%domain%% is not available and has been removed. +
diff --git a/language/host_whois_plugin/english_host_whois_plugin.xml b/language/host_whois_plugin/english_host_whois_plugin.xml new file mode 100644 index 00000000..c5dedb13 --- /dev/null +++ b/language/host_whois_plugin/english_host_whois_plugin.xml @@ -0,0 +1,7 @@ + + + host_whois_plugin + + Whois Server (eg: whios.networksolutions.com) + Available Response String (eg: AVAIL, NOT TAKEN, etc) + diff --git a/language/htaccess/english_htaccess.xml b/language/htaccess/english_htaccess.xml new file mode 100644 index 00000000..05cc2997 --- /dev/null +++ b/language/htaccess/english_htaccess.xml @@ -0,0 +1,32 @@ + + + htaccess + + Add Htaccess Group + View Htaccess Group + + Htaccess Groups + Add + List + + Start Date + Expiration Date + Name + Description + Active? + Available to Groups + + View All Directories for this Htaccess Group + Add Directory to this Group + Click Here to Enter + Thank you for logging in - you will be redirected to the protected area you were + attempting to access. If you do not wish to wait to be redirected, you may click the link + below now. + Your account is not currently authorized for the protected area you were + attempting to access. Please verify that your billing information is correct, and that your + account does not have any overdue charges. This situation could also be caused by an expired + membership/subscription that may need to be renewed. If you have any questions, please + contact our customer service department. + Your account is currently not authorized for any of our protected areas. + Downloads + \ No newline at end of file diff --git a/language/htaccess_dir/english_htaccess_dir.xml b/language/htaccess_dir/english_htaccess_dir.xml new file mode 100644 index 00000000..4a72d5ad --- /dev/null +++ b/language/htaccess_dir/english_htaccess_dir.xml @@ -0,0 +1,46 @@ + + + htaccess_dir + + Add Protected Directory + Update Protected Directory + + Directories + Add + List + + Display to Users? + Current Htaccess File + Protection Type + Name + Description + URL + System Path + FTP Host + FTP Path + FTP Username + FTP Password + FTP Port + Parent Htaccess Group + Recursively Protect Sub-directories? + + View All Protected Directories in this Group + Local Directory + Remote Directory (via FTP) + You can exlcude specific file types from being protected by checking them to the + right. All other file types will be protected. + You can exlcude specific file types from being protected by checking them to the + right. All other file types will be protected. To improve performance and reduce server + load, it is advised that you exclude any file types that do not need protection, and that + receive a lots of hits, such as images, css, javascript, etc. Protecting your main content + pages, such as PHP, HTML, PDF, etc, is generally all that is needed. + The path you specified does not exist, please check again to be sure you have + entered it correctly. You must enter the FULL system path to the directory you wish to + protect. + The path you specified is not writable, the user PHP is running as does not have + high enough permissions to create the .htaccess file. To fix this, please use your FTP + program to login and CHMOD the file to 777. + Protection of the %%dira%% directory has been removed. + Deletion of the %%dir%% file has failed, you may need to remove the .htaccess file + manually to be able to access it properly. + diff --git a/language/htaccess_exclude/english_htaccess_exclude.xml b/language/htaccess_exclude/english_htaccess_exclude.xml new file mode 100644 index 00000000..6720183e --- /dev/null +++ b/language/htaccess_exclude/english_htaccess_exclude.xml @@ -0,0 +1,15 @@ + + + htaccess_exclude + + Add File Type + View File Types + + File Types + Add + List + + Name + File Extension + + diff --git a/language/import/english_import.xml b/language/import/english_import.xml new file mode 100644 index 00000000..bb7a515b --- /dev/null +++ b/language/import/english_import.xml @@ -0,0 +1,36 @@ + + + import + + + + + + + Import + + + Import + Import Plugins + + + + + + + + + + + + + + Import Plugin + Plugin Options + + Ready - Click to process + Not ready... + Done - Click to undue + + + \ No newline at end of file diff --git a/language/invoice/english_invoice.xml b/language/invoice/english_invoice.xml new file mode 100644 index 00000000..5ccda531 --- /dev/null +++ b/language/invoice/english_invoice.xml @@ -0,0 +1,146 @@ + + + invoice + + Add Invoice + Invoice Number + Search Invoices + Reconcile Invoice Number + Refund Invoice Number + + Invoices + Statistics + Add + List + Search + + Invoice Number + Creation Date + Last Updated + Approved? + Balance Due + Refunded? + Printed? + Account + Billing Details + Affiliate ID + Campaign + Reseller + Checkout Plugin + Gateway Response + Tax Zone + Tax Amount + Discount(s) + Discount Amount + Invoice Total + Billed Amount + Billing Currency + Actual Billed Amount + Actual Billing Currency + Due Notices Sent + Max Due Notices + Next Notice Date + Grace Period (days) + Due Date + Suspend Billing Activity? + + This module controls the invoicing + + New Invoices Created: %%count%% + Affiliate Commissions + Products/Services Ordered + View Printer Friendly Version + Select Your Preferred Payment Option + Sales + Forecast + Quota + AR Credits + AR Balance + Users + Tickets + Affiliate Sales + Indicator + Period + Current + Previous + Change + This Year + This Month + This Week + Last Year + Last Month + Last Week + Today + vs + Weekly + Monthly + Yearly + Payment Amount + Refund Amount + Memo + Invoice Refund Completed + Invoice Reconciliation Completed + Customer overpaid by %%amt%%, please create a discount or apply this amount to another + invoice to balance this customnoer to balance the account. + Discount User + View Items + Finalize Invoice + %%amount%%.]]> + Attempt Billing Now + + Memo Text + Thank You! + Click here to review your order details... + Click here to return to your account center... + We want to take this opportunity to thank you for your purchase!

+ Please stick around a while and explore the rest of our product line while you are on our site!

+

We have so much to offer you... click here for more of our products and services.

+ ]]>
+ Select SKU of Product to add + Add a Domain to Invoice + Add ad hoc item to Invioce + Billing Period: %%start%% - %%stop%% + Pending Billing + Paid in full + You presently have unpaid invoices totaling %%total%%.

+

To pay all unpaid invoices now, please CLICK HERE.

+

To select the invoices you wish to pay, please CLICK HERE.

+ ]]>
+ The selected invoices total %%total%%.

+

To make payment, please select a payment option below.

+ ]]>
+ Pay Selected Invoices + + Items Purchased + Billing Details + Services + + Memos + + Print Invoice + Attempt Auto-billing Now + Refund Invoice + Reconcile Invoice + + + + DISCOUNTS + TOTAL + PAID + DUE + DATE DUE + PAYMENT STATUS + INVOICE NUMBER + PAGE + DATE + INVOICE + SKU NO + DESCRIPTION + QTY + UNIT COST + TOTAL COST + TAX +
diff --git a/language/invoice_commission/english_invoice_commission.xml b/language/invoice_commission/english_invoice_commission.xml new file mode 100644 index 00000000..03f30eb8 --- /dev/null +++ b/language/invoice_commission/english_invoice_commission.xml @@ -0,0 +1,4 @@ + + + invoice_commission + diff --git a/language/invoice_item/english_invoice_item.xml b/language/invoice_item/english_invoice_item.xml new file mode 100644 index 00000000..c10401c3 --- /dev/null +++ b/language/invoice_item/english_invoice_item.xml @@ -0,0 +1,17 @@ + + + invoice_item + + Invoice Items + + SKU + Item Type + Product Attributes + Base Price + Setup Price + Recurring Schedule + Domain Name + Domain Term + Domain Type + + diff --git a/language/invoice_memo/english_invoice_memo.xml b/language/invoice_memo/english_invoice_memo.xml new file mode 100644 index 00000000..2b1d2730 --- /dev/null +++ b/language/invoice_memo/english_invoice_memo.xml @@ -0,0 +1,29 @@ + + + invoice_memo + + Add Memo + View Memo + Search Memos + + Invoice Memos + Add Memo + View Memos + Search Memos + + Date + Invoice Number + Account + Memo Type + Memo + Misc + + System + Staff/Admin Memo + Payment Postback + Invoice Approval + Invoice Voided + Invoice Reconciled + Invoice Refunded + User Canceled + diff --git a/language/license/english_license.xml b/language/license/english_license.xml new file mode 100644 index 00000000..578d3d98 --- /dev/null +++ b/language/license/english_license.xml @@ -0,0 +1,31 @@ + + + license + + Add License + View License + Search + + Licensing + Add + List + Search + + Creation Date + Last Modified + Expiry Date + Permanant License Date + Account + Invoice No. + License Key + License Code + Permanent Status + License Type + Trial/Temporary Term (days) + Domain Authorized + IP Authorized + Domain Change Requested + IP Change Requested + Change Status + + diff --git a/language/log_error/english_log_error.xml b/language/log_error/english_log_error.xml new file mode 100644 index 00000000..4c439391 --- /dev/null +++ b/language/log_error/english_log_error.xml @@ -0,0 +1,19 @@ + + + log_error + + View Error Logs + Search Error Logs + + Error Logs + List + Search + + Date of Creation + Account + Module + Method + Error Message + + Errors Logged by the System: %%count%% + diff --git a/language/login_log/english_login_log.xml b/language/login_log/english_login_log.xml new file mode 100644 index 00000000..68392e6f --- /dev/null +++ b/language/login_log/english_login_log.xml @@ -0,0 +1,18 @@ + + + login_log + + View Login Logs + Search Login Logs + + Login Logs + List + Search + + Login Date + Account + Login Succeeded? + IP Address + + User Logins: %%count%% + diff --git a/language/module/english_module.xml b/language/module/english_module.xml new file mode 100644 index 00000000..ddd8b2e5 --- /dev/null +++ b/language/module/english_module.xml @@ -0,0 +1,65 @@ + + + Module + Add a new Module record + View/Edit Module + Search for a specific Module record + Install New Module + Database and Method Consistancy Check + Modules + Add + List + Search + Install + Add + List + Search + Development + Generate Install Files + Translate Modules + Upgrade + Name + Notes + Module Installed? + Show In Modules Menu? + Display as child of module + Date of creation + Date of last update + + Module Name + Authorized Groups + Unable to install required sub-module %%sub_module%% + The Module Installation Failed! + You must enter a module name + You must select at least one group to be authorized for this module + This module already exists in the database + The specified module directory does not exist + The specified module class file does not exist + The specified module construct file does not exist + The specified module installation file does not exist + This module already requires that the %%$depend%% module be installed + first + The module installation has completed! + + Uninstall Module + Install Complete + View all methods for this module + Add a method for this module + Select all modules to check for upgrades + Select a default group to add any new methods to + + Version and File Consistancy Check + Latest Version + Your Installation Version + Your Encoding Version + Your Optional Modules Installed + Check file consistancy + + Modified Files: + Missing Files: + No modified files. + No missing files. + %%mis%% file(s) are missing from your current installation. + %%md5%% files(s) are corrupt or modified in your current installation. + + diff --git a/language/module_method/english_module_method.xml b/language/module_method/english_module_method.xml new file mode 100644 index 00000000..80d53178 --- /dev/null +++ b/language/module_method/english_module_method.xml @@ -0,0 +1,26 @@ + + + module_method + + Add a Method + Update Method + View Methods + Search Methods + + Methods + Add + Search + + Module Name + Method Name + Notes + Menu Page Link + Display In Menu? + + Add to Group? + Update Group Authorizations + Delete All Methods for this Group + Go Back to Group Details + Note - Checkboxes that are greyed out indicate inheritance from parent + groups + diff --git a/language/net_term/english_net_term.xml b/language/net_term/english_net_term.xml new file mode 100644 index 00000000..aaa8b80b --- /dev/null +++ b/language/net_term/english_net_term.xml @@ -0,0 +1,21 @@ + + + Add Net Terms + View Net Terms + + Net Terms + Add + List + + Enabled? + Available to Groups + Available to Checkout Plugin + Name + SKU + Fee Type + Late Fee + Terms (eg: 15,30,90) + Suspend after Intervals + Enable E-mails? + Charge Sweep Type + diff --git a/language/newsletter/english_newsletter.xml b/language/newsletter/english_newsletter.xml new file mode 100644 index 00000000..bcf458e3 --- /dev/null +++ b/language/newsletter/english_newsletter.xml @@ -0,0 +1,67 @@ + + + newsletter + + Add Newsletter + View Newsletters + Search Newsletters + + Newsletters + Add + List + Search + Send + Statistics + + Available to Group(s) + Newsletter Name + Description + Notes + Active? + Display at Signup? + + View all subscribers of this newsletter + Send To Newsletter Subscribers + Send Using Email Setup + Message Subject + Message Body, Text Version + Message Body, HTML Version + Set as High Priority? + Test Only? + You must enter a subject for the message! + You must enter the text body for the message! + You must enter the html body for the message! + Could not send the newsletter! + The newsletter mailing has been completed! + No subscribers found for the selected newsletters(s) + The selected newsletters have been sent + Subscribe Now + Unsubscribe Now + Select newsletters to receive: + You must enter your name, please go back and fill in your name. + You must select at least one newsletter to subscribe to. + You must enter a valid email address, please go back and correct this. + You have already submitted a request within the last %limit% seconds, + please wait before you try again. + Thank you for subscribing! Futher action on your part is required; we have + sent an email to the address you provided requesting your confirmation. Once you confirm as + explained in your email, no further action on your part will be required. + The confirmation link you followed is older than 72 hours and has + expired, or has been malformed by your email reader and therefore does not work. Please + check that the full link shown in your email reader has displayed in browser address bar, or + you can start the newsletter subscription process again by clicking "Submit" below: %here%. + We have confirmed your email, and you have been subscribed for the + selected newsletters. Any newsletter emails you recieve in the future will have a link for + removing yourself from the newsletters you are currently subscribed to. + Newsletter Confirmation Required + Hello %name%, To confirm your newsletter subscription, you will need to click + the link below. Once you do this no futher action on your part will be required. Click: + %confirm_url% If the text above does not show up as a link in your browser, you can paste it + to your browser. Thank you, %site_name% + The form above allows you to subscribe to our newsletters, and the + form below is for removing any current newsletter subscriptions that you no longer wish to + receive. + Select newsletters to unsubscribe + You have been unsubscribed from the selected + newsletters + diff --git a/language/newsletter_subscriber/english_newsletter_subscriber.xml b/language/newsletter_subscriber/english_newsletter_subscriber.xml new file mode 100644 index 00000000..4650be99 --- /dev/null +++ b/language/newsletter_subscriber/english_newsletter_subscriber.xml @@ -0,0 +1,22 @@ + + + newsletter_subscriber + + Add Newsletter Subscriber + View Newsletter Subscribers + Search Newsletter Subscriber + + Subscribers + Add + List + Search + + Creation Date + Newsletter + Email Address + HTML Email Accepted? + First Name + Last Name + + Active Newsletter Subscribers: %%count%% + diff --git a/language/product/english_product.xml b/language/product/english_product.xml new file mode 100644 index 00000000..35659f1f --- /dev/null +++ b/language/product/english_product.xml @@ -0,0 +1,116 @@ + + + product + + Add New Product + View Product + Search All Products + + Products + Add + List + Search + + Creation Date + Last Update + Product SKU + Taxable? + Active? + Position/Ranking + User can add to cart multiple times for one purchase? + Available to Group(s) + Display in Category(s) + Automatically Generate Discount Code When This Product Is Ordered? + Discount Amount to Create + Pricing Structure + Base Price + Setup Price + Group Pricing Structure + Recurring Billing Schedule + Day of Month to Bill + Week Number + Allow Change of Billing Schedule? + Allow Cancelation of Service? + Trial Period Type + Trial Length + Trial For Product + Product(s) Required for Access to This Product + Match Type for Required Products + Purchasing This Product Grants Access to the Following Product(s) + Purchasing This Product Grants Access to the Following Group(s) + Type of Group Access Granted + Grant access to the selected group(s) for X days + Product Thumbnail + Default Billing Schedule + Set up a hosting account when this product is ordered? + Target Server + Allow Domain Purchases with this Hosting Plan? + Allow Purchases without a domain? + Discount the following TLDs + Domain Purchase Discount Amount + Allow Modification of Service? + Waive setup fee when modifying service? + + Setup + Domain Transfer / Registrations Options + Register new domain name + Transfer existing domain name + I will use an existing domain name and update my nameservers only. + All I need is an IP based hosting plan. + Options Available to Subscribers + One-time Charge + Recurring Membership/Subscription + Trial for Membership/Subscription + Bill on Aniversary Date of Subscription + Bill on Fixed Schedule + Offer weekly billing schedule for this product? + Offer monthly billing schedule for this product? + Offer quarterly billing schedule for this product? + Offer semi-annual billing schedule for this product? + Offer annual billing schedule for this product? + Offer two-year billing schedule for this product? + Offer three-year billing schedule for this product? + Weekly Billing Schedule + Monthly Billing Schedule + Quarterly Billing Schedule + Semi-annual Billing Schedule + Annual Billing Schedule + Two-year Billing Schedule + Three-year Billing Schedule + Require All Selected Products + Require Any One Selected Product + Grant access for specified amount of days: + Grant access while associated subscription is active + Grant access forerver + (example: 0.10 = 10%) + This product is a trial for SKU %%sku%%, which can be viewed in detail here: + If you wish to cancel prior to the trial expiring, you may do so and you will not + be billed for SKU %%sku2%%. + This trial will last for %%length%% days before it expires and you are + billed for the full cost of SKU %%sku1%%. + This trial will last for %%length%% months before it expires and you are + billed for the full cost of SKU %%sku1%%. + This trial will last for %%length%% weeks before it expires and you are + billed for the full cost of SKU %%sku1%%. + You must choose a 'Domain Transfer / Registration Option' to continue. + You must select a valid domain name to continue. + Top Product Sales + Add to Cart + Add to Cart and Checkout + Manage Images + Attributes + Advanced Billing + Associations + Discounts + Hosting + Product Plugins + Link + Clone + Please enter a unique SKU for the newly cloned product + The product has been cloned, click here to view it now + Finalize Purchase + Login and review purchase + Login to existing client account + Register for new client account + Proceed to checkout + diff --git a/language/product_attr/english_product_attr.xml b/language/product_attr/english_product_attr.xml new file mode 100644 index 00000000..2ab79a22 --- /dev/null +++ b/language/product_attr/english_product_attr.xml @@ -0,0 +1,22 @@ + + + product_attr + + Add New Product Attribute + Delete This Attribute + + Name + Description + Type + Attribute Input Type + Default Input Value + Base Price + Setup Price + Group Pricing Schedule + + Checkbox (yes/no) + Text Input Field + Multiple Choice Menu + Textarea Input Field + User input required to add product to cart + diff --git a/language/product_cat/english_product_cat.xml b/language/product_cat/english_product_cat.xml new file mode 100644 index 00000000..fe559652 --- /dev/null +++ b/language/product_cat/english_product_cat.xml @@ -0,0 +1,30 @@ + + + product_cat + + Add Product Category + View Product Categories + View all translations for this category + Add a translation for this category + + Categories + Add + List + + Category Nickname + Category Notes + Active? + Maximum Products Per Page + Template + Thumbnail + Image + Position/Ranking + Parent Category + Available to Group(s) + + View items on page: + No Products Available in this Category... + No Description + Please select a plan below + No Plans Available in this Category... + diff --git a/language/product_cat_translate/english_product_cat_translate.xml b/language/product_cat_translate/english_product_cat_translate.xml new file mode 100644 index 00000000..e82878e2 --- /dev/null +++ b/language/product_cat_translate/english_product_cat_translate.xml @@ -0,0 +1,17 @@ + + + product_cat_translate + + Add Product Category Translation + Edit Product Category Translation + + Product Category Translations + Add Category Translation + View All Translations + + Product Category + Language + Name + Description + + diff --git a/language/product_img/english_product_img.xml b/language/product_img/english_product_img.xml new file mode 100644 index 00000000..e6524e37 --- /dev/null +++ b/language/product_img/english_product_img.xml @@ -0,0 +1,18 @@ + + + product_img + + Add Product Image + View Product Image + Delete This Image + + Product SKU + Image Type + URL + Name + + Upload a file from your computer: + ...Or, enter the URL of the image: http://domain.com/image.gif + Saved Image + Remote Image + diff --git a/language/product_translate/english_product_translate.xml b/language/product_translate/english_product_translate.xml new file mode 100644 index 00000000..ff630ab2 --- /dev/null +++ b/language/product_translate/english_product_translate.xml @@ -0,0 +1,19 @@ + + + product_translate + + Add Product Translation + View Product Translation + Search Product Translations + + Product Translations + Search Product Translations + + Product + Language + Product Name + Short Description + Full Description + Extra E-mail Instructions + + diff --git a/language/radius/english_radius.xml b/language/radius/english_radius.xml new file mode 100644 index 00000000..c1b84ebd --- /dev/null +++ b/language/radius/english_radius.xml @@ -0,0 +1,47 @@ + + + + Add + List + Search + + + Radius + Add + List + Search + + + ID + + Account + Service Id + Active? + SKU + Remove This + Auth Type + Username + Password + Service Type + Session Limit + Idle Limit + Port Limit + Analog? + Digital + Filter ID + Netmask + Framed Route + Speed Limit + Static IP + Profiles + Time Bank + + Existing Authentication Management + Assign Available Authentication + MAC Address + Username + Password + + The username/password "%%user%%/%%pass%%" combo is not valid or is already in use, example username/password: "user1965/MySecret29". + "The MAC ID "%%user%%" is not valid or is already in use, example MAC ID: "00 0A E4 3A 18 13". + \ No newline at end of file diff --git a/language/realestate/english_realestate.xml b/language/realestate/english_realestate.xml new file mode 100644 index 00000000..57cfc88c --- /dev/null +++ b/language/realestate/english_realestate.xml @@ -0,0 +1,32 @@ + + + Add Property + View Properties + Search Properties + + Realestate + Configuration + Add Property + List Properties + Search Properties + + My Voice Center + Features + Overview + Activity + Faxes + Voicemail + Blacklist + Add a Blacklist + List all Blacklists + Call Forwarding + Busy Call Forwarding + Faxing + Failover Number + Remote Call Forwarding + Call Waiting + + MLS Number + Price +
Address
+
\ No newline at end of file diff --git a/language/report/english_report.xml b/language/report/english_report.xml new file mode 100644 index 00000000..ac324b0b --- /dev/null +++ b/language/report/english_report.xml @@ -0,0 +1,35 @@ + + + reports + + + Generate New Report + + Delete Saved Report + Report Administration + Locate Saved Report(s) + + + Reports + + + + Report Administration + + + + + Date Generated + Date Last Run + Report Template + Nickname + Criteria + Company or Reseller + + + Select A Report + Select A Report Category + No Reports for this Module + View + Update Query + \ No newline at end of file diff --git a/language/service/english_service.xml b/language/service/english_service.xml new file mode 100644 index 00000000..c2e27f8b --- /dev/null +++ b/language/service/english_service.xml @@ -0,0 +1,106 @@ + + + service + + Add Service + View Service + Search Services + Recurring Details + Group Details + Domain Details + Hosting Details + Product Plugin + Memos + Modify Service + Billing Suspended + + + Services + Add + List + Search + + Service Number + Date Created + Date Last Modified + Parent Service + Invoice Number + Invoice Item Number + Account + Billing Details + Product ID + Product SKU + Active? + Bind Services + Type + Price + Price Type + Taxable? + Queue Status + Last Invoiced + Next Invoice + Recurring Type + Recurring Schedule + Recurring Day of Month + Recurring Week + User May Change Schedule? + User May Cancel + User May Modify + Associated Groups to Grant + Group Access Type + Group Access Period (Days) + Host Server + Host Provisioning Data + Hosting IP + Host Username + Host Password + Domain Name + Domain TLD + Domain Registration Term + Domain Type + Date Domain Expires + Domain TLD + Domain Registrar + Suspend Billing Activity? + Phone Number + + + Hosting + Hosting + Group Access + Recurring Only + Group Access + Domain Name + Product Plugin + Group Access + Product Plugin + + Add New + Activate + Deactivate + Delete + Edit/Update + None + Force Current Queue + + Are you sure you wish to cancel this service? + Are you sure you wish to change the billing scheudle of this service? If so, your subscription price will be modified accordingly and you will be billed at the new rate on your next invoice date. + Your request has been sent to our customer service department for review, thank you! + Your account is not authorized to cancel this service. + Your account is not authorized to change the billing schedule of this service. + Resend hosting details e-mail + The hosting details have been resent to the customer's e-mail address on file. + %%amount%%.]]> + Find Recurring Invoices + Cancel This Subscription + Plugin + Retrieve all Invoices for service %%service%%... + + This will allow you to effectively upgrade or downgrade your current service.
+ To select another product,
please click here. + ]]> + Please select a product + Modify My Service Now + Modify Service to Another Product + Reactivate This Service + The billing for this service has been suspended and service will expire on + diff --git a/language/service_memo/english_service_memo.xml b/language/service_memo/english_service_memo.xml new file mode 100644 index 00000000..8be0473e --- /dev/null +++ b/language/service_memo/english_service_memo.xml @@ -0,0 +1,23 @@ + + + service_memo + + Add Memo + View Memo + Search Memos + + Service Memos + Add Memo + View Memos + Search Memos + + Date + Staff/Admin + Service ID + Memo Type + Memo + Misc + + System + Staff/Admin Memo + diff --git a/language/session/english_session.xml b/language/session/english_session.xml new file mode 100644 index 00000000..a8f6d732 --- /dev/null +++ b/language/session/english_session.xml @@ -0,0 +1,27 @@ + + + session + + View Sessions + Search Sessions + + Sessions + List + Search + + Creation Date + Last Used Date + Date of Expiration + User Logged In? + IP Address + Theme + Country + Language + Currency + Weight Unit + Account + Reseller Account + Affilliate Account + + User Sessions: %%count%% + diff --git a/language/setup/english_setup.xml b/language/setup/english_setup.xml new file mode 100644 index 00000000..e393f131 --- /dev/null +++ b/language/setup/english_setup.xml @@ -0,0 +1,106 @@ + + + setup + + Main Setup + Main Setup + + Setup + Site Setup + PHP Details + + ID + Site ID + Default Country + Default Language + Default Currency + Default Weight + Default User Theme + Default Admin Theme + Default Group + Default Affiliate Template + Default Affiliate + Default Reseller + Default Email Setup + SSL URL + NON-SSL URL + Login Expiration Time (seconds) + Cookie Name + Cookie Expiration Time (seconds) + IP Matching For Sessions + Error Reporting + Site Name + Site Email + Default Time Format + Default Date Format + Default Date-Time Format + Decimal Placement + Debug + Allowed Login Attempts + Login Attempt Period (in seconds) + Login Lock Period (in seconds) + Search Expiration (in seconds) + Cache DB Queries? + Show Newsletter Form on Registration page? + Require email validation on new accounts? + Cache Sessions? + Store Weblogs? + Auto Create Affiliate Account on new Account creation? + Display newsletter link? + Display contact us link? + Display domain link? + Display cart link? + Display checkout link? + Display products link? + Display product categories block? + Display file module block? + Display static page module block? + Display affiliate link? + Display affiliate input block at checkout? + Display ticket link? + Display discount code block at checkout? + Operating System + Curl Path (if using binary version) + Default Billing Day of Month + Grace Period (days) + Default Max Billing Notices + Generate Invoices how Long Prior to Due Date (days) + Company Address + Company City + Company State/Province + Company Postal/ZIP code + Company Phone + Company Fax + License Key + License Code + + Error Reporting Off + Fatal errors that occur at runtime + Non-fatal errors that occur at runtime + Parse errors (caused by invalid syntax) + Non-critical errors + Fatal errors that occur at PHP engine startup + Non-fatal errors that occur at PHP engine startup + Fatal errors that occur at script compile-time + Non-fatal errors that occur at script compile-time + User-thrown fatal error + User-thrown non-fatal error + User-thrown non-critical error + The combined value of all available error levels + + select option + Day (01..31) + Abbr. Weekday (Mon) + Full Weekday (Monday) + Month (01..12) + Abbr Month (Mar) + Full Month (March) + Year (00..99) + Year (2004) + + space + dash + slash + period + comma + diff --git a/language/setup_email/english_setup_email.xml b/language/setup_email/english_setup_email.xml new file mode 100644 index 00000000..b58379d4 --- /dev/null +++ b/language/setup_email/english_setup_email.xml @@ -0,0 +1,33 @@ + + + setup_email + + Add Email Setup + View Email Setups + + Email Setup + Add + List + + Account + Email Setup Name + Notes + SMTP Account? + From Name + From Email + CC List (cc@mail.com,ccme@mail.com) + BCC List (bcc@mail.com,bccme@mail.com) + Server (required only for SMTP - smtp.srv1.com;mail.srv2.com) + Username (required only for SMTP) + Password (required only for SMTP) + Message Retrieval Method + Host for Message Retrieval + Username + Password + Action after Message Retrieval + Queue E-mails? + + + Leave message in mailbox + Delete message from mailbox + diff --git a/language/setup_invoice/english_setup_invoice.xml b/language/setup_invoice/english_setup_invoice.xml new file mode 100644 index 00000000..2c9eac74 --- /dev/null +++ b/language/setup_invoice/english_setup_invoice.xml @@ -0,0 +1,59 @@ + + + setup_invoice + + Invoice Setup + Invoice Setup + + Invoice Setup + Invoice Setup + + + ID + Site ID + Bill to company name + Currency Symbol + Currency Decimal Precision + Number of items to display in summary + News you can use + Page Type + + Default Invoice Delivery Method + Show itemized detail pages + Default Net Terms for All System Generated Invoices + PDF Invoice Plugin + Contact Us URL + Contact Us Phone Number + Show service date ranges on invoice overview + Send advance billing notice how many days before invoice generation? (0 = disabled) + + Monthly Services for + The above is just a summary. To view a detailed list of charges, please visit our website. + Current Charges Summary for + Combined Minutes Used + Payment Coupon + Please return this portion with your check or money + order made payable to + Account Number + Username + Contact Us: + Online: + Phone: + Invoice Number + Invoice # + Billing Date + Bill Date + Current Charges + AMOUNT DUE BY + MAKE CHECK PAYABLE TO + Itemized Charges + Itemized Calls + Page # + Description + Quantity + Min./Quan. + Unit Cost + Amount + To + From + diff --git a/language/staff/english_staff.xml b/language/staff/english_staff.xml new file mode 100644 index 00000000..2c9ac376 --- /dev/null +++ b/language/staff/english_staff.xml @@ -0,0 +1,41 @@ + + + staff + + Add Staff + View Staff + Search Staff + Contact our Staff + + Staff + Add + List + Search + + Creation Date + Account + Can Access Ticket Departments + Staff Nickname + Notify of New Tickets + Notify of Changes to Tickets + Signature for Ticket Replies + + View all tickets for this staff member + To contact our staff, you may select their staff nickname below. If you do not + know any staff in the department you wish to correspond with, simply select the recipient + department instead, and your message will be forwarded to the appropriate staff member when + you send your message. You do not need to select both a recipient department and recipient + staff member; please just select one or the other. + Recipient Staff Nickname + Recipient Department + Your Name + Your E-mail + You must fill in all the required fields in order send your message, please + try again. + Sorry, the specified recipient staff member does not exist any longer. + Sorry, the specified recipient department does not exist any longer. + You must specify either the recipient staff member or department, please try + again. + Thank you, we have sent your message to the specified recipient. If a response is in + order, we will do so as soon as possible. + diff --git a/language/staff_department/english_staff_department.xml b/language/staff_department/english_staff_department.xml new file mode 100644 index 00000000..007d7e19 --- /dev/null +++ b/language/staff_department/english_staff_department.xml @@ -0,0 +1,17 @@ + + + staff_department + + Add Department + View Departments + + Staff Departments + Add + List + + Department Name + Department Description + Head Staff Member + Display on Contact Page? + + diff --git a/language/static_page/english_static_page.xml b/language/static_page/english_static_page.xml new file mode 100644 index 00000000..dcd2cf7e --- /dev/null +++ b/language/static_page/english_static_page.xml @@ -0,0 +1,32 @@ + + + static_page + + Add Page + View Pages + Search Pages + + Static Pages + Add + List + Search + + Show in Category + Creation Date + Date of Last Update + Expiration Date + Active? + Page Name + Page Description + Start Date + Display Sort Order + + View all translations for this page + Add a translations for this page + Read more ... + Sorry, no pages were found in this category, or your account is not authorized for + this category. + Sorry, the requested page was not found, or you do not have the required level + of authorization to view it. + Preview page + diff --git a/language/static_page_category/english_static_page_category.xml b/language/static_page_category/english_static_page_category.xml new file mode 100644 index 00000000..c6659bef --- /dev/null +++ b/language/static_page_category/english_static_page_category.xml @@ -0,0 +1,19 @@ + + + static_page_category + + Add Static Page Category + View Static Page Categories + + Categories + Add + List + + Sort Order + Date of Creation + Groups that can access this category + Name of Category + Category Description + Active? + + diff --git a/language/static_page_translate/english_static_page_translate.xml b/language/static_page_translate/english_static_page_translate.xml new file mode 100644 index 00000000..3ce9e0e2 --- /dev/null +++ b/language/static_page_translate/english_static_page_translate.xml @@ -0,0 +1,26 @@ + + + static_page_translate + + Add Translation + View Translations + Search Translations + + Translation Administration + Add Translation + View Translations + Search Translations + + + + Date of Creation + + Static Page + Translation Language + Intro Text + Full Text + Page Title + + View all translations for this page + Return to main page view + diff --git a/language/static_relation/english_static_relation.xml b/language/static_relation/english_static_relation.xml new file mode 100644 index 00000000..993fb6b4 --- /dev/null +++ b/language/static_relation/english_static_relation.xml @@ -0,0 +1,22 @@ + + + var_relation + + Add Var Relationship + Update Var Relationship + View Var Relationships + Search Var Relationships + + Relationships + Add + List + Search + + Static Var + Module + Default Value + Description + Required? + Sort Order + + diff --git a/language/static_var/english_static_var.xml b/language/static_var/english_static_var.xml new file mode 100644 index 00000000..3ffcec77 --- /dev/null +++ b/language/static_var/english_static_var.xml @@ -0,0 +1,49 @@ + + + static_var + + Add Custom Fields + Update Custom Field + View Custom Fields + + Custom Fields + Add + List + + Custom Field Name + Description + Input Format + Validation Type + Conversion Type + + The Custom Field module defines specific field types that can be collected on your + own custom forms at registration and in tickers. + + Small text field + Medium text field + Large text area + Dropdown list + Calendar Popup + File upload + Status Select + Checkbox + Hidden Field + None + Date + MD5 Encrypt + RC5 Encrypt + Crypt Encrypt + GPG Encrypt + PGP Encrypt + Serialize Array + Any + Email + Date +
Street Address
+ Zip Code + Phone or Fax No. + Credit Card No. + Any Number(s) + Any Alpha-numberic data + Any Non-numberic data +
diff --git a/language/task/english_task.xml b/language/task/english_task.xml new file mode 100644 index 00000000..28d250fa --- /dev/null +++ b/language/task/english_task.xml @@ -0,0 +1,31 @@ + + + task + + Add Task + View Tasks + Search Tasks + + Tasks + Add + List + + Start Date + Expiration Date + Last Run Date + Name + Description + Log Results? + Task Type + Command + Minutes (0-59) + Hour (0-23) + Month Day (1-31) + Month (1-12) + Week Day (0-6) + + Internal Method + System Call + Run Task Now + View Task Logs + diff --git a/language/task_log/english_task_log.xml b/language/task_log/english_task_log.xml new file mode 100644 index 00000000..b28ccaf0 --- /dev/null +++ b/language/task_log/english_task_log.xml @@ -0,0 +1,19 @@ + + + task_log + + View Task Logs + Search Task Logs + + Task Logs + View Task Logs + Search Task Logs + + + + Task + Date + Success? + Task Message + + diff --git a/language/tax/english_tax.xml b/language/tax/english_tax.xml new file mode 100644 index 00000000..767fe42f --- /dev/null +++ b/language/tax/english_tax.xml @@ -0,0 +1,21 @@ + + + tax + + Add Tax Zone + View Tax Zones + + Tax Zones + Add + List + + Country + Tax Zone + Tax Description + Tax Rate + Collect Tax ID? + Tax ID Descriptor + Allow Exempt Status? + Require Tax ID Input? + REGEX for Tax Id Number Validation + diff --git a/language/temporary_data/english_temporary_data.xml b/language/temporary_data/english_temporary_data.xml new file mode 100644 index 00000000..5b6cd939 --- /dev/null +++ b/language/temporary_data/english_temporary_data.xml @@ -0,0 +1,4 @@ + + + temporary_data + diff --git a/language/ticket/english_ticket.xml b/language/ticket/english_ticket.xml new file mode 100644 index 00000000..27f18eda --- /dev/null +++ b/language/ticket/english_ticket.xml @@ -0,0 +1,100 @@ + + + ticket + + Add Ticket + View Ticket + Search Tickets + + Tickets + Add + List + Search + Statistics + + + Creation Date + Last Change + Expiration Date + User Account + Department + Staff + Status + Priority + Subject + Message + E-mail Address + Response Status + + A department to send this ticket to must be entered, please go back and correct this. + A subject for this ticket is required, please go back and enter a subject. + A message for this ticket is required, please go back and enter a message. + The specified department is invalid or inactive. + You do not have access to the selected department + Close Ticket + OPEN + ON HOLD + CLOSED + PENDING + Standard + Medium + High + Emergency + Staff Wrote: + You Wrote: + User Wrote: + If you wish to submit a new ticket, please select from the department + below. Once you select the correct department, you will be able to enter your message for + our staff to review. + Below are the existing tickets for your account, you can click the subject to + view the ticket details and add a response if needed. + Your account has no associated tickets at this time. + Your account does not have access to add any new tickets at this time. + Your account does not have access to reopen this ticket + You do not have access to reopen this ticket, please try logging + into your account if you have one and retry + If you wish to respond or add information to this ticket, please use the form + below + If you wish to reopen this this ticket, please use the form below + You must provide authentication details below to retrieve this ticket! + You must select the department to send your ticket to, please go back + and select a department. + Your response has been received and our staff has been notified + Your ticket has been received and our staff has been notified + You do not have a staff account, please contact the administrator to have + your account setup as a ticket staff member. + A response is required if you wish to reply. + Your response has been recorded and the user has been notified. + In order to view your existing tickets, you must either login to your account + if one exists, or provide your E-mail addess and the the Key provided in our ticket + notification E-mail. + + Key + Verify Details + Ticket Merge + Are you sure you wish to merge these tickets? Select Yes to merge the current ticket with the one selected. + New + Awaiting Reply + Awaiting Customer + On Hold + Resolved + Pending + Awaiting Customer + Awaiting Reply + Notify user of update... + diff --git a/language/ticket_department/english_ticket_department.xml b/language/ticket_department/english_ticket_department.xml new file mode 100644 index 00000000..1912097a --- /dev/null +++ b/language/ticket_department/english_ticket_department.xml @@ -0,0 +1,21 @@ + + + ticket_department + + Add Department + View Departments + + Departments + Add + List + + Available to Group(s) + Default Email Setup + Department Name + Department Description + Is Active? + Enable Piping? + Email setup to use for piping + + View all tickets for this department + diff --git a/language/ticket_message/english_ticket_message.xml b/language/ticket_message/english_ticket_message.xml new file mode 100644 index 00000000..8267ffeb --- /dev/null +++ b/language/ticket_message/english_ticket_message.xml @@ -0,0 +1,19 @@ + + + ticket_message + + Add A Reply + View Messages + Search Messages + + Message Administration + Add A Reply + View Messages + Search Messages + + Ticket Id + Date Submitted + Message + + New Tickets Created: %%count%% + diff --git a/language/voip/english_voip.xml b/language/voip/english_voip.xml new file mode 100644 index 00000000..13540f68 --- /dev/null +++ b/language/voip/english_voip.xml @@ -0,0 +1,76 @@ + + + VoIP + VoIP Configuration + + Date + Invoiced? + Sweep Type + Account + Product SKU + Service + Amount + Quantity + Taxable + Attributes + From + To + Amount + Duration + Default NPA prepended to US 7 digit dialing + Amount at which prepaid low balance email notifications are sent + Provisioning Auth Domain (eg: SER SIP domain) + + My Voice Center + Features + Overview + Activity + Faxes + Voicemail + Blacklist + Add a Blacklist + List all Blacklists + Call Forwarding + Busy Call Forwarding + Faxing + Failover Number + Remote Call Forwarding + Call Waiting + + Placed Calls + Received Calls + No calls for this period + Last 25 Placed Calls + Last 25 Received Calls + Incoming call color guide + Call answered + Call routed to voicemail + Call routed to fax + Prepaid Call + + Phone Number + Forward calls to voicemail after + seconds + Send email notification to + Will ring for + seconds before being forwarded to + If this line is busy, then will forward the call to + Send new faxes for this line to e-mail address + In the event of Internet outage, redirect calls for this line to + Forward calls for this line to + View Blacklisted Numbers + Add Blacklisted Number + Enable Call waiting. Note: In order for Busy Call Forwarding to work, you must disable Call Waiting. + + VoIP Configuration + Randomly Generated + Reverse of the DID assigned + Same as the DID assigned + Default Voicemail PIN/Passcode + Method used for SIP/IAX secret provisioning + Your Intrastate NPAs for calculations + (comma separated) + (for post-paid rating only) + Perform CDR normalization + Minimum length for a number to be normalized + \ No newline at end of file diff --git a/language/voip_blacklist/english_voip_blacklist.xml b/language/voip_blacklist/english_voip_blacklist.xml new file mode 100644 index 00000000..136a0703 --- /dev/null +++ b/language/voip_blacklist/english_voip_blacklist.xml @@ -0,0 +1,16 @@ + + + Add Blacklist + View Blacklist + Search Blacklists + + Blacklists + Add + List + Search + + DID + Account + Phone Number + Destination + \ No newline at end of file diff --git a/language/voip_cdr/english_voip_cdr.xml b/language/voip_cdr/english_voip_cdr.xml new file mode 100644 index 00000000..447e427e --- /dev/null +++ b/language/voip_cdr/english_voip_cdr.xml @@ -0,0 +1,33 @@ + + + View CDR + Search CDRs + + CDRs + List + Search + + Date Created + Account + Rate ID + CLID + Source + Destination + Dest Context + Channel + Dest Channel + Last App + Last Data + Duration + Bill Seconds + Disposition + AMA Flags + Account Code + Unique ID + CDRID + Amount + Call Type + ID + Rating Status + Adjusted Bill Interval + \ No newline at end of file diff --git a/language/voip_did/english_voip_did.xml b/language/voip_did/english_voip_did.xml new file mode 100644 index 00000000..061b3158 --- /dev/null +++ b/language/voip_did/english_voip_did.xml @@ -0,0 +1,50 @@ + + + Add DID + View DIDs + Search DIDs + + DID + Add + List + Search + + Account + Service ID + Parent Service ID + DID + Calling Rate ID + Called Rate ID + Plan ID + Calling Name Display + Blacklisting + ANI-based routing + FAX detection + Channel + Channel Arguments + Voice Mail Enabled? + Call Forwarding Enabled? + Busy Call Forwarding Enabled? + Voice Mail After? + Call Forwarding Ring For? + Call Forwarding Number + Busy Call Forwarding Number + Fax Enabled? + Fax To Email + Active? + Conferencing Enabled? + Conference Limit + Failover? + Failover Number + Remote Call Forwarding? + Remote Call Forwarding Number + Caller ID + VoIP Registration Username + VoIP Registration Password + NAT Qualification/Monitoring + Voicemail Box + Incoming Call Limit + DTMF Mode + Can Re-Invite + NAT + \ No newline at end of file diff --git a/language/voip_did_plugin/english_voip_did_plugin.xml b/language/voip_did_plugin/english_voip_did_plugin.xml new file mode 100644 index 00000000..7128e67a --- /dev/null +++ b/language/voip_did_plugin/english_voip_did_plugin.xml @@ -0,0 +1,28 @@ + + + voip_did_plugin + + + New DID Plugin Setup + + + View DID Plugin Setups + + + + DID Plugin Setup + Add + + + List + + + + + + Plugin Setup Name + Use Plugin + Available for Countries + Release reserved DIDs after (minutes) + + \ No newline at end of file diff --git a/language/voip_fax/english_voip_fax.xml b/language/voip_fax/english_voip_fax.xml new file mode 100644 index 00000000..5f964023 --- /dev/null +++ b/language/voip_fax/english_voip_fax.xml @@ -0,0 +1,25 @@ + + + View Fax + Search Faxes + + Faxes + List + Search + + Account + Date + CLID + Source + Destination + Pages + Image Size + Image Resolution + Transfer Rate + Image Bytes + Bad Rows + Mime Type + + View + + \ No newline at end of file diff --git a/language/voip_pool/english_voip_pool.xml b/language/voip_pool/english_voip_pool.xml new file mode 100644 index 00000000..935aaf4b --- /dev/null +++ b/language/voip_pool/english_voip_pool.xml @@ -0,0 +1,25 @@ + + + voip_pool + + Add DID Pool + View DID Pool + List DID Pools + Search DID Pool + Import DIDs + + DID POOL + Add + List + Search + Import + + Account + NPA + NXX + Station + File to import + DID Pool to associate imported DIDs with + + Select a file to import below. The file must contain a single phone number per line, in E.164 format. Duplicates will not be imported. + \ No newline at end of file diff --git a/language/voip_prepaid/english_voip_prepaid.xml b/language/voip_prepaid/english_voip_prepaid.xml new file mode 100644 index 00000000..bb67fa61 --- /dev/null +++ b/language/voip_prepaid/english_voip_prepaid.xml @@ -0,0 +1,25 @@ + + + Add Prepaid Pin + Generate Bulk Prepaid Pins + View Prepaid Pin + Search Prepaid Pins + + Prepaid Pins + Add + Add Batch + List + Search + + Account + Product + Pin Number + Balance + In Use? + Pin expires on + Batch Reference Code + + Batch Quantity + Batch Reference Code + + \ No newline at end of file diff --git a/language/voip_rate/english_voip_rate.xml b/language/voip_rate/english_voip_rate.xml new file mode 100644 index 00000000..4d540742 --- /dev/null +++ b/language/voip_rate/english_voip_rate.xml @@ -0,0 +1,42 @@ + + + voip_rate + + Add Rate + View Rates + Search Rates + + Rates + Add + List + Product Associations + Import + + Date Added + Name + Digit Match Pattern (regex - separate with a semicolon for multiples) + Price for Connecting + Billing Increment Seconds + Seconds Included/Free + Price per minute + Rating Type + Call Direction + Minimum Minutes + Maximum Minutes + Combine Minutes? + Price is per Call + + Yes + No + + In Network + Local Calling + Regular + Default/Match All + + In-bound + Out-bound + Both In/Out-bound + + Run Rating Now + diff --git a/language/voip_rate_prod/english_voip_rate_prod.xml b/language/voip_rate_prod/english_voip_rate_prod.xml new file mode 100644 index 00000000..8f8c9c9e --- /dev/null +++ b/language/voip_rate_prod/english_voip_rate_prod.xml @@ -0,0 +1,11 @@ + + + voip_rate_prod + + Add Product Rate Association + View Product Rate Association + + Product SKU + Rate Name + + diff --git a/language/voip_vm/english_voip_vm.xml b/language/voip_vm/english_voip_vm.xml new file mode 100644 index 00000000..1d345e53 --- /dev/null +++ b/language/voip_vm/english_voip_vm.xml @@ -0,0 +1,28 @@ + + + Add Voicemail + View Voicemail + Search Voicemail + + Voicemail + Add + List + Search + + Account + Context + Mailbox + Password + Full Name + E-mail + Pager + Options + + Listen + Delete + Date + From + File Size + Length + + \ No newline at end of file diff --git a/modules/account/account.inc.php b/modules/account/account.inc.php new file mode 100644 index 00000000..872defe1 --- /dev/null +++ b/modules/account/account.inc.php @@ -0,0 +1,1335 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class account +{ + var $parent_id; + + # Open the constructor for this mod + function account_construct() + { + # name of this module: + $this->module = "account"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + /** add sub account */ + function sub_account_add($VAR) { + if(!SESS_LOGGED) return false; + $this->parent_id=SESS_ACCOUNT; + if($this->add($VAR, $this)) { + // add any additional groups + if(!empty($VAR['groups']) && is_array($VAR['groups'])) { + global $C_auth; + $db=&DB(); + foreach($VAR['groups'] as $key => $gid) { + if($C_auth->auth_group_by_id($gid)) { + $fields=Array('account_id'=>$this->account_id, 'active'=>1, 'group_id'=>$gid, 'date_orig'=>time()); + $db->Execute($sql=sqlInsert($db,"account_group",$fields)); + } + } + } + define('FORCE_PAGE', 'account:account'); + global $C_debug; + $C_debug->alert("The sub-account has been added"); + } + } + + /** delete sub account */ + function sub_delete($VAR) { + // return false; + // verify perms + if(empty($VAR['id']) || !$this->isParentAccount($VAR['id'])) { + return false; + } + + // ok, do deletion + include_once(PATH_MODULES.'account_admin/account_admin.inc.php'); + $aa = new account_admin; + $VAR['account_admin_id'] = $VAR['id']; + $aa->delete($VAR); + } + + /* check if sub account auth */ + function isParentAccount($sub_account_id) { + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"account","parent_id","id=". $db->qstr($sub_account_id)." + AND parent_id != 0 AND parent_id IS NOT NULL AND parent_id != '' + AND parent_id = ". $db->qstr(SESS_ACCOUNT))); + if($rs && $rs->RecordCount()) { + return true; + } + return false; + } + + /** Get authorized groups */ + function get_auth_groups($VAR) { + $groups = false; + global $smarty, $C_auth; + $db=&DB(); + + /* get groups for this account */ + $authgrp=array(); + if(!empty($VAR['id'])) { + $grs = $db->Execute(sqlSelect($db,"account_group","group_id","group_id>2 and active=1 and account_id=". $db->qstr($VAR['id']))); + if($grs && $grs->RecordCount()) { + while(!$grs->EOF) { + $authgrp["{$grs->fields['group_id']}"] = true; + $grs->MoveNext(); + } + } + } + + $ids = implode(",", $C_auth->group); + $rs = $db->Execute($sql=sqlSelect($db,"group","id,name","id in ($ids) and id > 2")); + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + $gid = $rs->fields['id']; + if ( (!empty($VAR['groups']) && is_array($VAR['groups']) && !empty($VAR['groups'][$gid])) + || (!empty($authgrp["$gid"])) ) + $rs->fields['checked']=true; + $groups[] = $rs->fields; + $rs->MoveNext(); + } + } + $smarty->assign("groups", $groups); + } + + + /** + * Check account limitations + */ + function checkLimits() { + if(!defined('AGILE_RST_ACCOUNT') || AGILE_RST_ACCOUNT <= 0) return true; + $sql="SELECT count(*) as totalacct from ".AGILE_DB_PREFIX."account WHERE site_id=".DEFAULT_SITE; + $db=&DB(); + $rs=$db->Execute($sql); + if($rs && $rs->RecordCount() && $rs->fields['totalacct'] <= AGILE_RST_ACCOUNT) { + return true; + } else { + global $C_debug; + $C_debug->alert("Licensed user limit of ".AGILE_RST_ACCOUNT." exceeded, operation failed."); + return false; + } + return true; + } + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + if(!$this->checkLimits()) return false; // check account limits + + $this->account_construct(); + global $C_list, $C_translate, $C_debug, $VAR, $smarty; + $this->validated = true; + + ### Set the hidden values: + $VAR['account_date_orig'] = time(); + $VAR['account_date_last'] = time(); + + if(defined("SESS_LANGUAGE")) + @$VAR['account_language_id'] = SESS_LANGUAGE; + else + @$VAR['account_language_id'] = DEFAULT_LANGUAGE; + + if(defined("SESS_AFFILIATE")) + @$VAR['account_affiliate_id']= SESS_AFFILIATE; + else + @$VAR['account_affiliate_id']= DEFAULT_AFFILIATE; + + if(defined("SESS_RESELLER")) + @$VAR['account_reseller_id'] = SESS_RESELLER; + else + @$VAR['account_reseller_id'] = DEFAULT_RESELLER; + + if(defined("SESS_CURRENCY")) + @$VAR['account_currency_id'] = SESS_CURRENCY; + else + @$VAR['account_currency_id'] = DEFAULT_CURRENCY; + + if(defined("SESS_THEME")) + @$VAR['account_theme_id'] = SESS_THEME; + else + @$VAR['account_theme_id'] = DEFAULT_THEME; + + if(defined("SESS_CAMPAIGN")) + @$VAR['account_campaign_id'] = SESS_CAMPAIGN; + else + @$VAR['account_campaign_id'] = 0; + + if(!isset($VAR['account_email_type']) && @$VAR['account_email_type'] != "1") + @$VAR['account_email_type'] = '0'; + + ### Determine the proper account status: + if(DEFAULT_ACCOUNT_STATUS != '1') + $status = '1'; + else + $status = '0'; + + ## Single field login: + if(defined('SINGLE_FIELD_LOGIN') && SINGLE_FIELD_LOGIN==true && empty($VAR['account_password'])) { + $VAR['account_password']='none'; + $VAR['confirm_password']='none'; + } + + #################################################################### + ### loop through the field list to validate the required fields + #################################################################### + + $type = 'add'; + $this->method["$type"] = split(",", $this->method["$type"]); + $arr = $this->method["$type"]; + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + $this->validated = true; + + while (list ($key, $value) = each ($arr)) + { + # get the field value + $field_var = $this->module . '_' . $value; + $field_name = $value; + + #################################################################### + ### perform any field validation... + #################################################################### + + # check if this value is unique + if(isset($this->field["$value"]["unique"]) && isset($VAR["$field_var"])) + { + if(!$validate->validate_unique($this->table, $field_name, "record_id", $VAR["$field_var"])) + { + $this->validated = false; + $this->val_error[] = array('field' => $this->table . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), # translate + 'error' => $C_translate->translate('validate_unique',"", "")); + } + } + + # check if the submitted value meets the specifed requirements + if(isset($this->field["$value"]["validate"])) + { + if(isset($VAR["$field_var"])) + { + if($VAR["$field_var"] != '') + { + if(!$validate->validate($field_name, $this->field["$value"], $VAR["$field_var"], $this->field["$value"]["validate"])) + { + $this->validated = false; + $this->val_error[] = array('field' => $this->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), + 'error' => $validate->error["$field_name"] ); + } + } + else + { + $this->validated = false; + $this->val_error[] = array('field' => $this->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), + 'error' => $C_translate->translate('validate_any',"", "")); + } + } + else + { + $this->validated = false; + $this->val_error[] = array('field' => $this->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), + 'error' => $C_translate->translate('validate_any',"", "")); + } + } + } + + + + #################################################################### + ### Validate the password + #################################################################### + + if(isset($VAR['account_password']) && $VAR['account_password'] != "") + { + if(isset($VAR['confirm_password']) && $VAR['account_password'] == $VAR['confirm_password']) + { + $password = $VAR['account_password']; + $smarty->assign('confirm_account_password', $VAR["account_password"]); + } + else + { + ### ERROR: The passwords provided do not match! + $smarty->assign('confirm_account_password', ''); + $this->validated = false; + $this->val_error[] = array('field' => 'account_confirm_password', + 'field_trans' => $C_translate->translate('field_confirm_password', $this->module, ""), # translate + 'error' => $C_translate->translate('password_change_match',"account", "")); + + } + } + else + { + $smarty->assign('confirm_account_password', ''); + } + + + #################################################################### + ### Validate that the user's IP & E-mail are not banned! + #################################################################### + + if($this->validated) + { + require_once(PATH_MODULES . 'blocked_email/blocked_email.inc.php'); + $blocked_email = new blocked_email; + if(!$blocked_email->is_blocked($VAR['account_email'])) + $this->val_error[] = array( + 'field' => 'account_email', + 'field_trans' => $C_translate->translate('field_email', $this->module, ""), + 'error' => $C_translate->translate('validate_banned_email',"", "")); + + + require_once(PATH_MODULES . 'blocked_ip/blocked_ip.inc.php'); + $blocked_ip = new blocked_ip; + if(!$blocked_ip->is_blocked(USER_IP)) + $this->val_error[] = array( + 'field' => 'IP Address', + 'field_trans' => $C_translate->translate('ip_address', $this->module, ""), + 'error' => $C_translate->translate('validate_banned_ip',"", "")); + } + + // validate the tax_id + require_once(PATH_MODULES.'tax/tax.inc.php'); + $taxObj=new tax; + $tax_arr = @$VAR['account_tax_id']; + if(is_array($tax_arr)) { + foreach($tax_arr as $country_id => $tax_id) { + if ($country_id == $VAR['account_country_id']) { + $exempt = @$VAR["account_tax_id_exempt"][$country_id]; + if(!$taxObj->TaxIdsValidate($country_id, $tax_id, $exempt)) { + $this->validated = false; + $this->val_error[] = array( + 'field' => 'account_tax_id', + 'field_trans' => $taxObj->errField, + 'error' => $C_translate->translate('validate_general', "", "")); + } + if($exempt) + $VAR['account_tax_id']=false; + else + $VAR['account_tax_id']=$tax_id; + } + } + } + + #################################################################### + ### Get required static_Vars and validate them... return an array + ### w/ ALL errors... + #################################################################### + + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + + if(!isset($this->val_error)) $this->val_error = false; + $all_error = $static_var->validate_form($this->module, $this->val_error); + + if($all_error != false && gettype($all_error) == 'array') + $this->validated = false; + else + $this->validated = true; + + + + #################################################################### + ### If validation was failed, skip the db insert & + ### set the errors & origonal fields as Smarty objects, + ### and change the page to be loaded. + #################################################################### + + if(!$this->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $all_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page_current']); + } + + # Stripslashes + global $C_vars; + $C_vars->strip_slashes_all(); + + return; + } + + # Get default invoice options + $db=&DB(); + $invopt=$db->Execute(sqlSelect($db,"setup_invoice","*","")); + if($invopt && $invopt->RecordCount()) { + $invoice_delivery=$invopt->fields['invoice_delivery']; + $invoice_format=$invopt->fields['invoice_show_itemized']; + } + + /* hash the password */ + if(defined('PASSWORD_ENCODING_SHA')) + $password_encoded = sha1($password); + else + $password_encoded = md5($password); + + #################################################################### + ### Insert the account record + #################################################################### + $this->account_id = $db->GenID(AGILE_DB_PREFIX . 'account_id'); + $validation_str = time(); + + /** get parent id */ + $this->account_id; + if(empty($this->parent_id)) $this->parent_id = $this->account_id; + + $sql = ' + INSERT INTO ' . AGILE_DB_PREFIX . 'account SET + id = ' . $db->qstr ( $this->account_id ) . ', + site_id = ' . $db->qstr ( DEFAULT_SITE ) . ', + date_orig = ' . $db->qstr ( $validation_str ) . ', + date_last = ' . $db->qstr ( time()) . ', + language_id = ' . $db->qstr ( $VAR["account_language_id"] ) . ', + country_id = ' . $db->qstr ( $VAR["account_country_id"] ) . ', + parent_id = ' . $db->qstr ( $this->parent_id ) . ', + affiliate_id = ' . $db->qstr ( @$VAR["account_affiliate_id"] ) . ', + campaign_id = ' . $db->qstr ( @$VAR["account_campaign_id"] ) . ', + reseller_id = ' . $db->qstr ( @$VAR["account_reseller_id"] ) . ', + currency_id = ' . $db->qstr ( $VAR["account_currency_id"] ) . ', + theme_id = ' . $db->qstr ( $VAR["account_theme_id"] ) . ', + username = ' . $db->qstr ( $VAR["account_username"] , get_magic_quotes_gpc()) . ', + password = ' . $db->qstr ( $password_encoded ) . ', + status = ' . $db->qstr ( $status ) . ', + first_name = ' . $db->qstr ( $VAR["account_first_name"] , get_magic_quotes_gpc()) . ', + middle_name = ' . $db->qstr ( $VAR["account_middle_name"], get_magic_quotes_gpc()) . ', + last_name = ' . $db->qstr ( $VAR["account_last_name"] , get_magic_quotes_gpc()) . ', + company = ' . $db->qstr ( $VAR["account_company"] , get_magic_quotes_gpc()) . ', + title = ' . $db->qstr ( $VAR["account_title"] , get_magic_quotes_gpc()) . ', + email = ' . $db->qstr ( $VAR["account_email"] , get_magic_quotes_gpc()) . ', + address1 = ' . $db->qstr ( $VAR["account_address1"] , get_magic_quotes_gpc()) . ', + address2 = ' . $db->qstr ( $VAR["account_address2"] , get_magic_quotes_gpc()) . ', + city = ' . $db->qstr ( $VAR["account_city"] , get_magic_quotes_gpc()) . ', + state = ' . $db->qstr ( $VAR["account_state"] , get_magic_quotes_gpc()) . ', + zip = ' . $db->qstr ( $VAR["account_zip"] , get_magic_quotes_gpc()) . ', + email_type = ' . $db->qstr ( $VAR["account_email_type"] , get_magic_quotes_gpc()). ', + invoice_delivery= ' . $db->qstr ( @$invoice_delivery ) . ', + invoice_show_itemized=' . $db->qstr ( @$invoice_format) . ', + invoice_advance_gen = ' . $db->qstr ( MAX_INV_GEN_PERIOD ) . ', + invoice_grace = ' . $db->qstr ( GRACE_PERIOD ) . ', + tax_id = ' . $db->qstr ( @$VAR['account_tax_id'] ); + $result = $db->Execute($sql); + + #################################################################### + ### error reporting: + #################################################################### + + if ($result === false) + { + global $C_debug; + $C_debug->error('account.inc.php','add', $db->ErrorMsg()); + + if(isset($this->trigger["$type"])) { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + return; + } + + /* password logging class */ + if($C_list->is_installed('account_password_history')) { + include_once(PATH_MODULES.'account_password_history/account_password_history.inc.php'); + $accountHistory = new account_password_history(); + $accountHistory->setNewPassword($this->account_id, $password_encoded); + } + + #################################################################### + ### Add the account to the default group: + #################################################################### + + $group_id = $db->GenID(AGILE_DB_PREFIX . 'account_group_id'); + $sql = ' + INSERT INTO ' . AGILE_DB_PREFIX . 'account_group SET + id = ' . $db->qstr ( $group_id ) . ', + site_id = ' . $db->qstr ( DEFAULT_SITE ) . ', + date_orig = ' . $db->qstr ( time() ) . ', + group_id = ' . $db->qstr ( DEFAULT_GROUP ) . ', + account_id = ' . $db->qstr ( $this->account_id ) . ', + active = ' . $db->qstr ('1'); + $db->Execute($sql); + + + #################################################################### + ### Insert the static vars: + #################################################################### + + $static_var->add($VAR, $this->module, $this->account_id); + + + #################################################################### + ### Mail the user the new_account email template + #################################################################### + + require_once(PATH_MODULES . 'email_template/email_template.inc.php'); + $my = new email_template; + if($status == "1") + { + $my->send('account_registration_active', $this->account_id, $this->account_id, '', ''); + } else { + $validation_str = strtoupper($validation_str. ':' .$this->account_id); + $my->send('account_registration_inactive', $this->account_id, '', '', $validation_str); + } + + + #################################################################### + ### Add the newsletters + #################################################################### + + if(NEWSLETTER_REGISTRATION == "1") + { + @$VAR['newsletter_html'] = $VAR['account_email_type']; + $VAR['newsletter_email'] = $VAR['account_email']; + $VAR['newsletter_first_name'] = $VAR['account_first_name']; + $VAR['newsletter_last_name'] = $VAR['account_last_name']; + require_once(PATH_MODULES . '/newsletter/newsletter.inc.php'); + $newsletter = new newsletter; + $newsletter->subscribe($VAR, $this); + } + + + #################################################################### + ### Log in the user & display the welcome message + #################################################################### + + if($status == "1") + { + if($this->parent_id == $this->account_id || empty($this->parent_id)) + { + $C_debug->alert($C_translate->translate("user_add_active_welcome","account","")); + if(SESSION_EXPIRE == 0) $exp = 99999; + else $exp = SESSION_EXPIRE; + $date_expire = (time() + (SESSION_EXPIRE * 60)); + + # update the session + $db = &DB(); + $q = "UPDATE " . AGILE_DB_PREFIX . "session + SET + ip= " . $db->qstr(USER_IP) .", + date_expire = " . $db->qstr($date_expire) . ", + logged = " . $db->qstr('1').", + account_id = " . $db->qstr($this->account_id) . " + WHERE + id = " . $db->qstr(SESS) . " + AND + site_id = " . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + + ### constants + define('FORCE_SESS_ACCOUNT', $this->account_id); + define('FORCE_SESS_LOGGED', 1); + + ### Reload the session auth cache + if(CACHE_SESSIONS == '1') { + $force = true; + $C_auth = new CORE_auth($force); + global $C_auth2; + $C_auth2 = $C_auth; + } + + if(isset($VAR['_page_next'])) + define('REDIRECT_PAGE', '?_page='.$VAR['_page_next']); + elseif(isset($VAR['_page'])) + define('REDIRECT_PAGE', '?_page='.$VAR['_page']); + } + + #################################################################### + ### Do any db_mapping + #################################################################### + if($C_list->is_installed('db_mapping')) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + if(!empty($password)) + $db_map->plaintext_password = $password; + else + $db_map->plaintext_password = false; + $db_map->account_add ( $this->account_id ); + + $db_map = new db_mapping; + $db_map->login ( $this->account_id ); + } + + #################################################################### + ### Affiliate Auto Creation + #################################################################### + if(AUTO_AFFILIATE == 1 && $C_list->is_installed("affiliate")) + { + $VAR['affiliate_account_id'] = $this->account_id; + $VAR['affiliate_template_id'] = DEFAULT_AFFILIATE_TEMPLATE; + + include_once(PATH_MODULES . 'affiliate/affiliate.inc.php'); + $affiliate = new affiliate; + $affiliate->add($VAR, $affiliate); + } + } else { + $C_debug->alert($C_translate->translate("user_add_inactive_welcome","account","")); + define('FORCE_PAGE', 'core:blank'); + } + } + + + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + + ### Check that user is logged in: + if(SESS_LOGGED != '1') { + echo "Sorry, you must be logged in!"; + return false; + } + + $this->account_construct(); + + /* check for sub account */ + if(!empty($VAR['id']) && $VAR['id'] != SESS_ACCOUNT) { + if($this->isParentAccount($VAR['id'])) { + $VAR['account_id'] = $VAR['id']; + global $smarty; + $smarty->assign('issubaccount', true); + } else { + return false; + } + } else { + $VAR['id'] = SESS_ACCOUNT; + $VAR['account_id'] = SESS_ACCOUNT; + } + + ### Retrieve the record: + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + + + ### Get the static vars: + global $smarty; + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + $arr = $static_var->update_form('account', 'update', SESS_ACCOUNT); + if(gettype($arr) == 'array') { + $smarty->assign('static_var', $arr); + } else { + $smarty->assign('static_var', false); + } + + /* get child accounts */ + if(empty($smarty->_tpl_vars['account'][0]['parent_id']) || $smarty->_tpl_vars['account'][0]['parent_id']==$smarty->_tpl_vars['account'][0]['id']) { + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"account","id,first_name,last_name,email,username","parent_id=". $db->qstr(SESS_ACCOUNT))); + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + $smart[] = $rs->fields; + $rs->MoveNext(); + } + $smarty->assign('subaccount', $smart); + } + } + } + + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + global $VAR; + + ### Check that user is logged in: + if(SESS_LOGGED != '1') + echo "Sorry, you must be logged in!"; + + + /* check for sub account */ + $issubaccount=false; + if(!empty($VAR['account_id']) && $VAR['account_id'] != SESS_ACCOUNT) { + if($this->isParentAccount($VAR['account_id'])) { + $VAR['id'] = $VAR['account_id']; + global $smarty; + $issubaccount=true; + } else { + return false; + } + } else { + $VAR['id'] = SESS_ACCOUNT; + $VAR['account_id'] = SESS_ACCOUNT; + } + + $VAR['account_date_last']=time(); + + + // validate the tax_id + require_once(PATH_MODULES.'tax/tax.inc.php'); + $taxObj=new tax; + $tax_arr = @$VAR['account_tax_id']; + if(is_array($tax_arr)) { + foreach($tax_arr as $country_id => $tax_id) { + if ($country_id == $VAR['cid']) { + $exempt = @$VAR["account_tax_id_exempt"][$country_id]; + if(!$txRs=$taxObj->TaxIdsValidate($country_id, $tax_id, $exempt)) { + $this->validated = false; + global $C_translate; + $this->val_error[] = array( + 'field' => 'account_tax_id', + 'field_trans' => $taxObj->errField, + 'error' => $C_translate->translate('validate_general', "", "")); + } + if($exempt) + $VAR['account_tax_id']=false; + else + $VAR['account_tax_id']=$tax_id; + } + } + } + + #################################################################### + ### Get required static_Vars and validate them... return an array + ### w/ ALL errors... + #################################################################### + + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + if(!isset($this->val_error)) $this->val_error = false; + $all_error = $static_var->validate_form('account', $this->val_error); + + if($all_error != false && gettype($all_error) == 'array') + $this->validated = false; + else + $this->validated = true; + + + + #################################################################### + # If validation was failed, skip the db insert & + # set the errors & origonal fields as Smarty objects, + # and change the page to be loaded. + #################################################################### + + if(!$this->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $all_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page_current']); + } + + return; + } + + + ### Change password + $password_changed = false; + if(isset($VAR['account_password']) && $VAR['account_password'] != "") + { + if(isset($VAR['confirm_password']) && $VAR['account_password'] == $VAR['confirm_password']) + { + $password = $VAR['account_password']; + unset($VAR['account_password']); + @$VAR["account_password"] = $password; + ### Alert: the password has been changed! + global $C_debug, $C_translate; + $C_debug->alert($C_translate->translate('password_changed','account','')); + $password_changed=true; + + /* check if new password is ok */ + global $C_list; + if($C_list->is_installed('account_password_history')) { + include_once(PATH_MODULES.'account_password_history/account_password_history.inc.php'); + $accountHistory = new account_password_history(); + if(!$accountHistory->getIsPasswordOk(SESS_ACCOUNT, $VAR['account_password'], false)) { + $C_debug->alert("The password you have selected has been used recently and cannot be used again at this time for security purposes."); + unset($VAR["account_password"]); + $password_changed=false; + } + } + + } + else + { + ### ERROR: The passwords provided do not match! + global $C_debug, $C_translate; + $C_debug->alert($C_translate->translate('password_change_match','account','')); + unset($VAR["account_password"]); + } + } + else + { + unset($VAR["account_password"]); + } + + + ### Change theme + if(isset($VAR['tid']) && $VAR['tid'] != "") + @$VAR["account_theme_id"] = $VAR['tid']; + + + ### Change Language + if(isset($VAR['lid']) && $VAR['lid'] != "") + @$VAR["account_language_id"] = $VAR['lid']; + + + ### Change country + if(isset($VAR['cid']) && $VAR['cid'] != "") + @$VAR["account_country_id"] = $VAR['cid']; + + + ### Change currency + if(isset($VAR['cyid']) && $VAR['cyid'] != "") + @$VAR["account_currency_id"] = $VAR['cyid']; + + ### Get the old username ( for db mapping ) + $db = &DB(); + $sql = 'SELECT username FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(SESS_ACCOUNT); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + $old_username = $result->fields['username']; + } + + ### Update the record + $this->account_construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + + + /* password logging class */ + if($password_changed && is_object($accountHistory)) $accountHistory->setNewPassword(SESS_ACCOUNT, $VAR['account_password'], false); + + + + ### Update the static vars: + $static_var->update($VAR, 'account', SESS_ACCOUNT); + + ### Do any db_mapping + global $C_list; + if($C_list->is_installed('db_mapping')) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + if(!empty($password)) + $db_map->plaintext_password = $password; + else + $db_map->plaintext_password = false; + $db_map->account_edit ( SESS_ACCOUNT, $old_username ); + } + + /* update groups for subaccount */ + if($issubaccount) { + $db=&DB(); + $db->Execute(sqlDelete($db,"account_group","group_id>2 and + (service_id is null or service_id=0 or service_id='') + and account_id=".$db->qstr($VAR['account_id']))); + if(!empty($VAR['groups'])) + { + global $C_auth; + foreach($VAR['groups'] as $gid=>$val) { + if($gid==$val && $C_auth->auth_group_by_id($gid)) { + $fields=Array('account_id'=>$VAR['account_id'], 'group_id'=>$gid, 'active'=>1, 'date_orig'=>time() ); + $db->Execute(sqlInsert($db,"account_group",$fields)); + } + } + } + } + } + + + + ############################## + ## PASSWORD ## + ############################## + + function password($VAR) + { + ### Set the max time between password requests: + $LIMIT_SECONDS = 120; + + global $C_translate, $C_debug; + + ### Is the username & email both set? + if(!isset($VAR["account_email"]) && !isset($VAR["account_username"]) ) + { + #### ERROR: You must enter either your username or e-mail address! + $C_debug->alert($C_translate->translate('password_reset_req','account','')); + return; + } + else if($VAR["account_email"] == "" && $VAR["account_username"] == "") + { + #### ERROR: You must enter either your username or e-mail address! + $C_debug->alert($C_translate->translate('password_reset_req','account','')); + return; + } + + $db = &DB(); + + if(isset($VAR["account_email"]) && $VAR["account_email"] != "") + { + $sql = ' email = '. $db->qstr($VAR["account_email"], get_magic_quotes_gpc()); + } + else if(isset($VAR["account_username"]) && $VAR["account_username"] != "") + { + $sql = ' username = '. $db->qstr($VAR["account_username"], get_magic_quotes_gpc()); + } + + + $q = 'SELECT id,email,first_name,last_name FROM ' . AGILE_DB_PREFIX . 'account + WHERE '. $sql . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + + if($result->RecordCount() == 0) + { + ### ERROR: No matches found! + $C_debug->alert($C_translate->translate('password_reset_no_match','account','')); + return; + } + $account = $result->fields["id"]; + + + ################################################################### + ### Check that this email has not been requested already + ### In the last 60 seconds + + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'temporary_data WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + field1 = ' . $db->qstr($account); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + $limit = $result->fields['date_orig'] + $LIMIT_SECONDS; + + if($limit > time()) + { + $error1 = $C_translate->translate("password_reset_spam_limit","account",""); + $error = ereg_replace('%limit%', "$LIMIT_SECONDS", $error1); + $C_debug->alert( $error ); + return; + } + else + { + ### Delete the old request + $sql = 'DELETE FROM ' . AGILE_DB_PREFIX . 'temporary_data WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + field1 = ' . $db->qstr($account); + $db->Execute($sql); + } + + } + + + ################################################################### + ### Ok to continue: + + $now = md5(microtime()); + $expire = time() + (15*60); // expires in 15 minutes + + + ##################################################### + ### Create the temporary DB Record: + + $db = &DB(); + $id = $db->GenID(AGILE_DB_PREFIX . "" . 'temporary_data_id'); + $sql = 'INSERT INTO ' . AGILE_DB_PREFIX . 'temporary_data SET + site_id = ' . $db->qstr(DEFAULT_SITE) . ', + id = ' . $db->qstr($id) . ', + date_orig = ' . $db->qstr(time()) . ', + date_expire = ' . $db->qstr($expire) . ', + field1 = ' . $db->qstr($account) . ', + field2 = ' . $db->qstr($now); + $result = $db->Execute($sql); + + + ##################################################### + ### Send the password reset email template: + + require_once(PATH_MODULES . 'email_template/email_template.inc.php'); + $my = new email_template; + $my->send('account_reset_password', $account, '', '', $now); + + ### ALERT: we have sent an email to you.... + $C_debug->alert($C_translate->translate('password_reset_sent','account','')); + } + + + + + ############################## + ## PASSWORD RESET ## + ############################## + + function password_reset($VAR) + { + global $C_translate, $C_debug, $smarty; + + ### Validate that the password is set... && confirm password is set... + if(!isset($VAR['account_password']) || !isset($VAR['confirm_password'])) + { + ### ERROR: + $message = $C_translate->translate('password_reset_reqq','account',''); + $C_debug->alert($message); + return; + } + else if ($VAR['account_password'] == "") + { + ### ERROR: + $message = $C_translate->translate('password_reset_reqq','account',''); + $C_debug->alert($message); + return; + } + else if ($VAR['account_password'] != $VAR['confirm_password']) + { + ### ERROR: + $message = $C_translate->translate('password_change_match','account',''); + $C_debug->alert($message); + return; + } + else + { + $plaintext_password = $VAR['account_password']; + + /* hash the password */ + if(defined('PASSWORD_ENCODING_SHA')) + $password = sha1($VAR['account_password']); + else + $password = md5($VAR['account_password']); + } + + + if(!isset($VAR['validate']) || $VAR['validate'] == "") + { + ### ERROR: bad link.... + $url = '
' . $C_translate->translate('submit','CORE','') . ''; + $message = $C_translate->translate('password_reset_bad_url','account',''); + $C_debug->alert($message . '' . $url); + return; + } + + + ### Get the temporary record from the database + $validate = @$VAR['validate']; + $db = &DB(); + $sql = 'SELECT field1,field2 FROM ' . AGILE_DB_PREFIX . 'temporary_data WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + date_expire >= '. $db->qstr(time()) . ' AND + field2 = ' . $db->qstr($validate); + $result = $db->Execute($sql); + + if($result->RecordCount() == 0) + { + ### ERROR: no match for submitted link, invalid or expired. + $url = '
' . $C_translate->translate('submit','CORE','') . ''; + $message = $C_translate->translate('password_reset_bad_url','account',''); + $C_debug->alert($message . '' . $url); + return; + } + + $account_id = $result->fields['field1']; + + /* check if new password is ok */ + global $C_list; + if($C_list->is_installed('account_password_history')) { + include_once(PATH_MODULES.'account_password_history/account_password_history.inc.php'); + $accountHistory = new account_password_history(); + if(!$accountHistory->getIsPasswordOk($account_id, $password)) { + $C_debug->alert("The password you have selected has been used recently and cannot be used again at this time for security purposes."); + return; + } + } + + + ############################################################### + ### Delete the temporary record + $sql = 'DELETE FROM ' . AGILE_DB_PREFIX . 'temporary_data WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + field2 = ' . $db->qstr($validate); + $db->Execute($sql); + + + ############################################################### + ### Update the password record: + $db = &DB(); + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'account + SET + date_last = ' . $db->qstr(time()) . ', + password = ' . $db->qstr($password) . ' + WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($account_id); + $db->Execute($sql); + + /* password logging class */ + if(!empty($accountHistory) && is_object($accountHistory)) $accountHistory->setNewPassword($account_id, $password); + + + #################################################################### + ### Get the old username ( for db mapping ) + + $db = &DB(); + $sql = 'SELECT username FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($account_id); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + $old_username = $result->fields['username']; + } + + #################################################################### + ### Do any db_mapping + #################################################################### + global $C_list; + if($C_list->is_installed('db_mapping')) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + $db_map->plaintext_password = $plaintext_password; + $db_map->account_edit ( $account_id, $old_username ); + } + + + ### Return the success message: + $C_debug->alert($C_translate->translate('password_update_success','account','')); + $smarty->assign('pw_changed', true); + } + + + + ############################## + ## VERIFY ACCOUNT ## + ############################## + + function verify($VAR) + { + global $C_debug, $C_translate, $smarty; + + ### Validate $verify is set... + if(!isset($VAR['verify']) || $VAR['verify'] == "") + { + ### Error: please use the form below ... + $smarty->assign('verify_results', false); + return; + } + + @$verify = explode(':', $VAR['verify']); + + ### Validate the $verify string.... + $db = &DB(); + $sql = 'SELECT id,username,status FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(@$verify[1]) . ' AND + date_orig = ' . $db->qstr(@$verify[0]); + $result = $db->Execute($sql); + if($result->RecordCount() == 0) + { + ### Error: please use the form below ... + $smarty->assign('verify_results', false); + return; + } + + + ### Check the status: + $status = $result->fields['status']; + $username = $result->fields['username']; + if($status == "1") + { + ### Account already active! + $smarty->assign('verify_results', true); + return; + } + + ### Update the account status + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'account SET + status = ' . $db->qstr("1") . ' + WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(@$verify[1]); + $result = $db->Execute($sql); + + + ### Account now active! + $smarty->assign('verify_results', true); + + + ### Return the success message: + $C_debug->alert($C_translate->translate('password_update_success','account','')); + + + #################################################################### + ### Do any db_mapping + #################################################################### + global $C_list; + /* + if($C_list->is_installed('db_mapping')) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + $db_map->account_edit ( $VAR['verify'], $username ); + } + */ + if($C_list->is_installed('db_mapping') ) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + $db_map->plaintext_password = false; + $db_map->account_add ( $verify[1] ); + } + } + + + + + ############################## + ## VERIFY ACCOUNT ## + ############################## + + function verify_resend($VAR) + { + global $C_translate, $C_debug; + + ### Is the username & email both set? + if(!isset($VAR["account_email"]) && !isset($VAR["account_username"]) ) + { + #### ERROR: You must enter either your username or e-mail address! + $C_debug->alert($C_translate->translate('verify_resend_req','account','')); + return; + } + else if($VAR["account_email"] == "" && $VAR["account_username"] == "") + { + #### ERROR: You must enter either your username or e-mail address! + $C_debug->alert($C_translate->translate('verify_resend_req','account','')); + return; + } + + $db = &DB(); + + if(isset($VAR["account_email"]) && $VAR["account_email"] != "") + { + $sql = ' email = '. $db->qstr($VAR["account_email"], get_magic_quotes_gpc()); + } + else if(isset($VAR["account_username"]) && $VAR["account_username"] != "") + { + $sql = ' username = '. $db->qstr($VAR["account_username"], get_magic_quotes_gpc()); + } + + + $q = 'SELECT id,date_orig,status,email,first_name,last_name FROM ' . AGILE_DB_PREFIX . 'account + WHERE '. $sql . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + + if($result->RecordCount() == 0) + { + ### ERROR: No matches found! + $C_debug->alert($C_translate->translate('password_reset_no_match','account','')); + return; + } + $account = $result->fields["id"]; + $status = $result->fields["status"]; + $validation_str = strtoupper($result->fields['date_orig']. ':' . $result->fields['id']); + + if($status == "1") + { + ### ERROR: This account is already active! + $C_debug->alert($C_translate->translate('verify_resend_active','account','')); + return; + } + + ### Resend the pending email: + require_once(PATH_MODULES . 'email_template/email_template.inc.php'); + $my = new email_template; + $my->send('account_registration_inactive', $account, $account, '', $validation_str); + + ### Notice that the email is sent: + $C_debug->alert($C_translate->translate("user_add_inactive_welcome","account","")); + + } + + + ############################## + ## STATIC VARS ## + ############################## + + function static_var($VAR) + { + global $smarty; + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + + + if(ereg('search', $VAR['_page'])) + $arr = $static_var->generate_form('account', 'add', 'search'); + else + $arr = $static_var->generate_form('account', 'add', 'update'); + + if(gettype($arr) == 'array') + { + ### Set everything as a smarty array, and return: + $smarty->assign('show_static_var', true); + $smarty->assign('static_var', $arr); + return true; + } + else + { + ### Or if no results: + $smarty->assign('show_static_var', false); + return false; + } + } +} +?> \ No newline at end of file diff --git a/modules/account/account_construct.xml b/modules/account/account_construct.xml new file mode 100644 index 00000000..bd59606a --- /dev/null +++ b/modules/account/account_construct.xml @@ -0,0 +1,193 @@ + + + + account + + account
+ + + + 0 + + last_name + + 30 + + + + I8 + 1 + + + I4 + + + I8 + + + I8 + date-now + + + I8 + date + + + I4 + + + C(32) + + + I4 + + + C(32) + + + I4 + + + I4 + + + I4 + + + C(32) + + + C(128) + 4 + 12 + any + 1 + 1 + + + C(128) + 6 + 12 + password + md5 + + + L + + + C2(128) + + + I4 + + + C(128) + 1 + 128 + any + 1 + + + C(128) + + + C(128) + 1 + 128 + any + 1 + + + <type>C(128)</type> + + + C(255) + 4 + 128 + email + 1 + 1 + + + C(255) + + + C(128) + 3 + 128 + any + + + C(128) + 128 + + + C(32) + 2 + 32 + any + + + C(32) + 2 + 32 + any + + + C(16) + 4 + 16 + any + + + L + + + I4 + + + L + 1 + + + I4 + + + I4 + + + C(64) + + + I4 + + + + + username,password + first_name,middle_name,last_name + company + email + affiliate_id + campaign_id + country_id + city,state + city + state + zip + id,site_id + first_name,last_name,email,company + + + + id,date_orig,date_last,language_id,country_id,affiliate_id,reseller_id,currency_id,theme_id,username,password,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,tax_id + id,date_orig,date_last,language_id,country_id,affiliate_id,reseller_id,currency_id,theme_id,username,password,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,email_type,tax_id + id,parent_id,date_last,language_id,country_id,affiliate_id,reseller_id,currency_id,theme_id,username,password,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,email_type,tax_id,max_child + + + + + account_admin:add_account_groups + + +
diff --git a/modules/account/account_install.xml b/modules/account/account_install.xml new file mode 100644 index 00000000..c664002c --- /dev/null +++ b/modules/account/account_install.xml @@ -0,0 +1,14 @@ + + + account + account + + + + + + install + + + + \ No newline at end of file diff --git a/modules/account/account_install_data.xml b/modules/account/account_install_data.xml new file mode 100644 index 00000000..26e597a8 --- /dev/null +++ b/modules/account/account_install_data.xml @@ -0,0 +1,33 @@ + + + + 1 + 1 + 1075175744 + 1112335769 + 0 + 0 + english + 840 + 0 + 1 + default + admin + 21232f297a57a5a743894a0e4a801fc3 + Notes + 1 + Admin + Admin + Mrs + email@company.com + + City + State + 12345 + 0 + 0 + + + 33 + + \ No newline at end of file diff --git a/modules/account/account_xmlrpc.php b/modules/account/account_xmlrpc.php new file mode 100644 index 00000000..9d40cddc --- /dev/null +++ b/modules/account/account_xmlrpc.php @@ -0,0 +1,155 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +ob_start(); + +include_once('../../config.inc.php'); +require_once(PATH_ADODB . 'adodb.inc.php'); +require_once(PATH_CORE . 'database.inc.php'); +require_once(PATH_CORE . 'setup.inc.php'); +require_once(PATH_CORE . 'vars.inc.php'); +require_once(PATH_CORE . 'translate.inc.php'); +require_once(PATH_CORE . 'xml.inc.php'); +include_once(PATH_INCLUDES . "xml-rpc/xml-rpc.php"); +$C_debug = new CORE_debugger; +$C_setup = new CORE_setup; +$C_translate= new CORE_translate; + +class AccountServer extends IXR_Server { + + var $account_id; + var $account_parent_id=false; + var $username; + var $password; + var $login_error; + + function AccountServer() { + $this->IXR_Server(array( + 'account.details' => 'this:getAccountDetails' + )); + } + + function getAccountDetails($args) { + $this->username = $args[0]; + $this->password = $args[1]; + if(!$this->getAccountAuth()) return array('auth'=> false, 'reason'=>$this->login_error); + $return = array( + 'auth' => true, + 'acct' => $this->account_id, + 'info' => $this->getAccountInfo(), + 'skus' => $this->getAccountSKUs(), + 'grps' => $this->getAccountGroups() + ); + return $return; + } + + function getAccountAuth() { + // select from account where username = $this_username and password = $this->password + include_once(PATH_CORE.'login.inc.php'); + $login = new CORE_login_handler(); + if(!$login->login(array("_username"=> $this->username, "_password"=> $this->password), true)) { + $this->login_error = $login->error; + return false; + } else { + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"account","id","username = ::$this->username::")); + $this->account_id = $rs->fields['id']; + return true; + } + } + + function getAccountInfo() { + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"account","*","id = ::$this->account_id::")); + if(!empty($rs->fields['parent_id'])) $this->account_parent_id = $rs->fields['parent_id']; + $ret = Array( + 'company' => $rs->fields['company'], + 'first_name' => $rs->fields['first_name'], + 'last_name' => $rs->fields['last_name'], + 'address1' => $rs->fields['address1'], + 'address2' => $rs->fields['address2'], + 'city' => $rs->fields['city'], + 'state' => $rs->fields['state'], + 'zip' => $rs->fields['zip'], + 'email' => $rs->fields['email'], + 'acct_parent_id' => $rs->fields['parent_id'] + ); + $rs = $db->Execute(sqlSelect($db,"module","id","name=::account::")); + $account_module=$rs->fields['id']; + /* get custom fields*/ + $sql = "SELECT DISTINCT A.value, B.name FROM ".AGILE_DB_PREFIX."static_var as B + LEFT JOIN ".AGILE_DB_PREFIX."static_var_record as A on (B.id=A.static_var_id AND A.record_id = ".$db->qstr($this->account_id).") + WHERE A.module_id=$account_module "; + $rs=$db->Execute($sql); + if($rs &&$rs->RecordCount()) { + while(!$rs->EOF) { + $fld = substr(strtolower(ereg_replace(" ",'_', $rs->fields['name'])),0,32); + @$ret["$fld"]=$rs->fields['value']; + $rs->MoveNext(); + } + } + return $ret; + } + + function getAccountSKUs() { + // select from invoice_item where id = $this->account_id + $db=&DB(); + $p=AGILE_DB_PREFIX; + $s=DEFAULT_SITE; + $arr=false; + $q = "SELECT DISTINCT A.sku FROM {$p}invoice_item A + JOIN {$p}invoice B on ((B.account_id={$this->account_id} "; + if($this->account_parent_id) + $q.= " OR B.account_id = {$this->account_parent_id} "; + $q.= ") AND B.id=A.invoice_id AND B.site_id={$s} AND billing_status=1 AND process_status=1) + WHERE A.site_id = {$s}"; + $rs = $db->Execute($q); + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + $arr[] = $rs->fields['sku']; + $rs->MoveNext(); + } + } + return $arr; + } + + function getAccountGroups() { + // select from account_group where account_id = $this->account_id + $db=&DB(); + $p=AGILE_DB_PREFIX; + $s=DEFAULT_SITE; + $arr=false; + $q = "SELECT DISTINCT group_id FROM {$p}account_group WHERE account_id={$this->account_id} AND site_id={$s} AND (active=1 OR active!='' or active!=0 or active is not null)"; + $rs = $db->Execute($q); + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + $arr[] = $rs->fields['group_id']; + $rs->MoveNext(); + } + } + return $arr; + } + +} +$server = new AccountServer(); + +ob_end_flush(); + +?> \ No newline at end of file diff --git a/modules/account/auth.inc.php b/modules/account/auth.inc.php new file mode 100644 index 00000000..c637b6b8 --- /dev/null +++ b/modules/account/auth.inc.php @@ -0,0 +1,38 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +$auth_methods = Array +( + Array ('module' => 'account', 'method' => 'add'), + Array ('module' => 'account', 'method' => 'user_add'), + Array ('module' => 'account', 'method' => 'user_view'), + Array ('module' => 'account', 'method' => 'add'), + Array ('module' => 'account', 'method' => 'view'), + Array ('module' => 'account', 'method' => 'update'), + Array ('module' => 'account', 'method' => 'password'), + Array ('module' => 'account', 'method' => 'password_reset'), + Array ('module' => 'account', 'method' => 'static_var'), + Array ('module' => 'account', 'method' => 'verify'), + Array ('module' => 'account', 'method' => 'verify_resend'), + Array ('module' => 'account', 'method' => 'sub_account_add'), + Array ('module' => 'account', 'method' => 'sub_delete') +); + +?> \ No newline at end of file diff --git a/modules/account_admin/account_admin.inc.php b/modules/account_admin/account_admin.inc.php new file mode 100644 index 00000000..d92b9f2a --- /dev/null +++ b/modules/account_admin/account_admin.inc.php @@ -0,0 +1,2651 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class account_admin +{ + + # Open the constructor for this mod + function account_admin() + { + # name of this module: + $this->module = "account_admin"; + + if(!defined('AJAX')) + { + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + } + + /** + * Check account limitations + */ + function checkLimits() { + if(!defined('AGILE_RST_ACCOUNT') || AGILE_RST_ACCOUNT <= 0) return true; + $sql="SELECT count(*) as totalacct from ".AGILE_DB_PREFIX."account WHERE site_id=".DEFAULT_SITE; + $db=&DB(); + $rs=$db->Execute($sql); + if($rs && $rs->RecordCount() && $rs->fields['totalacct'] <= AGILE_RST_ACCOUNT) { + return true; + } else { + echo "Licensed user limit of ".AGILE_RST_ACCOUNT." exceeded, operation failed."; + return false; + } + return true; + } + + /* BEGIN: custom product/group searching method */ + + function group_search($VAR) { + $sql = ''; + echo "
"; 
+
+		// get date ranges:
+		foreach($VAR['dates']['val'] as $cond => $val) 
+		{
+			if($val > 0) {
+				$exp = $VAR['dates']['expr'][$cond]; 
+				$val = $this->convert_date($val,false);
+
+				if(!empty($sql)) $sql .= " AND "; else $sql = " ";
+				$sql .= " A.date_orig $exp $val ";
+			} 
+		}        
+		if(!empty($sql)) $sql = " ( $sql ) ";	
+
+		// get group(s)
+		if(!empty($VAR['groups'])) {
+			foreach($VAR['groups'] as $group ) 
+			{  
+				if($group != 0) {
+					if(!empty($sql2)) $sql2 .= " OR "; else $sql2 = " ";
+					$sql2 .= " B.group_id = $group ";  
+				}
+			}
+		}
+		if(!empty($sql2)) {
+			if(!empty($sql)) $sql .= " AND \r\n";
+			$sql .= " ( $sql2 ) AND ( A.id = B.account_id AND B.active = 1 ) ";
+		}
+
+		// Assemble SQL:
+		$q = "SELECT DISTINCT A.* FROM 
+			". AGILE_DB_PREFIX ."account as A,
+			". AGILE_DB_PREFIX ."account_group as B
+			WHERE (
+			A.site_id = ". DEFAULT_SITE ." AND
+			B.site_id = ". DEFAULT_SITE ." ) ";        	
+		if(!empty($sql)) $q .= " AND " . $sql;
+		$db = &DB();
+		$rs = $db->Execute($q);	 
+
+		// print results in text format      	
+		if($rs && $rs->RecordCount() > 0) {
+			while(!$rs->EOF) {        			
+				echo $rs->fields['first_name'] .', '.$rs->fields['last_name'] .', '.$rs->fields['email'] .', '.$rs->fields['company'] .",\r\n";        		
+				$rs->MoveNext();
+			}
+		} else {
+			echo "No matches!";
+		}
+		echo "
"; + } + + + + function product_search($VAR) { + $sql = ''; + echo "
"; 
+
+		// get date ranges:
+		if(!empty($VAR["dates"]))
+		{
+			foreach($VAR['dates']['val'] as $cond => $val) 
+			{
+				if($val > 0) {
+					$exp = $VAR['dates']['expr'][$cond]; 
+					$val = $this->convert_date($val,false);
+
+					if(!empty($sql)) $sql .= " AND "; else $sql = " ";
+					$sql .= " B.date_orig $exp $val ";
+				} 
+			}
+		}        
+		if(!empty($sql)) $sql = " ( $sql ) ";	
+
+		// get group(s)
+		if(!empty($VAR['products'])) {
+			foreach($VAR['products'] as $prod ) 
+			{  
+				if($prod != 0) {
+					if(!empty($sql2)) $sql2 .= " OR "; else $sql2 = " ";
+					$sql2 .= " B.product_id = $prod ";  
+				}
+			}
+		}
+		if(!empty($sql2)) {
+			if(!empty($sql)) $sql .= " AND \r\n";
+			$sql .= " ( $sql2 ) AND ( A.id = C.account_id AND C.id =  B.invoice_id ) ";
+		}
+
+		// Assemble SQL:
+		$q = "SELECT DISTINCT A.* FROM 
+			". AGILE_DB_PREFIX ."account as A,
+			". AGILE_DB_PREFIX ."invoice_item as B,
+			". AGILE_DB_PREFIX ."invoice as C
+			WHERE (
+			A.site_id = ". DEFAULT_SITE ." AND
+			C.site_id = ". DEFAULT_SITE ." AND
+			B.site_id = ". DEFAULT_SITE ." ) ";        	
+		if(!empty($sql)) $q .= " AND " . $sql;
+		$db = &DB();
+		$rs = $db->Execute($q);	 
+
+
+		// print results in text format      	
+		if($rs && $rs->RecordCount() > 0) {
+			while(!$rs->EOF) {        			
+				echo $rs->fields['first_name'] .', '.$rs->fields['last_name'] .', '.$rs->fields['email'] .', '.$rs->fields['company'] .",\r\n";        		
+				$rs->MoveNext();
+			}
+		} else {
+			echo "No matches!";
+		}
+		echo "
"; + } + + function convert_date ($date,$field) + { + if($date == '0' || $date == '') + return ''; + + $Arr_format = split(DEFAULT_DATE_DIVIDER, UNIX_DATE_FORMAT); + $Arr_date = split(DEFAULT_DATE_DIVIDER, $date); + + for($i=0; $i<3; $i++) + { + if($Arr_format[$i] == 'd') + $day = $Arr_date[$i]; + + if($Arr_format[$i] == 'm') + $month = $Arr_date[$i]; + + if($Arr_format[$i] == 'Y') + $year = $Arr_date[$i]; + } + + $timestamp = mktime(0, 0, 0, $month, $day, $year); + return $timestamp; + } + + /* END: custom product/group searching method */ + + + + + + + + + ########################################### + ### AJAX Auto-selector + ########################################### + + function autoselect($VAR) + { + if(!$this->checkLimits()) return false; // check account limits + + $db = &DB(); + $p = AGILE_DB_PREFIX; + + if (empty($VAR['account_search'])) { + $where = "id > 0"; + $type = 1; + } elseif (is_numeric($VAR['account_search'])) { + $where = "id LIKE ".$db->qstr($VAR['account_search']."%"); + $type = 1; + } elseif (eregi(" ", $VAR['account_search'])) { + $arr = split(" ", $VAR['account_search']); + $where = "first_name = ".$db->qstr($arr[0])." AND ". + "last_name LIKE ".$db->qstr($arr[1].'%') ; + $type = 2; + } elseif (eregi("@", $VAR['account_search'])) { + $where = "email LIKE ".$db->qstr('%'.$VAR['account_search'].'%') ; + $type = 3; + + } else { + $where = "username LIKE ".$db->qstr($VAR['account_search'].'%')." OR ". + "first_name LIKE ".$db->qstr($VAR['account_search'].'%')." OR ". + "last_name LIKE ".$db->qstr($VAR['account_search'].'%') ; + $type = 4; + } + + $q = "SELECT id,email,first_name,last_name,username FROM {$p}account WHERE + ( $where ) + AND + site_id = " . DEFAULT_SITE." + ORDER BY first_name,last_name"; + $result = $db->SelectLimit($q,10); + + # Create the alert for no records found + echo '
    '; + # Create the alert for no records found + if ($result->RecordCount() > 0) { + $i=0; + while(!$result->EOF) + { + echo '
  • ' . $result->fields['first_name'].' '.$result->fields['last_name'] . '
    '. + ''. + '
  • ' . "\r\n"; + $result->MoveNext(); + $i++; + } + } + echo "
"; + + } + + + ########################################### + ### Login as user + ########################################### + + function login($VAR) + { + global $C_auth; + + # Check for target user + $display_this=false; + if(!empty($VAR['account_id'])) + { + ### Get any authorized groups of the target account + $dba = &DB(); + $sql = 'SELECT group_id FROM ' . AGILE_DB_PREFIX . 'account_group WHERE + site_id = ' . $dba->qstr(DEFAULT_SITE) . ' AND + account_id = ' . $dba->qstr($VAR['account_id']) . ' AND + active = ' . $dba->qstr("1") . ' + ORDER BY group_id'; + $groups = $dba->Execute($sql); + while (!$groups->EOF) { + $group[] = $groups->fields['group_id']; + $groups->MoveNext(); + } + + ### Verify the user has access to view this account: + if(SESS_ACCOUNT != $VAR['account_id']) { + $display_this = true; + for($ix=0; $ixauth_group_by_id($group[$ix])) + $display_this = false; + } + } else { + return false; + } + + } else { + return false; + } + + # Logout current user and login as the target user + if($display_this) + { + $db = &DB(); + $sql = 'SELECT username,password FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $dba->qstr(DEFAULT_SITE) . ' AND + id = ' . $dba->qstr($VAR['account_id']); + $acct = $db->Execute($sql); + $arr['_username'] = $acct->fields['username']; + $arr['_password'] = $acct->fields['password']; + include_once(PATH_CORE.'login.inc.php'); + $login = new CORE_login_handler; + $login->logout($VAR); + $login->login($arr, $md5=false); + define('REDIRECT_PAGE', '?_page=account:account&tid='.DEFAULT_THEME); + } + + + #################################################################### + ### Do any db_mapping + #################################################################### + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'module WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + name = ' . $db->qstr('db_mapping') . ' AND + status = ' . $db->qstr("1"); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + $db_map->login ( $VAR['account_id'] ); + } + } + + + ########################################### + ### Account selector list search + ########################################### + + function popup_search($VAR) + { + $db = &DB(); + if (empty($VAR['search'])) { + $where = ''; + } elseif (eregi(" ", $VAR['search'])) { + $arr = split(" ", $VAR['search']); + $where = "first_name = ".$db->qstr($arr[0])." AND ". + "last_name LIKE ".$db->qstr('%'.$arr[1].'%')." AND "; + } else { + $where = "username LIKE ".$db->qstr('%'.$VAR['search'].'%')." OR ". + "first_name LIKE ".$db->qstr('%'.$VAR['search'].'%')." OR ". + "first_name LIKE ".$db->qstr('%'.$VAR['search'].'%')." OR ". + "company LIKE ". $db->qstr('%'.$VAR['search'].'%')." AND "; + } + + $q = "SELECT id,first_name,last_name + FROM ".AGILE_DB_PREFIX."account + WHERE $where + site_id = '" . DEFAULT_SITE . "'"; + + $q_save = "SELECT * FROM ".AGILE_DB_PREFIX."account WHERE $where %%whereList%% "; + $result = $db->Execute($q); + + /// DEBUG //// + // echo "
$q
"; + + # get the result count: + $results = $result->RecordCount(); + + # Create the alert for no records found + if ($results == 0) + { + $id = $result->fields['id']; + $name = $result->fields['first_name'].' '.$result->fields['last_name']; + $val = $id.'|'.$name; + $res = ' + '; + echo $res; + } + else if ($results == 1) + { + $id = $result->fields['id']; + $name = $result->fields['first_name'].' '.$result->fields['last_name']; + $val = $id.'|'.$name; + $res = ' + '; + echo $res; + } + else + { + # create the search record + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $arr['module'] = $this->module; + $arr['sql'] = $q_save; + $arr['limit'] = '30'; + $arr['order_by'] = 'last_name'; + $arr['results'] = $results; + $search->add($arr); + + global $smarty; + $smarty->assign('search_id', $search->id); + $smarty->assign('page', '1'); + $smarty->assign('limit', $limit); + $smarty->assign('order_by', $order_by); + $smarty->assign('results', $results); + + $res = ' + '; + + echo $res; + + } + } + + + ########################################### + ### Top Accounts Graph: + ########################################### + function top($VAR) + { + global $smarty, $C_translate, $C_auth; + + # Get the period type, default to month + if (empty($VAR['period'])) + $p = 'm'; + else + $p = $VAR['period']; + + # Load the jpgraph class + include (PATH_GRAPH."jpgraph.php"); + include (PATH_GRAPH."jpgraph_bar.php"); + + # check the validation for this function + if(!$C_auth->auth_method_by_name($this->module,'search')) { + $error = $C_translate->translate('module_non_auth','',''); + include (PATH_GRAPH."jpgraph_canvas.php"); + $graph = new CanvasGraph(460,55,"auto"); + $t1 = new Text($error); + $t1->Pos(0.2,0.5); + $t1->SetOrientation("h"); + $t1->SetBox("white","black",'gray'); + $t1->SetFont(FF_FONT1,FS_NORMAL); + $t1->SetColor("black"); + $graph->AddText($t1); + $graph->Stroke(); + exit; + } + + # Get the period start & end + switch ($p) + { + # By Weeks: + case 'w': + $interval = "1"; + $width = ".9"; + $title = 'Top Accounts for Last Last Week'; + $dow = date('w'); + $start_str = mktime(0,0,0,date('m'), date('d')-$dow, date('y')); + $end_str = mktime(23,59,59,date('m'), date('d'), date('y')); + break; + + # By Months: + case 'm': + $interval = "3"; + $width = ".6"; + $title = 'Top Accounts for Last Last Month'; + $start_str = mktime(0,0,0,date('m'), 1, date('y')); + $end_str = mktime(23,59,59,date('m'), date('d'), date('y')); + break; + + # By Years: + case 'y': + $interval = "1"; + $width = ".8"; + $title = 'Top Accounts for Last Last Year'; + $start_str = mktime(0,0,0,1,1, date('y')); + $end_str = mktime(23,59,59, date('m'), date('d'), date('y')); + break; + } + + + ##############################@@@@@@@@ + # Get accounts & sales for this period + ##############################@@@@@@@@ + $db = &DB(); + $sql = 'SELECT account_id,total_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE + date_orig >= ' . $db->qstr( $start_str ) . ' AND date_orig <= ' . $db->qstr( $end_str ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + if(@$result->RecordCount() == 0) { + $file = fopen( PATH_THEMES.'default_admin/images/invisible.gif', 'r'); + fpassthru($file); + exit; + } + + while(!$result->EOF) + { + $amt = $result->fields['total_amt']; + $acct = $result->fields['account_id']; + if(!isset( $arr[$acct] )) $arr[$acct] = 0; + $arr[$acct] += $amt; + $result->MoveNext(); + } + + $i = 0; + while(list($key, $var) = each(@$arr)) { + # Get the user name + $sql = 'SELECT first_name,last_name FROM ' . AGILE_DB_PREFIX . 'account WHERE + id = ' . $db->qstr( $key ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + + $_lbl[] = strtoupper(substr($rs->fields['first_name'],0,1)) . ". " . $rs->fields['last_name']; + $_datay[] = $var; + $i++; + } + + + ### Sort the arrays + array_multisort($_datay,SORT_DESC, SORT_NUMERIC, $_lbl); + + ### Limit the results to 10 or less + for($i=0; $i=9) $i = count($_lbl); + } + + $i = count($lbl); + + + # Get the Currency + $sql = 'SELECT symbol FROM ' . AGILE_DB_PREFIX . 'currency WHERE + id = ' . $db->qstr( DEFAULT_CURRENCY ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + $currency_iso = $rs->fields['symbol']; + + // Size of graph + $width=265; + $height=75 + ($i*15); + + // Set the basic parameters of the graph + $graph = new Graph($width,$height,'auto'); + $graph->SetScale("textlin"); + $graph->yaxis->scale->SetGrace(50); + $graph->SetMarginColor('#F9F9F9'); + $graph->SetFrame(true,'#CCCCCC',1); + $graph->SetColor('#FFFFFF'); + + $top = 45; + $bottom = 10; + $left = 95; + $right = 15; + $graph->Set90AndMargin($left,$right,$top,$bottom); + + // Label align for X-axis + $graph->xaxis->SetLabelAlign('right','center','right'); + + // Label align for Y-axis + $graph->yaxis->SetLabelAlign('center','bottom'); + $graph->xaxis->SetTickLabels($lbl); + + // Titles + $graph->title->SetFont(FF_FONT1,FS_BOLD,9.5); + $title = $C_translate->translate('graph_top','account_admin',''); + $graph->title->Set($title); + + // Create a bar pot + $bplot = new BarPlot($datay); + $bplot->SetFillColor("#506DC7"); + $bplot->SetWidth(0.2); + + // Show the values + $bplot->value->Show(); + $bplot->value->SetFont(FF_FONT1,FS_NORMAL,8); + $bplot->value->SetAlign('center','center'); + $bplot->value->SetColor("black","darkred"); + $bplot->value->SetFormat($currency_iso.'%.2f'); + + $graph->Add($bplot); + $graph->Stroke(); + + return; + } + + + + ############################## + ## MAIL ONE ACCOUNT ## + ############################## + function mail_one($VAR) + { + global $C_translate, $C_debug; + + ## Validate the required vars (account_id, message, subject) + if(@$VAR['mail_account_id'] != "" && @$VAR['mail_subject'] != "" && @$VAR['mail_message'] != "") + { + ## Verify the specified account: + $db = &DB(); + $sql = 'SELECT email,first_name,last_name FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($VAR['mail_account_id']); + $account = $db->Execute($sql); + + if($account->RecordCount() == 0) + { + ## Error message: + $C_debug->alert($C_translate->translate('account_non_exist','account_admin','')); + return; + } + + ################################################################ + ## OK to send the email: + + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."setup_email WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($VAR['mail_email_id']); + $setup_email = $db->Execute($q); + + $E['priority'] = $VAR['mail_priority']; + $E['html'] = '0'; + $E['subject'] = $VAR['mail_subject']; + $E['body_text'] = $VAR['mail_message']; + $E['to_email'] = $account->fields['email']; + $E['to_name'] = $account->fields['first_name'] . ' ' . $account->fields['last_name']; + + + if($setup_email->fields['type'] == 0) + { + $type = 0; + } + else + { + $type = 1; + $E['server'] = $setup_email->fields['server']; + $E['account'] = $setup_email->fields['username']; + $E['password'] = $setup_email->fields['password']; + } + + $E['from_name'] = $setup_email->fields['from_name']; + $E['from_email'] = $setup_email->fields['from_email']; + + if($setup_email->fields['cc_list'] != '') + $E['cc_list'] = split(',', $setup_email->fields['cc_list']); + + if($setup_email->fields['bcc_list'] != '') + $E['bcc_list'] = split(',', $setup_email->fields['bcc_list']); + + + ### Call the mail class + require_once(PATH_CORE . 'email.inc.php'); + $email = new CORE_email; + if($type == 0) + $email->PHP_Mail($E); + else + $email->SMTP_Mail($E); + + + } + else + { + ## Error message: + $C_debug->alert($C_translate->translate('validate_any','','')); + + ## Stripslashes + global $C_vars; + $C_vars->strip_slashes_all(); + return; + } + + ## Success message: + $C_debug->alert($C_translate->translate('mail_sent','account_admin','')); + + ## Stripslashes + global $C_vars; + $C_vars->strip_slashes_all(); + } + + + ############################## + ## MAIL MULTI ACCOUNTS ## + ############################## + function mail_multi($VAR) + { + if(!$this->checkLimits()) return false; // check account limits + + global $C_translate, $C_debug; + + ## Validate the required vars (account_id, message, subject) + if(@$VAR['search_id'] != "" && @$VAR['mail_subject'] != "" && @$VAR['mail_message'] != "") + { + + ## Get the specified accounts: + # get the search details: + if(isset($VAR['search_id'])) { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } else { + # invalid search! + echo '
The search terms submitted were invalid!'; # translate... # alert + return; + } + + # generate the full query + $field_list = AGILE_DB_PREFIX."account.email, ". + AGILE_DB_PREFIX."account.first_name, ". + AGILE_DB_PREFIX."account.last_name "; + + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX."account", $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " ".AGILE_DB_PREFIX."account.site_id = '" . DEFAULT_SITE . "'"; + $db = &DB(); + $account = $db->Execute($q); + + // check results + if($account->RecordCount() == 0) { + $C_debug->alert($C_translate->translate('account_non_exist','account_admin','')); + return; + } + + // get the selected email setup details + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."setup_email WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($VAR['mail_email_id']); + $setup_email = $db->Execute($q); + if($setup_email->fields['type'] == 0) { + $type = 0; + } else { + $type = 1; + $E['server'] = $setup_email->fields['server']; + $E['account'] = $setup_email->fields['username']; + $E['password'] = $setup_email->fields['password']; + } + + // loop to send each e-mail + while ( !$account->EOF ) + { + $E['priority'] = $VAR['mail_priority']; + $E['html'] = '0'; + $E['subject'] = $VAR['mail_subject']; + $E['body_text'] = $VAR['mail_message']; + $E['to_email'] = $account->fields['email']; + $E['to_name'] = $account->fields['first_name'] . ' ' . $account->fields['last_name']; + $E['from_name'] = $setup_email->fields['from_name']; + $E['from_email'] = $setup_email->fields['from_email']; + + ### Call the mail class + require_once(PATH_CORE . 'email.inc.php'); + $email = new CORE_email; + $email = new CORE_email; + if($type == 0) + $email->PHP_Mail($E); + else + $email->SMTP_Mail($E); + + ### Next record + $account->MoveNext(); + } + + + } else { + ## Error message: + $C_debug->alert($C_translate->translate('validate_any','','')); + + ## Stripslashes + global $C_vars; + $C_vars->strip_slashes_all(); + return; + } + + ## Success message: + $C_debug->alert($C_translate->translate('mail_sent','account_admin','')); + + ## Stripslashes + global $C_vars; + $C_vars->strip_slashes_all(); + } + + + ############################## + ## SEND PASSWORD CHANGE ## + ############################## + function send_password_email($VAR) + { + global $C_translate, $C_debug; + require_once(PATH_MODULES . 'email_template/email_template.inc.php'); + $my = new email_template; + $my->send('password_change_instructions', @$VAR['id'], '', '', ''); + echo $C_translate->translate("password_change_instructions","account_admin",""); + } + + + ############################## + ## SEND VERIFY E-MAIL ## + ############################## + function send_verify_email($VAR) + { + global $C_translate, $C_debug; + + require_once(PATH_MODULES . 'email_template/email_template.inc.php'); + $my = new email_template; + $db = &DB(); + $dbm = new CORE_database; + echo $sql = $dbm->sql_select('account','date_orig',"id = {$VAR['id']}",'', $db); + $result = $db->Execute($sql); + $validation_str = strtoupper($result->fields['date_orig']. ':' . $VAR['id']); + $my->send('account_registration_inactive', @$VAR['id'], @$VAR['id'], '', $validation_str); + echo $C_translate->translate("account_verify_instructions","account_admin",""); + } + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + if(!$this->checkLimits()) return false; // check account limits + + global $C_translate, $C_debug, $smarty; + + ### Set the hidden values: + $VAR['account_admin_date_orig'] = time(); + $VAR['account_admin_date_last'] = time(); + if(!empty($VAR["account_admin_date_expire"])) { + include_once(PATH_CORE.'validate.inc.php'); + $val = new CORE_validate; + $date_expire = $val->DateToEpoch(false, $VAR["account_admin_date_expire"]); + } else { + $date_expire = 0; + } + + + ### Determine the proper account status: + if(!isset($VAR['account_admin_status']) || $VAR['account_admin_status'] != "1") + $status = 0; + else + $status = 1; + + + ### DEFINE A USERNAME: + if(empty($VAR['account_admin_username'])) { + $length = 4; + srand((double)microtime()*1000000); + $vowels = array("a", "e", "i", "o", "u"); + $cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", + "r", "s", "t", "u", "v", "w", "tr", "cr", "br", "fr", "th", + "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl"); + $num_vowels = count($vowels); + $num_cons = count($cons); + for($i = 0; $i < $length; $i++){ + @$VAR['account_admin_username'] .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)]; + } + } + + ## Single field login: + if(defined('SINGLE_FIELD_LOGIN') && SINGLE_FIELD_LOGIN==true && empty($VAR['account_admin_password'])) { + $VAR['account_admin_password']='none'; + $passwd = 'none'; + } + + ### DEFINE A PASSWORD: + if(empty($VAR['account_admin_password'])) + { + srand((double)microtime() * 1000000); + $UniqID = md5(uniqid(rand())); + @$VAR['account_admin_password'] = substr(md5(uniqid(rand())), 0, 10); + $passwd = '********'; + } else { + $passwd = $VAR['account_admin_password']; + + /* hash the password */ + if(defined('PASSWORD_ENCODING_SHA')) + $VAR['account_admin_password'] = sha1($VAR['account_admin_password']); + else + $VAR['account_admin_password'] = md5($VAR['account_admin_password']); + } + + + #################################################################### + ### loop through the field list to validate the required fields + #################################################################### + + $type = 'add'; + $this->method["$type"] = split(",", $this->method["$type"]); + $arr = $this->method["$type"]; + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + $this->validated = true; + + while (list ($key, $value) = each ($arr)) + { + # get the field value + $field_var = $this->module . '_' . $value; + $field_name = $value; + + #################################################################### + ### perform any field validation... + #################################################################### + + # check if this value is unique + if(isset($this->field["$value"]["unique"]) && isset($VAR["$field_var"])) + { + if(!$validate->validate_unique($this->table, $field_name, "record_id", $VAR["$field_var"])) + { + $this->validated = false; + $this->val_error[] = array('field' => $this->table . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), # translate + 'error' => $C_translate->translate('validate_unique',"", "")); + } + } + + # check if the submitted value meets the specifed requirements + if(isset($this->field["$value"]["validate"])) + { + if(isset($VAR["$field_var"])) + { + if($VAR["$field_var"] != '') + { + if(!$validate->validate($field_name, $this->field["$value"], $VAR["$field_var"], $this->field["$value"]["validate"])) + { + $this->validated = false; + $this->val_error[] = array('field' => $this->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), + 'error' => $validate->error["$field_name"] ); + } + } + else + { + $this->validated = false; + $this->val_error[] = array('field' => $this->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), + 'error' => $C_translate->translate('validate_any',"", "")); + } + } + else + { + $this->validated = false; + $this->val_error[] = array('field' => $this->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), + 'error' => $C_translate->translate('validate_any',"", "")); + } + } + } + + + // validate the tax_id + require_once(PATH_MODULES.'tax/tax.inc.php'); + $taxObj=new tax; + $tax_arr = @$VAR['account_admin_tax_id']; + if(is_array($tax_arr)) { + foreach($tax_arr as $country_id => $tax_id) { + if ($country_id == $VAR['account_admin_country_id']) { + $exempt = @$VAR["account_tax_id_exempt"][$country_id]; + if(!$taxObj->TaxIdsValidate($country_id, $tax_id, $exempt)) { + $this->validated = false; + $this->val_error[] = array( + 'field' => 'account_admin_tax_id', + 'field_trans' => $taxObj->errField, + 'error' => $C_translate->translate('validate_general', "", "")); + } + if($exempt) + $account_admin_tax_id=false; + else + $account_admin_tax_id=$tax_id; + } + } + } + + #################################################################### + ### Get required static_Vars and validate them... return an array + ### w/ ALL errors... + #################################################################### + + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + + if(!isset($this->val_error)) $this->val_error = false; + $all_error = $static_var->validate_form('account', $this->val_error); + + if($all_error != false && gettype($all_error) == 'array') + $this->validated = false; + else + $this->validated = true; + + + #################################################################### + ### If validation was failed, skip the db insert & + ### set the errors & origonal fields as Smarty objects, + ### and change the page to be loaded. + #################################################################### + + if(!$this->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $all_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page_current']); + } + + # Stripslashes + global $C_vars; + $C_vars->strip_slashes_all(); + + + return; + } + + # Get default invoice options + $db=&DB(); + $invopt=$db->Execute(sqlSelect($db,"setup_invoice","*","")); + if($invopt && $invopt->RecordCount()) { + $invoice_delivery=$invopt->fields['invoice_delivery']; + $invoice_format=$invopt->fields['invoice_show_itemized']; + } + + #################################################################### + ### Insert the account record + #################################################################### + $this->account_id = $db->GenID(AGILE_DB_PREFIX . 'account_id'); + $validation_str = time(); + + /** get parent id */ + @$parent_id = @$VAR["account_admin_parent_id"]; + if(empty($parent_id)) $parent_id = $this->account_id; + + $sql = ' + INSERT INTO ' . AGILE_DB_PREFIX . 'account SET + id = ' . $db->qstr ( $this->account_id ) . ', + site_id = ' . $db->qstr ( DEFAULT_SITE ) . ', + date_orig = ' . $db->qstr ( $validation_str ) . ', + date_last = ' . $db->qstr ( time()) . ', + date_expire = ' . $db->qstr ( $date_expire ) . ', + language_id = ' . $db->qstr ( $VAR["account_admin_language_id"] ) . ', + country_id = ' . $db->qstr ( $VAR["account_admin_country_id"] ) . ', + parent_id = ' . $db->qstr ( $parent_id ) . ', + affiliate_id = ' . $db->qstr ( @$VAR["account_admin_affiliate_id"] ) . ', + reseller_id = ' . $db->qstr ( @$VAR["account_admin_reseller_id"] ) . ', + currency_id = ' . $db->qstr ( $VAR["account_admin_currency_id"] ) . ', + theme_id = ' . $db->qstr ( $VAR["account_admin_theme_id"] ) . ', + username = ' . $db->qstr ( $VAR["account_admin_username"] ) . ', + password = ' . $db->qstr ( $VAR["account_admin_password"] ) . ', + status = ' . $db->qstr ( $status ) . ', + first_name = ' . $db->qstr ( $VAR["account_admin_first_name"] ) . ', + middle_name = ' . $db->qstr ( $VAR["account_admin_middle_name"] ) . ', + last_name = ' . $db->qstr ( $VAR["account_admin_last_name"] ) . ', + company = ' . $db->qstr ( $VAR["account_admin_company"] ) . ', + title = ' . $db->qstr ( $VAR["account_admin_title"] ) . ', + email = ' . $db->qstr ( $VAR["account_admin_email"] ) . ', + address1 = ' . $db->qstr ( $VAR["account_admin_address1"] ) . ', + address2 = ' . $db->qstr ( $VAR["account_admin_address2"] ) . ', + city = ' . $db->qstr ( $VAR["account_admin_city"] ) . ', + state = ' . $db->qstr ( $VAR["account_admin_state"] ) . ', + zip = ' . $db->qstr ( $VAR["account_admin_zip"] ) . ', + misc = ' . $db->qstr ( $VAR["account_admin_misc"] ) . ', + email_type = ' . $db->qstr ( $VAR["account_admin_email_html"] ) . ', + invoice_delivery= ' . $db->qstr ( @$invoice_delivery ) . ', + invoice_show_itemized=' . $db->qstr ( @$invoice_format ) . ', + invoice_advance_gen = ' . $db->qstr ( MAX_INV_GEN_PERIOD ) . ', + invoice_grace = ' . $db->qstr ( GRACE_PERIOD ) . ', + tax_id = ' . $db->qstr ( @$account_tax_id ); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('account_admin.inc.php','add', $db->ErrorMsg()); + + if(isset($this->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + return; + } + + /* password logging class */ + global $C_list; + if($C_list->is_installed('account_password_history')) { + include_once(PATH_MODULES.'account_password_history/account_password_history.inc.php'); + $accountHistory = new account_password_history(); + $accountHistory->setNewPassword($this->account_id, $VAR["account_admin_password"]); + } + + ### Add the account to the default group: + $this->add_account_groups($VAR['groups'], $this->account_id, $VAR['account_admin_date_expire']); + + ### Insert the static vars: + $static_var->add($VAR, 'account', $this->account_id); + + + ### Mail the new user + if(!empty($VAR['welcome_email'])) { + require_once(PATH_MODULES . 'email_template/email_template.inc.php'); + $my = new email_template; + if($status == "1") { + $my->send('account_add_staff_active', $this->account_id, '', '', $passwd); + } else { + $validation_str = strtoupper($validation_str. ':' .$this->account_id); + $my->send('account_add_staff_inactive', $this->account_id, $this->account_id, '', $validation_str); + } + } + + ### Do any db_mapping + if($C_list->is_installed('db_mapping')) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + if(!empty($passwd)) + $db_map->plaintext_password = $passwd; + else + $db_map->plaintext_password = false; + $db_map->account_add ( $this->account_id ); + } + + ### Display the welcome message + if($status == "1") + { + $C_debug->alert($C_translate->translate("staff_add_active","account_admin","")); + + } else { + $C_debug->alert($C_translate->translate("staff_add_inactive","account_admin","")); + } + + #$VAR["id"] = $this->account_id; + $url = '?_page=' . $VAR['_page'] . '&id=' . $this->account_id; + if(!empty($VAR['id'])) $url.= '&_escape=1'; + if(!empty($VAR['field'])) + { + $url .= '&field='.$VAR['field']; + $url .= '&name='.$VAR['account_admin_first_name'].' '.$VAR['account_admin_last_name']; + } + + define('REDIRECT_PAGE', $url); + + ### Affiliate Auto Creation + if(AUTO_AFFILIATE == 1 && $C_list->is_installed("affiliate")) + { + $VAR['affiliate_account_id'] = $this->account_id; + $VAR['affiliate_template_id'] = DEFAULT_AFFILIATE_TEMPLATE; + @$VAR['affiliate_parent_affiliate_id'] = $VAR['account_admin_affiliate_id']; + + include_once(PATH_MODULES . 'affiliate/affiliate.inc.php'); + $affiliate = new affiliate; + $affiliate->add($VAR, $affiliate); + } + + return; + } + + + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + if(!$this->checkLimits()) return false; // check account limits + + global $C_auth; + + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + + # set the field list for this method: + $db = &DB(); + $arr = $this->method[$type]; + if(isset($VAR["id"])) + { + $id = split(',',$VAR["id"]); + for($i=0; $iqstr($id[$i])." "; + $ii++; + } + else + { + $id_list .= " OR id = " .$db->qstr($id[$i]). " "; + $ii++; + } + } + } + } + + if($ii>0) + { + # generate the full query + $q = "SELECT * FROM + ".AGILE_DB_PREFIX."account + WHERE + $id_list + AND site_id = '" . DEFAULT_SITE . "'"; + + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('account_admin.inc.php','view', $db->ErrorMsg() . ' ' . $q); + return; + } + + # put the results into a smarty accessable array + $i=0; + $class_name = TRUE; + while (!$result->EOF) + { + $smart[$i] = $result->fields; + + if($class_name) + { + $smart[$i]["i"] = $i; + } else { + $smart[$i]["i"] = $i; + } + + ### Get any authorized groups: + $dba = &DB(); + $sql = 'SELECT service_id,group_id FROM ' . AGILE_DB_PREFIX . 'account_group WHERE + site_id = ' . $dba->qstr(DEFAULT_SITE) . ' AND + account_id = ' . $dba->qstr($result->fields['id']) . ' AND + active = ' . $dba->qstr("1") . ' + ORDER BY group_id'; + + $groups = $dba->Execute($sql); + + while (!$groups->EOF) + { + if($groups->fields['service_id'] == '') $group[] = $groups->fields['group_id']; + $groups->MoveNext(); + } + $smart[$i]["groups"] = $group; + + ### Verify the user has access to view this account: + if(SESS_ACCOUNT != $result->fields['id']) + { + $smart[$i]['own_account'] = false; + $display_this = true; + for($ix=0; $ixauth_group_by_id($group[$ix])) + $display_this = false; + } + } + else + { + $display_this = true; + $smart[$i]['own_account'] = true; + } + + + + + ### Get the static vars: + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + $arr = $static_var->update_form('account', 'update', $result->fields['id']); + if(gettype($arr) == 'array') + { + $smart[$i]["static_var"] = $arr; + } + + + ### Get the last activity date/IP + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."login_log + WHERE account_id = {$result->fields['id']} + AND site_id = ".DEFAULT_SITE." + ORDER BY date_orig DESC "; + $rslast = $db->SelectLimit($sql, 1); + if($rslast != false && $rslast->RecordCount() == 1) { + $smart[$i]["last_activity"] = $rslast->fields['date_orig']; + $smart[$i]["last_ip"] = $rslast->fields['ip']; + } else { + $smart[$i]["last_activity"] = $result->fields['date_orig']; + $smart[$i]["last_ip"] = ''; + } + + + ### Get invoice details for this account: + $sql = "SELECT id,date_orig,total_amt,billed_amt,process_status FROM ".AGILE_DB_PREFIX."invoice + WHERE account_id = {$result->fields['id']} + AND site_id = ".DEFAULT_SITE." + ORDER BY id DESC "; + $inv = $db->SelectLimit($sql, 10); + if($inv != false && $inv->RecordCount() > 0) { + while(!$inv->EOF) { + if($inv->fields['total_amt'] > $inv->fields['billed_amt'] && $inv->fields['suspend_billing'] != 1) { + $inv->fields['due'] = $inv->fields['total_amt'] - $inv->fields['billed_amt']; + } + $smart[$i]["invoice"][] = $inv->fields; + $inv->MoveNext(); + } + } + + + ### Get service details for this account: + $sql = "SELECT id,sku,active,type,domain_name,domain_tld FROM ".AGILE_DB_PREFIX."service + WHERE account_id = {$result->fields['id']} + AND site_id = ".DEFAULT_SITE." + ORDER BY id DESC "; + $svc = $db->SelectLimit($sql, 10); + if($svc != false && $svc->RecordCount() > 0) { + while(!$svc->EOF) { + $smart[$i]["service"][] = $svc->fields; + $svc->MoveNext(); + } + } + + + # define the results + if(!$display_this) + { + unset($smart["$i"]); + echo "You have selected an account for which you are not authorized, + your permission settings are to low!

"; + } + else + { + $i++; + } + unset($group); + $result->MoveNext(); + } + + # get the result count: + $results = $i; + + ### No results: + if($i == 0) + { + global $C_debug; + $C_debug->error("CORE:account_admin.inc.php", "view()", " + The selected record does not exist any longer, or your account is not authorized to view it"); + return; + } + + + global $smarty; + $smarty->assign($this->table, $smart); + $smarty->assign('results', $search->results); + } + } + + + + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + global $C_list, $C_debug; + + if(!$this->checkLimits()) return false; // check account limits + + // validate the tax_id + global $VAR; + require_once(PATH_MODULES.'tax/tax.inc.php'); + $taxObj=new tax; + $tax_arr = @$VAR['account_admin_tax_id']; + if(is_array($tax_arr)) { + foreach($tax_arr as $country_id => $tax_id) { + if ($country_id == $VAR['account_admin_country_id']) { + $exempt = @$VAR["account_tax_id_exempt"][$country_id]; + if(!$txRs=$taxObj->TaxIdsValidate($country_id, $tax_id, $exempt)) { + $this->validated = false; + global $C_translate; + $this->val_error[] = array( + 'field' => 'account_admin_tax_id', + 'field_trans' => $taxObj->errField, + 'error' => $C_translate->translate('validate_general', "", "")); + } + if($exempt) + $VAR['account_admin_tax_id']=false; + else + $VAR['account_admin_tax_id']=$tax_id; + } + } + } + + #################################################################### + ### Get required static_Vars and validate them... return an array + ### w/ ALL errors... + #################################################################### + + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + if(!isset($this->val_error)) $this->val_error = false; + $all_error = $static_var->validate_form('account', $this->val_error); + + if($all_error != false && gettype($all_error) == 'array') + $this->validated = false; + else + $this->validated = true; + + #################################################################### + # If validation was failed, skip the db insert & + # set the errors & origonal fields as Smarty objects, + # and change the page to be loaded. + #################################################################### + + if(!$this->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $all_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page_current']); + } + return; + } + + ### Get the old username ( for db mapping ) + $db = &DB(); + $sql = 'SELECT username FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($VAR['account_admin_id']); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + $old_username = $result->fields['username']; + } + + ### Update the password: + $update_password=false; + if(!empty($VAR['_password'])) { + $VAR['account_admin_password'] = $VAR['_password']; + + /* check if new password is ok */ + if($C_list->is_installed('account_password_history')) { + include_once(PATH_MODULES.'account_password_history/account_password_history.inc.php'); + $accountHistory = new account_password_history(); + if(!$accountHistory->getIsPasswordOk($VAR['account_admin_id'], $VAR['account_admin_password'], false)) { + $C_debug->alert("The password you have selected has been used recently and cannot be used again at this time for security purposes."); + unset($VAR['account_admin_password']); + } else { + $update_password=true; + } + } + } + + ### Update the record + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $ok = $db->update($VAR, $this, $type); + + if($ok) + { + /* password logging class */ + if($update_password && is_object($accountHistory)) $accountHistory->setNewPassword($VAR['account_admin_id'], $VAR["account_admin_password"], false); + + ### Update the static vars: + $static_var->update($VAR, 'account', $VAR['account_admin_id']); + + ### Do any db_mapping + if($C_list->is_installed('db_mapping')) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + + if(!empty($VAR['account_admin_password'])) + $db_map->plaintext_password = $VAR['account_admin_password']; + else + $db_map->plaintext_password = false; + + $db_map->account_edit ( $VAR['account_admin_id'], $old_username ); + } + + // remove login lock + if($VAR['account_admin_status']) { + $db=&DB(); + $delrs = $db->Execute($sql=sqlDelete($db,"login_lock","account_id={$VAR['account_admin_id']}")); + $delrs = $db->Execute($sql=sqlDelete($db,"login_log","account_id={$VAR['account_admin_id']} AND status=0")); + } + return true; + } + } + + + + ############################## + ## MERGE ## + ############################## + function merge($VAR) + { + $db = &DB(); + global $C_auth, $C_list, $C_translate, $C_debug; + + if(empty($VAR['id']) || empty($VAR['merge_acct_id'])) { + $C_debug->alert($C_translate->translate('merge_err','account_admin','')); + return false; + } + + $acct_id = $VAR['id']; + $merge_acct_id = $VAR['merge_acct_id']; + + # Get merged account_group + $q = "SELECT * FROM ".AGILE_DB_PREFIX."account_group WHERE ( + service_id = '' OR + service_id = 0 OR + service_id IS NULL + ) AND account_id = $acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) { + $C_debug->error('account_admin.inc.php','merge :: account_group', $db->ErrorMsg()); + } else { + while(!$rs->EOF) { + $Cauth = new CORE_auth(true); + if($Cauth->auth_group_by_account_id($merge_acct_id, $rs->fields['group_id'])) { + # duplicate group, delete + $q = "DELETE FROM ".AGILE_DB_PREFIX."account_group WHERE id = {$rs->fields['id']} AND site_id = ".DEFAULT_SITE; + $db->Execute($q); + } + $rs->MoveNext(); + } + } + + # account_group + $q = "UPDATE ".AGILE_DB_PREFIX."account_group SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: account_group', $db->ErrorMsg()); + + # account_billing + $q = "UPDATE ".AGILE_DB_PREFIX."account_billing SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: account_billing', $db->ErrorMsg()); + + # cart + $q = "UPDATE ".AGILE_DB_PREFIX."cart SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: cart', $db->ErrorMsg()); + + # charge + $q = "UPDATE ".AGILE_DB_PREFIX."charge SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: charge', $db->ErrorMsg()); + + # discount + $q = "UPDATE ".AGILE_DB_PREFIX."discount SET avail_account_id = $acct_id WHERE avail_account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: charge', $db->ErrorMsg()); + + # invoice + $q = "UPDATE ".AGILE_DB_PREFIX."invoice SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: invoice', $db->ErrorMsg()); + + # log_error + $q = "UPDATE ".AGILE_DB_PREFIX."log_error SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: log_error', $db->ErrorMsg()); + + # login_lock + $q = "DELETE FROM ".AGILE_DB_PREFIX."login_lock WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: login_lock', $db->ErrorMsg()); + + # login_log + $q = "UPDATE ".AGILE_DB_PREFIX."login_log SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: login_log', $db->ErrorMsg()); + + # search + $q = "UPDATE ".AGILE_DB_PREFIX."search SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: search', $db->ErrorMsg()); + + # service + $q = "UPDATE ".AGILE_DB_PREFIX."service SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: service', $db->ErrorMsg()); + + # session + $q = "DELETE FROM ".AGILE_DB_PREFIX."session WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: session', $db->ErrorMsg()); + + # staff + $q = "UPDATE ".AGILE_DB_PREFIX."staff SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: staff', $db->ErrorMsg()); + + # affiliate + if($C_list->is_installed('affiliate')) + { + $q = "UPDATE ".AGILE_DB_PREFIX."affiliate SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: affiliate', $db->ErrorMsg()); + } + + # ticket + if($C_list->is_installed('ticket')) + { + $q = "UPDATE ".AGILE_DB_PREFIX."ticket SET account_id = $acct_id WHERE account_id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: ticket', $db->ErrorMsg()); + } + + # DB Mapping + if($C_list->is_installed('db_mapping')) + { + $dbsql = "SELECT username FROM ".AGILE_DB_PREFIX."account WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($merge_acct_id); + $resultdb = $db->Execute($dbsql); + $old_username = $resultdb->fields['username']; + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + $db_map->account_delete ( $merge_acct_id, $old_username ); + } + + # Delete account + $q = "DELETE FROM ".AGILE_DB_PREFIX."account WHERE id = $merge_acct_id AND site_id = ".DEFAULT_SITE; + $rs = $db->Execute($q); + if ($rs === false) $C_debug->error('account_admin.inc.php','merge :: account', $db->ErrorMsg()); + + $C_debug->alert($C_translate->translate('merge_ok','account_admin','')); + return; + + } + + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = &DB(); + global $C_auth, $C_list; + + # set the id + $id = $this->table . '_id'; + + # generate the list of ID's + $id_list = ''; + $account_id_list = ''; + $discount_id_list = ''; + $ii=0; + + if(isset($VAR["delete_id"])) + { + $id = split(',',$VAR["delete_id"]); + } + elseif (isset($VAR["id"])) + { + $id = split(',',$VAR["id"]); + } + + for($i=0; $iExecute($sql); + while (!$groups->EOF) + { + $group[] = $groups->fields['group_id']; + $groups->MoveNext(); + } + + ### Verify the user has access to view this account: + $delete_this = true; + if(!empty($group) && is_array($group)) { + for($ix=0; $ixauth_group_by_id($group[$ix])) + { + $delete_this = false; + $ix = count($group); + } + } + } + unset($group); + + ### Verify this is not the admin account or the current user's account: + if(SESS_ACCOUNT == $id[$i] || $id[$i] == '1') + $delete_this = false; + + ### Generate the SQL + if($delete_this) + { + if($i == 0) { + $id_list .= " id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; + $account_id_list .= " account_id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; + $discount_id_list .= " account_id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; + $ii++; + } else { + $id_list .= " OR id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; + $account_id_list .= " OR account_id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; + $discount_id_list .= " OR account_id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; + $ii++; + } + + #################################################################### + ### Do any db_mapping + #################################################################### + + $dbsql = "SELECT username FROM ".AGILE_DB_PREFIX."account WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($id[$i]); + $resultdb = $db->Execute($dbsql); + $old_username = $resultdb->fields['username']; + + if($C_list->is_installed('db_mapping')) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + $db_map->account_delete ( $id[$i], $old_username ); + } + } + } + } + + $db = &DB(); + if($ii>0) + { + # generate the full query (account) + $q = "DELETE FROM ".AGILE_DB_PREFIX."account + WHERE $id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + + # generate the full query (sessions) + $q = "DELETE FROM ".AGILE_DB_PREFIX."session + WHERE $account_id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + + # generate the full query (account_billing) + $q = "DELETE FROM ".AGILE_DB_PREFIX."account_billing + WHERE $account_id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + + # generate the full query (account_group) + $q = "DELETE FROM ".AGILE_DB_PREFIX."account_group + WHERE $account_id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + + # generate the full query (cart) + $q = "DELETE FROM ".AGILE_DB_PREFIX."cart + WHERE $account_id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + + # generate the full query (search) + $q = "DELETE FROM ".AGILE_DB_PREFIX."search + WHERE $account_id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + + # generate the full query (staff) + $q = "DELETE FROM ".AGILE_DB_PREFIX."staff + WHERE $account_id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + + # generate the full query (ticket) + if($C_list->is_installed('ticket')) + { + $q = "SELECT id FROM ".AGILE_DB_PREFIX."ticket + WHERE $account_id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $ticket = $db->Execute($q); + if($ticket != false && $ticket->RecordCount() > 0) { + while( !$ticket->EOF ) { + include_once(PATH_MODULES.'ticket/ticket.inc.php'); + $tk = new ticket; + $arr['id'] = $ticket->fields['id']; + $tk->delete($arr, $tk); + $ticket->MoveNext(); + } + } + } + + # generate the full query (affiliate) + if($C_list->is_installed('affiliate')) + { + $q = "DELETE FROM ".AGILE_DB_PREFIX."affiliate + WHERE $account_id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + } + + # generate the full query (discount) + $q = "DELETE FROM ".AGILE_DB_PREFIX."discount + WHERE $discount_id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + + # generate the full query (invoice) + $q = "SELECT id FROM ".AGILE_DB_PREFIX."invoice + WHERE $account_id_list AND site_id = ".$db->qstr(DEFAULT_SITE); + $invoice = $db->Execute($q); + if($invoice != false && $invoice->RecordCount() > 0 ) { + while( !$invoice->EOF ) { + include_once(PATH_MODULES.'invoice/invoice.inc.php'); + $inv = new invoice; + $arr['id'] = $invoice->fields['id']; + $inv->delete($arr, $inv); + $invoice->MoveNext(); + } + } + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('account_admin.inc.php','delete', $db->ErrorMsg()); + + } + else + { + # Alert delete message + global $C_debug, $C_translate; + $C_translate->value["CORE"]["module_name"] = $C_translate->translate('name','account_admin',""); + $message = $C_translate->translate('alert_delete_ids',"CORE",""); + $C_debug->alert($message); + } + } + } + + + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + + + + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + + $db = &DB(); + + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + + # set the search criteria array + $arr = $VAR; + + # loop through the submitted field_names to get the WHERE statement + $where_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + if($value != '') + { + $pat = "^" . $this->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value = $validate->convert($field, $value, $this->field["$field"]["convert"]); + } + + $where_list .= " WHERE ".AGILE_DB_PREFIX."account.".$field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $this->module.'_'.$field; + $VAR['field_option']["$pat_field"]["$i_arr"]; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $this->field["$field"]["convert"]); + } + + + if($i_arr == 0) + { + $where_list .= " WHERE ".AGILE_DB_PREFIX."account.".$field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + else + { + $where_list .= " AND ".AGILE_DB_PREFIX."account.".$field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + } + else + { + $where_list .= " WHERE ".AGILE_DB_PREFIX."account.".$field . " = " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + else + { + if($value != '') + { + $pat = "^" . $this->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value = $validate->convert($field, $value, $this->field["$field"]["convert"]); + } + + $where_list .= " AND ".AGILE_DB_PREFIX."account.".$field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $this->module.'_'.$field; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $this->field["$field"]["convert"]); + } + + $where_list .= " AND ".AGILE_DB_PREFIX."account.". $field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + else + { + $where_list .= " AND ".AGILE_DB_PREFIX."account.". $field . " = ". $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + } + + #### finalize the WHERE statement + if($where_list == '') + { + $where_list .= ' WHERE '; + } + else + { + $where_list .= ' AND '; + } + + + # get limit type + if(isset($VAR['limit'])) + { + $limit = $VAR['limit']; + } + else + { + $limit = $this->limit; + } + + # get order by + if(isset($VAR['order_by'])) + { + $order_by = $VAR['order_by']; + } + else + { + $order_by = $this->order_by; + } + + $pre = AGILE_DB_PREFIX; + + $q = "SELECT DISTINCT ".AGILE_DB_PREFIX."account.id,".AGILE_DB_PREFIX."account.last_name,".AGILE_DB_PREFIX."account.first_name,".AGILE_DB_PREFIX."account.username FROM ".AGILE_DB_PREFIX."account "; + $q_save = "SELECT DISTINCT %%fieldList%% FROM ".AGILE_DB_PREFIX."account "; + + # Code for group searches: + if(!empty($VAR['account_group'])) + $q .= " LEFT JOIN ".AGILE_DB_PREFIX."account_group ON ".AGILE_DB_PREFIX."account_group.account_id = ".AGILE_DB_PREFIX."account.id"; + + + ######## GET ANY STATIC VARS TO SEARCH ########## + $join_list = ''; + if(!empty($VAR["static_relation"]) && count( $VAR["static_relation"] > 0 )) { + while(list($idx, $value) = each ($VAR["static_relation"])) { + if($value != "") { + + $join_list .= " INNER JOIN {$pre}static_var_record AS s{$idx} ON + ( + s{$idx}.record_id = {$pre}{$this->table}.id + AND + s{$idx}.static_var_relation_id = '{$idx}' + AND + s{$idx}.site_id = ".$db->qstr(DEFAULT_SITE)." + AND"; + if(ereg("%", $value)) + $join_list .= " s{$idx}.value LIKE ".$db->qstr($VAR["static_relation"]["$idx"]); + else + $join_list .= " s{$idx}.value = ".$db->qstr($VAR["static_relation"]["$idx"]); + $join_list .= " ) "; + } + } + } + ######## END STATIC VAR SEARCH ################## + + + # standard where list + $q .= $join_list . $where_list ." ".AGILE_DB_PREFIX."account.site_id = " . $db->qstr(DEFAULT_SITE); + + # Code for member group: + if(!empty($VAR['account_group'])) { + $q .= " AND ".AGILE_DB_PREFIX."account_group.group_id = " . $db->qstr($VAR['account_group'])." + AND ".AGILE_DB_PREFIX."account_group.site_id = " . $db->qstr(DEFAULT_SITE); + } + if(!empty($VAR['account_group'])) + { + $q_save .= " LEFT JOIN ".AGILE_DB_PREFIX."account_group ON ".AGILE_DB_PREFIX."account_group.account_id = ".AGILE_DB_PREFIX."account.id "; + + if(!empty($join_list)) + $q_save .= $join_list; + + $q_save .= $where_list ." %%whereList%% "; + $q_save .= AGILE_DB_PREFIX."account_group.group_id = " . $db->qstr($VAR['account_group'])." AND "; + } + else + { + if(!empty($join_list)) + $q_save .= $join_list; + + $q_save .= $where_list ." %%whereList%% "; + } + + ################## DEBUG ################## + #echo "
" . $q;
+		#echo "

" . $q_save; + #exit; + + # run the database query + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('database.inc.php','search', $db->ErrorMsg()); + return false; + } + + # get the result count: + $results = $result->RecordCount(); + + # get the first record id: + if($results == 1) $record_id = $result->fields['id']; + + # define the DB vars as a Smarty accessible block + global $smarty; + + # Create the definition for fast-forwarding to a single record: + if ($results == 1 && !isset($this->fast_forward)) + { + $smarty->assign('record_id', $record_id); + } + + # create the search record: + if($results > 0) + { + # create the search record + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $arr['module'] = $this->module; + $arr['sql'] = $q_save; + $arr['limit'] = $limit; + $arr['order_by']= $order_by; + $arr['results'] = $results; + $search->add($arr); + + # define the search id and other parameters for Smarty + $smarty->assign('search_id', $search->id); + + # page: + $smarty->assign('page', '1'); + + # limit: + $smarty->assign('limit', $limit); + + # order_by: + $smarty->assign('order_by', $order_by); + } + + # define the result count + $smarty->assign('results', $results); + } + + + + + + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + + # set the field list for this method: + $arr = $this->method[$type]; + + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $this->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . "account" . "." . $value; + + // determine if this record is linked to another table/field + if($this->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $this->field[$value]["asso_table"], 'link_field' => $this->field[$value]["asso_field"]); + } + } + else + { + $field_var = $this->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . "account" . "." . $value; + + // determine if this record is linked to another table/field + if($this->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $this->field[$value]["asso_table"], 'link_field' => $this->field[$value]["asso_field"]); + } + } + $i++; + } + + + # get the search details: + if(isset($VAR['search_id'])) { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } else { + # invalid search! + echo '
The search terms submitted were invalid!'; # translate... # alert + + if(isset($this->trigger["$type"])) { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . 'account.'.$VAR['order_by']; + $smarty_order = $VAR['order_by']; + } else { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . 'account.'.$this->order_by; + $smarty_order = $search->order_by; + } + + + # determine the sort order + if(isset($VAR['desc'])) { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } else if(isset($VAR['asc'])) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + if (!eregi('date',$smarty_order)) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } + } + + # generate the full query + + $db = &DB(); + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " ".AGILE_DB_PREFIX . "account."."site_id = " . $db->qstr(DEFAULT_SITE); + $q .= $order_by; + + ////////////////// + #echo "
 $q 

"; + $current_page=1; + $offset=-1; + if (!empty($VAR['page'])) $current_page = $VAR['page']; + if (empty($search->limit)) $search->limit=25; + if($current_page>1) $offset = (($current_page * $search->limit) - $search->limit); + $result = $db->SelectLimit($q, $search->limit, $offset); + + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('database.inc.php','search', $db->ErrorMsg()); + + if(isset($this->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + return; + } + + + # put the results into a smarty accessable array + $i=0; + $class_name = TRUE; + while (!$result->EOF) { + $smart[$i] = $result->fields; + + if($class_name) + { + $smart[$i]['_C'] = 'row1'; + $class_name = FALSE; + } else { + $smart[$i]['_C'] = 'row2'; + $class_name = TRUE; + } + $result->MoveNext(); + $i++; + } + + + # get any linked fields + if($i > 0) + { + $db_join = new CORE_database; + $this->result = $db_join->join_fields($smart, $this->linked); + } + else + { + $this->result = $smart; + } + + # get the result count: + $results = $result->RecordCount(); + + # define the DB vars as a Smarty accessible block + global $smarty; + + # define the results + $smarty->assign($this->table, $this->result); + $smarty->assign('page', $VAR['page']); + $smarty->assign('order', $smarty_order); + $smarty->assign('sort', $smarty_sort); + $smarty->assign('limit', $search->limit); + $smarty->assign('search_id',$search->id); + $smarty->assign('results', $search->results); + + # get the total pages for this search: + if(empty($search->limit)) + $this->pages = 1; + else + $this->pages = intval($search->results / $search->limit); + if ($search->results % $search->limit) $this->pages++; + + # total pages + $smarty->assign('pages', $this->pages); + + # current page + $smarty->assign('page', $current_page); + $page_arr = ''; + for($i=0; $i <= $this->pages; $i++) + { + if ($this->page != $i) $page_arr[] = $i; + } + + # page array for menu + $smarty->assign('page_arr', $page_arr); + } + + + + ############################## + ## SEARCH EXPORT ## + ############################## + function search_export($VAR) + { + if(!$this->checkLimits()) return false; // check account limits + + # require the export class + require_once (PATH_CORE . "export.inc.php"); + + # Call the correct export function for inline browser display, download, email, or web save. + if($VAR["format"] == "excel") + { + $type = "export_excel"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_excel($VAR, $this, $type); + } + + else if ($VAR["format"] == "pdf") + { + $type = "export_pdf"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_pdf($VAR, $this, $type); + } + + else if ($VAR["format"] == "xml") + { + $type = "export_xml"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_xml($VAR, $this, $type); + } + + else if ($VAR["format"] == "csv") + { + $type = "export_csv"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_csv($VAR, $this, $type); + } + + else if ($VAR["format"] == "tab") + { + $type = "export_tab"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_tab($VAR, $this, $type); + } + } + + + + + ############################## + ## ADD GROUPS ## + ############################## + + function add_account_groups($groups, $account, $expire) + { + global $C_auth; + $ii = 0; + + #loop through the array to add each account_group record + for($i=0; $iauth_group_by_id($groups[$i])) + { + + # add the account to the selected groups... + $dba = &DB(); + + # determine the record id: + $this->new_id = $dba->GenID(AGILE_DB_PREFIX . "" . 'account_group_id'); + + # generate the full query + $q = "INSERT INTO ".AGILE_DB_PREFIX."account_group + SET + id = ". $dba->qstr($this->new_id).", + date_orig = ". $dba->qstr(time()).", + date_expire = ". $dba->qstr($expire).", + group_id = ". $dba->qstr($groups[$i]).", + account_id = ". $dba->qstr($account).", + active = ". $dba->qstr('1').", + site_id = ". $dba->qstr(DEFAULT_SITE); + + # execute the query + $result = $dba->Execute($q); + $ii++; + + # error reporting: + if ($result === false) { + global $C_debug; + $C_debug->error('account_admin.inc.php','add_account_groups', $dba->ErrorMsg()); + } + } + } + + ### Add default group + if($ii == 0) + { + # add the account to the selected groups... + $dba = &DB(); + + # determine the record id: + $this->new_id = $dba->GenID(AGILE_DB_PREFIX . "" . 'account_group_id'); + + # generate the full query + $q = "INSERT INTO ".AGILE_DB_PREFIX."account_group + SET + id = ". $dba->qstr($this->new_id).", + date_orig = ". $dba->qstr(time()).", + date_expire = ". $dba->qstr($expire).", + group_id = ". $dba->qstr(DEFAULT_GROUP).", + account_id = ". $dba->qstr($account).", + active = ". $dba->qstr('1').", + site_id = ". $dba->qstr(DEFAULT_SITE); + + # execute the query + $result = $dba->Execute($q); + if ($result === false) { + global $C_debug; + $C_debug->error('account_admin.inc.php','add_account_groups', $dba->ErrorMsg()); + } + } + } + + + + + ############################## + ## UDPATE GROUPS ## + ############################## + + function update_account_groups($VAR) + { + global $C_auth; + $ii = 0; + @$groups = $VAR['groups']; + @$account = $VAR['account_admin_id']; + + # admin accounts groups cannot be altered + # user cannot modify their own groups + if($account == "1" || SESS_ACCOUNT == $account) + return false; + + ### Drop the current groups for this account: + # generate the full query + $dba = &DB(); + $q = "DELETE FROM ".AGILE_DB_PREFIX."account_group + WHERE + service_id IS NULL AND + account_id = ". $dba->qstr($account)." AND + site_id = ". $dba->qstr(DEFAULT_SITE); + # execute the query + $result = $dba->Execute($q); + + #loop through the array to add each account_group record + for($i=0; $iauth_group_by_id($groups[$i])) + { + # add the account to the selected groups... + $dba = &DB(); + + # determine the record id: + $this->new_id = $dba->GenID(AGILE_DB_PREFIX . "" . 'account_group_id'); + + # determine the expiration + if(!empty($VAR['account_admin_date_expire'])) + { + include_once(PATH_CORE.'validate.inc.php'); + $validate = new CORE_validate; + $expire = $validate->DateToEpoch(DEFAULT_DATE_FORMAT,$VAR['account_admin_date_expire']); + } else { + $expire = 0; + } + + # generate the full query + $q = "INSERT INTO ".AGILE_DB_PREFIX."account_group + SET + id = ". $dba->qstr($this->new_id).", + date_orig = ". $dba->qstr(time()).", + date_expire = ". $dba->qstr($expire).", + group_id = ". $dba->qstr($groups[$i]).", + account_id = ". $dba->qstr($account).", + active = ". $dba->qstr('1').", + site_id = ". $dba->qstr(DEFAULT_SITE); + + # execute the query + $result = $dba->Execute($q); + $ii++; + + # error reporting: + if ($result === false) { + global $C_debug; + $C_debug->error('account_admin.inc.php','update_account_groups', $dba->ErrorMsg()); + } + } + } + + ### Add default group + if($ii == 0) + { + # add the account to the selected groups... + $dba = &DB(); + + # determine the record id: + $this->new_id = $dba->GenID(AGILE_DB_PREFIX . "" . 'account_group_id'); + + # generate the full query + $q = "INSERT INTO ".AGILE_DB_PREFIX."account_group + SET + id = ". $dba->qstr($this->new_id).", + date_orig = ". $dba->qstr(time()).", + date_expire = ". $dba->qstr(@$expire).", + group_id = ". $dba->qstr(DEFAULT_GROUP).", + account_id = ". $dba->qstr($account).", + active = ". $dba->qstr('1').", + site_id = ". $dba->qstr(DEFAULT_SITE); + $result = $dba->Execute($q); + if ($result === false) { + global $C_debug; + $C_debug->error('account_admin.inc.php','update_account_groups', $dba->ErrorMsg()); + } + } + + ### Remove the user's session_auth_cache so it is regenerated on user's next pageview + $db = &DB(); + $q = "SELECT id FROM ".AGILE_DB_PREFIX."session WHERE + account_id = ".$db->qstr($account)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $rss = $db->Execute($q); + while(!$rss->EOF) + { + $q = "DELETE FROM ".AGILE_DB_PREFIX."session_auth_cache WHERE + session_id = ".$db->qstr($rss->fields['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + $rss->MoveNext(); + } + + ### Do any db_mapping + global $C_list; + if($C_list->is_installed('db_mapping')) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + $db_map->account_group_sync ( $account ); + } + } +} +?> \ No newline at end of file diff --git a/modules/account_admin/account_admin_construct.xml b/modules/account_admin/account_admin_construct.xml new file mode 100644 index 00000000..5f24d706 --- /dev/null +++ b/modules/account_admin/account_admin_construct.xml @@ -0,0 +1,180 @@ + + + + account_admin + + account
+ + account + + 0 + + last_name + + 30 + + + + I8 + 1 + + + I4 + + + I8 + date-time + + + I8 + date-now + + + I8 + date + + + I4 + + + C(32) + + + I4 + + + I4 + + + I4 + + + I4 + + + I4 + + + C(32) + + + C(128) + 4 + 128 + any + 1 + + + C(128) + 4 + 128 + password + md5 + + + L + + + C2(128) + + + I4 + 0 + + + C(128) + 1 + 128 + any + + + C(128) + + + C(128) + 1 + 128 + any + + + <type>C(128)</type> + + + C(255) + 4 + 128 + email + 1 + + + C(255) + + + C(128) + 3 + 128 + any + + + C(128) + 128 + + + C(32) + 2 + 32 + any + + + C(32) + 2 + 32 + any + + + C(16) + 4 + 16 + any + + + L + + + I4 + + + L + 1 + + + I4 + + + I4 + + + C(64) + + + I4 + + + + id + id,date_orig,date_last,date_expire,parent_id,language_id,country_id,affiliate_id,campaign_id,reseller_id,currency_id,theme_id,username,password,inherit_group,misc,status,first_name,middle_name,last_name,title,email,email_type,company,address1,address2,city,state,zip,invoice_delivery,invoice_show_itemized,invoice_grace,invoice_advance_gen,tax_id,max_child + id,date_orig,date_last,date_expire,parent_id,language_id,country_id,affiliate_id,campaign_id,reseller_id,currency_id,theme_id,username,password,inherit_group,misc,status,first_name,middle_name,last_name,title,email,email_type,company,address1,address2,city,state,zip,invoice_delivery,invoice_show_itemized,invoice_grace,invoice_advance_gen,tax_id,max_child + id,date_orig,date_last,date_expire,parent_id,language_id,country_id,affiliate_id,campaign_id,reseller_id,currency_id,theme_id,username,password,inherit_group,misc,status,first_name,middle_name,last_name,title,email,email_type,company,address1,address2,city,state,zip,invoice_delivery,invoice_show_itemized,invoice_grace,invoice_advance_gen,tax_id,max_child + id,date_orig,date_last,date_expire,parent_id,language_id,country_id,affiliate_id,campaign_id,reseller_id,currency_id,theme_id,username,password,misc,status,first_name,middle_name,last_name,title,email,email_type,company,address1,address2,city,state,zip,invoice_delivery,invoice_show_itemized,invoice_grace,invoice_advance_gen,tax_id,max_child + id,date_orig,date_last,date_expire,parent_id,language_id,country_id,affiliate_id,campaign_id,reseller_id,currency_id,theme_id,username,password,inherit_group,misc,status,first_name,middle_name,last_name,title,email,email_type,company,address1,address2,city,state,zip,tax_id,max_child + language_id,country_id,affiliate_id,campaign_id,currency_id,username,password,misc,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,tax_id + language_id,country_id,affiliate_id,campaign_id,currency_id,username,password,misc,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,tax_id + language_id,country_id,affiliate_id,campaign_id,currency_id,username,password,misc,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,tax_id + language_id,country_id,affiliate_id,campaign_id,currency_id,username,password,misc,status,first_name,middle_name,last_name,title,email,company,address1,address2,city,state,zip,tax_id + + + + account_admin:update_account_groups + + +
diff --git a/modules/account_admin/account_admin_install.xml b/modules/account_admin/account_admin_install.xml new file mode 100644 index 00000000..1db56c72 --- /dev/null +++ b/modules/account_admin/account_admin_install.xml @@ -0,0 +1,77 @@ + + + account_admin + account_admin + + 1 + + + + + add + 1 + + + update + + + delete + + + view + + 1 + + + search + + 1 + + + search_form + + + search_show + + + search_export + + + update_account_groups + + + + send_verify_email + + + + send_password_email + + + + mail_multi + + + mail_one + + + autoselect + + + login + + + + merge + + + + group_search + + + product_search + + + + + \ No newline at end of file diff --git a/modules/account_billing/account_billing.inc.php b/modules/account_billing/account_billing.inc.php new file mode 100644 index 00000000..51f0448b --- /dev/null +++ b/modules/account_billing/account_billing.inc.php @@ -0,0 +1,411 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class account_billing +{ + /** + * Return a list of options for the drop-down menus + */ + function cardMenuArr(&$result, $selected=false) { + global $C_translate; + if($result && $result->RecordCount()) { + while (!$result->EOF) { + $arr["{$result->fields["id"]}"] = $C_translate->translate('card_type_'.$result->fields["card_type"],'checkout','') . + ' ...' . $result->fields["card_num4"]; + if($result->fields['card_type'] != 'eft') + $arr["{$result->fields["id"]}"] .= ' | Exp: ' . $result->fields["card_exp_month"] . '/' . $result->fields["card_exp_year"]; + $result->MoveNext(); + } + return $arr; + } + return false; + } + + /** + * Get a list of cards of file for a specific user and checkout plugin + */ + function list_on_file($VAR) { + global $C_auth; + if(!empty($VAR['account_id']) && $C_auth->auth_method_by_name('checkout','admin_checkoutnow')) $account_id=$VAR['account_id']; else $account_id=SESS_ACCOUNT; + if(empty($VAR['option'])) return false; else $checkout_plugin_id=$VAR['option']; + $db=&DB(); + $year = ereg_replace("^20", "", date("Y")); + $result = $db->Execute($sql=sqlSelect($db,"account_billing","id,card_type,card_num4,card_exp_month,card_exp_year", + "(card_exp_year>=::$year:: or card_type='eft') AND account_id=::$account_id:: AND checkout_plugin_id=::$checkout_plugin_id::")); + $arr = $this->cardMenuArr($result); + if($arr) { + global $smarty; + $smarty->assign('onfile', $arr); + } + } + + /** + * Generate an admin menu of the list of cards on file... + */ + function menu_admin($field, $account, $default, $class, $user) { + global $C_translate; + if(empty($field)) $field = 'ccnum'; + $input_id = '1'; + $return = ''; + if(!$user) { + $return .= ' '; + $return .= ' '; + } else { + $return .= ' '; + } + } else { + $return .= ''; + $return .= ''; + } + echo $return; + } + + /** + * Allow user to delete a card on file + */ + function user_delete($VAR) + { + # Verify the current account owns this billing record + $dbx = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'account_billing WHERE + id = ' . $dbx->qstr( @$VAR['id'] ) . ' AND + account_id = ' . $dbx->qstr( SESS_ACCOUNT ) . ' AND + site_id = ' . $dbx->qstr(DEFAULT_SITE); + $rs = $dbx->Execute($sql); + if (@$rs->RecordCount() == 0) return false; + + global $C_debug, $C_translate; + + # Validate this isn't the only card on file + $rs = $dbx->Execute(sqlSelect($dbx,"account_billing","id","id=::".$VAR['id']."::")); + if($rs && $rs->RecordCount()) { + $msg = $C_translate->translate('card_in_use','account_billing',''); + $C_debug->alert($msg); + return false; + } + + # Validate the card isn't in use + $rs = $dbx->Execute(sqlSelect($dbx,"service","id","account_billing_id=::".$VAR['id'].":: AND account_id=::".SESS_ACCOUNT.":: AND active=1")); + if($rs && $rs->RecordCount()) { + $msg = $C_translate->translate('card_in_use','account_billing',''); + $C_debug->alert($msg); + return false; + } + + # Delete the card + $sql = sqlDelete($dbx,"account_billing","id=::".$VAR['id'].":: AND account_id=::".SESS_ACCOUNT."::"); + $dbx->Execute($sql); + $msg = $C_translate->translate('card_removed','account_billing',''); + $C_debug->alert($msg); + + return true; + } + + /** + * Task to detect credit cards that are expiring soon and e-mail the user a notice to update the card + */ + function task($VAR) { + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + $sql =''; + + for($i=1; $i<3; $i++) { + $exp = mktime(0,0,0,date('m')+$i,date('d'),date('Y')); + $month = date("m",$exp); + $year = ereg_replace("^20", "", date("Y",$exp)); + if(!empty($sql)) $sql .= " OR "; + $sql .= " ( card_exp_month = '$month' AND card_exp_year = '$year' ) "; + } + + $db = &DB(); + $rs = $db->Execute($qq=sqlSelect($db,"account_billing", "id,account_id,notify_count", " ( $sql ) AND notify_count < 4")); + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + $email = new email_template; + $email->send('account_billing_exp_soon', $rs->fields['account_id'], $rs->fields['id'],'',''); + $fields=Array('notify_count'=> $rs->fields["notify_count"]+1); + $db->Execute(sqlUpdate($db,"account_billing", $fields, "id = {$rs->fields['id']}")); + $rs->MoveNext(); + } + } + } + + + /** Get most recent account billing id */ + function default_billing($account_id) + { + $db = &DB(); + $sql = "SELECT id,checkout_plugin_id FROM ".AGILE_DB_PREFIX."account_billing WHERE + account_id = " . $db->qstr($account_id) . " AND + site_id = " . $db->qstr(DEFAULT_SITE); + $billing = $db->Execute($sql); + if($billing->RecordCount() > 0) + { + $ret['billing_id'] = $billing->fields['id']; + $ret['checkout_plugin_id'] = $billing->fields['checkout_plugin_id']; + } else { + $ret['billing_id'] = false; + $ret['checkout_plugin_id'] = false; + } + return $ret; + } + + + function add($VAR) + { + global $C_debug, $C_translate; + + # Get the last 4 digits of the cc: + @$VAR['account_billing_card_num4'] = substr($VAR['account_billing_card_num'],(strlen($VAR['account_billing_card_num']) - 4),4); + + # Validate the req fields + if(empty($VAR['account_billing_card_exp_month']) || empty($VAR['account_billing_card_exp_year']) || empty($VAR['account_billing_card_num'])) + { + $msg = $C_translate->translate('val_missing','account_billing',''); + $C_debug->alert($msg); + return false; + } + + # Validate the exp date + if(mktime(0,0,0,$VAR['account_billing_card_exp_month'], date('d'), $VAR['account_billing_card_exp_year']) <= time()) + { + $msg = $C_translate->translate('val_exp','account_billing',''); + $C_debug->alert($msg); + return false; + } + + # Validate the card against the card type + include_once(PATH_CORE.'validate.inc.php'); + $validate = new CORE_validate; + if(!$validate->validate_cc( $VAR['account_billing_card_num'], 'card_num', $VAR['account_billing_card_type'], false ) ) + { + $msg = $C_translate->translate('val_cc','account_billing',''); + $C_debug->alert($msg); + return false; + } + + $this->construct(); + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + function view($VAR) + { + global $C_debug, $C_translate; + $this->construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + function update($VAR) + { + global $C_translate,$C_debug; + + /* load database object */ + $db = new CORE_database; + $this->construct(); + $type = "update"; + + /* conditional fields for cc/eft */ + $dbx=&DB(); + $rs = $dbx->Execute(sqlSelect($dbx,"account_billing","card_type,id,checkout_plugin_id","id=::{$VAR['id']}::")); + if(!$rs || !$rs->RecordCount()) return false; + + $billing_id = $rs->fields['id']; + $checkout_plugin_id = $rs->fields['checkout_plugin_id']; + + if($rs->fields['card_type'] == 'eft') { + /* EFT */ + $this->method["$type"] = $db->ignore_fields( + array('card_exp_month', 'card_exp_year', 'card_num' ), + $this->method["$type"] + ); + + /* last four */ + @$VAR['account_billing_card_num4'] = substr($VAR['account_billing_eft_check_acct'],(strlen($VAR['account_billing_eft_check_acct']) - 4),4); + + } else { + /* CC */ + + # Validate the exp date + if(mktime(0,0,0,$VAR['account_billing_card_exp_month'], date('d'), $VAR['account_billing_card_exp_year']) <= time()) + { + $msg = $C_translate->translate('val_exp','account_billing',''); + $C_debug->alert($msg); + return false; + } + + # Validate the card against the card type + include_once(PATH_CORE.'validate.inc.php'); + $validate = new CORE_validate; + if(!$validate->validate_cc( @$VAR['account_billing_card_num'], 'card_num', @$VAR['account_billing_card_type'], false ) ) + { + $msg = $C_translate->translate('val_cc','account_billing',''); + $C_debug->alert($msg); + return false; + } + + $this->method["$type"] = $db->ignore_fields( + array('eft_trn', 'eft_check_acct'), + $this->method["$type"] + ); + + /* last four */ + @$VAR['account_billing_card_num4'] = substr($VAR['account_billing_card_num'],(strlen($VAR['account_billing_card_num']) - 4),4); + } + + if( $db->update($VAR, $this, $type) ) + { + # Update any invoices using this billing record + $dba = &DB(); + $sql = "UPDATE ".AGILE_DB_PREFIX."invoice SET + checkout_plugin_id = " . $dba->qstr($checkout_plugin_id) . " + WHERE site_id = " . $dba->qstr(DEFAULT_SITE) . " + AND account_billing_id = " . $dba->qstr($billing_id); + $result = $dba->Execute($sql); + return true; + } + return false; + } + + function delete($VAR) { + $this->construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + function search_form($VAR) { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + function search($VAR) { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + function user_search($VAR) { + # Lock the user only for his billing_records: + if(!SESS_LOGGED) return false; + + # Lock the account_id + $VAR['account_billing_account_id'] = SESS_ACCOUNT; + + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + function search_show($VAR) { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + function user_search_show($VAR) { + # Lock the user only for his billing_records: + if(!SESS_LOGGED) return false; + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + function user_view($VAR) { + # Check that the correct account owns this billing record + $dbx = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'account_billing WHERE + id = ' . $dbx->qstr( @$VAR['id'] ) . ' AND + account_id = ' . $dbx->qstr( SESS_ACCOUNT ) . ' AND + site_id = ' . $dbx->qstr(DEFAULT_SITE); + $rs = $dbx->Execute($sql); + if (@$rs->RecordCount() == 0) return false; + + $this->construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + function user_update($VAR) { + if(!SESS_LOGGED) return false; + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"account_billing","card_type","id=::{$VAR['id']}:: and account_id=".SESS_ACCOUNT)); + if(!$rs || !$rs->RecordCount()) return false; + $result=$this->update($VAR, $this); + global $VAR; $VAR['_page'] = 'account_billing:user_view'; + if($result) { + global $C_debug; + $C_debug->alert("Your billing details have been updated."); + } + } + + + # Open the constructor for this mod + function construct() + { + # name of this module: + $this->module = "account_billing"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } +} +?> \ No newline at end of file diff --git a/modules/account_billing/account_billing_construct.xml b/modules/account_billing/account_billing_construct.xml new file mode 100644 index 00000000..2aea4e0e --- /dev/null +++ b/modules/account_billing/account_billing_construct.xml @@ -0,0 +1,158 @@ + + + account_billing + account_billing
+ + 0 + account_id + 25 + + site_id,account_id + site_id,checkout_plugin_id + site_id,card_type + site_id,eft_check_acct_type + + + + I4 + 1 + + + I4 + + + I8 + account + username + + + C(32) + checkout + name + + + X + array + + + C(32) + + + C(128) + + + I4 + + + C(16) + + + X + encrypt + any + + + C(16) + + + C(16) + numeric + 2 + 2 + + + C(16) + numeric + 2 + 2 + + + C(16) + + + C(16) + + + C(16) + + + C(255) + encrypt + numeric + 6 + 16 + + + C(255) + encrypt + numeric + 6 + 16 + + + I8 + + + C(16) + any + + + C(16) + any + + + C(32) + any + + + C(32) + 3 + + + C(16) + any + + + C(16) + any + + + C(16) + any + + + C(16) + any + + + C(16) + + + C(128) + + + C(32) + + + C(255) + encrypt + + + C(255) + encrypt + + + C(255) + encrypt + + + + id,site_id,account_id,checkout_plugin_id,plugin_data,name,notes,card_type,card_num,card_exp_month,card_exp_year,card_start_month,card_start_year,card_num4,eft_trn,eft_check_acct,eft_check_acct_type,eft_check_checkno,first_name,last_name,address1,address2,city,state,zip,country_id,phone,email,company,ssn,dl_no,dob,eft_trn,eft_check_acct + id,site_id,account_id,checkout_plugin_id,plugin_data,name,notes,card_type,card_num,card_exp_month,card_exp_year,card_start_month,card_start_year,card_num4,eft_trn,eft_check_acct,eft_check_acct_type,eft_check_checkno,first_name,last_name,address1,address2,city,state,zip,country_id,phone,email,company,ssn,dl_no,dob,eft_trn,eft_check_acct + id + id,site_id,account_id,checkout_plugin_id,plugin_data,name,notes,card_type,card_num,card_exp_month,card_exp_year,card_start_month,card_start_year,card_num4,eft_trn,eft_check_acct,eft_check_acct_type,eft_check_checkno,first_name,last_name,address1,address2,city,state,zip,country_id,phone,email,company,ssn,dl_no,dob,eft_trn,eft_check_acct + id,site_id,account_id,checkout_plugin_id,plugin_data,name,notes,card_type,card_num,card_exp_month,card_exp_year,card_start_month,card_start_year,card_num4,eft_trn,eft_check_acct,eft_check_acct_type,eft_check_checkno,first_name,last_name,address1,address2,city,state,zip,country_id,phone,email,company,ssn,dl_no,dob,eft_trn,eft_check_acct + id,site_id,account_id,checkout_plugin_id,plugin_data,name,notes,card_type,card_num,card_exp_month,card_exp_year,card_start_month,card_start_year,card_num4,eft_trn,eft_check_acct,eft_check_acct_type,eft_check_checkno,first_name,last_name,address1,address2,city,state,zip,country_id,phone,email,company,ssn,dl_no,dob,eft_trn,eft_check_acct + + 0 +
diff --git a/modules/account_billing/account_billing_install.xml b/modules/account_billing/account_billing_install.xml new file mode 100644 index 00000000..31cf3b62 --- /dev/null +++ b/modules/account_billing/account_billing_install.xml @@ -0,0 +1,34 @@ + + + account_billing + account_admin + + + + + + add + + + update + + + delete + + + view + + + search + + + search_form + + + + search_show + + + + + \ No newline at end of file diff --git a/modules/account_billing/auth.inc.php b/modules/account_billing/auth.inc.php new file mode 100644 index 00000000..191d9ecf --- /dev/null +++ b/modules/account_billing/auth.inc.php @@ -0,0 +1,30 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +$auth_methods = Array +( + Array ('module' => 'account_billing', 'method' => 'user_search'), + Array ('module' => 'account_billing', 'method' => 'user_view'), + Array ('module' => 'account_billing', 'method' => 'user_search_show'), + Array ('module' => 'account_billing', 'method' => 'user_update'), + Array ('module' => 'account_billing', 'method' => 'user_delete'), + Array ('module' => 'account_billing', 'method' => 'list_on_file') +); +?> \ No newline at end of file diff --git a/modules/account_group/account_group_construct.xml b/modules/account_group/account_group_construct.xml new file mode 100644 index 00000000..e01fc7e9 --- /dev/null +++ b/modules/account_group/account_group_construct.xml @@ -0,0 +1,55 @@ + + + account_group + account_group
+ account + 0 + + 25 + + date_start,date_expire + active,account_id,group_id + service_id + + + + I8 + + + I4 + 1 + + + I8 + + + I8 + + + I8 + + + I4 + 1 + + + I8 + 1 + + + I8 + + + L + + + + id,site_id,module_id,name,notes,page,menu_display + id,site_id,module_id,name,notes,page,menu_display + id,site_id,module_id,name,notes,page,menu_display + id,site_id,module_id,name,notes,page,menu_display + id,site_id,module_id,name,notes,page,menu_display + id,site_id,module_id,name,notes,page,menu_display + + 0 +
diff --git a/modules/account_group/account_group_install.xml b/modules/account_group/account_group_install.xml new file mode 100644 index 00000000..e73f15d3 --- /dev/null +++ b/modules/account_group/account_group_install.xml @@ -0,0 +1,11 @@ + + + account_group + account_admin + + + + + + + \ No newline at end of file diff --git a/modules/account_group/account_group_install_data.xml b/modules/account_group/account_group_install_data.xml new file mode 100644 index 00000000..05798359 --- /dev/null +++ b/modules/account_group/account_group_install_data.xml @@ -0,0 +1,44 @@ + + + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + + + 210 + 1 + 1099624291 + 0 + 2 + 1 + 1 + + + 211 + 1 + 1099624291 + 0 + 1001 + 1 + 1 + + + 212 + 1 + 1099624291 + 0 + 4 + 1 + 1 + + + 502 + + \ No newline at end of file diff --git a/modules/account_memo/account_memo.inc.php b/modules/account_memo/account_memo.inc.php new file mode 100644 index 00000000..ab140298 --- /dev/null +++ b/modules/account_memo/account_memo.inc.php @@ -0,0 +1,125 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class account_memo +{ + + # Open the constructor for this mod + function account_memo() + { + # name of this module: + $this->module = "account_memo"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> diff --git a/modules/account_memo/account_memo_construct.xml b/modules/account_memo/account_memo_construct.xml new file mode 100644 index 00000000..eebd7367 --- /dev/null +++ b/modules/account_memo/account_memo_construct.xml @@ -0,0 +1,63 @@ + + + + account_memo + + account_memo
+ + account + + 0 + + date_orig + + 25 + + + account_id + memo + + + + + I8 + + + I4 + + + I8 + date-time + date-now + + + I8 + account + username + + + I8 + + + C(32) + any + + + C(255) + any + + + C(32) + + + + + id,site_id,date_orig,staff_id,account_id,type,memo + id,site_id,date_orig,staff_id,account_id,type,memo + id,site_id,date_orig,staff_id,account_id,type,memo + id,site_id,date_orig,staff_id,account_id,type,memo + id,site_id,date_orig,staff_id,account_id,type,memo + + + 0 +
diff --git a/modules/account_memo/account_memo_install.xml b/modules/account_memo/account_memo_install.xml new file mode 100644 index 00000000..c8469597 --- /dev/null +++ b/modules/account_memo/account_memo_install.xml @@ -0,0 +1,33 @@ + + + account_memo + account_admin + + invoice + + + + + add + + + update + + + delete + + + view + + + search + + + search_form + + + search_show + + + + diff --git a/modules/account_message/account_message.inc.php b/modules/account_message/account_message.inc.php new file mode 100644 index 00000000..7ec1bd94 --- /dev/null +++ b/modules/account_message/account_message.inc.php @@ -0,0 +1,54 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** + +Sample use in tpl: + +{if $list->is_installed('account_message')} +{$method->exe_noauth('account_message','view')} +

System message on {$date}

+

{$message|nl2br}

+{/if} + +*/ +class account_message +{ + /** update system message */ + function add($VAR) { + @$m=$VAR['message']; + $db=&DB(); + $fields=Array('date_orig'=>time(), 'message'=>$m); + $db->Execute(sqlUpdate($db,"account_message",$fields,"id = 1")); + } + + /** view system message */ + function view($VAR) { + if(!SESS_LOGGED) return false; + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"account_message","date_orig,message","id=1")); + if($rs && $rs->RecordCount()) { + global $smarty; + $smarty->assign('message', $rs->fields['message']); + $smarty->assign('date', date("m-d-Y", $rs->fields['date_orig'])); + } + } +} +?> \ No newline at end of file diff --git a/modules/account_message/account_message_construct.xml b/modules/account_message/account_message_construct.xml new file mode 100644 index 00000000..485f9d2e --- /dev/null +++ b/modules/account_message/account_message_construct.xml @@ -0,0 +1,35 @@ + + + account_message + account_message
+ + 0 + date_orig + 30 + + + I8 + 1 + + + I4 + + + I8 + + + I8 + + + X2 + + + + + id,date_orig,account_id,message + id,date_orig,account_id,message + id,date_orig,account_id,message + + + +
diff --git a/modules/account_message/account_message_install.xml b/modules/account_message/account_message_install.xml new file mode 100644 index 00000000..23ae6325 --- /dev/null +++ b/modules/account_message/account_message_install.xml @@ -0,0 +1,17 @@ + + + account_message + account + + + + + + add + + + view + + + + \ No newline at end of file diff --git a/modules/account_message/account_message_install_data.xml b/modules/account_message/account_message_install_data.xml new file mode 100644 index 00000000..caab92ed --- /dev/null +++ b/modules/account_message/account_message_install_data.xml @@ -0,0 +1,13 @@ + + + + 1 + 1 + 1075175744 + 0 + Default system message... + + + 2 + + \ No newline at end of file diff --git a/modules/account_message/auth.inc.php b/modules/account_message/auth.inc.php new file mode 100644 index 00000000..fe4425a0 --- /dev/null +++ b/modules/account_message/auth.inc.php @@ -0,0 +1,25 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +$auth_methods = Array +( + Array ('module' => 'account_message', 'method' => 'view') +); +?> \ No newline at end of file diff --git a/modules/account_password_history/account_password_history.inc.php b/modules/account_password_history/account_password_history.inc.php new file mode 100644 index 00000000..81638de4 --- /dev/null +++ b/modules/account_password_history/account_password_history.inc.php @@ -0,0 +1,104 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/* strict password changing enforcement */ +class account_password_history +{ + var $duplicateAfter=720; /* number of days between time identical password can be used */ + var $forceChangeAfter=60; /* number of days between forced password change */ + + /* determine if forced change is due for specified account */ + function getForceChangeDue($account_id) { + $db=&DB(); + + + /* not updated in last X days? */ + $date = (time() - (86400*$this->forceChangeAfter)); + $rs = $db->Execute(sqlSelect($db,"account_password_history","id", "account_id=$account_id and date_orig <= $date and date_last = 0")); + if($rs && $rs->RecordCount()) return true; + + return false; + } + + /* determine if new password is permissible */ + function getIsPasswordOk($account_id, $password, $hashed=true) { + + if(!$hashed) $this->hashPassword($password); + + $db=&DB(); + + /* currently used or used in duplicatePeriod? */ + $date = (time() - (86400*$this->duplicateAfter)); + $rs = $db->Execute(sqlSelect($db,"account_password_history","id", + "account_id=$account_id and password=::$password:: and (date_last=0 OR (date_last > $date OR date_orig > $date))")); + if($rs && $rs->RecordCount()) return false; + + return true; + } + + /* log the password change */ + function setNewPassword($account_id, $password, $hashed=true) { + $db=&DB(); + + if(!$hashed) $this->hashPassword($password); + + /* update last_date in existing passwords to indicate they are no longer in use */ + $fields['date_last'] = time(); + $db->Execute($sql="update ".AGILE_DB_PREFIX."account_password_history set date_last = ". time() . " where account_id = $account_id"); + + /* insert new password */ + $fields=Array('date_orig'=>time(), 'date_last'=>0, 'account_id'=>$account_id, 'password' => $password, 'ip' => USER_IP ); + $db->Execute(sqlInsert($db, "account_password_history", $fields)); + } + + + /* hash the password */ + function hashPassword(&$password) { + if(defined('PASSWORD_ENCODING_SHA')) + $password = sha1($password); + else + $password = md5($password); + } + + /* insert temp data for password reset */ + function resetPassword($account) { + + /* Delete the old request */ + $db=&DB(); + $sql = 'DELETE FROM ' . AGILE_DB_PREFIX . 'temporary_data WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND field1 = ' . $db->qstr($account); + $db->Execute($sql); + + $now = md5(microtime()); + $expire = time() + (20*60); + + /* Create the temporary DB Record */ + $id = $db->GenID(AGILE_DB_PREFIX . 'temporary_data_id'); + $sql = 'INSERT INTO ' . AGILE_DB_PREFIX . 'temporary_data SET + site_id = ' . $db->qstr(DEFAULT_SITE) . ', + id = ' . $db->qstr($id) . ', + date_orig = ' . $db->qstr(time()) . ', + date_expire = ' . $db->qstr($expire) . ', + field1 = ' . $db->qstr($account) . ', + field2 = ' . $db->qstr($now); + $result = $db->Execute($sql); + return $now; + } +} +?> \ No newline at end of file diff --git a/modules/account_password_history/account_password_history_construct.xml b/modules/account_password_history/account_password_history_construct.xml new file mode 100644 index 00000000..e2b0a015 --- /dev/null +++ b/modules/account_password_history/account_password_history_construct.xml @@ -0,0 +1,37 @@ + + + account_password_history + account_password_history
+ account + 0 + date_orig + 25 + + site_id,account_id + + + + I8 + + + I4 + + + I8 + + + I8 + + + I8 + + + C(32) + + + C(16) + + + 0 + 0 +
diff --git a/modules/account_password_history/account_password_history_install.xml b/modules/account_password_history/account_password_history_install.xml new file mode 100644 index 00000000..f828af0a --- /dev/null +++ b/modules/account_password_history/account_password_history_install.xml @@ -0,0 +1,12 @@ + + + account_password_history + account_admin + + account + + + + + + \ No newline at end of file diff --git a/modules/affiliate/affiliate.inc.php b/modules/affiliate/affiliate.inc.php new file mode 100644 index 00000000..c07f831b --- /dev/null +++ b/modules/affiliate/affiliate.inc.php @@ -0,0 +1,1806 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class affiliate +{ + # Open the constructor for this mod + function affiliate() + { + # name of affiliate id prefix + $this->id_prefix = 'AB-'; + + # name of this module: + $this->module = "affiliate"; + + if(!defined('AJAX')) + { + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + } + + + ########################################### + ### AJAX Auto-selector + ########################################### + + function autoselect($VAR) + { + + $db = &DB(); + $p = AGILE_DB_PREFIX; + + if (empty($VAR['affiliate_search'])) { + $where = "{$p}affiliate.id > 0"; + $type = 1; + } elseif (is_numeric($VAR['affiliate_search'])) { + $where = "{$p}affiliate.id LIKE ".$db->qstr($VAR['search']."%") ; + $type = 1; + } elseif (eregi(" ", $VAR['affiliate_search'])) { + $arr = split(" ", $VAR['affiliate_search']); + $where = "{$p}account.first_name = ".$db->qstr($arr[0])." AND ". + "{$p}account.last_name LIKE ".$db->qstr($arr[1].'%') ; + $type = 2; + } elseif (eregi("@", $VAR['affiliate_search'])) { + $where = "{$p}account.email LIKE ".$db->qstr('%'.$VAR['affiliate_search'].'%') ; + $type = 3; + } else { + $where = "{$p}account.username LIKE ".$db->qstr($VAR['affiliate_search'].'%')." OR ". + "{$p}account.first_name LIKE ".$db->qstr($VAR['affiliate_search'].'%')." OR ". + "{$p}account.last_name LIKE ".$db->qstr($VAR['affiliate_search'].'%'); + $type = 4; + } + + $q = "SELECT DISTINCT + {$p}affiliate.id, + {$p}account.first_name, + {$p}account.last_name, + {$p}account.username, + {$p}account.email + FROM + {$p}account + LEFT JOIN + {$p}affiliate + ON + {$p}account.id = {$p}affiliate.account_id + WHERE + ( $where ) + AND + {$p}affiliate.id IS NOT NULL AND + {$p}affiliate.site_id = " . DEFAULT_SITE . " AND + {$p}account.site_id = " . DEFAULT_SITE." + ORDER BY {$p}account.first_name,{$p}account.last_name"; + $result = $db->SelectLimit($q, 10); + + echo '
    '; + # Create the alert for no records found + if ($result->RecordCount() > 0) { + $i=0; + while(!$result->EOF) + { + echo '
  • ' . $result->fields['first_name'].' '.$result->fields['last_name'] . '
    '. + ''. + '
  • ' . "\r\n"; + $result->MoveNext(); + $i++; + } + } + echo "
"; + return; + } + + + + ########################################### + ### Top Sales Affiliates Graph: + ########################################### + function top($VAR) + { + global $smarty, $C_translate, $C_auth; + + # Get the period type, default to month + if (empty($VAR['period'])) + $p = 'm'; + else + $p = $VAR['period']; + + # Load the jpgraph class + include (PATH_GRAPH."jpgraph.php"); + include (PATH_GRAPH."jpgraph_bar.php"); + + # check the validation for this function + if(!$C_auth->auth_method_by_name('affiliate','search')) { + $error = $C_translate->translate('module_non_auth','',''); + include (PATH_GRAPH."jpgraph_canvas.php"); + $graph = new CanvasGraph(460,55,"auto"); + $t1 = new Text($error); + $t1->Pos(0.2,0.5); + $t1->SetOrientation("h"); + $t1->SetBox("white","black",'gray'); + $t1->SetFont(FF_FONT1,FS_NORMAL); + $t1->SetColor("black"); + $graph->AddText($t1); + $graph->Stroke(); + exit; + } + + # Get the period start & end + switch ($p) + { + # By Weeks: + case 'w': + $dow = date('w'); + $start_str = mktime(0,0,0,date('m'), date('d')-$dow, date('y')); + $end_str = mktime(23,59,59,date('m'), date('d'), date('y')); + break; + + # By Months: + case 'm': + $start_str = mktime(0,0,0,date('m'), 1, date('y')); + $end_str = mktime(23,59,59,date('m'), date('d'), date('y')); + break; + + # By Years: + case 'y': + $start_str = mktime(0,0,0,1,1, date('y')); + $end_str = mktime(23,59,59, date('m'), date('d'), date('y')); + break; + } + + + ###################################### + # Get accounts & sales for this period + ###################################### + $db = &DB(); + $sql = 'SELECT affiliate_id,total_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE + date_orig >= ' . $db->qstr( $start_str ) . ' AND date_orig <= ' . $db->qstr( $end_str ) . ' AND + affiliate_id != ' .$db->qstr( '0' ). ' AND affiliate_id != '.$db->qstr( '' ).' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + while(!$result->EOF) + { + $amt = $result->fields['total_amt']; + $aid = $result->fields['affiliate_id']; + if(!isset( $arr[$aid] )) $arr[$aid] = 0; + $arr[$aid] += $amt; + $result->MoveNext(); + } + + $i = 0; + $_datay = false; + $_lbl = false; + + if(isset($arr) && is_array($arr)) { + while(list($key, $var) = each($arr)) { + if($i<5) + { + $_lbl[] = strtoupper($key); + $_datay[] = $var; + $i++; + } + } + } else { + $file = fopen( PATH_THEMES.'default_admin/images/invisible.gif', 'r'); + fpassthru($file); + exit; + } + + ### Sort the arrays + array_multisort($_datay,SORT_DESC, SORT_NUMERIC, $_lbl); + + ### Limit the results to 10 or less + for($i=0; $i=9) $i = count($_lbl); + } + + $i = count($lbl); + + # Get the Currency + $sql = 'SELECT symbol FROM ' . AGILE_DB_PREFIX . 'currency WHERE + id = ' . $db->qstr( DEFAULT_CURRENCY ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + $currency_iso = $rs->fields['symbol']; + + // Size of graph + $width=265; + $height=75 + ($i*15); + + // Set the basic parameters of the graph + $graph = new Graph($width,$height,'auto'); + $graph->SetScale("textlin"); + $graph->yaxis->scale->SetGrace(50); + $graph->SetMarginColor('#F9F9F9'); + $graph->SetFrame(true,'#CCCCCC',1); + $graph->SetColor('#FFFFFF'); + + $top = 45; + $bottom = 10; + $left = 85; + $right = 15; + $graph->Set90AndMargin($left,$right,$top,$bottom); + + // Label align for X-axis + $graph->xaxis->SetLabelAlign('right','center','right'); + + // Label align for Y-axis + $graph->yaxis->SetLabelAlign('center','bottom'); + $graph->xaxis->SetTickLabels($lbl); + + // Titles + $graph->title->SetFont(FF_FONT1,FS_BOLD,10); + $title = $C_translate->translate('graph_top','affiliate',''); + $graph->title->Set($title); + + // Create a bar pot + $bplot = new BarPlot($datay); + $bplot->SetFillColor("#506DC7"); + $bplot->SetWidth(0.2); + + // Show the values + $bplot->value->Show(); + $bplot->value->SetFont(FF_FONT1,FS_NORMAL,7); + $bplot->value->SetAlign('center','center'); + $bplot->value->SetColor("black","darkred"); + $bplot->value->SetFormat($currency_iso.'%.2f'); + + $graph->Add($bplot); + $graph->Stroke(); + return; + } + + + ############################## + ## MAIL MULTI ACCOUNTS ## + ############################## + function mail_multi($VAR) + { + global $C_translate, $C_debug; + + ## Validate the required vars (account_id, message, subject) + if(@$VAR['search_id'] != "" && @$VAR['mail_subject'] != "" && @$VAR['mail_message'] != "") + { + + ## Get the specified accounts: + # get the search details: + if(isset($VAR['search_id'])) { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } else { + # invalid search! + echo '
The search terms submitted were invalid!'; # translate... # alert + return; + } + + # generate the full query + $field_list = AGILE_DB_PREFIX."affiliate.account_id"; + + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX."affiliate", $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " site_id = '" . DEFAULT_SITE . "'"; + + $db = &DB(); + $affiliate = $db->Execute($q); + + // check results + if($affiliate->RecordCount() == 0) { + $C_debug->alert($C_translate->translate('account_non_exist','account_admin','')); + return; + } + + // load the mail class + require_once(PATH_CORE . 'email.inc.php'); + $email = new CORE_email; + + // get the selected email setup details + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."setup_email WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($VAR['mail_email_id']); + $setup_email = $db->Execute($q); + if($setup_email->fields['type'] == 0) { + $type = 0; + } else { + $type = 1; + $E['server'] = $setup_email->fields['server']; + $E['account'] = $setup_email->fields['username']; + $E['password'] = $setup_email->fields['password']; + } + + // loop to send each e-mail + while ( !$affiliate->EOF ) { + + // get the account details + $q = "SELECT email,first_name,last_name FROM ".AGILE_DB_PREFIX."account ". + "WHERE site_id = ". + $db->qstr(DEFAULT_SITE). + "AND id = ". + $db->qstr($affiliate->fields['account_id']); + $account = $db->Execute($q); + + $E['priority'] = $VAR['mail_priority']; + $E['html'] = '0'; + $E['subject'] = $VAR['mail_subject']; + $E['body_text'] = $VAR['mail_message']; + $E['to_email'] = $account->fields['email']; + $E['to_name'] = $account->fields['first_name'] . ' ' . $account->fields['last_name']; + $E['from_name'] = $setup_email->fields['from_name']; + $E['from_email'] = $setup_email->fields['from_email']; + + ### Call the mail() or smtp() function to send + if($type == 0) + $email->PHP_Mail($E); + else + $email->SMTP_Mail($E); + + ### Next record + $affiliate->MoveNext(); + } + + } else { + ## Error message: + $C_debug->alert($C_translate->translate('validate_any','','')); + return; + } + + ## Success message: + $C_debug->alert($C_translate->translate('mail_sent','account_admin','')); + } + + + + ############################## + ## USER VIEW ## + ############################## + function user_view($VAR) + { + global $smarty; + + # check if this affiliate account exists + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'affiliate WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + account_id = ' . $db->qstr(SESS_ACCOUNT); + if(!empty($this->id_prefix)) + $sql .= " AND id LIKE ".$db->qstr($this->id_prefix."%"); + + $result = $db->Execute($sql); + if($result == true && $result->RecordCount() > 0) + { + ### Get the name of the plugin file to include: + $sql1 = "SELECT file FROM ".AGILE_DB_PREFIX."affiliate_plugin WHERE + id = ". $db->qstr($result->fields['affiliate_plugin_id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $plgn = $db->Execute($sql1); + $plugin = "affiliate:plugin_" . $plgn->fields["file"]; + + + ### Get the static vars: + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + $arr = $static_var->update_form('affiliate', 'update', $result->fields['id']); + + $smarty->assign('static_var', $arr); + $smarty->assign('affiliate', $result->fields); + $smarty->assign('plugin_data', unserialize($result->fields['plugin_data'])); + $smarty->assign('affiliate_plugin_file', $plugin); + $smarty->assign('affiliate_user_view', true); + + ############################################################################ + ### START AFFILIATE STATISTICS ################## + + ### Get the sessions referred by this affiliate: + $sql2 = "SELECT id FROM ".AGILE_DB_PREFIX."session WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $smart["stats_sessions"] = $result2->RecordCount(); + + + ### Get the accounts referred by this affiliate: + $sql2 = "SELECT id FROM ".AGILE_DB_PREFIX."account WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $smart["stats_accounts"] = $result2->RecordCount(); + + ### Get the invoices referred by this affiliate: + $sql2 = "SELECT id FROM ".AGILE_DB_PREFIX."invoice WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $smart["stats_invoices"] = $result2->RecordCount(); + + + ### Get the commissions issued to this affiliate: + $sql2 = "SELECT commission FROM ".AGILE_DB_PREFIX."invoice_commission WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $total = 0; + while(!$result2->EOF) { + $total += $result2->fields['commission']; + $result2->MoveNext(); + } + $smart["stats_commissions"] = $total; + + ### Get the commissions (outstanding) to be issued to this affiliate: + $smart["commissions_due"] = $this->commission_due($result->fields['id']) ; + + ### END AFFILIATE STATISTICS #################### + ############################################################################# + + + ### Get available affiliate campaign details: + $campaigns = unserialize($result->fields["avail_campaign_id"]); + if(count($campaigns) > 0) + { + $where=' WHERE '; + $num=0; + for ($i=0; $i 0) $where = " OR "; + $where .= " id = ". $db->qstr($campaigns[$i]); + $num++; + } + } + + if($num > 0) + { + $sql2 = "SELECT id,name FROM ".AGILE_DB_PREFIX."campaign + $where + AND site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $i=0; + if($result2 != false && $result2->RecordCount() > 0) { + while(!$result2->EOF) { + $campaigns[$i] = $result2->fields; + $i++; + $result2->MoveNext(); + } + } + $smarty->assign('affiliate_campaign', $campaigns); + } + } + $smarty->assign('affiliate_stats', $smart); + return; + } + else + { + # Get the affiliate template settings for the template + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'affiliate_template WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(DEFAULT_AFFILIATE_TEMPLATE); + $temp = $db->Execute($sql); + + + ### Get the static vars: + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + $arr = $static_var->generate_form('affiliate', 'add', 'update'); + if(gettype($arr) == 'array') + $smarty->assign('static_var', $arr); + + + # assign the smarty vars: + //$smarty->assign('affiliate_plugin', $plugin); + $smarty->assign('affiliate_template', $temp->fields); + $smarty->assign('affiliate_user_view', false); + return; + } + return; + } + + + ############################## + ## USER ADD ## + ############################## + function user_add($VAR) + { + global $C_debug, $C_translate; + + # check if this affiliate account exists + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'affiliate WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + account_id = ' . $db->qstr(SESS_ACCOUNT); + $result = $db->Execute($sql); + if($result != false && @$result->RecordCount() > 0) + { + $C_debug->alert($C_translate->translate('error_acct_aff_exist','affiliate','')); + return; + } + + ## Get the affiliate template details: + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'affiliate_template WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(DEFAULT_AFFILIATE_TEMPLATE); + $result = $db->Execute($sql); + if($result->RecordCount() == 0) + { + $C_debug->alert($C_translate->translate('error_template_invalid','affiliate','')); + return; + } + + + #################################################################### + ### Get required static_Vars and validate them... return an array + ### w/ ALL errors... + #################################################################### + + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + if(!isset($this->val_error)) $this->val_error = false; + $all_error = $static_var->validate_form('affiliate', $this->val_error); + + if($all_error != false && gettype($all_error) == 'array') + $this->validated = false; + else + $this->validated = true; + + #################################################################### + # If validation was failed, skip the db insert & + # set the errors & origonal fields as Smarty objects, + # and change the page to be loaded. + #################################################################### + + if(!$this->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $all_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page_current']); + } + return; + } + + ## Get the affiliate id that referred this account: + $sql = 'SELECT affiliate_id FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(SESS_ACCOUNT); + $ref = $db->Execute($sql); + + ## Create the record + $this->record_id = $db->GenID(AGILE_DB_PREFIX . "" . 'affiliate_id'); + $this->record_id = $this->id_prefix . "" . $this->record_id; + + ## Generate the full query + $sql = "INSERT INTO ".AGILE_DB_PREFIX."affiliate + SET + id = ". $db->qstr($this->record_id).", + site_id = ". $db->qstr(DEFAULT_SITE) . ", + account_id = ". $db->qstr(SESS_ACCOUNT) .", + parent_affiliate_id = ". $db->qstr($ref->fields['affiliate_id']) .", + status = ". $db->qstr($result->fields['status']) .", + affiliate_plugin = ". $db->qstr(@$VAR['affiliate_affiliate_plugin']) .", + avail_campaign_id = ". $db->qstr($result->fields['avail_campaign_id']) .", + max_tiers = ". $db->qstr($result->fields['max_tiers']) .", + commission_minimum = ". $db->qstr($result->fields['commission_minimum']) .", + new_commission_type = ". $db->qstr($result->fields['new_commission_type']) .", + new_commission_rate = ". $db->qstr($result->fields['new_commission_rate']) .", + recurr_commission_type =". $db->qstr($result->fields['recurr_commission_type']) .", + recurr_commission_rate =". $db->qstr($result->fields['recurr_commission_rate']) .", + recurr_max_commission_periods = ". $db->qstr($result->fields['recurr_max_commission_periods']) .", + date_orig = ". $db->qstr(time()) .", + date_last = ". $db->qstr(time()); + $result2 = $db->Execute($sql); + if($result2 != false) + { + ## Insert the static vars: + $static_var->add($VAR, $this->module, $this->record_id); + + ## Load the affiliate plugin and run the "Add" method: + $file = strtoupper(eregi_replace('[^0-9a-z_-]{1,}', '', @$VAR['affiliate_affiliate_plugin'])); + + $pluginfile = PATH_PLUGINS . 'affiliate/' . $file . '.php'; + if(@include_once($pluginfile)) + { + eval ( '$_PLGN_AFF = new plgn_aff_'. strtoupper ( $file ) . ';' ); + $_PLGN_AFF->add(SESS_ACCOUNT, $this->record_id); + } + + ## Send the affiliate e-mail: + require_once(PATH_MODULES . 'email_template/email_template.inc.php'); + if($result->fields['status'] == "1") + { + $my1 = new email_template; + $my1->send('affiliate_user_add_active', SESS_ACCOUNT, '', '', $this->record_id); + $C_debug->alert($C_translate->translate('user_add_active','affiliate','')); + } + else + { + $my1 = new email_template; + $my1->send('affiliate_user_add_pending', SESS_ACCOUNT, '', '', $this->record_id); + $my2 = new email_template; + $my2->send('affiliate_user_add_staff_notify', SESS_ACCOUNT, '', '', $this->record_id); + $C_debug->alert($C_translate->translate('user_add_inactive','affiliate','')); + } + + global $VAR; + $VAR['id'] = $this->record_id; + define('FORCE_PAGE', $VAR['_page_current']); + } + else + { + $C_debug->alert('There was an error and the affiliate account could not be added.'); + define('FORCE_PAGE', $VAR['_page_current']); + } + } + + + + ############################## + ## USER UPDATE ## + ############################## + function user_update($VAR) + { + global $C_debug, $C_translate; + + # check if this affiliate account exists + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'affiliate WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + account_id = ' . $db->qstr(SESS_ACCOUNT); + $result = $db->Execute($sql); + if($result == false || @$result->RecordCount() == 0) + { + $C_debug->alert($C_translate->translate('error_not_authorized','affiliate','')); + return; + } + + $VAR["affiliate_id"] = $result->fields["id"]; + + #################################################################### + ### Get required static_Vars and validate them... return an array + ### w/ ALL errors... + #################################################################### + + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + if(!isset($this->val_error)) $this->val_error = false; + $all_error = $static_var->validate_form('affiliate', $this->val_error); + + if($all_error != false && gettype($all_error) == 'array') + $this->validated = false; + else + $this->validated = true; + + #################################################################### + # If validation was failed, skip the db insert & + # set the errors & origonal fields as Smarty objects, + # and change the page to be loaded. + #################################################################### + + if(!$this->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $all_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page_current']); + } + + global $C_vars; + $C_vars->strip_slashes_all(); + return; + } + + # special handling for the affiliate data array + if(isset($VAR['affiliate_plugin_data']) && is_array($VAR['affiliate_plugin_data'])) { + while (list($key,$val) = each($VAR['affiliate_plugin_data'])) { + if(get_magic_quotes_gpc()) { + $VAR['affiliate_plugin_data']["$key"] = htmlentities(stripcslashes($val), ENT_QUOTES); + } + } + } + + $type = "user_update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + + ### Update the static vars: + $static_var->update($VAR, 'affiliate', $VAR['affiliate_id']); + + } + + + + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + global $C_debug, $C_translate; + + ## Verify the account id passed: + if(empty($VAR['affiliate_account_id'])) + { + $C_debug->alert($C_translate->translate('error_acct_req','affiliate','')); + return; + } + + ## Get the affiliate template details: + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'affiliate_template WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($VAR['affiliate_template_id']); + $result = $db->Execute($sql); + if($result->RecordCount() == 0) + { + $C_debug->alert($C_translate->translate('error_template_invalid','affiliate','')); + return; + } + + ## Verify that this account does not have an affiliate account already: + $sql = 'SELECT account_id FROM ' . AGILE_DB_PREFIX . 'affiliate WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + account_id = ' . $db->qstr($VAR['affiliate_account_id']); + $acctc = $db->Execute($sql); + if($acctc->RecordCount() > 0) + { + $C_debug->alert($C_translate->translate('error_acct_aff_exist','affiliate','')); + return; + } + + ## Get the affiliate id that referred this account: + $sql = 'SELECT affiliate_id FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($VAR['affiliate_account_id']); + $ref = $db->Execute($sql); + + ## Create the record + $this->record_id = $db->GenID(AGILE_DB_PREFIX . "" . 'affiliate_id'); + $this->record_id = $this->id_prefix . "" . $this->record_id; + + ## Generate the full query + $sql = "INSERT INTO ".AGILE_DB_PREFIX."affiliate + SET + id = ". $db->qstr($this->record_id).", + site_id = ". $db->qstr(DEFAULT_SITE) . ", + account_id = ". $db->qstr($VAR['affiliate_account_id']) .", + parent_affiliate_id = ". $db->qstr($ref->fields['affiliate_id']) .", + status = ". $db->qstr("1") .", + affiliate_plugin = ". $db->qstr($result->fields['affiliate_plugin']) .", + avail_campaign_id = ". $db->qstr($result->fields['avail_campaign_id']) .", + max_tiers = ". $db->qstr($result->fields['max_tiers']) .", + commission_minimum = ". $db->qstr($result->fields['commission_minimum']) .", + new_commission_type = ". $db->qstr($result->fields['new_commission_type']) .", + new_commission_rate = ". $db->qstr($result->fields['new_commission_rate']) .", + recurr_commission_type =". $db->qstr($result->fields['recurr_commission_type']) .", + recurr_commission_rate =". $db->qstr($result->fields['recurr_commission_rate']) .", + recurr_max_commission_periods = ". $db->qstr($result->fields['recurr_max_commission_periods']) .", + date_orig = ". $db->qstr(time()) .", + date_last = ". $db->qstr(time()); + $result2 = $db->Execute($sql); + if($result != false) + { + ## Load the affiliate plugin and run the "Add" method: + $sql = "SELECT file FROM ".AGILE_DB_PREFIX."affiliate_plugin WHERE + id = ". $db->qstr($result->fields['affiliate_plugin'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $plgn = $db->Execute($sql); + @$pluginfile = PATH_PLUGINS . 'affiliate/' . $plgn->fields['file'] . '.php'; + if(@include_once($pluginfile)) + { + eval ( '$_PLGN_AFF = new plgn_aff_'. strtoupper ( $plgn->fields['file'] ) . ';' ); + $_PLGN_AFF->add(SESS_ACCOUNT, $this->record_id); + } + + ## Send the affiliate e-mail: + require_once(PATH_MODULES . 'email_template/email_template.inc.php'); + $my = new email_template; + $my->send('affiliate_staff_add', $VAR['affiliate_account_id'], '', '', $this->record_id); + + ## Redirect + global $VAR; + $VAR['id'] = $this->record_id; + define('FORCE_PAGE', $VAR['_page']); + } + else + { + $C_debug->alert('There was an error and the affiliate account could not be added.'); + define('FORCE_PAGE', $VAR['_page_current']); + } + } + + + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + + # set the field list for this method: + $db = &DB(); + $arr = $this->method[$type]; + if(isset($VAR["id"])) + { + $id = split(',',$VAR["id"]); + for($i=0; $iqstr($id[$i])." "; + $ii++; + } + else + { + $id_list .= " OR id = " .$db->qstr($id[$i]). " "; + $ii++; + } + } + } + } + + if($ii>0) + { + # generate the full query + $q = "SELECT * FROM + ".AGILE_DB_PREFIX."affiliate + WHERE + $id_list + AND site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('affiliate.inc.php','view', $db->ErrorMsg() . ' ' . $q); + return; + } + + + # put the results into a smarty accessable array + $i=0; + $class_name = TRUE; + while (!$result->EOF) + { + $smart[$i] = $result->fields; + + if($class_name) + { + $smart[$i]["i"] = $i; + } else { + $smart[$i]["i"] = $i; + } + + $plugin_data = unserialize($result->fields["plugin_data"]); + + ### Get the name of the plugin file to include: + $sql1 = "SELECT file FROM ".AGILE_DB_PREFIX."affiliate_plugin WHERE + id = ". $db->qstr($result->fields['affiliate_plugin_id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $plgn = $db->Execute($sql1); + $smart[$i]["plugin_file"] = "affiliate:plugin_" . $plgn->fields["file"]; + + + ### Get the static vars: + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + $arr = $static_var->update_form('affiliate', 'update', $result->fields['id']); + if(gettype($arr) == 'array') + { + $smart[$i]["static_var"] = $arr; + } + + ############################################################################ + ### START AFFILIATE STATISTICS ################## + + ### Get the sessions referred by this affiliate: + $sql2 = "SELECT id FROM ".AGILE_DB_PREFIX."session WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $smart[$i]["stats_sessions"] = $result2->RecordCount(); + + + ### Get the accounts referred by this affiliate: + $sql2 = "SELECT id FROM ".AGILE_DB_PREFIX."account WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $smart[$i]["stats_accounts"] = $result2->RecordCount(); + + ### Get the invoices referred by this affiliate: + $sql2 = "SELECT id,total_amt FROM ".AGILE_DB_PREFIX."invoice WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $smart[$i]["stats_invoices"] = $result2->RecordCount(); + $total = 0; + while(!$result2->EOF) { + $total += $result2->fields['total_amt']; + $result2->MoveNext(); + } + $smart[$i]["stats_invoices_amt"] = $total; + + ### Get the commissions issued to this affiliate: + $sql2 = "SELECT commission FROM ".AGILE_DB_PREFIX."invoice_commission WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $total = 0; + while(!$result2->EOF) { + $total += $result2->fields['commission']; + $result2->MoveNext(); + } + $smart[$i]["stats_commissions"] = $total; + + ### Get the commissions (outstanding) to be issued to this affiliate: + $smart[$i]["commissions_due"] = $this->commission_due($result->fields['id']) ; + + + + ### END AFFILIATE STATISTICS #################### + ############################################################################# + + + $i++; + $result->MoveNext(); + } + + # get the result count: + $results = $i; + + ### No results: + if($i == 0) + { + global $C_debug; + $C_debug->error("CORE:affiliate.inc.php", "view()", " + The selected affiliate does not exist any longer!"); + return; + } + + + + + global $smarty; + $smarty->assign($this->table, $smart); + $smarty->assign('plugin_data', $plugin_data); + $smarty->assign('results', $search->results); + } + } + + + function commission_due($affiliate_id) + { + $db = &DB(); + $sql2 = "SELECT invoice_id FROM ".AGILE_DB_PREFIX."invoice_commission WHERE + affiliate_id = ". $db->qstr($affiliate_id)." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $sqla = ''; + while(!$result2->EOF) + { + $sqla .= " AND id != " . $result2->fields['invoice_id']; + $result2->MoveNext(); + } + $sql = "SELECT total_amt FROM ".AGILE_DB_PREFIX."invoice WHERE + affiliate_id = ". $db->qstr($affiliate_id)." AND + billing_status = 1 + {$sqla} + AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql); + $total = 0; + while(!$result2->EOF) { + $total += $result2->fields['total_amt']; + $result2->MoveNext(); + } + + return $total; + } + + + + + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + #################################################################### + ### Get required static_Vars and validate them... return an array + ### w/ ALL errors... + #################################################################### + + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + if(!isset($this->val_error)) $this->val_error = false; + $all_error = $static_var->validate_form('affiliate', $this->val_error); + + if($all_error != false && gettype($all_error) == 'array') + $this->validated = false; + else + $this->validated = true; + + #################################################################### + # If validation was failed, skip the db insert & + # set the errors & origonal fields as Smarty objects, + # and change the page to be loaded. + #################################################################### + + if(!$this->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $all_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page_current']); + } + return; + } + + # special handling for the affiliate data array + if(isset($VAR['affiliate_plugin_data']) && is_array($VAR['affiliate_plugin_data'])) { + while (list($key,$val) = each($VAR['affiliate_plugin_data'])) { + if(get_magic_quotes_gpc()) { + $VAR['affiliate_plugin_data']["$key"] = htmlentities(stripcslashes($val), ENT_QUOTES); + } + } + } + + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + + ### Update the static vars: + $static_var->update($VAR, 'affiliate', $VAR['affiliate_id']); + + } + + + + + + + ############################## + ## MASS DELETE ## + ############################## + function delete($VAR) + { + $id_list = ''; + $ii=0; + + if(isset($VAR["delete_id"])) + { + $id = split(',',$VAR["delete_id"]); + } + elseif (isset($VAR["id"])) + { + $id = split(',',$VAR["id"]); + } + + for($i=0; $idelete_one($id[$i]); + } + } + + if($ret) + { + # Alert delete message + global $C_debug, $C_translate; + $C_translate->value["CORE"]["module_name"] = $C_translate->translate('name',$this->module,""); + $message = $C_translate->translate('alert_delete_ids',"CORE",""); + $C_debug->alert($message); + } + } + + + + ############################## + ## MASS DELETE ## + ############################## + function delete_one($id) + { + # get the parent affiliate id for this account, if any + $db = &DB(); + $sql = 'SELECT parent_affiliate_id FROM ' . AGILE_DB_PREFIX . 'affiliate WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id= ' . $db->qstr($id); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + if(!empty($result->fields['parent_affiliate_id'])) + { + ## update all affiliates one this affiliate's main tier + ## to assume the position this affiliate was in: + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'affiliate + SET + parent_affiliate_id = ' . $db->qstr($result->fields['parent_affiliate_id']) . ' + WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + parent_affiliate_id= ' . $db->qstr($id); + $db->Execute($sql); + } + } + # delete any commission records for this affiliate: + $sql = 'DELETE FROM ' . AGILE_DB_PREFIX . 'affiliate + WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($id); + $db->Execute($sql); + return true; + } + + + ############################## + ## SEARCH EXPORT ## + ############################## + function search_export($VAR) + { + # require the export class + require_once (PATH_CORE . "export.inc.php"); + + # Call the correct export function for inline browser display, download, email, or web save. + if($VAR["format"] == "excel") + { + $type = "export_excel"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_excel($VAR, $this, $type); + } + + else if ($VAR["format"] == "pdf") + { + $type = "export_pdf"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_pdf($VAR, $this, $type); + } + + else if ($VAR["format"] == "xml") + { + $type = "export_xml"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_xml($VAR, $this, $type); + } + + else if ($VAR["format"] == "csv") + { + $type = "export_csv"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_csv($VAR, $this, $type); + } + + else if ($VAR["format"] == "tab") + { + $type = "export_tab"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_tab($VAR, $this, $type); + } + } + + + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + + $db = &DB(); + + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + + # set the search criteria array + $arr = $VAR; + + # loop through the submitted field_names to get the WHERE statement + $where_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + if($value != '') + { + $pat = "^" . $this->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value = $validate->convert($field, $value, $this->field["$field"]["convert"]); + } + + $where_list .= " WHERE ".AGILE_DB_PREFIX."affiliate.".$field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $this->module.'_'.$field; + $VAR['field_option']["$pat_field"]["$i_arr"]; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $this->field["$field"]["convert"]); + } + + + if($i_arr == 0) + { + $where_list .= " WHERE ".AGILE_DB_PREFIX."affiliate.".$field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + else + { + $where_list .= " AND ".AGILE_DB_PREFIX."affiliate.".$field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + } + else + { + $where_list .= " WHERE ".AGILE_DB_PREFIX."affiliate.".$field . " = " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + else + { + if($value != '') + { + $pat = "^" . $this->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value = $validate->convert($field, $value, $this->field["$field"]["convert"]); + } + + $where_list .= " AND ".AGILE_DB_PREFIX."affiliate.".$field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $this->module.'_'.$field; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $this->field["$field"]["convert"]); + } + + $where_list .= " AND ".AGILE_DB_PREFIX."affiliate.". $field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + else + { + $where_list .= " AND ".AGILE_DB_PREFIX."affiliate.". $field . " = ". $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + } + + + #### finalize the WHERE statement + if($where_list == '') + { + $where_list .= ' WHERE '; + } + else + { + $where_list .= ' AND '; + } + + + # get limit type + if(isset($VAR['limit'])) + { + $limit = $VAR['limit']; + } + else + { + $limit = $this->limit; + } + + # get order by + if(isset($VAR['order_by'])) + { + $order_by = $VAR['order_by']; + } + else + { + $order_by = $this->order_by; + } + + $pre = AGILE_DB_PREFIX; + $q = "SELECT DISTINCT {$pre}affiliate.id FROM {$pre}affiliate "; + $q_save = "SELECT DISTINCT + {$pre}account.first_name, + {$pre}account.last_name, + {$pre}account.username, + {$pre}account.email, + %%fieldList%% + FROM + {$pre}affiliate + LEFT JOIN + {$pre}account + ON + {$pre}affiliate.account_id = {$pre}account.id "; + + + ######## GET ANY STATIC VARS TO SEARCH ########## + $join_list = ''; + if(!empty($VAR["static_relation"]) && count( $VAR["static_relation"] > 0 )) { + while(list($idx, $value) = each ($VAR["static_relation"])) { + if($value != "") { + + $join_list .= " INNER JOIN {$pre}static_var_record AS s{$idx} ON + ( + s{$idx}.record_id = {$pre}{$this->table}.id + AND + s{$idx}.static_var_relation_id = '{$idx}' + AND + s{$idx}.site_id = ".$db->qstr(DEFAULT_SITE)." + AND"; + if(ereg("%", $value)) + $join_list .= " s{$idx}.value LIKE ".$db->qstr($VAR["static_relation"]["$idx"]); + else + $join_list .= " s{$idx}.value = ".$db->qstr($VAR["static_relation"]["$idx"]); + $join_list .= " ) "; + } + } + } + ######## END STATIC VAR SEARCH ################## + + + # standard where list + $q .= $join_list . $where_list ." ".AGILE_DB_PREFIX."affiliate.site_id = " . $db->qstr(DEFAULT_SITE); + $q_save .= $join_list . $where_list ." %%whereList%% "; + + + ################## DEBUG ################## + #echo "
" . $q;
+		#echo "

" . $q_save; + #exit; + + # run the database query + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('affiliate.inc.php','search', $db->ErrorMsg()); + return false; + } + + # get the result count: + $results = $result->RecordCount(); + + # get the first record id: + if($results == 1) $record_id = $result->fields['id']; + + # define the DB vars as a Smarty accessible block + global $smarty; + + # Create the definition for fast-forwarding to a single record: + if ($results == 1 && !isset($this->fast_forward)) + { + $smarty->assign('record_id', $record_id); + } + + # create the search record: + if($results > 0) + { + # create the search record + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $arr['module'] = $this->module; + $arr['sql'] = $q_save; + $arr['limit'] = $limit; + $arr['order_by']= $order_by; + $arr['results'] = $results; + $search->add($arr); + + # define the search id and other parameters for Smarty + $smarty->assign('search_id', $search->id); + + # page: + $smarty->assign('page', '1'); + + # limit: + $smarty->assign('limit', $limit); + + # order_by: + $smarty->assign('order_by', $order_by); + } + + # define the result count + $smarty->assign('results', $results); + } + + + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + + # set the field list for this method: + $arr = $this->method[$type]; + + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $this->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . "affiliate" . "." . $value; + + // determine if this record is linked to another table/field + if($this->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $this->field[$value]["asso_table"], 'link_field' => $this->field[$value]["asso_field"]); + } + } + else + { + $field_var = $this->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . "affiliate" . "." . $value; + + // determine if this record is linked to another table/field + if($this->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $this->field[$value]["asso_table"], 'link_field' => $this->field[$value]["asso_field"]); + } + } + $i++; + } + + + # get the search details: + if(isset($VAR['search_id'])) { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } else { + # invalid search! + echo '
The search terms submitted were invalid!'; # translate... # alert + + if(isset($this->trigger["$type"])) { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . 'affiliate.'.$VAR['order_by']; + $smarty_order = $VAR['order_by']; + } else { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . 'affiliate.'.$this->order_by; + $smarty_order = $search->order_by; + } + + + # determine the sort order + if(isset($VAR['desc'])) { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } else if(isset($VAR['asc'])) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + if (!eregi('date',$smarty_order)) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } + } + + # generate the full query + $db = &DB(); + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " ".AGILE_DB_PREFIX . "affiliate."."site_id = " . $db->qstr(DEFAULT_SITE); + $q .= $order_by; + + ////////////////// + #echo "
 $q 

"; + $current_page=1; + $offset=-1; + if (!empty($VAR['page'])) $current_page = $VAR['page']; + if (empty($search->limit)) $search->limit=25; + if($current_page>1) $offset = (($current_page * $search->limit) - $search->limit); + $result = $db->SelectLimit($q, $search->limit, $offset); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('affiliate.inc.php','search_show', $db->ErrorMsg()); + + if(isset($this->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + return; + } + + + # put the results into a smarty accessable array + $i=0; + $class_name = TRUE; + while (!$result->EOF) { + $smart[$i] = $result->fields; + + if($class_name) + { + $smart[$i]['_C'] = 'row1'; + $class_name = FALSE; + } else { + $smart[$i]['_C'] = 'row2'; + $class_name = TRUE; + } + + ### Get the sessions referred by this affiliate: + $sql2 = "SELECT id FROM ".AGILE_DB_PREFIX."session WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $smart[$i]["stats_sessions"] = $result2->RecordCount(); + + + ### Get the accounts referred by this affiliate: + $sql2 = "SELECT id FROM ".AGILE_DB_PREFIX."account WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $smart[$i]["stats_accounts"] = $result2->RecordCount(); + + ### Get the invoices referred by this affiliate: + $sql2 = "SELECT id,total_amt FROM ".AGILE_DB_PREFIX."invoice WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $smart[$i]["stats_invoices"] = $result2->RecordCount(); + $total = 0; + while(!$result2->EOF) { + $total += $result2->fields['total_amt']; + $result2->MoveNext(); + } + $smart[$i]["stats_invoices_amt"] = $total; + + ### Get the commissions issued to this affiliate: + $sql2 = "SELECT commission FROM ".AGILE_DB_PREFIX."invoice_commission WHERE + affiliate_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql2); + $total = 0; + while(!$result2->EOF) { + $total += $result2->fields['commission']; + $result2->MoveNext(); + } + $smart[$i]["stats_commissions"] = $total; + + $result->MoveNext(); + $i++; + } + + + # get any linked fields + if($i > 0) + { + $db_join = new CORE_database; + $this->result = $db_join->join_fields($smart, $this->linked); + } + else + { + $this->result = $smart; + } + + # get the result count: + $results = $result->RecordCount(); + + # define the DB vars as a Smarty accessible block + global $smarty; + + # define the results + $smarty->assign($this->table, $this->result); + $smarty->assign('page', $VAR['page']); + $smarty->assign('order', $smarty_order); + $smarty->assign('sort', $smarty_sort); + $smarty->assign('limit', $search->limit); + $smarty->assign('search_id',$search->id); + $smarty->assign('results', $search->results); + + # get the total pages for this search: + if(empty($search->limit)) + $this->pages = 1; + else + $this->pages = intval($search->results / $search->limit); + if ($search->results % $search->limit) $this->pages++; + + # total pages + $smarty->assign('pages', $this->pages); + + # current page + $smarty->assign('page', $current_page); + $page_arr = ''; + for($i=0; $i <= $this->pages; $i++) + { + if ($this->page != $i) $page_arr[] = $i; + } + + # page array for menu + $smarty->assign('page_arr', $page_arr); + } + + + ############################## + ## STATIC VARS ## + ############################## + + function static_var($VAR) + { + global $smarty; + + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + + if(ereg('search', $VAR['_page'])) + $arr = $static_var->generate_form($this->module, 'add', 'search'); + else + $arr = $static_var->generate_form($this->module, 'add', 'update'); + + if(gettype($arr) == 'array') + { + ### Set everything as a smarty array, and return: + $smarty->assign('show_static_var', true); + $smarty->assign('static_var', $arr); + return true; + } + else + { + ### Or if no results: + $smarty->assign('show_static_var', false); + return false; + } + } +} +?> \ No newline at end of file diff --git a/modules/affiliate/affiliate_construct.xml b/modules/affiliate/affiliate_construct.xml new file mode 100644 index 00000000..fb34ce00 --- /dev/null +++ b/modules/affiliate/affiliate_construct.xml @@ -0,0 +1,104 @@ + + + + affiliate + + affiliate
+ + + + 0 + + id + + 25 + + + account_id + parent_affiliate_id + + + + + C(32) + 1 + 1 + + + I4 + 1 + + + I8 + date-time + + + I8 + any + date-now + + + L + + + I8 + any + + + X2 + array + + + C(32) + + + C(16) + affiliate + id + + + I4 + + + F + + + L + + + X2 + array + + + L + + + X2 + array + + + I4 + + + X2 + array + + + + + id,site_id,date_orig,date_last,status,account_id,avail_campaign_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods,plugin_data + id,site_id,date_orig,date_last,status,account_id,avail_campaign_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods,plugin_data + id,site_id,date_orig,date_last,status,account_id,avail_campaign_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods,plugin_data + id,site_id,date_orig,date_last,status,account_id,avail_campaign_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods,plugin_data + id,site_id,date_orig,date_last,status,account_id,avail_campaign_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods,plugin_data + date_last,affiliate_plugin,plugin_data + id,site_id,date_orig,date_last,status,account_id,avail_campaign_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods + id,date_orig,date_last,status,account_id,avail_campaign_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods + id,date_orig,date_last,status,account_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,recurr_commission_type,recurr_max_commission_periods + id,date_orig,date_last,status,account_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,recurr_commission_type,recurr_max_commission_periods + id,date_orig,date_last,status,account_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,recurr_commission_type,recurr_max_commission_periods + id,date_orig,date_last,status,account_id,affiliate_plugin,parent_affiliate_id,max_tiers,commission_minimum,new_commission_type,recurr_commission_type,recurr_max_commission_periods + + + 0 +
diff --git a/modules/affiliate/affiliate_install.xml b/modules/affiliate/affiliate_install.xml new file mode 100644 index 00000000..d14e80b6 --- /dev/null +++ b/modules/affiliate/affiliate_install.xml @@ -0,0 +1,49 @@ + + + affiliate + affiliate + + 1 + affiliate_commission,affiliate_template,campaign + + + + + search_form + + + search_show + + + search + + 1 + + + view + + 1 + + + delete + + + update + + + add + + 1 + + + search_export + + + mail_multi + + + autoselect + + + + \ No newline at end of file diff --git a/modules/affiliate/auth.inc.php b/modules/affiliate/auth.inc.php new file mode 100644 index 00000000..f39c8c70 --- /dev/null +++ b/modules/affiliate/auth.inc.php @@ -0,0 +1,28 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +$auth_methods = Array +( + Array ('module' => 'affiliate', 'method' => 'user_add'), + Array ('module' => 'affiliate', 'method' => 'user_update'), + Array ('module' => 'affiliate', 'method' => 'user_view'), + Array ('module' => 'affiliate', 'method' => 'static_var') +); +?> \ No newline at end of file diff --git a/modules/affiliate_commission/affiliate_commission.inc.php b/modules/affiliate_commission/affiliate_commission.inc.php new file mode 100644 index 00000000..151343e4 --- /dev/null +++ b/modules/affiliate_commission/affiliate_commission.inc.php @@ -0,0 +1,531 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class affiliate_commission +{ + # Open the constructor for this mod + function affiliate_commission() + { + # name of this module: + $this->module = "affiliate_commission"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $search_limit = 50; + + global $C_debug, $C_translate; + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + + $this->start_date = false; + if(!empty($VAR['affiliate_commission_start_date'])) $this->start_date = $validate->convert('', $VAR['affiliate_commission_start_date'], 'date'); + + $this->end_date=false; + if(!empty($VAR['affiliate_commission_end_date'])) $this->end_date = $validate->convert('', $VAR['affiliate_commission_end_date'], 'date'); + + # determine the offset & limit + if(!empty($VAR['page'])) { + $current_page = $VAR['page']; + } else { + $current_page = '1'; + } + + # determine the offset & limit + $offset=-1; + if($current_page == 1) { + $offset = 0; + } else { + $offset = (($current_page * $search_limit) - $search_limit); + } + + $db = &DB(); + if($current_page == 1) + $this->GenID = $db->GenID(AGILE_DB_PREFIX . 'affiliate_commission_id'); + else + $this->GenID = @$VAR['GenID']; + + # Generate the SQL for this commission generation session: + $sql = "SELECT id,affiliate_id,total_amt,tax_amt,type FROM ".AGILE_DB_PREFIX."invoice WHERE site_id = ".$db->qstr(DEFAULT_SITE)." AND + process_status = 1 AND billing_status = 1 AND + ( affiliate_id IS NOT NULL AND affiliate_id !='' ) AND + total_amt > 0 "; + if($this->start_date) $sql .= " AND date_orig >= ".$db->qstr($this->start_date); + if($this->end_date) $sql .= " AND date_orig <= ".$db->qstr($this->end_date); + $result = $db->SelectLimit($sql, $search_limit, $offset); + + #echo $sql; + #echo "

"; + #print_r($result->fields); + #exit; + + # No more results - print link to export data: + if($result->RecordCount() == 0 && $current_page > 1) { + $msg = $C_translate->translate('generated','affiliate_commission',''); + $msg .= '    '.$C_translate->translate('submit','','').''; + $msg .= ''; + + $C_debug->alert($msg); + return; + } + + # Loop through the results: + $count = 0; + while (!$result->EOF) + { + $do = true; + $level = 1; + unset($affiliate_arr); + $affiliate_id = $result->fields["affiliate_id"]; + + # check if the commissions for this invoice have already been issued... + $sql = "SELECT id FROM ".AGILE_DB_PREFIX."invoice_commission WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + invoice_id = ".$db->qstr($result->fields["id"]); + $result2 = $db->Execute($sql); + if ($result2->RecordCount() == 0) + { + + # loop through all affiliate levels to generate the commissions... + while ( $level < 100 && @$affiliate_id) + { + for($i=0; $ifields["id"]} + GROUP BY invoice_id"; + $rsi=$db->Execute($sqli); + if($rsi && $rsi->RecordCount()) { + $invoice_amount = $rsi->fields["invoice_amount"]; + $arr = $this->calc_commission($affiliate_id, $invoice_amount, $result->fields["type"], $level); + if (@$arr["amount"] > 0) + $this->add_invoice_commission($arr['amount'], $affiliate_id, $result->fields["id"]); + unset($affiliate_id); + if (isset($arr["affiliate_id"])) + $affiliate_id = $arr['affiliate_id']; + + $count++; + } + } + $level++; + } + } + + # add this invoice to the processed list... + $result->MoveNext(); + } + + # Create the affiliate_commission record: + if($count == 0) + { + $msg = $C_translate->translate('no_results','affiliate_commission',''); + $C_debug->alert($msg); + } + else + { + $start = ($search_limit * $current_page) - $search_limit; + $stop = ($search_limit * $current_page); + $page = $current_page + 1; + $C_translate->value['affiliate_commission']['start'] = $start; + $C_translate->value['affiliate_commission']['stop'] = $stop; + $C_translate->value['affiliate_commission']['genid'] = $this->GenID; + $C_translate->value['affiliate_commission']['page'] = $page; + $C_translate->value['affiliate_commission']['unixtime_start_date'] = $this->start_date; + $C_translate->value['affiliate_commission']['unixtime_stop_date'] = $this->end_date; + + $msg = $C_translate->translate('continue','affiliate_commission',''); + $url = '?_page=core:blank&do[]=affiliate_commission:add&GenID='.$this->GenID. + '&page='.$page. + '&affiliate_commission_start_date='.@$VAR['affiliate_commission_start_date']. + '&affiliate_commission_start_date='.@$VAR['affiliate_commission_start_date']; + $msg .= '    '.$C_translate->translate('submit','','').''; + $msg .= ''; + $C_debug->alert($msg); + } + } + + + ############################## + ## CALCULATE COMMISSIONS ## + ############################## + function calc_commission( $affiliate_id, $amount, $type, $level ) + { + $db = &DB(); + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."affiliate WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($affiliate_id); + $result = $db->Execute($sql); + if ($result->RecordCount() == 0) return false; + + # can affiliate recieve commissions from this level? + if($result->fields['max_tiers'] >= $level) + { + ## Order Type: 0 = new, 1 = recurring charge + if($type == 0) { + $rate = unserialize($result->fields['new_commission_rate']); + $calc = $result->fields['new_commission_type']; + } else { + $rate = unserialize($result->fields['recurr_commission_rate']); + $calc = $result->fields['recurr_commission_type']; + } + $i = $level - 1; + $amount2 = $rate[$i] * $amount; + $ret['amount'] = $amount2; + } + else + { + $ret['amount'] = false; + } + + # get the parent affiliate id, if any: + if ( $result->fields['parent_affiliate_id'] != $affiliate_id) + $ret['affiliate_id'] = $result->fields['parent_affiliate_id']; + + return $ret; + } + + + ############################## + ## INCREMENT COMMISSION ## + ############################## + function add_invoice_commission( $amount, $affiliate_id, $invoice_id ) + { + $db = &DB(); + $id = $db->GenID(AGILE_DB_PREFIX . 'invoice_commission_id'); + $sql = "INSERT INTO ".AGILE_DB_PREFIX."invoice_commission SET + id = ".$db->qstr($id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + date_last = ".$db->qstr(time()).", + affiliate_commission_id = ".$db->qstr($this->GenID).", + invoice_id = ".$db->qstr($invoice_id).", + affiliate_id = ".$db->qstr($affiliate_id).", + commission = ".$db->qstr($amount).", + status = ".$db->qstr("0"); + $result = $db->Execute($sql); + + ### Increment the affiliate_commission totals: + $sql = "SELECT commissions FROM ".AGILE_DB_PREFIX."affiliate_commission WHERE + id = ".$db->qstr($this->GenID)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + ### Update the affiliate_commission total: + if( $result->fields['commissions'] > 0 ) + $current = $result->fields['commissions'] + $amount; + else + $current = $amount; + + $sql = "UPDATE ".AGILE_DB_PREFIX."affiliate_commission + SET + commissions = ".$db->qstr($current)." + WHERE + id = ".$db->qstr($this->GenID)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + } + else + { + ### Create new affiliate_commission record + $sql = "INSERT INTO ".AGILE_DB_PREFIX."affiliate_commission SET + id = ".$db->qstr($this->GenID).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + date_begin = ".$db->qstr($this->start_date).", + date_end = ".$db->qstr($this->end_date).", + commissions = ".$db->qstr($amount); + $result = $db->Execute($sql); + } + } + + + + + ############################## + ## GET ARRAY OF AFFILIATES ## + ############################## + function plugin_affiliate_list($plugin_name, $affiliate_commission_id) + { + # Get each affiliate in this commission: + $db = &DB(); + $sql = "SELECT DISTINCT affiliate_id FROM ".AGILE_DB_PREFIX."invoice_commission WHERE + affiliate_commission_id = ".$db->qstr($affiliate_commission_id)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + if ($result->RecordCount() == 0) return false; + while(!$result->EOF) { + # check if the affiliate is using plugin_name specified: + $sql = "SELECT id FROM ".AGILE_DB_PREFIX."affiliate WHERE + id = ".$db->qstr($result->fields['affiliate_id'])." AND + affiliate_plugin = ".$db->qstr($plugin_name)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result2 = $db->Execute($sql); + if ($result2->RecordCount() >= 1) { + $arr[] = $result->fields['affiliate_id']; + } + $result->MoveNext(); + } + if(count(@$arr) > 0) + return $arr; + else + return false; + } + + + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + + + ################################################# + # Get the data for each affiliate plugin: + global $C_translate, $smarty; + $id = @$VAR['id']; + + $path = PATH_PLUGINS . '/affiliate/'; + $pre = ''; + $ext = '.php'; + + $count = 0; + chdir($path); + $dir = opendir($path); + while ($file_name = readdir($dir)) + { + $display = true; + if($file_name != '..' && $file_name != '.') + { + if(!empty($ext)) + { + $cute = eregi_replace($ext.'$', "", $file_name); + if(!eregi($ext.'$', $file_name)) $display = false; + } + if(!empty($pre)) + { + $cute = eregi_replace('^'.$pre, "", $cute); + if(!eregi('^'.$pre, $file_name)) $display = false; + } + if($display) + { + $name = $cute; + if($arr_count = $this->plugin_affiliate_list($cute, $id)) + $count = count($arr_count); + else + $count = 0; + $cute = eregi_replace("_"," ",$cute); + $cute = eregi_replace("-"," ",$cute); + + $smart[] = Array ( 'name' => $cute, + 'plugin' => $name, + 'count' => $count); + $count++; + } + } + } + + $smarty->assign('plugindata', $smart); + } + + + ############################## + ## RUN AFFILIATE PLUGIN ## + ############################## + function export($VAR) + { + # make sure the required vars are set: id, plugin, + if(!isset($VAR['id']) || !isset($VAR['plugin'])) + echo "Invalid parameters passed.."; + + # Load the plugin + $file = $VAR['plugin']; + include_once(PATH_PLUGINS . 'affiliate/'. $file.'.php'); + eval ( '$_PLUGIN = new plgn_aff_'. strtoupper ( $file ) . ';' ); + + # Get each affiliate to be paid a commisson for this affiliate_commission ID + $db = &DB(); + $export=''; + if($arr_count = $this->plugin_affiliate_list($VAR['plugin'], $VAR['id'])) { + for($i=0; $iExecute($sql); + + # Run PLUGIN->commission to add the data to the return text + if($result && $result->RecordCount() && $result->fields['commission'] > 0) + $export .= $_PLUGIN->commission(round($result->fields['commission'],2), $arr_count[$i], $VAR['id']); + } + + # Run the PLUGIN->header method to set any req. headers. + $_PLUGIN->header(); + + # include detailed commission details? + $detail = ''; + if(is_callable($_PLUGIN->commission_detailed)) + { + $sql = "SELECT comm.affiliate_id, comm.invoice_id, comm.commission, invoice.date_orig, invoice.total_amt, account.first_name, account.last_name, affiliate.plugin_data from ".AGILE_DB_PREFIX."invoice_commission as comm + join ".AGILE_DB_PREFIX."invoice as invoice on (invoice.id=comm.invoice_id) + join ".AGILE_DB_PREFIX."account as account on (account.id=invoice.account_id) + join ".AGILE_DB_PREFIX."affiliate as affiliate on (affiliate.id=comm.affiliate_id) + WHERE + comm.affiliate_commission_id = ".$db->qstr($VAR['id'])." AND + comm.site_id = ".$db->qstr(DEFAULT_SITE)." + order by comm.affiliate_id"; + /* SELECT affiliate_id,sum(commission) as commission from ab_invoice_commission group by affiliate_id */ + $result = $db->Execute($sql); + + # Run PLUGIN->commission to add the data to the return text + if($result && $result->RecordCount()) $detail = $_PLUGIN->commission_detailed($result); + } + + # Print the data + echo $export . "\r\n\r\n". $detail; + + } else { + echo 'An error occurred: no affiliates are associated with this plugin'; + } + } + + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $this->associated_DELETE[] = Array ('table' => 'invoice_commission', 'field' => 'affiliate_commission_id'); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + + # Delete all associated discounts: + if(isset($VAR['id'])) + { + $id = $VAR['id']; + for($i=0; $iqstr($q)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + } + } + } + else + { + $id = $VAR['delete_id']; + $q = '%Affiliate Commission ID '. $id.'%'; + $db = &DB(); + $sql = "DELETE FROM ".AGILE_DB_PREFIX."discount WHERE + notes LIKE ".$db->qstr($q)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + } + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/affiliate_commission/affiliate_commission_construct.xml b/modules/affiliate_commission/affiliate_commission_construct.xml new file mode 100644 index 00000000..d4ce2b57 --- /dev/null +++ b/modules/affiliate_commission/affiliate_commission_construct.xml @@ -0,0 +1,66 @@ + + + + affiliate_commission + + affiliate_commission
+ + affiliate + + 0 + + date_orig + + 25 + + + date_begin + date_end + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I8 + date-now + + + I8 + date + + + I8 + date + + + F + + + X2 + + + X2 + + + L + + + + + id,site_id,date_orig,date_begin,date_end,commissions,notes_admin,notes_affiliate,status + id,site_id,date_orig,date_begin,date_end,commissions,notes_admin,notes_affiliate,status + id,site_id + id,site_id,date_orig,date_begin,date_end,commissions,notes_admin,notes_affiliate,status + id,site_id,date_orig,date_begin,date_end,commissions,notes_admin,notes_affiliate,status + + + 0 +
diff --git a/modules/affiliate_commission/affiliate_commission_install.xml b/modules/affiliate_commission/affiliate_commission_install.xml new file mode 100644 index 00000000..6cd1e34a --- /dev/null +++ b/modules/affiliate_commission/affiliate_commission_install.xml @@ -0,0 +1,41 @@ + + + affiliate_commission + affiliate + + 1 + affiliate + + + + + add + + 1 + + + update + + + delete + + + view + + + search + + 1 + + + search_form + + + search_show + + + export + + + + \ No newline at end of file diff --git a/modules/affiliate_template/affiliate_template.inc.php b/modules/affiliate_template/affiliate_template.inc.php new file mode 100644 index 00000000..613616e5 --- /dev/null +++ b/modules/affiliate_template/affiliate_template.inc.php @@ -0,0 +1,125 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class affiliate_template +{ + + # Open the constructor for this mod + function affiliate_template() + { + # name of this module: + $this->module = "affiliate_template"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> diff --git a/modules/affiliate_template/affiliate_template_construct.xml b/modules/affiliate_template/affiliate_template_construct.xml new file mode 100644 index 00000000..34a90956 --- /dev/null +++ b/modules/affiliate_template/affiliate_template_construct.xml @@ -0,0 +1,85 @@ + + + + affiliate_template + + affiliate_template
+ + affiliate + + 0 + + name + + 25 + + + + I4 + 1 + 1 + + + I4 + 1 + + + C(32) + + + X2 + array + + + L + + + C(32) + 2 + 32 + any + + + X2 + + + I4 + 1 + 2 + numeric + + + F + 1 + 12 + float + + + L + + + X2 + array + + + L + + + X2 + array + + + I4 + + + + + id,site_id,affiliate_plugin,avail_campaign_id,status,name,notes,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods + id,site_id,affiliate_plugin,avail_campaign_id,status,name,notes,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods + id,site_id,affiliate_plugin,avail_campaign_id,status,name,notes,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods + id,site_id,affiliate_plugin,avail_campaign_id,status,name,notes,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods + id,site_id,affiliate_plugin,avail_campaign_id,status,name,notes,max_tiers,commission_minimum,new_commission_type,new_commission_rate,recurr_commission_type,recurr_commission_rate,recurr_max_commission_periods + + + 0 +
diff --git a/modules/affiliate_template/affiliate_template_install.xml b/modules/affiliate_template/affiliate_template_install.xml new file mode 100644 index 00000000..edd2e2f6 --- /dev/null +++ b/modules/affiliate_template/affiliate_template_install.xml @@ -0,0 +1,35 @@ + + + affiliate_template + affiliate + + 1 + affiliate + + + + + delete + + + view + + 1 + + + update + + + add + + 1 + + + search + + + search_show + + + + \ No newline at end of file diff --git a/modules/affiliate_template/affiliate_template_install_data.xml b/modules/affiliate_template/affiliate_template_install_data.xml new file mode 100644 index 00000000..f8be3d1d --- /dev/null +++ b/modules/affiliate_template/affiliate_template_install_data.xml @@ -0,0 +1,21 @@ + + + + 1 + 1 + ACCOUNT_DISCOUNT + + 1 + Default + 1 + 10 + 1 + + 1 + + 5 + + + 1 + + \ No newline at end of file diff --git a/modules/asset/asset.inc.php b/modules/asset/asset.inc.php new file mode 100644 index 00000000..3732e04e --- /dev/null +++ b/modules/asset/asset.inc.php @@ -0,0 +1,182 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class asset +{ + var $module = "asset"; + + /* check availibility */ + function available($assetPoolId, $qty=1) { + $db=&DB(); + $rs = $db->Execute($sql=sqlSelect($db,"asset","id","(status=0 or status is null) and pool_id=::$assetPoolId::")); + if($rs && $rs->RecordCount() >= $qty) + return true; + else + return false; + } + + /* assign a asset to a specific service id from a specific asset pool */ + function assign($serviceId, $assetPoolId) { + // check if any available + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"asset","id,asset","(status=0 or status is null) and pool_id=::$assetPoolId::","",1)); + if($rs && $rs->RecordCount()) { + $id = $rs->fields['id']; + $asset = $rs->fields['asset']; + $fields=Array('service_id'=>$serviceId, 'status'=>1, 'date_last'=>time()); + $db->Execute($sql=sqlUpdate($db,"asset",$fields,"id = $id")); + return $asset; + } + return false; + } + + /** assign a known asset */ + function assignKnown($serviceId, $assetId) { + $fields=Array('service_id'=>$serviceId, 'status'=>1, 'date_last'=>time()); + $db=&DB(); + $sql=sqlUpdate($db,"asset",$fields,"id = ::$assetId::"); + $db->Execute($sql); + } + + /* un-assign a specific asset */ + function unAssign($assetId) { + $db=&DB(); + $db->Execute($sql="UPDATE ".AGILE_DB_PREFIX."asset SET status='0',date_last='".time()."',service_id='0' WHERE id='$assetId'"); + return true; + } + + /* un-assign all assets for a specific service */ + function unAssignAll($serviceId) { + $db=&DB(); + $db->Execute($sql="UPDATE ".AGILE_DB_PREFIX."asset SET status='0',date_last='".time()."',service_id='0' WHERE service_id='$serviceId'"); + return true; + } + + + /* import assets */ + function import($VAR) { + global $C_debug; + if(empty($VAR['asset_pool_id'])) { + $C_debug->alert("No asset pool specified"); + return; + } + + $db =& DB(); + if (is_uploaded_file($_FILES['datafile']['tmp_name'])) { + # Got a file to import + $fp = fopen($_FILES['datafile']['tmp_name'],"r"); + if ($fp) { + $counter = 0; $skipped = 0; + while (!feof($fp)) { + $line = fgets($fp,128); + $cols=explode(",", $line); + if(!empty($cols[0])) { + $fields = Array( + 'date_orig'=>time(), + 'date_last'=>time(), + 'status'=>0, + 'service_id'=>0, + 'pool_id'=> $VAR['asset_pool_id'], + 'asset'=>@$cols[0], + 'misc'=>@$cols[1]); + $db->Execute( sqlInsert($db, "asset", $fields) ); + $counter++; + } else { + $skipped++; + } + } + $C_debug->alert("Imported $counter new Asset(s) and skipped $skipped Asset(s)!"); + } else { + $C_debug->alert('Unable to fopen the file sent.'); + } + } else { + $C_debug->alert('Unable to process the uploaded file.'); + } + } + + function construct() { + $this->xml_construct = PATH_MODULES . $this->module . "/" . $this->module . "_construct.xml"; + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + function add($VAR) { + $this->construct(); + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + function view($VAR) { + $this->construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + function update($VAR) { + $this->construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + function delete($VAR) { + $this->construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + function search_form($VAR) { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + function search($VAR) { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + function search_show($VAR) { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/asset/asset_construct.xml b/modules/asset/asset_construct.xml new file mode 100644 index 00000000..b3e061e1 --- /dev/null +++ b/modules/asset/asset_construct.xml @@ -0,0 +1,64 @@ + + + asset + asset
+ + 0 + asset + 35 + + + + I8 + 1 + + + I4 + + + I8 + date-now + + + I8 + date-now + + + L + + + I8 + + + I4 + asset_pool + name + any + + + C(128) + 1 + 128 + + + C(255) + + + + + id,site_id,date_orig,date_last,status,service_id,pool_id,asset,misc + id,site_id,date_last,status,service_id,pool_id,asset,misc + id,site_id,date_orig,date_last,status,service_id,pool_id,asset,misc + id,site_id,date_orig,date_last,status,service_id,pool_id,asset,misc + id,site_id,date_orig,date_last,status,service_id,pool_id,asset,misc + + + + id,site_id + pool_id + service_id + asset + + + 0 +
\ No newline at end of file diff --git a/modules/asset/asset_install.xml b/modules/asset/asset_install.xml new file mode 100644 index 00000000..d053a374 --- /dev/null +++ b/modules/asset/asset_install.xml @@ -0,0 +1,47 @@ + + + + asset + asset + Manage assets that can be assigned to services and maintain their availibility status + 1 + + asset_pool + + + + + add + %%:add + 1 + + + update + + + delete + + + view + core:search&module=%%&_escape=1 + 1 + + + search + %%:search_form + 1 + + + search_form + + + search_show + + + import + %%:import + 1 + + + + \ No newline at end of file diff --git a/modules/asset/generator.php b/modules/asset/generator.php new file mode 100644 index 00000000..88498dcb --- /dev/null +++ b/modules/asset/generator.php @@ -0,0 +1,49 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/* +USAGE: + +url/to/modules/asset/generator.php?prefix=MyPrefix&start=1&end=100 + +Where prefix a text prefix (defaults to asset- ) +Where start is the start of the count +Where end is the end of the count + +Paste to a text file and save for loading into the asset import tool. + +*/ + +$prefix='asset-'; +$start=0; +$end=1000; + +@$prefix = $_GET['prefix']; +@$start = $_GET['start']; +@$end = $_GET['end']; + +echo "
";
+
+while($start < $end) {
+	echo $prefix.$start."\r\n";
+	$start++;
+}
+
+?>
\ No newline at end of file
diff --git a/modules/asset_invoice/asset_invoice.inc.php b/modules/asset_invoice/asset_invoice.inc.php
new file mode 100644
index 00000000..387c200d
--- /dev/null
+++ b/modules/asset_invoice/asset_invoice.inc.php
@@ -0,0 +1,209 @@
+ 
+ * @package AgileBill
+ * @version 1.4.93
+ */
+	
+class asset_invoice
+{	
+	/** get menu of asset pools */
+	function main($var) {
+		
+		$db=&DB();
+		$p=AGILE_DB_PREFIX;
+		$rs = $db->Execute("select id,name from {$p}asset_pool");
+		if($rs && $rs->RecordCount()) {		
+			global $smarty;
+			$pools=array();
+			while(!$rs->EOF) {
+				array_push($pools, $rs->fields);
+				$rs->MoveNext();
+			}
+			$smarty->assign('pools', $pools);		
+		} 
+	}
+	
+	/** show pending invoices */
+	function invoice($v) {
+		
+		// verify pool
+		if(empty($v['pool_id'])) 
+			return false;
+		else 
+			$pool_id = $v['pool_id'];
+			
+		$db=&DB();
+		$p=AGILE_DB_PREFIX;
+ 
+		// get all products ids set for manual assignment or this pool
+		$prodIds=array();
+		$prod = $db->Execute("select id,prod_plugin_data from {$p}product 
+				WHERE prod_plugin = 1 and prod_plugin_file = 'ASSET'");
+		if($prod && $prod->RecordCount()) {
+			while(!$prod->EOF) { 
+				@$d = unserialize($prod->fields['prod_plugin_data']);
+				
+				// is this asset pool
+				if(!empty($d['AssetPool']) && $d['AssetPool'] == $pool_id) {
+					
+					array_push($prodIds, $prod->fields['id']);
+				
+				// is manual enabled	
+				} elseif(!empty($d['manual']) && $d['manual'] == '1') {
+					
+					array_push($prodIds, $prod->fields['id']);					
+				} 
+				$prod->MoveNext();
+			}
+		} 
+		
+		if(count($prodIds)==0) {
+			echo '
No products defined for the selected asset pool or manual assignment.
'; + return false; + } + + $rs = $db->Execute($sql="select distinct a.*, + b.first_name, b.last_name, b.city, b.state, b.zip from {$p}invoice a + join {$p}account b on (a.account_id = b.id) + WHERE + a.billing_status = 1 AND a.process_status <> 1 AND a.refund_status <> 1 + AND a.id in + ( select c.invoice_id from {$p}invoice_item c where + c.product_id + in (".implode(',', $prodIds).") + ) "); + if($rs && $rs->RecordCount()) { + $invoices=array(); + global $smarty; + while(!$rs->EOF) { + + /** select invoice items */ + $rs2 = $db->Execute("select distinct a.id,a.product_id,a.sku,a.quantity, b.name + from {$p}invoice_item a + left join {$p}product_translate b on (a.product_id=b.product_id and language_id='".DEFAULT_LANGUAGE."') + where a.invoice_id = {$rs->fields['id']} + and a.product_id in (".implode(',', $prodIds).") + "); + + $itemsJs = ''; + if($rs2 && $rs2->RecordCount()) { + $i=0; + $jname = 'items_'. $rs->fields['id']; + while(!$rs2->EOF) { + + $itemsJs .= "{$jname}[{$i}] = {'id':{$rs2->fields['id']}, 'value':0}; \r\n"; + + $rs->fields['items'][] = $rs2->fields; + $rs2->MoveNext(); + $i++; + } + } + $rs->fields['itemsJs'] = $itemsJs; + + array_push($invoices, $rs->fields); + $rs->MoveNext(); + } + $smarty->assign('invoices', $invoices); + + /** get available assets for this category */ + $rs = $db->Execute("select id,asset as name from {$p}asset where status <> 1 and pool_id = ".$db->qstr($pool_id)); + if($rs && $rs->RecordCount()) { + $assets=array(); + while(!$rs->EOF) { + array_push($assets, $rs->fields); + $rs->MoveNext(); + } + $smarty->assign('assets', $assets); + } + } + } + + /** define asset ids for services and approve invoice */ + function assign($v) { + + @$id = $v['invoice_id']; + @$items = $v['items']; + + /** input valid? */ + if(empty($id) || empty($items) || !is_array($items)) { + echo 'Invalid data passed'; + return false; + } + + $db=&DB(); + $p=AGILE_DB_PREFIX; + + // validate all items set + foreach ($items as $key=>$item) { + if(empty($item) || $item=='0') { + echo 'All items must be assigned'; + return false; + } + + // validate that asset is available + $assetRs=$db->Execute("select a.id,a.asset,b.name as poolName from {$p}asset a, {$p}asset_pool b where a.pool_id=b.id and a.status <> 1 and a.id = ".$db->qstr($item)); + if(!$assetRs || !$assetRs->RecordCount()) { + echo "Asset $item is already assigned or non-existant!"; + return false; + } else { + $assets[] = array('item'=>$key, 'value'=>$item, 'asset'=> $assetRs->fields['asset'], 'poolname'=>$assetRs->fields['poolName'],); + } + } + + // loop through each line item and update the product_attr_cart field + foreach ($assets as $asset) { + + $item = $asset['item']; + $value = $asset['value']; + $name = $asset['asset']; + $pool = $asset['poolname']; + + $s = $db->GetOne($sql="select product_attr_cart from {$p}invoice_item where id = ".$db->qstr($item)." and invoice_id = ".$db->qstr($id) ); + if(empty($s)) { + $s['AssetId']=$value; + } else { + $s = unserialize($s); + $s['AssetId']=$value; + } + + @$ss=serialize($s); + + /** formatting for invoice view */ + $old=''; + $oldAttr = $db->Execute("select product_attr from {$p}invoice_item where id = ".$db->qstr($item)." and invoice_id = ".$db->qstr($id) ); + if($oldAttr && $oldAttr->RecordCount()) $old = $oldAttr->fields['product_attr']; + $product_attr = "{$pool}=={$name} (ID: {$value})\r\n".$old; + + /** update invoice */ + $db->Execute("update {$p}invoice_item set product_attr=".$db->qstr($product_attr).", product_attr_cart=".$db->qstr($ss)." where id = ".$db->qstr($item)." and invoice_id = ".$db->qstr($id) ); + + /** update service if exists */ + $db->Execute("update {$p}service set prod_attr=".$db->qstr($product_attr).", prod_attr_cart=".$db->qstr($ss)." where invoice_item_id = ".$db->qstr($item)." and invoice_id = ".$db->qstr($id) ); + } + + // process invoice => service + require_once(PATH_MODULES.'invoice/invoice.inc.php'); + $inv = new invoice(); + $result = $inv->approveInvoice(array('id'=>$id),&$inv); + + if($result) + echo 'true'; + else + echo 'Error occurred while approving invoice.'; + } +} +?> \ No newline at end of file diff --git a/modules/asset_invoice/asset_invoice_construct.xml b/modules/asset_invoice/asset_invoice_construct.xml new file mode 100644 index 00000000..7ee8e5c3 --- /dev/null +++ b/modules/asset_invoice/asset_invoice_construct.xml @@ -0,0 +1,21 @@ + + + asset_invoice + asset_invoice + asset_invoice
+ asset + 0 + name + 35 + + + I4 + 1 + + + C(32) + + + 0 + 0 +
\ No newline at end of file diff --git a/modules/asset_invoice/asset_invoice_install.xml b/modules/asset_invoice/asset_invoice_install.xml new file mode 100644 index 00000000..9b998523 --- /dev/null +++ b/modules/asset_invoice/asset_invoice_install.xml @@ -0,0 +1,27 @@ + + + + asset_invoice + asset_invoice
+ asset + Assign assets to pending invoices + 1 + asset + +
+ + + + search + %%:main + 1 + + + invoice + + + assign + + + +
\ No newline at end of file diff --git a/modules/asset_invoice/auth.inc.php b/modules/asset_invoice/auth.inc.php new file mode 100644 index 00000000..62620684 --- /dev/null +++ b/modules/asset_invoice/auth.inc.php @@ -0,0 +1,27 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +$auth_methods = Array +( + Array ('module' => 'asset_invoice', 'method' => 'main'), + Array ('module' => 'asset_invoice', 'method' => 'invoice'), + Array ('module' => 'asset_invoice', 'method' => 'assign') +); +?> \ No newline at end of file diff --git a/modules/asset_pool/asset_pool.inc.php b/modules/asset_pool/asset_pool.inc.php new file mode 100644 index 00000000..aad4d3a5 --- /dev/null +++ b/modules/asset_pool/asset_pool.inc.php @@ -0,0 +1,91 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class asset_pool +{ + # Open the constructor for this mod + function construct() + { + $this->table = 'asset_pool'; + $this->module = 'asset_pool'; + $this->xml_construct = PATH_MODULES . $this->module . "/" . $this->module . "_construct.xml"; + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + function add($VAR) + { + $this->construct(); + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + function view($VAR) + { + $this->construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + function update($VAR) + { + $this->construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + function delete($VAR) + { + $this->construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + function search($VAR) + { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + function search_show($VAR) + { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/asset_pool/asset_pool_construct.xml b/modules/asset_pool/asset_pool_construct.xml new file mode 100644 index 00000000..d0e10ad0 --- /dev/null +++ b/modules/asset_pool/asset_pool_construct.xml @@ -0,0 +1,33 @@ + + + asset_pool + asset_pool + asset_pool
+ asset + 0 + name + 35 + +
id,site_id
+
+ + + I4 + 1 + + + I4 + + + C(32) + + + + id,site_id,name + id,site_id,name + id,site_id,name + id,site_id,name + id,site_id,name + + 0 +
\ No newline at end of file diff --git a/modules/asset_pool/asset_pool_install.xml b/modules/asset_pool/asset_pool_install.xml new file mode 100644 index 00000000..e3dbd414 --- /dev/null +++ b/modules/asset_pool/asset_pool_install.xml @@ -0,0 +1,38 @@ + + + + asset_pool + asset_pool
+ asset + Manage multiple pools of assets + 1 + asset + +
+ + + + add + %%:add + 1 + + + update + + + search + + + search_show + + + delete + + + view + core:search&module=%%&_escape=1 + 1 + + + +
\ No newline at end of file diff --git a/modules/blocked_email/blocked_email.inc.php b/modules/blocked_email/blocked_email.inc.php new file mode 100644 index 00000000..54db2a47 --- /dev/null +++ b/modules/blocked_email/blocked_email.inc.php @@ -0,0 +1,146 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class blocked_email +{ + + # Open the constructor for this mod + function blocked_email() + { + # name of this module: + $this->module = "blocked_email"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + ############################## + ## IS EMAIL BLOCKED? ## + ############################## + function is_blocked($email) + { + @$dom = split('@', $email); + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'blocked_email WHERE + email = ' . $db->qstr($email) .' OR + email = ' . $db->qstr($dom[1]) .' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + return false; + } + return true; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/blocked_email/blocked_email_construct.xml b/modules/blocked_email/blocked_email_construct.xml new file mode 100644 index 00000000..c3ae6841 --- /dev/null +++ b/modules/blocked_email/blocked_email_construct.xml @@ -0,0 +1,59 @@ + + + + blocked_email + + blocked_email
+ + + + 0 + + email + + 25 + + + email + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I8 + date-now + + + I8 + date-now + + + C(128) + 1 + 128 + any + + + X2 + + + + + id,site_id,date_orig,date_last,email,notes + id,site_id,date_orig,date_last,email,notes + id,site_id,date_orig,date_last,email,notes + id,site_id,date_orig,date_last,email,notes + id,site_id,date_orig,date_last,email,notes + + + + +
diff --git a/modules/blocked_email/blocked_email_install.xml b/modules/blocked_email/blocked_email_install.xml new file mode 100644 index 00000000..2cd5a4c7 --- /dev/null +++ b/modules/blocked_email/blocked_email_install.xml @@ -0,0 +1,42 @@ + + + blocked_email + setup + + 1 + + + + + search + + + 1 + + + view + + + 1 + + + add + + 1 + + + delete + + + update + + + search_form + + + search_show + + + + + \ No newline at end of file diff --git a/modules/blocked_ip/blocked_ip.inc.php b/modules/blocked_ip/blocked_ip.inc.php new file mode 100644 index 00000000..a6e20695 --- /dev/null +++ b/modules/blocked_ip/blocked_ip.inc.php @@ -0,0 +1,146 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class blocked_ip +{ + + # Open the constructor for this mod + function blocked_ip() + { + # name of this module: + $this->module = "blocked_ip"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + ############################## + ## IS IP BLOCKED? ## + ############################## + function is_blocked($ip) + { + $ip_full = $ip; + @$ip = split('\.', $ip_full); + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'blocked_ip WHERE + ip = ' . $db->qstr(@$ip[0]) . ' OR + ip = ' . $db->qstr(@$ip[0].'.'.@$ip[1]) . ' OR + ip = ' . $db->qstr(@$ip[0].'.'.@$ip[1].'.'.@$ip[2]) . ' OR + ip = ' . $db->qstr($ip_full) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + return false; + } + return true; + } + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/blocked_ip/blocked_ip_construct.xml b/modules/blocked_ip/blocked_ip_construct.xml new file mode 100644 index 00000000..8eea0590 --- /dev/null +++ b/modules/blocked_ip/blocked_ip_construct.xml @@ -0,0 +1,57 @@ + + + + blocked_ip + + blocked_ip
+ + + + 0 + + ip + + 25 + + + ip + + + + + I4 + 1 + + + I4 + 1 + + + I8 + date-time + + + I8 + + + C(128) + 1 + 128 + any + + + X2 + + + + + id,site_id,date_orig,date_last,ip,notes + id,site_id,date_orig,date_last,ip,notes + id,site_id,date_orig,date_last,ip,notes + id,site_id,date_orig,date_last,ip,notes + id,site_id,date_orig,date_last,ip,notes + + + + +
diff --git a/modules/blocked_ip/blocked_ip_install.xml b/modules/blocked_ip/blocked_ip_install.xml new file mode 100644 index 00000000..ce97c4a4 --- /dev/null +++ b/modules/blocked_ip/blocked_ip_install.xml @@ -0,0 +1,42 @@ + + + blocked_ip + setup + + 1 + + + + + search + + + 1 + + + view + + + 1 + + + add + + 1 + + + delete + + + update + + + search_form + + + search_show + + + + + \ No newline at end of file diff --git a/modules/campaign/auth.inc.php b/modules/campaign/auth.inc.php new file mode 100644 index 00000000..cff58579 --- /dev/null +++ b/modules/campaign/auth.inc.php @@ -0,0 +1,27 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +$auth_methods = Array +( + Array ('module' => 'campaign', 'method' => 'display'), + Array ('module' => 'campaign', 'method' => 'click'), + Array ('module' => 'campaign', 'method' => 'affiliate') +); +?> \ No newline at end of file diff --git a/modules/campaign/campaign.inc.php b/modules/campaign/campaign.inc.php new file mode 100644 index 00000000..3a1cab8b --- /dev/null +++ b/modules/campaign/campaign.inc.php @@ -0,0 +1,701 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class campaign +{ + # Open the constructor for this mod + function campaign() + { + # name of this module: + $this->module = "campaign"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + ############################## + ## CLICK ## + ############################## + function click($VAR) + { + ### Set the forward URL + if(!empty($VAR['caid'])) + { + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'campaign WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(@$VAR['caid']); + $result = $db->Execute($sql); + if (strlen($result->fields['url']) >= 1) $url = $result->fields['url']; + } + if(empty($url)) $url = URL; + + echo ''; + + ### LOG the click + if(!isset($VAR['_log']) && !empty($VAR['caid'])) + { + if(isset($VAR['file'])) + $file_no = $VAR['file']; + else + $file_no = '1'; + $count_field= 'clicked'.$file_no; + $count = $result->fields[$count_field] + 1; + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'campaign SET + '.$count_field.' = ' . $db->qstr($count) . ' WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(@$VAR['caid']); + $result = $db->Execute($sql); + } + } + + + + ############################## + ## DISPLAY ## + ############################## + function display($VAR) + { + + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'campaign WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(@$VAR['id']); + $result = $db->Execute($sql); + if(isset($VAR['file'])) + $file_no = $VAR['file']; + else + $file_no = '1'; + $file = PATH_FILES . 'campaign_' . $VAR['id'] . '_' . $file_no .'.dat'; + $type = 'type'.$file_no; + $name = 'file'.$file_no; + $count_field= 'served'.$file_no; + $count = $result->fields[$count_field] + 1; + + if($result->RecordCount() > 0) + { + ### Open the file + if (@$file=fopen($file, 'r')) + { + ### Display the correct headers: + header ("Content-type: " . $result->fields[$type]); + header ("Content-Disposition: inline; filename=" . $result->fields[$name]); + header ("Content-Description: PHP/INTERBASE Generated Data" ); + fpassthru($file); + ### Increment the file + if(!isset($VAR['_log'])) + { + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'campaign SET + '.$count_field.' = ' . $db->qstr($count) . ' WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(@$VAR['id']); + $result = $db->Execute($sql); + } + exit; + } + } + echo 'Sorry, the campaign or required file does not exist!'; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + global $_FILES; + + + # Validate the files + for($i=1; $i<=12; $i++) { + if(isset($_FILES['upload_file'.$i]) && $_FILES['upload_file'.$i]['size'] > 0) { + $VAR['campaign_type'.$i] = $_FILES['upload_file'.$i]['type']; + $VAR['campaign_file'.$i] = $_FILES['upload_file'.$i]['name']; + } + } + + + ## Attempt to add the record: + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $campaign_id = $db->add($VAR, $this, $type); + + + ### Copy the files & delete temp files + if($campaign_id > 0) { + for($i=1; $i<=12; $i++) { + if(isset($_FILES['upload_file'.$i]) && $_FILES['upload_file'.$i]['size'] > 0) + { + if(!copy($_FILES['upload_file'.$i]['tmp_name'], PATH_FILES . 'campaign_'.$campaign_id.'_'.$i.'.dat')) + { + ### ERROR: + } + + #unlink any temp files + unlink($_FILES['upload_file'.$i]['tmp_name']); + } + } + } + } + + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $smart = $db->view($VAR, $this, $type); + + #print_r($smart); + for($i=0;$ireferred_accounts($smart[$i]['id']); + + # Invoices referred + $inv = $this->referred_invoices($smart[$i]['id']); + $smart[$i]['invoices_referred'] = $inv[0]; + $smart[$i]['invoices_revenue'] = round( $inv[1], 2); + + # total impressions & clicks: + $impressions_total=0; + $clicks_total=0; + for($ii=1; $ii<=12; $ii++) + { + $impressions_total += $smart[$i]["served".$ii]; + $clicks_total += $smart[$i]["clicked".$ii]; + + if(empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii])) + $smart[$i]["show".$ii] = false; + else + $smart[$i]["show".$ii] = true; + } + $smart[$i]['impressions_total'] = $impressions_total; + $smart[$i]['clicks_total'] = $clicks_total; + + + # Impr. percentage, Clicks percentage, CTR + $ctr_count = 0; + $ctr_amt = 0; + for($ii=1; $ii<=12; $ii++) + { + # Impr. percentage + if( $smart[$i]["show".$ii] ) + { + $impressions_percentage = $smart[$i]["served".$ii] / $impressions_total; + $smart[$i]['impressions_percentage'.$ii] = "(".round($impressions_percentage*100)."%)"; + } else { + $smart[$i]['impressions_percentage'.$ii] = ''; + } + + # Clicks percentage + if( $smart[$i]["show".$ii] ) { + @$clicks_percentage = ($smart[$i]["clicked".$ii] / $clicks_total); + $smart[$i]['clicks_percentage'.$ii] = "(".round($clicks_percentage*100)."%)"; + } else { + $smart[$i]['clicks_percentage'.$ii] = ''; + } + + # Cost + if( $smart[$i]["show".$ii] ) { + $impressions_percentage = $smart[$i]["served".$ii] / $impressions_total; + $smart[$i]['cost'.$ii] = round($budget * $impressions_percentage, 2); + } else { + $smart[$i]['cost'.$ii] = "0"; + } + + # CTR + if( $smart[$i]["show".$ii] ) { + $ctr = ( $smart[$i]["clicked".$ii] / $smart[$i]["served".$ii] ) * 100; + if($ctr < 0) + $smart[$i]['ctr'.$ii] = round($ctr).'%'; + else + $smart[$i]['ctr'.$ii] = round($ctr,1).'%'; + $ctr_count++; + $ctr_amt += $ctr; + } else { + $smart[$i]['ctr'.$ii] = "0%"; + $ctr_count++; + } + } + + # CTR Avg: + if($ctr_count > 0) + $smart[$i]['ctr_avg'] = round( $ctr_amt / $ctr_count, 2) .'%'; + else + $smart[$i]['ctr_avg'] = "0%"; + + + # CPC Avg: + if($clicks_total > 0) { + $cpc_avg = $budget / $clicks_total; + if($cpc_avg < .1) + $smart[$i]['cpc_avg'] = round($cpc_avg,3); + else + $smart[$i]['cpc_avg'] = round($cpc_avg,2); + } else { + $smart[$i]['cpc_avg'] = 0; + } + + # CPI Avg: + if($impressions_total > 0) { + $cpi_avg = $budget / $impressions_total; + if($cpi_avg < .1) + $smart[$i]['cpi_avg'] = round($cpi_avg,3); + else + $smart[$i]['cpi_avg'] = round($cpi_avg,2); + } else { + $smart[$i]['cpi_avg'] = 0; + } + + # Cost per Conversion: + if($inv[0] > 0) + $smart[$i]['conversion_cost'] = round($budget / $inv[0], 2); + else + $smart[$i]['conversion_cost'] = 0; + + # Avg sales amount: + if($inv[0] > 0 && $budget > 0) + $smart[$i]['invoice_avg'] = round($inv[1] / $inv[0], 2); + else + $smart[$i]['invoice_avg'] = 0; + + # ROI + if($inv[0] > 0 && $budget > 0) + $smart[$i]['roi'] = round(($inv[1] / $budget) * 100).'%'; + else + $smart[$i]['roi'] = '---'; + + # Impression to Buy Ratio + if($inv[0] > 0 && $impressions_total > 0) { + $ratio = round($impressions_total / $inv[0]); + $percent = round( ($inv[0] / $impressions_total) * 100, 3); + $smart[$i]['impr_to_buy'] = $ratio . ' / 1    ('.$percent.'%)'; + } else { + $smart[$i]['impr_to_buy'] = '---'; + } + + # Click-thru to Buy ratio + if($inv[0] > 0 && $clicks_total > 0) { + $ratio = round($clicks_total / $inv[0]); + $percent = round( ($inv[0] / $clicks_total) * 100, 2); + $smart[$i]['click_to_buy'] = $ratio . ' / 1    ('.$percent.'%)'; + } else { + $smart[$i]['click_to_buy'] = '---'; + } + } + + global $smarty; + $smarty->assign('campaign', $smart); + } + + ### Get the number of referred accounts: + function referred_accounts ($id) { + $dba = new CORE_database; + $db = &DB(); + $sql = $dba->sql_select("account","id","campaign_id = $id", false, $db); + $rs = $db->Execute($sql); + return $rs->RecordCount(); + } + + ### Get the number of referred invoices: + function referred_invoices ($id) { + $dba = new CORE_database; + $db = &DB(); + $sql = $dba->sql_select("invoice","id,total_amt","campaign_id = $id", false, $db); + $rs = $db->Execute($sql); + if ($rs->RecordCount() == 0) { + return Array(0,0); + } else { + $total = 0; + while(!$rs->EOF) { + $total += $rs->fields['total_amt']; + $rs->MoveNext(); + } + } + return Array($rs->RecordCount(), $total); + } + + ############################## + ## AFFILIATE VIEW ## + ############################## + function affiliate($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + # Validate the files + for($i=1; $i<=12; $i++) { + if(isset($_FILES['upload_file'.$i]) && $_FILES['upload_file'.$i]['size'] > 0) { + $VAR['campaign_type'.$i] = $_FILES['upload_file'.$i]['type']; + $VAR['campaign_file'.$i] = $_FILES['upload_file'.$i]['name']; + } + } + + # Store the record + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $rs = $db->update($VAR, $this, $type); + + ### Copy the files + if($rs) { + for($i=1; $i<=12; $i++) { + if(isset($_FILES['upload_file'.$i]) && $_FILES['upload_file'.$i]['size'] > 0) + { + if(!copy($_FILES['upload_file'.$i]['tmp_name'], PATH_FILES . 'campaign_'.$VAR['campaign_id'].'_'.$i.'.dat')) + { + ### ERROR: + } + } + } + } + } + + ############################## + ## DELETE ADDs ## + ############################## + function delete_add($VAR) + { + $field = 'file'.$VAR['file']; + $db = &DB(); + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'campaign + SET + '.$field.' = \'\' + WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($VAR["campaign_id"]); + $result = $db->Execute($sql); + + error_reporting(0); + if(!unlink(PATH_FILES . 'campaign_'.$VAR["campaign_id"].'_' . $VAR['file'] . '.dat')) + { + global $C_debug; + $C_debug->error('file.inc.php','delete', PATH_FILES . 'file_'.$id[$i]. + '.dat does not exist for deletion. File could not be deleted.'); + } + # Restore the proper error level + $error_reporting_eval = 'error_reporting('.ERROR_REPORTING.');'; + eval($error_reporting_eval); + } + + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = &DB(); + $id = $this->table . '_id'; + + # generate the list of ID's + $id_list = ''; + $ii=0; + + if(isset($VAR["delete_id"])) + { + $id = split(',',$VAR["delete_id"]); + } + elseif (isset($VAR["id"])) + { + $id = split(',',$VAR["id"]); + } + + for($i=0; $iqstr($id[$i]) . " "; + $ii++; + } + else + { + $id_list .= " OR id = " . $db->qstr($id[$i]) . " "; + $ii++; + } + } + } + + + if($ii>0) + { + # generate the full query + $q = "DELETE FROM + ".AGILE_DB_PREFIX."$this->table + WHERE + $id_list + AND + site_id = '" . DEFAULT_SITE . "'"; + # execute the query + $result = $db->Execute($q); + + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('campaign.inc.php','delete', $db->ErrorMsg()); + } + else + { + for($i=0; $ivalue["CORE"]["module_name"] = $C_translate->translate('name',$this->module,""); + $message = $C_translate->translate('alert_delete_ids',"CORE",""); + $C_debug->alert($message); + + } + } + } + + + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $smart = $db->search_show($VAR, $this, $type); + + for($i=0; $ireferred_invoices($smart[$i]['id']); + $smart[$i]['invoices_referred'] = $inv[0]; + $smart[$i]['invoices_revenue'] = $inv[1]; + @$smart[$i]['invoice_avg'] = $inv[1] / $inv[0]; + + # total impressions & clicks: + $impressions_total=0; + $clicks_total=0; + for($ii=1; $ii<=12; $ii++) + { + $impressions_total += $smart[$i]["served".$ii]; + $clicks_total += $smart[$i]["clicked".$ii]; + + if(empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii]) && empty($smart[$i]["served".$ii])) + $smart[$i]["show".$ii] = false; + else + $smart[$i]["show".$ii] = true; + } + $smart[$i]['impressions_total'] = $impressions_total; + $smart[$i]['clicks_total'] = $clicks_total; + + + # Impr. percentage, Clicks percentage, CTR + $ctr_count = 0; + $ctr_amt = 0; + for($ii=1; $ii<=12; $ii++) + { + # CTR + if( $smart[$i]["show".$ii] ) { + $ctr = ( $smart[$i]["clicked".$ii] / $smart[$i]["served".$ii] ) * 100; + if($ctr < 0) + $smart[$i]['ctr'.$ii] = round($ctr).'%'; + else + $smart[$i]['ctr'.$ii] = round($ctr,1).'%'; + $ctr_count++; + $ctr_amt += $ctr; + } else { + $smart[$i]['ctr'.$ii] = "0%"; + $ctr_count++; + } + } + + # CTR Avg: + if($ctr_count > 0) + $smart[$i]['ctr_avg'] = round( $ctr_amt / $ctr_count, 2) .'%'; + else + $smart[$i]['ctr_avg'] = "0%"; + + + # CPC Avg: + if($clicks_total > 0) { + $cpc_avg = $budget / $clicks_total; + if($cpc_avg < .1) + $smart[$i]['cpc_avg'] = round($cpc_avg,3); + else + $smart[$i]['cpc_avg'] = round($cpc_avg,2); + } else { + $smart[$i]['cpc_avg'] = 0; + } + + # CPI Avg: + if($impressions_total > 0) { + $cpi_avg = $budget / $impressions_total; + if($cpi_avg < .1) + $smart[$i]['cpi_avg'] = round($cpi_avg,3); + else + $smart[$i]['cpi_avg'] = round($cpi_avg,2); + } else { + $smart[$i]['cpi_avg'] = 0; + } + + # Cost per Conversion: + if($inv[0] > 0 && $budget > 0) + $smart[$i]['conversion_cost'] = round($budget / $inv[0], 2); + else + $smart[$i]['conversion_cost'] = 0; + + # ROI + if($inv[0] > 0 && $budget > 0) + $smart[$i]['roi'] = round(($inv[1] / $budget) * 100).'%'; + else + $smart[$i]['roi'] = '---'; + } + + global $smarty; + $smarty->assign('campaign', $smart); + + + } + ############################## + ## SEARCH EXPORT ## + ############################## + function search_export($VAR) + { + # require the export class + require_once (PATH_CORE . "export.inc.php"); + + # Call the correct export function for inline browser display, download, email, or web save. + if($VAR["format"] == "excel") + { + $type = "export_excel"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_excel($VAR, $this, $type); + } + + else if ($VAR["format"] == "pdf") + { + $type = "export_pdf"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_pdf($VAR, $this, $type); + } + + else if ($VAR["format"] == "xml") + { + $type = "export_xml"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_xml($VAR, $this, $type); + } + + else if ($VAR["format"] == "csv") + { + $type = "export_csv"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_csv($VAR, $this, $type); + } + + else if ($VAR["format"] == "tab") + { + $type = "export_tab"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_tab($VAR, $this, $type); + } + } +} +?> \ No newline at end of file diff --git a/modules/campaign/campaign_construct.xml b/modules/campaign/campaign_construct.xml new file mode 100644 index 00000000..7dc57573 --- /dev/null +++ b/modules/campaign/campaign_construct.xml @@ -0,0 +1,233 @@ + + + + campaign + + campaign
+ + + + 0 + + name + + 25 + + + + I4 + 1 + 1 + + + I4 + 1 + + + I8 + date-now + + + I8 + date-now + + + C(16) + date + + + C(16) + date + + + L + 30 + + + C(128) + 1 + 128 + any + 1 + 30 + + + X2 + + + F + 30 + + + F + 30 + + + C(128) + 1 + 128 + any + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + C(128) + + + C(128) + + + I4 + + + I4 + + + I4 + + + C(128) + + + + + id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url + id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url + id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url + id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url + id,site_id,date_orig,date_last,date_start,date_expire,status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12,url + status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12 + status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12 + status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12 + status,name,description,budget,target_conversion,file1,type1,served1,clicked1,file2,type2,served2,clicked2,file3,type3,served3,clicked3,file4,type4,served4,clicked4,file5,type5,served5,clicked5,file6,type6,served6,clicked6,file7,type7,served7,clicked7,file8,type8,served8,clicked8,file9,type9,served9,clicked9,file10,type10,served10,clicked10,file11,type11,served11,clicked11,file12,type12,served12,clicked12 + + + 0 +
diff --git a/modules/campaign/campaign_install.xml b/modules/campaign/campaign_install.xml new file mode 100644 index 00000000..1bd773e4 --- /dev/null +++ b/modules/campaign/campaign_install.xml @@ -0,0 +1,60 @@ + + + campaign + affiliate + + 1 + + + + + add + + 1 + + + update + + + delete + + + view + + 1 + + + search + + 1 + + + search_form + + + + search_show + + + + delete_add + + + + search_export + + + export_excel + + + export_pdf + + + export_csv + + + export_tab + + + + \ No newline at end of file diff --git a/modules/campaign/index.php b/modules/campaign/index.php new file mode 100644 index 00000000..a685fbb3 --- /dev/null +++ b/modules/campaign/index.php @@ -0,0 +1,97 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +ob_start(); + +# Required includes: +require_once('../../config.inc.php'); +require_once(PATH_ADODB . 'adodb.inc.php'); +require_once(PATH_CORE . 'database.inc.php'); +require_once(PATH_CORE . 'vars.inc.php'); + +$C_debug = new CORE_debugger; +$C_vars = new CORE_vars; +$VAR = $C_vars->f; + + +$db = &DB(); +$sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'campaign WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(@$VAR['id']); +$result = $db->Execute($sql); + +if( !empty($VAR['file']) ) { + $file_no = $VAR['file']; +} +else +{ + # random file: + $last = $result->fields['last_served']; + if(empty($last)) $last = 1; + $next = false; + + for($i=1; $i<=12; $i++) { + if(!empty($result->fields["file".$i]) && !$next) { + if($i == $last) + $next = true; + } else if(!empty($result->fields["file".$i]) && $next) { + $file_no = $i; + $i = 20; + } + } +} + +if(empty($file_no)) + $file_no = '1'; + +$file = PATH_FILES . 'campaign_' . $VAR['id'] . '_' . $file_no .'.dat'; +$type = 'type'.$file_no; +$name = 'file'.$file_no; +$count_field= 'served'.$file_no; +$count = $result->fields[$count_field] + 1; +if($result->RecordCount() > 0) +{ + ### Open the file + if (@$file=fopen($file, 'r')) + { + ### Display the correct headers: + header ("Content-type: " . $result->fields[$type]); + header ("Content-Disposition: inline; filename=" . $result->fields[$name]); + header ("Content-Description: PHP/INTERBASE Generated Data" ); + fpassthru($file); + + ### Increment the file + if(!isset($VAR['_log'])) + { + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'campaign SET + '.$count_field.' = ' . $db->qstr($count) . ', + last_served = ' . $db->qstr($file_no) . ' + WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(@$VAR['id']); + $result = $db->Execute($sql); + } + exit; + } +} +echo 'Sorry, the campaign or required file does not exist!'; + +ob_end_flush(); +?> \ No newline at end of file diff --git a/modules/cart/auth.inc.php b/modules/cart/auth.inc.php new file mode 100644 index 00000000..156c29b7 --- /dev/null +++ b/modules/cart/auth.inc.php @@ -0,0 +1,29 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +$auth_methods = Array +( + Array ('module' => 'cart', 'method' => 'add'), + Array ('module' => 'cart', 'method' => 'view'), + Array ('module' => 'cart', 'method' => 'delete'), + Array ('module' => 'cart', 'method' => 'changeqty'), + Array ('module' => 'cart', 'method' => 'update') +); +?> \ No newline at end of file diff --git a/modules/cart/cart.inc.php b/modules/cart/cart.inc.php new file mode 100644 index 00000000..42ddd030 --- /dev/null +++ b/modules/cart/cart.inc.php @@ -0,0 +1,717 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class cart +{ + var $account_id; + var $session_id; + + /** + * How many associated product levels to check for products to grant? + * + * @var int + */ + var $assoc_grant_levels=5; + var $module='cart'; + + /** + * Admin View Cart Contents + */ + function admin_view($VAR) { + if(!empty($VAR['account_id'])) { + $this->account_id = $VAR['account_id']; + } else { + return false; + } + $this->admin_view = true; + $this->view($VAR, $this); + } + + /** + * Admin Add Cart Contents + */ + function admin_add($VAR) { + if(!empty($VAR['account_id'])) { + $this->account_id = $VAR['account_id']; + $db = &DB(); + $rs = $db->Execute(sqlSelect($db,"session","id","account_id=$this->account_id")); + if($rs && $rs->RecordCount()) { + $this->session_id = $rs->fields['id']; + } else { + $this->session_id = SESS; + } + } else { + return false; + } + $this->add($VAR, $this); + } + + /** + * Admin change cart qty + */ + function admin_changeqty($VAR) { + if(!empty($VAR['account_id'])) { + $this->account_id = $VAR['account_id']; + } else { + return false; + } + $this->admin = true; + $this->changeqty($VAR, $this); + } + + /** + * Change the quantity of an item + */ + function changeqty($VAR) { + if(empty($this->account_id)) $this->account_id = SESS_ACCOUNT; + if(empty($this->session_id)) $this->session_id = SESS; + + @$id = $VAR['id']; + @$qty = $VAR['qty']; + if ($id <= 0 ) return; + + $db = &DB(); + if ($qty == '0') { + # Product Plugin Level deletion + $cartid = & $db->Execute($sql=sqlSelect($db,"cart","*","id=::{$id}:: AND session_id = ::{$this->session_id}::")); + if($cartid) $product = & $db->Execute($sql=sqlSelect($db,"product","*","id=::{$cartid->fields['product_id']}::")); + if(!empty($product->fields['prod_plugin']) && !empty($product->fields['prod_plugin_data'])) { + $prodplgfile = PATH_PLUGINS.'product/'. $product->fields['prod_plugin_file'] . '.php'; + if(is_file($prodplgfile)) { + include_once(PATH_PLUGINS.'product/'. $product->fields['prod_plugin_file'] . '.php'); + eval('$prodplg = new plgn_prov_'. $product->fields['prod_plugin_file'] .';'); + if(is_object($prodplg)) { + if(is_callable(array($prodplg, 'delete_cart'))) { + $prodplg->delete_cart($VAR, $cartid->fields); + } + } + } + } + + # delete main cart items & subitems: + $sql=''; + if(empty($this->admin)) $sql = "AND session_id = ::{$this->session_id}::"; + $rs = & $db->Execute($sql=sqlDelete($db,"cart","(id=::{$id}:: OR cart_parent_id=::{$id}:: ) $sql")); + + global $smarty; + $smarty->assign('js', false); + return false; + } + + # update the quantity: + if(!eregi("^[0-9]{1,5}$",$qty)) $qty = 1; + if($qty < 1) $qty = 1; + + if(!$this->admin) $sql_extra = " AND session_id=::$this->session_id::"; else $sql_extra=''; + if($VAR["type"] == 1) { + $fields=Array('quantity'=>$qty); + $db->Execute($sql=sqlUpdate($db,"cart",$fields,"id=::$id:: $sql_extra")); + } else if ($VAR["type"] == 2) { + $fields=Array('recurr_schedule'=>$VAR["schedule"]); + $db->Execute($sql=sqlUpdate($db,"cart",$fields,"id=::$id:: $sql_extra")); + } else if ($VAR["type"] == 3) { + # change domain term + $fields=Array('domain_term'=>$VAR["term"]); + $db->Execute($sql=sqlUpdate($db,"cart",$fields,"id=::$id:: $sql_extra")); + } + + # get the product id: + $result = $db->Execute(sqlSelect($db,"cart","*","id=$id $sql_extra","cart_type,date_orig")); + + # get the product details: + $product = $db->Execute(sqlSelect($db,"product","*","id={$result->fields["product_id"]}")); + + if($result->fields["cart_type"] == "2") { + # domain name, get pricing + include_once(PATH_MODULES.'host_tld/host_tld.inc.php'); + $tldObj=new host_tld; + $tldprice = $tldObj->price_tld_arr($result->fields["domain_tld"], $result->fields["host_type"], false, false, false, $this->account_id); + $qty = $result->fields["domain_term"]; + $base_price = $tldprice[$qty]; + $setup_price = 0; + } else if($result->fields["cart_type"] == "3") { + # ad-hoc, get price + $base_price = $result->fields["ad_hoc_amount"] * $result->fields["quantity"]; + $setup_price = $result->fields["ad_hoc_setup"] * $result->fields["quantity"]; + } else { + include_once(PATH_MODULES.'product/product.inc.php'); + $productObj=new product; + + # get pricing for this product: + $prod_price = $productObj->price_prod($product->fields, $result->fields["recurr_schedule"], $this->account); + $setup_price = $prod_price["setup"] * $result->fields["quantity"]; + $base_price = $prod_price["base"] * $result->fields["quantity"]; + + # get pricing for any attributes: + $attr_price = $productObj->price_attr($product->fields, $result->fields["product_attr"], $result->fields["recurr_schedule"], $this->account); + $setup_price += ($attr_price["setup"] * $result->fields["quantity"]); + $base_price += ($attr_price["base"] * $result->fields["quantity"]); + + # get the qty + $qty = $result->fields["quantity"]; + } + + # set the smarty fields: + global $smarty; + $smarty->assign('qty', $qty); + $smarty->assign('base', $base_price); + $smarty->assign('setup', $setup_price); + $smarty->assign('js', true); + return; + } + + /** Get cart contents and return adodb rs */ + function get_contents(&$db) { + $sql = 'SELECT DISTINCT c.* FROM ' . AGILE_DB_PREFIX . 'cart as c '; + if(!empty($this->account_id)) { + $sql .= "LEFT JOIN ".AGILE_DB_PREFIX."session AS s ON ( s.site_id = ".DEFAULT_SITE." AND s.account_id = {$this->account_id} ) + WHERE ( c.account_id = {$this->account_id} OR c.session_id = s.id ) "; + } else { + $sql .= " WHERE c.session_id = ". $db->qstr(SESS); + $this->account_id = SESS_ACCOUNT; + } + $sql .= ' AND c.site_id = ' .DEFAULT_SITE. ' AND ( c.cart_parent_id = 0 OR c.cart_parent_id IS NULL ) ORDER BY c.cart_type, c.date_orig'; + $result = $db->Execute($sql); + return $result; + } + + /** + * Convert cart contents into invoice object & get smarty data + */ + function put_contents_invoice(&$db, &$result, &$invoice, &$smart, $taxObj=false, $discountObj=false) { + + // get parent cart items + $i=0; + while(!$result->EOF) + { + $id=$result->fields['id']; + $this->addInvoiceItem($id,$result,$invoice,$smart,$i, false, false, $taxObj, $discountObj); + // ad hoc + if($result->fields["cart_type"] == 3 ) { + $smart[$i]["price"] = $invoice->invoice_item["$id"]["total_amt"]; + // domain + } if($result->fields["cart_type"] == 2 ) { + $smart[$i]["price"] = $invoice->invoice_item["$id"]["total_amt"]; + $smart[$i]["tld_arr"] = $invoice->tld_arr["$id"]; + $smart[$i]["sku"] = 'DOMAIN-'. strtoupper($result->fields["host_type"]); + // product + } else { + @$smart[$i]["price"] = $invoice->price_arr["$id"]; + } + + // get the product attributes + $smart[$i]["attr"]=''; + if(!empty($invoice->invoice_item[$id]['product_attr_cart'])) { + @$attrib = explode("\r\n", $invoice->invoice_item[$id]['product_attr_cart']); + foreach($attrib as $attr) { + $attributei = explode('==', $attr); + if(!empty($attributei[0]) && !empty($attributei[1])) $smart[$i]["attr"] .= "" . $attributei[0] . " : ". $attributei[1] . "
"; + } + } + + // get all children of this item + $ii=0; + $resultassoc = $db->Execute(sqlSelect($db,"cart","*","cart_parent_id=::{$result->fields["id"]}:: AND id!=::{$result->fields["id"]}::")); + if($resultassoc && $resultassoc->RecordCount()) { + while(!$resultassoc->EOF) { + $id=$resultassoc->fields["id"]; + $this->addInvoiceItem($id, $resultassoc, $invoice, $smart, $i, $ii, true, $taxObj, $discountObj); + // domain + if($resultassoc->fields["cart_type"] == 2 ) { + $smart[$i]["assoc"][$ii]["price"] = $invoice->invoice_item["$id"]["total_amt"]; + $smart[$i]["assoc"][$ii]["tld_arr"] = $invoice->tld_arr["$id"]; + $smart[$i]["assoc"][$ii]["sku"] = 'DOMAIN-'. strtoupper($result->fields["host_type"]); + } + $resultassoc->MoveNext(); + } + } + $result->MoveNext(); + $i++; + } + } + + /** + * View Cart Contents + */ + function view($VAR) { + global $smarty; + $db = &DB(); + + // get cart contents RS + $result=$this->get_contents($db); + if($result->RecordCount() == 0) { + $smarty->assign('result', '0'); + return false; + } + + // init invoice object + include_once(PATH_MODULES.'invoice/invoice.inc.php'); + $invoice = new invoice; + $invoice->initNew(0); + $invoice->taxable=false; + $invoice->discount=false; + + $smart=''; + $this->put_contents_invoice($db, $result, $invoice, $smart); + + $smarty->assign('results', count($invoice->invoice_item)); + $smarty->assign('cart', $smart); + } + + /** + * Run a cart item through the invoice class to retrieve totals, discounts, taxes, attributes, etc. + * + * @param int $id + * @param array $result + * @param object $invoice + * @param array $smart + * @param int $i + * @param int $assoc + */ + function addInvoiceItem($id, &$result, &$invoice, &$smart, $i, $ii=false, $assoc=false, $taxObj=false, $discountObj=false) { + + $sku=false; + $price_base=false; + $price_setup=false; + $discount_amt=false; + $taxable='verify'; + if($result->fields["cart_type"]==3) $taxable = $result->fields['ad_hoc_taxable']; + if(!empty($result->fields['ad_hoc_sku'])) $sku=$result->fields['ad_hoc_sku']; + if(!empty($result->fields['ad_hoc_amount'])) $price_base = $result->fields['ad_hoc_amount']; + if(!empty($result->fields['ad_hoc_setup'])) $price_base = $result->fields['ad_hoc_setup']; + if(!empty($result->fields['ad_hoc_discount'])) $discount_amt = $result->fields['ad_hoc_discount']; + if(!empty($result->fields['product_attr']) && !is_array($result->fields['product_attr'])) $attributes=unserialize($result->fields['product_attr']); + + + $invoice->addItem( + $id, + $taxObj, + $discountObj, + $result->fields['cart_type'], + $taxable, + $result->fields['service_id'], + false, + $result->fields['product_id'], + @$attributes, + $result->fields['ad_hoc_name'], + $sku, + $result->fields['quantity'], + $price_base, + $price_setup, + $discount_amt, + $result->fields['recurr_schedule'], + false, + false, + $result->fields['domain_name'], + $result->fields['domain_tld'], + $result->fields['domain_term'], + $result->fields['host_type'] + ); + + if(!$assoc) + @$smart[$i] = $result->fields; + else + @$smart[$i]["assoc"][$ii] = $result->fields; + + if(!$assoc) + @$smart[$i]["product"] = $invoice->product["$id"]; + else + @$smart[$i]["assoc"][$ii]["product"] = $invoice->product["$id"]; + + if(!$assoc) + @$smart[$i]["price_base"] = $invoice->invoice_item["$id"]["price_base"]; + else + @$smart[$i]["assoc"][$ii]["price_base"] = $invoice->invoice_item["$id"]["price_base"]; + + if(!$assoc) + @$smart[$i]["price_setup"] = $invoice->invoice_item["$id"]["price_setup"]; + else + @$smart[$i]["assoc"][$ii]["price_setup"] = $invoice->invoice_item["$id"]["price_setup"]; + + } + + /** + * Start add to cart process + */ + function add($VAR) { + # set the current account + if(empty($this->account_id)) $this->account_id = SESS_ACCOUNT; + if(empty($this->session_id)) $this->session_id = SESS; + + # Determine the type to be added to the domain: (domain or product) + if(!empty($VAR["product_id"])) + { + if($this->validate_product($VAR, $VAR["product_id"], $this->account_id)) { + if(!empty($VAR["domain_type"])) { + # Add hosting / domain + $this->product_add_host($VAR); + return true; + } else { + # Standard product (no hosting or domain) + $this->product_add($VAR); + return true; + } + } + } else if (!empty($VAR["domain_name"]) && !empty($VAR["domain_tld"])) { + # Add Domain only: + if(is_array($VAR["domain_name"])) { + for($i=0;$ivalidate_domain($VAR["domain_name"][$i], $VAR["domain_tld"][$i])) { + $this->domain_add($VAR["domain_name"]["$i"], $VAR["domain_tld"]["$i"], @$VAR["host_type"]["$i"], @$VAR["domain_term"]["$i"]); + } + } + } else { + if($this->validate_domain($VAR["domain_name"], $VAR["domain_tld"])) { + $this->domain_add($VAR["domain_name"], $VAR["domain_tld"], @$VAR["host_type"], @$VAR["domain_term"]); + } + } + } + } + + /** + * Add a domain name to cart + * + * @param string $domain + * @param string $tld + * @param int $type + * @param int $term + */ + function domain_add($domain, $tld, $type, $term=false) { + if(empty($type)) return false; + $db = &DB(); + if(!$term || empty($term) || !is_numeric($term)) { + # get the default term for this domain: + $rs = $db->Execute(sqlSelect($db,"host_tld","default_term_new","name=::$tld::")); + if($rs === false || empty($rs->fields['default_term_new'])) $term = 1; else $term = $rs->fields['default_term_new']; + } + // insert into cart + $fields=Array('date_orig'=>time(), 'session_id'=>$this->session_id, 'account_id'=>$this->account_id, + 'cart_type'=>2, 'host_type'=>$type, 'domain_term'=>$term, 'domain_name'=>$domain, 'domain_tld'=>$tld ); + $db->Execute(sqlInsert($db,"cart",$fields)); + } + + /** + * Add an ad-hoc line item to the cart + */ + function ad_hoc($VAR) { + $db = &DB(); + if(!empty($VAR['account_id'])) { + $rs = $db->Execute( sqlSelect($db,"session","id","account_id=::{$VAR['account_id']}::")); + if($rs && !empty($rs->fields['id'])) { + $this->session_id = $rs->fields['id']; + } else { + $this->session_id = SESS; + } + } else { + return false; + } + + if(empty($VAR["ad_hoc_sku"]) || empty($VAR["ad_hoc_name"]) || $VAR["ad_hoc_amount"] == "") { + global $C_debug,$C_translate; + $C_debug->alert( $C_translate->translate('ad_hoc_err', 'cart','')); + return false; + } + + if(empty($VAR["quantity"])) $qty = 1; else $qty = $VAR["quantity"]; + if(empty($VAR["ad_hoc_taxable"])) $VAR["ad_hoc_taxable"] = 0; + + # Attribs: (ad_hoc_attr_var & ad_hoc_attr_val) + for($i=0;$itime(), 'session_id'=>$this->session_id, 'account_id'=>$VAR['account_id'], 'product_attr'=>$attrib, + 'cart_type'=>3, 'quantity'=>$qty, 'ad_hoc_sku'=>$VAR["ad_hoc_sku"], 'ad_hoc_name'=>$VAR["ad_hoc_name"], + 'ad_hoc_amount'=>$VAR["ad_hoc_amount"], 'ad_hoc_taxable'=>$VAR["ad_hoc_taxable"]); + $db->Execute(sqlInsert($db,"cart",$fields)); + } + + /** + * Add a product to the cart + */ + function product_add($VAR) { + if(empty($VAR["quantity"])) $qty = 1; else $qty = $VAR["quantity"]; + if(!empty($VAR["attr"])) @$attr = serialize($VAR["attr"]); else $attr = ""; + + // Create the Main DB Record: + $db = &DB(); + $fields=Array( 'date_orig'=>time(), 'session_id'=>$this->session_id, 'account_id'=>@$VAR['account_id'], 'product_attr'=>$attr, + 'cart_type'=>0, 'quantity'=>$qty, 'product_id'=>$VAR["product_id"], 'recurr_schedule'=>@$VAR["recurr_schedule"], 'service_id'=>@$VAR["service_id"]); + $db->Execute(sqlInsert($db,"cart",$fields)); + } + + /** + * Add an assoc required product + * + * @param int $product_id + */ + function product_req_add($product_id) { + $db = &DB(); + $id = $db->GenID(AGILE_DB_PREFIX . "" . 'cart_id'); + $fields=Array( 'date_orig'=>time(), 'session_id'=>$this->session_id, 'account_id'=>$this->account_id, 'product_attr'=>$attr, + 'cart_type'=>0, 'quantity'=>1, 'product_id'=>$product_id, 'recurr_schedule'=>@$VAR["recurr_schedule"]); + $db->Execute(sqlInsert($db,"cart",$fields)); + } + + /** + * Add a product to the cart + */ + function product_add_host($VAR) { + if(!empty($VAR["attr"])) @$attr = serialize($VAR["attr"]); else $attr = serialize(Array("")); + $db = &DB(); + $fields=Array( 'date_orig'=>time(), 'session_id'=>$this->session_id, 'account_id'=>@$VAR['account_id'], 'product_attr'=>$attr, + 'cart_type'=>1, 'quantity'=>1, 'product_id'=>$VAR["product_id"], 'recurr_schedule'=>@$VAR["recurr_schedule"], 'service_id'=>@$VAR["service_id"], + 'host_type'=>$VAR["domain_type"], 'domain_name'=>$VAR["domain_name"], 'domain_tld'=>$VAR["domain_tld"] ); + $id=sqlGenID($db,"cart"); + $db->Execute(sqlInsert($db,"cart",$fields, $id)); + + // Get the default domain registration length: + if ( $VAR["domain_type"] == "transfer" || $VAR["domain_type"] == "register" ) { + $domain_term = 1; + $result = $db->Execute(sqlSelect($db,"host_tld","default_term_new","name=::{$VAR["domain_tld"]}::")); + if(!empty($result->fields["default_term_new"])) $domain_term = $result->fields["default_term_new"]; + } + + // add child domain if register or transfer + if($VAR["domain_type"] == "transfer" || $VAR['domain_type'] == "register") { + $fields=Array( 'date_orig'=>time(), 'session_id'=>$this->session_id, 'account_id'=>@$VAR['account_id'], 'product_attr'=>$attr, + 'cart_type'=>2, 'quantity'=>1, 'host_type'=>$VAR["domain_type"], 'domain_name'=>$VAR["domain_name"], 'domain_tld'=>$VAR["domain_tld"], + 'domain_term'=>$domain_term, 'cart_parent_id'=> $id ); + $db->Execute(sqlInsert($db,"cart",$fields)); + } + } + + /** + * Validate A Domain + * + * @param string $domain + * @param string $tld + * @return bool + */ + function validate_domain($domain, $tld) { + # check that it is not already in the user's cart: + $db = &DB(); + $result = $db->Execute(sqlSelect($db,"cart","id","(session_id=::$this->session_id:: OR account_id=::".SESS_ACCOUNT."::) AND domain_name=:: AND domain_tld=::$tld::")); + if($result && $result->RecordCount()) { + global $C_debug, $C_translate; + $C_debug->alert($C_translate->translate('err_prod_already','cart','')); + return false; + } else { + return true; + } + } + + /** + * Validate A Product + * + * @param array $VAR + * @param int $product_id + * @param int $account_id + * @return bool + */ + function validate_product($VAR, $product_id, $account_id) + { + global $C_translate, $C_debug, $C_auth; + $db = &DB(); + + # can user add inactive items + if($C_auth->auth_method_by_name('invoice','add')) $active = ''; else $active = " AND active=1 "; + + # validate that product exists + $result = $db->Execute(sqlSelect($db,"product","*","id=::$product_id:: $active")); + if($result->RecordCount() == 0) { + $C_debug->alert($C_translate->translate('err_no_prod','cart','')); + return false; + } + + # check that product is not already in cart + if($result->fields['cart_multiple'] != "1" && empty($VAR['service_id'])) { + $rs = $db->Execute(sqlSelect($db,"cart","id","product_id=::$product_id:: AND session_id=::$this->session_id::")); + if($rs->RecordCount() > 0) { + $C_debug->alert($C_translate->translate('err_prod_already','cart','')); + return false; + } + } + + # Validate groups: + $groups = unserialize($result->fields['group_avail']); + $auth = false; + for($ii=0; $iiauth_group_by_id($groups[$ii])) { + $auth = true; + break; + } + } + if(!$auth) return false; + + + # Validate any required products: + if(!empty($result->fields["assoc_req_prod"])) + $reqarr = unserialize($result->fields["assoc_req_prod"]); else $reqarr = false; + $reqtype = $result->fields["assoc_req_prod_type"]; + $assoc = true; + + if(is_array($reqarr) && !empty($reqarr[0])) { + /* + if($reqtype == 0 && is_array($reqarr)) { + # ALL are required + for($i=0; $iassoc_prod($reqarr[$i])) { + $assoc = false; + + # Add the required product: + $this->product_req_add($reqarr[$i]); + } + } elseif ($reqtype == 1 && is_array($reqarr)) { + # ONE is required + $assoc = false; + for($i=0; $iassoc_prod($reqarr[$i])) { + $assoc = true; + $i = count( $reqarr ); + } else { + # add the required product: + $this->product_req_add($reqarr[$i]); + } + } + }*/ + + if(!SESS_LOGGED) { + $C_debug->alert($C_translate->translate('err_assoc_login','cart','')); + return false; + } + + $items='
'; + foreach($reqarr as $prod_id) { + $prodrs = $db->Execute(sqlSelect($db,"product_translate","*","product_id=$prod_id AND language_id = ::".SESS_LANGUAGE."::")); + if($prodrs && $prodrs->RecordCount()) { + $items .= "- {$prodrs->fields['name']}
"; + } + } + + $C_translate->value("cart","items", $items); + $msg = $C_translate->translate('err_assoc_req','cart',''); + if($reqtype == 0) + $C_debug->alert($msg . " ". $C_translate->translate('assoc_all','cart','')); + else + $C_debug->alert($msg ." ". $C_translate->translate('assoc_one','cart','')); + + return false; + } + + + # Product Plugin Level Validation + $product = $result; + if(!empty($product->fields['prod_plugin']) && !empty($product->fields['prod_plugin_data'])) { + $prodplgfile = PATH_PLUGINS.'product/'. $product->fields['prod_plugin_file'] . '.php'; + if(is_file($prodplgfile)) { + include_once(PATH_PLUGINS.'product/'. $product->fields['prod_plugin_file'] . '.php'); + eval('$prodplg = new plgn_prov_'. $product->fields['prod_plugin_file'] .';'); + if(is_object($prodplg)) { + if(is_callable(array($prodplg, 'validate_cart'))) { + $result = $prodplg->validate_cart($VAR, $product); + if($result === true) { } else { + $C_debug->alert($result); + return false; + } + } + } + } + } + + # Service upgrade + if(!empty($VAR['service_id'])) { + # validate account logged in + if(SESS_LOGGED == false) return false; + $dbm = new CORE_database; + + # validate account owns service, service is modifyable, active, not canceled, and exists + $rs = $db->Execute( $sql = $dbm->sql_select( "service", "*", "recur_modify = 1 AND active = 1 AND ( suspend_billing IS NULL OR suspend_billing = 0 ) AND account_id = ".SESS_ACCOUNT." AND id = {$VAR['service_id']}", "", $db ) ); + if($rs === false || $rs->RecordCount() == 0) return false; + + # validate selected product_id is in allowed modify array for selected service + if(empty($rs->fields['product_id'])) return false; + $product_id = $rs->fields['product_id']; + $prod = $db->Execute( $dbm->sql_select( "product", "*", "id = $product_id", "", $db ) ); + if($prod === false || $prod->RecordCount() == 0) return false; + $arr = unserialize( $prod->fields['modify_product_arr'] ); + if(!is_array($arr) || count($arr) == 0 || empty($arr[0])) return false; + $do = false; + foreach($arr as $pid) if( $pid == $VAR['product_id'] ) { $do = true; break; } + if(!$do) return false; + + # make sure this service is not in the cart + $sql = 'DELETE FROM ' . AGILE_DB_PREFIX . 'cart WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND service_id = ' . $db->qstr($VAR['service_id']) ; + $rs = $db->Execute($sql); + + # make sure this service has no outstanding invoices: + $p = AGILE_DB_PREFIX; + $sql = "SELECT DISTINCT {$p}invoice.id, {$p}invoice_item.id + FROM {$p}invoice,{$p}invoice_item + WHERE {$p}invoice.site_id = ".DEFAULT_SITE." AND {$p}invoice_item.site_id = ".DEFAULT_SITE." + AND {$p}invoice_item.service_id = ".$db->qstr($VAR['service_id'])." + AND {$p}invoice_item.invoice_id = {$p}invoice.id AND {$p}invoice.billing_status != 1"; + $rs = $db->Execute($sql); + if($rs->RecordCount() > 0) { + echo "Invoice(s) in unpaid status for selected service ID {$VAR['service_id']}, cannot upgrade"; + return false; + } + } + return true; + } + + + /** + * Validate Associated Prod Req. + * + * @param int $product_id + * @return bool + */ + function assoc_prod($product_id) + { + # check if required assoc product is in cart + $db = &DB(); + $p = AGILE_DB_PREFIX; + $rs = $db->Execute(sqlSelect($db,"cart","*","product_id=::$product_id:: AND session_id=::".SESS."::")); + if($rs->RecordCount() > 0) { + return true; + } else if (SESS_LOGGED) { + # check if required assoc product has been purchased + $sql ="SELECT {$p}invoice.account_id, {$p}invoice_item.product_id + FROM {$p}invoice_item LEFT JOIN {$p}invoice ON {$p}invoice_item.invoice_id = {$p}invoice.id + WHERE {$p}invoice.account_id = " . $db->qstr(SESS_ACCOUNT) . " + AND {$p}invoice_item.product_id = " . $db->qstr( $product_id ) . " + AND {$p}invoice.process_status = " . $db->qstr( "1" ) . " + AND {$p}invoice.site_id = " . $db->qstr(DEFAULT_SITE) . " + AND {$p}invoice_item.site_id = " . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + $rs->RecordCount(); + if($rs->RecordCount() > 0) return true; + } + return false; + } +} +?> \ No newline at end of file diff --git a/modules/cart/cart_construct.xml b/modules/cart/cart_construct.xml new file mode 100644 index 00000000..cd1b93fa --- /dev/null +++ b/modules/cart/cart_construct.xml @@ -0,0 +1,107 @@ + + + + cart + + cart
+ + + + 0 + + date_orig + + 25 + + + account_id + session_id + cart_parent_id + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I8 + + + I8 + + + C(32) + + + I4 + + + I4 + + + X2 + array + + + I4 + + + C(16) + + + I4 + + + C(16) + + + I4 + + + C(128) + + + C(16) + + + I4 + + + I4 + + + C(16) + + + C(128) + + + C(255) + + + F + + + F + + + F + + + L + + + I8 + + + + 0 + + 0 +
diff --git a/modules/cart/cart_install.xml b/modules/cart/cart_install.xml new file mode 100644 index 00000000..8a771682 --- /dev/null +++ b/modules/cart/cart_install.xml @@ -0,0 +1,23 @@ + + + cart + cart + + + + + + admin_view + + + admin_add + + + admin_changeqty + + + ad_hoc + + + + \ No newline at end of file diff --git a/modules/charge/charge.inc.php b/modules/charge/charge.inc.php new file mode 100644 index 00000000..d58fa962 --- /dev/null +++ b/modules/charge/charge.inc.php @@ -0,0 +1,1115 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class charge +{ + var $xmlrpc=false; + + # Open the constructor for this mod + function charge_construct() + { + # name of this module: + $this->module = "charge"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + function sweep_daily() { + $this->sweep('0'); + } + + function sweep_weekly() { + $this->sweep('1'); + } + + function sweep_monthly() { + $this->sweep('2'); + } + + function sweep_quarterly() { + $this->sweep('3'); + } + + function sweep_semi_annually() { + $this->sweep('4'); + } + + function sweep_annually() { + $this->sweep('5'); + } + + ############################## + ## API ## + ############################## + function sweep($type) + { + $this->charge_construct(); + + include_once(PATH_MODULES.'account_billing/account_billing.inc.php'); + $account_billing = new account_billing; + + include_once(PATH_MODULES . 'tax/tax.inc.php'); + $taxObj = new tax; + + include_once(PATH_MODULES . 'discount/discount.inc.php'); + + $db = &DB(); + $sql = "SELECT DISTINCT + ".AGILE_DB_PREFIX."charge.id, + ".AGILE_DB_PREFIX."charge.account_id, + ".AGILE_DB_PREFIX."charge.service_id, + ".AGILE_DB_PREFIX."charge.amount, + ".AGILE_DB_PREFIX."charge.taxable, + ".AGILE_DB_PREFIX."charge.attributes, + ".AGILE_DB_PREFIX."charge.quantity, + ".AGILE_DB_PREFIX."charge.product_id, + ".AGILE_DB_PREFIX."charge.description, + ".AGILE_DB_PREFIX."account.affiliate_id, + ".AGILE_DB_PREFIX."account.reseller_id, + ".AGILE_DB_PREFIX."account.country_id, + ".AGILE_DB_PREFIX."account.currency_id, + ".AGILE_DB_PREFIX."account.state + FROM + ".AGILE_DB_PREFIX."charge + LEFT JOIN + ".AGILE_DB_PREFIX."account + ON + ".AGILE_DB_PREFIX."account.id = " . AGILE_DB_PREFIX."charge.account_id + WHERE + ".AGILE_DB_PREFIX."charge.site_id = " . $db->qstr(DEFAULT_SITE) . " + AND + ".AGILE_DB_PREFIX."account.site_id = " . $db->qstr(DEFAULT_SITE) . " + AND + ".AGILE_DB_PREFIX."charge.status = " . $db->qstr('0') ." + AND + ".AGILE_DB_PREFIX."charge.sweep_type = " . $db->qstr($type) ." + ORDER BY + ".AGILE_DB_PREFIX."charge.account_id"; + $rs = $db->Execute($sql); + if ($rs === false) { + global $C_debug; + $C_debug->error('charge.inc.php','charge :: sweep()', $db->ErrorMsg(). "\r\n\r\n". $sql); + return false; + } + + $account_id = false; + $invoice_id = false; + $i = false; + $i_total = false; + + $invoice_count = 0; + $sweep_count = 0; + + while(!$rs->EOF) + { + if( $rs->fields['account_id'] != $account_id ) + { + $account_id = $rs->fields['account_id']; + $i=0; + $i_total = $this->count_account_charges($account_id, $rs->CurrentRow(), $rs); + + $sub_total = 0; + $taxable_amount = 0; + $this_discount_total = 0; + $tax_amt = 0; + $discount_amt = 0; + + # Start a new transaction + $trans = &DB(); + $trans->StartTrans(); + + # Start a new invoice + $invoice_id = $db->GenID(AGILE_DB_PREFIX . 'invoice_id'); + + # check for any discounts for the parent invoice or account_id (applied at checkout and should continue to be applied if recurring type discount) + $discountObj = new discount; + + # get parent invoice id if service specified (for discount checking) + $parent_invoice_id = false; + if($rs->fields['service_id']) { + $parentinv = $db->Execute(sqlSelect($db,"service","invoice_id","id={$rs->fields['service_id']}")); + if($parentinv && $parentinv->RecordCount()) { + $parent_invoice_id = $parentinv->fields['invoice_id']; + } + } + + # get available discounts to this account/service + $discountObj->available_discounts($account_id, 1, $parent_invoice_id); + } + + + + ########################### + ##### LINE ITEM ACTIONS ### + ########################### + + if( !empty($account_id) ) + { + ### Get the line item id + $invoice_item_id = $db->GenID(AGILE_DB_PREFIX . 'invoice_item_id'); + + ### Set the invoice item details: + $product_id = $rs->fields['product_id']; + if(!empty($product_id) && empty($this->product["$product_id"])) + { + $sql = "SELECT sku FROM ".AGILE_DB_PREFIX."product WHERE + id = " . $db->qstr($product_id) . " AND + site_id = " . $db->qstr(DEFAULT_SITE); + $prod = $db->Execute($sql); + if($prod->RecordCount() > 0) + { + $sku = $prod->fields['sku']; + $this->product["$product_id"] = $sku; + $product_attr = ''; + if(!empty($rs->fields['description'])) + $product_attr = "Description=={$rs->fields['description']}\r\n"; + $product_attr .= $rs->fields['attributes']; + } + else + { + $sku = $rs->fields['description']; + $this->product["$product_id"] = $sku; + $product_attr = $rs->fields['attributes']; + } + } elseif (!empty($this->product["$product_id"])) { + $sku = $this->product["$product_id"]; + $product_attr = $rs->fields['attributes']; + } else { + $sku = $rs->fields['description']; + $product_attr = $rs->fields['attributes']; + } + + $quantity = $rs->fields['quantity']; + $price_base = $rs->fields['amount']; + $item_total_amt = ($price_base * $quantity); + + // Calculate any recurring discounts for this account + $item_discount_amt = $discountObj->calc_all_discounts(1, $invoice_item_id, $rs->fields['product_id'], $item_total_amt, $account_id, $sub_total+$item_total_amt); + $item_total_amt -= $item_discount_amt; + $sub_total += $item_total_amt; + $discount_amt += $item_discount_amt; + + # calculate any taxes for this item + $item_tax_amt=0; + if($rs->fields['taxable']) { + $item_tax_arr = $taxObj->calculate($item_total_amt, $rs->fields['country_id'], $rs->fields['state']); + if(is_array($item_tax_arr)) foreach($item_tax_arr as $tx) $item_tax_amt += $tx['rate']; + $tax_amt += $item_tax_amt; + } + + ### Add line item to new invoice + $sql = "INSERT INTO ".AGILE_DB_PREFIX."invoice_item SET + id = ".$db->qstr( $invoice_item_id ) .", + site_id = ".$db->qstr( DEFAULT_SITE ).", + invoice_id = ".$db->qstr( $invoice_id ).", + account_id = ".$db->qstr( $account_id ).", + date_orig = ".$db->qstr( time() ).", + product_id = ".$db->qstr( $product_id ).", + sku = ".$db->qstr( $sku ).", + quantity = ".$db->qstr( $quantity ).", + item_type = ".$db->qstr( '0' ).", + product_attr = ".$db->qstr( $product_attr ).", + price_type = ".$db->qstr( '0' ).", + price_base = ".$db->qstr( $price_base ).", + price_setup = ".$db->qstr( 0 ) .", + tax_amt = ".$db->qstr($item_tax_amt) . ", + total_amt = ".$db->qstr($item_total_amt) . ", + discount_amt = ".$db->qstr($item_discount_amt); + $trans->Execute($sql); + + # Insert tax records + $taxObj->invoice_item($invoice_id, $invoice_item_id, $account_id, @$item_tax_arr); + + # Insert discount records + $discountObj->invoice_item($invoice_id, $invoice_item_id, $account_id); + + ### Update this charge status to billed + $sql = "UPDATE ".AGILE_DB_PREFIX."charge SET + status = ".$db->qstr( '1' ) ." + WHERE + site_id = ".$db->qstr( DEFAULT_SITE )." AND + id = ".$db->qstr( $rs->fields['id'] ) ; + $trans->Execute($sql); + $i++; + $sweep_count++; + } + + + + ####################### + ### INVOICE ACTIONS ### + ####################### + if($i_total == $i || $i == $rs->RecordCount()) + { + if( $invoice_id ) + { + ### Get the most recent billing id for this client: + if(!isset($billing_id["$account_id"])) + { + $billing_arr = $account_billing->default_billing($account_id); + $billing_id["$account_id"] = $billing_arr['billing_id']; + $checkout_plugin_id["$account_id"] = $billing_arr['checkout_plugin_id']; + } + + ### Affiliate & Reseller info: + $affiliate_id = $rs->fields['affiliate_id']; + $reseller_id = $rs->fields['reseller_id']; + $actual_billed_currency_id = $rs->fields['currency_id']; + + # calculate any taxes + @$total = $sub_total + $tax_amt; + + if($total <= 0) { + $process_status = 1; + $billing_status = 1; + } else { + $process_status = 0; + $billing_status = 0; + } + + ### Generate the invoice insert SQL: + $sql = "INSERT INTO ".AGILE_DB_PREFIX."invoice SET + id = ".$db->qstr($invoice_id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + date_last = ".$db->qstr(time()).", + process_status = ".$db->qstr($process_status).", + billing_status = ".$db->qstr($billing_status).", + print_status = ".$db->qstr('0').", + account_id = ".$db->qstr($account_id).", + account_billing_id = ".$db->qstr($billing_id["$account_id"]).", + affiliate_id = ".$db->qstr($affiliate_id).", + reseller_id = ".$db->qstr($reseller_id).", + checkout_plugin_id = ".$db->qstr($checkout_plugin_id["$account_id"]).", + tax_amt = ".$db->qstr($tax_amt).", + discount_amt = ".$db->qstr($discount_amt).", + actual_billed_currency_id = ".$db->qstr($actual_billed_currency_id).", + actual_billed_amt = ".$db->qstr('0').", + billed_currency_id = ".$db->qstr(DEFAULT_CURRENCY).", + billed_amt = ".$db->qstr('0').", + total_amt = ".$db->qstr($total).", + notice_count = ".$db->qstr('0').", + notice_max = ".$db->qstr(MAX_BILLING_NOTICE).", + notice_next_date = ".$db->qstr(time()).", + grace_period = ".$db->qstr(GRACE_PERIOD).", + due_date = ".$db->qstr(time()); + $trans->Execute($sql); + + ### Close this transaction + $trans->CompleteTrans(); + + $i_total = false; + $i = false; + $account_id = false; + $invoice_id = false; + $discount = false; + $cookie = false; + $invoice_count++; + } + } + $rs->MoveNext(); + } + + global $C_debug; + $C_debug->alert("Swept $sweep_count Charge(s) into $invoice_count Invoice(s)."); + return true; + } + + + + ### Get total charges for an account + function count_account_charges($account, $start_pos, &$rs) + { + $rs->Move($start_pos); + $i = 0; + while(!$rs->EOF) + { + if($rs->fields['account_id'] != $account) + { + $rs->Move($start_pos); + return $i; + } + $i++; + $rs->MoveNext(); + } + $rs->Move($start_pos); + return $i; + } + + + + ############################## + ## API ## + ############################## + function api($VAR) + { + $db = &DB(); + + # amount + if(@$VAR['amount'] <= 0) { + return $this->api_return(0,'','Invalid value supplied for the \'amount\' parameter, must be greater than 0'); + } else { + $amount = $VAR['amount']; + } + + # sweep_type + if(@$VAR['sweep_type'] <= 6) { + $sweep_type = $VAR['sweep_type']; + } else { + return $this->api_return(0,'','Invalid value supplied for the \'sweep_type\' parameter, must be 0-6'); + } + + # account_id OR service_id + if(empty($VAR['account_id']) && empty($VAR['service_id'])) { + return $this->api_return(0,'','Either the \'account_id\' or \'service_id\' parameter must be provided'); + } else { + + # check the account id + if(!empty($VAR['account_id'])) + { + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."account WHERE + id = " . $db->qstr($VAR['account_id']) . " OR + username = " . $db->qstr($VAR['account_id']) . " AND + site_id = " . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + if ($rs === false) { + global $C_debug; + $C_debug->error('charge.inc.php','charge :: api()', $db->ErrorMsg(). "\r\n\r\n". $sql); + } + if($rs->RecordCount() == 1) + { + $account_id = $rs->fields['id']; + } + else + { + return $this->api_return(0,'','The \'account_id\' value provided does not exist'); + } + } + + # check the service id + elseif(!empty($VAR['service_id'])) + { + $sql = "SELECT id,account_id FROM ".AGILE_DB_PREFIX."service WHERE + site_id = " . $db->qstr(DEFAULT_SITE) . " AND + id = " . $db->qstr($VAR['service_id']); + $rs = $db->Execute($sql); + if ($rs === false) { + global $C_debug; + $C_debug->error('charge.inc.php','charge :: api()', $db->ErrorMsg(). "\r\n\r\n". $sql); + } + if($rs->RecordCount() == 1) + { + $service_id = $VAR['service_id']; + $account_id = $rs->fields['account_id']; + } else { + return $this->api_return(0,'','The \'service_id\' value provided does not exist'); + } + } + } + + # taxable + if(empty($VAR['taxable'])) + $taxable = 0; + else + $taxable = $VAR['taxable']; + + # attributes + if(!empty($VAR['attributes'])) { + @$attributes = ereg_replace("@@", "\r\n", $VAR['attributes']); + @$attributes = ereg_replace("--", "==", $attributes); + } else { + $attributes = false; + } + + # quantity + if(empty($VAR['quantity'])) + $quantity = 1; + else + $quantity = $VAR['quantity']; + + # product id + if(empty($VAR['product_id'])) { + $product_id = false; + } else { + $product_id = $VAR['product_id']; + } + + # description + if(empty($VAR['description'])) { + $description = false; + } else { + $description = $VAR['description']; + } + + /* Start: SQL Insert Statement */ + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."charge WHERE id = -1"; + $rs = $db->Execute($sql); + + $id = $db->GenID(AGILE_DB_PREFIX . 'charge_id'); + $insert = Array ( 'id' => $id, + 'site_id' => DEFAULT_SITE, + 'date_orig' => time(), + 'status' => 0, + 'sweep_type' => $sweep_type, + 'account_id' => @$account_id, + 'service_id' => @$service_id, + 'product_id' => @$product_id, + 'amount' => $amount, + 'quantity' => $quantity, + 'taxable' => $taxable, + 'attributes' => $attributes, + 'description' => $description ); + $sql = $db->GetInsertSQL($rs, $insert); + $result = $db->Execute($sql); + if ($result === false) { + global $C_debug; + $C_debug->error('charge.inc.php','charge :: api()', $db->ErrorMsg(). "\r\n\r\n". $sql); + return $this->api_return(0,'','The SQL insert failed!'); + } + else + { + return $this->api_return(1,$id,''); + } + return true; + } + + + function api_return($status=0,$id='',$error='') + { + if(!$this->xmlrpc) { + echo "status=={$status}++charge_id={$id}++error=={$error}"; + } else { + $arr = array('status'=>$status, 'charge_id'=>$id, 'error'=> $error); + #print_r($arr); + return $arr; + } + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $this->charge_construct(); + if(!empty($VAR['attributes'])) + { + $attr = false; + for($i=0; $imethod["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $this->charge_construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $this->charge_construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $this->charge_construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $this->charge_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $this->charge_construct(); + + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + + $db = &DB(); + + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + + # set the search criteria array + $arr = $VAR; + + # loop through the submitted field_names to get the WHERE statement + $where_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + if($value != '') + { + $pat = "^" . $this->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value = $validate->convert($field, $value, $this->field["$field"]["convert"]); + } + + $where_list .= " WHERE ".AGILE_DB_PREFIX."charge.".$field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $this->module.'_'.$field; + $VAR['field_option']["$pat_field"]["$i_arr"]; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $this->field["$field"]["convert"]); + } + + + if($i_arr == 0) + { + $where_list .= " WHERE ".AGILE_DB_PREFIX."charge.".$field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + else + { + $where_list .= " AND ".AGILE_DB_PREFIX."charge.".$field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + } + else + { + $where_list .= " WHERE ".AGILE_DB_PREFIX."charge.".$field . " = " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + else + { + if($value != '') + { + $pat = "^" . $this->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value = $validate->convert($field, $value, $this->field["$field"]["convert"]); + } + + $where_list .= " AND ".AGILE_DB_PREFIX."charge.".$field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $this->module.'_'.$field; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $this->field["$field"]["convert"]); + } + + $where_list .= " AND ".AGILE_DB_PREFIX."charge.". $field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + else + { + $where_list .= " AND ".AGILE_DB_PREFIX."charge.". $field . " = ". $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + } + + # Code for attribute searches: + if(!empty($VAR['item_attributes'])) + { + $attr_arr = $VAR['item_attributes']; + for($ati=0; $atiqstr("%{$attr_arr[$ati]['0']}=={$attr_arr[$ati]['1']}%"); + } + } + } + + + #### finalize the WHERE statement + if($where_list == '') + $where_list .= ' WHERE '; + else + $where_list .= ' AND '; + + + # get limit type + if(isset($VAR['limit'])) + { + $limit = $VAR['limit']; + } + else + { + $limit = $this->limit; + } + + # get order by + if(isset($VAR['order_by'])) + { + $order_by = $VAR['order_by']; + } + else + { + $order_by = $this->order_by; + } + + $q = "SELECT ".AGILE_DB_PREFIX."charge.id FROM ".AGILE_DB_PREFIX."charge "; + $q .= $where_list ." ".AGILE_DB_PREFIX."charge.site_id = " . $db->qstr(DEFAULT_SITE); + + $q_save = "SELECT DISTINCT %%fieldList%%, ".AGILE_DB_PREFIX."charge.id FROM ".AGILE_DB_PREFIX."charge "; + $q_save .= $where_list ." %%whereList%% "; + + #echo $q; + #exit; + + # run the database query + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('charge.inc.php','search', $db->ErrorMsg()); + return false; + } + + # get the result count: + $results = $result->RecordCount(); + + # get the first record id: + if($results == 1) $record_id = $result->fields['id']; + + # define the DB vars as a Smarty accessible block + global $smarty; + + # Create the definition for fast-forwarding to a single record: + if ($results == 1 && !isset($this->fast_forward)) + { + $smarty->assign('record_id', $record_id); + } + + # create the search record: + if($results > 0) + { + # create the search record + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $arr['module'] = $this->module; + $arr['sql'] = $q_save; + $arr['limit'] = $limit; + $arr['order_by']= $order_by; + $arr['results'] = $results; + $search->add($arr); + + # define the search id and other parameters for Smarty + $smarty->assign('search_id', $search->id); + + # page: + $smarty->assign('page', '1'); + + # limit: + $smarty->assign('limit', $limit); + + # order_by: + $smarty->assign('order_by', $order_by); + } + + # define the result count + $smarty->assign('results', $results); + } + + + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $this->charge_construct(); + + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + + # set the field list for this method: + $arr = $this->method[$type]; + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $this->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . "charge" . "." . $value; + + // determine if this record is linked to another table/field + if($this->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $this->field[$value]["asso_table"], 'link_field' => $this->field[$value]["asso_field"]); + } + } + else + { + $field_var = $this->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . "charge" . "." . $value; + + // determine if this record is linked to another table/field + if($this->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $this->field[$value]["asso_table"], 'link_field' => $this->field[$value]["asso_field"]); + } + } + $i++; + } + + + # get the search details: + if(isset($VAR['search_id'])) { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } else { + # invalid search! + echo '
The search terms submitted were invalid!'; # translate... # alert + + if(isset($this->trigger["$type"])) { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") { + $order_by = ' ORDER BY ' . $VAR['order_by']; + $smarty_order = $VAR['order_by']; + } else { + $order_by = ' ORDER BY ' . $this->order_by; + $smarty_order = $search->order_by; + } + + + # determine the sort order + if(isset($VAR['desc'])) { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } else if(isset($VAR['asc'])) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + if (!eregi('date',$smarty_order)) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } + } + + # generate the full query + $db = &DB(); + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " site_id = " . $db->qstr(DEFAULT_SITE); + $q .= $order_by; + + ////////////////// + # echo "
$q
"; + + $current_page=1; + $offset=-1; + if (!empty($VAR['page'])) $current_page = $VAR['page']; + if (empty($search->limit)) $search->limit=25; + if($current_page>1) $offset = (($current_page * $search->limit) - $search->limit); + $result = $db->SelectLimit($q, $search->limit, $offset); + + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('charge.inc.php','search', $db->ErrorMsg()); + + if(isset($this->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + return; + } + + + # put the results into a smarty accessable array + $i=0; + $class_name = TRUE; + while (!$result->EOF) { + $smart[$i] = $result->fields; + + if($class_name) + { + $smart[$i]['_C'] = 'row1'; + $class_name = FALSE; + } else { + $smart[$i]['_C'] = 'row2'; + $class_name = TRUE; + } + $result->MoveNext(); + $i++; + } + + + # get any linked fields + if($i > 0) + { + $db_join = new CORE_database; + $this->result = $db_join->join_fields($smart, $this->linked); + } + else + { + $this->result = $smart; + } + + # get the result count: + $results = $result->RecordCount(); + + # define the DB vars as a Smarty accessible block + global $smarty; + + # define the results + $smarty->assign($this->table, $this->result); + $smarty->assign('page', $VAR['page']); + $smarty->assign('order', $smarty_order); + $smarty->assign('sort', $smarty_sort); + $smarty->assign('limit', $search->limit); + $smarty->assign('search_id',$search->id); + $smarty->assign('results', $search->results); + + # get the total pages for this search: + if(empty($search->limit)) + $this->pages = 1; + else + $this->pages = intval($search->results / $search->limit); + if ($search->results % $search->limit) $this->pages++; + + # total pages + $smarty->assign('pages', $this->pages); + + # current page + $smarty->assign('page', $current_page); + $page_arr = ''; + for($i=0; $i <= $this->pages; $i++) + { + if ($this->page != $i) $page_arr[] = $i; + } + + # page array for menu + $smarty->assign('page_arr', $page_arr); + } + + ############################## + ## SEARCH EXPORT ## + ############################## + function search_export($VAR) + { + $this->charge_construct(); + + # require the export class + require_once (PATH_CORE . "export.inc.php"); + + # Call the correct export function for inline browser display, download, email, or web save. + if($VAR["format"] == "excel") + { + $type = "export_excel"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_excel($VAR, $this, $type); + } + + else if ($VAR["format"] == "pdf") + { + $type = "export_pdf"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_pdf($VAR, $this, $type); + } + + else if ($VAR["format"] == "xml") + { + $type = "export_xml"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_xml($VAR, $this, $type); + } + + else if ($VAR["format"] == "csv") + { + $type = "export_csv"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_csv($VAR, $this, $type); + } + + else if ($VAR["format"] == "tab") + { + $type = "export_tab"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_tab($VAR, $this, $type); + } + } + + ############################## + ## IMPORT ## + ############################## + function import($VAR) + { + $this->charge_construct(); + + include_once(PATH_CORE.'import.inc.php'); + $import = new CORE_import; + + if(!empty($VAR['confirm'])) + { + $import->do_import($VAR, $this); + } + else + { + $import->prepare_import($VAR, $this); + } + } +} +?> \ No newline at end of file diff --git a/modules/charge/charge_construct.xml b/modules/charge/charge_construct.xml new file mode 100644 index 00000000..4a04a381 --- /dev/null +++ b/modules/charge/charge_construct.xml @@ -0,0 +1,88 @@ + + + + charge + + charge
+ + + + 0 + + date_orig + + 35 + + + + I8 + 1 + + + I4 + + + I8 + + + L + 1 + + + I4 + + + I8 + account + username + any + + + I4 + product + sku + + + I4 + + + F + float + + + F + float + + + L + + + X2 + + + C(32) + + + + + id,site_id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + id,site_id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + id,site_id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + id,site_id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + id,site_id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + id,site_id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + id,site_id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + id,site_id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + id,site_id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + id,site_id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + id,date_orig,status,sweep_type,account_id,product_id,service_id,amount,quantity,taxable,attributes + + + + sweep_type,status + account_id,service_id + site_id,service_id,status + + + 0 +
diff --git a/modules/charge/charge_install.xml b/modules/charge/charge_install.xml new file mode 100644 index 00000000..1e6840b8 --- /dev/null +++ b/modules/charge/charge_install.xml @@ -0,0 +1,62 @@ + + + charge + account_admin + + 1 + + + + + add + + 1 + + + search_export + + + update + + + export_excel + + + delete + + + export_xml + + + view + + 1 + + + export_tab + + + search + + 1 + + + search_form + + + search_show + + + export_csv + + + import + + 1 + + + api + + + + \ No newline at end of file diff --git a/modules/charge/xmlrpc.php b/modules/charge/xmlrpc.php new file mode 100644 index 00000000..832a7c0e --- /dev/null +++ b/modules/charge/xmlrpc.php @@ -0,0 +1,84 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +include_once('../../config.inc.php'); +require_once(PATH_ADODB . 'adodb.inc.php'); +require_once(PATH_CORE . 'database.inc.php'); +require_once(PATH_CORE . 'setup.inc.php'); +require_once(PATH_CORE . 'vars.inc.php'); +include_once(PATH_INCLUDES.'xml-rpc/xml-rpc.php'); +include_once(PATH_MODULES .'charge/charge.inc.php'); +$C_debug = new CORE_debugger; +$C_vars = new CORE_vars; +$VAR = $C_vars->f; +$C_db = &DB(); +$C_setup = new CORE_setup; + +class ChargeServer extends IXR_Server { + + var $account_id; + var $username; + var $password; + + function ChargeServer() { + $this->IXR_Server(array( + 'charge.add' => 'this:add' + )); + } + + function add($args) { + $this->username = $args[0]; + $this->password = $args[1]; + if(!$this->validate()) return array('status'=>false, 'charge_id'=>false, 'error'=> "Authentication failed"); + + @$var['account_id'] = $args[2]; + @$var['service_id'] = $args[3]; + @$var['amount'] = $args[4]; + @$var['sweep_type'] = $args[5]; + @$var['taxable'] = $args[6]; + @$var['quantity'] = $args[7]; + @$var['product_id'] = $args[8]; + @$var['description'] = $args[9]; + @$var['attributes'] = $args[10]; + + $charge = new charge; + $charge->xmlrpc=true; + $ret = $charge->api($var, $charge); + + return $ret; + + } + + function validate() { + if(empty($this->username) || empty($this->password)) return false; + $p=AGILE_DB_PREFIX; + $s=DEFAULT_SITE; + $db=&DB(); + $sql = "SELECT DISTINCT A.id,A.username FROM {$p}account as A, {$p}account_group as AG + WHERE A.username=".$db->qstr($this->username)." AND A.password=MD5(".$db->qstr($this->password).") + AND A.status=1 AND AG.account_id = A.id AND A.site_id={$s} AND AG.site_id={$s} + AND AG.group_id in ( SELECT DISTINCT GM.group_id FROM _group_method GM JOIN {$p}module M on (M.name='charge' and M.site_id={$s}) JOIN {$p}module_method MM on (MM.name='api' AND MM.module_id=M.id and MM.site_id={$s}))"; + $rs=$db->Execute($sql); + if(!$rs || !$rs->RecordCount()) return false; + else return true; + } +} +$server = new ChargeServer(); +?> \ No newline at end of file diff --git a/modules/checkout/auth.inc.php b/modules/checkout/auth.inc.php new file mode 100644 index 00000000..eebfa051 --- /dev/null +++ b/modules/checkout/auth.inc.php @@ -0,0 +1,9 @@ + 'checkout', 'method' => 'preview'), +Array ('module' => 'checkout', 'method' => 'adddiscount'), +Array ('module' => 'checkout', 'method' => 'checkoutoption'), +Array ('module' => 'checkout', 'method' => 'checkoutnow') +); +?> \ No newline at end of file diff --git a/modules/checkout/base_checkout_plugin.class.php b/modules/checkout/base_checkout_plugin.class.php new file mode 100644 index 00000000..1f914208 --- /dev/null +++ b/modules/checkout/base_checkout_plugin.class.php @@ -0,0 +1,430 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** + * Base checkout plugin class + * + */ +class base_checkout_plugin +{ + var $checkout_id; /* current checkout plugin id */ + var $name; /* plugin name */ + var $type; /* redirect, gateway, or other */ + var $recurr_only=false; /* bool */ + var $return_url; /* return url */ + var $success_url; /* decline url */ + var $support_cur; /* supported currency array */ + var $cfg; + var $flds; + var $eft; /* true if checkout plugin type is eft */ + var $req_all_flds=true; /* require all account fields (first/last name, address1, state/province, zip) */ + var $req_fields_arr=false; /* if req_all_fields=false, use this array to define which fields will be required */ + var $billing; /* the billing details */ + var $account; /* the account level details */ + + /** + * Get the checkout plugin settings from the database + */ + function getDetails($checkout_id) { + if(!$checkout_id) return; + $this->checkout_id = $checkout_id; + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."checkout WHERE site_id=".DEFAULT_SITE." AND id=".$db->qstr($checkout_id); + $rs = $db->Execute($q); + if($rs && $rs->RecordCount()) { + @$this->cfg = unserialize($rs->fields["plugin_data"]); + $this->flds = $rs->fields; + } + } + + /** + * Get country name, + * + * @param string $field name, two_code, or three_code + */ + function getCountry($field, $country_id) { + $db = &DB(); + $sql= 'SELECT '.$field.' FROM '.AGILE_DB_PREFIX.'country WHERE site_id='.DEFAULT_SITE.' AND id='.$country_id; + $rs = $db->Execute($sql); + if($rs == false || $rs->RecordCount() == 0) + return "Not Defined"; + else + return $rs->fields["$field"]; + } + + /** + * Validate the current currency is allowed + * + * @return bool + */ + function validate_currency($currency_iso) { + $do = false; + for($i=0; $isupport_cur); $i++) + if ($currency_iso == $this->support_cur[$i]) + $do = true; + if ( !$do ) { + global $C_list, $C_translate; + $C_translate->value['checkout']['currency'] = $C_list->currency_iso(DEFAULT_CURRENCY); + $msg = $C_translate->translate('currency_not_supported','checkout',''); + $this->redirect=''; + return false; + } + return true; + } + + /** + * Validate the current credit card details + */ + function validate_card_details(&$ret) { + + // validate input fields + if($this->req_all_flds) $this->req_fields_arr = Array('first_name','last_name', 'address1', 'state', 'zip'); + if (is_array($this->req_fields_arr)) { + $validate=true; + global $VAR; + foreach($this->req_fields_arr as $fld) { + if(empty($this->billing["$fld"]) && empty($this->account["$fld"]) ) { + $VAR["{$fld}_error"]=true; + $validate=false; + } + } + if(!$validate) { + global $C_translate; + $ret['status'] = 0; + $ret['msg'] = $C_translate->translate('missing_fields','checkout',''); + return false; + } + } + + // validate actual credit card details + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + $this->billing["cc_no"] == ereg_replace('^[0-9]', '', $this->billing["cc_no"]); + if (!$validate->validate_cc( $this->billing["cc_no"], false, $this->billing["card_type"], $this->cfg['card_type'] )) { + $ret['status'] = 0; + global $C_translate; + $ret['msg'] = $C_translate->translate('card_invalid','checkout',''); + } elseif (!$validate->validate_cc_exp(@$this->billing["exp_month"],@$this->billing["exp_year"])) { + $ret['status'] = 0; + global $C_translate; + $ret['msg'] = $C_translate->translate('card_exp_invalid','checkout',''); + } else { + $ret['status'] = 1; + return true; + } + return false; + } + + + /** + * Validate the current eft card details + */ + function validate_eft_details(&$ret) { + // validate input fields + if($this->req_all_flds) $this->req_fields_arr = Array('first_name','last_name', 'address1', 'city', 'state', 'zip', 'eft_check_acct_type', 'eft_trn', 'eft_check_acct', 'phone'); + if (is_array($this->req_fields_arr)) { + $validate=true; + global $VAR; + foreach($this->req_fields_arr as $fld) { + if(empty($this->billing["$fld"]) && empty($this->account["$fld"]) ) { + $VAR["{$fld}_error"]=true; + $validate=false; + } + } + if(!$validate) { + global $C_translate; + $ret['status'] = 0; + $ret['msg'] = $C_translate->translate('missing_fields','checkout',''); + return false; + } + } + $ret['status'] = 1; + return true; + } + + + /** + * Set the redirect URL and form values + * + * @param string $url + * @param string $vals + */ + function post_vars($url,$vals) { + $ret = '
'; + foreach($vals as $v) + $ret .=''; + $ret .= ''; + $this->redirect=$ret; + } + + /** + * Set array for processing order with a stored billing record + * "getStoredArray" + */ + function setBillingFromDB($account_id, $account_billing_id, $checkout_plugin_id,$rebilling=false) { + $db=&DB(); + $ccrs=$db->Execute($sql=sqlSelect($db,"account_billing","*","account_id=::$account_id:: AND id=::$account_billing_id:: AND checkout_plugin_id=::$checkout_plugin_id::")); + return $this->setBillingFromDBObj($ccrs); + } + + /** + * Get stored array by passing in database object + */ + function setBillingFromDBObj(&$ccrs,$rebilling=false) { + if($ccrs && $ccrs->RecordCount()) { + + // account fields + if(empty($ccrs->fields['address1'])) { + if(!$this->setAccountFromDB($ccrs->fields['account_id'])) return false; + } else { + $this->account = Array( + 'first_name'=> $ccrs->fields['first_name'], + 'last_name'=> $ccrs->fields['last_name'], + 'company'=> $ccrs->fields['company'], + 'address1'=> $ccrs->fields['address1'], + 'address2'=> $ccrs->fields['address2'], + 'city'=> $ccrs->fields['city'], + 'state'=> $ccrs->fields['state'], + 'zip'=> $ccrs->fields['zip'], + 'country_id'=> $ccrs->fields['country_id'], + 'phone'=> $ccrs->fields['phone'], + 'company' => $ccrs->fields['company'], + 'email' => $ccrs->fields['email'] + ); + } + + // get the card or eft details & decrypt + include_once(PATH_CORE.'crypt.inc.php'); + $this->billing['card_type'] = $ccrs->fields['card_type']; + $this->billing['rebilling'] = $rebilling; + if($this->eft || $ccrs->fields['card_type']=='eft') { + // stored eft + $this->billing['eft_check_acct_type'] = $ccrs->fields['eft_check_acct_type']; + $this->billing['eft_check_checkno'] = false; + $this->billing['eft_check_acct'] = CORE_decrypt($ccrs->fields['eft_check_acct']); + $this->billing['eft_trn'] = CORE_decrypt($ccrs->fields['eft_trn']); + if(!empty($ccrs->fields['ssn'])) $this->billing['ssn'] = CORE_decrypt($ccrs->fields['ssn']); + if(!empty($ccrs->fields['dob'])) $this->billing['dob'] = CORE_decrypt($ccrs->fields['dob']); + if(!empty($ccrs->fields['dl_no'])) $this->billing['dl_no'] = CORE_decrypt($ccrs->fields['dl_no']); + } else { + // stored card + $this->billing['cc_no'] = CORE_decrypt($ccrs->fields['card_num']); + $this->billing['exp_month'] = $ccrs->fields['card_exp_month']; + $this->billing['exp_year'] = $ccrs->fields['card_exp_year']; + } + + /* write back params to global */ + $this->setBillingParams(); + + return true; + } else { + return false; + } + } + + /** + * Set account from account db table + */ + function setAccountFromDB($id) { + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"account","first_name,last_name,company,address1,address2,city,state,zip,country_id","id=::$id::")); + if($rs&&$rs->RecordCount()) { + $this->account = $rs->fields; + return true; + } + return false; + } + + /** + * Set account and billing details from $VAR (user params) + */ + function setBillingFromParams($VAR) { + global $VAR; + @$a = $VAR['checkout_plugin_data']; + + @$this->billing = Array( + 'card_type' => $a['card_type'], + 'cc_no' => $a['cc_no'], + 'ccv' => $a['ccv'], + 'exp_month' => $a['exp_month'], + 'exp_year' => $a['exp_year'], + 'eft_check_acct_type' => $a['eft_check_acct_type'], + 'eft_check_checkno' => $a['eft_check_checkno'], + 'eft_check_acct' => $a['eft_check_acct'], + 'eft_trn' => $a['eft_trn'], + 'ssn' => $a['ssn'], + 'dob' => $a['dob'], + 'dl_no' => $a['dl_no'] + ); + + @$this->account = Array( + 'first_name' => stripslashes($a['first_name']), + 'last_name' => stripslashes($a['last_name']), + 'address1' => stripslashes($a['address1']), + 'address2' => stripslashes($a['address2']), + 'city' => stripslashes($a['city']), + 'state' => stripslashes($a['state']), + 'zip' => stripslashes($a['zip']), + 'country_id' => stripslashes($a['country_id']), + 'phone' => stripslashes($a['phone']), + 'company' => stripslashes($a['company']), + 'email' => stripslashes($a['email']) + ); + + /* write back params for global */ + $this->setBillingParams(); + } + + /** + * Write the vars back to the global VAR for availibilty on the checkout plugin templates + */ + function setBillingParams() { + global $VAR; + foreach($this->billing as $key=>$val) $VAR["$key"]=$val; + foreach($this->account as $key=>$val) $VAR["$key"]=$val; + } + + + /** + * Store the billing credit card entered + */ + function saveCreditCardDetails($VAR) { + global $C_auth; + if(!empty($VAR['account_id']) && $C_auth->auth_method_by_name('checkout','admin_checkoutnow')) + $account_id=$VAR['account_id']; + else + $account_id=SESS_ACCOUNT; + + # Check if this card is already on file: + $last_four = substr($this->billing['cc_no'],(strlen($this->billing['cc_no'])-4),4); + $db = &DB(); + $q = "SELECT id,card_exp_month,card_exp_year FROM ".AGILE_DB_PREFIX."account_billing WHERE + site_id = ".$db->qstr(DEFAULT_SITE) ." AND + account_id = ".$db->qstr($account_id) ." AND + card_num4 = ".$db->qstr($last_four) ." AND + checkout_plugin_id = ".$db->qstr($this->checkout_id) ." AND + card_type = ".$db->qstr($this->billing['card_type']); + $rs = $db->Execute($q); + if($rs && $rs->RecordCount()) { + $fields=Array('card_exp_month'=>$this->billing['exp_month'], 'card_exp_year'=>$this->billing['exp_year']); + $db->Execute(sqlUpdate($db,"account_billing",$fields,"id = {$rs->fields['id']}")); + return $rs->fields['id']; + } + + include_once(PATH_CORE.'crypt.inc.php'); + $card_num = CORE_encrypt ($this->billing['cc_no']); + $id = $db->GenID(AGILE_DB_PREFIX . 'account_billing_id'); + $sql = "INSERT INTO ".AGILE_DB_PREFIX."account_billing SET + id = " . $db->qstr($id) . ", + site_id = " . $db->qstr(DEFAULT_SITE) . ", + account_id = " . $db->qstr(@$account_id) . ", + checkout_plugin_id = " . $db->qstr(@$this->checkout_id) . ", + card_type = " . $db->qstr(@$this->billing['card_type']) . ", + card_num = " . $db->qstr(@$card_num) . ", + card_num4 = " . $db->qstr(@$last_four) . ", + card_exp_month = " . $db->qstr(@$this->billing['exp_month']) . ", + card_exp_year = " . $db->qstr(@$this->billing['exp_year']) . ", + card_start_month = " . $db->qstr(@$this->billing['start_month']) . ", + card_start_year = " . $db->qstr(@$this->billing['start_year']) . ", + first_name = " . $db->qstr(@$this->account['first_name']) . ", + last_name = " . $db->qstr(@$this->account['last_name']) . ", + address1 = " . $db->qstr(@$this->account['address1']) . ", + address2 = " . $db->qstr(@$this->account['address2']) . ", + city = " . $db->qstr(@$this->account['city']) . ", + state = " . $db->qstr(@$this->account['state']) . ", + zip = " . $db->qstr(@$this->account['zip']) . ", + country_id = " . $db->qstr(@$this->account['country_id']) . ", + phone = " . $db->qstr(@$this->account['phone']) . ", + email = " . $db->qstr(@$this->account['email']) . ", + company = " . $db->qstr(@$this->account['company']) ; + $result = $db->Execute($sql); + if ($result) return $id; + return false; + } + + + /** + * Store the billing EFT details entered + */ + function saveEFTDetails($VAR) { + global $C_auth; + if(!empty($VAR['account_id']) && $C_auth->auth_method_by_name('checkout','admin_checkoutnow')) + $account_id=$VAR['account_id']; + else + $account_id=SESS_ACCOUNT; + + # Check if this card is already on file: + $last_four = substr($this->billing['eft_check_acct'],(strlen($this->billing['eft_check_acct']) - 4),4); + $db = &DB(); + $q = "SELECT id,card_exp_month,card_exp_year FROM ".AGILE_DB_PREFIX."account_billing WHERE + site_id = ".$db->qstr(DEFAULT_SITE) ." AND + account_id = ".$db->qstr($account_id) ." AND + card_num4 = ".$db->qstr($last_four) ." AND + checkout_plugin_id = ".$db->qstr($this->checkout_id) ." AND + card_type = ".$db->qstr($this->billing['card_type']); + $rs = $db->Execute($q); + if($rs && $rs->RecordCount()) { + return $rs->fields['id']; + } + + include_once(PATH_CORE.'crypt.inc.php'); + $ssn=false; + $dob=false; + $dl_no=false; + if(!empty($this->billing['dob'])) $dob = CORE_encrypt ($this->billing['dob']); + if(!empty($this->billing['ssn'])) $ssn = CORE_encrypt ($this->billing['ssn']); + if(!empty($this->billing['dl_no'])) $dl_no = CORE_encrypt ($this->billing['dl_no']); + $check_acct = CORE_encrypt ($this->billing['eft_check_acct']); + $trn = CORE_encrypt ($this->billing['eft_trn']); + + $id = $db->GenID(AGILE_DB_PREFIX . 'account_billing_id'); + $sql = "INSERT INTO ".AGILE_DB_PREFIX."account_billing SET + id = " . $db->qstr($id) . ", + site_id = " . $db->qstr(DEFAULT_SITE) . ", + account_id = " . $db->qstr($account_id) . ", + checkout_plugin_id = " . $db->qstr($this->checkout_id) . ", + card_num4 = " . $db->qstr($last_four) . ", + card_type = " . $db->qstr(@$this->billing['card_type']) . ", + eft_check_checkno = " . $db->qstr($this->billing['eft_check_checkno']) . ", + eft_check_acct_type = " . $db->qstr($this->billing['eft_check_acct_type']) . ", + eft_trn = " . $db->qstr($trn) . ", + eft_check_acct = " . $db->qstr($check_acct) . ", + dob = " . $db->qstr($dob) . ", + dl_no = " . $db->qstr($dl_no) . ", + ssn = " . $db->qstr($ssn) . ", + first_name = " . $db->qstr(@$this->account['first_name']) . ", + last_name = " . $db->qstr(@$this->account['last_name']) . ", + address1 = " . $db->qstr(@$this->account['address1']) . ", + address2 = " . $db->qstr(@$this->account['address2']) . ", + city = " . $db->qstr(@$this->account['city']) . ", + state = " . $db->qstr(@$this->account['state']) . ", + zip = " . $db->qstr(@$this->account['zip']) . ", + country_id = " . $db->qstr(@$this->account['country_id']) . ", + phone = " . $db->qstr(@$this->account['phone']) . ", + email = " . $db->qstr(@$this->account['email']) . ", + company = " . $db->qstr(@$this->account['company']); + $result = $db->Execute($sql); + if ($result) return $id; + return false; + } +} +?> \ No newline at end of file diff --git a/modules/checkout/checkout.inc.php b/modules/checkout/checkout.inc.php new file mode 100644 index 00000000..bf8ea3f9 --- /dev/null +++ b/modules/checkout/checkout.inc.php @@ -0,0 +1,905 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class checkout +{ + var $account_id; + var $session_id; + var $affiliate_id; + var $campaign_id; + + var $admin_view=false; + var $admin_checkout=false; + var $admin_checkout_option=false; + + /** + * Add Discount for Admin Checkout + */ + function admin_adddiscount($VAR) { + if(empty($VAR['amount'])) return false; + if(empty($VAR['id'])) return false; + $db=&DB(); + $fields=Array('ad_hoc_discount'=>round($VAR['amount'],2)); + $db->Execute(sqlUpdate($db,"cart",$fields,"id = ::{$VAR['id']}:: ")); + return true; + } + + /** + * Add Discount Code to Sess + */ + function adddiscount($VAR) + { + include_once(PATH_MODULES.'discount/discount.inc.php'); + $dsc=new discount(); + $dsc->add_cart_discount($VAR); + } + + /** + * Admin Create the Invoice Record + */ + function admin_checkoutnow($VAR) + { + # Get the account id & session_id + if(!empty($VAR['account_id'])) + { + $this->account_id = $VAR['account_id']; + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'session WHERE account_id = ' . $db->qstr( $this->account_id ) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + if(!empty($rs->fields['id'])) { + $this->session_id = $rs->fields['id']; + } else { + $this->session_id = SESS; + } + } else { + return false; + } + + # Get the affiliate details + global $C_list; + if(!$C_list->is_installed('affiliate')) { + $this->affiliate_id = ''; + } else { + if(SESS_AFFILIATE != "") { + $this->affiliate_id = SESS_AFFILIATE; + } else { + # Get the affiliate details for this account + $db = &DB(); + $sql = 'SELECT affiliate_id FROM ' . AGILE_DB_PREFIX . 'account WHERE id = ' . $db->qstr( $this->account_id ) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + if(!empty($rs->fields['affiliate_id'])) + { + $this->affiliate_id = $rs->fields['affiliate_id']; + } else { + # Get the affiliate account for the admin creating this invoice + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'affiliate WHERE account_id = ' . $db->qstr( SESS_ACCOUNT ) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + if(!empty($rs->fields['id'])) + $this->affiliate_id = $rs->fields['id']; + else + $this->affiliate_id = ''; + } + } + } + $this->redirect = true; + $this->admin_checkout = true; + + # Is processor free checkout? + if(@$VAR['option'] == '999') $this->admin_checkout_option = true; + + # Checkout + if($this->checkoutnow($VAR, $this)) { + echo ''; + } + } + + /** + * Get available checkout option + * + * @param int $account_id + * @param float $total + * @param array $product_arr Array of product_ids being purchased + * @param int $country_id + * @param bool $any_new + * @param bool $any_trial + * @param bool $any_recurring + * @return array + */ + function get_checkout_options($account_id,$total=0,$product_arr=false,$country_id=1,$any_new=false,$any_trial=false,$any_recurring=false) { + $options=false; + if($any_trial) $options .= " AND allow_trial=1 "; + if($any_recurring) $options .= " AND allow_recurring=1 "; + if($any_new) $options .= " AND allow_new=1 "; + if(!$options) return false; + $db=&DB(); + $chopt = $db->Execute(sqlSelect($db,"checkout","*","active=1 $options")); + if($chopt && $chopt->RecordCount()) { + while( !$chopt->EOF ) { + $show = true; + # Check that the cart total is not to low: + if ( $show == true && $chopt->fields["total_minimum"] != "" && $total < $chopt->fields["total_minimum"] ) $show = false; + # Check that the cart total is not to high: + if ( $show == true && $chopt->fields["total_maximum"] != "" && $total > $chopt->fields["total_maximum"] ) { + $show = false; + } elseif ($chopt->fields["total_maximum"] == '0' && $total > 0) { + $show = false; + } + # Check that the group requirement is met: + if ( $show == true && !$this->admin_view && !empty ( $chopt->fields["required_groups"] ) ) { + global $C_auth; + $arr = unserialize ( $chopt->fields["required_groups"] ); + if(count($arr) > 0 && !empty($arr[0])) $show = false; + for ( $i=0; $iauth_group_by_id($arr[$i])) { + $show = true; + $i=count($arr); + } + } + } + # Check that the customer is not ordering a blocked SKU: + if ( $show == true && !$this->admin_view && !empty ( $chopt->fields["excluded_products"] ) && $product_arr ) { + $arr = unserialize ( $chopt->fields["excluded_products"] ); + if(count($arr) > 0) { + for($i=0; $ifields["default_when_amount"] ) ) { + @$arr = unserialize ( $chopt->fields["default_when_amount"] ); + for ( $i=0; $i= $arr[$i] ) $list_ord--; $i=count($arr); + } + # By Currency + if ( !empty ( $chopt->fields["default_when_currency"] ) ) { + @$arr = unserialize ( $chopt->fields["default_when_currency"] ); + for ( $i=0; $ifields["default_when_group"] ) ) { + @$arr = unserialize ( $chopt->fields["default_when_group"] ); + global $C_auth; + for ( $i=0; $iauth_group_by_account_id( $account_id, $arr[$i] ) ) $list_ord--; $i=count($arr); + } + # By Country + if ( !empty ( $chopt->fields["default_when_country"] ) ) { + @$arr = unserialize ( $chopt->fields["default_when_country"] ); + for ( $i=0; $i$list_ord, 'fields'=>$chopt->fields); + } + $chopt->MoveNext(); + } + # Sort the checkout_options array by the [fields] element + if(count($checkout_options) > 0 ) { + foreach ( $checkout_options as $key => $row ) $sort[$key] = $row["sort"]; + array_multisort ( $sort, SORT_ASC, $checkout_options ); + return $checkout_options; + } + } else { + return false; + } + return false; + } + + + /** + * Admin View Preview / Confirm prior to checkout + */ + function admin_preview($VAR) { + global $C_auth; + if(!empty($VAR['account_id']) && $C_auth->auth_method_by_name('checkout','admin_checkoutnow')) { + $this->account_id=$VAR['account_id']; + $this->admin_view = true; + } else { + $this->account_id=SESS_ACCOUNT; + } + $this->preview($VAR, $this); + } + + /** + * Preview / Confirm prior to checkout + */ + function preview($VAR) { + if(!SESS_LOGGED) return false; + $db = &DB(); + + if(empty($this->session_id)) $this->session_id = SESS; + if(empty($this->account_id)) $this->account_id = SESS_ACCOUNT; + + include_once ( PATH_MODULES . '/cart/cart.inc.php' ); + $cartObj = new cart; + $cartObj->account_id=$this->account_id; + $cartObj->session_id=$this->session_id; + $result = $cartObj->get_contents($db); + if($result->RecordCount() == 0) return false; + + // load invoice object + include_once(PATH_MODULES.'invoice/invoice.inc.php'); + $invoice = new invoice; + $invoice->initNew(0); + $invoice->account_id = $this->account_id; + + // Get the account details: + $account = $db->Execute(sqlSelect($db,"account","*","id=::$this->account_id::")); + $invoice->country_id = $account->fields['country_id']; + $invoice->state = $account->fields['state']; + + // load tax object for tax calculation + include_once(PATH_MODULES.'tax/tax.inc.php'); + $taxObj=new tax; + + // load discount object for discount calculation + include_once(PATH_MODULES.'discount/discount.inc.php'); + $discountObj=new discount; + $discountObj->available_discounts($invoice->account_id); + + // put cart contents into invoice format + $cartObj->put_contents_invoice($db, $result, $invoice, $smart, $taxObj, $discountObj); + + // get available checkout options + foreach($invoice->invoice_item as $item) if(!empty($item['product_id'])) $product_arr[]=$item['product_id']; + $checkout_options = $this->get_checkout_options($this->account_id,$invoice->total_amt,@$product_arr,$invoice->country_id,$invoice->any_new, $invoice->any_trial, $invoice->any_recurring); + $checkout_c = count($checkout_options); + + global $smarty; + $smarty->assign('results', count($invoice->invoice_item)); + $smarty->assign('cart', $smart); + $smarty->assign('sub_total',($invoice->total_amt+$invoice->discount_amt)-$invoice->tax_amt); + $smarty->assign('total', $invoice->total_amt); + $smarty->assign('discount', $invoice->group_discounts()); + $smarty->assign('tax', $invoice->group_taxes()); + $smarty->assign('checkout', $checkout_options); + $smarty->assign('checkout_c', $checkout_c); + $checkout_c--; + $smarty->assign('last_checkout_id', $checkout_options["$checkout_c"]['fields']['id']); + + } + + /** + * Create the Invoice Record and send user to checkout + */ + function checkoutnow($VAR) + { + global $C_translate, $C_list, $smarty; + $db = &DB(); + + // Validate user is logged in: + if(!SESS_LOGGED) { + echo ''; + return false; + } + + // check for admin + if(!$this->admin_checkout && !empty($VAR['account_id'])) { + global $C_auth; + if(!empty($VAR['account_id']) && $C_auth->auth_method_by_name('checkout','admin_checkoutnow')) { + $this->account_id=$VAR['account_id']; + $this->admin_checkout=true; + } else { + $this->account_id=SESS_ACCOUNT; + } + } + + if(empty($this->session_id)) $this->session_id = SESS; + if(empty($this->account_id)) $this->account_id = SESS_ACCOUNT; + + include_once ( PATH_MODULES . '/cart/cart.inc.php' ); + $cartObj = new cart; + $cartObj->account_id=$this->account_id; + $cartObj->session_id=$this->session_id; + $result = $cartObj->get_contents($db); + if($result->RecordCount() == 0) return false; + + // load invoice object + include_once(PATH_MODULES.'invoice/invoice.inc.php'); + $invoice = new invoice; + $invoice->account_id = $this->account_id; + $invoice->initNew(0); + + // Get the account details: + $account = $db->Execute(sqlSelect($db,"account","*","id=::$this->account_id::")); + $invoice->country_id = $account->fields['country_id']; + $invoice->state = $account->fields['state']; + + // load tax object for tax calculation + include_once(PATH_MODULES.'tax/tax.inc.php'); + $taxObj=new tax; + + // load discount object for discount calculation + include_once(PATH_MODULES.'discount/discount.inc.php'); + $discountObj=new discount; + $discountObj->available_discounts($invoice->account_id); + + // put cart contents into invoice format + $cartObj->put_contents_invoice($db, $result, $invoice, $smart, $taxObj, $discountObj); + + // Validate and init a checkout plugin + $checkout=false; + if($this->admin_checkout_option) { + // admin checkout option specified + include_once ( PATH_MODULES . 'checkout/checkout_admin.inc.php' ); + $PLG = new checkout_admin; + $checkout=true; + $invoice->checkout_plugin_id=false; + } else { + // get available checkout options and check against the one provided + $invoice->checkout_plugin_id=$VAR['option']; + foreach($invoice->invoice_item as $item) if(!empty($item['product_id'])) $product_arr[]=$item['product_id']; + $checkout_options = $this->get_checkout_options($this->account_id,$invoice->total_amt,@$product_arr,$invoice->country_id,$invoice->any_new, $invoice->any_trial, $invoice->any_recurring); + if($checkout_options) { + foreach($checkout_options as $a) { + if($a['fields']['id']==$invoice->checkout_plugin_id) { + // load the selected checkout plugin and run pre-validation + $checkout_plugin=$a['fields']['checkout_plugin']; + $plugin_file = PATH_PLUGINS . 'checkout/'.$checkout_plugin.'.php'; + include_once ( $plugin_file ); + eval ( '$PLG = new plg_chout_'.$checkout_plugin.'("'.$invoice->checkout_plugin_id.'");'); + $plugin_validate = $PLG->validate($VAR, $this); + if ( $plugin_validate != true ) { + echo $plugin_validate; + return false; + } + $checkout=true; + break; + } + } + } + } + if(!$checkout) { + echo ' '; + return false; + } + + // validate credit card on file details + global $VAR; + if(!empty($VAR['account_billing_id']) && @$VAR['new_card']==2) { + $invoice->account_billing_id=$VAR['account_billing_id']; + /* validate credit card on file details */ + if(!$PLG->setBillingFromDB($this->account_id, $invoice->account_billing_id, $invoice->checkout_plugin_id)) { + global $C_debug; + $C_debug->alert("Sorry, we cannot use that billing record for this purchase."); + return false; + } + } else { + /* use passed in vars */ + $PLG->setBillingFromParams($VAR); + } + + // validate recurring processing options + if ($PLG->recurr_only) { + if ($invoice->recur_amt<=0) { + echo ' '; + return false; + } + if(is_array($invoice->recur_arr) && count($invoice->recur_arr)>1) { + $recurring = true; + // validate recur day and recurring schedule are the same for both products + foreach($invoice->recur_arr as $a) { + foreach($invoice->recur_arr as $b) { + foreach($b as $key=>$val) { + if($key != 'price' && $key != 'recurr_week' && $a[$key] != $val) { + $recurring=false; + break; + } + } + } + } + if (!$recurring) { + echo ' '; + return false; + } + } + } + + # Affiliate + if(empty($this->affiliate_id)) { + if(!empty($account->fields['affiliate_id'])) + $invoice->affiliate_id = $account->fields['affiliate_id']; + else + $invoice->affiliate_id = SESS_AFFILIATE; + } + + # Campaign + if(empty($this->campaign_id)) { + if(!empty($account->fields['campaign_id'])) + $invoice->campaign_id = $account->fields['campaign_id']; + else + $invoice->campaign_id = SESS_CAMPAIGN; + } + + $invoice->record_id = sqlGenID($db,"invoice"); + $invoice->actual_billed_currency_id = SESS_CURRENCY; + $invoice->billed_currency_id = DEFAULT_CURRENCY; + $invoice->checkout_type = $PLG->type; + + // initial invoice status + if( $invoice->total_amt == 0 || $PLG->type == 'gateway') { + $invoice->billing_status = 1; + $invoice->actual_billed_amt = $C_list->format_currency_decimal($invoice->total_amt, SESS_CURRENCY); + $invoice->billed_amt = $invoice->total_amt; + } + + // Currency conversion: + if (SESS_CURRENCY != DEFAULT_CURRENCY) { + $bill_amt = $C_list->format_currency_decimal ($invoice->total_amt, SESS_CURRENCY); + $recur_amt = $C_list->format_currency_decimal ($invoice->recur_amt, SESS_CURRENCY); + } else { + $bill_amt = round($invoice->total_amt,2); + $recur_amt = round($invoice->recur_amt,2); + } + + // Get currency ISO (three_digit) for checkout plugin + $currrs = $db->Execute(sqlSelect($db,"currency","three_digit","id=".SESS_CURRENCY)); + if($currrs && $currrs->RecordCount()) $currency_iso = $currrs->fields['three_digit']; + + // Run the plugin bill_checkout() method: + $currency_iso = $C_list->currency_iso(SESS_CURRENCY); + $invoice->checkout_plugin_data = $PLG->bill_checkout($bill_amt, $invoice->record_id, $currency_iso, $account->fields, $recur_amt, $invoice->recur_arr); + if($invoice->checkout_plugin_data === false || $invoice->checkout_plugin_data == '' ) { + if(!empty($PLG->redirect)) echo $PLG->redirect; + return false; + } elseif ($PLG->type == "gateway" || empty($PLG->redirect)) { + $VAR['id'] = $invoice->record_id; + if(!$this->admin_checkout) $VAR['_page'] = "invoice:thankyou"; + $invoice->checkout_plugin_data=false; + } elseif(!$this->admin_checkout) { + echo "
+ Please wait while we redirect you to the secure payment site.... + {$PLG->redirect}
"; + } + + // Call the Plugin method for storing the checkout data: + $invoice->account_billing_id = $PLG->store_billing($VAR, $invoice->account_id); + + // clear user discounts + $fields=Array('discounts'=>""); + $db->Execute(sqlUpdate($db,"session",$fields,"id = ::".SESS."::")); + + // admin options + $email=true; + if($this->admin_checkout) { + if(empty($VAR['send_email']) || $VAR['send_email']=='false') $email=false; else $email=true; + if(!empty($VAR['due_date'])) $invoice->due_date=$this->getInputDate($VAR['due_date']); + if(!empty($VAR['grace_period'])) $invoice->grace_period=$VAR['grace_period']; + if(!empty($VAR['notice_max'])) $invoice->notice_max=$VAR['notice_max']; + } + + if($invoice->commitNew($taxObj, $discountObj, $email)) { + // delete all cart items + $db->Execute(sqlDelete($db,"cart", "(session_id=::".SESS.":: OR account_id=$invoice->account_id)")); + // admin redirect + if($this->admin_checkout) { + $url = URL.'admin.php?_page=invoice:view&id='.$invoice->record_id; + echo ''; + } + } + return false; + } + + /** Convert a localized d,m,y string to epoch timestamp + */ + function getInputDate($date) { + + $Arr_format = split(DEFAULT_DATE_DIVIDER, UNIX_DATE_FORMAT); + $Arr_date = split(DEFAULT_DATE_DIVIDER, $date); + for($i=0; $i<3; $i++) + { + if($Arr_format[$i] == 'd') $day = $Arr_date[$i]; + if($Arr_format[$i] == 'm') $month = $Arr_date[$i]; + if($Arr_format[$i] == 'Y') $year = $Arr_date[$i]; + } + $timestamp = mktime(0, 0, 0, $month, $day, $year); + return $timestamp; + + return time(); + } + + /** + * Manage postback for multiple invoices + */ + function postback_multiple($arr) { + $db=&DB(); + include_once(PATH_MODULES.'invoice/invoice.inc.php'); + $invoice=new invoice; + + // get multi-invoice details + $total = $invoice->multiple_invoice_total($arr['invoice_id']); + if(!$total) return false; + + $amt = $arr['amount']; + + foreach($invoice->invoice_id as $id) + { + if($amt > 0) + { + // get total due for this invoice: + $rs=sqlSelect($db, "invoice","SUM(total_amt-billed_amt) as total","id=$id"); + if($rs && $rs->RecordCount()) { + $thisamt = $rs->fields["total"]; + + if($thisamt > $amt) + $arr['amount'] = $amt; + else + $arr['amount'] = $thisamt; + $arr["invoice_id"] = $id; + + $this->postback($arr); + $amt -= $thisamt; + } + } + } + } + + /** + * Postback for Redirect Pay + */ + function postback($arr) + { + global $C_debug; + + if(empty($arr['invoice_id'])) return false; + if(empty($arr['transaction_id'])) return false; + if(empty($arr['amount'])) return false; + + if(eregi("MULTI-", $arr['invoice_id'])) { + $this->postback_multiple($arr); + return; + } + + # Get the latest invoice info: + $db = &DB(); + + $sql1 =""; + if(!empty($arr['subscription_id'])) + $sql1 = "checkout_plugin_data = ".$db->qstr( trim($arr['subscription_id']) )." OR "; + + $q = "SELECT * FROM ".AGILE_DB_PREFIX."invoice WHERE + ( + $sql1 + parent_id = ".$db->qstr(@$arr['invoice_id'])." + OR + id = ".$db->qstr(@$arr['invoice_id'])." + ) + AND + billing_status != 1 + AND + site_id = ".$db->qstr(DEFAULT_SITE)." + ORDER BY date_orig + LIMIT 0,1"; + $invoice = $db->Execute($q); + + if ($invoice === false || $invoice->RecordCount()==0) + $C_debug->error('checkout.inc.php','postback', $q . " | " . @$db->ErrorMsg()); + + if($invoice->RecordCount() == 0) + return false; + + $invoice_id = $invoice->fields['id']; + + # Validate the currency + $billed_currency_id = $invoice->fields['billed_currency_id']; + $total_amt = $invoice->fields['total_amt']; + $billed_amt = $invoice->fields['billed_amt']; + $actual_billed_amt = $invoice->fields['actual_billed_amt']; + $currency_iso = @$arr['currency']; + + if(empty($currency_iso) || !$currency_iso) + { + # same as billed_currency_id + $this->billed_amt = $arr['amount'] + $billed_amt; + $this->actual_billed_amt = $arr['amount'] + $billed_amt; + $this->actual_billed_currency_id = $billed_currency_id; + } + else + { + # Get the actual billed currency id currency info: + $q = "SELECT * FROM ".AGILE_DB_PREFIX."currency WHERE + three_digit = ".$db->qstr($currency_iso)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + + if ($result === false) + $C_debug->error('checkout.inc.php','postback', $q . " | " . @$db->ErrorMsg()); + + $actual_billed_currency_id = $result->fields['id']; + + if(is_string($result->fields["convert_array"])) + $convert = unserialize($result->fields["convert_array"]); + else + $convert = false; + + $this->format_currency[$actual_billed_currency_id] = Array ( + 'symbol' => $result->fields["symbol"], + 'convert' => $convert, + 'iso' => $result->fields["three_digit"]); + + if($result->RecordCount() == 0 || $actual_billed_currency_id == $billed_currency_id) + { + # same as billed_currency_id + $this->billed_amt = $arr['amount'] + $billed_amt; + $this->actual_billed_amt = $arr['amount'] + $billed_amt; + $this->actual_billed_currency_id = $actual_billed_currency_id; + } + else + { + # Get the billed currency id currency info: + $q = "SELECT * FROM ".AGILE_DB_PREFIX."currency WHERE + id = ".$db->qstr($billed_currency_id)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + + if ($result === false) + $C_debug->error('checkout.inc.php','postback', $q . " | " . @$db->ErrorMsg()); + + $this->format_currency[$billed_currency_id] = Array ( + 'symbol' => $result->fields["symbol"], + 'convert' => unserialize($result->fields["convert_array"]), + 'iso' => $result->fields["three_digit"]); + + # Convert the invoice amount to the actual billed currency amount + $due_amount = $invoice->fields['total_amt'] - $invoice->fields['billed_amt']; + $conversion = $this->format_currency[$billed_currency_id]["convert"][$actual_billed_currency_id]["rate"]; + + $this->billed_amt = $billed_amt + ($arr['amount'] /= $conversion); + $this->actual_billed_amt = $actual_billed_amt + $arr['amount']; + $this->actual_billed_currency_id = $actual_billed_currency_id; + } + } + + + # Check for any subscription_id + if(!empty($arr['subscription_id'])) { + $this->subscription_id = trim($arr['subscription_id']); + } else { + $this->subscription_id = trim($invoice->fields['checkout_plugin_data']); + } + + # Check for the checkout_id + if(!empty($arr['checkout_id'])) { + $this->checkout_id = $arr['checkout_id']; + } else { + $this->checkout_id = $invoice->fields['checkout_plugin_id']; + } + + # Check for the billing status: + if($this->billed_amt >= $invoice->fields['total_amt']) { + $this->billing_status = '1'; + } else { + $this->billing_status = '0'; + } + + # Check if this transaction_id has already been processed: + $q = "SELECT id FROM ".AGILE_DB_PREFIX."invoice_memo WHERE + invoice_id = ".$db->qstr($invoice_id)." AND + type = ".$db->qstr('postback')." AND + memo = ".$db->qstr($arr['transaction_id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $memo = $db->Execute($q); + + if ($memo === false) + $C_debug->error('checkout.inc.php','postback', $q . " | " . @$db->ErrorMsg()); + + if ($memo->RecordCount() > 0) { + # duplicate post: + $C_debug->error('Duplicate Postback','checkout.inc.php :: postback()', "Duplicate postback for invoice {$arr['invoice_id']} & transaction id {$arr['transaction_id']}"); + } else { + # Create the invoice memo: + $memo_id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id'); + $q = "INSERT INTO + ".AGILE_DB_PREFIX."invoice_memo + SET + id = ".$db->qstr($memo_id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + invoice_id = ".$db->qstr($invoice_id).", + account_id = ".$db->qstr(0).", + type = ".$db->qstr('postback').", + memo = ".$db->qstr($arr['transaction_id']) ; + $memosql = $db->Execute($q); + + if ($memosql === false) + $C_debug->error('checkout.inc.php','postback', $q . " | " . @$db->ErrorMsg()); + + # Update the invoice billing info: + $q = "UPDATE + ".AGILE_DB_PREFIX."invoice + SET + date_last = ".$db->qstr(time()).", + billing_status = ".$db->qstr($this->billing_status).", + checkout_plugin_id = ".$db->qstr($this->checkout_id).", + checkout_plugin_data = ".$db->qstr($this->subscription_id).", + billed_amt = ".$db->qstr($this->billed_amt).", + actual_billed_amt = ".$db->qstr($this->actual_billed_amt).", + actual_billed_currency_id = ".$db->qstr($this->actual_billed_currency_id)." + WHERE + id = ".$db->qstr($invoice_id)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $memosql = $db->Execute($q); + + if ($memosql === false) + $C_debug->error('checkout.inc.php','postback', $q . " | " . @$db->ErrorMsg()); + + # Update the invoice approval status + $VAR['id'] = $invoice_id; + include_once(PATH_MODULES.'invoice/invoice.inc.php'); + $inv = new invoice; + if(!$arr['status']) + { + # void + $inv->voidInvoice($VAR); + + # create a record of the viod in an invoice memo: + $memo_id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id'); + $q = "INSERT INTO + ".AGILE_DB_PREFIX."invoice_memo + SET + id = ".$db->qstr($memo_id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + invoice_id = ".$db->qstr($invoice_id).", + account_id = ".$db->qstr(0).", + type = ".$db->qstr('void').", + memo = ".$db->qstr("Voided due to postback: ".$arr['transaction_id']) ; + $rsql = $db->Execute($q); + + if ($rsql === false) + $C_debug->error('checkout.inc.php','postback', $q . " | " . @$db->ErrorMsg()); + + } else { + + # approve + $inv->autoApproveInvoice($invoice_id); + + # User invoice payment confirmation + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + $email = new email_template; + $email->send('invoice_paid_user', $invoice->fields['account_id'], $invoice_id, DEFAULT_CURRENCY, ''); + + # Admin alert of payment processed + $email = new email_template; + $email->send('admin->invoice_paid_admin', $invoice->fields['account_id'], $invoice_id, DEFAULT_CURRENCY, ''); + } + } + return true; + } + + /** + * Display Checkout Data Form + */ + function checkoutoption($VAR) { + global $VAR, $C_translate, $smarty; + + if(SESS_LOGGED != '1') { + $smarty->assign('plugin_template', false); + return false; + } + + // Normal checkout + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."checkout WHERE site_id=".DEFAULT_SITE." AND id=".$db->qstr(@$VAR["option"]); + $rs = $db->Execute($q); + if($rs == false || $rs->RecordCount() == 0) { + $smarty->assign('plugin_template', false); + return false; + } + + // determine account id + global $C_auth; + if(!empty($VAR['account_id']) && $C_auth->auth_method_by_name('checkout','admin_checkoutnow')) { + $this->account_id=$VAR['account_id']; + $this->admin_view = true; + } else { + $this->account_id=SESS_ACCOUNT; + } + + // Set account options && seed VAR with defaults + if(empty($VAR['detailsnocopy'])) { + $acct = $db->Execute($sql=sqlSelect($db,"account","first_name,last_name,address1,address2,city,state,zip,country_id,email,company","id=".$this->account_id)); + if($acct && $acct->RecordCount()) + foreach($acct->fields as $key=>$val) + if(!is_numeric($key) && empty($VAR["$key"])) + $VAR["$key"]=stripslashes($acct->fields["$key"]); + } + + global $C_vars; + $C_vars->strip_slashes_all(); + $smarty->assign('VAR', $VAR); + + $smarty->assign('plugin_template', 'checkout_plugin:plugin_ord_' . $rs->fields["checkout_plugin"]); + } + + function add($VAR) { + $this->checkout_construct(); + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + function view($VAR) { + $this->checkout_construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + function update($VAR) { + $this->checkout_construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + function delete($VAR) { + $this->checkout_construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + function search($VAR) { + $this->checkout_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + function search_show($VAR) { + $this->checkout_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + function checkout_construct() { + $this->module = "checkout"; + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } +} +?> \ No newline at end of file diff --git a/modules/checkout/checkout_admin.inc.php b/modules/checkout/checkout_admin.inc.php new file mode 100644 index 00000000..c9fa32dd --- /dev/null +++ b/modules/checkout/checkout_admin.inc.php @@ -0,0 +1,64 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +include_once(PATH_MODULES.'checkout/base_checkout_plugin.class.php'); + +class checkout_admin extends base_checkout_plugin + +{ + # Get the config values for this checkout plugin: + function checkout_admin($checkout_id=false) { + + $this->name = 'NONE'; + $this->type = 'redirect'; + $this->recurr_only = false; + } + + # Validate the user submitted billing details at checkout: + function validate($VAR) { + return true; + } + + # Perform the checkout transaction (new purchase): + function bill_checkout( $amount, $invoice, $currency_iso, $acct_fields, $total_recurring=false, $recurr_bill_arr=false) { + return true; + } + + # Stores new billing details, & return account_billing_id (gateway only) + function store_billing($VAR) { + return 0; + } + + # Perform a transaction for an (new invoice): + function bill_invoice($VAR) { + return true; + } + + # Issue a refund for a paid invoice (captured charges w/gateway) + function refund($VAR) { + return true; + } + + # Void a authorized charge (gateways only) + function void($VAR) { + return true; + } +} +?> \ No newline at end of file diff --git a/modules/checkout/checkout_construct.xml b/modules/checkout/checkout_construct.xml new file mode 100644 index 00000000..c43401b6 --- /dev/null +++ b/modules/checkout/checkout_construct.xml @@ -0,0 +1,140 @@ + + + + checkout + + checkout
+ + + + 0 + + name + + 25 + + + + I4 + 1 + 1 + + + I4 + 1 + + + C(32) + 1 + 32 + any + + + C(255) + + + L + + + C(32) + any + + + X2 + array + 1 + + + L + + + L + + + L + + + F + + + F + + + I4 + + + L + + + L + + + X2 + array + 1 + + + X2 + array + 1 + + + F + + + X2 + array + 1 + + + X2 + array + 1 + + + X2 + array + 1 + + + X2 + array + 1 + + + F + + + X2 + array + 1 + any + + + X2 + + + X2 + array + 1 + + + X2 + array + 1 + + + C(128) + + + + + id,site_id,name,description,active,checkout_plugin,plugin_data,allow_recurring,allow_new,allow_trial,total_minimum,total_maximum,max_decline_attempts,manual_approval_all,manual_approval_recur,manual_approval_country,manual_approval_group,manual_approval_amount,manual_approval_currency,default_when_currency,default_when_country,default_when_group,default_when_amount,allowed_currencies,email_template,excluded_products,required_groups,graphic_url + id,site_id,name,description,active,checkout_plugin,plugin_data,allow_recurring,allow_new,allow_trial,total_minimum,total_maximum,max_decline_attempts,manual_approval_all,manual_approval_recur,manual_approval_country,manual_approval_group,manual_approval_amount,manual_approval_currency,default_when_currency,default_when_country,default_when_group,default_when_amount,allowed_currencies,email_template,excluded_products,required_groups,graphic_url + id,site_id,name,description,active,checkout_plugin,plugin_data,allow_recurring,allow_new,allow_trial,total_minimum,total_maximum,max_decline_attempts,manual_approval_all,manual_approval_recur,manual_approval_country,manual_approval_group,manual_approval_amount,manual_approval_currency,default_when_currency,default_when_country,default_when_group,default_when_amount,allowed_currencies,excluded_products,required_groups + id,site_id,name,description,active,checkout_plugin,plugin_data,allow_recurring,allow_new,allow_trial,total_minimum,total_maximum,max_decline_attempts,manual_approval_all,manual_approval_recur,manual_approval_country,manual_approval_group,manual_approval_amount,manual_approval_currency,default_when_currency,default_when_country,default_when_group,default_when_amount,allowed_currencies,email_template,excluded_products,required_groups,graphic_url + id,site_id,name,description,active,checkout_plugin,plugin_data,allow_recurring,allow_new,allow_trial,total_minimum,total_maximum,max_decline_attempts,manual_approval_all,manual_approval_recur,manual_approval_country,manual_approval_group,manual_approval_amount,manual_approval_currency,default_when_currency,default_when_country,default_when_group,default_when_amount,allowed_currencies,email_template,excluded_products,required_groups + + + 0 +
diff --git a/modules/checkout/checkout_install.xml b/modules/checkout/checkout_install.xml new file mode 100644 index 00000000..124b080e --- /dev/null +++ b/modules/checkout/checkout_install.xml @@ -0,0 +1,45 @@ + + + checkout + setup + + 1 + + + + + search_form + + + search + + + view + + 1 + + + delete + + + add + 1 + + + update + + + search_show + + + admin_checkoutnow + + + admin_adddiscount + + + admin_preview + + + + \ No newline at end of file diff --git a/modules/checkout/checkout_install_data.xml b/modules/checkout/checkout_install_data.xml new file mode 100644 index 00000000..15e14814 --- /dev/null +++ b/modules/checkout/checkout_install_data.xml @@ -0,0 +1,956 @@ + + + + 1 + 1 + Free Order Processing + There are no charges associated with this purchase, so no billing details are required to complete your order. + 1 + FREE + + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 3 + 1 + PayPal (Subscription) + This payment option will create a subscription in your PayPal account so you will be billed automatically for any recurring charges. + 0 + PAYPAL_RECURRING + + 1 + 0 + 0 + 0.01 + 10000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 6 + 1 + PayPal + Pay with your PayPal.com account and gain instant access to your order online. + 0 + PAYPAL + + 0 + 1 + 1 + 0.01 + 10000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 7 + 1 + 2Checkout.com + Pay at 2Checkout.com with your credit card. + 0 + 2CHECKOUT + + 1 + 1 + 1 + 0.01 + 10000 + 0 + 1 + + + 0 + + + + + 0 + + You have ordered via 2checkout.com, which may take up to 24 hours to complete their fraud tests. Once this process is complete, you will be contacted with instructions. + + + 8 + 1 + Nochex + Pay with your Nochex.com account. + 0 + NOCHEXS + + 1 + 1 + 1 + 0.01 + 10000 + 0 + 1 + + + 0 + + + + + 0 + + + + 9 + 1 + NetPayments + Pay at the NetPayments.com secure site. + 0 + NETPAYMENTS + + 1 + 1 + 1 + 0.01 + 10000 + 0 + 1 + 0 + + + 0 + + + + + 0 + + + + + + 10 + 1 + Worldpay + Pay at the secure WorldPay.com site... + 0 + WORLDPAY + + 0 + 1 + 1 + 0.01 + 10000 + 0 + 1 + 0 + + + 0 + + + + + 0 + + + + + + 15 + 1 + MoneyBookers + Pay with your MoneyBookers account. + 0 + MONEYBOOKERS + + 1 + 1 + 1 + 0.01 + 100000 + 0 + 1 + 0 + + + 0 + + + + + 0 + + + + + + 16 + 1 + MoneyBookers (subscription) + Pay with MoneyBookers and create and automatic subscription for future charges. + 0 + MONEYBOOKERS_RECURRING + + 1 + 0 + 0 + 0.1 + 100000 + 0 + 1 + 0 + + + 0 + + + + + 0 + + + + 17 + 1 + StormPay + Pay with your StormPay account + 0 + STORMPAY + + 0 + 1 + 1 + 0.01 + 100000 + 0 + 1 + 0 + + + 0 + + + + + 0 + + + + + + 19 + 1 + StormPay (subscription) + Pay with your StormPay account. + 0 + STORMPAY_RECURRING + + 1 + 0 + 0 + 0.01 + 100000 + 0 + 1 + 0 + + + 0 + + + + + 0 + + + + 23 + 1 + Manual Card + Collect cards to charge manually later + 1 + MANUAL + + 1 + 1 + 1 + 0 + 100000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + Your credit card details have been stored for manual review and verification of funds. Once we have reviewed and successfully debited the credit card, we will update the invoice status. In the meanwhile, your invoice will be displayed as due, so you can ignore this unless we contact you stating otherwise. + + + + + 27 + 1 + Paysystems Pro + Paysystems TTP Pro + 0 + PAYSYSTEMS_PRO + + 0 + 1 + 1 + 0.01 + 100000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + 28 + 1 + Paysystems Recurring + Pay for this recurring transaction at Paysystems.com with a credit card + 0 + PAYSYSTEMS_RECURRING + + 1 + 0 + 0 + 0.01 + 100000 + 0 + 0 + + + 0 + + + + + 0 + + + + 29 + 1 + Paysystems Check + Pay with an e-check at paystems.com + 0 + PAYSYSTEMS_CHECK + + 0 + 1 + 1 + 0.01 + 100000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 31 + 1 + Paysystems Check Recur + Create a recurring e-check at paysystems.com + 0 + PAYSYSTEMS_CHECK_RECUR + + 1 + 0 + 0 + 0.01 + 100000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 32 + 1 + WorldPay Futurepay + Create a recurring subscription at WorldPay.com + 0 + WORLDPAY_FUTUREPAY + + 1 + 0 + 0 + 0.01 + 100000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 33 + 1 + Remit Bank Wire + Remit a bank wire for this invoice + 0 + REMIT_BANK_WIRE + + 1 + 1 + 0 + 0.01 + 1000000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 34 + 1 + Remit Check + Remit a company or certified check for this invoice + 0 + REMIT_CHECK + + 1 + 1 + 0 + 10 + 1000000000 + 0 + 0 + + + 0 + + + + + 0 + + + + 35 + 1 + Authorize.net + Pay with your credit card through our realtime connection with authorize.net + 0 + AUTHORIZE_NET + + 1 + 1 + 1 + 0 + 100000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 36 + 1 + SWREG + Pay with your credit card at SWREG. + 0 + SWREG_ADVANCED + + 1 + 1 + 1 + 0.01 + 10000000 + 0 + 0 + + + 0 + + + + + 0 + + + + + 37 + 1 + Eway + Pay with a credit card at Eway.com.au + 0 + EWAY + + 1 + 1 + 1 + 0.01 + 10000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 39 + 1 + PaySwiss + Payswiss payment option + 0 + PAYSWISS + + 0 + 1 + 1 + 0.01 + 10000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + 40 + 1 + PaySwiss (recurring) + Setup a subscript at payswiss.com + 0 + PAYSWISS_RECURRING + + 1 + 0 + 0 + 0.01 + 10000 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + 41 + 1 + TrustCommerce + tc + 0 + TRUSTCOMMERCE + + 1 + 1 + 1 + 0.01 + 99999999999 + 0 + 0 + 0 + 0 + 0 + + + + 42 + 1 + EFTSecure + EFTSecure + 0 + EFT_SECURE + + 1 + 1 + 1 + 0.01 + 99999999 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 43 + 1 + USA ePAY + USA ePAY + 0 + USA_EPAY + + 1 + 1 + 1 + 1 + 9999999 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 45 + 1 + PAYMATE + PAYMATE.com + 0 + PAYMATE + + 1 + 1 + 1 + 0.01 + 99999999 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 46 + 1 + Internetsecure + InternetSecure + 0 + INTERNETSECURE + + 1 + 1 + 1 + 5 + 9999 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 47 + 1 + Verisign + 0 + VERISIGN_PFPRO + 0 + 0 + 0 + 0 + 9 + 0 + 0 + 0 + 0 + 0 + + + + + 48 + 1 + CommercePayment.com + CommercePayment.com + 0 + COMMERCEPAYMENTWINDOW + + 1 + 1 + 1 + 0.01 + 9999999 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 49 + 1 + OptimalPayments + OptimalPayments + 0 + OPTIMALPAYMENTS + + 1 + 1 + 1 + 0.01 + 9999999 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 50 + 1 + SkipJack + Cards... + 0 + SKIPJACK + + 1 + 1 + 1 + 0.01 + 999999 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 51 + 1 + PayFuse + Checkout with creditcard + 0 + PAYFUSE + + 1 + 1 + 1 + 0.01 + 99999 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 52 + 1 + Protx + Protx + 1 + PROTX + + 1 + 1 + 1 + 0.01 + 999999 + 0 + 0 + 0 + + + 0 + + + + + 0 + + + + + + 52 + + \ No newline at end of file diff --git a/modules/core/auth.inc.php b/modules/core/auth.inc.php new file mode 100644 index 00000000..d850244f --- /dev/null +++ b/modules/core/auth.inc.php @@ -0,0 +1,286 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_auth +{ + + var $auth_groups; + var $auth_modules; + var $auth_methods; + var $account=false; + var $logged=false; + + function CORE_auth($force) + { + global $VAR; + + if(!isset( $this->auth_methods ) ) { + #include (PATH_CORE . 'auth_methods.inc'); + #$this->auth_methods = $auth_methods; + } + + if(defined("SESS_LOGGED")) { + if(SESS_LOGGED == "1") { + $this->logged = TRUE; + $this->account = SESS_ACCOUNT; + } + else { + $this->logged = FALSE; + $this->account = 0; + } + } else { + $this->logged = FALSE; + $this->account = 0; + + if(!defined('SESS_LOGGED')) define('SESS_LOGGED', false); + if(!defined('SESS')) define('SESS', false); + } + + if($force && defined("FORCE_SESS_ACCOUNT")) { + $this->account = FORCE_SESS_ACCOUNT; + $this->logged = TRUE; + } + + if ( isset($VAR['_logout']) || + isset($VAR['_login']) || + isset($VAR['lid']) || + $force == true || + CACHE_SESSIONS != "1") { + $this->auth_update(); + return; + } else { + if($this->session_auth_cache_retrieve()) + { + $this->module_count = count($this->module); + return; + } + } + $this->auth_update(); + } + + + function auth_update() { + + if(!$this->account) { + $this->group = Array("0"); + $this->module = Array("0"); + } else { + $this->group_list($this->account); + $db = &DB(); + $p = AGILE_DB_PREFIX; + $sql="SELECT DISTINCT MM.module_id, GM.method_id, GM.group_id, + M.name AS module_name, M.parent_id AS module_parent_id, M.menu_display AS module_display, + MM.name AS method_name, MM.page AS method_page, MM.menu_display AS method_display + FROM {$p}group_method as GM + LEFT JOIN {$p}module as M on (GM.module_id=M.id and M.site_id=".DEFAULT_SITE.") + LEFT JOIN {$p}module_method as MM on (GM.method_id=MM.id and MM.site_id=".DEFAULT_SITE.") "; + for($i=0; $iauth_groups); $i++) + if($i==0) $sql .= "WHERE GM.group_id={$this->auth_groups[$i]} "; + else $sql .= "OR GM.group_id={$this->auth_groups[$i]} "; + $sql .= "AND GM.site_id=".DEFAULT_SITE." ORDER BY M.name,MM.name"; + $result=$db->Execute($sql); + if($result === false) + { + global $C_debug; + $C_debug->error('core:auth.inc.php','menu_update', $db->ErrorMsg() . '

' .$q); + return; + } + while (!$result->EOF) { + + $module_name = $result->fields["module_name"]; + $method_name = $result->fields["method_name"]; + + if(empty($this->module[$module_name])) { + $this->module[$module_name] = Array($result->fields["module_id"], + $result->fields["module_parent_id"], + $result->fields["module_display"]); + } + + if(empty($this->module[$module_name][$method_name])) { + $this->module[$module_name][$method_name] = Array($result->fields["method_id"], + $result->fields["method_display"], + $result->fields["method_page"]); + } + $result->MoveNext(); + } + } + $this->session_auth_cache_update(); + } + + + function session_auth_cache_update() { + $db = &DB(); + $expire = time() + 7200; // 1 hour + + if(isset($this->group) && gettype($this->group) == 'array') + $group = serialize($this->group); + else + $group = 0; + + if(isset($this->module) && gettype($this->module) == 'array') + $module = serialize($this->module); + else + $module = 0; + + $q = 'DELETE FROM '.AGILE_DB_PREFIX.'session_auth_cache WHERE + session_id = '. $db->qstr(SESS) .' AND + site_id = '. $db->qstr(DEFAULT_SITE); + $db->Execute($q); + + $id = $db->GenID(AGILE_DB_PREFIX . "" . 'session_auth_cache_id'); + $q = 'INSERT INTO '.AGILE_DB_PREFIX.'session_auth_cache SET + id = '. $db->qstr($id) .', + site_id = '. $db->qstr(DEFAULT_SITE) .', + session_id = '. $db->qstr(SESS) .', + date_expire = '. $db->qstr($expire) .', + group_arr = '. $db->qstr($group) .', + module_arr = '. $db->qstr($module); + $db->Execute($q); + } + + + function session_auth_cache_retrieve() { + global $C_sess; + if(!empty($C_sess->auth_cache)) { + if ( $C_sess->auth_cache["date_expire"] > time() ) { + $group = $C_sess->auth_cache['group_arr']; + $module = $C_sess->auth_cache['module_arr']; + if($group != '0' && $group != '') $this->group = unserialize($group); + if($module != '0' && $module != '') $this->module = unserialize($module); + return true; + } + } + + $db = &DB(); + $q = 'SELECT * FROM '.AGILE_DB_PREFIX.'session_auth_cache WHERE + site_id = '. $db->qstr(DEFAULT_SITE) .' AND + session_id = '. $db->qstr(SESS) .' AND + date_expire >= '. $db->qstr(time()); + $result = $db->Execute($q); + if($result->RecordCount() > 0) { + $group = $result->fields['group_arr']; + $module = $result->fields['module_arr']; + if($group != '0' && $group != '') $this->group = unserialize($group); + if($module != '0' && $module != '') $this->module = unserialize($module); + return true; + } + return false; + } + + + function group_list($account) { + $this->group[0] = "0"; + $time = time(); + $db = &DB(); + $p = AGILE_DB_PREFIX; + $q="SELECT DISTINCT ag.group_id AS group_id,g.parent_id AS parent_id + FROM {$p}account_group as ag + INNER JOIN {$p}group as g ON (ag.group_id=g.id AND g.status=1 AND g.site_id=".DEFAULT_SITE.") + WHERE ag.account_id = '$account' + AND ( ag.date_start IS NULL OR ag.date_start < $time ) + AND ( ag.date_expire IS NULL OR ag.date_expire = 0 OR ag.date_expire > $time ) + AND ( g.date_start IS NULL OR g.date_start <= $time ) + AND ( g.date_expire IS NULL OR g.date_expire = 0 OR g.date_expire > $time ) + AND ag.active=1 AND g.status=1 + AND ag.site_id=".DEFAULT_SITE; + $result = $db->Execute($q); + if ($result === false) { + global $C_debug; + echo $db->ErrorMsg(); + $C_debug->error('auth.inc.php','group_list', $db->ErrorMsg()); + exit; + } elseif($result->RecordCount() == 0) { + return; + } else { + while (!$result->EOF) { + $arr[] = $result->fields; + $result->MoveNext(); + } + } + + for($i=0; $igroup); $ii++) + if($this->group[$ii] == $arr[$i]["group_id"]) $do = false; + + if($do) { + $this->group[] = $arr[$i]["group_id"]; + + if(!empty($arr[$i]["parent_id"]) && $arr[$i]["parent_id"] != $arr[$i]["group_id"]) { + $do = true; + for($ii=0; $iigroup); $ii++) + if($this->group[$ii] == $arr[$i]["parent_id"]) $do = false; + if($do) $this->group[] = $arr[$i]["parent_id"]; + } + } + } + if($account != SESS_ACCOUNT) return $this->group; + } + + function auth_method_by_name($module,$method) { + + if(isset($this->module[$module][$method])) return TRUE; + + if($module == 'core') + if($method == 'cleanup') + return true; + else + return false; + + if( is_file(PATH_MODULES.$module.'/auth.inc.php')) { + include (PATH_MODULES.$module.'/auth.inc.php'); + $this->auth_methods = $auth_methods; + for($i=0; $iauth_methods); $i++) + if ($module == @$this->auth_methods[$i]['module']) + if($method == false || $method == @$this->auth_methods[$i]['method']) + return true; + } + return FALSE; + } + + function auth_group_by_id($id) { + if(!is_array($id)) + $ids[] = $id; + else + $ids = $id; + foreach ( $ids as $group_id ) + if(isset($this->group)) + foreach ($this->group as $this_group_id) + if($this_group_id == $group_id) + return true; + return false; + } + + function auth_group_by_account_id($account, $id) { + if(SESS_LOGGED == true && $account == SESS_ACCOUNT) + return $this->auth_group_by_id($id); + unset($this->group); + $this->group_list($account); + for($i=0; $i < count($this->group); $i++) + if($this->group[$i] == $id) return true; + return FALSE; + } + + function generate_admin_menu() { + include_once(PATH_CORE.'auth_generate_admin_menu.inc.php'); + return auth_generate_admin_menu($this); + } +} +?> \ No newline at end of file diff --git a/modules/core/auth_generate_admin_menu.inc.php b/modules/core/auth_generate_admin_menu.inc.php new file mode 100644 index 00000000..de3f5999 --- /dev/null +++ b/modules/core/auth_generate_admin_menu.inc.php @@ -0,0 +1,174 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +// generate the admin menu +function auth_generate_admin_menu($menu_obj) +{ + $menu_obj->auth_update(); + global $C_translate, $smarty, $C_list; + + $i=1; + $js=''; + $arr = $menu_obj->module; + $arr2 = $menu_obj->module; + + // loop through the modules + while (list($module, $val) = each ($arr)) { + if(!empty($val[2])) { + if($val[1] == $val[0] || empty($val[0]) || empty($val[1])) + { + $module_name = $C_translate->translate('menu',$module,''); + $parent = $val[0]; + $module_id = $val[0]; + $module_arr[$i]["name"] = $module_name; + $module_arr[$i]["module"] = $module; + + // loop through the methods + while (list($method, $meth_arr) = each ($arr[$module])) { + if(gettype($meth_arr) == 'array' && !empty($meth_arr[1])) { + $method_name = $C_translate->translate('menu_'.$method,$module,''); + if(empty($meth_arr[2])) + $page = $module.':'.$method; + else + $page = eregi_replace('%%', $module, $meth_arr[2]); + + $module_arr[$i]["methods"][] = Array('name' => $method_name, 'page' => $page); + + } + } + + // Loop through the sub-modules: + reset($arr2); + $ii=0; + while (list($module, $val) = each ($arr2)) { + if(!empty($val[2])) { + if($val[1] == $parent && $module_id != $val[0]) + { + $module_name = $C_translate->translate('menu',$module,''); + $module_arr[$i]["sub_name"][$ii] = $module_name; + + // loop through the methods + while (list($method, $meth_arr) = each ($arr2[$module])) { + if(gettype($meth_arr) == 'array' && !empty($meth_arr[1])) { + $method_name = $C_translate->translate('menu_'.$method,$module,''); + if(empty($meth_arr[2])) + $page = $module.':'.$method; + else + $page = eregi_replace('%%', $module, $meth_arr[2]); + $module_arr[$i]["sub_methods"][$ii][] = Array('name' => $method_name, 'page' => $page); + } + } + $ii++; + } + } + } + $i++; + + } + } + } + + + + + // Generate the main modules: + $js = ''; + $js .= ".|Overview|javascript:openUrl('?_page=core:admin');||includes/aptree/img/icons/info.gif\n"; + $js .= ".|Exit Administration|javascript:exitAdmin();||includes/aptree/img/icons/info.gif\n"; + $js .= ".|Misc\n"; + $js .= "..|Documentation|http://agilebill.com/documentation|||mainFrame\n"; + $js .= "..|Agileco News|http://forum.agileco.com/forumdisplay.php?f=26|||mainFrame\n"; + $js .= "..|Version Check|?_page=module:upgrade|||mainFrame\n"; + + for($i=1; $i<=count($module_arr); $i++) + { + $name = $module_arr[$i]['name']; + # if($i>1) $js.=','; + $js .= ".|{$name}\n"; + + // Generate the main methods: + for($ii=0; $iiassign('today_start', $C_list->date(mktime(0,0,0,date("m"),date("d"), date("Y")))); + $smarty->assign('week_start', $C_list->date(mktime(0,0,0,date("m"),date("d")-7, date("Y")))); + $smarty->assign('month_start', $C_list->date(mktime(0,0,0,date("m"),1, date("Y")))); + + # Generate the menu + require_once(PATH_INCLUDES."phplayers/PHPLIB.php"); + require_once(PATH_INCLUDES."phplayers/layersmenu-common.inc.php"); + require_once(PATH_INCLUDES."phplayers/treemenu.inc.php"); + + // unstoppable agileco logo ;) + echo ''; + + $mnu = new TreeMenu(); + $mnu->setMenuStructureString($js); + $mnu->setIconsize(16, 16); + $mnu->parseStructureForMenu('treemenu1'); + $mnu->setTreemenuTheme("kde_"); + return $mnu->newTreeMenu('treemenu1'); + return $js; + +} +?> \ No newline at end of file diff --git a/modules/core/calendar.inc.php b/modules/core/calendar.inc.php new file mode 100644 index 00000000..a5cac502 --- /dev/null +++ b/modules/core/calendar.inc.php @@ -0,0 +1,194 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** + * Core Calendar Class + * + * @example $cal = new calendar; + * $cal->add("Paid - $9,458.00", mktime(0,1,1,date('m'), date('d')+2, date('Y')), 'green', 'green'); + * $cal->add("Due - $455.25", mktime(0,1,1,date('m'), date('d')+2, date('Y')), 'red', 'red', "alert('Message')"); + * echo $cal->generate(); + * + */ +class calendar +{ + var $month; + var $year; + + var $days; + var $months; + var $leap; + + var $start; // starting timestamp, based on month/year specified + var $end; // ending timestamp, based on month/year specified + + var $start_day_num=1; // first day to show + var $total_days; // max days to show + var $on=0; // first day of month (0-sunday) + + var $items; // holds array of items to display on the calenday + + function calendar() { + $this->leap = date("l"); + $this->months = Array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'); + $this->days = Array(31,($this->leap == 1 ? 29 : 28),31,30,31,30,31,31,30,31,30,31); + if(empty($this->year)) $this->year = date("Y"); + if(empty($this->month)) $this->month = date("m")-1; + if(empty($this->total_days)) $this->total_days = $this->days["$this->month"]; + $this->start = mktime(0,0,0,$this->month+1, 1, $this->year); + $this->end = mktime(23, 59, 59, $this->month+1, $this->total_days, $this->year); + $this->days = Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); + } + + /** + * Add an item to the calendar for display + * + * @param string $data The data to display on the given date/timestamp + * @param date $timestamp The day of month (1-31) or the unix timestamp + * @param string $border The color of the border + * @param string $color The font color + */ + function add($data, $timestamp, $border='#ddd', $color='#000', $onclick=false) { + if($timestamp > 31) { + $day = date('d', $timestamp); + } else { + $day = $timestamp; + } + $this->items["$day"][] = Array("data" => $data, "border"=> $border, "color"=> $color, "onclick"=>$onclick); + } + + /** + * Generate the full calendar HTML + * + * @return string + */ + function generate() + { + // Today's date in number (such as 21th or whatever) + $today_num = $tnc = date("j"); + + // Today's day of the week (eg: Sat) + $today_day=date("D"); + + // $tdc contains the index number of today in $this->days + $tdc=array_search(date("D"),$this->days); + + // This is loop is used to get the day of the week on the 1st day of this month (eg: January 1st) + // $tdc is the day of the week in number (the index number in $this->days) + // $tnc is decreased until it hits 1 (the first day of the month) + // $tdc is also decreased if it goes below 0 (sunday), then it is set to 6 (saturday) + while ($tnc > 1) { + $tdc--; + if ($tdc < 0) { $tdc=6; } + $tnc--; + } + + // set $counter_day the first day of the month (eg: Saturday) + $counter_day=$this->days[$tdc]; + + // Just the title.. displays the month and the year + $date_display_title="". date("F") ." ( ".date("Y"). " )"; + + // Creates the table with 7 columns + $out = "
+ + + + + + + + + + + + "; + + // This is the loop.. starts the the first day of the month and works its way up to the last day of the month + while ($this->start_day_num <= $this->total_days) { + + // create a new row if we're at the last column (which is Saturday) + if ($this->on > 6) { + $this->on=0; + $out .= ""; + } + + /* Jan 1st 2005 is on Saturday. We're on the Monday column, + so leave this column blank, go to the next column, and start again from the loop's condition + */ + if ($counter_day != $this->days[$this->on]) { + $out .= ""; + $this->on++; + continue; + } + + /* if we are display a date thats not yet been past (which is the future), then dull down the colors + For example, if its 16th today, and we are displaying the 17th, then set the text color to grey + */ + if (isset($dull)) { + $out .= ""; + } + + /* + If we are not displaying the future dates, then display it normally. + If we are displaying today's date, set $dull as true so the dates that we dislay from here on are dull-colored + */ + else { + $out .= ""; + if ($this->start_day_num == date("j")) { $dull=true; } + } + + // Move on to the next day, if all goes well + $this->start_day_num++; + + // Move on to the next day of the week's index (refer to the $this->days array) + $next_day=array_search($counter_day,$this->days) + 1; + + // If its over 6 (saturday), then set it to 0 (sunday) since the 7th index doesn't exist in $this->days + $counter_day=$this->days[($next_day > 6 ? 0 : $next_day)]; + + // go to the next column + $this->on++; + } + $out .= "
{$date_display_title}
SunMonTueWedThuFriSat
start_day_num ."> start_day_num ." valign=top> +
". $this->start_day_num ."
"; + if(is_array($this->items["{$this->start_day_num}"])) { + foreach($this->items["{$this->start_day_num}"] as $item) { + if($item['onclick']) $onClick="onClick=\"{$item['onclick']}\" "; else $onClick=''; + $out .= "
{$item['data']}
"; + } + } else { + $out .= " "; + } + $out .= "
start_day_num ." valign=top> +
". $this->start_day_num ."
"; + if(is_array($this->items["{$this->start_day_num}"])) { + foreach($this->items["{$this->start_day_num}"] as $item) { + if($item['onclick']) $onClick="onClick=\"{$item['onclick']}\" "; else $onClick=''; + $out .= "
{$item['data']}
"; + } + } else { + $out .= " "; + } + $out .= "
"; + return $out; + } +} +?> \ No newline at end of file diff --git a/modules/core/core.inc.php b/modules/core/core.inc.php new file mode 100644 index 00000000..abdf2915 --- /dev/null +++ b/modules/core/core.inc.php @@ -0,0 +1,444 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +define('AGILE_SESS_EXPIRE_DAYS', 15); +define('AGILE_SESS_AFFIL_EXPIRE_DAYS', 180); +define('AGILE_LOG_ERR_EXPIRE_DAYS', 15); +define('AGILE_ACCOUNT_CLEANUP_DAYS', 60); +define('AGILE_INVOICE_CLEANUP_DAYS', 60); +define('AGILE_LOGIN_LOGS_EXPIRE_DAYS', 180); + +class core +{ + # Main cleanup function + function cleanup($VAR) + { + $alert = false; + + /* + cleanup: sessions + session auth cache + searches + saved searches + old task logs + old error logs + old login logs + old login locks + old temporary data + old backups + expired groups + + */ + + $clean = Array( + + Array ( 'table' => 'log_error', + 'field' => 'date_orig', + 'where' => '<=', + 'cond' => time()-86400*AGILE_LOG_ERR_EXPIRE_DAYS + ), + + Array ( 'table' => 'login_log', + 'field' => 'date_orig', + 'where' => '<=', + 'cond' => time()-86400*AGILE_LOGIN_LOGS_EXPIRE_DAYS + ), + + Array ( 'table' => 'session_auth_cache', + 'field' => 'date_expire', + 'where' => '<=', + 'cond' => time() + ), + + + Array ( 'table' => 'search', + 'field' => 'date_expire', + 'where' => '<=', + 'cond' => time() + ), + + + Array ( 'table' => 'search_saved', + 'field' => 'date_expire', + 'where' => '<=', + 'cond' => time() + ), + + Array ( 'table' => 'login_lock', + 'field' => 'date_expire', + 'where' => '<=', + 'cond' => time() + ), + + Array ( 'table' => 'temporary_data', + 'field' => 'date_expire', + 'where' => '<=', + 'cond' => time() + ) + ); + + + for($i=0; $iqstr($clean[$i]['cond']); + $result=$db->Execute($sql); + } + + ######################################################################## + ### Remove old sessions + ######################################################################## + + $sql = "DELETE FROM ".AGILE_DB_PREFIX."session WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + date_last < ".$db->qstr(time()-86400*AGILE_SESS_EXPIRE_DAYS)." + AND + ( + affiliate_id IS NULL OR + affiliate_id = '' OR + affiliate_id = 0 OR + campaign_id IS NULL OR + campaign_id = '' OR + campaign_id = 0 OR + date_last < ".$db->qstr(time()-86400*AGILE_SESS_AFFIL_EXPIRE_DAYS)." + )"; + $result = $db->Execute($sql); + + + ######################################################################## + ### Remove expired group access + ######################################################################## + + $sql = "DELETE FROM ".AGILE_DB_PREFIX."account_group WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + date_expire IS NOT NULL AND + date_expire > 0 AND + date_expire <= ".$db->qstr(time()); + $result = $db->Execute($sql); + + + ######################################################################## + ### Remove old backups + ######################################################################## + + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."backup WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + date_expire != ".$db->qstr('')." AND + date_expire != ".$db->qstr('0')." AND + date_expire != ".$db->qstr(time()); + $result = $db->Execute($sql); + if ( $result != false && $result->RecordCount() > 0) + { + while (!$result->EOF) + { + ## Delete this one.. + $arr["delete_id"] = $result->fields['id']; + include_once (PATH_MODULES . 'backup/backup.inc.php'); + $backup = new backup; + $backup->delete($arr,$backup); + $result->MoveNext(); + } + } + + ######################################################################### + ### Repair/optimize DB Tables (MYSQL ONLY!) + ######################################################################### + + if(AGILE_DB_TYPE == 'mysql') + { + $db = &DB(); + $q = "SELECT name FROM ".AGILE_DB_PREFIX."module WHERE site_id = ".$db->qstr(DEFAULT_SITE); + $rs = $db->Execute($q); + + while ( !$rs->EOF ) + { + $table = $rs->fields['name']; + $sql = "CHECK TABLE ".AGILE_DB_PREFIX.$table; + $db->Execute($sql); + + $sql = "REPAIR TABLE ".AGILE_DB_PREFIX.$table; + $db->Execute($sql); + + $sql = "OPTIMIZE TABLE ".AGILE_DB_PREFIX.$table; + $db->Execute($sql); + + $rs->MoveNext(); + } + } + + ######################################################################### + ### Force the correct id keys in each table that has unique ids + ######################################################################### + $sql = "SELECT name FROM ".AGILE_DB_PREFIX."module WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + status = ".$db->qstr('1')." + ORDER BY name"; + $rs = $db->Execute($sql); + while(!$rs->EOF) + { + $module = $rs->fields['name']; + + # check if key table exists: + $sql = "SELECT id FROM ".AGILE_DB_PREFIX.$module."_id ORDER BY id DESC"; + $keytable = $db->Execute($sql); + if ($module != 'session' && $module != 'affiliate' && $keytable != false && $keytable->RecordCount() > 0) + { + $current_id = $keytable->fields['id']; + + # get the current id from the main table: + $sql = "SELECT id FROM ".AGILE_DB_PREFIX.$module." ORDER BY id DESC"; + $table = $db->Execute($sql); + if ($table != false && $table->RecordCount() > 0) + { + $last_id = $table->fields['id']; + + # does key need updated? + if($current_id < $last_id) + { + $id = $last_id + 1; + $sql = "UPDATE ".AGILE_DB_PREFIX.$module."_id + SET + id = ".$db->qstr($id)." + WHERE + id = ".$db->qstr($current_id); + $db->Execute($sql); + $alert.= "Corrected incorrect primary key on the $module table.
"; + + } + } + } + $rs->MoveNext() ; + } + + ######################################################################### + ### Run any new upgrade files in the /upgrades directory + ######################################################################### + + @$dir = opendir(PATH_AGILE.'upgrades'); + while (@$file_name = readdir($dir)) + { + $display = true; + if($file_name != '..' && $file_name != '.') + { + # check if upgrade has been run: + $md5 = md5($file_name); + $sql = "SELECT data FROM ".AGILE_DB_PREFIX."temporary_data + WHERE + data = ".$db->qstr($md5)." AND + field1 = ".$db->qstr('upgrade'); + $rs = $db->Execute($sql); + if($rs->RecordCount() == 0) + { + # Run the upgrade: + if(is_file(PATH_AGILE.'upgrades/'.$file_name) && !is_dir(PATH_AGILE.'upgrades/'.$file_name)) + include_once(PATH_AGILE.'upgrades/'.$file_name); + + $function = strtolower(ereg_replace('.php', '', $file_name)); + + if(ereg('^upgrade', $function)) + { + if(is_callable($function)) + { + $result = call_user_func ( $function ); + #$result = true; + } + else + { + $result = false; + } + } + + # If success, save so it is not run again: + if($result) + { + /* Start: SQL Insert Statement */ + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."temporary_data WHERE id = -1"; + $rs = $db->Execute($sql); + + $id = $db->GenID(AGILE_DB_PREFIX . 'temporary_data_id'); + $insert = Array ( 'id' => $id, + 'site_id' => DEFAULT_SITE, + 'data' => $md5, + 'field1' => 'upgrade', + 'date_orig' => time(), + 'date_expire' => time()+86400*365*20); + + $sql = $db->GetInsertSQL($rs, $insert); + $result = $db->Execute($sql); + if ($result === false) { + global $C_debug; + $C_debug->error('core.inc.php','core :: cleanup()', $db->ErrorMsg(). "\r\n\r\n". $sql); + } + /* End: SQL Insert Statement */ + + $alert .= "Upgraded to $file_name!
"; + } else { + $alert .= "The $file_name upgrade failed!
"; + } + } + } + } + + + + ######################################################################### + ## Print any alerts: + ######################################################################### + + if(!empty($alert)) + { + global $C_debug; + $C_debug->alert($alert); + } + + return true; + } + + + /** + * Update invoices that are within 1 cent of full payment to paid in full + * so they are not suspended because of minor currency fluctuations. + * Change the $diff variable to the max allowable balance due on the invoice + * in order for the update to take place. + */ + function paid_fraction($VAR) { + $diff=.02; + $db=&DB(); + $p=AGILE_DB_PREFIX; + $s=DEFAULT_SITE; + $sql="UPDATE {$p}invoice SET process_status=1,billing_status=1,billed_amt=total_amt + WHERE ((total_amt-billed_amt)<=$diff) AND (total_amt!=billed_amt)"; + $db->Execute($sql); + return true; + } + + + /** + * send advance invoice notice via email + */ + function invoice_advance_notice($VAR) { + include_once(PATH_MODULES . 'invoice/advance_notice.php'); + $obj = new advance_notice(); + $obj->task(); + } + + + /** + * Loop though all accounts to delete inactive accounts with no + * invoices, services, and no staff or affiliate accts + */ + function account_cleanup($VAR) + { + # Load the account admin class + include_once(PATH_MODULES.'account_admin/account_admin.inc.php'); + $acct = new account_admin; + + # Get each account: + $time = time()-(AGILE_ACCOUNT_CLEANUP_DAYS*86400); + $db = &DB(); + $db->SetFetchMode(ADODB_FETCH_ASSOC); + $sql = 'SELECT id,username,email,first_name,last_name,company FROM '.AGILE_DB_PREFIX.'account WHERE date_orig <= '.$time.' AND id>1 AND site_id = '.DEFAULT_SITE.' ORDER BY id'; + $rs = $db->Execute($sql); + echo "Accounts Deleted:
";
+        while (!$rs->EOF)
+        {
+            # Get acct id
+            $id = $rs->fields['id']; 
+            $do = true;
+             
+            # Check for staff/admin account
+            if ($do) {
+            	$sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'account_group WHERE group_id in (4,1001) AND AND account_id='.$id.' site_id = ' . $db->qstr(DEFAULT_SITE);
+            	$rs2 = $db->Execute($sql);
+            	if($rs2 && $rs2->RecordCount()) $do = false; 
+            }           
+
+            # Check for invoices
+            if ($do) {
+	            $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'invoice WHERE account_id =  ' . $db->qstr( $id ) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE);
+	            $rs2 = $db->Execute($sql);
+	            if($rs2 && $rs2->RecordCount()) $do = false; 
+            }
+
+            # Check for services
+            if ($do) {
+            	$sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'service WHERE account_id =  ' . $db->qstr( $id ) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE);
+            	$rs2 = $db->Execute($sql);
+            	if($rs2 && $rs2->RecordCount()) $do = false; 
+            }
+
+            # Check for affiliate acct
+           if ($do) {
+            	$sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'affiliate WHERE account_id =  ' . $db->qstr( $id ) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE);
+            	$rs2 = $db->Execute($sql);
+            	if($rs2 && $rs2->RecordCount()) $do = false; 
+            }
+
+            # Check for staff acct
+            if ($do) {
+            	$sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'staff WHERE account_id =  ' . $db->qstr( $id ) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE);
+            	$rs2 = $db->Execute($sql);
+            	if($rs2 && $rs2->RecordCount()) $do = false; 
+            }
+
+            # Delete the account
+            if ($do) { 
+            	$arr['id'] = $id;
+            	foreach($rs->fields as $v) echo "$v	";
+            	echo "\r\n";
+            	$acct->delete($arr, $acct);
+            }
+           
+            $rs->MoveNext();
+        }
+        echo "
"; + } + + # Delete inactive/unpaid invoices older than the allowed period: + function invoice_cleanup($VAR) + { + # Load the account admin class + include_once(PATH_MODULES.'invoice/invoice.inc.php'); + $invoice = new invoice; + $exp = time() - 86400*AGILE_INVOICE_CLEANUP_DAYS; + + # Get each account: + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'invoice + WHERE + process_status = ' . $db->qstr( 0 ) . ' AND + billing_status = ' . $db->qstr( 0 ) . ' AND + billed_amt <= ' . $db->qstr( 0 ) . ' AND + date_last <= ' . $db->qstr( $exp ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + while (!$rs->EOF) + { + $arr['id'] = $rs->fields['id']; + $invoice->delete( $arr, $invoice ); + $rs->MoveNext(); + } + } +} +?> \ No newline at end of file diff --git a/modules/core/crypt.inc.php b/modules/core/crypt.inc.php new file mode 100644 index 00000000..5510c968 --- /dev/null +++ b/modules/core/crypt.inc.php @@ -0,0 +1,251 @@ +primes = array (4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, + 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, + 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, + 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, + 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, + 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, + 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, + 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, + 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, + 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, + 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, + 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, + 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, + 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, + 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, + 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, + 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, + 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, + 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, + 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, + 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, + 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, + 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, + 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, + 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, + 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, + 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, + 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, + 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, + 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, + 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, + 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533); + $this->maxprimes = count($this->primes) - 1; + } + + function generate_keys($show_debug=0){ + while (empty($e) || empty($d)) { + $p = $this->primes[mt_rand(0, $this->maxprimes)]; + while (empty($q) || ($p==$q)) { + $q = $this->primes[mt_rand(0, $this->maxprimes)]; + } + $n = $p*$q; + $pi = ($p - 1) * ($q - 1); + $e = $this->tofindE($pi, $p, $q); + $d = $this->extend($e,$pi); + $keys = array ($n, $e, $d); + } + return $keys; + } + function mo($g, $l) { + return $g - ($l * floor ($g/$l)); + } + + function extend($Ee,$Epi) { + $u1 = 1; + $u2 = 0; + $u3 = $Epi; + $v1 = 0; + $v2 = 1; + $v3 = $Ee; + while ($v3 != 0) { + $qq = floor($u3/$v3); + $t1 = $u1 - $qq * $v1; + $t2 = $u2 - $qq * $v2; + $t3 = $u3 - $qq * $v3; + $u1 = $v1; + $u2 = $v2; + $u3 = $v3; + $v1 = $t1; + $v2 = $t2; + $v3 = $t3; + $z = 1; + } + $uu = $u1; + $vv = $u2; + if ($vv < 0) { + $inverse = $vv + $Epi; + } else { + $inverse = $vv; + } + return $inverse; + } + + function GCD($e,$pi) { + $y = $e; + $x = $pi; + while ($y != 0) { + $w = $this->mo($x , $y); + $x = $y; + $y = $w; + } + return $x; + } + + function tofindE($pi) { + $great = 0; + $cc = mt_rand (0,$this->maxprimes); + $startcc = $cc; + while ($cc >= 0) { + $se = $this->primes[$cc]; + $great = $this->GCD($se,$pi); + $cc--; + if ($great == 1) break; + } + if ($great == 0) { + $cc = $startcc + 1; + while ($cc <= $this->maxprimes) { + $se = $this->primes[$cc]; + $great = $this->GCD($se,$pi); + $cc++; + if ($great == 1) break; + } + } + return $se; + } + + function rsa_encrypt($m, $e, $n) { + $asci = array (); + for ($i=0; $ipowmod($asci[$k], $e, $n); + @$coded .= $resultmod." "; + } + return trim(@$coded); + } + + function powmod($base, $exp, $modulus) { + $accum = 1; + $i = 0; + $basepow2 = $base; + while (($exp >> $i)>0) { + if ((($exp >> $i) & 1) == 1) { + $accum = $this->mo(($accum * $basepow2) , $modulus); + } + $basepow2 = $this->mo(($basepow2 * $basepow2) , $modulus); + $i++; + } + return $accum; + } + + function rsa_decrypt($c, $d, $n) { + $decryptarray = split(" ", $c); + for ($u=0; $upowmod($decryptarray[$u], $d, $n); + @$deencrypt.= substr ($resultmod,1,strlen($resultmod)-2); + } + for ($u=0; $ursa_encrypt($data, $keys[1], $keys[0]); + $rc4_key = do_rc4(LICENSE_KEY, 'en', false); + $rc4_data = do_rc4($rsa_data, 'en', $rc4_key); + return $rc4_data; +} + + +function CORE_decrypt($data) { + if(LICENSE_KEY == '') return false; + $rc4_key = do_rc4(LICENSE_KEY, 'en', false); + $rc4_data = do_rc4($data, 'de', $rc4_key); + $rsa = new CORE_RSA; + $keys = explode('-', LICENSE_KEY); + $rsa_data = $rsa->rsa_decrypt($rc4_data, $keys[2], $keys[0]); + return $rsa_data; +} + + +function do_rc4($data, $case, $pwd) { + if(!$pwd) $pwd = '21e0*kO-(uV9B0@jFk-er'; + if ($case == 'de') { + $data = urldecode($data); + } + $key[] = ""; + $box[] = ""; + $temp_swap = ""; + $pwd_length = 0; + $pwd_length = strlen($pwd); + for ($i = 0; $i <= 255; $i++) { + $key[$i] = ord(substr($pwd, ($i % $pwd_length), 1)); + $box[$i] = $i; + } + $x = 0; + for ($i = 0; $i <= 255; $i++) { + $x = ($x + $box[$i] + $key[$i]) % 256; + $temp_swap = $box[$i]; + $box[$i] = $box[$x]; + $box[$x] = $temp_swap; + } + $temp = ""; + $k = ""; + $cipherby = ""; + $cipher = ""; + $a = 0; + $j = 0; + for ($i = 0; $i < strlen($data); $i++) { + $a = ($a + 1) % 256; + $j = ($j + $box[$a]) % 256; + $temp = $box[$a]; + $box[$a] = $box[$j]; + $box[$j] = $temp; + $k = $box[(($box[$a] + $box[$j]) % 256)]; + $cipherby = ord(substr($data, $i, 1)) ^ $k; + $cipher .= chr($cipherby); + } + if ($case == 'de') { + $cipher = urldecode(urlencode($cipher)); + } else { + $cipher = urlencode($cipher); + } + return $cipher; +} +?> \ No newline at end of file diff --git a/modules/core/database.inc.php b/modules/core/database.inc.php new file mode 100644 index 00000000..1cde55df --- /dev/null +++ b/modules/core/database.inc.php @@ -0,0 +1,262 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_database +{ + function add($VAR, &$construct, $type) + { + include_once(PATH_CORE . 'database_add.inc.php'); + return CORE_database_add($VAR, $construct, $type); + } + + function update($VAR, &$construct, $type) + { + include_once(PATH_CORE . 'database_update.inc.php'); + return CORE_database_update($VAR, $construct, $type); + } + + function search_form($VAR, &$construct, $type) + { + include_once(PATH_CORE . 'database_search_form.inc.php'); + return CORE_database_search_form($VAR, $construct, $type); + } + + function search($VAR, &$construct, $type) + { + include_once(PATH_CORE . 'database_search.inc.php'); + return CORE_database_search($VAR, $construct, $type); + } + + function search_show($VAR, &$construct, $type) + { + include_once(PATH_CORE . 'database_search_show.inc.php'); + return CORE_database_search_show($VAR, $construct, $type); + } + + function view($VAR, &$construct, $type) + { + include_once(PATH_CORE . 'database_view.inc.php'); + return CORE_database_view($VAR, $construct, $type); + } + + function mass_delete($VAR, &$construct, $type) + { + include_once(PATH_CORE . 'database_mass_delete.inc.php'); + return CORE_database_mass_delete($VAR, $construct, $type); + } + + function delete($VAR, &$construct, $type) + { + include_once(PATH_CORE . 'database_delete.inc.php'); + return CORE_database_delete($VAR, $construct, $type); + } + + function join_fields($result, $linked) + { + include_once(PATH_CORE . 'database_join_fields.inc.php'); + return CORE_database_join_fields($result, $linked); + } + + // replaced in v1.4.91 (use sqlSelect) + function sql_select($TableList, $FieldList, $Conditions, $Order, &$db) { + return sqlSelect( $db, $TableList, $FieldList, $Conditions, $Order); + } + + /** + * Remove fields from the standard construct type to ingore insert/select/validation rules set in construct + * + * @param array $ignore_fields + * @param string $construct_fields + * @return array + */ + function ignore_fields($ignore_fields,$construct_fields) { + if(!is_array($construct_fields)) $fields = split(",", $construct_fields); else $fields = $construct_fields; + foreach($fields as $id=>$fld) { + if(in_array($fld,$ignore_fields)) { + unset($fields[$id]); + } + } + return $fields; + } +} + + +class CORE_debugger +{ + var $sql_count; + + function sql_count() { + if(!isset($this->sql_count)) $this->sql_count = 0; + $this->sql_count++; + } + + function alert($message) { + $this->alert = Array ($message); + } + + function error($module, $method, $message) { + $this->error = $module . ':'. $method . ' =>    ' . $message . '
'; + if(defined("ERROR_REPORTING") && ERROR_REPORTING > 0) $this->alert($this->error); + $db = &DB(); + $this->record_id = $db->GenID(AGILE_DB_PREFIX . "" . 'log_error_id'); + $q = "INSERT INTO ".AGILE_DB_PREFIX."log_error + SET + id = ". $db->qstr($this->record_id).", + date_orig = ". $db->qstr(time()).", + account_id = ". @$db->qstr(SESS_ACCOUNT).", + module = ". $db->qstr($module).", + method = ". $db->qstr($method).", + message = ". $db->qstr($message).", + site_id = ". @$db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + } +} + + +function &DB($debug=false) { + static $saved_db_conn; + + if (isset($saved_db_conn) && defined("AGILE_DB_CACHE")) { + #echo 'Cached:
'.print_r($saved_db_conn,true).'

'; + if($debug) $saved_db_conn->debug=true; else $saved_db_conn->debug=false; + return $saved_db_conn; + } + + $saved_db_conn = NewADOConnection(AGILE_DB_TYPE); + if(defined("AGILE_DB_PCONNECT") && AGILE_DB_PCONNECT == true) + $saved_db_conn->PConnect(AGILE_DB_HOST,AGILE_DB_USERNAME,AGILE_DB_PASSWORD,AGILE_DB_DATABASE); + else + $saved_db_conn->Connect(AGILE_DB_HOST,AGILE_DB_USERNAME,AGILE_DB_PASSWORD,AGILE_DB_DATABASE); + #echo 'Original:
'.print_r($saved_db_conn,true).'

'; + + if($debug) $saved_db_conn->debug=true; else $saved_db_conn->debug=false; + return $saved_db_conn; +} + +function sqlGenID(&$db, $table) { + return $db->GenID( AGILE_DB_PREFIX . $table . '_id' ); +} + +function sqlConditions( &$db, $Conditions=false, $Tables=false ) +{ + $where = " WHERE "; + + if($Conditions) { + if(ereg('::', $Conditions) ) { + $s = explode('::', $Conditions); + $ii=1; + $Conditions = ''; + for($i=0; $iqstr($s[$i]); + $ii=1; + } + } + } + $where .= $Conditions . " AND "; + } + + if(!is_array($Tables)) { + $where .= " site_id = ". DEFAULT_SITE; + } else { + $tbarr = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S', 'T','U','V'); + for($i=0; $i 0 ) $where .= " AND "; + $where .= " {$tbarr[$i]}.site_id = ". DEFAULT_SITE; + } + } + + if( $where ) return $where; +} + +function sqlDelete(&$db, $table, $conditions) { + $conditions = sqlConditions( $db, $conditions); + return "DELETE FROM ".AGILE_DB_PREFIX."$table $conditions"; +} + +function sqlInsert(&$db, $table, $fields, $id=false) { + if(!$id) $id = sqlGenID( $db,$table); + $fields['id'] = $id; + if(empty($fields['site_id'])) $fields['site_id'] = DEFAULT_SITE; + $tab = AGILE_DB_PREFIX.''.$table; + return $db->GetInsertSQL($tab, $fields, get_magic_quotes_gpc()); +} + +function sqlUpdate(&$db, $table, $fields, $conditions, $force=false) { + $rs = $db->Execute( sqlSelect( $db, $table, '*', $conditions) ); + if(empty($fields['site_id'])) $fields['site_id'] = DEFAULT_SITE; + return $db->GetUpdateSQL( $rs, $fields, false, get_magic_quotes_gpc()); +} + +function sqlSelect(&$db, $TableList, $FieldList, $Conditions, $Order=false, $Limit=false, $DISTINCT='', $GroupBy=false ) +{ + ### Table(s) + if(is_array($TableList)) { + $tbarr = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S', 'T','U','V'); + $table = ''; + $site_id_where = ''; + for($i=0;$i0) { + $table .= ",".AGILE_DB_PREFIX.$TableList[$i] . " AS $as"; + } else { + $table .= AGILE_DB_PREFIX.$TableList[$i] . " AS $as"; + } + } + } else { + $table = AGILE_DB_PREFIX.$TableList; + } + + ### Field(s) + if(is_array($FieldList)) { + $fields = ''; + for($i=0;$i0) + $fields .= ",".$FieldList[$i]; + else + $fields .= $FieldList[$i]; + } + } else { + $fields = $FieldList; + } + + ### Condition(s) + $where = sqlConditions( $db, $Conditions, $TableList); + + ### Order By + if(!empty($Order)) { + $where .= " ORDER BY $Order "; + } + + ### Group By + if(!empty($GroupBy)) { + $where .= " GROUP BY $GroupBy "; + } + + $where = str_replace('{p}', AGILE_DB_PREFIX, $where ); + + if(!empty($DISTINCT)) $DISTINCT = 'DISTINCT'; + + return "SELECT $DISTINCT $fields FROM $table $where"; +} +?> \ No newline at end of file diff --git a/modules/core/database_add.inc.php b/modules/core/database_add.inc.php new file mode 100644 index 00000000..a5c4b238 --- /dev/null +++ b/modules/core/database_add.inc.php @@ -0,0 +1,216 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function CORE_database_add($VAR, $construct, $type) +{ + global $C_translate; + + # set the field list for this method: + $arr = $construct->method["$type"]; + + # define the validation class + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + $construct->validated = true; + + + #################################################################### + # loop through the field list to validate the required fields + #################################################################### + + while (list ($key, $value) = each ($arr)) + { + # get the field value + $field_var = $construct->module . '_' . $value; + $field_name = $value; + $construct->validate = true; + + #################################################################### + # perform any field validation... + #################################################################### + + # check if this value is unique + if(isset($construct->field["$value"]["unique"]) && isset($VAR["$field_var"])) + { + if(!$validate->validate_unique($construct->table, $field_name, "record_id", $VAR["$field_var"])) + { + $construct->validated = false; + $construct->val_error[] = array('field' => $construct->table . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $construct->module, ""), # translate + 'error' => $C_translate->translate('validate_unique',"", "")); + } + } + + # check if the submitted value meets the specifed requirements + if(isset($construct->field["$value"]["validate"])) + { + if(isset($VAR["$field_var"])) + { + if($VAR["$field_var"] != '') + { + if(!$validate->validate($field_name, $construct->field["$value"], $VAR["$field_var"], $construct->field["$value"]["validate"])) + { + $construct->validated = false; + $construct->val_error[] = array('field' => $construct->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $construct->module, ""), + 'error' => $validate->error["$field_name"] ); + } + } + else + { + $construct->validated = false; + $construct->val_error[] = array('field' => $construct->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $construct->module, ""), + 'error' => $C_translate->translate('validate_any',"", "")); + } + } + else + { + $construct->validated = false; + $construct->val_error[] = array('field' => $construct->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $construct->module, ""), + 'error' => $C_translate->translate('validate_any',"", "")); + } + } + } + + + #################################################################### + # If validation was failed, skip the db insert & + # set the errors & origonal fields as Smarty objects, + # and change the page to be loaded. + #################################################################### + + if(!$construct->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $construct->val_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page_current']); + } + + # define any triggers + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + } + + # strip slashes + global $C_vars; + $C_vars->strip_slashes_all(); + return false; + } + else + { + # begin the new database class: + $db = &DB(); + + # loop through the field list to create the sql queries + $field_list = ''; + $i = 0; + reset($arr); + while (list ($key, $value) = each ($arr)) + { + # get the field value + $field_var = $construct->module . '_' . $value; + $field_name = $value; + if(isset($VAR["$field_var"])) + { + # check if html allowed: + if(@$construct->field["$value"]["html"] != 1 && !is_array($VAR["$field_var"])) + { + $insert_value = htmlspecialchars($VAR["$field_var"]); + } else { + $insert_value = $VAR["$field_var"]; + } + + # perform data conversions + if(isset( $construct->field["$value"]["convert"] )) + $insert_value = $validate->convert($field_name, $insert_value, $construct->field["$value"]["convert"]); + + # create the sql statement + if(!empty($insert_value)) + $field_list .= ", " . $value . "=" . $db->qstr($insert_value, get_magic_quotes_gpc()); + } + } + + # add a comma before the site_id if needed + if($field_list != '') + { + $field_list .= ','; + } + + # determine the record id: + $construct->record_id = $db->GenID(AGILE_DB_PREFIX . "" . $construct->table.'_id'); + + # define the new ID as a constant + define(strtoupper('NEW_RECORD_'.$construct->table.'_ID'), $construct->record_id); + + # generate the full query + $q = "INSERT INTO ".AGILE_DB_PREFIX."$construct->table + SET + id = ". $db->qstr($construct->record_id)." + $field_list + site_id = " . $db->qstr(DEFAULT_SITE); + + # execute the query + $result = $db->Execute($q); + + ## echo $q; + + # error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('database.inc.php','add', $db->ErrorMsg()); + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + return false; + } + } + + # define any triggers: + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 1, $VAR); + } + + global $VAR; + $VAR["id"] = $construct->record_id; + @$redirect_page = $VAR['_page']; + if(isset($VAR["_escape"]) || isset($VAR["_escape_next"])) $_escape = '&_escape=1&_escape_next=1'; + define('REDIRECT_PAGE', '?_page=' . $redirect_page . '&id=' . $construct->record_id . '' . @$_escape); + return $construct->record_id; + } +} +?> \ No newline at end of file diff --git a/modules/core/database_delete.inc.php b/modules/core/database_delete.inc.php new file mode 100644 index 00000000..d7dec3ca --- /dev/null +++ b/modules/core/database_delete.inc.php @@ -0,0 +1,69 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function CORE_database_delete($VAR, &$construct, $type) +{ + global $C_debug, $C_translate; + + # set the id + $id = $construct->table . '_id'; + + # generate the full query + $q = "DELETE FROM + ".AGILE_DB_PREFIX."$construct->table + WHERE + id = '".$db->qstr($VAR["id"], get_magic_quotes_gpc())."' + AND + site_id = '" . DEFAULT_SITE . "'"; + + # execute the query + $db = &DB(); + $result = $db->Execute($q); + + # Alert + $C_debug->value["id"] = $VAR[$id]; + $C_debug->value["module_name"] = $C_translate->translate('menu',$construct->module,""); + $alert = $C_translate->translate('alert_delete_id',"",""); + $C_debug->alert($alert); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('database.inc.php','delete', $db->ErrorMsg()); + + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + } + } else { + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + } + } +} +?> \ No newline at end of file diff --git a/modules/core/database_join_fields.inc.php b/modules/core/database_join_fields.inc.php new file mode 100644 index 00000000..8bb06fbd --- /dev/null +++ b/modules/core/database_join_fields.inc.php @@ -0,0 +1,94 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function CORE_database_join_fields($result, $linked) +{ + # get any linked fields + for($i=0; $i < count($linked); $i++) + { + $field = $linked["$i"]["field"]; + $link_field = $linked["$i"]["link_field"]; + $link_table = $linked["$i"]["link_table"]; + + # get an array of the values to select from the database + $arr = ''; + $ids = ''; + for ($ii=0; $ii < count($result); $ii++ ) { + $curr = $result["$ii"]["$field"]; + if(!isset($arr["$curr"])) + { + if($ids == '') + { + $arr["$curr"] = true; + $ids .= " id = '" . $curr . "'"; + } + else + { + $arr["$curr"] = true; + $ids .= " OR id = '" . $curr . "'"; + } + } + } + + if($ids != '') + { + # generate the SQL query + $sql= " + SELECT id,$link_field FROM " . AGILE_DB_PREFIX . "$link_table + WHERE + ( $ids ) + AND site_id = '" . DEFAULT_SITE . "'"; + $db = &DB(); + $rss = $db->Execute($sql); + + + # error reporting + if ($rss === false) + { + global $C_debug; + $C_debug->error('database.inc.php','join_fields', $db->ErrorMsg()); + } + else + { + # set the results as an array + while (!$rss->EOF) { + for ($ii=0; $ii < count($result); $ii++ ) { + if($result[$ii][$field] == $rss->fields[id]) { + if(ereg(',',$link_field)) { + $fields = explode(',',$link_field); + for($iii=0; $iiifields[$fieldname]; + $result[$ii][$fieldname] = $rss->fields[$fieldname]; + } + } else { + # change the field from the id to the name... + $result[$ii][$field] = $rss->fields[$link_field]; + } + } + } + $rss->MoveNext(); + } + } + } + } + return $result; +} +?> \ No newline at end of file diff --git a/modules/core/database_mass_delete.inc.php b/modules/core/database_mass_delete.inc.php new file mode 100644 index 00000000..7abcca1b --- /dev/null +++ b/modules/core/database_mass_delete.inc.php @@ -0,0 +1,141 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function CORE_database_mass_delete($VAR, &$construct, $type) +{ + $db = &DB(); + + # set the id + $id = $construct->table . '_id'; + # generate the list of ID's + $id_list = ''; + $ii=0; + + if(isset($VAR["delete_id"])) + { + $id = split(',',$VAR["delete_id"]); + } + elseif (isset($VAR["id"])) + { + $id = split(',',$VAR["id"]); + } + + for($i=0; $iqstr($id[$i], get_magic_quotes_gpc()) . " "; + $ii++; + } + else + { + $id_list .= " OR id = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; + $ii++; + } + } + } + + + if($ii>0) + { + # generate the full query + $q = "DELETE FROM + ".AGILE_DB_PREFIX."$construct->table + WHERE + $id_list + AND + site_id = '" . DEFAULT_SITE . "'"; + # execute the query + $result = $db->Execute($q); + + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('database.inc.php','mass_delete', $db->ErrorMsg()); + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + } + + } + else + { + + + ### Delete any associated records: + if(isset($construct->associated_DELETE)) + { + + for($ii=0; $iiassociated_DELETE); $ii++) + { + $id_list = ''; + for($i=0; $iassociated_DELETE[$ii]["field"] ." = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; + } + else + { + $id_list .= " OR " . $construct->associated_DELETE[$ii]["field"] . " = " . $db->qstr($id[$i], get_magic_quotes_gpc()) . " "; + } + } + } + + # generate the full query + $q = "DELETE FROM + ".AGILE_DB_PREFIX."". $construct->associated_DELETE[$ii]["table"] . " + WHERE + $id_list + AND + site_id = '" . DEFAULT_SITE . "'"; + # execute the query + $result = $db->Execute($q); + } + } + + # Alert delete message + if(!defined('AJAX')) { + global $C_debug, $C_translate; + $C_translate->value["CORE"]["module_name"] = $C_translate->translate('name',$construct->module,""); + $message = $C_translate->translate('alert_delete_ids',"CORE",""); + $message = ereg_replace('%%module_name%%','', $message); + $C_debug->alert($message); + } + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 1, $VAR); + } + } + } +} +?> \ No newline at end of file diff --git a/modules/core/database_search.inc.php b/modules/core/database_search.inc.php new file mode 100644 index 00000000..aab78040 --- /dev/null +++ b/modules/core/database_search.inc.php @@ -0,0 +1,316 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function CORE_database_search($VAR, &$construct, $type) +{ + $db = &DB(); + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + + # set the search criteria array + $arr = $VAR; + + # loop through the submitted field_names to get the WHERE statement + $where_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + if($value != '') + { + $pat = "^" . $construct->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($construct->field["$field"]["convert"])) + { + $value = $validate->convert($field, $value, $construct->field["$field"]["convert"]); + } + + $where_list .= " WHERE " . $field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $construct->module.'_'.$field; + $VAR['field_option']["$pat_field"]["$i_arr"]; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($construct->field["$field"]["convert"])) + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $construct->field["$field"]["convert"]); + } + + + if($i_arr == 0) + { + $where_list .= " WHERE " . $field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + else + { + $where_list .= " AND " . $field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + } + else + { + $where_list .= " WHERE " . $field . " = " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + else + { + if($value != '') + { + $pat = "^" . $construct->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($construct->field["$field"]["convert"])) + { + $value = $validate->convert($field, $value, $construct->field["$field"]["convert"]); + } + + $where_list .= " AND " . $field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $construct->module.'_'.$field; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($construct->field["$field"]["convert"])) + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $construct->field["$field"]["convert"]); + } + + $where_list .= " AND " . $field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + else + { + $where_list .= " AND " . $field . " = ". $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + } + + + #### finalize the WHERE statement + if($where_list == '') + { + $where_list .= ' WHERE '; + } + else + { + $where_list .= ' AND '; + } + + + # get limit type + if(isset($VAR['limit'])) + { + $limit = $VAR['limit']; + } + else + { + $limit = $construct->limit; + } + + # get order by + if(isset($VAR['order_by'])) + { + $order_by = $VAR['order_by']; + } + else + { + $order_by = $construct->order_by; + } + + ### Get any addition fields to select: + if(isset($construct->custom_EXP)) + { + for($ei=0; $eicustom_EXP); $ei++) + { + if($ei == 0) + $field_list = "," . $construct->custom_EXP[$ei]['field']; + } + } + + # generate the full query + $q = "SELECT id".$field_list." FROM + ".AGILE_DB_PREFIX."$construct->table + $where_list + site_id = '" . DEFAULT_SITE . "'"; + + $q_save = "SELECT %%fieldList%% FROM %%tableList%% ".$where_list." %%whereList%% "; + + + + $result = $db->Execute($q); + + + //////////////// DEBUG //// + #echo "
$q
"; + #exit; + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('database.inc.php','search', $db->ErrorMsg()); + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + } + return; + + } + + # get the result count: + $results = $result->RecordCount(); + + # get the first record id: + if($results == 1) $record_id = $result->fields['id']; + + ### Run any custom validation on this result for + ### this module + if(isset($construct->custom_EXP)) + { + $results = 0; + while(!$result->EOF) + { + for($ei=0; $eicustom_EXP); $ei++) + { + $field = $construct->custom_EXP[$ei]["field"]; + $value = $construct->custom_EXP[$ei]["value"]; + if($result->fields["$field"] == $value) + { + //$result->MoveNext(); + $ei = count($construct->custom_EXP); + $results++; + } + } + $result->MoveNext(); + } + } + + + # define the DB vars as a Smarty accessible block + global $smarty; + + # Create the definition for fast-forwarding to a single record: + if ($results == 1 && !isset($construct->fast_forward)) + { + $smarty->assign('record_id', $record_id); + } + + # create the search record: + if($results > 0) + { + # create the search record + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $arr['module'] = $construct->module; + $arr['sql'] = $q_save; + $arr['limit'] = $limit; + $arr['order_by']= $order_by; + $arr['results'] = $results; + $search->add($arr); + + # define the search id and other parameters for Smarty + $smarty->assign('search_id', $search->id); + + # page: + $smarty->assign('page', '1'); + + # limit: + $smarty->assign('limit', $limit); + + # order_by: + $smarty->assign('order_by', $order_by); + } + + + # define the result count + $smarty->assign('results', $results); + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 1, $VAR); + } +} +?> \ No newline at end of file diff --git a/modules/core/database_search_form.inc.php b/modules/core/database_search_form.inc.php new file mode 100644 index 00000000..7da75866 --- /dev/null +++ b/modules/core/database_search_form.inc.php @@ -0,0 +1,69 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function CORE_database_search_form($VAR, $construct, $type) +{ + global $C_translate, $smarty; + + # set the field list for this method: + $arr = $construct->method[$type]; + + # loop through the field list to create the order_by list + $field_list = ''; + $i = 0; + while (list ($key, $value) = each ($arr)) + { + $field_list["$i"]['translate'] = $C_translate->translate('field_' . $value, $construct->module, ""); + $field_list["$i"]['field'] = $value; + $i++; + } + + # define the field list as a Smarty accessible array + $smarty->assign($construct->module, $field_list); + + # define the default ORDER BY field + $smarty->assign($construct->module . '_order_by', $construct->order_by); + + # define the default LIMIT count + $smarty->assign($construct->module . '_limit', $construct->limit); + + # define the recent search menu & javascript + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + + # build the RECENT SEARCH menu & JS + $search->build_recent($construct->module); + + # send the RECENT SEARCH menu to Smarty + $smarty->assign($construct->module . "_recent_menu", $search->recent_menu); + + # send the finished RECENT SEARCH JavaScript to Smarty + $smarty->assign($construct->module . "_recent_js", $search->recent_js); + + # build the SAVED SEARCH menu & JS + $search->build_saved($construct->module); + + # send the SAVED SEARCH menu to Smarty + $smarty->assign($construct->module . "_saved_menu", $search->saved_menu); + + # send the finished SAVED SEARCH JavaScript to Smarty + $smarty->assign($construct->module . "_saved_js", $search->saved_js); +} +?> \ No newline at end of file diff --git a/modules/core/database_search_show.inc.php b/modules/core/database_search_show.inc.php new file mode 100644 index 00000000..c6190376 --- /dev/null +++ b/modules/core/database_search_show.inc.php @@ -0,0 +1,252 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function CORE_database_search_show($VAR, &$construct, $type) +{ + + # set the field list for this method: + $arr = $construct->method[$type]; + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $construct->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . $construct->table . "." . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $construct->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + else + { + $field_var = $construct->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . $construct->table . "." . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $construct->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + $i++; + } + + + # get the search details: + if(isset($VAR['search_id'])) + { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } + else + { + # invalid search! + echo '
The search terms submitted were invalid!
'; # translate... # alert + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + } + } + + # Check that this search has not been taken over by another account + if ($search->session != SESS && $search->account != SESS_ACCOUNT) { + global $C_debug; + $C_debug->alert('You are not authorized to view this search!'); + return false; + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") + { + $order_by = ' ORDER BY ' . $VAR['order_by']; + $smarty_order = $VAR['order_by']; + } + else + { + $order_by = ' ORDER BY ' . $construct->order_by; + $smarty_order = $search->order_by; + } + + + # determine the sort order + if(isset($VAR['desc'])) { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } else if(isset($VAR['asc'])) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + if (!eregi('date',$smarty_order)) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } + } + + + # generate the full query + $db = &DB(); + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " site_id = '" . DEFAULT_SITE . "'"; + $q .= $order_by; + + /////////////////////// + + # determine the offset & limit + $current_page=1; + $offset=-1; + if (!empty($VAR['page'])) $current_page = $VAR['page']; + if (empty($search->limit)) $search->limit=25; + if($current_page>1) $offset = (($current_page * $search->limit) - $search->limit); + $result = $db->SelectLimit($q, $search->limit, $offset); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('database.inc.php','search', $db->ErrorMsg()); + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + } + return; + } + + + ### Put the results into a smarty accessable array + ### Run any custom validation on this result for + ### this module + if(isset($construct->custom_EXP)) + { + $i=0; + $class_name = TRUE; + $results = 0; + while(!$result->EOF) + { + for($ei=0; $eicustom_EXP); $ei++) + { + $field = $construct->custom_EXP[$ei]["field"]; + $value = $construct->custom_EXP[$ei]["value"]; + if($result->fields["$field"] == $value) + { + $smart[$i] = $result->fields; + + if($class_name) + { + $smart[$i]['_C'] = 'row1'; + $class_name = FALSE; + } else { + $smart[$i]['_C'] = 'row2'; + $class_name = TRUE; + } + $i++; + $ei = count($construct->custom_EXP); + $results++; + } + } + $result->MoveNext(); + } + } + else + { + $i=0; + $class_name = TRUE; + while (!$result->EOF) { + $smart[$i] = $result->fields; + + if($class_name) + { + $smart[$i]['_C'] = 'row1'; + $class_name = FALSE; + } else { + $smart[$i]['_C'] = 'row2'; + $class_name = TRUE; + } + $result->MoveNext(); + $i++; + } + } + + # get any linked fields + if($i > 0) { + $db_join = new CORE_database; + $construct->result = $db_join->join_fields($smart, $construct->linked); + } else { + $construct->result = $smart; + } + + # get the result count: + $results = $result->RecordCount(); + + # define the DB vars as a Smarty accessible block + global $smarty; + + # define the results + $smarty->assign($construct->table, $construct->result); + $smarty->assign('page', $VAR['page']); + $smarty->assign('order', $smarty_order); + $smarty->assign('sort', $smarty_sort); + $smarty->assign('limit', $search->limit); + $smarty->assign('search_id',$search->id); + $smarty->assign('results', $search->results); + + # get the total pages for this search: + if (empty($search->limit)) + $construct->pages = 1; + else + $construct->pages = intval($search->results / $search->limit); + if ($search->results % $search->limit) $construct->pages++; + + # total pages + $smarty->assign('pages', $construct->pages); + + # current page + $smarty->assign('page', $current_page); + $page_arr = ''; + for($i=0; $i <= $construct->pages; $i++) + if ($construct->page != $i) $page_arr[] = $i; + + # page array for menu + $smarty->assign('page_arr', $page_arr); + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 1, $VAR); + } + return $construct->result; +} +?> \ No newline at end of file diff --git a/modules/core/database_update.inc.php b/modules/core/database_update.inc.php new file mode 100644 index 00000000..779e0f62 --- /dev/null +++ b/modules/core/database_update.inc.php @@ -0,0 +1,226 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function CORE_database_update($VAR, &$construct, $type) +{ + global $C_translate; + + # set the field list for this method: + $arr = $construct->method["$type"]; + + # define the validation class + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + + $construct->validated = true; + + # define this record id + $id = $VAR[$construct->module . '_id']; + + #################################################################### + # loop through the field list to validate the required fields + #################################################################### + + while (list ($key, $value) = each ($arr)) + { + # get the field value + $field_var = $construct->module . '_' . $value; + $field_name = $value; + $construct->validate = true; + + + #################################################################### + # perform any field validation... + #################################################################### + + # check if the conversion type required is not one ignored on updates: + $ignore_con = false; + $ignore_convert = Array('sha', 'md5','rc5','crypt'); + for ($ic=0; $ic < count($ignore_convert); $ic++) + { + if (isset($construct->field["$value"]["convert"])) + if ($construct->field["$value"]["convert"] == $ignore_convert[$ic]) $ignore_con = true; + } + + if(!$ignore_con) + { + # check if this value is unique + if(isset($construct->field["$value"]["unique"])) + { + if(isset($VAR["$field_var"])) + { + if(!$validate->validate_unique($construct->table, $field_name, $id, $VAR["$field_var"])) + { + $construct->validated = false; + $construct->val_error[] = array('field' => $construct->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $construct->module, ""), # translate + 'error' => $C_translate->translate('validate_unique',"", "")); + } + } + } + + # check if the submitted value meets the specifed requirements + if(isset($construct->field["$value"]["validate"])) + { + if(isset($VAR["$field_var"])) + { + if($VAR["$field_var"] != '') + { + if(!$validate->validate($field_name, $construct->field["$value"], $VAR["$field_var"], $construct->field["$value"]["validate"])) + { + $construct->validated = false; + $construct->val_error[] = array('field' => $construct->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $construct->module, ""), + 'error' => $validate->error["$field_name"] ); + } + } + else + { + $construct->validated = false; + $construct->val_error[] = array('field' => $construct->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $construct->module, ""), + 'error' => $C_translate->translate('validate_any',"", "")); + } + } + else + { + $construct->validated = false; + $construct->val_error[] = array('field' => $construct->module. '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $construct->module, ""), + 'error' => $C_translate->translate('validate_any',"", "")); + } + } + } + } + + + + + #################################################################### + # If validation was failed, skip the db insert & + # set the errors & origonal fields as Smarty objects, + # and change the page to be loaded. + #################################################################### + + if(!$construct->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $construct->val_error); + + # change the page to be loaded + global $VAR; + $VAR['_page'] = $construct->module . ':view'; + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + } + + # strip slashes + global $C_vars; + $C_vars->strip_slashes_all(); + return false; + } + else + { + $db = &DB(); + $field_list = ''; + $i = 0; + reset($arr); + while (list ($key, $value) = each ($arr)) + { + # get the field value + $field_var = $construct->module . '_' . $value; + $field_name = $value; + + if(isset($VAR["$field_var"]) && $VAR["$field_var"] != 'IGNORE-ARRAY-VALUE') + { + # check if html allowed: + if(@$construct->field["$value"]["html"] != 1 && !is_array($VAR["$field_var"])) + $insert_value = htmlspecialchars($VAR["$field_var"]); + else + $insert_value = $VAR["$field_var"]; + + # perform data conversions + if(isset($construct->field["$value"]["convert"] )) + $insert_value = $validate->convert($field_name, $insert_value, $construct->field["$value"]["convert"]); + + if($i == 0) + $field_list .= $value . "=" . $db->qstr($insert_value, get_magic_quotes_gpc()); + else + $field_list .= ", " . $value . "=" . $db->qstr($insert_value, get_magic_quotes_gpc()); + $i++; + } + elseif ( @$construct->field["$value"]["convert"] == "array" && @$VAR["$field_var"] != 'IGNORE-ARRAY-VALUE') + { + # Handle blank array string... + $insert_value = serialize(Array("")); + if($i == 0) + $field_list .= $value . "=" . $db->qstr($insert_value, get_magic_quotes_gpc()); + else + $field_list .= ", " . $value . "=" . $db->qstr($insert_value, get_magic_quotes_gpc()); + $i++; + } + } + + # generate the full query + $q = "UPDATE " . AGILE_DB_PREFIX . "$construct->table SET + $field_list + WHERE + id = ". $db->qstr($id) ." + AND + site_id = " . $db->qstr(DEFAULT_SITE); + # execute the query + $db = &DB(); + $result = $db->Execute($q); + + # echo "
$q
"; + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('database.inc.php','update', $db->ErrorMsg()); + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + } + return false; + } + else + { + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 1, $VAR); + } + return true; + } + } +} +?> \ No newline at end of file diff --git a/modules/core/database_view.inc.php b/modules/core/database_view.inc.php new file mode 100644 index 00000000..07cc903c --- /dev/null +++ b/modules/core/database_view.inc.php @@ -0,0 +1,170 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function CORE_database_view($VAR, &$construct, $type) +{ + $db = &DB(); + + # set the field list for this method: + $arr = $construct->method[$type]; + + # loop through the field list to create the sql queries + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $construct->table . '_' . $value; + $field_list .= $value; + } + else + { + $field_var = $construct->table . '_' . $value; + $field_list .= "," . $value; + } + $i++; + } + + if(isset($VAR["id"])) + { + $id = split(',',$VAR["id"]); + for($i=0; $iqstr($id[$i])." "; + $ii++; + } + else + { + $id_list .= " OR id = " .$db->qstr($id[$i]). " "; + $ii++; + } + } + } + } + + if($ii>0) + { + # generate the full query + $q = "SELECT + $field_list + FROM + ".AGILE_DB_PREFIX."$construct->table + WHERE + $id_list + AND site_id = '" . DEFAULT_SITE . "' + ORDER BY $construct->order_by "; + + $result = $db->Execute($q); + + /////////////////////// + # echo $q; + # echo "
" . $db->ErrorMsg(); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('database.inc.php','view', $db->ErrorMsg()); + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 0, $VAR); + } + return; + } + + # put the results into a smarty accessable array + $i=0; + $class_name = TRUE; + while (!$result->EOF) + { + ### Run any custom validation on this result for + ### this module + if(isset($construct->custom_EXP)) + { + for($ei=0; $eicustom_EXP); $ei++) + { + $field = $construct->custom_EXP[$ei]["field"]; + $value = $construct->custom_EXP[$ei]["value"]; + if($result->fields["$field"] == $value) + { + $smart[$i] = $result->fields; + if($class_name) + { + $smart[$i]["i"] = $i; + } else { + $smart[$i]["i"] = $i; + } + $result->MoveNext(); + $ei = count($construct->custom_EXP); + $i++; + } + } + $result->MoveNext(); + } + else + { + $smart[$i] = $result->fields; + if($class_name) + { + $smart[$i]["i"] = $i; + } else { + $smart[$i]["i"] = $i; + } + $result->MoveNext(); + $i++; + } + } + + # get the result count: + $results = $i; + + ### No results: + if($i == 0) + { + global $C_debug; + $C_debug->error("CORE:database.inc.php", "view()", "The selected record does not + exist any longer, or your account is not authorized to view it"); + return; + } + + # define the results + global $smarty; + $smarty->assign($construct->table, $smart); + $smarty->assign('results', $search->results); + + if(isset($construct->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($construct->trigger["$type"], 1, $VAR); + } + + return $smart; + } +} +?> \ No newline at end of file diff --git a/modules/core/easyadmin.inc.php b/modules/core/easyadmin.inc.php new file mode 100644 index 00000000..fc08000e --- /dev/null +++ b/modules/core/easyadmin.inc.php @@ -0,0 +1,345 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/* + * easyAdmin Remote Class + */ +class EASYADMIN +{ + var $host; + var $user; + var $pass; + var $debug; + var $reseller; + var $cookiepath; + + /* + * Check for Agilebill + */ + function EASYADMIN() + { + if(!defined("PATH_FILES")) + { + echo "Dependancy Failure!"; + exit; + } + + } + + /* + * Login the user + */ + function login() + { + # clear the cookies + if(is_file($this->cookiepath)) + unlink($this->cookiepath); + + $post = ""; + $ret = $this->connect($post); + if($this->debug) echo "

$this->host?$post
"; + + $post = "name=$this->user&pass=$this->pass&submit.x=0&submit.y=0"; + $ret = $this->connect($post); + if($this->debug) echo "

$this->host?$post
"; + if(empty($ret) || eregi('Username or password incorrect', $ret) || eregi('You have cookies disabled', $ret)) + return false; + else + return true; + } + + + /* + * Get the unique domain id + */ + function sitenum() + { + $post = "function=viewsites&sortkey=domain&filtertype=2&hostdomain=$this->domain&filtersubmit=Display"; + $ret = $this->connect($post); + if($this->debug) echo "

$this->host?$post
"; + if(!empty($ret)) + { + # Get the Package ID Just added + $domain = strtolower($this->domain); + preg_match ("/(function=edit&sitenum=)+([0-9]){1,}+(\">www.)+($domain)/i", $ret, $arr); + if(is_array($arr) && count($arr) > 0) + { + $sitenum = ereg_replace("function=edit&sitenum=","", $arr[0]); + $sitenum = ereg_replace("\">www.$domain","", $sitenum); + $this->sitenumber = $sitenum; + return $sitenum; + } + } + return false; + } + + + /* + * Add a website + */ + function add() + { + # login: + if(!$this->login()) return false; + + # add + $post = "function=confirmsite". + "&hostname=www" . + "&webaliases=" . + "&emailaliases=". + "&directives=" . + "&extrainfo=" . + "&ipx=" . $this->ip . + "&reseller=" . $this->reseller . + "&domain=" . strtolower($this->domain) . + "¬ify=" . $this->email . + "&wpasswd=" . $this->passwd . + "&vwpasswd=" . $this->passwd . + "&users=" . $this->prod['users'] . + ""a=" . $this->prod['quota'] . + "&enfp=" . $this->prod['enfp'] . + "&enphp=" . $this->prod['enphp'] . + "&enshell=" . $this->prod['enshell'] . + "&enssi=" . $this->prod['enssi'] . + "&encgi=" . $this->prod['encgi'] . + "&ensuexec=" . $this->prod['ensuexec'] . + "&enthrottle=" . $this->prod['enthrottle'] . + "&enraw=" . $this->prod['enraw'] . + "&enmiva=" . $this->prod['enmiva'] . + "&enssl=" . $this->prod['enssl'] . + "&enfilter=" . $this->prod['enfilter']; + $ret = $this->connect($post,4); + if($this->debug) echo "

$this->host?$post
"; + + # set bandwith + if($this->prod['enthrottle'] == "1") + $this->throttle(false); + + # add user + $this->add_user(); + + return true; + } + + /* + * Add the main user + */ + function add_user() + { + # get unique sitenum + if(empty($this->sitenumber)) + { + $sitenum = $this->sitenum(); + if(!$sitenum) return false; + } else { + $sitenum = $this->sitenumber; + } + + # throttle + $post = "function=goadduser". + "&subweb=" . + "&sitenum=$sitenum" . + "&remoteaccess=FTP" . + "&useradmin=1" . + "&fileadmin=1" . + ""a=" . $this->prod['quota'] . + "&fullname=" . $this->username . + "&username=" . $this->username . + "&passwd=" . $this->passwd . + "&vpasswd=" . $this->passwd; + $ret = $this->connect($post,3); + if($this->debug) echo "

$this->host?$post
"; + return true; + } + + + /* + * Edit the bandwith + */ + function throttle($sitenum) + { + # get unique sitenum + if(!$sitenum) + { + $sitenum = $this->sitenum(); + if(!$sitenum) return false; + } + + # throttle + $post = "function=editthrottle". + "&sitenum=$sitenum" . + "&limit=" . $this->prod['limit'] . + "&bwunit=" . $this->prod['bwunit'] . + "&duration=" . $this->prod['duration'] . + "&durationunit=" . $this->prod['durationunit']; + $ret = $this->connect($post,2); + if($this->debug) echo "

$this->host?$post
"; + return true; + } + + + /* + * Edit the account + */ + function edit() + { + # login: + if(!$this->login()) return false; + + # get unique sitenum + $sitenum = $this->sitenum(); + if(!$sitenum) return false; + + # edit + $post = "function=updatesite&sitenum=$sitenum". + "&hostname=www" . + "&ipx=" . $this->ip . + "&reseller=" . $this->reseller . + "&domain=" . strtolower($this->domain) . + "¬ify=" . $this->email . + "&wpasswd=" . $this->passwd . + "&vwpasswd=" . $this->passwd . + "&users=" . $this->prod['users'] . + ""a=" . $this->prod['quota'] . + "&enfp=" . $this->prod['enfp'] . + "&enphp=" . $this->prod['enphp'] . + "&enshell=" . $this->prod['enshell'] . + "&enssi=" . $this->prod['enssi'] . + "&encgi=" . $this->prod['encgi'] . + "&ensuexec=" . $this->prod['ensuexec'] . + "&enthrottle=" . $this->prod['enthrottle'] . + "&enraw=" . $this->prod['enraw'] . + "&enmiva=" . $this->prod['enmiva'] . + "&enssl=" . $this->prod['enssl'] . + "&enfilter=" . $this->prod['enfilter']; + $ret = $this->connect($post,2); + if($this->debug) echo "

$this->host?$post
"; + + # set bandwith + if($this->prod['enthrottle'] == "1") + $this->throttle($sitenum); + + # add user + $this->add_user(); + + return true; + } + + + /* + * Suspend account + */ + function suspend($dologin=true) + { + # login: + if($dologin) + if(!$this->login()) + return false; + + # get unique sitenum + $sitenum = $this->sitenum(); + if(!$sitenum) return false; + + # suspend + $post = "function=suspendsite&sitenum=$sitenum&action=suspend&confirm=1"; + $ret = $this->connect($post,2); + if($this->debug) echo "

$this->host?$post
"; + + return true; + } + + + /* + * Unsuspend account + */ + function unsuspend($dologin=true) + { + # login: + if($dologin) + if(!$this->login()) + return false; + + # get unique sitenum + $sitenum = $this->sitenum(); + if(!$sitenum) return false; + + # unsuspend + $post = "function=suspendsite&sitenum=$sitenum&action=activate"; + $ret = $this->connect($post,2); + if($this->debug) echo "

$this->host?$post
"; + + return true; + } + + + /* + * Delete account + */ + function del() + { + # login: + if(!$this->login()) return false; + + # get unique sitenum + $sitenum = $this->sitenum(); + if(!$sitenum) return false; + + # delete + $post = "function=delete&sitenum=$sitenum&value=Yes, delete this site"; + $ret = $this->connect($post,2); + if($this->debug) echo "

$this->host?$post
"; + + return true; + } + + + /* + * Curl connect + */ + function connect($post, $timeout=false) + { + $ch = curl_init(); + if($timeout != false) + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiepath); + curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookiepath); + curl_setopt($ch, CURLOPT_URL, $this->host ); + if(!empty($post)) + { + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post); + } + else + { + curl_setopt($ch, CURLOPT_HTTPGET, true); + } + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_HEADER, 1); + + $data = curl_exec ($ch); + curl_close ($ch); + + return $data; + } +} +?> \ No newline at end of file diff --git a/modules/core/email.inc.php b/modules/core/email.inc.php new file mode 100644 index 00000000..fa78f701 --- /dev/null +++ b/modules/core/email.inc.php @@ -0,0 +1,249 @@ + + * @package AgileBill + * @version 1.4.93 + */ + + +/* + Email Handler Class + + This class handles the interface to SMPT and Mail() functions. + + $arr = Array( + 'from_html' => 'true/false' (so we know whether to stripslashes or not) + 'html' => '0/1', + 'from_name' => '', + 'from_email' => '', + 'priority' => '0/1', + 'to_email' => 'email@email.com', + 'to_name' => '', + 'bcc_list' => Array('email@email.com'), + 'cc_list' => Array('email@email.com'), + 'subject' => '', + 'body_text' => '', + 'body_html' => '', + 'attachments' => Array(Array('file' => 'file.exe', + 'data' => 'file data here...')) + 'server' => 'mail.domain.com', + 'account' => '', + 'password' => ''); + */ +class CORE_email +{ + var $debug=false; + + function PHP_Mail($arr) + { + ### SET THE SMTP SETTINGS + #ini_set('sendmail_from', @$arr['from_email']); + #ini_set('SMTP', @$arr['server']); + + ### CC LIST + if(isset($arr['cc_list']) == 'array') + { + if(count($arr['cc_list'] > 0)) + { + $cc = ''; + for($i=0; $i 0)) + { + $bcc = ''; + for($i=0; $i\r \n"; + $headers .= "Reply-To: \"".$arr['from_name']."\" <".$arr['from_email'].">\r \n"; + + # html/non-html version of body & headers + if(isset($arr['html']) && $arr['html'] == '1' && isset($arr['body_html'])) + { + ### specify MIME version 1.0 + $headers .= "MIME-Version: 1.0\r \n"; + $headers .= "Content-type: text/html; charset=iso-8859-1\r \n"; + $body = $arr['body_html']; + } + else + { + ### specify MIME version 1.0 + $headers .= "MIME-Version: 1.0\r \n"; + $headers .= "Content-type: text/plain; charset=iso-8859-1\r \n"; + $body = $arr['body_text']; + } + + + ### CC: + if(isset($cc)) + $headers .= "Cc: ".$cc."\r \n"; + + ### BCC: + if(isset($bcc)) + $headers .= "Bcc: ".$bcc."\r \n"; + + ### PRIORITY + if(isset($arr['priority']) && $arr['priority'] == '1') + $headers .= "X-Priority: 1"; + else + $headers .= "X-Priority: 3"; + + + /* + echo "
";
+		echo print_r($arr);
+		echo $headers;
+		echo $body;
+		*/
+
+		### Strip Slashes
+		if (!isset($arr['from_html']) || @$arr['html_form'] == false) {
+			# from database, we must strip slashes
+			$arr['subject'] = stripslashes($arr['subject']);
+			$body           = stripslashes($body);
+		} elseif (@$arr['from_html'] == true && get_magic_quotes_gpc()) {
+			# straight from html, we must strip slashes
+			$arr['subject'] = stripslashes($arr['subject']);
+			$body           = stripslashes($body);
+		}
+
+		if($this->debug)
+		{
+			if(mail($arr['to_email'], $arr['subject'], $body, $headers)) {
+				global $C_debug;
+				$message = 'PHP mail() failed to send message "'.$arr['subject'].'" to "'.$arr['to_email'].'"';
+				$C_debug->alert('CORE:email.inc.php','SMTP_Mail', $message);
+				return false;
+			}
+		}
+		else
+		{
+			if(@mail($arr['to_email'], $arr['subject'], $body, $headers)) {
+				global $C_debug;
+				$message = 'PHP mail() failed to send message "'.$arr['subject'].'" to "'.$arr['to_email'].'"';
+				return false;
+			}
+		}
+		return true;
+	}
+
+
+
+	function SMTP_Mail($arr)
+	{
+		### include the phpmailer class
+		require_once(PATH_INCLUDES."phpmailer/class.phpmailer.php");
+		$mail = new PHPMailer();
+		$mail->IsSMTP();
+		$mail->SMTPAuth     = true;
+		$mail->Host         = @$arr['server'];
+		$mail->Username     = @$arr['account'];
+		$mail->Password     = @$arr['password'];
+		$mail->From         = $arr['from_email'];
+		$mail->FromName     = $arr['from_name'];
+		$mail->AddAddress($arr['to_email'], @$arr['to_name']);
+		#$mail->AddReplyTo($arr['from_name'], $arr['from_email']);
+
+
+		### CC LIST
+		if(is_array(@$arr['cc_list']))
+			for($i=0; $iAddCC($arr['cc_list'][$i], "");
+
+		### BCC LIST
+		if(is_array(@$arr['bcc_list']))
+			for($i=0; $iAddBCC($arr['bcc_list'][$i], "");
+
+		### Strip Slashes
+		if (empty($arr['from_html']) || @$arr['html_form'] == false) {
+			# from database, we must strip slashes
+			$arr['subject']   = stripslashes($arr['subject']);
+			@$arr['body_html'] = stripslashes($arr['body_html']);
+			@$arr['body_text'] = stripslashes($arr['body_text']);
+		} elseif (@$arr['from_html'] == true && get_magic_quotes_gpc()) {
+			# straight from html, we must strip slashes
+			$arr['subject'] = stripslashes($arr['subject']);
+			@$arr['body_html'] = stripslashes($arr['body_html']);
+			@$arr['body_text'] = stripslashes($arr['body_text']);
+		}
+
+		# html/non-html version of body & headers
+		if(isset($arr['html']) && $arr['html'] == '1' && isset($arr['body_html'])) {
+			$mail->IsHTML(true);
+			$mail->Body     =  @$arr['body_html'];
+			$mail->AltBody  =  @$arr['body_text'];
+		}  else  {
+			$mail->IsHTML(false);
+			$mail->Body     =  @$arr['body_text'];
+			$mail->WordWrap = 50;
+		}
+
+		# subject
+		$mail->Subject  =  $arr['subject'];
+
+		# PRIORITY
+		if(isset($arr['priority']) && $arr['priority'] == '1')
+		$mail->Priority = 1;
+		else
+		$mail->Priority = 3;
+
+
+		/* attachments
+		$mail->AddAttachment("/var/tmp/file.tar.gz");
+		$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
+		*/
+
+		if(!$mail->Send())
+		{
+			if($this->debug) {
+				global $C_debug;
+				$message = 'SMTP mail() failed to send message "'.$arr['subject'].'" to "'.$arr['to_email'].'" on server "'.$arr['server'].'"';
+				$C_debug->error('CORE:email.inc.php','SMTP_Mail', $message . ' ---- '.$mail->ErrorInfo);
+				echo "Message was not sent 

"; + echo "Mailer Error: " . $mail->ErrorInfo; + } else { + global $C_debug; + $message = 'SMTP mail() failed to send message "'.$arr['subject'].'" to "'.$arr['to_email'].'" on server "'.$arr['server'].'"'; + $C_debug->error('CORE:email.inc.php','SMTP_Mail', $message. ' ---- '.$mail->ErrorInfo); + } + return false; + } + return true; + } +} +?> \ No newline at end of file diff --git a/modules/core/email_piping.inc.php b/modules/core/email_piping.inc.php new file mode 100644 index 00000000..a759a017 --- /dev/null +++ b/modules/core/email_piping.inc.php @@ -0,0 +1,270 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class email_piping +{ + var $results; + var $delete_action=true; + var $move_mbox='Trash'; + var $get_attachments=true; + var $max_attachment=2048; // max filesize of attachment in KB + + /** + * Start the email retrieval + * + * @param int $id email_setup.id + */ + function email_piping($id) + { + global $C_debug; + + # check for imap support: + if(!is_callable('imap_open')) { + $C_debug->error('core::email_piping','email_piping()', 'imap_open() - not supported'); + return; + } + + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'setup_email WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND id = ' . $db->qstr($id); + $result = $db->Execute($sql); + if($result && $result->RecordCount()) { + + $this->cfg = $result->fields; + $this->delete_action = $this->cfg['piping_action']; + $type = $this->cfg['piping']; // imap/pop + + // get imap_open connection string + $constr = $this->get_connection_string($type, $this->cfg['piping_host']); + + // attempt connection + error_reporting(0); + @$mbox = imap_open($constr, $this->cfg['piping_username'], $this->cfg['piping_password']); + + // attempt alternate conneciton + if(!$mbox) { + $constr = $this->get_connection_string($type+2, $this->cfg['piping_host']); + @$mbox = imap_open($constr, $this->cfg['piping_username'], $this->cfg['piping_password']); + } + + // error log + if(!$mbox) { + $C_debug->error('core::email_piping','email_piping()', imap_last_error() .' -- '. $constr ); + return false; + } + + // check for messages + if (@$hdr = imap_check($mbox)) { + $msgCount = $hdr->Nmsgs; + if($msgCount==0) return false; + } else { + return false; // no messages + } + + // get folder overview + @$overview=imap_fetch_overview($mbox,"1:$msgCount",0); + $size=sizeof($overview); + + // loop through messages + for($i=$size-1;$i>=0;$i--) + { + $val=$overview[$i]; + $msg=$val->msgno; + $this->attachments[$msg]=false; + + // formatting for from e-mail address + $from=$val->from; + $sender=$from=$val->from; + $from=ereg_replace("\"","",$from); + if(ereg("<",$from)) { + $f=explode("<", $from); + $sender=$f[0]; + $from=$f[1]; + $from=str_replace(">","",$from); + } + + // retrieve body + $body = $this->get_part($mbox, $msg, "TEXT/PLAIN"); + if(empty($body)) { + $body = $this->get_part($mbox, $msg, "TEXT/HTML"); + if(!empty($body)) $body=str_replace("
", "\r\n", $body); + } + + // get attachements + if($this->get_attachments) { + $struct=imap_fetchstructure($mbox,$msg); + $contentParts = count($struct->parts); + if ($contentParts >= 2) { + + for ($ii=2; $ii<=$contentParts; $ii++) { + $c=($ii-2); + $att[$c] = imap_bodystruct($mbox,$msg,$ii); + } + + // download tmp file and add to attachemnt array + for ($k=0;$kdownload_file($mbox, $msg, $k, $att[$k]->parameters[0]->value); + } + } + } + + // Set the result array: + $this->results[] = Array('uniqueId' => $val->message_id, + 'date' => $val->date, + 'from' => trim($from), + 'to' => $val->to, + 'sender' => trim($sender), + 'subject' => trim($val->subject), + 'body' => trim($body), + 'attach' => $this->attachments[$msg]); + + // mark for deletion or move + if($this->cfg['piping_action'] == 1) { + if($this->delete_action) + imap_delete($mbox, $msg); + else if(($type==2 || $type==4 ) && !empty($this->move_mbox)) + imap_mail_move($mbox, $msg, $this->move_mbox); + } + } + imap_close($mbox, CL_EXPUNGE); + } + } + + /** + * Get an attached file + */ + function download_file(&$mbox, $msg, $file, $filename) { + $filetype = strrev(substr(strrev($filename),0,3)); + $filecontent = imap_fetchbody($mbox,$msg,$file+2); + if(empty($filecontent)) return false; + $tmp = PATH_FILES.'/'. md5('piping'.$filename.microtime()); + require_once('includes/pear/Compat/Function/file_put_contents.php'); + file_put_contents($tmp,$filecontent); + $this->attachments[$msg][] = Array('tmp'=>$tmp, 'file'=>$filename, 'type'=> $filetype); + } + + /** + * Get MIME Type + */ + function get_mime_type(&$structure) { + $primary_mime_type = array("TEXT", "MULTIPART","MESSAGE", "APPLICATION", "AUDIO","IMAGE", "VIDEO", "OTHER"); + if($structure->subtype) { + return $primary_mime_type[(int) $structure->type] . '/' .$structure->subtype; + } + return "TEXT/PLAIN"; + } + + /** + * Get Message Part + */ + function get_part($stream, $msg_number, $mime_type, $structure=false, $part_number=false) { + if(!$structure) { + $structure = imap_fetchstructure($stream, $msg_number); + } + if($structure) { + if($mime_type == $this->get_mime_type($structure)) { + if(!$part_number) { + $part_number = "1"; + } + $text = imap_fetchbody($stream, $msg_number, $part_number); + if($structure->encoding == 3) { + return imap_base64($text); + } else if($structure->encoding == 4) { + return imap_qprint($text); + } else { + return $text; + } + } + // multipart + if($structure->type == 1) { + while(list($index, $sub_structure) = each($structure->parts)) { + if($part_number) { + $prefix = $part_number . '.'; + } + $data = $this->get_part($stream, $msg_number, $mime_type, $sub_structure, @$prefix.($index + 1)); + if($data) { + return $data; + } + } + } + } + return false; + } + + + /** + * Get a connection string to use + * + * @param string $type 1=pop3, 2=imap, 3=pop3 alternate, 4=imap alternate + * @param string $host HOSTNAME OR HOSTNAME:PORT|MBOX + * @return string Connection string for imap_open() + */ + function get_connection_string($type,$host,$port=false,$mbox=false) { + + # Determine the path, host, & mbox name: + if(ereg(":", $host)) { + $arr = explode(":", $host); + + # host + @$host = $arr[0]; + + # port + if(!$port && is_numeric($arr[1])) @$port = $arr[1]; + + # mbox + elseif(preg_match('[|]', $arr[1])) { + $arr2 = explode('|', $arr[1]); + if(!$port && is_numeric($arr2[0]) ) @$port = $arr2[0]; + if(!$mbox) @$mbox = $arr2[1]; + } + } + + # defaults: + if(empty($port) && $type==1 || $type==3) $port = "110"; + if(empty($port) && $type==2 || $type==4) ; + if(empty($mbox)) $mbox = "INBOX"; + + // pop3 + if($type==1) { + if(empty($port)) $port = "110"; + return "{".$host.":".$port."/pop3}".$mbox; + } + + // pop3 alternate + if($type==3) { + if(empty($port)) $port = "110"; + return "{".$host.":".$port."/pop3/notls/novalidate-cert}".$mbox; + } + + // imap + if($type==2 ) { + if(empty($port)) $port = "143"; + return "{".$host.":".$port."}".$mbox; + } + + // imap alternate + if($type==4 ) { + if(empty($port)) $port = "143"; + return "{".$host.":".$port."/imap/notls/novalidate-cert}".$mbox; + } + + return string; + } +} +?> \ No newline at end of file diff --git a/modules/core/export.inc.php b/modules/core/export.inc.php new file mode 100644 index 00000000..89189b44 --- /dev/null +++ b/modules/core/export.inc.php @@ -0,0 +1,1213 @@ + + * @package AgileBill + * @version 1.4.93 + */ + + +/** +* Export Handler Class +* +* This class handles the various export methods for excel, pdf, csv, xml, & txt (tab frormatted). +*/ +class CORE_export +{ + + +######################################## +## EXPORT MULTIPE PDF INVOICES ##### +######################################## + +function pdf_invoice($VAR, $construct, $type) +{ + global $V_validate, $C_list, $C_translate; + + # loop through the field list to create the sql queries + $arr = $construct->method[$type]; + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $construct->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . $construct->table . '.' . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + else + { + $field_var = $construct->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . $construct->table . "." . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + $i++; + } + + # get the search details: + if(isset($VAR['search_id'])) + { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } + else + { + echo '
The search terms submitted were invalid!'; + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $VAR['order_by']; + $smarty_order = $VAR['order_by']; + } + else + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $construct->order_by; + $smarty_order = $search->order_by; + } + + # format saved search string + $sql = explode (" WHERE ", $search->sql); + + # generate the full query + $db = &DB(); + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " ".AGILE_DB_PREFIX . "invoice.site_id = '" . DEFAULT_SITE . "'"; + $q .= $order_by; + + $invoice = $db->Execute($q); + + # error reporting + if ($invoice === false) + { + global $C_debug; + $C_debug->error('core:export.inc.php','pdf_invoice', $db->ErrorMsg() . '

' .$q); + echo "An SQL error has occured!"; + return; + } + + include_once(PATH_MODULES.'invoice/invoice.inc.php'); + $iv=new invoice; + + $iv->pdfExport($invoice); + + +} + + + +######################################## +## ADMIN SEARCH EXCEL EXPORT ##### +######################################## + +function search_excel($VAR, $construct, $type) +{ + global $C_translate; + + # set the field list for this method: + $arr = $construct->method["$type"]; + $filename = 'Export.xls'; + + + # determine what action to take: + # inline display, download, email, web save + + if($VAR["type"] == "display") + { + header ('Content-type: application/x-msexcel'); + header ("Content-Disposition: inline; filename=$filename" ); + header ("Content-Description: PHP/INTERBASE Generated Data" ); + } + + else if($VAR["type"] == "download") + { + header ("Content-Disposition: attachment; filename=$filename" ); + } + + else if($VAR["type"] == "email") + { + echo "Email exports not supported yet!"; + exit; + } + + else if($VAR["type"] == "email") + { + echo "Saving exports not supported yet!"; + exit; + } + + # Start the Excel Stream + xlsBOF(); + + + /************** BEGIN STANDARD EXPORT SEARCH CODE *********************/ + + + # set the field list for this method: + $arr = $construct->method["$type"]; + + # loop through the field list to create the sql queries + $arr = $construct->method[$type]; + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $construct->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . $construct->table . '.' . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + else + { + $field_var = $construct->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . $construct->table . "." . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + $i++; + } + + # get the search details: + if(isset($VAR['search_id'])) + { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } + else + { + echo '
The search terms submitted were invalid!'; + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $VAR['order_by']; + $smarty_order = $VAR['order_by']; + } + else + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $construct->order_by; + $smarty_order = $search->order_by; + } + + # determine the offset & limit + if(isset($VAR['page'])) + { + $current_page = $VAR['page']; + } + else + { + $current_page = '0'; + } + + # determine the offset & limit + if($current_page==0) + { + $offset = '0,10000000'; + } + else + { + $offset = (($current_page * $search->limit) - $search->limit). ',' . $search->limit; + } + + # format saved search string + $sql = explode (" WHERE ", $search->sql); + + # generate the full query + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " " . AGILE_DB_PREFIX . $construct->table.".site_id = '" . DEFAULT_SITE . "'"; + $q .= $order_by; + $db = &DB(); + + # determine the offset & limit + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('core:export.inc.php','search_xml', $db->ErrorMsg() . '

' .$q); + echo "An SQL error has occured!"; + return; + } + + # put the results into an array + $i=0; + $class_name = TRUE; + $results = ''; + while (!$result->EOF) { + $results[$i] = $result->fields; + $result->MoveNext(); + $i++; + } + + # get any linked fields + if($i > 0) + { + $this->result = $results; + $db_join = new CORE_database; + $this->result = $db_join->join_fields($results, $this->linked); + } + else + { + $this->result = $results; + } + + /************** END STANDARD EXPORT SEARCH CODE *********************/ + + + # WRITE THE FIRST COLUMN + reset($arr); + $column=0; + while (list ($key, $value) = each ($arr)) + { + // get the translated field name + $field = $C_translate->translate('field_'.$value, $construct->module,''); + + if(gettype($this->result["$ii"]["$key"]) != "string" ) + { + xlsWriteLabel($row,$column,$field); + } + $column++; + } + + + # LOOP THROUGH THE RESULTS & DISPLAY AS EXCEL + $row = 1; + for($ii = 0; $ii < count($this->result); $ii++) + { + # get the data for each cell: + reset($arr); + $column=0; + while (list ($key, $value) = each ($arr)) + { + if ($construct->field["$value"][convert] == 'date' || + $construct->field["$value"][convert] == 'time' || + $construct->field["$value"][convert] == 'date-now' || + $construct->field["$value"][convert] == 'date-time' ) + { + $data = date(UNIX_DATE_FORMAT,$this->result["$ii"]["$value"]); + } else { + $data = $this->result["$ii"]["$value"]; + } + + if(is_numeric ($data)) + xlsWriteNumber($row,$column,$data); + else + xlsWriteLabel($row,$column,$data); + + $column++; + } + $row++; + } + + + # Dispay the output + xlsEOF(); + exit(); +} + + + + + + + + + + + + + ################################### + ## ADMIN SEARCH PDF EXPORT ##### + ################################### + + function search_pdf($VAR, $construct, $type) + { + # include fpdf class: + include_once(PATH_CORE . 'fpdf.inc.php'); + + # set the field list for this method: + $arr = $construct->method["$type"]; + + # loop through the field list to create the sql queries + $field_list = ''; + $heading_list = ''; + $width_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $construct->table . '_' . $value; + $field_list .= $value; + $heading_list .= strtoupper($value); // <- translate + $width_list .= $construct->field[$value]['pdf_width']; + } + else + { + $field_var = $construct->table . '_' . $value; + $field_list .= "," . $value; + $heading_list .= "," . strtoupper($value); // <- translate + $width_list .= "," . $construct->field[$value]['pdf_width']; + } + $i++; + } + + # start the new PDF class... + $pdf = new PDF_MC_Table(); + $pdf->Open(); + $pdf->AddPage(); + + # Determine the number of columns and width for each one... + $SetWidths = split(",",$width_list); + $pdf->SetWidths($SetWidths); + + # Define the table heading + $TableHeading = split(",",$heading_list); + + # Define the Properties for the table heading cells: + # set the font: + $pdf->HeadFontFamily = "Arial"; + $pdf->HeadFontStyle = "BI"; + $pdf->HeadFontSize = 8; + + # set the font color: + $pdf->HeadTextColor1 = 255; + $pdf->HeadTextColor2 = 255; + $pdf->HeadTextColor3 = 255; + + # set the bg color: + $pdf->HeadFillColor1 = 90; + $pdf->HeadFillColor2 = 90; + $pdf->HeadFillColor3 = 90; + + # set the hieght + $pdf->HeadHeight = 6; + + # Print the Heading: + $pdf->HeadRow($TableHeading); + + # Define the row settings for the rest of the cells... + # define the font settings + $pdf->SetFontFamily = "Arial"; + $pdf->SetFontStyle = ""; + $pdf->SetFontSize = "7"; + + # set the hieght + $pdf->RowHeight = 4; + + + + + /************** BEGIN STANDARD EXPORT SEARCH CODE *********************/ + + + # set the field list for this method: + $arr = $construct->method["$type"]; + + # loop through the field list to create the sql queries + $arr = $construct->method[$type]; + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $construct->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . $construct->table . '.' . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + else + { + $field_var = $construct->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . $construct->table . "." . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + $i++; + } + + # get the search details: + if(isset($VAR['search_id'])) + { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } + else + { + echo '
The search terms submitted were invalid!'; + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $VAR['order_by']; + $smarty_order = $VAR['order_by']; + } + else + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $construct->order_by; + $smarty_order = $search->order_by; + } + + # format saved search string + $sql = explode (" WHERE ", $search->sql); + + # generate the full query + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " ".AGILE_DB_PREFIX . $construct->table.".site_id = '" . DEFAULT_SITE . "'"; + $q .= $order_by; + $db = &DB(); + + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('core:export.inc.php','search_xml', $db->ErrorMsg() . '

' .$q); + echo "An SQL error has occured!"; + return; + } + + # put the results into an array + $i=0; + $class_name = TRUE; + $results = ''; + while (!$result->EOF) { + $results[$i] = $result->fields; + $result->MoveNext(); + $i++; + } + + # get any linked fields + if($i > 0) + { + $this->result = $results; + $db_join = new CORE_database; + $this->result = $db_join->join_fields($results, $this->linked); + } + else + { + $this->result = $results; + } + + /************** END STANDARD EXPORT SEARCH CODE *********************/ + + + + + + # LOOP THROUGH THE RESULTS & DISPLAY AS PDF + $results = $result->RecordCount(); + $BackAlt = TRUE; + while (!$result->EOF) + { + # get the data for each cell: + reset($arr); + $CurrRow=''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $CurrRow .= $result->fields["$key"]; + } + else + { + $CurrRow .= "::" . $result->fields["$key"]; + } + $i++; + } + $ThisRow = split("::",$CurrRow); + + # set the colors & fonts + if($BackAlt) + { + # alternating row 1: + $pdf->SetTextColorVar1 = "50"; + $pdf->SetTextColorVar2 = "50"; + $pdf->SetTextColorVar3 = "50"; + $pdf->SetFillColorVar1 = 255; + $pdf->SetFillColorVar2 = 255; + $pdf->SetFillColorVar3 = 255; + $BackAlt = FALSE; + } + else + { + # alternating row 2: + $pdf->SetTextColorVar1 = "0"; + $pdf->SetTextColorVar2 = "0"; + $pdf->SetTextColorVar3 = "0"; + $pdf->SetFillColorVar1 = 240; + $pdf->SetFillColorVar2 = 240; + $pdf->SetFillColorVar3 = 240; + $BackAlt = TRUE; + } + + # check for needed page break + $nb=0; + for($ii=0;$iiNbLines($pdf->widths[$ii],$dataarr[$ii])); + $h=5*$nb; + + # Issue a page break first if needed + if($pdf->CheckPageBreak($h)) + # print the Table Heading again + $pdf->HeadRow($TableHeading); + $pdf->Row($ThisRow); + # Next record + $result->MoveNext(); + } + + # Dispay the output + $pdf->Output(); + exit; + } + + + + + + + + + + +######################################## +## ADMIN SEARCH CSV EXPORT ##### +######################################## + +function search_csv($VAR, $construct, $type) +{ + global $C_translate; + + include_once(PATH_ADODB . 'toexport.inc.php'); + $filename = 'Export.csv'; + + + # determine what action to take: + # inline display, download, email, web save + + if($VAR["type"] == "display") + { + header ('Content-type: application/x-csv'); + header ("Content-Disposition: inline; filename=$filename" ); + } + + else if($VAR["type"] == "download") + { + header ("Content-Disposition: attachment; filename=$filename" ); + } + + + + /************** BEGIN STANDARD EXPORT SEARCH CODE *********************/ + + + # set the field list for this method: + $arr = $construct->method["$type"]; + + # loop through the field list to create the sql queries + $arr = $construct->method[$type]; + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $construct->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . $construct->table . '.' . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + else + { + $field_var = $construct->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . $construct->table . "." . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + $i++; + } + + # get the search details: + if(isset($VAR['search_id'])) + { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } + else + { + echo '
The search terms submitted were invalid!'; + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $VAR['order_by']; + $smarty_order = $VAR['order_by']; + } + else + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $construct->order_by; + $smarty_order = $search->order_by; + } + + # format saved search string + $sql = explode (" WHERE ", $search->sql); + + # generate the full query + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " ".AGILE_DB_PREFIX . $construct->table.".site_id = '" . DEFAULT_SITE . "'"; + $q .= $order_by; + $db = &DB(); + + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('core:export.inc.php','search_xml', $db->ErrorMsg() . '

' .$q); + echo "An SQL error has occured!"; + return; + } + + # put the results into an array + $i=0; + $class_name = TRUE; + $results = ''; + while (!$result->EOF) { + $results[$i] = $result->fields; + $result->MoveNext(); + $i++; + } + + # get any linked fields + if($i > 0) + { + $this->result = $results; + $db_join = new CORE_database; + $this->result = $db_join->join_fields($results, $this->linked); + } + else + { + $this->result = $results; + } + + /************** END STANDARD EXPORT SEARCH CODE *********************/ + + + + # LOOP THROUGH THE RESULTS & DISPLAY AS CSV + for($ii = 0; $ii < count($this->result); $ii++) + { + # print the heading: + if($ii == 0) + { + reset($arr); + $total_fields = count($arr) - 1; + $iii = 0; + while (list ($key, $value) = each ($arr)) + { + $field = $C_translate->translate('field_'.$value, $construct->module,''); + echo '"' . $field . '"'; + if($total_fields > $iii) echo ','; + $iii++; + } + } + + + + # new line + echo ' +'; + # print the data for each cell: + reset($arr); + $total_fields = count($arr) - 1; + $iii = 0; + while (list ($key, $value) = each ($arr)) + { + if ($construct->field["$value"][convert] == 'date' || + $construct->field["$value"][convert] == 'time' || + $construct->field["$value"][convert] == 'date-now' || + $construct->field["$value"][convert] == 'date-time' ) + { + $data = date(UNIX_DATE_FORMAT,$this->result["$ii"]["$value"]); + } else { + $data = $this->result["$ii"]["$value"]; + } + + echo '"' . $data . '"'; + if($total_fields > $iii) echo ','; + $iii++; + } + } + exit(); +} + + + + + + + + + +######################################## +## ADMIN SEARCH TAB EXPORT ##### +######################################## + +function search_tab($VAR, $construct, $type) +{ + global $C_translate; + include_once(PATH_ADODB . '/toexport.inc.php'); + $filename = 'Export.txt'; + + + # determine what action to take: + # inline display, download, email, web save + + if($VAR["type"] == "display") + { + header ('Content-type: application/x-txt'); + header ("Content-Disposition: inline; filename=$filename" ); + } + + else if($VAR["type"] == "download") + { + header ("Content-Disposition: attachment; filename=$filename" ); + } + + /************** BEGIN STANDARD EXPORT SEARCH CODE *********************/ + + + # set the field list for this method: + $arr = $construct->method["$type"]; + + # loop through the field list to create the sql queries + $arr = $construct->method[$type]; + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $construct->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . $construct->table . '.' . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + else + { + $field_var = $construct->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . $construct->table . "." . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + $i++; + } + + # get the search details: + if(isset($VAR['search_id'])) + { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } + else + { + echo '
The search terms submitted were invalid!'; + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $VAR['order_by']; + $smarty_order = $VAR['order_by']; + } + else + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $construct->order_by; + $smarty_order = $search->order_by; + } + + # format saved search string + $sql = explode (" WHERE ", $search->sql); + + # generate the full query + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " ".AGILE_DB_PREFIX . $construct->table.".site_id = '" . DEFAULT_SITE . "'"; + $q .= $order_by; + $db = &DB(); + + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('core:export.inc.php','search_xml', $db->ErrorMsg() . '

' .$q); + echo "An SQL error has occured!"; + return; + } + + # put the results into an array + $i=0; + $class_name = TRUE; + $results = ''; + while (!$result->EOF) { + $results[$i] = $result->fields; + $result->MoveNext(); + $i++; + } + + # get any linked fields + if($i > 0) + { + $this->result = $results; + $db_join = new CORE_database; + $this->result = $db_join->join_fields($results, $this->linked); + } + else + { + $this->result = $results; + } + + /************** END STANDARD EXPORT SEARCH CODE *********************/ + + + + + # LOOP THROUGH THE RESULTS & DISPLAY AS CSV + for($ii = 0; $ii < count($this->result); $ii++) + { + # print the heading: + if($ii == 0) + { + reset($arr); + $total_fields = count($arr) - 1; + $iii = 0; + while (list ($key, $value) = each ($arr)) + { + $data = $C_translate->translate('field_'.$value, $construct->module,''); + echo $data; + if($total_fields > $iii) echo ' '; + $iii++; + } + } + + + + # new line + echo ' +'; + # print the data for each cell: + reset($arr); + $total_fields = count($arr) - 1; + $iii = 0; + while (list ($key, $value) = each ($arr)) + { + if ($construct->field["$value"][convert] == 'date' || + $construct->field["$value"][convert] == 'time' || + $construct->field["$value"][convert] == 'date-now' || + $construct->field["$value"][convert] == 'date-time' ) + { + $data = date(UNIX_DATE_FORMAT,$this->result["$ii"]["$value"]); + } else { + $data = $this->result["$ii"]["$value"]; + } + + echo addslashes($data); + if($total_fields > $iii) echo ' '; + $iii++; + } + } + exit(); +} + + + + + + + + + ######################################## + ## ADMIN SEARCH XML EXPORT ##### + ######################################## + + function search_xml($VAR, $construct, $type) + { + + /************** BEGIN STANDARD EXPORT SEARCH CODE *********************/ + + + # set the field list for this method: + $arr = $construct->method["$type"]; + + # loop through the field list to create the sql queries + $arr = $construct->method[$type]; + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $construct->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . $construct->table . '.' . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + else + { + $field_var = $construct->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . $construct->table . "." . $value; + + // determine if this record is linked to another table/field + if($construct->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $construct->field[$value]["asso_table"], 'link_field' => $construct->field[$value]["asso_field"]); + } + } + $i++; + } + + # get the search details: + if(isset($VAR['search_id'])) + { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } + else + { + echo '
The search terms submitted were invalid!'; + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $VAR['order_by']; + $smarty_order = $VAR['order_by']; + } + else + { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . $construct->table . '.' . $construct->order_by; + $smarty_order = $search->order_by; + } + + # format saved search string + $sql = explode (" WHERE ", $search->sql); + + # generate the full query + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " ".AGILE_DB_PREFIX . $construct->table.".site_id = '" . DEFAULT_SITE . "'"; + $q .= $order_by; + $db = &DB(); + + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('core:export.inc.php','search_xml', $db->ErrorMsg() . '

' .$q); + echo "An SQL error has occured!"; + return; + } + + # put the results into an array + $i=0; + $class_name = TRUE; + $results = ''; + while (!$result->EOF) { + $results[$i] = $result->fields; + $result->MoveNext(); + $i++; + } + + # get any linked fields + if($i > 0) + { + $this->result = $results; + $db_join = new CORE_database; + $this->result = $db_join->join_fields($results, $this->linked); + } + else + { + $this->result = $results; + } + + /************** END STANDARD EXPORT SEARCH CODE *********************/ + + + + + + # create the xml processing instruction + # header("Content-type: text/xml"); + $filename = 'XML_Export.xml'; + + # determine what action to take: + if($VAR["type"] == "display") { + header ('Content-type: application/x-xml'); + header ("Content-Disposition: inline; filename=$filename" ); + } + + else if($VAR["type"] == "download") { + header ("Content-Disposition: attachment; filename=$filename" ); + } + + $_xml ="\r\n"; + $_xml .="\r\n"; + + # loop through the resulsts and display as PDF + $row = 0; + for($ii = 0; $ii < count($this->result); $ii++) + { + $_xml .= " <" . $construct->table . ">\r\n"; + + # get the data for each cell: + reset($arr); + $column=0; + while (list ($key, $value) = each ($arr)) + { + if ($construct->field["$value"][convert] == 'date' || + $construct->field["$value"][convert] == 'time' || + $construct->field["$value"][convert] == 'date-now' || + $construct->field["$value"][convert] == 'date-time' ) + { + $date = date(UNIX_DATE_FORMAT,$this->result["$ii"]["$value"]); + $data = htmlspecialchars($date,0,'ISO8859-1'); + //$data = test; + } else { + $data = htmlspecialchars($this->result["$ii"]["$value"],0,'ISO8859-1'); + } + $_xml .= " <$value>" . $data . "\r\n"; + } + + # Next record + $_xml .= " table . ">\r\n"; + + } + $_xml .="\r\n"; + echo $_xml; + exit(); + } +} + + + +// ----- begin of excel export function library ----- +// Excel begin of file header +function xlsBOF() { + echo pack("ssssss", 0x809, 0x8, 0x0, 0x10, 0x0, 0x0); + return; +} + +// Excel end of file footer +function xlsEOF() { + echo pack("ss", 0x0A, 0x00); + return; +} + + +// Function to write a Number (double) into Row, Col +function xlsWriteNumber($Row, $Col, $Value) { + echo pack("sssss", 0x203, 14, $Row, $Col, 0x0); + echo pack("d", $Value); + return; +} + + +// Function to write a label (text) into Row, Col + function xlsWriteLabel($Row, $Col, $Value ) { + $L = strlen($Value); + echo pack("ssssss", 0x204, 8 + $L, $Row, $Col, 0x0, $L); + echo $Value; + return; +} +?> \ No newline at end of file diff --git a/modules/core/file_extensions.inc.php b/modules/core/file_extensions.inc.php new file mode 100644 index 00000000..caf6f5d1 --- /dev/null +++ b/modules/core/file_extensions.inc.php @@ -0,0 +1,66 @@ +arr = Array + ( + Array ('name' => 'jpg', 'type' => 'image/jpeg', 'disposition' => 'inline'), + Array ('name' => 'jpeg', 'type' => 'image/jpeg', 'disposition' => 'inline'), + Array ('name' => 'jpe', 'type' => 'image/jpeg', 'disposition' => 'inline'), + Array ('name' => 'gif', 'type' => 'image/gif', 'disposition' => 'inline'), + Array ('name' => 'bmp', 'type' => 'image/bmp', 'disposition' => 'inline'), + Array ('name' => 'tif', 'type' => 'image/tif', 'disposition' => 'inline'), + Array ('name' => 'png', 'type' => 'image/png', 'disposition' => 'inline'), + Array ('name' => 'wbmp', 'type' => 'image/vnd.wap.wbmp', 'disposition' => 'inline'), + + Array ('name' => 'pdf', 'type' => 'application/pdf', 'disposition' => 'inline'), + Array ('name' => 'exe', 'type' => 'application/octet-stream', 'disposition'=> 'attatchment'), + Array ('name' => 'zip', 'type' => 'application/x-zip', 'disposition' => 'attatchment'), + Array ('name' => 'gzip', 'type' => 'application/gzip', 'disposition' => 'attatchment'), + Array ('name' => 'tgz', 'type' => 'application/tgz', 'disposition' => 'attatchment'), + Array ('name' => 'gz', 'type' => 'application/gz', 'disposition' => 'attatchment'), + Array ('name' => 'doc', 'type' => 'application/ms-word', 'disposition' => 'inline'), + Array ('name' => 'xls', 'type' => 'application/ms-excel', 'disposition' => 'inline'), + Array ('name' => 'csv', 'type' => 'application/ms-excel', 'disposition' => 'inline'), + Array ('name' => 'swf', 'type' => 'application/x-shockwave-flash', 'disposition' => 'inline'), + + Array ('name' => 'txt', 'type' => 'text/plain', 'disposition' => 'inline'), + Array ('name' => 'text', 'type' => 'text/plain', 'disposition' => 'inline'), + Array ('name' => 'rtf', 'type' => 'text/richtext', 'disposition' => 'inline'), + Array ('name' => 'xml', 'type' => 'text/xml', 'disposition' => 'inline'), + Array ('name' => 'css', 'type' => 'text/css', 'disposition' => 'inline'), + Array ('name' => 'js', 'type' => 'text/plain', 'disposition' => 'inline'), + Array ('name' => 'wml', 'type' => 'text/vnd.wap.wml', 'disposition' => 'inline'), + + Array ('name' => 'avi', 'type' => 'video/avi', 'disposition' => 'attatchment'), + Array ('name' => 'mpg', 'type' => 'video/mpeg', 'disposition' => 'attatchment'), + Array ('name' => 'mpeg', 'type' => 'video/mpeg', 'disposition' => 'attatchment'), + Array ('name' => 'mpe', 'type' => 'video/mpeg', 'disposition' => 'attatchment'), + Array ('name' => 'wmv', 'type' => 'video/x-ms-wmv', 'disposition' => 'attatchment'), + Array ('name' => 'asf', 'type' => 'video/x-ms-asf', 'disposition' => 'attatchment') + ); + } + + function content_type($file) + { + for($i=0; $iarr); $i++) + if(eregi($this->arr[$i]['name'].'$', $file)) + return $this->arr[$i]['type']; + } + + /** + * Set headers for a specific file extension + */ + function set_headers_ext($ext,$name="Download",$size=0) { + foreach($this->arr as $types) { + if($types['name'] == strtolower($ext)) { + header("Content-type: {$types['type']}"); + header("Content-disposition: \"{$types['disposition']}\"; filename=\"$name.$ext\"; size=\"$size\""); + return $types['type']; + } + } + } +} +?> \ No newline at end of file diff --git a/modules/core/fpdf.inc.php b/modules/core/fpdf.inc.php new file mode 100644 index 00000000..a945820c --- /dev/null +++ b/modules/core/fpdf.inc.php @@ -0,0 +1,219 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +require_once(PATH_FPDF . '/fpdf.php'); + +/** +* FPDF Handler Class +* +* This class handles the conversion to PDF format for printing, etc. +*/ +class CORE_fpdf +{ + + /** + * Opens the FPDF class and gets ready for data conversion... + * + * @return void + * @since Version 1.0 + */ + + function CORE_fpdf() + { + } + + + + /** + * FPDF Table Class + * + * This class handles the of tables to PDF, for searches, lists, reports, etc. + * + * @version 1.0 Beta, 2003/06/07 + * @package Core + */ +} + +class PDF_MC_Table extends FPDF +{ + var $widths; + + function SetWidths($w) + { + //Set the array of column widths + $this->widths=$w; + } + + function Header() + { + //Select Arial bold 15 + $this->SetFont('Arial','I',12); + //Move to the right + $this->Cell(190,10,"Search Results (translate)",'0','0','C'); + //Line break + $this->Ln(10); + } + + function Footer() + { + //Go to 1.5 cm from bottom right + $this->SetXY(-20,-15); + //Select Arial italic 8 + $this->SetFont('Arial','I',8); + //Print page number + $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C'); + //Go to 1.5 cm from bottom left + $this->SetXY(10,-15); + //Select Arial italic 8 + $this->SetFont('Arial','I',8); + //Print date + $this->Cell(0,10,date("m-d-Y"),0,0,'L'); + } + + + function HeadRow($data) + { + // Set the fill color + #$this->SetDrawColor(0,0,0); + $this->SetFillColor($this->HeadFillColor1,$this->HeadFillColor2,$this->HeadFillColor3); + $this->SetTextColor($this->HeadTextColor1,$this->HeadTextColor2,$this->HeadTextColor3); + $this->SetFont($this->HeadFontFamily,$this->HeadFontStyle,$this->HeadFontSize); + + //Calculate the height of the row + $nb=0; + for($i=0;$iNbLines($this->widths[$i],$data[$i])); + $h=$this->HeadHeight*$nb; + + //Draw the cells of the row + for($i=0;$iwidths[$i]; + //Save the current position + $x=$this->GetX(); + $y=$this->GetY(); + //Draw the border + $this->Rect($x,$y,$w,$h); + //Print the text + $this->MultiCell($w,$this->HeadHeight,$data[$i],1,'L',1); + //Put the position to the right of the cell + $this->SetXY($x+$w,$y); + } + //Go to the next line + $this->Ln($h); + } + + + + function Row($data) + { + // Set the fill color + #$this->SetDrawColor(0,0,0); + $this->SetFillColor($this->SetFillColorVar1,$this->SetFillColorVar2,$this->SetFillColorVar3); + $this->SetTextColor($this->SetTextColorVar1,$this->SetTextColorVar2,$this->SetTextColorVar3); + $this->SetFont($this->SetFontFamily,$this->SetFontStyle,$this->SetFontSize); + + //Calculate the height of the row + $nb=0; + for($i=0;$iNbLines($this->widths[$i],$data[$i])); + $h=$this->RowHeight*$nb; + + //Draw the cells of the row + for($i=0;$iwidths[$i]; + //Save the current position + $x=$this->GetX(); + $y=$this->GetY(); + //Draw the border + $this->Rect($x,$y,$w,$h); + //Print the text + $this->MultiCell($w,$this->RowHeight,$data[$i],1,'L',1); + //Put the position to the right of the cell + $this->SetXY($x+$w,$y); + } + //Go to the next line + $this->Ln($h); + } + + function CheckPageBreak($h) + { + //If the height h would cause an overflow, add a new page immediately + if($this->GetY()+$h>$this->PageBreakTrigger) + { + $this->AddPage($this->CurOrientation); + return TRUE; + } + + } + + function NbLines($w,$txt) + { + //Computes the number of lines a MultiCell of width w will take + $cw=&$this->CurrentFont['cw']; + if($w==0) + $w=$this->w-$this->rMargin-$this->x; + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + $s=str_replace("\r",'',$txt); + $nb=strlen($s); + if($nb>0 and $s[$nb-1]=="\n") + $nb--; + $sep=-1; + $i=0; + $j=0; + $l=0; + $nl=1; + while($i<$nb) + { + $c=$s[$i]; + if($c=="\n") + { + $i++; + $sep=-1; + $j=$i; + $l=0; + $nl++; + continue; + } + if($c==' ') + $sep=$i; + $l+=$cw[$c]; + if($l>$wmax) + { + if($sep==-1) + { + if($i==$j) + $i++; + } + else + $i=$sep+1; + $sep=-1; + $j=$i; + $l=0; + $nl++; + } + else + $i++; + } + return $nl; + } +} +?> \ No newline at end of file diff --git a/modules/core/ftp.inc.php b/modules/core/ftp.inc.php new file mode 100644 index 00000000..bef6421f --- /dev/null +++ b/modules/core/ftp.inc.php @@ -0,0 +1,171 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** +* FTP Connection Class +* +* This class creates a connection to a remote host for file upload/download/deletion. +*/ +class CORE_ftp +{ + var $server=''; + var $username=''; + var $password=''; + var $port=21; + var $remote_dir=''; + + + + ### Setup the connection: + function CORE_ftp($server, $username='anonymous', $password='anonymous@domain.com', $port=21) + { + $this->server=$server; + $this->username=$username; + $this->password=$password; + $this->port=$port; + } + + + + + ### Test the connection: + function return_connection() + { + # SET THE ERROR REPORTING LEVEL OFF! + error_reporting(0); + + $conn_id = @ftp_connect($this->server, $this->port); + if (!$conn_id) return false; + + $login_result = @ftp_login($conn_id, $this->username, $this->password); + if (!$login_result) return false; + + # SET THE ERROR REPORTING LEVEL ( E_ALL ^ E_NOTICE ) + $error_reporting_eval = 'error_reporting('.ERROR_REPORTING.');'; + eval($error_reporting_eval); + return $conn_id; + } + + + + + ### Kill the connection: + function kill() + { + if(isset($this->conn)) + $this->disconnect(); + unset($this); + } + + + + + ### Delete a file: + function delete($filename) + { + # SET THE ERROR REPORTING LEVEL OFF! + error_reporting(0); + + $conn=$this->return_connection(); + if (!$conn) return false; + + @ftp_pasv($conn, $passive); + $this->set_remote_dir(ftp_pwd($conn)); + if(!ftp_delete($conn, $filename)) + { + @ftp_quit($this->conn); + return false; + } + else + { + @ftp_quit($this->conn); + return true; + } + + # SET THE ERROR REPORTING LEVEL ( E_ALL ^ E_NOTICE ) + $error_reporting_eval = 'error_reporting('.ERROR_REPORTING.');'; + eval($error_reporting_eval); + return true; + } + + + + + ### Send a file: + function send($filename='', $save_as='', $passive=TRUE) + { + # SET THE ERROR REPORTING LEVEL OFF! + error_reporting(0); + + $conn=$this->return_connection(); + if ( !$conn ) return false; + + @ftp_pasv($conn, $passive); + $this->set_remote_dir(ftp_pwd($conn)); + if(!ftp_put($conn, $save_as, $filename, FTP_BINARY)) + { + @ftp_quit($this->conn); + return false; + } + else + { + @ftp_quit($this->conn); + return true; + } + + # SET THE ERROR REPORTING LEVEL ( E_ALL ^ E_NOTICE ) + $error_reporting_eval = 'error_reporting('.ERROR_REPORTING.');'; + eval($error_reporting_eval); + return true; + } + + ### Get a file + function get($filename='', $save_as='', $passive=TRUE) + { + # SET THE ERROR REPORTING LEVEL OFF! + error_reporting(0); + + $conn=$this->return_connection(); + if (!$conn) return false; + + @ftp_pasv($conn, $passive); + $this->set_remote_dir(ftp_pwd($conn)); + if(!ftp_get($conn, $save_as, $this->remote_dir.$filename, FTP_BINARY)) + { + @ftp_quit($this->conn); + return false; + } + else + { + @ftp_quit($this->conn); + return true; + } + } + + ### Set the current directory: + function set_remote_dir($dir) + { + $x = substr($dir, (strlen($dir)-1)); + if($x != "/" && $x != "\\") + $dir.="/"; + $this->remote_dir=$dir; + } +} +?> \ No newline at end of file diff --git a/modules/core/graph.inc.php b/modules/core/graph.inc.php new file mode 100644 index 00000000..bfbccf51 --- /dev/null +++ b/modules/core/graph.inc.php @@ -0,0 +1,405 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_graph +{ + + + ######################################################################## + ### Create a Bar Graph + ######################################################################## + + function PIE_graph($module, $method, $type, $start, $extra_fields) + { + global $C_translate, $C_auth; + include_once(PATH_CORE . 'validate.inc.php'); + $dt = new CORE_validate; + + include (PATH_GRAPH."jpgraph.php"); + + #################################################################### + ### Check if 'search' is authorized for this account + #################################################################### + + # check the validation for this function + if($C_auth->auth_method_by_name($module,'search')) + { + # validate this file exists, and include it. + if (file_exists(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php')) + { + include_once(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php'); + } + else + { + ### Not exist! + $error = $C_translate->translate('module_non_existant','',''); + } + } + else + { + ### Not auth + $error = $C_translate->translate('module_non_auth','',''); + } + + + if(isset($error)) + { + include (PATH_GRAPH."jpgraph_canvas.php"); + // Create the graph. + $graph = new CanvasGraph(460,55,"auto"); + $t1 = new Text($error); + $t1->Pos(0.2,0.5); + $t1->SetOrientation("h"); + $t1->SetBox("white","black",'gray'); + $t1->SetFont(FF_FONT1,FS_NORMAL); + $t1->SetColor("black"); + $graph->AddText($t1); + $graph->Stroke(); + exit; + } + + + # initialize the module, if it has not already been initialized + $eval = '$' . $module . ' = new ' . $module . '; '; + $eval .= '$this_Obj = $' . $module . ';'; + eval ($eval); + + # run the function + $array = call_user_func (array($module, $method), $start_str, $end_str, $constraint_array, $default_array, $extra_fields); + + + include (PATH_GRAPH."jpgraph_pie.php"); + include (PATH_GRAPH."jpgraph_pie3d.php"); + + + $data = $array['data']; + $legends = $array['legends']; + + // Create the Pie Graph. + $graph = new PieGraph(500,250,"auto"); + $graph->SetScale("textlin"); + $graph->SetMarginColor('#F9F9F9'); + $graph->SetFrame(true,'#FFFFFF',0); + $graph->SetColor('#F9F9F9'); + + // Create pie plot + $p1 = new PiePlot3d($data); + $p1->SetTheme("water"); + $p1->SetCenter(0.4); + $p1->SetAngle(30); + $p1->value->SetFont(FF_FONT1,FS_NORMAL,8); + $p1->SetLegends($legends); + + // Explode the larges slice: + $largest = 0; + for($i=0; $i $largest) + { + $largest = $data[$i]; + $explode = $i; + } + } + if($explode) + $p1->ExplodeSlice($explode); + + $graph->Add($p1); + $graph->Stroke(); + } + + + + + ######################################################################## + ### Create a Bar Graph + ######################################################################## + + function BAR_graph($module, $type, $start, $extra_fields) + { + global $C_translate, $C_auth; + include_once(PATH_CORE . 'validate.inc.php'); + $dt = new CORE_validate; + + include (PATH_GRAPH."jpgraph.php"); + + #################################################################### + ### Check if 'search' is authorized for this account + #################################################################### + + # check the validation for this function + if($C_auth->auth_method_by_name($module,'search')) + { + # validate this file exists, and include it. + if (file_exists(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php')) + { + include_once(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php'); + } + else + { + ### Not exist! + $error = $C_translate->translate('module_non_existant','',''); + } + } + else + { + ### Not auth + $error = $C_translate->translate('module_non_auth','',''); + } + + + if(isset($error)) + { + include (PATH_GRAPH."jpgraph_canvas.php"); + // Create the graph. + $graph = new CanvasGraph(460,55,"auto"); + $t1 = new Text($error); + $t1->Pos(0.2,0.5); + $t1->SetOrientation("h"); + $t1->SetBox("white","black",'gray'); + $t1->SetFont(FF_FONT1,FS_NORMAL); + $t1->SetColor("black"); + $graph->AddText($t1); + $graph->Stroke(); + exit; + } + + + + + #################################################################### + ### BY WEEK + #################################################################### + + if ($type == 'week') + { + $FONT_SIZE= 7; + $AbsWidth = 12; + $interval = 4; + + $type = $C_translate->translate('week','',''); + if($start == "" || $start <= 12) + { + ## Get the beginning/end of this week + $start_str = mktime (24,0,0,12, 31, date("Y")-1); + $start = date(UNIX_DATE_FORMAT, $start_str); + $end_str = mktime (24,0,0,12, 30, date("Y",$start_str)); + $end = date(UNIX_DATE_FORMAT, $end_str); + + } + else + { + ## Get the beginning/end of the specified week + $start_str = mktime (24,0,0,12, 31, date("$start")-1); + $start = date(UNIX_DATE_FORMAT, $start_str); + $end_str = mktime (24,0,0,12, 30, date("Y",$start_str)); + $end = date(UNIX_DATE_FORMAT, $end_str); + + } + + ### Set the constraint array: + $curr_str = $start_str; + while ( $curr_str <= $end_str ) + { + $new_curr_str = mktime (0,0,0,date("m",$curr_str), date("d",$curr_str)+7, date("Y",$curr_str)); + $constraint_array[] = Array('start' => $curr_str, 'end' => $new_curr_str); + $curr_str = $new_curr_str; + $default_array[] = 0; + } + } + + + #################################################################### + ### MONTH + #################################################################### + + else if ($type == 'month') + { + $FONT_SIZE = 10; + $AbsWidth = 12; + $TickLables = $gDateLocale->GetShortMonth(); + $interval =1; + $type = $C_translate->translate('month','',''); + + if($start == "" || $start < 12) + { + ## Get the beginning/end of this week + $start_str = mktime (24,0,0,12, 31, date("Y")-1); + $start = date(UNIX_DATE_FORMAT, $start_str); + $end_str = mktime (24,0,0,12, 30, date("Y",$start_str)); + $end = date(UNIX_DATE_FORMAT, $end_str); + } + else + { + ## Get the beginning/end of the specified week + ## Get the beginning/end of this week + $start_str = mktime (24,0,0,12, 31, date("$start")-1); + $start = date(UNIX_DATE_FORMAT, $start_str); + $end_str = mktime (24,0,0,12, 30, date("Y",$start_str)); + $end = date(UNIX_DATE_FORMAT, $end_str); + } + + ### Set the constraint array: + $curr_str = $start_str; + while ( $curr_str <= $end_str ) + { + $new_curr_str = mktime (0,0,0,date("m",$curr_str)+1, date("d",$curr_str), date("Y",$curr_str)); + $constraint_array[] = Array('start' => $curr_str, 'end' => $new_curr_str); + $curr_str = $new_curr_str; + $default_array[] = 0; + } + + + } + + + #################################################################### + ### BY YEAR + #################################################################### + + else if ($type == 'year') + { + $FONT_SIZE = 10; + $interval =1; + $AbsWidth = 13; + + $type = $C_translate->translate('year','',''); + + + ## Get the beginning/end of this year - 10 + $start_str = mktime (0,0,0,1,1, date("Y")-9); + $start = date(UNIX_DATE_FORMAT, $start_str); + $end_str = mktime (0,0,0,12,30, date("Y",$start_str)+9); + $end = date(UNIX_DATE_FORMAT, $end_str); + + + ### Set the constraint array: + $curr_str = $start_str; + while ( $curr_str <= $end_str ) + { + $new_curr_str = mktime (0,0,0,date("m",$curr_str), date("d",$curr_str), date("Y",$curr_str)+1); + $constraint_array[] = Array('start' => $curr_str, 'end' => $new_curr_str); + $TickLables[] = date("Y",$curr_str); + $curr_str = $new_curr_str; + $default_array[] = 0; + } + } + + + + + #################################################################### + ### BY DAY + #################################################################### + + else + { + $FONT_SIZE= 8; + $interval = 3; + $AbsWidth = 4; + $type = $C_translate->translate('day','',''); + + if($start == "" || $start > 12 || $start < 1 ) + { + ## Get the beginning/end of this week + $start_str = mktime (0,0,0,date("m"), 1, date("Y")); + $start = date(UNIX_DATE_FORMAT, $start_str); + $end_str = mktime (0,0,0,date("m",$start_str)+1, 1, date("Y",$start_str)); + $end = date(UNIX_DATE_FORMAT, $end_str); + } + else + { + ## Get the beginning/end of the specified week + $start_str = mktime (0,0,0,date("$start"), 1, date("Y")); + $start = date(UNIX_DATE_FORMAT, $start_str); + $end_str = mktime (0,0,0,date("m",$start_str)+1, 1, date("Y",$start_str)); + $end = date(UNIX_DATE_FORMAT, $end_str); + + } + + ### Set the constraint array: + $curr_str = $start_str; + while ( $curr_str < $end_str ) + { + $new_curr_str = mktime (0,0,0,date("m",$curr_str), date("d",$curr_str)+1, date("Y",$curr_str)); + $constraint_array[] = Array('start' => $curr_str, 'end' => $new_curr_str); + $TickLables[] = date("j",$curr_str); + $curr_str = $new_curr_str; + $default_array[] = 0; + } + } + + + # initialize the module, if it has not already been initialized + $eval = '$' . $module . ' = new ' . $module . '; '; + $eval .= '$this_Obj = $' . $module . ';'; + eval ($eval); + + # run the function + $array = call_user_func (array($module, "graph"), $start_str, $end_str, $constraint_array, $default_array, $extra_fields); + + + include (PATH_GRAPH."jpgraph_bar.php"); + + $datay=$array['results']; + + // Create the graph. These two calls are always required + $graph = new Graph(550,200,"auto"); + $graph->SetScale("textlin"); + $graph->yaxis->scale->SetGrace(25); + $graph->SetMarginColor('#F9F9F9'); + $graph->SetFrame(true,'darkgreen',0); + $graph->SetColor('#FFFFFF'); + #$graph->SetFrame(false); + + + // Adjust the margin a bit to make more room for titles + $graph->img->SetMargin(45,10,15,25); + + // Create a bar pot + $bplot = new BarPlot($datay); + + // Set the X + if(isset($TickLables)) + $graph->xaxis->SetTickLabels($TickLables); + $graph->xaxis->SetTextLabelInterval($interval); + $graph->xaxis->SetColor("navy"); + $graph->yaxis->SetColor("navy"); + + // Adjust fill color + $bplot->SetFillColor('#506DC7'); + $bplot->value->Show(); + $bplot->value->SetFont(FF_FONT1,FS_NORMAL,$FONT_SIZE); + $bplot->value->SetAngle(90); + $bplot->value->SetFormat('%0.0f'); + $bplot->value->SetColor("darkblue"); + $graph->Add($bplot); + + // Setup the titles + $title = $array['title']; + $graph->title->Set($title . " $start - $end"); + $graph->title->SetFont(FF_FONT1,FS_BOLD); + $graph->title->SetColor("black"); + + + // Display the graph + $graph->Stroke(); + } +} +?> \ No newline at end of file diff --git a/modules/core/helm.inc.php b/modules/core/helm.inc.php new file mode 100644 index 00000000..225873e6 --- /dev/null +++ b/modules/core/helm.inc.php @@ -0,0 +1,219 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** + * Helm Remote Class + */ +class HELM +{ + var $host; + var $port; + var $ssl; + var $user; + var $pass; + var $home_dir; + var $shell; + + /* + * Check for Agilebill + */ + function HELM() + { + if(!defined("PATH_FILES")) + { + echo "Dependancy Failure!"; + exit; + } + } + + /* + * Add a user and define available modules + */ + function add($reseller,$username,$domain,$tld,$plan_id,$plan_name,$fname,$lname,$company,$address,$city,$state,$zip,$email) + { + + # got to login first... + $url = $this->host.'/default.asp'; + $post = "txtUsername=tony&txtPassword=slashdot1&RememberMe=1&btnProcess=Login&selLanguageCode=EN&selInterface=standard_XP"; + $ret = $this->connect($url,$post); + + # logged in ok? + if(!eregi("You are now logged in", $ret)) { + echo "Login failed"; + return false; + } + + # create the user + $url = $this->host.'/interfaces/standard/addUser.asp'; + $post = "processing=1". + "&UserAccNum=$reseller". + "&SendWelcomeMessage=1". + "&action=ADD". + "&edited=TRUE". + "&NewAccountNumber=$username". + "&FirstName=$fname". + "&LastName=$lname". + "&CompanyName=$company". + "&Address1=$address". + "&Town=$city". + "&County=$state". + "&Postcode=$zip". + "&PrimaryEmail=$email". + "&Country=US"; + $ret = $this->connect($url,$post); + if($this->debug) echo "

$url?$post
"; + + # Add the package + $url = $this->host.'/interfaces/standard/addpackage.asp'; + $post = "processing=0". + "&txtStatus=0". + "&UserAccNum=$username". + "&action=ADD". + "&PlanID=$plan_id". + "&PackageName=$plan_name"; + $ret = $this->connect($url,$post); + if($this->debug) echo "

$url?$post
"; + + # Get the Package ID Just added + $USERNAME = strtoupper($username); + preg_match ("/(UserAccNum=$USERNAME&PackageID=)+([0-9]){1,}/i", $ret, $arr); + if(is_array($arr) && count($arr) > 0) + { + $package = ereg_replace("UserAccNum=$USERNAME&PackageID=","", $arr[0]); + } + + # Test for package id + if(!@$package > 0) + { + if($this->debug) echo 'Invalid package Id, cannot add domain.'; + return false; + } + + # Add the Domain + $url = $this->host.'/interfaces/standard/AddDomain.asp'; + $post = "processing=0". + "&stage=4". + "&UserAccNum=$username". + "&action=ADD". + "&selDomainReg=NONE". + "&PackageID=$package". + "&DomainName=$domain". + "&DomainExt=$tld"; + $ret = $this->connect($url,$post, 5); + if($this->debug) echo "

$url?$post
"; + + # if it timed out, no errors took place! + if(empty($ret)) + return true; + else + return false; + } + + + /* + * Suspend account in helm + */ + function suspend($username) + { + # Add the Domain + $url = $this->host.'/interfaces/standard/user.asp'; + $post = "action=EDIT". + "&UserAccNum=$username". + "&txtStatus=1"; + $ret = $this->connect($url,$post, 5); + if($this->debug) echo "

$url?$post
"; + + if($ret != false) + return true; + else + return false; + } + + + /* + * Unsuspend account in helm + */ + function unsuspend($username) + { + # Add the Domain + $url = $this->host.'/interfaces/standard/user.asp'; + $post = "action=EDIT". + "&UserAccNum=$username". + "&txtStatus=0"; + $ret = $this->connect($url,$post, 5); + if($this->debug) echo "

$url?$post
"; + + if($ret != false) + return true; + else + return false; + } + + + /* + * Delete account from helm + */ + function del($username) + { + # Add the Domain + $url = $this->host.'/interfaces/standard/user.asp'; + $post = "action=DELETE". + "&UserAccNum=$username"; + $ret = $this->connect($url,$post, 5); + if($this->debug) echo "

$url?$post
"; + + if($ret == false) + return true; + else + return false; + } + + + /* + * Curl connect + */ + function connect($url,$post, $timeout=false) + { + if($this->ssl) + $url = 'https://'.$url; + else + $url = 'http://'.$url; + + $ch = curl_init(); + if($timeout != false) + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie_path); + curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie_path); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_VERBOSE, 1 ); + curl_setopt($ch, CURLOPT_HEADER, 1); + + $data = curl_exec ($ch); + curl_close ($ch); + return $data; + } +} +?> \ No newline at end of file diff --git a/modules/core/import.inc.php b/modules/core/import.inc.php new file mode 100644 index 00000000..479993f4 --- /dev/null +++ b/modules/core/import.inc.php @@ -0,0 +1,345 @@ + + * @package AgileBill + * @version 1.4.93 + */ + + +/** + * Import Handler Module. + */ +class CORE_import +{ + + ### Validate the import file/upload. + ### Generate the array to display the field options. + + function prepare_import($VAR, $construct) + { + global $_FILES, $C_debug, $smarty; + + if($VAR['filetype'] == 'upload') + { + if(isset($_FILES['file']) && $_FILES['file']['size'] > 0) + { + # added str_replace for spaces, because Linux really doesn't like them much. + $this->filename = str_replace(" ","_",'import_'.$VAR['module'].'_'.$_FILES['file']['name']); + $this->file = PATH_FILES . $this->filename; + copy($_FILES['file']['tmp_name'], $this->file); + } + else + { + $C_debug->alert('Please go back and enter a file to upload!'); + return false; + } + } + elseif ($VAR['filetype'] == 'local') + { + @$this->filename = $VAR['file']; + @$this->file = PATH_FILES.$VAR['file']; + if(!is_file($this->file)) + $C_debug->alert('The specified file does not exist!'); + return false; + } + else + { + $C_debug->alert('Please go back and enter all required fields!'); + return false; + } + + # open the file for parsing + require_once('includes/pear/Compat/Function/file_get_contents.php'); + $data = file_get_contents($this->file); + $rows = explode("\r\n", $data); + + + if($VAR['type'] == 'csv') + $sp = ','; + elseif($VAR['type'] == 'tab') + $sp = ' '; + else + return false; + + # get the first row for the example data + if(count($rows) == 0) + { + return false; + } + else + { + # set the columns and sample data smarty array: + $columns = explode($sp, $rows[0]); + $this->sbox = array('-- Use Constant Value --'); + + for($i=0;$isbox[] = "Field #$i: ".$columns[$i]; + + if($VAR['type'] && ereg("^\"",$smart[$i]['sample']) && ereg("\"$",$smart[$i]['sample'])) + { + $smart[$i]['sample'] = ereg_replace("^\"","",$smart[$i]['sample']); + $smart[$i]['sample'] = ereg_replace("\"$","",$smart[$i]['sample']); + } + } + + # set the smarty vars: + $smarty->assign('rows',count($rows)); + $smarty->assign('columns',$smart); + $smarty->assign('file', $this->filename); + $smarty->assign('type', $VAR['type']); + + # set the available fields: + $fields = explode(',', '--NONE--,'.$construct->method['import']); + $smarty->assign('fields', $fields); + + + $smarty->assign('fields_array',$this->build_fields($construct)); + return true; + } + } + + function build_fields(&$construct) + { + $fields_array = explode(",",$construct->method['import']); + $i = 0; + foreach ($fields_array as $f) { + $itbl[$i]['field'] = $f; + $itbl[$i]['options'] = @$this->sbox; + $itbl[$i]['type'] = ''; + $itbl[$i]['custom'] = 0; + $i++; + } + if(isset($construct->import_custom) && count($construct->import_custom)) { + foreach ($construct->import_custom as $f) { + $itbl[$i]['field'] = $f['name']; + $itbl[$i]['options'] = $f['value']; + $itbl[$i]['type'] = $f['type']; + $itbl[$i]['custom'] = 1; + $i++; + } + } + return $itbl; + } + + ### Perform the actual import + function do_new_import(&$VAR, &$construct) + { + global $C_debug; + $this->file = PATH_FILES.$VAR['file']; + require_once('includes/pear/Compat/Function/file_get_contents.php'); + $data = file_get_contents($this->file); + $rows = explode("\r\n", $data); + + # get the file type: + if($VAR['type'] == 'csv') + $sp = ','; + elseif($VAR['type'] == 'tab') + $sp = ' '; + else + return false; + + # get the first row for the example data + if(count($rows) == 0) + { + return false; + } + else + { + # get the available fields: + $fields = $this->build_fields($construct); + + # start the insert statement + $db = &DB(); + $q = "INSERT INTO ".AGILE_DB_PREFIX."$construct->table "; + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."$construct->table WHERE id = -1"; + $rs = $db->Execute($sql); + + $bad = 0; + # loop through the rows + for($row=0; $row".print_r($columns,true)."

"; + $record = array(); + for($i=0;$i 0) { + $record[$fields[$i]['field']] = @$columns[--$idx]; + if($VAR['type'] && ereg("^\"",$record[$fields[$i]['field']]) && ereg("\"$",$record[$fields[$i]['field']])) { + $record[$fields[$i]['field']] = ereg_replace("^\"","",$record[$fields[$i]['field']]); + $record[$fields[$i]['field']] = ereg_replace("\"$","",$record[$fields[$i]['field']]); + } + } else { + $record[$fields[$i]['field']] = @$VAR['import_constant'][$fields[$i]['field']]; + } + + } + + $record['site_id'] = DEFAULT_SITE; + if(empty($record['id'])) + $record['id'] = $db->GenID(AGILE_DB_PREFIX . $construct->table . '_id'); + + $SQL = $db->GetInsertSQL($rs, $record); + # echo $SQL."
"; + + /* call import_line_process */ + if (is_callable(array($construct,'import_line_process'))) { + $construct->import_line_process($db, $VAR, $fields, $record); + } + + if($VAR['import_type'] == 'db') + { + # execute command + $db->Execute($SQL); + } + else + { + # add to sql command for download + @$SQL_DL .= $SQL . ";\r\n\r\n"; + } + } else { + $bad++; + } + } + + if(@$VAR['import_type'] == 'dl') + { + header ("Content-Disposition: attachment; filename=$construct->table.sql" ); + echo $SQL_DL; + exit; + } + + $C_debug->alert("Imported $row record(s) and $bad record(s) were skipped."); + return true; + } + } + + + ### Validate the fields. + ### Perform the actual import + + function do_import($VAR, $construct) + { + global $C_debug; + $this->file = PATH_FILES.$VAR['file']; + require_once('includes/pear/Compat/Function/file_get_contents.php'); + $data = file_get_contents($this->file); + $rows = explode("\r\n", $data); + + # get the file type: + if($VAR['type'] == 'csv') + $sp = ','; + elseif($VAR['type'] == 'tab') + $sp = ' '; + else + return false; + + # get the first row for the example data + if(count($rows) == 0) + { + return false; + } + else + { + # get the available fields: + $fields = explode(',', ','.$construct->method['import']); + + # start the insert statement + $db = &DB(); + $q = "INSERT INTO ".AGILE_DB_PREFIX."$construct->table "; + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."$construct->table WHERE id = -1"; + $rs = $db->Execute($sql); + + + # loop through the rows + for($row=0; $rowalert("You have used the table $field more than once!"); + return false; + } + + # get the field data: + if(!empty($field)) + { + # get the data: + $data = $columns[$i]; + if($VAR['type'] && ereg("^\"",$data) && ereg("\"$",$data)) + { + $data = ereg_replace("^\"","",$data); + $data = ereg_replace("\"$","",$data); + } + + # check for relational records: + + + $record["$field"] = $data; + } + } + + $record['site_id'] = DEFAULT_SITE; + if(empty($record['id'])) + $record['id'] = $db->GenID(AGILE_DB_PREFIX . $construct->table . '_id'); + + $SQL = $db->GetInsertSQL($rs, $record); + + if($VAR['import_type'] == 'db') + { + # execute command + $db->Execute($SQL); + if($import_rs === false) + { + # error message + } + } + else + { + # add to sql command for download + @$SQL_DL .= $SQL . ";\r\n\r\n"; + } + } + + if($VAR['import_type'] == 'dl') + { + header ("Content-Disposition: attachment; filename=$construct->table.sql" ); + echo $SQL_DL; + exit; + } + + $C_debug->alert("Imported $row record(s)."); + return true; + } + } +} +?> \ No newline at end of file diff --git a/modules/core/list.inc.php b/modules/core/list.inc.php new file mode 100644 index 00000000..6392292f --- /dev/null +++ b/modules/core/list.inc.php @@ -0,0 +1,423 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_list +{ + var $id; + + function menu($input_id, $name, $table, $field, $id, $class, $all=false) { + global $C_translate; + if($all == true || $id == 'all') $all = true; + if(!isset($this->id)) $this->id = 100; + if($input_id <= 0 && $input_id != 'no') $input_id = $this->id++; + $db = &DB(); + $sql= "SELECT id, $field FROM ".AGILE_DB_PREFIX."$table WHERE site_id = '" . DEFAULT_SITE . "' ORDER BY $field"; + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','menu', $db->ErrorMsg()); + } else { + $return = ''; + if($i > 0 && $input_id != 'no') + $return .= ' '; + echo $return; + } + } + + function decrypt($data) { + include_once(PATH_CORE.'crypt.inc.php'); + return CORE_decrypt($data); + } + + function menu_cc_admin($field, $account, $default, $class, $user=false) { + include_once(PATH_MODULES . 'account_billing/account_billing.inc.php'); + $acct_bill = new account_billing; + echo $acct_bill->menu_admin($field, $account, $default, $class, $user); + } + + function menu_multi($default, $name, $table, $field, $id, $max, $class) { + include_once(PATH_CORE . 'list_menu_multi.inc.php'); + echo list_menu_multi($default, $name, $table, $field, $id, $max, $class); + } + + function menu_files($id, $name, $default, $path, $pre, $ext, $class) { + include_once(PATH_CORE . 'list_menu_files.inc.php'); + echo list_menu_files($id, $name, $default, $path, $pre, $ext, $class); + } + + function format_currency ($number, $currency_id) { + if(empty($number)) $number = 0; + if(empty($currency_id)) $currency_id = DEFAULT_CURRENCY; + if(!isset($this->format_currency[$currency_id])) $this->currency($currency_id); + if($currency_id != DEFAULT_CURRENCY) + if(!isset($this->format_currency[DEFAULT_CURRENCY])) + $this->currency(DEFAULT_CURRENCY); + $number *= $this->format_currency[DEFAULT_CURRENCY]["convert"][$currency_id]["rate"]; + if($number > .05 || $number == 0 || $number < -1) + return $this->format_currency[$currency_id]["symbol"] + . "" . number_format($number, DEFAULT_DECIMAL_PLACE) . " " + . $this->format_currency[$currency_id]["iso"]; + else + return $this->format_currency[$currency_id]["symbol"] + . "" . number_format($number, 3) . " " + . $this->format_currency[$currency_id]["iso"]; + } + + function format_currency_num ($number, $currency_id) { + if(empty($number)) $number = 0; + if(empty($currency_id)) $currency_id = DEFAULT_CURRENCY; + if(!isset($this->format_currency[$currency_id])) $this->currency($currency_id); + if(!isset($this->format_currency[DEFAULT_CURRENCY])) $this->currency(DEFAULT_CURRENCY); + $number *= $this->format_currency[DEFAULT_CURRENCY]["convert"][$currency_id]["rate"]; + if($number > .05 || $number == 0 || $number < -1) + return $this->format_currency[$currency_id]["symbol"] . number_format($number, DEFAULT_DECIMAL_PLACE); + else + return $this->format_currency[$currency_id]["symbol"] . number_format($number, 3); + } + + function format_currency_decimal ($number, $currency_id) { + if(empty($number)) return 0; + if(empty($currency_id)) $currency_id = DEFAULT_CURRENCY; + if(!isset($this->format_currency[$currency_id])) $this->currency($currency_id); + if(!isset($this->format_currency[DEFAULT_CURRENCY])) $this->currency(DEFAULT_CURRENCY); + return round($number *= $this->format_currency[DEFAULT_CURRENCY]["convert"][$currency_id]["rate"], 2); + } + + function currency_list($ret) { + if(!isset($this->format_currency[$currency_id])) $this->currency(DEFAULT_CURRENCY); + global $smarty; + $smarty->assign("$ret", $this->format_currency[DEFAULT_CURRENCY]["convert"]); + } + + function currency_iso ($currency_id) { + if(empty($currency_id)) $currency_id = DEFAULT_CURRENCY; + if(!isset($this->format_currency[$currency_id])) $this->currency($currency_id); + return $this->format_currency[$currency_id]["iso"]; + } + + function currency($currency_id) { + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'currency WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($currency_id); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) { + $this->format_currency[$currency_id] = Array ( + 'symbol' => $result->fields["symbol"], + 'convert' => unserialize($result->fields["convert_array"]), + 'iso' => $result->fields["three_digit"]); + return true; + } else { + return false; + } + } + + function radio($input_id, $name, $table, $field, $id, $class) { + include_once(PATH_CORE . 'list_radio.inc.php'); + echo list_radio($input_id, $name, $table, $field, $id, $class); + } + + function check($input_id, $name, $table, $field, $default, $class) { + include_once(PATH_CORE . 'list_check.inc.php'); + echo list_check($input_id, $name, $table, $field, $default, $class); + } + + function select_groups($default, $field_name, $class, $size, $own_account) { + include_once(PATH_CORE . 'list_select_groups.inc.php'); + return list_select_groups($default, $field_name, $class, $size, $own_account); + } + + function calender_view($field, $default, $css, $id) { + if(isset($default) && $default != '' && $default != '0') + $default = date(UNIX_DATE_FORMAT, $default); + else + $default = ''; + include_once(PATH_CORE.'list_calendar.inc.php'); + echo list_calender_add($field, $default, $css); + } + + function calender_add($field, $default, $css) { + if($default == 'now') $default = date(UNIX_DATE_FORMAT, time()); + include_once(PATH_CORE.'list_calendar.inc.php'); + echo list_calender_add($field, $default, $css); + } + + function calender_add_static_var($field, $default, $css) { + if($default == 'now') $default = date(UNIX_DATE_FORMAT, time()); + include_once(PATH_CORE.'list_calendar.inc.php'); + echo list_calender_add_static($field, $default, $css); + } + + function calender_search($field, $default, $css) { + if($default == 'now') $default = date(UNIX_DATE_FORMAT, time()); + echo ' +   '; + $this->calender_view($field.'[0]', $default, $css, 1); + echo '
+   '; + $this->calender_view($field.'[1]', $default, $css, 1); + } + + function setup_default_date($default, $css) { + include_once(PATH_CORE . 'list_setup_default_date.inc.php'); + echo list_setup_default_date($default, $css); + } + + function card_type_menu($default_selected, $checkout_id, $field='checkout_plugin_data[card_type]', $class) { + include_once(PATH_CORE . 'list_card_type_menu.inc.php'); + echo list_card_type_menu($default_selected, $checkout_id, $field, $class); + } + + function date($date) { + if($date == '') $date = time(); + return date(UNIX_DATE_FORMAT, $date); + } + + function date_time($date) { + if($date == '') $date = time(); + $ret = date(UNIX_DATE_FORMAT, $date); + $ret .= " ".date(DEFAULT_TIME_FORMAT, $date); + return $ret; + } + + function unserial ($data, $var) { + global $smarty; + if(is_string($data)) $array = unserialize($data); + if(is_array($array)) $smarty->assign($var, $array); + return; + } + + function smarty_array($table, $field, $sql, $return) { + $db = &DB(); + $sql= "SELECT id, $field FROM ".AGILE_DB_PREFIX."$table + WHERE site_id = '" . DEFAULT_SITE . "'" . $sql . " + ORDER BY $field"; + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','smarty_array', $db->ErrorMsg()); + return false; + } + while (!$result->EOF) + { + $smart[] = $result->fields; + $result->MoveNext(); + } + global $smarty; + $smarty->assign("$return", $smart); + return true; + } + + function translate($table, $field1, $field2, $id, $var) { + global $smarty; + $db = &DB(); + $sql= "SELECT id, $field1 FROM ".AGILE_DB_PREFIX."$table + WHERE site_id = " . $db->qstr(DEFAULT_SITE) . " AND + language_id = " . $db->qstr(SESS_LANGUAGE). " AND " . + $field2 . " = " . $db->qstr($id); + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','translate', $db->ErrorMsg()); + return false; + } else if($result->RecordCount() > 0) { + $smarty->assign("$var", $result->fields); + return $result->fields; + } else { + if (SESS_LANGUAGE == DEFAULT_LANGUAGE) { + return false; + } else { + $sql= "SELECT id, $field1 FROM ".AGILE_DB_PREFIX."$table + WHERE site_id = " . $db->qstr(DEFAULT_SITE) . " AND + language_id = " . $db->qstr(DEFAULT_LANGUAGE). " AND " . + $field2 . " = " . $db->qstr($id); + $result = $db->Execute($sql); + if ($result === false) { + global $C_debug; + $C_debug->error('list.inc.php','translate', $db->ErrorMsg()); + return false; + } else if($result->RecordCount() > 0) { + $smarty->assign("$var", $result->fields); + return $result->fields; + } else { + return false; + } + } + } + } + + function bool($field, $curr_value, $extra) { + global $C_translate; + if($curr_value == 'all') { + $true = ''; + $false= ''; + } else if($curr_value == "1") { + $true = ' selected'; + $false= ''; + } else { + $true = ''; + $false= ' selected'; + } + + $return = ''; + echo $return; + } + + function bool_static_var($field, $curr_value, $class) { + global $C_translate; + if ($curr_value == 'all') { + $true = ''; + $false= ''; + } else if ($curr_value == 0) { + $true = ''; + $false= ' selected'; + } else { + $true = ' selected'; + $false= ''; + } + $return = ''; + return $return; + } + + function graphview() { + global $VAR, $C_method; + $auth = Array('product:top', 'account_admin:top', 'affiliate:top', 'invoice:compare'); + for($i=0; $iexe_noauth($m[0], $m[1]); + exit; + } + } + } + + function bar_graph() { + global $VAR; + require_once(PATH_CORE . 'graph.inc.php'); + $graph = new CORE_graph; + @$module = $VAR['graph_module']; + @$range = $VAR['graph_range']; + @$start = $VAR['graph_start']; + @$extra = $VAR['graph_extra']; + $graph->BAR_graph($module, $range, $start, $extra); + } + + function pie_graph() { + global $VAR; + require_once(PATH_CORE . 'graph.inc.php'); + $graph = new CORE_graph; + @$module = $VAR['graph_module']; + @$method = $VAR['graph_method']; + @$range = $VAR['graph_range']; + @$start = $VAR['graph_start']; + @$extra = $VAR['graph_extra']; + $graph->PIE_graph($module, $method, $range, $start, $extra); + } + + function is_installed($module) { + if(@$this->is_installed[$module] == true) return true; + if($this->auth_method_by_name($module, 'search')) { + $this->is_installed[$module] = true; + return true; + } + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'module WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + name = ' . $db->qstr($module) . ' AND + status = ' . $db->qstr("1"); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) { + $this->is_installed[$module] = true; + return true; + } else { + return false; + } + } + + function auth_method_by_name($module, $method) { + global $C_auth; + if(!is_object($C_auth)) return false; + return $C_auth->auth_method_by_name($module, $method); + } + + function generate_admin_menu() { + global $C_auth; + echo $C_auth->generate_admin_menu(); + } + + function account($field) { + if (empty($this->account) && SESS_LOGGED) { + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr(SESS_ACCOUNT); + $result = $db->Execute($sql); + $this->account = $result->fields; + } + echo $this->account[$field]; + } + + # Get the AgileBill version info + function version() { + require_once(PATH_CORE.'version.inc.php'); + } +} +?> \ No newline at end of file diff --git a/modules/core/list_calendar.inc.php b/modules/core/list_calendar.inc.php new file mode 100644 index 00000000..9eb60bd9 --- /dev/null +++ b/modules/core/list_calendar.inc.php @@ -0,0 +1,71 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function list_calender_add($field, $default, $css) +{ + # set the date to current date if 'now' is set as $default + if($default == 'now') + { + $default = date(UNIX_DATE_FORMAT, time()); + } + + $id = rand(9,999); + $ret = ' +   + + + '; + return $ret; +} + + +function list_calender_add_static($field, $default, $css) +{ + # set the date to current date if 'now' is set as $default + if($default == 'now') + { + $default = date(UNIX_DATE_FORMAT); + } + + $id = rand(9,999); + $ret = ' +   + + + '; + return $ret; +} +?> \ No newline at end of file diff --git a/modules/core/list_card_type_menu.inc.php b/modules/core/list_card_type_menu.inc.php new file mode 100644 index 00000000..f60a36d5 --- /dev/null +++ b/modules/core/list_card_type_menu.inc.php @@ -0,0 +1,65 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function list_card_type_menu($default_selected, $checkout_id, $field, $class) +{ + // define default list of accepted CC types + $def_accepted_arr = Array ( + 0 => 'visa', + 1 => 'mc', + 2 => 'amex', + 3 => 'discover', + 4 => 'delta', + 5 => 'solo', + 6 => 'switch', + 7 => 'jcb', + 8 => 'diners', + 9 => 'carteblanche', + 10 => 'enroute' ); + + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."checkout WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($checkout_id); + $rs = $db->Execute($q); + if($rs == false || $rs->RecordCount() == 0) + $accepted_arr = $def_accepted_arr; + + @$cfg = unserialize($rs->fields["plugin_data"]); + $accepted_arr = $cfg['card_type']; + + if(count($accepted_arr) <= 0) + $accepted_arr = $def_accepted_arr; + + global $C_translate; + $data = ''; + return $data; +} +?> \ No newline at end of file diff --git a/modules/core/list_check.inc.php b/modules/core/list_check.inc.php new file mode 100644 index 00000000..b142cb48 --- /dev/null +++ b/modules/core/list_check.inc.php @@ -0,0 +1,81 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function list_check($input_id, $name, $table, $field, $default, $class) +{ + global $C_translate; + + # get default + if(!isset($default)) + { + $default = Array(''); + } + else if (gettype($default) == 'array') + { + $default = $default; + } + else if (gettype($default) == 'string') + { + $default = unserialize($default); + } + else + { + $default = Array(''); + } + + # get the records + $db = &DB(); + $sql= "SELECT id, $field FROM ".AGILE_DB_PREFIX."$table + WHERE site_id = " . $db->qstr(DEFAULT_SITE) . " + ORDER BY $field"; + $result = $db->Execute($sql); + + # error handling + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','check', $db->ErrorMsg()); + } + + # loop through the records + $i = 0; + while (!$result->EOF) { + + # Create the return code for Smarty + $checked = ''; + for($ii=0; $iifields["id"] || $default[$i] == 'all') $checked = ' checked'; + } + + $return .= ' ' . $result->fields["$field"] . '
'; + + $i++; + $result->MoveNext(); + } + + if($i==0) + $return .= 'None Defined'; ### TRANSLATE + + echo $return; +} +?> \ No newline at end of file diff --git a/modules/core/list_currency.inc.php b/modules/core/list_currency.inc.php new file mode 100644 index 00000000..45bdabd5 --- /dev/null +++ b/modules/core/list_currency.inc.php @@ -0,0 +1,72 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function list_format_currency ($number, $currency_id) +{ + if(empty($currency_id)) $currency_id = DEFAULT_CURRENCY; + if(isset($this->format_currency["currency_id"])) + { + return $this->format_currency["currency_id"] + . "" . number_format($number, DEFAULT_DECIMAL_PLACE) . " " + . $this->format_currency["currency_id"]["iso"]; + } + else + { + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'currency WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($currency_id); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + $this->format_currency["currency_id"] = Array ( + 'symbol' => $result->fields["symbol"], + 'iso' => $result->fields["three_digit"]); + return $result->fields["symbol"] + . "" . number_format($number, DEFAULT_DECIMAL_PLACE) . " " + . $result->fields["three_digit"]; + } + else + { + return number_format($number, DEFAULT_DECIMAL_PLACE); + } + } +} + + +function list_currency_iso ($currency_id) +{ + if(empty($currency_id)) $currency_id = DEFAULT_CURRENCY; + if(isset($this->format_currency["currency_id"])) + { + return $this->format_currency["currency_id"]["iso"]; + } + else + { + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'currency WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($currency_id); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + return $result->fields["three_digit"]; + } +} +?> \ No newline at end of file diff --git a/modules/core/list_menu_files.inc.php b/modules/core/list_menu_files.inc.php new file mode 100644 index 00000000..ed355e4f --- /dev/null +++ b/modules/core/list_menu_files.inc.php @@ -0,0 +1,79 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function list_menu_files($id, $name, $default, $path, $pre, $ext, $class) +{ + global $C_translate; + if($path == 'product_cat') $path = PATH_THEMES . '' . DEF_THEME_N . '/blocks/product_cat/'; + elseif($path == 'whois_plugin') $path = PATH_PLUGINS . '/whois/'; + elseif($path == 'product') $path = PATH_PLUGINS . '/product/'; + elseif($path == 'e911') $path = PATH_PLUGINS . '/e911/'; + elseif($path == 'provision_plugin') $path = PATH_PLUGINS . '/provision/'; + elseif($path == 'affiliate_plugin') $path = PATH_PLUGINS . '/affiliate/'; + elseif($path == 'checkout_plugin') $path = PATH_PLUGINS . '/checkout/'; + elseif($path == 'theme') $path = PATH_THEMES; + elseif($path == 'language') $path = PATH_LANGUAGE . '/core/'; + + $count = 0; + chdir($path); + $dir = opendir($path); + while ($file_name = readdir($dir)) + { + $display = true; + if($file_name != '..' && $file_name != '.') + { + if(!empty($ext)) + { + $cute = eregi_replace($ext.'$', "", $file_name); + if(!eregi($ext.'$', $file_name)) $display = false; + } + if(!empty($pre)) + { + $cute = eregi_replace('^'.$pre, "", $cute); + if(!eregi('^'.$pre, $file_name)) $display = false; + } + if($display) + { + $arr[] = $cute; + $cute = eregi_replace("_"," ",$cute); + $cute = eregi_replace("-"," ",$cute); + $arrc[] = $cute; + $count++; + } + } + } + $return = ''; + echo $return; +} +?> \ No newline at end of file diff --git a/modules/core/list_menu_multi.inc.php b/modules/core/list_menu_multi.inc.php new file mode 100644 index 00000000..2ad9391a --- /dev/null +++ b/modules/core/list_menu_multi.inc.php @@ -0,0 +1,67 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function list_menu_multi($default, $name, $table, $field, $id, $max, $class) +{ + global $C_translate; + if(!isset($default)) + $default = Array(''); + else if (gettype($default) == 'array') + $default = $default; + else if (gettype($default) == 'string') + $default = unserialize($default); + else + $default = Array(''); + $db = &DB(); + $sql= "SELECT id, $field FROM ".AGILE_DB_PREFIX."$table WHERE site_id = '" . DEFAULT_SITE . "' ORDER BY $field"; + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','menu_list', $db->ErrorMsg()); + } + if (@$result->RecordCount() > $max && @$result->RecordCount() != 0) + $size = $max; + else + $size = $result->RecordCount(); + $return = ''; + echo $return; +} +?> \ No newline at end of file diff --git a/modules/core/list_menu_theme.inc.php b/modules/core/list_menu_theme.inc.php new file mode 100644 index 00000000..46c5327b --- /dev/null +++ b/modules/core/list_menu_theme.inc.php @@ -0,0 +1,85 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function list_menu_theme ($name, $id, $class) +{ + global $C_translate, $C_auth; + + if(!isset($this->id)) $this->id = 100; + + # set the input id + if($id = '') $id = DEFAULT_THEME; + + + # get the records + $db = &DB(); + $sql= "SELECT * FROM " + .AGILE_DB_PREFIX."theme WHERE site_id = '" . DEFAULT_SITE . "' ORDER BY name,description"; + $result = $db->Execute($sql); + + # error handling + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','menu', $db->ErrorMsg()); + return false; + } + + # start the return variable + $return = ''; + return $return; +} +?> \ No newline at end of file diff --git a/modules/core/list_radio.inc.php b/modules/core/list_radio.inc.php new file mode 100644 index 00000000..8e8648ab --- /dev/null +++ b/modules/core/list_radio.inc.php @@ -0,0 +1,57 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function list_radio($input_id, $name, $table, $field, $id, $class) +{ + global $C_translate; + $db = &DB(); + $sql= "SELECT id, $field FROM ".AGILE_DB_PREFIX."$table WHERE site_id = '" . DEFAULT_SITE . "' ORDER BY $field"; + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','radio', $db->ErrorMsg()); + } + if($result->RecordCount() >= 5) + { + $count = 5; + }else{ + $count = $result->RecordCount(); + } + if($id == "all") + $return .= ' All
'; + $i = 0; + while (!$result->EOF) { + if($id == $result->fields["id"]) + { + $return .= ' ' . $result->fields["$field"] . '
'; + } + else + { + $return .= ' ' . $result->fields["$field"] . '
'; + } + $i++; + $result->MoveNext(); + } + if($i==0) + $return .= ''. $C_translate->translate('lists_none_defined','CORE',''); + return $return; +} +?> \ No newline at end of file diff --git a/modules/core/list_select_groups.inc.php b/modules/core/list_select_groups.inc.php new file mode 100644 index 00000000..50bfcd8d --- /dev/null +++ b/modules/core/list_select_groups.inc.php @@ -0,0 +1,180 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function list_select_groups($default, $field_name, $class, $size, $own_account) +{ + global $C_auth; + + # get the default group + if(!isset($default) && $default == "") + { + $default = Array(DEFAULT_GROUP); + } + else if(gettype($default) == 'array') + { + #$default = $default; + } + else if(gettype($default) == 'string') + { + $default = unserialize($default); + } + + + for($i=0; $iExecute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','select_groups', $db->ErrorMsg()); + } + + # number of results + if($result->RecordCount() > 0) + { + + # set the results to an array: + $arr = $result->GetArray(); + + # start the list + $ret = ''; + + #---------------------- + # start the parent loop + #---------------------- + $group = 0; + $arr_count = count($arr); + for($i=0; $i < $arr_count; $i++) + { + + #################### + ### Is auth? + if(!$C_auth->auth_group_by_id($arr[$i]['id'])) + $disabled = ' disabled'; + else + $disabled = ''; + + ##################### + + $level = 0; + if($arr[$i]['parent_id'] == $group) + { + #if($own_account && $checked[$arr[$i]['id']] == true) $disabled = ' disabled'; + + $ret .= '  '. $arr[$i]['name'] .'
'; + + #---------------------- + # start the child loop + #---------------------- + $level++; + $ii_group = $arr[$i]['id']; + $ii_print = 1; + + # count the available childs for this group + $count_child[$ii_group]=0; + for($c_child=0; $c_child < $arr_count; $c_child++) + if($arr[$c_child]['parent_id'] == $ii_group) $count_child[$ii_group]++; + + for($ii=0; $ii < $arr_count; $ii++) + { + + ################ + ### Is auth? + if(!$C_auth->auth_group_by_id($arr[$ii]['id'])) + $disabled = ' disabled'; + else + $disabled = ''; + ################# + + if($arr[$ii]['parent_id'] == $ii_group) + { + #if($own_account && $checked[$arr[$ii]['id']] == true) $disabled = ' disabled'; + + $ret .= '  |__'; + $ret .= '  '. $arr[$ii]['name'] .'
'; + + $ii_print++; + + #-------------------------- + # start the sub-child loop + #-------------------------- + $level++; + $iii_group = $arr[$ii]['id']; + $iii_print = 0; + for($iii=0; $iii < $arr_count; $iii++) + { + + ################ + ### Is auth? + if(!$C_auth->auth_group_by_id($arr[$iii]['id'])) + $disabled = ' disabled'; + else + $disabled = ''; + ################# + + if($arr[$iii]['parent_id'] == $iii_group) + { + #if($own_account && $checked[$arr[$iii]['id']] == true) $disabled = ' disabled'; + + if($count_child[$ii_group] < $ii_print) + { + $ret .= '         |__ '; + } + else + { + $ret .= '  |      |__ '; + } + $ret .= '  '. $arr[$iii]['name'] .'
'; + $iii_print++; + } + } + $level--; + #----------------------- + # end of sub-child loop + #----------------------- + + } + } + $level--; + #------------------- + # end of child loop + #------------------- + } + } + } + else + { + return 'No groups available!'; // translate! + } + return $ret; +} +?> \ No newline at end of file diff --git a/modules/core/list_setup_default_date.inc.php b/modules/core/list_setup_default_date.inc.php new file mode 100644 index 00000000..16108333 --- /dev/null +++ b/modules/core/list_setup_default_date.inc.php @@ -0,0 +1,82 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +function list_setup_default_date($default, $css) +{ + global $C_translate; + $arr = unserialize($default); + $ret =''; + + # loop through the menus + for($i=0; $i<3; $i++) + { + + + $ret .= ' + + '; + } + + + $ret .= ' + +
+ '; + return $ret; +} +?> \ No newline at end of file diff --git a/modules/core/login.inc.php b/modules/core/login.inc.php new file mode 100644 index 00000000..e81ddafc --- /dev/null +++ b/modules/core/login.inc.php @@ -0,0 +1,357 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_login_handler +{ + + function login($VAR, $md5=true) + { + global $C_translate, $C_debug; + + # check that the username/password are both set + if(($VAR['_username'] == '') || ($VAR['_password'] == '')) + { + $C_debug->alert($C_translate->translate('login_enter_both','','')); + return; + } + + # md5 the password + if($md5) + $pass = md5($VAR['_password']); + else + $pass = $VAR['_password']; + + # check the database for a match + $db = &DB(); + $q = "SELECT id,status,username,password,date_expire FROM " . AGILE_DB_PREFIX . "account WHERE + password = '$pass' AND + username = '".$VAR['_username']."' AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + # get the account id + $id = $result->fields['id']; + + # check that their is no lock on this account id or IP address: + if($this->locked ($id)) + { + $C_debug->alert($C_translate->translate('login_locked','','')); + return; + } + + + # verify the username/password match. + if($result->fields['username'] == $VAR['_username']) + { + if (($result->fields['password'] !== $VAR['_password']) && ($result->fields['password'] != $pass)) + { + # no match + $C_debug->alert($C_translate->translate('login_pw_failed','','')); + + # log as a failed login + $this->lock_check($VAR,"0",$id); + return; + } + } + else + { + # no username match + $C_debug->alert($C_translate->translate('login_un_pw_failed','','')); + + # reload the login page + $VAR["_page"] = 'account:login'; + + # log as a failed login + $this->lock_check($VAR,"0",$VAR['_username']); + return; + } + + + if($result->fields['date_expire'] == "0" || $result->fields['date_expire'] == "") + $date_expire = time()+99; + else + $date_expire = $result->fields['date_expire']; + + + # check that it is an active account + if($result->fields['status'] != "1" || $date_expire <= time()) + { + # inactive account + $C_debug->alert($C_translate->translate('login_inactive','','')); + + # log as failed login + $this->lock_check($VAR,"0",$id); + return; + } + else + { + # active account - check for password sharing if login_share module is installed + include_once(PATH_CORE.'list.inc.php'); + $C_list = new CORE_list; + if($C_list->is_installed('login_share')) + { + include_once(PATH_MODULES.'login_share/login_share.inc.php'); + $share = new login_share; + if(!$share->login($id, $VAR['_username'])) + { + # shared account alert + $C_debug->alert($C_translate->translate('shared_account','login_share','')); + + # log as failed login + $this->lock_check($VAR,"0",$id); + + return; + } + } + } + + # set the expiry date of the login session + $date_expire = (time() + (SESSION_EXPIRE * 60)); + + # update the DB + $db = &DB(); + $q = "UPDATE " . AGILE_DB_PREFIX . "session + SET + ip= '". USER_IP ."', + date_expire = '$date_expire', + logged = '1', + account_id = '$id' + WHERE + id = '" . SESS . "' + AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + # delete any old sessions for this account + $db = &DB(); + $q = "DELETE FROM " . AGILE_DB_PREFIX . "session WHERE + account_id = '$id' AND + id != '" . SESS . "' AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + #return logged in message + $C_debug->alert($C_translate->translate('login_success','','')); + + + # Get the last successful login: + $db = &DB(); + $q = "SELECT * FROM " . AGILE_DB_PREFIX . "login_log WHERE + account_id = ". $db->qstr($id)." AND + status = ". $db->qstr(1)." AND + site_id = ". $db->qstr(DEFAULT_SITE) . " + ORDER BY date_orig DESC LIMIT 1"; + $result = $db->Execute($q); + if($result->RecordCount() != 0) + { + $ip = $result->fields["ip"]; + $date = $result->fields["date_orig"]; + $date1 = date(UNIX_DATE_FORMAT, $date); + $date1.= " ".date(DEFAULT_TIME_FORMAT, $date); + + $message = $C_translate->translate('login_log_success','',''); + $message = ereg_replace('%date%', $date1, $message); + $message = ereg_replace('%ip%', $ip, $message); + $C_debug->alert($message); + } + + + # log the successful login + $this->lock_check($VAR,"1",$id); + + + #################################################################### + ### Do any db_mapping + #################################################################### + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'module WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + name = ' . $db->qstr('db_mapping') . ' AND + status = ' . $db->qstr("1"); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + $db_map->login ( $id ); + } + } + + + + + function logout ($VAR) + { + global $C_debug, $C_translate; + $db = &DB(); + + # get the account id (for DB mapping): + $q = "SELECT account_id FROM ". AGILE_DB_PREFIX ."session WHERE + id = '" . SESS . "' AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + $account_id = $result->fields['account_id']; + + # logout the current session by editing the database record + $q = "UPDATE ". AGILE_DB_PREFIX ."session SET logged='0' + WHERE id = '" . SESS . "' AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + + # delete any session caches! + $q = 'DELETE FROM '.AGILE_DB_PREFIX.'session_auth_cache WHERE + session_id = '. $db->qstr(SESS) .' AND + site_id = '. $db->qstr(DEFAULT_SITE); + $db->Execute($q); + + # logout success: + $C_debug->alert($C_translate->translate('logout_success','','')); + + #################################################################### + ### Do any db_mapping + #################################################################### + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'module WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + name = ' . $db->qstr('db_mapping') . ' AND + status = ' . $db->qstr("1"); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) { + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + $db_map->logout ( $account_id ); + } + } + + + + + function locked ($account_id) + { + if($account_id != '') + $sql = " OR account_id = '$account_id' AND "; + else + $sql = " AND "; + + # check by IP & USER + $db = &DB(); + $q = "SELECT id FROM " . AGILE_DB_PREFIX . "login_lock WHERE + ip = '" . USER_IP . "'"; + $q .= $sql; + $q .= " date_expire >= '" . time() . "' AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + $i = 0; + while (!$result->EOF) + { + $i++; + $result->MoveNext(); + } + + # return the results + if ($i > 0) + return true; + else + return false; + } + + + + function lock_check ($VAR,$status,$account_id) + { + # if this is a success, delete all login old login records.. + /* + if($status == 1) + { + # delete all login attempts for this account + # (to clean the slate after the account login lock expires) + $db = &DB(); + $q = "DELETE FROM " . AGILE_DB_PREFIX . "login_log WHERE + account_id = '$account_id' AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + } + */ + + # create the appropriate login attempt record. + $db = &DB(); + $login_id = $db->GenID(AGILE_DB_PREFIX . 'login_log_id'); + $q = "INSERT INTO " . AGILE_DB_PREFIX . "login_log SET + id = " . $db->qstr($login_id) . ", + ip = " . $db->qstr( USER_IP ) . ", + account_id = " . $db->qstr($account_id ) . ", + date_orig = " . $db->qstr(time()) . ", + status = " . $db->qstr($status ) . ", + site_id = " . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + + # if this is a successfull login, we can now exit... + if($status == 1) return; + + # determine the time period to check for login attempts after: + $date_orig = (time() - (LOGIN_ATTEMPT_TIME*60)); + + # check the database for all the failed login attempts from + # this IP withing the time period defined in the setup. + $q = "SELECT id FROM " . AGILE_DB_PREFIX . "login_log WHERE + ip = '" . USER_IP . "' AND + date_orig >= '$date_orig' AND + status = '0' AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + $i = 0; + while (!$result->EOF) + { + $i++; + $result->MoveNext(); + } + + + # check that it does not exceed the allowed failed login attempts + if($i >= LOGIN_ATTEMPT_TRY) + { + # get the time this login block will expire: + $date_expire = (time() + (LOGIN_ATTEMPT_LOCK * 60)); + + # delete all old blocks for this ip + $q = "DELETE FROM " . AGILE_DB_PREFIX . "login_lock WHERE + ip = '" . USER_IP . "' AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + # create a block on this login + $q = "INSERT INTO " . AGILE_DB_PREFIX . "login_lock SET + ip = '" . USER_IP . "', + date_orig = '".time()."', + date_expire = '$date_expire', + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + # delete all login attempts for this account + # (to clean the slate after the account login lock expires) + $q = "DELETE FROM " . AGILE_DB_PREFIX . "login_log WHERE + ip = '" . USER_IP . "' AND + status = '0' AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + } + } +} +?> \ No newline at end of file diff --git a/modules/core/method.inc.php b/modules/core/method.inc.php new file mode 100644 index 00000000..b40f6a2a --- /dev/null +++ b/modules/core/method.inc.php @@ -0,0 +1,193 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_method +{ + function do_all() + { + global $C_auth, $C_sess, $C_debug, $C_translate, $VAR; + if(empty($VAR['do'])) return; + + for($i=0; $i < count($VAR['do']); $i++) + { + if(!empty($VAR['do'][$i])) + { + if(ereg(":", $VAR['do'][$i])) + { + $identifier = explode(':',$VAR['do'][$i]); + $module = $identifier[0]; + $method = strtolower($identifier[1]); + $C_translate->value['core']['module_name'] = ''. $module.":".$method . ''; + if ( + $module != '' && + $method != '' && + gettype($module) == 'string' && + gettype($method) == 'string' + ) + { + if($C_auth->auth_method_by_name($module,$method)) + { + if (file_exists(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php')) + { + include_once(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php'); + if(class_exists($module)) + { + $eval = '$' . $module . ' = new ' . $module . '(); '; + $eval .= '$this_Obj = $' . $module . ';'; + $eval .= '$this_Obj->' . $method . '($VAR,$this_Obj);'; + eval ($eval); + #call_user_func (array($module, "$method"), $VAR, $this_Obj); + } + else + { + $C_debug->alert($C_translate->translate('method_non_existant','core','')); + } + } + else + { + $C_debug->alert($C_translate->translate('module_non_existant','core','')); + } + } + else + { + $C_debug->alert($C_translate->translate('module_non_auth','core','')); + } + } + else + { + $C_debug->alert($C_translate->translate('method_invalid','core','')); + } + } + else + { + $C_debug->alert($C_translate->translate('method_invalid','core','')); + } + } + } + } + + + function exe($module,$method) + { + global $C_auth, $C_sess, $C_debug, $C_translate, $VAR; + $C_translate->value['core']['module_name'] = $module.":".$method; + if ( + $module != '' && + $method != '' && + gettype($module) == 'string' && + gettype($method) == 'string' + ) + { + if($C_auth->auth_method_by_name($module,$method)) + { + if (file_exists(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php')) + { + include_once(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php'); + if(class_exists($module)) + { + $eval = '$' . $module . ' = new ' . $module . '; '; + $eval .= '$this_Obj = $' . $module . ';'; + $eval .= '$this_Obj->' . $method . '($VAR,$this_Obj);'; + eval ($eval); + #call_user_func (array($module, "$method"), $VAR, $this_Obj); + global $smarty; + $smarty->assign_by_ref("return", $account); + $this->result = TRUE; + $this->error = FALSE; + } + else + { + $this->result = FALSE; + $this->error = $C_translate->translate('method_non_existant','core',''); + return; + } + } + else + { + $this->result = FALSE; + $this->error = $C_translate->translate('module_non_existant','core',''); + return; + } + } + else + { + $this->result = FALSE; + $this->error = $C_translate->translate('module_non_auth','core',''); + return; + } + } + else + { + $this->result = FALSE; + $this->error = $C_translate->translate('method_invalid','core',''); + return; + } + } + + + + function exe_noauth($module,$method) + { + global $C_auth, $C_sess, $C_debug, $C_translate, $VAR; + if ( + $module != '' && + $method != '' && + gettype($module) == 'string' && + gettype($method) == 'string' + ) + { + if (file_exists(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php')) + { + include_once(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php'); + if(class_exists($module)) + { + $eval = '$' . $module . ' = new ' . $module . '; '; + $eval .= '$this_Obj = $' . $module . ';'; + $eval .= '$this_Obj->' . $method . '($VAR,$this_Obj);'; + eval ($eval); + #call_user_func (array($module, "$method"), $VAR, $this_Obj); + global $smarty; + $smarty->assign_by_ref("return", $account); + $this->result = TRUE; + $this->error = FALSE; + } + else + { + $this->result = FALSE; + $this->error = $C_translate->translate('method_non_existant','',''); + return; + } + } + else + { + $this->result = FALSE; + $this->error = $C_translate->translate('module_non_existant','',''); + return; + } + } + else + { + $this->result = FALSE; + $this->error = $C_translate->translate('method_invalid','',''); + return; + } + } +} +?> \ No newline at end of file diff --git a/modules/core/method_ajax.inc.php b/modules/core/method_ajax.inc.php new file mode 100644 index 00000000..48f09f0e --- /dev/null +++ b/modules/core/method_ajax.inc.php @@ -0,0 +1,84 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_method +{ + function do_all() + { + global $C_auth, $C_sess, $C_debug, $C_translate, $VAR; + if(empty($VAR['do'])) return; + + for($i=0; $i < count($VAR['do']); $i++) + { + if(!empty($VAR['do'][$i])) + { + if(ereg(":", $VAR['do'][$i])) + { + $identifier = explode(':',$VAR['do'][$i]); + $module = $identifier[0]; + $method = strtolower($identifier[1]); + if ( + $module != '' && + $method != '' && + gettype($module) == 'string' && + gettype($method) == 'string' + ) + { + if($C_auth->auth_method_by_name($module,$method)) + { + if (file_exists(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php')) + { + include_once(PATH_MODULES . '/' . $module . '/' . $module . '.inc.php'); + if(class_exists($module)) + { + $eval = '$' . $module . ' = new ' . $module . '(); '; + $eval .= '$this_Obj = $' . $module . ';'; + $eval .= '$this_Obj->' . $method . '($VAR,$this_Obj);'; + eval ($eval); + } + else + { + echo 'method_non_existant'; + } + } + else + { + echo 'module_non_existant'; + } + } + else + { + echo 'Logged Out or Non-authorized'; + } + } + else + { + echo 'method_invalid'; + } + } + else + { + echo 'method_invalid'; + } + } + } + } +} +?> \ No newline at end of file diff --git a/modules/core/post.inc.php b/modules/core/post.inc.php new file mode 100644 index 00000000..0c0c2804 --- /dev/null +++ b/modules/core/post.inc.php @@ -0,0 +1,67 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/* + * include_once(PATH_CORE.'post.inc.php'); + * $post = new CORE_post; + * $result = $post->post_data($host, $url, $data); + */ +class CORE_post +{ + // post data and return reply + function post_data ($host, $url, $data, $port=80) + { + if (strlen($host)<1) return false; + if (strlen($url)<1) return false; + if ((!is_array($data)) || sizeof($data)<1) return false; + + $fp = @fsockopen ($host, $port, $errno, $errstr, 120); + $ret = ""; + @$req = substr ($url, $p); + + if ($fp) { + fputs ($fp, "POST $req HTTP/1.0\n"); + $this->post_send_headers ($fp); + fputs ($fp, "Content-type: application/x-www-form-urlencoded\n"); + $out = ""; + while (list ($k, $v) = each ($data)) { + if(strlen($out) != 0) $out .= "&"; + $out .= rawurlencode($k). "=" .rawurlencode($v); + } + $out = trim ($out); + fputs ($fp, "Content-length: ".strlen($out)."\n\n"); + fputs ($fp, "$out"); + fputs ($fp, "\n"); + while(!feof($fp)) + $ret .= fgets($fp,128); + fclose ($fp); + } + return $ret; + } + + // send out "browser" headers + function post_send_headers ($fp) { + fputs ($fp, "Accept: */*\n"); + fputs ($fp, "Accept-Language: en\n"); + fputs ($fp, "Connection: Keep-Alive\n"); + fputs ($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)\n"); + } +} +?> \ No newline at end of file diff --git a/modules/core/search.inc.php b/modules/core/search.inc.php new file mode 100644 index 00000000..c64d91bb --- /dev/null +++ b/modules/core/search.inc.php @@ -0,0 +1,653 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_search +{ + + var $recent_js; + var $recent_menu; + var $saved_js; + var $saved_menu; + + + + /** + * Create a new search record. + * + * @return void + * @since Version 1.0 + * @param array Contains the elements of the search query + */ + + function add($arr) + { + $db = &DB(); + # determine the search id: + $this->id = $db->GenID(AGILE_DB_PREFIX . 'search_id'); + + # safely store the SQL Query: + $sql = $db->qstr($arr['sql']); + + + # set the time when this record expires + $date_expire = (time() + (SEARCH_EXPIRE*60)); + + # create the search record + $q = "INSERT INTO " . AGILE_DB_PREFIX . "search SET + id = '" . $this->id . "', + site_id = '" . DEFAULT_SITE . "', + session_id = '" . SESS . "', + account_id = '" . SESS_ACCOUNT . "', + module = '" . $arr['module'] . "', + date_orig = '" . time() . "', + date_expire = '" . $date_expire . "', + full_sql = $sql, + order_by = '" . $arr['order_by'] . "', + limit_no = '" . $arr['limit'] . "', + results = '" . $arr['results'] . "'"; + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('search.inc.php','add', $db->ErrorMsg()); + } + } + + + /** + * Retrieves a specific search record, and sets the values to the object. + * + * @return void + * @since Version 1.0 + * @todo Complete the search refresh feature + * @param int Contians the Search Id to be retrieved + */ + + function get($id) + { + # get the details for this search + $db = &DB(); + $q = "SELECT * + FROM " . AGILE_DB_PREFIX . "search + WHERE + id = '" . $id . "' + AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('search.inc.php','get', $db->ErrorMsg()); + } + + # get the search values + $this->id = $id; + $this->account = $result->fields['account_id']; + $this->session = $result->fields['session_id']; + $this->date_orig = $result->fields['date_orig']; + $this->date_expire = $result->fields['date_expire']; + $this->sql = $result->fields['full_sql']; + $this->order_by = $result->fields['order_by']; + $this->limit = $result->fields['limit_no']; + + + # check if this search has expired: + if($this->date_expire <= time()) + { + # refresh the search + # $this->results = $this->refresh($id); + # echo "
this search has expired! Refreshing....
"; + $this->results = $result->fields['results']; + } + else + { + # use the existing result count + $this->results = $result->fields['results']; + } + return; + } + + + /** + * Refreshes the result count of a specific search and stores the new results in the search record, + * and returns the new search result count. + * + * @return int Contains the new search results count + * @since Version 1.0 + * @todo Complete the search refresh code + * @param int Contians the Search Id to be refreshed + * @return int The new search results count + */ + + function refresh($id) + { + + } + + + + /** + * Saves the current search for later retreival. + * + * @return void + * @since Version 1.0 + * @todo Add some error checking for previously used nicknames, identical searches, etc. + * @param int Contians the Search Id to be saved + * @param string Contains the name of the Module this search was for + * @param string Contains search nickname to remember this search as + */ + + function save($search_id,$module,$name) + { + # save the search + $db = &DB(); + + # determine the search id: + $this->id = $db->GenID('search_saved'); + + $n = $db->qstr($name); + + # generate the insert statement + $q = "INSERT INTO " . AGILE_DB_PREFIX . "search_saved SET + id = '$this->id', + site_id = '" . DEFAULT_SITE . "', + search_id = '$search_id', + account_id = '" . SESS_ACCOUNT . "', + session_id = '" . SESS . "', + date_orig = '" . time() . "', + date_last = '" . time() . "', + date_expire = '', + module = '$module', + name = $n"; + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('search.inc.php','refresh', $db->ErrorMsg()); + } + } + + + + /** + * Build the recent search menu and JavaScript + * + * @return void + * @since Version 1.0 + * @param string Contains the name of the Module to find recent searches for + */ + + function build_recent($module) + { + # disable for now + return 0; + + if(isset($this->arr)) unset ($this->arr); + + # get the recent searches + $db = &DB(); + $q = "SELECT id, date_orig, date_expire, full_sql, order_by, limit_no + FROM " . AGILE_DB_PREFIX . "search + WHERE + session_id = '" . SESS . "' + OR + account_id = '" . SESS_ACCOUNT . "' + AND + module = '$module' + AND + date_expire >= '" . time() . "' + AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('search.inc.php','build_recent', $db->ErrorMsg()); + } + + $results = $result->RecordCount(); + + + $i = 0; + while (!$result->EOF) { + # get the fields for this loop + $sql = $result->fields['full_sql']; + + # remove the WHERE + $sql = trim($sql); + $sql = eregi_replace("WHERE","",$sql); + $sql = eregi_replace("AND$","",$sql); + $sql = trim($sql); + + # replace any sql statements before we split the string + $sql = ereg_replace(" = ","===",$sql); + $sql = ereg_replace(" LIKE ","===",$sql); + + + # determine the number of fields + + $ii=0; + if(ereg(" AND ", $sql)) + { + $sql = split(" AND ",$sql); + $this_fields = count($sql); + + # loop + for($count=0; $count < $this_fields; $count++) + { + # do each field + $sqls = split("==",$sql[$count]); + $field[$count][name] = $sqls[0]; + $field[$count][value] = ereg_replace("'","",$sqls[1]); + $field[$count][value] = ereg_replace("=","",$field[$count][value]); + + # check that the name & value are both set... + if($field[$count][value] != '' && $field[$count][name] != '') + { + if(!isset($this->arr[$i][$ii][limit])) + { + $this->arr[$i][$ii][search] = $result->fields['id']; + $this->arr[$i][$ii][limit] = $result->fields['limit_no']; + $this->arr[$i][$ii][order] = $result->fields['order_by']; + } + + $this->arr[$i][$ii][0] = $field[$count][name]; + $this->arr[$i][$ii][1] = $field[$count][value]; + + # echo "

Field/Name: " . $this->arr[$i][$ii][0] . " -> " . $this->arr[$i][$ii][1]; + $ii++; + + # set the menu up for Smarty + $this->recent_menu[$i] = $result->fields; + } + } + } + else + { + # field count + $this_fields = 1; + + # do this one field + $sqls = split("==",$sql); + $field[name] = $sqls[0]; + $field[value] = ereg_replace("'","",$sqls[1]); + $field[value] = ereg_replace("=","",$field[value]); + + # check that the name & value are both set... + if($field[value] != '' && $field[name] != '') + { + if(!isset($this->arr[$i][$ii][limit])) + { + $this->arr[$i][$ii][search] = $result->fields['id']; + $this->arr[$i][$ii][limit] = $result->fields['limit_no']; + $this->arr[$i][$ii][order] = $result->fields['order_by']; + } + + $this->arr[$i][$ii][0] = $field[name]; + $this->arr[$i][$ii][1] = $field[value]; + + # echo "

Field/Name: " . $field[name] . " -> " . $field[value]; + $ii++; + + # set the menu up for Smarty + $this->recent_menu[$i] = $result->fields; + } + + } + + + # continue loop + $result->MoveNext(); + if ($ii > 0) $i++; + } + + # finish the JS: + if($i > 0 && $ii > 0) + { + # build the JavaScript + $this->recent_js = ' + + "; + } + else + { + $this->recent_js = FALSE; + } + } # end of functino + + + + + /** + * Build the saved search menu and JavaScript + * + * @return void + * @since Version 1.0 + * @param string Contains the name of the Module to find saved searches for + */ + + function build_saved($module) + { + # disable for now + return 0; + + if(isset($this->arr)) unset ($this->arr); + + # get the saved searches + # get the recent searches + $db1 = &DB(); + $q = "SELECT id, search_id, name + FROM " . AGILE_DB_PREFIX . "search_saved + WHERE + session_id = '" . SESS . "' + OR + account_id = '" . SESS_ACCOUNT . "' + AND + module = '$module' + AND + site_id = '" . DEFAULT_SITE . "' + ORDER BY name ASC"; + $result1 = $db1->Execute($q); + + # error reporting + if ($result1 === false) + { + global $C_debug; + $C_debug->sql_error($db1->ErrorMsg()); + } + + $i=0; + while (!$result1->EOF) + { + # get the information for this search + $db = &DB(); + $q = "SELECT id, full_sql, order_by, limit_no + FROM " . AGILE_DB_PREFIX . "search + WHERE + id = '" . $result1->fields['search_id'] . "' + AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('search.inc.php','build_saved', $db->ErrorMsg()); + } + + # get the fields for this loop + $sql = $result->fields['full_sql']; + + # remove the WHERE + $sql = trim($sql); + $sql = eregi_replace("WHERE","",$sql); + $sql = eregi_replace("AND$","",$sql); + $sql = trim($sql); + + # replace any sql statements before we split the string + $sql = ereg_replace(" = ","===",$sql); + $sql = ereg_replace(" LIKE ","===",$sql); + + + # determine the number of fields + + $ii=0; + if(ereg(" AND ", $sql)) + { + $sql = split(" AND ",$sql); + $this_fields = count($sql); + + # loop + for($count=0; $count < $this_fields; $count++) + { + # do each field + $sqls = split("==",$sql[$count]); + $field[$count][name] = $sqls[0]; + $field[$count][value] = ereg_replace("'","",$sqls[1]); + $field[$count][value] = ereg_replace("=","",$field[$count][value]); + + # check that the name & value are both set... + if($field[$count][value] != '' && $field[$count][name] != '') + { + if(!isset($this->arr[$i][$ii][limit])) + { + $this->arr[$i][$ii][search] = $result->fields['id']; + $this->arr[$i][$ii][limit] = $result->fields['limit_no']; + $this->arr[$i][$ii][order] = $result->fields['order_by']; + } + + $this->arr[$i][$ii][0] = $field[$count][name]; + $this->arr[$i][$ii][1] = $field[$count][value]; + + # echo "

Field/Name: " . $this->arr[$i][$ii][0] . " -> " . $this->arr[$i][$ii][1]; + $ii++; + $this->saved_menu[$i] = $result->fields; + $this->saved_menu[$i]["name"] = $result1->fields["name"]; + } + } + } + else + { + # field count + $this_fields = 1; + + # do this one field + $sqls = split("==",$sql); + $field[name] = $sqls[0]; + $field[value] = ereg_replace("'","",$sqls[1]); + $field[value] = ereg_replace("=","",$field[value]); + + # check that the name & value are both set... + if($field[value] != '' && $field[name] != '') + { + if(!isset($this->arr[$i][$ii][limit])) + { + $this->arr[$i][$ii][search] = $result->fields['id']; + $this->arr[$i][$ii][limit] = $result->fields['limit_no']; + $this->arr[$i][$ii][order] = $result->fields['order_by']; + } + + $this->arr[$i][$ii][0] = $field[name]; + $this->arr[$i][$ii][1] = $field[value]; + + # echo "

Field/Name: " . $field[name] . " -> " . $field[value]; + $ii++; + + # set the menu up for Smarty + $this->saved_menu[$i] = $result->fields; + $this->saved_menu[$i]["name"] = $result1->fields["name"]; + } + + } + $result1->MoveNext(); + if ($ii > 0) $i++; + } + + + + + # finish the JS: + if($i > 0 && $ii > 0) + { + # build the JavaScript + $this->saved_js = ' + + "; + } + else + { + $this->saved_js = FALSE; + } + } +} +?> \ No newline at end of file diff --git a/modules/core/service_domain.inc.php b/modules/core/service_domain.inc.php new file mode 100644 index 00000000..832c05f1 --- /dev/null +++ b/modules/core/service_domain.inc.php @@ -0,0 +1,83 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class service_domain +{ + # Set variables + function service_domain ( $rs ) { + $this->domain = $rs; + } + + + ######################################################## + # Do domain registration, transfer, park, or renewal ## + ######################################################## + + function s_new() + { + # Get the registrar plugin data + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."host_registrar_plugin WHERE + id = ".$db->qstr( $this->domain['host_server_id'] )." AND + site_id = ".$db->qstr(DEFAULT_SITE);; + $rs = $db->Execute($q); + if ($rs != false && $rs->RecordCount() == 1) { + $this->server = $rs->fields; + } + + # Get the registrar plugin data + $q = "SELECT * FROM ".AGILE_DB_PREFIX."host_registrar_plugin WHERE + id = ".$db->qstr( $this->domain['domain_host_registrar_id'] )." AND + site_id = ".$db->qstr(DEFAULT_SITE);; + $rs = $db->Execute($q); + if ($rs === false || $rs->RecordCount() == 0) { + return false; + } else { + # Load the plugin class + $this->registrar = unserialize( $rs->fields['plugin_data'] ); + $filename = PATH_PLUGINS.'registrar/'.$rs->fields['file'].'.php'; + if(!file_exists($filename)) return false; + include_once($filename); + $eval = '$_PLG = new plg_reg_'.$rs->fields['file'].'($this);'; + eval($eval); + } + + switch ( $this->domain['domain_type'] ) + { + case 'register': + return $_PLG->register(); + break; + + case 'transfer': + return $_PLG->transfer(); + break; + + case 'park': + return $_PLG->park(); + break; + + case 'renew': + return $_PLG->renew(); + break; + } + return false; + } +} +?> \ No newline at end of file diff --git a/modules/core/service_group.inc.php b/modules/core/service_group.inc.php new file mode 100644 index 00000000..5e78700d --- /dev/null +++ b/modules/core/service_group.inc.php @@ -0,0 +1,268 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class service_group +{ + # Set variables + function service_group ( $rs, $groups ) { + $this->rs = $rs; + $this->groups = $groups; + } + + + ############################################### + # Add new groups + ############################################### + + function s_new() + { + # Loop through each group to add: + for($i=0; $igroups); $i++) + { + # Determine the expiry date: + $this->calcExpiry(); + + # Create the new group + $this->addGroup( $this->groups[$i] ); + } + } + + + ############################################### + # Activate groups + ############################################### + + function s_active() + { + # Loop through each group to add: + for($i=0; $igroups); $i++) + { + # Determine the expiry date: + $this->calcExpiry(); + + # Create the new group + $this->addGroup( $this->groups[$i] ); + } + } + + ############################################### + # Deactivate groups + ############################################### + + function s_inactive() + { + # Loop through each group to add: + for($i=0; $igroups); $i++) + { + # Create the new group + $this->deleteGroup( $this->groups[$i] ); + } + } + + ############################################### + # Delete Groups + ############################################### + + function s_delete() + { + # Loop through each group to add: + for($i=0; $igroups); $i++) + { + # Create the new group + $this->deleteGroup( $this->groups[$i] ); + } + } + + + function s_edit() { + return; + } + + + + ######################################################################################################## + # MISC METHODS + ######################################################################################################## + + + + # Add new group to account + function addGroup($id) + { + # Delete any existing groups for this service & account + $db = &DB(); + $q = "DELETE FROM ".AGILE_DB_PREFIX."account_group WHERE + account_id = ".$db->qstr($this->rs['account_id'])." AND + group_id = ".$db->qstr($id)." AND + service_id = ".$db->qstr($this->rs['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + + # Create the new group: + $idx = $db->GenID(AGILE_DB_PREFIX . 'account_group_id'); + $q = "INSERT INTO ".AGILE_DB_PREFIX."account_group SET + id = ".$db->qstr( $idx ).", + site_id = ".$db->qstr( DEFAULT_SITE ).", + date_orig = ".$db->qstr( time() ).", + date_expire = ".$db->qstr( $this->expire ).", + group_id = ".$db->qstr( $id ).", + account_id = ".$db->qstr( $this->rs['account_id'] ).", + service_id = ".$db->qstr( $this->rs['id'] ).", + active = ".$db->qstr( '1' ); + $rs1 = $db->Execute($q); + if ($rs1 === false) { + global $C_debug; + $C_debug->error('service_group.inc.php','addGroup', $db->ErrorMsg()); + } + + # update session cache + if(defined('SESS_ACCOUNT') && SESS_ACCOUNT == $this->rs['account_id'] && SESS_LOGGED == 1) + { + if(CACHE_SESSIONS == '1') { + $force = true; + $C_auth = new CORE_auth($force); + global $C_auth2; + $C_auth2 = $C_auth; + } + } + elseif (!defined('SESS_ACCOUNT') || SESS_ACCOUNT != $this->rs['account_id']) + { + # delete the users_session_auth so it is reloaded on their next page view: + $q = "SELECT id FROM ".AGILE_DB_PREFIX."session WHERE + account_id = ".$db->qstr($this->rs['account_id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $rss = $db->Execute($q); + while(!$rss->EOF) + { + $q = "DELETE FROM ".AGILE_DB_PREFIX."session_auth_cache WHERE + session_id = ".$db->qstr($rss->fields['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + $rss->MoveNext(); + } + } + + # Call the dbmap: + $this->dbmap(); + } + + + + # Delete/suspend groups + function deleteGroup($id) + { + # Delete any existing groups for this service & account + $db = &DB(); + $q = "DELETE FROM ".AGILE_DB_PREFIX."account_group WHERE + account_id = ".$db->qstr($this->rs['account_id'])." AND + group_id = ".$db->qstr($id)." AND + service_id = ".$db->qstr($this->rs['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + + # update session cache + if(SESS_ACCOUNT == $this->rs['account_id'] && SESS_LOGGED == 1) + { + if(CACHE_SESSIONS == '1') { + $force = true; + $C_auth = new CORE_auth($force); + global $C_auth2; + $C_auth2 = $C_auth; + } + } + elseif (SESS_ACCOUNT != $this->rs['account_id']) + { + # delete the users_session_auth so it is reloaded on their next page view: + $q = "SELECT id FROM ".AGILE_DB_PREFIX."session WHERE + account_id = ".$db->qstr($this->rs['account_id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $rss = $db->Execute($q); + while(!$rss->EOF) + { + $q = "DELETE FROM ".AGILE_DB_PREFIX."session_auth_cache WHERE + session_id = ".$db->qstr($rss->fields['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + $rss->MoveNext(); + } + } + + # Call the dbmap: + $this->dbmap(); + } + + + # Calculate the expiry date for adding/activating groups: + function calcExpiry() + { + if ($this->rs['group_type'] == 0) { + $this->expire = $this->rs['date_orig'] + (86400*$this->rs['group_days']); + } else { + $this->expire = false; + } + } + + + # Force new login by deleting user's session/session_auth_cache records: + function forceLogin() + { + $db = &DB(); + $q = "SELECT id FROM ".AGILE_DB_PREFIX."session WHERE + account_id = ".$db->qstr( $this->rs['account_id'] )." AND + site_id = ".$db->qstr(DEFAULT_SITE);; + $rs = $db->Execute($q); + if ($rs->RecordCount() > 0) + { + $q = "DELETE FROM ".AGILE_DB_PREFIX."session WHERE + id = ".$db->qstr($rs->fields['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + + $q = "DELETE FROM ".AGILE_DB_PREFIX."sess_auth_cache WHERE + session_id = ".$db->qstr($rs->fields['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $db->Execute($q); + } + + # Call the dbmap: + $this->dbmap(); + } + + + + # Call the db_mapping update + function dbmap() + { + global $C_list; + if(!is_object($C_list)) { + include_once(PATH_CORE . 'list.inc.php'); + $C_list = new CORE_list; + } + + if($C_list->is_installed('db_mapping')) + { + # Update the db_mapping accounts + include_once ( PATH_MODULES . 'db_mapping/db_mapping.inc.php' ); + $db_map = new db_mapping; + $db_map->account_group_sync ( $this->rs['account_id'] ); + } + } +} +?> \ No newline at end of file diff --git a/modules/core/session.inc.php b/modules/core/session.inc.php new file mode 100644 index 00000000..ec3d64c5 --- /dev/null +++ b/modules/core/session.inc.php @@ -0,0 +1,413 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_session +{ + var $id; + + function CORE_session() + { + global $C_debug, $_GET, $_POST,$_COOKIE, $HTTP_COOKIE_VARS, $VAR; + + if (isset($_GET['s'])) + $session_arr[] = $_GET['s']; + else if (isset($_POST['s'])) + $session_arr[] = $_POST['s']; + else if(isset($_COOKIE[COOKIE_NAME])) + $session_arr[] = $_COOKIE[COOKIE_NAME]; + else if (isset($HTTP_COOKIE_VARS[COOKIE_NAME])) + $session_arr[] = $HTTP_COOKIE_VARS[COOKIE_NAME]; + + if(isset($session_arr)) { + for($i=0; $ivalidate($session_arr[$i]); + if($validate != FALSE) { + $this->id = $session_arr[$i]; + $i = count($session_arr); + } + } + } + } + + @$this->sess_date_expire = time() + (SESSION_EXPIRE*60); + if(!isset($this->id)) + { + empty($VAR['tid']) ? $this->sess_theme_id = DEFAULT_THEME : $this->sess_theme_id = $VAR['tid']; + empty($VAR['lid']) ? $this->sess_language_id = DEFAULT_LANGUAGE : $this->sess_language_id = $VAR['lid']; + empty($VAR['cid']) ? $this->sess_country_id = DEFAULT_COUNTRY : $this->sess_country_id = $VAR['cid']; + empty($VAR['cyid']) ? $this->sess_currency_id = DEFAULT_CURRENCY : $this->sess_currency_id = $this->get_currency($VAR['cyid']); + empty($VAR['wid']) ? $this->sess_weight_id = DEFAULT_WEIGHT : $this->sess_weight_id = $VAR['wid']; + @$this->sess_reseller_id = $VAR['rid']; + @$this->sess_affiliate_id = $this->get_affiliate(0); + @$this->sess_campaign_id = $this->get_campaign(0); + $this->sess_logged = false; + $this->sess_account_id = false; + $this->session(); + } + else + { + empty($VAR['tid']) ? $this->sess_theme_id = $validate['theme_id'] : $this->sess_theme_id = $VAR['tid']; + empty($VAR['lid']) ? $this->sess_language_id = $validate['language_id'] : $this->sess_language_id = $VAR['lid']; + empty($VAR['cid']) ? $this->sess_country_id = $validate['country_id'] : $this->sess_country_id = $VAR['cid']; + empty($VAR['cyid']) ? $this->sess_currency_id = $validate['currency_id'] : $this->sess_currency_id = $this->get_currency($VAR['cyid']); + empty($VAR['wid']) ? $this->sess_weight_id = $validate['weight_id'] : $this->sess_weight_id = $VAR['wid']; + empty($VAR['rid']) ? $this->sess_reseller_id = $validate['reseller_id'] : $this->sess_reseller_id = $VAR['rid']; + empty($VAR['aid']) ? $this->sess_affiliate_id = $validate['affiliate_id'] : $this->sess_affiliate_id = $this->get_affiliate($validate['affiliate_id']); + empty($VAR['caid']) ? $this->sess_campaign_id = $validate['campaign_id'] : $this->sess_campaign_id = $this->get_campaign($validate['campaign_id']); + + $this->sess_account_id = $validate['account_id']; + $this->sess_logged = $validate['logged']; + + $db = &DB(); + $q = "UPDATE " . AGILE_DB_PREFIX . "session SET + date_last = " . $db->qstr(time()) . ", + date_expire = " . $db->qstr($this->sess_date_expire) . ", + ip = " . $db->qstr(USER_IP) . ", + theme_id = " . $db->qstr($this->sess_theme_id) . ", + country_id = " . $db->qstr($this->sess_country_id) . ", + language_id = " . $db->qstr($this->sess_language_id) . ", + currency_id = " . $db->qstr($this->sess_currency_id) . ", + weight_id = " . $db->qstr($this->sess_weight_id) . ", + reseller_id = " . $db->qstr($this->sess_reseller_id) . ", + affiliate_id = " . $db->qstr($this->sess_affiliate_id). ", + campaign_id = " . $db->qstr($this->sess_campaign_id) . " + WHERE + id = " . $db->qstr($this->id) . " + AND + site_id = " . $db->qstr(DEFAULT_SITE); + + // update the old session ONLY if info has changed or expires/no update in the past 5 minutes. + if (!empty($VAR['tid']) || !empty($VAR['lid']) || !empty($VAR['cid']) || !empty($VAR['cyid']) || + !empty($VAR['wid']) || !empty($VAR['rid']) || !empty($VAR['aid']) || !empty($VAR['caid']) ) { + $result = $db->Execute($q); + } else if ($validate['logged'] == '0' && !empty($this->sess_date_expire) && $this->sess_date_expire+60*5 < time()) { + $result = $db->Execute($q); + } else if (!empty($validate['date_last']) && $validate['date_last']+60*5 < time()) { + $result = $db->Execute($q); + } + } + + if(!defined("SESS")) define ('SESS', $this->id); + $this->setcookies(); + } + + + function validate($session_id) { + global $C_debug; + $db = &DB(); + $q = "SELECT + " . AGILE_DB_PREFIX . "session.*, + " . AGILE_DB_PREFIX . "account.id AS acct_id, + " . AGILE_DB_PREFIX . "account.status, + " . AGILE_DB_PREFIX . "account.date_expire AS account_date_expire, + " . AGILE_DB_PREFIX . "session_auth_cache.date_expire AS sess_auth_date_expire, + " . AGILE_DB_PREFIX . "session_auth_cache.group_arr, + " . AGILE_DB_PREFIX . "session_auth_cache.module_arr + FROM + " . AGILE_DB_PREFIX . "session + LEFT JOIN " . AGILE_DB_PREFIX . "account ON ".AGILE_DB_PREFIX."account.id = ".AGILE_DB_PREFIX."session.account_id + LEFT JOIN " . AGILE_DB_PREFIX . "session_auth_cache ON " . AGILE_DB_PREFIX . "session.id = " . AGILE_DB_PREFIX . "session_auth_cache.session_id + WHERE + " . AGILE_DB_PREFIX . "session.id = " . $db->qstr($session_id) . " + AND + " . AGILE_DB_PREFIX . "session.site_id = " . $db->qstr(DEFAULT_SITE) . " + AND + " . AGILE_DB_PREFIX . "account.site_id = " . $db->qstr(DEFAULT_SITE) . " + AND + " . AGILE_DB_PREFIX . "session_auth_cache.site_id = " . $db->qstr(DEFAULT_SITE); + + $result = $db->Execute($q); + if ($result === false) { + $C_debug->error('session.inc.php','validate', $db->ErrorMsg()); + echo '
Unable to start session: Database Error: ' . $db->ErrorMsg(); + return; + } else if ($result->RecordCount() == 0) { + return FALSE; + } + + // Set the auth caching for use in the auth module to save a query there: + $this->auth_cache['date_expire'] = $result->fields["sess_auth_date_expire"]; + $this->auth_cache['group_arr'] = $result->fields["group_arr"]; + $this->auth_cache['module_arr'] = $result->fields["module_arr"]; + + if($result->fields['id'] == $session_id) { + if($result->fields["logged"] == "1") { + if($result->fields['status'] != "1") { + return FALSE; + } else if(!empty($result->fields['account_date_expire']) && $result->fields['account_date_expire'] < time()) { + return FALSE; + } else if(SESSION_EXPIRE != 0 && $result->fields['date_expire'] <= time()) { + $this->logout($session_id); + return FALSE; + } + } + + if(SESSION_IP_MATCH) { + if($result->fields['ip'] != USER_IP) { + $this->delete($session_id); + return FALSE; + } + } + + } else { + return FALSE; + } + + return $result->fields; + } + + + function setcookies() { + + if(defined("AGILE_COOKIE") && AGILE_COOKIE != '') { + $domain = AGILE_COOKIE; + } else { + global $_SERVER; + if(isset($_SERVER)) { + @$domain = $_SERVER['HTTP_HOST']; + } else { + $server = getallheaders(); + $domain = $server['Host']; + } + $domain = '.'.eregi_replace('^www.', '', $domain); + } + + if(COOKIE_EXPIRE == 0 ) + $cookie_expire = (time() + 86400*365); + else + $cookie_expire = (time() + (COOKIE_EXPIRE*60)); + if(empty($domain) || eregi('localhost', $domain)) + setcookie(COOKIE_NAME,$this->id,$cookie_expire,'/'); + else + setcookie(COOKIE_NAME,$this->id,$cookie_expire,'/', $domain); + + # Affiliate Cookie + if(!empty($this->sess_affiliate_id)) { + $aid_expire = time()+86400*720; + $aid_cookie_name = COOKIE_NAME . 'aid'; + if(empty($domain) || eregi('localhost', $domain)) + setcookie($aid_cookie_name, $this->sess_affiliate_id, $aid_expire,'/'); + else + setcookie($aid_cookie_name, $this->sess_affiliate_id, $aid_expire,'/', $domain); + } + + # Campaign Cookie + if(!empty($this->sess_campaign_id)) { + $cid_expire = time()+86400*720; + $cid_cookie_name = COOKIE_NAME . 'caid'; + if(empty($domain) || eregi('localhost', $domain)) + setcookie($cid_cookie_name, $this->sess_campaign_id, $cid_expire,'/'); + else + setcookie($cid_cookie_name, $this->sess_campaign_id, $cid_expire,'/', $domain); + } + } + + + function get_affiliate($old_aid) { + global $_COOKIE, $VAR; + $aid_cookie_name = COOKIE_NAME.'aid'; + if(isset($VAR['aid'])) + $aid = $VAR['aid']; + else if(isset($_COOKIE[$aid_cookie_name])) + @$aid = $_COOKIE[$aid_cookie_name]; + else if(isset($HTTP_COOKIE_VARS[$aid_cookie_name])) + @$aid = $HTTP_COOKIE_VARS[$aid_cookie_name]; + if ($aid == $old_aid) { + return $aid; + } else if (empty($aid)) { + return ''; + } else { + // validate + $db = &DB(); + $q = "SELECT id,account_id FROM " . AGILE_DB_PREFIX . "affiliate + WHERE id = ".$db->qstr($aid)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + @$result = $db->Execute($q); + if(@$result->fields['id'] == $aid) + return $aid; + else + return ''; + } + } + + + function get_campaign($old_cid) { + global $_COOKIE, $VAR; + $cid_cookie_name = COOKIE_NAME.'caid'; + if(isset($VAR['caid'])) + $cid = $VAR['caid']; + else if(isset($_COOKIE[$cid_cookie_name])) + @$cid = $_COOKIE[$cid_cookie_name]; + else if(isset($HTTP_COOKIE_VARS[$cid_cookie_name])) + @$cid = $HTTP_COOKIE_VARS[$cid_cookie_name]; + if ($cid == $old_cid) { + return $cid; + } else if (empty($cid)) { + return ''; + } else { + // validate + $db = &DB(); + $q = "SELECT id FROM " . AGILE_DB_PREFIX . "campaign + WHERE id = ".$db->qstr($cid)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + @$result = $db->Execute($q); + if(@$result->fields['id'] == $cid) + return $cid; + else + return ''; + } + } + + + function get_currency($id) { + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'currency WHERE id = ' . $db->qstr($id) . ' AND site_id = ' . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + if($result->fields['status'] == 1) return $id; + global $VAR; $VAR['cyid'] = DEFAULT_CURRENCY; + return DEFAULT_CURRENCY; + } + + + function session() { + global $C_debug; + mt_srand ((double) microtime() * 1000000); + $this->id = md5(uniqid(mt_rand(),1)); + $db = &DB(); + $q = "SELECT id FROM " . AGILE_DB_PREFIX . "session + WHERE id = ".$db->qstr($this->id)." AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + if ($result === false) { + echo "SESSION FAILED: Unable to connect to database"; + exit; + } if($result->RecordCount() == 0) { + $expires = time() + (SESSION_EXPIRE*60); + $db = &DB(); + $q = "INSERT INTO " . AGILE_DB_PREFIX . "session SET + id = ".$db->qstr($this->id).", + date_orig = ".$db->qstr(time()).", + date_last = ".$db->qstr(time()).", + date_expire = ".$db->qstr($expires).", + logged = ".$db->qstr('0').", + ip = ".$db->qstr(USER_IP).", + site_id = ".$db->qstr(DEFAULT_SITE).", + affiliate_id= ".$db->qstr($this->sess_affiliate_id).", + reseller_id = ".$db->qstr($this->sess_reseller_id).", + country_id = ".$db->qstr($this->sess_country_id).", + language_id = ".$db->qstr($this->sess_language_id).", + currency_id = ".$db->qstr($this->sess_currency_id).", + weight_id = ".$db->qstr($this->sess_weight_id).", + theme_id = ".$db->qstr($this->sess_theme_id).", + campaign_id = ".$db->qstr($this->sess_campaign_id); + $result = $db->Execute($q); + $C_debug->sql_count(); + if ($result === false) { + $C_debug->error('session.inc.php','validate', $db->ErrorMsg()); + echo 'Unable to start session: Db error
' . $q . '

' . $db->ErrorMsg(); + exit; + } + } + } + + + function logout($sess) { + $db = &DB(); + $q = "UPDATE " . AGILE_DB_PREFIX . "session SET logged = '0' WHERE + id = '$sess' AND + site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + if ($result === false) { + global $C_debug; + $C_debug->error('session.inc.php','logout', $db->ErrorMsg()); + } + + $q = 'DELETE FROM '.AGILE_DB_PREFIX.'session_auth_cache WHERE + session_id = '. $db->qstr($sess) .' AND + site_id = '. $db->qstr(DEFAULT_SITE); + $db->Execute($q); + + define('FORCE_SESS_ACCOUNT', 0); + define('FORCE_SESS_LOGGED', FALSE); + + if(CACHE_SESSIONS == '1') { + $VAR['_login'] = '1'; + $force = true; + $C_auth = new CORE_auth($force); + global $C_auth2; + $C_auth2 = $C_auth; + } + } + + + function delete($sess) { + global $C_debug; + + $db = &DB(); + $q = "DELETE FROM " . AGILE_DB_PREFIX . "session WHERE id = '$sess' AND site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + $C_debug->sql_count(); + if ($result === false) $C_debug->error('session.inc.php','delete', $db->ErrorMsg()); + } + + + function session_constant() { + # Define the constants + define ('SESS_THEME', $this->sess_theme_id); + define ('SESS_COUNTRY', $this->sess_country_id); + define ('SESS_LANGUAGE', $this->sess_language_id); + define ('SESS_CURRENCY', $this->sess_currency_id); + define ('SESS_WEIGHT', $this->sess_weight_id); + define ('SESS_RESELLER', $this->sess_reseller_id); + define ('SESS_AFFILIATE', $this->sess_affiliate_id); + define ('SESS_CAMPAIGN', $this->sess_campaign_id); + } + + + function session_constant_log() { + global $VAR; + if(isset($VAR['_login']) || isset($VAR['_logout'])) { + $db = &DB(); + $q = "SELECT logged,account_id FROM " . AGILE_DB_PREFIX . "session + WHERE id = " . $db->qstr($this->id) . " + AND site_id = " . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + global $C_debug; + $C_debug->sql_count(); + if ($result === false) $C_debug->error('session.inc.php','session_constant', $db->ErrorMsg()); + if(!defined("SESS_LOGGED")) + define ('SESS_LOGGED', $result->fields['logged']); + if(!defined("SESS_ACCOUNT")) + define ('SESS_ACCOUNT', $result->fields['account_id']); + } else { + if(!defined("SESS_LOGGED")) + define ('SESS_LOGGED', $this->sess_logged); + if(!defined("SESS_ACCOUNT")) + define ('SESS_ACCOUNT', $this->sess_account_id); + } + + if(SESS_LOGGED) + define ('SESS_EXPIRES', $this->sess_date_expire); + else + define ('SESS_EXPIRES', 0); + } +} +?> \ No newline at end of file diff --git a/modules/core/setup.inc.php b/modules/core/setup.inc.php new file mode 100644 index 00000000..85614dab --- /dev/null +++ b/modules/core/setup.inc.php @@ -0,0 +1,169 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_setup +{ + function CORE_setup() + { + if(defined('MEMCACHE_ENABLED') && MEMCACHE_ENABLED == true) { + require_once (PATH_INCLUDES. 'cache/cache.php'); + $key = md5('keyname1'.__FILE__.DEFAULT_SITE); + $sec = 60*30; + $timeout = get_value($key.'_exp'); + if($timeout == "" || $timeout < time() || !$fields = get_value($key) ) + { + $fields = $this->get_setup(); + store_value($key, $fields); + store_value($key.'_exp', time()+$sec); + } + } else { + $fields = $this->get_setup(); + } + + define ('DEFAULT_COUNTRY', $fields['country_id']); + define ('DEFAULT_LANGUAGE', $fields['language_id']); + define ('DEFAULT_CURRENCY', $fields['currency_id']); + define ('DEFAULT_WEIGHT', $fields['weight_id']); + define ('DEFAULT_THEME', $fields['theme_id']); + define ('DEFAULT_ADMIN_THEME', $fields['admin_theme_id']); + define ('DEFAULT_GROUP', $fields['group_id']); + define ('DEFAULT_AFFILIATE_TEMPLATE', $fields['affiliate_template_id']); + define ('DEFAULT_AFFILIATE', $fields['affiliate_id']); + define ('DEFAULT_RESELLER', $fields['reseller_id']); + define ('DEFAULT_SETUP_EMAIL', $fields['setup_email_id']); + define ('DEFAULT_TIME_FORMAT', $fields['time_format']); + define ('DEFAULT_ACCOUNT_STATUS',$fields['default_account_status']); + $this->default_date_format($fields['date_format']); + if(!defined("DEFAULT_TIME_FORMAT")) + define ('DEFAULT_TIME_FORMAT', $fields['time_format']); + define ('DEFAULT_DATE_TIME_FORMAT', $fields['date_time_format']); + define ('DEFAULT_DECIMAL_PLACE',$fields['decimal_place']); + define ('COOKIE_NAME', $fields['cookie_name']); + define ('COOKIE_EXPIRE', $fields['cookie_expire']); + define ('SESSION_IP_MATCH', $fields['session_ip_match']); + define ('SESSION_EXPIRE', $fields['login_expire']); + define ('NEWSLETTER_REGISTRATION',$fields['newsletter_registration']); + define ('SEARCH_EXPIRE', $fields['search_expire']); + define ('ERROR_REPORTING', $fields['error_reporting']); + define ('DEBUG', $fields['debug']); + + define ('LOGIN_ATTEMPT_TRY', $fields['login_attempt_try']); + define ('LOGIN_ATTEMPT_TIME', $fields['login_attempt_time']); + define ('LOGIN_ATTEMPT_LOCK', $fields['login_attempt_lock']); + define ('DB_CACHE', $fields['db_cache']); + define ('CACHE_SESSIONS', $fields['cache_sessions']); + define ('WEBLOG', $fields['weblog']); + define ('LICENSE_KEY', $fields['license_key']); + define ('LICENSE_CODE', $fields['license_code']); + + if(!defined('SSL_URL')) define ('SSL_URL', $fields['ssl_url']); + if(!defined('URL')) define ('URL', $fields['nonssl_url']); + if(!defined('SITE_NAME')) define ('SITE_NAME', $fields['site_name']); + if(!defined('SITE_EMAIL')) define ('SITE_EMAIL', $fields['site_email']); + if(!defined('SITE_ADDRESS'))define ('SITE_ADDRESS',$fields['site_address']); + if(!defined('SITE_CITY')) define ('SITE_CITY', $fields['site_city']); + if(!defined('SITE_STATE')) define ('SITE_STATE', $fields['site_state']); + if(!defined('SITE_ZIP')) define ('SITE_ZIP', $fields['site_zip']); + if(!defined('SITE_PHONE')) define ('SITE_PHONE', $fields['site_phone']); + if(!defined('SITE_FAX')) define ('SITE_FAX', $fields['site_fax']); + + if($fields['os'] == 1) + define ('AGILE_OS', 'WINDOWS'); + else + define ('AGILE_OS', 'LINUX'); + + define ('PATH_CURL', $fields['path_curl']); + define ('SHOW_AFFILIATE_LINK', $fields['show_affiliate_link']); + define ('AUTO_AFFILIATE', @$fields['auto_affiliate']); + define ('SHOW_TICKET_LINK', $fields['show_ticket_link']); + define ('SHOW_NEWSLETTER_LINK', $fields['show_newsletter_link']); + define ('SHOW_CONTACT_LINK', $fields['show_contact_link']); + define ('SHOW_DOMAIN_LINK', $fields['show_domain_link']); + define ('SHOW_CART_LINK', $fields['show_cart_link']); + define ('SHOW_CHECKOUT_LINK', $fields['show_checkout_link']); + define ('SHOW_PRODUCT_LINK', $fields['show_product_link']); + define ('SHOW_CAT_BLOCK', $fields['show_cat_block']); + define ('SHOW_FILE_BLOCK', $fields['show_file_block']); + define ('SHOW_STATIC_BLOCK', $fields['show_static_block']); + define ('SHOW_AFFILIATE_CODE', $fields['show_affiliate_code']); + define ('SHOW_DISCOUNT_CODE', $fields['show_discount_code']); + define ('BILLING_WEEKDAY', $fields['billing_weekday']); + define ('GRACE_PERIOD', $fields['grace_period']); + define ('MAX_BILLING_NOTICE', $fields['max_billing_notice']); + define ('MAX_INV_GEN_PERIOD', $fields['max_inv_gen_period']); + + $error_reporting_eval = 'error_reporting('.ERROR_REPORTING.');'; + eval($error_reporting_eval); + } + + function get_setup() + { + $db = &DB(); + $q = "SELECT * FROM " . AGILE_DB_PREFIX . "setup WHERE site_id = ". DEFAULT_SITE; + $result = $db->Execute($q); + if ($result === false || @$result->RecordCount() == 0) { + if(is_file('install/install.inc')) + require_once('install/install.inc'); + else + $this->handle_failure($db); + exit; + } else { + return $result->fields; + } + } + + function default_date_format($default) + { + $default = unserialize($default); + $format = ''; + $divider = $default[3]; + for($i=0; $i<3; $i++) + { + $format .= $default[$i]; + if($i != 2) + $format .= $divider; + } + $arr = Array('a','A','b','B','d','j','m','u','y','Y'); + for($i=0; $i_errorMsg . "\r\n"; + fputs($f,$data); + } + + exit; + } +} +?> \ No newline at end of file diff --git a/modules/core/sort_array.inc.php b/modules/core/sort_array.inc.php new file mode 100644 index 00000000..35d0048c --- /dev/null +++ b/modules/core/sort_array.inc.php @@ -0,0 +1,89 @@ + "Usr1", + "Sex" => "male", + "Country" => "US", + "Children" => 3, + "BirthDate" => "1970-07-21" + ), + array ( + "UserName" => "TheUser", + "Sex" => "female", + "Country" => "Canada", + "Children" => 0, + "BirthDate" => "1975-11-05" + ) + ); + +$srt = new arr_multisort($sample_arr); +$srt->sort(); +dump_arr($sample_arr); + +//Sort by sex descending and children ascending +$srt->colNames = array("Sex", "Children"); +$srt->colDirs = array(SRT_DESC,SRT_ASC); +$sample_arr = $srt->sort(); + +//Sort by sex ascending and Birth date decending +$srt->colNames = array("Sex", "BirthDate"); +$srt->colDirs = array(SRT_ASC,SRT_DESC); +$sample_arr = $srt->sort(); + +*/ + + +define("SRT_ASC",1); +define("SRT_DESC",-1); + +Class arr_multisort{ + + //The array to be sorted + var $arr = NULL; + //Single dimensioned array with column names. Ex. array("UserName","Sex","Country") + var $colNames = NULL; + /* + Single dimensioned array with sort directions. Ex. array(SRT_ASC,SRT_ASC,SRT_DESC) + Must have the same length as $colNames array + */ + var $colDirs = NULL; + + //Constructor + function arr_multisort(&$arr,$colNames=array(),$colDirs=array()){ + $this->arr = $arr; + $this->colNames = $colNames; + $this->colDirs = $colDirs; + } + + //sort() method + function &sort(){ + usort($this->arr,array($this,"_compare")); + return $this->arr; + } + + //Comparison function [PRIVATE] + function _compare($a,$b,$idx = 0){ + if(count($this->colNames) == 0 || count($this->colNames) != count($this->colDirs)) return 0; + $a_cmp = $a[$this->colNames[$idx]]; + $b_cmp = $b[$this->colNames[$idx]]; + $a_dt = strtotime($a_cmp); + $b_dt = strtotime($b_cmp); + if(($a_dt == -1) || ($b_dt == -1)) + $ret = $this->colDirs[$idx]*strnatcasecmp($a_cmp,$b_cmp); + else{ + $ret = $this->colDirs[$idx]*(($a_dt > $b_dt)?1:(($a_dt < $b_dt)?-1:0)); + } + if($ret == 0){ + if($idx < (count($this->colNames)-1)) + return $this->_compare($a,$b,$idx+1); + else + return $ret; + } + else + return $ret; + } +} +?> \ No newline at end of file diff --git a/modules/core/ssl.inc.php b/modules/core/ssl.inc.php new file mode 100644 index 00000000..00991864 --- /dev/null +++ b/modules/core/ssl.inc.php @@ -0,0 +1,186 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +# Debug +if(empty($VAR) && empty($VAR['do']) && !defined("PATH_AGILE")) +{ + include_once('../../config.inc.php'); + $test = new CORE_ssl; + $test->test(); +} + +class CORE_ssl +{ + function CORE_ssl ($type=false) + { + $disabled_functions = ini_get('disable_functions'); + + if ( defined("PATH_CURL") && is_file(PATH_CURL) ) + $this->connect_curl_binary = true; + + if ( function_exists('curl_init') && $curl_version = curl_version()) { + if ( phpversion() >= 5 ) { + if (eregi('openssl', @$curl_version['ssl_version'] )) + $this->connect_curl_module = true; + } else { + if (eregi('openssl', curl_version())) + $this->connect_curl_module = true; + } + } + + if (phpversion() >= '4.3.0') + if (function_exists("fsockopen") ) + if (function_exists("openssl_public_decrypt")) + $this->connect_fsockopen = true; + } + + # debuging... + function test() { + echo '"; + } + + # type: 1=post 2=get + function connect($host, $url, $vars, $ssl, $type) { + if ( @$this->connect_curl_binary ) + return $this->connect_curl_binary ($host, $url, $vars, $ssl, $type); + elseif ( @$this->connect_curl_module ) + return $this->connect_curl_module ($host, $url, $vars, $ssl, $type); + elseif ( @$this->connect_fsockopen ) + return $this->connect_fsockopen ($host, $url, $vars, $ssl, $type); + else + return false; + } + + # SSL connection with Curl Binary + function connect_curl_binary($host, $url, $vars, $ssl, $type) { + + if($ssl) $urli = 'https://'.$host .''. $url; + else $urli = 'http://'.$host .''. $url; + + $params = ""; + if(is_array($vars)) { + for($i=0; $i 0) { $params .= '&'; } + $params .= $vars[$i][0].'='.urlencode($vars[$i][1]); + + } + } elseif (!empty($vars)) { + $params = $vars; + } + + $curl = PATH_CURL; + + # connect + if(!empty($params)) { + //echo $curl ."-d -k \"$params\"". $urli; + //echo $urli.'?'.$params; + //exit; + return `$curl -k -d "$params" $urli`; + } else { + //echo "$curl -k $urli"; + return `$curl -k $urli`; + } + } + + + # SSL connection with Curl Module + function connect_curl_module($host, $url, $vars, $ssl, $type) { + + if($ssl) $url = 'https://'.$host .''. $url; + else $url = 'http://'.$host .''. $url; + + $params = ''; + if(is_array($vars)) { + for($i=0; $i 0) { $params .= '&'; } + @$params .= $vars[$i][0].'='.urlencode($vars[$i][1]); + + } + } elseif (!empty($vars)) { + $params = $vars; + } + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + $result = curl_exec ($ch); + curl_close ($ch); + return $result; + } + + + # SSL connection with fsockopen() + function connect_fsockopen($host, $url, $vars, $ssl, $type) { + + if($ssl) { + $host = 'ssl://'. $host; + $port = 443; + } else { + $port = 80; + } + + $fp = @fsockopen ($host, $port, $errno, $errstr, 120); + $ret = ""; + @$req = substr ($url, $p); + + if ($fp) { + fputs ($fp, "POST $req HTTP/1.1\n"); + fputs ($fp, "Accept: */*\n"); + fputs ($fp, "Accept-Language: en\n"); + fputs ($fp, "Connection: Keep-Alive\n"); + fputs ($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)\n"); + fputs ($fp, "Content-type: application/x-www-form-urlencoded\n"); + $out = ""; + for($i=0; $i0 && !empty($vars[$i][0])) + $out .= '&'; + $out .= rawurlencode($vars[$i][0]) .'='. $out .= rawurlencode($vars[$i][1]); + } + $out = trim ($out); + fputs ($fp, "Content-length: ".strlen($out)."\n\n"); + fputs ($fp, "$out"); + fputs ($fp, "\n"); + while(!feof($fp)) + $ret .= fgets($fp,128); + fclose ($fp); + } else { + return false; + } + return $ret; + } +} +?> \ No newline at end of file diff --git a/modules/core/static_var.inc.php b/modules/core/static_var.inc.php new file mode 100644 index 00000000..32f1c4d7 --- /dev/null +++ b/modules/core/static_var.inc.php @@ -0,0 +1,1448 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_static_var +{ + ############################## + ## Generate Static Var List # + ############################## + + function generate_form($module, $method, $display) + { + global $VAR, $C_translate; + include_once(PATH_CORE . 'validate.inc.php'); + + #################################################################### + ### $Method is the method name called to add records, so we know if we + ### should use the error class, i.e: 'user_add' + ### $Module is the module name + ### $Display is the display type (view or update) update allows for + ### user changes... + + $validate = false; + if(isset($VAR['do']) && gettype($VAR['do']) == 'array') + { + for($i=0; $iExecute($sql); + + if($relation->RecordCount() == 0) + { + return false; + } + else + { + $i = 0; + $C_validate = new CORE_validate; + + while (!$relation->EOF) + { + ################################################################ + ### Get the primary settings for this field + + $id = $relation->fields['id']; + $static_var_id = $relation->fields['static_var_id']; + $default_value = $relation->fields['default_value']; + $description = $relation->fields['description']; + $required = $relation->fields['required']; + + + + ############################################################ + ### Get the extended details for this field from the STATIC + ### VAR records + + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'static_var WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($static_var_id); + $var = $db->Execute($sql); + + + + $format = $var->fields['input_format']; + $validation = $var->fields['validation_type']; + $convert = $var->fields['convert_type']; + $name = $var->fields['name']; + + + + ############################################################ + ### Generate the field name, translate if it exists, + ### otherwise, just return the actual field name + + ### $this_name = $C_translate->translate('field_'.$name, $module, ''); + ### if($this_name = '') $this_name = $name; + $this_name = $name; + + + ############################################################ + ### Determine the field value & name + + if(!isset($VAR["static_relation"]["$id"]) || $VAR["static_relation"]["$id"] == '') + $static_value = $default_value; + else + $static_value = $VAR["static_relation"]["$id"]; + + $static_relation = 'static_relation['.$id.']'; + + + + ############################################################ + ### Determine The CSS Style to use... + + if($required == '1' && $validate == true) + { + if(!isset($VAR["static_relation"]["$id"]) || trim($VAR["static_relation"]["$id"]) == '') + { + $css = 'form_field_error'; + } + else if ($validation != 'any' && $validation != 'none' && $validation != '') + { + $css = 'form_field_error'; + $css = 'form_field'; + } + else + { + $css = 'form_field'; + } + } + else + { + $css = 'form_field'; + } + + $css_menu = 'form_menu'; + + + ############################################################ + ### Create the HTML + + if($format == 'small_text') + { + if($display == 'update') + { + ### SMALL TEXT FIELD + $this_html = ''; + } + elseif($display == 'search') + { + $this_html = '' . + $C_translate->translate('search_partial', 'CORE', SESS_LANGUAGE); + } + else + { + $this_html = $static_value; + } + } + + + else if ($format == 'medium_text') + { + if($display == 'update') + { + ### MEDIUM TEXT FIELD + $this_html = ''; + } + elseif($display == 'search') + { + $this_html = '' . + $C_translate->translate('search_partial', 'CORE', SESS_LANGUAGE); + } + else + { + $this_html = $static_value; + } + } + + + else if ($format == 'large_text') + { + if($display == 'update') + { + ### LARGE TEXT FIELD + $this_html = ''; + } + elseif($display == 'search') + { + $this_html = '' . + $C_translate->translate('search_partial', 'CORE', SESS_LANGUAGE); + } + else + { + $this_html = $static_value; + } + } + + + + + else if ($format == 'dropdown_list') + { + if( $display == 'update') + { + $this_html = ''; + } + elseif ($display == 'search') + { + $this_html = ''; + } + else + { + $this_html = $static_value; + } + } + + + else if ($format == 'calendar') + { + if($display == 'update' || $display == 'search') + { + # set the date to current date if 'now' is set as $default + if( $static_value == 'now' ) { + $default = date(UNIX_DATE_FORMAT); + } else { + $default = $static_value; + } + $id = rand(9,999); + $this_html = ' +   + + + '; + + } + else + { + $this_html = $static_value; + } + } + + + else if ($format == 'file_upload') + { + if($display == 'update') + { + ### FILE UPLOAD + $this_html = 'File upload not yet supported!'; + } + else + { + $this_html = ''; + } + } + + + else if ($format == 'status') + { + if($display == 'update') + { + ### BOOLEAN TRUE/FALSE + $C_list = new CORE_list; + $this_html = $C_list->bool_static_var($static_relation, $static_value, $css_menu); + } + elseif($display == 'search') + { + ### BOOLEAN TRUE/FALSE + $C_list = new CORE_list; + $this_html = $C_list->bool_static_var($static_relation, 'all', $css_menu); + } + else + { + $this_html = $static_value; + } + } + + + else if ($format == 'checkbox') + { + if($display == 'update') + { + ### CHECKBOX + if($static_value == '1') + $this_html = ''; + else + $this_html = ''; + } + elseif($display == 'search') + { + ### BOOLEAN TRUE/FALSE + $C_list = new CORE_list; + $this_html = $C_list->bool_static_var($static_relation, 'all', $css_menu); + } + else + { + $this_html = $static_value; + } + } + + else if ($format == 'hidden') + { + ### HIDDEN FIELD + $this_html = ''; + } + + + ### add to the array + $arr[] = Array('name' => $this_name, + 'html' => $this_html); + + $i++; + $relation->MoveNext(); + } + } + + #echo "
";
+		#htmlspecialchars(print_r(@$arr));
+
+		return $arr;
+	}	
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+	function update_form($module, $method, $record_id)
+	{
+	   global $VAR, $C_translate;
+	   include_once(PATH_CORE . 'validate.inc.php');
+
+	   $display = 'update';
+
+		####################################################################
+		### $Method is the method name called to add records, so we know if we
+		### should use the error class, i.e: 'user_add'
+		### $Module is the module name
+		### $Display is the display type (view or update) update allows for
+		### user changes...
+
+		$validate = false;
+		if(isset($VAR['do'])  &&   gettype($VAR['do']) == 'array')
+		{
+			for($i=0; $iExecute($sql);
+
+		if($relation->RecordCount() == 0)
+		{
+			return false;
+		}
+		else
+		{
+			$i = 0;
+			$C_validate = new CORE_validate;
+
+			while (!$relation->EOF)
+			{
+
+				################################################################
+				### Get the primary settings for this field
+
+				$id             = $relation->fields['id'];
+				$static_var_id  = $relation->fields['static_var_id'];
+				$default_value  = $relation->fields['default_value'];
+				$description    = $relation->fields['description'];
+				$required       = $relation->fields['required'];
+
+
+
+				############################################################
+				### Get the extended details for this field from the STATIC
+				### VAR records
+
+				$sql    = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'static_var WHERE
+						   site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
+						   id          = ' . $db->qstr($static_var_id);
+				$var = $db->Execute($sql);
+
+
+
+				$format         = $var->fields['input_format'];
+				$validation     = $var->fields['validation_type'];
+				$convert        = $var->fields['convert_type'];
+				$name           = $var->fields['name'];
+
+
+				############################################################
+				### Get the value for this record, if any...
+
+				$sql    = 'SELECT value FROM ' . AGILE_DB_PREFIX . 'static_var_record
+						   WHERE
+						   site_id      = ' . $db->qstr(DEFAULT_SITE) . ' AND
+						   record_id    = ' . $db->qstr($record_id) .' AND
+						   static_var_id= ' . $db->qstr($static_var_id) .' AND
+						   static_var_relation_id = ' . $db->qstr($id) .' AND
+						   module_id = ' . $db->qstr($module_id);
+				$value = $db->Execute($sql);
+
+				$static_value = $value->fields['value'];
+
+
+
+				############################################################
+				### Generate the field name, translate if it exists,
+				### otherwise, just return the actual field name
+
+				### $this_name      = $C_translate->translate('field_'.$name, $module, '');        		 	
+				### if($this_name = '') $this_name = $name;
+				$this_name = $name;
+				$static_relation = 'static_relation['.$id.']';
+
+
+				############################################################
+				### Determine The CSS Style to use...
+
+				if($required == '1' && $validate == true)
+				{
+					if(!isset($VAR["static_relation"]["$id"]) || trim($VAR["static_relation"]["$id"]) == '')
+					{
+						$css = 'form_field_error';
+					}
+					else if ($validation != 'any'   &&   $validation != 'none'  &&   $validation != '')
+					{
+						$css = 'form_field_error';
+						$css = 'form_field';
+					}
+					else
+					{
+						$css = 'form_field';
+					}
+				}
+				else
+				{
+					$css = 'form_field';
+				}
+
+				$css_menu = 'form_menu';
+
+
+
+
+				############################################################
+				### Create the HTML
+
+				if($format == 'small_text')
+				{
+					if($display == 'update')
+					{
+						### SMALL TEXT FIELD
+						$this_html = '';
+					}
+					else
+					{
+						$this_html = $static_value;
+					}
+				}
+
+
+				else if ($format == 'medium_text')
+				{
+					if($display == 'update')
+					{
+						### MEDIUM TEXT FIELD
+						$this_html = '';
+					}
+					else
+					{
+						$this_html = $static_value;
+					}
+				}
+
+
+				else if ($format == 'large_text')
+				{
+					if($display == 'update')
+					{
+						### LARGE TEXT FIELD
+						$this_html = '';
+					}
+					else
+					{
+						$this_html = $static_value;
+					}
+				}
+
+
+
+
+				else if ($format == 'dropdown_list')
+				{
+					if($display == 'update')
+					{
+						### MENU LIST
+						$this_html = '';
+					}
+					else
+					{
+						$this_html = $static_value;
+					} 
+				}
+
+
+				else if ($format == 'calendar')
+				{
+					if($display == 'update')
+					{ 
+						if(!empty($static_value))
+						@$default = date(UNIX_DATE_FORMAT,$static_value);
+						else 
+						$default = false;
+
+						$id = rand(9,999);
+						$this_html = '
+							 						
+							
+							
+							';
+					}
+					else
+					{
+						$this_html = $static_value;
+					}
+				}
+
+
+				else if ($format == 'file_upload')
+				{
+					if($display == 'update')
+					{
+						### FILE UPLOAD
+						$this_html = 'File upload not yet supported!';
+					}
+					else
+					{
+						$this_html = '';
+					}
+				}
+
+
+				else if ($format == 'status')
+				{
+					if($display == 'update')
+					{
+						### BOOLEAN TRUE/FALSE
+						$C_list = new CORE_list;
+						$this_html = $C_list->bool_static_var($static_relation, $static_value, $css_menu);
+					}
+					else
+					{
+						$this_html = $static_value;
+					}
+				}
+
+
+				else if ($format == 'checkbox')
+				{
+					if($display == 'update')
+					{
+						### CHECKBOX
+						if($static_value == '1')
+						$this_html = '';
+						else
+						$this_html = '';
+					}
+					else
+					{
+						$this_html = $static_value;
+					}
+				}
+
+				else if ($format == 'hidden')
+				{
+					### HIDDEN FIELD
+					$this_html = '';
+				}
+
+
+				### add to the array
+				$arr[] = Array('name' => $this_name,
+								 'html' => $this_html);
+
+				$i++;
+				$relation->MoveNext();
+			}
+		} 	
+		return $arr;
+	}	
+
+
+
+
+
+
+
+
+
+
+
+
+	#################################
+	##	View static vars for Record #
+	#################################
+
+	function view_form($module, $record_id)
+	{
+	   global $VAR, $C_translate; 	
+
+		####################################################################
+		### $Method is the method name called to add records, so we know if we
+		### should use the error class, i.e: 'user_add'
+		### $record_id is the record to retrieve values for
+
+
+		####################################################################
+		### Get the Id for this module
+
+		$db     = &DB();
+		$sql    = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'module WHERE
+					site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
+					name        = ' . $db->qstr($module);
+		$result = $db->Execute($sql);
+
+		if($result->RecordCount() == 0)
+		return false;
+		else
+		$module_id = $result->fields['id'];
+
+
+
+		####################################################################	 	
+		### Get all the associated STATIC RELATION records
+
+		$sql    = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'static_relation WHERE
+					site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
+					module_id   = ' . $db->qstr($module_id) .' ORDER BY sort_order';
+		$relation = $db->Execute($sql);
+
+		if($relation->RecordCount() == 0)
+		{
+			return false;
+		}
+		else
+		{
+			$i = 0;
+
+
+			while (!$relation->EOF)
+			{
+
+				################################################################
+				### Get the primary settings for this field
+
+				$id             = $relation->fields['id'];
+				$static_var_id  = $relation->fields['static_var_id'];
+
+
+				############################################################
+				### Get the extended details for this field from the STATIC
+				### VAR records
+
+				$sql    = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'static_var WHERE
+						   site_id     = ' . $db->qstr(DEFAULT_SITE) . ' AND
+						   id          = ' . $db->qstr($static_var_id);
+				$var = $db->Execute($sql);
+
+				$format         = $var->fields['input_format'];
+				$validation     = $var->fields['validation_type'];
+				$convert        = $var->fields['convert_type'];
+				$this_name      = $var->fields['name'];
+
+
+
+				############################################################
+				### Get the value for this record, if any...
+
+				$sql    = 'SELECT value FROM ' . AGILE_DB_PREFIX . 'static_var_record
+						   WHERE
+						   site_id      = ' . $db->qstr(DEFAULT_SITE) . ' AND
+						   record_id    = ' . $db->qstr($record_id) .' AND
+						   static_var_id= ' . $db->qstr($static_var_id) .' AND
+						   static_var_relation_id = ' . $db->qstr($id) .' AND
+						   module_id = ' . $db->qstr($module_id);
+				$value = $db->Execute($sql);
+
+				$static_value = $value->fields['value'];
+
+				############################################################
+				### Create the HTML
+
+				if($format == 'small_text')
+				{
+					if($display == 'update')
+					{
+						### SMALL TEXT FIELD
+						$this_html = '';
+					}
+					else if ( $static_value != '' )
+					{
+						$this_html = $static_value;
+					}
+				}
+
+
+				else if ($format == 'medium_text')
+				{
+					if($display == 'update')
+					{
+						### MEDIUM TEXT FIELD
+						$this_html = '';
+					}
+					else if ( $static_value != '' )
+					{
+						$this_html = $static_value;
+					}
+				}
+
+
+				else if ($format == 'large_text')
+				{
+					if($display == 'update')
+					{
+						### LARGE TEXT FIELD
+						$this_html = '';
+					}
+					else if ( $static_value != '' )
+					{
+						$return = '
+';
+						$this_html = ereg_replace($return, '
', $static_value); + } + } + + + else if ($format == 'dropdown_list') + { + if($display == 'update') + { + ### MENU LIST + $this_html = ''; + } + else if ( $static_value != '' ) + { + $this_html = $static_value; + } + } + + + else if ($format == 'calendar') + { + if($display == 'update') + { + ### SHOW DATE SELECTOR + $C_list = new CORE_list; + $this_html = $C_list->calender_add_static_var($static_relation, $static_value, $css); + } + else if ( $static_value != '' ) + { + $date = date(UNIX_DATE_FORMAT, $static_value); + $this_html = $date; + } + } + + + else if ($format == 'file_upload') + { + if($display == 'update') + { + ### FILE UPLOAD + $this_html = 'File upload not yet supported!'; + } + else if ( $static_value != '' ) + { + $this_html = ''; + } + } + + + else if ($format == 'status') + { + if($display == 'update') + { + ### BOOLEAN TRUE/FALSE + $C_list = new CORE_list; + $this_html = $C_list->bool_static_var($static_relation, $static_value, $css_menu); + } + else if ( $static_value != '' ) + { + if($static_value == 1) + $this_html = $C_translate->translate('true','',''); + else + $this_html = $C_translate->translate('false','',''); + } + } + + + else if ($format == 'checkbox') + { + if($display == 'update') + { + ### CHECKBOX + if($static_value == '1') + $this_html = ''; + else + $this_html = ''; + } + else if ( $static_value != '' ) + { + if($static_value == 1) + $this_html = $C_translate->translate('true','',''); + else + $this_html = $C_translate->translate('false','',''); + } + } + + else if ($format == 'hidden' && $static_value != '' ) + { + ### HIDDEN FIELD + $this_html = $static_value; + } + + + ### add to the array + if ( $static_value != '' ) + { + $arr[] = Array('name' => $this_name, 'html' => $this_html); + $i++; + } + + $relation->MoveNext(); + } + } + return $arr; + } + + + + + + + + + + + + + ############################## + ## VALIDATE A FORM # + ############################## + + function validate_form($module, $errors) + { + global $VAR, $C_translate; + include_once(PATH_CORE . 'validate.inc.php'); + + + #################################################################### + ### $Method is the method name called to add records, so we know if we + ### should use the error class, i.e: 'user_add' + ### $Module is the module name + ### $Display is the display type (view or update) update allows for + ### user changes... + + + #################################################################### + ### Get the Id for this module + + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'module WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + name = ' . $db->qstr($module); + $result = $db->Execute($sql); + + if($result->RecordCount() == 0) + return $errors; + else + $module_id = $result->fields['id']; + + + + #################################################################### + ### Get all the associated STATIC RELATION records + + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'static_relation WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + module_id = ' . $db->qstr($module_id) .' ORDER BY sort_order'; + $relation = $db->Execute($sql); + + if($relation->RecordCount() == 0) + { + return $errors; + } + else + { + $i = 0; + $C_validate = new CORE_validate; + + while (!$relation->EOF) + { + + ################################################################ + ### Get the primary settings for this field + + $id = $relation->fields['id']; + $static_var_id = $relation->fields['static_var_id']; + $default_value = $relation->fields['default_value']; + $description = $relation->fields['description']; + $required = $relation->fields['required']; + + + + ############################################################ + ### Get the extended details for this field from the STATIC + ### VAR records + + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'static_var WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($static_var_id); + $var = $db->Execute($sql); + + + + $format = $var->fields['input_format']; + $validation = $var->fields['validation_type']; + $convert = $var->fields['convert_type']; + $name = $var->fields['name']; + + + + ############################################################ + ### Generate the field name, translate if it exists, + ### otherwise, just return the actual field name + + ### $this_name = $C_translate->translate('field_'.$name, $module, ''); + ### if($this_name = '') $this_name = $name; + $this_name = $name; + $static_relation = 'static_relation['.$id.']'; + + ############################################################ + ### Determine the field value & name + + if(!isset($VAR["static_relation"]["$id"]) || $VAR["static_relation"]["$id"] == '') + $field_value = ''; + else + $field_value = $VAR["static_relation"]["$id"]; + + + + + ############################################################ + ### VALIDATE THE FIELD + + if($required == '1') + { + if($field_value == '') + { + ### ERROR: This field is required! + $errors[] = Array('field' => $name, + 'field_trans' => $name, + 'error' => $C_translate->translate('validate_any',"", "")); + } + else if ($validation != 'any' && $validation != 'none') + { + + ### VALIDATE THIS FIELD: + $val["min_len"] = '1'; + $val["max_len"] = '999999'; + if (!$C_validate->validate($name, $val, $field_value, $validation)) + { + ### ERROR: Validation failed! + ### ERROR: This field is required! + $errors[] = Array('field' => $name, + 'field_trans' => $name, + 'error' => $C_validate->error[$name]); + + } + } + } + + $i++; + $relation->MoveNext(); + } + } + + + if(!isset($errors)) + return false; + else + return $errors; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + ############################## + ## ADD STATIC VAR RECORDS # + ############################## + + function add($VAR, $module, $record_id) + { + include_once(PATH_CORE . 'validate.inc.php'); + + + #################################################################### + ### $Method is the method name called to add records, so we know if we + ### should use the error class, i.e: 'user_add' + + + #################################################################### + ### Get the Id for this module + + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'module WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + name = ' . $db->qstr($module); + $result = $db->Execute($sql); + + if($result->RecordCount() == 0) + return false; + else + $module_id = $result->fields['id']; + + + + #################################################################### + ### Get all the associated STATIC RELATION records + + $sql = 'SELECT id, static_var_id FROM ' . AGILE_DB_PREFIX . 'static_relation WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + module_id = ' . $db->qstr($module_id) .' ORDER BY sort_order'; + $relation = $db->Execute($sql); + + if($relation->RecordCount() == 0) + { + return false; + } + else + { + $i = 0; + $C_validate = new CORE_validate; + + # define the validation class + $validate = new CORE_validate; + + while (!$relation->EOF) + { + + ################################################################ + ### Get the primary settings for this field + + $id = $relation->fields['id']; + $static_var_relation_id = $id; + $static_var_id = $relation->fields['static_var_id']; + + + ############################################################ + ### Get the extended details for this field from the STATIC + ### VAR records + + $sql = 'SELECT id,name,convert_type FROM ' . AGILE_DB_PREFIX . 'static_var WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($static_var_id); + $var = $db->Execute($sql); + + $convert = $var->fields['convert_type']; + $name = $var->fields['name']; + + + + ############################################################ + ### Generate the field name, translate if it exists, + ### otherwise, just return the actual field name + + $static_relation = 'static_relation['.$id.']'; + + if(isset($VAR["static_relation"]["$id"]) && $VAR["static_relation"]["$id"] != '') + { + $value = $VAR["static_relation"]["$id"]; + + if($convert != 'none' && $convert != '') + $value = $validate->convert($name, $value, $convert); + + + ######################################################## + ### Create the DB Record: + $db = &DB(); + $idx = $db->GenID(AGILE_DB_PREFIX . "" . 'static_var_record_id'); + $sql = 'INSERT INTO ' . AGILE_DB_PREFIX . 'static_var_record SET + site_id = ' . $db->qstr(DEFAULT_SITE) . ', + id = ' . $db->qstr($idx) . ', + record_id = ' . $db->qstr($record_id) . ', + module_id = ' . $db->qstr($module_id) . ', + static_var_id=' . $db->qstr($static_var_id) . ', + static_var_relation_id= ' . $db->qstr($static_var_relation_id) . ', + value = ' . $db->qstr($value) ; + $insert = $db->Execute($sql); + + # error reporting: + if ($insert === false) + { + global $C_debug; + $C_debug->error('static_var.inc.php','add', $db->ErrorMsg()); + return false; + } + } + $relation->MoveNext(); + } + } + return true; + } + + + + + + + + + + + + + + + + + + + ############################## + ## ADD STATIC VAR RECORDS # + ############################## + + function update($VAR, $module, $record_id) + { + include_once(PATH_CORE . 'validate.inc.php'); + + + #################################################################### + ### $Method is the method name called to add records, so we know if we + ### should use the error class, i.e: 'user_add' + + + #################################################################### + ### Get the Id for this module + + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'module WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + name = ' . $db->qstr($module); + $result = $db->Execute($sql); + + if($result->RecordCount() == 0) + return false; + else + $module_id = $result->fields['id']; + + + + #################################################################### + ### Get all the associated STATIC RELATION records + + $sql = 'SELECT id, static_var_id FROM ' . AGILE_DB_PREFIX . 'static_relation WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + module_id = ' . $db->qstr($module_id) .' ORDER BY sort_order'; + $relation = $db->Execute($sql); + + if($relation->RecordCount() == 0) + { + return false; + } + else + { + $i = 0; + $validate = new CORE_validate; + + while (!$relation->EOF) + { + unset($value); + + ### Get the primary settings for this field + $id = $relation->fields['id']; + $static_var_relation_id = $id; + $static_var_id = $relation->fields['static_var_id']; + + + ### Get the extended details for this field from the STATIC + ### VAR records + + $sql = 'SELECT id,name,convert_type FROM ' . AGILE_DB_PREFIX . 'static_var WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($static_var_id); + $var = $db->Execute($sql); + + $convert = $var->fields['convert_type']; + $name = $var->fields['name']; + + + + ############################################################ + ### Generate the field name, translate if it exists, + ### otherwise, just return the actual field name + + $static_relation = 'static_relation['.$id.']'; + @$value = $VAR["static_relation"]["$id"]; + + if(!empty($VAR["static_relation"]["$id"]) || $value == 0 ) + { + if($convert != 'none' && $convert != '') + $value = $validate->convert($name, $value, $convert); + + ### Test record already exists: + $sql = 'SELECT id,value FROM ' . AGILE_DB_PREFIX . 'static_var_record + WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + record_id = ' . $db->qstr($record_id) . ' AND + module_id = ' . $db->qstr($module_id) . ' AND + static_var_id=' . $db->qstr($static_var_id) . ' AND + static_var_relation_id= ' . $db->qstr($static_var_relation_id); + $return = $db->Execute($sql); + + if ($return->RecordCount() == 0) + { + ### Create new record: + $idx = $db->GenID(AGILE_DB_PREFIX . "" . 'static_var_record_id'); + $sql = 'INSERT INTO ' . AGILE_DB_PREFIX . 'static_var_record SET + site_id = ' . $db->qstr(DEFAULT_SITE) . ', + id = ' . $db->qstr($idx) . ', + record_id = ' . $db->qstr($record_id) . ', + module_id = ' . $db->qstr($module_id) . ', + static_var_id=' . $db->qstr($static_var_id) . ', + static_var_relation_id= ' . $db->qstr($static_var_relation_id) . ', + value = ' . $db->qstr($value) ; + $insert = $db->Execute($sql); + if ($insert === false) { + global $C_debug; + $C_debug->error('static_var.inc.php','update', $db->ErrorMsg()); + return false; + } + } + elseif ($value != $return->fields['value']) + { + ### UPDATE the DB Record: + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'static_var_record SET + value = ' . $db->qstr($value) . ' + WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($return->fields['id']); + $insert = $db->Execute($sql); + if ($insert === false) { + global $C_debug; + $C_debug->error('static_var.inc.php','update', $db->ErrorMsg()); + return false; + } + } + } + else + { + ### Test record already exists: + $sql = 'DELETE FROM ' . AGILE_DB_PREFIX . 'static_var_record + WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + record_id = ' . $db->qstr($record_id) . ' AND + module_id = ' . $db->qstr($module_id) . ' AND + static_var_id=' . $db->qstr($static_var_id) . ' AND + static_var_relation_id= ' . $db->qstr($static_var_relation_id); + $return = $db->Execute($sql); + } + $relation->MoveNext(); + } + } + } +} +?> \ No newline at end of file diff --git a/modules/core/theme.inc.php b/modules/core/theme.inc.php new file mode 100644 index 00000000..6124e4e9 --- /dev/null +++ b/modules/core/theme.inc.php @@ -0,0 +1,180 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_theme +{ + var $id; + + function CORE_theme() + { + global $VAR, $C_debug, $C_translate, $smarty; + + # Get the cuurent session theme: + if(defined("SESS_THEME") && file_exists(PATH_THEMES . '' . SESS_THEME . '/template.tpl')) + { + if(SESS_THEME == 'default_admin' && SESS_LOGGED != true ) + define ('THEME_NAME', DEF_THEME_N); + elseif (defined("ADMIN_FORCE")) + define ('THEME_NAME', 'default_admin'); + elseif (!defined("ADMIN_FORCE") && SESS_THEME != 'default_admin') + define ('THEME_NAME', SESS_THEME); + else + define ('THEME_NAME', DEF_THEME_N); + } + elseif(file_exists(PATH_THEMES.DEFAULT_THEME.'/template.tpl')) + { + define ('THEME_NAME', DEFAULT_THEME); + } + else + { + define ('THEME_NAME', DEF_THEME_N); + } + + # load the block class + $block = new CORE_block; + + # set smarty vars + if(isset($smarty->template_dir)) unset($smarty->template_dir); + $smarty->use_sub_dirs = false; + $smarty->template_dir = PATH_THEMES . '' . THEME_NAME . '/'; + $smarty->compile_dir = PATH_SMARTY . 'templates/'; + $smarty->config_dir = PATH_SMARTY . 'configs/'; + $smarty->cache_dir = PATH_SMARTY . 'cache/'; + $this->caching = false; + $this->compile_check = true; + $smarty->assign("THEME_NAME", THEME_NAME); + + # Frame Theme Escape + if(THEME_NAME == 'default_admin') + { + if (!empty($VAR['tid']) && empty($VAR['_escape'])) + { + // get url string to pass to mainFrame + $url=''; + $i=0; + while(list($key,$val) = each($VAR)) { + if($key != 'tid') + { + if($i==0) $url .= '?'; else $url .= '&'; + $url .= $key.'='.$val; + $i++; + } + } + $url = ereg_replace('tid=default_admin', '', $url); + $smarty->assign('mainFrameUrl', $url); + $this_template = 'file:'.PATH_THEMES.''.THEME_NAME.'/template.tpl'; + $smarty->display($this_template); + exit; + } + + if (empty($VAR['_escape'])) + $block->display('core:top_frame'); + + # force or define page set? + if(defined("FORCE_PAGE")) { + $block->display(FORCE_PAGE); + exit(); + } elseif (@$VAR['_page']) { + $block->display($VAR['_page']); + exit(); + } else { + $block->display('core:admin'); + exit; + } + } + + # Standard themes + if(isset($VAR['_escape'])) + { + if(isset($VAR['_print'])) + { + # load printer friendly version + $block->display('core:top_frame'); + $block->display($VAR['_page']); + $block->display('core:bottom_print'); + exit(); + } + else + { + # check for force page: + if(defined("FORCE_PAGE")) + $block->display(FORCE_PAGE); + else + $block->display($VAR['_page']); + exit(); + } + } + else + { + if(defined("FORCE_PAGE")) { + define('THEME_PAGE', FORCE_PAGE); + } else { + if(isset($VAR['_page'])) + define('THEME_PAGE', $VAR['_page']); + else + define('THEME_PAGE', 'core:main'); + } + + # load the block normally + $this_template = 'file:' . PATH_THEMES . '' . THEME_NAME . '/template.tpl'; + $smarty->display($this_template); + + } + } +} + + + +class CORE_block +{ + function display($block_r) + { + global $smarty; + @$resource = explode(':',$block_r); + @$module = $resource[0]; + @$block = $resource[1]; + if($module == 'TEMPLATE') + { + $smarty->template_dir = PATH_THEMES . '' . THEME_NAME . '/'; + $smarty->display('file:' . $smarty->template_dir . '' . $block . '.tpl'); + } else { + if(is_file(PATH_THEMES . '' . THEME_NAME . '/blocks/' . $module . '/' . $block . '.tpl')) + { + $smarty->template_dir = PATH_THEMES . '' . THEME_NAME . '/blocks/' . $module . '/'; + $smarty->display('file:' . $smarty->template_dir . '' . $block . '.tpl'); + } + elseif (is_file(PATH_THEMES . '' . DEF_THEME_N . '/blocks/' . $module . '/' . $block . '.tpl')) + { + $smarty->template_dir = PATH_THEMES . '' . DEF_THEME_N . '/blocks/' . $module . '/'; + $smarty->display('file:' . $smarty->template_dir . '' . $block . '.tpl'); + } + elseif (is_file(PATH_THEMES . 'default/blocks/' . $module . '/' . $block . '.tpl')) + { + $smarty->template_dir = PATH_THEMES . 'default/blocks/' . $module . '/'; + $smarty->display('file:' . $smarty->template_dir . '' . $block . '.tpl'); + } + else + { + $smarty->display('file:'. PATH_THEMES . '' . DEF_THEME_N . '/blocks/core/invalid_page.tpl'); + } + } + } +} +?> \ No newline at end of file diff --git a/modules/core/translate.inc.php b/modules/core/translate.inc.php new file mode 100644 index 00000000..5749613b --- /dev/null +++ b/modules/core/translate.inc.php @@ -0,0 +1,96 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_translate +{ + function CORE_translate() { + if(defined("SESS_LANGUAGE")) + $language = SESS_LANGUAGE; + else + $language = DEFAULT_LANGUAGE; + $language = $this->get_lang_pack('CORE', $language); + define('LANG', $this->language_name); + } + + + function get_lang_pack($module, $language) { + # define the language names / ids (must match the language.name & language.id fields in the DB + $this->lang_arr[0] = 'english'; + + # get the Core language pack + if($module=='CORE') { + $pack_file = PATH_LANGUAGE .'core/'. $language . '_core.xml'; + $this->language_name = $language; + } else if ($language != '') { + $pack_file = PATH_LANGUAGE . '' . $module . '/' . $language . '_' . $module . '.xml'; + } + $def_pack_file = PATH_LANGUAGE . '' . $module . '/' . DEFAULT_LANGUAGE . '_' . $module . '.xml'; + + # check that the defined file exists, if not, use the default language instead: + if(file_exists($pack_file)) { + # open the file for parsing + $C_xml = new CORE_xml; + $this->lang_pack["$module"]["$language"] = $C_xml->xml_to_array($pack_file); + } else { + # open the default language file for parsing + $C_xml = new CORE_xml; + $this->lang_pack["$module"]["$language"] = $C_xml->xml_to_array($def_pack_file); + } + } + + function translate_resource($module, $resource, $language) { + if(!empty($this->value["$module"])) $array = $this->value["$module"]; + @$string = $this->lang_pack["$module"]["$language"]["translate"]["$resource"]; + if(!empty($array) && is_array($array) && !empty($string)) + while(list ($key, $val) = each ($array)) + $string = str_replace("%%{$key}%%", $val, $string); + return $string; + } + + function value($module, $variable, $value) { + $this->value["$module"]["$variable"] = $value; + } + + function translate($resource, $module='CORE', $language=SESS_LANGUAGE) { + # determine the language + if(empty($language)) { + if(defined("SESS_LANGUAGE")) + $language = SESS_LANGUAGE; + else + $language = DEFAULT_LANGUAGE; + } + + if(empty($module)) $module = 'CORE'; + + if(!empty($resource)) { + # checks if this is the core + if($module == 'CORE') + return $this->translate_resource('CORE', $resource, $language); + + # load the language pack for the current module if needed: + if(!isset($this->lang_pack["$module"]["$language"])) + $this->get_lang_pack($module,$language); + + # translate/return the current resource + return $this->translate_resource($module, $resource, $language); + } + } +} +?> \ No newline at end of file diff --git a/modules/core/trigger.inc.php b/modules/core/trigger.inc.php new file mode 100644 index 00000000..385802be --- /dev/null +++ b/modules/core/trigger.inc.php @@ -0,0 +1,58 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_trigger +{ + function trigger($trigger, $type, $VAR) + { + if($type) + { + # do success trigger(s) + if(isset($trigger["success"])) + $this->run_triggers($trigger["success"]); + } + else + { + # do failure trigger(s) + if(isset($trigger["failure"])) + $this->run_triggers($trigger["failure"]); + } + } + + # run the trigger(s): + function run_triggers($trigger) + { + global $C_method; + $triggers = split(',', $trigger); + for($i=0; $i 1) + { + $C_method->exe($triggerss[0], $triggerss[1]); + } + } + } + } +} +?> \ No newline at end of file diff --git a/modules/core/validate.inc.php b/modules/core/validate.inc.php new file mode 100644 index 00000000..3276a9b6 --- /dev/null +++ b/modules/core/validate.inc.php @@ -0,0 +1,757 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_validate +{ + function convert($field, $data, $type) + { + switch($type) + { + case "date": + return $this->convert_date ($data,$field); + break; + case "time": + return $this->convert_time ($data,$field); + break; + case "date-time": + return $this->convert_date_time ($data,$field); + break; + case "date-now": + return $this->convert_date_now($data,$field); + break; + case "md5": + return $this->convert_md5 ($data,$field); + break; + case "sha": + return $this->convert_sha ($data,$field); + break; + case "rc5": + return $this->convert_rc5 ($data,$field); + break; + case "crypt": + return $this->convert_crypt ($data,$field); + break; + case "encrypt": + return $this->convert_encrypt ($data,$field); + break; + case "gpg": + return $this->convert_gpg ($data,$field); + break; + case "pgp": + return $this->convert_pgp ($data,$field); + break; + case "array": + return $this->convert_array ($data,$field); + break; + case "html": + return $this->convert_html ($data,$field); + break; + } + } + + + # convert DEFAULT_TIME_FORMT to unix time stamp + function convert_time ($data,$field) + { + return strtotime($data); + } + + # convert DEFAULT_DATE_FORMT to unix time stamp + function convert_date ($date,$field) + { + if($date == '0' || $date == '') + return ''; + + $Arr_format = split(DEFAULT_DATE_DIVIDER, UNIX_DATE_FORMAT); + $Arr_date = split(DEFAULT_DATE_DIVIDER, $date); + + for($i=0; $i<3; $i++) + { + if($Arr_format[$i] == 'd') + $day = $Arr_date[$i]; + + if($Arr_format[$i] == 'm') + $month = $Arr_date[$i]; + + if($Arr_format[$i] == 'Y') + $year = $Arr_date[$i]; + } + + $timestamp = mktime(0, 0, 0, $month, $day, $year); + return $timestamp; + } + + # convert DEFAULT_DATE_TIME_FORMT to unix time stamp + function convert_date_time ($date,$field) + { + if($date == '0' || $date == '') + return ''; + + $Arr_format = split(DEFAULT_DATE_DIVIDER, UNIX_DATE_FORMAT); + $Arr_date = split(DEFAULT_DATE_DIVIDER, $date); + + for($i=0; $i<3; $i++) { + if($Arr_format[$i] == 'd') if(!empty($Arr_date[$i])) $day = $Arr_date[$i]; + if($Arr_format[$i] == 'm') if(!empty($Arr_date[$i])) $month = $Arr_date[$i]; + if($Arr_format[$i] == 'Y') if(!empty($Arr_date[$i])) $year = $Arr_date[$i]; + } + + if(empty($day)) $day = date('d'); + if(empty($month)) $month = date('m'); + if(empty($year)) $year = date('Y'); + + @$timestamp = mktime( date("H"), date("i"), date("s"), $month, $day, $year); + return $timestamp; + } + + function convert_date_now ($data,$field) + { + return time(); + } + + function convert_md5 ($data,$field) + { + if($data != "") + return md5($data); + else + return ''; + } + + function convert_rc5 ($data,$field) + { + if($data != "") + return rc5($data); + else + return ''; + } + + function convert_sha ($data, $field) + { + if($data != "") + return sha1($data); + else + return ''; + } + + function convert_crypt ($data,$field) + { + if($data != "") + return crypt($data); + else + return ''; + } + + function convert_encrypt ($data,$field) + { + if($data != "") { + include_once(PATH_CORE.'crypt.inc.php'); + return CORE_encrypt ($data); + } + else + { + return ''; + } + } + + function convert_gpg ($data,$field) + { + if($data != "") + return gpg($data); + else + return ''; + } + + function convert_pgp ($data,$field) + { + if($data != "") + return pgp($data); + else + return ''; + } + + + function convert_array ($data,$field) + { + if($data != "") + return serialize($data); + else + return serialize(Array("")); + } + + function convert_html ($data,$field) + { + if($data == "") + return ""; + else + return htmlspecialchars($data);; + } + + + function validate($field, $arr, $data, $type) + { + if(isset($arr["min_len"])) + { + if($arr["min_len"] > 1) + { + global $C_translate; + if (strlen($data) < $arr["min_len"]) { + $C_translate->value["CORE"]["min_length"] = $arr["min_len"]; + $this->error[$field] = $C_translate->translate('validate_min_length','CORE',''); + return FALSE; + } + } + } + if(isset($arr["max_len"])) + { + if($arr["max_len"] > 1) + { + global $C_translate; + if (strlen($data) > $arr["max_len"]) { + $C_translate->value["CORE"]["max_length"] = $arr["max_len"]; + $this->error[$field] = $C_translate->translate('validate_max_length','CORE',''); + return FALSE; + } + } + } + + switch($type) + { + case "email": + return $this->validate_email ($data,$field); + break; + case "date": + return $this->validate_date ($data,$field); + break; + case "time": + return $this->validate_time ($data,$field); + break; + case "date-time": + return $this->validate_date_time ($data,$field); + break; + case "address": + return $this->validate_address ($data,$field); + break; + case "zip": + return $this->validate_zip ($data,$field); + break; + case "phone": + return $this->validate_phone ($data,$field); + break; + case "cc": + return $this->validate_cc ($data,$field, false, false); + break; + case "check": + return $this->validate_check ($data,$field); + break; + case "numeric": + return $this->validate_numeric ($data,$field); + break; + case "alphanumeric": + return $this->validate_alphanumeric ($data,$field); + break; + case "non_numeric": + return $this->validate_non_numeric ($data,$field); + break; + case "float": + return $this->validate_float ($data,$field); + break; + case "any": + return $this->validate_any ($data,$field); + break; + case "domain": + return $this->validate_domain ($data,$field); + break; + case "ip": + return $this->validate_ip ($data,$field); + break; + case "password": + return $this->validate_password ($data,$field); + break; + } + } + + + function validate_email($data,$field) + { + if(eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$", $data)) + { + return TRUE; + } + else + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_email','CORE',''); + return FALSE; + } + } + + + function validate_ip($data,$field) + { + $ip = $data; + $valid = TRUE; + + if(preg_match("/^((127)|(192)|(10).*)$/", "$ip")) { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_ip','CORE',''); + return FALSE; + } + + $ip = explode(".", $ip); + if(count($ip)!=4) { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_ip','CORE',''); + return FALSE; + } + + foreach($ip as $block) + if(!is_numeric($block) || $block>255 || $block<1) + $valid = FALSE; + + if($valid == FALSE) { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_ip','CORE',''); + return FALSE; + } else { + return TRUE; + } + } + + + function validate_domain($data,$field) + { + if (!preg_match('#^[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $data)) { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_domain','CORE',''); + return FALSE; + } else { + return true; + } + } + + + function validate_date($data,$field) + { + + if($data == '0' || $data == '') + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_date','CORE',''); + return false; + } + + $Arr_format = split(DEFAULT_DATE_DIVIDER, UNIX_DATE_FORMAT); + $Arr_date = split(DEFAULT_DATE_DIVIDER, $data); + + if(!gettype($Arr_date) == 'array' || count($Arr_date) != 3) + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_date','CORE',''); + return false; + } + + for($i=0; $i<3; $i++) + { + if($Arr_format[$i] == 'd') + $day = $Arr_date[$i]; + + if($Arr_format[$i] == 'm') + $month = $Arr_date[$i]; + + if($Arr_format[$i] == 'Y') + $year = $Arr_date[$i]; + } + + @$timestamp = mktime(0, 0, 0, $month, $day, $year); + + $check_ts = mktime(0,0,0,"1","1","1979"); + + if($timestamp >= $check_ts) + { + return true; + } + else + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_date','CORE',''); + return false; + } + } + + function validate_time($data,$field) + { + return TRUE; + } + + function validate_date_time($data,$field) + { + return TRUE; + } + + + function validate_address($data,$field) + { + if(@strlen($data) >= 2 && eregi('[0-9]{1,}', $data) && eregi('[a-z]{1,}', $data)) { + return TRUE; + } else { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_address','CORE',''); + return FALSE; + } + } + + + function validate_zip($data,$field) + { + if(@strlen($data) >= 4 && eregi('[0-9a-zA-Z-]{4,}', $data)) + { + return TRUE; + } + else + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_zip','CORE',''); + return FALSE; + } + } + + + function validate_phone($data,$field) + { + if(@strlen($data) > 9 && eregi('[0-9()-]{10,}', $data)) + { + return TRUE; + } + else + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_phone','CORE',''); + return FALSE; + } + } + + function validate_fax($data,$field) + { + if(@strlen($data) > 9 && eregi('[0-9()-]{10,}', $data)) + { + return TRUE; + } + else + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_fax','CORE',''); + return FALSE; + } + } + + function validate_check($data,$field) + { + return TRUE; + } + + + function validate_numeric($data,$field) + { + if(eregi("^[0-9]{1,}$", $data)) + { + return TRUE; + } + else + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_numeric','CORE',''); + return FALSE; + } + } + + function validate_alphanumeric($data,$field) + { + if(eregi("^[0-9a-zA-Z-]{1,}$", $data)) + { + return TRUE; + } + else + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_alphanumeric','CORE',''); + return FALSE; + } + } + + function validate_non_numeric($data,$field) + { + if(!eregi("[0-9]{1,}", $data)) + { + return TRUE; + } + else + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_non_numeric','CORE',''); + return FALSE; + } + } + + function validate_float($data,$field) + { + if(eregi("^[0-9\.]{1,}$", $data)) + { + return TRUE; + } + else + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_float','CORE',''); + return FALSE; + } + } + + function validate_any ($data,$field) + { + if($data != "") + { + return TRUE; + } + else + { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_any','CORE',''); + return FALSE; + } + } + + + function validate_unique ($table, $field, $id, $value) + { + if($value == '') return TRUE; + $db = &DB(); + $value = $db->qstr($value); + $q = "SELECT $field FROM ".AGILE_DB_PREFIX."$table WHERE $field = ".$value." "; + if($id != '' && $id != 'record_id') + $q .= "AND id != " . $db->qstr($id); + $q .= "AND site_id = " . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + if ($result === false) + { + global $C_debug; + $C_debug->error('validate.inc.php','validate_unique', $db->ErrorMsg()); + return FALSE; + } + else + { + if($result->RecordCount() == 0) + return TRUE; + else + return FALSE; + } + } + + function validate_cc_exp($month, $year) + { + if (eregi_replace("^0", "", $year) > eregi_replace("^0","", date("y"))) + return true; + elseif ( eregi_replace("^0","", $year) == eregi_replace("^0","", date("y")) && + eregi_replace("^0","", $month) >= eregi_replace("^0","", date("m"))) + return true; + else + return false; + } + + + function validate_cc( $ccNum, $field, $card_type, $card_type_accepted_arr ) + { + $v_ccNum = false; + + + if ($card_type == "visa" || !$card_type) { + // VISA + if ( ereg("^4[0-9]{12}([0-9]{3})?$", $ccNum) ) { + $v_ccNum = true; + $c_type = 'visa'; + } + } + else if ($card_type == "mc" || !$card_type) { + // MC + if ( ereg("^5[1-5][0-9]{14}$", $ccNum) ) { + $v_ccNum = true; + $c_type = 'mc'; + } + } + else if ($card_type == "amex" || !$card_type) { + // AMEX + if ( ereg("^3[47][0-9]{13}$", $ccNum) ) { + $v_ccNum = true; + $c_type = 'amex'; + } + } + else if ($card_type == "discover" || !$card_type) { + // DISCOVER + if ( ereg("^6011[0-9]{12}$", $ccNum) ) { + $v_ccNum = true; + $c_type = 'discover'; + } + } + else if ($card_type == "delta" || !$card_type) { + // DELTA ? + if ( eregi ( "^4(1373[3-7]|462[0-9]{2}|5397[8-9]|". + "54313|5443[2-5]|54742|567(2[5-9]|3[0-9]|4[0-5])|". + "658[3-7][0-9]|659(0[1-9]|[1-4][0-9]|50)|844(09|10)|". + "909[6-7][0-9]|9218[1-2]|98824)[0-9]{10}$" ) ) { + $v_ccNum = true; + $c_type = 'delta'; + } + } + else if ($card_type == "solo" || !$card_type) { + // SOLO ? + if ( ereg("^6(3(34[5-9][0-9])|767[0-9]{2})[0-9]{10}([0-9]{2,3})?$") ) { + $v_ccNum = true; + $c_type = 'solo'; + } + } + else if ($card_type == "switch" || !$card_type) { + // SWITCH ? + if ( ereg('^49(03(0[2-9]|3[5-9])|11(0[1-2]|7[4-9]|8[1-2])|36[0-9]{2})[0-9]{10}([0-9]{2,3})?$', $ccNum) || + ereg('^564182[0-9]{10}([0-9]{2,3})?$', $ccNum) || + ereg('^6(3(33[0-4][0-9])|759[0-9]{2})[0-9]{10}([0-9]{2,3})?$', $ccNum) ) { + $v_ccNum = true; + $c_type = 'switch'; + } + } + else if ($card_type == "jcb" || !$card_type) { + // JCB + if ( ereg("^(3[0-9]{4}|2131|1800)[0-9]{11}$", $ccNum) ) { + $v_ccNum = true; + $c_type = 'jcb'; + } + } + else if ($card_type == "diners" || !$card_type) { + // DINERS + if ( ereg("^3(0[0-5]|[68][0-9])[0-9]{11}$", $ccNum) ) { + $v_ccNum = true; + $c_type = 'diners'; + } + } + else if ($card_type == "carteblanche" || !$card_type) { + // CARTEBLANCHE + if ( ereg("^3(0[0-5]|[68][0-9])[0-9]{11}$", $ccNum) ) { + $v_ccNum = true; + $c_type = 'carteblanche'; + } + } + else if ($card_type == "enroute" || !$card_type) { + // ENROUTE + if (( (substr($ccNum, 0, 4) == "2014" || substr($ccNum, 0, 4) == "2149") && (strlen($ccNum) == 15) )) { + $v_ccNum = true; + $c_type = 'enroute'; + } + } + + // validate accepted card type + if ($card_type_accepted_arr != false & $v_ccNum) { + $v_ccNum = false; + for($i=0; $ierror[$field] = $C_translate->translate('validate_cc','CORE',''); + return FALSE; + } + } + + /** + * Strong password validation + */ + function validate_password($data, $field) { + + // force numbers and letters + if(!eregi("[0-9]{1,}", $data) || !eregi("[a-z]{1,}", $data)) { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_password','CORE',''); + return false; + } + + global $VAR; + $exclude = array(); + + // not in email eq to email + if(!empty($VAR['account_email'])) { + @$e=explode("@",$VAR['account_email']); + @$exclude[] = $e[0]; + @$exclude[] = $VAR['account_email']; + } elseif(!empty($VAR['account_admin_email'])) { + @$e=explode("@",$VAR['account_admin_email']); + @$exclude[] = $e[0]; + @$exclude[] = $VAR['account_admin_email']; + } + + // not eq to name (first or last) + @$exclude[] = $VAR['account_username']; + + @$exclude[] = $VAR['account_admin_username']; + @$exclude[] = $VAR['account_admin_first_name']; + @$exclude[] = $VAR['account_admin_last_name']; + + // not eq to initials + if(!empty($VAR['account_first_name']) && !empty($VAR['account_last_name'])) { + @$exclude[] = $VAR['account_first_name']; + @$exclude[] = $VAR['account_last_name']; + @$exclude[] = substr($VAR['account_first_name'], 0, 1) . substr($VAR['account_middle_name'], 0, 1). substr($VAR['account_last_name'], 0, 1); + } else if(!empty($VAR['account_admin_first_name']) && !empty($VAR['account_admin_last_name'])) { + @$exclude[] = $VAR['account_admin_first_name']; + @$exclude[] = $VAR['account_admin_last_name']; + @$exclude[] = substr($VAR['account_admin_first_name'], 0, 1) . substr($VAR['account_admin_middle_name'], 0, 1). substr($VAR['account_admin_last_name'], 0, 1); + } + + // check against data + foreach($exclude as $bad_data) { + if(!empty($bad_data) && eregi($bad_data,$data)) { + global $C_translate; + $this->error[$field] = $C_translate->translate('validate_password','CORE',''); + return false; + } + } + return true; + } + + function DateToEpoch($format,$date) + { + $Arr_format = split(DEFAULT_DATE_DIVIDER, UNIX_DATE_FORMAT); + $Arr_date = split(DEFAULT_DATE_DIVIDER, $date); + for($i=0; $i<3; $i++) + { + if($Arr_format[$i] == 'd') $day = $Arr_date[$i]; + if($Arr_format[$i] == 'm') $month = $Arr_date[$i]; + if($Arr_format[$i] == 'Y') $year = $Arr_date[$i]; + } + $timestamp = mktime(0, 0, 0, $month, $day, $year); + return $timestamp; + } + + function EpochToDate($epoch) + { + return date(UNIX_DATE_FORMAT,$epoch); + } +} +?> \ No newline at end of file diff --git a/modules/core/vars.inc.php b/modules/core/vars.inc.php new file mode 100644 index 00000000..de4c5969 --- /dev/null +++ b/modules/core/vars.inc.php @@ -0,0 +1,95 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_vars +{ + var $f; + function CORE_vars() + { + if (phpversion() >= "4.1.0") + { + global $_GET, $_POST; + if(isset($_GET) && count($_GET) > 0) + { + reset ( $_GET ); + while ( list ($key, $val) = each ( $_GET ) ) { + $newkey=ereg_replace ('amp;', '', $key ); + $this->f["$newkey"] = $val; + } + reset ( $_GET ); + } + if(isset($_POST) && count($_POST) > 0) + { + reset ( $_POST ); + while ( list ($key, $val) = each ( $_POST ) ) $this->f["$key"] = $val; + reset ( $_POST ); + } + } + else + { + global $HTTP_POST_VARS, $HTTP_GET_VARS; + if(isset($HTTP_POST_VARS) && count($HTTP_POST_VARS) > 0) + $this->f = $HTTP_POST_VARS; + elseif(isset($HTTP_GET_VARS) && count($HTTP_GET_VARS) > 0) + $this->f = $HTTP_GET_VARS; + } + + // set the shortcuts: + if(!isset($this->f["_page"])) + { + global $_PAGE_SHORTCUTS; + for($i=0; $if[$shortcut])) $this->f["_page"] = $_PAGE_SHORTCUTS[$i]["p"]; + } + } + + // mods for hardcoded vars in config/multi-site + global $hardcode; + if(is_array($hardcode)) { + foreach($hardcode as $hc) { + $this->f["{$hc[0]}"] = $hc[1]; + } + } + } + + function strip_slashes($arr) { + global $VAR; + if(get_magic_quotes_gpc()) { + for($i=0; $i$val) { + if(!is_array($val)) + $VAR["$key"] = htmlspecialchars(stripslashes($val)); + else + foreach($VAR["$key"] as $keya=>$vara) $VAR[$key][$keya] = htmlspecialchars(stripslashes($vara)); + } + } + } +} +?> \ No newline at end of file diff --git a/modules/core/version.inc.php b/modules/core/version.inc.php new file mode 100644 index 00000000..bcbcd7f2 --- /dev/null +++ b/modules/core/version.inc.php @@ -0,0 +1,76 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +$list = new CORE_list; + +# get version +$fp = @fopen(PATH_AGILE.'Version.txt', "r"); +if($fp) { + $ver = fread($fp, 255); + fclose($fp); +} else { + $ver = "SVN"; +} + +# get latest version +$fp = fopen('http://agileco.com/Version.txt', "r"); +$abv = fread($fp, 255); +fclose($fp); +# get encoding version +require_once('includes/pear/Compat/Function/file_get_contents.php'); +$tmp = file_get_contents(PATH_AGILE.'index.php'); + +if(eregi('ioncube', $tmp)) + $enc = 'ioncube'; +elseif(eregi('zend', $tmp)) + $enc = 'zend'; +else + $enc = 'ioncube'; + +# get installed optional modules: +$modules = Array ('affiliate' => Array ('affiliate', 'campaign', 'affiliate_commission', 'affiliate_template'), + 'charge' => Array ('charge'), + 'db_mapping' => Array ('db_mapping'), + 'email_queue' => Array ('email_queue'), + 'file' => Array ('file', 'file_category'), + 'faq' => Array ('faq','faq_translate', 'faq_category'), + 'htaccess' => Array ('htaccess', 'htaccess_dir', 'htaccess_exclude'), + 'import' => Array ('import'), + 'hosting' => Array ('host_server', 'host_registrar_plugin', 'host_tld'), + 'ticket' => Array ('ticket', 'ticket_department', 'ticket_message'), + 'login_share' => Array ('login_share'), + 'static_page' => Array ('static_page', 'static_page_category','static_page_translate') ); + +foreach($modules as $name => $m) { + foreach($m as $module) { + if( empty($avail["$name"]) && $list->is_installed( $module ) ) { + $avail["$name"] = true; + $module_arr[] = $name; + } + } +} + +# set smarty vars +global $smarty; +$smarty->assign('version',$ver); +$smarty->assign('ab_version',$abv); +$smarty->assign('encoding_version',$enc); +$smarty->assign('modules',@$module_arr); +?> \ No newline at end of file diff --git a/modules/core/weblog.inc.php b/modules/core/weblog.inc.php new file mode 100644 index 00000000..3d668b5f --- /dev/null +++ b/modules/core/weblog.inc.php @@ -0,0 +1,226 @@ + + * @package AgileBill + * @version 1.4.93 + */ + + +/** + * Weblog Handler Class + */ +class CORE_weblog +{ + /** + * Logs the sesson variables. + * + * @return void + * @since Version 1.0 + */ + + function CORE_weblog() + { + global $current_module, $VAR; + if ($current_module == '') + $module = ''; + else + $module = $current_module; + + if (!isset($VAR['_page']) || $VAR['_page'] == '') + { + $page = ''; + } + else + { + @$pagearr = split(':', $VAR['_page']); + @$page = $pagearr["1"]; + } + + ### browser type: + $arr_browser = $this->get_browser(); + $browser = $arr_browser["type"]. ' ' . $arr_browser["ver"]; + + ### product: + if (isset($VAR['prid'])) + $product = $VAR['prid']; + else + $product = ''; + + ### log the current hit to the database + $db = &DB(); + $id = $db->GenID(AGILE_DB_PREFIX . "" . 'weblog_id'); + $sql = "INSERT INTO ".AGILE_DB_PREFIX."weblog SET + id = ".$db->qstr($id).", + date_orig = ".$db->qstr(time()).", + site_id = ".$db->qstr(DEFAULT_SITE).", + session_id = ".$db->qstr(SESS).", + account_id = ".$db->qstr(SESS_ACCOUNT).", + affiliate_id= ".$db->qstr(SESS_AFFILIATE).", + reseller_id = ".$db->qstr(SESS_RESELLER).", + campaign_id = ".$db->qstr(SESS_CAMPAIGN).", + product_id = ".$db->qstr($product).", + module = ".$db->qstr($module).", + page = ".$db->qstr($page).", + referrer = ".$db->qstr($this->get_referrer()).", + browser = ".$db->qstr($browser).", + os = ".$db->qstr($this->get_os()); + $result = $db->Execute($sql); + + # error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('weblog.inc.php','weblog', $db->ErrorMsg()); + } + + return; + } + + + + + /** + * Gets the current referrer. + * + * @return void + * @since Version 1.0 + */ + + function get_referrer() + { + global $HTTP_REFERER, $_SERVER; + + if(@$HTTP_REFERER != "") + $re = @$HTTP_REFERER; + else + $re = @$_SERVER['HTTP_REFERER']; + + + if ($re != '') + { + if (URL != '') + { + if (eregi (URL, $re)) return; + } + if (SSL_URL != '') + { + if (eregi (SSL_URL, $re)) return; + } + } + + return $re; + } + + + /** + * Gets the current user's browser type. + * + * @return string + * @since Version 1.0 + */ + + function get_browser() + { + global $HTTP_USER_AGENT, $_SERVER; + + if(@$HTTP_USER_AGENT == "") @$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; + + $browser=array(); + if(@eregi("(opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}",$HTTP_USER_AGENT,$match) || @eregi("(opera/)([0-9]{1,2}.[0- 9]{1,3}){0,1}",$HTTP_USER_AGENT,$match)) + { + $browser['type']= "Opera"; + $browser['ver']=$match[2]; + } elseif(eregi("(konqueror)/([0-9]{1,2}.[0-9]{1,3})",$HTTP_USER_AGENT,$match)) { + $browser['type'] = "Konqueror"; + $browser['ver']=$match[2]; + } elseif(eregi("(lynx)/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})",$HTTP_USER_AGENT,$match)) { + $browser['type'] = "Lynx"; + $browser['ver']=$match[2]; + } elseif(eregi("(links) \(([0-9]{1,2}.[0-9]{1,3})",$HTTP_USER_AGENT,$match)) { + $browser['type'] = "Links"; + $browser['ver']=$match[2]; + } elseif(eregi("(msie) ([0-9]{1,2}.[0-9]{1,3})",$HTTP_USER_AGENT,$match)) { + $browser['type'] = "MSIE"; + $browser['ver']=$match[2]; + } elseif(eregi("(netscape6)/(6.[0-9]{1,3})",$HTTP_USER_AGENT,$match)) { + $browser['type'] = "Netscape"; + $browser['ver']=$match[2]; + } elseif(eregi("mozilla/5",$HTTP_USER_AGENT)) { + $browser['type'] = "Mozilla"; + $browser['ver']="Unknown"; + } elseif(eregi("(mozilla)/([0-9]{1,2}.[0-9]{1,3})",$HTTP_USER_AGENT,$match)) { + $browser['type'] = "Netscape "; + $browser['ver']=$match[2]; + } elseif(eregi("w3m",$HTTP_USER_AGENT)) { + $browser['type'] = "w3m"; + $browser['ver']="Unknown"; + } else { + $browser['type'] = "Unknown"; + $browser['ver']="Unknown"; + } + return $browser; + } + + /** + * Gets the current user's AGILE_OS type. + * + * @return string + * @since Version 1.0 + */ + function get_os() + { + global $HTTP_USER_AGENT, $_SERVER; + + if(@$HTTP_USER_AGENT == "") @$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; + + if(eregi("linux",$HTTP_USER_AGENT)) + { + $return = "Linux"; + } elseif(eregi("win32",$HTTP_USER_AGENT)) { + $return = "Windows"; + } elseif((eregi("(win)([0-9]{2})",$HTTP_USER_AGENT,$match)) || (eregi("(windows) ([0-9]{2})",$HTTP_USER_AGENT,$match))) { + $return = "Windows $match[2]"; + } elseif(eregi("(winnt)([0-9]{1,2}.[0-9]{1,2}){0,1}",$HTTP_USER_AGENT,$match)) { + $return = "Windows NT $match[2]"; + } elseif(eregi("(windows nt)( ){0,1}([0-9]{1,2}.[0-9]{1,2}){0,1}",$HTTP_USER_AGENT,$match)) { + $return = "Windows NT $match[3]"; + } elseif(eregi("mac",$HTTP_USER_AGENT)) { + $return = "Macintosh"; + } elseif(eregi("(sunos) ([0-9]{1,2}.[0-9]{1,2}){0,1}",$HTTP_USER_AGENT,$match)) { + $return = "SunOS $match[2]"; + } elseif(eregi("(beos) r([0-9]{1,2}.[0-9]{1,2}){0,1}",$HTTP_USER_AGENT,$match)) { + $return = "BeOS $match[2]"; + } elseif(eregi("freebsd",$HTTP_USER_AGENT)) { + $return = "FreeBSD"; + } elseif(eregi("openbsd",$HTTP_USER_AGENT)) { + $return = "OpenBSD"; + } elseif(eregi("irix",$HTTP_USER_AGENT)) { + $return = "IRIX"; + } elseif(eregi("os/2",$HTTP_USER_AGENT)) { + $return = "AGILE_OS/2"; + } elseif(eregi("plan9",$HTTP_USER_AGENT)) { + $return = "Plan9"; + } elseif(eregi("unix",$HTTP_USER_AGENT) || eregi("hp-ux",$HTTP_USER_AGENT)) { + $return = "Unix"; + } elseif(eregi("osf",$HTTP_USER_AGENT)) { + $return = "OSF"; + } else { + $return = "Unknown"; + } + return $return; + } +} +?> \ No newline at end of file diff --git a/modules/core/webmin.inc.php b/modules/core/webmin.inc.php new file mode 100644 index 00000000..83567eee --- /dev/null +++ b/modules/core/webmin.inc.php @@ -0,0 +1,228 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** + * Webmin Virtualmin Remote Class + */ +class WEBMIN +{ + var $host; + var $user; + var $pass; + var $debug; + var $reseller; + var $cookiepath; + + /* + * Check for Agilebill + */ + function WEBMIN() + { + if(!defined("PATH_FILES")) + { + echo "Dependancy Failure!"; + exit; + } + } + + + + + /* + * Get the unique domain id + */ + function sitenum() + { + $url = "{$this->user}:{$this->pass}@{$this->host}:{$this->port}"; + $cgi = $url.'/virtual-server/search.cgi'; + $post = "&field=dom&match=0&what={$this->domain}"; + $ret = $this->connect($cgi,$post); + preg_match ("/(edit_domain.cgi\?dom=).([0-9]{1,})('>$this->domain<)/i", $ret, $arr); + if(is_array($arr) && count($arr) > 0) { + $id = ereg_replace("('>$this->domain<)", "", ereg_replace("(edit_domain.cgi\?dom=)","", $arr[0])); + } else { + preg_match ("/(edit_domain.cgi\?dom=).([0-9]{1,})('>$this->domain<\/i><)/i", $ret, $arr); + if(is_array($arr) && count($arr) > 0) + $id = ereg_replace("('>$this->domain<)", "", ereg_replace("(edit_domain.cgi\?dom=)","", $arr[0])); + else + $id = false; + } + + if($this->debug) echo "

{$cgi}?{$post}
"; + + return $id; + } + + + /* + * Add a domain + */ + function add() + { + $url = "{$this->user}:{$this->pass}@{$this->host}:{$this->port}"; + $cgi = $url.'/virtual-server/domain_setup.cgi'; + $post = "parentuser=&to=&dom={$this->domain}&owner=Created+by+AB&email_def=0&email={$this->email}". + "&user_def=0&user={$this->username}&pass={$this->password}&mgroup_def=1&mgroup=&group_def=1&ip=". + "&group=&prefix_def=1&mailbox=0&template=0&mailboxlimit_def=1&mailboxlimit=&domslimit_def=1&domslimit=". + "&dir={{$this->prod['home_dir']}&unix={$this->prod['unix']}&dns={$this->prod['dns']}". + "&web={$this->prod['website']}&webalizer={$this->prod['webalizer']}&logrotate={$this->prod['logrotate']}". + "&mysql={$this->prod['mysql']}&webmin={$this->prod['webmin']}&virt={$this->prod['network_interface']}"; + + $ret = $this->connect($cgi,$post); + if($this->debug) echo "

{$cgi}?{$post}
"; + + if(!eregi("Failed", $ret)) + return true; + else + return false; + } + + + /* + * Edit the domain + */ + function edit() + { + /* + # get unique sitenum + $sitenum = $this->sitenum(); + if(!$sitenum) return false; + + $url = "{$this->user}:{$this->pass}@{$this->host}:{$this->port}"; + $cgi = $url.'/virtual-server/save_domain.cgi'; + $post = "dom={$sitenum}&virt=0&ip={$this->ip}&owner=Created+by+AB&email_def=0&email={$this->email}&passwd_def=1&passwd={$this->password}". + "&dir={{$this->prod['home_dir']}&unix={$this->prod['unix']}&dns={$this->prod['dns']}". + "&web={$this->prod['website']}&webalizer={$this->prod['webalizer']}&logrotate={$this->prod['logrotate']}". + "&mysql={$this->prod['mysql']}&webmin={$this->prod['webmin']}&virt={$this->prod['network_interface']}"; + + $ret = $this->connect($cgi,$post); + if($this->debug) echo "

{$cgi}?{$post}
"; + + + if(!eregi("Failed", $ret)) + return true; + else + return false; + */ + + return true; + } + + + /* + * Suspend account + */ + function suspend($dologin=true) + { + # get unique sitenum + $sitenum = $this->sitenum(); + if(!$sitenum) return false; + + $url = "{$this->user}:{$this->pass}@{$this->host}:{$this->port}"; + $cgi = $url.'/virtual-server/disable_domain.cgi'; + $post = "confirm=Yes, Disable It&dom={$sitenum}"; + + $ret = $this->connect($cgi,$post); + if($this->debug) echo "

{$cgi}?{$post}
"; + + if(!eregi("Failed", $ret)) + return true; + else + return false; + } + + + /* + * Unsuspend account + */ + function unsuspend($dologin=true) + { + # get unique sitenum + $sitenum = $this->sitenum(); + if(!$sitenum) return false; + + $url = "{$this->user}:{$this->pass}@{$this->host}:{$this->port}"; + $cgi = $url.'/virtual-server/enable_domain.cgi'; + $post = "confirm=Yes, Enable It&dom={$sitenum}"; + + $ret = $this->connect($cgi,$post); + if($this->debug) echo "

{$cgi}?{$post}
"; + + if(!eregi("Failed", $ret)) + return true; + else + return false; + } + + + /* + * Delete account + */ + function del() + { + # get unique sitenum + $sitenum = $this->sitenum(); + if(!$sitenum) return false; + + $url = "{$this->user}:{$this->pass}@{$this->host}:{$this->port}"; + $cgi = $url.'/virtual-server/delete_domain.cgi'; + $post = "confirm=Yes, Delete It&dom={$sitenum}"; + + $ret = $this->connect($cgi,$post); + if($this->debug) echo "

{$cgi}?{$post}
"; + + if(!eregi("Failed", $ret)) + return true; + else + return false; + } + + + + /* + * Curl connect + * + */ + function connect($url,$post) + { + if($this->ssl) + $url = 'https://'.$url; + else + $url = 'http://'.$url; + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + + #curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_VERBOSE, 1 ); + curl_setopt($ch, CURLOPT_HEADER, 1); + + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + + $data = curl_exec ($ch); + curl_close ($ch); + return $data; + } +} +?> \ No newline at end of file diff --git a/modules/core/xml.inc.php b/modules/core/xml.inc.php new file mode 100644 index 00000000..f3d2eb33 --- /dev/null +++ b/modules/core/xml.inc.php @@ -0,0 +1,271 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class CORE_xml +{ + function xml_to_array($file) + { + if (defined('AGILE_CORE_CACHE_DIR') && AGILE_CORE_CACHE_DIR != '') { + $tfile = AGILE_CORE_CACHE_DIR."xml-".md5($file); + if (file_exists($tfile)) { + #clearstatcache(); + #$mt = filemtime($file); + if (@filemtime($file) <= filemtime($tfile)) { + #echo "cached: $file
"; + return unserialize(file_get_contents($tfile)); + } + } + #echo "cache miss: $file
"; + } + if(!is_callable('simplexml_load_file') || !is_callable('dom_import_simplexml')) { + // call old XML to array class + $arr = xmlFileToArray($file, $includeTopTag = true, $lowerCaseTags = true); + } else { + // use SimpleXML class + if(!is_file($file)) return false; + $xml = simplexml_load_file ($file); + if(is_object($xml)) { + $dom = dom_import_simplexml ($xml); + $arr["$dom->tagName"] = SimpleXML2Array($xml); + } + } + if (defined('AGILE_CORE_CACHE_DIR') && AGILE_CORE_CACHE_DIR != '') { + $fp = fopen($tfile,"wb"); + if ($fp) { + fwrite($fp, serialize($arr)); + fclose($fp); + } + } + return $arr; + } + + function array_to_xml() { + } + + function xml_string_to_array($string) { + } +} + +// new XML to Array for PHP5 and SimpleXML +function SimpleXML2Array($xml) { + if (get_class($xml) == 'SimpleXMLElement') { + $attributes = $xml->attributes(); + foreach($attributes as $k=>$v) { + if ($v) $a[$k] = (string) $v; + } + $x = $xml; + $xml = get_object_vars($xml); + } + if (is_array($xml)) { + if (count($xml) == 0) return (string) $x; // for CDATA + foreach($xml as $key=>$value) { + $r[$key] = simplexml2array($value); + } + if (isset($a)) $r['@'] = $a; // Attributes + return $r; + } + return (string) $xml; +} + + +function & toString( $fileName ) +{ + if ($content_array = file($fileName)) + { + $file = implode("", $content_array); + return $file; + } + else + { + // Error + $false = false; + return $false; + } +} + + +function & xmlFileToArray($fileName, $includeTopTag = false, $lowerCaseTags = true) +{ + // Definition file not found + if (!file_exists($fileName)) + { + // Error + $false = false; + return $false; + } + $p = xml_parser_create(); + xml_parse_into_struct($p,toString($fileName),$vals,$index); + xml_parser_free($p); + $xml = array(); + $levels = array(); + $multipleData = array(); + $prevTag = ""; + $currTag = ""; + $topTag = false; + foreach ($vals as $val) + { + // Open tag + if ($val["type"] == "open") + { + if (!_xmlFileToArrayOpen($topTag, $includeTopTag, $val, $lowerCaseTags, + $levels, $prevTag, $multipleData, $xml)) + { + continue; + } + } + // Close tag + else if ($val["type"] == "close") + { + if (!_xmlFileToArrayClose($topTag, $includeTopTag, $val, $lowerCaseTags, + $levels, $prevTag, $multipleData, $xml)) + { + continue; + } + } + // Data tag + else if ($val["type"] == "complete" && isset($val["value"])) + { + $loc =& $xml; + foreach ($levels as $level) + { + $temp =& $loc[str_replace(":arr#", "", $level)]; + $loc =& $temp; + } + $tag = $val["tag"]; + if ($lowerCaseTags) + { + $tag = strtolower($val["tag"]); + } + $loc[$tag] = str_replace("\\n", "\n", $val["value"]); + } + // Tag without data + else if ($val["type"] == "complete") + { + _xmlFileToArrayOpen($topTag, $includeTopTag, $val, $lowerCaseTags, + $levels, $prevTag, $multipleData, $xml); + _xmlFileToArrayClose($topTag, $includeTopTag, $val, $lowerCaseTags, + $levels, $prevTag, $multipleData, $xml); + } + } + return $xml; +} + + + +function _xmlFileToArrayOpen(& $topTag, & $includeTopTag, & $val, & $lowerCaseTags, +& $levels, & $prevTag, & $multipleData, & $xml) +{ + // don't include top tag + if (!$topTag && !$includeTopTag) + { + $topTag = $val["tag"]; + return false; + } + $currTag = $val["tag"]; + if ($lowerCaseTags) + { + $currTag = strtolower($val["tag"]); + } + $levels[] = $currTag; + + // Multiple items w/ same name. Convert to array. + if ($prevTag === $currTag) + { + if (!array_key_exists($currTag, $multipleData) || + !$multipleData[$currTag]["multiple"]) + { + $loc =& $xml; + foreach ($levels as $level) + { + $temp =& $loc[$level]; + $loc =& $temp; + } + $loc = array($loc); + $multipleData[$currTag]["multiple"] = true; + $multipleData[$currTag]["multiple_count"] = 0; + } + $multipleData[$currTag]["popped"] = false; + $levels[] = ":arr#" . ++$multipleData[$currTag]["multiple_count"]; + } + else + { + $multipleData[$currTag]["multiple"] = false; + } + + // Add attributes array + if (array_key_exists("attributes", $val)) + { + $loc =& $xml; + foreach ($levels as $level) + { + $temp =& $loc[str_replace(":arr#", "", $level)]; + $loc =& $temp; + } + $keys = array_keys($val["attributes"]); + foreach ($keys as $key) + { + $tag = $key; + if ($lowerCaseTags) + { + $tag = strtolower($tag); + } + $loc["attributes"][$tag] = & $val["attributes"][$key]; + } + } + return true; +} + + +function _xmlFileToArrayClose(& $topTag, & $includeTopTag, & $val, & $lowerCaseTags, +& $levels, & $prevTag, & $multipleData, & $xml) +{ + // don't include top tag + if ($topTag && !$includeTopTag && $val["tag"] == $topTag) + { + return false; + } + if(isset($currTag)) + { + if (isset($multipleData[$currTag]["multiple"])) + { + $tkeys = array_reverse(array_keys($multipleData)); + foreach ($tkeys as $tkey) + { + if ($multipleData[$tkey]["multiple"] && !$multipleData[$tkey]["popped"]) + { + array_pop($levels); + $multipleData[$tkey]["popped"] = true; + break; + } + else if (!$multipleData[$tkey]["multiple"]) + { + break; + } + } + } + } + $prevTag = array_pop($levels); + if (strpos($prevTag, "arr#")) + { + $prevTag = array_pop($levels); + } + return true; +} +?> \ No newline at end of file diff --git a/modules/country/country.inc.php b/modules/country/country.inc.php new file mode 100644 index 00000000..d4ef9ffe --- /dev/null +++ b/modules/country/country.inc.php @@ -0,0 +1,126 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class country +{ + + # Open the constructor for this mod + function country() + { + # name of this module: + $this->module = "country"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/country/country_construct.xml b/modules/country/country_construct.xml new file mode 100644 index 00000000..aa59d06a --- /dev/null +++ b/modules/country/country_construct.xml @@ -0,0 +1,65 @@ + + + + country + + country
+ + + + 0 + + name + + 25 + + + + I4 + 1 + 1 + + + I4 + 1 + + + C(128) + 1 + 128 + any + 1 + + + C2(128) + + + C2(128) + + + C(16) + 2 + 2 + any + 1 + + + C(16) + 3 + 3 + any + 1 + + + + + id,site_id,name,description,notes,two_code,three_code + id,site_id,name,description,notes,two_code,three_code + id,site_id,name,description,notes,two_code,three_code + id,site_id,name,description,notes,two_code,three_code + id,site_id,name,description,notes,two_code,three_code + id,site_id,name,description,notes,two_code,three_code + + + 0 +
diff --git a/modules/country/country_install.xml b/modules/country/country_install.xml new file mode 100644 index 00000000..c319fda7 --- /dev/null +++ b/modules/country/country_install.xml @@ -0,0 +1,37 @@ + + + country + setup + + 1 + + + + + search + + + view + + + 1 + + + add + 1 + + + delete + + + update + + + search_form + + + search_show + + + + \ No newline at end of file diff --git a/modules/country/country_install_data.xml b/modules/country/country_install_data.xml new file mode 100644 index 00000000..51d1b342 --- /dev/null +++ b/modules/country/country_install_data.xml @@ -0,0 +1,1681 @@ + + + + 8 + 1 + Albania + AL + ALB + + + 10 + 1 + Antarctica + AQ + ATA + + + 12 + 1 + Algeria + DZ + DZA + + + 16 + 1 + American Samoa + AS + ASM + + + 20 + 1 + Andorra + AD + AND + + + 24 + 1 + Angola + AO + AGO + + + 28 + 1 + Antigua And Barbuda + AG + ATG + + + 31 + 1 + Azerbaijan + AZ + AZE + + + 32 + 1 + Argentina + AR + ARG + + + 36 + 1 + Australia + AU + AUS + + + 40 + 1 + Austria + AT + AUT + + + 44 + 1 + Bahamas + BS + BHS + + + 48 + 1 + Bahrain + BH + BHR + + + 50 + 1 + Bangladesh + BD + BGD + + + 51 + 1 + Armenia + AM + ARM + + + 52 + 1 + Barbados + BB + BRB + + + 56 + 1 + Belgium + BE + BEL + + + 60 + 1 + Bermuda + BM + BMU + + + 64 + 1 + Bhutan + BT + BTN + + + 68 + 1 + Bolivia + BO + BOL + + + 70 + 1 + Bosnia And Herzegowina + BA + BIH + + + 72 + 1 + Botswana + BW + BWA + + + 74 + 1 + Bouvet Island + BV + BVT + + + 76 + 1 + Brazil + BR + BRA + + + 84 + 1 + Belize + BZ + BLZ + + + 86 + 1 + British Indian Ocean Territory + IO + IOT + + + 90 + 1 + Solomon Islands + SB + SLB + + + 92 + 1 + Virgin Islands (british) + VG + VGB + + + 96 + 1 + Brunei Darussalam + BN + BRN + + + 100 + 1 + Bulgaria + BG + BGR + + + 104 + 1 + Myanmar + MM + MMR + + + 108 + 1 + Burundi + BI + BDI + + + 112 + 1 + Belarus + BY + BLR + + + 116 + 1 + Cambodia + KH + KHM + + + 120 + 1 + Cameroon + CM + CMR + + + 124 + 1 + Canada + CA + CAN + + + 132 + 1 + Cape Verde + CV + CPV + + + 136 + 1 + Cayman Islands + KY + CYM + + + 140 + 1 + Central African Republic + CF + CAF + + + 144 + 1 + Sri Lanka + LK + LKA + + + 148 + 1 + Chad + TD + TCD + + + 152 + 1 + Chile + CL + CHL + + + 156 + 1 + China + CN + CHN + + + 158 + 1 + Taiwan, Province Of China + TW + TWN + + + 162 + 1 + Christmas Island + CX + CXR + + + 166 + 1 + Cocos Islands + CC + CCK + + + 170 + 1 + Colombia + CO + COL + + + 174 + 1 + Comoros + KM + COM + + + 175 + 1 + Mayotte + YT + MYT + + + 178 + 1 + Congo + CG + COG + + + 180 + 1 + Congo, Democratic Republic Of + CD + COD + + + 184 + 1 + Cook Islands + CK + COK + + + 188 + 1 + Costa Rica + CR + CRI + + + 191 + 1 + Croatia + HR + HRV + + + 192 + 1 + Cuba + CU + CUB + + + 196 + 1 + Cyprus + CY + CYP + + + 203 + 1 + Czech Republic + CZ + CZE + + + 204 + 1 + Benin + BJ + BEN + + + 208 + 1 + Denmark + DK + DNK + + + 212 + 1 + Dominica + DM + DMA + + + 214 + 1 + Dominican Republic + DO + DOM + + + 218 + 1 + Ecuador + EC + ECU + + + 222 + 1 + El Salvador + SV + SLV + + + 226 + 1 + Equatorial Guinea + GQ + GNQ + + + 231 + 1 + Ethiopia + ET + ETH + + + 232 + 1 + Eritrea + ER + ERI + + + 233 + 1 + Estonia + EE + EST + + + 234 + 1 + Faroe Islands + FO + FRO + + + 238 + 1 + Falkland Islands + FK + FLK + + + 239 + 1 + + GS + SGS + + + 242 + 1 + Fiji + FJ + FJI + + + 246 + 1 + Finland + FI + FIN + + + 249 + 1 + France, Metropolitan + FX + FXX + + + 250 + 1 + France + FR + FRA + + + 254 + 1 + French Guiana + GF + GUF + + + 258 + 1 + French Polynesia + PF + PYF + + + 260 + 1 + French Southern Territories + TF + ATF + + + 262 + 1 + Djibouti + DJ + DJI + + + 266 + 1 + Gabon + GA + GAB + + + 268 + 1 + Georgia + GE + GEO + + + 270 + 1 + Gambia + GM + GMB + + + 275 + 1 + Palestinian Territory + P + + + 276 + 1 + Germany + DE + DEU + + + 288 + 1 + Ghana + GH + GHA + + + 292 + 1 + Gibraltar + GI + GIB + + + 296 + 1 + Kiribati + KI + KIR + + + 300 + 1 + Greece + GR + GRC + + + 304 + 1 + Greenland + GL + GRL + + + 308 + 1 + Grenada + GD + GRD + + + 312 + 1 + Guadeloupe + GP + GLP + + + 316 + 1 + Guam + GU + GUM + + + 320 + 1 + Guatemala + GT + GTM + + + 324 + 1 + Guinea + GN + GIN + + + 328 + 1 + Guyana + GY + GUY + + + 332 + 1 + Haiti + HT + HTI + + + 334 + 1 + Heard And Mc Donald Islands + HM + HMD + + + 336 + 1 + Holy See (Vatican City State) + VA + VAT + + + 340 + 1 + Honduras + HN + HND + + + 344 + 1 + Hong Kong + HK + HKG + + + 348 + 1 + Hungary + HU + HUN + + + 352 + 1 + Iceland + IS + ISL + + + 356 + 1 + India + IN + IND + + + 360 + 1 + Indonesia + ID + IDN + + + 364 + 1 + Iran + IR + IRN + + + 368 + 1 + Iraq + IQ + IRQ + + + 372 + 1 + Ireland + IE + IRL + + + 376 + 1 + Israel + IL + ISR + + + 380 + 1 + Italy + IT + ITA + + + 384 + 1 + + CI + CIV + + + 388 + 1 + Jamaica + JM + JAM + + + 392 + 1 + Japan + JP + JPN + + + 398 + 1 + Kazakhstan + KZ + KAZ + + + 400 + 1 + Jordan + JO + JOR + + + 404 + 1 + Kenya + KE + KEN + + + 408 + 1 + + KP + PRK + + + 410 + 1 + Korea, Republic Of + KR + KOR + + + 414 + 1 + Kuwait + KW + KWT + + + 417 + 1 + Kyrgyzstan + KG + KGZ + + + 418 + 1 + + LA + LAO + + + 422 + 1 + Lebanon + LB + LBN + + + 426 + 1 + Lesotho + LS + LSO + + + 428 + 1 + Latvia + LV + LVA + + + 430 + 1 + Liberia + LR + LBR + + + 434 + 1 + Libyan Arab Jamahiriya + LY + LBY + + + 438 + 1 + Liechtenstein + LI + LIE + + + 440 + 1 + Lithuania + LT + LTU + + + 442 + 1 + Luxembourg + LU + LUX + + + 446 + 1 + Macau + MO + MAC + + + 450 + 1 + Madagascar + MG + MDG + + + 454 + 1 + Malawi + MW + MWI + + + 458 + 1 + Malaysia + MY + MYS + + + 462 + 1 + Maldives + MV + MDV + + + 466 + 1 + Mali + ML + MLI + + + 470 + 1 + Malta + MT + MLT + + + 474 + 1 + Martinique + MQ + MTQ + + + 478 + 1 + Mauritania + MR + MRT + + + 480 + 1 + Mauritius + MU + MUS + + + 484 + 1 + Mexico + MX + MEX + + + 492 + 1 + Monaco + MC + MCO + + + 496 + 1 + Mongolia + MN + MNG + + + 498 + 1 + Moldova, Republic Of + MD + MDA + + + 500 + 1 + Montserrat + MS + MSR + + + 504 + 1 + Morocco + MA + MAR + + + 508 + 1 + Mozambique + MZ + MOZ + + + 512 + 1 + Oman + OM + OMN + + + 516 + 1 + Namibia + NA + NAM + + + 520 + 1 + Nauru + NR + NRU + + + 524 + 1 + Nepal + NP + NPL + + + 528 + 1 + Netherlands + NL + NLD + + + 530 + 1 + Netherlands Antilles + AN + ANT + + + 533 + 1 + Aruba + AW + ABW + + + 540 + 1 + New Caledonia + NC + NCL + + + 548 + 1 + Vanuatu + VU + VUT + + + 554 + 1 + New Zealand + NZ + NZL + + + 558 + 1 + Nicaragua + NI + NIC + + + 562 + 1 + Niger + NE + NER + + + 566 + 1 + Nigeria + NG + NGA + + + 570 + 1 + Niue + NU + NIU + + + 574 + 1 + Norfolk Island + NF + NFK + + + 578 + 1 + Norway + NO + NOR + + + 580 + 1 + Northern Mariana Islands + MP + MNP + + + 581 + 1 + United States Outlying Islands + UM + UMI + + + 583 + 1 + Micronesia + FM + FSM + + + 584 + 1 + Marshall Islands + MH + MHL + + + 585 + 1 + Palau + PW + PLW + + + 586 + 1 + Pakistan + PK + PAK + + + 591 + 1 + Panama + PA + PAN + + + 598 + 1 + Papua New Guinea + PG + PNG + + + 600 + 1 + Paraguay + PY + PRY + + + 604 + 1 + Peru + PE + PER + + + 608 + 1 + Philippines + PH + PHL + + + 612 + 1 + Pitcairn + PN + PCN + + + 616 + 1 + Poland + PL + POL + + + 620 + 1 + Portugal + PT + PRT + + + 624 + 1 + Guinea-bissau + GW + GNB + + + 626 + 1 + East Timor + TP + TMP + + + 630 + 1 + Puerto Rico + PR + PRI + + + 634 + 1 + Qatar + QA + QAT + + + 638 + 1 + Reunion + RE + REU + + + 642 + 1 + Romania + RO + ROM + + + 643 + 1 + Russian Federation + RU + RUS + + + 646 + 1 + Rwanda + RW + RWA + + + 654 + 1 + St. Helena + SH + SHN + + + 659 + 1 + Saint Kitts And Nevis + KN + KNA + + + 660 + 1 + Anguilla + AI + AIA + + + 662 + 1 + Saint Lucia + LC + LCA + + + 666 + 1 + St. Pierre And Miquelon + PM + SPM + + + 670 + 1 + Saint Vincent / Grenadines + VC + VCT + + + 674 + 1 + San Marino + SM + SMR + + + 678 + 1 + Sao Tome And Principe + ST + STP + + + 682 + 1 + Saudi Arabia + SA + SAU + + + 686 + 1 + Senegal + SN + SEN + + + 690 + 1 + Seychelles + SC + SYC + + + 694 + 1 + Sierra Leone + SL + SLE + + + 702 + 1 + Singapore + SG + SGP + + + 703 + 1 + Slovakia (Slovak Republic) + SK + SVK + + + 704 + 1 + Viet Nam + VN + VNM + + + 705 + 1 + Slovenia + SI + SVN + + + 706 + 1 + Somalia + SO + SOM + + + 710 + 1 + South Africa + ZA + ZAF + + + 716 + 1 + Zimbabwe + ZW + ZWE + + + 724 + 1 + Spain + ES + ESP + + + 732 + 1 + Western Sahara + EH + ESH + + + 736 + 1 + Sudan + SD + SDN + + + 740 + 1 + Suriname + SR + SUR + + + 744 + 1 + Svalbard And Jan Mayen Islands + SJ + SJM + + + 748 + 1 + Swaziland + SZ + SWZ + + + 752 + 1 + Sweden + SE + SWE + + + 756 + 1 + Switzerland + CH + CHE + + + 760 + 1 + Syrian Arab Republic + SY + SYR + + + 762 + 1 + Tajikistan + TJ + TJK + + + 764 + 1 + Thailand + TH + THA + + + 768 + 1 + Togo + TG + TGO + + + 772 + 1 + Tokelau + TK + TKL + + + 776 + 1 + Tonga + TO + TON + + + 780 + 1 + Trinidad And Tobago + TT + TTO + + + 784 + 1 + United Arab Emirates + AE + ARE + + + 788 + 1 + Tunisia + TN + TUN + + + 792 + 1 + Turkey + TR + TUR + + + 795 + 1 + Turkmenistan + TM + TKM + + + 796 + 1 + Turks And Caicos Islands + TC + TCA + + + 798 + 1 + Tuvalu + TV + TUV + + + 800 + 1 + Uganda + UG + UGA + + + 804 + 1 + Ukraine + UA + UKR + + + 807 + 1 + Macedonia, Republic Of + MK + MKD + + + 818 + 1 + Egypt + EG + EGY + + + 826 + 1 + United Kingdom + GB + GBR + + + 834 + 1 + Tanzania, United Republic Of + TZ + TZA + + + 840 + 1 + United States + US + USA + + + 850 + 1 + Virgin Islands (U.S.) + VI + VIR + + + 854 + 1 + Burkina Faso + BF + BFA + + + 858 + 1 + Uruguay + UY + URY + + + 860 + 1 + Uzbekistan + UZ + UZB + + + 862 + 1 + Venezuela + VE + VEN + + + 876 + 1 + Wallis And Futuna Islands + WF + WLF + + + 882 + 1 + Samoa + WS + WSM + + + 887 + 1 + Yemen + YE + YEM + + + 891 + 1 + Yugoslavia + YU + YUG + + + 894 + 1 + Zambia + ZM + ZMB + + + 7 + + + 1000 + + \ No newline at end of file diff --git a/modules/currency/currency.inc.php b/modules/currency/currency.inc.php new file mode 100644 index 00000000..3235a2f1 --- /dev/null +++ b/modules/currency/currency.inc.php @@ -0,0 +1,128 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class currency +{ + + # Open the constructor for this mod + function currency() + { + # name of this module: + $this->module = "currency"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + # this function removed in v1.4.2 + return false; + + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/currency/currency_construct.xml b/modules/currency/currency_construct.xml new file mode 100644 index 00000000..6e44d668 --- /dev/null +++ b/modules/currency/currency_construct.xml @@ -0,0 +1,68 @@ + + + + currency + + currency
+ + + + 0 + + name + + 25 + + + + I4 + 1 + 1 + + + I4 + 1 + + + C(128) + 1 + 128 + any + 1 + + + L + + + X2 + array + + + C2(128) + + + C(16) + 1 + 16 + any + + + C(3) + 3 + 3 + any + 1 + + + + + id,site_id,name,convert_array,status,notes,symbol,three_digit + id,site_id,name,convert_array,status,notes,symbol,three_digit + id,site_id,name,convert_array,status,notes,symbol,three_digit + id,site_id,name,convert_array,status,notes,symbol,three_digit + id,site_id,name,convert_array,status,notes,symbol,three_digit + id,site_id,name,convert_array,status,notes,symbol,three_digit + + + 0 +
diff --git a/modules/currency/currency_install.xml b/modules/currency/currency_install.xml new file mode 100644 index 00000000..e3fc263e --- /dev/null +++ b/modules/currency/currency_install.xml @@ -0,0 +1,36 @@ + + + currency + setup + + 1 + + + + + search + + + view + + + 1 + + + add + + 1 + + + delete + + + update + + + search_show + + + + + \ No newline at end of file diff --git a/modules/currency/currency_install_data.xml b/modules/currency/currency_install_data.xml new file mode 100644 index 00000000..52dbe65b --- /dev/null +++ b/modules/currency/currency_install_data.xml @@ -0,0 +1,128 @@ + + + + 1 + 1 + United States Dollars + 1 + + Notes + $ + USD + + + 3 + 1 + Japanese Yen + 0 + + ¥ + JPY + + + 4 + 1 + United Kingdom Pounds + 0 + + £ + GBP + + + 5 + 1 + Canada Dollars + 0 + + $ + CAD + + + 6 + 1 + Australia Dollars + 0 + + $ + AUD + + + 7 + 1 + Switzerland Francs + $ + CHF + + + 8 + 1 + Denmark Kroner + 0 + + ¤ + DKK + + + 9 + 1 + Hong Kong Dollars + $ + HKD + + + 10 + 1 + Norway Kroner + ¤ + NOK + + + 11 + 1 + Sweden Kroner + ¤ + SEK + + + 12 + 1 + New Zealand Dollars + $ + NZD + + + 13 + 1 + Russian Rubles + $ + RUR + + + 14 + 1 + South Africa Rand + $ + ZAR + + + 15 + 1 + Mexican Pesos + 0 + + $ + MXN + + + 16 + 1 + Euro + 0 + + + EUR + + + 16 + + \ No newline at end of file diff --git a/modules/db_mapping/db_mapping.inc.php b/modules/db_mapping/db_mapping.inc.php new file mode 100644 index 00000000..09b86e2d --- /dev/null +++ b/modules/db_mapping/db_mapping.inc.php @@ -0,0 +1,2079 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class db_mapping +{ + var $sync_limit=100; + + # Open the constructor for this mod + function construct() + { + # name of this module: + $this->module = "db_mapping"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + ######################################################################## + ### Syncronize all accounts & groups + ######################################################################## + + function sync($VAR) + { + $id = @$VAR['id']; + $db = &DB(); + $sql= 'SELECT * FROM '.AGILE_DB_PREFIX.'db_mapping WHERE id = '.$db->qstr(@$VAR["id"]).' AND site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) { + global $C_debug; + $C_debug->error('db_mapping.inc.php','sync', $db->ErrorMsg()); + echo $db->ErrorMsg(); + return; + } + + $file = $result->fields['map_file']; + $group_map = $result->fields['group_map']; + + if($file != '') + { + include_once(PATH_PLUGINS . 'db_mapping/'. $file.'.php'); + eval ( '$_MAP = new map_'. strtoupper ( $file ) . ';' ); + $_MAP->sync($id, $file); + return true; + } + return false; + } + + + + + + ############################## + ## Connect to the remote db # + ############################## + + function &DB_connect($id, $map_file) + { + + ### Get the variables for this map plugin: + $db = &DB(); + $sql= 'SELECT * FROM '.AGILE_DB_PREFIX.'db_mapping WHERE '; + + if($id) + $sql .= ' id = '.$db->qstr($id).' AND '; + else if($map_file) + $sql .= ' map_file = '.$db->qstr($map_file).' AND '; + + $sql .= ' site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + if ($result === false) { + global $C_debug; + $C_debug->error('db_mapping.inc.php','DB_connect', $db->ErrorMsg()); return; + } + + $file = $result->fields['map_file']; + if($file != '') + { + include_once(PATH_PLUGINS . 'db_mapping/'. $file.'.php'); + eval ( '$_MAP = new map_'. strtoupper ( $file ) . ';' ); + + ### Get the DB settings + $db_name = $result->fields['db_name']; + $db_host = $result->fields['db_host']; + $db_prefix = $result->fields['db_prefix']; + $db_user = $result->fields['db_user']; + $db_pass = $result->fields['db_pass']; + @$db_type = $_MAP->map['db_type']; + + if($db_host == '*') $db_host = AGILE_DB_HOST; + if($db_user == '*') $db_user = AGILE_DB_USERNAME; + if($db_pass == '*') $db_pass = AGILE_DB_PASSWORD; + if($db_type == '') $db_type = 'mysql'; + + $const = 'DB2_PREFIX' . strtoupper($file); + if(!defined($const)) eval ( 'define ("'.$const.'", "'.$db_prefix.'");' ); + + $this->db_prefix = $db_prefix; + + ### Connect to the remote Db; + $ADODB = &NewADOConnection($db_type); + $ADODB->Connect($db_host, $db_user, $db_pass, $db_name); + $ADODB_FETCH_MODE = 'ADODB_FETCH_ASSOC'; + return $ADODB; + } + return false; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $this->construct(); + global $C_translate; + + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + + # set the field list for this method: + $arr = $this->method["$type"]; + + # define the validation class + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + $this->validated = true; + + + #################################################################### + # loop through the field list to validate the required fields + #################################################################### + + while (list ($key, $value) = each ($arr)) + { + # get the field value + $field_var = $this->module . '_' . $value; + $field_name = $value; + $this->validate = true; + + #################################################################### + # perform any field validation... + #################################################################### + + # check if this value is unique + if(isset($this->field["$value"]["unique"]) && isset($VAR["$field_var"])) + { + if(!$validate->validate_unique($this->table, $field_name, "record_id", $VAR["$field_var"])) + { + $this->validated = false; + $this->val_error[] = array('field' => $this->table . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), # translate + 'error' => $C_translate->translate('validate_unique',"", "")); + } + } + + # check if the submitted value meets the specifed requirements + if(isset($this->field["$value"]["validate"])) + { + if(isset($VAR["$field_var"])) + { + if($VAR["$field_var"] != '') + { + if(!$validate->validate($field_name, $this->field["$value"], $VAR["$field_var"], $this->field["$value"]["validate"])) + { + $this->validated = false; + $this->val_error[] = array('field' => $this->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), + 'error' => $validate->error["$field_name"] ); + } + } + else + { + $this->validated = false; + $this->val_error[] = array('field' => $this->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), + 'error' => $C_translate->translate('validate_any',"", "")); + } + } + else + { + $this->validated = false; + $this->val_error[] = array('field' => $this->module . '_' . $field_name, + 'field_trans' => $C_translate->translate('field_' . $field_name, $this->module, ""), + 'error' => $C_translate->translate('validate_any',"", "")); + } + } + } + + + + + #################################################################### + # If validation was failed, skip the db insert & + # set the errors & origonal fields as Smarty objects, + # and change the page to be loaded. + #################################################################### + + if(!$this->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $this->val_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page_current']); + } + + # define any triggers + if(isset($this->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + + return; + } + else + { + # begin the new database class: + $db = &DB(); + + + # loop through the field list to create the sql queries + $field_list = ''; + $i = 0; + reset($arr); + while (list ($key, $value) = each ($arr)) + { + # get the field value + $field_var = $this->module . '_' . $value; + $field_name = $value; + + #################################################################### + # perform any special actions + #################################################################### + # md5, rc5, pgp, gpg, time, date, date-time + + if(isset($this->field["$value"]["convert"]) && isset($VAR["$field_var"])) + { + # do the conversion... + $VAR["$field_var"] = $validate->convert($field_name, $VAR["$field_var"], $this->field["$value"]["convert"]); + } + + + if(isset($VAR["$field_var"])) + { + $field_list .= ", " . $value . "=" . $db->qstr($VAR["$field_var"]); + } + } + + # add a comma before the site_id if needed + if($field_list != '') + { + $field_list .= ','; + } + + # determine the record id: + $this->record_id = $db->GenID(AGILE_DB_PREFIX . "" . $this->table.'_id'); + + # determine the record id, if it is an ACCOUNT record + if($this->table == 'account') $this->record_id = md5($this->record_id . '' . microtime()); + + # define the new ID as a constant + define(strtoupper('NEW_RECORD_'.$this->table.'_ID'), $this->record_id); + + # generate the full query + $q = "INSERT INTO ".AGILE_DB_PREFIX."$this->table + SET + id = ". $db->qstr($this->record_id)." + $field_list + site_id = " . $db->qstr(DEFAULT_SITE); + + # execute the query + $result = $db->Execute($q); + + # error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('database.inc.php','add', $db->ErrorMsg()); + + if(isset($this->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + } + + + $VAR["id"] = $this->record_id; + @$redirect_page = $VAR['_page']; + define('REDIRECT_PAGE', '?_page=' . $redirect_page . '&id=' . $this->record_id . '&s=' . SESS); + + # RUN ANY INSTALL SCRIPT! + $file = $VAR['db_mapping_map_file']; + if($file != '') + { + include_once (PATH_PLUGINS . 'db_mapping/'. $file.'.php'); + eval ( '$_MAP = new map_'. strtoupper ( $file ) . ';' ); + + if ( isset($_MAP->map['install']) && $_MAP->map['install'] == true) + { + $_MAP->install(); + } + } + } + } + + + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + global $smarty; + $this->construct(); + + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + + ### Define the group mapping.... + $id = @$VAR['id']; + + ### Get the variables for this map plugin: + $db = &DB(); + $sql= 'SELECT * FROM '.AGILE_DB_PREFIX.'db_mapping WHERE + id = '.$db->qstr(@$VAR["id"]).' AND + site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) { global $C_debug; + $C_debug->error('db_mapping.inc.php','view', $db->ErrorMsg()); return; + } + + $file = $result->fields['map_file']; + + $group_map = $result->fields['group_map']; + if($group_map != '') + $group_map = unserialize ( $group_map ); + else + $group_map = Array(); + + if($file != '') + { + include_once (PATH_PLUGINS . 'db_mapping/'. $file.'.php'); + eval ( '$_MAP = new map_'. strtoupper ( $file ) . ';' ); + + ### If this map type is 'db' groups based: + if ($_MAP->map['group_type'] == 'db' || $_MAP->map['group_type'] == 'db-status') + { + ### Connect to the DB & get the groups: + $dbm = new db_mapping; + $db = $dbm->DB_connect($id, 'false'); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($file) .';' ); + $sql = "SELECT * FROM " . $db_prefix . "" . $_MAP->map['group_map']['table'] . " + ORDER BY " . $_MAP->map['group_map']['name']; + $db2 = $db->Execute($sql); + if ($db2 === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','view', $db->ErrorMsg()); + $smarty->assign('db_mapping_result', $db->ErrorMsg()); + return; + } + + ### get the remote groups... + if($db2->RecordCount() > 0) + { + + + $i=0; + while ( !$db2->EOF ) + { + $smart[$i]['id'] = $db2->fields[$_MAP->map['group_map']['id']]; + $smart[$i]['name'] = $db2->fields[$_MAP->map['group_map']['name']]; + $db2->MoveNext(); + $i++; + } + + ### Get the local groups: + $db = &DB(); + $sql = 'SELECT * FROM '.AGILE_DB_PREFIX.'group WHERE + site_id = '.$db->qstr(DEFAULT_SITE).' + ORDER BY name'; + $groups = $db->Execute($sql); + if ($groups === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','view', $db->ErrorMsg()); + return; + } + + if($groups->RecordCount() > 0) + { + $i=0; + while ( !$groups->EOF ) + { + $id = $groups->fields['id']; + $smartgr[$i]['id'] = $groups->fields['id']; + $smartgr[$i]['name'] = $groups->fields['name']; + + + for($ii=0; $iiMoveNext(); + $i++; + } + + ### Define smarty vars + $smarty->assign('db_mapping_result', false); + $smarty->assign('db_mapping_template', 'db_mapping:group_map_' . $_MAP->map['group_type']); + $smarty->assign('db_mapping_groups', $smartgr); + } + else + { + global $C_translate; + $message = $C_translate->translate('no_local_groups','db_mapping',''); + $smarty->assign('db_mapping_result', $message); + } + } + else + { + global $C_translate; + $message = $C_translate->translate('no_remote_groups','db_mapping',''); + $smarty->assign('db_mapping_result', $message); + } + } + elseif ( $_MAP->map['group_type'] == 'status' ) + { + ### This is at 'status' based database map + + ### Get the local groups: + $db = &DB(); + $sql = 'SELECT * FROM '.AGILE_DB_PREFIX.'group WHERE + site_id = '.$db->qstr(DEFAULT_SITE).' + ORDER BY name'; + $groups = $db->Execute($sql); + ### error reporting: + if ($groups === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','view', $db->ErrorMsg()); return; + } + if($groups->RecordCount() > 0) + { + $i=0; + while ( !$groups->EOF ) + { + $id = $groups->fields['id']; + $smart[$i]['id'] = $groups->fields['id']; + $smart[$i]['name'] = $groups->fields['name']; + @$smart[$i]['value'] = $group_map[$id]; + $groups->MoveNext(); + $i++; + } + } + + + ### Assign the smarty vars: + $smarty->assign('db_mapping_result', false); + $smarty->assign('db_mapping_template', 'db_mapping:group_map_status'); + $smarty->assign('db_mapping_groups', $smart); + } + else + { + ### No group mapping for this database map + global $C_translate; + $message = $C_translate->translate('no_group_mapping','db_mapping',''); + $smarty->assign('db_mapping_result', $message); + } + } + else + { + global $C_translate; + $message = $C_translate->translate('file_error','db_mapping',''); + $smarty->assign('db_mapping_result', $message); + } + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $this->construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $this->construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $this->construct(); + + ### Read the contents of the /plugins/db_mapping directory: + $count = 0; + chdir(PATH_PLUGINS . 'db_mapping'); + $dir = opendir(PATH_PLUGINS . 'db_mapping'); + while ($file_name = readdir($dir)) + { + if($file_name != '..' && $file_name != '.') + { + $count++; + } + } + + # define the DB vars as a Smarty accessible block + global $smarty; + + # create the search record: + if($count > 0) + { + # create the search record + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $arr['module'] = $this->module; + $arr['sql'] = ''; + $arr['limit'] = '999'; + $arr['order_by']= 'name'; + $arr['results'] = $count; + $search->add($arr); + + # define the search id and other parameters for Smarty + $smarty->assign('search_id', $search->id); + + # page: + $smarty->assign('page', '1'); + + # limit: + $smarty->assign('limit', '999'); + + # order_by: + $smarty->assign('order_by', 'name'); + + # define the result count + $smarty->assign('results', $count); + } + } + + + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $this->construct(); + + ### Read the contents of the /plugins/db_mapping directory: + $count = 0; + chdir(PATH_PLUGINS . 'db_mapping'); + $dir = opendir(PATH_PLUGINS . 'db_mapping'); + while ($file_name = readdir($dir)) + { + if($file_name != '..' && $file_name != '.') + { + $result[$count]['name'] = eregi_replace('.php', '', $file_name); + $result[$count]['id'] = $count; + + ### Get the status of this plugin: + $db = &DB(); + $q = 'SELECT status,id FROM '.AGILE_DB_PREFIX.'db_mapping WHERE + map_file = '. $db->qstr($result[$count]['name']) . ' AND + site_id = '. $db->qstr(DEFAULT_SITE); + $dbmap = $db->Execute($q); + + ### error reporting: + if ($dbmap === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','search_show', $db->ErrorMsg()); return; + } + + if($dbmap->RecordCount() > 0) + { + $result[$count]['id'] = $dbmap->fields['id']; + $result[$count]['status'] = 1; + $result[$count]['active'] = $dbmap->fields['status']; + } else { + $result[$count]['status'] = 0; + } + + $count++; + } + } + + + + + $class_name = TRUE; + for ($i=0; $iassign($this->table, $smart); + $smarty->assign('page', $VAR['page']); + $smarty->assign('order', $smarty_order); + $smarty->assign('sort', $smarty_sort); + $smarty->assign('limit', $search->limit); + $smarty->assign('search_id',$search->id); + $smarty->assign('results', $count); + + # total pages + $smarty->assign('pages', 1); + + # current page + $smarty->assign('page', 1); + $page_arr = ''; + + # page array for menu + $smarty->assign('page_arr', $page_arr); + } + + + + + + +################################################################################ +# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +################################################################################ + + + ######################################################################## + ### Add a new account to the remote db + ######################################################################## + + function account_add ( $account_id ) + { + $db = &DB(); + $sql= 'SELECT * FROM '.AGILE_DB_PREFIX.'db_mapping WHERE + status = '.$db->qstr(1).' AND + site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','account_add', $db->ErrorMsg()); + return; + } + + while ( !$result->EOF ) + { + $file = $result->fields['map_file']; + $id = $result->fields['id']; + if($file != '') + { + include_once (PATH_PLUGINS . 'db_mapping/'. $file.'.php'); + eval ( '$_MAP = new map_'. strtoupper ( $file ) . ';' ); + $_MAP->plaintext_password = $this->plaintext_password; + $_MAP->account_add ( $account_id ); + unset ($_MAP); + } + $result->MoveNext(); + } + } + + + + + + + + ######################################################################## + ### Edit an existing account in the remote db + ######################################################################## + + function account_edit ( $account_id, $old_username ) + { + $db = &DB(); + $sql= 'SELECT * FROM '.AGILE_DB_PREFIX.'db_mapping WHERE + status = '.$db->qstr(1).' AND + site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','account_edit', $db->ErrorMsg()); + return; + } + + while ( !$result->EOF ) + { + $file = $result->fields['map_file']; + $id = $result->fields['id']; + if($file != '') + { + include_once (PATH_PLUGINS . 'db_mapping/'. $file.'.php'); + eval ( '$_MAP = new map_'. strtoupper ( $file ) . ';' ); + $_MAP->plaintext_password = $this->plaintext_password; + $_MAP->account_edit ( $account_id, $old_username ); + unset ($_MAP); + } + $result->MoveNext(); + } + } + + + + + + + + + + ######################################################################## + ### Delete an account from the remote db + ######################################################################## + + function account_delete ( $account_id, $username ) + { + $db = &DB(); + $sql= 'SELECT * FROM '.AGILE_DB_PREFIX.'db_mapping WHERE + status = '.$db->qstr(1).' AND + site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','account_delete', $db->ErrorMsg()); + return; + } + + while ( !$result->EOF ) + { + $file = $result->fields['map_file']; + $id = $result->fields['id']; + if($file != '') + { + include_once (PATH_PLUGINS . 'db_mapping/'. $file.'.php'); + eval ( '$_MAP = new map_'. strtoupper ( $file ) . ';' ); + $_MAP->account_delete ( $account_id, $username ); + unset ($_MAP); + } + $result->MoveNext(); + } + } + + + + + + + + + ######################################################################## + ### Sync the remote groups for a specific user + ######################################################################## + + function account_group_sync ( $account_id ) + { + $db = &DB(); + $sql= 'SELECT * FROM '.AGILE_DB_PREFIX.'db_mapping WHERE + status = '.$db->qstr(1).' AND + site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','account_group_sync', $db->ErrorMsg()); + return; + } + + while ( !$result->EOF ) + { + $file = $result->fields['map_file']; + $id = $result->fields['id']; + if($file != '') + { + include_once (PATH_PLUGINS . 'db_mapping/'. $file.'.php'); + eval ( '$_MAP = new map_'. strtoupper ( $file ) . ';' ); + $_MAP->account_group_sync ( $account_id ); + unset ($_MAP); + } + $result->MoveNext(); + } + } + + + + + + + + + ######################################################################## + ### Log the user in + ######################################################################## + + function login ( $account_id ) + { + + $db = &DB(); + $sql= 'SELECT * FROM '.AGILE_DB_PREFIX.'db_mapping WHERE + status = '.$db->qstr(1).' AND + site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','login', $db->ErrorMsg()); + return; + } + + while ( !$result->EOF ) + { + $file = $result->fields['map_file']; + $id = $result->fields['id']; + $cookie = $result->fields['cookie_name']; + if($file != '') + { + include_once (PATH_PLUGINS . 'db_mapping/'. $file.'.php'); + eval ( '$_MAP = new map_'. strtoupper ( $file ) . ';' ); + $_MAP->login ( $account_id, $cookie); + unset ($_MAP); + } + $result->MoveNext(); + } + } + + + + + + + + + ######################################################################## + ### Log the user out + ######################################################################## + + function logout ( $account_id ) + { + $db = &DB(); + $sql= 'SELECT * FROM '.AGILE_DB_PREFIX.'db_mapping WHERE + status = '.$db->qstr(1).' AND + site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','logout', $db->ErrorMsg()); + return; + } + + while ( !$result->EOF ) + { + $file = $result->fields['map_file']; + $id = $result->fields['id']; + $cookie = $result->fields['cookie_name']; + if($file != '') + { + include_once (PATH_PLUGINS . 'db_mapping/'. $file.'.php'); + eval ( '$_MAP = new map_'. strtoupper ( $file ) . ';' ); + $_MAP->logout ( $account_id, $cookie ); + unset ($_MAP); + } + $result->MoveNext(); + } + } + + + + + + + + +################################################################################ +# <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +################################################################################ + + + + + + + + + + + + + + + + +############################################################################ +#>>>>> default sync module +############################################################################ + +function MAP_sync ($id, $file, $MAP_this) +{ + global $C_debug, $C_translate, $VAR; + + $message=''; + $remote_complete=false; + $local_complete=false; + $count_exp=0; + $count_upd=0; + $count_imp=0; + + // set limits for large databases: + $offset=-1; + if(!empty($VAR['offset'])) $offset=$VAR['offset']; + + # get total number of accounts + $db = &DB(); + $sql= 'SELECT count(*) as idx FROM '.AGILE_DB_PREFIX.'account WHERE site_id = '. DEFAULT_SITE .' AND status=1'; + $result = $db->Execute($sql); + $total_accounts = $result->fields['idx']; + if($total_accounts < $offset) $local_complete=true; + + # Loop through each account in the LOCAL DB to update / add the record to the REMOTE DB... + if(!$local_complete) + { + $sql= 'SELECT id,username,email FROM '.AGILE_DB_PREFIX.'account WHERE site_id = '.DEFAULT_SITE.' AND status=1'; + $result = $db->SelectLimit($sql, $this->sync_limit, $offset); + if ($result === false) { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_sync:1', $db->ErrorMsg()); + return; + } + + # loop through local accounts + while ( !$result->EOF ) { + $account_id = $result->fields['id']; + $user = $result->fields['username']; + $email = $result->fields['email']; + + # Check if an account with this username or e-mail exists in the REMOTE DB: + $dbm = new db_mapping; + $dbx = $dbm->DB_connect($id, 'false'); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($file) .';' ); + $sql = "SELECT * FROM " . $db_prefix . $MAP_this->map['account_map_field'] . " + WHERE " . $MAP_this->map['account_fields']['username']['map_field']. " = ".$dbx->qstr($user); + $rs2 = $dbx->Execute($sql); + if ($rs2 === false) { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_sync:2', $dbx->ErrorMsg()); + return; + } + + if($rs2->RecordCount() == 0) { + # Account does not exist: ADD IT + if(!eregi('admin', $user) && !eregi('administrator', $user)) { + $MAP_this->account_add($account_id); + $count_exp++; + } + } else { + # Account exist: UPDATE IT - Skip if user is 'admin' or 'administrator' + if(!eregi('admin', $user) && !eregi('administrator', $user)) { + $MAP_this->account_edit($account_id, $user); + $count_upd++; + } + } + $result->MoveNext(); + } + } + + # get total number of remote accounts + $dbm = new db_mapping; + $dbx = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "SELECT count(*) as idx FROM " . $db_prefix . $MAP_this->map['account_map_field']; + $result = $dbx->Execute($sql); + $total_accounts = $result->fields['idx']; + if($total_accounts < $offset) $remote_complete=true; + + // loop through remote accounts + if(!$remote_complete) { + + $sql = "SELECT * FROM " . $db_prefix . $MAP_this->map['account_map_field']; + $result = $dbx->SelectLimit($sql, $this->sync_limit, $offset); + if ($result === false) { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_sync:3', $dbx->ErrorMsg()); + return; + } + while ( !$result->EOF ) + { + $fld_account_id = $MAP_this->map['account_fields']['id']['map_field']; + $fld_user = $MAP_this->map['account_fields']['username']['map_field']; + $fld_email = $MAP_this->map['account_fields']['email']['map_field']; + + $account_id = $result->fields[$fld_account_id]; + $user = $result->fields[$fld_user]; + $email = $result->fields[$fld_email]; + + # Check if an account with this username or e-mail exists in the LOCAL DB: + $db = &DB(); + $sql= 'SELECT id FROM '.AGILE_DB_PREFIX.'account WHERE + ( username= '.$db->qstr($user).' OR email = '.$db->qstr($email).' ) AND + site_id = '.DEFAULT_SITE .' AND status=1'; + $db2 = $db->Execute($sql); + if ($db2 === false) { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_sync:4', $db->ErrorMsg()); + return; + } + if($db2->RecordCount() == 0) { + # Account does not exist: ADD IT - Skip if user is 'admin' or 'administrator' + if(!eregi('admin', $user) && !eregi('administrator', $user)) + $MAP_this->account_import($account_id); + $count_imp++; + } + $result->MoveNext(); + } + } + + $C_translate->value['db_mapping']['count_exp'] = $count_exp; + $message .= $C_translate->translate('exported','db_mapping', ''); + + $C_translate->value['db_mapping']['count_upd'] = $count_upd; + $message .= "
". $C_translate->translate('updated','db_mapping', ''); + + $C_translate->value['db_mapping']['count_imp'] = $count_imp; + $message .= "
". $C_translate->translate('imported','db_mapping', ''); + + if($remote_complete && $local_complete) { + $message .= "
Local and Remote Account Sync completed after processing $offset records.
"; + } else { + $offset+=$this->sync_limit; + $url = "?_page=db_mapping:view&id=$id&do[]=db_mapping:sync&offset=$offset"; + $message .= "
Syncing Local and Remote Databases, please be patient as this screen will continue to refresh until all results have been processed.
Total Records Processed: $offset
"; + $message .= "Click here if the page does not refresh"; + $message .= ""; + } + + $C_debug->alert($message); +} + + + + + ############################################################################ + #>>>>> default Account Add module + ############################################################################ + + function MAP_account_add( $account_id, $MAP_this ) + { + ### Get the local account details + $db = &DB(); + $sql= 'SELECT * FROM '.AGILE_DB_PREFIX.'account WHERE + site_id = '.$db->qstr(DEFAULT_SITE).' AND + id = '.$db->qstr($account_id); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_add', $db->ErrorMsg()); + return; + } + + ### Create the insert statement + $dbm = new db_mapping; + $db = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "INSERT INTO " . + $db_prefix . "" . $MAP_this->map['account_map_field'] . ' SET '; + + ### Define the main fields + $comma=false; + reset ( $MAP_this->map['account_fields'] ); + while ( list ($key, $val) = each ( $MAP_this->map['account_fields'] )) + { + if ( $val['map_field'] && $key != 'id') + { + if($comma) $sql .= " , "; + $sql .= $val['map_field'] . " = ". $db->qstr($result->fields[$key]); + $comma = true; + } + elseif ( $val['map_field'] && $key == 'id') + { + if(isset($val['unique']) && $val['unique'] == '1') + { + $remote_account_id = $db->GenID($db_prefix . "" . $MAP_this->map['account_map_field'] . '_id'); + if($comma) $sql .= " , "; + $sql .= $val['map_field'] . " = ". $db->qstr($remote_account_id); + $comma = true; + } + } + } + + ### Define any custom fields + for($i=0; $imap['extra_field']); $i++) + { + if ( $MAP_this->map['extra_field'][$i]['add'] ) + { + if($comma) $sql .= " , "; + $value = $MAP_this->map['extra_field'][$i]['value']; + + # conversion + if ($value == 'random|64') + $value = rand(999,99999) .''. md5(microtime() . '-' . rand(999,9999)); + if ($value == 'random|32') + $value = md5(microtime() . rand(999,99999)); + + $sql .= $MAP_this->map['extra_field'][$i]['name'] . " = ".$db->qstr($value); + $comma = true; + } + } + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_add', $db->ErrorMsg()); + return; + } + return true; + } + + + + + + + + + + + + ############################################################################ + #>>>>> default Account Edit method + ############################################################################ + + function MAP_account_edit($account_id, $old_username, $MAP_this) + { + $db = &DB(); + if( $old_username == '') + { + ### Get the username: + $sql = 'SELECT username FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($account_id); + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_edit(1)', $db->ErrorMsg()); + return; + } + + if($result->RecordCount() > 0) + { + $old_username = $result->fields['username']; + } + } + + + if (@$old_username == strtolower('admin') || + @$old_username == strtolower('administrator')) + return false; + + ### Get the current account details from the local db + $sql= "SELECT * FROM " . AGILE_DB_PREFIX . "account WHERE + id = " . $db->qstr($account_id) . " AND + site_id = " . $db->qstr(DEFAULT_SITE); + $result=$db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_edit(2)', $db->ErrorMsg()); + return; + } + + ### Create the sql update statement + unset($db); + $dbm = new db_mapping; + $db = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "UPDATE " . + $db_prefix . "" . $MAP_this->map['account_map_field'] . ' SET '; + + + ### Define the main fields + $comma=false; + reset ( $MAP_this->map['account_fields'] ); + while ( list ($key, $val) = each ( $MAP_this->map['account_fields'] )) + { + if ( $val['map_field'] && $key != 'id') + { + if($comma) $sql .= " , "; + $sql .= $val['map_field'] . " = ". $db->qstr($result->fields[$key]); + $comma = true; + } + } + + ### Define any custom fields + for($i=0; $imap['extra_field']); $i++) + { + if ( $MAP_this->map['extra_field'][$i]['edit'] ) + { + if($comma) $sql .= " , "; + $sql .= $MAP_this->map['extra_field'][$i]['name'] . " = ". + $db->qstr($MAP_this->map['extra_field'][$i]['value']); + $comma = true; + } + } + + ### Update the account in the remote db + $sql .= " WHERE " . $MAP_this->map['account_fields']['username']['map_field'] . + ' = ' . $db->qstr($old_username); + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_edit(3)', $db->ErrorMsg()); + return; + } + } + + + + + ############################################################################ + #>>>>> default Account Deletion method + ############################################################################ + + function MAP_account_delete($account_id, $username, $MAP_this) + { + ### Check if delete is allowed for this db map: + if ( !isset($MAP_this->map['account_sync_field']['delete']) || + !$MAP_this->map['account_sync_field']['delete'] ) + return false; + + ### Check if username is defined + if ( $username == '') + { + ### Get the username: + $db = &DB(); + $sql = 'SELECT username FROM ' . AGILE_DB_PREFIX . 'account WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($account_id); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_delete', $db->ErrorMsg()); + return; + } + + if($result->RecordCount > 0) + { + $username = $result->fields['username']; + } + } + + ################################################################### + ### Get the remote account ID: + $dbm = new db_mapping; + $db2 = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "SELECT " . $MAP_this->map['account_fields']['id']['map_field'] . " FROM " . + $db_prefix . "" . $MAP_this->map['account_map_field'] . ' WHERE ' . + $MAP_this->map['account_fields']['username']['map_field'] . " = " . + $db2->qstr($username); + $result = $db2->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','Map_account_delete', $db2->ErrorMsg()); + return; + } + + $fld = $MAP_this->map['account_fields']['id']['map_field']; + $remote_account_id = $result->fields[$fld]; + + #################################################################### + ### Delete the remote account: + $sql = "DELETE FROM " . + $db_prefix . "" . $MAP_this->map['account_map_field'] . ' WHERE ' . + $MAP_this->map['account_fields']['id']['map_field'] . " = " . + $db2->qstr($remote_account_id); + $result = $db2->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_delete', $db->ErrorMsg()); + return; + } + + #################################################################### + ### Delete the remote groups: + if ( $MAP_this->map['group_type'] == 'db' || $MAP_this->map['group_type'] == 'hardcode' ) + { + $sql = "DELETE FROM " . + $db_prefix . "" . $MAP_this->map['group_account_map']['table'] . ' WHERE ' . + $MAP_this->map['group_account_map']['account_id'] . " = " . + $db2->qstr($remote_account_id); + $result = $db2->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_delete', $db->ErrorMsg()); + return; + } + + return $remote_account_id; + } + } + + + + + + + ######################################################################## + #>>>>> default Account Import method + ######################################################################## + + function MAP_account_import($remote_account_id, $MAP_this) + { + #################################################################### + ### Get the remote account details: + $dbm = new db_mapping; + $db2 = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "SELECT * FROM " . + $db_prefix . "" . $MAP_this->map['account_map_field'] . ' WHERE ' . + $MAP_this->map['account_fields']['id']['map_field'] . " = " . + $db2->qstr($remote_account_id); + $result = $db2->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_import', $db2->ErrorMsg()); + return; + } + + if ($result->RecordCount() == 0) return false; + + #################################################################### + ### get a unique account id: + + $db = &DB(); + $account_id = $db->GenID(AGILE_DB_PREFIX . 'account_id'); + + $fld = $MAP_this->map['account_fields']['username']['map_field']; + @$username = $result->fields[$fld]; + + $fld = $MAP_this->map['account_fields']['password']['map_field']; + @$password = $result->fields[$fld]; + + if ( !$MAP_this->map['account_fields']['company']['map_field'] ) + { + $company = ''; + } + else + { + $fld = $MAP_this->map['account_fields']['company']['map_field']; + @$company = $result->fields[$fld]; + } + + $fld = $MAP_this->map['account_fields']['email']['map_field']; + @$email = $result->fields[$fld]; + + $fld = $MAP_this->map['account_fields']['email_type']['map_field']; + @$email_type = $result->fields[$fld]; + + $fld = $MAP_this->map['account_fields']['date_last']['map_field']; + @$date_last = $result->fields[$fld]; + if ($date_last <= 0) $date_last = time(); + + $fld = $MAP_this->map['account_fields']['date_orig']['map_field']; + @$date_orig = $result->fields[$fld]; + if ($date_orig <= 0) $date_orig = time(); + + + if ( !$MAP_this->map['account_fields']['last_name']['map_field'] ) + { + $status = '1'; + } + else + { + $fld = $MAP_this->map['account_fields']['status']['map_field']; + @$status = $result->fields[$fld]; + if ($status != '0' && $status != '1') $status = '1'; + } + + + $fld = $MAP_this->map['account_fields']['first_name']['map_field']; + @$first_name = $result->fields[$fld]; + @$name_arr = split(' ', $first_name); + + if ( !$MAP_this->map['account_fields']['last_name']['map_field'] ) + { + if (count($name_arr) >= 3) + { + @$first_name = $name_arr["0"]; + @$middle_name = $name_arr["1"]; + @$last_name = $name_arr["2"]; + } + elseif (count($name_arr) == 2) + { + @$first_name = $name_arr["0"]; + $middle_name = ''; + @$last_name = $name_arr["1"]; + } + else + { + $middle_name = ''; + $last_name = ''; + } + } + else + { + $fld = $MAP_this->map['account_fields']['middle_name']['map_field']; + @$middle_name = $result->fields[$fld]; + + $fld = $MAP_this->map['account_fields']['last_name']['map_field']; + @$last_name = $result->fields[$fld]; + } + + + + #################################################################### + ### Create the sql update statement + + $sql = "INSERT INTO ". AGILE_DB_PREFIX ."account SET + id = ".$db->qstr($account_id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + language_id = ".$db->qstr(DEFAULT_LANGUAGE).", + affiliate_id= ".$db->qstr(DEFAULT_AFFILIATE).", + reseller_id = ".$db->qstr(DEFAULT_RESELLER).", + currency_id = ".$db->qstr(DEFAULT_CURRENCY).", + theme_id = ".$db->qstr(DEFAULT_THEME).", + status = ".$db->qstr($status).", + date_orig = ".$db->qstr($date_orig).", + date_last = ".$db->qstr($date_last).", + username = ".$db->qstr($username).", + password = ".$db->qstr($password).", + first_name = ".$db->qstr($first_name).", + middle_name = ".$db->qstr($middle_name).", + last_name = ".$db->qstr($last_name).", + company = ".$db->qstr($company).", + email = ".$db->qstr($email).", + email_type = ".$db->qstr($email_type); + $result = $db->Execute($sql); + + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_import', $db->ErrorMsg() . " --- ". $sql); + return; + } + + + #################################################################### + ### add the user to the default group: + + $group_id = $db->GenID(AGILE_DB_PREFIX . "" . 'account_id'); + $sql = ' + INSERT INTO ' . AGILE_DB_PREFIX . 'account_group SET + id = ' . $db->qstr ( $group_id ) . ', + site_id = ' . $db->qstr ( DEFAULT_SITE ) . ', + date_orig = ' . $db->qstr ( time() ) . ', + group_id = ' . $db->qstr ( DEFAULT_GROUP ) . ', + account_id = ' . $db->qstr ( $account_id ) . ', + active = ' . $db->qstr ('1'); + $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_import', $db->ErrorMsg()); + return; + } + } + + + + + + + + + + + + + + + + + + + ######################################################################## + #>>>>> default Account Import method ( FOR 'DB' based groups... ) + ######################################################################## + + function MAP_account_group_sync_db($account_id, $MAP_this) + { + ### Get the local account details + + $db = &DB(); + $sql= 'SELECT username,email FROM '.AGILE_DB_PREFIX.'account WHERE + site_id = '.$db->qstr(DEFAULT_SITE).' AND + id = '.$db->qstr($account_id); + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_db1', $db->ErrorMsg(). ' ---> ' . $sql); + return; + } + + $user = $result->fields['username']; + $email = $result->fields['email']; + + ### Get the remote account id: + $dbm = new db_mapping; + $db2 = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "SELECT " . + $MAP_this->map['account_fields']['id']['map_field'] + . " FROM " . + $db_prefix . "" . $MAP_this->map['account_map_field'] . ' WHERE ' . + $MAP_this->map['account_fields']['username']['map_field'] . " = " . + $db2->qstr($user); + $result = $db2->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_db2', $db2->ErrorMsg(). ' ---> ' . $sql); + return; + } + + $fld_remote_id = $MAP_this->map['account_fields']['id']['map_field']; + $remote_account_id = $result->fields[$fld_remote_id]; + + ### Delete all current groups for this account id: + if(!empty($MAP_this->map['group_account_map']['account_id'])) { + $sql = "DELETE FROM " . + $db_prefix . "" . $MAP_this->map['group_account_map']['table'] + . ' WHERE ' . + $MAP_this->map['group_account_map']['account_id'] . " = " . + $db2->qstr($remote_account_id); + $result = $db2->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_db3', $db2->ErrorMsg(). ' ---> ' . $sql); + return; + } + } + + ### Get the group_map array for this database map: + if(!isset($this->group_arr)) + { + $db = &DB(); + $sql = "SELECT group_map FROM ".AGILE_DB_PREFIX."db_mapping WHERE + map_file = ".$db->qstr($MAP_this->map['map'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_db4', $db->ErrorMsg(). ' ---> ' . $sql); + return; + } + @$MAP_this->group_arr = unserialize( $result->fields['group_map'] ); + } + + + #################################################################### + ### Determine the groups the selected account is authorize for: + + $db = &DB(); + $sql = "SELECT group_id,date_start,date_expire FROM ". + AGILE_DB_PREFIX."account_group WHERE + account_id = ".$db->qstr($account_id)." AND + active = ".$db->qstr(1)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_db4', $db->ErrorMsg(). ' ---> ' . $sql); + return; + } + + if($result->RecordCount() == 0) return; + while( !$result->EOF ) + { + $start = $result->fields['date_start']; + $expire = $result->fields['date_expire']; + $group = $result->fields['group_id']; + + ### Group access started and not expired: + if + (($expire >= time() || $expire == '' || $expire == '0') + && + ($start <= time() || $start == '' || $start == '0')) + { + ### Group is authorized: + ### Get the associated remote group(s) this account needs + ### to be added to: + + reset ($MAP_this->group_arr); + while ( list ($key, $val) = each ($MAP_this->group_arr)) + { + if ($key == $group) + { + ### what remote group(s) is this group mapped to? + while ( list ($remote_group, $add) = each ($val)) + { + if ($add) + { + ### create this group in the remote DB: + $dbm = new db_mapping; + $db2 = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "INSERT INTO " . + $db_prefix . "" . + $MAP_this->map['group_account_map']['table'] . ' SET ' . + $MAP_this->map['group_account_map']['group_id'] . " = " . + $db2->qstr($remote_group) . ", " . + $MAP_this->map['group_account_map']['account_id'] . " = " . + $db2->qstr($remote_account_id); + $group_result = $db2->Execute($sql); + if ($group_result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_db5', $db2->ErrorMsg(). ' ---> ' . $sql); + return; + } + } + } + } + } + } + $result->MoveNext(); + } + return $remote_account_id; + } + + + + + + + + + + + + + + + + + + ######################################################################## + #>>>>> default Account Import method ( FOR 'DB' based groups... ) + ######################################################################## + + function MAP_account_group_sync_status($account_id, $MAP_this) + { + #################################################################### + ### Get the local account details + + $db = &DB(); + $sql= 'SELECT username,email FROM '.AGILE_DB_PREFIX.'account WHERE + site_id = '.$db->qstr(DEFAULT_SITE).' AND + id = '.$db->qstr($account_id); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_status', $db->ErrorMsg()); + return; + } + + $user = $result->fields['username']; + $email = $result->fields['email']; + + + + #################################################################### + ### Get the remote account id: + + $dbm = new db_mapping; + $db2 = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "SELECT " . + $MAP_this->map['account_fields']['id']['map_field'] + . " FROM " . + $db_prefix . "" . $MAP_this->map['account_map_field'] . ' WHERE ' . + $MAP_this->map['account_fields']['username']['map_field'] . " = " . + $db2->qstr($user); + $result = $db2->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_status', $db2->ErrorMsg()); + return; + } + + $fld_remote_id = $MAP_this->map['account_fields']['id']['map_field']; + $remote_account_id = $result->fields[$fld_remote_id]; + + + #################################################################### + ### Get the group_map array for this database map: + + if(!isset($this->group_arr)) + { + $db = &DB(); + $sql = "SELECT group_map FROM ".AGILE_DB_PREFIX."db_mapping WHERE + map_file = ".$db->qstr($MAP_this->map['map'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_status', $db->ErrorMsg()); + return; + } + + @$MAP_this->group_arr = unserialize( $result->fields['group_map'] ); + } + + + #################################################################### + ### Determine the groups the selected account is authorize for: + + $db = &DB(); + $sql = "SELECT group_id,date_start,date_expire FROM ". + AGILE_DB_PREFIX."account_group WHERE + account_id = ".$db->qstr($account_id)." AND + active = ".$db->qstr(1)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_status', $db->ErrorMsg()); + return; + } + + if($result->RecordCount() == 0) return; + + $MAP_this->status = 0; + + while( !$result->EOF ) + { + $start = $result->fields['date_start']; + $expire = $result->fields['date_expire']; + $group = $result->fields['group_id']; + + ### Group access started and not expired: + if + (($expire >= time() || $expire == '' || $expire == '0') + && + ($start <= time() || $start == '' || $start == '0')) + { + ### Group is authorized: + ### Get the associated remote group(s) this account needs + ### to be added to: + + + if(is_array($MAP_this->group_arr)) + { + reset ($MAP_this->group_arr); + while ( list ($key, $add) = each ($MAP_this->group_arr)) + { + if ($key == $group) + { + if ($add != '' && gettype($add) != 'string') + { + if ( $MAP_this->status < $add ) + $MAP_this->status = $add; + } + else + { + $MAP_this->status = $add; + } + } + } + } + } + $result->MoveNext(); + } + + ### Update the remote account: + $dbm = new db_mapping; + $db2 = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "UPDATE " . + $db_prefix . "" . + $MAP_this->map['account_map_field'] . ' SET ' . + $MAP_this->map['account_status_field'] . " = " . + $db2->qstr($MAP_this->status) . " WHERE " . + $MAP_this->map['account_fields']['id']['map_field'] . " = " . + $db2->qstr($remote_account_id); + $group_result = $db2->Execute($sql); + + ### error reporting: + if ($group_result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_status', $db->ErrorMsg()); + return; + } + return $remote_account_id; + } + + + + + + + + + + ######################################################################## + #>>>>> default Account Import method ( FOR 'DB' based groups... ) + ######################################################################## + + function MAP_account_group_sync_db_status($account_id, $MAP_this) + { + ### Get the local account details + $db = &DB(); + $sql= 'SELECT username,email FROM '.AGILE_DB_PREFIX.'account WHERE + site_id = '.$db->qstr(DEFAULT_SITE).' AND + id = '.$db->qstr($account_id); + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_status', $db->ErrorMsg()); + return; + } + + $user = $result->fields['username']; + $email = $result->fields['email']; + + + ### Get the remote account id: + $dbm = new db_mapping; + $db2 = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "SELECT " . + $MAP_this->map['account_fields']['id']['map_field'] + . " FROM " . + $db_prefix . "" . $MAP_this->map['account_map_field'] . ' WHERE ' . + $MAP_this->map['account_fields']['username']['map_field'] . " = " . + $db2->qstr($user); + $result = $db2->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_status', $db2->ErrorMsg()); + return; + } + + $fld_remote_id = $MAP_this->map['account_fields']['id']['map_field']; + $remote_account_id = $result->fields[$fld_remote_id]; + + ### Get the group_map array for this database map: + if(!isset($this->group_arr)) + { + $db = &DB(); + $sql = "SELECT group_map,group_rank FROM ".AGILE_DB_PREFIX."db_mapping WHERE + map_file = ".$db->qstr($MAP_this->map['map'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_status', $db->ErrorMsg()); + return; + } + + @$MAP_this->group_arr = unserialize( $result->fields['group_map'] ); + @$MAP_this->group_rank = unserialize( $result->fields['group_rank']); + } + + ### Determine the groups the selected account is authorize for: + $db = &DB(); + $sql = "SELECT group_id,date_start,date_expire FROM ". + AGILE_DB_PREFIX."account_group WHERE + account_id = ".$db->qstr($account_id)." AND + active = ".$db->qstr(1)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + + ### error reporting: + if ($result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_status', $db->ErrorMsg()); + return; + } + + if($result->RecordCount() == 0) return; + + $MAP_this->status = 0; + if($result->RecordCount() == 0) return; + $rank = 0; + while( !$result->EOF ) + { + $start = $result->fields['date_start']; + $expire = $result->fields['date_expire']; + $group = $result->fields['group_id']; + + ### Group access started and not expired: + if + (($expire >= time() || $expire == '' || $expire == '0') + && + ($start <= time() || $start == '' || $start == '0')) + { + ### Group is authorized: + ### Get the associated remote group(s) this account needs + ### to be added to: + + if(!empty($MAP_this->group_arr) && is_array($MAP_this->group_arr)) + { + reset ($MAP_this->group_arr); + foreach($MAP_this->group_arr as $key => $val) + { + if ($key == $group) + { + ### what remote group(s) is this group mapped to? + foreach($val as $remote_group => $add) { + if (!empty($add) && $MAP_this->group_rank[$key]['rank'] > $rank) + { + $MAP_this->status = $add; + $rank = $MAP_this->group_rank[$key]['rank']; + } + } + } + } + } + } + $result->MoveNext(); + } + + ### Update the remote account: + $dbm = new db_mapping; + $db2 = $dbm->DB_connect(false, $MAP_this->map['map']); + eval ( '@$db_prefix = DB2_PREFIX'. strtoupper($MAP_this->map['map']) .';' ); + $sql = "UPDATE " . + $db_prefix . "" . + $MAP_this->map['account_map_field'] . ' SET ' . + $MAP_this->map['account_status_field'] . " = " . + $db2->qstr($MAP_this->status) . " WHERE " . + $MAP_this->map['account_fields']['id']['map_field'] . " = " . + $db2->qstr($remote_account_id); + $group_result = $db2->Execute($sql); + if ($group_result === false) + { + global $C_debug; + $C_debug->error('db_mapping.inc.php','MAP_account_group_sync_status', $db->ErrorMsg()); + return; + } + return $remote_account_id; + } +} +?> \ No newline at end of file diff --git a/modules/db_mapping/db_mapping_construct.xml b/modules/db_mapping/db_mapping_construct.xml new file mode 100644 index 00000000..1e5d3764 --- /dev/null +++ b/modules/db_mapping/db_mapping_construct.xml @@ -0,0 +1,90 @@ + + + + db_mapping + + db_mapping
+ + + + 0 + + name + + 25 + + name + status,type + + + + I8 + 1 + + + I4 + + + C(128) + 3 + 128 + any + + + X2 + + + L + + + C(16) + + + C(128) + 1 + 128 + any + + + C(128) + 2 + 128 + any + + + C(128) + + + C(128) + + + C(128) + + + C(128) + + + X + array + + + X + array + + + C(128) + 4 + 128 + + + + + id,site_id,name,notes,status,type,db_name,db_host,db_user,db_pass,db_prefix,cookie_name,group_map,map_file,group_rank + id,site_id,name,notes,status,type,db_name,db_host,db_user,db_pass,db_prefix,cookie_name,group_map,map_file,group_rank + id,site_id,name,notes,status,type,db_name,db_host,db_user,db_pass,db_prefix,cookie_name,group_map,map_file,group_rank + id,site_id,name,notes,status,type,db_name,db_host,db_user,db_pass,db_prefix,cookie_name,group_map,map_file,group_rank + id,site_id,name,notes,status,type,db_name,db_host,db_user,db_pass,db_prefix,cookie_name,group_map,map_file,group_rank + + + 0 +
diff --git a/modules/db_mapping/db_mapping_install.xml b/modules/db_mapping/db_mapping_install.xml new file mode 100644 index 00000000..8bf1e345 --- /dev/null +++ b/modules/db_mapping/db_mapping_install.xml @@ -0,0 +1,35 @@ + + + db_mapping + setup + + 1 + + + + + view + + 1 + + + add + + + update + + + search + + + delete + + + search_show + + + sync + + + + \ No newline at end of file diff --git a/modules/discount/auth.inc.php b/modules/discount/auth.inc.php new file mode 100644 index 00000000..f0b382d3 --- /dev/null +++ b/modules/discount/auth.inc.php @@ -0,0 +1,10 @@ + 'discount', 'method' => 'user_search'), + Array ('module' => 'discount', 'method' => 'user_search_show') + ); +?> \ No newline at end of file diff --git a/modules/discount/discount.inc.php b/modules/discount/discount.inc.php new file mode 100644 index 00000000..b31d36b0 --- /dev/null +++ b/modules/discount/discount.inc.php @@ -0,0 +1,480 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class discount +{ + /** + * array of available discounts + * + * @var array + */ + var $discounts=false; + + /** + * the cumulative amount of the current discount + * + * @var float + */ + var $discount_total=0; + + /** + * the array of discounts applied to the line_items + * + * @var array + */ + var $discount_arr; + + /** + * Array that contains list of discount plugins in the /plugins/discount/ directory to load + * + * @var array + */ + var $plugins=false; + + /** + * Setup the discount plugin array if needed + */ + function discount() { + // $this->plugins = array('test'); + } + + /** + * Load a specific discount plugin and validate the results + * + * @param string $plugin The plugin name + * @param string $discount The discount code + * @return bool + */ + function plugin_validate($plugin, $discount) { + $plugin_file = PATH_PLUGINS.'discount/'. $plugin . '.php'; + if(is_file($plugin_file)) { + include_once($plugin_file); + eval('$plg = new plgn_discount_'. $plugin .';'); + if(is_object($plg)) { + if(is_callable(array($plg, 'validate'))) { + $plg->discount = $discount; + return $plg->validate($discount); + } + } + } + return false; + } + + /** + * Add a discount at the cart/checkout by user/admin + * + * @param array $VAR + * @return bool + */ + function add_cart_discount($VAR) { + global $C_debug, $C_translate, $smarty; + + # Validate input + if(empty($VAR["discount"])) { + $C_debug->alert($C_translate->translate('invalid_discount','checkout','')); + return false; + } + + $discount_code = $VAR["discount"]; + + # Check the supplied discount + $db = &DB(); + $rs = $db->Execute(sqlSelect($db,"discount","*","( date_start IS NULL OR date_start=0 OR date_start>".time().") AND date_expire<=".time()." AND name=::$discount_code::")); + if (!$rs || !$rs->RecordCount() || $rs->fields["status"] != '1') { + + // local check failed, attempt any discount plugins + $plg=false; + if($this->plugins && is_array($this->plugins)) { + foreach($this->plugins as $plugin){ + if($discount_code = $this->plugin_validate($plugin, $discount_code)) { + $plg=true; + break; + } + } + } + // no plugins returned true... + if(!$plg) { + $C_debug->alert($C_translate->translate('invalid_discount','checkout','')); + return false; + } + } + + # get existing discounts: + $arr = array(); + $rs = $db->Execute(sqlSelect($db,"session","discounts","id=::".SESS."::")); + if($rs && $rs->RecordCount() && !empty($rs->fields['discounts']) && is_string($rs->fields['discounts'])) + $arr=unserialize($rs->fields['discounts']); + + # check for duplicates + $do = true; + if(is_array($arr)) { + foreach($arr as $key=>$discount) { + if($discount == $discount_code) { + unset($arr[$key]); + $do = false; + } + } + } + + # update session data + if($do) $arr[]=$discount_code; + $rs = $db->Execute(sqlUpdate($db,"session",array('discounts'=> serialize($arr)), "id=::".SESS."::")); + + return true; + } + + + /** + * Commit current discounts to the database (call after creating an invoice_item record) + */ + function invoice_item($invoice_id,$invoice_item_id,$account_id,$discount_arr=false) { + if($discount_arr && is_array($discount_arr)) $this->discount_arr=$discount_arr; + if(is_array($this->discount_arr)) { + $db=&DB(); + foreach($this->discount_arr as $dsc) { + $sql="INSERT INTO ".AGILE_DB_PREFIX."invoice_item_discount SET id=".sqlGenID($db,"invoice_item_discount").", site_id=".DEFAULT_SITE.", invoice_id=$invoice_id, account_id=$account_id, invoice_item_id=$invoice_item_id, discount=".$db->qstr($dsc["discount"]).", amount=".$db->qstr($dsc["amount"]); + $db->Execute($sql); + } + } + } + + /** + * Get the avialable discounts for an account, session, or service + * @param $account + * @param $type 0=initial order, 1=recurring charge + */ + function available_discounts($account, $type=0,$invoice=false) { + // get account specific discounts + if($type) $type = " recurr_status=1 "; else $type = " new_status=1 "; + $db =& DB(); + $rs = $db->Execute($sql=sqlSelect($db, 'discount', '*', "avail_account_id = $account AND $type AND status=1")); + if($rs && $rs->RecordCount()) { + while (!$rs->EOF) { + $this->discounts["{$rs->fields['name']}"] = $rs->fields; + $rs->MoveNext(); + } + } + // get session discounts from cart + if($type==0) { + $rsc = $db->Execute(sqlSelect($db, 'session', 'discounts', "(account_id = $account OR id=::".SESS."::) AND discounts != '' AND discounts IS NOT NULL")); + if($rsc && $rsc->RecordCount()) { + $arr=unserialize($rsc->fields['discounts']); + foreach($arr as $discount) { + if(!empty($discount)) { + $rs = $db->Execute(sqlSelect($db, 'discount', '*', "name=::$discount:: AND status=1")); + if($rs && $rs->RecordCount()) + if(empty($this->discounts["{$rs->fields['name']}"])) $this->discounts["{$rs->fields['name']}"] = $rs->fields; + } + } + } + } + // get recurring discounts + if($type==1 && $invoice) { + $rs = $db->Execute(sqlSelect($db,array('invoice_item_discount','discount'),'B.*', "A.invoice_id = $invoice AND A.discount = B.name AND $type AND status=1")); + if($rs && $rs->RecordCount()) { + while (!$rs->EOF) { + if(empty($this->discounts["{$rs->fields['name']}"])) $this->discounts["{$rs->fields['name']}"] = $rs->fields; + $rs->MoveNext(); + } + } + } + } + + /** + * Calculate all applicable discounts for the current line item + * @param $type bool 0=initial product, 1=recurring product, 2=initial_domain, 3=recurring domain + * @param $invoice_item_id int The invoice item id for the discount + * @param $product_id int The product ID if type=0,1 or The TLD if type = 2,3 + * @param $account_id int The account ID + * @param $invoice_amt float The cumulative invoice amount + * @param $prod_amt float The product price before any discounts + */ + function calc_all_discounts($type=0,$invoice_item_id=false, $product_id, $product_amt, $account_id, $invoice_amt) { + $total_amt=0; + if(is_array($this->discounts)) { + if(!$invoice_item_id) unset($this->discount_arr); + foreach($this->discounts as $discount => $tmp) + { + $amt = $this->calc_item_discount($type,$discount, $product_id, $account_id, $invoice_amt, $product_amt); + if($amt > 0) + { + $this->discount_arr[] = Array ('id' => $invoice_item_id, 'discount' => $discount, 'amount' => $amt ); + $total_amt += $amt; + $this->discount_total+=$amt; + } + } + } + return $total_amt; + } + + /** + * Add a manual ad-hoc invoice to the array + * + * @param float $amount The discount amount + * @param string $discount Name of the discount + * @param $invoice_item_id int The invoice item id for the discount + */ + function add_manual_discount($amount, $discount='MISC', $invoice_item_id=false) { + $this->discount_arr[] = Array ('id' => $invoice_item_id, 'discount' => $discount, 'amount' => $amount ); + } + + + /** + * Calculate Recurring Discount + * @param $type bool 0=initial product, 1=recurring product, 2=initial_domain, 3=recurring domain + * @param $discount string The discount array obj (must be set to $this->discount["$discounts"] containing the fields of the discount) + * @param $product_id int The product ID if type=0,1 or The TLD if type = 2,3 + * @param $account_id int The account ID + * @param $invoice_amt float The cumulative invoice amount + * @param $prod_amt float The product price before any discounts + */ + function calc_item_discount($type, $discount, $product_id, $account_id, $invoice_amt, $prod_amt) + { + $this->discount = $this->discounts["$discount"]; + if($type == 0 || $type == 2) { // initial + $rate_type = $this->discount["new_type"]; + $rate = $this->discount["new_rate"]; + $min_cost = $this->discount["new_min_cost"]; + $max_usage_amt = $this->discount["new_max_discount"]; + } else { // recurr + $rate_type = $this->discount["recurr_type"]; + $rate = $this->discount["recurr_rate"]; + $min_cost = $this->discount["recurr_min_cost"]; + $max_usage_amt = $this->discount["recurr_max_discount"]; + } + + if(empty($this->discounts["$discount"])) return false; + $this->discount = $this->discounts["$discount"]; + + if (!empty( $this->discount["date_start"] ) && $this->discount["date_start"] > time()) return 0; + + if (!empty( $this->discount["date_expire"] ) && $this->discount["date_expire"] < time()) return 0; + + if(!empty( $min_cost ) && $min_cost > $invoice_amt) return 0; + + if( $this->discount["max_usage_account"] > 0 || $this->discount["max_usage_global"] > 0 ) + if(!$this->discount_check_usage($this->discount["max_usage_account"],$this->discount["max_usage_global"], $account_id, $discount)) + return 0; + + if(!empty( $this->discount["avail_account_id"]) && $this->discount["avail_account_id"] != $account_id) return 0; + + if($type==0 || $type==2) { + if(!empty( $this->discount["avail_account_id"]) && $this->discount["avail_account_id"] != $account_id) { + return 0; + } else { + if(!empty( $this->discount["avail_group_id"] )) { + $arr=unserialize($this->discount["avail_group_id"]); + if(is_array($arr) && count($arr) > 0 && !empty($arr[0])) { + $do=false; + global $C_auth; + for($i=0; $iauth_group_by_id($arr[$i])) { $do=true; $i=count($arr); } + } + if(!$do) return 0; + } + } + } + } + + if($type<2 && !empty($product_id) && !empty( $this->discount["avail_product_id"] )) { + $arr=unserialize($this->discount["avail_product_id"]); + if(is_array($arr) && count($arr) > 0 && !empty($arr[0])) { + $do=false; + for($i=0; $i1) { + if(!empty( $this->discount["avail_tld_id"] )) { + $do=false; + $tld = $product_id; + $db = &DB(); + $rstld = $db->Execute(sqlSelect($db,"host_tld","id","name=::$tld::")); + if($rstld && $rstld->RecordCount()) { + $tld_id = $rstld->fields["id"]; + $arr=unserialize($this->discount["avail_tld_id"]); + if(is_array($arr) && count($arr) > 0 && !empty($arr[0])) { + for($i=0; $i $max_usage_amt) $discount_amt = $max_usage_amt; + } else { + $discount_amt = $rate; + } + + if(!empty( $max_usage_amt )) { + if ( $discount_amt + $this->discount_total > $max_usage_amt) + $discount_amt = $max_usage_amt - $this->discount_total; + } + + return round($discount_amt,2); + } + + + /** + * Check discount usage for account/global restrictions + */ + function discount_check_usage($max_acct, $max_global, $account_id, $discount) + { + $db = &DB(); + $rs = $db->Execute(sqlSelect($db,"invoice_item_discount","invoice_id,account_id","","","","DISTINCT")); + if($rs && $rs->RecordCount()) { + + # Check global usage + if(!empty($max_global) && $max_global > 0) if($rs->RecordCount() >= $max_global) return false; + + # Check usage by this account + if(!empty($max_acct) && $max_acct > 0) { + $i=0; + while(!$rs->EOF) { + if($rs->fields['account_id'] == $account_id) $i++; + $rs->MoveNext(); + } + if($i>=$max_acct) return false; + } + } + return true; + } + + + function discount_construct() { + $this->module = "discount"; + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + function user_search($VAR) { + # Lock the user only for his billing_records: + if(!SESS_LOGGED) { + return false; + } + # Lock the account_id + $VAR['discount_avail_account_id'] = SESS_ACCOUNT; + $this->discount_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + function user_search_show($VAR) { + # Lock the user only for his billing_records: + if(!SESS_LOGGED) { + return false; + } + $this->discount_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + function add($VAR) { + $this->discount_construct(); + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + function view($VAR) { + $this->discount_construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + function update($VAR) { + $this->discount_construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + function delete($VAR) { + $this->discount_construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + function search_form($VAR) { + $this->discount_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + function search($VAR) { + $this->discount_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + function search_show($VAR) { + $this->discount_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $dbc = new CORE_database; + $smart = $dbc->search_show($VAR, $this, $type); + $db = &DB(); + for($i=0; $iExecute($sql=sqlSelect($db,Array("invoice","invoice_item_discount"),"SUM(A.total_amt) as sum","B.invoice_id=A.id AND A.billing_status=1 AND B.discount=::{$smart[$i]['name']}::","","","DISTINCT")); + if($rs && $rs->RecordCount()) $smart[$i]['revenue'] = $rs->fields['sum']; + $rs = $db->Execute(sqlSelect($db, 'invoice_item_discount', 'invoice_id,amount', "discount=::{$smart[$i]['name']}::")); + if($rs && $rs->RecordCount() > 0) { + while(!$rs->EOF) { + $smart[$i]['savings'] += $rs->fields['amount']; + if(empty($invoices[$rs->fields['invoice_id']])) { + $smart[$i]['orders']++; + $invoices[$rs->fields['invoice_id']]=true; + } + $rs->MoveNext(); + } + } + } + global $smarty; + $smarty->clear_assign('discount'); + $smarty->assign('discount', $smart); + } +} +?> \ No newline at end of file diff --git a/modules/discount/discount_construct.xml b/modules/discount/discount_construct.xml new file mode 100644 index 00000000..ed463398 --- /dev/null +++ b/modules/discount/discount_construct.xml @@ -0,0 +1,120 @@ + + + + discount + + discount
+ + + + 0 + + name + + 25 + + + date_start + date_expire + status + + + + + I8 + 1 + 1 + + + I4 + 1 + + + I8 + date-now + + + I8 + date + + + I8 + date + + + L + + + C(64) + 2 + 32 + any + + + X2 + + + I4 + + + I4 + + + I8 + + + X2 + country + name + array + + + X2 + array + + + X2 + array + + + L + + + L + + + F + + + F + + + F + + + L + + + L + + + F + + + F + + + F + + + + + id,site_id,date_orig,date_start,date_expire,status,name,notes,max_usage_account,max_usage_global,avail_account_id,avail_product_id,avail_group_id,avail_tld_id,new_status,new_type,new_rate,new_max_discount,new_min_cost,recurr_status,recurr_type,recurr_rate,recurr_max_discount,recurr_min_cost + id,site_id,date_orig,date_start,date_expire,status,name,notes,max_usage_account,max_usage_global,avail_account_id,avail_product_id,avail_group_id,avail_tld_id,new_status,new_type,new_rate,new_max_discount,new_min_cost,recurr_status,recurr_type,recurr_rate,recurr_max_discount,recurr_min_cost + id,site_id,date_orig,date_start,date_expire,status,name,notes,max_usage_account,max_usage_global,avail_account_id,avail_product_id,avail_group_id,avail_tld_id,new_status,new_type,new_rate,new_max_discount,new_min_cost,recurr_status,recurr_type,recurr_rate,recurr_max_discount,recurr_min_cost + id,site_id,date_orig,date_start,date_expire,status,name,notes,max_usage_account,max_usage_global,avail_account_id,avail_product_id,avail_group_id,avail_tld_id,new_status,new_type,new_rate,new_max_discount,new_min_cost,recurr_status,recurr_type,recurr_rate,recurr_max_discount,recurr_min_cost + id,site_id,date_orig,date_start,date_expire,status,name,notes,max_usage_account,max_usage_global,avail_account_id,new_status,new_type,new_rate,new_max_discount,new_min_cost,recurr_status,recurr_type,recurr_rate,recurr_max_discount,recurr_min_cost + + + 0 +
diff --git a/modules/discount/discount_install.xml b/modules/discount/discount_install.xml new file mode 100644 index 00000000..cfb721d2 --- /dev/null +++ b/modules/discount/discount_install.xml @@ -0,0 +1,39 @@ + + + discount + account_admin + + 1 + + + + + search + + 1 + + + view + + 1 + + + delete + + + update + + + add + + 1 + + + search_form + + + search_show + + + + \ No newline at end of file diff --git a/modules/email_log/auth.inc.php b/modules/email_log/auth.inc.php new file mode 100644 index 00000000..32a64445 --- /dev/null +++ b/modules/email_log/auth.inc.php @@ -0,0 +1,7 @@ + 'email_log', 'method' => 'user_list'), +Array ('module' => 'email_log', 'method' => 'user_view') +); +?> \ No newline at end of file diff --git a/modules/email_log/email_log.inc.php b/modules/email_log/email_log.inc.php new file mode 100644 index 00000000..d0690e9e --- /dev/null +++ b/modules/email_log/email_log.inc.php @@ -0,0 +1,118 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class email_log +{ + var $user_view_count = 25; /* show last X email logs for user */ + + function user_list($VAR) { + if(!SESS_LOGGED) return false; + $db=&DB(); + $email = $db->GetOne("select email from ".AGILE_DB_PREFIX."account where id = ".SESS_ACCOUNT); + $rs=$db->Execute(sqlSelect($db,"email_log","id,email,date_orig,subject,urgent,userread", + "email=::$email:: and account_id=".SESS_ACCOUNT,'date_orig',$this->user_view_count)); + if($rs && $rs->RecordCount()) { + $smart=array(); + while(!$rs->EOF) { + array_push($smart, $rs->fields); + $rs->MoveNext(); + } + global $smarty; + $smarty->assign('email_log', $smart); + } + } + + function user_view($VAR) { + /* validate, update to read, and view() */ + if(!SESS_LOGGED || empty($VAR['id'])) return false; + /* select id for this user */ + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"email_log","*","id=::{$VAR['id']}:: and account_id=".SESS_ACCOUNT)); + if($rs && $rs->RecordCount()) { + global $smarty; + $smarty->assign('email_log', $rs->fields); + if($rs->fields['userread'] != 1) { + /* update to read */ + $fields=Array('userread'=>1); + $db->Execute(sqlUpdate($db,"email_log",$fields,"id = {$rs->fields['id']}")); + } + } + } + + function add($account_id, $subject, $message, $email, $html=0, $urgent=0) { + $db=&DB(); + $fields=Array('date_orig'=>time(), 'account_id'=>$account_id, 'subject'=>$subject, 'message'=>$message, 'email'=>$email, 'html'=>$html, 'urgent'=>$urgent, 'userread'=>0); + $id = & $db->Execute(sqlInsert($db,"email_log",$fields)); + } + + function view($VAR) { + $this->construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + function delete($VAR) { + $this->construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + function search_form($VAR) { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + function search($VAR) { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + function search_show($VAR) { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + function construct() { + $this->module = "email_log"; + $this->xml_construct = PATH_MODULES . $this->module . "/" . $this->module . "_construct.xml"; + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } +} +?> \ No newline at end of file diff --git a/modules/email_log/email_log_construct.xml b/modules/email_log/email_log_construct.xml new file mode 100644 index 00000000..1a5745ff --- /dev/null +++ b/modules/email_log/email_log_construct.xml @@ -0,0 +1,55 @@ + + + email_log + email_log
+ setup + 0 + date_orig + 35 + + id,site_id,account_id + email + html,urgent,userread + + + + I8 + 1 + + + I4 + + + I8 + date-now + + + I4 + any + + + C(128) + + + C(128) + + + X2 + + + L + + + L + + + L + + + + id,site_id,date_orig,account_id,email,subject,message,html,urgent,userread + id,site_id,date_orig,account_id,email,subject,message,html,urgent,userread + id,site_id,date_orig,account_id,email,subject,message,html,urgent,userread + + +
\ No newline at end of file diff --git a/modules/email_log/email_log_install.xml b/modules/email_log/email_log_install.xml new file mode 100644 index 00000000..c500c944 --- /dev/null +++ b/modules/email_log/email_log_install.xml @@ -0,0 +1,34 @@ + + + + email_log + setup + Stores log of all e-mails sent out to accounts + 1 + setup + + + + + + delete + + + view + core:search&module=%%&_escape=1 + 1 + + + search + %%:search_form + 1 + + + search_form + + + search_show + + + + \ No newline at end of file diff --git a/modules/email_queue/email_queue.inc.php b/modules/email_queue/email_queue.inc.php new file mode 100644 index 00000000..74a1c219 --- /dev/null +++ b/modules/email_queue/email_queue.inc.php @@ -0,0 +1,189 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class email_queue +{ + + # Open the constructor for this mod + function email_queue() + { + # name of this module: + $this->module = "email_queue"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + ############################## + ## SEND E-MAILS IN QUEUE ## + ############################## + function send($VAR) + { + $VAR_ORIG = $VAR; + + $db = &DB(); + $dbm = new CORE_database; + $sql = $dbm->sql_select("email_queue", "*", "status = 0", "", $db); + $rs = $db->Execute($sql); + + if($rs != false && $rs->RecordCount() > 0) + { + require_once ( PATH_MODULES . 'email_template/email_template.inc.php' ); + while(!$rs->EOF) + { + # Get values + global $VAR; + $VAR = unserialize($rs->fields['var']); + + $sql1 = $rs->fields['sql1']; + $sql2 = $rs->fields['sql2']; + $sql3 = $rs->fields['sql3']; + + if(!empty($sql1)) { + if(ereg("^a:", $sql1) && is_array(unserialize($sql1))) $sql1 = unserialize($sql1); + } else { + $sql1 = false; + } + + if(!empty($sql2)) { + if(ereg("^a:", $sql2) && is_array(unserialize($sql2))) $sql2 = unserialize($sql2); + } else { + $sql2 = false; + } + + if(!empty($sql3)) { + if(ereg("^a:", $sql3) && is_array(unserialize($sql3))) $sql3 = unserialize($sql3); + } else { + $sql3 = false; + } + + # Send email + $mail = new email_template; + $result = $mail->send($rs->fields['email_template'], $rs->fields['account_id'], $sql1, $sql2, $sql3, false); + + # Update to sent status + if($result) + { + $sql = "UPDATE ".AGILE_DB_PREFIX."email_queue SET + status = 1 + WHERE + id = {$rs->fields['id']} + AND + site_id = ".DEFAULT_SITE; + $db->Execute($sql); + } + $rs->MoveNext(); + } + } + + $VAR = $VAR_ORIG; + } + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/email_queue/email_queue_construct.xml b/modules/email_queue/email_queue_construct.xml new file mode 100644 index 00000000..6bca2ae4 --- /dev/null +++ b/modules/email_queue/email_queue_construct.xml @@ -0,0 +1,78 @@ + + + + + email_queue + + + email_queue
+ + + + + + 0 + + + id + + + 35 + + + + + I8 + + + I4 + + + I8 + time + + + I8 + date-now + + + L + + + C(128) + + + C(128) + + + C(128) + + + C(128) + + + C(128) + + + C(128) + + + C(128) + + + X2 + + + + + + id,site_id,date_orig,date_last,status,account_id,email_template,sql1,sql2,sql3,sql4,sql5,var + id,site_id,date_orig,date_last,status,account_id,email_template,sql1,sql2,sql3,sql4,sql5,var + id,site_id,date_orig,date_last,status,account_id,email_template,sql1,sql2,sql3,sql4,sql5,var + id,site_id,date_orig,date_last,status,account_id,email_template,sql1,sql2,sql3,sql4,sql5,var + id,site_id,date_orig,date_last,status,account_id,email_template,sql1,sql2,sql3,sql4,sql5,var + + + + 0 +
\ No newline at end of file diff --git a/modules/email_queue/email_queue_install.xml b/modules/email_queue/email_queue_install.xml new file mode 100644 index 00000000..8cdd8825 --- /dev/null +++ b/modules/email_queue/email_queue_install.xml @@ -0,0 +1,22 @@ + + + + + + email_queue + account_admin + Stores the email queue for future mailing + + + + + + + + + + add + + + + \ No newline at end of file diff --git a/modules/email_template/email_template.inc.php b/modules/email_template/email_template.inc.php new file mode 100644 index 00000000..c9d3ff11 --- /dev/null +++ b/modules/email_template/email_template.inc.php @@ -0,0 +1,527 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** + * include_once(PATH_MODULES.'email_template/email_template.inc.php'); + * $my = new email_template; + * $my->send('newsletter_subscribe', '4d1800b401f5d340f022688de0ac2687', 'f1714072da3c05a220ac3b60a3a57d88', '2', '3'); + */ +class email_template +{ + var $debug=false; + + # Open the constructor for this mod + function construct() + { + # name of this module: + $this->module = "email_template"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $this->construct(); + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $this->construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $this->construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $this->construct(); + $this->associated_DELETE[] = Array( 'table' => 'email_template_translate', + 'field' => 'email_template_id'); + + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + + + + ############################## + ## SEND EMAIL TEMPLATE ## + ############################## + + function send($template, $acct, $sql1, $sql2, $sql3, $queue=true) + { + global $VAR, $C_debug; + $db = &DB(); + + # Send to admin only? + $admin_only = false; + if(eregi('admin->', $template)) { + $admin_only = true; + $template = eregi_replace('admin->', '', $template); + } + + + ############################################################ + ### Get the template settings + + $q = "SELECT * FROM ".AGILE_DB_PREFIX."email_template WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + name = ".$db->qstr($template); + $template = $db->Execute($q); + if($template->fields['status'] != '1') + return; + + $E['priority'] = $template->fields["priority"]; + + ############################################################ + ### Get the setup_email settings + + if(empty($template->fields["setup_email_id"])) + $setup_email_id = DEFAULT_SETUP_EMAIL; + else + $setup_email_id = $template->fields["setup_email_id"]; + + $q = "SELECT * FROM ".AGILE_DB_PREFIX."setup_email WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($setup_email_id); + $setup_email = $db->Execute($q); + + ### E-mail queue? + if($setup_email->fields['queue'] == 1 && $queue) + { + # Set sql vars + if(is_array($sql1)) $sql1 = serialize($sql1); + if(is_array($sql2)) $sql2 = serialize($sql2); + if(is_array($sql3)) $sql3 = serialize($sql3); + if(is_array($VAR)) $var = serialize($VAR); + if(@$admin_only) + $sql_template = "admin->".$template->fields['name']; + else + $sql_template = $template->fields['name']; + + # Check that this email is not already in the queue: + $q = "SELECT id FROM ".AGILE_DB_PREFIX."email_queue WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + status = 0 AND + account_id = '$acct' AND + email_template= ".$db->qstr($sql_template)." AND + sql1 = ".$db->qstr(@$sql1)." AND + sql2 = ".$db->qstr(@$sql2)." AND + sql3 = ".$db->qstr(@$sql3); + $duplicates = $db->Execute($q); + if($duplicates != false && $duplicates->RecordCount() > 0) + return; + + # queue this e-mail: + $id = $db->GenID(AGILE_DB_PREFIX.'email_queue_id'); + $sql = "INSERT INTO ".AGILE_DB_PREFIX."email_queue SET + id = $id, + site_id = ".DEFAULT_SITE.", + date_orig = ".time().", + date_last = ".time().", + status = 0, + account_id = '$acct', + email_template= ".$db->qstr($sql_template).", + sql1 = ".$db->qstr(@$sql1).", + sql2 = ".$db->qstr(@$sql2).", + sql3 = ".$db->qstr(@$sql3).", + var = ".$db->qstr(@$var); + $db->Execute($sql); + return; + } + + if($setup_email->fields['type'] == 0) { + $type = 0; + } else { + $type = 1; + $E['server'] = $setup_email->fields['server']; + $E['account'] = $setup_email->fields['username']; + $E['password'] = $setup_email->fields['password']; + } + + $E['from_name'] = $setup_email->fields['from_name']; + $E['from_email'] = $setup_email->fields['from_email']; + + if($setup_email->fields['cc_list'] != '') + $E['cc_list'] = split(',', $setup_email->fields['cc_list']); + + if($setup_email->fields['bcc_list'] != '') + $E['bcc_list'] = split(',', $setup_email->fields['bcc_list']); + + + + ############################################################ + ### Get the account settings + + $q = "SELECT * FROM ".AGILE_DB_PREFIX."account WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + ( + email = ".$db->qstr($acct)." OR + id = ".$db->qstr($acct). " + )"; + $account = $db->Execute($q); + if($account == false) + { + $C_debug->error('email_template.inc.php','send1', $db->ErrorMsg() . " " . $sql); + return false; + } + else + { + if($admin_only == false) + { + if($account->RecordCount() > 0) { + $E['to_email'] = $account->fields['email']; + $E['to_name'] = $account->fields['first_name'] . ' ' . $account->fields['last_name']; + $this->ab_account = true; + } else { + $E['to_email'] = $acct; + $E['to_name'] = $acct; + $this->ab_account = false; + } + } else { + $E['to_email'] = $setup_email->fields['from_email']; + $E['to_name'] = $setup_email->fields['from_name']; + $this->ab_account = true; + } + } + + + ############################################################ + ### Get the template translation for the specified account for text/htm + + if(@$this->ab_account && @$account->fields["language_id"] != "") + $language_id = $account->fields["language_id"]; + else + $language_id = DEFAULT_LANGUAGE; + + $q = "SELECT * FROM ".AGILE_DB_PREFIX."email_template_translate WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + language_id = ".$db->qstr($language_id)." AND + email_template_id = ".$db->qstr($template->fields["id"]); + $setup_email = $db->Execute($q); + + if(!$setup_email || !$setup_email->RecordCount()) { + # get the default translation for this email: + $q = "SELECT * FROM ".AGILE_DB_PREFIX."email_template_translate WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + language_id = ".$db->qstr(DEFAULT_LANGUAGE)." AND + email_template_id = ".$db->qstr($template->fields["id"]); + $setup_email = $db->Execute($q); + } + + if(!$setup_email || !$setup_email->RecordCount()) { + # unable to locate translation! + global $C_debug; + $message = 'Unable to locate translation for Email Template "'.$template->fields['name'].'" and Language "'. $language_id .'" OR "' . DEFAULT_LANGUAGE . '"'; + $C_debug->error('email_template.inc.php','send', $message); + return; + } + + + # set the subject: + $E['subject'] = $setup_email->fields['subject']; + + # determine whether to send HTML or not... + if(@$this->ab_account && $account->fields['email_type'] == 1) { + if(!empty($setup_email->fields['message_html'])) { + $E['body_html'] = $setup_email->fields['message_html']; + $E['html'] = '1'; + } else { + $E['body_html'] = false; + $E['html'] = '0'; + } + } else { + $E['html'] = '0'; + } + + $E['body_text'] = $setup_email->fields['message_text']; + + ### Get the date-time + include_once(PATH_CORE.'list.inc.php'); + $C_list = new CORE_list; + $date = $C_list->date_time(time()); + + ### Url formatting... + if($admin_only) { + $site_url = URL.'admin.php'; + $site_ssl_url = SSL_URL.'admin.php'; + } else { + $site_url = URL; + $site_ssl_url = SSL_URL; + } + + ### Get the replace vars from the email template: + $replace = Array('%site_name%' => $E['from_name'], + '%site_email%' => $E['from_email'], + '%url%' => $site_url, + '%date%' => $date, + '%ssl_url%' => $site_ssl_url); + + ### Get the replace vars from the $VAR variable: + reset($VAR); + while(list($key, $value) = each($VAR)) + { + $re_this = "%var_".$key."%"; + $replace[$re_this] = $value; + } + + ### Get the replace vars from the account: + $replace['%acct_id%'] = $acct; + if(@$this->ab_account) { + while(list($key, $value) = each($account->fields)) { + $re_this = "%acct_".$key."%"; + $replace[$re_this] = $value; + } + } + + ############################################################ + ### Get the SQL1 Query/Arrays + if(!empty($template->fields["sql_1"]) && !empty($sql1) &&!is_array($sql1)) + { + $sql = eregi_replace('%DB_PREFIX%', AGILE_DB_PREFIX, $template->fields["sql_1"]); + $sql = eregi_replace('%SQL1%', $db->qstr($sql1), $sql); + if(!is_array($sql2)) + $sql = eregi_replace('%SQL2%', $db->qstr($sql2), $sql); + if(!is_array($sql3)) + $sql = eregi_replace('%SQL3%', $db->qstr($sql3), $sql); + $sql .= " AND site_id = ". $db->qstr(DEFAULT_SITE); + $SQL_1 = $db->Execute($sql); + + if($SQL_1 == false) + { + ### return the error message + global $C_debug; + $C_debug->error('email_template.inc.php','send', $db->ErrorMsg() . " " . $sql); + } + else if($SQL_1->RecordCount() > 0) + { + ### Get the replace vars from the sql results: + while(list($key, $value) = each($SQL_1->fields)) + { + $re_this = "%sql1_".$key."%"; + $replace[$re_this] = $value; + } + } + } + elseif (is_array($sql1)) + { + while(list($key, $value) = each($sql1[$i])) + $replace[$key] = $value; + } + elseif (!empty($sql1)) + { + $replace['%sql1%'] = $sql3; + } + + + ############################################################ + ### Get the SQL2 Query/Arrays + if(!empty($template->fields["sql_2"]) && !empty($sql2) &&!is_array($sql2)) + { + $sql = eregi_replace('%DB_PREFIX%', AGILE_DB_PREFIX, $template->fields["sql_2"]); + $sql = eregi_replace('%SQL1%', $db->qstr($sql1), $sql); + if(!is_array($sql2)) + $sql = eregi_replace('%SQL2%', $db->qstr($sql2), $sql); + if(!is_array($sql3)) + $sql = eregi_replace('%SQL3%', $db->qstr($sql3), $sql); + $sql .= " AND site_id = ".$db->qstr(DEFAULT_SITE); + $SQL_2 = $db->Execute($sql); + if($SQL_2 == false) + { + ### return the error message + global $C_debug; + $C_debug->error('email_template.inc.php','send', $db->ErrorMsg() . " " . $sql); + } + else if($SQL_2->RecordCount() > 0) + { + ### Get the replace vars from the sql results: + while(list($key, $value) = each($SQL_2->fields)) + { + $re_this = "%sql2_".$key."%"; + $replace[$re_this] = $value; + } + } + } + elseif (is_array($sql2)) + { + while(list($key, $value) = each($sql2[$i])) + $replace[$key] = $value; + } + elseif (!empty($sql2)) + { + $replace['%sql2%'] = $sql2; + } + + + ############################################################ + ### Get the SQL3 Query/Arrays + if(!empty($template->fields["sql_3"]) && !empty($sql3) &&!is_array($sql3)) + { + $sql = eregi_replace('%DB_PREFIX%', AGILE_DB_PREFIX, $template->fields["sql_3"]); + $sql = eregi_replace('%SQL1%', $db->qstr($sql1), $sql); + if(!is_array($sql2)) + $sql = eregi_replace('%SQL2%', $db->qstr($sql2), $sql); + if(!is_array($sql3)) + $sql = eregi_replace('%SQL3%', $db->qstr($sql3), $sql); + $sql .= " AND site_id = ".$db->qstr(DEFAULT_SITE); + $SQL_3 = $db->Execute($sql); + if($SQL_3 == false) + { + ### return the error message + global $C_debug; + $C_debug->error('email_template.inc.php','send', $db->ErrorMsg() . " " . $sql); + } + else if($SQL_3->RecordCount() > 0) + { + ### Get the replace vars from the sql results: + while(list($key, $value) = each($SQL_3->fields)) + { + $re_this = "%sql3_".$key."%"; + $replace[$re_this] = $value; + } + } + } + elseif (is_array($sql3)) + { + while(list($key, $value) = each($sql3)) + $replace[$key] = $value; + } + elseif (!empty($sql3)) + { + $replace['%sql3%'] = $sql3; + } + + ### Replace the $replace vars in the body and subject + while(list($key, $value) = each($replace)) + { + $E['subject'] = eregi_replace($key, $value, $E['subject']); + $E['body_text'] = eregi_replace($key, $value, $E['body_text']); + if(!empty($E['body_html'])) + $E['body_html'] = eregi_replace($key, $value, $E['body_html']); + } + + ### Remove any unparsed vars from the body text and html: + if(!empty($E['body_html']) && ereg('%',$E['body_html'])) + @$E['body_html'] = ereg_replace("%[a-zA-Z0-9_]{1,}%", '', $E['body_html']); + if(!empty($E['body_text']) && ereg("%",$E['body_text'])) + @$E['body_text'] = ereg_replace("%[a-zA-Z0-9_]{1,}%", '', $E['body_text']); + + ### Set any attachments (not currently supported) + $E['attatchments'] = ''; + + /* email log? */ + global $C_list; + if(is_object($C_list) && $C_list->is_installed('email_log')) { + include_once(PATH_MODULES.'email_log/email_log.inc.php'); + $log = new email_log; + $log->add($acct, $E['subject'], $E['body_text'], $E['to_email'], false, $E['priority']); + } + + ### Call the mail class + require_once(PATH_CORE . 'email.inc.php'); + $email = new CORE_email; + $email->debug=$this->debug; + if($type == 0) + return $email->PHP_Mail($E); + else + return $email->SMTP_Mail($E); + } +} +?> \ No newline at end of file diff --git a/modules/email_template/email_template_construct.xml b/modules/email_template/email_template_construct.xml new file mode 100644 index 00000000..dd5f4db6 --- /dev/null +++ b/modules/email_template/email_template_construct.xml @@ -0,0 +1,74 @@ + + + + email_template + + email_template
+ + + + 0 + + name + + 25 + + + name + + + + + I8 + 1 + 1 + + + I4 + 1 + + + I4 + setup_email + name + 1 + + + C(128) + 4 + 128 + any + + + L + + + X2 + + + X2 + + + X2 + + + X2 + + + X2 + + + L + + + + + id,site_id,setup_email_id,name,priority,shortcuts,notes,sql_1,sql_2,sql_3,status + id,site_id,setup_email_id,priority,shortcuts,notes,sql_1,sql_2,sql_3,status + id,site_id,setup_email_id,name,priority,shortcuts,notes,sql_1,sql_2,sql_3,status + id,site_id,setup_email_id,name,priority,shortcuts,notes,sql_1,sql_2,sql_3,status + id,site_id,setup_email_id,name,priority,shortcuts,notes,sql_1,sql_2,sql_3,status + + + 0 +
diff --git a/modules/email_template/email_template_install.xml b/modules/email_template/email_template_install.xml new file mode 100644 index 00000000..31562720 --- /dev/null +++ b/modules/email_template/email_template_install.xml @@ -0,0 +1,35 @@ + + + email_template + setup + + 1 + + + + + search + + + view + + + 1 + + + search_show + + + add + + 1 + + + delete + + + update + + + + \ No newline at end of file diff --git a/modules/email_template/email_template_install_data.xml b/modules/email_template/email_template_install_data.xml new file mode 100644 index 00000000..a07bde69 --- /dev/null +++ b/modules/email_template/email_template_install_data.xml @@ -0,0 +1,611 @@ + + + + 11 + 1 + 1 + account_reset_password + 1 + all + This email is sent to the user when they use the password retrieval program + 1 + + + 12 + 1 + 1 + account_registration_active + 0 + all + + 1 + + + 14 + 1 + 1 + account_registration_inactive + 1 + all + This email is sent to the user after account registration, if email verification is required. + 1 + + + 15 + 1 + 1 + account_add_staff_active + 0 + all + This is the email a user recieves when the staff adds their new account as active + 1 + + + 16 + 1 + 1 + account_add_staff_inactive + 0 + all + This email is sent to users when a staff-member creates their account as inactive + 1 + + + 17 + 1 + 1 + password_change_instructions + 0 + all + This email is sent by the administrator / staff to resend the change password instructions... + 1 + + + 18 + 1 + 1 + affiliate_staff_add + 0 + * + This e-mail template is sent when staff/admin adds a new affiliate account. + 1 + + + 19 + 1 + 1 + affiliate_user_add_active + 0 + * + This e-mail template is sent when the user signs up for an affiliate account and is automatically approved. + 1 + + + 20 + 1 + 1 + affiliate_user_add_pending + 0 + * + This e-mail template is sent when an affiliate signs up for an account and it requires admin approval. + 1 + + + 21 + 1 + 1 + affiliate_user_add_staff_notify + 0 + * + This e-mail template is sent to the staff when a pending affiliate application is received. + 1 + + + 22 + 1 + 1 + invoice_confirm_user + 0 + all + + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + SELECT email_template FROM %DB_PREFIX%checkout WHERE id = %SQL2% + 1 + + + 23 + 1 + 1 + invoice_confirm_admin + 0 + all + Sends the admin an new invoice alert. + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + SELECT email_template FROM %DB_PREFIX%checkout WHERE id = %SQL2% + 1 + + + 24 + 1 + 1 + invoice_due_user + 0 + all + Sends the user a due invoice alert when new invoice is created or they pay via a 3rd party method. + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + 1 + + + 25 + 1 + 1 + invoice_due_admin + 0 + all + Alert sent to admin when manual payment needs processed. + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + 1 + + + 26 + 1 + 1 + invoice_paid_user + 0 + all + Notify user of payment recieved for an invoice. + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + SELECT * FROM %DB_PREFIX%currency WHERE id = %SQL2% + 1 + + + 27 + 1 + 1 + invoice_paid_admin + 0 + all + Notify admin of payment recieved for an invoice. + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + SELECT * FROM %DB_PREFIX%currency WHERE id = %SQL2% + 1 + + + 28 + 1 + 1 + invoice_resend + 0 + all + Resends payment due alert.... + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + 1 + + + 29 + 1 + 1 + invoice_manual_auth_admin + 0 + all + Sends admin alert that an invoice requires manual approval + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + SELECT checkout_plugin FROM %DB_PREFIX%checkout WHERE id = %SQL2% + 1 + + + 30 + 1 + 1 + invoice_approved_user + 0 + all + Sent to user when invoice status is updated to approved + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + 1 + + + 31 + 1 + 1 + registrar_manual_admin + 0 + All + Sends selected staff member an alert to manually renew, register, transfer, or park a domain name. + SELECT * FROM %DB_PREFIX%account WHERE id = %SQL1% + 1 + + + 32 + 1 + 1 + registrar_bulkregister_admin + 0 + All + + 1 + + + 33 + 1 + 1 + registrar_nominet_admin + 0 + all + 1 + + + 35 + 1 + 1 + invoice_recur_user + 0 + all + Sends the user notification of new invoice created for a recurring service + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + 1 + + + 36 + 1 + 1 + invoice_recur_admin + 0 + all + Sends the admin notification of new invoice created for a recurring service + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + 1 + + + 37 + 1 + 1 + service_suspend_user + 0 + all + Sends the user notice that service(s) have been suspended due to non-payment. + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + 1 + + + 38 + 1 + 1 + service_suspend_admin + 0 + all + Sends the admin notice that service(s) have been suspended due to non-payment. + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + 1 + + + 39 + 1 + 1 + host_new_user + 0 + all + This e-mail is sent to the user when their hosting account is provisioned + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + 1 + + + 40 + 1 + 1 + host_edit_user + 0 + all + This e-mail is sent to the user when their hosting account is edited + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + 1 + + + 41 + 1 + 1 + host_new_admin + 0 + all + Email sent to admin to notify of new manual provisioning required. + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + 1 + + + 42 + 1 + 1 + host_edit_admin + 0 + all + Email sent to admin to notify that edit of manual provisioning required. + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + 1 + + + 43 + 1 + 1 + host_inactive_admin + 0 + all + Email sent to admin to notify that edit of manual suspend required. + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + 1 + + + 44 + 1 + 1 + host_active_admin + 0 + all + Email sent to admin to notify that edit of manual activation required. + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + 1 + + + 45 + 1 + 1 + host_delete_admin + 0 + all + Email sent to admin to notify that edit of manual deletion required. + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + 1 + + + 46 + 1 + 1 + service_cancel_user + 0 + all + Notify user of service cancelation + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + 1 + + + 47 + 1 + 1 + service_cancel_admin + 0 + all + Notify admin of service cancelation + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + 1 + + + 48 + 1 + 1 + service_changeschedule_admin + 0 + all + Sends admin notice that user has selected a different billing schedule. + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + 1 + + + 638 + 1 + 1 + login_share_ban_user + 1 + 1 + + + 639 + 1 + 1 + login_share_ban_admin + 0 + 1 + + + 640 + 1 + 1 + account_billing_exp_soon + 0 + Sent when a credit card is set to expire soon, triggered by the account_billing::task + SELECT * FROM %DB_PREFIX%account_billing WHERE id = %SQL1% + 1 + + + 651 + 1 + 1 + net_term_suspend + 0 + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + 1 + + + 652 + 1 + 1 + net_term_late_notice + 0 + SELECT * FROM %DB_PREFIX%invoice WHERE id = %SQL1% + 1 + + + 653 + 1 + 1 + voip_balance_prepaid + 0 + SELECT * FROM %DB_PREFIX%voip_prepaid WHERE id = %SQL1% + 1 + + + 654 + 1 + 1 + voip_manual + 0 + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + + 1 + + + 655 + 1 + 1 + voip_new_prepaid_ani + 0 + SELECT * FROM %DB_PREFIX%voip_prepaid WHERE id=%SQL1% + 1 + + + 656 + 1 + 1 + voip_new_prepaid_pin + 0 + SELECT * FROM %DB_PREFIX%voip_prepaid WHERE id=%SQL1% + + 1 + + + 657 + 1 + 1 + voip_new_service + 0 + SELECT * FROM %DB_PREFIX%service WHERE id = %SQL1% + + SELECT * FROM %DB_PREFIX%voip_vm WHERE mailbox=%SQL3% + 1 + + + 658 + 1 + 3 + ticket_piping_add_user + 0 + This e-mail is set to the user when a e-mail message is successfully piped to a new ticket. + SELECT * FROM %DB_PREFIX%ticket WHERE id = %SQL1% + 1 + + + 659 + 1 + 3 + ticket_piping_add_user_pending + 0 + This e-mail is set to the user when a e-mail message is piped to a new ticket and requires further authorization... + SELECT * FROM %DB_PREFIX%ticket WHERE id = %SQL1% + 1 + + + 660 + 1 + 3 + ticket_piping_add_user_unauth + 0 + This e-mail is set to the user when a e-mail message is piped to a new ticket and requires further authorization... + SELECT * FROM %DB_PREFIX%ticket WHERE id = %SQL1% + 1 + + + 661 + 1 + 1 + ticket_staff_add + 0 + all + This template is sent to all applicable staff members (except the staff member who added the ticket) when a staff member adds a new ticket + SELECT * FROM %DB_PREFIX%ticket WHERE id = %SQL1% + SELECT * FROM %DB_PREFIX%ticket_department WHERE id = %SQL2% + 1 + + + 662 + 1 + 1 + ticket_staff_add_user + 0 + all + This template is sent to the user when a staff member adds a new ticket to their account + SELECT * FROM %DB_PREFIX%ticket WHERE id = %SQL1% + 1 + + + 663 + 1 + 1 + ticket_staff_update_user + 0 + all + This template is sent out to the user when a staff member updates one of their tickets... + SELECT * FROM %DB_PREFIX%ticket WHERE id = %SQL1% + 1 + + + 664 + 1 + 1 + ticket_user_add + 0 + all + This template is sent out when a new ticket is added + SELECT * FROM %DB_PREFIX%ticket WHERE id = %SQL1% + 1 + + + 665 + 1 + 1 + ticket_user_add_staff + 0 + all + This email is sent to all ticket staff members who are set to recieve new ticket notices + SELECT * FROM %DB_PREFIX%ticket WHERE id = %SQL1% + SELECT * FROM %DB_PREFIX%ticket_department WHERE id = %SQL2% + 1 + + + 666 + 1 + 1 + ticket_user_update + 0 + All + This is sent to the user when they respond to a ticket + SELECT * FROM %DB_PREFIX%ticket WHERE id = %SQL1% + 1 + + + 667 + 1 + 1 + ticket_user_update_staff + 0 + all + This email is sent to all ticket staff members who are set to recieve updated ticket notices + SELECT * FROM %DB_PREFIX%ticket WHERE id = %SQL1% + SELECT * FROM %DB_PREFIX%ticket_department WHERE id = %SQL2% + 1 + + + 668 + 1 + 1 + invoice_pregen_notice + 0 + Sends out a notice to user prior to generating invoices + SELECT sum(price) as price FROM %DB_PREFIX%service WHERE id in (%SQL1%) + SELECT symbol,three_digit FROM %DB_PREFIX%currency WHERE id = %SQL2% + 1 + + + 668 + + + 668 + + \ No newline at end of file diff --git a/modules/email_template_translate/email_template_translate.inc.php b/modules/email_template_translate/email_template_translate.inc.php new file mode 100644 index 00000000..a40c94dd --- /dev/null +++ b/modules/email_template_translate/email_template_translate.inc.php @@ -0,0 +1,125 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class email_template_translate +{ + + # Open the constructor for this mod + function email_template_translate() + { + # name of this module: + $this->module = "email_template_translate"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/email_template_translate/email_template_translate_construct.xml b/modules/email_template_translate/email_template_translate_construct.xml new file mode 100644 index 00000000..6a81363a --- /dev/null +++ b/modules/email_template_translate/email_template_translate_construct.xml @@ -0,0 +1,64 @@ + + + email_template_translate + + email_template_translate
+ + email_template + + 0 + + email_template_id + + 25 + + + email_template_id + language_id + + + + + I8 + 1 + 1 + + + I4 + 1 + + + I8 + email_template + name + + + C(16) + + + C(255) + 1 + 255 + any + + + X2 + any + 1 + + + X2 + 1 + + + + + id,site_id,email_template_id,language_id,subject,message_text,message_html + id,site_id,email_template_id,language_id,subject,message_text,message_html + id,site_id,email_template_id,language_id,subject,message_text,message_html + id,site_id,email_template_id,language_id,subject,message_text,message_html + id,site_id,email_template_id,language_id,subject,message_text,message_html + + + 1 +
diff --git a/modules/email_template_translate/email_template_translate_install.xml b/modules/email_template_translate/email_template_translate_install.xml new file mode 100644 index 00000000..eefc8aca --- /dev/null +++ b/modules/email_template_translate/email_template_translate_install.xml @@ -0,0 +1,34 @@ + + + email_template_translate + email_template + + + + + + search + + + view + + + add + + + + delete + + + update + + + search_form + + + search_show + + + + + \ No newline at end of file diff --git a/modules/email_template_translate/email_template_translate_install_data.xml b/modules/email_template_translate/email_template_translate_install_data.xml new file mode 100644 index 00000000..15dd5a92 --- /dev/null +++ b/modules/email_template_translate/email_template_translate_install_data.xml @@ -0,0 +1,2969 @@ + + + + 2 + 1 + 4 + english + New Ticket ( %var_ticket_subject% ) + + We have received your new ticket, dated %date%.
+
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please provide the following information:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%
+
+
]]> + + + 3 + 1 + 5 + english + New Ticket ( %sql2_name% ) %var_ticket_subject% + + We have recieved a new ticket on %date%, with a priority of %var_ticket_priority%.
+
+==================================================
+%var_ticket_subject%
+==================================================
+%var_ticket_body%
+==================================================
+
+%url%admin.php?_page=ticket:view&id=%sql1_id%
+
]]> + + + 4 + 1 + 6 + english + Updated Ticket ( %sql1_subject% ) + + This e-mail is to let you know we have recieved your response to your ticket, dated %date%.
+
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please provide the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%
+
+]]>
+
+ + 5 + 1 + 7 + english + Updated Ticket ( %sql2_name% ) %sql1_subject% + + We have received a reply to a ticket at %date%, with a priority of %sql1_priority%.
+
+==================================================
+%sql1_subject%
+==================================================
+%var_ticket_reply%
+==================================================
+
%url%admin.php?_page=ticket:view&id=%sql1_id%
]]>
+
+ + 6 + 1 + 9 + english + New Ticket (%var_ticket_subject% ) + + +
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If promted, please provide the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+
Subject: %var_ticket_subject%
+
%var_ticket_body%
+

+Thank you,
+%site_name%]]>
+
+ + 7 + 1 + 8 + english + New Ticket ( %sql2_name% ) %var_ticket_subject% + + We have recieved a new staff issued ticket at %date%, with a priority of  %var_ticket_priority%.
+
+==================================================
+%var_ticket_subject%
+==================================================
+%var_ticket_body%
+==================================================
+
+%url%admin.php?_page=ticket:view&id=%sql1_id%]]>
+
+ + 8 + 1 + 10 + english + Ticket Response [ %sql1_subject% ] + + This e-mail is to let you know we have responded to a ticket of yours on %date%.

+

You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%

+

Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+

+

Subject: %sql1_subject%

+
%var_message%
+ +

Thank you,
+%site_name%

]]>
+
+ + 9 + 1 + 11 + english + Password Retrieval Link for %site_name% + + Dear %acct_first_name%,

You (or someone who knows your email or username) has recently submitted a password retrieval request at our site.

If this was you, you can click the link below to change your password.
The link expires in 15 minutes so be sure to do this right away:

%ssl_url%?_page=account:password_reset&validate=%sql3%

If the link above does not display as a link in your browser, you will need to paste it into the address bar of your browser instead.

If you did not request a password retrieval at our site, then you can safetly ignore and delete this email.

Thank you,
%site_name%

]]>
+
+ + 10 + 1 + 12 + english + %site_name%: User Registration Complete + Dear %acct_first_name%, + +Thank you for registering with us! + +You can login to your account any time here: +%ssl_url%?_page=account:account + +Thanks! +%site_name% + Dear %acct_first_name%,

Thank you for registering with us!

You can login to your account any time here:
%ssl_url%?_page=account:account

Thanks!
%site_name%

]]>
+
+ + 11 + 1 + 14 + english + %site_name%: Verification Required + + Dear %acct_first_name%,

We have received your registration, but futher action on your part is requested in order to activate your account.

Please click the link below in order to activate your account:
%ssl_url%?_page=account:verify&verify=%sql3%

If the text above does not show up as a clickable link, you can paste it to the address bar of your web browser. If you are not sure how to do this, or it does not work, then do the following:

Go to %ssl_url%

Click 'Verify Account'

Enter the following code into the verification form:

%sql3%

Thank you!
%site_name%

]]>
+
+ + 12 + 1 + 15 + english + New Account Created + Dear %acct_first_name%, + +One of our staff members has just added your account to our system. + +The username assigned to your account is: %acct_username% + +For security reasons, you must choose your own password here: +%ssl_url%?_page=account:password + +Once you set your password, you will be able to login to your account. + +Thank you, +%site_name% + Dear %acct_first_name%,

+

One of our staff members has just added your account to our system.

+

The username assigned to your account is: %acct_username%

+

For security reasons, you must choose your own password here:
%ssl_url%?_page=account:password

+

Once you set your password, you will be able to login to your account.

+

Thank you,
%site_name%

]]>
+
+ + 13 + 1 + 16 + english + New Account Created + + Dear %acct_first_name%,

One of our staff members has just added your account to our system. Futher action on your part is required to validate your account.

To validate your account, please click the link below:
%ssl_url%?_page=account:verify&verify=%sql3%

The username assigned to your account is: %acct_username%

For security reasons, you must choose your own password here:
%ssl_url%?_page=account:password

Once you set your password and verify your account, you will be able to login to your account.

Thank you,
%site_name%

]]>
+
+ + 14 + 1 + 17 + english + How to change your %site_name% password + Dear %acct_first_name%, + +We are sending you this e-mail because you indicated to our staff that you would like to change your account password. + +If you would like to change your password, just click this link: +%ssl_url%?_page=account:password + +You can then enter either your username or e-mail address, and we will send you a link where you can change your password. + +Thank you, +%site_name% + Dear %acct_first_name%,

We are sending you this e-mail because you indicated to our staff that you would like to change your account password.

If you would like to change your password, just click this link:
%ssl_url%?_page=account:password

You can then enter either your username or e-mail address, and we will send you a link where you can change your password.

Thank you,
%site_name%

]]>
+
+ + 15 + 1 + 18 + english + Your Affiliate Account Complete + Hello %acct_first_name%, + +This e-mail is to let you know that a member of our staff has set up an affiliate account on your behalf. + +For future reference, your Affiliate Id is %SQL3% + +You can visit the affiliate center at the link below to edit your account details, as well as view statistics, referrals, and commissions. + +%url%?_page=affiliate:affiliate + +Thank you, +%site_name% + Hello %acct_first_name%,

This +e-mail is to let you know that a member of our staff has set up an +affiliate account on your behalf. For future reference, your Affiliate +Id is %SQL3% You can visit the affiliate center at the link below to +edit your account details, as well as view statistics, referrals, and +commissions.

%url%?_page=affiliate:affiliate

Thank you,
%site_name%

]]>
+
+ + 16 + 1 + 19 + english + Your affiliate account is ready + Hello %acct_first_name%, + +This e-mail is to let you know that your affiliate account has been setup. + +For future reference, your affiliate Id is: %SQL3% + +You can visit the affiliate center at the link below to edit your account details, as well as view statistics, referrals, and commissions. + +%url%?_page=affiliate:affiliate + +Thank you, +%site_name% + Â Hello %acct_first_name%,

This e-mail is to let you know that your affiliate account has been setup.

For future reference, your affiliate Id is: %SQL3%

You +can visit the affiliate center at the link below to edit your account +details, as well as view statistics, referrals, and commissions.

%url%?_page=affiliate:affiliate

Thank you,
%site_name%

]]>
+
+ + 17 + 1 + 20 + english + Your affiliate application received + Hello %acct_first_name%, + +This e-mail is to let you know that your affiliate account application has been recieved. + +You can visit the affiliate center at the link below to view the status of your application from time to time. We will also send you an e-mail when your affiliate account is activated. + +%url%?_page=affiliate:affiliate + +Thank you, +%site_name% + Hello %acct_first_name%,

This e-mail is to let you know that your affiliate account application has been recieved.

You +can visit the affiliate center at the link below to view the status of +your application from time to time. We will also send you an e-mail +when your affiliate account is activated.

%url%?_page=affiliate:affiliate

Thank you,
%site_name%

]]>
+
+ + 18 + 1 + 21 + english + Affiliate Application Received + + A user has just submitted an affiliate application, you can view it here:

%url%?_page=affiliate:view&id=%SQL3%

]]>
+
+ + 19 + 1 + 22 + english + %site_name% Order Confirmation + + Dear %acct_first_name%,

This e-mail is to confirm that we have received your order dated %date%.

The order number is %sql1_id%, and can be viewed online HERE:

View Printable Invoice HERE:

==============================================================
Products Ordered
==============================================================
%products%
==============================================================
Order Total: %sql1_total_amt% %currency%
==============================================================
%sql2_email_template%

Thank you,
%site_name%

]]>
+
+ + 20 + 1 + 23 + english + New Invoice Alert [%sql1_id%] + %url%?_page=invoice:view&id=%sql1_id%&tid=default_admin + +Print Invoice: +-> %url%?_page=invoice:pdf&id=%sql1_id%&_escape=true&tid=default_admin + +User Details: +-> %url%?_page=account_admin:view&id=%acct_id%&tid=default_admin +]]> + A new invoice has been created for %acct_first_name% %acct_last_name% on %date%.

==============================================================
Products Ordered
==============================================================
%products%
==============================================================
Order Total:   %sql1_total_amt% %currency%
==============================================================

Invoice Details | Print Invoice | User Details  

]]>
+
+ + 21 + 1 + 24 + english + Invoice Due Notification [%sql1_id%] + + %acct_first_name%,

This e-mail is to remind you that payment is due for invoice %sql1_id% by %sql3%.

If you have already paid for this invoice, you may ignore this e-mail.

Otherwise, please follow the link below to view the invoice details and make payment.

%ssl_url%?_page=invoice:user_view&id=%sql1_id%

Thank you,
%site_name%

]]>
+
+ + 22 + 1 + 25 + english + Invoice Manual Processing [%sql1_id%] + %url%?_page=invoice:view&id=%sql1_id%&tid=default_admin + +Account Details: +> %url%?_page=account_admin:view&id=%acct_id%&tid=default_admin +]]> + This alert is to notify you that manual processing/verification is required for invoice number %sql1_id%, which is due on %sql3%.

Invoice Details | Account Details

]]>
+
+ + 23 + 1 + 26 + english + Payment Received for Invoice %sql1_id% + + Dear %acct_first_name%,

This e-mail is to notify you that we have recieved your payment for invoice number %sql1_id%.

The total amount of the invoice is %sql1_total_amt%. To date, you have paid %sql1_billed_amt%.

For more details on this invoice, you can view it online at the link below:
%url%?_page=invoice:user_view&id=%sql1_id%

Thank you,
%site_name%

]]>
+
+ + 24 + 1 + 27 + english + Payment Received for Invoice %sql1_id% + %url%?_page=invoice:view&id=%sql1_id%&tid=default_admin + +User Details: +> %url%?_page=account_admin:view&id=%acct_id%&tid=default_admin + +Thank you, +%site_name%]]> + This e-mail is to alert you that %acct_first_name% %acct_last_name% made a payment for invoice number %sql1_id%.

Payment in the amount of %sql1_billed_amt% %sql2_three_digit% of the %sql1_total_amt% %sql2_three_digit% has been made.

Invoice Details | User Details

]]>
+
+ + 25 + 1 + 28 + english + Notice: Invoice %sql1_id% Due! + + Dear %acct_first_name%,

Invoice number %sql1_id% is now overdue, please visit the link below for payment options.

%ssl_url%?_page=invoice:user_view&id=%sql1_id%

Thank you,
%site_name%

]]>
+
+ + 26 + 1 + 29 + english + Manual Approval Required for Invoice Number %sql1_id% + + This +message is to notify you that payment has been recieved for invoice +number %sql1_id% via %sql2_checkout_plugin% and manual approval is +required.

+

%url%admin.php?_page=invoice:view&id=%sql1_id%

]]>
+
+ + 27 + 1 + 30 + english + Invoice Approved + + Dear %acct_first_name%,

This alert is to notify you that invoice number %sql1_id% has been updated to approved status.

You can view the details of this invoice below:
%url%?_page=invoice:user_view&id=%sql1_id%

Thank you,
%site_name%

]]>
+
+ + 28 + 1 + 31 + english + Manual Registrar Action Required + %sql3% + +Account Details: +%sql1_first_name% %sql1_middle_name% %sql1_last_name% +%sql1_address1% %sql1_address2% +%sql1_city%, %sql1_state% %sql1_zip% +%sql1_email% + %sql3%

Account Details:
%sql1_first_name% %sql1_middle_name% %sql1_last_name%
%sql1_address1% %sql1_address2%
%sql1_city%, %sql1_state% %sql1_zip%
%sql1_email%

]]>
+
+ + 29 + 1 + 32 + english + + %sql3% + %sql3%
]]> + + + 30 + 1 + 33 + english + TAG (%sql2%) Domain Request + %sql3% + %sql3%
]]> + + + 32 + 1 + 35 + english + New Invoice Created [%sql1_id%] + + %acct_first_name%,

This e-mail is a friendly reminder that invoice %sql1_id% has been automatically generated for the amount of %sql2% and that payment is due  by %sql3%.

If you have already paid for this invoice, you may ignore this e-mail.

Otherwise, please follow the link below to view the invoice details and make payment.

%url%?_page=invoice:user_view&id=%sql1_id%

Thank you,
%site_name%

]]>
+
+ + 33 + 1 + 36 + english + New Invoice Created [%sql1_id%] + + This e-mail is to remind you that a new invoice numbered %sql1_id% has been generated for the amount of %sql2% and is due by %sql3%.

%url%?_page=invoice:view&id=%sql1_id%&tid=default_admin

]]>
+
+ + 34 + 1 + 37 + english + Service Suspended for Invoice [%sql1_id%] + + %acct_first_name%,

This e-mail is a friendly notice that service(s) for invoice %sql1_id% have been suspended due to nonpayment by %sql3%.

Please follow the link below to view the invoice details and make payment.

%ssl_url%?_page=invoice:user_view&id=%sql1_id%

Thank you,
%site_name%

]]>
+
+ + 35 + 1 + 38 + english + Service Suspended for Invoice [%sql1_id%] + + This e-mail is notice that service(s) for invoice %sql1_id% have been suspended due to nonpayment by %sql3%.

%url%?_page=invoice:view&id=%sql1_id%&tid=default_admin

]]>
+
+ + 36 + 1 + 39 + english + Hosting Details + %acct_first_name%, + +This e-mail is to alert you that your hosting account has been setup. The details are as follows: + +Username: %sql1_host_username% +Password: %sql1_host_password% + +Thank you, +%site_name% + %acct_first_name%,

This e-mail is to alert you that your hosting account has been setup. The details are as follows:
 
Username: %sql1_host_username%
Password: %sql1_host_password%

Thank you,
%site_name%

]]>
+
+ + 37 + 1 + 40 + english + Hosting Updated + %acct_first_name%, + +This e-mail is to alert you that your hosting account has been modified. The details are as follows: + +Username: %sql1_host_username% +Password: %sql1_host_password% + +Thank you, +%site_name% + %acct_first_name%,

This e-mail is to alert you that your hosting account has been modified. The details are as follows:
 
Username: %sql1_host_username%
Password: %sql1_host_password%

Thank you,
%site_name%

]]>
+
+ + 38 + 1 + 41 + english + Manual Provisioning: New Account + + This e-mail is to notify you that a new hosting service has been created that requires manual provisioning.

Invoice No.: %sql1_invoice_id%
Plan SKU: %sql1_sku%
Username: %sql1_host_username%
Password: %sql1_host_password%
Ip Address: %sql1_host_ip%

View the service:
%url%?_page=service:view&id=%sql1_id%&tid=default_admin

]]>
+
+ + 39 + 1 + 42 + english + Manual Provisioning: Edit + + This e-mail is to notify you that a hosting service has been modified and may require manual provisioning.

Invoice No.: %sql1_invoice_id%
Plan SKU: %sql1_sku%
Username: %sql1_host_username%
Password: %sql1_host_password%
Ip Address: %sql1_host_ip%

View the service:
%url%?_page=service:view&id=%sql1_id%&tid=default_admin

]]>
+
+ + 40 + 1 + 43 + english + Manual Provisioing: Suspend + + This e-mail is to notify you that a hosting service has been deactivated and requires manual provisioning.

Invoice No.: %sql1_invoice_id%
Plan SKU: %sql1_sku%
Username: %sql1_host_username%
Password: %sql1_host_password%
Ip Address: %sql1_host_ip%

View the service:
%url%?_page=service:view&id=%sql1_id%&tid=default_admin

]]>
+
+ + 41 + 1 + 44 + english + Manual Provisioning: Activate + + This e-mail is to notify you that a hosting service has been activated and requires manual provisioning.

Invoice No.: %sql1_invoice_id%
Plan SKU: %sql1_sku%
Username: %sql1_host_username%
Password: %sql1_host_password%
Ip Address: %sql1_host_ip%

View the service:
%url%?_page=service:view&id=%sql1_id%&tid=default_admin

]]>
+
+ + 42 + 1 + 45 + english + Manual Provisioning: Delete + This e-mail is to notify you that a hosting service has been deleted and requires manual provisioning. + +Invoice No.: %sql1_invoice_id% +Plan SKU: %sql1_sku% +Username: %sql1_host_username% +Password: %sql1_host_password% +Ip Address: %sql1_host_ip% +Domain: %sql1_domain_name%.%sql1_domain_tld% + This e-mail is to notify you that a hosting service has been deleted and requires manual provisioning.

Invoice No.: %sql1_invoice_id%
Plan SKU: %sql1_sku%
Username: %sql1_host_username%
Password: %sql1_host_password%
Ip Address: %sql1_host_ip%
Domain: %sql1_domain_name%.%sql1_domain_tld%

]]>
+
+ + 43 + 1 + 46 + english + Service Cancelation Confirmation + %acct_first_name%, + +This e-mail is to notify you that your service id %sql1_id% for SKU %sql1_sku% has been canceled. + +Thank you, +%site_name% + %acct_first_name%,

This e-mail is to notify you that your service id %sql1_id% for SKU %sql1_sku% has been canceled.

Thank you,
%site_name%

]]>
+
+ + 44 + 1 + 47 + english + Service Cancelation + + This e-mail is to notify you that %acct_first_name% %acct_last_name%'s service id %sql1_id% for SKU %sql1_sku% has been canceled.]]> + + + 45 + 1 + 48 + english + Service Billing Schedule Change Requested + + This e-mail is to notify you that %acct_first_name% %acct_last_name% has requested a change of billing schedule for service id %sql1_id%.

Current Billing Schedule: %sql2%
Requested Billing Schedule: %sql3%

View service details | View account details | View invoice details

]]>
+
+ + 104 + 1 + 104 + english + New Ticket ( %var_ticket_subject% ) + + We have recently received your email dated %date% with the following subject:
+
+%var_ticket_subject%
+
+You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%]]>
+
+ + 105 + 1 + 105 + english + New Ticket Received - Authorization Required + + We have recently received your e-mail dated %date% with the following subject:
+
+%var_ticket_subject%
+
+Further action on your part is required before we can process your request, for one of two possible reasons:
+
+ +1) The department you sent your request to requires that you have an account with us and maintain a particular subscription.
+
+ +2) The e-mail address you sent your request from is not the same as the e-mail address on file in your your account with us.
+ + + + +

To +rectify this situation, please visit the link below and provide your +login details so we can associate your request with an authorized +account:

You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+
Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff.
+
+ +Thank you,
+ +%site_name%
+

]]>
+
+ + 106 + 1 + 106 + english + Unable to Process your e-mail request + We have recently received your e-mail dated %date% with the following subject: + +%var_ticket_subject% + +We regret to inform you that we are unable to process your request for the following reason: + +The department you sent your request to requires that you have an account with us and maintain a particular subscription. + +Please check the link below to see if there are any other departments which your account is authorized to access: + +%url%?_page=ticket:ticket + +If no available departments are listed at the link above, please contact customer service with your account details and request details for any additional requirements needed to access our ticket system. + +Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff. + +Thank you, +%site_name% + + We have recently received your e-mail dated %date% with the following subject:
+
+%var_ticket_subject%
+
+We regret to inform you that we are unable to process your request for the following reason:
+
+The department you sent your request to requires that you have an account with us and maintain a particular subscription.
+
+ +Please check the link below to see if there are any other departments which your account is authorized to access:
+ + + +

+

%url%?_page=ticket:ticket
+
+

+

If no available departments are listed at the link above, please +contact customer service with your account details and request details +for any additional requirements needed to access our ticket system.
+
+ +Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff.
+
+ +Thank you,
+ +%site_name%
+ +

]]>
+
+ + 616 + 1 + 616 + english + New Ticket ( %var_ticket_subject% ) + + We have recently received your email dated %date% with the following subject:
+
+%var_ticket_subject%
+
+You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%]]>
+
+ + 617 + 1 + 617 + english + New Ticket ( %var_ticket_subject% ) + + We have recently received your email dated %date% with the following subject:
+
+%var_ticket_subject%
+
+You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%]]>
+
+ + 618 + 1 + 618 + english + New Ticket ( %var_ticket_subject% ) + + We have recently received your email dated %date% with the following subject:
+
+%var_ticket_subject%
+
+You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%]]>
+
+ + 619 + 1 + 619 + english + New Ticket Received - Authorization Required + + We have recently received your e-mail dated %date% with the following subject:
+
+%var_ticket_subject%
+
+Further action on your part is required before we can process your request, for one of two possible reasons:
+
+ +1) The department you sent your request to requires that you have an account with us and maintain a particular subscription.
+
+ +2) The e-mail address you sent your request from is not the same as the e-mail address on file in your your account with us.
+ + + + +

To +rectify this situation, please visit the link below and provide your +login details so we can associate your request with an authorized +account:

You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+
Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff.
+
+ +Thank you,
+ +%site_name%
+

]]>
+
+ + 621 + 1 + 621 + english + New Ticket ( %sql2_name% ) %var_ticket_subject% + + We have recieved a new staff issued ticket at %date%, with a priority of  %var_ticket_priority%.
+
+==================================================
+%var_ticket_subject%
+==================================================
+%var_ticket_body%
+==================================================
+
+%url%admin.php?_page=ticket:view&id=%sql1_id%]]>
+
+ + 622 + 1 + 622 + english + New Ticket (%var_ticket_subject% ) + + +
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If promted, please provide the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+
Subject: %var_ticket_subject%
+
%var_ticket_body%
+

+Thank you,
+%site_name%]]>
+
+ + 623 + 1 + 623 + english + Ticket Response ( %sql1_subject% ) + + This e-mail is to let you know we have responded to a ticket of yours on %date%.

+

You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%

+

Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+

+

Subject: %sql1_subject%

+
%var_message%
+ +

Thank you,
+%site_name%

]]>
+
+ + 624 + 1 + 624 + english + New Ticket ( %var_ticket_subject% ) + + We have received your new ticket, dated %date%.
+
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please provide the following information:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%
+
+]]>
+
+ + 625 + 1 + 625 + english + New Ticket ( %sql2_name% ) %var_ticket_subject% + + We have recieved a new ticket on %date%, with a priority of %var_ticket_priority%.
+
+==================================================
+%var_ticket_subject%
+==================================================
+%var_ticket_body%
+==================================================
+
+%url%admin.php?_page=ticket:view&id=%sql1_id%
+]]>
+
+ + 626 + 1 + 626 + english + Updated Ticket ( %sql1_subject% ) + + This e-mail is to let you know we have recieved your response to your ticket, dated %date%.
+
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please provide the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%
+
+]]>
+
+ + 627 + 1 + 627 + english + Updated Ticket ( %sql2_name% ) %sql1_subject% + + We have received a reply to a ticket at %date%, with a priority of %sql1_priority%.
+
+==================================================
+%sql1_subject%
+==================================================
+%var_ticket_reply%
+==================================================
+
%url%admin.php?_page=ticket:view&id=%sql1_id%
]]>
+
+ + 1620 + 1 + 620 + english + Unable to Process your e-mail request + We have recently received your e-mail dated %date% with the following subject: + +%var_ticket_subject% + +We regret to inform you that we are unable to process your request for the following reason: + +The department you sent your request to requires that you have an account with us and maintain a particular subscription. + +Please check the link below to see if there are any other departments which your account is authorized to access: + +%url%?_page=ticket:ticket + +If no available departments are listed at the link above, please contact customer service with your account details and request details for any additional requirements needed to access our ticket system. + +Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff. + +Thank you, +%site_name% + + We have recently received your e-mail dated %date% with the following subject:
+
+%var_ticket_subject%
+
+We regret to inform you that we are unable to process your request for the following reason:
+
+The department you sent your request to requires that you have an account with us and maintain a particular subscription.
+
+ +Please check the link below to see if there are any other departments which your account is authorized to access:
+ + + +

+

%url%?_page=ticket:ticket
+
+

+

If no available departments are listed at the link above, please +contact customer service with your account details and request details +for any additional requirements needed to access our ticket system.
+
+ +Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff.
+
+ +Thank you,
+ +%site_name%
+ +

]]>
+
+ + 1622 + 1 + 628 + english + New Ticket ( %var_ticket_subject% ) + + We have recently received your email dated %date% with the following subject:
+
+%var_ticket_subject%
+
+You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%]]>
+
+ + 1623 + 1 + 629 + english + New Ticket Received - Authorization Required + + We have recently received your e-mail dated %date% with the following subject:
+
+%var_ticket_subject%
+
+Further action on your part is required before we can process your request, for one of two possible reasons:
+
+ +1) The department you sent your request to requires that you have an account with us and maintain a particular subscription.
+
+ +2) The e-mail address you sent your request from is not the same as the e-mail address on file in your your account with us.
+ + + + +

To +rectify this situation, please visit the link below and provide your +login details so we can associate your request with an authorized +account:

You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+
Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff.
+
+ +Thank you,
+ +%site_name%
+

]]>
+
+ + 1625 + 1 + 631 + english + New Ticket ( %sql2_name% ) %var_ticket_subject% + + We have recieved a new staff issued ticket at %date%, with a priority of  %var_ticket_priority%.
+
+==================================================
+%var_ticket_subject%
+==================================================
+%var_ticket_body%
+==================================================
+
+%url%admin.php?_page=ticket:view&id=%sql1_id%]]>
+
+ + 1626 + 1 + 632 + english + New Ticket (%var_ticket_subject% ) + + +
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If promted, please provide the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+
Subject: %var_ticket_subject%
+
%var_ticket_body%
+

+Thank you,
+%site_name%]]>
+
+ + 1627 + 1 + 633 + english + Ticket Response ( %sql1_subject% ) + + This e-mail is to let you know we have responded to a ticket of yours on %date%.

+

You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%

+

Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+

+

Subject: %sql1_subject%

+
%var_message%
+ +

Thank you,
+%site_name%

]]>
+
+ + 1628 + 1 + 634 + english + New Ticket ( %var_ticket_subject% ) + + We have received your new ticket, dated %date%.
+
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please provide the following information:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%
+
+]]>
+
+ + 1629 + 1 + 635 + english + New Ticket ( %sql2_name% ) %var_ticket_subject% + + We have recieved a new ticket on %date%, with a priority of %var_ticket_priority%.
+
+==================================================
+%var_ticket_subject%
+==================================================
+%var_ticket_body%
+==================================================
+
+%url%admin.php?_page=ticket:view&id=%sql1_id%
+]]>
+
+ + 1630 + 1 + 636 + english + Updated Ticket ( %sql1_subject% ) + + This e-mail is to let you know we have recieved your response to your ticket, dated %date%.
+
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please provide the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%
+
+]]>
+
+ + 1631 + 1 + 637 + english + Updated Ticket ( %sql2_name% ) %sql1_subject% + + We have received a reply to a ticket at %date%, with a priority of %sql1_priority%.
+
+==================================================
+%sql1_subject%
+==================================================
+%var_ticket_reply%
+==================================================
+
%url%admin.php?_page=ticket:view&id=%sql1_id%
]]>
+
+ + 11624 + 1 + 630 + english + Unable to Process your e-mail request + We have recently received your e-mail dated %date% with the following subject: + +%var_ticket_subject% + +We regret to inform you that we are unable to process your request for the following reason: + +The department you sent your request to requires that you have an account with us and maintain a particular subscription. + +Please check the link below to see if there are any other departments which your account is authorized to access: + +%url%?_page=ticket:ticket + +If no available departments are listed at the link above, please contact customer service with your account details and request details for any additional requirements needed to access our ticket system. + +Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff. + +Thank you, +%site_name% + + We have recently received your e-mail dated %date% with the following subject:
+
+%var_ticket_subject%
+
+We regret to inform you that we are unable to process your request for the following reason:
+
+The department you sent your request to requires that you have an account with us and maintain a particular subscription.
+
+ +Please check the link below to see if there are any other departments which your account is authorized to access:
+ + + +

+

%url%?_page=ticket:ticket
+
+

+

If no available departments are listed at the link above, please +contact customer service with your account details and request details +for any additional requirements needed to access our ticket system.
+
+ +Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff.
+
+ +Thank you,
+ +%site_name%
+ +

]]>
+
+ + 11626 + 1 + 638 + english + Your %site_name% Account + %acct_first_name%, + +Your account has been blocked due to a high volume of logins from multiple IP addresses. + +Our system monitors all logins to ensure passwords are not shared with non-members. We have logged your username being used from %sql3% separate locations, which exceeds our limit of %sql2%. + +If you feel this is in error, please contact our customer service department. + +Thank you, +%site_name% +%url% + %acct_first_name%,
+
+Your account has been blocked due to a high volume of logins from multiple IP addresses.
+
+Our system monitors all logins to ensure passwords are not shared with +non-members. We have logged your username being used from %sql3% +separate locations, which exceeds our limit of %sql2%.
+
+If you feel this is in error, please contact our customer service department.
+
+Thank you,
+%site_name%
+%url%
]]>
+
+ + 11627 + 1 + 639 + english + Banned User %acct_first_name% %acct_last_name% + + +
+%sql3% separate IPs have been logged for this account.
+
+User Details
+]]>
+
+ + 11628 + 1 + 640 + english + Your Credit Card Expires Soon + + +
+Your %sql1_cart_type% on file ending with %sql2_card_num4% expires on %sql1_%/%sql1_%.
+
+Please login at the link below to update it so your service is not suspended.
+
+%ssl_url%?_page=account_billing:user_view&id=%sql1_id%
+
+Thank you,
+%site_name%]]>
+
+ + 11629 + 1 + 641 + english + New Ticket ( %var_ticket_subject% ) + + We have recently received your email dated %date% with the following subject:
+
+%var_ticket_subject%
+
+You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%]]>
+
+ + 11630 + 1 + 642 + english + New Ticket Received - Authorization Required + + We have recently received your e-mail dated %date% with the following subject:
+
+%var_ticket_subject%
+
+Further action on your part is required before we can process your request, for one of two possible reasons:
+
+ +1) The department you sent your request to requires that you have an account with us and maintain a particular subscription.
+
+ +2) The e-mail address you sent your request from is not the same as the e-mail address on file in your your account with us.
+ + + + +

To +rectify this situation, please visit the link below and provide your +login details so we can associate your request with an authorized +account:

You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+
Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff.
+
+ +Thank you,
+ +%site_name%
+

]]>
+
+ + 11632 + 1 + 644 + english + New Ticket ( %sql2_name% ) %var_ticket_subject% + + We have recieved a new staff issued ticket at %date%, with a priority of %var_ticket_priority%.
+
+==================================================
%sql1_email% - %var_ticket_subject%
+==================================================
+%var_ticket_body%
+==================================================
+
+%url%admin.php?_page=ticket:view&id=%sql1_id%]]>
+
+ + 11633 + 1 + 645 + english + New Ticket (%var_ticket_subject% ) + + +
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If promted, please provide the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+
Subject: %var_ticket_subject%
+
%var_ticket_body%
+

+Thank you,
+%site_name%]]>
+
+ + 11634 + 1 + 646 + english + Ticket Response ( %sql1_subject% ) + + This e-mail is to let you know we have responded to a ticket of yours on %date%.

+

You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%

+

Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+

+

Subject: %sql1_subject%

+
%var_message%
+ +

Thank you,
+%site_name%

]]>
+
+ + 11635 + 1 + 647 + english + New Ticket ( %var_ticket_subject% ) + + We have received your new ticket, dated %date%.
+
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please provide the following information:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%
+
+]]>
+
+ + 11636 + 1 + 648 + english + New Ticket ( %sql2_name% ) %var_ticket_subject% + + We have recieved a new ticket on %date%, with a priority of %var_ticket_priority%.
+
+==================================================
+%sql1_email% - %var_ticket_subject%
+==================================================
+%var_ticket_body%
+==================================================
+
+%url%admin.php?_page=ticket:view&id=%sql1_id%
+]]>
+
+ + 11637 + 1 + 649 + english + Updated Ticket ( %sql1_subject% ) + + This e-mail is to let you know we have recieved your response to your ticket, dated %date%.
+
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please provide the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%
+
+]]>
+
+ + 11638 + 1 + 650 + english + Updated Ticket ( %sql2_name% ) %sql1_subject% + + We have received a reply to a ticket at %date%, with a priority of %sql1_priority%.
+
+==================================================
%sql1_email% - %sql1_subject%
+==================================================
+%var_ticket_reply%
+==================================================
+
%url%admin.php?_page=ticket:view&id=%sql1_id%
]]>
+
+ + 111631 + 1 + 643 + english + Unable to Process your e-mail request + We have recently received your e-mail dated %date% with the following subject: + +%var_ticket_subject% + +We regret to inform you that we are unable to process your request for the following reason: + +The department you sent your request to requires that you have an account with us and maintain a particular subscription. + +Please check the link below to see if there are any other departments which your account is authorized to access: + +%url%?_page=ticket:ticket + +If no available departments are listed at the link above, please contact customer service with your account details and request details for any additional requirements needed to access our ticket system. + +Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff. + +Thank you, +%site_name% + + We have recently received your e-mail dated %date% with the following subject:
+
+%var_ticket_subject%
+
+We regret to inform you that we are unable to process your request for the following reason:
+
+The department you sent your request to requires that you have an account with us and maintain a particular subscription.
+
+ +Please check the link below to see if there are any other departments which your account is authorized to access:
+ + + +

+

%url%?_page=ticket:ticket
+
+

+

If no available departments are listed at the link above, please +contact customer service with your account details and request details +for any additional requirements needed to access our ticket system.
+
+ +Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff.
+
+ +Thank you,
+ +%site_name%
+ +

]]>
+
+ + 111633 + 1 + 651 + english + Invoice %sql1_id% suspended for non-payment + + + + +
+ + +This e-mail is to inform you that Invoice # %sql1_id% and associated services have been suspended for non-payment.
+ + +
+ + +This invoice was being billed on net terms and %sql3% intervals have passed and the invoice has not been paid in full.
+ + +
+ + +You can visit login to your account and view the invoice at %url%?_page=invoice:view&id=%sql1_id% to review the invoice and make payment.
+ + +
+ + +Regards,
+ + +%site_name%]]>
+
+ + 111634 + 1 + 652 + english + Late Fees for Invoice %sql1_id% + + + + +
+ + +This is a friendly notice to inform you that a late charge in the +amount of %sql2% has been applied to your account. These charges are +for invoice # %sql1_id%, which is presently being billed on net terms.
+ + +
+ + +You have %sql3% intervals remaining before the services associated with +this invoice are suspended and collection activity may occur. In the +meanwhile, we will continue to apply the late charges to your next +invoice on each remaining interval.
+ + +
+ + +You may login to your account at and view your invoice at +%url%?_page=invoice:user_view&id=%sql1_id% to make payment +arrangements.
+ + +
+ + +Thank you,
+ + +%site_name%]]>
+
+ + 111635 + 1 + 653 + english + Prepaid Pin Balance Low + Dear %acct_first_name%, + +Your prepaid balance for Pin # %sql1_pin% is low. + +The balance is currently %sql3%. + +To replenish this card, please visit %url%?_page=product_cat:menu + +Thank you, +%site_name% + + +
+ +Your prepaid balance for Pin # %sql1_pin% is low.
+ +
+ +The balance is currently %sql3%.
+ +
+ +To replenish this card, please visit %url%?_page=product_cat:menu
+

+ +Thank you,
+ +%site_name%
+]]>
+
+ + 111636 + 1 + 654 + english + Manual VoIP Provisioning [%sql3%] + This e-mail is to inform you that we that the following action is needed for service id %sql1_id%: %sql3%. + +Service Details: + +Product SKU: %sql1_sku% +Authenticate Username: %sql2_sip% +Phone Number: %sql2_sip% +Password: %sql2_data% + This e-mail is to inform you that we that the following action is needed for service id %sql1_id%: %sql3%.
+
+Service Details:
+
+Product SKU: %sql1_sku%
+Authenticate Username: %sql2_sip%
+Phone Number: %sql2_sip%
+Password: %sql2_data%

+]]>
+
+ + 111637 + 1 + 655 + english + New Prepaid Account + Dear %acct_first_name%, + +This e-mail is to inform you that your new prepaid account has been setup. + +To use this prepaid account, please call %sql3% and from your phone number entered when you ordered ( %sql1_pin% ). + +Your balance for prepaid account number %sql1_pin% is presently %sql1_balance%. + +Thank you, +%site_name% + + +
+ +This e-mail is to inform you that your new prepaid account has been setup.
+ +
+ +To use this prepaid account, please call %sql3% and from your phone number entered when you ordered ( %sql1_pin% ).
+ +
+ +Your balance for prepaid account number %sql1_pin% is presently %sql1_balance%.
+ +
+ +Thank you,
+ +%site_name%
+]]>
+
+ + 111638 + 1 + 656 + english + New Pin Number Added + Dear %acct_first_name%, + +This e-mail is to inform you that your new pin number has been setup. + +To use this pin number, please call toll-free %sql3% and enter the pin code as %sql1_pin% when prompted. + +Your balance for pin # %sql1_pin% is presently %sql1_balance%. + +Thank you, +%site_name% + + +
+ +This e-mail is to inform you that your new pin number has been setup.
+ +
+ +To use this pin number, please call toll-free %sql3% and enter the pin code as %sql1_pin% when prompted.
+ +
+ +Your balance for pin # %sql1_pin% is presently %sql1_balance%.
+ +
+ +Thank you,
+ +%site_name%
+]]>
+
+ + 111639 + 1 + 657 + english + New VoIP Service Creation Notice + Dear %acct_first_name%, + +This e-mail is to inform you that we have created a new VoIP service. + +Product SKU: %sql1_sku% +Your Authenticate Username: %sql2_sip% +Your Phone Number: %sql2_sip% +Your Password: %sql2_data% +Your Voicemail PIN: %sql3_password% + +Thank you, +%site_name% + Dear %acct_first_name%,

This e-mail is to inform you that we have created a new VoIP service.

Product SKU: %sql1_sku%
Your Authenticate Username: %sql2_sip%
Your Phone Number: %sql2_sip%
Your Password: %sql2_data%
Your Voicemail PIN: %sql3_password%

+

Thank you,
+%site_name%
+

+]]>
+
+ + 111640 + 1 + 658 + english + New Ticket ( %var_ticket_subject% ) + + We have recently received your email dated %date% with the following subject:
+
+%var_ticket_subject%
+
+You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%]]>
+
+ + 111641 + 1 + 659 + english + New Ticket Received - Authorization Required + + We have recently received your e-mail dated %date% with the following subject:
+
+%var_ticket_subject%
+
+Further action on your part is required before we can process your request, for one of two possible reasons:
+
+ +1) The department you sent your request to requires that you have an account with us and maintain a particular subscription.
+
+ +2) The e-mail address you sent your request from is not the same as the e-mail address on file in your your account with us.
+ + + + +

To +rectify this situation, please visit the link below and provide your +login details so we can associate your request with an authorized +account:

You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please enter the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+
Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff.
+
+ +Thank you,
+ +%site_name%
+

]]>
+
+ + 111643 + 1 + 661 + english + New Ticket ( %sql2_name% ) %var_ticket_subject% + + We have recieved a new staff issued ticket at %date%, with a priority of  %var_ticket_priority%.
+
+==================================================
+%var_ticket_subject%
+==================================================
+%var_ticket_body%
+==================================================
+
+%url%admin.php?_page=ticket:view&id=%sql1_id%]]>
+
+ + 111644 + 1 + 662 + english + New Ticket (%var_ticket_subject% ) + + +
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If promted, please provide the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+
Subject: %var_ticket_subject%
+
%var_ticket_body%
+

+Thank you,
+%site_name%]]>
+
+ + 111645 + 1 + 663 + english + Ticket Response ( %sql1_subject% ) + + This e-mail is to let you know we have responded to a ticket of yours on %date%.

+

You can view your ticket here: %url%?_page=ticket:user_view&id=%sql1_id%

+

Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+

+

Subject: %sql1_subject%

+
%var_message%
+ +

Thank you,
+%site_name%

]]>
+
+ + 111646 + 1 + 664 + english + New Ticket ( %var_ticket_subject% ) + + We have received your new ticket, dated %date%.
+
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please provide the following information:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%
+
+]]>
+
+ + 111647 + 1 + 665 + english + New Ticket ( %sql2_name% ) %var_ticket_subject% + + We have recieved a new ticket on %date%, with a priority of %var_ticket_priority%.
+
+==================================================
+%var_ticket_subject%
+==================================================
+%var_ticket_body%
+==================================================
+
+%url%admin.php?_page=ticket:view&id=%sql1_id%
+]]>
+
+ + 111648 + 1 + 666 + english + Updated Ticket ( %sql1_subject% ) + + This e-mail is to let you know we have recieved your response to your ticket, dated %date%.
+
+You can view your ticket here:
+%url%?_page=ticket:user_view&id=%sql1_id%&email=%var_email%&key=%var_key%
+
+If prompted, please provide the following details:
+E-mail: %var_email%
+Key: %var_key%
+
+Please do not reply to this email, this message was generated automatically and your response will not be seen by our staff.
+
+Thank you,
+%site_name%
+
+]]>
+
+ + 111649 + 1 + 667 + english + Updated Ticket ( %sql2_name% ) %sql1_subject% + + We have received a reply to a ticket at %date%, with a priority of %sql1_priority%.
+
+==================================================
+%sql1_subject%
+==================================================
+%var_ticket_reply%
+==================================================
+
%url%admin.php?_page=ticket:view&id=%sql1_id%
]]>
+
+ + 1111642 + 1 + 660 + english + Unable to Process your e-mail request + We have recently received your e-mail dated %date% with the following subject: + +%var_ticket_subject% + +We regret to inform you that we are unable to process your request for the following reason: + +The department you sent your request to requires that you have an account with us and maintain a particular subscription. + +Please check the link below to see if there are any other departments which your account is authorized to access: + +%url%?_page=ticket:ticket + +If no available departments are listed at the link above, please contact customer service with your account details and request details for any additional requirements needed to access our ticket system. + +Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff. + +Thank you, +%site_name% + + We have recently received your e-mail dated %date% with the following subject:
+
+%var_ticket_subject%
+
+We regret to inform you that we are unable to process your request for the following reason:
+
+The department you sent your request to requires that you have an account with us and maintain a particular subscription.
+
+ +Please check the link below to see if there are any other departments which your account is authorized to access:
+ + + +

+

%url%?_page=ticket:ticket
+
+

+

If no available departments are listed at the link above, please +contact customer service with your account details and request details +for any additional requirements needed to access our ticket system.
+
+ +Please do not reply to this e-mail, this message was generated automatically and your response will not be seen by our staff.
+
+ +Thank you,
+ +%site_name%
+ +

]]>
+
+ + 1111644 + 1 + 668 + english + Advance Billing Notification from %site_name% + Dear %acct_first_name%, + +This message is a friendly alert that an invoice in the amount of %sql2_symbol%%sql1_price% %sql2_three_digit% is set to generate shortly and will be due on %sql3%. + +(This amount does not reflect any appicable discounts, taxes, and usage charges, if any) + +If you wish to modify your service(s) with us prior to the automatic generation, please visit your account area at %url%. Please make sure your billing information is up to date so we can process the invoice without any service delays. + +Thank you, +%site_name% + Dear %acct_first_name%,


+This message is a friendly alert that an invoice in the amount of +%sql2_symbol%%sql1_price% %sql2_three_digit% is set to generate shortly +and will be due on %sql3%.
+
+(This amount does not reflect any appicable discounts, taxes, and usage charges, if any)
+
+If you wish to modify your service(s) with us prior to the automatic generation, please visit your account area at %url%. Please make sure your billing information is up to date so we can process the invoice without any service delays.
+
+Thank you,
+%site_name%

]]>
+
+ + 1111644 + + + 1111644 + + \ No newline at end of file diff --git a/modules/faq/auth.inc.php b/modules/faq/auth.inc.php new file mode 100644 index 00000000..c3151b11 --- /dev/null +++ b/modules/faq/auth.inc.php @@ -0,0 +1,12 @@ + 'faq', 'method' => 'faq_categories'), + Array ('module' => 'faq', 'method' => 'faq_show'), + Array ('module' => 'faq', 'method' => 'autofill'), + Array ('module' => 'faq', 'method' => 'faq_search') + ); +?> diff --git a/modules/faq/faq.inc.php b/modules/faq/faq.inc.php new file mode 100644 index 00000000..abe222f1 --- /dev/null +++ b/modules/faq/faq.inc.php @@ -0,0 +1,318 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class faq +{ + + # Open the constructor for this mod + function faq() + { + # name of this module: + $this->module = "faq"; + $this->version = "1.0.0a"; + + if(!defined('AJAX')) + { + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + } + + + + ### autofill for admin 'canned messages' in ticket reply + function autofill($VAR) + { + $db = &DB(); + if(!empty($VAR['faq_autofill']) && strlen($VAR['faq_autofill']) > 3) { + $dbm = new CORE_database(); + $result = $db->Execute( + $sql = $dbm->sql_select( + Array( 'faq_translate', 'faq' ), + Array( 'A.*', 'B.name' ), + " A.faq_id = B.id AND MATCH(A.question, A.answer) AGAINST(".$db->qstr($VAR['faq_autofill'].'*')." IN BOOLEAN MODE)", + "", + &$db + ) + ); + } + + echo '
    '; + # Create the alert for no records found + if (@$result != false && $result->RecordCount() > 0) { + $i=0; + while(!$result->EOF && $i < 10) { + echo '
  • ' . stripcslashes( substr( ereg_replace("\r\n", " ", $result->fields['question']), 0, 65 ) ). '
    '. + ''. + '
  • '). "\r\n"; + $result->MoveNext(); + $i++; + } + } else { + include_once(PATH_CORE.'translate.inc.php'); + include_once(PATH_CORE.'xml.inc.php'); + $C_translate = new CORE_translate; + echo '
  • '. $C_translate->translate('admin_no_match','faq') .'
    ' . + ''. + '
  • ' . "\r\n"; + } + echo "
"; + + } + + + ### Get the faq details: + function faq_show($VAR) + { + if (!empty($VAR['id'])) { + $db = &DB(); + $dbm = new CORE_database(); + $rs = $db->Execute( + $sql = $dbm->sql_select( + Array( 'faq_translate', 'faq', 'faq_category' ), + Array( 'A.*', 'B.name', 'C.group_avail' ), + " B.id = ::".$VAR['id'].":: AND B.id = A.faq_id AND A.language_id = '".SESS_LANGUAGE."' AND B.status = 1 AND C.status = 1 ", + "", + &$db + ) + ); + } + + global $C_auth; + if( !$rs || $rs->RecordCount() == 0 || !$C_auth->auth_group_by_id( unserialize( $rs->fields['group_avail'] ))) { + include_once(PATH_CORE.'translate.inc.php'); + include_once(PATH_CORE.'xml.inc.php'); + $C_translate = new CORE_translate; + echo $C_translate->translate('no_faqs','faq'); + } else { + echo '

' . ereg_replace("\r\n", "
", stripcslashes( htmlentities( $rs->fields['question']) ) ). '

' . + '

' . ereg_replace("\r\n", "
", $this->linkalize(stripcslashes( htmlentities( $rs->fields['answer']) ) ) ). '

'; + } + } + + + ### Get the faq translation: + function faq_search($VAR) + { + $db = &DB(); + if(!empty($VAR['search']) && strlen($VAR['search']) > 3) { + $dbm = new CORE_database(); + $result = $db->Execute( + $sql = $dbm->sql_select( + Array( 'faq_translate', 'faq', 'faq_category' ), + Array( 'A.*', 'B.name', 'C.group_avail' ), + " A.faq_id = B.id AND B.faq_category_id = C.id AND MATCH(A.question, A.answer) AGAINST(".$db->qstr($VAR['search'].'*')." IN BOOLEAN MODE) AND B.status = 1 AND C.status=1", + "", + &$db + ) + ); + } elseif (!empty($VAR['category_id'])) { + $dbm = new CORE_database(); + $result = $db->Execute( + $sql = $dbm->sql_select( + Array( 'faq_translate', 'faq', 'faq_category' ), + Array( 'A.*', 'B.name', 'C.group_avail' ), + " B.faq_category_id = ::".$VAR['category_id'].":: AND B.id = A.faq_id AND B.faq_category_id = C.id AND A.language_id = '".SESS_LANGUAGE."' AND B.status = 1 AND C.status=1", + "", + &$db + ) + ); + } + + echo '
    '; + if (@$result != false && $result->RecordCount() > 0) { + $i=0; + while(!$result->EOF) { + global $C_auth; + if( $C_auth->auth_group_by_id( unserialize($result->fields['group_avail'] ))) { + echo '
  • '. "\r\n"; + $i++; + } + $result->MoveNext(); + } + } else { + include_once(PATH_CORE.'translate.inc.php'); + include_once(PATH_CORE.'xml.inc.php'); + $C_translate = new CORE_translate; + echo '
  • '. $C_translate->translate('admin_no_match','faq') .'
  • ' . "\r\n"; + } + echo "
"; + } + + + + ### Get the authorized/active categories + function faq_categories($VAR) + { + $db = &DB(); + $dbm = new CORE_database(); + $rs = $db->Execute( $sql= + $sql = $dbm->sql_select( + 'faq_category', + '*' , + " status=1 ", + "sort_order,name,date_orig", + &$db + ) + ); + + if(!$rs || $rs->RecordCount() == 0) { + // + } else { + while(!$rs->EOF) { + // validate groups + global $C_auth; + if( $C_auth->auth_group_by_id( unserialize($rs->fields['group_avail']) )) { + $smart[] = $rs->fields; + } + $rs->MoveNext(); + } + } + + global $smarty; + $smarty->assign('faq_category_list', @$smart); + } + + + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $id = $db->add($VAR, $this, $type); + + if($id && !empty($VAR['faq_question'])) + { + # Insert translation + $db = &DB(); + $idx = $db->GenID(AGILE_DB_PREFIX. 'faq_translate_id'); + $sql = "INSERT INTO ".AGILE_DB_PREFIX."faq_translate + SET + site_id = ".DEFAULT_SITE.", + id = $idx, + faq_id = $id, + date_orig = ".time().", + date_last = ".time().", + language_id = '".DEFAULT_LANGUAGE."', + answer = ".$db->qstr( @$VAR['faq_answer'] ).", + question = ".$db->qstr( @$VAR['faq_question']); + $db->Execute($sql); + } + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $this->associated_DELETE[] = + Array( + 'table' => 'faq_translate', + 'field' => 'faq_id' + ); + + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + function linkalize($text) + { + $text = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i", "$1http://$2", $text); + $text = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i", "$1", $text); //make all URLs links + $text = preg_replace("/[\w-\.]+@(\w+[\w-]+\.){0,3}\w+[\w-]+\.[a-zA-Z]{2,4}\b/i","$0",$text); + return $text; + } +} +?> \ No newline at end of file diff --git a/modules/faq/faq_construct.xml b/modules/faq/faq_construct.xml new file mode 100644 index 00000000..23b466e0 --- /dev/null +++ b/modules/faq/faq_construct.xml @@ -0,0 +1,78 @@ + + + + + faq + + + faq
+ + + + + + 0 + + + sort_order,date_orig,name + + + 35 + + + + + I4 + 1 + + + I4 + + + I4 + faq_category + name + + + I8 + date-now + + + I8 + date-now + + + I8 + date + + + I8 + date + + + I4 + + + L + + + C(255) + 1 + 255 + any + 1 + + + + + + id,site_id,faq_category_id,date_orig,date_last,date_start,date_expire,sort_order,status,name + id,site_id,faq_category_id,date_orig,date_last,date_start,date_expire,sort_order,status,name + id,site_id,faq_category_id,date_orig,date_last,date_start,date_expire,sort_order,status,name + id,site_id,faq_category_id,date_orig,date_last,date_start,date_expire,sort_order,status,name + id,site_id,faq_category_id,date_orig,date_last,date_start,date_expire,sort_order,status,name + + + + 0 +
diff --git a/modules/faq/faq_install.xml b/modules/faq/faq_install.xml new file mode 100644 index 00000000..2c1ee562 --- /dev/null +++ b/modules/faq/faq_install.xml @@ -0,0 +1,49 @@ + + + + + + faq + faq + This module controls the FAQs + 1 + faq_category,faq_translate + + + + + + + + search + Allow users to view the search form + %%:search_form + 1 + + + view + Allow users to view records + + 1 + + + add + Allow users to add records + 1 + + + delete + + + update + + + search_form + + + search_show + Allow users to view the search results + + + + diff --git a/modules/faq_category/auth.inc.php b/modules/faq_category/auth.inc.php new file mode 100644 index 00000000..e44fc43d --- /dev/null +++ b/modules/faq_category/auth.inc.php @@ -0,0 +1,9 @@ + 'faq_category', 'method' => 'category_list'), + ); +?> diff --git a/modules/faq_category/faq_category.inc.php b/modules/faq_category/faq_category.inc.php new file mode 100644 index 00000000..c3dd16d4 --- /dev/null +++ b/modules/faq_category/faq_category.inc.php @@ -0,0 +1,208 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class faq_category +{ + + # Open the constructor for this mod + function faq_category_construct() + { + # name of this module: + $this->module = "faq_category"; + $this->version = "1.0.0a"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + ############################## + ## GET AUTH CATEGORIES ## + ############################## + + function category_list($VAR) + { + + /* check if current session is authorized for any ticket departments.. + and return true/false... + */ + global $smarty; + $db = &DB(); + $sql = 'SELECT DISTINCT fc.id,fc.name,fc.group_avail,count(f.id) children, fc.site_id, fc.status + FROM + ' . AGILE_DB_PREFIX . 'faq_category fc + INNER JOIN + ' . AGILE_DB_PREFIX . 'faq f ON f.faq_category_id = fc.id + GROUP BY (fc.id) + HAVING + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + status = ' . $db->qstr('1') .' + ORDER BY fc.sort_order,fc.name'; + + $result = $db->Execute($sql); + + if($result->RecordCount() == 0) + { + $smarty->assign('faq_category_list_display', false); + return false; + } + + global $C_auth; + $ii = 0; + + while(!$result->EOF) + { + @$arr = unserialize($result->fields['group_avail']); + + for($i=0; $iauth_group_by_id($arr[$i])) + { + ### Add to the array + $ii++; + $arr_smarty[] = Array( 'name' => $result->fields['name'], + 'id' => $result->fields['id'], + 'children' => $result->fields['children']); + + $i=count($arr); + } + } + $result->MoveNext(); + } + + if($ii == "0") + { + $smarty->assign('faq_category_list_display', false); + return false; + } + else + { + $smarty->assign('faq_category_list_display', true); + $smarty->assign('faq_category_list_results', $arr_smarty); + return true; + } + } + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $this->faq_category_construct(); + + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $this->faq_category_construct(); + + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $this->faq_category_construct(); + + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $this->faq_category_construct(); + + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $this->faq_category_construct(); + + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $this->faq_category_construct(); + + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $this->faq_category_construct(); + + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/faq_category/faq_category_construct.xml b/modules/faq_category/faq_category_construct.xml new file mode 100644 index 00000000..ba59adc8 --- /dev/null +++ b/modules/faq_category/faq_category_construct.xml @@ -0,0 +1,69 @@ + + + + + faq_category + + + faq_category
+ + + faq + + + 0 + + + sort_order,name + + + 35 + + + + + I4 + 1 + + + I4 + + + I8 + date-now + + + C(255) + any + array + + + C(128) + 1 + 128 + any + 1 + + + X2 + + + L + + + I4 + + + + + + id,site_id,date_orig,group_avail,name,description,status,sort_order + id,site_id,date_orig,group_avail,name,description,status,sort_order + id,site_id,date_orig,group_avail,name,description,status,sort_order + id,site_id,date_orig,group_avail,name,description,status,sort_order + id,site_id,date_orig,group_avail,name,description,status,sort_order + + + + 0 +
diff --git a/modules/faq_category/faq_category_install.xml b/modules/faq_category/faq_category_install.xml new file mode 100644 index 00000000..cfe5d506 --- /dev/null +++ b/modules/faq_category/faq_category_install.xml @@ -0,0 +1,41 @@ + + + + + + faq_category + faq + This module controls the FAQs categories + 1 + + + + + + + + + + search + + + view + + 1 + + + add + 1 + + + delete + + + update + + + search_show + + + + diff --git a/modules/faq_translate/faq_translate.inc.php b/modules/faq_translate/faq_translate.inc.php new file mode 100644 index 00000000..af7ca0ed --- /dev/null +++ b/modules/faq_translate/faq_translate.inc.php @@ -0,0 +1,127 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class faq_translate +{ + + # Open the constructor for this mod + function faq_translate() + { + # name of this module: + $this->module = "faq_translate"; + $this->version = "1.0.0a"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/faq_translate/faq_translate_construct.xml b/modules/faq_translate/faq_translate_construct.xml new file mode 100644 index 00000000..759c4a37 --- /dev/null +++ b/modules/faq_translate/faq_translate_construct.xml @@ -0,0 +1,77 @@ + + + + + faq_translate + + + faq_translate
+ + + faq + + + 0 + + + faq_id + + + 35 + + + + + I4 + 1 + 1 + + + I4 + + + I8 + date-now + + + I8 + date-now + + + I4 + faq + name + + + C(16) + + + X2 + 1 + 1 + + + X2 + 1 + 255 + any + + + + + + answer,question + + + + + id,site_id,date_orig,date_last,faq_id,language_id,answer,question + id,site_id,date_orig,date_last,faq_id,language_id,answer,question + id,site_id,date_orig,date_last,faq_id,language_id,answer,question + id,site_id,date_orig,date_last,faq_id,language_id,answer,question + id,site_id,date_orig,date_last,faq_id,language_id,answer,question + + + + 0 +
diff --git a/modules/faq_translate/faq_translate_install.xml b/modules/faq_translate/faq_translate_install.xml new file mode 100644 index 00000000..979c19e9 --- /dev/null +++ b/modules/faq_translate/faq_translate_install.xml @@ -0,0 +1,34 @@ + + + + + + faq_translate + faq_translate + This module controls the FAQs translations + + + + + + + search + + + view + + + add + + + delete + + + update + + + search_show + + + + diff --git a/modules/file/auth.inc.php b/modules/file/auth.inc.php new file mode 100644 index 00000000..4b629485 --- /dev/null +++ b/modules/file/auth.inc.php @@ -0,0 +1,11 @@ + 'file', 'method' => 'download'), + Array ('module' => 'file', 'method' => 'category_list'), + Array ('module' => 'file', 'method' => 'file_list') + ); +?> \ No newline at end of file diff --git a/modules/file/file.inc.php b/modules/file/file.inc.php new file mode 100644 index 00000000..846ee07a --- /dev/null +++ b/modules/file/file.inc.php @@ -0,0 +1,492 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class file +{ + + # Open the constructor for this mod + function file() + { + # name of this module: + $this->module = "file"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## LIST AUTH FILES ## + ############################## + + function file_list($VAR) + { + global $smarty; + if(!isset($VAR['id'])) + { + global $C_debug; + $smarty->assign('file_display', false); + return false; + } + + ### Check if user is auth for the selected category: + $db = &DB(); + $sql = 'SELECT * + FROM ' . AGILE_DB_PREFIX . 'file WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + file_category_id = ' . $db->qstr($VAR['id']) . ' AND + status = ' . $db->qstr('1') .' + ORDER BY sort_order,date_orig,name'; + $result = $db->Execute($sql); + + if($result->RecordCount() == 0) + { + $smarty->assign('file_display', false); + return false; + } + + global $C_auth; + $ii = 0; + + while(!$result->EOF) + { + @$arr = unserialize($result->fields['group_avail']); + $this_show = false; + + for($i=0; $iauth_group_by_id($arr[$i])) + { + $this_show = true; + $i=count($arr); + } + } + + if($this_show) + { + + $start = $result->fields['date_start']; + $expire= $result->fields['date_expire']; + + ### Check that it is not expired + if (( $start == "0" || $start <= time()+2 ) && + ( $expire == "0" || $expire >= time() ) ) + { + $arr_smarty[] = Array ( + 'id' => $result->fields['id'], + 'name' => $result->fields['name'], + 'description' => $result->fields['description'], + 'size' => $result->fields['type'], + 'size' => $result->fields['size'] + ); + $ii++; + } + } + $result->MoveNext(); + } + + + if($ii == "0") + { + $smarty->assign('file_display', false); + return false; + } + else + { + $smarty->assign('file_display', true); + $smarty->assign('file_results', $arr_smarty); + return true; + } + } + + + + ############################## + ## GET AUTH CATEGORIES ## + ############################## + + function category_list($VAR) + { + /* check if current session is authorized for any ticket departments.. + and return true/false... + */ + + global $smarty; + $db = &DB(); + $sql = 'SELECT id,name,group_avail FROM ' . AGILE_DB_PREFIX . 'file_category WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + status = ' . $db->qstr('1') .' + ORDER BY sort_order,name'; + $result = $db->Execute($sql); + + if($result->RecordCount() == 0) + { + $smarty->assign('file_category_display', false); + return false; + } + + global $C_auth; + $ii = 0; + + while(!$result->EOF) + { + @$arr = unserialize($result->fields['group_avail']); + + for($i=0; $iauth_group_by_id($arr[$i])) + { + ### Add to the array + $ii++; + $arr_smarty[] = Array( 'name' => $result->fields['name'], + 'id' => $result->fields['id']); + $i=count($arr); + } + } + $result->MoveNext(); + } + + if($ii == "0") + { + $smarty->assign('file_category_display', false); + return false; + } + else + { + $smarty->assign('file_category_display', true); + $smarty->assign('file_category_results', $arr_smarty); + return true; + } + } + + + + + ############################## + ## DOWNLOAD ## + ############################## + function download($VAR) + { + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'file WHERE + site_id = ' . DEFAULT_SITE . ' AND + id = ' . $db->qstr(@$VAR['id']) . ' AND + status = 1'; + $result = $db->Execute($sql); + + if($result->RecordCount() == 1) + { + $show = true; + + ### Validate start date + $s = $result->fields['date_start']; + if($s != '' && $s != 0) + if($s > time()) + $show = false; + + ### Validate expire date + $e = $result->fields['date_expire']; + if($e != '' && $e != 0) + if($e < time()) + $show = false; + + ### Validate user group: + if($show) { + global $C_auth; + @$arr = unserialize($result->fields['group_avail']); + $show = false; + for($i=0; $iauth_group_by_id($arr[$i])) { + $show = true; + break; + } + } + } + + ### Get the filetype + if($show) + { + $ft = $result->fields['location_type']; + if($ft == 0) + $file = PATH_FILES . 'file_'.$VAR['id'].'.dat'; + elseif ($ft == 1) + $file = $result->fields['location']; + elseif ($ft == 2) + $file = $result->fields['location']; + + ### Open the file + if (@$file=fopen($file, 'r')) + { + ### Display the correct headers: + header ("Content-Type: " . $result->fields['type']); + header ("Content-Size: " . $result->fields['size']); + header ("Content-Disposition: inline; filename=" . $result->fields['name']); + fpassthru($file); + exit; + } + } + } + echo 'Sorry, the file does not exist or you are not authorized or your access has expired!'; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + global $_FILES, $smarty, $C_debug, $C_translate; + + if($VAR['file_location_type'] == '') return false; + + $lt = $VAR['file_location_type']; + + // UPLOADED FILE FROM LOCAL PC + if($lt == 0) { + ### Validate the file upoad: + if(!isset($_FILES['upload_file']) || $_FILES['upload_file']['size'] <= 0) + { + global $C_debug; + $C_debug->alert('You must go back and enter a file for upload!'); + return; + } + $VAR['file_size'] = $_FILES['upload_file']['size']; + $VAR['file_type'] = $_FILES['upload_file']['type']; + $VAR['file_name'] = $_FILES['upload_file']['name']; + } + + // ENTERED URL TO FILE + elseif ($lt == 1) { + ### Validate the remote file can be opened and is greater than 0K + $file = $VAR['url_file']; + if(empty($file) || !$fp = fopen ($file, "r")) { + # error + $C_debug->alert( $C_translate->translate('remote_file_err','file','') ); + return; + } else { + $VAR['file_location'] = $file; + $fn = explode("/", $file); + $count = count($fn)-1; + $VAR['file_name'] = $fn[$count]; + $headers = stream_get_meta_data($fp); + $headers = $headers['wrapper_data']; + for($i=0;$icontent_type($file); + } + else + { + $C_debug->alert( $C_translate->translate('local_file_err','file','') ); + return; + } + } + else { return false; } + + ### Create the record + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $id = $db->add($VAR, $this, $type); + + ### Copy the uploaded file, or exit if fail: + if($lt == 0) { + if(isset($id) && $id > 0) { + if(!copy($_FILES['upload_file']['tmp_name'], PATH_FILES . 'file_'.$id.'.dat')) { + $C_debug->alert( $C_translate->translate('copy_file_err','file','') ); + } + } + unlink($_FILES['upload_file']['tmp_name']); + } + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = &DB(); + $id = $this->table . '_id'; + + # generate the list of ID's + $id_list = ''; + $ii=0; + + if(isset($VAR["delete_id"])) + { + $id = split(',',$VAR["delete_id"]); + } + elseif (isset($VAR["id"])) + { + $id = split(',',$VAR["id"]); + } + + for($i=0; $iqstr($id[$i]) . " "; + $ii++; + } + else + { + $id_list .= " OR id = " . $db->qstr($id[$i]) . " "; + $ii++; + } + } + } + + if($ii>0) + { + # generate the full query + $q = "DELETE FROM + ".AGILE_DB_PREFIX."$this->table + WHERE + $id_list + AND + site_id = " . DEFAULT_SITE; + $result = $db->Execute($q); + + # error reporting + if ($result === false) { + global $C_debug; + $C_debug->error('file.inc.php','delete', $db->ErrorMsg()); + } else { + for($i=0; $ivalue["CORE"]["module_name"] = $C_translate->translate('name',$this->module,""); + $message = $C_translate->translate('alert_delete_ids',"CORE",""); + $C_debug->alert($message); + + } + } + } + + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/file/file_construct.xml b/modules/file/file_construct.xml new file mode 100644 index 00000000..2ae86c14 --- /dev/null +++ b/modules/file/file_construct.xml @@ -0,0 +1,100 @@ + + + + + file + + + file
+ + + + + + 0 + + + sort_order + + + 35 + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I8 + date-now + + + I8 + date-now + + + I8 + date + + + I8 + date + + + I4 + file_category + name + 1 + + + C(32) + + + I8 + + + C(255) + 1 + 255 + any + + + X2 + + + L + + + C(255) + + + L + + + I4 + + + C(255) + array + any + + + + + + id,site_id,group_avail,date_orig,date_last,date_start,date_expire,file_category_id,type,size,name,description,status,location,location_type,sort_order + id,site_id,group_avail,date_orig,date_last,date_start,date_expire,file_category_id,type,size,name,description,status,location,location_type,sort_order + id,site_id,group_avail,date_orig,date_last,date_start,date_expire,file_category_id,type,size,name,description,status,location,location_type,sort_order + id,site_id,group_avail,date_orig,date_last,date_start,date_expire,file_category_id,type,size,name,description,status,location,location_type,sort_order + id,site_id,group_avail,date_orig,date_last,date_start,date_expire,file_category_id,type,size,name,description,status,location,location_type,sort_order + + + + 0 +
diff --git a/modules/file/file_install.xml b/modules/file/file_install.xml new file mode 100644 index 00000000..cc54a7f5 --- /dev/null +++ b/modules/file/file_install.xml @@ -0,0 +1,50 @@ + + + + + + file + file + This module allows you to manage your downloadable files and permissions. + 1 + + file_category + + + + + + + + search + Allow users to view the search form + %%:search_form + 1 + + + view + Allow users to view records + core:search&module=%%&_escape=1&_next_page_one=view + 1 + + + add + Allow users to add records + 1 + + + delete + + + update + + + search_form + + + search_show + Allow users to view the search results + + + + \ No newline at end of file diff --git a/modules/file/file_install_data.xml b/modules/file/file_install_data.xml new file mode 100644 index 00000000..5d28dce2 --- /dev/null +++ b/modules/file/file_install_data.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/modules/file_category/file_category.inc.php b/modules/file_category/file_category.inc.php new file mode 100644 index 00000000..92155c7b --- /dev/null +++ b/modules/file_category/file_category.inc.php @@ -0,0 +1,123 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class file_category +{ + + # Open the constructor for this mod + function file_category() + { + # name of this module: + $this->module = "file_category"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/file_category/file_category_construct.xml b/modules/file_category/file_category_construct.xml new file mode 100644 index 00000000..c4846e10 --- /dev/null +++ b/modules/file_category/file_category_construct.xml @@ -0,0 +1,71 @@ + + + + + file_category + + + file_category
+ + + file + + + 0 + + + sort_order + + + 35 + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I8 + date-now + + + C(128) + 1 + 128 + any + + + X2 + + + L + + + C(255) + any + array + + + I4 + + + + + + id,site_id,date_orig,name,description,status,group_avail,sort_order + id,site_id,date_orig,name,description,status,group_avail,sort_order + id,site_id,date_orig,name,description,status,group_avail,sort_order + id,site_id,date_orig,name,description,status,group_avail,sort_order + id,site_id,date_orig,name,description,status,group_avail,sort_order + + + + + +
diff --git a/modules/file_category/file_category_install.xml b/modules/file_category/file_category_install.xml new file mode 100644 index 00000000..921ef90b --- /dev/null +++ b/modules/file_category/file_category_install.xml @@ -0,0 +1,44 @@ + + + + + + file_category + file + This module allows you to manage the categories for your downloadable files. + 1 + file + + + + + + + + + search + + + view + Allow users to view records + core:search&module=%%&_escape=1&_next_page_one=view + 1 + + + add + Allow users to add records + 1 + + + delete + + + update + + + search_show + Allow users to view the search results + + + + \ No newline at end of file diff --git a/modules/file_category/file_category_install_data.xml b/modules/file_category/file_category_install_data.xml new file mode 100644 index 00000000..49188bce --- /dev/null +++ b/modules/file_category/file_category_install_data.xml @@ -0,0 +1,26 @@ + + + + 1 + 1 + 1069748554 + Registered Users + Only registered users can access this category + 1 + a:4:{i:0;s:1:"2";i:1;s:1:"3";i:2;s:4:"1001";i:3;s:1:"4";} + 2 + + + 2 + 1 + 1069748586 + All Users + All users can access these downloads + 1 + a:4:{i:0;s:1:"2";i:1;s:1:"3";i:2;s:4:"1001";i:3;s:1:"4";} + 1 + + + 2 + + \ No newline at end of file diff --git a/modules/group/group.inc.php b/modules/group/group.inc.php new file mode 100644 index 00000000..f8a6853a --- /dev/null +++ b/modules/group/group.inc.php @@ -0,0 +1,329 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class group +{ + # Open the constructor for this mod + function group() + { + # name of this module: + $this->module = "group"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $group_id = $db->add($VAR, $this, $type); + + # add the new group to the account_group table: + $db = &DB(); + $record_id = $db->GenID(AGILE_DB_PREFIX . 'account_group_id'); + $sql= "INSERT INTO ". AGILE_DB_PREFIX ."account_group SET + id = ".$db->qstr($record_id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + date_expire = ".$db->qstr('0').", + group_id = ".$db->qstr($group_id).", + account_id = ".$db->qstr(SESS_ACCOUNT).", + active = ".$db->qstr(1); + $result = $db->Execute($sql); + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','select_groups', $db->ErrorMsg()); + return; + } + + # update the current user's authentication so the newly added group appears + # as available to them + global $C_auth; + $C_auth->auth_update(); + + return; + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + #remove any group ids <= 1001 from the VAR array: + global $C_debug, $C_auth; + $id_list = ''; + if(isset($VAR["delete_id"])) + $id = split(',',$VAR["delete_id"]); + elseif (isset($VAR["id"])) + $id = split(',',$VAR["id"]); + + for($i=0; $i 1001 ) + { + if($i == 0) + $id_list .= $id[$i]; + else + $id_list .= ','.$id[$i]; + + # Check if group allowed: + if(!$C_auth->auth_group_by_id($id[$i])) { + $C_debug->alert('The selected group cannot be modified as your account is not authorized for it.'); + return; + } + } else { + $C_debug->alert('The selected group is part of the CORE and cannot be edited.'); + return; + } + } + + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + global $C_auth; + + $this->associated_DELETE[] = Array ('table' => 'account_group', 'field' => 'group_id'); + $this->associated_DELETE[] = Array ('table' => 'group_method', 'field' => 'group_id'); + + #remove any group ids <= 1001 from the mass delete array: + global $C_debug; + $id_list = ''; + if(isset($VAR["delete_id"])) + $id = split(',',$VAR["delete_id"]); + elseif (isset($VAR["id"])) + $id = split(',',$VAR["id"]); + + for($i=0; $i 1001 ) + { + if($i == 0) + $id_list .= $id[$i]; + else + $id_list .= ','.$id[$i]; + + # Check if group allowed: + if(!$C_auth->auth_group_by_id(1001) && !$C_auth->auth_group_by_id($id[$i])) { + $C_debug->alert('The selected group cannot be modified as your account is not authorized for it.'); + return; + } + + } else { + $C_debug->alert('One or more of the groups selected to be deleted are part of the core and cannot be removed.'); + } + } + + $VAR['id'] = $id_list; + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + + ############################## + ## VISUAL LAYOUT ## + ############################## + function visual_layout() + { + + $class = 'form_field'; + + # get the default group + if(!isset($default)) $default = unserialize(DEFAULT_GROUP); + for($i=0; $iExecute($sql); + + # error handling + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','select_groups', $db->ErrorMsg()); + } + + # number of results + if($result->RecordCount() > 0) + { + # set the results to an array: + $arr = $result->GetArray(); + + # start the list + $ret = ''; + + #---------------------- + # start the parent loop + #---------------------- + $group = 0; + $arr_count = count($arr); + for($i=0; $i < $arr_count; $i++) + { + $level = 0; + if($arr[$i]['parent_id'] == $group) + { + + $ret .= '  '. $arr[$i]['name']; + $ret .= '    edit
'; + + #---------------------- + # start the child loop + #---------------------- + $level++; + $ii_group = $arr[$i]['id']; + $ii_print = 1; + + # count the available childs for this group + $count_child[$ii_group]=0; + for($c_child=0; $c_child < $arr_count; $c_child++) + if($arr[$c_child]['parent_id'] == $ii_group) $count_child[$ii_group]++; + + for($ii=0; $ii < $arr_count; $ii++) + { + if($arr[$ii]['parent_id'] == $ii_group) + { + $ret .= '  |__'; + $ret .= '  '. $arr[$ii]['name']; + $ret .= '    edit
'; + + $ii_print++; + + #-------------------------- + # start the sub-child loop + #-------------------------- + $level++; + $iii_group = $arr[$ii]['id']; + $iii_print = 0; + for($iii=0; $iii < $arr_count; $iii++) + { + if($arr[$iii]['parent_id'] == $iii_group) + { + + if($count_child[$ii_group] < $ii_print) + { + $ret .= '         |__ '; + } + else + { + $ret .= '  |      |__ '; + } + $ret .= '  '. $arr[$iii]['name']; + $ret .= '    edit
'; + $iii_print++; + } + } + $level--; + #----------------------- + # end of sub-child loop + #----------------------- + + } + } + $level--; + #------------------- + # end of child loop + #------------------- + } + } + } + else + { + return 'No groups available!'; // translate! + } + echo $ret; + } + + +} +?> \ No newline at end of file diff --git a/modules/group/group_construct.xml b/modules/group/group_construct.xml new file mode 100644 index 00000000..51dbfd0d --- /dev/null +++ b/modules/group/group_construct.xml @@ -0,0 +1,72 @@ + + + + group + + group
+ + + + 0 + + parent_id,name + + 25 + + + date_expire + status,parent_id,date_start,date_expire + + + + + I4 + 1 + + + I4 + + + I8 + date-now + + + I8 + date-time + + + I8 + date-time + + + I4 + + + L + + + L + + + C(128) + any + 3 + 64 + 1 + + + X2 + + + + + id,site_id,date_orig,date_start,date_expire,name,notes,status,pricing,parent_id + id,site_id,date_orig,date_start,date_expire,name,notes,status,pricing,parent_id + id,site_id,date_orig,date_start,date_expire,name,notes,status,pricing,parent_id + id,site_id,date_orig,date_start,date_expire,name,notes,status,pricing,parent_id + id,site_id,date_orig,date_start,date_expire,name,notes,status,pricing,parent_id + id,site_id,date_orig,date_start,date_expire,name,notes,status,pricing,parent_id + + + 0 +
diff --git a/modules/group/group_install.xml b/modules/group/group_install.xml new file mode 100644 index 00000000..23a1babd --- /dev/null +++ b/modules/group/group_install.xml @@ -0,0 +1,40 @@ + + + group + account_admin + + 1 + + + + + visual_layout + + + + search + + + view + + + 1 + + + add + + 1 + + + delete + + + update + + + search_show + + + + + \ No newline at end of file diff --git a/modules/group/group_install_data.xml b/modules/group/group_install_data.xml new file mode 100644 index 00000000..a42c61e4 --- /dev/null +++ b/modules/group/group_install_data.xml @@ -0,0 +1,51 @@ + + + + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 1 + All Users + All unregistered users will have access to this. + + + 2 + 1 + 0 + 0 + 0 + 0 + 1 + 1 + Registered Users + + + 4 + 1 + 0 + 0 + 0 + 2 + 1 + 0 + Staff + + + 1001 + 1 + 0 + 0 + 0 + 2 + 1 + 0 + Root + + + 1016 + + \ No newline at end of file diff --git a/modules/group_method/group_method_construct.xml b/modules/group_method/group_method_construct.xml new file mode 100644 index 00000000..4ecacac1 --- /dev/null +++ b/modules/group_method/group_method_construct.xml @@ -0,0 +1,60 @@ + + + + group_method + + group_method
+ + + + 0 + + group_id + + 25 + + + group_id + module_id,method_id + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I4 + module_method + name + any + + + I4 + group + name + any + + + I4 + module + name + any + + + + + id,site_id,method_id,group_id,module_id + id,site_id,method_id,group_id,module_id + id,site_id,method_id,group_id,module_id + id,site_id,method_id,group_id,module_id + id,site_id,method_id,group_id,module_id + + + 0 +
diff --git a/modules/group_method/group_method_install.xml b/modules/group_method/group_method_install.xml new file mode 100644 index 00000000..169c5910 --- /dev/null +++ b/modules/group_method/group_method_install.xml @@ -0,0 +1,29 @@ + + + group_method + group + + + + + + search + + + view + + + add + + + delete + + + update + + + search_show + + + + \ No newline at end of file diff --git a/modules/host_registrar_plugin/host_registrar_plugin.inc.php b/modules/host_registrar_plugin/host_registrar_plugin.inc.php new file mode 100644 index 00000000..af2b220d --- /dev/null +++ b/modules/host_registrar_plugin/host_registrar_plugin.inc.php @@ -0,0 +1,239 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class host_registrar_plugin +{ + + # Open the constructor for this mod + function host_registrar_plugin() + { + # name of this module: + $this->module = "host_registrar_plugin"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + + ### Read the contents of the /plugins/affiliate directory: + $count = 0; + chdir(PATH_PLUGINS . 'registrar'); + $dir = opendir(PATH_PLUGINS . 'registrar'); + while ($file_name = readdir($dir)) + { + if($file_name != '..' && $file_name != '.' && !eregi("^_", $file_name)) + { + $count++; + } + } + + # define the DB vars as a Smarty accessible block + global $smarty; + + # create the search record: + if($count > 0) + { + # create the search record + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $arr['module'] = $this->module; + $arr['sql'] = ''; + $arr['limit'] = '999'; + $arr['order_by']= 'name'; + $arr['results'] = $count; + $search->add($arr); + + # define the search id and other parameters for Smarty + $smarty->assign('search_id', $search->id); + + # page: + $smarty->assign('page', '1'); + + # limit: + $smarty->assign('limit', '999'); + + # order_by: + $smarty->assign('order_by', 'name'); + + # define the result count + $smarty->assign('results', $count); + } + } + + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + + ### Read the contents of the /plugins/db_mapping directory: + $count = 0; + chdir(PATH_PLUGINS . 'registrar'); + $dir = opendir(PATH_PLUGINS . 'registrar'); + while ($file_name = readdir($dir)) + { + if($file_name != '..' && $file_name != '.' && !eregi("^_", $file_name) ) + { + $result[$count]['name'] = eregi_replace('.php', '', $file_name); + $result[$count]['id'] = $count; + + ### Get the status of this plugin: + $db = &DB(); + $q = 'SELECT status,id FROM '.AGILE_DB_PREFIX.'host_registrar_plugin WHERE + file = '. $db->qstr($result[$count]['name']) . ' AND + site_id = '. $db->qstr(DEFAULT_SITE); + $dbmap = $db->Execute($q); + + ### error reporting: + if ($dbmap === false) + { + global $C_debug; + $C_debug->error('affiliate_plugin.inc.php','search_show', $db->ErrorMsg()); return; + } + + if($dbmap->RecordCount() > 0) + { + $result[$count]['id'] = $dbmap->fields['id']; + $result[$count]['status'] = 1; + $result[$count]['active'] = $dbmap->fields['status']; + } + else + { + $result[$count]['status'] = 0; + } + + $count++; + } + } + + + $class_name = TRUE; + for ($i=0; $iassign($this->table, $smart); + $smarty->assign('page', $VAR['page']); + $smarty->assign('order', $smarty_order); + $smarty->assign('sort', $smarty_sort); + $smarty->assign('limit', $search->limit); + $smarty->assign('search_id',$search->id); + $smarty->assign('results', $count); + + # total pages + $smarty->assign('pages', 1); + + # current page + $smarty->assign('page', 1); + $page_arr = ''; + + # page array for menu + $smarty->assign('page_arr', $page_arr); + } +} +?> \ No newline at end of file diff --git a/modules/host_registrar_plugin/host_registrar_plugin_construct.xml b/modules/host_registrar_plugin/host_registrar_plugin_construct.xml new file mode 100644 index 00000000..0440d43d --- /dev/null +++ b/modules/host_registrar_plugin/host_registrar_plugin_construct.xml @@ -0,0 +1,59 @@ + + + + host_registrar_plugin + + host_registrar_plugin
+ + + + 0 + + name + + 25 + + + + I4 + 1 + 1 + + + I4 + 1 + 1 + + + L + + + C(32) + 1 + 2 + 32 + any + + + C(32) + 1 + 2 + 32 + any + + + X2 + array + + + + + id,site_id,status,name,file,plugin_data + id,site_id,status,name,file,plugin_data + id,site_id,status,name,file,plugin_data + id,site_id,status,name,file,plugin_data + id,site_id,status,name,file,plugin_data + + + 0> +
\ No newline at end of file diff --git a/modules/host_registrar_plugin/host_registrar_plugin_install.xml b/modules/host_registrar_plugin/host_registrar_plugin_install.xml new file mode 100644 index 00000000..8b547bd7 --- /dev/null +++ b/modules/host_registrar_plugin/host_registrar_plugin_install.xml @@ -0,0 +1,35 @@ + + + host_registrar_plugin + host_server + + 1 + + + + + add + + + update + + + delete + + + view + + 1 + + + search + + + search_form + + + search_show + + + + \ No newline at end of file diff --git a/modules/host_registrar_plugin/host_registrar_plugin_install_data.xml b/modules/host_registrar_plugin/host_registrar_plugin_install_data.xml new file mode 100644 index 00000000..5c8a3687 --- /dev/null +++ b/modules/host_registrar_plugin/host_registrar_plugin_install_data.xml @@ -0,0 +1,14 @@ + + + + 1 + 1 + 1 + manual + MANUAL + + + + 2 + + \ No newline at end of file diff --git a/modules/host_server/host_server.inc.php b/modules/host_server/host_server.inc.php new file mode 100644 index 00000000..05f403a5 --- /dev/null +++ b/modules/host_server/host_server.inc.php @@ -0,0 +1,311 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class host_server +{ + + # Open the constructor for this mod + function host_server() + { + # name of this module: + $this->module = "host_server"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + # manual add + function host_manual_new($service, $server, $account) + { + } + + # manual edit + function host_manual_edit($service, $server, $account) + { + } + + # manual activate + function host_manual_active($service, $server, $account) + { + } + + # manual deactivate + function host_manual_inactive($service, $server, $account) + { + } + + # manual delete + function host_manual_delete($service, $server, $account) + { + } + + + # Generate a new login + function generate_login($service,$account,$max_un_len, $max_pw_len, $shared) + { + # define username + if($service['host_username'] != '') + { + $ret['username'] = $service['host_username']; + } else + { + if ($shared == false) + { + # is username already in use on this server? + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'service WHERE + id != ' . $db->qstr( $service['id'] ) . ' AND + host_server_id = ' . $db->qstr( $service['host_server_id'] ) . ' AND + host_username = ' . $db->qstr( $account['username'] ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + if ($rs->RecordCount() == 0) + { + $ret['username'] = $account['username']; + } else { + $ret['username'] = $this->generate_login1($max_un_len); + } + } else { + $ret['username'] = $account['username']; + } + } + + # define password + if($service['host_password'] != '') { + $ret['password'] = $service['host_password']; + } else { + $ret['password'] = $this->generate_login1($max_pw_len); + } + + # save the username/password for this service + $db = &DB(); + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'service + SET + host_username = ' . $db->qstr( $ret['username'] ) . ', + host_password = ' . $db->qstr( $ret['password'] ) . ' + WHERE + id = ' . $db->qstr( $service['id'] ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $db->Execute($sql); + return $ret; + } + + + # random un/pw + function generate_login1($length) + { + srand((double)microtime()*1000000); + $vowels = array("a", "e", "i", "o", "u"); + $cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", + "r", "s", "t", "u", "v", "w", "tr", "cr", "br", "fr", "th", + "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl"); + $num_vowels = count($vowels); + $num_cons = count($cons); + for($i = 0; $i < $length; $i++){ + @$rand .= $cons[rand(0, $num_cons - 1)] . $vowels[rand(0, $num_vowels - 1)]; + } + return $rand; + } + + # use ip address + function useipaddress($service, $server) + { + if($service['host_ip'] != '') return $service['host_ip']; + + $pat = "\r\n"; + $ips_r = ''; + @$ips = explode($pat, $server['ip_based_ip']); + for($i=0; $imethod["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + global $smarty; + + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $dx = new CORE_database; + $rs = $dx->view($VAR, $this, $type); + + # get the list of available servers to define as "next server" + $db = &DB(); + $sql= 'SELECT id,name FROM ' . AGILE_DB_PREFIX . 'host_server WHERE + id != ' . $db->qstr( $rs[0]['id'] ) . ' AND + next_host_server_id != ' . $db->qstr( $rs[0]['id'] ) . ' AND + provision_plugin = ' . $db->qstr( $rs[0]['provision_plugin'] ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + if(@$rs->RecordCount() > 0) + { + $arr[0] = ''; + while(!$rs->EOF) { + $arr[$rs->fields['id']] = $rs->fields['name']; + $rs->MoveNext(); + } + $smarty->assign('next_server_options', $arr); + $smarty->assign('next_server', true); + + } else { + $smarty->assign('next_server', false); + } + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/host_server/host_server_construct.xml b/modules/host_server/host_server_construct.xml new file mode 100644 index 00000000..a2ad8bd6 --- /dev/null +++ b/modules/host_server/host_server_construct.xml @@ -0,0 +1,96 @@ + + + + host_server + + host_server
+ + + + 0 + + name + + 25 + + + + I4 + 1 + 1 + + + I4 + 1 + + + L + + + L + + + C(128) + 1 + 128 + any + + + C(255) + + + C(128) + 1 + 128 + + + X2 + array + + + I4 + + + I4 + host_server + name + + + L + + + C(32) + + + L + + + X2 + + + C(128) + + + C(128) + + + C(128) + + + C(128) + + + C(64) + + + + + id,site_id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts,next_host_server_id,name_based,name_based_ip,ip_based,ip_based_ip,ns_ip_secondary,ns_ip_primary,ns_primary,ns_secondary,keycode + id,site_id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts,next_host_server_id,name_based,name_based_ip,ip_based,ip_based_ip,ns_ip_secondary,ns_ip_primary,ns_primary,ns_secondary,keycode + id,site_id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts,next_host_server_id,name_based,name_based_ip,ip_based,ip_based_ip,ns_ip_secondary,ns_ip_primary,ns_primary,ns_secondary,keycode + id,site_id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts,next_host_server_id,name_based,name_based_ip,ip_based,ip_based_ip,ns_ip_secondary,ns_ip_primary,ns_primary,ns_secondary,keycode + id,site_id,status,debug,name,notes,provision_plugin,provision_plugin_data,max_accounts,next_host_server_id,name_based,name_based_ip,ip_based,ip_based_ip,ns_ip_secondary,ns_ip_primary,ns_primary,ns_secondary,keycode + + + 0 +
diff --git a/modules/host_server/host_server_install.xml b/modules/host_server/host_server_install.xml new file mode 100644 index 00000000..d44e4a6c --- /dev/null +++ b/modules/host_server/host_server_install.xml @@ -0,0 +1,40 @@ + + + host_server + host_server + + 1 + host_tld,host_registrar_plugin + + + + + add + + 1 + + + update + + + search + + + search_form + + + + view + + 1 + + + delete + + + search_show + + + + + \ No newline at end of file diff --git a/modules/host_tld/auth.inc.php b/modules/host_tld/auth.inc.php new file mode 100644 index 00000000..87d52290 --- /dev/null +++ b/modules/host_tld/auth.inc.php @@ -0,0 +1,8 @@ + 'host_tld', 'method' => 'whois'), +Array ('module' => 'host_tld', 'method' => 'whois_transfer'), +Array ('module' => 'host_tld', 'method' => 'whois_mass') +); +?> \ No newline at end of file diff --git a/modules/host_tld/host_tld.inc.php b/modules/host_tld/host_tld.inc.php new file mode 100644 index 00000000..3c8dfafd --- /dev/null +++ b/modules/host_tld/host_tld.inc.php @@ -0,0 +1,416 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class host_tld +{ + + /** + * Get the TLD pricing array + * + * @param string $tld + * @param string $type park, register, renew + * @param int $product_id + * @param array $discount_products + * @param float $discount_rate + * @param int $account + * @return array + */ + function price_tld_arr($tld, $type, $product_id=false, $discount_products=false, $discount_rate=false, $account=SESS_ACCOUNT) + { + # get the plugin for this domain: + $db = &DB(); + $result = $db->Execute(sqlSelect($db,"host_tld","*","name=::$tld:: AND status=1")); + if($result == false || $result->RecordCount() == 0) return false; + + # serialize: + global $C_auth; + $p_arr = unserialize($result->fields["price_group"]); + + # get the pricing for domain parking: + if($type == "park") { + if($p_arr[0]["show"] != "1") { + return false; + } else { + $i = 0; + $type = $register; + while (list ($group, $vals) = each ($p_arr[$i])) + if (gettype($group) != 'string' && $C_auth->auth_group_by_account_id($account, $group)) + if(empty($price) || $vals["register"] < $price) + $price = $vals["register"]; + return $price; + } + } else { + # get any hosting discounts for this product: + if(!empty($discount_products)) { + $d_arr = unserialize($discount_products); + for($ii=0; $iifields["id"]) + $hosting_discount = $discount_rate; + } + } + + if(empty($hosting_discount)) $hosting_discount = false; + + # get the pricing details for registrations/transfers for this TLD: + if(count($p_arr) > 0) + for($i=1; $i<=10; $i++) + if($p_arr[$i]["show"] == "1") + while (list ($group, $vals) = each ($p_arr[$i])) + if (gettype($group) != 'string' && $C_auth->auth_group_by_account_id($account, $group)) + if(empty($price[$i]) || $vals[$type] < $price[$i]) + if(!empty($vals[$type])) + if($hosting_discount != false) + $price[$i] = $vals[$type] - ($vals[$type] * $hosting_discount); + else + $price[$i] = $vals[$type]; + return $price; + } + return false; + } + + + /** SUGGEST RESULTS + */ + function suggest($VAR) + { + $db = &DB(); + $dbm = new CORE_database; + $sql = $dbm->sql_select('host_tld','name,default_term_new', "auto_search = 1 AND status = 1", "name", $db); + $rs = $db->Execute($sql); + while(!$rs->EOF) { + $smart[] = $rs->fields; + $rs->MoveNext(); + } + + $count = count($smart); + $js = "var tldArr = new Array($count); var tldCount = $count; "; + for($i=0; $i<$count; $i++) + $js .= "tldArr[$i] = '{$smart[$i]['name']}'; "; + + global $smarty; + $smarty->assign('tlds', $smart); + $smarty->assign('javascript', $js); + } + + /** WHOIS LOOKUP + */ + function whois_mass($VAR) + { + global $smarty, $C_debug, $C_translate; + $db = &DB(); + + if(!empty($VAR['domains'])) + { + $arr = explode("\r\n", $VAR['domains']); + $domains =''; + $msg =''; + // loop through each row + for($i=0; $i$td) { + if($key > 0) { + if(!empty($tld)) $tld .='.'; + $tld .= $td; + } + } + + # check for duplicates + $do=true; + for($ii=0; $iivalue['host_tld']['domain'] = ''.$domain.".".$tld.''; + $C_translate->value['host_tld']['tld'] = ''.$tld.''; + + # get the plugin for this domain: + $result = $db->Execute(sqlSelect($db,"host_tld","*","name=::$tld:: AND status=1")); + if($result == false || $result->RecordCount() == 0) + { + ### INVALID TLD + $msg .= $C_translate->translate('search_mass_err_tld','host_tld','') . '
'; + } + else + { + # get the whois plugin details for this TLD & check avail + $file = $result->fields['whois_plugin']; + $data = unserialize($result->fields['whois_plugin_data']); + include_once(PATH_PLUGINS . 'whois/'. $file.'.php'); + eval ( '$_WHOIS = new plgn_whois_'. strtoupper ( $file ) . ';' ); + if($_WHOIS->check($domain, $tld, $data)) + { + $smarty->assign("checkout", true); + $domains .= $domain.'.'.$tld."\r\n"; + $domainarr[] = Array($domain,$tld); + } else { + ### DOMAIN NOT AVAILABLE + $msg .= $C_translate->translate('search_mass_err_dom','host_tld','') . '
'; + } + } + } + } + } + if($msg) $C_debug->alert($msg); + $smarty->assign('domains', @$domains); + $smarty->assign('domainarr', @$domainarr); + } + } + + /** + * WHOIS RESPONSE + */ + function whois_reponse($type, $VAR, $response, $park=0) { + if(defined('AJAX')) { + + if($type=='register') { + if($response) + echo 'available('.$park.');'; + else + echo 'unavailable();'; + + } elseif($type=='transfer') { + if($response) + echo 'unavailable();'; + else + echo 'available();'; + + } elseif($type=='suggest') { + if($response) + echo "domainUpdate('{$VAR['domain']}','{$VAR['tld']}','register','{$VAR['element']}',1);"; + else + echo "domainUpdate('{$VAR['domain']}','{$VAR['tld']}','register','{$VAR['element']}',0);"; + } + } + return $response; + } + + /** + * WHOIS LOOKUP + */ + function whois($VAR) + { + if(!empty($VAR['tld']) && !empty($VAR['domain'])) + { + $db = &DB(); + # check this domain & tld is not already in the service table: + $rs = $db->Execute(sqlSelect($db,"service","id","domain_name = ::{$VAR['domain']}:: AND domain_tld = ::{$VAR['tld']}::")); + if($rs && $rs->RecordCount()) { + //$smarty->assign("whois_result", "0"); + //echo 'unavailable();'; + return $this->whois_reponse($VAR['type'], $VAR, false); + } + + # check this domain & tld is not already in the shopping cart: + $rs = $db->Execute(sqlSelect($db,"cart","id","domain_name = ::{$VAR['domain']}:: AND domain_tld = ::{$VAR['tld']}::")); + if($rs && $rs->RecordCount()) { + return $this->whois_reponse($VAR['type'], $VAR, false); + } + + # get the plugin for this domain: + $result = $db->Execute(sqlSelect($db,"host_tld","*","name=::{$VAR['tld']}:: AND status=1")); + if($result == false || $result->RecordCount() == 0) { + return $this->whois_reponse($VAR['type'], $VAR, false); + } + + # get the whois plugin details for this TLD + $file = $result->fields['whois_plugin']; + $data = unserialize($result->fields['whois_plugin_data']); + + # allow parking? + $price = unserialize ( $result->fields['price_group'] ); + $park = $price["0"]["show"]; + + # initialize the whois plugin: + include_once(PATH_PLUGINS . 'whois/'. $file.'.php'); + eval ( '$_WHOIS = new plgn_whois_'. strtoupper ( $file ) . ';' ); + + if($_WHOIS->check($VAR['domain'], $VAR['tld'], $data)) + return $this->whois_reponse($VAR['type'], $VAR, true, $park); + else + return $this->whois_reponse($VAR['type'], $VAR, false, $park); + + } else { + return $this->whois_reponse($VAR['type'], $VAR, false, $park); + } + } + + /** + * WHOIS TRANSFER LOOKUP + */ + function whois_transfer($VAR) + { + global $smarty; + if(!empty($VAR['tld']) && !empty($VAR['domain'])) + { + $db = &DB(); + + # check this domain & tld is not already in the service table: + $rs = $db->Execute(sqlSelect($db,"service","id","domain_name = ::{$VAR['domain']}:: AND domain_tld = ::{$VAR['tld']}::")); + if($rs && $rs->RecordCount()) { + $smarty->assign("whois_result", "0"); + return; + } + + # check this domain & tld is not already in the shopping cart: + $rs = $db->Execute(sqlSelect($db,"cart","id","domain_name = ::{$VAR['domain']}:: AND domain_tld = ::{$VAR['tld']}::")); + if($rs && $rs->RecordCount()) { + $smarty->assign("whois_result", "0"); + return; + } + + # get the plugin for this domain: + $result = $db->Execute(sqlSelect($db,"host_tld","*","name=::{$VAR['tld']}:: AND status=1")); + if($result == false || $result->RecordCount() == 0) { + $smarty->assign("whois_result", "0"); + return; + } + + # get the pricing details to see if transfers are allowed for this TLD: + $p_arr = unserialize($result->fields["price_group"]); + $transfer = false; + if(count($p_arr) > 0) + for($i=1; $i<=10; $i++) + if($p_arr[$i]["show"] == "1") + while(list($key,$val) = each($p_arr[$i])) + if(isset($val["transfer"]) && $val["transfer"] > 1) $transfer = true; + + if(!$transfer) + { + $smarty->assign("whois_result", "0"); + return; + } + + # get the whois plugin details for this TLD + $file = $result->fields['whois_plugin']; + $data = unserialize($result->fields['whois_plugin_data']); + + # initialize the whois plugin: + include_once(PATH_PLUGINS . 'whois/'. $file.'.php'); + eval ( '$_WHOIS = new plgn_whois_'. strtoupper ( $file ) . ';' ); + + if($_WHOIS->check_transfer($VAR['domain'], $VAR['tld'], $data)) + { + $smarty->assign("whois_result", "1"); + return; + } + else + { + $smarty->assign("whois_result", "0"); + return; + } + } + else + { + $smarty->assign("whois_result", "0"); + return; + } + } + + function constructor() + { + $this->module = "host_tld"; + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + function add($VAR) + { + $this->constructor(); + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + function view($VAR) + { + $this->constructor(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + function update($VAR) + { + $this->constructor(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + function delete($VAR) + { + $this->constructor(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + function search_form($VAR) + { + $this->constructor(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + function search($VAR) + { + $this->constructor(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + function search_show($VAR) + { + $this->constructor(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/host_tld/host_tld_construct.xml b/modules/host_tld/host_tld_construct.xml new file mode 100644 index 00000000..43afd8a4 --- /dev/null +++ b/modules/host_tld/host_tld_construct.xml @@ -0,0 +1,84 @@ + + + + host_tld + + host_tld
+ + + + 0 + + name + + 25 + + + status + name + auto_search + + + + + I4 + 1 + 1 + + + I4 + 1 + + + L + + + C(128) + any + + + L + + + C(32) + 1 + 32 + + + X2 + array + + + I4 + host_registrar_plugin + name + + + X2 + array + + + L + + + I4 + 1 + 2 + numeric + + + X2 + array + + + + + id,site_id,status,name,whois_plugin,whois_plugin_data,registrar_plugin_id,registrar_plugin_data,auto_search,default_term_new,price_group,taxable + id,site_id,status,name,whois_plugin,whois_plugin_data,registrar_plugin_id,registrar_plugin_data,auto_search,default_term_new,price_group,taxable + id,site_id,status,name,whois_plugin,whois_plugin_data,registrar_plugin_id,registrar_plugin_data,auto_search,default_term_new,price_group,taxable + id,site_id,status,name,whois_plugin,whois_plugin_data,registrar_plugin_id,registrar_plugin_data,auto_search,default_term_new,price_group,taxable + id,site_id,status,name,whois_plugin,whois_plugin_data,registrar_plugin_id,registrar_plugin_data,auto_search,default_term_new,price_group,taxable + + + 0 +
diff --git a/modules/host_tld/host_tld_install.xml b/modules/host_tld/host_tld_install.xml new file mode 100644 index 00000000..f8438d95 --- /dev/null +++ b/modules/host_tld/host_tld_install.xml @@ -0,0 +1,37 @@ + + + host_tld + host_server + + 1 + + + + + add + + 1 + + + update + + + delete + + + view + + 1 + + + search + + + search_form + + + search_show + + + + \ No newline at end of file diff --git a/modules/host_tld/host_tld_install_data.xml b/modules/host_tld/host_tld_install_data.xml new file mode 100644 index 00000000..0ced9544 --- /dev/null +++ b/modules/host_tld/host_tld_install_data.xml @@ -0,0 +1,48 @@ + + + + 1 + 1 + 1 + com + 0 + DEFAULT + + 1 + + 1 + 1 + + + + 2 + 1 + 1 + net + 1 + DEFAULT + + 1 + + 1 + 1 + + + + 3 + 1 + 1 + org + 1 + DEFAULT + + 1 + + 1 + 2 + + + + 3 + + \ No newline at end of file diff --git a/modules/htaccess/auth.inc.php b/modules/htaccess/auth.inc.php new file mode 100644 index 00000000..bdbf26a0 --- /dev/null +++ b/modules/htaccess/auth.inc.php @@ -0,0 +1,10 @@ + 'htaccess', 'method' => 'list_dirs'), + Array ('module' => 'htaccess', 'method' => 'check_smarty') + ); +?> \ No newline at end of file diff --git a/modules/htaccess/htaccess.inc.php b/modules/htaccess/htaccess.inc.php new file mode 100644 index 00000000..d96d26c0 --- /dev/null +++ b/modules/htaccess/htaccess.inc.php @@ -0,0 +1,362 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class htaccess +{ + + # Open the constructor for this mod + function htaccess() + { + # name of this module: + $this->module = "htaccess"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## LIST AUTH HTACCESS URLS ## + ############################## + + function list_dirs($VAR) + { + global $smarty, $C_auth; + $ii = 0; + + ### Get a list of htaccess groups: + $db = &DB(); + $sql = 'SELECT id,group_avail + FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + status = ' . $db->qstr('1'); + $result = $db->Execute($sql); + + if($result->RecordCount() == 0) + { + + $smarty->assign('htaccess_display', false); + return false; + } + + while(!$result->EOF) + { + @$arr = unserialize($result->fields['group_avail']); + $id = $result->fields['id']; + $this_show = false; + + for($i=0; $iauth_group_by_id($arr[$i])) + { + $this_show = true; + $i=count($arr); + } + } + + if($this_show) + { + ### Get each directory and add it to the array: + $db = &DB(); + $sql = 'SELECT * + FROM ' . AGILE_DB_PREFIX . 'htaccess_dir WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + htaccess_id = ' . $db->qstr($id) . ' AND + status = ' . $db->qstr('1'); + $result_dir = $db->Execute($sql); + + while(!$result_dir->EOF) + { + + $arr_smarty[] = Array ( + 'id' => $result_dir->fields['id'], + 'name' => $result_dir->fields['name'], + 'description' => $result_dir->fields['description'], + 'url' => $result_dir->fields['url'] + ); + $ii++; + $result_dir->MoveNext(); + } + } + $result->MoveNext(); + } + + + + if($ii == "0") + { + $smarty->assign('htaccess_display', false); + return false; + } + else + { + $smarty->assign('htaccess_display', true); + $smarty->assign('htaccess_results', $arr_smarty); + return true; + } + } + + + + + + ############################## + ## Smarty Authentication ## + ############################## + function check_smarty($VAR) + { + global $smarty, $C_translate; + if($this->check_auth($VAR['_htaccess_id']) ) + { + if(isset($VAR['_htaccess_dir_id'])) + { + ## Get the URL for this htaccess area: + $db = &DB(); + $sql = 'SELECT url FROM ' . AGILE_DB_PREFIX . 'htaccess_dir WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($VAR['_htaccess_dir_id']); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + $smarty->assign('htaccess_url', $result->fields['url']); + $smarty->assign('htaccess_auth', "1"); + return true; + } + } + + $smarty->assign('htaccess_auth', "0"); + return false; + } + + + ############################## + ## Check Authentication ## + ############################## + function check_auth($id) + { + ### Check if user is a member of one of the authorized groups: + $db = &DB(); + $sql = 'SELECT status,group_avail FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($id); + $result = $db->Execute($sql); + + if($result->RecordCount() > 0) + { + if ($result->fields['status'] != '1') return false; + @$arr = unserialize($result->fields['group_avail']); + global $C_auth; + for($i=0; $iauth_group_by_id($arr[$i])) return true; + + } + + return false; + } + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $id = $db->add($VAR, $this, $type); + + if(isset($id) && $id > 0) + { + # Create the php index file for the Apache mod_auth_remote module: + /* + $GroupArray = ''; + for($i=0; $i 0) $GroupArray .= ','; + $GroupArray .= $VAR['htaccess_group_avail'][$i]; + } + + $data = ''; + + # add dir: + $dir = PATH_FILES . 'htaccess_'. $id .'/'; + if(is_dir($dir)) + mkdir($dir, '755'); + + $file = $dir . 'index.php'; + $fp = fopen($file, "w+"); + fputs($fp, $data); + fclose($fp); + */ + } + } + + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $result = $db->update($VAR, $this, $type); + + if($result) + { + $id = $VAR['htaccess_id']; + + # Update the php index file for the Apache mod_auth_remote module: + $GroupArray = ''; + for($i=0; $i 0) $GroupArray .= ','; + $GroupArray .= $VAR['htaccess_group_avail'][$i]; + } + + + $data = ''; + + # add dir: + $dir = PATH_FILES . 'htaccess_'. $id; + if(!is_dir($dir)) + mkdir($dir, '755'); + + $file = PATH_FILES . 'htaccess_'. $id . '/index.php'; + $fp = fopen($file, "w+"); + fputs($fp, $data); + fclose($fp); + } + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + global $C_debug, $C_translate; + + ### Get the array + if(isset($VAR["delete_id"])) + $id = split(',', $VAR["delete_id"]); + elseif (isset($VAR["id"])) + $id = split(',', $VAR["id"]); + + ### Load class for deleting sub-dirs. + include_once ( PATH_MODULES .'htaccess_dir/htaccess_dir.inc.php' ); + $htdir = new htaccess_dir; + + ### Loop: + $db = &DB(); + for($i=0; $i 0 ) + { + ### Delete the htpasswd record: + $sql = "DELETE FROM ".AGILE_DB_PREFIX."htaccess WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($id[$i]); + $result = $db->Execute($sql); + + if ( $result ) + { + ### Delete .htaccess file(s) from the sub-directories + $sql = "SELECT id FROM ".AGILE_DB_PREFIX."htaccess_dir WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + htaccess_id = ".$db->qstr($id[$i]); + $result = $db->Execute($sql); + if ($result->RecordCount() > 0 ) + $htdir->delete_one($result->fields['id']); + } + } + + ### Delete the mod_auth_remote files: + /* + unlink(PATH_FILES.'htaccess_'. $id[$i] . '/index.php'); + rmdir(PATH_FILES.'htaccess_'. $id[$i] ); + */ + } + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/htaccess/htaccess_construct.xml b/modules/htaccess/htaccess_construct.xml new file mode 100644 index 00000000..3749b7dc --- /dev/null +++ b/modules/htaccess/htaccess_construct.xml @@ -0,0 +1,70 @@ + + + + htaccess + + htaccess
+ + + + 0 + + name + + 25 + + + date_start + date_expire + status + + + + + I4 + 1 + 1 + + + I4 + 1 + 1 + + + I8 + date + + + I8 + date + + + C(128) + 3 + 128 + alphanumeric + 1 + + + X2 + + + L + + + X2 + any + array + + + + + id,site_id,date_start,date_expire,name,description,status,group_avail + id,site_id,date_start,date_expire,name,description,status,group_avail + id,site_id,date_start,date_expire,name,description,status,group_avail + id,site_id,date_start,date_expire,name,description,status,group_avail + id,site_id,date_start,date_expire,name,description,status,group_avail + + + 0 +
diff --git a/modules/htaccess/htaccess_install.xml b/modules/htaccess/htaccess_install.xml new file mode 100644 index 00000000..c6d37810 --- /dev/null +++ b/modules/htaccess/htaccess_install.xml @@ -0,0 +1,37 @@ + + + htaccess + htaccess + + 1 + htaccess_dir,htaccess_exclude + + + + + search + + + view + + + 1 + + + add + + 1 + + + delete + + + update + + + search_show + + + + + \ No newline at end of file diff --git a/modules/htaccess/mod_auth_remote.inc.php b/modules/htaccess/mod_auth_remote.inc.php new file mode 100644 index 00000000..1b11c42d --- /dev/null +++ b/modules/htaccess/mod_auth_remote.inc.php @@ -0,0 +1,103 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +# check that the username/password are both set +if(empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW'])) +{ + mail('sales@agileco.com', 'htaccess empty', ''); + header_unauth(); +} + + +#check the database for a match +$pre = AGILE_DB_PREFIX; +$time = time(); +$db = &DB(); +$q = " SELECT DISTINCT + {$pre}account.id AS account_id, + {$pre}account_group.group_id AS group_id + FROM + {$pre}account + INNER JOIN + {$pre}account_group + ON + {$pre}account_group.account_id = {$pre}account.id + WHERE + ( + {$pre}account.date_expire IS NULL OR + {$pre}account.date_expire = 0 OR + {$pre}account.date_expire > ".$db->qstr($time)." + ) + AND + {$pre}account.status = ". $db->qstr(1) . " + AND + ( + {$pre}account.password = ". $db->qstr(md5(@$_SERVER['PHP_AUTH_PW'])) . " + OR + {$pre}account.password = ". $db->qstr(@$_SERVER['PHP_AUTH_PW']) . " + ) + AND + {$pre}account.username = ". $db->qstr(@$_SERVER['PHP_AUTH_USER'] )." + AND + {$pre}account.site_id = ". $db->qstr(DEFAULT_SITE ) . " + AND + ( + {$pre}account_group.date_start IS NULL OR + {$pre}account_group.date_start = 0 OR + {$pre}account_group.date_start < ".$db->qstr($time)." + ) + AND + ( + {$pre}account_group.date_expire IS NULL OR + {$pre}account_group.date_expire = 0 OR + {$pre}account_group.date_expire > ".$db->qstr($time)." + ) + AND + {$pre}account_group.active = ".$db->qstr(1)." + AND + {$pre}account_group.site_id = ". $db->qstr( DEFAULT_SITE ); + +# Check for group permissions: +$result = $db->Execute($q); +if($result->RecordCount() > 0) { + while( !$result->EOF ) { + for($i=0; $ifields["group_id"]) + header_auth(); + } + $result->MoveNext(); + } +} + +# Not authorized: +header_unauth(); + + +function header_auth() { + header('HTTP/1.0 201 Authorized'); + exit; +} + +function header_unauth() +{ + header('WWW-Authenticate: Basic realm="{$realm}"'); + header('HTTP/1.0 401 Unauthorized'); +} +?> \ No newline at end of file diff --git a/modules/htaccess_dir/htaccess_dir.inc.php b/modules/htaccess_dir/htaccess_dir.inc.php new file mode 100644 index 00000000..82bcabdf --- /dev/null +++ b/modules/htaccess_dir/htaccess_dir.inc.php @@ -0,0 +1,472 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class htaccess_dir +{ + + # Open the constructor for this mod + function htaccess_dir() + { + # name of this module: + $this->module = "htaccess_dir"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + + # add extra lines needed in the .htaccess files when added/updated: + # Example: + #$this->htaccess_extra = "Options +FollowSymlinks\n"; + $this->htaccess_extra = ''; + } + + + + + ############################## + ## ADD ## + ############################## + + function add($VAR) + { + global $C_translate, $C_debug; + $VAR['htaccess_dir_htaccess'] = '# Error!'; + $this->validated = true; + + ### Change the path... + if ( isset ( $VAR['htaccess_dir_path'] ) && $VAR['htaccess_dir_path'] != '' ) + { + # trim whitspaces + $VAR['htaccess_dir_path'] = trim ( $VAR['htaccess_dir_path'] ); + + # replace all forward slashes with back slashes + $VAR['htaccess_dir_path'] = ereg_replace('\\\\', '/', $VAR['htaccess_dir_path']); + + # add the final trailing slash if missing + if ( !ereg ('[/]$', $VAR['htaccess_dir_path'] ) ) + $VAR['htaccess_dir_path'] = $VAR['htaccess_dir_path'] . '/'; + } + + + if( isset ( $VAR['htaccess_dir_path'] ) && $VAR['htaccess_dir_path'] != '' ) + { + ################################################################ + ### VERIFY LOCAL PATH & WRITABILITY! + + @$filename = $VAR['htaccess_dir_path'] . '.htaccess'; + @$id = $VAR['htaccess_dir_htaccess_id']; + $db = &DB(); + $sql = 'SELECT name FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($id); + $result = $db->Execute($sql); + @$name = $result->fields['name']; + + ### Check path + $path = $VAR['htaccess_dir_path']; + if ( is_dir ( $path ) ) + { + ### Check if is writable! + if ( !is_writable ( $path ) ) + { + ## Path not writable! + $this->validated = false; + $this->val_error[] = array( + 'field' => 'none', + 'field_trans' => $C_translate->translate('error', 'core', ""), + 'error' => $C_translate->translate('path_auth', 'htaccess_dir', "")); + } + } + else + { + ### Path broken! + $this->validated = false; + $this->val_error[] = array( + 'field' => 'none', + 'field_trans' => $C_translate->translate('error', 'core', ""), + 'error' => $C_translate->translate('path_broke', 'htaccess_dir', "")); + } + } + + + + #################################################################### + ### If validation was failed, skip the db insert & + ### set the errors & origonal fields as Smarty objects, + ### and change the page to be loaded. + #################################################################### + + if(!$this->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $this->val_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page_current']); + } + return; + } + + + #################################################################### + ### Create the record/verify fields + + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $dir_id = $db->add($VAR, $this, $type); + + #################################################################### + ### Create the .htaccess file + + if( isset ( $dir_id ) && $dir_id > 0 ) + { + ### GENERATE THE EXCLUDE LIST + $exclude_list = $this->exclude_list(); + + ### GENERATE THE .HTACCESS FILE + $nl = "\n"; + $data = $this->htaccess_extra . 'RewriteEngine on' . $nl; + if(empty($VAR['htaccess_dir_recursive'])) + $data .= 'RewriteRule ^(.*)/.*$ - [L]' . $nl; + $data .= 'RewriteRule ' . $exclude_list . '$ htaccess_index.php?_HTACCESS_ID='.$id.'&_HTACCESS_DIR_ID='.$dir_id; + + ### Update the db record + $db = &DB(); + $sql = "UPDATE ".AGILE_DB_PREFIX."htaccess_dir SET + htaccess = " . $db->qstr( $data ) . " WHERE + id = " . $db->qstr( $dir_id ) . " AND + site_id = " . $db->qstr( DEFAULT_SITE ); + $result = $db->Execute($sql); + + ### WRITE THE LOCAL .HTACCESS FILE + $fp = fopen($filename, "w+"); + fwrite($fp,$data); + fclose($fp); + + ### WRITE THE htaccess_index.php FILE + $php_filename = $VAR['htaccess_dir_path'] . 'htaccess_index.php'; + $data = $this->create_php(); + $fp = fopen($php_filename, "w+"); + fwrite($fp,$data); + fclose($fp); + } + } + + + + + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + global $C_translate, $C_debug; + $this->validated = true; + + ### Change the path... + if ( isset ( $VAR['htaccess_dir_path'] ) && $VAR['htaccess_dir_path'] != '' ) + { + # trim whitspaces + $VAR['htaccess_dir_path'] = trim ( $VAR['htaccess_dir_path'] ); + + # replace all forward slashes with back slashes + $VAR['htaccess_dir_path'] = ereg_replace('\\\\', '/', $VAR['htaccess_dir_path']); + + # add the final trailing slash if missing + if ( !ereg ('[/]$', $VAR['htaccess_dir_path'] ) ) + $VAR['htaccess_dir_path'] = $VAR['htaccess_dir_path'] . '/'; + } + + ### Change the .htaccess data + if( isset ( $VAR['htaccess_dir_path'] ) && $VAR['htaccess_dir_path'] != '' ) + { + + ################################################################ + ### VERIFY LOCAL PATH & WRITABILITY! + + @$filename = $VAR['htaccess_dir_path'] . '.htaccess'; + @$php_filename = $VAR['htaccess_dir_path'] . 'htaccess_index.php'; + @$id = $VAR['htaccess_dir_htaccess_id']; + $db = &DB(); + $sql = 'SELECT name FROM ' . AGILE_DB_PREFIX . 'htaccess WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($id); + $result = $db->Execute($sql); + @$name = $result->fields['name']; + + + ### Check path + $path = $VAR['htaccess_dir_path']; + if ( is_dir ( $path ) ) + { + ### Check if is writable! + if ( is_writable ( $path ) ) + { + ### GENERATE THE EXCLUDE LIST + $exclude_list = $this->exclude_list(); + $nl = "\n"; + + /* + $data = $this->htaccess_extra . + 'RewriteEngine on' . $nl . + 'RewriteRule ^(.*)/.*$ - [L]' . $nl . + 'RewriteRule ' . + '' . $exclude_list . '$ ' . + 'htaccess_index.php' . + '?_HTACCESS_ID='.$id.'&_HTACCESS_DIR_ID='.$VAR["htaccess_dir_id"]; + */ + + $data = $this->htaccess_extra . 'RewriteEngine on' . $nl; + if(empty($VAR['htaccess_dir_recursive'])) + $data .= 'RewriteRule ^(.*)/.*$ - [L]' . $nl; + $data .= 'RewriteRule ' . $exclude_list . '$ htaccess_index.php?_HTACCESS_ID='.$id.'&_HTACCESS_DIR_ID='.$VAR["htaccess_dir_id"]; + + + ### Set the .htaccess var for the db + $VAR['htaccess_dir_htaccess'] = $data; + } + else + { + ## Path not writable! + $this->validated = false; + $this->val_error[] = array( + 'field' => 'none', + 'field_trans' => $C_translate->translate('error', 'core', ""), + 'error' => $C_translate->translate('path_auth', 'htaccess_dir', "")); + } + } + else + { + ### Path broken! + $this->validated = false; + $this->val_error[] = array( + 'field' => 'none', + 'field_trans' => $C_translate->translate('error', 'core', ""), + 'error' => $C_translate->translate('path_broke', 'htaccess_dir', "")); + } + } + + #################################################################### + ### If validation was failed, skip the db insert & + ### set the errors & origonal fields as Smarty objects, + ### and change the page to be loaded. + #################################################################### + + if(!$this->validated) + { + global $smarty; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $this->val_error); + + # set the page to be loaded + if(!defined("FORCE_PAGE")) + { + define('FORCE_PAGE', $VAR['_page']); + } + return; + } + + ### Update the db record + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $dir = $db->update($VAR, $this, $type); + + if($dir != false) + { + ### UPDATE THE LOCAL .HTACCESS FILE + $fp = fopen($filename, "w+"); + fwrite($fp,$data); + fclose($fp); + + ### UPDATE THE LOCAL htaccess_index.php + $data = $this->create_php(); + $fp = fopen($php_filename, "w+"); + fwrite($fp,$data); + fclose($fp); + } + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + ### Get the array + if(isset($VAR["delete_id"])) + $id = split(',', $VAR["delete_id"]); + elseif (isset($VAR["id"])) + $id = split(',', $VAR["id"]); + + ### Loop: + for($i=0; $idelete_one($id[$i]); + } + } + + ############################## + ## DELETE ONE ## + ############################## + function delete_one($id) + { + global $C_debug, $C_translate; + + if ($id == '') return false; + + ### Get the details of this directory record + $db = &DB(); + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."htaccess_dir WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($id); + $result = $db->Execute($sql); + $type = $result->fields['type']; + $path = $result->fields['path']; + + if( $result != false ) + { + ### DELETE THE LOCAL .HTACCESS FILE + $filename = $result->fields['path'] . '.htaccess'; + if ( @unlink ($filename) === false) + { + $C_translate->value['htaccess_dir']['dir'] = $result->fields['path'] . '.htaccess'; + $C_debug->alert($C_translate->translate('remove_fail','htaccess_dir','')); + } + + ### DELETE THE LOCAL HTACCESS_ATILE.PHP FILE + $filename = $result->fields['path'] . 'htaccess_index.php'; + @unlink ($filename); + } + + ### Delete the Record: + $db = &DB(); + $sql = "DELETE FROM ".AGILE_DB_PREFIX."htaccess_dir WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($id); + $resulta = $db->Execute($sql); + + ### Success message + $C_translate->value['htaccess_dir']['dira'] = $path; + $C_debug->alert($C_translate->translate('remove_success','htaccess_dir','')); + + return true; + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + function exclude_list() + { + global $VAR; + + $list = ''; + @$Arr = $VAR['htaccess_dir_exclude']; + if ( count($Arr) == 0) return ''; + + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'htaccess_exclude WHERE + site_id = ' . $db->qstr(DEFAULT_SITE); + $result = $db->Execute($sql); + if($result->RecordCount() == 0) return ''; + while(!$result->EOF) + { + $id = $result->fields['id']; + $ext= $result->fields['extension']; + + ### GENERATE THE EXCLUDE LIST + for ($i=0; $iMoveNext(); + } + + if ($list != '') $list = '!(\.+' . $list . ')'; + return $list; + } + + + + function create_php() + { + $data = ''; + return $data; + } +} +?> \ No newline at end of file diff --git a/modules/htaccess_dir/htaccess_dir_construct.xml b/modules/htaccess_dir/htaccess_dir_construct.xml new file mode 100644 index 00000000..1cdf9011 --- /dev/null +++ b/modules/htaccess_dir/htaccess_dir_construct.xml @@ -0,0 +1,114 @@ + + + + htaccess_dir + + htaccess_dir
+ + htaccess + + 0 + + id + + 25 + + + htaccess_id + status + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I4 + htaccess + name + any + 1 + + + C(128) + 3 + 128 + any + + + X + + + L + + + L + + + L + + + X + any + + + C(128) + 1 + 128 + any + + + C(128) + 1 + 128 + any + 1 + + + C(128) + 1 + 128 + + + C(128) + 1 + 128 + + + C(128) + 1 + 128 + + + C(128) + 1 + 128 + + + C(16) + 21 + 1 + 4 + + + X + array + + + + + id,site_id,name,description,htaccess,status,type,url,path,ftp_host,ftp_user,ftp_pass,ftp_path,ftp_port,htaccess_id,exclude,recursive + id,site_id,name,description,htaccess,status,type,url,path,ftp_host,ftp_user,ftp_pass,ftp_path,ftp_port,htaccess_id,exclude,recursive + id,site_id,name,description,htaccess,status,type,url,path,ftp_host,ftp_user,ftp_pass,ftp_path,ftp_port,htaccess_id,exclude,recursive + id,site_id,name,description,htaccess,status,type,url,path,ftp_host,ftp_user,ftp_pass,ftp_path,ftp_port,htaccess_id,exclude,recursive + id,site_id,name,description,htaccess,status,type,url,path,ftp_host,ftp_user,ftp_pass,ftp_path,ftp_port,htaccess_id,exclude,recursive + + + 0 +
diff --git a/modules/htaccess_dir/htaccess_dir_install.xml b/modules/htaccess_dir/htaccess_dir_install.xml new file mode 100644 index 00000000..4b4c9d26 --- /dev/null +++ b/modules/htaccess_dir/htaccess_dir_install.xml @@ -0,0 +1,33 @@ + + + htaccess_dir + htaccess + + 1 + + + + + search + + + view + + 1 + + + add + 1 + + + delete + + + update + + + search_show + + + + \ No newline at end of file diff --git a/modules/htaccess_exclude/htaccess_exclude.inc.php b/modules/htaccess_exclude/htaccess_exclude.inc.php new file mode 100644 index 00000000..68f276ad --- /dev/null +++ b/modules/htaccess_exclude/htaccess_exclude.inc.php @@ -0,0 +1,126 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class htaccess_exclude +{ + + # Open the constructor for this mod + function htaccess_exclude() + { + # name of this module: + $this->module = "htaccess_exclude"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/htaccess_exclude/htaccess_exclude_construct.xml b/modules/htaccess_exclude/htaccess_exclude_construct.xml new file mode 100644 index 00000000..2b722a9d --- /dev/null +++ b/modules/htaccess_exclude/htaccess_exclude_construct.xml @@ -0,0 +1,49 @@ + + + + htaccess_exclude + + htaccess_exclude
+ + htaccess + + 0 + + name + + 25 + + + + I4 + 1 + 1 + + + I4 + 1 + + + C(32) + 3 + 24 + any + + + C(16) + 2 + 4 + alphanumeric + + + + + id,site_id,name,extension + id,site_id,name,extension + id,site_id,name,extension + id,site_id,name,extension + id,site_id,name,extension + + + 0 +
diff --git a/modules/htaccess_exclude/htaccess_exclude_install.xml b/modules/htaccess_exclude/htaccess_exclude_install.xml new file mode 100644 index 00000000..44007e06 --- /dev/null +++ b/modules/htaccess_exclude/htaccess_exclude_install.xml @@ -0,0 +1,36 @@ + + + htaccess_exclude + htaccess + + 1 + + + + + search + + + view + + + 1 + + + add + + 1 + + + delete + + + update + + + search_show + + + + + \ No newline at end of file diff --git a/modules/htaccess_exclude/htaccess_exclude_install_data.xml b/modules/htaccess_exclude/htaccess_exclude_install_data.xml new file mode 100644 index 00000000..d1432102 --- /dev/null +++ b/modules/htaccess_exclude/htaccess_exclude_install_data.xml @@ -0,0 +1,153 @@ + + + + 1 + 1 + PHP + php + + + 2 + 1 + PHP3 + php3 + + + 3 + 1 + PHP4 + php4 + + + 4 + 1 + PHPS + phps + + + 5 + 1 + INC + inc + + + 6 + 1 + HTML + html + + + 7 + 1 + HTM + htm + + + 8 + 1 + JPG + jpg + + + 9 + 1 + JPEG + jpeg + + + 10 + 1 + GIF + gif + + + 11 + 1 + BMP + bmp + + + 12 + 1 + TIF + tif + + + 13 + 1 + JAVASCRIPT + js + + + 14 + 1 + CSS + css + + + 15 + 1 + PDF + pdf + + + 16 + 1 + MS WORD + doc + + + 17 + 1 + MS EXCEL + xls + + + 18 + 1 + CSV + csv + + + 19 + 1 + TEXT + txt + + + 20 + 1 + RICH TEXT + rtf + + + 21 + 1 + XML + xml + + + 22 + 1 + ZIP + zip + + + 23 + 1 + GZIP + gzip + + + 24 + 1 + TAR.GZ + gz + + + 30 + + + 1 + + \ No newline at end of file diff --git a/modules/import/import.inc.php b/modules/import/import.inc.php new file mode 100644 index 00000000..f0098a62 --- /dev/null +++ b/modules/import/import.inc.php @@ -0,0 +1,301 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class import +{ + + # Open the constructor for this mod + function import() + { + # name of this module: + $this->module = "import"; + + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + ### Store import id + function import_transaction($plugin, $action, $ab_table, $ab_id, $remote_table, $remote_id, &$db) + { + # Check that this record has not already been imported: + $sql = "SELECT id FROM ".AGILE_DB_PREFIX."import WHERE + plugin = ".$db->qstr($plugin)." AND + action = ".$db->qstr($action)." AND + ab_table = ".$db->qstr($ab_table)." AND + ab_id = ".$db->qstr($ab_id)." AND + remote_table= ".$db->qstr($remote_table). " AND + remote_id = ".$db->qstr($remote_id)." AND + site_id = ".DEFAULT_SITE; + $rs = $db->Execute($sql); + + # check results + if($rs === false || $rs->RecordCount() > 0) { + $db->FailTrans(); + return false; + } + + # Insert the record + $id = $db->GenID(AGILE_DB_PREFIX.'import_id'); + $sql = "INSERT INTO ".AGILE_DB_PREFIX."import SET + id = $id, + date_orig = ".time().", + plugin = ".$db->qstr($plugin).", + action = ".$db->qstr($action).", + ab_table = ".$db->qstr($ab_table).", + ab_id = ".$db->qstr($ab_id).", + remote_table= ".$db->qstr($remote_table). ", + remote_id = ".$db->qstr($remote_id).", + site_id = ".DEFAULT_SITE; + $rs = $db->Execute($sql); + return true; + } + + + ### Do an action for a specific plugin: + function do_action ($VAR) + { + # Load the plugin + if(!is_file($file = PATH_PLUGINS . 'import/'.@$VAR['plugin'].'.php')) + return false; + + + # New instance + include_once($file); + $import_plugin = new import_plugin; + + + # Call the required method + call_user_func (array($import_plugin, @$VAR['action']), $VAR, $import_plugin); + } + + + ### Do an action for a specific plugin: + function undo_action ($VAR) + { + $db = &DB(); + + # Make sure this action is done... + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."import WHERE + plugin = ".$db->qstr($VAR['plugin'])." AND + action = ".$db->qstr($VAR['action'])." AND + site_id = ".DEFAULT_SITE; + $rs = $db->Execute($sql); + if($rs->RecordCount() == 0) { + echo 'There is nothing to undo!'; + return; + } + + while(!$rs->EOF) + { + $table = $rs->fields['ab_table']; + $id = $rs->fields['ab_id']; + + $q = "DELETE FROM ".AGILE_DB_PREFIX."$table WHERE + id = $id AND + site_id = ".DEFAULT_SITE; + $db->Execute($q); + + $rs->MoveNext(); + } + + # delete the selected action: + $sql = "DELETE FROM ".AGILE_DB_PREFIX."import WHERE + plugin = ".$db->qstr($VAR['plugin'])." AND + action = ".$db->qstr($VAR['action'])." AND + site_id = ".DEFAULT_SITE; + $rs = $db->Execute($sql); + } + + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $db = &DB(); + + if(!is_file($file = PATH_PLUGINS . 'import/'.@$VAR['plugin'].'.php')) + return false; + + include_once($file); + $import_plugin = new import_plugin; + + # Loop through each action to determine its availibility status + $actions = $import_plugin->actions; + $done = false; + for($i=0; $iassign('name', $import_plugin->name); + $smarty->assign('instructions', $import_plugin->instructions); + $smarty->assign('import', $actions); + } + + + + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + ### Read the contents of the /plugins/affiliate directory: + $count = 0; + chdir(PATH_PLUGINS . 'import'); + $dir = opendir(PATH_PLUGINS . 'import'); + while ($file_name = readdir($dir)) { + if($file_name != '..' && $file_name != '.' && !eregi("^_", $file_name) && eregi(".php$", $file_name)) { + $count++; + } + } + + # define the DB vars as a Smarty accessible block + global $smarty; + + # create the search record: + if($count > 0) + { + # create the search record + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $arr['module'] = $this->module; + $arr['sql'] = ''; + $arr['limit'] = '999'; + $arr['order_by']= 'name'; + $arr['results'] = $count; + $search->add($arr); + + # define the search id and other parameters for Smarty + $smarty->assign('search_id', $search->id); + + # page: + $smarty->assign('page', '1'); + + # limit: + $smarty->assign('limit', '999'); + + # order_by: + $smarty->assign('order_by', 'name'); + + # define the result count + $smarty->assign('results', $count); + } + } + + + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + ### Read the contents of the /plugins/db_mapping directory: + $count = 0; + chdir(PATH_PLUGINS . 'import'); + $dir = opendir(PATH_PLUGINS . 'import'); + while ($file_name = readdir($dir)) { + if($file_name != '..' && $file_name != '.' && !eregi("^_", $file_name) && eregi(".php$", $file_name) ) { + $result[$count]['name'] = eregi_replace('.php', '', $file_name); + $result[$count]['id'] = $count; + $count++; + } + } + + $class_name = TRUE; + for ($i=0; $iassign($this->table, $smart); + $smarty->assign('page', $VAR['page']); + $smarty->assign('order', $smarty_order); + $smarty->assign('sort', $smarty_sort); + $smarty->assign('limit', $search->limit); + $smarty->assign('search_id',$search->id); + $smarty->assign('results', $count); + + # total pages + $smarty->assign('pages', 1); + + # current page + $smarty->assign('page', 1); + $page_arr = ''; + + # page array for menu + $smarty->assign('page_arr', $page_arr); + } +} +?> \ No newline at end of file diff --git a/modules/import/import_construct.xml b/modules/import/import_construct.xml new file mode 100644 index 00000000..2717b772 --- /dev/null +++ b/modules/import/import_construct.xml @@ -0,0 +1,65 @@ + + + + + import + + + import
+ + + + + + 0 + + + plugin + + + 35 + + + + + I8 + 1 + + + I4 + + + I8 + + + C(32) + + + C(32) + + + C(32) + + + C(32) + + + I8 + + + I8 + + + + + + id,site_id,date_orig,plugin,local_table,ab_table,remote_id,ab_id + id,site_id,date_orig,plugin,local_table,ab_table,remote_id,ab_id + id,site_id,date_orig,plugin,local_table,ab_table,remote_id,ab_id + id,site_id,date_orig,plugin,local_table,ab_table,remote_id,ab_id + id,site_id,date_orig,plugin,local_table,ab_table,remote_id,ab_id + + + + 0 +
\ No newline at end of file diff --git a/modules/import/import_install.xml b/modules/import/import_install.xml new file mode 100644 index 00000000..f794caf4 --- /dev/null +++ b/modules/import/import_install.xml @@ -0,0 +1,43 @@ + + + + + + import + setup + + 1 + + + + + + + + + + do_action + + + + undo_action + + + + + view + core:search&module=%%&_escape=1 + + + + search + core:search&module=%%&_escape=1 + 1 + + + search_show + + + + + \ No newline at end of file diff --git a/modules/invoice/advance_notice.php b/modules/invoice/advance_notice.php new file mode 100644 index 00000000..6f8bf760 --- /dev/null +++ b/modules/invoice/advance_notice.php @@ -0,0 +1,109 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** +* Advance invoice e-mail notification class +*/ +class advance_notice +{ + var $advance_days=false; + var $advance_days_service; + + function task() { + + $db=&DB(); + + /* get the max invoice days from the setup_invoice table */ + if(!$this->advance_days) { + $setup = $db->Execute(sqlSelect($db,"setup_invoice","advance_notice","advance_notice>0 and advance_notice != '' and advance_notice is not null")); + if(!$setup && !$setup->RecordCount()) return false; + $this->advance_days = $setup->fields['advance_notice']; + } + + /* pre-billing days global setting */ + if(MAX_INV_GEN_PERIOD <= 0) $max_days = $max_date=1; else $max_days = MAX_INV_GEN_PERIOD; + + /* pre-notification date for service */ + $this->advance_days_service = $this->advance_days + $max_days; + $max_date = time()+($this->advance_days_service*86400); + date("Y-m-d", $max_date); + + $p=AGILE_DB_PREFIX; $s=DEFAULT_SITE; + $ids=false; + $account=false; + $date=false; + $invoice=false; + $sql = "SELECT DISTINCT service.id as serviceId, account.id as accountId, invoice.id as invoiceId, from_unixtime(service.date_next_invoice,'%Y-%m-%d') as dayGroup + FROM {$p}service as service + JOIN {$p}account as account ON ( service.account_id=account.id and account.site_id={$s} ) + LEFT JOIN {$p}invoice as invoice ON ( service.invoice_id=invoice.id and invoice.site_id={$s} ) + WHERE service.site_id={$s} + AND service.active = 1 + AND ( service.invoice_advance_notified IS NULL OR service.invoice_advance_notified = 0 ) + AND ( service.suspend_billing IS NULL OR service.suspend_billing = 0 ) + AND ( service.date_next_invoice > 0 AND service.date_next_invoice IS NOT NULL ) + AND + (( + ( account.invoice_advance_gen!='' OR account.invoice_advance_gen is not null ) AND service.date_next_invoice <= ((86400*(account.invoice_advance_gen+{$this->advance_days})) + (UNIX_TIMESTAMP(CURDATE()))) + ) OR ( + ( account.invoice_advance_gen='' OR account.invoice_advance_gen is null ) AND service.date_next_invoice <= {$max_date} + )) + ORDER BY accountId, dayGroup, serviceId"; + $rs = $db->Execute($sql); + if($rs === false) {global $C_debug; $C_debug->error('advance_notice.inc.php','task()', $sql . " \r\n\r\n " . @$db->ErrorMsg()); } + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + if( $ids && ($rs->fields['accountId'] != $account ) || ($rs->fields['dayGroup'] != $date) ) { + $this->sendEmail($ids, $account, $date); + $ids=false; + } + + // set the current account and date + $account=$rs->fields['accountId']; + $invoice=$rs->fields['invoiceId']; + $date=$rs->fields['dayGroup']; + + // add to id list + if($ids) $ids.=","; + $ids.=$rs->fields['serviceId']; + $rs->MoveNext(); + } + if($ids) $this->sendEmail($ids, $account, $date); + } + } + + + /* send e-mail to user with pre-billing notice */ + function sendEmail($ids, $account, $date) { + if (empty($account)) return; + + //echo "
$account - $ids - $date"; + + /* send e-mail to user */ + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + $mail = new email_template; + $mail->send('invoice_pregen_notice', $account, $ids, DEFAULT_CURRENCY, $date); + + /* update service.invoice_advance_notified=1 to stop future notifications */ + $db=&DB(); + $db->Execute("UPDATE ".AGILE_DB_PREFIX."service SET invoice_advance_notified=1 WHERE site_id=".DEFAULT_SITE." AND id in ($ids)"); + } +} +?> \ No newline at end of file diff --git a/modules/invoice/auth.inc.php b/modules/invoice/auth.inc.php new file mode 100644 index 00000000..59fea1f5 --- /dev/null +++ b/modules/invoice/auth.inc.php @@ -0,0 +1,13 @@ + 'invoice', 'method' => 'user_search'), +Array ('module' => 'invoice', 'method' => 'user_search_show'), +Array ('module' => 'invoice', 'method' => 'user_view'), +Array ('module' => 'invoice', 'method' => 'pdf'), +Array ('module' => 'invoice', 'method' => 'checkoutnow'), +Array ('module' => 'invoice', 'method' => 'checkout_multiple_preview'), +Array ('module' => 'invoice', 'method' => 'custom_tracking'), +Array ('module' => 'invoice', 'method' => 'has_unpaid'), +); +?> \ No newline at end of file diff --git a/modules/invoice/invoice.inc.php b/modules/invoice/invoice.inc.php new file mode 100644 index 00000000..c51a87c9 --- /dev/null +++ b/modules/invoice/invoice.inc.php @@ -0,0 +1,4376 @@ + + * @package AgileBill + * @version 1.4.93 + */ + + +/** + * The main AgileBill Invoice Class + */ +class invoice +{ + /** Enable summary invoice view that rolls multiple instances of the same sku w/identical base&setup price & attributes into one line item */ + var $summarizeInvoice=true; + + /** + * Holds sku's of line items to exclude from invoice summarys (pdf view only) + * + * @var array + */ + var $summarizeInvoiceExclude; + + /** Invoice type, 0=new, 1=recurr */ + var $type=0; + + /** Invoice Creation Timestamp */ + var $date_orig; + + /** Last modification Timestamp */ + var $date_last; + + /** Invoice Id */ + var $record_id; + + /** Invoice Item Id */ + var $item_id=1; + + /** Parent Invoice Id for recurring */ + var $parent_id; + + /** Account Id for invoice */ + var $account_id; + + /** Affiliate Id of Invoice */ + var $affiliate_id; + + /** Account Billing Id */ + var $account_billing_id; + + /** Campaign Id */ + var $campaign_id; + + /** Reseller Id */ + var $reseller_id; + + /** Billed Currency Id */ + var $billed_currency_id; + + /** Actual Billed Currency selected by Client */ + var $actual_billed_currency_id; + + /** Checkout Plugin Id */ + var $checkout_plugin_id; + + /** Array of checkout plugin data returned by checkout plugin */ + var $checkout_plugin_data; + + /** Current Notice Count */ + var $notice_count=0; + + /** Last Notice Timestamp */ + var $notice_date; + + /** Due Date Timestamp */ + var $due_date; + + /** Net Term Id */ + var $net_term_id=false; + + /** Net Term Last Notice/Late fee Timestamp */ + var $net_term_date_last; + + /** Net Term Interval Count */ + var $net_term_intervals=0; + + /** Process Status */ + var $process_status=0; + + /** Billing Status */ + var $billing_status=0; + + /** Suspend Billing Status */ + var $suspend_billing=0; + + /** Printed Invoice Status */ + var $print_status=0; + + /** Refunded Invoice Status */ + var $refund_status=0; + + /** Calcuate Taxes */ + var $tax=true; + + /** Calculate Discounts */ + var $discount=true; + + /** Total Invoice Amount */ + var $total_amt=0; + + /** Total Amount Billed */ + var $billed_amt=0; + + /** Actual total amount billed (converted to local) */ + var $actual_billed_amt=0; + + /** Total Tax Amount */ + var $tax_amt=0; + + /** Total Discount Amount */ + var $discount_amt=0; + + /** Recurring Amount */ + var $recur_amt; + + /** Recurring Array for Later Processing */ + var $recur_arr; + + /** IP Address of User */ + var $ip=USER_IP; + + /** Array of the Invoice items */ + var $invoice_item; + + /** Array of the discounts for the Invoice items */ + var $item_discount; + + /** Array of the taxes for the Invoice Items */ + var $item_tax; + + /** Tracking to determine payment options */ + var $any_new=false; + var $any_trial=false; + var $any_recurring=false; + + /** Invoice Config Global Options */ + var $invoice_delivery=1; + var $invoice_format=0; + var $notice_max=MAX_BILLING_NOTICE; + var $grace_period=GRACE_PERIOD; + + + + /** + * Get the global level invoice settings + */ + function setupGlobal() { + $db=&DB(); + $invopt=$db->Execute(sqlSelect($db,"setup_invoice","*","")); + if($invopt && $invopt->RecordCount()) { + $this->invoice_delivery=$invopt->fields['invoice_delivery']; + $this->invoice_format=$invopt->fields['invoice_show_itemized']; + } + } + + /** + * Get the account level invoice options + * + * @param int $id Account Id + */ + function setupAccount() { + if(!$this->account_id) return; + $db=&DB(); + $acctrs=$db->Execute(sqlSelect($db,"account","invoice_grace,invoice_advance_gen","id=$this->account_id")); + if($acctrs && $acctrs->RecordCount()) { + $this->advance_gen=$acctrs->fields['invoice_advance_gen']; + if($this->grace_period == GRACE_PERIOD && !empty($acctrs->fields['invoice_grace'])) $this->grace_period=$acctrs->fields['invoice_grace']; + } + } + + /** + * Initialize new invoice creation + * + * @param bool $type 0=new 1=recur + */ + function initNew($type=0) { + $this->type=$type; + $this->date_orig=time(); + $this->date_last=time(); + + global $C_list; + $this->net_term = $C_list->is_installed('net_term'); + + // get account invoice defaults + $this->setupAccount(); + } + + /** + * Commit the current invoice/items/discounts/taxes + * + * @param object $taxObj Object for Tax Calculation + * @param object $discountObj Object for Discount Calculation + * @param bool $email Send customer/admin e-mails + */ + function commitNew(&$taxObj, &$discountObj, $email=true) { + + // init DB transaction + $db=&DB(); + $db->BeginTrans(); + + // get invoice id + if(empty($this->record_id)) $this->record_id = sqlGenID($db,"invoice"); + + // serialized records: + if(is_array($this->checkout_plugin_data)) $this->checkout_plugin_data=serialize($this->checkout_plugin_data); + if(is_array($this->recur_arr)) $this->recur_arr=serialize($this->recur_arr); + + // dates & defaults + if(empty($this->due_date)) $this->due_date=time(); + if(empty($this->date_orig)) $this->date_orig=time(); + if(empty($this->date_last)) $this->date_last=time(); + if(empty($this->notice_next_date)) $this->notice_next_date=$this->due_date+86400; + + // net terms + if ($this->net_term && !$this->billing_status && $this->total_amt>0) { + include_once(PATH_MODULES.'net_term/net_term.inc.php'); + $net=new net_term; + $this->net_term_id = $net->termsAllowed($this->account_id, $this->checkout_plugin_id); + if(empty($this->net_term_date_last)) $this->net_term_date_last=time(); + } + + // insert invoice + $fields=Array( + 'date_orig'=>$this->date_orig, + 'date_last'=>$this->date_last, + 'parent_id'=>$this->parent_id, + 'type'=>$this->type, + 'process_status'=>$this->process_status, + 'billing_status'=>$this->billing_status, + 'suspend_billing'=>$this->suspend_billing, + 'refund_status'=>$this->refund_status, + 'print_status'=>$this->print_status, + 'account_id'=>$this->account_id, + 'account_billing_id'=>$this->account_billing_id, + 'affiliate_id'=>$this->affiliate_id, + 'campaign_id'=>$this->campaign_id, + 'reseller_id'=>$this->reseller_id, + 'checkout_plugin_id'=>$this->checkout_plugin_id, + 'checkout_plugin_data'=>$this->checkout_plugin_data, + 'tax_amt'=>$this->tax_amt, + 'discount_amt'=>$this->discount_amt, + 'total_amt'=>$this->total_amt, + 'billed_amt'=>$this->billed_amt, + 'recur_amt'=>$this->recur_amt, + 'recur_arr'=>$this->recur_arr, + 'actual_billed_amt'=>$this->actual_billed_amt, + 'billed_currency_id'=>$this->billed_currency_id, + 'actual_billed_currency_id'=>$this->actual_billed_currency_id, + 'notice_count'=>$this->notice_count, + 'notice_max'=>$this->notice_max, + 'notice_next_date'=>$this->notice_next_date, + 'due_date'=>$this->due_date, + 'grace_period'=>$this->grace_period, + 'net_term_id'=>$this->net_term_id, + 'net_term_date_last'=>$this->net_term_date_last, + 'net_term_intervals'=>$this->net_term_intervals, + 'ip'=>$this->ip + ); + $db->Execute($sql=sqlInsert($db, "invoice", $fields, $this->record_id)); + + // loop through invoice items + if(is_array($this->invoice_item)) { + foreach($this->invoice_item as $id=>$fields) { + // get an invoice_item id + $invoice_item_id = sqlGenID($db, "invoice_item"); + + // domain sku's + if ($fields['item_type'] == 2) { + $fields['sku'] = "DOMAIN-".strtoupper($fields['domain_type']); + $fields['price_type'] = '0'; + } + + // build e-mail item details + if($email) { + $email_instructions=''; + if($fields['item_type']<2 && !empty($fields['product_id'])) { + // product, get email instructions and translated name + $translate_prod=$db->Execute(sqlSelect($db,"product_translate","email_template,name","product_id={$fields['product_id']} and language_id=::".SESS_LANGUAGE."::")); + if($translate_prod && $translate_prod->RecordCount()) { + $instructions=$translate_prod->fields['email_template']; + $name=$translate_prod->fields['name']; + } else { + $name=$fields["sku"]; + } + } elseif ($fields['item_type'] == 2) { + $name=strtoupper($fields['domain_name'].".".$fields['domain_tld']); + } else { + if(!empty($fields['product_name'])) $name=$fields['product_name']; else $name=$fields['sku']; + } + // add to e-mail array + $email_arr[] = array('Qty' => '('.$fields["quantity"].')', 'Item' => 'SKU '.$fields["sku"], 'Price' => number_format($fields["total_amt"],2), 'Name' => $name, 'Instructions' => $instructions); + } + + // insert the invoice item_id + $fields['invoice_id']=$this->record_id; + $fields['date_orig']=time(); + $attr = serialize($fields['product_attr']); + $fields['product_attr']=$fields['product_attr_cart']; + $fields['product_attr_cart']=$attr; + $db->Execute($sql=sqlInsert($db, "invoice_item", $fields, $invoice_item_id)); + + // insert taxes + if($this->tax && $this->tax_amt > 0 && !empty($this->tax_arr[$id])) { + $taxObj->invoice_item($this->record_id, $invoice_item_id, $this->account_id, $this->tax_arr[$id]); + } + + // insert discounts + if($this->discount && $this->discount_amt>0 && !empty($this->discount_arr[$id])) { + $discountObj->invoice_item($this->record_id, $invoice_item_id, $this->account_id, $this->discount_arr[$id]); + } + } + } + + // complete DB transaction + $db->CompleteTrans(); + + // complete building e-mail notices and send + if($email) { + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + + // Create the products order list for the e-mail: + $e_itm_usr = ''; + $e_itm_adm = ''; + if(is_array($email_arr)) { + foreach($email_arr as $i=>$em) { + $e_itm_usr .= $em['Qty'].' '.$em['Item'].' ('.$em['Name'].') '.$em['Price']; + $e_itm_adm .= $em['Qty'].' '.$em['Item'].' ('.$em['Name'].') '.$em['Price']."\r\n"; + if(!empty($email_arr[$i]['Instructions'])) $e_itm_usr .= "\r\n * " . $email_item_arr[$i]['Instructions']; + $e_itm_usr .= "\r\n"; + } + $e_arr_user = Array('%products%' => $e_itm_usr); + $e_arr_adm = Array('%products%' => $e_itm_adm); + } + + // e-mail invoice creation confirmation + $mail = new email_template; + $mail->send('invoice_confirm_user', $this->account_id, $this->record_id, $this->checkout_plugin_id, $e_arr_user); + $email = new email_template; + $email->send('admin->invoice_confirm_admin', $this->account_id, $this->record_id, $this->checkout_plugin_id, $e_arr_adm); + } + + // net terms? + if($this->net_term_id) { + $this->approveInvoice(array('id'=>$this->record_id), $this); + return $this->record_id; + } + + // Determine the approval status by checkout plugin type & settings: + if($email && $this->billing_status == 0 && $this->billed_amt > 0 ) { + global $C_list; + if($this->checkout_type == 'redirect') { + // User e-mail alert of due invoice + $email = new email_template; + $email->send('invoice_due_user', $this->account_id, $this->record_id, $user_currency, $C_list->date($this->due_date)); + } elseif ($this->checkout_type == 'other') { + // Admin e-mail alert of manual payment processing + $email = new email_template; + $email->send('admin->invoice_due_admin', $this->account_id, $this->record_id, $admin_currency, $C_list->date($this->due_date)); + } + } elseif($this->billed_amt>0 ) { + if($email) { + // User alert of payment processed + $email = new email_template; + $email->send('invoice_paid_user', $this->account_id, $this->record_id, $this->billed_currency_id, ''); + // Admin alert of payment processed + $email = new email_template; + $email->send('admin->invoice_paid_admin', $this->account_id, $this->record_id, $this->billed_currency_id, ''); + } + $this->autoApproveInvoice($this->record_id); + } elseif($this->billed_amt == 0 && $this->billing_status == 1 ) { + $this->autoApproveInvoice($this->record_id); + } + + // return invoice id + return $this->record_id; + } + + /** + * Add an invoice item + * + * @param int $id Reference ID for use in Cart or false + * @param object $taxObj Object for Tax Calculation + * @param object $discountObj Object for Discount Calculation + * @param int $item_type 0/1=Product/Service/Hosting 2=Domain 3=Add Hoc + * @param string $taxable True, False, or 'validate' to locate the specified $product id and verify + * @param int $service_id If this is for a service upgrade, this will be defined + * @param int $parent_id Item Parent Id + * @param int $product_id Item Product Id + * @param array $product_attr Item attributes from the cart/prev service + * @param string $product_name Item product name + * @param string $sku Item Product SKU + * @param int $quantity Item Quantity + * @param float $price_base Item Base price + * @param float $price_setup Item Setup Price + * @param float $discount_manual Ad Hoc Discount Amount + * @param int $recurring_schedule Item recurring schedule, 0=week, 1=month, 2=quarter, 3=semi-annual, 4=annual, 5=bi-year + * @param int $date_start Date service started + * @param int $date_stop Date service stops + * @param string $domain_name Domain name + * @param string $domain_tld Domain TLD + * @param int $domain_term Domain Term + * @param string $domain_type Domain Type (register, transfer, renew, park, ns_transfer) + */ + function addItem($id, &$taxObj, &$discountObj, $item_type, $taxable=false, $service_id=false, $parent_id=false, $product_id=false, $product_attr=false, $product_name=false, $sku=false, $quantity=1, $price_base=false, $price_setup=false, $discount_manual=false, $recurring_schedule=false, $date_start=false, $date_stop=false, $domain_name=false, $domain_tld=false, $domain_term=false, $domain_type=false) { + $tax_amt=0; + $total_amt=0; + $discount_amt=0; + + // define correct qty + if($quantity<=0) $quantity=1; + + // determine the reference id for this item + if($id>0) { + $this->item_id=$id; + } else { + $this->item_id++; + } + + // get the product details + if($product_id && $item_type<2) { + $db=&DB(); + $product=$db->Execute(sqlSelect($db,"product","*","id=$product_id")); + if($product && $product->RecordCount()) { + $taxable = $product->fields['taxable']; + $this->product["$this->item_id"] = $product->fields; + } + + // get the tld details + } elseif($item_type==2) { + $db=&DB(); + $tld=$db->Execute(sqlSelect($db,"host_tld","*","name=::$domain_tld::")); + if($tld && $tld->RecordCount()) + $taxable = $tld->fields['taxable']; + } + + // get the product pricing details if product + $price_type=0; + if($price_base===false && $price_setup===false && $product_id && $item_type<2) { + if($product && $product->RecordCount()) { + $price_type=$product->fields['price_type']; + $sku=$product->fields['sku']; + include_once(PATH_MODULES.'product/product.inc.php'); + $productObj=new product; + + // get pricing for this product: + $prod_price = $productObj->price_prod($product->fields, $recurring_schedule, $this->account_id); + $price_base = $prod_price["base"]; + $price_setup = $prod_price["setup"]; + + // calculate any product attributes fees + $attr_price = $productObj->price_attr($product->fields, $product_attr, $recurring_schedule, $this->account_id); + $price_base += $attr_price["base"]; + $price_setup += $attr_price["setup"]; + + // determine price type for checkout + if ($product->fields["price_type"] == '0') + $this->any_new=true; + else if ($product->fields["price_type"] == '1') + $this->any_recurring=true; + else if ($product->fields["price_type"] == '2') + $this->any_trial=true; + + } else { + $this->any_new=true; + } + } else { + $this->any_new=true; + } + + // get the TLD pricing details if domain + if($price_base===false && $price_setup===false && $domain_tld && $domain_term && $domain_type) { + include_once(PATH_MODULES.'host_tld/host_tld.inc.php'); + $tldObj = new host_tld; + $tldprice = $tldObj->price_tld_arr($domain_tld, $domain_type, false, false, false, $this->account_id); + if($domain_type == "park") { + $price_base = $tldprice; + } else { + $price_base = $tldprice["$domain_term"]; + $this->tld_arr["$this->item_id"] = $tldprice; + } + } + + // set total amount for this line item before attributes, taxes, or discounts + $price_base *= $quantity; + $price_setup *= $quantity; + $total_amt = ($price_setup + $price_base); + + // format product attributes for storage + $product_attr_cart=false; + if(($item_type==0 || $item_type>2) && is_array($product_attr)) $product_attr_cart = $this->get_product_attr_cart($product_attr); + + // recurring taxes and arrays + if($price_base>0 && $price_type==1) + { + // increment the total invoice recurring amount + $this->recur_amt += $price_base; + + // determine taxes for the recurring amount + if($this->tax && $taxable && $price_base>0 && $this->account_id) { + $recur_tax_arr = $taxObj->calculate($price_base, $this->country_id, $this->state); + if(is_array($recur_tax_arr)) foreach($recur_tax_arr as $tx) $this->recur_amt += $tx['rate']; + } + + // get the recurring arrays for price and invoice + if($product && $product->RecordCount()) { + $this->price_arr["$this->item_id"] = $productObj->price_recurr_arr($product->fields, $this->account_id); + $this->recur_arr[] = Array ( + 'price' => $price_base*$quantity, + 'recurr_schedule'=> $recurring_schedule, + 'recurr_type' => $product->fields['price_recurr_type'], + 'recurr_weekday' => $product->fields['price_recurr_weekday'], + 'recurr_week' => $product->fields['price_recurr_week'] + ); + } + } + + // calculate any ad-hoc line item level (admin) discounts + if($this->discount && $discount_manual>0) { + $total_amt -= $discount_manual; + $discount_amt += $discount_manual; + $this->discount_amt += $discount_amt; + $discountObj->add_manual_discount($discount_manual,'MISC',$this->item_id); + } + + // account level discounts + if($this->discount && $this->account_id) { + // calculate any database level discounts for this item (both account specific and session specific) + $discount_amt = $discountObj->calc_all_discounts(0, $this->item_id, $product_id, $total_amt, $this->account_id, $this->total_amt+$total_amt); + $total_amt -= $discount_amt; + $this->discount_amt += $discount_amt; + } + + // add to total discount array + if(is_array($discountObj->discount_arr)) { + $this->discount_arr["$this->item_id"] = $discountObj->discount_arr; + } + + // increment invoice total amount + $this->total_amt += $total_amt; + + // calculate any taxes for current item + if($this->tax && $taxable && $total_amt>0 && $this->account_id) { + $tax_arr = $taxObj->calculate($total_amt, $this->country_id, $this->state); + if(is_array($tax_arr)) { + foreach($tax_arr as $tx) $tax_amt += $tx['rate']; + $this->item_tax["$this->item_id"] = $tax_arr; + $this->tax_arr["$this->item_id"] = $tax_arr; + } + $this->tax_amt += $tax_amt; + $this->total_amt += $tax_amt; + } + + // store the fields to an array + $this->invoice_item["$this->item_id"]=Array( + 'item_type'=>$item_type, + 'price_type'=>$price_type, + 'taxable'=>$taxable, + 'service_id'=>$service_id, + 'parent_id'=>$parent_id, + 'product_id'=>$product_id, + 'product_attr'=>$product_attr, + 'product_attr_cart'=>$product_attr_cart, + 'product_name'=>$product_name, + 'sku'=>$sku, + 'quantity'=>$quantity, + 'price_base'=>$price_base, + 'price_setup'=>$price_setup, + 'recurring_schedule'=>$recurring_schedule, + 'date_start'=>$date_start, + 'date_stop'=>$date_stop, + 'domain_name'=>$domain_name, + 'domain_tld'=>$domain_tld, + 'domain_term'=>$domain_term, + 'domain_type'=>$domain_type, + 'total_amt'=>$total_amt, + 'tax_amt'=>$tax_amt, + 'discount_amt'=>$discount_amt + ); + } + + /** + * Group all taxes to lump sums + */ + function group_taxes() { + if(is_array($this->tax_arr)) { + foreach($this->tax_arr as $taxarr) foreach($taxarr as $taxes) $arr[$taxes["name"]]+=$taxes["rate"]; + if(is_array($arr)) { + foreach($arr as $a=>$b) $ret[] = Array('name'=>$a, 'rate'=>$b); + return $ret; + } + } + } + + /** + * Group all discounts to lump sums + */ + function group_discounts() { + if(is_array($this->discount_arr)) { + foreach($this->discount_arr as $discarr) foreach($discarr as $discounts) $arr[$discounts["discount"]]+=$discounts["amount"]; + if(is_array($arr)) { + foreach($arr as $a=>$b) $ret[] = Array('name'=>$a, 'total'=>$b); + return $ret; + } + } + } + + /** + * Build a formatted product attribute list + * + * @param array $attributes + * @return string Formatted product attribute list + */ + function get_product_attr_cart($attributes) { + # Set the attribute array: + if(!empty($attributes) && is_array($attributes)) { + $db=&DB(); + $product_attr = false; + foreach($attributes as $id=>$value) { + if (!empty($value)) { + if(is_numeric($id)) { + $attr = $db->Execute(sqlSelect($db,"product_attr","name","id=$id")); + if ($attr && $attr->RecordCount()) $product_attr .= "{$attr->fields['name']}==".ereg_replace("\r\n", "
", $value)."\r\n"; + } else { + $product_attr .= "{$id}=={$value}\r\n"; + } + } + } + } + return $product_attr; + } + + + + /** Custom Tracking + */ + function custom_tracking($VAR) + { + # Get the invoice id + if(SESS_LOGGED == false) + return false; + + # Check if we are in the iframe + if(empty($VAR['_escape']) || empty($VAR['confirm'])) + { + echo ''; + return; + } + + # Get the un-tracked invoice details + $db = &DB(); + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."invoice WHERE + ( custom_affiliate_status IS NULL OR + custom_affiliate_status = 0 ) + AND billing_status = ".$db->qstr(1)." + AND site_id = ".$db->qstr(DEFAULT_SITE)." + AND account_id = ".$db->qstr(SESS_ACCOUNT); + $result = $db->Execute($sql); + if ($result === false) { + global $C_debug; + $C_debug->error('','', $db->ErrorMsg(). "\r\n\r\n". $sql); + return false; + } + if($result->RecordCount() == 0) { + echo 'none'; + return false; + } + + # Get the totals + $invoice = ''; + $total_amount = false; + while(!$result->EOF) + { + if(!empty($invoice)) + $invoice .= '-'; + $invoice .= $result->fields['id']; + $amt = $result->fields["total_amt"]; + $total_amount += $amt; + $result->MoveNext(); + } + + # echo the custom tracking code to the screen: + if(!is_file(PATH_FILES.'tracking.txt')) return false; + require_once('includes/pear/Compat/Function/file_get_contents.php'); + $tracking = file_get_contents(PATH_FILES.'tracking.txt'); + $tracking = ereg_replace('%%amount%%', "$total_amount", $tracking); + $tracking = ereg_replace('%%invoice%%', $invoice, $tracking); + $tracking = ereg_replace('%%affiliate%%', SESS_AFFILIATE, $tracking); + $tracking = ereg_replace('%%campaign%%', SESS_CAMPAIGN, $tracking); + $tracking = ereg_replace('%%account%%', SESS_ACCOUNT, $tracking); + echo $tracking; + + # Update the record so it is not tracked again + $sql = "UPDATE ".AGILE_DB_PREFIX."invoice + SET + custom_affiliate_status = ".$db->qstr('1')." + WHERE + account_id = ".$db->qstr(SESS_ACCOUNT)." + AND + billing_status = ".$db->qstr(1)." + AND + site_id = ".$db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + if ($rs === false) { + global $C_debug; + $C_debug->error('','', $db->ErrorMsg(). "\r\n\r\n". $sql); + } + return true; + } + + + + + /** Performance: (for the admin dashboard) + */ + function performance($VAR) + { + global $smarty, $C_list, $C_translate; + + + # Get the period type, default to month + if (empty($VAR['period'])) + $p = 'm'; + else + $p = $VAR['period']; + + # Determine the correct period language: + if($p=='' or $p == 'm') + { + $pTrans = $C_translate->translate('thismonth','invoice','') . ' '. + $C_translate->translate('vs','invoice','') . ' ' . + $C_translate->translate('lastmonth','invoice',''); + $pFore = $C_translate->translate('thismonth','invoice',''); + } + elseif ($p == 'w') + { + $pTrans = $C_translate->translate('thisweek','invoice','') . ' '. + $C_translate->translate('vs','invoice','') . ' ' . + $C_translate->translate('lastweek','invoice',''); + $pFore = $C_translate->translate('thisweek','invoice',''); + } + elseif ($p == 'y') + { + $pTrans = $C_translate->translate('thisyear','invoice','') . ' '. + $C_translate->translate('vs','invoice','') . ' ' . + $C_translate->translate('lastyear','invoice',''); + $pFore = $C_translate->translate('thisyear','invoice',''); + } + + $smarty->assign('period_compare', $pTrans); + $smarty->assign('period_forcast', $pFore); + + + + # Get the period start & end + switch ($p) { + case 'w': + $dow = date('w'); + $this_start = mktime(0,0,0,date('m'), date('d')-$dow, date('y')); + $this_end = mktime(23,59,59,date('m'), date('d'), date('y')); + $last_start = mktime(0,0,0,date('m'), date('d', $this_start)-7, date('y')); + $last_end = $this_start-1; + break; + + case 'm': + $this_start = mktime(0,0,0,date('m'), 1, date('y')); + $this_end = mktime(23,59,59,date('m'), date('d'), date('y')); + $last_start = mktime(0,0,0, date('m', $this_start)-1, 1, date('y')); + $last_end = $this_start-1; + break; + + case 'y': + $this_start = mktime(0,0,0,1,1, date('y', time())); + $this_end = mktime(23,59,59, date('m'), date('d'), date('y')); + $last_start = mktime(0,0,0,1,1, date('y', $this_start)-1); + $last_end = $this_start-1; + break; + } + + ############################## + # Get sales for this period + ############################## + $db = &DB(); + $this_amt = 0; + $sql = 'SELECT total_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE + date_orig >= ' . $db->qstr( $this_start ) . ' AND + date_orig <= ' . $db->qstr( $this_end ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + while( !$rs->EOF ) { + $this_amt += $rs->fields['total_amt']; + $rs->MoveNext(); + } + $smarty->assign('sales_current', $this_amt); + + ############################### + # Get sales for last period + ############################### + $last_amt = 0; + $sql = 'SELECT total_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE + date_orig >= ' . $db->qstr( $last_start ) . ' AND + date_orig <= ' . $db->qstr( $last_end ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + while( !$rs->EOF ) { + $last_amt += $rs->fields['total_amt']; + $rs->MoveNext(); + } + $smarty->assign('sales_previous', $last_amt); + + ############################### + # Get sales change percentage + ############################### + if($last_amt > 0) + $sales_change = $this_amt/$last_amt *100 -100; + else + $sales_change = 0; + + if($sales_change == 0) + $sales_change = ''; + elseif($sales_change < 0) + $sales_change = '' . number_format($sales_change, 1). '%'; + else + $sales_change = '+'.number_format($sales_change, 1). '%'; + + + $smarty->assign('sales_change', $sales_change); + + ################################# + # Get forcast for current period + ################################# + switch ($p) { + case 'w': + $dow = date('w')+1; + $forcast_daily = $this_amt/$dow ; + $forcast_l_daily = $last_amt / 7; + @$forcast_change = $forcast_daily / $forcast_1_daily *100 -100; + $forcast_current = $forcast_daily * 7; + break; + + case 'm': + $forcast_daily = $this_amt / date('d'); + $forcast_1_daily = $last_amt / date('t', mktime(0,0,0,date('m')-1, 1, date('y'))); + @$forcast_change = $forcast_daily / $forcast_1_daily *100 -100; + $forcast_current = $forcast_daily * date('t'); + break; + + case 'y': + $forcast_daily = $this_amt / date('z'); + $forcast_1_daily = $last_amt / 356; + @$forcast_change = $forcast_daily / $forcast_1_daily *100 -100; + $forcast_current = $forcast_daily * 365; + break; + } + + $smarty->assign('forcast_current', $forcast_current); + + ############################### + # Get forcast change percentage + ############################### + if($last_amt > 0 ) + @$forcast_change = $forcast_daily/$forcast_1_daily *100; + else + $forcast_change = 0; + + + if($forcast_change == 0) + $forcast_change = '-'; + elseif($forcast_change < 0) + $forcast_change = '' . number_format($forcast_change, 1). '%'; + else + $forcast_change = '+'.number_format($forcast_change, 1). '%'; + + + $smarty->assign('forcast_change', $forcast_change); + + + #################################################### + # Get Quota for Today to meet Forcasted sales: + #################################################### + $smarty->assign('quota_current', $forcast_daily); + + ############################## + # Get AR credits for this period + ############################## + $this_billed_amt = 0; + $sql = 'SELECT billed_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE + date_orig >= ' . $db->qstr( $this_start ) . ' AND + date_orig <= ' . $db->qstr( $this_end ) . ' AND + billed_amt > ' . $db->qstr( 0 ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + while( !$rs->EOF ) { + $this_billed_amt += $rs->fields['billed_amt']; + $rs->MoveNext(); + } + $smarty->assign('ar_credits_current', $this_billed_amt); + + ############################### + # Get AR credits for last period + ############################### + $last_billed_amt = 0; + $sql = 'SELECT billed_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE + date_orig >= ' . $db->qstr( $last_start ) . ' AND + date_orig <= ' . $db->qstr( $last_end ) . ' AND + billed_amt > ' . $db->qstr( 0 ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + while( !$rs->EOF ) { + $last_billed_amt += $rs->fields['billed_amt']; + $rs->MoveNext(); + } + $smarty->assign('ar_credits_previous', $last_billed_amt); + + ############################### + # Get AR Credits change percentage + ############################### + if($last_billed_amt > 0) + $ar_change = $this_billed_amt/$last_billed_amt *100 -100; + else + $ar_change = 0; + + if($ar_change == 0) + $ar_change = '-'; + elseif($ar_change < 0) + $ar_change = '' . number_format($ar_change, 1). '%'; + else + $ar_change = '+'.number_format($ar_change, 1). '%'; + + $smarty->assign('ar_credit_change', $ar_change); + + ########################################## + # Get AR Balance + ########################################## + $this_ar_balance = $this_billed_amt - $this_amt; + $last_ar_balance = $last_billed_amt - $last_amt; + + $smarty->assign('ar_balance_current', $this_ar_balance); + $smarty->assign('ar_balance_last', $last_ar_balance); + + ######################################### + # Get Users (current) + ######################################### + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'account WHERE + date_orig >= ' . $db->qstr( $this_start ) . ' AND + date_orig <= ' . $db->qstr( $this_end ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + $users_current = $rs->RecordCount(); + $smarty->assign('users_current', $users_current); + + ######################################### + # Get Users (previous) + ######################################### + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'account WHERE + date_orig >= ' . $db->qstr( $last_start ) . ' AND + date_orig <= ' . $db->qstr( $last_end ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + $users_previous = $rs->RecordCount(); + $smarty->assign('users_previous', $users_previous); + + ############################### + # Get users change percentage + ############################### + if($users_previous > 0) + @$users_change = $users_current/$users_current *100 -100; + else + $users_change = 0; + + if($users_change == 0) + $users_change = '-'; + elseif($users_change < 0) + $users_change = '' . number_format($users_change, 1). '%'; + else + $users_change = '+'.number_format($users_change, 1). '%'; + + $smarty->assign('users_change', $users_change); + + # Get Tickets + if( $C_list->is_installed('ticket') ) + { + $smarty->assign('show_tickets', true); + + ######################################### + # Get Tickets (current) + ######################################### + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'ticket WHERE + date_orig >= ' . $db->qstr( $this_start ) . ' AND + date_orig <= ' . $db->qstr( $this_end ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + $tickets_current = $rs->RecordCount(); + $smarty->assign('tickets_current', $tickets_current); + + ######################################### + # Get Tickets (previous) + ######################################### + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'ticket WHERE + date_orig >= ' . $db->qstr( $last_start ) . ' AND + date_orig <= ' . $db->qstr( $last_end ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + $tickets_previous = $rs->RecordCount(); + $smarty->assign('tickets_previous', $tickets_previous); + + ############################### + # Get Tickets change percentage + ############################### + if($tickets_previous > 0) + @$tickets_change = $tickets_current/$tickets_current *100 -100; + else + $tickets_change = 0; + + if($tickets_change == 0) + $tickets_change = '-'; + elseif($tickets_change < 0) + $tickets_change = '' . number_format($tickets_change, 1). '%'; + else + $tickets_change = '+'.number_format($tickets_change, 1). '%'; + + $smarty->assign('tickets_change', $tickets_change); + } + + # Get Affiliate stats + if( $C_list->is_installed('affiliate') ) + { + $smarty->assign('show_affiliates', true); + + ########################################### + # Get affiliate sales for this period + ########################################### + $this_amt = 0; + $sql = 'SELECT total_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE + date_orig >= ' . $db->qstr( $this_start ) . ' AND + date_orig <= ' . $db->qstr( $this_end ) . ' AND + affiliate_id != ' . $db->qstr( 0 ) . ' AND + affiliate_id != ' . $db->qstr( '' ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + while( !$rs->EOF ) { + $this_amt += $rs->fields['total_amt']; + $rs->MoveNext(); + } + $smarty->assign('affiliate_sales_current', $this_amt); + + ########################################## + # Get affiliate sales for last period + ########################################## + $last_amt = 0; + $sql = 'SELECT total_amt FROM ' . AGILE_DB_PREFIX . 'invoice WHERE + date_orig >= ' . $db->qstr( $last_start ) . ' AND + date_orig <= ' . $db->qstr( $last_end ) . ' AND + affiliate_id != ' . $db->qstr( 0 ) . ' AND + affiliate_id != ' . $db->qstr( '' ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + while( !$rs->EOF ) { + $last_amt += $rs->fields['total_amt']; + $rs->MoveNext(); + } + $smarty->assign('affiliate_sales_previous', $last_amt); + + ########################################### + # Get affiliate sales change percentage + ########################################### + if($last_amt > 0) + $sales_change = $this_amt/$last_amt *100 -100; + else + $sales_change = 0; + + if($sales_change == 0) + $sales_change = '-'; + elseif($sales_change < 0) + $sales_change = '' . number_format($sales_change, 1). '%'; + else + $sales_change = '+'.number_format($sales_change, 1). '%'; + + $smarty->assign('affiliate_sales_change', $sales_change); + } + + + /** Get VoIP Performance Data + */ + if( $C_list->is_installed('voip') ) + { + + # Avg. Call Duration for this period + $rs = $db->Execute(sqlSelect($db, "voip_cdr", "avg(ceiling(billsec/60))", "disposition='ANSWERED' AND date_orig >= $this_start AND date_orig <= $this_end")); + if(empty($rs->fields[0])) $acd=0; else $acd = $rs->fields[0]; + $smarty->assign('acd',$acd); + + # Avg. Call Duration for last period + $rs = $db->Execute(sqlSelect($db, "voip_cdr", "avg(ceiling(billsec/60))", "disposition='ANSWERED' AND date_orig >= $last_start AND date_orig <= $last_end")); + if(empty($rs->fields[0])) $acd_last=0; else $acd_last = $rs->fields[0]; + $smarty->assign('acd_last',$acd_last); + + # Get Avg. Call Duration change Percentage + if($acd > 0) $acd_change = $acd/$acd_last*100-100; else $acd_change = 0; + if($acd_change == 0) + $acd_change = '-'; + elseif ($acd_change < 0) + $acd_change = '' . number_format($acd_change, 1). '%'; + else + $acd_change = '+'.number_format($acd_change, 1). '%'; + $smarty->assign('acd_change', $acd_change); + + + # Avg. Successful Rate for this period + $rs = $db->Execute(sqlSelect($db, "voip_cdr", "count(*)", "disposition='ANSWERED' AND date_orig >= $this_start AND date_orig <= $this_end")); + $rs1 = $db->Execute(sqlSelect($db, "voip_cdr", "count(*)", "date_orig >= $this_start AND date_orig <= $this_end")); + if ($rs->fields[0]) + $asr = number_format(($rs->fields[0] / $rs1->fields[0]) * 100,3)." %"; + else + $asr = "-"; + $smarty->assign('asr', $asr); + + # Number of CDRs for this period + $cdrs = $rs1->fields[0]; + $smarty->assign('cdrs', number_format($cdrs,0)); + + # Avg. Successful Rate for last period + $rs = $db->Execute(sqlSelect($db, "voip_cdr", "count(*)", "disposition='ANSWERED' AND date_orig >= $last_start AND date_orig <= $last_end")); + $rs1 = $db->Execute(sqlSelect($db, "voip_cdr", "count(*)", "date_orig >= $last_start AND date_orig <= $last_end")); + if ($rs->fields[0]) + $asr_last = number_format(($rs->fields[0] / $rs1->fields[0]) * 100,3)." %"; + else + $asr_last = "-"; + $smarty->assign('asr_last', $asr_last); + + # Number of CDRS for last period + $cdrs_last = $rs1->fields[0]; + $smarty->assign('cdrs_last', number_format($cdrs_last,0)); + + # Get Avg. Successful Rate change Percentage + if($asr > 0) $asr_change = $asr/$asr_last*100-100; else $asr_change = 0; + if($asr_change == 0) + $asr_change = '-'; + elseif ($asr_change < 0) + $asr_change = '' . number_format($asr_change, 1). '%'; + else + $asr_change = '+'.number_format($asr_change, 1). '%'; + $smarty->assign('asr_change', $asr_change); + + + # Get Number of CDRs change Percentage + if($cdrs > 0) $cdrs_change = $cdrs/$cdrs_last*100-100; else $cdrs_change = 0; + if($cdrs_change == 0) + $cdrs_change = '-'; + elseif ($cdrs_change < 0) + $cdrs_change = '' . number_format($cdrs_change, 1). '%'; + else + $cdrs_change = '+'.number_format($cdrs_change, 1). '%'; + $smarty->assign('cdrs_change', $cdrs_change); + } + + + # Generate the Calendar Overview + include_once(PATH_MODULES.'core/calendar.inc.php'); + $calendar = new calendar; + $start = $calendar->start; + $end = $calendar->end; + + global $C_list; + $C_list->currency(DEFAULT_CURRENCY); + $currency_symbol=$C_list->format_currency[DEFAULT_CURRENCY]['symbol']; + + # Get the paid/due invoice statistics + $rs = $db->Execute($sql=sqlSelect($db,"invoice","date_orig,total_amt,billing_status,refund_status,billed_amt,suspend_billing","date_orig >= $start && date_orig <= $end")); + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + $day = date("j", $rs->fields['date_orig']); + + if($rs->fields['billed_amt'] > 0 && ($rs->fields['billing_status'] == 1 || $rs->fields['refund_status'] != 1)) { + $paid[$day] += $rs->fields['billed_amt']; + } + if ($rs->fields['billing_status'] != 1 && $rs->fields['refund_status'] != 1 ) { + $amt = $rs->fields['total_amt'] - $rs->fields['billed_amt']; + $due[$day] += $amt; + } + + $rs->MoveNext(); + } + + if(is_array($paid)) + foreach($paid as $day=>$item) + $calendar->add("Paid - {$currency_symbol}". number_format($item,2), $day, 'green', 'green'); + + if(is_array($due)) + foreach($due as $day=>$item) + $calendar->add("Due - {$currency_symbol}". number_format($item,2), $day,'red','red'); + } + + # Get the upcoming due services + $rs = $db->Execute($sql=sqlSelect($db,"service","date_next_invoice,price","price > 0 AND date_next_invoice >= $start AND date_next_invoice <= $end AND suspend_billing <> 1")); + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + $day = date("j", $rs->fields['date_next_invoice']); + $sdue[$day] += $rs->fields['price']; + $rs->MoveNext(); + } + foreach($sdue as $day=>$item) { + $calendar->add("Recurring - {$currency_symbol}". number_format($item,2), $day, 'grey', 'grey'); + } + } + + $calout= $calendar->generate(); + $smarty->assign("calendar", $calout); + + return; + } + + /** AUTO APPROVE INVOICE + */ + function autoApproveInvoice($invoice_id) + { + $do = false; + + # Get the invoice details: + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."invoice WHERE + id = ".$db->qstr($invoice_id)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $invoice = $db->Execute($q); + if ($invoice === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','autoApproveInvoice', $db->ErrorMsg()); + return false; + } + + # Get the checkout details: + $q = "SELECT * FROM ".AGILE_DB_PREFIX."checkout WHERE + id = ".$db->qstr($invoice->fields['checkout_plugin_id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $checkout = $db->Execute($q); + if ($checkout === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','autoApproveInvoice', $db->ErrorMsg()); + return false; + } + + # Get the account details: + $q = "SELECT * FROM ".AGILE_DB_PREFIX."account WHERE + id = ".$db->qstr($invoice->fields['account_id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $account = $db->Execute($q); + if ($account === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','autoApproveInvoice', $db->ErrorMsg()); + return false; + } + + # is this a recurring invoices, and is manual approvale req? + if ( $invoice->fields['type'] == 1 && $checkout->fields['manual_approval_recur'] != 1) { + $do = true; + } + + # Manual approval required for all? + if( $invoice->fields['type'] != 1 && $checkout->fields['manual_approval_all'] != 1) { + $do = true; + } + + if(!$do) { + + # manual approval req. for invoice amount? + if(!empty($checkout->fields['manual_approval_amount']) && $do == true) + if($checkout->fields['manual_approval_amount'] <= $invoice->fields['total_amt']) + $do = false; + + # manual approval req. for user's country? + if(!empty($checkout->fields['manual_approval_country']) && $do == true) { + $arr = unserialize($checkout->fields['manual_approval_country']); + for($i=0; $ifields['country_id'] == $arr[$i]) + $do = false; + } + } + + # manual approval req. for user's currency? + if(!empty($checkout->fields['manual_approval_currency']) && $do == true) { + $arr = unserialize($checkout->fields['manual_approval_currency']); + for($i=0; $ifields['actual_billed_currency_id'] == $arr[$i]) + $do = false; + } + } + + # manual approval req. for user's group(s)? + if(!empty($checkout->fields['manual_approval_group']) && $do == true) { + # Get the group details: + $q = "SELECT group_id FROM ".AGILE_DB_PREFIX."account_group WHERE + account_id = ".$db->qstr($invoice->fields['account_id'])." AND + active = ".$db->qstr('1')." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $groups = $db->Execute($q); + if ($groups === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','autoApproveInvoice', $db->ErrorMsg()); + } + + $arr = unserialize($checkout->fields['manual_approval_group']); + while(!$groups->EOF) { + for($i=0; $ifields["group_id"]; + if($idx == $arr[$i]) + $do = false; + } + $groups->MoveNext(); + } + } + } + + if ($do) + { + # Approve the invoice + $arr['id'] = $invoice_id; + $this->approveInvoice($arr, $this); + } + else + { + # Admin manual approval notice + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + $mail = new email_template; + $mail->send('invoice_manual_auth_admin', $invoice->fields['account_id'], $invoice->fields['id'], $invoice->fields['checkout_plugin_id'], ''); + } + } + + + /* APPROVE INVOICE + */ + function approveInvoice($VAR) + { + # Get the invoice details: + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."invoice WHERE + id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $invoice = $db->Execute($q); + if ($invoice === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','approveInvoice', $db->ErrorMsg()); + return false; + } + + # Validate invoice exists & needs approval: + if($invoice->fields['id'] != $VAR['id'] || $invoice->fields['process_status'] == '1') return false; + + # Update the invoice approval status: + $q = "UPDATE ".AGILE_DB_PREFIX."invoice SET + date_last = ".$db->qstr(time()).", + process_status = ".$db->qstr('1')." WHERE + id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + if ($result === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','approveInvoice', $db->ErrorMsg()); + return false; + } + + # Send approval notice to user: + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + $mail = new email_template; + $mail->send('invoice_approved_user', $invoice->fields['account_id'], $VAR['id'], '', ''); + + # Include the service class + include_once(PATH_MODULES.'service/service.inc.php'); + $srvc = new service; + + # Determine if services have already been created for this invoice: + if($invoice->fields['type'] != 1 ) + { + $q = "SELECT id FROM ".AGILE_DB_PREFIX."service WHERE + invoice_id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $service = $db->Execute($q); + if ($service === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','approveInvoice', $db->ErrorMsg()); + return false; + } + if ($service->RecordCount() > 0) + { + # Update services to approved status: + while(!$service->EOF) + { + $srvc->approveService($service->fields['id']); + $service->MoveNext(); + } + return true; + } + + # Get the parent items in this invoice : + $q = "SELECT * FROM ".AGILE_DB_PREFIX."invoice_item WHERE + ( parent_id = 0 OR parent_id IS NULL OR parent_id = '') AND + invoice_id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $ii = $db->Execute($q); + if ($ii === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','approveInvoice', $db->ErrorMsg()); + return false; + } + while(!$ii->EOF) + { + if(empty($ii->fields['service_id'])) + { + # Add the service + $srvc->invoiceItemToService($ii->fields['id'], $invoice); + + # Check for any children items in this invoice: + $q = "SELECT * FROM ".AGILE_DB_PREFIX."invoice_item WHERE + parent_id = ".$db->qstr($ii->fields['id'])." AND + invoice_id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $iii = $db->Execute($q); + if ($iii === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','approveInvoice', $db->ErrorMsg()); + return false; + } + while(!$iii->EOF) + { + # Add the service + $srvc->invoiceItemToService($ii->fields['id'], $invoice); + $iii->MoveNext(); + } + } + else + { + $srvc = new service; + if($ii->fields['item_type'] == 2 && $ii->fields['domain_type'] == 'renew' ) { + # this is a domain renewal + $srvc->renewDomain( $ii, $invoice->fields['account_billing_id'] ); + } else { + # this is an upgrade for an existing service + $srvc->modifyService( $ii, $invoice->fields['account_billing_id'] ); + } + } + $ii->MoveNext(); + } + } + elseif ($invoice->fields['type'] == 1 ) + { + # recurring invoice, just update assoc services + # Loop through invoice items & approve assoc services + $q = "SELECT service_id FROM ".AGILE_DB_PREFIX."invoice_item WHERE + invoice_id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $service = $db->Execute($q); + if ($service === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','voidInvoice', $db->ErrorMsg()); + return false; + } + if ($service->RecordCount() > 0) + { + # Include the service class + include_once(PATH_MODULES.'service/service.inc.php'); + $srvc = new service; + + # Update services to inactive status: + while(!$service->EOF) { + $srvc->approveService($service->fields['service_id']); + $service->MoveNext(); + } + } + } + + # get account id + if(defined("SESS_ACCOUNT")) + $account_id = SESS_ACCOUNT; + else + $account_id = 0; + + # if approved, create a memo + $id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id'); + $q = "INSERT INTO ".AGILE_DB_PREFIX."invoice_memo + SET + id = ".$db->qstr($id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + invoice_id = ".$db->qstr($VAR['id']).", + account_id = ".$db->qstr($account_id).", + type = ".$db->qstr('approval').", + memo = ".$db->qstr('NA'); + $memo = $db->Execute($q); + if ($memo === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','approveInvoice', $db->ErrorMsg()); + return false; + } + return true; + } + + + /** VOID INVOICE + */ + function voidInvoice($VAR) + { + # Update the invoice approval status: + $db = &DB(); + $q = "UPDATE ".AGILE_DB_PREFIX."invoice SET + date_last = ".$db->qstr(time()).", + process_status = ".$db->qstr('0')." WHERE + id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $update = $db->Execute($q); + if ($update === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','voidInvoice', $db->ErrorMsg()); + return false; + } + + # Determine if services have already been created for this invoice and deactivate: + $q = "SELECT id FROM ".AGILE_DB_PREFIX."service WHERE + invoice_id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $service = $db->Execute($q); + if ($service === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','voidInvoice', $db->ErrorMsg()); + return false; + } + if ($service->RecordCount() > 0) + { + # Include the service class + include_once(PATH_MODULES.'service/service.inc.php'); + $srvc = new service; + + # Update services to inactive status: + while(!$service->EOF) { + $srvc->voidService($service->fields['id']); + $service->MoveNext(); + } + } + + # Loop through invoice items & delete assoc services + $q = "SELECT service_id FROM ".AGILE_DB_PREFIX."invoice_item WHERE + invoice_id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $service = $db->Execute($q); + if ($service === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','voidInvoice', $db->ErrorMsg()); + return false; + } + if ($service->RecordCount() > 0) + { + # Include the service class + include_once(PATH_MODULES.'service/service.inc.php'); + $srvc = new service; + + # Update services to inactive status: + while(!$service->EOF) { + $srvc->voidService($service->fields['service_id']); + $service->MoveNext(); + } + } + + # if voided, create a memo + $id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id'); + $q = "INSERT INTO ".AGILE_DB_PREFIX."invoice_memo + SET + id = ".$db->qstr($id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + invoice_id = ".$db->qstr($VAR['id']).", + account_id = ".$db->qstr(SESS_ACCOUNT).", + type = ".$db->qstr('void').", + memo = ".$db->qstr('NA'); + $insert = $db->Execute($q); + if ($insert === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','voidInvoice', $db->ErrorMsg()); + return false; + } + return true; + } + + + /** RECONCILE INVOICE + */ + function reconcile($VAR) + { + global $C_translate, $C_debug; + + # validate amt + if( $VAR['amount'] <= 0) { + $C_debug->alert( "Payment amount to low!" ); + return false; + } + + # get the invoice details + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'invoice WHERE + id = ' . $db->qstr( $VAR['id'] ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + if ($rs === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','reconcileInvoice', $db->ErrorMsg()); + return false; + } + + if(@$rs->RecordCount() == 0) return false; + + $amt = $VAR['amount']; + $total_amt = $rs->fields['total_amt']; + $billed_amt = $rs->fields['billed_amt']; + $billed_currency_id = $rs->fields['billed_currency_id']; + $actual_billed_amt = $rs->fields['actual_billed_amt']; + $actual_billed_currency_id = $rs->fields['actual_billed_currency_id']; + $due = $total_amt - $billed_amt; + + $overpaid = false; + if($amt > $due) + { + $billed = 1; + $update = $total_amt; + + $overpaid = $amt - $due; + + $C_translate->value['invoice']['amt'] = number_format($overpaid, 2); + $alert = $C_translate->translate('rec_over','invoice',''); + } + elseif ($amt == $due) + { + $billed = 1; + $update = $total_amt; + } + else + { + $billed = 0; + $update = $amt + $billed_amt; + } + + # Update the invoice record + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'invoice + SET + billed_amt = ' . $db->qstr( $update ) . ', + billing_status = ' . $db->qstr( $billed ) . ' + WHERE + id = ' . $db->qstr( $VAR['id'] ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $db->Execute($sql); + + # Create a memo + $id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id'); + $q = "INSERT INTO ".AGILE_DB_PREFIX."invoice_memo + SET + id = ".$db->qstr($id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + invoice_id = ".$db->qstr($VAR['id']).", + account_id = ".$db->qstr(SESS_ACCOUNT).", + type = ".$db->qstr('reconcile').", + memo = ".$db->qstr('+ '.number_format($VAR['amount'],2) . " \r\n" . @$VAR['memo']); + $db->Execute($q); + + + # Reciept printing + include_once PATH_MODULES.'invoice/receipt_print.php'; + $receipt = new receipt_print; + $receipt->add($rs, number_format($VAR['amount'],2), number_format($update,2)); + + + # Auto update if billed complete + if($billed) + { + $this->autoApproveInvoice($VAR['id']); + + # Get the default currency ISO + $q = "SELECT ".AGILE_DB_PREFIX."invoice_memo + SET + id = ".$db->qstr($id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + invoice_id = ".$db->qstr($VAR['id']).", + account_id = ".$db->qstr(SESS_ACCOUNT).", + type = ".$db->qstr('reconcile').", + memo = ".$db->qstr('+ '.number_format($VAR['amount'],2) . " \r\n" . @$VAR['memo']); + $currency = $db->Execute($q); + + # User invoice creation confirmation + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + $email = new email_template; + $email->send('invoice_paid_user', $rs->fields['account_id'], $VAR['id'], $rs->fields['billed_currency_id'], ''); + + # Admin alert of payment processed + $email = new email_template; + $email->send('admin->invoice_paid_admin', $rs->fields['account_id'], $VAR['id'], $rs->fields['billed_currency_id'], ''); + } + + # Redirect + if(!empty($VAR['redirect'])) + { + echo ' + '; + exit; + } + + $msg = $C_translate->translate('ref_comp','invoice',''); + $C_debug->alert( $msg ); + return; + } + + + /** REFUND INVOICE + */ + function refund($VAR) + { + global $C_translate, $C_debug; + + # validate amt + if( $VAR['amount'] <= 0) { + $C_debug->alert( "Refund amount to low!" ); + return false; + } + + # get the invoice details + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'invoice WHERE + id = ' . $db->qstr( $VAR['id'] ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $rs = $db->Execute($sql); + if(@$rs->RecordCount() == 0) return false; + + $amt = $VAR['amount']; + $total_amt = $rs->fields['total_amt']; + $billed_amt = $rs->fields['billed_amt']; + $billed_currency_id = $rs->fields['billed_currency_id']; + $actual_billed_amt = $rs->fields['actual_billed_amt']; + $actual_billed_currency_id = $rs->fields['actual_billed_currency_id']; + $update = $billed_amt - $amt; + + if($update>0) $billing_status=1; else $billing_status=0; + + # Update the invoice record + echo $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'invoice + SET + billed_amt = ' . $db->qstr( $update ) . ', + billing_status = '.$billing_status.', + suspend_billing = 1, + refund_status = 1 + WHERE + id = ' . $db->qstr( $VAR['id'] ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $update2 = $db->Execute($sql); + if ($update2 === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','refundInvoice', $db->ErrorMsg()); + return false; + } + + # Create a memo + $id = $db->GenID(AGILE_DB_PREFIX . 'invoice_memo_id'); + $q = "INSERT INTO ".AGILE_DB_PREFIX."invoice_memo + SET + id = ".$db->qstr($id).", + site_id = ".$db->qstr(DEFAULT_SITE).", + date_orig = ".$db->qstr(time()).", + invoice_id = ".$db->qstr($VAR['id']).", + account_id = ".$db->qstr(SESS_ACCOUNT).", + type = ".$db->qstr('refund').", + memo = ".$db->qstr('- '.number_format($VAR['amount'],2) . " \r\n" . @$VAR['memo']); + $insert = $db->Execute($q); + if ($insert === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','refundInvoice', $db->ErrorMsg()); + return false; + } + + # Void: + $this->voidInvoice($VAR, $this); + + # Call into the checkout plugin and attempt realtime refund + $billing = $db->Execute($sql=sqlSelect($db, array('account_billing','checkout'), 'A.*,B.checkout_plugin', + "A.id = ::{$rs->fields['account_billing_id']}:: AND A.checkout_plugin_id=B.id")); + if($billing && $billing->RecordCount() && !empty($billing->fields['checkout_plugin'])) { + $plugin_file = PATH_PLUGINS.'checkout/'. $billing->fields['checkout_plugin'] .'.php'; + if(is_file($plugin_file)) { + include_once ( $plugin_file ); + eval( '$PLG = new plg_chout_' . $billing->fields['checkout_plugin'] . '("'.$billing->fields['checkout_plugin_id'].'");'); + if(is_callable(Array($PLG,"refund"))) $PLG->refund($rs->fields, $billing->fields, $amt); + } + } + + # Redirect + if(!empty($VAR['redirect'])) { + echo ' '; + return; + } + + $msg = $C_translate->translate('ref_comp','invoice',''); + $C_debug->alert( $msg ); + return; + } + + # Get translated/hardcoded line item description for PDF invoice + function getLineItemDesc($sku,$id,$domain=false,$item_name) + { + if(!empty($item_name)) return $item_name; + global $C_translate; + if(!empty($sku) && $sku == 'DOMAIN-PARK' || $sku == 'DOMAIN-TRANSFER' || $sku == 'DOMAIN-REGISTER' || $sku == 'DOMAIN-RENEW') { + if($sku == 'DOMAIN-REGISTER') $name=$C_translate->translate('register','cart',''); + elseif ($sku == 'DOMAIN-TRANSFER') $name=$C_translate->translate('transfer','cart',''); + elseif ($sku == 'DOMAIN-PARK') $name=$C_translate->translate('park','cart',''); + elseif ($sku == 'DOMAIN-RENEW') $name=$C_translate->translate('renew','cart',''); + if($domain) return "$domain \r\n ( $name )"; + else return $name; + } else { + include_once(PATH_CORE.'list.inc.php'); + $C_list=new CORE_list; + if(empty($this->product_desc["$id"])) { + $desc = $C_list->translate("product_translate", "name", "product_id", $id, "translate_product"); + $this->product_desc["$id"] = $desc['name']; + } + if(!empty($this->product_desc["$id"])) + return $this->product_desc["$id"]; + else + return $sku; + } + return $sku; + } + + /** + * Task based function to e-mail or store printable PDF of all unprinted invoices + */ + function delivery_task() + { + # get all unprinted invoices + $db=&DB(); + $invcfg = $db->Execute(sqlSelect($db,"setup_invoice","*","id=::".DEFAULT_SITE."::")); + $rs = $db->SelectLimit($sql=sqlSelect($db,Array("invoice","account"), + "A.id,B.email,B.first_name,B.last_name,B.invoice_delivery,B.invoice_show_itemized", + "(A.billing_status=0 OR A.billing_status IS NULL) AND (A.print_status=0 OR A.print_status=NULL) and A.account_id=B.id and (B.invoice_delivery is not null AND B.invoice_delivery>0)"),100); + if($rs && $rs->RecordCount()) + { + //define('FPDF_FONTPATH', PATH_INCLUDES.'pdf/font/'); + require_once(PATH_INCLUDES.'pdf/fpdi.php'); + require_once(PATH_INCLUDES.'pdf/fpdf_tpl.php'); + require_once(PATH_INCLUDES.'pdf/fpdf.php'); + require_once(PATH_INCLUDES.'pdf/pdf_invoice_'.$invcfg->fields['invoice_pdf_plugin'].'.inc.php'); + + // Send the e-mail.... + require_once(PATH_INCLUDES."phpmailer/class.phpmailer.php"); + + $mail = new PHPMailer(); + $mail->From = SITE_EMAIL; + $mail->FromName = SITE_NAME; + + /* + $mail->SMTPAuth = true; + $mail->Host = "smtp.domain.com"; + $mail->Username = "user"; + $mail->Password = "pass"; + $mail->Mailer = "smtp"; + $mail->Debug = true; + */ + + while(!$rs->EOF) + { + $pdf = new pdf_invoice_overview(); + $pdf->companyName = SITE_NAME; + $pdf->companyAddress = SITE_ADDRESS; + $pdf->companyCity = SITE_CITY; + $pdf->companyState = SITE_STATE; + $pdf->companyZip = SITE_ZIP; + + # load the setup_invoice fields into the pdf class + $pdf->load_setup($invcfg); + + $pagecount = $pdf->setSourceFile($pdf->getTemplate()); + $tplidx = $pdf->ImportPage(1); + + $pdf->addPage(); + $pdf->useTemplate($tplidx); + + # override the show itemized, based on the customers choice + if($rs->fields['invoice_show_itemized'] == 0 || $rs->fields['invoice_show_itemized'] == 1) + $pdf->show_itemized = $rs->fields['invoice_show_itemized']; + + $this->pdfInvoiceSummary($rs->fields['id'], $pdf); + + $file = tempnam(PATH_FILES, "pdf_inv_".$rs->fields['id']).".pdf"; + $pdf->Output($file,'F'); + $pdf->closeParsers(); + + if($rs->fields['invoice_delivery'] == 1) { + $mail->AddAddress($rs->fields['email'], $rs->fields['first_name']. ' ' . $rs->fields['last_name']); + $mail->Subject = "Printable Invoice No. ". $rs->fields['id']; + $mail->Body = "Please find the printable version of invoice number {$rs->fields['id']} attached.\r\n\r\nThank you,\r\n".SITE_NAME; + $mail->AddAttachment($file, "INVOICE_{$rs->fields['id']}.pdf"); + + if($mail->Send()) { + $fields=Array('print_status'=>1); + $db->Execute(sqlUpdate($db,"invoice",$fields,"id=".$rs->fields['id'])); + } else { + echo "Unable to email invoice # {$rs->fields['id']} to {$rs->fields['email']}
"; + } + + $mail->ClearAddresses(); + $mail->ClearAttachments(); + } else if($rs->fields['invoice_delivery'] == 2) { + if(copy($file,AGILE_PDF_INVOICE_PATH."invoice_".$rs->fields['id'].".pdf")) { + $fields=Array('print_status'=>1); + $db->Execute(sqlUpdate($db,"invoice",$fields,"id=".$rs->fields['id'])); + } + } + + // delete tmp file and clean up vars used + unlink($file); + unset($pdf->itemsSummary); + unset($pdf); unset($tplidx); unset($pagecount); + + $rs->MoveNext(); + } + } + } + + + /** Display a PDF invoice + */ + function pdf($VAR) + { + # Check invoice + if(empty($VAR['id'])) { + echo 'No Invoice Specified.'; + return false; + } + + # Check admin authentication: + global $C_auth; + if ($C_auth->auth_method_by_name('invoice','view') == false) { + # Validate on account level + $db = &DB(); + $rs = $db->Execute(sqlSelect($db,"invoice","account_id", "id = ::{$VAR['id']}::")); + if ($rs->fields['account_id'] != SESS_ACCOUNT) { + // todo: redirect to login page if not logged + return false; + } + } + + $db =& DB(); + $invcfg = $db->Execute(sqlSelect($db,"setup_invoice","*","id=::".DEFAULT_SITE."::")); + + if (!defined('FPDF_FONTPATH')) + define('FPDF_FONTPATH', PATH_INCLUDES.'pdf/font/'); + require_once(PATH_INCLUDES.'pdf/fpdi.php'); + require_once(PATH_INCLUDES.'pdf/fpdf_tpl.php'); + require_once(PATH_INCLUDES.'pdf/fpdf.php'); + require_once(PATH_INCLUDES.'pdf/pdf_invoice_'.$invcfg->fields['invoice_pdf_plugin'].'.inc.php'); + + ob_start(); + + $pdf = new pdf_invoice_overview(); + $pdf->companyName = SITE_NAME; + $pdf->companyAddress = SITE_ADDRESS; + $pdf->companyCity = SITE_CITY; + $pdf->companyState = SITE_STATE; + $pdf->companyZip = SITE_ZIP; + + # load the setup_invoice + $pdf->load_setup($invcfg); + + $pagecount = $pdf->setSourceFile($pdf->getTemplate()); + $tplidx = $pdf->ImportPage(1); + $pdf->addPage(); + $pdf->useTemplate($tplidx); + $this->pdfInvoiceSummary($VAR['id'], $pdf); + $pdf->Output('invoice.pdf','D'); + $pdf->closeParsers(); + + ob_end_flush(); + } + + /** Export multiple invoices */ + function pdfExport(&$rs) + { + $db =& DB(); + $invcfg = $db->Execute(sqlSelect($db,"setup_invoice","*","")); + + define('FPDF_FONTPATH', PATH_INCLUDES.'pdf/font/'); + require_once(PATH_INCLUDES.'pdf/fpdi.php'); + require_once(PATH_INCLUDES.'pdf/fpdf_tpl.php'); + require_once(PATH_INCLUDES.'pdf/fpdf.php'); + require_once(PATH_INCLUDES.'pdf/pdf_invoice_'.$invcfg->fields['invoice_pdf_plugin'].'.inc.php'); + + ob_start(); + $pdf = new pdf_invoice_overview(); + $pdf->companyName = SITE_NAME; + $pdf->companyAddress = SITE_ADDRESS; + $pdf->companyCity = SITE_CITY; + $pdf->companyState = SITE_STATE; + $pdf->companyZip = SITE_ZIP; + $pdf->load_setup($invcfg); + $pagecount = $pdf->setSourceFile($pdf->getTemplate()); + $tplidx = $pdf->ImportPage(1); + while(!$rs->EOF) { + $pdf->addPage(); + $pdf->useTemplate($tplidx); + $this->pdfInvoiceSummary($rs->fields['id'], $pdf); + $rs->MoveNext(); + unset($pdf->itemsSummary); + } + $pdf->Output(); + $pdf->closeParsers(); + ob_end_flush(); + } + + + + function pdfInvoiceSummary($id, &$pdf) + { + # Invoice details: + $db = &DB(); + $invoice = $db->Execute( $sql = sqlSelect($db, array("invoice", "currency"), "A.*, B.symbol", "A.id = ::$id:: AND B.id = A.billed_currency_id")); + $pdf->setInvoiceFields($invoice->fields); + $pdf->setDueAmt($invoice->fields['total_amt'] - $invoice->fields['billed_amt']); + $pdf->setCurrency($invoice->fields['symbol']); + $pdf->setDateRange( mktime(0,0,0,date('m',$invoice->fields['due_date'])-1, date('d',$invoice->fields['due_date']), date('Y',$invoice->fields['due_date'])), $invoice->fields['due_date']); + $pdf->drawInvoiceNo(); + $pdf->drawInvoiceDueDate(); + $pdf->drawInvoiceTotalAmt(); + $pdf->drawInvoiceDueAmt(); + $pdf->drawInvoicePaidAmt(); + $pdf->drawInvoiceDiscountAmt(); + $pdf->drawInvoiceTaxAmt(); + $pdf->drawInvoiceShippingAmt(); + $pdf->drawInvoiceRange(); + if($invoice->fields['billing_status'] !=1 && $invoice->fields['suspend_billing'] != 1 && $invoice->fields['due_date'] <= time()) + $pdf->drawInvoiceDueNotice(); + elseif($invoice->fields['billing_status'] == 1) + $pdf->drawInvoicePaidNotice(); + + # Account details: + $account = $db->Execute("SELECT * FROM ".AGILE_DB_PREFIX."account WHERE id = ".$db->qstr($invoice->fields['account_id'])." AND site_id = ".$db->qstr(DEFAULT_SITE)); + $pdf->setAccountFields($account->fields); + $pdf->drawAccountId(); + $pdf->drawAccountUsername(); + $pdf->drawAccountName(); + $pdf->drawAccountMailing(); + + # Company details: + $pdf->drawCompanyAddress(); + $pdf->drawCompanyLogo(); + + ## Get the summary items + $items = & $db->Execute("select sku, item_type, product_name, product_id, sum(quantity) as quantity, (sum(total_amt)) as amount, price_setup, price_base from ".AGILE_DB_PREFIX."invoice_item where invoice_id=".$db->qstr($id)." group by sku, item_type"); + $i = 0; + if($items && $items->RecordCount()) { + while (!$items->EOF) { + $items_arr[$i] = $items->fields; + $desc = $this->getLineItemDesc($items->fields['sku'], $items->fields['product_id'], false, $items->fields['product_name']); + $items_arr[$i]['name'] = $desc; + $i++; + if ($items->fields['price_setup']) { + $items_arr[$i]['name'] = $desc." Set-up Charge"; + $items_arr[$i]['amount'] = $items->fields['price_setup']; + $i++; + } + $items->MoveNext(); + } + } + if ($invoice->fields['discount_amt']) { + $items_arr[$i]['name'] = 'Discount'; + $items_arr[$i]['amount'] = -($invoice->fields['discount_amt']); + $i++; + } + if ($invoice->fields['tax_amt']) { + $trs = $db->Execute($sql=sqlSelect($db, Array('invoice_item_tax','tax'),"A.amount,B.description","A.tax_id=B.id AND A.invoice_id=::$id::")); + if($trs && $trs->RecordCount()) { + unset($taxes); + while(!$trs->EOF) { + $taxes["{$trs->fields['description']}"] += $trs->fields["amount"]; + $trs->MoveNext(); + } + foreach($taxes as $txds=>$txamt) { + $items_arr[$i]['name'] = $txds; + $items_arr[$i]['amount'] = $txamt; + $i++; + } + } + } + $pdf->drawSummaryLineItems($items_arr); + unset($items_arr); + unset($pdf->itemsSummary); + + ## BEGIN loop for enumerating information in multiple ways on the invoice + $iteration = 0; + while($pdf->drawLineItems_pre($iteration)) { + ## Get the line items: + $items = & $db->Execute( sqlSelect($db, "invoice_item", "*", "invoice_id = ::$id::") ); + if ($items && $items->RecordCount()) { + while ( !$items->EOF ) { + #$items_arr[] = $items->fields; + // get the date range if set + if(!empty($items->fields['date_start']) && !empty($items->fields['date_stop'])) { + global $C_translate; + $C_translate->value('invoice','start', date(UNIX_DATE_FORMAT,$items->fields['date_start'])); + $C_translate->value('invoice','stop', date(UNIX_DATE_FORMAT,$items->fields['date_stop'])); + #$smart_items[$ii]['range'] = $C_translate->translate('recur_date_range','invoice',''); + } + + $cost = $items->fields['price_base']; + $total = $cost * $items->fields['quantity']; + $desc = $this->getLineItemDesc($items->fields['sku'],$items->fields['product_id'], strtolower($items->fields['domain_name'].'.'.$items->fields['domain_tld']), $items->fields['product_name']); + $line = array( + "name" => $desc, + 'amount' => $cost, + 'sku'=>$items->fields['sku'], + 'qty'=>$items->fields['quantity'], + 'cost'=>$cost, + 'attr'=>$items->fields['product_attr'], + 'price_type'=>$items->fields['price_type'], + 'price_base'=>$items->fields['price_base'], + 'item_type'=>$items->fields['item_type'], + 'total_amt'=>$items->fields['total_amt'] + ); + $pdf->drawLineItems($db, $line); + if ($items->fields['price_setup']) { + $desc .= " Set-up Charge"; + $total = $items->fields['price_setup']; + $line = array("name" => $desc, 'amount' => $total, 'qty'=>'1', 'sku'=>$items->fields['sku'], 'cost'=>$total, 'price_base'=>$total, 'price_type'=>999); + $pdf->drawLineItems($db, $line); + } + $items->MoveNext(); + } + } + if ($invoice->fields['discount_amt']) { + $desc = 'Discount'; + $total = -($invoice->fields['discount_amt']); + $line = array("name" => $desc, 'amount' => $total, 'qty'=>'1', 'cost'=>$total, 'price_base'=>$total, 'price_type'=>999); + $pdf->drawLineItems($db, $line); + } + if ($invoice->fields['tax_amt']) { + $trs = $db->Execute($sql=sqlSelect($db, Array('invoice_item_tax','tax'),"A.amount,B.description","A.tax_id=B.id AND A.invoice_id=::$id::")); + if($trs && $trs->RecordCount()) { + unset($taxes); + while(!$trs->EOF) { + $taxes["{$trs->fields['description']}"] += $trs->fields["amount"]; + $trs->MoveNext(); + } + foreach($taxes as $txds=>$txamt) { + $line = array("name" => $txds, 'amount' => $txamt, 'qty'=>'1', 'cost'=>$txamt, 'price_base'=>$txamt, 'price_type'=>999); + $pdf->drawLineItems($db, $line); + } + } + } + # Increment the iteration + ++$iteration; + } + # Custom functions: + $pdf->drawCustom(); + unset($db); + } + + + /** RESEND DUE NOTICE + */ + function resend($VAR) + { + global $C_debug; + + # User invoice creation confirmation + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + $mail = new email_template; + $mail->send('invoice_resend', $VAR['account_id'], $VAR['id'], '', ''); + + # Alert + $C_debug->alert('Sent payment due notice to user'); + + # Update invoice + $db = &DB(); + $q = "SELECT notice_count FROM ".AGILE_DB_PREFIX."invoice WHERE + id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $rs = $db->Execute($q); + $count = $rs->fields['notice_count'] + 1; + $q = "UPDATE ".AGILE_DB_PREFIX."invoice SET + notice_count = ".$db->qstr($count)." WHERE + id = ".$db->qstr($VAR['id'])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $rs = $db->Execute($q); + } + + + /** + * Generate all invoices for recurring services/charges/domains + */ + function generate() { + + // check if charge module installed + global $C_list; + $charge_installed = $C_list->is_installed('charge'); + + // get services to be billed grouped by account and date + if(MAX_INV_GEN_PERIOD <= 0) $max_date = time()+86400; else $max_date = time()+(MAX_INV_GEN_PERIOD*86400); + $p=AGILE_DB_PREFIX; $s=DEFAULT_SITE; + $ids=false; + $account=false; + $date=false; + $invoice=false; + $sql = "SELECT DISTINCT service.id as serviceId, account.id as accountId, invoice.id as invoiceId, from_unixtime(service.date_next_invoice,'%Y-%m-%d') as dayGroup + FROM {$p}service as service + JOIN {$p}account as account ON ( service.account_id=account.id and account.site_id={$s} ) + LEFT JOIN {$p}invoice as invoice ON ( service.invoice_id=invoice.id and invoice.site_id={$s} ) + WHERE service.site_id={$s} + AND service.active = 1 + AND ( service.suspend_billing IS NULL OR service.suspend_billing = 0 ) + AND ( service.date_next_invoice > 0 AND service.date_next_invoice IS NOT NULL ) + AND + (( + ( account.invoice_advance_gen!='' OR account.invoice_advance_gen is not null ) AND service.date_next_invoice <= (UNIX_TIMESTAMP(CURDATE())+(account.invoice_advance_gen*86400)) + ) OR ( + ( account.invoice_advance_gen='' OR account.invoice_advance_gen is null ) AND service.date_next_invoice <= {$max_date} + )) + ORDER BY accountId, dayGroup, serviceId"; + $db=&DB(); + #$db->debug=true; + $rs=$db->Execute($sql); + if($rs === false) {global $C_debug; $C_debug->error('invoice.inc.php','generate()', $sql . " \r\n\r\n " . @$db->ErrorMsg()); } + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + if( $ids && ($rs->fields['accountId'] != $account ) || ($rs->fields['dayGroup'] != $date) ) { + $this->generateInvoices($ids, $account, $invoice, $charge_installed); + $ids=false; + } + + // set the current account and date + $account=$rs->fields['accountId']; + $invoice=$rs->fields['invoiceId']; + $date=$rs->fields['dayGroup']; + + // add to id list + if($ids) $ids.=","; + $ids.=$rs->fields['serviceId']; + $rs->MoveNext(); + } + if($ids) $this->generateInvoices($ids, $account, $invoice, $charge_installed); + } + + // Generate invoices for any domains expiring in X days. + if($C_list->is_installed('host_tld')) $this->generateDomains(); + + return true; + } + + + function generateInvoices($ids, $account_id, $invoice_id, $charge_installed=false) { + + if(empty($ids)) return false; + + # load required elements + include_once(PATH_MODULES . 'service/service.inc.php'); + include_once(PATH_MODULES . 'discount/discount.inc.php'); + include_once(PATH_MODULES . 'tax/tax.inc.php'); + $taxObj = new tax; + $serviceObj = new service; + + # start a transaction + $db=&DB(); + #$db->debug=true; + if(AGILE_DB_TYPE == 'mysqlt') { + $db->StartTrans(); + if(!$db->hasTransactions) { + global $C_debug; + $msg= "Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver"; + $C_debug->alert($msg); + $C_debug->error('invoice.inc.php','generateInvoices()', "Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver"); + return false; + } + } + + # generate an invoice id + $invoice = sqlGenID($db, 'invoice'); + + # check for any discounts for the parent invoice or account_id + # applied at checkout and should continue to be applied if recurring type discount + $discountObj = new discount; + $discountObj->available_discounts($account_id, 1, $invoice_id); + + # beginning totals + $sub_total=0; + $taxable_amount=0; + $tax_amt=0; + $discount_amt=0; + + # get the full account and service and invoice details + $p=AGILE_DB_PREFIX; $s=DEFAULT_SITE; + $sql = "SELECT DISTINCT + service.id, service.parent_id, service.invoice_id, service.invoice_item_id, service.account_id, service.account_billing_id, service.product_id, + service.sku, service.active, service.bind, service.type, service.price, service.price_type, service.taxable, service.date_last_invoice, service.date_next_invoice, + service.recur_type, service.recur_schedule, service.recur_weekday, service.recur_week, service.domain_name, + service.domain_tld, service.domain_type, service.domain_term, service.prod_attr, service.prod_attr_cart, + account.currency_id, account.first_name, account.last_name, account.country_id, account.state, account.invoice_grace, account.invoice_advance_gen, account.affiliate_id as account_affiliate_id, + invoice.affiliate_id, invoice.campaign_id, invoice.reseller_id, invoice.checkout_plugin_id, invoice.checkout_plugin_data, invoice.billed_currency_id, invoice.actual_billed_currency_id + FROM {$p}service as service + JOIN {$p}account as account ON ( service.account_id=account.id and account.site_id={$s} ) + LEFT JOIN {$p}invoice as invoice ON ( service.invoice_id=invoice.id and invoice.site_id={$s} ) + WHERE service.id in ({$ids})"; + $service=$db->Execute($sql); + if($service === false) {global $C_debug; $C_debug->error('invoice.inc.php','generateInvoices()1', $sql . " \r\n\r\n " . @$db->ErrorMsg()); $db->FailTrans(); return false; } + if($service && $service->RecordCount()) { + while(!$service->EOF) { + + if(empty($service->fields['billed_currency_id'])) $service->fields['billed_currency_id'] = DEFAULT_CURRENCY; + if(empty($service->fields['actual_billed_currency_id'])) $service->fields['actual_billed_currency_id'] = $service->fields['billed_currency_id']; + + $this->account_id=$service->fields['account_id']; + $this->parent_id=$service->fields['invoice_id']; + $this->account_billing_id=$service->fields['account_billing_id']; + if(!empty($service->fields['account_affiliate_id'])) + $this->affiliate_id=$service->fields['account_affiliate_id']; + else + $this->affiliate_id=$service->fields['affiliate_id']; + $this->campaign_id=$service->fields['campaign_id']; + $this->reseller_id=$service->fields['reseller_id']; + $this->checkout_plugin_id=$service->fields['checkout_plugin_id']; + $this->checkout_plugin_data=$service->fields['checkout_plugin_data']; + $this->billed_currency_id=$service->fields['billed_currency_id']; + $this->actual_billed_currency_id=$service->fields['actual_billed_currency_id']; + $this->invoice_grace=$service->fields['invoice_grace']; + + $item_tax_amt=0; + $item_total_amt=0; + $item_discount_amt=0; + + # gen item_id + $item = sqlGenID($db, "invoice_item"); + + # Calculate any recurring discounts for this item + $item_total_amt = $service->fields['price']; + $item_discount_amt = $discountObj->calc_all_discounts(1, $item, $service->fields['product_id'], $service->fields['price'], $service->fields['account_id'], $sub_total+$service->fields['price']); + $item_total_amt -= $item_discount_amt; + $sub_total += $item_total_amt; + $discount_amt += $item_discount_amt; + + # calculate any taxes for this item + if($service->fields['taxable'] == 1) { + $item_tax_amt=0; + $item_tax_arr = $taxObj->calculate($item_total_amt, $service->fields['country_id'], $service->fields['state']); + if(is_array($item_tax_arr)) foreach($item_tax_arr as $tx) $item_tax_amt += $tx['rate']; + $tax_amt += $item_tax_amt; + } + + # Calculate next invoice date + $next_invoice = $serviceObj->calcNextInvoiceDate($service->fields['date_next_invoice'], $service->fields['recur_schedule'], $service->fields['recur_type'], $service->fields['recur_weekday']); + $due_date = $service->fields['date_next_invoice']; + $recur_schedule=0; + if(!empty($service->fields['recur_schedule'])) $recur_schedule = $service->fields['recur_schedule']; + + // create the invoice item + $sql="INSERT INTO {$p}invoice_item SET + id=$item, + site_id=$s, + date_orig=".time().", + invoice_id = $invoice, + account_id={$service->fields['account_id']}, + service_id={$service->fields['id']}, + product_id={$service->fields['product_id']}, + product_attr=".$db->qstr($service->fields['prod_attr']).", + product_attr_cart=".$db->qstr($service->fields['prod_attr_cart']).", + sku=".$db->qstr($service->fields['sku']).", + quantity=1, + item_type=0, + price_type={$service->fields['price_type']}, + price_base={$service->fields['price']}, + price_setup=0, + recurring_schedule={$recur_schedule}, + date_start={$service->fields['date_next_invoice']}, + date_stop=$next_invoice, + domain_name=".$db->qstr($service->fields['domain_name']).", + domain_tld=".$db->qstr($service->fields['domain_tld']).", + domain_type=".$db->qstr($service->fields['domain_type']).", + tax_amt=$tax_amt, + total_amt=$item_total_amt, + discount_amt=$item_discount_amt"; + $itemrs=$db->Execute($sql); + if($itemrs === false) {global $C_debug; $C_debug->error('invoice.inc.php','generateInvoices()2', $sql . " \r\n\r\n " . @$db->ErrorMsg()); $db->FailTrans(); return false; } + + // Insert tax records + $taxObj->invoice_item($invoice, $item, $service->fields['account_id'], @$item_tax_arr); + + # Insert discount records + $discountObj->invoice_item($invoice, $item, $service->fields['account_id'], @$discountObj->discount_arr); + + // Update the last & next invoice date for this service + $sql="UPDATE {$p}service + SET + date_last_invoice = {$service->fields['date_next_invoice']}, + date_next_invoice = $next_invoice + WHERE + site_id=$s AND id = {$service->fields['id']} "; + $srvsrs = $db->Execute($sql); + if($srvsrs === false) {global $C_debug; $C_debug->error('invoice.inc.php','generateInvoices()3', $sql . " \r\n\r\n " . @$db->ErrorMsg()); $db->FailTrans(); return false; } + + // get any charges for this service and create them as invoice items + if($charge_installed) { + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."charge WHERE (status=0 or status is null) and site_id=".DEFAULT_SITE." AND service_id = ".$service->fields['id']." AND date_orig < ". $service->fields['date_next_invoice']; + $charge = $db->Execute($sql); + if($charge && $charge->RecordCount()) { + while(!$charge->EOF) { + $item_tax_amt=0; + $item_total_amt=0; + $item_discount_amt=0; + + // Calculate any recurring discounts for this charge item + $item_total_amt = ($charge->fields['quantity']*$charge->fields['amount']); + $item_discount_amt = $discountObj->calc_all_discounts(1, $item, $charge->fields['product_id'], $item_total_amt, $service->fields['account_id'], $sub_total+$item_total_amt); + $item_total_amt -= $item_discount_amt; + $sub_total += $item_total_amt; + $discount_amt += $item_discount_amt; + + // calculate any taxes for this item + if($charge->fields['taxable'] == 1) { + $item_tax_amt=0; + $item_tax_arr = $taxObj->calculate($chargeamt, $service->fields['country_id'], $service->fields['state']); + if(is_array($item_tax_arr)) foreach($item_tax_arr as $tx) $item_tax_amt += $tx['rate']; + $tax_amt += $item_tax_amt; + } + + // create the invoice item + $charge_item_id = sqlGenID($db, 'invoice_item'); + + $sql = "INSERT INTO {$p}invoice_item SET + id = $charge_item_id, + site_id = $s, + charge_id = {$charge->fields['id']}, + date_orig = ".time().", + invoice_id = $invoice, + account_id = ".$this->account_id.", + service_id = ".$db->qstr($service->fields['id']).", + product_id = ".$db->qstr($charge->fields['product_id']).", + product_attr= ".$db->qstr($charge->fields['attributes']).", + sku = ".$db->qstr($service->fields['sku']).", + price_base = ".$db->qstr($charge->fields['amount']).", + quantity = ".$charge->fields['quantity'].", + item_type = 5, + price_type = 0, + price_setup = 0, + tax_amt = $item_tax_amt, + total_amt = $item_total_amt, + discount_amt= $item_discount_amt"; + $itemrs=$db->Execute($sql); + if($itemrs === false) {global $C_debug; $C_debug->error('invoice.inc.php','generateInvoices()4', $sql . " \r\n\r\n " . @$db->ErrorMsg()); $db->FailTrans(); return false; } + + # Insert tax records + $taxObj->invoice_item($invoice, $charge_item_id, $charge->fields['account_id'], @$item_tax_arr); + + # Insert discount records + $discountObj->invoice_item($invoice, $charge_item_id, $charge->fields['account_id'], @$discountObj->discount_arr); + + # update charge status + $chargers=$db->Execute("UPDATE ".AGILE_DB_PREFIX."charge set status=1 WHERE id={$charge->fields['id']} AND site_id=".DEFAULT_SITE); + if($chargers === false) {global $C_debug; $C_debug->error('invoice.inc.php','generateInvoices()2', $sql . " \r\n\r\n " . @$db->ErrorMsg()); $db->FailTrans(); return false; } + + $charge->MoveNext(); + } + } + } + $service->MoveNext(); + } + + // add any taxes + @$total = $sub_total + $tax_amt; + + // get invoice grace period from global/account + if(!empty($this->invoice_grace)) $grace_period=$this->invoice_grace; else $grace_period=GRACE_PERIOD; + + $sql = "INSERT INTO {$p}invoice SET + id=$invoice, + site_id=$s, + date_orig = ".time().", + date_last = ".time().", + notice_next_date = ".time().", + type = 1, + process_status = 0, + billing_status = 0, + suspend_billing = 0, + print_status = 0, + refund_status = 0, + billed_amt = 0, + actual_billed_amt = 0, + notice_count = 0, + parent_id = ".$db->qstr($this->parent_id).", + account_id = {$this->account_id}, + account_billing_id = ".$db->qstr($this->account_billing_id).", + affiliate_id = ".$db->qstr($this->affiliate_id).", + campaign_id = ".$db->qstr($this->campaign_id).", + reseller_id = ".$db->qstr($this->reseller_id).", + checkout_plugin_id = ".$db->qstr($this->checkout_plugin_id).", + checkout_plugin_data = ".$db->qstr($this->checkout_plugin_data).", + actual_billed_currency_id = ".$db->qstr($this->actual_billed_currency_id).", + billed_currency_id = ".$db->qstr($this->billed_currency_id).", + notice_max = ".$db->qstr(MAX_BILLING_NOTICE).", + grace_period = ".$db->qstr($grace_period).", + tax_amt = ".$tax_amt.", + discount_amt = ".$discount_amt.", + total_amt = ".$total.", + due_date = $due_date"; + $invoicers=$db->Execute($sql); + if($invoicers === false) {global $C_debug; $C_debug->error('invoice.inc.php','generateInvoices()2', $sql . " \r\n\r\n " . @$db->ErrorMsg()); $db->FailTrans(); return false; } + } + + if(AGILE_DB_TYPE == 'mysqlt') $db->CompleteTrans(); + } + + + + + /** Invoice expiring domains + */ + function generateDomains() + { + $db = &DB(); + define('DEFAULT_DOMAIN_INVOICE', 30); //how far out to generate expiring domain invoices + $expire = time() + (DEFAULT_DOMAIN_INVOICE*86400); + + ### Get domains expiring soon: + $rs = $db->Execute( sqlSelect( $db, 'service', '*', " active=1 AND domain_date_expire <= $expire AND type = 'domain' AND queue = 'none' AND + ( domain_type = 'register' OR domain_type = 'transfer' OR domain_type = 'renew' ) AND + ( suspend_billing = 0 OR suspend_billing IS NULL) " ) ); + + if($rs && $rs->RecordCount() > 0 ) { + while(!$rs->EOF) { + # Check that this domain has not already been invoiced + $invoiced = $db->Execute( sqlSelect ($db, Array('invoice_item','invoice'), Array('A.*','B.*'), + " A.invoice_id = B.id AND A.service_id = {$rs->fields['id']} AND A.sku = 'DOMAIN-RENEW' AND domain_type = 'renew' AND + date_start = {$rs->fields['date_last_invoice']} AND date_stop = {$rs->fields['domain_date_expire']}" ) ); + + if($invoiced && $invoiced->RecordCount() == 0) { + # Not previously invoiced, generate now! + $this->generatedomaininvoice( $rs->fields, $this ); + } + $rs->MoveNext(); + } + } + } + + /** Invoice expiring domains p2 + */ + function generatedomaininvoice( $VAR ) + { + include_once(PATH_MODULES . 'tax/tax.inc.php'); + $taxObj = new tax; + + $db = &DB(); + + if( is_array( $VAR ) ) { + $expire = time(); + $rs = $db->Execute( sqlSelect($db, 'service', '*', " id = ::{$VAR['id']}:: AND active=1 + AND type = 'domain' AND queue = 'none' AND + ( domain_type = 'register' OR domain_type = 'transfer' OR domain_type = 'renew' ) AND + ( suspend_billing = 0 OR suspend_billing IS NULL ) " )); + $service = $rs->fields; + } else { + $service = $VAR; + } + + if(empty($service['id'])) { + global $C_debug; + $C_debug->alert("Unable to generate domain renweal invoice due to domain status."); + return false; + } + + # Get the parent invoice details: + if(!empty($service['invoice_id'])) { + $rs = $db->Execute( sqlSelect($db, 'invoice', '*', " id = {$service['invoice_id']} ", "" ) ); + $invoice = $rs->fields; + } else { + $invoice = false; + } + + # Get the account details: + $rs = $db->Execute( sqlSelect($db, 'account', '*', " id = {$service['account_id']} ", "" ) ); + $account = $rs->fields; + + # Get the account price + include_once(PATH_MODULES.'host_tld/host_tld.inc.php'); + $tldObj=new host_tld; + $tld_arr = $tldObj->price_tld_arr($service['domain_tld'], 'renew', false, false, false, $service['account_id']); + foreach($tld_arr as $term => $price) break; + + # Calculate taxes: + $rs = $db->Execute($sql=sqlSelect($db,"host_tld","taxable","name = ::{$service['domain_tld']}::")); + if( $service['taxable'] || @$rs->fields['taxable'] ) { + $tax_arr = $taxObj->calculate($price, $account["country_id"], $account["state"]); + } else { + $tax_arr = false; + } + + $total = $price; + + $tax_amt = 0; + if(is_array($tax_arr)) { + foreach($tax_arr as $tx) { + $tax_amt += $tx['rate']; + } + $total += $tax_amt; + } + + # calculate the dates + $expire = $service['domain_date_expire'] + ($term*86400); + $due_date = $service['domain_date_expire'] - (86400*3); + + # Create the invoice + $id = sqlGenID( $db, "invoice" ); + $insert = $db->Execute( $sql = sqlInsert($db, "invoice", + Array( + 'date_orig' => time(), + 'date_last' => time(), + 'type' => 2, + 'process_status' => 0, + 'billing_status' => 0, + 'suspend_billing' => 0, + 'print_status' => 0, + 'parent_id' => $service['invoice_id'], + 'account_id' => $service['account_id'], + 'account_billing_id'=> $service['account_billing_id'], + 'affiliate_id' => @$invoice['affiliate_id'], + 'campaign_id' => @$invoice['campaign_id'], + 'reseller_id' => @$invoice['reseller_id'], + 'checkout_plugin_id'=> @$invoice['checkout_plugin_id'], + 'tax_amt' => $tax_amt, + 'discount_arr' => serialize(@$discount_arr), + 'discount_amt' => @$discount_amt, + 'total_amt' => $total, + 'billed_amt' => 0, + 'billed_currency_id'=> DEFAULT_CURRENCY, + 'actual_billed_amt' => 0, + 'actual_billed_currency_id' => @$invoice['actual_billed_currency_id'], + 'notice_count' => 0, + 'notice_next_date' => time(), + 'notice_max' => MAX_BILLING_NOTICE, + 'grace_period' => 0, + 'due_date' => $due_date + ), $id ) ) ; + + # create the invoice item: + if($insert) { + $db->Execute ( $idx = sqlInsert($db, "invoice_item", + Array( + 'date_orig' => time(), + 'invoice_id' => $id, + 'account_id' => $service['account_id'], + 'service_id' => $service['id'], + 'sku' => 'DOMAIN-RENEW', + 'quantity' => 1, + 'item_type' => 2, + 'price_type' => 0, + 'price_base' => $price, + 'price_setup' => 0, + 'domain_type' => 'renew', + 'date_start' => $service['domain_date_expire'], + 'date_stop' => $expire, + 'domain_name' => $service['domain_name'], + 'domain_tld' => $service['domain_tld'], + 'domain_term' => $term, + 'tax_amt' => $tax_amt, + 'total_amt' => $price + ) ) ); + + # Insert tax records + $taxObj->invoice_item($id, $idx, $service['account_id'], @$item_tax_arr); + + # Update the service record + $fields=Array('active' => 0); + $db->Execute(sqlUpdate($db,"service",$fields,"id = {$service['id']}")); + + global $C_debug; + $C_debug->alert("Generated domain renewal invoice for {$service['domain_name']}.{$service['domain_tld']}"); + return $id; + } + } + + + + /** Run AutoBilling and Due Notices + */ + function autobill($VAR) + { + global $VAR, $C_debug, $C_list; + + # User invoice creation confirmation + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + $mail = new email_template; + + # get all due invoices + $db = &DB(); + #$db->debug = true; + + if(empty($VAR['invoice_id'])) + { + $this->bill_one = false; + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'invoice + WHERE notice_next_date <= ' . $db->qstr( time() ) . ' + AND ( + billing_status = 0 OR + billing_status IS NULL + ) AND ( + suspend_billing = 0 OR + suspend_billing IS NULL + ) + AND site_id = ' . $db->qstr(DEFAULT_SITE); + $invoice = $db->Execute($sql); + if($invoice->RecordCount() == 0) { + $C_debug->alert('No Invoices to Autobill'); + return false; + } + } else { + # get the specified invoice: + $this->bill_one = true; + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'invoice + WHERE ( + billing_status = 0 OR + billing_status IS NULL + ) + AND id = ' . $db->qstr($VAR['invoice_id']) . ' + AND site_id = ' . $db->qstr(DEFAULT_SITE); + $invoice = $db->Execute($sql); + } + + # Check for results + if($invoice->RecordCount() == 0) { + $C_debug->alert('Invoice could not be billed!'); + return false; + } + + # Loop through results + while(!$invoice->EOF) + { + $db->StartTrans(); + + $due = true; + + # get currency code + $cyid = $invoice->fields['actual_billed_currency_id']; + $billed_currency_id = $invoice->fields['billed_currency_id']; + if(empty($this->currency_iso[$cyid])) + { + $q = "SELECT three_digit,convert_array FROM ". AGILE_DB_PREFIX ."currency WHERE + id = ". $db->qstr($cyid)." AND + site_id = ". $db->qstr(DEFAULT_SITE); + $currb = $db->Execute($q); + $this->format_currency[$cyid] = Array ( 'convert' => unserialize($currb->fields["convert_array"]), + 'iso' => $currb->fields["three_digit"]); + } + + # get the currency codes (default) + if(empty($this->format_currency[$billed_currency_id])) + { + # Get the billed currency id currency info: + $q = "SELECT three_digit,convert_array FROM ".AGILE_DB_PREFIX."currency WHERE + id = ".$db->qstr($billed_currency_id)." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $currb = $db->Execute($q); + $this->format_currency[$billed_currency_id] = Array ( 'convert' => unserialize($currb->fields["convert_array"]), + 'iso' => $currb->fields["three_digit"]); + } + + # attempt to autobill? + if(!empty( $invoice->fields['account_billing_id'] )) + { + # get checkout plugin details: + $billing =& $db->Execute($sql=sqlSelect($db, array('account_billing','checkout'), 'A.*,B.checkout_plugin', + "A.id = ::{$invoice->fields['account_billing_id']}:: AND A.checkout_plugin_id=B.id")); + + if($billing && $billing->RecordCount() == 1 && !empty($billing->fields['checkout_plugin'])) { + $plugin_file = PATH_PLUGINS.'checkout/'. $billing->fields['checkout_plugin'] .'.php'; + if(!is_file($plugin_file)) { + $err = $plugin_file .' missing when autobilling invoice id ' . $invoice->fields['id']; + $C_debug->error('invoice.inc.php','autobill()', $err); + } else { + include_once ( $plugin_file ); + eval( '$PLG = new plg_chout_' . $billing->fields['checkout_plugin'] . '("'.$billing->fields['checkout_plugin_id'].'");'); + } + } else { + $err = 'account_billing.id '.$invoice->fields['account_billing_id'].' empty or not associated with a checkout plugin when autobilling invoice id ' . $invoice->fields['id']; + $C_debug->error('invoice.inc.php','autobill()', $err); + } + } + + # get the actual billed amount + $amount = $invoice->fields['total_amt'] - $invoice->fields['billed_amt']; + $billed_amt = $invoice->fields['total_amt']; + $actual_billed_amt = $invoice->fields['total_amt']; + if($amount <= 0) $due = false; + + if(!empty($PLG) && is_object($PLG) && $PLG->type == 'gateway' && $amount > 0) + { + # attempt autobilling if account billing exists and gateway plugin + if($invoice->fields['account_billing_id'] > 0 ) + { + /* get the account details */ + $account = $db->Execute(sqlSelect($db,"account","id,email","id=::{$invoice->fields['account_id']}")); + + /* Convert the invoice amount to the actual billed currency amount */ + if($cyid != $invoice->fields['billed_currency_id']) { + $conversion = $this->format_currency[$billed_currency_id]["convert"][$cyid]["rate"]; + $amount *= $conversion; + $actual_billed_amt = $invoice->fields['actual_billed_amt'] + $amount; + } + + /* load the billing details from the database */ + $PLG->setBillingFromDBObj($billing, true); + + /* attempt to auto-bill */ + if(!$checkout_plugin_data = $PLG->bill_checkout( number_format($amount,2), $invoice->fields['id'], $this->format_currency[$cyid]['iso'], $account->fields, 0,0) ) { + $due = true; + $email = new email_template; + $email->send('invoice_decline_user', $invoice->fields['account_id'], $invoice->fields['id'],$C_list->format_currency($invoice->fields['total_amt'],$cyid), $C_list->date($invoice->fields['due_date'])); + $email = new email_template; + $email->send('admin->invoice_decline_admin', $invoice->fields['account_id'], $invoice->fields['id'], $C_list->format_currency($invoice->fields['total_amt'],''), $C_list->date($invoice->fields['due_date'])); + } else { + $due = false; + } + } + } + + # send proper alert & manage services + if ($due) + { + # determine if overdue + $due = $invoice->fields['due_date']; + $grace = $invoice->fields['grace_period']; + if(time() < $due+(86400*$grace)) + { + if($invoice->fields['notice_count'] <= 0) + { + # send out first alert - new invoice created! + $email = new email_template; + $email->send('invoice_recur_user', $invoice->fields['account_id'], $invoice->fields['id'], $C_list->format_currency($invoice->fields['total_amt'],$cyid), $C_list->date($invoice->fields['due_date'])); + $email = new email_template; + $email->send('admin->invoice_recur_admin', $invoice->fields['account_id'], $invoice->fields['id'], $C_list->format_currency($invoice->fields['total_amt'],''), $C_list->date($invoice->fields['due_date'])); + } + else + { + # send out payment due notice + if(empty($PLG) || $PLG->type == 'gateway') { + $email = new email_template; + $email->send('invoice_due_user', $invoice->fields['account_id'], $invoice->fields['id'], $this->format_currency[$cyid]["iso"], $C_list->date($invoice->fields['due_date'])); + $email = new email_template; + $email->send('admin->invoice_due_admin', $invoice->fields['account_id'], $invoice->fields['id'], $this->format_currency[$billed_currency_id]["iso"], $C_list->date($invoice->fields['due_date'])); + } + elseif($PLG->type == 'redirect') { + $email = new email_template; + $email->send('invoice_due_user', $invoice->fields['account_id'], $invoice->fields['id'], $this->format_currency[$cyid]["iso"], $C_list->date($invoice->fields['due_date'])); + } elseif ($PLG->type == 'other') { + $email = new email_template; + $email->send('admin->invoice_due_admin', $invoice->fields['account_id'], $invoice->fields['id'], $this->format_currency[$billed_currency_id]["iso"], $C_list->date($invoice->fields['due_date'])); + } + } + + # increment notice counter + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'invoice SET + notice_count = ' . $db->qstr($invoice->fields['notice_count']+1) . ', + notice_next_date = ' . $db->qstr(time()+86400*3) . ' + WHERE + id = ' . $db->qstr( $invoice->fields['id'] ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $db->Execute($sql); + } + else + { + # send service cancelation notice + $email = new email_template; + $email->send('service_suspend_user', $invoice->fields['account_id'], $invoice->fields['id'], $C_list->format_currency($invoice->fields['total_amt'],$cyid), $C_list->date($invoice->fields['due_date'])); + $email = new email_template; + $email->send('admin->service_suspend_admin', $invoice->fields['account_id'], $invoice->fields['id'], $C_list->format_currency($invoice->fields['total_amt'],''), $C_list->date($invoice->fields['due_date'])); + + # overdue - cancel services + $vara['id'] = $invoice->fields['id']; + $this->voidInvoice($vara, $this); + + # suspend billing activity + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'invoice SET + notice_count = ' . $db->qstr($invoice->fields['notice_count']+1) . ', + suspend_billing = ' . $db->qstr('1') . ' + WHERE + id = ' . $db->qstr( $invoice->fields['id'] ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $db->Execute($sql); + } + } + else + { + # update billing stauts + $sql = 'UPDATE ' . AGILE_DB_PREFIX . 'invoice SET + notice_count = ' . $db->qstr($invoice->fields['notice_count']+1) . ', + billing_status = ' . $db->qstr('1') . ', + billed_amt = ' . $db->qstr($billed_amt) . ', + actual_billed_amt = ' . $db->qstr($actual_billed_amt) . ' + WHERE + id = ' . $db->qstr( $invoice->fields['id'] ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $db->Execute($sql); + + # update invoice via autoapproveInvoice + $this->autoApproveInvoice($invoice->fields['id']); + + # User alert of payment processed + $email = new email_template; + $email->send('invoice_paid_user', $invoice->fields['account_id'], $invoice->fields['id'], $this->format_currency[$cyid]['iso'], ''); + + # Admin alert of payment processed + $email = new email_template; + $email->send('admin->invoice_paid_admin', $invoice->fields['account_id'], $invoice->fields['id'], $this->format_currency[$billed_currency_id]['iso'], ''); + } + $invoice->MoveNext(); + unset($PLG); + + /* finish transaction */ + $db->CompleteTrans(); + } + } + + + + /** + * Find out if a user has unpaid invoices + */ + function has_unpaid($VAR) { + if(!SESS_LOGGED) return false; + $db=&DB(); + $inv=$db->Execute($sql=sqlSelect($db,"invoice","SUM(total_amt-billed_amt) as total", + "account_id=".SESS_ACCOUNT." AND billing_status=0 AND refund_status=0")); + if($inv && $inv->RecordCount() && $inv->fields['total']>0) { + global $smarty, $C_list; + //$act= $db->Execute(sqlSelect($db,"account","currency_id","id=)); + $smarty->assign('has_unpaid', $C_list->format_currency_num($inv->fields['total'],SESS_CURRENCY)); + } + } + + + /** + * Get the totals for multiple invoices or for a group of invoices stored in temp + */ + function multiple_invoice_total($invoice,$account_id=SESS_ACCOUNT) + { + $db = &DB(); + if(empty($invoice) || eregi(",", $invoice)) { + $id_list=''; + if(!empty($invoice)) { + $id = split(',', $invoice); + for($i=0; $iqstr($id[$i])." "; + $ii++; + } else { + $id_list .= " OR id = " .$db->qstr($id[$i]). " "; + $ii++; + } + } + } + if(!empty($id_list)) $id_list = "( $id_list ) AND "; + } + // get invoice totals + $total=0; + $inv=$db->Execute($sql=sqlSelect($db,"invoice","id,total_amt,billed_amt", "$id_list account_id=".SESS_ACCOUNT." AND billing_status=0 AND refund_status=0")); + if($inv && $inv->RecordCount()) { + while(!$inv->EOF) { + $this->invoice[] = $inv->fields['id']; + $total += ($inv->fields['total_amt']-$inv->fields['billed_amt']); + $inv->MoveNext(); + } + return $total; + } else { + return false; + } + } else { + // get total from temp data + $inv=$db->Execute($sql=sqlSelect($db,"temporary_data","data,field1 as total","field2=::$invoice::")); + if($inv && $inv->RecordCount() && $inv->fields['total'] > 0) { + if(!empty($inv->fields['field2'])) $this->invoice=unserialize($inv->fields['data']); + return $inv->fields['total']; + } else { + return false; + } + } + return false; + } + + /** + * Preview checkout of multiple invoices + */ + function checkout_multiple_preview($VAR) + { + global $smarty,$C_list; + if(!SESS_LOGGED) return false; + + $db=&DB(); + $total = $this->multiple_invoice_total(@$VAR['id'],SESS_ACCOUNT); + if($total > 0 && count($this->invoice) > 1) + { + // get country id for checkout options + $account=sqlSelect($db, "account", "country_id", "id=".SESS_ACCOUNT); + + // get payment options + include_once(PATH_MODULES.'checkout/checkout.inc.php'); + $checkout = new checkout; + $checkoutoptions = $checkout->get_checkout_options(SESS_ACCOUNT, $total, false, $account->fields['country_id'],true); + + // get a temporary id (48 hours) + $id=sqlGenID($db, "temporary_data"); + $invoice["id"] = "MULTI-$id"; + $invoice["total"] = $total; + $fields=Array('date_orig'=>time(), 'date_expire'=>time()+86400*3, 'field2'=> $invoice['id'], 'field1'=>$total, 'data'=>serialize($this->invoice)); + $id = & $db->Execute(sqlInsert($db,"temporary_data",$fields)); + + $smarty->assign('invoice', $invoice); + $smarty->assign('total', $C_list->format_currency_num($total,SESS_CURRENCY)); + $smarty->assign('checkoutoptions', $checkoutoptions); + + } elseif (count($this->invoice) == 1) { + $id = $this->invoice[0]; + echo ""; + } else { + echo "No due invoices selected for payment."; + } + } + + + /** Run checkout plugin for billing + */ + function checkoutnow($VAR) + { + global $C_translate, $smarty, $C_list, $VAR; + + # Validate user logged in: + if(SESS_LOGGED != '1') { + echo ''; + return false; + } + + $db = &DB(); + if(eregi("MULTI-", @$VAR['invoice_id'])) { + // get multi-invoice details + $total = $this->multiple_invoice_total(@$VAR['invoice_id'],SESS_ACCOUNT); + if(!$total) return false; + $recur_amt=false; + $recur_arr=false; + $account_id=SESS_ACCOUNT; + $this->invoice[]=$VAR['invoice_id']; + $this->invoice_id=$VAR['invoice_id']; + $CURRENCY = DEFAULT_CURRENCY; + $multi=true; + } else { + # Validate the invoice selected, & get the totals: + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'invoice WHERE site_id = '.$db->qstr(DEFAULT_SITE).' AND id = ' . $db->qstr($VAR['invoice_id']); + $result = $db->Execute($sql); + if(!$result || $result->RecordCount() == 0) return false; + + # Determine the price & currency + if($result->fields['billed_currency_id'] != $result->fields['actual_billed_currency_id']) { + global $C_list; + $CURRENCY = $result->fields['actual_billed_currency_id']; + if($result->fields['billed_amt'] <= 0) + $total = $C_list->format_currency_decimal ($result->fields['total_amt'], $CURRENCY); + else + $total = $C_list->format_currency_decimal ($result->fields['total_amt'], $CURRENCY) - $result->fields['actual_billed_amt']; + } else { + $CURRENCY = $result->fields['billed_currency_id']; + $total = $result->fields['total_amt']-$result->fields['billed_amt']; + } + $recur_amt=$result->fields['recur_amt']; + if($recur_amt>0) $recur_amt = $C_list->format_currency_decimal ($recur_amt, $CURRENCY); + @$recur_arr=unserialize($result->fields['recur_arr']); + $account_id=$result->fields['account_id']; + $this->invoice_id=$result->fields['id']; + $this->invoice[]=$result->fields['id']; + $multi=false; + } + $amount = round($total, 2); + + # Get the account details: + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'account WHERE site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND id = ' . $db->qstr($account_id); + $account = $db->Execute($sql); + if (!$account || !$account->RecordCount()) return false; + + # Validate checkout option selected is allowed for purchase: + $q = "SELECT * FROM ".AGILE_DB_PREFIX."checkout WHERE site_id = ".$db->qstr(DEFAULT_SITE)." AND id = ".$db->qstr(@$VAR['option'])." AND active = 1 AND "; + if($recur_amt>0 && @$billed_amt == 0 ) $q .= "allow_recurring = 1 "; else $q .= "allow_new = 1 "; + $chopt = $db->Execute($q); + if (!$chopt || !$chopt->RecordCount()) return false; + if($chopt && $chopt->RecordCount()) { + $show = true; + if ( @$chopt->fields["total_maximum"] != "" && $total > $chopt->fields["total_maximum"] ) $show = false; + if ( @$chopt->fields["total_miniumum"] != "" && $total < $chopt->fields["total_miniumum"] ) $show = false; + } + if(!$show) { + echo ' '; + return false; + } + + # Load the checkout plugin: + $plugin_file = PATH_PLUGINS . 'checkout/'. $chopt->fields["checkout_plugin"] . '.php'; + include_once ( $plugin_file ); + eval ( '$PLG = new plg_chout_' . $chopt->fields["checkout_plugin"] . '("'.@$VAR["option"].'");'); + + if(!empty($VAR['account_billing_id']) && @$VAR['new_card']==2) { + /* validate credit card on file details */ + $account_billing_id=$VAR['account_billing_id']; + if(!$PLG->setBillingFromDB($account_id, $account_billing_id, $VAR['option'])) { + global $C_debug; + $C_debug->alert("Sorry, we cannot use that billing record for this purchase."); + return false; + } + } else { + /* use passed in vars */ + $PLG->setBillingFromParams($VAR); + } + + # Set Invoice Vars: + $this->total_amt = $amount; + $this->currency_iso = $C_list->currency_iso($CURRENCY); + $this->currency_iso_admin = $C_list->currency_iso($CURRENCY); + $this->account_id = $account_id; + $this->actual_billed_currency_id = $CURRENCY; + $this->billed_currency_id = $CURRENCY; + $this->checkout_plugin_id = @$VAR["option"]; + + # Run the plugin bill_checkout() method: + $this->checkout_plugin_data = $PLG->bill_checkout( $amount, $this->invoice_id, $this->currency_iso, $account->fields, $recur_amt, $recur_arr); + + # redirect + if(!empty($this->checkout_plugin_data['redirect'])) echo $this->checkout_plugin_data['redirect']; + + # determine results + if( $this->checkout_plugin_data === false ) { + if(!empty($PLG->redirect)) echo $PLG->redirect; + return false; + } elseif ($PLG->type == "gateway" && empty($PLG->redirect)) { + if(empty($this->admin_checkout)) { + $VAR['_page'] = "invoice:thankyou"; + } else { + $VAR['_page'] = "invoice:view"; + } + } elseif ($PLG->type == "redirect") { + echo "
+ Please wait while we redirect you to the secure payment site.... + {$PLG->redirect}
"; + } + + # Call the Plugin method for storing the checkout data, if new data entered: + $this->account_billing_id = $PLG->store_billing($VAR, $PLG); + + # Load the email template module + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + $mail = new email_template; + + # Update billing details for this invoice, if realtime billing succeeded: + if($PLG->type == 'gateway' || $amount == 0) { + $q = "UPDATE ".AGILE_DB_PREFIX."invoice + SET + account_billing_id = " .$db->qstr($this->account_billing_id). ", + billing_status = " .$db->qstr(1). ", + billed_amt = " .$db->qstr($total). ", + actual_billed_amt = " .$db->qstr($amount). ", + date_last = " .$db->qstr(time()). ", + checkout_plugin_id = " .$db->qstr($this->checkout_plugin_id) .", + checkout_plugin_data = " .$db->qstr(serialize($this->checkout_plugin_data)). " + WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($this->invoice_id); + $rst = $db->Execute($q); + if ($rst === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','checkoutnow', $db->ErrorMsg()); + return false; + } + + // loop through each invoice paid + foreach($this->invoice as $this->invoice_id) { + # Send billed e-mail notice to user + $email = new email_template; + $email->send('invoice_paid_user', $this->account_id, $this->invoice_id, $this->currency_iso, ''); + + # Admin alert of payment processed + $email = new email_template; + $email->send('admin->invoice_paid_admin', $this->account_id, $this->invoice_id, $this->currency_iso_admin, ''); + + # Submit the invoice for approval + $arr['id'] = $this->invoice_id; + $this->approveInvoice($arr, $this); + } + + } else { + + # Just update the last_date and plugin data + $q = "UPDATE ".AGILE_DB_PREFIX."invoice + SET + account_billing_id = " .$db->qstr($this->account_billing_id). ", + date_last = " .$db->qstr(time()). ", + checkout_plugin_id = " .$db->qstr($this->checkout_plugin_id) .", + checkout_plugin_data = " .$db->qstr(serialize($this->checkout_plugin_data)). " + WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($this->invoice_id); + $rst = $db->Execute($q); + if ($rst === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','checkoutnow', $db->ErrorMsg()); + return false; + } + + # Admin e-mail alert of manual payment processing + if ( $PLG->name == 'MANUAL' ) { + $date_due = $C_list->date(time()); + foreach($this->invoice as $this->invoice_id) { + $email = new email_template; + $email->send('admin->invoice_due_admin', $this->account_id, $this->invoice_id, '', $date_due); + } + + global $C_debug; + $C_debug->alert($C_translate->translate('manual_alert','checkout')); + } + } + } + + + /** create modified array for invoice summarization + */ + function summarizeLineItems($smart_items) + { + //$ignore['SKU']=true; + $sum=false; + if(is_array($smart_items)) { + foreach($smart_items as $it) { + if(empty($sum["{$it["sku"]}"])) { + // unique line item + if(empty($ignore["{$it["sku"]}"])) $sum["{$it["sku"]}"][] = $it; + } else { + // is unique price/attributes? + $unique=true; + foreach($sum["{$it["sku"]}"] as $sid => $flds) { + if( $flds["price_base"] == $it["price_base"] && $flds["price_setup"] == $it["price_setup"] && $flds['product_attr'] == $it['product_attr'] ) { + $sum["{$it["sku"]}"]["$sid"]["quantity"] += 1; + $unique = false; + break; + } + } + // unique line item + if($unique) $sum["{$it["sku"]}"][] = $it; + } + } + } + + if(!empty($sum)) { + unset($smart_items); + foreach($sum as $sku => $item) foreach($item as $sitem) $smart_items[] = $sitem; + return $smart_items; + } + } + + + + /** VIEW + */ + function view($VAR) + { + global $C_translate, $C_list; + $this->invoice_construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + + $db = &DB(); + + # set the field list for this method: + $arr = $this->method[$type]; + + # loop through the field list to create the sql queries + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $this->table . '_' . $value; + $field_list .= $value; + } + else + { + $field_var = $this->table . '_' . $value; + $field_list .= "," . $value; + } + $i++; + } + + if(isset($VAR["id"])) + { + $id = split(',',$VAR["id"]); + for($i=0; $iqstr($id[$i])." "; + $ii++; + } + else + { + $id_list .= " OR id = " .$db->qstr($id[$i]). " "; + $ii++; + } + } + } + } + + if($ii>0) + { + $any_trial = false; + $any_recurring = false; + $any_new = false; + + # generate the full query + $q = "SELECT + $field_list + FROM + ".AGILE_DB_PREFIX."$this->table + WHERE + $id_list + AND site_id = '" . DEFAULT_SITE . "' + ORDER BY $this->order_by + LIMIT 0,1"; + $result = $db->Execute($q); + if ($result === false) + { + global $C_debug; + $C_debug->error('invoice.inc.php','view', $db->ErrorMsg()); + + if(isset($this->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + return; + } + + ### Set it as a class variable: + $this->result = $result; + + # put the results into a smarty accessable array + $i=0; + $ii=0; + $class_name = TRUE; + while (!$result->EOF) + { + $smart[$i] = $result->fields; + + ## get the product plugin name + if(!empty($result->fields['checkout_plugin_id'])) { + $cplg = $db->Execute(sqlSelect($db,"checkout","name","id = {$result->fields['checkout_plugin_id']}")); + if($cplg && $cplg->RecordCount()) $smart[$i]['checkout_plugin'] = $cplg->fields['name']; + } + + if($result->fields['total_amt'] == 0) + $smart[$i]['balance'] = 0; + else + $smart[$i]['balance'] = $result->fields['total_amt'] - $result->fields['billed_amt']; + + ## Get the tax details + if( !empty($result->fields['tax_amt']) ) { + $trs = $db->Execute($sql=sqlSelect($db, Array('invoice_item_tax','tax'),"A.amount,B.description","A.tax_id=B.id AND A.invoice_id={$result->fields['id']}")); + if($trs && $trs->RecordCount()) { + while(!$trs->EOF) { + $taxes["{$trs->fields['description']}"] += $trs->fields["amount"]; + $trs->MoveNext(); + } + foreach($taxes as $txds=>$txamt) + $smart[$i]["tax_arr"][] = Array('description'=>$txds, 'amount'=>$txamt); + } + } + + ## Get the discount details + if( !empty($result->fields['discount_amt']) ) { + $drs = $db->Execute($sql=sqlSelect($db, 'invoice_item_discount',"amount,discount","invoice_id={$result->fields['id']}")); + if($drs && $drs->RecordCount()) { + while(!$drs->EOF) { + $discounts["{$drs->fields['discount']}"] += $drs->fields["amount"]; + $drs->MoveNext(); + } + $dhtml=''; + foreach($discounts as $dsds=>$dsamt) $dhtml .= ''.$dsds.' - '. number_format($dsamt, 2) . "
"; + $smart[$i]['discount_popup'] = $dhtml; + $dhtml=''; + foreach($discounts as $dsds=>$dsamt) $dhtml .= $dsds.' - '. number_format($dsamt, 2) . "
"; + $smart[$i]['discount_popup_user'] = $dhtml; + + } + } + + ## Get the checkout plugin details: + if(!empty($result->fields['checkout_plugin_data'])) { + $plugin_data = unserialize($result->fields['checkout_plugin_data']); + if(is_array($plugin_data)) { + $smart[$i]['checkout_plugin_data'] = $plugin_data; + } else { + $smart[$i]['checkout_plugin_data'] = Array(0 => $result->fields['checkout_plugin_data']); + } + } + + ## Get the line items: + $q = "SELECT * FROM ".AGILE_DB_PREFIX."invoice_item WHERE + invoice_id = ". $db->qstr($result->fields['id'])." AND + site_id = ". $db->qstr(DEFAULT_SITE); + if($C_list->is_installed('voip')) { + $q .= " AND item_type!=5"; + } + $items = $db->Execute($q); + if ($items === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','view', $db->ErrorMsg()); + return false; + } + $ii =0; + while ( !$items->EOF ) + { + $smart_items[$ii] = $items->fields; + + // get the product attribs + if(!empty($items->fields['product_attr'])) + { + @$attrib = explode("\r\n", $items->fields['product_attr']); + $js=''; + for($attr_i = 0; $attr_i < count( $attrib ); $attr_i++) + { + $attributei = explode('==', $attrib[$attr_i]); + if(!empty($attributei[0]) && !empty($attributei[1])) { + $js .= "" . $attributei[0] . " : ". $attributei[1] . "
"; + } + } + $smart_items[$ii]['attribute_popup'] = $js; + } + + // get the date range if set + if(!empty($items->fields['date_start']) && !empty($items->fields['date_stop'])) + { + $C_translate->value('invoice','start', date(UNIX_DATE_FORMAT,$items->fields['date_start'])); + $C_translate->value('invoice','stop', date(UNIX_DATE_FORMAT,$items->fields['date_stop'])); + $smart_items[$ii]['range'] = $C_translate->translate('recur_date_range','invoice',''); + } + + // Set charge type for payment option list: + $any_new = true; + if ($items->fields["price_type"] == '1' && !empty($result->fields['recurr_arr']) && is_array(unserialize($result->fields['recurr_arr']))) + $any_recurring = true; + $items->MoveNext(); + $ii++; + } + + ## Create a summary (for duplicate skus w/identical price,and attributes, roll into a single value + if($this->summarizeInvoice) { + $tmp = $smart_items; + unset($smart_items); + $smart_items = $this->summarizeLineItems($tmp); + } + + ### GET THE CHECKOUT (PAYMENT) OPTIONS + if($VAR['_page'] != 'invoice:view') + { + # get the converted amount due: + if($result->fields['billed_currency_id'] != $result->fields['actual_billed_currency_id']) + { + global $C_list; + $CURRENCY = $result->fields['actual_billed_currency_id']; + if($result->fields['billed_amt'] <= 0) + $total = $C_list->format_currency_decimal ($result->fields['total_amt'], $CURRENCY); + else + $total = $C_list->format_currency_decimal ($result->fields['total_amt'], $CURRENCY) - $result->fields['actual_billed_amt']; + } else { + $CURRENCY = $result->fields['billed_currency_id']; + $total = $result->fields['total_amt']-$result->fields['billed_amt']; + } + + $q = "SELECT * FROM ".AGILE_DB_PREFIX."checkout WHERE site_id = ". DEFAULT_SITE ." AND active = 1"; + if($any_trial) $q .= " AND allow_trial = ".$db->qstr('1'); + if($any_recurring) $q .= " AND allow_recurring = ".$db->qstr('1'); + if($any_new) $q .= " AND allow_new = ".$db->qstr('1'); + $chopt = $db->Execute($q); + if ($chopt === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','view', $db->ErrorMsg()); + return false; + } + if($chopt != false && $chopt->RecordCount() > 0) { + while( !$chopt->EOF ) { + $show = true; + + # Check that the cart total is not to high: + if ( $chopt->fields["total_maximum"] != "" && + $result->fields['total_amt'] >= $chopt->fields["total_maximum"] ) { + $show = false; + } + + # Check that the cart total is not to low: + if ( $chopt->fields["total_miniumum"] != "" && + $result->fields['total_amt'] <= $chopt->fields["total_miniumum"] ) { + $show = false; + } + + # Check that the group requirement is met: + if ( $show && !empty ( $chopt->fields["required_groups"] ) ) { + global $C_auth; + $arr = unserialize ( $chopt->fields["required_groups"] ); + if(count($arr) > 0 && !empty($arr[0])) $show = false; + for ( $i=0; $iauth_group_by_id($arr[$i])) { + $show = true; + $i=count($arr); + } + } + } + + # Check that the customer is not ordering a blocked SKU: + if ( $show && !empty ( $chopt->fields["excluded_products"] ) ) { + $arr = unserialize ( $chopt->fields["excluded_products"] ); + if(count($arr) > 0) { + for($i=0; $ifields["default_when_amount"] ) ) { + $arr = unserialize ( $chopt->fields["default_when_amount"] ); + for ( $idx=0; $idx= $arr[$idx] ) $list_ord--; + $idx=count($arr); + } + } + + # By Currency + if ( !empty ( $chopt->fields["default_when_currency"] ) ) { + $arr = unserialize ( $chopt->fields["default_when_currency"] ); + for ( $idx=0; $idxfields["default_when_group"] ) ) { + $arr = unserialize ( $chopt->fields["default_when_group"] ); + global $C_auth; + for ( $idx=0; $idxauth_group_by_id( $arr[$idx] ) ) $list_ord--; + $idx=count($arr); + } + } + + # By Country + if ( !empty ( $chopt->fields["default_when_country"] ) ) { + $arr = unserialize ( $chopt->fields["default_when_country"] ); + for ( $idx=0; $idxfields["country_id"] == $arr[$idx] ) $list_ord--; + $idx=count($arr); + } + } + + # Add to the array + $checkout_optionsx[] = Array ('sort' => $list_ord, + 'fields' => $chopt->fields); + } + $chopt->MoveNext(); + } + + # Sort the checkout_options array by the [fields] element + if(count($checkout_optionsx) > 0 ) { + foreach ( $checkout_optionsx as $key => $row ) + $sort[$key] = $row["sort"]; + array_multisort ( $sort, SORT_ASC, $checkout_optionsx ); + } + } + } + + $result->MoveNext(); + $i++; + } + + + # get the result count: + $results = $result->RecordCount(); + + ### No results: + if($result->RecordCount() == 0) + { + global $C_debug; + $C_debug->error("CORE:database.inc.php", "view()", "The selected record does not + exist any longer, or your account is not authorized to view it"); + return; + } + + # define the DB vars as a Smarty accessible block + global $smarty; + + # define the results + $smarty->assign('cart', $smart_items); + $smarty->assign($this->table, $smart); + #$smarty->assign('results', $search->results); + $smarty->assign('checkoutoptions', $checkout_optionsx); + } + } + + /** UPDATE + */ + function update($VAR) + { + $this->invoice_construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + /** DELETE + */ + function delete($VAR) + { + $this->invoice_construct(); + $dbx = new CORE_database; + $db = &DB(); + + ### Get the array + if(isset($VAR["delete_id"])) + $id = split(',', $VAR["delete_id"]); + elseif (isset($VAR["id"])) + $id = split(',', $VAR["id"]); + + ### Load the service module + include_once(PATH_MODULES.'service/service.inc.php'); + $service = new service; + + ### Loop: + for($i=0; $iinvoice_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + /** SEARCH + */ + function search($VAR) + { + $this->invoice_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + + $db = &DB(); + + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + + # set the search criteria array + $arr = $VAR; + + # convert invoice_discount_arr + if(!empty($VAR['invoice_discount_arr'])) + $arr['invoice_discount_arr'] = '%"'.$VAR['invoice_discount_arr'].'"%'; + + + # loop through the submitted field_names to get the WHERE statement + $where_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + if($value != '') + { + $pat = "^" . $this->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"]) && $this->field["$field"]["convert"] != 'array') + { + $value = $validate->convert($field, $value, $this->field["$field"]["convert"]); + } + + $where_list .= " WHERE ".AGILE_DB_PREFIX."invoice.".$field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $this->module.'_'.$field; + $VAR['field_option']["$pat_field"]["$i_arr"]; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"]) && $this->field["$field"]["convert"] != 'array') + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $this->field["$field"]["convert"]); + } + + + if($i_arr == 0) + { + $where_list .= " WHERE ".AGILE_DB_PREFIX."invoice.".$field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + else + { + $where_list .= " AND ".AGILE_DB_PREFIX."invoice.".$field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + } + else + { + $where_list .= " WHERE ".AGILE_DB_PREFIX."invoice.".$field . " = " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + else + { + if($value != '') + { + $pat = "^" . $this->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"]) && $this->field["$field"]["convert"] != 'array') + { + $value = $validate->convert($field, $value, $this->field["$field"]["convert"]); + } + + $where_list .= " AND ".AGILE_DB_PREFIX."invoice.".$field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $this->module.'_'.$field; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"]) && $this->field["$field"]["convert"] != 'array') + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $this->field["$field"]["convert"]); + } + + $where_list .= " AND ".AGILE_DB_PREFIX."invoice.". $field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + else + { + $where_list .= " AND ".AGILE_DB_PREFIX."invoice.". $field . " = ". $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + } + + + + # Code for attribute searches: + if(!empty($VAR['join_product_id']) && !empty($VAR['item_attributes'])) + { + $attr_arr = $VAR['item_attributes']; + for($ati=0; $atiqstr("%{$attr_arr[$ati]['0']}=={$attr_arr[$ati]['1']}%"); + } + } + } + + # get limit type + if(isset($VAR['limit'])) + { + $limit = $VAR['limit']; + } + else + { + $limit = $this->limit; + } + + # get order by + if(isset($VAR['order_by'])) + { + $order_by = $VAR['order_by']; + } + else + { + $order_by = $this->order_by; + } + + + ## SELECT FROM + $p = AGILE_DB_PREFIX; + $q = "SELECT DISTINCT {$p}invoice.id FROM ".AGILE_DB_PREFIX."invoice "; + $q_save = "SELECT DISTINCT %%fieldList%%,{$p}invoice.id FROM {$p}invoice "; + + ## LEFT JOIN + if( !empty($VAR['join_product_id']) || !empty($VAR['join_service_id']) || + !empty($VAR['join_domain_name']) || !empty($VAR['join_domain_tld']) || + !empty($VAR['join_memo_text']) ) + { + # JOIN ON PRODUCT DETAILS: + if(!empty($VAR['join_product_id']) || !empty($VAR['join_service_id']) || !empty($VAR['join_domain_name']) || !empty($VAR['join_domain_tld'])) + { + $q .= " LEFT JOIN {$p}invoice_item ON {$p}invoice_item.invoice_id = {$p}invoice.id"; + $q_save .= " LEFT JOIN {$p}invoice_item ON {$p}invoice_item.invoice_id = {$p}invoice.id"; + + if($where_list == '') { + $q .= " WHERE {$p}invoice_item.site_id = " . $db->qstr(DEFAULT_SITE); + $q_save .= " WHERE {$p}invoice_item.site_id = " . $db->qstr(DEFAULT_SITE); + } else { + $q .= $where_list ." AND {$p}invoice_item.site_id = " . $db->qstr(DEFAULT_SITE); + $q_save .= $where_list ." AND {$p}invoice_item.site_id = " . $db->qstr(DEFAULT_SITE); + } + + # AND (invoice_item.product_id) + if(!empty($VAR['join_product_id'])) { + $q .= " AND {$p}invoice_item.product_id = " . $db->qstr($VAR['join_product_id']); + $q_save .= " AND {$p}invoice_item.product_id = " . $db->qstr($VAR['join_product_id']); + } + + # AND (invoice_item.service_id) + if(!empty($VAR['join_service_id'])) { + $q .= " AND {$p}invoice_item.service_id = " . $db->qstr($VAR['join_service_id']); + $q_save .= " AND {$p}invoice_item.service_id = " . $db->qstr($VAR['join_service_id']); + } + + # AND (invoice_item.domain_name) + if(!empty($VAR['join_domain_name'])) { + if(!ereg('%',$VAR['join_domain_name']) ) $qtype = ' = '; else $qtype = ' LIKE '; + $q .= " AND {$p}invoice_item.domain_name $qtype " . $db->qstr($VAR['join_domain_name']); + $q_save .= " AND {$p}invoice_item.domain_name $qtype " . $db->qstr($VAR['join_domain_name']); + + } + + # AND (invoice_item.domain_tld) + if(!empty($VAR['join_domain_tld'])) { + if(!ereg('%',$VAR['join_domain_tld']) ) $qtype = ' = '; else $qtype = ' LIKE '; + $q .= " AND {$p}invoice_item.domain_tld $qtype " . $db->qstr($VAR['join_domain_tld']); + $q_save .= " AND {$p}invoice_item.domain_tld $qtype " . $db->qstr($VAR['join_domain_tld']); + } + } + + # JOIN ON MEMO TEXT: + if(!empty($VAR['join_memo_text'])) + { + $q .= " LEFT JOIN {$p}invoice_memo ON {$p}invoice_memo.invoice_id = {$p}invoice.id"; + $q_save .= " LEFT JOIN {$p}invoice_memo ON {$p}invoice_memo.invoice_id = {$p}invoice.id"; + + if($where_list == '') { + $q .= " WHERE {$p}invoice_memo.site_id = " . $db->qstr(DEFAULT_SITE); + $q_save .= " WHERE {$p}invoice_memo.site_id = " . $db->qstr(DEFAULT_SITE); + } else { + $q .= $where_list ." AND {$p}invoice_memo.site_id = " . $db->qstr(DEFAULT_SITE); + $q_save .= $where_list ." AND {$p}invoice_memo.site_id = " . $db->qstr(DEFAULT_SITE); + } + + $q .= " AND {$p}invoice_memo.memo LIKE " . $db->qstr('%'. $VAR['join_memo_text'] .'%'); + $q_save .= " AND {$p}invoice_memo.memo LIKE " . $db->qstr('%'. $VAR['join_memo_text'] .'%'); + } + + $q .= " AND {$p}invoice.site_id = ". DEFAULT_SITE; + $q_save .= ' AND '; + } + else + { + if($where_list == '') { + $q .= "WHERE {$p}invoice.site_id = ". DEFAULT_SITE; + $q_save .= ' WHERE '; + } + else + { + $q .= $where_list . " AND {$p}invoice.site_id = ". DEFAULT_SITE; + $q_save .= $where_list . ' AND '; + } + } + + + ///////////////// debug + #echo $q; + #exit; + + # run the database query + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('invoice.inc.php','search', $db->ErrorMsg()); + return false; + } + + # get the result count: + $results = $result->RecordCount(); + + # get the first record id: + if($results == 1) $record_id = $result->fields['id']; + + # define the DB vars as a Smarty accessible block + global $smarty; + + # Create the definition for fast-forwarding to a single record: + if ($results == 1 && !isset($this->fast_forward)) + { + $smarty->assign('record_id', $record_id); + } + + # create the search record: + if($results > 0) + { + # create the search record + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $arr['module'] = $this->module; + $arr['sql'] = $q_save; + $arr['limit'] = $limit; + $arr['order_by']= $order_by; + $arr['results'] = $results; + $search->add($arr); + + # define the search id and other parameters for Smarty + $smarty->assign('search_id', $search->id); + + # page: + $smarty->assign('page', '1'); + + # limit: + $smarty->assign('limit', $limit); + + # order_by: + $smarty->assign('order_by', $order_by); + } + + # define the result count + $smarty->assign('results', $results); + } + + /** SEARCH SHOW + */ + function search_show($VAR) + { + $this->invoice_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + + # set the field list for this method: + $arr = $this->method[$type]; + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $this->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . "invoice" . "." . $value; + + // determine if this record is linked to another table/field + if($this->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $this->field[$value]["asso_table"], 'link_field' => $this->field[$value]["asso_field"]); + } + } + else + { + $field_var = $this->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . "invoice" . "." . $value; + + // determine if this record is linked to another table/field + if($this->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $this->field[$value]["asso_table"], 'link_field' => $this->field[$value]["asso_field"]); + } + } + $i++; + } + + + # get the search details: + if(isset($VAR['search_id'])) { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } else { + # invalid search! + echo '
The search terms submitted were invalid!'; # translate... # alert + + if(isset($this->trigger["$type"])) { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") { + $order_by = ' ORDER BY ' . $VAR['order_by']; + $smarty_order = $VAR['order_by']; + } else { + $order_by = ' ORDER BY ' . $this->order_by; + $smarty_order = $search->order_by; + } + + + # determine the sort order + if(isset($VAR['desc'])) { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } else if(isset($VAR['asc'])) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + if (!eregi('date',$smarty_order)) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } + } + + + # determine the offset & limit + $current_page=1; + $offset=-1; + if (!empty($VAR['page'])) $current_page = $VAR['page']; + if (empty($search->limit)) $search->limit=25; + if($current_page>1) $offset = (($current_page * $search->limit) - $search->limit); + + # generate the full query + $db = &DB(); + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " ".AGILE_DB_PREFIX . "invoice.site_id = '" . DEFAULT_SITE . "'"; + $q .= $order_by; + + ////////////////// + #echo "
$q
"; + + $result = $db->SelectLimit($q, $search->limit, $offset); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('invoice.inc.php','search', $db->ErrorMsg()); + + if(isset($this->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + return; + } + + + # put the results into a smarty accessable array + $i=0; + $class_name = TRUE; + while (!$result->EOF) { + $smart[$i] = $result->fields; + $amount += $result->fields['total_amt']; + if($class_name) + { + $smart[$i]['_C'] = 'row1'; + $class_name = FALSE; + } else { + $smart[$i]['_C'] = 'row2'; + $class_name = TRUE; + } + + $result->MoveNext(); + $i++; + } + + + # get any linked fields + if($i > 0) + { + $db_join = new CORE_database; + $this->result = $db_join->join_fields($smart, $this->linked); + } + else + { + $this->result = $smart; + } + + # get the result count: + $results = $result->RecordCount(); + + # define the DB vars as a Smarty accessible block + global $smarty; + + # define the results + $smarty->assign($this->table, $this->result); + $smarty->assign('page', $VAR['page']); + $smarty->assign('order', $smarty_order); + $smarty->assign('sort', $smarty_sort); + $smarty->assign('limit', $search->limit); + $smarty->assign('search_id',$search->id); + $smarty->assign('results', $search->results); + + global $C_list; + $smarty->assign('total_amount', $C_list->format_currency($amount,DEFAULT_CURRENCY)); + + # get the total pages for this search: + if(empty($search->limit)) + $this->pages = 1; + else + $this->pages = intval($search->results / $search->limit); + if ($search->results % $search->limit) $this->pages++; + + # total pages + $smarty->assign('pages', $this->pages); + + # current page + $smarty->assign('page', $current_page); + $page_arr = ''; + for($i=0; $i <= $this->pages; $i++) + { + if ($this->page != $i) $page_arr[] = $i; + } + + # page array for menu + $smarty->assign('page_arr', $page_arr); + } + + /** USER SEARCH + */ + function user_search($VAR) + { + if(!SESS_LOGGED) return false; + $VAR['invoice_account_id'] = SESS_ACCOUNT; + $this->invoice_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + /** USER SEARCH SHOW + */ + function user_search_show($VAR) + { + if(!SESS_LOGGED) return false; + $this->invoice_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + /** USER VIEW + */ + function user_view($VAR) + { + global $C_auth; + if(!SESS_LOGGED) return false; + + // verify the account_id for this order is the SESS_ACCOUNT + if ( $C_auth->auth_method_by_name('invoice','view') == false) + { + $id = split(',',$VAR['id']); + $db = &DB(); + $q = "SELECT account_id FROM ".AGILE_DB_PREFIX."invoice WHERE + id = ".$db->qstr($id[0])." AND + site_id = ".$db->qstr(DEFAULT_SITE); + $rs = $db->Execute($q); + if ($rs === false) { + global $C_debug; + $C_debug->error('invoice.inc.php','user_view', $db->ErrorMsg()); + return false; + } + if ($rs->fields['account_id'] != SESS_ACCOUNT) return false; + } + $this->view($VAR, $this); + } + + /** SEARCH EXPORT + */ + function search_export($VAR) + { + $this->invoice_construct(); + + # require the export class + require_once (PATH_CORE . "export.inc.php"); + + # Call the correct export function for inline browser display, download, email, or web save. + if($VAR["format"] == "excel") + { + $type = "export_excel"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_excel($VAR, $this, $type); + } + + else if ($VAR["format"] == "pdf") + { + $type = "export_pdf"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->pdf_invoice($VAR, $this, $type); + } + + else if ($VAR["format"] == "xml") + { + $type = "export_xml"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_xml($VAR, $this, $type); + } + + else if ($VAR["format"] == "csv") + { + $type = "export_csv"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_csv($VAR, $this, $type); + } + + else if ($VAR["format"] == "tab") + { + $type = "export_tab"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_tab($VAR, $this, $type); + } + } + + function invoice_construct() + { + $this->module = "invoice"; + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + include_once(PATH_CORE.'xml.inc.php'); + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } +} +?> \ No newline at end of file diff --git a/modules/invoice/invoice_construct.xml b/modules/invoice/invoice_construct.xml new file mode 100644 index 00000000..3634b321 --- /dev/null +++ b/modules/invoice/invoice_construct.xml @@ -0,0 +1,182 @@ + + + + invoice + + invoice
+ + + + 0 + + date_orig + + 25 + + + date_orig + date_last + parent_id + billing_status + process_status + suspend_billing + refund_status + account_id + affiliate_id + campaign_id + reseller_id + total_amt + due_date + checkout_plugin_id + tax_id + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I8 + date-time + + + I8 + date-now + + + I4 + + + L + + + L + + + L + + + L + + + L + + + L + + + I8 + account + first_name,last_name + + + I4 + + + C(32) + + + I4 + + + L + + + C(32) + + + I4 + + + C(255) + array + + + I4 + + + F + + + C(255) + array + + + F + + + F + + + F + + + F + + + I4 + + + F + + + I4 + + + I4 + + + I4 + + + I8 + date-time + + + I4 + + + I8 + date-time + + + X + + + X + + + L + + + I8 + + + I4 + + + C(32) + + + + + id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date + id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals + id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date + id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals,ip + id,site_id,date_orig,date_last,type,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,checkout_plugin_data,tax_id,tax_amt,discount_arr,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals,ip + id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals + id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals + id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals + id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals + id,date_orig,date_last,process_status,billing_status,suspend_billing,print_status,account_id,account_billing_id,affiliate_id,campaign_id,reseller_id,checkout_plugin_id,tax_id,tax_amt,discount_amt,total_amt,billed_amt,billed_currency_id,actual_billed_amt,actual_billed_currency_id,notice_count,notice_max,notice_next_date,grace_period,due_date,net_term_date_last,net_term_id,net_term_intervals + + + 0 +
diff --git a/modules/invoice/invoice_fpdf.inc.php b/modules/invoice/invoice_fpdf.inc.php new file mode 100644 index 00000000..82af25b7 --- /dev/null +++ b/modules/invoice/invoice_fpdf.inc.php @@ -0,0 +1,393 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +require_once(PATH_INCLUDES.'pdf/fpdf.php'); +define('EURO', chr(128) ); +define('EURO_VAL', 6.55957 ); + +class INVOICE_FPDF extends FPDF +{ + // private variables + var $colonnes; + var $format; + var $angle=0; + + // private functions + function RoundedRect($x, $y, $w, $h, $r, $style = '') + { + $k = $this->k; + $hp = $this->h; + if($style=='F') + $op='f'; + elseif($style=='FD' or $style=='DF') + $op='B'; + else + $op='S'; + $MyArc = 4/3 * (sqrt(2) - 1); + $this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k )); + $xc = $x+$w-$r ; + $yc = $y+$r; + $this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k )); + + $this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc); + $xc = $x+$w-$r ; + $yc = $y+$h-$r; + $this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k)); + $this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r); + $xc = $x+$r ; + $yc = $y+$h-$r; + $this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k)); + $this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc); + $xc = $x+$r ; + $yc = $y+$r; + $this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k )); + $this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r); + $this->_out($op); + } + + function _Arc($x1, $y1, $x2, $y2, $x3, $y3) + { + $h = $this->h; + $this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k, + $x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k)); + } + + function Rotate($angle,$x=-1,$y=-1) + { + if($x==-1) + $x=$this->x; + if($y==-1) + $y=$this->y; + if($this->angle!=0) + $this->_out('Q'); + $this->angle=$angle; + if($angle!=0) + { + $angle*=M_PI/180; + $c=cos($angle); + $s=sin($angle); + $cx=$x*$this->k; + $cy=($this->h-$y)*$this->k; + $this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy)); + } + } + + function _endpage() + { + if($this->angle!=0) + { + $this->angle=0; + $this->_out('Q'); + } + parent::_endpage(); + } + + // public functions + function sizeOfText( $texte, $largeur ) + { + $index = 0; + $nb_lines = 0; + $loop = TRUE; + while ( $loop ) + { + $pos = strpos($texte, "\n"); + if (!$pos) + { + $loop = FALSE; + $ligne = $texte; + } + else + { + $ligne = substr( $texte, $index, $pos); + $texte = substr( $texte, $pos+1 ); + } + $length = floor( $this->GetStringWidth( $ligne ) ); + //$res = 1 + floor( $length / $largeur) ; + $nb_lines += $res; + } + return $nb_lines; + } + + // Company + function addCompany( $nom, $adresse ) + { + $this->Image(PATH_THEMES.'default/images/invoice_logo.jpg',11,8,50); + $x1 = 10; + $y1 = 20; + $this->SetXY( $x1, $y1 ); + $this->SetFont('Arial','B',12); + $length = $this->GetStringWidth( $nom ); + $this->Cell( $length, 2, $nom); + $this->SetXY( $x1, $y1 + 4 ); + $this->SetFont('Arial','',10); + $length = $this->GetStringWidth( $adresse ); + $lignes = $this->sizeOfText( $adresse, $length) ; + $this->MultiCell($length, 4, $adresse); + } + + function addDate( $date ) + { + global $C_translate; + + $r1 = $this->w - 40; + $r2 = $r1 + 30; + $y1 = 8; + $y2 = $y1 ; + $mid = $y1 + ($y2 / 2); + $this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 3.5, 'D'); + $this->Line( $r1, $mid, $r2, $mid); + $this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 ); + $this->SetFont( "Helvetica", "B", 10); + $this->Cell(10,5, $C_translate->translate('pdf_date','invoice',''), 0, 0, "C"); + $this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+4 ); + $this->SetFont( "Helvetica", "", 10); + $this->Cell(10,5,$date, 0,0, "C"); + } + + function addPageNumber( $page ) + { + global $C_translate; + + $r1 = $this->w - 59; + $r2 = $r1 + 19; + $y1 = 8; + $y2 = $y1; + $mid = $y1 + ($y2 / 2); + $this->RoundedRect($r1, $y1, ($r2 - $r1), $y2, 3.5, 'D'); + $this->Line( $r1, $mid, $r2, $mid); + $this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1 ); + $this->SetFont( "Helvetica", "B", 10); + $this->Cell(10,5, $C_translate->translate('pdf_page','invoice',''), 0, 0, "C"); + $this->SetXY( $r1 + ($r2-$r1)/2 - 5, $y1+4 ); + $this->SetFont( "Helvetica", "", 10); + $this->Cell(10,5,$page, 0,0, "C"); + } + + // Client address + function addClient( $adresse ) + { + $r1 = 140; + $r2 = $r1 + 68; + $y1 = 35; + $this->SetXY( $r1, $y1); + $this->MultiCell( 60, 4, $adresse); + } + + // Invoice number + function addInvoiceNo($id) + { + global $C_translate; + + $r1 = 10; + $r2 = $r1 + 60; + $y1 = 65; + $y2 = $y1+10; + $mid = $y1 + (($y2-$y1) / 2); + $this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D'); + $this->Line( $r1, $mid, $r2, $mid); + $this->SetXY( $r1 + ($r2-$r1)/2 - 20 , $y1+1 ); + $this->SetFont( "Helvetica", "B", 10); + $this->Cell(40, 4, $C_translate->translate('pdf_invoice_number','invoice',''), 0, 0, "C"); + $this->SetFont( "Helvetica", "", 10); + $this->SetXY( $r1 + 9 , $y1+5 ); + $this->Cell(40, 5, $id, '', '', "C"); + } + + // Payment Status + function addStatus( $mode ) + { + global $C_translate; + + $r1 = 75; + $r2 = $r1 + 60; + $y1 = 65; + $y2 = $y1+10; + $mid = $y1 + (($y2-$y1) / 2); + $this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D'); + $this->Line( $r1, $mid, $r2, $mid); + $this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1+1 ); + $this->SetFont( "Helvetica", "B", 10); + $this->Cell(10,4, $C_translate->translate('pdf_payment_status','invoice',''), 0, 0, "C"); + $this->SetXY( $r1 + ($r2-$r1)/2 -5 , $y1 + 5 ); + $this->SetFont( "Helvetica", "", 10); + $this->Cell(10,5,$mode, 0,0, "C"); + } + + // Due date + function addDueDate( $date ) + { + global $C_translate; + + $r1 = 140; + $r2 = $r1 + 60; + $y1 = 65; + $y2 = $y1+10; + $mid = $y1 + (($y2-$y1) / 2); + $this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D'); + $this->Line( $r1, $mid, $r2, $mid); + $this->SetXY( $r1 + ($r2 - $r1)/2 - 5 , $y1+1 ); + $this->SetFont( "Helvetica", "B", 10); + $this->Cell(10,4, $C_translate->translate('pdf_date_due','invoice',''), 0, 0, "C"); + $this->SetXY( $r1 + ($r2-$r1)/2 - 5 , $y1 + 5 ); + $this->SetFont( "Helvetica", "", 10); + $this->Cell(10,5,$date, 0,0, "C"); + } + + function addCols( $tab ) + { + global $colonnes; + + $r1 = 10; + $r2 = $this->w - ($r1 * 2) ; + $y1 = 80; + $y2 = $this->h - 50 - $y1; + $this->SetXY( $r1, $y1 ); + $this->Rect( $r1, $y1, $r2, $y2, "D"); + $this->Line( $r1, $y1+6, $r1+$r2, $y1+6); + $colX = $r1; + $colonnes = $tab; + while ( list( $lib, $pos ) = each ($tab) ) + { + $this->SetXY( $colX, $y1+2 ); + $this->Cell( $pos, 1, $lib, 0, 0, "C"); + $colX += $pos; + $this->Line( $colX, $y1, $colX, $y1+$y2); + } + } + + function addLineFormat( $tab ) + { + global $format, $colonnes; + + while ( list( $lib, $pos ) = each ($colonnes) ) + { + if ( isset( $tab["$lib"] ) ) + $format[ $lib ] = $tab["$lib"]; + } + } + + function lineVert( $tab ) + { + global $colonnes; + + reset( $colonnes ); + $maxSize=0; + while ( list( $lib, $pos ) = each ($colonnes) ) + { + $texte = $tab[ $lib ]; + $longCell = $pos -2; + $size = $this->sizeOfText( $texte, $longCell ); + if ($size > $maxSize) + $maxSize = $size; + } + return $maxSize; + } + + function addLine( $ligne, $tab ) + { + global $colonnes, $format; + + $ordonnee = 10; + $maxSize = $ligne; + + reset( $colonnes ); + while ( list( $lib, $pos ) = each ($colonnes) ) + { + $longCell = $pos -2; + $texte = $tab[ $lib ]; + $length = $this->GetStringWidth( $texte ); + $tailleTexte = $this->sizeOfText( $texte, $length ); + $formText = $format[ $lib ]; + $this->SetXY( $ordonnee, $ligne-1); + $this->MultiCell( $longCell, 4 , $texte, 0, $formText); + if ( $maxSize < ($this->GetY() ) ) + $maxSize = $this->GetY() ; + $ordonnee += $pos; + } + return ( $maxSize - $ligne ); + } + + function addTotals($a, $b, $a_total, $a_paid, $a_due, $b_total, $b_paid, $b_due, $a_disc, $b_disc) + { + global $C_translate; + + $r1 = $this->w - 102; + $r2 = $r1 + 92; + $y1 = $this->h - 45; + $y2 = $y1+25; + $this->RoundedRect($r1, $y1, ($r2 - $r1), ($y2-$y1), 2.5, 'D'); + $this->Line( $r1+20, $y1, $r1+20, $y2); // avant EUROS + $this->Line( $r1+20, $y1+4, $r2, $y1+4); // Sous Euros & Francs + $this->Line( $r1+55, $y1, $r1+55, $y2); // Entre Euros & Francs + $this->SetFont( "Arial", "B", 8); + $this->SetXY( $r1+30, $y1 ); + $this->Cell(15,4, $a, 0, 0, "C"); + $this->SetFont( "Arial", "", 8); + $this->SetXY( $r1+65, $y1 ); + $this->Cell(15,4, $b, 0, 0, "C"); + $this->SetFont( "Arial", "B", 6); + + $this->SetXY( $r1, $y1+5 ); + $this->Cell(20,4, $C_translate->translate('pdf_discounts','invoice',''), 0, 0, "C"); + $this->SetXY( $r1, $y1+10 ); + $this->Cell(20,4, $C_translate->translate('pdf_total','invoice',''), 0, 0, "C"); + $this->SetXY( $r1, $y1+15 ); + $this->Cell(20,4, $C_translate->translate('pdf_paid','invoice',''), 0, 0, "C"); + $this->SetXY( $r1, $y1+20 ); + $this->Cell(20,4, $C_translate->translate('pdf_due','invoice',''), 0, 0, "C"); + + $re = $this->w - 65; + $rf = $this->w - 28; + $y1 = $this->h - 40; + + // A total + $this->SetFont( "Arial", "", 8); + $this->SetXY( $re, $y1+0 ); + $this->Cell( 17,4, $a_disc, '', '', 'R'); + $this->SetXY( $re, $y1+5 ); + $this->Cell( 17,4, $a_total, '', '', 'R'); + $this->SetXY( $re, $y1+10 ); + $this->Cell( 17,4, $a_paid, '', '', 'R'); + $this->SetXY( $re, $y1+15 ); + $this->Cell( 17,4, $a_due, '', '', 'R'); + $this->SetXY( $rf, $y1+5 ); + + // B Total + if(!empty($b)) { + $this->Cell( 17,4, $b_total, '', '', 'R'); + $this->SetXY( $rf, $y1+10 ); + $this->Cell( 17,4, $b_paid, '', '', 'R'); + $this->SetXY( $rf, $y1+14.8 ); + $this->Cell( 17,4, $b_due, '', '', 'R'); + } + } + + // watermark + function addWatermark( $text ) + { + $this->SetFont('Arial','B',50); + $this->SetTextColor(203,203,203); + $this->Rotate(0); + $this->Text(10,50,$text); + $this->Rotate(0); + $this->SetTextColor(0,0,0); + } +} +?> \ No newline at end of file diff --git a/modules/invoice/invoice_install.xml b/modules/invoice/invoice_install.xml new file mode 100644 index 00000000..b538d418 --- /dev/null +++ b/modules/invoice/invoice_install.xml @@ -0,0 +1,65 @@ + + + invoice + invoice + + 1 + + + + + add + 1 + + + update + + + delete + + + view + + 1 + + + search + + 1 + + + search_form + + + search_show + + + resend + + + search_export + + + approveinvoice + + + voidinvoice + + + performance + + + refund + + + reconcile + + + autobill + + + generatedomaininvoice + + + + \ No newline at end of file diff --git a/modules/invoice/receipt_print.php b/modules/invoice/receipt_print.php new file mode 100644 index 00000000..bb13b33a --- /dev/null +++ b/modules/invoice/receipt_print.php @@ -0,0 +1,93 @@ + + * @package AgileBill + * @version 1.4.93 + */ + + +/** + * This module creates a printable pdf reciept on manual invoice reconciliation suitable for retail printing. + * To enable, simply change "var $active=false;" to "var $active=true" below. + * When an invoice is reconciled from the admin menu, a PDF will be displayed inline, and you can use the print + * feature in the inline acrobat reader to print. + */ + +require_once(PATH_INCLUDES.'pdf/fpdf.php'); + +class receipt_print extends FPDF +{ + var $active=false; + var $save_path = ''; + + function add(&$invoiceRs, $payment_amt, $paid_amt) { + + if(!$this->active) return false; + + ob_start(); + + $this->AddPage(); + $this->SetFont('Arial','B',10); + + $this->drawCompanyLogo(); + $this->drawCompanyAddress(); + + $this->SetXY(0,50); + $this->Cell(50,10,"*** INVOICE# {$invoiceRs->fields['id']} ***"); + + $this->SetXY(0,60); + $this->Cell(50,10,"DATE ".date("d/m/Y D H:i")); + + $this->SetXY(0,70); $this->Cell(50,5,"INVOICE TOTAL: "); + $this->SetXY(45,70); $this->Cell(50,5, number_format($invoiceRs->fields['total_amt'],2)); + + $this->SetXY(0,75); $this->Cell(50,5,"PREV AMT DUE: " ); + $this->SetXY(45,75); $this->Cell(50,5, number_format($invoiceRs->fields['total_amt']-$invoiceRs->fields['billed_amt'],2)); + + $this->SetXY(0,80); $this->Cell(50,5,"CURRENT PAYMENT: " ); + $this->SetXY(45,80); $this->Cell(50,5, $payment_amt); + + $this->SetXY(0,85); $this->Cell(50,5,"PAID TO DATE: " ); + $this->SetXY(45,85); $this->Cell(50,5, number_format($paid_amt,2)); + + $this->SetXY(0,90); $this->Cell(50,5,"CURRENY AMT DUE: " ); + $this->SetXY(45,90); $this->Cell(50,5, number_format($invoiceRs->fields['total_amt']-$paid_amt,2)); + + $this->SetXY(0,100); $this->Cell(50,5,"Thank You!" ); + + $this->Output(); + + ob_flush(); + } + + + // draw the logo + function drawCompanyLogo() { + $width = 50; + if(is_file(PATH_THEMES.'default/images/invoice_logo.jpg')) + $this->Image(PATH_THEMES.'default/images/invoice_logo.jpg',0,0,$width); + } + + // draw the company address + function drawCompanyAddress() { + // add the company address on the payment stub (1) + $this->SetFont('times','B', 10); + $this->SetXY(0,30); $this->Cell(50,10, SITE_NAME); + $this->SetXY(0,35); $this->Cell(50,10, SITE_ADDRESS); + $this->SetXY(0,40); $this->Cell(50,10, SITE_CITY. ", ". SITE_STATE . " " . SITE_ZIP); + } +} +?> \ No newline at end of file diff --git a/modules/invoice_commission/invoice_commission.inc.php b/modules/invoice_commission/invoice_commission.inc.php new file mode 100644 index 00000000..d6dff18d --- /dev/null +++ b/modules/invoice_commission/invoice_commission.inc.php @@ -0,0 +1,47 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class invoice_commission +{ + + # Open the constructor for this mod + function invoice_commission() + { + # name of this module: + $this->module = "invoice_commission"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } +} +?> \ No newline at end of file diff --git a/modules/invoice_commission/invoice_commission_construct.xml b/modules/invoice_commission/invoice_commission_construct.xml new file mode 100644 index 00000000..bd93b85d --- /dev/null +++ b/modules/invoice_commission/invoice_commission_construct.xml @@ -0,0 +1,60 @@ + + + + invoice_commission + + invoice_commission
+ + invoice + + 0 + + invoice_id + + 25 + + + date_orig + affiliate_commission_id + invoice_id + affiliate_id + status + + + + + I8 + 1 + 1 + + + I4 + 1 + + + I8 + + + I8 + + + I4 + + + I8 + + + C(32) + + + F + + + L + + + + + + 0 +
diff --git a/modules/invoice_commission/invoice_commission_install.xml b/modules/invoice_commission/invoice_commission_install.xml new file mode 100644 index 00000000..6a0cee59 --- /dev/null +++ b/modules/invoice_commission/invoice_commission_install.xml @@ -0,0 +1,12 @@ + + + invoice_commission + invoice + + invoice + + + + + + \ No newline at end of file diff --git a/modules/invoice_item/invoice_item.inc.php b/modules/invoice_item/invoice_item.inc.php new file mode 100644 index 00000000..f5af1553 --- /dev/null +++ b/modules/invoice_item/invoice_item.inc.php @@ -0,0 +1,126 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class invoice_item +{ + + # Open the constructor for this mod + function invoice_item() + { + # name of this module: + $this->module = "invoice_item"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/invoice_item/invoice_item_construct.xml b/modules/invoice_item/invoice_item_construct.xml new file mode 100644 index 00000000..2fc978f6 --- /dev/null +++ b/modules/invoice_item/invoice_item_construct.xml @@ -0,0 +1,130 @@ + + + + invoice_item + + invoice_item
+ + invoice + + 0 + + sku + + 25 + + + parent_id + invoice_id,site_id + product_id + account_id + service_id,site_id + service_id,invoice_id + sku + domain_name,domain_tld + date_orig + site_id,charge_id + + + + + I8 + 1 + 1 + + + I4 + 1 + + + I8 + + + I8 + + + I8 + + + I8 + + + I8 + + + I8 + + + I8 + + + C(128) + + + I4 + + + L + + + X2 + array + + + X2 + + + C(128) + + + F + + + F + + + F + + + L + + + F + + + F + + + I4 + + + C(128) + + + C(16) + + + I4 + + + C(16) + + + I8 + + + I8 + + + + + id,site_id,date_orig,invoice_id,product_id,sku,quantity,item_type,product_attr,product_attr_cart,price_base,price_setup,recurring_schedule,domain_name,domain_tld,domain_term,domain_type,invoice_item_parent_id + id,site_id,date_orig,invoice_id,product_id,sku,quantity,item_type,product_attr,product_attr_cart,price_base,price_setup,recurring_schedule,domain_name,domain_tld,domain_term,domain_type,invoice_item_parent_id + id,site_id,date_orig,invoice_id,product_id,sku,quantity,item_type,product_attr,product_attr_cart,price_base,price_setup,recurring_schedule,domain_name,domain_tld,domain_term,domain_type,invoice_item_parent_id + id,site_id,date_orig,invoice_id,product_id,sku,quantity,item_type,product_attr,product_attr_cart,price_base,price_setup,recurring_schedule,domain_name,domain_tld,domain_term,domain_type,invoice_item_parent_id + id,site_id,date_orig,invoice_id,product_id,sku,quantity,item_type,product_attr,product_attr_cart,price_base,price_setup,recurring_schedule,domain_name,domain_tld,domain_term,domain_type,invoice_item_parent_id + + + 0 +
+ diff --git a/modules/invoice_item/invoice_item_install.xml b/modules/invoice_item/invoice_item_install.xml new file mode 100644 index 00000000..693898fe --- /dev/null +++ b/modules/invoice_item/invoice_item_install.xml @@ -0,0 +1,12 @@ + + + invoice_item + invoice + + invoice + + + + + + \ No newline at end of file diff --git a/modules/invoice_item_discount/invoice_item_discount.inc.php b/modules/invoice_item_discount/invoice_item_discount.inc.php new file mode 100644 index 00000000..6cfa47a4 --- /dev/null +++ b/modules/invoice_item_discount/invoice_item_discount.inc.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/modules/invoice_item_discount/invoice_item_discount_construct.xml b/modules/invoice_item_discount/invoice_item_discount_construct.xml new file mode 100644 index 00000000..c6590eb3 --- /dev/null +++ b/modules/invoice_item_discount/invoice_item_discount_construct.xml @@ -0,0 +1,45 @@ + + + invoice_item_discount + invoice_item_discount
+ invoice + 0 + zone + 25 + + discount + invoice_id,invoice_item_id + date_orig + account_id + + + + I4 + 1 + + + I4 + + + I8 + + + I8 + + + I8 + + + I8 + + + C(64) + + + F + + + + + 0 +
\ No newline at end of file diff --git a/modules/invoice_item_discount/invoice_item_discount_install.xml b/modules/invoice_item_discount/invoice_item_discount_install.xml new file mode 100644 index 00000000..e5016ceb --- /dev/null +++ b/modules/invoice_item_discount/invoice_item_discount_install.xml @@ -0,0 +1,13 @@ + + + invoice_item_discount + invoice + + 0 + invoice + + + + + + \ No newline at end of file diff --git a/modules/invoice_item_tax/invoice_item_tax.inc.php b/modules/invoice_item_tax/invoice_item_tax.inc.php new file mode 100644 index 00000000..49bdacdc --- /dev/null +++ b/modules/invoice_item_tax/invoice_item_tax.inc.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/modules/invoice_item_tax/invoice_item_tax_construct.xml b/modules/invoice_item_tax/invoice_item_tax_construct.xml new file mode 100644 index 00000000..717ca277 --- /dev/null +++ b/modules/invoice_item_tax/invoice_item_tax_construct.xml @@ -0,0 +1,45 @@ + + + invoice_item_tax + invoice_item_tax
+ invoice + 0 + zone + 25 + + tax_id + invoice_id,invoice_item_id + date_orig + account_id + + + + I4 + 1 + + + I4 + + + I8 + + + I8 + + + I8 + + + I8 + + + I4 + + + F + + + + + 0 +
\ No newline at end of file diff --git a/modules/invoice_item_tax/invoice_item_tax_install.xml b/modules/invoice_item_tax/invoice_item_tax_install.xml new file mode 100644 index 00000000..2e46b825 --- /dev/null +++ b/modules/invoice_item_tax/invoice_item_tax_install.xml @@ -0,0 +1,13 @@ + + + invoice_item_tax + invoice + + 0 + invoice + + + + + + \ No newline at end of file diff --git a/modules/invoice_memo/invoice_memo.inc.php b/modules/invoice_memo/invoice_memo.inc.php new file mode 100644 index 00000000..0ce943df --- /dev/null +++ b/modules/invoice_memo/invoice_memo.inc.php @@ -0,0 +1,126 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class invoice_memo +{ + + # Open the constructor for this mod + function invoice_memo() + { + # name of this module: + $this->module = "invoice_memo"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/invoice_memo/invoice_memo_construct.xml b/modules/invoice_memo/invoice_memo_construct.xml new file mode 100644 index 00000000..5fa4eab3 --- /dev/null +++ b/modules/invoice_memo/invoice_memo_construct.xml @@ -0,0 +1,63 @@ + + + + invoice_memo + + invoice_memo
+ + invoice + + 0 + + date_orig + + 25 + + + invoice_id + memo + + + + + I8 + + + I4 + + + I8 + date-time + date-now + + + C(32) + + + I8 + account + username + + + C(32) + any + + + C(255) + any + + + C(32) + + + + + id,site_id,date_orig,invoice_id,account_id,type,memo + id,site_id,date_orig,invoice_id,account_id,type,memo + id,site_id,date_orig,invoice_id,account_id,type,memo + id,site_id,date_orig,invoice_id,account_id,type,memo + id,site_id,date_orig,invoice_id,account_id,type,memo + + + 0 +
diff --git a/modules/invoice_memo/invoice_memo_install.xml b/modules/invoice_memo/invoice_memo_install.xml new file mode 100644 index 00000000..ad6cacaf --- /dev/null +++ b/modules/invoice_memo/invoice_memo_install.xml @@ -0,0 +1,35 @@ + + + invoice_memo + invoice + + invoice + + + + + add + + + update + + + delete + + + view + + + search + + + search_form + + + + search_show + + + + + \ No newline at end of file diff --git a/modules/log_error/log_error.inc.php b/modules/log_error/log_error.inc.php new file mode 100644 index 00000000..b3c3c8f8 --- /dev/null +++ b/modules/log_error/log_error.inc.php @@ -0,0 +1,167 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class log_error +{ + + # Open the constructor for this mod + function log_error() + { + # name of this module: + $this->module = "log_error"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + ############################## + ## GRAPH STATISTICS ## + ############################## + function graph($start, $end, $constraint, $default) + { + global $C_translate; + + $db = &DB(); + $sql = 'SELECT date_orig FROM ' . AGILE_DB_PREFIX . 'log_error WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + date_orig >= ' . $db->qstr($start) . ' AND + date_orig <= ' . $db->qstr($end); + + $result = $db->Execute($sql); + + if($result->RecordCount() == 0) + { + $arr['title'] = $C_translate->translate('search_no_results','',''); + $arr['results'] = $default; + return $arr; + } + + $ii=0; + while(!$result->EOF) + { + $d = $result->fields['date_orig']; + for($i=0; $i= $constraint[$i]["start"] && $d < $constraint[$i]["end"]) + $default[$i]++; + $ii++; + } + $result->MoveNext(); + } + + $C_translate->value['log_error']['count'] = $result->RecordCount(); + $title = $C_translate->translate('statistics','log_error',''); + $arr['title'] = $title; + $arr['results'] = $default; + return $arr; + } + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/log_error/log_error_construct.xml b/modules/log_error/log_error_construct.xml new file mode 100644 index 00000000..2b93c970 --- /dev/null +++ b/modules/log_error/log_error_construct.xml @@ -0,0 +1,55 @@ + + + + log_error + + log_error
+ + + + 0 + + date_orig + + 25 + + + + I8 + 1 + 1 + + + I4 + 1 + + + I8 + date + + + I8 + account + username + + + C(64) + + + C(64) + + + X2 + + + + + id,site_id,date_orig,account_id,module,method,message + id,site_id,date_orig,account_id,module,method,message + id,site_id,date_orig,account_id,module,method,message + id,site_id,date_orig,account_id,module,method,message + id,site_id,date_orig,account_id,module,method,message + + + 0 +
diff --git a/modules/log_error/log_error_install.xml b/modules/log_error/log_error_install.xml new file mode 100644 index 00000000..ff50dd6e --- /dev/null +++ b/modules/log_error/log_error_install.xml @@ -0,0 +1,37 @@ + + + log_error + setup + + 1 + + + + + search + + + 1 + + + view + + + 1 + + + delete + + + update + + + search_form + + + search_show + + + + + \ No newline at end of file diff --git a/modules/login_lock/login_lock_construct.xml b/modules/login_lock/login_lock_construct.xml new file mode 100644 index 00000000..e2257b48 --- /dev/null +++ b/modules/login_lock/login_lock_construct.xml @@ -0,0 +1,49 @@ + + + + login_lock + + login_lock
+ + + + 0 + + account_id + + 25 + + + account_id + date_expire + ip + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I8 + + + I8 + + + I8 + + + C(32) + + + + + + 0 +
diff --git a/modules/login_lock/login_lock_install.xml b/modules/login_lock/login_lock_install.xml new file mode 100644 index 00000000..27a1d10f --- /dev/null +++ b/modules/login_lock/login_lock_install.xml @@ -0,0 +1,11 @@ + + + login_lock + login_lock + + + + + + + \ No newline at end of file diff --git a/modules/login_log/login_log.inc.php b/modules/login_log/login_log.inc.php new file mode 100644 index 00000000..3e86a474 --- /dev/null +++ b/modules/login_log/login_log.inc.php @@ -0,0 +1,169 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class login_log +{ + + # Open the constructor for this mod + function login_log() + { + # name of this module: + $this->module = "login_log"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + ############################## + ## GRAPH STATISTICS ## + ############################## + function graph($start, $end, $constraint, $default) + { + global $C_translate; + + + $db = &DB(); + $sql = 'SELECT date_orig FROM ' . AGILE_DB_PREFIX . 'login_log WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + date_orig >= ' . $db->qstr($start) . ' AND + date_orig <= ' . $db->qstr($end); + + $result = $db->Execute($sql); + if($result->RecordCount() == 0) + { + $arr['title'] = $C_translate->translate('search_no_results','',''); + $arr['results'] = $default; + return $arr; + } + $ii=0; + while(!$result->EOF) + { + $d = $result->fields['date_orig']; + for($i=0; $i= $constraint[$i]["start"] && $d < $constraint[$i]["end"]) + $default[$i]++; + $ii++; + } + $result->MoveNext(); + } + + $C_translate->value['login_log']['count'] = $result->RecordCount(); + $title = $C_translate->translate('statistics_login','login_log',''); + $arr['title'] = $title; + $arr['results'] = $default; + return $arr; + } + + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/login_log/login_log_construct.xml b/modules/login_log/login_log_construct.xml new file mode 100644 index 00000000..3317d443 --- /dev/null +++ b/modules/login_log/login_log_construct.xml @@ -0,0 +1,56 @@ + + + + login_log + + login_log
+ + + + 0 + + date_orig + + 25 + + + account_id + ip + + + + + I4 + 1 + + + I4 + 1 + + + I8 + date-now + + + I8 + account + username + + + L + + + C(32) + + + + + id,site_id,date_orig,account_id,status,ip + id,site_id,date_orig,account_id,status,ip + id,site_id,date_orig,account_id,status,ip + id,site_id,date_orig,account_id,status,ip + id,site_id,date_orig,account_id,status,ip + + + 0 +
diff --git a/modules/login_log/login_log_install.xml b/modules/login_log/login_log_install.xml new file mode 100644 index 00000000..7d6665de --- /dev/null +++ b/modules/login_log/login_log_install.xml @@ -0,0 +1,32 @@ + + + login_log + account_admin + + 1 + + + + + search + + + view + + 1 + + + delete + + + update + + + search_form + + + search_show + + + + \ No newline at end of file diff --git a/modules/login_share/login_share.inc.php b/modules/login_share/login_share.inc.php new file mode 100644 index 00000000..acb7c856 --- /dev/null +++ b/modules/login_share/login_share.inc.php @@ -0,0 +1,148 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class login_share +{ + function login_share() + { + // Number of days to check when searching for shared passwords + $this->range = 7; + + // Cutoff number for different subnets - if the amount of unique + // IP addresses used to access an account is greater than this number, the + // account will be suspended. + $this->max_subnets = 5; + + // number of subnets to compare when search for shared passwords + // example: + // "4" would check the full IP address, ie: 123.456.789.123 + // "3" would check the first 3 subnets of an IP, ie: 123.456.789. (recommended) + // "2" would check the first 2 subnets of an IP, ie: 123.456. + // "1" would check the first 1 subnets of an IP, ie: 123. + $this->subnets = 3; + + // List of exempt usernames: + $this->exempt = Array('admin'); + } + + ### Detect password sharing + function login($account_id, $username) + { + # Check if account is exempt: + if(!empty($this->exempt) && is_array($this->exempt)) + for($i=0; $iexempt); $i++) + if($this->exempt[$i] == $username) + return true; + + # Determine current subnet to match: + @$arr = explode('.', USER_IP); + + # Validate values + if(!is_array($arr) || !is_numeric($this->subnets) || $this->subnets > 4 ) + return true; + + # Subnet... + $subnet=''; + for($i=0; $i<$this->subnets; $i++) { + $subnet .= $arr[$i]; + if($i<3) $subnet .= '.'; + } + + # time limit... + $limit = time() - (86400 * $this->range); + + # Generate SQL query + $db = &DB(); + $sql = "SELECT DISTINCT + ip + FROM ". + AGILE_DB_PREFIX."login_log + WHERE + date_orig > $limit + AND + ip NOT LIKE '$subnet%' + AND + account_id = $account_id + AND + site_id = ".DEFAULT_SITE; + $rs = $db->Execute($sql); + + if($this->max_subnets > 0 && $rs->RecordCount() >= ($this->max_subnets - 1)) + { + $subnets["$subnet"] = true; + + $count = 0; + while(!$rs->EOF) + { + @$arr = explode('.', $rs->fields['ip']); + $subnet1=''; + for($i=0; $i<$this->subnets; $i++) { + $subnet1 .= $arr[$i]; + if($i<3) $subnet1 .= '.'; + } + + if(empty($subnets["$subnet1"])) + $subnets["$subnet1"] = true; + + if(!empty($subnets) && count($subnets) >= $this->max_subnets) + break; + + $rs->MoveNext(); + } + + # over limit? + if(!empty($subnets) && count($subnets) >= $this->max_subnets) + { + # Deactivate account: + $sql = "UPDATE ". + AGILE_DB_PREFIX."account + SET + status = 0 + WHERE + site_id = ".DEFAULT_SITE." + AND + id = $account_id"; + $db->Execute($sql); + + # send e-mail alerts + include_once(PATH_MODULES.'email_template/email_template.inc.php'); + + # send user alert + $email = new email_template; + $email->send('login_share_ban_user', $account_id, '', $this->max_subnets, count($subnets)); + + # send admin alert + $email = new email_template; + $email->send('admin->login_share_ban_admin', $account_id, '', $this->max_subnets, count($subnets)); + + return false; + } + else + { + return true; + } + } + else + { + return true; + } + } +} +?> \ No newline at end of file diff --git a/modules/login_share/login_share_construct.xml b/modules/login_share/login_share_construct.xml new file mode 100644 index 00000000..9b748fd0 --- /dev/null +++ b/modules/login_share/login_share_construct.xml @@ -0,0 +1,46 @@ + + + + login_share + + login_share
+ + + + 0 + + id + + 30 + + + + + I8 + + + I4 + + + I8 + date-time + + + I8 + date-time + + + I8 + + + + + id,site_id,date_orig,date_last,account_id + id,site_id,date_orig,date_last,account_id + id + id,site_id,date_orig,date_last,account_id + id,site_id,date_orig,date_last,account_id + + + 0 +
diff --git a/modules/login_share/login_share_install.xml b/modules/login_share/login_share_install.xml new file mode 100644 index 00000000..f95c9c5c --- /dev/null +++ b/modules/login_share/login_share_install.xml @@ -0,0 +1,12 @@ + + + login_share + setup + + 0 + + + + + + \ No newline at end of file diff --git a/modules/module/dev.inc.php b/modules/module/dev.inc.php new file mode 100644 index 00000000..98d254e4 --- /dev/null +++ b/modules/module/dev.inc.php @@ -0,0 +1,1441 @@ + + * @package AgileBill + * @version 1.4.93 + */ + + +# create the main block +function dev_block_main($VAR) +{ + $ret = ' + + + + +
+ + + + + + + +
+
+ {translate module='.$VAR['module'].'} + menu + {/translate} +
+
+ + + + +
{translate module='.$VAR['module'].'}help_file{/translate}
+
+
+'; + return $ret; +} + + + + + +####################################################### +## create the add block ### +####################################################### +function dev_block_add($VAR) +{ + +# define the field types: +$field_type['text_small'] = ''; +$field_type['text_medium'] =''; +$field_type['text_large'] = ''; +$field_type['menu'] = '{ $list->menu("", "' . $VAR['module'] . '_%%field%%", "%%table%%", "name", $VAR.' . $VAR['module'] . '_%%field%%, "form_menu") }'; +$field_type['account_menu'] = '{ $list->popup("' . $VAR['module'] . '_add", "' . $VAR['module'] . '_%%field%%", $VAR.' . $VAR['module'] . '_%%field%%, "account_admin", "account", "first_name,middle_name,last_name", "form_field", "") }'; +$field_type['date'] = '{ $list->calender_add("' . $VAR['module'] . '_%%field%%", $VAR.' . $VAR['module'] . '_%%field%%, "form_field") }'; +$field_type['date_time'] = '{$list->date_time("")} '; +$field_type['date_now'] = '{$list->date_time("")} '; +$field_type['bool'] = '{ $list->bool("' . $VAR['module'] . '_%%field%%", $VAR.' . $VAR['module'] . '_%%field%%, "form_menu") }'; + + +$ret = ' + + +{if $form_validation} + { $block->display("core:alert_fields") } +{/if} + + + +{$COOKIE_FORM} + + + + +
+ + + + + + + +
+
+ {translate module=' . $VAR['module'] . '}title_add{/translate} +
+
+ +'; + + #loop through the fields + for($i=0; $i < count($VAR["f"]); $i++) + { + $field = $VAR["f"]["$i"]; + $type = $VAR["field"]["$field"]["field_type"]; + $this_content = eregi_replace('%%field%%', $field, $field_type["$type"]); + if($type == 'menu') $this_content = eregi_replace('%%table%%', $VAR["field"]["$field"]["asso_table"], $this_content); + + if(isset($VAR["field"]["$field"]["page_add"]["include"])) + { + + + $ret .= ' + + + +'; + } + } + + + + $ret .= ' + + + +
+ {translate module=' . $VAR['module'] . '} + field_' . $field . ' + {/translate} + ' . $this_content . ' +
+ + + + +
+
+
+ +'; + +return $ret; +} + + + + + + ####################################################### + ## GENERATE THE INSTALL DATA (SQL) ### + ####################################################### + function dev_install_xml_data($module,$module_id) + { + $rt = ' +'; + # open the backup file: + $xml = ''; + $xml .= $rt . '' . $rt; + + + + # generate the sql select statement: + $db = &DB(); + $dba = &DB(); + + + $sql = 'SELECT * FROM '.AGILE_DB_PREFIX.''.$module.' WHERE site_id = '. + $dba->qstr(DEFAULT_SITE) . ' ORDER BY id'; + $resulta = $dba->Execute($sql); + + # check the results + if($resulta != false && $resulta->RecordCount() > 0) + { + + # get the export data: + $resultarr = $resulta->GetArray(); + + # loop through each field + for ($ii=0; $ii' . $rt; + while (list ($field,$value) = each ($resultarr[$ii])) + { + if($value != '' && !is_integer($field)) + { + if( ereg('<', $value) || ereg('>', $value) || ereg('&', $value) || ereg('\'', $value) || ereg('"', $value) ) { + $value = ereg_replace('&', '&', $value); + $data = ' <'.$field.'>'; + $xml .= $data . '' . $rt; + } else { + $data = ' <'.$field.'>' . $value . ''; + $xml .= $data . '' . $rt; + } + } + } + $xml .= ' ' . $rt; + } + + + #################################################################### + # backup the autoincrement count: + #################################################################### + + $idmodule = $module . '_id'; + $sql = 'SELECT id FROM '.AGILE_DB_PREFIX.''.$idmodule; + $resulti = $db->Execute($sql); + + if($resulti!=false && @$resulti->RecordCount() != 0) + { + # get the export data: + $resultarr = $resulti->GetArray(); + + # loop through each field + for ($ii=0; $ii' . $rt; + while (list ($field,$value) = each ($resultarr[$ii])) + { + if($value != '' && gettype($field) != 'integer') + { + $data = ' <'.$field.'>' . htmlspecialchars($value,0,"ISO8859-1") . ''; + $xml .= $data . '' . $rt; + } + } + $xml .= ' ' . $rt; + } + } + } else { + return false; + } + + + $xml .= ''; + return $xml; + + } + + + + + ####################################################### + ## GENERATE THE INSTALL XML ### + ####################################################### + function dev_install_xml_gen($module,$module_id) + { + # get the module parent + $db = &DB(); + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."module WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($module_id); + $mr = $db->Execute($sql); + + if( $mr->fields["parent_id"] == "" || + $mr->fields["parent_id"] == "0" || + $mr->fields["parent_id"] == $module_id ) + { + $parent = $module; + } + else + { + $db = &DB(); + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."module WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($mr->fields["parent_id"]); + $mrp = $db->Execute($sql); + $parent = $mrp->fields["name"]; + } + + + + # get the current settings: + $t = "\t"; + $n = "\n"; + $C_xml = new CORE_xml; + $inst = $C_xml->xml_to_array(PATH_MODULES . '' . $module . '/' . $module . '_install.xml'); + + # Get any dependancy + $dependancy = @$inst['install']['module_properties']['dependancy']; + + # Get any sub_modules + $sub_modules = @$inst['install']['module_properties']['sub_modules']; + + ################################################################# + # regenerate the install file: + $xml = "{$n}"; + $install_xml = + "". $n . + "{$t}".$n . + "{$t}{$t}{$module}".$n . + "{$t}{$t}{$parent}".$n . + "{$t}{$t}fields["notes"]}]]>{$n}"; + + if(!empty($mr->fields["menu_display"])) + $install_xml .= + "{$t}{$t}1{$n}"; + + if(!empty($dependancy)) + $install_xml .= + "{$t}{$t}{$dependancy}{$n}"; + + if(!empty($sub_modules)) + $install_xml .= + "{$t}{$t}{$sub_modules}{$n}"; + + $install_xml .= + "{$t}" . $n . + "{$t}" . $n . + "{$t}{$t}" . $n; + + # loop through the methods + $db = &DB(); + $sql = "SELECT * FROM ".AGILE_DB_PREFIX."module_method WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + module_id = ".$db->qstr($module_id); + $result=$db->Execute($sql); + + while(!$result->EOF) + { + $method = $result->fields['name']; + $display = $result->fields['menu_display']; + $notes = $result->fields['notes']; + $page = trim(ereg_replace('&', '&', $result->fields['page'] ) ); + + $install_xml .= + "{$t}{$t}{$t}<{$method}>".$n. + "{$t}{$t}{$t}{$t}{$method}". $n; + + if(!empty($notes)) + $install_xml .= + "{$t}{$t}{$t}{$t}" . $n; + + if(!empty($page)) + $install_xml .= + "{$t}{$t}{$t}{$t}" . $n; + + if(!empty($display)) + $install_xml .= + "{$t}{$t}{$t}{$t}1" . $n; + + $install_xml .= + "{$t}{$t}{$t}" . $n; + + $result->MoveNext(); + } + + $install_xml .= + "{$t}{$t}".$n. + "{$t}".$n. + ""; + + return $install_xml; + } + + + + + + +####################################################### +## create the view block ### +####################################################### +function dev_block_view($VAR) +{ + + +# define the field types: +$field_type['text_small'] = ''; +$field_type['text_medium'] = ''; +$field_type['text_large'] = ''; +$field_type['menu'] = '{ $list->menu("", "' . $VAR['module'] . '_%%field%%", "%%table%%", "name", $'.$VAR['module'].'.%%field%%, "form_menu") }'; +$field_type['account_menu'] = '{ $list->popup("' . $VAR['module'] . '_view", "' . $VAR['module'] . '_%%field%%", $'.$VAR['module'].'.%%field%%, "account_admin", "account", "first_name,middle_name,last_name", "form_field", $' . $VAR['module'] .'.id) }'; +$field_type['date'] = '{ $list->calender_view("' . $VAR['module'] . '_%%field%%", $'.$VAR['module'].'.%%field%%, "form_field", $' . $VAR['module'] .'.id) }'; +$field_type['date_time'] = '{ $list->calender_view("' . $VAR['module'] . '_%%field%%", $'.$VAR['module'].'.%%field%%, "form_field", $' . $VAR['module'] .'.id) }'; +$field_type['date_now'] = '{$list->date_time("")} '; +$field_type['bool'] = '{ $list->bool("' . $VAR['module'] . '_%%field%%", $'.$VAR['module'].'.%%field%%, "form_menu") }'; + + + $ret = ' +{ $method->exe("' . $VAR["module"] . '","view") } { if ($method->result == FALSE) } { $block->display("core:method_error") } {else} + +{literal} + + +{/literal} + + +{foreach from=$' . $VAR["module"] . ' item=' . $VAR["module"] . '} + + +{if $form_validation} + { $block->display("core:alert_fields") } +{/if} + + +
+{$COOKIE_FORM} + + + + +
+ + + + + + + +
+
+ {translate module=' . $VAR['module'] . '}title_view{/translate} +
+
+ +'; + + + + #loop through the fields + for($i=0; $i < count($VAR["f"]); $i++) + { + $field = $VAR["f"]["$i"]; + $type = $VAR["field"]["$field"]["field_type"]; + $this_content = eregi_replace('%%field%%', $field, $field_type["$type"]); + if($type == 'menu') $this_content = eregi_replace('%%table%%', $VAR["field"]["$field"]["asso_table"], $this_content); + + if(isset($VAR["field"]["$field"]["page_view"]["include"])) + { + # is field changeable + if(!isset($VAR["field"]["$field"]["page_view"]["type"])) + { + $this_content = $VAR['module'] . '.' . $field; + + if($type == 'bool') + { + $this_content = '{if $' . $this_content . ' == "1"}{translate}true{/translate}{else}{translate}false{/translate}{/if}'; + } + else if ($type == 'date') + { + $this_content = '{$list->date($' . $this_content . ')}'; + } + else if ($type == 'date_time' || 'date_now') + { + $this_content = '{$list->date_time($' . $this_content . ')}'; + } + else + { + $this_content = '{$' . $this_content .'}'; + } + } + + + $ret .= ' + + + +'; + + } + } + + + + $ret .= ' + + + +
+ {translate module=' . $VAR['module'] . '} + field_' . $field . ' + {/translate} + ' . $this_content . ' +
+ + + + + +
+ + + +
+
+
+
+ + + + +
+ {/foreach} +{/if} +'; + +return $ret; +} + + + + + + + + + + + + + + + + + + +####################################################### +## create the search_form block ### +####################################################### +function dev_block_search_form($VAR) +{ + + +# define the field types: +$field_type['text_small'] = '   {translate}search_partial{/translate}'; +$field_type['text_medium'] = '   {translate}search_partial{/translate}'; +$field_type['text_large'] = '   {translate}search_partial{/translate}'; +$field_type['menu'] = '{ $list->menu("", "' . $VAR['module'] . '_%%field%%", "%%table%%", "name", "all", "form_menu") }'; +$field_type['account_menu'] = '{ $list->popup("' . $VAR['module'] . '_search", "' . $VAR['module'] . '_%%field%%", $VAR.' . $VAR['module'] . '_%%field%%, "account_admin", "account", "first_name,middle_name,last_name", "form_field", "") }'; +$field_type['date'] = '{ $list->calender_search("' . $VAR['module'] . '_%%field%%", $VAR.' . $VAR['module'] . '_%%field%%, "form_field", "") }'; +$field_type['date_time'] = '{ $list->calender_search("' . $VAR['module'] . '_%%field%%", $VAR.' . $VAR['module'] . '_%%field%%, "form_field", "") }'; +$field_type['date_now'] = '{ $list->calender_search("' . $VAR['module'] . '_%%field%%", $VAR.' . $VAR['module'] . '_%%field%%, "form_field", "") }'; +$field_type['bool'] = '{ $list->bool("' . $VAR['module'] . '_%%field%%", "all", "form_menu") }'; + + + $ret = ' +{ $method->exe("' . $VAR["module"] . '","search_form") } +{ if ($method->result == FALSE) } + { $block->display("core:method_error") } +{else} + +
+ {$COOKIE_FORM} + + + + +
+ + + + + + + +
+
+ {translate module=' . $VAR['module'] . '}title_search{/translate} +
+
+ +'; + + #loop through the fields + for($i=0; $i < count($VAR["f"]); $i++) + { + $field = $VAR["f"]["$i"]; + $type = $VAR["field"]["$field"]["field_type"]; + $this_content = eregi_replace('%%field%%', $field, $field_type["$type"]); + if($type == 'menu') $this_content = eregi_replace('%%table%%', $VAR["field"]["$field"]["asso_table"], $this_content); + + if(isset($VAR["field"]["$field"]["page_search_form"]["include"])) + { + + + $ret .= ' + + + +'; + } + } + + + + $ret .= ' + + + + + + + + + + + + + + + +
+ {translate module=' . $VAR['module'] . '} + field_' . $field . ' + {/translate} + ' . $this_content . ' +
{translate}search_results_per{/translate} + +
{translate}search_order_by{/translate} + +
+ + + + +
+
+
+
+{ $block->display("core:saved_searches") } +{ $block->display("core:recent_searches") } +{/if} +'; + +return $ret; +} + + + + + + + + + + + + + + + + + + + + +####################################################### +## create the search_show block ### +####################################################### +function dev_block_search_show($VAR) +{ + + + +$ret = ' + +{$method->exe("' . $VAR["module"] . '","search_show")} +{if ($method->result == FALSE)} + {$block->display("core:method_error")} +{else} + {if $results == 1} + {translate results=$results}search_result_count{/translate} + {else} + {translate results=$results}search_results_count{/translate} + {/if} +
+ + + {literal} + + + {/literal} + + +
+ + +
+ + + + + + +
+ + + + + + +'; + + $total = 0; + #count the fields + for($i=0; $i < count($VAR["f"]); $i++) + { + $field = $VAR["f"]["$i"]; + if(isset($VAR["field"]["$field"]["page_search_show"]["include"])) + { + $total++; + } + } + + + @$width = 95 / $total; + + #loop through the fields + for($i=0; $i < count($VAR["f"]); $i++) + { + $field = $VAR["f"]["$i"]; + $type = $VAR["field"]["$field"]["field_type"]; + $this_content = '$record.' . $field; + if(isset($VAR["field"]["$field"]["page_search_show"]["include"])) + { +$ret.= ' +'; + } + } + +$ret.= ' + {foreach from=$' . $VAR["module"] . ' item=record} + + + +'; + + #loop through the fields + for($i=0; $i < count($VAR["f"]); $i++) + { + $field = $VAR["f"]["$i"]; + $type = $VAR["field"]["$field"]["field_type"]; + $this_content = '$record.' . $field; + + if(isset($VAR["field"]["$field"]["page_search_show"]["include"])) + { + if($type == 'bool') + { + $this_content = '{if ' . $this_content . ' == "1"}{translate}true{/translate}{else}{translate}false{/translate}{/if}'; + } + else if ($type == 'date') + { + $this_content = '{$list->date(' . $this_content . ')}'; + } + else if ($type == 'date_time' || $type == 'date_now') + { + $this_content = '{$list->date_time(' . $this_content . ')}'; + } + else + { + $this_content = '{' . $this_content .'}'; + } + + +$ret .= ' +'; + } + } + +$ret .= ' + + + {literal} + + {/literal} + {/foreach} + + +
  + {literal} + + {/literal} +
+ +  ' . $this_content . '
+
+{if $VAR._print != TRUE}
+
+ + + + + +
+'; + +if(isset($VAR['module_export_bar'])) +{ +$ret .= '
+ + + + +
+ {translate}search_export_image{/translate} + {translate}search_print_image{/translate}'; + //{translate}search_save_image{/translate} +$ret .= ' + {translate}search_new_image{/translate} + {translate module='  . $VAR[ +
+'; +} +$ret.= '
+{/if} +{/if} +
+'; + +return $ret; +} + + + + + + + + + + + + + +####################################################### +## GENERATE THE LANGUAGE PACKS ### +####################################################### +function dev_language_xml($VAR) +{ +$xml = ''; +$language_xml = $xml . ' + + ' . $VAR["lang"]["name"] . ' + + '; + + # loop through the methods + for($i=0; $i < count($VAR["m"]); $i++) + { + $method = $VAR["m"]["$i"]; + $language_xml .= ' + '; + $title = $VAR["method"]["$method"]["block_name"]; + $language_xml .= $title . ''; + } + + + $language_xml .=' + + + ' . $VAR["lang"]["menu"] . ''; + + + # loop through the methods + for($i=0; $i < count($VAR["m"]); $i++) + { + $method = $VAR["m"]["$i"]; + $language_xml .= ' + '; + $menu = $VAR["method"]["$method"]["menu_name"]; + $language_xml .= $menu . ''; + } + + $language_xml .=' + + '; + + # loop through the fields + for($i=0; $i < count($VAR["f"]); $i++) + { + $field = $VAR["f"]["$i"]; + $language_xml .=' + ' . $VAR["field"]["$field"]["name"] . ''; + } + + $pat_nl = ' +'; + $language_xml .=' +'; + +return $language_xml; +} + + + + +####################################################### +## GENERATE THE CONSTRUCT PHP ### +####################################################### +function dev_construct_php($VAR) +{ + $construct_php = 'module = "' . $VAR["module"] . '"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + +'; if (isset($VAR["method"]["add"])) { $construct_php .= ' + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } +' +; } if (isset($VAR["method"]["view"])) { $construct_php .= +' + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } +' +; } if (isset($VAR["method"]["update"])) { $construct_php .= +' + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } +' +; } if (isset($VAR["method"]["delete"])) { $construct_php .= +' + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } +' +; } if (isset($VAR["method"]["search"])) { $construct_php .= +' + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } +' +; } if (isset($VAR["method"]["search"])) { $construct_php .= +' + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } +' +; } if (isset($VAR["method"]["search"])) { $construct_php .= +' + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +' +; } if (isset($VAR["method"]["search_save"])) { $construct_php .= +' + ############################## + ## SEARCH SAVE ## + ############################## + function search_save($VAR) + { + if ( + isset($VAR["search_id"]) && + isset($VAR["save_name"]) + ) + { + if ( + $VAR["search_id"] != "" && + $VAR["save_name"] != "" + ) + { + # create the record + include_once(PATH_CORE . "search.inc.php"); + $search = new CORE_search; + $search->save($VAR["search_id"], $this->table, $VAR["save_name"]); + } + } + } +' +; } if (isset($VAR["method"]["search_export"])) { $construct_php .= +' + ############################## + ## SEARCH EXPORT ## + ############################## + function search_export($VAR) + { + # require the export class + require_once (PATH_CORE . "export.inc.php"); + + # Call the correct export function for inline browser display, download, email, or web save. + if($VAR["format"] == "excel") + { + $type = "export_excel"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_excel($VAR, $this, $type); + } + + else if ($VAR["format"] == "pdf") + { + $type = "export_pdf"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_pdf($VAR, $this, $type); + } + + else if ($VAR["format"] == "xml") + { + $type = "export_xml"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_xml($VAR, $this, $type); + } + + else if ($VAR["format"] == "csv") + { + $type = "export_csv"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_csv($VAR, $this, $type); + } + + else if ($VAR["format"] == "tab") + { + $type = "export_tab"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_tab($VAR, $this, $type); + } + } +'; +} + +$construct_php .= ' + } +?' . '' . '>'; + +return $construct_php; +} + + + + + + + + + + + +####################################################### +## GENERATE THE CONSTRUCT XML ### +####################################################### +function dev_construct_xml($VAR) +{ + $xml = ''; + + $construct_xml = $xml . ' + + + + ' . $VAR["module"] . ' + + + ' . $VAR["table"] . '
+ + + ' . $VAR["dependancy"] . ' + + + ' . $VAR["cache"] . ' + + + ' . $VAR["order_by"] . ' + + + ' . $VAR["limit"] . ' + + + '; + + # loop through the fields + for($i=0; $i < count($VAR["f"]); $i++) + { + + $field = $VAR["f"]["$i"]; + $construct_xml .= ' + <' . $field . '>'; + + if (isset($VAR["field"]["$field"]["type"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["type"] .''; + + if (isset($VAR["field"]["$field"]["min_len"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["min_len"] .''; + + if (isset($VAR["field"]["$field"]["max_len"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["max_len"] .''; + + if (isset($VAR["field"]["$field"]["def_len"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["def_len"] .''; + + if (isset($VAR["field"]["$field"]["pdf_width"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["pdf_width"] .''; + + if (isset($VAR["field"]["$field"]["default"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["default"] .''; + + if (isset($VAR["field"]["$field"]["asso_table"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["asso_table"] .''; + + if (isset($VAR["field"]["$field"]["asso_field"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["asso_field"] .''; + + if (isset($VAR["field"]["$field"]["validate"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["validate"] .''; + + if (isset($VAR["field"]["$field"]["convert"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["convert"] .''; + + if (isset($VAR["field"]["$field"]["unique"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["unique"] .''; + + if (isset($VAR["field"]["$field"]["index"])) + $construct_xml .= ' + '. $VAR["field"]["$field"]["index"] .''; + $construct_xml .= ' + '; + } + + +$construct_xml .= ' + + + + '; + + # loop through the methods + for($i=0; $i < count($VAR["m"]); $i++) + { + $method = $VAR["m"]["$i"]; + $construct_xml .= ' + <' . $method . '>id'; + $arr = $VAR["method"]["$method"]; + $ii = 0; + while (list($key, $value) = each($arr)) + { + if($value == 1) + { + if (($ii != 0) && ($key != 'method_display')) + { + $construct_xml .= ','; + $construct_xml .= $key; + } + } + $ii++; + } + + $construct_xml .= ''; + } + + +$construct_xml .= ' + + + + '; + + # loop through the methods + for($i=0; $i < count($VAR["m"]); $i++) + { + $method = $VAR["m"]["$i"]; + $construct_xml .= ' + <' . $method . '>'; + $arr = $VAR["method"]["$method"]; + $ii = 0; + + if(isset($VAR["method"]["$method"]["trigger_success"])) + if($VAR["method"]["$method"]["trigger_success"] != '') + { + $construct_xml .= ' + ' . $VAR["method"]["$method"]["trigger_success"] . ''; + } + + if(isset($VAR["method"]["$method"]["trigger_failure"])) + if($VAR["method"]["$method"]["trigger_failure"] != '') + { + $construct_xml .= ' + ' . $VAR["method"]["$method"]["trigger_failure"] . ''; + } + + $construct_xml .= ' + '; + } + +$construct_xml .= ' + +
'; + +return $construct_xml; +} + + + + + + + + + + + + ####################################################### + ## GENERATE THE INSTALL XML ### + ####################################################### + function dev_install_xml($VAR) + { + $xml = ''; + $install_xml = $xml . ' + + + + + ' . $VAR["module"] . ' + ' . $VAR["module_parent"] . ' + ' . $VAR["module_notes"] . ' + ' . $VAR["module_menu_display"] . ' + ' . $VAR["dependancy"] . ' + '. $VAR["module_sub_module"] .' + '; + + + /* + for($i=0; $i < count($VAR["group_type"]); $i++) + { + if($VAR["group_type"]["$i"] != '') + { + $install_xml .=' + <' . $VAR["group_type"]["$i"] . '>1'; + } else { + $install_xml .=' + <' . $VAR["group_type"]["$i"] . '>0'; + } + } + */ + + $install_xml .= ' + + + + '; + + # loop through the methods + for($i=0; $i < count($VAR["m"]); $i++) + { + $method = $VAR["m"]["$i"]; + + if(isset($VAR["method"]["$method"]["method_notes"])) + { + $notes = $VAR["method"]["$method"]["method_notes"]; + } else { + $notes = ''; + } + if(isset($VAR["method"]["$method"]["method_page"])) + { + $page = $VAR["method"]["$method"]["method_page"]; + } else { + $page = ''; + } + + if(isset($VAR["method"]["$method"]["method_display"])) + { + $display = $VAR["method"]["$method"]["method_display"]; + } else { + $display = ''; + } + + $page = eregi_replace('&','&', $page); + + $install_xml .= ' + <' . $method . '> + %%module_id%% + ' . $method . ' + ' . $notes . ' + ' . $page . ' + ' . $display . ' + '; + + if($method == 'search') + { + $install_xml .= ' + + %%module_id%% + search_form + Allow users to view the search form + + + %%module_id%% + search_show + Allow users to view the search results + + '; + } + } + + $install_xml .= ' + + +'; + + return $install_xml; + } + +?> \ No newline at end of file diff --git a/modules/module/module.inc.php b/modules/module/module.inc.php new file mode 100644 index 00000000..6f858f8e --- /dev/null +++ b/modules/module/module.inc.php @@ -0,0 +1,1524 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class module +{ + + # Open the constructor for this mod + function module() + { + # name of this module: + $this->module = "module"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + + # core modules for installation/deletion: + $this->core_mods= Array( 'account', + 'account_admin', + 'account_group', + 'backup', + 'blocked_email', + 'blocked_ip', + 'country', + 'currency', + 'email_template', + 'email_template_translate', + 'group', + 'group_method', + 'login_lock', + 'login_log', + 'log_error', + 'module', + 'module_method', + 'newsletter', + 'newsletter_subscriber', + 'session', + 'session_auth_inc', + 'setup', + 'setup_email', + 'staff', + 'staff_department', + 'static_relation', + 'static_var', + 'static_var_record', + 'task', + 'temporary_data' ); + + + $this->dev_inst_excl = Array( 'module', + 'module_method', + 'group_method', + 'backup', + 'login_log', + 'session', + 'weblog', + 'temporary_data', + 'setup', + 'session_auth_cache'); + } + + + ### Send php/mysql/server/license details and check versions + function remote_version_check($VAR) { + global $C_auth; + if(!$C_auth->auth_method_by_name("module","upgrade")) return false; + + require_once('includes/pear/Compat/Function/file_get_contents.php'); + if(is_file(PATH_AGILE.'Version.txt')) + $f['version']=trim(file_get_contents(PATH_AGILE.'Version.txt')); + else + $f['version']='SVN'; + + $f['license']=LICENSE_KEY; + $f['php']=phpversion(); + $f['mysql']=mysql_get_client_info(); + $f['os']=$_ENV['OS']; + $f['proc']=$_ENV['PROCESSOR_ARCHITECTURE']; + $f['arch']=$_ENV['PROCESSOR_ARCHITEW6432']; + $f['server']=$_SERVER["SERVER_SOFTWARE"]; + global $smarty; + $smarty->assign('send', $f); + } + + ### Get remote hash file and check for inconsitancys in local files + function remote_update($VAR) + { + ## Load file_get_contents function for older versions: + require_once('includes/pear/Compat/Function/file_get_contents.php'); + + $ver = $VAR['ver']; + $mis=0; + $md5=0; + $i=0; + $msg = ''; + + # Get the core modules & compare + if(defined('DEMO_VERSION')) + $url_core = 'http://agileco.com/downloads/trial/'.$ver.'.hash.txt'; + else + $url_core = 'http://agileco.com/downloads/commercial/'.$ver.'.hash.txt'; + + @$data = file_get_contents($url_core); + if(empty($data)) { + $msg .= 'Failed to retrieve MD5 Hash file at http://agileco.com/downloads/commercial/'.$ver.'.hash.txt...
'; + } else { + $arr = explode("|",$data); + foreach($arr as $arx) + { + $rx = explode(',',$arx); + @$ar['name'] = $rx[1]; + @$ar['md5'] = $rx[0]; + if(!empty($ar['name']) && !empty($ar['md5']) && + !ereg("^install/", $ar['name']) && + !ereg("^test.php", $ar['name'])) + { + if(!is_file(PATH_AGILE.$ar["name"])) + { + $core_mis[] = $ar["name"]; + $mis++; + } + elseif(md5_file(PATH_AGILE.$ar["name"]) != $ar["md5"]) + { + $core_md5[] = $ar["name"]; + $md5++; + } + } + $i++; + } + $smart[] = Array ('name' => 'Core', 'md5' => @$core_md5, 'mis' => @$core_mis ); + } + + + ### Get each optional module && compare + if(!defined('DEMO_VERSION')) + { + @$modules = $VAR["module"]; + foreach($modules as $module) + { + $data = ''; + @$data = file_get_contents('http://agileco.com/downloads/commercial/'.$module.'.hash.txt'); + if(empty($data)) { + $msg .= 'Failed to retrieve MD5 Hash file at http://agileco.com/downloads/commercial/'.$module.'.hash.txt...
'; + } else { + $arr = explode("|",$data); + foreach($arr as $arx) + { + $rx = explode(',',$arx); + @$ar['name'] = $rx[1]; + @$ar['md5'] = $rx[0]; + + # check if file exists locally... + if(!empty($ar['name']) && !empty($ar['md5']) ) + { + if(!is_file(PATH_AGILE.$ar["name"])) + { + $f_mis[] = $ar["name"]; + $mis++; + } + elseif(md5_file(PATH_AGILE.$ar["name"]) != $ar["md5"]) + { + $f_md5[] = $ar["name"]; + $md5++; + } + } + $i++; + } + + $smart[] = Array ('name' => $module, 'md5' => @$f_md5, 'mis' => @$f_mis ); + unset($f_mis); + unset($f_md5); + } + } + } + + global $smarty; + $smarty->assign('modules', $smart); + $smarty->assign('md5', $md5); + $smarty->assign('mis', $mis); + + if(!empty($msg)) { + global $C_debug; + $C_debug->alert($msg); + } + } + + + + ############################## + ## TRANSLATE ## + ############################## + function translate($VAR) + { + if(!isset($VAR['translate_language']) || !isset($VAR['translate_module'])) + { + echo "error!"; + return; + } + + if($VAR['translate_module'] == "") + { + echo "error!"; + return; + } + + # Get the default language file: + if(!$file = fopen(PATH_LANGUAGE . '' . + $VAR["translate_module"] . + "/english_" . $VAR["translate_module"] . + ".xml", "r")) + { + echo 'Unable to open base translation!'; + } + else + { + $systran_text=''; + while(!feof($file)) + { + $systran_text .= fgetc($file); + } + } + fclose($file); + + + for($i=0; $isystran($systran_text,$systran_lp)); + + # write the language packs + $file = fopen(PATH_LANGUAGE . '' . $VAR["translate_module"] . "/".$language."_" . $VAR["translate_module"] . ".xml", "w+"); + fputs($file, $language_xml); + fclose($file); + } + } + } + + + ############################## + ## SYSTRAN TRANSLATION ## + ############################## + function systran($text, $lang) + { + $systran_id = "SystranSoft-en"; + $systran_charset = "ISO-8859-1"; + + $host = 'systranbox.com'; + $form = '/systran/box'; + $pass = array( + 'systran_id' => $systran_id, + 'systran_charset' => $systran_charset, + 'systran_lp' => $lang, + 'systran_text' => $text + ); + + // CREATE THE RECORD + require_once(PATH_CORE . 'post.inc.php'); + $post= new CORE_post; + $result = $post->post_data($host, $form, $pass); + $pat = "\n"; + $arr = split($pat, $result); + + $ret=''; + for($i=0; $i5) $ret.= $arr[$i]; + + return $ret; + } + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + # set the core modules: + $core = $this->core_mods; + + if(isset($VAR["delete_id"])) + $id = split(',',$VAR["delete_id"]); + elseif (isset($VAR["id"])) + $id = split(',',$VAR["id"]); + + for($i=0; $ixml_to_array($xml_construct); + + + ### Check that this Module has any db installation required... + if(isset($construct["construct"]["table"])) + { + ### Create the module DB table + $table = $construct["construct"]["table"]; + $db = &DB(); + $dict = NewDataDictionary($db); + $sql = $dict->DropTableSQL(AGILE_DB_PREFIX.''.$table); + $db->Execute($sql[0]); + + $table = $construct["construct"]["table"].'_id'; + $sql = $dict->DropTableSQL(AGILE_DB_PREFIX.''.$table); + $db->Execute($sql[0]); + } + } + } + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + + + ################################### + ## INSTALL ERROR CHECKING: MODULE ## + ################################### + function install_error_check($VAR) + { + global $smarty, $C_translate; + + ########################################### + ### Check that the module name is defined: + if(!isset($VAR["install_name"])) + { + $error[] = $C_translate->translate('install_enter_name','module',''); + } + else if ($VAR["install_name"] == '') + { + $error[] = $C_translate->translate('install_enter_name','module',''); + } + $module = trim($VAR["install_name"]); + + + ########################################### + ### Check that at least one group is defined: + if(!isset($VAR["module_group"])) + $error[] = $C_translate->translate('install_select_group','module',''); + + + ########################################### + ### Check if the module already exists in the Database: + $db = &DB(); + $q = 'SELECT name FROM '.AGILE_DB_PREFIX.'module WHERE + name = '.$db->qstr($module).' AND + site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + if($result->RecordCount() > 0) + $error[] = $C_translate->translate('install_module_exists','module',''); + + ####################################################### + ### Check if the module exists in the file structure: + if (!is_dir(PATH_MODULES . '' . $module)) + $error[] = $C_translate->translate('install_missing_dir','module',''); + + if (!file_exists(PATH_MODULES . '' . $module . '/' . $module . '.inc.php')) + $error[] = $C_translate->translate('install_missing_class','module',''); + + if (!file_exists(PATH_MODULES . '' . $module . '/' . $module . '_construct.xml')) + $error[] = $C_translate->translate('install_missing_construct','module',''); + + if (!file_exists(PATH_MODULES . '' . $module . '/' . $module . '_install.xml')) + $error[] = $C_translate->translate('install_missing_install','module',''); + + if(isset($error)) + { + $error[] = $C_translate->translate('install_failed','module',''); + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $error); + return false; + } + + + ########################################### + ### Load the install XML file... + $xml_construct = PATH_MODULES . "" . $module . "/" . $module . "_install.xml"; + $C_xml = new CORE_xml; + $install = $C_xml->xml_to_array($xml_construct); + $this->install = $install; + + /* + echo "
";
+		print_r($install);
+		echo "
"; + */ + + ########################################### + ### Get the module properties: + $name = $install["install"]["module_properties"]["name"]; + + if(isset($install["install"]["module_properties"]["parent"])) + $parent = $install["install"]["module_properties"]["parent"]; + else + $parent = 0; + + + ############################################ + ### Get dependancies.... + if(isset($install["install"]["module_properties"]["dependancy"])) + $dependancy = $install["install"]["module_properties"]["dependancy"]; + else + $dependancy = false; + + if($dependancy) + { + if(ereg(',', $dependancy)) + $depend = split(',', $dependancy); + else + $depend[0] = $dependancy; + + ################################################### + ### Check to be sure the dependancies are installed: + + for($i=0; $i < count($depend); $i++) + { + $db = &DB(); + $q = 'SELECT name FROM '.AGILE_DB_PREFIX.'module WHERE + name = '.$db->qstr($depend["$i"]).' AND + status = '.$db->qstr("1").' AND + site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + if($result->RecordCount() == 0) + $error[] = $C_translate->translate('install_module_depend','module','depend='.$depend["$i"]); + } + } + + # check for error: + if(isset($error)) + { + $error[] = $C_translate->translate('install_failed','module',''); + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $error); + return false; + } + + return true; + } + + + + ##################################### + ## INSTALL ERROR CHECKING: MODULE ## + ##################################### + function install_error_check_sub($module) + { + global $smarty; + + if ($module == '') + { + return true; + } + + ######################################################## + ### Check if the module already exists in the Database: + $db = &DB(); + $q = 'SELECT name FROM '.AGILE_DB_PREFIX.'module WHERE + name = '.$db->qstr($module).' AND + site_id = '.$db->qstr(DEFAULT_SITE); + $result = $db->Execute($q); + if($result->RecordCount() > 0) + $error[] = 'This module already exists in the database!'; + + ###################################################### + ### Check if the module exists in the file structure: + if (!is_dir(PATH_MODULES . '' . $module)) + $error[] = 'The specified module directory does not exist!'; + + if (!file_exists(PATH_MODULES . '' . $module . '/' . $module . '.inc.php')) + $error[] = 'The specified module class file does not exist!'; + + if (!file_exists(PATH_MODULES . '' . $module . '/' . $module . '_construct.xml')) + $error[] = 'The specified module construct file does not exist!'; + + if (!file_exists(PATH_MODULES . '' . $module . '/' . $module . '_install.xml')) + $error[] = 'The specified module installation file does not exist!'; + + if(isset($error)) + { + $error[] = 'Module Installation Failed'; + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $error); + return false; + } + + return true; + } + + + ################################### + ## INSTALL ERROR CHECKING ## + ################################### + function install_sql($module) + { + global $VAR, $smarty; + + ########################################### + ### Load the install XML file... + $C_xml = new CORE_xml; + $xml_install = PATH_MODULES . "" . $module . "/" . $module . "_install.xml"; + $install = $C_xml->xml_to_array($xml_install); + + ########################################### + ### Load the construct XML file... + $C_xml = new CORE_xml; + $xml_construct = PATH_MODULES . "" . $module . "/" . $module . "_construct.xml"; + $construct = $C_xml->xml_to_array($xml_construct); + + ### Check that this Module has any db installation required... + if(isset($construct["construct"]["table"])) + { + ### Create the module DB table + $table = $construct["construct"]["table"]; + + ### Create the module DB fields + $arr_field = $construct["construct"]["field"]; + + ### Loop through the fields to build the list: + #$index_flds = 'id,site_id'; + $index_flds = ''; + while (list ($key, $value) = each($arr_field)) + { + $field = $key; + $t_s = $arr_field["$key"]["type"]; + if(isset($arr_field["$key"]["index"])) + { + if(empty($index_flds)) + $index_flds .= $key; + else + $index_flds .= ','.$key; + } + + if(ereg('[(]',$t_s)) + { + $ts = split('[(]',$t_s); + $type = $ts[0]; + $size = ereg_replace('[)]', '', $ts[1]); + $flds[] = Array($field, $type, $size); + } + else + { + $flds[] = Array($field, $t_s); + } + } + + ### Multi site? + if(DEFAULT_SITE==1) + { + ### Create the table & colums using the ADODB Data Dictionary functions: + $db = &DB(); + $dict = NewDataDictionary($db); + $table_options = array('mysql' => 'TYPE=MyISAM'); + $sqlarray = $dict->CreateTableSQL(AGILE_DB_PREFIX.''.$table, $flds, $table_options); + $result = $db->Execute($sqlarray[0]); + if ($result === false) + { + global $C_debug; + $C_debug->error('module.inc.php','install_db (1)', $db->ErrorMsg() . ' '. print_r($sqlarray[0])); + return false; + } + + # Create unique index on site_id,id (mysql specific) + $db->Execute("CREATE UNIQUE INDEX IDS on ".AGILE_DB_PREFIX."$table (site_id, id)"); + + # Create any custom indexes + if(@$new_indexes = $construct["construct"]["index"]) + { + while (list ($index, $fields) = each($new_indexes)) + { + $dict = NewDataDictionary($db); + if(eregi("fulltext", $index) && AGILE_DB_TYPE == 'mysql') + $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX.$table, $fields, array('FULLTEXT')); + else + $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX.$table, $fields); + $db->Execute($sqlarray[0]); + } + } + } + } + + + + ################################################################## + ### Get the module properties: + + if(isset($install["install"]["module_properties"]["menu_display"])) + $menu_display = $install["install"]["module_properties"]["menu_display"]; + else + $menu_display = ''; + + if(isset($install["install"]["module_properties"]["notes"])) + $notes = $install["install"]["module_properties"]["notes"]; + else + $notes = ''; + + ################################################################### + ### Get the parent module... + + $db = &DB(); + $module_id = $db->GenID(AGILE_DB_PREFIX . "" . 'module_id'); + if(isset($install["install"]["module_properties"]["parent"])) + { + $q = 'SELECT id FROM '.AGILE_DB_PREFIX.'module WHERE + site_id = '.$db->qstr(DEFAULT_SITE).' AND + name = '.$db->qstr($install["install"]["module_properties"]["parent"]); + $result = $db->Execute($q); + + + + # Error checking + if ($result === false) + { + global $C_debug; + $C_debug->error('module.inc.php','install_db', $db->ErrorMsg()); + return false; + } + + if($result->fields["id"] == '') + $parent_id = $module_id; + else + $parent_id = $result->fields["id"]; + + } + else + { + $parent_id = $module_id; + } + + + + ################################################################## + ### Create the module record, & get the module ID + ### get the ID of the parent, and create it as child if needed... + ### else the record is a child of itself... + + $q = 'INSERT INTO '.AGILE_DB_PREFIX.'module SET + id = ' .$db->qstr($module_id).', + site_id = ' .$db->qstr(DEFAULT_SITE).', + name = ' .$db->qstr($module).', + parent_id = ' .$db->qstr($parent_id).', + notes = ' .$db->qstr($notes).', + status = ' .$db->qstr('1').', + menu_display = '.$db->qstr($menu_display); + $result = $db->Execute($q); + + ################################################################### + ### Create the module_method records, and get the ID for each one + + @$methods = $install["install"]["sql_inserts"]["module_method"]; + + if(!empty($methods) && is_array($methods)) + { + while (list ($key, $value) = each($methods)) + { + + $name = $key; + $method_id = $db->GenID(AGILE_DB_PREFIX.'module_method_id'); + + if(isset($methods[$key]["notes"])) + $notes = $methods[$key]["notes"]; + else + $notes = ''; + + if(isset($methods[$key]["page"])) + $page = $methods[$key]["page"]; + else + $page = ''; + + if(isset($methods[$key]["menu_display"])) + $menu_display = '1'; + else + $menu_display = '0'; + + $q = 'INSERT INTO '.AGILE_DB_PREFIX .'module_method SET + id = '.$db->qstr($method_id).', + site_id = '.$db->qstr(DEFAULT_SITE).', + name = '.$db->qstr($name).', + module_id = '.$db->qstr($module_id).', + notes = '.$db->qstr($notes).', + page = '.$db->qstr($page).', + menu_display = '.$db->qstr($menu_display); + + $result = $db->Execute($q); + + # Error checking + if ($result === false) + { + global $C_debug; + $C_debug->error('module.inc.php','install_db :: module_method', $db->ErrorMsg()); + return false; + } + + + ############################################################### + ### Create the group_method records, with the ID from each + ### of the above methods... + ### Get the groups to add to (FROM THE install.tpl form!) + + for($i=0; $iGenID(AGILE_DB_PREFIX . 'group_method_id'); + $q = 'INSERT INTO '.AGILE_DB_PREFIX .'group_method SET + id = '.$db->qstr($group_method_id).', + site_id = '.$db->qstr(DEFAULT_SITE).', + method_id = '.$db->qstr($method_id).', + module_id = '.$db->qstr($module_id).', + group_id = '.$db->qstr($VAR["module_group"][$i]); + + $result = $db->Execute($q); + + # Error checking + if ($result === false) + { + global $C_debug; + $C_debug->error('module.inc.php','install_db :: group_method_id', $db->ErrorMsg()); + return false; + } + } + } + } + + //$db->Execute ( sqlDelete(&$db, 'module', "name IS NULL or name = '' OR parent_id IS NULL or parent_id = ''") ); + + # all done! + return true; + } + + + ############################################## + ## INSTALL DEFAULT DATA ## + ############################################## + function install_sql_data($module) + { + # check the file: + $f = PATH_MODULES . '' . $module . '/' . $module . '_install_data.xml'; + + if(is_file($f)) + { + # open the XML backup file: + $C_xml = new CORE_xml; + $backup = $C_xml->xml_to_array($f); + $db = &DB(); + $arr = $backup['install']; + + # loop through each table in this array + if(is_array($arr) ) + { + while (list ($table,$records) = each ($arr)) + { + $runsql = false; + $sqls = 'INSERT INTO '.AGILE_DB_PREFIX.'' . $table . ' SET '; + + if (is_array($records) ) + { + # loop through each of the fields for this module + $sql = ''; + $sqlcount = 0; + while (list ($fld,$val) = each ($records)) + { + if (is_array($val)) + { + # loop through each of the fields for this module + $sql = ''; + $sqlcount = 0; + while (list ($fld2,$val2) = each ($val)) + { + if ($sqlcount != 0) $sql .= ', '; + $sql .= $fld2 .' = '.$db->qstr($val2); + $sqlcount++; + } + ## echo '
' . $sqls. ' ' . $sql; + $result = $db->Execute($sqls. ' ' . $sql); + + } + else + { + if ($sqlcount != 0) $sql .= ', '; + $sql .= $fld .' = '.$db->qstr($val); + $sqlcount++; + $runsql = true; + } + + } + if ($runsql) + { + ## echo '
' . $sqls. ' ' . $sql; + $result = $db->Execute($sqls. ' ' . $sql); + if($result === false) + @$this->error .= "
". $sqls. ' ' . $sql; + } + } + } + } + } + } + + + ################################### + ## MAIN INSTALLER ## + ################################### + function install($VAR) + { + global $smarty, $C_translate; + + # check this module for any errors: + if($this->install_error_check($VAR)) + { + + ### Get sub_modules of this package + if(isset($this->install["install"]["module_properties"]["sub_modules"])) + { + ### Check Each Sub-module: + $arr_sub = $this->install["install"]["module_properties"]["sub_modules"]; + + if(ereg(',', $arr_sub)) + $arr_s = split(',', $arr_sub); + else + $arr_s[] = $arr_sub; + + for($i=0; $iinstall_error_check_sub($arr_s[$i])) + $error[] = $C_translate->translate('install_sub_module_err','module','sub_module='.$arr_s[$i]); + } + } + + # check for error: + if(isset($error)) + { + $error[] = $C_translate->translate('install_failed','module',''); + + # set the errors as a Smarty Object + $smarty->assign('form_validation', $error); + return false; + } + + + ### install the SQL... + $module = trim($VAR["install_name"]); + if($this->install_sql($module)) + { + ### Loop through the sub-modules and install each of them + if(isset($arr_s)) + { + for($i=0; $iinstall_sql($arr_s[$i])) + { + ### Errors in install_sql(), then delete any SQL changes! + ### set smarty error + return; + } + + } + } + } + else + { + ### Errors in install_sql(), then delete any SQL changes! + ### set smarty error + return; + } + + ### Insert default data: + $this->install_sql_data($module); + } + + # update the current user's authentication so the update group access applies + # to them + global $C_auth; + $C_auth->auth_update(); + } + + + + + + + ################################### + ## AUTO UPGRADER ## + ################################### + function upgrade($VAR) + { + if(!isset($VAR['module_name']) || !isset($VAR['module_group'])) + { + echo "You must select both the module(s) to upgrade and the groups to grant access to new methods to."; + return; + } + + $module_count = 0; + $method_count = 0; + $fields_count = 0; + $method_new_count = 0; + $fields_new_count = 0; + + # loop through each module + $modules = $VAR['module_name']; + + for($i=0; $iExecute(sqlSelect($db,"module","*","id=::{$modules[$i]}:: or name=::{$modules[$i]}::")); + $module_name = $db_module->fields['name']; + $module_id = $db_module->fields['id']; + + ######################################################################### + # Update the Methods from the _install.xml file + # get the install xml file + ######################################################################### + + $install_xml = PATH_MODULES.$module_name.'/'.$module_name.'_install.xml'; + if(is_file($install_xml)) + { + $C_xml = new CORE_xml; + @$methods = $C_xml->xml_to_array($install_xml); + @$methods = $methods['install']['sql_inserts']['module_method']; + + # loop through the methods + if(is_array($methods)) + { + while (list ($key, $value) = each($methods)) + { + # increment method count + $method_count++; + + # see if this method exists + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'module_method WHERE + name = ' . $db->qstr( $key ) . ' AND + module_id = ' . $db->qstr( $module_id ) . ' AND + site_id = ' . $db->qstr(DEFAULT_SITE); + $method_db = $db->Execute($sql); + if ($method_db === false) { + global $C_debug; + $C_debug->error('module.inc.php','upgrade', $db->ErrorMsg()); + } + if($method_db->RecordCount() == 0) + { + # increment method count + $method_new_count++; + + ### add this method + @$notes = $methods[$key]["notes"]; + @$page = $methods[$key]["page"]; + @$menu_display = $methods[$key]["menu_display"]; + + $method_id = sqlGenID($db, 'module_method'); + $fields=Array('name'=>$key, 'module_id'=>$module_id, 'notes'=>$notes, 'page'=>$page, 'menu_display'=>$menu_display); + $db->Execute(sqlInsert($db,"module_method",$fields, $method_id)); + if ($result === false) { + global $C_debug; + $C_debug->error('module.inc.php','upgrade', $db->ErrorMsg()); + } + + ### Create the group_method records, with the ID from each + for($ii=0; $iiGenID(AGILE_DB_PREFIX . "" . 'group_method_id'); + $q = 'INSERT INTO '.AGILE_DB_PREFIX .'group_method SET + id = '.$db->qstr($group_method_id).', + site_id = '.$db->qstr(DEFAULT_SITE).', + method_id = '.$db->qstr($method_id).', + module_id = '.$db->qstr($module_id).', + group_id = '.$db->qstr($VAR["module_group"][$ii]); + $result = $db->Execute($q); + if ($result === false) { + global $C_debug; + $C_debug->error('module.inc.php','upgrade', $db->ErrorMsg()); + } + } + } + } + } + } + + + ######################################################################### + # Update the DB Fields from the _construct.xml file + # get the install xml file + ######################################################################### + + $construct_xml = PATH_MODULES.$module_name.'/'.$module_name.'_construct.xml'; + if(is_file($construct_xml)) + { + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($construct_xml); + @$fields = $construct['construct']['field']; + + ### Check that this Module has any db installation required... + if(!empty($construct["construct"]["table"]) && $construct["construct"]["table"] == $module_name) + { + ### Create the module DB table + $table = $construct["construct"]["table"]; + $db = &DB(); + $db_fields = $db->MetaColumns(AGILE_DB_PREFIX.$table, true); + + ### Create the module DB fields + $arr_field = $construct["construct"]["field"]; + + ### Loop through the fields to build the list: + while (list ($key, $value) = each($arr_field)) + { + $field = $key; + $FIELD = strtoupper($key); + if(!isset($db_fields[$FIELD])) + { + # increment field count + $fields_new_count++; + + $t_s = $arr_field["$key"]["type"]; + if(ereg('[(]',$t_s)) + { + $ts = split('[(]',$t_s); + $type = $ts[0]; + $size = ereg_replace(')', '', $ts[1]); + $flds[] = Array($field, $type, $size); + } + else + { + $flds[] = Array($field, $t_s); + } + } + } + + ### Add any new columns: + if(is_array(@$flds)) + { + $dict = NewDataDictionary($db); + $sqlarray = $dict->AddColumnSQL(AGILE_DB_PREFIX.$table, $flds); + $result = $db->Execute($sqlarray[0]); + if ($result === false) { + global $C_debug; + $C_debug->error('module.inc.php','install_db', $db->ErrorMsg()); + echo $db->ErrorMsg(); + } + unset($flds); + } + + + ### Remove any unused columns + while (list ($key, $value) = each($db_fields)) + { + $fieldname = strtolower($key); + if(!isset($construct["construct"]["field"][$fieldname])) $flds[] = $key; + + } + if(is_array(@$flds)) + { + $dict = NewDataDictionary($db); + $sqlarray = $dict->DropColumnSQL(AGILE_DB_PREFIX.$table, $flds); + + $sqlarray[0]; + $result = $db->Execute($sqlarray[0]); + if ($result === false) { + global $C_debug; + $C_debug->error('module.inc.php','install_db', $db->ErrorMsg()); + echo $db->ErrorMsg(); + } + unset($flds); + } + + + #################################################### + ### Update Indexes: + + # Get old database indexes + $dict = NewDataDictionary($db); + $oldindex = $dict->MetaIndexes(AGILE_DB_PREFIX.$table); + + # check if the 'site_id' index exists: + if(!empty($oldindex['site_id']) && $oldindex['site_id'] = 'id,site_id') { + $dict = NewDataDictionary($db); + $sqlarray = $dict->DropIndexSQL('site_id', AGILE_DB_PREFIX.$table); + $db->Execute($sqlarray[0]); + } + + # check that that UNIQUE index for site_id,id exists + if(empty($oldindex['IDS']) || $oldindex['IDS']['unique'] != 1) + { + $db=&DB(); + $db->Execute("alter table ".AGILE_DB_PREFIX."$table drop primary key"); + $db->Execute("CREATE UNIQUE INDEX IDS on ".AGILE_DB_PREFIX."$table (site_id, id)"); + } + + $dict = NewDataDictionary($db); + $oldindex = $dict->MetaIndexes(AGILE_DB_PREFIX.$table); + + # Current construct invoices + if(@$new_indexes = $construct["construct"]["index"]) + { + while (list ($index, $fields) = each($new_indexes)) + { + if(is_array(@$oldindex[$index])) + { + # already exists - compare fields: + $oldfields = implode(",", $oldindex[$index]['columns']); + + if($oldfields != $fields) + { + # index changed - drop: + $dict = NewDataDictionary($db); + $sqlarray = $dict->DropIndexSQL($index, AGILE_DB_PREFIX.$table); + + $db->Execute($sqlarray[0]); + + # create index + $dict = NewDataDictionary($db); + + if(eregi("fulltext", $index) && AGILE_DB_TYPE == 'mysql') + $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX.$table, $fields, array('FULLTEXT')); + else + $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX.$table, $fields); + $db->Execute($sqlarray[0]); + } + } + else + { + # index does not exist - create! + $dict = NewDataDictionary($db); + + if(eregi("fulltext", $index) && AGILE_DB_TYPE == 'mysql') + $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX.$table, $fields, array('FULLTEXT')); + else + $sqlarray = $dict->CreateIndexSQL($index, AGILE_DB_PREFIX.$table, $fields); + $db->Execute($sqlarray[0]); + } + + $verify_index[] = $index; + } + + # Check for removed indexes: + if(!empty($oldindex)) + { + reset($oldindex); + while (list ($index, $fields) = each($oldindex)) + { + if(!isset($new_indexes[$index]) && $index != 'IDS') + { + $dict = NewDataDictionary($db); + $sqlarray = $dict->DropIndexSQL($index, AGILE_DB_PREFIX.$table); + $db->Execute($sqlarray[0]); + } + } + } + } + else + { + # remove all old indexes + if(!empty($oldindex)) + { + reset($oldindex); + while (list ($index, $fields) = each($oldindex)) + { + if($index != 'IDS') + { + $dict = NewDataDictionary($db); + $sqlarray = $dict->DropIndexSQL($index, AGILE_DB_PREFIX.$table); + $db->Execute($sqlarray[0]); + } + } + } + } + } + } + } + + $msg = "Successfully checked $module_count module(s), $method_count method(s), ". + "and $fields_count db fields.
". + "Added $method_new_count method(s) and $fields_new_count db field(s)."; + + + if(!empty($fields_new_count) > 0) { + $js = ''; + global $smarty; + if(is_object($smarty)) + $smarty->assign('js', $js); + else + echo ''; + } + + + # Display the message. + global $C_debug; + if(is_object($C_debug)) + $C_debug->alert($msg); + else + echo $msg; + + # update the current user's authentication so the update group access applies + # to them + global $C_auth; + if(is_object($C_auth)) $C_auth->auth_update(); + + } + + + # Create the install XML file for specified modules + function dev_install_gen($VAR) + { + + # loop through each module passed... + include_once('dev.inc.php'); + $db = &DB(); + + if(is_array($VAR['module'])) + { + for($ix = 0; $ixdev_inst_excl); $i++) + { + if ( $this->dev_inst_excl[$i] == $result->fields['name']) + { + $do = false; + } + } + + if ($do) + { + # update/create the {$module}_install_data.xml file data + $xml = dev_install_xml_data($result->fields['name'],$result->fields['id']); + } + else + { + /* + $xml = ''; + $xml .= ' + +'; + */ + $xml = false; + } + + # write the file + if($xml != false) + { + $file = fopen(PATH_MODULES . '' . $result->fields['name'] . '/'. $result->fields['name'] . "_install_data.xml", "w+"); + fputs($file, $xml); + fclose($file); + } + + # next module + $result->MoveNext(); + } + } + } + } + + + + # add a new module construct + function dev_add($VAR) + { + + # check if the needed directories exist & attempt to create... + + if (!is_dir(PATH_MODULES . '' . $VAR["module"])) { + echo "
Path does not exist, attempting to create: ".PATH_MODULES . '' . $VAR["module"]; + if(!mkdir(PATH_MODULES . '' . $VAR["module"])) { + echo "

Error: Module creation failed, please check path permissions...
"; + return false; + } + } + + if (!is_dir(PATH_LANGUAGE . '' . $VAR["module"])) { + echo "
Path does not exist, attempting to create: ".PATH_LANGUAGE . '' . $VAR["module"]; + if(!mkdir(PATH_LANGUAGE . '' . $VAR["module"])) { + echo "

Error: Module creation failed, please check path permissions...
"; + return false; + } + } + + + if (!is_dir(PATH_THEMES . 'default/blocks/' . $VAR["module"])) { + echo "
Path does not exist, attempting to create: ".PATH_THEMES . 'default/blocks/' . $VAR["module"]; + if(!mkdir(PATH_THEMES . 'default/blocks/' . $VAR["module"])) { + echo "

Error: Module creation failed, please check path permissions...
"; + return false; + } + } + + + # include the dev functions: + include('dev.inc.php'); + + $construct_xml = dev_construct_xml($VAR); + # write the consruct XML + $file = fopen(PATH_MODULES . '' . $VAR["module"] . '/'. $VAR["module"] . "_construct.xml", "w+"); + fputs($file,$construct_xml); + fclose($file); + + + $construct_php = dev_construct_php($VAR); + # write the construct PHP + $file=fopen(PATH_MODULES . '' . $VAR["module"] . '/'. $VAR["module"] . ".inc.php", "w+"); + fputs($file,$construct_php); + fclose($file); + + + $language_xml = dev_language_xml($VAR); + # write the language packs + $file=fopen(PATH_LANGUAGE . '' . $VAR["module"] . "/english_" . $VAR["module"] . ".xml", "w+"); + fputs($file, $language_xml); + fclose($file); + + + $install_xml = dev_install_xml($VAR); + # write the language packs + $file = fopen(PATH_MODULES . '' . $VAR["module"] . '/'. $VAR["module"] . "_install.xml", "w+"); + fputs($file, $install_xml); + fclose($file); + + + # generate the main block + $main_tpl = dev_block_main($VAR); + # write the block + $file = fopen(PATH_THEMES . 'default/blocks/' . $VAR["module"] . "/main.tpl", "w+"); + fputs($file, $main_tpl); + fclose($file); + + # generate the add block + $add_tpl = dev_block_add($VAR); + # write the block + $file = fopen(PATH_THEMES . 'default/blocks/' . $VAR["module"] . "/add.tpl", "w+"); + fputs($file, $add_tpl); + fclose($file); + + # generate the view block + $view_tpl = dev_block_view($VAR); + # write the block + $file = fopen(PATH_THEMES . 'default/blocks/' . $VAR["module"] . "/view.tpl", "w+"); + fputs($file, $view_tpl); + fclose($file); + + # generate the search_form block + $search_form_tpl = dev_block_search_form($VAR); + # write the block + $file = fopen(PATH_THEMES . 'default/blocks/' . $VAR["module"] . "/search_form.tpl", "w+"); + fputs($file, $search_form_tpl); + fclose($file); + + # generate the search_show block + $search_show_tpl = dev_block_search_show($VAR); + # write the block + $file = fopen(PATH_THEMES . 'default/blocks/' . $VAR["module"] . "/search_show.tpl", "w+"); + fputs($file, $search_show_tpl); + fclose($file); + } +} +?> \ No newline at end of file diff --git a/modules/module/module_construct.xml b/modules/module/module_construct.xml new file mode 100644 index 00000000..8d0d19bd --- /dev/null +++ b/modules/module/module_construct.xml @@ -0,0 +1,79 @@ + + + + module + + module
+ + module,account + + 0 + + name + + 25 + + + parent_id + menu_display + status,menu_display + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I8 + + + I8 + + + I4 + 1 + + + C(128) + 3 + 128 + any + 1 + + + X2 + + + L + + + L + + + + + name,notes,status,date_orig,date_last,menu_display,parent_id + notes,status,date_orig,date_last,menu_display,parent_id + id,name,notes,status,date_orig,date_last,menu_display,parent_id + id,name,notes,status,date_orig,date_last,menu_display,parent_id + id,name,notes,status,date_orig,date_last,menu_display,parent_id + id,name,notes,status,date_orig,date_last,menu_display,parent_id + id,name,notes,status,date_orig,date_last,menu_display,parent_id + id,name,notes,status + id,name,notes,status,date_orig,date_last,menu_display,parent_id + id,name,notes,status,date_orig,date_last,menu_display,parent_id + + + + + module:method + module:method + + +
diff --git a/modules/module/module_install.xml b/modules/module/module_install.xml new file mode 100644 index 00000000..d6aad6d3 --- /dev/null +++ b/modules/module/module_install.xml @@ -0,0 +1,63 @@ + + + module + setup + + 1 + + + + + search + + + view + + + 1 + + + add + + 1 + + + delete + + + update + + + search_show + + + + dev_add + 1 + + + failure + + + install + + + 1 + + + translate + + + dev_install_gen + + + upgrade + + 1 + + + remote_update + + + + \ No newline at end of file diff --git a/modules/module_method/module_method.inc.php b/modules/module_method/module_method.inc.php new file mode 100644 index 00000000..86ad9c69 --- /dev/null +++ b/modules/module_method/module_method.inc.php @@ -0,0 +1,366 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class module_method +{ + + # Open the constructor for this mod + function module_method() + { + # name of this module: + $this->module = "module_method"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + ############################## + ## VIEW METHODS ## + ############################## + + function view_methods($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $this->this_search_show($VAR, $this, $type); + } + + ############################## + ## VIEW METHODS p.2 ##### + ############################## + + function this_search_show($VAR, $construct, $type) + { + global $VAR; + + # Get the list of parents for this group + $this->group_parent_list($VAR['module_method_group_id']); + + + # generate the full query + $q = "SELECT * FROM + ".AGILE_DB_PREFIX."module_method + WHERE + module_id = ".$VAR['module_method_module_id']; + $db = &DB(); + $result = $db->Execute($q); + + + + # put the results into a smarty accessable array + $i=0; + $class_name = TRUE; + + while (!$result->EOF) { + $smart[$i] = $result->fields; + $method_id = $smart[$i]['id']; + + ## Get the auth status for this method & group + $q1 = 'SELECT id FROM '.AGILE_DB_PREFIX.'group_method WHERE + method_id = '.$smart[$i]['id'].' AND + group_id = '.$VAR['module_method_group_id']; + $db1 = &DB(); + $resulta = $db1->Execute($q1); + #echo "
$q1"; + + ## authorized by current group + if($resulta->RecordCount() >= 1) + { + #echo "
1 - This group matches!"; + $smart[$i]['checked'] = '1'; + } + else + { + # get the parent group id(s) for this group + $match = false; + for($ii=0; $ii < count($this->group); $ii++) + { + if($match == false && $this->group[$ii] != $VAR['module_method_group_id']) + { + $q2 = 'SELECT id FROM '.AGILE_DB_PREFIX.'group_method + WHERE method_id = '.$method_id.' + AND group_id = '.$this->group[$ii]; + + $db2 = &DB(); + $resultb = $db2->Execute($q2); + + #echo "
$q2"; + if($resultb->RecordCount() >= 1) + $match = true; + } + } + + + ## authorized by parent + if($match) + { + #echo "
2 - This Parent Matches!"; + $smart[$i]['checked'] = '2'; + } + else + { + ## not authorized + #echo "
3 - NO matches"; + $smart[$i]['checked'] = '3'; + } + } + + + if($class_name) + { + $smart[$i]['_C'] = 'row2'; + $class_name = FALSE; + } else { + $smart[$i]['_C'] = 'row1'; + $class_name = TRUE; + } + + $result->MoveNext(); + $i++; + + } + + # get any linked fields + if($i > 0) + { + $db_join = new CORE_database; + $this->result = $db_join->join_fields($smart, $this->linked); + } + else + { + $this->result = $smart; + } + + + # get the result count: + $results = $result->RecordCount(); + # define the DB vars as a Smarty accessible block + global $smarty; + # define the results + $smarty->assign($construct->table, $this->result); + $smarty->assign('page', $VAR['page']); + $smarty->assign('order', 1111); + $smarty->assign('sort', 1111); + $smarty->assign('limit', 1111); + $smarty->assign('search_id',1111); + $smarty->assign('results', $results); + + # get the total pages for this search: + $this->pages = 1; + if ($search->results % $search->limit) $this->pages++; + # total pages + $smarty->assign('pages', $this->pages); + # current page + $smarty->assign('page', $current_page); + $page_arr = ''; + for($i=0; $i <= $this->pages; $i++) + { + if ($this->page != $i) $page_arr[] = $i; + } + # page array for menu + $smarty->assign('page_arr', $page_arr); + + } + + + /** + * Get any inherited groups (parent) for a specified group + * @return void + * @since Version 1.0 + * @param int Group Id + */ + function group_parent_list($group) + { + # check if this group is a child with an active parent + $db = &DB(); + $q = "SELECT id,parent_id FROM " . AGILE_DB_PREFIX . "group + WHERE id = '$group' + AND site_id = '" . DEFAULT_SITE . "'"; + $result = $db->Execute($q); + + # error handling + if ($result === false) + { + global $C_debug; + $C_debug->error('auth.inc.php','group_parent_list', $db->ErrorMsg()); + } + + # loop through the results + while (!$result->EOF) + { + # add this group to the list + $this->group[] = $result->fields['id']; + + # get inherited groups and check that the associated + # group is active before adding to the list of authorized groups. + if($result->fields['parent_id'] != 0) + { + $this->group_parent_list($result->fields['parent_id']); + } + + # move to next record + $result->MoveNext(); + } + } + + /** + * Mass add methods to a specific group + * @return void + * @since Version 1.0 + * @param int Group Id + */ + + function update_relations() + { + global $VAR; + + if(isset($VAR['id']) && $VAR['id'] != '') + { + $arr = split(',', $VAR['id']); + } + else { return;} + + + + for($i=0; $iExecute($q); + } + + if($arr[$i] == 0) return; + + # determine the record id: + $this->record_id = $db->GenID(AGILE_DB_PREFIX . 'group_method_id'); + + # generate the full query + $q = "INSERT INTO ".AGILE_DB_PREFIX."group_method + SET + id = '".$this->record_id."', + site_id = '" . DEFAULT_SITE . "', + method_id = '".$arr[$i]."', + module_id = '".$VAR['module_method_module_id']."', + group_id = '".$VAR['module_method_group_id']."'"; + $db = &DB(); + $result = $db->Execute($q); + } + } +} +?> \ No newline at end of file diff --git a/modules/module_method/module_method_construct.xml b/modules/module_method/module_method_construct.xml new file mode 100644 index 00000000..02bdcb1e --- /dev/null +++ b/modules/module_method/module_method_construct.xml @@ -0,0 +1,66 @@ + + + + module_method + + module_method
+ + module + + 0 + + name + + 25 + + + module_id + menu_display + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I4 + module + name + any + 1 + + + C(64) + 1 + 64 + non_numeric + + + + C2(128) + + + C(128) + + + L + + + + + id,site_id,module_id,name,notes,page,menu_display + id,site_id,module_id,name,notes,page,menu_display + id,site_id,module_id,name,notes,page,menu_display + id,site_id,module_id,name,notes,page,menu_display + id,site_id,module_id,name,notes,page,menu_display + id,site_id,module_id,name,notes,page,menu_display + + + 0 +
diff --git a/modules/module_method/module_method_install.xml b/modules/module_method/module_method_install.xml new file mode 100644 index 00000000..5b64df37 --- /dev/null +++ b/modules/module_method/module_method_install.xml @@ -0,0 +1,40 @@ + + + module_method + module + + + + + + search + + + view + + + add + + + delete + + + update + + + search_form + + + search_show + + + + view_methods + + + + update_relations + + + + \ No newline at end of file diff --git a/modules/net_term/net_term.inc.php b/modules/net_term/net_term.inc.php new file mode 100644 index 00000000..39a7c3db --- /dev/null +++ b/modules/net_term/net_term.inc.php @@ -0,0 +1,245 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class net_term +{ + var $taxable=1; # are late fees taxable? 0/1 + + # Open the constructor for this mod + function net_term() + { + # name of this module: + $this->module = "net_term"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + ### Check usergroup&checkout plugin to determin if net terms available (get best) + function termsAllowed($account_id,$checkout_plugin_id) + { + $db=&DB(); + $rs=&$db->Execute($sql=sqlSelect($db,"net_term","*","status=1 AND checkout_id=$checkout_plugin_id","fee ASC")); + if($rs && $rs->RecordCount() > 0) { + global $C_auth; + while(!$rs->EOF) { + $availarr = unserialize($rs->fields['group_avail']); + if(is_array($availarr)) { + foreach($availarr as $g) { + if($C_auth->auth_group_by_account_id($account_id,$g)) return $rs->fields['id']; + } + } + } + } + return 0; + } + + ### Task to generate late charges & insert into charge module: + function task($VAR) + { + require_once(PATH_MODULES.'email_template/email_template.inc.php'); + require_once(PATH_MODULES.'invoice/invoice.inc.php'); + $invoice = new invoice; + + # get active net terms + $db=&DB(); + $rs=&$db->Execute($sql=sqlSelect($db,"net_term","*","status=1")); + if($rs && $rs->RecordCount() > 0) + { + // loop through net terms + while(!$rs->EOF) + { + $id = $rs->fields['id']; + $last_interval = mktime(0,0,0,date('m'), date('d')-$rs->fields['terms'], date('Y')); + + $i=&$db->Execute($sql=sqlSelect($db,"invoice", + "id,account_id,total_amt,billed_amt,due_date,net_term_date_last,net_term_intervals", + "net_term_id = $id AND + (suspend_billing = 0 OR suspend_billing IS NULL) AND + (billing_status = 0 OR billing_status IS NULL) AND + due_date <= $last_interval AND + net_term_date_last <= $last_interval")); + if($i && $i->RecordCount() > 0) + { + + + + // loop through invoices + while(!$i->EOF) + { + $terms = $rs->fields['terms']; + echo "
" . $start_interval = $i->fields['net_term_date_last']; + echo "
" . $stop_interval = $start_interval+(86400*$terms); + + echo "
". date(UNIX_DATE_FORMAT,$start_interval); + + // charge or suspend? + if(!empty($i->fields['net_term_intervals']) && $rs->fields['suspend_intervals'] < $i->fields['net_term_intervals']) { + + // suspend invoice + $arr['id'] = $i->fields['id']; + $na =& $invoice->voidInvoice($arr,$invoice); + + // suspend billing status + $fields=Array('suspend_billing'=>1); + $db->Execute($sql=sqlUpdate($db,"invoice",$fields,"id = {$i->fields['id']}")); + + // send suspend e-mail + if($rs->fields['enable_emails']) { + $email = new email_template; + $email->send('net_term_suspend', $i->fields['account_id'], $i->fields['id'], $rs->fields['suspend_intervals'], $i->fields['net_term_intervals']); + } + } + else + { + // calc late fee + if($rs->fields['fee_type'] == 1) + $fee = $rs->fields['fee']; + else + $fee = ($i->fields['total_amt'] - $i->fields['billed_amt']) * $rs->fields['fee']; + + // create late charge + if($fee>0) + { + $fields=Array( 'date_orig'=> time(), + 'status'=> 0, + 'account_id'=> $i->fields['account_id'], + 'amount'=> $fee, + 'sweep_type'=> $rs->fields['sweep_type'], + 'taxable'=> $this->taxable, + 'quantity' => 1, + 'attributes'=> "Name=={$rs->fields['name']}\r\nInterval==".date(UNIX_DATE_FORMAT,$start_interval)." - ".date(UNIX_DATE_FORMAT,$stop_interval), // todo: translate + 'description'=> $rs->fields['sku']); + $db->Execute($sql=sqlInsert($db,"charge",$fields)); + + // update invoice + $_fields['net_term_intervals'] = $i->fields['net_term_intervals']+1; + $_fields['net_term_date_last'] = $stop_interval; + $db->Execute($sql=sqlUpdate($db,"invoice",$_fields,"id={$i->fields['id']}")); + echo "

$sql"; + } + + // send late fee/payment reminder e-mail: + if($rs->fields['enable_emails']){ + $email = new email_template; + $email->send('net_term_late_notice', $i->fields['account_id'], $i->fields['id'], number_format($fee,2), number_format($rs->fields['suspend_intervals']-$i->fields['net_term_intervals'])); + } + } + $i->MoveNext(); + } + } + $rs->MoveNext(); + } + } + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/net_term/net_term_construct.xml b/modules/net_term/net_term_construct.xml new file mode 100644 index 00000000..18afc37d --- /dev/null +++ b/modules/net_term/net_term_construct.xml @@ -0,0 +1,70 @@ + + + net_term + net_term
+ charge + 0 + name + 35 + + + I4 + 1 + + + I4 + + + L + + + X2 + any + array + + + I4 + checkout + name + + + C(16) + 2 + 16 + alphanumeric + 1 + + + C(16) + alphanumeric + + + L + + + F + float + + + I4 + numeric + + + L + + + I4 + + + I4 + + + + id,status,group_avail,checkout_id,name,sku,fee_type,fee,suspend_intervals,enable_emails,sweep_type,terms + id,status,group_avail,checkout_id,name,sku,fee_type,fee,suspend_intervals,enable_emails,sweep_type,terms + id,status,group_avail,checkout_id,name,sku,fee_type,fee,suspend_intervals,enable_emails,sweep_type,terms + id,status,group_avail,checkout_id,name,sku,fee_type,fee,suspend_intervals,enable_emails,sweep_type,terms + id,status,checkout_id,name,sku,fee_type,fee,suspend_intervals,enable_emails,sweep_type,terms + + 0 +
\ No newline at end of file diff --git a/modules/net_term/net_term_install.xml b/modules/net_term/net_term_install.xml new file mode 100644 index 00000000..22ad2fba --- /dev/null +++ b/modules/net_term/net_term_install.xml @@ -0,0 +1,37 @@ + + + + net_term + setup + This module controls the groups and checkout plugins that net terms will be available to + 1 + charge + + + + + + add + %%:add + 1 + + + update + + + delete + + + view + core:search&module=%%&_escape=1 + 1 + + + search + + + search_show + + + + \ No newline at end of file diff --git a/modules/newsletter/auth.inc.php b/modules/newsletter/auth.inc.php new file mode 100644 index 00000000..f993b796 --- /dev/null +++ b/modules/newsletter/auth.inc.php @@ -0,0 +1,14 @@ + 'newsletter', 'method' => 'check_list'), + Array ('module' => 'newsletter', 'method' => 'check_list_registration'), + Array ('module' => 'newsletter', 'method' => 'popup'), + Array ('module' => 'newsletter', 'method' => 'subscribe'), + Array ('module' => 'newsletter', 'method' => 'subscribe_confirm'), + Array ('module' => 'newsletter', 'method' => 'unsubscribe') + ); +?> \ No newline at end of file diff --git a/modules/newsletter/newsletter.inc.php b/modules/newsletter/newsletter.inc.php new file mode 100644 index 00000000..86a96d61 --- /dev/null +++ b/modules/newsletter/newsletter.inc.php @@ -0,0 +1,912 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class newsletter +{ + + # Open the constructor for this mod + function newsletter_construct() + { + # name of this module: + $this->module = "newsletter"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $this->newsletter_construct(); + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $this->newsletter_construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + + ############################## + ## POPUP VIEW ## + ############################## + function popup($VAR) + { + $this->newsletter_construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $this->newsletter_construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $this->newsletter_construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $this->newsletter_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $this->newsletter_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $this->newsletter_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + + + ############################## + ## SEND NEWSLETTERS ## + ############################## + + function send($VAR) + { + global $C_debug, $C_translate, $C_vars; + + $C_vars->strip_slashes_all(); + + ##################################################### + ### Get the setup email settings: + + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."setup_email WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr($VAR["setup_email_id"]); + $setup_email = $db->Execute($q); + + if($setup_email->fields['type'] == 0) + { + $type = 0; + } + else + { + $type = 1; + $E['server'] = $setup_email->fields['server']; + $E['account'] = $setup_email->fields['username']; + $E['password'] = $setup_email->fields['password']; + } + + $E['from_name'] = $setup_email->fields['from_name']; + $E['from_email'] = $setup_email->fields['from_email']; + + if($setup_email->fields['cc_list'] != '') + $E['cc_list'] = split(',', $setup_email->fields['cc_list']); + + if($setup_email->fields['bcc_list'] != '') + $E['bcc_list'] = split(',', $setup_email->fields['bcc_list']); + + + ##################################################### + ### Priority: + + if(isset($VAR['newsletter_priority']) && $VAR['newsletter_priority'] == '1') + $E['priority'] = 1; + + + ##################################################### + ### Subject: + + if(isset($VAR['newsletter_subject']) && $VAR['newsletter_subject'] != '') + { + $E['subject'] = $VAR['newsletter_subject']; + } + else + { + ### ERROR! + $C_debug->alert($C_translate->translate('send_alert_message','newsletter','')); + $C_debug->alert($C_translate->translate('send_alert_fail','newsletter','')); + return; + } + + + ##################################################### + ### Body (TEXT version): + + if(isset($VAR['newsletter_body_text']) && $VAR['newsletter_body_text'] != '') + { + + $E['body_text'] = $VAR['newsletter_body_text']; + + } + else + { + ### ERROR! + $C_debug->alert($C_translate->translate('send_alert_body_text','newsletter','')); + $C_debug->alert($C_translate->translate('send_alert_fail','newsletter','')); + return; + } + + ##################################################### + ### Body (HTML version): + + if(isset($VAR['newsletter_body_html']) && $VAR['newsletter_body_html'] != '') + { + $E['body_html'] = $VAR['newsletter_body_html']; + } + else + { + ### ERROR! + $C_debug->alert($C_translate->translate('send_alert_body_html','newsletter','')); + $C_debug->alert($C_translate->translate('send_alert_fail','newsletter','')); + return; + } + + + + + ##################################################### + ### TEST - Get current user account details + + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."account WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr(SESS_ACCOUNT); + $account = $db->Execute($q); + + $E['to_email'] = $account->fields['email']; + $E['to_name'] = $account->fields['first_name'] . ' ' . $account->fields['last_name']; + + ### Call the mail() or smtp() function to send + require_once(PATH_CORE . 'email.inc.php'); + $email = new CORE_email; + + if($type == 0) + { + if(isset($E['body_html'])) + { + ### SEND HTML VERSION + $E['html'] = '1'; + $email->PHP_Mail($E); + } + + ### SEND TEXT VERSION + $E['html'] = '0'; + $email->PHP_Mail($E); + + $C_debug->alert("Send success!"); + } + else + { + if(isset($E['body_html'])) + { + ### SEND HTML VERSION + $E['html'] = '1'; + $email->SMTP_Mail($E); + } + + ### SEND TEXT VERSION + $E['html'] = '0'; + $email->SMTP_Mail($E); + } + + + + + + ##################################################### + ### LIVE - Get all subscribers + if(!isset($VAR['newsletter_test'])) + { + + ### SET THE BODY & SUBJECT + $body_text = $E['body_text']; + $body_html = $E['body_html']; + $subject = $E['subject']; + + ### Delete the cc/bcc lists... + unset($E['cc_list']); + unset($E['bcc_list']); + + $newsletters = $VAR['newsletter_id']; + for($i=0; $i $subs->fields["first_name"], + 'lName'=> $subs->fields["last_name"]); + $subs->MoveNext(); + } + } + + + ### LOOP through the final results + if(!isset($arr_s) || gettype($arr_s) != 'array') + { + ### NO RESULTS... RETURN NOW! + $C_debug->alert($C_translate->translate('send_alert_no_results','newsletter','')); + $C_debug->alert($C_translate->translate('send_alert_fail','newsletter','')); + return; + + } + + $i = 0; + while (list ($key, $val) = each ($arr_s)) + { + $i++; + + $E['to_email'] = $key; + $E['to_name'] = $arr_s["$key"]["fName"] . ' ' . $arr_s["$key"]["lName"]; + + $remove = URL . '?_page=newsletter:unsubscribe&email='.$key; + + if($arr_s["$key"]["html"] == '1') + { + ### replace %name%, %email%, and %remove% with correct vars: (for html) + $E['body_html'] = eregi_replace('%name%', $arr_s["$key"]["fName"], $body_html); + $E['body_html'] = eregi_replace('%email%', $key, $E['body_html']); + $E['body_html'] = eregi_replace('%remove%', $remove, $E['body_html']); + $E['html'] = '1'; + } + else + { + ### replace %name%, %email%, and %remove% with correct vars: (for text) + $E['body_text'] = eregi_replace('%name%', $arr_s["$key"]["fName"], $body_text); + $E['body_text'] = eregi_replace('%email%', $key, $E['body_text']); + $E['body_text'] = eregi_replace('%remove%', $remove, $E['body_text']); + $E['html'] = false; + } + + + ### replace %name%, %email%, and %remove% with correct vars: (for subject) + $E['subject'] = eregi_replace('%name%', $arr_s["$key"]["fName"], $subject); + $E['subject'] = eregi_replace('%email%', $key, $E['subject']); + + + if($type == 0) + { + ### SEND THE MESSAGE + $email = new CORE_email; + $email->PHP_Mail($E); + } + else + { + ### SEND TEXT VERSION + $email = new CORE_email; + $email->SMTP_Mail($E); + } + } + + ### Completion notice + $C_debug->alert($C_translate->translate('send_alert_success','newsletter','')); + ## Sent $i messages... + } + } + + + ############################## + ## SHOW NEWSLETTER LIST ## + ############################## + + function check_list($VAR) + { + + $name = "newsletter_id"; + $table = 'newsletter'; + $field = 'name'; + $id = ''; + $input_id = ''; + + global $C_translate, $C_auth; + + # get the records + $db = &DB(); + $sql= "SELECT id,group_avail,name FROM ".AGILE_DB_PREFIX."$table + WHERE site_id = '" . DEFAULT_SITE . "' AND + active = " . $db->qstr('1') . " + ORDER BY $field"; + $result = $db->Execute($sql); + + # error handling + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','check', $db->ErrorMsg()); + } + + + # loop through the records + $i = 0; + while (!$result->EOF) { + + $groups = unserialize($result->fields['group_avail']); + + $auth = false; + for($ii=0; $iiauth_group_by_id($groups[$ii])) $auth = true; + } + + if($auth) + { + # Create the return code for Smarty + $return .= ' ' . + $result->fields["$field"] . + '  [ ? ] +
'; + $i++; + } + $result->MoveNext(); + } + + if($i==0) + $return .= 'No Newsletters Available to Your Account'; + + echo $return; + } + + + + + + ############################## + ## SHOW NEWSLETTER LIST ## + ## FOR REGISTRATION ## + ############################## + + function check_list_registration($VAR) + { + + $name = "newsletter_id"; + $table = 'newsletter'; + $field = 'name'; + $id = ''; + $input_id = ''; + + global $C_translate, $C_auth; + + # get the records + $db = &DB(); + $sql= "SELECT id,group_avail,name FROM ".AGILE_DB_PREFIX."$table + WHERE site_id = '" . DEFAULT_SITE . "' AND + active = " . $db->qstr('1') . " AND + display_signup = " . $db->qstr('1') . " + ORDER BY $field"; + $result = $db->Execute($sql); + + # error handling + if ($result === false) + { + global $C_debug; + $C_debug->error('list.inc.php','check', $db->ErrorMsg()); + } + + + # loop through the records + $i = 0; + while (!$result->EOF) { + + $groups = unserialize($result->fields['group_avail']); + + $auth = false; + for($ii=0; $iiauth_group_by_id($groups[$ii])) $auth = true; + } + + if($auth) + { + # Create the return code for Smarty + $return .= ' ' . + $result->fields["$field"] . + '  [ ? ] +
'; + $i++; + } + $result->MoveNext(); + } + + if($i==0) + $return .= 'No Newsletters Available to Your Account'; + + echo $return; + } + + + + + + + + ############################## + ## SUBSCRIBE ## + ############################## + + /* we need the following vars: + + 'newsletter_id' (array) + 'newsletter_type' (0/1) ( standalone / with new account) + 'newsletter_html' (0/1) + + 'newsletter_email' (email_required) + 'newsletter_first_name' (first name, required) + 'newsletter_last_name' (last_name, optional) + or + 'account_email' (email_required) + 'account_first_name' (from the signup form) + 'account_last_name' (from the singup form) + + */ + + + function subscribe($VAR) + { + $LIMIT_SECONDS = 120; + + global $C_debug, $C_translate; + + ### Include the validation class + include_once(PATH_CORE . 'validate.inc.php'); + + ### store the details in a temporary database, and email the user + ### a link with the time() string from the creation date of the + ### record + + + + ### Check that the required variables are set: + if(!isset($VAR['newsletter_id']) || gettype($VAR['newsletter_id']) != 'array') + { + if(isset($VAR['newsletter_type'])) { + #ERROR! + $C_debug->alert($C_translate->translate('subscribe_newsletter_req','newsletter','')); + return; + } else { + return; + } + } + + $newsletter_id = @$VAR['newsletter_id']; + + if(isset($VAR['newsletter_html'])) + $html = 1; + else + $html = 0; + + if(isset($VAR['newsletter_type'])) + { + if(empty($VAR['newsletter_first_name'])) + { + #### ERROR! + if (isset($VAR['newsletter_type'])) + $C_debug->alert($C_translate->translate('subscribe_name_req','newsletter','')); + return; + } + + $validate = new CORE_validate; + if(empty($VAR['newsletter_email']) || !$validate->validate_email($VAR['newsletter_email'], '')) + { + ### ERROR! + if (isset($VAR['newsletter_type'])) + $C_debug->alert($C_translate->translate('subscribe_email_req','newsletter','')); + return; + } + + $first_name = @$VAR['newsletter_first_name']; + $last_name = @$VAR['newsletter_last_name']; + $email = @$VAR['newsletter_email']; + } + else + { + if(!isset($VAR['account_first_name']) || $VAR['account_first_name'] == '') + return; + + $validate = new CORE_validate; + if(!isset($VAR['account_email']) || $validate->validate_email($VAR['account_email'], '') == false) + return; + + + $first_name = @$VAR['account_first_name']; + $last_name = @$VAR['account_last_name']; + $email = @$VAR['account_email']; + } + + + ### Check that this email has not been requested already + ### In the last 60 seconds + + $db = &DB(); + $sql = 'SELECT * FROM ' . AGILE_DB_PREFIX . 'temporary_data WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + field1 = ' . $db->qstr($email); + $result = $db->Execute($sql); + if($result->RecordCount() > 0) + { + $limit = $result->fields['date_orig'] + $LIMIT_SECONDS; + + if($limit > time()) + { + ### ERROR! + if(isset($VAR['newsletter_type'])) + { + $error1 = $C_translate->translate("subscribe_spam_limit","newsletter",""); + $error = ereg_replace('%limit%', "$LIMIT_SECONDS", $error1); + $C_debug->alert( $error ); + } + return; + } + else + { + ### Delete the old request + $sql = 'DELETE FROM ' . AGILE_DB_PREFIX . 'temporary_data WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + field1 = ' . $db->qstr($email); + $db->Execute($sql); + } + + } + + ##################################################### + ### Ok to continue: + + $now = time(); + $expire = time() + 86400*3; + $data = serialize(Array ('html' => $html, + 'email' => $email, + 'first_name' => $first_name, + 'last_name' => $last_name, + 'newsletter_id' => $newsletter_id, + 'var' => base64_encode(serialize(@$VAR['static_relation'])))); + + ##################################################### + ### Create the temporary DB Record: + + $db = &DB(); + $id = $db->GenID(AGILE_DB_PREFIX . "" . 'temporary_data_id'); + $sql = 'INSERT INTO ' . AGILE_DB_PREFIX . 'temporary_data SET + site_id = ' . $db->qstr(DEFAULT_SITE) . ', + id = ' . $db->qstr($id) . ', + date_orig = ' . $db->qstr($now) . ', + date_expire = ' . $db->qstr($expire) . ', + field1 = ' . $db->qstr($email) . ', + data = ' . $db->qstr($data) ; + $result = $db->Execute($sql); + + ##################################################### + ### Send the subscription confirmation email : + + $E['html'] = 0; + $E['priority'] = 0; + $E['to_email'] = $email; + $E['to_name'] = $first_name; + + global $C_translate; + $E['body_text'] = $C_translate->translate('subscribe_body','newsletter',''); + $E['subject'] = $C_translate->translate('subscribe_subj','newsletter',''); + + $E['body_text'] = eregi_replace('%name%', $first_name, $E['body_text']); + $E['body_text'] = eregi_replace('%email%', $email, $E['body_text']); + $E['body_text'] = eregi_replace('%confirm_url%', URL.'?_page=newsletter:subscribe_confirm&email='.$email.'&validate='.$now, $E['body_text']); + $E['body_text'] = eregi_replace('%site_name%', SITE_NAME, $E['body_text']); + + + ##################################################### + ### Get the setup email settings: + + $db = &DB(); + $q = "SELECT * FROM ".AGILE_DB_PREFIX."setup_email WHERE + site_id = ".$db->qstr(DEFAULT_SITE)." AND + id = ".$db->qstr(DEFAULT_SETUP_EMAIL); + $setup_email = $db->Execute($q); + + if($setup_email->fields['type'] == 0) + { + $type = 0; + } + else + { + $type = 1; + $E['server'] = $setup_email->fields['server']; + $E['account'] = $setup_email->fields['username']; + $E['password'] = $setup_email->fields['password']; + } + + $E['from_name'] = $setup_email->fields['from_name']; + $E['from_email'] = $setup_email->fields['from_email']; + + + ###################################################### + ### SEND THE MESSAGE! + + require_once(PATH_CORE . 'email.inc.php'); + $email = new CORE_email; + + if($type == 0) + { + ### SEND THE MESSAGE + $email->PHP_Mail($E); + } + else + { + ### SEND TEXT VERSION + $email->SMTP_Mail($E); + } + + ##################################################### + ### Success message! + if(isset($VAR['newsletter_type'])) + { + $message = $C_translate->translate('subscribe_confirm', 'newsletter', ''); + $C_debug->alert($message); + } + } + + + + + + ############################## + ## SUBSCRIBE CONFIRM ## + ############################## + + function subscribe_confirm($VAR) + { + global $C_debug, $C_translate; + + ### validate that the user provided their email + + /* + We need the following vars to confirm: + + 'email' + 'validate' + + */ + + if(!isset($VAR['email']) || !isset($VAR['validate'])) + { + ### ERROR: bad link.... + $url = '
' . $C_translate->translate('submit','CORE','') . ''; + $message = eregi_replace('%here%', $url, $C_translate->translate('subscribe_confirm_fail','newsletter','')); + echo $message; + return; + } + else + { + ### Confirm the email/timestamp match + $email = @$VAR['email']; + $time = @$VAR['validate']; + + + $db = &DB(); + $sql = 'SELECT data FROM ' . AGILE_DB_PREFIX . 'temporary_data WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + date_orig = ' . $db->qstr($time) . ' AND + field1 = ' . $db->qstr($email); + $result = $db->Execute($sql); + + if($result->RecordCount() == 0) + { + ### ERROR: no match for submitted link, invalid or expired. + $url = '
' . $C_translate->translate('submit','CORE','') . ''; + $message = eregi_replace('%here%', $url, $C_translate->translate('subscribe_confirm_fail','newsletter','')); + echo $message; + return; + } + + $arr = unserialize($result->fields['data']); + @$varstored['static_relation'] = unserialize(base64_decode($arr['var'])); + + + ############################################################### + ### Delete the temporary record + $sql = 'DELETE FROM ' . AGILE_DB_PREFIX . 'temporary_data WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + field1 = ' . $db->qstr($email); + $db->Execute($sql); + + + + + ############################################################### + ### Create the newsletter subscription(s): + $db = &DB(); + for($i=0; $iadd($varstored, 'newsletter_subscriber', $id); + } + + + ### Return the success message: + echo $C_translate->translate('subscribe_confirm_success','newsletter',''); + } + + } + + + + + ############################## + ## UNSUBSCRIBE ## + ############################## + + function unsubscribe($VAR) + { + global $C_debug, $C_translate; + + ### Check required var + if(!isset($VAR['newsletter_email']) || $VAR['newsletter_email'] == '') + { + ### ERROR: bad link.... + $message = $C_translate->translate('subscribe_email_req','newsletter',''); + $C_debug->alert($message); + return; + } + + ### Confirm the email/timestamp match + $email = @$VAR['newsletter_email']; + $n_id = @$VAR['newsletter_id']; + + + ######################################################### + ### Drop any existing subscriptions to avoid duplicates! + + $db = &DB(); + if(gettype($n_id) == 'array') + { + for($i=0; $ialert($message); + } +} +?> \ No newline at end of file diff --git a/modules/newsletter/newsletter_construct.xml b/modules/newsletter/newsletter_construct.xml new file mode 100644 index 00000000..1015d461 --- /dev/null +++ b/modules/newsletter/newsletter_construct.xml @@ -0,0 +1,60 @@ + + + + newsletter + + newsletter
+ + + + 0 + + name + + 25 + + + + I4 + 1 + 1 + + + I4 + + + C(255) + any + array + + + C(255) + 1 + 255 + 1 + + + X2 + 1 + + + X2 + + + L + + + L + + + + + id,site_id,group_avail,name,description,notes,active,display_signup + id,site_id,group_avail,name,description,notes,active,display_signup + id,site_id,group_avail,name,description,notes,active,display_signup + id,site_id,group_avail,name,description,notes,active,display_signup + id,site_id,group_avail,name,description,notes,active,display_signup + + + 0 +
diff --git a/modules/newsletter/newsletter_install.xml b/modules/newsletter/newsletter_install.xml new file mode 100644 index 00000000..dedccf5c --- /dev/null +++ b/modules/newsletter/newsletter_install.xml @@ -0,0 +1,48 @@ + + + newsletter + newsletter + + 1 + + + + + search + + + 1 + + + view + + + 1 + + + add + + 1 + + + delete + + + update + + + search_form + + + search_show + + + + send + + + 1 + + + + \ No newline at end of file diff --git a/modules/newsletter/newsletter_install_data.xml b/modules/newsletter/newsletter_install_data.xml new file mode 100644 index 00000000..4006e444 --- /dev/null +++ b/modules/newsletter/newsletter_install_data.xml @@ -0,0 +1,15 @@ + + + + 0 + 1 + + Newsletter 1 + Sign up today! + 1 + 1 + + + 3 + + \ No newline at end of file diff --git a/modules/newsletter_subscriber/auth.inc.php b/modules/newsletter_subscriber/auth.inc.php new file mode 100644 index 00000000..3b7bc450 --- /dev/null +++ b/modules/newsletter_subscriber/auth.inc.php @@ -0,0 +1,9 @@ + 'newsletter_subscriber', 'method' => 'static_var') + ); +?> \ No newline at end of file diff --git a/modules/newsletter_subscriber/newsletter_subscriber.inc.php b/modules/newsletter_subscriber/newsletter_subscriber.inc.php new file mode 100644 index 00000000..728e3e46 --- /dev/null +++ b/modules/newsletter_subscriber/newsletter_subscriber.inc.php @@ -0,0 +1,726 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class newsletter_subscriber +{ + + # Open the constructor for this mod + function newsletter_subscriber() + { + # name of this module: + $this->module = "newsletter_subscriber"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + ############################## + ## GRAPH STATISTICS ## + ############################## + function graph($start, $end, $constraint, $default) + { + global $C_translate; + + + $db = &DB(); + $sql = 'SELECT date_orig FROM ' . AGILE_DB_PREFIX . 'newsletter_subscriber WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + date_orig >= ' . $db->qstr($start) . ' AND + date_orig <= ' . $db->qstr($end); + + $result = $db->Execute($sql); + if($result->RecordCount() == 0) + { + $arr['title'] = $C_translate->translate('search_no_results','',''); + $arr['results'] = $default; + return $arr; + } + $ii=0; + while(!$result->EOF) + { + $d = $result->fields['date_orig']; + for($i=0; $i= $constraint[$i]["start"] && $d < $constraint[$i]["end"]) + $default[$i]++; + $ii++; + } + $result->MoveNext(); + } + + $C_translate->value['newsletter_subscriber']['count'] = $result->RecordCount(); + $title = $C_translate->translate('statistics','newsletter_subscriber',''); + $arr['title'] = $title; + $arr['results'] = $default; + return $arr; + } + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $id = $db->add($VAR, $this, $type); + + ### Set the static vars: + if($id) + { + global $smarty; + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + $static_var->add($VAR, $this->module, $id); + } + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + + ### Get the static vars: + global $smarty; + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + $ids = explode(',',$VAR['id']); + $arr = $static_var->update_form($this->module, 'update', $ids[0]); + if(gettype($arr) == 'array') + $smarty->assign('static_var', $arr); + else + $smarty->assign('static_var', false); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + if($db->update($VAR, $this, $type)) + { + ### Update the static vars: + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + $static_var->update($VAR, 'newsletter_subscriber', $VAR['id']); + } + } + + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + + $db = &DB(); + + include_once(PATH_CORE . 'validate.inc.php'); + $validate = new CORE_validate; + + # set the search criteria array + $arr = $VAR; + + # loop through the submitted field_names to get the WHERE statement + $where_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + if($value != '') + { + $pat = "^" . $this->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value = $validate->convert($field, $value, $this->field["$field"]["convert"]); + } + + $where_list .= " WHERE ".AGILE_DB_PREFIX."newsletter_subscriber.".$field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $this->module.'_'.$field; + $VAR['field_option']["$pat_field"]["$i_arr"]; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $this->field["$field"]["convert"]); + } + + + if($i_arr == 0) + { + $where_list .= " WHERE ".AGILE_DB_PREFIX."newsletter_subscriber.".$field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + else + { + $where_list .= " AND ".AGILE_DB_PREFIX."newsletter_subscriber.".$field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + } + else + { + $where_list .= " WHERE ".AGILE_DB_PREFIX."newsletter_subscriber.".$field . " = " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + else + { + if($value != '') + { + $pat = "^" . $this->module . "_"; + if(eregi($pat, $key)) + { + $field = eregi_replace($pat,"",$key); + if(eregi('%',$value)) + { + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value = $validate->convert($field, $value, $this->field["$field"]["convert"]); + } + + $where_list .= " AND ".AGILE_DB_PREFIX."newsletter_subscriber.".$field . " LIKE " . $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + else + { + # check if array + if(is_array($value)) + { + for($i_arr=0; $i_arr < count($value); $i_arr++) + { + if($value["$i_arr"] != '') + { + # determine any field options (=, >, <, etc...) + $f_opt = '='; + $pat_field = $this->module.'_'.$field; + if(isset($VAR['field_option']["$pat_field"]["$i_arr"])) + { + $f_opt = $VAR['field_option']["$pat_field"]["$i_arr"]; + + # error checking, safety precaution + if($f_opt != '=' && $f_opt != '>' && $f_opt != '<' && $f_opt != '>=' && $f_opt != '<=' && $f_opt != '!=') + $f_opt = '='; + } + + # do any data conversion for this field (date, encrypt, etc...) + if(isset($this->field["$field"]["convert"])) + { + $value["$i_arr"] = $validate->convert($field, $value["$i_arr"], $this->field["$field"]["convert"]); + } + + $where_list .= " AND ".AGILE_DB_PREFIX."newsletter_subscriber.". $field . " $f_opt " . $db->qstr($value["$i_arr"], get_magic_quotes_gpc()); + $i++; + } + } + } + else + { + $where_list .= " AND ".AGILE_DB_PREFIX."newsletter_subscriber.". $field . " = ". $db->qstr($value, get_magic_quotes_gpc()); + $i++; + } + } + } + } + } + } + + #### finalize the WHERE statement + if($where_list == '') + { + $where_list .= ' WHERE '; + } + else + { + $where_list .= ' AND '; + } + + + # get limit type + if(isset($VAR['limit'])) + { + $limit = $VAR['limit']; + } + else + { + $limit = $this->limit; + } + + # get order by + if(isset($VAR['order_by'])) + { + $order_by = $VAR['order_by']; + } + else + { + $order_by = $this->order_by; + } + + $pre = AGILE_DB_PREFIX; + + + $q = "SELECT DISTINCT ".AGILE_DB_PREFIX."newsletter_subscriber.id FROM ".AGILE_DB_PREFIX."newsletter_subscriber "; + $q_save = "SELECT DISTINCT %%fieldList%% FROM ".AGILE_DB_PREFIX."newsletter_subscriber "; + + + ######## GET ANY STATIC VARS TO SEARCH ########## + $join_list = ''; + if(!empty($VAR["static_relation"]) && count( $VAR["static_relation"] > 0 )) { + while(list($idx, $value) = each ($VAR["static_relation"])) { + if($value != "") { + + $join_list .= " INNER JOIN {$pre}static_var_record AS s{$idx} ON + ( + s{$idx}.record_id = {$pre}{$this->table}.id + AND + s{$idx}.static_var_relation_id = '{$idx}' + AND + s{$idx}.site_id = ".$db->qstr(DEFAULT_SITE)." + AND"; + if(ereg("%", $value)) + $join_list .= " s{$idx}.value LIKE ".$db->qstr($VAR["static_relation"]["$idx"]); + else + $join_list .= " s{$idx}.value = ".$db->qstr($VAR["static_relation"]["$idx"]); + $join_list .= " ) "; + } + } + } + ######## END STATIC VAR SEARCH ################## + + + # standard where list + $q .= $join_list . $where_list ." ".AGILE_DB_PREFIX."newsletter_subscriber.site_id = " . $db->qstr(DEFAULT_SITE); + $q_save .= $join_list . $where_list ." %%whereList%% "; + + + ################## DEBUG ################## + #echo "
" . $q;
+		#echo "

" . $q_save; + #exit; + + # run the database query + $result = $db->Execute($q); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('newsletter_subscriber.inc.php','search', $db->ErrorMsg()); + return false; + } + + # get the result count: + $results = $result->RecordCount(); + + # get the first record id: + if($results == 1) $record_id = $result->fields['id']; + + # define the DB vars as a Smarty accessible block + global $smarty; + + # Create the definition for fast-forwarding to a single record: + if ($results == 1 && !isset($this->fast_forward)) + { + $smarty->assign('record_id', $record_id); + } + + # create the search record: + if($results > 0) + { + # create the search record + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $arr['module'] = $this->module; + $arr['sql'] = $q_save; + $arr['limit'] = $limit; + $arr['order_by']= $order_by; + $arr['results'] = $results; + $search->add($arr); + + # define the search id and other parameters for Smarty + $smarty->assign('search_id', $search->id); + + # page: + $smarty->assign('page', '1'); + + # limit: + $smarty->assign('limit', $limit); + + # order_by: + $smarty->assign('order_by', $order_by); + } + + # define the result count + $smarty->assign('results', $results); + } + + + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + + # set the field list for this method: + $arr = $this->method[$type]; + + $field_list = ''; + $i=0; + while (list ($key, $value) = each ($arr)) + { + if($i == 0) + { + $field_var = $this->table . '_' . $value; + $field_list .= AGILE_DB_PREFIX . "newsletter_subscriber" . "." . $value; + + // determine if this record is linked to another table/field + if($this->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $this->field[$value]["asso_table"], 'link_field' => $this->field[$value]["asso_field"]); + } + } + else + { + $field_var = $this->table . '_' . $value; + $field_list .= "," . AGILE_DB_PREFIX . "newsletter_subscriber" . "." . $value; + + // determine if this record is linked to another table/field + if($this->field[$value]["asso_table"] != "") + { + $this->linked[] = array('field' => $value, 'link_table' => $this->field[$value]["asso_table"], 'link_field' => $this->field[$value]["asso_field"]); + } + } + $i++; + } + + + # get the search details: + if(isset($VAR['search_id'])) { + include_once(PATH_CORE . 'search.inc.php'); + $search = new CORE_search; + $search->get($VAR['search_id']); + } else { + # invalid search! + echo '
The search terms submitted were invalid!'; # translate... # alert + + if(isset($this->trigger["$type"])) { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + } + + # get the sort order details: + if(isset($VAR['order_by']) && $VAR['order_by'] != "") { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . 'newsletter_subscriber.'.$VAR['order_by']; + $smarty_order = $VAR['order_by']; + } else { + $order_by = ' ORDER BY ' . AGILE_DB_PREFIX . 'newsletter_subscriber.'.$this->order_by; + $smarty_order = $search->order_by; + } + + + # determine the sort order + if(isset($VAR['desc'])) { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } else if(isset($VAR['asc'])) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + if (!eregi('date',$smarty_order)) { + $order_by .= ' ASC'; + $smarty_sort = 'asc='; + } else { + $order_by .= ' DESC'; + $smarty_sort = 'desc='; + } + } + + # determine the offset & limit + $current_page=1; + $offset=-1; + if (!empty($VAR['page'])) $current_page = $VAR['page']; + if (empty($search->limit)) $search->limit=25; + if($current_page>1) $offset = (($current_page * $search->limit) - $search->limit); + + # generate the full query + $db = &DB(); + $q = eregi_replace("%%fieldList%%", $field_list, $search->sql); + $q = eregi_replace("%%tableList%%", AGILE_DB_PREFIX.$construct->table, $q); + $q = eregi_replace("%%whereList%%", "", $q); + $q .= " ".AGILE_DB_PREFIX . "newsletter_subscriber."."site_id = " . $db->qstr(DEFAULT_SITE); + $q .= $order_by; + + ////////////////// + #echo "
 $q 

"; + + $result = $db->SelectLimit($q, $search->limit); + + # error reporting + if ($result === false) + { + global $C_debug; + $C_debug->error('newsletter_subscriber.inc.php','search_show', $db->ErrorMsg()); + + if(isset($this->trigger["$type"])) + { + include_once(PATH_CORE . 'trigger.inc.php'); + $trigger = new CORE_trigger; + $trigger->trigger($this->trigger["$type"], 0, $VAR); + } + return; + } + + + # put the results into a smarty accessable array + $i=0; + $class_name = TRUE; + while (!$result->EOF) { + $smart[$i] = $result->fields; + + if($class_name) + { + $smart[$i]['_C'] = 'row1'; + $class_name = FALSE; + } else { + $smart[$i]['_C'] = 'row2'; + $class_name = TRUE; + } + $result->MoveNext(); + $i++; + } + + + # get any linked fields + if($i > 0) + { + $db_join = new CORE_database; + $this->result = $db_join->join_fields($smart, $this->linked); + } + else + { + $this->result = $smart; + } + + # get the result count: + $results = $result->RecordCount(); + + # define the DB vars as a Smarty accessible block + global $smarty; + + # define the results + $smarty->assign($this->table, $this->result); + $smarty->assign('page', $VAR['page']); + $smarty->assign('order', $smarty_order); + $smarty->assign('sort', $smarty_sort); + $smarty->assign('limit', $search->limit); + $smarty->assign('search_id',$search->id); + $smarty->assign('results', $search->results); + + # get the total pages for this search: + if(empty($search->limit)) + $this->pages = 1; + else + $this->pages = intval($search->results / $search->limit); + if ($search->results % $search->limit) $this->pages++; + + # total pages + $smarty->assign('pages', $this->pages); + + # current page + $smarty->assign('page', $current_page); + $page_arr = ''; + for($i=0; $i <= $this->pages; $i++) + { + if ($this->page != $i) $page_arr[] = $i; + } + + # page array for menu + $smarty->assign('page_arr', $page_arr); + } + + + + + + ############################## + ## SEARCH EXPORT ## + ############################## + function search_export($VAR) + { + # require the export class + require_once (PATH_CORE . "export.inc.php"); + + # Call the correct export function for inline browser display, download, email, or web save. + if($VAR["format"] == "excel") + { + $type = "export_excel"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_excel($VAR, $this, $type); + } + + else if ($VAR["format"] == "pdf") + { + $type = "export_pdf"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_pdf($VAR, $this, $type); + } + + else if ($VAR["format"] == "xml") + { + $type = "export_xml"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_xml($VAR, $this, $type); + } + + else if ($VAR["format"] == "csv") + { + $type = "export_csv"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_csv($VAR, $this, $type); + } + + else if ($VAR["format"] == "tab") + { + $type = "export_tab"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_tab($VAR, $this, $type); + } + } + + + ############################## + ## STATIC VARS ## + ############################## + + function static_var($VAR) + { + global $smarty; + + require_once(PATH_CORE . 'static_var.inc.php'); + $static_var = new CORE_static_var; + + if(ereg('search', $VAR['_page'])) + $arr = $static_var->generate_form($this->module, 'add', 'search'); + else + $arr = $static_var->generate_form($this->module, 'add', 'update'); + + if(gettype($arr) == 'array') + { + ### Set everything as a smarty array, and return: + $smarty->assign('show_static_var', true); + $smarty->assign('static_var', $arr); + return true; + } + else + { + ### Or if no results: + $smarty->assign('show_static_var', false); + return false; + } + } +} +?> \ No newline at end of file diff --git a/modules/newsletter_subscriber/newsletter_subscriber_construct.xml b/modules/newsletter_subscriber/newsletter_subscriber_construct.xml new file mode 100644 index 00000000..ecd8d86a --- /dev/null +++ b/modules/newsletter_subscriber/newsletter_subscriber_construct.xml @@ -0,0 +1,65 @@ + + + + newsletter_subscriber + + newsletter_subscriber
+ + + + 0 + + newsletter_id + + 25 + + + + I8 + 1 + 1 + + + I4 + + + I8 + date-time + + + I8 + newsletter + name + + + C(128) + 1 + 128 + email + + + L + + + C(128) + + + C(128) + + + + + id,site_id,date_orig,newsletter_id,email,html,first_name,last_name + id,site_id,date_orig,newsletter_id,email,html,first_name,last_name + id,site_id,date_orig,newsletter_id,email,html,first_name,last_name + id,site_id,date_orig,newsletter_id,email,html,first_name,last_name + id,site_id,date_orig,newsletter_id,email,html,first_name,last_name + id,newsletter_id,email,html,first_name,last_name + id,newsletter_id,email,html,first_name,last_name + id,newsletter_id,email,html,first_name,last_name + id,newsletter_id,email,html,first_name,last_name + id,newsletter_id,email,html,first_name,last_name + + + 0 +
diff --git a/modules/newsletter_subscriber/newsletter_subscriber_install.xml b/modules/newsletter_subscriber/newsletter_subscriber_install.xml new file mode 100644 index 00000000..c1dc5e8f --- /dev/null +++ b/modules/newsletter_subscriber/newsletter_subscriber_install.xml @@ -0,0 +1,54 @@ + + + newsletter_subscriber + newsletter + + 1 + + + + + search + + + 1 + + + view + + + 1 + + + add + + 1 + + + delete + + + update + + + search_form + + + search_show + + + + search_export + + + export_excel + + + export_csv + + + export_tab + + + + \ No newline at end of file diff --git a/modules/product/auth.inc.php b/modules/product/auth.inc.php new file mode 100644 index 00000000..28073223 --- /dev/null +++ b/modules/product/auth.inc.php @@ -0,0 +1,9 @@ + 'product', 'method' => 'details') + ); +?> \ No newline at end of file diff --git a/modules/product/base_product_plugin.inc.php b/modules/product/base_product_plugin.inc.php new file mode 100644 index 00000000..4f643105 --- /dev/null +++ b/modules/product/base_product_plugin.inc.php @@ -0,0 +1,128 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** + * Basic Product Plugin Class for AgileBill + * + */ +class base_product_plugin +{ + var $name = ''; + var $tax_based = false; + var $remote_based = true; + var $account; + var $product; + var $product_attr; + + /** + * Provision new service + */ + function p_new() + { + return true; + } + + /** + * Modify service + */ + function p_edit() + { + return true; + } + + /** + * Suspend service + */ + function p_inactive() + { + return true; + } + + /** + * Activate service + */ + function p_active() + { + return true; + } + + /** + * Delete service + */ + function p_delete() + { + return true; + } + + function p_one($id) + { + global $C_debug; + + /* Get the service details */ + $db = &DB(); + $rs = $db->Execute(sqlSelect($db,"service","*","id=::$id::")); + if(!$rs || !$rs->RecordCount()) return false; + $this->service = $rs->fields; + @$this->plugin_data = unserialize($this->service['prod_plugin_data']); + @$this->prod_attr_cart = unserialize($this->service['prod_attr_cart']); + + /* Get the account details */ + $acct = $db->Execute(sqlSelect($db,"account","*","id=::{$this->service['account_id']}::")); + if($acct && $acct->RecordCount()) $this->account = $acct->fields; + + /* Get the product details */ + if(!empty($this->service['product_id'])) { + $product = $db->Execute(sqlSelect($db,"product","*","id = ::{$this->service['product_id']}::")); + $this->product = $product->fields; + @$this->product_attr = unserialize($product->fields['prod_plugin_data']); + } + + /* determine the correct action */ + switch ($this->service['queue']) + { + case 'new': + $result = $this->p_new(); + break; + case 'active': + $result = $this->p_active(); + break; + case 'inactive': + $result = $this->p_inactive(); + break; + case 'edit': + if ($this->service['active'] == 1) + $this->p_active(); + else + $this->p_inactive(); + $result = $this->p_edit(); + break; + case 'delete': + $result = $this->p_delete(); + break; + } + if(@$result !== false) { + $sql = 'UPDATE '.AGILE_DB_PREFIX.'service SET queue='.$db->qstr('none') . ', date_last='.$db->qstr(time()) . ' WHERE id ='.$db->qstr($rs->fields['id']).' AND site_id='.$db->qstr(DEFAULT_SITE); + $upd = $db->Execute($sql); + } else { + $C_debug->error($this->name.'php', $this->service['queue'], @$result); + } + } +} +?> \ No newline at end of file diff --git a/modules/product/product.inc.php b/modules/product/product.inc.php new file mode 100644 index 00000000..8a1af03c --- /dev/null +++ b/modules/product/product.inc.php @@ -0,0 +1,720 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class product +{ + /** + * Holds the array of available attributes for the current product + * @var array + */ + var $attr; + + /** Admin: View details */ + function admin_details($VAR) { + $this->session_id = SESS; + if(!empty($VAR['account_id'])) { + $this->account_id = $VAR['account_id']; + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"session","id","account_id={$this->account_id}")); + if($rs && $rs->RecordCount()) $this->session_id = $rs->fields['id']; + } + $this->details($VAR, $this); + } + + /** User: View details */ + function details($VAR, &$product_obj) { + global $smarty; + if(empty($VAR['id'])) return false; + + # able to view inactive items? + $db = &DB(); + global $C_auth; + if($C_auth->auth_method_by_name('invoice','add')) $active = ''; else $active = " AND active=1"; + + $result = $db->Execute(sqlSelect($db,"product","*","id=::{$VAR['id']}:: $active")); + if($result->RecordCount() == 0) return false; + + # check for group settings: + $groups = unserialize($result->fields['group_avail']); + $auth = false; + for($ii=0; $iiauth_group_by_id($groups[$ii])) { + $auth = true; + break; + } + } + if(!$auth) return false; + + # define the DB vars as a Smarty accessible block + $smarty->assign('product', $result->fields); + + # If trial, get the sku of the trial product: + if($result->fields["price_type"] == '2') { + $trial = $db->Execute(sqlSelect($db,"*","product","id=::{$result->fields["price_trial_prod"]}::")); + $smarty->assign('trial', $trial->fields); + } + + # Get the best price for base, setup, & any attributes: + $this->price_arr($result->fields); + $smarty->assign('price', $this->price); + + # Get any attributes & attribute pricing: + $this->attr_arr($VAR['id']); + $smarty->assign('attr', $this->attr); + + return true; + } + + /** + * Get Atribute values for product details page, sets $this->attr + * + * @param int $product_id The product id + * @return unknown + */ + function attr_arr($product_id) + { + global $C_auth; + # set the current account + if(empty($this->account_id)) $this->account_id = SESS_ACCOUNT; + $db = &DB(); + $result = $db->Execute(sqlSelect($db,"product_attr","*","product_id=::$product_id::","sort_order")); + if(!$result || $result->RecordCount() == 0) { + $this->attr = false; + return false; + } + # loop through each attribute to get the values: + $i=0; + while( !$result->EOF ) { + $this->attr[$i]["id"] = $result->fields["id"]; + $this->attr[$i]["type"] = $result->fields["collect_type"]; + $this->attr[$i]["default"] = $result->fields["collect_default"]; + $this->attr[$i]["name"] = $result->fields["name"]; + $this->attr[$i]["description"] = $result->fields["description"]; + $this->attr[$i]["required"] = $result->fields["required"]; + #get the best base & setup price + $g_ar = unserialize($result->fields["price_group"]); + $ret['base'] = $result->fields["price_base"]; + $ret['setup'] = $result->fields["price_setup"]; + if($ret['base'] != 0 && $ret['setup']!= 0) { + if(count($g_ar) > 0) { + while (list ($group, $vals) = each ($g_ar)) { + if ($C_auth->auth_group_by_account_id($this->account_id, $group)) { + if($vals["price_base"] != "" && $vals["price_base"] < $ret['base']) + $ret['base'] = $vals["price_base"]; + if($vals["price_setup"] != "" && $vals["price_setup"] < $ret['setup']) + $ret['setup'] = $vals["price_setup"]; + } + } + } + } + # if menu, get the menu values as an array: + if($result->fields["collect_type"] == '2') { + $pat="\r\n"; + $tarr = false; + $marr = explode($pat,$result->fields["collect_default"]); + for($ii=0;$ii '', 'base' => 0, 'setup' => 0); + } else { + # populated line, determine base/setup price: + if(ereg('==', $marr[$ii])) { + # Use custom prices + $marrp = explode("==", $marr[$ii]); + $tarr[] = Array ('name' => @$marrp[0], 'base' => @$marrp[1], 'setup' => @$marrp[2]); + } else { + # Use default prices + $tarr[] = Array ('name' => $marr[$ii], 'base' => $ret['base'], 'setup' => $ret['setup']); + } + } + } + $this->attr[$i]["default"] = $tarr; + } + + $this->attr[$i]["price_base"] = $ret["base"]; + $this->attr[$i]["price_setup"] = $ret["setup"]; + $result->MoveNext(); + $i++; + } + return true; + } + + /** + * Calculate the cost for the attributes in the cart + * + * @param array $fields The product record fields + * @param array $cart_attr The array of attributes in the cart + * @param int $recurr_schedule The recurring schedule, 0-5 + * @param int $account The account id + * @param bool $prorate Apply prorating or not + * @return unknown + */ + function price_attr($fields, $cart_attr, $recurr_schedule, $account=SESS_ACCOUNT, $prorate=true) + { + global $C_auth; + $ret['base'] = 0; + $rest['setup'] = 0; + $product_id = $fields['id']; + + # Get the vars: + if(!empty($cart_attr) && !is_array($cart_attr)) $cart_attr = unserialize($cart_attr); + if(!is_array($cart_attr)) return false; + + # get the attributes for this product + $db = &DB(); + $result = $db->Execute(sqlSelect($db, "product_attr", "*","product_id=::$product_id::","sort_order")); + if(!$result || $result->RecordCount() == 0) { + $this->attr = false; + return false; + } + + # loop through each attribute to get the values & validate the input: + $i=0; + while( !$result->EOF ) { + $calc = false; + reset($cart_attr); + # loop through each attribute defined in the cart + foreach($cart_attr as $id=>$val) { + $menu_def = true; + # if defined in the cart: + if(!empty($val) && is_numeric($id) && $id == $result->fields["id"]) { + # get the best base & setup price + $g_ar = unserialize($result->fields["price_group"]); + $curr['base'] = $result->fields["price_base"]; + $curr['setup'] = $result->fields["price_setup"]; + ### if menu, get the base & setup amount from the selected item: + if($result->fields["collect_type"] == '2') { + $marr = explode("\r\n",$result->fields["collect_default"]); + # Loop through each menu option + for($ii=0;$iiattr[$i]["default"] = $tarr; + } + + ### determine best group pricing + if($menu_def) { + if($curr['base'] > 0 || $curr['setup'] > 0) { + if(count($g_ar) > 0) { + $idx = 0; + while (( (list ($group, $vals) = each ($g_ar)) && ($idx < 1) )) { + // check if better pricing exist for current group + if (is_numeric($group) && $C_auth->auth_group_by_account_id($account, $group)) { + // calculate the base price + if($vals["price_base"] != "" && $vals["price_base"] < $curr['base']) @$ret['base'] += $vals["price_base"]; + else @$ret['base'] += $curr["base"]; + // calculate the setup price + if($vals["price_setup"] != "" && $vals["price_setup"] < $curr['setup']) @$ret['setup'] += $vals["price_setup"]; + else @$ret['setup'] += $curr["setup"]; + $idx++; + } + } + } + } + } + } + } + $result->MoveNext(); + $i++; + } + + # check the subscription schedule and calculate actual rate for this schedule: + $arr = Array(.23, 1, 3, 6, 12, 24, 36); + if($fields["price_recurr_type"] == 1) + $ret['base'] *= $arr[$recurr_schedule]; + + # check for any prorating for the selected schedule: + if($fields["price_recurr_type"] == 1 && $prorate==true) + $prorate = $this->prorate($recurr_schedule, $fields["price_recurr_weekday"], $fields["price_recurr_week"]); + + # calculate the prorated recurring amount: + if (@$prorate > 0 && $ret["base"] > 0) $ret["base"] *= $prorate; + + return Array('base' => @$ret["base"], 'setup' => @$ret["setup"]); + } + + /** + * Get the start & end of set billing schedules + * + * @param int $type + * @param int $weekday + * @param int $week + * @return float + */ + function recurrDates($type, $weekday, $week) { + if ($type == 0) { + $period_start = time(); + $period_end = $period_start + (86400*7); + return Array('start' => $period_start, 'end' => $period_end); + } elseif ($type == 1) { + $inc_months = 1; + } elseif ($type == 2) { + $inc_months = 3; + } elseif ($type == 3) { + $inc_months = 6; + } elseif ($type == 4) { + $inc_months = 12; + } elseif ($type == 5) { + $inc_months = 24; + } else { + return false; + } + $d = mktime(0, 0 ,0 ,date('m', time()), $weekday, date('y', time())); + if($d < time()) + $period_start = $d; + else + $period_start = mktime(0,0,0,date('m', $d)-1, $weekday, date('y', $d)); + $period_end = mktime(0,0,0,date('m', $period_start)+$inc_months, $weekday, date('y', $period_start)); + return Array('start' => $period_start, 'end' => $period_end); + } + + /** + * Determine Prorate Amount + * + * @param int $type + * @param int $weekday + * @param int $week + * @return float + */ + function prorate($type, $weekday, $week) + { + $arr = $this->recurrDates($type, $weekday, $week); + if(!$arr) return 0; + $total_time = $arr['end'] - $arr['start']; + $remain_time = $arr['end'] - time(); + $percent_remain = ($remain_time/$total_time) ; + return round($percent_remain,2); + } + + /** + * Get the lowest price for one-time or recurring product fees + * + * @param array $fields Array containing all product fields + */ + function price_arr($fields) { + global $C_auth; + if(empty($this->account_id)) $this->account_id = SESS_ACCOUNT; + + $type = $fields['price_type']; + $g_ar = unserialize($fields["price_group"]); + if($type != "1") + { + # get the best base price (trial or one-time charges): + $ret['base'] = $fields["price_base"]; + $ret['setup'] = $fields["price_setup"]; + + if(is_array($g_ar) && count($g_ar) > 0) + { + while (list ($group, $vals) = each ($g_ar)) + { + if (is_numeric($group) && $C_auth->auth_group_by_account_id($this->account_id, $group)) + { + if($this->group_pricing($group)) + { + if($vals["price_base"] != "" || $vals["price_setup"] != "" ) + { + if(!empty($vals["price_base"]) && $vals["price_base"] < $ret['base']) + $ret['base']= $vals["price_base"]; + if(!empty($vals["price_setup"]) && $vals["price_setup"] < $ret['setup']) + $ret['setup'] = $vals["price_setup"]; + } + } + } + } + } + $this->price = $ret; + } + else + { + ## Recurring charge, return best base/setup rates for all available payment schedules + if(is_array($g_ar) && count($g_ar) > 0) + { + for($i=0; $i$vals) + { + if($g_ar[$i]["show"] == "1") + { + if (is_numeric($group) && $C_auth->auth_group_by_account_id($this->account_id, $group)) + { + if($this->group_pricing($group)) + { + if($vals["price_base"] != "" || $vals["price_setup"] != "" ) + { + if(empty($ret[$i]['base']) || $vals["price_base"] < $ret[$i]['base']) $ret["$i"]['base'] = $vals["price_base"]; + if(empty($ret[$i]['setup']) || $vals["price_setup"] < $ret[$i]['setup']) $ret["$i"]['setup'] = $vals["price_setup"]; + } + } + } + } + } + } + } + } + $this->price = $ret; + } + + /** + * Check if alternate pricing is allowed for specified group + * + * @param int $group Group ID + * @return bool + */ + function group_pricing($group) { + $db = &DB(); + $rs = $db->Execute(sqlSelect($db,"group","pricing","id=$group")); + if($rs && $rs->fields['pricing']==1) return true; + } + + /** + * Best Price for Product + * + * @param array $fields + * @param array $recurr_schedule + * @param int $account + * @param bool $prorate + * @return array + */ + function price_prod($fields, $recurr_schedule, $account=SESS_ACCOUNT, $prorate=true) { + global $C_auth; + $type = $fields['price_type']; + @$g_ar = unserialize($fields["price_group"]); + if($type != "1") { + # get the best base price (trial or one-time charges) + $ret['base'] = $fields["price_base"]; + $ret['setup'] = $fields["price_setup"]; + if(is_array($g_ar) && count($g_ar) > 0 ) { + while (list ($group, $vals) = each ($g_ar)) { + if (is_numeric($group) && $C_auth->auth_group_by_account_id($account,$group)) { + if($this->group_pricing($group)) { + if($vals["price_base"] != "" && $vals["price_base"] < $ret['base']) $ret['base']= $vals["price_base"]; + if($vals["price_setup"] != "" && $vals["price_setup"] < $ret['setup']) $ret['setup'] = $vals["price_setup"]; + } + } + } + } + return Array('base' => $ret["base"], 'setup' => $ret["setup"]); + } else { + ## Recurring charge, return best base/setup rates for all available payment schedules + if(is_array($g_ar) && count($g_ar) > 0) { + $i = $recurr_schedule; + # check for any prorating for the selected schedule: + if($fields["price_recurr_type"] == 1 && $prorate==true) + $prorate = $this->prorate($recurr_schedule, $fields["price_recurr_weekday"], $fields["price_recurr_week"]); + while (list ($group, $vals) = each ($g_ar[$i])) { + if($g_ar[$i]["show"] == "1") { + if (is_numeric($group) && $C_auth->auth_group_by_account_id($account, $group)) { + if($this->group_pricing($group)) { + if($vals["price_base"] != "") + if(empty($ret['base']) || $vals["price_base"] < $ret['base']) $ret['base'] = $vals["price_base"]; + if($vals["price_setup"] != "") + if(empty($ret['setup']) || $vals["price_setup"] < $ret['setup']) + $ret['setup'] = $vals["price_setup"]; + } + } + } + } + } + if(empty($ret)) return false; + + # calculate the prorated recurring amount: + if (@$prorate > 0 && $ret["base"] > 0) $ret["base"] *= $prorate; + } + return Array('base' => @$ret["base"], 'setup' => @$ret["setup"]); + } + + /** + * Get the lowest (recurring) price + * + * @param array $fields + * @param int $account + * @return array Recurring Price + */ + function price_recurr_arr($fields, $account) { + global $C_auth; + $g_ar = unserialize($fields["price_group"]); + if(count($g_ar) > 0) { + for($i=0; $iauth_group_by_account_id($account,$group)) { + if($vals["price_base"] != "") + if(empty($ret[$i]['base']) || $vals["price_base"] < $ret[$i]['base']) $ret[$i]['base'] = $vals["price_base"]; + + if($vals["price_setup"] != "") + if(empty($ret[$i]['setup']) || $vals["price_setup"] < $ret[$i]['setup']) $ret[$i]['setup'] = $vals["price_setup"]; + } + } + } + } + } + return $ret; + } + + /** + * Clone Existing Product + */ + function cloner($VAR) + { + global $C_debug, $C_translate; + + $product_id = $VAR['id']; + $sku = $VAR['product_sku']; + $p = AGILE_DB_PREFIX; + + if(empty($product_id) || empty($sku)) { + $C_debug->alert( $C_translate->translate('clone_error', 'product','')); + return false; + } + + $db = &DB(); + $dbc= new CORE_database; + + # Get current product details + $sql = $dbc->sql_select("product", "*", "id = $product_id", "", $db); + $result = $db->Execute($sql); + + # Clone product + $new_prod_id = $db->GenID(AGILE_DB_PREFIX.'product_id'); + $sql = "INSERT INTO {$p}product SET + id = $new_prod_id, + sku = " . $db->qstr($sku); + while(list($field,$value) = each($result->fields)) { + if($field != 'sku' && $field != 'id' && !is_numeric($field) ) + $sql .= ",$field = ".$db->qstr($value); + } + $result = $db->Execute($sql); + + # Get current translation + $sql = $dbc->sql_select("product_translate", "*", "product_id = $product_id", "", $db); + $result = $db->Execute($sql); + + # Clone translation + while(!$result->EOF) + { + $id = $db->GenID(AGILE_DB_PREFIX.'product_translate_id'); + $sql = "INSERT INTO {$p}product_translate SET + id = $id, + product_id = $new_prod_id"; + while(list($field,$value) = each($result->fields)) { + if($field != 'product_id' && $field != 'id' && !is_numeric($field) ) + $sql .= ",$field = ".$db->qstr($value); + } + $db->Execute($sql); + $result->MoveNext(); + } + + # Get current attributes + $sql = $dbc->sql_select("product_attr", "*", "product_id = $product_id", "", $db); + $result = $db->Execute($sql); + + # Clone attributes + while(!$result->EOF) + { + $id = $db->GenID(AGILE_DB_PREFIX.'product_attr_id'); + $sql = "INSERT INTO {$p}product_attr SET + id = $id, + product_id = $new_prod_id"; + while(list($field,$value) = each($result->fields)) { + if($field != 'product_id' && $field != 'id' && !is_numeric($field) ) + $sql .= ",$field = ".$db->qstr($value); + } + $db->Execute($sql); + $result->MoveNext(); + } + + $msg = $C_translate->translate('clone_success', 'product',''); + $C_debug->alert( ''. $msg .''); + return $new_prod_id; + } + + function add($VAR) { + # defaults for 'recurring' product + if($VAR["product_price_type"] == "1") + { + $VAR['product_price_recurr_default'] = "1"; + $VAR['product_price_recurr_type'] = "0"; + $VAR['product_price_recurr_week'] = "1"; + $VAR['product_price_recurr_weekday'] = "1"; + + # Set default recurring prices: (monthly only) + $db = &DB(); + $sql = 'SELECT id FROM ' . AGILE_DB_PREFIX . 'group WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + pricing = ' . $db->qstr('1'); + $rs = $db->Execute($sql); + while(!$rs->EOF) { + $i = $rs->fields['id']; + $recur_price[0][$i]['price_base'] = ''; + $recur_price[0][$i]['price_setup'] = ''; + @$recur_price[1][$i]['price_base'] = $VAR['product_price_base']; + @$recur_price[1][$i]['price_setup'] = $VAR['product_price_setup']; + $recur_price[2][$i]['price_base'] = ''; + $recur_price[2][$i]['price_setup'] = ''; + $recur_price[3][$i]['price_base'] = ''; + $recur_price[3][$i]['price_setup'] = ''; + $recur_price[4][$i]['price_base'] = ''; + $recur_price[4][$i]['price_setup'] = ''; + $recur_price[5][$i]['price_base'] = ''; + $recur_price[5][$i]['price_setup'] = ''; + $rs->MoveNext(); + } + $recur_price[0]['show'] = "0"; + $recur_price[1]['show'] = "1"; + $recur_price[2]['show'] = "0"; + $recur_price[3]['show'] = "0"; + $recur_price[4]['show'] = "0"; + $recur_price[5]['show'] = "0"; + @$VAR['product_price_group'] = $recur_price; + } + + # Defaults for product groups: + $VAR['product_group_avail'] = Array('0'); + + $this->product_construct(); + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $result = $db->add($VAR, $this, $type); + + # Create a translate record for this product: + if($result) { + $db = &DB(); + $id = $db->GenID(AGILE_DB_PREFIX . 'product_translate_id'); + $sql = 'INSERT INTO ' . AGILE_DB_PREFIX . 'product_translate SET + site_id = ' . $db->qstr(DEFAULT_SITE) . ', + id = ' . $db->qstr($id) . ', + product_id = ' . $db->qstr($result) . ', + language_id = ' . $db->qstr(DEFAULT_LANGUAGE) . ', + name = ' . $db->qstr(@$VAR["translate_name"]) . ', + description_short = ' . $db->qstr(@$VAR["translate_description_short"]) . ', + description_full = ' . $db->qstr(@$VAR["translate_description_full"]); + $db->Execute($sql); + } + } + + function view($VAR) { + $this->product_construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + function update($VAR) { + global $_FILES; + $imgarr = Array('jpeg','jpg','gif','bmp','tif','tiff','png'); + if(isset($_FILES['upload_file1']) && $_FILES['upload_file1']['size'] > 0) + { + for($i=0; $iproduct_construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $result = $db->update($VAR, $this, $type); + + ### Copy the thumbnail + if($result && isset($filename)) + { + ### Copy 1ST file upoad: + copy($_FILES['upload_file1']['tmp_name'], PATH_IMAGES . "" . $filename); + } + } + + function delete($VAR) { + $this->associated_DELETE = + Array ( + Array ( 'table' => 'product_translate', 'field' => 'product_id'), + Array ( 'table' => 'product_attr', 'field' => 'product_id'), + Array ( 'table' => 'product_img', 'field' => 'product_id') + ); + $this->product_construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + function search_form($VAR) { + $this->product_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + function search($VAR) + { + $this->product_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + function search_show($VAR) { + $this->product_construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + function product_construct() { + $this->module = "product"; + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } +} +?> \ No newline at end of file diff --git a/modules/product/product_construct.xml b/modules/product/product_construct.xml new file mode 100644 index 00000000..fd29405b --- /dev/null +++ b/modules/product/product_construct.xml @@ -0,0 +1,204 @@ + + + + product + + product
+ + + + 0 + + sku + + 25 + + + sku + active + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I8 + date-time + + + I8 + date-now + + + C(32) + 1 + 1 + 32 + alphanumeric + + + L + + + L + + + I4 + + + L + + + X2 + any + array + 1 + + + C(255) + any + array + 1 + + + L + + + I4 + + + X2 + array + + + L + + + L + + + X2 + array + + + F + + + L + + + F + + + I4 + + + F + 1 + 32 + float + + + F + + + X2 + array + + + I4 + + + L + + + I4 + + + I4 + + + L + + + L + + + I4 + + + I4 + + + I4 + product + sku + + + X2 + product + sku + array + + + I4 + + + X2 + product + sku + array + 1 + + + X2 + array + + + I4 + + + I4 + + + C(128) + + + L + + + C(128) + + + X2 + array + + + L + + + L + + + X2 + array + + + + + id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,discount,discount_amount,price_type,price_base,price_setup,price_group,price_recurr_type,price_recurr_weekday,price_recurr_week,price_recurr_schedule,price_recurr_cancel,price_trial_length_type,price_trial_length,price_trial_prod,assoc_req_prod,assoc_req_prod_type,assoc_grant_prod,assoc_grant_group,assoc_grant_group_type,assoc_grant_group_days,thumbnail,price_recurr_default,price_recurr_modify,modify_waive_setup,modify_product_arr + id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,discount,discount_amount,price_type,price_base,price_setup,price_group,price_recurr_type,price_recurr_weekday,price_recurr_week,price_recurr_schedule,price_recurr_cancel,price_trial_length_type,price_trial_length,price_trial_prod,assoc_req_prod,assoc_req_prod_type,assoc_grant_prod,assoc_grant_group,assoc_grant_group_type,assoc_grant_group_days,thumbnail,price_recurr_default,host,host_server_id,host_provision_plugin_data,host_allow_domain,host_allow_host_only,host_discount_tld,host_discount_tld_amt,prod_plugin,prod_plugin_file,prod_plugin_data,price_recurr_modify,modify_waive_setup,modify_product_arr + id,site_id + id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,discount,discount_amount,price_type,price_base,price_setup,price_group,price_recurr_type,price_recurr_weekday,price_recurr_week,price_recurr_schedule,price_recurr_cancel,price_trial_length_type,price_trial_length,price_trial_prod,assoc_req_prod,assoc_req_prod_type,assoc_grant_prod,assoc_grant_group,assoc_grant_group_type,assoc_grant_group_days,thumbnail,price_recurr_default,host,host_server_id,host_provision_plugin_data,host_allow_domain,host_allow_host_only,host_discount_tld,host_discount_tld_amt,prod_plugin,prod_plugin_file,prod_plugin_data,price_recurr_modify,modify_waive_setup,modify_product_arr + id,site_id,date_orig,date_last,sku,taxable,active,group_avail,position,cart_multiple,avail_category_id,price_type,price_recurr_schedule,price_recurr_cancel,price_base,price_setup + + + 0 +
diff --git a/modules/product/product_install.xml b/modules/product/product_install.xml new file mode 100644 index 00000000..dbada672 --- /dev/null +++ b/modules/product/product_install.xml @@ -0,0 +1,45 @@ + + + product + product + + 1 + + + + + search_show + + + search_form + + + search + + 1 + + + delete + + + view + + 1 + + + update + + + add + + 1 + + + admin_details + + + cloner + + + + \ No newline at end of file diff --git a/modules/product/product_install_data.xml b/modules/product/product_install_data.xml new file mode 100644 index 00000000..9649a8c9 --- /dev/null +++ b/modules/product/product_install_data.xml @@ -0,0 +1,26 @@ + + + + 2 + 1 + 1132443241 + 1132443241 + SAMPLE1 + 1 + 1 + + + 0 + 1 + 10 + 10 + + 1 + 0 + 1 + 1 + + + 2 + + \ No newline at end of file diff --git a/modules/product_attr/product_attr.inc.php b/modules/product_attr/product_attr.inc.php new file mode 100644 index 00000000..71e3e1b5 --- /dev/null +++ b/modules/product_attr/product_attr.inc.php @@ -0,0 +1,125 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class product_attr +{ + + # Open the constructor for this mod + function product_attr() + { + # name of this module: + $this->module = "product_attr"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/product_attr/product_attr_construct.xml b/modules/product_attr/product_attr_construct.xml new file mode 100644 index 00000000..a9fd3799 --- /dev/null +++ b/modules/product_attr/product_attr_construct.xml @@ -0,0 +1,80 @@ + + + + product_attr + + product_attr
+ + product + + 0 + + sort_order,name + + 25 + + + product_id + collect_type + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I4 + 1 + + + C(32) + 1 + 32 + any + + + C(255) + + + I4 + + + I4 + + + C(255) + + + L + + + F + 1 + 32 + float + + + F + + + X2 + array + + + + + id,site_id,name,description,sort_order,collect_type,collect_default,price_base,price_setup,price_group,product_id,required + id,site_id,name,description,sort_order,collect_type,collect_default,price_base,price_setup,price_group,product_id,required + id,site_id,name,description,sort_order,collect_type,collect_default,price_base,price_setup,price_group,product_id,required + id,site_id,name,description,sort_order,collect_type,collect_default,price_base,price_setup,price_group,product_id,required + id,site_id,name,sort_order,collect_type,collect_default,price_base,price_group,product_id,required + + + 0 +
diff --git a/modules/product_attr/product_attr_install.xml b/modules/product_attr/product_attr_install.xml new file mode 100644 index 00000000..855cdb65 --- /dev/null +++ b/modules/product_attr/product_attr_install.xml @@ -0,0 +1,30 @@ + + + product_attr + product + + product + + + + + search_show + + + search + + + view + + + delete + + + add + + + update + + + + \ No newline at end of file diff --git a/modules/product_cat/product_cat.inc.php b/modules/product_cat/product_cat.inc.php new file mode 100644 index 00000000..60e7ae6c --- /dev/null +++ b/modules/product_cat/product_cat.inc.php @@ -0,0 +1,612 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class product_cat +{ + + # Open the constructor for this mod + function product_cat() + { + # name of this module: + $this->module = "product_cat"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + ############################## + ## USER CATEGORY ARR SMARTY ## + ############################## + function user_menu($VAR) + { + global $smarty, $C_auth; + $db = &DB(); + $dbc = new CORE_database; + $sql = $dbc->sql_select( "product_cat", "*", + "status = 1 AND (parent_id = 0 OR parent_id IS NULL OR parent_id = id)", "position", $db); + $result = $db->Execute($sql); + if($result->RecordCount() == 0) { + return false; + } else { + while(!$result->EOF) { + # check for group settings: + $groups = unserialize($result->fields['group_avail']); + + $auth = false; + for($ii=0; $iiauth_group_by_id($groups[$ii])) $auth = true; + } + + if($auth) { + # Create the array for smarty + $smart[] = $result->fields; + $i++; + } + $result->MoveNext(); + } + $smarty->assign('product_cat', $smart); + } + } + + + ############################## + ## USER VIEW A CATEGORY ## + ############################## + function user_view($VAR) + { + global $smarty, $C_auth; + $db = &DB(); + + ### Get the category information: + $sql = sqlSelect($db, "product_cat", "id,position,template,name,thumbnail,group_avail,parent_id,max", "status = 1 AND id = ::{$VAR['id']}::"); + $result = $db->Execute($sql); + + if(!$result || $result->RecordCount() == 0) { + return false; + } else { + + # check for group settings: + $groups = unserialize($result->fields['group_avail']); + + # max results per page: + $max = $result->fields['max']; + if(empty($max)) $max = 25; + $count = 0; + if(empty($VAR['page']) || !is_numeric($VAR['page']) || $VAR['page'] <= 1 ) { + $page = 1; + $start = 0; + } else { + $page = $VAR['page']; + $start = ($page-1)*$max; + } + + $auth = false; + for($ii=0; $iiauth_group_by_id($groups[$ii])) $auth = true; + } + + if($auth) { + $smart[] = $result->fields; + $smarty->assign('product_cat_arr', $smart); + } else { + return false; + } + + $parent_id = $result->fields['parent_id']; + if(!$parent_id) $parent_id = '0'; + } + + ### Get the items in this category: + $sql = sqlSelect($db, "product", "id,sku,thumbnail,avail_category_id,price_base,price_setup,group_avail", "active = 1", "position,sku"); + $result = $db->Execute($sql); + if(!$result || $result->RecordCount() == 0) { + return false; + } else { + while(!$result->EOF) { + # check that this item can be displayed in the current category: + $cat = false; + $cats = unserialize($result->fields['avail_category_id']); + for($i=0; $ifields['group_avail']); + + $auth = false; + for($ii=0; $iiauth_group_by_id($groups[$ii])) { + $auth = true; + break; + } + } + + ### Paging + if($auth) { + if($count >= $start && $count < $max*$page) + $smart_prod[] = $result->fields; + $count++; + } + } + $result->MoveNext(); + } + + $results = $count; + $pages = intval($results / $max); + if ($results % $max) $pages++; + + for($i=1;$i<=$pages;$i++) $pagearr[$i] = $i; + + $smarty->assign('product_arr', $smart_prod); + $smarty->assign('page_page', $page); + $smarty->assign('page_results', $results); + $smarty->assign('page_pages', $pages); + $smarty->assign('page_arr', $pagearr); + } + + ### Get any sub-categories: + $sql = sqlSelect($db, "product_cat", "*", "status = 1 AND parent_id = ::{$VAR['id']}::","position,name"); + $result = $db->Execute($sql); + if($result && $result->RecordCount()) { + while(!$result->EOF) { + $smart_sub_cat[] = $result->fields; + $result->MoveNext(); + } + $smarty->assign('product_sub_cat', $smart_sub_cat); + } + + ### Get any parent categores: + $p = AGILE_DB_PREFIX; + $d = DEFAULT_SITE; + $smart_parent_cat = Array(); + for($i=0; $i<=5; $i++) + { + if($parent_id > 0 ) + { + # Get parent id & add to array + $sql = "SELECT + {$p}product_cat.id, + {$p}product_cat.parent_id, + {$p}product_cat.template, + {$p}product_cat_translate.name + FROM + {$p}product_cat,{$p}product_cat_translate + WHERE + {$p}product_cat.site_id = {$d} + AND + {$p}product_cat_translate.site_id = {$d} + AND + {$p}product_cat.id = $parent_id + AND + {$p}product_cat_translate.product_cat_id = $parent_id + AND + {$p}product_cat_translate.language_id = '".SESS_LANGUAGE."'"; + $result = $db->Execute($sql); + if($result && $result->RecordCount()) + { + $parent_id = $result->fields['parent_id']; + $smart_parent_cat[] = $result->fields; + } + } + } + + $smart_parent_cat = array_reverse($smart_parent_cat); + + ## Get the current category: + $sql = "SELECT + {$p}product_cat.id, + {$p}product_cat.parent_id, + {$p}product_cat.template, + {$p}product_cat_translate.name + FROM + {$p}product_cat,{$p}product_cat_translate + WHERE + {$p}product_cat.site_id = {$d} + AND + {$p}product_cat_translate.site_id = {$d} + AND + {$p}product_cat.id = ".$db->qstr($VAR['id'])." + AND + {$p}product_cat_translate.product_cat_id = ".$db->qstr($VAR['id'])." + AND + {$p}product_cat_translate.language_id = '".SESS_LANGUAGE."'"; + $result = $db->Execute($sql); + if($result && $result->RecordCount()) + $smart_parent_cat[] = $result->fields; + + $smarty->assign('parent_cat', $smart_parent_cat); + + } + + + + ############################### + ## ADMIN SINGLE SELECT MENU ## + ############################### + function admin_menu_parent($VAR) + { + global $smarty, $C_auth; + $db = &DB(); + $dbc = new CORE_database; + $sql = $dbc->sql_select( "product_cat", "*", "", "parent_id,position,name", $db); + $result = $db->Execute($sql); + + # Get current id + if(!empty($VAR['id'])) { + $cid = ereg_replace(",","", $VAR['id']); + } else { + $current = ''; + } + + # Loop and put in array + while(!$result->EOF) { + if($result->fields['parent_id'] == "" || $result->fields['parent_id'] == 0 || $result->fields['parent_id'] == $result->fields['id']) { + $arr[0][] = $result->fields; + } else { + $arr["{$result->fields['parent_id']}"][] = $result->fields; + } + + # get current parent_id + if($cid > 0 && $result->fields['id'] == $cid) + $current = $result->fields['parent_id']; + + $result->MoveNext(); + } + + # Create menu + $option = ''; + + for($i=0; $i'.$arr[0][$i]["name"].''; + + ########################## + # get the sub-categories # (LEVEL 2) + if(isset($arr[$id])) + { + for($ii=0; $ii-  '.$arr[$id][$ii]["name"].''; + } + + ########################## + # get the sub-categories # (LEVEL 3) + if(isset($arr[$idx])) + { + for($iii=0; $iii  -  '.$arr[$idx][$iii]["name"].''; + } + + ########################## + # get the sub-categories # (LEVEL 4) + if(isset($arr[$idx2])) + { + for($iiii=0; $iiii    -  '.$arr[$idx2][$iiii]["name"].''; + } + + ########################## + # get the sub-categories # (LEVEL 5) + if(isset($arr[$idx3])) + { + for($iiiii=0; $iiiii      -  '.$arr[$idx3][$iiiii]["name"].''; + } + } + } + } + } + } + + echo ''; + } + + + ############################## + ## ADMIN MULTI SELECT MENU ## + ############################## + function admin_menu_product($VAR) + { + global $smarty, $C_auth; + $db = &DB(); + $dbc = new CORE_database; + + # Get current category id + if(!empty($VAR['id'])) { + $product_id = ereg_replace(",","", $VAR['id']); + $sql = $dbc->sql_select("product", "avail_category_id", "id = $product_id","", $db); + $product = $db->Execute($sql); + $current = unserialize($product->fields['avail_category_id']); + } else { + $current = ''; + } + + # Loop and put in array + $sql = $dbc->sql_select( "product_cat", "*", "", "parent_id,position,name", $db); + $result = $db->Execute($sql); + while(!$result->EOF) + { + # determine if selected + $select = false; + for($ix=0; $ixfields['id']) { + $result->fields['sel'] = 'selected'; + break; + } + } + + # set array + if($result->fields['parent_id'] == "" || $result->fields['parent_id'] == 0 || $result->fields['parent_id'] == $result->fields['id']) { + $arr[0][] = $result->fields; + } else { + $arr["{$result->fields['parent_id']}"][] = $result->fields; + } + + $result->MoveNext(); + } + + # Create menu + $option = ''; + + for($i=0; $i'.$arr[0][$i]["name"].''; + + ########################## + # get the sub-categories # (LEVEL 2) + if(isset($arr[$id])) + { + for($ii=0; $ii-  '.$arr[$id][$ii]["name"].''; + } + + ########################## + # get the sub-categories # (LEVEL 3) + if(isset($arr[$idx])) + { + for($iii=0; $iii  -  '.$arr[$idx][$iii]["name"].''; + } + + ########################## + # get the sub-categories # (LEVEL 4) + if(isset($arr[$idx2])) + { + for($iiii=0; $iiii    -  '.$arr[$idx2][$iiii]["name"].''; + } + + ########################## + # get the sub-categories # (LEVEL 5) + if(isset($arr[$idx3])) + { + for($iiiii=0; $iiiii      -  '.$arr[$idx3][$iiiii]["name"].''; + } + } + } + } + } + } + + echo ''; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + global $_FILES; + + #################################################################### + ### Validate the thumbnail upoad: + if(isset($_FILES['upload_file1']) && $_FILES['upload_file1']['size'] > 0) + { + $VAR['product_cat_thumbnail'] = "cat_thmb_".$_FILES['upload_file1']['name']; + } + + ### Validate the image upoad: + if(isset($_FILES['upload_file2']) && $_FILES['upload_file2']['size'] > 0) + { + $VAR['product_cat_image'] = "cat_img_".$_FILES['upload_file2']['name']; + } + + + #################################################################### + ## Attempt to add the record: + + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $result = $db->add($VAR, $this, $type); + + + #################################################################### + ### Copy the image(s) + if($result) + { + ### Copy 1ST file upoad: + if(isset($_FILES['upload_file1']) && $_FILES['upload_file1']['size'] > 0) + copy($_FILES['upload_file1']['tmp_name'], PATH_IMAGES . "cat_thmb_" . $_FILES['upload_file1']['name']); + + ### Copy the 2ND file upoad: + if(isset($_FILES['upload_file2']) && $_FILES['upload_file2']['size'] > 0) + copy($_FILES['upload_file2']['tmp_name'], PATH_IMAGES . "cat_img_" . $_FILES['upload_file2']['name']); + } + + } + + + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + global $_FILES; + + #################################################################### + ### Validate the thumbnail upoad: + if(isset($_FILES['upload_file1']) && $_FILES['upload_file1']['size'] > 0) + { + $VAR['product_cat_thumbnail'] = "cat_thmb_".$_FILES['upload_file1']['name']; + } elseif ( $VAR['delthumb'] == 1 ) { + $VAR['product_cat_thumbnail'] = ""; + } + + ### Validate the image upoad: + if(isset($_FILES['upload_file2']) && $_FILES['upload_file2']['size'] > 0) + { + $VAR['product_cat_image'] = "cat_img_".$_FILES['upload_file2']['name']; + } elseif ( $VAR['delimg'] == 1 ) { + $VAR['product_cat_image'] = ""; + } + + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $result = $db->update($VAR, $this, $type); + + #################################################################### + ### Copy the image(s) + if($result) + { + ### Copy 1ST file upoad: + if(isset($_FILES['upload_file1']) && $_FILES['upload_file1']['size'] > 0) + copy($_FILES['upload_file1']['tmp_name'], PATH_IMAGES . "cat_thmb_" . $_FILES['upload_file1']['name']); + + ### Copy the 2ND file upoad: + if(isset($_FILES['upload_file2']) && $_FILES['upload_file2']['size'] > 0) + copy($_FILES['upload_file2']['tmp_name'], PATH_IMAGES . "cat_img_" . $_FILES['upload_file2']['name']); + } + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $this->associated_DELETE = + Array ( Array ( 'table' => 'product_cat_translate', 'field' => 'product_cat_id') ); + + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/product_cat/product_cat_construct.xml b/modules/product_cat/product_cat_construct.xml new file mode 100644 index 00000000..377f31f4 --- /dev/null +++ b/modules/product_cat/product_cat_construct.xml @@ -0,0 +1,77 @@ + + + + product_cat + + product_cat
+ + product + + 0 + + position + + 25 + + + status + position + name + + + + + I4 + 1 + + + I4 + + + I4 + + + X2 + array + any + + + C(32) + 2 + 32 + any + + + C(255) + + + L + + + + C(128) + + + C(128) + + + I4 + + + I4 + numeric + + + + + id,site_id,name,notes,status,template,thumbnail,image,position,max,group_avail,parent_id + id,site_id,name,notes,status,template,thumbnail,image,position,max,group_avail,parent_id + id,site_id,name,notes,status,template,thumbnail,image,position,max,group_avail,parent_id + id,site_id,name,notes,status,template,thumbnail,image,position,max,group_avail,parent_id + id,site_id,name,notes,status,template,thumbnail,image,position,max,group_avail,parent_id + + + 0 +
diff --git a/modules/product_cat/product_cat_install.xml b/modules/product_cat/product_cat_install.xml new file mode 100644 index 00000000..de5650a5 --- /dev/null +++ b/modules/product_cat/product_cat_install.xml @@ -0,0 +1,40 @@ + + + product_cat + product + + 1 + product + + + + + add + + 1 + + + search_form + + + + search + + + view + + 1 + + + delete + + + update + + + search_show + + + + + \ No newline at end of file diff --git a/modules/product_cat/product_cat_install_data.xml b/modules/product_cat/product_cat_install_data.xml new file mode 100644 index 00000000..121f4937 --- /dev/null +++ b/modules/product_cat/product_cat_install_data.xml @@ -0,0 +1,18 @@ + + + + 1 + 1 + 0 + + Sample Directory + You can edit this category as needed + 1 + + 1 + 10 + + + 8 + + \ No newline at end of file diff --git a/modules/product_cat_translate/product_cat_translate.inc.php b/modules/product_cat_translate/product_cat_translate.inc.php new file mode 100644 index 00000000..463078e9 --- /dev/null +++ b/modules/product_cat_translate/product_cat_translate.inc.php @@ -0,0 +1,126 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class product_cat_translate +{ + + # Open the constructor for this mod + function product_cat_translate() + { + # name of this module: + $this->module = "product_cat_translate"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/product_cat_translate/product_cat_translate_construct.xml b/modules/product_cat_translate/product_cat_translate_construct.xml new file mode 100644 index 00000000..2a36daa3 --- /dev/null +++ b/modules/product_cat_translate/product_cat_translate_construct.xml @@ -0,0 +1,57 @@ + + + + product_cat_translate + + product_cat_translate
+ + product + + 0 + + product_cat_id + + 25 + + + + I4 + 1 + 1 + + + I4 + 1 + + + I4 + product_cat + name + any + + + C(16) + + + C(128) + 2 + 128 + any + + + X2 + any + 1 + + + + + id,site_id,product_cat_id,language_id,name,description + id,site_id,product_cat_id,language_id,name,description + id,site_id,product_cat_id,language_id,name,description + id,site_id,product_cat_id,language_id,name,description + id,site_id,product_cat_id,language_id,name + + + 0 +
diff --git a/modules/product_cat_translate/product_cat_translate_install.xml b/modules/product_cat_translate/product_cat_translate_install.xml new file mode 100644 index 00000000..f7dfdb60 --- /dev/null +++ b/modules/product_cat_translate/product_cat_translate_install.xml @@ -0,0 +1,32 @@ + + + product_cat_translate + product_cat + + product_cat + + + + + search + + 1 + + + delete + + + view + + + update + + + add + + + search_show + + + + \ No newline at end of file diff --git a/modules/product_cat_translate/product_cat_translate_install_data.xml b/modules/product_cat_translate/product_cat_translate_install_data.xml new file mode 100644 index 00000000..c015e675 --- /dev/null +++ b/modules/product_cat_translate/product_cat_translate_install_data.xml @@ -0,0 +1,32 @@ + + + + 2 + 1 + 1 + english + Sample Directory + links, + images, font sizes and colors, + etc...]]> + + + 3 + 1 + 5 + english + Membership + View our selection of memberships + + + 5 + 1 + 7 + english + test + test + + + 6 + + \ No newline at end of file diff --git a/modules/product_img/product_img.inc.php b/modules/product_img/product_img.inc.php new file mode 100644 index 00000000..474d1ef2 --- /dev/null +++ b/modules/product_img/product_img.inc.php @@ -0,0 +1,195 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class product_img +{ + + # Open the constructor for this mod + function product_img() + { + # name of this module: + $this->module = "product_img"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + global $_FILES, $C_translate, $C_debug; + + $imgarr = Array('jpeg','jpg','gif','bmp','tif','tiff','png'); + + if(isset($_FILES['upload_file1']) && $_FILES['upload_file1']['size'] > 0) + { + for($i=0; $imethod["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $result = $db->add($VAR, $this, $type); + + # copy the image + if($result && !empty($filename)) + { + $file = 'prod_img_' . $result . '.' . $filename; + copy($_FILES['upload_file1']['tmp_name'], PATH_IMAGES . "" . $file); + } + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = &DB(); + + ### Delete any saved images: + if(isset($VAR["delete_id"])) + { + $id = split(',',$VAR["delete_id"]); + } + elseif (isset($VAR["id"])) + { + $id = split(',',$VAR["id"]); + } + + for($i=0; $ifields['url']); + } + + # delete the record + $sql = 'DELETE FROM ' . AGILE_DB_PREFIX . 'product_img WHERE + site_id = ' . $db->qstr(DEFAULT_SITE) . ' AND + id = ' . $db->qstr($id[$i]); + $result = $db->Execute($sql); + } + } + } + + + # Alert delete message + global $C_debug, $C_translate; + $C_translate->value["CORE"]["module_name"] = $C_translate->translate('name',$this->module,""); + $message = $C_translate->translate('alert_delete_ids',"CORE",""); + $C_debug->alert($message); + } + + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + +} +?> \ No newline at end of file diff --git a/modules/product_img/product_img_construct.xml b/modules/product_img/product_img_construct.xml new file mode 100644 index 00000000..44226dfd --- /dev/null +++ b/modules/product_img/product_img_construct.xml @@ -0,0 +1,53 @@ + + + + product_img + + product_img
+ + product + + 0 + + product_id + + 25 + + + product_id + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I4 + + + L + + + C(255) + + + C(128) + + + + + id,site_id,product_id,type,url,name + id,site_id,product_id,type,url,name + id,site_id,product_id,type,url,name + id,site_id,product_id,type,url,name + id,site_id,product_id,type,url,name + + + 0 +
diff --git a/modules/product_img/product_img_install.xml b/modules/product_img/product_img_install.xml new file mode 100644 index 00000000..ed57992f --- /dev/null +++ b/modules/product_img/product_img_install.xml @@ -0,0 +1,30 @@ + + + product_img + product + + product + + + + + search_show + + + search + + + view + + + delete + + + update + + + add + + + + \ No newline at end of file diff --git a/modules/product_translate/product_translate.inc.php b/modules/product_translate/product_translate.inc.php new file mode 100644 index 00000000..e8c3ae1c --- /dev/null +++ b/modules/product_translate/product_translate.inc.php @@ -0,0 +1,125 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +class product_translate +{ + + # Open the constructor for this mod + function product_translate() + { + # name of this module: + $this->module = "product_translate"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + + function search_show($VAR) + { + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } +} +?> \ No newline at end of file diff --git a/modules/product_translate/product_translate_construct.xml b/modules/product_translate/product_translate_construct.xml new file mode 100644 index 00000000..80c54b45 --- /dev/null +++ b/modules/product_translate/product_translate_construct.xml @@ -0,0 +1,69 @@ + + + + product_translate + + product_translate
+ + product + + 0 + + product_id + + 25 + + + product_id + language_id + name + + + + + I4 + 1 + 1 + + + I4 + 1 + + + I4 + product + sku + any + + + C(16) + + + C(128) + 1 + 128 + any + + + X2 + 1 + + + X2 + 1 + + + X2 + + + + + id,site_id,product_id,language_id,name,description_short,description_full,email_template + id,site_id,product_id,language_id,name,description_short,description_full,email_template + id,site_id,product_id,language_id,name,description_short,description_full,email_template + id,site_id,product_id,language_id,name,description_short,description_full,email_template + id,site_id,product_id,language_id,name,description_short,description_full,email_template + + + 0 +
diff --git a/modules/product_translate/product_translate_install.xml b/modules/product_translate/product_translate_install.xml new file mode 100644 index 00000000..a67ff112 --- /dev/null +++ b/modules/product_translate/product_translate_install.xml @@ -0,0 +1,30 @@ + + + product_translate + product + + product + + + + + add + + + update + + + search_show + + + search + + + view + + + delete + + + + \ No newline at end of file diff --git a/modules/product_translate/product_translate_install_data.xml b/modules/product_translate/product_translate_install_data.xml new file mode 100644 index 00000000..7a9699b8 --- /dev/null +++ b/modules/product_translate/product_translate_install_data.xml @@ -0,0 +1,16 @@ + + + + 2 + 1 + 2 + english + Sample Product + +]]> + This is just a sample product, edit as needed or delete. + + + 2 + + \ No newline at end of file diff --git a/modules/radius/auth.inc.php b/modules/radius/auth.inc.php new file mode 100644 index 00000000..92be3cb1 --- /dev/null +++ b/modules/radius/auth.inc.php @@ -0,0 +1,7 @@ + 'radius', 'method' => 'do_update'), +Array ('module' => 'radius', 'method' => 'do_list') +); +?> \ No newline at end of file diff --git a/modules/radius/radius.inc.php b/modules/radius/radius.inc.php new file mode 100644 index 00000000..811e487d --- /dev/null +++ b/modules/radius/radius.inc.php @@ -0,0 +1,418 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** + * Radius Provisioning Class for AgileBill + */ +class radius +{ + var $user_regex='^([a-zA-Z0-9\-\_\.]{4,20})$'; + var $pass_regex='^([a-zA-Z0-9\-\_\.]{4,20})$'; + + /** + * Get the user's password list: + */ + function do_list($VAR) + { + global $smarty, $C_debug; + + # Validate logged in: + if(!SESS_LOGGED) { + $C_debug->alert("You must be logged in!"); + return; + } + + # Get all accounts defined for this user: + $db=&DB(); + $result = $db->Execute(sqlSelect($db,"radius","*","account_id=::".SESS_ACCOUNT."::","username DESC")); + if($result && $result->RecordCount()) { + while(!$result->EOF) { + + if($result->fields['auth'] == 'login') + $old_login[] = $result->fields; + + if($result->fields['auth'] == 'wireless') + $old_wireless[] = $result->fields; + + $result->MoveNext(); + } + } + $smarty->assign("old_login", $old_login); + $smarty->assign("old_wireless", $old_wireless); + + $rs = $db->Execute($sql=sqlSelect($db,"radius_service","*", + "account_id=::".SESS_ACCOUNT.":: AND (radius_id IS NULL OR radius_id=0 OR radius_id=::::)")); + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + if($rs->fields['auth']=='login') { + $new_login[] = array('id'=>$rs->fields['id']); + } elseif($rs->fields['auth']=='wireless') { + $new_wireless[] = array('id'=>$rs->fields['id']); + } + $rs->MoveNext(); + } + } + + $smarty->assign("new_login", @$new_login); + $smarty->assign("new_wireless", @$new_wireless); + + } + + /** + * Get total accounts available for this user + */ + function available_accounts(&$avail_login, &$avail_wireless) { + $db=&DB(); + $rs = $db->Execute($sql=sqlSelect($db,"radius_service","*", + "account_id=::".SESS_ACCOUNT.":: AND (radius_id IS NULL OR radius_id=0 OR radius_id=::::)")); + if($rs && $rs->RecordCount()) { + while(!$rs->EOF) { + if($rs->fields['auth']=='login') { + $avail_login++; + } elseif($rs->fields['auth']=='wireless') { + $avail_wireless++; + } + $rs->MoveNext(); + } + } + } + + /** + * Add a radius entry + */ + function add_radius($service_id, $radius_service_id, $username, $password=false) { + + // determine type of auth + if(!$password) + $auth='wireless'; + else + $auth='login'; + + // get the associated service + $db=&DB(); + $rs = $db->Execute(sqlSelect($db,"service","*", "id=::$service_id::")); + if(!$rs || !$rs->RecordCount()) return false; + + $f['service_id']=$service_id; + $f['username']=$username; + $f['password']=$password; + $f['account_id']=$rs->fields['account_id']; + $f['sku']=$rs->fields['sku']; + $f['active']=1; + + // insert radius record + $arr=unserialize($rs->fields['prod_plugin_data']); + foreach($arr as $a=>$b) { + if($a != 'max') $f[$a]=$b; + } + $id = sqlGenID($db,"radius"); + $db->Execute($sql=sqlInsert($db,"radius",$f,$id)); + + // update radius_service table + $db->Execute(sqlUpdate($db, "radius_service", array('radius_id'=>$id), "id = $radius_service_id")); + + return true; + } + + /** + * validate mac id + */ + function validate_wireless($user) { + if(ereg("^([0-9A-Z]{2}) ([0-9A-Z]{2}) ([0-9A-Z]{2}) ([0-9A-Z]{2}) ([0-9A-Z]{2}) ([0-9A-Z]{2})$",$user)) return $user; + return false; + } + + /** + * validate username and password + */ + function validate_login($user,$pass) { + + if(!ereg("$this->user_regex", $pass)) return false; + if(!ereg("$this->pass_regex", $pass)) return false; + return true; + } + + /** + * Validate unique user/mac id + */ + function validate_unique($id,$username) { + + $s=''; + if($id) $s="id!=::$id:: AND "; + $db=&DB(); + $result = $db->Execute($sql=sqlSelect($db,"radius","id","$s username=::$username::")); + + if($result === false || $result->RecordCount() == 0) + return true; + else + return false; + } + + /** + * Update password list + */ + function do_update($VAR) + { + global $smarty, $C_debug, $C_translate; + $db=&DB(); + + $msg = false; + + # Validate logged in: + if(!SESS_LOGGED) { + $C_debug->alert("You must be logged in!"); + return; + } + + # Loop through the submitted passwords for update: + if(!empty($VAR['username']) && is_array($VAR['username'])) { + foreach($VAR['username'] as $id=>$val) { + $user = $VAR['username'][$id]; + @$pass = $VAR['password'][$id]; + + + $result = $db->Execute(sqlSelect($db,"radius","*", "id=::$id:: AND account_id=::".SESS_ACCOUNT."::")); + if($result && $result->RecordCount()) + { + if($result->fields['auth'] == 'login') { + if(!$this->validate_login($user,$pass) || !$this->validate_unique($id, $user)) { + $C_translate->value["radius"]["user"]=$user; + $C_translate->value["radius"]["pass"]=$pass; + $msg .= $C_translate->translate("err_login", "radius")."
"; + } else { + // update login record + $db->Execute(sqlUpdate($db,"radius",array('password'=>$pass, 'username'=>$user), "id=$id")); + #$used_login++; + } + } elseif ($result->fields['auth'] == 'wireless') { + // validate mac id + $user=strtoupper($user); + $user=str_replace("-", " ", $user); + if(!$this->validate_wireless($user) || !$this->validate_unique($id, $user)) { + $C_translate->value["radius"]["user"]=$user; + $msg .= $C_translate->translate("err_wireless", "radius")."
"; + } else { + $db->Execute(sqlUpdate($db,"radius",array('username'=>$user), "id=$id")); + } + } + } + } + } + + + # Loop through the submitted passwords for additions: + if(!empty($VAR['new_username']) && is_array($VAR['new_username'])) { + foreach($VAR['new_username'] as $id=>$val) { + if(!empty($VAR['new_username'][$id])) { + $user = $VAR['new_username'][$id]; + @$pass = $VAR['new_password'][$id]; + + // validation + $rsRS = $db->Execute(sqlSelect($db,"radius_service","*", "id=::$id:: AND account_id=::".SESS_ACCOUNT."::")); + $service_id = $rsRS->fields['service_id']; + $radius_service_id = $rsRS->fields['id']; + if($rsRS->fields['auth'] == 'login') { + if(!$this->validate_login($user,$pass) || !$this->validate_unique(false, $user)) { + $C_translate->value["radius"]["user"]=$user; + $C_translate->value["radius"]["pass"]=$pass; + $msg .= $C_translate->translate("err_login", "radius")."
"; + } else { + // add login record + $this->add_radius($service_id, $radius_service_id, $user, $pass); + } + } elseif ($rsRS->fields['auth'] == 'wireless' ) { + // validate mac id + $user=strtoupper($user); + $user=str_replace("-", " ", $user); + if(!$this->validate_wireless($user) || !$this->validate_unique(false, $user)) { + $C_translate->value["radius"]["user"]=$user; + $msg .= $C_translate->translate("err_wireless", "radius")."
"; + } else { + // add mac id record + $this->add_radius($service_id, $radius_service_id, $user); + } + } + } + } + } + + if(!empty($msg)) $C_debug->alert($msg); + } + + + # Open the constructor for this mod + function construct() + { + # name of this module: + $this->module = "radius"; + + # location of the construct XML file: + $this->xml_construct = PATH_MODULES . "" . $this->module . "/" . $this->module . "_construct.xml"; + + # open the construct file for parsing + $C_xml = new CORE_xml; + $construct = $C_xml->xml_to_array($this->xml_construct); + + $this->method = $construct["construct"]["method"]; + $this->trigger = $construct["construct"]["trigger"]; + $this->field = $construct["construct"]["field"]; + $this->table = $construct["construct"]["table"]; + $this->module = $construct["construct"]["module"]; + $this->cache = $construct["construct"]["cache"]; + $this->order_by = $construct["construct"]["order_by"]; + $this->limit = $construct["construct"]["limit"]; + } + + + + ############################## + ## ADD ## + ############################## + function add($VAR) + { + $this->construct(); + $type = "add"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->add($VAR, $this, $type); + } + + ############################## + ## VIEW ## + ############################## + function view($VAR) + { + $this->construct(); + $type = "view"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->view($VAR, $this, $type); + } + + ############################## + ## UPDATE ## + ############################## + function update($VAR) + { + $this->construct(); + $type = "update"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->update($VAR, $this, $type); + } + + ############################## + ## DELETE ## + ############################## + function delete($VAR) + { + $this->construct(); + $db = new CORE_database; + $db->mass_delete($VAR, $this, ""); + } + + ############################## + ## SEARCH FORM ## + ############################## + function search_form($VAR) + { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_form($VAR, $this, $type); + } + + ############################## + ## SEARCH ## + ############################## + function search($VAR) + { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search($VAR, $this, $type); + } + + ############################## + ## SEARCH SHOW ## + ############################## + function search_show($VAR) + { + $this->construct(); + $type = "search"; + $this->method["$type"] = split(",", $this->method["$type"]); + $db = new CORE_database; + $db->search_show($VAR, $this, $type); + } + + ############################## + ## SEARCH EXPORT ## + ############################## + function search_export($VAR) + { + $this->construct(); + # require the export class + require_once (PATH_CORE . "export.inc.php"); + + # Call the correct export function for inline browser display, download, email, or web save. + if($VAR["format"] == "excel") + { + $type = "export_excel"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_excel($VAR, $this, $type); + } + + else if ($VAR["format"] == "pdf") + { + $type = "export_pdf"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_pdf($VAR, $this, $type); + } + + else if ($VAR["format"] == "xml") + { + $type = "export_xml"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_xml($VAR, $this, $type); + } + + else if ($VAR["format"] == "csv") + { + $type = "export_csv"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_csv($VAR, $this, $type); + } + + else if ($VAR["format"] == "tab") + { + $type = "export_tab"; + $this->method["$type"] = split(",", $this->method["$type"]); + $export = new CORE_export; + $export->search_tab($VAR, $this, $type); + } + } +} +?> \ No newline at end of file diff --git a/modules/radius/radius_construct.xml b/modules/radius/radius_construct.xml new file mode 100644 index 00000000..a1aca703 --- /dev/null +++ b/modules/radius/radius_construct.xml @@ -0,0 +1,113 @@ + + + + + radius + + + radius
+ + + + + + 0 + + + id + + + 35 + + + + + I8 + 1 + + + I4 + + + I4 + any + + + I8 + service + id + + + L + + + C(32) + + + C(16) + + + C(128) + any + + + C(128) + + + C(128) + + + I4 + + + I4 + + + I4 + + + L + + + L + + + C(128) + + + C(128) + + + C(128) + + + I4 + + + C(128) + + + C(128) + + + I4 + + + + + + id,site_id,account_id,service_id,active,sku,auth,username,password,service_type,session_limit,idle_limit,port_limit,analog,digital,filter_id,netmask,framed_route,speed_limit,static_ip,profiles,time_bank + id,site_id,account_id,service_id,active,sku,auth,username,password,service_type,session_limit,idle_limit,port_limit,analog,digital,filter_id,netmask,framed_route,speed_limit,static_ip,profiles,time_bank + id,site_id,account_id,service_id,active,sku,auth,username,password,service_type,session_limit,idle_limit,port_limit,analog,digital,filter_id,netmask,framed_route,speed_limit,static_ip,profiles,time_bank + id,site_id,account_id,service_id,active,sku,auth,username,password,service_type,session_limit,idle_limit,port_limit,analog,digital,filter_id,netmask,framed_route,speed_limit,static_ip,profiles,time_bank + id,site_id,account_id,service_id,active,sku,auth,username,password,service_type,session_limit,idle_limit,port_limit,analog,digital,filter_id,netmask,framed_route,speed_limit,static_ip,profiles,time_bank + id,site_id,account_id,service_id,active,sku,auth,username,password,service_type,session_limit,idle_limit,port_limit,analog,digital,filter_id,netmask,framed_route,speed_limit,static_ip,profiles,time_bank + id,site_id,account_id,service_id,active,sku,auth,username,password,service_type,session_limit,idle_limit,port_limit,analog,digital,filter_id,netmask,framed_route,speed_limit,static_ip,profiles,time_bank + id,site_id,account_id,service_id,active,sku,auth,username,password,service_type,session_limit,idle_limit,port_limit,analog,digital,filter_id,netmask,framed_route,speed_limit,static_ip,profiles,time_bank + id,site_id,account_id,service_id,active,sku,auth,username,password,service_type,session_limit,idle_limit,port_limit,analog,digital,filter_id,netmask,framed_route,speed_limit,static_ip,profiles,time_bank + id,site_id,account_id,service_id,active,sku,auth,username,password,service_type,session_limit,idle_limit,port_limit,analog,digital,filter_id,netmask,framed_route,speed_limit,static_ip,profiles,time_bank + + + + 0 +
\ No newline at end of file diff --git a/modules/radius/radius_install.xml b/modules/radius/radius_install.xml new file mode 100644 index 00000000..392aabe7 --- /dev/null +++ b/modules/radius/radius_install.xml @@ -0,0 +1,74 @@ + + + + + + radius + + Controls radius provisioning + 1 + + radius_service + + + + + + + %%module_id%% + add + %%:add + 1 + + + %%module_id%% + search_export + + + %%module_id%% + update + + + %%module_id%% + export_excel + + + %%module_id%% + delete + + + %%module_id%% + export_xml + + + %%module_id%% + view + core:search&module=%%&_escape=1 + 1 + + + %%module_id%% + export_tab + + + %%module_id%% + search + %%:search_form + 1 + + + %%module_id%% + search_form + + + %%module_id%% + search_show + + + + %%module_id%% + export_csv > + + + + \ No newline at end of file diff --git a/modules/radius_service/radius_service.inc.php b/modules/radius_service/radius_service.inc.php new file mode 100644 index 00000000..ef8510f4 --- /dev/null +++ b/modules/radius_service/radius_service.inc.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/modules/radius_service/radius_service_construct.xml b/modules/radius_service/radius_service_construct.xml new file mode 100644 index 00000000..082800e0 --- /dev/null +++ b/modules/radius_service/radius_service_construct.xml @@ -0,0 +1,33 @@ + + + radius_service + radius_service
+ radius + 0 + id + 35 + + + I8 + 1 + + + I4 + + + I8 + + + I8 + + + I8 + + + C(16) + + + + + 0 +
\ No newline at end of file diff --git a/modules/radius_service/radius_service_install.xml b/modules/radius_service/radius_service_install.xml new file mode 100644 index 00000000..5dab0ae2 --- /dev/null +++ b/modules/radius_service/radius_service_install.xml @@ -0,0 +1,15 @@ + + + + radius_service + radius + + + radius + + + + + + + \ No newline at end of file diff --git a/modules/report/class.Level.php b/modules/report/class.Level.php new file mode 100644 index 00000000..2b072ec8 --- /dev/null +++ b/modules/report/class.Level.php @@ -0,0 +1,1060 @@ + and Thralling Penguin, LLC + * @package AgileBill + * @version 1.4.93 + */ + +class LevelGraph extends Level_Base { + + var $lev_setting; + var $lev_items; + var $SQL_filtered; + var $group_level; + var $grouping_criteria; + var $formatter; + var $graph; + var $plotarea; + var $dataset; + var $canvas; + + function LevelGraph ( + $title = '', + $width=800, + $height=300, + $type='bar', + $direction = 'vertical', + $x_angle = 90) + { + if(!strlen($direction)) $direction = 'vertical'; + + $this->lev_setting = array( + "title" => $title, + "width" => $width, + "height" => $height, + "y_label_angle" => 0, + "x_label_angle" => intval($x_angle), + "type" => $type, + "direction" => $direction, + "SQL_criteria" => '' + ); + } + + function addDataset ($SQL_select, $SQL_criteria='', $SQL_order='') + { + $this->dataset[] = array( + "SQL_select" => $SQL_select, + "SQL_criteria" => $SQL_criteria, + "SQL_order" => $SQL_order + ); + } + + function display ($grouping_criteria = Null, $grouping_aggregate = Null, &$formatter) + { + $this->formatter =& $formatter; + $this->formatter->setLevel($this); + $this->grouping_criteria = $grouping_criteria; + $this->grouping_aggregate = $grouping_aggregate; + + $this->group_level = false; + if (count($this->lev_items) > 0) { + $this->group_level = true; + } + + set_include_path(get_include_path().PATH_SEPARATOR.PATH_INCLUDES."pear"); + include_once 'Image/Graph.php'; + include_once 'Image/Canvas.php'; + + $this->canvas =& Image_Canvas::factory('png', array( + 'width' => $this->lev_setting["width"], + 'height' => $this->lev_setting["height"], + 'antialias' => 'native' + )); + + $this->graph =& Image_Graph::factory('graph', $this->canvas); + $this->plotarea =& $this->graph->addNew('plotarea',array( + 'Image_Graph_Axis_Category', 'Image_Graph_Axis', $this->lev_setting['direction'] + )); + + $this->plotarea->setFillColor('black@0.1'); + #$this->plotarea->showShadow(); + + $AxisX =& $this->plotarea->getAxis(IMAGE_GRAPH_AXIS_X); + $AxisY =& $this->plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); + + $AxisX->setFontAngle($this->lev_setting["x_label_angle"]); + $AxisY->setFontAngle($this->lev_setting["y_label_angle"]); + + foreach($this->dataset as $dset) { + $SQL_criteria = ''; + if ($dset['SQL_criteria'] != '') { + $SQL_criteria = $this->addToFilter($SQL_criteria, + $dset['SQL_criteria']); + } + #echo "C1: ".$SQL_criteria."
"; + if ($this->lev_setting['SQL_criteria'] != '') { + $SQL_criteria = $this->addToFilter($SQL_criteria, + $this->lev_setting['SQL_criteria']); + } + #echo "C2: ".$SQL_criteria."
"; + if (count($this->grouping_criteria) > 0) { + foreach ($this->grouping_criteria as $key => $value) { + $SQL_criteria = $this->addToFilter($SQL_criteria, + "$key = $value", + $this->grouping_aggregate[$key] + ); + } + } + #echo "C3: ".$SQL_criteria."
"; + $this->SQL_filtered = $this->shuffleSQL($dset["SQL_select"].$SQL_criteria." ".$dset["SQL_order"]); + if(defined('REPORT_DEBUG')) + echo "
The SQL_filtered is: " . $this->SQL_filtered . "
"; + $db =& DB(); + $result = $db->Execute($this->SQL_filtered); + if(!$result) { + echo "SQL: ".$this->SQL_filtered."
".$db->ErrorMsg(); + exit; + } + $num_rows = $result->RecordCount(); + + if ($num_rows == 0) { + return; + } + + $Dataset =& Image_Graph::factory('dataset'); + while(!$result->EOF) { + $Dataset->addPoint($result->fields[0],$result->fields[1]); + $result->MoveNext(); + } + $Plot =& $this->plotarea->addNew($this->lev_setting["type"], &$Dataset); + } + + $file = tempnam($this->formatter->output_path."/", "s"); + @unlink($file); + $file .= ".png"; + $this->graph->done( + array('filename' => $file) + ); + + # add to output + $this->formatter->insertImage( + $file, + $this->lev_setting["width"], + $this->lev_setting["height"] + ); + + #intersperse and whatnot + if ($this->group_level === true) { + $this->formatter->endTable(); + } + if ($this->group_level === true) { + $this->intersperse($this->grouping_criteria,$this->grouping_aggregate); + } + } +} + +class Level extends Level_Base { + + var $lev_setting; + var $lev_fields; + var $lev_items; + var $indent_html; + var $SQL_filtered; + var $group_level; + var $grouping_criteria; + var $has_title; + var $formatter; + var $add_headers = 0; + var $class; + + function Level ($title='', + $SQL_select='', $SQL_criteria='', $SQL_order='', + $title_table_class='title', $title_class='', $indent=0, + $lev_field_width = '', + $lev_field_class = 'row', $lev_label_class = '', $lev_table_class = 'level', + $lev_tot_class = 'rc-lev-tot1', $lev_colspan_label_class = 'rc-lev-colspan-label1') + { + + if($lev_field_class == 'row') { + $lev_field_class = new ReportStyle; + $lev_field_class->backgroundColor(230,230,230); + } + if($lev_label_class == '') { + $lev_label_class = new ReportStyle; + $lev_label_class->bold(); + $lev_label_class->fontFamily('arial'); + $lev_label_class->is_heading = true; + } + + $this->lev_setting = array( + "title" => $title, + "SQL_select" => $SQL_select, + "SQL_criteria" => $SQL_criteria, + "SQL_order" => $SQL_order, + "title_class_html" => $title_class, + "title_table_class_html" => $title_table_class, + "indent" => $indent, + "lev_field_width" => $lev_field_width, + "lev_field_class" => $lev_field_class, + "lev_label_class" => $lev_label_class, + "lev_table_class_html" => $lev_table_class, + "lev_tot_class" => $lev_tot_class, + "lev_colspan_label_class" => $lev_colspan_label_class, + "class" => '' + ); + } + + function setTitle($t) + { + $this->lev_setting["title"] = $t; + } + + function setSql($s) + { + $this->lev_setting["SQL_select"] = $s; + } + + function setCriteria($c) + { + $this->lev_setting["SQL_criteria"] = $c; + } + + function setOrderby($o) + { + $this->lev_setting["SQL_order"] = $o; + } + + function setIndent($i) + { + $this->lev_setting["indent"] = $i; + return $i; + } + + function setClass($c) + { + $this->lev_setting["class"] = $c; + } + + function addField ($label, $name, $isAggregate = false, $width = '', $format = '', + $group_children_by = false, $visible = true, $hide_dups = false, + $class = '', $lev_class_also = false, $label_class = '', $lev_label_class_also = false, + $condition = '', $cond_class = '', + $SQL_select = '', $SQL_criteria = '', + $colspan = 0, $colspan_label = '', $colspan_label_class = '', $lev_colspan_class_also = false, + $has_tot = false, $tot_label = '', $tot_format = '', $tot_class = '', $lev_tot_class_also = false, + $link = '') + { + //NB every field added MUST be in the source SQL + //if a grouping variable, then set group_children_by to True + //if a field is an aggregate, then it must be True. This causes it's usage to be in HAVING clause, instead of WHERE + + if ($link != "") { + $is_link = True; + $link_text_start = $link["link_text_start"]; + $link_text_end = $link["link_text_end"]; + $link_title_start = $link["link_title_start"]; + $link_title_end = $link["link_title_end"]; + $link_href_start = $link["link_href_start"]; + $link_href_end = $link["link_href_end"]; + } else { + $is_link = False; + $link_text_start = ""; + $link_text_end = ""; + $link_title_start = ""; + $link_title_end = ""; + $link_href_start = ""; + $link_href_end = ""; + } + + if($tot_class == '') { + $tot_class = new ReportStyle; + $tot_class->backgroundColor(200,200,200); + } + $this->lev_fields[$name] = array("field_label"=>$label, + "field_name"=>$name, + "field_aggregate"=>$isAggregate, + "colspan"=>$colspan, + "colspan_label"=>$colspan_label, + "colspan_label_class"=>$colspan_label_class, + "lev_colspan_class_also"=>$lev_colspan_class_also, + "field_SQL_select"=>$SQL_select, + "field_SQL_criteria"=>$SQL_criteria, + "group_children_by"=>$group_children_by, + "visible"=>$visible, + "hide_duplicates"=>$hide_dups, + "field_width"=>$width, + "field_format"=>$format, + "field_class"=>$class, + "lev_class_also" =>$lev_class_also, + "field_label_class"=>$label_class, + "lev_label_class_also"=>$lev_label_class_also, + "field_condition"=>$condition, + "field_cond_class"=>$cond_class, + "has_tot"=>$has_tot, + "tot_label"=>$tot_label, + "field_tot_format"=>$tot_format, + "field_tot_class"=>$tot_class, + "lev_tot_class_also"=>$lev_tot_class_also, + "is_link"=>$is_link, + "link_text_start"=>$link_text_start, + "link_text_end"=>$link_text_end, + "link_title_start"=>$link_title_start, + "link_title_end"=>$link_title_end, + "link_href_start"=>$link_href_start, + "link_href_end"=>$link_href_end + ); + } + + function display ($grouping_criteria = Null, $grouping_aggregate = Null, &$formatter) + { + $this->formatter =& $formatter; + $this->formatter->setLevel($this); + $this->grouping_criteria = $grouping_criteria; + $this->grouping_aggregate = $grouping_aggregate; + + #echo "Freshly received grouping criteria: " . print_r($this->grouping_criteria); //check + + $this->group_level = false; + if (count($this->lev_items) > 0) { + $this->group_level = true; + } + + $SQL_criteria = ''; + if ($this->lev_setting['SQL_criteria'] != '') { + $SQL_criteria = $this->addToFilter($SQL_criteria, + $this->lev_setting['SQL_criteria']); + } + + if (count($this->grouping_criteria) > 0) { + foreach ($this->grouping_criteria as $key => $value) { + $SQL_criteria = $this->addToFilter($SQL_criteria, + "$key = $value", + $this->grouping_aggregate[$key] + ); + } + } + + //echo "
The row filter clause is: " . $SQL_criteria , "
"; //check + // 2-2) put select, where, and order clauses together + $this->SQL_filtered = $this->shuffleSQL($this->lev_setting["SQL_select"].$SQL_criteria." ".$this->lev_setting["SQL_order"]); + + if(defined('REPORT_DEBUG')) + echo "
The SQL_filtered is: " . $this->SQL_filtered . "
"; //check + + + $db =& DB(); + $result = $db->Execute($this->SQL_filtered); + if(!$result) { + echo "SQL: {$this->SQL_filtered}
".$db->ErrorMsg(); + exit; + } + $num_rows = $result->RecordCount(); + if ($num_rows == 0) { + return; + } + + $this->indent_html = $this->setIndent($this->lev_setting['indent']); + + // 3-3) insert level title if needed + $this->has_title = False; + if ($this->lev_setting["title"] != '') { + $this->has_title = true; + } + + $heading = ''; + if ($this->has_title === true) { + if(is_a($this->formatter,'HTML_ReportFormatter')) { + $this->formatter->setIndent($this->indent_html); + $heading = '
'.$this->lev_setting["title"].'
'; + + } else { + $this->formatter->setIndent($this->indent_html); + $this->formatter->addTable($this->lev_setting["title_table_class_html"]); + $this->formatter->addRow(); + $this->formatter->addColumn($this->lev_setting["title"], + $this->lev_setting["title_class_html"] + ); + $this->formatter->endRow(); + $this->formatter->endTable(); + } + } + + //if a final row, use header-style labels + if ($this->group_level === false) { + + $this->formatter->setIndent($this->indent_html); + $this->addHeaderLabels($heading); + } + + + /*set these up once before rows begin (needed for hide_duplicates)*/ + foreach ($this->lev_fields as $field) { + $content[$field['field_name']] = ''; //seed/reset + $last_content[$field['field_name']] = ''; //seed/reset + //each of these is an array with an item for each field value in the row + } + + + // 4) DISPLAY EACH ROW >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + while (!$result->EOF) { + $row = $result->fields; + $result->MoveNext(); + + // 4-1) display each visible field (from supplied field argument) within row + + //if level is group level (no header row) need to start table and body (one for each level) + + if ($this->group_level === true) { + if(strlen($this->lev_setting['class'])) + $this->formatter->write('
'); + $this->formatter->setIndent($this->indent_html); + $this->formatter->addTable($this->lev_setting["lev_table_class_html"],$heading); + } + + $this->formatter->addRow(); + + foreach ($this->lev_fields as $field) { + + // 4-1-0) only display field if visible + if ($field['visible'] === false) { + continue; //skip this field + } + + // 4-1-1) set up class(es) + + //only make label classes html if a group level + if ($this->group_level === true) { + /*must create class html here - it is a combination of level and + field class settings */ + + $field_label_class_html = $this->classHtml($field["field_label_class"], + $this->lev_setting["lev_label_class"], + $field["lev_class_also"]); + } + + /*if a conditional class, see if condition met. If it is, use field_conditional class + instead of standard field class*/ + + $condition_met = false; //initialise + if ($field['field_condition'] != '') { + //get condition + $condition_met = $this->makeCondition($field['field_condition'], + $row, $this->lev_fields + ); + } + + if ($condition_met === true) { + $field_class = $field['field_cond_class']; + } else { + $field_class =$field['field_class']; + } + + $field_class_html = $this->classHtml($field_class, + $this->lev_setting['lev_field_class'], + $field['lev_class_also']); + + $field_width_html = $this->setWidth ($field["field_width"], $this->lev_setting["lev_field_width"]); + + if ($field["field_SQL_select"] != '') { //if this field has its own data source ... + + /* 5-1-3-1) set up WHERE/HAVING clause using both parent-derived criteria + (if the level above is team='CommunityCare' then this record source needs to be filtered to + only include data for the CommunityCare team*/ + + $field_SQL_criteria = ""; + + if ($field["field_SQL_criteria"] != "") { + + $field_SQL_criteria = $this->addToFilter($field_SQL_criteria, + $field["field_SQL_criteria"]); + } + + /* + if (count($this->grouping_criteria) > 0) { + + foreach ($this->grouping_criteria as $key => $value) { + + $field_SQL_criteria = $this->addToFilter($field_SQL_criteria, "$key = $value"); + } + } + */ + if($field["field_name"]!="") { + $dba = DB(); + $field_SQL_criteria = $this->addToFilter($field_SQL_criteria, $field["field_name"]." = ".$dba->qstr($row[$field["field_name"]])); + } + + + //echo "
The field filter clause is: " . $field_SQL_criteria , "
"; //check + + /* 4-1-3-2) put select, where (but not order - not applicable - + order derived from other fields) parts of SQL statement together*/ + + $field_SQL_filtered = $this->shuffleSQL($field["field_SQL_select"] . $field_SQL_criteria); + + #echo "
The field_SQL_filtered is: " . $field_SQL_filtered . "
"; //check + + // 4-1-3-3) get the content according to the SQL statement + + $db = DB(); + $rs = $db->Execute($field_SQL_filtered); + if($rs && $rs->RecordCount()) { + $content[$field["field_name"]] = $rs->fields[0]; + } + + } else { //take content from field + + $content[$field["field_name"]] = $row[$field["field_name"]]; + } + + /*if a final level, hide_duplicates = True, and it is a duplicate, + make $field_content = "" and skip to display*/ + $duplicate = false; //seed/reset + + if ($last_content[$field["field_name"]] == $content[$field["field_name"]]) { + $duplicate = true; + } + + //set last content for next comparison (if any) + $last_content[$field["field_name"]] = $content[$field["field_name"]]; + + if ($this->group_level === false + AND $duplicate === true + AND $field["hide_duplicates"] === true) { + + $field_content = ""; + + //skipping formatting and linking + + } else { + + // 4-1-5) set up formatting e.g. decimal places + + $style = $this->getStyle($field["field_format"]); + $dp = $this->getDp($field["field_format"]); + $date_format = $this->getDateFormat($field["field_format"]); + + //echo "
Field content before formatting is: " . $content[$field["field_name"]]; + //echo "
Field array contains: " . print_r($field) . "
"; //check + $field_content = $this->myFormat($content[$field["field_name"]], + $style, $dp, $date_format); + + // 4-1-6) put in link if required + if ($field["is_link"] === true) { + + $field_content = "" . + $field["link_text_start"] . $field_content . $field["link_text_end"] . + ""; + } + } + + // 4-1-7) display field + + if ($this->group_level === true) { + $this->formatter->addColumn($field["field_label"], $field_label_class_html); + $this->formatter->addColumn($field_content, $field_class_html); + } else { + $this->formatter->addColumn($field_content, $field_class_html); + } + } + + $this->formatter->endRow(); + $this->add_headers = 0; + + if ($this->group_level === true) { //a separate table for each group by level + $this->formatter->endTable(); + } + + + //5-1) add additional grouping criteria to $grouping_criteria + + //loop through all fields in level - add to grouping_criteria filter if new_group_by is True + foreach ($this->lev_fields as $field) { + + if ($field["group_children_by"] != true) { //only process this field if adding to filter + continue; + } + $key = "`" . $field["field_name"] . "`"; + $value = $row[$field["field_name"]]; + + if (strpos($field["field_format"],"num") === false) { + $value = $db->qstr($value); + } + $this->grouping_criteria[$key] = $value; + $this->grouping_aggregate[$key] = $field['field_aggregate']; + } + + //echo "
The grouping_criteria are now set to: " . print_r($this->grouping_criteria) . "
"; //check */ + + if ($this->group_level === true) { + $this->intersperse($this->grouping_criteria,$this->grouping_aggregate); + if(strlen($this->lev_setting["class"])) + $this->formatter->write('
'); + } + + } + + + // 6 DISPLAY TOTALS (only if a final level and only if one required) + + /*any fields which have 'have_tot' equal True? Loop through them, and build array of field names. + If the array has any values, proceed (and pass on array to provide headstart building source query*/ + + if ($this->group_level === false) { + $this->addTotal($db); + $this->formatter->endTable(); + } + } + + function addHeaderLabels ($heading) + { + if($this->add_headers>0) return; + $this->add_headers++; + + $this->formatter->addTable($this->lev_setting["lev_table_class_html"], $heading); + $this->formatter->addRow(); + + foreach ($this->lev_fields as $field) { + // only display field if visible + if ($field['visible'] === False) { + continue; //skip this field + } + + $field_label_class_html = $this->classHtml($field["field_label_class"], + $this->lev_setting["lev_label_class"], + $field["lev_label_class_also"]); + + $field_width_html = $this->setWidth ($field["field_width"], $this->lev_setting["lev_field_width"]); + + // c) display + $this->formatter->addColumn($field["field_label"], $field_label_class_html); + } + $this->formatter->endRow(); + } + + function addTotal (&$db) + { + // 0 ) check to see if totals are required for any of the fields >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + // (and build SQL select statement for totals row) + + $SQL_select_tot = ''; + foreach ($this->lev_fields as $field) { + if ($field['has_tot'] === True) { + if ($SQL_select_tot == '') { + $SQL_select_tot = + "SELECT Sum(" . $field["field_name"] . ") AS `Tot_" . $field["field_name"] . "`" ; + } else { + $SQL_select_tot .= + ", Sum(" . $field["field_name"] . ") AS `Tot_" . $field["field_name"] . "`"; + } + } + } + + if ($SQL_select_tot == '') { + return false; + } + + $group_by = ""; + if (count($this->grouping_criteria) > 0) { + $group_by = "GROUP BY "; + foreach ($this->grouping_criteria as $key=>$value) { + $group_by .= (($group_by === "GROUP BY ") ? $key : ", " . $key); + } + } + //echo "
Group by is now: " .$group_by; + + $SQL_tot_filtered = $this->shuffleSQL("$SQL_select_tot FROM (" . $this->SQL_filtered . + ") AS Source "); #$group_by"; //each key in grouping criteria + + # echo "
The SQL tot filtered is: " . $SQL_tot_filtered . "
"; + $result1 = $db->Execute($SQL_tot_filtered); + while (!$result1->EOF) { + $row = $result1->fields; + $result1->MoveNext(); + + $this->formatter->addRow(); + + foreach ($this->lev_fields as $field) { + if ($field["visible"] === False) { + continue; + } + + //must create class html here - it is a combination of field and level class settings + $field_tot_class_html = $this->classHtml($field["field_tot_class"], + $this->lev_setting["lev_tot_class"], + $field["lev_tot_class_also"]); + + $field_width_html = $this->setWidth ($field["field_width"], $this->lev_setting["lev_field_width"]); + + if ($field["has_tot"] === True) { + + // 6-2-1-1) set up field content (whether a value or a format) + + if ($field["tot_label"] != "") { + + // 6-2-1-1-1) set up label + $field_content = $field["tot_label"]; + + } else { + + // 6-2-1-1-2) set up formatting e.g. decimal places (only run when a cell to display) + $field_tot = "Tot_" . $field["field_name"]; + + $field_content = $this->myFormat($row["$field_tot"], + $this->getStyle($field["field_tot_format"]), + $this->getDp($field["field_tot_format"]), + $this->getDateFormat($field["field_format"])); + } + + // 6-2-1-2) display row + $this->formatter->addColumn($field_content, $field_tot_class_html); + } else { + + // 6-2-2) display row + $this->formatter->addColumn(" ", $field_tot_class_html); + } + } + $this->formatter->endRow(); + } + return true; //i.e. had totals + } +} + + +/** + * This is the base Level class, any and all types of rendered chunks MUST inherit from this. + */ +class Level_Base { + + /** + * Add a user criteria to the WHERE clause + */ + function addFieldCriteria($sql, $bIsAggregate = false, $field = '') + { + require_once PATH_INCLUDES . 'pear/Compat/Function/stripos.php'; + $this->lev_setting['SQL_criteria'] = + $this->addToFilter($this->lev_setting['SQL_criteria'], + $sql, $bIsAggregate); + + if(strlen($this->lev_setting['SQL_order'])>0) { + $sql = $this->lev_setting['SQL_order']; + if( ($p=stripos($sql,'GROUP BY')) !== false) { + if( ($t=$this->find_next_sql_keyword($sql,$p+1)) !== false) { + $groupby = substr($sql,$p,$t[1]-$p); + if(stripos($groupby,$field)===false) + $sql = str_replace($groupby,$groupby.", {$field}",$sql); + } + } + $this->lev_setting['SQL_order'] = $sql; + } else { + $this->lev_setting['SQL_order'] = "GROUP BY ".$field; + } + + if(isset($this->dataset)) { + for($i=0;$idataset);$i++) { + if(strlen($this->dataset[$i]['SQL_order'])>0) { + $sql = $this->dataset[$i]['SQL_order']; + if( ($p=stripos($sql,'GROUP BY')) !== false) { + if( ($t=$this->find_next_sql_keyword($sql,$p+1)) !== false) { + $groupby = substr($sql,$p,$t[1]-$p); + if(stripos($groupby,$field)===false) + $sql = str_replace($groupby,$groupby.", {$field}",$sql); + } + } + $this->dataset[$i]['SQL_order'] = $sql; + } else { + $this->dataset[$i]['SQL_order'] = "GROUP BY ".$field; + } + } + } + } + + /** + * Add a sub-object to render beneath the current object + */ + function append (&$item) + { + $this->lev_items[] =& $item; + } + + function addBreak () + { + $this->lev_items[] = new Report_BreakAdaptor; + } + + function addDiv($id) + { + $item = new Report_BreakAdaptor; + $item->id = $id; + $this->lev_items[] =& $item; + } + + /** + * This calls all sub-objects of the current object to tell them to build their output + */ + function intersperse ($grouping_criteria, $grouping_aggregate) + { + if(isset($this->lev_items) && is_array($this->lev_items)) { + foreach ($this->lev_items as $item) { + #if(strlen($this->lev_setting['class'])) + # $this->formatter->write('
'); + $c = $this->formatter->indent; + $item->display($grouping_criteria, $grouping_aggregate, $this->formatter); + $this->formatter->indent = $c; + #if(strlen($this->lev_setting["class"])) + # $this->formatter->write('
'); + } + } + } + + /** + * Build onto the SQL WHERE/HAVING clause + */ + function addToFilter ($full_criteria, $new_criterion, $aggregate = false) + { + /* + echo "
"; + echo "full_criteria = ".$full_criteria."
"; + echo "new_criterion = ".$new_criterion."
"; + echo "aggregate = ".$aggregate."
"; + */ + $new_criterion = str_replace(" "," ",$new_criterion); + $new_criterion = str_replace("WHERE HAVING","HAVING",$new_criterion); + $t = "WHERE"; + if($aggregate) { + $t = "HAVING"; + } + if ($full_criteria == "") { + if(strpos($new_criterion,$t)!==false) + return $new_criterion; + else + return " $t " . $new_criterion; + break; + } + #echo "t:".$t."
fc:".$full_criteria."
nc:".$new_criterion."
"; + if (strpos($full_criteria, $t) === False && strpos($new_criterion, $t)===false) { + if($t == "WHERE") { + $r = " WHERE ".$full_criteria; + if(strlen($new_criterion)) + $r .= " AND ".$new_criterion; + return $r; + } else { + return $full_criteria." $t " . $new_criterion; + } + } else if(strpos($full_criteria, $t)!==false && strpos($new_criterion, $t) !== false) { + $sql = $full_criteria . " AND " . substr($new_criterion, strpos($new_criterion,$t)+strlen($t)); + $sql = str_replace("AND HAVING","HAVING",$sql); + #echo 'OUTPUT:'.$sql."
"; + return $sql; + } else { + #echo "fc1:".$full_criteria."
nc:".$new_criterion."
"; + if(strncasecmp(trim($new_criterion),"having",6)==0) + return $full_criteria . ' '. $new_criterion; + else + return $full_criteria . " AND " . $new_criterion; + } + } + + function find_next_sql_keyword($sql,$offset=0) + { + require_once PATH_INCLUDES . 'pear/Compat/Function/stripos.php'; + $ret = false; + if(is_string($sql) && is_numeric($offset)) { + $arr = array( + 'WHERE', + 'GROUP BY', + 'ORDER BY', + 'LIMIT', + 'HAVING' + ); + $bFound = false; + foreach($arr as $k) { + if( ($t=stripos($sql,$k,$offset)) !== false) { + if($ret === false) { + $ret = array($k,$t); + $bFound = true; + } + } + } + if($bFound == false) { + $ret = array('',strlen($sql)); + } + } + return $ret; + } + + function shuffleSQL($sql, $groupBy='') + { + require_once PATH_INCLUDES . 'pear/Compat/Function/stripos.php'; + if( ($p=stripos($sql,'HAVING')) !== false) { + # found a having clause + $leading = ''; + $having = ''; + $groupby = ''; + $orderby = ''; + $limit = ''; + + if( ($t=$this->find_next_sql_keyword($sql,$p+1)) !== false) { + $having = substr($sql,$p,$t[1]-$p); + $sql = str_replace($having,'',$sql); + } + if( ($p=stripos($sql,'GROUP BY')) !== false) { + if( ($t=$this->find_next_sql_keyword($sql,$p+1)) !== false) { + $groupby = substr($sql,$p,$t[1]-$p).$groupBy; + $sql = str_replace($groupby,'',$sql); + } + } + if( ($p=stripos($sql,'ORDER BY')) !== false) { + if( ($t=$this->find_next_sql_keyword($sql,$p+1)) !== false) { + $orderby = substr($sql,$p,$t[1]-$p); + $sql = str_replace($orderby,'',$sql); + } + } + if( ($p=stripos($sql,'LIMIT')) !== false) { + if( ($t=$this->find_next_sql_keyword($sql,$p+1)) !== false) { + $limit = substr($sql,$p,$t[1]-$p); + $sql = str_replace($limit,'',$sql); + } + } + #echo "having=$having
groupby=$groupby
orderby=$orderby
limit=$limit
"; + $sql .= $groupby.' '.$having.' '.$orderby.' '.$limit; + } + return $sql; + } + + + function makeCondition ($condition, $row, $fields) + { + //replace bracketed text with data from field in row with same name + //numeric data does not need to be unquoted as long as == is used instead of === + //date data must be wrapped in strtotime on both sides of comparison to work (NB Unix time 1970 onwards only) + //replace brackets with PHP code then use eval to run generated string as PHP code + + $condition = str_replace('[','$row[\'',$condition); + $condition = str_replace(']','\']',$condition); + $condition = "if($condition){\$condition_met=True;}else{\$condition_met=False;}"; + //echo "
Test expression as generated: $condition";//check + eval($condition); + + return $condition_met; + } + + function setIndent ($indent) + { + return $this->formatter->setIndent($indent); + } + + function myFormat ($value, $style, $dp, $date_format) + { + switch ($style) { + + case "upper": + + return strtoupper($value); + break; + + case "perc": + + return sprintf("%01." . $dp . "f", $value) . "%"; + break; + + case "dol": + + return "$" . number_format($value, $dp); + break; + + case "num": + + return number_format($value, $dp);; + break; + + case "date": + if ($value != "") { + /*echo "Date format: " . $date_format . "; + Value: " . $value . "Date: " . date($date_format, strtotime($value)); //check*/ + return date($date_format, $value); + + } else { + + return $value; + } + + break; + + default: + + return $value; + break; + } + } + + function getStyle ($format) + { + $field_format = explode(",", $format); + return $field_format[0]; + } + + function getDp ($format) + { + $field_format = explode(",", $format); + return (count($field_format) > 1 ? $field_format[1] : 0); + } + + function getDateFormat ($format) + { + $field_format = explode(",", $format); + return (count($field_format) > 2 ? $field_format[2] : "m/d/Y"); + } + + function setWidth ($field_width, $level_field_width) + { + $width = (($field_width != "") ? $field_width : $level_field_width); + return (($width != "") ? " width='" . $width . "'" : "" ); + } + + /** + * This is worthless junk from the original author, should be refactored + */ + function classHtml ($field_class, $lev_class, $both = False) + { + if(is_a($field_class,'ReportStyle')) + return $field_class; + if(is_a($lev_class,'ReportStyle')) + return $lev_class; + if ($field_class == "" AND $lev_class == "") { //nothing to set + + return ""; + } + + switch ($both) { + + case true: //use both classes + + return "$field_class $lev_class"; + break; + + case false: //only use on class (field takes precedence over level) + + if ($field_class != '') { + return $field_class; + } else { + return $lev_class; + } + break; + } + } +} +?> \ No newline at end of file diff --git a/modules/report/class.Report.php b/modules/report/class.Report.php new file mode 100644 index 00000000..79956ffc --- /dev/null +++ b/modules/report/class.Report.php @@ -0,0 +1,681 @@ + and Thralling Penguin, LLC + * @package AgileBill + * @version 1.4.93 + */ + +class BASE_ReportFormatter { + var $output_path; + var $output; + + function setOutputDirectory($d) + { + $this->output_path = $d; + } + + function getOutput() + { + return $this->output; + } +} + +class HTML_ReportFormatter extends BASE_ReportFormatter { + var $indent = 0; + var $coldata; + var $level; + var $div_count; + + function setLevel(&$level) + { + $this->level =& $level; + } + + function setIndent($amount) + { + if($amount == "") return; + $this->indent = $amount; + } + + function addRow() + { + $this->coldata = array(); + echo " \n"; + } + + function endRow() + { + /* output the coldata */ + #if($this->indent) { + # echo " indent}\"> \n"; + #} + $w = 100 / count($this->coldata); + foreach($this->coldata as $col) { + $tag = "td"; + if (is_a($col[1],'ReportStyle')) { + $s = "style=\"".$col[1]->doHTML()."\""; + if($col[1]->is_heading) $tag = "th scope=\"col\""; + } else { + $s = ""; + } + + echo " <{$tag} {$s} width=\"{$w}%\">\n"; + echo " {$col[0]}\n"; + echo " \n"; + } + echo " \n"; + } + + function addColumn($col, $style = '') + { + /* take a column and a style */ + $this->coldata[] = array($col, $style); + } + + function addTable($style, $heading) + { + $i = $this->indent / 30; if($i<0) $i = 0; + ++$i; + $this->div_count = 0; + + if($style != 'report_heading') { + echo '
'; + $this->div_count += 1; + } + if($this->indent == 0) { + if($style != 'level') { + echo '
'; + $this->div_count += 1; + } + } + echo $heading; + echo ''; + echo "\n"; + } + + function endTable() + { + $i = $this->indent / 30; if($i<0) $i = 0; + ++$i; + echo "
\n"; + + if($this->div_count == 1) + echo "
\n"; + if($this->indent == 0) { + if($this->div_count == 2) + echo "
\n"; + } + } + + function startDocument($title = '') + { + ob_start(); + echo "\n"; + echo "\n"; + echo "{$title}\n"; + echo ""; + echo "\n\n"; + } + + function endDocument() + { + echo "\n\n"; + $content = ob_get_contents(); + ob_end_clean(); + $this->output = $this->output_path."/report.html"; + $fp = fopen($this->output,'w'); + if($fp) { + fwrite($fp,$content); + fclose($fp); + } else { + echo 'Could not write to output file.'; + } + } + + function addBreak() + { + echo "


"; + } + + function insertImage($file,$width,$height) + { + $file = basename($file); + echo "
\n"; + } + + function write($s) + { + echo $s; + } +} + +/** + * Outputs the report in DOS text format + */ +class TXT_ReportFormatter extends BASE_ReportFormatter { + var $indent = 0; + var $aindent; + var $coldata; + var $level; + + function setLevel(&$level) + { + $this->level =& $level; + } + + function setIndent($amount) + { + if($amount == "") return; + $this->indent = $amount; + } + + function addRow() + { + $this->coldata = array(); + } + + function endRow() + { + /* output the coldata */ + if($this->indent) { + $n = intval($this->indent) / 30; + echo str_repeat(" ", $n); + } + $w = (100 / count($this->coldata))/100 * 80; + foreach($this->coldata as $col) { + echo str_pad($col[0], $w); + } + echo "\r\n"; + } + + function addColumn($col, $style = '') + { + /* take a column and a style */ + $this->coldata[] = array($col, $style); + } + + function addTable($style, $heading=false) + { + if($this->indent) { + echo "\r\n"; + $this->aindent = $this->indent; + } else { + echo "\r\n\r\n"; + } + } + + function endTable() + { + if($this->indent && $this->indent != $this->aindent) echo "\r\n"; + } + + function startDocument($title = '') + { + ob_start(); + } + + function endDocument() + { + $content = ob_get_contents(); + ob_end_clean(); + $this->output = $this->output_path."/report.txt"; + $fp = fopen($this->output,'w'); + if($fp) { + fwrite($fp,$content); + fclose($fp); + } else { + echo 'Could not write to output file.'; + } + } + + function addBreak() + { + echo "\r\n\r\n"; + } + + function insertImage($file,$width,$height) + { + $file = basename($file); + echo "\r\nSee file: $file\r\n"; + } + + function write($s) + { + + } +} + +class PDF_ReportFormatter extends BASE_ReportFormatter { + var $indent = 0; + var $aindent; + var $coldata; + var $pdf; + var $y; + var $level; + + function write($s) + { + + } + + function setIndent($amount) + { + if($amount == "") return; + $this->indent = intval($amount); + } + + function addRow() + { + $this->coldata = array(); + } + + function endRow() + { + $x = 9; + $n = 0; + /* output the coldata */ + if($this->indent) { + $n = $this->indent / 30; + $x += ($n * 9); + } + $w = round((100 / count($this->coldata))/100 * (190 - ($n*9))); + $tx = $x; + foreach($this->coldata as $col) { + if (is_a($col[1],'ReportStyle')) { + /* set the bounding area */ + $col[1]->setBounds($tx,$this->y,$tx + $w,$this->y + 5); + $col[1]->doPDF($this->pdf); + } else { + $tmp = new ReportStyle; + $tmp->doPDF($this->pdf); + } + #echo "x={$tx} y={$this->y} data={$col[0]} style={$col[1]}
"; + $this->pdf->Text($tx, $this->y,$col[0]); + $tx += $w; + } + $this->addY(5, true); + } + + function addY($y, $repeatLabels = false) + { + $this->y += $y; + if ($this->y > 275) { + $this->pdf->AddPage(); + $this->y = 5; + if($repeatLabels) + $this->level->addHeaderLabels(); + } + } + + function setLevel(&$level) + { + $this->level =& $level; + } + + function addColumn($col, $style = '') + { + /* take a column and a style */ + $this->coldata[] = array($col, $style); + } + + function addTable($style, $heading='') + { + if($this->indent) { + $this->addY(5); + $this->aindent = $this->indent; + } else { + $this->addY(10); + } + + # if we're close to the end, goto next page + if($this->y > 250) $this->addY(1000); + } + + function endTable() + { + if($this->indent && $this->indent != $this->aindent) $this->addY(5); + } + + function startDocument($title = '') + { + require_once(PATH_INCLUDES.'pdf/fpdi.php'); + require_once(PATH_INCLUDES.'pdf/fpdf_tpl.php'); + require_once(PATH_INCLUDES.'pdf/fpdf.php'); + + $this->pdf = new fpdi; + $this->pdf->addPage(); + $this->y = 5; + } + + function endDocument() + { + $file = $this->output_path."/report.pdf"; + $this->output = $file; + $this->pdf->Output($file,'F'); + } + + function addBreak() + { + $this->addY(10); + } + + function insertImage($file,$width,$height) + { + $w = $width / 11.81102 * 2.5; + $h = $height / 11.81102 * 2.5; + $y = $this->y + 5; + $x = 105 - ($w/2); + #echo 'Place image at 0,'.$y." $w x $h
"; + $this->pdf->Image($file, $x, $y, $w, $h); + $this->y = $y + $h + 5; + } +} + +class ReportStyle { + var $font_weight; + var $font_family; + var $font_height; + var $bg_color; + var $is_heading; + var $tx, $ty, $bx, $by; + + function ReportStyle() + { + $this->font_weight = ''; + $this->font_family = 'times'; + $this->font_height = 10; + $this->is_heading = false; + } + + function fontFamily($f) + { + $this->font_family = $f; + } + + function fontHeight($h) + { + $this->font_height = $h; + } + + function bold() + { + $this->font_weight = 'bold'; + } + + function backgroundColor($r,$g,$b) + { + $this->bg_color = array($r,$g,$b); + } + + function setBounds($x1,$y1,$x2,$y2) + { + $this->tx = $x1; $this->ty = $y1; + $this->bx = $x2; $this->by = $y2; + #echo "BOUNDS: $x1 x $y1 x $x2 x $y2
"; + } + + /** + * Generates the PDF style + */ + function doPDF(&$pdf) + { + if(is_array($this->bg_color)) { + $x1 = $this->tx; + $y1 = $this->ty - ($this->font_height * 0.352777778); + $w = $this->bx - $this->tx; + $h = $this->by - $this->ty; + $pdf->SetFillColor($this->bg_color[0],$this->bg_color[1],$this->bg_color[2]); + $pdf->Rect($x1,$y1,$w,$h,'F'); + #echo "BOX: $x1 x $y1 x $w x $h
"; + } + + $b = ($this->font_weight == 'bold' ? "B" : ""); + + $pdf->SetFont($this->font_family,$b,$this->font_height); + } + + /** + * Generates the HTML style + */ + function doHTML() + { + $s = "font-family: {$this->font_family}; font-size: {$this->font_height}pt;"; + if($this->font_weight == 'bold') + $s .= " font-weight: bold;"; + if(is_array($this->bg_color)) { + $s .= " background-color: #"; + $s .= str_pad(dechex($this->bg_color[0]), 2, '0', STR_PAD_LEFT); + $s .= str_pad(dechex($this->bg_color[1]), 2, '0', STR_PAD_LEFT); + $s .= str_pad(dechex($this->bg_color[2]), 2, '0', STR_PAD_LEFT); + $s .= ";"; + } + $s=""; + return $s; + } +} + +/** + * This class is a adaptor pattern that serves to place a break in the formatting of the report. + */ +class Report_BreakAdaptor { + function display($grouping, $aggregate, &$formatter) + { + $formatter->addBreak(); + } +} + +require_once PATH_MODULES.'report/class.Level.php'; +class Report_DivAdaptor extends Level_Base { + var $id; + var $lev_setting; + var $lev_fields; + var $lev_items; + var $indent_html; + var $SQL_filtered; + var $group_level; + var $grouping_criteria; + var $has_title; + var $formatter; + + function display($grouping, $aggregate, &$formatter) + { + $this->formatter =& $formatter; + #echo "
id}\">"; + if(isset($this->lev_items) && is_array($this->lev_items)) { + foreach ($this->lev_items as $item) { + echo "
id}\">"; + $c = $this->formatter->indent; + $item->display($grouping, $aggregate, $this->formatter); + $this->formatter->indent = $c; + echo "
"; + } + } + #echo "
"; + } +} + +class Reporting { + var $has_header; + var $rep_title; + var $rep_subtitle_1; + var $rep_subtitle_2; + var $rep_date_start; + var $rep_date_end; + var $rep_image_src; + var $rep_image_width; + var $rep_image_height; + var $rep_image_alt; + var $rep_desc; + var $rep_items; + var $rep_formatter; + + function Reporting (&$formatter, $has_header = false) + { + $this->has_header = $has_header; + /* + + TODO: Implement this crap at a later point + + + $this->rep_title = $rep_title; + $this->rep_subtitle_1 = $rep_subtitle_1; + $this->rep_subtitle_2 = $rep_subtitle_2; + $this->rep_date_start = $rep_date_start; + $this->rep_date_end = $rep_date_end; + $this->rep_desc = $rep_desc; + $this->rep_image_src = $rep_image_src; + $this->rep_image_width = $rep_image_width; + $this->rep_image_height = $rep_image_height; + $this->rep_image_alt = $rep_image_alt; + */ + $this->rep_formatter =& $formatter; + } + + function setTitle($t, $style = '') + { + if($style=='') $style = new ReportStyle; + $style->fontHeight(16); + $style->fontFamily('arial'); + $this->rep_title = array($t,$style); + } + + function setSubtitle1($t, $style = '') + { + if($style=='') $style = new ReportStyle; + $style->fontHeight(14); + $style->fontFamily('arial'); + $this->rep_subtitle_1 = array($t,$style); + } + + function setSubtitle2($t, $style = '') + { + if($style=='') $style = new ReportStyle; + $style->fontHeight(12); + $style->fontFamily('arial'); + $this->rep_subtitle_2 = array($t,$style); + } + + function addBreak () + { + $this->rep_items[] = new Report_BreakAdaptor; + } + + function addDiv($id) + { + $item = new Report_DivAdaptor; + $item->id = $id; + $this->rep_items[] = $item; + } + + function append (&$item) + { + $this->rep_items[] =& $item; + } + + function display () + { + $this->rep_formatter->startDocument($this->rep_title[0]); + + if ($this->has_header) { + $this->displayHeader(); + } + if(is_array($this->rep_items)) { + foreach ($this->rep_items as $item) { + $cur = $this->rep_formatter->indent; + $item->display(Null, Null, $this->rep_formatter); + $this->rep_formatter->indent = $cur; + } + } + $this->rep_formatter->endDocument(); + } + + function displayHeader () + { + if(is_a($this->rep_formatter,'HTML_ReportFormatter')) { + if ($this->rep_title != '') { + echo '

'.$this->rep_title[0].'

'; + } + + if ($this->rep_subtitle_1 != '') { + echo '

'.$this->rep_subtitle_1[0].'

'; + } + + if ($this->rep_subtitle_2 != '') { + echo '

'.$this->rep_subtitle_2[0].'

'; + } + + } else { + $this->rep_formatter->addTable('report_heading'); + + if ($this->rep_image_src != '') { + + echo ""; + + $width_html = ''; + $height_html = ''; + $alt_html = ''; + + if ($this->rep_image_width != '') { + $width_html = " width='$this->rep_image_width'"; + } + + echo ""; + + if ($this->rep_image_height != '') { + $height_html = " height='$this->rep_image_height'"; + } + + if ($this->rep_image_alt != '') { + $alt_html = " alt='$this->rep_image_alt'"; + } + + echo " + "; + } + + $d = ""; + if ($this->rep_title != '') { + $this->rep_formatter->addRow(); + $this->rep_formatter->addColumn($this->rep_title[0],$this->rep_title[1]); + $this->rep_formatter->endRow(); + } + + if ($this->rep_subtitle_1 != '') { + $this->rep_formatter->addRow(); + $this->rep_formatter->addColumn($this->rep_subtitle_1[0],$this->rep_subtitle_1[1]); + $this->rep_formatter->endRow(); + } + + if ($this->rep_subtitle_2 != '') { + $this->rep_formatter->addRow(); + $this->rep_formatter->addColumn($this->rep_subtitle_2[0],$this->rep_subtitle_2[1]); + $this->rep_formatter->endRow(); + } + + # $d .= "

Report generated on " . date("d/m/y") . "

"; + + if ($this->rep_desc != '') { + $d .= "

$this->rep_desc

"; + } + + $this->rep_formatter->addRow(); + $this->rep_formatter->addColumn(' '); + $this->rep_formatter->endRow(); + $this->rep_formatter->endTable(); + } + } +} +?> diff --git a/modules/report/class.ReportParser.php b/modules/report/class.ReportParser.php new file mode 100644 index 00000000..96b19dca --- /dev/null +++ b/modules/report/class.ReportParser.php @@ -0,0 +1,420 @@ + and Thralling Penguin, LLC + * @package AgileBill + * @version 1.4.93 + */ + +set_include_path(PATH_SEPARATOR.PATH_INCLUDES."pear"); +require_once 'XML/Parser.php'; + +class reportColumnTag +{ + var $type; + var $sql = ''; + var $criteria = ''; + var $orderby = ''; + var $indent = 0; + var $display = ''; + var $field = ''; + var $aggregate = false; + var $width = ''; + var $format = ''; + var $group_children_by = false; + var $visible = true; + var $hide_dups = false; + var $condition = ''; + var $sql_criteria = ''; + var $total = false; + var $total_format = ''; + var $link = ''; + var $user_criteria_table = ''; + var $user_criteria_col_id = ''; + var $user_criteria_col_name = ''; + var $user_criteria_date_format = 'Y-m'; + var $user_criteria_type; + var $user_criteria; + var $user_criteria_aggregate; + + function reportColumnTag() + { + $this->type = 'reportLevelTag'; + $this->user_criteria = false; + } +} + +class reportDatasetTag +{ + var $type; + var $sql = ''; + var $criteria = ''; + var $orderby = ''; + + function reportDatasetTag() + { + $this->type = 'reportDatasetTag'; + } +} + +class ReportParser extends XML_Parser +{ + // Holds a reference to the reporting root class + var $reportClass; + // Holds the cdata as we parse a given tag + var $cdata; + // Holds our processing objects in a first in - last out (FILO) manner + var $stack; + + // Holds the fields the user may edit and change + var $user_criteria; + // Holds the fields the user has changed + var $user_criteria_data; + // Holds the fields that have been added + var $user_criteria_fields; + + function ReportParser(&$reportClass) + { + static $uc; + static $ucd; + static $ucf; + + $this->user_criteria =& $uc; + $this->user_criteria_data =& $ucd; + $this->user_criteria_fields =& $ucf; + + # Create the user criteria fields as static members + + if(!is_a($reportClass,'Reporting')) die('Parameter 1 must be a Reporting reference.'); + # Save the Reporting reference + $this->reportClass =& $reportClass; + # Clear the cdata buffer + $this->cdata = ""; + # Init the stack + $this->stack = array(); + # Call into XML_Parser, to set us up the bomb. (See references on ALL YOUR BASE R BELONG TO US - Seriously, it's funny shit.) + parent::XML_Parser(); + # Do NOT perform case foldering! + $this->folding = false; + } + + function getUserCriteria() + { + return $this->user_criteria; + } + + function setUserCriteria($field, $condition, $value) + { + #$this->user_criteria_fields[] = $field; + $this->user_criteria_data[] = array($field, $condition, $value); + } + + function getUserCriteriaSQL($field,&$isAggregate) + { + $sql = ""; + if(!is_array($this->user_criteria_data)) return ''; + foreach($this->user_criteria as $uc) { + if($uc['name'] == $field) { + break; + } + } + foreach($this->user_criteria_data as $ucd) { + if($ucd[0] == $field) { + $db =& DB(); + + # format the field correctly + switch($uc['type']) { + case 'date': + case 'date_year_month': + $ucd[2] = date('Ym',$ucd[2]); + break; + case 'date_year': + $ucd[2] = date('Y',$ucd[2]); + break; + default: + break; + } + + if(strpos(strtoupper($ucd[1]),'NULL') !== false) { + $sql .= $field." ".$ucd[1]; + } else { + if(ereg("^[0-9]+$",$ucd[2])) + $sql .= $field." ".$ucd[1]." ".$ucd[2]; + else + $sql .= $field." ".$ucd[1]." ".$db->qstr($ucd[2]); + } + $sql .= " AND "; + } + } + if(strlen($sql)) + $sql = substr($sql,0,strlen($sql)-4); + $isAggregate = $uc['aggregate']; + return $sql; + } + + function startHandler($xp, $name, $attr) + { + # Clear the cdata buffer + $this->cdata = ""; + + if($name == 'report' && !count($this->stack)) { + # initial outer report tag. set our start state. + $this->stack[] =& $this->reportClass; + return; + } else if($name == 'level') { + $this->stack[] = new Level; + } else if($name == 'graph') { + $this->stack[] = new LevelGraph( + $attr['title'], + intval($attr['width']), + intval($attr['height']), + $attr['type'], + @$attr['direction'], + @$attr['x_angle'] + ); + } else if($name == 'column') { + $this->stack[] = new reportColumnTag; + } else if($name == 'dataset') { + $this->stack[] = new reportDatasetTag; + } else if($name == 'break') { + $work =& $this->last($this->stack); + if($work) { + $work->addBreak(); + } + } else if($name == 'div') { + $item = new Report_DivAdaptor; + $item->id = $attr['id']; + $this->stack[] =& $item; + } else if($name == 'user_criteria') { + $work =& $this->last($this->stack); + if($work && is_a($work,'reportColumnTag')) { + # validate the type + switch($attr['type']) { + case 'auto_affiliate': + case 'auto_account': + case 'menu': + case 'bool': + case 'text': + case 'date_year_month': + case 'date_year': + case 'date': + break; + default: + echo 'Error in user_criteria type.'; exit; + } + $work->user_criteria = true; + $work->user_criteria_type = $attr['type']; + $work->user_criteria_date_format = @$attr['date_format']; + $work->user_criteria_table = @$attr['table']; + $work->user_criteria_col_id = @$attr['col_id']; + $work->user_criteria_col_name = @$attr['col_name']; + $work->user_criteria_aggregate = @$attr['aggregate']; + } + } + #echo '
startHandler: '.$name."\n\n".print_r($this->stack,true).'
'; + } + + function endHandler($xp, $name) + { + if(strlen($this->cdata)) { + while(preg_match("/%%([A-Z1-2_]+)%%/", $this->cdata, $regs)>0) { + if(defined($regs[1])) { + $this->cdata = str_replace("%%".$regs[1]."%%", constant($regs[1]), $this->cdata); + } + } + } + + #echo "endHandler:$name
"; + $work =& $this->last($this->stack); array_pop($this->stack); + #echo "Class Type: ".get_class($work)."
"; + #echo '
endHandler: '.$name."\n\n".print_r($this->stack,true).'
'; + if($name == 'report' && count($this->stack)==1) { + #echo 'stack is empty. returning from endHandler.
'; + return; + } + + # Report + if(is_a($work,'Reporting')) { + if($name == 'title') + $work->setTitle($this->cdata); + else if($name == 'subtitle1') + $work->setSubtitle1($this->cdata); + else if($name == 'subtitle2') + $work->setSubtitle2($this->cdata); + } + + # Level + if(is_a($work,'Level')) { + if($name == 'sql') + $work->setSql($this->cdata); + else if($name == 'criteria') + $work->setCriteria($this->cdata); + else if($name == 'orderby') + $work->setOrderby($this->cdata); + else if($name == 'indent') + $work->setIndent($this->cdata); + else if($name == 'title') + $work->setTitle($this->cdata); + else if($name == 'htmlstyle') + $work->setClass($this->cdata); + + else if($name == 'level') { + $ltmp =& $work; + $work =& $this->last($this->stack); array_pop($this->stack); + # Do we have user criteria values on this? + if(is_array($this->user_criteria_data)) { + #echo '
'.print_r($this->user_criteria_data,true).'
'; + $tmp = $this->user_criteria_data; + foreach($tmp as $f) { + $a = false; + $c = $this->getUserCriteriaSQL($f[0], $a); + #echo "
c=$c\n".print_r($f,true).'
'; + if(strlen($c)) { + $ltmp->addFieldCriteria($c, $a, $f[0]); + } + } + #echo "
".print_r($ltmp,true)."
"; exit; + } + $work->append($ltmp); + } + } + if(is_a($work,'Report_DivAdaptor')) { + $ltmp =& $work; + $work =& $this->last($this->stack); array_pop($this->stack); + $work->append($ltmp); + } + if(is_a($work,'reportColumnTag')) { + if($name == 'display') + $work->display = $this->cdata; + else if($name == 'field') + $work->field = $this->cdata; + else if($name == 'aggregate') + $work->aggregate = $this->cdata == 'true' ? true : false; + else if($name == 'width') + $work->width = $this->cdata; + else if($name == 'format') + $work->format = $this->cdata; + else if($name == 'group_children_by') + $work->group_children_by = $this->cdata == 'true' ? true : false; + else if($name == 'visible') + $work->visible = $this->cdata == 'true' ? true : false; + else if($name == 'hide_dups') + $work->hide_dups = $this->cdata == 'true' ? true : false; + else if($name == 'sql') + $work->sql = $this->cdata; + else if($name == 'sql_criteria') + $work->sql_criteria = $this->cdata; + else if($name == 'condition') + $work->condition = $this->cdata; + else if($name == 'total') + $work->total = $this->cdata == 'true' ? true : false; + else if($name == 'total_format') + $work->total_format = $this->cdata; + else if($name == 'link') + $work->link = $this->cdata; + else if($name == 'column') { + $f =& $work; + $work =& $this->last($this->stack); array_pop($this->stack); + $work->addField($f->display, $f->field, $f->aggregate, $f->width, + $f->format, $f->group_children_by, $f->visible, $f->hide_dups, + '', false, '', false, $f->condition, '', $f->sql, $f->sql_criteria, + 0, '', '', false, $f->total, '', $f->total_format, '', false, $f->link + ); + # If this field has user_criteria=true, then add it to the avail array + if($f->user_criteria) { + #echo "
Trying\n".print_r($this->user_criteria_fields,true).'
'; + + if(!is_array($this->user_criteria_fields) || !in_array(str_replace('.','',$f->field),$this->user_criteria_fields)) { + $this->user_criteria[] = array( + 'name' => $f->field, + 'display' => $f->display, + 'type' => $f->user_criteria_type, + 'date_format' => $f->user_criteria_date_format, + 'values' => '', + 'table' => $f->user_criteria_table, + 'col_id' => $f->user_criteria_col_id, + 'col_name' => $f->user_criteria_col_name, + 'aggregate' => $f->aggregate + ); + $this->user_criteria_fields[] = str_replace('.','',$f->field); + #echo "
LEVEL\n".print_r($this->user_criteria,true).'
'; + } + } + } + } + if(is_a($work,'LevelGraph')) { + if($name == 'title') + $work->setTitle($this->cdata); + else if($name == 'graph') { + # store the reference + $ltmp =& $work; + # pop the stack again + $work =& $this->last($this->stack); array_pop($this->stack); + + # Do we have user criteria values on this? + if(is_array($this->user_criteria_data)) { + $tmp = $this->user_criteria_data; + foreach($tmp as $f) { + $a = false; + $c = $this->getUserCriteriaSQL($f[0], $a); + #echo "
c=$c\n".print_r($f,true).'
'; + if(strlen($c)) { + $ltmp->addFieldCriteria($c, $a, $f[0]); + } + } + #echo "
".print_r($ltmp,true)."
"; exit; + } + # append this graph onto the level/report/graph below + $work->append($ltmp); + } + } + if(is_a($work,'reportDatasetTag')) { + if($name == 'criteria') + $work->criteria = $this->cdata; + else if($name == 'orderby') + $work->orderby = $this->cdata; + else if($name == 'sql') + $work->sql = $this->cdata; + else if($name == 'dataset') { + # store the reference + $d =& $work; + # pop the stack + $work =& $this->last($this->stack); array_pop($this->stack); + # add the dataset to the graph + $work->addDataset($d->sql, $d->criteria, $d->orderby); + } + } + # Push the worker object back onto the stack + $this->stack[] =& $work; + } + + function cdataHandler($xp, $cdata) + { + $this->cdata .= $cdata; + } + + /** + * Returns the true class reference from an array, unlike any PHP function + */ + function &last(&$array) { + if (!is_array($array)) + return null; + if (!count($array)) + return false; // like end() + return $array[count($array)-1]; + } +} + +?> \ No newline at end of file diff --git a/modules/report/report.inc.php b/modules/report/report.inc.php new file mode 100644 index 00000000..27618587 --- /dev/null +++ b/modules/report/report.inc.php @@ -0,0 +1,310 @@ + + * @package AgileBill + * @version 1.4.93 + */ + +/** + * Agileco Report Module + */ +class report +{ + /** + * Get the list of available modules + */ + function module_menu($VAR) + { + global $C_translate; + + if(!empty($VAR['report_module'])) + $default = $VAR['report_module']; + else + $default = false; + + $return = ''; + + $path = PATH_AGILE . 'reports/'; + chdir($path); + $dir = opendir($path); + $count = 0; + while ($file_name = readdir($dir)) + { + if( $file_name != '..' && $file_name != '.' && !ereg(".xml", $file_name) && !ereg(".php", $file_name)) + { + $name = $C_translate->translate('menu', $file_name, ''); + if(empty($name) && eregi("^[a-zA-Z0-9\-\_]{1,}", $file_name)) $name = strtoupper($file_name); + if(!empty($name)) + { + $return .= "