コード例 #1
0
ファイル: MediaDataTable.php プロジェクト: mylastof/os-class
 private function processData($media)
 {
     if (!empty($media)) {
         foreach ($media as $aRow) {
             $row = array();
             $row['bulkactions'] = '<input type="checkbox" name="id[]" value="' . $aRow['pk_i_id'] . '" />';
             $row['file'] = '<div id="media_list_pic"><img src="' . osc_apply_filter('resource_path', osc_base_url() . $aRow['s_path']) . $aRow['pk_i_id'] . '_thumbnail.' . $aRow['s_extension'] . '" style="max-width: 60px; max-height: 60px;" /></div> <div id="media_list_filename">' . $aRow['s_content_type'];
             $row['action'] = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" >' . __('Delete') . '</a>';
             $row['attached_to'] = '<a target="_blank" href="' . osc_item_url_ns($aRow['fk_i_item_id']) . '">item #' . $aRow['fk_i_item_id'] . '</a>';
             $row['date'] = osc_format_date($aRow['dt_pub_date']);
             $row = osc_apply_filter('media_processing_row', $row, $aRow);
             $this->addRow($row);
             $this->rawRows[] = $aRow;
         }
     }
 }
コード例 #2
0
ファイル: item-sidebar.php プロジェクト: abhi143u11/ads
                    <div class="pull-left pub-details">
                        <?php 
    if (osc_item_user_id() != null) {
        ?>
                            <h5><a href="<?php 
        echo osc_user_public_profile_url(osc_item_user_id());
        ?>
"><?php 
        echo osc_item_contact_name();
        ?>
</a> </h5>
                            <small><?php 
        _e("Registered on", 'flatter');
        ?>
 <?php 
        echo osc_format_date(osc_user_regdate());
        ?>
</small>
                        <?php 
    } else {
        ?>
                            <h5><?php 
        echo osc_item_contact_name();
        ?>
</h5>
                        <?php 
    }
    ?>
                    </div>
				<?php 
}
コード例 #3
0
ファイル: index.php プロジェクト: oanav/closetshare
                                    <input type="checkbox" <?php 
echo osc_market_external_sources() ? 'checked="checked"' : '';
?>
 name="market_external_sources" />
                                    <?php 
_e('Allow updates and installations of non-official plugins and themes');
?>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-row">
                        <div class="form-label"></div>
                        <div class="form-controls">
                            <?php 
printf(__('Last checked on %s'), osc_format_date(date('d-m-Y h:i:s', osc_get_preference('themes_last_version_check'))));
?>
 <a class="btn btn-mini" href="<?php 
echo osc_admin_base_url(true);
?>
?page=settings&action=check_updates"><?php 
_e('Check updates');
?>
</a>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="form-actions">
                        <input type="submit" id="save_changes" value="<?php 
echo osc_esc_html(__('Save changes'));
?>
コード例 #4
0
ファイル: item.php プロジェクト: oanav/closetshare
if (count($location) > 0) {
    ?>
                    <div class="item-location">
                        <i class="fa fa-map-marker"></i>
                        <?php 
    echo implode(', ', $location);
    ?>
                    </div>
                    <?php 
}
?>
                    <div class="item-date">
                        <i class="fa fa-calendar"></i>
                        <?php 
if (osc_item_pub_date() !== '') {
    printf(__('%1$s', 'pop'), osc_format_date(osc_item_pub_date()));
}
?>
                    </div>

                    <?php 
voting_item_detail();
?>

                </div>
                <?php 
