Пример #1
0
function site_hminfo_install()
{
    $query = "CREATE TABLE site_hminfo (" . "\tid \t\tINTEGER(20) UNSIGNED NOT NULL," . "\tdvd_title \tVARCHAR(128)," . "\tstudio\t\tVARCHAR(30)," . "\treleased\tDATE," . "\tstatus \t\tVARCHAR(15)," . "\tsound \t\tVARCHAR(20)," . "\tversions\tVARCHAR(20)," . "\tprice\t\tDECIMAL(12,2)," . "\trating\t\tVARCHAR(5)," . "\tyear\t\tVARCHAR(5)," . "\tgenre\t\tVARCHAR(20)," . "\taspect\t\tVARCHAR(6)," . "\tupc\t\tVARCHAR(15)," . "\tdvd_releasedate DATE," . "\ttimestamp\tDATE," . "\tupdate_on\tTIMESTAMP," . "\tPRIMARY KEY ( id )" . ") ENGINE=MyISAM COMMENT='Home Theatre Info Lookup Table';";
    $create = db_query($query);
    if ($create) {
        opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, 'Table site_hminfo created');
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error());
        return FALSE;
    }
}
Пример #2
0
function delete_announcement($announcement_id)
{
    $query = "DELETE FROM announcement WHERE sequence_number = " . $announcement_id;
    $delete = db_query($query);
    if (db_affected_rows() > 0) {
        opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($announcement_id));
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($announcement_id));
        return FALSE;
    }
}
 function __perform_install_table_batch()
 {
     if (file_exists("./admin/s_site_plugin/sql/" . $this->_job . ".install.class.php")) {
         $classname = "Install_" . $this->_job;
         include_once "./admin/s_site_plugin/sql/" . $this->_job . ".install.class.php";
         $installPlugin = new $classname();
         // this is currently the only type we support.
         if ($installPlugin->getInstallType() == 'Install_Table') {
             if (check_opendb_table($installPlugin->getInstallTable())) {
                 if ($this->_batchlimit > 0) {
                     $fh = @fopen('./admin/s_site_plugin/upload/' . $this->_uploadFile, 'rb');
                     if ($fh !== FALSE) {
                         $installPlugin->setRowRange($this->_completed + 1, $this->_completed + $this->_batchlimit);
                         if (($header_row = fgetcsv($fh, 4096, ",")) !== FALSE) {
                             $installPlugin->_handleRow($header_row);
                         }
                         while (!$installPlugin->isEndRowFound() && ($read_row_r = fgetcsv($fh, 4096, ",")) !== FALSE) {
                             $installPlugin->_handleRow($read_row_r);
                         }
                         fclose($fh);
                         $this->_processed = $installPlugin->getProcessedCount();
                         $this->_completed = $installPlugin->getRowCount();
                     } else {
                         opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Upload file not accessible');
                         return FALSE;
                     }
                 } else {
                     return FALSE;
                 }
             } else {
                 opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Plugin table ' . strtoupper($installPlugin->getInstallTable()) . ' does not exist');
                 return FALSE;
             }
         } else {
             return FALSE;
         }
     } else {
         opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Site Plugin installation maintenance class not found');
         return FALSE;
     }
 }
Пример #4
0
function update_role_permissions($role_name, $permissions_r)
{
    $role_name = addslashes($role_name);
    db_query("DELETE FROM s_role_permission WHERE role_name = '{$role_name}'");
    if (strlen($role_name) > 0 && is_array($permissions_r)) {
        reset($permissions_r);
        while (list($permission_name, $permission_r) = each($permissions_r)) {
            $enabled_ind = validate_ind_column($permission_r['enabled_ind']);
            $remember_me_ind = validate_ind_column($permission_r['remember_me_ind']);
            if ($enabled_ind == 'Y') {
                $query = "INSERT INTO s_role_permission(role_name, permission_name, remember_me_ind) \n\t\t\t\t\tVALUES('{$role_name}', '{$permission_name}', '" . $remember_me_ind . "')";
                $insert = db_query($query);
                if ($insert && db_affected_rows() > 0) {
                    opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, NULL, array($role_name, $permission_name, $remember_me_ind));
                } else {
                    opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($role_name, $permission_name, $remember_me_ind));
                }
            }
        }
    }
}
Пример #5
0
/**
 * Simple HTTTP Location redirect
 *
 * A simple function to redirect browsers via the HTTP Location header.
 *
 * @param string $link The URL to redirect the user's browser to
 */
