function set_config($name, $value)
 {
     $fname = $this->instance . '/' . $name;
     if (is_array($value)) {
         $dbval = implode(',', $value);
     } else {
         $dbval = $value;
     }
     $_POST['serendipity']['plugin'][$name] = $dbval;
     $set = serendipity_set_config_var($fname, $dbval);
     $this->init_trusted();
     return $set;
 }
Example #2
0
     echo '<br />';
     echo CREATE_DATABASE;
     serendipity_installDatabase();
     echo ' <strong>' . DONE . '</strong><br />';
     echo sprintf(CREATING_PRIMARY_AUTHOR, htmlspecialchars($_POST['user'])) . '...';
     $authorid = serendipity_addAuthor($_POST['user'], $_POST['pass'], $_POST['realname'], $_POST['email'], USERLEVEL_ADMIN, 1);
     $mail_comments = serendipity_db_bool($_POST['want_mail']) ? 1 : 0;
     serendipity_set_user_var('mail_comments', $mail_comments, $authorid);
     serendipity_set_user_var('mail_trackbacks', $mail_comments, $authorid);
     serendipity_set_user_var('right_publish', 1, $authorid);
     serendipity_addDefaultGroup('USERLEVEL_EDITOR_DESC', USERLEVEL_EDITOR);
     serendipity_addDefaultGroup('USERLEVEL_CHIEF_DESC', USERLEVEL_CHIEF);
     serendipity_addDefaultGroup('USERLEVEL_ADMIN_DESC', USERLEVEL_ADMIN);
     echo ' <strong>' . DONE . '</strong><br />';
     echo SETTING_DEFAULT_TEMPLATE . '... ';
     serendipity_set_config_var('template', $serendipity['defaultTemplate']);
     echo ' <strong>' . DONE . '</strong><br />';
     echo INSTALLING_DEFAULT_PLUGINS . '... ';
     include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php';
     serendipity_plugin_api::register_default_plugins();
     echo ' <strong>' . DONE . '</strong><br />';
 }
 echo sprintf(ATTEMPT_WRITE_FILE, '.htaccess') . '... ';
 $errors = serendipity_installFiles($basedir);
 if ($errors === true) {
     echo ' <strong>' . DONE . '</strong><br />';
 } else {
     echo ' <strong>' . FAILED . '</strong><br />';
     foreach ($errors as $error) {
         echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . $error . '</div>';
     }
/**
 * Display the list of images in our database
 *
 * @access public
 * @param   int     The current page number
 * @param   string  The HTML linebreak to use after a row of images
 * @param   boolean Should the toolbar for editing media files be shown?
 * @param   string  The URL to use for pagination
 * @param   boolean Show the "upload media item" feature?
 * @param   boolean Restrict viewing images to a specific directory
 * @param   boolean  If TRUE, will echo Smarty output.
 * @return  string   Smarty block name
 */
function serendipity_displayImageList($page = 0, $lineBreak = NULL, $manage = false, $url = NULL, $show_upload = false, $limit_path = NULL, $smarty_display = true)
{
    global $serendipity;
    static $debug = false;
    $sortParams = array('perpage', 'order', 'ordermode');
    $importParams = array('adminModule', 'htmltarget', 'filename_only', 'textarea', 'subpage', 'keywords');
    $extraParems = '';
    $filterParams = array('only_path', 'only_filename');
    foreach ($importParams as $importParam) {
        if (isset($serendipity['GET'][$importParam])) {
            $extraParems .= 'serendipity[' . $importParam . ']=' . $serendipity['GET'][$importParam] . '&amp;';
        }
    }
    foreach ($sortParams as $sortParam) {
        serendipity_restoreVar($serendipity['COOKIE']['sortorder_' . $sortParam], $serendipity['GET']['sortorder'][$sortParam]);
        serendipity_JSsetCookie('sortorder_' . $sortParam, $serendipity['GET']['sortorder'][$sortParam]);
        $extraParems .= 'serendipity[sortorder][' . $sortParam . ']=' . $serendipity['GET']['sortorder'][$sortParam] . '&amp;';
    }
    foreach ($filterParams as $filterParam) {
        serendipity_restoreVar($serendipity['COOKIE'][$filterParam], $serendipity['GET'][$filterParam]);
        serendipity_JSsetCookie($filterParam, $serendipity['GET'][$filterParam]);
        if (!empty($serendipity['GET'][$filterParam])) {
            $extraParems .= 'serendipity[' . $filterParam . ']=' . $serendipity['GET'][$filterParam] . '&amp;';
        }
    }
    $serendipity['GET']['only_path'] = serendipity_uploadSecure($limit_path . $serendipity['GET']['only_path'], true);
    $serendipity['GET']['only_filename'] = str_replace(array('*', '?'), array('%', '_'), $serendipity['GET']['only_filename']);
    $perPage = !empty($serendipity['GET']['sortorder']['perpage']) ? $serendipity['GET']['sortorder']['perpage'] : 8;
    while ($perPage % $lineBreak !== 0) {
        $perPage++;
    }
    $start = ($page - 1) * $perPage;
    if ($manage && $limit_path == NULL) {
        ## SYNCH START ##
        $aExclude = array("CVS" => true, ".svn" => true);
        serendipity_plugin_api::hook_event('backend_media_path_exclude_directories', $aExclude);
        $paths = array();
        $aFilesOnDisk = array();
        $aResultSet = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $limit_path, '', false, NULL, 1, NULL, FALSE, $aExclude);
        foreach ($aResultSet as $sKey => $sFile) {
            if ($sFile['directory']) {
                if ($debug) {
                    echo "{$sFile['relpath']} is a directory.<br />";
                }
                array_push($paths, $sFile);
            } else {
                if ($debug) {
                    echo "{$sFile['relpath']} is a file.<br />";
                }
                // Store the file in our array, remove any ending slashes
                $aFilesOnDisk[$sFile['relpath']] = 1;
            }
            unset($aResultSet[$sKey]);
        }
        usort($paths, 'serendipity_sortPath');
        if ($debug) {
            echo "<p>Got files: <pre>" . print_r($aFilesOnDisk, true) . "</pre></p>";
        }
        $serendipity['current_image_hash'] = md5(serialize($aFilesOnDisk));
        $nTimeStart = microtime_float();
        // MTG 21/01/06: request all images from the database, delete any which don't exist
        // on the filesystem, and mark off files from the file list which are already
        // in the database
        $nCount = 0;
        if ($debug) {
            echo "<p>Image Sync Right: " . serendipity_checkPermission('adminImagesSync') . " Onthefly Sync: " . $serendipity['onTheFlySynch'] . " Hash: " . $serendipity['current_image_hash'] . "!=" . $serendipity['last_image_hash'] . "</p>";
        }
        if ($serendipity['onTheFlySynch'] && serendipity_checkPermission('adminImagesSync') && ($debug || $serendipity['current_image_hash'] != $serendipity['last_image_hash'])) {
            $aResultSet = serendipity_db_query("SELECT path, name, extension, thumbnail_name, id\n                                                FROM {$serendipity['dbPrefix']}images", false, 'assoc');
            if ($debug) {
                echo "<p>Got images: <pre>" . print_r($aResultSet, true) . "</pre></p>";
            }
            if (is_array($aResultSet)) {
                foreach ($aResultSet as $sKey => $sFile) {
                    serendipity_plugin_api::hook_event('backend_thumbnail_filename_select', $sFile);
                    $sThumbNailFile = '';
                    if (isset($sFile['thumbnail_filename'])) {
                        $sThumbNailFile = $sFile['thumbnail_filename'];
                    } else {
                        $sThumbNailFile = $sFile['path'] . $sFile['name'] . '.' . $sFile['thumbnail_name'] . '.' . $sFile['extension'];
                    }
                    $sFileName = $sFile['path'] . $sFile['name'] . '.' . $sFile['extension'];
                    if ($debug) {
                        echo "<p>File name is {$sFileName},<br />thumbnail is {$sThumbNailFile}</p>";
                    }
                    unset($aResultSet[$sKey]);
                    if (isset($aFilesOnDisk[$sFileName])) {
                        unset($aFilesOnDisk[$sFileName]);
                    } else {
                        if ($debug) {
                            echo "Deleting Image {$sFile['id']}<br />\n";
                        }
                        serendipity_deleteImage($sFile['id']);
                        ++$nCount;
                    }
                    unset($aFilesOnDisk[$sThumbNailFile]);
                }
            }
            if ($nCount > 0) {
                if ($debug) {
                    echo "<p>Cleaned up " . $nCount . " database entries</p>";
                }
            }
            serendipity_set_config_var('last_image_hash', $serendipity['current_image_hash'], 0);
            $aUnmatchedOnDisk = array_keys($aFilesOnDisk);
            if ($debug) {
                echo "<p>Got unmatched files: <pre>" . print_r($aUnmatchedOnDisk, true) . "</pre></p>";
            }
            $nCount = 0;
            foreach ($aUnmatchedOnDisk as $sFile) {
                if (preg_match('@\\.' . $serendipity['thumbSuffix'] . '\\.@', $sFile)) {
                    if ($debug) {
                        echo "<p>Skipping thumbnailed file {$sFile}</p>";
                    }
                    continue;
                } else {
                    if ($debug) {
                        echo "<p>Checking {$sFile}</p>";
                    }
                }
                // MTG: 21/01/06: put files which have just 'turned up' into the database
                $aImageData = serendipity_getImageData($sFile);
                if (serendipity_isImage($aImageData, false, '(image)|(video)|(audio)/')) {
                    $nPos = strrpos($sFile, "/");
                    if (is_bool($nPos) && !$nPos) {
                        $sFileName = $sFile;
                        $sDirectory = "";
                    } else {
                        ++$nPos;
                        $sFileName = substr($sFile, $nPos);
                        $sDirectory = substr($sFile, 0, $nPos);
                    }
                    if ($debug) {
                        echo "<p>Inserting image {$sFileName} from {$sDirectory} <pre>" . print_r($aImageData, true) . "</pre> into database</p>";
                    }
                    # TODO: Check if the thumbnail generation goes fine with Marty's code
                    serendipity_makeThumbnail($sFileName, $sDirectory);
                    serendipity_insertImageInDatabase($sFileName, $sDirectory);
                    ++$nCount;
                }
            }
            if ($nCount > 0) {
                if ($debug) {
                    echo "<p>Inserted " . $nCount . " images into the database</p>";
                }
            }
        } else {
            if ($debug) {
                echo "<p>Media Gallery database is up to date</p>";
            }
        }
        /*
         $nTimeEnd = microtime_float ( );
         $nDifference = $nTimeEnd - $nTimeStart;
         echo "<p> total time taken was " . $nDifference . "</p>";
        */
        ## SYNCH FINISHED ##
    }
    ## Aply ACL afterwards:
    serendipity_directoryACL($paths, 'read');
    $serendipity['imageList'] = serendipity_fetchImagesFromDatabase($start, $perPage, $totalImages, isset($serendipity['GET']['sortorder']['order']) ? $serendipity['GET']['sortorder']['order'] : false, isset($serendipity['GET']['sortorder']['ordermode']) ? $serendipity['GET']['sortorder']['ordermode'] : false, isset($serendipity['GET']['only_path']) ? $serendipity['GET']['only_path'] : '', isset($serendipity['GET']['only_filename']) ? $serendipity['GET']['only_filename'] : '', isset($serendipity['GET']['keywords']) ? $serendipity['GET']['keywords'] : '', isset($serendipity['GET']['filter']) ? $serendipity['GET']['filter'] : '');
    $pages = ceil($totalImages / $perPage);
    $linkPrevious = '?' . $extraParems . 'serendipity[page]=' . ($page - 1);
    $linkNext = '?' . $extraParems . 'serendipity[page]=' . ($page + 1);
    if (is_null($lineBreak)) {
        $lineBreak = floor(750 / ($serendipity['thumbSize'] + 20));
    }
    $dprops = $keywords = array();
    if ($serendipity['parseMediaOverview']) {
        $ids = array();
        foreach ($serendipity['imageList'] as $k => $file) {
            $ids[] = $file['id'];
        }
        $allprops =& serendipity_fetchMediaProperties($ids);
    }
    if (count($serendipity['imageList']) > 0) {
        foreach ($serendipity['imageList'] as $k => $file) {
            if (!($serendipity['authorid'] == $file['authorid'] || $file['authorid'] == '0' || serendipity_checkPermission('adminImagesViewOthers'))) {
                // This is a fail-safe continue. Basically a non-matching file should already be filtered in SQL.
                continue;
            }
            serendipity_prepareMedia($serendipity['imageList'][$k], $url);
            if ($serendipity['parseMediaOverview']) {
                $serendipity['imageList'][$k]['props'] =& $allprops[$file['id']];
                if (!is_array($serendipity['imageList'][$k]['props']['base_metadata'])) {
                    $serendipity['imageList'][$k]['metadata'] =& serendipity_getMetaData($serendipity['imageList'][$k]['realfile'], $serendipity['imageList'][$k]['header']);
                } else {
                    $serendipity['imageList'][$k]['metadata'] = $serendipity['imageList'][$k]['props']['base_metadata'];
                    serendipity_plugin_api::hook_event('media_getproperties_cached', $serendipity['imageList'][$k]['metadata'], $serendipity['imageList'][$k]['realfile']);
                }
                serendipity_parseMediaProperties($dprops, $keywords, $serendipity['imageList'][$k], $serendipity['imageList'][$k]['props'], 3, false);
            }
        }
    }
    $smarty_vars = array('limit_path' => $limit_path, 'perPage' => $perPage, 'show_upload' => $show_upload, 'page' => $page, 'pages' => $pages, 'linkNext' => $linkNext, 'linkPrevious' => $linkPrevious, 'extraParems' => $extraParems);
    return serendipity_showMedia($serendipity['imageList'], $paths, $url, $manage, $lineBreak, true, $smarty_vars, $smarty_display);
}
Example #4
0
    case 'publish':
        if (!serendipity_checkFormToken()) {
            break;
        }
        $success = serendipity_updertEntry(array('id' => serendipity_specialchars($serendipity['POST']['id']), 'timestamp' => time(), 'isdraft' => 0));
        if (is_numeric($success)) {
            $data['published'] = $success;
        } else {
            $data['error_publish'] = $success;
        }
        break;
    case 'updateCheckDisable':
        if (!serendipity_checkFormToken() || !serendipity_checkPermission('blogConfiguration')) {
            break;
        }
        serendipity_set_config_var('updateCheck', false);
        break;
}
$user = serendipity_fetchAuthor($serendipity['authorid']);
// chrome-compatible, from Oliver Gassner, adapted from TextPattern. Hi guys, keep it up. :-)
$bookmarklet = "javascript:var%20d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),f='" . $serendipity['baseURL'] . "',l=d.location,e=encodeURIComponent,p='serendipity_admin.php?serendipity[adminModule]=entries&serendipity[adminAction]=new&serendipity[title]='+e(d.title)+'&serendipity[body]='+e(s)+'&serendipity[url]='+location.href,u=f+p;a=function(){%20%20if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=800,height=800'))%20%20%20%20l.href=u;};if(/Firefox/.test(navigator.userAgent))%20%20setTimeout(a,0);else%20%20a();void(0)";
$data['bookmarklet'] = $bookmarklet;
$data['username'] = $user[0]['realname'];
$data['js_failure_file'] = serendipity_getTemplateFile('admin/serendipity_editor.js');
$output = array();
serendipity_plugin_api::hook_event('backend_frontpage_display', $output);
$data['backend_frontpage_display'] = $output['more'];
$data['usedVersion'] = $serendipity['version'];
$data['updateCheck'] = $serendipity['updateCheck'];
$data['curVersion'] = serendipity_getCurrentVersion();
$data['update'] = version_compare($data['usedVersion'], $data['curVersion'], '<');
Example #5
0
                                     }
                 */
                 continue;
             }
             // Moved to group administration:
             if ($item['var'] == 'userlevel') {
                 continue;
             }
             if ($item['view'] == 'dangerous') {
                 continue;
             }
             if (serendipity_checkConfigItemFlags($item, 'local')) {
                 serendipity_set_user_var($item['var'], $_POST[$item['var']], $serendipity['authorid'], true);
             }
             if (serendipity_checkConfigItemFlags($item, 'configuration')) {
                 serendipity_set_config_var($item['var'], $_POST[$item['var']], $serendipity['authorid']);
             }
         }
         $pl_data = array('id' => $serendipity['POST']['authorid'], 'authorid' => $serendipity['POST']['authorid'], 'username' => $_POST['username'], 'realname' => $_POST['realname'], 'email' => $_POST['email']);
         serendipity_updatePermalink($pl_data, 'author');
         serendipity_plugin_api::hook_event('backend_users_edit', $pl_data);
     }
     if ($serendipity['authorid'] === $_SESSION['serendipityAuthorid']) {
         if (is_null($serendipity['detected_lang'])) {
             $_SESSION['serendipityLanguage'] = $serendipity['lang'];
         }
     }
     $from = $_POST;
     ?>
 <div class="serendipityAdminMsgSuccess"><img width="22px" height="22px" style="border: 0px; padding-right: 4px; vertical-align: middle" src="<?php 
     echo serendipity_getTemplateFile('admin/img/admin_msg_success.png');