if (osc_price_enabled_at_items() && osc_item_price()) {
    ?>
                <div class="item-price">
                    <?php 
    echo osc_item_formated_price();
コード例 #5
0
        ?>
"><?php 
        echo osc_item_category();
        ?>
</a></span> <?php 
        if (osc_item_is_premium()) {
            ?>
 <span class="label success"><?php 
            _e('Premium', 'twitter');
            ?>
</span><?php 
        }
        ?>
</h3>
            <p><?php 
        printf(__('<strong>Publish date</strong>: %s', 'twitter'), osc_format_date(osc_item_pub_date()));
        ?>
</p>
            <?php 
        $location = array();
        if (osc_item_country() != '') {
            $location[] = sprintf(__('<strong>Country</strong>: %s', 'twitter'), osc_item_country());
        }
        if (osc_item_region() != '') {
            $location[] = sprintf(__('<strong>Region</strong>: %s', 'twitter'), osc_item_region());
        }
        if (osc_item_city() != '') {
            $location[] = sprintf(__('<strong>City</strong>: %s', 'twitter'), osc_item_city());
        }
        if (count($location) > 0) {
            ?>
コード例 #6
0
ファイル: ajax.php プロジェクト: jmcclenon/Osclass
 function doModel()
 {
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             break;
         case 'regions':
             //Return regions given a countryId
             $regions = Region::newInstance()->findByCountry(Params::getParam("countryId"));
             echo json_encode($regions);
             break;
         case 'cities':
             //Returns cities given a regionId
             $cities = City::newInstance()->findByRegion(Params::getParam("regionId"));
             echo json_encode($cities);
             break;
         case 'location':
             // This is the autocomplete AJAX
             $cities = City::newInstance()->ajax(Params::getParam("term"));
             echo json_encode($cities);
             break;
         case 'userajax':
             // This is the autocomplete AJAX
             $users = User::newInstance()->ajax(Params::getParam("term"));
             if (count($users) == 0) {
                 echo json_encode(array(0 => array('id' => '', 'label' => __('No results'), 'value' => __('No results'))));
             } else {
                 echo json_encode($users);
             }
             break;
         case 'date_format':
             echo json_encode(array('format' => Params::getParam('format'), 'str_formatted' => osc_format_date(date('Y-m-d H:i:s'), Params::getParam('format'))));
             break;
         case 'runhook':
             // run hooks
             $hook = Params::getParam('hook');
             if ($hook == '') {
                 echo json_encode(array('error' => 'hook parameter not defined'));
                 break;
             }
             switch ($hook) {
                 case 'item_form':
                     osc_run_hook('item_form', Params::getParam('catId'));
                     break;
                 case 'item_edit':
                     $catId = Params::getParam("catId");
                     $itemId = Params::getParam("itemId");
                     osc_run_hook("item_edit", $catId, $itemId);
                     break;
                 default:
                     osc_run_hook('ajax_admin_' . $hook);
                     break;
             }
             break;
         case 'categories_order':
             // Save the order of the categories
             osc_csrf_check(false);
             $aIds = Params::getParam('list');
             $orderParent = 0;
             $orderSub = 0;
             $catParent = 0;
             $error = 0;
             $catManager = Category::newInstance();
             $aRecountCat = array();
             foreach ($aIds as $id => $parent) {
                 if ($parent == 'root') {
                     $res = $catManager->updateOrder($id, $orderParent);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                     // find category
                     $auxCategory = Category::newInstance()->findByPrimaryKey($id);
                     // set parent category
                     $conditions = array('pk_i_id' => $id);
                     $array['fk_i_parent_id'] = NULL;
                     $res = $catManager->update($array, $conditions);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     } else {
                         if ($res == 1) {
                             // updated ok
                             $parentId = $auxCategory['fk_i_parent_id'];
                             if ($parentId) {
                                 // update parent category stats
                                 array_push($aRecountCat, $id);
                                 array_push($aRecountCat, $parentId);
                             }
                         }
                     }
                     $orderParent++;
                 } else {
                     if ($parent != $catParent) {
                         $catParent = $parent;
                         $orderSub = 0;
                     }
                     $res = $catManager->updateOrder($id, $orderSub);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                     // set parent category
                     $auxCategory = Category::newInstance()->findByPrimaryKey($id);
                     $auxCategoryP = Category::newInstance()->findByPrimaryKey($catParent);
                     $conditions = array('pk_i_id' => $id);
                     $array['fk_i_parent_id'] = $catParent;
                     $res = $catManager->update($array, $conditions);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     } else {
                         if ($res == 1) {
                             // updated ok
                             // update category parent
                             $prevParentId = $auxCategory['fk_i_parent_id'];
                             $parentId = $auxCategoryP['pk_i_id'];
                             array_push($aRecountCat, $prevParentId);
                             array_push($aRecountCat, $parentId);
                         }
                     }
                     $orderSub++;
                 }
             }
             // update category stats
             foreach ($aRecountCat as $rId) {
                 osc_update_cat_stats_id($rId);
             }
             if ($error) {
                 $result = array('error' => __("An error occurred"));
             } else {
                 $result = array('ok' => __("Order saved"));
             }
             echo json_encode($result);
             break;
         case 'category_edit_iframe':
             $this->_exportVariableToView('category', Category::newInstance()->findByPrimaryKey(Params::getParam("id")));
             $this->_exportVariableToView('languages', OSCLocale::newInstance()->listAllEnabled());
             $this->doView("categories/iframe.php");
             break;
         case 'field_categories_iframe':
             $selected = Field::newInstance()->categories(Params::getParam("id"));
             if ($selected == null) {
                 $selected = array();
             }
             $this->_exportVariableToView("selected", $selected);
             $this->_exportVariableToView("field", Field::newInstance()->findByPrimaryKey(Params::getParam("id")));
             $this->_exportVariableToView("categories", Category::newInstance()->toTreeAll());
             $this->doView("fields/iframe.php");
             break;
         case 'field_categories_post':
             osc_csrf_check(false);
             $error = 0;
             $field = Field::newInstance()->findByName(Params::getParam("s_name"));
             if (!isset($field['pk_i_id']) || isset($field['pk_i_id']) && $field['pk_i_id'] == Params::getParam("id")) {
                 // remove categories from a field
                 Field::newInstance()->cleanCategoriesFromField(Params::getParam("id"));
                 // no error... continue updating fields
                 if ($error == 0) {
                     $slug = Params::getParam("field_slug") != '' ? Params::getParam("field_slug") : Params::getParam("s_name");
                     $slug_tmp = $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower($slug)));
                     $slug_k = 0;
                     while (true) {
                         $field = Field::newInstance()->findBySlug($slug);
                         if (!$field || $field['pk_i_id'] == Params::getParam("id")) {
                             break;
                         } else {
                             $slug_k++;
                             $slug = $slug_tmp . "_" . $slug_k;
                         }
                     }
                     // trim options
                     $s_options = '';
                     $aux = Params::getParam('s_options');
                     $aAux = explode(',', $aux);
                     foreach ($aAux as &$option) {
                         $option = trim($option);
                     }
                     $s_options = implode(',', $aAux);
                     $res = Field::newInstance()->update(array('s_name' => Params::getParam("s_name"), 'e_type' => Params::getParam("field_type"), 's_slug' => $slug, 'b_required' => Params::getParam("field_required") == "1" ? 1 : 0, 's_options' => $s_options), array('pk_i_id' => Params::getParam("id")));
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                 }
                 // no error... continue inserting categories-field
                 if ($error == 0) {
                     $aCategories = Params::getParam("categories");
                     if (is_array($aCategories) && count($aCategories) > 0) {
                         $res = Field::newInstance()->insertCategories(Params::getParam("id"), $aCategories);
                         if (!$res) {
                             $error = 1;
                         }
                     }
                 }
                 // error while updating?
                 if ($error == 1) {
                     $message = __("An error occurred while updating.");
                 }
             } else {
                 $error = 1;
                 $message = __("Sorry, you already have a field with that name");
             }
             if ($error) {
                 $result = array('error' => $message);
             } else {
                 $result = array('ok' => __("Saved"), 'text' => Params::getParam("s_name"), 'field_id' => Params::getParam("id"));
             }
             echo json_encode($result);
             break;
         case 'delete_field':
             osc_csrf_check(false);
             $res = Field::newInstance()->deleteByPrimaryKey(Params::getParam('id'));
             if ($res > 0) {
                 $result = array('ok' => __('The custom field has been deleted'));
             } else {
                 $result = array('error' => __('An error occurred while deleting'));
             }
             echo json_encode($result);
             break;
         case 'add_field':
             osc_csrf_check(false);
             $s_name = __('NEW custom field');
             $slug_tmp = $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower($s_name)));
             $slug_k = 0;
             while (true) {
                 $field = Field::newInstance()->findBySlug($slug);
                 if (!$field || $field['pk_i_id'] == Params::getParam("id")) {
                     break;
                 } else {
                     $slug_k++;
                     $slug = $slug_tmp . "_" . $slug_k;
                 }
             }
             $fieldManager = Field::newInstance();
             $result = $fieldManager->insertField($s_name, 'TEXT', $slug, 0, '', array());
             if ($result) {
                 echo json_encode(array('error' => 0, 'field_id' => $fieldManager->dao->insertedId(), 'field_name' => $s_name));
             } else {
                 echo json_encode(array('error' => 1));
             }
             break;
         case 'enable_category':
             osc_csrf_check(false);
             $id = strip_tags(Params::getParam('id'));
             $enabled = Params::getParam('enabled') != '' ? Params::getParam('enabled') : 0;
             $error = 0;
             $result = array();
             $aUpdated = array();
             $mCategory = Category::newInstance();
             $aCategory = $mCategory->findByPrimaryKey($id);
             if ($aCategory == false) {
                 $result = array('error' => sprintf(__("No category with id %d exists"), $id));
                 echo json_encode($result);
                 break;
             }
             // root category
             if ($aCategory['fk_i_parent_id'] == '') {
                 $mCategory->update(array('b_enabled' => $enabled), array('pk_i_id' => $id));
                 $mCategory->update(array('b_enabled' => $enabled), array('fk_i_parent_id' => $id));
                 $subCategories = $mCategory->findSubcategories($id);
                 $aIds = array($id);
                 $aUpdated[] = array('id' => $id);
                 foreach ($subCategories as $subcategory) {
                     $aIds[] = $subcategory['pk_i_id'];
                     $aUpdated[] = array('id' => $subcategory['pk_i_id']);
                 }
                 Item::newInstance()->enableByCategory($enabled, $aIds);
                 if ($enabled) {
                     $result = array('ok' => __('The category as well as its subcategories have been enabled'));
                 } else {
                     $result = array('ok' => __('The category as well as its subcategories have been disabled'));
                 }
                 $result['affectedIds'] = $aUpdated;
                 echo json_encode($result);
                 break;
             }
             // subcategory
             $parentCategory = $mCategory->findRootCategory($id);
             if (!$parentCategory['b_enabled']) {
                 $result = array('error' => __('Parent category is disabled, you can not enable that category'));
                 echo json_encode($result);
                 break;
             }
             $mCategory->update(array('b_enabled' => $enabled), array('pk_i_id' => $id));
             if ($enabled) {
                 $result = array('ok' => __('The subcategory has been enabled'));
             } else {
                 $result = array('ok' => __('The subcategory has been disabled'));
             }
             $result['affectedIds'] = array(array('id' => $id));
             echo json_encode($result);
             break;
         case 'delete_category':
             osc_csrf_check(false);
             $id = Params::getParam("id");
             $error = 0;
             $categoryManager = Category::newInstance();
             $res = $categoryManager->deleteByPrimaryKey($id);
             if ($res > 0) {
                 $message = __('The categories have been deleted');
             } else {
                 $error = 1;
                 $message = __('An error occurred while deleting');
             }
             if ($error) {
                 $result = array('error' => $message);
             } else {
                 $result = array('ok' => __("Saved"));
             }
             echo json_encode($result);
             break;
         case 'edit_category_post':
             osc_csrf_check(false);
             $id = Params::getParam("id");
             $fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0;
             $error = 0;
             $has_one_title = 0;
             $postParams = Params::getParamsAsArray();
             foreach ($postParams as $k => $v) {
                 if (preg_match('|(.+?)#(.+)|', $k, $m)) {
                     if ($m[2] == 's_name') {
                         if ($v != "") {
                             $has_one_title = 1;
                             $aFieldsDescription[$m[1]][$m[2]] = $v;
                             $s_text = $v;
                         } else {
                             $aFieldsDescription[$m[1]][$m[2]] = NULL;
                             $error = 1;
                         }
                     } else {
                         $aFieldsDescription[$m[1]][$m[2]] = $v;
                     }
                 }
             }
             $l = osc_language();
             if ($error == 0 || $error == 1 && $has_one_title == 1) {
                 $categoryManager = Category::newInstance();
                 $res = $categoryManager->updateByPrimaryKey(array('fields' => $fields, 'aFieldsDescription' => $aFieldsDescription), $id);
                 $categoryManager->updateExpiration($id, $fields['i_expiration_days']);
                 if (is_bool($res)) {
                     $error = 2;
                 }
             }
             if (Params::getParam('apply_changes_to_subcategories') == 1) {
                 $subcategories = $categoryManager->findSubcategories($id);
                 foreach ($subcategories as $subc) {
                     $categoryManager->updateExpiration($subc['pk_i_id'], $fields['i_expiration_days']);
                 }
             }
             if ($error == 0) {
                 $msg = __("Category updated correctly");
             } else {
                 if ($error == 1) {
                     if ($has_one_title == 1) {
                         $error = 4;
                         $msg = __('Category updated correctly, but some titles are empty');
                     } else {
                         $msg = __('Sorry, including at least a title is mandatory');
                     }
                 } else {
                     if ($error == 2) {
                         $msg = __('An error occurred while updating');
                     }
                 }
             }
             echo json_encode(array('error' => $error, 'msg' => $msg, 'text' => $aFieldsDescription[$l]['s_name']));
             break;
         case 'custom':
             // Execute via AJAX custom file
             $ajaxFile = Params::getParam("ajaxfile");
             if ($ajaxFile == '') {
                 echo json_encode(array('error' => 'no action defined'));
                 break;
             }
             // valid file?
             if (stripos($ajaxFile, '../') !== false) {
                 echo json_encode(array('error' => 'no valid ajaxFile'));
                 break;
             }
             if (!file_exists(osc_plugins_path() . $ajaxFile)) {
                 echo json_encode(array('error' => "ajaxFile doesn't exist"));
                 break;
             }
             require_once osc_plugins_path() . $ajaxFile;
             break;
         case 'test_mail':
             $title = sprintf(__('Test email, %s'), osc_page_title());
             $body = __("Test email") . "<br><br>" . osc_page_title();
             $emailParams = array('subject' => $title, 'to' => osc_contact_email(), 'to_name' => 'admin', 'body' => $body, 'alt_body' => $body);
             $array = array();
             if (osc_sendMail($emailParams)) {
                 $array = array('status' => '1', 'html' => __('Email sent successfully'));
             } else {
                 $array = array('status' => '0', 'html' => __('An error occurred while sending email'));
             }
             echo json_encode($array);
             break;
         case 'test_mail_template':
             // replace por valores por defecto
             $email = Params::getParam("email");
             $title = Params::getParam("title");
             $body = urldecode(Params::getParam("body"));
             $emailParams = array('subject' => $title, 'to' => $email, 'to_name' => 'admin', 'body' => $body, 'alt_body' => $body);
             $array = array();
             if (osc_sendMail($emailParams)) {
                 $array = array('status' => '1', 'html' => __('Email sent successfully'));
             } else {
                 $array = array('status' => '0', 'html' => __('An error occurred while sending email'));
             }
             echo json_encode($array);
             break;
         case 'order_pages':
             osc_csrf_check(false);
             $order = Params::getParam("order");
             $id = Params::getParam("id");
             if ($order != '' && $id != '') {
                 $mPages = Page::newInstance();
                 $actual_page = $mPages->findByPrimaryKey($id);
                 $actual_order = $actual_page['i_order'];
                 $array = array();
                 $condition = array();
                 $new_order = $actual_order;
                 if ($order == 'up') {
                     $page = $mPages->findPrevPage($actual_order);
                 } else {
                     if ($order == 'down') {
                         $page = $mPages->findNextPage($actual_order);
                     }
                 }
                 if (isset($page['i_order'])) {
                     $mPages->update(array('i_order' => $page['i_order']), array('pk_i_id' => $id));
                     $mPages->update(array('i_order' => $actual_order), array('pk_i_id' => $page['pk_i_id']));
                 }
             }
             break;
             /******************************
              ** COMPLETE UPGRADE PROCESS **
              ******************************/
         /******************************
          ** COMPLETE UPGRADE PROCESS **
          ******************************/
         case 'upgrade':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             osc_csrf_check(false);
             $message = "";
             $error = 0;
             $sql_error_msg = "";
             $rm_errors = 0;
             $perms = osc_save_permissions();
             osc_change_permissions();
             $maintenance_file = ABS_PATH . '.maintenance';
             $fileHandler = @fopen($maintenance_file, 'w');
             fclose($fileHandler);
             /***********************
              **** DOWNLOAD FILE ****
              ***********************/
             $data = osc_file_get_contents("http://osclass.org/latest_version.php");
             $data = json_decode(substr($data, 1, strlen($data) - 3), true);
             $source_file = $data['url'];
             if ($source_file != '') {
                 $tmp = explode("/", $source_file);
                 $filename = end($tmp);
                 $result = osc_downloadFile($source_file, $filename);
                 if ($result) {
                     // Everything is OK, continue
                     /**********************
                      ***** UNZIP FILE *****
                      **********************/
                     @mkdir(ABS_PATH . 'oc-temp', 0777);
                     $res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, ABS_PATH . 'oc-temp/');
                     if ($res == 1) {
                         // Everything is OK, continue
                         /**********************
                          ***** COPY FILES *****
                          **********************/
                         $fail = -1;
                         if ($handle = opendir(ABS_PATH . 'oc-temp')) {
                             $fail = 0;
                             while (false !== ($_file = readdir($handle))) {
                                 if ($_file != '.' && $_file != '..' && $_file != 'remove.list' && $_file != 'upgrade.sql' && $_file != 'customs.actions') {
                                     $data = osc_copy(ABS_PATH . "oc-temp/" . $_file, ABS_PATH . $_file);
                                     if ($data == false) {
                                         $fail = 1;
                                     }
                                 }
                             }
                             closedir($handle);
                             //TRY TO REMOVE THE ZIP PACKAGE
                             @unlink(osc_content_path() . 'downloads/' . $filename);
                             if ($fail == 0) {
                                 // Everything is OK, continue
                                 /************************
                                  *** UPGRADE DATABASE ***
                                  ************************/
                                 $error_queries = array();
                                 if (file_exists(osc_lib_path() . 'osclass/installer/struct.sql')) {
                                     $sql = file_get_contents(osc_lib_path() . 'osclass/installer/struct.sql');
                                     $conn = DBConnectionClass::newInstance();
                                     $c_db = $conn->getOsclassDb();
                                     $comm = new DBCommandClass($c_db);
                                     $error_queries = $comm->updateDB(str_replace('/*TABLE_PREFIX*/', DB_TABLE_PREFIX, $sql));
                                 }
                                 if ($error_queries[0]) {
                                     // Everything is OK, continue
                                     /**********************************
                                      ** EXECUTING ADDITIONAL ACTIONS **
                                      **********************************/
                                     if (file_exists(osc_lib_path() . 'osclass/upgrade-funcs.php')) {
                                         // There should be no errors here
                                         define('AUTO_UPGRADE', true);
                                         require_once osc_lib_path() . 'osclass/upgrade-funcs.php';
                                     }
                                     // Additional actions is not important for the rest of the proccess
                                     // We will inform the user of the problems but the upgrade could continue
                                     /****************************
                                      ** REMOVE TEMPORARY FILES **
                                      ****************************/
                                     $path = ABS_PATH . 'oc-temp';
                                     $rm_errors = 0;
                                     $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
                                     for ($dir->rewind(); $dir->valid(); $dir->next()) {
                                         if ($dir->isDir()) {
                                             if ($dir->getFilename() != '.' && $dir->getFilename() != '..') {
                                                 if (!rmdir($dir->getPathname())) {
                                                     $rm_errors++;
                                                 }
                                             }
                                         } else {
                                             if (!unlink($dir->getPathname())) {
                                                 $rm_errors++;
                                             }
                                         }
                                     }
                                     if (!rmdir($path)) {
                                         $rm_errors++;
                                     }
                                     $deleted = @unlink(ABS_PATH . '.maintenance');
                                     if ($rm_errors == 0) {
                                         $message = __('Everything looks good! Your Osclass installation is up-to-date');
                                     } else {
                                         $message = __('Nearly everything looks good! Your Osclass installation is up-to-date, but there were some errors removing temporary files. Please manually remove the "oc-temp" folder');
                                         $error = 6;
                                         // Some errors removing files
                                     }
                                 } else {
                                     $sql_error_msg = $error_queries[2];
                                     $message = __('Problems when upgrading the database');
                                     $error = 5;
                                     // Problems upgrading the database
                                 }
                             } else {
                                 $message = __('Problems when copying files. Please check your permissions. ');
                                 $error = 4;
                                 // Problems copying files. Maybe permissions are not correct
                             }
                         } else {
                             $message = __('Nothing to copy');
                             $error = 99;
                             // Nothing to copy. THIS SHOULD NEVER HAPPEN, means we don't update any file!
                         }
                     } else {
                         $message = __('Unzip failed');
                         $error = 3;
                         // Unzip failed
                     }
                 } else {
                     $message = __('Download failed');
                     $error = 2;
                     // Download failed
                 }
             } else {
                 $message = __('Missing download URL');
                 $error = 1;
                 // Missing download URL
             }
             if ($error == 5) {
                 $message .= "<br /><br />" . __('We had some errors upgrading your database. The follwing queries failed:') . implode("<br />", $sql_error_msg);
             }
             echo $message;
             foreach ($perms as $k => $v) {
                 @chmod($k, $v);
             }
             break;
             /*******************************
              ** COMPLETE MARKET PROCESS **
              *******************************/
         /*******************************
          ** COMPLETE MARKET PROCESS **
          *******************************/
         case 'market':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             osc_csrf_check(false);
             $section = Params::getParam('section');
             $code = Params::getParam('code');
             $plugin = false;
             $re_enable = false;
             $message = "";
             $error = 0;
             $data = array();
             /************************
              *** CHECK VALID CODE ***
              ************************/
             if ($code != '' && $section != '') {
                 if (stripos($code, "http://") === FALSE) {
                     // OSCLASS OFFICIAL REPOSITORY
                     $url = osc_market_url($section, $code);
                     $data = json_decode(osc_file_get_contents($url), true);
                 } else {
                     // THIRD PARTY REPOSITORY
                     if (osc_market_external_sources()) {
                         $data = json_decode(osc_file_get_contents($code), true);
                     } else {
                         echo json_encode(array('error' => 8, 'error_msg' => __('No external sources are allowed')));
                         break;
                     }
                 }
                 /***********************
                  **** DOWNLOAD FILE ****
                  ***********************/
                 if (isset($data['s_update_url']) && isset($data['s_source_file']) && isset($data['e_type'])) {
                     if ($data['e_type'] == 'THEME') {
                         $folder = 'themes/';
                     } else {
                         if ($data['e_type'] == 'LANGUAGE') {
                             $folder = 'languages/';
                         } else {
                             // PLUGINS
                             $folder = 'plugins/';
                             $plugin = Plugins::findByUpdateURI($data['s_update_url']);
                             if ($plugin != false) {
                                 if (Plugins::isEnabled($plugin)) {
                                     Plugins::runHook($plugin . '_disable');
                                     Plugins::deactivate($plugin);
                                     $re_enable = true;
                                 }
                             }
                         }
                     }
                     $filename = $data['s_update_url'] . "_" . $data['s_version'] . ".zip";
                     $url_source_file = $data['s_source_file'];
                     //                            error_log('Source file: ' . $url_source_file);
                     //                            error_log('Filename: ' . $filename);
                     $result = osc_downloadFile($url_source_file, $filename);
                     if ($result) {
                         // Everything is OK, continue
                         /**********************
                          ***** UNZIP FILE *****
                          **********************/
                         @mkdir(ABS_PATH . 'oc-temp', 0777);
                         $res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, osc_content_path() . 'downloads/oc-temp/');
                         if ($res == 1) {
                             // Everything is OK, continue
                             /**********************
                              ***** COPY FILES *****
                              **********************/
                             $fail = -1;
                             if ($handle = opendir(osc_content_path() . 'downloads/oc-temp')) {
                                 $folder_dest = ABS_PATH . "oc-content/" . $folder;
                                 if (function_exists('posix_getpwuid')) {
                                     $current_user = posix_getpwuid(posix_geteuid());
                                     $ownerFolder = posix_getpwuid(fileowner($folder_dest));
                                 }
                                 $fail = 0;
                                 while (false !== ($_file = readdir($handle))) {
                                     if ($_file != '.' && $_file != '..') {
                                         $copyprocess = osc_copy(osc_content_path() . "downloads/oc-temp/" . $_file, $folder_dest . $_file);
                                         if ($copyprocess == false) {
                                             $fail = 1;
                                         }
                                     }
                                 }
                                 closedir($handle);
                                 // Additional actions is not important for the rest of the proccess
                                 // We will inform the user of the problems but the upgrade could continue
                                 // Also remove the zip package
                                 /****************************
                                  ** REMOVE TEMPORARY FILES **
                                  ****************************/
                                 @unlink(osc_content_path() . 'downloads/' . $filename);
                                 $path = osc_content_path() . 'downloads/oc-temp';
                                 $rm_errors = 0;
                                 $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
                                 for ($dir->rewind(); $dir->valid(); $dir->next()) {
                                     if ($dir->isDir()) {
                                         if ($dir->getFilename() != '.' && $dir->getFilename() != '..') {
                                             if (!rmdir($dir->getPathname())) {
                                                 $rm_errors++;
                                             }
                                         }
                                     } else {
                                         if (!unlink($dir->getPathname())) {
                                             $rm_errors++;
                                         }
                                     }
                                 }
                                 if (!rmdir($path)) {
                                     $rm_errors++;
                                 }
                                 if ($fail == 0) {
                                     // Everything is OK, continue
                                     if ($data['e_type'] != 'THEME' && $data['e_type'] != 'LANGUAGE') {
                                         if ($plugin != false && $re_enable) {
                                             $enabled = Plugins::activate($plugin);
                                             if ($enabled) {
                                                 Plugins::runHook($plugin . '_enable');
                                             }
                                         }
                                     }
                                     // recount plugins&themes for update
                                     if ($section == 'plugins') {
                                         osc_check_plugins_update(true);
                                     } else {
                                         if ($section == 'themes') {
                                             osc_check_themes_update(true);
                                         } else {
                                             if ($section == 'languages') {
                                                 // load oc-content/
                                                 if (osc_checkLocales()) {
                                                     $message .= __('The language has been installed correctly');
                                                 } else {
                                                     $message .= __('There was a problem adding the language');
                                                     $error = 8;
                                                 }
                                                 osc_check_languages_update(true);
                                             }
                                         }
                                     }
                                     if ($rm_errors == 0) {
                                         $message = __('Everything looks good!');
                                         $error = 0;
                                     } else {
                                         $message = __('Nearly everything looks good! but there were some errors removing temporary files. Please manually remove the \\"oc-temp\\" folder');
                                         $error = 6;
                                         // Some errors removing files
                                     }
                                 } else {
                                     $message = __('Problems when copying files. Please check your permissions. ');
                                     if ($current_user['uid'] != $ownerFolder['uid']) {
                                         if (function_exists('posix_getgrgid')) {
                                             $current_group = posix_getgrgid($current_user['gid']);
                                             $message .= '<p><strong>' . sprintf(__('NOTE: Web user and destination folder user is not the same, you might have an issue there. <br/>Do this in your console:<br/>chown -R %s:%s %s'), $current_user['name'], $current_group['name'], $folder_dest) . '</strong></p>';
                                         }
                                     }
                                     $error = 4;
                                     // Problems copying files. Maybe permissions are not correct
                                 }
                             } else {
                                 $message = __('Nothing to copy');
                                 $error = 99;
                                 // Nothing to copy. THIS SHOULD NEVER HAPPEN, means we don't update any file!
                             }
                         } else {
                             $message = __('Unzip failed');
                             $error = 3;
                             // Unzip failed
                         }
                     } else {
                         $message = __('Download failed');
                         $error = 2;
                         // Download failed
                     }
                 } else {
                     $message = __('Input code not valid');
                     $error = 7;
                     // Input code not valid
                 }
             } else {
                 $message = __('Missing download URL');
                 $error = 1;
                 // Missing download URL
             }
             echo json_encode(array('error' => $error, 'message' => $message, 'data' => $data));
             break;
         case 'check_market':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             $section = Params::getParam('section');
             $code = Params::getParam('code');
             $data = array();
             /************************
              *** CHECK VALID CODE ***
              ************************/
             if ($code != '' && $section != '') {
                 if (stripos($code, "http://") === FALSE) {
                     // OSCLASS OFFICIAL REPOSITORY
                     $data = json_decode(osc_file_get_contents(osc_market_url($section, $code)), true);
                 } else {
                     // THIRD PARTY REPOSITORY
                     if (osc_market_external_sources()) {
                         $data = json_decode(osc_file_get_contents($code), true);
                     } else {
                         echo json_encode(array('error' => 3, 'error_msg' => __('No external sources are allowed')));
                         break;
                     }
                 }
                 if (!isset($data['s_source_file']) || !isset($data['s_update_url'])) {
                     $data = array('error' => 2, 'error_msg' => __('Invalid code'));
                 }
             } else {
                 $data = array('error' => 1, 'error_msg' => __('No code was submitted'));
             }
             echo json_encode($data);
             break;
         case 'market_data':
             $section = Params::getParam('section');
             $page = Params::getParam("mPage");
             $featured = Params::getParam("featured");
             $sort = Params::getParam("sort");
             $order = Params::getParam("order");
             // for the moment this value is static
             $length = 9;
             if ($page >= 1) {
                 $page--;
             }
             $url = osc_market_url($section) . "page/" . $page . '/';
             if ($length != '' && is_numeric($length)) {
                 $url .= 'length/' . $length . '/';
             }
             if ($sort != '') {
                 $url .= 'order/' . $sort;
                 if ($order != '') {
                     $url .= '/' . $order;
                 }
             }
             if ($featured != '') {
                 $url = osc_market_featured_url($section);
             }
             $data = array();
             $data = json_decode(osc_file_get_contents($url), true);
             if (!isset($data[$section])) {
                 $data = array('error' => 1, 'error_msg' => __('No market data'));
             }
             echo 'var market_data = window.market_data || {}; market_data.' . $section . ' = ' . json_encode($data) . ';';
             break;
         case 'local_market':
             // AVOID CROSS DOMAIN PROBLEMS OF AJAX REQUEST
             $marketPage = Params::getParam("mPage");
             if ($marketPage >= 1) {
                 $marketPage--;
             }
             $out = osc_file_get_contents(osc_market_url(Params::getParam("section")) . "page/" . $marketPage);
             $array = json_decode($out, true);
             // do pagination
             $pageActual = $array['page'];
             $totalPages = ceil($array['total'] / $array['sizePage']);
             $params = array('total' => $totalPages, 'selected' => $pageActual, 'url' => '#{PAGE}', 'sides' => 5);
             // set pagination
             $pagination = new Pagination($params);
             $aux = $pagination->doPagination();
             $array['pagination_content'] = $aux;
             // encode to json
             echo json_encode($array);
             break;
         case 'dashboardbox_market':
             $error = 0;
             // make market call
             $url = getPreference('marketURL') . 'dashboardbox/';
             $content = '';
             if (false === ($json = @osc_file_get_contents($url))) {
                 $error = 1;
             } else {
                 $content = $json;
             }
             if ($error == 1) {
                 echo json_encode(array('error' => 1));
             } else {
                 // replace content with correct urls
                 $content = str_replace('{URL_MARKET_THEMES}', osc_admin_base_url(true) . '?page=market&action=themes', $content);
                 $content = str_replace('{URL_MARKET_PLUGINS}', osc_admin_base_url(true) . '?page=market&action=plugins', $content);
                 echo json_encode(array('html' => $content));
             }
             break;
         case 'location_stats':
             osc_csrf_check(false);
             $workToDo = osc_update_location_stats();
             if ($workToDo > 0) {
                 $array['status'] = 'more';
                 $array['pending'] = $workToDo;
                 echo json_encode($array);
             } else {
                 $array['status'] = 'done';
                 echo json_encode($array);
             }
             break;
         case 'error_permissions':
             echo json_encode(array('error' => __("You don't have the necessary permissions")));
             break;
         default:
             echo json_encode(array('error' => __('no action defined')));
             break;
     }
     // clear all keep variables into session
     Session::newInstance()->_dropKeepForm();
     Session::newInstance()->_clearVariables();
 }
