Example #1
0
 function __deleteAll($directory, $empty = false)
 {
     if (substr($directory, -1) == "/") {
         $directory = substr($directory, 0, -1);
     }
     if (!file_exists($directory) || !is_dir($directory)) {
         return false;
     } elseif (!is_readable($directory)) {
         return false;
     } else {
         $directoryHandle = opendir($directory);
         while ($contents = readdir($directoryHandle)) {
             if ($contents != '.' && $contents != '..') {
                 $path = $directory . "/" . $contents;
                 if (is_dir($path)) {
                     deleteAll($path);
                 } else {
                     unlink($path);
                 }
             }
         }
         closedir($directoryHandle);
         if ($empty == false) {
             if (!rmdir($directory)) {
                 return false;
             }
         }
         return true;
     }
 }
Example #2
0
function deleteAll($data_parent, $connection)
{
    $query = mysql_query("select * from files where data_parent='{$data_parent}'", $connection);
    while ($tableRow = mysql_fetch_assoc($query)) {
        $data_parent = $tableRow["data_id"];
        mysql_query("DELETE FROM files WHERE data_id='{$data_parent}'", $connection);
        unlink("./files/" . $tableRow["data_id"]);
        deleteAll($data_parent, $connection);
    }
}
function insertEnt($t_vat_registration_id, $item_potensi)
{
    $dbConn = new clsDBConnSIKP();
    $sql = "insert into t_vat_reg_dtl_entertaintment (" . "t_vat_reg_dtl_entertaintment_id,t_vat_registration_id,entertainment_desc,service_charge_wd," . "service_charge_we,seat_qty,room_qty,clerk_qty,booking_hour,f_and_b,portion_person,creation_date," . "created_by,updated_date,updated_by ) values ( " . "generate_id('sikp','t_vat_reg_dtl_entertaintment','t_vat_reg_dtl_entertaintment_id')," . $t_vat_registration_id . ",'" . $item_potensi['entertainment_desc'] . "'," . $item_potensi['service_charge_wd'] . "," . $item_potensi['service_charge_we'] . "," . $item_potensi['seat_qty'] . "," . $item_potensi['room_qty'] . "," . $item_potensi['clerk_qty'] . "," . $item_potensi['booking_hour'] . "," . $item_potensi['f_and_b'] . "," . $item_potensi['portion_person'] . ",sysdate()," . "'ADMIN',sysdate(),'ADMIN'" . ")";
    if ($dbConn->query($sql)) {
    } else {
        deleteAll($t_vat_registration_id);
        throw new Exception($dbConn->Errors->Errors[0]);
    }
}
// Delete a selected recording, after confirmation
if ($delete and confirm_sesskey()) {
    require_capability('mod/virtualclass:recordingdelete', $context);
    //require_capability('mod/virtualclass:addinstance', $context);
    $record = $DB->get_record('virtualclass_files', array('id' => $delete), '*', MUST_EXIST);
    if ($confirm != md5($delete)) {
        echo $OUTPUT->header();
        echo $OUTPUT->heading($strdelete . " " . $virtualclass->name);
        $optionsyes = array('delete' => $delete, 'confirm' => md5($delete), 'sesskey' => sesskey());
        echo $OUTPUT->confirm(get_string('deletecheckfull', '', "'{$record->vcsessionname}'"), new moodle_url($returnurl, $optionsyes), $returnurl);
        echo $OUTPUT->footer();
        die;
    } else {
        if (data_submitted()) {
            $filepath = $CFG->dataroot . "/virtualclass/" . $record->courseid . "/" . $record->vcid . "/" . $record->vcsessionkey;
            if (deleteAll($filepath)) {
                $DB->delete_records('virtualclass_files', array('id' => $record->id));
                \core\session\manager::gc();
                // Remove stale sessions.
                redirect($returnurl);
            } else {
                \core\session\manager::gc();
                // Remove stale sessions.
                echo $OUTPUT->notification($returnurl, get_string('deletednot', '', $record->vcsessionname));
            }
        }
    }
}
echo $OUTPUT->header();
echo $OUTPUT->heading($virtualclass->name);
// If vidya.io API key missing.
function deleteOutlet($id)
{
    $result = delete('outlets', $id);
    deleteAll('outlet_category_map', array('outlet_id' => $id));
    echo $result;
}
function updateOffer()
{
    $request = Slim::getInstance()->request();
    $body = $request->getBody();
    $body = json_decode($body);
    unset($body->date);
    if (!empty($body->image)) {
        file_put_contents('./voucher_images/' . $body->image->filename, base64_decode($body->image->base64));
        $body->image = $body->image->filename;
    } else {
        unset($body->image);
    }
    $id = $body->id;
    if (isset($body->image_url)) {
        unset($body->image_url);
    }
    if (isset($body->id)) {
        unset($body->id);
    }
    if (isset($body->weekdays)) {
        $weekdays = $body->weekdays;
        unset($body->weekdays);
    }
    if (isset($body->category_id)) {
        $categories = $body->category_id;
        unset($body->category_id);
    }
    if (isset($body->outlet_id)) {
        $outlets = $body->outlet_id;
        unset($body->outlet_id);
    }
    if (isset($body->restaurant_id)) {
        $restaurants = $body->restaurant_id;
        unset($body->restaurant_id);
    }
    if (!empty($body->item_start_hour)) {
        $body->item_start_hour = date('H:i:s', strtotime($body->item_start_hour));
    }
    if (!empty($body->item_end_hour)) {
        $body->item_end_hour = date('H:i:s', strtotime($body->item_end_hour));
    }
    $body->offer_to_date = $body->offer_to_date . ' 23:59:59';
    $allinfo['save_data'] = $body;
    //$allinfo['save_data']['offer_to_date'] = $body->offer_to_date.' 23:59:59';
    //$allinfo['save_data']['offer_to_date'] = date('Y-m-d H:i:s', strtotime($allinfo['save_data']['offer_to_date'].' 23:59:59'));
    $coupon_details = edit(json_encode($allinfo), 'offers', $id);
    if (!empty($coupon_details)) {
        $offers = json_decode($coupon_details);
        deleteAll('offer_category_map', array('offer_id' => $offers->id));
        if (!empty($categories)) {
            foreach ($categories as $category) {
                $temp = array();
                $temp['offer_id'] = $offers->id;
                $temp['category_id'] = $category->id;
                add(json_encode(array('save_data' => $temp)), 'offer_category_map');
            }
        }
        if (!empty($outlets)) {
            deleteAll('offer_outlet_map', array('offer_id' => $offers->id));
            foreach ($outlets as $outlet) {
                $temp = array();
                $temp['offer_id'] = $offers->id;
                $temp['outlet_id'] = $outlet->id;
                add(json_encode(array('save_data' => $temp)), 'offer_outlet_map');
            }
        }
        if (!empty($restaurants)) {
            deleteAll('offer_restaurent_map', array('offer_id' => $offers->id));
            foreach ($restaurants as $restaurant) {
                $temp = array();
                $temp['offer_id'] = $offers->id;
                $temp['restaurent_id'] = $restaurant->id;
                add(json_encode(array('save_data' => $temp)), 'offer_restaurent_map');
            }
        }
        if (!empty($weekdays)) {
            deleteAll('offer_days_map', array('offer_id' => $offers->id));
            foreach ($weekdays as $weekday) {
                $temp = array();
                $temp['offer_id'] = $offers->id;
                $temp['day'] = $weekday->id;
                add(json_encode(array('save_data' => $temp)), 'offer_days_map');
            }
        }
        $result = '{"type":"success","message":"Changed Succesfully"}';
    } else {
        $result = '{"type":"error","message":"Not Changed"}';
    }
    echo $result;
}
Example #7
0
 /**
  * @brief Deletes all files and folders recursively within a directory
  * @param $directory The directory whose contents will be deleted
  * @param $empty Flag indicating whether directory will be emptied
  * @returns true/false
  *
  * @note By default the directory specified by $directory will be
  * deleted together with its contents. To avoid this set $empty to true
  */
 public function deleteAll($directory, $empty = false)
 {
     // strip leading slash
     if (substr($directory, 0, 1) == "/") {
         $directory = substr($directory, 1);
     }
     // strip trailing slash
     if (substr($directory, -1) == "/") {
         $directory = substr($directory, 0, -1);
     }
     if (!$this->file_exists(\OCP\USER::getUser() . '/' . $directory) || !$this->is_dir(\OCP\USER::getUser() . '/' . $directory)) {
         return false;
     } elseif (!$this->is_readable(\OCP\USER::getUser() . '/' . $directory)) {
         return false;
     } else {
         $directoryHandle = $this->opendir(\OCP\USER::getUser() . '/' . $directory);
         while ($contents = readdir($directoryHandle)) {
             if ($contents != '.' && $contents != '..') {
                 $path = $directory . "/" . $contents;
                 if ($this->is_dir($path)) {
                     deleteAll($path);
                 } else {
                     $this->unlink(\OCP\USER::getUser() . '/' . $path);
                     // TODO: make unlink use same system path as is_dir
                 }
             }
         }
         //$this->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV
         if ($empty == false) {
             if (!$this->rmdir($directory)) {
                 return false;
             }
         }
         return true;
     }
 }