/**
 * Return the SHA1 (with pre-hash) of a value
 *
 * @param string    The string to hash
 * @return string   The hashed string
 */
function serendipity_hash($string)
{
    global $serendipity;
    if (empty($serendipity['hashkey'])) {
        serendipity_set_config_var('hashkey', time(), 0);
    }
    return sha1($serendipity['hashkey'] . $string);
}
 /**
  * Sets a configuration value for a plugin
  *
  * @access public
  * @param   string  Name of the plugin configuration item
  * @param   string  Value of the plugin configuration item
  * @param   string  A concatenation key for imploding arrays
  * @return
  */
 function set_config($name, $value, $implodekey = '^')
 {
     $name = $this->instance . '/' . $name;
     if (is_array($value)) {
         $dbvalue = implode($implodekey, $value);
         $_POST['serendipity']['plugin'][$name] = $dbvalue;
     } else {
         $dbvalue = $value;
     }
     return serendipity_set_config_var($name, $dbvalue);
 }
Example #8
0
 function import_table(&$s9ydb, $table, $primary_keys, $where = null, $dupe_check = false, $fix_relations = false, $skip_dupes = false)
 {
     global $serendipity;
     echo "<span class='block_level'>Starting with table <strong>{$table}</strong>...</span>";
     if ($dupe_check) {
         $dupes = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}" . $table . " " . $where, false, 'both', false, $dupe_check);
         if (!$this->execute) {
             echo 'Dupe-Check: <pre>' . print_r($dupes, true) . '</pre>';
         }
     }
     $res = $this->nativeQuery("SELECT * FROM {$this->data['prefix']}" . $table . " " . $where, $s9ydb);
     echo mysqli_error($s9ydb);
     if (!$res || mysqli_num_rows($res) < 1) {
         return false;
     }
     $this->counter = 100;
     while ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
         $this->counter++;
         if (is_array($primary_keys)) {
             foreach ($primary_keys as $primary_key) {
                 $primary_vals[$primary_key] = $row[$primary_key];
                 if ($table == 'comments') {
                     $primary_vals['entry_id'] = $row['entry_id'];
                 }
                 unset($row[$primary_key]);
             }
         } else {
             $primary_vals = array();
         }
         $insert = true;
         if (is_array($fix_relations)) {
             foreach ($fix_relations as $primary_key => $fix_relation) {
                 foreach ($fix_relation as $fix_relation_table => $fix_relation_primary_key) {
                     if ($table == 'comments' && $fix_relation_table == 'entries') {
                         $assoc_val = $primary_vals['entry_id'];
                     } elseif (isset($primary_vals[$fix_relation_primary_key])) {
                         $assoc_val = $primary_vals[$fix_relation_primary_key];
                     } else {
                         $assoc_val = $row[$primary_key];
                     }
                     if (!$this->execute && empty($assoc_val)) {
                         if ($this->debug) {
                             echo '<pre>';
                             print_r($row);
                             print_r($fix_relation);
                             echo '</pre>';
                         }
                     }
                     $new_val = $this->storage[$fix_relation_table][$fix_relation_primary_key][$assoc_val];
                     if ($skip_dupes && $assoc_val == $new_val) {
                         $insert = false;
                     }
                     if (!empty($new_val)) {
                         $row[$primary_key] = $new_val;
                     }
                     if (!$this->execute && $this->debug) {
                         echo "<span>Fix relation from {$fix_relation_table}.{$fix_relation_primary_key}={$primary_vals[$fix_relation_primary_key]} to {$row[$primary_key]} (assoc_val: {$assoc_val})</span>";
                     }
                 }
             }
         }
         if ($insert) {
             if ($dupe_check && isset($dupes[$row[$dupe_check]])) {
                 if ($this->debug) {
                     echo "Skipping duplicate: <pre>" . print_r($dupes[$row[$dupe_check]], true) . "</pre>";
                 }
                 foreach ($primary_vals as $primary_key => $primary_val) {
                     $this->storage[$table][$primary_key][$primary_val] = $dupes[$row[$dupe_check]][$primary_key];
                     $this->storage['dupes'][$table][$primary_key][$primary_val] = $dupes[$row[$dupe_check]][$primary_key];
                 }
             } elseif ($this->execute) {
                 serendipity_db_insert($table, $this->strtrRecursive($row));
                 foreach ($primary_vals as $primary_key => $primary_val) {
                     $dbid = serendipity_db_insert_id($table, $primary_key);
                     $this->storage[$table][$primary_key][$primary_val] = $dbid;
                 }
                 echo "<span class='block_level'>Migrated entry #{$dbid} into {$table}.</span>";
             } else {
                 if ($this->debug) {
                     echo 'DB Insert: <pre>' . print_r($row, true) . '</pre>';
                 }
                 foreach ($primary_vals as $primary_key => $primary_val) {
                     $this->storage[$table][$primary_key][$primary_val] = $this->counter;
                 }
             }
             foreach ($this->storage[$table] as $primary_key => $primary_data) {
                 foreach ($primary_data as $primary_val => $replace_val) {
                     serendipity_set_config_var('import_s9y_' . $table . '_' . $primary_key . '_' . $primary_val, $replace_val, 99);
                 }
             }
         } else {
             if ($this->debug && !$this->execute) {
                 echo "<span class='block_level'>Ignoring Duplicate.</span>";
             }
         }
     }
     if (!$this->execute) {
         echo 'Storage on ' . $table . ':<pre>' . print_r($this->storage[$table], true) . '</pre>';
     } else {
         echo "<span class='block_level'>Finished table <strong>{$table}</strong></span>";
     }
 }