function opendb_redirect($link)
{
    if (!is_url_absolute($link)) {
        $protocol = 'http';
        if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
            $protocol = 'https';
        }
        $host = $_SERVER['HTTP_HOST'];
        // fix for windows
        $path = str_replace('\\', '/', dirname($_SERVER['PHP_SELF']));
        if (substr($path, -1, 1) != '/') {
            $path .= '/';
        }
        $path .= $link;
        $url = $protocol . '://' . $host . $path;
        opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($link, $url));
        header('Location: ' . $url);
    } else {
        opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($link));
        header("Location: {$link}");
    }
}
Пример #6
0
 function OpenDbMailer($mailer)
 {
     $this->PluginDir = './lib/phpmailer/';
     if (get_opendb_config_var('email', 'windows_smtp_server') === TRUE) {
         $this->LE = "\r\n";
     } else {
         $this->LE = "\n";
     }
     $this->Mailer = $mailer;
     $this->Priority = "3";
     // in case we want to change it
     $this->Sender = get_opendb_config_var('email', 'noreply_address');
     if ($this->Mailer == 'smtp') {
         $email_smtp_r = get_opendb_config_var('email.smtp');
         // at least host should be defined.
         if (is_not_empty_array($email_smtp_r) && strlen($email_smtp_r['host']) > 0) {
             $this->Host = $email_smtp_r['host'];
             if (strlen($email_smtp_r['port']) > 0) {
                 $this->Port = $email_smtp_r['port'];
             }
             if ($email_smtp_r['secure'] != 'none') {
                 $this->SMTPSecure = $email_smtp_r['secure'];
                 // sets the prefix to the server
             }
             if (strlen($email_smtp_r['username']) > 0 && strlen($email_smtp_r['password']) > 0) {
                 $this->Username = $email_smtp_r['username'];
                 $this->Password = $email_smtp_r['password'];
                 $this->SMTPAuth = TRUE;
             }
         } else {
             // set to 'mail' mailer as default, and log configuration error.
             opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Email SMTP Configuration missing', array($mailer));
             // override, because mailer smtp is misconfigured.
             $this->Mailer = 'mail';
         }
     }
 }
