当前位置: 首页>>代码示例>>PHP>>正文


PHP safe_alter函数代码示例

本文整理汇总了PHP中safe_alter函数的典型用法代码示例。如果您正苦于以下问题:PHP safe_alter函数的具体用法?PHP safe_alter怎么用?PHP safe_alter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了safe_alter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: safe_alter

if (!in_array('thumb_w', $cols)) {
    safe_alter('txp_image', "ADD thumb_w int(8) NOT NULL DEFAULT 0");
}
if (!in_array('thumb_h', $cols)) {
    safe_alter('txp_image', "ADD thumb_h int(8) NOT NULL DEFAULT 0");
}
// Plugin flags.
$cols = getThings('DESCRIBE `' . PFX . 'txp_plugin`');
if (!in_array('flags', $cols)) {
    safe_alter('txp_plugin', "ADD flags SMALLINT UNSIGNED NOT NULL DEFAULT 0");
}
// Default theme.
if (!safe_field("name", 'txp_prefs', "name = 'theme_name'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'theme_name', val = 'classic', type = '1', event = 'admin', html = 'themename', position = '160'");
}
safe_alter('txp_plugin', "MODIFY code         MEDIUMTEXT NOT NULL");
safe_alter('txp_plugin', "MODIFY code_restore MEDIUMTEXT NOT NULL");
safe_alter('txp_prefs', "MODIFY val TEXT NOT NULL");
// Add author column to files and links, boldy assuming that the publisher in
// charge of updating this site is the author of any existing content items.
foreach (array('txp_file', 'txp_link') as $table) {
    $cols = getThings("DESCRIBE `" . PFX . $table . "`");
    if (!in_array('author', $cols)) {
        safe_alter($table, "ADD author varchar(64) NOT NULL DEFAULT ''");
        safe_create_index($table, 'author', 'author_idx');
        safe_update($table, "author = '" . doSlash($txp_user) . "'", "1 = 1");
    }
}
// Add indices on author columns.
safe_create_index('textpattern', 'AuthorID', 'author_idx');
safe_create_index('txp_image', 'author', 'author_idx');
开发者ID:scar45,项目名称:textpattern,代码行数:31,代码来源:_to_4.2.0.php

示例2: safe_upgrade_table

<?php

/*
$HeadURL$
$LastChangedRevision$
*/
safe_upgrade_table('textpattern', array('markup_body' => 'varchar(32)', 'markup_excerpt' => 'varchar(32)'));
// user-specific preferences
safe_upgrade_table('txp_prefs_user', array('id' => DB_AUTOINC . ' PRIMARY KEY', 'user' => "varchar(64) NOT NULL default ''", 'name' => "varchar(255) NOT NULL default ''", 'val' => "varchar(255) NOT NULL default ''"));
// unique index on user+name
safe_upgrade_index('txp_prefs_user', 'user_idx', 'unique', 'user, name');
if (!safe_column_exists('txp_section', 'id')) {
    safe_alter('txp_section', 'drop primary key');
}
safe_upgrade_table('txp_section', array('id' => DB_AUTOINC . ' PRIMARY KEY', 'path' => "varchar(255) not null default ''", 'parent' => 'INT', 'lft' => 'INT not null default 0', 'rgt' => 'INT not null default 0', 'inherit' => 'SMALLINT not null default 0'));
safe_update('txp_section', 'path=name', "path=''");
// shortname has to be unique within a parent
if (!safe_index_exists('txp_section', 'parent_idx')) {
    safe_upgrade_index('txp_section', 'parent_idx', 'unique', 'parent,name');
}
#if (!safe_index_exists('txp_section', 'path_idx'))
#	safe_upgrade_index('txp_section', 'path_idx', 'unique', 'path');
safe_update('txp_section', 'parent=0', "name='default'");
$root_id = safe_field('id', 'txp_section', "name='default'");
safe_update('txp_section', "parent='" . $root_id . "'", "parent IS NULL");
include_once txpath . '/lib/txplib_tree.php';
tree_rebuild('txp_section', $root_id, 1);
// <txp:message /> is dropped
safe_update('txp_form', "Form = REPLACE(Form, '<txp:message', '<txp:comment_message')", "1 = 1");
// Expiry datetime for articles
safe_upgrade_table('textpattern', array('Expires' => "datetime NOT NULL default '0000-00-00 00:00:00' after `Posted`"));
开发者ID:bgarrels,项目名称:textpattern,代码行数:31,代码来源:_to_4.1.0.php