/**
 * When paths or other options are changed in the s9y configuration, update the core files
 *
 * @access public
 * @return boolean
 */
function serendipity_updateConfiguration()
{
    global $serendipity, $umask;
    // Save all basic config variables to the database
    $config = serendipity_parseTemplate(S9Y_CONFIG_TEMPLATE);
    if (isset($_POST['sqlitedbName']) && !empty($_POST['sqlitedbName'])) {
        $_POST['dbName'] = $_POST['sqlitedbName'];
    }
    // Password can be hidden in re-configuring, but we need to store old password
    if (empty($_POST['dbPass']) && !empty($serendipity['dbPass'])) {
        $_POST['dbPass'] = $serendipity['dbPass'];
    }
    foreach ($config as $category) {
        foreach ($category['items'] as $item) {
            /* Don't save trash */
            if (!serendipity_checkConfigItemFlags($item, 'configuration')) {
                continue;
            }
            if (!isset($item['userlevel'])) {
                $item['userlevel'] = USERLEVEL_ADMIN;
            }
            // Check permission set. Changes to blogConfiguration or siteConfiguration items
            // always required authorid = 0, so that it be not specific to a userlogin
            if ($serendipity['serendipityUserlevel'] >= $item['userlevel'] || IS_installed === false) {
                $authorid = 0;
            } elseif ($item['permission'] == 'blogConfiguration' && serendipity_checkPermission('blogConfiguration')) {
                $authorid = 0;
            } elseif ($item['permission'] == 'siteConfiguration' && serendipity_checkPermission('siteConfiguration')) {
                $authorid = 0;
            } else {
                $authorid = $serendipity['authorid'];
            }
            if (is_array($_POST[$item['var']])) {
                // Arrays not allowed. Use first index value.
                list($a_key, $a_val) = each($_POST[$item['var']]);
                $_POST[$item['var']] = $a_key;
                // If it still is an array, munge it all together.
                if (is_array($_POST[$item['var']])) {
                    $_POST[$item['var']] = @implode(',', $_POST[$item['var']]);
                }
            }
            serendipity_set_config_var($item['var'], $_POST[$item['var']], $authorid);
        }
    }
    if (IS_installed === false || serendipity_checkPermission('siteConfiguration')) {
        return serendipity_updateLocalConfig($_POST['dbName'], $_POST['dbPrefix'], $_POST['dbHost'], $_POST['dbUser'], $_POST['dbPass'], $_POST['dbType'], $_POST['dbPersistent']);
    } else {
        return true;
    }
}
Example #10
0
        }
        return true;
    }
    function import(&$config)
    {
        foreach ($config as $key => $item) {
            $this->config[$item['var']] = $item;
            $this->keys[$item['var']] = $item['var'];
        }
    }
}
if ($serendipity['GET']['adminAction'] == 'install') {
    serendipity_plugin_api::hook_event('backend_templates_fetchtemplate', $serendipity);
    $themeInfo = serendipity_fetchTemplateInfo(htmlspecialchars($serendipity['GET']['theme']));
    serendipity_set_config_var('template', htmlspecialchars($serendipity['GET']['theme']));
    serendipity_set_config_var('template_engine', isset($themeInfo['engine']) ? $themeInfo['engine'] : 'default');
    echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . sprintf(TEMPLATE_SET, htmlspecialchars($serendipity['GET']['theme'])) . '</div>';
}
?>