Пример #7
0
function db_remove_all_interest_level($user_id)
{
    $query = "DELETE FROM user_item_interest" . " WHERE user_id = '{$user_id}'";
    $update = db_query($query);
    // We should not treat updates that were not actually updated because value did not change as failures.
    $rows_affected = db_affected_rows();
    if ($update && $rows_affected !== -1) {
        if ($rows_affected > 0) {
            opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($user_id));
        }
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($user_id));
        return FALSE;
    }
}
Пример #8
0
function delete_author_reviews($author_id)
{
    $query = "DELETE FROM review WHERE author_id = '{$author_id}'";
    $delete = db_query($query);
    // doesn't matter if no items deleted, as long as operation was successful.
    if ($delete) {
        opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($author_id));
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($author_id));
        return FALSE;
    }
}
Пример #9
0
function handle_item_relation_delete($item_r, $status_type_r, $HTTP_VARS, &$errors)
{
    if ($item_r['owner_id'] != get_opendb_session_var('user_id') && !is_user_granted_permission(PERM_ITEM_ADMIN)) {
        $errors = array('error' => get_opendb_lang_var('cannot_delete_relation_item_not_owned'), 'detail' => '');
        opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'User to delete item relationship they do not own', $item_r);
        return FALSE;
    }
    if ($HTTP_VARS['confirmed'] == 'true') {
        delete_related_item_instance_relationship($item_r['item_id'], $item_r['instance_no'], $HTTP_VARS['parent_item_id'], $HTTP_VARS['parent_instance_no']);
    } else {
        if ($HTTP_VARS['confirmed'] != 'false') {
            return "__CONFIRM__";
        } else {
            // confirmation required.
            return "__ABORTED__";
        }
    }
}
Пример #10
0
function perform_newpassword($HTTP_VARS, &$errors)
{
    if (!is_user_valid($HTTP_VARS['uid'])) {
        opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'New password request failure: User does not exist', array($HTTP_VARS['uid']));
        // make user look successful to prevent mining for valid userids
        return TRUE;
    } else {
        if (!is_user_active($HTTP_VARS['uid'])) {
            // Do not allow new password operation for 'deactivated' user.
            opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'New password request failure: User is not active', array($HTTP_VARS['uid']));
            return FALSE;
        } else {
            if (!is_user_granted_permission(PERM_CHANGE_PASSWORD, $HTTP_VARS['uid'])) {
                opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'New password request failure: User does not have permission to change password', array($HTTP_VARS['uid']));
                return FALSE;
            } else {
                if (get_opendb_config_var('user_admin', 'user_passwd_change_allowed') === FALSE && !is_user_granted_permission(PERM_ADMIN_CHANGE_PASSWORD)) {
                    opendb_logger(OPENDB_LOG_WARN, __FILE__, __FUNCTION__, 'New password request failure: Password change is disabled', array($HTTP_VARS['uid']));
                    return FALSE;
                } else {
                    opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, 'User requested to be emailed a new password', array($HTTP_VARS['uid']));
                    $user_r = fetch_user_r($HTTP_VARS['uid']);
                    $user_passwd = generate_password(8);
                    // only send if valid user (email)
                    if (strlen($user_r['email_addr']) > 0) {
                        $pass_result = update_user_passwd($HTTP_VARS['uid'], $user_passwd);
                        if ($pass_result === TRUE) {
                            $subject = get_opendb_lang_var('lost_password');
                            $message = get_opendb_lang_var('to_user_email_intro', 'fullname', $user_r['fullname']) . "\n\n" . get_opendb_lang_var('new_passwd_email') . "\n\n" . get_opendb_lang_var('userid') . ": " . $HTTP_VARS['uid'] . "\n" . get_opendb_lang_var('password') . ": " . $user_passwd;
                            if (opendb_user_email($user_r['user_id'], NULL, $subject, $message, $errors)) {
                                return TRUE;
                            } else {
                                return "EMAIL_NOT_SENT";
                            }
                        }
                    } else {
                        $errors[] = "User '" . $HTTP_VARS['uid'] . "' does not have a valid email address.";
                        return FALSE;
                    }
                }
            }
        }
    }
}
Пример #11
0
function delete_s_language($language)
{
    if (is_exists_language($language)) {
        $query = "DELETE FROM s_language " . "WHERE language = '{$language}'";
        $delete = db_query($query);
        // We should not treat deletes that were not actually updated because value did not change as failures.
        if ($delete && ($rows_affected = db_affected_rows()) !== -1) {
            if ($rows_affected > 0) {
                opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($language));
            }
            return TRUE;
        } else {
            opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($language));
            return FALSE;
        }
    }
    //else
    return FALSE;
}
Пример #12
0
/**
 * The table structure could be more sophisticated where a message is sent to multiple
 * addresses, but since the email function does not provide this, I see no reason to
 * do anything more complicated.
 *
 * @param unknown_type $item_id
 * @param unknown_type $author_id
 * @param unknown_type $comment
 * @param unknown_type $rating
 * @return unknown
 */