示例3: exit

 *
 * This file is part of Textpattern.
 *
 * Textpattern is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, version 2.
 *
 * Textpattern is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Textpattern. If not, see <http://www.gnu.org/licenses/>.
 */
if (!defined('TXP_UPDATE')) {
    exit("Nothing here. You can't access this file directly.");
}
// Updates comment email length.
safe_alter('txp_discuss', "MODIFY email VARCHAR(254) NOT NULL DEFAULT ''");
// Store IPv6 properly in logs.
safe_alter('txp_log', "MODIFY ip VARCHAR(45) NOT NULL DEFAULT ''");
// Save sections correctly in articles.
safe_alter('textpattern', "MODIFY Section VARCHAR(255) NOT NULL DEFAULT ''");
// Ensure all memory-mappable columns have defaults
safe_alter('txp_form', "MODIFY name VARCHAR(64) NOT NULL DEFAULT ''");
safe_alter('txp_page', "MODIFY name VARCHAR(128) NOT NULL DEFAULT ''");
safe_alter('txp_prefs', "MODIFY prefs_id INT NOT NULL DEFAULT '1'");
safe_alter('txp_prefs', "MODIFY name VARCHAR(255) NOT NULL DEFAULT ''");
safe_alter('txp_section', "MODIFY name VARCHAR(128) NOT NULL DEFAULT ''");
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:30,代码来源:_to_4.5.7.php

示例4: exit

<?php

/*
$HeadURL: https://textpattern.googlecode.com/svn/releases/4.5.7/source/textpattern/update/_to_4.3.0.php $
$LastChangedRevision: 4011 $
*/
if (!defined('TXP_UPDATE')) {
    exit("Nothing here. You can't access this file directly.");
}
// Raw CSS is now the only option
safe_delete('txp_prefs', "event='css' and name='edit_raw_css_by_default'");
$rs = getRows('select name,css from `' . PFX . 'txp_css`');
foreach ($rs as $row) {
    if (preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $row['css'])) {
        // Data is still base64 encoded
        safe_update('txp_css', "css = '" . doSlash(base64_decode($row['css'])) . "'", "name = '" . doSlash($row['name']) . "'");
    }
}
// add column for file title
$cols = getThings('describe `' . PFX . 'txp_file`');
if (!in_array('title', $cols)) {
    safe_alter('txp_file', "ADD `title` VARCHAR( 255 ) NULL AFTER `filename`");
}
开发者ID:balcides,项目名称:Cathartic_server,代码行数:23,代码来源:_to_4.3.0.php

示例5: safe_alter

    safe_alter('txp_plugin', "ADD load_order TINYINT UNSIGNED NOT NULL DEFAULT 5");
}
#  Enable XML-RPC server?
if (!safe_field('name', 'txp_prefs', "name = 'enable_xmlrpc_server'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'enable_xmlrpc_server', val = 0, type = 1, event = 'admin', html = 'yesnoradio', position = 130");
}
if (!safe_field('name', 'txp_prefs', "name = 'smtp_from'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'smtp_from', val = '', type = 1, event = 'admin', position = 110");
}
if (!safe_field('val', 'txp_prefs', "name='author_list_pageby'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'author_list_pageby', val = 25, type = 2");
}
# Expiry datetime for articles
$txp = getThings('describe `' . PFX . 'textpattern`');
if (!in_array('Expires', $txp)) {
    safe_alter("textpattern", "add `Expires` datetime NOT NULL default '0000-00-00 00:00:00' after `Posted`");
}
$has_expires_idx = 0;
$rs = getRows('show index from `' . PFX . 'textpattern`');
foreach ($rs as $row) {
    if ($row['Key_name'] == 'Expires_idx') {
        $has_expires_idx = 1;
    }
}
if (!$has_expires_idx) {
    safe_query('alter ignore table `' . PFX . 'textpattern` add index Expires_idx(Expires)');
}
#  Publish expired articles, or return 410?
if (!safe_field('name', 'txp_prefs', "name = 'publish_expired_articles'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'publish_expired_articles', val = '0', type = '1', event='publish', html='yesnoradio', position='130'");
}
开发者ID:balcides,项目名称:Cathartic_server,代码行数:31,代码来源:_to_4.0.7.php