<?php 
if (@file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/layout.php')) {
    echo '<div class="serendipityAdminMsgNote"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_note.png') . '" alt="" />' . WARNING_TEMPLATE_DEPRECATED . '</div>';
}
echo '<h3>' . STYLE_OPTIONS . ' (' . $serendipity['template'] . ')</h3>';
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php')) {
    serendipity_smarty_init();
    include_once $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php';
}
if (is_array($template_config)) {
    serendipity_plugin_api::hook_event('backend_templates_configuration_top', $template_config);
Example #11
0
    // A separate hook is used post installation, for plugins to possibly perform some actions
    serendipity_plugin_api::hook_event('backend_templates_install', $serendipity['GET']['theme'], $themeInfo);
    if ($serendipity['GET']['adminAction'] == 'install' || $serendipity['GET']['adminAction'] == 'install-frontend') {
        serendipity_set_config_var('template', serendipity_specialchars($serendipity['GET']['theme']));
    }
    if ($serendipity['GET']['adminAction'] == 'install-backend' && $themeInfo['custom_admin_interface'] == YES) {
        serendipity_set_config_var('template_backend', serendipity_specialchars($serendipity['GET']['theme']));
    } else {
        // template_engine was set by default to default, which screws up the fallback chain (to the default-template first)
        // The "Engine" now only applies to FRONTEND themes. Backend themes will always fall back to our default backend theme only, to ensure proper backend operation.
        serendipity_set_config_var('template_engine', null);
        if ($themeInfo['engine']) {
            serendipity_set_config_var('template_engine', $themeInfo['engine']);
        }
    }
    serendipity_set_config_var('last_template_change', time());
    $data["adminAction"] = "install";
    $data["install_template"] = serendipity_specialchars($serendipity['GET']['theme']);
}
if (@file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/layout.php')) {
    $data["deprecated"] = true;
}
$data["cur_template"] = $serendipity['template'];
$data["cur_template_backend"] = $serendipity['template_backend'];
$data['cur_template_info'] = serendipity_fetchTemplateInfo($serendipity['template']);
// NOTE: config.inc.php currently only applies to frontend configuration. Backend configuration is not planned yet, and would preferrably use a "config_backend.inc.php" file!
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $data['cur_template_info']['custom_config_engine'] . '/config.inc.php')) {
    serendipity_smarty_init();
    $old_template_config_groups = $template_config_groups;
    include_once $serendipity['serendipityPath'] . $serendipity['templatePath'] . $data['cur_template_info']['custom_config_engine'] . '/config.inc.php';
    // in case of theme switch, check to unset config_group array
 function forkTemplate()
 {
     global $serendipity;
     $template_path = $serendipity['serendipity_path'] . $serendipity['templatePath'];
     $cur_template = $serendipity['template'];
     //fork only if not already forked
     $info_txt = file_get_contents($template_path . $cur_template . '/info.txt');
     $forked = false;
     if (strpos($info_txt, 'Fork_of:') !== false) {
         $forked = true;
     }
     if (!$forked) {
         $fork_template = $cur_template . '_fork';
         if (is_writable($template_path)) {
             if (!is_dir($template_path . $fork_template)) {
                 $this->copy_directory($template_path . $cur_template, $template_path . $fork_template);
                 $info_txt = preg_replace('/Name: (.*)/', 'Name: ${1}_fork', $info_txt);
                 $info_txt = $info_txt . "\nFork_of: {$cur_template}";
                 file_put_contents($template_path . $fork_template . '/info.txt', $info_txt);
             }
             //Now that the fork is created we need to set it instantly
             //but only if copying succeeded
             if (is_dir($template_path . $fork_template)) {
                 $themeInfo = serendipity_fetchTemplateInfo(function_exists('serendipity_specialchars') ? serendipity_specialchars($fork_template) : htmlspecialchars($fork_template, ENT_COMPAT, LANG_CHARSET));
                 serendipity_set_config_var('template', function_exists('serendipity_specialchars') ? serendipity_specialchars($fork_template) : htmlspecialchars($fork_template, ENT_COMPAT, LANG_CHARSET));
                 serendipity_set_config_var('template_engine', isset($themeInfo['engine']) ? $themeInfo['engine'] : 'default');
             }
         } else {
             echo 'Error: Template Directory not writeable';
             return false;
         }
     }
     return true;
 }
/**
 * baseURL is now defaultBaseURL in the database, so copy if not already set
 *
 * */
function serendipity_copyBaseURL()
{
    global $serendipity;
    if ((serendipity_get_config_var("defaultBaseURL") === false || serendipity_get_config_var("defaultBaseURL") == "") && serendipity_get_config_var("baseURL") !== false) {
        serendipity_set_config_var("defaultBaseURL", serendipity_get_config_var("baseURL"));
    }
}
/**
 * Check https://raw.github.com/s9y/Serendipity/master/docs/RELEASE for the newest available version
 *
 * If the file is not fetch- or parseable (behind a proxy, malformed by Garvin), this will return -1
 * */
function serendipity_getCurrentVersion()
{
    global $serendipity;
    if ($serendipity['updateCheck'] != "stable" && $serendipity['updateCheck'] != "beta") {
        return -1;
    }
    // Perform update check once a day. We use a suffix of the configured channel, so when
    // the user switches channels, it has its own timer.
    if ($serendipity['last_update_check_' . $serendipity['updateCheck']] >= time() - 86400) {
        // Last update was performed less than a day ago. Return last result.
        return $serendipity['last_update_version_' . $serendipity['updateCheck']];
    }
    serendipity_set_config_var('last_update_check_' . $serendipity['updateCheck'], time());
    $updateURL = 'https://raw.githubusercontent.com/s9y/Serendipity/master/docs/RELEASE';
    $context = stream_context_create(array('http' => array('timeout' => 5.0)));
    $file = @file_get_contents($updateURL, false, $context);
    if (!$file) {
        if (function_exists('curl_init')) {
            $ch = curl_init($updateURL);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT, "5");
            $file = curl_exec($ch);
            curl_close($ch);
        }
    }
    if ($file) {
        if ($serendipity['updateCheck'] == "stable") {
            if (preg_match('/^stable:(.+)\\b/m', $file, $match)) {
                serendipity_set_config_var('last_update_version_' . $serendipity['updateCheck'], $match[1]);
                return $match[1];
            }
        } else {
            if (preg_match('/^beta:(.+)\\b/m', $file, $match)) {
                serendipity_set_config_var('last_update_version_' . $serendipity['updateCheck'], $match[1]);
                return $match[1];
            }
        }
    }
    return -1;
}
Example #15
0
 static function checkuser($usergroups = array())
 {
     global $serendipity;
     static $debug = false;
     if (!empty($serendipity['GET']['adduser_activation']) && !empty($_GET['r'])) {
         $string = $serendipity['GET']['adduser_activation'];
         $q = "SELECT * FROM {$serendipity['dbPrefix']}pending_authors WHERE hash = '" . serendipity_db_escape_string($string) . "' LIMIT 1";
         if ($debug) {
             echo "[debug] QUERY: {$q}<br />\n";
         }
         $author = serendipity_db_query($q, true);
         serendipity_common_adduser::sendMail($author['username'], function_exists('serendipity_specialchars') ? serendipity_specialchars($string) : htmlspecialchars($string, ENT_COMPAT, LANG_CHARSET), $author['email'], false, false);
         echo PLUGIN_ADDUSER_SENTMAIL_APPROVE_ADMIN;
         return true;
     }
     if (!empty($serendipity['GET']['adduser_activation'])) {
         $string = $serendipity['GET']['adduser_activation'];
         unset($serendipity['GET']['adduser_activation']);
         if (strlen($string) != 32) {
             echo PLUGIN_ADDUSER_WRONG_ACTIVATION . '<hr />';
             return false;
         }
         $q = "SELECT * FROM {$serendipity['dbPrefix']}pending_authors WHERE hash = '" . serendipity_db_escape_string($string) . "' LIMIT 1";
         if ($debug) {
             echo "[debug] QUERY: {$q}<br />\n";
         }
         $author = serendipity_db_query($q, true);
         if ($debug) {
             echo "[debug] RESULT: " . print_r($author, true) . "<br />\n";
         }
         if (is_array($author)) {
             $user = serendipity_db_query("SELECT authorid FROM {$serendipity['dbPrefix']}authors WHERE username = '******'username']) . "'", true);
             if (is_array($user) && !empty($user['authorid'])) {
                 printf(PLUGIN_ADDUSER_EXISTS . '<hr />', function_exists('serendipity_specialchars') ? serendipity_specialchars($author['username']) : htmlspecialchars($author['username'], ENT_COMPAT, LANG_CHARSET));
                 return false;
             }
             $newID = serendipity_addAuthor($author['username'], '', $author['username'], $author['email'], $author['userlevel']);
             if ($debug) {
                 echo "[debug] serendipity_addAuthor: {$newID}<br />\n";
             }
             if ($newID) {
                 serendipity_db_query("UPDATE {$serendipity['dbPrefix']}authors\n                                             SET right_publish = '" . ($author['right_publish'] ? '1' : '0') . "',\n                                                 password      = '******'password'] . "'\n                                           WHERE authorid = " . (int) $newID);
                 serendipity_set_config_var('no_create', $author['no_create'], $newID);
                 serendipity_set_config_var('lang', $serendipity['lang'], $newID);
                 // Fetch default properties for new authors as configured.
                 // Only set values for the keys that are supported (all booleans currently!)
                 $config = serendipity_db_query("SELECT name, value FROM {$serendipity['dbPrefix']}config WHERE name LIKE 'serendipity_plugin_adduser:%'");
                 $pair_config = array('wysiwyg' => '', 'simpleFilters' => '', 'enableBackendPopup' => '', 'moderateCommentsDefault' => '', 'allowCommentsDefault' => '', 'showMediaToolbar' => '', 'use_autosave' => '');
                 if (is_array($config)) {
                     foreach ($config as $conf) {
                         $names = explode('/', $conf['name']);
                         if (isset($pair_config[$names[1]])) {
                             $pair_config[$names[1]] = serendipity_get_bool($conf['value']);
                             serendipity_set_config_var($names[1], $pair_config['wysiwyg'], $newID);
                         }
                     }
                 }
                 if (is_array($usergroups) && function_exists('serendipity_updateGroups')) {
                     if ($debug) {
                         echo "[debug] update groups: " . print_r($usergroups, true) . "<br />\n";
                     }
                     serendipity_updateGroups($usergroups, $newID, false);
                 } elseif ($debug) {
                     echo "[debug] no group addition: " . print_r($usergroups, true) . "<br />\n";
                 }
             } elseif ($debug) {
                 echo "[debug] serendipity_addAuthor() failed!<br />\n";
             }
         }
         $q = "SELECT authorid FROM {$serendipity['dbPrefix']}authors\n                                             WHERE username = '******'username'] . "'\n                                               AND password = '******'password'] . "'\n                                             LIMIT 1";
         $newauthor = serendipity_db_query($q, true);
         if (is_array($newauthor) && $newauthor['authorid'] > 0) {
             echo PLUGIN_ADDUSER_SUCCEED . '<hr />';
             serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}pending_authors WHERE hash = '" . serendipity_db_escape_string($string) . "'");
             return true;
         } else {
             if ($debug) {
                 echo "[debug] QUERY: {$q}<br />\n";
                 echo "[debug] RESULT: " . print_r($newauthor, true) . "<br />\n";
             }
             echo PLUGIN_ADDUSER_FAILED . '<hr />';
             return false;
         }
     }
     return false;
 }
