Example #1
0
    $blog['post_content'] = $post_content_short;
    $towrite = '<?php $post=' . var_export($blog, true) . ';';
    $fileop->file_put_contents(_CACHEPATH_ . '/blogs/posts/' . $blog['post_id'][0] . '/' . $blog['post_id'] . '_short.inc.php', $towrite);
    if (!isset($blog_details[$blog['fk_blog_id']])) {
        $query = "SELECT `blog_id`,`blog_name`,`blog_diz`,`blog_skin`,`fk_user_id`,`alt_url` FROM `{$dbtable_prefix}user_blogs` WHERE `blog_id`=" . $blog['fk_blog_id'];
        if (!($res2 = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        if (mysql_num_rows($res2)) {
            $blog_details = mysql_fetch_assoc($res2);
            $blog_details['blog_name'] = sanitize_and_format($blog_details['blog_name'], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
            $blog_details['blog_diz'] = sanitize_and_format($blog_details['blog_diz'], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
        }
    }
    if (!is_dir(_CACHEPATH_ . '/blogs/' . $blog_details['blog_id'][0] . '/' . $blog_details['blog_id'])) {
        $fileop->mkdir(_CACHEPATH_ . '/blogs/' . $blog_details['blog_id'][0] . '/' . $blog_details['blog_id']);
    }
    $towrite = '<?php $blog=' . var_export($blog_details, true) . ';';
    $fileop->file_put_contents(_CACHEPATH_ . '/blogs/' . $blog_details['blog_id'][0] . '/' . $blog_details['blog_id'] . '/blog.inc.php', $towrite);
    $year = (int) date('Y', $last_approved);
    $month = (int) date('m', $last_approved);
    if (isset($blog_archive[$blog['fk_blog_id']][$year][$month])) {
        $blog_archive[$blog['fk_blog_id']][$year][$month] += 1;
    } else {
        $blog_archive[$blog['fk_blog_id']][$year][$month] = 1;
    }
}
foreach ($blog_archive as $bid => $archive) {
    krsort($archive, SORT_NUMERIC);
    $bid = (string) $bid;
    $towrite = '<?php $blog_archive=' . var_export($archive, true) . ';';
Example #2
0
 function install($install_index, $skip_input = -1)
 {
     $this->ui = '';
     if (isset($this->install[$install_index]['input']) && $skip_input != $install_index) {
         $this->ui = (require_once $this->package_path . '/' . $this->install[$install_index]['input']);
         $this->error = false;
     } else {
         $modfile = $this->package_path . '/' . $this->install[$install_index]['file'];
         $mod_content = file_get_contents($modfile);
         $fileop = new fileop();
         $mydoc = new XML_dsb();
         $mydoc->parseXML($mod_content);
         $mod_command = $mydoc->firstChild->firstChild;
         while ($mod_command) {
             if ($mod_command->nodeName == 'php') {
                 // artificially create a block
                 // inside the included file we're still in this class!!
                 // this php file can generate errors of type critical which halt the execution of installer
                 $mod_command->firstChild->nodeValue = str_replace(array('{package_path}', '{basepath}'), array($this->package_path, _BASEPATH_), $mod_command->firstChild->nodeValue);
                 require_once $mod_command->firstChild->nodeValue;
                 // end block
             } elseif ($mod_command->nodeName == 'diff') {
                 if (isset($mod_command->attributes['force_revision'])) {
                     $force_revision = true;
                 } else {
                     $force_revision = false;
                 }
                 if (!$this->_do_diff($this->package_path . '/' . $mod_command->firstChild->nodeValue, $force_revision)) {
                     $this->error = true;
                     $masize = count($this->manual_actions);
                     $this->manual_actions[$masize]['type'] = 'diff';
                     $this->manual_actions[$masize]['from'] = $this->package_path . '/' . $mod_command->firstChild->nodeValue;
                     $this->manual_actions[$masize]['to'] = '';
                     $this->manual_actions[$masize]['error'] = $this->error_text;
                 }
             } elseif ($mod_command->nodeName == 'copy') {
                 $attrs = $mod_command->attributes;
                 $attrs['from'] = str_replace(array('{package_path}', '{basepath}'), array($this->package_path, _BASEPATH_), $attrs['from']);
                 $attrs['to'] = str_replace(array('{package_path}', '{basepath}'), array($this->package_path, _BASEPATH_), $attrs['to']);
                 if (isset($attrs['type']) && $attrs['type'] == 'skin') {
                     foreach ($GLOBALS['skins'] as $mc => $mdir) {
                         $temp = str_replace('{skin}', $mdir, $attrs['from']);
                         $temp1 = str_replace('{skin}', $mdir, $attrs['to']);
                         if (!$fileop->copy($temp, $temp1)) {
                             $this->error = true;
                             $masize = count($this->manual_actions);
                             $this->manual_actions[$masize]['type'] = 'copy';
                             $this->manual_actions[$masize]['from'] = $temp;
                             $this->manual_actions[$masize]['to'] = $temp1;
                             $this->manual_actions[$masize]['error'] = sprintf('Unable to copy file %1$s to %2$s', $temp, $temp1);
                         }
                     }
                 } else {
                     if (!$fileop->copy($attrs['from'], $attrs['to'])) {
                         $this->error = true;
                         $masize = count($this->manual_actions);
                         $this->manual_actions[$masize]['type'] = 'copy';
                         $this->manual_actions[$masize]['from'] = $attrs['from'];
                         $this->manual_actions[$masize]['to'] = $attrs['to'];
                         $this->manual_actions[$masize]['error'] = sprintf('Unable to copy file %1$s to %2$s', $attrs['from'], $attrs['to']);
                     }
                 }
             } elseif ($mod_command->nodeName == 'delete') {
                 $attrs = $mod_command->attributes;
                 $attrs['file'] = str_replace(array('{package_path}', '{basepath}'), array($this->package_path, _BASEPATH_), $attrs['file']);
                 if (isset($attrs['type']) && $attrs['type'] == 'skin') {
                     foreach ($GLOBALS['skins'] as $mc => $mdir) {
                         $temp = str_replace('{skin}', $mdir, $attrs['file']);
                         if (!$fileop->delete($temp)) {
                             $this->error = true;
                             $masize = count($this->manual_actions);
                             $this->manual_actions[$masize]['type'] = 'delete';
                             $this->manual_actions[$masize]['from'] = $temp;
                             $this->manual_actions[$masize]['to'] = '';
                             $this->manual_actions[$masize]['error'] = 'Unable to automatically delete file.';
                         }
                     }
                 } else {
                     if (!$fileop->delete($attrs['file'])) {
                         $this->error = true;
                         $masize = count($this->manual_actions);
                         $this->manual_actions[$masize]['type'] = 'delete';
                         $this->manual_actions[$masize]['from'] = $attrs['file'];
                         $this->manual_actions[$masize]['to'] = '';
                         $this->manual_actions[$masize]['error'] = "Unable to automatically delete file.";
                     }
                 }
             } elseif ($mod_command->nodeName == 'extract') {
                 $attrs = $mod_command->attributes;
                 $attrs['archive'] = str_replace(array('{package_path}', '{basepath}'), array($this->package_path, _BASEPATH_), $attrs['archive']);
                 $attrs['to'] = str_replace(array('{package_path}', '{basepath}'), array($this->package_path, _BASEPATH_), $attrs['to']);
                 if (isset($attrs['type']) && $attrs['type'] == 'zip') {
                     if (!$fileop->extract_zip($attrs['archive'], $attrs['to'])) {
                         $this->error = true;
                         $masize = count($this->manual_actions);
                         $this->manual_actions[$masize]['type'] = 'extract';
                         $this->manual_actions[$masize]['from'] = $attrs['archive'];
                         $this->manual_actions[$masize]['to'] = $attrs['to'];
                         $this->manual_actions[$masize]['error'] = "Unable to extract archive.";
                     }
                 }
             } elseif ($mod_command->nodeName == 'mkdir') {
                 $attrs = $mod_command->attributes;
                 $attrs['path'] = str_replace(array('{package_path}', '{basepath}'), array($this->package_path, _BASEPATH_), $attrs['path']);
                 if (isset($attrs['type']) && $attrs['type'] == 'skin') {
                     for ($i = 0; isset($GLOBALS['skins'][$i]); ++$i) {
                         $temp1 = str_replace('{skin}', $GLOBALS['skins'][$i], $attrs['path']);
                         $path = '';
                         $temp = explode('/', $temp1);
                         for ($i = 0; isset($temp[$i]); ++$i) {
                             if (!empty($temp[$i])) {
                                 $path .= '/' . $temp[$i];
                                 if (strpos($path, _BASEPATH_) === false) {
                                     continue;
                                 }
                                 if (!is_dir($path) && !$fileop->mkdir($path)) {
                                     $this->error = true;
                                     $masize = count($this->manual_actions);
                                     $this->manual_actions[$masize]['type'] = 'mkdir';
                                     $this->manual_actions[$masize]['from'] = $temp1;
                                     $this->manual_actions[$masize]['to'] = '';
                                     $this->manual_actions[$masize]['error'] = 'Unable to automatically create directory.';
                                     break;
                                 }
                             }
                         }
                     }
                 } else {
                     $path = '';
                     $temp = explode('/', $attrs['path']);
                     for ($i = 0; isset($temp[$i]); ++$i) {
                         if (!empty($temp[$i])) {
                             $path .= '/' . $temp[$i];
                             if (strpos($path, _BASEPATH_) === false) {
                                 continue;
                             }
                             if (!is_dir($path) && !$fileop->mkdir($path)) {
                                 $this->error = true;
                                 $masize = count($this->manual_actions);
                                 $this->manual_actions[$masize]['type'] = 'mkdir';
                                 $this->manual_actions[$masize]['from'] = $attrs['path'];
                                 $this->manual_actions[$masize]['to'] = '';
                                 $this->manual_actions[$masize]['error'] = 'Unable to automatically create directory.';
                                 break;
                             }
                         }
                     }
                 }
             } elseif ($mod_command->nodeName == 'sql') {
                 $attrs = $mod_command->attributes;
                 if (!isset($attrs['type'])) {
                     $attrs['type'] = 'inline';
                 }
                 if ($attrs['type'] == 'inline') {
                     $query = $mod_command->firstChild->nodeValue;
                     $query = trim($query, " \n\t;\r");
                     if (!@mysql_query($query)) {
                         $this->error = true;
                         $masize = count($this->manual_actions);
                         $this->manual_actions[$masize]['type'] = 'sql';
                         $this->manual_actions[$masize]['from'] = $mod_command->firstChild->nodeValue;
                         $this->manual_actions[$masize]['to'] = '';
                         $this->manual_actions[$masize]['error'] = mysql_error();
                     }
                 } else {
                     if (!$this->db_insert_file($this->package_path . '/' . $mod_command->firstChild->nodeValue)) {
                         $this->error = true;
                         $masize = count($this->manual_actions);
                         $this->manual_actions[$masize]['type'] = 'sqlfile';
                         $this->manual_actions[$masize]['from'] = $this->package_path . '/' . $mod_command->firstChild->nodeValue;
                         $this->manual_actions[$masize]['to'] = '';
                         $this->manual_actions[$masize]['error'] = mysql_error();
                     }
                 }
             }
             $mod_command = $mod_command->nextSibling;
         }
         if (!$this->error) {
             $this->post_install($install_index);
         }
     }
     return !$this->error;
 }
Example #3
0
     }
     $query = substr($query, 0, -1);
     if (isset($_on_before_insert)) {
         for ($i = 0; isset($_on_before_insert[$i]); ++$i) {
             call_user_func($_on_before_insert[$i]);
         }
     }
     if (!($res = @mysql_query($query))) {
         trigger_error(mysql_error(), E_USER_ERROR);
     }
     $input['blog_id'] = mysql_insert_id();
     $towrite['blog_id'] = $input['blog_id'];
     $input['blog_id'] = (string) $input['blog_id'];
     // create the blog cache folder if it doesn't exist
     if (!is_dir(_CACHEPATH_ . '/blogs/' . $input['blog_id'][0] . '/' . $input['blog_id'])) {
         $fileop->mkdir(_CACHEPATH_ . '/blogs/' . $input['blog_id'][0] . '/' . $input['blog_id']);
     }
     $temp = '<?php $blog_archive=array();';
     $fileop->file_put_contents(_CACHEPATH_ . '/blogs/' . $input['blog_id'][0] . '/' . $input['blog_id'] . '/blog_archive.inc.php', $temp);
     $topass['message']['type'] = MESSAGE_INFO;
     $topass['message']['text'] = $GLOBALS['_lang'][15];
     if (isset($_on_after_insert)) {
         for ($i = 0; isset($_on_after_insert[$i]); ++$i) {
             call_user_func($_on_after_insert[$i]);
         }
     }
 }
 $towrite['fk_user_id'] = $input['fk_user_id'];
 unset($towrite['return']);
 $towrite = '<?php $blog=' . var_export($towrite, true) . ';';
 $fileop->file_put_contents(_CACHEPATH_ . '/blogs/' . $input['blog_id'][0] . '/' . $input['blog_id'] . '/blog.inc.php', $towrite);