コード例 #7
0
ファイル: AlertsDataTable.php プロジェクト: mylastof/os-class
 private function processData($alerts)
 {
     if (!empty($alerts) && !empty($alerts['alerts'])) {
         $csrf_token_url = osc_csrf_token_url();
         foreach ($alerts['alerts'] as $aRow) {
             $row = array();
             $options = array();
             // first column
             $row['bulkactions'] = '<input type="checkbox" name="alert_id[]" value="' . $aRow['pk_i_id'] . '" /></div>';
             $options[] = '<a onclick="return delete_alert(\'' . $aRow['pk_i_id'] . '\');" href="#">' . __('Delete') . '</a>';
             if ($aRow['b_active'] == 1) {
                 $options[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=status_alerts&amp;alert_id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;status=0" >' . __('Deactivate') . '</a>';
             } else {
                 $options[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=status_alerts&amp;alert_id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;status=1" >' . __('Activate') . '</a>';
             }
             $options = osc_apply_filter('actions_manage_alerts', $options, $aRow);
             // create list of actions
             $auxOptions = '<ul>' . PHP_EOL;
             foreach ($options as $actual) {
                 $auxOptions .= '<li>' . $actual . '</li>' . PHP_EOL;
             }
             $auxOptions .= '</ul>' . PHP_EOL;
             $actions = '<div class="actions">' . $auxOptions . '</div>' . PHP_EOL;
             // second column
             $row['email'] = '<a href="' . osc_admin_base_url(true) . '?page=items&userId=">' . $aRow['s_email'] . '</a>' . $actions;
             // third row
             $pieces = array();
             $conditions = osc_get_raw_search((array) json_decode($aRow['s_search'], true));
             if (isset($conditions['sPattern']) && $conditions['sPattern'] != '') {
                 $pieces[] = sprintf(__("<b>Pattern:</b> %s"), $conditions['sPattern']);
             }
             if (isset($conditions['aCategories']) && !empty($conditions['aCategories'])) {
                 $l = min(count($conditions['aCategories']), 4);
                 $cat_array = array();
                 for ($c = 0; $c < $l; $c++) {
                     $cat_array[] = $conditions['aCategories'][$c];
                 }
                 if (count($conditions['aCategories']) > $l) {
                     $cat_array[] = '<a href="#" class="more-tooltip" categories="' . osc_esc_html(implode(", ", $conditions['aCategories'])) . '" >' . __("...More") . '</a>';
                 }
                 $pieces[] = sprintf(__("<b>Categories:</b> %s"), implode(", ", $cat_array));
             }
             $row['alert'] = implode($pieces, ", ");
             // fourth row
             $row['date'] = osc_format_date($aRow['dt_date']);
             $row = osc_apply_filter('alerts_processing_row', $row, $aRow);
             $this->addRow($row);
             $this->rawRows[] = $aRow;
         }
     }
 }
コード例 #8
0
        private function processData($users)
        {
            if(!empty($users)) {

                $csrf_token_url = osc_csrf_token_url();
                foreach($users as $aRow) {
                    $row = array();
                    $options        = array();
                    $options_more   = array();
                    // first column

                    $options[]  = '<a href="' . osc_admin_base_url(true) . '?page=users&action=edit&amp;id=' . $aRow['pk_i_id'] . '">' . __('Edit') . '</a>';
                    $options[]  = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" href="' . osc_admin_base_url(true) . '?page=users&action=delete&amp;id[]=' . $aRow['pk_i_id'] . '">' . __('Delete') . '</a>';
                    $options[]  = '<a href="' . osc_user_public_profile_url($aRow['pk_i_id']) . '" targe="_blank">' . __('Public profile') . '</a>';

                    if( $aRow['b_active'] == 1 ) {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=deactivate&amp;id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '">' . __('Deactivate') . '</a>';
                    } else {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=activate&amp;id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url .'">' . __('Activate') . '</a>';
                    }
                    if( $aRow['b_enabled'] == 1 ) {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=disable&amp;id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '">' . __('Block') . '</a>';
                    } else {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=enable&amp;id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '">' . __('Unblock') . '</a>';
                    }
                    if( osc_user_validation_enabled() && ( $aRow['b_active'] == 0 ) ) {
                        $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=users&action=resend_activation&amp;id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '">' . __('Re-send activation email') . '</a>';
                    }

                    $options_more = osc_apply_filter('more_actions_manage_users', $options_more, $aRow);
                    // more actions
                    $moreOptions = '<li class="show-more">'.PHP_EOL.'<a href="#" class="show-more-trigger">'. __('Show more') .'...</a>'. PHP_EOL .'<ul>'. PHP_EOL;
                    foreach( $options_more as $actual ) {
                        $moreOptions .= '<li>'.$actual."</li>".PHP_EOL;
                    }
                    $moreOptions .= '</ul>'. PHP_EOL .'</li>'.PHP_EOL;

                    $options = osc_apply_filter('actions_manage_users', $options, $aRow);
                    // create list of actions
                    $auxOptions = '<ul>'.PHP_EOL;
                    foreach( $options as $actual ) {
                        $auxOptions .= '<li>'.$actual.'</li>'.PHP_EOL;
                    }
                    $auxOptions  .= $moreOptions;
                    $auxOptions  .= '</ul>'.PHP_EOL;

                    $actions = '<div class="actions">'.$auxOptions.'</div>'.PHP_EOL;

                    $status = $this->get_row_status($aRow);
                    $row['status-border'] = '';
                    $row['status'] = $status['text'];
                    $row['bulkactions'] = '<input type="checkbox" name="id[]" value="' . $aRow['pk_i_id'] . '" /></div>';
                    $row['email'] = '<a href="' . osc_admin_base_url(true) . '?page=items&userId='. $aRow['pk_i_id'] .'&user='******'s_name'] .'">' . $aRow['s_email'] . '</a>'. $actions;
                    $row['username'] = $aRow['s_username'];
                    $row['name'] = $aRow['s_name'];
                    $row['date'] = osc_format_date($aRow['dt_reg_date']);
                    $row['items'] = $aRow['i_items'];
                    $row['update_date'] = osc_format_date($aRow['dt_mod_date']);

                    $row = osc_apply_filter('users_processing_row', $row, $aRow);

                    $this->addRow($row);
                    $this->rawRows[] = $aRow;
                }

            }
        }
コード例 #9
0
ファイル: item.php プロジェクト: nsswaga/OSClass
    echo osc_item_formated_price();
    ?>
</small> &middot; <?php 
}
echo osc_item_title();
?>
</h1>
                    <p class="no-margin"><?php 