Example #16
0
                        }
                    } else {
                        continue;
                    }
                    if (count($_POST[$item['var']]) < 1) {
                        echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />' . WARNING_NO_GROUPS_SELECTED . '</div>';
                    } else {
                        serendipity_updateGroups($_POST[$item['var']], $serendipity['POST']['user'], false);
                    }
                    continue;
                }
                if (serendipity_checkConfigItemFlags($item, 'local')) {
                    serendipity_set_user_var($item['var'], $_POST[$item['var']], $serendipity['POST']['user'], $serendipity['authorid'] == $serendipity['POST']['user'] ? true : false);
                }
                if (serendipity_checkConfigItemFlags($item, 'configuration')) {
                    serendipity_set_config_var($item['var'], $_POST[$item['var']], $serendipity['POST']['user']);
                }
            }
        }
        $pl_data = array('id' => $serendipity['POST']['authorid'], 'authorid' => $serendipity['POST']['authorid'], 'username' => $_POST['username'], 'realname' => $_POST['realname'], 'email' => $_POST['email']);
        serendipity_updatePermalink($pl_data, 'author');
        serendipity_plugin_api::hook_event('backend_users_edit', $pl_data);
        printf('<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . MODIFIED_USER . '</div>', htmlspecialchars($_POST['realname']));
    }
}
if ($serendipity['GET']['adminAction'] != 'delete') {
    ?>
    <table width="100%">
        <tr>
            <td><strong><?php 
    echo USER;