示例6: safe_alter

    safe_alter('txp_file', "ADD modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'");
    $update_files = 1;
}
if (!in_array('created', $txpfile)) {
    safe_alter('txp_file', "ADD created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'");
    $update_files = 1;
}
if (!in_array('size', $txpfile)) {
    safe_alter('txp_file', "ADD size BIGINT");
    $update_files = 1;
}
if (!in_array('downloads', $txpfile)) {
    safe_alter('txp_file', "ADD downloads INT DEFAULT '0' NOT NULL");
}
if (array_intersect(array('modified', 'created'), $txpfile)) {
    safe_alter('txp_file', "\n        MODIFY modified DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',\n        MODIFY created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'");
}
// Copy existing file timestamps into the new database columns.
if ($update_files) {
    $prefs = get_prefs();
    $rs = safe_rows("*", 'txp_file', "1 = 1");
    foreach ($rs as $row) {
        $path = build_file_path(@$prefs['file_base_path'], @$row['filename']);
        if ($path and $stat = @stat($path)) {
            safe_update('txp_file', "created = '" . strftime('%Y-%m-%d %H:%M:%S', $stat['ctime']) . "', modified = '" . strftime('%Y-%m-%d %H:%M:%S', $stat['mtime']) . "', size = '" . doSlash(sprintf('%u', $stat['size'])) . "'", "id = '" . doSlash($row['id']) . "'");
        }
    }
}
safe_update('textpattern', "Keywords = TRIM(BOTH ',' FROM \n    REPLACE(\n        REPLACE(\n            REPLACE(\n                REPLACE(\n                    REPLACE(\n                        REPLACE(\n                            REPLACE(\n                                REPLACE(\n                                    REPLACE(\n                                        REPLACE(\n                                            REPLACE(Keywords, '\n', ','),\n                                            '\r', ','),\n                                        '\t', ','),\n                                    '    ', ' '),\n                                '  ', ' '),\n                            '  ', ' '),\n                        ' ,', ','),\n                    ', ', ','),\n                ',,,,', ','),\n            ',,', ','),\n        ',,', ',')\n    )", "Keywords != ''");
// Shift preferences to more intuitive spots.
// Give positions, leave enough room for later additions.
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:31,代码来源:_to_4.0.5.php

示例7: safe_alter

safe_alter('txp_section', "MODIFY page VARCHAR(255) NOT NULL default '', MODIFY css VARCHAR(255) NOT NULL default ''");
// Save sections correctly in articles.
safe_alter('textpattern', "MODIFY Section VARCHAR(255) NOT NULL default ''");
safe_alter('txp_section', "MODIFY name VARCHAR(255) NOT NULL");
// Plugins can have longer version numbers.
safe_alter('txp_plugin', "MODIFY version VARCHAR(255) NOT NULL DEFAULT '1.0'");
// Translation strings should allow more than 255 characters.
safe_alter('txp_lang', "MODIFY data TEXT");
// Add meta description to articles...
$cols = getThings('describe `' . PFX . 'textpattern`');
if (!in_array('description', $cols)) {
    safe_alter('textpattern', "ADD description VARCHAR(255) NOT NULL DEFAULT '' AFTER Keywords");
}
// ... categories...
$cols = getThings('describe `' . PFX . 'txp_category`');
if (!in_array('description', $cols)) {
    safe_alter('txp_category', "ADD description VARCHAR(255) NOT NULL DEFAULT '' AFTER title");
}
// ... and sections.
$cols = getThings('describe `' . PFX . 'txp_section`');
if (!in_array('description', $cols)) {
    safe_alter('txp_section', "ADD description VARCHAR(255) NOT NULL DEFAULT '' AFTER css");
}
// Remove textpattern.com ping pref.
if (safe_field('name', 'txp_prefs', "name = 'ping_textpattern_com'")) {
    safe_delete('txp_prefs', "name = 'ping_textpattern_com'");
}
// Add default publishing status pref.
if (!get_pref('default_publish_status')) {
    set_pref('default_publish_status', STATUS_LIVE, 'publish', PREF_CORE, 'defaultPublishStatus', 15, PREF_PRIVATE);
}
开发者ID:hcgtv,项目名称:textpattern,代码行数:31,代码来源:_to_4.6.0.php