printf(__('<strong>Published date:</strong> %s %s', 'twitter_bootstrap'), osc_format_date(osc_item_pub_date()), date(osc_time_format(), strtotime(osc_item_pub_date())));
?>
</p>
                    <?php 
if (osc_item_mod_date() != '') {
    ?>
                    <p class="no-margin"><?php 
    printf(__('<strong>Modified date:</strong> %s %s', 'twitter_bootstrap'), osc_format_date(osc_item_mod_date()), date(osc_time_format(), strtotime(osc_item_mod_date())));
    ?>
</p>
                    <?php 
}
?>
                    <?php 
$item_location = item_detail_location();
?>
                    <?php 
if (count($item_location) > 0) {
    ?>
                    <p class="no-margin"><?php 
    printf(__('<strong>Location:</strong> %s', 'twitter_bootstrap'), implode(', ', $item_location));
    ?>
</p>
コード例 #10
0
ファイル: item.php プロジェクト: syedfiraat4/bikade.com
    ?>
          <?php 
}
?>
        </li>
        <li>
          <?php 
if (osc_item_pub_date() !== '') {
    printf(__('<i class="fa fa-calendar-o"></i> Published date: %1$s', OSCLASSWIZARDS_THEME_FOLDER), osc_format_date(osc_item_pub_date()));
}
?>
        </li>
        <li>
          <?php 
if (osc_item_mod_date() !== '') {
    printf(__('<span class="update"><i class="fa fa-calendar"></i> Modified date:</span> %1$s', OSCLASSWIZARDS_THEME_FOLDER), osc_format_date(osc_item_mod_date()));
}
?>
        </li>
        <?php 
