if ($this->authorize()) { $menuBar = array(); if ($this->registry->params['comfirm'] == 'delete') { // delete image file first. $login = $this->registry->admin_config->get('FTP'); $row = $this->getResult('image', $ushop->db_name . 'products', null, array('where' => 'product_id=' . $this->registry->params['id'])); $di = true; // set delete flag. if ($row) { $ftp = new File_FTP($this->registry); if ($ftp) { $delete = $ftp->rm($login['public_html'] . '/components/ushop/images/products/' . $row[0]->image); if (!$delete) { $di = false; } $ftp->disconnect(); } else { $di = false; } } else { $di = false; } $res = $this->remove($ushop->db_name . 'products', 'product_id=' . $this->registry->params['id']); if ($res) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Product was successfully deleted.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Product could not be deleted due to an error.</h2>'; } if (!$di) {
public function save() { try { if ($this->path == null) { throw new ConfigException("Config::save() - ini path not set, error."); } $content = null; // PROTECTED_MODE-prefix if ($this->protected_mode) { $content .= "<?php\n; /*\n; -- BEGIN PROTECTED_MODE\n"; } // config-header $content .= "; This file was automatically generated by Config\n"; $content .= "; Do not edit this file by hand, use Config instead.\n"; $content .= "; Last modified: " . date('d M Y H:i s') . "\n"; // check if there are sections to process if ($this->process_sections) { foreach ($this->vars as $key => $elem) { $content .= "[" . $key . "]\n"; foreach ($elem as $key2 => $elem2) { if (is_array($elem2)) { foreach ($elem2 as $elem3) { $content .= $key2 . "[] = \"" . $elem3 . "\"\n"; } } else { $content .= $key2 . " = \"" . $elem2 . "\"\n"; } } } } else { foreach ($this->vars as $key => $elem) { $content .= $key . " = \"" . $elem . "\"\n"; } } // add PROTECTED_MODE-ending if ($this->protected_mode) { $content .= "\n; -- END PROTECTED_MODE\n; */\n?>\n"; } $ftp = new File_FTP($this->registry); $dir = preg_replace("/(.*?)" . str_replace("/", "\\/", $ftp->public_html) . "|(.*?)" . str_replace("/", "\\/", $ftp->uthando_dir) . "/", "", $this->path); if ($this->public_html) { $path = $ftp->public_html . $dir; } else { $path = $ftp->uthando_dir . $dir; } $ftp->chmod($path, 0646); if (!file_put_contents($this->path, $content)) { throw new ConfigException("Config::save() - Could not write to file('" . $this->path . "'), error."); } $ftp->chmod($path, 0644); $ftp->disconnect(); return true; } catch (ConfigException $e) { $this->registry->Error($e->getMessage()); return false; } }