示例8: exit

 *
 * This file is part of Textpattern.
 *
 * Textpattern is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, version 2.
 *
 * Textpattern is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Textpattern. If not, see <http://www.gnu.org/licenses/>.
 */
if (!defined('TXP_UPDATE')) {
    exit("Nothing here. You can't access this file directly.");
}
// Updates comment email length.
safe_alter('txp_discuss', "MODIFY email VARCHAR(254) NOT NULL default ''");
// Store IPv6 properly in logs.
safe_alter('txp_log', "MODIFY ip VARCHAR(45) NOT NULL default ''");
// Save sections correctly in articles.
safe_alter('textpattern', "MODIFY Section VARCHAR(128) NOT NULL default ''");
// Ensure all memory-mappable columns have defaults
safe_alter('txp_form', "MODIFY `name` VARCHAR(64) NOT NULL default ''");
safe_alter('txp_page', "MODIFY `name` VARCHAR(128) NOT NULL default ''");
safe_alter('txp_prefs', "MODIFY `prefs_id` INT(11) NOT NULL default '1'");
safe_alter('txp_prefs', "MODIFY `name` VARCHAR(255) NOT NULL default ''");
safe_alter('txp_section', "MODIFY `name` VARCHAR(128) NOT NULL default ''");
开发者ID:hcgtv,项目名称:textpattern,代码行数:30,代码来源:_to_4.5.7.php

示例9: image_replace