if (count($location) > 0) {
    ?>
        <li>
          <ul id="item_location">
            <li><i class="fa fa-map-marker"></i> <?php 
    echo implode(', ', $location);
    ?>
</li>
          </ul>
        </li>
        <?php 
コード例 #11
0
 private function processData($comments)
 {
     if (!empty($comments)) {
         $csrf_token_url = osc_csrf_token_url();
         foreach ($comments as $aRow) {
             $row = array();
             $options = array();
             $options_more = array();
             View::newInstance()->_exportVariableToView('item', Item::newInstance()->findByPrimaryKey($aRow['fk_i_item_id']));
             if ($aRow['b_enabled']) {
                 $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=DISABLE">' . __('Block') . '</a>';
             } else {
                 $options_more[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=ENABLE">' . __('Unblock') . '</a>';
             }
             $options_more[] = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" href="' . osc_admin_base_url(true) . '?page=comments&amp;action=delete&amp;id=' . $aRow['pk_i_id'] . '" id="dt_link_delete">' . __('Delete') . '</a>';
             $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=comment_edit&amp;id=' . $aRow['pk_i_id'] . '" id="dt_link_edit">' . __('Edit') . '</a>';
             if ($aRow['b_active']) {
                 $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=INACTIVE">' . __('Deactivate') . '</a>';
             } else {
                 $options[] = '<a href="' . osc_admin_base_url(true) . '?page=comments&amp;action=status&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;value=ACTIVE">' . __('Activate') . '</a>';
             }
             // more actions
             $moreOptions = '<li class="show-more">' . PHP_EOL . '<a href="#" class="show-more-trigger">' . __('Show more') . '...</a>' . PHP_EOL . '<ul>' . PHP_EOL;
             foreach ($options_more as $actual) {
                 $moreOptions .= '<li>' . $actual . "</li>" . PHP_EOL;
             }
             $moreOptions .= '</ul>' . PHP_EOL . '</li>' . PHP_EOL;
             // create list of actions
             $auxOptions = '<ul>' . PHP_EOL;
             foreach ($options as $actual) {
                 $auxOptions .= '<li>' . $actual . '</li>' . PHP_EOL;
             }
             $auxOptions .= $moreOptions;
             $auxOptions .= '</ul>' . PHP_EOL;
             $actions = '<div class="actions">' . $auxOptions . '</div>' . PHP_EOL;
             $status = $this->get_row_status($aRow);
             $row['status-border'] = '';
             $row['status'] = $status['text'];
             $row['bulkactions'] = '<input type="checkbox" name="id[]" value="' . $aRow['pk_i_id'] . '" />';
             if (empty($aRow['s_author_name'])) {
                 $user = User::newInstance()->findByPrimaryKey($aRow['fk_i_user_id']);
                 $aRow['s_author_name'] = $user['s_email'];
             }
             $row['author'] = $aRow['s_author_name'] . ' (<a target="_blank" href="' . osc_item_url() . '">' . osc_item_title() . '</a>)' . $actions;
             $row['comment'] = $aRow['s_body'];
             $row['date'] = osc_format_date($aRow['dt_pub_date']);
             $row = osc_apply_filter('comments_processing_row', $row, $aRow);
             $this->addRow($row);
             $this->rawRows[] = $aRow;
         }
     }
 }
コード例 #12
0
ファイル: ajax.php プロジェクト: adrienrn/Osclass
 function doModel()
 {
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             break;
         case 'regions':
             //Return regions given a countryId
             $regions = Region::newInstance()->findByCountry(Params::getParam("countryId"));
             echo json_encode($regions);
             break;
         case 'cities':
             //Returns cities given a regionId
             $cities = City::newInstance()->findByRegion(Params::getParam("regionId"));
             echo json_encode($cities);
             break;
         case 'location':
             // This is the autocomplete AJAX
             $cities = City::newInstance()->ajax(Params::getParam("term"));
             echo json_encode($cities);
             break;
         case 'userajax':
             // This is the autocomplete AJAX
             $users = User::newInstance()->ajax(Params::getParam("term"));
             if (count($users) == 0) {
                 echo json_encode(array(0 => array('id' => '', 'label' => __('No results'), 'value' => __('No results'))));
             } else {
                 echo json_encode($users);
             }
             break;
         case 'date_format':
             echo json_encode(array('format' => Params::getParam('format'), 'str_formatted' => osc_format_date(date('Y-m-d H:i:s'), Params::getParam('format'))));
             break;
         case 'runhook':
             // run hooks
             $hook = Params::getParam('hook');
             if ($hook == '') {
                 echo json_encode(array('error' => 'hook parameter not defined'));
                 break;
             }
             switch ($hook) {
                 case 'item_form':
                     osc_run_hook('item_form', Params::getParam('catId'));
                     break;
                 case 'item_edit':
                     $catId = Params::getParam("catId");
                     $itemId = Params::getParam("itemId");
                     osc_run_hook("item_edit", $catId, $itemId);
                     break;
                 default:
                     osc_run_hook('ajax_admin_' . $hook);
                     break;
             }
             break;
         case 'categories_order':
             // Save the order of the categories
             osc_csrf_check(false);
             $aIds = Params::getParam('list');
             $order = array();
             $error = 0;
             $catManager = Category::newInstance();
             $aRecountCat = array();
             foreach ($aIds as $cat) {
                 if (!isset($order[$cat['p']])) {
                     $order[$cat['p']] = 0;
                 }
                 $res = $catManager->update(array('fk_i_parent_id' => $cat['p'] == 'root' ? NULL : $cat['p'], 'i_position' => $order[$cat['p']]), array('pk_i_id' => $cat['c']));
                 if (is_bool($res) && !$res) {
                     $error = 1;
                 } else {
                     if ($res == 1) {
                         $aRecountCat[] = $cat['c'];
                     }
                 }
                 $order[$cat['p']] = $order[$cat['p']] + 1;
             }
             // update category stats
             foreach ($aRecountCat as $rId) {
                 osc_update_cat_stats_id($rId);
             }
             if ($error) {
                 $result = array('error' => __("An error occurred"));
             } else {
                 $result = array('ok' => __("Order saved"));
             }
             echo json_encode($result);
             break;
         case 'category_edit_iframe':
             $this->_exportVariableToView('category', Category::newInstance()->findByPrimaryKey(Params::getParam("id"), 'all'));
             if (count(Category::newInstance()->findSubcategories(Params::getParam("id"))) > 0) {
                 $this->_exportVariableToView('has_subcategories', true);
             } else {
                 $this->_exportVariableToView('has_subcategories', false);
             }
             $this->_exportVariableToView('languages', OSCLocale::newInstance()->listAllEnabled());
             $this->doView("categories/iframe.php");
             break;
         case 'field_categories_iframe':
             $selected = Field::newInstance()->categories(Params::getParam("id"));
             if ($selected == null) {
                 $selected = array();
             }
             $this->_exportVariableToView("selected", $selected);
             $this->_exportVariableToView("field", Field::newInstance()->findByPrimaryKey(Params::getParam("id")));
             $this->_exportVariableToView("categories", Category::newInstance()->toTreeAll());
             $this->doView("fields/iframe.php");
             break;
         case 'field_categories_post':
             osc_csrf_check(false);
             $error = 0;
             $field = Field::newInstance()->findByName(Params::getParam("s_name"));
             if (!isset($field['pk_i_id']) || isset($field['pk_i_id']) && $field['pk_i_id'] == Params::getParam("id")) {
                 // remove categories from a field
                 Field::newInstance()->cleanCategoriesFromField(Params::getParam("id"));
                 // no error... continue updating fields
                 if ($error == 0) {
                     $slug = Params::getParam("field_slug") != '' ? Params::getParam("field_slug") : Params::getParam("s_name");
                     $slug_tmp = $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower($slug)));
                     $slug_k = 0;
                     while (true) {
                         $field = Field::newInstance()->findBySlug($slug);
                         if (!$field || $field['pk_i_id'] == Params::getParam("id")) {
                             break;
                         } else {
                             $slug_k++;
                             $slug = $slug_tmp . "_" . $slug_k;
                         }
                     }
                     // trim options
                     $s_options = '';
                     $aux = Params::getParam('s_options');
                     $aAux = explode(',', $aux);
                     foreach ($aAux as &$option) {
                         $option = trim($option);
                     }
                     $s_options = implode(',', $aAux);
                     $res = Field::newInstance()->update(array('s_name' => Params::getParam("s_name"), 'e_type' => Params::getParam("field_type"), 's_slug' => $slug, 'b_required' => Params::getParam("field_required") == "1" ? 1 : 0, 'b_searchable' => Params::getParam("field_searchable") == "1" ? 1 : 0, 's_options' => $s_options), array('pk_i_id' => Params::getParam("id")));
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                 }
                 // no error... continue inserting categories-field
                 if ($error == 0) {
                     $aCategories = Params::getParam("categories");
                     if (is_array($aCategories) && count($aCategories) > 0) {
                         $res = Field::newInstance()->insertCategories(Params::getParam("id"), $aCategories);
                         if (!$res) {
                             $error = 1;
                         }
                     }
                 }
                 // error while updating?
                 if ($error == 1) {
                     $message = __("An error occurred while updating.");
                 }
             } else {
                 $error = 1;
                 $message = __("Sorry, you already have a field with that name");
             }
             if ($error) {
                 $result = array('error' => $message);
             } else {
                 $result = array('ok' => __("Saved"), 'text' => Params::getParam("s_name"), 'field_id' => Params::getParam("id"));
             }
             echo json_encode($result);
             break;
         case 'delete_field':
             osc_csrf_check(false);
             $res = Field::newInstance()->deleteByPrimaryKey(Params::getParam('id'));
             if ($res > 0) {
                 $result = array('ok' => __('The custom field has been deleted'));
             } else {
                 $result = array('error' => __('An error occurred while deleting'));
             }
             echo json_encode($result);
             break;
         case 'add_field':
             osc_csrf_check(false);
             $s_name = __('NEW custom field');
             $slug_tmp = $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower($s_name)));
             $slug_k = 0;
             while (true) {
                 $field = Field::newInstance()->findBySlug($slug);
                 if (!$field || $field['pk_i_id'] == Params::getParam("id")) {
                     break;
                 } else {
                     $slug_k++;
                     $slug = $slug_tmp . "_" . $slug_k;
                 }
             }
             $fieldManager = Field::newInstance();
             $result = $fieldManager->insertField($s_name, 'TEXT', $slug, 0, '', array());
             if ($result) {
                 echo json_encode(array('error' => 0, 'field_id' => $fieldManager->dao->insertedId(), 'field_name' => $s_name));
             } else {
                 echo json_encode(array('error' => 1));
             }
             break;
         case 'enable_category':
             osc_csrf_check(false);
             $id = strip_tags(Params::getParam('id'));
             $enabled = Params::getParam('enabled') != '' ? Params::getParam('enabled') : 0;
             $error = 0;
             $result = array();
             $aUpdated = array();
             $mCategory = Category::newInstance();
             $aCategory = $mCategory->findByPrimaryKey($id);
             if ($aCategory == false) {
                 $result = array('error' => sprintf(__("No category with id %d exists"), $id));
                 echo json_encode($result);
                 break;
             }
             // root category
             if ($aCategory['fk_i_parent_id'] == '') {
                 $mCategory->update(array('b_enabled' => $enabled), array('pk_i_id' => $id));
                 $mCategory->update(array('b_enabled' => $enabled), array('fk_i_parent_id' => $id));
                 $subCategories = $mCategory->findSubcategories($id);
                 $aIds = array($id);
                 $aUpdated[] = array('id' => $id);
                 foreach ($subCategories as $subcategory) {
                     $aIds[] = $subcategory['pk_i_id'];
                     $aUpdated[] = array('id' => $subcategory['pk_i_id']);
                 }
                 Item::newInstance()->enableByCategory($enabled, $aIds);
                 if ($enabled) {
                     $result = array('ok' => __('The category as well as its subcategories have been enabled'));
                 } else {
                     $result = array('ok' => __('The category as well as its subcategories have been disabled'));
                 }
                 $result['affectedIds'] = $aUpdated;
                 echo json_encode($result);
                 break;
             }
             // subcategory
             $parentCategory = $mCategory->findRootCategory($id);
             if (!$parentCategory['b_enabled']) {
                 $result = array('error' => __('Parent category is disabled, you can not enable that category'));
                 echo json_encode($result);
                 break;
             }
             $mCategory->update(array('b_enabled' => $enabled), array('pk_i_id' => $id));
             if ($enabled) {
                 $result = array('ok' => __('The subcategory has been enabled'));
             } else {
                 $result = array('ok' => __('The subcategory has been disabled'));
             }
             $result['affectedIds'] = array(array('id' => $id));
             echo json_encode($result);
             break;
         case 'delete_category':
             osc_csrf_check(false);
             $id = Params::getParam("id");
             $error = 0;
             $categoryManager = Category::newInstance();
             $res = $categoryManager->deleteByPrimaryKey($id);
             if ($res > 0) {
                 $message = __('The categories have been deleted');
             } else {
                 $error = 1;
                 $message = __('An error occurred while deleting');
             }
             if ($error) {
                 $result = array('error' => $message);
             } else {
                 $result = array('ok' => __("Saved"));
             }
             echo json_encode($result);
             break;
         case 'edit_category_post':
             osc_csrf_check(false);
             $id = Params::getParam("id");
             $fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0;
             $fields['b_price_enabled'] = Params::getParam('b_price_enabled') != '' ? 1 : 0;
             $apply_changes_to_subcategories = Params::getParam('apply_changes_to_subcategories') == 1 ? true : false;
             $error = 0;
             $has_one_title = 0;
             $postParams = Params::getParamsAsArray();
             foreach ($postParams as $k => $v) {
                 if (preg_match('|(.+?)#(.+)|', $k, $m)) {
                     if ($m[2] == 's_name') {
                         if ($v != "") {
                             $has_one_title = 1;
                             $aFieldsDescription[$m[1]][$m[2]] = $v;
                             $s_text = $v;
                         } else {
                             $aFieldsDescription[$m[1]][$m[2]] = NULL;
                             $error = 1;
                         }
                     } else {
                         $aFieldsDescription[$m[1]][$m[2]] = $v;
                     }
                 }
             }
             $l = osc_language();
             if ($error == 0 || $error == 1 && $has_one_title == 1) {
                 $categoryManager = Category::newInstance();
                 $res = $categoryManager->updateByPrimaryKey(array('fields' => $fields, 'aFieldsDescription' => $aFieldsDescription), $id);
                 $categoryManager->updateExpiration($id, $fields['i_expiration_days'], $apply_changes_to_subcategories);
                 $categoryManager->updatePriceEnabled($id, $fields['b_price_enabled'], $apply_changes_to_subcategories);
                 if (is_bool($res)) {
                     $error = 2;
                 }
             }
             if ($error == 0) {
                 $msg = __("Category updated correctly");
             } else {
                 if ($error == 1) {
                     if ($has_one_title == 1) {
                         $error = 4;
                         $msg = __('Category updated correctly, but some titles are empty');
                     } else {
                         $msg = __('Sorry, including at least a title is mandatory');
                     }
                 } else {
                     if ($error == 2) {
                         $msg = __('An error occurred while updating');
                     }
                 }
             }
             echo json_encode(array('error' => $error, 'msg' => $msg, 'text' => $aFieldsDescription[$l]['s_name']));
             break;
         case 'custom':
             // Execute via AJAX custom file
             if (Params::existParam('route')) {
                 $routes = Rewrite::newInstance()->getRoutes();
                 $rid = Params::getParam('route');
                 $file = '../';
                 if (isset($routes[$rid]) && isset($routes[$rid]['file'])) {
                     $file = $routes[$rid]['file'];
                 }
             } else {
                 $file = Params::getParam("ajaxfile");
             }
             if ($file == '') {
                 echo json_encode(array('error' => 'no action defined'));
                 break;
             }
             // valid file?
             if (stripos($file, '../') !== false || stripos($file, '..\\') !== false) {
                 echo json_encode(array('error' => 'no valid file'));
                 break;
             }
             if (!file_exists(osc_plugins_path() . $file)) {
                 echo json_encode(array('error' => "file doesn't exist"));
                 break;
             }
             require_once osc_plugins_path() . $file;
             break;
         case 'test_mail':
             $title = sprintf(__('Test email, %s'), osc_page_title());
             $body = __("Test email") . "<br><br>" . osc_page_title();
             $emailParams = array('subject' => $title, 'to' => osc_contact_email(), 'to_name' => 'admin', 'body' => $body, 'alt_body' => $body);
             $array = array();
             if (osc_sendMail($emailParams)) {
                 $array = array('status' => '1', 'html' => __('Email sent successfully'));
             } else {
                 $array = array('status' => '0', 'html' => __('An error occurred while sending email'));
             }
             echo json_encode($array);
             break;
         case 'test_mail_template':
             // replace por valores por defecto
             $email = Params::getParam("email");
             $title = Params::getParam("title");
             $body = Params::getParam("body", false, false);
             $emailParams = array('subject' => $title, 'to' => $email, 'to_name' => 'admin', 'body' => $body, 'alt_body' => $body);
             $array = array();
             if (osc_sendMail($emailParams)) {
                 $array = array('status' => '1', 'html' => __('Email sent successfully'));
             } else {
                 $array = array('status' => '0', 'html' => __('An error occurred while sending email'));
             }
             echo json_encode($array);
             break;
         case 'order_pages':
             osc_csrf_check(false);
             $order = Params::getParam("order");
             $id = Params::getParam("id");
             if ($order != '' && $id != '') {
                 $mPages = Page::newInstance();
                 $actual_page = $mPages->findByPrimaryKey($id);
                 $actual_order = $actual_page['i_order'];
                 $array = array();
                 $condition = array();
                 $new_order = $actual_order;
                 if ($order == 'up') {
                     $page = $mPages->findPrevPage($actual_order);
                 } else {
                     if ($order == 'down') {
                         $page = $mPages->findNextPage($actual_order);
                     }
                 }
                 if (isset($page['i_order'])) {
                     $mPages->update(array('i_order' => $page['i_order']), array('pk_i_id' => $id));
                     $mPages->update(array('i_order' => $actual_order), array('pk_i_id' => $page['pk_i_id']));
                 }
             }
             break;
         case 'check_version':
             $data = osc_file_get_contents('http://osclass.org/latest_version_v1.php?callback=?');
             $data = preg_replace('|^\\?\\((.*?)\\);$|', '$01', $data);
             $json = json_decode($data);
             if (isset($json->version)) {
                 if ($json->version > osc_version()) {
                     osc_set_preference('update_core_json', $data);
                     echo json_encode(array('error' => 0, 'msg' => __('Update available')));
                 } else {
                     osc_set_preference('update_core_json', '');
                     echo json_encode(array('error' => 0, 'msg' => __('No update available')));
                 }
                 osc_set_preference('last_version_check', time());
             } else {
                 // Latest version couldn't be checked (site down?)
                 osc_set_preference('last_version_check', time() - 82800);
                 // 82800 = 23 hours, so repeat check in one hour
                 echo json_encode(array('error' => 1, 'msg' => __('Version could not be checked')));
             }
             break;
         case 'check_languages':
             $total = _osc_check_languages_update();
             echo json_encode(array('msg' => __('Checked updates'), 'total' => $total));
             break;
         case 'check_themes':
             $total = _osc_check_themes_update();
             echo json_encode(array('msg' => __('Checked updates'), 'total' => $total));
             break;
         case 'check_plugins':
             $total = _osc_check_plugins_update();
             echo json_encode(array('msg' => __('Checked updates'), 'total' => $total));
             break;
             /******************************
              ** COMPLETE UPGRADE PROCESS **
              ******************************/
         /******************************
          ** COMPLETE UPGRADE PROCESS **
          ******************************/
         case 'upgrade':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             osc_csrf_check();
             $result = osc_do_upgrade();
             if (!defined('__FROM_CRON__') || !__FROM_CRON__) {
                 if ($result['error'] == 0) {
                     osc_add_flash_ok_message($result['message'], 'admin');
                 } else {
                     if ($result['error'] == 6) {
                         osc_add_flash_warning_message($result['message'], 'admin');
                     }
                 }
             }
             echo json_encode($result);
             break;
             /*******************************
              ** COMPLETE MARKET PROCESS **
              *******************************/
         /*******************************
          ** COMPLETE MARKET PROCESS **
          *******************************/
         case 'market':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             osc_csrf_check(false);
             $result = osc_market(Params::getParam('section'), Params::getParam('code'));
             echo json_encode($result);
             break;
         case 'check_market':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             $section = Params::getParam('section');
             $code = Params::getParam('code');
             $data = array();
             /************************
              *** CHECK VALID CODE ***
              ************************/
             if ($code != '' && $section != '') {
                 if (stripos($code, "http://") === FALSE) {
                     // OSCLASS OFFICIAL REPOSITORY
                     $data = json_decode(osc_file_get_contents(osc_market_url($section, $code), array('api_key' => osc_market_api_connect())), true);
                 } else {
                     // THIRD PARTY REPOSITORY
                     if (osc_market_external_sources()) {
                         $data = json_decode(osc_file_get_contents($code), true);
                     } else {
                         echo json_encode(array('error' => 3, 'error_msg' => __('No external sources are allowed')));
                         break;
                     }
                 }
                 if (!isset($data['s_source_file']) || !isset($data['s_update_url'])) {
                     //$data = array('error' => 2, 'error_msg' => __('Invalid code'));
                 }
             } else {
                 $data = array('error' => 1, 'error_msg' => __('No code was submitted'));
             }
             echo json_encode($data);
             break;
         case 'market_data':
             $section = Params::getParam('section');
             $page = Params::getParam("mPage");
             $featured = Params::getParam("featured");
             $sort = Params::getParam("sort");
             $order = Params::getParam("order");
             // for the moment this value is static
             $length = 9;
             if ($page >= 1) {
                 $page--;
             }
             $url = osc_market_url($section) . "page/" . $page . '/';
             if ($length != '' && is_numeric($length)) {
                 $url .= 'length/' . $length . '/';
             }
             if ($sort != '') {
                 $url .= 'order/' . $sort;
                 if ($order != '') {
                     $url .= '/' . $order;
                 }
             }
             if ($featured != '') {
                 $url = osc_market_featured_url($section);
             }
             $data = array();
             $data = json_decode(osc_file_get_contents($url, array('api_key' => osc_market_api_connect())), true);
             if (!isset($data[$section])) {
                 $data = array('error' => 1, 'error_msg' => __('No market data'));
             }
             echo 'var market_data = window.market_data || {}; market_data.' . $section . ' = ' . json_encode($data) . ';';
             break;
         case 'local_market':
             // AVOID CROSS DOMAIN PROBLEMS OF AJAX REQUEST
             $marketPage = Params::getParam("mPage");
             if ($marketPage >= 1) {
                 $marketPage--;
             }
             $out = osc_file_get_contents(osc_market_url(Params::getParam("section")) . "page/" . $marketPage, array('api_key' => osc_market_api_connect()));
             $array = json_decode($out, true);
             // do pagination
             $pageActual = $array['page'];
             $totalPages = ceil($array['total'] / $array['sizePage']);
             $params = array('total' => $totalPages, 'selected' => $pageActual, 'url' => '#{PAGE}', 'sides' => 5);
             // set pagination
             $pagination = new Pagination($params);
             $aux = $pagination->doPagination();
             $array['pagination_content'] = $aux;
             // encode to json
             echo json_encode($array);
             break;
         case 'market_connect':
             $json = osc_file_get_contents(osc_market_url() . 'connect/', array('s_email' => Params::getParam('s_email'), 's_password' => Params::getParam('s_password')));
             $data = json_decode($json, true);
             if ($data['error'] == 0) {
                 osc_set_preference('marketAPIConnect', $data['api_key']);
                 unset($data['api_key']);
                 $json = json_encode($data);
             }
             echo $json;
             break;
         case 'dashboardbox_market':
             $error = 0;
             // make market call
             $url = osc_get_preference('marketURL') . 'dashboardbox/';
             $content = '';
             if (false === ($json = @osc_file_get_contents($url))) {
                 $error = 1;
             } else {
                 $content = $json;
             }
             if ($error == 1) {
                 echo json_encode(array('error' => 1));
             } else {
                 // replace content with correct urls
                 $content = str_replace('{URL_MARKET_THEMES}', osc_admin_base_url(true) . '?page=market&action=themes', $content);
                 $content = str_replace('{URL_MARKET_PLUGINS}', osc_admin_base_url(true) . '?page=market&action=plugins', $content);
                 echo json_encode(array('html' => $content));
             }
             break;
         case 'market_header':
             $error = 0;
             // make market call
             $url = osc_get_preference('marketURL') . 'market_header/';
             $content = '';
             if (false === ($json = @osc_file_get_contents($url))) {
                 $error = 1;
             } else {
                 $content = $json;
             }
             if ($error == 1) {
                 echo json_encode(array('error' => 1));
             } else {
                 echo json_encode(array('html' => $content));
             }
             break;
         case 'location_stats':
             osc_csrf_check(false);
             $workToDo = osc_update_location_stats();
             if ($workToDo > 0) {
                 $array['status'] = 'more';
                 $array['pending'] = $workToDo;
                 echo json_encode($array);
             } else {
                 $array['status'] = 'done';
                 echo json_encode($array);
             }
             break;
         case 'country_slug':
             $exists = Country::newInstance()->findBySlug(Params::getParam('slug'));
             if (isset($exists['s_slug'])) {
                 echo json_encode(array('error' => 1, 'country' => $exists));
             } else {
                 echo json_encode(array('error' => 0));
             }
             break;
         case 'region_slug':
             $exists = Region::newInstance()->findBySlug(Params::getParam('slug'));
             if (isset($exists['s_slug'])) {
                 echo json_encode(array('error' => 1, 'region' => $exists));
             } else {
                 echo json_encode(array('error' => 0));
             }
             break;
         case 'city_slug':
             $exists = City::newInstance()->findBySlug(Params::getParam('slug'));
             if (isset($exists['s_slug'])) {
                 echo json_encode(array('error' => 1, 'city' => $exists));
             } else {
                 echo json_encode(array('error' => 0));
             }
             break;
         case 'error_permissions':
             echo json_encode(array('error' => __("You don't have the necessary permissions")));
             break;
         default:
             echo json_encode(array('error' => __('no action defined')));
             break;
     }
     // clear all keep variables into session
     Session::newInstance()->_dropKeepForm();
     Session::newInstance()->_clearVariables();
 }