function insert_email($to_user_id, $from_user_id, $from_email_addr, $subject, $message)
{
    $to_user_id = trim($to_user_id);
    $from_user_id = trim($from_user_id);
    $from_email_addr = trim($from_email_addr);
    if (!is_user_valid($to_user_id)) {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Invalid To User', array($to_user_id, $from_user_id, $from_email_addr, $subject));
        return FALSE;
    } else {
        if (strlen($from_user_id) > 0 && !is_user_valid($from_user_id)) {
            opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Invalid From User', array($to_user_id, $from_user_id, $from_email_addr, $subject));
            return FALSE;
        } else {
            if (strlen($from_user_id) == 0 && (strlen($from_email_addr) == 0 || !is_valid_email_addr($from_email_addr))) {
                opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Invalid From Email', array($to_user_id, $from_user_id, $from_email_addr, $subject));
                return FALSE;
            }
        }
    }
    if (strlen($from_user_id) > 0) {
        $from_email_addr = NULL;
    } else {
        $from_email_addr = addslashes($from_email_addr);
    }
    $subject = addslashes(trim($subject));
    $message = addslashes(replace_newlines(trim($message)));
    $query = "INSERT INTO mailbox (to_user_id,from_user_id,from_email_addr,subject,message)" . "VALUES ('{$to_user_id}'," . (strlen($from_user_id) > 0 ? "'{$from_user_id}'" : "NULL") . "," . (strlen($from_email_addr) > 0 ? "'{$from_email_addr}'" : "NULL") . ", '{$subject}','{$message}')";
    $insert = db_query($query);
    if ($insert && db_affected_rows() > 0) {
        opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($to_user_id, $from_user_id, $from_email_addr, $subject));
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($to_user_id, $from_user_id, $from_email_addr, $subject));
        return FALSE;
    }
}
Пример #13
0
/**
 */
function delete_s_config_group_item_vars($group_id, $id, $keyid)
{
    if (strlen($group_id) > 0) {
        $query = "DELETE FROM s_config_group_item_var " . "WHERE group_id = '{$group_id}'";
        if (strlen($id) > 0) {
            $query .= " AND id = '{$id}'";
        }
        if (strlen($keyid) > 0) {
            $query .= " AND keyid = '{$keyid}'";
        }
        $delete = db_query($query);
        // We should not treat deletes that were not actually updated because value did not change as failures.
        if ($delete && ($rows_affected = db_affected_rows()) !== -1) {
            //if($rows_affected>0)
            //	opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($group_id, $id, $keyid));
            return TRUE;
        } else {
            opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($group_id, $id, $keyid));
            return FALSE;
        }
    }
    //else
    return FALSE;
}
Пример #14
0
function import_cache_deleteall()
{
    // hack
    import_cache_get_cache_directory();
    if (db_query("LOCK TABLES import_cache WRITE")) {
        $query = "SELECT sequence_number FROM import_cache";
        $results = db_query($query);
        if ($results) {
            while ($import_cache_r = db_fetch_assoc($results)) {
                import_cache_delete($import_cache_r['sequence_number']);
            }
            db_free_result($results);
        }
        db_query("UNLOCK TABLES");
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error());
        return FALSE;
    }
}
Пример #15
0
/**
 */