function image_replace()
{
    global $txpcfg, $extensions, $txp_user, $img_dir, $path_from_root;
    extract($txpcfg);
    $id = gps('id');
    $file = $_FILES['thefile']['tmp_name'];
    $name = $_FILES['thefile']['name'];
    list($w, $h, $extension) = getimagesize($file);
    if ($extensions[$extension]) {
        $ext = $extensions[$extension];
        $name = substr($name, 0, strrpos($name, '.'));
        $name .= $ext;
        $name2db = doSlash($name);
        $rs = safe_update("txp_image", "w        = '{$w}',\n\t\t\t\t h        = '{$h}',\n\t\t\t\t ext      = '{$ext}',\n\t\t\t\t `name`   = '{$name2db}',\n\t\t\t\t `date`   = now(),\n\t\t\t\t author   = '{$txp_user}'", "id = {$id}\n\t\t\t");
        if (!$rs) {
            image_list('there was a problem saving image data');
        } else {
            $newpath = $doc_root . $path_from_root . $img_dir . '/' . $id . $ext;
            $newpath = str_replace('//', '/', $newpath);
            if (move_uploaded_file($file, $newpath) == false) {
                safe_delete("txp_image", "id='{$id}'");
                safe_alter("txp_image", "auto_increment={$id}");
                image_list($newpath . sp . gTxt('upload_dir_perms'));
            } else {
                chmod($newpath, 0755);
                image_edit(messenger('image', $name, 'uploaded'), $id);
            }
        }
    } else {
        image_list(gTxt('only_graphic_files_allowed'));
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:32,代码来源:txp_image.php

示例10: file_insert

function file_insert()
{
    global $txpcfg, $extensions, $txp_user, $file_base_path, $file_max_upload_size;
    extract($txpcfg);
    extract(doSlash(gpsa(array('category', 'permissions', 'description'))));
    $name = file_get_uploaded_name();
    $file = file_get_uploaded();
    if ($file === false) {
        // could not get uploaded file
        file_list(gTxt('file_upload_failed') . " {$name} - " . upload_get_errormsg(@$_FILES['file']['error']));
        return;
    }
    if ($file_max_upload_size < filesize($file)) {
        unlink($file);
        file_list(gTxt('file_upload_failed') . " {$name} - " . upload_get_errormsg(UPLOAD_ERR_FORM_SIZE));
        return;
    }
    if (!is_file(build_file_path($file_base_path, $name))) {
        $id = file_db_add($name, $category, $permissions, $description);
        if (!$id) {
            file_list(gTxt('file_upload_failed') . ' (db_add)');
        } else {
            $id = assert_int($id);
            $newpath = build_file_path($file_base_path, trim($name));
            if (!shift_uploaded_file($file, $newpath)) {
                safe_delete("txp_file", "id = {$id}");
                safe_alter("txp_file", "auto_increment={$id}");
                if (isset($GLOBALS['ID'])) {
                    unset($GLOBALS['ID']);
                }
                file_list($newpath . ' ' . gTxt('upload_dir_perms'));
                // clean up file
            } else {
                file_set_perm($newpath);
                $message = gTxt('file_uploaded', array('{name}' => $name));
                file_edit($message, $id);
            }
        }
    } else {
        $message = gTxt('file_already_exists', array('{name}' => $name));
        file_list($message);
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:43,代码来源:txp_file.php

示例11: mem_self_register_install

    function mem_self_register_install()
    {
        global $mem_self;
        extract(doSlash(gpsa(array('admin_email', 'admin_name', 'new_user_priv', 'use_ign_db', 'add_address', 'add_phone'))));
        if (!isset($new_user_priv) || empty($new_user_priv)) {
            $new_user_priv = '0';
        }
        $log = array();
        if (!($rs = safe_field('val,html', 'txp_prefs', "name='mem_self_use_ign_db'"))) {
            if (set_pref('mem_self_use_ign_db', $use_ign_db, 'self_reg', 1, 0, 'yesnoradio')) {
                $log[] = mem_self_gTxt('log_added_pref', array('{name}' => 'mem_self_use_ign_db'));
            } else {
                $log[] = mem_self_gTxt('log_pref_failed', array('{name}' => 'mem_self_use_ign_db', '{error}' => mysql_error()));
            }
        } else {
            if ($rs['html'] != 'yesnoradio') {
                safe_update('txp_prefs', "html='yesnoradio'", "name='mem_self_use_ign_db'");
            }
            $log[] = mem_self_gTxt('log_pref_exists', array('{name}' => 'mem_self_use_ign_db', '{value}' => $rs));
        }
        $user_table = mem_get_user_table_name();
        $xtra_columns = mem_get_extra_user_columns();
        if ($add_address) {
            if (!in_array('address', $xtra_columns)) {
                if (safe_alter($user_table, "ADD `address` VARCHAR( 128 )")) {
                    $log[] = mem_self_gTxt('log_col_added', array('{name}' => 'address', '{table}' => $user_table));
                } else {
                    $log[] = mem_self_gTxt('log_col_failed', array('{name}' => 'address', '{table}' => $user_table, '{error}' => mysql_error()));
                }
            } else {
                $log[] = mem_self_gTxt('log_col_exists', array('{name}' => 'address', '{table}' => $user_table));
            }
        }
        if ($add_phone) {
            if (!in_array('phone', $xtra_columns)) {
                if (safe_alter($user_table, "ADD `phone` VARCHAR( 32 )")) {
                    $log[] = mem_self_gTxt('log_col_added', array('{name}' => 'phone', '{table}' => $user_table));
                } else {
                    $log[] = mem_self_gTxt('log_col_failed', array('{name}' => 'phone', '{table}' => $user_table, '{error}' => mysql_error()));
                }
            } else {
                $log[] = mem_self_gTxt('log_col_exists', array('{name}' => 'phone', '{table}' => $user_table));
            }
        }
        if (!($rs = safe_field('val', 'txp_prefs', "name='mem_self_admin_email'"))) {
            if (set_pref('mem_self_admin_email', $admin_email, 'self_reg', 1)) {
                $log[] = mem_self_gTxt('log_added_pref', array('{name}' => 'mem_self_admin_email'));
            } else {
                $log[] = mem_self_gTxt('log_pref_failed', array('{name}' => 'mem_self_admin_email', '{error}' => mysql_error()));
            }
        } else {
            $log[] = mem_self_gTxt('log_pref_exists', array('{name}' => 'mem_self_admin_email', '{value}' => $rs));
        }
        if (!($rs = safe_field('val', 'txp_prefs', "name='mem_self_admin_name'"))) {
            if (set_pref('mem_self_admin_name', $admin_name, 'self_reg', 1)) {
                $log[] = mem_self_gTxt('log_added_pref', array('{name}' => 'mem_self_admin_name'));
            } else {
                $log[] = mem_self_gTxt('log_pref_failed', array('{name}' => 'mem_self_admin_name', '{error}' => mysql_error()));
            }
        } else {
            $log[] = mem_self_gTxt('log_pref_exists', array('{name}' => 'mem_self_admin_name', '{value}' => $rs));
        }
        if (!($rs = safe_row('val,html', 'txp_prefs', "name='mem_self_new_user_priv'"))) {
            if (set_pref('mem_self_new_user_priv', $new_user_priv, 'self_reg', 1, 0, 'priv_levels')) {
                $log[] = mem_self_gTxt('log_added_pref', array('{name}' => 'mem_self_new_user_priv'));
                $mem_self['new_user_priv'] = $new_user_priv;
            } else {
                $log[] = mem_self_gTxt('log_pref_failed', array('{name}' => 'mem_self_newuser_priv', '{error}' => mysql_error()));
            }
        } else {
            safe_update('txp_prefs', "html='priv_levels'", "name='mem_self_new_user_priv'");
            $log[] = mem_self_gTxt('log_pref_exists', array('{name}' => 'mem_self_new_user_priv', '{value}' => $rs));
        }
        // create default registration form
        $form_html = <<<EOF
\t<fieldset>
\t<legend>Register</legend>
\t\t<txp:mem_form_text name="RealName" label="Full Name" /><br />
\t\t<br />
\t\t
\t\t<txp:mem_form_text name="name" label="Username" /><br />
\t\t<br />
\t\t
\t\t<txp:mem_form_email name="email" label="E-Mail" /><br />
\t\t<br />

\t\t<txp:mem_form_submit />
\t</fieldset>
EOF;
        $form = fetch('Form', 'txp_form', 'name', 'self_register_form');
        if (!$form) {
            if (safe_insert('txp_form', "name='self_register_form',type='misc',Form='{$form_html}'")) {
                $log[] = mem_self_gTxt('log_form_added', array('{name}' => 'self_register_form'));
            } else {
                $log[] = mem_self_gTxt('log_form_failed', array('{name}' => 'self_register_form', '{error}' => mysql_error())) . br . '<textpattern style="width:300px;height:150px;">' . htmlspecialchars($form_html) . '</textarea>';
            }
        } else {
            $log[] = mem_self_gTxt('log_form_found', array('{name}' => 'self_register_form'));
        }
        // create default successful registration form to show the user
//.........这里部分代码省略.........
开发者ID:netcarver,项目名称:mem_self_register,代码行数:101,代码来源:mem_self_register.php

示例12: image_data

function image_data($file, $meta = '', $id = '', $uploaded = true)
{
    global $txpcfg, $txp_user, $prefs, $file_max_upload_size;
    $extensions = array(0, '.gif', '.jpg', '.png', '.swf');
    extract($txpcfg);
    $name = $file['name'];
    $error = $file['error'];
    $file = $file['tmp_name'];
    if ($uploaded) {
        $file = get_uploaded_file($file);
        if ($file_max_upload_size < filesize($file)) {
            unlink($file);
            return upload_get_errormsg(UPLOAD_ERR_FORM_SIZE);
        }
    }
    list($w, $h, $extension) = @getimagesize($file);
    if ($file !== false && @$extensions[$extension]) {
        $ext = $extensions[$extension];
        $name = doSlash(substr($name, 0, strrpos($name, '.')) . $ext);
        if ($meta == false) {
            $meta = array('category' => '', 'caption' => '', 'alt' => '');
        }
        extract(doSlash($meta));
        $q = "\n\t\t\tname = '{$name}',\n\t\t\text = '{$ext}',\n\t\t\tw = {$w},\n\t\t\th = {$h},\n\t\t\talt = '{$alt}',\n\t\t\tcaption = '{$caption}',\n\t\t\tcategory = '{$category}',\n\t\t\tdate = now(),\n\t\t\tauthor = '{$txp_user}'\n\t\t";
        if (empty($id)) {
            $rs = safe_insert('txp_image', $q);
            $id = $GLOBALS['ID'] = mysql_insert_id();
        } else {
            $id = assert_int($id);
            $rs = safe_update('txp_image', $q, "id = {$id}");
        }
        if (!$rs) {
            return gTxt('image_save_error');
        } else {
            $newpath = IMPATH . $id . $ext;
            if (shift_uploaded_file($file, $newpath) == false) {
                $id = assert_int($id);
                safe_delete('txp_image', "id = {$id}");
                safe_alter('txp_image', "auto_increment = {$id}");
                if (isset($GLOBALS['ID'])) {
                    unset($GLOBALS['ID']);
                }
                return $newpath . sp . gTxt('upload_dir_perms');
            } else {
                @chmod($newpath, 0644);
                // Auto-generate a thumbnail using the last settings
                if (isset($prefs['thumb_w'], $prefs['thumb_h'], $prefs['thumb_crop'])) {
                    img_makethumb($id, $prefs['thumb_w'], $prefs['thumb_h'], $prefs['thumb_crop']);
                }
                update_lastmod();
                $message = gTxt('image_uploaded', array('{name}' => $name));
                return array($message, $id);
            }
        }
    } else {
        // missing or invalid file
        if ($file === false) {
            return upload_get_errormsg($error);
        } else {
            return gTxt('only_graphic_files_allowed');
        }
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:63,代码来源:txplib_image.php

示例13: exit

if (!defined('TXP_UPDATE')) {
    exit("Nothing here. You can't access this file directly.");
}
$txpplugin = getThings('DESCRIBE `' . PFX . 'txp_plugin`');
if (!in_array('load_order', $txpplugin)) {
    safe_alter('txp_plugin', "ADD load_order TINYINT UNSIGNED NOT NULL DEFAULT 5");
}
// Enable XML-RPC server?
if (!safe_field("name", 'txp_prefs', "name = 'enable_xmlrpc_server'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'enable_xmlrpc_server', val = 0, type = 1, event = 'admin', html = 'yesnoradio', position = 130");
}
if (!safe_field("name", 'txp_prefs', "name = 'smtp_from'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'smtp_from', val = '', type = 1, event = 'admin', position = 110");
}
if (!safe_field("val", 'txp_prefs', "name = 'author_list_pageby'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'author_list_pageby', val = 25, type = 2");
}
// Expiry datetime for articles.
$txp = getThings("DESCRIBE `" . PFX . "textpattern`");
if (!in_array('Expires', $txp)) {
    safe_alter('textpattern', "ADD Expires DATETIME AFTER Posted");
}
safe_create_index('textpattern', 'Expires', 'Expires_idx');
// Publish expired articles, or return 410?
if (!safe_field("name", 'txp_prefs', "name = 'publish_expired_articles'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'publish_expired_articles', val = '0', type = '1', event = 'publish', html = 'yesnoradio', position = '130'");
}
// Searchable article fields hidden preference.
if (!safe_field("name", 'txp_prefs', "name = 'searchable_article_fields'")) {
    safe_insert('txp_prefs', "prefs_id = 1, name = 'searchable_article_fields', val = 'Title, Body', type = '2', event = 'publish', html = 'text_input', position = '0'");
}
开发者ID:scar45,项目名称:textpattern,代码行数:31,代码来源:_to_4.0.7.php

示例14: cleanup_4a_cb

 function cleanup_4a_cb($table, $field, $attributes)
 {
     $langs = MLPLanguageHandler::get_site_langs();
     foreach ($langs as $lang) {
         $f = _l10n_make_field_name($field, $lang);
         $sql = "DROP `{$f}`";
         $ok = @safe_alter($table, $sql);
         $this->add_report_item(gTxt('l10n-drop_field', array('{field}' => $f, '{table}' => $table)), $ok, true);
     }
 }
开发者ID:netcarver,项目名称:mlp_pack,代码行数:10,代码来源:l10n_admin_classes.php

示例15: file_insert

function file_insert()
{
    global $txpcfg, $extensions, $txp_user, $file_base_path;
    extract($txpcfg);
    extract(doSlash(gpsa(array('category', 'permissions', 'description'))));
    $name = file_get_uploaded_name();
    $file = file_get_uploaded();
    if ($file === false) {
        // could not get uploaded file
        file_list(gTxt('file_upload_failed') . " {$name} - " . upload_get_errormsg($_FILES['file']['error']));
        return;
    }
    if (!is_file(build_file_path($file_base_path, $name))) {
        $id = file_db_add($name, $category, $permissions, $description);
        if (!$id) {
            file_list(gTxt('file_upload_failed') . ' (db_add)');
        } else {
            $newpath = build_file_path($file_base_path, trim($name));
            if (!shift_uploaded_file($file, $newpath)) {
                safe_delete("txp_file", "id='{$id}'");
                safe_alter("txp_file", "auto_increment={$id}");
                file_list($newpath . ' ' . gTxt('upload_dir_perms'));
                // clean up file
            } else {
                file_set_perm($newpath);
                file_edit(messenger('file', $name, 'uploaded'), $id);
            }
        }
    } else {
        file_list(messenger(gTxt('file'), $name, gTxt('already_exists')));
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:32,代码来源:txp_file.php


注:本文中的safe_alter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。