コード例 #13
0
ファイル: index.php プロジェクト: pombredanne/ArcherSys
                        </div>
                    </div>
                    <div class="form-row">
                        <div class="form-label"><?php _e('Market external sources'); ?></div>
                        <div class="form-controls">
                            <div class="form-label-checkbox">
                                <label>
                                    <input type="checkbox" <?php echo ( osc_market_external_sources() ? 'checked="checked"' : '' ); ?> name="market_external_sources" />
                                    <?php _e('Allow updates and installations of non-official plugins and themes'); ?>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-row">
                        <div class="form-label"></div>
                        <div class="form-controls">
                            <?php printf(__('Last checked on %s'), osc_format_date( date('d-m-Y h:i:s', osc_get_preference('themes_last_version_check')) )); ?> <a class="btn btn-mini" href="<?php echo osc_admin_base_url(true); ?>?page=settings&action=check_updates"><?php _e('Check updates');?></a>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="form-actions">
                        <input type="submit" id="save_changes" value="<?php echo osc_esc_html( __('Save changes') ); ?>" class="btn btn-submit" />
                    </div>
                </div>
            </fieldset>
        </form>
    </div>
    <!-- /settings form -->
</div>
<?php osc_current_admin_theme_path( 'parts/footer.php' ); ?>
コード例 #14
0
ファイル: item-sidebar.php プロジェクト: oanav/closetshare
    ?>
            <?php 
    _e('Price', 'osclasswizards');
    ?>
: <?php 
    echo osc_item_formated_price();
    ?>
            <?php 
}
?>
        </div>
        <div class="item-date">
            <i class="fa fa-calendar"></i>
            <?php 
if (osc_item_pub_date() !== '') {
    printf(__('%1$s', 'osclasswizards'), osc_format_date(osc_item_pub_date()));
}
?>
        </div>
        <?php 
if (count($location) > 0) {
    ?>
        <div id="item_location">
            <i class="fa fa-map-marker"></i>
            <?php 
    echo implode(', ', $location);
    ?>
        </div>
        <?php 
}
?>
コード例 #15
0
ファイル: item.php プロジェクト: hashemgamal/OSClass
                </div>
                <div id="main">
                    <div id="type_dates">
                        <strong><?php 
echo osc_item_category();
?>
</strong>
                        <em class="publish"><?php 
if (osc_item_pub_date() != '') {
    echo osc_format_date(osc_item_pub_date());
}
?>
</em>
                        <em class="update"><?php 
if (osc_item_mod_date() != '') {
    echo osc_format_date(osc_item_mod_date());
}
?>
</em>
                    </div>
                    <ul id="item_location">
                        <?php 
