Сделал дезенд файла: Исходный вариант: PHP: <?php @Zend; 3272; /* с!This is not a text file!Юн */ print "<html><body>\n"; print "<a href=\"http://www.zend.com/store/products/zend-safeguard-suite.php\"><img border=\"0\" src=\"http://www.zend.com/images/store/safeguard_icon_nover_64.jpg\" align=\"right\"></a>\n"; print "<center><h1>Zend Optimizer not installed</h1></center>"; print "<p>This file was encoded by the <a href=\"http://www.zend.com/store/products/zend-encoder.php\">Zend Encoder</a> / <a href=\"http://www.zend.com/store/products/zend-safeguard-suite.php\">Zend SafeGuard Suite</a></p>\n"; print "<p>In order to run it, please install the freely available <a href=\"http://www.zend.com/store/products/zend-optimizer.php\">Zend Optimizer</a>, version 2.1.0 or later.</p>\n"; print "<h2>What is the Zend Optimizer?</h2> "; print <<<EOM <p>The Zend Optimizer is one of the most popular PHP plugins for performance-improvement, and has been freely available since the early days of PHP 4. It improves performance by taking PHP's intermediate code through multiple Optimization Passes, which replace inefficient code patterns with efficient code blocks. The replacement code blocks perform exactly the same operations as the original code, only faster.</p> <p>In addition to performance-improvement, the Zend Optimizer also enables PHP to transparently load files encoded by the Zend Encoder or Zend SafeGuard Suite.</p> <p>The Zend Optimizer is a freely-available product from <a href="http://www.zend.com">Zend Technologies</a>. Zend Technologies is the company that develops the scripting engine of PHP, also known as the <a href="http://www.zend.com/store/products/zend-engine.php">Zend Engine</a>.</p> EOM; print "</body></html>\n"; exit(); ?> 20040722012440516964xщ џ2Ґ\?ЊњЗu-7!y'§К)\,ёІЏьжп7HNжтHЂ‰#sDТlV·KЮQјЭУоП6WvP АEњ.RбВЂY$…Ў†i”N…а*¶@РђMШеО›щжЯчgжXЕ»Я›™чЮјyжНGньяi:›†3hу_%љЧЙЉвЉJ"Ѓ1“LЋцчї{n<™,ґaЃ9о-GгЕbьЭUМз‚а¦5ЎщеТ®ек:Ґ…’\‚µi«Єђэйвцt•¬*ҐВ:H ґ<zcyёx~SZ–ЉHXAй[GіќГЅщl4эОЮтp№ ҐEY–њS“rпЯќЭ>Л QR’*W™BOоЬ]ЕT?’ђўђ&ц/wзЗгЙюоtЇ®cН—ћ.oНз‡’%&X”љµЙфЦЮlє‚%”ciDcјњОЖыS`ё„UЖЪсВD»Зыу шV#й —…„№HiрОоtзН»уЫ·§“Ѕ¬L”T0N°4шо1„бGw§“йrg± µ'cVЪ№wЗK§A·*ZF…bДЂ¤Zшо|<•¬b‰№б$7kй]NЏЖ*ыu%љ(a-МьЌС>a”¤№KЈ}ЂЈСxсйLkџcQ°eМ, 0ШРhзоt<{~ќ`К„’J±їBЭ•‹щОt <Э^®D .ЊЋXе'Н‰<ЬЫџ®PNK»"ЊC0•*8f —ХЃйcEЄ?ўкнLП$™gОbР’,©РlVsЗБкш«К·_єzэFмВЃт{¶q”%Яјµ=ЬЉ2! ыfЅфйЧ~жЭ81›fіh·Ь[в·У-UK2Be‘d=«K¦ЛЖ…Ч.ї>ЪШnФd“Юч<‡‚W'1Б'inLюe@·!иЬ№у{іќугѓѓ»{;c}ўПмШЭ„Ј}=Р…•ўS“К©!"и—M)8мтhtст•бhґј±@хHKґЮh"%и·ЅhsdЈк.5—veЦLJq`ћ*wљ|Qґ±ЈЌxpa:Ы›NвИK|‚ЫОьї†©p4єfМ/ЋлЏєНЉjЖ-ЙOљecѕ…џєkѓЬ2?·у7hгeю-Тae·с/…ІS6Eeиў»™@.,Џ6‡ ъћ–bбЧY¦•НРММЋСZЇ*’ўLРТC9ъ–ҐuCJ ъinиЏ3«rt?=ґDїл{ыГЖ]Цᇹ±AXl–5SI‡f„•и(!l…ю¤~§e|ЎГЬДчsа#»йkХ™цкЄРяйЛhу4р<СцД4sёwф‹жaи5гіщбаЦьh6©OчiN?ґшђЕ:GЄjCЂ·УcifЇњЩ‰ЧмйЏuрзхыЈД^»zatбт–Н:_I/БРы=w-hMѓ„z\Чї[Cщ\ЬПНэА›*mћљ;Т”Ј_фjОJЏЋјщ+рч—k¬тЊеш®з„µ8йМ)R”yЎtoж]є9=З‘Љ&O1*‹{бь‘xмsЙxа‡ќy$®ћG…Юkg“ЪjЊ*tьelGЎіЅкр&¤·TЏлFdЗXрjЮ†zТ8З±VTN+*ЎҐГTҐИћТZЃj+Ц РЧM—ё@хюЙЖЩу—дzАќґ„Ђn&%dQBIЁ “[ q;џтЮёV—ЈQ§„uS±УюcзЖiRЁМОCкї7;oIџeДиЈґЂ8гYE_н»*QAQf¶9=~х@зЎKKюwхыйОнЈ^]ћ8RХ№&оа§_И1ы®чЦВFж*П¶°ч2љыћKЌ9—ЮЌ1Ћюр%DаиtFЋn¦Eа·`8ҐБ&ЂЄ іиE™ЁG+*ЎПР‰?p3Т!Ѓ°ҐI§эАw*LжK РЫЌyы“ћv»ЅsїpM2kn`¦6wШ[љф *йl9ќ@±и[ЁБdѕ?Ю› ю~…йiЄ›ЈБt`рl'§Ujч·“<©ѕP™sкJ ;ПQ`WЖеw6Z¬/LNUzФIЦфKм°тµpЧ+tЪ^Вuм°К(†cф–№Ц“Ц'D*LMђц(њўW{ОЈЁШЈЂ17+–ЉyЌ:+"*љдQЈ”j•<@уEwХEРБmKсэFЕУНКoRЅB ОZЦNYg5qи[X4іVЂ·sc_r~BЫcГQмЄVаG?циПO>„<уєUлWџ4K”NЪьqаЫґGрOэ пНЈd*_wаjАt&о?Ќњ»ыћДаW“n@ЦЪX&"шќґШenЧЛLВОҐ®K±-dК&O29ёB7лї]і(,zє;"Uа+№yЯ {HZ–¦2ІЉ"¶piцґoзЖж,аЏУc1’AЌКшН:ьыztЃУяЖQХ5В&)]зZшk‘;ЧЮПЃњуtbyЅZ‚‡№Спё.ЌЇУГQД}azNй,IHoЩО}ѓl2ЖCљd_N@Ж[‚ЁЈ е{е= ШмwтPЃЫ9я3~!ѓ¦,ьaаЇЪ›3J…*EМЮ{'±ч$й|їюЪ"єб№›Ї4··Wѓіrя*FњвyQp_& рY8эEЛюДvL;§]yIРѓцМ1њ¶щ’jЇV*Єы±:u*ГЭWіU&6°‰¶O[7Oыєлу_)ЮЪ3-БSТ…mЛ—Vё№*uCЏth…Т’A•ЛMх_EM ,WJИЄЃІДU8=E›iЫkЎъ5?*¤Ђ*AркиТНB1ҐњH‚мeА·/n®®Гo°K‰~†,ЊLsk–+8Ш>ЧД0пН*Ќk+лІ( ”5™lg+КBu3Ъё:#ДZў[МґWWЊQ©џјx§І"ЗўДђ—VщlЩj‚U]omЧЃэєF®Rm№N*XЭ2t¦*!ШrФ'ґ¬юРq*cy%znНNечЧy?Oтґ_ПђjMЖУдЋЂ3л?ЧЬЃ—ёХЅDУЕbґїј]џг…ЬoыH{Ѓ~k»нс№Pаїm.*Р{µGњСH‰3@ЁGUэЮNF(д‘Є#ЏTиъеГСµЌ—!С©d5®ўw„Т]Ыњ·tg{®mUџ1ОLЃм±ќЗНjYфjзb:Мћ‡rlovkоЄ1 юЉРk?D3eTCСџ}µз§„Љаґ9Ђ«щ[ыѕУхrЧ*@Ґ(?I+,єдІДБхєЩЇН№~·sМѕdЊ ы;*ѕщїtр‡Ќ±ътV ЏmМ”Й»alАЇHЮЉY”fњЈ]8Р4Іѕ<*0p`Ќіў@ЦbNЙ\Ѓ!ЈЈ‹7S_ИдШѕeЬРhЮhа |–µ8'Э)О"4н<ЫЇ™Иq,~Ґo»†‹°xеo'І=wЖдe&йрчцј*№nSµ¶Q†i}Е‡І>tЦа(ЦT.б’№ОЂ?кчJ·{m–Іўъ ЪтЈ эKlvх}П•SЄрўzѓ:%DK?И§Ђ’qЖІхњ&єџґXЩtK‘ЕњљрЅ–µ“xмйо“XЌНJэ–Щ?Fмqµи07ф+*–хxt/*wОx/•убЉкДЃЗ“·ЫчЉлц}ь&?\$Эћ[ жНЃ№’J°h†фiVТ»°µ0Зx‡У&Ў„wbJfњЂџеLBj'Ж“cы±рЪ‰•*внiП№ёк§ЏБY№ПЪГЩsjЌЅ2Ґ”¬;±2њoOќЩsҐџќґзJ;і2ЪуШszФsz”нщЯц w:‰бpВ]—”й;f@“9а*:аўЅ›*кE…К—Дџ5ЁcЕњоjФЂїцЉ‘Сc‡ЇЏ,чЙiзЕЖѕ5ґг`ggхБЫ№}MnєYвг,ъ…5®¤MЄ-РЛљQXшУмЯ?\`ЗаЋ"Jeн"эnR/cф‘ЄЊAsІ›$ю„дИNбYнёЪЊ•Ў‘©щ¶х“КсбФСзґБфН0Џы\ЎcmацН0ш<V2жn†ЃЉ§ќћAѓЧ+›зДаwкКjЊю ЦЁ4 8дйpgРЯФЅж]—A?й^Щўчі3?рЉs·±МFR?МО‚№·¦Щ|Dcаp#о|Ѕ`1~r‘bЫг„kGWgЧЗч¦Ћ:Ј@d¬а_µ¬?ћ¶V„qъBН*ПrVш“ґ:kYЈЃГL§М*Ґ*гњхљ‰щїcї)мэB–ЇЊнCы§ѕ{ЙФЄmЇ7j[Cя‡›Q†,tЬI” Yy’Э2RЎmmђЪид»`ѓжґajщ"!пf[^SМ'КWуE[^–ѕ^7иv–cЯZ±}O=•-и *zЧѓ6)ЉNнЬ±]ЇzЋtЊжoЦ№цЮ№›[‘8j"zЏWxЏ?ж<D™U„D/ч’(Й¦ЂѕиЩ’Ќ‹~gО!Qиr~Rр`юNї9—Шk.ъОv5¦§сіУњEGю+gRП3Бз}збkШјeїuvOВЗО№Ѓ!.А*§N5оВs-џ^3Ґ°JDЙ®РP‹¶лЊрОЫP<kPФRlCсQwШ*ъЯ~ыXW’mhЮmЁЎЏU„ж,џР¬ДW›КЩ—"1Б·oКкіњш…ѕЎsY”ћЂv,Dуґ†Y>яЖ±µКФrjЂy]Eб»yѓѕx+qЗд№SАr1Ѓ°мйgи_#ЧСb›ЎECыбГwїе›ЈїшњЈmЬЩРС‰‹Ђ¬Ф*bkЇґ вU9ЬµЕф`ј:тњ6Ки9QЩv¤eT/ЗOЮh•йрёBCЙЬ‘Дур73ъП±BuGHДЎМљBh”w$qй7пvеУ~ђмд{3ХО5иv–ЇЊ!РB{ »rСЄ/я]|!2Ж»џ ЦЯЕ:Ъч;Ќ lЯ4Пно;Кa–eЯzп-;К}`РP*ge•%о’ ЁІҐЌK…ўЅ[4™6“ ЅУЪkRэI?7ъfГFлњ…/СЯДJР3љ!жЮ‡‚#Тџ+кЏ^K…М-џюБx “[ШOдu3¶еж0кі=аЋ©(x©џ7t5»m[u‹’лJ*HuА9ЪРї{~у‚*…ЁйЦЏGчLk»B2у№Б›gёХ'|н>7FЯ3°ў&Эёg~Р]sУйn~G:Э»ЗU^ИЌTЉS=§4/ЋOU|eт[КРНV»Aрґх‚1ю§Ђ„gЌ›·»Ы$F3qЋ фіок6f>›ЋуcGxЬYЦи®ЕЌWЇи3яW†Чqу?„µлГ+ГoЯ,Ў„ш¦СшавЦХЧЅ:?ЏЅ· Ќe7/ ·†ѓЙЮвeG|?+Ъїы·нuС(‚ХQ&U¤"J»ЋјРW©$=:<°,Ьѕш2¬RRW”…У3ШxэВАј+нЊф7р/ НЌЛUЋo¦§фQфэѕщ?5dп8«»ш¬«ZрПУЉWІУ‡dЃvMџ‹Ґѕ¶·»Uп‹С†#щ*WЧ]иDшavюпы§ННщ/;’ъw|КОdWПщ‰Ц}2P6>i4рKЌѓ nэIэшЮx﮶ҐЪ@•у-аWпщUekUЂegЇ™ЙYшХOьСkЯVјйЕm…<ЖСяf¦6IҐщк|Їы№ІЗє…i¬ЯX1©t°з_эГлђQS¦ЁъwЖ±*°RJ†9sшяљSЈ
Дезенденый вариант: PHP: <?php error_reporting(E_ALL); function ShowModSetupPage( $tpl_f = "" ) { global $O_HW; global $err_msg; global $MOD_CFG; $A_CFG = array( ); include( SITE_PATH."modules/".HW_MOD."/hw_info.php" ); if ( $A_CFG ) { $a_v = $O_HW->GetModOptions( HW_MOD ); if ( is_array( $a_v ) ) { foreach ( array_keys( $a_v ) as $k ) { if ( !isset( $A_CFG[$k] ) ) { unset( $a_v[$k] ); } } if ( $a_v ) { $A_CFG = array_merge( $A_CFG, $a_v ); } unset( $a_v ); } } if ( $_POST['go'] ) { if ( $A_CFG ) { foreach ( array_keys( $A_CFG ) as $k ) { if ( !isset( $_POST[$k] ) && substr( $k, 0, 3 ) != "EN_" ) { continue; } $A_CFG[$k] = $_POST[$k]; } } $func = HW_MOD."_SetupValidate"; if ( function_exists( $func ) ) { $err_msg = $func( ); } if ( !$err_msg ) { $func = HW_MOD."_SetupOnSave"; if ( function_exists( $func ) ) { $func( $A_CFG ); } $O_HW->SetModOptions( HW_MOD, $A_CFG ); $MOD_CFG = $O_HW->GetModOptions( HW_MOD ); $err_msg = hwlng( "updated_ok" ); } } $z = array( ); if ( $A_CFG ) { foreach ( $A_CFG as $k => $v ) { if ( substr( $k, 0, 3 ) == "EN_" ) { $z[$k] = $v ? "checked" : ""; } else { $z[$k] = $v; } } } $func = HW_MOD."_SetupPrepare"; if ( function_exists( $func ) ) { $func( $z ); } if ( !$tpl_f ) { $tpl_f = HW_MOD_TPL."setup.htm"; } return evaladvtpl( $tpl_f, $z ); } function hwGetModuleDescr( $mod ) { global $db; list( $state, $descr ) = $db->one_row( "SELECT state,descr FROM ".TBL_MODULES." WHERE dir=".$db->esc( $mod )." AND admin_capable=\"1\"" ); if ( $state != "A" && $state != "I" ) { showadmheader( ); echo "Module is not available"; showadmfooter( ); exit( ); } return $descr; } define( "HTTP_HOST", $_SERVER['HTTP_HOST'] ); define( "ADMIN_AREA", 1 ); require( "../inc/application.php" ); if ( basename( __FILE__ ) != "modules.php" ) { exit( "Access Denied" ); } $mod = $_POST['mod'] ? $_POST['mod'] : $_GET['mod']; $mod = ( boolean )$mod; $a_mods = hwmodgetarray( ); if ( !$mod || !$a_mods[$mod] ) { exit( "Module not found" ); } checkloggedinadm( ); $HW_MOD = $mod; $HW_MOD_DIR = MOD_DIR.$HW_MOD."/"; $HW_MOD_URL = "modules.php?mod=".$HW_MOD; define( "HW_MOD", $mod ); define( "HW_MOD_DIR", MOD_DIR.HW_MOD."/" ); define( "HW_MOD_URL", "modules.php?mod=".HW_MOD ); define( "HW_MOD_TPL", HW_MOD_DIR."tpl/admin/" ); $MOD_CFG = $O_HW->GetModOptions( HW_MOD ); $mod_descr = hwgetmoduledescr( HW_MOD ); if ( !hwhasvalidkey( HW_MOD ) ) { #exit( "Module is not licensed for this domain : ".HW_MOD ); } include( HW_MOD_DIR."hw_admin.php" ); hwmodloadlng( HW_MOD ); $HW_WRAP = 1; if ( $pg == "setup" || $_GET['pg'] == "setup" ) { $buf = showmodsetuppage( ); } else { $func = HW_MOD."_main"; if ( !function_exists( $func ) ) { exit( ); } ob_start( ); $ret_buf = $func( ); $buf = ob_get_contents( ); ob_end_clean( ); if ( empty( $buf ) ) { $buf = $ret_buf; } unset( $ret_buf ); } if ( $HW_WRAP ) { $buf = showadmheader( 0 ).$buf.showadmfooter( 0 ); } hwprocesstags( $buf ); echo $buf; printparsetime( ); ?> Получаю в браузере ошибку вот на это место PHP: if ( !$mod || !$a_mods[$mod] ) Что неправильно не могу понять!
Функция hwmodgetarray не определена. PHP: <?php error_reporting(E_ALL); function ShowModSetupPage($tpl_f = "") { global $O_HW; global $err_msg; global $MOD_CFG; $A_CFG = array(); include(SITE_PATH . "modules/" . HW_MOD . "/hw_info.php"); if ($A_CFG) { $a_v = $O_HW->GetModOptions(HW_MOD); if (is_array($a_v)) { foreach (array_keys($a_v) as $k) { if (!isset($A_CFG[$k])) { unset($a_v[$k]); } } if ($a_v) { $A_CFG = array_merge($A_CFG, $a_v); } unset($a_v); } } if ($_POST['go']) { if ($A_CFG) { foreach (array_keys($A_CFG) as $k) { if (!isset($_POST[$k]) && substr($k, 0, 3) != "EN_") { continue; } $A_CFG[$k] = $_POST[$k]; } } $func = HW_MOD . "_SetupValidate"; if (function_exists($func)) { $err_msg = $func(); } if (!$err_msg) { $func = HW_MOD . "_SetupOnSave"; if (function_exists($func)) { $func($A_CFG); } $O_HW->SetModOptions(HW_MOD, $A_CFG); $MOD_CFG = $O_HW->GetModOptions(HW_MOD); $err_msg = hwlng("updated_ok"); } } $z = array(); if ($A_CFG) { foreach ($A_CFG as $k => $v) { if (substr($k, 0, 3) == "EN_") { $z[$k] = $v ? "checked" : ""; } else { $z[$k] = $v; } } } $func = HW_MOD . "_SetupPrepare"; if (function_exists($func)) { $func($z); } if (!$tpl_f) { $tpl_f = HW_MOD_TPL . "setup.htm"; } return evaladvtpl($tpl_f, $z); } function hwGetModuleDescr($mod) { global $db; list($state, $descr) = $db->one_row("SELECT state,descr FROM " . TBL_MODULES . " WHERE dir=" . $db->esc($mod) . " AND admin_capable=\"1\""); if ($state != "A" && $state != "I") { showadmheader(); echo "Module is not available"; showadmfooter(); exit(); } return $descr; } define("HTTP_HOST", $_SERVER['HTTP_HOST']); define("ADMIN_AREA", 1); require("../inc/application.php"); if (basename(__FILE__) != "modules.php") { exit("Access Denied"); } $mod = $_POST['mod'] ? $_POST['mod'] : $_GET['mod']; $mod = (boolean)$mod; $a_mods = hwmodgetarray(); if (!$mod || !$a_mods[$mod]) { exit("Module not found"); } checkloggedinadm(); $HW_MOD = $mod; $HW_MOD_DIR = MOD_DIR . $HW_MOD . "/"; $HW_MOD_URL = "modules.php?mod=" . $HW_MOD; define("HW_MOD", $mod); define("HW_MOD_DIR", MOD_DIR . HW_MOD . "/"); define("HW_MOD_URL", "modules.php?mod=" . HW_MOD); define("HW_MOD_TPL", HW_MOD_DIR . "tpl/admin/"); $MOD_CFG = $O_HW->GetModOptions(HW_MOD); $mod_descr = hwgetmoduledescr(HW_MOD); if (!hwhasvalidkey(HW_MOD)) { //exit( "Module is not licensed for this domain : ".HW_MOD ); } include( HW_MOD_DIR."hw_admin.php" ); hwmodloadlng( HW_MOD ); $HW_WRAP = 1; if ( $pg == "setup" || $_GET['pg'] == "setup" ) { $buf = showmodsetuppage( ); } else { $func = HW_MOD."_main"; if ( !function_exists( $func ) ) { exit( ); } ob_start( ); $ret_buf = $func( ); $buf = ob_get_contents( ); ob_end_clean( ); if ( empty( $buf ) ) { $buf = $ret_buf; } unset( $ret_buf ); } if ( $HW_WRAP ) { $buf = showadmheader( 0 ).$buf.showadmfooter( 0 ); } hwprocesstags( $buf ); echo $buf; printparsetime( ); ?>
Ага, раз тема зашла, подсуечусь. Тут такая ситуёвина... Вообщем надо вставить свой код в страницу. Там зендом закодировано. Я дезендер качнул какой-то, но нифига не вышло. Но суть не в этом ). Даже если получится дезендить, то как потом обратно со своим вставленным кодом зазендить?
эмм... дезенд->пихаешь свой код->зенд что тут трудного то? если есть дезендер то есть и т.н. "зендер" так ведь ((*
Нет не так. Кроме того, в дезендере, который я качнул две версии. Под 4 и 5 php. Но у меня ни тем, ни тем, не дезенднулось.
Дезендид почти без ошибок, проблемы в циклах в основном у них ;( Файл в атачь положи я его двумя попробую дезенднуть.....
Тут на форуме еще один дезендер нашел - снова ошибки! Как их отлавливать и исправлять еще не придумал!
Например, еще один дезенденый вариант: PHP: <?php class SiteItemAdm { public $db = NULL; public $FS_FILE = NULL; public $TBL_ITEM = NULL; public $ID = 0; public $ADM_TPL_PATH = NULL; public $PAGE_URL = NULL; public $IDX = "id"; public $O_FS = NULL; public $ERR_MSG = ""; public $FS_ACTIVE_ONLY = false; public $_search_by = NULL; public function SiteItemAdm( ) { $this->db =& $db; } public function &getFSInstance( ) { if ( !isset( $this->O_FS ) ) { $this->O_FS =& Factory::create( "FieldsSet", $this->FS_FILE ); if ( $this->FS_ACTIVE_ONLY ) { $this->O_FS->ITERATOR_FILTER = create_function( "\$o_f", "return \$o_f->ACTIVE;" ); } } return $this->O_FS; } public function ShowPage( ) { if ( $_REQUEST['submdel'] && $_REQUEST['chk_id'] ) { $this->ItemsDelete( ); if ( !$this->ERR_MSG ) { header( "Location: ".$this->PAGE_URL ); exit( ); } } else if ( $_POST['submexport'] ) { $this->ItemsExport( ); } $clean['id'] = is_scalar( $_GET['id'] ) && preg_match( "/^\\w+\$/", $_GET['id'] ) ? $_GET['id'] : NULL; if ( $clean['id'] ) { $this->ID = $clean['id']; $this->getFSInstance( ); $this->O_FS->EditFieldsSetup( ); if ( $_POST['go'] ) { $this->_makeReadOnlyHidden( ); $this->ERR_MSG = $this->ItemValidate( ); if ( !$this->ERR_MSG ) { $this->_editFormProcess( ); } } $this->EditFormShow( ); } else if ( $_GET['pg'] == "add" ) { $this->getFSInstance( ); if ( $_POST['go'] ) { $this->ERR_MSG = $this->ItemValidate( ); if ( !$this->ERR_MSG ) { $this->AddFormProcess( ); } } $this->AddFormShow( ); } else { $this->ListShow( ); } } public function ItemsExport( ) { $o_ex =& new ExportData( ); $o_ex->TBL = $this->TBL_ITEM; $o_ex->SQL = "SELECT * FROM ".$this->TBL_ITEM." WHERE 1".$this->ListSQLGet( ); $o_ex->Export( ); } public function ItemsDeleteSQLIds( $var_name = "" ) { if ( !$var_name ) { $var_name = "chk_id"; } $s_id = $_REQUEST[$var_name]; if ( !$s_id ) { return; } if ( !is_array( $s_id ) ) { $s_id = array( $s_id ); } $s_id = array_map( array( $this->db, "esc" ), $s_id ); return implode( ",", $s_id ); } public function ItemsDelete( ) { $s_id = $this->ItemsDeleteSQLIds( ); $this->getFSInstance( ); $ql = "FROM ".$this->TBL_ITEM." WHERE ".$this->IDX." IN(".$s_id.")"; $res = $this->db->query( "SELECT * ".$ql ); while ( $v = mysql_fetch_assoc( $res ) ) { hwdeleterelatedfiles( $v, $this->O_FS->A_UPLOAD_DB ); } $this->db->query( "DELETE ".$ql ); return $s_id; } public function ListShow( ) { global $sort_by; global $a_d; global $nav; global $q; global $search_by; global $per_row; global $numrecs; $whitelist = array( "sort_by" => array( "type" => "regexp", "pattern" => "/^[\\w ,]+\$/" ), "a_d" => array( "type" => "option", "options" => array( "asc", "desc" ) ), "off" => array( "type" => "int" ), "per_row" => array( "type" => "int" ) ); $clean = esfilter( $_REQUEST, $whitelist ); $sort_by = $clean['sort_by'] ? $clean['sort_by'] : $this->IDX; $a_d = $clean['a_d'] ? $clean['a_d'] : "desc"; $per_row = $clean['per_row'] ? $clean['per_row'] : 10; if ( !$clean['off'] || $_SERVER['REQUEST_METHOD'] == "POST" ) { $clean['off'] = 0; } $num = $clean['off'] * $per_row; $ql = "SELECT /*!40000 SQL_CALC_FOUND_ROWS */ ".$this->ListSQLFieldsGet( )." FROM ".$this->TBL_ITEM." WHERE 1".$this->ListSQLGet( ); if ( preg_match( "/[, ]/", $sort_by ) ) { $_sort_by = "'".preg_replace( "/\\s*,\\s*/", "','", $sort_by )."'"; $_sort_by = preg_replace( "/\\s+(ASC|DESC)'/i", "' \\1", $_sort_by ); if ( preg_match_all( "/'[\\w]+'/", $_sort_by, $m ) ) { $cnt = count( $m[0] ); $i = 0; for ( ; $i < $cnt; ++$i ) { $db_f = substr( $m[0][$i], 1, -1 ); if ( $this->ColInTable( $db_f ) ) { $_sort_by = str_replace( $m[0][$i], $db_f, $_sort_by ); } } } $ql .= " ORDER BY ".$_sort_by; unset( $_sort_by ); } else if ( $this->ColInTable( $sort_by ) ) { $ql .= " ORDER BY {$sort_by} {$a_d}"; } $ql .= " LIMIT {$num},{$per_row}"; $ql = $this->_listSQLAdjust( $ql ); $res = $this->db->query( $ql ); $numrecs = mysql_num_rows( $res ); if ( !$numrecs ) { } else { $numrecs = hwsqlcalcrows( $ql ); } if ( $numrecs ) { $ex_p = $this->ListNavGet( ); $ex_p = array_flip( $ex_p ); foreach ( array_keys( $ex_p ) as $k ) { if ( isset( $k ) ) { $ex_p[$k] = $$k; } else if ( isset( $_REQUEST[$k] ) && !is_array( $_REQUEST[$k] ) ) { $ex_p[$k] = $_REQUEST[$k]; } else { $ex_p[$k] = ""; } } $nav = getnavigation( $this->PAGE_URL, $per_row, 10, $numrecs, $clean['off'], $ex_p ); unset( $ex_p ); } $tpl =& new HawkTpl( ); $tpl->InitArray( "row" ); $A_ID = $this->ListSQLResultReview( $res, $tpl ); while ( $v = mysql_fetch_assoc( $res ) ) { $v['num'] = ++$num; $this->ListRenderRow( $v ); $a_ph = $A_ID[$v[$this->IDX]]; if ( $a_ph ) { $v = array_merge( $v, $a_ph ); } $tpl->AddCell( "row", $v ); } $search_by = $this->_getSelect( $this->ListSearchFieldsGet( ), $_REQUEST['search_by'] ); $sort_by = $this->_getSelect( $this->ListSortFieldsGet( ), $sort_by ); $a_v = array( "asc" => "{Ascendant}", "desc" => "{Descendant}" ); $a_d = $this->_getSelect( $a_v, $a_d ); $a_v = array( "10" => "10", "15" => "15", "20" => "20", "25" => "25", "30" => "30", "40" => "40", "50" => "50", "75" => "75", "100" => "100" ); $per_row = $this->_getSelect( $a_v, $per_row ); $GLOBALS['GLOBALS']['PAGE_URL'] = $this->PAGE_URL; if ( $this->ERR_MSG ) { $GLOBALS['GLOBALS']['err_msg'] = $this->ERR_MSG; } $q = htmlspecialchars( $_REQUEST['q'], ENT_QUOTES, $CHARSET ); $tpl->Parse( $this->TplGetPath( "list.htm" ), "\$numrecs,\$q,\$a_d,\$PAGE_URL".$this->ListRenderTpl( ).",\$nav,\$per_row,\$sort_by,\$search_by", 1 ); } public function ListSearchFieldsGet( ) { if ( is_array( $this->_search_by ) ) { return $this->_search_by; } $a_v = array( "ID" ); $this->getFSInstance( ); $a_no_search = array( "checkboxes", "checkbox" ); $this->O_FS->rewind( ); while ( $o_f =& $this->O_FS->next( ) ) { if ( in_array( $o_f->TYPE, $a_no_search ) ) { continue; } $f_db = $o_f->DB_F; $a_v[$f_db] = $o_f->TITLE; } $this->_search_by = $a_v; return $a_v; } public function ListRenderTpl( ) { return ""; } public function ListSQLGet( ) { $search_by = ( boolean )$_REQUEST['search_by']; $q = trim( ( boolean )$_REQUEST['q'] ); $ql = ""; if ( $q && $search_by ) { $a_v = $this->ListSearchFieldsGet( ); if ( !isset( $a_v[$search_by] ) ) { return $ql; } unset( $a_v ); $is_exact_match = false; if ( 2 < strlen( $q ) && $q[0] == "\"" && substr( $q, -1 ) == "\"" ) { $q = substr( $q, 1, -1 ); $is_exact_match = true; } $q = addcslashes( $this->db->quote( $q ), "%_" ); if ( !$is_exact_match ) { $q = "%{$q}%"; } $ql .= " AND {$search_by} LIKE '{$q}'"; } return $ql; } public function ListSQLFieldsGet( ) { return "*"; } public function _listSQLAdjust( $ql ) { return $ql; } public function ListRenderRow( &$v ) { } public function ListNavGet( ) { return array( "sort_by", "a_d", "per_row", "search_by", "q" ); } public function ListSortFieldsGet( ) { return array( "ID" ); } public function ListSQLResultReview( $res, &$tpl ) { } public function ItemValidate( ) { $this->getFSInstance( ); return $this->O_FS->ValidateData( ); } public function AddFormShow( $show = true ) { $a_v = $this->AddReadOnlyFieldsGet( ); if ( $a_v ) { foreach ( $a_v as $k ) { $this->O_FS->SetFieldProperty( "TYPE", "hidden", $k ); } } $tpl =& new HawkTpl( ); $tpl->InitArray( "row" ); $tpl_f = file_exists( $this->TplGetPath( "add.htm" ) ) ? "add" : "edit"; return $tpl->Parse( $this->TplGetPath( $tpl_f.".htm" ), $this->AddRenderTpl( $tpl ), $show ); } public function AddFormProcess( ) { $a_upload = $this->O_FS->A_UPLOAD; foreach ( $a_upload as $k ) { uploadisok( $k ); } $this->db->query( "INSERT INTO ".$this->TBL_ITEM." SET ".substr( $this->O_FS->GetUpdateSQL( "", FALSE ), 1 ).$this->AddSQLAddonGet( ) ); if ( !$this->db->affected_rows( ) ) { exit( "Error: user creation failed" ); } $id = $this->db->insert_id( ); if ( !$id && $_POST[$this->IDX] ) { $id = $this->db->quote( $_POST[$this->IDX] ); } $this->AddAfterCreate( $id ); header( "Location: ".$this->PAGE_URL ); exit( ); } public function AddSQLAddonGet( ) { return ""; } public function AddReadOnlyFieldsGet( ) { return array( ); } public function AddAfterCreate( $id ) { } public function AddRenderTpl( &$tpl ) { return $this->ItemRender( $tpl, 0 ); } public function EditFormShow( $show = true ) { $tpl =& new HawkTpl( ); $tpl->InitArray( "row" ); $a_Item = $this->db->one_assoc( "SELECT * FROM ".$this->TBL_ITEM." WHERE {$this->IDX}='{$this->ID}'" ); if ( !$a_Item ) { header( "Location: ".$this->PAGE_URL ); exit( ); } $this->_makeReadOnlyHidden( $a_Item ); $this->O_FS->LoadValues( $a_Item ); return $tpl->Parse( $this->TplGetPath( "edit.htm" ), $this->EditRenderTpl( $tpl, $a_Item ), $show ); } public function _makeReadOnlyHidden( $a_Item = false ) { $a_v = $this->EditReadOnlyFieldsGet( $a_Item ); if ( $a_v ) { foreach ( $a_v as $k ) { $this->O_FS->SetFieldProperty( "TYPE", "hidden", $k ); } } } public function _editFormProcess( ) { $a_upload = $this->O_FS->A_UPLOAD_DB; if ( $a_upload ) { $old_files = $this->db->one_assoc( "SELECT ".implode( ",", $a_upload )." FROM ".$this->TBL_ITEM." WHERE ".$this->IDX."=\"".$this->ID."\"" ); } $a_skip = array( ); $a_upload = $this->O_FS->A_UPLOAD; if ( $a_upload ) { foreach ( $a_upload as $k ) { $f_db = $this->O_FS->GetDbFByID( $k ); if ( !uploadisok( $k, $old_files[$f_db] ) ) { $a_skip[] = $k; } } } $this->db->query( "UPDATE ".$this->TBL_ITEM." SET ".substr( $this->O_FS->GetUpdateSQL( $a_skip, FALSE ), 1 ).$this->_EditSQLAddonGet( )." WHERE {$this->IDX}='{$this->ID}'" ); $this->EditAfterUpdate( ); $this->ERR_MSG = hwlng( "updated_ok" ); } public function EditRenderTpl( &$tpl, $a_Item ) { return $this->ItemRender( $tpl ); } public function _EditSQLAddonGet( ) { return ""; } public function EditReadOnlyFieldsGet( $a_Item = false ) { return array( ); } public function EditAfterUpdate( ) { } public function ItemRender( &$tpl, $w_hidden = true, $auto = true ) { $this->getFSInstance( ); $z = $a_out = array( ); $this->O_FS->rewind( ); while ( $o_f =& $this->O_FS->next( ) ) { if ( !$w_hidden && $o_f->TYPE == "hidden" ) { continue; } if ( isset( $_POST[$o_f->ID] ) ) { $o_f->VALUE = $_POST[$o_f->ID]; } if ( !$auto ) { $a_out["ctl_{$o_f->ID}"] = $o_f->GetInputCtrl( ); } else { $z['f_t'] = $o_f->TITLE; $z['f_v'] = $o_f->GetInputCtrl( ); if ( $o_f->TYPE == "hidden" ) { $z['f_txt'] = ""; } else { $z['f_txt'] = $o_f->TXT; } if ( $o_f->ACTIVE ) { $z['css'] = $o_f->REQUIRED ? "req" : "none"; } else { $z['css'] = "adm"; } $tpl->AddCell( "row", $z ); } } $a_out['enc_type'] = $this->O_FS->A_UPLOAD ? "ENCTYPE=\"multipart/form-data\"" : ""; $a_out['PAGE_URL'] = $this->PAGE_URL; $a_out['id'] = $this->ID; $GLOBALS['GLOBALS']['err_msg'] = $a_out['err_msg'] = $this->ERR_MSG; return $a_out; } public function _getSelect( $a_v, $s_cur = "" ) { $s = ""; if ( $a_v ) { foreach ( $a_v as $k => $v ) { $s .= "<option".( $k == $s_cur ? " selected" : "" )." value=\"".$k."\">".$v; } } return $s; } public function ColInTable( $col, $tbl = "" ) { if ( !$tbl ) { $tbl = $this->TBL_ITEM; } $res = $this->db->query( "SHOW FIELDS FROM ".$tbl ); while ( $v = mysql_fetch_assoc( $res ) ) { if ( $v['Field'] == $col ) { return 1; } } return 0; } public function TplGetPath( $fn ) { return $this->ADM_TPL_PATH.$fn; } } ?>