function delete_s_title_display_mask_item($stdm_id, $s_item_type_group, $s_item_type)
{
    if (strlen($stdm_id) > 0 && strlen($s_item_type_group) > 0 && strlen($s_item_type) > 0) {
        // ensure parent record exists
        if (is_exists_s_title_display_mask($stdm_id)) {
            $query = "DELETE FROM s_title_display_mask_item " . " WHERE stdm_id = '{$stdm_id}' AND " . "s_item_type_group = '{$s_item_type_group}' AND " . "s_item_type = '{$s_item_type}'";
            $delete = db_query($query);
            // We should not treat deletes that were not actually updated because value did not change as failures.
            if ($delete && ($rows_affected = db_affected_rows()) !== -1) {
                if ($rows_affected > 0) {
                    opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($stdm_id, $s_item_type_group, $s_item_type));
                }
                return TRUE;
            } else {
                opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($stdm_id, $s_item_type_group, $s_item_type));
                return FALSE;
            }
        }
    }
    //else
    return FALSE;
}
Пример #16
0
 function &fetchURI($URI, $http_cache = TRUE)
 {
     @set_time_limit(600);
     $URI = trim($URI);
     $this->__debug('fetchURI', "URI: {$URI}");
     $this->_file_cache_r = NULL;
     $overwrite_cache_entry = FALSE;
     if ($http_cache !== FALSE && $this->_file_cache_enabled) {
         // see if we can find the cache file.
         $this->_file_cache_r = fetch_url_file_cache_r($URI, 'HTTP');
         if ($this->_file_cache_r !== FALSE) {
             $file_location = file_cache_get_cache_file($this->_file_cache_r);
             if ($file_location !== FALSE) {
                 $this->_file_cache_r['content'] = file_get_contents($file_location);
                 if (strlen($this->_file_cache_r['content']) == 0) {
                     $this->__debug('fetchURI', 'URL cache invalid');
                     $overwrite_cache_entry = TRUE;
                     unset($this->_file_cache_r);
                 }
             } else {
                 unset($this->_file_cache_r);
             }
         }
     }
     if (is_not_empty_array($this->_file_cache_r)) {
         $this->__debug('fetchURI', 'URL cached');
         return $this->_file_cache_r['content'];
     } else {
         $this->__debug('fetchURI', 'URL NOT cached');
         if ($this->fetch($URI) && $this->status >= 200 && $this->status < 300) {
             opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($URI));
             $this->_file_cache_r['url'] = $URI;
             $this->_file_cache_r['content'] = $this->results;
             $this->results = NULL;
             if (strlen($this->_file_cache_r['content']) > 0) {
                 $this->__debug('fetchURI', 'URL fetched (Size=' . strlen($this->_file_cache_r['content']) . ')');
                 // assume a default.
                 $this->_file_cache_r['content_type'] = 'text/html';
                 if (is_array($this->headers) && count($this->headers) > 0) {
                     for ($i = 0; $i < count($this->headers); $i++) {
                         if (preg_match("/^([^:]*):([^\$]*)\$/i", $this->headers[$i], $matches)) {
                             if (strcasecmp(trim($matches[1]), 'content-type') === 0) {
                                 $this->_file_cache_r['content_type'] = trim($matches[2]);
                                 break;
                             }
                         }
                     }
                 }
                 $this->_file_cache_r['location'] = $this->lastredirectaddr;
                 if ($http_cache !== FALSE && $this->_file_cache_enabled) {
                     if (file_cache_insert_file($this->_file_cache_r['url'], $this->_file_cache_r['location'], $this->_file_cache_r['content_type'], $this->_file_cache_r['content'], 'HTTP', $overwrite_cache_entry) !== FALSE) {
                         $this->__debug('fetchURI', "Added {$URI} to file cache");
                     } else {
                         $this->__debug('fetchURI', "Failed to add {$URI} to file cache");
                     }
                 }
                 //if($http_cache!==FALSE && $this->_file_cache_enabled)
             }
             //if(strlen($_file_cache_r['content'])>0)
             return $this->_file_cache_r['content'];
         } else {
             $this->__debug('fetchURI', "Failed to fetch {$URI}", ifempty($this->error, 'Status ' . $this->status));
             opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, ifempty($this->error, 'Status ' . $this->status), array($URI));
             return FALSE;
         }
     }
 }