if (osc_item_country() != "") {
    ?>
<li><?php 
    _e("Country", 'modern');
    ?>
: <strong><?php 
    echo osc_item_country();
    ?>
</strong></li><?php 
コード例 #16
0
ファイル: index.php プロジェクト: oanav/closetshare
function aam_pub_repub_date()
{
    $conn = getConnection();
    $rePubTime = $conn->osc_dbFetchResult("SELECT * FROM %st_item_adManage_limit WHERE fk_i_item_id = '%d'", DB_TABLE_PREFIX, osc_item_id());
    if ($rePubTime['r_times'] >= 1) {
        return (string) __('Republished Date: ', 'adManage') . osc_format_date(osc_item_pub_date());
    } else {
        return (string) __('Published Date: ', 'adManage') . osc_format_date(osc_item_pub_date());
    }
}
コード例 #17
0
ファイル: item.php プロジェクト: kraymond70/osclassclsx
        <h1><strong><?php 
echo osc_item_title();
?>
</strong></h1>
        <!-- <div class="item-header">
            <div>
                <?php 
if (osc_item_pub_date() !== '') {
    printf(__('<strong class="publish">Published date</strong>: %1$s', 'osclassclsx'), osc_format_date(osc_item_pub_date()));
}
?>
            </div>
            <div>
                <?php 
if (osc_item_mod_date() !== '') {
    printf(__('<strong class="update">Modified date:</strong> %1$s', 'osclassclsx'), osc_format_date(osc_item_mod_date()));
}
?>
            </div>
            <?php 
if (count($location) > 0) {
    ?>
                <ul id="item_location">
                    <li><strong><?php 
    _e("Location", 'osclassclsx');
    ?>
</strong>: <?php 
    echo implode(', ', $location);
    ?>
</li>
                </ul>
コード例 #18
0
        private function processDataReported($items)
        {
            if(!empty($items)) {

                $csrf_token_url = osc_csrf_token_url();
                foreach($items as $aRow) {
                    View::newInstance()->_exportVariableToView('item', $aRow);
                    $row     = array();
                    $options = array();
                    // -- prepare data --
                    // prepare item title
                    $title = mb_substr($aRow['s_title'], 0, 30, 'UTF-8');
                    if($title != $aRow['s_title']) {
                        $title .= '...';
                    }

                    $options[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=clear_stat&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;stat=all">' . __('Clear All') .'</a>';
                    if( $aRow['i_num_spam'] > 0 ) {
                        $options[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=clear_stat&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;stat=spam">' . __('Clear Spam') .'</a>';
                    }
                    if( $aRow['i_num_bad_classified'] > 0 ) {
                        $options[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=clear_stat&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;stat=bad">' . __('Clear Misclassified') .'</a>';
                    }
                    if( $aRow['i_num_repeated'] > 0 ) {
                        $options[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=clear_stat&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;stat=duplicated">' . __('Clear Duplicated') .'</a>';
                    }
                    if( $aRow['i_num_offensive'] > 0 ) {
                        $options[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=clear_stat&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;stat=offensive">' . __('Clear Offensive') .'</a>';
                    }
                    if( $aRow['i_num_expired'] > 0 ) {
                        $options[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=clear_stat&amp;id=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '&amp;stat=expired">' . __('Clear Expired') .'</a>';
                    }
                    if(count($options) > 0) {
                        $options[] = '<a href="' . osc_admin_base_url(true) . '?page=items&amp;action=item_edit&amp;id=' . $aRow['pk_i_id'] . '">' . __('Edit') . '</a>';
                        $options[] = '<a onclick="return delete_dialog(\'' . $aRow['pk_i_id'] . '\');" href="' . osc_admin_base_url(true) . '?page=items&amp;action=delete&amp;id[]=' . $aRow['pk_i_id'] . '&amp;' . $csrf_token_url . '">' . __('Delete') . '</a>';
                    }

                    // create list of actions
                    $auxOptions = '<ul>'.PHP_EOL;
                    foreach( $options as $actual ) {
                        $auxOptions .= '<li>'.$actual.'</li>'.PHP_EOL;
                    }
                    $auxOptions  .= '</ul>'.PHP_EOL;

                    $actions = '<div class="actions">'.$auxOptions.'</div>'.PHP_EOL;

                    // fill a row
                    $row['bulkactions'] = '<input type="checkbox" name="id[]" value="' . $aRow['pk_i_id'] . '" active="' . $aRow['b_active'] . '" blocked="' . $aRow['b_enabled'] . '"/>';
                    $row['title'] = '<a href="' . osc_item_url().'" target="_blank">' . $title . '</a>'. $actions;
                    $row['user'] = $aRow['s_user_name'];
                    $row['spam'] = $aRow['i_num_spam'];
                    $row['bad'] = $aRow['i_num_bad_classified'];
                    $row['rep'] = $aRow['i_num_repeated'];
                    $row['exp'] = $aRow['i_num_expired'];
                    $row['off'] = $aRow['i_num_offensive'];
                    $row['date'] = osc_format_date($aRow['dt_pub_date']);
                    $row['expiration'] = ($aRow['dt_expiration'] != '9999-12-31 23:59:59') ? osc_format_date($aRow['dt_expiration']) : __('Never expires');

                    $row = osc_apply_filter('items_processing_reported_row', $row, $aRow);

                    $this->addRow($row);
                    $this->rawRows[] = $aRow;
                }

            }
        }
コード例 #19
0
ファイル: item.php プロジェクト: nsswaga/OSClass
                </div>
                <div id="main">
                    <div id="type_dates">
                        <strong><?php 
echo osc_item_category();
?>
</strong>
                        <em class="publish"><?php 
if (osc_item_pub_date() != '') {
    echo __('Published date', 'modern') . ': ' . osc_format_date(osc_item_pub_date());
}
?>
</em>
                        <em class="update"><?php 
if (osc_item_mod_date() != '') {
    echo __('Modified date', 'modern') . ': ' . osc_format_date(osc_item_mod_date());
}
?>
</em>
                    </div>
                    <ul id="item_location">
                        <?php 
if (osc_item_country() != "") {
    ?>
<li><?php 
    _e("Country", 'modern');
    ?>
: <strong><?php 
    echo osc_item_country();
    ?>
</strong></li><?php 
コード例 #20
0
ファイル: item.php プロジェクト: blairmain/theme-realestate
    echo '</div>';
    echo '</div>';
}
//echo join(', ',$regionData);
?>
                <div class="has-icon dates">
                    <div class="ico-dates ico"></div>
                    <div><?php 
if (osc_item_pub_date() != '') {
    echo __('Published', 'realestate') . ': ' . osc_format_date(osc_item_pub_date());
}
?>
</div>
                    <div><?php 
if (osc_item_mod_date() != '') {
    echo __('Modified', 'realestate') . ': ' . osc_format_date(osc_item_mod_date());
}
?>
</div>
                </div>
                <div class="has-icon author">
                    <div class="ico-author ico"></div>
                    <?php 
if (osc_item_user_id() != null) {
    ?>
                            <?php 
    echo osc_item_contact_name();
    ?>
                    <?php 
} else {
    ?>
コード例 #21
0
ファイル: user-outbox.php プロジェクト: xop32/OSClass-PM
                      <tr class="<?php 
            echo $odd_even;
            ?>
">
                      <?php 
            $user = User::newInstance()->findByPrimaryKey($recipPM['recip_id']);
            ?>
                        <td class="pmCheckboxes"><input class="delChecks" type="checkbox" id="delete<?php 
            echo $recipPM['pm_id'];
            ?>
" name="pms[]" value="<?php 
            echo $recipPM['pm_id'];
            ?>
" /></td>
                        <td><?php 
            echo osc_format_date($recipPM['message_date']) . ', ' . osclass_pm_format_time($recipPM['message_date']);
            ?>
</td>
                        <td><a class="mesLink" href="<?php 
            echo osc_render_file_url(osc_plugin_folder(__FILE__) . 'user-messages.php?message=' . $recipPM['pm_id'] . '&box=outbox');
            ?>
"><?php 
            echo $recipPM['pm_subject'];
            ?>
</a></td>
                        <td><?php 
            echo $user['s_name'];
            ?>
</td>
                      </tr>
                  <?php 
コード例 #22
0
ファイル: ajax.php プロジェクト: ricktaylord/OSClass
 function doModel()
 {
     //specific things for this class
     switch ($this->action) {
         case 'bulk_actions':
             break;
         case 'regions':
             //Return regions given a countryId
             $regions = Region::newInstance()->findByCountry(Params::getParam("countryId"));
             echo json_encode($regions);
             break;
         case 'cities':
             //Returns cities given a regionId
             $cities = City::newInstance()->findByRegion(Params::getParam("regionId"));
             echo json_encode($cities);
             break;
         case 'location':
             // This is the autocomplete AJAX
             $cities = City::newInstance()->ajax(Params::getParam("term"));
             echo json_encode($cities);
             break;
         case 'userajax':
             // This is the autocomplete AJAX
             $users = User::newInstance()->ajax(Params::getParam("term"));
             if (count($users) == 0) {
                 echo json_encode(array(0 => array('id' => '', 'label' => __('No results'), 'value' => __('No results'))));
             } else {
                 echo json_encode($users);
             }
             break;
         case 'date_format':
             echo json_encode(array('format' => Params::getParam('format'), 'str_formatted' => osc_format_date(date(Params::getParam('format')))));
             break;
         case 'runhook':
             // run hooks
             $hook = Params::getParam('hook');
             if ($hook == '') {
                 echo json_encode(array('error' => 'hook parameter not defined'));
                 break;
             }
             switch ($hook) {
                 case 'item_form':
                     osc_run_hook('item_form', Params::getParam('catId'));
                     break;
                 case 'item_edit':
                     $catId = Params::getParam("catId");
                     $itemId = Params::getParam("itemId");
                     osc_run_hook("item_edit", $catId, $itemId);
                     break;
                 default:
                     osc_run_hook('ajax_admin_' . $hook);
                     break;
             }
             break;
         case 'items':
             // Return items (use external file oc-admin/ajax/item_processing.php)
             require_once osc_admin_base_path() . 'ajax/items_processing.php';
             $items_processing = new ItemsProcessingAjax(Params::getParamsAsArray("get"));
             break;
         case 'users':
             // Return items (use external file oc-admin/ajax/item_processing.php)
             require_once osc_admin_base_path() . 'ajax/users_processing.php';
             $users_processing = new UsersProcessingAjax(Params::getParamsAsArray("get"));
             break;
         case 'media':
             // Return items (use external file oc-admin/ajax/media_processing.php)
             require_once osc_admin_base_path() . 'ajax/media_processing.php';
             $media_processing = new MediaProcessingAjax(Params::getParamsAsArray("get"));
             break;
         case 'categories_order':
             // Save the order of the categories
             $aIds = Params::getParam('list');
             $orderParent = 0;
             $orderSub = 0;
             $catParent = 0;
             $error = 0;
             $catManager = Category::newInstance();
             $aRecountCat = array();
             foreach ($aIds as $id => $parent) {
                 if ($parent == 'root') {
                     $res = $catManager->updateOrder($id, $orderParent);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                     // find category
                     $auxCategory = Category::newInstance()->findByPrimaryKey($id);
                     // set parent category
                     $conditions = array('pk_i_id' => $id);
                     $array['fk_i_parent_id'] = NULL;
                     $res = $catManager->update($array, $conditions);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     } else {
                         if ($res == 1) {
                             // updated ok
                             $parentId = $auxCategory['fk_i_parent_id'];
                             if ($parentId) {
                                 // update parent category stats
                                 array_push($aRecountCat, $id);
                                 array_push($aRecountCat, $parentId);
                             }
                         }
                     }
                     $orderParent++;
                 } else {
                     if ($parent != $catParent) {
                         $catParent = $parent;
                         $orderSub = 0;
                     }
                     $res = $catManager->updateOrder($id, $orderSub);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                     // set parent category
                     $auxCategory = Category::newInstance()->findByPrimaryKey($id);
                     $auxCategoryP = Category::newInstance()->findByPrimaryKey($catParent);
                     $conditions = array('pk_i_id' => $id);
                     $array['fk_i_parent_id'] = $catParent;
                     $res = $catManager->update($array, $conditions);
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     } else {
                         if ($res == 1) {
                             // updated ok
                             // update category parent
                             $prevParentId = $auxCategory['fk_i_parent_id'];
                             $parentId = $auxCategoryP['pk_i_id'];
                             array_push($aRecountCat, $prevParentId);
                             array_push($aRecountCat, $parentId);
                         }
                     }
                     $orderSub++;
                 }
             }
             // update category stats
             foreach ($aRecountCat as $rId) {
                 osc_update_cat_stats_id($rId);
             }
             if ($error) {
                 $result = array('error' => __("Some error ocurred"));
             } else {
                 $result = array('ok' => __("Order saved"));
             }
             echo json_encode($result);
             break;
         case 'category_edit_iframe':
             $this->_exportVariableToView('category', Category::newInstance()->findByPrimaryKey(Params::getParam("id")));
             $this->_exportVariableToView('languages', OSCLocale::newInstance()->listAllEnabled());
             $this->doView("categories/iframe.php");
             break;
         case 'field_categories_iframe':
             $selected = Field::newInstance()->categories(Params::getParam("id"));
             if ($selected == null) {
                 $selected = array();
             }
             $this->_exportVariableToView("selected", $selected);
             $this->_exportVariableToView("field", Field::newInstance()->findByPrimaryKey(Params::getParam("id")));
             $this->_exportVariableToView("categories", Category::newInstance()->toTreeAll());
             $this->doView("fields/iframe.php");
             break;
         case 'field_categories_post':
             $error = 0;
             $field = Field::newInstance()->findByName(Params::getParam("s_name"));
             if (!isset($field['pk_i_id']) || isset($field['pk_i_id']) && $field['pk_i_id'] == Params::getParam("id")) {
                 // remove categories from a field
                 Field::newInstance()->cleanCategoriesFromField(Params::getParam("id"));
                 // no error... continue updating fields
                 if ($error == 0) {
                     $slug = Params::getParam("field_slug") != '' ? Params::getParam("field_slug") : Params::getParam("s_name");
                     $slug_tmp = $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower($slug)));
                     $slug_k = 0;
                     while (true) {
                         $field = Field::newInstance()->findBySlug($slug);
                         if (!$field || $field['pk_i_id'] == Params::getParam("id")) {
                             break;
                         } else {
                             $slug_k++;
                             $slug = $slug_tmp . "_" . $slug_k;
                         }
                     }
                     $res = Field::newInstance()->update(array('s_name' => Params::getParam("s_name"), 'e_type' => Params::getParam("field_type"), 's_slug' => $slug, 'b_required' => Params::getParam("field_required") == "1" ? 1 : 0, 's_options' => Params::getParam('s_options')), array('pk_i_id' => Params::getParam("id")));
                     if (is_bool($res) && !$res) {
                         $error = 1;
                     }
                 }
                 // no error... continue inserting categories-field
                 if ($error == 0) {
                     $aCategories = Params::getParam("categories");
                     if (is_array($aCategories) && count($aCategories) > 0) {
                         $res = Field::newInstance()->insertCategories(Params::getParam("id"), $aCategories);
                         if (!$res) {
                             $error = 1;
                         }
                     }
                 }
                 // error while updating?
                 if ($error == 1) {
                     $message = __("Error while updating.");
                 }
             } else {
                 $error = 1;
                 $message = __("Sorry, you already have one field with that name");
             }
             if ($error) {
                 $result = array('error' => $message);
             } else {
                 $result = array('ok' => __("Saved"), 'text' => Params::getParam("s_name"), 'field_id' => $field['pk_i_id']);
             }
             echo json_encode($result);
             break;
         case 'delete_field':
             $id = Params::getParam("id");
             $error = 0;
             $fieldManager = Field::newInstance();
             $res = $fieldManager->deleteByPrimaryKey($id);
             if ($res > 0) {
                 $message = __('The custom field have been deleted');
             } else {
                 $error = 1;
                 $message = __('Error while deleting');
             }
             if ($error) {
                 $result = array('error' => $message);
             } else {
                 $result = array('ok' => __("Saved"));
             }
             echo json_encode($result);
             break;
         case 'add_field':
             $s_name = __('NEW custom field');
             $slug_tmp = $slug = preg_replace('|([-]+)|', '-', preg_replace('|[^a-z0-9_-]|', '-', strtolower($s_name)));
             $slug_k = 0;
             while (true) {
                 $field = Field::newInstance()->findBySlug($slug);
                 if (!$field || $field['pk_i_id'] == Params::getParam("id")) {
                     break;
                 } else {
                     $slug_k++;
                     $slug = $slug_tmp . "_" . $slug_k;
                 }
             }
             $fieldManager = Field::newInstance();
             $result = $fieldManager->insertField($s_name, 'TEXT', $slug, 0, '', array());
             if ($result) {
                 echo json_encode(array('error' => 0, 'field_id' => $fieldManager->dao->insertedId(), 'field_name' => $s_name));
             } else {
                 echo json_encode(array('error' => 1));
             }
             break;
         case 'enable_category':
             $id = strip_tags(Params::getParam('id'));
             $enabled = Params::getParam('enabled') != '' ? Params::getParam('enabled') : 0;
             $error = 0;
             $result = array();
             $aUpdated = array();
             $mCategory = Category::newInstance();
             $aCategory = $mCategory->findByPrimaryKey($id);
             if ($aCategory == false) {
                 $result = array('error' => sprintf(__("It doesn't exist a category with this id: %d"), $id));
                 echo json_encode($result);
                 break;
             }
             // root category
             if ($aCategory['fk_i_parent_id'] == '') {
                 $mCategory->update(array('b_enabled' => $enabled), array('pk_i_id' => $id));
                 $mCategory->update(array('b_enabled' => $enabled), array('fk_i_parent_id' => $id));
                 $subCategories = $mCategory->findSubcategories($id);
                 $aIds = array($id);
                 $aUpdated[] = array('id' => $id);
                 foreach ($subCategories as $subcategory) {
                     $aIds[] = $subcategory['pk_i_id'];
                     $aUpdated[] = array('id' => $subcategory['pk_i_id']);
                 }
                 Item::newInstance()->enableByCategory($enabled, $aIds);
                 if ($enabled) {
                     $result = array('ok' => __('The category and its subcategories have been enabled'));
                 } else {
                     $result = array('ok' => __('The category and its subcategories have been disabled'));
                 }
                 $result['affectedIds'] = $aUpdated;
                 echo json_encode($result);
                 break;
             }
             // subcategory
             $parentCategory = $mCategory->findRootCategory($id);
             if (!$parentCategory['b_enabled']) {
                 $result = array('error' => __('Parent category is disabled, you can not enable that category'));
                 echo json_encode($result);
                 break;
             }
             $mCategory->update(array('b_enabled' => $enabled), array('pk_i_id' => $id));
             if ($enabled) {
                 $result = array('ok' => __('The subcategory has been enabled'));
             } else {
                 $result = array('ok' => __('The subcategory has been disabled'));
             }
             $result['affectedIds'] = array(array('id' => $id));
             echo json_encode($result);
             break;
         case 'delete_category':
             $id = Params::getParam("id");
             $error = 0;
             $categoryManager = Category::newInstance();
             $res = $categoryManager->deleteByPrimaryKey($id);
             if ($res > 0) {
                 $message = __('The categories have been deleted');
             } else {
                 $error = 1;
                 $message = __('Error while deleting');
             }
             if ($error) {
                 $result = array('error' => $message);
             } else {
                 $result = array('ok' => __("Saved"));
             }
             echo json_encode($result);
             break;
         case 'edit_category_post':
             $id = Params::getParam("id");
             $fields['i_expiration_days'] = Params::getParam("i_expiration_days") != '' ? Params::getParam("i_expiration_days") : 0;
             $error = 0;
             $has_one_title = 0;
             $postParams = Params::getParamsAsArray();
             foreach ($postParams as $k => $v) {
                 if (preg_match('|(.+?)#(.+)|', $k, $m)) {
                     if ($m[2] == 's_name') {
                         if ($v != "") {
                             $has_one_title = 1;
                             $aFieldsDescription[$m[1]][$m[2]] = $v;
                             $s_text = $v;
                         } else {
                             $aFieldsDescription[$m[1]][$m[2]] = ' ';
                             $error = 1;
                         }
                     } else {
                         $aFieldsDescription[$m[1]][$m[2]] = $v;
                     }
                 }
             }
             $l = osc_language();
             if ($error == 0 || $error == 1 && $has_one_title == 1) {
                 $categoryManager = Category::newInstance();
                 $res = $categoryManager->updateByPrimaryKey(array('fields' => $fields, 'aFieldsDescription' => $aFieldsDescription), $id);
                 if (is_bool($res)) {
                     $error = 2;
                 }
             }
             if ($error == 0) {
                 $msg = __("Category updated correctly");
             } else {
                 if ($error == 1) {
                     if ($has_one_title == 1) {
                         $error = 4;
                         $msg = __('Category updated correctly, but some titles were empty');
                     } else {
                         $msg = __('Sorry, at least a title is needed');
                     }
                 } else {
                     if ($error == 2) {
                         $msg = __('Error while updating');
                     }
                 }
             }
             echo json_encode(array('error' => $error, 'msg' => $msg, 'text' => $aFieldsDescription[$l]['s_name']));
             break;
         case 'custom':
             // Execute via AJAX custom file
             $ajaxFile = Params::getParam("ajaxfile");
             if ($ajaxFile == '') {
                 echo json_encode(array('error' => 'no action defined'));
                 break;
             }
             // valid file?
             if (stripos($ajaxFile, '../') !== false) {
                 echo json_encode(array('error' => 'no valid ajaxFile'));
                 break;
             }
             if (!file_exists(osc_plugins_path() . $ajaxFile)) {
                 echo json_encode(array('error' => "ajaxFile doesn't exist"));
                 break;
             }
             require_once osc_plugins_path() . $ajaxFile;
             break;
         case 'test_mail':
             $title = sprintf(__('Test email, %s'), osc_page_title());
             $body = __("Test email") . "<br><br>" . osc_page_title();
             $emailParams = array('subject' => $title, 'to' => osc_contact_email(), 'to_name' => 'admin', 'body' => $body, 'alt_body' => $body);
             $array = array();
             if (osc_sendMail($emailParams)) {
                 $array = array('status' => '1', 'html' => __('Email sent successfully'));
             } else {
                 $array = array('status' => '0', 'html' => __('An error has occurred while sending email'));
             }
             echo json_encode($array);
             break;
         case 'order_pages':
             $order = Params::getParam("order");
             $id = Params::getParam("id");
             if ($order != '' && $id != '') {
                 $mPages = Page::newInstance();
                 $actual_page = $mPages->findByPrimaryKey($id);
                 $actual_order = $actual_page['i_order'];
                 $array = array();
                 $condition = array();
                 $new_order = $actual_order;
                 if ($order == 'up') {
                     $page = $mPages->findPrevPage($actual_order);
                 } else {
                     if ($order == 'down') {
                         $page = $mPages->findNextPage($actual_order);
                     }
                 }
                 if (isset($page['i_order'])) {
                     $mPages->update(array('i_order' => $page['i_order']), array('pk_i_id' => $id));
                     $mPages->update(array('i_order' => $actual_order), array('pk_i_id' => $page['pk_i_id']));
                 }
                 // TO BE IMPROVED
                 // json for datatables
                 $prefLocale = osc_current_user_locale();
                 $this->_exportVariableToView('pages', $mPages->listAll(0));
                 $o_json = array();
                 while (osc_has_static_pages()) {
                     $row = array();
                     $page = osc_static_page();
                     $content = array();
                     if (isset($page['locale'][$prefLocale]) && !empty($page['locale'][$prefLocale]['s_title'])) {
                         $content = $page['locale'][$prefLocale];
                     } else {
                         $content = current($page['locale']);
                     }
                     $options = array();
                     $options[] = '<a href="' . osc_static_page_url() . '">' . __('View page') . '</a>';
                     $options[] = '<a href="' . osc_admin_base_url(true) . '?page=pages&amp;action=edit&amp;id=' . osc_static_page_id() . '">' . __('Edit') . '</a>';
                     if (!$page['b_indelible']) {
                         $options[] = '<a onclick="javascript:return confirm(\'' . osc_esc_js("This action can't be undone. Are you sure you want to continue?") . '\')" href="' . osc_admin_base_url(true) . '?page=pages&amp;action=delete&amp;id=' . osc_static_page_id() . '">' . __('Delete') . '</a>';
                     }
                     $row[] = '<input type="checkbox" name="id[]"" value="' . osc_static_page_id() . '"" />';
                     $row[] = $page['s_internal_name'] . '<div id="datatables_quick_edit" style="display: none;">' . implode(' &middot; ', $options) . '</div>';
                     $row[] = $content['s_title'];
                     $row[] = osc_static_page_order() . ' <img id="up" onclick="order_up(' . osc_static_page_id() . ');" style="cursor:pointer; width:15px; height:15px;" src="' . osc_current_admin_theme_url('images/arrow_up.png') . '"/> <br/><img id="down" onclick="order_down(' . osc_static_page_id() . ');" style="cursor:pointer; width:15px; height:15px; margin-left: 10px;" src="' . osc_current_admin_theme_url('images/arrow_down.png') . '"/>';
                     $o_json[] = $row;
                 }
                 echo json_encode($o_json);
             }
             break;
             /******************************
              ** COMPLETE UPGRADE PROCESS **
              ******************************/
         /******************************
          ** COMPLETE UPGRADE PROCESS **
          ******************************/
         case 'upgrade':
             // AT THIS POINT WE KNOW IF THERE'S AN UPDATE OR NOT
             $message = "";
             $error = 0;
             $sql_error_msg = "";
             $rm_errors = 0;
             $perms = osc_save_permissions();
             osc_change_permissions();
             $maintenance_file = ABS_PATH . '.maintenance';
             $fileHandler = @fopen($maintenance_file, 'w');
             fclose($fileHandler);
             /***********************
              **** DOWNLOAD FILE ****
              ***********************/
             $data = osc_file_get_contents("http://osclass.org/latest_version.php");
             $data = json_decode(substr($data, 1, strlen($data) - 3), true);
             $source_file = $data['url'];
             if ($source_file != '') {
                 $tmp = explode("/", $source_file);
                 $filename = end($tmp);
                 $result = osc_downloadFile($source_file, $filename);
                 if ($result) {
                     // Everything is OK, continue
                     /**********************
                      ***** UNZIP FILE *****
                      **********************/
                     @mkdir(ABS_PATH . 'oc-temp', 0777);
                     $res = osc_unzip_file(osc_content_path() . 'downloads/' . $filename, ABS_PATH . 'oc-temp/');
                     if ($res == 1) {
                         // Everything is OK, continue
                         /**********************
                          ***** COPY FILES *****
                          **********************/
                         $fail = -1;
                         if ($handle = opendir(ABS_PATH . 'oc-temp')) {
                             $fail = 0;
                             while (false !== ($_file = readdir($handle))) {
                                 if ($_file != '.' && $_file != '..' && $_file != 'remove.list' && $_file != 'upgrade.sql' && $_file != 'customs.actions') {
                                     $data = osc_copy(ABS_PATH . "oc-temp/" . $_file, ABS_PATH . $_file);
                                     if ($data == false) {
                                         $fail = 1;
                                     }
                                 }
                             }
                             closedir($handle);
                             if ($fail == 0) {
                                 // Everything is OK, continue
                                 /************************
                                  *** UPGRADE DATABASE ***
                                  ************************/
                                 $error_queries = array();
                                 if (file_exists(osc_lib_path() . 'osclass/installer/struct.sql')) {
                                     $sql = file_get_contents(osc_lib_path() . 'osclass/installer/struct.sql');
                                     $conn = DBConnectionClass::newInstance();
                                     $c_db = $conn->getOsclassDb();
                                     $comm = new DBCommandClass($c_db);
                                     $error_queries = $comm->updateDB(str_replace('/*TABLE_PREFIX*/', DB_TABLE_PREFIX, $sql));
                                 }
                                 if ($error_queries[0]) {
                                     // Everything is OK, continue
                                     /**********************************
                                      ** EXECUTING ADDITIONAL ACTIONS **
                                      **********************************/
                                     if (file_exists(osc_lib_path() . 'osclass/upgrade-funcs.php')) {
                                         // There should be no errors here
                                         define('AUTO_UPGRADE', true);
                                         require_once osc_lib_path() . 'osclass/upgrade-funcs.php';
                                     }
                                     // Additional actions is not important for the rest of the proccess
                                     // We will inform the user of the problems but the upgrade could continue
                                     /****************************
                                      ** REMOVE TEMPORARY FILES **
                                      ****************************/
                                     $path = ABS_PATH . 'oc-temp';
                                     $rm_errors = 0;
                                     $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
                                     for ($dir->rewind(); $dir->valid(); $dir->next()) {
                                         if ($dir->isDir()) {
                                             if ($dir->getFilename() != '.' && $dir->getFilename() != '..') {
                                                 if (!rmdir($dir->getPathname())) {
                                                     $rm_errors++;
                                                 }
                                             }
                                         } else {
                                             if (!unlink($dir->getPathname())) {
                                                 $rm_errors++;
                                             }
                                         }
                                     }
                                     if (!rmdir($path)) {
                                         $rm_errors++;
                                     }
                                     $deleted = @unlink(ABS_PATH . '.maintenance');
                                     if ($rm_errors == 0) {
                                         $message = __('Everything was OK! Your OSClass installation is updated');
                                     } else {
                                         $message = __('Almost everything was OK! Your OSClass installation is updated, but there were some errors removing temporary files. Please, remove manually the "oc-temp" folder');
                                         $error = 6;
                                         // Some errors removing files
                                     }
                                 } else {
                                     $sql_error_msg = $error_queries[2];
                                     $message = __('Problems upgrading the database');
                                     $error = 5;
                                     // Problems upgrading the database
                                 }
                             } else {
                                 $message = __('Problems copying files. Maybe permissions are not correct');
                                 $error = 4;
                                 // Problems copying files. Maybe permissions are not correct
                             }
                         } else {
                             $message = __('Nothing to copy');
                             $error = 99;
                             // Nothing to copy. THIS SHOULD NEVER HAPPENS, means we dont update any file!
                         }
                     } else {
                         $message = __('Unzip failed');
                         $error = 3;
                         // Unzip failed
                     }
                 } else {
                     $message = __('Download failed');
                     $error = 2;
                     // Download failed
                 }
             } else {
                 $message = __('Missing download URL');
                 $error = 1;
                 // Missing download URL
             }
             if ($error == 5) {
                 $message .= "<br /><br />" . __('We had some errors upgrading your database. The follwing queries failed') . implode("<br />", $sql_error_msg);
             }
             echo $message;
             foreach ($perms as $k => $v) {
                 @chmod($k, $v);
             }
             break;
         case 'location_stats':
             $workToDo = LocationsTmp::newInstance()->count();
             if ($workToDo > 0) {
                 // there are wotk to do
                 $aLocations = LocationsTmp::newInstance()->getLocations(1000);
                 foreach ($aLocations as $location) {
                     $id = $location['id_location'];
                     $type = $location['e_type'];
                     $data = 0;
                     // update locations stats
                     switch ($type) {
                         case 'COUNTRY':
                             $numItems = CountryStats::newInstance()->calculateNumItems($id);
                             $data = CountryStats::newInstance()->setNumItems($id, $numItems);
                             unset($numItems);
                             break;
                         case 'REGION':
                             $numItems = RegionStats::newInstance()->calculateNumItems($id);
                             $data = RegionStats::newInstance()->setNumItems($id, $numItems);
                             unset($numItems);
                             break;
                         case 'CITY':
                             $numItems = CityStats::newInstance()->calculateNumItems($id);
                             $data = CityStats::newInstance()->setNumItems($id, $numItems);
                             unset($numItems);
                             break;
                         default:
                             break;
                     }
                     if ($data >= 0) {
                         LocationsTmp::newInstance()->delete(array('e_type' => $location['e_type'], 'id_location' => $location['id_location']));
                     }
                 }
                 $array['status'] = 'more';
                 $array['pending'] = $workToDo = LocationsTmp::newInstance()->count();
                 echo json_encode($array);
             } else {
                 $array['status'] = 'done';
                 echo json_encode($array);
             }
             break;
         default:
             echo json_encode(array('error' => __('no action defined')));
             break;
     }
     // clear all keep variables into session
     Session::newInstance()->_dropKeepForm();
     Session::newInstance()->_clearVariables();
 }
コード例 #23
0
ファイル: functions.php プロジェクト: jhalendra/classmandu
function nc_osc_get_logged_user_ref_date()
{
    $user = View::newInstance()->_get('_loggedUser');
    $d = $user['dt_reg_date'];
    return osc_format_date($d, 'F j, Y');
}
コード例 #24
0
ファイル: comments.php プロジェクト: abhi143u11/ads
                ?>
"><?php 
                echo osc_comment_author_name();
                ?>
</a> <small><?php 
                echo osc_format_date(osc_comment_pub_date());
                ?>
</small></h5>
                            <?php 
            } else {
                ?>
                            <h5><?php 
                echo osc_comment_author_name();
                ?>
 <small><?php 
                echo osc_format_date(osc_comment_pub_date());
                ?>
</small></h5>
                            <?php 
            }
            ?>
                            <p><?php 
            echo nl2br(osc_comment_body());
            ?>
</p>
                            <?php 
            if (osc_comment_user_id() && osc_comment_user_id() == osc_logged_user_id()) {
                ?>
                            <p><a rel="nofollow" class="btn-danger" href="<?php 
                echo osc_delete_comment_url();
                ?>
コード例 #25
0
ファイル: admin-messages.php プロジェクト: oanav/closetshare
            <div class="pm_tools">
               <div class="pm_sub">
                  <span class="subject_pm"><?php 
echo $pm['pm_subject'];
?>
</span>
                  <br />
                  <?php 
if ($pm['recip_id'] != 0) {
    $user = User::newInstance()->findByPrimaryKey($pm['recip_id']);
} else {
    $user['s_name'] = pmAdmin();
}
?>
                  <?php 
echo __('Sent to: ', 'osclass_pm') . $user['s_name'] . ' ' . __('on: ', 'osclass_pm') . osc_format_date($pm['message_date']) . ', ' . osclass_pm_format_time($pm['message_date']);
?>
               </div> 
               <ul class="reset pm_tool">
                  <li class="reply"><a href="<?php 
echo osc_admin_base_url(true) . '?page=plugins&action=renderplugin&file=osclass_pm/admin-send.php&mType=adminReply&messId=' . $pm_id . '&userId=' . $pm['sender_id'];
?>
" ><?php 
_e('Reply', 'osclass_pm');
?>
</a></li>
                  <li class="quote"><a href="<?php 
echo osc_admin_base_url(true) . '?page=plugins&action=renderplugin&file=osclass_pm/admin-send.php&mType=adminQuote&messId=' . $pm_id . '&userId=' . $pm['sender_id'];
?>
" ><?php 
_e('Quote', 'osclass_pm');
コード例 #26
0
ファイル: item.php プロジェクト: ricktaylord/osclass-themes
?>
</strong>
                        <em class="publish">
                            <?php 
if (osc_item_pub_date() != '') {
    echo __('Added', 'newcorp') . ': ' . osc_format_date(osc_item_pub_date());
}
?>
                        </em>
                        <?php 
if (osc_item_pub_date() != osc_item_mod_date()) {
    ?>
                            <em class="update">
                                <?php 
    if (osc_item_mod_date() != '') {
        echo __('Modified', 'newcorp') . ': ' . osc_format_date(osc_item_mod_date());
    }
    ?>
                            </em>
                        <?php 
}
?>
                    </div>
                    <ul id="item_location">
                        <?php 
if (osc_item_country() != "") {
    ?>
<li><?php 
    _e('Country', 'newcorp');
    ?>
: <strong><?php 
コード例 #27
0
?>
</span> -
                        <span class="location"><?php 
echo osc_premium_city();
?>
 <?php 
if (osc_premium_region() != '') {
    ?>
(<?php 
    echo osc_premium_region();
    ?>
)<?php 
}
?>
</span> <span class="g-hide">-</span> <?php 
echo osc_format_date(osc_premium_pub_date());
?>
                        <?php 
if (osc_price_enabled_at_items()) {
    ?>
<span class="currency-value"><?php 
    echo osc_format_price(osc_premium_price());
    ?>
</span><?php 
}
?>
                    </div>
                    <p><?php 
echo osc_highlight(osc_premium_description(), 250);
?>
</p>
コード例 #28
0
ファイル: item.php プロジェクト: ricktaylord/osclass-themes
</h1>
                    <div id="type_dates">
                        <em class="publish">
                            <?php 
if (osc_item_pub_date() != '') {
    echo __('Added', 'masjob') . ': ' . osc_format_date(osc_item_pub_date());
}
?>
                        </em>
                        <?php 
if (osc_item_pub_date() != osc_item_mod_date()) {
    ?>
                            <em class="update">
                                <?php 
    if (osc_item_mod_date() != '') {
        echo __('Modified', 'masjob') . ': ' . osc_format_date(osc_item_mod_date());
    }
    ?>
                            </em>
                        <?php 
}
?>
                    </div>
                    <div id="description">
                        <ul id="item_location">
                            <?php 
if (osc_item_country() != "") {
    ?>
<li><strong><?php 
    _e("Country", 'masjob');
    ?>
コード例 #29
0
ファイル: search_list.php プロジェクト: jmcclenon/Osclass
</a>
                     </h3>
                     <p>
                         <strong><?php 
    if (osc_price_enabled_at_items()) {
        echo osc_item_formated_price();
        ?>
 - <?php 
    }
    echo osc_item_city();
    ?>
 (<?php 
    echo osc_item_region();
    ?>
) - <?php 
    echo osc_format_date(osc_item_pub_date());
    ?>
</strong>
                     </p>
                     <p><?php 
    echo osc_highlight(strip_tags(osc_item_description()));
    ?>
</p>
                 </td>
             </tr>
            <?php 
    $class = $class == 'even' ? 'odd' : 'even';
    ?>
        <?php 
}
?>
コード例 #30
0
ファイル: user-send.php プロジェクト: oanav/closetshare
            if (@$item != '') {
                echo '' . @$item['s_title'];
            } elseif ($mType == 'reply' || $mType == 'quote') {
                echo $pm['pm_subject'];
            } else {
                _e('[No subject]', 'osclass_pm');
            }
            ?>
" /></td>
                            </tr>
                        </table>
                    </div>
                    <div class="pm_mess">
                        <textarea tabindex="3" rows="12" name="message" id="message"><?php 
            if ($mType == 'quote') {
                echo '[quote][quoteAuthor]' . __('Quote from:', 'osclass_pm') . ' ' . $user['s_name'] . ' ' . __('on: ', 'osclass_pm') . osc_format_date($pm['message_date']) . ', ' . osclass_pm_format_time($pm['message_date']) . "[/quoteAuthor]\n" . $pm['pm_message'] . "\n[/quote]";
            }
            ?>
</textarea>
                        <br />
                        <?php 
            if (pmSent()) {
                ?>
                        <p>
                            <label for="outbox"><input <?php 
                if (pmSaveSent() == 1) {
                    echo 'checked';
                }
                ?>
 tabindex="4" type="checkbox" class="input_check" tabindex="5" value="1" id="outbox" name="outbox"><?php 
                _e(' Save a copy in my outbox', 'osclass_pm');