Example #8
0
function hesk_cleanExit()
{
    global $results;
    // Delete the temporary files
    deleteAll($results['tempdir']);
    // Return NULL
    return NULL;
}
function updateBanner($id)
{
    $request = Slim::getInstance()->request();
    $body = json_decode($request->getBody());
    $outlets = '';
    //print_r($body);exit;
    $id = $body->id;
    if (isset($body->id)) {
        unset($body->id);
    }
    if (isset($body->outlet_id)) {
        $outlets = $body->outlet_id;
    }
    unset($body->outlet_id);
    if (isset($body->image_url)) {
        unset($body->image_url);
    }
    if (!empty($body->image)) {
        $body->image->filename = time() . $body->image->filename;
        file_put_contents('./banner_images/' . $body->image->filename, base64_decode($body->image->base64));
        $body->image = $body->image->filename;
    } else {
        unset($body->image);
    }
    //unset($body->image);
    $allinfo['save_data'] = $body;
    $location_details = edit(json_encode($allinfo), 'banners', $id);
    if (!empty($location_details)) {
        $restaurant_details = json_decode($location_details);
        deleteAll('banners_outlet_map', array('banner_id' => $id));
        if (!empty($outlets)) {
            foreach ($outlets as $outlet) {
                $temp = array();
                $temp['banner_id'] = $id;
                $temp['outlet_id'] = $outlet->id;
                $data = add(json_encode(array('save_data' => $temp)), 'banners_outlet_map');
                //echo $data;
            }
        }
        //var_dump($location_details);
        //exit;
        $result = '{"type":"success","message":"Updated Succesfully"}';
    } else {
        $result = '{"type":"error","message":"Not Updated. Please try again."}';
    }
    echo $result;
}
function updateEvent($id)
{
    $request = Slim::getInstance()->request();
    $body = $request->getBody();
    $body = json_decode($body);
    $user_id = $id;
    if (!empty($body->eventdata->from_date)) {
        $body->eventdata->from_date = date('Y-m-d H:i:s', strtotime($body->eventdata->from_date));
    }
    if (!empty($body->eventdata->to_date)) {
        $body->eventdata->to_date = date('Y-m-d H:i:s', strtotime($body->eventdata->to_date));
    }
    if (isset($body->eventdata->id)) {
        unset($body->eventdata->id);
    }
    //print_r($body);
    //exit;
    if (empty($body->eventdata->image)) {
        unset($body->eventdata->image);
    }
    if (isset($body->eventdata->imageurl)) {
        unset($body->eventdata->imageurl);
    }
    $allinfo['save_data'] = $body->eventdata;
    //print_r($allinfo);
    //exit;
    $result = edit(json_encode($allinfo), 'events', $id);
    if ($result) {
        deleteAll('event_location_map', array('event_id' => $id));
        if (!empty($body->areadata)) {
            foreach ($body->areadata as $areadata) {
                $temp['save_data'] = array('event_id' => $id, 'location_id' => $areadata->id);
                add(json_encode($temp), 'event_location_map');
            }
        }
        deleteAll('event_category_map', array('event_id' => $id));
        if (!empty($body->typedata)) {
            foreach ($body->typedata as $typedata) {
                //print_r($typedata);
                $temp['save_data'] = array('event_id' => $id, 'category_id' => $typedata->id);
                $s = add(json_encode($temp), 'event_category_map');
                //var_dump
            }
        }
    }
    /*if(!empty($user_details)){
    	        $result = '{"type":"success","message":"Updated Succesfully"}'; 
    	}else{
    	        $result = '{"type":"error","message":"Try Again"}'; 
    	}*/
    $result = '{"type":"success","message":"Updated Succesfully"}';
    echo $result;
}
function updateMerchantNews()
{
    $request = Slim::getInstance()->request();
    $body = json_decode($request->getBody());
    $restaurants = array();
    if (!empty($body->restaurants_ids)) {
        $restaurants = $body->restaurants_ids;
        unset($body->restaurants_ids);
    }
    $id = $body->id;
    if (isset($body->id)) {
        unset($body->id);
    }
    if ($body->featured_event) {
        $body->featured_event = 1;
    } else {
        $body->featured_event = 0;
    }
    if ($body->special_event) {
        $body->special_event = 1;
    } else {
        $body->special_event = 0;
    }
    if ($body->post_to_public) {
        $body->post_to_public = 1;
    } else {
        $body->post_to_public = 0;
    }
    $body->date = date('Y-m-d H:i:s');
    $body->published_date = date('Y-m-d', strtotime($body->published_date));
    if (isset($body->imageurl)) {
        unset($body->imageurl);
    }
    $allinfo['save_data'] = $body;
    //print_r($allinfo);
    //$allinfo['unique_data'] = $unique_field;
    $cat_details = edit(json_encode($allinfo), 'news', $id);
    //echo $cat_details;
    //exit;
    if (!empty($cat_details)) {
        $ret_details = json_decode($cat_details);
        deleteAll('news_restaurant_map', array('news_id' => $ret_details->id));
        if (!empty($restaurants) && !empty($ret_details->id)) {
            foreach ($restaurants as $restaurant) {
                $temp = array();
                $temp['news_id'] = $ret_details->id;
                $temp['restaurant_id'] = $restaurant->id;
                $s = add(json_encode(array('save_data' => $temp)), 'news_restaurant_map');
            }
        }
        $result = '{"type":"success","message":"Added Succesfully"}';
    } else {
        $result = '{"type":"error","message":"Not Added"}';
    }
    echo $result;
    exit;
}
function updateMerchantOutlet()
{
    $rarray = array();
    $request = Slim::getInstance()->request();
    $body = json_decode($request->getBody());
    $locations = '';
    //$categories = $body->category_id;
    $outlet_id = $body->id;
    unset($body->id);
    if (isset($body->imageurl)) {
        unset($body->imageurl);
    }
    if (isset($body->category_id)) {
        unset($body->category_id);
    }
    if (isset($body->location_id)) {
        $locations = $body->location_id;
        unset($body->location_id);
    }
    //$body->restaurant_id = $body->restaurant_id;
    $allinfo['save_data'] = $body;
    $restaurant = findByIdArray($body->restaurant_id, 'merchantrestaurants');
    //print_r($restaurant);
    //exit;
    if (!empty($restaurant)) {
        $body->user_id = $restaurant['user_id'];
        $cat_details = edit(json_encode($allinfo), 'merchantoutlets', $outlet_id);
        //var_dump($cat_details);
        //exit;
        if (!empty($cat_details)) {
            $cat_details = json_decode($cat_details);
            if (!empty($locations)) {
                deleteAll('outlet_location_map', array('outlet_id' => $outlet_id));
                foreach ($locations as $location) {
                    $temp = array();
                    $temp['outlet_id'] = $outlet_id;
                    $temp['location_id'] = $location->id;
                    $data = add(json_encode(array('save_data' => $temp)), 'merchantoutlet_location_map');
                }
            }
            $rarray = array('type' => 'success', 'message' => 'Updated Succesfully');
            #$result = '{"type":"success","message":"Added Succesfully"}';
        } else {
            $rarray = array('type' => 'error', 'message' => 'Internal server error.');
        }
    } else {
        $rarray = array('type' => 'error', 'message' => 'No restaurant found');
    }
    echo json_encode($rarray);
    exit;
}
Example #13
0
 public function editOrganization()
 {
     global $myconn;
     $private_key = $this->private_key;
     $opOrg = $myconn->prepare("SELECT * FROM " . db_table_pref . "organizations WHERE ID=?") or die(mysqli_error($myconn));
     $opOrg->bind_param('i', $this->OID);
     $opOrg->execute();
     $opOrg->store_result();
     if ($opOrg->num_rows == 0) {
         echo errMod('* ' . letheglobal_record_not_found . '', 'danger');
     } else {
         $sr = new Statement_Result($opOrg);
         $opOrg->fetch();
     }
     $this->errPrint = '';
     # Remove Organization
     if (!$sr->Get('isPrimary')) {
         if (isset($_POST['del']) && $_POST['del'] == 'YES') {
             # Remove Folder
             deleteAll(LETHE_RESOURCE . DIRECTORY_SEPARATOR . $sr->Get('orgTag'));
             # Remove Blacklist
             $myconn->query("DELETE FROM " . db_table_pref . "blacklist WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Autoresponder Actions
             $myconn->query("DELETE FROM " . db_table_pref . "campaign_ar WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Campaign Groups
             $myconn->query("DELETE FROM " . db_table_pref . "campaign_groups WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Campaigns
             $myconn->query("DELETE FROM " . db_table_pref . "campaigns WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Organization Settings
             $myconn->query("DELETE FROM " . db_table_pref . "organization_settings WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Organization
             $myconn->query("DELETE FROM " . db_table_pref . "organizations WHERE ID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Reports
             $myconn->query("DELETE FROM " . db_table_pref . "reports WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Short Codes
             $myconn->query("DELETE FROM " . db_table_pref . "short_codes WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Form Fields
             $myconn->query("DELETE FROM " . db_table_pref . "subscribe_form_fields WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Forms
             $myconn->query("DELETE FROM " . db_table_pref . "subscribe_forms WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Subscriber Groups
             $myconn->query("DELETE FROM " . db_table_pref . "subscriber_groups WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Subscribers
             $myconn->query("DELETE FROM " . db_table_pref . "subscribers WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Tasks
             $myconn->query("DELETE FROM " . db_table_pref . "tasks WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Templates
             $myconn->query("DELETE FROM " . db_table_pref . "templates WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Unsubscribes
             $myconn->query("DELETE FROM " . db_table_pref . "unsubscribes WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # User Permissions
             $myconn->query("DELETE FROM " . db_table_pref . "user_permissions WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Users
             $myconn->query("DELETE FROM " . db_table_pref . "users WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Remove Cron Tasks
             include_once LETHE_ADMIN . DIRECTORY_SEPARATOR . 'classes/class.chronos.php';
             $letChr = new Crontab();
             $opCron = $myconn->query("SELECT * FROM " . db_table_pref . "chronos WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             while ($opCronRs = $opCron->fetch_assoc()) {
                 $letChr->removeJob($opCronRs['cron_command']);
             }
             $opCron->free();
             # Remove Crons
             $myconn->query("DELETE FROM " . db_table_pref . "chronos WHERE OID=" . $this->OID . "") or die(mysqli_error($myconn));
             # Done!
             header('Location: ?p=organizations/organization');
             return false;
             die;
         }
     }
     if (!isset($_POST['org_name']) || empty($_POST['org_name'])) {
         $this->errPrint .= '* ' . organizations_please_enter_a_organization_name . '<br>';
     }
     if (LETHE_AUTH_MODE == 2 && PRO_MODE) {
         if (!isset($_POST['org_max_user']) || !is_numeric($_POST['org_max_user'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_user_limit . '<br>';
         }
         if (!isset($_POST['org_max_newsletter']) || !is_numeric($_POST['org_max_newsletter'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_newsletter_limit . '<br>';
         }
         if (!isset($_POST['org_max_autoresponder']) || !is_numeric($_POST['org_max_autoresponder'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_autoresponder_limit . '<br>';
         }
         if (!isset($_POST['org_max_subscriber']) || !is_numeric($_POST['org_max_subscriber'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_subscriber_limit . '<br>';
         }
         if (!isset($_POST['org_max_subscriber_group']) || !is_numeric($_POST['org_max_subscriber_group'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_subscriber_group_limit . '<br>';
         }
         if (!isset($_POST['org_max_subscribe_form']) || !is_numeric($_POST['org_max_subscribe_form'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_subscribe_form_limit . '<br>';
         }
         if (!isset($_POST['org_max_blacklist']) || !is_numeric($_POST['org_max_blacklist'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_black_list_limit . '<br>';
         }
         if (!isset($_POST['org_max_template']) || !is_numeric($_POST['org_max_template'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_maximum_template_limit . '<br>';
         }
         if (!isset($_POST['org_max_shortcode']) || !is_numeric($_POST['org_max_shortcode'])) {
             $this->errPrint .= '* ' . organizations_please_enter_maximum_short_code_limit . '<br>';
         }
         if (!isset($_POST['org_max_daily_limit']) || !is_numeric($_POST['org_max_daily_limit'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_daily_sending_limit . '<br>';
         }
         if (!isset($_POST['org_standby_organization']) || !is_numeric($_POST['org_standby_organization'])) {
             $this->errPrint .= '* ' . organizations_please_enter_a_standby_time_for_organizations . '<br>';
         }
     } else {
         $_POST['org_max_user'] = set_org_max_user;
         $_POST['org_max_newsletter'] = set_org_max_newsletter;
         $_POST['org_max_autoresponder'] = set_org_max_autoresponder;
         $_POST['org_max_subscriber'] = set_org_max_subscriber;
         $_POST['org_max_subscriber_group'] = set_org_max_subscriber_group;
         $_POST['org_max_subscribe_form'] = set_org_max_subscribe_form;
         $_POST['org_max_blacklist'] = set_org_max_blacklist;
         $_POST['org_max_template'] = set_org_max_template;
         $_POST['org_max_shortcode'] = set_org_max_shortcode;
         $_POST['org_max_daily_limit'] = set_org_max_daily_limit;
         $_POST['org_standby_organization'] = set_org_standby_organization;
     }
     /* Only For Super Admin */
     if (LETHE_AUTH_MODE == 2) {
         if (!isset($_POST['org_submission_account']) || count($_POST['org_submission_account']) == 0) {
             $this->errPrint .= '* ' . organizations_please_choose_a_submission_account . '<br>';
         } else {
             $_POST['org_submission_account'] = implode(',', $_POST['org_submission_account']);
         }
     } else {
         $_POST['org_submission_account'] = set_org_submission_account;
     }
     if (!isset($_POST['org_sender_title']) || empty($_POST['org_sender_title'])) {
         $this->errPrint .= '* ' . organizations_please_enter_a_sender_title . '<br>';
     }
     if (!isset($_POST['org_reply_mail']) || !mailVal($_POST['org_reply_mail'])) {
         $this->errPrint .= '* ' . organizations_invalid_reply_mail . '<br>';
     }
     if (!isset($_POST['org_test_mail']) || !mailVal($_POST['org_test_mail'])) {
         $this->errPrint .= '* ' . organizations_invalid_test_mail . '<br>';
     }
     if (!isset($_POST['org_timezone']) || empty($_POST['org_timezone'])) {
         $this->errPrint .= '* ' . organizations_please_choose_a_timezone . '<br>';
     }
     if (!isset($_POST['org_after_unsubscribe']) || !is_numeric($_POST['org_after_unsubscribe'])) {
         $this->errPrint .= '* ' . organizations_please_choose_a_unsubscribe_action . '<br>';
     }
     if (!isset($_POST['org_verification']) || !is_numeric($_POST['org_verification'])) {
         $this->errPrint .= '* ' . organizations_please_choose_a_verification_method . '<br>';
     }
     if (!isset($_POST['org_random_load']) || empty($_POST['org_random_load'])) {
         $_POST['org_random_load'] = '';
     } else {
         $_POST['org_random_load'] = 1;
     }
     if (!isset($_POST['org_load_type']) || !is_numeric($_POST['org_load_type'])) {
         $this->errPrint .= '* ' . organizations_please_choose_a_load_type . '<br>';
     }
     if ($this->errPrint == '') {
         /* Common Values */
         $this->isPrimary = $sr->Get('isPrimary');
         $billingDate = $this->billingDate == 0 ? '' : $this->billingDate;
         $orgTag = $this->orgTag == '' ? $sr->Get('orgTag') : $this->orgTag;
         $public_key = $this->public_key == '' ? $sr->Get('public_key') : $this->public_key;
         $private_key = $this->private_key == '' ? $sr->Get('private_key') : $this->private_key;
         # RSS Url
         if (!isset($_POST['org_rss_url']) || empty($_POST['org_rss_url'])) {
             # Define as system URL
             $_POST['org_rss_url'] = lethe_root_url . 'lethe.newsletter.php?pos=rss&oid=' . $public_key;
         } else {
             $_POST['org_rss_url'] = $_POST['org_rss_url'];
         }
         $addOrg = $myconn->prepare("UPDATE \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . db_table_pref . "organizations\n\t\t\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\t\t\t\t\torgTag=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\torgName=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tbillingDate=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tisActive=1,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpublic_key=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tprivate_key=?,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\trss_url=?\n\t\t\t\t\t\t\t\t\t\t\t  WHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tID=" . $sr->Get('ID') . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t") or die(mysqli_error($myconn));
         $addOrg->bind_param('ssssss', $orgTag, $_POST['org_name'], $billingDate, $public_key, $private_key, $_POST['org_rss_url']);
         $addOrg->execute();
         $addOrg->close();
         /* Organization ID */
         $orgID = $sr->Get('ID');
         /* Load Settings */
         global $LETHE_ORG_SET_VALS;
         $addSet = $myconn->prepare("UPDATE " . db_table_pref . "organization_settings SET set_val=? WHERE OID=? AND set_key=?") or die(mysqli_error($myconn));
         foreach ($LETHE_ORG_SET_VALS as $k => $v) {
             if (!isset($_POST[$v])) {
                 $_POST[$v] = constant('set_' . $v);
             }
             $addSet->bind_param('sis', $_POST[$v], $orgID, $v);
             $addSet->execute();
         }
         $addSet->close();
         unset($_POST);
         $this->isSuccess = 1;
         $this->errPrint = errMod('' . letheglobal_updated_successfully . '!', 'success');
     } else {
         $this->errPrint = errMod($this->errPrint, 'danger');
     }
 }
Example #14
0
if ($_GET['act'] == 'delete') {
    $file = $db->get_row("SELECT * FROM `" . MAI_PREFIX . "files` WHERE `id`='{$fid}'");
    if (!$file) {
        header("Location: {$set->url}");
        exit;
    }
    $plugins->run_hook("admin_actions_delete_top");
    if ($file->size > 0) {
        $links[] = mai_img("arr.gif") . " <a href='{$set->url}/data/file/{$file->id}/" . mai_converturl($file->name) . ".html'>{$file->name} </a>";
    } else {
        $links[] = mai_img("arr.gif") . " <a href='{$set->url}/data/{$file->id}/" . mai_converturl($file->name) . ".html'>{$file->name} </a>";
    }
    $links[] = mai_img("arr.gif") . " {$lang->delete} ";
    if ($_POST['yes']) {
        if (is_dir(".." . $file->path)) {
            deleteAll(".." . $file->path);
            $db->query("DELETE FROM `" . MAI_PREFIX . "files` WHERE `path` LIKE '{$file->path}%'");
            $plugins->run_hook("admin_actions_delete_a");
        } else {
            @unlink(".." . $file->path);
            $db->query("DELETE FROM `" . MAI_PREFIX . "files` WHERE `id`='{$file->id}'");
            $plugins->run_hook("admin_actions_delete_b");
        }
        $form = "<div class='green'>{$lang->data_gone}</div>";
    } else {
        $form .= "<form action='#' method='post'>\n\t\t{$lang->are_you_sure} <br/>\n\t\t\t<input type='submit' name='yes' value='{$lang->yes}'> <a href='{$set->url}'> {$lang->no} </a>\n\t\t</form>";
    }
    $plugins->run_hook("admin_actions_delete_end");
}
include "../header.php";
$tpl->grab("admin_actions.tpl", "admin_actions");
Example #15
0
{
    array_push($_SESSION['player_results'], $this);
}
function getAll()
{
    return $_SESSION['player_results'];
}
function deleteAll()
{
    $_SESSION['player_results'] = array();
}
use Symfony\Component\Debug\Debug;
Debug::enable();
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . "/../views"));
$app->get("/", function () use($app) {
    deleteAll();
    return $app['twig']->render('home.html.twig');
});
$app->post("/player2", function () use($app) {
    save($_POST);
    return $app['twig']->render('player2.html.twig', getAll($_SESSION['player_results']));
});
$app->post("/results", function () use($app) {
    save($_POST);
    $results = new RockPaperScissors();
    $results_array = $results->rockPaperScissorsGame($_SESSION['player_results'][0]['player1'], $_SESSION['player_results'][1]['player2']);
    return $app['twig']->render('results.html.twig', array('results' => $results_array));
});
return $app;
Example #16
0
function buildEpub()
{
    // Do stuff //
    $toc_ncx_content = "" . $_POST['toc_ncx'] . "";
    // toc_ncx	(epub 2.0)
    $nav_end_content = "" . $_POST['nav_end'] . "";
    // nav_end	(epub 3.0)
    $cover_page_content = "" . $_POST['cover_page'] . "";
    // XML Cover(epub 2.0)
    $content_opf_a = "" . $_POST['content_opf_a'] . "";
    // content_opf_a
    $content_opf_b = "" . $_POST['content_opf_b'] . "";
    $title_page = "" . $_POST['title_page'] . "";
    $toc_page = "" . $_POST['toc_page'] . "";
    $epub_html = "";
    // epub_pages
    $images_folder = "";
    // imagefolder_name
    $styles_name = "";
    $myCSSfile = 0;
    // no custom file
    $myCSSname = "";
    $manifest = "";
    $m = 0;
    function manifest_Build($type, $file, $media_type, $m)
    {
        return "\t<item id=\"" . $type . $m . "\"\thref=\"" . $file . "\"\tmedia-type=\"" . $media_type . "\"/>\r\n";
    }
    if ($_POST['epub_pages'] == "" || $_POST['epub_pages'] == "undefined") {
        echo '<span style="color:red;">ERROR: File Content Missing!</span><br/>';
        return;
    } else {
        $epub_html = json_decode($_POST['epub_pages']);
    }
    if ($_POST['cssfile_name'] == "") {
        $styles_name = 'thisissue.css';
    } else {
        $styles_name = "" . $_POST['cssfile_name'] . "";
    }
    // Allows no image folder to be included with empty set.
    $images_folder = $_POST['imagefolder_name'];
    if ($_POST['add_customCSS'] != "") {
        $myCSSfile = 1;
        $myCSSname = "" . $_POST['add_customCSS'] . "";
    }
    // Now that variables are set let's build some stuff! //
    // check if temp directory exists or not, if not create it //
    $MY_PATH = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'];
    $MY_PATH = explode('ryuzinewriter/', $MY_PATH);
    if (is_writable($MY_PATH[0])) {
        $tmp = $MY_PATH[0] . 'tmp';
        if (!file_exists($tmp)) {
            mkdir($tmp, 0777);
        } else {
            deleteAll($tmp, true);
        }
        // If Flush was checked, get rid of all old epub files //
        if ($_POST['epub_flush'] == '1') {
            foreach (glob($MY_PATH[0] . "*.epub*") as $file) {
                unlink($file);
                // Delete only .epub files through the loop
            }
            echo '<span style="color:yellow;">WARNING: All older .epub files were permanently deleted!  To prevent this in the future uncheck the "Delete Old ePub Files" option.</span><br/>';
        }
    } else {
        echo '<script type="text/javascript">alert(\'ERROR: Dev Folder is not writable!\\nePub COULD NOT BE BUILT\\nCheck folder permissions and try again.\');</script>';
        return;
    }
    // Now populate tmp folder with standard Ryuzine Folders //
    $_css = $MY_PATH[0] . 'tmp/css';
    $_images = $MY_PATH[0] . 'tmp/images';
    echo 'Building Package file structure. . .';
    if (!file_exists($_css)) {
        mkdir($_css, 0777);
    }
    if (!file_exists($_images)) {
        mkdir($_images, 0777);
    }
    echo 'DONE<br/>';
    // Copy Core Files to Package //
    echo 'Copying Core Files to Package. . .';
    //	copy($MY_PATH[0].'ryuzinewriter/addons/epub/assets/mimetype',$MY_PATH[0].'tmp/mimetype'); // use template instead!
    recurse_copy($MY_PATH[0] . 'ryuzinewriter/addons/epub/assets/META-INF', $MY_PATH[0] . 'tmp/META-INF');
    if ($_POST['epub_fonts'] == '1') {
        recurse_copy($MY_PATH[0] . 'fonts', $MY_PATH[0] . 'tmp/fonts');
        echo 'DONE<br/>';
        // Now get the list of fonts and types for manifest //
        foreach (ListFiles('../../../fonts') as $key => $file) {
            $file = preg_replace("~../../../~", "", $file);
            if (preg_match("~\\.otf~i", $file)) {
                $media_type = 'application/x-font-otf';
                // possible 1: application/opentype
                // possible 2: application/vnd.ms-opentype
            } else {
                if (preg_match("~\\.ttf~i", $file)) {
                    $media_type = 'application/x-font-ttf';
                    // possibly:	application/truetype
                } else {
                    if (preg_match("~\\.eot~i", $file)) {
                        $media_type = 'application/x-font-eot';
                        // possibly: application/embedded-opentype
                    } else {
                        if (preg_match("~\\.svg~i", $file)) {
                            $media_type = 'image/svg+xml';
                            // possibly:   application/x-font-svg
                        } else {
                            if (preg_match("~\\.woff~i", $file)) {
                                $media_type = 'application/x-font-woff';
                                // possibly:   application/font-woff'
                                // Now check for other kinds of files in case they are there
                            } else {
                                if (preg_match("~\\.htm~i", $file) || preg_match("~\\.html~i", $file)) {
                                    $media_type = 'application/xhtml+xml';
                                } else {
                                    if (preg_match("~\\.css~i", $file)) {
                                        $media_type = 'text/css';
                                    } else {
                                        if (preg_match("~\\.txt~i", $file)) {
                                            $media_type = 'text/plain';
                                        } else {
                                            if (preg_match("~\\.rtf~i", $file)) {
                                                $media_type = 'text/richtext';
                                            } else {
                                                if (preg_match("~\\.xml~i", $file)) {
                                                    $media_type = 'text/xml';
                                                } else {
                                                    if (preg_match("~\\.zip~i", $file)) {
                                                        echo '<span style="color:yellow;">WARNING: There is a ZIP archive (' . $file . ') in your /fonts folder.  Consider removing it and run build again.</span><br/>';
                                                        $media_type = 'application/zip';
                                                    } else {
                                                        $media_type = 'unknown';
                                                        echo '<span style="color:red;">ERROR: ' . $file . ' in the fonts folder unknown media-type.  This invalidates the ePub.  Please fix it and try again!</span><br/>';
                                                        return;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $manifest = $manifest . "" . manifest_Build('font', $file, $media_type, $m) . "";
            $m++;
        }
    } else {
        if (file_exists($tmp . 'fonts')) {
            deleteAll($tmp . 'fonts', true);
        }
    }
    echo '<span style="font-weight:bold;color:limegreen;">**** BUILDING ePUB ****</span><br/>';
    ePubFiles('', 'nav.xhtml', $nav_end_content);
    ePubFiles('', 'toc.ncx', $toc_ncx_content);
    if ($cover_page_content != "") {
        ePubFiles('', 'cover.xhtml', $cover_page_content);
    }
    if ($title_page != "") {
        ePubFiles('', 'title.xhtml', $title_page);
    }
    if ($toc_page != "") {
        ePubFiles('', 'contents.xhtml', $toc_page);
    }
    $epub_html = closeTags($epub_html);
    for ($e = 0; $e < count($epub_html); $e++) {
        ePubFiles('', 'page' . $e . '.xhtml', $epub_html[$e]);
    }
    if ($images_folder != "") {
        if (!file_exists($MY_PATH[0] . 'images/' . $images_folder)) {
            echo '<span style="color:red;">ERROR: Images sub-folder does not exist!  No images are included in this ePub.</span><br/>';
        } else {
            // File exists, yay!
            echo 'DONE<br/>Copying issue-specific images subdirectory ' . $images_folder . '. . .';
            recurse_copy($MY_PATH[0] . 'images/' . $images_folder, $MY_PATH[0] . 'tmp/images/' . $images_folder);
            echo 'DONE<br/>';
            $m = 0;
            foreach (ListFiles('../../../images/' . $images_folder . '') as $key => $file) {
                $file = preg_replace("~../../../~", "", $file);
                if (preg_match("~\\.jpg~i", $file) || preg_match("~\\.jpeg~i", $file)) {
                    $media_type = 'image/jpeg';
                } else {
                    if (preg_match("~\\.png~i", $file)) {
                        $media_type = 'image/png';
                    } else {
                        if (preg_match("~\\.gif~i", $file)) {
                            $media_type = 'image/gif';
                        } else {
                            if (preg_match("~\\.svg~i", $file)) {
                                $media_type = 'image/svg+xml';
                            } else {
                                if (preg_match("~\\.htm~i", $file) || preg_match("~\\.html~i", $file)) {
                                    $media_type = 'application/xhtml+xml';
                                } else {
                                    if (preg_match("~\\.css~i", $file)) {
                                        $media_type = 'text/css';
                                    } else {
                                        if (preg_match("~\\.txt~i", $file)) {
                                            $media_type = 'text/plain';
                                        } else {
                                            if (preg_match("~\\.rtf~i", $file)) {
                                                $media_type = 'text/richtext';
                                            } else {
                                                if (preg_match("~\\.xml~i", $file)) {
                                                    $media_type = 'text/xml';
                                                } else {
                                                    $media_type = 'unknown';
                                                    echo '<span style="color:red;">ERROR: ' . $file . ' in the images folder unknown media-type.  This invalidates the ePub.  Please fix it and try again!</span><br/>';
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                $manifest = $manifest . manifest_Build('image', $file, $media_type, $m);
                $m++;
            }
        }
    } else {
        if (file_exists($tmp . 'images')) {
            deleteAll($tmp . 'images', true);
        }
        echo '<span style="color:yellow;">WARNING: No images sub-folder set!  No images are included in this ePub.</span><br/>';
    }
    if ($styles_name != "") {
        echo 'Copying ' . $styles_name . ' to ePub Package<br/>';
        copy($MY_PATH[0] . 'css/' . $styles_name, $MY_PATH[0] . 'tmp/css/' . $styles_name);
    }
    if ($myCSSfile == '1') {
        echo 'Copying ' . $myCSSname . ' file into package /css</br/>';
        if (!copy($MY_PATH[0] . 'js/' . $myCSSname, $MY_PATH[0] . 'tmp/css/' . $myCSSname)) {
            echo 'File could not be copied (either missing, wrong name, or destination is not writable)';
        }
    }
    ePubFiles('', 'content.opf', $content_opf_a . $manifest . $content_opf_b);
    $epubname = $_POST['mytitle'];
    $epubname = preg_replace("/[^\\w\\.-]/", "-", strtolower($epubname));
    $epubname = $epubname . '_ops_' . date_timestamp_get(date_create()) . '.epub';
    createArchive($MY_PATH[0], 'tmp/', $epubname);
}
function updateResturant($id)
{
    $request = Slim::getInstance()->request();
    $body = json_decode($request->getBody());
    //print_r($body);exit;
    $id = $body->id;
    if (isset($body->id)) {
        unset($body->id);
    }
    if (isset($body->category_id)) {
        $categories = $body->category_id;
    }
    if (isset($body->image_url)) {
        unset($body->image_url);
    }
    unset($body->category_id);
    //unset($body->is_active);
    if (!empty($body->logo)) {
        file_put_contents('./restaurant_images/' . $body->logo->filename, base64_decode($body->logo->base64));
        $body->logo = $body->logo->filename;
    } else {
        unset($body->logo);
    }
    unset($body->image);
    $allinfo['save_data'] = $body;
    //$allinfo['unique_data'] = $unique_field;
    $location_details = edit(json_encode($allinfo), 'restaurants', $id);
    //$location_details  = add(json_encode($allinfo),'restaurants');
    if (!empty($location_details)) {
        /* $user_details = add(json_encode($allinfo),'coupons');
           $user_details = json_decode($user_details);*/
        $restaurant_details = json_decode($location_details);
        //var_dump($location_details);
        //exit;
        deleteAll('resturant_category_map', array('restaurant_id' => $id));
        foreach ($categories as $category) {
            $temp = array();
            $temp['restaurant_id'] = $restaurant_details->id;
            $temp['category_id'] = $category->id;
            $data = add(json_encode(array('save_data' => $temp)), 'resturant_category_map');
            //echo $data;
        }
        $result = '{"type":"success","message":"Updated Succesfully"}';
    } else {
        $result = '{"type":"error","message":"Not Added"}';
    }
    echo $result;
}
Example #18
0
    foreach ($items as $item) {
        $delete = $es->delete(['index' => $index, 'type' => $type, 'id' => $item['_id']]);
    }
}
if (isset($_SESSION['email']) && $_SESSION['email'] === '*****@*****.**') {
    if (!empty($origIndex)) {
        if (!empty($origType)) {
            //Get items in current index/type
            $items = getItems($origIndex, $origType);
            if (isset($items['hits']['hits'])) {
                echo "Backing up " . $items['hits']['total'] . " items<br>";
                //Backup and delete current items
                $items = $items['hits']['hits'];
                duplicate($items, $newIndex, $newType);
                echo "Deleting items in original index<br>";
                deleteAll($items, $origIndex, $origType);
                //Delte original index
                echo "Deleting original index<br>";
                $delete = $es->indices()->deleteMapping(['index' => $origIndex, 'type' => $origType]);
                echo $origIndex . "/" . $origType . " successfully moved to " . $newIndex . "/" . $newType . "<br>";
                echo "<a href='moveIndex.php?origIndex=" . $newIndex . "&origType=" . $newType . "&newIndex=" . $origIndex . "&newType=" . $origType . "'>Undo move</a>";
            } else {
                echo "No documents found";
            }
        } else {
            echo "Please pass a type.";
        }
    } else {
        echo "Please pass an index.";
    }
} else {
Example #19
0
    if ($_REQUEST['operation'] == 'buttonopt') {
        importopt();
    } else {
        //$process = new Dbprocess();
        echo $_REQUEST['operation'];
        if ($_REQUEST['operation'] == 'buttonimport') {
            import($process);
        }
        if ($_REQUEST['operation'] == 'buttondelete') {
            //  	  deleteAll($process);
        }
        unset($process);
    }
} else {
    echo "1";
    if (isset($_POST['buttonopt'])) {
        importopt();
    } else {
        ///	echo 'isset(_POST[isImport])'.isset($_POST['buttonimport']);
        $process = new Dbprocess();
        //	print_r($_POST);
        //	 import($process);
        if (isset($_POST['buttonimport'])) {
            import($process);
        }
        if (isset($_POST['buttondelete'])) {
            deleteAll($process);
        }
        unset($process);
    }
}
Example #20
0
function buildPackage()
{
    // Default Var Values //
    $zine_include = 1;
    $ryuzine_src = 0;
    // Export Box
    $ryuzine_html = "";
    $ryuzine_name = 'index.htm';
    $images_src = 0;
    // full folder (any value other than zero deprecated!)
    $images_sub = "";
    // no sub-folder
    $keep_thumbs = 0;
    // keep editor thumbnail images
    $config_src = 0;
    // Existing File
    $config_code = "";
    $config_name = 'ryuzine.config.js';
    $styles_src = 0;
    // Existing File
    $styles_code = "";
    $styles_name = 'thisissue.css';
    $rack_include = 0;
    // Do not include
    $rack_name = "rack.htm";
    // not index file
    $rackcat_src = 0;
    // Existing File
    $rackcat_code = "";
    $rackcat_name = "catalog1.htm";
    $fonts_all = 1;
    $addons_all = 0;
    $themes_all = 0;
    $rackimgs_all = 1;
    $fonts_add = array();
    // holds actual check value
    $fonts = glob('../../fonts/*', GLOB_ONLYDIR);
    // strip out relative path
    for ($f = 0; $f < count($fonts); $f++) {
        $fonts[$f] = preg_replace("~../../fonts/~", "", $fonts[$f]);
        $fonts_add[] = $_POST['font_' . $fonts[$f] . ''];
    }
    $loose_fonts_add = array();
    // holds actual check value
    $loose_fonts_input = array();
    $loose_fonts = glob('../../fonts/{*.eot,*.svg,*.ttf,*.woff,*.otf}', GLOB_BRACE);
    // strip out relative path
    for ($f = 0; $f < count($loose_fonts); $f++) {
        $loose_fonts[$f] = preg_replace("~../../fonts/~", "", $loose_fonts[$f]);
        $loose_fonts_input[] = str_replace('.', '_', $loose_fonts[$f]);
        $loose_fonts_add[] = $_POST['loose_font_' . $loose_fonts_input[$f] . ''];
    }
    $addon_add = array();
    // holds the actual check value
    $addons = glob('../../ryuzine/addons/*', GLOB_ONLYDIR);
    // strip out relative path
    for ($a = 0; $a < count($addons); $a++) {
        $addons[$a] = preg_replace("~../../ryuzine/addons/~", "", $addons[$a]);
        $addon_add[] = $_POST['add_' . $addons[$a] . ''];
    }
    $theme_add = array();
    // holds the actual check value
    $themes = glob('../../ryuzine/theme/*', GLOB_ONLYDIR);
    // strip out relative path
    for ($t = 0; $t < count($themes); $t++) {
        $themes[$t] = preg_replace("~../../ryuzine/theme/~", "", $themes[$t]);
        $theme_add[] = $_POST['theme_' . $themes[$t] . ''];
    }
    $rackcats_add = array();
    // holds actual checked value
    $rackcats = glob('../../data/*', GLOB_BRACE);
    // strip out relative path
    for ($r = 0; $r < count($rackcats); $r++) {
        $rackcats[$r] = preg_replace("~../../data/~", "", $rackcats[$r]);
        $rackcats_add[] = $_POST['cat_' . preg_replace("~.htm~", "", $rackcats[$r]) . ''];
    }
    $rackimgs_add = array();
    // hold actual checked value
    $rackimgs = glob('../../images/rack/*', GLOB_ONLYDIR);
    // strip out relative path
    for ($r = 0; $r < count($rackimgs); $r++) {
        $rackimgs[$r] = preg_replace("~../../images/rack/~", "", $rackimgs[$r]);
        $rackimgs_add[] = $_POST['rackimg_' . $rackimgs[$r] . ''];
    }
    $myJSfile = 0;
    // no custom file
    $myJSname = "";
    $myCSSfile = 0;
    // no custom file
    $myCSSname = "";
    $source_include = 0;
    // Do not include source code
    if ($_POST['zineadd'] == '1') {
        // Package should include a publication
        $zine_include = 1;
        if ($_POST['packfile_src'] == '0') {
            if ($_POST['packfile_content'] == "" || $_POST['packfile_content'] == "Ryuzine File HTML code will be in this box.") {
                echo '<span style="color:red;">ERROR: HTML Export Box is empty!  Go to Editor, Build file, and then Package.</span><br/>';
                return;
            }
            $ryuzine_src = 0;
            $ryuzine_html = $_POST['packfile_content'];
            $ryuzine_name = $_POST['packfile_name'];
        } else {
            $ryuzine_src = $_POST['packfile_src'];
            $ryuzine_html = "";
            $ryuzine_name = $_POST['packfile_name'];
        }
        // Get or set stylesheet
        if ($_POST['cssfile_src'] == '0') {
            $styles_src = 0;
            $styles_code = "";
            $style_name = $_POST['cssfile_name'];
        } else {
            if ($_POST['cssfile_src'] == '1') {
                if ($_POST['cssfile_content'] == "" || $_POST['cssfile_content'] == "Custom Styles: Copy & Paste contents into your file thisissue.css") {
                    echo '<span style="color:red;">ERROR: No CSS code to write into file!</span><br/>';
                } else {
                    $styles_src = 1;
                    $styles_code = $_POST['cssfile_content'];
                    $styles_name = $_POST['cssfile_name'];
                }
            } else {
                $styles_src = $_POST['cssfile_src'];
                $styles_code = "";
                $styles_name = $_POST['cssfile_name'];
            }
        }
        if ($_POST['imagefile_src'] == '1') {
            $images_src = 1;
            $images_sub = $_POST['imagefolder_name'];
        }
        if ($_POST['allrackimages'] == '1') {
            $rackimgs_all = 1;
        } else {
            $rackimgs_all = 0;
        }
    } else {
        $zine_include = 0;
    }
    if ($_POST['rackadd'] == '1') {
        // Package should include Ryuzine Rack
        $rack_include = 1;
        if ($_POST['rackfile'] == '1') {
            $rack_name = "index.htm";
            if ($ryuzine_name == 'index.htm') {
                $ryuzine_name = "issue.htm";
            }
        }
        if ($_POST['catfile_src'] == '0') {
            $rackcat_src = 0;
        } else {
            if ($_POST['catfile_src'] == '1') {
                if ($_POST['catfile_content'] == "" || $_POST['catafile_content'] == "RyuzineRack Data Catalog Code will be in this box.") {
                    echo '<span style="color:red;">ERROR: Rack Data Export box is empty!  No data to write to file. Will copy all files in <i>data/cat/</i></span><br/>';
                } else {
                    $rackcat_src = 1;
                    $rackcat_code = $_POST['catfile_content'];
                    $rackcat_name = $_POST['catfile_name'];
                }
            } else {
                $rackcat_src = 2;
                $rackcat_code = "";
                $rackcat_name = "";
            }
        }
    } else {
        $rack_include = 0;
    }
    // No matter what package is selected it needs a config file
    if ($_POST['configfile_src'] == '0') {
        $config_src = 0;
        $config_code = "";
        $config_name = $_POST['configfile_name'];
    } else {
        if ($_POST['configfile_src'] == '1') {
            if ($_POST['configfile_content'] == "" || $_POST['configfile_content'] == "// Custom Configuration File Javascript Code: //") {
                echo '<span style="color:red;">ERROR: No code in Config Export Box.  Using default file.</span><br/>';
                $config_src = 0;
                $config_code = "";
                $config_name = $_POST['configfile_name'];
            } else {
                $config_src = 1;
                $config_code = $_POST['configfile_content'];
                $config_name = $_POST['configfile_name'];
            }
        } else {
            $config_src = $_POST['configfile_src'];
            $config_code = "";
            $config_name = $_POST['configfile_name'];
        }
    }
    if ($_POST['packtype'] == '0') {
        // smallest package
        $fonts_all = 0;
        $addons_all = 0;
        $themes_all = 0;
        $myJSfile = 0;
        $myCSSfile = 0;
        $source_include = 0;
    } else {
        if ($_POST['packtype'] == '2') {
            // custom package
            if ($_POST['allfonts'] == '1') {
                $fonts_all = 1;
            } else {
                $fonts_all = 0;
            }
            if ($_POST['alladdons'] == '1') {
                $addons_all = 1;
            } else {
                $addons_all = 0;
            }
            if ($_POST['allthemes'] == '1') {
                $themes_all = 1;
            } else {
                $themes_all = 0;
            }
            if ($_POST['customJSadd'] == '1') {
                $myJSfile = 1;
                $myJSname = $_POST['customJSfile_name'];
            } else {
                $myJSfile = 0;
                $myJSname = "";
            }
            if ($_POST['customCSSadd'] == '1') {
                $myCSSfile = 1;
                $myCSSname = $_POST['customCSSfile_name'];
            } else {
                $myCSSfile = 0;
                $myCSSname = "";
            }
            $keep_thumbs = $_POST['keep_thumbs'];
            $source_include = $_POST['sourceadd'];
        } else {
            if ($_POST['packtype'] == '1') {
                // standard package
                $addons_all = 1;
                $themes_all = 1;
            } else {
                echo '<span style="color:red;font-weight:bold;">ERROR: PACKAGE TYPE UNKNOWN!</span><br/>';
                return;
            }
        }
    }
    /*******************
    	 Now that variables are set let's build some stuff!
    ********************/
    // check if temp directory exists or not, if not create it //
    $MY_PATH = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'];
    $MY_PATH = explode('ryuzinewriter/php/', $MY_PATH);
    if (is_writable($MY_PATH[0])) {
        $tmp = $MY_PATH[0] . 'tmp';
        if (!file_exists($tmp)) {
            mkdir($tmp, 0777);
        } else {
            deleteAll($tmp, true);
        }
    } else {
        echo '<script type="text/javascript">alert(\'ERROR: Dev Folder is not writable!\\nPACKAGE COULD NOT BE BUILT\\nCheck folder permissions and try again.\');</script>';
        return;
    }
    // Now populate tmp folder with Ryuzine Webapp //
    //	$_ryuzine= $MY_PATH[0].'tmp/ryuzine';
    // Copy Core Files to Package //
    echo 'Copying Ryuzine webapps to Package. . .';
    recurse_copy($MY_PATH[0] . 'ryuzine', $MY_PATH[0] . 'tmp/ryuzine');
    echo 'Core files DONE!<br/>';
    if ($_POST['packtype'] != '1') {
        // empty addon and theme folders
        deleteAll($MY_PATH[0] . 'tmp/ryuzine/addons', true);
        deleteAll($MY_PATH[0] . 'tmp/ryuzine/theme', true);
        // add back required files
        recurse_copy($MY_PATH[0] . 'ryuzine/addons/socialwidget', $MY_PATH[0] . 'tmp/ryuzine/addons/socialwidget');
        recurse_copy($MY_PATH[0] . 'ryuzine/theme/light', $MY_PATH[0] . 'tmp/ryuzine/theme/light');
        recurse_copy($MY_PATH[0] . 'ryuzine/theme/dark', $MY_PATH[0] . 'tmp/ryuzine/theme/dark');
    }
    if ($_POST['packtype'] == '2') {
        // copy All or Selected Add-Ons
        if ($addons_all == '1') {
            echo 'Copying entire ADDONS directory into Package. . .';
            recurse_copy($MY_PATH[0] . 'ryuzine/addons', $MY_PATH[0] . 'tmp/ryuzine/addons');
            echo 'DONE<br/>';
        } else {
            for ($a = 0; $a < count($addons); $a++) {
                if ($addon_add[$a] == '1') {
                    echo 'Copying ' . $addons[$a] . ' directory to package. . .';
                    recurse_copy($MY_PATH[0] . 'ryuzine/addons/' . $addons[$a] . '', $MY_PATH[0] . 'tmp/ryuzine/addons/' . $addons[$a] . '');
                    echo 'DONE<br/>';
                }
            }
        }
        // copy All or selected Themes
        if ($themes_all == '1') {
            echo 'Copy ALL THEMES to Package. . .';
            recurse_copy($MY_PATH[0] . 'ryuzine/theme', $MY_PATH[0] . 'tmp/ryuzine/theme');
            echo 'DONE<br/>';
        } else {
            for ($t = 0; $t < count($themes); $t++) {
                if ($theme_add[$t] == '1') {
                    echo 'Copying ' . $themes[$t] . ' theme to package. . .';
                    recurse_copy($MY_PATH[0] . 'ryuzine/theme/' . $themes[$t] . '', $MY_PATH[0] . 'tmp/ryuzine/theme/' . $themes[$t] . '');
                    echo 'DONE<br/>';
                }
            }
        }
    }
    // And now the Issue-Specific Folders
    $_css = $MY_PATH[0] . 'tmp/css';
    $_data = $MY_PATH[0] . 'tmp/data';
    $_fonts = $MY_PATH[0] . 'tmp/fonts';
    $_images = $MY_PATH[0] . 'tmp/images';
    $_js = $MY_PATH[0] . 'tmp/js';
    echo 'Building Issue folders. . .';
    if (!file_exists($_css)) {
        mkdir($_css, 0777);
    }
    if (!file_exists($_data)) {
        mkdir($_data, 0777);
    }
    if (!file_exists($_images)) {
        mkdir($_images, 0777);
    }
    if (!file_exists($_js)) {
        mkdir($_js, 0777);
    }
    echo 'DONE<br/>';
    echo '<span style="font-weight:bold;color:limegreen;">**** BUILDING PACKAGE ****</span><br/>';
    copy($MY_PATH[0] . 'css/blank.css', $MY_PATH[0] . 'tmp/css/blank.css');
    copy($MY_PATH[0] . 'css/simplestyles.css', $MY_PATH[0] . 'tmp/css/simplestyles.css');
    if ($fonts_all == '1') {
        echo 'Copy ALL FONTS to Package. . .';
        recurse_copy($MY_PATH[0] . 'fonts', $MY_PATH[0] . 'tmp/fonts');
        echo 'DONE<br/>';
    } else {
        if ($fonts_all == '0' && $_POST['packtype'] == '2') {
            if (!file_exists($_fonts)) {
                mkdir($_fonts, 0777);
            }
            for ($f = 0; $f < count($fonts); $f++) {
                if ($fonts_add[$f] == '1') {
                    echo 'Copying ' . $fonts[$f] . ' font folder to package. . .';
                    recurse_copy($MY_PATH[0] . 'fonts/' . $fonts[$f] . '', $MY_PATH[0] . 'tmp/fonts/' . $fonts[$f] . '');
                    echo 'DONE<br/>';
                }
            }
            for ($f = 0; $f < count($loose_fonts); $f++) {
                if ($loose_fonts_add[$f] == '1') {
                    echo 'Copying ' . $loose_fonts[$f] . ' font to package. . .';
                    copy($MY_PATH[0] . 'fonts/' . $loose_fonts[$f], $MY_PATH[0] . 'tmp/fonts/' . $loose_fonts[$f]);
                    echo 'DONE<br/>';
                }
            }
        } else {
            echo 'Custom Fonts will not be included in this package.<br/>';
        }
    }
    if ($zine_include == '1') {
        // Save Publication File HTML
        if ($ryuzine_src == '0') {
            // Export Box
            echo 'Ryuzine file does not exist.<br/>';
            echo 'Writing HTML Export code into a file named ' . $ryuzine_name . '. . .';
            saveRyuzine(5, $ryuzine_name, $ryuzine_html, 1);
            echo 'DONE<br/>';
        } else {
            echo 'Ryuzine file already exists!<br/>';
            echo 'copying ' . $ryuzine_src . ' to Package as ' . $ryuzine_name . '<br/>';
            copy($MY_PATH[0] . $ryuzine_src, $MY_PATH[0] . 'tmp/' . $ryuzine_name);
        }
        // Copy Publication Stylesheet
        if ($styles_src == '0') {
            // Existing File
            echo 'Copying default thississue.css file to package<br/>';
            copy($MY_PATH[0] . 'ryuzine/css/thisissue.css', $MY_PATH[0] . 'tmp/css/' . $styles_name);
        } else {
            if ($styles_src == '1') {
                echo 'Issue-Specific Styles do not exist.<br/>';
                echo 'Writing CSS Export Box code into file named ' . $styles_name . '. . .';
                saveRyuzine(6, $styles_name, $styles_code, 1);
                echo 'DONE<br/>';
            } else {
                echo 'Copying ' . $styles_src . ' to Package as ' . $styles_name . '<br/>';
                copy($MY_PATH[0] . 'css/' . $styles_src, $MY_PATH[0] . 'tmp/css/' . $styles_name);
            }
        }
        // Copy Publication Image Folder
        echo 'DONE<br/>Coping issue-specific images subdirectory ' . $images_sub . '. . .';
        recurse_copy($MY_PATH[0] . 'images/' . $images_sub, $MY_PATH[0] . 'tmp/images/' . $images_sub);
        echo 'DONE<br/>';
        // clear out editor thumbnails
        if ($keep_thumbs == 0) {
            deleteAll($MY_PATH[0] . 'tmp/images/' . $images_sub . '/thumbs', false);
        }
    }
    //  If Include Rack is checked make sure catalog and images are included in package
    if ($rack_include == '1') {
        echo 'Ryuzine Rack will be included in package as ' . $rack_name . '.<br/>';
        // prefer possible edited version, but if not found use default rack HTML file
        if (!file_exists($MY_PATH[0] . 'rack.htm')) {
            copy($MY_PATH[0] . 'ryuzine/res/rack.htm', $MY_PATH[0] . 'tmp/' . $rack_name);
        } else {
            copy($MY_PATH[0] . 'rack.htm', $MY_PATH[0] . 'tmp/' . $rack_name);
        }
        echo 'DONE<br/>Copying Ryuzine Rack images to package. . .';
        if ($rackimgs_all == '1') {
            recurse_copy($MY_PATH[0] . 'images/rack', $MY_PATH[0] . 'tmp/images/rack');
            echo 'DONE<br/>';
        } else {
            for ($i = 0; $i < count($rackimgs); $i++) {
                if ($rackimgs_add[$i] == '1') {
                    echo 'Copying ' . $rackimgs[$i] . ' directory to package. . .';
                    recurse_copy($MY_PATH[0] . 'images/rack/' . $rackimgs[$i] . '', $MY_PATH[0] . 'tmp/images/rack/' . $rackimgs[$i] . '');
                    echo 'DONE<br/>';
                }
            }
        }
        if ($rackcat_src == '0') {
            echo 'Copying all catalogs in data/ folder to Package. . .';
            recurse_copy($MY_PATH[0] . 'data', $MY_PATH[0] . 'tmp/data');
            echo 'DONE<br/>';
        } else {
            if ($rackcat_src == '1') {
                echo 'Catalog file does not exist.<br/>';
                echo 'Writing Data Export code into file named ' . $rackcat_name . '. . .';
                saveRyuzine(8, $rackcat_name, $rackcat_code, 1);
                echo 'DONE<br/>';
            } else {
                for ($r = 0; $r < count($rackcats); $r++) {
                    if ($rackcats_add[$r] == '1') {
                        echo 'Copying ' . $rackcats[$r] . ' catalog to package. . .';
                        copy($MY_PATH[0] . 'data/' . $rackcats[$r] . '', $MY_PATH[0] . 'tmp/data/' . $rackcats[$r] . '');
                        echo 'DONE<br/>';
                    }
                }
            }
        }
    } else {
        echo 'Ryuzine Rack will NOT be included in this package<br/>';
        echo 'DELETING files and folder related to Ryuzine Rack from webapp...';
        deleteAll($MY_PATH[0] . 'tmp/data', false);
        unlink($MY_PATH[0] . 'tmp/ryuzine/css/rackdetail.css');
        unlink($MY_PATH[0] . 'tmp/ryuzine/css/rackgrid.css');
        unlink($MY_PATH[0] . 'tmp/ryuzine/css/racklist.css');
        unlink($MY_PATH[0] . 'tmp/ryuzine/js/ryuzine.rack.js');
        echo 'DONE<br/>';
    }
    //  Copy or Create Issue-specific Configuration File
    if ($config_src == '0') {
        echo 'Copying default ryuzine.config.js to package. . .';
        copy($MY_PATH[0] . 'js/ryuzine.config.js', $MY_PATH[0] . 'tmp/js/' . $config_name);
        echo 'DONE<br/>';
    } else {
        if ($config_src == '1') {
            echo 'Config file does not exist.<br/>';
            echo 'Writing Config Export code into a file named ' . $config_name . '...';
            saveRyuzine(7, $config_name, $config_code, 1);
            echo 'DONE<br/>';
        } else {
            echo 'Copy config file ' . $config_src . ' to Package as ' . $config_name . ' <br/>';
            copy($MY_PATH[0] . 'js/' . $config_src, $MY_PATH[0] . 'tmp/js/' . $config_name);
        }
    }
    if ($myJSfile == '1') {
        echo 'Copying ' . $myJSname . ' file into package /js<br/>';
        if (!copy($MY_PATH[0] . 'js/' . $myJSname, $MY_PATH[0] . 'tmp/js/' . $myJSname)) {
            echo 'File could not be copied (either missing, wrong name, or destination is not writable)';
        }
    }
    if ($myCSSfile == '1') {
        echo 'Copying ' . $myCSSname . ' file into package /css</br/>';
        if (!copy($MY_PATH[0] . 'js/' . $myCSSname, $MY_PATH[0] . 'tmp/css/' . $myCSSname)) {
            echo 'File could not be copied (either missing, wrong name, or destination is not writable)';
        }
    }
    // Unless it is a Custom Package explicitly including source code, remove those files
    if ($source_include == '0') {
        echo 'Cleaning up...';
        deleteAll($MY_PATH[0] . 'tmp/ryuzine/css/src', false);
        deleteAll($MY_PATH[0] . 'tmp/ryuzine/js/src', false);
        deleteAll($MY_PATH[0] . 'tmp/ryuzine/res', false);
        echo 'DONE<br/>';
    }
    if ($_POST['time_stamp'] == '1') {
        $timestamp = '_' . date_timestamp_get(date_create());
    } else {
        $timestamp = '';
    }
    if ($_POST['skip_zip'] == '1') {
        echo '<b>Package contents set. <span style="color:red">ZIP Archiving is disabled...</span></b><br/>';
        $dirname = $_POST['mytitle'];
        $dirname = preg_replace("/[^\\w\\.-]/", "-", strtolower($dirname));
        $dirpath = $MY_PATH[0] . $dirname . '_Ryuzine' . $timestamp;
        if (!file_exists($dirpath)) {
            mkdir($dirpath, 0777);
        } else {
            deleteAll($dirpath, true);
        }
        echo 'Attempting to copy contents to ' . $dirpath . '<br/>';
        recurse_copy($MY_PATH[0] . 'tmp', $dirpath);
        echo '<p>DONE.  The package folder should be available in your Ryuzine Development directory on the server.<br/>';
    } else {
        echo '<b>Package contents set.  Now will attempt to ZIP. . .</b><br/>';
        $zipname = $_POST['mytitle'];
        $zipname = preg_replace("/[^\\w\\.-]/", "-", strtolower($zipname));
        $zippath = $zipname . '_Ryuzine' . $timestamp . '.zip';
        Zip($MY_PATH[0] . 'tmp/', $MY_PATH[0] . $zippath);
        global $AUTO_DOWNLOAD;
        if ($AUTO_DOWNLOAD == 1) {
            echo 'Attempting to automatically download file to your computer<br/>';
            echo '<iframe height="1" width="1" src="../../' . $zippath . '" style="display:none;"></iframe>';
            echo 'Ok, if the file is not in your downloads folder something went wrong :(<br/>';
        } else {
            // Download link in Output Console //
            echo '<p><strong><a href="../../' . $zippath . '">Click to download ZIP file ' . $zippath . '</a><strong></p>';
        }
    }
}
function deleteUser($id)
{
    $result = delete('users', $id);
    deleteAll('merchant_location_map', array('user_id' => $id));
    deleteAll('merchant_category_map', array('user_id' => $id));
    echo $result;
}
 /**
  * 下载文件
  */
 public function download_site()
 {
     $site_id = I('site_id', session('site_info.id'));
     if (empty($site_id)) {
         return $this->error('请选择网站');
     }
     $site_info = M()->table('site_info')->field('site_name,url,json')->where(array('id' => $site_id, 'user_id' => session('user_info.id'), 'status' => 0))->find();
     if (empty($site_info)) {
         return $this->error('此网站无效');
     }
     $info = M()->table('user_column')->where(array('site_id' => $site_id, 'forbidden' => 0))->order('sort')->select();
     if (empty($info)) {
         return $this->error('没有找到文件');
     }
     $rootpath = C('TEMP_DIR') . $site_info['url'] . "/";
     if (is_dir($rootpath)) {
         deleteAll($rootpath, true);
     } elseif (!mkdir($rootpath)) {
         return $this->error('创建根目录失败');
     }
     $public_rootpath = $rootpath . "Public/";
     if (!mkdir($public_rootpath)) {
         return $this->error('创建Public目录失败');
     }
     /*=================================生成html==============================*/
     $html_rootpath = $rootpath . "html/";
     if (!mkdir($html_rootpath)) {
         return $this->error('创建html目录失败');
     }
     $user_info = M()->table('user_info')->field('nickname,head_img')->find(session('user_info')['id']);
     $site_common = A('Panel')->get_site_common($site_id);
     $theme_templet = $site_common['theme_templet'];
     unset($site_common['theme_templet']);
     $this->collect_link($site_common['theme_links']);
     //var_dump($site_common['theme_links']);
     $this->assign($site_common);
     $this->assign('user_info', $user_info);
     $this->assign('download', true);
     /*==================生成栏目页===================*/
     foreach ($info as $key => $value) {
         $widget_common = A('Panel')->resolve_json($site_id, $value['html']);
         $this->collect_link($widget_common['links']);
         $links = array_merge_recursive($site_common['theme_links'], $widget_common['links']);
         $this->assign($links);
         $this->assign('now_column', $value['id']);
         $this->assign('content', $widget_common['content']);
         $html = $this->fetch('Theme/theme');
         $html = $this->replaceHtml($html);
         $result = file_put_contents($html_rootpath . $value['url'] . '.html', $html);
         if (!$result) {
             ////***删除文件**///
             deleteAll($rootpath);
             return $this->error('下载失败:html失败');
         }
     }
     /*==================生成详情页===================*/
     $desc = json_decode($site_info['json'], true);
     foreach ($desc as $key => $value) {
         $desc_info = D($key)->get_all_info($site_id);
         $desc_path = $rootpath . '/' . $key . '/';
         if (!mkdir($desc_path)) {
             deleteAll($rootpath);
             return $this->error('创建$key目录失败');
         }
         $widget = A('Panel')->load_widget(ucwords(strtolower($key)) . 'Desc', $value);
         $widget_link = $widget->load_template_link();
         $this->collect_link($widget_link, $rootpath);
         $links = array_merge_recursive($site_common['theme_links'], $widget_link);
         $this->assign($links);
         foreach ($desc_info as $desc_key => $desc_resource) {
             ob_start();
             ob_implicit_flush(0);
             $widget->index($site_id, null, $desc_resource);
             $content = ob_get_clean();
             \Think\Hook::listen('view_filter', $content);
             $this->assign('content', $content);
             $html = $this->fetch('Theme/theme');
             $html = $this->replaceHtml($html);
             $result = file_put_contents($desc_path . $desc_resource['id'] . '.html', $html);
             if (!$result) {
                 ////***删除文件**///
                 deleteAll($rootpath);
                 return $this->error('下载失败:article失败');
             }
         }
     }
     /*=================================引入资源文件==============================*/
     /*=============引入js css=============*/
     $this->download_theme_link($public_rootpath, $site_common['site_ifno']['theme']);
     $this->download_widget_link($public_rootpath);
     /*=============引入img=============*/
     $img_path = $rootpath . 'Uploads/';
     $photo_info = M()->table('photo as a')->field('c.savename,c.savepath')->join('home_picture as c on a.pic_id = c.id')->where(array('a.site_id' => $site_id))->select();
     $admin_column_info = M()->table('user_column as a')->field('b.savename,b.savepath')->join('left join picture as b on a.icon = b.id')->where(array('a.site_id' => $site_id, 'a.is_default' => 1))->select();
     $home_column_info = M()->table('user_column as a')->field('b.savename,b.savepath')->join('left join home_picture as b on a.icon = b.id')->where(array('a.site_id' => $site_id, 'a.is_default' => 0))->select();
     $article_info = M()->table('article as a')->field('b.savename,b.savepath')->join('left join home_picture as b on a.pic_id = b.id')->where(array('a.site_id' => $site_id))->select();
     $img_info = array_merge($photo_info, $admin_column_info, $home_column_info, $article_info);
     $uploads_path = C('PICTURE_UPLOAD')['rootPath'];
     foreach ($img_info as $key => $value) {
         hCopy($uploads_path . $value['savepath'] . $value['savename'], $img_path . $value['savepath'] . $value['savename']);
     }
     /*========================生成zip==============================*/
     load("@.HZip#class");
     $zip_name = C('TEMP_DIR') . $site_info['url'] . '.zip';
     $zip = \HZip::zipDir(C('TEMP_DIR') . $site_info['url'], $zip_name);
     /*========================下载==================================*/
     header("Cache-Control: max-age=0");
     header("Content-Description: File Transfer");
     header('Content-disposition: attachment; filename=' . basename($zip_name));
     // 文件名
     header("Content-Type: application/zip");
     // zip格式的
     header("Content-Transfer-Encoding: binary");
     //二进制文件
     header('Content-Length: ' . filesize($zip_name));
     // 告诉浏览器,文件大小
     @readfile($zip_name);
     //输出文件;
     unlink($zip_name);
     deleteAll($rootpath);
 }
function deleteCartByUser($user_id)
{
    deleteAll('cart', array('user_id' => $user_id));
}