Пример #17
0
/**
	Delete user.  Assumes validation has already been performed.

	TODO - delete user_address and user_address_attributes for this user!
*/
function delete_user($uid)
{
    $query = "DELETE FROM user WHERE user_id = '{$uid}'";
    $delete = db_query($query);
    if (db_affected_rows() > 0) {
        opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($uid));
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($uid));
        return FALSE;
    }
}
Пример #18
0
function delete_file_cache($file_cache_r)
{
    if (($filename = file_cache_get_cache_file($file_cache_r)) !== FALSE) {
        delete_file($filename);
    }
    // in case thumbnail file is orphaned, delete separately.
    if (($thumbnail_filename = file_cache_get_cache_file_thumbnail($file_cache_r)) !== FALSE) {
        delete_file($thumbnail_filename);
    }
    $query = "DELETE FROM file_cache WHERE sequence_number = " . $file_cache_r['sequence_number'];
    $delete = db_query($query);
    if ($delete) {
        // Even if no attributes were deleted, because there were none, this should still return true.
        if (db_affected_rows() > 0) {
            opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, $file_cache_r);
        }
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), $file_cache_r);
        return FALSE;
    }
}
Пример #19
0
function delete_s_item_listing_conf($silc_id)
{
    $query = "DELETE FROM s_item_listing_conf " . " WHERE id = '{$silc_id}' ";
    $delete = db_query($query);
    if ($delete && ($rows_affected = db_affected_rows()) !== -1) {
        if ($rows_affected > 0) {
            opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($silc_id));
        }
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($silc_id));
        return FALSE;
    }
    //else
    return FALSE;
}
Пример #20
0
function delete_s_addr_attribute_type_rltshp($s_address_type, $s_attribute_type, $order_no)
{
    $query = "DELETE FROM s_addr_attribute_type_rltshp " . "WHERE s_address_type = '{$s_address_type}'";
    if (strlen($s_attribute_type) > 0) {
        $query .= " AND s_attribute_type = '{$s_attribute_type}' AND order_no = '{$order_no}'";
    }
    $delete = db_query($query);
    // We should not treat updates that were not actually updated because value did not change as failures.
    $rows_affected = db_affected_rows();
    if ($delete && $rows_affected !== -1) {
        if ($rows_affected > 0) {
            opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($s_address_type, $s_attribute_type, $order_no));
        }
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($s_address_type, $s_attribute_type, $order_no));
        return FALSE;
    }
}
Пример #21
0
function insert_remember_me($user_id, $cookie)
{
    $cookie = addslashes($cookie);
    $query = "INSERT INTO remember_me(user_id, cookie)" . "VALUES ('{$user_id}', '{$cookie}')";
    $insert = db_query($query);
    if ($insert && db_affected_rows() > 0) {
        $sequence_number = db_insert_id();
        opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($user_id, $cookie));
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($user_id, $cookie));
        return FALSE;
    }
}
Пример #22
0
function delete_item_attribute_order_no($s_item_type, $s_attribute_type, $order_no)
{
    // have to use alias to lock table! -- http://dev.mysql.com/doc/mysql/en/LOCK_TABLES.html
    if (db_query("LOCK TABLES item AS i WRITE, item_attribute AS ia WRITE, item_attribute WRITE")) {
        $results = db_query("SELECT DISTINCT ia.item_id " . "FROM item i, item_attribute ia " . "WHERE i.id = ia.item_id AND " . "i.s_item_type = '{$s_item_type}' AND " . "ia.s_attribute_type = '{$s_attribute_type}' AND " . "ia.order_no = {$order_no}");
        if ($results) {
            while ($item_attribute_r = db_fetch_assoc($results)) {
                $update = db_query("DELETE FROM item_attribute " . "WHERE item_id = " . $item_attribute_r['item_id'] . " AND s_attribute_type = '{$s_attribute_type}' AND order_no = '{$order_no}'");
                // We should not treat updates that were not actually updated because value did not change as failures.
                $rows_affected = db_affected_rows();
                if ($update && $rows_affected !== -1) {
                    if ($rows_affected > 0) {
                        opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($s_item_type, $s_attribute_type, $order_no));
                    }
                } else {
                    db_query("UNLOCK TABLES");
                    opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($s_item_type, $s_attribute_type, $order_no));
                    return FALSE;
                }
            }
            db_free_result($results);
            db_query("UNLOCK TABLES");
            return TRUE;
        } else {
            db_query("UNLOCK TABLES");
            opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($s_item_type, $s_attribute_type, $order_no));
            return FALSE;
        }
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($s_item_type, $s_attribute_type, $order_no));
        return FALSE;
    }
}
Пример #23
0
 // Cache often used configuration entries
 $CONFIG_VARS['logging'] = get_opendb_config_var('logging');
 // Buffer output for possible pushing through ob_gzhandler handler
 if (is_gzip_compression_enabled($PHP_SELF)) {
     ob_start('ob_gzhandler');
 }
 // Restrict cookie to site host and path.
 if (get_opendb_config_var('site', 'restrict_session_cookie_to_host_path') === TRUE) {
     session_set_cookie_params(0, get_site_path(), get_site_host());
 }
 if (get_opendb_config_var('session_handler', 'enable') === TRUE) {
     require_once "./lib/dbsession.php";
     if (strtolower(ini_get('session.save_handler')) == 'user' || ini_set('session.save_handler', 'user')) {
         session_set_save_handler('db_session_open', 'db_session_close', 'db_session_read', 'db_session_write', 'db_session_destroy', 'db_session_gc');
     } else {
         opendb_logger(OPENDB_LOG_ERROR, __FILE__, NULL, 'Cannot set session.save_handler to \'user\'');
     }
 }
 // We want to start the session here, so we can get access to the $_SESSION properly.
 session_name(get_opendb_session_cookie_name());
 session_start();
 handle_opendb_remember_me();
 //allows specific pages to overide themes
 if (is_exists_theme($_OVRD_OPENDB_THEME)) {
     $_OPENDB_THEME = $_OVRD_OPENDB_THEME;
 } else {
     unset($_OPENDB_THEME);
     if (strlen(get_opendb_session_var('user_id')) > 0 && get_opendb_config_var('user_admin', 'user_themes_support') !== FALSE) {
         $user_theme = fetch_user_theme(get_opendb_session_var('user_id'));
         if (is_exists_theme($user_theme)) {
             $_OPENDB_THEME = $user_theme;
Пример #24
0
function delete_file($filename)
{
    if (@is_file($filename)) {
        if (@unlink($filename)) {
            opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($filename));
            return TRUE;
        } else {
            opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, NULL, array($filename));
            return FALSE;
        }
    } else {
        return FALSE;
    }
}
Пример #25
0
function delete_s_site_plugin_link($site_type, $sequence_number = NULL)
{
    if (strlen($site_type) > 0) {
        $site_type = strtolower($site_type);
        $query = "DELETE FROM s_site_plugin_link " . "WHERE site_type = '{$site_type}'";
        if (is_numeric($sequence_number)) {
            $query .= " AND sequence_number = {$sequence_number}";
        }
        $delete = db_query($query);
        // We should not treat updates that were not actually updated because value did not change as failures.
        $rows_affected = db_affected_rows();
        if ($delete && $rows_affected !== -1) {
            if ($rows_affected > 0) {
                opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($site_type, $sequence_number));
            }
            return TRUE;
        } else {
            opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($site_type, $sequence_number));
            return FALSE;
        }
    }
    //else
    return FALSE;
}
Пример #26
0
function get_export_plugin_list_r()
{
    $pluginList = NULL;
    $export_type_r = get_export_r();
    if (is_array($export_type_r)) {
        while (list(, $pluginRef) = @each($export_type_r)) {
            include_once "./lib/export/" . $pluginRef . ".class.php";
            $exportPlugin = new $pluginRef();
            if ($exportPlugin !== NULL) {
                if (strcasecmp($pluginRef, get_class($exportPlugin)) === 0) {
                    $pluginList[] = array(name => $pluginRef, description => $exportPlugin->get_display_name());
                } else {
                    opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Export class is not valid', array($pluginRef));
                }
            }
        }
    }
    return $pluginList;
}
Пример #27
0
function delete_s_status_type($s_status_type)
{
    $s_status_type = strtoupper($s_status_type);
    $query = "DELETE FROM s_status_type " . "WHERE s_status_type = '{$s_status_type}'";
    $delete = db_query($query);
    // We should not treat updates that were not actually updated because value did not change as failures.
    $rows_affected = db_affected_rows();
    if ($delete && $rows_affected !== -1) {
        if ($rows_affected > 0) {
            opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($s_status_type));
        }
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($s_status_type));
        return FALSE;
    }
}
Пример #28
0
function delete_related_item_instance_relationship($item_id, $instance_no, $parent_item_id, $parent_instance_no)
{
    $query = "DELETE FROM item_instance_relationship \n\t\t\tWHERE related_item_id = '" . $item_id . "' AND \n\t\t\t\trelated_instance_no = {$instance_no} AND\n\t\t\t\titem_id = {$parent_item_id} AND\n\t\t\t\tinstance_no = {$parent_instance_no}";
    $delete = db_query($query);
    if (db_affected_rows() > 0) {
        opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($item_id, $instance_no, $parent_item_id, $parent_instance_no));
        return TRUE;
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, db_error(), array($item_id, $instance_no, $parent_item_id, $parent_instance_no));
        return FALSE;
    }
}
Пример #29
0
function handle_user_delete($user_id, $HTTP_VARS, &$errors)
{
    if (is_user_valid($user_id) && is_user_not_activated($user_id)) {
        // If already confirmed operation.
        if ($HTTP_VARS['confirmed'] == 'true') {
            // ignore failure to delete user addresses - will be logged.
            delete_user_addresses($user_id);
            if (!delete_user($user_id)) {
                $db_error = db_error();
                $errors = array('error' => get_opendb_lang_var('user_not_deleted'), 'detail' => $db_error);
                return FALSE;
            } else {
                return TRUE;
            }
        } else {
            if ($HTTP_VARS['confirmed'] != 'false') {
                // confirmation required.
                return "__CONFIRM__";
            } else {
                return "__ABORTED__";
            }
        }
    } else {
        opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Attempt to delete a user which is activated or previously activated', $user_id);
        $errors = array('error' => get_opendb_lang_var('operation_not_available'), 'detail' => '');
        return FALSE;
    }
}
Пример #30
0
function delete_s_item_type_group_rltshp($s_item_type_group, $s_item_type = NULL)
{
    // ignore attempt to delete every record, this is done by accident!
    if (strlen($s_item_type_group) > 0 || strlen($s_item_type) > 0) {
        $s_item_type = strtoupper($s_item_type);
        $s_item_type_group = strtoupper($s_item_type_group);
        $query = "DELETE FROM s_item_type_group_rltshp WHERE ";
        if (strlen($s_item_type_group)) {
            $query .= "s_item_type_group = '{$s_item_type_group}'";
            if (strlen($s_item_type) > 0) {
                $query .= " AND s_item_type = '{$s_item_type}'";
            }
        } else {
            $query .= "s_item_type = '{$s_item_type}'";
        }
        $delete = db_query($query);
        // We should not treat updates that were not actually updated because value did not change as failures.
        $rows_affected = db_affected_rows();
        if ($delete && $rows_affected !== -1) {
            if ($rows_affected > 0) {
                opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($s_item_type_group, $s_item_type));
            }
            return TRUE;
        } else {
            opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, db_error(), array($s_item_type_group, $s_item_type));
            return FALSE;
        }
    }
    //else
    return FALSE;
}