3v4l.org

run code in 300+ PHP versions simultaneously
<?php // обеспечение включение файла включен в родительский файл defined('_VALID_MOS') or die('Direct Access to this location is not allowed.'); // обеспечение пользователя доступом к этой функции if (!($acl->acl_check('administration', 'edit', 'users', $my->usertype, 'components', 'all') || $acl->acl_check('administration', 'edit', 'users', $my->usertype, 'components', 'com_dailymessage'))) { mosRedirect('index2.php', _NOT_AUTH); } require_once($mainframe->getPath('admin_html')); mosCommonHTML::loadOverlib(); HTML_catalog::Stylesheet(); global $database; function ExchangeItems($itemtype, $idname, $itemid,$itemid1) { global $database, $mainframe; $database->setQuery("SELECT prio FROM #__".$itemtype." WHERE ".$idname." = ".$itemid); $result = $database->loadObjectList(); $prio = $result[0]->prio; $database->setQuery("SELECT prio FROM #__".$itemtype." WHERE ".$idname." = ".$itemid1); $result = $database->loadObjectList(); $prio1 = $result[0]->prio; $database->doSQL("UPDATE #__".$itemtype." SET prio=".$prio1." WHERE ".$idname." =".$itemid); $database->doSQL("UPDATE #__".$itemtype." SET prio=".$prio." WHERE ".$idname." =".$itemid1); } function ISNULL($var) { if (empty($var)) return 0; else return $var; } function DelTree($id) { global $database; $database->setQuery ('SELECT * from #__catalog where parentid='.$id); $result=$database->loadObjectList(); if (sizeof($result)) foreach ($result as $row) DelTree($row->id); $database->setQuery('SELECT * from #__items where sectionid='.$id); $result=$database->loadObjectList(); if (sizeof($result)) foreach ($result as $row) { $database->doSQL('DELETE from #__itemdetails where itemid = '.$row->itemid); $database->doSQL('DELETE from #__items where itemid='.$row->itemid); } $database->doSQL('DELETE from #__catalog where id='.$id); } switch($act) { case 'managecatalog': { switch ($task) { case 'move': ExchangeItems($itemtype,$idname,$itemid,$itemid1); break; case 'delete': switch ($itemtype) { case 'catalog': DelTree($itemid); break; case 'item': $database->doSQL('DELETE from #__itemdetails where itemid = '.$itemid); $database->doSQL('DELETE from #__items where itemid='.$itemid); break; case 'itemdetail': $database->doSQL('DELETE from #__itemdetails where id='.$itemdetailsid); mosRedirect('index2.php?option='.$option.'&act='.$act.'&itemid='.$itemid.'&parentid='.$parentid.'&task=edit&itemtype=item'); break; } break; case 'edit': switch ($itemtype) { case 'item': switch ($task2) { case 'move': ExchangeItems('itemdetails','id',$moveid,$moveid1); break; default: break; } HTML_catalog::DrawPath($parentid); $database->setQuery("SELECT #__items.itemid as itemid, #__itemdetails.id as itemdetailsid, naim, img, foto, drawing, shema, description, article, pricefor, code, size, color, price1, price2, price3, price4, price5 from #__items left join #__itemdetails on #__items.itemid=#__itemdetails.itemid where #__items.itemid=".$itemid." ORDER by #__itemdetails.prio"); $result=$database->loadObjectList(); HTML_catalog::ShowItemEditForm($result, 'edit'); break; case 'catalog': HTML_catalog::DrawPath($parentid); $database->setQuery("SELECT * from #__catalog where id=".$catalogid); $result=$database->loadObjectList(); HTML_catalog::ShowCatalogEditForm($result, 'edit'); break; } break; case 'new': switch ($itemtype) { case 'catalog': HTML_catalog::DrawPath($parentid); HTML_catalog::ShowCatalogEditForm(null, 'new'); break; case 'item': HTML_catalog::DrawPath($parentid); HTML_catalog::ShowItemEditForm(null, 'new'); break; case 'itemdetail': $database->setQuery('SELECT * from #__items where itemid='.$itemid); $result=$database->loadObjectList(); $itemname=$result[0]->naim; HTML_catalog::DrawPath($parentid,'','/<a href="index2.php?option=com_catalog&act=managecatalog&task=edit&itemtype=item&parentid='.$parentid.'&itemid='.$itemid.'">'.$itemname.'</a>'); HTML_catalog::ShowItemdetailEditForm('new'); break; } break; case 'save': switch ($itemtype) { case 'item': $vars = get_defined_vars(); $deleteimg = 'Не использовать изображение'; $itemimgfile =''; if ((isset($HTTP_POST_FILES['itemimg']['name']))&&(!empty($HTTP_POST_FILES['itemimg']['name']))) { copy($HTTP_POST_FILES['itemimg']['tmp_name'],"./../UserFiles/Image/catalog/".basename($HTTP_POST_FILES['itemimg']['name'])); $itemimgfile = "./UserFiles/Image/catalog/".basename($HTTP_POST_FILES['itemimg']['name']); } else if ($selectimg != $deleteimg) $itemimgfile = "./UserFiles/Image/catalog/".$selectimg; $itemfotofile=''; if ((isset($HTTP_POST_FILES['itemfoto']['name']))&&(!empty($HTTP_POST_FILES['itemfoto']['name']))) { copy($HTTP_POST_FILES['itemfoto']['tmp_name'],"./../UserFiles/Image/catalog/".basename($HTTP_POST_FILES['itemfoto']['name'])); $itemfotofile = "./UserFiles/Image/catalog/".basename($HTTP_POST_FILES['itemfoto']['name']); } else if ($selectfoto != $deleteimg) $itemfotofile = "./UserFiles/Image/catalog/".$selectfoto; $itemdrawingfile =''; if ((isset($HTTP_POST_FILES['itemdrawing']['name']))&&(!empty($HTTP_POST_FILES['itemdrawing']['name']))) { copy($HTTP_POST_FILES['itemdrawing']['tmp_name'],"./../UserFiles/Image/catalog/".basename($HTTP_POST_FILES['itemdrawing']['name'])); $itemdrawingfile = "./UserFiles/Image/catalog/".basename($HTTP_POST_FILES['itemdrawing']['name']); } else if ($selectdrawing != $deleteimg) $itemdrawingfile = "./UserFiles/Image/catalog/".$selectdrawing; $itemshemafile=''; if ((isset($HTTP_POST_FILES['itemshema']['name']))&&(!empty($HTTP_POST_FILES['itemshema']['name']))) { copy($HTTP_POST_FILES['itemshema']['tmp_name'],"./../UserFiles/Image/catalog/".basename($HTTP_POST_FILES['itemshema']['name'])); $itemshemafile = "./UserFiles/Image/catalog/".basename($HTTP_POST_FILES['itemshema']['name']); } else if ($selectshema != $deleteimg) $itemshemafile = "./UserFiles/Image/catalog/".$selectshema; switch ($savetype) { case 'new': $database->setQuery('SELECT MAX(itemid)+1 as itemid from #__items'); $result=$database->loadObjectList(); $itemid=$result[0]->itemid; $database->setQuery('SELECT MAX(prio)+1 as prio from #__items'); $result=$database->loadObjectList(); $prio=$result[0]->prio; $sqlquery='INSERT into #__items (itemid, prio, sectionid, naim, img, foto, drawing, shema, description, article, pricefor) VALUES ('. $itemid.','.$prio.','.$parentid.',"'.addslashes($itemname).'","'.addslashes($itemimgfile).'","'.addslashes($itemfotofile).'","'. addslashes($itemdrawingfile).'","'.addslashes($itemshemafile).'","'.addslashes($itemdescript).'","'.addslashes($itemarticle).'","'.addslashes($itempricefor).'")'; $database->doSQL($sqlquery); echo 'Элемент успешно добавлен'; break; case 'edit': if ($itemdetailscount) for ($i=0; $i<$itemdetailscount; $i++) $database->doSQL('UPDATE #__itemdetails SET code='.ISNULL($vars['itemcode'.$i]).', size="'.addslashes($vars['itemsize'.$i]).'", color="'.addslashes($vars['itemcolor'.$i]).'", price1='.str_replace(',','.',ISNULL($vars['itemprice1'.$i])).', price2='.str_replace(',','.',ISNULL($vars['itemprice2'.$i])).', price3='.str_replace(',','.',ISNULL($vars['itemprice3'.$i])).', price4='.str_replace(',','.',ISNULL($vars['itemprice4'.$i]))./*', price5='.str_replace(',','.',ISNULL($vars['itemprice5'.$i])).*/' WHERE id = '.$vars['itemdetailsid'.$i]); $sqlquery = 'UPDATE #__items SET naim="'.addslashes($itemname).'", description="'.addslashes($itemdescript).'", article="'.addslashes($itemarticle). '", pricefor="'.addslashes($itempricefor).'", img="'.$itemimgfile.'", foto="'.$itemfotofile.'", drawing="'.$itemdrawingfile.'", shema="'.$itemshemafile.'" WHERE itemid='.$itemid; $database->doSQL($sqlquery); echo 'Элемент успешно обновлен<br>'; break; } break; case 'catalog': //if (empty($deleteimg)) $deleteimg = 'Не использовать изображение'; $catalogimgfile=''; if ((isset($HTTP_POST_FILES['catalogimg']['name']))&&(!empty($HTTP_POST_FILES['catalogimg']['name']))) { copy($HTTP_POST_FILES['catalogimg']['tmp_name'],"./../UserFiles/Image/catalog/".basename($HTTP_POST_FILES['catalogimg']['name'])); $catalogimgfile = "./UserFiles/Image/catalog/".basename($HTTP_POST_FILES['catalogimg']['name']); } else if ($selectimg != $deleteimg) $catalogimgfile = "./UserFiles/Image/catalog/".$selectimg; switch ($savetype) { case 'new': $database->setQuery('SELECT MAX(id)+1 as id from #__catalog'); $result=$database->loadObjectList(); $catalogid=$result[0]->id; $database->setQuery('SELECT MAX(prio)+1 as prio from #__catalog'); $result=$database->loadObjectList(); $prio=$result[0]->prio; $sqlquery='INSERT into #__catalog (id, prio, siteid, parentid, caption, img, article, article1, checked_out, checked_out_time, published) VALUES ('. $catalogid.','.$prio.',"",'.$parentid.',"'.addslashes($catalogcaption).'","'.addslashes($catalogimgfile).'","'.addslashes($catalogarticle).'","'. addslashes($catalogarticle1).'", 0, "00000000", '.(int)(!empty($catalogpublished)).')'; $database->doSQL($sqlquery); echo 'Элемент успешно добавлен'; break; case 'edit': $sqlquery = 'UPDATE #__catalog SET caption="'.addslashes($catalogcaption).'", article="'.addslashes($catalogarticle). '", article1="'.addslashes($catalogarticle1).'", published='.(int)(!empty($catalogpublished)).', img="'.$catalogimgfile.'" WHERE id='.$catalogid; $database->doSQL($sqlquery); echo 'Элемент успешно обновлен<br>'; break; } break; case 'itemdetail': $database->setQuery('SELECT * from #__itemdetails where code='.$itemcode); $result=$database->loadObjectList(); if (!sizeof($result)) { $database->setQuery('SELECT MAX(prio) as maxprio from #__itemdetails where itemid='.$itemid); $maxprio=$database->loadObjectList(); $maxprio=$maxprio[0]->maxprio+1; $database->doSQL('INSERT into #__itemdetails (itemid, prio, code, size, color, price1, price2, price3, price4) VALUES ('.$itemid.', '.$maxprio.', '.ISNULL($itemcode).', "'.addslashes($itemsize).'", "'.addslashes($itemcolor).'", '.str_replace(',','.',ISNULL($itemprice1)).', '.str_replace(',','.',ISNULL($itemprice2)).', '.str_replace(',','.',ISNULL($itemprice3)).', '.str_replace(',','.',ISNULL($itemprice4))./*', '.str_replace(',','.',ISNULL($itemprice5)).*/')'); } else { $saveerror = '&saveerror=1'; } mosRedirect('index2.php?option='.$option.'&act='.$act.'&itemid='.$itemid.'&parentid='.$parentid.'&task=edit&itemtype=item'.$saveerror); break; } break; default: break; } if (($task == 'edit')||($task == 'new')||(($task=='new')&&($itemtype=='itemdetail'))) exit; if (!isset($parentid)) $parentid=0; HTML_catalog::DrawPath($parentid); $database->setQuery("SELECT * FROM #__catalog WHERE parentid=".$parentid." order by prio"); $catalog = $database->loadObjectList(); $database->setQuery("SELECT * FROM #__items WHERE sectionid=".$parentid." order by prio"); $items = $database->loadObjectList(); HTML_catalog::ShowList($catalog, $items, $parentid); break; } case 'updateprice': switch ($task) { case 'update': { if(isset($HTTP_POST_FILES['filename']['name'])) { echo "<h3>Uploading: ".$HTTP_POST_FILES['filename']['name']."</h3><br>"; $handle=fopen($HTTP_POST_FILES['filename']['tmp_name'],"r"); if ($handle) { if (!feof($handle)) $buffer = fgets($handle); while (!feof($handle)&&!stristr(iconv("WINDOWS-1251","UTF-8",$buffer),'Код')) { $buffer = fgets($handle); } if(!stristr(iconv("WINDOWS-1251","UTF-8",$buffer),'Код')) { echo "<h3>Incorrect file<h3>"; exit; } else { $columns=explode("\t",$buffer); $i=0; foreach ($columns as $column) { $column=iconv("WINDOWS-1251","UTF-8",$column); if ($column=="Розница") $price1=$i; if ($column=="Опт1") $price2=$i; if ($column=="Опт2") $price3=$i; if ($column=="Опт3") $price4=$i; if ($column=="Код") $code=$i; $i++; } } echo $database->doSQL("DROP TABLE IF EXISTS #__import"); echo $database->doSQL("CREATE TABLE IF NOT EXISTS #__import ( `code` bigint(20) unsigned NOT NULL, `price1` float NOT NULL default '0', `price2` float NOT NULL default '0', `price3` float NOT NULL default '0', `price4` float NOT NULL default '0', KEY `code` (`code`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1"); $buffer = fgets($handle); while (!feof($handle)) { $buffer = fgets($handle); $row = explode("\t",$buffer); if (array_key_exists(9,$row)) { $out=array("'"," руб."); $row[$price1] = str_replace($out,"",$row[$price1]); $row[$price2] = str_replace($out,"",$row[$price2]); $row[$price3] = str_replace($out,"",$row[$price3]); $row[$price4] = str_replace($out,"",$row[$price4]); $sql = "INSERT INTO #__import (`code`, `price1`, `price2`, `price3`, `price4`) VALUES ('$row[$code]', '$row[$price1]', '$row[$price2]', '$row[$price3]', '$row[$price4]');"; $result = $database->doSQL($sql); } } fclose($handle); } echo "<h3>Import completed</h3><br />"; $database->doSQL("UPDATE #__itemdetails SET `price1` = 0, `price2` = 0, `price3` = 0, `price4` = 0"); echo '<h3>Old prices was nulled</h3><br>'; $sql=""; $database->setQuery('select * from #__itemdetails'); $rows = $database->loadObjectList(); foreach ($rows as $row) { $database->setQuery("select * from #__import where code=$row->code"); $rows1=$database->loadObjectList(); if (!sizeof($rows1)) $errors.=$row->code.', '; else { $database->doSQL("UPDATE #__itemdetails SET `price1` = '".$rows1[0]->price1."', `price2` = '".$rows1[0]->price2."', `price3` = '".$rows1[0]->price3."', `price4` = '".$rows1[0]->price4."' WHERE `code` = ".$row->code); $completed.=$row->code.', '; } } echo '<div align=left><b>The following goods were updated:</b> '.substr($completed,0,strlen($completed)-2).'</div>'; if (isset($errors)) echo '<br><br><div align=left><b><font color=red>The following goods were not found:</b></font> '.substr($errors,0,strlen($errors)-2).'</div>'; exit; } } default: HTML_catalog::ShowUploadPriceForm(); break; } break; } ?>
Output for git.master, git.master_jit, rfc.property-hooks
Direct Access to this location is not allowed.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
41.88 ms | 401 KiB | 8 Q