Esempio n. 1
0
 public static function edit_payment_plan($id, $opt = array())
 {
     global $db;
     if (!$GLOBALS['me']->is_admin) {
         return false;
     }
     $opt = array_map('trim', $opt);
     $opt['price'] = \site\utils::make_money_format($opt['price']);
     if (empty($opt['name']) || $opt['price'] < 0 || $opt['credits'] <= 0) {
         return false;
     }
     $plan = \query\payments::plan_infos($id);
     $avatar = \site\images::upload(@$_FILES['logo'], 'payment_plan_', array('path' => DIR . '/', 'max_size' => 1024, 'max_width' => 500, 'max_height' => 600, 'current' => $plan->image));
     $stmt = $db->stmt_init();
     $stmt->prepare("UPDATE " . DB_TABLE_PREFIX . "p_plans SET name = ?, description = ?, price = ?, credits = ?, image = ?, lastupdate_by = ?, lastupdate = NOW(), visible = ? WHERE id = ?");
     $stmt->bind_param("ssdisiii", $opt['name'], $opt['description'], $opt['price'], $opt['credits'], $avatar, $GLOBALS['me']->ID, $opt['publish'], $id);
     $execute = $stmt->execute();
     $stmt->close();
     if ($execute) {
         return true;
     }
     return false;
 }